doxum 0.1.13 → 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 +4 -0
- package/dist/advanced.cjs +1 -1
- package/dist/advanced.d.cts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +1 -1
- package/dist/{definition-177L4Amk.cjs → definition-BDW6i7fp.cjs} +8 -20
- package/dist/{definition-177L4Amk.cjs.map → definition-BDW6i7fp.cjs.map} +1 -1
- package/dist/{definition-kxnWUvX9.d.cts → definition-DN6yW2vi.d.cts} +37 -36
- package/dist/{definition-BlMeHwdz.d.ts → definition-Dr8tHwTD.d.ts} +37 -36
- package/dist/{definition-DXrKMVs7.js → definition-wOvuklwp.js} +9 -3
- package/dist/{definition-DXrKMVs7.js.map → definition-wOvuklwp.js.map} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/integration-WniqaEPW.cjs +30 -0
- package/dist/integration-WniqaEPW.cjs.map +1 -0
- package/dist/{integration-Bco8ZB16.js → integration-zB8e-uNP.js} +3 -7
- package/dist/integration-zB8e-uNP.js.map +1 -0
- package/dist/integration.cjs +2 -5
- package/dist/integration.d.cts +3 -7
- package/dist/integration.d.ts +3 -7
- package/dist/integration.js +3 -3
- package/dist/react.cjs +2 -2
- package/dist/react.js +2 -2
- package/dist/{store-DcDpDgjk.cjs → store-6wMvZthf.cjs} +4 -6
- package/dist/store-6wMvZthf.cjs.map +1 -0
- package/dist/{store-P5dJ7TVe.d.ts → store-BCR20XSb.d.ts} +2 -2
- package/dist/{store-CtgvCVFg.js → store-PLKs1KnS.js} +4 -6
- package/dist/store-PLKs1KnS.js.map +1 -0
- package/dist/{store-CDeqZEE3.d.cts → store-jJ3SNYKH.d.cts} +2 -2
- package/package.json +1 -1
- package/skills/doxum-runtime/references/guide.en.md +2 -1
- package/skills/doxum-runtime/references/guide.zh-CN.md +2 -1
- package/skills/doxum-runtime/references/projections.en.md +8 -1
- package/skills/doxum-runtime/references/projections.zh-CN.md +7 -1
- package/dist/integration-Bco8ZB16.js.map +0 -1
- package/dist/integration-CEUn96tx.cjs +0 -52
- package/dist/integration-CEUn96tx.cjs.map +0 -1
- package/dist/store-CtgvCVFg.js.map +0 -1
- package/dist/store-DcDpDgjk.cjs.map +0 -1
|
@@ -3,55 +3,53 @@ import { J as Infer, L as CollectionId, R as CollectionNode, Z as ObjectNode, _
|
|
|
3
3
|
//#region core/src/projection/contract.d.ts
|
|
4
4
|
/** Opaque application metadata identifying the action that produced a source event. */
|
|
5
5
|
type Cause = unknown;
|
|
6
|
-
type BatchContext = {
|
|
7
|
-
readonly id: number;
|
|
8
|
-
readonly cause?: Cause;
|
|
9
|
-
};
|
|
10
6
|
type BatchOptions = {
|
|
11
7
|
readonly cause?: Cause;
|
|
12
8
|
};
|
|
13
|
-
type CollectionEntryTransition<K extends string, V> = {
|
|
14
|
-
readonly key: K;
|
|
15
|
-
readonly kind: 'added' | 'updated' | 'removed';
|
|
16
|
-
readonly before: V | undefined;
|
|
17
|
-
readonly after: V | undefined;
|
|
18
|
-
};
|
|
19
|
-
type ValueContext<T, D = unknown> = {
|
|
20
|
-
readonly value: T;
|
|
21
|
-
readonly previous: T;
|
|
22
|
-
readonly changed: boolean;
|
|
23
|
-
readonly revision: number;
|
|
24
|
-
readonly reset: boolean;
|
|
25
|
-
readonly detail?: D;
|
|
26
|
-
readonly cause?: Cause;
|
|
27
|
-
readonly batch?: BatchContext;
|
|
28
|
-
};
|
|
29
9
|
type CollectionRead<K extends string, V> = {
|
|
30
10
|
get(key: K): V | undefined;
|
|
31
11
|
has(key: K): boolean;
|
|
32
12
|
ids(): readonly K[];
|
|
33
13
|
};
|
|
34
|
-
type
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
readonly reset: boolean;
|
|
39
|
-
readonly transitions: (keys?: Iterable<K>) => readonly CollectionEntryTransition<K, V>[];
|
|
40
|
-
readonly detail?: D;
|
|
41
|
-
readonly cause?: Cause;
|
|
42
|
-
readonly batch?: BatchContext;
|
|
14
|
+
type ExternalCollectionRead<K extends string, V> = {
|
|
15
|
+
readonly get: (key: K) => V | undefined;
|
|
16
|
+
readonly has: (key: K) => boolean;
|
|
17
|
+
readonly ids: () => readonly K[];
|
|
43
18
|
};
|
|
44
19
|
type ExternalValueSource<T, D = unknown> = {
|
|
45
20
|
readonly kind: 'value';
|
|
46
21
|
current(): T;
|
|
47
22
|
revision(): number;
|
|
48
|
-
subscribe(listener: (event:
|
|
23
|
+
subscribe(listener: (event: ExternalValueEvent<T, D>) => void): Unsubscribe;
|
|
49
24
|
};
|
|
50
25
|
type ExternalCollectionSource<K extends string, V, D = unknown> = {
|
|
51
26
|
readonly kind: 'collection';
|
|
52
|
-
current():
|
|
27
|
+
current(): ExternalCollectionRead<K, V>;
|
|
53
28
|
revision(): number;
|
|
54
|
-
subscribe(listener: (event:
|
|
29
|
+
subscribe(listener: (event: ExternalCollectionEvent<K, V, D>) => void): Unsubscribe;
|
|
30
|
+
};
|
|
31
|
+
type ExternalValueEvent<T, D = unknown> = {
|
|
32
|
+
readonly value: T;
|
|
33
|
+
readonly revision: number;
|
|
34
|
+
readonly reset?: boolean;
|
|
35
|
+
readonly detail?: D;
|
|
36
|
+
readonly cause?: Cause;
|
|
37
|
+
readonly batch?: {
|
|
38
|
+
readonly id: number;
|
|
39
|
+
readonly cause?: Cause;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type ExternalCollectionEvent<K extends string, V, D = unknown> = {
|
|
43
|
+
readonly previous: ExternalCollectionRead<K, V>;
|
|
44
|
+
readonly revision: number;
|
|
45
|
+
readonly reset?: boolean;
|
|
46
|
+
readonly change?: CollectionImpact<K>;
|
|
47
|
+
readonly detail?: D;
|
|
48
|
+
readonly cause?: Cause;
|
|
49
|
+
readonly batch?: {
|
|
50
|
+
readonly id: number;
|
|
51
|
+
readonly cause?: Cause;
|
|
52
|
+
};
|
|
55
53
|
};
|
|
56
54
|
type CollectionDraft<K extends string, V> = {
|
|
57
55
|
set(key: K, value: V): void;
|
|
@@ -85,14 +83,17 @@ type PublicCollection<K extends string, V> = ReadonlyMap<K, V>;
|
|
|
85
83
|
type ObservedCollection<P extends CollectionPath> = PublicCollection<CollectionId<P>, ReadonlyValue<Infer<CollectionNode<P>>>>;
|
|
86
84
|
declare const input: <T>(initial: T, equality?: (previous: T, next: T) => boolean) => Input<T>;
|
|
87
85
|
/**
|
|
88
|
-
* Establishes a reactive boundary from a document
|
|
89
|
-
* when the definition is materialized, so
|
|
86
|
+
* Establishes a reactive boundary from a document, readable, or external
|
|
87
|
+
* source. The selector is compiled when the definition is materialized, so
|
|
88
|
+
* declarations stay lazy and reusable.
|
|
90
89
|
*/
|
|
91
90
|
declare function observe<S extends ObjectNode>(document: DocumentReadable<S>): Projection<Infer<S>>;
|
|
91
|
+
declare function observe<T, D>(source: ExternalValueSource<T, D>): Projection<T>;
|
|
92
|
+
declare function observe<K extends string, V, D>(source: ExternalCollectionSource<K, V, D>): Projection<PublicCollection<K, V>>;
|
|
92
93
|
declare function observe<T>(readable: Readable<T>): Projection<T>;
|
|
93
94
|
declare function observe<S extends ObjectNode, P extends CollectionPath>(document: DocumentReadable<S>, selector: (path: SchemaPath<S['shape']>) => P): Projection<ObservedCollection<P>>;
|
|
94
95
|
declare function observe<S extends ObjectNode, P>(document: DocumentReadable<S>, selector: (path: SchemaPath<S['shape']>) => P): Projection<PathValueOf<P>>;
|
|
95
96
|
declare function derive<const D extends readonly Projection<unknown>[], T>(dependencies: D, compute: (...values: ProjectionValues<D>) => Synchronous<T>, equality?: (previous: T, next: T) => boolean): Projection<T>;
|
|
96
97
|
//#endregion
|
|
97
|
-
export { derive as a, BatchOptions as c,
|
|
98
|
-
//# sourceMappingURL=definition-
|
|
98
|
+
export { ProjectionError as _, derive as a, BatchOptions as c, ExternalCollectionEvent as d, ExternalCollectionRead as f, ProjectionDisposedError as g, ExternalValueSource as h, PublicCollection as i, CollectionDraft as l, ExternalValueEvent as m, Projection as n, input as o, ExternalCollectionSource as p, ProjectionValues as r, observe as s, Input as t, CollectionRead as u };
|
|
99
|
+
//# sourceMappingURL=definition-DN6yW2vi.d.cts.map
|
|
@@ -3,55 +3,53 @@ import { J as Infer, L as CollectionId, R as CollectionNode, Z as ObjectNode, _
|
|
|
3
3
|
//#region core/src/projection/contract.d.ts
|
|
4
4
|
/** Opaque application metadata identifying the action that produced a source event. */
|
|
5
5
|
type Cause = unknown;
|
|
6
|
-
type BatchContext = {
|
|
7
|
-
readonly id: number;
|
|
8
|
-
readonly cause?: Cause;
|
|
9
|
-
};
|
|
10
6
|
type BatchOptions = {
|
|
11
7
|
readonly cause?: Cause;
|
|
12
8
|
};
|
|
13
|
-
type CollectionEntryTransition<K extends string, V> = {
|
|
14
|
-
readonly key: K;
|
|
15
|
-
readonly kind: 'added' | 'updated' | 'removed';
|
|
16
|
-
readonly before: V | undefined;
|
|
17
|
-
readonly after: V | undefined;
|
|
18
|
-
};
|
|
19
|
-
type ValueContext<T, D = unknown> = {
|
|
20
|
-
readonly value: T;
|
|
21
|
-
readonly previous: T;
|
|
22
|
-
readonly changed: boolean;
|
|
23
|
-
readonly revision: number;
|
|
24
|
-
readonly reset: boolean;
|
|
25
|
-
readonly detail?: D;
|
|
26
|
-
readonly cause?: Cause;
|
|
27
|
-
readonly batch?: BatchContext;
|
|
28
|
-
};
|
|
29
9
|
type CollectionRead<K extends string, V> = {
|
|
30
10
|
get(key: K): V | undefined;
|
|
31
11
|
has(key: K): boolean;
|
|
32
12
|
ids(): readonly K[];
|
|
33
13
|
};
|
|
34
|
-
type
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
readonly reset: boolean;
|
|
39
|
-
readonly transitions: (keys?: Iterable<K>) => readonly CollectionEntryTransition<K, V>[];
|
|
40
|
-
readonly detail?: D;
|
|
41
|
-
readonly cause?: Cause;
|
|
42
|
-
readonly batch?: BatchContext;
|
|
14
|
+
type ExternalCollectionRead<K extends string, V> = {
|
|
15
|
+
readonly get: (key: K) => V | undefined;
|
|
16
|
+
readonly has: (key: K) => boolean;
|
|
17
|
+
readonly ids: () => readonly K[];
|
|
43
18
|
};
|
|
44
19
|
type ExternalValueSource<T, D = unknown> = {
|
|
45
20
|
readonly kind: 'value';
|
|
46
21
|
current(): T;
|
|
47
22
|
revision(): number;
|
|
48
|
-
subscribe(listener: (event:
|
|
23
|
+
subscribe(listener: (event: ExternalValueEvent<T, D>) => void): Unsubscribe;
|
|
49
24
|
};
|
|
50
25
|
type ExternalCollectionSource<K extends string, V, D = unknown> = {
|
|
51
26
|
readonly kind: 'collection';
|
|
52
|
-
current():
|
|
27
|
+
current(): ExternalCollectionRead<K, V>;
|
|
53
28
|
revision(): number;
|
|
54
|
-
subscribe(listener: (event:
|
|
29
|
+
subscribe(listener: (event: ExternalCollectionEvent<K, V, D>) => void): Unsubscribe;
|
|
30
|
+
};
|
|
31
|
+
type ExternalValueEvent<T, D = unknown> = {
|
|
32
|
+
readonly value: T;
|
|
33
|
+
readonly revision: number;
|
|
34
|
+
readonly reset?: boolean;
|
|
35
|
+
readonly detail?: D;
|
|
36
|
+
readonly cause?: Cause;
|
|
37
|
+
readonly batch?: {
|
|
38
|
+
readonly id: number;
|
|
39
|
+
readonly cause?: Cause;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type ExternalCollectionEvent<K extends string, V, D = unknown> = {
|
|
43
|
+
readonly previous: ExternalCollectionRead<K, V>;
|
|
44
|
+
readonly revision: number;
|
|
45
|
+
readonly reset?: boolean;
|
|
46
|
+
readonly change?: CollectionImpact<K>;
|
|
47
|
+
readonly detail?: D;
|
|
48
|
+
readonly cause?: Cause;
|
|
49
|
+
readonly batch?: {
|
|
50
|
+
readonly id: number;
|
|
51
|
+
readonly cause?: Cause;
|
|
52
|
+
};
|
|
55
53
|
};
|
|
56
54
|
type CollectionDraft<K extends string, V> = {
|
|
57
55
|
set(key: K, value: V): void;
|
|
@@ -85,14 +83,17 @@ type PublicCollection<K extends string, V> = ReadonlyMap<K, V>;
|
|
|
85
83
|
type ObservedCollection<P extends CollectionPath> = PublicCollection<CollectionId<P>, ReadonlyValue<Infer<CollectionNode<P>>>>;
|
|
86
84
|
declare const input: <T>(initial: T, equality?: (previous: T, next: T) => boolean) => Input<T>;
|
|
87
85
|
/**
|
|
88
|
-
* Establishes a reactive boundary from a document
|
|
89
|
-
* when the definition is materialized, so
|
|
86
|
+
* Establishes a reactive boundary from a document, readable, or external
|
|
87
|
+
* source. The selector is compiled when the definition is materialized, so
|
|
88
|
+
* declarations stay lazy and reusable.
|
|
90
89
|
*/
|
|
91
90
|
declare function observe<S extends ObjectNode>(document: DocumentReadable<S>): Projection<Infer<S>>;
|
|
91
|
+
declare function observe<T, D>(source: ExternalValueSource<T, D>): Projection<T>;
|
|
92
|
+
declare function observe<K extends string, V, D>(source: ExternalCollectionSource<K, V, D>): Projection<PublicCollection<K, V>>;
|
|
92
93
|
declare function observe<T>(readable: Readable<T>): Projection<T>;
|
|
93
94
|
declare function observe<S extends ObjectNode, P extends CollectionPath>(document: DocumentReadable<S>, selector: (path: SchemaPath<S['shape']>) => P): Projection<ObservedCollection<P>>;
|
|
94
95
|
declare function observe<S extends ObjectNode, P>(document: DocumentReadable<S>, selector: (path: SchemaPath<S['shape']>) => P): Projection<PathValueOf<P>>;
|
|
95
96
|
declare function derive<const D extends readonly Projection<unknown>[], T>(dependencies: D, compute: (...values: ProjectionValues<D>) => Synchronous<T>, equality?: (previous: T, next: T) => boolean): Projection<T>;
|
|
96
97
|
//#endregion
|
|
97
|
-
export { derive as a, BatchOptions as c,
|
|
98
|
-
//# sourceMappingURL=definition-
|
|
98
|
+
export { ProjectionError as _, derive as a, BatchOptions as c, ExternalCollectionEvent as d, ExternalCollectionRead as f, ProjectionDisposedError as g, ExternalValueSource as h, PublicCollection as i, CollectionDraft as l, ExternalValueEvent as m, Projection as n, input as o, ExternalCollectionSource as p, ProjectionValues as r, observe as s, Input as t, CollectionRead as u };
|
|
99
|
+
//# sourceMappingURL=definition-Dr8tHwTD.d.ts.map
|
|
@@ -735,6 +735,7 @@ const input = (initial, equality = Object.is) => define({
|
|
|
735
735
|
isEqual: equality
|
|
736
736
|
});
|
|
737
737
|
function observe(document, selector) {
|
|
738
|
+
if (isExternalSource(document)) return document.kind === "collection" ? defineExternalCollection(document) : defineExternalValue(document);
|
|
738
739
|
if ("current" in document && typeof document.current === "function") return defineReadable(document);
|
|
739
740
|
return define({
|
|
740
741
|
kind: "document",
|
|
@@ -742,6 +743,11 @@ function observe(document, selector) {
|
|
|
742
743
|
selector
|
|
743
744
|
});
|
|
744
745
|
}
|
|
746
|
+
const isExternalSource = (source) => {
|
|
747
|
+
if (!source || typeof source !== "object") return false;
|
|
748
|
+
const candidate = source;
|
|
749
|
+
return (candidate.kind === "value" || candidate.kind === "collection") && typeof candidate.current === "function" && typeof candidate.revision === "function" && typeof candidate.subscribe === "function";
|
|
750
|
+
};
|
|
745
751
|
function derive(dependencies, compute, equality = Object.is) {
|
|
746
752
|
if (!Array.isArray(dependencies) || dependencies.some((value) => !definitions.has(value))) throw new TypeError("derive dependencies must be projections.");
|
|
747
753
|
return define({
|
|
@@ -751,7 +757,7 @@ function derive(dependencies, compute, equality = Object.is) {
|
|
|
751
757
|
isEqual: equality
|
|
752
758
|
});
|
|
753
759
|
}
|
|
754
|
-
/** Internal adapters used by
|
|
760
|
+
/** Internal source adapters used by observe, not exported publicly. */
|
|
755
761
|
const defineReadable = (readable, equality = Object.is) => define({
|
|
756
762
|
kind: "readable",
|
|
757
763
|
readable,
|
|
@@ -780,6 +786,6 @@ const defineIncrementalCollection = (definition) => define({
|
|
|
780
786
|
name: definition.name
|
|
781
787
|
});
|
|
782
788
|
//#endregion
|
|
783
|
-
export {
|
|
789
|
+
export { input as a, createAccess as c, ParseError as d, checkKey as f, parse as g, equalValue as h, derive as i, replace as l, copyValue as m, defineIncrementalValue as n, observe as o, checkValue as p, definitionOf as r, collectionAccess as s, defineIncrementalCollection as t, snapshot as u };
|
|
784
790
|
|
|
785
|
-
//# sourceMappingURL=definition-
|
|
791
|
+
//# sourceMappingURL=definition-wOvuklwp.js.map
|