ecspresso 0.7.1 → 0.9.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.
@@ -1,6 +1,6 @@
1
1
  import Bundle from "./bundle";
2
2
  import ECSpresso from "./ecspresso";
3
- import type { FilteredEntity, System } from "./types";
3
+ import type { FilteredEntity, System, SystemPhase } from "./types";
4
4
  /**
5
5
  * Builder class for creating type-safe ECS Systems with proper query inference
6
6
  */
@@ -14,6 +14,7 @@ export declare class SystemBuilder<ComponentTypes extends Record<string, any> =
14
14
  private initializeFunction?;
15
15
  private eventHandlers?;
16
16
  private _priority;
17
+ private _phase;
17
18
  private _isRegistered;
18
19
  private _groups;
19
20
  private _inScreens?;
@@ -52,6 +53,14 @@ export declare class SystemBuilder<ComponentTypes extends Record<string, any> =
52
53
  * @returns This SystemBuilder instance for method chaining
53
54
  */
54
55
  setPriority(priority: number): this;
56
+ /**
57
+ * Set the execution phase for this system.
58
+ * Systems are grouped by phase and executed in order:
59
+ * preUpdate -> fixedUpdate -> update -> postUpdate -> render
60
+ * @param phase The phase to assign this system to (default: 'update')
61
+ * @returns This SystemBuilder instance for method chaining
62
+ */
63
+ inPhase(phase: SystemPhase): this;
55
64
  /**
56
65
  * Add this system to a group. Systems can belong to multiple groups.
57
66
  * When any group a system belongs to is disabled, the system will be skipped.
@@ -89,6 +98,7 @@ export declare class SystemBuilder<ComponentTypes extends Record<string, any> =
89
98
  addQuery<QueryName extends string, WithComponents extends keyof ComponentTypes, WithoutComponents extends keyof ComponentTypes = never, NewQueries extends Queries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>> = Queries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>>>(name: QueryName, definition: {
90
99
  with: ReadonlyArray<WithComponents>;
91
100
  without?: ReadonlyArray<WithoutComponents>;
101
+ changed?: ReadonlyArray<WithComponents>;
92
102
  }): this extends SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, Queries> ? SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, NewQueries> : this extends SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Queries> ? SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, NewQueries> : SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, NewQueries>;
93
103
  /**
94
104
  * Set the system's process function that runs each update
@@ -148,6 +158,7 @@ export declare function registerSystemWithEcspresso<ComponentTypes extends Recor
148
158
  type QueryDefinition<ComponentTypes, WithComponents extends keyof ComponentTypes = any, WithoutComponents extends keyof ComponentTypes = any> = {
149
159
  with: ReadonlyArray<WithComponents>;
150
160
  without?: ReadonlyArray<WithoutComponents>;
161
+ changed?: ReadonlyArray<WithComponents>;
151
162
  };
152
163
  type QueryResults<ComponentTypes, Queries extends Record<string, QueryDefinition<ComponentTypes>>> = {
153
164
  [QueryName in keyof Queries]: QueryName extends string ? FilteredEntity<ComponentTypes, Queries[QueryName] extends QueryDefinition<ComponentTypes, infer W, any> ? W : never, Queries[QueryName] extends QueryDefinition<ComponentTypes, any, infer WO> ? WO : never>[] : never;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import ECSpresso from "./ecspresso";
2
+ /**
3
+ * Execution phase for systems. Systems are grouped by phase and executed
4
+ * in this fixed order: preUpdate -> fixedUpdate -> update -> postUpdate -> render.
5
+ * Within each phase, systems are sorted by priority (higher first).
6
+ */
7
+ export type SystemPhase = 'preUpdate' | 'fixedUpdate' | 'update' | 'postUpdate' | 'render';
2
8
  export interface Entity<ComponentTypes> {
3
9
  id: number;
4
10
  components: Partial<ComponentTypes>;
@@ -54,6 +60,7 @@ export interface FilteredEntity<ComponentTypes, WithComponents extends keyof Com
54
60
  export interface QueryConfig<ComponentTypes, WithComponents extends keyof ComponentTypes, WithoutComponents extends keyof ComponentTypes> {
55
61
  with: ReadonlyArray<WithComponents>;
56
62
  without?: ReadonlyArray<WithoutComponents>;
63
+ changed?: ReadonlyArray<WithComponents>;
57
64
  }
58
65
  /**
59
66
  * Utility type to derive the entity type that would result from a query definition.
@@ -79,6 +86,7 @@ export interface QueryConfig<ComponentTypes, WithComponents extends keyof Compon
79
86
  export type QueryResultEntity<ComponentTypes extends Record<string, any>, QueryDef extends {
80
87
  with: ReadonlyArray<keyof ComponentTypes>;
81
88
  without?: ReadonlyArray<keyof ComponentTypes>;
89
+ changed?: ReadonlyArray<keyof ComponentTypes>;
82
90
  }> = FilteredEntity<ComponentTypes, QueryDef['with'][number], QueryDef['without'] extends ReadonlyArray<any> ? QueryDef['without'][number] : never>;
83
91
  /**
84
92
  * Simplified query definition type for creating reusable queries
@@ -86,6 +94,7 @@ export type QueryResultEntity<ComponentTypes extends Record<string, any>, QueryD
86
94
  export type QueryDefinition<ComponentTypes extends Record<string, any>, WithComponents extends keyof ComponentTypes = keyof ComponentTypes, WithoutComponents extends keyof ComponentTypes = keyof ComponentTypes> = {
87
95
  with: ReadonlyArray<WithComponents>;
88
96
  without?: ReadonlyArray<WithoutComponents>;
97
+ changed?: ReadonlyArray<WithComponents>;
89
98
  };
90
99
  /**
91
100
  * Helper function to create a query definition with proper type inference.
@@ -117,6 +126,7 @@ export type QueryDefinition<ComponentTypes extends Record<string, any>, WithComp
117
126
  export declare function createQueryDefinition<ComponentTypes extends Record<string, any>, const QueryDef extends {
118
127
  with: ReadonlyArray<keyof ComponentTypes>;
119
128
  without?: ReadonlyArray<keyof ComponentTypes>;
129
+ changed?: ReadonlyArray<keyof ComponentTypes>;
120
130
  }>(queryDef: QueryDef): QueryDef;
121
131
  export interface System<ComponentTypes extends Record<string, any> = {}, WithComponents extends keyof ComponentTypes = never, WithoutComponents extends keyof ComponentTypes = never, EventTypes extends Record<string, any> = {}, ResourceTypes extends Record<string, any> = {}, AssetTypes extends Record<string, unknown> = {}, ScreenStates extends Record<string, any> = {}> {
122
132
  label: string;
@@ -125,6 +135,12 @@ export interface System<ComponentTypes extends Record<string, any> = {}, WithCom
125
135
  * When systems have the same priority, they execute in registration order
126
136
  */
127
137
  priority?: number;
138
+ /**
139
+ * Execution phase for this system (default: 'update')
140
+ * Systems are grouped by phase and executed in order:
141
+ * preUpdate -> fixedUpdate -> update -> postUpdate -> render
142
+ */
143
+ phase?: SystemPhase;
128
144
  /**
129
145
  * Groups this system belongs to. If any group is disabled, the system will be skipped.
130
146
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecspresso",
3
- "version": "0.7.1",
3
+ "version": "0.9.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,9 +11,9 @@
11
11
  "import": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts"
13
13
  },
14
- "./bundles/renderers/pixi": {
15
- "import": "./dist/bundles/renderers/pixi.js",
16
- "types": "./dist/bundles/renderers/pixi.d.ts"
14
+ "./bundles/renderers/renderer2D": {
15
+ "import": "./dist/bundles/renderers/renderer2D.js",
16
+ "types": "./dist/bundles/renderers/renderer2D.d.ts"
17
17
  },
18
18
  "./bundles/utils/timers": {
19
19
  "import": "./dist/bundles/utils/timers.js",
@@ -58,7 +58,7 @@
58
58
  "scripts": {
59
59
  "build:clean": "rm -rf dist",
60
60
  "build:ts": "bun tsc -p tsconfig.build.json",
61
- "build:js": "bun build --target=browser --sourcemap=linked --minify --external=pixi.js --outdir=dist src/index.ts src/bundles/renderers/pixi.ts src/bundles/utils/timers.ts",
61
+ "build:js": "bun build --target=browser --sourcemap=linked --minify --external=pixi.js --outdir=dist src/index.ts src/bundles/renderers/renderer2D.ts src/bundles/utils/timers.ts",
62
62
  "build": "bun build:clean && bun build:ts && bun build:js",
63
63
  "check:types": "bun tsc --noEmit --skipLibCheck",
64
64
  "check": "bun run check:types && bun test",
@@ -1,4 +0,0 @@
1
- var O=Object.create;var{getPrototypeOf:x,defineProperty:C,getOwnPropertyNames:T}=Object;var I=Object.prototype.hasOwnProperty;var f=(H,J,K)=>{K=H!=null?O(x(H)):{};let _=J||!H||!H.__esModule?C(K,"default",{value:H,enumerable:!0}):K;for(let U of T(H))if(!I.call(_,U))C(_,U,{get:()=>H[U],enumerable:!0});return _};var b=((H)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(H,{get:(J,K)=>(typeof require<"u"?require:J)[K]}):H)(function(H){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+H+'" is not supported')});class L{_label;_ecspresso;_bundle;queries={};processFunction;detachFunction;initializeFunction;eventHandlers;_priority=0;_isRegistered=!1;_groups=[];_inScreens;_excludeScreens;_requiredAssets;constructor(H,J=null,K=null){this._label=H;this._ecspresso=J;this._bundle=K}get label(){return this._label}get bundle(){return this._bundle}get ecspresso(){return this._ecspresso}_autoRegister(){if(this._isRegistered||!this._ecspresso)return;let H=this._buildSystemObject();k(H,this._ecspresso),this._isRegistered=!0}_buildSystemObject(){return this._createSystemObject()}_createSystemObject(){let H={label:this._label,entityQueries:this.queries,priority:this._priority};if(this.processFunction)H.process=this.processFunction;if(this.detachFunction)H.onDetach=this.detachFunction;if(this.initializeFunction)H.onInitialize=this.initializeFunction;if(this.eventHandlers)H.eventHandlers=this.eventHandlers;if(this._groups.length>0)H.groups=[...this._groups];if(this._inScreens)H.inScreens=this._inScreens;if(this._excludeScreens)H.excludeScreens=this._excludeScreens;if(this._requiredAssets)H.requiredAssets=this._requiredAssets;return H}setPriority(H){return this._priority=H,this}inGroup(H){if(!this._groups.includes(H))this._groups.push(H);return this}inScreens(H){return this._inScreens=[...H],this}excludeScreens(H){return this._excludeScreens=[...H],this}requiresAssets(H){return this._requiredAssets=[...H],this}addQuery(H,J){let K=this;return K.queries={...this.queries,[H]:J},K}setProcess(H){return this.processFunction=H,this}registerAndContinue(){if(!this._ecspresso)throw Error(`Cannot register system '${this._label}': SystemBuilder is not attached to an ECSpresso instance. Use Bundle.addSystem() or ECSpresso.addSystem() instead.`);return this._autoRegister(),this._ecspresso}and(){if(this._ecspresso)return this._autoRegister(),this._ecspresso;if(this._bundle)return this._bundle;throw Error(`Cannot use and() on system '${this._label}': not attached to ECSpresso or Bundle.`)}setOnDetach(H){return this.detachFunction=H,this}setOnInitialize(H){return this.initializeFunction=H,this}setEventHandlers(H){return this.eventHandlers=H,this}build(H){let J=this._createSystemObject();if(this._ecspresso)k(J,this._ecspresso);if(H)k(J,H);return this}}function k(H,J){J._registerSystem(H)}function r(H,J){return new L(H,J)}function B(H,J){return new L(H,null,J)}function u(){return`bundle_${Date.now().toString(36)}_${Math.random().toString(36).substring(2,9)}`}class E{_systems=[];_resources=new Map;_assets=new Map;_assetGroups=new Map;_screens=new Map;_id;constructor(H){this._id=H||u()}get id(){return this._id}set id(H){this._id=H}addSystem(H){if(typeof H==="string"){let J=B(H,this);return this._systems.push(J),J}else return this._systems.push(H),H}addResource(H,J){return this._resources.set(H,J),this}addAsset(H,J,K){return this._assets.set(H,{loader:J,eager:K?.eager??!0,group:K?.group}),this}addAssetGroup(H,J){let K=new Map;for(let[_,U]of Object.entries(J))K.set(_,U),this._assets.set(_,{loader:U,eager:!1,group:H});return this._assetGroups.set(H,K),this}addScreen(H,J){return this._screens.set(H,J),this}getAssets(){return new Map(this._assets)}getScreens(){return new Map(this._screens)}_setResource(H,J){this._resources.set(H,J)}_setAsset(H,J){this._assets.set(H,J)}_setScreen(H,J){this._screens.set(H,J)}getSystems(){return this._systems.map((H)=>H.build())}registerSystemsWithEcspresso(H){for(let J of this._systems)J.build(H)}getResources(){return new Map(this._resources)}getResource(H){return this._resources.get(H)}getSystemBuilders(){return[...this._systems]}hasResource(H){return this._resources.has(H)}}function j(H,...J){if(J.length===0)return new E(H);let K=new E(H);for(let _ of J){for(let U of _.getSystemBuilders())K.addSystem(U);for(let[U,M]of _.getResources().entries())K._setResource(U,M);for(let[U,M]of _.getAssets().entries())K._setAsset(U,M);for(let[U,M]of _.getScreens().entries())K._setScreen(U,M)}return K}function m(H,J){return{localTransform:{x:H,y:J,rotation:0,scaleX:1,scaleY:1}}}function y(H,J){return{worldTransform:{x:H,y:J,rotation:0,scaleX:1,scaleY:1}}}function d(H,J,K){let _=K?.scale??K?.scaleX??1,U=K?.scale??K?.scaleY??1,M=K?.rotation??0,Y={x:H,y:J,rotation:M,scaleX:_,scaleY:U};return{localTransform:{...Y},worldTransform:{...Y}}}function w(H){let{systemGroup:J="transform",priority:K=500}=H??{},_=new E("transform");return _.addSystem("transform-propagation").setPriority(K).inGroup(J).setProcess((U,M,Y)=>{l(Y)}).and(),_}function l(H){H.forEachInHierarchy((K,_)=>{let U=H.entityManager.getComponent(K,"localTransform"),M=H.entityManager.getComponent(K,"worldTransform");if(!U||!M)return;if(_===null)V(U,M);else{let Y=H.entityManager.getComponent(_,"worldTransform");if(Y)c(Y,U,M);else V(U,M)}});let J=H.getEntitiesWithQuery(["localTransform","worldTransform"]);for(let K of J)if(H.getParent(K.id)===null&&H.getChildren(K.id).length===0){let{localTransform:U,worldTransform:M}=K.components;V(U,M)}}function V(H,J){J.x=H.x,J.y=H.y,J.rotation=H.rotation,J.scaleX=H.scaleX,J.scaleY=H.scaleY}function c(H,J,K){let _=J.x*H.scaleX,U=J.y*H.scaleY,M=Math.cos(H.rotation),Y=Math.sin(H.rotation),X=_*M-U*Y,N=_*Y+U*M;K.x=H.x+X,K.y=H.y+N,K.rotation=H.rotation+J.rotation,K.scaleX=H.scaleX*J.scaleX,K.scaleY=H.scaleY*J.scaleY}async function p(H){let{Application:J}=await import("pixi.js"),K=new J;return await K.init(H),K}var KH={x:0,y:0,rotation:0,scaleX:1,scaleY:1},QH={x:0,y:0,rotation:0,scaleX:1,scaleY:1};function P(H,J){let K=J?.scale,_=typeof K==="number"?K:K?.x??1,U=typeof K==="number"?K:K?.y??1;return{x:H?.x??0,y:H?.y??0,rotation:J?.rotation??0,scaleX:_,scaleY:U}}function v(H,J){let K=J?.scale,_=typeof K==="number"?K:K?.x??1,U=typeof K==="number"?K:K?.y??1;return{x:H?.x??0,y:H?.y??0,rotation:J?.rotation??0,scaleX:_,scaleY:U}}function S(H){return{visible:H?.visible??!0,alpha:H?.alpha}}function UH(H,J,K){return{pixiSprite:{sprite:H,anchor:K?.anchor},localTransform:P(J,K),worldTransform:v(J,K),pixiVisible:S(K)}}function ZH(H,J,K){return{pixiGraphics:{graphics:H},localTransform:P(J,K),worldTransform:v(J,K),pixiVisible:S(K)}}function _H(H,J,K){return{pixiContainer:{container:H},localTransform:P(J,K),worldTransform:v(J,K),pixiVisible:S(K)}}function $H(H){let{rootContainer:J,systemGroup:K="pixi-renderer",renderSyncPriority:_=500,transform:U}=H,M=new E("pixi-renderer-internal");if("init"in H&&H.init!==void 0){let{init:Z,container:Q}=H;M.addResource("pixiApp",async()=>{let $=await p(Z);if(Q){let F=typeof Q==="string"?document.querySelector(Q):Q;if(F)F.appendChild($.canvas);else if(typeof Q==="string")console.warn(`PixiJS bundle: container selector "${Q}" not found`)}return $}),M.addResource("pixiRootContainer",{dependsOn:["pixiApp"],factory:($)=>J??$.getResource("pixiApp").stage})}else{let Z=H.app;M.addResource("pixiApp",Z),M.addResource("pixiRootContainer",J??Z.stage)}let X=new Map;function N(Z,Q){let $=X.get(Z);if($)return $;let F=Q.entityManager.getComponent(Z,"pixiSprite");if(F)return X.set(Z,F.sprite),F.sprite;let R=Q.entityManager.getComponent(Z,"pixiGraphics");if(R)return X.set(Z,R.graphics),R.graphics;let D=Q.entityManager.getComponent(Z,"pixiContainer");if(D)return X.set(Z,D.container),D.container;return null}function A(Z,Q,$){let F=$.getResource("pixiRootContainer"),R=$.getParent(Z),z=(R!==null?N(R,$):null)??F;if(Q.parent!==z)z.addChild(Q)}function G(Z){let Q=X.get(Z);if(Q)Q.removeFromParent(),X.delete(Z)}function g(Z,Q){let $=X.get(Z);if(!$)return;let F=Q.getResource("pixiRootContainer"),R=Q.getParent(Z),z=(R!==null?N(R,Q):null)??F;if($.parent!==z)$.removeFromParent(),z.addChild($)}M.addSystem("pixi-render-sync").setPriority(_).inGroup(K).addQuery("sprites",{with:["pixiSprite","worldTransform"]}).addQuery("graphics",{with:["pixiGraphics","worldTransform"]}).addQuery("containers",{with:["pixiContainer","worldTransform"]}).setProcess((Z,Q,$)=>{for(let F of Z.sprites){let{pixiSprite:R,worldTransform:D}=F.components,{sprite:z,anchor:q}=R;if(z.position.set(D.x,D.y),z.rotation=D.rotation,z.scale.set(D.scaleX,D.scaleY),q)z.anchor.set(q.x,q.y);let W=$.entityManager.getComponent(F.id,"pixiVisible");if(W){if(z.visible=W.visible,W.alpha!==void 0)z.alpha=W.alpha}}for(let F of Z.graphics){let{pixiGraphics:R,worldTransform:D}=F.components,{graphics:z}=R;z.position.set(D.x,D.y),z.rotation=D.rotation,z.scale.set(D.scaleX,D.scaleY);let q=$.entityManager.getComponent(F.id,"pixiVisible");if(q){if(z.visible=q.visible,q.alpha!==void 0)z.alpha=q.alpha}}for(let F of Z.containers){let{pixiContainer:R,worldTransform:D}=F.components,{container:z}=R;z.position.set(D.x,D.y),z.rotation=D.rotation,z.scale.set(D.scaleX,D.scaleY);let q=$.entityManager.getComponent(F.id,"pixiVisible");if(q){if(z.visible=q.visible,q.alpha!==void 0)z.alpha=q.alpha}}}).and(),M.addSystem("pixi-scene-graph-manager").setPriority(9999).inGroup(K).setOnInitialize((Z)=>{Z.addReactiveQuery("pixi-sprites",{with:["pixiSprite"],onEnter:(Q)=>{let $=Q.components.pixiSprite.sprite;X.set(Q.id,$),A(Q.id,$,Z)},onExit:(Q)=>{G(Q)}}),Z.addReactiveQuery("pixi-graphics",{with:["pixiGraphics"],onEnter:(Q)=>{let $=Q.components.pixiGraphics.graphics;X.set(Q.id,$),A(Q.id,$,Z)},onExit:(Q)=>{G(Q)}}),Z.addReactiveQuery("pixi-containers",{with:["pixiContainer"],onEnter:(Q)=>{let $=Q.components.pixiContainer.container;X.set(Q.id,$),A(Q.id,$,Z)},onExit:(Q)=>{G(Q)}}),Z.on("hierarchyChanged",({entityId:Q})=>{g(Q,Z)})}).and();let h=w(U);return j("pixi-renderer",h,M)}export{y as createWorldTransform,d as createTransform,UH as createSpriteComponents,$H as createPixiBundle,m as createLocalTransform,ZH as createGraphicsComponents,_H as createContainerComponents,QH as DEFAULT_WORLD_TRANSFORM,KH as DEFAULT_LOCAL_TRANSFORM};
2
-
3
- //# debugId=FD4EB6F5A72B658164756E2164756E21
4
- //# sourceMappingURL=pixi.js.map
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/system-builder.ts", "../src/bundle.ts", "../src/bundles/utils/transform.ts", "../src/bundles/renderers/pixi.ts"],
4
- "sourcesContent": [
5
- "import Bundle from \"./bundle\";\nimport ECSpresso from \"./ecspresso\";\nimport type { FilteredEntity, System } from \"./types\";\n\n/**\n * Builder class for creating type-safe ECS Systems with proper query inference\n */\nexport class SystemBuilder<\n\tComponentTypes extends Record<string, any> = Record<string, any>,\n\tEventTypes extends Record<string, any> = Record<string, any>,\n\tResourceTypes extends Record<string, any> = Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>> = {},\n> {\n\tprivate queries: Queries = {} as Queries;\n\tprivate processFunction?: ProcessFunction<ComponentTypes, EventTypes, ResourceTypes, Queries>;\n\tprivate detachFunction?: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>;\n\tprivate initializeFunction?: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>;\n\tprivate eventHandlers?: {\n\t\t[EventName in keyof EventTypes]?: {\n\t\t\thandler(\n\t\t\t\tdata: EventTypes[EventName],\n\t\t\t\tecs: ECSpresso<\n\t\t\t\t\tComponentTypes,\n\t\t\t\t\tEventTypes,\n\t\t\t\t\tResourceTypes\n\t\t\t\t>,\n\t\t\t): void;\n\t\t};\n\t};\n\tprivate _priority = 0; // Default priority is 0\n\tprivate _isRegistered = false; // Track if system has been auto-registered\n\tprivate _groups: string[] = [];\n\tprivate _inScreens?: string[];\n\tprivate _excludeScreens?: string[];\n\tprivate _requiredAssets?: string[];\n\n\tconstructor(\n\t\tprivate _label: string,\n\t\tprivate _ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes> | null = null,\n\t\tprivate _bundle: Bundle<ComponentTypes, EventTypes, ResourceTypes> | null = null,\n\t) {}\n\n\tget label() {\n\t\treturn this._label;\n\t}\n\n\t/**\n\t * Returns the associated bundle if one was provided in the constructor\n\t */\n\tget bundle() {\n\t\treturn this._bundle;\n\t}\n\n\t/**\n\t * Returns the associated ECSpresso instance if one was provided in the constructor\n\t */\n\tget ecspresso() {\n\t\treturn this._ecspresso;\n\t}\n\n\t/**\n\t * Auto-register this system with its ECSpresso instance if not already registered\n\t * @private\n\t */\n\tprivate _autoRegister(): void {\n\t\tif (this._isRegistered || !this._ecspresso) return;\n\t\t\n\t\tconst system = this._buildSystemObject();\n\t\tregisterSystemWithEcspresso(system, this._ecspresso);\n\t\tthis._isRegistered = true;\n\t}\n\n\t/**\n\t * Create the system object without registering it\n\t * @private\n\t */\n\tprivate _buildSystemObject(): System<ComponentTypes, any, any, EventTypes, ResourceTypes> {\n\t\treturn this._createSystemObject();\n\t}\n\n\t/**\n\t * Create a system object with all configured properties\n\t * @private\n\t */\n\tprivate _createSystemObject(): System<ComponentTypes, any, any, EventTypes, ResourceTypes> {\n\t\tconst system: System<ComponentTypes, any, any, EventTypes, ResourceTypes> = {\n\t\t\tlabel: this._label,\n\t\t\tentityQueries: this.queries,\n\t\t\tpriority: this._priority,\n\t\t};\n\n\t\tif (this.processFunction) {\n\t\t\tsystem.process = this.processFunction;\n\t\t}\n\n\t\tif (this.detachFunction) {\n\t\t\tsystem.onDetach = this.detachFunction;\n\t\t}\n\n\t\tif (this.initializeFunction) {\n\t\t\tsystem.onInitialize = this.initializeFunction;\n\t\t}\n\n\t\tif (this.eventHandlers) {\n\t\t\tsystem.eventHandlers = this.eventHandlers;\n\t\t}\n\n\t\tif (this._groups.length > 0) {\n\t\t\tsystem.groups = [...this._groups];\n\t\t}\n\n\t\tif (this._inScreens) {\n\t\t\tsystem.inScreens = this._inScreens;\n\t\t}\n\n\t\tif (this._excludeScreens) {\n\t\t\tsystem.excludeScreens = this._excludeScreens;\n\t\t}\n\n\t\tif (this._requiredAssets) {\n\t\t\tsystem.requiredAssets = this._requiredAssets;\n\t\t}\n\n\t\treturn system;\n\t}\n\n\t// TODO: Should this be a setter?\n\t/**\n\t * Set the priority of this system. Systems with higher priority values\n\t * execute before those with lower values. Systems with the same priority\n\t * execute in the order they were registered.\n\t * @param priority The priority value (default: 0)\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetPriority(priority: number): this {\n\t\tthis._priority = priority;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add this system to a group. Systems can belong to multiple groups.\n\t * When any group a system belongs to is disabled, the system will be skipped.\n\t * @param groupName The name of the group to add the system to\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tinGroup(groupName: string): this {\n\t\tif (!this._groups.includes(groupName)) {\n\t\t\tthis._groups.push(groupName);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Restrict this system to only run in specified screens.\n\t * System will be skipped during update() when the current screen\n\t * is not in this list.\n\t * @param screens Array of screen names where this system should run\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tinScreens(screens: ReadonlyArray<string>): this {\n\t\tthis._inScreens = [...screens];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Exclude this system from running in specified screens.\n\t * System will be skipped during update() when the current screen\n\t * is in this list.\n\t * @param screens Array of screen names where this system should NOT run\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\texcludeScreens(screens: ReadonlyArray<string>): this {\n\t\tthis._excludeScreens = [...screens];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Require specific assets to be loaded for this system to run.\n\t * System will be skipped during update() if any required asset\n\t * is not loaded.\n\t * @param assets Array of asset keys that must be loaded\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\trequiresAssets(assets: ReadonlyArray<string>): this {\n\t\tthis._requiredAssets = [...assets];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a query definition to the system\n\t */\n\taddQuery<\n\t\tQueryName extends string,\n\t\tWithComponents extends keyof ComponentTypes,\n\t\tWithoutComponents extends keyof ComponentTypes = never,\n\t\tNewQueries extends Queries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>> =\n\t\t\tQueries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>>\n\t>(\n\t\tname: QueryName,\n\t\tdefinition: {\n\t\t\twith: ReadonlyArray<WithComponents>;\n\t\t\twithout?: ReadonlyArray<WithoutComponents>;\n\t\t}\n\t): this extends SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, Queries>\n\t\t? SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, NewQueries>\n\t\t: this extends SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Queries>\n\t\t\t? SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, NewQueries>\n\t\t\t: SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, NewQueries> {\n\t\t// Cast is needed because TypeScript can't preserve the type information\n\t\t// when modifying an object property\n\t\tconst newBuilder = this as any;\n\t\tnewBuilder.queries = {\n\t\t\t...this.queries,\n\t\t\t[name]: definition,\n\t\t};\n\t\treturn newBuilder;\n\t}\n\n\t/**\n\t * Set the system's process function that runs each update\n\t * @param process Function to process entities matching the system's queries each update\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetProcess(\n\t\tprocess: ProcessFunction<ComponentTypes, EventTypes, ResourceTypes, Queries>\n\t): this {\n\t\tthis.processFunction = process;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Register this system with its ECSpresso instance and return the ECSpresso for chaining\n\t * This enables seamless method chaining: .registerAndContinue().addSystem(...)\n\t * @returns ECSpresso instance if attached to one, otherwise throws an error\n\t */\n\tregisterAndContinue(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes> {\n\t\tif (!this._ecspresso) {\n\t\t\tthrow new Error(`Cannot register system '${this._label}': SystemBuilder is not attached to an ECSpresso instance. Use Bundle.addSystem() or ECSpresso.addSystem() instead.`);\n\t\t}\n\t\t\n\t\tthis._autoRegister();\n\t\treturn this._ecspresso;\n\t}\n\n\t/**\n\t * Complete this system and return the parent container for seamless chaining\n\t * - For ECSpresso-attached builders: registers the system and returns ECSpresso\n\t * - For Bundle-attached builders: returns the Bundle\n\t * This method is typed via the specialized interfaces (SystemBuilderWithEcspresso, SystemBuilderWithBundle)\n\t */\n\tand(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes> | Bundle<ComponentTypes, EventTypes, ResourceTypes> {\n\t\tif (this._ecspresso) {\n\t\t\tthis._autoRegister();\n\t\t\treturn this._ecspresso;\n\t\t}\n\n\t\tif (this._bundle) {\n\t\t\treturn this._bundle;\n\t\t}\n\n\t\tthrow new Error(`Cannot use and() on system '${this._label}': not attached to ECSpresso or Bundle.`);\n\t}\n\n\t/**\n\t * Set the onDetach lifecycle hook\n\t * Called when the system is removed from the ECS\n\t * @param onDetach Function to run when this system is detached from the ECS\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetOnDetach(\n\t\tonDetach: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>\n\t): this {\n\t\tthis.detachFunction = onDetach;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the onInitialize lifecycle hook\n\t * Called when the system is initialized via ECSpresso.initialize() method\n\t * @param onInitialize Function to run when this system is initialized\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetOnInitialize(\n\t\tonInitialize: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>\n\t): this {\n\t\tthis.initializeFunction = onInitialize;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set event handlers for the system\n\t * These handlers will be automatically subscribed when the system is attached\n\t * @param handlers Object mapping event names to handler functions\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetEventHandlers(\n\t\thandlers: {\n\t\t\t[EventName in keyof EventTypes]?: {\n\t\t\t\thandler(\n\t\t\t\t\tdata: EventTypes[EventName],\n\t\t\t\t\tecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>\n\t\t\t\t): void;\n\t\t\t};\n\t\t}\n\t): this {\n\t\tthis.eventHandlers = handlers;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Build the final system object\n\t */\n\tbuild(ecspresso?: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) {\n\t\tconst system = this._createSystemObject();\n\n\t\tif (this._ecspresso) {\n\t\t\tregisterSystemWithEcspresso(system, this._ecspresso);\n\t\t}\n\n\t\tif(ecspresso) {\n\t\t\tregisterSystemWithEcspresso(system, ecspresso);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n\n/**\n * Helper function to register a system with an ECSpresso instance\n * This handles attaching the system and setting up event handlers\n * @internal Used by SystemBuilder and Bundle\n */\nexport function registerSystemWithEcspresso<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>\n>(\n\tsystem: System<ComponentTypes, any, any, EventTypes, ResourceTypes>,\n\tecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>\n) {\n\t// Use the new internal registration method instead of direct property access\n\tecspresso._registerSystem(system);\n}\n\n// Helper type definitions\ntype QueryDefinition<\n\tComponentTypes,\n\tWithComponents extends keyof ComponentTypes = any,\n\tWithoutComponents extends keyof ComponentTypes = any,\n> = {\n\twith: ReadonlyArray<WithComponents>;\n\twithout?: ReadonlyArray<WithoutComponents>;\n};\n\ntype QueryResults<\n\tComponentTypes,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>>,\n> = {\n\t[QueryName in keyof Queries]: QueryName extends string\n\t\t? FilteredEntity<\n\t\t\tComponentTypes,\n\t\t\tQueries[QueryName] extends QueryDefinition<ComponentTypes, infer W, any> ? W : never,\n\t\t\tQueries[QueryName] extends QueryDefinition<ComponentTypes, any, infer WO> ? WO : never\n\t\t>[]\n\t\t: never;\n};\n\n/**\n * Function signature for system process methods\n * @param queries Results of entity queries defined by the system\n * @param deltaTime Time elapsed since last update in seconds\n * @param ecs The ECSpresso instance providing access to all ECS functionality\n */\ntype ProcessFunction<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>>,\n> = (\n\tqueries: QueryResults<ComponentTypes, Queries>,\n\tdeltaTime: number,\n\tecs: ECSpresso<\n\t\tComponentTypes,\n\t\tEventTypes,\n\t\tResourceTypes\n\t>\n) => void;\n\n/**\n * Type for system initialization functions\n * These can be asynchronous\n */\ntype LifecycleFunction<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n> = (\n\tecs: ECSpresso<\n\t\tComponentTypes,\n\t\tEventTypes,\n\t\tResourceTypes\n\t>,\n) => void | Promise<void>;\n\n/**\n * Create a SystemBuilder attached to an ECSpresso instance\n * Helper function used by ECSpresso.addSystem\n */\nexport function createEcspressoSystemBuilder<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>\n>(\n\tlabel: string,\n\tecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>\n): SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes> {\n\treturn new SystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(\n\t\tlabel,\n\t\tecspresso\n\t) as SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes>;\n}\n\n/**\n * Create a SystemBuilder attached to a Bundle\n * Helper function used by Bundle.addSystem\n */\nexport function createBundleSystemBuilder<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>\n>(\n\tlabel: string,\n\tbundle: Bundle<ComponentTypes, EventTypes, ResourceTypes>\n): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes> {\n\treturn new SystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(\n\t\tlabel,\n\t\tnull,\n\t\tbundle\n\t) as SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes>;\n}\n\n// Type interfaces for specialized SystemBuilders\n\n/**\n * SystemBuilder with a guaranteed non-null reference to an ECSpresso instance\n */\nexport interface SystemBuilderWithEcspresso<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>> = {}\n> extends SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, Queries> {\n\treadonly ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>;\n\t\n\t/**\n\t * Complete this system and return ECSpresso for seamless chaining\n\t * Automatically registers the system when called\n\t */\n\tand(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes>;\n}\n\n/**\n * SystemBuilder with a guaranteed non-null reference to a Bundle\n */\nexport interface SystemBuilderWithBundle<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>> = {}\n> extends SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, Queries> {\n\treadonly bundle: Bundle<ComponentTypes, EventTypes, ResourceTypes>;\n\n\t/**\n\t * Complete this system and return the Bundle for chaining\n\t * Enables fluent API: bundle.addSystem(...).and().addSystem(...)\n\t */\n\tand(): Bundle<ComponentTypes, EventTypes, ResourceTypes>;\n}\n",
6
- "import { createBundleSystemBuilder, SystemBuilderWithBundle } from './system-builder';\nimport type ECSpresso from './ecspresso';\nimport type { AssetDefinition } from './asset-types';\nimport type { ScreenDefinition } from './screen-types';\nimport type { BundlesAreCompatible } from './type-utils';\n\n/**\n * Generates a unique ID for a bundle\n */\nfunction generateBundleId(): string {\n\treturn `bundle_${Date.now().toString(36)}_${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Bundle class that encapsulates a set of components, resources, events, and systems\n * that can be merged into a ECSpresso instance\n */\nexport default class Bundle<\n\tComponentTypes extends Record<string, any> = {},\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {},\n\tAssetTypes extends Record<string, unknown> = {},\n\tScreenStates extends Record<string, ScreenDefinition<any, any>> = {},\n> {\n\tprivate _systems: SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>[] = [];\n\tprivate _resources: Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]> = new Map();\n\tprivate _assets: Map<string, AssetDefinition<unknown>> = new Map();\n\tprivate _assetGroups: Map<string, Map<string, () => Promise<unknown>>> = new Map();\n\tprivate _screens: Map<string, ScreenDefinition<any, any>> = new Map();\n\tprivate _id: string;\n\n\tconstructor(id?: string) {\n\t\tthis._id = id || generateBundleId();\n\t}\n\n\t/**\n\t * Get the unique ID of this bundle\n\t */\n\tget id(): string {\n\t\treturn this._id;\n\t}\n\n\t/**\n\t * Set the ID of this bundle\n\t * @internal Used by combineBundles\n\t */\n\tset id(value: string) {\n\t\tthis._id = value;\n\t}\n\n\t/**\n\t * Add a system to this bundle, by label (creating a new builder) or by reusing an existing one\n\t */\n\taddSystem<Q extends Record<string, any>>(builder: SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Q>): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Q>;\n\taddSystem(label: string): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, {}>;\n\taddSystem(builderOrLabel: string | SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>) {\n\t\tif (typeof builderOrLabel === 'string') {\n\t\t\tconst system = createBundleSystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(builderOrLabel, this);\n\t\t\tthis._systems.push(system);\n\t\t\treturn system;\n\t\t} else {\n\t\t\tthis._systems.push(builderOrLabel);\n\t\t\treturn builderOrLabel;\n\t\t}\n\t}\n\n\t/**\n\t * Add a resource to this bundle\n\t * @param label The resource key\n\t * @param resource The resource value, a factory function, or a factory with dependencies\n\t */\n\taddResource<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\tresource:\n\t\t\t| ResourceTypes[K]\n\t\t\t| ((ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]>)\n\t\t\t| { dependsOn: readonly string[]; factory: (ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]> }\n\t) {\n\t\t// We need this cast because TypeScript doesn't recognize that a value of type\n\t\t// ResourceTypes[K] | (() => ResourceTypes[K] | Promise<ResourceTypes[K]>) | { dependsOn, factory }\n\t\t// can be properly assigned to Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]>\n\t\tthis._resources.set(label, resource as unknown as ResourceTypes[K]);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add an asset to this bundle\n\t * @param key The asset key\n\t * @param loader Function that loads and returns the asset\n\t * @param options Optional asset configuration\n\t */\n\taddAsset<K extends string, T>(\n\t\tkey: K,\n\t\tloader: () => Promise<T>,\n\t\toptions?: { eager?: boolean; group?: string }\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & Record<K, T>, ScreenStates> {\n\t\tthis._assets.set(key, {\n\t\t\tloader,\n\t\t\teager: options?.eager ?? true,\n\t\t\tgroup: options?.group,\n\t\t});\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & Record<K, T>, ScreenStates>;\n\t}\n\n\t/**\n\t * Add a group of assets to this bundle\n\t * @param groupName The group name\n\t * @param assets Object mapping asset keys to loader functions\n\t */\n\taddAssetGroup<G extends string, T extends Record<string, () => Promise<unknown>>>(\n\t\tgroupName: G,\n\t\tassets: T\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & { [K in keyof T]: Awaited<ReturnType<T[K]>> }, ScreenStates> {\n\t\tconst groupAssets = new Map<string, () => Promise<unknown>>();\n\t\tfor (const [key, loader] of Object.entries(assets)) {\n\t\t\tgroupAssets.set(key, loader as () => Promise<unknown>);\n\t\t\tthis._assets.set(key, {\n\t\t\t\tloader: loader as () => Promise<unknown>,\n\t\t\t\teager: false,\n\t\t\t\tgroup: groupName,\n\t\t\t});\n\t\t}\n\t\tthis._assetGroups.set(groupName, groupAssets);\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & { [K in keyof T]: Awaited<ReturnType<T[K]>> }, ScreenStates>;\n\t}\n\n\t/**\n\t * Add a screen to this bundle\n\t * @param name The screen name\n\t * @param definition The screen definition\n\t */\n\taddScreen<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(\n\t\tname: K,\n\t\tdefinition: ScreenDefinition<Config, State>\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates & Record<K, ScreenDefinition<Config, State>>> {\n\t\tthis._screens.set(name, definition);\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates & Record<K, ScreenDefinition<Config, State>>>;\n\t}\n\n\t/**\n\t * Get all asset definitions in this bundle\n\t */\n\tgetAssets(): Map<string, AssetDefinition<unknown>> {\n\t\treturn new Map(this._assets);\n\t}\n\n\t/**\n\t * Get all screen definitions in this bundle\n\t */\n\tgetScreens(): Map<string, ScreenDefinition<any, any>> {\n\t\treturn new Map(this._screens);\n\t}\n\n\t/**\n\t * Internal method to set a resource\n\t * @internal Used by mergeBundles\n\t */\n\t_setResource(key: string, value: unknown): void {\n\t\tthis._resources.set(key as keyof ResourceTypes, value as ResourceTypes[keyof ResourceTypes]);\n\t}\n\n\t/**\n\t * Internal method to set an asset definition\n\t * @internal Used by mergeBundles\n\t */\n\t_setAsset(key: string, definition: AssetDefinition<unknown>): void {\n\t\tthis._assets.set(key, definition);\n\t}\n\n\t/**\n\t * Internal method to set a screen definition\n\t * @internal Used by mergeBundles\n\t */\n\t_setScreen(name: string, definition: ScreenDefinition<any, any>): void {\n\t\tthis._screens.set(name, definition);\n\t}\n\n\t/**\n\t * Get all systems defined in this bundle\n\t * Returns built System objects instead of SystemBuilders\n\t */\n\tgetSystems() {\n\t\treturn this._systems.map(system => system.build());\n\t}\n\n\t/**\n\t * Register all systems in this bundle with an ECSpresso instance\n\t * @internal Used by ECSpresso when adding a bundle\n\t */\n\tregisterSystemsWithEcspresso(ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) {\n\t\tfor (const systemBuilder of this._systems) {\n\t\t\tsystemBuilder.build(ecspresso);\n\t\t}\n\t}\n\n\t/**\n\t * Get all resources defined in this bundle\n\t */\n\tgetResources(): Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]> {\n\t\treturn new Map(this._resources);\n\t}\n\n\t/**\n\t * Get a specific resource by key\n\t * @param key The resource key\n\t * @returns The resource value or undefined if not found\n\t */\n\tgetResource<K extends keyof ResourceTypes>(key: K): ResourceTypes[K] {\n\t\treturn this._resources.get(key) as ResourceTypes[K];\n\t}\n\n\t/**\n\t * Get all system builders in this bundle\n\t */\n\tgetSystemBuilders(): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>[] {\n\t\treturn [...this._systems];\n\t}\n\n\t/**\n\t * Check if this bundle has a specific resource\n\t * @param key The resource key to check\n\t * @returns True if the resource exists\n\t */\n\thasResource<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._resources.has(key);\n\t}\n}\n\n/**\n * Function that merges multiple bundles into a single bundle\n */\nexport function mergeBundles<\n\tC1 extends Record<string, any>,\n\tE1 extends Record<string, any>,\n\tR1 extends Record<string, any>,\n\tA1 extends Record<string, unknown>,\n\tS1 extends Record<string, ScreenDefinition<any, any>>,\n\tC2 extends Record<string, any>,\n\tE2 extends Record<string, any>,\n\tR2 extends Record<string, any>,\n\tA2 extends Record<string, unknown>,\n\tS2 extends Record<string, ScreenDefinition<any, any>>,\n>(\n\tid: string,\n\tbundle1: Bundle<C1, E1, R1, A1, S1>,\n\tbundle2: BundlesAreCompatible<C1, C2, E1, E2, R1, R2, A1, A2, S1, S2> extends true\n\t\t? Bundle<C2, E2, R2, A2, S2>\n\t\t: never\n): Bundle<C1 & C2, E1 & E2, R1 & R2, A1 & A2, S1 & S2>;\n\nexport function mergeBundles<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tAssetTypes extends Record<string, unknown>,\n\tScreenStates extends Record<string, ScreenDefinition<any, any>>,\n>(\n\tid: string,\n\t...bundles: Array<Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>>\n): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>;\n\nexport function mergeBundles(\n\tid: string,\n\t...bundles: Array<Bundle<any, any, any, any, any>>\n): Bundle<any, any, any, any, any> {\n\tif (bundles.length === 0) {\n\t\treturn new Bundle(id);\n\t}\n\n\tconst combined = new Bundle(id);\n\n\tfor (const bundle of bundles) {\n\t\tfor (const system of bundle.getSystemBuilders()) {\n\t\t\t// reuse the full builder so we carry over queries, hooks, and handlers\n\t\t\tcombined.addSystem(system);\n\t\t}\n\n\t\t// Add resources from this bundle\n\t\tfor (const [label, resource] of bundle.getResources().entries()) {\n\t\t\tcombined._setResource(label as string, resource);\n\t\t}\n\n\t\t// Add assets from this bundle\n\t\tfor (const [key, definition] of bundle.getAssets().entries()) {\n\t\t\tcombined._setAsset(key, definition);\n\t\t}\n\n\t\t// Add screens from this bundle\n\t\tfor (const [name, definition] of bundle.getScreens().entries()) {\n\t\t\tcombined._setScreen(name, definition);\n\t\t}\n\t}\n\n\treturn combined;\n}\n",
7
- "/**\n * Transform Bundle for ECSpresso\n *\n * Provides hierarchical transform propagation following Bevy's Transform/GlobalTransform pattern.\n * LocalTransform is modified by user code; WorldTransform is computed automatically.\n *\n * @see https://docs.rs/bevy/latest/bevy/transform/components/struct.GlobalTransform.html\n */\n\nimport Bundle from '../../bundle';\nimport type ECSpresso from '../../ecspresso';\n\n// ==================== Component Types ====================\n\n/**\n * Local transform relative to parent (or world if no parent).\n * This is the transform you modify directly.\n */\nexport interface LocalTransform {\n\tx: number;\n\ty: number;\n\trotation: number;\n\tscaleX: number;\n\tscaleY: number;\n}\n\n/**\n * Computed world transform (accumulated from parent chain).\n * Read-only - managed by the transform propagation system.\n */\nexport interface WorldTransform {\n\tx: number;\n\ty: number;\n\trotation: number;\n\tscaleX: number;\n\tscaleY: number;\n}\n\n/**\n * Component types provided by the transform bundle.\n * Extend your component types with this interface.\n *\n * @example\n * ```typescript\n * interface GameComponents extends TransformComponentTypes {\n * sprite: Sprite;\n * velocity: { x: number; y: number };\n * }\n * ```\n */\nexport interface TransformComponentTypes {\n\tlocalTransform: LocalTransform;\n\tworldTransform: WorldTransform;\n}\n\n// ==================== Bundle Options ====================\n\n/**\n * Configuration options for the transform bundle.\n */\nexport interface TransformBundleOptions {\n\t/** System group name (default: 'transform') */\n\tsystemGroup?: string;\n\t/** Priority for transform propagation (default: 500, runs after physics/movement) */\n\tpriority?: number;\n}\n\n// ==================== Default Values ====================\n\n/**\n * Default local transform values.\n */\nexport const DEFAULT_LOCAL_TRANSFORM: Readonly<LocalTransform> = {\n\tx: 0,\n\ty: 0,\n\trotation: 0,\n\tscaleX: 1,\n\tscaleY: 1,\n} as const;\n\n/**\n * Default world transform values.\n */\nexport const DEFAULT_WORLD_TRANSFORM: Readonly<WorldTransform> = {\n\tx: 0,\n\ty: 0,\n\trotation: 0,\n\tscaleX: 1,\n\tscaleY: 1,\n} as const;\n\n// ==================== Helper Functions ====================\n\n/**\n * Create a local transform component with position only.\n * Uses default rotation (0) and scale (1, 1).\n *\n * @param x The x coordinate\n * @param y The y coordinate\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createLocalTransform(100, 200),\n * sprite,\n * });\n * ```\n */\nexport function createLocalTransform(x: number, y: number): Pick<TransformComponentTypes, 'localTransform'> {\n\treturn {\n\t\tlocalTransform: {\n\t\t\tx,\n\t\t\ty,\n\t\t\trotation: 0,\n\t\t\tscaleX: 1,\n\t\t\tscaleY: 1,\n\t\t},\n\t};\n}\n\n/**\n * Create a world transform component with position only.\n * Typically used alongside createLocalTransform for initial state.\n *\n * @param x The x coordinate\n * @param y The y coordinate\n * @returns Component object suitable for spreading into spawn()\n */\nexport function createWorldTransform(x: number, y: number): Pick<TransformComponentTypes, 'worldTransform'> {\n\treturn {\n\t\tworldTransform: {\n\t\t\tx,\n\t\t\ty,\n\t\t\trotation: 0,\n\t\t\tscaleX: 1,\n\t\t\tscaleY: 1,\n\t\t},\n\t};\n}\n\n/**\n * Options for creating a full transform.\n */\nexport interface TransformOptions {\n\trotation?: number;\n\tscaleX?: number;\n\tscaleY?: number;\n\t/** Uniform scale (overrides scaleX/scaleY if provided) */\n\tscale?: number;\n}\n\n/**\n * Create both local and world transform components.\n * World transform is initialized to match local transform.\n *\n * @param x The x coordinate\n * @param y The y coordinate\n * @param options Optional rotation and scale\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * sprite,\n * });\n *\n * // With rotation and scale\n * ecs.spawn({\n * ...createTransform(100, 200, { rotation: Math.PI / 4, scale: 2 }),\n * sprite,\n * });\n * ```\n */\nexport function createTransform(\n\tx: number,\n\ty: number,\n\toptions?: TransformOptions\n): TransformComponentTypes {\n\tconst scaleX = options?.scale ?? options?.scaleX ?? 1;\n\tconst scaleY = options?.scale ?? options?.scaleY ?? 1;\n\tconst rotation = options?.rotation ?? 0;\n\n\tconst transform = {\n\t\tx,\n\t\ty,\n\t\trotation,\n\t\tscaleX,\n\t\tscaleY,\n\t};\n\n\treturn {\n\t\tlocalTransform: { ...transform },\n\t\tworldTransform: { ...transform },\n\t};\n}\n\n// ==================== Bundle Factory ====================\n\n/**\n * Create a transform bundle for ECSpresso.\n *\n * This bundle provides:\n * - Transform propagation system that computes world transforms from local transforms\n * - Parent-first traversal ensures parents are processed before children\n * - Supports full transform hierarchy (position, rotation, scale)\n *\n * @example\n * ```typescript\n * const ecs = ECSpresso\n * .create<Components, Events, Resources>()\n * .withBundle(createTransformBundle())\n * .withBundle(createMovementBundle())\n * .build();\n *\n * // Spawn entity with transform\n * ecs.spawn({\n * ...createTransform(100, 200),\n * velocity: { x: 50, y: 0 },\n * });\n * ```\n */\nexport function createTransformBundle(\n\toptions?: TransformBundleOptions\n): Bundle<TransformComponentTypes, {}, {}> {\n\tconst {\n\t\tsystemGroup = 'transform',\n\t\tpriority = 500,\n\t} = options ?? {};\n\n\tconst bundle = new Bundle<TransformComponentTypes, {}, {}>('transform');\n\n\tbundle\n\t\t.addSystem('transform-propagation')\n\t\t.setPriority(priority)\n\t\t.inGroup(systemGroup)\n\t\t.setProcess((_queries, _deltaTime, ecs) => {\n\t\t\tpropagateTransforms(ecs as ECSpresso<TransformComponentTypes, {}, {}>);\n\t\t})\n\t\t.and();\n\n\treturn bundle;\n}\n\n/**\n * Propagate transforms through the hierarchy.\n * Parent-first traversal ensures parents are computed before children.\n */\nfunction propagateTransforms(ecs: ECSpresso<TransformComponentTypes, {}, {}>): void {\n\t// Use parent-first traversal for entities in hierarchy\n\tecs.forEachInHierarchy((entityId, parentId) => {\n\t\tconst localTransform = ecs.entityManager.getComponent(entityId, 'localTransform');\n\t\tconst worldTransform = ecs.entityManager.getComponent(entityId, 'worldTransform');\n\n\t\tif (!localTransform || !worldTransform) return;\n\n\t\tif (parentId === null) {\n\t\t\t// Root entity: world transform equals local transform\n\t\t\tcopyTransform(localTransform, worldTransform);\n\t\t} else {\n\t\t\t// Child entity: combine with parent's world transform\n\t\t\tconst parentWorld = ecs.entityManager.getComponent(parentId, 'worldTransform');\n\t\t\tif (parentWorld) {\n\t\t\t\tcombineTransforms(parentWorld, localTransform, worldTransform);\n\t\t\t} else {\n\t\t\t\t// Parent has no world transform, treat as root\n\t\t\t\tcopyTransform(localTransform, worldTransform);\n\t\t\t}\n\t\t}\n\t});\n\n\t// Process orphaned entities (not in hierarchy but have transforms)\n\tconst orphanedEntities = ecs.getEntitiesWithQuery(['localTransform', 'worldTransform']);\n\tfor (const entity of orphanedEntities) {\n\t\tconst parentId = ecs.getParent(entity.id);\n\t\t// Only process if truly orphaned (no parent and not a root with children)\n\t\tif (parentId === null && ecs.getChildren(entity.id).length === 0) {\n\t\t\tconst { localTransform, worldTransform } = entity.components;\n\t\t\tcopyTransform(localTransform, worldTransform);\n\t\t}\n\t}\n}\n\n/**\n * Copy transform values from source to destination.\n */\nfunction copyTransform(src: LocalTransform, dest: WorldTransform): void {\n\tdest.x = src.x;\n\tdest.y = src.y;\n\tdest.rotation = src.rotation;\n\tdest.scaleX = src.scaleX;\n\tdest.scaleY = src.scaleY;\n}\n\n/**\n * Combine parent world transform with child local transform into child world transform.\n */\nfunction combineTransforms(\n\tparent: WorldTransform,\n\tlocal: LocalTransform,\n\tworld: WorldTransform\n): void {\n\t// Apply parent's scale to local position\n\tconst scaledLocalX = local.x * parent.scaleX;\n\tconst scaledLocalY = local.y * parent.scaleY;\n\n\t// Rotate local position by parent's rotation\n\tconst cos = Math.cos(parent.rotation);\n\tconst sin = Math.sin(parent.rotation);\n\tconst rotatedX = scaledLocalX * cos - scaledLocalY * sin;\n\tconst rotatedY = scaledLocalX * sin + scaledLocalY * cos;\n\n\t// Add to parent's position\n\tworld.x = parent.x + rotatedX;\n\tworld.y = parent.y + rotatedY;\n\tworld.rotation = parent.rotation + local.rotation;\n\tworld.scaleX = parent.scaleX * local.scaleX;\n\tworld.scaleY = parent.scaleY * local.scaleY;\n}\n",
8
- "/**\n * PixiJS Renderer Bundle for ECSpresso\n *\n * An opt-in PixiJS rendering bundle that automates scene graph wiring.\n * Import from 'ecspresso/bundles/renderers/pixi'\n *\n * This bundle includes transform propagation automatically.\n */\n\nimport type { Application, ApplicationOptions, Container, Sprite, Graphics } from 'pixi.js';\nimport Bundle, { mergeBundles } from '../../bundle';\nimport type ECSpresso from '../../ecspresso';\nimport {\n\tcreateTransformBundle,\n\ttype LocalTransform,\n\ttype WorldTransform,\n\ttype TransformComponentTypes,\n\ttype TransformBundleOptions,\n} from '../utils/transform';\n\n// Re-export transform types for convenience\nexport type { LocalTransform, WorldTransform, TransformComponentTypes };\nexport { createTransform, createLocalTransform, createWorldTransform } from '../utils/transform';\n\n// Dynamic import for Application to avoid requiring pixi.js at bundle creation time\n// when using managed mode (init options instead of pre-initialized app)\nasync function createPixiApplication(options: Partial<ApplicationOptions>): Promise<Application> {\n\tconst { Application } = await import('pixi.js');\n\tconst app = new Application();\n\tawait app.init(options);\n\treturn app;\n}\n\n// ==================== Component Types ====================\n\n/**\n * PixiJS Sprite component\n */\nexport interface PixiSprite {\n\tsprite: Sprite;\n\tanchor?: { x: number; y: number };\n}\n\n/**\n * PixiJS Graphics component\n */\nexport interface PixiGraphics {\n\tgraphics: Graphics;\n}\n\n/**\n * PixiJS Container component\n */\nexport interface PixiContainer {\n\tcontainer: Container;\n}\n\n/**\n * Visibility and alpha component\n */\nexport interface PixiVisible {\n\tvisible: boolean;\n\talpha?: number;\n}\n\n/**\n * Aggregate component types for PixiJS bundle.\n * Users should extend this interface with their own component types.\n *\n * @example\n * ```typescript\n * interface GameComponents extends PixiComponentTypes {\n * velocity: { x: number; y: number };\n * player: true;\n * }\n * ```\n */\nexport interface PixiComponentTypes extends TransformComponentTypes {\n\tpixiSprite: PixiSprite;\n\tpixiGraphics: PixiGraphics;\n\tpixiContainer: PixiContainer;\n\tpixiVisible: PixiVisible;\n}\n\n// ==================== Event Types ====================\n\n/**\n * Events emitted by the PixiJS bundle\n */\nexport interface PixiEventTypes {\n\thierarchyChanged: {\n\t\tentityId: number;\n\t\toldParent: number | null;\n\t\tnewParent: number | null;\n\t};\n}\n\n// ==================== Resource Types ====================\n\n/**\n * Resources provided by the PixiJS bundle\n */\nexport interface PixiResourceTypes {\n\tpixiApp: Application;\n\tpixiRootContainer: Container;\n}\n\n// ==================== Bundle Options ====================\n\n/**\n * Common options shared between both initialization modes\n */\ninterface PixiBundleCommonOptions {\n\t/** Optional custom root container (defaults to app.stage) */\n\trootContainer?: Container;\n\t/** System group name (default: 'pixi-renderer') */\n\tsystemGroup?: string;\n\t/** Priority for render sync system (default: 500) */\n\trenderSyncPriority?: number;\n\t/** Options for the included transform bundle */\n\ttransform?: TransformBundleOptions;\n}\n\n/**\n * Options when providing a pre-initialized PixiJS Application\n */\nexport interface PixiBundleAppOptions extends PixiBundleCommonOptions {\n\t/** The PixiJS Application instance (already initialized) */\n\tapp: Application;\n\tinit?: never;\n\tcontainer?: never;\n}\n\n/**\n * Options when letting the bundle create and manage the PixiJS Application\n */\nexport interface PixiBundleManagedOptions extends PixiBundleCommonOptions {\n\tapp?: never;\n\t/** PixiJS ApplicationOptions - bundle will create and initialize the Application */\n\tinit: Partial<ApplicationOptions>;\n\t/** Container element to append the canvas to, or CSS selector string */\n\tcontainer?: HTMLElement | string;\n}\n\n/**\n * Configuration options for the PixiJS bundle.\n *\n * Supports two modes:\n * 1. **Pre-initialized**: Pass an already-initialized Application via `app`\n * 2. **Managed**: Pass `init` options and the bundle creates the Application during `ecs.initialize()`\n *\n * This bundle includes transform propagation automatically - no need to add createTransformBundle() separately.\n *\n * @example Pre-initialized mode (full control)\n * ```typescript\n * const app = new Application();\n * await app.init({ resizeTo: window });\n * const ecs = ECSpresso.create<GameComponents, {}, {}>()\n * .withBundle(createPixiBundle({ app }))\n * .build();\n * ```\n *\n * @example Managed mode (convenience)\n * ```typescript\n * const ecs = ECSpresso.create<GameComponents, {}, {}>()\n * .withBundle(createPixiBundle({\n * init: { background: '#1099bb', resizeTo: window },\n * container: document.body,\n * }))\n * .build();\n * await ecs.initialize(); // Application created here\n * ```\n */\nexport type PixiBundleOptions = PixiBundleAppOptions | PixiBundleManagedOptions;\n\n// ==================== Default Values ====================\n\n/**\n * Default local transform values\n */\nexport const DEFAULT_LOCAL_TRANSFORM: Readonly<LocalTransform> = {\n\tx: 0,\n\ty: 0,\n\trotation: 0,\n\tscaleX: 1,\n\tscaleY: 1,\n} as const;\n\n/**\n * Default world transform values\n */\nexport const DEFAULT_WORLD_TRANSFORM: Readonly<WorldTransform> = {\n\tx: 0,\n\ty: 0,\n\trotation: 0,\n\tscaleX: 1,\n\tscaleY: 1,\n} as const;\n\n// ==================== Helper Utilities ====================\n\ninterface PositionOption {\n\tx?: number;\n\ty?: number;\n}\n\ninterface TransformOptions {\n\trotation?: number;\n\tscale?: number | { x: number; y: number };\n\tvisible?: boolean;\n\talpha?: number;\n}\n\nfunction createLocalTransformInternal(\n\tposition?: PositionOption,\n\toptions?: TransformOptions\n): LocalTransform {\n\tconst scaleValue = options?.scale;\n\tconst scaleX = typeof scaleValue === 'number'\n\t\t? scaleValue\n\t\t: scaleValue?.x ?? 1;\n\tconst scaleY = typeof scaleValue === 'number'\n\t\t? scaleValue\n\t\t: scaleValue?.y ?? 1;\n\n\treturn {\n\t\tx: position?.x ?? 0,\n\t\ty: position?.y ?? 0,\n\t\trotation: options?.rotation ?? 0,\n\t\tscaleX,\n\t\tscaleY,\n\t};\n}\n\nfunction createWorldTransformInternal(\n\tposition?: PositionOption,\n\toptions?: TransformOptions\n): WorldTransform {\n\tconst scaleValue = options?.scale;\n\tconst scaleX = typeof scaleValue === 'number'\n\t\t? scaleValue\n\t\t: scaleValue?.x ?? 1;\n\tconst scaleY = typeof scaleValue === 'number'\n\t\t? scaleValue\n\t\t: scaleValue?.y ?? 1;\n\n\treturn {\n\t\tx: position?.x ?? 0,\n\t\ty: position?.y ?? 0,\n\t\trotation: options?.rotation ?? 0,\n\t\tscaleX,\n\t\tscaleY,\n\t};\n}\n\nfunction createVisibleComponent(options?: TransformOptions): PixiVisible {\n\treturn {\n\t\tvisible: options?.visible ?? true,\n\t\talpha: options?.alpha,\n\t};\n}\n\n/**\n * Create components for a sprite entity.\n * Returns an object suitable for spreading into spawn().\n *\n * @example\n * ```typescript\n * const player = ecs.spawn({\n * ...createSpriteComponents(new Sprite(texture), { x: 100, y: 100 }),\n * velocity: { x: 0, y: 0 },\n * });\n * ```\n */\nexport function createSpriteComponents(\n\tsprite: Sprite,\n\tposition?: PositionOption,\n\toptions?: TransformOptions & { anchor?: { x: number; y: number } }\n): Pick<PixiComponentTypes, 'pixiSprite' | 'localTransform' | 'worldTransform' | 'pixiVisible'> {\n\treturn {\n\t\tpixiSprite: {\n\t\t\tsprite,\n\t\t\tanchor: options?.anchor,\n\t\t},\n\t\tlocalTransform: createLocalTransformInternal(position, options),\n\t\tworldTransform: createWorldTransformInternal(position, options),\n\t\tpixiVisible: createVisibleComponent(options),\n\t};\n}\n\n/**\n * Create components for a graphics entity.\n * Returns an object suitable for spreading into spawn().\n *\n * @example\n * ```typescript\n * const rect = ecs.spawn({\n * ...createGraphicsComponents(graphics, { x: 50, y: 50 }),\n * });\n * ```\n */\nexport function createGraphicsComponents(\n\tgraphics: Graphics,\n\tposition?: PositionOption,\n\toptions?: TransformOptions\n): Pick<PixiComponentTypes, 'pixiGraphics' | 'localTransform' | 'worldTransform' | 'pixiVisible'> {\n\treturn {\n\t\tpixiGraphics: { graphics },\n\t\tlocalTransform: createLocalTransformInternal(position, options),\n\t\tworldTransform: createWorldTransformInternal(position, options),\n\t\tpixiVisible: createVisibleComponent(options),\n\t};\n}\n\n/**\n * Create components for a container entity.\n * Returns an object suitable for spreading into spawn().\n *\n * @example\n * ```typescript\n * const group = ecs.spawn({\n * ...createContainerComponents(new Container(), { x: 0, y: 0 }),\n * });\n * ```\n */\nexport function createContainerComponents(\n\tcontainer: Container,\n\tposition?: PositionOption,\n\toptions?: TransformOptions\n): Pick<PixiComponentTypes, 'pixiContainer' | 'localTransform' | 'worldTransform' | 'pixiVisible'> {\n\treturn {\n\t\tpixiContainer: { container },\n\t\tlocalTransform: createLocalTransformInternal(position, options),\n\t\tworldTransform: createWorldTransformInternal(position, options),\n\t\tpixiVisible: createVisibleComponent(options),\n\t};\n}\n\n// ==================== Bundle Factory ====================\n\n/**\n * Create a PixiJS rendering bundle for ECSpresso.\n *\n * This bundle provides:\n * - Transform propagation (localTransform → worldTransform)\n * - Render sync system (updates PixiJS objects from ECS components)\n * - Scene graph management (mirrors ECS hierarchy in PixiJS scene graph)\n *\n * @example Pre-initialized mode\n * ```typescript\n * const app = new Application();\n * await app.init({ resizeTo: window });\n *\n * const ecs = ECSpresso.create<GameComponents, {}, {}>()\n * .withBundle(createPixiBundle({ app }))\n * .build();\n * ```\n *\n * @example Managed mode\n * ```typescript\n * const ecs = ECSpresso.create<GameComponents, {}, {}>()\n * .withBundle(createPixiBundle({\n * init: { background: '#1099bb', resizeTo: window },\n * container: document.body,\n * }))\n * .build();\n * await ecs.initialize();\n * ```\n */\nexport function createPixiBundle(\n\toptions: PixiBundleOptions\n): Bundle<PixiComponentTypes, PixiEventTypes, PixiResourceTypes> {\n\tconst {\n\t\trootContainer: customRootContainer,\n\t\tsystemGroup = 'pixi-renderer',\n\t\trenderSyncPriority = 500,\n\t\ttransform: transformOptions,\n\t} = options;\n\n\tconst pixiBundle = new Bundle<PixiComponentTypes, PixiEventTypes, PixiResourceTypes>('pixi-renderer-internal');\n\n\t// Determine mode and set up resources accordingly\n\tconst isManaged = 'init' in options && options.init !== undefined;\n\n\tif (isManaged) {\n\t\t// Managed mode: create Application during initialization\n\t\tconst initOptions = options.init;\n\t\tconst containerOption = options.container;\n\n\t\t// Resource factory that creates the Application\n\t\tpixiBundle.addResource('pixiApp', async () => {\n\t\t\tconst app = await createPixiApplication(initOptions);\n\n\t\t\t// Auto-append canvas if container specified\n\t\t\tif (containerOption) {\n\t\t\t\tconst containerEl = typeof containerOption === 'string'\n\t\t\t\t\t? document.querySelector(containerOption)\n\t\t\t\t\t: containerOption;\n\n\t\t\t\tif (containerEl) {\n\t\t\t\t\tcontainerEl.appendChild(app.canvas);\n\t\t\t\t} else if (typeof containerOption === 'string') {\n\t\t\t\t\tconsole.warn(`PixiJS bundle: container selector \"${containerOption}\" not found`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn app;\n\t\t});\n\n\t\t// pixiRootContainer depends on pixiApp - declarative dependency\n\t\tpixiBundle.addResource('pixiRootContainer', {\n\t\t\tdependsOn: ['pixiApp'],\n\t\t\tfactory: (ecs) => customRootContainer ?? ecs.getResource('pixiApp').stage,\n\t\t});\n\t} else {\n\t\t// Pre-initialized mode: use provided Application\n\t\tconst app = options.app;\n\t\tpixiBundle.addResource('pixiApp', app);\n\t\tpixiBundle.addResource('pixiRootContainer', customRootContainer ?? app.stage);\n\t}\n\n\t// Entity ID -> PixiJS Container mapping for scene graph management\n\tconst entityToPixiObject = new Map<number, Container>();\n\n\t// Helper to get the PixiJS display object for an entity\n\tfunction getPixiObject(entityId: number, ecs: ECSpresso<PixiComponentTypes, PixiEventTypes, PixiResourceTypes>): Container | null {\n\t\t// Check cache first\n\t\tconst cached = entityToPixiObject.get(entityId);\n\t\tif (cached) return cached;\n\n\t\t// Try to get from components\n\t\tconst spriteComp = ecs.entityManager.getComponent(entityId, 'pixiSprite');\n\t\tif (spriteComp) {\n\t\t\tentityToPixiObject.set(entityId, spriteComp.sprite);\n\t\t\treturn spriteComp.sprite;\n\t\t}\n\n\t\tconst graphicsComp = ecs.entityManager.getComponent(entityId, 'pixiGraphics');\n\t\tif (graphicsComp) {\n\t\t\tentityToPixiObject.set(entityId, graphicsComp.graphics);\n\t\t\treturn graphicsComp.graphics;\n\t\t}\n\n\t\tconst containerComp = ecs.entityManager.getComponent(entityId, 'pixiContainer');\n\t\tif (containerComp) {\n\t\t\tentityToPixiObject.set(entityId, containerComp.container);\n\t\t\treturn containerComp.container;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t// Helper to add a PixiJS object to the scene graph\n\tfunction addToSceneGraph(\n\t\tentityId: number,\n\t\tpixiObject: Container,\n\t\tecs: ECSpresso<PixiComponentTypes, PixiEventTypes, PixiResourceTypes>\n\t): void {\n\t\tconst rootContainer = ecs.getResource('pixiRootContainer');\n\t\tconst parentId = ecs.getParent(entityId);\n\t\tconst parentPixiObject = parentId !== null ? getPixiObject(parentId, ecs) : null;\n\t\tconst targetContainer = parentPixiObject ?? rootContainer;\n\n\t\t// Only add if not already a child\n\t\tif (pixiObject.parent !== targetContainer) {\n\t\t\ttargetContainer.addChild(pixiObject);\n\t\t}\n\t}\n\n\t// Helper to remove a PixiJS object from scene graph\n\tfunction removeFromSceneGraph(entityId: number): void {\n\t\tconst pixiObject = entityToPixiObject.get(entityId);\n\t\tif (pixiObject) {\n\t\t\tpixiObject.removeFromParent();\n\t\t\tentityToPixiObject.delete(entityId);\n\t\t}\n\t}\n\n\t// Helper to update parent in scene graph\n\tfunction updateSceneGraphParent(\n\t\tentityId: number,\n\t\tecs: ECSpresso<PixiComponentTypes, PixiEventTypes, PixiResourceTypes>\n\t): void {\n\t\tconst pixiObject = entityToPixiObject.get(entityId);\n\t\tif (!pixiObject) return;\n\n\t\tconst rootContainer = ecs.getResource('pixiRootContainer');\n\t\tconst parentId = ecs.getParent(entityId);\n\t\tconst parentPixiObject = parentId !== null ? getPixiObject(parentId, ecs) : null;\n\t\tconst targetContainer = parentPixiObject ?? rootContainer;\n\n\t\tif (pixiObject.parent !== targetContainer) {\n\t\t\tpixiObject.removeFromParent();\n\t\t\ttargetContainer.addChild(pixiObject);\n\t\t}\n\t}\n\n\t// ==================== Render Sync System ====================\n\t// Updates PixiJS objects from world transforms and visibility\n\tpixiBundle\n\t\t.addSystem('pixi-render-sync')\n\t\t.setPriority(renderSyncPriority)\n\t\t.inGroup(systemGroup)\n\t\t.addQuery('sprites', {\n\t\t\twith: ['pixiSprite', 'worldTransform'] as const,\n\t\t})\n\t\t.addQuery('graphics', {\n\t\t\twith: ['pixiGraphics', 'worldTransform'] as const,\n\t\t})\n\t\t.addQuery('containers', {\n\t\t\twith: ['pixiContainer', 'worldTransform'] as const,\n\t\t})\n\t\t.setProcess((queries, _deltaTime, ecs) => {\n\t\t\t// Process sprites\n\t\t\tfor (const entity of queries.sprites) {\n\t\t\t\tconst { pixiSprite, worldTransform } = entity.components;\n\t\t\t\tconst { sprite, anchor } = pixiSprite;\n\n\t\t\t\tsprite.position.set(worldTransform.x, worldTransform.y);\n\t\t\t\tsprite.rotation = worldTransform.rotation;\n\t\t\t\tsprite.scale.set(worldTransform.scaleX, worldTransform.scaleY);\n\n\t\t\t\tif (anchor) {\n\t\t\t\t\tsprite.anchor.set(anchor.x, anchor.y);\n\t\t\t\t}\n\n\t\t\t\t// Apply visibility if component exists\n\t\t\t\tconst visible = ecs.entityManager.getComponent(entity.id, 'pixiVisible');\n\t\t\t\tif (visible) {\n\t\t\t\t\tsprite.visible = visible.visible;\n\t\t\t\t\tif (visible.alpha !== undefined) {\n\t\t\t\t\t\tsprite.alpha = visible.alpha;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Process graphics\n\t\t\tfor (const entity of queries.graphics) {\n\t\t\t\tconst { pixiGraphics, worldTransform } = entity.components;\n\t\t\t\tconst { graphics } = pixiGraphics;\n\n\t\t\t\tgraphics.position.set(worldTransform.x, worldTransform.y);\n\t\t\t\tgraphics.rotation = worldTransform.rotation;\n\t\t\t\tgraphics.scale.set(worldTransform.scaleX, worldTransform.scaleY);\n\n\t\t\t\t// Apply visibility if component exists\n\t\t\t\tconst visible = ecs.entityManager.getComponent(entity.id, 'pixiVisible');\n\t\t\t\tif (visible) {\n\t\t\t\t\tgraphics.visible = visible.visible;\n\t\t\t\t\tif (visible.alpha !== undefined) {\n\t\t\t\t\t\tgraphics.alpha = visible.alpha;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Process containers\n\t\t\tfor (const entity of queries.containers) {\n\t\t\t\tconst { pixiContainer, worldTransform } = entity.components;\n\t\t\t\tconst { container } = pixiContainer;\n\n\t\t\t\tcontainer.position.set(worldTransform.x, worldTransform.y);\n\t\t\t\tcontainer.rotation = worldTransform.rotation;\n\t\t\t\tcontainer.scale.set(worldTransform.scaleX, worldTransform.scaleY);\n\n\t\t\t\t// Apply visibility if component exists\n\t\t\t\tconst visible = ecs.entityManager.getComponent(entity.id, 'pixiVisible');\n\t\t\t\tif (visible) {\n\t\t\t\t\tcontainer.visible = visible.visible;\n\t\t\t\t\tif (visible.alpha !== undefined) {\n\t\t\t\t\t\tcontainer.alpha = visible.alpha;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.and();\n\n\t// ==================== Scene Graph Manager System ====================\n\t// Sets up reactive queries to manage scene graph on entity create/destroy\n\t// High priority ensures this runs before user systems' onInitialize\n\tpixiBundle\n\t\t.addSystem('pixi-scene-graph-manager')\n\t\t.setPriority(9999)\n\t\t.inGroup(systemGroup)\n\t\t.setOnInitialize((ecs) => {\n\t\t\t// Reactive query for sprites\n\t\t\tecs.addReactiveQuery('pixi-sprites', {\n\t\t\t\twith: ['pixiSprite'] as const,\n\t\t\t\tonEnter: (entity) => {\n\t\t\t\t\tconst pixiObject = entity.components.pixiSprite.sprite;\n\t\t\t\t\tentityToPixiObject.set(entity.id, pixiObject);\n\t\t\t\t\taddToSceneGraph(entity.id, pixiObject, ecs);\n\t\t\t\t},\n\t\t\t\tonExit: (entityId) => {\n\t\t\t\t\tremoveFromSceneGraph(entityId);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Reactive query for graphics\n\t\t\tecs.addReactiveQuery('pixi-graphics', {\n\t\t\t\twith: ['pixiGraphics'] as const,\n\t\t\t\tonEnter: (entity) => {\n\t\t\t\t\tconst pixiObject = entity.components.pixiGraphics.graphics;\n\t\t\t\t\tentityToPixiObject.set(entity.id, pixiObject);\n\t\t\t\t\taddToSceneGraph(entity.id, pixiObject, ecs);\n\t\t\t\t},\n\t\t\t\tonExit: (entityId) => {\n\t\t\t\t\tremoveFromSceneGraph(entityId);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Reactive query for containers\n\t\t\tecs.addReactiveQuery('pixi-containers', {\n\t\t\t\twith: ['pixiContainer'] as const,\n\t\t\t\tonEnter: (entity) => {\n\t\t\t\t\tconst pixiObject = entity.components.pixiContainer.container;\n\t\t\t\t\tentityToPixiObject.set(entity.id, pixiObject);\n\t\t\t\t\taddToSceneGraph(entity.id, pixiObject, ecs);\n\t\t\t\t},\n\t\t\t\tonExit: (entityId) => {\n\t\t\t\t\tremoveFromSceneGraph(entityId);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Subscribe to hierarchy changes to mirror reparenting in scene graph\n\t\t\tecs.on('hierarchyChanged', ({ entityId }) => {\n\t\t\t\tupdateSceneGraphParent(entityId, ecs);\n\t\t\t});\n\t\t})\n\t\t.and();\n\n\t// Merge transform bundle (runs first) with pixi bundle\n\tconst transformBundle = createTransformBundle(transformOptions);\n\treturn mergeBundles('pixi-renderer', transformBundle, pixiBundle);\n}\n"
9
- ],
10
- "mappings": "kjBAOO,MAAM,CAKX,CAyBQ,OACA,WACA,QA1BD,QAAmB,CAAC,EACpB,gBACA,eACA,mBACA,cAYA,UAAY,EACZ,cAAgB,GAChB,QAAoB,CAAC,EACrB,WACA,gBACA,gBAER,WAAW,CACF,EACA,EAA0E,KAC1E,EAAoE,KAC3E,CAHO,cACA,kBACA,kBAGL,MAAK,EAAG,CACX,OAAO,KAAK,UAMT,OAAM,EAAG,CACZ,OAAO,KAAK,WAMT,UAAS,EAAG,CACf,OAAO,KAAK,WAOL,aAAa,EAAS,CAC7B,GAAI,KAAK,eAAiB,CAAC,KAAK,WAAY,OAE5C,IAAM,EAAS,KAAK,mBAAmB,EACvC,EAA4B,EAAQ,KAAK,UAAU,EACnD,KAAK,cAAgB,GAOd,kBAAkB,EAAgE,CACzF,OAAO,KAAK,oBAAoB,EAOzB,mBAAmB,EAAgE,CAC1F,IAAM,EAAsE,CAC3E,MAAO,KAAK,OACZ,cAAe,KAAK,QACpB,SAAU,KAAK,SAChB,EAEA,GAAI,KAAK,gBACR,EAAO,QAAU,KAAK,gBAGvB,GAAI,KAAK,eACR,EAAO,SAAW,KAAK,eAGxB,GAAI,KAAK,mBACR,EAAO,aAAe,KAAK,mBAG5B,GAA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