doxum 0.1.23 → 0.1.26

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 (66) hide show
  1. package/README.md +208 -102
  2. package/dist/advanced.cjs +237 -2
  3. package/dist/advanced.cjs.map +1 -0
  4. package/dist/advanced.d.cts +90 -2
  5. package/dist/advanced.d.ts +90 -2
  6. package/dist/advanced.js +236 -1
  7. package/dist/advanced.js.map +1 -0
  8. package/dist/{contract-ULPQmiEs.d.ts → contract-CNR6BS75.d.cts} +216 -30
  9. package/dist/{contract-SYJFP0lM.d.cts → contract-COgxO5sv.d.ts} +216 -30
  10. package/dist/definition-CDOuvb5C.d.cts +111 -0
  11. package/dist/definition-xgk3YNBp.d.ts +111 -0
  12. package/dist/{driver-yFfvDMX5.js → driver-B5vdPohL.js} +59 -3
  13. package/dist/driver-B5vdPohL.js.map +1 -0
  14. package/dist/{driver-BD3DQOW6.cjs → driver-BL91gn7_.cjs} +107 -9
  15. package/dist/driver-BL91gn7_.cjs.map +1 -0
  16. package/dist/index.cjs +1637 -703
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +65 -33
  19. package/dist/index.d.ts +65 -33
  20. package/dist/index.js +1432 -497
  21. package/dist/index.js.map +1 -1
  22. package/dist/local-sync.cjs +69 -103
  23. package/dist/local-sync.cjs.map +1 -1
  24. package/dist/local-sync.d.cts +14 -26
  25. package/dist/local-sync.d.ts +14 -26
  26. package/dist/local-sync.js +68 -96
  27. package/dist/local-sync.js.map +1 -1
  28. package/dist/react.cjs +4 -5
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +6 -8
  31. package/dist/react.d.ts +6 -8
  32. package/dist/react.js +4 -5
  33. package/dist/react.js.map +1 -1
  34. package/dist/record-B2yRhYsc.js +28 -0
  35. package/dist/record-B2yRhYsc.js.map +1 -0
  36. package/dist/record-ChYUi8PP.cjs +45 -0
  37. package/dist/record-ChYUi8PP.cjs.map +1 -0
  38. package/dist/scheduler--137L3j-.js +500 -0
  39. package/dist/scheduler--137L3j-.js.map +1 -0
  40. package/dist/scheduler-D4VthaaK.cjs +589 -0
  41. package/dist/scheduler-D4VthaaK.cjs.map +1 -0
  42. package/package.json +6 -3
  43. package/skills/doxum-runtime/SKILL.md +32 -7
  44. package/skills/doxum-runtime/agents/openai.yaml +1 -1
  45. package/skills/doxum-runtime/references/api.en.md +249 -0
  46. package/skills/doxum-runtime/references/api.zh-CN.md +242 -0
  47. package/skills/doxum-runtime/references/guide.en.md +18 -8
  48. package/skills/doxum-runtime/references/guide.zh-CN.md +14 -6
  49. package/skills/doxum-runtime/references/invariants.en.md +29 -5
  50. package/skills/doxum-runtime/references/invariants.zh-CN.md +24 -6
  51. package/skills/doxum-runtime/references/patterns.en.md +78 -18
  52. package/skills/doxum-runtime/references/patterns.zh-CN.md +76 -18
  53. package/skills/doxum-runtime/references/projections.en.md +209 -119
  54. package/skills/doxum-runtime/references/projections.zh-CN.md +200 -101
  55. package/dist/advanced-CLJCWkHa.d.cts +0 -176
  56. package/dist/advanced-CRNHfJBu.js +0 -1224
  57. package/dist/advanced-CRNHfJBu.js.map +0 -1
  58. package/dist/advanced-Cle5g3B4.cjs +0 -1517
  59. package/dist/advanced-Cle5g3B4.cjs.map +0 -1
  60. package/dist/advanced-d6J61er9.d.ts +0 -176
  61. package/dist/context-BcLKGfq8.cjs +0 -149
  62. package/dist/context-BcLKGfq8.cjs.map +0 -1
  63. package/dist/context-DFEaDUv5.js +0 -84
  64. package/dist/context-DFEaDUv5.js.map +0 -1
  65. package/dist/driver-BD3DQOW6.cjs.map +0 -1
  66. package/dist/driver-yFfvDMX5.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { $ as TreeNode, A as ParseError, B as DocumentTreeNode, C as Read, D as ChangeSet, E as Change, G as MapNode, H as FieldNode, I as DocumentAddress, J as OptionalNode, K as ObjectNode, L as DocumentAnchor, M as parse, O as MemberChange, Q as TableNode, R as DocumentListConfig, S as Draft, T as snapshot, U as Infer, V as DocumentTreeValue, W as ListNode, X as ReadonlyValue, Y as PathValueOf, Z as SchemaPath, _ as Unsubscribe, a as DocumentProblem, at as map, b as CollectionImpact, c as DocumentRuntime, ct as table, d as ObserverError, et as Validator, f as OperationResult, g as Readable, h as TransactionResult, i as DocumentDisposedError, it as list, j as ParseIssue, k as ValueTransition, l as HistoryState, lt as tree, m as TransactionRejected, n as DocumentCommit, nt as VariantShape, o as DocumentReadable, ot as object, q as ObjectShape, r as DocumentDiagnostic, rt as field, s as DocumentReentrancyError, st as optional, t as CommitSource, tt as VariantNode, u as LocalHistory, ut as variant, v as MutationIssue, w as replace, x as DocumentImpact, y as MutationIssueCode, z as DocumentNode } from "./contract-SYJFP0lM.cjs";
2
- import { C as ProjectionError, S as ProjectionDisposedError, _ as ExternalCollectionEvent, b as ExternalValueEvent, d as Input, f as Projection, g as CollectionChange, h as observe, m as input, p as derive, u as incremental, v as ExternalCollectionRead, x as ExternalValueSource, y as ExternalCollectionSource } from "./advanced-CLJCWkHa.cjs";
1
+ import { $ as table, A as ParseError, B as DocumentListConfig, C as Read, D as ChangeSet, E as Change, F as CollectionPath, G as ReadonlyValue, H as DocumentTreeValue, I as PathValueOf, J as field, K as Schema, L as SchemaPath, M as parse, N as CollectionEntry, O as MemberChange, P as CollectionId, Q as optional, R as DocumentAddress, S as Draft, T as snapshot, U as Infer, V as DocumentTreeNode, W as ObjectSchema, X as map, Y as list, Z as object, _ as Unsubscribe, a as DocumentProblem, b as CollectionImpact, c as HistoryState, d as OperationResult, et as tree, f as ReadonlyDocument, g as Readable, h as TransactionResult, i as DocumentDisposedError, j as ParseIssue, k as ValueTransition, l as LocalHistory, m as TransactionRejected, n as DocumentCommit, o as DocumentReentrancyError, p as Synchronous, q as Validator, r as DocumentDiagnostic, s as DocumentRuntime, t as CommitSource, tt as variant, u as ObserverError, v as MutationIssue, w as replace, x as DocumentImpact, y as MutationIssueCode, z as DocumentAnchor } from "./contract-CNR6BS75.cjs";
2
+ import { a as Projection, d as ExternalCollectionRead, f as ExternalCollectionSource, g as ProjectionError, h as ProjectionDisposedError, i as KeyedProjection, m as ExternalValueSource, n as CollectionInputDraft, p as ExternalValueEvent, r as Input, t as CollectionInput, u as ExternalCollectionEvent } from "./definition-CDOuvb5C.cjs";
3
3
 
4
4
  //#region core/src/runtime.d.ts
5
- declare const createDocument: <S extends ObjectNode>(input: {
5
+ declare const createDocument: <S extends ObjectSchema<object>>(input: {
6
6
  readonly schema: S;
7
7
  readonly initial: Infer<S>;
8
8
  readonly history?: {
@@ -10,49 +10,81 @@ declare const createDocument: <S extends ObjectNode>(input: {
10
10
  } | false;
11
11
  }) => DocumentRuntime<S>;
12
12
  //#endregion
13
- //#region core/src/runtime/readable.d.ts
14
- declare const asReadable: <TSchema extends ObjectNode>(runtime: DocumentRuntime<TSchema>) => DocumentReadable<TSchema>;
15
- //#endregion
16
13
  //#region core/src/runtime/select.d.ts
17
- type DocumentSelector<TSchema extends ObjectNode, TResult> = (read: Read<TSchema>) => TResult;
18
- declare const read: <TSchema extends ObjectNode, TResult>(document: DocumentReadable<TSchema>, selector: DocumentSelector<TSchema, TResult>) => TResult;
19
- declare const select: <TSchema extends ObjectNode, TResult>(document: DocumentReadable<TSchema>, selector: DocumentSelector<TSchema, TResult>, equality?: (previous: TResult, next: TResult) => boolean) => Readable<TResult>;
14
+ type DocumentSelector<TSchema extends ObjectSchema<object>, TResult> = (read: Read<TSchema>) => TResult;
15
+ declare const read: <TSchema extends ObjectSchema<object>, TResult>(document: ReadonlyDocument<TSchema>, selector: DocumentSelector<TSchema, TResult>) => TResult;
16
+ declare const select: <TSchema extends ObjectSchema<object>, TResult>(document: ReadonlyDocument<TSchema>, selector: DocumentSelector<TSchema, TResult>, equality?: (previous: TResult, next: TResult) => boolean) => Readable<TResult>;
20
17
  //#endregion
21
- //#region core/src/projection/runtime.d.ts
22
- type KeyedDraft<K extends string, V> = {
23
- get(key: K): V | undefined;
24
- has(key: K): boolean;
25
- set(key: K, value: V): void;
26
- remove(key: K): void;
18
+ //#region core/src/projection/input.d.ts
19
+ declare const input: (<T>(initial: T, equality?: (previous: T, next: T) => boolean) => Input<T>) & {
20
+ collection: <K extends string, V>(initial?: ReadonlyMap<K, V>, equality?: (previous: V, next: V) => boolean) => CollectionInput<K, V>;
21
+ };
22
+ //#endregion
23
+ //#region core/src/projection/observe.d.ts
24
+ /** Establish a lazy reactive boundary from a document, readable, or external source. */
25
+ declare function observe<S extends ObjectSchema<object>>(document: ReadonlyDocument<S>): Projection<Infer<S>>;
26
+ declare function observe<T>(source: ExternalValueSource<T>): Projection<T>;
27
+ declare function observe<K extends string, V>(source: ExternalCollectionSource<K, V>): KeyedProjection<K, V>;
28
+ declare function observe<T>(readable: Readable<T>): Projection<T>;
29
+ declare function observe<S extends ObjectSchema<object>, P extends CollectionPath>(document: ReadonlyDocument<S>, selector: (path: SchemaPath<S>) => P): KeyedProjection<CollectionId<P>, ReadonlyValue<CollectionEntry<P>>>;
30
+ declare function observe<S extends ObjectSchema<object>, P>(document: ReadonlyDocument<S>, selector: (path: SchemaPath<S>) => P): Projection<PathValueOf<P>>;
31
+ //#endregion
32
+ //#region core/src/projection/derive.d.ts
33
+ type ProjectionDependencies = Readonly<Record<string, Projection<unknown>>>;
34
+ type ProjectionValues<D extends ProjectionDependencies> = { readonly [K in keyof D]: D[K] extends Projection<infer T> ? T : never };
35
+ type Equality<T> = (previous: T, next: T) => boolean;
36
+ /** A declared dynamic lookup from one driver entry to one key in another keyed projection. */
37
+ type KeyedDependency<DriverKey extends string, DriverValue, SourceKey extends string = string, SourceValue = unknown> = {
38
+ readonly source: KeyedProjection<SourceKey, SourceValue>;
39
+ readonly key: (value: DriverValue, key: DriverKey) => Synchronous<SourceKey | undefined>;
27
40
  };
41
+ type KeyedDeriveDependency<K extends string, V> = (Projection<unknown> & {
42
+ readonly source?: never;
43
+ readonly key?: never;
44
+ }) | KeyedDependency<K, V, string, unknown>;
45
+ type KeyedDeriveDependencies<K extends string, V, D extends object> = { readonly [P in keyof D]: P extends string ? KeyedDeriveDependency<K, V> : never };
46
+ type KeyedDependencyValues<D extends Readonly<Record<string, unknown>>> = { readonly [P in keyof D]: D[P] extends {
47
+ readonly source: KeyedProjection<infer _K extends string, infer V>;
48
+ } ? V | undefined : D[P] extends Projection<infer T> ? T : never };
49
+ declare function createValueDerive<const D extends ProjectionDependencies, T>(dependencies: D, compute: (values: ProjectionValues<D>) => Synchronous<T>, equality?: Equality<T>): Projection<T>;
50
+ declare function createKeyedDerive<K extends string, V, T>(source: KeyedProjection<K, V>, select: (value: V, key: K) => Synchronous<T>, equality?: Equality<T>): KeyedProjection<K, T>;
51
+ declare function createKeyedDerive<K extends string, V, const D extends object & KeyedDeriveDependencies<K, V, D>, T>(source: KeyedProjection<K, V>, dependencies: D, select: (value: V, key: K, dependencies: KeyedDependencyValues<D>) => Synchronous<T>, equality?: Equality<T>): KeyedProjection<K, T>;
52
+ declare const derive: typeof createValueDerive & {
53
+ keyed: typeof createKeyedDerive;
54
+ };
55
+ //#endregion
56
+ //#region core/src/projection/runtime.d.ts
28
57
  type ProjectionRuntime = {
29
- get<T>(projection: Projection<T, unknown>): T;
30
- readable<T>(projection: Projection<T, unknown>): Readable<T>;
31
- readable<T, R>(projection: Projection<T, unknown>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
32
- set<T>(input: Input<T>, value: T): void;
33
- update<K extends string, V>(input: Input<ReadonlyMap<K, V>, CollectionChange<K, V>>, run: (draft: KeyedDraft<K, V>) => void): void;
34
- batch<T>(run: () => T): T;
35
- batch<T>(options: {
58
+ read<T>(projection: Projection<T>): T;
59
+ select<T>(projection: Projection<T>): Readable<T>;
60
+ select<T, R>(projection: Projection<T>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
61
+ update<T>(input: Input<T>, value: T): void;
62
+ update<K extends string, V>(input: CollectionInput<K, V>, run: (draft: CollectionInputDraft<K, V>) => void): void;
63
+ batch<T>(run: () => T, options?: {
36
64
  readonly cause?: unknown;
37
- }, run: () => T): T;
65
+ }): T;
38
66
  scope(): ProjectionScope;
39
67
  dispose(): void;
40
68
  };
69
+ type ProjectionOwnershipTree = {
70
+ readonly [name: string]: Projection<unknown> | ProjectionOwnershipTree;
71
+ };
41
72
  type ProjectionScope = {
42
- readonly input: typeof input;
43
- readonly derive: typeof derive;
44
- readonly incremental: typeof incremental;
45
- get<T>(projection: Projection<T, unknown>): T;
46
- readable<T>(projection: Projection<T, unknown>): Readable<T>;
47
- readable<T, R>(projection: Projection<T, unknown>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
48
- set<T>(input: Input<T>, value: T): void;
49
- update<K extends string, V>(input: Input<ReadonlyMap<K, V>, CollectionChange<K, V>>, run: (draft: KeyedDraft<K, V>) => void): void;
50
- batch: ProjectionRuntime['batch'];
73
+ own<P extends Projection<unknown>>(projection: P): P;
74
+ own<T extends ProjectionOwnershipTree>(tree: T): T;
75
+ read<T>(projection: Projection<T>): T;
76
+ select<T>(projection: Projection<T>): Readable<T>;
77
+ select<T, R>(projection: Projection<T>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
78
+ update<T>(input: Input<T>, value: T): void;
79
+ update<K extends string, V>(input: CollectionInput<K, V>, run: (draft: CollectionInputDraft<K, V>) => void): void;
80
+ batch<T>(run: () => T, options?: {
81
+ readonly cause?: unknown;
82
+ }): T;
51
83
  dispose(): void;
52
84
  };
53
85
  declare const createProjectionRuntime: (options?: {
54
86
  readonly onError?: (error: ProjectionError) => void;
55
87
  }) => ProjectionRuntime;
56
88
  //#endregion
57
- export { type Change, type ChangeSet, type CollectionChange, type CollectionImpact, type CommitSource, type DocumentAddress, type DocumentAnchor, type DocumentCommit, type DocumentDiagnostic, DocumentDisposedError, type DocumentImpact, type DocumentListConfig, type DocumentNode, type DocumentProblem, type DocumentReadable, DocumentReentrancyError, type DocumentRuntime, type DocumentSelector, type DocumentTreeNode, type DocumentTreeValue, type Draft, type ExternalCollectionEvent, type ExternalCollectionRead, type ExternalCollectionSource, type ExternalValueEvent, type ExternalValueSource, type FieldNode, type HistoryState, type Infer, type Input, type ListNode, type LocalHistory, type MapNode, type MemberChange, type MutationIssue, type MutationIssueCode, type ObjectNode, type ObjectShape, type ObserverError, type OperationResult, type OptionalNode, ParseError, type ParseIssue, type PathValueOf, type Projection, ProjectionDisposedError, ProjectionError, type ProjectionRuntime, type ProjectionScope, type Read, type Readable, type ReadonlyValue, type SchemaPath, type TableNode, TransactionRejected, type TransactionResult, type TreeNode, type Unsubscribe, type Validator, type ValueTransition, type VariantNode, type VariantShape, asReadable, createDocument, createProjectionRuntime, derive, field, input, list, map, object, observe, optional, parse, read, replace, select, snapshot, table, tree, variant };
89
+ export { type Change, type ChangeSet, type CollectionImpact, type CollectionInput, type CollectionInputDraft, type CommitSource, type DocumentAddress, type DocumentAnchor, type DocumentCommit, type DocumentDiagnostic, DocumentDisposedError, type DocumentImpact, type DocumentListConfig, type DocumentProblem, DocumentReentrancyError, type DocumentRuntime, type DocumentSelector, type DocumentTreeNode, type DocumentTreeValue, type Draft, type ExternalCollectionEvent, type ExternalCollectionRead, type ExternalCollectionSource, type ExternalValueEvent, type ExternalValueSource, type HistoryState, type Infer, type Input, type KeyedProjection, type LocalHistory, type MemberChange, type MutationIssue, type MutationIssueCode, type ObjectSchema, type ObserverError, type OperationResult, ParseError, type ParseIssue, type PathValueOf, type Projection, ProjectionDisposedError, ProjectionError, type ProjectionRuntime, type ProjectionScope, type Read, type Readable, type ReadonlyDocument, type ReadonlyValue, type Schema, type SchemaPath, TransactionRejected, type TransactionResult, type Unsubscribe, type Validator, type ValueTransition, createDocument, createProjectionRuntime, derive, field, input, list, map, object, observe, optional, parse, read, replace, select, snapshot, table, tree, variant };
58
90
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { $ as TreeNode, A as ParseError, B as DocumentTreeNode, C as Read, D as ChangeSet, E as Change, G as MapNode, H as FieldNode, I as DocumentAddress, J as OptionalNode, K as ObjectNode, L as DocumentAnchor, M as parse, O as MemberChange, Q as TableNode, R as DocumentListConfig, S as Draft, T as snapshot, U as Infer, V as DocumentTreeValue, W as ListNode, X as ReadonlyValue, Y as PathValueOf, Z as SchemaPath, _ as Unsubscribe, a as DocumentProblem, at as map, b as CollectionImpact, c as DocumentRuntime, ct as table, d as ObserverError, et as Validator, f as OperationResult, g as Readable, h as TransactionResult, i as DocumentDisposedError, it as list, j as ParseIssue, k as ValueTransition, l as HistoryState, lt as tree, m as TransactionRejected, n as DocumentCommit, nt as VariantShape, o as DocumentReadable, ot as object, q as ObjectShape, r as DocumentDiagnostic, rt as field, s as DocumentReentrancyError, st as optional, t as CommitSource, tt as VariantNode, u as LocalHistory, ut as variant, v as MutationIssue, w as replace, x as DocumentImpact, y as MutationIssueCode, z as DocumentNode } from "./contract-ULPQmiEs.js";
2
- import { C as ProjectionError, S as ProjectionDisposedError, _ as ExternalCollectionEvent, b as ExternalValueEvent, d as Input, f as Projection, g as CollectionChange, h as observe, m as input, p as derive, u as incremental, v as ExternalCollectionRead, x as ExternalValueSource, y as ExternalCollectionSource } from "./advanced-d6J61er9.js";
1
+ import { $ as table, A as ParseError, B as DocumentListConfig, C as Read, D as ChangeSet, E as Change, F as CollectionPath, G as ReadonlyValue, H as DocumentTreeValue, I as PathValueOf, J as field, K as Schema, L as SchemaPath, M as parse, N as CollectionEntry, O as MemberChange, P as CollectionId, Q as optional, R as DocumentAddress, S as Draft, T as snapshot, U as Infer, V as DocumentTreeNode, W as ObjectSchema, X as map, Y as list, Z as object, _ as Unsubscribe, a as DocumentProblem, b as CollectionImpact, c as HistoryState, d as OperationResult, et as tree, f as ReadonlyDocument, g as Readable, h as TransactionResult, i as DocumentDisposedError, j as ParseIssue, k as ValueTransition, l as LocalHistory, m as TransactionRejected, n as DocumentCommit, o as DocumentReentrancyError, p as Synchronous, q as Validator, r as DocumentDiagnostic, s as DocumentRuntime, t as CommitSource, tt as variant, u as ObserverError, v as MutationIssue, w as replace, x as DocumentImpact, y as MutationIssueCode, z as DocumentAnchor } from "./contract-COgxO5sv.js";
2
+ import { a as Projection, d as ExternalCollectionRead, f as ExternalCollectionSource, g as ProjectionError, h as ProjectionDisposedError, i as KeyedProjection, m as ExternalValueSource, n as CollectionInputDraft, p as ExternalValueEvent, r as Input, t as CollectionInput, u as ExternalCollectionEvent } from "./definition-xgk3YNBp.js";
3
3
 
4
4
  //#region core/src/runtime.d.ts
5
- declare const createDocument: <S extends ObjectNode>(input: {
5
+ declare const createDocument: <S extends ObjectSchema<object>>(input: {
6
6
  readonly schema: S;
7
7
  readonly initial: Infer<S>;
8
8
  readonly history?: {
@@ -10,49 +10,81 @@ declare const createDocument: <S extends ObjectNode>(input: {
10
10
  } | false;
11
11
  }) => DocumentRuntime<S>;
12
12
  //#endregion
13
- //#region core/src/runtime/readable.d.ts
14
- declare const asReadable: <TSchema extends ObjectNode>(runtime: DocumentRuntime<TSchema>) => DocumentReadable<TSchema>;
15
- //#endregion
16
13
  //#region core/src/runtime/select.d.ts
17
- type DocumentSelector<TSchema extends ObjectNode, TResult> = (read: Read<TSchema>) => TResult;
18
- declare const read: <TSchema extends ObjectNode, TResult>(document: DocumentReadable<TSchema>, selector: DocumentSelector<TSchema, TResult>) => TResult;
19
- declare const select: <TSchema extends ObjectNode, TResult>(document: DocumentReadable<TSchema>, selector: DocumentSelector<TSchema, TResult>, equality?: (previous: TResult, next: TResult) => boolean) => Readable<TResult>;
14
+ type DocumentSelector<TSchema extends ObjectSchema<object>, TResult> = (read: Read<TSchema>) => TResult;
15
+ declare const read: <TSchema extends ObjectSchema<object>, TResult>(document: ReadonlyDocument<TSchema>, selector: DocumentSelector<TSchema, TResult>) => TResult;
16
+ declare const select: <TSchema extends ObjectSchema<object>, TResult>(document: ReadonlyDocument<TSchema>, selector: DocumentSelector<TSchema, TResult>, equality?: (previous: TResult, next: TResult) => boolean) => Readable<TResult>;
20
17
  //#endregion
21
- //#region core/src/projection/runtime.d.ts
22
- type KeyedDraft<K extends string, V> = {
23
- get(key: K): V | undefined;
24
- has(key: K): boolean;
25
- set(key: K, value: V): void;
26
- remove(key: K): void;
18
+ //#region core/src/projection/input.d.ts
19
+ declare const input: (<T>(initial: T, equality?: (previous: T, next: T) => boolean) => Input<T>) & {
20
+ collection: <K extends string, V>(initial?: ReadonlyMap<K, V>, equality?: (previous: V, next: V) => boolean) => CollectionInput<K, V>;
21
+ };
22
+ //#endregion
23
+ //#region core/src/projection/observe.d.ts
24
+ /** Establish a lazy reactive boundary from a document, readable, or external source. */
25
+ declare function observe<S extends ObjectSchema<object>>(document: ReadonlyDocument<S>): Projection<Infer<S>>;
26
+ declare function observe<T>(source: ExternalValueSource<T>): Projection<T>;
27
+ declare function observe<K extends string, V>(source: ExternalCollectionSource<K, V>): KeyedProjection<K, V>;
28
+ declare function observe<T>(readable: Readable<T>): Projection<T>;
29
+ declare function observe<S extends ObjectSchema<object>, P extends CollectionPath>(document: ReadonlyDocument<S>, selector: (path: SchemaPath<S>) => P): KeyedProjection<CollectionId<P>, ReadonlyValue<CollectionEntry<P>>>;
30
+ declare function observe<S extends ObjectSchema<object>, P>(document: ReadonlyDocument<S>, selector: (path: SchemaPath<S>) => P): Projection<PathValueOf<P>>;
31
+ //#endregion
32
+ //#region core/src/projection/derive.d.ts
33
+ type ProjectionDependencies = Readonly<Record<string, Projection<unknown>>>;
34
+ type ProjectionValues<D extends ProjectionDependencies> = { readonly [K in keyof D]: D[K] extends Projection<infer T> ? T : never };
35
+ type Equality<T> = (previous: T, next: T) => boolean;
36
+ /** A declared dynamic lookup from one driver entry to one key in another keyed projection. */
37
+ type KeyedDependency<DriverKey extends string, DriverValue, SourceKey extends string = string, SourceValue = unknown> = {
38
+ readonly source: KeyedProjection<SourceKey, SourceValue>;
39
+ readonly key: (value: DriverValue, key: DriverKey) => Synchronous<SourceKey | undefined>;
27
40
  };
41
+ type KeyedDeriveDependency<K extends string, V> = (Projection<unknown> & {
42
+ readonly source?: never;
43
+ readonly key?: never;
44
+ }) | KeyedDependency<K, V, string, unknown>;
45
+ type KeyedDeriveDependencies<K extends string, V, D extends object> = { readonly [P in keyof D]: P extends string ? KeyedDeriveDependency<K, V> : never };
46
+ type KeyedDependencyValues<D extends Readonly<Record<string, unknown>>> = { readonly [P in keyof D]: D[P] extends {
47
+ readonly source: KeyedProjection<infer _K extends string, infer V>;
48
+ } ? V | undefined : D[P] extends Projection<infer T> ? T : never };
49
+ declare function createValueDerive<const D extends ProjectionDependencies, T>(dependencies: D, compute: (values: ProjectionValues<D>) => Synchronous<T>, equality?: Equality<T>): Projection<T>;
50
+ declare function createKeyedDerive<K extends string, V, T>(source: KeyedProjection<K, V>, select: (value: V, key: K) => Synchronous<T>, equality?: Equality<T>): KeyedProjection<K, T>;
51
+ declare function createKeyedDerive<K extends string, V, const D extends object & KeyedDeriveDependencies<K, V, D>, T>(source: KeyedProjection<K, V>, dependencies: D, select: (value: V, key: K, dependencies: KeyedDependencyValues<D>) => Synchronous<T>, equality?: Equality<T>): KeyedProjection<K, T>;
52
+ declare const derive: typeof createValueDerive & {
53
+ keyed: typeof createKeyedDerive;
54
+ };
55
+ //#endregion
56
+ //#region core/src/projection/runtime.d.ts
28
57
  type ProjectionRuntime = {
29
- get<T>(projection: Projection<T, unknown>): T;
30
- readable<T>(projection: Projection<T, unknown>): Readable<T>;
31
- readable<T, R>(projection: Projection<T, unknown>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
32
- set<T>(input: Input<T>, value: T): void;
33
- update<K extends string, V>(input: Input<ReadonlyMap<K, V>, CollectionChange<K, V>>, run: (draft: KeyedDraft<K, V>) => void): void;
34
- batch<T>(run: () => T): T;
35
- batch<T>(options: {
58
+ read<T>(projection: Projection<T>): T;
59
+ select<T>(projection: Projection<T>): Readable<T>;
60
+ select<T, R>(projection: Projection<T>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
61
+ update<T>(input: Input<T>, value: T): void;
62
+ update<K extends string, V>(input: CollectionInput<K, V>, run: (draft: CollectionInputDraft<K, V>) => void): void;
63
+ batch<T>(run: () => T, options?: {
36
64
  readonly cause?: unknown;
37
- }, run: () => T): T;
65
+ }): T;
38
66
  scope(): ProjectionScope;
39
67
  dispose(): void;
40
68
  };
69
+ type ProjectionOwnershipTree = {
70
+ readonly [name: string]: Projection<unknown> | ProjectionOwnershipTree;
71
+ };
41
72
  type ProjectionScope = {
42
- readonly input: typeof input;
43
- readonly derive: typeof derive;
44
- readonly incremental: typeof incremental;
45
- get<T>(projection: Projection<T, unknown>): T;
46
- readable<T>(projection: Projection<T, unknown>): Readable<T>;
47
- readable<T, R>(projection: Projection<T, unknown>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
48
- set<T>(input: Input<T>, value: T): void;
49
- update<K extends string, V>(input: Input<ReadonlyMap<K, V>, CollectionChange<K, V>>, run: (draft: KeyedDraft<K, V>) => void): void;
50
- batch: ProjectionRuntime['batch'];
73
+ own<P extends Projection<unknown>>(projection: P): P;
74
+ own<T extends ProjectionOwnershipTree>(tree: T): T;
75
+ read<T>(projection: Projection<T>): T;
76
+ select<T>(projection: Projection<T>): Readable<T>;
77
+ select<T, R>(projection: Projection<T>, selector: (value: T) => R, equality?: (previous: R, next: R) => boolean): Readable<R>;
78
+ update<T>(input: Input<T>, value: T): void;
79
+ update<K extends string, V>(input: CollectionInput<K, V>, run: (draft: CollectionInputDraft<K, V>) => void): void;
80
+ batch<T>(run: () => T, options?: {
81
+ readonly cause?: unknown;
82
+ }): T;
51
83
  dispose(): void;
52
84
  };
53
85
  declare const createProjectionRuntime: (options?: {
54
86
  readonly onError?: (error: ProjectionError) => void;
55
87
  }) => ProjectionRuntime;
56
88
  //#endregion
57
- export { type Change, type ChangeSet, type CollectionChange, type CollectionImpact, type CommitSource, type DocumentAddress, type DocumentAnchor, type DocumentCommit, type DocumentDiagnostic, DocumentDisposedError, type DocumentImpact, type DocumentListConfig, type DocumentNode, type DocumentProblem, type DocumentReadable, DocumentReentrancyError, type DocumentRuntime, type DocumentSelector, type DocumentTreeNode, type DocumentTreeValue, type Draft, type ExternalCollectionEvent, type ExternalCollectionRead, type ExternalCollectionSource, type ExternalValueEvent, type ExternalValueSource, type FieldNode, type HistoryState, type Infer, type Input, type ListNode, type LocalHistory, type MapNode, type MemberChange, type MutationIssue, type MutationIssueCode, type ObjectNode, type ObjectShape, type ObserverError, type OperationResult, type OptionalNode, ParseError, type ParseIssue, type PathValueOf, type Projection, ProjectionDisposedError, ProjectionError, type ProjectionRuntime, type ProjectionScope, type Read, type Readable, type ReadonlyValue, type SchemaPath, type TableNode, TransactionRejected, type TransactionResult, type TreeNode, type Unsubscribe, type Validator, type ValueTransition, type VariantNode, type VariantShape, asReadable, createDocument, createProjectionRuntime, derive, field, input, list, map, object, observe, optional, parse, read, replace, select, snapshot, table, tree, variant };
89
+ export { type Change, type ChangeSet, type CollectionImpact, type CollectionInput, type CollectionInputDraft, type CommitSource, type DocumentAddress, type DocumentAnchor, type DocumentCommit, type DocumentDiagnostic, DocumentDisposedError, type DocumentImpact, type DocumentListConfig, type DocumentProblem, DocumentReentrancyError, type DocumentRuntime, type DocumentSelector, type DocumentTreeNode, type DocumentTreeValue, type Draft, type ExternalCollectionEvent, type ExternalCollectionRead, type ExternalCollectionSource, type ExternalValueEvent, type ExternalValueSource, type HistoryState, type Infer, type Input, type KeyedProjection, type LocalHistory, type MemberChange, type MutationIssue, type MutationIssueCode, type ObjectSchema, type ObserverError, type OperationResult, ParseError, type ParseIssue, type PathValueOf, type Projection, ProjectionDisposedError, ProjectionError, type ProjectionRuntime, type ProjectionScope, type Read, type Readable, type ReadonlyDocument, type ReadonlyValue, type Schema, type SchemaPath, TransactionRejected, type TransactionResult, type Unsubscribe, type Validator, type ValueTransition, createDocument, createProjectionRuntime, derive, field, input, list, map, object, observe, optional, parse, read, replace, select, snapshot, table, tree, variant };
58
90
  //# sourceMappingURL=index.d.ts.map