doxum 0.1.12 → 0.1.14
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 +48 -39
- package/dist/advanced.cjs +116 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +42 -0
- package/dist/advanced.d.ts +42 -0
- package/dist/advanced.js +115 -0
- package/dist/advanced.js.map +1 -0
- package/dist/{contract-CeAnEPBA.d.ts → contract-BT53Gg94.d.ts} +5 -4
- package/dist/{contract-DtGVSXSK.d.cts → contract-XmKnroJq.d.cts} +5 -4
- package/dist/definition-BDW6i7fp.cjs +886 -0
- package/dist/definition-BDW6i7fp.cjs.map +1 -0
- package/dist/definition-DN6yW2vi.d.cts +99 -0
- package/dist/definition-Dr8tHwTD.d.ts +99 -0
- package/dist/definition-wOvuklwp.js +791 -0
- package/dist/definition-wOvuklwp.js.map +1 -0
- package/dist/{driver-xOIkwrB8.cjs → driver-BCyfqxsl.cjs} +1 -1
- package/dist/{driver-xOIkwrB8.cjs.map → driver-BCyfqxsl.cjs.map} +1 -1
- package/dist/{driver-BlR81Dqg.js → driver-CSnhMjbP.js} +1 -1
- package/dist/{driver-BlR81Dqg.js.map → driver-CSnhMjbP.js.map} +1 -1
- package/dist/index.cjs +31 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/{integration-BShL68Nc.cjs → integration-WniqaEPW.cjs} +2 -2
- package/dist/integration-WniqaEPW.cjs.map +1 -0
- package/dist/{integration-CWjttg7H.js → integration-zB8e-uNP.js} +2 -2
- package/dist/integration-zB8e-uNP.js.map +1 -0
- package/dist/integration.cjs +4 -3
- package/dist/integration.d.cts +3 -3
- package/dist/integration.d.ts +3 -3
- package/dist/integration.js +3 -3
- package/dist/local-sync.cjs +1 -1
- package/dist/local-sync.d.cts +1 -1
- package/dist/local-sync.d.ts +1 -1
- package/dist/local-sync.js +1 -1
- package/dist/react.cjs +63 -36
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +8 -7
- package/dist/react.d.ts +8 -7
- package/dist/react.js +63 -35
- package/dist/react.js.map +1 -1
- package/dist/{store-DBv58dns.cjs → store-6wMvZthf.cjs} +593 -992
- package/dist/store-6wMvZthf.cjs.map +1 -0
- package/dist/store-BCR20XSb.d.ts +28 -0
- package/dist/{store-7XBEcR8s.js → store-PLKs1KnS.js} +583 -922
- package/dist/store-PLKs1KnS.js.map +1 -0
- package/dist/store-jJ3SNYKH.d.cts +28 -0
- package/package.json +6 -1
- package/skills/doxum-runtime/SKILL.md +5 -7
- package/skills/doxum-runtime/references/guide.en.md +13 -16
- package/skills/doxum-runtime/references/guide.zh-CN.md +10 -14
- package/skills/doxum-runtime/references/patterns.en.md +12 -20
- package/skills/doxum-runtime/references/patterns.zh-CN.md +12 -18
- package/skills/doxum-runtime/references/projections.en.md +63 -199
- package/skills/doxum-runtime/references/projections.zh-CN.md +56 -180
- package/dist/integration-BShL68Nc.cjs.map +0 -1
- package/dist/integration-CWjttg7H.js.map +0 -1
- package/dist/store-2i8pYXqa.d.ts +0 -263
- package/dist/store-7XBEcR8s.js.map +0 -1
- package/dist/store-DBv58dns.cjs.map +0 -1
- 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 {
|
|
63
|
+
import { read, snapshot } from 'doxum';
|
|
64
64
|
|
|
65
|
-
const title =
|
|
66
|
-
const 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,53 @@ with `history: false` close the active group.
|
|
|
209
209
|
## Projections
|
|
210
210
|
|
|
211
211
|
```ts
|
|
212
|
-
import {
|
|
212
|
+
import { createProjectionRuntime, derive, input, observe } from 'doxum';
|
|
213
213
|
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
(
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
+
});
|
|
227
230
|
```
|
|
228
231
|
|
|
229
|
-
Projection declarations are lazy and reusable.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
`
|
|
235
|
-
`
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
+
`observe` is the single source boundary for documents, Doxum `Readable` values,
|
|
238
|
+
and eventful external sources. External sources declare `kind: 'value'` or
|
|
239
|
+
`kind: 'collection'`; collection invalidation remains keyed internally.
|
|
240
|
+
|
|
241
|
+
For retained state, reverse indexes and keyed patches, use the isolated advanced
|
|
242
|
+
entry point. Whole-value processors use `incremental(...)`; keyed collection
|
|
243
|
+
processors use `incremental.collection(...)`:
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
import { incremental } from 'doxum/advanced';
|
|
247
|
+
|
|
248
|
+
const doubled = incremental.collection([tasks], ({ sources, output }) => {
|
|
249
|
+
for (const [id, task] of sources[0]) output.set(id, task.value * 2);
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
In React, `useProjection(projection)` reads a value and
|
|
254
|
+
`useProjection(projection, selector, equality?)` tracks keyed reads such as
|
|
255
|
+
`tasks => tasks.get(taskId)`. Unrelated key changes do not execute that selector;
|
|
256
|
+
equality only filters a selector result after a related change. `useInput(input)`
|
|
257
|
+
returns the current value and its Runtime-local setter.
|
|
258
|
+
|
|
250
259
|
See [projection contracts](docs/projections.md).
|
|
251
260
|
|
|
252
261
|
## Local Sync
|
|
@@ -288,7 +297,7 @@ baselines from final published order copies. Architecture workloads include orde
|
|
|
288
297
|
round trips and repeated tree edits to expose costs hidden by commit-only benchmarks.
|
|
289
298
|
|
|
290
299
|
Builds produce root `dist` ESM/CJS/declarations for `doxum`, `doxum/integration`,
|
|
291
|
-
`doxum/local-sync` and `doxum/
|
|
300
|
+
`doxum/local-sync`, `doxum/react` and `doxum/advanced`. Source ownership is described in
|
|
292
301
|
[architecture](docs/architecture.md) and [AGENTS.md](AGENTS.md).
|
|
293
302
|
The runtime shares one transaction lifecycle; complete mutation operations are
|
|
294
303
|
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-BDW6i7fp.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,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,QA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
|
|
1
|
+
import { i as PublicCollection, l as CollectionDraft, n as Projection, r as ProjectionValues, u as CollectionRead } from "./definition-DN6yW2vi.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-Dr8tHwTD.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
|
package/dist/advanced.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { n as defineIncrementalValue, t as defineIncrementalCollection, u as snapshot } from "./definition-wOvuklwp.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,QAAQ,YAAY;EAC9E,MAAM,yBAAS,IAAI,KAAsB;EACzC,MAAM,OAAO;AACb,OAAK,MAAM,MAAM,KAAK,KAAK,CAAE,QAAO,IAAI,IAAI,KAAK,IAAI,GAAG,CAAC;AACzD,SAAO;;AAET,QAAO;;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AKP,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 {
|
|
458
|
-
//# sourceMappingURL=contract-
|
|
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 {
|
|
458
|
-
//# sourceMappingURL=contract-
|
|
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
|