@silentstatestudio/perseon 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.
Files changed (47) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +848 -2
  4. package/dist/authoring/index.cjs +213 -0
  5. package/dist/authoring/index.d.cts +866 -0
  6. package/dist/authoring/index.d.ts +866 -0
  7. package/dist/authoring/index.js +214 -0
  8. package/dist/authoring/index.js.map +1 -0
  9. package/dist/chunk-GDXCMDJ6.js +5462 -0
  10. package/dist/chunk-GDXCMDJ6.js.map +1 -0
  11. package/dist/chunk-ON4JV4BI.js +8432 -0
  12. package/dist/chunk-ON4JV4BI.js.map +1 -0
  13. package/dist/chunk-PT7F7TTB.cjs +8431 -0
  14. package/dist/chunk-Q2HLLGJ7.cjs +5461 -0
  15. package/dist/chunk-SVI6WUOB.js +1 -0
  16. package/dist/chunk-SVI6WUOB.js.map +1 -0
  17. package/dist/chunk-ZIMCQTYK.cjs +1 -0
  18. package/dist/colors-CUEeQ78V.d.cts +2247 -0
  19. package/dist/colors-pshUJaKB.d.ts +2247 -0
  20. package/dist/core/index.cjs +29 -0
  21. package/dist/core/index.d.cts +39 -0
  22. package/dist/core/index.d.ts +39 -0
  23. package/dist/core/index.js +30 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/index.cjs +29 -0
  26. package/dist/index.d.cts +3 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.js +30 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/pixi-v7/index.cjs +513 -0
  31. package/dist/pixi-v7/index.d.cts +372 -0
  32. package/dist/pixi-v7/index.d.ts +372 -0
  33. package/dist/pixi-v7/index.js +514 -0
  34. package/dist/pixi-v7/index.js.map +1 -0
  35. package/dist/pixi-v8/index.cjs +608 -0
  36. package/dist/pixi-v8/index.d.cts +380 -0
  37. package/dist/pixi-v8/index.d.ts +380 -0
  38. package/dist/pixi-v8/index.js +609 -0
  39. package/dist/pixi-v8/index.js.map +1 -0
  40. package/dist/rendering-DeUo1BsK.d.cts +237 -0
  41. package/dist/rendering-DeUo1BsK.d.ts +237 -0
  42. package/dist/testing/index.cjs +159 -0
  43. package/dist/testing/index.d.cts +85 -0
  44. package/dist/testing/index.d.ts +85 -0
  45. package/dist/testing/index.js +160 -0
  46. package/dist/testing/index.js.map +1 -0
  47. package/package.json +148 -6
@@ -0,0 +1,237 @@
1
+ /**
2
+ * What a renderer does with one blend mode.
3
+ *
4
+ * - `fixed-function` — a GPU blend state. Free: it costs nothing beyond the
5
+ * draw the particles were already going to make.
6
+ * - `filter-pass` — correct, but the group is rendered into an off-screen
7
+ * target and composited with a shader, which breaks the batch and costs one
8
+ * pass per Particle Layer that uses it.
9
+ * - `unsupported` — the backend cannot honor it and will draw the layer with
10
+ * `normal` instead. Not an error and not a crash: a silent difference between
11
+ * what the config says and what the screen shows, which is exactly the thing
12
+ * a host has to be able to say out loud.
13
+ */
14
+ type BlendModeSupport = 'fixed-function' | 'filter-pass' | 'unsupported';
15
+ /**
16
+ * What a concrete renderer can actually do — asked of the renderer, never
17
+ * declared in a table beside the feature.
18
+ *
19
+ * Blend modes are the case that forced this. `BLEND_MODE_CATALOG` lists the
20
+ * modes an animation may name, and it is renderer-agnostic by construction, so
21
+ * it cannot know what any of them costs: the same `overlay` is a shader pass on
22
+ * the PixiJS v8 adapter and plain `normal` on the v7 one, whose fixed-function
23
+ * table has no entry for it. A static "advanced, best-effort" tag beside the id
24
+ * could only ever be right for one of them.
25
+ *
26
+ * Optional on `IRenderer` on purpose. A renderer that draws nothing — a test
27
+ * double, a headless benchmark — has no capabilities to report, and inventing
28
+ * an answer for it would put a fiction where a host expects a fact. A host that
29
+ * finds none asks nothing and assumes nothing.
30
+ *
31
+ * Deliberately not "which backend is this": the graphics backend is a fact
32
+ * about the host's renderer, which the host already holds (`resolveRendererBackend`
33
+ * for the Pixi adapters), and it turns out not to decide
34
+ * any of the answers here. What decides them is the adapter — see each
35
+ * implementation. Reporting it a second time from a place that would sometimes
36
+ * have to guess would make this interface less trustworthy, not more complete.
37
+ */
38
+ interface IRendererCapabilities {
39
+ /** What this renderer does with `mode` — see `BlendModeSupport`. */
40
+ blendModeSupport(mode: ParticleBlendMode): BlendModeSupport;
41
+ }
42
+
43
+ /**
44
+ * Renderer-agnostic contracts: these interfaces name no rendering library, and
45
+ * each adapter implements them.
46
+ */
47
+
48
+ /** Opaque reference to a renderer-resolved texture resource. */
49
+ interface ITextureRef {
50
+ readonly width: number;
51
+ readonly height: number;
52
+ }
53
+ /** Geometric containment test, used for spawn areas and regions. */
54
+ interface IShape {
55
+ contains(x: number, y: number): boolean;
56
+ }
57
+ /** Frame ticker abstraction (Pixi.Ticker, requestAnimationFrame, etc.). */
58
+ interface ITicker {
59
+ /** Calls `fn` on every frame, with the time since the previous frame in milliseconds. */
60
+ add(fn: (deltaMS: number) => void): void;
61
+ /** Stops calling `fn`; the same function that was passed to `add`. */
62
+ remove(fn: (deltaMS: number) => void): void;
63
+ }
64
+ /**
65
+ * Visual state of a particle read by the renderer each frame.
66
+ * The engine writes these fields; the renderer mirrors them to its backend.
67
+ */
68
+ interface IParticleVisualState {
69
+ x: number;
70
+ y: number;
71
+ scaleX: number;
72
+ scaleY: number;
73
+ rotation: number;
74
+ alpha: number;
75
+ tint: number;
76
+ anchorX: number;
77
+ anchorY: number;
78
+ texture: ITextureRef;
79
+ /**
80
+ * Opaque backend slot. A render adapter may stash the object mirroring this
81
+ * particle (e.g. its `Pixi.Particle`) here so the per-frame sync reads a
82
+ * direct field instead of a per-particle map lookup in the hot loop. Typed
83
+ * `unknown` to keep this file renderer-agnostic. A particle belongs to a
84
+ * single render group at a time, so one slot suffices; the adapter sets it
85
+ * on add and clears it on remove/reset.
86
+ */
87
+ renderHandle?: unknown;
88
+ }
89
+ interface IParticleGroupOptions {
90
+ dynamicProperties: {
91
+ /** Position/scale/anchor change at runtime. */
92
+ vertex: boolean;
93
+ rotation: boolean;
94
+ /** tint/alpha change at runtime. */
95
+ color: boolean;
96
+ /** Sprite-sheet (texture frame changes at runtime). */
97
+ uvs: boolean;
98
+ };
99
+ /**
100
+ * Compositing mode for the group's container. Defaults to `'normal'` when
101
+ * omitted. Blend is a container-level property (the GPU sets it per draw
102
+ * call, not per instance), so the engine creates one group per Particle
103
+ * Layer, each with a fixed blend mode.
104
+ */
105
+ blendMode?: ParticleBlendMode;
106
+ }
107
+ /**
108
+ * A render group is a sub-buffer/sub-container owned by a single Particle Layer
109
+ * of an emitter. The engine asks the renderer for one per layer in its
110
+ * constructor — the creation order sets the z-order between layers — and uses it
111
+ * to insert, remove, and flush per-frame state. Each group tracks its own live
112
+ * particles, so `syncFrame` takes no argument.
113
+ */
114
+ interface IParticleGroup {
115
+ /** Number of live particles currently in this group. */
116
+ readonly size: number;
117
+ /**
118
+ * A group is created visible. Hidden, the renderer draws none of its
119
+ * particles; it still holds them and `syncFrame` still runs.
120
+ */
121
+ visible: boolean;
122
+ /**
123
+ * Starts drawing `particle` at position `index` of the group, which is its draw
124
+ * order among the group's particles: 0 is drawn first, beneath the rest.
125
+ */
126
+ addParticle(particle: IParticleVisualState, index: number): void;
127
+ /** Stops drawing `particle`. A particle the group does not hold is ignored. */
128
+ removeParticle(particle: IParticleVisualState): void;
129
+ /** Stops drawing every particle of the group, which stays usable. */
130
+ removeAll(): void;
131
+ /** Copies the visual state of every particle of the group to the backend; the engine calls it once per frame. */
132
+ syncFrame(): void;
133
+ /** Releases the group's backend resources. It is not used again afterwards. */
134
+ destroy(): void;
135
+ }
136
+ /**
137
+ * A node of the scene graph. Two roles share this shape, one nested in the
138
+ * other: a playback's **root** node, and one **child** node per emitter under
139
+ * it. Visibility and transform are per node, so a whole animation can be moved
140
+ * or hidden, and so can one of its emitters.
141
+ *
142
+ * The order in which a node's groups are created is the z-order between layers;
143
+ * `setGroupIndex` re-sequences them in place, without recreating any container.
144
+ */
145
+ interface IRenderNode {
146
+ visible: boolean;
147
+ x: number;
148
+ y: number;
149
+ /** One group per Particle Layer of the emitter that owns this node. */
150
+ createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
151
+ /** Move an existing group to `index` among its siblings (z-order). */
152
+ setGroupIndex(group: IParticleGroup, index: number): void;
153
+ /**
154
+ * Destroy one group and let go of it. The node is what created the group and
155
+ * what holds the list of them, so it has to be what removes one — a group
156
+ * destroyed behind the node's back leaves a dead entry there, which is a
157
+ * leak per Particle Layer a host removes at runtime.
158
+ */
159
+ destroyParticleGroup(group: IParticleGroup): void;
160
+ /** Detaches and destroys the node and every group created from it. */
161
+ destroy(): void;
162
+ }
163
+ /**
164
+ * The root node of one playback — the only node that attaches to something the
165
+ * host owns, and therefore the only one whose parent has a host-specific type.
166
+ *
167
+ * It is created detached. A host mounts it where the animation should appear,
168
+ * and can move it later: re-mounting is what lets a pooled playback be replayed
169
+ * under a different container without being rebuilt.
170
+ */
171
+ interface IRenderRootNode<TParent = unknown> extends IRenderNode {
172
+ /**
173
+ * One child per emitter. Declared here and not on `IRenderNode` because only
174
+ * a root has children: nesting a node under an emitter's would silently
175
+ * create an emitter inside an emitter.
176
+ */
177
+ createChildNode(): IRenderNode;
178
+ /** Attach under `parent`, moving the node if it was mounted elsewhere. */
179
+ mount(parent: TParent): void;
180
+ /** Detach without destroying — how a pool parks a playback between uses. */
181
+ unmount(): void;
182
+ /**
183
+ * Whether the host destroyed this root (in Pixi, its container's `destroyed`).
184
+ * The instance reads it at the start of every tick, when it is claimed and
185
+ * in `prepare()`: a destroyed root can no longer draw, so the instance ends.
186
+ */
187
+ readonly hostDestroyed: boolean;
188
+ }
189
+ /**
190
+ * Renderer host: a factory of scene nodes and a resolver of textures.
191
+ *
192
+ * It is deliberately **not** the scene root. One renderer serves many playbacks,
193
+ * and those go into different containers of the host's own graph — a thruster
194
+ * under the ship, an explosion under the world — so a single root owned here
195
+ * could not serve them. Each playback asks for its own root and mounts it.
196
+ *
197
+ * `TParent` is the host's container type (e.g. `PIXI.Container`). It defaults to
198
+ * `unknown` so untyped references to `IRenderer` stay valid without an argument.
199
+ */
200
+ interface IRenderer<TParent = unknown> {
201
+ /** Optional frame ticker provided by the renderer (e.g. Pixi.Application.ticker). */
202
+ readonly ticker?: ITicker;
203
+ /**
204
+ * What this renderer can actually do, when it is a renderer that draws —
205
+ * see `IRendererCapabilities`. Absent on a renderer that has no screen to
206
+ * answer for, which is why a host checks before it asks.
207
+ */
208
+ readonly capabilities?: IRendererCapabilities;
209
+ /** Creates one detached root node per playback, for the host to mount. */
210
+ createRootNode(): IRenderRootNode<TParent>;
211
+ resolveTexture(source: unknown): ITextureRef;
212
+ /**
213
+ * Forget every memoized texture lookup, so the next `resolveTexture` asks the
214
+ * host's assets again.
215
+ *
216
+ * Required because a renderer outlives what it resolved: one serves the whole
217
+ * app, and a host that republishes an atlas destroys the textures behind ids
218
+ * that are still memoized here. Without this the ids keep resolving to dead
219
+ * resources and the animation renders nothing — correctly, and in silence.
220
+ * Live particles keep the reference they were spawned with; call it before
221
+ * the animations that use those ids are rebuilt.
222
+ */
223
+ clearTextureCache(): void;
224
+ /** Releases the renderer's own resources. Does not destroy live nodes. */
225
+ destroy(): void;
226
+ }
227
+
228
+ /**
229
+ * Fixed compositing/blend mode for a Particle Layer. A static rendering setting,
230
+ * not a dynamic parameter — no randomness, curves, or animation. Adapters map
231
+ * these onto their backend's blend modes, and what each one costs there — or
232
+ * whether it degrades to `normal` — is the renderer's own answer, through
233
+ * `IRendererCapabilities.blendModeSupport`.
234
+ */
235
+ type ParticleBlendMode = 'normal' | 'add' | 'screen' | 'multiply' | 'subtract' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion';
236
+
237
+ export type { BlendModeSupport as B, IParticleGroup as I, ParticleBlendMode as P, IParticleGroupOptions as a, IParticleVisualState as b, IRenderRootNode as c, IRenderNode as d, ITicker as e, IRenderer as f, ITextureRef as g, IRendererCapabilities as h, IShape as i };
@@ -0,0 +1,237 @@
1
+ /**
2
+ * What a renderer does with one blend mode.
3
+ *
4
+ * - `fixed-function` — a GPU blend state. Free: it costs nothing beyond the
5
+ * draw the particles were already going to make.
6
+ * - `filter-pass` — correct, but the group is rendered into an off-screen
7
+ * target and composited with a shader, which breaks the batch and costs one
8
+ * pass per Particle Layer that uses it.
9
+ * - `unsupported` — the backend cannot honor it and will draw the layer with
10
+ * `normal` instead. Not an error and not a crash: a silent difference between
11
+ * what the config says and what the screen shows, which is exactly the thing
12
+ * a host has to be able to say out loud.
13
+ */
14
+ type BlendModeSupport = 'fixed-function' | 'filter-pass' | 'unsupported';
15
+ /**
16
+ * What a concrete renderer can actually do — asked of the renderer, never
17
+ * declared in a table beside the feature.
18
+ *
19
+ * Blend modes are the case that forced this. `BLEND_MODE_CATALOG` lists the
20
+ * modes an animation may name, and it is renderer-agnostic by construction, so
21
+ * it cannot know what any of them costs: the same `overlay` is a shader pass on
22
+ * the PixiJS v8 adapter and plain `normal` on the v7 one, whose fixed-function
23
+ * table has no entry for it. A static "advanced, best-effort" tag beside the id
24
+ * could only ever be right for one of them.
25
+ *
26
+ * Optional on `IRenderer` on purpose. A renderer that draws nothing — a test
27
+ * double, a headless benchmark — has no capabilities to report, and inventing
28
+ * an answer for it would put a fiction where a host expects a fact. A host that
29
+ * finds none asks nothing and assumes nothing.
30
+ *
31
+ * Deliberately not "which backend is this": the graphics backend is a fact
32
+ * about the host's renderer, which the host already holds (`resolveRendererBackend`
33
+ * for the Pixi adapters), and it turns out not to decide
34
+ * any of the answers here. What decides them is the adapter — see each
35
+ * implementation. Reporting it a second time from a place that would sometimes
36
+ * have to guess would make this interface less trustworthy, not more complete.
37
+ */
38
+ interface IRendererCapabilities {
39
+ /** What this renderer does with `mode` — see `BlendModeSupport`. */
40
+ blendModeSupport(mode: ParticleBlendMode): BlendModeSupport;
41
+ }
42
+
43
+ /**
44
+ * Renderer-agnostic contracts: these interfaces name no rendering library, and
45
+ * each adapter implements them.
46
+ */
47
+
48
+ /** Opaque reference to a renderer-resolved texture resource. */
49
+ interface ITextureRef {
50
+ readonly width: number;
51
+ readonly height: number;
52
+ }
53
+ /** Geometric containment test, used for spawn areas and regions. */
54
+ interface IShape {
55
+ contains(x: number, y: number): boolean;
56
+ }
57
+ /** Frame ticker abstraction (Pixi.Ticker, requestAnimationFrame, etc.). */
58
+ interface ITicker {
59
+ /** Calls `fn` on every frame, with the time since the previous frame in milliseconds. */
60
+ add(fn: (deltaMS: number) => void): void;
61
+ /** Stops calling `fn`; the same function that was passed to `add`. */
62
+ remove(fn: (deltaMS: number) => void): void;
63
+ }
64
+ /**
65
+ * Visual state of a particle read by the renderer each frame.
66
+ * The engine writes these fields; the renderer mirrors them to its backend.
67
+ */
68
+ interface IParticleVisualState {
69
+ x: number;
70
+ y: number;
71
+ scaleX: number;
72
+ scaleY: number;
73
+ rotation: number;
74
+ alpha: number;
75
+ tint: number;
76
+ anchorX: number;
77
+ anchorY: number;
78
+ texture: ITextureRef;
79
+ /**
80
+ * Opaque backend slot. A render adapter may stash the object mirroring this
81
+ * particle (e.g. its `Pixi.Particle`) here so the per-frame sync reads a
82
+ * direct field instead of a per-particle map lookup in the hot loop. Typed
83
+ * `unknown` to keep this file renderer-agnostic. A particle belongs to a
84
+ * single render group at a time, so one slot suffices; the adapter sets it
85
+ * on add and clears it on remove/reset.
86
+ */
87
+ renderHandle?: unknown;
88
+ }
89
+ interface IParticleGroupOptions {
90
+ dynamicProperties: {
91
+ /** Position/scale/anchor change at runtime. */
92
+ vertex: boolean;
93
+ rotation: boolean;
94
+ /** tint/alpha change at runtime. */
95
+ color: boolean;
96
+ /** Sprite-sheet (texture frame changes at runtime). */
97
+ uvs: boolean;
98
+ };
99
+ /**
100
+ * Compositing mode for the group's container. Defaults to `'normal'` when
101
+ * omitted. Blend is a container-level property (the GPU sets it per draw
102
+ * call, not per instance), so the engine creates one group per Particle
103
+ * Layer, each with a fixed blend mode.
104
+ */
105
+ blendMode?: ParticleBlendMode;
106
+ }
107
+ /**
108
+ * A render group is a sub-buffer/sub-container owned by a single Particle Layer
109
+ * of an emitter. The engine asks the renderer for one per layer in its
110
+ * constructor — the creation order sets the z-order between layers — and uses it
111
+ * to insert, remove, and flush per-frame state. Each group tracks its own live
112
+ * particles, so `syncFrame` takes no argument.
113
+ */
114
+ interface IParticleGroup {
115
+ /** Number of live particles currently in this group. */
116
+ readonly size: number;
117
+ /**
118
+ * A group is created visible. Hidden, the renderer draws none of its
119
+ * particles; it still holds them and `syncFrame` still runs.
120
+ */
121
+ visible: boolean;
122
+ /**
123
+ * Starts drawing `particle` at position `index` of the group, which is its draw
124
+ * order among the group's particles: 0 is drawn first, beneath the rest.
125
+ */
126
+ addParticle(particle: IParticleVisualState, index: number): void;
127
+ /** Stops drawing `particle`. A particle the group does not hold is ignored. */
128
+ removeParticle(particle: IParticleVisualState): void;
129
+ /** Stops drawing every particle of the group, which stays usable. */
130
+ removeAll(): void;
131
+ /** Copies the visual state of every particle of the group to the backend; the engine calls it once per frame. */
132
+ syncFrame(): void;
133
+ /** Releases the group's backend resources. It is not used again afterwards. */
134
+ destroy(): void;
135
+ }
136
+ /**
137
+ * A node of the scene graph. Two roles share this shape, one nested in the
138
+ * other: a playback's **root** node, and one **child** node per emitter under
139
+ * it. Visibility and transform are per node, so a whole animation can be moved
140
+ * or hidden, and so can one of its emitters.
141
+ *
142
+ * The order in which a node's groups are created is the z-order between layers;
143
+ * `setGroupIndex` re-sequences them in place, without recreating any container.
144
+ */
145
+ interface IRenderNode {
146
+ visible: boolean;
147
+ x: number;
148
+ y: number;
149
+ /** One group per Particle Layer of the emitter that owns this node. */
150
+ createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
151
+ /** Move an existing group to `index` among its siblings (z-order). */
152
+ setGroupIndex(group: IParticleGroup, index: number): void;
153
+ /**
154
+ * Destroy one group and let go of it. The node is what created the group and
155
+ * what holds the list of them, so it has to be what removes one — a group
156
+ * destroyed behind the node's back leaves a dead entry there, which is a
157
+ * leak per Particle Layer a host removes at runtime.
158
+ */
159
+ destroyParticleGroup(group: IParticleGroup): void;
160
+ /** Detaches and destroys the node and every group created from it. */
161
+ destroy(): void;
162
+ }
163
+ /**
164
+ * The root node of one playback — the only node that attaches to something the
165
+ * host owns, and therefore the only one whose parent has a host-specific type.
166
+ *
167
+ * It is created detached. A host mounts it where the animation should appear,
168
+ * and can move it later: re-mounting is what lets a pooled playback be replayed
169
+ * under a different container without being rebuilt.
170
+ */
171
+ interface IRenderRootNode<TParent = unknown> extends IRenderNode {
172
+ /**
173
+ * One child per emitter. Declared here and not on `IRenderNode` because only
174
+ * a root has children: nesting a node under an emitter's would silently
175
+ * create an emitter inside an emitter.
176
+ */
177
+ createChildNode(): IRenderNode;
178
+ /** Attach under `parent`, moving the node if it was mounted elsewhere. */
179
+ mount(parent: TParent): void;
180
+ /** Detach without destroying — how a pool parks a playback between uses. */
181
+ unmount(): void;
182
+ /**
183
+ * Whether the host destroyed this root (in Pixi, its container's `destroyed`).
184
+ * The instance reads it at the start of every tick, when it is claimed and
185
+ * in `prepare()`: a destroyed root can no longer draw, so the instance ends.
186
+ */
187
+ readonly hostDestroyed: boolean;
188
+ }
189
+ /**
190
+ * Renderer host: a factory of scene nodes and a resolver of textures.
191
+ *
192
+ * It is deliberately **not** the scene root. One renderer serves many playbacks,
193
+ * and those go into different containers of the host's own graph — a thruster
194
+ * under the ship, an explosion under the world — so a single root owned here
195
+ * could not serve them. Each playback asks for its own root and mounts it.
196
+ *
197
+ * `TParent` is the host's container type (e.g. `PIXI.Container`). It defaults to
198
+ * `unknown` so untyped references to `IRenderer` stay valid without an argument.
199
+ */
200
+ interface IRenderer<TParent = unknown> {
201
+ /** Optional frame ticker provided by the renderer (e.g. Pixi.Application.ticker). */
202
+ readonly ticker?: ITicker;
203
+ /**
204
+ * What this renderer can actually do, when it is a renderer that draws —
205
+ * see `IRendererCapabilities`. Absent on a renderer that has no screen to
206
+ * answer for, which is why a host checks before it asks.
207
+ */
208
+ readonly capabilities?: IRendererCapabilities;
209
+ /** Creates one detached root node per playback, for the host to mount. */
210
+ createRootNode(): IRenderRootNode<TParent>;
211
+ resolveTexture(source: unknown): ITextureRef;
212
+ /**
213
+ * Forget every memoized texture lookup, so the next `resolveTexture` asks the
214
+ * host's assets again.
215
+ *
216
+ * Required because a renderer outlives what it resolved: one serves the whole
217
+ * app, and a host that republishes an atlas destroys the textures behind ids
218
+ * that are still memoized here. Without this the ids keep resolving to dead
219
+ * resources and the animation renders nothing — correctly, and in silence.
220
+ * Live particles keep the reference they were spawned with; call it before
221
+ * the animations that use those ids are rebuilt.
222
+ */
223
+ clearTextureCache(): void;
224
+ /** Releases the renderer's own resources. Does not destroy live nodes. */
225
+ destroy(): void;
226
+ }
227
+
228
+ /**
229
+ * Fixed compositing/blend mode for a Particle Layer. A static rendering setting,
230
+ * not a dynamic parameter — no randomness, curves, or animation. Adapters map
231
+ * these onto their backend's blend modes, and what each one costs there — or
232
+ * whether it degrades to `normal` — is the renderer's own answer, through
233
+ * `IRendererCapabilities.blendModeSupport`.
234
+ */
235
+ type ParticleBlendMode = 'normal' | 'add' | 'screen' | 'multiply' | 'subtract' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion';
236
+
237
+ export type { BlendModeSupport as B, IParticleGroup as I, ParticleBlendMode as P, IParticleGroupOptions as a, IParticleVisualState as b, IRenderRootNode as c, IRenderNode as d, ITicker as e, IRenderer as f, ITextureRef as g, IRendererCapabilities as h, IShape as i };
@@ -0,0 +1,159 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2; var _class3; var _class4;// src/core/testing/FakeParticleGroup.ts
2
+ var FakeParticleGroup = (_class = class {
3
+
4
+ __init() {this.particles = []}
5
+ __init2() {this.addCalls = 0}
6
+ __init3() {this.removeCalls = 0}
7
+ __init4() {this.removeAllCalls = 0}
8
+ __init5() {this.syncFrameCalls = 0}
9
+ __init6() {this.destroyed = false}
10
+ __init7() {this.visible = true}
11
+ constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);
12
+ this.options = options;
13
+ }
14
+ get size() {
15
+ return this.particles.length;
16
+ }
17
+ addParticle(particle, index) {
18
+ this.addCalls += 1;
19
+ this.particles.splice(index, 0, particle);
20
+ }
21
+ removeParticle(particle) {
22
+ this.removeCalls += 1;
23
+ const index = this.particles.indexOf(particle);
24
+ if (index >= 0) this.particles.splice(index, 1);
25
+ }
26
+ removeAll() {
27
+ this.removeAllCalls += 1;
28
+ this.particles.length = 0;
29
+ }
30
+ syncFrame() {
31
+ this.syncFrameCalls += 1;
32
+ }
33
+ destroy() {
34
+ this.destroyed = true;
35
+ this.particles.length = 0;
36
+ }
37
+ }, _class);
38
+
39
+ // src/core/testing/FakeRenderNode.ts
40
+ var FakeRenderNode = (_class2 = class _FakeRenderNode {
41
+ __init8() {this.visible = true}
42
+ __init9() {this.x = 0}
43
+ __init10() {this.y = 0}
44
+ __init11() {this.groups = []}
45
+ __init12() {this.destroyed = false}
46
+
47
+ /** The same flag as `destroyed`, under the name of `IRenderRootNode`. */
48
+ get hostDestroyed() {
49
+ return this.destroyed;
50
+ }
51
+ constructor(release = () => {
52
+ }) {;_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);
53
+ this._release = release;
54
+ }
55
+ /** Whatever a test mounted this under, or `undefined` while detached. */
56
+ __init13() {this.parent = void 0}
57
+ __init14() {this.children = []}
58
+ mount(parent) {
59
+ this.parent = parent;
60
+ }
61
+ unmount() {
62
+ this.parent = void 0;
63
+ }
64
+ createChildNode() {
65
+ const node = new _FakeRenderNode((released) => {
66
+ const index = this.children.indexOf(released);
67
+ if (index >= 0) this.children.splice(index, 1);
68
+ });
69
+ this.children.push(node);
70
+ return node;
71
+ }
72
+ createParticleGroup(options) {
73
+ const group = new FakeParticleGroup(options);
74
+ this.groups.push(group);
75
+ return group;
76
+ }
77
+ setGroupIndex(group, index) {
78
+ const current = this.groups.indexOf(group);
79
+ if (current < 0) return;
80
+ const [moved] = this.groups.splice(current, 1);
81
+ this.groups.splice(index, 0, moved);
82
+ }
83
+ destroyParticleGroup(group) {
84
+ const index = this.groups.indexOf(group);
85
+ if (index < 0) return;
86
+ this.groups.splice(index, 1);
87
+ group.destroy();
88
+ }
89
+ destroy() {
90
+ if (this.destroyed) return;
91
+ this.destroyed = true;
92
+ [...this.children].forEach((child) => child.destroy());
93
+ this.groups.forEach((group) => group.destroy());
94
+ this._release(this);
95
+ }
96
+ }, _class2);
97
+
98
+ // src/core/testing/FakeTicker.ts
99
+ var FakeTicker = (_class3 = class {constructor() { _class3.prototype.__init15.call(this); }
100
+ __init15() {this.callbacks = []}
101
+ add(callback) {
102
+ this.callbacks.push(callback);
103
+ }
104
+ remove(callback) {
105
+ this.callbacks = this.callbacks.filter((registered) => registered !== callback);
106
+ }
107
+ /** Manually pump a frame to all registered callbacks. */
108
+ pump(deltaMS) {
109
+ this.callbacks.forEach((callback) => callback(deltaMS));
110
+ }
111
+ }, _class3);
112
+
113
+ // src/core/testing/FakeRenderer.ts
114
+ var FakeRenderer = (_class4 = class {constructor() { _class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this);_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this); }
115
+ __init16() {this.ticker = new FakeTicker()}
116
+ __init17() {this.nodes = []}
117
+ __init18() {this.textureCache = /* @__PURE__ */ new Map()}
118
+ __init19() {this.destroyed = false}
119
+ /** Every emitter node, across every playback root. */
120
+ get emitterNodes() {
121
+ return this.nodes.flatMap((node) => node.children);
122
+ }
123
+ /** Every group of every node, in creation order. */
124
+ get groups() {
125
+ return this.nodes.flatMap((node) => [node, ...node.children].flatMap((n) => n.groups));
126
+ }
127
+ createRootNode() {
128
+ const node = new FakeRenderNode((released) => this._releaseNode(released));
129
+ this.nodes.push(node);
130
+ return node;
131
+ }
132
+ /** Mirrors the adapters: a destroyed node stops being a live one. */
133
+ _releaseNode(node) {
134
+ const index = this.nodes.indexOf(node);
135
+ if (index >= 0) this.nodes.splice(index, 1);
136
+ }
137
+ resolveTexture(source) {
138
+ const cached = this.textureCache.get(source);
139
+ if (cached) return cached;
140
+ const reference = { width: 1, height: 1 };
141
+ this.textureCache.set(source, reference);
142
+ return reference;
143
+ }
144
+ clearTextureCache() {
145
+ this.textureCache.clear();
146
+ }
147
+ destroy() {
148
+ this.destroyed = true;
149
+ [...this.nodes].forEach((node) => node.destroy());
150
+ this.nodes.length = 0;
151
+ this.textureCache.clear();
152
+ }
153
+ }, _class4);
154
+
155
+
156
+
157
+
158
+
159
+ exports.FakeParticleGroup = FakeParticleGroup; exports.FakeRenderNode = FakeRenderNode; exports.FakeRenderer = FakeRenderer; exports.FakeTicker = FakeTicker;