doxum 0.1.7 → 0.1.9

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 (70) hide show
  1. package/README.md +217 -296
  2. package/dist/contract-BNStLbSE.d.ts +441 -0
  3. package/dist/contract-CIU5FCC1.d.cts +441 -0
  4. package/dist/driver-BlR81Dqg.js +200 -0
  5. package/dist/driver-BlR81Dqg.js.map +1 -0
  6. package/dist/driver-xOIkwrB8.cjs +241 -0
  7. package/dist/driver-xOIkwrB8.cjs.map +1 -0
  8. package/dist/index.cjs +666 -2222
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +10 -20
  11. package/dist/index.d.ts +10 -18
  12. package/dist/index.js +634 -2189
  13. package/dist/index.js.map +1 -1
  14. package/dist/{integration-CZwCwFBS.cjs → integration-C87tjRop.cjs} +4 -9
  15. package/dist/integration-C87tjRop.cjs.map +1 -0
  16. package/dist/{integration-B56u1l9V.js → integration-D5XCBLJ8.js} +2 -7
  17. package/dist/integration-D5XCBLJ8.js.map +1 -0
  18. package/dist/integration.cjs +11 -11
  19. package/dist/integration.d.cts +10 -4
  20. package/dist/integration.d.ts +10 -4
  21. package/dist/integration.js +4 -3
  22. package/dist/issue-DVaGQGeP.js +576 -0
  23. package/dist/issue-DVaGQGeP.js.map +1 -0
  24. package/dist/issue-DhrNdQNg.cjs +797 -0
  25. package/dist/issue-DhrNdQNg.cjs.map +1 -0
  26. package/dist/local-sync.cjs +67 -39
  27. package/dist/local-sync.cjs.map +1 -1
  28. package/dist/local-sync.d.cts +10 -10
  29. package/dist/local-sync.d.ts +10 -10
  30. package/dist/local-sync.js +66 -38
  31. package/dist/local-sync.js.map +1 -1
  32. package/dist/react.cjs +23 -4
  33. package/dist/react.cjs.map +1 -1
  34. package/dist/react.d.cts +8 -3
  35. package/dist/react.d.ts +8 -3
  36. package/dist/react.js +21 -6
  37. package/dist/react.js.map +1 -1
  38. package/dist/store-1Uob0Ghk.cjs +2750 -0
  39. package/dist/store-1Uob0Ghk.cjs.map +1 -0
  40. package/dist/store-CD0KdGsq.d.cts +262 -0
  41. package/dist/store-D7QH6Rzw.js +2511 -0
  42. package/dist/store-D7QH6Rzw.js.map +1 -0
  43. package/dist/store-cp5CpfCy.d.ts +262 -0
  44. package/package.json +1 -1
  45. package/skills/doxum-runtime/SKILL.md +26 -44
  46. package/skills/doxum-runtime/references/guide.en.md +95 -359
  47. package/skills/doxum-runtime/references/guide.zh-CN.md +80 -285
  48. package/skills/doxum-runtime/references/invariants.en.md +42 -165
  49. package/skills/doxum-runtime/references/invariants.zh-CN.md +34 -97
  50. package/skills/doxum-runtime/references/patterns.en.md +73 -225
  51. package/skills/doxum-runtime/references/patterns.zh-CN.md +73 -179
  52. package/dist/chunk-pbuEa-1d.js +0 -13
  53. package/dist/contract-DNZ4D53r.d.ts +0 -563
  54. package/dist/contract-j3SLGAwh.d.cts +0 -563
  55. package/dist/driver-CNxqMVFH.cjs +0 -69
  56. package/dist/driver-CNxqMVFH.cjs.map +0 -1
  57. package/dist/driver-CbzfW5MR.js +0 -46
  58. package/dist/driver-CbzfW5MR.js.map +0 -1
  59. package/dist/integration-B56u1l9V.js.map +0 -1
  60. package/dist/integration-CZwCwFBS.cjs.map +0 -1
  61. package/dist/ownership-CY0nPXGF.cjs +0 -304
  62. package/dist/ownership-CY0nPXGF.cjs.map +0 -1
  63. package/dist/ownership-CduRygE7.js +0 -245
  64. package/dist/ownership-CduRygE7.js.map +0 -1
  65. package/dist/runtime-0mOFbe_H.cjs +0 -2439
  66. package/dist/runtime-0mOFbe_H.cjs.map +0 -1
  67. package/dist/runtime-B22tuj9A.d.cts +0 -150
  68. package/dist/runtime-BFmhzPpZ.d.ts +0 -150
  69. package/dist/runtime-DF1q9Gje.js +0 -2129
  70. package/dist/runtime-DF1q9Gje.js.map +0 -1
@@ -1,46 +0,0 @@
1
- //#region core/src/runtime/driver.ts
2
- const states = /* @__PURE__ */ new WeakMap();
3
- const stateOf = (runtime) => {
4
- const state = states.get(runtime);
5
- if (!state) throw new Error("Unknown Doxum runtime.");
6
- return state;
7
- };
8
- const bindRuntimeDriver = (runtime) => {
9
- states.set(runtime, {
10
- driver: void 0,
11
- bypassDepth: 0
12
- });
13
- };
14
- const assertRuntimeWritable = (runtime, intent) => {
15
- const state = stateOf(runtime);
16
- if (state.bypassDepth === 0) state.driver?.assertWritable(intent);
17
- };
18
- const installRuntimeWriteDriver = (runtime, driver) => {
19
- const state = stateOf(runtime);
20
- if (state.driver) throw new Error("Doxum runtime already has a write driver.");
21
- state.driver = driver;
22
- let active = true;
23
- return Object.freeze({
24
- run: (run) => {
25
- if (!active) throw new Error("Doxum runtime write driver is no longer active.");
26
- state.bypassDepth += 1;
27
- try {
28
- return run();
29
- } finally {
30
- state.bypassDepth -= 1;
31
- }
32
- },
33
- dispose: () => {
34
- if (!active) return;
35
- active = false;
36
- if (state.driver === driver) state.driver = void 0;
37
- }
38
- });
39
- };
40
- const disposeRuntimeDriver = (runtime) => {
41
- states.delete(runtime);
42
- };
43
- //#endregion
44
- export { installRuntimeWriteDriver as i, bindRuntimeDriver as n, disposeRuntimeDriver as r, assertRuntimeWritable as t };
45
-
46
- //# sourceMappingURL=driver-CbzfW5MR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"driver-CbzfW5MR.js","names":[],"sources":["../core/src/runtime/driver.ts"],"sourcesContent":["import type { CommitSource, DocumentRuntime } from './contract';\nimport type { DocumentSchema } from '../schema';\n\nexport type RuntimeWriteIntent =\n | { readonly kind: 'update'; readonly source: Extract<CommitSource, 'local' | 'system'> }\n | { readonly kind: 'prepare' }\n | { readonly kind: 'apply'; readonly source: CommitSource }\n | { readonly kind: 'replace'; readonly source: Extract<CommitSource, 'system' | 'remote'> };\n\nexport type RuntimeWriteDriver = {\n readonly assertWritable: (intent: RuntimeWriteIntent) => void;\n};\n\nexport type RuntimeWriteDriverLease = {\n readonly run: <TResult>(run: () => TResult) => TResult;\n readonly dispose: () => void;\n};\n\ntype RuntimeDriverState = {\n driver: RuntimeWriteDriver | undefined;\n bypassDepth: number;\n};\n\nconst states = new WeakMap<object, RuntimeDriverState>();\n\nconst stateOf = (runtime: object): RuntimeDriverState => {\n const state = states.get(runtime);\n if (!state) throw new Error('Unknown Doxum runtime.');\n return state;\n};\n\nexport const bindRuntimeDriver = (runtime: object): void => {\n states.set(runtime, { driver: undefined, bypassDepth: 0 });\n};\n\nexport const assertRuntimeWritable = (runtime: object, intent: RuntimeWriteIntent): void => {\n const state = stateOf(runtime);\n if (state.bypassDepth === 0) state.driver?.assertWritable(intent);\n};\n\nexport const installRuntimeWriteDriver = <TSchema extends DocumentSchema>(\n runtime: DocumentRuntime<TSchema>,\n driver: RuntimeWriteDriver\n): RuntimeWriteDriverLease => {\n const state = stateOf(runtime);\n if (state.driver) throw new Error('Doxum runtime already has a write driver.');\n state.driver = driver;\n let active = true;\n return Object.freeze({\n run: <TResult>(run: () => TResult): TResult => {\n if (!active) throw new Error('Doxum runtime write driver is no longer active.');\n state.bypassDepth += 1;\n try {\n return run();\n } finally {\n state.bypassDepth -= 1;\n }\n },\n dispose: (): void => {\n if (!active) return;\n active = false;\n if (state.driver === driver) state.driver = undefined;\n },\n });\n};\n\nexport const disposeRuntimeDriver = (runtime: object): void => {\n states.delete(runtime);\n};\n"],"mappings":";AAuBA,MAAM,yBAAS,IAAI,SAAqC;AAExD,MAAM,WAAW,YAAwC;CACvD,MAAM,QAAQ,OAAO,IAAI,QAAQ;AACjC,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,yBAAyB;AACrD,QAAO;;AAGT,MAAa,qBAAqB,YAA0B;AAC1D,QAAO,IAAI,SAAS;EAAE,QAAQ,KAAA;EAAW,aAAa;EAAG,CAAC;;AAG5D,MAAa,yBAAyB,SAAiB,WAAqC;CAC1F,MAAM,QAAQ,QAAQ,QAAQ;AAC9B,KAAI,MAAM,gBAAgB,EAAG,OAAM,QAAQ,eAAe,OAAO;;AAGnE,MAAa,6BACX,SACA,WAC4B;CAC5B,MAAM,QAAQ,QAAQ,QAAQ;AAC9B,KAAI,MAAM,OAAQ,OAAM,IAAI,MAAM,4CAA4C;AAC9E,OAAM,SAAS;CACf,IAAI,SAAS;AACb,QAAO,OAAO,OAAO;EACnB,MAAe,QAAgC;AAC7C,OAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,kDAAkD;AAC/E,SAAM,eAAe;AACrB,OAAI;AACF,WAAO,KAAK;aACJ;AACR,UAAM,eAAe;;;EAGzB,eAAqB;AACnB,OAAI,CAAC,OAAQ;AACb,YAAS;AACT,OAAI,MAAM,WAAW,OAAQ,OAAM,SAAS,KAAA;;EAE/C,CAAC;;AAGJ,MAAa,wBAAwB,YAA0B;AAC7D,QAAO,OAAO,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"integration-B56u1l9V.js","names":["impactTarget.same"],"sources":["../core/src/access/dependency.ts","../core/src/integration.ts"],"sourcesContent":["import type { ImpactTarget } from '../schema';\nimport * as impactTarget from '../impact-target';\n\nexport type DependencyTracker = {\n readonly record: (target: ImpactTarget<unknown>) => void;\n readonly clear: () => void;\n readonly size: () => number;\n readonly some: (test: (target: ImpactTarget<unknown>) => boolean) => boolean;\n readonly snapshot: () => readonly ImpactTarget<unknown>[];\n};\n\nexport const createDependencyTracker = (): DependencyTracker => {\n const targets: ImpactTarget<unknown>[] = [];\n return {\n record: value => {\n if (!targets.some(entry => impactTarget.same(entry, value))) targets.push(value);\n },\n clear: () => {\n targets.length = 0;\n },\n size: () => targets.length,\n some: test => targets.some(test),\n snapshot: () => Object.freeze(targets.slice()),\n };\n};\n","import type { DocumentSchema, ImpactTarget } from './schema';\nimport type { DocumentReader } from './access/reader';\nimport type { DocumentReadable } from './runtime/contract';\nimport { createDependencyTracker } from './access/dependency';\nimport { readWith } from './runtime/access';\nexport { projectionDebug } from './projection/runtime';\nexport type { AddressRef } from './address';\nexport { contains, debugKey, overlaps, read as readAddress, resolveAddress } from './address';\nexport { commandFootprint, decodeCommandFootprint, footprintsOverlap } from './mutation/footprint';\nexport type { CommandFootprint, CommandFootprintTarget } from './mutation/footprint';\n\nexport type TrackedSelection<TValue> = {\n readonly value: TValue;\n readonly targets: readonly ImpactTarget<unknown>[];\n};\n\n// Framework adapters receive one immutable result instead of coordinating a\n// mutable collector with the reader's scoped lifetime themselves.\nexport const track = <TSchema extends DocumentSchema, TValue>(\n runtime: DocumentReadable<TSchema>,\n selector: (read: DocumentReader<TSchema>) => TValue\n): TrackedSelection<TValue> => {\n const dependencies = createDependencyTracker();\n const value = readWith(runtime, selector, dependencies);\n return Object.freeze({ value, targets: dependencies.snapshot() });\n};\n"],"mappings":";;AAWA,MAAa,gCAAmD;CAC9D,MAAM,UAAmC,EAAE;AAC3C,QAAO;EACL,SAAQ,UAAS;AACf,OAAI,CAAC,QAAQ,MAAK,UAASA,KAAkB,OAAO,MAAM,CAAC,CAAE,SAAQ,KAAK,MAAM;;EAElF,aAAa;AACX,WAAQ,SAAS;;EAEnB,YAAY,QAAQ;EACpB,OAAM,SAAQ,QAAQ,KAAK,KAAK;EAChC,gBAAgB,OAAO,OAAO,QAAQ,OAAO,CAAC;EAC/C;;;;ACLH,MAAa,SACX,SACA,aAC6B;CAC7B,MAAM,eAAe,yBAAyB;CAC9C,MAAM,QAAQ,SAAS,SAAS,UAAU,aAAa;AACvD,QAAO,OAAO,OAAO;EAAE;EAAO,SAAS,aAAa,UAAU;EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"integration-CZwCwFBS.cjs","names":["readWith"],"sources":["../core/src/access/dependency.ts","../core/src/integration.ts"],"sourcesContent":["import type { ImpactTarget } from '../schema';\nimport * as impactTarget from '../impact-target';\n\nexport type DependencyTracker = {\n readonly record: (target: ImpactTarget<unknown>) => void;\n readonly clear: () => void;\n readonly size: () => number;\n readonly some: (test: (target: ImpactTarget<unknown>) => boolean) => boolean;\n readonly snapshot: () => readonly ImpactTarget<unknown>[];\n};\n\nexport const createDependencyTracker = (): DependencyTracker => {\n const targets: ImpactTarget<unknown>[] = [];\n return {\n record: value => {\n if (!targets.some(entry => impactTarget.same(entry, value))) targets.push(value);\n },\n clear: () => {\n targets.length = 0;\n },\n size: () => targets.length,\n some: test => targets.some(test),\n snapshot: () => Object.freeze(targets.slice()),\n };\n};\n","import type { DocumentSchema, ImpactTarget } from './schema';\nimport type { DocumentReader } from './access/reader';\nimport type { DocumentReadable } from './runtime/contract';\nimport { createDependencyTracker } from './access/dependency';\nimport { readWith } from './runtime/access';\nexport { projectionDebug } from './projection/runtime';\nexport type { AddressRef } from './address';\nexport { contains, debugKey, overlaps, read as readAddress, resolveAddress } from './address';\nexport { commandFootprint, decodeCommandFootprint, footprintsOverlap } from './mutation/footprint';\nexport type { CommandFootprint, CommandFootprintTarget } from './mutation/footprint';\n\nexport type TrackedSelection<TValue> = {\n readonly value: TValue;\n readonly targets: readonly ImpactTarget<unknown>[];\n};\n\n// Framework adapters receive one immutable result instead of coordinating a\n// mutable collector with the reader's scoped lifetime themselves.\nexport const track = <TSchema extends DocumentSchema, TValue>(\n runtime: DocumentReadable<TSchema>,\n selector: (read: DocumentReader<TSchema>) => TValue\n): TrackedSelection<TValue> => {\n const dependencies = createDependencyTracker();\n const value = readWith(runtime, selector, dependencies);\n return Object.freeze({ value, targets: dependencies.snapshot() });\n};\n"],"mappings":";;AAWA,MAAa,gCAAmD;CAC9D,MAAM,UAAmC,EAAE;AAC3C,QAAO;EACL,SAAQ,UAAS;AACf,OAAI,CAAC,QAAQ,MAAK,UAAA,gBAAA,KAA2B,OAAO,MAAM,CAAC,CAAE,SAAQ,KAAK,MAAM;;EAElF,aAAa;AACX,WAAQ,SAAS;;EAEnB,YAAY,QAAQ;EACpB,OAAM,SAAQ,QAAQ,KAAK,KAAK;EAChC,gBAAgB,OAAO,OAAO,QAAQ,OAAO,CAAC;EAC/C;;;;ACLH,MAAa,SACX,SACA,aAC6B;CAC7B,MAAM,eAAe,yBAAyB;CAC9C,MAAM,QAAQA,gBAAAA,SAAS,SAAS,UAAU,aAAa;AACvD,QAAO,OAAO,OAAO;EAAE;EAAO,SAAS,aAAa,UAAU;EAAE,CAAC"}
@@ -1,304 +0,0 @@
1
- //#region core/src/profile.ts
2
- const active = { current: void 0 };
3
- const profile = {
4
- projection: (counter, amount = 1) => {
5
- if (active.current) active.current.projection[counter] += amount;
6
- },
7
- clone: {
8
- call: () => {
9
- const value = active.current;
10
- if (value) value.clone.calls += 1;
11
- },
12
- node: (reason) => {
13
- const value = active.current;
14
- if (!value) return;
15
- value.clone.nodes[reason] += 1;
16
- },
17
- container: () => {
18
- const value = active.current;
19
- if (value) value.clone.containers += 1;
20
- },
21
- deepEqual: () => {
22
- const value = active.current;
23
- if (value) value.clone.deepEqual.calls += 1;
24
- },
25
- deepEqualContainer: () => {
26
- const value = active.current;
27
- if (value) value.clone.deepEqual.containers += 1;
28
- },
29
- initialDocument: () => {
30
- const value = active.current;
31
- if (value) value.clone.documents.initial += 1;
32
- }
33
- },
34
- mutation: {
35
- normalized: () => {
36
- const value = active.current;
37
- if (value) value.mutation.normalized += 1;
38
- },
39
- executed: () => {
40
- const value = active.current;
41
- if (value) value.mutation.executed += 1;
42
- },
43
- inverse: () => {
44
- const value = active.current;
45
- if (value) value.mutation.inverseCreated += 1;
46
- }
47
- },
48
- batch: {
49
- operation: () => {
50
- const value = active.current;
51
- if (value) value.batch.operations += 1;
52
- },
53
- entry: (amount = 1) => {
54
- const value = active.current;
55
- if (value) value.batch.entries += amount;
56
- },
57
- collectionResolved: () => {
58
- const value = active.current;
59
- if (value) value.batch.collectionsResolved += 1;
60
- },
61
- journalRecord: () => {
62
- const value = active.current;
63
- if (value) value.batch.journalRecords += 1;
64
- },
65
- rejected: () => {
66
- const value = active.current;
67
- if (value) value.batch.rejected += 1;
68
- },
69
- inverse: () => {
70
- const value = active.current;
71
- if (value) value.batch.inverseOperations += 1;
72
- },
73
- payloadTransferred: () => {
74
- const value = active.current;
75
- if (value) value.batch.payloadTransferred += 1;
76
- },
77
- payloadSnapshot: () => {
78
- const value = active.current;
79
- if (value) value.batch.payloadSnapshots += 1;
80
- }
81
- },
82
- journal: {
83
- subject: () => {
84
- const value = active.current;
85
- if (value) value.journal.subjects += 1;
86
- },
87
- comparison: () => {
88
- const value = active.current;
89
- if (value) value.journal.comparisons += 1;
90
- },
91
- absorbed: () => {
92
- const value = active.current;
93
- if (value) value.journal.absorbed += 1;
94
- },
95
- orderSnapshot: (items) => {
96
- const value = active.current;
97
- if (!value) return;
98
- value.journal.orderSnapshots += 1;
99
- value.journal.orderItems += items;
100
- }
101
- },
102
- address: {
103
- schemaStep: () => {
104
- const value = active.current;
105
- if (value) value.address.schemaSteps += 1;
106
- },
107
- documentStep: () => {
108
- const value = active.current;
109
- if (value) value.address.documentSteps += 1;
110
- },
111
- arrayCopied: () => {
112
- const value = active.current;
113
- if (value) value.address.arraysCopied += 1;
114
- },
115
- prefixComparison: () => {
116
- const value = active.current;
117
- if (value) value.address.prefixComparisons += 1;
118
- },
119
- segmentCompared: () => {
120
- const value = active.current;
121
- if (value) value.address.segmentsCompared += 1;
122
- }
123
- },
124
- impact: { affects: () => {
125
- const value = active.current;
126
- if (value) value.impact.affectsChecks += 1;
127
- } },
128
- reader: {
129
- session: () => {
130
- const value = active.current;
131
- if (value) value.reader.sessions += 1;
132
- },
133
- lookup: () => {
134
- const value = active.current;
135
- if (value) value.reader.nodeLookups += 1;
136
- },
137
- collectionIds: (amount = 1) => {
138
- const value = active.current;
139
- if (value) value.reader.collectionIds += amount;
140
- },
141
- structuralSnapshot: () => {
142
- const value = active.current;
143
- if (value) value.reader.structuralSnapshots += 1;
144
- }
145
- },
146
- collectionView: {
147
- mapped: () => {
148
- const value = active.current;
149
- if (value) value.collectionView.mappedItems += 1;
150
- },
151
- idsScanned: (amount = 1) => {
152
- const value = active.current;
153
- if (value) value.collectionView.idsScanned += amount;
154
- },
155
- arrayCopied: () => {
156
- const value = active.current;
157
- if (value) value.collectionView.arraysCopied += 1;
158
- }
159
- },
160
- materialized: {
161
- updated: () => {
162
- const value = active.current;
163
- if (value) value.materialized.updated += 1;
164
- },
165
- skipped: () => {
166
- const value = active.current;
167
- if (value) value.materialized.skipped += 1;
168
- },
169
- rebuilt: () => {
170
- const value = active.current;
171
- if (value) value.materialized.rebuilt += 1;
172
- },
173
- sourceChanged: () => {
174
- const value = active.current;
175
- if (value) value.materialized.sourceChanges += 1;
176
- },
177
- notification: () => {
178
- const value = active.current;
179
- if (value) value.materialized.notifications += 1;
180
- }
181
- }
182
- };
183
- //#endregion
184
- //#region core/src/value/ownership.ts
185
- const stablePayloads = /* @__PURE__ */ new WeakSet();
186
- const markStablePayload = (value) => {
187
- if (Array.isArray(value) || isPlainObject(value)) stablePayloads.add(value);
188
- return value;
189
- };
190
- const isStablePayload = (value) => (Array.isArray(value) || isPlainObject(value)) && stablePayloads.has(value);
191
- const isPlainObject = (value) => {
192
- if (value === null || typeof value !== "object") return false;
193
- const prototype = Object.getPrototypeOf(value);
194
- return prototype === Object.prototype || prototype === null;
195
- };
196
- const countCloneReason = (reason) => {
197
- if (reason) profile.clone.node(reason);
198
- };
199
- const cloneValue = (value, reason) => {
200
- profile.clone.call();
201
- countCloneReason(reason);
202
- if (Array.isArray(value)) {
203
- profile.clone.container();
204
- const result = new Array(value.length);
205
- for (let index = 0; index < value.length; index += 1) result[index] = cloneValue(value[index], reason);
206
- return reason === "commit" || reason === "inverse" || reason === "snapshot" ? markStablePayload(Object.freeze(result)) : result;
207
- }
208
- if (isPlainObject(value)) {
209
- profile.clone.container();
210
- const result = Object.create(Object.getPrototypeOf(value));
211
- for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) result[key] = cloneValue(value[key], reason);
212
- return reason === "commit" || reason === "inverse" || reason === "snapshot" ? markStablePayload(Object.freeze(result)) : result;
213
- }
214
- return value;
215
- };
216
- const ownPayload = (value, reason = "canonical") => Array.isArray(value) || isPlainObject(value) ? cloneValue(value, reason) : value;
217
- const transferPayload = (value) => {
218
- profile.batch.payloadTransferred();
219
- return value;
220
- };
221
- const snapshotPayload = (value, reason = "commit") => (profile.batch.payloadSnapshot(), ownPayload(value, reason));
222
- const deepEqual = (left, right) => {
223
- profile.clone.deepEqual();
224
- if (Object.is(left, right)) return true;
225
- if (Array.isArray(left) && Array.isArray(right)) {
226
- profile.clone.deepEqualContainer();
227
- if (left.length !== right.length) return false;
228
- for (let index = 0; index < left.length; index += 1) if (!deepEqual(left[index], right[index])) return false;
229
- return true;
230
- }
231
- if (isPlainObject(left) && isPlainObject(right)) {
232
- profile.clone.deepEqualContainer();
233
- const leftKeys = Object.keys(left);
234
- if (leftKeys.length !== Object.keys(right).length) return false;
235
- for (const key of leftKeys) if (!Object.prototype.hasOwnProperty.call(right, key) || !deepEqual(left[key], right[key])) return false;
236
- return true;
237
- }
238
- return false;
239
- };
240
- const sameStructuralValue = (left, right) => Object.is(left, right) || (Array.isArray(left) || isPlainObject(left)) && deepEqual(left, right);
241
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
242
- //#endregion
243
- Object.defineProperty(exports, "cloneValue", {
244
- enumerable: true,
245
- get: function() {
246
- return cloneValue;
247
- }
248
- });
249
- Object.defineProperty(exports, "deepEqual", {
250
- enumerable: true,
251
- get: function() {
252
- return deepEqual;
253
- }
254
- });
255
- Object.defineProperty(exports, "isPlainObject", {
256
- enumerable: true,
257
- get: function() {
258
- return isPlainObject;
259
- }
260
- });
261
- Object.defineProperty(exports, "isRecord", {
262
- enumerable: true,
263
- get: function() {
264
- return isRecord;
265
- }
266
- });
267
- Object.defineProperty(exports, "isStablePayload", {
268
- enumerable: true,
269
- get: function() {
270
- return isStablePayload;
271
- }
272
- });
273
- Object.defineProperty(exports, "ownPayload", {
274
- enumerable: true,
275
- get: function() {
276
- return ownPayload;
277
- }
278
- });
279
- Object.defineProperty(exports, "profile", {
280
- enumerable: true,
281
- get: function() {
282
- return profile;
283
- }
284
- });
285
- Object.defineProperty(exports, "sameStructuralValue", {
286
- enumerable: true,
287
- get: function() {
288
- return sameStructuralValue;
289
- }
290
- });
291
- Object.defineProperty(exports, "snapshotPayload", {
292
- enumerable: true,
293
- get: function() {
294
- return snapshotPayload;
295
- }
296
- });
297
- Object.defineProperty(exports, "transferPayload", {
298
- enumerable: true,
299
- get: function() {
300
- return transferPayload;
301
- }
302
- });
303
-
304
- //# sourceMappingURL=ownership-CY0nPXGF.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ownership-CY0nPXGF.cjs","names":[],"sources":["../core/src/profile.ts","../core/src/value/ownership.ts"],"sourcesContent":["export type CloneReason =\n 'initial' | 'canonical' | 'commit' | 'inverse' | 'reader' | 'replace' | 'journal' | 'snapshot';\n\ntype CloneCounters = {\n calls: number;\n containers: number;\n nodes: Record<CloneReason, number>;\n deepEqual: { calls: number; containers: number };\n documents: { initial: number };\n};\ntype ProfileCounters = {\n projection: {\n sourceEvents: number;\n scheduledNodes: number;\n processedNodes: number;\n touchedKeys: number;\n changedKeys: number;\n publishedNodes: number;\n flushes: number;\n };\n clone: CloneCounters;\n mutation: { normalized: number; executed: number; inverseCreated: number };\n batch: {\n operations: number;\n entries: number;\n collectionsResolved: number;\n journalRecords: number;\n rejected: number;\n inverseOperations: number;\n payloadTransferred: number;\n payloadSnapshots: number;\n };\n journal: {\n subjects: number;\n comparisons: number;\n absorbed: number;\n orderSnapshots: number;\n orderItems: number;\n };\n address: {\n schemaSteps: number;\n documentSteps: number;\n prefixComparisons: number;\n segmentsCompared: number;\n arraysCopied: number;\n };\n impact: { affectsChecks: number };\n reader: {\n sessions: number;\n nodeLookups: number;\n collectionIds: number;\n structuralSnapshots: number;\n };\n collectionView: {\n mappedItems: number;\n idsScanned: number;\n arraysCopied: number;\n };\n materialized: {\n updated: number;\n skipped: number;\n rebuilt: number;\n sourceChanges: number;\n notifications: number;\n };\n};\n\nexport type ProfileSnapshot = Readonly<{\n projection: Readonly<ProfileCounters['projection']>;\n clone: Readonly<{\n calls: number;\n containers: number;\n nodes: Readonly<Record<CloneReason, number>>;\n deepEqual: Readonly<{ calls: number; containers: number }>;\n documents: Readonly<{ initial: number }>;\n }>;\n mutation: Readonly<{\n normalized: number;\n executed: number;\n inverseCreated: number;\n }>;\n batch: Readonly<ProfileCounters['batch']>;\n journal: Readonly<ProfileCounters['journal']>;\n address: Readonly<ProfileCounters['address']>;\n impact: Readonly<ProfileCounters['impact']>;\n reader: Readonly<ProfileCounters['reader']>;\n collectionView: Readonly<ProfileCounters['collectionView']>;\n materialized: Readonly<ProfileCounters['materialized']>;\n}>;\n\nconst cloneReasons = (): Record<CloneReason, number> => ({\n initial: 0,\n canonical: 0,\n commit: 0,\n inverse: 0,\n reader: 0,\n replace: 0,\n journal: 0,\n snapshot: 0,\n});\n\nconst counters = (): ProfileCounters => ({\n projection: {\n sourceEvents: 0,\n scheduledNodes: 0,\n processedNodes: 0,\n touchedKeys: 0,\n changedKeys: 0,\n publishedNodes: 0,\n flushes: 0,\n },\n clone: {\n calls: 0,\n containers: 0,\n nodes: cloneReasons(),\n deepEqual: { calls: 0, containers: 0 },\n documents: { initial: 0 },\n },\n mutation: { normalized: 0, executed: 0, inverseCreated: 0 },\n batch: {\n operations: 0,\n entries: 0,\n collectionsResolved: 0,\n journalRecords: 0,\n rejected: 0,\n inverseOperations: 0,\n payloadTransferred: 0,\n payloadSnapshots: 0,\n },\n journal: {\n subjects: 0,\n comparisons: 0,\n absorbed: 0,\n orderSnapshots: 0,\n orderItems: 0,\n },\n address: {\n schemaSteps: 0,\n documentSteps: 0,\n prefixComparisons: 0,\n segmentsCompared: 0,\n arraysCopied: 0,\n },\n impact: { affectsChecks: 0 },\n reader: {\n sessions: 0,\n nodeLookups: 0,\n collectionIds: 0,\n structuralSnapshots: 0,\n },\n collectionView: { mappedItems: 0, idsScanned: 0, arraysCopied: 0 },\n materialized: {\n updated: 0,\n skipped: 0,\n rebuilt: 0,\n sourceChanges: 0,\n notifications: 0,\n },\n});\n\n// Recorder calls are stable no-op-capable functions. Only this module owns the\n// mutable session counter tree; domain code never branches on profile state.\nconst active = { current: undefined as ProfileCounters | undefined };\n\n// Snapshot allocation is intentionally delayed until the caller asks for it.\nconst freezeSnapshot = (value: ProfileCounters): ProfileSnapshot =>\n Object.freeze({\n projection: Object.freeze({ ...value.projection }),\n clone: Object.freeze({\n calls: value.clone.calls,\n containers: value.clone.containers,\n nodes: Object.freeze({ ...value.clone.nodes }),\n deepEqual: Object.freeze({ ...value.clone.deepEqual }),\n documents: Object.freeze({ ...value.clone.documents }),\n }),\n mutation: Object.freeze({ ...value.mutation }),\n batch: Object.freeze({ ...value.batch }),\n journal: Object.freeze({ ...value.journal }),\n address: Object.freeze({ ...value.address }),\n impact: Object.freeze({ ...value.impact }),\n reader: Object.freeze({ ...value.reader }),\n collectionView: Object.freeze({ ...value.collectionView }),\n materialized: Object.freeze({ ...value.materialized }),\n });\n\nexport const profile = {\n projection: (counter: keyof ProfileCounters['projection'], amount = 1): void => {\n if (active.current) active.current.projection[counter] += amount;\n },\n clone: {\n call: (): void => {\n const value = active.current;\n if (value) value.clone.calls += 1;\n },\n node: (reason: CloneReason): void => {\n const value = active.current;\n if (!value) return;\n value.clone.nodes[reason] += 1;\n },\n container: (): void => {\n const value = active.current;\n if (value) value.clone.containers += 1;\n },\n deepEqual: (): void => {\n const value = active.current;\n if (value) value.clone.deepEqual.calls += 1;\n },\n deepEqualContainer: (): void => {\n const value = active.current;\n if (value) value.clone.deepEqual.containers += 1;\n },\n initialDocument: (): void => {\n const value = active.current;\n if (value) value.clone.documents.initial += 1;\n },\n },\n mutation: {\n normalized: (): void => {\n const value = active.current;\n if (value) value.mutation.normalized += 1;\n },\n executed: (): void => {\n const value = active.current;\n if (value) value.mutation.executed += 1;\n },\n inverse: (): void => {\n const value = active.current;\n if (value) value.mutation.inverseCreated += 1;\n },\n },\n batch: {\n operation: (): void => {\n const value = active.current;\n if (value) value.batch.operations += 1;\n },\n entry: (amount = 1): void => {\n const value = active.current;\n if (value) value.batch.entries += amount;\n },\n collectionResolved: (): void => {\n const value = active.current;\n if (value) value.batch.collectionsResolved += 1;\n },\n journalRecord: (): void => {\n const value = active.current;\n if (value) value.batch.journalRecords += 1;\n },\n rejected: (): void => {\n const value = active.current;\n if (value) value.batch.rejected += 1;\n },\n inverse: (): void => {\n const value = active.current;\n if (value) value.batch.inverseOperations += 1;\n },\n payloadTransferred: (): void => {\n const value = active.current;\n if (value) value.batch.payloadTransferred += 1;\n },\n payloadSnapshot: (): void => {\n const value = active.current;\n if (value) value.batch.payloadSnapshots += 1;\n },\n },\n journal: {\n subject: (): void => {\n const value = active.current;\n if (value) value.journal.subjects += 1;\n },\n comparison: (): void => {\n const value = active.current;\n if (value) value.journal.comparisons += 1;\n },\n absorbed: (): void => {\n const value = active.current;\n if (value) value.journal.absorbed += 1;\n },\n orderSnapshot: (items: number): void => {\n const value = active.current;\n if (!value) return;\n value.journal.orderSnapshots += 1;\n value.journal.orderItems += items;\n },\n },\n address: {\n schemaStep: (): void => {\n const value = active.current;\n if (value) value.address.schemaSteps += 1;\n },\n documentStep: (): void => {\n const value = active.current;\n if (value) value.address.documentSteps += 1;\n },\n arrayCopied: (): void => {\n const value = active.current;\n if (value) value.address.arraysCopied += 1;\n },\n prefixComparison: (): void => {\n const value = active.current;\n if (value) value.address.prefixComparisons += 1;\n },\n segmentCompared: (): void => {\n const value = active.current;\n if (value) value.address.segmentsCompared += 1;\n },\n },\n impact: {\n affects: (): void => {\n const value = active.current;\n if (value) value.impact.affectsChecks += 1;\n },\n },\n reader: {\n session: (): void => {\n const value = active.current;\n if (value) value.reader.sessions += 1;\n },\n lookup: (): void => {\n const value = active.current;\n if (value) value.reader.nodeLookups += 1;\n },\n collectionIds: (amount = 1): void => {\n const value = active.current;\n if (value) value.reader.collectionIds += amount;\n },\n structuralSnapshot: (): void => {\n const value = active.current;\n if (value) value.reader.structuralSnapshots += 1;\n },\n },\n collectionView: {\n mapped: (): void => {\n const value = active.current;\n if (value) value.collectionView.mappedItems += 1;\n },\n idsScanned: (amount = 1): void => {\n const value = active.current;\n if (value) value.collectionView.idsScanned += amount;\n },\n arrayCopied: (): void => {\n const value = active.current;\n if (value) value.collectionView.arraysCopied += 1;\n },\n },\n materialized: {\n updated: (): void => {\n const value = active.current;\n if (value) value.materialized.updated += 1;\n },\n skipped: (): void => {\n const value = active.current;\n if (value) value.materialized.skipped += 1;\n },\n rebuilt: (): void => {\n const value = active.current;\n if (value) value.materialized.rebuilt += 1;\n },\n sourceChanged: (): void => {\n const value = active.current;\n if (value) value.materialized.sourceChanges += 1;\n },\n notification: (): void => {\n const value = active.current;\n if (value) value.materialized.notifications += 1;\n },\n },\n} as const;\n\nexport type ProfileSession = {\n readonly snapshot: () => ProfileSnapshot;\n readonly stop: () => ProfileSnapshot;\n};\n\nexport const startProfile = (): ProfileSession => {\n if (active.current) throw new Error('A document profile session is already active.');\n const value = counters();\n active.current = value;\n let stopped = false;\n const snapshot = (): ProfileSnapshot => freezeSnapshot(value);\n return {\n snapshot,\n stop: (): ProfileSnapshot => {\n if (!stopped) {\n stopped = true;\n active.current = undefined;\n }\n return snapshot();\n },\n };\n};\n\nexport const measureProfile = <T>(\n run: () => T\n): { readonly value: T; readonly profile: ProfileSnapshot } => {\n const session = startProfile();\n try {\n const value = run();\n return { value, profile: session.stop() };\n } catch (error) {\n session.stop();\n throw error;\n }\n};\n","import { profile } from '../profile';\n\nexport type CloneReason =\n 'initial' | 'canonical' | 'commit' | 'inverse' | 'reader' | 'replace' | 'journal' | 'snapshot';\n\nconst stablePayloads = new WeakSet<object>();\n\nconst markStablePayload = <T>(value: T): T => {\n if (Array.isArray(value) || isPlainObject(value)) stablePayloads.add(value as object);\n return value;\n};\n\nexport const isStablePayload = (value: unknown): boolean =>\n (Array.isArray(value) || isPlainObject(value)) && stablePayloads.has(value as object);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (value === null || typeof value !== 'object') return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n};\n\nconst countCloneReason = (reason: CloneReason | undefined): void => {\n if (reason) profile.clone.node(reason);\n};\n\nexport const cloneValue = <T>(value: T, reason?: CloneReason): T => {\n profile.clone.call();\n countCloneReason(reason);\n if (Array.isArray(value)) {\n profile.clone.container();\n const result = new Array(value.length);\n for (let index = 0; index < value.length; index += 1)\n result[index] = cloneValue(value[index], reason);\n return (\n reason === 'commit' || reason === 'inverse' || reason === 'snapshot'\n ? markStablePayload(Object.freeze(result))\n : result\n ) as T;\n }\n if (isPlainObject(value)) {\n profile.clone.container();\n const result: Record<string, unknown> = Object.create(Object.getPrototypeOf(value)) as Record<\n string,\n unknown\n >;\n for (const key in value) {\n if (Object.prototype.hasOwnProperty.call(value, key))\n result[key] = cloneValue(value[key], reason);\n }\n return (\n reason === 'commit' || reason === 'inverse' || reason === 'snapshot'\n ? markStablePayload(Object.freeze(result))\n : result\n ) as T;\n }\n return value;\n};\n\n// Structural document values cross an ownership boundary by cloning. Atomic\n// values are shared because their schema contract treats them as immutable.\nexport const ownPayload = <T>(value: T, reason: CloneReason = 'canonical'): T =>\n Array.isArray(value) || isPlainObject(value) ? cloneValue(value, reason) : value;\n\n// The caller transfers structural ownership to the mutable canonical document.\n// Public commit/history boundaries use snapshotPayload instead.\nexport const transferPayload = <T>(value: T): T => {\n profile.batch.payloadTransferred();\n return value;\n};\nexport const snapshotPayload = <T>(value: T, reason: CloneReason = 'commit'): T => (\n profile.batch.payloadSnapshot(),\n ownPayload(value, reason)\n);\n\nexport const deepEqual = (left: unknown, right: unknown): boolean => {\n profile.clone.deepEqual();\n if (Object.is(left, right)) return true;\n if (Array.isArray(left) && Array.isArray(right)) {\n profile.clone.deepEqualContainer();\n if (left.length !== right.length) return false;\n for (let index = 0; index < left.length; index += 1)\n if (!deepEqual(left[index], right[index])) return false;\n return true;\n }\n if (isPlainObject(left) && isPlainObject(right)) {\n profile.clone.deepEqualContainer();\n const leftKeys = Object.keys(left);\n if (leftKeys.length !== Object.keys(right).length) return false;\n for (const key of leftKeys) {\n if (!Object.prototype.hasOwnProperty.call(right, key) || !deepEqual(left[key], right[key]))\n return false;\n }\n return true;\n }\n return false;\n};\n\nexport const sameStructuralValue = (left: unknown, right: unknown): boolean =>\n Object.is(left, right) ||\n ((Array.isArray(left) || isPlainObject(left)) && deepEqual(left, right));\n\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n"],"mappings":";AAkKA,MAAM,SAAS,EAAE,SAAS,KAAA,GAA0C;AAuBpE,MAAa,UAAU;CACrB,aAAa,SAA8C,SAAS,MAAY;AAC9E,MAAI,OAAO,QAAS,QAAO,QAAQ,WAAW,YAAY;;CAE5D,OAAO;EACL,YAAkB;GAChB,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,MAAM,SAAS;;EAElC,OAAO,WAA8B;GACnC,MAAM,QAAQ,OAAO;AACrB,OAAI,CAAC,MAAO;AACZ,SAAM,MAAM,MAAM,WAAW;;EAE/B,iBAAuB;GACrB,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,MAAM,cAAc;;EAEvC,iBAAuB;GACrB,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,MAAM,UAAU,SAAS;;EAE5C,0BAAgC;GAC9B,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,MAAM,UAAU,cAAc;;EAEjD,uBAA6B;GAC3B,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,MAAM,UAAU,WAAW;;EAE/C;CACD,UAAU;EACR,kBAAwB;GACtB,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,SAAS,cAAc;;EAE1C,gBAAsB;GACpB,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,SAAS,YAAY;;EAExC,eAAqB;GACnB,MAAM,QAAQ,OAAO;AACrB,OAAI,MAAO,OAAM,SAAS,kBAAkB;;EAE/C;CACD,OAAO;EACL,iBAAuB;GACrB,MAAM,QAAQ,OAAO;AACrB,O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 0 };
3
- const profile = {
4
- projection: (counter, amount = 1) => {
5
- if (active.current) active.current.projection[counter] += amount;
6
- },
7
- clone: {
8
- call: () => {
9
- const value = active.current;
10
- if (value) value.clone.calls += 1;
11
- },
12
- node: (reason) => {
13
- const value = active.current;
14
- if (!value) return;
15
- value.clone.nodes[reason] += 1;
16
- },
17
- container: () => {
18
- const value = active.current;
19
- if (value) value.clone.containers += 1;
20
- },
21
- deepEqual: () => {
22
- const value = active.current;
23
- if (value) value.clone.deepEqual.calls += 1;
24
- },
25
- deepEqualContainer: () => {
26
- const value = active.current;
27
- if (value) value.clone.deepEqual.containers += 1;
28
- },
29
- initialDocument: () => {
30
- const value = active.current;
31
- if (value) value.clone.documents.initial += 1;
32
- }
33
- },
34
- mutation: {
35
- normalized: () => {
36
- const value = active.current;
37
- if (value) value.mutation.normalized += 1;
38
- },
39
- executed: () => {
40
- const value = active.current;
41
- if (value) value.mutation.executed += 1;
42
- },
43
- inverse: () => {
44
- const value = active.current;
45
- if (value) value.mutation.inverseCreated += 1;
46
- }
47
- },
48
- batch: {
49
- operation: () => {
50
- const value = active.current;
51
- if (value) value.batch.operations += 1;
52
- },
53
- entry: (amount = 1) => {
54
- const value = active.current;
55
- if (value) value.batch.entries += amount;
56
- },
57
- collectionResolved: () => {
58
- const value = active.current;
59
- if (value) value.batch.collectionsResolved += 1;
60
- },
61
- journalRecord: () => {
62
- const value = active.current;
63
- if (value) value.batch.journalRecords += 1;
64
- },
65
- rejected: () => {
66
- const value = active.current;
67
- if (value) value.batch.rejected += 1;
68
- },
69
- inverse: () => {
70
- const value = active.current;
71
- if (value) value.batch.inverseOperations += 1;
72
- },
73
- payloadTransferred: () => {
74
- const value = active.current;
75
- if (value) value.batch.payloadTransferred += 1;
76
- },
77
- payloadSnapshot: () => {
78
- const value = active.current;
79
- if (value) value.batch.payloadSnapshots += 1;
80
- }
81
- },
82
- journal: {
83
- subject: () => {
84
- const value = active.current;
85
- if (value) value.journal.subjects += 1;
86
- },
87
- comparison: () => {
88
- const value = active.current;
89
- if (value) value.journal.comparisons += 1;
90
- },
91
- absorbed: () => {
92
- const value = active.current;
93
- if (value) value.journal.absorbed += 1;
94
- },
95
- orderSnapshot: (items) => {
96
- const value = active.current;
97
- if (!value) return;
98
- value.journal.orderSnapshots += 1;
99
- value.journal.orderItems += items;
100
- }
101
- },
102
- address: {
103
- schemaStep: () => {
104
- const value = active.current;
105
- if (value) value.address.schemaSteps += 1;
106
- },
107
- documentStep: () => {
108
- const value = active.current;
109
- if (value) value.address.documentSteps += 1;
110
- },
111
- arrayCopied: () => {
112
- const value = active.current;
113
- if (value) value.address.arraysCopied += 1;
114
- },
115
- prefixComparison: () => {
116
- const value = active.current;
117
- if (value) value.address.prefixComparisons += 1;
118
- },
119
- segmentCompared: () => {
120
- const value = active.current;
121
- if (value) value.address.segmentsCompared += 1;
122
- }
123
- },
124
- impact: { affects: () => {
125
- const value = active.current;
126
- if (value) value.impact.affectsChecks += 1;
127
- } },
128
- reader: {
129
- session: () => {
130
- const value = active.current;
131
- if (value) value.reader.sessions += 1;
132
- },
133
- lookup: () => {
134
- const value = active.current;
135
- if (value) value.reader.nodeLookups += 1;
136
- },
137
- collectionIds: (amount = 1) => {
138
- const value = active.current;
139
- if (value) value.reader.collectionIds += amount;
140
- },
141
- structuralSnapshot: () => {
142
- const value = active.current;
143
- if (value) value.reader.structuralSnapshots += 1;
144
- }
145
- },
146
- collectionView: {
147
- mapped: () => {
148
- const value = active.current;
149
- if (value) value.collectionView.mappedItems += 1;
150
- },
151
- idsScanned: (amount = 1) => {
152
- const value = active.current;
153
- if (value) value.collectionView.idsScanned += amount;
154
- },
155
- arrayCopied: () => {
156
- const value = active.current;
157
- if (value) value.collectionView.arraysCopied += 1;
158
- }
159
- },
160
- materialized: {
161
- updated: () => {
162
- const value = active.current;
163
- if (value) value.materialized.updated += 1;
164
- },
165
- skipped: () => {
166
- const value = active.current;
167
- if (value) value.materialized.skipped += 1;
168
- },
169
- rebuilt: () => {
170
- const value = active.current;
171
- if (value) value.materialized.rebuilt += 1;
172
- },
173
- sourceChanged: () => {
174
- const value = active.current;
175
- if (value) value.materialized.sourceChanges += 1;
176
- },
177
- notification: () => {
178
- const value = active.current;
179
- if (value) value.materialized.notifications += 1;
180
- }
181
- }
182
- };
183
- //#endregion
184
- //#region core/src/value/ownership.ts
185
- const stablePayloads = /* @__PURE__ */ new WeakSet();
186
- const markStablePayload = (value) => {
187
- if (Array.isArray(value) || isPlainObject(value)) stablePayloads.add(value);
188
- return value;
189
- };
190
- const isStablePayload = (value) => (Array.isArray(value) || isPlainObject(value)) && stablePayloads.has(value);
191
- const isPlainObject = (value) => {
192
- if (value === null || typeof value !== "object") return false;
193
- const prototype = Object.getPrototypeOf(value);
194
- return prototype === Object.prototype || prototype === null;
195
- };
196
- const countCloneReason = (reason) => {
197
- if (reason) profile.clone.node(reason);
198
- };
199
- const cloneValue = (value, reason) => {
200
- profile.clone.call();
201
- countCloneReason(reason);
202
- if (Array.isArray(value)) {
203
- profile.clone.container();
204
- const result = new Array(value.length);
205
- for (let index = 0; index < value.length; index += 1) result[index] = cloneValue(value[index], reason);
206
- return reason === "commit" || reason === "inverse" || reason === "snapshot" ? markStablePayload(Object.freeze(result)) : result;
207
- }
208
- if (isPlainObject(value)) {
209
- profile.clone.container();
210
- const result = Object.create(Object.getPrototypeOf(value));
211
- for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) result[key] = cloneValue(value[key], reason);
212
- return reason === "commit" || reason === "inverse" || reason === "snapshot" ? markStablePayload(Object.freeze(result)) : result;
213
- }
214
- return value;
215
- };
216
- const ownPayload = (value, reason = "canonical") => Array.isArray(value) || isPlainObject(value) ? cloneValue(value, reason) : value;
217
- const transferPayload = (value) => {
218
- profile.batch.payloadTransferred();
219
- return value;
220
- };
221
- const snapshotPayload = (value, reason = "commit") => (profile.batch.payloadSnapshot(), ownPayload(value, reason));
222
- const deepEqual = (left, right) => {
223
- profile.clone.deepEqual();
224
- if (Object.is(left, right)) return true;
225
- if (Array.isArray(left) && Array.isArray(right)) {
226
- profile.clone.deepEqualContainer();
227
- if (left.length !== right.length) return false;
228
- for (let index = 0; index < left.length; index += 1) if (!deepEqual(left[index], right[index])) return false;
229
- return true;
230
- }
231
- if (isPlainObject(left) && isPlainObject(right)) {
232
- profile.clone.deepEqualContainer();
233
- const leftKeys = Object.keys(left);
234
- if (leftKeys.length !== Object.keys(right).length) return false;
235
- for (const key of leftKeys) if (!Object.prototype.hasOwnProperty.call(right, key) || !deepEqual(left[key], right[key])) return false;
236
- return true;
237
- }
238
- return false;
239
- };
240
- const sameStructuralValue = (left, right) => Object.is(left, right) || (Array.isArray(left) || isPlainObject(left)) && deepEqual(left, right);
241
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
242
- //#endregion
243
- export { isStablePayload as a, snapshotPayload as c, isRecord as i, transferPayload as l, deepEqual as n, ownPayload as o, isPlainObject as r, sameStructuralValue as s, cloneValue as t, profile as u };
244
-
245
- //# sourceMappingURL=ownership-CduRygE7.js.map