@tawaship/pixim-animate-runtime 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: animate-data-converter-guide
3
+ description: Use this skill whenever the user asks to extract, inspect, or debug the data that @tawaship/animate-data-converter extracts from Adobe Animate HTML5 Canvas (CreateJS) publish output — the engine-independent symbol and timeline definitions (IDefinition). Trigger on any mention of 'animate-data-converter', 'extractPublishedFile', 'extractPublished', 'expand', 'compact', 'IDefinition', 'converterVersion', definition JSON files, or unsupported-feature 'issues' reported for Animate content. To play content on PixiJS, use the pixi-animate-runtime-guide skill instead (its generator runs this converter for you); with Pixim.js, the pixim-animate-runtime-guide skill.
4
+ ---
5
+
6
+ # @tawaship/animate-data-converter development skill
7
+
8
+ Supported versions: **`^0.1.0`** (written against `0.1.0`).
9
+
10
+ First determine the installed version (`node_modules/@tawaship/animate-data-converter/package.json`). If it is outside the supported range, **treat the type definitions in node_modules as authoritative** and follow them wherever they disagree with this skill.
11
+
12
+ The content is assumed to be published by **Adobe Animate 24.0.15** for HTML5 Canvas, the only version checked: this package depends on the form of the published JavaScript. If the user's content comes from another version of Animate and something does not work, mention this before looking for other causes.
13
+
14
+ ## Overview
15
+
16
+ `@tawaship/animate-data-converter` reads the JavaScript that Adobe Animate publishes for HTML5 Canvas and extracts every symbol and its timeline as plain data (JSON-compatible), one definition per symbol, shared by every instance. A player for a specific engine builds on this data, so content can be played without CreateJS or the published code at play time.
17
+
18
+ - It runs in **Node.js 18 or later only**, at development time. Never suggest running it in the browser
19
+ - It reads only the published JavaScript. Images and sounds are not read, and CreateJS 1.0.0 comes with the package
20
+ - Most users do not call it directly: `@tawaship/pixi-animate-runtime`'s generator (`npx --no-install @tawaship/pixi-animate-runtime`) runs it. Use the converter directly only to keep definitions as files, to inspect them, or to build a player of your own
21
+
22
+ ## Type definition files
23
+
24
+ **Before writing code that uses this package, check the corresponding type definition file.** Read them from the package installed in the project (`node_modules/@tawaship/animate-data-converter/types/`); that is the single source of truth.
25
+
26
+ | What | Type definition file |
27
+ |---|---|
28
+ | Entry point (everything exported) | `types/index.d.ts` |
29
+ | The definition (`IDefinition` and the types it is made of) | `types/types.d.ts` |
30
+ | `extractPublishedFile`, `extractPublished` | `types/load.d.ts` |
31
+ | `expand`, `compact`, `SLOT_DEFAULTS` | `types/compact.d.ts` |
32
+ | `extract` | `types/extract.d.ts` |
33
+ | The CreateJS surface `extract` reads | `types/createjs.d.ts` |
34
+
35
+ ## Basic usage
36
+
37
+ ### Command line
38
+
39
+ ```sh
40
+ npx --no-install @tawaship/animate-data-converter game.js --out game.json --pretty
41
+ ```
42
+
43
+ - `-o, --out <file>`: where to write (standard output without it). `-p, --pretty`: indented JSON. `-e, --expanded`: the expanded form instead of the compact one. `-f, --force`: write even with unsupported features. `-h, --help`: the usage
44
+ - Exit code `1` when the content uses unsupported features (each one is listed, nothing is written unless `--force` is given), `2` when the file cannot be read or is not Animate HTML5 Canvas output
45
+
46
+ ### API
47
+
48
+ ```js
49
+ const { extractPublishedFile } = require('@tawaship/animate-data-converter');
50
+
51
+ extractPublishedFile('game.js').then(definition => {
52
+ definition.issues.forEach(issue => console.warn(issue.symbol, issue.message));
53
+ });
54
+ ```
55
+
56
+ The published code runs in a sandbox (QuickJS, a JavaScript engine compiled to WebAssembly, given nothing of the host), so extraction is asynchronous. Still tell the user to convert only content they trust (see the README).
57
+
58
+ | Function | Use it for |
59
+ |---|---|
60
+ | `extractPublishedFile(path)` | Extracting from a file (returns a promise) |
61
+ | `extractPublished({ published })` | Extracting from source text already in hand (returns a promise) |
62
+ | `extract(createjs, source)` | Extracting from content already running in an environment you set up |
63
+ | `expand(definition)` / `compact(expanded)` | Converting between the compact form (what extraction gives) and the expanded form (every value as it is) |
64
+
65
+ When calling `extract()` on an environment of your own, images created while symbols are constructed must report that they have loaded as soon as an `onload` handler is assigned; otherwise bitmap fills from sprite sheets are missing from the definition. Prefer `extractPublished()`, which runs the published code in its sandbox (QuickJS) and does this.
66
+
67
+ ## What the definition holds
68
+
69
+ The definition is extracted in its **compact form** (`form: 'compact'`): every value kept, written once (drawings in the content's `graphics` with `commandKinds`, slots as `slotTemplates` plus initial values, each tween's distinct `values` with the index of every position's values in `frames`). `expand()` gives the **expanded form** (`form: 'expanded'`), every value where it applies; read `IExpandedDefinition` for that. The README's "Reading a definition" explains both. pixi-animate-runtime's generator takes the compact form only.
70
+
71
+
72
+ - `symbols`: every symbol of the published `lib`, under its library name (non-ASCII names kept as they are). Published content has no root of its own; any symbol can be played as a root (the published HTML picks one)
73
+ - For a movie clip: labels, length, the display objects it owns with their initial state, masks, buttons, color effects, caching, and its tweens with **the exact value of every controlled property at every frame** (not approximated)
74
+ - Frame scripts as their **source text**, unchanged. They are not run or rewritten
75
+ - `manifest`, `spriteSheets`, `properties` (size, frame rate, background color), `issues`
76
+ - `converterVersion`: the converter version that extracted it. A reader of kept definition files can tell from it whether it knows their form
77
+
78
+ ## Important notes
79
+
80
+ ### Unsupported content is reported, not guessed
81
+
82
+ When `issues` is not empty, the content uses something outside the supported range (the Animate camera / "Advanced Layers", filters other than color effects, event listeners added by symbol code, hand-written looping/reversed tweens, non-plain frame script functions, display objects other than MovieClip/Shape/Sprite/Bitmap/Text). Report the listed issues to the user and suggest changing the Animate document (for the camera: delete the camera layer and publish again). Do not suggest `--force` as a fix: it only writes the data anyway.
83
+
84
+ ### Publish again → extract again
85
+
86
+ The definition is a snapshot of one publish. After the content is published again from Animate, extract (or generate) again.
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: pixi-animate-runtime-guide
3
+ description: Use this skill whenever the user asks to create, edit, or debug content using @tawaship/pixi-animate-runtime — a player that plays Adobe Animate HTML5 Canvas (CreateJS) content on pixi.js from runtime content files generated at development time, without CreateJS. Trigger on any mention of 'pixi-animate-runtime', 'runtime content', 'Animate コンテンツ', 'Adobe Animate' or 'createjs' in a project that has @tawaship/pixi-animate-runtime installed, or on concepts like loadContentAsync, AnimateContainer, AnimateController, content.create, PIXI.animateRuntime, or the 'npx pixi-animate-runtime' command. If the project uses @tawaship/pixi-animate-container instead (CreateJS at run time, loadAssetAsync), use the pixi-animate-container-guide skill. If the user is working with Pixim.js, use the pixim-animate-runtime-guide skill (it builds on this one).
4
+ ---
5
+
6
+ # @tawaship/pixi-animate-runtime development skill
7
+
8
+ Supported versions: **`^0.1.0`** (written against `0.1.0`).
9
+
10
+ First determine the installed version (`node_modules/@tawaship/pixi-animate-runtime/package.json`). If it is outside the supported range, **treat the type definitions in node_modules as authoritative** and follow them wherever they disagree with this skill.
11
+
12
+ The content is assumed to be published by **Adobe Animate 24.0.15** for HTML5 Canvas, the only version checked: this package depends on the form of the published JavaScript. If the user's content comes from another version of Animate and something does not work, mention this before looking for other causes.
13
+
14
+ ## Dependencies
15
+
16
+ Read these skills first if they are available, then apply this one:
17
+
18
+ - A PixiJS v5.3 skill (such as pixijs-guide): the player runs on pixi.js 5.3 (`^5.3.2`)
19
+
20
+ ## Overview
21
+
22
+ "Animate content" is what Adobe Animate publishes in HTML5 Canvas mode: a JavaScript file (plus images) that runs on CreateJS. This package plays it on pixi.js in two steps:
23
+
24
+ 1. **At development time (Node.js 18+)**, the generator turns the published JavaScript into a **runtime content file** (one per published file). This runs CreateJS once and records every symbol
25
+ 2. **In the browser**, the player loads runtime content files and plays them. **CreateJS and the published JavaScript are not loaded**
26
+
27
+ Consequences to keep in mind:
28
+
29
+ - **After the content is published again from Animate, the runtime content must be generated again.** The player never reads the published `.js`. When a change made in Animate does not show, check this first
30
+ - Never write `<script>` tags for CreateJS or the published `.js` in a project using this package
31
+
32
+ ## Type definition files
33
+
34
+ **Before writing code that uses a class, method, or property of this package, check the corresponding type definition file** in the installed package (`node_modules/@tawaship/pixi-animate-runtime/`). That is the single source of truth.
35
+
36
+ | What | Type definition file |
37
+ |---|---|
38
+ | Everything the player exports | `types/player/index.d.ts` |
39
+ | `loadContentAsync`, `IContentTarget` (the load options) | `types/player/loader.d.ts` |
40
+ | `IContent` (`create`, `lib`, `properties`, `id`), `tick` | `types/player/content.d.ts` |
41
+ | `AnimateContainer`, `AnimateController` | `types/player/animate-container.d.ts` |
42
+ | `MovieClip` (`play`, `stop`, `gotoAndPlay`, `labels`, ...) | `types/player/movieclip.d.ts` |
43
+ | `DisplayObject`, `Container` (the CreateJS-compatible base classes, `pixi`) | `types/player/display.d.ts` |
44
+ | `Shape`, `Sprite`, `Bitmap`, `Text`, `ButtonHelper`, `ColorFilter` | `types/player/objects.d.ts` |
45
+ | The generator (Node): `planGeneration`, `writeGeneration`, `generateFromPublishedFile`, `generate` | `types/generator/generator/index.d.ts` (the plan types in `types/generator/generator/plan.d.ts`) |
46
+
47
+ ## Basic usage
48
+
49
+ ### 1. Generate the runtime content (development time)
50
+
51
+ ```sh
52
+ npx --no-install @tawaship/pixi-animate-runtime assets/animates
53
+ ```
54
+
55
+ Give it the directory Animate published into. It writes `assets/animates/generated/<same name>.js` for every published `.js`, and copies the images each content uses next to it (`generated/images/...`). Copy the `generated/` directory into the application's assets.
56
+
57
+ - `-o, --out-dir <dir>` writes there instead of `generated/`. `-r, --recursive` also converts the published files in the directories below (not `node_modules` or hidden ones), written below `-o` at the same relative paths, or next to each published file in `generated/`. `-h, --help` shows the usage. A published `.js` file instead of a directory converts only that file
58
+ - It first lists what it would write as a table (where from and where to, then for each published file its composition id shortened to 8 characters, the number of images, and new / replace / not written with the reason). For the whole composition id, read `lib.properties.id` in the published file or the comment at the top of the runtime content file. It writes only after the user answers `y`. `-y, --yes` asks nothing and writes; run from a script, an npm script in CI or anything that is not a terminal, **`-y` is needed** (without it, nothing is written and the command exits with `1`)
59
+ - Nothing is deleted. Leftover files in the output directory are only listed
60
+ - Always write the command as `npx --no-install @tawaship/pixi-animate-runtime` (in npm scripts, `pixi-animate-runtime` alone). A bare `npx pixi-animate-runtime` in a project where the package is not installed downloads and runs an unscoped package of that name from the npm registry, without asking in CI or scripts. `yes=false` in the project's `.npmrc` keeps `npx` from downloading anything
61
+ - From a Node script, `planGeneration(options)` (the same options as the command: `input`, `outDir`, `recursive`, `force`) makes everything and writes nothing, and `writeGeneration(plan)` writes it, so the script can show its own list or questions in between (or remove contents from the plan to write only some)
62
+ - A content using unsupported features (each one listed) is not written, and the command exits with `1`. Report the listed features to the user; do not reach for `--force`
63
+ - On Windows, `tools/pixi-animate-runtime.bat` in the installed package does the same (copy it into the project, drop the published directory on it)
64
+ - The command prints each content's **composition id**, needed below
65
+
66
+ ### 2. Load and play (browser)
67
+
68
+ ```html
69
+ <script src="pixi.js"></script>
70
+ <script src="pixi-animate-runtime.js"></script>
71
+ <script src="assets/animates/generated/game.js"></script><!-- runtime content file -->
72
+ ```
73
+
74
+ ```javascript
75
+ const { loadContentAsync, AnimateContainer } = PIXI.animateRuntime;
76
+
77
+ loadContentAsync({ id: 'COMPOSITION_ID', basepath: 'assets/animates/generated/' })
78
+ .then((content) => {
79
+ const container = new AnimateContainer();
80
+ app.stage.addChild(container);
81
+ app.ticker.add(container.handleTick, container); // required: nothing plays without it
82
+
83
+ container.addCreatejs(content.create('game')); // the symbol the published HTML used as its root
84
+ });
85
+ ```
86
+
87
+ - Runtime content files must be loaded (script tags, or script elements added at run time) **before** `loadContentAsync` is called. They register under their composition id
88
+ - `id`: the composition id (`lib.properties.id`; printed by the command, and written at the top of the runtime content file). When nothing is registered under it, the error lists what is
89
+ - `basepath`: the directory the runtime content file was written to, ending with `/`; images are loaded relative to it
90
+ - `options.crossOrigin: false` loads images without CORS. `options.handleManifest(manifest)` can change image `src` before loading
91
+ - An array of targets gives an array of contents
92
+ - With a bundler: `import { loadContentAsync, AnimateContainer } from '@tawaship/pixi-animate-runtime'`. Runtime content files are still loaded as scripts
93
+
94
+ ### 3. Creating instances
95
+
96
+ - `content.create('symbolName')` creates an instance set up the way the published HTML sets up its root. Use it for every instance the application places
97
+ - `new content.lib.symbolName()` is what frame scripts do; it skips that setup
98
+ - `content.properties` holds the published `lib.properties` (`width`, `height`, `fps`, `color`, ...)
99
+ - Symbol names are the library names in Animate (non-ASCII names kept as they are)
100
+
101
+ ### 4. AnimateContainer
102
+
103
+ - `addCreatejs(instance)` / `addCreatejsAt(instance, index)` put an instance on the container; a movie clip plays from its first frame. `removeCreatejs(instance)` takes it off and it stops
104
+ - Content plays at its published frame rate whatever the display's refresh rate
105
+ - `speed`: playback speed (`1` = published frame rate, `0` stops)
106
+ - `overSpeed` (default `true`): when the display runs slower than the content, one tick may play several frames. `false` plays at most one frame per tick
107
+ - `smooth` (default `true`): frames follow a steady clock, so small variations of the frame time do not make the playing uneven (no frame on one tick, two on the next); it still keeps to the real time. Leave it on unless the user asks for the pixi-animate-container behavior (`false`)
108
+ - To play on a container of another PixiJS framework, use `new AnimateController(container)`; it has the same `addCreatejs`, `handleTick`, `speed`, `overSpeed`, `smooth`
109
+
110
+ ## Objects and their PixiJS nodes
111
+
112
+ Every instance is a CreateJS-compatible object (what frame scripts see as `this`), shown by a PixiJS node in its `pixi` property. Common values are stored once: `instance.x = 100` and `instance.pixi.x = 100` are the same write, and `instance.pixi` is always current.
113
+
114
+ Members whose meaning differs keep the CreateJS meaning on the instance and the PixiJS meaning on the node:
115
+
116
+ | Member | On the instance | On `instance.pixi` |
117
+ |---|---|---|
118
+ | `rotation` | Degrees | Radians (`angle` is degrees) |
119
+ | `skewX` / `skewY` | Degrees, CreateJS skew | `skew` in radians |
120
+ | `mask`, `filters`, `parent`, `children` | CreateJS-compatible objects | PixiJS objects |
121
+
122
+ - **Do not draw into a shape's `pixi` node** (`clear()`, `lineTo()`, ...): shapes showing the same drawing share one geometry, so the change shows everywhere
123
+ - Named instances placed in Animate (`this.button`, ...) exist at run time but are not in the types (`MovieClip` has no index signature)
124
+ - `addEventListener` / `dispatchEvent` follow CreateJS, so the usual pattern of dispatching an event from a frame script and listening in the application works
125
+ - Frame scripts run as published. They see `this`, `cjs` / `createjs` (the player's compatible classes, not real CreateJS) and `lib`. `exportRoot` and `stage` are undefined; `playSound()` plays nothing
126
+
127
+ ## Current limits (tell the user instead of working around silently)
128
+
129
+ - Buttons do not react to the pointer and CreateJS mouse events (`click`, `mousedown`, `rollover`, ...) are never called. For input, listen to PixiJS events on `instance.pixi` (`pointertap`, ... with `interactive = true`)
130
+ - Sound is not played
131
+ - The Animate camera ("Advanced Layers") is not supported: delete the camera layer and publish again
132
+ - Dynamic text: lines break as in the published content; vertical position can differ slightly by font
133
+
134
+ ## Coming from pixi-animate-container
135
+
136
+ | pixi-animate-container | pixi-animate-runtime |
137
+ |---|---|
138
+ | Script tags for CreateJS and the published `.js` | Script tag for the runtime content file only |
139
+ | `PIXI.animate` | `PIXI.animateRuntime` |
140
+ | `loadAssetAsync(targets)` → `lib` | `loadContentAsync(targets)` → content (`content.lib`) |
141
+ | `new lib.game()` | `content.create('game')` |
142
+ | `PIXI.animate.Container` | `AnimateContainer` |
143
+ | `createjsSpeed` / `createjsOverSpeed` | `speed` / `overSpeed` |
144
+ | `CreatejsMovieClip` etc. | `MovieClip` etc. |
145
+
146
+ Not available: `listenFrameEvents`, `useSound`, CreateJS mouse events.
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: pixim-animate-runtime-guide
3
+ description: Use this skill whenever the user asks to create, edit, or debug content using @tawaship/pixim-animate-runtime — a plugin that plays Adobe Animate HTML5 Canvas (CreateJS) content in Pixim.js applications from runtime content files generated at development time, without CreateJS. Trigger on any mention of 'pixim-animate-runtime', 'Animate コンテンツ', 'Adobe Animate' or 'createjs' in a Pixim.js project that has @tawaship/pixim-animate-runtime installed, or on concepts like defineAnimateContentsTo, addAnimateContentsTo, $.resources.animateContents, Pixim.animateRuntime, or AnimateContainer in a Pixim.js project. If the project uses @tawaship/pixim-animate-container instead (CreateJS at run time, defineAnimatesTo), use the pixim-animate-container-guide skill.
4
+ ---
5
+
6
+ # @tawaship/pixim-animate-runtime development skill
7
+
8
+ Supported versions: **`^0.1.0`** (written against `0.1.0`).
9
+
10
+ First determine the installed version (`node_modules/@tawaship/pixim-animate-runtime/package.json`). If it is outside the supported range, **treat the type definitions in node_modules as authoritative** and follow them wherever they disagree with this skill.
11
+
12
+ The content is assumed to be published by **Adobe Animate 24.0.15** for HTML5 Canvas, the only version checked: this package depends on the form of the published JavaScript. If the user's content comes from another version of Animate and something does not work, mention this before looking for other causes.
13
+
14
+ ## Dependencies
15
+
16
+ Read these skills first, then apply this one:
17
+
18
+ - **pixi-animate-runtime-guide** — this package is the player of `@tawaship/pixi-animate-runtime` with Pixim.js loading and playing. Generating runtime content, creating instances, the objects and their PixiJS nodes, and the current limits are all described there and apply unchanged
19
+ - A Pixim.js v1.15 skill (such as pixim-js-dev) and a PixiJS v5.3 skill, if available
20
+
21
+ ## Overview
22
+
23
+ This package bundles the player of pixi-animate-runtime (do not load pixi-animate-runtime as well) and adds what a Pixim application needs:
24
+
25
+ - Contents are **assets of a Pixim content**: defined with `defineAnimateContentsTo`, loaded with the content's other assets, and given as `$.resources.animateContents[name]`
26
+ - `AnimateContainer` is a **Pixim container** that plays the instances put on it through its task, while it is on the display tree of a running application
27
+
28
+ As with pixi-animate-runtime, **runtime content files are generated at development time** (`npx --no-install @tawaship/pixi-animate-runtime <published directory>`) and must be generated again after publishing again from Animate. CreateJS and the published `.js` are never loaded.
29
+
30
+ ## Type definition files
31
+
32
+ **Before writing code that uses a class, method, or property of this package, check the corresponding type definition file** in the installed package (`node_modules/@tawaship/pixim-animate-runtime/types/`). Everything of pixi-animate-runtime is re-exported; its types are in `node_modules/@tawaship/pixi-animate-runtime/types/player/` (see pixi-animate-runtime-guide).
33
+
34
+ | What | Type definition file |
35
+ |---|---|
36
+ | Everything exported | `types/index.d.ts` |
37
+ | `defineAnimateContentsTo`, `addAnimateContentsTo`, `ANIMATE_CONTENTS` | `types/AnimateContentManifest.d.ts` |
38
+ | The target of each content (`id`, `basepath`, `filepath`, `options`) | `types/AnimateContentLoader.d.ts` |
39
+ | `AnimateContainer` (Pixim) | `types/AnimateContainer.d.ts` |
40
+
41
+ ## Basic usage
42
+
43
+ ### 1. Loading the scripts
44
+
45
+ ```html
46
+ <script src="pixi.js"></script>
47
+ <script src="Pixim.js"></script>
48
+ <script src="pixim-animate-runtime.js"></script>
49
+ ```
50
+
51
+ In a browser setup the module is `Pixim.animateRuntime`. With a bundler: `import { defineAnimateContentsTo, AnimateContainer } from '@tawaship/pixim-animate-runtime'`.
52
+
53
+ ### 2. Defining contents and playing them
54
+
55
+ ```javascript
56
+ const { defineAnimateContentsTo, AnimateContainer } = Pixim.animateRuntime;
57
+
58
+ const Game = Pixim.Content.create();
59
+
60
+ defineAnimateContentsTo(Game, {
61
+ title: { id: 'COMPOSITION_ID', basepath: 'assets/animates/', filepath: 'title.js' }
62
+ });
63
+
64
+ class Root extends Pixim.Container {
65
+ constructor($) {
66
+ super();
67
+ const content = $.resources.animateContents.title;
68
+ const container = new AnimateContainer();
69
+ this.addChild(container);
70
+ container.addCreatejs(content.create('title')); // the symbol the published HTML used as its root
71
+ }
72
+ }
73
+
74
+ Game.defineLibraries({ root: Root });
75
+ ```
76
+
77
+ - `id`: the composition id (printed by `npx --no-install @tawaship/pixi-animate-runtime`, and written at the top of the runtime content file)
78
+ - `basepath`: the directory of the runtime content file and its images, relative to the Pixim content's `basepath` option
79
+ - `filepath`: the runtime content file, relative to `basepath`. Without it, the file has to be loaded already (by a script tag)
80
+ - `options`: as pixi-animate-runtime's `loadContentAsync` (`crossOrigin`, `handleManifest`)
81
+ - `defineAnimateContentsTo(Game, targets, { unrequired: true })` gives `null` for a content that failed to load instead of failing the whole Pixim content
82
+ - `addAnimateContentsTo(game, targets)` adds contents to one instance of a Pixim content
83
+ - `$.resources.animateContents.title` is the content as `loadContentAsync` gives it: `id`, `lib`, `properties`, `create(id)`
84
+
85
+ **No ticker wiring is needed**: unlike pixi-animate-runtime's container, the Pixim `AnimateContainer` plays through its own task while it is on the display tree of a running application.
86
+
87
+ ### 3. Options of the Pixim content
88
+
89
+ The Pixim content's own options apply to runtime content files and images as to its other assets:
90
+
91
+ - `version` adds `_fv=<version>` to the URLs. `typeOptions.animateContents.fileVersion` / `assetVersion` set it for the files / the images separately
92
+ - `xhr` fetches the runtime content files and the images with its request options
93
+
94
+ ### 4. AnimateContainer
95
+
96
+ - `addCreatejs(instance)` / `addCreatejsAt(instance, index)` / `removeCreatejs(instance)`; a movie clip put on again starts from its first frame
97
+ - `speed` (`1` = published frame rate, `0` stops), `overSpeed` (default `true`; `false` plays at most one frame per application frame), `smooth` (default `true`; even playing when the frame time varies a little, as in pixi-animate-runtime-guide)
98
+ - `taskEnabled = false` stops playing. The container's `task` is free for your own use: clearing it does not stop playing
99
+
100
+ ## Coming from pixim-animate-container
101
+
102
+ | pixim-animate-container | pixim-animate-runtime |
103
+ |---|---|
104
+ | Script tag for CreateJS | None |
105
+ | `Pixim.animate` | `Pixim.animateRuntime` |
106
+ | `defineAnimatesTo(Game, {...})`, `filepath` = published `.js` | `defineAnimateContentsTo(Game, {...})`, `filepath` = runtime content file |
107
+ | `addAnimatesTo` | `addAnimateContentsTo` |
108
+ | `$.resources.animates.name` (`lib`) → `new ...game()` | `$.resources.animateContents.name` (content) → `.create('game')` |
109
+ | `Pixim.animate.Container` | `AnimateContainer` |
110
+ | `createjsSpeed` / `createjsOverSpeed` | `speed` / `overSpeed` |
111
+
112
+ Not available: `replaceInstance()`, `replaceTexture()`, and what pixi-animate-runtime does not have (`listenFrameEvents`, `useSound`, CreateJS mouse events).
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@tawaship/pixim-animate-runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Plays Adobe Animate HTML5 Canvas content in Pixim.js: loads runtime content generated by @tawaship/pixi-animate-runtime as a Pixim content asset.",
5
+ "main": "dist/pixim-animate-runtime.cjs.js",
6
+ "module": "dist/pixim-animate-runtime.esm.js",
7
+ "browser": "dist/pixim-animate-runtime.js",
8
+ "types": "types/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "types",
12
+ "dist-skills"
13
+ ],
14
+ "scripts": {
15
+ "rollup": "rollup -c --bundleConfigAsCjs",
16
+ "d": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --outDir ./types",
17
+ "build": "npm run rollup -- --environment PROD && npm run d && echo done.",
18
+ "docs": "typedoc",
19
+ "prepublishOnly": "node scripts/check-publish.js"
20
+ },
21
+ "keywords": [
22
+ "pixi.js",
23
+ "pixim.js",
24
+ "adobe-animate",
25
+ "createjs"
26
+ ],
27
+ "author": "tawaship",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/tawaship/Pixim-animate-runtime.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/tawaship/Pixim-animate-runtime/issues"
35
+ },
36
+ "homepage": "https://tawaship.github.io/Pixim-animate-runtime/",
37
+ "peerDependencies": {
38
+ "@tawaship/pixim.js": "^1.15.2",
39
+ "pixi.js": "^5.3.2"
40
+ },
41
+ "dependencies": {
42
+ "@tawaship/pixi-animate-runtime": "^0.1.0"
43
+ },
44
+ "devDependencies": {
45
+ "@rollup/plugin-buble": "^1.0.3",
46
+ "@rollup/plugin-typescript": "^12.3.1",
47
+ "@tawaship/pixim.js": "1.15.2",
48
+ "del": "^8.0.1",
49
+ "pixi.js": "5.3.9",
50
+ "rollup": "^4.65.0",
51
+ "tslib": "^2.8.1",
52
+ "typedoc": "^0.28.20",
53
+ "typescript": "^6.0.3"
54
+ }
55
+ }
@@ -0,0 +1,34 @@
1
+ import { Container, ITickerData } from '@tawaship/pixim.js';
2
+ import { DisplayObject } from '@tawaship/pixi-animate-runtime';
3
+ /**
4
+ * A Pixim container that plays the content roots put on it at their
5
+ * content's frame rate (the rate the content was published with), while it is
6
+ * on the display tree of a running Pixim application.
7
+ *
8
+ * Each frame of the application plays `delta x speed x fps / 60` frames of every
9
+ * root (delta being the application ticker's), one frame being createjs's tick
10
+ * phase followed by its resolve phase; the first frame after a root is put on
11
+ * only settles it on its first frame. Playing stops while `taskEnabled` is
12
+ * false. The container's own `task` is free for the application: what it holds
13
+ * does not change the playing.
14
+ */
15
+ export declare class AnimateContainer extends Container {
16
+ private readonly _controller;
17
+ constructor();
18
+ /** Playback speed (1 is the content's own frame rate) */
19
+ get speed(): number;
20
+ set speed(value: number);
21
+ /** Whether one frame of the application may play more than one frame of a root (when the display runs slower than the content) */
22
+ get overSpeed(): boolean;
23
+ set overSpeed(value: boolean);
24
+ /** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */
25
+ get smooth(): boolean;
26
+ set smooth(value: boolean);
27
+ updateTask(e: ITickerData): void;
28
+ /** Plays the roots by hand, as one frame of the application with this delta does */
29
+ handleTick(delta: number): void;
30
+ /** Puts a content object on this container; a MovieClip plays from then on */
31
+ addCreatejs<T extends DisplayObject>(obj: T): T;
32
+ addCreatejsAt<T extends DisplayObject>(obj: T, index: number): T;
33
+ removeCreatejs<T extends DisplayObject>(obj: T): T;
34
+ }
@@ -0,0 +1,35 @@
1
+ import { ILoaderOption, LoaderBase, LoaderResource, TLoaderResourceVersion } from '@tawaship/pixim.js';
2
+ import { IContent, IContentTarget } from '@tawaship/pixi-animate-runtime';
3
+ /** A content to load: what loadContentAsync takes, and the runtime content file to load first */
4
+ export interface IAnimateContentLoaderTarget extends IContentTarget {
5
+ /**
6
+ * The runtime content file, relative to `basepath`. Loaded (as a script) before
7
+ * the content when given; otherwise it has to be loaded already.
8
+ */
9
+ filepath?: string;
10
+ }
11
+ export interface IAnimateContentLoaderOption extends ILoaderOption {
12
+ /** The version added to the runtime content file's URL (`version` when omitted) */
13
+ fileVersion?: TLoaderResourceVersion;
14
+ /** The version added to the image URLs (`version` when omitted) */
15
+ assetVersion?: TLoaderResourceVersion;
16
+ }
17
+ export declare class AnimateContentLoaderResource extends LoaderResource<IContent | null> {
18
+ destroy(): void;
19
+ }
20
+ /**
21
+ * Loads a content as a Pixim asset: its runtime content file (when a filepath
22
+ * is given), then the content with loadContentAsync, the base path being the
23
+ * Pixim content's and the target's together.
24
+ *
25
+ * With the Pixim content's `xhr` option, the images are fetched (with its
26
+ * request options) into blob: URLs first, after the target's own
27
+ * handleManifest; the blob: URLs are released once the content is loaded.
28
+ */
29
+ export declare class AnimateContentLoader extends LoaderBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {
30
+ protected _loadAsync(target: IAnimateContentLoaderTarget, options?: IAnimateContentLoaderOption): Promise<AnimateContentLoaderResource>;
31
+ private _loadFileAsync;
32
+ private _loadContentAsync;
33
+ /** The images fetched into blob: URLs, which then stand for their files */
34
+ private _fetchImagesAsync;
35
+ }
@@ -0,0 +1,17 @@
1
+ import { Content, IManifestOption, ManifestBase } from '@tawaship/pixim.js';
2
+ import { IContent } from '@tawaship/pixi-animate-runtime';
3
+ import { AnimateContentLoader, AnimateContentLoaderResource, IAnimateContentLoaderTarget } from './AnimateContentLoader';
4
+ /** The key of the contents in a Pixim content's resources: `$.resources.animateContents` */
5
+ export declare const ANIMATE_CONTENTS = "animateContents";
6
+ export declare class AnimateContentManifest extends ManifestBase<IAnimateContentLoaderTarget, IContent | null, AnimateContentLoaderResource> {
7
+ protected _createLoader(): AnimateContentLoader;
8
+ }
9
+ /**
10
+ * Defines contents for a Pixim content class: each is loaded with the class's
11
+ * other assets and given as `$.resources.animateContents[name]`.
12
+ */
13
+ export declare function defineAnimateContentsTo(PiximContent: typeof Content, targets: Record<string, IAnimateContentLoaderTarget>, options?: IManifestOption): typeof Content;
14
+ /**
15
+ * Adds contents to a Pixim content instance (loaded with its other assets).
16
+ */
17
+ export declare function addAnimateContentsTo(content: Content, targets: Record<string, IAnimateContentLoaderTarget>, options?: IManifestOption): Content;
@@ -0,0 +1,5 @@
1
+ export * from '@tawaship/pixi-animate-runtime';
2
+ export { AnimateContainer } from './AnimateContainer';
3
+ export { AnimateContentLoader, AnimateContentLoaderResource } from './AnimateContentLoader';
4
+ export type { IAnimateContentLoaderTarget, IAnimateContentLoaderOption } from './AnimateContentLoader';
5
+ export { AnimateContentManifest, ANIMATE_CONTENTS, defineAnimateContentsTo, addAnimateContentsTo } from './AnimateContentManifest';