@agoric/swingset-liveslots 0.10.3-mainnet1B-dev-26244e8.0 → 0.10.3-orchestration-dev-096c4e8.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/README.md +2 -0
- package/package.json +25 -17
- package/src/cache.js +5 -3
- package/src/collectionManager.js +147 -69
- package/src/index.js +2 -1
- package/src/liveslots.js +52 -79
- package/src/message.js +4 -4
- package/src/types.js +8 -2
- package/src/vatDataTypes.d.ts +234 -0
- package/src/vatDataTypes.js +2 -0
- package/src/vatstore-iterators.js +2 -0
- package/src/virtualObjectManager.js +107 -63
- package/src/virtualReferences.js +51 -0
- package/src/watchedPromises.js +50 -15
- package/test/gc-and-finalize.js +30 -1
- package/test/gc-helpers.js +2 -1
- package/test/liveslots-helpers.js +6 -6
- package/test/mock-gc.js +1 -0
- package/test/storeGC/test-lifecycle.js +2 -2
- package/test/storeGC/test-refcount-management.js +1 -2
- package/test/storeGC/test-scalar-store-kind.js +0 -1
- package/test/storeGC/test-weak-key.js +1 -2
- package/test/test-baggage.js +1 -2
- package/test/test-cache.js +0 -1
- package/test/test-collection-schema-refcount.js +1 -2
- package/test/test-collection-upgrade.js +1 -3
- package/test/test-collections.js +117 -14
- package/test/test-dropped-collection-weakrefs.js +1 -2
- package/test/test-durabilityChecks.js +3 -3
- package/test/test-facetiousness.js +1 -2
- package/test/test-gc-sensitivity.js +2 -2
- package/test/test-handled-promises.js +5 -7
- package/test/test-initial-vrefs.js +2 -3
- package/test/test-liveslots-mock-gc.js +2 -2
- package/test/test-liveslots-real-gc.js +44 -35
- package/test/test-liveslots.js +13 -14
- package/test/test-vo-test-harness.js +0 -1
- package/test/test-vpid-liveslots.js +4 -5
- 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 +1 -2
- package/test/virtual-objects/test-empty-data.js +1 -2
- package/test/virtual-objects/test-facets.js +1 -2
- 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 +2 -3
- package/test/virtual-objects/test-retain-remotable.js +25 -24
- 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 +126 -8
- package/test/virtual-objects/test-vo-real-gc.js +8 -8
- package/test/virtual-objects/test-weakcollections-vref-handling.js +1 -2
- package/tools/fakeVirtualSupport.js +48 -21
- package/tools/prepare-test-env.js +13 -0
- package/tools/setup-vat-data.js +62 -0
- package/CHANGELOG.md +0 -77
- package/test/kmarshal.js +0 -79
package/README.md
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/swingset-liveslots",
|
|
3
|
-
"version": "0.10.3-
|
|
3
|
+
"version": "0.10.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
4
4
|
"description": "SwingSet ocap support layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -13,26 +13,28 @@
|
|
|
13
13
|
"test:xs": "exit 0",
|
|
14
14
|
"lint-fix": "yarn lint:eslint --fix",
|
|
15
15
|
"lint": "run-s --continue-on-error lint:*",
|
|
16
|
-
"lint:types": "tsc
|
|
16
|
+
"lint:types": "tsc",
|
|
17
17
|
"lint:eslint": "eslint ."
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@agoric/assert": "0.6.1-
|
|
21
|
-
"@agoric/internal": "0.
|
|
22
|
-
"@agoric/store": "0.9.3-
|
|
23
|
-
"@
|
|
24
|
-
"@endo/
|
|
25
|
-
"@endo/
|
|
26
|
-
"@endo/
|
|
27
|
-
"@endo/
|
|
28
|
-
"@endo/
|
|
29
|
-
"@endo/
|
|
30
|
-
"@endo/
|
|
31
|
-
"@endo/
|
|
32
|
-
"@endo/
|
|
20
|
+
"@agoric/assert": "0.6.1-orchestration-dev-096c4e8.0+096c4e8",
|
|
21
|
+
"@agoric/internal": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
22
|
+
"@agoric/store": "0.9.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
23
|
+
"@endo/env-options": "^1.1.1",
|
|
24
|
+
"@endo/errors": "^1.1.0",
|
|
25
|
+
"@endo/eventual-send": "^1.1.2",
|
|
26
|
+
"@endo/exo": "^1.2.1",
|
|
27
|
+
"@endo/far": "^1.0.4",
|
|
28
|
+
"@endo/init": "^1.0.4",
|
|
29
|
+
"@endo/marshal": "^1.3.0",
|
|
30
|
+
"@endo/nat": "^5.0.4",
|
|
31
|
+
"@endo/pass-style": "^1.2.0",
|
|
32
|
+
"@endo/patterns": "^1.2.0",
|
|
33
|
+
"@endo/promise-kit": "^1.0.4"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"
|
|
36
|
+
"@agoric/kmarshal": "0.1.1-orchestration-dev-096c4e8.0+096c4e8",
|
|
37
|
+
"ava": "^5.3.0"
|
|
36
38
|
},
|
|
37
39
|
"files": [
|
|
38
40
|
"src/**/*.js",
|
|
@@ -55,11 +57,17 @@
|
|
|
55
57
|
"files": [
|
|
56
58
|
"test/**/test-*.js"
|
|
57
59
|
],
|
|
60
|
+
"require": [
|
|
61
|
+
"@endo/init/debug.js"
|
|
62
|
+
],
|
|
58
63
|
"timeout": "20m",
|
|
59
64
|
"workerThreads": false
|
|
60
65
|
},
|
|
61
66
|
"publishConfig": {
|
|
62
67
|
"access": "public"
|
|
63
68
|
},
|
|
64
|
-
"
|
|
69
|
+
"typeCoverage": {
|
|
70
|
+
"atLeast": 75.2
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "096c4e8fce80e9a509b0e1a30fda11736c4570e1"
|
|
65
73
|
}
|
package/src/cache.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Fail } from '@agoric/assert';
|
|
|
4
4
|
* @template V
|
|
5
5
|
* @callback CacheGet
|
|
6
6
|
* @param {string} key
|
|
7
|
-
* @returns {V}
|
|
7
|
+
* @returns {V | undefined}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -17,7 +17,7 @@ import { Fail } from '@agoric/assert';
|
|
|
17
17
|
/**
|
|
18
18
|
* @callback CacheDelete
|
|
19
19
|
* @param {string} key
|
|
20
|
-
* @returns {
|
|
20
|
+
* @returns {boolean}
|
|
21
21
|
*
|
|
22
22
|
* @callback CacheFlush
|
|
23
23
|
* @returns {void}
|
|
@@ -62,6 +62,7 @@ import { Fail } from '@agoric/assert';
|
|
|
62
62
|
export function makeCache(readBacking, writeBacking, deleteBacking) {
|
|
63
63
|
const stash = new Map();
|
|
64
64
|
const dirtyKeys = new Set();
|
|
65
|
+
/** @type {Cache<V>} */
|
|
65
66
|
const cache = {
|
|
66
67
|
get: key => {
|
|
67
68
|
assert.typeof(key, 'string');
|
|
@@ -82,8 +83,9 @@ export function makeCache(readBacking, writeBacking, deleteBacking) {
|
|
|
82
83
|
},
|
|
83
84
|
delete: key => {
|
|
84
85
|
assert.typeof(key, 'string');
|
|
85
|
-
stash.delete(key);
|
|
86
|
+
const result = stash.delete(key);
|
|
86
87
|
dirtyKeys.add(key);
|
|
88
|
+
return result;
|
|
87
89
|
},
|
|
88
90
|
flush: () => {
|
|
89
91
|
const keys = [...dirtyKeys.keys()];
|
package/src/collectionManager.js
CHANGED
|
@@ -15,7 +15,10 @@ import {
|
|
|
15
15
|
makeCopySet,
|
|
16
16
|
makeCopyMap,
|
|
17
17
|
getRankCover,
|
|
18
|
+
getCopyMapEntries,
|
|
19
|
+
getCopySetKeys,
|
|
18
20
|
} from '@endo/patterns';
|
|
21
|
+
import { isCopyMap, isCopySet } from '@agoric/store';
|
|
19
22
|
import { makeBaseRef, parseVatSlot } from './parseVatSlots.js';
|
|
20
23
|
import {
|
|
21
24
|
enumerateKeysStartEnd,
|
|
@@ -47,6 +50,14 @@ function throwNotDurable(value, slotIndex, serializedValue) {
|
|
|
47
50
|
Fail`value is not durable: ${value} at slot ${q(slotIndex)} of ${serializedValue.body}`;
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
function failNotFound(key, label) {
|
|
54
|
+
Fail`key ${key} not found in collection ${q(label)}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function failNotIterable(value) {
|
|
58
|
+
Fail`provided data source is not iterable: ${value}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
50
61
|
function prefixc(collectionID, dbEntryKey) {
|
|
51
62
|
return `vc.${collectionID}.${dbEntryKey}`;
|
|
52
63
|
}
|
|
@@ -244,7 +255,11 @@ export function makeCollectionManager(
|
|
|
244
255
|
const kindInfo = storeKindInfo[kindName];
|
|
245
256
|
kindInfo || Fail`unknown collection kind ${kindName}`;
|
|
246
257
|
const { hasWeakKeys, durable } = kindInfo;
|
|
247
|
-
const getSchema = () =>
|
|
258
|
+
const getSchema = () => {
|
|
259
|
+
const result = schemaCache.get(collectionID);
|
|
260
|
+
assert(result !== undefined);
|
|
261
|
+
return result;
|
|
262
|
+
};
|
|
248
263
|
const dbKeyPrefix = `vc.${collectionID}.`;
|
|
249
264
|
let currentGenerationNumber = 0;
|
|
250
265
|
|
|
@@ -336,24 +351,26 @@ export function makeCollectionManager(
|
|
|
336
351
|
const { keyShape } = getSchema();
|
|
337
352
|
if (!matches(key, keyShape)) {
|
|
338
353
|
return false;
|
|
339
|
-
}
|
|
340
|
-
if (passStyleOf(key) === 'remotable') {
|
|
354
|
+
} else if (passStyleOf(key) === 'remotable') {
|
|
341
355
|
return getOrdinal(key) !== undefined;
|
|
342
356
|
} else {
|
|
343
357
|
return syscall.vatstoreGet(keyToDBKey(key)) !== undefined;
|
|
344
358
|
}
|
|
345
359
|
}
|
|
346
360
|
|
|
361
|
+
function mustGet(key, label) {
|
|
362
|
+
if (passStyleOf(key) === 'remotable' && getOrdinal(key) === undefined) {
|
|
363
|
+
failNotFound(key, label);
|
|
364
|
+
}
|
|
365
|
+
const dbKey = keyToDBKey(key);
|
|
366
|
+
const result = syscall.vatstoreGet(dbKey) || failNotFound(key, label);
|
|
367
|
+
return { dbKey, result };
|
|
368
|
+
}
|
|
369
|
+
|
|
347
370
|
function get(key) {
|
|
348
371
|
const { keyShape, label } = getSchema();
|
|
349
372
|
mustMatch(key, keyShape, makeInvalidKeyTypeMsg(label));
|
|
350
|
-
|
|
351
|
-
throw Fail`key ${key} not found in collection ${q(label)}`;
|
|
352
|
-
}
|
|
353
|
-
const result = syscall.vatstoreGet(keyToDBKey(key));
|
|
354
|
-
if (!result) {
|
|
355
|
-
throw Fail`key ${key} not found in collection ${q(label)}`;
|
|
356
|
-
}
|
|
373
|
+
const { result } = mustGet(key, label);
|
|
357
374
|
return unserializeValue(JSON.parse(result));
|
|
358
375
|
}
|
|
359
376
|
|
|
@@ -377,11 +394,11 @@ export function makeCollectionManager(
|
|
|
377
394
|
currentGenerationNumber += 1;
|
|
378
395
|
assertAcceptableSyscallCapdataSize([serializedValue]);
|
|
379
396
|
if (durable) {
|
|
380
|
-
serializedValue.slots.
|
|
397
|
+
for (const [slotIndex, vref] of serializedValue.slots.entries()) {
|
|
381
398
|
if (!vrm.isDurable(vref)) {
|
|
382
399
|
throwNotDurable(value, slotIndex, serializedValue);
|
|
383
400
|
}
|
|
384
|
-
}
|
|
401
|
+
}
|
|
385
402
|
}
|
|
386
403
|
if (passStyleOf(key) === 'remotable') {
|
|
387
404
|
/** @type {string} */
|
|
@@ -397,7 +414,9 @@ export function makeCollectionManager(
|
|
|
397
414
|
vrm.addReachableVref(vref);
|
|
398
415
|
}
|
|
399
416
|
}
|
|
400
|
-
serializedValue.slots
|
|
417
|
+
for (const vref of serializedValue.slots) {
|
|
418
|
+
vrm.addReachableVref(vref);
|
|
419
|
+
}
|
|
401
420
|
syscall.vatstoreSet(keyToDBKey(key), JSON.stringify(serializedValue));
|
|
402
421
|
updateEntryCount(1);
|
|
403
422
|
};
|
|
@@ -416,15 +435,13 @@ export function makeCollectionManager(
|
|
|
416
435
|
const after = serializeValue(harden(value));
|
|
417
436
|
assertAcceptableSyscallCapdataSize([after]);
|
|
418
437
|
if (durable) {
|
|
419
|
-
after.slots.
|
|
438
|
+
for (const [i, vref] of after.slots.entries()) {
|
|
420
439
|
if (!vrm.isDurable(vref)) {
|
|
421
440
|
throwNotDurable(value, i, after);
|
|
422
441
|
}
|
|
423
|
-
}
|
|
442
|
+
}
|
|
424
443
|
}
|
|
425
|
-
const dbKey =
|
|
426
|
-
const rawBefore = syscall.vatstoreGet(dbKey);
|
|
427
|
-
rawBefore || Fail`key ${key} not found in collection ${q(label)}`;
|
|
444
|
+
const { dbKey, result: rawBefore } = mustGet(key, label);
|
|
428
445
|
const before = JSON.parse(rawBefore);
|
|
429
446
|
vrm.updateReferenceCounts(before.slots, after.slots);
|
|
430
447
|
syscall.vatstoreSet(dbKey, JSON.stringify(after));
|
|
@@ -433,12 +450,7 @@ export function makeCollectionManager(
|
|
|
433
450
|
function deleteInternal(key) {
|
|
434
451
|
const { keyShape, label } = getSchema();
|
|
435
452
|
mustMatch(key, keyShape, makeInvalidKeyTypeMsg(label));
|
|
436
|
-
|
|
437
|
-
throw Fail`key ${key} not found in collection ${q(label)}`;
|
|
438
|
-
}
|
|
439
|
-
const dbKey = keyToDBKey(key);
|
|
440
|
-
const rawValue = syscall.vatstoreGet(dbKey);
|
|
441
|
-
rawValue || Fail`key ${key} not found in collection ${q(label)}`;
|
|
453
|
+
const { dbKey, result: rawValue } = mustGet(key, label);
|
|
442
454
|
const value = JSON.parse(rawValue);
|
|
443
455
|
const doMoreGC1 = value.slots.map(vrm.removeReachableVref).some(b => b);
|
|
444
456
|
syscall.vatstoreDelete(dbKey);
|
|
@@ -474,18 +486,15 @@ export function makeCollectionManager(
|
|
|
474
486
|
const end = prefix(coverEnd); // exclusive
|
|
475
487
|
|
|
476
488
|
const generationAtStart = currentGenerationNumber;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
}
|
|
489
|
+
const checkGen = () =>
|
|
490
|
+
currentGenerationNumber === generationAtStart ||
|
|
491
|
+
Fail`keys in store cannot be added to during iteration`;
|
|
482
492
|
|
|
483
493
|
const needToMatchKey = !matchAny(keyPatt);
|
|
484
494
|
const needToMatchValue = !matchAny(valuePatt);
|
|
485
495
|
|
|
486
|
-
// we
|
|
496
|
+
// we might not need to unserialize the dbKey or get the dbValue
|
|
487
497
|
const needKeys = yieldKeys || needToMatchKey;
|
|
488
|
-
// we don't always need the dbValue
|
|
489
498
|
const needValues = yieldValues || needToMatchValue;
|
|
490
499
|
|
|
491
500
|
/**
|
|
@@ -513,7 +522,7 @@ export function makeCollectionManager(
|
|
|
513
522
|
yield [yieldKeys ? key : undefined, yieldValues ? value : undefined];
|
|
514
523
|
}
|
|
515
524
|
}
|
|
516
|
-
|
|
525
|
+
harden(iter);
|
|
517
526
|
return iter();
|
|
518
527
|
}
|
|
519
528
|
|
|
@@ -523,6 +532,7 @@ export function makeCollectionManager(
|
|
|
523
532
|
yield entry[0];
|
|
524
533
|
}
|
|
525
534
|
}
|
|
535
|
+
harden(iter);
|
|
526
536
|
return iter();
|
|
527
537
|
}
|
|
528
538
|
|
|
@@ -587,6 +597,7 @@ export function makeCollectionManager(
|
|
|
587
597
|
yield entry[1];
|
|
588
598
|
}
|
|
589
599
|
}
|
|
600
|
+
harden(iter);
|
|
590
601
|
return iter();
|
|
591
602
|
}
|
|
592
603
|
|
|
@@ -596,6 +607,7 @@ export function makeCollectionManager(
|
|
|
596
607
|
yield entry;
|
|
597
608
|
}
|
|
598
609
|
}
|
|
610
|
+
harden(iter);
|
|
599
611
|
return iter();
|
|
600
612
|
}
|
|
601
613
|
|
|
@@ -624,6 +636,34 @@ export function makeCollectionManager(
|
|
|
624
636
|
const snapshotMap = (keyPatt, valuePatt) =>
|
|
625
637
|
makeCopyMap(entries(keyPatt, valuePatt));
|
|
626
638
|
|
|
639
|
+
const addAllToSet = elems => {
|
|
640
|
+
if (typeof elems[Symbol.iterator] !== 'function') {
|
|
641
|
+
elems =
|
|
642
|
+
Object.isFrozen(elems) && isCopySet(elems)
|
|
643
|
+
? getCopySetKeys(elems)
|
|
644
|
+
: failNotIterable(elems);
|
|
645
|
+
}
|
|
646
|
+
for (const elem of elems) {
|
|
647
|
+
addToSet(elem);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
const addAllToMap = mapEntries => {
|
|
652
|
+
if (typeof mapEntries[Symbol.iterator] !== 'function') {
|
|
653
|
+
mapEntries =
|
|
654
|
+
Object.isFrozen(mapEntries) && isCopyMap(mapEntries)
|
|
655
|
+
? getCopyMapEntries(mapEntries)
|
|
656
|
+
: failNotIterable(mapEntries);
|
|
657
|
+
}
|
|
658
|
+
for (const [key, value] of mapEntries) {
|
|
659
|
+
if (has(key)) {
|
|
660
|
+
set(key, value);
|
|
661
|
+
} else {
|
|
662
|
+
doInit(key, value, true);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
|
|
627
667
|
return {
|
|
628
668
|
has,
|
|
629
669
|
get,
|
|
@@ -635,6 +675,8 @@ export function makeCollectionManager(
|
|
|
635
675
|
keys,
|
|
636
676
|
values,
|
|
637
677
|
entries,
|
|
678
|
+
addAllToSet,
|
|
679
|
+
addAllToMap,
|
|
638
680
|
snapshotSet,
|
|
639
681
|
snapshotMap,
|
|
640
682
|
sizeInternal,
|
|
@@ -647,12 +689,23 @@ export function makeCollectionManager(
|
|
|
647
689
|
const hasWeakKeys = storeKindInfo[kindName].hasWeakKeys;
|
|
648
690
|
const raw = summonCollectionInternal(initial, collectionID, kindName);
|
|
649
691
|
|
|
650
|
-
const {
|
|
692
|
+
const {
|
|
693
|
+
has,
|
|
694
|
+
get,
|
|
695
|
+
init,
|
|
696
|
+
addToSet,
|
|
697
|
+
addAllToMap,
|
|
698
|
+
addAllToSet,
|
|
699
|
+
set,
|
|
700
|
+
delete: del,
|
|
701
|
+
} = raw;
|
|
651
702
|
const weakMethods = {
|
|
652
703
|
has,
|
|
653
704
|
get,
|
|
654
705
|
init,
|
|
655
706
|
addToSet,
|
|
707
|
+
addAllToSet,
|
|
708
|
+
addAllToMap,
|
|
656
709
|
set,
|
|
657
710
|
delete: del,
|
|
658
711
|
};
|
|
@@ -700,7 +753,9 @@ export function makeCollectionManager(
|
|
|
700
753
|
const collection = summonCollectionInternal(false, collectionID, kindName);
|
|
701
754
|
|
|
702
755
|
let doMoreGC = collection.clearInternal(true);
|
|
703
|
-
const
|
|
756
|
+
const record = schemaCache.get(collectionID);
|
|
757
|
+
assert(record !== undefined);
|
|
758
|
+
const { schemataCapData } = record;
|
|
704
759
|
doMoreGC =
|
|
705
760
|
schemataCapData.slots.map(vrm.removeReachableVref).some(b => b) ||
|
|
706
761
|
doMoreGC;
|
|
@@ -747,13 +802,15 @@ export function makeCollectionManager(
|
|
|
747
802
|
}
|
|
748
803
|
const schemataCapData = serialize(harden(schemata));
|
|
749
804
|
if (isDurable) {
|
|
750
|
-
schemataCapData.slots.
|
|
805
|
+
for (const [slotIndex, vref] of schemataCapData.slots.entries()) {
|
|
751
806
|
if (!vrm.isDurable(vref)) {
|
|
752
807
|
throwNotDurable(vref, slotIndex, schemataCapData);
|
|
753
808
|
}
|
|
754
|
-
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
for (const vref of schemataCapData.slots) {
|
|
812
|
+
vrm.addReachableVref(vref);
|
|
755
813
|
}
|
|
756
|
-
schemataCapData.slots.forEach(vrm.addReachableVref);
|
|
757
814
|
|
|
758
815
|
schemaCache.set(
|
|
759
816
|
collectionID,
|
|
@@ -764,12 +821,48 @@ export function makeCollectionManager(
|
|
|
764
821
|
}
|
|
765
822
|
|
|
766
823
|
function collectionToMapStore(collection) {
|
|
767
|
-
const {
|
|
768
|
-
|
|
824
|
+
const {
|
|
825
|
+
has,
|
|
826
|
+
get,
|
|
827
|
+
init,
|
|
828
|
+
set,
|
|
829
|
+
delete: del,
|
|
830
|
+
addAllToMap,
|
|
831
|
+
keys,
|
|
832
|
+
values,
|
|
833
|
+
entries,
|
|
834
|
+
snapshotMap,
|
|
835
|
+
getSize,
|
|
836
|
+
clear,
|
|
837
|
+
} = collection;
|
|
838
|
+
const mapStore = {
|
|
839
|
+
has,
|
|
840
|
+
get,
|
|
841
|
+
init,
|
|
842
|
+
set,
|
|
843
|
+
delete: del,
|
|
844
|
+
addAll: addAllToMap,
|
|
845
|
+
keys,
|
|
846
|
+
values,
|
|
847
|
+
entries,
|
|
848
|
+
snapshot: snapshotMap,
|
|
849
|
+
getSize,
|
|
850
|
+
clear,
|
|
851
|
+
};
|
|
852
|
+
return Far('mapStore', mapStore);
|
|
769
853
|
}
|
|
770
854
|
|
|
771
855
|
function collectionToWeakMapStore(collection) {
|
|
772
|
-
|
|
856
|
+
const { has, get, init, set, delete: del, addAllToMap } = collection;
|
|
857
|
+
const weakMapStore = {
|
|
858
|
+
has,
|
|
859
|
+
get,
|
|
860
|
+
init,
|
|
861
|
+
set,
|
|
862
|
+
delete: del,
|
|
863
|
+
addAll: addAllToMap,
|
|
864
|
+
};
|
|
865
|
+
return Far('weakMapStore', weakMapStore);
|
|
773
866
|
}
|
|
774
867
|
|
|
775
868
|
function collectionToSetStore(collection) {
|
|
@@ -777,50 +870,35 @@ export function makeCollectionManager(
|
|
|
777
870
|
has,
|
|
778
871
|
addToSet,
|
|
779
872
|
delete: del,
|
|
873
|
+
addAllToSet,
|
|
780
874
|
keys,
|
|
781
|
-
getSize,
|
|
782
875
|
snapshotSet,
|
|
876
|
+
getSize,
|
|
783
877
|
clear,
|
|
784
878
|
} = collection;
|
|
785
|
-
function* entries(patt) {
|
|
786
|
-
for (const k of keys(patt)) {
|
|
787
|
-
yield [k, k];
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
function addAll(elems) {
|
|
791
|
-
for (const elem of elems) {
|
|
792
|
-
addToSet(elem, null);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
879
|
|
|
796
880
|
const setStore = {
|
|
797
881
|
has,
|
|
798
882
|
add: addToSet,
|
|
799
|
-
addAll,
|
|
800
883
|
delete: del,
|
|
884
|
+
addAll: addAllToSet,
|
|
801
885
|
keys: patt => keys(patt),
|
|
802
886
|
values: patt => keys(patt),
|
|
803
|
-
entries,
|
|
804
|
-
getSize: patt => getSize(patt),
|
|
805
887
|
snapshot: snapshotSet,
|
|
888
|
+
getSize: patt => getSize(patt),
|
|
806
889
|
clear,
|
|
807
890
|
};
|
|
808
891
|
return Far('setStore', setStore);
|
|
809
892
|
}
|
|
810
893
|
|
|
811
894
|
function collectionToWeakSetStore(collection) {
|
|
812
|
-
const { has, addToSet, delete: del } = collection;
|
|
813
|
-
function addAll(elems) {
|
|
814
|
-
for (const elem of elems) {
|
|
815
|
-
addToSet(elem);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
895
|
+
const { has, addToSet, delete: del, addAllToSet } = collection;
|
|
818
896
|
|
|
819
897
|
const weakSetStore = {
|
|
820
898
|
has,
|
|
821
899
|
add: addToSet,
|
|
822
|
-
addAll,
|
|
823
900
|
delete: del,
|
|
901
|
+
addAll: addAllToSet,
|
|
824
902
|
};
|
|
825
903
|
return Far('weakSetStore', weakSetStore);
|
|
826
904
|
}
|
|
@@ -829,7 +907,7 @@ export function makeCollectionManager(
|
|
|
829
907
|
* Produce a big map.
|
|
830
908
|
*
|
|
831
909
|
* @template K,V
|
|
832
|
-
* @param {string} [label
|
|
910
|
+
* @param {string} [label] - diagnostic label for the store
|
|
833
911
|
* @param {StoreOptions} [options]
|
|
834
912
|
* @returns {MapStore<K,V>}
|
|
835
913
|
*/
|
|
@@ -873,7 +951,7 @@ export function makeCollectionManager(
|
|
|
873
951
|
* Produce a weak big map.
|
|
874
952
|
*
|
|
875
953
|
* @template K,V
|
|
876
|
-
* @param {string} [label
|
|
954
|
+
* @param {string} [label] - diagnostic label for the store
|
|
877
955
|
* @param {StoreOptions} [options]
|
|
878
956
|
* @returns {WeakMapStore<K,V>}
|
|
879
957
|
*/
|
|
@@ -902,7 +980,7 @@ export function makeCollectionManager(
|
|
|
902
980
|
* Produce a big set.
|
|
903
981
|
*
|
|
904
982
|
* @template K
|
|
905
|
-
* @param {string} [label
|
|
983
|
+
* @param {string} [label] - diagnostic label for the store
|
|
906
984
|
* @param {StoreOptions} [options]
|
|
907
985
|
* @returns {SetStore<K>}
|
|
908
986
|
*/
|
|
@@ -929,7 +1007,7 @@ export function makeCollectionManager(
|
|
|
929
1007
|
* Produce a weak big set.
|
|
930
1008
|
*
|
|
931
1009
|
* @template K
|
|
932
|
-
* @param {string} [label
|
|
1010
|
+
* @param {string} [label] - diagnostic label for the store
|
|
933
1011
|
* @param {StoreOptions} [options]
|
|
934
1012
|
* @returns {WeakSetStore<K>}
|
|
935
1013
|
*/
|
|
@@ -1006,7 +1084,7 @@ export function makeCollectionManager(
|
|
|
1006
1084
|
* remotables.
|
|
1007
1085
|
*
|
|
1008
1086
|
* @template K,V
|
|
1009
|
-
* @param {string} [label
|
|
1087
|
+
* @param {string} [label] - diagnostic label for the store
|
|
1010
1088
|
* @param {StoreOptions} [options]
|
|
1011
1089
|
* @returns {MapStore<K,V>}
|
|
1012
1090
|
*/
|
|
@@ -1018,7 +1096,7 @@ export function makeCollectionManager(
|
|
|
1018
1096
|
* primitives, or remotables.
|
|
1019
1097
|
*
|
|
1020
1098
|
* @template K,V
|
|
1021
|
-
* @param {string} [label
|
|
1099
|
+
* @param {string} [label] - diagnostic label for the store
|
|
1022
1100
|
* @param {StoreOptions} [options]
|
|
1023
1101
|
* @returns {WeakMapStore<K,V>}
|
|
1024
1102
|
*/
|
|
@@ -1030,7 +1108,7 @@ export function makeCollectionManager(
|
|
|
1030
1108
|
* remotables.
|
|
1031
1109
|
*
|
|
1032
1110
|
* @template K
|
|
1033
|
-
* @param {string} [label
|
|
1111
|
+
* @param {string} [label] - diagnostic label for the store
|
|
1034
1112
|
* @param {StoreOptions} [options]
|
|
1035
1113
|
* @returns {SetStore<K>}
|
|
1036
1114
|
*/
|
|
@@ -1042,7 +1120,7 @@ export function makeCollectionManager(
|
|
|
1042
1120
|
* primitives, or remotables.
|
|
1043
1121
|
*
|
|
1044
1122
|
* @template K
|
|
1045
|
-
* @param {string} [label
|
|
1123
|
+
* @param {string} [label] - diagnostic label for the store
|
|
1046
1124
|
* @param {StoreOptions} [options]
|
|
1047
1125
|
* @returns {WeakSetStore<K>}
|
|
1048
1126
|
*/
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable import/export -- types files have no named runtime exports */
|
|
1
2
|
export { makeLiveSlots, makeMarshaller } from './liveslots.js';
|
|
2
3
|
|
|
3
4
|
export {
|
|
@@ -8,5 +9,5 @@ export {
|
|
|
8
9
|
insistVatSyscallResult,
|
|
9
10
|
} from './message.js';
|
|
10
11
|
|
|
11
|
-
// eslint-disable-next-line import/export -- no named exports
|
|
12
12
|
export * from './types.js';
|
|
13
|
+
export * from './vatDataTypes.js';
|