@agoric/swingset-liveslots 0.10.3-dev-5dc325b.0 → 0.10.3-getting-started-dev-26244e8.0
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/CHANGELOG.md +77 -0
- package/package.json +17 -23
- package/src/collectionManager.js +66 -135
- package/src/index.js +1 -2
- package/src/liveslots.js +74 -47
- package/src/virtualObjectManager.js +15 -61
- package/src/virtualReferences.js +0 -51
- package/src/watchedPromises.js +0 -6
- package/test/gc-helpers.js +1 -1
- package/test/kmarshal.js +79 -0
- package/test/liveslots-helpers.js +6 -6
- package/test/mock-gc.js +0 -1
- package/test/storeGC/test-lifecycle.js +2 -2
- package/test/storeGC/test-refcount-management.js +2 -1
- package/test/storeGC/test-scalar-store-kind.js +1 -0
- package/test/storeGC/test-weak-key.js +2 -1
- package/test/test-baggage.js +2 -1
- package/test/test-cache.js +1 -0
- package/test/test-collection-schema-refcount.js +2 -1
- package/test/test-collection-upgrade.js +3 -1
- package/test/test-collections.js +14 -117
- package/test/test-dropped-collection-weakrefs.js +2 -1
- package/test/test-durabilityChecks.js +3 -3
- package/test/test-facetiousness.js +2 -1
- package/test/test-gc-sensitivity.js +2 -2
- package/test/test-handled-promises.js +7 -5
- package/test/test-initial-vrefs.js +3 -2
- package/test/test-liveslots-mock-gc.js +2 -2
- package/test/test-liveslots-real-gc.js +2 -2
- package/test/test-liveslots.js +14 -13
- package/test/test-vo-test-harness.js +1 -0
- package/test/test-vpid-liveslots.js +4 -3
- package/test/util.js +2 -2
- package/test/vat-util.js +1 -1
- package/test/virtual-objects/test-cease-recognition.js +2 -2
- package/test/virtual-objects/test-cross-facet.js +2 -1
- package/test/virtual-objects/test-empty-data.js +2 -1
- package/test/virtual-objects/test-facets.js +2 -1
- package/test/virtual-objects/test-kind-changes.js +2 -2
- package/test/virtual-objects/test-reachable-vrefs.js +2 -2
- package/test/virtual-objects/test-rep-tostring.js +3 -2
- package/test/virtual-objects/test-retain-remotable.js +1 -1
- package/test/virtual-objects/test-state-shape.js +2 -2
- package/test/virtual-objects/test-virtualObjectGC.js +2 -2
- package/test/virtual-objects/test-virtualObjectManager.js +2 -6
- package/test/virtual-objects/test-vo-real-gc.js +2 -2
- package/test/virtual-objects/test-weakcollections-vref-handling.js +2 -1
- package/tools/fakeVirtualSupport.js +19 -37
- package/src/vatDataTypes.d.ts +0 -234
- package/src/vatDataTypes.js +0 -2
- package/tools/prepare-test-env.js +0 -13
- package/tools/setup-vat-data.js +0 -61
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
+
import '@endo/init/debug.js';
|
|
2
3
|
// this sets process.env.DEBUG = 'label-instances'
|
|
3
4
|
import './set-debug-label-instances.js';
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ const init = () => ({});
|
|
|
15
16
|
const behavior = {};
|
|
16
17
|
const facets = { foo: {}, bar: {} };
|
|
17
18
|
|
|
18
|
-
test('representatives with label-instances', t => {
|
|
19
|
+
test('representatives with label-instances', async t => {
|
|
19
20
|
const { fakeStuff, vom } = makeFakeVirtualStuff();
|
|
20
21
|
const { getSlotForVal } = fakeStuff;
|
|
21
22
|
const makeThing = vom.defineKind('thing', init, behavior);
|
|
@@ -32,7 +33,7 @@ test('representatives with label-instances', t => {
|
|
|
32
33
|
t.is(`${q(thing2)}`, `"[Alleged: thing#${thing2vref}]"`);
|
|
33
34
|
});
|
|
34
35
|
|
|
35
|
-
test('facets with label-instances', t => {
|
|
36
|
+
test('facets with label-instances', async t => {
|
|
36
37
|
const { fakeStuff, vom } = makeFakeVirtualStuff();
|
|
37
38
|
const { getSlotForVal } = fakeStuff;
|
|
38
39
|
const makeThings = vom.defineKindMulti('thing', init, facets);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
2
|
+
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
4
|
import { Far } from '@endo/marshal';
|
|
5
|
-
import { kser, kslot } from '@agoric/kmarshal';
|
|
6
5
|
import { M } from '@agoric/store';
|
|
7
6
|
import { makeLiveSlots } from '../../src/liveslots.js';
|
|
7
|
+
import { kser, kslot } from '../kmarshal.js';
|
|
8
8
|
import { buildSyscall } from '../liveslots-helpers.js';
|
|
9
9
|
import { makeStartVat, makeMessage } from '../util.js';
|
|
10
10
|
import { makeMockGC } from '../mock-gc.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
2
|
+
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
4
|
import { Far } from '@endo/marshal';
|
|
5
|
-
import { krefOf, kser, kslot } from '@agoric/kmarshal';
|
|
6
5
|
import {
|
|
7
6
|
setupTestLiveslots,
|
|
8
7
|
findSyscallsByType,
|
|
9
8
|
} from '../liveslots-helpers.js';
|
|
9
|
+
import { krefOf, kser, kslot } from '../kmarshal.js';
|
|
10
10
|
import { parseVatSlot } from '../../src/parseVatSlots.js';
|
|
11
11
|
|
|
12
12
|
// Legs:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
2
|
+
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
|
-
import { kser, kslot } from '@agoric/kmarshal';
|
|
5
4
|
import {
|
|
6
5
|
makeFakeVirtualObjectManager,
|
|
7
6
|
makeFakeVirtualStuff,
|
|
8
7
|
} from '../../tools/fakeVirtualSupport.js';
|
|
9
8
|
|
|
9
|
+
import { kser, kslot } from '../kmarshal.js';
|
|
10
10
|
import { vstr } from '../util.js';
|
|
11
11
|
|
|
12
12
|
function initThing(label = 'thing', counter = 0) {
|
|
@@ -128,7 +128,6 @@ test('multifaceted virtual objects', t => {
|
|
|
128
128
|
flushStateCache();
|
|
129
129
|
t.deepEqual(log.splice(0), [
|
|
130
130
|
`get kindIDID => undefined`,
|
|
131
|
-
`get idCounters => undefined`,
|
|
132
131
|
`set kindIDID 1`,
|
|
133
132
|
`set vom.vkind.2.descriptor {"kindID":"2","tag":"multithing"}`,
|
|
134
133
|
`set vom.${kid}/1 ${multiThingVal('foo', 1)}`,
|
|
@@ -204,7 +203,6 @@ test('virtual object operations', t => {
|
|
|
204
203
|
const thing4 = makeThing('thing-4', 300); // [t4-0* t3-0* t2-0* t1-0*]
|
|
205
204
|
// t4-0: 'thing-4' 300 0
|
|
206
205
|
t.is(log.shift(), `get kindIDID => undefined`);
|
|
207
|
-
t.is(log.shift(), `get idCounters => undefined`);
|
|
208
206
|
t.is(log.shift(), `set kindIDID 1`);
|
|
209
207
|
t.is(log.shift(), `set vom.vkind.2.descriptor {"kindID":"2","tag":"thing"}`);
|
|
210
208
|
t.is(log.shift(), `set vom.vkind.3.descriptor {"kindID":"3","tag":"zot"}`);
|
|
@@ -469,7 +467,6 @@ test('symbol named methods', t => {
|
|
|
469
467
|
const thing2 = makeThing('thing-2', 100); // [t1-0* t2-0*]
|
|
470
468
|
// t2-0: 'thing-2' 100 0
|
|
471
469
|
t.is(log.shift(), `get kindIDID => undefined`);
|
|
472
|
-
t.is(log.shift(), `get idCounters => undefined`);
|
|
473
470
|
t.is(log.shift(), `set kindIDID 1`);
|
|
474
471
|
t.is(
|
|
475
472
|
log.shift(),
|
|
@@ -650,7 +647,6 @@ test('virtual object gc', t => {
|
|
|
650
647
|
});
|
|
651
648
|
|
|
652
649
|
t.is(log.shift(), `get kindIDID => undefined`);
|
|
653
|
-
t.is(log.shift(), `get idCounters => undefined`);
|
|
654
650
|
t.is(log.shift(), `set kindIDID 1`);
|
|
655
651
|
const skit = [
|
|
656
652
|
'storeKindIDTable',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/* global WeakRef */
|
|
3
2
|
import test from 'ava';
|
|
3
|
+
import '@endo/init/debug.js';
|
|
4
4
|
|
|
5
5
|
import { Far } from '@endo/marshal';
|
|
6
|
-
import { kser, kunser } from '
|
|
6
|
+
import { kser, kunser } from '../kmarshal.js';
|
|
7
7
|
import { setupTestLiveslots } from '../liveslots-helpers.js';
|
|
8
8
|
|
|
9
9
|
test('virtual object state writes', async t => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
+
import '@endo/init/debug.js';
|
|
2
3
|
|
|
3
4
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
4
5
|
|
|
5
|
-
test('weakMap vref handling', t => {
|
|
6
|
+
test('weakMap vref handling', async t => {
|
|
6
7
|
const log = [];
|
|
7
8
|
const {
|
|
8
9
|
VirtualObjectAwareWeakMap,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global
|
|
1
|
+
/* global WeakRef */
|
|
2
2
|
/* eslint-disable max-classes-per-file */
|
|
3
3
|
import { makeMarshal } from '@endo/marshal';
|
|
4
4
|
import { assert } from '@agoric/assert';
|
|
@@ -9,14 +9,6 @@ import { makeWatchedPromiseManager } from '../src/watchedPromises.js';
|
|
|
9
9
|
import { makeFakeVirtualObjectManager } from './fakeVirtualObjectManager.js';
|
|
10
10
|
import { makeFakeCollectionManager } from './fakeCollectionManager.js';
|
|
11
11
|
|
|
12
|
-
const { Fail } = assert;
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
WeakRef: RealWeakRef,
|
|
16
|
-
WeakMap: RealWeakMap,
|
|
17
|
-
WeakSet: RealWeakSet,
|
|
18
|
-
} = globalThis;
|
|
19
|
-
|
|
20
12
|
class FakeFinalizationRegistry {
|
|
21
13
|
// eslint-disable-next-line no-useless-constructor, no-empty-function
|
|
22
14
|
constructor() {}
|
|
@@ -38,6 +30,8 @@ class FakeWeakRef {
|
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
32
|
|
|
33
|
+
const RealWeakRef = WeakRef;
|
|
34
|
+
|
|
41
35
|
export function makeFakeLiveSlotsStuff(options = {}) {
|
|
42
36
|
let vrm;
|
|
43
37
|
function setVrm(vrmToUse) {
|
|
@@ -51,8 +45,6 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
51
45
|
log,
|
|
52
46
|
FinalizationRegistry = FakeFinalizationRegistry,
|
|
53
47
|
WeakRef = FakeWeakRef, // VRM uses this
|
|
54
|
-
WeakMap = RealWeakMap,
|
|
55
|
-
WeakSet = RealWeakSet,
|
|
56
48
|
addToPossiblyDeadSet = () => {},
|
|
57
49
|
addToPossiblyRetiredSet = () => {},
|
|
58
50
|
} = options;
|
|
@@ -159,12 +151,18 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
159
151
|
},
|
|
160
152
|
};
|
|
161
153
|
|
|
154
|
+
let nextExportID = 1;
|
|
162
155
|
function allocateExportID() {
|
|
163
|
-
|
|
156
|
+
const exportID = nextExportID;
|
|
157
|
+
nextExportID += 1;
|
|
158
|
+
return exportID;
|
|
164
159
|
}
|
|
165
160
|
|
|
161
|
+
let nextCollectionID = 1;
|
|
166
162
|
function allocateCollectionID() {
|
|
167
|
-
|
|
163
|
+
const collectionID = nextCollectionID;
|
|
164
|
+
nextCollectionID += 1;
|
|
165
|
+
return collectionID;
|
|
168
166
|
}
|
|
169
167
|
|
|
170
168
|
// note: The real liveslots slotToVal() maps slots (vrefs) to a WeakRef,
|
|
@@ -214,23 +212,17 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
214
212
|
}
|
|
215
213
|
return val;
|
|
216
214
|
}
|
|
217
|
-
let result;
|
|
218
215
|
if (virtual || durable) {
|
|
219
216
|
if (vrm) {
|
|
220
217
|
val = vrm.reanimate(slot);
|
|
221
218
|
if (facet !== undefined) {
|
|
222
|
-
|
|
219
|
+
return vrm.getFacet(id, val, facet);
|
|
223
220
|
}
|
|
224
221
|
} else {
|
|
225
222
|
assert.fail('fake liveSlots stuff configured without vrm');
|
|
226
223
|
}
|
|
227
224
|
}
|
|
228
|
-
|
|
229
|
-
registerEntry(baseRef, val, facet !== undefined);
|
|
230
|
-
if (!result) {
|
|
231
|
-
result = val;
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
225
|
+
return val;
|
|
234
226
|
}
|
|
235
227
|
|
|
236
228
|
const marshal = makeMarshal(convertValToSlot, convertSlotToVal, {
|
|
@@ -238,15 +230,12 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
238
230
|
});
|
|
239
231
|
|
|
240
232
|
function registerEntry(baseRef, val, valIsCohort) {
|
|
241
|
-
const { facet } = parseVatSlot(baseRef);
|
|
242
|
-
!facet ||
|
|
243
|
-
Fail`registerEntry(${baseRef} should not receive individual facets`;
|
|
244
233
|
setValForSlot(baseRef, val);
|
|
245
234
|
if (valIsCohort) {
|
|
246
235
|
const { id } = parseVatSlot(baseRef);
|
|
247
|
-
|
|
236
|
+
vrm.getFacetNames(id).forEach((name, index) => {
|
|
248
237
|
valToSlot.set(val[name], `${baseRef}:${index}`);
|
|
249
|
-
}
|
|
238
|
+
});
|
|
250
239
|
} else {
|
|
251
240
|
valToSlot.set(val, baseRef);
|
|
252
241
|
}
|
|
@@ -281,8 +270,6 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
281
270
|
deleteEntry,
|
|
282
271
|
FinalizationRegistry,
|
|
283
272
|
WeakRef,
|
|
284
|
-
WeakMap,
|
|
285
|
-
WeakSet,
|
|
286
273
|
addToPossiblyDeadSet,
|
|
287
274
|
addToPossiblyRetiredSet,
|
|
288
275
|
dumpStore,
|
|
@@ -328,12 +315,8 @@ export function makeFakeWatchedPromiseManager(
|
|
|
328
315
|
* Configure virtual stuff with relaxed durability rules and fake liveslots
|
|
329
316
|
*
|
|
330
317
|
* @param {object} [options]
|
|
331
|
-
* @param {number} [options.cacheSize]
|
|
332
|
-
* @param {boolean} [options.relaxDurabilityRules]
|
|
333
|
-
* @param {Map<any, any>} [options.fakeStore]
|
|
334
|
-
* @param {WeakMapConstructor} [options.WeakMap]
|
|
335
|
-
* @param {WeakSetConstructor} [options.WeakSet]
|
|
336
|
-
* @param {boolean} [options.weak]
|
|
318
|
+
* @param {number} [options.cacheSize=3]
|
|
319
|
+
* @param {boolean} [options.relaxDurabilityRules=true]
|
|
337
320
|
*/
|
|
338
321
|
export function makeFakeVirtualStuff(options = {}) {
|
|
339
322
|
const actualOptions = {
|
|
@@ -343,9 +326,9 @@ export function makeFakeVirtualStuff(options = {}) {
|
|
|
343
326
|
const { relaxDurabilityRules } = actualOptions;
|
|
344
327
|
const fakeStuff = makeFakeLiveSlotsStuff(actualOptions);
|
|
345
328
|
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
346
|
-
fakeStuff.setVrm(vrm);
|
|
347
329
|
const vom = makeFakeVirtualObjectManager(vrm, fakeStuff);
|
|
348
330
|
vom.initializeKindHandleKind();
|
|
331
|
+
fakeStuff.setVrm(vrm);
|
|
349
332
|
const cm = makeFakeCollectionManager(vrm, fakeStuff, actualOptions);
|
|
350
333
|
const wpm = makeFakeWatchedPromiseManager(vrm, vom, cm, fakeStuff);
|
|
351
334
|
return { fakeStuff, vrm, vom, cm, wpm };
|
|
@@ -355,9 +338,9 @@ export function makeStandaloneFakeVirtualObjectManager(options = {}) {
|
|
|
355
338
|
const fakeStuff = makeFakeLiveSlotsStuff(options);
|
|
356
339
|
const { relaxDurabilityRules = true } = options;
|
|
357
340
|
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
358
|
-
fakeStuff.setVrm(vrm);
|
|
359
341
|
const vom = makeFakeVirtualObjectManager(vrm, fakeStuff);
|
|
360
342
|
vom.initializeKindHandleKind();
|
|
343
|
+
fakeStuff.setVrm(vrm);
|
|
361
344
|
return vom;
|
|
362
345
|
}
|
|
363
346
|
|
|
@@ -365,7 +348,6 @@ export function makeStandaloneFakeCollectionManager(options = {}) {
|
|
|
365
348
|
const fakeStuff = makeFakeLiveSlotsStuff(options);
|
|
366
349
|
const { relaxDurabilityRules = true } = options;
|
|
367
350
|
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
368
|
-
fakeStuff.setVrm(vrm);
|
|
369
351
|
return makeFakeCollectionManager(vrm, fakeStuff, options);
|
|
370
352
|
}
|
|
371
353
|
|
package/src/vatDataTypes.d.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Types for vat-data
|
|
3
|
-
*
|
|
4
|
-
* Facet is a single object with methods.
|
|
5
|
-
* Behavior is a description when defining a kind of what facets it will have.
|
|
6
|
-
* For the non-multi defineKind, there is just one facet so it doesn't have a key.
|
|
7
|
-
*/
|
|
8
|
-
import type { InterfaceGuard, Pattern } from '@endo/patterns';
|
|
9
|
-
import type {
|
|
10
|
-
MapStore,
|
|
11
|
-
SetStore,
|
|
12
|
-
StoreOptions,
|
|
13
|
-
WeakMapStore,
|
|
14
|
-
WeakSetStore,
|
|
15
|
-
} from '@agoric/store';
|
|
16
|
-
import type { makeWatchedPromiseManager } from './watchedPromises.js';
|
|
17
|
-
|
|
18
|
-
// TODO should be moved into @endo/patterns and eventually imported here
|
|
19
|
-
// instead of this local definition.
|
|
20
|
-
export type InterfaceGuardKit = Record<string, InterfaceGuard>;
|
|
21
|
-
|
|
22
|
-
export type { MapStore, Pattern };
|
|
23
|
-
|
|
24
|
-
// This needs `any` values. If they were `unknown`, code that uses Baggage
|
|
25
|
-
// would need explicit runtime checks or casts for every fetch, which is
|
|
26
|
-
// onerous.
|
|
27
|
-
export type Baggage = MapStore<string, any>;
|
|
28
|
-
|
|
29
|
-
type WatchedPromisesManager = ReturnType<typeof makeWatchedPromiseManager>;
|
|
30
|
-
|
|
31
|
-
type Tail<T extends any[]> = T extends [head: any, ...rest: infer Rest]
|
|
32
|
-
? Rest
|
|
33
|
-
: [];
|
|
34
|
-
|
|
35
|
-
// used to omit the 'context' parameter
|
|
36
|
-
type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R
|
|
37
|
-
? (...args: P) => R
|
|
38
|
-
: never;
|
|
39
|
-
|
|
40
|
-
export type KindFacet<O> = {
|
|
41
|
-
[K in keyof O]: OmitFirstArg<O[K]>; // omit the 'context' parameter
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type KindFacets<B> = {
|
|
45
|
-
[FacetKey in keyof B]: KindFacet<B[FacetKey]>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export type KindContext<S, F> = { state: S; self: KindFacet<F> };
|
|
49
|
-
export type MultiKindContext<S, B> = { state: S; facets: KindFacets<B> };
|
|
50
|
-
|
|
51
|
-
export type PlusContext<C, M> = (c: C, ...args: Parameters<M>) => ReturnType<M>;
|
|
52
|
-
export type FunctionsPlusContext<C, O> = {
|
|
53
|
-
[K in keyof O]: PlusContext<C, O[K]>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
declare class DurableKindHandleClass {
|
|
57
|
-
private descriptionTag: string;
|
|
58
|
-
}
|
|
59
|
-
export type DurableKindHandle = DurableKindHandleClass;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Grab bag of options that can be provided to `defineDurableKind` and its
|
|
63
|
-
* siblings. Not all options are meaningful in all contexts. See the
|
|
64
|
-
* doc-comments on each option.
|
|
65
|
-
*/
|
|
66
|
-
export type DefineKindOptions<C> = {
|
|
67
|
-
/**
|
|
68
|
-
* If provided, the `finish` function will be called after the instance is
|
|
69
|
-
* made and internally registered, but before it is returned. The finish
|
|
70
|
-
* function is to do any post-intantiation initialization that should be
|
|
71
|
-
* done before exposing the object to its clients.
|
|
72
|
-
*/
|
|
73
|
-
finish?: (context: C) => void;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Meaningful to `makeScalarBigMapStore` and its siblings. These maker
|
|
77
|
-
* fuctions will make either virtual or durable stores, depending on
|
|
78
|
-
* this flag. Defaults to off, making virtual but not durable collections.
|
|
79
|
-
*
|
|
80
|
-
* Generally, durable collections are provided with `provideDurableMapStore`
|
|
81
|
-
* and its sibling, which use this flag internally. If you do not make
|
|
82
|
-
* durable collections by other means, you can consider this as
|
|
83
|
-
* intended for internal use only.
|
|
84
|
-
*/
|
|
85
|
-
durable?: boolean;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* If provided, it describes the shape of all state records of instances
|
|
89
|
-
* of this kind.
|
|
90
|
-
*/
|
|
91
|
-
stateShape?: { [name: string]: Pattern };
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Intended for internal use only.
|
|
95
|
-
* Should the raw methods receive their `context` argument as their first
|
|
96
|
-
* argument or as their `this` binding? For `defineDurableKind` and its
|
|
97
|
-
* siblings (including `prepareSingleton`), this defaults to off, meaning that
|
|
98
|
-
* their behavior methods receive `context` as their first argument.
|
|
99
|
-
* `prepareExoClass` and its siblings (including `prepareExo`) use
|
|
100
|
-
* this flag internally to indicate that their methods receive `context`
|
|
101
|
-
* as their `this` binding.
|
|
102
|
-
*/
|
|
103
|
-
thisfulMethods?: boolean;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Intended for internal use only.
|
|
107
|
-
* Only applicable if this is a class kind. A class kit kind should use
|
|
108
|
-
* `interfaceGuardKit` instead.
|
|
109
|
-
*
|
|
110
|
-
* If an `interfaceGuard` is provided, then the raw methods passed alongside
|
|
111
|
-
* it are wrapped by a function that first checks that this method's guard
|
|
112
|
-
* pattern is satisfied before calling the raw method.
|
|
113
|
-
*
|
|
114
|
-
* In `defineDurableKind` and its siblings, this defaults to `undefined`.
|
|
115
|
-
* Exo classes use this internally to protect their raw class methods
|
|
116
|
-
* using the provided interface.
|
|
117
|
-
* In absence, an exo is protected anyway, while a bare kind is
|
|
118
|
-
* not (detected by `!thisfulMethods`),
|
|
119
|
-
*/
|
|
120
|
-
interfaceGuard?: InterfaceGuard;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Intended for internal use only.
|
|
124
|
-
* Only applicable if this is a class kit kind. A class kind should use
|
|
125
|
-
* `interfaceGuard` instead.
|
|
126
|
-
*
|
|
127
|
-
* If an `interfaceGuardKit` is provided, then each member of the
|
|
128
|
-
* interfaceGuardKit is used to guard the corresponding facet of the
|
|
129
|
-
* class kit.
|
|
130
|
-
*
|
|
131
|
-
* In `defineDurableKindMulti` and its siblings, this defaults to `undefined`.
|
|
132
|
-
* Exo class kits use this internally to protect their facets.
|
|
133
|
-
* In absence, an exo is protected anyway, while a bare kind is
|
|
134
|
-
* not (detected by `!thisfulMethods`),
|
|
135
|
-
*/
|
|
136
|
-
interfaceGuardKit?: InterfaceGuardKit;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export type VatData = {
|
|
140
|
-
// virtual kinds
|
|
141
|
-
/** @deprecated Use defineVirtualExoClass instead */
|
|
142
|
-
defineKind: <P, S, F>(
|
|
143
|
-
tag: string,
|
|
144
|
-
init: (...args: P) => S,
|
|
145
|
-
facet: F,
|
|
146
|
-
options?: DefineKindOptions<KindContext<S, F>>,
|
|
147
|
-
) => (...args: P) => KindFacet<F>;
|
|
148
|
-
|
|
149
|
-
/** @deprecated Use defineVirtualExoClassKit instead */
|
|
150
|
-
defineKindMulti: <P, S, B>(
|
|
151
|
-
tag: string,
|
|
152
|
-
init: (...args: P) => S,
|
|
153
|
-
behavior: B,
|
|
154
|
-
options?: DefineKindOptions<MultiKindContext<S, B>>,
|
|
155
|
-
) => (...args: P) => KindFacets<B>;
|
|
156
|
-
|
|
157
|
-
// durable kinds
|
|
158
|
-
makeKindHandle: (descriptionTag: string) => DurableKindHandle;
|
|
159
|
-
|
|
160
|
-
/** @deprecated Use defineDurableExoClass instead */
|
|
161
|
-
defineDurableKind: <P, S, F>(
|
|
162
|
-
kindHandle: DurableKindHandle,
|
|
163
|
-
init: (...args: P) => S,
|
|
164
|
-
facet: F,
|
|
165
|
-
options?: DefineKindOptions<KindContext<S, F>>,
|
|
166
|
-
) => (...args: P) => KindFacet<F>;
|
|
167
|
-
|
|
168
|
-
/** @deprecated Use defineDurableExoClassKit instead */
|
|
169
|
-
defineDurableKindMulti: <P, S, B>(
|
|
170
|
-
kindHandle: DurableKindHandle,
|
|
171
|
-
init: (...args: P) => S,
|
|
172
|
-
behavior: B,
|
|
173
|
-
options?: DefineKindOptions<MultiKindContext<S, B>>,
|
|
174
|
-
) => (...args: P) => KindFacets<B>;
|
|
175
|
-
|
|
176
|
-
providePromiseWatcher: WatchedPromisesManager['providePromiseWatcher'];
|
|
177
|
-
watchPromise: WatchedPromisesManager['watchPromise'];
|
|
178
|
-
|
|
179
|
-
makeScalarBigMapStore: <K, V>(
|
|
180
|
-
label: string,
|
|
181
|
-
options?: StoreOptions,
|
|
182
|
-
) => MapStore<K, V>;
|
|
183
|
-
makeScalarBigWeakMapStore: <K, V>(
|
|
184
|
-
label: string,
|
|
185
|
-
options?: StoreOptions,
|
|
186
|
-
) => WeakMapStore<K, V>;
|
|
187
|
-
|
|
188
|
-
makeScalarBigSetStore: <K>(
|
|
189
|
-
label: string,
|
|
190
|
-
options?: StoreOptions,
|
|
191
|
-
) => SetStore<K>;
|
|
192
|
-
makeScalarBigWeakSetStore: <K>(
|
|
193
|
-
label: string,
|
|
194
|
-
options?: StoreOptions,
|
|
195
|
-
) => WeakSetStore<K>;
|
|
196
|
-
canBeDurable: (specimen: unknown) => boolean;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// The JSDoc is repeated here and at the function definition so it appears
|
|
200
|
-
// in IDEs where it's used, regardless of type resolution.
|
|
201
|
-
export interface PickFacet {
|
|
202
|
-
/**
|
|
203
|
-
* When making a multi-facet kind, it's common to pick one facet to
|
|
204
|
-
* expose. E.g.,
|
|
205
|
-
*
|
|
206
|
-
* const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self;
|
|
207
|
-
*
|
|
208
|
-
* This helper reduces the duplication:
|
|
209
|
-
*
|
|
210
|
-
* const makeFoo = pickFacet(makeFooBase, 'self');
|
|
211
|
-
*/
|
|
212
|
-
<M extends (...args: any[]) => any, F extends keyof ReturnType<M>>(
|
|
213
|
-
maker: M,
|
|
214
|
-
facetName: F,
|
|
215
|
-
): (...args: Parameters<M>) => ReturnType<M>[F];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** @deprecated Use prepareExoClass instead */
|
|
219
|
-
export type PrepareKind = <P, S, F>(
|
|
220
|
-
baggage: Baggage,
|
|
221
|
-
tag: string,
|
|
222
|
-
init: (...args: P) => S,
|
|
223
|
-
facet: F,
|
|
224
|
-
options?: DefineKindOptions<KindContext<S, F>>,
|
|
225
|
-
) => (...args: P) => KindFacet<F>;
|
|
226
|
-
|
|
227
|
-
/** @deprecated Use prepareExoClassKit instead */
|
|
228
|
-
export type PrepareKindMulti = <P, S, B>(
|
|
229
|
-
baggage: Baggage,
|
|
230
|
-
tag: string,
|
|
231
|
-
init: (...args: P) => S,
|
|
232
|
-
behavior: B,
|
|
233
|
-
options?: DefineKindOptions<MultiKindContext<S, B>>,
|
|
234
|
-
) => (...args: P) => KindFacets<B>;
|
package/src/vatDataTypes.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prepare Agoric SwingSet vat global environment for testing.
|
|
3
|
-
*
|
|
4
|
-
* Installs Hardened JS (and does lockdown), plus adds mocks for virtual objects
|
|
5
|
-
* and stores.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import '@agoric/internal/src/install-ses-debug.js';
|
|
9
|
-
|
|
10
|
-
import { reincarnate } from './setup-vat-data.js';
|
|
11
|
-
|
|
12
|
-
// Install the VatData globals.
|
|
13
|
-
reincarnate();
|
package/tools/setup-vat-data.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/* global globalThis */
|
|
3
|
-
// This file produces the globalThis.VatData property outside of a running
|
|
4
|
-
// SwingSet so that it can be used by '@agoric/vat-data' (which only *consumes*
|
|
5
|
-
// `globalThis.VatData`) in code under test.
|
|
6
|
-
import { makeFakeVirtualStuff } from './fakeVirtualSupport.js';
|
|
7
|
-
|
|
8
|
-
const { WeakMap, WeakSet } = globalThis;
|
|
9
|
-
|
|
10
|
-
/** @type {ReturnType<makeFakeVirtualStuff>} */
|
|
11
|
-
let fakeVomKit;
|
|
12
|
-
|
|
13
|
-
globalThis.VatData = harden({
|
|
14
|
-
// @ts-expect-error spread argument for non-rest parameter
|
|
15
|
-
defineKind: (...args) => fakeVomKit.vom.defineKind(...args),
|
|
16
|
-
// @ts-expect-error spread argument for non-rest parameter
|
|
17
|
-
defineKindMulti: (...args) => fakeVomKit.vom.defineKindMulti(...args),
|
|
18
|
-
// @ts-expect-error spread argument for non-rest parameter
|
|
19
|
-
defineDurableKind: (...args) => fakeVomKit.vom.defineDurableKind(...args),
|
|
20
|
-
defineDurableKindMulti: (...args) =>
|
|
21
|
-
// @ts-expect-error spread argument for non-rest parameter
|
|
22
|
-
fakeVomKit.vom.defineDurableKindMulti(...args),
|
|
23
|
-
makeKindHandle: tag => fakeVomKit.vom.makeKindHandle(tag),
|
|
24
|
-
canBeDurable: (...args) => fakeVomKit.vom.canBeDurable(...args),
|
|
25
|
-
providePromiseWatcher: (...args) =>
|
|
26
|
-
fakeVomKit.wpm.providePromiseWatcher(...args),
|
|
27
|
-
watchPromise: (p, watcher, ...args) =>
|
|
28
|
-
fakeVomKit.wpm.watchPromise(p, watcher, ...args),
|
|
29
|
-
makeScalarBigMapStore: (...args) =>
|
|
30
|
-
fakeVomKit.cm.makeScalarBigMapStore(...args),
|
|
31
|
-
makeScalarBigWeakMapStore: (...args) =>
|
|
32
|
-
fakeVomKit.cm.makeScalarBigWeakMapStore(...args),
|
|
33
|
-
makeScalarBigSetStore: (...args) =>
|
|
34
|
-
fakeVomKit.cm.makeScalarBigSetStore(...args),
|
|
35
|
-
makeScalarBigWeakSetStore: (...args) =>
|
|
36
|
-
fakeVomKit.cm.makeScalarBigWeakSetStore(...args),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export const reincarnate = (options = {}) => {
|
|
40
|
-
const { fakeStore = new Map(), fakeVomKit: fvk } = options;
|
|
41
|
-
|
|
42
|
-
if (options.fakeVomKit) {
|
|
43
|
-
fvk.vom.flushStateCache();
|
|
44
|
-
fvk.cm.flushSchemaCache();
|
|
45
|
-
fvk.vrm.flushIDCounters();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
fakeVomKit = makeFakeVirtualStuff({
|
|
49
|
-
...options,
|
|
50
|
-
fakeStore,
|
|
51
|
-
WeakMap,
|
|
52
|
-
WeakSet,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// @ts-expect-error toStringTag set imperatively so it doesn't show up in the type
|
|
56
|
-
globalThis.WeakMap = fakeVomKit.vom.VirtualObjectAwareWeakMap;
|
|
57
|
-
// @ts-expect-error ditto
|
|
58
|
-
globalThis.WeakSet = fakeVomKit.vom.VirtualObjectAwareWeakSet;
|
|
59
|
-
|
|
60
|
-
return { ...options, fakeStore, fakeVomKit };
|
|
61
|
-
};
|