ecspresso 0.10.2 → 0.11.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 (82) hide show
  1. package/README.md +73 -17
  2. package/dist/asset-manager.d.ts +15 -15
  3. package/dist/asset-types.d.ts +16 -14
  4. package/dist/bundle.d.ts +66 -16
  5. package/dist/bundles/audio.d.ts +293 -0
  6. package/dist/bundles/{utils/bounds.d.ts → bounds.d.ts} +9 -7
  7. package/dist/bundles/camera.d.ts +89 -0
  8. package/dist/bundles/collision.d.ts +289 -0
  9. package/dist/bundles/diagnostics.d.ts +48 -0
  10. package/dist/bundles/{utils/input.d.ts → input.d.ts} +16 -17
  11. package/dist/bundles/physics2D.d.ts +159 -0
  12. package/dist/bundles/renderers/renderer2D.d.ts +65 -24
  13. package/dist/bundles/spatial-index.d.ts +57 -0
  14. package/dist/bundles/state-machine.d.ts +298 -0
  15. package/dist/bundles/{utils/timers.d.ts → timers.d.ts} +9 -8
  16. package/dist/bundles/{utils/transform.d.ts → transform.d.ts} +10 -10
  17. package/dist/bundles/tween.d.ts +197 -0
  18. package/dist/command-buffer.d.ts +20 -20
  19. package/dist/ecspresso-builder.d.ts +165 -0
  20. package/dist/ecspresso.d.ts +157 -178
  21. package/dist/entity-manager.d.ts +76 -40
  22. package/dist/event-bus.d.ts +6 -1
  23. package/dist/index.d.ts +1 -9
  24. package/dist/reactive-query-manager.d.ts +14 -3
  25. package/dist/resource-manager.d.ts +35 -19
  26. package/dist/screen-manager.d.ts +4 -4
  27. package/dist/screen-types.d.ts +12 -11
  28. package/dist/src/bundles/audio.js +4 -0
  29. package/dist/src/bundles/audio.js.map +10 -0
  30. package/dist/src/bundles/bounds.js +4 -0
  31. package/dist/src/bundles/bounds.js.map +10 -0
  32. package/dist/src/bundles/camera.js +4 -0
  33. package/dist/src/bundles/camera.js.map +10 -0
  34. package/dist/src/bundles/collision.js +4 -0
  35. package/dist/src/bundles/collision.js.map +11 -0
  36. package/dist/src/bundles/diagnostics.js +5 -0
  37. package/dist/src/bundles/diagnostics.js.map +10 -0
  38. package/dist/src/bundles/input.js +4 -0
  39. package/dist/src/bundles/input.js.map +10 -0
  40. package/dist/src/bundles/physics2D.js +4 -0
  41. package/dist/src/bundles/physics2D.js.map +11 -0
  42. package/dist/src/bundles/renderers/renderer2D.js +4 -0
  43. package/dist/src/bundles/renderers/renderer2D.js.map +10 -0
  44. package/dist/src/bundles/spatial-index.js +4 -0
  45. package/dist/src/bundles/spatial-index.js.map +11 -0
  46. package/dist/src/bundles/state-machine.js +4 -0
  47. package/dist/src/bundles/state-machine.js.map +10 -0
  48. package/dist/src/bundles/timers.js +4 -0
  49. package/dist/src/bundles/timers.js.map +10 -0
  50. package/dist/src/bundles/transform.js +4 -0
  51. package/dist/src/bundles/transform.js.map +10 -0
  52. package/dist/src/bundles/tween.js +4 -0
  53. package/dist/src/bundles/tween.js.map +11 -0
  54. package/dist/src/index.js +4 -0
  55. package/dist/src/index.js.map +25 -0
  56. package/dist/system-builder.d.ts +36 -42
  57. package/dist/type-utils.d.ts +52 -3
  58. package/dist/types.d.ts +10 -19
  59. package/dist/utils/check-required-cycle.d.ts +12 -0
  60. package/dist/utils/easing.d.ts +71 -0
  61. package/dist/utils/math.d.ts +67 -0
  62. package/dist/utils/narrowphase.d.ts +63 -0
  63. package/dist/utils/spatial-hash.d.ts +53 -0
  64. package/package.json +50 -20
  65. package/dist/bundles/renderers/renderer2D.js +0 -4
  66. package/dist/bundles/renderers/renderer2D.js.map +0 -10
  67. package/dist/bundles/utils/bounds.js +0 -4
  68. package/dist/bundles/utils/bounds.js.map +0 -10
  69. package/dist/bundles/utils/collision.d.ts +0 -204
  70. package/dist/bundles/utils/collision.js +0 -4
  71. package/dist/bundles/utils/collision.js.map +0 -10
  72. package/dist/bundles/utils/input.js +0 -4
  73. package/dist/bundles/utils/input.js.map +0 -10
  74. package/dist/bundles/utils/movement.d.ts +0 -86
  75. package/dist/bundles/utils/movement.js +0 -4
  76. package/dist/bundles/utils/movement.js.map +0 -10
  77. package/dist/bundles/utils/timers.js +0 -4
  78. package/dist/bundles/utils/timers.js.map +0 -10
  79. package/dist/bundles/utils/transform.js +0 -4
  80. package/dist/bundles/utils/transform.js.map +0 -10
  81. package/dist/index.js +0 -4
  82. package/dist/index.js.map +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecspresso",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,29 +15,53 @@
15
15
  "import": "./dist/bundles/renderers/renderer2D.js",
16
16
  "types": "./dist/bundles/renderers/renderer2D.d.ts"
17
17
  },
18
- "./bundles/utils/timers": {
19
- "import": "./dist/bundles/utils/timers.js",
20
- "types": "./dist/bundles/utils/timers.d.ts"
18
+ "./bundles/bounds": {
19
+ "import": "./dist/bundles/bounds.js",
20
+ "types": "./dist/bundles/bounds.d.ts"
21
21
  },
22
- "./bundles/utils/transform": {
23
- "import": "./dist/bundles/utils/transform.js",
24
- "types": "./dist/bundles/utils/transform.d.ts"
22
+ "./bundles/camera": {
23
+ "import": "./dist/bundles/camera.js",
24
+ "types": "./dist/bundles/camera.d.ts"
25
25
  },
26
- "./bundles/utils/movement": {
27
- "import": "./dist/bundles/utils/movement.js",
28
- "types": "./dist/bundles/utils/movement.d.ts"
26
+ "./bundles/collision": {
27
+ "import": "./dist/bundles/collision.js",
28
+ "types": "./dist/bundles/collision.d.ts"
29
29
  },
30
- "./bundles/utils/bounds": {
31
- "import": "./dist/bundles/utils/bounds.js",
32
- "types": "./dist/bundles/utils/bounds.d.ts"
30
+ "./bundles/diagnostics": {
31
+ "import": "./dist/bundles/diagnostics.js",
32
+ "types": "./dist/bundles/diagnostics.d.ts"
33
33
  },
34
- "./bundles/utils/collision": {
35
- "import": "./dist/bundles/utils/collision.js",
36
- "types": "./dist/bundles/utils/collision.d.ts"
34
+ "./bundles/input": {
35
+ "import": "./dist/bundles/input.js",
36
+ "types": "./dist/bundles/input.d.ts"
37
37
  },
38
- "./bundles/utils/input": {
39
- "import": "./dist/bundles/utils/input.js",
40
- "types": "./dist/bundles/utils/input.d.ts"
38
+ "./bundles/physics2D": {
39
+ "import": "./dist/bundles/physics2D.js",
40
+ "types": "./dist/bundles/physics2D.d.ts"
41
+ },
42
+ "./bundles/spatial-index": {
43
+ "import": "./dist/bundles/spatial-index.js",
44
+ "types": "./dist/bundles/spatial-index.d.ts"
45
+ },
46
+ "./bundles/state-machine": {
47
+ "import": "./dist/bundles/state-machine.js",
48
+ "types": "./dist/bundles/state-machine.d.ts"
49
+ },
50
+ "./bundles/timers": {
51
+ "import": "./dist/bundles/timers.js",
52
+ "types": "./dist/bundles/timers.d.ts"
53
+ },
54
+ "./bundles/transform": {
55
+ "import": "./dist/bundles/transform.js",
56
+ "types": "./dist/bundles/transform.d.ts"
57
+ },
58
+ "./bundles/tween": {
59
+ "import": "./dist/bundles/tween.js",
60
+ "types": "./dist/bundles/tween.d.ts"
61
+ },
62
+ "./bundles/audio": {
63
+ "import": "./dist/bundles/audio.js",
64
+ "types": "./dist/bundles/audio.d.ts"
41
65
  }
42
66
  },
43
67
  "publishConfig": {
@@ -59,17 +83,23 @@
59
83
  ],
60
84
  "devDependencies": {
61
85
  "@types/bun": "latest",
86
+ "@types/howler": "^2.2.12",
62
87
  "@types/three": "^0.180.0",
88
+ "howler": "^2.2.0",
63
89
  "pixi.js": "^8.15.0",
64
90
  "three": "^0.180.0"
65
91
  },
66
92
  "peerDependencies": {
67
93
  "typescript": "^5.9.2",
68
- "pixi.js": "^8.0.0"
94
+ "pixi.js": "^8.0.0",
95
+ "howler": "^2.2.0"
69
96
  },
70
97
  "peerDependenciesMeta": {
71
98
  "pixi.js": {
72
99
  "optional": true
100
+ },
101
+ "howler": {
102
+ "optional": true
73
103
  }
74
104
  },
75
105
  "files": [
@@ -1,4 +0,0 @@
1
- var G=((M)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(M,{get:(Z,J)=>(typeof require<"u"?require:Z)[J]}):M)(function(M){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+M+'" is not supported')});import{Bundle as f,mergeBundles as h}from"ecspresso";import{createTransformBundle as j}from"ecspresso/bundles/utils/transform";import{createBounds as B}from"ecspresso/bundles/utils/bounds";import{createTransform as s,createLocalTransform as r,createWorldTransform as o}from"ecspresso/bundles/utils/transform";async function T(M){let{Application:Z}=await import("pixi.js"),J=new Z;return await J.init(M),J}var b={x:0,y:0,rotation:0,scaleX:1,scaleY:1},m={x:0,y:0,rotation:0,scaleX:1,scaleY:1};function A(M,Z){let J=Z?.scale,E=typeof J==="number"?J:J?.x??1,R=typeof J==="number"?J:J?.y??1;return{x:M?.x??0,y:M?.y??0,rotation:Z?.rotation??0,scaleX:E,scaleY:R}}function L(M,Z){let J=Z?.scale,E=typeof J==="number"?J:J?.x??1,R=typeof J==="number"?J:J?.y??1;return{x:M?.x??0,y:M?.y??0,rotation:Z?.rotation??0,scaleX:E,scaleY:R}}function N(M){return{visible:M?.visible??!0,alpha:M?.alpha}}function y(M,Z,J){if(J?.anchor)M.anchor.set(J.anchor.x,J.anchor.y);return{sprite:M,localTransform:A(Z,J),worldTransform:L(Z,J),visible:N(J)}}function d(M,Z,J){return{graphics:M,localTransform:A(Z,J),worldTransform:L(Z,J),visible:N(J)}}function l(M,Z,J){return{container:M,localTransform:A(Z,J),worldTransform:L(Z,J),visible:N(J)}}function c(M){let{rootContainer:Z,systemGroup:J="renderer2d",renderSyncPriority:E=500,transform:R,startLoop:V=!0,renderLayers:v=[]}=M,k=new f("renderer2d-internal");if("init"in M&&M.init!==void 0){let{init:D,container:Q}=M;k.addResource("pixiApp",async()=>{let U=await T(D);if(Q){let K=typeof Q==="string"?document.querySelector(Q):Q;if(K)K.appendChild(U.canvas);else if(typeof Q==="string")console.warn(`Renderer2D bundle: container selector "${Q}" not found`)}return U}),k.addResource("rootContainer",{dependsOn:["pixiApp"],factory:(U)=>Z??U.getResource("pixiApp").stage}),k.addResource("bounds",{dependsOn:["pixiApp"],factory:(U)=>{let K=U.getResource("pixiApp");return B(K.screen.width,K.screen.height)}})}else{let D=M.app;k.addResource("pixiApp",D),k.addResource("rootContainer",Z??D.stage),k.addResource("bounds",B(D.screen.width,D.screen.height))}let $=new Map,X=new Map,Y;function w(D,Q){let U=$.get(D);if(U)return U;let K=Q.entityManager.getComponent(D,"sprite");if(K)return $.set(D,K),K;let z=Q.entityManager.getComponent(D,"graphics");if(z)return $.set(D,z),z;let H=Q.entityManager.getComponent(D,"container");if(H)return $.set(D,H),H;return null}function P(D,Q){let U=X.get(D);if(U)return U;let K=Y(`layer:${D}`);return X.set(D,K),Q.addChild(K),K}function S(D,Q){let U=Q.getResource("rootContainer"),K=Q.getParent(D),z=K!==null?w(K,Q):null;if(z)return z;let H=Q.entityManager.getComponent(D,"renderLayer");if(H)return P(H,U);return U}function F(D,Q,U){let K=S(D,U);if(Q.parent!==K)K.addChild(Q)}function W(D){let Q=$.get(D);if(Q)Q.removeFromParent(),$.delete(D)}function q(D,Q){let U=$.get(D);if(!U)return;let K=S(D,Q);if(U.parent!==K)U.removeFromParent(),K.addChild(U)}k.addSystem("renderer2d-sync").setPriority(E).inPhase("render").inGroup(J).addQuery("sprites",{with:["sprite","worldTransform"],changed:["worldTransform"]}).addQuery("graphics",{with:["graphics","worldTransform"],changed:["worldTransform"]}).addQuery("containers",{with:["container","worldTransform"],changed:["worldTransform"]}).setProcess((D,Q,U)=>{for(let K of D.sprites){let{sprite:z,worldTransform:H}=K.components;z.position.set(H.x,H.y),z.rotation=H.rotation,z.scale.set(H.scaleX,H.scaleY);let _=U.entityManager.getComponent(K.id,"visible");if(_){if(z.visible=_.visible,_.alpha!==void 0)z.alpha=_.alpha}}for(let K of D.graphics){let{graphics:z,worldTransform:H}=K.components;z.position.set(H.x,H.y),z.rotation=H.rotation,z.scale.set(H.scaleX,H.scaleY);let _=U.entityManager.getComponent(K.id,"visible");if(_){if(z.visible=_.visible,_.alpha!==void 0)z.alpha=_.alpha}}for(let K of D.containers){let{container:z,worldTransform:H}=K.components;z.position.set(H.x,H.y),z.rotation=H.rotation,z.scale.set(H.scaleX,H.scaleY);let _=U.entityManager.getComponent(K.id,"visible");if(_){if(z.visible=_.visible,_.alpha!==void 0)z.alpha=_.alpha}}}).and(),k.addSystem("renderer2d-scene-graph").setPriority(9999).inGroup(J).setOnInitialize(async(D)=>{let Q=D.getResource("pixiApp"),U=D.getResource("rootContainer"),{Container:K}=await import("pixi.js");Y=(z)=>{let H=new K;return H.label=z,H};for(let z of v){let H=Y(`layer:${z}`);X.set(z,H),U.addChild(H)}if(D.addReactiveQuery("renderer2d-sprites",{with:["sprite"],onEnter:(z)=>{let H=z.components.sprite;$.set(z.id,H),F(z.id,H,D)},onExit:(z)=>{W(z)}}),D.addReactiveQuery("renderer2d-graphics",{with:["graphics"],onEnter:(z)=>{let H=z.components.graphics;$.set(z.id,H),F(z.id,H,D)},onExit:(z)=>{W(z)}}),D.addReactiveQuery("renderer2d-containers",{with:["container"],onEnter:(z)=>{let H=z.components.container;$.set(z.id,H),F(z.id,H,D)},onExit:(z)=>{W(z)}}),D.on("hierarchyChanged",({entityId:z})=>{q(z,D)}),D.onComponentAdded("renderLayer",(z,H)=>{q(H.id,D)}),D.onComponentRemoved("renderLayer",(z,H)=>{q(H.id,D)}),Q.renderer.on("resize",(z,H)=>{let _=D.getResource("bounds");_.width=z,_.height=H}),V)Q.ticker.add((z)=>{D.update(z.deltaMS/1000)})}).and();let g=j(R);return h("renderer2d",g,k)}export{o as createWorldTransform,s as createTransform,y as createSpriteComponents,c as createRenderer2DBundle,r as createLocalTransform,d as createGraphicsComponents,l as createContainerComponents,m as DEFAULT_WORLD_TRANSFORM,b as DEFAULT_LOCAL_TRANSFORM};
2
-
3
- //# debugId=BB9BA06A6FF5407264756E2164756E21
4
- //# sourceMappingURL=renderer2D.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/bundles/renderers/renderer2D.ts"],
4
- "sourcesContent": [
5
- "/**\n * 2D Renderer Bundle for ECSpresso\n *\n * An opt-in PixiJS-based 2D rendering bundle that automates scene graph wiring.\n * Import from 'ecspresso/bundles/renderers/renderer2D'\n *\n * This bundle includes transform propagation automatically.\n */\n\nimport type { Application, ApplicationOptions, Container, Sprite, Graphics } from 'pixi.js';\nimport { Bundle, mergeBundles } from 'ecspresso';\nimport type ECSpresso from 'ecspresso';\nimport {\n\tcreateTransformBundle,\n\ttype LocalTransform,\n\ttype WorldTransform,\n\ttype TransformComponentTypes,\n\ttype TransformBundleOptions,\n} from 'ecspresso/bundles/utils/transform';\nimport { createBounds, type BoundsRect } from 'ecspresso/bundles/utils/bounds';\n\n// Re-export transform and bounds types for convenience\nexport type { LocalTransform, WorldTransform, TransformComponentTypes };\nexport type { BoundsRect };\nexport { createTransform, createLocalTransform, createWorldTransform } from 'ecspresso/bundles/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 * Visibility and alpha component\n */\nexport interface Visible {\n\tvisible: boolean;\n\talpha?: number;\n}\n\n/**\n * Aggregate component types for the 2D renderer bundle.\n * Users should extend this interface with their own component types.\n *\n * @example\n * ```typescript\n * interface GameComponents extends Renderer2DComponentTypes {\n * velocity: { x: number; y: number };\n * player: true;\n * }\n * ```\n */\nexport interface Renderer2DComponentTypes extends TransformComponentTypes {\n\tsprite: Sprite;\n\tgraphics: Graphics;\n\tcontainer: Container;\n\tvisible: Visible;\n\t/** Assigns the entity to a named render layer for z-ordering */\n\trenderLayer: string;\n}\n\n// ==================== Event Types ====================\n\n/**\n * Events emitted by the 2D renderer bundle\n */\nexport interface Renderer2DEventTypes {\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 2D renderer bundle\n */\nexport interface Renderer2DResourceTypes {\n\tpixiApp: Application;\n\trootContainer: Container;\n\t/** Screen bounds derived from PixiJS screen dimensions, updated on resize */\n\tbounds: BoundsRect;\n}\n\n// ==================== Bundle Options ====================\n\n/**\n * Common options shared between both initialization modes\n */\ninterface Renderer2DBundleCommonOptions {\n\t/** Optional custom root container (defaults to app.stage) */\n\trootContainer?: Container;\n\t/** System group name (default: 'renderer2d') */\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\t/** When true, wires up pixiApp.ticker to drive ecs.update() automatically (default: true) */\n\tstartLoop?: boolean;\n\t/** Ordered render layer names (back-to-front). Entities with a renderLayer component are placed in the corresponding container. */\n\trenderLayers?: string[];\n}\n\n/**\n * Options when providing a pre-initialized PixiJS Application\n */\nexport interface Renderer2DBundleAppOptions extends Renderer2DBundleCommonOptions {\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 Renderer2DBundleManagedOptions extends Renderer2DBundleCommonOptions {\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 2D renderer 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(createRenderer2DBundle({ app }))\n * .build();\n * ```\n *\n * @example Managed mode (convenience)\n * ```typescript\n * const ecs = ECSpresso.create<GameComponents, {}, {}>()\n * .withBundle(createRenderer2DBundle({\n * init: { background: '#1099bb', resizeTo: window },\n * container: document.body,\n * }))\n * .build();\n * await ecs.initialize(); // Application created here\n * ```\n */\nexport type Renderer2DBundleOptions = Renderer2DBundleAppOptions | Renderer2DBundleManagedOptions;\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};\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};\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): Visible {\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<Renderer2DComponentTypes, 'sprite' | 'localTransform' | 'worldTransform' | 'visible'> {\n\tif (options?.anchor) {\n\t\tsprite.anchor.set(options.anchor.x, options.anchor.y);\n\t}\n\treturn {\n\t\tsprite,\n\t\tlocalTransform: createLocalTransformInternal(position, options),\n\t\tworldTransform: createWorldTransformInternal(position, options),\n\t\tvisible: 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<Renderer2DComponentTypes, 'graphics' | 'localTransform' | 'worldTransform' | 'visible'> {\n\treturn {\n\t\tgraphics,\n\t\tlocalTransform: createLocalTransformInternal(position, options),\n\t\tworldTransform: createWorldTransformInternal(position, options),\n\t\tvisible: 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<Renderer2DComponentTypes, 'container' | 'localTransform' | 'worldTransform' | 'visible'> {\n\treturn {\n\t\tcontainer,\n\t\tlocalTransform: createLocalTransformInternal(position, options),\n\t\tworldTransform: createWorldTransformInternal(position, options),\n\t\tvisible: createVisibleComponent(options),\n\t};\n}\n\n// ==================== Bundle Factory ====================\n\n/**\n * Create a 2D 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(createRenderer2DBundle({ app }))\n * .build();\n * ```\n *\n * @example Managed mode\n * ```typescript\n * const ecs = ECSpresso.create<GameComponents, {}, {}>()\n * .withBundle(createRenderer2DBundle({\n * init: { background: '#1099bb', resizeTo: window },\n * container: document.body,\n * }))\n * .build();\n * await ecs.initialize();\n * ```\n */\nexport function createRenderer2DBundle(\n\toptions: Renderer2DBundleOptions\n): Bundle<Renderer2DComponentTypes, Renderer2DEventTypes, Renderer2DResourceTypes> {\n\tconst {\n\t\trootContainer: customRootContainer,\n\t\tsystemGroup = 'renderer2d',\n\t\trenderSyncPriority = 500,\n\t\ttransform: transformOptions,\n\t\tstartLoop = true,\n\t\trenderLayers = [],\n\t} = options;\n\n\tconst rendererBundle = new Bundle<Renderer2DComponentTypes, Renderer2DEventTypes, Renderer2DResourceTypes>('renderer2d-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\trendererBundle.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(`Renderer2D 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// rootContainer depends on pixiApp - declarative dependency\n\t\trendererBundle.addResource('rootContainer', {\n\t\t\tdependsOn: ['pixiApp'],\n\t\t\tfactory: (ecs) => customRootContainer ?? ecs.getResource('pixiApp').stage,\n\t\t});\n\n\t\t// Bounds resource derived from screen dimensions\n\t\trendererBundle.addResource('bounds', {\n\t\t\tdependsOn: ['pixiApp'],\n\t\t\tfactory: (ecs) => {\n\t\t\t\tconst pixiApp = ecs.getResource('pixiApp');\n\t\t\t\treturn createBounds(pixiApp.screen.width, pixiApp.screen.height);\n\t\t\t},\n\t\t});\n\t} else {\n\t\t// Pre-initialized mode: use provided Application\n\t\tconst app = options.app;\n\t\trendererBundle.addResource('pixiApp', app);\n\t\trendererBundle.addResource('rootContainer', customRootContainer ?? app.stage);\n\t\trendererBundle.addResource('bounds', createBounds(app.screen.width, app.screen.height));\n\t}\n\n\t// Entity ID -> PixiJS Container mapping for scene graph management\n\tconst entityToPixiObject = new Map<number, Container>();\n\n\t// Render layer name -> PixiJS Container mapping\n\tconst layerContainers = new Map<string, Container>();\n\n\t// Container constructor captured during initialization via dynamic import\n\t// Used by getOrCreateLayerContainer for lazy layer creation\n\tlet createLayerContainer: (label: string) => Container;\n\n\t// Helper to get the PixiJS display object for an entity\n\tfunction getPixiObject(entityId: number, ecs: ECSpresso<Renderer2DComponentTypes, Renderer2DEventTypes, Renderer2DResourceTypes>): 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, 'sprite');\n\t\tif (spriteComp) {\n\t\t\tentityToPixiObject.set(entityId, spriteComp);\n\t\t\treturn spriteComp;\n\t\t}\n\n\t\tconst graphicsComp = ecs.entityManager.getComponent(entityId, 'graphics');\n\t\tif (graphicsComp) {\n\t\t\tentityToPixiObject.set(entityId, graphicsComp);\n\t\t\treturn graphicsComp;\n\t\t}\n\n\t\tconst containerComp = ecs.entityManager.getComponent(entityId, 'container');\n\t\tif (containerComp) {\n\t\t\tentityToPixiObject.set(entityId, containerComp);\n\t\t\treturn containerComp;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t// Helper to get or create a render layer container\n\tfunction getOrCreateLayerContainer(\n\t\tlayerName: string,\n\t\trootCont: Container\n\t): Container {\n\t\tconst existing = layerContainers.get(layerName);\n\t\tif (existing) return existing;\n\n\t\t// Lazy-create for undeclared layers, appended to end\n\t\tconst cont = createLayerContainer(`layer:${layerName}`);\n\t\tlayerContainers.set(layerName, cont);\n\t\trootCont.addChild(cont);\n\t\treturn cont;\n\t}\n\n\t// Helper to resolve the target container for an entity\n\tfunction resolveTargetContainer(\n\t\tentityId: number,\n\t\tecs: ECSpresso<Renderer2DComponentTypes, Renderer2DEventTypes, Renderer2DResourceTypes>\n\t): Container {\n\t\tconst rootCont = ecs.getResource('rootContainer');\n\n\t\t// 1. Check ECS parent hierarchy\n\t\tconst parentId = ecs.getParent(entityId);\n\t\tconst parentPixiObject = parentId !== null ? getPixiObject(parentId, ecs) : null;\n\t\tif (parentPixiObject) return parentPixiObject;\n\n\t\t// 2. Check render layer component\n\t\tconst layerName = ecs.entityManager.getComponent(entityId, 'renderLayer');\n\t\tif (layerName) return getOrCreateLayerContainer(layerName, rootCont);\n\n\t\t// 3. Fall back to root container\n\t\treturn rootCont;\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<Renderer2DComponentTypes, Renderer2DEventTypes, Renderer2DResourceTypes>\n\t): void {\n\t\tconst targetContainer = resolveTargetContainer(entityId, ecs);\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<Renderer2DComponentTypes, Renderer2DEventTypes, Renderer2DResourceTypes>\n\t): void {\n\t\tconst pixiObject = entityToPixiObject.get(entityId);\n\t\tif (!pixiObject) return;\n\n\t\tconst targetContainer = resolveTargetContainer(entityId, ecs);\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\trendererBundle\n\t\t.addSystem('renderer2d-sync')\n\t\t.setPriority(renderSyncPriority)\n\t\t.inPhase('render')\n\t\t.inGroup(systemGroup)\n\t\t.addQuery('sprites', {\n\t\t\twith: ['sprite', 'worldTransform'],\n\t\t\tchanged: ['worldTransform'],\n\t\t})\n\t\t.addQuery('graphics', {\n\t\t\twith: ['graphics', 'worldTransform'],\n\t\t\tchanged: ['worldTransform'],\n\t\t})\n\t\t.addQuery('containers', {\n\t\t\twith: ['container', 'worldTransform'],\n\t\t\tchanged: ['worldTransform'],\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 { sprite, worldTransform } = entity.components;\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\t// Apply visibility if component exists\n\t\t\t\tconst visibleComp = ecs.entityManager.getComponent(entity.id, 'visible');\n\t\t\t\tif (visibleComp) {\n\t\t\t\t\tsprite.visible = visibleComp.visible;\n\t\t\t\t\tif (visibleComp.alpha !== undefined) {\n\t\t\t\t\t\tsprite.alpha = visibleComp.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 { graphics, worldTransform } = entity.components;\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 visibleComp = ecs.entityManager.getComponent(entity.id, 'visible');\n\t\t\t\tif (visibleComp) {\n\t\t\t\t\tgraphics.visible = visibleComp.visible;\n\t\t\t\t\tif (visibleComp.alpha !== undefined) {\n\t\t\t\t\t\tgraphics.alpha = visibleComp.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 { container, worldTransform } = entity.components;\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 visibleComp = ecs.entityManager.getComponent(entity.id, 'visible');\n\t\t\t\tif (visibleComp) {\n\t\t\t\t\tcontainer.visible = visibleComp.visible;\n\t\t\t\t\tif (visibleComp.alpha !== undefined) {\n\t\t\t\t\t\tcontainer.alpha = visibleComp.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\trendererBundle\n\t\t.addSystem('renderer2d-scene-graph')\n\t\t.setPriority(9999)\n\t\t.inGroup(systemGroup)\n\t\t.setOnInitialize(async (ecs) => {\n\t\t\tconst pixiApp = ecs.getResource('pixiApp');\n\t\t\tconst rootCont = ecs.getResource('rootContainer');\n\n\t\t\t// Capture Container constructor via dynamic import (same module instance as pixi.js internals)\n\t\t\tconst { Container: ContainerClass } = await import('pixi.js');\n\t\t\tcreateLayerContainer = (label: string) => {\n\t\t\t\tconst cont = new ContainerClass();\n\t\t\t\tcont.label = label;\n\t\t\t\treturn cont;\n\t\t\t};\n\n\t\t\t// Create declared render layer containers in order (back-to-front)\n\t\t\tfor (const layerName of renderLayers) {\n\t\t\t\tconst cont = createLayerContainer(`layer:${layerName}`);\n\t\t\t\tlayerContainers.set(layerName, cont);\n\t\t\t\trootCont.addChild(cont);\n\t\t\t}\n\n\t\t\t// Reactive query for sprites\n\t\t\tecs.addReactiveQuery('renderer2d-sprites', {\n\t\t\t\twith: ['sprite'],\n\t\t\t\tonEnter: (entity) => {\n\t\t\t\t\tconst pixiObject = entity.components.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('renderer2d-graphics', {\n\t\t\t\twith: ['graphics'],\n\t\t\t\tonEnter: (entity) => {\n\t\t\t\t\tconst pixiObject = entity.components.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('renderer2d-containers', {\n\t\t\t\twith: ['container'],\n\t\t\t\tonEnter: (entity) => {\n\t\t\t\t\tconst pixiObject = entity.components.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\n\t\t\t// Re-parent entity when render layer is added or changed\n\t\t\tecs.onComponentAdded('renderLayer', (_layerName, entity) => {\n\t\t\t\tupdateSceneGraphParent(entity.id, ecs);\n\t\t\t});\n\n\t\t\t// Re-parent entity when render layer is removed\n\t\t\tecs.onComponentRemoved('renderLayer', (_oldLayerName, entity) => {\n\t\t\t\tupdateSceneGraphParent(entity.id, ecs);\n\t\t\t});\n\n\t\t\t// Track screen bounds on resize\n\t\t\tpixiApp.renderer.on('resize', (width: number, height: number) => {\n\t\t\t\tconst bounds = ecs.getResource('bounds');\n\t\t\t\tbounds.width = width;\n\t\t\t\tbounds.height = height;\n\t\t\t});\n\n\t\t\t// Wire up the game loop if requested\n\t\t\tif (startLoop) {\n\t\t\t\tpixiApp.ticker.add((ticker) => {\n\t\t\t\t\tecs.update(ticker.deltaMS / 1_000);\n\t\t\t\t});\n\t\t\t}\n\t\t})\n\t\t.and();\n\n\t// Merge transform bundle (runs first) with renderer bundle\n\tconst transformBundle = createTransformBundle(transformOptions);\n\treturn mergeBundles('renderer2d', transformBundle, rendererBundle);\n}\n"
6
- ],
7
- "mappings": "2PAUA,iBAAS,kBAAQ,kBAEjB,gCACC,0CAMD,uBAAS,uCAKT,0BAAS,0BAAiB,0BAAsB,0CAIhD,eAAe,CAAqB,CAAC,EAA4D,CAChG,IAAQ,eAAgB,KAAa,mBAC/B,EAAM,IAAI,EAEhB,OADA,MAAM,EAAI,KAAK,CAAO,EACf,EAwID,IAAM,EAAoD,CAChE,EAAG,EACH,EAAG,EACH,SAAU,EACV,OAAQ,EACR,OAAQ,CACT,EAKa,EAAoD,CAChE,EAAG,EACH,EAAG,EACH,SAAU,EACV,OAAQ,EACR,OAAQ,CACT,EAgBA,SAAS,CAA4B,CACpC,EACA,EACiB,CACjB,IAAM,EAAa,GAAS,MACtB,EAAS,OAAO,IAAe,SAClC,EACA,GAAY,GAAK,EACd,EAAS,OAAO,IAAe,SAClC,EACA,GAAY,GAAK,EAEpB,MAAO,CACN,EAAG,GAAU,GAAK,EAClB,EAAG,GAAU,GAAK,EAClB,SAAU,GAAS,UAAY,EAC/B,SACA,QACD,EAGD,SAAS,CAA4B,CACpC,EACA,EACiB,CACjB,IAAM,EAAa,GAAS,MACtB,EAAS,OAAO,IAAe,SAClC,EACA,GAAY,GAAK,EACd,EAAS,OAAO,IAAe,SAClC,EACA,GAAY,GAAK,EAEpB,MAAO,CACN,EAAG,GAAU,GAAK,EAClB,EAAG,GAAU,GAAK,EAClB,SAAU,GAAS,UAAY,EAC/B,SACA,QACD,EAGD,SAAS,CAAsB,CAAC,EAAqC,CACpE,MAAO,CACN,QAAS,GAAS,SAAW,GAC7B,MAAO,GAAS,KACjB,EAeM,SAAS,CAAsB,CACrC,EACA,EACA,EAC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"?require:I)[F]}):j)(function(j){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+j+'" is not supported')});import{Bundle as E}from"ecspresso";function h(j,I,F,Q){let U={width:j,height:I};if(F!==void 0)U.x=F;if(Q!==void 0)U.y=Q;return U}function T(j){return{destroyOutOfBounds:j!==void 0?{padding:j}:{}}}function y(j){return{clampToBounds:j!==void 0?{margin:j}:{}}}function x(j){return{wrapAtBounds:j!==void 0?{padding:j}:{}}}function b(j){let{systemGroup:I="physics",priority:F=50,boundsResourceKey:Q="bounds",autoRemove:U=!0,phase:S="postUpdate"}=j??{},W=new E("bounds");return W.addSystem("bounds-destroy").setPriority(F).inPhase(S).inGroup(I).addQuery("entities",{with:["worldTransform","destroyOutOfBounds"]}).setProcess((A,B,J)=>{let C=J.getResource(Q),L=C.x??0,N=C.y??0,$=L+C.width,v=N+C.height;for(let P of A.entities){let{worldTransform:V,destroyOutOfBounds:z}=P.components,D=z.padding??0,k=R(V,L,N,$,v,D);if(!k)continue;if(J.eventBus.publish("entityOutOfBounds",{entityId:P.id,exitEdge:k}),U)J.commands.removeEntity(P.id)}}).and(),W.addSystem("bounds-clamp").setPriority(F-1).inPhase(S).inGroup(I).addQuery("entities",{with:["localTransform","worldTransform","clampToBounds"]}).setProcess((A,B,J)=>{let C=J.getResource(Q),L=C.x??0,N=C.y??0,$=L+C.width,v=N+C.height;for(let P of A.entities){let{localTransform:V,worldTransform:z,clampToBounds:D}=P.components,k=D.margin??0,Z=L+k,_=N+k,H=$-k,O=v-k,G=0,K=0;if(z.x<Z)G=Z-z.x;if(z.x>H)G=H-z.x;if(z.y<_)K=_-z.y;if(z.y>O)K=O-z.y;if(G!==0||K!==0)V.x+=G,V.y+=K,J.markChanged(P.id,"localTransform")}}).and(),W.addSystem("bounds-wrap").setPriority(F-2).inPhase(S).inGroup(I).addQuery("entities",{with:["localTransform","worldTransform","wrapAtBounds"]}).setProcess((A,B,J)=>{let C=J.getResource(Q),L=C.x??0,N=C.y??0,$=L+C.width,v=N+C.height;for(let P of A.entities){let{localTransform:V,worldTransform:z,wrapAtBounds:D}=P.components,k=D.padding??0,Z=0,_=0,H=$-L,O=v-N;if(z.x>$+k)Z=-(H+2*k);else if(z.x<L-k)Z=H+2*k;if(z.y>v+k)_=-(O+2*k);else if(z.y<N-k)_=O+2*k;if(Z!==0||_!==0)V.x+=Z,V.y+=_,J.markChanged(P.id,"localTransform")}}).and(),W}function R(j,I,F,Q,U,S){if(j.x>Q+S)return"right";if(j.x<I-S)return"left";if(j.y>U+S)return"bottom";if(j.y<F-S)return"top";return null}export{x as createWrapAtBounds,T as createDestroyOutOfBounds,y as createClampToBounds,b as createBoundsBundle,h as createBounds};
2
-
3
- //# debugId=8FF1EB3AF1C6181164756E2164756E21
4
- //# sourceMappingURL=bounds.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/bundles/utils/bounds.ts"],
4
- "sourcesContent": [
5
- "/**\n * Bounds Bundle for ECSpresso\n *\n * Provides screen bounds enforcement for entities with transforms.\n * Reads worldTransform for position checking; modifies localTransform for corrections.\n * Supports destroy, clamp, and wrap behaviors.\n */\n\nimport { Bundle } from 'ecspresso';\nimport type { SystemPhase } from 'ecspresso';\nimport type { TransformComponentTypes } from './transform';\n\n// ==================== Component Types ====================\n\n/**\n * Component that marks an entity for destruction when outside bounds.\n */\nexport interface DestroyOutOfBounds {\n\t/** Extra padding beyond bounds before destruction (default: 0) */\n\tpadding?: number;\n}\n\n/**\n * Component that clamps an entity's position to stay within bounds.\n */\nexport interface ClampToBounds {\n\t/** Margin to shrink the valid area (default: 0) */\n\tmargin?: number;\n}\n\n/**\n * Component that wraps an entity's position to the opposite edge.\n */\nexport interface WrapAtBounds {\n\t/** Padding beyond bounds before wrapping (default: 0) */\n\tpadding?: number;\n}\n\n/**\n * Component types provided by the bounds bundle.\n * Extend your component types with this interface.\n *\n * @example\n * ```typescript\n * interface GameComponents extends TransformComponentTypes, BoundsComponentTypes {\n * sprite: Sprite;\n * }\n * ```\n */\nexport interface BoundsComponentTypes {\n\tdestroyOutOfBounds: DestroyOutOfBounds;\n\tclampToBounds: ClampToBounds;\n\twrapAtBounds: WrapAtBounds;\n}\n\n// ==================== Resource Types ====================\n\n/**\n * Bounds rectangle definition.\n */\nexport interface BoundsRect {\n\t/** Left edge x coordinate (default: 0) */\n\tx?: number;\n\t/** Top edge y coordinate (default: 0) */\n\ty?: number;\n\t/** Width of the bounds area */\n\twidth: number;\n\t/** Height of the bounds area */\n\theight: number;\n}\n\n/**\n * Resource types provided by the bounds bundle.\n */\nexport interface BoundsResourceTypes {\n\tbounds: BoundsRect;\n}\n\n// ==================== Event Types ====================\n\n/**\n * Event fired when an entity exits bounds.\n */\nexport interface EntityOutOfBoundsEvent {\n\t/** The entity that exited bounds */\n\tentityId: number;\n\t/** The edge the entity exited through */\n\texitEdge: 'top' | 'bottom' | 'left' | 'right';\n}\n\n/**\n * Event types provided by the bounds bundle.\n */\nexport interface BoundsEventTypes {\n\tentityOutOfBounds: EntityOutOfBoundsEvent;\n}\n\n// ==================== Bundle Options ====================\n\n/**\n * Configuration options for the bounds bundle.\n */\nexport interface BoundsBundleOptions {\n\t/** System group name (default: 'physics') */\n\tsystemGroup?: string;\n\t/** Priority for bounds systems (default: 50) */\n\tpriority?: number;\n\t/** Resource key for bounds rectangle (default: 'bounds') */\n\tboundsResourceKey?: string;\n\t/** Whether to auto-remove entities when out of bounds (default: true) */\n\tautoRemove?: boolean;\n\t/** Execution phase (default: 'postUpdate') */\n\tphase?: SystemPhase;\n}\n\n// ==================== Helper Functions ====================\n\n/**\n * Create a bounds rectangle resource.\n *\n * @param width The width of the bounds area\n * @param height The height of the bounds area\n * @param x The left edge x coordinate (default: 0)\n * @param y The top edge y coordinate (default: 0)\n * @returns Bounds rectangle suitable for use as a resource\n *\n * @example\n * ```typescript\n * ECSpresso.create()\n * .withResource('bounds', createBounds(800, 600))\n * .build();\n * ```\n */\nexport function createBounds(width: number, height: number, x?: number, y?: number): BoundsRect {\n\tconst bounds: BoundsRect = { width, height };\n\tif (x !== undefined) bounds.x = x;\n\tif (y !== undefined) bounds.y = y;\n\treturn bounds;\n}\n\n/**\n * Create a destroyOutOfBounds component.\n *\n * @param padding Extra padding beyond bounds before destruction\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createDestroyOutOfBounds(20),\n * });\n * ```\n */\nexport function createDestroyOutOfBounds(padding?: number): Pick<BoundsComponentTypes, 'destroyOutOfBounds'> {\n\treturn {\n\t\tdestroyOutOfBounds: padding !== undefined ? { padding } : {},\n\t};\n}\n\n/**\n * Create a clampToBounds component.\n *\n * @param margin Margin to shrink the valid area\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createClampToBounds(30),\n * });\n * ```\n */\nexport function createClampToBounds(margin?: number): Pick<BoundsComponentTypes, 'clampToBounds'> {\n\treturn {\n\t\tclampToBounds: margin !== undefined ? { margin } : {},\n\t};\n}\n\n/**\n * Create a wrapAtBounds component.\n *\n * @param padding Padding beyond bounds before wrapping\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createWrapAtBounds(10),\n * });\n * ```\n */\nexport function createWrapAtBounds(padding?: number): Pick<BoundsComponentTypes, 'wrapAtBounds'> {\n\treturn {\n\t\twrapAtBounds: padding !== undefined ? { padding } : {},\n\t};\n}\n\n// ==================== Internal Types ====================\n\ntype CombinedComponentTypes = BoundsComponentTypes & TransformComponentTypes;\n\n// ==================== Bundle Factory ====================\n\n/**\n * Create a bounds bundle for ECSpresso.\n *\n * This bundle provides:\n * - Destroy out of bounds system - removes entities that exit bounds\n * - Clamp to bounds system - constrains entities within bounds\n * - Wrap at bounds system - wraps entities to opposite edge\n *\n * Uses worldTransform for position checking (world-space) and modifies\n * localTransform for corrections. Works best with entities that don't\n * have parent transforms (orphan entities).\n *\n * @example\n * ```typescript\n * const ecs = ECSpresso\n * .create<Components, Events, Resources>()\n * .withResource('bounds', createBounds(800, 600))\n * .withBundle(createTransformBundle())\n * .withBundle(createBoundsBundle())\n * .build();\n *\n * // Entity that gets destroyed when leaving screen\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createDestroyOutOfBounds(),\n * });\n * ```\n */\nexport function createBoundsBundle<ResourceTypes extends BoundsResourceTypes = BoundsResourceTypes>(\n\toptions?: BoundsBundleOptions\n): Bundle<CombinedComponentTypes, BoundsEventTypes, ResourceTypes> {\n\tconst {\n\t\tsystemGroup = 'physics',\n\t\tpriority = 50,\n\t\tboundsResourceKey = 'bounds',\n\t\tautoRemove = true,\n\t\tphase = 'postUpdate',\n\t} = options ?? {};\n\n\tconst bundle = new Bundle<CombinedComponentTypes, BoundsEventTypes, ResourceTypes>('bounds');\n\n\t// Destroy out of bounds system\n\tbundle\n\t\t.addSystem('bounds-destroy')\n\t\t.setPriority(priority)\n\t\t.inPhase(phase)\n\t\t.inGroup(systemGroup)\n\t\t.addQuery('entities', {\n\t\t\twith: ['worldTransform', 'destroyOutOfBounds'],\n\t\t})\n\t\t.setProcess((queries, _deltaTime, ecs) => {\n\t\t\tconst bounds = ecs.getResource(boundsResourceKey as keyof ResourceTypes) as BoundsRect;\n\t\t\tconst minX = bounds.x ?? 0;\n\t\t\tconst minY = bounds.y ?? 0;\n\t\t\tconst maxX = minX + bounds.width;\n\t\t\tconst maxY = minY + bounds.height;\n\n\t\t\tfor (const entity of queries.entities) {\n\t\t\t\tconst { worldTransform, destroyOutOfBounds } = entity.components;\n\t\t\t\tconst padding = destroyOutOfBounds.padding ?? 0;\n\n\t\t\t\tconst exitEdge = getExitEdge(worldTransform, minX, minY, maxX, maxY, padding);\n\t\t\t\tif (!exitEdge) continue;\n\n\t\t\t\tecs.eventBus.publish('entityOutOfBounds', {\n\t\t\t\t\tentityId: entity.id,\n\t\t\t\t\texitEdge,\n\t\t\t\t});\n\n\t\t\t\tif (autoRemove) {\n\t\t\t\t\tecs.commands.removeEntity(entity.id);\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.and();\n\n\t// Clamp to bounds system\n\tbundle\n\t\t.addSystem('bounds-clamp')\n\t\t.setPriority(priority - 1)\n\t\t.inPhase(phase)\n\t\t.inGroup(systemGroup)\n\t\t.addQuery('entities', {\n\t\t\twith: ['localTransform', 'worldTransform', 'clampToBounds'],\n\t\t})\n\t\t.setProcess((queries, _deltaTime, ecs) => {\n\t\t\tconst bounds = ecs.getResource(boundsResourceKey as keyof ResourceTypes) as BoundsRect;\n\t\t\tconst minX = bounds.x ?? 0;\n\t\t\tconst minY = bounds.y ?? 0;\n\t\t\tconst maxX = minX + bounds.width;\n\t\t\tconst maxY = minY + bounds.height;\n\n\t\t\tfor (const entity of queries.entities) {\n\t\t\t\tconst { localTransform, worldTransform, clampToBounds } = entity.components;\n\t\t\t\tconst margin = clampToBounds.margin ?? 0;\n\n\t\t\t\tconst clampedMinX = minX + margin;\n\t\t\t\tconst clampedMinY = minY + margin;\n\t\t\t\tconst clampedMaxX = maxX - margin;\n\t\t\t\tconst clampedMaxY = maxY - margin;\n\n\t\t\t\t// Calculate world-space correction and apply to local transform\n\t\t\t\t// For entities without parents, this is equivalent to direct position clamping\n\t\t\t\tlet deltaX = 0;\n\t\t\t\tlet deltaY = 0;\n\n\t\t\t\tif (worldTransform.x < clampedMinX) deltaX = clampedMinX - worldTransform.x;\n\t\t\t\tif (worldTransform.x > clampedMaxX) deltaX = clampedMaxX - worldTransform.x;\n\t\t\t\tif (worldTransform.y < clampedMinY) deltaY = clampedMinY - worldTransform.y;\n\t\t\t\tif (worldTransform.y > clampedMaxY) deltaY = clampedMaxY - worldTransform.y;\n\n\t\t\t\tif (deltaX !== 0 || deltaY !== 0) {\n\t\t\t\t\tlocalTransform.x += deltaX;\n\t\t\t\t\tlocalTransform.y += deltaY;\n\t\t\t\t\tecs.markChanged(entity.id, 'localTransform');\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.and();\n\n\t// Wrap at bounds system\n\tbundle\n\t\t.addSystem('bounds-wrap')\n\t\t.setPriority(priority - 2)\n\t\t.inPhase(phase)\n\t\t.inGroup(systemGroup)\n\t\t.addQuery('entities', {\n\t\t\twith: ['localTransform', 'worldTransform', 'wrapAtBounds'],\n\t\t})\n\t\t.setProcess((queries, _deltaTime, ecs) => {\n\t\t\tconst bounds = ecs.getResource(boundsResourceKey as keyof ResourceTypes) as BoundsRect;\n\t\t\tconst minX = bounds.x ?? 0;\n\t\t\tconst minY = bounds.y ?? 0;\n\t\t\tconst maxX = minX + bounds.width;\n\t\t\tconst maxY = minY + bounds.height;\n\n\t\t\tfor (const entity of queries.entities) {\n\t\t\t\tconst { localTransform, worldTransform, wrapAtBounds } = entity.components;\n\t\t\t\tconst padding = wrapAtBounds.padding ?? 0;\n\n\t\t\t\tlet deltaX = 0;\n\t\t\t\tlet deltaY = 0;\n\t\t\t\tconst boundsWidth = maxX - minX;\n\t\t\t\tconst boundsHeight = maxY - minY;\n\n\t\t\t\t// Wrap horizontally\n\t\t\t\tif (worldTransform.x > maxX + padding) {\n\t\t\t\t\tdeltaX = -(boundsWidth + 2 * padding);\n\t\t\t\t} else if (worldTransform.x < minX - padding) {\n\t\t\t\t\tdeltaX = boundsWidth + 2 * padding;\n\t\t\t\t}\n\n\t\t\t\t// Wrap vertically\n\t\t\t\tif (worldTransform.y > maxY + padding) {\n\t\t\t\t\tdeltaY = -(boundsHeight + 2 * padding);\n\t\t\t\t} else if (worldTransform.y < minY - padding) {\n\t\t\t\t\tdeltaY = boundsHeight + 2 * padding;\n\t\t\t\t}\n\n\t\t\t\tif (deltaX !== 0 || deltaY !== 0) {\n\t\t\t\t\tlocalTransform.x += deltaX;\n\t\t\t\t\tlocalTransform.y += deltaY;\n\t\t\t\t\tecs.markChanged(entity.id, 'localTransform');\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.and();\n\n\treturn bundle;\n}\n\n/**\n * Determine which edge an entity has exited through, if any.\n */\nfunction getExitEdge(\n\ttransform: { x: number; y: number },\n\tminX: number,\n\tminY: number,\n\tmaxX: number,\n\tmaxY: number,\n\tpadding: number\n): 'top' | 'bottom' | 'left' | 'right' | null {\n\tif (transform.x > maxX + padding) return 'right';\n\tif (transform.x < minX - padding) return 'left';\n\tif (transform.y > maxY + padding) return 'bottom';\n\tif (transform.y < minY - padding) return 'top';\n\treturn null;\n}\n"
6
- ],
7
- "mappings": "2PAQA,iBAAS,kBA6HF,SAAS,CAAY,CAAC,EAAe,EAAgB,EAAY,EAAwB,CAC/F,IAAM,EAAqB,CAAE,QAAO,QAAO,EAC3C,GAAI,IAAM,OAAW,EAAO,EAAI,EAChC,GAAI,IAAM,OAAW,EAAO,EAAI,EAChC,OAAO,EAiBD,SAAS,CAAwB,CAAC,EAAoE,CAC5G,MAAO,CACN,mBAAoB,IAAY,OAAY,CAAE,SAAQ,EAAI,CAAC,CAC5D,EAiBM,SAAS,CAAmB,CAAC,EAA8D,CACjG,MAAO,CACN,cAAe,IAAW,OAAY,CAAE,QAAO,EAAI,CAAC,CACrD,EAiBM,SAAS,CAAkB,CAAC,EAA8D,CAChG,MAAO,CACN,aAAc,IAAY,OAAY,CAAE,SAAQ,EAAI,CAAC,CACtD,EAqCM,SAAS,CAAmF,CAClG,EACkE,CAClE,IACC,cAAc,UACd,WAAW,GACX,oBAAoB,SACpB,aAAa,GACb,QAAQ,cACL,GAAW,CAAC,EAEV,EAAS,IAAI,EAAgE,QAAQ,EAiI3F,OA9HA,EACE,UAAU,gBAAgB,EAC1B,YAAY,CAAQ,EACpB,QAAQ,CAAK,EACb,QAAQ,CAAW,EACnB,SAAS,WAAY,CACrB,KAAM,CAAC,iBAAkB,oBAAoB,CAC9C,CAAC,EACA,WAAW,CAAC,EAAS,EAAY,IAAQ,CACzC,IAAM,EAAS,EAAI,YAAY,CAAwC,EACjE,EAAO,EAAO,GAAK,EACnB,EAAO,EAAO,GAAK,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AAY,EAAW,CAAC,EACxB,QAAQ,CAAK,EACb,QAAQ,CAAW,EACnB,SAAS,WAAY,CACrB,KAAM,CAAC,iBAAkB,iBAAkB,cAAc,CAC1D,CAAC,EACA,WAAW,CAAC,EAAS,EAAY,IAAQ,CACzC,IAAM,EAAS,EAAI,YAAY,CAAwC,EACjE,EAAO,EAAO,GAAK,EACnB,EAAO,EAAO,GAAK,EACnB,EAAO,EAAO,EAAO,MACrB,EAAO,EAAO,EAAO,OAE3B,QAAW,KAAU,EAAQ,SAAU,CACtC,IAAQ,iBAAgB,iBAAgB,gBAAiB,EAAO,WAC1D,EAAU,EAAa,SAAW,EAEpC,EAAS,EACT,EAAS,EACP,EAAc,EAAO,EACrB,EAAe,EAAO,EAG5B,GAAI,EAAe,EAAI,EAAO,EAC7B,EAAS,EAAE,EAAc,EAAI,GACvB,QAAI,EAAe,EAAI,EAAO,EACpC,EAAS,EAAc,EAAI,EAI5B,GAAI,EAAe,EAAI,EAAO,EAC7B,EAAS,EAAE,EAAe,EAAI,GACxB,QAAI,EAAe,EAAI,EAAO,EACpC,EAAS,EAAe,EAAI,EAG7B,GAAI,IAAW,GAAK,IAAW,EAC9B,EAAe,GAAK,EACpB,EAAe,GAAK,EACpB,EAAI,YAAY,EAAO,GAAI,gBAAgB,GAG7C,EACA,IAAI,EAEC,EAMR,SAAS,CAAW,CACnB,EACA,EACA,EACA,EACA,EACA,EAC6C,CAC7C,GAAI,EAAU,EAAI,EAAO,EAAS,MAAO,QACzC,GAAI,EAAU,EAAI,EAAO,EAAS,MAAO,OACzC,GAAI,EAAU,EAAI,EAAO,EAAS,MAAO,SACzC,GAAI,EAAU,EAAI,EAAO,EAAS,MAAO,MACzC,OAAO",
8
- "debugId": "8FF1EB3AF1C6181164756E2164756E21",
9
- "names": []
10
- }
@@ -1,204 +0,0 @@
1
- /**
2
- * Collision Bundle for ECSpresso
3
- *
4
- * Provides layer-based collision detection with events.
5
- * Uses worldTransform for position (world-space collision).
6
- * Supports AABB and circle colliders.
7
- */
8
- import { Bundle } from 'ecspresso';
9
- import type { SystemPhase } from 'ecspresso';
10
- import type { TransformComponentTypes } from './transform';
11
- /**
12
- * Axis-Aligned Bounding Box collider.
13
- */
14
- export interface AABBCollider {
15
- /** Width of the bounding box */
16
- width: number;
17
- /** Height of the bounding box */
18
- height: number;
19
- /** X offset from entity position (default: 0) */
20
- offsetX?: number;
21
- /** Y offset from entity position (default: 0) */
22
- offsetY?: number;
23
- }
24
- /**
25
- * Circle collider.
26
- */
27
- export interface CircleCollider {
28
- /** Radius of the circle */
29
- radius: number;
30
- /** X offset from entity position (default: 0) */
31
- offsetX?: number;
32
- /** Y offset from entity position (default: 0) */
33
- offsetY?: number;
34
- }
35
- /**
36
- * Collision layer configuration.
37
- */
38
- export interface CollisionLayer {
39
- /** The layer this entity belongs to */
40
- layer: string;
41
- /** Layers this entity can collide with */
42
- collidesWith: readonly string[];
43
- }
44
- /**
45
- * Component types provided by the collision bundle.
46
- * Extend your component types with this interface.
47
- *
48
- * @example
49
- * ```typescript
50
- * interface GameComponents extends TransformComponentTypes, CollisionComponentTypes {
51
- * sprite: Sprite;
52
- * enemy: boolean;
53
- * }
54
- * ```
55
- */
56
- export interface CollisionComponentTypes {
57
- aabbCollider: AABBCollider;
58
- circleCollider: CircleCollider;
59
- collisionLayer: CollisionLayer;
60
- }
61
- /**
62
- * Event fired when two entities collide.
63
- */
64
- export interface CollisionEvent {
65
- /** First entity in the collision */
66
- entityA: number;
67
- /** Second entity in the collision */
68
- entityB: number;
69
- /** Layer of the first entity */
70
- layerA: string;
71
- /** Layer of the second entity */
72
- layerB: string;
73
- }
74
- /**
75
- * Event types provided by the collision bundle.
76
- */
77
- export interface CollisionEventTypes {
78
- collision: CollisionEvent;
79
- }
80
- /**
81
- * Configuration options for the collision bundle.
82
- */
83
- export interface CollisionBundleOptions {
84
- /** System group name (default: 'physics') */
85
- systemGroup?: string;
86
- /** Priority for collision system (default: 0) */
87
- priority?: number;
88
- /** Name of the collision event (default: 'collision') */
89
- collisionEventName?: string;
90
- /** Execution phase (default: 'postUpdate') */
91
- phase?: SystemPhase;
92
- }
93
- /**
94
- * Create an AABB collider component.
95
- *
96
- * @param width Width of the bounding box
97
- * @param height Height of the bounding box
98
- * @param offsetX X offset from entity position
99
- * @param offsetY Y offset from entity position
100
- * @returns Component object suitable for spreading into spawn()
101
- *
102
- * @example
103
- * ```typescript
104
- * ecs.spawn({
105
- * ...createTransform(100, 200),
106
- * ...createAABBCollider(50, 30),
107
- * });
108
- * ```
109
- */
110
- export declare function createAABBCollider(width: number, height: number, offsetX?: number, offsetY?: number): Pick<CollisionComponentTypes, 'aabbCollider'>;
111
- /**
112
- * Create a circle collider component.
113
- *
114
- * @param radius Radius of the circle
115
- * @param offsetX X offset from entity position
116
- * @param offsetY Y offset from entity position
117
- * @returns Component object suitable for spreading into spawn()
118
- *
119
- * @example
120
- * ```typescript
121
- * ecs.spawn({
122
- * ...createTransform(100, 200),
123
- * ...createCircleCollider(25),
124
- * });
125
- * ```
126
- */
127
- export declare function createCircleCollider(radius: number, offsetX?: number, offsetY?: number): Pick<CollisionComponentTypes, 'circleCollider'>;
128
- /**
129
- * Create a collision layer component.
130
- *
131
- * @param layer The layer this entity belongs to
132
- * @param collidesWith Layers this entity can collide with
133
- * @returns Component object suitable for spreading into spawn()
134
- *
135
- * @example
136
- * ```typescript
137
- * ecs.spawn({
138
- * ...createTransform(100, 200),
139
- * ...createAABBCollider(50, 30),
140
- * ...createCollisionLayer('player', ['enemy', 'obstacle']),
141
- * });
142
- * ```
143
- */
144
- export declare function createCollisionLayer(layer: string, collidesWith: readonly string[]): Pick<CollisionComponentTypes, 'collisionLayer'>;
145
- /**
146
- * Layer factory result from defineCollisionLayers.
147
- */
148
- export type LayerFactories<T extends Record<string, readonly string[]>> = {
149
- [K in keyof T]: () => Pick<CollisionComponentTypes, 'collisionLayer'>;
150
- };
151
- /**
152
- * Define collision layer relationships and get factory functions.
153
- *
154
- * @param rules Object mapping layer names to arrays of layers they collide with
155
- * @returns Object with factory functions for each layer
156
- *
157
- * @example
158
- * ```typescript
159
- * const layers = defineCollisionLayers({
160
- * player: ['enemy', 'enemyProjectile'],
161
- * playerProjectile: ['enemy'],
162
- * enemy: ['playerProjectile'],
163
- * enemyProjectile: ['player'],
164
- * });
165
- *
166
- * // Usage
167
- * ecs.spawn({
168
- * ...createTransform(100, 200),
169
- * ...createAABBCollider(50, 30),
170
- * ...layers.player(),
171
- * });
172
- * ```
173
- */
174
- export declare function defineCollisionLayers<T extends Record<string, readonly string[]>>(rules: T): LayerFactories<T>;
175
- type CombinedComponentTypes = CollisionComponentTypes & TransformComponentTypes;
176
- /**
177
- * Create a collision bundle for ECSpresso.
178
- *
179
- * This bundle provides:
180
- * - O(n²) collision detection between entities with colliders
181
- * - AABB-AABB, circle-circle, and AABB-circle collision
182
- * - Layer-based filtering for collision pairs
183
- * - Deduplication of A-B / B-A collisions
184
- *
185
- * Uses worldTransform for position (world-space collision detection).
186
- *
187
- * @example
188
- * ```typescript
189
- * const ecs = ECSpresso
190
- * .create<Components, Events, Resources>()
191
- * .withBundle(createTransformBundle())
192
- * .withBundle(createCollisionBundle())
193
- * .build();
194
- *
195
- * // Entity with collision
196
- * ecs.spawn({
197
- * ...createTransform(100, 200),
198
- * ...createAABBCollider(50, 30),
199
- * ...createCollisionLayer('player', ['enemy']),
200
- * });
201
- * ```
202
- */
203
- export declare function createCollisionBundle(options?: CollisionBundleOptions): Bundle<CombinedComponentTypes, CollisionEventTypes, {}>;
204
- export {};
@@ -1,4 +0,0 @@
1
- var L=((v)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(v,{get:(z,D)=>(typeof require<"u"?require:z)[D]}):v)(function(v){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+v+'" is not supported')});import{Bundle as B}from"ecspresso";function R(v,z,D,E){let I={width:v,height:z};if(D!==void 0)I.offsetX=D;if(E!==void 0)I.offsetY=E;return{aabbCollider:I}}function V(v,z,D){let E={radius:v};if(z!==void 0)E.offsetX=z;if(D!==void 0)E.offsetY=D;return{circleCollider:E}}function K(v,z){return{collisionLayer:{layer:v,collidesWith:z}}}function m(v){let z={};for(let D of Object.keys(v)){let E=v[D];z[D]=()=>K(D,E)}return z}function C(v){let{systemGroup:z="physics",priority:D=0,phase:E="postUpdate"}=v??{},I=new B("collision");return I.addSystem("collision-detection").setPriority(D).inPhase(E).inGroup(z).addQuery("collidables",{with:["worldTransform","collisionLayer"]}).setProcess((Z,_,O)=>{let N=[];for(let M of Z.collidables){let{worldTransform:J,collisionLayer:k}=M.components,F=O.entityManager.getComponent(M.id,"aabbCollider"),$=O.entityManager.getComponent(M.id,"circleCollider");if(!F&&!$)continue;let U={entityId:M.id,x:J.x,y:J.y,layer:k.layer,collidesWith:k.collidesWith};if(F)U.x+=F.offsetX??0,U.y+=F.offsetY??0,U.aabb={halfWidth:F.width/2,halfHeight:F.height/2};if($)U.x+=$.offsetX??0,U.y+=$.offsetY??0,U.circle={radius:$.radius};N.push(U)}let Q=new Set;for(let M=0;M<N.length;M++){let J=N[M];if(!J)continue;for(let k=M+1;k<N.length;k++){let F=N[k];if(!F)continue;let $=J.collidesWith.includes(F.layer),U=F.collidesWith.includes(J.layer);if(!$&&!U)continue;let G=J.entityId<F.entityId?`${J.entityId}:${F.entityId}`:`${F.entityId}:${J.entityId}`;if(Q.has(G))continue;if(P(J,F))Q.add(G),O.eventBus.publish("collision",{entityA:J.entityId,entityB:F.entityId,layerA:J.layer,layerB:F.layer})}}}).and(),I}function P(v,z){if(v.aabb&&z.aabb)return T(v.x,v.y,v.aabb.halfWidth,v.aabb.halfHeight,z.x,z.y,z.aabb.halfWidth,z.aabb.halfHeight);if(v.circle&&z.circle)return j(v.x,v.y,v.circle.radius,z.x,z.y,z.circle.radius);if(v.aabb&&z.circle)return A(v.x,v.y,v.aabb.halfWidth,v.aabb.halfHeight,z.x,z.y,z.circle.radius);if(v.circle&&z.aabb)return A(z.x,z.y,z.aabb.halfWidth,z.aabb.halfHeight,v.x,v.y,v.circle.radius);return!1}function T(v,z,D,E,I,Z,_,O){let N=Math.abs(v-I),Q=Math.abs(z-Z);return N<D+_&&Q<E+O}function j(v,z,D,E,I,Z){let _=v-E,O=z-I,N=_*_+O*O,Q=D+Z;return N<Q*Q}function A(v,z,D,E,I,Z,_){let O=Math.max(v-D,Math.min(I,v+D)),N=Math.max(z-E,Math.min(Z,z+E)),Q=I-O,M=Z-N;return Q*Q+M*M<_*_}export{m as defineCollisionLayers,K as createCollisionLayer,C as createCollisionBundle,V as createCircleCollider,R as createAABBCollider};
2
-
3
- //# debugId=87C006826612A65764756E2164756E21
4
- //# sourceMappingURL=collision.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/bundles/utils/collision.ts"],
4
- "sourcesContent": [
5
- "/**\n * Collision Bundle for ECSpresso\n *\n * Provides layer-based collision detection with events.\n * Uses worldTransform for position (world-space collision).\n * Supports AABB and circle colliders.\n */\n\nimport { Bundle } from 'ecspresso';\nimport type { SystemPhase } from 'ecspresso';\nimport type { TransformComponentTypes } from './transform';\n\n// ==================== Component Types ====================\n\n/**\n * Axis-Aligned Bounding Box collider.\n */\nexport interface AABBCollider {\n\t/** Width of the bounding box */\n\twidth: number;\n\t/** Height of the bounding box */\n\theight: number;\n\t/** X offset from entity position (default: 0) */\n\toffsetX?: number;\n\t/** Y offset from entity position (default: 0) */\n\toffsetY?: number;\n}\n\n/**\n * Circle collider.\n */\nexport interface CircleCollider {\n\t/** Radius of the circle */\n\tradius: number;\n\t/** X offset from entity position (default: 0) */\n\toffsetX?: number;\n\t/** Y offset from entity position (default: 0) */\n\toffsetY?: number;\n}\n\n/**\n * Collision layer configuration.\n */\nexport interface CollisionLayer {\n\t/** The layer this entity belongs to */\n\tlayer: string;\n\t/** Layers this entity can collide with */\n\tcollidesWith: readonly string[];\n}\n\n/**\n * Component types provided by the collision bundle.\n * Extend your component types with this interface.\n *\n * @example\n * ```typescript\n * interface GameComponents extends TransformComponentTypes, CollisionComponentTypes {\n * sprite: Sprite;\n * enemy: boolean;\n * }\n * ```\n */\nexport interface CollisionComponentTypes {\n\taabbCollider: AABBCollider;\n\tcircleCollider: CircleCollider;\n\tcollisionLayer: CollisionLayer;\n}\n\n// ==================== Event Types ====================\n\n/**\n * Event fired when two entities collide.\n */\nexport interface CollisionEvent {\n\t/** First entity in the collision */\n\tentityA: number;\n\t/** Second entity in the collision */\n\tentityB: number;\n\t/** Layer of the first entity */\n\tlayerA: string;\n\t/** Layer of the second entity */\n\tlayerB: string;\n}\n\n/**\n * Event types provided by the collision bundle.\n */\nexport interface CollisionEventTypes {\n\tcollision: CollisionEvent;\n}\n\n// ==================== Bundle Options ====================\n\n/**\n * Configuration options for the collision bundle.\n */\nexport interface CollisionBundleOptions {\n\t/** System group name (default: 'physics') */\n\tsystemGroup?: string;\n\t/** Priority for collision system (default: 0) */\n\tpriority?: number;\n\t/** Name of the collision event (default: 'collision') */\n\tcollisionEventName?: string;\n\t/** Execution phase (default: 'postUpdate') */\n\tphase?: SystemPhase;\n}\n\n// ==================== Helper Functions ====================\n\n/**\n * Create an AABB collider component.\n *\n * @param width Width of the bounding box\n * @param height Height of the bounding box\n * @param offsetX X offset from entity position\n * @param offsetY Y offset from entity position\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createAABBCollider(50, 30),\n * });\n * ```\n */\nexport function createAABBCollider(\n\twidth: number,\n\theight: number,\n\toffsetX?: number,\n\toffsetY?: number\n): Pick<CollisionComponentTypes, 'aabbCollider'> {\n\tconst collider: AABBCollider = { width, height };\n\tif (offsetX !== undefined) collider.offsetX = offsetX;\n\tif (offsetY !== undefined) collider.offsetY = offsetY;\n\treturn { aabbCollider: collider };\n}\n\n/**\n * Create a circle collider component.\n *\n * @param radius Radius of the circle\n * @param offsetX X offset from entity position\n * @param offsetY Y offset from entity position\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createCircleCollider(25),\n * });\n * ```\n */\nexport function createCircleCollider(\n\tradius: number,\n\toffsetX?: number,\n\toffsetY?: number\n): Pick<CollisionComponentTypes, 'circleCollider'> {\n\tconst collider: CircleCollider = { radius };\n\tif (offsetX !== undefined) collider.offsetX = offsetX;\n\tif (offsetY !== undefined) collider.offsetY = offsetY;\n\treturn { circleCollider: collider };\n}\n\n/**\n * Create a collision layer component.\n *\n * @param layer The layer this entity belongs to\n * @param collidesWith Layers this entity can collide with\n * @returns Component object suitable for spreading into spawn()\n *\n * @example\n * ```typescript\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createAABBCollider(50, 30),\n * ...createCollisionLayer('player', ['enemy', 'obstacle']),\n * });\n * ```\n */\nexport function createCollisionLayer(\n\tlayer: string,\n\tcollidesWith: readonly string[]\n): Pick<CollisionComponentTypes, 'collisionLayer'> {\n\treturn {\n\t\tcollisionLayer: { layer, collidesWith },\n\t};\n}\n\n/**\n * Layer factory result from defineCollisionLayers.\n */\nexport type LayerFactories<T extends Record<string, readonly string[]>> = {\n\t[K in keyof T]: () => Pick<CollisionComponentTypes, 'collisionLayer'>;\n};\n\n/**\n * Define collision layer relationships and get factory functions.\n *\n * @param rules Object mapping layer names to arrays of layers they collide with\n * @returns Object with factory functions for each layer\n *\n * @example\n * ```typescript\n * const layers = defineCollisionLayers({\n * player: ['enemy', 'enemyProjectile'],\n * playerProjectile: ['enemy'],\n * enemy: ['playerProjectile'],\n * enemyProjectile: ['player'],\n * });\n *\n * // Usage\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createAABBCollider(50, 30),\n * ...layers.player(),\n * });\n * ```\n */\nexport function defineCollisionLayers<T extends Record<string, readonly string[]>>(\n\trules: T\n): LayerFactories<T> {\n\tconst factories = {} as LayerFactories<T>;\n\n\tfor (const layer of Object.keys(rules) as Array<keyof T & string>) {\n\t\tconst collidesWith = rules[layer] as readonly string[];\n\t\tfactories[layer] = () => createCollisionLayer(layer, collidesWith);\n\t}\n\n\treturn factories;\n}\n\n// ==================== Internal Types ====================\n\ntype CombinedComponentTypes = CollisionComponentTypes & TransformComponentTypes;\n\ninterface ColliderInfo {\n\tentityId: number;\n\tx: number;\n\ty: number;\n\tlayer: string;\n\tcollidesWith: readonly string[];\n\taabb?: { halfWidth: number; halfHeight: number };\n\tcircle?: { radius: number };\n}\n\n// ==================== Bundle Factory ====================\n\n/**\n * Create a collision bundle for ECSpresso.\n *\n * This bundle provides:\n * - O(n²) collision detection between entities with colliders\n * - AABB-AABB, circle-circle, and AABB-circle collision\n * - Layer-based filtering for collision pairs\n * - Deduplication of A-B / B-A collisions\n *\n * Uses worldTransform for position (world-space collision detection).\n *\n * @example\n * ```typescript\n * const ecs = ECSpresso\n * .create<Components, Events, Resources>()\n * .withBundle(createTransformBundle())\n * .withBundle(createCollisionBundle())\n * .build();\n *\n * // Entity with collision\n * ecs.spawn({\n * ...createTransform(100, 200),\n * ...createAABBCollider(50, 30),\n * ...createCollisionLayer('player', ['enemy']),\n * });\n * ```\n */\nexport function createCollisionBundle(\n\toptions?: CollisionBundleOptions\n): Bundle<CombinedComponentTypes, CollisionEventTypes, {}> {\n\tconst {\n\t\tsystemGroup = 'physics',\n\t\tpriority = 0,\n\t\tphase = 'postUpdate',\n\t} = options ?? {};\n\n\tconst bundle = new Bundle<CombinedComponentTypes, CollisionEventTypes, {}>('collision');\n\n\tbundle\n\t\t.addSystem('collision-detection')\n\t\t.setPriority(priority)\n\t\t.inPhase(phase)\n\t\t.inGroup(systemGroup)\n\t\t.addQuery('collidables', {\n\t\t\twith: ['worldTransform', 'collisionLayer'],\n\t\t})\n\t\t.setProcess((queries, _deltaTime, ecs) => {\n\t\t\t// Build list of collidable entities with their computed positions\n\t\t\tconst colliders: ColliderInfo[] = [];\n\n\t\t\tfor (const entity of queries.collidables) {\n\t\t\t\tconst { worldTransform, collisionLayer } = entity.components;\n\n\t\t\t\t// Get collider info\n\t\t\t\tconst aabb = ecs.entityManager.getComponent(entity.id, 'aabbCollider') as AABBCollider | null;\n\t\t\t\tconst circle = ecs.entityManager.getComponent(entity.id, 'circleCollider') as CircleCollider | null;\n\n\t\t\t\t// Must have at least one collider\n\t\t\t\tif (!aabb && !circle) continue;\n\n\t\t\t\tconst info: ColliderInfo = {\n\t\t\t\t\tentityId: entity.id,\n\t\t\t\t\tx: worldTransform.x,\n\t\t\t\t\ty: worldTransform.y,\n\t\t\t\t\tlayer: collisionLayer.layer,\n\t\t\t\t\tcollidesWith: collisionLayer.collidesWith,\n\t\t\t\t};\n\n\t\t\t\tif (aabb) {\n\t\t\t\t\tinfo.x += aabb.offsetX ?? 0;\n\t\t\t\t\tinfo.y += aabb.offsetY ?? 0;\n\t\t\t\t\tinfo.aabb = {\n\t\t\t\t\t\thalfWidth: aabb.width / 2,\n\t\t\t\t\t\thalfHeight: aabb.height / 2,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (circle) {\n\t\t\t\t\tinfo.x += circle.offsetX ?? 0;\n\t\t\t\t\tinfo.y += circle.offsetY ?? 0;\n\t\t\t\t\tinfo.circle = { radius: circle.radius };\n\t\t\t\t}\n\n\t\t\t\tcolliders.push(info);\n\t\t\t}\n\n\t\t\t// Track processed pairs to avoid duplicates\n\t\t\tconst processedPairs = new Set<string>();\n\n\t\t\t// O(n²) collision detection\n\t\t\tfor (let i = 0; i < colliders.length; i++) {\n\t\t\t\tconst a = colliders[i];\n\t\t\t\tif (!a) continue;\n\n\t\t\t\tfor (let j = i + 1; j < colliders.length; j++) {\n\t\t\t\t\tconst b = colliders[j];\n\t\t\t\t\tif (!b) continue;\n\n\t\t\t\t\t// Check layer compatibility (A→B or B→A)\n\t\t\t\t\tconst aCollidesWithB = a.collidesWith.includes(b.layer);\n\t\t\t\t\tconst bCollidesWithA = b.collidesWith.includes(a.layer);\n\n\t\t\t\t\tif (!aCollidesWithB && !bCollidesWithA) continue;\n\n\t\t\t\t\t// Create unique pair key\n\t\t\t\t\tconst pairKey = a.entityId < b.entityId\n\t\t\t\t\t\t? `${a.entityId}:${b.entityId}`\n\t\t\t\t\t\t: `${b.entityId}:${a.entityId}`;\n\n\t\t\t\t\tif (processedPairs.has(pairKey)) continue;\n\n\t\t\t\t\t// Check collision based on collider types\n\t\t\t\t\tconst colliding = checkCollision(a, b);\n\n\t\t\t\t\tif (colliding) {\n\t\t\t\t\t\tprocessedPairs.add(pairKey);\n\t\t\t\t\t\tecs.eventBus.publish('collision', {\n\t\t\t\t\t\t\tentityA: a.entityId,\n\t\t\t\t\t\t\tentityB: b.entityId,\n\t\t\t\t\t\t\tlayerA: a.layer,\n\t\t\t\t\t\t\tlayerB: b.layer,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.and();\n\n\treturn bundle;\n}\n\n/**\n * Check if two colliders are overlapping.\n */\nfunction checkCollision(a: ColliderInfo, b: ColliderInfo): boolean {\n\t// AABB vs AABB\n\tif (a.aabb && b.aabb) {\n\t\treturn aabbVsAabb(\n\t\t\ta.x, a.y, a.aabb.halfWidth, a.aabb.halfHeight,\n\t\t\tb.x, b.y, b.aabb.halfWidth, b.aabb.halfHeight\n\t\t);\n\t}\n\n\t// Circle vs Circle\n\tif (a.circle && b.circle) {\n\t\treturn circleVsCircle(\n\t\t\ta.x, a.y, a.circle.radius,\n\t\t\tb.x, b.y, b.circle.radius\n\t\t);\n\t}\n\n\t// AABB vs Circle\n\tif (a.aabb && b.circle) {\n\t\treturn aabbVsCircle(\n\t\t\ta.x, a.y, a.aabb.halfWidth, a.aabb.halfHeight,\n\t\t\tb.x, b.y, b.circle.radius\n\t\t);\n\t}\n\n\tif (a.circle && b.aabb) {\n\t\treturn aabbVsCircle(\n\t\t\tb.x, b.y, b.aabb.halfWidth, b.aabb.halfHeight,\n\t\t\ta.x, a.y, a.circle.radius\n\t\t);\n\t}\n\n\treturn false;\n}\n\n/**\n * AABB vs AABB collision test.\n */\nfunction aabbVsAabb(\n\tax: number, ay: number, aHalfWidth: number, aHalfHeight: number,\n\tbx: number, by: number, bHalfWidth: number, bHalfHeight: number\n): boolean {\n\tconst dx = Math.abs(ax - bx);\n\tconst dy = Math.abs(ay - by);\n\treturn dx < (aHalfWidth + bHalfWidth) && dy < (aHalfHeight + bHalfHeight);\n}\n\n/**\n * Circle vs Circle collision test.\n */\nfunction circleVsCircle(\n\tax: number, ay: number, aRadius: number,\n\tbx: number, by: number, bRadius: number\n): boolean {\n\tconst dx = ax - bx;\n\tconst dy = ay - by;\n\tconst distSq = dx * dx + dy * dy;\n\tconst radiusSum = aRadius + bRadius;\n\treturn distSq < radiusSum * radiusSum;\n}\n\n/**\n * AABB vs Circle collision test.\n */\nfunction aabbVsCircle(\n\taabbX: number, aabbY: number, halfWidth: number, halfHeight: number,\n\tcircleX: number, circleY: number, radius: number\n): boolean {\n\t// Find the closest point on the AABB to the circle center\n\tconst closestX = Math.max(aabbX - halfWidth, Math.min(circleX, aabbX + halfWidth));\n\tconst closestY = Math.max(aabbY - halfHeight, Math.min(circleY, aabbY + halfHeight));\n\n\t// Calculate distance from closest point to circle center\n\tconst dx = circleX - closestX;\n\tconst dy = circleY - closestY;\n\tconst distSq = dx * dx + dy * dy;\n\n\treturn distSq < radius * radius;\n}\n"
6
- ],
7
- "mappings": "2PAQA,iBAAS,kBAsHF,SAAS,CAAkB,CACjC,EACA,EACA,EACA,EACgD,CAChD,IAAM,EAAyB,CAAE,QAAO,QAAO,EAC/C,GAAI,IAAY,OAAW,EAAS,QAAU,EAC9C,GAAI,IAAY,OAAW,EAAS,QAAU,EAC9C,MAAO,CAAE,aAAc,CAAS,EAmB1B,SAAS,CAAoB,CACnC,EACA,EACA,EACkD,CAClD,IAAM,EAA2B,CAAE,QAAO,EAC1C,GAAI,IAAY,OAAW,EAAS,QAAU,EAC9C,GAAI,IAAY,OAAW,EAAS,QAAU,EAC9C,MAAO,CAAE,eAAgB,CAAS,EAmB5B,SAAS,CAAoB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,KAAK,UAAW,EAAE,KAAK,WACnC,EAAE,EAAG,EAAE,EAAG,EAAE,OAAO,MACpB,EAGD,MAAO,GAMR,SAAS,CAAU,CAClB,EAAY,EAAY,EAAoB,EAC5C,EAAY,EAAY,EAAoB,EAClC,CACV,IAAM,EAAK,KAAK,IAAI,EAAK,CAAE,EACrB,EAAK,KAAK,IAAI,EAAK,CAAE,EAC3B,OAAO,EAAM,EAAa,GAAe,EAAM,EAAc,EAM9D,SAAS,CAAc,CACtB,EAAY,EAAY,EACxB,EAAY,EAAY,EACd,CACV,IAAM,EAAK,EAAK,EACV,EAAK,EAAK,EACV,EAAS,EAAK,EAAK,EAAK,EACxB,EAAY,EAAU,EAC5B,OAAO,EAAS,EAAY,EAM7B,SAAS,CAAY,CACpB,EAAe,EAAe,EAAmB,EACjD,EAAiB,EAAiB,EACxB,CAEV,IAAM,EAAW,KAAK,IAAI,EAAQ,EAAW,KAAK,IAAI,EAAS,EAAQ,CAAS,CAAC,EAC3E,EAAW,KAAK,IAAI,EAAQ,EAAY,KAAK,IAAI,EAAS,EAAQ,CAAU,CAAC,EAG7E,EAAK,EAAU,EACf,EAAK,EAAU,EAGrB,OAFe,EAAK,EAAK,EAAK,EAEd,EAAS",
8
- "debugId": "87C006826612A65764756E2164756E21",
9
- "names": []
10
- }
@@ -1,4 +0,0 @@
1
- var _=((q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(q,{get:(O,Q)=>(typeof require<"u"?require:O)[Q]}):q)(function(q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+q+'" is not supported')});import{Bundle as Y}from"ecspresso";function M(q){return q}function A(){return{keysDown:new Set,keysPressed:[],keysReleased:[],buttonsDown:new Set,buttonsPressed:[],buttonsReleased:[],pointerX:0,pointerY:0,pointerDeltaX:0,pointerDeltaY:0,lastPointerX:0,lastPointerY:0,pointerMoved:!1}}var K=new Set,m=new Set;function D(){return{keysDown:K,keysPressed:K,keysReleased:K,buttonsDown:m,buttonsPressed:m,buttonsReleased:m,pointerX:0,pointerY:0,pointerDeltaX:0,pointerDeltaY:0,actionsActive:K,prevActionsActive:K}}function R(q,O,Q){let V=new Set;for(let[Z,W]of Object.entries(q)){let H=W.keys?.some((J)=>O.has(J))??!1,z=W.buttons?.some((J)=>Q.has(J))??!1;if(H||z)V.add(Z)}return V}function v(q,O,Q){let V=new Set(q.keysDown),Z=new Set(q.keysPressed),W=new Set(q.keysReleased),H=new Set(q.buttonsDown),z=new Set(q.buttonsPressed),J=new Set(q.buttonsReleased),$=q.pointerMoved?q.pointerX-q.lastPointerX:0,j=q.pointerMoved?q.pointerY-q.lastPointerY:0,x=R(Q,V,H),B={keysDown:V,keysPressed:Z,keysReleased:W,buttonsDown:H,buttonsPressed:z,buttonsReleased:J,pointerX:q.pointerX,pointerY:q.pointerY,pointerDeltaX:$,pointerDeltaY:j,actionsActive:x,prevActionsActive:O};return q.keysPressed=[],q.keysReleased=[],q.buttonsPressed=[],q.buttonsReleased=[],q.lastPointerX=q.pointerX,q.lastPointerY=q.pointerY,q.pointerMoved=!1,B}function T(q){let{systemGroup:O="input",priority:Q=100,phase:V="preUpdate",actions:Z={},target:W=globalThis}=q??{},H=A(),z=D(),J={...Z},$=[],j={x:0,y:0},x={x:0,y:0},L={keyboard:{isDown:(f)=>z.keysDown.has(f),justPressed:(f)=>z.keysPressed.has(f),justReleased:(f)=>z.keysReleased.has(f)},pointer:{position:j,delta:x,isDown:(f)=>z.buttonsDown.has(f),justPressed:(f)=>z.buttonsPressed.has(f),justReleased:(f)=>z.buttonsReleased.has(f)},actions:{isActive:(f)=>z.actionsActive.has(f),justActivated:(f)=>z.actionsActive.has(f)&&!z.prevActionsActive.has(f),justDeactivated:(f)=>!z.actionsActive.has(f)&&z.prevActionsActive.has(f)},setActionMap(f){J={...f}},getActionMap(){return{...J}}};function g(f){let C=f;if(C.repeat)return;H.keysDown.add(C.key),H.keysPressed.push(C.key)}function G(f){let C=f;H.keysDown.delete(C.key),H.keysReleased.push(C.key)}function I(f){let C=f;H.buttonsDown.add(C.button),H.buttonsPressed.push(C.button)}function U(f){let C=f;H.pointerX=C.clientX,H.pointerY=C.clientY,H.pointerMoved=!0}function N(f){let C=f;H.buttonsDown.delete(C.button),H.buttonsReleased.push(C.button)}function X(f,C){W.addEventListener(f,C),$.push(()=>W.removeEventListener(f,C))}let F=new Y("input");return F.addResource("inputState",L),F.addSystem("input-state").setPriority(Q).inPhase(V).inGroup(O).setOnInitialize(()=>{X("keydown",g),X("keyup",G),X("pointerdown",I),X("pointermove",U),X("pointerup",N)}).setOnDetach(()=>{for(let f of $)f();$.length=0}).setProcess(()=>{let f=z.actionsActive;z=v(H,f,J),j.x=z.pointerX,j.y=z.pointerY,x.x=z.pointerDeltaX,x.y=z.pointerDeltaY}).and(),F}export{T as createInputBundle,M as createActionBinding};
2
-
3
- //# debugId=1A29264AD47B9F8264756E2164756E21
4
- //# sourceMappingURL=input.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/bundles/utils/input.ts"],
4
- "sourcesContent": [
5
- "/**\n * Input Bundle for ECSpresso\n *\n * Provides frame-accurate keyboard, pointer (mouse + touch via PointerEvent),\n * and action mapping input. Resource-only bundle — input is polled via the\n * `inputState` resource. No ECS components or events.\n *\n * DOM events are accumulated between frames and snapshotted once per frame\n * in the system's process step, so all systems see consistent state.\n */\n\nimport { Bundle } from 'ecspresso';\nimport type { SystemPhase } from 'ecspresso';\n\n// ==================== Public Types ====================\n\nexport interface Vec2 {\n\tx: number;\n\ty: number;\n}\n\n// Key codes per the UI Events spec (KeyboardEvent.key values)\n// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values\n\ntype LowercaseLetter =\n\t| 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm'\n\t| 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';\n\ntype Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';\n\ntype Punctuation =\n\t| '`' | '~' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '(' | ')'\n\t| '-' | '_' | '=' | '+' | '[' | '{' | ']' | '}' | '\\\\' | '|'\n\t| ';' | ':' | \"'\" | '\"' | ',' | '<' | '.' | '>' | '/' | '?';\n\ntype ModifierKey =\n\t| 'Alt' | 'AltGraph' | 'CapsLock' | 'Control' | 'Fn' | 'FnLock'\n\t| 'Hyper' | 'Meta' | 'NumLock' | 'ScrollLock' | 'Shift'\n\t| 'Super' | 'Symbol' | 'SymbolLock';\n\ntype WhitespaceKey = 'Enter' | 'Tab' | ' ';\n\ntype NavigationKey =\n\t| `Arrow${'Down' | 'Left' | 'Right' | 'Up'}`\n\t| 'End' | 'Home' | 'PageDown' | 'PageUp';\n\ntype EditingKey =\n\t| 'Backspace' | 'Clear' | 'Copy' | 'CrSel' | 'Cut' | 'Delete'\n\t| 'EraseEof' | 'ExSel' | 'Insert' | 'Paste' | 'Redo' | 'Undo';\n\ntype UIKey =\n\t| 'Accept' | 'Again' | 'Attn' | 'Cancel' | 'ContextMenu' | 'Escape'\n\t| 'Execute' | 'Find' | 'Finish' | 'Help' | 'Pause' | 'Play'\n\t| 'Props' | 'Select' | 'ZoomIn' | 'ZoomOut';\n\ntype DeviceKey =\n\t| 'BrightnessDown' | 'BrightnessUp' | 'Eject' | 'Hibernate'\n\t| 'LogOff' | 'Power' | 'PowerOff' | 'PrintScreen' | 'Standby' | 'WakeUp';\n\ntype IMEKey =\n\t| 'AllCandidates' | 'Alphanumeric' | 'CodeInput' | 'Compose' | 'Convert'\n\t| 'FinalMode' | 'GroupFirst' | 'GroupLast' | 'GroupNext' | 'GroupPrevious'\n\t| 'ModeChange' | 'NextCandidate' | 'NonConvert' | 'PreviousCandidate'\n\t| 'Process' | 'SingleCandidate'\n\t| 'HangulMode' | 'HanjaMode' | 'JunjaMode'\n\t| 'Eisu' | 'Hankaku' | 'Hiragana' | 'HiraganaKatakana' | 'KanaMode'\n\t| 'KanjiMode' | 'Katakana' | 'Romaji' | 'Zenkaku' | 'ZenkakuHankaku';\n\ntype FunctionKey =\n\t| `F${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24}`\n\t| 'Soft1' | 'Soft2' | 'Soft3' | 'Soft4';\n\ntype PhoneKey =\n\t| 'AppSwitch' | 'Call' | 'Camera' | 'CameraFocus' | 'EndCall'\n\t| 'GoBack' | 'GoHome' | 'HeadsetHook' | 'LastNumberRedial'\n\t| 'Notification' | 'MannerMode' | 'VoiceDial';\n\ntype MultimediaKey =\n\t| 'ChannelDown' | 'ChannelUp'\n\t| `Media${\n\t\t'FastForward' | 'Pause' | 'Play' | 'PlayPause'\n\t\t| 'Record' | 'Rewind' | 'Stop' | 'TrackNext' | 'TrackPrevious'\n\t}`;\n\ntype AudioKey =\n\t| `Audio${\n\t\t'BalanceLeft' | 'BalanceRight' | 'BassDown' | 'BassBoostDown'\n\t\t| 'BassBoostToggle' | 'BassBoostUp' | 'BassUp' | 'FaderFront' | 'FaderRear'\n\t\t| 'SurroundModeNext' | 'TrebleDown' | 'TrebleUp'\n\t\t| 'VolumeDown' | 'VolumeMute' | 'VolumeUp'\n\t}`\n\t| `Microphone${'Toggle' | 'VolumeDown' | 'VolumeMute' | 'VolumeUp'}`;\n\ntype TVKey =\n\t| 'TV'\n\t| `TV${\n\t\t'3DMode' | 'AntennaCable' | 'AudioDescription' | 'AudioDescriptionMixDown'\n\t\t| 'AudioDescriptionMixUp' | 'ContentsMenu' | 'DataService' | 'Input'\n\t\t| 'InputComponent1' | 'InputComponent2' | 'InputComposite1' | 'InputComposite2'\n\t\t| 'InputHDMI1' | 'InputHDMI2' | 'InputHDMI3' | 'InputHDMI4' | 'InputVGA1'\n\t\t| 'MediaContext' | 'Network' | 'NumberEntry' | 'Power' | 'RadioService'\n\t\t| 'Satellite' | 'SatelliteBS' | 'SatelliteCS' | 'SatelliteToggle'\n\t\t| 'TerrestrialAnalog' | 'TerrestrialDigital' | 'Timer'\n\t}`;\n\ntype MediaControllerKey =\n\t| 'AVRInput' | 'AVRPower'\n\t| `Color${'F0Red' | 'F1Green' | 'F2Yellow' | 'F3Blue' | 'F4Grey' | 'F5Brown'}`\n\t| 'ClosedCaptionToggle' | 'Dimmer' | 'DisplaySwap' | 'DVR' | 'Exit'\n\t| `Favorite${'Clear' | 'Recall' | 'Store'}${0 | 1 | 2 | 3}`\n\t| 'Guide' | 'GuideNextDay' | 'GuidePreviousDay' | 'Info' | 'InstantReplay'\n\t| 'Link' | 'ListProgram' | 'LiveContent' | 'Lock'\n\t| `Media${\n\t\t'Apps' | 'AudioTrack' | 'Last' | 'SkipBackward'\n\t\t| 'SkipForward' | 'StepBackward' | 'StepForward' | 'TopMenu'\n\t}`\n\t| `Navigate${'In' | 'Next' | 'Out' | 'Previous'}`\n\t| 'NextFavoriteChannel' | 'NextUserProfile' | 'OnDemand' | 'Pairing'\n\t| `PinP${'Down' | 'Move' | 'Toggle' | 'Up'}`\n\t| `PlaySpeed${'Down' | 'Reset' | 'Up'}`\n\t| 'RandomToggle' | 'RcLowBattery' | 'RecordSpeedNext' | 'RfBypass'\n\t| 'ScanChannelsToggle' | 'ScreenModeNext' | 'Settings' | 'SplitScreenToggle'\n\t| 'STBInput' | 'STBPower' | 'Subtitle' | 'Teletext'\n\t| 'VideoModeNext' | 'Wink' | 'ZoomToggle';\n\ntype SpeechKey = 'SpeechCorrectionList' | 'SpeechInputToggle';\n\ntype DocumentKey =\n\t| 'Close' | 'New' | 'Open' | 'Print' | 'Save' | 'SpellCheck'\n\t| 'MailForward' | 'MailReply' | 'MailSend';\n\ntype LaunchKey = `Launch${\n\t| 'Calculator' | 'Calendar' | 'Contacts' | 'Mail' | 'MediaPlayer'\n\t| 'MusicPlayer' | 'MyComputer' | 'Phone' | 'ScreenSaver' | 'Spreadsheet'\n\t| 'WebBrowser' | 'WebCam' | 'WordProcessor'\n\t| `Application${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16}`\n}`;\n\ntype BrowserKey = `Browser${'Back' | 'Favorites' | 'Forward' | 'Home' | 'Refresh' | 'Search' | 'Stop'}`;\n\ntype NumpadKey = 'Decimal' | 'Key11' | 'Key12' | 'Multiply' | 'Add' | 'Divide' | 'Subtract' | 'Separator';\n\nexport type KeyCode =\n\t| LowercaseLetter | Uppercase<LowercaseLetter> | Digit | Punctuation\n\t| ModifierKey | WhitespaceKey | NavigationKey | EditingKey | UIKey | DeviceKey\n\t| IMEKey | FunctionKey | PhoneKey | MultimediaKey | AudioKey | TVKey\n\t| MediaControllerKey | SpeechKey | DocumentKey | LaunchKey | BrowserKey | NumpadKey\n\t| 'Unidentified' | 'Dead';\n\nexport interface KeyboardState {\n\tisDown(key: KeyCode): boolean;\n\tjustPressed(key: KeyCode): boolean;\n\tjustReleased(key: KeyCode): boolean;\n}\n\nexport interface PointerState {\n\treadonly position: Readonly<Vec2>;\n\treadonly delta: Readonly<Vec2>;\n\tisDown(button: number): boolean;\n\tjustPressed(button: number): boolean;\n\tjustReleased(button: number): boolean;\n}\n\nexport interface ActionState {\n\tisActive(action: string): boolean;\n\tjustActivated(action: string): boolean;\n\tjustDeactivated(action: string): boolean;\n}\n\nexport interface InputState {\n\treadonly keyboard: KeyboardState;\n\treadonly pointer: PointerState;\n\treadonly actions: ActionState;\n\tsetActionMap(actions: ActionMap): void;\n\tgetActionMap(): Readonly<ActionMap>;\n}\n\nexport interface ActionBinding {\n\tkeys?: KeyCode[];\n\tbuttons?: number[];\n}\n\nexport type ActionMap = Record<string, ActionBinding>;\n\nexport interface InputResourceTypes {\n\tinputState: InputState;\n}\n\nexport interface InputBundleOptions {\n\t/** System group name (default: 'input') */\n\tsystemGroup?: string;\n\t/** Priority for input system (default: 100) */\n\tpriority?: number;\n\t/** Execution phase (default: 'preUpdate') */\n\tphase?: SystemPhase;\n\t/** Initial action mappings */\n\tactions?: ActionMap;\n\t/** EventTarget to attach listeners to (default: globalThis). Pass a custom target for testability. */\n\ttarget?: EventTarget;\n}\n\n// ==================== Helper Functions ====================\n\n/**\n * Create a single action binding.\n *\n * @param binding The binding configuration\n * @returns The same binding object\n */\nexport function createActionBinding(binding: ActionBinding): ActionBinding {\n\treturn binding;\n}\n\n// ==================== Internal Types ====================\n\ninterface RawInputState {\n\tkeysDown: Set<string>;\n\tkeysPressed: string[];\n\tkeysReleased: string[];\n\tbuttonsDown: Set<number>;\n\tbuttonsPressed: number[];\n\tbuttonsReleased: number[];\n\tpointerX: number;\n\tpointerY: number;\n\tpointerDeltaX: number;\n\tpointerDeltaY: number;\n\tlastPointerX: number;\n\tlastPointerY: number;\n\tpointerMoved: boolean;\n}\n\ninterface FrameSnapshot {\n\tkeysDown: ReadonlySet<string>;\n\tkeysPressed: ReadonlySet<string>;\n\tkeysReleased: ReadonlySet<string>;\n\tbuttonsDown: ReadonlySet<number>;\n\tbuttonsPressed: ReadonlySet<number>;\n\tbuttonsReleased: ReadonlySet<number>;\n\tpointerX: number;\n\tpointerY: number;\n\tpointerDeltaX: number;\n\tpointerDeltaY: number;\n\tactionsActive: ReadonlySet<string>;\n\tprevActionsActive: ReadonlySet<string>;\n}\n\n// ==================== Bundle Factory ====================\n\nfunction createRawInputState(): RawInputState {\n\treturn {\n\t\tkeysDown: new Set(),\n\t\tkeysPressed: [],\n\t\tkeysReleased: [],\n\t\tbuttonsDown: new Set(),\n\t\tbuttonsPressed: [],\n\t\tbuttonsReleased: [],\n\t\tpointerX: 0,\n\t\tpointerY: 0,\n\t\tpointerDeltaX: 0,\n\t\tpointerDeltaY: 0,\n\t\tlastPointerX: 0,\n\t\tlastPointerY: 0,\n\t\tpointerMoved: false,\n\t};\n}\n\nconst EMPTY_SET_STRING: ReadonlySet<string> = new Set<string>();\nconst EMPTY_SET_NUMBER: ReadonlySet<number> = new Set<number>();\n\nfunction createEmptySnapshot(): FrameSnapshot {\n\treturn {\n\t\tkeysDown: EMPTY_SET_STRING,\n\t\tkeysPressed: EMPTY_SET_STRING,\n\t\tkeysReleased: EMPTY_SET_STRING,\n\t\tbuttonsDown: EMPTY_SET_NUMBER,\n\t\tbuttonsPressed: EMPTY_SET_NUMBER,\n\t\tbuttonsReleased: EMPTY_SET_NUMBER,\n\t\tpointerX: 0,\n\t\tpointerY: 0,\n\t\tpointerDeltaX: 0,\n\t\tpointerDeltaY: 0,\n\t\tactionsActive: EMPTY_SET_STRING,\n\t\tprevActionsActive: EMPTY_SET_STRING,\n\t};\n}\n\nfunction computeActiveActions(\n\tactionMap: ActionMap,\n\tkeysDown: ReadonlySet<string>,\n\tbuttonsDown: ReadonlySet<number>,\n): Set<string> {\n\tconst active = new Set<string>();\n\tfor (const [name, binding] of Object.entries(actionMap)) {\n\t\tconst keyActive = binding.keys?.some((k) => keysDown.has(k)) ?? false;\n\t\tconst buttonActive = binding.buttons?.some((b) => buttonsDown.has(b)) ?? false;\n\t\tif (keyActive || buttonActive) {\n\t\t\tactive.add(name);\n\t\t}\n\t}\n\treturn active;\n}\n\nfunction snapshotRaw(raw: RawInputState, prevActionsActive: ReadonlySet<string>, actionMap: ActionMap): FrameSnapshot {\n\tconst keysDown = new Set(raw.keysDown);\n\tconst keysPressed = new Set(raw.keysPressed);\n\tconst keysReleased = new Set(raw.keysReleased);\n\tconst buttonsDown = new Set(raw.buttonsDown);\n\tconst buttonsPressed = new Set(raw.buttonsPressed);\n\tconst buttonsReleased = new Set(raw.buttonsReleased);\n\n\tconst pointerDeltaX = raw.pointerMoved ? raw.pointerX - raw.lastPointerX : 0;\n\tconst pointerDeltaY = raw.pointerMoved ? raw.pointerY - raw.lastPointerY : 0;\n\n\tconst actionsActive = computeActiveActions(actionMap, keysDown, buttonsDown);\n\n\tconst snapshot: FrameSnapshot = {\n\t\tkeysDown,\n\t\tkeysPressed,\n\t\tkeysReleased,\n\t\tbuttonsDown,\n\t\tbuttonsPressed,\n\t\tbuttonsReleased,\n\t\tpointerX: raw.pointerX,\n\t\tpointerY: raw.pointerY,\n\t\tpointerDeltaX,\n\t\tpointerDeltaY,\n\t\tactionsActive,\n\t\tprevActionsActive,\n\t};\n\n\t// Clear accumulation buffers\n\traw.keysPressed = [];\n\traw.keysReleased = [];\n\traw.buttonsPressed = [];\n\traw.buttonsReleased = [];\n\traw.lastPointerX = raw.pointerX;\n\traw.lastPointerY = raw.pointerY;\n\traw.pointerMoved = false;\n\n\treturn snapshot;\n}\n\n/**\n * Create an input bundle for ECSpresso.\n *\n * This bundle provides:\n * - Frame-accurate keyboard state (isDown, justPressed, justReleased)\n * - Pointer position/delta and button state (mouse + touch via PointerEvent)\n * - Named action mapping with runtime remapping\n * - Automatic listener cleanup on detach\n *\n * @example\n * ```typescript\n * const ecs = ECSpresso\n * .create<Components, Events, Resources>()\n * .withBundle(createInputBundle({\n * actions: {\n * jump: { keys: [' ', 'ArrowUp'] },\n * shoot: { keys: ['z'], buttons: [0] },\n * },\n * }))\n * .build();\n *\n * // In a system:\n * const input = ecs.getResource('inputState');\n * if (input.actions.justActivated('jump')) { ... }\n * if (input.keyboard.isDown('ArrowRight')) { ... }\n * ```\n */\nexport function createInputBundle(\n\toptions?: InputBundleOptions\n): Bundle<{}, {}, InputResourceTypes> {\n\tconst {\n\t\tsystemGroup = 'input',\n\t\tpriority = 100,\n\t\tphase = 'preUpdate',\n\t\tactions: initialActions = {},\n\t\ttarget = globalThis,\n\t} = options ?? {};\n\n\t// Closure state\n\tconst raw = createRawInputState();\n\tlet snapshot = createEmptySnapshot();\n\tlet actionMap: ActionMap = { ...initialActions };\n\tconst cleanupFns: Array<() => void> = [];\n\n\t// The position/delta objects exposed via the resource.\n\t// Updated in-place each frame to avoid allocations.\n\tconst position: Vec2 = { x: 0, y: 0 };\n\tconst delta: Vec2 = { x: 0, y: 0 };\n\n\t// Build the InputState resource that closes over snapshot\n\tconst keyboard: KeyboardState = {\n\t\tisDown: (key) => snapshot.keysDown.has(key),\n\t\tjustPressed: (key) => snapshot.keysPressed.has(key),\n\t\tjustReleased: (key) => snapshot.keysReleased.has(key),\n\t};\n\n\tconst pointer: PointerState = {\n\t\tposition,\n\t\tdelta,\n\t\tisDown: (button) => snapshot.buttonsDown.has(button),\n\t\tjustPressed: (button) => snapshot.buttonsPressed.has(button),\n\t\tjustReleased: (button) => snapshot.buttonsReleased.has(button),\n\t};\n\n\tconst actionState: ActionState = {\n\t\tisActive: (action) => snapshot.actionsActive.has(action),\n\t\tjustActivated: (action) =>\n\t\t\tsnapshot.actionsActive.has(action) && !snapshot.prevActionsActive.has(action),\n\t\tjustDeactivated: (action) =>\n\t\t\t!snapshot.actionsActive.has(action) && snapshot.prevActionsActive.has(action),\n\t};\n\n\tconst inputState: InputState = {\n\t\tkeyboard,\n\t\tpointer,\n\t\tactions: actionState,\n\t\tsetActionMap(newMap) {\n\t\t\tactionMap = { ...newMap };\n\t\t},\n\t\tgetActionMap() {\n\t\t\treturn { ...actionMap };\n\t\t},\n\t};\n\n\t// DOM event handlers\n\tfunction onKeyDown(e: Event) {\n\t\tconst ke = e as KeyboardEvent;\n\t\tif (ke.repeat) return;\n\t\traw.keysDown.add(ke.key);\n\t\traw.keysPressed.push(ke.key);\n\t}\n\n\tfunction onKeyUp(e: Event) {\n\t\tconst ke = e as KeyboardEvent;\n\t\traw.keysDown.delete(ke.key);\n\t\traw.keysReleased.push(ke.key);\n\t}\n\n\tfunction onPointerDown(e: Event) {\n\t\tconst pe = e as unknown as PointerEvent;\n\t\traw.buttonsDown.add(pe.button);\n\t\traw.buttonsPressed.push(pe.button);\n\t}\n\n\tfunction onPointerMove(e: Event) {\n\t\tconst pe = e as unknown as PointerEvent;\n\t\traw.pointerX = pe.clientX;\n\t\traw.pointerY = pe.clientY;\n\t\traw.pointerMoved = true;\n\t}\n\n\tfunction onPointerUp(e: Event) {\n\t\tconst pe = e as unknown as PointerEvent;\n\t\traw.buttonsDown.delete(pe.button);\n\t\traw.buttonsReleased.push(pe.button);\n\t}\n\n\tfunction addListener(type: string, handler: (e: Event) => void) {\n\t\ttarget.addEventListener(type, handler);\n\t\tcleanupFns.push(() => target.removeEventListener(type, handler));\n\t}\n\n\t// Build bundle\n\tconst bundle = new Bundle<{}, {}, InputResourceTypes>('input');\n\n\tbundle.addResource('inputState', inputState);\n\n\tbundle\n\t\t.addSystem('input-state')\n\t\t.setPriority(priority)\n\t\t.inPhase(phase)\n\t\t.inGroup(systemGroup)\n\t\t.setOnInitialize(() => {\n\t\t\taddListener('keydown', onKeyDown);\n\t\t\taddListener('keyup', onKeyUp);\n\t\t\taddListener('pointerdown', onPointerDown);\n\t\t\taddListener('pointermove', onPointerMove);\n\t\t\taddListener('pointerup', onPointerUp);\n\t\t})\n\t\t.setOnDetach(() => {\n\t\t\tfor (const cleanup of cleanupFns) {\n\t\t\t\tcleanup();\n\t\t\t}\n\t\t\tcleanupFns.length = 0;\n\t\t})\n\t\t.setProcess(() => {\n\t\t\tconst prevActionsActive = snapshot.actionsActive;\n\t\t\tsnapshot = snapshotRaw(raw, prevActionsActive, actionMap);\n\n\t\t\t// Update the exposed position/delta objects in-place\n\t\t\tposition.x = snapshot.pointerX;\n\t\t\tposition.y = snapshot.pointerY;\n\t\t\tdelta.x = snapshot.pointerDeltaX;\n\t\t\tdelta.y = snapshot.pointerDeltaY;\n\t\t})\n\t\t.and();\n\n\treturn bundle;\n}\n"
6
- ],
7
- "mappings": "2PAWA,iBAAS,kBAsMF,SAAS,CAAmB,CAAC,EAAuC,CAC1E,OAAO,EAsCR,SAAS,CAAmB,EAAkB,CAC7C,MAAO,CACN,SAAU,IAAI,IACd,YAAa,CAAC,EACd,aAAc,CAAC,EACf,YAAa,IAAI,IACjB,eAAgB,CAAC,EACjB,gBAAiB,CAAC,EAClB,SAAU,EACV,SAAU,EACV,cAAe,EACf,cAAe,EACf,aAAc,EACd,aAAc,EACd,aAAc,EACf,EAGD,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