@agoric/internal 0.3.3-other-dev-d15096d.0.d15096d → 0.3.3-other-dev-ecf44df.0.ecf44df
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 +32 -36
- package/src/action-types.d.ts +47 -20
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +21 -21
- 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 +7 -0
- package/src/batched-deliver.d.ts +2 -2
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +2 -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 +1 -1
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +1 -0
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +0 -2
- package/src/config.d.ts +3 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +6 -5
- package/src/debug.d.ts +2 -2
- package/src/debug.d.ts.map +1 -1
- package/src/debug.js +19 -5
- package/src/hex.d.ts.map +1 -1
- package/src/hex.js +18 -22
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -2
- package/src/js-utils.d.ts +17 -2
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +49 -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 +265 -0
- package/src/lib-chainStorage.d.ts +25 -42
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +38 -14
- 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 +217 -20
- package/src/lib-nodejs/engine-gc.js +2 -2
- package/src/lib-nodejs/gc-and-finalize.d.ts +2 -1
- package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -1
- package/src/lib-nodejs/gc-and-finalize.js +1 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +11 -4
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +14 -4
- 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 -6
- 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.map +1 -1
- package/src/marshal/board-client-utils.js +4 -1
- package/src/marshal/cap-data.d.ts +9 -1
- package/src/marshal/cap-data.d.ts.map +1 -1
- package/src/marshal/cap-data.js +1 -2
- package/src/marshal/wrap-marshaller.d.ts +34 -7
- package/src/marshal/wrap-marshaller.d.ts.map +1 -1
- package/src/marshal/wrap-marshaller.js +64 -68
- package/src/metrics.d.ts +1 -4
- package/src/metrics.d.ts.map +1 -1
- package/src/metrics.js +7 -2
- package/src/module-utils.d.ts +1 -0
- package/src/module-utils.d.ts.map +1 -1
- package/src/module-utils.js +17 -0
- package/src/natural-sort.d.ts.map +1 -1
- package/src/natural-sort.js +7 -3
- package/src/netstring.d.ts +1 -1
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +5 -6
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +0 -1
- package/src/node/createBundles.d.ts +7 -3
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +31 -10
- package/src/node/fs-stream.d.ts +8 -5
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +120 -8
- 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 +16 -0
- package/src/node/shutdown.d.ts +6 -2
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +9 -3
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +1 -0
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +10 -2
- package/src/scratch.d.ts +32 -10
- package/src/scratch.d.ts.map +1 -1
- package/src/scratch.js +11 -0
- package/src/ses-utils.d.ts +14 -3
- package/src/ses-utils.d.ts.map +1 -1
- package/src/ses-utils.js +13 -15
- package/src/storage-test-utils.d.ts +4 -11
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +16 -14
- package/src/tagged.d.ts +18 -1
- package/src/testing-utils.d.ts +22 -1
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +131 -6
- package/src/tmpDir.d.ts.map +1 -1
- package/src/tmpDir.js +1 -1
- package/src/typeCheck.d.ts +4 -8
- package/src/typeCheck.d.ts.map +1 -1
- package/src/typeCheck.js +13 -6
- package/src/typeGuards.d.ts +5 -5
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +4 -5
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +41 -14
- package/src/types.d.ts.map +1 -1
- package/src/types.js +161 -0
- package/src/upgrade-api.d.ts +2 -2
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +4 -3
- package/src/work-pool.d.ts.map +1 -1
- package/src/work-pool.js +9 -2
- 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/types.ts +0 -133
package/src/node/fs-stream.js
CHANGED
|
@@ -3,13 +3,16 @@ import process from 'node:process';
|
|
|
3
3
|
import { promisify } from 'node:util';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @import {ReadStream} from 'fs';
|
|
7
|
-
* @import {
|
|
8
|
-
* @import {Socket} from 'net';
|
|
6
|
+
* @import {ReadStream, WriteStream} from 'node:fs';
|
|
7
|
+
* @import {Socket} from 'node:net';
|
|
9
8
|
*/
|
|
10
9
|
|
|
10
|
+
/** @typedef {ReadStream | WriteStream | Socket} StreamLike */
|
|
11
|
+
/** @typedef {'drain' | 'ready'} EventName */
|
|
12
|
+
/** @typedef {boolean} WriteBufferIsFull */
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
|
-
* @param {
|
|
15
|
+
* @param {StreamLike} stream
|
|
13
16
|
* @returns {Promise<void>}
|
|
14
17
|
*/
|
|
15
18
|
export const fsStreamReady = stream =>
|
|
@@ -44,6 +47,111 @@ export const fsStreamReady = stream =>
|
|
|
44
47
|
stream.on('error', onError);
|
|
45
48
|
});
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Subscribe fresh listeners for a single stream event and reject on stream
|
|
52
|
+
* error first.
|
|
53
|
+
*
|
|
54
|
+
* @param {StreamLike} stream
|
|
55
|
+
* @param {EventName} eventName
|
|
56
|
+
* @param {() => void} [onCleanup] called when the event is emitted or an error occurs, after listeners are removed
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
*/
|
|
59
|
+
const subscribeOnceWithError = (stream, eventName, onCleanup = () => {}) =>
|
|
60
|
+
new Promise((resolve, reject) => {
|
|
61
|
+
const onEvent = () => {
|
|
62
|
+
cleanup();
|
|
63
|
+
resolve();
|
|
64
|
+
};
|
|
65
|
+
/** @param {Error} err */
|
|
66
|
+
const onError = err => {
|
|
67
|
+
cleanup();
|
|
68
|
+
reject(err);
|
|
69
|
+
};
|
|
70
|
+
const cleanup = () => {
|
|
71
|
+
stream.off(eventName, onEvent);
|
|
72
|
+
stream.off('error', onError);
|
|
73
|
+
onCleanup();
|
|
74
|
+
};
|
|
75
|
+
stream.on(eventName, onEvent);
|
|
76
|
+
stream.on('error', onError);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Memoize promises to prevent multiple subscriptions to the same event on the
|
|
81
|
+
* same stream. This is necessary to prevent:
|
|
82
|
+
*
|
|
83
|
+
* (node:1224) MaxListenersExceededWarning: Possible EventEmitter memory leak
|
|
84
|
+
* detected. 11 drain listeners added to [WriteStream]. MaxListeners is 10. Use
|
|
85
|
+
* emitter.setMaxListeners() to increase limit
|
|
86
|
+
*
|
|
87
|
+
* @param {(stream: StreamLike,
|
|
88
|
+
* eventName: EventName, onDone?: () => void) => Promise<void>} doOnceWithError
|
|
89
|
+
* @returns {(stream: StreamLike,
|
|
90
|
+
* eventName: EventName) => Promise<void>}
|
|
91
|
+
*/
|
|
92
|
+
const makeMemoizedOnceWithError = doOnceWithError => {
|
|
93
|
+
/**
|
|
94
|
+
* @type {Map<string, WeakMap<StreamLike, Promise<void>>>}
|
|
95
|
+
*/
|
|
96
|
+
const promiseFromEventAndStream = new Map();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Wait for a stream event and reject on stream error first.
|
|
100
|
+
*
|
|
101
|
+
* @param {StreamLike} stream
|
|
102
|
+
* @param {EventName} eventName
|
|
103
|
+
* @returns {Promise<void>}
|
|
104
|
+
*/
|
|
105
|
+
const memoizedOnceWithError = (stream, eventName) => {
|
|
106
|
+
let promiseFromStream = promiseFromEventAndStream.get(eventName);
|
|
107
|
+
if (!promiseFromStream) {
|
|
108
|
+
promiseFromStream = new WeakMap();
|
|
109
|
+
promiseFromEventAndStream.set(eventName, promiseFromStream);
|
|
110
|
+
}
|
|
111
|
+
/** @type {Promise<void> | undefined} */
|
|
112
|
+
let promise = promiseFromStream.get(stream);
|
|
113
|
+
if (promise) {
|
|
114
|
+
return promise;
|
|
115
|
+
}
|
|
116
|
+
promise = doOnceWithError(stream, eventName, () =>
|
|
117
|
+
promiseFromStream.delete(stream),
|
|
118
|
+
);
|
|
119
|
+
promiseFromStream.set(stream, promise);
|
|
120
|
+
return promise;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return memoizedOnceWithError;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Wait for a stream event and reject on stream error first.
|
|
128
|
+
*
|
|
129
|
+
* @param {StreamLike} stream
|
|
130
|
+
* @param {EventName} eventName
|
|
131
|
+
* @returns {Promise<void>}
|
|
132
|
+
*/
|
|
133
|
+
const onceWithError = makeMemoizedOnceWithError(subscribeOnceWithError);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @param {WriteStream | Socket} stream
|
|
137
|
+
* @param {string | Uint8Array} data
|
|
138
|
+
* @returns {Promise<WriteBufferIsFull>} whether caller must await drain
|
|
139
|
+
*/
|
|
140
|
+
const writeChunk = (stream, data) =>
|
|
141
|
+
new Promise((resolve, reject) => {
|
|
142
|
+
try {
|
|
143
|
+
const waitForDrain = !stream.write(data, err => {
|
|
144
|
+
if (err) {
|
|
145
|
+
reject(err);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
resolve(waitForDrain);
|
|
149
|
+
});
|
|
150
|
+
} catch (err) {
|
|
151
|
+
reject(err);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
47
155
|
/** @typedef {NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>} FsStreamWriter */
|
|
48
156
|
/** @param {string | undefined | null} filePath */
|
|
49
157
|
export const makeFsStreamWriter = async filePath => {
|
|
@@ -60,21 +168,24 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
60
168
|
return { handle: fh, stream: fh.createWriteStream({ flush: true }) };
|
|
61
169
|
})();
|
|
62
170
|
await fsStreamReady(stream);
|
|
63
|
-
const
|
|
171
|
+
const waitForDrainAsync = () => onceWithError(stream, 'drain');
|
|
64
172
|
const closeAsync =
|
|
65
173
|
useStdout || !(/** @type {any} */ (stream).close)
|
|
66
174
|
? undefined
|
|
67
175
|
: promisify(/** @type {WriteStream} */ (stream).close.bind(stream));
|
|
68
176
|
|
|
69
|
-
|
|
177
|
+
/** @type {Promise<WriteBufferIsFull>} */
|
|
178
|
+
let flushed = Promise.resolve(false);
|
|
70
179
|
let closed = false;
|
|
71
180
|
|
|
181
|
+
/** @param {Promise<WriteBufferIsFull>} p */
|
|
72
182
|
const updateFlushed = p => {
|
|
73
183
|
flushed = flushed.then(
|
|
74
184
|
() => p,
|
|
75
185
|
err =>
|
|
76
186
|
p.then(
|
|
77
187
|
() => Promise.reject(err),
|
|
188
|
+
/** @param {Error} pError */
|
|
78
189
|
pError =>
|
|
79
190
|
Promise.reject(
|
|
80
191
|
pError !== err ? AggregateError([err, pError]) : err,
|
|
@@ -84,14 +195,15 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
84
195
|
flushed.catch(() => {});
|
|
85
196
|
};
|
|
86
197
|
|
|
198
|
+
/** @param {string | Uint8Array} data */
|
|
87
199
|
const write = async data => {
|
|
88
200
|
const written = closed
|
|
89
201
|
? Promise.reject(Error('Stream closed'))
|
|
90
|
-
:
|
|
202
|
+
: writeChunk(stream, data);
|
|
91
203
|
updateFlushed(written);
|
|
92
204
|
const waitForDrain = await written;
|
|
93
205
|
if (waitForDrain) {
|
|
94
|
-
await
|
|
206
|
+
await waitForDrainAsync();
|
|
95
207
|
}
|
|
96
208
|
};
|
|
97
209
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-json.d.ts","sourceRoot":"","sources":["read-json.js"],"names":[],"mappings":"AAOO,iCAJO,CAAC,sBACJ,IAAI,CAAC,cAAc,kBAAkB,CAAC,EAAE,UAAU,CAAC,mBACnD,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAGlC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAOxC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a function that reads and parses a JSON file.
|
|
3
|
+
*
|
|
4
|
+
* @template [U=ReturnType<typeof JSON.parse>]
|
|
5
|
+
* @param {Pick<typeof import('node:fs/promises'), 'readFile'>} fsp
|
|
6
|
+
* @param {(input: ReturnType<typeof JSON.parse>) => U} [resultReplacer]
|
|
7
|
+
*/
|
|
8
|
+
export const makeReadJsonFile = ({ readFile }, resultReplacer) => {
|
|
9
|
+
/** @type {(path: string) => Promise<U>} */
|
|
10
|
+
const readJsonFile = async path => {
|
|
11
|
+
const text = await readFile(path, 'utf8');
|
|
12
|
+
const result = JSON.parse(text);
|
|
13
|
+
return resultReplacer ? resultReplacer(result) : /** @type {U} */ (result);
|
|
14
|
+
};
|
|
15
|
+
return readJsonFile;
|
|
16
|
+
};
|
package/src/node/shutdown.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export function makeFreshShutdown(verbose?: boolean): {
|
|
2
|
-
|
|
2
|
+
/** @param {(isSigInt: boolean) => unknown} thunk */
|
|
3
|
+
registerShutdown: (thunk: (isSigInt: boolean) => unknown) => () => void;
|
|
4
|
+
};
|
|
5
|
+
export function makeCachedShutdown(verbose?: boolean | undefined): {
|
|
6
|
+
/** @param {(isSigInt: boolean) => unknown} thunk */
|
|
7
|
+
registerShutdown: (thunk: (isSigInt: boolean) => unknown) => () => void;
|
|
3
8
|
};
|
|
4
|
-
export function makeCachedShutdown(...args: any[]): any;
|
|
5
9
|
export { makeCachedShutdown as makeShutdown };
|
|
6
10
|
//# sourceMappingURL=shutdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["shutdown.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["shutdown.js"],"names":[],"mappings":"AAKO;IA4DH,oDAAoD;8BAAxC,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO;EAQ7C;AAKM;IAbH,oDAAoD;8BAAxC,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO;EAoB7C"}
|
package/src/node/shutdown.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import anylogger from 'anylogger';
|
|
2
|
+
import anylogger from '../../vendor/anylogger.js';
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
-
// @ts-ignore TODO remove when anylogger has types
|
|
6
4
|
const console = anylogger('shutdown');
|
|
7
5
|
|
|
8
6
|
export const makeFreshShutdown = (verbose = true) => {
|
|
7
|
+
/** @type {Set<(isSigInt: boolean) => unknown>} */
|
|
9
8
|
const shutdownThunks = new Set();
|
|
10
9
|
|
|
11
10
|
let shuttingDown = false;
|
|
@@ -42,12 +41,16 @@ export const makeFreshShutdown = (verbose = true) => {
|
|
|
42
41
|
.catch(error => verbose && console.warn('Error shutting down', error))
|
|
43
42
|
.finally(() => {
|
|
44
43
|
// Let `beforeExit` exit cleanly
|
|
44
|
+
// `code` may be a signal string; the loose `>=` comparison is
|
|
45
|
+
// intentional. The cast is type-only (erased at runtime), so it
|
|
46
|
+
// preserves the original comparison semantics.
|
|
45
47
|
if (!(code >= 0)) {
|
|
46
48
|
process.exit();
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
};
|
|
50
52
|
|
|
53
|
+
/** @type {NodeJS.UncaughtExceptionListener} */
|
|
51
54
|
const uncaughtShutdown = e => {
|
|
52
55
|
console.error(e);
|
|
53
56
|
shutdown(-1);
|
|
@@ -60,6 +63,7 @@ export const makeFreshShutdown = (verbose = true) => {
|
|
|
60
63
|
process.on('uncaughtException', uncaughtShutdown);
|
|
61
64
|
|
|
62
65
|
return {
|
|
66
|
+
/** @param {(isSigInt: boolean) => unknown} thunk */
|
|
63
67
|
registerShutdown: thunk => {
|
|
64
68
|
shutdownThunks.add(thunk);
|
|
65
69
|
return () => {
|
|
@@ -69,7 +73,9 @@ export const makeFreshShutdown = (verbose = true) => {
|
|
|
69
73
|
};
|
|
70
74
|
};
|
|
71
75
|
|
|
76
|
+
/** @type {ReturnType<typeof makeFreshShutdown> | null} */
|
|
72
77
|
let cachedShutdown = null;
|
|
78
|
+
/** @param {Parameters<typeof makeFreshShutdown>} args */
|
|
73
79
|
export const makeCachedShutdown = (...args) => {
|
|
74
80
|
// It's possible our caller has specified different arguments.
|
|
75
81
|
// Since they control verbosity only, first-one-wins is acceptable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAUA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,KAAK,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAUA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,KAAK,WAAW,CAAC;IA2CxB;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;;IArB1B;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;GAuB7B;qCAGa,UAAU,CAAC,OAAO,0BAA0B,CAAC;iCA3G7B,uBAAuB;0BAD9B,WAAW"}
|
package/src/priority-senders.js
CHANGED
package/src/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAMO,kCAoCqB,OAFf,CAEoB,MAKH,GAAG,MAHlB,UAAU,CAAC,CAAC,CAGU,KAFpB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAmB/C"}
|
package/src/queue.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @jessie-check
|
|
2
|
-
|
|
3
1
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -7,6 +5,15 @@ import { makePromiseKit } from '@endo/promise-kit';
|
|
|
7
5
|
* of them (in order) is running at a time.
|
|
8
6
|
*/
|
|
9
7
|
export const makeWithQueue = () => {
|
|
8
|
+
/**
|
|
9
|
+
* @type {Array<
|
|
10
|
+
* [
|
|
11
|
+
* thunk: (value?: unknown) => unknown,
|
|
12
|
+
* resolve: (value: unknown) => void,
|
|
13
|
+
* reject: (reason?: unknown) => void,
|
|
14
|
+
* ]
|
|
15
|
+
* >}
|
|
16
|
+
*/
|
|
10
17
|
const queue = [];
|
|
11
18
|
|
|
12
19
|
// Execute the thunk at the front of the queue.
|
|
@@ -41,6 +48,7 @@ export const makeWithQueue = () => {
|
|
|
41
48
|
return function queueCall(...args) {
|
|
42
49
|
// Curry the arguments into the inner function, and
|
|
43
50
|
// resolve/reject with whatever the inner function does.
|
|
51
|
+
/** @param {unknown} _ */
|
|
44
52
|
const thunk = _ => inner(...args);
|
|
45
53
|
const pr = makePromiseKit();
|
|
46
54
|
queue.push([thunk, pr.resolve, pr.reject]);
|
package/src/scratch.d.ts
CHANGED
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
export default function makeScratchPad(): {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/** @param {import('@endo/far').ERef<unknown>} keyP */
|
|
3
|
+
delete: (keyP: import("@endo/far").ERef<unknown>) => Promise<void>;
|
|
4
|
+
/** @param {import('@endo/far').ERef<unknown>} keyP */
|
|
5
|
+
get: (keyP: import("@endo/far").ERef<unknown>) => Promise<any>;
|
|
6
|
+
/** @param {...unknown} path */
|
|
7
|
+
lookup: (...path: unknown[]) => any;
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('@endo/far').ERef<unknown>} keyP
|
|
10
|
+
* @param {import('@endo/far').ERef<unknown>} objP
|
|
11
|
+
*/
|
|
12
|
+
init: (keyP: import("@endo/far").ERef<unknown>, objP: import("@endo/far").ERef<unknown>) => Promise<unknown>;
|
|
6
13
|
keys: () => Promise<any[]>;
|
|
7
14
|
list: () => Promise<any[]>;
|
|
8
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @param {import('@endo/far').ERef<unknown>} keyP
|
|
17
|
+
* @param {import('@endo/far').ERef<unknown>} objP
|
|
18
|
+
*/
|
|
19
|
+
set: (keyP: import("@endo/far").ERef<unknown>, objP: import("@endo/far").ERef<unknown>) => Promise<unknown>;
|
|
9
20
|
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
/** @param {import('@endo/far').ERef<unknown>} keyP */
|
|
22
|
+
delete: (keyP: import("@endo/far").ERef<unknown>) => Promise<void>;
|
|
23
|
+
/** @param {import('@endo/far').ERef<unknown>} keyP */
|
|
24
|
+
get: (keyP: import("@endo/far").ERef<unknown>) => Promise<any>;
|
|
25
|
+
/** @param {...unknown} path */
|
|
26
|
+
lookup: (...path: unknown[]) => any;
|
|
27
|
+
/**
|
|
28
|
+
* @param {import('@endo/far').ERef<unknown>} keyP
|
|
29
|
+
* @param {import('@endo/far').ERef<unknown>} objP
|
|
30
|
+
*/
|
|
31
|
+
init: (keyP: import("@endo/far").ERef<unknown>, objP: import("@endo/far").ERef<unknown>) => Promise<unknown>;
|
|
14
32
|
keys: () => Promise<any[]>;
|
|
15
33
|
list: () => Promise<any[]>;
|
|
16
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @param {import('@endo/far').ERef<unknown>} keyP
|
|
36
|
+
* @param {import('@endo/far').ERef<unknown>} objP
|
|
37
|
+
*/
|
|
38
|
+
set: (keyP: import("@endo/far").ERef<unknown>, objP: import("@endo/far").ERef<unknown>) => Promise<unknown>;
|
|
17
39
|
}>;
|
|
18
40
|
export type ScratchPad = ReturnType<typeof makeScratchPad>;
|
|
19
41
|
//# sourceMappingURL=scratch.d.ts.map
|
package/src/scratch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["scratch.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["scratch.js"],"names":[],"mappings":"AAEA;IASI,sDAAsD;mBAA1C,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;IAK7C,sDAAsD;gBAA1C,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;IAK7C,+BAA+B;sBAAhB,OAAO,EAAA;IActB;;;OAGG;iBAFQ,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,QACjC,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;;;IAa5C;;;OAGG;gBAFQ,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,QACjC,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;;IAzC5C,sDAAsD;mBAA1C,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;IAK7C,sDAAsD;gBAA1C,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;IAK7C,+BAA+B;sBAAhB,OAAO,EAAA;IActB;;;OAGG;iBAFQ,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,QACjC,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;;;IAa5C;;;OAGG;gBAFQ,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,QACjC,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC;GAS/C;yBACa,UAAU,CAAC,OAAO,cAAc,CAAC"}
|
package/src/scratch.js
CHANGED
|
@@ -9,14 +9,17 @@ export default function makeScratchPad() {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const scratch = Far('scratchPad', {
|
|
12
|
+
/** @param {import('@endo/far').ERef<unknown>} keyP */
|
|
12
13
|
delete: async keyP => {
|
|
13
14
|
const key = await keyP;
|
|
14
15
|
map.delete(key);
|
|
15
16
|
},
|
|
17
|
+
/** @param {import('@endo/far').ERef<unknown>} keyP */
|
|
16
18
|
get: async keyP => {
|
|
17
19
|
const key = await keyP;
|
|
18
20
|
return map.get(key);
|
|
19
21
|
},
|
|
22
|
+
/** @param {...unknown} path */
|
|
20
23
|
lookup: (...path) => {
|
|
21
24
|
if (path.length === 0) {
|
|
22
25
|
return scratch;
|
|
@@ -30,6 +33,10 @@ export default function makeScratchPad() {
|
|
|
30
33
|
},
|
|
31
34
|
// Initialize a key only if it doesn't already exist. Needed for atomicity
|
|
32
35
|
// between multiple invocations.
|
|
36
|
+
/**
|
|
37
|
+
* @param {import('@endo/far').ERef<unknown>} keyP
|
|
38
|
+
* @param {import('@endo/far').ERef<unknown>} objP
|
|
39
|
+
*/
|
|
33
40
|
init: async (keyP, objP) => {
|
|
34
41
|
const [key, obj] = await Promise.all([keyP, objP]);
|
|
35
42
|
if (map.has(key)) {
|
|
@@ -41,6 +48,10 @@ export default function makeScratchPad() {
|
|
|
41
48
|
keys,
|
|
42
49
|
// Legacy alias for `keys`.
|
|
43
50
|
list: keys,
|
|
51
|
+
/**
|
|
52
|
+
* @param {import('@endo/far').ERef<unknown>} keyP
|
|
53
|
+
* @param {import('@endo/far').ERef<unknown>} objP
|
|
54
|
+
*/
|
|
44
55
|
set: async (keyP, objP) => {
|
|
45
56
|
const [key, obj] = await Promise.all([keyP, objP]);
|
|
46
57
|
map.set(key, obj);
|
package/src/ses-utils.d.ts
CHANGED
|
@@ -39,9 +39,20 @@ export function throwErrorCode<Code extends string>(details: Parameters<typeof m
|
|
|
39
39
|
export function tryNow<F extends (...args: any[]) => any, U = ReturnType<F>>(fn: F, transformError: (err: Error) => U, ...args: Parameters<F>): ReturnType<F> | U;
|
|
40
40
|
export function tryJsonParse(jsonText: string, onError: string | ((err: Error) => unknown)): any;
|
|
41
41
|
export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
42
|
-
export function aggregateTryFinally<T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<unknown>):
|
|
43
|
-
export function withDeferredCleanup<T>(fn: (addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>):
|
|
44
|
-
|
|
42
|
+
export function aggregateTryFinally<T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<unknown>): Promise<T>;
|
|
43
|
+
export function withDeferredCleanup<T>(fn: (addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* @template {Record<string, unknown>} T
|
|
46
|
+
* @typedef {{ [P in keyof T]: Exclude<T[P], undefined> }} AllDefined
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Concise way to check values are available from object literal shorthand.
|
|
50
|
+
* Throws error message to specify the missing values.
|
|
51
|
+
*
|
|
52
|
+
* @type {<T extends Record<string, unknown>>(obj: T) => asserts obj is AllDefined<T>}
|
|
53
|
+
* @throws if any value in the object entries is not defined
|
|
54
|
+
*/
|
|
55
|
+
export const assertAllDefined: <T extends Record<string, unknown>>(obj: T) => asserts obj is AllDefined<T>;
|
|
45
56
|
export function attenuate<T, P extends Permit<T>>(specimen: T, permit: P, transform?: <U, SubP extends Permit<U>>(attenuation: U, permit: SubP) => U): Attenuated<T, P>;
|
|
46
57
|
export const forever: AsyncIterable<undefined>;
|
|
47
58
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
package/src/ses-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ses-utils.d.ts","sourceRoot":"","sources":["ses-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ses-utils.d.ts","sourceRoot":"","sources":["ses-utils.js"],"names":[],"mappings":"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"}
|
package/src/ses-utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
// @jessie-check
|
|
3
2
|
/**
|
|
4
3
|
* @file Utility functions that are dependent upon a hardened environment,
|
|
5
4
|
* either directly or indirectly (e.g. by @endo imports).
|
|
@@ -137,7 +136,7 @@ export const throwErrorCode = (details, code, opts) => {
|
|
|
137
136
|
* similarly to a Promise `catch` callback (e.g., substituting a non-error
|
|
138
137
|
* returned value or throwing a possibly-new error). This is useful for (among
|
|
139
138
|
* other things) replacing generic error messages with specific ones (as in
|
|
140
|
-
* {@
|
|
139
|
+
* {@link tryJsonParse}).
|
|
141
140
|
*
|
|
142
141
|
* @template {(...args: any[]) => any} F
|
|
143
142
|
* @template [U=ReturnType<F>]
|
|
@@ -184,7 +183,8 @@ export const tryJsonParse = (jsonText, onError) => {
|
|
|
184
183
|
const transformError =
|
|
185
184
|
typeof onError === 'function'
|
|
186
185
|
? onError
|
|
187
|
-
:
|
|
186
|
+
: /** @param {Error} err */
|
|
187
|
+
err => Fail([`${onError}: ${err.message} for input `, ''], jsonText);
|
|
188
188
|
return tryNow(() => {
|
|
189
189
|
const type = typeof jsonText;
|
|
190
190
|
type === 'string' || Fail`Input must be a string, not ${b(type)}`;
|
|
@@ -218,7 +218,7 @@ export const PromiseAllOrErrors = async items => {
|
|
|
218
218
|
* @template T
|
|
219
219
|
* @param {() => Promise<T>} trier
|
|
220
220
|
* @param {(error?: unknown) => Promise<unknown>} finalizer
|
|
221
|
-
* @returns {
|
|
221
|
+
* @returns {Promise<T>}
|
|
222
222
|
*/
|
|
223
223
|
export const aggregateTryFinally = async (trier, finalizer) =>
|
|
224
224
|
trier().then(
|
|
@@ -239,7 +239,7 @@ export const aggregateTryFinally = async (trier, finalizer) =>
|
|
|
239
239
|
* @param {(
|
|
240
240
|
* addCleanup: (fn: (err?: unknown) => Promise<void>) => void,
|
|
241
241
|
* ) => Promise<T>} fn
|
|
242
|
-
* @returns {
|
|
242
|
+
* @returns {Promise<T>}
|
|
243
243
|
*/
|
|
244
244
|
export const withDeferredCleanup = async fn => {
|
|
245
245
|
/** @type {((err?: unknown) => unknown)[]} */
|
|
@@ -269,9 +269,7 @@ export const withDeferredCleanup = async fn => {
|
|
|
269
269
|
* Concise way to check values are available from object literal shorthand.
|
|
270
270
|
* Throws error message to specify the missing values.
|
|
271
271
|
*
|
|
272
|
-
* @
|
|
273
|
-
* @param {T} obj
|
|
274
|
-
* @returns {asserts obj is AllDefined<T>}
|
|
272
|
+
* @type {<T extends Record<string, unknown>>(obj: T) => asserts obj is AllDefined<T>}
|
|
275
273
|
* @throws if any value in the object entries is not defined
|
|
276
274
|
*/
|
|
277
275
|
export const assertAllDefined = obj => {
|
|
@@ -306,9 +304,10 @@ export const attenuate = (specimen, permit, transform = x => x) => {
|
|
|
306
304
|
/** @type {string[]} */
|
|
307
305
|
const path = [];
|
|
308
306
|
/**
|
|
309
|
-
* @
|
|
310
|
-
*
|
|
311
|
-
*
|
|
307
|
+
* @type {<SubT, SubP extends Exclude<Permit<SubT>, Primitive>>(
|
|
308
|
+
* subSpecimen: SubT,
|
|
309
|
+
* subPermit: SubP,
|
|
310
|
+
* ) => Attenuated<SubT, SubP>}
|
|
312
311
|
*/
|
|
313
312
|
const extract = (subSpecimen, subPermit) => {
|
|
314
313
|
if (subPermit === null || typeof subPermit !== 'object') {
|
|
@@ -400,8 +399,7 @@ export const zip = (xs, ys) => harden(xs.map((x, i) => [x, ys[+i]]));
|
|
|
400
399
|
*/
|
|
401
400
|
export const allValues = async obj => {
|
|
402
401
|
const resolved = await Promise.all(values(obj));
|
|
403
|
-
|
|
404
|
-
return harden(fromEntries(zip(keys(obj), resolved)));
|
|
402
|
+
return /** @type {any} */ (harden(fromEntries(zip(keys(obj), resolved))));
|
|
405
403
|
};
|
|
406
404
|
|
|
407
405
|
/**
|
|
@@ -503,11 +501,11 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
503
501
|
queue.put(rejection);
|
|
504
502
|
return rejection;
|
|
505
503
|
},
|
|
506
|
-
|
|
504
|
+
|
|
507
505
|
[Symbol.asyncIterator]() {
|
|
508
506
|
return reader;
|
|
509
507
|
},
|
|
510
|
-
|
|
508
|
+
|
|
511
509
|
async [Symbol.asyncDispose]() {
|
|
512
510
|
await reader.return();
|
|
513
511
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/
|
|
1
|
+
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/marshal").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>;
|
|
2
2
|
/**
|
|
3
3
|
* A basic marshaller whose unserializer produces Remotables. It can only
|
|
4
4
|
* serialize plain data, not Remotables.
|
|
@@ -24,14 +24,7 @@ export function makeAsyncQueue<T>(): {
|
|
|
24
24
|
export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2], { eachMessage }?: {
|
|
25
25
|
eachMessage?: (m: StorageMessage) => void;
|
|
26
26
|
}): {
|
|
27
|
-
rootNode: import("
|
|
28
|
-
getPath(): string;
|
|
29
|
-
getStoreKey(): Promise<VStorageKey>;
|
|
30
|
-
makeChildNode(name: string, childNodeOptions?: {
|
|
31
|
-
sequence?: boolean;
|
|
32
|
-
}): StorageNode;
|
|
33
|
-
setValue(value: string): Promise<void>;
|
|
34
|
-
}>;
|
|
27
|
+
rootNode: import("./types.js").StorageNode;
|
|
35
28
|
data: Map<string, string>;
|
|
36
29
|
updateNewCellBlockHeight: (blockHeight?: number) => void;
|
|
37
30
|
getValues: (path: string) => string[];
|
|
@@ -39,7 +32,7 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
39
32
|
toStorage: ((message: StorageMessage) => string | number | true | any[] | {
|
|
40
33
|
storeName: string;
|
|
41
34
|
storeSubkey: string;
|
|
42
|
-
} | null) & import("@endo/
|
|
35
|
+
} | null) & import("@endo/marshal").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | true | any[] | {
|
|
43
36
|
storeName: string;
|
|
44
37
|
storeSubkey: string;
|
|
45
38
|
} | null>;
|
|
@@ -70,7 +63,7 @@ export type MockChainStorageRootMethods = {
|
|
|
70
63
|
export type MockChainStorageRoot = StorageNode & MockChainStorageRootMethods;
|
|
71
64
|
import { makeChainStorageRoot } from './lib-chainStorage.js';
|
|
72
65
|
import type { StorageMessage } from './lib-chainStorage.js';
|
|
73
|
-
import type { StorageNode } from './lib-chainStorage.js';
|
|
74
66
|
import type { ExecutionContext } from 'ava';
|
|
75
67
|
import type { Marshaller } from './lib-chainStorage.js';
|
|
68
|
+
import type { StorageNode } from './lib-chainStorage.js';
|
|
76
69
|
//# sourceMappingURL=storage-test-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AA0BO,yCAHI,MAAM,UACN,MAAM,
|
|
1
|
+
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AA0BO,yCAHI,MAAM,UACN,MAAM,0GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;;eAMU,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;mBAEzB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;;AA8CjC,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAa1D,+BAFM,CAAC;oBASA,CAAC;;;;;EA6Bd;AAWM,6CAJI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,oBAC1C;IAAE,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;CAAE;;UAoJnC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;sBAd3B,MAAM,KACJ,MAAM,EAAE;;0BA/FP,cAAc;;;2IAAd,cAAc;;;;EAkH7B;AAoBM,4CADO,oBAAoB,CA2BjC;AAUM,yCAPI,iBAAiB,OAAO,CAAC,WACzB,oBAAoB,GAAG,cAAc,QACrC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9D,CAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,EAAE,CAAC,GAAG;IAChD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,iBAoDL;6BAxGa,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;aAIrC,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,CAAC,EAAE,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;mCAEd,WAAW,GAAG,2BAA2B;qCAxTJ,uBAAuB;oCAOU,uBAAuB;sCACxE,KAAK;gCAD4C,uBAAuB;iCAAvB,uBAAuB"}
|
|
@@ -239,7 +239,7 @@ export const makeFakeStorageKit = (
|
|
|
239
239
|
try {
|
|
240
240
|
streamCell = JSON.parse(oldVal);
|
|
241
241
|
assert(isStreamCell(streamCell));
|
|
242
|
-
} catch
|
|
242
|
+
} catch {
|
|
243
243
|
streamCell = undefined;
|
|
244
244
|
}
|
|
245
245
|
// StreamCells reset at block boundaries.
|
|
@@ -378,20 +378,22 @@ export const documentStorageSchema = async (t, storage, opts) => {
|
|
|
378
378
|
? opts
|
|
379
379
|
: { pattern: 'mockChainStorageRoot.', replacement: 'published.' };
|
|
380
380
|
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
381
|
+
const nodePrefix = 'node' in opts ? `published.${opts.node}` : undefined;
|
|
382
|
+
/** @type {[key: string, publishedKey: string][]} */
|
|
383
|
+
const normalized = [];
|
|
384
|
+
for (const key of keys) {
|
|
385
|
+
const publishedKey = key.replace(pattern, replacement);
|
|
386
|
+
if (!nodePrefix || publishedKey.startsWith(nodePrefix)) {
|
|
387
|
+
normalized.push([key, publishedKey]);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
normalized.sort(([left], [right]) =>
|
|
391
|
+
left < right ? -1 : left > right ? 1 : 0,
|
|
392
|
+
);
|
|
391
393
|
|
|
392
|
-
const illustration =
|
|
393
|
-
/** @type {(
|
|
394
|
-
key => [
|
|
394
|
+
const illustration = normalized.map(
|
|
395
|
+
/** @type {(entry: [string, string]) => [string, unknown]} */
|
|
396
|
+
([key, publishedKey]) => [publishedKey, getBody(key)],
|
|
395
397
|
);
|
|
396
398
|
|
|
397
399
|
const note =
|