@adobe/data 0.9.60 → 0.9.62
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/dist/ecs/archetype/archetype.d.ts +9 -2
- package/dist/ecs/archetype/archetype.js.map +1 -1
- package/dist/ecs/archetype/create-archetype.js +5 -2
- package/dist/ecs/archetype/create-archetype.js.map +1 -1
- package/dist/ecs/database/combine-plugins.d.ts +5 -1
- package/dist/ecs/database/combine-plugins.js +3 -3
- package/dist/ecs/database/combine-plugins.js.map +1 -1
- package/dist/ecs/database/concurrency/concurrency-strategy.d.ts +86 -0
- package/dist/ecs/database/concurrency/concurrency-strategy.js +3 -0
- package/dist/ecs/database/concurrency/concurrency-strategy.js.map +1 -0
- package/dist/ecs/database/concurrency/immediate-concurrency.d.ts +22 -0
- package/dist/ecs/database/concurrency/immediate-concurrency.js +74 -0
- package/dist/ecs/database/concurrency/immediate-concurrency.js.map +1 -0
- package/dist/ecs/database/concurrency/index.d.ts +4 -0
- package/dist/ecs/database/concurrency/index.js +5 -0
- package/dist/ecs/database/concurrency/index.js.map +1 -0
- package/dist/ecs/database/concurrency/rebase-replay-concurrency.d.ts +20 -0
- package/dist/ecs/database/concurrency/rebase-replay-concurrency.js +34 -0
- package/dist/ecs/database/concurrency/rebase-replay-concurrency.js.map +1 -0
- package/dist/ecs/database/concurrency/roll-forward-concurrency.d.ts +33 -0
- package/dist/ecs/database/concurrency/roll-forward-concurrency.js +115 -0
- package/dist/ecs/database/concurrency/roll-forward-concurrency.js.map +1 -0
- package/dist/ecs/database/concurrency/roll-forward-concurrency.test.d.ts +1 -0
- package/dist/ecs/database/concurrency/roll-forward-concurrency.test.js +136 -0
- package/dist/ecs/database/concurrency/roll-forward-concurrency.test.js.map +1 -0
- package/dist/ecs/database/create-plugin.d.ts +17 -14
- package/dist/ecs/database/create-plugin.js +2 -1
- package/dist/ecs/database/create-plugin.js.map +1 -1
- package/dist/ecs/database/database.d.ts +61 -11
- package/dist/ecs/database/database.index.performance.test.d.ts +1 -0
- package/dist/ecs/database/database.index.performance.test.js +417 -0
- package/dist/ecs/database/database.index.performance.test.js.map +1 -0
- package/dist/ecs/database/database.index.test.d.ts +1 -0
- package/dist/ecs/database/database.index.test.js +1142 -0
- package/dist/ecs/database/database.index.test.js.map +1 -0
- package/dist/ecs/database/database.index.type-test.d.ts +1 -0
- package/dist/ecs/database/database.index.type-test.js +275 -0
- package/dist/ecs/database/database.index.type-test.js.map +1 -0
- package/dist/ecs/database/database.js.map +1 -1
- package/dist/ecs/database/database.reset.test.js +2 -1
- package/dist/ecs/database/database.reset.test.js.map +1 -1
- package/dist/ecs/database/deep-extends-chain.type-test.d.ts +256 -256
- package/dist/ecs/database/index-api-proof.type-test.d.ts +1 -0
- package/dist/ecs/database/index-api-proof.type-test.js +88 -0
- package/dist/ecs/database/index-api-proof.type-test.js.map +1 -0
- package/dist/ecs/database/index-registry/create-index-registry.d.ts +53 -0
- package/dist/ecs/database/index-registry/create-index-registry.js +174 -0
- package/dist/ecs/database/index-registry/create-index-registry.js.map +1 -0
- package/dist/ecs/database/index-registry/create-index.d.ts +60 -0
- package/dist/ecs/database/index-registry/create-index.js +539 -0
- package/dist/ecs/database/index-registry/create-index.js.map +1 -0
- package/dist/ecs/database/index-registry/index.d.ts +4 -0
- package/dist/ecs/database/index-registry/index.js +4 -0
- package/dist/ecs/database/index-registry/index.js.map +1 -0
- package/dist/ecs/database/index.d.ts +1 -0
- package/dist/ecs/database/index.js +1 -0
- package/dist/ecs/database/index.js.map +1 -1
- package/dist/ecs/database/observe-index-entities.d.ts +26 -0
- package/dist/ecs/database/observe-index-entities.js +66 -0
- package/dist/ecs/database/observe-index-entities.js.map +1 -0
- package/dist/ecs/database/observed/create-observed-database.js +1 -1
- package/dist/ecs/database/observed/create-observed-database.js.map +1 -1
- package/dist/ecs/database/observed/observed-database.d.ts +1 -1
- package/dist/ecs/database/public/create-database.d.ts +12 -27
- package/dist/ecs/database/public/create-database.js +252 -10
- package/dist/ecs/database/public/create-database.js.map +1 -1
- package/dist/ecs/database/public/create-database.test.js +8 -7
- package/dist/ecs/database/public/create-database.test.js.map +1 -1
- package/dist/ecs/database/public/create-transaction-dispatcher.d.ts +4 -2
- package/dist/ecs/database/public/create-transaction-dispatcher.js +2 -8
- package/dist/ecs/database/public/create-transaction-dispatcher.js.map +1 -1
- package/dist/ecs/database/reconciling/create-rebase-replay-applier.d.ts +26 -0
- package/dist/ecs/database/reconciling/create-rebase-replay-applier.js +121 -0
- package/dist/ecs/database/reconciling/create-rebase-replay-applier.js.map +1 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.d.ts +11 -0
- package/dist/ecs/database/reconciling/create-reconciling-database.js +28 -137
- package/dist/ecs/database/reconciling/create-reconciling-database.js.map +1 -1
- package/dist/ecs/database/transactional-store/create-transactional-store.js.map +1 -1
- package/dist/ecs/database/transactional-store/transactional-store.d.ts +4 -3
- package/dist/ecs/entity-location-table/create-entity-location-table.js +2 -2
- package/dist/ecs/entity-location-table/create-entity-location-table.js.map +1 -1
- package/dist/ecs/entity-location-table/entity-location-table.d.ts +7 -1
- package/dist/ecs/plugins/scheduler/scheduler.d.ts +1 -0
- package/dist/ecs/store/core/core.d.ts +7 -1
- package/dist/ecs/store/core/create-core.js +3 -3
- package/dist/ecs/store/core/create-core.js.map +1 -1
- package/dist/ecs/store/index-types.d.ts +142 -0
- package/dist/ecs/store/index-types.js +3 -0
- package/dist/ecs/store/index-types.js.map +1 -0
- package/dist/ecs/store/public/create-store.js +206 -4
- package/dist/ecs/store/public/create-store.js.map +1 -1
- package/dist/ecs/store/public/create-store.test.js +25 -0
- package/dist/ecs/store/public/create-store.test.js.map +1 -1
- package/dist/ecs/store/store.d.ts +38 -14
- package/dist/ecs/store/store.js +5 -4
- package/dist/ecs/store/store.js.map +1 -1
- package/dist/ecs/store/transaction-functions.d.ts +4 -3
- package/dist/schema/fractional-index/between-n.d.ts +2 -0
- package/dist/schema/fractional-index/between-n.js +34 -0
- package/dist/schema/fractional-index/between-n.js.map +1 -0
- package/dist/schema/fractional-index/between-n.test.d.ts +1 -0
- package/dist/schema/fractional-index/between-n.test.js +36 -0
- package/dist/schema/fractional-index/between-n.test.js.map +1 -0
- package/dist/schema/fractional-index/between.d.ts +2 -0
- package/dist/schema/fractional-index/between.js +3 -0
- package/dist/schema/fractional-index/between.js.map +1 -0
- package/dist/schema/fractional-index/between.test.d.ts +1 -0
- package/dist/schema/fractional-index/between.test.js +68 -0
- package/dist/schema/fractional-index/between.test.js.map +1 -0
- package/dist/schema/fractional-index/decrement-integer.d.ts +1 -0
- package/dist/schema/fractional-index/decrement-integer.js +32 -0
- package/dist/schema/fractional-index/decrement-integer.js.map +1 -0
- package/dist/schema/fractional-index/decrement-integer.test.d.ts +1 -0
- package/dist/schema/fractional-index/decrement-integer.test.js +31 -0
- package/dist/schema/fractional-index/decrement-integer.test.js.map +1 -0
- package/dist/schema/fractional-index/digits.d.ts +1 -0
- package/dist/schema/fractional-index/digits.js +3 -0
- package/dist/schema/fractional-index/digits.js.map +1 -0
- package/dist/schema/fractional-index/fractional-index.d.ts +4 -0
- package/dist/schema/fractional-index/fractional-index.js +2 -0
- package/dist/schema/fractional-index/fractional-index.js.map +1 -0
- package/dist/schema/fractional-index/increment-integer.d.ts +1 -0
- package/dist/schema/fractional-index/increment-integer.js +32 -0
- package/dist/schema/fractional-index/increment-integer.js.map +1 -0
- package/dist/schema/fractional-index/increment-integer.test.d.ts +1 -0
- package/dist/schema/fractional-index/increment-integer.test.js +34 -0
- package/dist/schema/fractional-index/increment-integer.test.js.map +1 -0
- package/dist/schema/fractional-index/initial.d.ts +2 -0
- package/dist/schema/fractional-index/initial.js +2 -0
- package/dist/schema/fractional-index/initial.js.map +1 -0
- package/dist/schema/fractional-index/integer-length.d.ts +1 -0
- package/dist/schema/fractional-index/integer-length.js +9 -0
- package/dist/schema/fractional-index/integer-length.js.map +1 -0
- package/dist/schema/fractional-index/integer-part.d.ts +1 -0
- package/dist/schema/fractional-index/integer-part.js +9 -0
- package/dist/schema/fractional-index/integer-part.js.map +1 -0
- package/dist/schema/fractional-index/key-between.d.ts +2 -0
- package/dist/schema/fractional-index/key-between.js +39 -0
- package/dist/schema/fractional-index/key-between.js.map +1 -0
- package/dist/schema/fractional-index/midpoint.d.ts +1 -0
- package/dist/schema/fractional-index/midpoint.js +23 -0
- package/dist/schema/fractional-index/midpoint.js.map +1 -0
- package/dist/schema/fractional-index/midpoint.test.d.ts +1 -0
- package/dist/schema/fractional-index/midpoint.test.js +83 -0
- package/dist/schema/fractional-index/midpoint.test.js.map +1 -0
- package/dist/schema/fractional-index/public.d.ts +4 -0
- package/dist/schema/fractional-index/public.js +6 -0
- package/dist/schema/fractional-index/public.js.map +1 -0
- package/dist/schema/fractional-index/schema.d.ts +4 -0
- package/dist/schema/fractional-index/schema.js +5 -0
- package/dist/schema/fractional-index/schema.js.map +1 -0
- package/dist/schema/fractional-index/smallest-integer.d.ts +1 -0
- package/dist/schema/fractional-index/smallest-integer.js +3 -0
- package/dist/schema/fractional-index/smallest-integer.js.map +1 -0
- package/dist/schema/fractional-index/validate-integer.d.ts +1 -0
- package/dist/schema/fractional-index/validate-integer.js +7 -0
- package/dist/schema/fractional-index/validate-integer.js.map +1 -0
- package/dist/schema/fractional-index/validate-order-key.d.ts +1 -0
- package/dist/schema/fractional-index/validate-order-key.js +11 -0
- package/dist/schema/fractional-index/validate-order-key.js.map +1 -0
- package/dist/schema/guid/create.d.ts +2 -0
- package/dist/schema/guid/create.js +10 -0
- package/dist/schema/guid/create.js.map +1 -0
- package/dist/schema/guid/create.test.d.ts +1 -0
- package/dist/schema/guid/create.test.js +39 -0
- package/dist/schema/guid/create.test.js.map +1 -0
- package/dist/schema/guid/equals.d.ts +2 -0
- package/dist/schema/guid/equals.js +3 -0
- package/dist/schema/guid/equals.js.map +1 -0
- package/dist/schema/guid/equals.test.d.ts +1 -0
- package/dist/schema/guid/equals.test.js +30 -0
- package/dist/schema/guid/equals.test.js.map +1 -0
- package/dist/schema/guid/from-uuid.d.ts +2 -0
- package/dist/schema/guid/from-uuid.js +15 -0
- package/dist/schema/guid/from-uuid.js.map +1 -0
- package/dist/schema/guid/from-uuid.test.d.ts +1 -0
- package/dist/schema/guid/from-uuid.test.js +39 -0
- package/dist/schema/guid/from-uuid.test.js.map +1 -0
- package/dist/schema/guid/guid.performance.test.d.ts +1 -0
- package/dist/schema/guid/guid.performance.test.js +297 -0
- package/dist/schema/guid/guid.performance.test.js.map +1 -0
- package/dist/schema/guid/index.d.ts +4 -0
- package/dist/schema/guid/index.js +3 -0
- package/dist/schema/guid/index.js.map +1 -0
- package/dist/schema/guid/layout.d.ts +1 -0
- package/dist/schema/guid/layout.js +5 -0
- package/dist/schema/guid/layout.js.map +1 -0
- package/dist/schema/guid/nil.d.ts +2 -0
- package/dist/schema/guid/nil.js +3 -0
- package/dist/schema/guid/nil.js.map +1 -0
- package/dist/schema/guid/public.d.ts +8 -0
- package/dist/schema/guid/public.js +10 -0
- package/dist/schema/guid/public.js.map +1 -0
- package/dist/schema/guid/schema.d.ts +12 -0
- package/dist/schema/guid/schema.js +10 -0
- package/dist/schema/guid/schema.js.map +1 -0
- package/dist/schema/guid/schema.test.d.ts +1 -0
- package/dist/schema/guid/schema.test.js +35 -0
- package/dist/schema/guid/schema.test.js.map +1 -0
- package/dist/schema/guid/to-unserializable-key.d.ts +2 -0
- package/dist/schema/guid/to-unserializable-key.js +10 -0
- package/dist/schema/guid/to-unserializable-key.js.map +1 -0
- package/dist/schema/guid/to-uuid.d.ts +2 -0
- package/dist/schema/guid/to-uuid.js +15 -0
- package/dist/schema/guid/to-uuid.js.map +1 -0
- package/dist/schema/guid/to-uuid.test.d.ts +1 -0
- package/dist/schema/guid/to-uuid.test.js +31 -0
- package/dist/schema/guid/to-uuid.test.js.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/table/select-rows.d.ts +7 -4
- package/dist/table/select-rows.js.map +1 -1
- package/dist/test-setup.js +2 -2
- package/dist/test-setup.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/references/data-lit/package.json +1 -1
- package/references/data-lit-tictactoe/package.json +1 -1
- package/references/data-react/package.json +1 -1
- package/references/data-react-hello/package.json +1 -1
- package/references/data-react-pixie/package.json +1 -1
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Key serialization
|
|
4
|
+
// ============================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Stable string serialization for a bucket key. Objects are key-sorted
|
|
7
|
+
* so `{a, b}` and `{b, a}` produce the same key. Used for the Map<string,
|
|
8
|
+
* Entity[]> bucket store.
|
|
9
|
+
*/
|
|
10
|
+
const serializeKey = (value) => {
|
|
11
|
+
if (value === null || typeof value !== "object") {
|
|
12
|
+
return JSON.stringify(value);
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return `[${value.map(serializeKey).join(",")}]`;
|
|
16
|
+
}
|
|
17
|
+
const keys = Object.keys(value).sort();
|
|
18
|
+
let out = "{";
|
|
19
|
+
for (let i = 0; i < keys.length; i++) {
|
|
20
|
+
if (i > 0)
|
|
21
|
+
out += ",";
|
|
22
|
+
const k = keys[i];
|
|
23
|
+
out += JSON.stringify(k) + ":" + serializeKey(value[k]);
|
|
24
|
+
}
|
|
25
|
+
out += "}";
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Fan-out: given a single raw key value (scalar / array / object with
|
|
30
|
+
* possibly-array slots), produce every bucket key value the entity should
|
|
31
|
+
* be filed under. Array at top level → one entry per element. Object
|
|
32
|
+
* with array-valued slots → cartesian product across them.
|
|
33
|
+
*/
|
|
34
|
+
const expandBucketKeys = (keyValue) => {
|
|
35
|
+
if (Array.isArray(keyValue))
|
|
36
|
+
return keyValue.length === 0 ? [] : keyValue;
|
|
37
|
+
if (keyValue !== null && typeof keyValue === "object") {
|
|
38
|
+
const entries = Object.entries(keyValue);
|
|
39
|
+
let acc = [{}];
|
|
40
|
+
for (const [k, v] of entries) {
|
|
41
|
+
const choices = Array.isArray(v) ? v : [v];
|
|
42
|
+
if (choices.length === 0)
|
|
43
|
+
return [];
|
|
44
|
+
const next = [];
|
|
45
|
+
for (const partial of acc) {
|
|
46
|
+
for (const choice of choices) {
|
|
47
|
+
next.push({ ...partial, [k]: choice });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
acc = next;
|
|
51
|
+
}
|
|
52
|
+
return acc;
|
|
53
|
+
}
|
|
54
|
+
return [keyValue];
|
|
55
|
+
};
|
|
56
|
+
const normalizeKey = (keyDecl, extraComponents) => {
|
|
57
|
+
// Bare column name
|
|
58
|
+
if (typeof keyDecl === "string") {
|
|
59
|
+
return {
|
|
60
|
+
readColumns: [keyDecl],
|
|
61
|
+
extractFromEntity: (values) => {
|
|
62
|
+
const v = values[keyDecl];
|
|
63
|
+
return v === undefined ? null : v;
|
|
64
|
+
},
|
|
65
|
+
extractFromLookup: (arg) => arg,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// String tuple
|
|
69
|
+
if (Array.isArray(keyDecl)) {
|
|
70
|
+
const cols = keyDecl;
|
|
71
|
+
return {
|
|
72
|
+
readColumns: cols,
|
|
73
|
+
extractFromEntity: (values) => {
|
|
74
|
+
const out = {};
|
|
75
|
+
for (const c of cols) {
|
|
76
|
+
const v = values[c];
|
|
77
|
+
if (v === undefined)
|
|
78
|
+
return null;
|
|
79
|
+
out[c] = v;
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
},
|
|
83
|
+
extractFromLookup: (arg) => arg,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Function
|
|
87
|
+
if (typeof keyDecl === "function") {
|
|
88
|
+
return {
|
|
89
|
+
readColumns: extraComponents,
|
|
90
|
+
extractFromEntity: (values) => {
|
|
91
|
+
const args = extraComponents.map((c) => values[c]);
|
|
92
|
+
if (args.some((v) => v === undefined))
|
|
93
|
+
return null;
|
|
94
|
+
const out = keyDecl(...args);
|
|
95
|
+
return out === undefined ? null : out;
|
|
96
|
+
},
|
|
97
|
+
extractFromLookup: (arg) => arg,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Slot map
|
|
101
|
+
const slotEntries = Object.entries(keyDecl);
|
|
102
|
+
// Read set: identity-string columns + extra components for functions.
|
|
103
|
+
const reads = new Set();
|
|
104
|
+
for (const [, v] of slotEntries)
|
|
105
|
+
if (typeof v === "string")
|
|
106
|
+
reads.add(v);
|
|
107
|
+
for (const c of extraComponents)
|
|
108
|
+
reads.add(c);
|
|
109
|
+
return {
|
|
110
|
+
readColumns: [...reads],
|
|
111
|
+
extractFromEntity: (values) => {
|
|
112
|
+
const out = {};
|
|
113
|
+
for (const [slot, ext] of slotEntries) {
|
|
114
|
+
if (typeof ext === "string") {
|
|
115
|
+
const v = values[ext];
|
|
116
|
+
if (v === undefined)
|
|
117
|
+
return null;
|
|
118
|
+
out[slot] = v;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const args = extraComponents.map((c) => values[c]);
|
|
122
|
+
if (args.some((v) => v === undefined))
|
|
123
|
+
return null;
|
|
124
|
+
const v = ext(...args);
|
|
125
|
+
if (v === undefined)
|
|
126
|
+
return null;
|
|
127
|
+
out[slot] = v;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
},
|
|
132
|
+
extractFromLookup: (arg) => arg,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
const defaultCompare = (by) => (a, b) => {
|
|
136
|
+
for (const c of by) {
|
|
137
|
+
const va = a[c];
|
|
138
|
+
const vb = b[c];
|
|
139
|
+
if (va === vb)
|
|
140
|
+
continue;
|
|
141
|
+
if (va < vb)
|
|
142
|
+
return -1;
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
return 0;
|
|
146
|
+
};
|
|
147
|
+
const normalizeOrder = (order) => {
|
|
148
|
+
const { by, compare } = order;
|
|
149
|
+
const cmp = compare ?? defaultCompare(by);
|
|
150
|
+
return {
|
|
151
|
+
readColumns: by,
|
|
152
|
+
snapshot: (values) => {
|
|
153
|
+
const out = {};
|
|
154
|
+
for (const c of by) {
|
|
155
|
+
const v = values[c];
|
|
156
|
+
if (v === undefined)
|
|
157
|
+
return null;
|
|
158
|
+
out[c] = v;
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
},
|
|
162
|
+
compare: cmp,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export const createIndex = (state) => {
|
|
166
|
+
const unique = state.unique ?? false;
|
|
167
|
+
const extraComponents = state.components ?? [];
|
|
168
|
+
const keyEx = normalizeKey(state.key, extraComponents);
|
|
169
|
+
const orderEx = state.order ? normalizeOrder(state.order) : null;
|
|
170
|
+
const sorted = orderEx !== null;
|
|
171
|
+
// All columns the index touches (key reads + sort reads). Used by
|
|
172
|
+
// the store to walk only relevant archetypes when seeding.
|
|
173
|
+
const readColumns = (() => {
|
|
174
|
+
const set = new Set(keyEx.readColumns);
|
|
175
|
+
if (orderEx)
|
|
176
|
+
for (const c of orderEx.readColumns)
|
|
177
|
+
set.add(c);
|
|
178
|
+
return [...set];
|
|
179
|
+
})();
|
|
180
|
+
// Bucket payload:
|
|
181
|
+
// - non-unique → Set<Entity> (membership; O(1) add + delete + has)
|
|
182
|
+
// - unique → single Entity
|
|
183
|
+
// We use a Set rather than an Entity[] so single-entity writes are
|
|
184
|
+
// O(1) in bucket size — `arr.indexOf` + `splice` / `swap-pop` would
|
|
185
|
+
// make remove and bucket-change updates O(bucket.size), which can be
|
|
186
|
+
// O(archetype.rowCount) in pathological cases (many entities sharing
|
|
187
|
+
// one bucket key).
|
|
188
|
+
const buckets = new Map();
|
|
189
|
+
// The post-fan-out key value for each serialized bucket key. `findRange`
|
|
190
|
+
// reads this to apply per-bucket operator filters (find scans every
|
|
191
|
+
// bucket once and keeps the ones whose value matches the filter).
|
|
192
|
+
const bucketValueByKey = new Map();
|
|
193
|
+
// Reverse map: which serialized bucket keys each entity sits in.
|
|
194
|
+
const entityKeys = new Map();
|
|
195
|
+
// Sort cache, if sorted.
|
|
196
|
+
const sortCache = sorted ? new Map() : undefined;
|
|
197
|
+
// Cached sorted array per bucket — populated lazily by `find` /
|
|
198
|
+
// `findRange`, dropped on any write that touches the bucket. Lets
|
|
199
|
+
// repeated reads of the same bucket avoid re-materializing + re-sorting.
|
|
200
|
+
const sortedCache = sorted ? new Map() : undefined;
|
|
201
|
+
// Helpers ---------------------------------------------------------------
|
|
202
|
+
/** Enumerate (serialized-key, post-fan-out-value) pairs for an entity. */
|
|
203
|
+
const bucketEntriesFor = (values) => {
|
|
204
|
+
const raw = keyEx.extractFromEntity(values);
|
|
205
|
+
if (raw === null)
|
|
206
|
+
return [];
|
|
207
|
+
const expanded = expandBucketKeys(raw);
|
|
208
|
+
const out = [];
|
|
209
|
+
const seen = new Set();
|
|
210
|
+
for (const v of expanded) {
|
|
211
|
+
const s = serializeKey(v);
|
|
212
|
+
if (!seen.has(s)) {
|
|
213
|
+
seen.add(s);
|
|
214
|
+
out.push({ key: s, value: v });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
};
|
|
219
|
+
/** Just the keys (used in many maintenance paths). */
|
|
220
|
+
const bucketKeysFor = (values) => bucketEntriesFor(values).map((e) => e.key);
|
|
221
|
+
const lookupKey = (arg) => serializeKey(keyEx.extractFromLookup(arg));
|
|
222
|
+
/** Comparator that reads each entity's snapshot from sortCache. */
|
|
223
|
+
const compareEntities = (a, b) => orderEx.compare(sortCache.get(a), sortCache.get(b));
|
|
224
|
+
/**
|
|
225
|
+
* Materialize a non-unique bucket as an `Entity[]`. For sorted indexes
|
|
226
|
+
* the result is cached and the cache is invalidated by writes — so
|
|
227
|
+
* repeated reads of the same bucket pay nothing after the first.
|
|
228
|
+
*/
|
|
229
|
+
const materializeBucket = (key, set) => {
|
|
230
|
+
if (sorted) {
|
|
231
|
+
const cached = sortedCache.get(key);
|
|
232
|
+
if (cached !== undefined)
|
|
233
|
+
return cached;
|
|
234
|
+
const arr = [...set];
|
|
235
|
+
if (arr.length > 1)
|
|
236
|
+
arr.sort(compareEntities);
|
|
237
|
+
sortedCache.set(key, arr);
|
|
238
|
+
return arr;
|
|
239
|
+
}
|
|
240
|
+
return [...set];
|
|
241
|
+
};
|
|
242
|
+
const insertIntoBucket = (entity, key, value) => {
|
|
243
|
+
bucketValueByKey.set(key, value);
|
|
244
|
+
if (unique) {
|
|
245
|
+
const existing = buckets.get(key);
|
|
246
|
+
if (existing !== undefined && existing !== entity) {
|
|
247
|
+
throw new Error(`Unique index conflict on key ${key}: ` +
|
|
248
|
+
`existing entity ${existing}, new entity ${entity}`);
|
|
249
|
+
}
|
|
250
|
+
buckets.set(key, entity);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
let set = buckets.get(key);
|
|
254
|
+
if (!set)
|
|
255
|
+
buckets.set(key, (set = new Set()));
|
|
256
|
+
set.add(entity);
|
|
257
|
+
if (sorted)
|
|
258
|
+
sortedCache.delete(key);
|
|
259
|
+
};
|
|
260
|
+
const removeFromBucket = (entity, key) => {
|
|
261
|
+
if (unique) {
|
|
262
|
+
buckets.delete(key);
|
|
263
|
+
bucketValueByKey.delete(key);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const set = buckets.get(key);
|
|
267
|
+
if (!set)
|
|
268
|
+
return;
|
|
269
|
+
set.delete(entity);
|
|
270
|
+
if (sorted)
|
|
271
|
+
sortedCache.delete(key);
|
|
272
|
+
if (set.size === 0) {
|
|
273
|
+
buckets.delete(key);
|
|
274
|
+
bucketValueByKey.delete(key);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
// Public methods --------------------------------------------------------
|
|
278
|
+
const add = (entity, values) => {
|
|
279
|
+
const entries = bucketEntriesFor(values);
|
|
280
|
+
if (entries.length === 0)
|
|
281
|
+
return;
|
|
282
|
+
if (unique) {
|
|
283
|
+
for (const { key } of entries) {
|
|
284
|
+
const existing = buckets.get(key);
|
|
285
|
+
if (existing !== undefined && existing !== entity) {
|
|
286
|
+
throw new Error(`Unique index conflict on key ${key}: ` +
|
|
287
|
+
`existing entity ${existing}, new entity ${entity}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (sorted) {
|
|
292
|
+
const snap = orderEx.snapshot(values);
|
|
293
|
+
if (snap === null)
|
|
294
|
+
return;
|
|
295
|
+
sortCache.set(entity, snap);
|
|
296
|
+
}
|
|
297
|
+
for (const { key, value } of entries)
|
|
298
|
+
insertIntoBucket(entity, key, value);
|
|
299
|
+
entityKeys.set(entity, entries.map((e) => e.key));
|
|
300
|
+
};
|
|
301
|
+
const remove = (entity) => {
|
|
302
|
+
const keys = entityKeys.get(entity);
|
|
303
|
+
if (!keys)
|
|
304
|
+
return;
|
|
305
|
+
for (const k of keys)
|
|
306
|
+
removeFromBucket(entity, k);
|
|
307
|
+
entityKeys.delete(entity);
|
|
308
|
+
if (sorted)
|
|
309
|
+
sortCache.delete(entity);
|
|
310
|
+
};
|
|
311
|
+
const update = (entity, values) => {
|
|
312
|
+
const nextEntries = bucketEntriesFor(values);
|
|
313
|
+
const nextKeys = nextEntries.map((e) => e.key);
|
|
314
|
+
const prevKeys = entityKeys.get(entity) ?? [];
|
|
315
|
+
const nextSet = new Set(nextKeys);
|
|
316
|
+
const prevSet = new Set(prevKeys);
|
|
317
|
+
// Unique pre-check on new keys we don't already own.
|
|
318
|
+
if (unique) {
|
|
319
|
+
for (const k of nextKeys) {
|
|
320
|
+
if (prevSet.has(k))
|
|
321
|
+
continue;
|
|
322
|
+
const existing = buckets.get(k);
|
|
323
|
+
if (existing !== undefined && existing !== entity) {
|
|
324
|
+
throw new Error(`Unique index conflict on key ${k}: ` +
|
|
325
|
+
`existing entity ${existing}, new entity ${entity}`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// Same bucket set → only the per-entity sort snapshot may have
|
|
330
|
+
// changed. Refresh it and drop the sort cache so the next read
|
|
331
|
+
// re-sorts. No bucket scan up front — O(b) total.
|
|
332
|
+
const sameBuckets = nextKeys.length === prevKeys.length &&
|
|
333
|
+
nextKeys.every((k, i) => k === prevKeys[i]);
|
|
334
|
+
if (sameBuckets) {
|
|
335
|
+
if (!sorted)
|
|
336
|
+
return;
|
|
337
|
+
const newSnap = orderEx.snapshot(values);
|
|
338
|
+
if (newSnap === null) {
|
|
339
|
+
remove(entity);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const oldSnap = sortCache.get(entity);
|
|
343
|
+
if (oldSnap !== undefined && orderEx.compare(oldSnap, newSnap) === 0)
|
|
344
|
+
return;
|
|
345
|
+
sortCache.set(entity, newSnap);
|
|
346
|
+
if (!unique)
|
|
347
|
+
for (const k of nextKeys)
|
|
348
|
+
sortedCache.delete(k);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
// Bucket-set changed: drop the ones we left, refresh sort cache,
|
|
352
|
+
// insert into the new ones. insertIntoBucket marks new buckets dirty.
|
|
353
|
+
for (const k of prevKeys)
|
|
354
|
+
if (!nextSet.has(k))
|
|
355
|
+
removeFromBucket(entity, k);
|
|
356
|
+
if (sorted) {
|
|
357
|
+
if (nextEntries.length === 0)
|
|
358
|
+
sortCache.delete(entity);
|
|
359
|
+
else {
|
|
360
|
+
const snap = orderEx.snapshot(values);
|
|
361
|
+
if (snap === null) {
|
|
362
|
+
remove(entity);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
sortCache.set(entity, snap);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
for (const { key, value } of nextEntries) {
|
|
369
|
+
if (!prevSet.has(key))
|
|
370
|
+
insertIntoBucket(entity, key, value);
|
|
371
|
+
}
|
|
372
|
+
if (nextKeys.length === 0)
|
|
373
|
+
entityKeys.delete(entity);
|
|
374
|
+
else
|
|
375
|
+
entityKeys.set(entity, nextKeys);
|
|
376
|
+
};
|
|
377
|
+
const clear = () => {
|
|
378
|
+
buckets.clear();
|
|
379
|
+
bucketValueByKey.clear();
|
|
380
|
+
entityKeys.clear();
|
|
381
|
+
if (sorted) {
|
|
382
|
+
sortCache.clear();
|
|
383
|
+
sortedCache.clear();
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const find = (arg) => {
|
|
387
|
+
const k = lookupKey(arg);
|
|
388
|
+
const bucket = buckets.get(k);
|
|
389
|
+
if (bucket === undefined)
|
|
390
|
+
return [];
|
|
391
|
+
if (unique)
|
|
392
|
+
return [bucket];
|
|
393
|
+
// Materialize a fresh array on each call to keep the returned
|
|
394
|
+
// result independent of internal mutations. For sorted indexes
|
|
395
|
+
// the inner sorted array is cached and reused across reads until
|
|
396
|
+
// the next write to the bucket — so successive reads only pay
|
|
397
|
+
// the slice, not the sort.
|
|
398
|
+
return materializeBucket(k, bucket).slice();
|
|
399
|
+
};
|
|
400
|
+
// findRange supports the exact-match argument shape that `find` accepts,
|
|
401
|
+
// plus operator filters on the bucket key. Operators are
|
|
402
|
+
// ==, !=, <, <=, >, >=. For a scalar key (bare-string or function key),
|
|
403
|
+
// an operator object at the argument root applies to the scalar value.
|
|
404
|
+
// For an object key (tuple or slot map), each field can be either a
|
|
405
|
+
// value (equality) or an operator object.
|
|
406
|
+
//
|
|
407
|
+
// Implementation walks every bucket once. That cost is linear in the
|
|
408
|
+
// bucket count, but the alternative — maintaining a sorted index on the
|
|
409
|
+
// bucket key — is much heavier machinery for the same result on most
|
|
410
|
+
// workloads. The hot path for users is `find`, not `findRange`.
|
|
411
|
+
const isOperatorObject = (v) => {
|
|
412
|
+
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
413
|
+
return false;
|
|
414
|
+
const keys = Object.keys(v);
|
|
415
|
+
if (keys.length === 0)
|
|
416
|
+
return false;
|
|
417
|
+
for (const k of keys) {
|
|
418
|
+
if (k !== "==" && k !== "!=" && k !== "<" && k !== "<=" && k !== ">" && k !== ">=") {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return true;
|
|
423
|
+
};
|
|
424
|
+
const matchesOps = (value, ops) => {
|
|
425
|
+
for (const op in ops) {
|
|
426
|
+
const target = ops[op];
|
|
427
|
+
const v = value;
|
|
428
|
+
const t = target;
|
|
429
|
+
switch (op) {
|
|
430
|
+
case "==":
|
|
431
|
+
if (!Object.is(v, t))
|
|
432
|
+
return false;
|
|
433
|
+
break;
|
|
434
|
+
case "!=":
|
|
435
|
+
if (Object.is(v, t))
|
|
436
|
+
return false;
|
|
437
|
+
break;
|
|
438
|
+
case "<":
|
|
439
|
+
if (!(v < t))
|
|
440
|
+
return false;
|
|
441
|
+
break;
|
|
442
|
+
case "<=":
|
|
443
|
+
if (!(v <= t))
|
|
444
|
+
return false;
|
|
445
|
+
break;
|
|
446
|
+
case ">":
|
|
447
|
+
if (!(v > t))
|
|
448
|
+
return false;
|
|
449
|
+
break;
|
|
450
|
+
case ">=":
|
|
451
|
+
if (!(v >= t))
|
|
452
|
+
return false;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
457
|
+
};
|
|
458
|
+
const scalarKey = typeof state.key === "string" || typeof state.key === "function";
|
|
459
|
+
const matchesArg = (bucketValue, arg) => {
|
|
460
|
+
if (scalarKey) {
|
|
461
|
+
if (isOperatorObject(arg))
|
|
462
|
+
return matchesOps(bucketValue, arg);
|
|
463
|
+
return Object.is(bucketValue, arg);
|
|
464
|
+
}
|
|
465
|
+
if (arg === null || typeof arg !== "object" || Array.isArray(arg))
|
|
466
|
+
return false;
|
|
467
|
+
for (const field in arg) {
|
|
468
|
+
const condition = arg[field];
|
|
469
|
+
const fieldValue = bucketValue[field];
|
|
470
|
+
if (isOperatorObject(condition)) {
|
|
471
|
+
if (!matchesOps(fieldValue, condition))
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
else if (!Object.is(fieldValue, condition)) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return true;
|
|
479
|
+
};
|
|
480
|
+
const findRange = (arg) => {
|
|
481
|
+
const result = new Set();
|
|
482
|
+
for (const [key, bucketEntries] of buckets) {
|
|
483
|
+
const bucketValue = bucketValueByKey.get(key);
|
|
484
|
+
if (!matchesArg(bucketValue, arg))
|
|
485
|
+
continue;
|
|
486
|
+
if (unique) {
|
|
487
|
+
result.add(bucketEntries);
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
// For sorted indexes, materialize the (cached) sorted array
|
|
491
|
+
// so per-bucket order is consistent with `find` semantics.
|
|
492
|
+
// Cross-bucket order is still arbitrary (the outer Set).
|
|
493
|
+
const set = bucketEntries;
|
|
494
|
+
const ordered = sorted ? materializeBucket(key, set) : set;
|
|
495
|
+
for (const e of ordered)
|
|
496
|
+
result.add(e);
|
|
497
|
+
}
|
|
498
|
+
return [...result];
|
|
499
|
+
};
|
|
500
|
+
const get = (arg) => {
|
|
501
|
+
if (!unique) {
|
|
502
|
+
throw new Error("Database.Index.Handle.get is only available on unique indexes");
|
|
503
|
+
}
|
|
504
|
+
const k = lookupKey(arg);
|
|
505
|
+
const bucket = buckets.get(k);
|
|
506
|
+
return bucket === undefined ? null : bucket;
|
|
507
|
+
};
|
|
508
|
+
const checkUniqueAvailable = (values, excludeEntity) => {
|
|
509
|
+
if (!unique)
|
|
510
|
+
return null;
|
|
511
|
+
const keys = bucketKeysFor(values);
|
|
512
|
+
for (const k of keys) {
|
|
513
|
+
const existing = buckets.get(k);
|
|
514
|
+
if (existing === undefined)
|
|
515
|
+
continue;
|
|
516
|
+
if (excludeEntity !== null && existing === excludeEntity)
|
|
517
|
+
continue;
|
|
518
|
+
return existing;
|
|
519
|
+
}
|
|
520
|
+
return null;
|
|
521
|
+
};
|
|
522
|
+
return {
|
|
523
|
+
unique,
|
|
524
|
+
readColumns,
|
|
525
|
+
sorted,
|
|
526
|
+
key: state.key,
|
|
527
|
+
order: state.order,
|
|
528
|
+
add,
|
|
529
|
+
remove,
|
|
530
|
+
update,
|
|
531
|
+
clear,
|
|
532
|
+
get size() { return entityKeys.size; },
|
|
533
|
+
find,
|
|
534
|
+
findRange,
|
|
535
|
+
get: get,
|
|
536
|
+
checkUniqueAvailable,
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
//# sourceMappingURL=create-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-index.js","sourceRoot":"","sources":["../../../../src/ecs/database/index-registry/create-index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAyCvD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE;IAC5C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACpD,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC;YAAE,GAAG,IAAI,GAAG,CAAC;QACtB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC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CAAC,IAAI,CAAC,CAAC,CAAE,MAAiB,CAAC;IAC5D,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,CACzB,MAAyC,EACzC,aAA4B,EACf,EAAE;QACf,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,QAAQ,KAAK,SAAS;gBAAE,SAAS;YACrC,IAAI,aAAa,KAAK,IAAI,IAAI,QAAQ,KAAK,aAAa;gBAAE,SAAS;YACnE,OAAO,QAAkB,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO;QACH,MAAM;QACN,WAAW;QACX,MAAM;QACN,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,GAAG;QACH,MAAM;QACN,MAAM;QACN,KAAK;QACL,IAAI,IAAI,KAAK,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,IAAI;QACJ,SAAS;QACT,GAAG,EAAE,GAA0B;QAC/B,oBAAoB;KACvB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createIndex } from "./create-index.js";
|
|
2
|
+
export type { IndexState, RuntimeIndex, IndexKeyDecl, IndexOrderDecl } from "./create-index.js";
|
|
3
|
+
export { createIndexRegistry } from "./create-index-registry.js";
|
|
4
|
+
export type { IndexRegistry, EntityReader, IndexDeclarationObject } from "./create-index-registry.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ecs/database/index-registry/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./public/create-database.js";
|
|
2
2
|
export * from "./public/observe-select-deep.js";
|
|
3
|
+
export * from "./concurrency/index.js";
|
|
3
4
|
export * from "./reconciling/create-reconciling-database.js";
|
|
4
5
|
export * from "./reconciling/reconciling-database.js";
|
|
5
6
|
export * from "./reconciling/reconciling-entry.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
2
|
export * from "./public/create-database.js";
|
|
3
3
|
export * from "./public/observe-select-deep.js";
|
|
4
|
+
export * from "./concurrency/index.js";
|
|
4
5
|
export * from "./reconciling/create-reconciling-database.js";
|
|
5
6
|
export * from "./reconciling/reconciling-database.js";
|
|
6
7
|
export * from "./reconciling/reconciling-entry.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ecs/database/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ecs/database/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Observe } from "../../observe/index.js";
|
|
2
|
+
import { Entity } from "../entity/entity.js";
|
|
3
|
+
import { TransactionResult } from "./transactional-store/transactional-store.js";
|
|
4
|
+
/**
|
|
5
|
+
* Reactive counterpart to an index handle's `find`. Mirrors
|
|
6
|
+
* {@link observeSelectEntities}: the initial value is emitted synchronously on
|
|
7
|
+
* subscribe, and subsequent values are emitted on a microtask after any
|
|
8
|
+
* transaction whose changed components intersect the index's read columns —
|
|
9
|
+
* the same commit boundary every other observer in the database fires on.
|
|
10
|
+
*
|
|
11
|
+
* Why route through transactions rather than notifying inside the index's own
|
|
12
|
+
* `add` / `remove` / `update`: those run *during* a transaction body, once per
|
|
13
|
+
* mutated entity, before the transaction commits. Emitting there would fire
|
|
14
|
+
* observers mid-transaction against half-applied state and at a different
|
|
15
|
+
* cadence than `db.observe.select`. Recomputing `find(arg)` at the commit
|
|
16
|
+
* boundary instead coalesces a whole transaction into one emission and keeps
|
|
17
|
+
* index reactivity consistent with the rest of the system.
|
|
18
|
+
*
|
|
19
|
+
* Bucket precision ("don't emit when an unrelated bucket changed") falls out
|
|
20
|
+
* of comparing the freshly-recomputed entity sequence against the last emitted
|
|
21
|
+
* one: an unrelated change recomputes to an identical sequence and is
|
|
22
|
+
* suppressed, while a reorder *within* the observed bucket — the regression
|
|
23
|
+
* case the index `find` already handles but a `where`-only `observe.select`
|
|
24
|
+
* silently swallows — produces a different sequence and is emitted.
|
|
25
|
+
*/
|
|
26
|
+
export declare const observeIndexEntities: (observeTransactions: Observe<TransactionResult<any>>) => (find: (arg: unknown) => readonly Entity[], readColumns: readonly string[]) => (arg: unknown) => Observe<readonly Entity[]>;
|