@agoric/internal 0.4.0 → 0.4.1-upgrade-23-dev-bd79330.0.bd79330
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 +1 -4
- package/package.json +13 -11
- package/src/action-types.d.ts +47 -20
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +19 -19
- package/src/ava-force-exit.d.mts +2 -0
- package/src/ava-force-exit.d.mts.map +1 -0
- package/src/ava-force-exit.mjs +6 -0
- package/src/batched-deliver.d.ts +6 -2
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +7 -3
- package/src/build-cache-types.d.ts +33 -0
- package/src/build-cache-types.d.ts.map +1 -0
- package/src/build-cache-types.js +42 -0
- package/src/build-cache.d.ts +12 -0
- package/src/build-cache.d.ts.map +1 -0
- package/src/build-cache.js +184 -0
- package/src/callback.d.ts +9 -11
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +16 -10
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +0 -2
- package/src/chain-utils.d.ts +3 -1
- package/src/chain-utils.d.ts.map +1 -1
- package/src/chain-utils.js +6 -1
- package/src/config.d.ts +22 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +25 -3
- package/src/debug.d.ts +4 -1
- package/src/debug.d.ts.map +1 -1
- package/src/debug.js +26 -15
- package/src/index.d.ts +2 -1
- package/src/index.js +10 -3
- package/src/js-utils.d.ts +7 -3
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +24 -3
- package/src/keyMirror.d.ts +3 -0
- package/src/keyMirror.d.ts.map +1 -0
- package/src/keyMirror.js +45 -0
- package/src/kv-store.d.ts +33 -0
- package/src/kv-store.d.ts.map +1 -0
- package/src/kv-store.js +257 -0
- package/src/lib-chainStorage.d.ts +23 -12
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +18 -18
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +18 -3
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -1
- package/src/lib-nodejs/ava-unhandled-rejection.js +211 -20
- package/src/lib-nodejs/engine-gc.js +2 -2
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +0 -2
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +8 -7
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +3 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -1
- package/src/lib-nodejs/waitUntilQuiescent.js +5 -1
- package/src/lib-nodejs/worker-protocol.d.ts +1 -1
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
- package/src/lib-nodejs/worker-protocol.js +5 -5
- package/src/magic-cookie-test-only.d.ts.map +1 -1
- package/src/magic-cookie-test-only.js +0 -2
- package/src/marshal/board-client-utils.d.ts +19 -0
- package/src/marshal/board-client-utils.d.ts.map +1 -0
- package/src/{marshal.js → marshal/board-client-utils.js} +27 -52
- package/src/marshal/cap-data.d.ts +11 -0
- package/src/marshal/cap-data.d.ts.map +1 -0
- package/src/marshal/cap-data.js +19 -0
- package/src/marshal/inaccessible-val.d.ts +2 -0
- package/src/marshal/inaccessible-val.d.ts.map +1 -0
- package/src/marshal/inaccessible-val.js +15 -0
- package/src/marshal/pure-data.d.ts +8 -0
- package/src/marshal/pure-data.d.ts.map +1 -0
- package/src/marshal/pure-data.js +14 -0
- package/src/marshal/wrap-marshaller.d.ts +60 -0
- package/src/marshal/wrap-marshaller.d.ts.map +1 -0
- package/src/marshal/wrap-marshaller.js +432 -0
- package/src/module-utils.d.ts +1 -0
- package/src/module-utils.d.ts.map +1 -1
- package/src/module-utils.js +16 -0
- package/src/natural-sort.d.ts.map +1 -1
- package/src/natural-sort.js +48 -13
- package/src/netstring.d.ts +1 -1
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +5 -5
- package/src/node/buffer-line-transform.d.ts +10 -5
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +8 -4
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +3 -5
- package/src/node/fs-stream.d.ts +4 -1
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +58 -9
- package/src/node/read-json.d.ts +2 -0
- package/src/node/read-json.d.ts.map +1 -0
- package/src/node/read-json.js +18 -0
- package/src/node/shutdown.js +1 -1
- package/src/priority-senders.d.ts +2 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +6 -4
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +0 -2
- package/src/ses-utils.d.ts +27 -5
- package/src/ses-utils.d.ts.map +1 -1
- package/src/ses-utils.js +115 -20
- package/src/storage-test-utils.d.ts +15 -5
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +62 -8
- package/src/tagged.d.ts +18 -1
- package/src/testing-utils.d.ts +4 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +88 -2
- package/src/typeGuards.d.ts +6 -2
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +7 -4
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +34 -19
- package/src/types.d.ts.map +1 -1
- package/src/types.js +173 -0
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +4 -3
- package/src/work-pool.d.ts +13 -0
- package/src/work-pool.d.ts.map +1 -0
- package/src/work-pool.js +233 -0
- package/vendor/anylogger.d.ts +98 -0
- package/vendor/anylogger.d.ts.map +1 -0
- package/vendor/anylogger.js +60 -0
- package/vendor/anylogger.ts +160 -0
- package/vendor/tsconfig.anylogger.json +15 -0
- package/exported.js +0 -2
- package/src/marshal.d.ts +0 -33
- package/src/marshal.d.ts.map +0 -1
- package/src/types.ts +0 -129
|
@@ -1,54 +1,186 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { spawn } from 'child_process';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
4
|
|
|
5
5
|
import engineGC from './engine-gc.js';
|
|
6
6
|
import { makeGcAndFinalize } from './gc-and-finalize.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @import {ExecutionContext, Macro, TestFn} from 'ava';
|
|
9
|
+
* @import {ExecutionContext, ImplementationFn, Macro, MacroDeclarationOptions,TestFn} from 'ava';
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** Not an official AVA feature, so prefix with `AGORIC_` */
|
|
13
|
+
export const AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS =
|
|
13
14
|
'AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS';
|
|
15
|
+
/** Backwards compatibility... */
|
|
16
|
+
export const AVA_EXPECT_UNHANDLED_REJECTIONS =
|
|
17
|
+
AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS;
|
|
18
|
+
|
|
19
|
+
const delayTurn = () => new Promise(resolve => setImmediate(resolve));
|
|
20
|
+
const settleUnhandled = async () => {
|
|
21
|
+
await delayTurn();
|
|
22
|
+
await delayTurn();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const stripListeners = event => {
|
|
26
|
+
const listeners = process.listeners(event);
|
|
27
|
+
for (const listener of listeners) {
|
|
28
|
+
process.off(event, listener);
|
|
29
|
+
}
|
|
30
|
+
return () => {
|
|
31
|
+
for (const listener of listeners) {
|
|
32
|
+
process.on(event, listener);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const makeUnhandledTracker = () => {
|
|
38
|
+
let unhandled = 0;
|
|
39
|
+
let seenUnhandled = 0;
|
|
40
|
+
const pending = new Set();
|
|
41
|
+
const handledLate = new Set();
|
|
42
|
+
const tokenByPromise = new WeakMap();
|
|
43
|
+
// Finalization callbacks run on the main thread; `pending` is only mutated
|
|
44
|
+
// here and after the flushes in countUnhandled, so no extra synchronization
|
|
45
|
+
// is required.
|
|
46
|
+
const registry = new FinalizationRegistry(token => {
|
|
47
|
+
if (pending.delete(token)) {
|
|
48
|
+
// Don't count promises that were handled late.
|
|
49
|
+
if (!handledLate.delete(token)) {
|
|
50
|
+
unhandled += 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
14
54
|
|
|
15
|
-
|
|
55
|
+
const onUnhandled = (_reason, promise) => {
|
|
56
|
+
seenUnhandled += 1;
|
|
57
|
+
const token = Symbol('unhandledRejection');
|
|
58
|
+
tokenByPromise.set(promise, token);
|
|
59
|
+
pending.add(token);
|
|
60
|
+
registry.register(promise, token, token);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onHandledLate = promise => {
|
|
64
|
+
const token = tokenByPromise.get(promise);
|
|
65
|
+
tokenByPromise.delete(promise);
|
|
66
|
+
// Mark this token as handled late so it won't be counted when the
|
|
67
|
+
// finalizer runs. We remove it from `pending` to exclude it from
|
|
68
|
+
// the pending count, and track it in `handledLate` to avoid counting
|
|
69
|
+
// it when GC'd.
|
|
70
|
+
if (token && pending.delete(token)) {
|
|
71
|
+
handledLate.add(token);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const snapshot = () => ({ unhandled, pending: pending.size, seenUnhandled });
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
onUnhandled,
|
|
79
|
+
onHandledLate,
|
|
80
|
+
snapshot,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
16
83
|
|
|
17
84
|
/**
|
|
85
|
+
* Count unhandled rejections for the given work by running it after removing
|
|
86
|
+
* any existing listeners (like AVA's) and waiting for GC/finalization.
|
|
87
|
+
*
|
|
88
|
+
* @param {() => any | Promise<any>} work
|
|
89
|
+
* @param {object} powers
|
|
90
|
+
* @param {() => Promise<void>} powers.gcAndFinalize
|
|
91
|
+
*/
|
|
92
|
+
export const countUnhandled = async (work, { gcAndFinalize }) => {
|
|
93
|
+
await null; // for Jessie
|
|
94
|
+
const tracker = makeUnhandledTracker();
|
|
95
|
+
const restoreUnhandled = stripListeners('unhandledRejection');
|
|
96
|
+
const restoreHandled = stripListeners('rejectionHandled');
|
|
97
|
+
const flushUnhandled = async () => {
|
|
98
|
+
await settleUnhandled();
|
|
99
|
+
await gcAndFinalize();
|
|
100
|
+
};
|
|
101
|
+
process.on('unhandledRejection', tracker.onUnhandled);
|
|
102
|
+
process.on('rejectionHandled', tracker.onHandledLate);
|
|
103
|
+
try {
|
|
104
|
+
await work();
|
|
105
|
+
} finally {
|
|
106
|
+
// Two passes through settle+GC help ensure finalizers run before we snapshot
|
|
107
|
+
// the unhandled state across Node/XS runtimes, even when callbacks queue
|
|
108
|
+
// additional macrotasks. This count happens after the flushes so finalizer
|
|
109
|
+
// timing cannot race the snapshot.
|
|
110
|
+
await flushUnhandled();
|
|
111
|
+
await flushUnhandled();
|
|
112
|
+
await settleUnhandled();
|
|
113
|
+
process.off('unhandledRejection', tracker.onUnhandled);
|
|
114
|
+
process.off('rejectionHandled', tracker.onHandledLate);
|
|
115
|
+
restoreUnhandled();
|
|
116
|
+
restoreHandled();
|
|
117
|
+
}
|
|
118
|
+
return tracker.snapshot();
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated Use `makeExpectUnhandledRejectionMacro` instead, which uses the
|
|
123
|
+
* test's first argument title instead of an explicit `name`, and can
|
|
124
|
+
* optionally wrap an inner `Macro`.
|
|
125
|
+
*
|
|
18
126
|
* @template C
|
|
19
127
|
* @param {object} powers
|
|
20
128
|
* @param {TestFn<C>} powers.test
|
|
129
|
+
* @param {boolean} [powers.sameWorker]
|
|
21
130
|
* @param {string} powers.importMetaUrl
|
|
22
|
-
* @returns {(
|
|
23
|
-
*
|
|
24
|
-
* ) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>}
|
|
131
|
+
* @returns {( expectedUnhandled: number) => Macro<[name: string, impl: (t:
|
|
132
|
+
* ExecutionContext<C>) => any], C>}
|
|
25
133
|
*/
|
|
26
|
-
export const makeExpectUnhandledRejection = ({
|
|
134
|
+
export const makeExpectUnhandledRejection = ({
|
|
135
|
+
test,
|
|
136
|
+
sameWorker = false,
|
|
137
|
+
importMetaUrl,
|
|
138
|
+
}) => {
|
|
27
139
|
const self = fileURLToPath(importMetaUrl);
|
|
28
140
|
const gcAndFinalize = makeGcAndFinalize(engineGC);
|
|
29
141
|
|
|
30
|
-
if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
|
|
31
|
-
|
|
142
|
+
if (sameWorker || process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
|
|
143
|
+
let mutex = Promise.resolve();
|
|
144
|
+
return expectedUnhandled =>
|
|
32
145
|
test.macro({
|
|
33
|
-
title: (
|
|
146
|
+
title: (_providedTitle = '', name, _impl) => name,
|
|
34
147
|
exec: async (t, _name, impl) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
148
|
+
const rawExpected =
|
|
149
|
+
(sameWorker
|
|
150
|
+
? undefined
|
|
151
|
+
: process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) ||
|
|
152
|
+
expectedUnhandled;
|
|
153
|
+
const expected = Number(rawExpected);
|
|
154
|
+
if (!Number.isSafeInteger(expected) || expected < 0) {
|
|
155
|
+
t.fail(
|
|
156
|
+
`expected unhandled rejection count to be a natural number, got ${rawExpected}`,
|
|
157
|
+
);
|
|
41
158
|
}
|
|
159
|
+
const nextP = mutex.then(async () => {
|
|
160
|
+
const { unhandled, pending, seenUnhandled } = await countUnhandled(
|
|
161
|
+
() => impl(t),
|
|
162
|
+
{ gcAndFinalize },
|
|
163
|
+
);
|
|
164
|
+
const totalUnhandled = unhandled + pending;
|
|
165
|
+
if (totalUnhandled !== expected) {
|
|
166
|
+
t.fail(
|
|
167
|
+
`expected ${expected} unhandled promise rejections, got ${totalUnhandled} (of ${seenUnhandled} seen, ${pending} pending finalization)`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
mutex = nextP.catch(() => {}); // don't let a failure block the next test
|
|
172
|
+
await nextP;
|
|
42
173
|
},
|
|
43
174
|
});
|
|
44
175
|
}
|
|
45
176
|
|
|
46
177
|
return expectedUnhandled =>
|
|
47
178
|
test.macro({
|
|
48
|
-
title: (
|
|
179
|
+
title: (_providedTitle = '', name, _impl) =>
|
|
180
|
+
`${name} (unhandled: ${expectedUnhandled})`,
|
|
49
181
|
exec: async (t, name, _impl) =>
|
|
50
182
|
new Promise((resolve, reject) => {
|
|
51
|
-
const ps = spawn('ava', [self, '
|
|
183
|
+
const ps = spawn('ava', [self, '--match', name], {
|
|
52
184
|
env: {
|
|
53
185
|
...process.env,
|
|
54
186
|
[AVA_EXPECT_UNHANDLED_REJECTIONS]: `${expectedUnhandled}`,
|
|
@@ -64,3 +196,62 @@ export const makeExpectUnhandledRejection = ({ test, importMetaUrl }) => {
|
|
|
64
196
|
}),
|
|
65
197
|
});
|
|
66
198
|
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @template [C=unknown]
|
|
202
|
+
* @param {object} powers
|
|
203
|
+
* @param {TestFn<C>} powers.test
|
|
204
|
+
* @param {boolean} [powers.sameWorker] defaults to require in-process execution
|
|
205
|
+
* @param {string} powers.importMetaUrl
|
|
206
|
+
*/
|
|
207
|
+
export const makeExpectUnhandledRejectionMacro = ({
|
|
208
|
+
test,
|
|
209
|
+
sameWorker = true,
|
|
210
|
+
importMetaUrl,
|
|
211
|
+
}) => {
|
|
212
|
+
const expectUnhandledRejection = makeExpectUnhandledRejection({
|
|
213
|
+
test,
|
|
214
|
+
sameWorker,
|
|
215
|
+
importMetaUrl,
|
|
216
|
+
});
|
|
217
|
+
/**
|
|
218
|
+
* @template {any[]} [A=[ImplementationFn<any[], any>, ...any[]]]
|
|
219
|
+
* @param {number} numUnhandled
|
|
220
|
+
* @param {Macro<A, C>} [innerMacro]
|
|
221
|
+
* @returns {Macro<A, C>}
|
|
222
|
+
*/
|
|
223
|
+
return (numUnhandled, innerMacro) => {
|
|
224
|
+
const expector = expectUnhandledRejection(numUnhandled);
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @param {ExecutionContext<C>} _t
|
|
228
|
+
* @param {A} args
|
|
229
|
+
* @returns {(t: ExecutionContext<C>) => any}
|
|
230
|
+
*/
|
|
231
|
+
const makeImpl = (_t, args) =>
|
|
232
|
+
innerMacro
|
|
233
|
+
? async t => innerMacro.exec(t, ...args)
|
|
234
|
+
: t => (0, args[0])(t, ...args);
|
|
235
|
+
|
|
236
|
+
/** @type {string} */
|
|
237
|
+
return test.macro(
|
|
238
|
+
/** @type {MacroDeclarationOptions<A, C>} */ ({
|
|
239
|
+
title(providedTitle = '', ...args) {
|
|
240
|
+
let expectorName =
|
|
241
|
+
innerMacro?.title?.(providedTitle, ...args) ?? providedTitle;
|
|
242
|
+
const impl = () => {};
|
|
243
|
+
if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
|
|
244
|
+
expectorName =
|
|
245
|
+
expector.title?.(expectorName, expectorName, impl) ??
|
|
246
|
+
expectorName;
|
|
247
|
+
}
|
|
248
|
+
return expectorName;
|
|
249
|
+
},
|
|
250
|
+
async exec(t, ...args) {
|
|
251
|
+
const impl = makeImpl(t, args);
|
|
252
|
+
return expector.exec(t, t.title, impl);
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
};
|
|
257
|
+
};
|
|
@@ -10,6 +10,4 @@ export function startSubprocessWorker(execPath: any, procArgs?: any[], { netstri
|
|
|
10
10
|
terminate: () => void;
|
|
11
11
|
done: Promise<any>;
|
|
12
12
|
};
|
|
13
|
-
export type IOType = import("child_process").IOType;
|
|
14
|
-
export type Writable = import("stream").Writable;
|
|
15
13
|
//# sourceMappingURL=spawnSubprocessWorker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawnSubprocessWorker.d.ts","sourceRoot":"","sources":["spawnSubprocessWorker.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spawnSubprocessWorker.d.ts","sourceRoot":"","sources":["spawnSubprocessWorker.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;EA0DC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// this file is loaded by the controller, in the start compartment
|
|
2
|
-
import { spawn } from 'child_process';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
3
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
4
4
|
import { NonNullish } from '../errors.js';
|
|
5
5
|
import { arrayEncoderStream, arrayDecoderStream } from './worker-protocol.js';
|
|
@@ -8,19 +8,20 @@ import {
|
|
|
8
8
|
netstringDecoderStream,
|
|
9
9
|
} from '../netstring.js';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @import {IOType} from 'child_process'
|
|
13
|
+
* @import {Writable} from 'stream'
|
|
14
|
+
*/
|
|
15
|
+
|
|
11
16
|
// Start a subprocess from a given executable, and arrange a bidirectional
|
|
12
17
|
// message channel with a "supervisor" within that process. Return a {
|
|
13
18
|
// toChild, fromChild } pair of Streams which accept/emit hardened Arrays of
|
|
14
19
|
// JSON-serializable data.
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// console.error(`--parent: ${first}`, ...args);
|
|
21
|
+
function parentLog(_first, ..._args) {
|
|
22
|
+
// console.error(`--parent: ${_first}`, ..._args);
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
/** @typedef {import('child_process').IOType} IOType */
|
|
22
|
-
/** @typedef {import('stream').Writable} Writable */
|
|
23
|
-
|
|
24
25
|
// we send on fd3, and receive on fd4. We pass fd1/2 (stdout/err) through, so
|
|
25
26
|
// console log/err from the child shows up normally. We don't use Node's
|
|
26
27
|
// built-in serialization feature ('ipc') because the child process won't
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitUntilQuiescent.d.ts","sourceRoot":"","sources":["waitUntilQuiescent.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"waitUntilQuiescent.d.ts","sourceRoot":"","sources":["waitUntilQuiescent.js"],"names":[],"mappings":"AAGA;;GAEG;AAKH,oDAWC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* global setImmediate */
|
|
2
2
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {PromiseKit} from '@endo/promise-kit';
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
// This can only be imported from the Start Compartment, where 'setImmediate'
|
|
5
9
|
// is available.
|
|
6
10
|
|
|
@@ -11,7 +15,7 @@ export function waitUntilQuiescent() {
|
|
|
11
15
|
// lower-priority than the Promise queue on browsers and Node 11, but on
|
|
12
16
|
// Node 10 it is higher. So this trick requires Node 11.
|
|
13
17
|
// https://jsblog.insiderattack.net/new-changes-to-timers-and-microtasks-from-node-v11-0-0-and-above-68d112743eb3
|
|
14
|
-
/** @type {
|
|
18
|
+
/** @type {PromiseKit<void>} */
|
|
15
19
|
const { promise: queueEmptyP, resolve } = makePromiseKit();
|
|
16
20
|
setImmediate(() => resolve());
|
|
17
21
|
return queueEmptyP;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["worker-protocol.js"],"names":[],"mappings":"AAMA,gDAqBC;AAED,gDAwBC;0BApDyB,
|
|
1
|
+
{"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["worker-protocol.js"],"names":[],"mappings":"AAMA,gDAqBC;AAED,gDAwBC;0BApDyB,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-env node */
|
|
2
|
-
import { Transform } from 'stream';
|
|
2
|
+
import { Transform } from 'node:stream';
|
|
3
3
|
|
|
4
4
|
// Transform objects which convert from hardened Arrays of JSON-serializable
|
|
5
5
|
// data into Buffers suitable for netstring conversion.
|
|
@@ -7,11 +7,11 @@ import { Transform } from 'stream';
|
|
|
7
7
|
export function arrayEncoderStream() {
|
|
8
8
|
/**
|
|
9
9
|
* @param {any} object
|
|
10
|
-
* @param {BufferEncoding}
|
|
10
|
+
* @param {BufferEncoding} _encoding
|
|
11
11
|
* @param {any} callback
|
|
12
12
|
* @this {{ push: (b: Buffer) => void }}
|
|
13
13
|
*/
|
|
14
|
-
function transform(object,
|
|
14
|
+
function transform(object, _encoding, callback) {
|
|
15
15
|
if (!Array.isArray(object)) {
|
|
16
16
|
throw Error('stream requires Arrays');
|
|
17
17
|
}
|
|
@@ -30,11 +30,11 @@ export function arrayEncoderStream() {
|
|
|
30
30
|
export function arrayDecoderStream() {
|
|
31
31
|
/**
|
|
32
32
|
* @param {Buffer} buf
|
|
33
|
-
* @param {BufferEncoding}
|
|
33
|
+
* @param {BufferEncoding} _encoding
|
|
34
34
|
* @param {any} callback
|
|
35
35
|
* @this {{ push: (b: Buffer) => void }}
|
|
36
36
|
*/
|
|
37
|
-
function transform(buf,
|
|
37
|
+
function transform(buf, _encoding, callback) {
|
|
38
38
|
let err;
|
|
39
39
|
try {
|
|
40
40
|
if (!Buffer.isBuffer(buf)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-cookie-test-only.d.ts","sourceRoot":"","sources":["magic-cookie-test-only.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"magic-cookie-test-only.d.ts","sourceRoot":"","sources":["magic-cookie-test-only.js"],"names":[],"mappings":"AAMO,0CAEN"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function makeBoardRemote<BoardId = string | null>({ boardId, iface }: {
|
|
2
|
+
boardId: BoardId;
|
|
3
|
+
iface?: string;
|
|
4
|
+
}): BoardRemote<BoardId>;
|
|
5
|
+
export function slotToBoardRemote<BoardId = string>(boardId: BoardId, iface: string): BoardRemote<BoardId>;
|
|
6
|
+
export function boardSlottingMarshaller<BoardId = string | null>(slotToVal?: (slot: BoardId, iface: string) => any): Omit<Marshal<BoardId>, "serialize" | "unserialize">;
|
|
7
|
+
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: FromCapData<string>, index: number): any;
|
|
8
|
+
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): {
|
|
9
|
+
getItem: (key: string) => any;
|
|
10
|
+
children: (prefix: string) => string[];
|
|
11
|
+
has: (k: string) => boolean;
|
|
12
|
+
};
|
|
13
|
+
export type BoardRemote<BoardId = string | null> = {
|
|
14
|
+
getBoardId: () => BoardId;
|
|
15
|
+
} & RemotableObject;
|
|
16
|
+
import type { Marshal } from '@endo/marshal';
|
|
17
|
+
import type { FromCapData } from '@endo/marshal';
|
|
18
|
+
import type { RemotableObject } from '@endo/pass-style';
|
|
19
|
+
//# sourceMappingURL=board-client-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-client-utils.d.ts","sourceRoot":"","sources":["board-client-utils.js"],"names":[],"mappings":"AAsBO,gCAJO,OAAO,sCACV;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,WAAW,CAAC,OAAO,CAAC,CAKhC;AAOM,kCAJO,OAAO,oBACV,OAAO,SACP,MAAM,wBAGoB;AAsB9B,wCAJO,OAAO,8BACV,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GACnC,IAAI,CAAC,QAAQ,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAU/D;AAYM,4CAPI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,YAAY,MAAM,CAAC,SACnB,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAClB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;wBArHa,OAAO,oBACR;IAAE,UAAU,EAAE,MAAM,OAAO,CAAA;CAAE,GAAG,eAAe;6BALM,eAAe;iCAAf,eAAe;qCAD/C,kBAAkB"}
|
|
@@ -2,24 +2,23 @@
|
|
|
2
2
|
import { Fail } from '@endo/errors';
|
|
3
3
|
import { Far } from '@endo/far';
|
|
4
4
|
import { makeMarshal } from '@endo/marshal';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { isStreamCell } from '../lib-chainStorage.js';
|
|
6
|
+
import { assertCapData } from './cap-data.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @import {
|
|
10
|
-
* @import {
|
|
9
|
+
* @import {RemotableObject} from '@endo/pass-style';
|
|
10
|
+
* @import {CapData, FromCapData, ConvertValToSlot, Marshal} from '@endo/marshal';
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @typedef {{ getBoardId: () => string | null }} BoardRemote
|
|
14
|
+
* @template [BoardId=(string | null)]
|
|
15
|
+
* @typedef {{ getBoardId: () => BoardId } & RemotableObject} BoardRemote
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
19
|
+
* @template [BoardId=(string | null)]
|
|
20
|
+
* @param {{ boardId: BoardId; iface?: string }} slotInfo
|
|
21
|
+
* @returns {BoardRemote<BoardId>}
|
|
23
22
|
*/
|
|
24
23
|
export const makeBoardRemote = ({ boardId, iface }) => {
|
|
25
24
|
const nonalleged = iface ? iface.replace(/^Alleged: /, '') : '';
|
|
@@ -27,13 +26,17 @@ export const makeBoardRemote = ({ boardId, iface }) => {
|
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
|
-
* @
|
|
29
|
+
* @template [BoardId=string]
|
|
30
|
+
* @param {BoardId} boardId
|
|
31
31
|
* @param {string} iface
|
|
32
32
|
*/
|
|
33
33
|
export const slotToBoardRemote = (boardId, iface) =>
|
|
34
34
|
makeBoardRemote({ boardId, iface });
|
|
35
35
|
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* @param {BoardRemote<any> | object} val
|
|
38
|
+
* @returns {val extends BoardRemote<infer BoardId> ? BoardId : never}
|
|
39
|
+
*/
|
|
37
40
|
const boardValToSlot = val => {
|
|
38
41
|
if ('getBoardId' in val) {
|
|
39
42
|
return val.getBoardId();
|
|
@@ -46,47 +49,26 @@ const boardValToSlot = val => {
|
|
|
46
49
|
* allows the caller to pick their slots. The deserializer is configurable: the
|
|
47
50
|
* default cannot handle Remotable-bearing data.
|
|
48
51
|
*
|
|
49
|
-
* @
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
52
|
-
* 'serialize' | 'unserialize'
|
|
53
|
-
* >}
|
|
52
|
+
* @template [BoardId=(string | null)]
|
|
53
|
+
* @param {(slot: BoardId, iface: string) => any} [slotToVal]
|
|
54
|
+
* @returns {Omit<Marshal<BoardId>, 'serialize' | 'unserialize'>}
|
|
54
55
|
*/
|
|
55
56
|
export const boardSlottingMarshaller = (slotToVal = undefined) => {
|
|
56
|
-
return makeMarshal(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* @type {TypedPattern<CapData<any>>}
|
|
64
|
-
*/
|
|
65
|
-
export const CapDataShape = { body: M.string(), slots: M.array() };
|
|
66
|
-
harden(CapDataShape);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Assert that this is CapData
|
|
70
|
-
*
|
|
71
|
-
* @param {unknown} data
|
|
72
|
-
* @returns {asserts data is CapData<unknown>}
|
|
73
|
-
*/
|
|
74
|
-
export const assertCapData = data => {
|
|
75
|
-
assert.typeof(data, 'object');
|
|
76
|
-
assert(data);
|
|
77
|
-
typeof data.body === 'string' || Fail`data has non-string .body ${data.body}`;
|
|
78
|
-
Array.isArray(data.slots) || Fail`data has non-Array slots ${data.slots}`;
|
|
57
|
+
return makeMarshal(
|
|
58
|
+
/** @type {ConvertValToSlot<BoardId>} */ (boardValToSlot),
|
|
59
|
+
slotToVal,
|
|
60
|
+
{
|
|
61
|
+
serializeBodyFormat: 'smallcaps',
|
|
62
|
+
},
|
|
63
|
+
);
|
|
79
64
|
};
|
|
80
|
-
harden(assertCapData);
|
|
81
65
|
|
|
82
66
|
/**
|
|
83
67
|
* Read and unmarshal a value from a map representation of vstorage data
|
|
84
68
|
*
|
|
85
69
|
* @param {Map<string, string>} data
|
|
86
70
|
* @param {string} key
|
|
87
|
-
* @param {
|
|
88
|
-
* typeof import('@endo/marshal').makeMarshal
|
|
89
|
-
* >['fromCapData']} fromCapData
|
|
71
|
+
* @param {FromCapData<string>} fromCapData
|
|
90
72
|
* @param {number} index index of the desired value in a deserialized stream
|
|
91
73
|
* cell
|
|
92
74
|
* @returns {any}
|
|
@@ -107,7 +89,7 @@ export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
|
|
|
107
89
|
const marshalled = values.at(index);
|
|
108
90
|
assert.typeof(marshalled, 'string');
|
|
109
91
|
|
|
110
|
-
/** @type {
|
|
92
|
+
/** @type {CapData<string>} */
|
|
111
93
|
const capData = harden(JSON.parse(marshalled));
|
|
112
94
|
assertCapData(capData);
|
|
113
95
|
|
|
@@ -147,10 +129,3 @@ export const makeHistoryReviver = (entries, slotToVal = undefined) => {
|
|
|
147
129
|
|
|
148
130
|
return harden({ getItem, children, has });
|
|
149
131
|
};
|
|
150
|
-
|
|
151
|
-
/** @param {import('@endo/marshal').CapData<unknown>} cap */
|
|
152
|
-
const rejectOCap = cap => Fail`${cap} is not pure data`;
|
|
153
|
-
export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, {
|
|
154
|
-
serializeBodyFormat: 'smallcaps',
|
|
155
|
-
});
|
|
156
|
-
harden(pureDataMarshaller);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {CapData} from '@endo/marshal';
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Assert that this is CapData
|
|
6
|
+
*
|
|
7
|
+
* @type {(data: unknown) => asserts data is CapData<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export const assertCapData: (data: unknown) => asserts data is CapData<unknown>;
|
|
10
|
+
import type { CapData } from '@endo/marshal';
|
|
11
|
+
//# sourceMappingURL=cap-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cap-data.d.ts","sourceRoot":"","sources":["cap-data.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;GAIG;AACH,4BAFU,CAAC,IAAI,EAAE,OAAO,KAAK,QAAQ,IAAI,IAAI,QAAQ,OAAO,CAAC,CAO3D;6BAbwB,eAAe"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Fail } from '@endo/errors';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @import {CapData} from '@endo/marshal';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Assert that this is CapData
|
|
10
|
+
*
|
|
11
|
+
* @type {(data: unknown) => asserts data is CapData<unknown>}
|
|
12
|
+
*/
|
|
13
|
+
export const assertCapData = data => {
|
|
14
|
+
assert.typeof(data, 'object');
|
|
15
|
+
assert(data);
|
|
16
|
+
typeof data.body === 'string' || Fail`data has non-string .body ${data.body}`;
|
|
17
|
+
Array.isArray(data.slots) || Fail`data has non-Array slots ${data.slots}`;
|
|
18
|
+
};
|
|
19
|
+
harden(assertCapData);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inaccessible-val.d.ts","sourceRoot":"","sources":["inaccessible-val.js"],"names":[],"mappings":"AASO,2CAHI,MAAM,GAAG,SAAS,GAChB,GAAG,CAOf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Far } from '@endo/far';
|
|
3
|
+
|
|
4
|
+
const ifaceAllegedPrefix = 'Alleged: ';
|
|
5
|
+
const ifaceInaccessiblePrefix = 'SEVERED: ';
|
|
6
|
+
/**
|
|
7
|
+
* @param {string | undefined} iface
|
|
8
|
+
* @returns {any}
|
|
9
|
+
*/
|
|
10
|
+
export const makeInaccessibleVal = iface => {
|
|
11
|
+
if (typeof iface === 'string' && iface.startsWith(ifaceAllegedPrefix)) {
|
|
12
|
+
iface = iface.slice(ifaceAllegedPrefix.length);
|
|
13
|
+
}
|
|
14
|
+
return Far(`${ifaceInaccessiblePrefix}${iface}`, {});
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const pureDataMarshaller: {
|
|
2
|
+
toCapData: import("@endo/marshal").ToCapData<CapData<unknown>>;
|
|
3
|
+
fromCapData: import("@endo/marshal").FromCapData<CapData<unknown>>;
|
|
4
|
+
serialize: import("@endo/marshal").ToCapData<CapData<unknown>>;
|
|
5
|
+
unserialize: import("@endo/marshal").FromCapData<CapData<unknown>>;
|
|
6
|
+
};
|
|
7
|
+
import type { CapData } from '@endo/marshal';
|
|
8
|
+
//# sourceMappingURL=pure-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure-data.d.ts","sourceRoot":"","sources":["pure-data.js"],"names":[],"mappings":"AAUA;;;;;EAEG;6BAPuB,eAAe"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Fail } from '@endo/errors';
|
|
3
|
+
import { makeMarshal } from '@endo/marshal';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @import {CapData} from '@endo/marshal';
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @param {CapData<unknown>} cap */
|
|
10
|
+
const rejectOCap = cap => Fail`${cap} is not pure data`;
|
|
11
|
+
export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, {
|
|
12
|
+
serializeBodyFormat: 'smallcaps',
|
|
13
|
+
});
|
|
14
|
+
harden(pureDataMarshaller);
|