@silentstatestudio/perseon 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +219 -0
  2. package/LICENSE.md +73 -0
  3. package/README.md +849 -2
  4. package/dist/authoring/index.cjs +218 -0
  5. package/dist/authoring/index.d.cts +964 -0
  6. package/dist/authoring/index.d.ts +964 -0
  7. package/dist/authoring/index.js +219 -0
  8. package/dist/authoring/index.js.map +1 -0
  9. package/dist/chunk-443SQYAB.cjs +8468 -0
  10. package/dist/chunk-AVYXWDFD.js +8469 -0
  11. package/dist/chunk-AVYXWDFD.js.map +1 -0
  12. package/dist/chunk-BEDH7OYG.js +5484 -0
  13. package/dist/chunk-BEDH7OYG.js.map +1 -0
  14. package/dist/chunk-WEQPSGPS.cjs +5482 -0
  15. package/dist/chunk-ZIMCQTYK.cjs +6 -0
  16. package/dist/chunk-ZTG42LPX.js +6 -0
  17. package/dist/chunk-ZTG42LPX.js.map +1 -0
  18. package/dist/colors-CCeWL9q4.d.cts +2597 -0
  19. package/dist/colors-CGWrMf4V.d.ts +2597 -0
  20. package/dist/core/index.cjs +34 -0
  21. package/dist/core/index.d.cts +40 -0
  22. package/dist/core/index.d.ts +40 -0
  23. package/dist/core/index.js +35 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/index.cjs +34 -0
  26. package/dist/index.d.cts +3 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.js +35 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/pixi-v7/index.cjs +587 -0
  31. package/dist/pixi-v7/index.d.cts +471 -0
  32. package/dist/pixi-v7/index.d.ts +471 -0
  33. package/dist/pixi-v7/index.js +588 -0
  34. package/dist/pixi-v7/index.js.map +1 -0
  35. package/dist/pixi-v8/index.cjs +679 -0
  36. package/dist/pixi-v8/index.d.cts +452 -0
  37. package/dist/pixi-v8/index.d.ts +452 -0
  38. package/dist/pixi-v8/index.js +680 -0
  39. package/dist/pixi-v8/index.js.map +1 -0
  40. package/dist/rendering-dYQXmGTV.d.cts +264 -0
  41. package/dist/rendering-dYQXmGTV.d.ts +264 -0
  42. package/dist/testing/index.cjs +182 -0
  43. package/dist/testing/index.d.cts +103 -0
  44. package/dist/testing/index.d.ts +103 -0
  45. package/dist/testing/index.js +184 -0
  46. package/dist/testing/index.js.map +1 -0
  47. package/package.json +144 -5
@@ -0,0 +1,182 @@
1
+ /*!
2
+ * @silentstatestudio/perseon v0.1.1
3
+ * Required Notice: Copyright 2026 Jesús Pérez de Miguel, trading as Silent State Studio (https://perseon.dev)
4
+ * PolyForm Perimeter License 1.0.1 <https://polyformproject.org/licenses/perimeter/1.0.1>
5
+ */
6
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2; var _class3; var _class4;// src/core/testing/FakeParticleGroup.ts
7
+ var FakeParticleGroup = (_class = class {
8
+ /** The options the group was created with. */
9
+
10
+ /** The particles currently held, in the order `addParticle` placed them (index 0 would be drawn first). */
11
+ __init() {this.particles = []}
12
+ /** How many times `addParticle` has been called. */
13
+ __init2() {this.addCalls = 0}
14
+ /** How many times `removeParticle` has been called, whether or not the particle was held. */
15
+ __init3() {this.removeCalls = 0}
16
+ /** How many times `removeAll` has been called. */
17
+ __init4() {this.removeAllCalls = 0}
18
+ /** How many times `syncFrame` has been called. */
19
+ __init5() {this.syncFrameCalls = 0}
20
+ /** Whether `destroy` has been called. */
21
+ __init6() {this.destroyed = false}
22
+ __init7() {this.visible = true}
23
+ /** Creates an empty, visible group that records `options`. */
24
+ 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);
25
+ this.options = options;
26
+ }
27
+ get size() {
28
+ return this.particles.length;
29
+ }
30
+ addParticle(particle, index) {
31
+ this.addCalls += 1;
32
+ this.particles.splice(index, 0, particle);
33
+ }
34
+ removeParticle(particle) {
35
+ this.removeCalls += 1;
36
+ const index = this.particles.indexOf(particle);
37
+ if (index >= 0) this.particles.splice(index, 1);
38
+ }
39
+ removeAll() {
40
+ this.removeAllCalls += 1;
41
+ this.particles.length = 0;
42
+ }
43
+ syncFrame() {
44
+ this.syncFrameCalls += 1;
45
+ }
46
+ destroy() {
47
+ this.destroyed = true;
48
+ this.particles.length = 0;
49
+ }
50
+ }, _class);
51
+
52
+ // src/core/testing/FakeRenderNode.ts
53
+ var FakeRenderNode = (_class2 = class _FakeRenderNode {
54
+ __init8() {this.visible = true}
55
+ __init9() {this.x = 0}
56
+ __init10() {this.y = 0}
57
+ /** The groups this node created and still holds, in z-order. After `destroy` they stay listed, destroyed, for inspection. */
58
+ __init11() {this.groups = []}
59
+ /** Whether `destroy` has been called. */
60
+ __init12() {this.destroyed = false}
61
+ /** Called once, at the end of `destroy`, so the owner can stop tracking this node. */
62
+
63
+ /** The same flag as `destroyed`, under the name of `IRenderRootNode`. */
64
+ get hostDestroyed() {
65
+ return this.destroyed;
66
+ }
67
+ /** Creates a detached, visible node at (0, 0). `release` is called when the node is destroyed. */
68
+ constructor(release = () => {
69
+ }) {;_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);
70
+ this._release = release;
71
+ }
72
+ /** Whatever a test mounted this under, or `undefined` while detached. */
73
+ __init13() {this.parent = void 0}
74
+ /** The child nodes created through `createChildNode` and not yet destroyed. */
75
+ __init14() {this.children = []}
76
+ mount(parent) {
77
+ this.parent = parent;
78
+ }
79
+ unmount() {
80
+ this.parent = void 0;
81
+ }
82
+ createChildNode() {
83
+ const node = new _FakeRenderNode((released) => {
84
+ const index = this.children.indexOf(released);
85
+ if (index >= 0) this.children.splice(index, 1);
86
+ });
87
+ this.children.push(node);
88
+ return node;
89
+ }
90
+ createParticleGroup(options) {
91
+ const group = new FakeParticleGroup(options);
92
+ this.groups.push(group);
93
+ return group;
94
+ }
95
+ setGroupIndex(group, index) {
96
+ const current = this.groups.indexOf(group);
97
+ if (current < 0) return;
98
+ const [moved] = this.groups.splice(current, 1);
99
+ this.groups.splice(index, 0, moved);
100
+ }
101
+ destroyParticleGroup(group) {
102
+ const index = this.groups.indexOf(group);
103
+ if (index < 0) return;
104
+ this.groups.splice(index, 1);
105
+ group.destroy();
106
+ }
107
+ destroy() {
108
+ if (this.destroyed) return;
109
+ this.destroyed = true;
110
+ [...this.children].forEach((child) => child.destroy());
111
+ this.groups.forEach((group) => group.destroy());
112
+ this._release(this);
113
+ }
114
+ }, _class2);
115
+
116
+ // src/core/testing/FakeTicker.ts
117
+ var FakeTicker = (_class3 = class {constructor() { _class3.prototype.__init15.call(this); }
118
+ /** The callbacks currently registered, in the order they were added. */
119
+ __init15() {this.callbacks = []}
120
+ add(callback) {
121
+ this.callbacks.push(callback);
122
+ }
123
+ remove(callback) {
124
+ this.callbacks = this.callbacks.filter((registered) => registered !== callback);
125
+ }
126
+ /** Manually pump a frame to all registered callbacks. */
127
+ pump(deltaMS) {
128
+ this.callbacks.forEach((callback) => callback(deltaMS));
129
+ }
130
+ }, _class3);
131
+
132
+ // src/core/testing/FakeRenderer.ts
133
+ 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); }
134
+ __init16() {this.ticker = new FakeTicker()}
135
+ /** The root nodes created through `createRootNode` that have not been destroyed. */
136
+ __init17() {this.nodes = []}
137
+ /** The texture references handed out so far, by source, until `clearTextureCache` or `destroy`. */
138
+ __init18() {this.textureCache = /* @__PURE__ */ new Map()}
139
+ /** Whether `destroy` has been called. */
140
+ __init19() {this.destroyed = false}
141
+ /** Every emitter node, across every playback root. */
142
+ get emitterNodes() {
143
+ return this.nodes.flatMap((node) => node.children);
144
+ }
145
+ /** Every group of every node, in creation order. */
146
+ get groups() {
147
+ return this.nodes.flatMap((node) => [node, ...node.children].flatMap((n) => n.groups));
148
+ }
149
+ createRootNode() {
150
+ const node = new FakeRenderNode((released) => this._releaseNode(released));
151
+ this.nodes.push(node);
152
+ return node;
153
+ }
154
+ /** Mirrors the adapters: a destroyed node stops being a live one. */
155
+ _releaseNode(node) {
156
+ const index = this.nodes.indexOf(node);
157
+ if (index >= 0) this.nodes.splice(index, 1);
158
+ }
159
+ /** Returns a 1x1 texture reference for any source, the same one each time for the same source. */
160
+ resolveTexture(source) {
161
+ const cached = this.textureCache.get(source);
162
+ if (cached) return cached;
163
+ const reference = { width: 1, height: 1 };
164
+ this.textureCache.set(source, reference);
165
+ return reference;
166
+ }
167
+ clearTextureCache() {
168
+ this.textureCache.clear();
169
+ }
170
+ destroy() {
171
+ this.destroyed = true;
172
+ [...this.nodes].forEach((node) => node.destroy());
173
+ this.nodes.length = 0;
174
+ this.textureCache.clear();
175
+ }
176
+ }, _class4);
177
+
178
+
179
+
180
+
181
+
182
+ exports.FakeParticleGroup = FakeParticleGroup; exports.FakeRenderNode = FakeRenderNode; exports.FakeRenderer = FakeRenderer; exports.FakeTicker = FakeTicker;
@@ -0,0 +1,103 @@
1
+ import { I as IParticleGroup, a as IParticleGroupOptions, b as IParticleVisualState, c as IRenderRootNode, d as IRenderNode, e as ITicker, f as IRenderer, g as ITextureRef } from '../rendering-dYQXmGTV.cjs';
2
+
3
+ /**
4
+ * In-memory IParticleGroup for tests. Counts every call the engine makes so
5
+ * assertions can cover grouped particle count, `syncFrame` invocations, etc.
6
+ */
7
+ declare class FakeParticleGroup implements IParticleGroup {
8
+ /** The options the group was created with. */
9
+ options: IParticleGroupOptions;
10
+ /** The particles currently held, in the order `addParticle` placed them (index 0 would be drawn first). */
11
+ particles: IParticleVisualState[];
12
+ /** How many times `addParticle` has been called. */
13
+ addCalls: number;
14
+ /** How many times `removeParticle` has been called, whether or not the particle was held. */
15
+ removeCalls: number;
16
+ /** How many times `removeAll` has been called. */
17
+ removeAllCalls: number;
18
+ /** How many times `syncFrame` has been called. */
19
+ syncFrameCalls: number;
20
+ /** Whether `destroy` has been called. */
21
+ destroyed: boolean;
22
+ visible: boolean;
23
+ /** Creates an empty, visible group that records `options`. */
24
+ constructor(options: IParticleGroupOptions);
25
+ get size(): number;
26
+ addParticle(particle: IParticleVisualState, index: number): void;
27
+ removeParticle(particle: IParticleVisualState): void;
28
+ removeAll(): void;
29
+ syncFrame(): void;
30
+ destroy(): void;
31
+ }
32
+
33
+ /**
34
+ * In-memory `IRenderNode` for tests: records its groups and their z-order, and
35
+ * releases itself from its renderer on destroy, exactly as the Pixi adapters do
36
+ * — so a leaked node shows up as a live node the renderer still holds.
37
+ */
38
+ declare class FakeRenderNode implements IRenderRootNode {
39
+ visible: boolean;
40
+ x: number;
41
+ y: number;
42
+ /** The groups this node created and still holds, in z-order. After `destroy` they stay listed, destroyed, for inspection. */
43
+ groups: FakeParticleGroup[];
44
+ /** Whether `destroy` has been called. */
45
+ destroyed: boolean;
46
+ /** Called once, at the end of `destroy`, so the owner can stop tracking this node. */
47
+ protected _release: (node: FakeRenderNode) => void;
48
+ /** The same flag as `destroyed`, under the name of `IRenderRootNode`. */
49
+ get hostDestroyed(): boolean;
50
+ /** Creates a detached, visible node at (0, 0). `release` is called when the node is destroyed. */
51
+ constructor(release?: (node: FakeRenderNode) => void);
52
+ /** Whatever a test mounted this under, or `undefined` while detached. */
53
+ parent: unknown;
54
+ /** The child nodes created through `createChildNode` and not yet destroyed. */
55
+ children: FakeRenderNode[];
56
+ mount(parent: unknown): void;
57
+ unmount(): void;
58
+ createChildNode(): IRenderNode;
59
+ createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
60
+ setGroupIndex(group: IParticleGroup, index: number): void;
61
+ destroyParticleGroup(group: IParticleGroup): void;
62
+ destroy(): void;
63
+ }
64
+
65
+ /**
66
+ * In-memory ITicker for tests: frames are pumped manually instead of being
67
+ * driven by a real render loop.
68
+ */
69
+ declare class FakeTicker implements ITicker {
70
+ /** The callbacks currently registered, in the order they were added. */
71
+ callbacks: Array<(deltaMS: number) => void>;
72
+ add(callback: (deltaMS: number) => void): void;
73
+ remove(callback: (deltaMS: number) => void): void;
74
+ /** Manually pump a frame to all registered callbacks. */
75
+ pump(deltaMS: number): void;
76
+ }
77
+
78
+ /**
79
+ * In-memory IRenderer for tests, so the engine can be driven without
80
+ * instantiating any PixiJS Container, Particle, or Texture.
81
+ */
82
+ declare class FakeRenderer implements IRenderer {
83
+ readonly ticker: FakeTicker;
84
+ /** The root nodes created through `createRootNode` that have not been destroyed. */
85
+ nodes: FakeRenderNode[];
86
+ /** The texture references handed out so far, by source, until `clearTextureCache` or `destroy`. */
87
+ textureCache: Map<unknown, ITextureRef>;
88
+ /** Whether `destroy` has been called. */
89
+ destroyed: boolean;
90
+ /** Every emitter node, across every playback root. */
91
+ get emitterNodes(): FakeRenderNode[];
92
+ /** Every group of every node, in creation order. */
93
+ get groups(): FakeParticleGroup[];
94
+ createRootNode(): IRenderRootNode;
95
+ /** Mirrors the adapters: a destroyed node stops being a live one. */
96
+ protected _releaseNode(node: FakeRenderNode): void;
97
+ /** Returns a 1x1 texture reference for any source, the same one each time for the same source. */
98
+ resolveTexture(source: unknown): ITextureRef;
99
+ clearTextureCache(): void;
100
+ destroy(): void;
101
+ }
102
+
103
+ export { FakeParticleGroup, FakeRenderNode, FakeRenderer, FakeTicker };
@@ -0,0 +1,103 @@
1
+ import { I as IParticleGroup, a as IParticleGroupOptions, b as IParticleVisualState, c as IRenderRootNode, d as IRenderNode, e as ITicker, f as IRenderer, g as ITextureRef } from '../rendering-dYQXmGTV.js';
2
+
3
+ /**
4
+ * In-memory IParticleGroup for tests. Counts every call the engine makes so
5
+ * assertions can cover grouped particle count, `syncFrame` invocations, etc.
6
+ */
7
+ declare class FakeParticleGroup implements IParticleGroup {
8
+ /** The options the group was created with. */
9
+ options: IParticleGroupOptions;
10
+ /** The particles currently held, in the order `addParticle` placed them (index 0 would be drawn first). */
11
+ particles: IParticleVisualState[];
12
+ /** How many times `addParticle` has been called. */
13
+ addCalls: number;
14
+ /** How many times `removeParticle` has been called, whether or not the particle was held. */
15
+ removeCalls: number;
16
+ /** How many times `removeAll` has been called. */
17
+ removeAllCalls: number;
18
+ /** How many times `syncFrame` has been called. */
19
+ syncFrameCalls: number;
20
+ /** Whether `destroy` has been called. */
21
+ destroyed: boolean;
22
+ visible: boolean;
23
+ /** Creates an empty, visible group that records `options`. */
24
+ constructor(options: IParticleGroupOptions);
25
+ get size(): number;
26
+ addParticle(particle: IParticleVisualState, index: number): void;
27
+ removeParticle(particle: IParticleVisualState): void;
28
+ removeAll(): void;
29
+ syncFrame(): void;
30
+ destroy(): void;
31
+ }
32
+
33
+ /**
34
+ * In-memory `IRenderNode` for tests: records its groups and their z-order, and
35
+ * releases itself from its renderer on destroy, exactly as the Pixi adapters do
36
+ * — so a leaked node shows up as a live node the renderer still holds.
37
+ */
38
+ declare class FakeRenderNode implements IRenderRootNode {
39
+ visible: boolean;
40
+ x: number;
41
+ y: number;
42
+ /** The groups this node created and still holds, in z-order. After `destroy` they stay listed, destroyed, for inspection. */
43
+ groups: FakeParticleGroup[];
44
+ /** Whether `destroy` has been called. */
45
+ destroyed: boolean;
46
+ /** Called once, at the end of `destroy`, so the owner can stop tracking this node. */
47
+ protected _release: (node: FakeRenderNode) => void;
48
+ /** The same flag as `destroyed`, under the name of `IRenderRootNode`. */
49
+ get hostDestroyed(): boolean;
50
+ /** Creates a detached, visible node at (0, 0). `release` is called when the node is destroyed. */
51
+ constructor(release?: (node: FakeRenderNode) => void);
52
+ /** Whatever a test mounted this under, or `undefined` while detached. */
53
+ parent: unknown;
54
+ /** The child nodes created through `createChildNode` and not yet destroyed. */
55
+ children: FakeRenderNode[];
56
+ mount(parent: unknown): void;
57
+ unmount(): void;
58
+ createChildNode(): IRenderNode;
59
+ createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
60
+ setGroupIndex(group: IParticleGroup, index: number): void;
61
+ destroyParticleGroup(group: IParticleGroup): void;
62
+ destroy(): void;
63
+ }
64
+
65
+ /**
66
+ * In-memory ITicker for tests: frames are pumped manually instead of being
67
+ * driven by a real render loop.
68
+ */
69
+ declare class FakeTicker implements ITicker {
70
+ /** The callbacks currently registered, in the order they were added. */
71
+ callbacks: Array<(deltaMS: number) => void>;
72
+ add(callback: (deltaMS: number) => void): void;
73
+ remove(callback: (deltaMS: number) => void): void;
74
+ /** Manually pump a frame to all registered callbacks. */
75
+ pump(deltaMS: number): void;
76
+ }
77
+
78
+ /**
79
+ * In-memory IRenderer for tests, so the engine can be driven without
80
+ * instantiating any PixiJS Container, Particle, or Texture.
81
+ */
82
+ declare class FakeRenderer implements IRenderer {
83
+ readonly ticker: FakeTicker;
84
+ /** The root nodes created through `createRootNode` that have not been destroyed. */
85
+ nodes: FakeRenderNode[];
86
+ /** The texture references handed out so far, by source, until `clearTextureCache` or `destroy`. */
87
+ textureCache: Map<unknown, ITextureRef>;
88
+ /** Whether `destroy` has been called. */
89
+ destroyed: boolean;
90
+ /** Every emitter node, across every playback root. */
91
+ get emitterNodes(): FakeRenderNode[];
92
+ /** Every group of every node, in creation order. */
93
+ get groups(): FakeParticleGroup[];
94
+ createRootNode(): IRenderRootNode;
95
+ /** Mirrors the adapters: a destroyed node stops being a live one. */
96
+ protected _releaseNode(node: FakeRenderNode): void;
97
+ /** Returns a 1x1 texture reference for any source, the same one each time for the same source. */
98
+ resolveTexture(source: unknown): ITextureRef;
99
+ clearTextureCache(): void;
100
+ destroy(): void;
101
+ }
102
+
103
+ export { FakeParticleGroup, FakeRenderNode, FakeRenderer, FakeTicker };
@@ -0,0 +1,184 @@
1
+ /*!
2
+ * @silentstatestudio/perseon v0.1.1
3
+ * Required Notice: Copyright 2026 Jesús Pérez de Miguel, trading as Silent State Studio (https://perseon.dev)
4
+ * PolyForm Perimeter License 1.0.1 <https://polyformproject.org/licenses/perimeter/1.0.1>
5
+ */
6
+
7
+ // src/core/testing/FakeParticleGroup.ts
8
+ var FakeParticleGroup = class {
9
+ /** The options the group was created with. */
10
+ options;
11
+ /** The particles currently held, in the order `addParticle` placed them (index 0 would be drawn first). */
12
+ particles = [];
13
+ /** How many times `addParticle` has been called. */
14
+ addCalls = 0;
15
+ /** How many times `removeParticle` has been called, whether or not the particle was held. */
16
+ removeCalls = 0;
17
+ /** How many times `removeAll` has been called. */
18
+ removeAllCalls = 0;
19
+ /** How many times `syncFrame` has been called. */
20
+ syncFrameCalls = 0;
21
+ /** Whether `destroy` has been called. */
22
+ destroyed = false;
23
+ visible = true;
24
+ /** Creates an empty, visible group that records `options`. */
25
+ constructor(options) {
26
+ this.options = options;
27
+ }
28
+ get size() {
29
+ return this.particles.length;
30
+ }
31
+ addParticle(particle, index) {
32
+ this.addCalls += 1;
33
+ this.particles.splice(index, 0, particle);
34
+ }
35
+ removeParticle(particle) {
36
+ this.removeCalls += 1;
37
+ const index = this.particles.indexOf(particle);
38
+ if (index >= 0) this.particles.splice(index, 1);
39
+ }
40
+ removeAll() {
41
+ this.removeAllCalls += 1;
42
+ this.particles.length = 0;
43
+ }
44
+ syncFrame() {
45
+ this.syncFrameCalls += 1;
46
+ }
47
+ destroy() {
48
+ this.destroyed = true;
49
+ this.particles.length = 0;
50
+ }
51
+ };
52
+
53
+ // src/core/testing/FakeRenderNode.ts
54
+ var FakeRenderNode = class _FakeRenderNode {
55
+ visible = true;
56
+ x = 0;
57
+ y = 0;
58
+ /** The groups this node created and still holds, in z-order. After `destroy` they stay listed, destroyed, for inspection. */
59
+ groups = [];
60
+ /** Whether `destroy` has been called. */
61
+ destroyed = false;
62
+ /** Called once, at the end of `destroy`, so the owner can stop tracking this node. */
63
+ _release;
64
+ /** The same flag as `destroyed`, under the name of `IRenderRootNode`. */
65
+ get hostDestroyed() {
66
+ return this.destroyed;
67
+ }
68
+ /** Creates a detached, visible node at (0, 0). `release` is called when the node is destroyed. */
69
+ constructor(release = () => {
70
+ }) {
71
+ this._release = release;
72
+ }
73
+ /** Whatever a test mounted this under, or `undefined` while detached. */
74
+ parent = void 0;
75
+ /** The child nodes created through `createChildNode` and not yet destroyed. */
76
+ children = [];
77
+ mount(parent) {
78
+ this.parent = parent;
79
+ }
80
+ unmount() {
81
+ this.parent = void 0;
82
+ }
83
+ createChildNode() {
84
+ const node = new _FakeRenderNode((released) => {
85
+ const index = this.children.indexOf(released);
86
+ if (index >= 0) this.children.splice(index, 1);
87
+ });
88
+ this.children.push(node);
89
+ return node;
90
+ }
91
+ createParticleGroup(options) {
92
+ const group = new FakeParticleGroup(options);
93
+ this.groups.push(group);
94
+ return group;
95
+ }
96
+ setGroupIndex(group, index) {
97
+ const current = this.groups.indexOf(group);
98
+ if (current < 0) return;
99
+ const [moved] = this.groups.splice(current, 1);
100
+ this.groups.splice(index, 0, moved);
101
+ }
102
+ destroyParticleGroup(group) {
103
+ const index = this.groups.indexOf(group);
104
+ if (index < 0) return;
105
+ this.groups.splice(index, 1);
106
+ group.destroy();
107
+ }
108
+ destroy() {
109
+ if (this.destroyed) return;
110
+ this.destroyed = true;
111
+ [...this.children].forEach((child) => child.destroy());
112
+ this.groups.forEach((group) => group.destroy());
113
+ this._release(this);
114
+ }
115
+ };
116
+
117
+ // src/core/testing/FakeTicker.ts
118
+ var FakeTicker = class {
119
+ /** The callbacks currently registered, in the order they were added. */
120
+ callbacks = [];
121
+ add(callback) {
122
+ this.callbacks.push(callback);
123
+ }
124
+ remove(callback) {
125
+ this.callbacks = this.callbacks.filter((registered) => registered !== callback);
126
+ }
127
+ /** Manually pump a frame to all registered callbacks. */
128
+ pump(deltaMS) {
129
+ this.callbacks.forEach((callback) => callback(deltaMS));
130
+ }
131
+ };
132
+
133
+ // src/core/testing/FakeRenderer.ts
134
+ var FakeRenderer = class {
135
+ ticker = new FakeTicker();
136
+ /** The root nodes created through `createRootNode` that have not been destroyed. */
137
+ nodes = [];
138
+ /** The texture references handed out so far, by source, until `clearTextureCache` or `destroy`. */
139
+ textureCache = /* @__PURE__ */ new Map();
140
+ /** Whether `destroy` has been called. */
141
+ destroyed = false;
142
+ /** Every emitter node, across every playback root. */
143
+ get emitterNodes() {
144
+ return this.nodes.flatMap((node) => node.children);
145
+ }
146
+ /** Every group of every node, in creation order. */
147
+ get groups() {
148
+ return this.nodes.flatMap((node) => [node, ...node.children].flatMap((n) => n.groups));
149
+ }
150
+ createRootNode() {
151
+ const node = new FakeRenderNode((released) => this._releaseNode(released));
152
+ this.nodes.push(node);
153
+ return node;
154
+ }
155
+ /** Mirrors the adapters: a destroyed node stops being a live one. */
156
+ _releaseNode(node) {
157
+ const index = this.nodes.indexOf(node);
158
+ if (index >= 0) this.nodes.splice(index, 1);
159
+ }
160
+ /** Returns a 1x1 texture reference for any source, the same one each time for the same source. */
161
+ resolveTexture(source) {
162
+ const cached = this.textureCache.get(source);
163
+ if (cached) return cached;
164
+ const reference = { width: 1, height: 1 };
165
+ this.textureCache.set(source, reference);
166
+ return reference;
167
+ }
168
+ clearTextureCache() {
169
+ this.textureCache.clear();
170
+ }
171
+ destroy() {
172
+ this.destroyed = true;
173
+ [...this.nodes].forEach((node) => node.destroy());
174
+ this.nodes.length = 0;
175
+ this.textureCache.clear();
176
+ }
177
+ };
178
+ export {
179
+ FakeParticleGroup,
180
+ FakeRenderNode,
181
+ FakeRenderer,
182
+ FakeTicker
183
+ };
184
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/testing/FakeParticleGroup.ts","../../src/core/testing/FakeRenderNode.ts","../../src/core/testing/FakeTicker.ts","../../src/core/testing/FakeRenderer.ts"],"mappings":";;;;;;;AAMO,IAAM,oBAAN,MAAkD;AAAA;AAAA,EAE9C;AAAA;AAAA,EAEA,YAAoC,CAAC;AAAA;AAAA,EAErC,WAAW;AAAA;AAAA,EAEX,cAAc;AAAA;AAAA,EAEd,iBAAiB;AAAA;AAAA,EAEjB,iBAAiB;AAAA;AAAA,EAEjB,YAAY;AAAA,EACZ,UAAU;AAAA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