@oasys/oecs 0.3.1 → 0.4.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.
- package/README.md +196 -267
- package/dist/array-CxbPyiHO.cjs +1 -0
- package/dist/array-uFR7Q8fU.js +132 -0
- package/dist/core/ecs/access_check.d.ts +77 -0
- package/dist/core/ecs/access_check.d.ts.map +1 -0
- package/dist/core/ecs/archetype.d.ts +474 -0
- package/dist/core/ecs/archetype.d.ts.map +1 -0
- package/dist/core/ecs/builtin_relations.d.ts +43 -0
- package/dist/core/ecs/builtin_relations.d.ts.map +1 -0
- package/dist/core/ecs/command_log.d.ts +113 -0
- package/dist/core/ecs/command_log.d.ts.map +1 -0
- package/dist/core/ecs/component.d.ts +106 -0
- package/dist/core/ecs/component.d.ts.map +1 -0
- package/dist/core/ecs/compute_backend.d.ts +37 -0
- package/dist/core/ecs/compute_backend.d.ts.map +1 -0
- package/dist/core/ecs/dispatch_trace.d.ts +93 -0
- package/dist/core/ecs/dispatch_trace.d.ts.map +1 -0
- package/dist/core/ecs/ecs.d.ts +533 -0
- package/dist/core/ecs/ecs.d.ts.map +1 -0
- package/dist/core/ecs/ecs_memory.d.ts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts.map +1 -0
- package/dist/core/ecs/entity.d.ts +28 -0
- package/dist/core/ecs/entity.d.ts.map +1 -0
- package/dist/core/ecs/event.d.ts +54 -0
- package/dist/core/ecs/event.d.ts.map +1 -0
- package/dist/core/ecs/frame_trace.d.ts +133 -0
- package/dist/core/ecs/frame_trace.d.ts.map +1 -0
- package/dist/core/ecs/host_commands.d.ts +252 -0
- package/dist/core/ecs/host_commands.d.ts.map +1 -0
- package/dist/core/ecs/index.d.ts +41 -0
- package/dist/core/ecs/index.d.ts.map +1 -0
- package/dist/core/ecs/observer.d.ts +142 -0
- package/dist/core/ecs/observer.d.ts.map +1 -0
- package/dist/core/ecs/query.d.ts +557 -0
- package/dist/core/ecs/query.d.ts.map +1 -0
- package/dist/core/ecs/ref.d.ts +31 -0
- package/dist/core/ecs/ref.d.ts.map +1 -0
- package/dist/core/ecs/relation.d.ts +231 -0
- package/dist/core/ecs/relation.d.ts.map +1 -0
- package/dist/core/ecs/resource.d.ts +33 -0
- package/dist/core/ecs/resource.d.ts.map +1 -0
- package/dist/core/ecs/resume.d.ts +85 -0
- package/dist/core/ecs/resume.d.ts.map +1 -0
- package/dist/core/ecs/run_condition.d.ts +75 -0
- package/dist/core/ecs/run_condition.d.ts.map +1 -0
- package/dist/core/ecs/schedule.d.ts +133 -0
- package/dist/core/ecs/schedule.d.ts.map +1 -0
- package/dist/core/ecs/sparse_store.d.ts +107 -0
- package/dist/core/ecs/sparse_store.d.ts.map +1 -0
- package/dist/core/ecs/store.d.ts +1149 -0
- package/dist/core/ecs/store.d.ts.map +1 -0
- package/dist/core/ecs/store_layout_listener.d.ts +23 -0
- package/dist/core/ecs/store_layout_listener.d.ts.map +1 -0
- package/dist/core/ecs/system.d.ts +134 -0
- package/dist/core/ecs/system.d.ts.map +1 -0
- package/dist/core/ecs/utils/arrays.d.ts +7 -0
- package/dist/core/ecs/utils/arrays.d.ts.map +1 -0
- package/dist/core/ecs/utils/constants.d.ts +12 -0
- package/dist/core/ecs/utils/constants.d.ts.map +1 -0
- package/dist/core/ecs/utils/error.d.ts +51 -0
- package/dist/core/ecs/utils/error.d.ts.map +1 -0
- package/dist/core/reactive/array.d.ts +24 -0
- package/dist/core/reactive/array.d.ts.map +1 -0
- package/dist/core/reactive/index.cjs +1 -0
- package/dist/core/reactive/index.d.ts +10 -0
- package/dist/core/reactive/index.d.ts.map +1 -0
- package/dist/core/reactive/index.js +17 -0
- package/dist/core/reactive/interop.d.ts +19 -0
- package/dist/core/reactive/interop.d.ts.map +1 -0
- package/dist/core/reactive/kernel.d.ts +71 -0
- package/dist/core/reactive/kernel.d.ts.map +1 -0
- package/dist/core/reactive/map.d.ts +16 -0
- package/dist/core/reactive/map.d.ts.map +1 -0
- package/dist/core/reactive/struct.d.ts +10 -0
- package/dist/core/reactive/struct.d.ts.map +1 -0
- package/dist/core/store/__generated__/abi.d.ts +43 -0
- package/dist/core/store/__generated__/abi.d.ts.map +1 -0
- package/dist/core/store/action_ring.d.ts +136 -0
- package/dist/core/store/action_ring.d.ts.map +1 -0
- package/dist/core/store/allocator.d.ts +238 -0
- package/dist/core/store/allocator.d.ts.map +1 -0
- package/dist/core/store/buffer_backed_column.d.ts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -0
- package/dist/core/store/column_store.d.ts +265 -0
- package/dist/core/store/column_store.d.ts.map +1 -0
- package/dist/core/store/command_dispatch.d.ts +52 -0
- package/dist/core/store/command_dispatch.d.ts.map +1 -0
- package/dist/core/store/command_ring.d.ts +107 -0
- package/dist/core/store/command_ring.d.ts.map +1 -0
- package/dist/core/store/descriptor.d.ts +80 -0
- package/dist/core/store/descriptor.d.ts.map +1 -0
- package/dist/core/store/entity_index.d.ts +108 -0
- package/dist/core/store/entity_index.d.ts.map +1 -0
- package/dist/core/store/event_ring.d.ts +95 -0
- package/dist/core/store/event_ring.d.ts.map +1 -0
- package/dist/core/store/extend.d.ts +109 -0
- package/dist/core/store/extend.d.ts.map +1 -0
- package/dist/core/store/grow.d.ts +39 -0
- package/dist/core/store/grow.d.ts.map +1 -0
- package/dist/core/store/header.d.ts +64 -0
- package/dist/core/store/header.d.ts.map +1 -0
- package/dist/core/store/index.d.ts +16 -0
- package/dist/core/store/index.d.ts.map +1 -0
- package/dist/core/store/region_table.d.ts +74 -0
- package/dist/core/store/region_table.d.ts.map +1 -0
- package/dist/core/store/snapshot.d.ts +43 -0
- package/dist/core/store/snapshot.d.ts.map +1 -0
- package/dist/core/store/state_hash.d.ts +38 -0
- package/dist/core/store/state_hash.d.ts.map +1 -0
- package/dist/core/store/store_regions.d.ts +38 -0
- package/dist/core/store/store_regions.d.ts.map +1 -0
- package/dist/extensions/editor/editor.d.ts +149 -0
- package/dist/extensions/editor/editor.d.ts.map +1 -0
- package/dist/extensions/editor/field_handle.d.ts +35 -0
- package/dist/extensions/editor/field_handle.d.ts.map +1 -0
- package/dist/extensions/editor/index.cjs +1 -0
- package/dist/extensions/editor/index.d.ts +21 -0
- package/dist/extensions/editor/index.d.ts.map +1 -0
- package/dist/extensions/editor/index.js +209 -0
- package/dist/extensions/reactive/ecs_sync.d.ts +210 -0
- package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -0
- package/dist/extensions/reactive/index.cjs +1 -0
- package/dist/extensions/reactive/index.d.ts +23 -0
- package/dist/extensions/reactive/index.d.ts.map +1 -0
- package/dist/extensions/reactive/index.js +225 -0
- package/dist/extensions/solid/index.cjs +1 -0
- package/dist/extensions/solid/index.d.ts +6 -0
- package/dist/extensions/solid/index.d.ts.map +1 -0
- package/dist/extensions/solid/index.js +32 -0
- package/dist/extensions/solid/kernel_solid.d.ts +42 -0
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8565 -1310
- package/dist/interop-CT-REx0W.cjs +1 -0
- package/dist/interop-CcY6ASQc.js +18 -0
- package/dist/kernel-DgyrLFjW.js +227 -0
- package/dist/kernel-yWV3XnAb.cjs +1 -0
- package/dist/log/console_sink.d.ts +4 -0
- package/dist/log/console_sink.d.ts.map +1 -0
- package/dist/log/index.d.ts +3 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/logger.d.ts +27 -0
- package/dist/log/logger.d.ts.map +1 -0
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.d.ts +18 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +44 -0
- package/dist/shared-BXSZnxx4.cjs +1 -0
- package/dist/shared-C678TAPY.js +99 -0
- package/dist/shared.cjs +1 -0
- package/dist/shared.d.ts +22 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +7 -0
- package/dist/topological_sort-DlRpSrxu.js +391 -0
- package/dist/topological_sort-WAT-VHb-.cjs +1 -0
- package/dist/type_primitives/assertions.d.ts +12 -8
- package/dist/type_primitives/assertions.d.ts.map +1 -1
- package/dist/type_primitives/binary_heap/binary_heap.d.ts +6 -2
- package/dist/type_primitives/binary_heap/binary_heap.d.ts.map +1 -1
- package/dist/type_primitives/bitset/bitset.d.ts +16 -4
- package/dist/type_primitives/bitset/bitset.d.ts.map +1 -1
- package/dist/type_primitives/brand.d.ts +6 -1
- package/dist/type_primitives/brand.d.ts.map +1 -1
- package/dist/type_primitives/error.d.ts +4 -0
- package/dist/type_primitives/error.d.ts.map +1 -1
- package/dist/type_primitives/index.d.ts +3 -0
- package/dist/type_primitives/index.d.ts.map +1 -1
- package/dist/type_primitives/sparse_map/sparse_map.d.ts +7 -3
- package/dist/type_primitives/sparse_map/sparse_map.d.ts.map +1 -1
- package/dist/type_primitives/sparse_set/sparse_set.d.ts +4 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.ts.map +1 -1
- package/dist/type_primitives/topological_sort/topological_sort.d.ts +7 -3
- package/dist/type_primitives/topological_sort/topological_sort.d.ts.map +1 -1
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +53 -16
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts.map +1 -1
- package/dist/utils/arrays.d.ts +1 -1
- package/dist/utils/arrays.d.ts.map +1 -1
- package/dist/utils/error.d.ts +2 -20
- package/dist/utils/error.d.ts.map +1 -1
- package/package.json +36 -9
- package/dist/archetype.d.ts +0 -108
- package/dist/archetype.d.ts.map +0 -1
- package/dist/component.d.ts +0 -45
- package/dist/component.d.ts.map +0 -1
- package/dist/ecs.d.ts +0 -104
- package/dist/ecs.d.ts.map +0 -1
- package/dist/entity.d.ts +0 -11
- package/dist/entity.d.ts.map +0 -1
- package/dist/event.d.ts +0 -30
- package/dist/event.d.ts.map +0 -1
- package/dist/query.d.ts +0 -94
- package/dist/query.d.ts.map +0 -1
- package/dist/ref.d.ts +0 -23
- package/dist/ref.d.ts.map +0 -1
- package/dist/resource.d.ts +0 -23
- package/dist/resource.d.ts.map +0 -1
- package/dist/schedule.d.ts +0 -45
- package/dist/schedule.d.ts.map +0 -1
- package/dist/store.d.ts +0 -118
- package/dist/store.d.ts.map +0 -1
- package/dist/system.d.ts +0 -16
- package/dist/system.d.ts.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { InPlaceBufferAllocator } from '../store';
|
|
2
|
+
/** Default byte ceiling of the growable backing — mirrors
|
|
3
|
+
* `growableSabAllocator`'s default (see its doc comment for the measured
|
|
4
|
+
* footprint analysis that makes 256 MiB structurally unreachable). */
|
|
5
|
+
export declare const DEFAULT_ECS_CAP_BYTES: number;
|
|
6
|
+
/** Headroom multiplier applied to a budget's live column bytes: capacity
|
|
7
|
+
* doubling plus abandoned in-place holes bound worst-case footprint at ~3×
|
|
8
|
+
* live data (footprint analysis in `growableSabAllocator`'s doc). */
|
|
9
|
+
export declare const BUDGET_GROWTH_HEADROOM = 3;
|
|
10
|
+
/** Default average fully-populated row stride assumed by the budget arm.
|
|
11
|
+
* The instrumented 2-party workload measured ~49 B/entity; 64 rounds up. */
|
|
12
|
+
export declare const BUDGET_DEFAULT_BYTES_PER_ENTITY = 64;
|
|
13
|
+
/** Default archetype spread assumed by the budget arm when the consumer
|
|
14
|
+
* doesn't declare one. Drives only the derived per-archetype column
|
|
15
|
+
* capacity, not correctness — an under-declared spread just means earlier
|
|
16
|
+
* (amortised) column doubling. */
|
|
17
|
+
export declare const BUDGET_DEFAULT_ARCHETYPES = 8;
|
|
18
|
+
/** Sizing intent: "I expect a world about this big." The engine derives
|
|
19
|
+
* column capacity, entity-index reservation, and the byte cap from it, and
|
|
20
|
+
* cap errors are phrased against this budget. */
|
|
21
|
+
export interface EntityBudget {
|
|
22
|
+
/** Expected peak live entities — the one number most callers know.
|
|
23
|
+
* Bounded by the EntityID 20-bit index space (1<<20). */
|
|
24
|
+
readonly entities: number;
|
|
25
|
+
/** Expected distinct archetypes the entities spread across.
|
|
26
|
+
* Default `BUDGET_DEFAULT_ARCHETYPES`. */
|
|
27
|
+
readonly archetypes?: number;
|
|
28
|
+
/** Average fully-populated row stride in bytes.
|
|
29
|
+
* Default `BUDGET_DEFAULT_BYTES_PER_ENTITY`. */
|
|
30
|
+
readonly bytesPerEntity?: number;
|
|
31
|
+
}
|
|
32
|
+
/** WASM-backed memory, first-class (#682). Either bring your own shared
|
|
33
|
+
* `WebAssembly.Memory` (the server match context does — its sim factory
|
|
34
|
+
* owns the memory), or declare page bounds and let the engine construct
|
|
35
|
+
* it — replacing the hand-wired incantation that previously lived only in
|
|
36
|
+
* `workbench/ecs/scripts/run-memory.ts`. */
|
|
37
|
+
export type WasmMemoryArm = {
|
|
38
|
+
readonly memory: WebAssembly.Memory;
|
|
39
|
+
readonly initialPages?: never;
|
|
40
|
+
readonly maximumPages?: never;
|
|
41
|
+
} | {
|
|
42
|
+
readonly maximumPages: number;
|
|
43
|
+
readonly initialPages?: number;
|
|
44
|
+
readonly memory?: never;
|
|
45
|
+
};
|
|
46
|
+
/** Pure-TS **heap** backing (#643 / ADR-0018 §1B): a plain resizable
|
|
47
|
+
* `ArrayBuffer` instead of a `SharedArrayBuffer`. Needs no cross-origin
|
|
48
|
+
* isolation (COOP/COEP) and is the intended default for embedders that can't
|
|
49
|
+
* set those headers (the oecs profile). Trade-off: no worker offload and no
|
|
50
|
+
* WASM compute backend — both require a transferable `SharedArrayBuffer`. An
|
|
51
|
+
* empty `{}` takes the default 256 MiB growable cap. */
|
|
52
|
+
export interface HeapMemoryArm {
|
|
53
|
+
/** Byte ceiling of the growable heap backing. Default
|
|
54
|
+
* `DEFAULT_ECS_CAP_BYTES` (256 MiB), same hard-ceiling semantics as the
|
|
55
|
+
* SAB backing (#380). */
|
|
56
|
+
readonly maxBytes?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Opt-in **shared-memory** backing (`@oasys/oecs/shared`): a growable
|
|
59
|
+
* `SharedArrayBuffer` instead of a plain `ArrayBuffer`. Required for worker
|
|
60
|
+
* offload and a WASM compute backend, but needs cross-origin isolation
|
|
61
|
+
* (COOP/COEP) in browsers. Empty `{}` takes the default 256 MiB growable cap. */
|
|
62
|
+
export interface SharedMemoryArm {
|
|
63
|
+
/** Byte ceiling of the growable shared backing. Default
|
|
64
|
+
* `DEFAULT_ECS_CAP_BYTES` (256 MiB), hard-ceiling semantics (#380). */
|
|
65
|
+
readonly maxBytes?: number;
|
|
66
|
+
}
|
|
67
|
+
/** Pinnable on every arm: exact initial rows per archetype column. The
|
|
68
|
+
* budget arm derives one when unpinned; every other arm defaults to
|
|
69
|
+
* `DEFAULT_COLUMN_CAPACITY`. */
|
|
70
|
+
interface ColumnCapacityPin {
|
|
71
|
+
readonly columnCapacity?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The single sizing option on `ECSOptions.memory`. Key-discriminated —
|
|
75
|
+
* exactly one of `budget` | `maxBytes` | `wasm` | `allocator`, or none for
|
|
76
|
+
* default sizing. The `never` fields make a two-arm literal a type error;
|
|
77
|
+
* `resolveECSMemory` backstops untyped JS callers at runtime.
|
|
78
|
+
*/
|
|
79
|
+
export type ECSMemoryOptions = ({
|
|
80
|
+
readonly budget: EntityBudget;
|
|
81
|
+
readonly maxBytes?: never;
|
|
82
|
+
readonly wasm?: never;
|
|
83
|
+
readonly allocator?: never;
|
|
84
|
+
readonly heap?: never;
|
|
85
|
+
readonly shared?: never;
|
|
86
|
+
} & ColumnCapacityPin) | ({
|
|
87
|
+
readonly maxBytes: number;
|
|
88
|
+
readonly budget?: never;
|
|
89
|
+
readonly wasm?: never;
|
|
90
|
+
readonly allocator?: never;
|
|
91
|
+
readonly heap?: never;
|
|
92
|
+
readonly shared?: never;
|
|
93
|
+
} & ColumnCapacityPin) | ({
|
|
94
|
+
readonly wasm: WasmMemoryArm;
|
|
95
|
+
readonly budget?: never;
|
|
96
|
+
readonly maxBytes?: never;
|
|
97
|
+
readonly allocator?: never;
|
|
98
|
+
readonly heap?: never;
|
|
99
|
+
readonly shared?: never;
|
|
100
|
+
} & ColumnCapacityPin) | ({
|
|
101
|
+
readonly heap: HeapMemoryArm;
|
|
102
|
+
readonly budget?: never;
|
|
103
|
+
readonly maxBytes?: never;
|
|
104
|
+
readonly wasm?: never;
|
|
105
|
+
readonly allocator?: never;
|
|
106
|
+
readonly shared?: never;
|
|
107
|
+
} & ColumnCapacityPin) | ({
|
|
108
|
+
readonly shared: SharedMemoryArm;
|
|
109
|
+
readonly budget?: never;
|
|
110
|
+
readonly maxBytes?: never;
|
|
111
|
+
readonly wasm?: never;
|
|
112
|
+
readonly allocator?: never;
|
|
113
|
+
readonly heap?: never;
|
|
114
|
+
} & ColumnCapacityPin) | ({
|
|
115
|
+
/** Expert escape hatch. Typed `InPlaceBufferAllocator` so only
|
|
116
|
+
* allocators that statically declare `isInPlace: true` compile —
|
|
117
|
+
* the ADR-0008 boundary. `DEFAULT_SAB_ALLOCATOR` is rejected by the
|
|
118
|
+
* type system; non-in-place allocators stay snapshot/test-sizing
|
|
119
|
+
* utilities. */
|
|
120
|
+
readonly allocator: InPlaceBufferAllocator;
|
|
121
|
+
/** The allocator owns its real ceiling; this hint only labels
|
|
122
|
+
* diagnostics (cap errors, `memoryPlan.derivation`). */
|
|
123
|
+
readonly capBytesHint?: number;
|
|
124
|
+
readonly budget?: never;
|
|
125
|
+
readonly maxBytes?: never;
|
|
126
|
+
readonly wasm?: never;
|
|
127
|
+
readonly heap?: never;
|
|
128
|
+
readonly shared?: never;
|
|
129
|
+
} & ColumnCapacityPin) | ({
|
|
130
|
+
/** No sizing arm: default growable backing (256 MiB cap), with the
|
|
131
|
+
* column capacity optionally pinned — the minimal migration from the
|
|
132
|
+
* removed `initialCapacity` knob. */
|
|
133
|
+
readonly budget?: never;
|
|
134
|
+
readonly maxBytes?: never;
|
|
135
|
+
readonly wasm?: never;
|
|
136
|
+
readonly allocator?: never;
|
|
137
|
+
readonly heap?: never;
|
|
138
|
+
readonly shared?: never;
|
|
139
|
+
} & ColumnCapacityPin);
|
|
140
|
+
/** What the caller's intent resolved to. Exposed as `ECS.memoryPlan` for
|
|
141
|
+
* diagnostics; `intentLabel`/`budgetEntities`/`capBytes` also travel
|
|
142
|
+
* into `Store` so cap errors speak the caller's language. */
|
|
143
|
+
export interface ResolvedECSMemory {
|
|
144
|
+
readonly source: "default" | "budget" | "max_bytes" | "wasm" | "allocator" | "heap" | "shared";
|
|
145
|
+
readonly allocator: InPlaceBufferAllocator;
|
|
146
|
+
readonly columnCapacity: number;
|
|
147
|
+
readonly entityIndexCapacity: number;
|
|
148
|
+
/** Byte ceiling of the backing, `null` when unknowable from JS (a
|
|
149
|
+
* bring-your-own `WebAssembly.Memory` hides its `maximum`; a custom
|
|
150
|
+
* allocator owns its own cap unless hinted). */
|
|
151
|
+
readonly capBytes: number | null;
|
|
152
|
+
/** Human phrasing of the declared intent — reused verbatim in cap
|
|
153
|
+
* errors so the failure names what the caller asked for. */
|
|
154
|
+
readonly intentLabel: string;
|
|
155
|
+
/** The declared entity budget when the budget arm was used — drives the
|
|
156
|
+
* "N× the declared budget" cap-error diagnostic. */
|
|
157
|
+
readonly budgetEntities: number | null;
|
|
158
|
+
/** How each derived number was arrived at, one line per decision. */
|
|
159
|
+
readonly derivation: readonly string[];
|
|
160
|
+
/** The backing `WebAssembly.Memory` when the wasm arm was used (both
|
|
161
|
+
* bring-your-own and engine-constructed) — the consumer hands this to
|
|
162
|
+
* its WASM `ComputeBackend` so the sim and the columns share bytes. */
|
|
163
|
+
readonly wasmMemory: WebAssembly.Memory | null;
|
|
164
|
+
}
|
|
165
|
+
/** Subset of the plan `Store` needs to phrase cap/overflow errors in the
|
|
166
|
+
* caller's terms. */
|
|
167
|
+
export interface ECSMemoryCapContext {
|
|
168
|
+
readonly capBytes: number | null;
|
|
169
|
+
readonly intentLabel: string;
|
|
170
|
+
readonly budgetEntities: number | null;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Turn a consumer's sizing intent into a concrete memory plan. Pure apart
|
|
174
|
+
* from allocator/Memory construction; throws `INVALID_MEMORY_OPTIONS` on a
|
|
175
|
+
* malformed option set — at construction, not first-grow.
|
|
176
|
+
*/
|
|
177
|
+
export declare function resolveECSMemory(opts?: ECSMemoryOptions): ResolvedECSMemory;
|
|
178
|
+
export {};
|
|
179
|
+
//# sourceMappingURL=ecs_memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecs_memory.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/ecs_memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAON,KAAK,sBAAsB,EAC3B,MAAM,UAAU,CAAC;AAQlB;;sEAEsE;AACtE,eAAO,MAAM,qBAAqB,QAAY,CAAC;AAE/C;;qEAEqE;AACrE,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;4EAC4E;AAC5E,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD;;;kCAGkC;AAClC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAO3C;;iDAEiD;AACjD,MAAM,WAAW,YAAY;IAC5B;6DACyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;8CAC0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;oDACgD;IAChD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;4CAI4C;AAC5C,MAAM,MAAM,aAAa,GACtB;IACA,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;IACpC,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC;CAC7B,GACD;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,C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M,GAAG,IAAI,CAAC;CACvC;AAkBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CA4R3E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Brand } from '../../type_primitives';
|
|
2
|
+
export type EntityID = Brand<number, "entity_id">;
|
|
3
|
+
/**
|
|
4
|
+
* Compile-time readonly view of a `Uint32Array` whose elements are packed
|
|
5
|
+
* `EntityID`s — `Archetype.entityIds` returns this, so `ids[i]` is already
|
|
6
|
+
* branded and consumers don't re-brand by hand. Blocks index writes at the
|
|
7
|
+
* type layer.
|
|
8
|
+
*
|
|
9
|
+
* **Advisory, not a runtime barrier** — same caveat as `ReadonlyColumn`: the
|
|
10
|
+
* underlying value is the live mutable buffer, and indexing past
|
|
11
|
+
* `totalCount - 1` reads stale slots (the brand can't catch that).
|
|
12
|
+
*/
|
|
13
|
+
export interface ReadonlyEntityIdArray {
|
|
14
|
+
readonly [index: number]: EntityID;
|
|
15
|
+
readonly length: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const INDEX_BITS = 20;
|
|
18
|
+
export declare const INDEX_MASK: number;
|
|
19
|
+
export declare const MAX_INDEX: number;
|
|
20
|
+
export declare const GENERATION_BITS: number;
|
|
21
|
+
export declare const MAX_GENERATION: number;
|
|
22
|
+
export declare const RETIRED_GENERATION: number;
|
|
23
|
+
export declare const MAX_LIVE_GENERATION: number;
|
|
24
|
+
export declare const MAX_ENTITY_ID: number;
|
|
25
|
+
export declare const createEntityId: (index: number, generation: number) => EntityID;
|
|
26
|
+
export declare const getEntityIndex: (id: EntityID) => number;
|
|
27
|
+
export declare const getEntityGeneration: (id: EntityID) => number;
|
|
28
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/entity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BK;AAEL,OAAO,EAAE,KAAK,EAAc,MAAM,uBAAuB,CAAC;AAI1D,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,UAAU,QAAwB,CAAC;AAChD,eAAO,MAAM,SAAS,QAAa,CAAC;AACpC,eAAO,MAAM,eAAe,QAAiC,CAAC;AAC9D,eAAO,MAAM,cAAc,QAA6B,CAAC;AAQzD,eAAO,MAAM,kBAAkB,QAAiB,CAAC;AAGjD,eAAO,MAAM,mBAAmB,QAAqB,CAAC;AAMtD,eAAO,MAAM,aAAa,QAA6C,CAAC;AAExE,eAAO,MAAM,cAAc,UAAW,MAAM,cAAc,MAAM,KAAG,QAWlE,CAAC;AAEF,eAAO,MAAM,cAAc,OAAQ,QAAQ,KAAG,MAAyB,CAAC;AAExE,eAAO,MAAM,mBAAmB,OAAQ,QAAQ,KAAG,MAAsC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Brand } from '../../type_primitives';
|
|
2
|
+
export type EventID = Brand<number, "event_id">;
|
|
3
|
+
export declare const asEventId: (value: number) => EventID;
|
|
4
|
+
/** Event schema: field name → value type. Every value is a number at
|
|
5
|
+
* runtime; the declared type may be a branded number (e.g. `EntityID`)
|
|
6
|
+
* so the brand survives the emit → read round trip at the type layer.
|
|
7
|
+
* Declare schemas as type literals (`eventKey<{ a: EntityID }>`), not
|
|
8
|
+
* interfaces — assignability to the `EventSchema` constraint relies on
|
|
9
|
+
* the implicit index signature literals get and interfaces don't. */
|
|
10
|
+
export type EventSchema = Readonly<Record<string, number>>;
|
|
11
|
+
/** Schema of a signal — a zero-field event. */
|
|
12
|
+
export type EmptyEventSchema = Readonly<Record<never, number>>;
|
|
13
|
+
declare const __eventSchema: unique symbol;
|
|
14
|
+
export type EventDef<S extends EventSchema = EventSchema> = EventID & {
|
|
15
|
+
readonly [__eventSchema]: S;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Reader view over an event channel's SoA columns. Columns are read-only
|
|
19
|
+
* arrays typed per the event schema: consumers index them and read
|
|
20
|
+
* `.length`. A field declared as a branded number (e.g. `EntityID`) reads
|
|
21
|
+
* back branded — no cast at the consumer.
|
|
22
|
+
*
|
|
23
|
+
* The "cannot mutate the live channel through the reader" property is
|
|
24
|
+
* **advisory** — the columns are the same live `number[]` objects the channel
|
|
25
|
+
* mutates (see `EventChannel` below), so the `readonly` typing blocks writes
|
|
26
|
+
* at the type layer only; a §10c-policed cast can still write through.
|
|
27
|
+
*/
|
|
28
|
+
export type EventReader<S extends EventSchema> = {
|
|
29
|
+
length: number;
|
|
30
|
+
} & {
|
|
31
|
+
readonly [K in keyof S]: ReadonlyArray<S[K]>;
|
|
32
|
+
};
|
|
33
|
+
export declare class EventChannel {
|
|
34
|
+
readonly fieldNames: string[];
|
|
35
|
+
readonly columns: number[][];
|
|
36
|
+
readonly reader: EventReader<any>;
|
|
37
|
+
constructor(fieldNames: string[]);
|
|
38
|
+
emit(values: Record<string, number>): void;
|
|
39
|
+
/** Emit a signal (zero-field event). */
|
|
40
|
+
emitSignal(): void;
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
declare const __eventKeySchema: unique symbol;
|
|
44
|
+
export type EventKey<S extends EventSchema = EventSchema> = symbol & {
|
|
45
|
+
readonly [__eventKeySchema]: S;
|
|
46
|
+
};
|
|
47
|
+
declare const __signalKey: unique symbol;
|
|
48
|
+
export type SignalKey = EventKey<EmptyEventSchema> & {
|
|
49
|
+
readonly [__signalKey]: true;
|
|
50
|
+
};
|
|
51
|
+
export declare function eventKey<S extends EventSchema>(name: string): EventKey<S>;
|
|
52
|
+
export declare function signalKey(name: string): SignalKey;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BK;AAEL,OAAO,EACN,KAAK,EAIL,MAAM,uBAAuB,CAAC;AAG/B,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAChD,eAAO,MAAM,SAAS,UAAW,MAAM,YAKrC,CAAC;AAEH;;;;;qEAKqE;AACrE,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3D,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAG/D,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,OAAO,GAAG;IACrE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI;IAChD,MAAM,EAAE,MAAM,CAAC;CACf,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAErD,qBAAa,YAAY;IACxB,SAAgB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrC,SAAgB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IAEpC,SAAgB,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;gBAE7B,UAAU,EAAE,MAAM,EAAE;IAoBzB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAsBjD,wCAAwC;IACjC,UAAU,IAAI,IAAI;IAIlB,KAAK,IAAI,IAAI;CAOpB;AAMD,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,MAAM,CAAC;AAE9C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,MAAM,GAAG;IACpE,QAAQ,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;CAC/B,CAAC;AAQF,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,gBAAgB,CAAC,GAAG;IACpD,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAEzE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAEjD"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { EntityID } from './entity';
|
|
2
|
+
import { SystemDescriptor } from './system';
|
|
3
|
+
import { SCHEDULE } from './schedule';
|
|
4
|
+
/** A deferred structural command issued through `ctx.commands.*` (`query.ts`).
|
|
5
|
+
* `spawn`/`despawn`/`enable`/`disable` carry a `null` component; `add`/`remove`
|
|
6
|
+
* carry the affected component's id. */
|
|
7
|
+
export type StructuralOp = "spawn" | "despawn" | "add" | "remove" | "enable" | "disable";
|
|
8
|
+
/** An observer edge that fired at a flush (`add`/`remove`/`enable`/`disable`) or
|
|
9
|
+
* at the post-update onSet detection point (`set`). */
|
|
10
|
+
export type ObserverOp = "add" | "remove" | "set" | "enable" | "disable";
|
|
11
|
+
/**
|
|
12
|
+
* The push sink. All callers are `__DEV__`-gated, so the methods receive raw ids
|
|
13
|
+
* and descriptor references (no string-building on the hot path); the recorder
|
|
14
|
+
* decides what to retain. Implementations must be side-effect-free with respect
|
|
15
|
+
* to the ECS — they observe, never mutate.
|
|
16
|
+
*/
|
|
17
|
+
export interface FrameTraceSink {
|
|
18
|
+
/** Opens a frame. Fired first in `world.update`, before any phase runs. */
|
|
19
|
+
tickBegin(tick: number, dt: number): void;
|
|
20
|
+
/** Closes the frame opened by `tickBegin` (after onSet + `clearEvents`). */
|
|
21
|
+
tickEnd(tick: number): void;
|
|
22
|
+
/** A scheduled system is about to run, in the given phase. */
|
|
23
|
+
systemStart(system: SystemDescriptor, phase: SCHEDULE): void;
|
|
24
|
+
/** The system that last `systemStart`'d has returned. */
|
|
25
|
+
systemEnd(system: SystemDescriptor): void;
|
|
26
|
+
/** A deferred structural command was enqueued (applied at the next flush). */
|
|
27
|
+
commandQueued(op: StructuralOp, entity: EntityID, component: number | null): void;
|
|
28
|
+
/** The deferred command buffer is about to drain for this phase. */
|
|
29
|
+
flushBegin(phase: SCHEDULE): void;
|
|
30
|
+
/** The deferred command buffer (and any observer cascade) has settled. */
|
|
31
|
+
flushEnd(phase: SCHEDULE): void;
|
|
32
|
+
/**
|
|
33
|
+
* A schedule phase has fully settled — every system in `phase` ran and the
|
|
34
|
+
* deferred command buffer (plus any observer cascade) flushed — so the live
|
|
35
|
+
* world sits at a consistent, fingerprint-able point WITHIN the frame. Fired
|
|
36
|
+
* once per phase that runs (each startup phase, each fixed step, and each
|
|
37
|
+
* update phase), immediately after `flushEnd(phase)`.
|
|
38
|
+
*
|
|
39
|
+
* This is the blessed seam for a consumer to read `stateHash()` between the
|
|
40
|
+
* phases of one `update()` and bisect a divergence to the exact phase that
|
|
41
|
+
* introduced it (#797 / ADR-0032). `flushEnd` marks the same instant, but it
|
|
42
|
+
* is an observation of the flush *mechanism*, not a "safe to read consistent
|
|
43
|
+
* state" contract — so per-phase fingerprinting binds to this method, not to a
|
|
44
|
+
* flush-internal name. Like every sink method the call is read-only w.r.t. the
|
|
45
|
+
* ECS: reading `stateHash()` here cannot perturb the per-tick hash or ordering.
|
|
46
|
+
*
|
|
47
|
+
* Caveat: the POST_UPDATE boundary fires BEFORE the tick-tail onSet-observer
|
|
48
|
+
* dispatch + `clearEvents`, so for a world with onSet observers the final
|
|
49
|
+
* per-tick `stateHash` (after `update()` returns) may differ from the
|
|
50
|
+
* POST_UPDATE phase hash. A world with no onSet observers reconciles exactly.
|
|
51
|
+
*/
|
|
52
|
+
phaseBoundary(phase: SCHEDULE): void;
|
|
53
|
+
/** An observer callback fired for one entity (`entity === -1` for an
|
|
54
|
+
* archetype-granular onSet, which has no per-entity id). */
|
|
55
|
+
observerFired(op: ObserverOp, component: number, entity: number, observer: SystemDescriptor): void;
|
|
56
|
+
/** A system emitted an event on `key` (the channel's symbol description). */
|
|
57
|
+
eventEmitted(key: string): void;
|
|
58
|
+
/** A system read an event channel; `count` is how many events it saw. */
|
|
59
|
+
eventRead(key: string, count: number): void;
|
|
60
|
+
}
|
|
61
|
+
/** One captured event, as plain JSON-serialisable data (string names + numeric
|
|
62
|
+
* ids), so a `FrameTrace[]` streams straight to a browser renderer. */
|
|
63
|
+
export type FrameTraceEvent = {
|
|
64
|
+
readonly kind: "system_start";
|
|
65
|
+
readonly system: string;
|
|
66
|
+
readonly phase: SCHEDULE;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "system_end";
|
|
69
|
+
readonly system: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: "command_queued";
|
|
72
|
+
readonly op: StructuralOp;
|
|
73
|
+
readonly entity: number;
|
|
74
|
+
readonly component: number | null;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "flush_begin";
|
|
77
|
+
readonly phase: SCHEDULE;
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "flush_end";
|
|
80
|
+
readonly phase: SCHEDULE;
|
|
81
|
+
} | {
|
|
82
|
+
readonly kind: "observer_fired";
|
|
83
|
+
readonly op: ObserverOp;
|
|
84
|
+
readonly component: number;
|
|
85
|
+
readonly entity: number;
|
|
86
|
+
readonly observer: string;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: "event_emitted";
|
|
89
|
+
readonly key: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: "event_read";
|
|
92
|
+
readonly key: string;
|
|
93
|
+
readonly count: number;
|
|
94
|
+
};
|
|
95
|
+
/** One frame's captured internals, in causal order. */
|
|
96
|
+
export interface FrameTrace {
|
|
97
|
+
readonly tick: number;
|
|
98
|
+
readonly dt: number;
|
|
99
|
+
readonly events: FrameTraceEvent[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The in-tree `FrameTraceSink`. Mirrors `command_log.ts`'s `openTick` /
|
|
103
|
+
* `RecordedTick` shape: `tickBegin` opens a fresh `FrameTrace`, every other
|
|
104
|
+
* method appends to it, `tickEnd` closes it. Events arriving with no open
|
|
105
|
+
* frame (e.g. a stray pre-`update` flush) are ignored rather than throwing —
|
|
106
|
+
* the recorder is a passive observer.
|
|
107
|
+
*/
|
|
108
|
+
export declare class FrameTraceRecorder implements FrameTraceSink {
|
|
109
|
+
private readonly _frames;
|
|
110
|
+
private _current;
|
|
111
|
+
tickBegin(tick: number, dt: number): void;
|
|
112
|
+
tickEnd(_tick: number): void;
|
|
113
|
+
systemStart(system: SystemDescriptor, phase: SCHEDULE): void;
|
|
114
|
+
systemEnd(system: SystemDescriptor): void;
|
|
115
|
+
commandQueued(op: StructuralOp, entity: EntityID, component: number | null): void;
|
|
116
|
+
flushBegin(phase: SCHEDULE): void;
|
|
117
|
+
flushEnd(phase: SCHEDULE): void;
|
|
118
|
+
/** No-op (#797 / ADR-0032). The recorder already marks this instant with
|
|
119
|
+
* `flushEnd`, and a per-phase fingerprint is a consumer concern — the recorder
|
|
120
|
+
* holds no world reference to hash. The seam exists so a consumer's OWN sink can
|
|
121
|
+
* run code (e.g. `stateHash()`) at the safe post-flush point; the in-tree
|
|
122
|
+
* event-stream recorder has nothing to add, so it stays a stream of causal
|
|
123
|
+
* events, not fingerprints. */
|
|
124
|
+
phaseBoundary(_phase: SCHEDULE): void;
|
|
125
|
+
observerFired(op: ObserverOp, component: number, entity: number, observer: SystemDescriptor): void;
|
|
126
|
+
eventEmitted(key: string): void;
|
|
127
|
+
eventRead(key: string, count: number): void;
|
|
128
|
+
/** The captured frames, in `update()` order. */
|
|
129
|
+
frames(): readonly FrameTrace[];
|
|
130
|
+
/** Drop all captured frames (reuse the recorder for a fresh run). */
|
|
131
|
+
reset(): void;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=frame_trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame_trace.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/frame_trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;wCAEwC;AACxC,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzF;uDACuD;AACvD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,2EAA2E;IAC3E,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,4EAA4E;IAC5E,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,8DAA8D;IAC9D,WAAW,CAAC,MA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