@contember/bindx 0.1.46 → 0.1.47
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/dist/core/ActionDispatcher.d.ts +4 -1
- package/dist/core/ActionDispatcher.d.ts.map +1 -1
- package/dist/core/actions.d.ts +7 -1
- package/dist/core/actions.d.ts.map +1 -1
- package/dist/events/EventEmitter.d.ts +13 -1
- package/dist/events/EventEmitter.d.ts.map +1 -1
- package/dist/handles/BaseHandle.d.ts +14 -3
- package/dist/handles/BaseHandle.d.ts.map +1 -1
- package/dist/handles/EntityHandle.d.ts +14 -5
- package/dist/handles/EntityHandle.d.ts.map +1 -1
- package/dist/handles/FieldHandle.d.ts +11 -4
- package/dist/handles/FieldHandle.d.ts.map +1 -1
- package/dist/handles/HasManyListHandle.d.ts +36 -2
- package/dist/handles/HasManyListHandle.d.ts.map +1 -1
- package/dist/handles/HasOneHandle.d.ts +52 -9
- package/dist/handles/HasOneHandle.d.ts.map +1 -1
- package/dist/handles/PlaceholderHandle.d.ts +25 -13
- package/dist/handles/PlaceholderHandle.d.ts.map +1 -1
- package/dist/handles/index.d.ts +1 -1
- package/dist/handles/index.d.ts.map +1 -1
- package/dist/handles/proxyFactory.d.ts +7 -1
- package/dist/handles/proxyFactory.d.ts.map +1 -1
- package/dist/handles/types.d.ts +33 -0
- package/dist/handles/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/persistence/BatchPersister.d.ts +53 -37
- package/dist/persistence/BatchPersister.d.ts.map +1 -1
- package/dist/persistence/ChangeRegistry.d.ts +15 -0
- package/dist/persistence/ChangeRegistry.d.ts.map +1 -1
- package/dist/persistence/MutationCollector.d.ts +106 -3
- package/dist/persistence/MutationCollector.d.ts.map +1 -1
- package/dist/persistence/PersistExecution.d.ts +26 -0
- package/dist/persistence/PersistExecution.d.ts.map +1 -0
- package/dist/persistence/types.d.ts +8 -2
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/store/EntityMetaStore.d.ts +32 -10
- package/dist/store/EntityMetaStore.d.ts.map +1 -1
- package/dist/store/EntitySnapshotStore.d.ts +50 -3
- package/dist/store/EntitySnapshotStore.d.ts.map +1 -1
- package/dist/store/ErrorStore.d.ts +3 -2
- package/dist/store/ErrorStore.d.ts.map +1 -1
- package/dist/store/HasManyStore.d.ts +214 -0
- package/dist/store/HasManyStore.d.ts.map +1 -0
- package/dist/store/HasOneStore.d.ts +159 -0
- package/dist/store/HasOneStore.d.ts.map +1 -0
- package/dist/store/ReachabilityAnalyzer.d.ts +19 -0
- package/dist/store/ReachabilityAnalyzer.d.ts.map +1 -1
- package/dist/store/RekeyOrchestrator.d.ts +76 -0
- package/dist/store/RekeyOrchestrator.d.ts.map +1 -0
- package/dist/store/RelationEdgeIndex.d.ts +34 -0
- package/dist/store/RelationEdgeIndex.d.ts.map +1 -0
- package/dist/store/RelationStore.d.ts +74 -137
- package/dist/store/RelationStore.d.ts.map +1 -1
- package/dist/store/RootRegistry.d.ts +25 -4
- package/dist/store/RootRegistry.d.ts.map +1 -1
- package/dist/store/SnapshotStore.d.ts +137 -13
- package/dist/store/SnapshotStore.d.ts.map +1 -1
- package/dist/store/SubscriptionManager.d.ts +63 -14
- package/dist/store/SubscriptionManager.d.ts.map +1 -1
- package/dist/store/TouchedStore.d.ts +3 -2
- package/dist/store/TouchedStore.d.ts.map +1 -1
- package/dist/store/relationKey.d.ts +15 -0
- package/dist/store/relationKey.d.ts.map +1 -0
- package/dist/undo/UndoJournal.d.ts +133 -0
- package/dist/undo/UndoJournal.d.ts.map +1 -0
- package/dist/undo/UndoManager.d.ts +25 -82
- package/dist/undo/UndoManager.d.ts.map +1 -1
- package/dist/undo/UnrecordedWriteError.d.ts +16 -0
- package/dist/undo/UnrecordedWriteError.d.ts.map +1 -0
- package/dist/undo/index.d.ts +3 -1
- package/dist/undo/index.d.ts.map +1 -1
- package/dist/undo/rekeyJournalEntry.d.ts +20 -0
- package/dist/undo/rekeyJournalEntry.d.ts.map +1 -0
- package/dist/undo/types.d.ts +0 -48
- package/dist/undo/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/core/ActionDispatcher.ts +56 -36
- package/src/core/actions.ts +8 -1
- package/src/events/EventEmitter.ts +78 -24
- package/src/handles/BaseHandle.ts +19 -2
- package/src/handles/EntityHandle.ts +48 -17
- package/src/handles/FieldHandle.ts +36 -10
- package/src/handles/HasManyListHandle.ts +120 -16
- package/src/handles/HasOneHandle.ts +177 -44
- package/src/handles/PlaceholderHandle.ts +184 -36
- package/src/handles/index.ts +3 -0
- package/src/handles/proxyFactory.ts +27 -0
- package/src/handles/types.ts +39 -0
- package/src/index.ts +4 -4
- package/src/persistence/BatchPersister.ts +810 -446
- package/src/persistence/ChangeRegistry.ts +27 -3
- package/src/persistence/MutationCollector.ts +265 -31
- package/src/persistence/PersistExecution.ts +217 -0
- package/src/persistence/types.ts +8 -2
- package/src/store/EntityMetaStore.ts +89 -45
- package/src/store/EntitySnapshotStore.ts +102 -19
- package/src/store/ErrorStore.ts +6 -5
- package/src/store/HasManyStore.ts +810 -0
- package/src/store/HasOneStore.ts +454 -0
- package/src/store/ReachabilityAnalyzer.ts +37 -0
- package/src/store/RekeyOrchestrator.ts +123 -0
- package/src/store/RelationEdgeIndex.ts +79 -0
- package/src/store/RelationStore.ts +176 -725
- package/src/store/RootRegistry.ts +50 -8
- package/src/store/SnapshotStore.ts +572 -101
- package/src/store/SubscriptionManager.ts +122 -75
- package/src/store/TouchedStore.ts +5 -2
- package/src/store/relationKey.ts +20 -0
- package/src/undo/UndoJournal.ts +258 -0
- package/src/undo/UndoManager.ts +151 -281
- package/src/undo/UnrecordedWriteError.ts +23 -0
- package/src/undo/index.ts +8 -7
- package/src/undo/rekeyJournalEntry.ts +145 -0
- package/src/undo/types.ts +0 -58
- package/dist/core/actionClassification.d.ts +0 -48
- package/dist/core/actionClassification.d.ts.map +0 -1
- package/src/core/actionClassification.ts +0 -199
|
@@ -13,32 +13,74 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Keys use the same composite format as the rest of the store: "entityType:id".
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
import type { RekeyContext, Rekeyable } from './RekeyOrchestrator.js'
|
|
17
|
+
|
|
18
|
+
export class RootRegistry implements Rekeyable {
|
|
17
19
|
private readonly roots = new Set<string>()
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Monotonic counter bumped whenever the root set actually changes. Used by
|
|
23
|
+
* {@link ReachabilityAnalyzer} to memoize the reachability walk. Bumps happen
|
|
24
|
+
* only on a real change so the per-render `registerParentChild` → `unregister`
|
|
25
|
+
* call (almost always a no-op for an already-anchored child) does not
|
|
26
|
+
* needlessly invalidate the cache.
|
|
27
|
+
*/
|
|
28
|
+
private mutationVersion = 0
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Monotonic counter bumped on EDITABLE-layer root changes — the create-root
|
|
32
|
+
* register/unregister that back an undoable gesture (createEntity,
|
|
33
|
+
* registerParentChild). The persist rekey and full clear deliberately do NOT
|
|
34
|
+
* bump it. Read by the undo write-guard (see UndoJournal). The unjournaled
|
|
35
|
+
* register/unregister callers (undo restore, memory sweep, unmount cleanup) all
|
|
36
|
+
* run outside a journal transaction, so counting them here is harmless.
|
|
37
|
+
*/
|
|
38
|
+
private editableWriteVersion = 0
|
|
39
|
+
|
|
19
40
|
register(key: string): void {
|
|
20
|
-
this.roots.
|
|
41
|
+
if (!this.roots.has(key)) {
|
|
42
|
+
this.roots.add(key)
|
|
43
|
+
this.mutationVersion++
|
|
44
|
+
this.editableWriteVersion++
|
|
45
|
+
}
|
|
21
46
|
}
|
|
22
47
|
|
|
23
48
|
unregister(key: string): void {
|
|
24
|
-
this.roots.delete(key)
|
|
49
|
+
if (this.roots.delete(key)) {
|
|
50
|
+
this.mutationVersion++
|
|
51
|
+
this.editableWriteVersion++
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getEditableWriteVersion(): number {
|
|
56
|
+
return this.editableWriteVersion
|
|
25
57
|
}
|
|
26
58
|
|
|
27
59
|
keys(): IterableIterator<string> {
|
|
28
60
|
return this.roots.keys()
|
|
29
61
|
}
|
|
30
62
|
|
|
63
|
+
has(key: string): boolean {
|
|
64
|
+
return this.roots.has(key)
|
|
65
|
+
}
|
|
66
|
+
|
|
31
67
|
/**
|
|
32
|
-
* Moves a root entry from
|
|
33
|
-
* id to a server-assigned id).
|
|
68
|
+
* Moves a root entry from the temp key to the persisted key (used after
|
|
69
|
+
* persist rekeys a temp id to a server-assigned id).
|
|
34
70
|
*/
|
|
35
|
-
rekey(
|
|
36
|
-
if (this.roots.delete(oldKey)) {
|
|
37
|
-
this.roots.add(newKey)
|
|
71
|
+
rekey(ctx: RekeyContext): void {
|
|
72
|
+
if (this.roots.delete(ctx.oldKey)) {
|
|
73
|
+
this.roots.add(ctx.newKey)
|
|
74
|
+
this.mutationVersion++
|
|
38
75
|
}
|
|
39
76
|
}
|
|
40
77
|
|
|
41
78
|
clear(): void {
|
|
42
79
|
this.roots.clear()
|
|
80
|
+
this.mutationVersion++
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getMutationVersion(): number {
|
|
84
|
+
return this.mutationVersion
|
|
43
85
|
}
|
|
44
86
|
}
|