@tawaship/pixim-animate-runtime 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/pixim-animate-runtime.cjs.js +2 -2
- package/dist/pixim-animate-runtime.cjs.js.map +1 -1
- package/dist/pixim-animate-runtime.esm.js +2 -2
- package/dist/pixim-animate-runtime.esm.js.map +1 -1
- package/dist/pixim-animate-runtime.js +71 -7
- package/dist/pixim-animate-runtime.js.map +1 -1
- package/dist-skills/pixi-animate-runtime-guide/SKILL.md +2 -2
- package/dist-skills/pixim-animate-runtime-guide/SKILL.md +2 -2
- package/package.json +1 -1
- package/types/AnimateContainer.d.ts +1 -1
package/README.md
CHANGED
|
@@ -201,7 +201,8 @@ frame of the application plays the roots put on it with `addCreatejs`, at their
|
|
|
201
201
|
|
|
202
202
|
- `taskEnabled = false` stops playing; the container's `task` is free for your own use (clearing it does not
|
|
203
203
|
stop playing)
|
|
204
|
-
- `speed` changes the playback speed (`1` is the published frame rate, `0` stops
|
|
204
|
+
- `speed` changes the playback speed (`1` is the published frame rate, `0` stops; a value below `0` stops it as `0`
|
|
205
|
+
does). `overSpeed = false` plays at
|
|
205
206
|
most one frame per frame of the application
|
|
206
207
|
- `smooth` (`true` by default) keeps the playing even when the time between frames of the application varies a
|
|
207
208
|
little, while keeping to the real time, as described for pixi-animate-runtime. `false` plays by the time of
|
|
@@ -261,6 +262,13 @@ into the package on purpose to confirm that the comparison notices them.
|
|
|
261
262
|
|
|
262
263
|
## Change log
|
|
263
264
|
|
|
265
|
+
### 0.1.1
|
|
266
|
+
|
|
267
|
+
- A `speed` below `0` stops the playing as `0` does, and it goes on at once when the speed is above `0` again
|
|
268
|
+
- Built with pixi-animate-runtime 0.1.1: right after a goto made outside the playing (from a pointer event, for
|
|
269
|
+
example), synched and single frame clips, and clips coming back on the display list, are drawn as CreateJS shows
|
|
270
|
+
them from the first draw after the goto, not at their old frame until the content plays its next frame
|
|
271
|
+
|
|
264
272
|
### 0.1.0
|
|
265
273
|
|
|
266
274
|
- First release: loads runtime content as an asset of a Pixim content (`defineAnimateContentsTo`, `addAnimateContentsTo`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @tawaship/pixim-animate-runtime - v0.1.
|
|
2
|
+
* @tawaship/pixim-animate-runtime - v0.1.1
|
|
3
3
|
*
|
|
4
4
|
* @require pixi.js ^5.3.2
|
|
5
5
|
* @require @tawaship/pixim.js ^1.15.2
|
|
@@ -35,7 +35,7 @@ var AnimateContainer = /*@__PURE__*/(function (Container) {
|
|
|
35
35
|
AnimateContainer.prototype.constructor = AnimateContainer;
|
|
36
36
|
|
|
37
37
|
var prototypeAccessors = { speed: { configurable: true },overSpeed: { configurable: true },smooth: { configurable: true } };
|
|
38
|
-
/** Playback speed (1 is the content's own frame rate) */
|
|
38
|
+
/** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */
|
|
39
39
|
prototypeAccessors.speed.get = function () { return this._controller.speed; };
|
|
40
40
|
prototypeAccessors.speed.set = function (value) { this._controller.speed = value; };
|
|
41
41
|
/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixim-animate-runtime.cjs.js","sources":["../src/AnimateContainer.ts","../src/AnimateContentLoader.ts","../src/AnimateContentManifest.ts"],"sourcesContent":["import { Container, ITickerData } from '@tawaship/pixim.js';\nimport { AnimateController, DisplayObject } from '@tawaship/pixi-animate-runtime';\n\n/**\n * A Pixim container that plays the content roots put on it at their\n * content's frame rate (the rate the content was published with), while it is\n * on the display tree of a running Pixim application.\n *\n * Each frame of the application plays `delta x speed x fps / 60` frames of every\n * root (delta being the application ticker's), one frame being createjs's tick\n * phase followed by its resolve phase; the first frame after a root is put on\n * only settles it on its first frame. Playing stops while `taskEnabled` is\n * false. The container's own `task` is free for the application: what it holds\n * does not change the playing.\n */\nexport class AnimateContainer extends Container {\n\tprivate readonly _controller: AnimateController;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._controller = new AnimateController(this);\n\t}\n\n\t/** Playback speed (1 is the content's own frame rate) */\n\tget speed(): number { return this._controller.speed; }\n\tset speed(value: number) { this._controller.speed = value; }\n\n\t/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */\n\tget overSpeed(): boolean { return this._controller.overSpeed; }\n\tset overSpeed(value: boolean) { this._controller.overSpeed = value; }\n\n\t/** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */\n\tget smooth(): boolean { return this._controller.smooth; }\n\tset smooth(value: boolean) { this._controller.smooth = value; }\n\n\tupdateTask(e: ITickerData): void {\n\t\tsuper.updateTask(e);\n\t\tif (!this.taskEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._controller.handleTick(e.delta);\n\t}\n\n\t/** Plays the roots by hand, as one frame of the application with this delta does */\n\thandleTick(delta: number): void {\n\t\tthis._controller.handleTick(delta);\n\t}\n\n\t/** Puts a content object on this container; a MovieClip plays from then on */\n\taddCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.addCreatejs(obj);\n\t}\n\n\taddCreatejsAt<T extends DisplayObject>(obj: T, index: number): T {\n\t\treturn this._controller.addCreatejsAt(obj, index);\n\t}\n\n\tremoveCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.removeCreatejs(obj);\n\t}\n}\n","import { BlobLoader, BlobLoaderResource, ILoaderOption, JsLoader, LoaderBase, LoaderResource, TLoaderResourceVersion } from '@tawaship/pixim.js';\nimport { IContent, IContentManifestEntry, IContentTarget, loadContentAsync, resolveContentUrl } from '@tawaship/pixi-animate-runtime';\n\n/** A content to load: what loadContentAsync takes, and the runtime content file to load first */\nexport interface IAnimateContentLoaderTarget extends IContentTarget {\n\t/**\n\t * The runtime content file, relative to `basepath`. Loaded (as a script) before\n\t * the content when given; otherwise it has to be loaded already.\n\t */\n\tfilepath?: string;\n}\n\nexport interface IAnimateContentLoaderOption extends ILoaderOption {\n\t/** The version added to the runtime content file's URL (`version` when omitted) */\n\tfileVersion?: TLoaderResourceVersion;\n\t/** The version added to the image URLs (`version` when omitted) */\n\tassetVersion?: TLoaderResourceVersion;\n}\n\nexport class AnimateContentLoaderResource extends LoaderResource<IContent | null> {\n\tdestroy(): void {\n\t\tthis._data = null;\n\t}\n}\n\nfunction isUrl(src: string): boolean {\n\treturn src.indexOf('data:') !== 0 && src.indexOf('blob:') !== 0;\n}\n\n/**\n * Loads a content as a Pixim asset: its runtime content file (when a filepath\n * is given), then the content with loadContentAsync, the base path being the\n * Pixim content's and the target's together.\n *\n * With the Pixim content's `xhr` option, the images are fetched (with its\n * request options) into blob: URLs first, after the target's own\n * handleManifest; the blob: URLs are released once the content is loaded.\n */\nexport class AnimateContentLoader extends LoaderBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _loadAsync(target: IAnimateContentLoaderTarget, options: IAnimateContentLoaderOption = {}): Promise<AnimateContentLoaderResource> {\n\t\tconst basepath = resolveContentUrl(options.basepath || '', target.basepath || '');\n\t\treturn this._loadFileAsync(target, basepath, options)\n\t\t\t.then(() => this._loadContentAsync(target, basepath, options))\n\t\t\t.then(content => new AnimateContentLoaderResource(content, null))\n\t\t\t.catch((e: Error) => new AnimateContentLoaderResource(null, e));\n\t}\n\n\tprivate _loadFileAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<void> {\n\t\tif (!target.filepath) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new JsLoader().loadAsync(resolveContentUrl(basepath, target.filepath), { version: options.fileVersion || options.version, xhr: options.xhr })\n\t\t\t.then(resource => {\n\t\t\t\tif (resource.error) {\n\t\t\t\t\tthrow resource.error;\n\t\t\t\t}\n\t\t\t\tresource.ref();\n\t\t\t});\n\t}\n\n\tprivate _loadContentAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<IContent> {\n\t\tconst version = options.assetVersion || options.version;\n\t\tconst blobs: BlobLoaderResource[] = [];\n\t\tconst release = (): void => {\n\t\t\tblobs.forEach(blob => blob.destroy());\n\t\t};\n\t\tconst own = target.options && target.options.handleManifest;\n\t\tconst contentTarget: IContentTarget = {\n\t\t\tid: target.id,\n\t\t\tbasepath,\n\t\t\toptions: {\n\t\t\t\tcrossOrigin: target.options ? target.options.crossOrigin : undefined,\n\t\t\t\thandleManifest: (manifest: IContentManifestEntry[]) => {\n\t\t\t\t\treturn Promise.resolve(own ? own(manifest) : undefined)\n\t\t\t\t\t\t.then(() => options.xhr ? this._fetchImagesAsync(manifest, basepath, version, options, blobs) : undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn loadContentAsync(contentTarget, { version })\n\t\t\t.then(content => {\n\t\t\t\trelease();\n\t\t\t\treturn content;\n\t\t\t}, (e: Error) => {\n\t\t\t\trelease();\n\t\t\t\tthrow e;\n\t\t\t});\n\t}\n\n\t/** The images fetched into blob: URLs, which then stand for their files */\n\tprivate _fetchImagesAsync(manifest: IContentManifestEntry[], basepath: string, version: TLoaderResourceVersion | undefined, options: IAnimateContentLoaderOption, blobs: BlobLoaderResource[]): Promise<void> {\n\t\tconst targets: Record<string, string> = {};\n\t\tmanifest.forEach((entry, i) => {\n\t\t\tif (isUrl(entry.src)) {\n\t\t\t\ttargets[i] = resolveContentUrl(basepath, entry.src);\n\t\t\t}\n\t\t});\n\t\treturn new BlobLoader().loadAllAsync(targets, { version, xhr: options.xhr })\n\t\t\t.then(resources => {\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tblobs.push(resources[i]);\n\t\t\t\t});\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tconst resource = resources[i];\n\t\t\t\t\tif (resource.error) {\n\t\t\t\t\t\tthrow resource.error;\n\t\t\t\t\t}\n\t\t\t\t\tmanifest[Number(i)].src = resource.data;\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n","import { Content, IManifestOption, ManifestBase } from '@tawaship/pixim.js';\nimport { IContent } from '@tawaship/pixi-animate-runtime';\nimport { AnimateContentLoader, AnimateContentLoaderResource, IAnimateContentLoaderTarget } from './AnimateContentLoader';\n\n/** The key of the contents in a Pixim content's resources: `$.resources.animateContents` */\nexport const ANIMATE_CONTENTS = 'animateContents';\n\nexport class AnimateContentManifest extends ManifestBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _createLoader(): AnimateContentLoader {\n\t\treturn new AnimateContentLoader();\n\t}\n}\n\nContent.registerManifest(ANIMATE_CONTENTS, AnimateContentManifest);\n\n/**\n * Defines contents for a Pixim content class: each is loaded with the class's\n * other assets and given as `$.resources.animateContents[name]`.\n */\nexport function defineAnimateContentsTo(PiximContent: typeof Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): typeof Content {\n\treturn PiximContent.defineTargets(ANIMATE_CONTENTS, targets, options);\n}\n\n/**\n * Adds contents to a Pixim content instance (loaded with its other assets).\n */\nexport function addAnimateContentsTo(content: Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): Content {\n\treturn content.addTargets(ANIMATE_CONTENTS, targets, options);\n}\n"],"names":["super","AnimateController","Container","LoaderResource","const","resolveContentUrl","this","JsLoader","loadContentAsync","BlobLoader","LoaderBase","ManifestBase","Content"],"mappings":";;;;;;;;;;;;;;AAGA;;;;;;;;;;;AAWG;AACG,IAAO,gBAAiB,iBAAiB,UAAA,SAAA,EAAA;AAG9C,IAAA,SAAA,gBAAA,GAAA;AACC,QAAAA,SAAAA,CAAAA,IAAK,CAAA,KAAE;QACP,IAAI,CAAC,WAAW,GAAG,IAAIC,oCAAiB,CAAC,IAAI,CAAC;;;;;;;AAC9C,IAAA,IAAA,kBAAA,GAAA,EAAA,KAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA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AAgB,EAAE,OAAoD,EAAE,OAA6B,EAAA;wCAAF,EAAA;;IACvI,OAAO,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;AAC9D;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"pixim-animate-runtime.cjs.js","sources":["../src/AnimateContainer.ts","../src/AnimateContentLoader.ts","../src/AnimateContentManifest.ts"],"sourcesContent":["import { Container, ITickerData } from '@tawaship/pixim.js';\nimport { AnimateController, DisplayObject } from '@tawaship/pixi-animate-runtime';\n\n/**\n * A Pixim container that plays the content roots put on it at their\n * content's frame rate (the rate the content was published with), while it is\n * on the display tree of a running Pixim application.\n *\n * Each frame of the application plays `delta x speed x fps / 60` frames of every\n * root (delta being the application ticker's), one frame being createjs's tick\n * phase followed by its resolve phase; the first frame after a root is put on\n * only settles it on its first frame. Playing stops while `taskEnabled` is\n * false. The container's own `task` is free for the application: what it holds\n * does not change the playing.\n */\nexport class AnimateContainer extends Container {\n\tprivate readonly _controller: AnimateController;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._controller = new AnimateController(this);\n\t}\n\n\t/** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */\n\tget speed(): number { return this._controller.speed; }\n\tset speed(value: number) { this._controller.speed = value; }\n\n\t/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */\n\tget overSpeed(): boolean { return this._controller.overSpeed; }\n\tset overSpeed(value: boolean) { this._controller.overSpeed = value; }\n\n\t/** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */\n\tget smooth(): boolean { return this._controller.smooth; }\n\tset smooth(value: boolean) { this._controller.smooth = value; }\n\n\tupdateTask(e: ITickerData): void {\n\t\tsuper.updateTask(e);\n\t\tif (!this.taskEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._controller.handleTick(e.delta);\n\t}\n\n\t/** Plays the roots by hand, as one frame of the application with this delta does */\n\thandleTick(delta: number): void {\n\t\tthis._controller.handleTick(delta);\n\t}\n\n\t/** Puts a content object on this container; a MovieClip plays from then on */\n\taddCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.addCreatejs(obj);\n\t}\n\n\taddCreatejsAt<T extends DisplayObject>(obj: T, index: number): T {\n\t\treturn this._controller.addCreatejsAt(obj, index);\n\t}\n\n\tremoveCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.removeCreatejs(obj);\n\t}\n}\n","import { BlobLoader, BlobLoaderResource, ILoaderOption, JsLoader, LoaderBase, LoaderResource, TLoaderResourceVersion } from '@tawaship/pixim.js';\nimport { IContent, IContentManifestEntry, IContentTarget, loadContentAsync, resolveContentUrl } from '@tawaship/pixi-animate-runtime';\n\n/** A content to load: what loadContentAsync takes, and the runtime content file to load first */\nexport interface IAnimateContentLoaderTarget extends IContentTarget {\n\t/**\n\t * The runtime content file, relative to `basepath`. Loaded (as a script) before\n\t * the content when given; otherwise it has to be loaded already.\n\t */\n\tfilepath?: string;\n}\n\nexport interface IAnimateContentLoaderOption extends ILoaderOption {\n\t/** The version added to the runtime content file's URL (`version` when omitted) */\n\tfileVersion?: TLoaderResourceVersion;\n\t/** The version added to the image URLs (`version` when omitted) */\n\tassetVersion?: TLoaderResourceVersion;\n}\n\nexport class AnimateContentLoaderResource extends LoaderResource<IContent | null> {\n\tdestroy(): void {\n\t\tthis._data = null;\n\t}\n}\n\nfunction isUrl(src: string): boolean {\n\treturn src.indexOf('data:') !== 0 && src.indexOf('blob:') !== 0;\n}\n\n/**\n * Loads a content as a Pixim asset: its runtime content file (when a filepath\n * is given), then the content with loadContentAsync, the base path being the\n * Pixim content's and the target's together.\n *\n * With the Pixim content's `xhr` option, the images are fetched (with its\n * request options) into blob: URLs first, after the target's own\n * handleManifest; the blob: URLs are released once the content is loaded.\n */\nexport class AnimateContentLoader extends LoaderBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _loadAsync(target: IAnimateContentLoaderTarget, options: IAnimateContentLoaderOption = {}): Promise<AnimateContentLoaderResource> {\n\t\tconst basepath = resolveContentUrl(options.basepath || '', target.basepath || '');\n\t\treturn this._loadFileAsync(target, basepath, options)\n\t\t\t.then(() => this._loadContentAsync(target, basepath, options))\n\t\t\t.then(content => new AnimateContentLoaderResource(content, null))\n\t\t\t.catch((e: Error) => new AnimateContentLoaderResource(null, e));\n\t}\n\n\tprivate _loadFileAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<void> {\n\t\tif (!target.filepath) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new JsLoader().loadAsync(resolveContentUrl(basepath, target.filepath), { version: options.fileVersion || options.version, xhr: options.xhr })\n\t\t\t.then(resource => {\n\t\t\t\tif (resource.error) {\n\t\t\t\t\tthrow resource.error;\n\t\t\t\t}\n\t\t\t\tresource.ref();\n\t\t\t});\n\t}\n\n\tprivate _loadContentAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<IContent> {\n\t\tconst version = options.assetVersion || options.version;\n\t\tconst blobs: BlobLoaderResource[] = [];\n\t\tconst release = (): void => {\n\t\t\tblobs.forEach(blob => blob.destroy());\n\t\t};\n\t\tconst own = target.options && target.options.handleManifest;\n\t\tconst contentTarget: IContentTarget = {\n\t\t\tid: target.id,\n\t\t\tbasepath,\n\t\t\toptions: {\n\t\t\t\tcrossOrigin: target.options ? target.options.crossOrigin : undefined,\n\t\t\t\thandleManifest: (manifest: IContentManifestEntry[]) => {\n\t\t\t\t\treturn Promise.resolve(own ? own(manifest) : undefined)\n\t\t\t\t\t\t.then(() => options.xhr ? this._fetchImagesAsync(manifest, basepath, version, options, blobs) : undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn loadContentAsync(contentTarget, { version })\n\t\t\t.then(content => {\n\t\t\t\trelease();\n\t\t\t\treturn content;\n\t\t\t}, (e: Error) => {\n\t\t\t\trelease();\n\t\t\t\tthrow e;\n\t\t\t});\n\t}\n\n\t/** The images fetched into blob: URLs, which then stand for their files */\n\tprivate _fetchImagesAsync(manifest: IContentManifestEntry[], basepath: string, version: TLoaderResourceVersion | undefined, options: IAnimateContentLoaderOption, blobs: BlobLoaderResource[]): Promise<void> {\n\t\tconst targets: Record<string, string> = {};\n\t\tmanifest.forEach((entry, i) => {\n\t\t\tif (isUrl(entry.src)) {\n\t\t\t\ttargets[i] = resolveContentUrl(basepath, entry.src);\n\t\t\t}\n\t\t});\n\t\treturn new BlobLoader().loadAllAsync(targets, { version, xhr: options.xhr })\n\t\t\t.then(resources => {\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tblobs.push(resources[i]);\n\t\t\t\t});\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tconst resource = resources[i];\n\t\t\t\t\tif (resource.error) {\n\t\t\t\t\t\tthrow resource.error;\n\t\t\t\t\t}\n\t\t\t\t\tmanifest[Number(i)].src = resource.data;\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n","import { Content, IManifestOption, ManifestBase } from '@tawaship/pixim.js';\nimport { IContent } from '@tawaship/pixi-animate-runtime';\nimport { AnimateContentLoader, AnimateContentLoaderResource, IAnimateContentLoaderTarget } from './AnimateContentLoader';\n\n/** The key of the contents in a Pixim content's resources: `$.resources.animateContents` */\nexport const ANIMATE_CONTENTS = 'animateContents';\n\nexport class AnimateContentManifest extends ManifestBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _createLoader(): AnimateContentLoader {\n\t\treturn new AnimateContentLoader();\n\t}\n}\n\nContent.registerManifest(ANIMATE_CONTENTS, AnimateContentManifest);\n\n/**\n * Defines contents for a Pixim content class: each is loaded with the class's\n * other assets and given as `$.resources.animateContents[name]`.\n */\nexport function defineAnimateContentsTo(PiximContent: typeof Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): typeof Content {\n\treturn PiximContent.defineTargets(ANIMATE_CONTENTS, targets, options);\n}\n\n/**\n * Adds contents to a Pixim content instance (loaded with its other assets).\n */\nexport function addAnimateContentsTo(content: Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): Content {\n\treturn content.addTargets(ANIMATE_CONTENTS, targets, options);\n}\n"],"names":["super","AnimateController","Container","LoaderResource","const","resolveContentUrl","this","JsLoader","loadContentAsync","BlobLoader","LoaderBase","ManifestBase","Content"],"mappings":";;;;;;;;;;;;;;AAGA;;;;;;;;;;;AAWG;AACG,IAAO,gBAAiB,iBAAiB,UAAA,SAAA,EAAA;AAG9C,IAAA,SAAA,gBAAA,GAAA;AACC,QAAAA,SAAAA,CAAAA,IAAK,CAAA,KAAE;QACP,IAAI,CAAC,WAAW,GAAG,IAAIC,oCAAiB,CAAC,IAAI,CAAC;;;;;;;AAC9C,IAAA,IAAA,kBAAA,GAAA,EAAA,KAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,MAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,EAAA;;IAGD,kBAAA,CAAI,KAAA,CAAA,GAAA,GAAA,YAAK,EAAa,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA,CAAA;AACpD,IAAA,kBAAA,CAAI,KAAA,CAAA,GAAA,GAAA,UAAM,KAAa,EAAA,EAAI,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA,CAAA;;IAG1D,kBAAA,CAAI,SAAA,CAAA,GAAA,GAAA,YAAS,EAAc,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA,CAAA;AAC7D,IAAA,kBAAA,CAAI,SAAA,CAAA,GAAA,GAAA,UAAU,KAAc,EAAA,EAAI,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,KAAK,CAAC,CAAA,CAAA;;IAGnE,kBAAA,CAAI,MAAA,CAAA,GAAA,GAAA,YAAM,EAAc,OAAO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AAC,CAAC,CAAC,CAAC,GAAG,GAAG,QAAQ,CAAC,IAAI;AACxC,YAAA,CAAC,CAAC;AACH,QAAA,CAAC,CAAC;;;;EAtEqCM,mBAAA,CAAA;;AClC1C;AACO,IAAM,gBAAgB,GAAG;AAE1B,IAAO,sBAAuB,iBAAgG,UAAA,YAAA,EAAA;;;;;;;;;AACzH,IAAA,sBAAA,CAAA,SAAA,CAAA,aAAA,GAAA,SAAA,aAAA,IAAa;QACtB,OAAO,IAAI,oBAAoB,EAAE;;;;EAFSC,qBAAA,CAAA;AAM5CC,gBAAO,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;AAElE;;;AAGG;AACG,SAAU,uBAAuB,CAAC,YAA4B,EAAE,OAAoD,EAAE,OAA6B,EAAA;wCAAF,EAAA;;IACtJ,OAAO,YAAY,CAAC,aAAa,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;AACtE;AAEA;;AAEG;AACG,SAAU,oBAAoB,CAAC,OAAgB,EAAE,OAAoD,EAAE,OAA6B,EAAA;wCAAF,EAAA;;IACvI,OAAO,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;AAC9D;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @tawaship/pixim-animate-runtime - v0.1.
|
|
2
|
+
* @tawaship/pixim-animate-runtime - v0.1.1
|
|
3
3
|
*
|
|
4
4
|
* @require pixi.js ^5.3.2
|
|
5
5
|
* @require @tawaship/pixim.js ^1.15.2
|
|
@@ -34,7 +34,7 @@ var AnimateContainer = /*@__PURE__*/(function (Container) {
|
|
|
34
34
|
AnimateContainer.prototype.constructor = AnimateContainer;
|
|
35
35
|
|
|
36
36
|
var prototypeAccessors = { speed: { configurable: true },overSpeed: { configurable: true },smooth: { configurable: true } };
|
|
37
|
-
/** Playback speed (1 is the content's own frame rate) */
|
|
37
|
+
/** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */
|
|
38
38
|
prototypeAccessors.speed.get = function () { return this._controller.speed; };
|
|
39
39
|
prototypeAccessors.speed.set = function (value) { this._controller.speed = value; };
|
|
40
40
|
/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixim-animate-runtime.esm.js","sources":["../src/AnimateContainer.ts","../src/AnimateContentLoader.ts","../src/AnimateContentManifest.ts"],"sourcesContent":["import { Container, ITickerData } from '@tawaship/pixim.js';\nimport { AnimateController, DisplayObject } from '@tawaship/pixi-animate-runtime';\n\n/**\n * A Pixim container that plays the content roots put on it at their\n * content's frame rate (the rate the content was published with), while it is\n * on the display tree of a running Pixim application.\n *\n * Each frame of the application plays `delta x speed x fps / 60` frames of every\n * root (delta being the application ticker's), one frame being createjs's tick\n * phase followed by its resolve phase; the first frame after a root is put on\n * only settles it on its first frame. Playing stops while `taskEnabled` is\n * false. The container's own `task` is free for the application: what it holds\n * does not change the playing.\n */\nexport class AnimateContainer extends Container {\n\tprivate readonly _controller: AnimateController;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._controller = new AnimateController(this);\n\t}\n\n\t/** Playback speed (1 is the content's own frame rate) */\n\tget speed(): number { return this._controller.speed; }\n\tset speed(value: number) { this._controller.speed = value; }\n\n\t/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */\n\tget overSpeed(): boolean { return this._controller.overSpeed; }\n\tset overSpeed(value: boolean) { this._controller.overSpeed = value; }\n\n\t/** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */\n\tget smooth(): boolean { return this._controller.smooth; }\n\tset smooth(value: boolean) { this._controller.smooth = value; }\n\n\tupdateTask(e: ITickerData): void {\n\t\tsuper.updateTask(e);\n\t\tif (!this.taskEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._controller.handleTick(e.delta);\n\t}\n\n\t/** Plays the roots by hand, as one frame of the application with this delta does */\n\thandleTick(delta: number): void {\n\t\tthis._controller.handleTick(delta);\n\t}\n\n\t/** Puts a content object on this container; a MovieClip plays from then on */\n\taddCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.addCreatejs(obj);\n\t}\n\n\taddCreatejsAt<T extends DisplayObject>(obj: T, index: number): T {\n\t\treturn this._controller.addCreatejsAt(obj, index);\n\t}\n\n\tremoveCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.removeCreatejs(obj);\n\t}\n}\n","import { BlobLoader, BlobLoaderResource, ILoaderOption, JsLoader, LoaderBase, LoaderResource, TLoaderResourceVersion } from '@tawaship/pixim.js';\nimport { IContent, IContentManifestEntry, IContentTarget, loadContentAsync, resolveContentUrl } from '@tawaship/pixi-animate-runtime';\n\n/** A content to load: what loadContentAsync takes, and the runtime content file to load first */\nexport interface IAnimateContentLoaderTarget extends IContentTarget {\n\t/**\n\t * The runtime content file, relative to `basepath`. Loaded (as a script) before\n\t * the content when given; otherwise it has to be loaded already.\n\t */\n\tfilepath?: string;\n}\n\nexport interface IAnimateContentLoaderOption extends ILoaderOption {\n\t/** The version added to the runtime content file's URL (`version` when omitted) */\n\tfileVersion?: TLoaderResourceVersion;\n\t/** The version added to the image URLs (`version` when omitted) */\n\tassetVersion?: TLoaderResourceVersion;\n}\n\nexport class AnimateContentLoaderResource extends LoaderResource<IContent | null> {\n\tdestroy(): void {\n\t\tthis._data = null;\n\t}\n}\n\nfunction isUrl(src: string): boolean {\n\treturn src.indexOf('data:') !== 0 && src.indexOf('blob:') !== 0;\n}\n\n/**\n * Loads a content as a Pixim asset: its runtime content file (when a filepath\n * is given), then the content with loadContentAsync, the base path being the\n * Pixim content's and the target's together.\n *\n * With the Pixim content's `xhr` option, the images are fetched (with its\n * request options) into blob: URLs first, after the target's own\n * handleManifest; the blob: URLs are released once the content is loaded.\n */\nexport class AnimateContentLoader extends LoaderBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _loadAsync(target: IAnimateContentLoaderTarget, options: IAnimateContentLoaderOption = {}): Promise<AnimateContentLoaderResource> {\n\t\tconst basepath = resolveContentUrl(options.basepath || '', target.basepath || '');\n\t\treturn this._loadFileAsync(target, basepath, options)\n\t\t\t.then(() => this._loadContentAsync(target, basepath, options))\n\t\t\t.then(content => new AnimateContentLoaderResource(content, null))\n\t\t\t.catch((e: Error) => new AnimateContentLoaderResource(null, e));\n\t}\n\n\tprivate _loadFileAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<void> {\n\t\tif (!target.filepath) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new JsLoader().loadAsync(resolveContentUrl(basepath, target.filepath), { version: options.fileVersion || options.version, xhr: options.xhr })\n\t\t\t.then(resource => {\n\t\t\t\tif (resource.error) {\n\t\t\t\t\tthrow resource.error;\n\t\t\t\t}\n\t\t\t\tresource.ref();\n\t\t\t});\n\t}\n\n\tprivate _loadContentAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<IContent> {\n\t\tconst version = options.assetVersion || options.version;\n\t\tconst blobs: BlobLoaderResource[] = [];\n\t\tconst release = (): void => {\n\t\t\tblobs.forEach(blob => blob.destroy());\n\t\t};\n\t\tconst own = target.options && target.options.handleManifest;\n\t\tconst contentTarget: IContentTarget = {\n\t\t\tid: target.id,\n\t\t\tbasepath,\n\t\t\toptions: {\n\t\t\t\tcrossOrigin: target.options ? target.options.crossOrigin : undefined,\n\t\t\t\thandleManifest: (manifest: IContentManifestEntry[]) => {\n\t\t\t\t\treturn Promise.resolve(own ? own(manifest) : undefined)\n\t\t\t\t\t\t.then(() => options.xhr ? this._fetchImagesAsync(manifest, basepath, version, options, blobs) : undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn loadContentAsync(contentTarget, { version })\n\t\t\t.then(content => {\n\t\t\t\trelease();\n\t\t\t\treturn content;\n\t\t\t}, (e: Error) => {\n\t\t\t\trelease();\n\t\t\t\tthrow e;\n\t\t\t});\n\t}\n\n\t/** The images fetched into blob: URLs, which then stand for their files */\n\tprivate _fetchImagesAsync(manifest: IContentManifestEntry[], basepath: string, version: TLoaderResourceVersion | undefined, options: IAnimateContentLoaderOption, blobs: BlobLoaderResource[]): Promise<void> {\n\t\tconst targets: Record<string, string> = {};\n\t\tmanifest.forEach((entry, i) => {\n\t\t\tif (isUrl(entry.src)) {\n\t\t\t\ttargets[i] = resolveContentUrl(basepath, entry.src);\n\t\t\t}\n\t\t});\n\t\treturn new BlobLoader().loadAllAsync(targets, { version, xhr: options.xhr })\n\t\t\t.then(resources => {\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tblobs.push(resources[i]);\n\t\t\t\t});\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tconst resource = resources[i];\n\t\t\t\t\tif (resource.error) {\n\t\t\t\t\t\tthrow resource.error;\n\t\t\t\t\t}\n\t\t\t\t\tmanifest[Number(i)].src = resource.data;\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n","import { Content, IManifestOption, ManifestBase } from '@tawaship/pixim.js';\nimport { IContent } from '@tawaship/pixi-animate-runtime';\nimport { AnimateContentLoader, AnimateContentLoaderResource, IAnimateContentLoaderTarget } from './AnimateContentLoader';\n\n/** The key of the contents in a Pixim content's resources: `$.resources.animateContents` */\nexport const ANIMATE_CONTENTS = 'animateContents';\n\nexport class AnimateContentManifest extends ManifestBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _createLoader(): AnimateContentLoader {\n\t\treturn new AnimateContentLoader();\n\t}\n}\n\nContent.registerManifest(ANIMATE_CONTENTS, AnimateContentManifest);\n\n/**\n * Defines contents for a Pixim content class: each is loaded with the class's\n * other assets and given as `$.resources.animateContents[name]`.\n */\nexport function defineAnimateContentsTo(PiximContent: typeof Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): typeof Content {\n\treturn PiximContent.defineTargets(ANIMATE_CONTENTS, targets, options);\n}\n\n/**\n * Adds contents to a Pixim content instance (loaded with its other assets).\n */\nexport function addAnimateContentsTo(content: Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): Content {\n\treturn content.addTargets(ANIMATE_CONTENTS, targets, options);\n}\n"],"names":["super","const","this"],"mappings":";;;;;;;;;;;;;AAGA;;;;;;;;;;;AAWG;AACG,IAAO,gBAAiB,iBAAiB,UAAA,SAAA,EAAA;AAG9C,IAAA,SAAA,gBAAA,GAAA;AACC,QAAAA,SAAAA,CAAAA,IAAK,CAAA,KAAE;QACP,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC;;;;;;;AAC9C,IAAA,IAAA,kBAAA,GAAA,EAAA,KAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,MAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,EAAA;;IAGD,kBAAA,CAAI,KAAA,CAAA,GAAA,GAAA,YAAK,EAAa,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA,CAAA;AACpD,IAAA,kBAAA,CAAI,KAAA,CAAA,GAAA,GAAA,UAAM,KAAa,EAAA,EAAI,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA,CAAA;;IAG1D,kBAAA,CAAI,SAAA,CAAA,GAAA,GAAA,YAAS,EAAc,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA,CAAA;AAC7D,IAAA,kBAAA,CAAI,SAAA,CAAA,GAAA,GAAA,UAAU,KAAc,EAAA,EAAI,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,KAAK,CAAC,CAAA,CAAA;;IAGnE,kBAAA,CAAI,MAAA,CAAA,GAAA,GAAA,YAAM,EAAc,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA,CAAA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AAA,CAAC,CAAC;AACH,QAAA,CAAC,CAAC;;;;EAtEqC,UAAA,CAAA;;AClC1C;AACO,IAAM,gBAAgB,GAAG;AAE1B,IAAO,sBAAuB,iBAAgG,UAAA,YAAA,EAAA;;;;;;;;;AACzH,IAAA,sBAAA,CAAA,SAAA,CAAA,aAAA,GAAA,SAAA,aAAA,IAAa;QACtB,OAAO,IAAI,oBAAoB,EAAE;;;;EAFS,YAAA,CAAA;AAM5C,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;AAElE;;;AAGG;AACG,SAAU,uBAAuB,CAAC,YAA4B,EAAE,OAAoD,EAAE,OAA6B,EAAA;wCAAF,EAAA;;IACtJ,OAAO,YAAY,CAAC,aAAa,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;AACtE;AAEA;;AAEG;AACG,SAAU,oBAAoB,CAAC,OAAgB,EAAE,OAAoD,EAAE,OAA6B,EAAA;wCAAF,EAAA;;IACvI,OAAO,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC;AAC9D;;"}
|
|
1
|
+
{"version":3,"file":"pixim-animate-runtime.esm.js","sources":["../src/AnimateContainer.ts","../src/AnimateContentLoader.ts","../src/AnimateContentManifest.ts"],"sourcesContent":["import { Container, ITickerData } from '@tawaship/pixim.js';\nimport { AnimateController, DisplayObject } from '@tawaship/pixi-animate-runtime';\n\n/**\n * A Pixim container that plays the content roots put on it at their\n * content's frame rate (the rate the content was published with), while it is\n * on the display tree of a running Pixim application.\n *\n * Each frame of the application plays `delta x speed x fps / 60` frames of every\n * root (delta being the application ticker's), one frame being createjs's tick\n * phase followed by its resolve phase; the first frame after a root is put on\n * only settles it on its first frame. Playing stops while `taskEnabled` is\n * false. The container's own `task` is free for the application: what it holds\n * does not change the playing.\n */\nexport class AnimateContainer extends Container {\n\tprivate readonly _controller: AnimateController;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._controller = new AnimateController(this);\n\t}\n\n\t/** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */\n\tget speed(): number { return this._controller.speed; }\n\tset speed(value: number) { this._controller.speed = value; }\n\n\t/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */\n\tget overSpeed(): boolean { return this._controller.overSpeed; }\n\tset overSpeed(value: boolean) { this._controller.overSpeed = value; }\n\n\t/** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */\n\tget smooth(): boolean { return this._controller.smooth; }\n\tset smooth(value: boolean) { this._controller.smooth = value; }\n\n\tupdateTask(e: ITickerData): void {\n\t\tsuper.updateTask(e);\n\t\tif (!this.taskEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._controller.handleTick(e.delta);\n\t}\n\n\t/** Plays the roots by hand, as one frame of the application with this delta does */\n\thandleTick(delta: number): void {\n\t\tthis._controller.handleTick(delta);\n\t}\n\n\t/** Puts a content object on this container; a MovieClip plays from then on */\n\taddCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.addCreatejs(obj);\n\t}\n\n\taddCreatejsAt<T extends DisplayObject>(obj: T, index: number): T {\n\t\treturn this._controller.addCreatejsAt(obj, index);\n\t}\n\n\tremoveCreatejs<T extends DisplayObject>(obj: T): T {\n\t\treturn this._controller.removeCreatejs(obj);\n\t}\n}\n","import { BlobLoader, BlobLoaderResource, ILoaderOption, JsLoader, LoaderBase, LoaderResource, TLoaderResourceVersion } from '@tawaship/pixim.js';\nimport { IContent, IContentManifestEntry, IContentTarget, loadContentAsync, resolveContentUrl } from '@tawaship/pixi-animate-runtime';\n\n/** A content to load: what loadContentAsync takes, and the runtime content file to load first */\nexport interface IAnimateContentLoaderTarget extends IContentTarget {\n\t/**\n\t * The runtime content file, relative to `basepath`. Loaded (as a script) before\n\t * the content when given; otherwise it has to be loaded already.\n\t */\n\tfilepath?: string;\n}\n\nexport interface IAnimateContentLoaderOption extends ILoaderOption {\n\t/** The version added to the runtime content file's URL (`version` when omitted) */\n\tfileVersion?: TLoaderResourceVersion;\n\t/** The version added to the image URLs (`version` when omitted) */\n\tassetVersion?: TLoaderResourceVersion;\n}\n\nexport class AnimateContentLoaderResource extends LoaderResource<IContent | null> {\n\tdestroy(): void {\n\t\tthis._data = null;\n\t}\n}\n\nfunction isUrl(src: string): boolean {\n\treturn src.indexOf('data:') !== 0 && src.indexOf('blob:') !== 0;\n}\n\n/**\n * Loads a content as a Pixim asset: its runtime content file (when a filepath\n * is given), then the content with loadContentAsync, the base path being the\n * Pixim content's and the target's together.\n *\n * With the Pixim content's `xhr` option, the images are fetched (with its\n * request options) into blob: URLs first, after the target's own\n * handleManifest; the blob: URLs are released once the content is loaded.\n */\nexport class AnimateContentLoader extends LoaderBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _loadAsync(target: IAnimateContentLoaderTarget, options: IAnimateContentLoaderOption = {}): Promise<AnimateContentLoaderResource> {\n\t\tconst basepath = resolveContentUrl(options.basepath || '', target.basepath || '');\n\t\treturn this._loadFileAsync(target, basepath, options)\n\t\t\t.then(() => this._loadContentAsync(target, basepath, options))\n\t\t\t.then(content => new AnimateContentLoaderResource(content, null))\n\t\t\t.catch((e: Error) => new AnimateContentLoaderResource(null, e));\n\t}\n\n\tprivate _loadFileAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<void> {\n\t\tif (!target.filepath) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new JsLoader().loadAsync(resolveContentUrl(basepath, target.filepath), { version: options.fileVersion || options.version, xhr: options.xhr })\n\t\t\t.then(resource => {\n\t\t\t\tif (resource.error) {\n\t\t\t\t\tthrow resource.error;\n\t\t\t\t}\n\t\t\t\tresource.ref();\n\t\t\t});\n\t}\n\n\tprivate _loadContentAsync(target: IAnimateContentLoaderTarget, basepath: string, options: IAnimateContentLoaderOption): Promise<IContent> {\n\t\tconst version = options.assetVersion || options.version;\n\t\tconst blobs: BlobLoaderResource[] = [];\n\t\tconst release = (): void => {\n\t\t\tblobs.forEach(blob => blob.destroy());\n\t\t};\n\t\tconst own = target.options && target.options.handleManifest;\n\t\tconst contentTarget: IContentTarget = {\n\t\t\tid: target.id,\n\t\t\tbasepath,\n\t\t\toptions: {\n\t\t\t\tcrossOrigin: target.options ? target.options.crossOrigin : undefined,\n\t\t\t\thandleManifest: (manifest: IContentManifestEntry[]) => {\n\t\t\t\t\treturn Promise.resolve(own ? own(manifest) : undefined)\n\t\t\t\t\t\t.then(() => options.xhr ? this._fetchImagesAsync(manifest, basepath, version, options, blobs) : undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn loadContentAsync(contentTarget, { version })\n\t\t\t.then(content => {\n\t\t\t\trelease();\n\t\t\t\treturn content;\n\t\t\t}, (e: Error) => {\n\t\t\t\trelease();\n\t\t\t\tthrow e;\n\t\t\t});\n\t}\n\n\t/** The images fetched into blob: URLs, which then stand for their files */\n\tprivate _fetchImagesAsync(manifest: IContentManifestEntry[], basepath: string, version: TLoaderResourceVersion | undefined, options: IAnimateContentLoaderOption, blobs: BlobLoaderResource[]): Promise<void> {\n\t\tconst targets: Record<string, string> = {};\n\t\tmanifest.forEach((entry, i) => {\n\t\t\tif (isUrl(entry.src)) {\n\t\t\t\ttargets[i] = resolveContentUrl(basepath, entry.src);\n\t\t\t}\n\t\t});\n\t\treturn new BlobLoader().loadAllAsync(targets, { version, xhr: options.xhr })\n\t\t\t.then(resources => {\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tblobs.push(resources[i]);\n\t\t\t\t});\n\t\t\t\tObject.keys(resources).forEach(i => {\n\t\t\t\t\tconst resource = resources[i];\n\t\t\t\t\tif (resource.error) {\n\t\t\t\t\t\tthrow resource.error;\n\t\t\t\t\t}\n\t\t\t\t\tmanifest[Number(i)].src = resource.data;\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n","import { Content, IManifestOption, ManifestBase } from '@tawaship/pixim.js';\nimport { IContent } from '@tawaship/pixi-animate-runtime';\nimport { AnimateContentLoader, AnimateContentLoaderResource, IAnimateContentLoaderTarget } from './AnimateContentLoader';\n\n/** The key of the contents in a Pixim content's resources: `$.resources.animateContents` */\nexport const ANIMATE_CONTENTS = 'animateContents';\n\nexport class AnimateContentManifest extends ManifestBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {\n\tprotected _createLoader(): AnimateContentLoader {\n\t\treturn new AnimateContentLoader();\n\t}\n}\n\nContent.registerManifest(ANIMATE_CONTENTS, AnimateContentManifest);\n\n/**\n * Defines contents for a Pixim content class: each is loaded with the class's\n * other assets and given as `$.resources.animateContents[name]`.\n */\nexport function defineAnimateContentsTo(PiximContent: typeof Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): typeof Content {\n\treturn PiximContent.defineTargets(ANIMATE_CONTENTS, targets, options);\n}\n\n/**\n * Adds contents to a Pixim content instance (loaded with its other assets).\n */\nexport function addAnimateContentsTo(content: Content, targets: Record<string, IAnimateContentLoaderTarget>, options: IManifestOption = {}): Content {\n\treturn content.addTargets(ANIMATE_CONTENTS, targets, options);\n}\n"],"names":["super","const","this"],"mappings":";;;;;;;;;;;;;AAGA;;;;;;;;;;;AAWG;AACG,IAAO,gBAAiB,iBAAiB,UAAA,SAAA,EAAA;AAG9C,IAAA,SAAA,gBAAA,GAAA;AACC,QAAAA,SAAAA,CAAAA,IAAK,CAAA,KAAE;QACP,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC;;;;;;;AAC9C,IAAA,IAAA,kBAAA,GAAA,EAAA,KAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,CAAA,MAAA,EAAA,EAAA,YAAA,EAAA,IAAA,EAAA,EAAA;;IAGD,kBAAA,CAAI,KAAA,CAAA,GAAA,GAAA,YAAK,EAAa,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,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|
1
1
|
/*!
|
|
2
|
-
* @tawaship/pixim-animate-runtime - v0.1.
|
|
2
|
+
* @tawaship/pixim-animate-runtime - v0.1.1
|
|
3
3
|
*
|
|
4
4
|
* @require pixi.js ^5.3.2
|
|
5
5
|
* @require @tawaship/pixim.js ^1.15.2
|
|
@@ -31,7 +31,7 @@ this.Pixim = this.Pixim || {};
|
|
|
31
31
|
var PIXI__namespace = /*#__PURE__*/_interopNamespaceDefault(PIXI);
|
|
32
32
|
|
|
33
33
|
/*!
|
|
34
|
-
* @tawaship/pixi-animate-runtime - v0.1.
|
|
34
|
+
* @tawaship/pixi-animate-runtime - v0.1.1
|
|
35
35
|
*
|
|
36
36
|
* @author tawaship (makazu.mori@gmail.com)
|
|
37
37
|
* @license MIT
|
|
@@ -456,6 +456,12 @@ this.Pixim = this.Pixim || {};
|
|
|
456
456
|
this._maskHost = null;
|
|
457
457
|
/** The objects this object masks (while they are on a display list) */
|
|
458
458
|
this._maskTargets = [];
|
|
459
|
+
/**
|
|
460
|
+
* Set on a root when a timeline under it jumped outside the playing (a goto):
|
|
461
|
+
* its clips are to be settled before Pixi draws it (settleForDrawing), as a
|
|
462
|
+
* createjs draw would. The resolve phase of a frame clears it
|
|
463
|
+
*/
|
|
464
|
+
this._pendingResolve = false;
|
|
459
465
|
this.id = nextId++;
|
|
460
466
|
this.pixi = pixi;
|
|
461
467
|
pixi.owner = this;
|
|
@@ -1256,6 +1262,13 @@ this.Pixim = this.Pixim || {};
|
|
|
1256
1262
|
if (position != null) {
|
|
1257
1263
|
this._t = 0;
|
|
1258
1264
|
this._updateTimeline(position, true);
|
|
1265
|
+
// The clips it placed (synched ones, ones to start over) are settled by createjs when it
|
|
1266
|
+
// draws: the root is to be settled before Pixi draws it, if no frame is played before
|
|
1267
|
+
var root = this;
|
|
1268
|
+
while (root.parent) {
|
|
1269
|
+
root = root.parent;
|
|
1270
|
+
}
|
|
1271
|
+
root._pendingResolve = true;
|
|
1259
1272
|
}
|
|
1260
1273
|
};
|
|
1261
1274
|
MovieClip.prototype._reset = function _reset () {
|
|
@@ -2700,7 +2713,7 @@ this.Pixim = this.Pixim || {};
|
|
|
2700
2713
|
}
|
|
2701
2714
|
|
|
2702
2715
|
/** The version of this package (written in from package.json when the package is built) */
|
|
2703
|
-
var VERSION = "0.1.
|
|
2716
|
+
var VERSION = "0.1.1";
|
|
2704
2717
|
|
|
2705
2718
|
/**
|
|
2706
2719
|
* The eases of CreateJS (createjs.Ease), computed as CreateJS computes them,
|
|
@@ -3347,6 +3360,7 @@ this.Pixim = this.Pixim || {};
|
|
|
3347
3360
|
* reverse order), without playing a frame.
|
|
3348
3361
|
*/
|
|
3349
3362
|
function resolveState(node) {
|
|
3363
|
+
node._pendingResolve = false;
|
|
3350
3364
|
if (node instanceof MovieClip) {
|
|
3351
3365
|
node._updateState();
|
|
3352
3366
|
}
|
|
@@ -3359,6 +3373,34 @@ this.Pixim = this.Pixim || {};
|
|
|
3359
3373
|
}
|
|
3360
3374
|
}
|
|
3361
3375
|
}
|
|
3376
|
+
/**
|
|
3377
|
+
* Settles a display tree for drawing without playing it on, as a createjs
|
|
3378
|
+
* stage draw shows it (MovieClip.draw settles each clip): the synched and
|
|
3379
|
+
* single frame clips are placed at the frame their parent gives, and a clip
|
|
3380
|
+
* waiting to start over (an independent clip reset when its parent placed it
|
|
3381
|
+
* again) is shown at its first frame the way a new clip is (no frame script,
|
|
3382
|
+
* its playhead left to start on the next frame, as in the template, where
|
|
3383
|
+
* createjs draws only after a frame). Children after their parent, in reverse
|
|
3384
|
+
* order as the resolve phase.
|
|
3385
|
+
*/
|
|
3386
|
+
function settleForDrawing(node) {
|
|
3387
|
+
if (node instanceof MovieClip) {
|
|
3388
|
+
if (node.mode !== INDEPENDENT) {
|
|
3389
|
+
node._updateState();
|
|
3390
|
+
}
|
|
3391
|
+
else if (node._rawPosition === -1) {
|
|
3392
|
+
node._renderFirstFrame();
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
if (node instanceof Container) {
|
|
3396
|
+
var children = node.children.slice();
|
|
3397
|
+
for (var i = children.length - 1; i >= 0; i--) {
|
|
3398
|
+
if (children[i] instanceof MovieClip) {
|
|
3399
|
+
settleForDrawing(children[i]);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3362
3404
|
|
|
3363
3405
|
/** The frame rate a root plays at when its content does not give one */
|
|
3364
3406
|
var DEFAULT_FPS = 60;
|
|
@@ -3384,7 +3426,7 @@ this.Pixim = this.Pixim || {};
|
|
|
3384
3426
|
* on only settles it on its first frame.
|
|
3385
3427
|
*/
|
|
3386
3428
|
var AnimateController = function AnimateController(container) {
|
|
3387
|
-
/** Playback speed (1 is the content's own frame rate) */
|
|
3429
|
+
/** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */
|
|
3388
3430
|
this.speed = 1;
|
|
3389
3431
|
/** Whether one call may play more than one frame (when the display runs slower than the content) */
|
|
3390
3432
|
this.overSpeed = true;
|
|
@@ -3396,12 +3438,34 @@ this.Pixim = this.Pixim || {};
|
|
|
3396
3438
|
this._deltas = [];
|
|
3397
3439
|
this._nextDelta = 0;
|
|
3398
3440
|
this._container = container;
|
|
3441
|
+
// Pixi updates the transforms of the tree before every draw: the roots a goto changed outside
|
|
3442
|
+
// the playing are settled then, as a createjs draw settles them (frames played meanwhile settle them first)
|
|
3443
|
+
var updateTransform = container.updateTransform;
|
|
3444
|
+
var controller = this;
|
|
3445
|
+
container.updateTransform = function () {
|
|
3446
|
+
controller._settleForDrawing();
|
|
3447
|
+
updateTransform.call(this);
|
|
3448
|
+
};
|
|
3449
|
+
};
|
|
3450
|
+
/** Settles the roots marked by a goto since they were last resolved */
|
|
3451
|
+
AnimateController.prototype._settleForDrawing = function _settleForDrawing () {
|
|
3452
|
+
var targets = this._targets;
|
|
3453
|
+
Object.keys(targets).forEach(function (key) {
|
|
3454
|
+
var target = targets[Number(key)];
|
|
3455
|
+
if (target && target.root._pendingResolve) {
|
|
3456
|
+
target.root._pendingResolve = false;
|
|
3457
|
+
settleForDrawing(target.root);
|
|
3458
|
+
}
|
|
3459
|
+
});
|
|
3399
3460
|
};
|
|
3400
3461
|
AnimateController.prototype.handleTick = function handleTick (delta) {
|
|
3401
3462
|
var this$1$1 = this;
|
|
3402
3463
|
|
|
3403
|
-
|
|
3404
|
-
|
|
3464
|
+
// A speed below 0 plays as 0 does (nothing is played backward): the frames owed stay where they
|
|
3465
|
+
// were, and the playing goes on from there once the speed is above 0 again
|
|
3466
|
+
var speed = Math.max(this.speed, 0);
|
|
3467
|
+
var d = delta * speed;
|
|
3468
|
+
var usual = this._usualDelta(delta) * speed;
|
|
3405
3469
|
var targets = this._targets;
|
|
3406
3470
|
Object.keys(targets).forEach(function (key) {
|
|
3407
3471
|
var target = targets[Number(key)];
|
|
@@ -3624,7 +3688,7 @@ this.Pixim = this.Pixim || {};
|
|
|
3624
3688
|
AnimateContainer.prototype.constructor = AnimateContainer;
|
|
3625
3689
|
|
|
3626
3690
|
var prototypeAccessors = { speed: { configurable: true },overSpeed: { configurable: true },smooth: { configurable: true } };
|
|
3627
|
-
/** Playback speed (1 is the content's own frame rate) */
|
|
3691
|
+
/** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */
|
|
3628
3692
|
prototypeAccessors.speed.get = function () { return this._controller.speed; };
|
|
3629
3693
|
prototypeAccessors.speed.set = function (value) { this._controller.speed = value; };
|
|
3630
3694
|
/** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */
|