@agoric/swingset-liveslots 0.10.3-dev-8358d20.0 → 0.10.3-dev-5eb596e.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/swingset-liveslots",
3
- "version": "0.10.3-dev-8358d20.0+8358d20",
3
+ "version": "0.10.3-dev-5eb596e.0+5eb596e",
4
4
  "description": "SwingSet ocap support layer",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -17,10 +17,10 @@
17
17
  "lint:eslint": "eslint ."
18
18
  },
19
19
  "dependencies": {
20
- "@agoric/assert": "0.6.1-dev-8358d20.0+8358d20",
21
- "@agoric/internal": "0.3.3-dev-8358d20.0+8358d20",
22
- "@agoric/store": "0.9.3-dev-8358d20.0+8358d20",
23
- "@agoric/vat-data": "0.5.3-dev-8358d20.0+8358d20",
20
+ "@agoric/assert": "0.6.1-dev-5eb596e.0+5eb596e",
21
+ "@agoric/internal": "0.3.3-dev-5eb596e.0+5eb596e",
22
+ "@agoric/store": "0.9.3-dev-5eb596e.0+5eb596e",
23
+ "@agoric/vat-data": "0.5.3-dev-5eb596e.0+5eb596e",
24
24
  "@endo/eventual-send": "^0.17.3",
25
25
  "@endo/exo": "^0.2.3",
26
26
  "@endo/far": "^0.2.19",
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "8358d208a105af24bc267ba4ef928ca7ecf6a4e3"
64
+ "gitHead": "5eb596e63bf4d5b416d4eff187e87af366b34928"
65
65
  }
@@ -1,4 +1,4 @@
1
- /* global WeakRef */
1
+ /* global globalThis */
2
2
  /* eslint-disable max-classes-per-file */
3
3
  import { makeMarshal } from '@endo/marshal';
4
4
  import { assert } from '@agoric/assert';
@@ -9,6 +9,14 @@ 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
+
12
20
  class FakeFinalizationRegistry {
13
21
  // eslint-disable-next-line no-useless-constructor, no-empty-function
14
22
  constructor() {}
@@ -30,8 +38,6 @@ class FakeWeakRef {
30
38
  }
31
39
  }
32
40
 
33
- const RealWeakRef = WeakRef;
34
-
35
41
  export function makeFakeLiveSlotsStuff(options = {}) {
36
42
  let vrm;
37
43
  function setVrm(vrmToUse) {
@@ -45,6 +51,8 @@ export function makeFakeLiveSlotsStuff(options = {}) {
45
51
  log,
46
52
  FinalizationRegistry = FakeFinalizationRegistry,
47
53
  WeakRef = FakeWeakRef, // VRM uses this
54
+ WeakMap = RealWeakMap,
55
+ WeakSet = RealWeakSet,
48
56
  addToPossiblyDeadSet = () => {},
49
57
  addToPossiblyRetiredSet = () => {},
50
58
  } = options;
@@ -206,17 +214,23 @@ export function makeFakeLiveSlotsStuff(options = {}) {
206
214
  }
207
215
  return val;
208
216
  }
217
+ let result;
209
218
  if (virtual || durable) {
210
219
  if (vrm) {
211
220
  val = vrm.reanimate(slot);
212
221
  if (facet !== undefined) {
213
- return vrm.getFacet(id, val, facet);
222
+ result = vrm.getFacet(id, val, facet);
214
223
  }
215
224
  } else {
216
225
  assert.fail('fake liveSlots stuff configured without vrm');
217
226
  }
218
227
  }
219
- return val;
228
+ // eslint-disable-next-line no-use-before-define
229
+ registerEntry(baseRef, val, facet !== undefined);
230
+ if (!result) {
231
+ result = val;
232
+ }
233
+ return result;
220
234
  }
221
235
 
222
236
  const marshal = makeMarshal(convertValToSlot, convertSlotToVal, {
@@ -224,6 +238,9 @@ export function makeFakeLiveSlotsStuff(options = {}) {
224
238
  });
225
239
 
226
240
  function registerEntry(baseRef, val, valIsCohort) {
241
+ const { facet } = parseVatSlot(baseRef);
242
+ !facet ||
243
+ Fail`registerEntry(${baseRef} should not receive individual facets`;
227
244
  setValForSlot(baseRef, val);
228
245
  if (valIsCohort) {
229
246
  const { id } = parseVatSlot(baseRef);
@@ -264,6 +281,8 @@ export function makeFakeLiveSlotsStuff(options = {}) {
264
281
  deleteEntry,
265
282
  FinalizationRegistry,
266
283
  WeakRef,
284
+ WeakMap,
285
+ WeakSet,
267
286
  addToPossiblyDeadSet,
268
287
  addToPossiblyRetiredSet,
269
288
  dumpStore,
@@ -311,6 +330,10 @@ export function makeFakeWatchedPromiseManager(
311
330
  * @param {object} [options]
312
331
  * @param {number} [options.cacheSize]
313
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]
314
337
  */
315
338
  export function makeFakeVirtualStuff(options = {}) {
316
339
  const actualOptions = {