doxum 0.1.12 → 0.1.13

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.
Files changed (64) hide show
  1. package/README.md +44 -39
  2. package/dist/advanced.cjs +116 -0
  3. package/dist/advanced.cjs.map +1 -0
  4. package/dist/advanced.d.cts +42 -0
  5. package/dist/advanced.d.ts +42 -0
  6. package/dist/advanced.js +115 -0
  7. package/dist/advanced.js.map +1 -0
  8. package/dist/{contract-CeAnEPBA.d.ts → contract-BT53Gg94.d.ts} +5 -4
  9. package/dist/{contract-DtGVSXSK.d.cts → contract-XmKnroJq.d.cts} +5 -4
  10. package/dist/definition-177L4Amk.cjs +898 -0
  11. package/dist/definition-177L4Amk.cjs.map +1 -0
  12. package/dist/definition-BlMeHwdz.d.ts +98 -0
  13. package/dist/definition-DXrKMVs7.js +785 -0
  14. package/dist/definition-DXrKMVs7.js.map +1 -0
  15. package/dist/definition-kxnWUvX9.d.cts +98 -0
  16. package/dist/{driver-xOIkwrB8.cjs → driver-BCyfqxsl.cjs} +1 -1
  17. package/dist/{driver-xOIkwrB8.cjs.map → driver-BCyfqxsl.cjs.map} +1 -1
  18. package/dist/{driver-BlR81Dqg.js → driver-CSnhMjbP.js} +1 -1
  19. package/dist/{driver-BlR81Dqg.js.map → driver-CSnhMjbP.js.map} +1 -1
  20. package/dist/index.cjs +31 -29
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +5 -4
  23. package/dist/index.d.ts +5 -4
  24. package/dist/index.js +7 -6
  25. package/dist/index.js.map +1 -1
  26. package/dist/{integration-CWjttg7H.js → integration-Bco8ZB16.js} +7 -3
  27. package/dist/integration-Bco8ZB16.js.map +1 -0
  28. package/dist/integration-CEUn96tx.cjs +52 -0
  29. package/dist/integration-CEUn96tx.cjs.map +1 -0
  30. package/dist/integration.cjs +7 -3
  31. package/dist/integration.d.cts +7 -3
  32. package/dist/integration.d.ts +7 -3
  33. package/dist/integration.js +3 -3
  34. package/dist/local-sync.cjs +1 -1
  35. package/dist/local-sync.d.cts +1 -1
  36. package/dist/local-sync.d.ts +1 -1
  37. package/dist/local-sync.js +1 -1
  38. package/dist/react.cjs +63 -36
  39. package/dist/react.cjs.map +1 -1
  40. package/dist/react.d.cts +8 -7
  41. package/dist/react.d.ts +8 -7
  42. package/dist/react.js +63 -35
  43. package/dist/react.js.map +1 -1
  44. package/dist/store-CDeqZEE3.d.cts +28 -0
  45. package/dist/{store-7XBEcR8s.js → store-CtgvCVFg.js} +585 -922
  46. package/dist/store-CtgvCVFg.js.map +1 -0
  47. package/dist/{store-DBv58dns.cjs → store-DcDpDgjk.cjs} +595 -992
  48. package/dist/store-DcDpDgjk.cjs.map +1 -0
  49. package/dist/store-P5dJ7TVe.d.ts +28 -0
  50. package/package.json +6 -1
  51. package/skills/doxum-runtime/SKILL.md +5 -7
  52. package/skills/doxum-runtime/references/guide.en.md +12 -16
  53. package/skills/doxum-runtime/references/guide.zh-CN.md +9 -14
  54. package/skills/doxum-runtime/references/patterns.en.md +12 -20
  55. package/skills/doxum-runtime/references/patterns.zh-CN.md +12 -18
  56. package/skills/doxum-runtime/references/projections.en.md +56 -199
  57. package/skills/doxum-runtime/references/projections.zh-CN.md +50 -180
  58. package/dist/integration-BShL68Nc.cjs +0 -30
  59. package/dist/integration-BShL68Nc.cjs.map +0 -1
  60. package/dist/integration-CWjttg7H.js.map +0 -1
  61. package/dist/store-2i8pYXqa.d.ts +0 -263
  62. package/dist/store-7XBEcR8s.js.map +0 -1
  63. package/dist/store-DBv58dns.cjs.map +0 -1
  64. package/dist/store-Ks80xWS_.d.cts +0 -263
package/README.md CHANGED
@@ -60,10 +60,10 @@ Committed observer failures are returned in `observerErrors` without rollback.
60
60
  ## Read And Observe
61
61
 
62
62
  ```ts
63
- import { select, snapshot } from 'doxum';
63
+ import { read, snapshot } from 'doxum';
64
64
 
65
- const title = select(document, state => state.title);
66
- const tasks = select(document, state => snapshot(state.tasks));
65
+ const title = read(document, state => state.title);
66
+ const tasks = read(document, state => snapshot(state.tasks));
67
67
  document.subscribe(
68
68
  path => path.tasks.item('b').title,
69
69
  commit => {
@@ -209,44 +209,49 @@ with `history: false` close the active group.
209
209
  ## Projections
210
210
 
211
211
  ```ts
212
- import { createProjectionStore, input, project } from 'doxum';
212
+ import { createProjectionRuntime, derive, input, observe } from 'doxum';
213
213
 
214
- const titles = project(
215
- document,
216
- path => path.tasks,
217
- (id, task) => `${id}: ${task.title}`
218
- );
219
- const count = project({ titles }, ({ titles }) => titles.ids().length);
220
- const zoom = input(1);
221
- const scaled = project({ count, zoom }, ({ count, zoom }) => count * zoom);
222
-
223
- const store = createProjectionStore({ onError: console.error });
224
- store.get(scaled);
225
- store.set(zoom, 2);
226
- const title = store.item(titles, taskId); // Stable Readable<string | undefined>.
214
+ const tasks = observe(document, path => path.tasks);
215
+ const filter = input<'all' | 'open'>('all');
216
+ const visible = derive([tasks, filter], (all, mode) => {
217
+ if (mode === 'all') return all;
218
+ return new Map([...all].filter(([, task]) => !task.done));
219
+ });
220
+
221
+ const runtime = createProjectionRuntime({ onError: console.error });
222
+ runtime.get(visible);
223
+ runtime.set(filter, 'open');
224
+ runtime.batch({ cause: { action: 'refresh' } }, () => {
225
+ runtime.set(filter, 'all');
226
+ document.update(draft => {
227
+ draft.title = 'Updated';
228
+ });
229
+ });
230
+ ```
231
+
232
+ Projection declarations are lazy and reusable. The only Runtime operations are
233
+ `get`, `subscribe`, `set`, `batch` and `dispose`; materialization, incremental
234
+ state, publication and recovery stay inside the Runtime. Collection values are
235
+ immutable `ReadonlyMap`-like snapshots, so callers do not hold lifecycle handles.
236
+
237
+ For retained state, reverse indexes and keyed patches, use the isolated advanced
238
+ entry point. Whole-value processors use `incremental(...)`; keyed collection
239
+ processors use `incremental.collection(...)`:
240
+
241
+ ```ts
242
+ import { incremental } from 'doxum/advanced';
243
+
244
+ const doubled = incremental.collection([tasks], ({ sources, output }) => {
245
+ for (const [id, task] of sources[0]) output.set(id, task.value * 2);
246
+ });
227
247
  ```
228
248
 
229
- Projection declarations are lazy and reusable. A `ProjectionStore` owns
230
- materialized values, subscriptions, batching, processor state and disposal.
231
- `project(document, path)` binds a document collection; adding a mapper performs
232
- incremental keyed mapping. `project(readable)` bridges an external readable.
233
- Pure computations receive current values. Advanced processors use tagged specs:
234
- `project({ kind: 'value', sources, build })` and
235
- `project({ kind: 'collection', sources, build })`.
236
- Document collection events provide scoped `read.get/has/ids`, final candidate
237
- keys, order dirtiness, commits and reset state.
238
- Ordinary mappers intentionally model only one-source, same-key transforms.
239
- Cross-collection relationships use an advanced collection processor with explicit,
240
- application-owned dependency indexes; processor reads are not tracked automatically.
241
- For per-key observation, `store.item(collection, key)` returns a stable `Readable`
242
- that only notifies for that key. React components use
243
- `useProjectionItem(collection, key)`; unrelated keys and order-only changes do not
244
- rerender the component.
245
-
246
- Processors settle before external listeners. `store.batch` defers graph
247
- settlement and projection notifications, but document commits/listeners remain
248
- synchronous. Projection readers inside the batch see the last publication.
249
- Dispose projection stores with their owning service.
249
+ In React, `useProjection(projection)` reads a value and
250
+ `useProjection(projection, selector, equality?)` tracks keyed reads such as
251
+ `tasks => tasks.get(taskId)`. Unrelated key changes do not execute that selector;
252
+ equality only filters a selector result after a related change. `useInput(input)`
253
+ returns the current value and its Runtime-local setter.
254
+
250
255
  See [projection contracts](docs/projections.md).
251
256
 
252
257
  ## Local Sync
@@ -288,7 +293,7 @@ baselines from final published order copies. Architecture workloads include orde
288
293
  round trips and repeated tree edits to expose costs hidden by commit-only benchmarks.
289
294
 
290
295
  Builds produce root `dist` ESM/CJS/declarations for `doxum`, `doxum/integration`,
291
- `doxum/local-sync` and `doxum/react`. Source ownership is described in
296
+ `doxum/local-sync`, `doxum/react` and `doxum/advanced`. Source ownership is described in
292
297
  [architecture](docs/architecture.md) and [AGENTS.md](AGENTS.md).
293
298
  The runtime shares one transaction lifecycle; complete mutation operations are
294
299
  organized by domain under `core/src/mutation/operations`, with access, first-touch
@@ -0,0 +1,116 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_definition = require("./definition-177L4Amk.cjs");
3
+ //#region core/src/projection/advanced.ts
4
+ const dependenciesOf = (dependencies) => Object.fromEntries(dependencies.map((dependency, index) => [`d${index}`, dependency]));
5
+ const sourceChange = (sources) => {
6
+ for (const source of Object.values(sources)) if (source && typeof source === "object" && "change" in source && source.change !== void 0) return source.change;
7
+ };
8
+ const sourceCause = (sources) => {
9
+ for (const source of Object.values(sources)) if (source && typeof source === "object" && "cause" in source && source.cause !== void 0) return source.cause;
10
+ };
11
+ const publicSource = (source) => {
12
+ if (!source || typeof source !== "object") return source;
13
+ if ("value" in source) return source.value;
14
+ if ("read" in source) {
15
+ const read = source.read;
16
+ if (read && typeof read === "object" && "ids" in read && typeof read.ids === "function") {
17
+ const result = /* @__PURE__ */ new Map();
18
+ for (const id of read.ids()) result.set(id, read.get(id));
19
+ return result;
20
+ }
21
+ return require_definition.snapshot(read);
22
+ }
23
+ if ("ids" in source && typeof source.ids === "function") {
24
+ const result = /* @__PURE__ */ new Map();
25
+ const read = source;
26
+ for (const id of read.ids()) result.set(id, read.get(id));
27
+ return result;
28
+ }
29
+ return source;
30
+ };
31
+ const publicTuple = (sources) => Object.keys(sources).sort((left, right) => Number(left.slice(1)) - Number(right.slice(1))).map((key) => publicSource(sources[key]));
32
+ const normalizeValue = (result) => result && typeof result === "object" && result.kind === "value" ? {
33
+ value: result.value,
34
+ state: result.state
35
+ } : { value: result };
36
+ function createIncrementalValue(dependencies, processor) {
37
+ const dependencyMap = dependenciesOf(dependencies);
38
+ let state = Object.create(null);
39
+ let current;
40
+ const build = (sources) => {
41
+ state = Object.create(null);
42
+ const result = processor({
43
+ sources: publicTuple(sources),
44
+ previous: void 0,
45
+ reset: true,
46
+ change: void 0,
47
+ cause: sourceCause(sources),
48
+ state
49
+ });
50
+ if (result && typeof result === "object" && "kind" in result) throw new TypeError("Initial incremental processor cannot rebuild.");
51
+ const normalized = normalizeValue(result);
52
+ current = normalized.value;
53
+ if (normalized.state) state = normalized.state;
54
+ return {
55
+ value: current,
56
+ update: (nextSources) => {
57
+ const next = processor({
58
+ sources: publicTuple(nextSources),
59
+ previous: current,
60
+ reset: false,
61
+ change: sourceChange(nextSources),
62
+ cause: sourceCause(nextSources),
63
+ state
64
+ });
65
+ if (next && typeof next === "object" && "kind" in next) return next;
66
+ const nextValue = normalizeValue(next);
67
+ current = nextValue.value;
68
+ if (nextValue.state) state = nextValue.state;
69
+ return {
70
+ kind: "changed",
71
+ value: current
72
+ };
73
+ }
74
+ };
75
+ };
76
+ return require_definition.defineIncrementalValue({
77
+ dependencies: dependencyMap,
78
+ build
79
+ });
80
+ }
81
+ function createIncrementalCollection(dependencies, processor) {
82
+ const dependencyMap = dependenciesOf(dependencies);
83
+ let state = Object.create(null);
84
+ const build = (input) => {
85
+ state = Object.create(null);
86
+ if (processor({
87
+ sources: publicTuple(input.sources),
88
+ previous: input.previous,
89
+ next: input.next,
90
+ reset: true,
91
+ change: void 0,
92
+ cause: sourceCause(input.sources),
93
+ state,
94
+ output: input.writer
95
+ })?.kind === "rebuild") throw new TypeError("Initial incremental collection processor cannot rebuild.");
96
+ return { update: (nextInput) => processor({
97
+ sources: publicTuple(nextInput.sources),
98
+ previous: nextInput.previous,
99
+ next: nextInput.next,
100
+ reset: false,
101
+ change: sourceChange(nextInput.sources),
102
+ cause: sourceCause(nextInput.sources),
103
+ state,
104
+ output: nextInput.writer
105
+ }) };
106
+ };
107
+ return require_definition.defineIncrementalCollection({
108
+ dependencies: dependencyMap,
109
+ build
110
+ });
111
+ }
112
+ const incremental = Object.assign(createIncrementalValue, { collection: createIncrementalCollection });
113
+ //#endregion
114
+ exports.incremental = incremental;
115
+
116
+ //# sourceMappingURL=advanced.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced.cjs","names":["snapshot","defineIncrementalValue","defineIncrementalCollection"],"sources":["../core/src/projection/advanced.ts"],"sourcesContent":["import type { Projection, ProjectionValues, PublicCollection } from './definition';\nimport { defineIncrementalCollection, defineIncrementalValue } from './definition';\nimport type { CollectionDraft, CollectionRead, GraphSources } from './contract';\nimport { snapshot } from '../access/scope';\n\nexport type IncrementalState = Record<string, unknown>;\n\nexport type IncrementalValueContext<S, T> = {\n readonly sources: S;\n readonly previous: T | undefined;\n readonly reset: boolean;\n readonly change: unknown;\n readonly cause: unknown;\n readonly state: IncrementalState;\n};\n\nexport type IncrementalValueProcessor<S, T> = (\n context: IncrementalValueContext<S, T>\n) =>\n | T\n | { readonly kind: 'value'; readonly value: T; readonly state?: IncrementalState }\n | { readonly kind: 'rebuild' };\n\nexport type IncrementalCollectionContext<S, K extends string, V> = {\n readonly sources: S;\n readonly previous: CollectionRead<K, V>;\n readonly next: CollectionRead<K, V>;\n readonly change: unknown;\n readonly reset: boolean;\n readonly cause: unknown;\n readonly state: IncrementalState;\n readonly output: CollectionDraft<K, V>;\n};\n\nexport type IncrementalCollectionProcessor<S, K extends string, V> = (\n context: IncrementalCollectionContext<S, K, V>\n) => void | { readonly kind: 'rebuild' };\n\ntype DependencyMap<D extends readonly Projection<unknown>[]> = {\n readonly [K in keyof D as `d${Extract<K, number>}`]: D[K];\n};\n\nconst dependenciesOf = <D extends readonly Projection<unknown>[]>(dependencies: D): GraphSources =>\n Object.fromEntries(\n dependencies.map((dependency, index) => [`d${index}`, dependency])\n ) as unknown as GraphSources;\n\nconst sourceChange = (sources: Record<string, unknown>): unknown => {\n for (const source of Object.values(sources)) {\n if (\n source &&\n typeof source === 'object' &&\n 'change' in source &&\n (source as { readonly change?: unknown }).change !== undefined\n )\n return (source as { readonly change?: unknown }).change;\n }\n return undefined;\n};\n\nconst sourceCause = (sources: Record<string, unknown>): unknown => {\n for (const source of Object.values(sources)) {\n if (\n source &&\n typeof source === 'object' &&\n 'cause' in source &&\n (source as { readonly cause?: unknown }).cause !== undefined\n )\n return (source as { readonly cause?: unknown }).cause;\n }\n return undefined;\n};\n\nconst publicSource = (source: unknown): unknown => {\n if (!source || typeof source !== 'object') return source;\n if ('value' in source) return (source as { readonly value: unknown }).value;\n if ('read' in source) {\n const read = (source as { readonly read: unknown }).read;\n if (\n read &&\n typeof read === 'object' &&\n 'ids' in read &&\n typeof (read as { ids?: unknown }).ids === 'function'\n ) {\n const result = new Map<string, unknown>();\n for (const id of (read as CollectionRead<string, unknown>).ids())\n result.set(id, (read as CollectionRead<string, unknown>).get(id));\n return result;\n }\n return snapshot(read);\n }\n if ('ids' in source && typeof (source as { ids?: unknown }).ids === 'function') {\n const result = new Map<string, unknown>();\n const read = source as CollectionRead<string, unknown>;\n for (const id of read.ids()) result.set(id, read.get(id));\n return result;\n }\n return source;\n};\n\nconst publicTuple = (sources: Record<string, unknown>): readonly unknown[] =>\n Object.keys(sources)\n .sort((left, right) => Number(left.slice(1)) - Number(right.slice(1)))\n .map(key => publicSource(sources[key]));\n\nconst normalizeValue = <T>(\n result: T | { readonly kind: 'value'; readonly value: T; readonly state?: IncrementalState }\n): { value: T; state?: IncrementalState } =>\n result && typeof result === 'object' && (result as { readonly kind?: unknown }).kind === 'value'\n ? {\n value: (result as { readonly value: T }).value,\n state: (result as { readonly state?: IncrementalState }).state,\n }\n : { value: result as T };\n\nfunction createIncrementalValue<const D extends readonly Projection<unknown>[], T>(\n dependencies: D,\n processor: IncrementalValueProcessor<ProjectionValues<D>, T>\n): Projection<T> {\n const dependencyMap = dependenciesOf(dependencies);\n let state: IncrementalState = Object.create(null) as IncrementalState;\n let current!: T;\n const build = (sources: Record<string, unknown>) => {\n state = Object.create(null) as IncrementalState;\n const result = processor({\n sources: publicTuple(sources) as ProjectionValues<D>,\n previous: undefined,\n reset: true,\n change: undefined,\n cause: sourceCause(sources),\n state,\n });\n if (result && typeof result === 'object' && 'kind' in result)\n throw new TypeError('Initial incremental processor cannot rebuild.');\n const normalized = normalizeValue(result as T);\n current = normalized.value;\n if (normalized.state) state = normalized.state;\n return {\n value: current,\n update: (nextSources: Record<string, unknown>) => {\n const next = processor({\n sources: publicTuple(nextSources) as ProjectionValues<D>,\n previous: current,\n reset: false,\n change: sourceChange(nextSources),\n cause: sourceCause(nextSources),\n state,\n });\n if (next && typeof next === 'object' && 'kind' in next) return next;\n const nextValue = normalizeValue(next as T);\n current = nextValue.value;\n if (nextValue.state) state = nextValue.state;\n return { kind: 'changed', value: current } as const;\n },\n };\n };\n return defineIncrementalValue({ dependencies: dependencyMap, build: build as never });\n}\n\nfunction createIncrementalCollection<\n const D extends readonly Projection<unknown>[],\n K extends string,\n V,\n>(\n dependencies: D,\n processor: IncrementalCollectionProcessor<ProjectionValues<D>, K, V>\n): Projection<PublicCollection<K, V>> {\n const dependencyMap = dependenciesOf(dependencies);\n let state: IncrementalState = Object.create(null) as IncrementalState;\n const build = (input: {\n readonly sources: Record<string, unknown>;\n readonly previous: CollectionRead<K, V>;\n readonly next: CollectionRead<K, V>;\n readonly writer: CollectionDraft<K, V>;\n }) => {\n state = Object.create(null) as IncrementalState;\n const result = processor({\n sources: publicTuple(input.sources) as ProjectionValues<D>,\n previous: input.previous,\n next: input.next,\n reset: true,\n change: undefined,\n cause: sourceCause(input.sources),\n state,\n output: input.writer,\n });\n if (result?.kind === 'rebuild')\n throw new TypeError('Initial incremental collection processor cannot rebuild.');\n return {\n update: (nextInput: typeof input) =>\n processor({\n sources: publicTuple(nextInput.sources) as ProjectionValues<D>,\n previous: nextInput.previous,\n next: nextInput.next,\n reset: false,\n change: sourceChange(nextInput.sources),\n cause: sourceCause(nextInput.sources),\n state,\n output: nextInput.writer,\n }),\n };\n };\n return defineIncrementalCollection({ dependencies: dependencyMap, build: build as never });\n}\n\nexport const incremental = Object.assign(createIncrementalValue, {\n collection: createIncrementalCollection,\n});\n\nexport type IncrementalDependencies<D extends readonly Projection<unknown>[]> = DependencyMap<D>;\n"],"mappings":";;;AA0CA,MAAM,kBAA4D,iBAChE,OAAO,YACL,aAAa,KAAK,YAAY,UAAU,CAAC,IAAI,SAAS,WAAW,CAAC,CACnE;AAEH,MAAM,gBAAg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AAM;GACf,CACS,EAAE,SAAS,UACnB,OAAM,IAAI,UAAU,2DAA2D;AACjF,SAAO,EACL,SAAS,cACP,UAAU;GACR,SAAS,YAAY,UAAU,QAAQ;GACvC,UAAU,UAAU;GACpB,MAAM,UAAU;GAChB,OAAO;GACP,QAAQ,aAAa,UAAU,QAAQ;GACvC,OAAO,YAAY,UAAU,QAAQ;GACrC;GACA,QAAQ,UAAU;GACnB,CAAC,EACL;;AAEH,QAAOC,mBAAAA,4BAA4B;EAAE,cAAc;EAAsB;EAAgB,CAAC;;AAG5F,MAAa,cAAc,OAAO,OAAO,wBAAwB,EAC/D,YAAY,6BACb,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { i as PublicCollection, l as CollectionDraft, n as Projection, r as ProjectionValues, u as CollectionRead } from "./definition-kxnWUvX9.cjs";
2
+
3
+ //#region core/src/projection/advanced.d.ts
4
+ type IncrementalState = Record<string, unknown>;
5
+ type IncrementalValueContext<S, T> = {
6
+ readonly sources: S;
7
+ readonly previous: T | undefined;
8
+ readonly reset: boolean;
9
+ readonly change: unknown;
10
+ readonly cause: unknown;
11
+ readonly state: IncrementalState;
12
+ };
13
+ type IncrementalValueProcessor<S, T> = (context: IncrementalValueContext<S, T>) => T | {
14
+ readonly kind: 'value';
15
+ readonly value: T;
16
+ readonly state?: IncrementalState;
17
+ } | {
18
+ readonly kind: 'rebuild';
19
+ };
20
+ type IncrementalCollectionContext<S, K extends string, V> = {
21
+ readonly sources: S;
22
+ readonly previous: CollectionRead<K, V>;
23
+ readonly next: CollectionRead<K, V>;
24
+ readonly change: unknown;
25
+ readonly reset: boolean;
26
+ readonly cause: unknown;
27
+ readonly state: IncrementalState;
28
+ readonly output: CollectionDraft<K, V>;
29
+ };
30
+ type IncrementalCollectionProcessor<S, K extends string, V> = (context: IncrementalCollectionContext<S, K, V>) => void | {
31
+ readonly kind: 'rebuild';
32
+ };
33
+ type DependencyMap<D extends readonly Projection<unknown>[]> = { readonly [K in keyof D as `d${Extract<K, number>}`]: D[K] };
34
+ declare function createIncrementalValue<const D extends readonly Projection<unknown>[], T>(dependencies: D, processor: IncrementalValueProcessor<ProjectionValues<D>, T>): Projection<T>;
35
+ declare function createIncrementalCollection<const D extends readonly Projection<unknown>[], K extends string, V>(dependencies: D, processor: IncrementalCollectionProcessor<ProjectionValues<D>, K, V>): Projection<PublicCollection<K, V>>;
36
+ declare const incremental: typeof createIncrementalValue & {
37
+ collection: typeof createIncrementalCollection;
38
+ };
39
+ type IncrementalDependencies<D extends readonly Projection<unknown>[]> = DependencyMap<D>;
40
+ //#endregion
41
+ export { IncrementalCollectionContext, IncrementalCollectionProcessor, IncrementalDependencies, IncrementalState, IncrementalValueContext, IncrementalValueProcessor, incremental };
42
+ //# sourceMappingURL=advanced.d.cts.map
@@ -0,0 +1,42 @@
1
+ import { i as PublicCollection, l as CollectionDraft, n as Projection, r as ProjectionValues, u as CollectionRead } from "./definition-BlMeHwdz.js";
2
+
3
+ //#region core/src/projection/advanced.d.ts
4
+ type IncrementalState = Record<string, unknown>;
5
+ type IncrementalValueContext<S, T> = {
6
+ readonly sources: S;
7
+ readonly previous: T | undefined;
8
+ readonly reset: boolean;
9
+ readonly change: unknown;
10
+ readonly cause: unknown;
11
+ readonly state: IncrementalState;
12
+ };
13
+ type IncrementalValueProcessor<S, T> = (context: IncrementalValueContext<S, T>) => T | {
14
+ readonly kind: 'value';
15
+ readonly value: T;
16
+ readonly state?: IncrementalState;
17
+ } | {
18
+ readonly kind: 'rebuild';
19
+ };
20
+ type IncrementalCollectionContext<S, K extends string, V> = {
21
+ readonly sources: S;
22
+ readonly previous: CollectionRead<K, V>;
23
+ readonly next: CollectionRead<K, V>;
24
+ readonly change: unknown;
25
+ readonly reset: boolean;
26
+ readonly cause: unknown;
27
+ readonly state: IncrementalState;
28
+ readonly output: CollectionDraft<K, V>;
29
+ };
30
+ type IncrementalCollectionProcessor<S, K extends string, V> = (context: IncrementalCollectionContext<S, K, V>) => void | {
31
+ readonly kind: 'rebuild';
32
+ };
33
+ type DependencyMap<D extends readonly Projection<unknown>[]> = { readonly [K in keyof D as `d${Extract<K, number>}`]: D[K] };
34
+ declare function createIncrementalValue<const D extends readonly Projection<unknown>[], T>(dependencies: D, processor: IncrementalValueProcessor<ProjectionValues<D>, T>): Projection<T>;
35
+ declare function createIncrementalCollection<const D extends readonly Projection<unknown>[], K extends string, V>(dependencies: D, processor: IncrementalCollectionProcessor<ProjectionValues<D>, K, V>): Projection<PublicCollection<K, V>>;
36
+ declare const incremental: typeof createIncrementalValue & {
37
+ collection: typeof createIncrementalCollection;
38
+ };
39
+ type IncrementalDependencies<D extends readonly Projection<unknown>[]> = DependencyMap<D>;
40
+ //#endregion
41
+ export { IncrementalCollectionContext, IncrementalCollectionProcessor, IncrementalDependencies, IncrementalState, IncrementalValueContext, IncrementalValueProcessor, incremental };
42
+ //# sourceMappingURL=advanced.d.ts.map
@@ -0,0 +1,115 @@
1
+ import { i as defineIncrementalValue, p as snapshot, r as defineIncrementalCollection } from "./definition-DXrKMVs7.js";
2
+ //#region core/src/projection/advanced.ts
3
+ const dependenciesOf = (dependencies) => Object.fromEntries(dependencies.map((dependency, index) => [`d${index}`, dependency]));
4
+ const sourceChange = (sources) => {
5
+ for (const source of Object.values(sources)) if (source && typeof source === "object" && "change" in source && source.change !== void 0) return source.change;
6
+ };
7
+ const sourceCause = (sources) => {
8
+ for (const source of Object.values(sources)) if (source && typeof source === "object" && "cause" in source && source.cause !== void 0) return source.cause;
9
+ };
10
+ const publicSource = (source) => {
11
+ if (!source || typeof source !== "object") return source;
12
+ if ("value" in source) return source.value;
13
+ if ("read" in source) {
14
+ const read = source.read;
15
+ if (read && typeof read === "object" && "ids" in read && typeof read.ids === "function") {
16
+ const result = /* @__PURE__ */ new Map();
17
+ for (const id of read.ids()) result.set(id, read.get(id));
18
+ return result;
19
+ }
20
+ return snapshot(read);
21
+ }
22
+ if ("ids" in source && typeof source.ids === "function") {
23
+ const result = /* @__PURE__ */ new Map();
24
+ const read = source;
25
+ for (const id of read.ids()) result.set(id, read.get(id));
26
+ return result;
27
+ }
28
+ return source;
29
+ };
30
+ const publicTuple = (sources) => Object.keys(sources).sort((left, right) => Number(left.slice(1)) - Number(right.slice(1))).map((key) => publicSource(sources[key]));
31
+ const normalizeValue = (result) => result && typeof result === "object" && result.kind === "value" ? {
32
+ value: result.value,
33
+ state: result.state
34
+ } : { value: result };
35
+ function createIncrementalValue(dependencies, processor) {
36
+ const dependencyMap = dependenciesOf(dependencies);
37
+ let state = Object.create(null);
38
+ let current;
39
+ const build = (sources) => {
40
+ state = Object.create(null);
41
+ const result = processor({
42
+ sources: publicTuple(sources),
43
+ previous: void 0,
44
+ reset: true,
45
+ change: void 0,
46
+ cause: sourceCause(sources),
47
+ state
48
+ });
49
+ if (result && typeof result === "object" && "kind" in result) throw new TypeError("Initial incremental processor cannot rebuild.");
50
+ const normalized = normalizeValue(result);
51
+ current = normalized.value;
52
+ if (normalized.state) state = normalized.state;
53
+ return {
54
+ value: current,
55
+ update: (nextSources) => {
56
+ const next = processor({
57
+ sources: publicTuple(nextSources),
58
+ previous: current,
59
+ reset: false,
60
+ change: sourceChange(nextSources),
61
+ cause: sourceCause(nextSources),
62
+ state
63
+ });
64
+ if (next && typeof next === "object" && "kind" in next) return next;
65
+ const nextValue = normalizeValue(next);
66
+ current = nextValue.value;
67
+ if (nextValue.state) state = nextValue.state;
68
+ return {
69
+ kind: "changed",
70
+ value: current
71
+ };
72
+ }
73
+ };
74
+ };
75
+ return defineIncrementalValue({
76
+ dependencies: dependencyMap,
77
+ build
78
+ });
79
+ }
80
+ function createIncrementalCollection(dependencies, processor) {
81
+ const dependencyMap = dependenciesOf(dependencies);
82
+ let state = Object.create(null);
83
+ const build = (input) => {
84
+ state = Object.create(null);
85
+ if (processor({
86
+ sources: publicTuple(input.sources),
87
+ previous: input.previous,
88
+ next: input.next,
89
+ reset: true,
90
+ change: void 0,
91
+ cause: sourceCause(input.sources),
92
+ state,
93
+ output: input.writer
94
+ })?.kind === "rebuild") throw new TypeError("Initial incremental collection processor cannot rebuild.");
95
+ return { update: (nextInput) => processor({
96
+ sources: publicTuple(nextInput.sources),
97
+ previous: nextInput.previous,
98
+ next: nextInput.next,
99
+ reset: false,
100
+ change: sourceChange(nextInput.sources),
101
+ cause: sourceCause(nextInput.sources),
102
+ state,
103
+ output: nextInput.writer
104
+ }) };
105
+ };
106
+ return defineIncrementalCollection({
107
+ dependencies: dependencyMap,
108
+ build
109
+ });
110
+ }
111
+ const incremental = Object.assign(createIncrementalValue, { collection: createIncrementalCollection });
112
+ //#endregion
113
+ export { incremental };
114
+
115
+ //# sourceMappingURL=advanced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced.js","names":[],"sources":["../core/src/projection/advanced.ts"],"sourcesContent":["import type { Projection, ProjectionValues, PublicCollection } from './definition';\nimport { defineIncrementalCollection, defineIncrementalValue } from './definition';\nimport type { CollectionDraft, CollectionRead, GraphSources } from './contract';\nimport { snapshot } from '../access/scope';\n\nexport type IncrementalState = Record<string, unknown>;\n\nexport type IncrementalValueContext<S, T> = {\n readonly sources: S;\n readonly previous: T | undefined;\n readonly reset: boolean;\n readonly change: unknown;\n readonly cause: unknown;\n readonly state: IncrementalState;\n};\n\nexport type IncrementalValueProcessor<S, T> = (\n context: IncrementalValueContext<S, T>\n) =>\n | T\n | { readonly kind: 'value'; readonly value: T; readonly state?: IncrementalState }\n | { readonly kind: 'rebuild' };\n\nexport type IncrementalCollectionContext<S, K extends string, V> = {\n readonly sources: S;\n readonly previous: CollectionRead<K, V>;\n readonly next: CollectionRead<K, V>;\n readonly change: unknown;\n readonly reset: boolean;\n readonly cause: unknown;\n readonly state: IncrementalState;\n readonly output: CollectionDraft<K, V>;\n};\n\nexport type IncrementalCollectionProcessor<S, K extends string, V> = (\n context: IncrementalCollectionContext<S, K, V>\n) => void | { readonly kind: 'rebuild' };\n\ntype DependencyMap<D extends readonly Projection<unknown>[]> = {\n readonly [K in keyof D as `d${Extract<K, number>}`]: D[K];\n};\n\nconst dependenciesOf = <D extends readonly Projection<unknown>[]>(dependencies: D): GraphSources =>\n Object.fromEntries(\n dependencies.map((dependency, index) => [`d${index}`, dependency])\n ) as unknown as GraphSources;\n\nconst sourceChange = (sources: Record<string, unknown>): unknown => {\n for (const source of Object.values(sources)) {\n if (\n source &&\n typeof source === 'object' &&\n 'change' in source &&\n (source as { readonly change?: unknown }).change !== undefined\n )\n return (source as { readonly change?: unknown }).change;\n }\n return undefined;\n};\n\nconst sourceCause = (sources: Record<string, unknown>): unknown => {\n for (const source of Object.values(sources)) {\n if (\n source &&\n typeof source === 'object' &&\n 'cause' in source &&\n (source as { readonly cause?: unknown }).cause !== undefined\n )\n return (source as { readonly cause?: unknown }).cause;\n }\n return undefined;\n};\n\nconst publicSource = (source: unknown): unknown => {\n if (!source || typeof source !== 'object') return source;\n if ('value' in source) return (source as { readonly value: unknown }).value;\n if ('read' in source) {\n const read = (source as { readonly read: unknown }).read;\n if (\n read &&\n typeof read === 'object' &&\n 'ids' in read &&\n typeof (read as { ids?: unknown }).ids === 'function'\n ) {\n const result = new Map<string, unknown>();\n for (const id of (read as CollectionRead<string, unknown>).ids())\n result.set(id, (read as CollectionRead<string, unknown>).get(id));\n return result;\n }\n return snapshot(read);\n }\n if ('ids' in source && typeof (source as { ids?: unknown }).ids === 'function') {\n const result = new Map<string, unknown>();\n const read = source as CollectionRead<string, unknown>;\n for (const id of read.ids()) result.set(id, read.get(id));\n return result;\n }\n return source;\n};\n\nconst publicTuple = (sources: Record<string, unknown>): readonly unknown[] =>\n Object.keys(sources)\n .sort((left, right) => Number(left.slice(1)) - Number(right.slice(1)))\n .map(key => publicSource(sources[key]));\n\nconst normalizeValue = <T>(\n result: T | { readonly kind: 'value'; readonly value: T; readonly state?: IncrementalState }\n): { value: T; state?: IncrementalState } =>\n result && typeof result === 'object' && (result as { readonly kind?: unknown }).kind === 'value'\n ? {\n value: (result as { readonly value: T }).value,\n state: (result as { readonly state?: IncrementalState }).state,\n }\n : { value: result as T };\n\nfunction createIncrementalValue<const D extends readonly Projection<unknown>[], T>(\n dependencies: D,\n processor: IncrementalValueProcessor<ProjectionValues<D>, T>\n): Projection<T> {\n const dependencyMap = dependenciesOf(dependencies);\n let state: IncrementalState = Object.create(null) as IncrementalState;\n let current!: T;\n const build = (sources: Record<string, unknown>) => {\n state = Object.create(null) as IncrementalState;\n const result = processor({\n sources: publicTuple(sources) as ProjectionValues<D>,\n previous: undefined,\n reset: true,\n change: undefined,\n cause: sourceCause(sources),\n state,\n });\n if (result && typeof result === 'object' && 'kind' in result)\n throw new TypeError('Initial incremental processor cannot rebuild.');\n const normalized = normalizeValue(result as T);\n current = normalized.value;\n if (normalized.state) state = normalized.state;\n return {\n value: current,\n update: (nextSources: Record<string, unknown>) => {\n const next = processor({\n sources: publicTuple(nextSources) as ProjectionValues<D>,\n previous: current,\n reset: false,\n change: sourceChange(nextSources),\n cause: sourceCause(nextSources),\n state,\n });\n if (next && typeof next === 'object' && 'kind' in next) return next;\n const nextValue = normalizeValue(next as T);\n current = nextValue.value;\n if (nextValue.state) state = nextValue.state;\n return { kind: 'changed', value: current } as const;\n },\n };\n };\n return defineIncrementalValue({ dependencies: dependencyMap, build: build as never });\n}\n\nfunction createIncrementalCollection<\n const D extends readonly Projection<unknown>[],\n K extends string,\n V,\n>(\n dependencies: D,\n processor: IncrementalCollectionProcessor<ProjectionValues<D>, K, V>\n): Projection<PublicCollection<K, V>> {\n const dependencyMap = dependenciesOf(dependencies);\n let state: IncrementalState = Object.create(null) as IncrementalState;\n const build = (input: {\n readonly sources: Record<string, unknown>;\n readonly previous: CollectionRead<K, V>;\n readonly next: CollectionRead<K, V>;\n readonly writer: CollectionDraft<K, V>;\n }) => {\n state = Object.create(null) as IncrementalState;\n const result = processor({\n sources: publicTuple(input.sources) as ProjectionValues<D>,\n previous: input.previous,\n next: input.next,\n reset: true,\n change: undefined,\n cause: sourceCause(input.sources),\n state,\n output: input.writer,\n });\n if (result?.kind === 'rebuild')\n throw new TypeError('Initial incremental collection processor cannot rebuild.');\n return {\n update: (nextInput: typeof input) =>\n processor({\n sources: publicTuple(nextInput.sources) as ProjectionValues<D>,\n previous: nextInput.previous,\n next: nextInput.next,\n reset: false,\n change: sourceChange(nextInput.sources),\n cause: sourceCause(nextInput.sources),\n state,\n output: nextInput.writer,\n }),\n };\n };\n return defineIncrementalCollection({ dependencies: dependencyMap, build: build as never });\n}\n\nexport const incremental = Object.assign(createIncrementalValue, {\n collection: createIncrementalCollection,\n});\n\nexport type IncrementalDependencies<D extends readonly Projection<unknown>[]> = DependencyMap<D>;\n"],"mappings":";;AA0CA,MAAM,kBAA4D,iBAChE,OAAO,YACL,aAAa,KAAK,YAAY,UAAU,CAAC,IAAI,SAAS,WAAW,CAAC,CACnE;AAEH,MAAM,gBAAgB,YAA8C;AAClE,MAAK,MAAM,UAAU,OAAO,OAAO,QAAQ,CACzC,KACE,UACA,OAAO,WAAW,YAClB,YAAY,UACX,OAAyC,WAAW,KAAA,EAErD,QAAQ,OAAyC;;AAKvD,MAAM,eAAe,YAA8C;AACjE,MAAK,MAAM,UAAU,OAAO,OAAO,QAAQ,CACzC,KACE,UACA,OAAO,WAAW,YAClB,WAAW,UACV,OAAwC,UAAU,KAAA,EAEnD,QAAQ,OAAwC;;AAKtD,MAAM,gBAAgB,WAA6B;AACjD,KAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,KAAI,WAAW,OAAQ,QAAQ,OAAuC;AACtE,KAAI,UAAU,QAAQ;EACpB,MAAM,OAAQ,OAAsC;AACpD,MACE,QACA,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA2B,QAAQ,YAC3C;GACA,MAAM,yBAAS,IAAI,KAAsB;AACzC,QAAK,MAAM,MAAO,KAAyC,KAAK,CAC9D,QAAO,IAAI,IAAK,KAAyC,IAAI,GAAG,CAAC;AACnE,UAAO;;AAET,SAAO,SAAS,KAAK;;AAEvB,KAAI,SAAS,UAAU,OAAQ,OAA6B,Q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,cAAU,UAAU;AACpB,QAAI,UAAU,MAAO,SAAQ,UAAU;AACvC,WAAO;KAAE,MAAM;KAAW,OAAO;KAAS;;GAE7C;;AAEH,QAAO,uBAAuB;EAAE,cAAc;EAAsB;EAAgB,CAAC;;AAGvF,SAAS,4BAKP,cACA,WACoC;CACpC,MAAM,gBAAgB,eAAe,aAAa;CAClD,IAAI,QAA0B,OAAO,OAAO,KAAK;CACjD,MAAM,SAAS,UAKT;AACJ,UAAQ,OAAO,OAAO,KAAK;AAW3B,MAVe,UAAU;GACvB,SAAS,YAAY,MAAM,QAAQ;GACnC,UAAU,MAAM;GAChB,MAAM,MAAM;GACZ,OAAO;GACP,QAAQ,KAAA;GACR,OAAO,YAAY,MAAM,QAAQ;GACjC;GACA,QAAQ,MAAM;GACf,CACS,EAAE,SAAS,UACnB,OAAM,IAAI,UAAU,2DAA2D;AACjF,SAAO,EACL,SAAS,cACP,UAAU;GACR,SAAS,YAAY,UAAU,QAAQ;GACvC,UAAU,UAAU;GACpB,MAAM,UAAU;GAChB,OAAO;GACP,QAAQ,aAAa,UAAU,QAAQ;GACvC,OAAO,YAAY,UAAU,QAAQ;GACrC;GACA,QAAQ,UAAU;GACnB,CAAC,EACL;;AAEH,QAAO,4BAA4B;EAAE,cAAc;EAAsB;EAAgB,CAAC;;AAG5F,MAAa,cAAc,OAAO,OAAO,wBAAwB,EAC/D,YAAY,6BACb,CAAC"}
@@ -143,6 +143,9 @@ declare const collectionKey: unique symbol;
143
143
  type PathMarker<TValue> = {
144
144
  readonly [pathValue]: TValue;
145
145
  };
146
+ type PathValueOf<T> = T extends {
147
+ readonly [pathValue]: infer TValue;
148
+ } ? TValue : never;
146
149
  type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown> = { readonly [K in keyof S]: PathValue<S[K]> } & PathMarker<TValue>;
147
150
  type SchemaPath<S extends ObjectShape = ObjectShape> = SchemaPathFor<S, ShapeValue<S>>;
148
151
  type PathPick<S extends ObjectNode = ObjectNode> = (path: SchemaPath<S['shape']>) => PathMarker<unknown>;
@@ -315,8 +318,6 @@ type ReplaceParentAccess = {
315
318
  }>, true, unknown];
316
319
  };
317
320
  declare const replace: <T extends object & ReplaceParentAccess, K extends keyof Snapshot<T>>(container: T, key: K, value: NoInfer<Snapshot<T>[K]>) => void;
318
- /** Projection collection contexts use the same scoped access, with explicit collection tools. */
319
- type CollectionAccess<K extends string, N extends ValueSchemaNode> = TableAccess<K, N, false>;
320
321
  //#endregion
321
322
  //#region core/src/impact.d.ts
322
323
  type CollectionImpact<K> = {
@@ -454,5 +455,5 @@ type DocumentRuntime<S extends ObjectNode> = DocumentReadable<S> & {
454
455
  dispose(): void;
455
456
  };
456
457
  //#endregion
457
- export { ObjectShape as $, debugKey as A, CollectionPath as B, CollectionAccess as C, snapshot as D, replace as E, ChangeSet as F, DocumentTreeNode as G, DocumentAnchor as H, MemberChange as I, ImpactTarget as J, DocumentTreeValue as K, ValueTransition as L, read as M, resolveAddress as N, AddressRef as O, Change as P, ObjectNode as Q, CollectionId as R, DocumentImpact as S, Read as T, DocumentListConfig as U, DocumentAddress as V, DocumentNode as W, ListNode as X, Infer as Y, MapNode as Z, Unsubscribe as _, ParseError as _t, DocumentDisposedError as a, TreeNode as at, MutationIssueCode as b, parse as bt, DocumentReentrancyError as c, VariantShape as ct, LocalHistory as d, map as dt, OptionalNode as et, ObserverError as f, object as ft, TransactionResult as g, variant as gt, TransactionRejected as h, tree as ht, DocumentDiagnostic as i, TableNode as it, overlaps as j, contains as k, DocumentRuntime as l, field as lt, Synchronous as m, table as mt, CommitSource as n, ReadonlyValue as nt, DocumentProblem as o, ValueSchemaNode as ot, OperationResult as p, optional as pt, FieldNode as q, DocumentCommit as r, SchemaPath as rt, DocumentReadable as s, VariantNode as st, CommitListener as t, PathPick as tt, HistoryState as u, list as ut, Readable as v, ParseIssue as vt, Draft as w, CollectionImpact as x, MutationIssue as y, Validator as yt, CollectionNode as z };
458
- //# sourceMappingURL=contract-CeAnEPBA.d.ts.map
458
+ export { OptionalNode as $, overlaps as A, DocumentAddress as B, Draft as C, AddressRef as D, snapshot as E, MemberChange as F, DocumentTreeValue as G, DocumentListConfig as H, ValueTransition as I, Infer as J, FieldNode as K, CollectionId as L, resolveAddress as M, Change as N, contains as O, ChangeSet as P, ObjectShape as Q, CollectionNode as R, DocumentImpact as S, replace as T, DocumentNode as U, DocumentAnchor as V, DocumentTreeNode as W, MapNode as X, ListNode as Y, ObjectNode as Z, Unsubscribe as _, Validator as _t, DocumentDisposedError as a, VariantNode as at, MutationIssueCode as b, DocumentReentrancyError as c, list as ct, LocalHistory as d, optional as dt, PathValueOf as et, ObserverError as f, table as ft, TransactionResult as g, ParseIssue as gt, TransactionRejected as h, ParseError as ht, DocumentDiagnostic as i, TreeNode as it, read as j, debugKey as k, DocumentRuntime as l, map as lt, Synchronous as m, variant as mt, CommitSource as n, SchemaPath as nt, DocumentProblem as o, VariantShape as ot, OperationResult as p, tree as pt, ImpactTarget as q, DocumentCommit as r, TableNode as rt, DocumentReadable as s, field as st, CommitListener as t, ReadonlyValue as tt, HistoryState as u, object as ut, Readable as v, parse as vt, Read as w, CollectionImpact as x, MutationIssue as y, CollectionPath as z };
459
+ //# sourceMappingURL=contract-BT53Gg94.d.ts.map
@@ -143,6 +143,9 @@ declare const collectionKey: unique symbol;
143
143
  type PathMarker<TValue> = {
144
144
  readonly [pathValue]: TValue;
145
145
  };
146
+ type PathValueOf<T> = T extends {
147
+ readonly [pathValue]: infer TValue;
148
+ } ? TValue : never;
146
149
  type SchemaPathFor<S extends ObjectShape = ObjectShape, TValue = unknown> = { readonly [K in keyof S]: PathValue<S[K]> } & PathMarker<TValue>;
147
150
  type SchemaPath<S extends ObjectShape = ObjectShape> = SchemaPathFor<S, ShapeValue<S>>;
148
151
  type PathPick<S extends ObjectNode = ObjectNode> = (path: SchemaPath<S['shape']>) => PathMarker<unknown>;
@@ -315,8 +318,6 @@ type ReplaceParentAccess = {
315
318
  }>, true, unknown];
316
319
  };
317
320
  declare const replace: <T extends object & ReplaceParentAccess, K extends keyof Snapshot<T>>(container: T, key: K, value: NoInfer<Snapshot<T>[K]>) => void;
318
- /** Projection collection contexts use the same scoped access, with explicit collection tools. */
319
- type CollectionAccess<K extends string, N extends ValueSchemaNode> = TableAccess<K, N, false>;
320
321
  //#endregion
321
322
  //#region core/src/impact.d.ts
322
323
  type CollectionImpact<K> = {
@@ -454,5 +455,5 @@ type DocumentRuntime<S extends ObjectNode> = DocumentReadable<S> & {
454
455
  dispose(): void;
455
456
  };
456
457
  //#endregion
457
- export { ObjectShape as $, debugKey as A, CollectionPath as B, CollectionAccess as C, snapshot as D, replace as E, ChangeSet as F, DocumentTreeNode as G, DocumentAnchor as H, MemberChange as I, ImpactTarget as J, DocumentTreeValue as K, ValueTransition as L, read as M, resolveAddress as N, AddressRef as O, Change as P, ObjectNode as Q, CollectionId as R, DocumentImpact as S, Read as T, DocumentListConfig as U, DocumentAddress as V, DocumentNode as W, ListNode as X, Infer as Y, MapNode as Z, Unsubscribe as _, ParseError as _t, DocumentDisposedError as a, TreeNode as at, MutationIssueCode as b, parse as bt, DocumentReentrancyError as c, VariantShape as ct, LocalHistory as d, map as dt, OptionalNode as et, ObserverError as f, object as ft, TransactionResult as g, variant as gt, TransactionRejected as h, tree as ht, DocumentDiagnostic as i, TableNode as it, overlaps as j, contains as k, DocumentRuntime as l, field as lt, Synchronous as m, table as mt, CommitSource as n, ReadonlyValue as nt, DocumentProblem as o, ValueSchemaNode as ot, OperationResult as p, optional as pt, FieldNode as q, DocumentCommit as r, SchemaPath as rt, DocumentReadable as s, VariantNode as st, CommitListener as t, PathPick as tt, HistoryState as u, list as ut, Readable as v, ParseIssue as vt, Draft as w, CollectionImpact as x, MutationIssue as y, Validator as yt, CollectionNode as z };
458
- //# sourceMappingURL=contract-DtGVSXSK.d.cts.map
458
+ export { OptionalNode as $, overlaps as A, DocumentAddress as B, Draft as C, AddressRef as D, snapshot as E, MemberChange as F, DocumentTreeValue as G, DocumentListConfig as H, ValueTransition as I, Infer as J, FieldNode as K, CollectionId as L, resolveAddress as M, Change as N, contains as O, ChangeSet as P, ObjectShape as Q, CollectionNode as R, DocumentImpact as S, replace as T, DocumentNode as U, DocumentAnchor as V, DocumentTreeNode as W, MapNode as X, ListNode as Y, ObjectNode as Z, Unsubscribe as _, Validator as _t, DocumentDisposedError as a, VariantNode as at, MutationIssueCode as b, DocumentReentrancyError as c, list as ct, LocalHistory as d, optional as dt, PathValueOf as et, ObserverError as f, table as ft, TransactionResult as g, ParseIssue as gt, TransactionRejected as h, ParseError as ht, DocumentDiagnostic as i, TreeNode as it, read as j, debugKey as k, DocumentRuntime as l, map as lt, Synchronous as m, variant as mt, CommitSource as n, SchemaPath as nt, DocumentProblem as o, VariantShape as ot, OperationResult as p, tree as pt, ImpactTarget as q, DocumentCommit as r, TableNode as rt, DocumentReadable as s, field as st, CommitListener as t, ReadonlyValue as tt, HistoryState as u, object as ut, Readable as v, parse as vt, Read as w, CollectionImpact as x, MutationIssue as y, CollectionPath as z };
459
+ //# sourceMappingURL=contract-XmKnroJq.d.cts.map