Visualize Your Ideas With Code
fix: fix meta file version and timing (#32)
Jacoba36961007eb7
diff --git a/bin/index.mjs b/bin/index.mjsindex 597b8b58..eaab1e9f 100644--- a/bin/index.mjs+++ b/bin/index.mjs@@ -41,6 +41,8 @@ if (cli.flags.uiServer) {}}+const META_VERSION = 1;+const projectFile = path.resolve(cli.input[0]);const renderOutput = path.resolve(cli.flags.output);const __dirname = path.dirname(fileURLToPath(import.meta.url));@@ -62,7 +64,7 @@ const compiler = webpack({before: [metaImportTransformer({project: projectFile,- version: packageJSON.version,+ version: META_VERSION,}),],}),@@ -129,6 +131,7 @@ const compiler = webpack({new webpack.DefinePlugin({PROJECT_FILE_NAME: `'${path.parse(projectFile).name}'`,CORE_VERSION: `'${packageJSON.version}'`,+ META_VERSION,}),new HtmlWebpackPlugin({title: 'Motion Canvas'}),new UIPlugin(cli.flags),diff --git a/src/Meta.ts b/src/Meta.tsindex 92d850ff..df2493b9 100644--- a/src/Meta.ts+++ b/src/Meta.ts@@ -28,7 +28,7 @@ export class Meta<T extends Metadata = Metadata> {private changed = new SimpleEventDispatcher<T>();private constructor() {- this.data = <T>{version: Meta.currentVersion};+ this.data = <T>{version: META_VERSION};}public getData(): T {@@ -62,7 +62,6 @@ export class Meta<T extends Metadata = Metadata> {}}- private static currentVersion = 1;private static metaLookup: Record<string, Meta> = {};/**@@ -101,7 +100,7 @@ export class Meta<T extends Metadata = Metadata> {return;}- data.version ??= Meta.currentVersion;+ data.version ??= META_VERSION;meta.source = source;meta.data = data;meta.changed.dispatch(data);diff --git a/src/TimeEvents.ts b/src/TimeEvents.tsindex 317e5ef0..2f13683e 100644--- a/src/TimeEvents.ts+++ b/src/TimeEvents.ts@@ -150,13 +150,13 @@ export class TimeEvents {}const offset = Math.max(0, event.targetTime - event.initialTime);- if (!this.preserveTiming && event.offset !== offset) {+ if (this.preserveTiming && event.offset !== offset) {event.offset = offset;changed = true;}const target = event.initialTime + event.offset;- if (this.preserveTiming && event.targetTime !== target) {+ if (!this.preserveTiming && event.targetTime !== target) {event.targetTime = target;changed = true;}diff --git a/src/globals.ts b/src/globals.tsindex f1b67d0a..6c49f42a 100644--- a/src/globals.ts+++ b/src/globals.ts@@ -57,3 +57,5 @@ declare type Callback = (...args: unknown[]) => void;declare const PROJECT_FILE_NAME: string;declare const CORE_VERSION: string;++declare const META_VERSION: number;