@tawaship/pixi-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.
- package/LICENSE +21 -0
- package/README.md +452 -2
- package/bin/pixi-animate-runtime.js +27 -0
- package/dist/generator.cjs.js +1056 -0
- package/dist/generator.cjs.js.map +1 -0
- package/dist/pixi-animate-runtime.cjs.js +3678 -0
- package/dist/pixi-animate-runtime.cjs.js.map +1 -0
- package/dist/pixi-animate-runtime.esm.js +3613 -0
- package/dist/pixi-animate-runtime.esm.js.map +1 -0
- package/dist/pixi-animate-runtime.js +3680 -0
- package/dist/pixi-animate-runtime.js.map +1 -0
- package/dist-skills/animate-data-converter-guide/SKILL.md +86 -0
- package/dist-skills/pixi-animate-runtime-guide/SKILL.md +146 -0
- package/package.json +70 -4
- package/tools/pixi-animate-runtime.bat +8 -0
- package/types/generator/generator/cli.d.ts +17 -0
- package/types/generator/generator/converter-version.d.ts +7 -0
- package/types/generator/generator/generate.d.ts +33 -0
- package/types/generator/generator/index.d.ts +6 -0
- package/types/generator/generator/plan.d.ts +87 -0
- package/types/generator/player/data.d.ts +141 -0
- package/types/generator/player/ease.d.ts +11 -0
- package/types/generator/player/semver.d.ts +27 -0
- package/types/generator/player/version.d.ts +2 -0
- package/types/player/animate-container.d.ts +71 -0
- package/types/player/content.d.ts +170 -0
- package/types/player/data.d.ts +141 -0
- package/types/player/display.d.ts +186 -0
- package/types/player/ease.d.ts +11 -0
- package/types/player/events.d.ts +60 -0
- package/types/player/geom.d.ts +19 -0
- package/types/player/index.d.ts +20 -0
- package/types/player/loader.d.ts +53 -0
- package/types/player/movieclip.d.ts +191 -0
- package/types/player/objects.d.ts +320 -0
- package/types/player/semver.d.ts +27 -0
- package/types/player/transform.d.ts +32 -0
- package/types/player/version.d.ts +2 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic version numbers and ranges, as far as the version checks of
|
|
3
|
+
* definitions and runtime content need them: versions are MAJOR.MINOR.PATCH,
|
|
4
|
+
* and ranges are written as npm writes them (`1.2.3`, `1.x`, `^1.2.0`,
|
|
5
|
+
* `~1.2.0`, `>=1.0.0 <2.0.0`, `0.x || 1.x`). Pre-release tags are not handled.
|
|
6
|
+
*/
|
|
7
|
+
type TVersion = [number, number, number];
|
|
8
|
+
/** A version as its three numbers, or null when it is not MAJOR.MINOR.PATCH */
|
|
9
|
+
export declare function parseVersion(text: string): TVersion | null;
|
|
10
|
+
/** -1, 0 or 1 as a is lower than, the same as or higher than b (both have to be versions) */
|
|
11
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
12
|
+
/** Whether a version is in a range (npm's notation, see above); a range not understood throws */
|
|
13
|
+
export declare function satisfies(version: string, range: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether data a reader is given can be read: `error` when its writer's
|
|
16
|
+
* version is outside the range the reader reads, `warning` when it is in the
|
|
17
|
+
* range but newer than the version the reader knows of (the data may hold
|
|
18
|
+
* what the reader does not know and leaves out). Both null when it reads.
|
|
19
|
+
*/
|
|
20
|
+
export interface IVersionCheck {
|
|
21
|
+
error: string | null;
|
|
22
|
+
warning: string | null;
|
|
23
|
+
/** With an error: whether the writer is newer than the reader (update the reader) or older (write the data again) */
|
|
24
|
+
newer: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function checkVersion(version: string, range: string, known: string): IVersionCheck;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as PIXI from 'pixi.js';
|
|
2
|
+
import { DisplayObject } from './display';
|
|
3
|
+
/**
|
|
4
|
+
* Plays the content roots put on a Pixi container at their content's frame
|
|
5
|
+
* rate (the rate the content was published with). AnimateContainer is a Pixi
|
|
6
|
+
* container with one; a container of another framework can hold one too.
|
|
7
|
+
*
|
|
8
|
+
* Each handleTick call owes every root `delta x speed x fps / 60` frames
|
|
9
|
+
* (delta being the ticker's: 1 per frame of a 60 fps display) and plays the
|
|
10
|
+
* whole frames owed. With `smooth`, the frames played follow a steady clock
|
|
11
|
+
* instead of the deltas themselves: it advances by the usual delta of the
|
|
12
|
+
* display (the median of the latest ones) on every call, so that small changes
|
|
13
|
+
* of the delta do not play a frame early or late (0 frames on one call and 2
|
|
14
|
+
* on the next), and it is pulled toward the real time a little on every call,
|
|
15
|
+
* and set to it when they are a frame apart (a frame of the display was
|
|
16
|
+
* missed), so that the content keeps the real time. One frame is createjs's
|
|
17
|
+
* tick phase followed by its resolve phase. The first call after a root is put
|
|
18
|
+
* on only settles it on its first frame.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AnimateController {
|
|
21
|
+
/** Playback speed (1 is the content's own frame rate) */
|
|
22
|
+
speed: number;
|
|
23
|
+
/** Whether one call may play more than one frame (when the display runs slower than the content) */
|
|
24
|
+
overSpeed: boolean;
|
|
25
|
+
/** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */
|
|
26
|
+
smooth: boolean;
|
|
27
|
+
private readonly _container;
|
|
28
|
+
private _targets;
|
|
29
|
+
private _nextId;
|
|
30
|
+
/** The latest deltas (a ring of DELTA_SAMPLES) */
|
|
31
|
+
private _deltas;
|
|
32
|
+
private _nextDelta;
|
|
33
|
+
/** @param container The container the roots are put on */
|
|
34
|
+
constructor(container: PIXI.Container);
|
|
35
|
+
handleTick(delta: number): void;
|
|
36
|
+
/** Records a delta and gives the median of the latest ones */
|
|
37
|
+
private _usualDelta;
|
|
38
|
+
/** Puts a content object on the container; a MovieClip plays from then on */
|
|
39
|
+
addCreatejs<T extends DisplayObject>(obj: T): T;
|
|
40
|
+
addCreatejsAt<T extends DisplayObject>(obj: T, index: number): T;
|
|
41
|
+
removeCreatejs<T extends DisplayObject>(obj: T): T;
|
|
42
|
+
/**
|
|
43
|
+
* A MovieClip is played while its node is on the container. Coming from
|
|
44
|
+
* another parent, it starts over from its first frame.
|
|
45
|
+
*/
|
|
46
|
+
private _register;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A Pixi container that plays the content roots put on it at their
|
|
50
|
+
* content's frame rate (see AnimateController).
|
|
51
|
+
*
|
|
52
|
+
* Call handleTick from the application's ticker:
|
|
53
|
+
* `app.ticker.add(container.handleTick, container)`.
|
|
54
|
+
*/
|
|
55
|
+
export declare class AnimateContainer extends PIXI.Container {
|
|
56
|
+
private readonly _controller;
|
|
57
|
+
/** Playback speed (1 is the content's own frame rate) */
|
|
58
|
+
get speed(): number;
|
|
59
|
+
set speed(value: number);
|
|
60
|
+
/** Whether one call may play more than one frame (when the display runs slower than the content) */
|
|
61
|
+
get overSpeed(): boolean;
|
|
62
|
+
set overSpeed(value: boolean);
|
|
63
|
+
/** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */
|
|
64
|
+
get smooth(): boolean;
|
|
65
|
+
set smooth(value: boolean);
|
|
66
|
+
handleTick(delta: number): void;
|
|
67
|
+
/** Puts a content object on this container; a MovieClip plays from then on */
|
|
68
|
+
addCreatejs<T extends DisplayObject>(obj: T): T;
|
|
69
|
+
addCreatejsAt<T extends DisplayObject>(obj: T, index: number): T;
|
|
70
|
+
removeCreatejs<T extends DisplayObject>(obj: T): T;
|
|
71
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as PIXI from 'pixi.js';
|
|
2
|
+
import { DisplayObject, Container } from './display';
|
|
3
|
+
import { Rectangle } from './geom';
|
|
4
|
+
import { Event, EventDispatcher } from './events';
|
|
5
|
+
import { MovieClip, TScript, TWriter, TMemberWriter } from './movieclip';
|
|
6
|
+
import { Shape, Graphics, Sprite, SpriteSheet, Bitmap, Text, ColorFilter, ButtonHelper, ITextureSource, IImageAsset } from './objects';
|
|
7
|
+
import { IRuntimeData, IRuntimeMovieClipDef, IRuntimeTweenDef, IRuntimeSlotDef, ISpriteDef, IBitmapDef } from './data';
|
|
8
|
+
export type TMovieClipClass = new (mode?: string | null, startPosition?: number | null, loop?: boolean | number | null) => MovieClip;
|
|
9
|
+
export type TSpriteClass = new () => Sprite;
|
|
10
|
+
export type TBitmapClass = new () => Bitmap;
|
|
11
|
+
export type TSymbolClass = TMovieClipClass | TSpriteClass | TBitmapClass;
|
|
12
|
+
/**
|
|
13
|
+
* The symbol classes of a content by symbol id: what published code calls `lib`.
|
|
14
|
+
*/
|
|
15
|
+
export interface ILibrary {
|
|
16
|
+
[id: string]: TSymbolClass;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The createjs-compatible names frame scripts reach as `cjs` / `createjs`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const namespace: {
|
|
22
|
+
DisplayObject: typeof DisplayObject;
|
|
23
|
+
Container: typeof Container;
|
|
24
|
+
MovieClip: typeof MovieClip;
|
|
25
|
+
Shape: typeof Shape;
|
|
26
|
+
Graphics: typeof Graphics;
|
|
27
|
+
Sprite: typeof Sprite;
|
|
28
|
+
SpriteSheet: typeof SpriteSheet;
|
|
29
|
+
Bitmap: typeof Bitmap;
|
|
30
|
+
Text: typeof Text;
|
|
31
|
+
ColorFilter: typeof ColorFilter;
|
|
32
|
+
ButtonHelper: typeof ButtonHelper;
|
|
33
|
+
Event: typeof Event;
|
|
34
|
+
EventDispatcher: typeof EventDispatcher;
|
|
35
|
+
Rectangle: typeof Rectangle;
|
|
36
|
+
Point: typeof PIXI.Point;
|
|
37
|
+
};
|
|
38
|
+
export type TNamespace = typeof namespace;
|
|
39
|
+
/** What frame scripts get for the template's global playSound: nothing is played */
|
|
40
|
+
export interface ISilentSound {
|
|
41
|
+
paused: boolean;
|
|
42
|
+
volume: number;
|
|
43
|
+
addEventListener(): void;
|
|
44
|
+
removeEventListener(): void;
|
|
45
|
+
on(): void;
|
|
46
|
+
stop(): void;
|
|
47
|
+
play(): void;
|
|
48
|
+
}
|
|
49
|
+
export interface IGeneratedContent {
|
|
50
|
+
data: IRuntimeData;
|
|
51
|
+
scripts: TScript[];
|
|
52
|
+
writers: TWriter[];
|
|
53
|
+
memberWriters: TMemberWriter[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What runtime content exports: given the names frame scripts refer
|
|
57
|
+
* to, it returns the content's data and its frame scripts (as code, closed
|
|
58
|
+
* over those names). exportRoot and stage are passed as undefined: they are
|
|
59
|
+
* the template's root and stage, which a player of any symbol does not have.
|
|
60
|
+
*/
|
|
61
|
+
export type TContentFactory = (cjs: TNamespace, createjs: TNamespace, lib: ILibrary, exportRoot: undefined, stage: undefined, playSound: () => ISilentSound) => IGeneratedContent;
|
|
62
|
+
export interface IContentAssets {
|
|
63
|
+
/** Textures of the manifest images (sprite sheet atlases included), by manifest id */
|
|
64
|
+
images?: {
|
|
65
|
+
[id: string]: PIXI.Texture;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** A value of the published lib.properties (width, height, fps, color, ...) */
|
|
69
|
+
export type TContentProperty = number | string | boolean | null;
|
|
70
|
+
export interface IContentProperties {
|
|
71
|
+
[key: string]: TContentProperty;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A loaded content, as the application uses it.
|
|
75
|
+
*/
|
|
76
|
+
export interface IContent {
|
|
77
|
+
/** The composition id (lib.properties.id of the published content) */
|
|
78
|
+
readonly id: string;
|
|
79
|
+
/** The symbol classes by symbol name: what frame scripts reach as `lib` */
|
|
80
|
+
readonly lib: ILibrary;
|
|
81
|
+
/** The values of the published lib.properties (its lists, such as the manifest, left out) */
|
|
82
|
+
readonly properties: Readonly<IContentProperties>;
|
|
83
|
+
/**
|
|
84
|
+
* An instance of a symbol for the application to place, set up as the HTML
|
|
85
|
+
* template sets up the root it creates.
|
|
86
|
+
*/
|
|
87
|
+
create(id: string): DisplayObject;
|
|
88
|
+
}
|
|
89
|
+
/** A MovieClip symbol as the player builds its instances from: its slots with every field */
|
|
90
|
+
interface IMovieClipPlan extends Omit<IRuntimeMovieClipDef, 'slots' | 'tweens'> {
|
|
91
|
+
slots: IRuntimeSlotDef[];
|
|
92
|
+
tweens: IRuntimeTweenDef[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A content: the symbol classes built from generated data, sharing one
|
|
96
|
+
* definition per symbol. Not part of the API: applications get an IContent.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
export declare class Content implements ITextureSource {
|
|
100
|
+
readonly data: IRuntimeData;
|
|
101
|
+
readonly scripts: TScript[];
|
|
102
|
+
readonly writers: TWriter[];
|
|
103
|
+
readonly memberWriters: TMemberWriter[];
|
|
104
|
+
readonly lib: ILibrary;
|
|
105
|
+
readonly images: {
|
|
106
|
+
[id: string]: IImageAsset;
|
|
107
|
+
};
|
|
108
|
+
/** One Graphics per drawing of the content, shared by every symbol that shows it */
|
|
109
|
+
readonly graphics: Graphics[];
|
|
110
|
+
readonly spriteSheets: {
|
|
111
|
+
[name: string]: SpriteSheet;
|
|
112
|
+
};
|
|
113
|
+
private readonly _frameAssets;
|
|
114
|
+
constructor(factory: TContentFactory, assets?: IContentAssets);
|
|
115
|
+
/**
|
|
116
|
+
* Sets the textures of the content's images (by manifest id) and the sprite
|
|
117
|
+
* sheets cut from them. Done before any instance is made: the constructor's
|
|
118
|
+
* assets, or the textures a loader read for the content afterwards.
|
|
119
|
+
*/
|
|
120
|
+
_applyImages(textures: {
|
|
121
|
+
[id: string]: PIXI.Texture;
|
|
122
|
+
}): void;
|
|
123
|
+
image(id: string): PIXI.Texture | null;
|
|
124
|
+
frame(sheet: string, index: number): PIXI.Texture | null;
|
|
125
|
+
imageAsset(id: string): IImageAsset | null;
|
|
126
|
+
/** The image a frame of a sheet is drawn into for a bitmap fill (named after the atlas and the frame) */
|
|
127
|
+
frameAsset(sheet: string, index: number): IImageAsset | null;
|
|
128
|
+
/**
|
|
129
|
+
* An instance of a symbol for the application to place, set up as the HTML
|
|
130
|
+
* template sets up the root it creates: a clip that re-caches its children's
|
|
131
|
+
* color effects (it has a filterCacheList) gets the filter cache handling,
|
|
132
|
+
* which published code otherwise gets from the symbol that creates it (an
|
|
133
|
+
* instance made by `new lib[id]()` in a frame script gets none, as in
|
|
134
|
+
* CreateJS). The handling does not change what the player draws (it draws
|
|
135
|
+
* color effects without caches); it keeps the instance's state the
|
|
136
|
+
* template's.
|
|
137
|
+
*/
|
|
138
|
+
create(id: string): DisplayObject;
|
|
139
|
+
private _movieClipClass;
|
|
140
|
+
private _spriteClass;
|
|
141
|
+
private _bitmapClass;
|
|
142
|
+
private _sheet;
|
|
143
|
+
private _image;
|
|
144
|
+
_applySprite(sprite: Sprite, def: ISpriteDef | null): void;
|
|
145
|
+
_applyBitmap(bitmap: Bitmap, def: IBitmapDef | null): void;
|
|
146
|
+
private _createSlot;
|
|
147
|
+
/**
|
|
148
|
+
* Builds an instance of a MovieClip symbol: what the published
|
|
149
|
+
* constructor builds, from the shared definition.
|
|
150
|
+
*/
|
|
151
|
+
_populate(self: MovieClip, def: IMovieClipPlan, graphics: Graphics[]): void;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* What the application gets of a content: the content itself stays out of
|
|
155
|
+
* reach, the methods closing over it.
|
|
156
|
+
*/
|
|
157
|
+
export declare function contentInterface(content: Content): IContent;
|
|
158
|
+
/**
|
|
159
|
+
* Plays one frame of a display tree the way createjs does on a stage update:
|
|
160
|
+
* the tick phase (playheads advance, children in reverse order, tick
|
|
161
|
+
* listeners), then the resolve phase (each MovieClip settles its timeline,
|
|
162
|
+
* children in reverse order).
|
|
163
|
+
*/
|
|
164
|
+
export declare function tick(root: DisplayObject, event?: Event): void;
|
|
165
|
+
/**
|
|
166
|
+
* The resolve phase alone: each MovieClip settles its timeline (children in
|
|
167
|
+
* reverse order), without playing a frame.
|
|
168
|
+
*/
|
|
169
|
+
export declare function resolveState(node: DisplayObject): void;
|
|
170
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data of runtime content (what the generator writes and the player reads): the definition
|
|
3
|
+
* extracted by @tawaship/animate-data-converter, with every frame script
|
|
4
|
+
* taken out of the data and referenced by its index in the runtime content's
|
|
5
|
+
* script list (the scripts themselves are code in the runtime content), and with
|
|
6
|
+
* the writes of each tween and of each instance's initial values compiled
|
|
7
|
+
* into writer functions (code in the runtime content as well, referenced by index).
|
|
8
|
+
* Drawings are gathered into one table for the whole content, identical
|
|
9
|
+
* ones merged, and a symbol refers to them by index.
|
|
10
|
+
*/
|
|
11
|
+
import type { IMovieClipSymbolDef, ISpriteSymbolDef, IBitmapSymbolDef, ITweenDef, IPropMapDef, ISlotDef, IManifestEntryDef, ISpriteSheetDef, IGraphicsCommandDef, IStateEntryDef, TDataValue, TFrameValue } from '@tawaship/animate-data-converter';
|
|
12
|
+
import { TEase } from './ease';
|
|
13
|
+
/** A kind of drawing command: its type and the names of its props, in order */
|
|
14
|
+
export type TRuntimeCommandKind = [string, string[]];
|
|
15
|
+
/** A drawing command as written in runtime content: the index of its kind, then its props' values in the kind's order */
|
|
16
|
+
export type TRuntimeCommand = TDataValue[];
|
|
17
|
+
/** A drawing as written in runtime content */
|
|
18
|
+
export interface IRuntimeGraphicsData {
|
|
19
|
+
commands: TRuntimeCommand[];
|
|
20
|
+
}
|
|
21
|
+
/** A drawing's commands as the player draws them, from their written form */
|
|
22
|
+
export declare function commandsOf(kinds: TRuntimeCommandKind[], graphics: IRuntimeGraphicsData): IGraphicsCommandDef[];
|
|
23
|
+
export type { ISlotDef, ITweenDef, IStateEntryDef, IGraphicsDef, IGraphicsCommandDef, ISpriteDef, IBitmapDef, IFilterDef, ICacheDef, IButtonDef, IFilterCacheEntryDef, IRectDef, IDataMap, IPropMapDef, IManifestEntryDef, ISpriteSheetDef, ILabelDef, IMemberDef, TTargetDef, TFrameValue, TDataValue, ISpriteSymbolDef, IBitmapSymbolDef } from '@tawaship/animate-data-converter';
|
|
24
|
+
/**
|
|
25
|
+
* The pixi-animate-runtime versions whose runtime content this player plays
|
|
26
|
+
* (npm's range notation). Raised when the player stops playing runtime
|
|
27
|
+
* content older versions made.
|
|
28
|
+
*/
|
|
29
|
+
export declare const RUNTIME_CONTENT_RANGE = "0.x";
|
|
30
|
+
export interface IRuntimeActionDef {
|
|
31
|
+
/** Timeline position the action sits on */
|
|
32
|
+
position: number;
|
|
33
|
+
/** Index into the runtime content's script list */
|
|
34
|
+
script: number;
|
|
35
|
+
params: TFrameValue[] | null;
|
|
36
|
+
}
|
|
37
|
+
export interface IRuntimeTweenDef extends Omit<ITweenDef, 'actions' | 'frames'> {
|
|
38
|
+
actions: IRuntimeActionDef[];
|
|
39
|
+
/** The tween's distinct frame values (each the values of its props, in order) */
|
|
40
|
+
values: TFrameValue[][];
|
|
41
|
+
/** For every position, the index of its values in values (a position holding the same values as another shares them) */
|
|
42
|
+
frames: number[];
|
|
43
|
+
/**
|
|
44
|
+
* Index into the runtime content's writer list: the function that writes a frame's
|
|
45
|
+
* values (values[frames[position]]) to the target, one property after another by
|
|
46
|
+
* name (null when the tween writes no property)
|
|
47
|
+
*/
|
|
48
|
+
writer: number | null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A slot as the player uses it. Its initial values are in code only (the
|
|
52
|
+
* writer), not in the data.
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* A frame value as written in runtime content: a display list (`state`) may
|
|
56
|
+
* give an entry that places a slot as it is (no props) as the slot's index
|
|
57
|
+
*/
|
|
58
|
+
export type TRuntimeFrameValue = TFrameValue | Array<IStateEntryDef | number>;
|
|
59
|
+
/**
|
|
60
|
+
* A position, or a stretch of positions, of a tween as written in runtime
|
|
61
|
+
* content: the index of the position's values, or an interpolated stretch
|
|
62
|
+
* [from, to, length, ease] whose positions run from values[from] toward
|
|
63
|
+
* values[to] (the position after the stretch) as CreateJS interpolates a
|
|
64
|
+
* step with that ease (see interpolated)
|
|
65
|
+
*/
|
|
66
|
+
export type TRuntimeFrameRef = number | [number, number, number, string];
|
|
67
|
+
/** A tween as written in runtime content (tweenOf makes its values for every position) */
|
|
68
|
+
export interface IRuntimeTweenData extends Omit<IRuntimeTweenDef, 'values' | 'frames'> {
|
|
69
|
+
values: TRuntimeFrameValue[][];
|
|
70
|
+
frames: TRuntimeFrameRef[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The values at a position of a step, as CreateJS's Tween computes them: the
|
|
74
|
+
* ratio of the position in the step, eased, then each value from its start
|
|
75
|
+
* toward its end (a value that is not a number, or does not change, keeps its
|
|
76
|
+
* start until the eased ratio reaches 1).
|
|
77
|
+
*/
|
|
78
|
+
export declare function interpolated(from: TFrameValue[], to: TFrameValue[], position: number, length: number, ease: TEase | null): TFrameValue[];
|
|
79
|
+
/**
|
|
80
|
+
* A tween with the values of every position: its display lists (the values of
|
|
81
|
+
* its `state` prop) as entries, and its interpolated stretches computed (each
|
|
82
|
+
* position of a stretch gets values of its own)
|
|
83
|
+
*/
|
|
84
|
+
export declare function tweenOf(data: IRuntimeTweenData): IRuntimeTweenDef;
|
|
85
|
+
export interface IRuntimeSlotDef extends Omit<ISlotDef, 'init'> {
|
|
86
|
+
/** Index into the runtime content's writer list: the function that writes the slot's initial values (initValues) */
|
|
87
|
+
initWriter: number | null;
|
|
88
|
+
/** The slot's initial values, in the order its writer writes them */
|
|
89
|
+
initValues: TFrameValue[] | null;
|
|
90
|
+
}
|
|
91
|
+
/** The values a slot's fields have when runtime content leaves them out */
|
|
92
|
+
export declare const SLOT_DEFAULTS: Omit<IRuntimeSlotDef, 'kind'>;
|
|
93
|
+
/**
|
|
94
|
+
* A slot template as written in runtime content: its kind, and the fields not
|
|
95
|
+
* at their defaults (SLOT_DEFAULTS); its initial values are the slot's own
|
|
96
|
+
*/
|
|
97
|
+
export type TRuntimeSlotData = Pick<IRuntimeSlotDef, 'kind'> & Partial<Omit<IRuntimeSlotDef, 'kind' | 'initValues'>>;
|
|
98
|
+
/**
|
|
99
|
+
* A slot as written in a symbol: the index of its template in the content's
|
|
100
|
+
* slotTemplates, with its initial values when it has some
|
|
101
|
+
*/
|
|
102
|
+
export type TRuntimeSlotRef = number | [number, TFrameValue[]];
|
|
103
|
+
/** A slot from its template (the fields left out at their defaults) and its initial values */
|
|
104
|
+
export declare function slotOf(templates: TRuntimeSlotData[], ref: TRuntimeSlotRef): IRuntimeSlotDef;
|
|
105
|
+
export interface IRuntimeMovieClipDef extends Omit<IMovieClipSymbolDef, 'tweens' | 'slots' | 'graphics' | 'members'> {
|
|
106
|
+
/** The slots as written (templates and initial values; slotOf makes them whole) */
|
|
107
|
+
slots: TRuntimeSlotRef[];
|
|
108
|
+
/** The tweens as written (display lists with slot indexes; tweenOf turns them back into entries) */
|
|
109
|
+
tweens: IRuntimeTweenData[];
|
|
110
|
+
/**
|
|
111
|
+
* Index into the runtime content's member writer list: the function that
|
|
112
|
+
* gives an instance its named children (`this.instance = ...`), or null
|
|
113
|
+
* when it has none
|
|
114
|
+
*/
|
|
115
|
+
memberWriter: number | null;
|
|
116
|
+
/**
|
|
117
|
+
* The symbol's drawings as indexes into the content's drawing table
|
|
118
|
+
* (graphics[n] is the drawing the symbol's slots and tween values call n)
|
|
119
|
+
*/
|
|
120
|
+
graphics: number[];
|
|
121
|
+
}
|
|
122
|
+
export type TRuntimeSymbolDef = IRuntimeMovieClipDef | ISpriteSymbolDef | IBitmapSymbolDef;
|
|
123
|
+
export interface IRuntimeData {
|
|
124
|
+
/** The version of pixi-animate-runtime that generated the runtime content */
|
|
125
|
+
runtimeVersion: string;
|
|
126
|
+
/** Primitive entries of the published lib.properties (width, height, fps, color, ...) */
|
|
127
|
+
properties: IPropMapDef;
|
|
128
|
+
/** Images of the published manifest (sounds are left out) */
|
|
129
|
+
images: IManifestEntryDef[];
|
|
130
|
+
/** The published lib.ssMetadata */
|
|
131
|
+
spriteSheets: ISpriteSheetDef[];
|
|
132
|
+
/** Every drawing of the content, identical ones merged (shared by every symbol that shows them); commandsOf reads them */
|
|
133
|
+
graphics: IRuntimeGraphicsData[];
|
|
134
|
+
/** The kinds of the drawings' commands (a type and the names of its props) */
|
|
135
|
+
commandKinds: TRuntimeCommandKind[];
|
|
136
|
+
/** The slots of every symbol but their initial values, identical ones merged */
|
|
137
|
+
slotTemplates: TRuntimeSlotData[];
|
|
138
|
+
symbols: {
|
|
139
|
+
[id: string]: TRuntimeSymbolDef;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as PIXI from 'pixi.js';
|
|
2
|
+
import { Event, EventDispatcher } from './events';
|
|
3
|
+
import { Rectangle } from './geom';
|
|
4
|
+
/**
|
|
5
|
+
* A Pixi node owned by a createjs-compatible display object.
|
|
6
|
+
*/
|
|
7
|
+
export interface IOwnedNode extends PIXI.Container {
|
|
8
|
+
owner: DisplayObject | null;
|
|
9
|
+
}
|
|
10
|
+
export declare class PixiContainer extends PIXI.Container implements IOwnedNode {
|
|
11
|
+
owner: DisplayObject | null;
|
|
12
|
+
}
|
|
13
|
+
/** A hit area nothing is inside: Pixi's hit test skips a node with it and the node's children */
|
|
14
|
+
export declare const NO_HIT_AREA: PIXI.Rectangle;
|
|
15
|
+
/**
|
|
16
|
+
* Members a filter shown through a display object has to provide.
|
|
17
|
+
*/
|
|
18
|
+
export interface IFilterLike {
|
|
19
|
+
pixiFilter: PIXI.Filter;
|
|
20
|
+
}
|
|
21
|
+
export interface ICacheState {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
scale: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* createjs-compatible display object: a window onto a Pixi node.
|
|
30
|
+
*
|
|
31
|
+
* The values both have in common live on the Pixi node only (x / y on
|
|
32
|
+
* position, scaleX / scaleY on scale, regX / regY on pivot, alpha, visible),
|
|
33
|
+
* read and written through accessors, so a write through the Pixi node and a
|
|
34
|
+
* write through this object are the same write. Members that mean different
|
|
35
|
+
* things in createjs and Pixi keep the createjs meaning here (rotation and
|
|
36
|
+
* skew in degrees, mask, filters, parent); the Pixi node keeps the Pixi one.
|
|
37
|
+
*/
|
|
38
|
+
export declare class DisplayObject extends EventDispatcher {
|
|
39
|
+
/** The Pixi node this object shows */
|
|
40
|
+
readonly pixi: IOwnedNode;
|
|
41
|
+
readonly id: number;
|
|
42
|
+
parent: Container | null;
|
|
43
|
+
tickEnabled: boolean;
|
|
44
|
+
mouseEnabled: boolean;
|
|
45
|
+
cursor: string | null;
|
|
46
|
+
hitArea: DisplayObject | null;
|
|
47
|
+
shadow: null;
|
|
48
|
+
snapToPixel: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Kept off the display list by the timeline (published code sets it on masks
|
|
51
|
+
* and absent instances). createjs reads it only when its timeline places
|
|
52
|
+
* children: it does not affect drawing (an _off object on a display list is drawn)
|
|
53
|
+
*/
|
|
54
|
+
/** createjs leaves it unset (undefined) until the timeline or published code sets it */
|
|
55
|
+
private _offValue;
|
|
56
|
+
private _name;
|
|
57
|
+
private _mask;
|
|
58
|
+
private _filters;
|
|
59
|
+
private _compositeOperation;
|
|
60
|
+
/** The composite operation in effect on the parent (createjs draws children under it) */
|
|
61
|
+
private _inheritedComposite;
|
|
62
|
+
/** The cache createjs would draw through (filters show in Pixi without one) */
|
|
63
|
+
bitmapCache: ICacheState | null;
|
|
64
|
+
/** Set only when the symbol has them (createjs leaves them undefined otherwise) */
|
|
65
|
+
nominalBounds?: Rectangle | null;
|
|
66
|
+
frameBounds?: Rectangle[] | null;
|
|
67
|
+
_bounds: Rectangle | null;
|
|
68
|
+
/** The parent whose Pixi node holds this object's mask node */
|
|
69
|
+
_maskHost: Container | null;
|
|
70
|
+
/** The objects this object masks (while they are on a display list) */
|
|
71
|
+
_maskTargets: DisplayObject[];
|
|
72
|
+
constructor(pixi: IOwnedNode);
|
|
73
|
+
get _eventParent(): EventDispatcher | null;
|
|
74
|
+
private get _transform();
|
|
75
|
+
get x(): number;
|
|
76
|
+
set x(value: number);
|
|
77
|
+
get y(): number;
|
|
78
|
+
set y(value: number);
|
|
79
|
+
get scaleX(): number;
|
|
80
|
+
set scaleX(value: number);
|
|
81
|
+
get scaleY(): number;
|
|
82
|
+
set scaleY(value: number);
|
|
83
|
+
get regX(): number;
|
|
84
|
+
set regX(value: number);
|
|
85
|
+
get regY(): number;
|
|
86
|
+
set regY(value: number);
|
|
87
|
+
get rotation(): number;
|
|
88
|
+
set rotation(value: number);
|
|
89
|
+
get skewX(): number;
|
|
90
|
+
set skewX(value: number);
|
|
91
|
+
get skewY(): number;
|
|
92
|
+
set skewY(value: number);
|
|
93
|
+
get alpha(): number;
|
|
94
|
+
set alpha(value: number);
|
|
95
|
+
get visible(): boolean;
|
|
96
|
+
set visible(value: boolean);
|
|
97
|
+
get name(): string | null;
|
|
98
|
+
set name(value: string | null);
|
|
99
|
+
get _off(): boolean | undefined;
|
|
100
|
+
set _off(value: boolean | undefined);
|
|
101
|
+
get compositeOperation(): string | null;
|
|
102
|
+
set compositeOperation(value: string | null);
|
|
103
|
+
/**
|
|
104
|
+
* The composite operation createjs draws this object with: its own, or else
|
|
105
|
+
* the nearest ancestor's (createjs sets it on the context and draws the
|
|
106
|
+
* children under it, each child saving and restoring the context)
|
|
107
|
+
*/
|
|
108
|
+
_effectiveComposite(): string | null;
|
|
109
|
+
/** Told by the parent when the composite operation in effect on it changes */
|
|
110
|
+
_setInheritedComposite(value: string | null): void;
|
|
111
|
+
/**
|
|
112
|
+
* Pixi blends per drawing node (a container has no blend mode of its own),
|
|
113
|
+
* so the composite operation in effect is set on this object's drawing node
|
|
114
|
+
* and handed down to the children
|
|
115
|
+
*/
|
|
116
|
+
_applyComposite(): void;
|
|
117
|
+
get mask(): DisplayObject | null;
|
|
118
|
+
set mask(value: DisplayObject | null);
|
|
119
|
+
get filters(): IFilterLike[] | null;
|
|
120
|
+
set filters(value: IFilterLike[] | null);
|
|
121
|
+
/** Blend mode for the Pixi node(s) that draw this object */
|
|
122
|
+
_setBlendMode(mode: PIXI.BLEND_MODES): void;
|
|
123
|
+
/**
|
|
124
|
+
* The node is drawn unless Pixi uses it as a mask, or it is in a parent's
|
|
125
|
+
* node only to carry the mask shape of a sibling (a createjs mask is not on
|
|
126
|
+
* any display list and is not drawn itself)
|
|
127
|
+
*/
|
|
128
|
+
_updateRenderable(): void;
|
|
129
|
+
/** Whether this object clips when used as a mask (createjs clips only with a non-empty Graphics) */
|
|
130
|
+
_clipsAsMask(): boolean;
|
|
131
|
+
/** The node Pixi masks with when this object is a mask */
|
|
132
|
+
_pixiMaskNode(): PIXI.Container | null;
|
|
133
|
+
/** Called when this object stops being some object's Pixi mask */
|
|
134
|
+
_releaseMaskNode(): void;
|
|
135
|
+
/** Sets the Pixi mask from the createjs one: Pixi masks only while the createjs mask would clip */
|
|
136
|
+
_updatePixiMask(): void;
|
|
137
|
+
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): this;
|
|
138
|
+
set(props: {
|
|
139
|
+
[key: string]: string | number | boolean | null;
|
|
140
|
+
}): this;
|
|
141
|
+
isVisible(): boolean;
|
|
142
|
+
cache(x: number, y: number, width: number, height: number, scale?: number): void;
|
|
143
|
+
updateCache(): void;
|
|
144
|
+
uncache(): void;
|
|
145
|
+
setBounds(x: number | null, y?: number, width?: number, height?: number): void;
|
|
146
|
+
getChildDepth(): number;
|
|
147
|
+
/** createjs tick phase: dispatches the tick event to listeners */
|
|
148
|
+
_tick(event: Event): void;
|
|
149
|
+
toString(): string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* createjs-compatible Container. The Pixi node's children are the display
|
|
153
|
+
* list's nodes in the same order, followed by the nodes of the masks the
|
|
154
|
+
* children use (a createjs mask is drawn in its target's parent space, so
|
|
155
|
+
* its node lives in the parent's node).
|
|
156
|
+
*/
|
|
157
|
+
export declare class Container extends DisplayObject {
|
|
158
|
+
children: DisplayObject[];
|
|
159
|
+
tickChildren: boolean;
|
|
160
|
+
mouseChildren: boolean;
|
|
161
|
+
/** Mask nodes held in this container's node, by the child that uses them */
|
|
162
|
+
private _maskNodes;
|
|
163
|
+
constructor(pixi?: IOwnedNode);
|
|
164
|
+
get numChildren(): number;
|
|
165
|
+
addChild(...children: DisplayObject[]): DisplayObject | null;
|
|
166
|
+
addChildAt(child: DisplayObject, index: number): DisplayObject;
|
|
167
|
+
removeChild(...children: DisplayObject[]): boolean;
|
|
168
|
+
removeChildAt(...indexes: number[]): boolean;
|
|
169
|
+
removeAllChildren(): void;
|
|
170
|
+
getChildAt(index: number): DisplayObject | undefined;
|
|
171
|
+
getChildByName(name: string): DisplayObject | null;
|
|
172
|
+
getChildIndex(child: DisplayObject): number;
|
|
173
|
+
setChildIndex(child: DisplayObject, index: number): void;
|
|
174
|
+
swapChildrenAt(index1: number, index2: number): void;
|
|
175
|
+
swapChildren(child1: DisplayObject, child2: DisplayObject): void;
|
|
176
|
+
sortChildren(compare: (a: DisplayObject, b: DisplayObject) => number): void;
|
|
177
|
+
contains(child: DisplayObject | null): boolean;
|
|
178
|
+
_removeChildAt(index: number, silent?: boolean): boolean;
|
|
179
|
+
/** Puts the node of a child's mask into this container's node, and sets it as the Pixi mask */
|
|
180
|
+
_attachMask(child: DisplayObject): void;
|
|
181
|
+
_detachMask(child: DisplayObject): void;
|
|
182
|
+
_applyComposite(): void;
|
|
183
|
+
/** createjs tick phase: children in reverse order (live array), then this object's listeners */
|
|
184
|
+
_tick(event: Event): void;
|
|
185
|
+
toString(): string;
|
|
186
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eases of CreateJS (createjs.Ease), computed as CreateJS computes them,
|
|
3
|
+
* by name. Runtime content names the ease of an interpolated stretch of a
|
|
4
|
+
* tween; the player computes the stretch's values with it once, when a symbol's
|
|
5
|
+
* class is made. `get:<amount>` is Ease.get(amount) (Animate's classic ease).
|
|
6
|
+
*/
|
|
7
|
+
export type TEase = (t: number) => number;
|
|
8
|
+
/** The ease runtime content names (null for a name the player does not know) */
|
|
9
|
+
export declare function easeOf(id: string): TEase | null;
|
|
10
|
+
/** The eases the generator tries for a stretch of a tween, by name: the named ones, then Ease.get(-1 .. 1) in hundredths */
|
|
11
|
+
export declare function easeIds(): string[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createjs-compatible events: Event and EventDispatcher, with the capture,
|
|
3
|
+
* target and bubble phases createjs dispatches through the parent chain.
|
|
4
|
+
*/
|
|
5
|
+
export interface IEventHandlerObject {
|
|
6
|
+
handleEvent(event: Event): void;
|
|
7
|
+
}
|
|
8
|
+
/** Data passed to a listener added with on() */
|
|
9
|
+
export type TEventData = string | number | boolean | object | null | undefined;
|
|
10
|
+
export type TEventListener = ((event: Event, data?: TEventData) => void) | IEventHandlerObject;
|
|
11
|
+
interface IListenerMap {
|
|
12
|
+
[type: string]: TEventListener[];
|
|
13
|
+
}
|
|
14
|
+
export declare class Event {
|
|
15
|
+
type: string;
|
|
16
|
+
target: EventDispatcher | null;
|
|
17
|
+
currentTarget: EventDispatcher | null;
|
|
18
|
+
eventPhase: number;
|
|
19
|
+
bubbles: boolean;
|
|
20
|
+
cancelable: boolean;
|
|
21
|
+
timeStamp: number;
|
|
22
|
+
defaultPrevented: boolean;
|
|
23
|
+
propagationStopped: boolean;
|
|
24
|
+
immediatePropagationStopped: boolean;
|
|
25
|
+
removed: boolean;
|
|
26
|
+
/** Time since the last tick, for tick events (createjs Ticker events carry it) */
|
|
27
|
+
delta: number | undefined;
|
|
28
|
+
paused: boolean | undefined;
|
|
29
|
+
constructor(type: string, bubbles?: boolean, cancelable?: boolean);
|
|
30
|
+
preventDefault(): void;
|
|
31
|
+
stopPropagation(): void;
|
|
32
|
+
stopImmediatePropagation(): void;
|
|
33
|
+
remove(): void;
|
|
34
|
+
clone(): Event;
|
|
35
|
+
set(props: {
|
|
36
|
+
[key: string]: string | number | boolean | null;
|
|
37
|
+
}): Event;
|
|
38
|
+
toString(): string;
|
|
39
|
+
}
|
|
40
|
+
export declare class EventDispatcher {
|
|
41
|
+
_listeners: IListenerMap | null;
|
|
42
|
+
_captureListeners: IListenerMap | null;
|
|
43
|
+
/** The parent the bubble and capture phases walk through (a display object's parent) */
|
|
44
|
+
get _eventParent(): EventDispatcher | null;
|
|
45
|
+
addEventListener(type: string, listener: TEventListener, useCapture?: boolean): TEventListener;
|
|
46
|
+
on(type: string, listener: TEventListener, scope?: object, once?: boolean, data?: TEventData, useCapture?: boolean): TEventListener;
|
|
47
|
+
removeEventListener(type: string, listener: TEventListener, useCapture?: boolean): void;
|
|
48
|
+
off(type: string, listener: TEventListener, useCapture?: boolean): void;
|
|
49
|
+
removeAllEventListeners(type?: string): void;
|
|
50
|
+
dispatchEvent(eventOrType: Event | string, bubbles?: boolean, cancelable?: boolean): boolean;
|
|
51
|
+
hasEventListener(type: string): boolean;
|
|
52
|
+
willTrigger(type: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Phase 1 is capture, 2 the target, 3 bubbling. At the target, the capture
|
|
55
|
+
* listeners run first and then the others (createjs runs the target phase
|
|
56
|
+
* twice, the second time as phase 2.1, which reads the non-capture listeners).
|
|
57
|
+
*/
|
|
58
|
+
_dispatchEvent(event: Event, phase: number): void;
|
|
59
|
+
}
|
|
60
|
+
export {};
|