@zylem/game-lib 0.6.4 → 0.8.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 (156) hide show
  1. package/README.md +18 -2
  2. package/dist/actions.d.ts +321 -11
  3. package/dist/actions.js +1 -936
  4. package/dist/api/game-lib.api.json +54074 -0
  5. package/dist/api/game-lib.api.md +4544 -0
  6. package/dist/api/game-lib.d.ts +8258 -0
  7. package/dist/api/game-lib.typedoc.json +345421 -0
  8. package/dist/audio.d.ts +13 -0
  9. package/dist/audio.js +1 -0
  10. package/dist/base-node-life-cycle-D2NuN1VB.d.ts +151 -0
  11. package/dist/behavior.d.ts +2 -0
  12. package/dist/behavior.js +1 -0
  13. package/dist/blueprints-TbGY-h53.d.ts +162 -0
  14. package/dist/chunk-4QLJUQSJ.js +1 -0
  15. package/dist/chunk-7FR5JSQ2.js +1 -0
  16. package/dist/chunk-7GYFZKK7.js +1 -0
  17. package/dist/chunk-7WRQ2UAN.js +1 -0
  18. package/dist/chunk-BH53MBAZ.js +1 -0
  19. package/dist/chunk-BIGH6D34.js +0 -0
  20. package/dist/chunk-CM5YRNBJ.js +19 -0
  21. package/dist/chunk-COM6HJ2L.js +1 -0
  22. package/dist/chunk-D2PATZCC.js +1 -0
  23. package/dist/chunk-DFLI7ICU.js +0 -0
  24. package/dist/chunk-E3UBSUPX.js +1 -0
  25. package/dist/chunk-FKIKN7RP.js +24 -0
  26. package/dist/chunk-G4HONLWC.js +1 -0
  27. package/dist/chunk-IKWE2W6L.js +1 -0
  28. package/dist/chunk-IPWUDOV5.js +1 -0
  29. package/dist/chunk-JEHFHUH4.js +0 -0
  30. package/dist/chunk-JNKPTL77.js +1 -0
  31. package/dist/chunk-JQKS42G4.js +1 -0
  32. package/dist/chunk-M3XNO56P.js +1 -0
  33. package/dist/chunk-MSC2BEO5.js +1 -0
  34. package/dist/chunk-ORIDWL3T.js +0 -0
  35. package/dist/chunk-QB3NL7VQ.js +1 -0
  36. package/dist/chunk-QXVH6POE.js +1 -0
  37. package/dist/chunk-RXDTAWI2.js +29 -0
  38. package/dist/chunk-TAUWDQZF.js +9 -0
  39. package/dist/chunk-VS2D4B3W.js +1 -0
  40. package/dist/chunk-WQ3WMMZD.js +1 -0
  41. package/dist/chunk-XK63E4SX.js +1 -0
  42. package/dist/chunk-XNDS4YFR.js +1 -0
  43. package/dist/chunk-XNHVRFAK.js +1 -0
  44. package/dist/chunk-XRP4JJXL.js +1 -0
  45. package/dist/chunk-YHEWKN7N.js +1 -0
  46. package/dist/chunk-ZRT3ZQVH.js +1 -0
  47. package/dist/collision-builder-jF-toPIl.d.ts +38 -0
  48. package/dist/core.d.ts +223 -16
  49. package/dist/core.js +1 -12424
  50. package/dist/debug-state-BPT6jEog.d.ts +17 -0
  51. package/dist/debug.d.ts +76 -0
  52. package/dist/debug.js +1 -0
  53. package/dist/default-controls-0-vCnli7.d.ts +111 -0
  54. package/dist/{entity-vj-HTjzU.d.ts → entity-BdSI8CL3.d.ts} +119 -626
  55. package/dist/{entity-Bq_eNEDI.d.ts → entity-DZbFQ1Wg.d.ts} +4 -4
  56. package/dist/entity-type-map-Bd69SpAS.d.ts +928 -0
  57. package/dist/entity.d.ts +268 -0
  58. package/dist/entity.js +1 -0
  59. package/dist/events.d.ts +181 -0
  60. package/dist/events.js +1 -0
  61. package/dist/game-C1FHVqXl.d.ts +1886 -0
  62. package/dist/game-default-QHROHW2O.js +1 -0
  63. package/dist/game-interfaces-mchNYSZE.d.ts +90 -0
  64. package/dist/globals.d.ts +115 -0
  65. package/dist/globals.js +1 -0
  66. package/dist/graphics.d.ts +53 -0
  67. package/dist/graphics.js +1 -0
  68. package/dist/input-ui.d.ts +35 -0
  69. package/dist/input-ui.js +1 -0
  70. package/dist/input.d.ts +73 -0
  71. package/dist/input.js +1 -0
  72. package/dist/material-9vJ6SZaI.d.ts +126 -0
  73. package/dist/public.d.ts +38 -0
  74. package/dist/public.js +1 -0
  75. package/dist/runtime.d.ts +59 -0
  76. package/dist/runtime.js +1 -0
  77. package/dist/schema/entity.schema.json +244 -0
  78. package/dist/schema/game-config.schema.json +625 -0
  79. package/dist/schema/input-config.schema.json +499 -0
  80. package/dist/schema/stage-config.schema.json +93 -0
  81. package/dist/schema/stage.schema.json +271 -0
  82. package/dist/schema.d.ts +538 -0
  83. package/dist/schema.js +1 -0
  84. package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
  85. package/dist/vector-CiSHbivc.d.ts +133 -0
  86. package/dist/web-components.d.ts +70 -0
  87. package/dist/web-components.js +1 -0
  88. package/dist/zylem-camera-C3bn6BTI.d.ts +575 -0
  89. package/package.json +70 -73
  90. package/dist/actions.js.map +0 -1
  91. package/dist/behavior/jumper-2d.d.ts +0 -114
  92. package/dist/behavior/jumper-2d.js +0 -711
  93. package/dist/behavior/jumper-2d.js.map +0 -1
  94. package/dist/behavior/platformer-3d.d.ts +0 -296
  95. package/dist/behavior/platformer-3d.js +0 -761
  96. package/dist/behavior/platformer-3d.js.map +0 -1
  97. package/dist/behavior/ricochet-2d.d.ts +0 -275
  98. package/dist/behavior/ricochet-2d.js +0 -425
  99. package/dist/behavior/ricochet-2d.js.map +0 -1
  100. package/dist/behavior/ricochet-3d.d.ts +0 -117
  101. package/dist/behavior/ricochet-3d.js +0 -443
  102. package/dist/behavior/ricochet-3d.js.map +0 -1
  103. package/dist/behavior/screen-visibility.d.ts +0 -79
  104. package/dist/behavior/screen-visibility.js +0 -358
  105. package/dist/behavior/screen-visibility.js.map +0 -1
  106. package/dist/behavior/screen-wrap.d.ts +0 -87
  107. package/dist/behavior/screen-wrap.js +0 -246
  108. package/dist/behavior/screen-wrap.js.map +0 -1
  109. package/dist/behavior/shooter-2d.d.ts +0 -79
  110. package/dist/behavior/shooter-2d.js +0 -180
  111. package/dist/behavior/shooter-2d.js.map +0 -1
  112. package/dist/behavior/thruster.d.ts +0 -11
  113. package/dist/behavior/thruster.js +0 -292
  114. package/dist/behavior/thruster.js.map +0 -1
  115. package/dist/behavior/top-down-movement.d.ts +0 -56
  116. package/dist/behavior/top-down-movement.js +0 -125
  117. package/dist/behavior/top-down-movement.js.map +0 -1
  118. package/dist/behavior/world-boundary-2d.d.ts +0 -142
  119. package/dist/behavior/world-boundary-2d.js +0 -235
  120. package/dist/behavior/world-boundary-2d.js.map +0 -1
  121. package/dist/behavior/world-boundary-3d.d.ts +0 -76
  122. package/dist/behavior/world-boundary-3d.js +0 -274
  123. package/dist/behavior/world-boundary-3d.js.map +0 -1
  124. package/dist/behavior-descriptor-BXnVR8Ki.d.ts +0 -159
  125. package/dist/blueprints-DmbK2dki.d.ts +0 -26
  126. package/dist/camera-4XO5gbQH.d.ts +0 -905
  127. package/dist/camera.d.ts +0 -6
  128. package/dist/camera.js +0 -1993
  129. package/dist/camera.js.map +0 -1
  130. package/dist/composition-BASvMKrW.d.ts +0 -218
  131. package/dist/core-CARRaS55.d.ts +0 -541
  132. package/dist/core.js.map +0 -1
  133. package/dist/entities-ChFirVL9.d.ts +0 -410
  134. package/dist/entities.d.ts +0 -9
  135. package/dist/entities.js +0 -4986
  136. package/dist/entities.js.map +0 -1
  137. package/dist/entity-types-DAu8sGJH.d.ts +0 -26
  138. package/dist/global-change-2JvMaz44.d.ts +0 -25
  139. package/dist/main.d.ts +0 -1353
  140. package/dist/main.js +0 -19525
  141. package/dist/main.js.map +0 -1
  142. package/dist/physics-pose-DCc4oE44.d.ts +0 -25
  143. package/dist/physics-protocol-BDD3P5W2.d.ts +0 -200
  144. package/dist/physics-worker.d.ts +0 -21
  145. package/dist/physics-worker.js +0 -306
  146. package/dist/physics-worker.js.map +0 -1
  147. package/dist/physics.d.ts +0 -205
  148. package/dist/physics.js +0 -577
  149. package/dist/physics.js.map +0 -1
  150. package/dist/stage-types-C19IhuzA.d.ts +0 -731
  151. package/dist/stage.d.ts +0 -52
  152. package/dist/stage.js +0 -8479
  153. package/dist/stage.js.map +0 -1
  154. package/dist/sync-state-machine-CZyspBpj.d.ts +0 -16
  155. package/dist/thruster-23lzoPZd.d.ts +0 -180
  156. package/dist/world-DfgxoNMt.d.ts +0 -105
@@ -1,541 +0,0 @@
1
- import { ak as InputPlayerNumber, al as InputProvider, am as Inputs, L as SetupContext, U as UpdateContext, M as DestroyContext, an as GameEntityLifeCycle, O as BaseNode, ao as IGame, S as SetupFunction, J as UpdateFunction, K as DestroyFunction, aa as GameEvents, ap as LoadedContext, aq as CleanupContext, ar as NodeInterface } from './entity-vj-HTjzU.js';
2
- import { G as GameInputConfig, e as StageInterface, B as BaseGlobals, b as Stage, Z as ZylemGameConfig } from './stage-types-C19IhuzA.js';
3
- import { Z as ZylemCamera, R as RendererManager } from './camera-4XO5gbQH.js';
4
- import { Vector3 } from 'three';
5
- import { Vector3 as Vector3$1 } from '@dimforge/rapier3d-compat';
6
- import './global-change-2JvMaz44.js';
7
-
8
- declare class InputManager {
9
- private inputMap;
10
- private currentInputs;
11
- private previousInputs;
12
- constructor(config?: GameInputConfig);
13
- /**
14
- * Reconfigure keyboard and mouse providers at runtime without affecting gamepad providers.
15
- * Disposes existing keyboard/mouse providers and creates new ones from the given config.
16
- */
17
- configure(config: GameInputConfig): void;
18
- addInputProvider(playerNumber: InputPlayerNumber, provider: InputProvider): void;
19
- getInputs(delta: number): Inputs;
20
- private buildPlayerEntries;
21
- private mergeInputs;
22
- }
23
-
24
- /**
25
- * This class is an alternative to {@link Clock} with a different API design and behavior.
26
- * The goal is to avoid the conceptual flaws that became apparent in `Clock` over time.
27
- *
28
- * - `Timer` has an `update()` method that updates its internal state. That makes it possible to
29
- * call `getDelta()` and `getElapsed()` multiple times per simulation step without getting different values.
30
- * - The class can make use of the Page Visibility API to avoid large time delta values when the app
31
- * is inactive (e.g. tab switched or browser hidden).
32
- *
33
- * ```js
34
- * const timer = new Timer();
35
- * timer.connect( document ); // use Page Visibility API
36
- * ```
37
- *
38
- * @three_import import { Timer } from 'three/addons/misc/Timer.js';
39
- */
40
- declare class Timer {
41
- protected _previousTime: number;
42
- protected _currentTime: number;
43
- protected _startTime: number;
44
- protected _delta: number;
45
- protected _elapsed: number;
46
- protected _timescale: number;
47
- protected _document: Document | null;
48
- protected _pageVisibilityHandler: (() => void) | null;
49
- /**
50
- * Constructs a new timer.
51
- */
52
- constructor();
53
- /**
54
- * Connect the timer to the given document.Calling this method is not mandatory to
55
- * use the timer but enables the usage of the Page Visibility API to avoid large time
56
- * delta values.
57
- *
58
- * @param {Document} document - The document.
59
- */
60
- connect(document: Document): void;
61
- /**
62
- * Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
63
- */
64
- disconnect(): void;
65
- /**
66
- * Returns the time delta in seconds.
67
- *
68
- * @return {number} The time delta in second.
69
- */
70
- getDelta(): number;
71
- /**
72
- * Returns the elapsed time in seconds.
73
- *
74
- * @return {number} The elapsed time in second.
75
- */
76
- getElapsed(): number;
77
- /**
78
- * Returns the timescale.
79
- *
80
- * @return {number} The timescale.
81
- */
82
- getTimescale(): number;
83
- /**
84
- * Sets the given timescale which scale the time delta computation
85
- * in `update()`.
86
- *
87
- * @param {number} timescale - The timescale to set.
88
- * @return {Timer} A reference to this timer.
89
- */
90
- setTimescale(timescale: number): Timer;
91
- /**
92
- * Resets the time computation for the current simulation step.
93
- *
94
- * @return {Timer} A reference to this timer.
95
- */
96
- reset(): Timer;
97
- /**
98
- * Can be used to free all internal resources. Usually called when
99
- * the timer instance isn't required anymore.
100
- */
101
- dispose(): void;
102
- /**
103
- * Updates the internal state of the timer. This method should be called
104
- * once per simulation step and before you perform queries against the timer
105
- * (e.g. via `getDelta()`).
106
- *
107
- * @param {number} timestamp - The current time in milliseconds. Can be obtained
108
- * from the `requestAnimationFrame` callback argument. If not provided, the current
109
- * time will be determined with `performance.now`.
110
- * @return {Timer} A reference to this timer.
111
- */
112
- update(timestamp?: number): Timer;
113
- }
114
-
115
- declare const AspectRatio: {
116
- readonly FourByThree: number;
117
- readonly SixteenByNine: number;
118
- readonly NineBySixteen: number;
119
- readonly TwentyOneByNine: number;
120
- readonly OneByOne: number;
121
- };
122
- type AspectRatioValue = (typeof AspectRatio)[keyof typeof AspectRatio] | number;
123
- /**
124
- * AspectRatioDelegate manages sizing a canvas to fit within a container
125
- * while preserving a target aspect ratio. It notifies a consumer via
126
- * onResize when the final width/height are applied so renderers/cameras
127
- * can update their viewports.
128
- */
129
- declare class AspectRatioDelegate {
130
- container: HTMLElement;
131
- canvas: HTMLCanvasElement;
132
- aspectRatio: number;
133
- onResize?: (width: number, height: number) => void;
134
- private handleResizeBound;
135
- private resizeObserver;
136
- constructor(params: {
137
- container: HTMLElement;
138
- canvas: HTMLCanvasElement;
139
- aspectRatio: AspectRatioValue;
140
- onResize?: (width: number, height: number) => void;
141
- });
142
- /** Attach window resize listener and apply once. */
143
- attach(): void;
144
- /** Detach window resize listener. */
145
- detach(): void;
146
- /** Compute the largest size that fits container while preserving aspect. */
147
- measure(): {
148
- width: number;
149
- height: number;
150
- };
151
- /** Apply measured size to canvas and notify. */
152
- apply(): void;
153
- }
154
-
155
- interface ViewportSize {
156
- width: number;
157
- height: number;
158
- }
159
-
160
- type RetroResolution = {
161
- key: string;
162
- width: number;
163
- height: number;
164
- notes?: string;
165
- };
166
- type RetroPreset = {
167
- displayAspect: number;
168
- resolutions: RetroResolution[];
169
- };
170
- /**
171
- * Retro, console, and device display presets.
172
- * displayAspect represents the intended display aspect (letterboxing target),
173
- * not necessarily the raw pixel aspect of internal buffers.
174
- */
175
- declare const RetroPresets: Record<string, RetroPreset>;
176
- type RetroPresetKey = keyof typeof RetroPresets;
177
- declare function getDisplayAspect(preset: RetroPresetKey): number;
178
- declare function getPresetResolution(preset: RetroPresetKey, key?: string): RetroResolution | undefined;
179
- declare function parseResolution(text: string): {
180
- width: number;
181
- height: number;
182
- } | null;
183
-
184
- type ResolutionInput = string | {
185
- width: number;
186
- height: number;
187
- };
188
- type DeviceProfile = 'auto' | 'desktop' | 'mobile';
189
- interface ResolveGameConfigRuntime {
190
- deviceProfile?: DeviceProfile;
191
- viewportSize?: ViewportSize;
192
- }
193
- type GameDeviceConfig = Partial<{
194
- /** numeric value or key in AspectRatio */
195
- aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
196
- /** console/display preset to derive aspect ratio */
197
- preset: RetroPresetKey;
198
- /** lock internal render buffer for this device profile */
199
- resolution: ResolutionInput;
200
- }>;
201
- type GameConfigLike = Partial<{
202
- id: string;
203
- globals: Record<string, any>;
204
- stages: StageInterface[];
205
- debug: boolean;
206
- time: number;
207
- input: GameInputConfig;
208
- /** numeric value or key in AspectRatio */
209
- aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
210
- /** console/display preset to derive aspect ratio */
211
- preset: RetroPresetKey;
212
- /** lock internal render buffer to this desktop/default resolution */
213
- resolution: ResolutionInput;
214
- /** mobile-specific aspect/preset/resolution overrides */
215
- mobile: GameDeviceConfig;
216
- fullscreen: boolean;
217
- /** CSS background value for document body */
218
- bodyBackground: string;
219
- /** existing container by reference */
220
- container: HTMLElement;
221
- /** create/find container by id */
222
- containerId: string;
223
- /** optional canvas if caller wants to manage it */
224
- canvas: HTMLCanvasElement;
225
- }>;
226
- declare class GameConfig {
227
- id: string;
228
- globals: Record<string, any>;
229
- stages: StageInterface[];
230
- debug: boolean;
231
- time: number;
232
- input: GameInputConfig | undefined;
233
- aspectRatio: number;
234
- internalResolution: {
235
- width: number;
236
- height: number;
237
- } | undefined;
238
- fullscreen: boolean;
239
- bodyBackground: string | undefined;
240
- container: HTMLElement;
241
- containerId?: string | undefined;
242
- canvas?: HTMLCanvasElement | undefined;
243
- constructor(id: string, globals: Record<string, any>, stages: StageInterface[], debug: boolean, time: number, input: GameInputConfig | undefined, aspectRatio: number, internalResolution: {
244
- width: number;
245
- height: number;
246
- } | undefined, fullscreen: boolean, bodyBackground: string | undefined, container: HTMLElement, containerId?: string | undefined, canvas?: HTMLCanvasElement | undefined);
247
- }
248
- /**
249
- * Factory for authoring configuration objects in user code.
250
- * Returns a plain object that can be passed to `game(...)`.
251
- */
252
- declare function gameConfig(config: GameConfigLike): GameConfigLike;
253
-
254
- interface GameCanvasOptions {
255
- id: string;
256
- container?: HTMLElement;
257
- containerId?: string;
258
- canvas?: HTMLCanvasElement;
259
- bodyBackground?: string;
260
- fullscreen?: boolean;
261
- aspectRatio: AspectRatioValue | number;
262
- }
263
- /**
264
- * GameCanvas is a DOM delegate that owns:
265
- * - container lookup/creation and styling (including fullscreen centering)
266
- * - body background application
267
- * - canvas mounting into container
268
- * - aspect ratio sizing via AspectRatioDelegate
269
- */
270
- declare class GameCanvas {
271
- id: string;
272
- container: HTMLElement;
273
- canvas: HTMLCanvasElement;
274
- bodyBackground?: string;
275
- fullscreen: boolean;
276
- aspectRatio: number;
277
- private ratioDelegate;
278
- constructor(options: GameCanvasOptions);
279
- applyBodyBackground(): void;
280
- mountCanvas(): void;
281
- mountRenderer(rendererDom: HTMLCanvasElement, onResize: (width: number, height: number) => void): void;
282
- centerIfFullscreen(): void;
283
- attachAspectRatio(onResize: (width: number, height: number) => void): void;
284
- setAspectRatio(aspectRatio: number): void;
285
- reapplyLayout(): void;
286
- destroy(): void;
287
- private ensureContainer;
288
- }
289
-
290
- /**
291
- * Game-level loading event that includes stage context.
292
- */
293
- interface GameLoadingEvent {
294
- type: 'start' | 'progress' | 'complete';
295
- stageName?: string;
296
- stageIndex?: number;
297
- message: string;
298
- progress: number;
299
- current?: number;
300
- total?: number;
301
- }
302
-
303
- type ZylemGameOptions<TGlobals extends BaseGlobals> = ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals> & Partial<GameConfig>;
304
- declare class ZylemGame<TGlobals extends BaseGlobals> {
305
- id: string;
306
- initialGlobals: TGlobals;
307
- customSetup: ((params: SetupContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
308
- customUpdate: ((params: UpdateContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
309
- customDestroy: ((params: DestroyContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
310
- stages: Stage[];
311
- stageMap: Map<string, Stage>;
312
- currentStageId: string;
313
- previousTimeStamp: number;
314
- totalTime: number;
315
- timer: Timer;
316
- inputManager: InputManager;
317
- wrapperRef: Game<TGlobals>;
318
- globalInputConfig: GameInputConfig | undefined;
319
- defaultCamera: ZylemCamera | null;
320
- /** Shared renderer manager for all stages */
321
- rendererManager: RendererManager | null;
322
- container: HTMLElement | null;
323
- canvas: HTMLCanvasElement | null;
324
- aspectRatioDelegate: AspectRatioDelegate | null;
325
- resolvedConfig: GameConfig | null;
326
- gameCanvas: GameCanvas | null;
327
- private animationFrameId;
328
- private isDisposed;
329
- private debugDelegate;
330
- private loadingDelegate;
331
- private rendererObserver;
332
- private eventBusUnsubscribes;
333
- private readonly gameUpdateParams;
334
- private readonly stageSetupParams;
335
- private readonly stageUpdateParams;
336
- private readonly frameCallback;
337
- private readonly sourceOptions;
338
- private displayRuntime;
339
- static FRAME_LIMIT: number;
340
- static FRAME_DURATION: number;
341
- static MAX_DELTA_SECONDS: number;
342
- constructor(options: ZylemGameOptions<TGlobals>, wrapperRef: Game<TGlobals>, displayRuntime?: ResolveGameConfigRuntime);
343
- setDisplayRuntime(runtime: ResolveGameConfigRuntime): void;
344
- loadGameCanvas(config: GameConfig): void;
345
- loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
346
- loadStage(stage: Stage, stageIndex?: number): Promise<void>;
347
- /**
348
- * Merges game-level global input config with the stage's per-stage overrides
349
- * and reconfigures the InputManager.
350
- */
351
- applyInputConfig(stage: Stage): void;
352
- /**
353
- * Update the game-level global input config and re-apply to the current stage.
354
- */
355
- setGlobalInputConfig(config: GameInputConfig): void;
356
- unloadCurrentStage(): void;
357
- setGlobals(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>): void;
358
- params(): UpdateContext<ZylemGame<TGlobals>, TGlobals>;
359
- start(): void;
360
- /**
361
- * Execute a single frame update.
362
- * This method can be called directly for testing or from the game loop.
363
- * @param deltaTime Optional delta time in seconds. If not provided, uses timer delta.
364
- */
365
- step(deltaTime?: number): void;
366
- loop(timestamp: number): void;
367
- dispose(): void;
368
- outOfLoop(): void;
369
- getStage(id: string): Stage | undefined;
370
- currentStage(): Stage | undefined;
371
- /**
372
- * Subscribe to loading events from the game.
373
- * Events include stage context (stageName, stageIndex).
374
- * @param callback Invoked for each loading event
375
- * @returns Unsubscribe function
376
- */
377
- onLoading(callback: (event: GameLoadingEvent) => void): () => void;
378
- /**
379
- * Build the stage config payload for the current stage.
380
- */
381
- private buildStageConfigPayload;
382
- /**
383
- * Build the entities payload for the current stage.
384
- */
385
- private buildEntitiesPayload;
386
- /**
387
- * Emit a state:dispatch event to the zylemEventBus.
388
- * Called after stage load and on global state changes.
389
- */
390
- private emitStateDispatch;
391
- /**
392
- * Inspect a stage's options to determine the renderer type.
393
- * Looks for CameraWrapper instances in the stage options and uses
394
- * the first camera's rendererType. Falls back to 'webgl'.
395
- */
396
- private resolveRendererType;
397
- /**
398
- * Subscribe to the game event bus for stage loading and state events.
399
- * Emits events to zylemEventBus for cross-package communication.
400
- */
401
- private subscribeToEventBus;
402
- }
403
-
404
- type GameOptions<TGlobals extends BaseGlobals> = Array<ZylemGameConfig<Stage, any, TGlobals> | GameConfigLike | Stage | GameEntityLifeCycle | BaseNode>;
405
-
406
- declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
407
- private wrappedGame;
408
- options: GameOptions<TGlobals>;
409
- private setupCallbacks;
410
- private updateCallbacks;
411
- private destroyCallbacks;
412
- private pendingLoadingCallbacks;
413
- private globalChangeCallbacks;
414
- private globalChangesCallbacks;
415
- private activeGlobalSubscriptions;
416
- private eventDelegate;
417
- /** Pending global input config set before the game starts. */
418
- private pendingInputConfig;
419
- private displayRuntime;
420
- refErrorMessage: string;
421
- constructor(options: GameOptions<TGlobals>);
422
- onSetup(...callbacks: Array<SetupFunction<ZylemGame<TGlobals>, TGlobals>>): this;
423
- onUpdate(...callbacks: Array<UpdateFunction<ZylemGame<TGlobals>, TGlobals>>): this;
424
- onDestroy(...callbacks: Array<DestroyFunction<ZylemGame<TGlobals>, TGlobals>>): this;
425
- /**
426
- * Set composable input configuration as global defaults for the entire game.
427
- * Multiple configs are deep-merged (later configs win on key conflicts).
428
- * Per-stage overrides (via stage.setInputConfiguration) are merged on top.
429
- * Can be called before or after start().
430
- * @example game.setInputConfiguration(useArrowsForAxes('p1'), useWASDForDirections('p2'));
431
- */
432
- setInputConfiguration(...configs: GameInputConfig[]): this;
433
- start(): Promise<this>;
434
- setDisplayRuntime(runtime: Partial<ResolveGameConfigRuntime>): this;
435
- setDeviceProfile(profile: DeviceProfile): this;
436
- setViewportSize(width: number, height: number): this;
437
- private load;
438
- private setOverrides;
439
- /**
440
- * Subscribe to changes on a global value. Subscriptions are registered
441
- * when the game starts and cleaned up when disposed.
442
- * The callback receives the value and the current stage.
443
- * @example game.onGlobalChange('score', (val, stage) => console.log(val));
444
- */
445
- onGlobalChange<T = unknown>(path: string, callback: (value: T, stage: Stage | null) => void): this;
446
- /**
447
- * Subscribe to changes on multiple global paths. Subscriptions are registered
448
- * when the game starts and cleaned up when disposed.
449
- * The callback receives the values and the current stage.
450
- * @example game.onGlobalChanges(['score', 'lives'], ([score, lives], stage) => console.log(score, lives));
451
- */
452
- onGlobalChanges<T extends unknown[] = unknown[]>(paths: string[], callback: (values: T, stage: Stage | null) => void): this;
453
- /**
454
- * Register all stored global change callbacks.
455
- * Called internally during start().
456
- */
457
- private registerGlobalSubscriptions;
458
- /**
459
- * Get the current stage wrapper.
460
- */
461
- getCurrentStage(): Stage | null;
462
- pause(): Promise<void>;
463
- resume(): Promise<void>;
464
- /**
465
- * Execute a single frame update.
466
- * Useful for testing or manual frame stepping.
467
- * @param deltaTime Optional delta time in seconds (defaults to 1/60)
468
- */
469
- step(deltaTime?: number): void;
470
- reset(): Promise<void>;
471
- previousStage(): void;
472
- loadStageFromId(stageId: string): Promise<void>;
473
- nextStage(): void;
474
- goToStage(): Promise<void>;
475
- end(): Promise<void>;
476
- dispose(): void;
477
- /**
478
- * Dispatch an event from the game.
479
- * Events are emitted both locally and to the global event bus.
480
- */
481
- dispatch<K extends keyof GameEvents>(event: K, payload: GameEvents[K]): void;
482
- /**
483
- * Listen for events on this game instance.
484
- * @returns Unsubscribe function
485
- */
486
- listen<K extends keyof GameEvents>(event: K, handler: (payload: GameEvents[K]) => void): () => void;
487
- /**
488
- * Subscribe to loading events from the game.
489
- * Events include stage context (stageName, stageIndex).
490
- * @param callback Invoked for each loading event
491
- * @returns Unsubscribe function
492
- */
493
- onLoading(callback: (event: GameLoadingEvent) => void): () => void;
494
- }
495
- /**
496
- * create a new game
497
- * @param options GameOptions - Array of IGameOptions, Stage, GameEntity, or BaseNode objects
498
- * @param options.id Game name string (when using IGameOptions)
499
- * @param options.globals Game globals object (when using IGameOptions)
500
- * @param options.stages Array of stage objects (when using IGameOptions)
501
- * @returns Game
502
- */
503
- declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
504
-
505
- /**
506
- * A Vessel is an empty container entity that holds child entities.
507
- * It has no geometry, physics, or rendering of its own, but propagates
508
- * lifecycle events to its children and provides a logical grouping mechanism.
509
- *
510
- * Child entities added to a Vessel will be individually spawned into the
511
- * stage's physics world and render scene when the Vessel is spawned.
512
- */
513
- declare class Vessel extends BaseNode<{}, Vessel> {
514
- static type: symbol;
515
- protected _setup(_params: SetupContext<this>): void;
516
- protected _loaded(_params: LoadedContext<this>): Promise<void>;
517
- protected _update(_params: UpdateContext<this>): void;
518
- protected _destroy(_params: DestroyContext<this>): void;
519
- protected _cleanup(_params: CleanupContext<this>): void;
520
- create(): this;
521
- clone(): this;
522
- /**
523
- * Add one or more child entities to this vessel.
524
- * Overrides parent to support multiple arguments.
525
- * @returns this for chaining
526
- */
527
- add(...nodes: NodeInterface[]): this;
528
- }
529
- /**
530
- * Create a vessel containing the given child entities.
531
- * @param args Child BaseNode entities to add
532
- * @returns A new Vessel with the children added
533
- */
534
- declare function vessel(...args: Array<BaseNode>): Vessel;
535
-
536
- /**
537
- * @deprecated This type is deprecated.
538
- */
539
- type Vect3 = Vector3 | Vector3$1;
540
-
541
- export { AspectRatio as A, type DeviceProfile as D, Game as G, type ResolutionInput as R, type Vect3 as V, type GameConfigLike as a, type GameDeviceConfig as b, createGame as c, type ResolveGameConfigRuntime as d, type AspectRatioValue as e, getDisplayAspect as f, gameConfig as g, getPresetResolution as h, type RetroPreset as i, type RetroPresetKey as j, type RetroResolution as k, parseResolution as p, vessel as v };