@oasys/oecs 0.4.0 → 0.5.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/CHANGELOG.md +553 -0
- package/README.md +42 -31
- package/dist/core/ecs/access_check.d.cts +77 -0
- package/dist/core/ecs/access_check.d.ts +8 -8
- package/dist/core/ecs/access_check.d.ts.map +1 -1
- package/dist/core/ecs/archetype.d.cts +486 -0
- package/dist/core/ecs/archetype.d.ts +23 -11
- package/dist/core/ecs/archetype.d.ts.map +1 -1
- package/dist/core/ecs/archetype_graph.d.cts +96 -0
- package/dist/core/ecs/archetype_graph.d.ts +96 -0
- package/dist/core/ecs/archetype_graph.d.ts.map +1 -0
- package/dist/core/ecs/builtin_relations.d.cts +43 -0
- package/dist/core/ecs/builtin_relations.d.ts +8 -8
- package/dist/core/ecs/builtin_relations.d.ts.map +1 -1
- package/dist/core/ecs/command_log.d.cts +116 -0
- package/dist/core/ecs/command_log.d.ts +13 -10
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +176 -0
- package/dist/core/ecs/component.d.ts +75 -5
- package/dist/core/ecs/component.d.ts.map +1 -1
- package/dist/core/ecs/compute_backend.d.cts +37 -0
- package/dist/core/ecs/compute_backend.d.ts +2 -2
- package/dist/core/ecs/debug_names.d.cts +7 -0
- package/dist/core/ecs/debug_names.d.ts +7 -0
- package/dist/core/ecs/debug_names.d.ts.map +1 -0
- package/dist/core/ecs/deferred_commands.d.cts +55 -0
- package/dist/core/ecs/deferred_commands.d.ts +55 -0
- package/dist/core/ecs/deferred_commands.d.ts.map +1 -0
- package/dist/core/ecs/dispatch_trace.d.cts +93 -0
- package/dist/core/ecs/dispatch_trace.d.ts +3 -3
- package/dist/core/ecs/ecs.d.cts +562 -0
- package/dist/core/ecs/ecs.d.ts +314 -285
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/ecs_memory.d.cts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts +1 -1
- package/dist/core/ecs/entity.d.cts +34 -0
- package/dist/core/ecs/entity.d.ts +7 -1
- package/dist/core/ecs/entity.d.ts.map +1 -1
- package/dist/core/ecs/entity_allocator.d.cts +59 -0
- package/dist/core/ecs/entity_allocator.d.ts +59 -0
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -0
- package/dist/core/ecs/event.d.cts +79 -0
- package/dist/core/ecs/event.d.ts +36 -11
- package/dist/core/ecs/event.d.ts.map +1 -1
- package/dist/core/ecs/event_registry.d.cts +22 -0
- package/dist/core/ecs/event_registry.d.ts +22 -0
- package/dist/core/ecs/event_registry.d.ts.map +1 -0
- package/dist/core/ecs/facades.d.cts +158 -0
- package/dist/core/ecs/facades.d.ts +158 -0
- package/dist/core/ecs/facades.d.ts.map +1 -0
- package/dist/core/ecs/frame_stepper.d.cts +58 -0
- package/dist/core/ecs/frame_stepper.d.ts +58 -0
- package/dist/core/ecs/frame_stepper.d.ts.map +1 -0
- package/dist/core/ecs/frame_trace.d.cts +133 -0
- package/dist/core/ecs/frame_trace.d.ts +5 -5
- package/dist/core/ecs/frame_trace.d.ts.map +1 -1
- package/dist/core/ecs/host_commands.d.cts +274 -0
- package/dist/core/ecs/host_commands.d.ts +53 -31
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +46 -0
- package/dist/core/ecs/index.d.ts +45 -40
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +173 -0
- package/dist/core/ecs/observer.d.ts +43 -12
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +718 -0
- package/dist/core/ecs/query.d.ts +251 -90
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/ref.d.cts +31 -0
- package/dist/core/ecs/ref.d.ts +3 -3
- package/dist/core/ecs/relation.d.cts +243 -0
- package/dist/core/ecs/relation.d.ts +26 -14
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/relation_service.d.cts +235 -0
- package/dist/core/ecs/relation_service.d.ts +235 -0
- package/dist/core/ecs/relation_service.d.ts.map +1 -0
- package/dist/core/ecs/resource.d.cts +53 -0
- package/dist/core/ecs/resource.d.ts +25 -5
- package/dist/core/ecs/resource.d.ts.map +1 -1
- package/dist/core/ecs/resource_registry.d.cts +20 -0
- package/dist/core/ecs/resource_registry.d.ts +20 -0
- package/dist/core/ecs/resource_registry.d.ts.map +1 -0
- package/dist/core/ecs/resume.d.cts +85 -0
- package/dist/core/ecs/resume.d.ts +6 -6
- package/dist/core/ecs/resume.d.ts.map +1 -1
- package/dist/core/ecs/run_condition.d.cts +81 -0
- package/dist/core/ecs/run_condition.d.ts +15 -9
- package/dist/core/ecs/run_condition.d.ts.map +1 -1
- package/dist/core/ecs/schedule.d.cts +142 -0
- package/dist/core/ecs/schedule.d.ts +15 -6
- package/dist/core/ecs/schedule.d.ts.map +1 -1
- package/dist/core/ecs/snapshot_service.d.cts +94 -0
- package/dist/core/ecs/snapshot_service.d.ts +94 -0
- package/dist/core/ecs/snapshot_service.d.ts.map +1 -0
- package/dist/core/ecs/sparse_store.d.cts +110 -0
- package/dist/core/ecs/sparse_store.d.ts +5 -2
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +950 -0
- package/dist/core/ecs/store.d.ts +143 -342
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +23 -0
- package/dist/core/ecs/system.d.cts +250 -0
- package/dist/core/ecs/system.d.ts +138 -22
- package/dist/core/ecs/system.d.ts.map +1 -1
- package/dist/{utils/arrays.d.ts → core/ecs/utils/arrays.d.cts} +1 -0
- package/dist/core/ecs/utils/error.d.cts +61 -0
- package/dist/core/ecs/utils/error.d.ts +12 -2
- package/dist/core/ecs/utils/error.d.ts.map +1 -1
- package/dist/core/store/action_ring.d.cts +136 -0
- package/dist/core/store/allocator.d.cts +238 -0
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts +2 -2
- package/dist/core/store/column_store.d.cts +273 -0
- package/dist/core/store/column_store.d.ts +18 -10
- package/dist/core/store/column_store.d.ts.map +1 -1
- package/dist/core/store/command_dispatch.d.cts +52 -0
- package/dist/core/store/command_ring.d.cts +107 -0
- package/dist/core/store/descriptor.d.cts +80 -0
- package/dist/core/store/descriptor.d.ts +1 -1
- package/dist/core/store/descriptor.d.ts.map +1 -1
- package/dist/core/store/entity_index.d.cts +108 -0
- package/dist/core/store/event_ring.d.cts +95 -0
- package/dist/core/store/extend.d.cts +39 -0
- package/dist/core/store/extend.d.ts +3 -73
- package/dist/core/store/extend.d.ts.map +1 -1
- package/dist/core/store/grow.d.cts +34 -0
- package/dist/core/store/grow.d.ts +4 -9
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +64 -0
- package/dist/core/store/header.d.ts +1 -1
- package/dist/core/store/header.d.ts.map +1 -1
- package/dist/core/store/index.d.cts +17 -0
- package/dist/core/store/index.d.ts +16 -15
- package/dist/core/store/index.d.ts.map +1 -1
- package/dist/core/store/layout_ops.d.cts +152 -0
- package/dist/core/store/layout_ops.d.ts +152 -0
- package/dist/core/store/layout_ops.d.ts.map +1 -0
- package/dist/core/store/region_table.d.cts +74 -0
- package/dist/core/store/region_table.d.ts +1 -1
- package/dist/core/store/region_table.d.ts.map +1 -1
- package/dist/core/store/snapshot.d.cts +43 -0
- package/dist/core/store/snapshot.d.ts +2 -2
- package/dist/core/store/state_hash.d.cts +38 -0
- package/dist/core/store/state_hash.d.ts +1 -1
- package/dist/core/store/store_regions.d.cts +38 -0
- package/dist/core/store/store_regions.d.ts +1 -1
- package/dist/core/store/vendored_abi/abi.d.ts +43 -0
- package/dist/core/store/{__generated__ → vendored_abi}/abi.d.ts.map +1 -1
- package/dist/dev_flag.d.cts +17 -0
- package/dist/dev_flag.d.ts +17 -0
- package/dist/dev_flag.d.ts.map +1 -0
- package/dist/extensions/editor/editor.d.cts +170 -0
- package/dist/extensions/editor/editor.d.ts +43 -22
- package/dist/extensions/editor/editor.d.ts.map +1 -1
- package/dist/extensions/editor/field_handle.d.cts +40 -0
- package/dist/extensions/editor/field_handle.d.ts +8 -3
- package/dist/extensions/editor/field_handle.d.ts.map +1 -1
- package/dist/extensions/editor/index.cjs +1 -1
- package/dist/extensions/editor/index.d.cts +21 -0
- package/dist/extensions/editor/index.d.ts +2 -2
- package/dist/extensions/editor/index.js +116 -88
- package/dist/extensions/reactive/ecs_sync.d.cts +214 -0
- package/dist/extensions/reactive/ecs_sync.d.ts +26 -22
- package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -1
- package/dist/extensions/reactive/index.cjs +1 -1
- package/dist/extensions/reactive/index.d.cts +23 -0
- package/dist/extensions/reactive/index.d.ts +1 -1
- package/dist/extensions/reactive/index.js +106 -116
- package/dist/extensions/solid/index.cjs +1 -1
- package/dist/extensions/solid/index.d.cts +6 -0
- package/dist/extensions/solid/index.d.ts +2 -2
- package/dist/extensions/solid/index.js +8 -4
- package/dist/extensions/solid/kernel_solid.d.cts +45 -0
- package/dist/extensions/solid/kernel_solid.d.ts +6 -3
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
- package/dist/host_commands-BF8QMi3c.cjs +1 -0
- package/dist/host_commands-i4cAeyL5.js +2318 -0
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +66 -0
- package/dist/index.d.ts +50 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4469 -5933
- package/dist/internal.cjs +2 -0
- package/dist/internal.d.cts +20 -0
- package/dist/internal.d.ts +20 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +141 -0
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.d.cts +18 -0
- package/dist/primitives.d.ts +6 -6
- package/dist/primitives.js +24 -23
- package/dist/reactive/array.d.ts +24 -0
- package/dist/reactive/array.d.ts.map +1 -0
- package/dist/reactive/index.cjs +1 -0
- package/dist/reactive/index.d.cts +11 -0
- package/dist/reactive/index.d.ts +11 -0
- package/dist/reactive/index.d.ts.map +1 -0
- package/dist/reactive/index.js +18 -0
- package/dist/reactive/interop.d.cts +19 -0
- package/dist/{core/reactive → reactive}/interop.d.ts +1 -1
- package/dist/reactive/interop.d.ts.map +1 -0
- package/dist/reactive/kernel.d.cts +73 -0
- package/dist/{core/reactive → reactive}/kernel.d.ts +5 -3
- package/dist/reactive/kernel.d.ts.map +1 -0
- package/dist/reactive/map.d.ts +16 -0
- package/dist/reactive/map.d.ts.map +1 -0
- package/dist/reactive/shallow.d.cts +11 -0
- package/dist/reactive/shallow.d.ts +11 -0
- package/dist/reactive/shallow.d.ts.map +1 -0
- package/dist/reactive/struct.d.cts +10 -0
- package/dist/{core/reactive → reactive}/struct.d.ts +1 -1
- package/dist/reactive/struct.d.ts.map +1 -0
- package/dist/shallow-DQ8aG51_.cjs +1 -0
- package/dist/shallow-DfnAm9vG.js +150 -0
- package/dist/shared-BU1Cd40h.js +103 -0
- package/dist/shared-BymrGTyR.cjs +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +22 -0
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +1 -1
- package/dist/topological_sort-BDvEyb9W.cjs +1 -0
- package/dist/topological_sort-DK6EjpWa.js +135 -0
- package/dist/type_primitives/assertions.d.cts +32 -0
- package/dist/type_primitives/assertions.d.ts +13 -1
- package/dist/type_primitives/assertions.d.ts.map +1 -1
- package/dist/type_primitives/binary_heap/binary_heap.d.cts +37 -0
- package/dist/type_primitives/bitset/bitset.d.cts +54 -0
- package/dist/type_primitives/brand.d.cts +23 -0
- package/dist/type_primitives/error.d.cts +16 -0
- package/dist/type_primitives/error.d.ts +4 -3
- package/dist/type_primitives/error.d.ts.map +1 -1
- package/dist/type_primitives/index.d.cts +13 -0
- package/dist/type_primitives/index.d.ts +9 -9
- package/dist/type_primitives/sparse_map/sparse_map.d.cts +30 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.cts +28 -0
- package/dist/type_primitives/topological_sort/topological_sort.d.cts +29 -0
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +127 -0
- package/dist/typed_arrays-BcXcnzB4.js +258 -0
- package/dist/typed_arrays-D3NmwtCG.cjs +1 -0
- package/dist/utils/error.d.cts +6 -0
- package/dist/version.d.cts +10 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +102 -19
- package/dist/array-CxbPyiHO.cjs +0 -1
- package/dist/array-uFR7Q8fU.js +0 -132
- package/dist/core/reactive/array.d.ts.map +0 -1
- package/dist/core/reactive/index.cjs +0 -1
- package/dist/core/reactive/index.d.ts +0 -10
- package/dist/core/reactive/index.d.ts.map +0 -1
- package/dist/core/reactive/index.js +0 -17
- package/dist/core/reactive/interop.d.ts.map +0 -1
- package/dist/core/reactive/kernel.d.ts.map +0 -1
- package/dist/core/reactive/map.d.ts.map +0 -1
- package/dist/core/reactive/struct.d.ts.map +0 -1
- package/dist/log/console_sink.d.ts +0 -4
- package/dist/log/console_sink.d.ts.map +0 -1
- package/dist/log/index.d.ts +0 -3
- package/dist/log/index.d.ts.map +0 -1
- package/dist/log/logger.d.ts +0 -27
- package/dist/log/logger.d.ts.map +0 -1
- package/dist/shared-BXSZnxx4.cjs +0 -1
- package/dist/shared-C678TAPY.js +0 -99
- package/dist/topological_sort-DlRpSrxu.js +0 -391
- package/dist/topological_sort-WAT-VHb-.cjs +0 -1
- package/dist/utils/arrays.d.ts.map +0 -1
- package/dist/utils/constants.d.ts.map +0 -1
- /package/dist/{utils/constants.d.ts → core/ecs/utils/constants.d.cts} +0 -0
- /package/dist/core/store/{__generated__/abi.d.ts → vendored_abi/abi.d.cts} +0 -0
- /package/dist/{core/reactive/array.d.ts → reactive/array.d.cts} +0 -0
- /package/dist/{core/reactive/map.d.ts → reactive/map.d.cts} +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { s as y, b as O, u as j } from "./kernel-DgyrLFjW.js";
|
|
2
|
+
function S(p = Object.is) {
|
|
3
|
+
const l = /* @__PURE__ */ new Map(), [e, f] = y(0);
|
|
4
|
+
let i = 0;
|
|
5
|
+
const a = (s, r) => s !== void 0 && r !== void 0 ? p(s, r) : s === r;
|
|
6
|
+
return {
|
|
7
|
+
get(s) {
|
|
8
|
+
const r = l.get(s);
|
|
9
|
+
if (r !== void 0) return r[0]();
|
|
10
|
+
e();
|
|
11
|
+
},
|
|
12
|
+
set(s, r) {
|
|
13
|
+
const o = l.get(s);
|
|
14
|
+
o !== void 0 ? o[1](r) : (l.set(s, y(r, a)), f(++i));
|
|
15
|
+
},
|
|
16
|
+
delete(s) {
|
|
17
|
+
const r = l.get(s);
|
|
18
|
+
return r === void 0 ? !1 : (l.delete(s), O(() => {
|
|
19
|
+
r[1](void 0), f(++i);
|
|
20
|
+
}), !0);
|
|
21
|
+
},
|
|
22
|
+
has(s) {
|
|
23
|
+
return e(), l.has(s);
|
|
24
|
+
},
|
|
25
|
+
size() {
|
|
26
|
+
return e(), l.size;
|
|
27
|
+
},
|
|
28
|
+
keys() {
|
|
29
|
+
return e(), [...l.keys()];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function M(p, l = {}) {
|
|
34
|
+
const e = {}, f = {}, i = Object.keys(p), a = new Set(i);
|
|
35
|
+
for (const r of i) {
|
|
36
|
+
const [o, m] = y(
|
|
37
|
+
p[r],
|
|
38
|
+
l[r]
|
|
39
|
+
);
|
|
40
|
+
e[r] = o, f[r] = m;
|
|
41
|
+
}
|
|
42
|
+
return [new Proxy({}, {
|
|
43
|
+
// A field read subscribes; a NON-field key must not throw. `JSON.stringify`
|
|
44
|
+
// (`toJSON`), `await proxy` (`then`), `String(proxy)` (`Symbol.toPrimitive`)
|
|
45
|
+
// and `for..of` (`Symbol.iterator`) all probe keys that aren't fields — fall
|
|
46
|
+
// through to the (empty) target so they see the ordinary undefined/inherited
|
|
47
|
+
// value instead of calling `undefined()`. `fieldSet` (not `k in reads`) so
|
|
48
|
+
// inherited `toString`/`constructor` aren't mistaken for fields.
|
|
49
|
+
get: (r, o) => a.has(o) ? e[o]() : Reflect.get(r, o),
|
|
50
|
+
has: (r, o) => a.has(o),
|
|
51
|
+
// Enumerable without subscribing: enumeration calls `ownKeys` +
|
|
52
|
+
// `getOwnPropertyDescriptor`, never `get`, so `Object.keys(proxy)` returns
|
|
53
|
+
// the field set and tracks nothing. The descriptor is an ACCESSOR whose `get`
|
|
54
|
+
// reads the live signal, so `{...proxy}` / `Object.values(proxy)` /
|
|
55
|
+
// `Object.getOwnPropertyDescriptor(proxy, f).value` see the current value
|
|
56
|
+
// (a value-less descriptor would normalize to `value: undefined`). Non-field
|
|
57
|
+
// keys report no own descriptor. The target is the empty (extensible) object,
|
|
58
|
+
// so these configurable own keys satisfy the Proxy invariants.
|
|
59
|
+
ownKeys: () => i,
|
|
60
|
+
getOwnPropertyDescriptor: (r, o) => a.has(o) ? { get: () => e[o](), enumerable: !0, configurable: !0 } : void 0,
|
|
61
|
+
// Writes go through `set.field(v)` — the proxy is a READ surface, and its
|
|
62
|
+
// public type says so (`Readonly<T>`, POLISH_AUDIT #8). The trap backs the
|
|
63
|
+
// type for JS callers / policed casts: without it, a field assignment threw
|
|
64
|
+
// an opaque "Cannot redefine property" (the accessor descriptor above has no
|
|
65
|
+
// setter) and a TYPO'D field silently stuck on the hidden target as a
|
|
66
|
+
// non-reactive value.
|
|
67
|
+
set: (r, o) => !1
|
|
68
|
+
}), f];
|
|
69
|
+
}
|
|
70
|
+
const v = Symbol("reactiveArray.absent");
|
|
71
|
+
function x(p = [], l = Object.is) {
|
|
72
|
+
const e = [], [f, i] = y(0);
|
|
73
|
+
let a = 0;
|
|
74
|
+
const s = (t, n) => t !== v && n !== v ? l(t, n) : t === n, r = (t) => y(t, s), o = (t) => j(e[t][0]);
|
|
75
|
+
for (const t of p) e.push(r(t));
|
|
76
|
+
function m(t) {
|
|
77
|
+
O(() => {
|
|
78
|
+
const n = e.length, h = t.length, g = h < n ? h : n;
|
|
79
|
+
for (let c = 0; c < g; c++) e[c][1](t[c]);
|
|
80
|
+
if (h > n) {
|
|
81
|
+
for (let c = n; c < h; c++) e.push(r(t[c]));
|
|
82
|
+
i(++a);
|
|
83
|
+
} else if (h < n) {
|
|
84
|
+
const c = e.splice(h);
|
|
85
|
+
for (let d = 0; d < c.length; d++) c[d][1](v);
|
|
86
|
+
i(++a);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
get(t) {
|
|
92
|
+
if (t >= 0 && t < e.length) {
|
|
93
|
+
const n = e[t][0]();
|
|
94
|
+
if (n !== v) return n;
|
|
95
|
+
}
|
|
96
|
+
f();
|
|
97
|
+
},
|
|
98
|
+
length() {
|
|
99
|
+
return f(), e.length;
|
|
100
|
+
},
|
|
101
|
+
snapshot() {
|
|
102
|
+
f();
|
|
103
|
+
const t = new Array(e.length);
|
|
104
|
+
for (let n = 0; n < e.length; n++) t[n] = e[n][0]();
|
|
105
|
+
return t;
|
|
106
|
+
},
|
|
107
|
+
set(t, n) {
|
|
108
|
+
t >= 0 && t < e.length && e[t][1](n);
|
|
109
|
+
},
|
|
110
|
+
push(t) {
|
|
111
|
+
e.push(r(t)), i(++a);
|
|
112
|
+
},
|
|
113
|
+
pop() {
|
|
114
|
+
const t = e.length;
|
|
115
|
+
if (t === 0) return;
|
|
116
|
+
const n = o(t - 1), [h] = e.splice(t - 1);
|
|
117
|
+
return O(() => {
|
|
118
|
+
h[1](v), i(++a);
|
|
119
|
+
}), n;
|
|
120
|
+
},
|
|
121
|
+
splice(t, n, ...h) {
|
|
122
|
+
const g = e.length, c = t < 0 ? Math.max(g + t, 0) : Math.min(t, g), d = n === void 0 ? g - c : Math.max(0, Math.min(n, g - c)), w = [];
|
|
123
|
+
for (let u = 0; u < d; u++) w.push(o(c + u));
|
|
124
|
+
const b = [];
|
|
125
|
+
for (let u = 0; u < c; u++) b.push(o(u));
|
|
126
|
+
for (let u = 0; u < h.length; u++) b.push(h[u]);
|
|
127
|
+
for (let u = c + d; u < g; u++) b.push(o(u));
|
|
128
|
+
return m(b), w;
|
|
129
|
+
},
|
|
130
|
+
reconcile(t) {
|
|
131
|
+
m(t);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function A(p, l) {
|
|
136
|
+
if (Object.is(p, l)) return !0;
|
|
137
|
+
const e = p, f = l, i = Object.keys(e);
|
|
138
|
+
if (i.length !== Object.keys(f).length) return !1;
|
|
139
|
+
for (let a = 0; a < i.length; a++) {
|
|
140
|
+
const s = i[a];
|
|
141
|
+
if (!Object.prototype.hasOwnProperty.call(f, s) || !Object.is(e[s], f[s])) return !1;
|
|
142
|
+
}
|
|
143
|
+
return !0;
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
M as a,
|
|
147
|
+
x as b,
|
|
148
|
+
S as r,
|
|
149
|
+
A as s
|
|
150
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
class u extends Error {
|
|
2
|
+
constructor(t, e, r, n) {
|
|
3
|
+
super(t, n), this.requestedBytes = e, this.capBytes = r, this.name = "StoreCapExceededError";
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class c extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(
|
|
9
|
+
"SharedArrayBuffer is not available in this runtime. The chosen world backing is SAB-based and cannot start without it. In browsers this requires cross-origin isolation: serve the page with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` (or `credentialless`). Alternatively choose the pure-TS heap profile (`memory: { heap: {} }`), which is backed by a plain ArrayBuffer and needs no SAB / no COOP+COEP. In Bun/Node SAB is available unconditionally — if you see this there, the runtime is older than expected or the global was shadowed."
|
|
10
|
+
), this.name = "SabUnavailableError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const d = (a) => {
|
|
14
|
+
if (typeof SharedArrayBuffer > "u") throw new c();
|
|
15
|
+
return new SharedArrayBuffer(a);
|
|
16
|
+
}, h = 64 * 1024;
|
|
17
|
+
function f(a, t, e) {
|
|
18
|
+
if (e <= 0 || !Number.isInteger(e))
|
|
19
|
+
throw new Error(`${a}: maxBytes must be a positive integer (got ${e})`);
|
|
20
|
+
let r = null;
|
|
21
|
+
const n = (o) => {
|
|
22
|
+
if (o > e)
|
|
23
|
+
throw new u(
|
|
24
|
+
`${a}: requested ${o} bytes exceeds the by-design maxBytes cap of ${e}. This is a hard ceiling with no grow-beyond-cap fallback (#380); a real workload stays ~16 MiB. Reaching it signals runaway entity/column growth upstream — diagnose that rather than raising the cap blindly.`,
|
|
25
|
+
o,
|
|
26
|
+
e
|
|
27
|
+
);
|
|
28
|
+
return r === null ? (r = t.create(o, e), r) : (o > r.byteLength && t.growTo(r, o), r);
|
|
29
|
+
};
|
|
30
|
+
return Object.defineProperty(n, "isInPlace", { value: !0, enumerable: !0 }), n;
|
|
31
|
+
}
|
|
32
|
+
function w(a = 256 * 1024 * 1024) {
|
|
33
|
+
if (typeof SharedArrayBuffer > "u") throw new c();
|
|
34
|
+
return f(
|
|
35
|
+
"growable_sab_allocator",
|
|
36
|
+
{
|
|
37
|
+
create: (t, e) => {
|
|
38
|
+
const r = SharedArrayBuffer;
|
|
39
|
+
return new r(t, { maxByteLength: e });
|
|
40
|
+
},
|
|
41
|
+
// boundary: SharedArrayBuffer.grow is in the spec but not in all
|
|
42
|
+
// lib types; widen here so the rest of the layer doesn't need to.
|
|
43
|
+
growTo: (t, e) => t.grow(e)
|
|
44
|
+
},
|
|
45
|
+
a
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function b(a = 256 * 1024 * 1024) {
|
|
49
|
+
return f(
|
|
50
|
+
"heap_arraybuffer_allocator",
|
|
51
|
+
{
|
|
52
|
+
create: (t, e) => {
|
|
53
|
+
const r = ArrayBuffer;
|
|
54
|
+
return new r(t, { maxByteLength: e });
|
|
55
|
+
},
|
|
56
|
+
// boundary: `ArrayBuffer.prototype.resize` is ES2024, not in the ES2022
|
|
57
|
+
// lib types; widen here. Resize keeps the same buffer object and
|
|
58
|
+
// preserves existing views (the in-place contract).
|
|
59
|
+
growTo: (t, e) => t.resize(e)
|
|
60
|
+
},
|
|
61
|
+
a
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function g(a) {
|
|
65
|
+
if (!(a.buffer instanceof SharedArrayBuffer))
|
|
66
|
+
throw new Error(
|
|
67
|
+
"wasm_memory_allocator: WebAssembly.Memory must be constructed with `shared: true` so its buffer is a SharedArrayBuffer"
|
|
68
|
+
);
|
|
69
|
+
const t = () => a.buffer, e = (r) => {
|
|
70
|
+
const n = a.buffer.byteLength;
|
|
71
|
+
if (r <= n)
|
|
72
|
+
return t();
|
|
73
|
+
const o = Math.ceil((r - n) / h), s = (i) => (
|
|
74
|
+
// The JS API doesn't expose the Memory's `maximum`, so the cap is
|
|
75
|
+
// reported as unknowable (`null`) — the caller declared it at
|
|
76
|
+
// `new WebAssembly.Memory({ maximum })` time.
|
|
77
|
+
new u(
|
|
78
|
+
`wasm_memory_allocator: memory.grow(${o}) failed (current=${n} bytes, requested=${r} bytes, maximum may be reached)`,
|
|
79
|
+
r,
|
|
80
|
+
null,
|
|
81
|
+
{ cause: i }
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
let l;
|
|
85
|
+
try {
|
|
86
|
+
l = a.grow(o);
|
|
87
|
+
} catch (i) {
|
|
88
|
+
throw s(i);
|
|
89
|
+
}
|
|
90
|
+
if (l === -1)
|
|
91
|
+
throw s();
|
|
92
|
+
return t();
|
|
93
|
+
};
|
|
94
|
+
return Object.defineProperty(e, "isInPlace", { value: !0, enumerable: !0 }), e;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
d as D,
|
|
98
|
+
u as S,
|
|
99
|
+
c as a,
|
|
100
|
+
w as g,
|
|
101
|
+
b as h,
|
|
102
|
+
g as w
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class s extends Error{constructor(o,r,e,n){super(o,n),this.requestedBytes=r,this.capBytes=e,this.name="StoreCapExceededError"}}class l extends Error{constructor(){super("SharedArrayBuffer is not available in this runtime. The chosen world backing is SAB-based and cannot start without it. In browsers this requires cross-origin isolation: serve the page with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` (or `credentialless`). Alternatively choose the pure-TS heap profile (`memory: { heap: {} }`), which is backed by a plain ArrayBuffer and needs no SAB / no COOP+COEP. In Bun/Node SAB is available unconditionally — if you see this there, the runtime is older than expected or the global was shadowed."),this.name="SabUnavailableError"}}const h=a=>{if(typeof SharedArrayBuffer>"u")throw new l;return new SharedArrayBuffer(a)},d=64*1024;function f(a,o,r){if(r<=0||!Number.isInteger(r))throw new Error(`${a}: maxBytes must be a positive integer (got ${r})`);let e=null;const n=t=>{if(t>r)throw new s(`${a}: requested ${t} bytes exceeds the by-design maxBytes cap of ${r}. This is a hard ceiling with no grow-beyond-cap fallback (#380); a real workload stays ~16 MiB. Reaching it signals runaway entity/column growth upstream — diagnose that rather than raising the cap blindly.`,t,r);return e===null?(e=o.create(t,r),e):(t>e.byteLength&&o.growTo(e,t),e)};return Object.defineProperty(n,"isInPlace",{value:!0,enumerable:!0}),n}function b(a=256*1024*1024){if(typeof SharedArrayBuffer>"u")throw new l;return f("growable_sab_allocator",{create:(o,r)=>{const e=SharedArrayBuffer;return new e(o,{maxByteLength:r})},growTo:(o,r)=>o.grow(r)},a)}function w(a=256*1024*1024){return f("heap_arraybuffer_allocator",{create:(o,r)=>{const e=ArrayBuffer;return new e(o,{maxByteLength:r})},growTo:(o,r)=>o.resize(r)},a)}function A(a){if(!(a.buffer instanceof SharedArrayBuffer))throw new Error("wasm_memory_allocator: WebAssembly.Memory must be constructed with `shared: true` so its buffer is a SharedArrayBuffer");const o=()=>a.buffer,r=e=>{const n=a.buffer.byteLength;if(e<=n)return o();const t=Math.ceil((e-n)/d),c=i=>new s(`wasm_memory_allocator: memory.grow(${t}) failed (current=${n} bytes, requested=${e} bytes, maximum may be reached)`,e,null,{cause:i});let u;try{u=a.grow(t)}catch(i){throw c(i)}if(u===-1)throw c();return o()};return Object.defineProperty(r,"isInPlace",{value:!0,enumerable:!0}),r}exports.DEFAULT_SAB_ALLOCATOR=h;exports.SabUnavailableError=l;exports.StoreCapExceededError=s;exports.growableSabAllocator=b;exports.heapArraybufferAllocator=w;exports.wasmMemoryAllocator=A;
|
package/dist/shared.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-BymrGTyR.cjs");exports.DEFAULT_SAB_ALLOCATOR=a.DEFAULT_SAB_ALLOCATOR;exports.SabUnavailableError=a.SabUnavailableError;exports.growableSabAllocator=a.growableSabAllocator;exports.wasmMemoryAllocator=a.wasmMemoryAllocator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oasys/oecs/shared` — the opt-in SharedArrayBuffer / WASM profile.
|
|
3
|
+
*
|
|
4
|
+
* The default `@oasys/oecs` profile runs the column store over a plain
|
|
5
|
+
* resizable `ArrayBuffer` (no cross-origin isolation). This entry surfaces the
|
|
6
|
+
* `SharedArrayBuffer`-backed allocators for worlds that opt into worker offload
|
|
7
|
+
* or a WASM compute backend — construct with `new ECS({ memory: { shared: {} } })`,
|
|
8
|
+
* or pass one of these allocators through `memory: { allocator }`.
|
|
9
|
+
*
|
|
10
|
+
* **Requires cross-origin isolation (COOP/COEP) in browsers** — that's the
|
|
11
|
+
* whole reason it's a separate, opt-in profile.
|
|
12
|
+
*
|
|
13
|
+
* The WASM compute backend itself is NOT bundled here: oecs ships the
|
|
14
|
+
* `ComputeBackend` *seam* (`@oasys/oecs` → `attachBackend`) plus the
|
|
15
|
+
* cross-thread ring transport (`HostCommandDispatcher`). The worker entrypoint
|
|
16
|
+
* and the compiled WASM module are the consumer's to provide.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
export { growableSabAllocator, wasmMemoryAllocator, DEFAULT_SAB_ALLOCATOR, SabUnavailableError } from './core/store/index.cjs';
|
|
21
|
+
export type { SharedMemoryArm } from './core/ecs/ecs_memory.cjs';
|
|
22
|
+
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts
CHANGED
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
|
-
export { growableSabAllocator, wasmMemoryAllocator, DEFAULT_SAB_ALLOCATOR, SabUnavailableError } from './core/store';
|
|
21
|
-
export type { SharedMemoryArm } from './core/ecs/ecs_memory';
|
|
20
|
+
export { growableSabAllocator, wasmMemoryAllocator, DEFAULT_SAB_ALLOCATOR, SabUnavailableError } from './core/store/index.js';
|
|
21
|
+
export type { SharedMemoryArm } from './core/ecs/ecs_memory.js';
|
|
22
22
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class d{_denseKeys=[];_denseVals=[];_sparse=[];get size(){return this._denseKeys.length}get keys(){return this._denseKeys}has(s){return this._denseKeys[this._sparse[s]]===s}get(s){return this.has(s)?this._denseVals[this._sparse[s]]:void 0}set(s,t){if(this.has(s)){this._denseVals[this._sparse[s]]=t;return}this._sparse[s]=this._denseKeys.length,this._denseKeys.push(s),this._denseVals.push(t)}delete(s){if(!this.has(s))return!1;const t=this._sparse[s],i=this._denseKeys[this._denseKeys.length-1];return this._denseKeys[t]=i,this._denseVals[t]=this._denseVals[this._denseVals.length-1],this._sparse[i]=t,this._denseKeys.pop(),this._denseVals.pop(),!0}clear(){this._denseKeys.length=0,this._denseVals.length=0,this._sparse.length=0}forEach(s){for(let t=0;t<this._denseKeys.length;t++)s(this._denseKeys[t],this._denseVals[t])}[Symbol.iterator](){let s=0;const t=this._denseKeys,i=this._denseVals;return{next(){return s<t.length?{value:[t[s],i[s++]],done:!1}:{value:void 0,done:!0}}}}}class g{_compare;_data=[];constructor(s){this._compare=s}get size(){return this._data.length}peek(){return this._data[0]}push(s){this._data.push(s),this._siftUp(this._data.length-1)}pop(){const s=this._data;if(s.length===0)return;const i=s[0],h=s.pop();return s.length>0&&(s[0]=h,this._siftDown(0)),i}clear(){this._data.length=0}_siftUp(s){const t=this._data,i=this._compare,h=t[s];for(;s>0;){const n=s-1>>1;if(i(h,t[n])>=0)break;t[s]=t[n],s=n}t[s]=h}_siftDown(s){const t=this._data,i=this._compare,h=t.length,n=h>>1,c=t[s];for(;s<n;){let a=(s<<1)+1;const e=a+1;if(e<h&&i(t[e],t[a])<0&&(a=e),i(t[a],c)>=0)break;t[s]=t[a],s=a}t[s]=c}}function u(l,s,t,i){const h=i??(e=>String(e)),n=new Map;for(let e=0;e<l.length;e++)n.set(l[e],0);for(const[,e]of s)for(let r=0;r<e.length;r++){const o=e[r];n.has(o)&&n.set(o,n.get(o)+1)}const c=new g(t);for(let e=0;e<l.length;e++)n.get(l[e])===0&&c.push(l[e]);const a=[];for(;c.size>0;){const e=c.pop();a.push(e);const r=s.get(e);if(r!==void 0)for(let o=0;o<r.length;o++){const _=r[o];if(!n.has(_))continue;const p=n.get(_)-1;n.set(_,p),p===0&&c.push(_)}}if(a.length!==l.length){const e=[];for(const[r,o]of n)o>0&&e.push(h(r));throw new TypeError(`Cycle detected in topological sort. Nodes still pending: ${e.join(", ")}`)}return a}exports.BinaryHeap=g;exports.SparseMap=d;exports.topologicalSort=u;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
class g {
|
|
2
|
+
_denseKeys = [];
|
|
3
|
+
_denseVals = [];
|
|
4
|
+
_sparse = [];
|
|
5
|
+
get size() {
|
|
6
|
+
return this._denseKeys.length;
|
|
7
|
+
}
|
|
8
|
+
get keys() {
|
|
9
|
+
return this._denseKeys;
|
|
10
|
+
}
|
|
11
|
+
has(s) {
|
|
12
|
+
return this._denseKeys[this._sparse[s]] === s;
|
|
13
|
+
}
|
|
14
|
+
get(s) {
|
|
15
|
+
return this.has(s) ? this._denseVals[this._sparse[s]] : void 0;
|
|
16
|
+
}
|
|
17
|
+
set(s, t) {
|
|
18
|
+
if (this.has(s)) {
|
|
19
|
+
this._denseVals[this._sparse[s]] = t;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this._sparse[s] = this._denseKeys.length, this._denseKeys.push(s), this._denseVals.push(t);
|
|
23
|
+
}
|
|
24
|
+
delete(s) {
|
|
25
|
+
if (!this.has(s)) return !1;
|
|
26
|
+
const t = this._sparse[s], h = this._denseKeys[this._denseKeys.length - 1];
|
|
27
|
+
return this._denseKeys[t] = h, this._denseVals[t] = this._denseVals[this._denseVals.length - 1], this._sparse[h] = t, this._denseKeys.pop(), this._denseVals.pop(), !0;
|
|
28
|
+
}
|
|
29
|
+
clear() {
|
|
30
|
+
this._denseKeys.length = 0, this._denseVals.length = 0, this._sparse.length = 0;
|
|
31
|
+
}
|
|
32
|
+
forEach(s) {
|
|
33
|
+
for (let t = 0; t < this._denseKeys.length; t++)
|
|
34
|
+
s(this._denseKeys[t], this._denseVals[t]);
|
|
35
|
+
}
|
|
36
|
+
[Symbol.iterator]() {
|
|
37
|
+
let s = 0;
|
|
38
|
+
const t = this._denseKeys, h = this._denseVals;
|
|
39
|
+
return {
|
|
40
|
+
next() {
|
|
41
|
+
return s < t.length ? { value: [t[s], h[s++]], done: !1 } : { value: void 0, done: !0 };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class d {
|
|
47
|
+
_compare;
|
|
48
|
+
_data = [];
|
|
49
|
+
constructor(s) {
|
|
50
|
+
this._compare = s;
|
|
51
|
+
}
|
|
52
|
+
get size() {
|
|
53
|
+
return this._data.length;
|
|
54
|
+
}
|
|
55
|
+
/** Returns the highest-priority element without removing it, or undefined if empty. */
|
|
56
|
+
peek() {
|
|
57
|
+
return this._data[0];
|
|
58
|
+
}
|
|
59
|
+
/** Inserts a value and restores heap order by sifting up. O(log n). */
|
|
60
|
+
push(s) {
|
|
61
|
+
this._data.push(s), this._siftUp(this._data.length - 1);
|
|
62
|
+
}
|
|
63
|
+
/** Removes and returns the highest-priority element, or undefined if empty. O(log n). */
|
|
64
|
+
pop() {
|
|
65
|
+
const s = this._data;
|
|
66
|
+
if (s.length === 0) return;
|
|
67
|
+
const h = s[0], i = s.pop();
|
|
68
|
+
return s.length > 0 && (s[0] = i, this._siftDown(0)), h;
|
|
69
|
+
}
|
|
70
|
+
/** Removes all elements. O(1). */
|
|
71
|
+
clear() {
|
|
72
|
+
this._data.length = 0;
|
|
73
|
+
}
|
|
74
|
+
/** Moves a node up toward the root until heap order is restored. */
|
|
75
|
+
_siftUp(s) {
|
|
76
|
+
const t = this._data, h = this._compare, i = t[s];
|
|
77
|
+
for (; s > 0; ) {
|
|
78
|
+
const n = s - 1 >> 1;
|
|
79
|
+
if (h(i, t[n]) >= 0) break;
|
|
80
|
+
t[s] = t[n], s = n;
|
|
81
|
+
}
|
|
82
|
+
t[s] = i;
|
|
83
|
+
}
|
|
84
|
+
/** Moves a node down away from the root until heap order is restored. */
|
|
85
|
+
_siftDown(s) {
|
|
86
|
+
const t = this._data, h = this._compare, i = t.length, n = i >> 1, c = t[s];
|
|
87
|
+
for (; s < n; ) {
|
|
88
|
+
let a = (s << 1) + 1;
|
|
89
|
+
const e = a + 1;
|
|
90
|
+
if (e < i && h(t[e], t[a]) < 0 && (a = e), h(t[a], c) >= 0) break;
|
|
91
|
+
t[s] = t[a], s = a;
|
|
92
|
+
}
|
|
93
|
+
t[s] = c;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function u(l, s, t, h) {
|
|
97
|
+
const i = h ?? ((e) => String(e)), n = /* @__PURE__ */ new Map();
|
|
98
|
+
for (let e = 0; e < l.length; e++)
|
|
99
|
+
n.set(l[e], 0);
|
|
100
|
+
for (const [, e] of s)
|
|
101
|
+
for (let r = 0; r < e.length; r++) {
|
|
102
|
+
const o = e[r];
|
|
103
|
+
n.has(o) && n.set(o, n.get(o) + 1);
|
|
104
|
+
}
|
|
105
|
+
const c = new d(t);
|
|
106
|
+
for (let e = 0; e < l.length; e++)
|
|
107
|
+
n.get(l[e]) === 0 && c.push(l[e]);
|
|
108
|
+
const a = [];
|
|
109
|
+
for (; c.size > 0; ) {
|
|
110
|
+
const e = c.pop();
|
|
111
|
+
a.push(e);
|
|
112
|
+
const r = s.get(e);
|
|
113
|
+
if (r !== void 0)
|
|
114
|
+
for (let o = 0; o < r.length; o++) {
|
|
115
|
+
const _ = r[o];
|
|
116
|
+
if (!n.has(_)) continue;
|
|
117
|
+
const p = n.get(_) - 1;
|
|
118
|
+
n.set(_, p), p === 0 && c.push(_);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (a.length !== l.length) {
|
|
122
|
+
const e = [];
|
|
123
|
+
for (const [r, o] of n)
|
|
124
|
+
o > 0 && e.push(i(r));
|
|
125
|
+
throw new TypeError(
|
|
126
|
+
`Cycle detected in topological sort. Nodes still pending: ${e.join(", ")}`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return a;
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
d as B,
|
|
133
|
+
g as S,
|
|
134
|
+
u as t
|
|
135
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Assertions — Dev-only runtime validation and branded casting.
|
|
3
|
+
*
|
|
4
|
+
* All checks are guarded by DEV and tree-shaken in production builds.
|
|
5
|
+
* validateAndCast is the primary tool for creating branded IDs:
|
|
6
|
+
* it validates the input in dev and returns the value as the branded type.
|
|
7
|
+
* unsafeCast bypasses all checks (used when the caller guarantees validity).
|
|
8
|
+
*
|
|
9
|
+
***/
|
|
10
|
+
export declare const isNonNegativeInteger: (v: number) => boolean;
|
|
11
|
+
export declare const isNonNull: (v: unknown) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Dev-only assertion that value is not null/undefined.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare function assertNonNull<T>(value: T): asserts value is NonNullable<T>;
|
|
17
|
+
export declare function assert<T, Result extends T = T>(value: T, condition: (v: T) => v is Result, errMessage: string): asserts value is Result;
|
|
18
|
+
export declare function validateAndCast<T, Result extends T = T>(value: T, validator: (v: T) => boolean, errMessage: string): Result;
|
|
19
|
+
export declare function unsafeCast<T>(value: unknown): T;
|
|
20
|
+
/**
|
|
21
|
+
* Exhaustiveness backstop for tagged-union dispatches. Put it in the
|
|
22
|
+
* `default` arm (or after the final `case`) of a switch over a closed union:
|
|
23
|
+
* the `never` parameter makes "a union gained a variant but this dispatch
|
|
24
|
+
* didn't" a COMPILE error at the call site, and the throw catches runtime
|
|
25
|
+
* values that bypassed the type layer (deserialized/foreign data).
|
|
26
|
+
*
|
|
27
|
+
* Deliberately NOT `DEV`-gated, unlike the rest of this file: it marks a
|
|
28
|
+
* can't-happen branch, so it costs nothing until the day it fires — and that
|
|
29
|
+
* day it must fire in production too, not silently fall through.
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertNever(value: never, label: string): never;
|
|
32
|
+
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/***
|
|
2
2
|
* Assertions — Dev-only runtime validation and branded casting.
|
|
3
3
|
*
|
|
4
|
-
* All checks are guarded by
|
|
4
|
+
* All checks are guarded by DEV and tree-shaken in production builds.
|
|
5
5
|
* validateAndCast is the primary tool for creating branded IDs:
|
|
6
6
|
* it validates the input in dev and returns the value as the branded type.
|
|
7
7
|
* unsafeCast bypasses all checks (used when the caller guarantees validity).
|
|
@@ -17,4 +17,16 @@ export declare function assertNonNull<T>(value: T): asserts value is NonNullable
|
|
|
17
17
|
export declare function assert<T, Result extends T = T>(value: T, condition: (v: T) => v is Result, errMessage: string): asserts value is Result;
|
|
18
18
|
export declare function validateAndCast<T, Result extends T = T>(value: T, validator: (v: T) => boolean, errMessage: string): Result;
|
|
19
19
|
export declare function unsafeCast<T>(value: unknown): T;
|
|
20
|
+
/**
|
|
21
|
+
* Exhaustiveness backstop for tagged-union dispatches. Put it in the
|
|
22
|
+
* `default` arm (or after the final `case`) of a switch over a closed union:
|
|
23
|
+
* the `never` parameter makes "a union gained a variant but this dispatch
|
|
24
|
+
* didn't" a COMPILE error at the call site, and the throw catches runtime
|
|
25
|
+
* values that bypassed the type layer (deserialized/foreign data).
|
|
26
|
+
*
|
|
27
|
+
* Deliberately NOT `DEV`-gated, unlike the rest of this file: it marks a
|
|
28
|
+
* can't-happen branch, so it costs nothing until the day it fires — and that
|
|
29
|
+
* day it must fire in production too, not silently fall through.
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertNever(value: never, label: string): never;
|
|
20
32
|
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../src/type_primitives/assertions.ts"],"names":[],"mappings":"AAAA;;;;;;;;KAQK;
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../src/type_primitives/assertions.ts"],"names":[],"mappings":"AAAA;;;;;;;;KAQK;AAKL,eAAO,MAAM,oBAAoB,MAAO,MAAM,KAAG,OAAwC,CAAC;AAE1F,eAAO,MAAM,SAAS,MAAO,OAAO,KAAG,OAAqB,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAU1E;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,EAC7C,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,MAAM,EAChC,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,IAAI,MAAM,CAOzB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,EACtD,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,EAC5B,UAAU,EAAE,MAAM,GAChB,MAAM,CAQR;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE/C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAK9D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* BinaryHeap — generic array-backed binary heap with configurable ordering.
|
|
3
|
+
*
|
|
4
|
+
* Array layout uses implicit indexing: root at index 0, children of node `i`
|
|
5
|
+
* at `2i + 1` and `2i + 2`, parent of node `i` at `(i - 1) >> 1`.
|
|
6
|
+
*
|
|
7
|
+
* The comparator determines ordering: when `compare(a, b) < 0`, `a` has
|
|
8
|
+
* higher priority and floats toward the root. A standard `(a, b) => a - b`
|
|
9
|
+
* comparator yields a min-heap; `(a, b) => b - a` yields a max-heap.
|
|
10
|
+
*
|
|
11
|
+
* push and pop are O(log n). peek and clear are O(1).
|
|
12
|
+
*
|
|
13
|
+
***/
|
|
14
|
+
export type CompareFn<T> = (a: T, b: T) => number;
|
|
15
|
+
/**
|
|
16
|
+
* Generic array-backed binary heap with configurable comparator.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare class BinaryHeap<T> {
|
|
20
|
+
private readonly _compare;
|
|
21
|
+
private readonly _data;
|
|
22
|
+
constructor(compare: CompareFn<T>);
|
|
23
|
+
get size(): number;
|
|
24
|
+
/** Returns the highest-priority element without removing it, or undefined if empty. */
|
|
25
|
+
peek(): T | undefined;
|
|
26
|
+
/** Inserts a value and restores heap order by sifting up. O(log n). */
|
|
27
|
+
push(value: T): void;
|
|
28
|
+
/** Removes and returns the highest-priority element, or undefined if empty. O(log n). */
|
|
29
|
+
pop(): T | undefined;
|
|
30
|
+
/** Removes all elements. O(1). */
|
|
31
|
+
clear(): void;
|
|
32
|
+
/** Moves a node up toward the root until heap order is restored. */
|
|
33
|
+
private _siftUp;
|
|
34
|
+
/** Moves a node down away from the root until heap order is restored. */
|
|
35
|
+
private _siftDown;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=binary_heap.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* BitSet — number[]-backed bit set with auto-grow.
|
|
3
|
+
*
|
|
4
|
+
* Used as the archetype component signature. Each bit position corresponds
|
|
5
|
+
* to a ComponentID. Operations (has/set/clear) are O(1), and mask
|
|
6
|
+
* comparisons (contains, equals, overlaps) are O(words) where
|
|
7
|
+
* words = ceil(maxComponentId / 32).
|
|
8
|
+
*
|
|
9
|
+
* Bit layout within each 32-bit word:
|
|
10
|
+
* wordIndex = bit >>> BITS_PER_WORD_SHIFT (divide by 32)
|
|
11
|
+
* bit_offset = bit & BITS_PER_WORD_MASK (mod 32)
|
|
12
|
+
* test: word & (1 << offset)
|
|
13
|
+
* set: word |= (1 << offset)
|
|
14
|
+
* clear: word &= ~(1 << offset)
|
|
15
|
+
*
|
|
16
|
+
***/
|
|
17
|
+
export declare const BITS_PER_WORD = 32;
|
|
18
|
+
export declare const BITS_PER_WORD_SHIFT = 5;
|
|
19
|
+
export declare const BITS_PER_WORD_MASK = 31;
|
|
20
|
+
export declare const FNV_OFFSET_BASIS = 2166136261;
|
|
21
|
+
export declare const FNV_PRIME = 16777619;
|
|
22
|
+
/**
|
|
23
|
+
* number[]-backed bit set with auto-grow. Used as the archetype component signature.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare class BitSet {
|
|
27
|
+
_words: number[];
|
|
28
|
+
constructor(words?: number[]);
|
|
29
|
+
has(bit: number): boolean;
|
|
30
|
+
set(bit: number): void;
|
|
31
|
+
clear(bit: number): void;
|
|
32
|
+
/** True if no bit is set. */
|
|
33
|
+
isEmpty(): boolean;
|
|
34
|
+
/** True if any bit is set in both this and other (non-empty intersection). */
|
|
35
|
+
overlaps(other: BitSet): boolean;
|
|
36
|
+
/** True if this is a superset of other (all bits in other are set in this). */
|
|
37
|
+
contains(other: BitSet): boolean;
|
|
38
|
+
equals(other: BitSet): boolean;
|
|
39
|
+
copy(): BitSet;
|
|
40
|
+
/** Mutate `target` so it has the same set bits as `this`. Reuses
|
|
41
|
+
* `target._words` storage when capacity allows (no allocation) and
|
|
42
|
+
* grows it only when `this` is wider. Designed for hot-path scratch
|
|
43
|
+
* BitSets where callers want `.copy()` semantics without the
|
|
44
|
+
* per-call allocation. Returns `target` for chaining. */
|
|
45
|
+
copyInto(target: BitSet): BitSet;
|
|
46
|
+
copyWithSet(bit: number): BitSet;
|
|
47
|
+
copyWithClear(bit: number): BitSet;
|
|
48
|
+
/** FNV-1a hash. Skips trailing zero words so differently-sized arrays with the same bits hash equally. */
|
|
49
|
+
hash(): number;
|
|
50
|
+
/** Iterate all set bits via lowest-set-bit extraction. */
|
|
51
|
+
forEach(fn: (bit: number) => void): void;
|
|
52
|
+
private grow;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=bitset.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Brand — Nominal typing for TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* Brand<T, Name> intersects T with a phantom readonly symbol property
|
|
5
|
+
* tagged with Name. The symbol never exists at runtime — it only prevents
|
|
6
|
+
* accidental assignment between structurally identical types.
|
|
7
|
+
*
|
|
8
|
+
* Example: EntityID and ComponentID are both numbers at runtime, but
|
|
9
|
+
* Brand<number, "entityId"> and Brand<number, "component_id"> are
|
|
10
|
+
* incompatible at compile time.
|
|
11
|
+
*
|
|
12
|
+
***/
|
|
13
|
+
declare const brand: unique symbol;
|
|
14
|
+
/**
|
|
15
|
+
* Nominal typing helper — intersects T with a phantom readonly symbol
|
|
16
|
+
* so structurally identical types become compile-time incompatible.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export type Brand<T, BrandName extends string> = T & {
|
|
20
|
+
readonly [brand]: BrandName;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=brand.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppError } from '../utils/error.cjs';
|
|
2
|
+
export declare enum TYPE_ERROR {
|
|
3
|
+
ASSERTION_FAIL_CONDITION = "ASSERTION_FAIL_CONDITION",
|
|
4
|
+
VALIDATION_FAIL_CONDITION = "VALIDATION_FAIL_CONDITION",
|
|
5
|
+
ASSERTION_FAIL_NON_NULLABLE = "ASSERTION_FAIL_NON_NULLABLE",
|
|
6
|
+
ASSERTION_FAIL_UNREACHABLE = "ASSERTION_FAIL_UNREACHABLE"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Error class thrown by std's runtime assertions. Non-operational.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare class AssertionError extends AppError {
|
|
13
|
+
readonly category: TYPE_ERROR;
|
|
14
|
+
constructor(category: TYPE_ERROR, message: string, context?: Record<string, unknown>);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { AppError } from '../utils/error';
|
|
1
|
+
import { AppError } from '../utils/error.js';
|
|
2
2
|
export declare enum TYPE_ERROR {
|
|
3
3
|
ASSERTION_FAIL_CONDITION = "ASSERTION_FAIL_CONDITION",
|
|
4
4
|
VALIDATION_FAIL_CONDITION = "VALIDATION_FAIL_CONDITION",
|
|
5
|
-
ASSERTION_FAIL_NON_NULLABLE = "ASSERTION_FAIL_NON_NULLABLE"
|
|
5
|
+
ASSERTION_FAIL_NON_NULLABLE = "ASSERTION_FAIL_NON_NULLABLE",
|
|
6
|
+
ASSERTION_FAIL_UNREACHABLE = "ASSERTION_FAIL_UNREACHABLE"
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Error class thrown by std's runtime assertions. Non-operational.
|
|
9
10
|
*
|
|
10
11
|
*/
|
|
11
|
-
export declare class
|
|
12
|
+
export declare class AssertionError extends AppError {
|
|
12
13
|
readonly category: TYPE_ERROR;
|
|
13
14
|
constructor(category: TYPE_ERROR, message: string, context?: Record<string, unknown>);
|
|
14
15
|
}
|