lantern-engine 0.0.0-stage → 0.4.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 (178) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/LICENSE +21 -0
  3. package/README.md +113 -2
  4. package/dist/assets/takeCleanerWorker-DTcI_Jqr.js +31 -0
  5. package/dist/assets/takeCleanerWorker-DTcI_Jqr.js.map +1 -0
  6. package/dist/constants-CjYVdFid.js +252 -0
  7. package/dist/constants-CjYVdFid.js.map +1 -0
  8. package/dist/lantern-engine.js +3473 -0
  9. package/dist/lantern-engine.js.map +1 -0
  10. package/dist/pixel.js +1404 -0
  11. package/dist/pixel.js.map +1 -0
  12. package/dist/types/anim/Animator.d.ts +50 -0
  13. package/dist/types/anim/Animator.d.ts.map +1 -0
  14. package/dist/types/anim/animationSystem.d.ts +13 -0
  15. package/dist/types/anim/animationSystem.d.ts.map +1 -0
  16. package/dist/types/assets/AssetLoader.d.ts +85 -0
  17. package/dist/types/assets/AssetLoader.d.ts.map +1 -0
  18. package/dist/types/audio/MusicPlayer.d.ts +57 -0
  19. package/dist/types/audio/MusicPlayer.d.ts.map +1 -0
  20. package/dist/types/audio/SoundEngine.d.ts +42 -0
  21. package/dist/types/audio/SoundEngine.d.ts.map +1 -0
  22. package/dist/types/audio/cleanTake.d.ts +3 -0
  23. package/dist/types/audio/cleanTake.d.ts.map +1 -0
  24. package/dist/types/audio/sampleBank.d.ts +27 -0
  25. package/dist/types/audio/sampleBank.d.ts.map +1 -0
  26. package/dist/types/audio/soundTable.d.ts +14 -0
  27. package/dist/types/audio/soundTable.d.ts.map +1 -0
  28. package/dist/types/audio/synth.d.ts +34 -0
  29. package/dist/types/audio/synth.d.ts.map +1 -0
  30. package/dist/types/audio/takeCleanerWorker.d.ts +2 -0
  31. package/dist/types/audio/takeCleanerWorker.d.ts.map +1 -0
  32. package/dist/types/core/BitmapLabel.d.ts +26 -0
  33. package/dist/types/core/BitmapLabel.d.ts.map +1 -0
  34. package/dist/types/core/Camera.d.ts +90 -0
  35. package/dist/types/core/Camera.d.ts.map +1 -0
  36. package/dist/types/core/Clock.d.ts +11 -0
  37. package/dist/types/core/Clock.d.ts.map +1 -0
  38. package/dist/types/core/Graphics.d.ts +37 -0
  39. package/dist/types/core/Graphics.d.ts.map +1 -0
  40. package/dist/types/core/Group.d.ts +15 -0
  41. package/dist/types/core/Group.d.ts.map +1 -0
  42. package/dist/types/core/Image.d.ts +25 -0
  43. package/dist/types/core/Image.d.ts.map +1 -0
  44. package/dist/types/core/ObjectFactory.d.ts +34 -0
  45. package/dist/types/core/ObjectFactory.d.ts.map +1 -0
  46. package/dist/types/core/Pointer.d.ts +27 -0
  47. package/dist/types/core/Pointer.d.ts.map +1 -0
  48. package/dist/types/core/Rectangle.d.ts +26 -0
  49. package/dist/types/core/Rectangle.d.ts.map +1 -0
  50. package/dist/types/core/Stage.d.ts +58 -0
  51. package/dist/types/core/Stage.d.ts.map +1 -0
  52. package/dist/types/core/Text.d.ts +22 -0
  53. package/dist/types/core/Text.d.ts.map +1 -0
  54. package/dist/types/core/TextureRegistry.d.ts +51 -0
  55. package/dist/types/core/TextureRegistry.d.ts.map +1 -0
  56. package/dist/types/core/Tweener.d.ts +53 -0
  57. package/dist/types/core/Tweener.d.ts.map +1 -0
  58. package/dist/types/core/atlas.d.ts +16 -0
  59. package/dist/types/core/atlas.d.ts.map +1 -0
  60. package/dist/types/core/atlasPlan.d.ts +34 -0
  61. package/dist/types/core/atlasPlan.d.ts.map +1 -0
  62. package/dist/types/core/eases.d.ts +3 -0
  63. package/dist/types/core/eases.d.ts.map +1 -0
  64. package/dist/types/core/gameObject.d.ts +42 -0
  65. package/dist/types/core/gameObject.d.ts.map +1 -0
  66. package/dist/types/core/pixiPatches.d.ts +9 -0
  67. package/dist/types/core/pixiPatches.d.ts.map +1 -0
  68. package/dist/types/core/types.d.ts +4 -0
  69. package/dist/types/core/types.d.ts.map +1 -0
  70. package/dist/types/ecs/SparseSet.d.ts +25 -0
  71. package/dist/types/ecs/SparseSet.d.ts.map +1 -0
  72. package/dist/types/ecs/World.d.ts +133 -0
  73. package/dist/types/ecs/World.d.ts.map +1 -0
  74. package/dist/types/ecs/fields.d.ts +34 -0
  75. package/dist/types/ecs/fields.d.ts.map +1 -0
  76. package/dist/types/engine/Engine.d.ts +80 -0
  77. package/dist/types/engine/Engine.d.ts.map +1 -0
  78. package/dist/types/engine/FixedLoop.d.ts +32 -0
  79. package/dist/types/engine/FixedLoop.d.ts.map +1 -0
  80. package/dist/types/engine/Scene.d.ts +37 -0
  81. package/dist/types/engine/Scene.d.ts.map +1 -0
  82. package/dist/types/engine/SceneManager.d.ts +31 -0
  83. package/dist/types/engine/SceneManager.d.ts.map +1 -0
  84. package/dist/types/events/EventBus.d.ts +20 -0
  85. package/dist/types/events/EventBus.d.ts.map +1 -0
  86. package/dist/types/fx/hitStop.d.ts +20 -0
  87. package/dist/types/fx/hitStop.d.ts.map +1 -0
  88. package/dist/types/fx/viewCull.d.ts +14 -0
  89. package/dist/types/fx/viewCull.d.ts.map +1 -0
  90. package/dist/types/index.d.ts +68 -0
  91. package/dist/types/index.d.ts.map +1 -0
  92. package/dist/types/input/Actions.d.ts +75 -0
  93. package/dist/types/input/Actions.d.ts.map +1 -0
  94. package/dist/types/input/Keyboard.d.ts +25 -0
  95. package/dist/types/input/Keyboard.d.ts.map +1 -0
  96. package/dist/types/input/aimAxis.d.ts +9 -0
  97. package/dist/types/input/aimAxis.d.ts.map +1 -0
  98. package/dist/types/input/longPress.d.ts +21 -0
  99. package/dist/types/input/longPress.d.ts.map +1 -0
  100. package/dist/types/input/stickAxis.d.ts +26 -0
  101. package/dist/types/input/stickAxis.d.ts.map +1 -0
  102. package/dist/types/input/touchDetect.d.ts +18 -0
  103. package/dist/types/input/touchDetect.d.ts.map +1 -0
  104. package/dist/types/light/LightLayer.d.ts +65 -0
  105. package/dist/types/light/LightLayer.d.ts.map +1 -0
  106. package/dist/types/net/Connection.d.ts +66 -0
  107. package/dist/types/net/Connection.d.ts.map +1 -0
  108. package/dist/types/net/InterpolationBuffer.d.ts +36 -0
  109. package/dist/types/net/InterpolationBuffer.d.ts.map +1 -0
  110. package/dist/types/net/PredictedMover.d.ts +43 -0
  111. package/dist/types/net/PredictedMover.d.ts.map +1 -0
  112. package/dist/types/net/Room.d.ts +69 -0
  113. package/dist/types/net/Room.d.ts.map +1 -0
  114. package/dist/types/net/RoomHost.d.ts +74 -0
  115. package/dist/types/net/RoomHost.d.ts.map +1 -0
  116. package/dist/types/net/cadence.d.ts +22 -0
  117. package/dist/types/net/cadence.d.ts.map +1 -0
  118. package/dist/types/net/constants.d.ts +24 -0
  119. package/dist/types/net/constants.d.ts.map +1 -0
  120. package/dist/types/net/movement.d.ts +50 -0
  121. package/dist/types/net/movement.d.ts.map +1 -0
  122. package/dist/types/net/protocol.d.ts +59 -0
  123. package/dist/types/net/protocol.d.ts.map +1 -0
  124. package/dist/types/net/serverClock.d.ts +14 -0
  125. package/dist/types/net/serverClock.d.ts.map +1 -0
  126. package/dist/types/net/snapshotCodec.d.ts +55 -0
  127. package/dist/types/net/snapshotCodec.d.ts.map +1 -0
  128. package/dist/types/pixel/Darkness.d.ts +78 -0
  129. package/dist/types/pixel/Darkness.d.ts.map +1 -0
  130. package/dist/types/pixel/Evaporation.d.ts +30 -0
  131. package/dist/types/pixel/Evaporation.d.ts.map +1 -0
  132. package/dist/types/pixel/PixelLayer.d.ts +85 -0
  133. package/dist/types/pixel/PixelLayer.d.ts.map +1 -0
  134. package/dist/types/pixel/index.d.ts +22 -0
  135. package/dist/types/pixel/index.d.ts.map +1 -0
  136. package/dist/types/pixel/lights.d.ts +34 -0
  137. package/dist/types/pixel/lights.d.ts.map +1 -0
  138. package/dist/types/pixel/palette.d.ts +54 -0
  139. package/dist/types/pixel/palette.d.ts.map +1 -0
  140. package/dist/types/pixel/pixel.d.ts +80 -0
  141. package/dist/types/pixel/pixel.d.ts.map +1 -0
  142. package/dist/types/pixel/pixelPaint.d.ts +43 -0
  143. package/dist/types/pixel/pixelPaint.d.ts.map +1 -0
  144. package/dist/types/pixel/pixelTone.d.ts +49 -0
  145. package/dist/types/pixel/pixelTone.d.ts.map +1 -0
  146. package/dist/types/pixel/propKit.d.ts +26 -0
  147. package/dist/types/pixel/propKit.d.ts.map +1 -0
  148. package/dist/types/pixel/ramp.d.ts +31 -0
  149. package/dist/types/pixel/ramp.d.ts.map +1 -0
  150. package/dist/types/pixel/selout.d.ts +3 -0
  151. package/dist/types/pixel/selout.d.ts.map +1 -0
  152. package/dist/types/pixel/spritePixels.d.ts +29 -0
  153. package/dist/types/pixel/spritePixels.d.ts.map +1 -0
  154. package/dist/types/platform/touch.d.ts +5 -0
  155. package/dist/types/platform/touch.d.ts.map +1 -0
  156. package/dist/types/rig/PosePlayer.d.ts +64 -0
  157. package/dist/types/rig/PosePlayer.d.ts.map +1 -0
  158. package/dist/types/rig/RigView.d.ts +68 -0
  159. package/dist/types/rig/RigView.d.ts.map +1 -0
  160. package/dist/types/rig/Skeleton.d.ts +14 -0
  161. package/dist/types/rig/Skeleton.d.ts.map +1 -0
  162. package/dist/types/rig/humanoid.d.ts +4 -0
  163. package/dist/types/rig/humanoid.d.ts.map +1 -0
  164. package/dist/types/rig/humanoidPoses.d.ts +117 -0
  165. package/dist/types/rig/humanoidPoses.d.ts.map +1 -0
  166. package/dist/types/rig/poseMath.d.ts +14 -0
  167. package/dist/types/rig/poseMath.d.ts.map +1 -0
  168. package/dist/types/rig/rigTypes.d.ts +82 -0
  169. package/dist/types/rig/rigTypes.d.ts.map +1 -0
  170. package/dist/types/settings.d.ts +25 -0
  171. package/dist/types/settings.d.ts.map +1 -0
  172. package/dist/types/tilemap/TilemapView.d.ts +42 -0
  173. package/dist/types/tilemap/TilemapView.d.ts.map +1 -0
  174. package/dist/types/tilemap/collision.d.ts +16 -0
  175. package/dist/types/tilemap/collision.d.ts.map +1 -0
  176. package/dist/types/tilemap/tiled.d.ts +104 -0
  177. package/dist/types/tilemap/tiled.d.ts.map +1 -0
  178. package/package.json +82 -4
@@ -0,0 +1,22 @@
1
+ import { Text as PixiText } from 'pixi.js';
2
+ export interface TextStyle {
3
+ fontFamily?: string;
4
+ fontSize: string | number;
5
+ color?: string;
6
+ stroke?: string;
7
+ strokeThickness?: number;
8
+ /** Texture pixels per world pixel: world text is zoomed by the camera, so it is rasterised finer. */
9
+ resolution?: number;
10
+ align?: 'left' | 'center' | 'right';
11
+ lineSpacing?: number;
12
+ wordWrapWidth?: number;
13
+ }
14
+ declare const Text_base: typeof PixiText & (new (...args: any[]) => import("./gameObject.js").GameObjectMembers);
15
+ /** Canvas text in world or screen space. */
16
+ export declare class Text extends Text_base {
17
+ constructor(x: number, y: number, text: string, style: TextStyle);
18
+ setOrigin(x?: number, y?: number): this;
19
+ setText(text: string): this;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=Text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/core/Text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAyB,MAAM,SAAS,CAAC;AAGlE,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qGAAqG;IACrG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;;AAED,4CAA4C;AAC5C,qBAAa,IAAK,SAAQ,SAAoB;gBAChC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS;IAkBhE,SAAS,CAAC,CAAC,SAAM,EAAE,CAAC,SAAI,GAAG,IAAI;IAK/B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAI5B"}
@@ -0,0 +1,51 @@
1
+ import { CanvasSource, Texture } from 'pixi.js';
2
+ /** A canvas-backed texture with named frames; repaint the canvas, then `refresh()` to upload it. */
3
+ export declare class CanvasTexture {
4
+ readonly key: string;
5
+ readonly canvas: HTMLCanvasElement;
6
+ readonly frames: Map<string, Texture<import("pixi.js").TextureSource<any>>>;
7
+ readonly source: CanvasSource;
8
+ readonly whole: Texture;
9
+ constructor(key: string, canvas: HTMLCanvasElement);
10
+ get width(): number;
11
+ get height(): number;
12
+ get context(): CanvasRenderingContext2D;
13
+ /** Adds a frame cut from the canvas (`_source` kept for the old call shape). */
14
+ add(name: string, _source: number, x: number, y: number, w: number, h: number): void;
15
+ /**
16
+ * Registers under this texture a frame that lives on another one (an atlas page after the first), so the frame is
17
+ * found by this texture's key. A texture of its own over the other page's source: each side frees its own.
18
+ */
19
+ adopt(name: string, from: CanvasTexture): void;
20
+ refresh(): void;
21
+ destroy(): void;
22
+ }
23
+ /** Every texture of the world by key: the sprite atlas and per-player repainted sheets. */
24
+ export declare class TextureRegistry {
25
+ private readonly textures;
26
+ /** Textures repainted or freed while in use (a rig body, its hand): a copy of one must snapshot it first. */
27
+ private readonly live;
28
+ private missing;
29
+ private snapshots;
30
+ markLive(key: string): void;
31
+ isLive(key: string): boolean;
32
+ /** A new texture holding frame `frame` of `key` as it is painted right now; returns its key (one frame, '0'). */
33
+ snapshot(key: string, frame?: string | number): string;
34
+ /**
35
+ * `snapshot` into a texture kept for reuse (`into`): its canvas is repainted in place and uploaded again, and only
36
+ * made anew when the frame's size changes. Frame '0' is the copy.
37
+ */
38
+ snapshotInto(key: string, frame: string | number | undefined, into: string): void;
39
+ exists(key: string): boolean;
40
+ addCanvas(key: string, canvas: HTMLCanvasElement): CanvasTexture;
41
+ /** A canvas cut into equal frames named 0, 1, 2... left to right, then row by row. */
42
+ addSpriteSheet(key: string, canvas: HTMLCanvasElement, size: {
43
+ frameWidth: number;
44
+ frameHeight: number;
45
+ }): CanvasTexture;
46
+ createCanvas(key: string, width: number, height: number): CanvasTexture;
47
+ remove(key: string): void;
48
+ get(key: string, frame?: string | number): Texture;
49
+ private warn;
50
+ }
51
+ //# sourceMappingURL=TextureRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextureRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/TextureRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3D,oGAAoG;AACpG,qBAAa,aAAa;IAMtB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IANpC,QAAQ,CAAC,MAAM,6DAA8B;IAC7C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;gBAGb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB;IAMpC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,OAAO,IAAI,wBAAwB,CAEtC;IAED,gFAAgF;IAChF,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAKpF;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAO9C,OAAO,IAAI,IAAI;IAIf,OAAO,IAAI,IAAI;CAMhB;AAED,2FAA2F;AAC3F,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAC7D,6GAA6G;IAC7G,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,SAAS,CAAK;IAEtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI3B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,iHAAiH;IACjH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAatD;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAkBjF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,aAAa;IAOhE,sFAAsF;IACtF,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,aAAa;IAUxH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa;IAOvE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAOlD,OAAO,CAAC,IAAI;CAOb"}
@@ -0,0 +1,53 @@
1
+ export type TweenTarget = Record<string, unknown> & {
2
+ destroyed?: boolean;
3
+ };
4
+ /** Tween config in the shape the renderer has always used: numeric props at the top level or under `props`. */
5
+ export interface TweenConfig {
6
+ targets: object | object[];
7
+ duration?: number;
8
+ delay?: number;
9
+ /** Ms to stay at the end values before a yoyo plays back. */
10
+ hold?: number;
11
+ yoyo?: boolean;
12
+ /** Extra plays after the first (-1 = forever). */
13
+ repeat?: number;
14
+ ease?: string;
15
+ props?: Record<string, number>;
16
+ onStart?: () => void;
17
+ onUpdate?: () => void;
18
+ onComplete?: () => void;
19
+ [prop: string]: unknown;
20
+ }
21
+ /** One running tween; `remove()` stops it without calling onComplete. */
22
+ export declare class Tween {
23
+ private readonly cfg;
24
+ private readonly ends;
25
+ private tracks;
26
+ private elapsed;
27
+ private plays;
28
+ removed: boolean;
29
+ readonly targets: TweenTarget[];
30
+ constructor(cfg: TweenConfig, ends: Record<string, number>);
31
+ /**
32
+ * Every target is a destroyed display object: nothing is left to move. A forever tween (`repeat: -1`) on a sprite
33
+ * its owner freed used to stay in the list for good, holding the sprite, and the list grew with every map loaded.
34
+ * A plain object (a clock a callback reads) has no `destroyed` and is never taken for one. Only a forever tween is
35
+ * dropped this way: a finite one still runs out and calls its `onComplete`, which may clean up more than the sprite.
36
+ */
37
+ private orphaned;
38
+ remove(): void;
39
+ stop(): void;
40
+ /** Advances by `dt` ms; returns false once the tween is finished. */
41
+ step(dt: number): boolean;
42
+ }
43
+ /** Frame-driven tween manager (the renderer's replacement for Phaser's TweenManager). */
44
+ export declare class Tweener {
45
+ /** Global speed factor; hit-stop slows every tween at once. */
46
+ timeScale: number;
47
+ private tweens;
48
+ add(cfg: TweenConfig): Tween;
49
+ killTweensOf(target: object | object[]): void;
50
+ update(dt: number): void;
51
+ clear(): void;
52
+ }
53
+ //# sourceMappingURL=Tweener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tweener.d.ts","sourceRoot":"","sources":["../../../src/core/Tweener.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5E,+GAA+G;AAC/G,M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C,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAK7C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAiBxB,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,16 @@
1
+ import type { TextureRegistry } from './TextureRegistry.js';
2
+ /**
3
+ * Packs many small procedurally painted canvases into as few textures as the GPU allows, so Pixi can batch every
4
+ * sprite of the world into very few draw calls. One page on every desktop (up to 8192 square); a device whose GPU
5
+ * takes less gets pages of `limit` (`atlasPageLimit`, `planAtlas`). Every frame is registered under the one `key`
6
+ * whichever page holds it — the pages after the first are textures of their own (`key~1`, `key~2`…) whose frames
7
+ * the first page's texture adopts — so the world keeps asking for `atlas` and a frame name, and never knows.
8
+ * Frame names: `name` for single images, `name#i` for sheet frames.
9
+ */
10
+ export declare class AtlasBuilder {
11
+ private items;
12
+ add(name: string, canvas: HTMLCanvasElement): void;
13
+ addSheet(name: string, canvas: HTMLCanvasElement, frameWidth: number, frameHeight: number): void;
14
+ build(textures: TextureRegistry, key: string, limit?: number): void;
15
+ }
16
+ //# sourceMappingURL=atlas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../../../src/core/atlas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAUzD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAmB;IAEhC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAIlD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAIhG,KAAK,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAkB,GAAG,IAAI;CAuC7E"}
@@ -0,0 +1,34 @@
1
+ export declare const ATLAS_PAD = 2;
2
+ /** The page side every desktop GPU takes, and the one the atlas was built to before pages existed. */
3
+ export declare const ATLAS_PAGE_FULL = 8192;
4
+ /**
5
+ * How big an atlas page may be on this device: 8192 wherever the GPU takes it (every desktop — unchanged), else
6
+ * split at 4096, or at the largest power of two the GPU does take if that is smaller still. Unknown: 8192, as before.
7
+ */
8
+ export declare function atlasPageLimit(maxTextureSize: number | null): number;
9
+ export interface AtlasSize {
10
+ w: number;
11
+ h: number;
12
+ }
13
+ export interface AtlasPage {
14
+ width: number;
15
+ height: number;
16
+ }
17
+ export interface AtlasPlan {
18
+ pages: AtlasPage[];
19
+ /** One per input, in input order: the page and the top-left corner. */
20
+ places: {
21
+ page: number;
22
+ x: number;
23
+ y: number;
24
+ }[];
25
+ }
26
+ /**
27
+ * Shelf-packs the images, tallest first, into pages no larger than `limit` on either side. The page width is the
28
+ * power of two that fits the widest image and the square root of the total area (at least 1024), capped at `limit`;
29
+ * a shelf that would run past `limit` starts a new page. With everything fitting under `limit` this is exactly the
30
+ * single page the atlas always was. An image larger than `limit` itself is given a page of its own (the GPU will
31
+ * refuse it, but nothing else is lost with it).
32
+ */
33
+ export declare function planAtlas(sizes: readonly AtlasSize[], limit: number): AtlasPlan;
34
+ //# sourceMappingURL=atlasPlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atlasPlan.d.ts","sourceRoot":"","sources":["../../../src/core/atlasPlan.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,sGAAsG;AACtG,eAAO,MAAM,eAAe,OAAO,CAAC;AAIpC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGpE;AAED,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,uEAAuE;IACvE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAqC/E"}
@@ -0,0 +1,3 @@
1
+ export type EaseFn = (t: number) => number;
2
+ export declare function easeByName(name: string | undefined): EaseFn;
3
+ //# sourceMappingURL=eases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eases.d.ts","sourceRoot":"","sources":["../../../src/core/eases.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAmB3C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAK3D"}
@@ -0,0 +1,42 @@
1
+ import { type BLEND_MODES, type Container } from 'pixi.js';
2
+ import type { Stage } from './Stage.js';
3
+ type Ctor<T> = new (...args: any[]) => T;
4
+ /** What `GameObject` adds to a Pixi display object. */
5
+ export interface GameObjectMembers {
6
+ scene: Stage;
7
+ /** False once destroyed. */
8
+ readonly active: boolean;
9
+ /** The draw order in the world layer (`zIndex`): bigger is in front. */
10
+ depth: number;
11
+ /** Scale without the flip: stays positive on a mirrored sprite. */
12
+ scaleX: number;
13
+ scaleY: number;
14
+ flipX: boolean;
15
+ flipY: boolean;
16
+ setScale(x: number, y?: number): this;
17
+ setFlipX(v: boolean): this;
18
+ setFlipY(v: boolean): this;
19
+ setFlip(x: boolean, y: boolean): this;
20
+ setDepth(d: number): this;
21
+ setAlpha(a?: number): this;
22
+ setVisible(v: boolean): this;
23
+ setPosition(x?: number, y?: number): this;
24
+ setRotation(r?: number): this;
25
+ setAngle(a?: number): this;
26
+ setBlendMode(mode: BLEND_MODES): this;
27
+ setTint(color?: number): this;
28
+ /** Paints every opaque pixel in one solid colour (hit flash, silhouettes). */
29
+ setTintFill(color: number): this;
30
+ clearTint(): this;
31
+ /** 0 pins the object to the screen instead of the world. */
32
+ setScrollFactor(f: number): this;
33
+ destroy(): void;
34
+ }
35
+ /**
36
+ * The chainable setters the world code was written against (setDepth, setAlpha, setTintFill...), added onto a Pixi
37
+ * display object. Scale is kept apart from flipping, so `scaleX` stays positive on a mirrored sprite as it did
38
+ * before, and a tween on scale cannot undo a flip.
39
+ */
40
+ export declare function GameObject<TBase extends Ctor<Container>>(Base: TBase): TBase & Ctor<GameObjectMembers>;
41
+ export {};
42
+ //# sourceMappingURL=gameObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gameObject.d.ts","sourceRoot":"","sources":["../../../src/core/gameObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAsBzC,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,4BAA4B;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,8EAA8E;IAC9E,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,IAAI,IAAI,CAAC;IAClB,4DAA4D;IAC5D,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAuKtG"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Pixi 8's `BatchTextureArray.clear` sets `ids[source.uid] = null` instead of deleting the key, and its batches are
3
+ * pooled, so every pooled batch keeps one key for every texture source ever drawn through it — about 70% of what a
4
+ * fight's heap grew by in an hour (Pixi 8.21.0). The replacement deletes the key, which reads the
5
+ * same to Pixi (`checkAndUpdateTexture` treats null and a missing key alike). Applied once, and only while `clear`
6
+ * still has the shape it was written against, so a Pixi that fixed or changed it is left alone.
7
+ */
8
+ export declare function patchPixi(): boolean;
9
+ //# sourceMappingURL=pixiPatches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixiPatches.d.ts","sourceRoot":"","sources":["../../../src/core/pixiPatches.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAkBnC"}
@@ -0,0 +1,4 @@
1
+ import type { Container } from 'pixi.js';
2
+ /** Anything that can be placed in the world: images, graphics, groups, text. */
3
+ export type WorldObject = Container;
4
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * One component type's storage: a sparse set. `sparse[index]` is where the entity's value sits in the dense arrays
3
+ * (or -1), and `entities`/`values` are packed with no holes, so walking a component is a walk over two flat arrays
4
+ * and finding one is two array reads. Removing swaps the last entry into the hole.
5
+ *
6
+ * Indexed by the entity's slot index (`entityIndex`), not the whole id: the generation is checked by the world.
7
+ */
8
+ export declare class SparseSet<T> {
9
+ private sparse;
10
+ /** Packed entity ids, in the same order as `values`. */
11
+ readonly entities: number[];
12
+ readonly values: T[];
13
+ /** Bumped whenever an entity joins or leaves the set (not when a value changes): query caches key on it. */
14
+ version: number;
15
+ get size(): number;
16
+ has(index: number): boolean;
17
+ /** The value at slot `index`, or undefined. */
18
+ get(index: number): T | undefined;
19
+ set(index: number, entity: number, value: T): void;
20
+ /** Removes slot `index`; true if it was there. */
21
+ delete(index: number, indexOf: (entity: number) => number): boolean;
22
+ clear(): void;
23
+ private grow;
24
+ }
25
+ //# sourceMappingURL=SparseSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SparseSet.d.ts","sourceRoot":"","sources":["../../../src/ecs/SparseSet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,SAAS,CAAC,CAAC;IACtB,OAAO,CAAC,MAAM,CAA2C;IACzD,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAM;IACjC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,CAAM;IAC1B,4GAA4G;IAC5G,OAAO,SAAK;IAEZ,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI3B,+CAA+C;IAC/C,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAMjC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAclD,kDAAkD;IAClD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO;IAkBnE,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,IAAI;CAQb"}
@@ -0,0 +1,133 @@
1
+ import { type Columns, type FieldSpec, type FieldValues, type FieldsType } from './fields.js';
2
+ /**
3
+ * An entity–component–system store. Entities are numbers; components are data kept in one sparse set per component
4
+ * type; systems are functions run in the order they were added, each in a phase:
5
+ *
6
+ * - `fixed` runs once per simulation step (`FixedLoop`), for movement and rules;
7
+ * - `frame` runs once per rendered frame, for drawing and anything purely visual.
8
+ *
9
+ * Storage is a sparse set per component (packed arrays, O(1) lookups), the layout fast ECS libraries use. For hot
10
+ * loops prefer `each` (a callback, no allocation per entity) over `query` (an iterator yielding a fresh row).
11
+ *
12
+ * Entity ids are recycled: an id carries its slot index and a generation, so an id kept after its entity was
13
+ * destroyed never matches the entity that later reuses the slot.
14
+ *
15
+ * Changing structure while walking: adding components is always safe (new entries are not visited this walk).
16
+ * Removing a component or destroying an entity while a `query`, an `each` or a system run is in progress is deferred
17
+ * until it ends, so nothing is skipped or visited twice.
18
+ */
19
+ export type Entity = number;
20
+ /** A component type: a typed key. Make one per kind of data with `defineComponent`. */
21
+ export interface ComponentType<T> {
22
+ readonly id: number;
23
+ readonly name: string;
24
+ /** Phantom field carrying `T`; never set. */
25
+ readonly __type?: T;
26
+ }
27
+ export declare function defineComponent<T>(name: string): ComponentType<T>;
28
+ /** A component of numeric fields kept in typed-array columns (`fields.ts`): the fast form for data every body has. */
29
+ export declare function defineFields<const S extends FieldSpec>(name: string, fields: S): FieldsType<S>;
30
+ export type SystemPhase = 'fixed' | 'frame';
31
+ export interface SystemContext {
32
+ world: World;
33
+ /** Seconds this run covers: one step in `fixed`, the frame's length in `frame`. */
34
+ dt: number;
35
+ /** `performance.now()` of the frame. */
36
+ now: number;
37
+ /** In `frame`: the share of a step since the last fixed step (0–1), for interpolation. 0 in `fixed`. */
38
+ alpha: number;
39
+ }
40
+ export interface System {
41
+ readonly name: string;
42
+ readonly phase: SystemPhase;
43
+ run(ctx: SystemContext): void;
44
+ /** Called when the system is taken out of its world (or the world is cleared). */
45
+ dispose?(): void;
46
+ }
47
+ /** A system from a function. */
48
+ export declare function system(name: string, phase: SystemPhase, run: (ctx: SystemContext) => void): System;
49
+ export type ComponentValues<T extends readonly ComponentType<unknown>[]> = {
50
+ [K in keyof T]: T[K] extends ComponentType<infer V> ? V : never;
51
+ };
52
+ /** The slot an entity id sits in. */
53
+ export declare const entityIndex: (e: Entity) => number;
54
+ export declare class World {
55
+ /** Current generation per slot; an id is alive when its generation matches and the slot is in use. */
56
+ private generations;
57
+ private readonly inUse;
58
+ private readonly free;
59
+ private live;
60
+ private readonly stores;
61
+ /** Typed-array columns of the field components, by component id. */
62
+ private readonly cols;
63
+ private readonly systems;
64
+ private readonly pending;
65
+ /** `slots` results by the component ids asked for, rebuilt only when one of those sets changed membership. */
66
+ private readonly slotCache;
67
+ /** Walks (`query`, `each`, system runs) in progress: structure changes wait until it is 0. */
68
+ private walking;
69
+ /** A new entity with no components. */
70
+ create(): Entity;
71
+ /** A new entity with these components. */
72
+ spawn(...components: [ComponentType<unknown>, unknown][]): Entity;
73
+ isAlive(e: Entity): boolean;
74
+ /** Live entities. */
75
+ get size(): number;
76
+ /** Removes an entity and every component it had (deferred while a walk is in progress). */
77
+ destroy(e: Entity): void;
78
+ /** Gives an entity a field component; fields left out start at 0. Returns the slot index into its columns. */
79
+ add<S extends FieldSpec>(e: Entity, type: FieldsType<S>, values?: FieldValues<S>): number;
80
+ add<T>(e: Entity, type: ComponentType<T>, value: T): T;
81
+ /**
82
+ * The typed-array columns of a field component, indexed by slot. Fetch them per system run: adding entities may
83
+ * grow them into new arrays.
84
+ */
85
+ columns<S extends FieldSpec>(type: FieldsType<S>): Columns<S>;
86
+ get<T>(e: Entity, type: ComponentType<T>): T | undefined;
87
+ /** The component, or an error naming what is missing: for code that knows the entity has it. */
88
+ require<T>(e: Entity, type: ComponentType<T>): T;
89
+ has(e: Entity, type: ComponentType<unknown>): boolean;
90
+ /** Takes one component off an entity (deferred while a walk is in progress). */
91
+ remove(e: Entity, type: ComponentType<unknown>): void;
92
+ /** How many entities hold `type`. */
93
+ count(type: ComponentType<unknown>): number;
94
+ /**
95
+ * Calls `fn(entity, ...components)` for every live entity holding all of `types`. Allocates nothing per entity:
96
+ * the form for systems that walk thousands of bodies every step.
97
+ */
98
+ each<const T extends readonly ComponentType<unknown>[]>(...args: [...types: T, fn: (e: Entity, ...values: ComponentValues<T>) => void]): void;
99
+ /**
100
+ * The slot index of every entity holding all of `types`, as a typed array: the fastest walk there is, made for
101
+ * field components (`defineFields`), whose columns are indexed by slot.
102
+ *
103
+ * ```ts
104
+ * const p = world.columns(Position), v = world.columns(Velocity);
105
+ * const slots = world.slots(Position, Velocity);
106
+ * for (let k = 0; k < slots.length; k++) { const i = slots[k]!; p.x[i]! += v.x[i]! * dt; }
107
+ * ```
108
+ *
109
+ * The result is cached and rebuilt only when an entity joins or leaves one of those components, so asking every
110
+ * step is cheap. It is a view the world owns: read it, don't keep it past the step, and fetch it again after
111
+ * adding or removing components.
112
+ */
113
+ slots(...types: ComponentType<unknown>[]): Int32Array;
114
+ /**
115
+ * Every live entity holding all of `types`, with those components in the same order. Yields a fresh row per
116
+ * entity: convenient, but `each` is the form for hot loops.
117
+ */
118
+ query<const T extends readonly ComponentType<unknown>[]>(...types: T): IterableIterator<[Entity, ...ComponentValues<T>]>;
119
+ /** The first entity matching the query, or undefined: for singletons (the player, the camera target). */
120
+ first<const T extends readonly ComponentType<unknown>[]>(...types: T): [Entity, ...ComponentValues<T>] | undefined;
121
+ addSystem(s: System): this;
122
+ removeSystem(name: string): void;
123
+ /** Runs every system of `phase` in the order added. A system that throws is reported and the rest still run. */
124
+ run(phase: SystemPhase, ctx: Omit<SystemContext, 'world'>, onError?: (system: System, err: unknown) => void): void;
125
+ /** Every entity, component and system gone. */
126
+ clear(): void;
127
+ private columnsOf;
128
+ private store;
129
+ /** The stores for `types`, or null when one has never been used (so nothing can match). */
130
+ private setsFor;
131
+ private endWalk;
132
+ }
133
+ //# sourceMappingURL=World.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"World.d.ts","sourceRoot":"","sources":["../../../src/ecs/World.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAElH;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,uFAAuF;AACvF,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,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AAC,MAAM,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;IAKlH,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAM1B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAOhC,gHAAgH;IAChH,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAkBlH,+CAA+C;IAC/C,KAAK,IAAI,IAAI;IAYb,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,KAAK;IASb,2FAA2F;IAC3F,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,OAAO;CAShB"}
@@ -0,0 +1,34 @@
1
+ import type { ComponentType } from './World.js';
2
+ /**
3
+ * Numeric components stored as columns of typed arrays instead of one object per entity: `Position.x` and
4
+ * `Position.y` are two `Float32Array`s indexed by the entity's slot. A system walking thousands of bodies then reads
5
+ * memory in order and makes no garbage, which is several times faster than objects at scale (see `bench/`).
6
+ *
7
+ * ```ts
8
+ * const Position = defineFields('Position', { x: 'f32', y: 'f32' });
9
+ * world.add(e, Position, { x: 10, y: 20 });
10
+ * const p = world.columns(Position); // fetch per run: columns grow (and are replaced) as entities are added
11
+ * world.each(Position, (e, i) => { p.x[i] += 1; });
12
+ * ```
13
+ *
14
+ * In `each`/`query` a field component's value is the entity's slot index `i`, the index into every column.
15
+ */
16
+ export type FieldKind = 'f32' | 'f64' | 'i8' | 'i16' | 'i32' | 'u8' | 'u16' | 'u32';
17
+ export type FieldSpec = Record<string, FieldKind>;
18
+ export type ArrayOf<K extends FieldKind> = K extends 'f32' ? Float32Array : K extends 'f64' ? Float64Array : K extends 'i8' ? Int8Array : K extends 'i16' ? Int16Array : K extends 'i32' ? Int32Array : K extends 'u8' ? Uint8Array : K extends 'u16' ? Uint16Array : Uint32Array;
19
+ /** One typed array per field, indexed by slot. */
20
+ export type Columns<S extends FieldSpec> = {
21
+ [K in keyof S]: ArrayOf<S[K]>;
22
+ };
23
+ /** What `add` takes for a field component: any subset of its fields (the rest start at 0). */
24
+ export type FieldValues<S extends FieldSpec> = {
25
+ [K in keyof S]?: number;
26
+ };
27
+ /** A component of numeric fields. Its value in `each`/`query` is the slot index. */
28
+ export interface FieldsType<S extends FieldSpec> extends ComponentType<number> {
29
+ readonly fields: S;
30
+ }
31
+ export declare function isFields(type: ComponentType<unknown>): type is FieldsType<FieldSpec>;
32
+ /** Fresh columns of at least `n` slots, keeping what `old` held. */
33
+ export declare function growColumns(spec: FieldSpec, n: number, old?: Record<string, ArrayLike<number>>): Record<string, ArrayLike<number>>;
34
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/ecs/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;AAEpF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAElD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,KAAK,GACtD,YAAY,GACZ,CAAC,SAAS,KAAK,GACb,YAAY,GACZ,CAAC,SAAS,IAAI,GACZ,SAAS,GACT,CAAC,SAAS,KAAK,GACb,UAAU,GACV,CAAC,SAAS,KAAK,GACb,UAAU,GACV,CAAC,SAAS,IAAI,GACZ,UAAU,GACV,CAAC,SAAS,KAAK,GACb,WAAW,GACX,WAAW,CAAC;AAE5B,kDAAkD;AAClD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,SAAS,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE7E,8FAA8F;AAC9F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,SAAS,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM;CAAE,CAAC;AAE3E,oFAAoF;AACpF,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,aAAa,CAAC,MAAM,CAAC;IAC5E,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACpB;AAaD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC,SAAS,CAAC,CAEpF;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CASlI"}
@@ -0,0 +1,80 @@
1
+ import { Application } from 'pixi.js';
2
+ import { Stage } from '../core/Stage.js';
3
+ import { TextureRegistry } from '../core/TextureRegistry.js';
4
+ import { EventBus } from '../events/EventBus.js';
5
+ import { FixedLoop } from './FixedLoop.js';
6
+ import { SceneManager } from './SceneManager.js';
7
+ import type { Scene } from './Scene.js';
8
+ export interface EngineOptions {
9
+ /** Where the canvas goes. */
10
+ parent: HTMLElement;
11
+ /** A fixed canvas size in CSS pixels. Leave both out to fill `parent` and follow its size. */
12
+ width?: number;
13
+ height?: number;
14
+ /** CSS colour behind the world (default black). */
15
+ background?: string;
16
+ /** World pixels are drawn this many screen pixels wide (default 1). Whole numbers keep pixel art crisp. */
17
+ zoom?: number;
18
+ /** Simulation steps per second (default 60). */
19
+ hz?: number;
20
+ /** Textures shared by the stage; a fresh registry by default. */
21
+ textures?: TextureRegistry;
22
+ /**
23
+ * Pixel art: nearest-neighbour textures, no antialiasing, one backing pixel per CSS pixel, and a camera that lands
24
+ * on whole pixels (default false: smooth textures drawn at the screen's own density, for any other art style).
25
+ */
26
+ pixelPerfect?: boolean;
27
+ /** Backing pixels per CSS pixel when not `pixelPerfect` (default `devicePixelRatio`, at most 2). */
28
+ resolution?: number;
29
+ /**
30
+ * Renderer preference (default 'webgl'). WebGL 2 runs everywhere the engine is tested. 'webgpu' is experimental:
31
+ * Pixi falls back to WebGL where WebGPU is missing, but the engine's own paths (pooled `PixelLayer` buffers, the
32
+ * `erase` blend `Darkness` cuts lights with, the fill filters) have only been profiled on WebGL.
33
+ */
34
+ preference?: 'webgl' | 'webgpu';
35
+ }
36
+ export interface EngineEvents {
37
+ /** Something a guarded step or a system threw; the frame carried on. */
38
+ error: {
39
+ where: string;
40
+ error: unknown;
41
+ };
42
+ /** After every rendered frame's update, before Pixi renders. */
43
+ frame: {
44
+ now: number;
45
+ dt: number;
46
+ };
47
+ }
48
+ /**
49
+ * The top of the engine: a Pixi application, the `Stage` (world and screen layers, camera, tweens, timers,
50
+ * pointer), a fixed-step simulation loop and a stack of scenes.
51
+ *
52
+ * ```ts
53
+ * const engine = await Engine.create({ parent: document.body, zoom: 3 });
54
+ * await engine.scenes.replace(new MyLevel());
55
+ * ```
56
+ */
57
+ export declare class Engine {
58
+ readonly app: Application;
59
+ readonly stage: Stage;
60
+ readonly loop: FixedLoop;
61
+ readonly scenes: SceneManager;
62
+ readonly events: EventBus<EngineEvents>;
63
+ private running;
64
+ private destroyed;
65
+ private readonly onTick;
66
+ private constructor();
67
+ static create(options: EngineOptions): Promise<Engine>;
68
+ /** The scene that updates now, if any. */
69
+ get scene(): Scene | undefined;
70
+ /** Stops simulating and drawing; the canvas keeps its last frame. */
71
+ pause(): void;
72
+ resume(): void;
73
+ get paused(): boolean;
74
+ /** Reports a fault to `events.error` (and the console when nobody listens). */
75
+ reportError(where: string, error: unknown): void;
76
+ /** Leaves every scene, removes the canvas and frees the renderer. */
77
+ destroy(): Promise<void>;
78
+ private tick;
79
+ }
80
+ //# sourceMappingURL=Engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Engine.d.ts","sourceRoot":"","sources":["../../../src/engine/Engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oGAAoG;IACpG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,gEAAgE;IAChE,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACpC;AAiBD;;;;;;;;GAQG;AACH,qBAAa,MAAM;IAUf,QAAQ,CAAC,GAAG,EAAE,WAAW;IAT3B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,yBAAgC;IAC/C,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2D;IAElF,OAAO;WAgBM,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB5D,0CAA0C;IAC1C,IAAI,KAAK,IAAI,KAAK,GAAG,SAAS,CAE7B;IAED,qEAAqE;IACrE,KAAK,IAAI,IAAI;IAMb,MAAM,IAAI,IAAI;IAOd,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,+EAA+E;IAC/E,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAKhD,qEAAqE;IAC/D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAW9B,OAAO,CAAC,IAAI;CAeb"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A fixed-timestep accumulator: frames arrive whenever the display wants them, the simulation advances in equal
3
+ * steps. Movement and anything a server replays must run here, so every machine takes the same steps whatever its
4
+ * frame rate.
5
+ *
6
+ * A frame that comes very late (a tab in the background, a debugger) would owe hundreds of steps; at most
7
+ * `maxStepsPerFrame` are run and the rest of the debt is dropped, so the game slows down instead of freezing while it
8
+ * catches up (the "spiral of death").
9
+ */
10
+ export interface FixedLoopOptions {
11
+ /** Steps per second (default 60). */
12
+ hz?: number;
13
+ /** The most steps one frame may run before the debt is dropped (default 8). */
14
+ maxStepsPerFrame?: number;
15
+ }
16
+ export declare class FixedLoop {
17
+ readonly stepMs: number;
18
+ readonly stepSeconds: number;
19
+ private readonly maxSteps;
20
+ private carry;
21
+ /** Steps taken since the loop started. */
22
+ tick: number;
23
+ constructor(options?: FixedLoopOptions);
24
+ /**
25
+ * Feeds one frame of `deltaMs` and runs `step` as many times as it owes. Returns the share of a step left over
26
+ * (0–1), for interpolating what is drawn between the last two steps.
27
+ */
28
+ advance(deltaMs: number, step: (tick: number) => void): number;
29
+ /** Forgets any debt, e.g. after a scene change or a long load. */
30
+ reset(): void;
31
+ }
32
+ //# sourceMappingURL=FixedLoop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FixedLoop.d.ts","sourceRoot":"","sources":["../../../src/engine/FixedLoop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,SAAS;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,KAAK,CAAK;IAClB,0CAA0C;IAC1C,IAAI,SAAK;gBAEG,OAAO,GAAE,gBAAqB;IAQ1C;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM;IAe9D,kEAAkE;IAClE,KAAK,IAAI,IAAI;CAGd"}