Skip to content

Commit

Permalink
fix: 🐛 default generator in manifest (#8)
Browse files Browse the repository at this point in the history
* fix: 🐛 default generator in manifest

* chore: 🤖 add changeset

* fix: 🐛 build

* test: 💍 default generator value

* chore: 🤖 revert the version changes
  • Loading branch information
theashraf authored May 8, 2023
1 parent 4ac5090 commit 9541d50
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-ears-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dotlottie/dotlottie-js": patch
---

fix: 🐛 default generator in manifest
4 changes: 3 additions & 1 deletion packages/dotlottie-js/src/common/dotlottie-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import type { Animation } from '@lottiefiles/lottie-types';

import pkg from '../../package.json';

import type { DotLottiePlugin } from './dotlottie-plugin';
import type { AnimationOptions, LottieAnimationCommon } from './lottie-animation-common';
import type { LottieImageCommon } from './lottie-image-common';
Expand Down Expand Up @@ -50,7 +52,7 @@ export class DotLottieCommon {

this._description = options?.description ?? '';

this._generator = options?.generator ?? 'dotLottie-js_v2.0';
this._generator = options?.generator ?? `${pkg.name}@${pkg.version}`;

this._keywords = options?.keywords ?? 'dotLottie';

Expand Down
1 change: 0 additions & 1 deletion packages/dotlottie-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2023 Design Barn Inc.
*/

// export * from './main';
export * from './dotlottie';
export * from './lottie-animation';
export * from './lottie-image';
8 changes: 7 additions & 1 deletion packages/dotlottie-js/src/node/dotlottie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Animation } from '@lottiefiles/lottie-types';
import type { Zippable } from 'fflate';
import { strToU8, unzip, zip, strFromU8 } from 'fflate';

import pkg from '../../package.json';
import { createError, DotLottieCommon } from '../common';
import type { DotLottieOptions, DotLottiePlugin, AnimationOptions } from '../common';

Expand All @@ -16,7 +17,12 @@ import { base64ToUint8Array, getExtensionTypeFromBase64 } from './utils';

export class DotLottie extends DotLottieCommon {
public constructor(options?: DotLottieOptions) {
super(options);
const generator = options?.generator ?? `${pkg.name}/node@${pkg.version}`;

super({
...options,
generator,
});

if (this.enableDuplicateImageOptimization) this.addPlugins(new DuplicateImageDetector());
}
Expand Down
7 changes: 7 additions & 0 deletions packages/dotlottie-js/src/tests/dotlottie-js-browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { Base64 } from 'js-base64';

import { DotLottie, LottieAnimation } from '..';
import pkg from '../../package.json';
import type { AnimationData, Manifest } from '../common';
import { DotLottiePlugin } from '../common';

Expand Down Expand Up @@ -108,6 +109,12 @@ describe('setGenerator', () => {

expect(dotlottie.generator).toBe(generator);
});

it('has proper generator when no input provided', () => {
const dotLottie = new DotLottie();

expect(dotLottie.generator).toBe(`${pkg.name}@${pkg.version}`);
});
});

describe('setKeywords', () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/dotlottie-js/src/tests/dotlottie-js-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { Base64 } from 'js-base64';

import pkg from '../../package.json';
import type { AnimationData, Manifest } from '../common';
import { DotLottiePlugin } from '../common';
import { DotLottie, LottieAnimation } from '../node';
Expand Down Expand Up @@ -108,6 +109,12 @@ describe('setGenerator', () => {

expect(dotlottie.generator).toBe(generator);
});

it('has proper generator when no input provided', () => {
const dotLottie = new DotLottie();

expect(dotLottie.generator).toBe(`${pkg.name}/node@${pkg.version}`);
});
});

describe('setKeywords', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dotlottie-js/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"outDir": "./dist",

// Source root directory
"rootDir": "./src"
"rootDir": "."
},

// Files included in compilation
Expand Down

0 comments on commit 9541d50

Please sign in to comment.