@agoric/swingset-liveslots 0.10.3-dev-51399d1.0 → 0.10.3-dev-1b5e57f.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 +6 -6
- package/src/types.js +8 -2
- package/src/watchedPromises.js +48 -19
- package/tools/setup-vat-data.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/swingset-liveslots",
|
|
3
|
-
"version": "0.10.3-dev-
|
|
3
|
+
"version": "0.10.3-dev-1b5e57f.0+1b5e57f",
|
|
4
4
|
"description": "SwingSet ocap support layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"lint:eslint": "eslint ."
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@agoric/assert": "0.6.1-dev-
|
|
21
|
-
"@agoric/internal": "0.3.3-dev-
|
|
22
|
-
"@agoric/store": "0.9.3-dev-
|
|
20
|
+
"@agoric/assert": "0.6.1-dev-1b5e57f.0+1b5e57f",
|
|
21
|
+
"@agoric/internal": "0.3.3-dev-1b5e57f.0+1b5e57f",
|
|
22
|
+
"@agoric/store": "0.9.3-dev-1b5e57f.0+1b5e57f",
|
|
23
23
|
"@endo/eventual-send": "^0.17.5",
|
|
24
24
|
"@endo/exo": "^0.2.5",
|
|
25
25
|
"@endo/far": "^0.2.21",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@endo/promise-kit": "^0.2.59"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@agoric/kmarshal": "0.1.1-dev-
|
|
34
|
+
"@agoric/kmarshal": "0.1.1-dev-1b5e57f.0+1b5e57f",
|
|
35
35
|
"ava": "^5.3.0"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"typeCoverage": {
|
|
68
68
|
"atLeast": 71.48
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "1b5e57f17a043a43171621bbe3ef68131954f714"
|
|
71
71
|
}
|
package/src/types.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Ensure this is a module.
|
|
2
|
+
export {};
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @callback makeLiveSlots
|
|
3
6
|
*/
|
|
@@ -79,5 +82,8 @@
|
|
|
79
82
|
*
|
|
80
83
|
*/
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
/**
|
|
86
|
+
* @template V fulfilled value
|
|
87
|
+
* @template {any[]} [A=unknown[]] arguments
|
|
88
|
+
* @typedef { {onFulfilled?: (value: V, ...args: A) => void, onRejected?: (reason: unknown, ...args: A) => void} } PromiseWatcher
|
|
89
|
+
*/
|
package/src/watchedPromises.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
// no-lonely-if is a stupid rule that really should be disabled globally
|
|
2
3
|
/* eslint-disable no-lonely-if */
|
|
3
4
|
|
|
@@ -6,6 +7,12 @@ import { initEmpty, M } from '@agoric/store';
|
|
|
6
7
|
import { E } from '@endo/eventual-send';
|
|
7
8
|
import { parseVatSlot } from './parseVatSlots.js';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @template V
|
|
12
|
+
* @template {any[]} [A=unknown[]]
|
|
13
|
+
* @typedef {[watcher: import('./types.js').PromiseWatcher<V, A>, ...args: A]} PromiseWatcherTuple
|
|
14
|
+
*/
|
|
15
|
+
|
|
9
16
|
/**
|
|
10
17
|
* @param {object} options
|
|
11
18
|
* @param {*} options.syscall
|
|
@@ -28,17 +35,28 @@ export function makeWatchedPromiseManager({
|
|
|
28
35
|
const { makeScalarBigMapStore } = collectionManager;
|
|
29
36
|
const { defineDurableKind } = vom;
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
/**
|
|
39
|
+
* virtual Store (not durable) mapping vpid to Promise objects, to
|
|
40
|
+
* maintain the slotToVal registration until resolution. Without
|
|
41
|
+
* this, slotToVal would forget local Promises that aren't exported.
|
|
42
|
+
*
|
|
43
|
+
* @type {MapStore<string, Promise<unknown>>}
|
|
44
|
+
*/
|
|
34
45
|
let promiseRegistrations;
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
/**
|
|
48
|
+
* watched promises by vpid: each entry is an array of watches on the
|
|
49
|
+
* corresponding vpid; each of these is in turn an array of a watcher object
|
|
50
|
+
* and the arguments associated with it by `watchPromise`.
|
|
51
|
+
* @type {MapStore<string, PromiseWatcherTuple<unknown>[]>}
|
|
52
|
+
*/
|
|
39
53
|
let watchedPromiseTable;
|
|
40
54
|
|
|
41
|
-
|
|
55
|
+
/**
|
|
56
|
+
* defined promise watcher objects indexed by kindHandle
|
|
57
|
+
*
|
|
58
|
+
* @type {MapStore<import('./vatDataTypes.js').DurableKindHandle, import('./types.js').PromiseWatcher<unknown>>}
|
|
59
|
+
*/
|
|
42
60
|
let promiseWatcherByKindTable;
|
|
43
61
|
|
|
44
62
|
function preparePromiseWatcherTables() {
|
|
@@ -73,11 +91,17 @@ export function makeWatchedPromiseManager({
|
|
|
73
91
|
}
|
|
74
92
|
|
|
75
93
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @param {Promise<
|
|
94
|
+
* @template T
|
|
95
|
+
* @param {Promise<T>} p
|
|
78
96
|
* @param {string} vpid
|
|
97
|
+
* @returns {void}
|
|
79
98
|
*/
|
|
80
99
|
function pseudoThen(p, vpid) {
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {T} value
|
|
103
|
+
* @param {boolean} wasFulfilled
|
|
104
|
+
*/
|
|
81
105
|
function settle(value, wasFulfilled) {
|
|
82
106
|
const watches = watchedPromiseTable.get(vpid);
|
|
83
107
|
watchedPromiseTable.delete(vpid);
|
|
@@ -121,20 +145,28 @@ export function makeWatchedPromiseManager({
|
|
|
121
145
|
}
|
|
122
146
|
}
|
|
123
147
|
|
|
148
|
+
/**
|
|
149
|
+
* @template V
|
|
150
|
+
* @template {any[]} A]
|
|
151
|
+
* @param {import('./vatDataTypes.js').DurableKindHandle} kindHandle
|
|
152
|
+
* @param {(value: V, ...args: A) => void} fulfillHandler
|
|
153
|
+
* @param {(reason: any, ...args: A) => void} rejectHandler
|
|
154
|
+
* @returns {import('./types.js').PromiseWatcher<V, A>}
|
|
155
|
+
*/
|
|
124
156
|
function providePromiseWatcher(
|
|
125
157
|
kindHandle,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
},
|
|
158
|
+
// @ts-expect-error xxx rest params in typedef
|
|
159
|
+
fulfillHandler = _value => {},
|
|
160
|
+
// @ts-expect-error xxx rest params in typedef
|
|
161
|
+
rejectHandler = _reason => {},
|
|
130
162
|
) {
|
|
131
163
|
assert.typeof(fulfillHandler, 'function');
|
|
132
164
|
assert.typeof(rejectHandler, 'function');
|
|
133
165
|
|
|
134
166
|
const makeWatcher = defineDurableKind(kindHandle, initEmpty, {
|
|
135
|
-
|
|
167
|
+
/** @type {(context: unknown, res: V, ...args: A) => void} */
|
|
136
168
|
onFulfilled: (_context, res, ...args) => fulfillHandler(res, ...args),
|
|
137
|
-
|
|
169
|
+
/** @type {(context: unknown, rej: unknown, ...args: A) => void} */
|
|
138
170
|
onRejected: (_context, rej, ...args) => rejectHandler(rej, ...args),
|
|
139
171
|
});
|
|
140
172
|
|
|
@@ -148,10 +180,7 @@ export function makeWatchedPromiseManager({
|
|
|
148
180
|
}
|
|
149
181
|
|
|
150
182
|
/**
|
|
151
|
-
*
|
|
152
|
-
* @param {Promise} p
|
|
153
|
-
* @param {{onFulfilled?: Function, onRejected?: Function}} watcher
|
|
154
|
-
* @param {...any} args
|
|
183
|
+
* @type {<P extends Promise<any>, A extends any[]>(p: P, watcher: import('./types.js').PromiseWatcher<Awaited<P>, A>, ...args: A) => void}
|
|
155
184
|
*/
|
|
156
185
|
function watchPromise(p, watcher, ...args) {
|
|
157
186
|
// The following wrapping defers setting up the promise watcher itself to a
|
package/tools/setup-vat-data.js
CHANGED
|
@@ -23,6 +23,7 @@ globalThis.VatData = harden({
|
|
|
23
23
|
makeKindHandle: tag => fakeVomKit.vom.makeKindHandle(tag),
|
|
24
24
|
canBeDurable: (...args) => fakeVomKit.vom.canBeDurable(...args),
|
|
25
25
|
providePromiseWatcher: (...args) =>
|
|
26
|
+
// @ts-expect-error spread argument for non-rest parameter
|
|
26
27
|
fakeVomKit.wpm.providePromiseWatcher(...args),
|
|
27
28
|
watchPromise: (p, watcher, ...args) =>
|
|
28
29
|
fakeVomKit.wpm.watchPromise(p, watcher, ...args),
|