doxum 0.1.28 → 0.1.30
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 +3 -2
- package/dist/advanced.cjs +1 -1
- package/dist/advanced.js +1 -1
- package/dist/{driver-B5vdPohL.js → driver-B7RR-VfX.js} +31 -12
- package/dist/driver-B7RR-VfX.js.map +1 -0
- package/dist/{driver-BL91gn7_.cjs → driver-CN3dGxQI.cjs} +31 -12
- package/dist/driver-CN3dGxQI.cjs.map +1 -0
- package/dist/index.cjs +206 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +206 -133
- package/dist/index.js.map +1 -1
- package/dist/local-sync.cjs +1 -1
- package/dist/local-sync.js +1 -1
- package/dist/{transform-DUleAsG0.cjs → transform-B6YxfR0R.cjs} +176 -50
- package/dist/transform-B6YxfR0R.cjs.map +1 -0
- package/dist/{transform-B4T3AcJr.js → transform-BQY9I6il.js} +147 -51
- package/dist/transform-BQY9I6il.js.map +1 -0
- package/package.json +3 -2
- package/skills/doxum-runtime/SKILL.md +64 -82
- package/skills/doxum-runtime/agents/openai.yaml +2 -2
- package/skills/doxum-runtime/references/document-runtime.md +370 -0
- package/skills/doxum-runtime/references/integrations.md +215 -0
- package/skills/doxum-runtime/references/{invariants.en.md → invariants.md} +5 -2
- package/skills/doxum-runtime/references/projections.md +467 -0
- package/skills/doxum-runtime/references/public-api.md +623 -0
- package/skills/doxum-runtime/references/recipes.md +493 -0
- package/dist/driver-B5vdPohL.js.map +0 -1
- package/dist/driver-BL91gn7_.cjs.map +0 -1
- package/dist/transform-B4T3AcJr.js.map +0 -1
- package/dist/transform-DUleAsG0.cjs.map +0 -1
- package/skills/doxum-runtime/references/api.en.md +0 -283
- package/skills/doxum-runtime/references/api.zh-CN.md +0 -276
- package/skills/doxum-runtime/references/guide.en.md +0 -138
- package/skills/doxum-runtime/references/guide.zh-CN.md +0 -116
- package/skills/doxum-runtime/references/invariants.zh-CN.md +0 -53
- package/skills/doxum-runtime/references/patterns.en.md +0 -162
- package/skills/doxum-runtime/references/patterns.zh-CN.md +0 -159
- package/skills/doxum-runtime/references/projections.en.md +0 -313
- package/skills/doxum-runtime/references/projections.zh-CN.md +0 -306
|
@@ -108,14 +108,17 @@ const defineSource = (source, output) => {
|
|
|
108
108
|
};
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region core/src/projection/collection/view.ts
|
|
111
|
-
const mapRead = (value) =>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
const mapRead = (value) => {
|
|
112
|
+
let ids;
|
|
113
|
+
return {
|
|
114
|
+
get: (key) => value.get(key),
|
|
115
|
+
has: (key) => value.has(key),
|
|
116
|
+
ids: () => ids ??= Object.freeze([...value.keys()])
|
|
117
|
+
};
|
|
118
|
+
};
|
|
116
119
|
/** Immutable map-like view over a CollectionRead. */
|
|
117
|
-
const collectionView = (read) => {
|
|
118
|
-
const ids = read.ids();
|
|
120
|
+
const collectionView = (read, knownIds) => {
|
|
121
|
+
const ids = knownIds ?? read.ids();
|
|
119
122
|
const entries = function* () {
|
|
120
123
|
for (const key of ids) yield [key, read.get(key)];
|
|
121
124
|
};
|
|
@@ -143,7 +146,7 @@ const snapshotCollectionView = (read) => {
|
|
|
143
146
|
const ids = read.ids();
|
|
144
147
|
const values = /* @__PURE__ */ new Map();
|
|
145
148
|
for (const key of ids) values.set(key, read.get(key));
|
|
146
|
-
return collectionView(mapRead(values));
|
|
149
|
+
return collectionView(mapRead(values), ids);
|
|
147
150
|
};
|
|
148
151
|
//#endregion
|
|
149
152
|
//#region core/src/projection/dependency.ts
|
|
@@ -180,29 +183,96 @@ const compileProjectionDependencies = (dependencies, label) => {
|
|
|
180
183
|
});
|
|
181
184
|
};
|
|
182
185
|
//#endregion
|
|
186
|
+
//#region core/src/value/array.ts
|
|
187
|
+
/** Allocation-free strict equality for ordered readonly arrays. */
|
|
188
|
+
const sameArray = (left, right) => {
|
|
189
|
+
if (left === right) return true;
|
|
190
|
+
if (left.length !== right.length) return false;
|
|
191
|
+
for (let index = 0; index < left.length; index++) if (left[index] !== right[index]) return false;
|
|
192
|
+
return true;
|
|
193
|
+
};
|
|
194
|
+
/** Owns an immutable shallow snapshot while reusing arrays that are already frozen. */
|
|
195
|
+
const snapshotArray = (values) => Object.isFrozen(values) ? values : Object.freeze([...values]);
|
|
196
|
+
/** Compares an iterable with an ordered array without materializing the iterable. */
|
|
197
|
+
const iterableMatchesArray = (values, expected) => {
|
|
198
|
+
let index = 0;
|
|
199
|
+
for (const value of values) {
|
|
200
|
+
if (index >= expected.length || value !== expected[index]) return false;
|
|
201
|
+
index++;
|
|
202
|
+
}
|
|
203
|
+
return index === expected.length;
|
|
204
|
+
};
|
|
205
|
+
//#endregion
|
|
183
206
|
//#region core/src/projection/collection/change.ts
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
return beforeCommon.some((key, index) => afterCommon[index] !== key);
|
|
207
|
+
const transitionContains = (entries, key) => {
|
|
208
|
+
for (const entry of entries) if (entry.key === key) return true;
|
|
209
|
+
return false;
|
|
188
210
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
211
|
+
const transitionSet = (entries) => {
|
|
212
|
+
if (entries.length <= 4) return void 0;
|
|
213
|
+
const keys = /* @__PURE__ */ new Set();
|
|
214
|
+
for (const entry of entries) keys.add(entry.key);
|
|
215
|
+
return keys;
|
|
216
|
+
};
|
|
217
|
+
const nextExcluding = (iterator, excluded, index) => {
|
|
218
|
+
while (true) {
|
|
219
|
+
const next = iterator.next();
|
|
220
|
+
if (next.done || !(index ? index.has(next.value) : transitionContains(excluded, next.value))) return next;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
/** Compares common-member order from known transitions without materializing common arrays. */
|
|
224
|
+
const transitionOrderChanged = (before, after, removed, added) => {
|
|
225
|
+
const removedKeys = transitionSet(removed);
|
|
226
|
+
const addedKeys = transitionSet(added);
|
|
227
|
+
const beforeIterator = before[Symbol.iterator]();
|
|
228
|
+
const afterIterator = after[Symbol.iterator]();
|
|
229
|
+
while (true) {
|
|
230
|
+
const left = nextExcluding(beforeIterator, removed, removedKeys);
|
|
231
|
+
const right = nextExcluding(afterIterator, added, addedKeys);
|
|
232
|
+
if (left.done || right.done) return left.done !== right.done;
|
|
233
|
+
if (left.value !== right.value) return true;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const nextPresentIn = (iterator, membership) => {
|
|
237
|
+
while (true) {
|
|
238
|
+
const next = iterator.next();
|
|
239
|
+
if (next.done || membership.has(next.value)) return next;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
/** Compares common-member order between two map snapshots without key snapshots or closures. */
|
|
243
|
+
const mapOrderChanged = (before, after) => {
|
|
244
|
+
const beforeIterator = before.keys();
|
|
245
|
+
const afterIterator = after.keys();
|
|
246
|
+
while (true) {
|
|
247
|
+
const left = nextPresentIn(beforeIterator, after);
|
|
248
|
+
const right = nextPresentIn(afterIterator, before);
|
|
249
|
+
if (left.done || right.done) return left.done !== right.done;
|
|
250
|
+
if (left.value !== right.value) return true;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const sealIncrementalChange = (added, updated, removed, order) => {
|
|
254
|
+
if (!added.length && !updated.length && !removed.length && !order) return void 0;
|
|
195
255
|
return Object.freeze({
|
|
196
256
|
kind: "incremental",
|
|
197
|
-
added: Object.freeze(
|
|
198
|
-
updated: Object.freeze(
|
|
199
|
-
removed: Object.freeze(
|
|
200
|
-
...
|
|
201
|
-
before:
|
|
202
|
-
after:
|
|
257
|
+
added: Object.freeze(added),
|
|
258
|
+
updated: Object.freeze(updated),
|
|
259
|
+
removed: Object.freeze(removed),
|
|
260
|
+
...order ? { order: Object.freeze({
|
|
261
|
+
before: snapshotArray(order.before),
|
|
262
|
+
after: snapshotArray(order.after)
|
|
203
263
|
}) } : {}
|
|
204
264
|
});
|
|
205
265
|
};
|
|
266
|
+
/** Builds the canonical incremental CollectionChange from already-known net transitions. */
|
|
267
|
+
const createCollectionChange = (input) => {
|
|
268
|
+
let orderChanged = false;
|
|
269
|
+
if (input.beforeOrder !== input.afterOrder) if (!input.added.length && !input.removed.length) orderChanged = !sameArray(input.beforeOrder, input.afterOrder);
|
|
270
|
+
else orderChanged = transitionOrderChanged(input.beforeOrder, input.afterOrder, input.removed, input.added);
|
|
271
|
+
return sealIncrementalChange(input.added, input.updated, input.removed, orderChanged ? {
|
|
272
|
+
before: input.beforeOrder,
|
|
273
|
+
after: input.afterOrder
|
|
274
|
+
} : void 0);
|
|
275
|
+
};
|
|
206
276
|
/** Exact fallback diff between two published map-like snapshots. */
|
|
207
277
|
const diffCollection = (previous, current, isEqual = Object.is) => {
|
|
208
278
|
const added = [];
|
|
@@ -224,13 +294,10 @@ const diffCollection = (previous, current, isEqual = Object.is) => {
|
|
|
224
294
|
key,
|
|
225
295
|
after
|
|
226
296
|
});
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
beforeOrder: [...previous.keys()],
|
|
232
|
-
afterOrder: [...current.keys()]
|
|
233
|
-
});
|
|
297
|
+
return sealIncrementalChange(added, updated, removed, mapOrderChanged(previous, current) ? {
|
|
298
|
+
before: Object.freeze([...previous.keys()]),
|
|
299
|
+
after: Object.freeze([...current.keys()])
|
|
300
|
+
} : void 0);
|
|
234
301
|
};
|
|
235
302
|
const changedKeys = function* (change) {
|
|
236
303
|
if (change.kind !== "incremental") throw new TypeError("collectionChange.keys requires an incremental CollectionChange.");
|
|
@@ -240,6 +307,18 @@ const changedKeys = function* (change) {
|
|
|
240
307
|
};
|
|
241
308
|
const collectionChange = Object.freeze({ keys: changedKeys });
|
|
242
309
|
const collectionHasStructuralChange = (change) => change.kind === "reset" || Boolean(change.added.length || change.removed.length || change.order);
|
|
310
|
+
const collectionChangeTouchesKey = (change, key) => {
|
|
311
|
+
for (const entry of change.added) if (entry.key === key) return true;
|
|
312
|
+
for (const entry of change.updated) if (entry.key === key) return true;
|
|
313
|
+
for (const entry of change.removed) if (entry.key === key) return true;
|
|
314
|
+
return false;
|
|
315
|
+
};
|
|
316
|
+
const collectionChangeIntersects = (change, keys) => {
|
|
317
|
+
for (const entry of change.added) if (keys.has(entry.key)) return true;
|
|
318
|
+
for (const entry of change.updated) if (keys.has(entry.key)) return true;
|
|
319
|
+
for (const entry of change.removed) if (keys.has(entry.key)) return true;
|
|
320
|
+
return false;
|
|
321
|
+
};
|
|
243
322
|
//#endregion
|
|
244
323
|
//#region core/src/projection/contract.ts
|
|
245
324
|
var ProjectionError = class extends Error {
|
|
@@ -619,15 +698,30 @@ const createKeyRelation = () => {
|
|
|
619
698
|
}
|
|
620
699
|
};
|
|
621
700
|
return {
|
|
701
|
+
replaceOne(left, right) {
|
|
702
|
+
const previous = forward.get(left);
|
|
703
|
+
if (right === void 0) {
|
|
704
|
+
if (!previous) return false;
|
|
705
|
+
detach(left, previous);
|
|
706
|
+
forward.delete(left);
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
if (previous?.length === 1 && previous[0] === right) return false;
|
|
710
|
+
if (previous) detach(left, previous);
|
|
711
|
+
const next = Object.freeze([right]);
|
|
712
|
+
forward.set(left, next);
|
|
713
|
+
attach(left, next);
|
|
714
|
+
return true;
|
|
715
|
+
},
|
|
622
716
|
replace(left, right) {
|
|
623
|
-
const previous = forward.get(left)
|
|
624
|
-
if (previous
|
|
625
|
-
detach(left, previous);
|
|
717
|
+
const previous = forward.get(left);
|
|
718
|
+
if (previous ? sameArray(previous, right) : right.length === 0) return false;
|
|
719
|
+
if (previous) detach(left, previous);
|
|
626
720
|
if (!right.length) {
|
|
627
721
|
forward.delete(left);
|
|
628
722
|
return true;
|
|
629
723
|
}
|
|
630
|
-
const next =
|
|
724
|
+
const next = snapshotArray(right);
|
|
631
725
|
forward.set(left, next);
|
|
632
726
|
attach(left, next);
|
|
633
727
|
return true;
|
|
@@ -718,24 +812,24 @@ const compileKeyedDependencies = (driver, dependencySpecs, label) => {
|
|
|
718
812
|
projections: Object.freeze(projections)
|
|
719
813
|
});
|
|
720
814
|
};
|
|
815
|
+
const selectedKey = (dependency, value, key) => {
|
|
816
|
+
const result = dependency.select(value, key);
|
|
817
|
+
assertSynchronous(result);
|
|
818
|
+
if (result === void 0) return void 0;
|
|
819
|
+
if (typeof result !== "string") throw new TypeError("Dynamic keyed dependency key must be a string or undefined.");
|
|
820
|
+
return result;
|
|
821
|
+
};
|
|
721
822
|
const selectedKeys = (dependency, value, key) => {
|
|
722
823
|
const result = dependency.select(value, key);
|
|
723
824
|
assertSynchronous(result);
|
|
724
|
-
if (dependency.kind === "one") {
|
|
725
|
-
if (result === void 0) return Object.freeze([]);
|
|
726
|
-
if (typeof result !== "string") throw new TypeError("Dynamic keyed dependency key must be a string or undefined.");
|
|
727
|
-
return Object.freeze([result]);
|
|
728
|
-
}
|
|
729
825
|
if (!Array.isArray(result)) throw new TypeError("Dynamic keyed dependency keys must be an array of strings.");
|
|
730
826
|
const seen = /* @__PURE__ */ new Set();
|
|
731
|
-
const keys = [];
|
|
732
827
|
for (const selected of result) {
|
|
733
828
|
if (typeof selected !== "string") throw new TypeError("Dynamic keyed dependency keys must contain only strings.");
|
|
734
829
|
if (seen.has(selected)) throw new TypeError("Dynamic keyed dependency keys must not contain duplicates.");
|
|
735
830
|
seen.add(selected);
|
|
736
|
-
keys.push(selected);
|
|
737
831
|
}
|
|
738
|
-
return
|
|
832
|
+
return result;
|
|
739
833
|
};
|
|
740
834
|
const emptyValues = Object.freeze(Object.create(null));
|
|
741
835
|
const createKeyedDependencyRuntime = (compiled) => {
|
|
@@ -772,13 +866,14 @@ const createKeyedDependencyRuntime = (compiled) => {
|
|
|
772
866
|
const dependency = state.entry;
|
|
773
867
|
const source = sources[state.sourceIndex];
|
|
774
868
|
if (source.kind !== "collection") throw new TypeError("Dynamic keyed dependency resolved to a non-collection source.");
|
|
775
|
-
const keys = selectedKeys(dependency, driverValue, driverKey);
|
|
776
|
-
state.relation.replace(driverKey, keys);
|
|
777
869
|
if (dependency.kind === "one") {
|
|
778
|
-
const selected =
|
|
870
|
+
const selected = selectedKey(dependency, driverValue, driverKey);
|
|
871
|
+
state.relation.replaceOne(driverKey, selected);
|
|
779
872
|
values[dependency.name] = selected === void 0 ? void 0 : source.read.get(selected);
|
|
780
873
|
continue;
|
|
781
874
|
}
|
|
875
|
+
const keys = selectedKeys(dependency, driverValue, driverKey);
|
|
876
|
+
state.relation.replace(driverKey, keys);
|
|
782
877
|
const selected = /* @__PURE__ */ new Map();
|
|
783
878
|
for (const key of keys) if (source.read.has(key)) selected.set(key, source.read.get(key));
|
|
784
879
|
values[dependency.name] = collectionView(mapRead(selected));
|
|
@@ -802,7 +897,9 @@ const createKeyedDependencyRuntime = (compiled) => {
|
|
|
802
897
|
all = true;
|
|
803
898
|
continue;
|
|
804
899
|
}
|
|
805
|
-
for (const
|
|
900
|
+
for (const entry of source.change.added) for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);
|
|
901
|
+
for (const entry of source.change.updated) for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);
|
|
902
|
+
for (const entry of source.change.removed) for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);
|
|
806
903
|
}
|
|
807
904
|
return all;
|
|
808
905
|
},
|
|
@@ -879,8 +976,7 @@ const createKeyedTransform = (definition) => {
|
|
|
879
976
|
if (evaluation.reset) {
|
|
880
977
|
dependencies.clearBindings();
|
|
881
978
|
const ids = driver.read.ids();
|
|
882
|
-
const
|
|
883
|
-
for (const key of [...states.keys()]) if (!present.has(key)) states.delete(key);
|
|
979
|
+
for (const key of states.keys()) if (!driver.read.has(key)) states.delete(key);
|
|
884
980
|
for (const key of ids) project(key);
|
|
885
981
|
output.output.order(ids.filter((key) => output.next.has(key)));
|
|
886
982
|
dependencies.remember(evaluation.sources);
|
|
@@ -933,6 +1029,6 @@ const createKeyedTransform = (definition) => {
|
|
|
933
1029
|
return projection;
|
|
934
1030
|
};
|
|
935
1031
|
//#endregion
|
|
936
|
-
export {
|
|
1032
|
+
export { ownProjections as A, snapshotDependencyValue as C, defineProcessor as D, snapshotCollectionView as E, projectionRef as M, profile as N, defineSource as O, compileProjectionDependencies as S, mapRead as T, createCollectionChange as _, createKeyedDependencyRuntime as a, sameArray as b, assertScope as c, ProjectionDisposedError as d, ProjectionError as f, collectionHasStructuralChange as g, collectionChangeTouchesKey as h, compileKeyedDependencies as i, producerOf as j, isProjection as k, assertSynchronous as l, collectionChangeIntersects as m, keyedAbsent as n, outputKind as o, collectionChange as p, assertKeyedProjection as r, createKeyRelation as s, createKeyedTransform as t, createScheduler as u, diffCollection as v, collectionView as w, snapshotArray as x, iterableMatchesArray as y };
|
|
937
1033
|
|
|
938
|
-
//# sourceMappingURL=transform-
|
|
1034
|
+
//# sourceMappingURL=transform-BQY9I6il.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-BQY9I6il.js","names":[],"sources":["../core/src/profile.ts","../core/src/projection/definition.ts","../core/src/projection/collection/view.ts","../core/src/projection/dependency.ts","../core/src/value/array.ts","../core/src/projection/collection/change.ts","../core/src/projection/contract.ts","../core/src/projection/graph/scheduler.ts","../core/src/projection/keyed/relation.ts","../core/src/projection/keyed/dependency.ts","../core/src/projection/keyed/transform.ts"],"sourcesContent":["const counters = () => ({\n projection: {\n sourceEvents: 0,\n scheduledNodes: 0,\n processedNodes: 0,\n touchedKeys: 0,\n changedKeys: 0,\n publishedNodes: 0,\n flushes: 0,\n },\n copy: { structures: 0, treeNodes: 0, shallowRecordItems: 0 },\n equality: { calls: 0, containers: 0 },\n recorder: {\n facts: 0,\n groups: 0,\n transitions: 0,\n absorbed: 0,\n orderSnapshots: 0,\n orderCaptures: 0,\n orderItems: 0,\n publishedOrderItems: 0,\n treeNodes: 0,\n sealed: 0,\n indexedGroups: 0,\n },\n access: { scopes: 0, proxies: 0, snapshots: 0, addresses: 0, resolutions: 0 },\n address: {\n schemaSteps: 0,\n documentSteps: 0,\n prefixComparisons: 0,\n segmentsCompared: 0,\n listIndexes: 0,\n listItems: 0,\n },\n impact: { affectsChecks: 0, indexes: 0 },\n dependency: { comparisons: 0, segmentsCompared: 0 },\n collectionIndex: { nodes: 0, builds: 0, builtItems: 0 },\n collectionView: { mappedItems: 0, idsScanned: 0, arraysCopied: 0 },\n materialized: { updated: 0, rebuilt: 0, notifications: 0 },\n});\ntype Counters = ReturnType<typeof counters>;\ntype DeepReadonly<T> = { readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K] };\nexport type ProfileSnapshot = DeepReadonly<Counters>;\nlet active: Counters | undefined;\nconst freeze = <T extends object>(value: T): DeepReadonly<T> => {\n Object.values(value).forEach(child => {\n if (child && typeof child === 'object') freeze(child);\n });\n return Object.freeze(value) as DeepReadonly<T>;\n};\nexport const profile = {\n projection: (key: keyof Counters['projection'], amount = 1) => {\n if (active) active.projection[key] += amount;\n },\n recorder: (key: keyof Counters['recorder'], amount = 1) => {\n if (active) active.recorder[key] += amount;\n },\n access: (key: keyof Counters['access']) => {\n if (active) active.access[key]++;\n },\n copy: {\n structure: () => {\n if (active) active.copy.structures++;\n },\n treeNode: () => {\n if (active) active.copy.treeNodes++;\n },\n shallowRecord: (items: number) => {\n if (active) active.copy.shallowRecordItems += items;\n },\n },\n equality: {\n call: () => {\n if (active) active.equality.calls++;\n },\n container: () => {\n if (active) active.equality.containers++;\n },\n },\n address: {\n listIndex: (items: number) => {\n if (active) {\n active.address.listIndexes++;\n active.address.listItems += items;\n }\n },\n schemaStep: () => {\n if (active) active.address.schemaSteps++;\n },\n documentStep: () => {\n if (active) active.address.documentSteps++;\n },\n prefixComparison: () => {\n if (active) active.address.prefixComparisons++;\n },\n segmentCompared: () => {\n if (active) active.address.segmentsCompared++;\n },\n },\n impact: {\n index: () => {\n if (active) active.impact.indexes++;\n },\n affects: () => {\n if (active) active.impact.affectsChecks++;\n },\n },\n dependency: {\n comparison: () => {\n if (active) active.dependency.comparisons++;\n },\n segmentCompared: () => {\n if (active) active.dependency.segmentsCompared++;\n },\n },\n collectionIndex: {\n node: () => {\n if (active) active.collectionIndex.nodes++;\n },\n build: (items: number) => {\n if (active) {\n active.collectionIndex.builds++;\n active.collectionIndex.builtItems += items;\n }\n },\n },\n collectionView: {\n mapped: () => {\n if (active) active.collectionView.mappedItems++;\n },\n idsScanned: (amount = 1) => {\n if (active) active.collectionView.idsScanned += amount;\n },\n arrayCopied: () => {\n if (active) active.collectionView.arraysCopied++;\n },\n },\n materialized: {\n updated: () => {\n if (active) active.materialized.updated++;\n },\n rebuilt: () => {\n if (active) active.materialized.rebuilt++;\n },\n notification: () => {\n if (active) active.materialized.notifications++;\n },\n },\n};\nexport type ProfileSession = { snapshot(): ProfileSnapshot; stop(): ProfileSnapshot };\nexport const startProfile = (): ProfileSession => {\n if (active) throw new Error('A document profile session is already active.');\n const value = counters();\n active = value;\n const snapshot = () => freeze(structuredClone(value));\n return {\n snapshot,\n stop: () => {\n if (active === value) active = undefined;\n return snapshot();\n },\n };\n};\nexport const measureProfile = <T>(run: () => T): { value: T; profile: ProfileSnapshot } => {\n const session = startProfile();\n try {\n return { value: run(), profile: session.stop() };\n } finally {\n session.stop();\n }\n};\n","import type { ReadonlyDocument } from '@/runtime/contract';\nimport type { ObjectSchema } from '@/schema/model';\nimport type { CollectionSelector, ValueSelector } from '@/schema/path';\nimport type {\n CollectionChange,\n CollectionDraft,\n CollectionRead,\n ExternalCollectionSource,\n ExternalValueSource,\n SourceContext,\n} from './contract';\nimport type { Readable } from '@/readable';\n\ndeclare const projectionDefinition: unique symbol;\ndeclare const keyedProjection: unique symbol;\ndeclare const writableInput: unique symbol;\ndeclare const writableCollectionInput: unique symbol;\n\n/** A lazy output reference with no materialized Runtime state. */\nexport type Projection<T> = {\n readonly [projectionDefinition]: T;\n};\n\n/** A projection whose output is a keyed collection with per-key change semantics. */\nexport type KeyedProjection<K extends string, V> = Projection<ReadonlyMap<K, V>> & {\n readonly [keyedProjection]: { readonly key: K; readonly value: V };\n};\n\n/** A writable source projection. */\nexport type Input<T> = Projection<T> & { readonly [writableInput]: true };\n\n/** A writable keyed collection source projection. */\nexport type CollectionInput<K extends string, V> = KeyedProjection<K, V> & {\n readonly [writableCollectionInput]: { readonly key: K; readonly value: V };\n};\n\nexport type CollectionInputDraft<K extends string, V> = {\n get(key: K): V | undefined;\n has(key: K): boolean;\n set(key: K, value: V): void;\n remove(key: K): void;\n};\n\nexport type ProjectionChange<P> =\n P extends KeyedProjection<infer K, infer V> ? CollectionChange<K, V> : undefined;\n\nexport type Equality = (a: unknown, b: unknown) => boolean;\n\nexport type OutputDefinition =\n | {\n readonly kind: 'value';\n readonly equality: Equality;\n readonly path?: readonly string[];\n }\n | {\n readonly kind: 'collection';\n readonly equality: Equality;\n readonly path?: readonly string[];\n };\n\nexport type ValueOutputEvaluation = {\n readonly kind: 'value';\n readonly previous: unknown;\n readonly next: () => unknown;\n readonly output: { set(value: unknown): void };\n};\n\nexport type CollectionOutputEvaluation = {\n readonly kind: 'collection';\n readonly previous: CollectionRead<string, unknown>;\n readonly next: CollectionRead<string, unknown>;\n readonly output: CollectionDraft<string, unknown>;\n};\n\nexport type OutputEvaluation = ValueOutputEvaluation | CollectionOutputEvaluation;\n\nexport type ProcessorEvaluation = {\n readonly reset: boolean;\n readonly cause: unknown;\n readonly sources: readonly SourceContext[];\n readonly outputs: readonly OutputEvaluation[];\n};\n\nexport type ProcessorInstance = {\n evaluate(input: ProcessorEvaluation): void;\n release?(): void;\n};\n\nexport type SourceAdapter =\n | {\n readonly kind: 'value-input';\n readonly initial: unknown;\n readonly equality: Equality;\n }\n | {\n readonly kind: 'collection-input';\n readonly initial: ReadonlyMap<string, unknown>;\n readonly equality: Equality;\n }\n | {\n readonly kind: 'readable';\n readonly readable: Readable<unknown>;\n readonly equality: Equality;\n }\n | {\n readonly kind: 'external-value';\n readonly source: ExternalValueSource<unknown>;\n readonly equality: Equality;\n }\n | {\n readonly kind: 'external-collection';\n readonly source: ExternalCollectionSource<string, unknown>;\n }\n | {\n readonly kind: 'document';\n readonly document: ReadonlyDocument<ObjectSchema<object>>;\n readonly selector: ValueSelector | CollectionSelector;\n };\n\nexport type SourceDefinition = {\n readonly kind: 'source';\n readonly source: SourceAdapter;\n readonly output: OutputDefinition;\n owner?: object;\n materialized?: true;\n};\n\nexport type ProcessorDefinition = {\n readonly kind: 'processor';\n readonly dependencies: readonly Projection<unknown>[];\n readonly outputs: readonly OutputDefinition[];\n readonly create: () => ProcessorInstance;\n readonly name?: string;\n owner?: object;\n materialized?: true;\n};\n\nexport type ProducerDefinition = SourceDefinition | ProcessorDefinition;\n\nexport type ProjectionRef = {\n readonly producer: ProducerDefinition;\n readonly output: number;\n};\n\nconst projections = new WeakMap<object, ProjectionRef>();\n\nconst defineRef = <T>(producer: ProducerDefinition, output: number): Projection<T> => {\n const handle = Object.freeze({}) as Projection<T>;\n projections.set(handle, Object.freeze({ producer, output }));\n return handle;\n};\n\nexport const projectionRef = (projection: Projection<unknown>): ProjectionRef => {\n const ref = projections.get(projection);\n if (!ref) throw new TypeError('Unknown projection definition.');\n return ref;\n};\n\nexport const producerOf = (projection: Projection<unknown>): ProducerDefinition =>\n projectionRef(projection).producer;\n\n/** Resolves the immutable output description owned by a projection definition. */\nexport const outputDefinitionOf = (projection: Projection<unknown>): OutputDefinition => {\n const ref = projectionRef(projection);\n const producer = ref.producer;\n const output = producer.kind === 'source' ? producer.output : producer.outputs[ref.output];\n if (!output) throw new TypeError('Projection output does not exist.');\n return output;\n};\n\nexport const isProjection = (value: unknown): value is Projection<unknown> =>\n value !== null && typeof value === 'object' && projections.has(value);\n\nexport const ownProjections = (\n projections: readonly Projection<unknown>[],\n owner: object\n): void => {\n const producers = new Set(projections.map(producerOf));\n for (const producer of producers) {\n if (producer.owner !== undefined && producer.owner !== owner)\n throw new TypeError('Projection producer already belongs to another scope.');\n if (producer.owner === undefined && producer.materialized)\n throw new TypeError('A materialized root projection cannot become scope-owned.');\n if (producer.kind !== 'processor') continue;\n for (const dependency of producer.dependencies) {\n const dependencyOwner = producerOf(dependency).owner;\n if (dependencyOwner !== undefined && dependencyOwner !== owner)\n throw new TypeError('A scope cannot depend on another scope.');\n }\n }\n for (const producer of producers) producer.owner = owner;\n};\n\nconst freezeOutput = (output: OutputDefinition): OutputDefinition =>\n Object.freeze({\n kind: output.kind,\n equality: output.equality,\n ...(output.path ? { path: Object.freeze([...output.path]) } : {}),\n });\n\nexport const defineProcessor = (definition: {\n readonly dependencies: readonly Projection<unknown>[];\n readonly outputs: readonly OutputDefinition[];\n readonly create: () => ProcessorInstance;\n readonly name?: string;\n}): readonly Projection<unknown>[] => {\n if (!Array.isArray(definition.dependencies))\n throw new TypeError('Projection dependencies must be an array.');\n definition.dependencies.forEach(projectionRef);\n if (!definition.outputs.length) throw new TypeError('Projection processor requires an output.');\n const producer: ProcessorDefinition = {\n kind: 'processor',\n dependencies: Object.freeze([...definition.dependencies]),\n outputs: Object.freeze(definition.outputs.map(freezeOutput)),\n create: definition.create,\n ...(definition.name ? { name: definition.name } : {}),\n };\n return Object.freeze(producer.outputs.map((_, output) => defineRef<unknown>(producer, output)));\n};\n\nexport const defineSource = <T>(source: SourceAdapter, output: OutputDefinition): Projection<T> => {\n const producer: SourceDefinition = {\n kind: 'source',\n source,\n output: freezeOutput(output),\n };\n return defineRef<T>(producer, 0);\n};\n","import type { CollectionRead } from '@/projection/contract';\n\nexport const mapRead = <K extends string, V>(value: ReadonlyMap<K, V>): CollectionRead<K, V> => {\n let ids: readonly K[] | undefined;\n return {\n get: key => value.get(key),\n has: key => value.has(key),\n ids: () => (ids ??= Object.freeze([...value.keys()])),\n };\n};\n\n/** Immutable map-like view over a CollectionRead. */\nexport const collectionView = <K extends string, V>(\n read: CollectionRead<K, V>,\n knownIds?: readonly K[]\n): ReadonlyMap<K, V> => {\n const ids = knownIds ?? read.ids();\n const entries = function* (): IterableIterator<[K, V]> {\n for (const key of ids) yield [key, read.get(key) as V];\n };\n const values = function* (): IterableIterator<V> {\n for (const key of ids) yield read.get(key) as V;\n };\n const view: ReadonlyMap<K, V> = {\n get: key => read.get(key),\n has: key => read.has(key),\n get size() {\n return ids.length;\n },\n keys: () => ids[Symbol.iterator](),\n values,\n entries,\n forEach: (callback, thisArg) => {\n for (const key of ids) callback.call(thisArg, read.get(key) as V, key, view);\n },\n [Symbol.iterator]: entries,\n };\n return Object.freeze(view);\n};\n\n/** Eager durable view used when a processor result may retain its dependency value. */\nexport const snapshotCollectionView = <K extends string, V>(\n read: CollectionRead<K, V>\n): ReadonlyMap<K, V> => {\n const ids = read.ids();\n const values = new Map<K, V>();\n for (const key of ids) values.set(key, read.get(key) as V);\n return collectionView(mapRead(values), ids);\n};\n","import { isPlainObject } from '@/value/record';\nimport { snapshotCollectionView } from '@/projection/collection/view';\nimport type { SourceContext } from './contract';\nimport { isProjection, projectionRef, type Projection } from './definition';\n\nexport type CompiledProjectionDependencies = {\n readonly names: readonly string[];\n readonly projections: readonly Projection<unknown>[];\n};\n\nexport type NamedDependencyEntry = {\n readonly name: string;\n readonly value: unknown;\n};\n\n/** Owns validation of the shared named dependency object shape. */\nexport const readNamedDependencyEntries = (\n dependencies: unknown,\n label: string\n): readonly NamedDependencyEntry[] => {\n if (!isPlainObject(dependencies) || isProjection(dependencies))\n throw new TypeError(`${label} dependencies must be a plain object.`);\n const entries: NamedDependencyEntry[] = [];\n for (const name of Reflect.ownKeys(dependencies)) {\n if (typeof name !== 'string') throw new TypeError(`${label} dependency names must be strings.`);\n const descriptor = Object.getOwnPropertyDescriptor(dependencies, name);\n if (!descriptor?.enumerable || !('value' in descriptor))\n throw new TypeError(`${label} dependencies must be enumerable data properties.`);\n entries.push(Object.freeze({ name, value: descriptor.value }));\n }\n return Object.freeze(entries);\n};\n\n/** Creates the durable dependency value exposed to pure derive callbacks. */\nexport const snapshotDependencyValue = (source: SourceContext): unknown =>\n source.kind === 'value' ? source.value : snapshotCollectionView(source.read);\n\n/** Compiles the shared named Projection dependency declaration contract. */\nexport const compileProjectionDependencies = (\n dependencies: unknown,\n label: string\n): CompiledProjectionDependencies => {\n const names: string[] = [];\n const projections: Projection<unknown>[] = [];\n for (const { name, value } of readNamedDependencyEntries(dependencies, label)) {\n const projection = value as Projection<unknown>;\n projectionRef(projection);\n names.push(name);\n projections.push(projection);\n }\n return Object.freeze({\n names: Object.freeze(names),\n projections: Object.freeze(projections),\n });\n};\n","/** Allocation-free strict equality for ordered readonly arrays. */\nexport const sameArray = <T>(left: readonly T[], right: readonly T[]): boolean => {\n if (left === right) return true;\n if (left.length !== right.length) return false;\n for (let index = 0; index < left.length; index++) if (left[index] !== right[index]) return false;\n return true;\n};\n\n/** Owns an immutable shallow snapshot while reusing arrays that are already frozen. */\nexport const snapshotArray = <T>(values: readonly T[]): readonly T[] =>\n Object.isFrozen(values) ? values : Object.freeze([...values]);\n\n/** Compares an iterable with an ordered array without materializing the iterable. */\nexport const iterableMatchesArray = <T>(values: Iterable<T>, expected: readonly T[]): boolean => {\n let index = 0;\n for (const value of values) {\n if (index >= expected.length || value !== expected[index]) return false;\n index++;\n }\n return index === expected.length;\n};\n","import type { CollectionChange } from '@/projection/contract';\nimport { sameArray, snapshotArray } from '@/value/array';\n\ntype Added<K extends string, V> = { readonly key: K; readonly after: V };\ntype Updated<K extends string, V> = {\n readonly key: K;\n readonly before: V;\n readonly after: V;\n};\ntype Removed<K extends string, V> = { readonly key: K; readonly before: V };\n\nconst transitionContains = <K extends string>(\n entries: readonly { readonly key: K }[],\n key: K\n): boolean => {\n for (const entry of entries) if (entry.key === key) return true;\n return false;\n};\n\nconst transitionSet = <K extends string>(\n entries: readonly { readonly key: K }[]\n): ReadonlySet<K> | undefined => {\n // Small net membership changes are overwhelmingly common. Linear lookup avoids\n // allocating a Set while keeping large batches O(n).\n if (entries.length <= 4) return undefined;\n const keys = new Set<K>();\n for (const entry of entries) keys.add(entry.key);\n return keys;\n};\n\nconst nextExcluding = <K extends string>(\n iterator: Iterator<K>,\n excluded: readonly { readonly key: K }[],\n index: ReadonlySet<K> | undefined\n): IteratorResult<K> => {\n while (true) {\n const next = iterator.next();\n if (next.done || !(index ? index.has(next.value) : transitionContains(excluded, next.value)))\n return next;\n }\n};\n\n/** Compares common-member order from known transitions without materializing common arrays. */\nconst transitionOrderChanged = <K extends string>(\n before: Iterable<K>,\n after: Iterable<K>,\n removed: readonly { readonly key: K }[],\n added: readonly { readonly key: K }[]\n): boolean => {\n const removedKeys = transitionSet(removed);\n const addedKeys = transitionSet(added);\n const beforeIterator = before[Symbol.iterator]();\n const afterIterator = after[Symbol.iterator]();\n while (true) {\n const left = nextExcluding(beforeIterator, removed, removedKeys);\n const right = nextExcluding(afterIterator, added, addedKeys);\n if (left.done || right.done) return left.done !== right.done;\n if (left.value !== right.value) return true;\n }\n};\n\nconst nextPresentIn = <K, V>(\n iterator: Iterator<K>,\n membership: ReadonlyMap<K, V>\n): IteratorResult<K> => {\n while (true) {\n const next = iterator.next();\n if (next.done || membership.has(next.value)) return next;\n }\n};\n\n/** Compares common-member order between two map snapshots without key snapshots or closures. */\nconst mapOrderChanged = <K, V>(before: ReadonlyMap<K, V>, after: ReadonlyMap<K, V>): boolean => {\n const beforeIterator = before.keys();\n const afterIterator = after.keys();\n while (true) {\n const left = nextPresentIn(beforeIterator, after);\n const right = nextPresentIn(afterIterator, before);\n if (left.done || right.done) return left.done !== right.done;\n if (left.value !== right.value) return true;\n }\n};\n\nconst sealIncrementalChange = <K extends string, V>(\n added: Added<K, V>[],\n updated: Updated<K, V>[],\n removed: Removed<K, V>[],\n order?: { readonly before: readonly K[]; readonly after: readonly K[] }\n): CollectionChange<K, V> | undefined => {\n if (!added.length && !updated.length && !removed.length && !order) return undefined;\n return Object.freeze({\n kind: 'incremental' as const,\n added: Object.freeze(added),\n updated: Object.freeze(updated),\n removed: Object.freeze(removed),\n ...(order\n ? {\n order: Object.freeze({\n before: snapshotArray(order.before),\n after: snapshotArray(order.after),\n }),\n }\n : {}),\n });\n};\n\n/** Builds the canonical incremental CollectionChange from already-known net transitions. */\nexport const createCollectionChange = <K extends string, V>(input: {\n readonly added: Added<K, V>[];\n readonly updated: Updated<K, V>[];\n readonly removed: Removed<K, V>[];\n readonly beforeOrder: readonly K[];\n readonly afterOrder: readonly K[];\n}): CollectionChange<K, V> | undefined => {\n let orderChanged = false;\n if (input.beforeOrder !== input.afterOrder) {\n if (!input.added.length && !input.removed.length)\n orderChanged = !sameArray(input.beforeOrder, input.afterOrder);\n else\n orderChanged = transitionOrderChanged(\n input.beforeOrder,\n input.afterOrder,\n input.removed,\n input.added\n );\n }\n return sealIncrementalChange(\n input.added,\n input.updated,\n input.removed,\n orderChanged ? { before: input.beforeOrder, after: input.afterOrder } : undefined\n );\n};\n\n/** Exact fallback diff between two published map-like snapshots. */\nexport const diffCollection = <K extends string, V>(\n previous: ReadonlyMap<K, V>,\n current: ReadonlyMap<K, V>,\n isEqual: (previous: V, next: V) => boolean = Object.is\n): CollectionChange<K, V> | undefined => {\n const added: Added<K, V>[] = [];\n const updated: Updated<K, V>[] = [];\n const removed: Removed<K, V>[] = [];\n for (const [key, before] of previous) {\n if (!current.has(key)) removed.push({ key, before });\n else {\n const after = current.get(key) as V;\n if (!isEqual(before, after)) updated.push({ key, before, after });\n }\n }\n for (const [key, after] of current) if (!previous.has(key)) added.push({ key, after });\n const orderChanged = mapOrderChanged(previous, current);\n return sealIncrementalChange(\n added,\n updated,\n removed,\n orderChanged\n ? {\n before: Object.freeze([...previous.keys()]),\n after: Object.freeze([...current.keys()]),\n }\n : undefined\n );\n};\n\nconst changedKeys = function* <K extends string, V>(\n change: Extract<CollectionChange<K, V>, { readonly kind: 'incremental' }>\n): IterableIterator<K> {\n if ((change as CollectionChange<K, V>).kind !== 'incremental')\n throw new TypeError('collectionChange.keys requires an incremental CollectionChange.');\n for (const entry of change.added) yield entry.key;\n for (const entry of change.updated) yield entry.key;\n for (const entry of change.removed) yield entry.key;\n};\n\nexport const collectionChange: {\n readonly keys: <K extends string, V>(\n change: Extract<CollectionChange<K, V>, { readonly kind: 'incremental' }>\n ) => Iterable<K>;\n} = Object.freeze({ keys: changedKeys });\n\nexport const collectionHasStructuralChange = <K extends string, V>(\n change: CollectionChange<K, V>\n): boolean =>\n change.kind === 'reset' || Boolean(change.added.length || change.removed.length || change.order);\n\nexport const collectionChangeTouchesKey = <K extends string, V>(\n change: Extract<CollectionChange<K, V>, { readonly kind: 'incremental' }>,\n key: K\n): boolean => {\n for (const entry of change.added) if (entry.key === key) return true;\n for (const entry of change.updated) if (entry.key === key) return true;\n for (const entry of change.removed) if (entry.key === key) return true;\n return false;\n};\n\nexport const collectionChangeIntersects = <K extends string, V>(\n change: Extract<CollectionChange<K, V>, { readonly kind: 'incremental' }>,\n keys: ReadonlySet<K>\n): boolean => {\n for (const entry of change.added) if (keys.has(entry.key)) return true;\n for (const entry of change.updated) if (keys.has(entry.key)) return true;\n for (const entry of change.removed) if (keys.has(entry.key)) return true;\n return false;\n};\n","import type { CollectionImpact } from '@/impact';\nimport type { Unsubscribe } from '@/runtime/contract';\n\n/** Scheduler-owned metadata for one Runtime batch. */\nexport type BatchContext = {\n readonly id: number;\n readonly cause?: unknown;\n};\n\n/** The one processor-facing collection transition protocol. */\nexport type CollectionChange<K extends string, V> =\n | { readonly kind: 'reset' }\n | {\n readonly kind: 'incremental';\n readonly added: readonly { readonly key: K; readonly after: V }[];\n readonly updated: readonly {\n readonly key: K;\n readonly before: V;\n readonly after: V;\n }[];\n readonly removed: readonly { readonly key: K; readonly before: V }[];\n readonly order?: {\n readonly before: readonly K[];\n readonly after: readonly K[];\n };\n };\n\nexport type ValueContext<T> = {\n readonly kind: 'value';\n readonly value: T;\n readonly revision: number;\n readonly reset: boolean;\n readonly cause?: unknown;\n};\n\nexport type CollectionRead<K extends string, V> = {\n get(key: K): V | undefined;\n has(key: K): boolean;\n ids(): readonly K[];\n};\n\nexport type ExternalCollectionRead<K extends string, V> = {\n readonly get: (key: K) => V | undefined;\n readonly has: (key: K) => boolean;\n readonly ids: () => readonly K[];\n};\n\nexport type CollectionContext<K extends string, V> = {\n readonly kind: 'collection';\n readonly read: CollectionRead<K, V>;\n readonly change: CollectionChange<K, V> | undefined;\n readonly revision: number;\n readonly reset: boolean;\n readonly cause?: unknown;\n};\n\nexport type SourceContext = ValueContext<unknown> | CollectionContext<string, unknown>;\n\nexport type ExternalValueSource<T> = {\n readonly kind: 'value';\n current(): T;\n revision(): number;\n subscribe(listener: (event: ExternalValueEvent<T>) => void): Unsubscribe;\n};\n\nexport type ExternalCollectionSource<K extends string, V> = {\n readonly kind: 'collection';\n current(): ExternalCollectionRead<K, V>;\n revision(): number;\n subscribe(listener: (event: ExternalCollectionEvent<K, V>) => void): Unsubscribe;\n};\n\nexport type ExternalValueEvent<T> = {\n readonly value: T;\n readonly revision: number;\n readonly reset?: boolean;\n readonly cause?: unknown;\n};\n\nexport type ExternalCollectionEvent<K extends string, V> = {\n /** Stable read from the source before this event or external batch. */\n readonly previous: ExternalCollectionRead<K, V>;\n readonly revision: number;\n /** Optional document-style hint; the adapter resolves the canonical change. */\n readonly impact?: CollectionImpact<K>;\n readonly cause?: unknown;\n};\n\nexport type CollectionDraft<K extends string, V> = {\n set(key: K, value: V): void;\n remove(key: K): void;\n order(ids: readonly K[]): void;\n};\n\nexport class ProjectionError extends Error {\n readonly cause: unknown;\n\n constructor(\n readonly phase: 'processor' | 'listener' | 'source' | 'blocked',\n cause: unknown\n ) {\n super(`Projection ${phase} failed.`, { cause });\n this.name = 'ProjectionError';\n this.cause = cause;\n }\n}\n\nexport class ProjectionDisposedError extends Error {\n constructor() {\n super('Projection has been disposed.');\n this.name = 'ProjectionDisposedError';\n }\n}\n","import { profile } from '@/profile';\nimport type { ObserverError, Unsubscribe } from '@/runtime/contract';\nimport type { BatchContext, CollectionChange, SourceContext } from '@/projection/contract';\nimport { ProjectionDisposedError, ProjectionError } from '@/projection/contract';\n\ntype BatchOptions = { readonly cause?: unknown };\n\ntype ProducerBase = {\n readonly name: string;\n readonly outputs: readonly OutputRecord[];\n fault: ProjectionError | undefined;\n disposed: boolean;\n clear(): void;\n release(): void;\n};\n\nexport type OutputListener = (change?: CollectionChange<string, unknown>) => void;\n\nexport type OutputRecord = {\n readonly kind: 'value' | 'collection';\n readonly owner: ProducerRecord;\n context(active: () => boolean): SourceContext;\n current(): unknown;\n revision(): number;\n reset(): boolean;\n subscribe(listener: OutputListener): Unsubscribe;\n emit(call: (listener: OutputListener, change?: CollectionChange<string, unknown>) => void): void;\n hasConsumers(): boolean;\n forEachConsumer(run: (consumer: ProcessorRecord) => void): void;\n attachConsumer(consumer: ProcessorRecord): void;\n detachConsumer(consumer: ProcessorRecord): void;\n clear(): void;\n release(): void;\n};\n\nexport type SourceBoundaryRecord = ProducerBase & {\n readonly kind: 'source';\n readonly outputs: readonly [OutputRecord];\n pendingCause(): unknown;\n recovering(): boolean;\n prepare(cause: unknown): { readonly changed: boolean; readonly force: boolean };\n publish(): void;\n};\n\nexport type ProcessorRecord = ProducerBase & {\n readonly kind: 'processor';\n readonly dependencies: readonly OutputRecord[];\n readonly order: number;\n evaluate(reset: boolean, cause: unknown, recreate?: boolean): readonly OutputRecord[];\n publish(): void;\n};\n\nexport type ProducerRecord = SourceBoundaryRecord | ProcessorRecord;\n\nexport const createScheduler = (onError: (error: ProjectionError) => void) => {\n let disposed = false;\n let depth = 0;\n let batchSequence = 0;\n let activeBatch: BatchContext | undefined;\n let phase: 'idle' | 'compute' | 'notify' = 'idle';\n let sequence = 0;\n const sources = new Set<SourceBoundaryRecord>();\n const processors = new Set<ProcessorRecord>();\n const pendingSources = new Set<SourceBoundaryRecord>();\n const heap: ProcessorRecord[] = [];\n const queued = new Set<ProcessorRecord>();\n const completed = new Set<ProcessorRecord>();\n const emissions = new Set<OutputRecord>();\n const errors: ProjectionError[] = [];\n let reportingFailures: unknown[] = [];\n const guards = new Set<(locked: boolean) => void>();\n\n const assertActive = () => {\n if (disposed) throw new ProjectionDisposedError();\n };\n const assertIdle = () => {\n assertActive();\n if (phase !== 'idle')\n throw new Error('Projection cannot be re-entered during processing or notification.');\n };\n const lock = (value: boolean) => guards.forEach(guard => guard(value));\n\n const enqueue = (processor: ProcessorRecord) => {\n if (processor.disposed || queued.has(processor)) return;\n queued.add(processor);\n profile.projection('scheduledNodes');\n let index = heap.length;\n heap.push(processor);\n while (index > 0) {\n const parent = (index - 1) >> 1;\n if (heap[parent].order < processor.order) break;\n heap[index] = heap[parent];\n index = parent;\n }\n heap[index] = processor;\n };\n\n const pop = (): ProcessorRecord => {\n const first = heap[0];\n const last = heap.pop()!;\n if (heap.length) {\n let index = 0;\n while (index * 2 + 1 < heap.length) {\n let child = index * 2 + 1;\n if (child + 1 < heap.length && heap[child + 1].order < heap[child].order) child++;\n if (last.order < heap[child].order) break;\n heap[index] = heap[child];\n index = child;\n }\n heap[index] = last;\n }\n return first;\n };\n\n const errorFor = (\n producer: ProducerRecord,\n cause: unknown,\n kind: ProjectionError['phase'] = producer.kind === 'source' ? 'source' : 'processor'\n ) => new ProjectionError(kind, cause);\n\n const capture = (source: SourceBoundaryRecord) => {\n if (disposed) return;\n if (phase !== 'idle') {\n source.fault = errorFor(\n source,\n new Error('Source changed while projection was running.'),\n 'source'\n );\n errors.push(source.fault);\n throw source.fault;\n }\n pendingSources.add(source);\n profile.projection('sourceEvents');\n if (source.fault) errors.push(source.fault);\n };\n\n const settleCause = (): unknown => {\n if (activeBatch?.cause !== undefined) return activeBatch.cause;\n for (const source of pendingSources) {\n const cause = source.pendingCause();\n if (cause !== undefined) return cause;\n }\n return undefined;\n };\n\n const settle = () => {\n if (disposed || depth || phase !== 'idle') return;\n phase = 'compute';\n lock(true);\n const cause = settleCause();\n try {\n for (const source of pendingSources) {\n if (source.disposed) continue;\n const wasFaulted = source.fault !== undefined;\n let changed = false;\n let force = false;\n if (!source.fault || source.recovering()) {\n try {\n const prepared = source.prepare(cause);\n changed = prepared.changed;\n force = prepared.force;\n source.fault = undefined;\n } catch (failure) {\n source.fault = errorFor(source, failure, 'source');\n errors.push(source.fault);\n }\n }\n const recovered = wasFaulted && !source.fault;\n if (changed) source.publish();\n if (source.fault || changed || force || recovered) {\n const output = source.outputs[0];\n emissions.add(output);\n output.forEachConsumer(enqueue);\n }\n }\n\n while (heap.length) {\n const processor = pop();\n if (processor.disposed) continue;\n const wasFaulted = processor.fault !== undefined;\n profile.projection('processedNodes');\n let changedOutputs: readonly OutputRecord[] = Object.freeze([]);\n const blocked = processor.dependencies.find(\n output => output.owner.fault || output.owner.disposed\n );\n if (blocked) {\n processor.fault = errorFor(\n processor,\n blocked.owner.fault ?? new ProjectionDisposedError(),\n 'blocked'\n );\n } else {\n const reset = wasFaulted || processor.dependencies.some(output => output.reset());\n try {\n changedOutputs = processor.evaluate(reset, cause, wasFaulted);\n const dependencyFailure = processor.dependencies.find(output => output.owner.fault)\n ?.owner.fault;\n if (dependencyFailure) throw dependencyFailure;\n processor.fault = undefined;\n } catch (failure) {\n const error = errorFor(processor, failure);\n processor.fault = error;\n if (!reset) {\n try {\n changedOutputs = processor.evaluate(true, cause, true);\n const dependencyFailure = processor.dependencies.find(output => output.owner.fault)\n ?.owner.fault;\n if (dependencyFailure) throw dependencyFailure;\n processor.fault = undefined;\n errors.push(error);\n } catch (rebuildFailure) {\n processor.fault = errorFor(processor, rebuildFailure);\n errors.push(processor.fault);\n }\n } else errors.push(error);\n }\n }\n completed.add(processor);\n const recovered = wasFaulted && !processor.fault;\n if (processor.fault) {\n processor.outputs.forEach(output => {\n emissions.add(output);\n output.forEachConsumer(enqueue);\n });\n } else {\n if (changedOutputs.length) {\n processor.publish();\n changedOutputs.forEach(output => emissions.add(output));\n }\n const propagated = recovered ? processor.outputs : changedOutputs;\n propagated.forEach(output => output.forEachConsumer(enqueue));\n }\n if (processor.fault || changedOutputs.length) {\n profile.projection('publishedNodes');\n }\n }\n } finally {\n lock(false);\n phase = 'idle';\n }\n };\n\n const flush = (): readonly ObserverError[] => {\n if (disposed || depth) return [];\n if (pendingSources.size || completed.size) profile.projection('flushes');\n phase = 'notify';\n lock(true);\n const reportFailures: unknown[] = [];\n try {\n emissions.forEach(output =>\n output.emit((listener, change) => {\n try {\n listener(change);\n } catch (cause) {\n errors.push(errorFor(output.owner, cause, 'listener'));\n }\n })\n );\n for (const error of errors.slice()) {\n try {\n onError(error);\n } catch (cause) {\n reportFailures.push(cause);\n }\n }\n return Object.freeze([\n ...errors.map(error =>\n Object.freeze({\n phase: error.phase === 'listener' ? ('listener' as const) : ('processor' as const),\n error,\n })\n ),\n ...reportFailures.map(error => Object.freeze({ phase: 'listener' as const, error })),\n ]);\n } finally {\n pendingSources.forEach(source => source.clear());\n completed.forEach(processor => processor.clear());\n pendingSources.clear();\n queued.clear();\n completed.clear();\n emissions.clear();\n errors.length = 0;\n reportingFailures = reportFailures;\n lock(false);\n phase = 'idle';\n }\n };\n\n const run = () => {\n settle();\n const result = flush();\n const failures = reportingFailures;\n reportingFailures = [];\n if (failures.length) throw new AggregateError(failures, 'Projection error reporter failed.');\n return result;\n };\n\n const batch = <T>(callback: () => T, options?: BatchOptions): T => {\n assertIdle();\n const outer = depth === 0;\n if (outer)\n activeBatch = Object.freeze({\n id: ++batchSequence,\n ...(options?.cause === undefined ? {} : { cause: options.cause }),\n });\n depth++;\n let failed = false;\n try {\n const value = callback();\n assertSynchronous(value);\n return value;\n } catch (error) {\n failed = true;\n throw error;\n } finally {\n depth--;\n if (!depth) {\n try {\n if (failed) {\n try {\n run();\n } catch {\n /* The original application error retains priority. */\n }\n } else run();\n } finally {\n activeBatch = undefined;\n }\n }\n }\n };\n\n const releaseProducer = (producer: ProducerRecord) => {\n assertIdle();\n if (producer.outputs.some(output => output.hasConsumers()))\n throw new Error('Projection producer is still used by another processor.');\n producer.disposed = true;\n if (producer.kind === 'processor') {\n producer.dependencies.forEach(output => output.detachConsumer(producer));\n processors.delete(producer);\n queued.delete(producer);\n completed.delete(producer);\n } else {\n sources.delete(producer);\n pendingSources.delete(producer);\n }\n const failures: unknown[] = [];\n try {\n producer.release();\n } catch (error) {\n failures.push(error);\n }\n try {\n producer.clear();\n } catch (error) {\n failures.push(error);\n }\n producer.outputs.forEach(output => emissions.delete(output));\n if (failures.length) throw failures[0];\n };\n\n return {\n assertActive,\n assertIdle,\n capture,\n settle,\n flush,\n run,\n registerGuard(guard: (locked: boolean) => void): Unsubscribe {\n assertActive();\n guards.add(guard);\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n guards.delete(guard);\n };\n },\n get active() {\n return !disposed;\n },\n addSource(source: SourceBoundaryRecord) {\n assertIdle();\n sources.add(source);\n },\n addProcessor(processor: ProcessorRecord) {\n assertIdle();\n processors.add(processor);\n processor.dependencies.forEach(output => output.attachConsumer(processor));\n },\n releaseProducer,\n order: () => sequence++,\n initialize<T>(callback: () => T): T {\n assertIdle();\n phase = 'compute';\n lock(true);\n try {\n return callback();\n } finally {\n lock(false);\n phase = 'idle';\n }\n },\n batch,\n batchContext: () => activeBatch,\n dispose() {\n if (disposed) return;\n assertIdle();\n disposed = true;\n const failures: unknown[] = [];\n processors.forEach(processor => {\n processor.disposed = true;\n try {\n processor.release();\n } catch (error) {\n failures.push(error);\n }\n });\n sources.forEach(source => {\n source.disposed = true;\n try {\n source.release();\n } catch (error) {\n failures.push(error);\n }\n });\n processors.clear();\n sources.clear();\n pendingSources.clear();\n heap.length = 0;\n queued.clear();\n completed.clear();\n emissions.clear();\n guards.clear();\n errors.length = 0;\n reportingFailures = [];\n if (failures.length) throw new AggregateError(failures, 'Projection cleanup failed.');\n },\n };\n};\n\nexport type Scheduler = ReturnType<typeof createScheduler>;\n\nexport const assertSynchronous = (value: unknown): void => {\n if (\n value != null &&\n (typeof value === 'object' || typeof value === 'function') &&\n 'then' in value &&\n typeof value.then === 'function'\n )\n throw new TypeError('Projection callbacks must be synchronous.');\n};\n\nexport const assertScope = (active: () => boolean) => {\n if (!active()) throw new Error('Projection reader or writer is no longer active.');\n};\n","import { sameArray, snapshotArray } from '@/value/array';\n\nexport type KeyRelation = {\n replaceOne(left: string, right: string | undefined): boolean;\n replace(left: string, right: readonly string[]): boolean;\n delete(left: string): boolean;\n forward(left: string): readonly string[] | undefined;\n reverse(right: string): ReadonlySet<string> | undefined;\n lefts(): IterableIterator<string>;\n rights(): IterableIterator<string>;\n clear(): void;\n};\n\n/** Runtime-local domain-neutral many-to-many keyed relation. */\nexport const createKeyRelation = (): KeyRelation => {\n const forward = new Map<string, readonly string[]>();\n const reverse = new Map<string, Set<string>>();\n\n const detach = (left: string, right: readonly string[]): void => {\n for (const key of right) {\n const dependents = reverse.get(key);\n dependents?.delete(left);\n if (dependents?.size === 0) reverse.delete(key);\n }\n };\n\n const attach = (left: string, right: readonly string[]): void => {\n for (const key of right) {\n const dependents = reverse.get(key);\n if (dependents) dependents.add(left);\n else reverse.set(key, new Set([left]));\n }\n };\n\n return {\n replaceOne(left, right) {\n const previous = forward.get(left);\n if (right === undefined) {\n if (!previous) return false;\n detach(left, previous);\n forward.delete(left);\n return true;\n }\n if (previous?.length === 1 && previous[0] === right) return false;\n if (previous) detach(left, previous);\n const next = Object.freeze([right]);\n forward.set(left, next);\n attach(left, next);\n return true;\n },\n replace(left, right) {\n const previous = forward.get(left);\n if (previous ? sameArray(previous, right) : right.length === 0) return false;\n if (previous) detach(left, previous);\n if (!right.length) {\n forward.delete(left);\n return true;\n }\n const next = snapshotArray(right);\n forward.set(left, next);\n attach(left, next);\n return true;\n },\n delete(left) {\n const previous = forward.get(left);\n if (!previous) return false;\n detach(left, previous);\n forward.delete(left);\n return true;\n },\n forward: left => forward.get(left),\n reverse: right => reverse.get(right),\n lefts: () => forward.keys(),\n rights: () => reverse.keys(),\n clear() {\n forward.clear();\n reverse.clear();\n },\n };\n};\n","import type { Synchronous } from '@/runtime/contract';\nimport { isPlainObject } from '@/value/record';\nimport { collectionView, mapRead } from '@/projection/collection/view';\nimport type { SourceContext } from '@/projection/contract';\nimport { readNamedDependencyEntries, snapshotDependencyValue } from '@/projection/dependency';\nimport {\n isProjection,\n outputDefinitionOf,\n type KeyedProjection,\n type Projection,\n} from '@/projection/definition';\nimport { assertSynchronous } from '@/projection/graph/scheduler';\nimport { createKeyRelation, type KeyRelation } from './relation';\n\nexport type SingularKeyedDependency<\n DriverKey extends string,\n DriverValue,\n SourceKey extends string,\n SourceValue,\n> = {\n readonly source: KeyedProjection<SourceKey, SourceValue>;\n readonly key: (value: DriverValue, key: DriverKey) => Synchronous<SourceKey | undefined>;\n readonly keys?: never;\n};\n\nexport type PluralKeyedDependency<\n DriverKey extends string,\n DriverValue,\n SourceKey extends string,\n SourceValue,\n> = {\n readonly source: KeyedProjection<SourceKey, SourceValue>;\n readonly keys: (value: DriverValue, key: DriverKey) => Synchronous<readonly SourceKey[]>;\n readonly key?: never;\n};\n\nexport type KeyedDependency<DriverKey extends string, DriverValue> =\n | (Projection<unknown> & {\n readonly source?: never;\n readonly key?: never;\n readonly keys?: never;\n })\n | SingularKeyedDependency<DriverKey, DriverValue, string, unknown>\n | PluralKeyedDependency<DriverKey, DriverValue, string, unknown>;\n\nexport type KeyedDependencyRecord<DriverKey extends string, DriverValue> = Readonly<\n Record<string, KeyedDependency<DriverKey, DriverValue>>\n>;\n\nexport type KeyedDependencies<DriverKey extends string, DriverValue, D extends object> = {\n readonly [P in keyof D]: P extends string ? KeyedDependency<DriverKey, DriverValue> : never;\n};\n\nexport type KeyedDependencyValues<D extends object> = {\n readonly [P in keyof D]: D[P] extends {\n readonly source: KeyedProjection<infer K extends string, infer V>;\n readonly keys: (...args: never[]) => unknown;\n }\n ? ReadonlyMap<K, V>\n : D[P] extends {\n readonly source: KeyedProjection<infer _K extends string, infer V>;\n }\n ? V | undefined\n : D[P] extends Projection<infer T>\n ? T\n : never;\n};\n\ntype CompiledDynamicKeyedDependency =\n | {\n readonly kind: 'one';\n readonly projection: Projection<unknown>;\n readonly select: (value: unknown, key: string) => unknown;\n }\n | {\n readonly kind: 'many';\n readonly projection: Projection<unknown>;\n readonly select: (value: unknown, key: string) => unknown;\n };\n\ntype CompiledKeyedDependency =\n | {\n readonly name: string;\n readonly kind: 'global';\n readonly projection: Projection<unknown>;\n }\n | ({ readonly name: string } & CompiledDynamicKeyedDependency);\n\nexport type CompiledKeyedDependencies = {\n readonly entries: readonly CompiledKeyedDependency[];\n readonly projections: readonly Projection<unknown>[];\n};\n\nexport const outputKind = (projection: Projection<unknown>): 'value' | 'collection' =>\n outputDefinitionOf(projection).kind;\n\nexport const assertKeyedProjection = (projection: Projection<unknown>, role: string): void => {\n if (outputKind(projection) !== 'collection')\n throw new TypeError(`${role} must be a keyed collection projection.`);\n};\n\nconst compileDynamicDependency = (\n value: unknown,\n label: string\n): CompiledDynamicKeyedDependency => {\n if (!isPlainObject(value) || isProjection(value))\n throw new TypeError(\n `${label} dependencies must be projections or singular/plural keyed lookups.`\n );\n const candidate: { source?: unknown; key?: unknown; keys?: unknown } = {};\n const allowed = new Set(['source', 'key', 'keys']);\n let hasKey = false;\n let hasKeys = false;\n for (const name of Reflect.ownKeys(value)) {\n if (typeof name !== 'string' || !allowed.has(name))\n throw new TypeError(`${label} dynamic keyed dependency contains an unknown property.`);\n const descriptor = Object.getOwnPropertyDescriptor(value, name);\n if (!descriptor?.enumerable || !('value' in descriptor))\n throw new TypeError(`${label} dynamic keyed dependency must use enumerable data properties.`);\n candidate[name as 'source' | 'key' | 'keys'] = descriptor.value;\n if (name === 'key') hasKey = true;\n if (name === 'keys') hasKeys = true;\n }\n if (!isProjection(candidate.source))\n throw new TypeError(`${label} dynamic keyed dependency source must be a projection.`);\n if (hasKey === hasKeys)\n throw new TypeError(\n `${label} dynamic keyed dependency must declare exactly one of key or keys.`\n );\n const singular = hasKey;\n const selector = singular ? candidate.key : candidate.keys;\n if (typeof selector !== 'function')\n throw new TypeError(`${label} dynamic keyed dependency selector must be a function.`);\n assertKeyedProjection(candidate.source, `${label} dynamic keyed dependency source`);\n return singular\n ? {\n kind: 'one',\n projection: candidate.source,\n select: selector as (value: unknown, key: string) => unknown,\n }\n : {\n kind: 'many',\n projection: candidate.source,\n select: selector as (value: unknown, key: string) => unknown,\n };\n};\n\nexport const compileKeyedDependencies = (\n driver: Projection<unknown>,\n dependencySpecs: KeyedDependencyRecord<string, unknown> | undefined,\n label: string\n): CompiledKeyedDependencies => {\n const entries: CompiledKeyedDependency[] = [];\n const projections: Projection<unknown>[] = [driver];\n if (dependencySpecs === undefined)\n return Object.freeze({\n entries: Object.freeze(entries),\n projections: Object.freeze(projections),\n });\n for (const { name, value: dependency } of readNamedDependencyEntries(dependencySpecs, label)) {\n if (isProjection(dependency)) {\n entries.push(Object.freeze({ name, kind: 'global' as const, projection: dependency }));\n projections.push(dependency);\n continue;\n }\n const dynamic = compileDynamicDependency(dependency, label);\n entries.push(Object.freeze({ name, ...dynamic }));\n projections.push(dynamic.projection);\n }\n return Object.freeze({\n entries: Object.freeze(entries),\n projections: Object.freeze(projections),\n });\n};\n\nconst selectedKey = (\n dependency: Extract<CompiledDynamicKeyedDependency, { readonly kind: 'one' }>,\n value: unknown,\n key: string\n): string | undefined => {\n const result = dependency.select(value, key);\n assertSynchronous(result);\n if (result === undefined) return undefined;\n if (typeof result !== 'string')\n throw new TypeError('Dynamic keyed dependency key must be a string or undefined.');\n return result;\n};\n\nconst selectedKeys = (\n dependency: Extract<CompiledDynamicKeyedDependency, { readonly kind: 'many' }>,\n value: unknown,\n key: string\n): readonly string[] => {\n const result = dependency.select(value, key);\n assertSynchronous(result);\n if (!Array.isArray(result))\n throw new TypeError('Dynamic keyed dependency keys must be an array of strings.');\n const seen = new Set<string>();\n for (const selected of result) {\n if (typeof selected !== 'string')\n throw new TypeError('Dynamic keyed dependency keys must contain only strings.');\n if (seen.has(selected))\n throw new TypeError('Dynamic keyed dependency keys must not contain duplicates.');\n seen.add(selected);\n }\n return result as readonly string[];\n};\n\nexport type KeyedDependencyRuntime = {\n prepare(sources: readonly SourceContext[], reset: boolean): void;\n resolve(\n driverValue: unknown,\n driverKey: string,\n sources: readonly SourceContext[]\n ): Readonly<Record<string, unknown>>;\n driverChanged(source: SourceContext): boolean;\n collectInvalidated(sources: readonly SourceContext[], dirty: Set<string>): boolean;\n remove(driverKey: string): void;\n clearBindings(): void;\n remember(sources: readonly SourceContext[]): void;\n release(): void;\n};\n\nconst emptyValues: Readonly<Record<string, unknown>> = Object.freeze(\n Object.create(null) as Record<string, unknown>\n);\n\nexport const createKeyedDependencyRuntime = (\n compiled: CompiledKeyedDependencies\n): KeyedDependencyRuntime => {\n type GlobalDependencyState = {\n readonly kind: 'global';\n readonly entry: Extract<CompiledKeyedDependency, { readonly kind: 'global' }>;\n readonly sourceIndex: number;\n revision: number;\n globalValue: unknown;\n };\n type DynamicDependencyState = {\n readonly kind: 'dynamic';\n readonly entry: Exclude<CompiledKeyedDependency, { readonly kind: 'global' }>;\n readonly sourceIndex: number;\n readonly relation: KeyRelation;\n revision: number;\n };\n type DependencyState = GlobalDependencyState | DynamicDependencyState;\n const states: DependencyState[] = compiled.entries.map((entry, index) =>\n entry.kind === 'global'\n ? { kind: 'global', entry, sourceIndex: index + 1, revision: -1, globalValue: undefined }\n : {\n kind: 'dynamic',\n entry,\n sourceIndex: index + 1,\n relation: createKeyRelation(),\n revision: -1,\n }\n );\n let driverRevision = -1;\n\n return {\n prepare(sources, reset) {\n for (const state of states) {\n if (state.kind !== 'global') continue;\n const source = sources[state.sourceIndex];\n if (reset || state.revision !== source.revision)\n state.globalValue = snapshotDependencyValue(source);\n }\n },\n resolve(driverValue, driverKey, sources) {\n if (!states.length) return emptyValues;\n const values = Object.create(null) as Record<string, unknown>;\n for (const state of states) {\n if (state.kind === 'global') {\n values[state.entry.name] = state.globalValue;\n continue;\n }\n const dependency = state.entry;\n const source = sources[state.sourceIndex];\n if (source.kind !== 'collection')\n throw new TypeError('Dynamic keyed dependency resolved to a non-collection source.');\n if (dependency.kind === 'one') {\n const selected = selectedKey(dependency, driverValue, driverKey);\n state.relation.replaceOne(driverKey, selected);\n values[dependency.name] = selected === undefined ? undefined : source.read.get(selected);\n continue;\n }\n const keys = selectedKeys(dependency, driverValue, driverKey);\n state.relation.replace(driverKey, keys);\n const selected = new Map<string, unknown>();\n for (const key of keys) if (source.read.has(key)) selected.set(key, source.read.get(key));\n values[dependency.name] = collectionView(mapRead(selected));\n }\n return Object.freeze(values);\n },\n driverChanged(source) {\n return driverRevision !== source.revision;\n },\n collectInvalidated(sources, dirty) {\n let all = false;\n for (const state of states) {\n const source = sources[state.sourceIndex];\n if (state.revision === source.revision) continue;\n const dependency = state.entry;\n if (state.kind === 'global') {\n all = true;\n continue;\n }\n if (source.kind !== 'collection' || !source.change || source.change.kind === 'reset') {\n all = true;\n continue;\n }\n for (const entry of source.change.added)\n for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);\n for (const entry of source.change.updated)\n for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);\n for (const entry of source.change.removed)\n for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);\n }\n return all;\n },\n remove(driverKey) {\n for (const state of states) if (state.kind === 'dynamic') state.relation.delete(driverKey);\n },\n clearBindings() {\n for (const state of states) if (state.kind === 'dynamic') state.relation.clear();\n },\n remember(sources) {\n driverRevision = sources[0]?.revision ?? -1;\n for (const state of states) state.revision = sources[state.sourceIndex].revision;\n },\n release() {\n for (const state of states) {\n state.revision = -1;\n if (state.kind === 'global') state.globalValue = undefined;\n else state.relation.clear();\n }\n driverRevision = -1;\n },\n };\n};\n","import type { CollectionRead, SourceContext } from '@/projection/contract';\nimport { defineProcessor, type KeyedProjection } from '@/projection/definition';\nimport { assertSynchronous } from '@/projection/graph/scheduler';\nimport {\n assertKeyedProjection,\n compileKeyedDependencies,\n createKeyedDependencyRuntime,\n type KeyedDependencyRecord,\n} from './dependency';\n\nexport const keyedAbsent = Symbol('keyed-transform-absent');\nexport type KeyedTransformResult<T> = T | typeof keyedAbsent;\n\nexport type KeyedTransformContext<K extends string, V, State> = {\n readonly key: K;\n readonly value: V;\n readonly dependencies: Readonly<Record<string, unknown>>;\n readonly state: State;\n readonly reset: boolean;\n readonly cause: unknown;\n};\n\nexport type KeyedTransformDefinition<K extends string, V, T, State> = {\n readonly source: KeyedProjection<K, V>;\n readonly dependencies?: KeyedDependencyRecord<K, V>;\n readonly equality?: (previous: T, next: T) => boolean;\n readonly name: string;\n readonly state?: (value: V, key: K) => State;\n readonly evaluate: (context: KeyedTransformContext<K, V, State>) => KeyedTransformResult<T>;\n};\n\n/** Shared driver-keyed lifecycle for pure and retained keyed transforms. */\nexport const createKeyedTransform = <K extends string, V, T, State = undefined>(\n definition: KeyedTransformDefinition<K, V, T, State>\n): KeyedProjection<K, T> => {\n assertKeyedProjection(definition.source, `${definition.name} source`);\n const compiled = compileKeyedDependencies(\n definition.source,\n definition.dependencies as KeyedDependencyRecord<string, unknown> | undefined,\n definition.name\n );\n const [projection] = defineProcessor({\n dependencies: compiled.projections,\n outputs: [\n {\n kind: 'collection',\n equality: (definition.equality ?? Object.is) as (\n previous: unknown,\n next: unknown\n ) => boolean,\n },\n ],\n create: () => {\n const dependencies = createKeyedDependencyRuntime(compiled);\n const states = new Map<string, State>();\n\n const dropState = (key: string): void => {\n states.delete(key);\n dependencies.remove(key);\n };\n\n return {\n evaluate: evaluation => {\n const driver = evaluation.sources[0];\n const output = evaluation.outputs[0];\n if (driver.kind !== 'collection' || output.kind !== 'collection')\n throw new Error(`${definition.name} requires collection input and output.`);\n dependencies.prepare(evaluation.sources, evaluation.reset);\n\n const stateFor = (key: string, value: V): State => {\n if (states.has(key)) return states.get(key) as State;\n const state = definition.state\n ? definition.state(value, key as K)\n : (undefined as State);\n assertSynchronous(state);\n if (definition.state) states.set(key, state);\n return state;\n };\n\n const project = (key: string): boolean => {\n if (!driver.read.has(key)) return false;\n const value = driver.read.get(key) as V;\n const beforePresent = output.previous.has(key);\n const next = definition.evaluate({\n key: key as K,\n value,\n dependencies: dependencies.resolve(value, key, evaluation.sources),\n state: stateFor(key, value),\n reset: evaluation.reset,\n cause: evaluation.cause,\n });\n assertSynchronous(next);\n if (next === keyedAbsent) output.output.remove(key);\n else output.output.set(key, next);\n return beforePresent !== output.next.has(key);\n };\n\n if (evaluation.reset) {\n dependencies.clearBindings();\n const ids = driver.read.ids();\n for (const key of states.keys()) if (!driver.read.has(key)) states.delete(key);\n for (const key of ids) project(key);\n output.output.order(ids.filter(key => output.next.has(key)));\n dependencies.remember(evaluation.sources);\n return;\n }\n\n const dirty = new Set<string>();\n let all = false;\n let updateOrder = false;\n let membershipChanged = false;\n if (dependencies.driverChanged(driver)) {\n const change = driver.change;\n if (!change || change.kind === 'reset') {\n all = true;\n updateOrder = true;\n for (const key of output.previous.ids()) {\n if (driver.read.has(key)) continue;\n output.output.remove(key);\n dropState(key);\n membershipChanged = true;\n }\n } else {\n for (const entry of change.removed) {\n membershipChanged ||= output.previous.has(entry.key);\n output.output.remove(entry.key);\n dropState(entry.key);\n dirty.delete(entry.key);\n }\n for (const entry of change.added) dirty.add(entry.key);\n for (const entry of change.updated) dirty.add(entry.key);\n updateOrder = Boolean(change.order);\n }\n }\n\n all ||= dependencies.collectInvalidated(evaluation.sources, dirty);\n if (all) for (const key of driver.read.ids()) dirty.add(key);\n for (const key of dirty) {\n const changedMembership = project(key);\n membershipChanged ||= changedMembership;\n }\n if (updateOrder || membershipChanged)\n output.output.order(driver.read.ids().filter(key => output.next.has(key)));\n dependencies.remember(evaluation.sources);\n },\n release: () => {\n states.clear();\n dependencies.release();\n },\n };\n },\n name: definition.name,\n });\n return projection as KeyedProjection<K, T>;\n};\n"],"mappings":";AAkDA,MAAa,UAAU;CACrB,aAAa,KAAmC,SAAS,MAAM;CAG/D,WAAW,KAAiC,SAAS,MAAM;CAG3D,SAAS,QAAkC;CAG3C,MAAM;EACJ,iBAAiB;EAGjB,gBAAgB;EAGhB,gBAAgB,UAAkB;EAGnC;CACD,UAAU;EACR,YAAY;EAGZ,iBAAiB;EAGlB;CACD,SAAS;EACP,YAAY,UAAkB;EAM9B,kBAAkB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
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Doxum is a typed runtime for complex mutable documents.",
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"build": "tsdown --config tsdown.config.ts && node scripts/check-build-exports.mjs && pnpm run check:declaration-portability",
|
|
83
83
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
84
84
|
"test": "vitest run --config vitest.config.ts",
|
|
85
|
-
"check": "pnpm run format:check && pnpm run lint && pnpm run typecheck && pnpm run check:public-types && pnpm run test && pnpm run check:projection-surface && pnpm run check:runtime-imports",
|
|
85
|
+
"check": "pnpm run format:check && pnpm run lint && pnpm run typecheck && pnpm run check:public-types && pnpm run test && pnpm run check:runtime-skill && pnpm run check:projection-surface && pnpm run check:runtime-imports",
|
|
86
|
+
"check:runtime-skill": "node scripts/check-runtime-skill.mjs",
|
|
86
87
|
"check:projection-surface": "node scripts/check-projection-surface.mjs",
|
|
87
88
|
"check:runtime-imports": "node scripts/check-runtime-imports.mjs",
|
|
88
89
|
"check:public-types": "tsc -p tsconfig.public-api.json --noEmit",
|