doxum 0.1.16 → 0.1.18

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 (37) hide show
  1. package/README.md +31 -4
  2. package/dist/advanced-DgRnyRAc.js +233 -0
  3. package/dist/advanced-DgRnyRAc.js.map +1 -0
  4. package/dist/advanced-Dgu8-bPS.cjs +274 -0
  5. package/dist/advanced-Dgu8-bPS.cjs.map +1 -0
  6. package/dist/advanced-GTwIWcn6.d.cts +138 -0
  7. package/dist/advanced-c0F3gpLG.d.ts +138 -0
  8. package/dist/advanced.cjs +2 -165
  9. package/dist/advanced.d.cts +2 -42
  10. package/dist/advanced.d.ts +2 -42
  11. package/dist/advanced.js +1 -164
  12. package/dist/index.cjs +1195 -874
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +26 -4
  15. package/dist/index.d.ts +26 -4
  16. package/dist/index.js +1192 -871
  17. package/dist/index.js.map +1 -1
  18. package/dist/react.cjs +5 -10
  19. package/dist/react.cjs.map +1 -1
  20. package/dist/react.d.cts +6 -8
  21. package/dist/react.d.ts +6 -8
  22. package/dist/react.js +6 -10
  23. package/dist/react.js.map +1 -1
  24. package/package.json +3 -2
  25. package/skills/doxum-runtime/SKILL.md +2 -1
  26. package/skills/doxum-runtime/references/patterns.en.md +4 -4
  27. package/skills/doxum-runtime/references/patterns.zh-CN.md +2 -2
  28. package/skills/doxum-runtime/references/projections.en.md +19 -4
  29. package/skills/doxum-runtime/references/projections.zh-CN.md +15 -4
  30. package/dist/advanced.cjs.map +0 -1
  31. package/dist/advanced.js.map +0 -1
  32. package/dist/definition-C__VJqA4.d.cts +0 -136
  33. package/dist/definition-Dc1Udkop.d.ts +0 -136
  34. package/dist/definition-Z6TagMup.cjs +0 -107
  35. package/dist/definition-Z6TagMup.cjs.map +0 -1
  36. package/dist/definition-c6XQXzvK.js +0 -72
  37. package/dist/definition-c6XQXzvK.js.map +0 -1
package/dist/advanced.js CHANGED
@@ -1,165 +1,2 @@
1
- import { i as snapshot } from "./scope-d-L87NeC.js";
2
- import { n as defineIncrementalValue, t as defineIncrementalCollection } from "./definition-c6XQXzvK.js";
3
- //#region core/src/projection/advanced.ts
4
- const dependenciesOf = (dependencies) => Object.fromEntries(dependencies.map((dependency, index) => [`d${index}`, dependency]));
5
- const resetCollectionChange = Object.freeze({ kind: "reset" });
6
- const isCollectionSource = (source) => Boolean(source && typeof source === "object" && "ids" in source && typeof source.ids === "function" && "previous" in source && "transitions" in source && typeof source.transitions === "function");
7
- const collectionChange = (source) => {
8
- if (!isCollectionSource(source)) return void 0;
9
- if (source.reset || source.change?.kind === "reset") return resetCollectionChange;
10
- const impact = source.change;
11
- if (!impact) return void 0;
12
- const added = [];
13
- const updated = [];
14
- const removed = [];
15
- for (const transition of source.transitions()) if (transition.kind === "added") added.push({
16
- key: transition.key,
17
- kind: transition.kind,
18
- after: transition.after
19
- });
20
- else if (transition.kind === "updated") updated.push(transition);
21
- else removed.push({
22
- key: transition.key,
23
- kind: transition.kind,
24
- before: transition.before
25
- });
26
- const order = impact.orderChanged ? {
27
- before: Object.freeze([...source.previous.ids()]),
28
- after: Object.freeze([...source.ids()])
29
- } : void 0;
30
- if (!added.length && !updated.length && !removed.length && !order) return void 0;
31
- return Object.freeze({
32
- kind: "incremental",
33
- added: Object.freeze(added),
34
- updated: Object.freeze(updated),
35
- removed: Object.freeze(removed),
36
- ...order ? { order: Object.freeze(order) } : {}
37
- });
38
- };
39
- const sourceCause = (sources) => {
40
- for (const source of Object.values(sources)) if (source && typeof source === "object" && "cause" in source && source.cause !== void 0) return source.cause;
41
- };
42
- const publicSource = (source) => {
43
- if (!source || typeof source !== "object") return source;
44
- if ("value" in source) return source.value;
45
- if ("read" in source) {
46
- const read = source.read;
47
- if (read && typeof read === "object" && "ids" in read && typeof read.ids === "function") {
48
- const result = /* @__PURE__ */ new Map();
49
- for (const id of read.ids()) result.set(id, read.get(id));
50
- return result;
51
- }
52
- return snapshot(read);
53
- }
54
- if ("ids" in source && typeof source.ids === "function") {
55
- const result = /* @__PURE__ */ new Map();
56
- const read = source;
57
- for (const id of read.ids()) result.set(id, read.get(id));
58
- return result;
59
- }
60
- return source;
61
- };
62
- const publicInputs = (sources, initial = false) => {
63
- const values = [];
64
- const changes = [];
65
- for (const key of Object.keys(sources).sort((left, right) => Number(left.slice(1)) - Number(right.slice(1)))) {
66
- const source = sources[key];
67
- values.push(publicSource(source));
68
- changes.push(initial && isCollectionSource(source) ? resetCollectionChange : collectionChange(source));
69
- }
70
- return {
71
- values,
72
- changes
73
- };
74
- };
75
- const normalizeValue = (result) => result && typeof result === "object" && result.kind === "value" ? {
76
- value: result.value,
77
- state: result.state
78
- } : { value: result };
79
- function createIncrementalValue(dependencies, processor) {
80
- const dependencyMap = dependenciesOf(dependencies);
81
- let state = Object.create(null);
82
- let current;
83
- const build = (sources) => {
84
- state = Object.create(null);
85
- const publicInputsForBuild = publicInputs(sources, true);
86
- const result = processor({
87
- sources: publicInputsForBuild.values,
88
- changes: publicInputsForBuild.changes,
89
- previous: void 0,
90
- reset: true,
91
- cause: sourceCause(sources),
92
- state
93
- });
94
- if (result && typeof result === "object" && "kind" in result) throw new TypeError("Initial incremental processor cannot rebuild.");
95
- const normalized = normalizeValue(result);
96
- current = normalized.value;
97
- if (normalized.state) state = normalized.state;
98
- return {
99
- value: current,
100
- update: (nextSources) => {
101
- const publicInputsForUpdate = publicInputs(nextSources);
102
- const next = processor({
103
- sources: publicInputsForUpdate.values,
104
- changes: publicInputsForUpdate.changes,
105
- previous: current,
106
- reset: false,
107
- cause: sourceCause(nextSources),
108
- state
109
- });
110
- if (next && typeof next === "object" && "kind" in next) return next;
111
- const nextValue = normalizeValue(next);
112
- current = nextValue.value;
113
- if (nextValue.state) state = nextValue.state;
114
- return {
115
- kind: "changed",
116
- value: current
117
- };
118
- }
119
- };
120
- };
121
- return defineIncrementalValue({
122
- dependencies: dependencyMap,
123
- build
124
- });
125
- }
126
- function createIncrementalCollection(dependencies, processor) {
127
- const dependencyMap = dependenciesOf(dependencies);
128
- let state = Object.create(null);
129
- const build = (input) => {
130
- state = Object.create(null);
131
- const publicInputsForBuild = publicInputs(input.sources, true);
132
- if (processor({
133
- sources: publicInputsForBuild.values,
134
- changes: publicInputsForBuild.changes,
135
- previous: input.previous,
136
- next: input.next,
137
- reset: true,
138
- cause: sourceCause(input.sources),
139
- state,
140
- output: input.writer
141
- })?.kind === "rebuild") throw new TypeError("Initial incremental collection processor cannot rebuild.");
142
- return { update: (nextInput) => {
143
- const publicInputsForUpdate = publicInputs(nextInput.sources);
144
- return processor({
145
- sources: publicInputsForUpdate.values,
146
- changes: publicInputsForUpdate.changes,
147
- previous: nextInput.previous,
148
- next: nextInput.next,
149
- reset: false,
150
- cause: sourceCause(nextInput.sources),
151
- state,
152
- output: nextInput.writer
153
- });
154
- } };
155
- };
156
- return defineIncrementalCollection({
157
- dependencies: dependencyMap,
158
- build
159
- });
160
- }
161
- const incremental = Object.assign(createIncrementalValue, { collection: createIncrementalCollection });
162
- //#endregion
1
+ import { t as incremental } from "./advanced-DgRnyRAc.js";
163
2
  export { incremental };
164
-
165
- //# sourceMappingURL=advanced.js.map