@agoric/swingset-liveslots 0.10.3-other-dev-8f8782b.0 → 0.10.3-other-dev-fbe72e7.0.fbe72e7
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 +2 -0
- package/package.json +34 -26
- package/src/boyd-gc.d.ts +12 -0
- package/src/boyd-gc.d.ts.map +1 -0
- package/src/boyd-gc.js +598 -0
- package/src/cache.d.ts +71 -0
- package/src/cache.d.ts.map +1 -0
- package/src/cache.js +3 -2
- package/src/capdata.d.ts +16 -0
- package/src/capdata.d.ts.map +1 -0
- package/src/capdata.js +17 -10
- package/src/collectionManager.d.ts +47 -0
- package/src/collectionManager.d.ts.map +1 -0
- package/src/collectionManager.js +220 -103
- package/src/facetiousness.d.ts +25 -0
- package/src/facetiousness.d.ts.map +1 -0
- package/src/facetiousness.js +1 -1
- package/src/index.d.ts +4 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +4 -2
- package/src/kdebug.d.ts +7 -0
- package/src/kdebug.d.ts.map +1 -0
- package/src/liveslots.d.ts +42 -0
- package/src/liveslots.d.ts.map +1 -0
- package/src/liveslots.js +137 -305
- package/src/message.d.ts +49 -0
- package/src/message.d.ts.map +1 -0
- package/src/message.js +9 -5
- package/src/parseVatSlots.d.ts +125 -0
- package/src/parseVatSlots.d.ts.map +1 -0
- package/src/parseVatSlots.js +1 -1
- package/src/types-index.d.ts +4 -0
- package/src/types-index.js +2 -0
- package/src/types.d.ts +81 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +14 -7
- package/src/vatDataTypes.d.ts +170 -0
- package/src/vatDataTypes.d.ts.map +1 -0
- package/src/vatDataTypes.ts +272 -0
- package/src/vatstore-iterators.d.ts +4 -0
- package/src/vatstore-iterators.d.ts.map +1 -0
- package/src/vatstore-iterators.js +2 -0
- package/src/vatstore-usage.md +198 -0
- package/src/virtualObjectManager.d.ts +44 -0
- package/src/virtualObjectManager.d.ts.map +1 -0
- package/src/virtualObjectManager.js +254 -84
- package/src/virtualReferences.d.ts +61 -0
- package/src/virtualReferences.d.ts.map +1 -0
- package/src/virtualReferences.js +135 -26
- package/src/vpid-tracking.md +92 -0
- package/src/watchedPromises.d.ts +31 -0
- package/src/watchedPromises.d.ts.map +1 -0
- package/src/watchedPromises.js +81 -24
- package/test/{test-baggage.js → baggage.test.js} +1 -2
- package/test/{test-cache.js → cache.test.js} +0 -1
- package/test/clear-collection.test.js +586 -0
- package/test/{test-collection-schema-refcount.js → collection-schema-refcount.test.js} +1 -2
- package/test/{test-collection-upgrade.js → collection-upgrade.test.js} +1 -3
- package/test/{test-collections.js → collections.test.js} +183 -18
- package/test/{test-dropped-collection-weakrefs.js → dropped-collection-weakrefs.test.js} +1 -2
- package/test/dropped-weakset-9939.test.js +80 -0
- package/test/dummyMeterControl.d.ts +2 -0
- package/test/dummyMeterControl.d.ts.map +1 -0
- package/test/dummyMeterControl.js +1 -1
- package/test/{test-durabilityChecks.js → durabilityChecks.test.js} +4 -4
- package/test/engine-gc.d.ts +3 -0
- package/test/engine-gc.d.ts.map +1 -0
- package/test/exo-utils.js +70 -0
- package/test/{test-facetiousness.js → facetiousness.test.js} +1 -2
- package/test/gc-and-finalize.d.ts +5 -0
- package/test/gc-and-finalize.d.ts.map +1 -0
- package/test/gc-and-finalize.js +30 -1
- package/test/gc-before-finalizer.test.js +230 -0
- package/test/gc-helpers.js +4 -5
- package/test/{test-gc-sensitivity.js → gc-sensitivity.test.js} +2 -2
- package/test/handled-promises.test.js +872 -0
- package/test/{test-initial-vrefs.js → initial-vrefs.test.js} +13 -20
- package/test/liveslots-helpers.d.ts +64 -0
- package/test/liveslots-helpers.d.ts.map +1 -0
- package/test/liveslots-helpers.js +13 -7
- package/test/{test-liveslots-mock-gc.js → liveslots-mock-gc.test.js} +101 -2
- package/test/{test-liveslots-real-gc.js → liveslots-real-gc.test.js} +73 -46
- package/test/{test-liveslots.js → liveslots.test.js} +17 -18
- package/test/mock-gc.js +1 -0
- package/test/storeGC/{test-lifecycle.js → lifecycle.test.js} +15 -14
- package/test/storeGC/{test-refcount-management.js → refcount-management.test.js} +1 -2
- package/test/storeGC/{test-scalar-store-kind.js → scalar-store-kind.test.js} +0 -1
- package/test/storeGC/{test-weak-key.js → weak-key.test.js} +1 -2
- package/test/strict-test-env-upgrade.test.js +94 -0
- package/test/util.d.ts +25 -0
- package/test/util.d.ts.map +1 -0
- package/test/util.js +4 -4
- package/test/vat-environment.test.js +65 -0
- package/test/vat-util.d.ts +9 -0
- package/test/vat-util.d.ts.map +1 -0
- package/test/vat-util.js +2 -2
- package/test/virtual-objects/{test-cease-recognition.js → cease-recognition.test.js} +2 -2
- package/test/virtual-objects/{test-cross-facet.js → cross-facet.test.js} +5 -4
- package/test/virtual-objects/{test-empty-data.js → empty-data.test.js} +1 -2
- package/test/virtual-objects/{test-facets.js → facets.test.js} +1 -2
- package/test/virtual-objects/{test-kind-changes.js → kind-changes.test.js} +2 -2
- package/test/virtual-objects/{test-reachable-vrefs.js → reachable-vrefs.test.js} +2 -2
- package/test/virtual-objects/{test-rep-tostring.js → rep-tostring.test.js} +3 -5
- package/test/virtual-objects/{test-retain-remotable.js → retain-remotable.test.js} +25 -24
- package/test/virtual-objects/set-debug-label-instances.js +1 -1
- package/test/virtual-objects/state-shape.test.js +389 -0
- package/test/virtual-objects/{test-virtualObjectGC.js → virtualObjectGC.test.js} +39 -38
- package/test/virtual-objects/{test-virtualObjectManager.js → virtualObjectManager.test.js} +104 -8
- package/test/virtual-objects/{test-vo-real-gc.js → vo-real-gc.test.js} +8 -8
- package/test/virtual-objects/{test-weakcollections-vref-handling.js → weakcollections-vref-handling.test.js} +1 -2
- package/test/{test-vo-test-harness.js → vo-test-harness.test.js} +13 -10
- package/test/{test-vpid-liveslots.js → vpid-liveslots.test.js} +105 -5
- package/test/waitUntilQuiescent.d.ts +3 -0
- package/test/waitUntilQuiescent.d.ts.map +1 -0
- package/test/waitUntilQuiescent.js +2 -1
- package/test/weakset-dropped-remotable.test.js +50 -0
- package/tools/fakeCollectionManager.d.ts +14 -0
- package/tools/fakeCollectionManager.d.ts.map +1 -0
- package/tools/fakeCollectionManager.js +44 -0
- package/tools/fakeVirtualObjectManager.d.ts +32 -0
- package/tools/fakeVirtualObjectManager.d.ts.map +1 -0
- package/tools/fakeVirtualObjectManager.js +62 -0
- package/tools/fakeVirtualSupport.d.ts +278 -0
- package/tools/fakeVirtualSupport.d.ts.map +1 -0
- package/tools/fakeVirtualSupport.js +389 -0
- package/tools/prepare-strict-test-env.d.ts +37 -0
- package/tools/prepare-strict-test-env.d.ts.map +1 -0
- package/tools/prepare-strict-test-env.js +124 -0
- package/tools/prepare-test-env.d.ts +2 -0
- package/tools/prepare-test-env.d.ts.map +1 -0
- package/tools/prepare-test-env.js +13 -0
- package/tools/setup-vat-data.d.ts +9 -0
- package/tools/setup-vat-data.d.ts.map +1 -0
- package/tools/setup-vat-data.js +95 -0
- package/tools/vo-test-harness.d.ts +33 -0
- package/tools/vo-test-harness.d.ts.map +1 -0
- package/tools/vo-test-harness.js +164 -0
- package/CHANGELOG.md +0 -61
- package/test/kmarshal.js +0 -79
- package/test/test-handled-promises.js +0 -360
- package/test/virtual-objects/test-state-shape.js +0 -298
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
export function makeFakeLiveSlotsStuff(options?: {}): {
|
|
2
|
+
syscall: {
|
|
3
|
+
vatstoreGet(key: any): any;
|
|
4
|
+
vatstoreGetNextKey(priorKey: any): any;
|
|
5
|
+
vatstoreSet(key: any, value: any): void;
|
|
6
|
+
vatstoreDelete(key: any): void;
|
|
7
|
+
};
|
|
8
|
+
allocateExportID: () => any;
|
|
9
|
+
allocatePromiseID: () => any;
|
|
10
|
+
allocateCollectionID: () => any;
|
|
11
|
+
getSlotForVal: (val: any) => any;
|
|
12
|
+
requiredValForSlot: (slot: any) => any;
|
|
13
|
+
getValForSlot: (slot: any) => any;
|
|
14
|
+
setValForSlot: (slot: any, val: any) => void;
|
|
15
|
+
registerEntry: (baseRef: any, val: any, valIsCohort: any) => void;
|
|
16
|
+
valToSlot: any;
|
|
17
|
+
slotToVal: Map<any, any>;
|
|
18
|
+
convertValToSlot: (val: any) => any;
|
|
19
|
+
convertSlotToVal: (slot: any) => any;
|
|
20
|
+
marshal: {
|
|
21
|
+
toCapData: import("@endo/marshal").ToCapData<any>;
|
|
22
|
+
fromCapData: import("@endo/marshal").FromCapData<any>;
|
|
23
|
+
serialize: import("@endo/marshal").ToCapData<any>;
|
|
24
|
+
unserialize: import("@endo/marshal").FromCapData<any>;
|
|
25
|
+
};
|
|
26
|
+
deleteEntry: (slot: any, val: any) => void;
|
|
27
|
+
FinalizationRegistry: any;
|
|
28
|
+
WeakRef: any;
|
|
29
|
+
WeakMap: any;
|
|
30
|
+
WeakSet: any;
|
|
31
|
+
addToPossiblyDeadSet: any;
|
|
32
|
+
addToPossiblyRetiredSet: any;
|
|
33
|
+
dumpStore: () => any[][];
|
|
34
|
+
setVrm: (vrmToUse: any) => void;
|
|
35
|
+
assertAcceptableSyscallCapdataSize: (_capdatas: any) => void;
|
|
36
|
+
maybeExportPromise: (_vref: any) => boolean;
|
|
37
|
+
};
|
|
38
|
+
export function makeFakeVirtualReferenceManager(fakeStuff: any, relaxDurabilityRules?: boolean): {
|
|
39
|
+
registerDroppedCollection: (target: any, descriptor: any) => void;
|
|
40
|
+
isDurable: (vref: string) => boolean;
|
|
41
|
+
isDurableKind: (kindID: string) => boolean;
|
|
42
|
+
registerKind: (kindID: string, reanimator?: (string: any, boolean: any) => object, deleter?: (string: any) => boolean, durable?: boolean) => void;
|
|
43
|
+
rememberFacetNames: (kindID: string, facetNames: string[] | null) => void;
|
|
44
|
+
getFacet: (kindID: any, facets: any, facetIndex: any) => any;
|
|
45
|
+
getFacetNames: (kindID: any) => any;
|
|
46
|
+
reanimate: (baseRef: string) => any;
|
|
47
|
+
addReachableVref: (vref: any) => void;
|
|
48
|
+
removeReachableVref: (vref: any) => boolean;
|
|
49
|
+
updateReferenceCounts: (beforeSlots: any, afterSlots: any) => void;
|
|
50
|
+
getReachablePromiseRefCount: (p: any) => number;
|
|
51
|
+
addRecognizableValue: (value: any, recognizer: string | (Map<string, any> | Set<string>), recognizerIsVirtual?: boolean) => void;
|
|
52
|
+
removeRecognizableVref: (vref: string, recognizer: string | (Map<string, any> | Set<string>), recognizerIsVirtual?: boolean) => void;
|
|
53
|
+
removeRecognizableValue: (value: any, recognizer: string | (Map<string, any> | Set<string>), recognizerIsVirtual?: boolean) => void;
|
|
54
|
+
vrefKey: (value: any) => string | undefined;
|
|
55
|
+
isPresenceReachable: (vref: string) => boolean;
|
|
56
|
+
isVrefRecognizable: (vref: any) => boolean;
|
|
57
|
+
setExportStatus: (vref: any, exportStatus: any) => void;
|
|
58
|
+
isVirtualObjectReachable: (baseRef: string) => boolean;
|
|
59
|
+
deleteVirtualObject: (baseRef: string) => [boolean, string[]];
|
|
60
|
+
ceaseRecognition: (vref: string) => boolean;
|
|
61
|
+
setDeleteCollectionEntry: (fn: any) => void;
|
|
62
|
+
getRetentionStats: () => {
|
|
63
|
+
remotableRefCounts: number;
|
|
64
|
+
vrefRecognizers: number;
|
|
65
|
+
kindInfoTable: number;
|
|
66
|
+
};
|
|
67
|
+
initializeIDCounters: () => void;
|
|
68
|
+
allocateNextID: (name: any) => number;
|
|
69
|
+
flushIDCounters: () => void;
|
|
70
|
+
testHooks: {
|
|
71
|
+
getReachableRefCount: (vref: any) => number | undefined;
|
|
72
|
+
countCollectionsForWeakKey: (vref: any) => number;
|
|
73
|
+
getDroppedCollectionRegistry: () => any;
|
|
74
|
+
remotableRefCounts: Map<any, number>;
|
|
75
|
+
vrefRecognizers: Map<string, Set<Map<string, any> | Set<string>>>;
|
|
76
|
+
kindInfoTable: Map<any, any>;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export function makeFakeWatchedPromiseManager(vrm: any, vom: any, collectionManager: any, fakeStuff: any): {
|
|
80
|
+
preparePromiseWatcherTables: () => void;
|
|
81
|
+
loadWatchedPromiseTable: (revivePromise: (vref: any) => Promise<any>) => void;
|
|
82
|
+
providePromiseWatcher: <V, A extends any[]>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, fulfillHandler?: (value: V, ...args: A) => void, rejectHandler?: (reason: any, ...args: A) => void) => import("../src/types.js").PromiseWatcher<V, A>;
|
|
83
|
+
watchPromise: <P extends Promise<any>, A extends any[]>(p: P, watcher: import("../src/types.js").PromiseWatcher<Awaited<P>, A>, ...args: A) => void;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Configure virtual stuff with relaxed durability rules and fake liveslots
|
|
87
|
+
*
|
|
88
|
+
* @param {object} [options]
|
|
89
|
+
* @param {number} [options.cacheSize]
|
|
90
|
+
* @param {boolean} [options.relaxDurabilityRules]
|
|
91
|
+
* @param {Map<string, string>} [options.fakeStore]
|
|
92
|
+
* @param {WeakMapConstructor} [options.WeakMap]
|
|
93
|
+
* @param {WeakSetConstructor} [options.WeakSet]
|
|
94
|
+
* @param {boolean} [options.weak]
|
|
95
|
+
*/
|
|
96
|
+
export function makeFakeVirtualStuff(options?: {
|
|
97
|
+
cacheSize?: number | undefined;
|
|
98
|
+
relaxDurabilityRules?: boolean | undefined;
|
|
99
|
+
fakeStore?: Map<string, string> | undefined;
|
|
100
|
+
WeakMap?: WeakMapConstructor | undefined;
|
|
101
|
+
WeakSet?: WeakSetConstructor | undefined;
|
|
102
|
+
weak?: boolean | undefined;
|
|
103
|
+
}): {
|
|
104
|
+
fakeStuff: {
|
|
105
|
+
syscall: {
|
|
106
|
+
vatstoreGet(key: any): any;
|
|
107
|
+
vatstoreGetNextKey(priorKey: any): any;
|
|
108
|
+
vatstoreSet(key: any, value: any): void;
|
|
109
|
+
vatstoreDelete(key: any): void;
|
|
110
|
+
};
|
|
111
|
+
allocateExportID: () => any;
|
|
112
|
+
allocatePromiseID: () => any;
|
|
113
|
+
allocateCollectionID: () => any;
|
|
114
|
+
getSlotForVal: (val: any) => any;
|
|
115
|
+
requiredValForSlot: (slot: any) => any;
|
|
116
|
+
getValForSlot: (slot: any) => any;
|
|
117
|
+
setValForSlot: (slot: any, val: any) => void;
|
|
118
|
+
registerEntry: (baseRef: any, val: any, valIsCohort: any) => void;
|
|
119
|
+
valToSlot: any;
|
|
120
|
+
slotToVal: Map<any, any>;
|
|
121
|
+
convertValToSlot: (val: any) => any;
|
|
122
|
+
convertSlotToVal: (slot: any) => any;
|
|
123
|
+
marshal: {
|
|
124
|
+
toCapData: import("@endo/marshal").ToCapData<any>;
|
|
125
|
+
fromCapData: import("@endo/marshal").FromCapData<any>;
|
|
126
|
+
serialize: import("@endo/marshal").ToCapData<any>;
|
|
127
|
+
unserialize: import("@endo/marshal").FromCapData<any>;
|
|
128
|
+
};
|
|
129
|
+
deleteEntry: (slot: any, val: any) => void;
|
|
130
|
+
FinalizationRegistry: any;
|
|
131
|
+
WeakRef: any;
|
|
132
|
+
WeakMap: any;
|
|
133
|
+
WeakSet: any;
|
|
134
|
+
addToPossiblyDeadSet: any;
|
|
135
|
+
addToPossiblyRetiredSet: any;
|
|
136
|
+
dumpStore: () => any[][];
|
|
137
|
+
setVrm: (vrmToUse: any) => void;
|
|
138
|
+
assertAcceptableSyscallCapdataSize: (_capdatas: any) => void;
|
|
139
|
+
maybeExportPromise: (_vref: any) => boolean;
|
|
140
|
+
};
|
|
141
|
+
vrm: {
|
|
142
|
+
registerDroppedCollection: (target: any, descriptor: any) => void;
|
|
143
|
+
isDurable: (vref: string) => boolean;
|
|
144
|
+
isDurableKind: (kindID: string) => boolean;
|
|
145
|
+
registerKind: (kindID: string, reanimator?: (string: any, boolean: any) => object, deleter?: (string: any) => boolean, durable?: boolean) => void;
|
|
146
|
+
rememberFacetNames: (kindID: string, facetNames: string[] | null) => void;
|
|
147
|
+
getFacet: (kindID: any, facets: any, facetIndex: any) => any;
|
|
148
|
+
getFacetNames: (kindID: any) => any;
|
|
149
|
+
reanimate: (baseRef: string) => any;
|
|
150
|
+
addReachableVref: (vref: any) => void;
|
|
151
|
+
removeReachableVref: (vref: any) => boolean;
|
|
152
|
+
updateReferenceCounts: (beforeSlots: any, afterSlots: any) => void;
|
|
153
|
+
getReachablePromiseRefCount: (p: any) => number;
|
|
154
|
+
addRecognizableValue: (value: any, recognizer: string | (Map<string, any> | Set<string>), recognizerIsVirtual?: boolean) => void;
|
|
155
|
+
removeRecognizableVref: (vref: string, recognizer: string | (Map<string, any> | Set<string>), recognizerIsVirtual?: boolean) => void;
|
|
156
|
+
removeRecognizableValue: (value: any, recognizer: string | (Map<string, any> | Set<string>), recognizerIsVirtual?: boolean) => void;
|
|
157
|
+
vrefKey: (value: any) => string | undefined;
|
|
158
|
+
isPresenceReachable: (vref: string) => boolean;
|
|
159
|
+
isVrefRecognizable: (vref: any) => boolean;
|
|
160
|
+
setExportStatus: (vref: any, exportStatus: any) => void;
|
|
161
|
+
isVirtualObjectReachable: (baseRef: string) => boolean;
|
|
162
|
+
deleteVirtualObject: (baseRef: string) => [boolean, string[]];
|
|
163
|
+
ceaseRecognition: (vref: string) => boolean;
|
|
164
|
+
setDeleteCollectionEntry: (fn: any) => void;
|
|
165
|
+
getRetentionStats: () => {
|
|
166
|
+
remotableRefCounts: number;
|
|
167
|
+
vrefRecognizers: number;
|
|
168
|
+
kindInfoTable: number;
|
|
169
|
+
};
|
|
170
|
+
initializeIDCounters: () => void;
|
|
171
|
+
allocateNextID: (name: any) => number;
|
|
172
|
+
flushIDCounters: () => void;
|
|
173
|
+
testHooks: {
|
|
174
|
+
getReachableRefCount: (vref: any) => number | undefined;
|
|
175
|
+
countCollectionsForWeakKey: (vref: any) => number;
|
|
176
|
+
getDroppedCollectionRegistry: () => any;
|
|
177
|
+
remotableRefCounts: Map<any, number>;
|
|
178
|
+
vrefRecognizers: Map<string, Set<Map<string, any> | Set<string>>>;
|
|
179
|
+
kindInfoTable: Map<any, any>;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
vom: {
|
|
183
|
+
getValForSlot: any;
|
|
184
|
+
setValForSlot: any;
|
|
185
|
+
registerEntry: any;
|
|
186
|
+
deleteEntry: any;
|
|
187
|
+
flushStateCache: () => void;
|
|
188
|
+
dumpStore: any;
|
|
189
|
+
initializeKindHandleKind: () => void;
|
|
190
|
+
defineKind: <P extends Array<any>, S, F>(tag: string, init: (...args: P) => S, facet: F, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").KindContext<S, F>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacet<F>;
|
|
191
|
+
defineKindMulti: <P extends Array<any>, S, B>(tag: string, init: (...args: P) => S, behavior: B, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").MultiKindContext<S, B>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacets<B>;
|
|
192
|
+
defineDurableKind: <P extends Array<any>, S, F>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, init: (...args: P) => S, facet: F, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").KindContext<S, F>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacet<F>;
|
|
193
|
+
defineDurableKindMulti: <P extends Array<any>, S, B>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, init: (...args: P) => S, behavior: B, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").MultiKindContext<S, B>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacets<B>;
|
|
194
|
+
makeKindHandle: (tag: string) => import("../src/vatDataTypes.js").DurableKindHandle;
|
|
195
|
+
canBeDurable: (specimen: any) => boolean;
|
|
196
|
+
insistAllDurableKindsReconnected: () => void;
|
|
197
|
+
VirtualObjectAwareWeakMap: {
|
|
198
|
+
new (): {
|
|
199
|
+
has(key: any): any;
|
|
200
|
+
get(key: any): any;
|
|
201
|
+
set(key: any, value: any): /*elided*/ any;
|
|
202
|
+
delete(key: any): any;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
VirtualObjectAwareWeakSet: {
|
|
206
|
+
new (): {
|
|
207
|
+
has(value: any): any;
|
|
208
|
+
add(value: any): /*elided*/ any;
|
|
209
|
+
delete(value: any): any;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
cm: {
|
|
214
|
+
getValForSlot: any;
|
|
215
|
+
setValForSlot: any;
|
|
216
|
+
registerEntry: any;
|
|
217
|
+
deleteEntry: any;
|
|
218
|
+
dumpStore: any;
|
|
219
|
+
makeScalarBigMapStore: <K, V>(label?: string, options?: StoreOptions) => MapStore<K, V>;
|
|
220
|
+
makeScalarBigWeakMapStore: <K, V>(label?: string, options?: StoreOptions) => WeakMapStore<K, V>;
|
|
221
|
+
makeScalarBigSetStore: <K>(label?: string, options?: StoreOptions) => SetStore<K>;
|
|
222
|
+
makeScalarBigWeakSetStore: <K>(label?: string, options?: StoreOptions) => WeakSetStore<K>;
|
|
223
|
+
provideBaggage: () => any;
|
|
224
|
+
flushSchemaCache: () => void;
|
|
225
|
+
};
|
|
226
|
+
wpm: {
|
|
227
|
+
preparePromiseWatcherTables: () => void;
|
|
228
|
+
loadWatchedPromiseTable: (revivePromise: (vref: any) => Promise<any>) => void;
|
|
229
|
+
providePromiseWatcher: <V, A extends any[]>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, fulfillHandler?: (value: V, ...args: A) => void, rejectHandler?: (reason: any, ...args: A) => void) => import("../src/types.js").PromiseWatcher<V, A>;
|
|
230
|
+
watchPromise: <P extends Promise<any>, A extends any[]>(p: P, watcher: import("../src/types.js").PromiseWatcher<Awaited<P>, A>, ...args: A) => void;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
export function makeStandaloneFakeVirtualObjectManager(options?: {}): {
|
|
234
|
+
getValForSlot: any;
|
|
235
|
+
setValForSlot: any;
|
|
236
|
+
registerEntry: any;
|
|
237
|
+
deleteEntry: any;
|
|
238
|
+
flushStateCache: () => void;
|
|
239
|
+
dumpStore: any;
|
|
240
|
+
initializeKindHandleKind: () => void;
|
|
241
|
+
defineKind: <P extends Array<any>, S, F>(tag: string, init: (...args: P) => S, facet: F, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").KindContext<S, F>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacet<F>;
|
|
242
|
+
defineKindMulti: <P extends Array<any>, S, B>(tag: string, init: (...args: P) => S, behavior: B, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").MultiKindContext<S, B>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacets<B>;
|
|
243
|
+
defineDurableKind: <P extends Array<any>, S, F>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, init: (...args: P) => S, facet: F, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").KindContext<S, F>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacet<F>;
|
|
244
|
+
defineDurableKindMulti: <P extends Array<any>, S, B>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, init: (...args: P) => S, behavior: B, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").MultiKindContext<S, B>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacets<B>;
|
|
245
|
+
makeKindHandle: (tag: string) => import("../src/vatDataTypes.js").DurableKindHandle;
|
|
246
|
+
canBeDurable: (specimen: any) => boolean;
|
|
247
|
+
insistAllDurableKindsReconnected: () => void;
|
|
248
|
+
VirtualObjectAwareWeakMap: {
|
|
249
|
+
new (): {
|
|
250
|
+
has(key: any): any;
|
|
251
|
+
get(key: any): any;
|
|
252
|
+
set(key: any, value: any): /*elided*/ any;
|
|
253
|
+
delete(key: any): any;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
VirtualObjectAwareWeakSet: {
|
|
257
|
+
new (): {
|
|
258
|
+
has(value: any): any;
|
|
259
|
+
add(value: any): /*elided*/ any;
|
|
260
|
+
delete(value: any): any;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
export function makeStandaloneFakeCollectionManager(options?: {}): {
|
|
265
|
+
getValForSlot: any;
|
|
266
|
+
setValForSlot: any;
|
|
267
|
+
registerEntry: any;
|
|
268
|
+
deleteEntry: any;
|
|
269
|
+
dumpStore: any;
|
|
270
|
+
makeScalarBigMapStore: <K, V>(label?: string, options?: StoreOptions) => MapStore<K, V>;
|
|
271
|
+
makeScalarBigWeakMapStore: <K, V>(label?: string, options?: StoreOptions) => WeakMapStore<K, V>;
|
|
272
|
+
makeScalarBigSetStore: <K>(label?: string, options?: StoreOptions) => SetStore<K>;
|
|
273
|
+
makeScalarBigWeakSetStore: <K>(label?: string, options?: StoreOptions) => WeakSetStore<K>;
|
|
274
|
+
provideBaggage: () => any;
|
|
275
|
+
flushSchemaCache: () => void;
|
|
276
|
+
};
|
|
277
|
+
export { makeStandaloneFakeVirtualObjectManager as makeFakeVirtualObjectManager, makeStandaloneFakeCollectionManager as makeFakeCollectionManager };
|
|
278
|
+
//# sourceMappingURL=fakeVirtualSupport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakeVirtualSupport.d.ts","sourceRoot":"","sources":["fakeVirtualSupport.js"],"names":[],"mappings":"AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuQC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcC;AAED;;;4IA5HwB,GAAI,gDAE1B,GAAC;;EAyIF;AAED;;;;;;;;;;GAUG;AACH,+CAPG;IAAyB,SAAS;IACR,oBAAoB;IACR,SAAS;IACV,OAAO;IACP,OAAO;IAClB,IAAI;CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAjFH,GAC9B,+IAKuB,GAAG;0EAQd,GAAG,uJAKV,GAAG;+HAeL,GAAG,+IAKiB,GAAG;oIAOA,GAC1B,uJAGG,GAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gJAvHkB,GAAI,gDAE1B,GAAC;;;EAqKF;AAED;;;;;;;;iEApG+B,GAC9B,+IAKuB,GAAG;sEAQd,GAAG,uJAKV,GAAG;2HAeL,GAAG,+IAKiB,GAAG;gIAOA,GAC1B,uJAGG,GAAE;;;;;;;;;;;;;;;;;;;EA0DL;AAED;;;;;;;;;;;;EAMC"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/* global globalThis */
|
|
2
|
+
/* eslint-disable max-classes-per-file */
|
|
3
|
+
import { assert, Fail } from '@endo/errors';
|
|
4
|
+
import { makeMarshal } from '@endo/marshal';
|
|
5
|
+
import { isPromise } from '@endo/promise-kit';
|
|
6
|
+
|
|
7
|
+
import { parseVatSlot } from '../src/parseVatSlots.js';
|
|
8
|
+
import { makeVirtualReferenceManager } from '../src/virtualReferences.js';
|
|
9
|
+
import { makeWatchedPromiseManager } from '../src/watchedPromises.js';
|
|
10
|
+
import { makeFakeVirtualObjectManager } from './fakeVirtualObjectManager.js';
|
|
11
|
+
import { makeFakeCollectionManager } from './fakeCollectionManager.js';
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
WeakRef: RealWeakRef,
|
|
15
|
+
WeakMap: RealWeakMap,
|
|
16
|
+
WeakSet: RealWeakSet,
|
|
17
|
+
} = globalThis;
|
|
18
|
+
|
|
19
|
+
class FakeFinalizationRegistry {
|
|
20
|
+
// eslint-disable-next-line no-useless-constructor, no-empty-function
|
|
21
|
+
constructor() {}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line class-methods-use-this
|
|
24
|
+
register(_target, _heldValue, _unregisterToken) {}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line class-methods-use-this
|
|
27
|
+
unregister(_unregisterToken) {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class FakeWeakRef {
|
|
31
|
+
#target;
|
|
32
|
+
|
|
33
|
+
constructor(target) {
|
|
34
|
+
this.#target = target;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
deref() {
|
|
38
|
+
return this.#target; // strong ref
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function makeFakeLiveSlotsStuff(options = {}) {
|
|
43
|
+
let vrm;
|
|
44
|
+
function setVrm(vrmToUse) {
|
|
45
|
+
assert(!vrm, 'vrm already configured');
|
|
46
|
+
vrmToUse.initializeIDCounters();
|
|
47
|
+
vrm = vrmToUse;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
fakeStore = new Map(),
|
|
52
|
+
weak = false,
|
|
53
|
+
log,
|
|
54
|
+
FinalizationRegistry = FakeFinalizationRegistry,
|
|
55
|
+
WeakRef = FakeWeakRef, // VRM uses this
|
|
56
|
+
WeakMap = RealWeakMap,
|
|
57
|
+
WeakSet = RealWeakSet,
|
|
58
|
+
addToPossiblyDeadSet = () => {},
|
|
59
|
+
addToPossiblyRetiredSet = () => {},
|
|
60
|
+
} = options;
|
|
61
|
+
|
|
62
|
+
let sortedKeys;
|
|
63
|
+
let priorKeyReturned;
|
|
64
|
+
let priorKeyIndex;
|
|
65
|
+
|
|
66
|
+
function s(v) {
|
|
67
|
+
switch (typeof v) {
|
|
68
|
+
case 'symbol':
|
|
69
|
+
return v.toString();
|
|
70
|
+
case 'bigint':
|
|
71
|
+
return `${v}n`;
|
|
72
|
+
default:
|
|
73
|
+
return `${v}`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function ensureSorted() {
|
|
78
|
+
if (!sortedKeys) {
|
|
79
|
+
sortedKeys = [];
|
|
80
|
+
for (const key of fakeStore.keys()) {
|
|
81
|
+
sortedKeys.push(key);
|
|
82
|
+
}
|
|
83
|
+
sortedKeys.sort((k1, k2) => k1.localeCompare(k2));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function clearGetNextKeyCache() {
|
|
88
|
+
priorKeyReturned = undefined;
|
|
89
|
+
priorKeyIndex = -1;
|
|
90
|
+
}
|
|
91
|
+
clearGetNextKeyCache();
|
|
92
|
+
|
|
93
|
+
function clearSorted() {
|
|
94
|
+
sortedKeys = undefined;
|
|
95
|
+
clearGetNextKeyCache();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function dumpStore() {
|
|
99
|
+
ensureSorted();
|
|
100
|
+
const result = [];
|
|
101
|
+
for (const key of sortedKeys) {
|
|
102
|
+
result.push([key, fakeStore.get(key)]);
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const syscall = {
|
|
108
|
+
vatstoreGet(key) {
|
|
109
|
+
const result = fakeStore.get(key);
|
|
110
|
+
if (log) {
|
|
111
|
+
log.push(`get ${s(key)} => ${s(result)}`);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
},
|
|
115
|
+
vatstoreGetNextKey(priorKey) {
|
|
116
|
+
assert.typeof(priorKey, 'string');
|
|
117
|
+
ensureSorted();
|
|
118
|
+
// TODO: binary search for priorKey (maybe missing), then get
|
|
119
|
+
// the one after that. For now we go simple and slow. But cache
|
|
120
|
+
// a starting point, because the main use case is a full
|
|
121
|
+
// iteration. OTOH, the main use case also deletes everything,
|
|
122
|
+
// which will clobber the cache on each deletion, so it might
|
|
123
|
+
// not help.
|
|
124
|
+
const start = priorKeyReturned === priorKey ? priorKeyIndex : 0;
|
|
125
|
+
let result;
|
|
126
|
+
for (let i = start; i < sortedKeys.length; i += 1) {
|
|
127
|
+
const key = sortedKeys[i];
|
|
128
|
+
if (key > priorKey) {
|
|
129
|
+
priorKeyReturned = key;
|
|
130
|
+
priorKeyIndex = i;
|
|
131
|
+
result = key;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!result) {
|
|
136
|
+
// reached end without finding the key, so clear our cache
|
|
137
|
+
clearGetNextKeyCache();
|
|
138
|
+
}
|
|
139
|
+
if (log) {
|
|
140
|
+
log.push(`getNextKey ${s(priorKey)} => ${s(result)}`);
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
},
|
|
144
|
+
vatstoreSet(key, value) {
|
|
145
|
+
if (log) {
|
|
146
|
+
log.push(`set ${s(key)} ${s(value)}`);
|
|
147
|
+
}
|
|
148
|
+
if (!fakeStore.has(key)) {
|
|
149
|
+
clearSorted();
|
|
150
|
+
}
|
|
151
|
+
fakeStore.set(key, value);
|
|
152
|
+
},
|
|
153
|
+
vatstoreDelete(key) {
|
|
154
|
+
if (log) {
|
|
155
|
+
log.push(`delete ${s(key)}`);
|
|
156
|
+
}
|
|
157
|
+
if (fakeStore.has(key)) {
|
|
158
|
+
clearSorted();
|
|
159
|
+
}
|
|
160
|
+
fakeStore.delete(key);
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
function allocateExportID() {
|
|
165
|
+
return vrm.allocateNextID('exportID');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function allocatePromiseID() {
|
|
169
|
+
return vrm.allocateNextID('promiseID');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function allocateCollectionID() {
|
|
173
|
+
return vrm.allocateNextID('collectionID');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// note: The real liveslots slotToVal() maps slots (vrefs) to a WeakRef,
|
|
177
|
+
// and the WeakRef may or may not contain the target value. Use
|
|
178
|
+
// options={weak:true} to match that behavior, or the default weak:false to
|
|
179
|
+
// keep strong references.
|
|
180
|
+
const WeakRefForSlot = weak ? RealWeakRef : FakeWeakRef;
|
|
181
|
+
const valToSlot = new WeakMap();
|
|
182
|
+
const slotToVal = new Map();
|
|
183
|
+
|
|
184
|
+
function getSlotForVal(val) {
|
|
185
|
+
return valToSlot.get(val);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function getValForSlot(slot) {
|
|
189
|
+
const d = slotToVal.get(slot);
|
|
190
|
+
return d && d.deref();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function requiredValForSlot(slot) {
|
|
194
|
+
const val = getValForSlot(slot);
|
|
195
|
+
assert(val, `${slot} must have a value`);
|
|
196
|
+
return val;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function setValForSlot(slot, val) {
|
|
200
|
+
slotToVal.set(slot, new WeakRefForSlot(val));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function convertValToSlot(val) {
|
|
204
|
+
if (!valToSlot.has(val)) {
|
|
205
|
+
const slot = isPromise(val)
|
|
206
|
+
? `p+${allocatePromiseID()}`
|
|
207
|
+
: `o+${allocateExportID()}`;
|
|
208
|
+
valToSlot.set(val, slot);
|
|
209
|
+
setValForSlot(slot, val);
|
|
210
|
+
}
|
|
211
|
+
return valToSlot.get(val);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function convertSlotToVal(slot) {
|
|
215
|
+
const { type, id, virtual, durable, facet, baseRef } = parseVatSlot(slot);
|
|
216
|
+
assert.equal(type, 'object');
|
|
217
|
+
let val = getValForSlot(baseRef);
|
|
218
|
+
if (val) {
|
|
219
|
+
if (virtual || durable) {
|
|
220
|
+
if (facet !== undefined) {
|
|
221
|
+
return vrm.getFacet(id, val, facet);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return val;
|
|
225
|
+
}
|
|
226
|
+
let result;
|
|
227
|
+
if (virtual || durable) {
|
|
228
|
+
if (vrm) {
|
|
229
|
+
val = vrm.reanimate(slot);
|
|
230
|
+
if (facet !== undefined) {
|
|
231
|
+
result = vrm.getFacet(id, val, facet);
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
assert.fail('fake liveSlots stuff configured without vrm');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
registerEntry(baseRef, val, facet !== undefined);
|
|
238
|
+
if (!result) {
|
|
239
|
+
result = val;
|
|
240
|
+
}
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const marshal = makeMarshal(convertValToSlot, convertSlotToVal, {
|
|
245
|
+
serializeBodyFormat: 'smallcaps',
|
|
246
|
+
marshalName: 'fakeLiveSlots',
|
|
247
|
+
errorIdNum: 80_000,
|
|
248
|
+
marshalSaveError: _err => {},
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
function registerEntry(baseRef, val, valIsCohort) {
|
|
252
|
+
const { facet } = parseVatSlot(baseRef);
|
|
253
|
+
!facet ||
|
|
254
|
+
Fail`registerEntry(${baseRef} should not receive individual facets`;
|
|
255
|
+
setValForSlot(baseRef, val);
|
|
256
|
+
if (valIsCohort) {
|
|
257
|
+
const { id } = parseVatSlot(baseRef);
|
|
258
|
+
for (const [index, name] of vrm.getFacetNames(id).entries()) {
|
|
259
|
+
valToSlot.set(val[name], `${baseRef}:${index}`);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
valToSlot.set(val, baseRef);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function deleteEntry(slot, val) {
|
|
267
|
+
if (!val) {
|
|
268
|
+
val = getValForSlot(slot);
|
|
269
|
+
}
|
|
270
|
+
slotToVal.delete(slot);
|
|
271
|
+
valToSlot.delete(val);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function assertAcceptableSyscallCapdataSize(_capdatas) {}
|
|
275
|
+
|
|
276
|
+
const maybeExportPromise = _vref => false;
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
syscall,
|
|
280
|
+
allocateExportID,
|
|
281
|
+
allocatePromiseID,
|
|
282
|
+
allocateCollectionID,
|
|
283
|
+
getSlotForVal,
|
|
284
|
+
requiredValForSlot,
|
|
285
|
+
getValForSlot,
|
|
286
|
+
setValForSlot,
|
|
287
|
+
registerEntry,
|
|
288
|
+
valToSlot,
|
|
289
|
+
slotToVal,
|
|
290
|
+
convertValToSlot,
|
|
291
|
+
convertSlotToVal,
|
|
292
|
+
marshal,
|
|
293
|
+
deleteEntry,
|
|
294
|
+
FinalizationRegistry,
|
|
295
|
+
WeakRef,
|
|
296
|
+
WeakMap,
|
|
297
|
+
WeakSet,
|
|
298
|
+
addToPossiblyDeadSet,
|
|
299
|
+
addToPossiblyRetiredSet,
|
|
300
|
+
dumpStore,
|
|
301
|
+
setVrm,
|
|
302
|
+
assertAcceptableSyscallCapdataSize,
|
|
303
|
+
maybeExportPromise,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function makeFakeVirtualReferenceManager(
|
|
308
|
+
fakeStuff,
|
|
309
|
+
relaxDurabilityRules = true,
|
|
310
|
+
) {
|
|
311
|
+
return makeVirtualReferenceManager(
|
|
312
|
+
fakeStuff.syscall,
|
|
313
|
+
fakeStuff.getSlotForVal,
|
|
314
|
+
fakeStuff.getValForSlot,
|
|
315
|
+
fakeStuff.FinalizationRegistry,
|
|
316
|
+
fakeStuff.WeakRef,
|
|
317
|
+
fakeStuff.addToPossiblyDeadSet,
|
|
318
|
+
fakeStuff.addToPossiblyRetiredSet,
|
|
319
|
+
relaxDurabilityRules,
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function makeFakeWatchedPromiseManager(
|
|
324
|
+
vrm,
|
|
325
|
+
vom,
|
|
326
|
+
collectionManager,
|
|
327
|
+
fakeStuff,
|
|
328
|
+
) {
|
|
329
|
+
return makeWatchedPromiseManager({
|
|
330
|
+
syscall: fakeStuff.syscall,
|
|
331
|
+
vrm,
|
|
332
|
+
vom,
|
|
333
|
+
collectionManager,
|
|
334
|
+
convertValToSlot: fakeStuff.convertValToSlot,
|
|
335
|
+
convertSlotToVal: fakeStuff.convertSlotToVal,
|
|
336
|
+
maybeExportPromise: fakeStuff.maybeExportPromise,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Configure virtual stuff with relaxed durability rules and fake liveslots
|
|
342
|
+
*
|
|
343
|
+
* @param {object} [options]
|
|
344
|
+
* @param {number} [options.cacheSize]
|
|
345
|
+
* @param {boolean} [options.relaxDurabilityRules]
|
|
346
|
+
* @param {Map<string, string>} [options.fakeStore]
|
|
347
|
+
* @param {WeakMapConstructor} [options.WeakMap]
|
|
348
|
+
* @param {WeakSetConstructor} [options.WeakSet]
|
|
349
|
+
* @param {boolean} [options.weak]
|
|
350
|
+
*/
|
|
351
|
+
export function makeFakeVirtualStuff(options = {}) {
|
|
352
|
+
const actualOptions = {
|
|
353
|
+
relaxDurabilityRules: true,
|
|
354
|
+
...options,
|
|
355
|
+
};
|
|
356
|
+
const { relaxDurabilityRules } = actualOptions;
|
|
357
|
+
const fakeStuff = makeFakeLiveSlotsStuff(actualOptions);
|
|
358
|
+
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
359
|
+
fakeStuff.setVrm(vrm);
|
|
360
|
+
const vom = makeFakeVirtualObjectManager(vrm, fakeStuff);
|
|
361
|
+
vom.initializeKindHandleKind();
|
|
362
|
+
const cm = makeFakeCollectionManager(vrm, fakeStuff, actualOptions);
|
|
363
|
+
const wpm = makeFakeWatchedPromiseManager(vrm, vom, cm, fakeStuff);
|
|
364
|
+
wpm.preparePromiseWatcherTables();
|
|
365
|
+
return { fakeStuff, vrm, vom, cm, wpm };
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export function makeStandaloneFakeVirtualObjectManager(options = {}) {
|
|
369
|
+
const fakeStuff = makeFakeLiveSlotsStuff(options);
|
|
370
|
+
const { relaxDurabilityRules = true } = options;
|
|
371
|
+
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
372
|
+
fakeStuff.setVrm(vrm);
|
|
373
|
+
const vom = makeFakeVirtualObjectManager(vrm, fakeStuff);
|
|
374
|
+
vom.initializeKindHandleKind();
|
|
375
|
+
return vom;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export function makeStandaloneFakeCollectionManager(options = {}) {
|
|
379
|
+
const fakeStuff = makeFakeLiveSlotsStuff(options);
|
|
380
|
+
const { relaxDurabilityRules = true } = options;
|
|
381
|
+
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
382
|
+
fakeStuff.setVrm(vrm);
|
|
383
|
+
return makeFakeCollectionManager(vrm, fakeStuff, options);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export {
|
|
387
|
+
makeStandaloneFakeVirtualObjectManager as makeFakeVirtualObjectManager,
|
|
388
|
+
makeStandaloneFakeCollectionManager as makeFakeCollectionManager,
|
|
389
|
+
};
|