@forgeax/engine-ecs 0.1.26 → 0.1.28

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 (50) hide show
  1. package/README.md +94 -35
  2. package/dist/__tests__/world-read.unit.test.d.ts +2 -0
  3. package/dist/__tests__/world-read.unit.test.d.ts.map +1 -0
  4. package/dist/commands.d.ts +2 -0
  5. package/dist/commands.d.ts.map +1 -1
  6. package/dist/index.mjs +3471 -4263
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/internal.d.ts +2 -3
  9. package/dist/internal.d.ts.map +1 -1
  10. package/dist/internal.mjs +3 -333
  11. package/dist/internal.mjs.map +1 -1
  12. package/dist/projection/index.mjs.map +1 -1
  13. package/dist/shared.mjs.map +1 -1
  14. package/dist/world-entity-lifecycle.d.ts +3 -14
  15. package/dist/world-entity-lifecycle.d.ts.map +1 -1
  16. package/dist/world-internal.d.ts +65 -5
  17. package/dist/world-internal.d.ts.map +1 -1
  18. package/dist/world-read.d.ts +16 -0
  19. package/dist/world-read.d.ts.map +1 -0
  20. package/dist/world-read.mjs +8 -0
  21. package/dist/world-read.mjs.map +1 -0
  22. package/dist/world-scheduling.d.ts +0 -4
  23. package/dist/world-scheduling.d.ts.map +1 -1
  24. package/dist/world-storage-primitives.d.ts +26 -0
  25. package/dist/world-storage-primitives.d.ts.map +1 -0
  26. package/dist/world.d.ts +352 -157
  27. package/dist/world.d.ts.map +1 -1
  28. package/package.json +8 -4
  29. package/src/__tests__/command-buffer.test.ts +29 -3
  30. package/src/__tests__/hierarchy.unit.test.ts +3 -3
  31. package/src/__tests__/world-health.contract.test.ts +195 -2
  32. package/src/__tests__/world-read.unit.test.ts +30 -0
  33. package/src/commands.ts +22 -9
  34. package/src/internal.ts +5 -3
  35. package/src/world-entity-lifecycle.ts +23 -252
  36. package/src/world-internal-augmentation.d.ts +11 -0
  37. package/src/world-internal.ts +114 -63
  38. package/src/world-read.ts +38 -0
  39. package/src/world-scheduling.ts +0 -26
  40. package/src/world-storage-primitives.ts +179 -0
  41. package/src/world.ts +2590 -509
  42. package/dist/world-component-access.d.ts +0 -311
  43. package/dist/world-component-access.d.ts.map +0 -1
  44. package/dist/world-component-storage.d.ts +0 -298
  45. package/dist/world-component-storage.d.ts.map +0 -1
  46. package/dist/world-core.d.ts +0 -39
  47. package/dist/world-core.d.ts.map +0 -1
  48. package/src/world-component-access.ts +0 -1769
  49. package/src/world-component-storage.ts +0 -1264
  50. package/src/world-core.ts +0 -74
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-read.d.ts","sourceRoot":"","sources":["../src/world-read.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,oEAAoE;AACpE,eAAO,MAAM,SAAS,EAAE,OAAO,MAEC,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,aAAa,EAAE,CACtB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,KACd,MAAM,GAAG,SAAS,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,CACvB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,KACd,MAAM,GAAG,SAAS,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,CACxB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,KACV,MAAM,GAAG,SAAS,CAAC;CACzB"}
@@ -0,0 +1,8 @@
1
+ // src/world-read.ts
2
+ var worldRead = /* @__PURE__ */ Symbol.for(
3
+ "forgeax.ecs.worldRead"
4
+ );
5
+
6
+ export { worldRead };
7
+ //# sourceMappingURL=world-read.mjs.map
8
+ //# sourceMappingURL=world-read.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/world-read.ts"],"names":[],"mappings":";AAUO,IAAM,4BAA2B,MAAA,CAAO,GAAA;AAAA,EAC7C;AACF","file":"world-read.mjs","sourcesContent":["// @forgeax/engine-ecs — safe read-only World seam.\n//\n// This is the only cross-package World capability needed by relationship and\n// scene projections. It exposes semantic scalar/array reads, never the table,\n// archetype, buffer-pool, or mutation stores behind those reads.\n\nimport type { Component } from './component';\nimport type { EntityHandle } from './entity-handle';\n\n/** Stable identity for the World-owned semantic read capability. */\nexport const worldRead: unique symbol = Symbol.for(\n 'forgeax.ecs.worldRead',\n) as unknown as typeof worldRead;\n\n/**\n * Read-only semantic probes used by owner packages such as scene.\n *\n * Missing entities, components, fields, and out-of-range elements return\n * `undefined`; callers never receive a storage object or mutable view.\n */\nexport interface WorldRead {\n readonly getFieldValue: (\n entity: EntityHandle,\n component: Component,\n fieldName: string,\n ) => number | undefined;\n readonly getArrayLength: (\n entity: EntityHandle,\n component: Component,\n fieldName: string,\n ) => number | undefined;\n readonly getArrayElement: (\n entity: EntityHandle,\n component: Component,\n fieldName: string,\n index: number,\n ) => number | undefined;\n}\n"]}
@@ -1,4 +1,3 @@
1
- import type { Handle } from '@forgeax/engine-types';
2
1
  import { type Result } from '@forgeax/engine-types';
3
2
  import { CommandFailedError, CyclicDependencyError, ScheduleScopeMismatchError, SystemFailedError, type SystemSetNotRegisteredError, TimeConfigInvalidError, TimeDeltaInvalidError } from './errors';
4
3
  import { SharedKernelFailureError, WorldPoisonedError } from './execution/shared-kernel';
@@ -23,8 +22,5 @@ export declare function worldInspect(world: World): WorldInspection;
23
22
  export declare function worldScheduleData(world: World): ReadonlyArray<WorldScheduleData>;
24
23
  /** Control-plane guard used before releasing a World-local component registration. */
25
24
  export declare function worldScheduleUsesComponent(world: World, component: object): boolean;
26
- export declare function worldAllocUniqueRef<Target extends string, T>(world: World, target: Target, payload: T, onRelease?: (payload: T) => void): Handle<Target, 'unique'>;
27
- export declare function worldAllocSharedRef<Target extends string, T>(world: World, target: Target, payload: T): Handle<Target, 'shared'>;
28
- export declare function worldInternSharedRef<Target extends string, T extends object>(world: World, target: Target, payload: T): Handle<Target, 'shared'>;
29
25
  export {};
30
26
  //# sourceMappingURL=world-scheduling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"world-scheduling.d.ts","sourceRoot":"","sources":["../src/world-scheduling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EAErB,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,2BAA2B,EAChC,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAIL,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOrD,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAGd,YAAY,IAAI,oBAAoB,EACpC,aAAa,IAAI,qBAAqB,EACvC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAgC,KAAK,aAAa,EAAU,MAAM,kBAAkB,CAAC;AAG5F,OAAO,KAAK,EACV,KAAK,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,SAAS,CAAC;AAIjB,KAAK,WAAW,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAyCtD,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,SAAS,aAAa,CAAC,eAAe,CAAC,EAC5E,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAC/B,MAAM,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAM1C;AAED,wBA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
3
+ export declare function detachWorldInspection<T extends object>(snapshot: T): Readonly<T>;
4
+ /**
5
+ * Element-byte-width for a managed-array element type, read off the global
6
+ * TYPE_METADATA table (single SSOT). `entity` stores as `u32` (4 bytes); every
7
+ * scalar maps to its own key. `fieldTypeToMetaKey` always resolves a key for a
8
+ * ManagedArrayElementType, and every such row carries a concrete `byteSize`.
9
+ */
10
+ export declare function elementByteSize(elementType: ManagedArrayElementType): number;
11
+ export declare function reinterpretSlotBytes(bytes: Uint8Array, elementType: ManagedArrayElementType, elementCount: number): ReturnType<typeof reinterpretBufferRegion>;
12
+ export declare function reinterpretBufferRegion(buffer: ArrayBufferLike, byteOffset: number, elementType: ManagedArrayElementType, elementCount: number): Float32Array | Float64Array | Int32Array | Uint32Array | Int16Array | Uint16Array | Int8Array | Uint8Array;
13
+ /**
14
+ * Reinterpret `bytes` as the typed view for `elementType` and write `value`
15
+ * at element index `idx`. Mirrors the `array<T>` storage law (4/8/2/1-byte
16
+ * element widths per TYPE_METADATA.byteSize) and is used by `world.push`
17
+ * to land a new tail element into BufferPool slot bytes after a `grow`.
18
+ */
19
+ export declare function writeArrayElementAt(bytes: Uint8Array, idx: number, elementType: ManagedArrayElementType, value: number): void;
20
+ /**
21
+ * Reinterpret `bytes` as the typed view for `elementType` and read element
22
+ * `idx`. Mirrors `writeArrayElementAt` -- consumed by `world.pop` to materialise
23
+ * the tail value before the count is decremented.
24
+ */
25
+ export declare function readArrayElementAt(bytes: Uint8Array, idx: number, elementType: ManagedArrayElementType): number;
26
+ //# sourceMappingURL=world-storage-primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-storage-primitives.d.ts","sourceRoot":"","sources":["../src/world-storage-primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,uBAAuB,EAAiB,MAAM,aAAa,CAAC;AAE9F,2DAA2D;AAC3D,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAEhF;AAeD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,uBAAuB,GAAG,MAAM,CAI5E;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,uBAAuB,EACpC,YAAY,EAAE,MAAM,GACnB,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAE5C;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,uBAAuB,EACpC,YAAY,EAAE,MAAM,GAElB,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,CAmCb;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,uBAAuB,EACpC,KAAK,EAAE,MAAM,GACZ,IAAI,CAkCN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,uBAAuB,GACnC,MAAM,CAgCR"}