@agoric/zone 0.2.3-other-dev-3eb1a1d.0 → 0.2.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/package.json +17 -17
- package/src/durable.d.ts +2 -1
- package/src/durable.d.ts.map +1 -1
- package/src/durable.js +15 -11
- package/src/virtual.d.ts +1 -1
- package/src/virtual.d.ts.map +1 -1
- package/test/exos.test.js +78 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/zone",
|
|
3
|
-
"version": "0.2.3-other-dev-
|
|
3
|
+
"version": "0.2.3-other-dev-fbe72e7.0.fbe72e7",
|
|
4
4
|
"description": "Allocation zone abstraction for objects on the heap, persistent stores, etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
7
7
|
"main": "./src/index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "exit 0",
|
|
10
|
-
"prepack": "tsc --build tsconfig.build.json",
|
|
11
|
-
"postpack": "git clean -f '*.d
|
|
10
|
+
"prepack": "yarn run -T tsc --build tsconfig.build.json",
|
|
11
|
+
"postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'",
|
|
12
12
|
"test": "ava",
|
|
13
|
-
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
13
|
+
"test:c8": "c8 --all ${C8_OPTIONS:-} ava",
|
|
14
14
|
"test:xs": "exit 0",
|
|
15
15
|
"lint-fix": "yarn lint:eslint --fix",
|
|
16
|
-
"lint": "run-s --continue-on-error lint:*",
|
|
17
|
-
"lint:types": "tsc",
|
|
18
|
-
"lint:eslint": "eslint ."
|
|
16
|
+
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
17
|
+
"lint:types": "yarn run -T tsc",
|
|
18
|
+
"lint:eslint": "yarn run -T eslint ."
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": "./src/index.js",
|
|
@@ -27,22 +27,22 @@
|
|
|
27
27
|
"author": "Agoric",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agoric/base-zone": "0.1.1-other-dev-
|
|
31
|
-
"@agoric/vat-data": "0.5.3-other-dev-
|
|
32
|
-
"@endo/errors": "^1.2.
|
|
33
|
-
"@endo/far": "^1.1.
|
|
34
|
-
"@endo/pass-style": "^1.
|
|
30
|
+
"@agoric/base-zone": "0.1.1-other-dev-fbe72e7.0.fbe72e7",
|
|
31
|
+
"@agoric/vat-data": "0.5.3-other-dev-fbe72e7.0.fbe72e7",
|
|
32
|
+
"@endo/errors": "^1.2.13",
|
|
33
|
+
"@endo/far": "^1.1.14",
|
|
34
|
+
"@endo/pass-style": "^1.6.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@agoric/swingset-vat": "0.32.3-other-dev-
|
|
38
|
-
"@endo/patterns": "^1.
|
|
37
|
+
"@agoric/swingset-vat": "0.32.3-other-dev-fbe72e7.0.fbe72e7",
|
|
38
|
+
"@endo/patterns": "^1.7.0",
|
|
39
39
|
"ava": "^5.3.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": "^
|
|
45
|
+
"node": "^20.9 || ^22.11"
|
|
46
46
|
},
|
|
47
47
|
"ava": {
|
|
48
48
|
"files": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"workerThreads": false
|
|
56
56
|
},
|
|
57
57
|
"typeCoverage": {
|
|
58
|
-
"atLeast":
|
|
58
|
+
"atLeast": 94
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "fbe72e72107f9997f788674e668c660d92ec4492"
|
|
61
61
|
}
|
package/src/durable.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export function makeDurableZone(baggage: import("@agoric/vat-data").Baggage, baseLabel?: string
|
|
1
|
+
export function makeDurableZone(baggage: import("@agoric/vat-data").Baggage, baseLabel?: string): Zone;
|
|
2
|
+
import type { Zone } from './index.js';
|
|
2
3
|
//# sourceMappingURL=durable.d.ts.map
|
package/src/durable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable.d.ts","sourceRoot":"","sources":["durable.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durable.d.ts","sourceRoot":"","sources":["durable.js"],"names":[],"mappings":"AA6EO,yCAJI,OAAO,kBAAkB,EAAE,OAAO,cAClC,MAAM,GACJ,IAAI,CA+ChB;0BApGsB,YAAY"}
|
package/src/durable.js
CHANGED
|
@@ -19,6 +19,10 @@ import {
|
|
|
19
19
|
|
|
20
20
|
import { agoricVatDataKeys as keys, makeOnceKit } from '@agoric/base-zone';
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @import {Zone} from './index.js';
|
|
24
|
+
*/
|
|
25
|
+
|
|
22
26
|
/**
|
|
23
27
|
* A variant of `canBeDurable` that returns `false` instead of ever throwing.
|
|
24
28
|
*
|
|
@@ -32,23 +36,23 @@ harden(isStorable);
|
|
|
32
36
|
* @param {() => import('@agoric/vat-data').Baggage} getBaggage
|
|
33
37
|
*/
|
|
34
38
|
const attachDurableStores = getBaggage => {
|
|
35
|
-
/** @type {
|
|
39
|
+
/** @type {Zone['mapStore']} */
|
|
36
40
|
const mapStore = (label, options) => {
|
|
37
41
|
const baggage = getBaggage();
|
|
38
42
|
const ret = provideDurableMapStore(baggage, label, options);
|
|
39
43
|
return ret;
|
|
40
44
|
};
|
|
41
|
-
/** @type {
|
|
45
|
+
/** @type {Zone['setStore']} */
|
|
42
46
|
const setStore = (label, options) =>
|
|
43
47
|
provideDurableSetStore(getBaggage(), label, options);
|
|
44
|
-
/** @type {
|
|
48
|
+
/** @type {Zone['weakSetStore']} */
|
|
45
49
|
const weakSetStore = (label, options) =>
|
|
46
50
|
provideDurableWeakSetStore(getBaggage(), label, options);
|
|
47
|
-
/** @type {
|
|
51
|
+
/** @type {Zone['weakMapStore']} */
|
|
48
52
|
const weakMapStore = (label, options) =>
|
|
49
53
|
provideDurableWeakMapStore(getBaggage(), label, options);
|
|
50
54
|
|
|
51
|
-
/** @type {import('.').Stores} */
|
|
55
|
+
/** @type {import('./index.js').Stores} */
|
|
52
56
|
return Far('durableStores', {
|
|
53
57
|
detached: () => detachedDurableStores,
|
|
54
58
|
isStorable,
|
|
@@ -59,7 +63,7 @@ const attachDurableStores = getBaggage => {
|
|
|
59
63
|
});
|
|
60
64
|
};
|
|
61
65
|
|
|
62
|
-
/** @type {import('.').Stores} */
|
|
66
|
+
/** @type {import('./index.js').Stores} */
|
|
63
67
|
const detachedDurableStores = attachDurableStores(() =>
|
|
64
68
|
makeScalarMapStore('detached'),
|
|
65
69
|
);
|
|
@@ -69,7 +73,7 @@ const detachedDurableStores = attachDurableStores(() =>
|
|
|
69
73
|
*
|
|
70
74
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
71
75
|
* @param {string} [baseLabel]
|
|
72
|
-
* @returns {
|
|
76
|
+
* @returns {Zone}
|
|
73
77
|
*/
|
|
74
78
|
export const makeDurableZone = (baggage, baseLabel = 'durableZone') => {
|
|
75
79
|
baggage || Fail`baggage required`;
|
|
@@ -82,18 +86,18 @@ export const makeDurableZone = (baggage, baseLabel = 'durableZone') => {
|
|
|
82
86
|
baggage,
|
|
83
87
|
);
|
|
84
88
|
|
|
85
|
-
/** @type {
|
|
89
|
+
/** @type {Zone['exoClass']} */
|
|
86
90
|
const exoClass = (...args) => prepareExoClass(baggage, ...args);
|
|
87
|
-
/** @type {
|
|
91
|
+
/** @type {Zone['exoClassKit']} */
|
|
88
92
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- happens only integrating with Endo master
|
|
89
93
|
// @ts-ignore FIXME in Endo
|
|
90
94
|
const exoClassKit = (...args) => prepareExoClassKit(baggage, ...args);
|
|
91
|
-
/** @type {
|
|
95
|
+
/** @type {Zone['exo']} */
|
|
92
96
|
const exo = (...args) => prepareExo(baggage, ...args);
|
|
93
97
|
|
|
94
98
|
const subZoneStore = wrapProvider(attachedStores.mapStore, keys.zone);
|
|
95
99
|
|
|
96
|
-
/** @type {
|
|
100
|
+
/** @type {Zone['subZone']} */
|
|
97
101
|
const subZone = (label, options = {}) => {
|
|
98
102
|
/** @type {import('@agoric/swingset-liveslots').Baggage} */
|
|
99
103
|
const subBaggage = subZoneStore(label, options);
|
package/src/virtual.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makeVirtualZone(baseLabel?: string
|
|
1
|
+
export function makeVirtualZone(baseLabel?: string): import(".").Zone;
|
|
2
2
|
//# sourceMappingURL=virtual.d.ts.map
|
package/src/virtual.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["virtual.js"],"names":[],"mappings":"AAiEO,
|
|
1
|
+
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["virtual.js"],"names":[],"mappings":"AAiEO,4CAHI,MAAM,GACJ,OAAO,GAAG,EAAE,IAAI,CA+B5B"}
|
package/test/exos.test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { M } from '@endo/patterns';
|
|
1
2
|
import {
|
|
2
3
|
annihilate,
|
|
3
4
|
getBaggage,
|
|
@@ -123,3 +124,80 @@ test.serial('vatData migrate to durableZone', t => {
|
|
|
123
124
|
const baggage2 = getBaggage();
|
|
124
125
|
testSecondZoneIncarnation(t, makeDurableZone(baggage2));
|
|
125
126
|
});
|
|
127
|
+
|
|
128
|
+
test.serial('exoClass stateShape expansion', t => {
|
|
129
|
+
annihilate();
|
|
130
|
+
|
|
131
|
+
// See ../../swingset-liveslots/test/virtual-objects/state-shape.test.js
|
|
132
|
+
const stateShapeMismatch = { message: /stateShape mismatch/ };
|
|
133
|
+
const HolderI = M.interface('Holder', {
|
|
134
|
+
get: M.call().rest(M.arrayOf(M.string())).returns(M.record()),
|
|
135
|
+
set: M.call(M.record()).returns(),
|
|
136
|
+
});
|
|
137
|
+
const initHolder = fields => ({ ...fields });
|
|
138
|
+
const holderMethods = {
|
|
139
|
+
get(...fields) {
|
|
140
|
+
const { state } = this;
|
|
141
|
+
// We require fields to be explicit because they are currently defined on
|
|
142
|
+
// the state *prototype*.
|
|
143
|
+
return Object.fromEntries(
|
|
144
|
+
fields.flatMap(key => (key in state ? [[key, state[key]]] : [])),
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
set(fields) {
|
|
148
|
+
Object.assign(this.state, fields);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
const prepareHolder = (zone, stateShape) =>
|
|
152
|
+
zone.exoClass('Holder', HolderI, initHolder, holderMethods, { stateShape });
|
|
153
|
+
|
|
154
|
+
const fields = ['foo', 'bar', 'baz']; // but "baz" is not initially present
|
|
155
|
+
const baggage1 = getBaggage();
|
|
156
|
+
const zone1 = makeDurableZone(baggage1);
|
|
157
|
+
const makeHolder1 = prepareHolder(zone1, {
|
|
158
|
+
foo: M.number(),
|
|
159
|
+
bar: M.number(),
|
|
160
|
+
});
|
|
161
|
+
const holder1 = makeHolder1({ foo: 0, bar: 1 });
|
|
162
|
+
t.deepEqual(holder1.get(...fields), { foo: 0, bar: 1 });
|
|
163
|
+
holder1.set({ foo: 2, bar: 2 });
|
|
164
|
+
t.deepEqual(holder1.get(...fields), { foo: 2, bar: 2 });
|
|
165
|
+
t.throws(() => makeHolder1({ foo: 0, bar: 1, baz: 2 }));
|
|
166
|
+
t.throws(() => makeHolder1({ foo: 0, bar: 'string' }));
|
|
167
|
+
|
|
168
|
+
nextLife();
|
|
169
|
+
t.throws(
|
|
170
|
+
() =>
|
|
171
|
+
prepareHolder(makeDurableZone(getBaggage()), {
|
|
172
|
+
foo: M.string(),
|
|
173
|
+
bar: M.number(),
|
|
174
|
+
}),
|
|
175
|
+
stateShapeMismatch,
|
|
176
|
+
'backwards-incompatible stateShape change',
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
nextLife();
|
|
180
|
+
t.throws(
|
|
181
|
+
() =>
|
|
182
|
+
prepareHolder(makeDurableZone(getBaggage()), {
|
|
183
|
+
foo: M.or(M.number(), M.string()),
|
|
184
|
+
bar: M.number(),
|
|
185
|
+
baz: M.or(undefined, M.number()),
|
|
186
|
+
}),
|
|
187
|
+
stateShapeMismatch,
|
|
188
|
+
'stateShape field value expansion (needs #7407)',
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
nextLife();
|
|
192
|
+
const baggage2 = getBaggage();
|
|
193
|
+
const zone2 = makeDurableZone(baggage2);
|
|
194
|
+
const makeHolder2 = prepareHolder(zone2, {
|
|
195
|
+
foo: M.number(),
|
|
196
|
+
bar: M.number(),
|
|
197
|
+
baz: M.or(undefined, M.number()),
|
|
198
|
+
});
|
|
199
|
+
const holder2 = makeHolder2({ foo: 0, bar: 1, baz: 2 });
|
|
200
|
+
t.deepEqual(holder2.get(...fields), { foo: 0, bar: 1, baz: 2 });
|
|
201
|
+
holder2.set({ foo: 2, bar: 2, baz: undefined });
|
|
202
|
+
t.deepEqual(holder2.get(...fields), { foo: 2, bar: 2, baz: undefined });
|
|
203
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./durable.js","./heap.js","./virtual.js","./src/durable.js","./src/index.js","./src/virtual.js"],"version":"5.
|
|
1
|
+
{"root":["./durable.js","./heap.js","./virtual.js","./src/durable.js","./src/index.js","./src/virtual.js"],"version":"5.9.2"}
|