@daneren2005/shared-memory-ecs 1.10.2 → 1.10.4

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.
package/README.md CHANGED
@@ -926,6 +926,27 @@ through `system.addEntities(batch)`. Entities with the same component keys are g
926
926
  test runs once per group instead of once per entity; system membership keeps load order. A system that overrides
927
927
  `checkAddEntity` (or an `EntityWorkerSystem` that overrides `matchesQuery`) still has it called for each entity.
928
928
 
929
+ #### Loading in slices with progress
930
+
931
+ A big save can block the main thread for seconds. Pass `sliceMs` and `load()` yields to the event loop whenever a
932
+ slice runs over, reporting progress as it goes:
933
+
934
+ ```ts
935
+ await world.load(save, {
936
+ sliceMs: 25,
937
+ onProgress: ({ phase, done, total, fraction }) => setBar(fraction),
938
+ // Systems hold every entity and their load messages are posted; only worker replies are left.
939
+ onEntitiesReady: () => buildIndexes(world),
940
+ });
941
+ ```
942
+
943
+ Phases run `entities` → `linking` (`finishLoading`, `entity-added`) → `systems` (`addEntities`, then
944
+ `finishLoading`) → `workers` (replies). `fraction` weights them 0.6 / 0.1 / 0.1 / 0.2. `yieldTo` overrides the yield
945
+ (default `scheduler.yield()`, else `setTimeout(0)`). While `world.isLoading` is set, `update()` does nothing; don't touch
946
+ the world until `load()` resolves. A `load()`, `clear()` or `destroy()` during a sliced load, or aborting its `signal`, rejects it
947
+ with an `AbortError`, and the next load or clear tears down the partly loaded world. Without `sliceMs`, `load()` runs
948
+ synchronously up to awaiting the workers, and `onProgress`/`onEntitiesReady` still fire.
949
+
929
950
  ### Compressing saves
930
951
 
931
952
  Big maps are mostly entities whose save is a `type` plus a few integers. `compressEntities(entities, definitions)`
@@ -1019,3 +1040,5 @@ npm install
1019
1040
  npm run build # emits dist/ (js + d.ts)
1020
1041
  npm run type-check
1021
1042
  ```
1043
+
1044
+ Workers invoked directly outside scheduler dispatch publish their effects immediately. Replies from before a scheduler reset are discarded.
@@ -37,4 +37,5 @@ export declare class EntityCompressor {
37
37
  export declare function compressEntities<Cfg extends CompressibleConfig>(entities: ReadonlyArray<Cfg>, definitions: ReadonlyArray<CompressedEntityDefinition>): CompressedEntities<Cfg>;
38
38
  export declare function decompressEntity(encoded: string, definitions: CompressedEntityDefinitions): Record<string, DecompressedValue | string>;
39
39
  export declare function decompressEntities<Cfg>(entities: ReadonlyArray<Cfg | string>, definitions: CompressedEntityDefinitions | undefined): Array<Cfg>;
40
+ export declare function decompressEntityConfig<Cfg>(entity: Cfg | string, definitions: CompressedEntityDefinitions | undefined): Cfg;
40
41
  export {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as BaseWorld } from './world';
2
- export type { WorldOptions, WorldConfig, CompressedWorldConfig } from './world';
2
+ export type { WorldOptions, WorldConfig, CompressedWorldConfig, WorldLoadOptions, WorldLoadPhase, WorldLoadProgress } from './world';
3
3
  export { EntityCompressor, compressEntities, decompressEntity, decompressEntities } from './entity-compression';
4
4
  export type { CompressedEntities, CompressedEntityDefinition, CompressedEntityDefinitions, CompressedEntityProperty, CompressedPropertyType, } from './entity-compression';
5
5
  export { default as DefaultScheduler } from './scheduling/default-scheduler';