@zylem/game-lib 0.6.3 → 0.7.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 (97) hide show
  1. package/README.md +3 -1
  2. package/dist/actions.d.ts +255 -8
  3. package/dist/actions.js +1 -772
  4. package/dist/audio.d.ts +13 -0
  5. package/dist/audio.js +1 -0
  6. package/dist/base-node-life-cycle-CnJ-7zX-.d.ts +143 -0
  7. package/dist/behavior.d.ts +3 -0
  8. package/dist/behavior.js +1 -0
  9. package/dist/chunk-4QLJUQSJ.js +1 -0
  10. package/dist/chunk-73VZQZUL.js +1 -0
  11. package/dist/chunk-A34ZG3L4.js +1 -0
  12. package/dist/chunk-CDPY4VOQ.js +1 -0
  13. package/dist/chunk-DR6XXZE7.js +19 -0
  14. package/dist/chunk-FM5TBEPO.js +1 -0
  15. package/dist/chunk-G2IIMSUH.js +1 -0
  16. package/dist/chunk-MSC2BEO5.js +1 -0
  17. package/dist/chunk-NIH5CONO.js +1 -0
  18. package/dist/chunk-ONWXGBWB.js +1 -0
  19. package/dist/chunk-QEDQDR27.js +1 -0
  20. package/dist/chunk-QXVH6POE.js +1 -0
  21. package/dist/chunk-RXDTAWI2.js +29 -0
  22. package/dist/chunk-WKHW2QO2.js +1 -0
  23. package/dist/chunk-XRP4JJXL.js +1 -0
  24. package/dist/chunk-YHEWKN7N.js +1 -0
  25. package/dist/chunk-YHKXQ2ZN.js +1 -0
  26. package/dist/core.d.ts +206 -13
  27. package/dist/core.js +24 -9160
  28. package/dist/debug.d.ts +24 -0
  29. package/dist/debug.js +1 -0
  30. package/dist/default-controls-BGc61yYl.d.ts +111 -0
  31. package/dist/entity-DNkYKfdp.d.ts +1043 -0
  32. package/dist/entity-type-map-C94h2TDW.d.ts +781 -0
  33. package/dist/entity.d.ts +265 -0
  34. package/dist/entity.js +1 -0
  35. package/dist/events.d.ts +172 -0
  36. package/dist/events.js +1 -0
  37. package/dist/game-Cuj5gy7U.d.ts +1590 -0
  38. package/dist/game-default-PZLLHYL7.js +1 -0
  39. package/dist/game-interfaces-tfpM5NBk.d.ts +90 -0
  40. package/dist/globals.d.ts +104 -0
  41. package/dist/globals.js +1 -0
  42. package/dist/graphics.d.ts +83 -0
  43. package/dist/graphics.js +1 -0
  44. package/dist/input-ui.d.ts +34 -0
  45. package/dist/input-ui.js +1 -0
  46. package/dist/input.d.ts +72 -0
  47. package/dist/input.js +1 -0
  48. package/dist/material-Wz83vTTp.d.ts +151 -0
  49. package/dist/runtime.d.ts +433 -0
  50. package/dist/runtime.js +1 -0
  51. package/dist/web-components.d.ts +67 -0
  52. package/dist/web-components.js +9 -0
  53. package/dist/world-C9zdyl5d.d.ts +103 -0
  54. package/dist/zylem-stage-runtime-Cs-UDEVU.d.ts +777 -0
  55. package/package.json +54 -41
  56. package/dist/actions.js.map +0 -1
  57. package/dist/behavior/platformer-3d.d.ts +0 -296
  58. package/dist/behavior/platformer-3d.js +0 -518
  59. package/dist/behavior/platformer-3d.js.map +0 -1
  60. package/dist/behavior/ricochet-2d.d.ts +0 -274
  61. package/dist/behavior/ricochet-2d.js +0 -394
  62. package/dist/behavior/ricochet-2d.js.map +0 -1
  63. package/dist/behavior/screen-wrap.d.ts +0 -86
  64. package/dist/behavior/screen-wrap.js +0 -195
  65. package/dist/behavior/screen-wrap.js.map +0 -1
  66. package/dist/behavior/thruster.d.ts +0 -10
  67. package/dist/behavior/thruster.js +0 -234
  68. package/dist/behavior/thruster.js.map +0 -1
  69. package/dist/behavior/world-boundary-2d.d.ts +0 -141
  70. package/dist/behavior/world-boundary-2d.js +0 -181
  71. package/dist/behavior/world-boundary-2d.js.map +0 -1
  72. package/dist/behavior-descriptor-BWNWmIjv.d.ts +0 -142
  73. package/dist/blueprints-BWGz8fII.d.ts +0 -26
  74. package/dist/camera-B5e4c78l.d.ts +0 -468
  75. package/dist/camera.d.ts +0 -6
  76. package/dist/camera.js +0 -1406
  77. package/dist/camera.js.map +0 -1
  78. package/dist/composition-DrzFrbqI.d.ts +0 -218
  79. package/dist/core-DAkskq6Y.d.ts +0 -498
  80. package/dist/core.js.map +0 -1
  81. package/dist/entities-DC9ce_vx.d.ts +0 -416
  82. package/dist/entities.d.ts +0 -9
  83. package/dist/entities.js +0 -4069
  84. package/dist/entities.js.map +0 -1
  85. package/dist/entity-BpbZqg19.d.ts +0 -1100
  86. package/dist/entity-Bq_eNEDI.d.ts +0 -28
  87. package/dist/entity-types-DAu8sGJH.d.ts +0 -26
  88. package/dist/global-change-Dc8uCKi2.d.ts +0 -25
  89. package/dist/main.d.ts +0 -654
  90. package/dist/main.js +0 -13355
  91. package/dist/main.js.map +0 -1
  92. package/dist/stage-types-BFsm3qsZ.d.ts +0 -567
  93. package/dist/stage.d.ts +0 -51
  94. package/dist/stage.js +0 -5738
  95. package/dist/stage.js.map +0 -1
  96. package/dist/thruster-DhRaJnoL.d.ts +0 -172
  97. package/dist/world-Be5m1XC1.d.ts +0 -31
@@ -1,567 +0,0 @@
1
- import { J as UpdateFunction, S as SetupFunction, Z as ZylemShader, I as GameEntity, K as DestroyFunction, L as SetupContext, U as UpdateContext, M as DestroyContext, N as BaseNode, O as LoadingEvent, P as GameEntityOptions, Q as StageEvents } from './entity-BpbZqg19.js';
2
- import * as bitecs from 'bitecs';
3
- import { defineSystem, IWorld } from 'bitecs';
4
- import { Scene, Color, Object3D, Vector3, BufferGeometry, Material } from 'three';
5
- import { Z as ZylemWorld } from './world-Be5m1XC1.js';
6
- import { E as Entity, L as LifecycleFunction, S as StageEntity } from './entity-Bq_eNEDI.js';
7
- import { Z as ZylemCamera, C as CameraManager, R as RendererManager, a as CameraDebugDelegate, b as CameraDebugState, c as CameraWrapper } from './camera-B5e4c78l.js';
8
- import { G as GameEntityInterface, B as BaseEntityInterface } from './entity-types-DAu8sGJH.js';
9
- import RAPIER__default from '@dimforge/rapier3d-compat';
10
- import { S as SPRITE_TYPE, Z as ZylemSprite, a as SPHERE_TYPE, b as ZylemSphere, R as RECT_TYPE, c as ZylemRect, T as TEXT_TYPE, d as ZylemText, B as BOX_TYPE, e as ZylemBox, P as PLANE_TYPE, f as ZylemPlane, g as ZONE_TYPE, h as ZylemZone, A as ACTOR_TYPE, i as ZylemActor, C as CONE_TYPE, j as ZylemCone, k as PYRAMID_TYPE, l as ZylemPyramid, m as CYLINDER_TYPE, n as ZylemCylinder, o as PILL_TYPE, p as ZylemPill } from './entities-DC9ce_vx.js';
11
- import { B as BehaviorSystem, a as BehaviorSystemFactory } from './behavior-descriptor-BWNWmIjv.js';
12
-
13
- type BasicTypes = number | string | boolean;
14
- type BaseGlobals = Record<string, BasicTypes>;
15
- type KeyboardMapping = Record<string, string[]>;
16
- type MouseMapping = Record<string, string[]>;
17
- interface GameInputPlayerConfig {
18
- key?: KeyboardMapping;
19
- mouse?: MouseMapping;
20
- includeDefaults?: boolean;
21
- }
22
- interface GameInputConfig {
23
- p1?: GameInputPlayerConfig;
24
- p2?: GameInputPlayerConfig;
25
- p3?: GameInputPlayerConfig;
26
- p4?: GameInputPlayerConfig;
27
- p5?: GameInputPlayerConfig;
28
- p6?: GameInputPlayerConfig;
29
- p7?: GameInputPlayerConfig;
30
- p8?: GameInputPlayerConfig;
31
- }
32
- interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends BaseGlobals> {
33
- id: string;
34
- globals?: TGlobals;
35
- stages?: StageInterface[];
36
- update?: UpdateFunction<GameInterface>;
37
- debug?: boolean;
38
- time?: number;
39
- input?: GameInputConfig;
40
- }
41
-
42
- interface SceneState {
43
- backgroundColor: Color | string;
44
- backgroundImage: string | null;
45
- backgroundShader?: ZylemShader | null;
46
- }
47
- declare class ZylemScene implements Entity<ZylemScene> {
48
- type: string;
49
- _setup?: SetupFunction<ZylemScene>;
50
- scene: Scene;
51
- /** @deprecated Use cameraManager instead */
52
- zylemCamera: ZylemCamera;
53
- cameraManager: CameraManager | null;
54
- containerElement: HTMLElement | null;
55
- update: LifecycleFunction<ZylemScene>;
56
- _collision?: ((entity: any, other: any, globals?: any) => void) | undefined;
57
- _destroy?: ((globals?: any) => void) | undefined;
58
- name?: string | undefined;
59
- tag?: Set<string> | undefined;
60
- private skyboxMaterial;
61
- constructor(id: string, camera: ZylemCamera, state: SceneState);
62
- /**
63
- * Create a large inverted box with the shader for skybox effect
64
- * Supports both GLSL (ShaderMaterial) and TSL (MeshBasicNodeMaterial) shaders
65
- */
66
- private setupBackgroundShader;
67
- setup(): void;
68
- destroy(): void;
69
- /**
70
- * Setup camera with the scene.
71
- * Supports both legacy single camera and CameraManager modes.
72
- */
73
- setupCamera(scene: Scene, camera: ZylemCamera, rendererManager?: RendererManager): void;
74
- /**
75
- * Setup with a CameraManager (multi-camera support).
76
- */
77
- setupCameraManager(scene: Scene, cameraManager: CameraManager, rendererManager: RendererManager): Promise<void>;
78
- /**
79
- * Add a camera (rig or direct) to the scene graph.
80
- */
81
- private addCameraToScene;
82
- /**
83
- * Setup scene lighting
84
- */
85
- setupLighting(scene: Scene): void;
86
- /**
87
- * Update renderer size - delegates to camera manager or camera
88
- */
89
- updateRenderer(width: number, height: number): void;
90
- /**
91
- * Add object to scene
92
- */
93
- add(object: Object3D, position?: Vector3): void;
94
- /**
95
- * Add game entity to scene
96
- */
97
- addEntity(entity: GameEntity<any>): void;
98
- /**
99
- * Add an entity's group or mesh to the scene (for late-loaded models).
100
- * Uses entity's current body position if physics is active.
101
- */
102
- addEntityGroup(entity: GameEntity<any>): void;
103
- /**
104
- * Add debug helpers to scene
105
- */
106
- debugScene(): void;
107
- /**
108
- * Update skybox shader uniforms (only applies to GLSL ShaderMaterial)
109
- * TSL shaders use the time node which auto-updates
110
- */
111
- updateSkybox(delta: number): void;
112
- }
113
-
114
- /**
115
- * Configuration for batch key generation
116
- */
117
- interface BatchKeyConfig {
118
- geometryType: string;
119
- dimensions: Record<string, number>;
120
- materialPath?: string | null;
121
- shaderType?: 'standard' | 'custom';
122
- colorHex?: number;
123
- }
124
- /**
125
- * Manages instanced mesh batching for entities
126
- */
127
- declare class InstanceManager {
128
- private batches;
129
- private entityToBatch;
130
- private scene;
131
- /** Default initial capacity for new batches */
132
- static DEFAULT_CAPACITY: number;
133
- /** Factor to grow batch when full */
134
- static GROWTH_FACTOR: number;
135
- /**
136
- * Set the scene to add instanced meshes to
137
- */
138
- setScene(scene: Object3D): void;
139
- /**
140
- * Generate a batch key from configuration
141
- */
142
- static generateBatchKey(config: BatchKeyConfig): string;
143
- /**
144
- * Register an entity with the instance manager
145
- * @returns The instance index, or -1 if registration failed
146
- */
147
- register(entity: GameEntity<any>, geometry: BufferGeometry, material: Material, batchKey: string): number;
148
- /**
149
- * Unregister an entity from the instance manager
150
- */
151
- unregister(entity: GameEntity<any>): void;
152
- /**
153
- * Mark an entity's transform as dirty (needs syncing)
154
- */
155
- markDirty(entity: GameEntity<any>): void;
156
- /**
157
- * Update all dirty instance transforms
158
- * Call this once per frame
159
- */
160
- /**
161
- * Update all active instance transforms
162
- * Call this once per frame
163
- */
164
- update(): void;
165
- private updateInstanceMatrix;
166
- /**
167
- * Get batch info for an entity
168
- */
169
- getBatchInfo(entity: GameEntity<any>): {
170
- batchKey: string;
171
- instanceId: number;
172
- } | null;
173
- /**
174
- * Get statistics about current batching
175
- */
176
- getStats(): {
177
- batchCount: number;
178
- totalInstances: number;
179
- batches: {
180
- key: string;
181
- count: number;
182
- capacity: number;
183
- }[];
184
- };
185
- /**
186
- * Dispose all batches and release resources
187
- */
188
- dispose(): void;
189
- /**
190
- * Create a new batch group
191
- */
192
- private createBatch;
193
- /**
194
- * Grow a batch's capacity
195
- */
196
- private growBatch;
197
- }
198
-
199
- /**
200
- * Provides BaseNode-like lifecycle without ECS/children. Consumers implement
201
- * the protected hooks and may assign public setup/update/destroy callbacks.
202
- */
203
- declare abstract class LifeCycleBase<TSelf> {
204
- update: UpdateFunction<TSelf>;
205
- setup: SetupFunction<TSelf>;
206
- destroy: DestroyFunction<TSelf>;
207
- protected abstract _setup(context: SetupContext<TSelf>): void;
208
- protected abstract _update(context: UpdateContext<TSelf>): void;
209
- protected abstract _destroy(context: DestroyContext<TSelf>): void;
210
- nodeSetup(context: SetupContext<TSelf>): void;
211
- nodeUpdate(context: UpdateContext<TSelf>): void;
212
- nodeDestroy(context: DestroyContext<TSelf>): void;
213
- }
214
-
215
- type StageSystem = {
216
- _childrenMap: Map<number, StageEntity & {
217
- body: RAPIER__default.RigidBody;
218
- }>;
219
- };
220
- type TransformSystemResult = {
221
- system: ReturnType<typeof defineSystem>;
222
- destroy: (world: IWorld) => void;
223
- };
224
- declare function createTransformSystem(stage: StageSystem): TransformSystemResult;
225
-
226
- type AddEntityFactory = (params: {
227
- position: Vector3;
228
- normal?: Vector3;
229
- }) => Promise<any> | any;
230
- interface StageDebugDelegateOptions {
231
- maxRayDistance?: number;
232
- addEntityFactory?: AddEntityFactory | null;
233
- }
234
- declare class StageDebugDelegate {
235
- private stage;
236
- private options;
237
- private mouseNdc;
238
- private raycaster;
239
- private isMouseDown;
240
- private disposeFns;
241
- private debugCursor;
242
- private debugLines;
243
- constructor(stage: ZylemStage, options?: StageDebugDelegateOptions);
244
- private initDebugVisuals;
245
- private disposeDebugVisuals;
246
- update(): void;
247
- dispose(): void;
248
- private handleActionOnHit;
249
- private attachDomListeners;
250
- }
251
-
252
- /**
253
- * Debug delegate that bridges the stage's entity map and debug state to the camera.
254
- */
255
- declare class StageCameraDebugDelegate implements CameraDebugDelegate {
256
- private stage;
257
- constructor(stage: ZylemStage);
258
- subscribe(listener: (state: CameraDebugState) => void): () => void;
259
- resolveTarget(uuid: string): Object3D | null;
260
- private snapshot;
261
- }
262
-
263
- interface ZylemStageConfig {
264
- inputs: Record<string, string[]>;
265
- backgroundColor: Color | string;
266
- backgroundImage: string | null;
267
- backgroundShader: any | null;
268
- gravity: Vector3;
269
- variables: Record<string, any>;
270
- stageRef?: Stage;
271
- }
272
- type NodeLike$1 = {
273
- create: Function;
274
- };
275
- type StageEntityInput = NodeLike$1 | Promise<any> | (() => NodeLike$1 | Promise<any>);
276
- type StageOptionItem = Partial<ZylemStageConfig> | CameraWrapper | StageEntityInput;
277
- type StageOptions = [] | [Partial<ZylemStageConfig>, ...StageOptionItem[]];
278
- type StageState = ZylemStageConfig & {
279
- entities: GameEntityInterface[];
280
- };
281
- /**
282
- * ZylemStage orchestrates scene, physics world, entities, and lifecycle.
283
- *
284
- * Responsibilities:
285
- * - Manage stage configuration (background, inputs, gravity, variables)
286
- * - Initialize and own `ZylemScene` and `ZylemWorld`
287
- * - Spawn, track, and remove entities; emit entity-added events
288
- * - Drive per-frame updates and transform system
289
- */
290
- declare class ZylemStage extends LifeCycleBase<ZylemStage> {
291
- type: string;
292
- state: StageState;
293
- gravity: Vector3;
294
- world: ZylemWorld | null;
295
- scene: ZylemScene | null;
296
- instanceManager: InstanceManager | null;
297
- children: Array<BaseNode>;
298
- _childrenMap: Map<number, BaseNode>;
299
- _removalMap: Map<number, BaseNode>;
300
- private pendingEntities;
301
- private pendingPromises;
302
- private isLoaded;
303
- _debugMap: Map<string, BaseNode>;
304
- private entityAddedHandlers;
305
- ecs: bitecs.IWorld;
306
- testSystem: any;
307
- transformSystem: ReturnType<typeof createTransformSystem> | null;
308
- private behaviorSystems;
309
- private registeredSystemKeys;
310
- debugDelegate: StageDebugDelegate | null;
311
- cameraDebugDelegate: StageCameraDebugDelegate | null;
312
- private debugStateUnsubscribe;
313
- uuid: string;
314
- wrapperRef: Stage | null;
315
- camera?: CameraWrapper;
316
- cameras: CameraWrapper[];
317
- cameraRef?: ZylemCamera | null;
318
- /** Camera manager for multi-camera support */
319
- cameraManagerRef: CameraManager | null;
320
- /** Shared renderer manager (injected by the game) */
321
- rendererManager: RendererManager | null;
322
- private cameraDelegate;
323
- private loadingDelegate;
324
- private entityModelDelegate;
325
- /**
326
- * Create a new stage.
327
- * @param options Stage options: partial config, camera, and initial entities or factories
328
- */
329
- constructor(options?: StageOptions);
330
- private handleEntityImmediatelyOrQueue;
331
- private handlePromiseWithSpawnOnResolve;
332
- private saveState;
333
- private setState;
334
- /**
335
- * Load and initialize the stage's scene and world.
336
- * Uses generator pattern to yield control to event loop for real-time progress.
337
- * @param id DOM element id for the renderer container
338
- * @param camera Optional camera override
339
- */
340
- load(id: string, camera?: ZylemCamera | null, rendererManager?: RendererManager | null): Promise<void>;
341
- /**
342
- * Generator that yields between entity loads for real-time progress updates.
343
- */
344
- private entityLoadGenerator;
345
- /**
346
- * Runs the entity load generator, yielding to the event loop between loads.
347
- * This allows the browser to process events and update the UI in real-time.
348
- */
349
- private runEntityLoadGenerator;
350
- protected _setup(params: SetupContext<ZylemStage>): void;
351
- private updateDebugDelegate;
352
- protected _update(params: UpdateContext<ZylemStage>): void;
353
- outOfLoop(): void;
354
- /** Update debug overlays and helpers if enabled. */
355
- debugUpdate(): void;
356
- /** Cleanup owned resources when the stage is destroyed. */
357
- protected _destroy(params: DestroyContext<ZylemStage>): void;
358
- /**
359
- * Create, register, and add an entity to the scene/world.
360
- * Safe to call only after `load` when scene/world exist.
361
- */
362
- spawnEntity(child: BaseNode): Promise<void>;
363
- /**
364
- * Try to register an entity for instanced rendering.
365
- * Batching is enabled by default unless explicitly disabled with batched: false.
366
- */
367
- private tryRegisterInstance;
368
- buildEntityState(child: BaseNode): Partial<BaseEntityInterface>;
369
- /** Add the entity to internal maps and notify listeners. */
370
- addEntityToStage(entity: BaseNode): void;
371
- /**
372
- * Subscribe to entity-added events.
373
- * @param callback Invoked for each entity when added
374
- * @param options.replayExisting If true and stage already loaded, replays existing entities
375
- * @returns Unsubscribe function
376
- */
377
- onEntityAdded(callback: (entity: BaseNode) => void, options?: {
378
- replayExisting?: boolean;
379
- }): () => void;
380
- onLoading(callback: (event: LoadingEvent) => void): () => void;
381
- /**
382
- * Register an ECS behavior system to run each frame.
383
- * @param systemOrFactory A BehaviorSystem instance or factory function
384
- * @returns this for chaining
385
- */
386
- registerSystem(systemOrFactory: BehaviorSystem | BehaviorSystemFactory): this;
387
- /**
388
- * Remove an entity and its resources by its UUID.
389
- * @returns true if removed, false if not found or stage not ready
390
- */
391
- removeEntityByUuid(uuid: string): boolean;
392
- /** Get an entity by its name; returns null if not found. */
393
- getEntityByName(name: string): BaseNode<any, any> | null;
394
- logMissingEntities(): void;
395
- /**
396
- * Add a camera to this stage's camera manager.
397
- */
398
- addCamera(camera: ZylemCamera, name?: string): string | null;
399
- /**
400
- * Remove a camera from this stage's camera manager.
401
- */
402
- removeCamera(nameOrRef: string | ZylemCamera): boolean;
403
- /**
404
- * Set the active camera by name or reference.
405
- */
406
- setActiveCamera(nameOrRef: string | ZylemCamera): boolean;
407
- /**
408
- * Get a camera by name from the camera manager.
409
- */
410
- getCamera(name: string): ZylemCamera | null;
411
- /** Resize renderer viewport. */
412
- resize(width: number, height: number): void;
413
- /**
414
- * Enqueue items to be spawned. Items can be:
415
- * - BaseNode instances (immediate or deferred until load)
416
- * - Factory functions returning BaseNode or Promise<BaseNode>
417
- * - Promises resolving to BaseNode
418
- */
419
- enqueue(...items: StageEntityInput[]): void;
420
- }
421
-
422
- type ZylemDiskOptions = GameEntityOptions & {
423
- innerRadius?: number;
424
- outerRadius?: number;
425
- thetaSegments?: number;
426
- };
427
- declare const DISK_TYPE: unique symbol;
428
- declare class ZylemDisk extends GameEntity<ZylemDiskOptions> {
429
- static type: symbol;
430
- constructor(options?: ZylemDiskOptions);
431
- buildInfo(): Record<string, any>;
432
- }
433
- type DiskOptions = BaseNode | Partial<ZylemDiskOptions>;
434
- declare function createDisk(...args: Array<DiskOptions>): ZylemDisk;
435
-
436
- /**
437
- * Maps entity type symbols to their class types.
438
- * Used by getEntityByName to infer return types.
439
- */
440
- interface EntityTypeMap {
441
- [SPRITE_TYPE]: ZylemSprite;
442
- [SPHERE_TYPE]: ZylemSphere;
443
- [RECT_TYPE]: ZylemRect;
444
- [TEXT_TYPE]: ZylemText;
445
- [BOX_TYPE]: ZylemBox;
446
- [PLANE_TYPE]: ZylemPlane;
447
- [ZONE_TYPE]: ZylemZone;
448
- [ACTOR_TYPE]: ZylemActor;
449
- [DISK_TYPE]: ZylemDisk;
450
- [CONE_TYPE]: ZylemCone;
451
- [PYRAMID_TYPE]: ZylemPyramid;
452
- [CYLINDER_TYPE]: ZylemCylinder;
453
- [PILL_TYPE]: ZylemPill;
454
- }
455
-
456
- type NodeLike = {
457
- create: Function;
458
- };
459
- type AnyNode = NodeLike | Promise<NodeLike>;
460
- type EntityInput = AnyNode | (() => AnyNode) | (() => Promise<any>);
461
- declare class Stage {
462
- wrappedStage: ZylemStage | null;
463
- options: StageOptionItem[];
464
- private _pendingEntities;
465
- private setupCallbacks;
466
- private updateCallbacks;
467
- private destroyCallbacks;
468
- private pendingLoadingCallbacks;
469
- private eventDelegate;
470
- /** Per-stage input configuration overrides. Merged with game-level defaults on stage load. */
471
- inputConfig: GameInputConfig | null;
472
- /**
473
- * Callback set by the game to trigger input reconfiguration
474
- * when this stage's input config changes at runtime.
475
- * @internal
476
- */
477
- onInputConfigChanged: (() => void) | null;
478
- constructor(options: StageOptions);
479
- /**
480
- * Set composable input configuration for this stage.
481
- * Multiple configs are deep-merged (later configs win on key conflicts).
482
- * If this stage is currently active, the change takes effect immediately.
483
- * @example stage.setInputConfiguration(useArrowsForAxes('p1'), useWASDForDirections('p2'));
484
- */
485
- setInputConfiguration(...configs: GameInputConfig[]): this;
486
- load(id: string, camera?: ZylemCamera | CameraWrapper | null, rendererManager?: RendererManager | null): Promise<void>;
487
- private applyLifecycleCallbacks;
488
- addEntities(entities: BaseNode[]): Promise<void>;
489
- add(...inputs: Array<EntityInput>): void;
490
- private addToBlueprints;
491
- private addToStage;
492
- start(params: SetupContext<ZylemStage>): void;
493
- onUpdate(...callbacks: UpdateFunction<ZylemStage>[]): this;
494
- onSetup(...callbacks: SetupFunction<ZylemStage>[]): this;
495
- onDestroy(...callbacks: DestroyFunction<ZylemStage>[]): this;
496
- onLoading(callback: (event: LoadingEvent) => void): () => void;
497
- /**
498
- * Find an entity by name on the current stage.
499
- * @param name The name of the entity to find
500
- * @param type Optional type symbol for type inference (e.g., TEXT_TYPE, SPRITE_TYPE)
501
- * @returns The entity if found, or undefined
502
- * @example stage.getEntityByName('scoreText', TEXT_TYPE)
503
- */
504
- getEntityByName<T extends symbol | void = void>(name: string, type?: T): T extends keyof EntityTypeMap ? EntityTypeMap[T] | undefined : BaseNode | undefined;
505
- /**
506
- * Add a camera to this stage.
507
- * @param camera The ZylemCamera or CameraWrapper to add
508
- * @param name Optional name for lookup
509
- */
510
- addCamera(camera: ZylemCamera | CameraWrapper, name?: string): string | null;
511
- /**
512
- * Remove a camera from this stage by name or reference.
513
- */
514
- removeCamera(nameOrRef: string | ZylemCamera | CameraWrapper): boolean;
515
- /**
516
- * Set the active camera by name or reference.
517
- */
518
- setActiveCamera(nameOrRef: string | ZylemCamera | CameraWrapper): boolean;
519
- /**
520
- * Get a camera by name from the camera manager.
521
- */
522
- getCamera(name: string): ZylemCamera | null;
523
- /**
524
- * Dispatch an event from the stage.
525
- * Events are emitted both locally and to the global event bus.
526
- */
527
- dispatch<K extends keyof StageEvents>(event: K, payload: StageEvents[K]): void;
528
- /**
529
- * Listen for events on this stage instance.
530
- * @returns Unsubscribe function
531
- */
532
- listen<K extends keyof StageEvents>(event: K, handler: (payload: StageEvents[K]) => void): () => void;
533
- /**
534
- * Clean up stage resources including event subscriptions.
535
- */
536
- dispose(): void;
537
- }
538
- /**
539
- * Create a stage with optional camera
540
- */
541
- declare function createStage(...options: StageOptions): Stage;
542
-
543
- /**
544
- * Stage state interface - minimal to prevent circular dependencies
545
- */
546
- interface StageStateInterface {
547
- backgroundColor: Color;
548
- backgroundImage: string | null;
549
- inputs: {
550
- p1: string[];
551
- p2: string[];
552
- };
553
- variables: Record<string, any>;
554
- gravity: Vector3;
555
- entities: Partial<BaseEntityInterface>[];
556
- stageRef?: any;
557
- }
558
- /**
559
- * Minimal stage interface to break circular dependencies
560
- */
561
- interface StageInterface {
562
- uuid: string;
563
- children: any[];
564
- state: StageStateInterface;
565
- }
566
-
567
- export { type BaseGlobals as B, type GameInputConfig as G, type StageStateInterface as S, type ZylemGameConfig as Z, type StageOptions as a, Stage as b, createStage as c, createDisk as d, type StageInterface as e };
package/dist/stage.d.ts DELETED
@@ -1,51 +0,0 @@
1
- import { S as StageStateInterface } from './stage-types-BFsm3qsZ.js';
2
- export { a as StageOptions, c as createStage } from './stage-types-BFsm3qsZ.js';
3
- export { S as StageBlueprint, e as entitySpawner } from './blueprints-BWGz8fII.js';
4
- import './entity-BpbZqg19.js';
5
- import 'three';
6
- import '@dimforge/rapier3d-compat';
7
- import 'bitecs';
8
- import 'mitt';
9
- import './behavior-descriptor-BWNWmIjv.js';
10
- import './world-Be5m1XC1.js';
11
- import './entity-Bq_eNEDI.js';
12
- import './camera-B5e4c78l.js';
13
- import 'three/webgpu';
14
- import 'three/examples/jsm/postprocessing/EffectComposer.js';
15
- import './entity-types-DAu8sGJH.js';
16
- import './entities-DC9ce_vx.js';
17
- import '@sinclair/typebox';
18
-
19
- /**
20
- * Event name for stage state changes.
21
- * Dispatched when the stage state proxy is updated.
22
- */
23
- declare const STAGE_STATE_CHANGE = "STAGE_STATE_CHANGE";
24
- /**
25
- * Event detail payload for STAGE_STATE_CHANGE events.
26
- */
27
- interface StageStateChangeEvent {
28
- entities: StageStateInterface['entities'];
29
- variables: StageStateInterface['variables'];
30
- }
31
- /**
32
- * Initialize the stage state dispatcher.
33
- * Subscribes to stageState changes and dispatches STAGE_STATE_CHANGE events to the window.
34
- *
35
- * @returns Unsubscribe function to stop dispatching events.
36
- *
37
- * @example
38
- * // Start dispatching stage state changes
39
- * const unsubscribe = initStageStateDispatcher();
40
- *
41
- * // Later, stop dispatching
42
- * unsubscribe();
43
- */
44
- declare function initStageStateDispatcher(): () => void;
45
- /**
46
- * Manually dispatch the current stage state.
47
- * Useful for initial sync when a listener is added.
48
- */
49
- declare function dispatchStageState(): void;
50
-
51
- export { STAGE_STATE_CHANGE, type StageStateChangeEvent, dispatchStageState, initStageStateDispatcher };