@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,391 @@
|
|
|
1
|
+
const y = 5, b = 31;
|
|
2
|
+
class f {
|
|
3
|
+
_words;
|
|
4
|
+
constructor(s) {
|
|
5
|
+
this._words = s ?? new Array(4).fill(0);
|
|
6
|
+
}
|
|
7
|
+
has(s) {
|
|
8
|
+
const t = s >>> 5;
|
|
9
|
+
return t >= this._words.length ? !1 : (this._words[t] & 1 << (s & 31)) !== 0;
|
|
10
|
+
}
|
|
11
|
+
set(s) {
|
|
12
|
+
const t = s >>> 5;
|
|
13
|
+
t >= this._words.length && this.grow(t + 1), this._words[t] |= 1 << (s & 31);
|
|
14
|
+
}
|
|
15
|
+
clear(s) {
|
|
16
|
+
const t = s >>> 5;
|
|
17
|
+
t >= this._words.length || (this._words[t] &= ~(1 << (s & 31)));
|
|
18
|
+
}
|
|
19
|
+
/** True if no bit is set. */
|
|
20
|
+
isEmpty() {
|
|
21
|
+
const s = this._words;
|
|
22
|
+
for (let t = 0; t < s.length; t++)
|
|
23
|
+
if (s[t] !== 0) return !1;
|
|
24
|
+
return !0;
|
|
25
|
+
}
|
|
26
|
+
/** True if any bit is set in both this and other (non-empty intersection). */
|
|
27
|
+
overlaps(s) {
|
|
28
|
+
const t = this._words, e = s._words, r = t.length < e.length ? t.length : e.length;
|
|
29
|
+
for (let n = 0; n < r; n++)
|
|
30
|
+
if ((t[n] & e[n]) !== 0) return !0;
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
/** True if this is a superset of other (all bits in other are set in this). */
|
|
34
|
+
contains(s) {
|
|
35
|
+
const t = s._words, e = this._words, r = e.length;
|
|
36
|
+
for (let n = 0; n < t.length; n++) {
|
|
37
|
+
const o = t[n];
|
|
38
|
+
if (o !== 0 && (n >= r || (e[n] & o) !== o))
|
|
39
|
+
return !1;
|
|
40
|
+
}
|
|
41
|
+
return !0;
|
|
42
|
+
}
|
|
43
|
+
equals(s) {
|
|
44
|
+
const t = this._words, e = s._words, r = t.length > e.length ? t.length : e.length;
|
|
45
|
+
for (let n = 0; n < r; n++) {
|
|
46
|
+
const o = n < t.length ? t[n] : 0, l = n < e.length ? e[n] : 0;
|
|
47
|
+
if (o !== l) return !1;
|
|
48
|
+
}
|
|
49
|
+
return !0;
|
|
50
|
+
}
|
|
51
|
+
copy() {
|
|
52
|
+
return new f(this._words.slice());
|
|
53
|
+
}
|
|
54
|
+
/** Mutate `target` so it has the same set bits as `this`. Reuses
|
|
55
|
+
* `target._words` storage when capacity allows (no allocation) and
|
|
56
|
+
* grows it only when `this` is wider. Designed for hot-path scratch
|
|
57
|
+
* BitSets where callers want `.copy()` semantics without the
|
|
58
|
+
* per-call allocation. Returns `target` for chaining. */
|
|
59
|
+
copyInto(s) {
|
|
60
|
+
const t = this._words, e = s._words, r = t.length, n = e.length;
|
|
61
|
+
if (n >= r) {
|
|
62
|
+
for (let o = 0; o < r; o++) e[o] = t[o];
|
|
63
|
+
for (let o = r; o < n; o++) e[o] = 0;
|
|
64
|
+
} else {
|
|
65
|
+
let o = n > 0 ? n : 1;
|
|
66
|
+
for (; o < r; ) o *= 2;
|
|
67
|
+
const l = new Array(o).fill(0);
|
|
68
|
+
for (let i = 0; i < r; i++) l[i] = t[i];
|
|
69
|
+
s._words = l;
|
|
70
|
+
}
|
|
71
|
+
return s;
|
|
72
|
+
}
|
|
73
|
+
copyWithSet(s) {
|
|
74
|
+
const t = s >>> 5, e = t + 1, r = this._words.length > e ? this._words.length : e, n = new Array(r).fill(0);
|
|
75
|
+
for (let o = 0; o < this._words.length; o++) n[o] = this._words[o];
|
|
76
|
+
return n[t] |= 1 << (s & 31), new f(n);
|
|
77
|
+
}
|
|
78
|
+
copyWithClear(s) {
|
|
79
|
+
const t = this._words.slice(), e = s >>> 5;
|
|
80
|
+
return e < t.length && (t[e] &= ~(1 << (s & 31))), new f(t);
|
|
81
|
+
}
|
|
82
|
+
/** FNV-1a hash. Skips trailing zero words so differently-sized arrays with the same bits hash equally. */
|
|
83
|
+
hash() {
|
|
84
|
+
let s = 2166136261;
|
|
85
|
+
const t = this._words;
|
|
86
|
+
let e = t.length - 1;
|
|
87
|
+
for (; e >= 0 && t[e] === 0; ) e--;
|
|
88
|
+
for (let r = 0; r <= e; r++)
|
|
89
|
+
s ^= t[r], s = Math.imul(s, 16777619);
|
|
90
|
+
return s;
|
|
91
|
+
}
|
|
92
|
+
/** Iterate all set bits via lowest-set-bit extraction. */
|
|
93
|
+
forEach(s) {
|
|
94
|
+
const t = this._words;
|
|
95
|
+
for (let e = 0; e < t.length; e++) {
|
|
96
|
+
let r = t[e];
|
|
97
|
+
if (r === 0) continue;
|
|
98
|
+
const n = e << 5;
|
|
99
|
+
for (; r !== 0; ) {
|
|
100
|
+
const o = r & -r >>> 0, l = 31 - Math.clz32(o);
|
|
101
|
+
s(n + l), r ^= o;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
grow(s) {
|
|
106
|
+
let t = this._words.length;
|
|
107
|
+
for (; t < s; ) t *= 2;
|
|
108
|
+
const e = new Array(t).fill(0);
|
|
109
|
+
for (let r = 0; r < this._words.length; r++) e[r] = this._words[r];
|
|
110
|
+
this._words = e;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
class I {
|
|
114
|
+
_denseKeys = [];
|
|
115
|
+
_denseVals = [];
|
|
116
|
+
_sparse = [];
|
|
117
|
+
get size() {
|
|
118
|
+
return this._denseKeys.length;
|
|
119
|
+
}
|
|
120
|
+
get keys() {
|
|
121
|
+
return this._denseKeys;
|
|
122
|
+
}
|
|
123
|
+
has(s) {
|
|
124
|
+
return this._denseKeys[this._sparse[s]] === s;
|
|
125
|
+
}
|
|
126
|
+
get(s) {
|
|
127
|
+
return this.has(s) ? this._denseVals[this._sparse[s]] : void 0;
|
|
128
|
+
}
|
|
129
|
+
set(s, t) {
|
|
130
|
+
if (this.has(s)) {
|
|
131
|
+
this._denseVals[this._sparse[s]] = t;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this._sparse[s] = this._denseKeys.length, this._denseKeys.push(s), this._denseVals.push(t);
|
|
135
|
+
}
|
|
136
|
+
delete(s) {
|
|
137
|
+
if (!this.has(s)) return !1;
|
|
138
|
+
const t = this._sparse[s], e = this._denseKeys[this._denseKeys.length - 1];
|
|
139
|
+
return this._denseKeys[t] = e, this._denseVals[t] = this._denseVals[this._denseVals.length - 1], this._sparse[e] = t, this._denseKeys.pop(), this._denseVals.pop(), !0;
|
|
140
|
+
}
|
|
141
|
+
clear() {
|
|
142
|
+
this._denseKeys.length = 0, this._denseVals.length = 0, this._sparse.length = 0;
|
|
143
|
+
}
|
|
144
|
+
forEach(s) {
|
|
145
|
+
for (let t = 0; t < this._denseKeys.length; t++)
|
|
146
|
+
s(this._denseKeys[t], this._denseVals[t]);
|
|
147
|
+
}
|
|
148
|
+
[Symbol.iterator]() {
|
|
149
|
+
let s = 0;
|
|
150
|
+
const t = this._denseKeys, e = this._denseVals;
|
|
151
|
+
return {
|
|
152
|
+
next() {
|
|
153
|
+
return s < t.length ? { value: [t[s], e[s++]], done: !1 } : { value: void 0, done: !0 };
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const c = 16, p = 2;
|
|
159
|
+
class u {
|
|
160
|
+
constructor(s, t = 16) {
|
|
161
|
+
this._ctor = s, this._buf = new s(t);
|
|
162
|
+
}
|
|
163
|
+
_buf;
|
|
164
|
+
_len = 0;
|
|
165
|
+
get length() {
|
|
166
|
+
return this._len;
|
|
167
|
+
}
|
|
168
|
+
push(s) {
|
|
169
|
+
this._len >= this._buf.length && this._grow(), this._buf[this._len++] = s;
|
|
170
|
+
}
|
|
171
|
+
pop() {
|
|
172
|
+
return this._buf[--this._len];
|
|
173
|
+
}
|
|
174
|
+
get(s) {
|
|
175
|
+
return this._buf[s];
|
|
176
|
+
}
|
|
177
|
+
setAt(s, t) {
|
|
178
|
+
this._buf[s] = t;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Move the last element into slot i, decrement length.
|
|
182
|
+
* Returns the value that was removed from slot i.
|
|
183
|
+
*/
|
|
184
|
+
swapRemove(s) {
|
|
185
|
+
const t = this._buf[s];
|
|
186
|
+
return this._buf[s] = this._buf[--this._len], t;
|
|
187
|
+
}
|
|
188
|
+
clear() {
|
|
189
|
+
this._len = 0;
|
|
190
|
+
}
|
|
191
|
+
/** Set the logical length directly (snapshot-mount reconstruction, #789). The
|
|
192
|
+
* caller guarantees `[0, len)` already holds valid data. Grows the backing if
|
|
193
|
+
* needed so the length is always representable. */
|
|
194
|
+
setLength(s) {
|
|
195
|
+
this.ensureCapacity(s), this._len = s;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Raw backing buffer. Valid data: indices 0..length-1.
|
|
199
|
+
* This reference is stable until the next push() that triggers a grow —
|
|
200
|
+
* do not cache across entity additions.
|
|
201
|
+
*/
|
|
202
|
+
get buf() {
|
|
203
|
+
return this._buf;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Zero-copy subarray view of valid data (0..length-1).
|
|
207
|
+
* Shares the backing buffer — invalidated if a subsequent push() grows.
|
|
208
|
+
*/
|
|
209
|
+
view() {
|
|
210
|
+
return this._buf.subarray(0, this._len);
|
|
211
|
+
}
|
|
212
|
+
[Symbol.iterator]() {
|
|
213
|
+
let s = 0;
|
|
214
|
+
const t = this._buf, e = this._len;
|
|
215
|
+
return {
|
|
216
|
+
next() {
|
|
217
|
+
return s < e ? { value: t[s++], done: !1 } : { value: 0, done: !0 };
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/** Ensure the backing buffer can hold at least `capacity` elements without growing. */
|
|
222
|
+
ensureCapacity(s) {
|
|
223
|
+
if (s <= this._buf.length) return;
|
|
224
|
+
let t = this._buf.length || 1;
|
|
225
|
+
for (; t < s; ) t *= p;
|
|
226
|
+
const e = new this._ctor(t);
|
|
227
|
+
e.set(this._buf.subarray(0, this._len)), this._buf = e;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Append `count` elements from `src` starting at `srcOffset`.
|
|
231
|
+
* Grows if needed. Equivalent to push() in a loop but uses TypedArray.set().
|
|
232
|
+
*/
|
|
233
|
+
bulkAppend(s, t, e) {
|
|
234
|
+
this.ensureCapacity(this._len + e), this._buf.set(s.subarray(t, t + e), this._len), this._len += e;
|
|
235
|
+
}
|
|
236
|
+
/** Append `count` zeroes. Grows if needed. */
|
|
237
|
+
bulkAppendZeroes(s) {
|
|
238
|
+
this.ensureCapacity(this._len + s), this._buf.fill(0, this._len, this._len + s), this._len += s;
|
|
239
|
+
}
|
|
240
|
+
/** Append `count` copies of `value`. Grows if needed. Single-pass
|
|
241
|
+
* analogue of `bulkAppendZeroes` for a non-zero default. */
|
|
242
|
+
bulkAppendValue(s, t) {
|
|
243
|
+
this.ensureCapacity(this._len + t), this._buf.fill(s, this._len, this._len + t), this._len += t;
|
|
244
|
+
}
|
|
245
|
+
_grow() {
|
|
246
|
+
const s = new this._ctor(this._buf.length * p);
|
|
247
|
+
s.set(this._buf), this._buf = s;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
class A extends u {
|
|
251
|
+
constructor(s = c) {
|
|
252
|
+
super(Float32Array, s);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
class S extends u {
|
|
256
|
+
constructor(s = c) {
|
|
257
|
+
super(Float64Array, s);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
class R extends u {
|
|
261
|
+
constructor(s = c) {
|
|
262
|
+
super(Int8Array, s);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
class T extends u {
|
|
266
|
+
constructor(s = c) {
|
|
267
|
+
super(Int16Array, s);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class E extends u {
|
|
271
|
+
constructor(s = c) {
|
|
272
|
+
super(Int32Array, s);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
class K extends u {
|
|
276
|
+
constructor(s = c) {
|
|
277
|
+
super(Uint8Array, s);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
class F extends u {
|
|
281
|
+
constructor(s = c) {
|
|
282
|
+
super(Uint16Array, s);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
class O extends u {
|
|
286
|
+
constructor(s = c) {
|
|
287
|
+
super(Uint32Array, s);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
class g {
|
|
291
|
+
_compare;
|
|
292
|
+
_data = [];
|
|
293
|
+
constructor(s) {
|
|
294
|
+
this._compare = s;
|
|
295
|
+
}
|
|
296
|
+
get size() {
|
|
297
|
+
return this._data.length;
|
|
298
|
+
}
|
|
299
|
+
/** Returns the highest-priority element without removing it, or undefined if empty. */
|
|
300
|
+
peek() {
|
|
301
|
+
return this._data[0];
|
|
302
|
+
}
|
|
303
|
+
/** Inserts a value and restores heap order by sifting up. O(log n). */
|
|
304
|
+
push(s) {
|
|
305
|
+
this._data.push(s), this._siftUp(this._data.length - 1);
|
|
306
|
+
}
|
|
307
|
+
/** Removes and returns the highest-priority element, or undefined if empty. O(log n). */
|
|
308
|
+
pop() {
|
|
309
|
+
const s = this._data;
|
|
310
|
+
if (s.length === 0) return;
|
|
311
|
+
const e = s[0], r = s.pop();
|
|
312
|
+
return s.length > 0 && (s[0] = r, this._siftDown(0)), e;
|
|
313
|
+
}
|
|
314
|
+
/** Removes all elements. O(1). */
|
|
315
|
+
clear() {
|
|
316
|
+
this._data.length = 0;
|
|
317
|
+
}
|
|
318
|
+
/** Moves a node up toward the root until heap order is restored. */
|
|
319
|
+
_siftUp(s) {
|
|
320
|
+
const t = this._data, e = this._compare, r = t[s];
|
|
321
|
+
for (; s > 0; ) {
|
|
322
|
+
const n = s - 1 >> 1;
|
|
323
|
+
if (e(r, t[n]) >= 0) break;
|
|
324
|
+
t[s] = t[n], s = n;
|
|
325
|
+
}
|
|
326
|
+
t[s] = r;
|
|
327
|
+
}
|
|
328
|
+
/** Moves a node down away from the root until heap order is restored. */
|
|
329
|
+
_siftDown(s) {
|
|
330
|
+
const t = this._data, e = this._compare, r = t.length, n = r >> 1, o = t[s];
|
|
331
|
+
for (; s < n; ) {
|
|
332
|
+
let l = (s << 1) + 1;
|
|
333
|
+
const i = l + 1;
|
|
334
|
+
if (i < r && e(t[i], t[l]) < 0 && (l = i), e(t[l], o) >= 0) break;
|
|
335
|
+
t[s] = t[l], s = l;
|
|
336
|
+
}
|
|
337
|
+
t[s] = o;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function W(h, s, t, e) {
|
|
341
|
+
const r = e ?? ((i) => String(i)), n = /* @__PURE__ */ new Map();
|
|
342
|
+
for (let i = 0; i < h.length; i++)
|
|
343
|
+
n.set(h[i], 0);
|
|
344
|
+
for (const [, i] of s)
|
|
345
|
+
for (let a = 0; a < i.length; a++) {
|
|
346
|
+
const _ = i[a];
|
|
347
|
+
n.has(_) && n.set(_, n.get(_) + 1);
|
|
348
|
+
}
|
|
349
|
+
const o = new g(t);
|
|
350
|
+
for (let i = 0; i < h.length; i++)
|
|
351
|
+
n.get(h[i]) === 0 && o.push(h[i]);
|
|
352
|
+
const l = [];
|
|
353
|
+
for (; o.size > 0; ) {
|
|
354
|
+
const i = o.pop();
|
|
355
|
+
l.push(i);
|
|
356
|
+
const a = s.get(i);
|
|
357
|
+
if (a !== void 0)
|
|
358
|
+
for (let _ = 0; _ < a.length; _++) {
|
|
359
|
+
const d = a[_];
|
|
360
|
+
if (!n.has(d)) continue;
|
|
361
|
+
const w = n.get(d) - 1;
|
|
362
|
+
n.set(d, w), w === 0 && o.push(d);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (l.length !== h.length) {
|
|
366
|
+
const i = [];
|
|
367
|
+
for (const [a, _] of n)
|
|
368
|
+
_ > 0 && i.push(r(a));
|
|
369
|
+
throw new globalThis.TypeError(
|
|
370
|
+
`Cycle detected in topological sort. Nodes still pending: ${i.join(", ")}`
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
return l;
|
|
374
|
+
}
|
|
375
|
+
export {
|
|
376
|
+
f as B,
|
|
377
|
+
u as G,
|
|
378
|
+
I as S,
|
|
379
|
+
A as a,
|
|
380
|
+
S as b,
|
|
381
|
+
R as c,
|
|
382
|
+
T as d,
|
|
383
|
+
E as e,
|
|
384
|
+
K as f,
|
|
385
|
+
F as g,
|
|
386
|
+
O as h,
|
|
387
|
+
g as i,
|
|
388
|
+
b as j,
|
|
389
|
+
y as k,
|
|
390
|
+
W as t
|
|
391
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class d{_words;constructor(t){this._words=t??new Array(4).fill(0)}has(t){const s=t>>>5;return s>=this._words.length?!1:(this._words[s]&1<<(t&31))!==0}set(t){const s=t>>>5;s>=this._words.length&&this.grow(s+1),this._words[s]|=1<<(t&31)}clear(t){const s=t>>>5;s>=this._words.length||(this._words[s]&=~(1<<(t&31)))}isEmpty(){const t=this._words;for(let s=0;s<t.length;s++)if(t[s]!==0)return!1;return!0}overlaps(t){const s=this._words,e=t._words,n=s.length<e.length?s.length:e.length;for(let r=0;r<n;r++)if((s[r]&e[r])!==0)return!0;return!1}contains(t){const s=t._words,e=this._words,n=e.length;for(let r=0;r<s.length;r++){const o=s[r];if(o!==0&&(r>=n||(e[r]&o)!==o))return!1}return!0}equals(t){const s=this._words,e=t._words,n=s.length>e.length?s.length:e.length;for(let r=0;r<n;r++){const o=r<s.length?s[r]:0,h=r<e.length?e[r]:0;if(o!==h)return!1}return!0}copy(){return new d(this._words.slice())}copyInto(t){const s=this._words,e=t._words,n=s.length,r=e.length;if(r>=n){for(let o=0;o<n;o++)e[o]=s[o];for(let o=n;o<r;o++)e[o]=0}else{let o=r>0?r:1;for(;o<n;)o*=2;const h=new Array(o).fill(0);for(let i=0;i<n;i++)h[i]=s[i];t._words=h}return t}copyWithSet(t){const s=t>>>5,e=s+1,n=this._words.length>e?this._words.length:e,r=new Array(n).fill(0);for(let o=0;o<this._words.length;o++)r[o]=this._words[o];return r[s]|=1<<(t&31),new d(r)}copyWithClear(t){const s=this._words.slice(),e=t>>>5;return e<s.length&&(s[e]&=~(1<<(t&31))),new d(s)}hash(){let t=2166136261;const s=this._words;let e=s.length-1;for(;e>=0&&s[e]===0;)e--;for(let n=0;n<=e;n++)t^=s[n],t=Math.imul(t,16777619);return t}forEach(t){const s=this._words;for(let e=0;e<s.length;e++){let n=s[e];if(n===0)continue;const r=e<<5;for(;n!==0;){const o=n&-n>>>0,h=31-Math.clz32(o);t(r+h),n^=o}}}grow(t){let s=this._words.length;for(;s<t;)s*=2;const e=new Array(s).fill(0);for(let n=0;n<this._words.length;n++)e[n]=this._words[n];this._words=e}}class y{_denseKeys=[];_denseVals=[];_sparse=[];get size(){return this._denseKeys.length}get keys(){return this._denseKeys}has(t){return this._denseKeys[this._sparse[t]]===t}get(t){return this.has(t)?this._denseVals[this._sparse[t]]:void 0}set(t,s){if(this.has(t)){this._denseVals[this._sparse[t]]=s;return}this._sparse[t]=this._denseKeys.length,this._denseKeys.push(t),this._denseVals.push(s)}delete(t){if(!this.has(t))return!1;const s=this._sparse[t],e=this._denseKeys[this._denseKeys.length-1];return this._denseKeys[s]=e,this._denseVals[s]=this._denseVals[this._denseVals.length-1],this._sparse[e]=s,this._denseKeys.pop(),this._denseVals.pop(),!0}clear(){this._denseKeys.length=0,this._denseVals.length=0,this._sparse.length=0}forEach(t){for(let s=0;s<this._denseKeys.length;s++)t(this._denseKeys[s],this._denseVals[s])}[Symbol.iterator](){let t=0;const s=this._denseKeys,e=this._denseVals;return{next(){return t<s.length?{value:[s[t],e[t++]],done:!1}:{value:void 0,done:!0}}}}}const u=16,p=2;class c{constructor(t,s=16){this._ctor=t,this._buf=new t(s)}_buf;_len=0;get length(){return this._len}push(t){this._len>=this._buf.length&&this._grow(),this._buf[this._len++]=t}pop(){return this._buf[--this._len]}get(t){return this._buf[t]}setAt(t,s){this._buf[t]=s}swapRemove(t){const s=this._buf[t];return this._buf[t]=this._buf[--this._len],s}clear(){this._len=0}setLength(t){this.ensureCapacity(t),this._len=t}get buf(){return this._buf}view(){return this._buf.subarray(0,this._len)}[Symbol.iterator](){let t=0;const s=this._buf,e=this._len;return{next(){return t<e?{value:s[t++],done:!1}:{value:0,done:!0}}}}ensureCapacity(t){if(t<=this._buf.length)return;let s=this._buf.length||1;for(;s<t;)s*=p;const e=new this._ctor(s);e.set(this._buf.subarray(0,this._len)),this._buf=e}bulkAppend(t,s,e){this.ensureCapacity(this._len+e),this._buf.set(t.subarray(s,s+e),this._len),this._len+=e}bulkAppendZeroes(t){this.ensureCapacity(this._len+t),this._buf.fill(0,this._len,this._len+t),this._len+=t}bulkAppendValue(t,s){this.ensureCapacity(this._len+s),this._buf.fill(t,this._len,this._len+s),this._len+=s}_grow(){const t=new this._ctor(this._buf.length*p);t.set(this._buf),this._buf=t}}class I extends c{constructor(t=u){super(Float32Array,t)}}class b extends c{constructor(t=u){super(Float64Array,t)}}class A extends c{constructor(t=u){super(Int8Array,t)}}class S extends c{constructor(t=u){super(Int16Array,t)}}class R extends c{constructor(t=u){super(Int32Array,t)}}class T extends c{constructor(t=u){super(Uint8Array,t)}}class E extends c{constructor(t=u){super(Uint16Array,t)}}class F extends c{constructor(t=u){super(Uint32Array,t)}}class g{_compare;_data=[];constructor(t){this._compare=t}get size(){return this._data.length}peek(){return this._data[0]}push(t){this._data.push(t),this._siftUp(this._data.length-1)}pop(){const t=this._data;if(t.length===0)return;const e=t[0],n=t.pop();return t.length>0&&(t[0]=n,this._siftDown(0)),e}clear(){this._data.length=0}_siftUp(t){const s=this._data,e=this._compare,n=s[t];for(;t>0;){const r=t-1>>1;if(e(n,s[r])>=0)break;s[t]=s[r],t=r}s[t]=n}_siftDown(t){const s=this._data,e=this._compare,n=s.length,r=n>>1,o=s[t];for(;t<r;){let h=(t<<1)+1;const i=h+1;if(i<n&&e(s[i],s[h])<0&&(h=i),e(s[h],o)>=0)break;s[t]=s[h],t=h}s[t]=o}}function O(l,t,s,e){const n=e??(i=>String(i)),r=new Map;for(let i=0;i<l.length;i++)r.set(l[i],0);for(const[,i]of t)for(let a=0;a<i.length;a++){const _=i[a];r.has(_)&&r.set(_,r.get(_)+1)}const o=new g(s);for(let i=0;i<l.length;i++)r.get(l[i])===0&&o.push(l[i]);const h=[];for(;o.size>0;){const i=o.pop();h.push(i);const a=t.get(i);if(a!==void 0)for(let _=0;_<a.length;_++){const f=a[_];if(!r.has(f))continue;const w=r.get(f)-1;r.set(f,w),w===0&&o.push(f)}}if(h.length!==l.length){const i=[];for(const[a,_]of r)_>0&&i.push(n(a));throw new globalThis.TypeError(`Cycle detected in topological sort. Nodes still pending: ${i.join(", ")}`)}return h}exports.BITS_PER_WORD_MASK=31;exports.BITS_PER_WORD_SHIFT=5;exports.BinaryHeap=g;exports.BitSet=d;exports.GrowableFloat32Array=I;exports.GrowableFloat64Array=b;exports.GrowableInt16Array=S;exports.GrowableInt32Array=R;exports.GrowableInt8Array=A;exports.GrowableTypedArray=c;exports.GrowableUint16Array=E;exports.GrowableUint32Array=F;exports.GrowableUint8Array=T;exports.SparseMap=y;exports.topologicalSort=O;
|
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
* Assertions — Dev-only runtime validation and branded casting.
|
|
3
3
|
*
|
|
4
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).
|
|
8
8
|
*
|
|
9
9
|
***/
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
20
|
//# 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;AAIL,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../src/type_primitives/assertions.ts"],"names":[],"mappings":"AAAA;;;;;;;;KAQK;AAIL,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"}
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
*
|
|
13
13
|
***/
|
|
14
14
|
export type CompareFn<T> = (a: T, b: T) => number;
|
|
15
|
+
/**
|
|
16
|
+
* Generic array-backed binary heap with configurable comparator.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
15
19
|
export declare class BinaryHeap<T> {
|
|
16
20
|
private readonly _compare;
|
|
17
21
|
private readonly _data;
|
|
@@ -26,8 +30,8 @@ export declare class BinaryHeap<T> {
|
|
|
26
30
|
/** Removes all elements. O(1). */
|
|
27
31
|
clear(): void;
|
|
28
32
|
/** Moves a node up toward the root until heap order is restored. */
|
|
29
|
-
private
|
|
33
|
+
private _siftUp;
|
|
30
34
|
/** Moves a node down away from the root until heap order is restored. */
|
|
31
|
-
private
|
|
35
|
+
private _siftDown;
|
|
32
36
|
}
|
|
33
37
|
//# sourceMappingURL=binary_heap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary_heap.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/binary_heap/binary_heap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;KAYK;AAEL,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAElD,qBAAa,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"binary_heap.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/binary_heap/binary_heap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;KAYK;AAEL,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAElD;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;gBAErB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAIjC,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,uFAAuF;IAChF,IAAI,IAAI,CAAC,GAAG,SAAS;IAI5B,uEAAuE;IAChE,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAK3B,yFAAyF;IAClF,GAAG,IAAI,CAAC,GAAG,SAAS;IAc3B,kCAAkC;IAC3B,KAAK,IAAI,IAAI;IAIpB,oEAAoE;IACpE,OAAO,CAAC,OAAO;IAcf,yEAAyE;IACzE,OAAO,CAAC,SAAS;CAsBjB"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* words = ceil(maxComponentId / 32).
|
|
8
8
|
*
|
|
9
9
|
* Bit layout within each 32-bit word:
|
|
10
|
-
*
|
|
10
|
+
* wordIndex = bit >>> BITS_PER_WORD_SHIFT (divide by 32)
|
|
11
11
|
* bit_offset = bit & BITS_PER_WORD_MASK (mod 32)
|
|
12
12
|
* test: word & (1 << offset)
|
|
13
13
|
* set: word |= (1 << offset)
|
|
@@ -19,24 +19,36 @@ export declare const BITS_PER_WORD_SHIFT = 5;
|
|
|
19
19
|
export declare const BITS_PER_WORD_MASK = 31;
|
|
20
20
|
export declare const FNV_OFFSET_BASIS = 2166136261;
|
|
21
21
|
export declare const FNV_PRIME = 16777619;
|
|
22
|
+
/**
|
|
23
|
+
* number[]-backed bit set with auto-grow. Used as the archetype component signature.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
22
26
|
export declare class BitSet {
|
|
23
27
|
_words: number[];
|
|
24
28
|
constructor(words?: number[]);
|
|
25
29
|
has(bit: number): boolean;
|
|
26
30
|
set(bit: number): void;
|
|
27
31
|
clear(bit: number): void;
|
|
32
|
+
/** True if no bit is set. */
|
|
33
|
+
isEmpty(): boolean;
|
|
28
34
|
/** True if any bit is set in both this and other (non-empty intersection). */
|
|
29
35
|
overlaps(other: BitSet): boolean;
|
|
30
36
|
/** True if this is a superset of other (all bits in other are set in this). */
|
|
31
37
|
contains(other: BitSet): boolean;
|
|
32
38
|
equals(other: BitSet): boolean;
|
|
33
39
|
copy(): BitSet;
|
|
34
|
-
|
|
35
|
-
|
|
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;
|
|
36
48
|
/** FNV-1a hash. Skips trailing zero words so differently-sized arrays with the same bits hash equally. */
|
|
37
49
|
hash(): number;
|
|
38
50
|
/** Iterate all set bits via lowest-set-bit extraction. */
|
|
39
|
-
|
|
51
|
+
forEach(fn: (bit: number) => void): void;
|
|
40
52
|
private grow;
|
|
41
53
|
}
|
|
42
54
|
//# sourceMappingURL=bitset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitset.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/bitset/bitset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;KAeK;AAGL,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAGrC,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,SAAS,WAAa,CAAC;AAIpC,qBAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"bitset.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/bitset/bitset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;KAeK;AAGL,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAGrC,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,SAAS,WAAa,CAAC;AAIpC;;;GAGG;AACH,qBAAa,MAAM;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEZ,KAAK,CAAC,EAAE,MAAM,EAAE;IAIrB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAMzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMtB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAM/B,6BAA6B;IACtB,OAAO,IAAI,OAAO;IAQzB,8EAA8E;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAUvC,+EAA+E;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAehC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAa9B,IAAI,IAAI,MAAM;IAIrB;;;;6DAIyD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAoBhC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAUhC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IASzC,0GAA0G;IACnG,IAAI,IAAI,MAAM;IAarB,0DAA0D;IACnD,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAmB/C,OAAO,CAAC,IAAI;CAOZ"}
|
|
@@ -6,11 +6,16 @@
|
|
|
6
6
|
* accidental assignment between structurally identical types.
|
|
7
7
|
*
|
|
8
8
|
* Example: EntityID and ComponentID are both numbers at runtime, but
|
|
9
|
-
* Brand<number, "
|
|
9
|
+
* Brand<number, "entityId"> and Brand<number, "component_id"> are
|
|
10
10
|
* incompatible at compile time.
|
|
11
11
|
*
|
|
12
12
|
***/
|
|
13
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
|
+
*/
|
|
14
19
|
export type Brand<T, BrandName extends string> = T & {
|
|
15
20
|
readonly [brand]: BrandName;
|
|
16
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/type_primitives/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;KAWK;AAEL,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AAEnC,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS,SAAS,MAAM,IAAI,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/type_primitives/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;KAWK;AAEL,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AAEnC;;;;GAIG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS,SAAS,MAAM,IAAI,CAAC,GAAG;IACpD,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC5B,CAAC"}
|
|
@@ -4,6 +4,10 @@ export declare enum TYPE_ERROR {
|
|
|
4
4
|
VALIDATION_FAIL_CONDITION = "VALIDATION_FAIL_CONDITION",
|
|
5
5
|
ASSERTION_FAIL_NON_NULLABLE = "ASSERTION_FAIL_NON_NULLABLE"
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Error class thrown by std's runtime assertions. Non-operational.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
7
11
|
export declare class TypeError extends AppError {
|
|
8
12
|
readonly category: TYPE_ERROR;
|
|
9
13
|
constructor(category: TYPE_ERROR, message: string, context?: Record<string, unknown>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/type_primitives/error.ts"],"names":[],"mappings":"AAAA;;;;;;KAMK;AAEL,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,oBAAY,UAAU;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/type_primitives/error.ts"],"names":[],"mappings":"AAAA;;;;;;KAMK;AAEL,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,oBAAY,UAAU;IACrB,wBAAwB,6BAA6B;IACrD,yBAAyB,8BAA8B;IACvD,2BAA2B,gCAAgC;CAC3D;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,QAAQ;aAErB,QAAQ,EAAE,UAAU;gBAApB,QAAQ,EAAE,UAAU,EACpC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAIlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/type_primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/type_primitives/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC"}
|
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
* so stale sparse entries are harmless. Deletion uses swap-and-pop.
|
|
10
10
|
*
|
|
11
11
|
***/
|
|
12
|
+
/**
|
|
13
|
+
* O(1) integer-keyed map with cache-friendly dense iteration.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
12
16
|
export declare class SparseMap<V> {
|
|
13
|
-
private
|
|
14
|
-
private
|
|
17
|
+
private _denseKeys;
|
|
18
|
+
private _denseVals;
|
|
15
19
|
private _sparse;
|
|
16
20
|
get size(): number;
|
|
17
21
|
get keys(): readonly number[];
|
|
@@ -20,7 +24,7 @@ export declare class SparseMap<V> {
|
|
|
20
24
|
set(key: number, value: V): void;
|
|
21
25
|
delete(key: number): boolean;
|
|
22
26
|
clear(): void;
|
|
23
|
-
|
|
27
|
+
forEach(fn: (key: number, value: V) => void): void;
|
|
24
28
|
[Symbol.iterator](): Iterator<[number, V]>;
|
|
25
29
|
}
|
|
26
30
|
//# sourceMappingURL=sparse_map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparse_map.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/sparse_map/sparse_map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;KAUK;AAEL,qBAAa,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"sparse_map.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/sparse_map/sparse_map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;KAUK;AAEL;;;GAGG;AACH,qBAAa,SAAS,CAAC,CAAC;IACvB,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,OAAO,CAAgB;IAE/B,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,IAAI,SAAS,MAAM,EAAE,CAEnC;IAEM,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAUhC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAa5B,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAMzD,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAe1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparse_set.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/sparse_set/sparse_set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;KAWK;AAEL,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"sparse_set.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/sparse_set/sparse_set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;KAWK;AAEL;;;GAGG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,OAAO,CAAgB;IAE/B,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,MAAM,IAAI,SAAS,MAAM,EAAE,CAErC;IAEM,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMtB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAW5B,KAAK,IAAI,IAAI;IAKpB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC;CAGrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/***
|
|
2
|
-
*
|
|
2
|
+
* topologicalSort — Kahn's algorithm with a BinaryHeap ready queue.
|
|
3
3
|
*
|
|
4
4
|
* Accepts an arbitrary node set, a dependency edge map, and a tiebreaker
|
|
5
5
|
* comparator used to order nodes that are simultaneously ready (zero in-degree).
|
|
@@ -17,9 +17,13 @@
|
|
|
17
17
|
* @param nodes - All items to sort.
|
|
18
18
|
* @param edges - Adjacency list: `edges.get(a)` = items that must come after `a`.
|
|
19
19
|
* @param tiebreaker - Comparator for the ready queue (min-heap semantics: lower = higher priority).
|
|
20
|
-
* @param
|
|
20
|
+
* @param nodeName - Optional label function for cycle error messages. Defaults to `String(node)`.
|
|
21
21
|
* @returns Sorted array in topological order.
|
|
22
22
|
* @throws {TypeError} If a cycle is detected among the nodes.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Topologically sorts `nodes` respecting dependency edges, breaking ties with the comparator.
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export declare function topologicalSort<T>(nodes: readonly T[], edges: Map<T, T[]>, tiebreaker: (a: T, b: T) => number, nodeName?: (node: T) => string): T[];
|
|
25
29
|
//# sourceMappingURL=topological_sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topological_sort.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/topological_sort/topological_sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;KAWK;AAIL;;;;;;;;;;GAUG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"topological_sort.d.ts","sourceRoot":"","sources":["../../../src/type_primitives/topological_sort/topological_sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;KAWK;AAIL;;;;;;;;;;GAUG;AACH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAChC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAClB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,EAClC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAC5B,CAAC,EAAE,CA8DL"}
|