@agoric/internal 0.3.3-dev-6c8bf5c.0 → 0.3.3-dev-35d20eb.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 +4 -4
- package/src/batched-deliver.d.ts +4 -1
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +4 -1
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +24 -22
- package/src/chain-storage-paths.d.ts +2 -3
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +2 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +6 -4
- package/src/lib-chainStorage.d.ts +26 -11
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +69 -35
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +7 -5
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
- package/src/lib-nodejs/worker-protocol.js +5 -7
- package/src/magic-cookie-test-only.js +2 -2
- package/src/marshal.d.ts +3 -2
- package/src/marshal.d.ts.map +1 -1
- package/src/marshal.js +18 -12
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +17 -16
- package/src/netstring.d.ts +4 -5
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +8 -11
- package/src/node/buffer-line-transform.d.ts +15 -10
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +11 -8
- package/src/node/fs-stream.js +1 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +7 -3
- package/src/queue.js +2 -2
- package/src/storage-test-utils.d.ts +8 -8
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +43 -33
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +7 -5
- package/src/upgrade-api.d.ts +2 -2
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +8 -8
- package/src/utils.d.ts +24 -14
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +50 -29
package/src/utils.d.ts
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
export const BASIS_POINTS: 10000n;
|
|
2
|
-
/** @import {
|
|
2
|
+
/** @import {ERef} from '@endo/far' */
|
|
3
3
|
/**
|
|
4
4
|
* @template T
|
|
5
|
-
* @typedef {{[KeyType in keyof T]: T[KeyType]} & {}} Simplify
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
|
|
6
|
+
* type output to improve type hints shown in editors
|
|
7
|
+
* https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {(...args: any[]) => any} Callable
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* @template {{}} T
|
|
14
|
-
* @typedef {{
|
|
14
|
+
* @typedef {{
|
|
15
|
+
* [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>;
|
|
16
|
+
* }} DeeplyAwaitedObject
|
|
15
17
|
*/
|
|
16
18
|
/**
|
|
17
19
|
* @template T
|
|
18
|
-
* @typedef {T extends PromiseLike<any>
|
|
20
|
+
* @typedef {T extends PromiseLike<any>
|
|
21
|
+
* ? Awaited<T>
|
|
22
|
+
* : T extends {}
|
|
23
|
+
* ? Simplify<DeeplyAwaitedObject<T>>
|
|
24
|
+
* : Awaited<T>} DeeplyAwaited
|
|
19
25
|
*/
|
|
20
26
|
/**
|
|
21
27
|
* A more constrained version of {deeplyFulfilled} for type safety until
|
|
22
|
-
* https://github.com/endojs/endo/issues/1257
|
|
23
|
-
*
|
|
24
|
-
* in order to be durable.
|
|
28
|
+
* https://github.com/endojs/endo/issues/1257 Useful in starting contracts that
|
|
29
|
+
* need all terms to be fulfilled in order to be durable.
|
|
25
30
|
*
|
|
26
31
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
27
32
|
*/
|
|
@@ -34,7 +39,7 @@ export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): P
|
|
|
34
39
|
/**
|
|
35
40
|
* @type {<T>(
|
|
36
41
|
* trier: () => Promise<T>,
|
|
37
|
-
*
|
|
42
|
+
* finalizer: (error?: unknown) => Promise<void>,
|
|
38
43
|
* ) => Promise<T>}
|
|
39
44
|
*/
|
|
40
45
|
export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
|
|
@@ -42,14 +47,19 @@ export function assertAllDefined<T extends Record<string, unknown>>(obj: T): ass
|
|
|
42
47
|
export const forever: AsyncIterable<undefined>;
|
|
43
48
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
44
49
|
export function untilTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
45
|
-
/** @type {
|
|
50
|
+
/** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
46
51
|
export const zip: <X, Y>(xs: X[], ys: Y[]) => [X, Y][];
|
|
47
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* @type {<T extends Record<string, ERef<any>>>(
|
|
54
|
+
* obj: T,
|
|
55
|
+
* ) => Promise<{ [K in keyof T]: Awaited<T[K]> }>}
|
|
56
|
+
*/
|
|
48
57
|
export const allValues: <T extends Record<string, any>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>; }>;
|
|
49
58
|
export function synchronizedTee<T = unknown>(sourceStream: AsyncIterator<T, void, void>, readerCount: number): AsyncGenerator<T, void, void>[];
|
|
50
59
|
/**
|
|
51
|
-
* flatten the
|
|
52
|
-
*
|
|
60
|
+
* flatten the
|
|
61
|
+
* type output to improve type hints shown in editors
|
|
62
|
+
* https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
53
63
|
*/
|
|
54
64
|
export type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
55
65
|
export type Callable = (...args: any[]) => any;
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAYA,kCAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAYA,kCAAoC;AAEpC,sCAAsC;AAEtC;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAFU,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAA8B,CAAC,AAA5B,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAKxE;AAYK,wDALI,cAAc,YAAY,EAAE,WAAW,CAAC,GAAG,GACzC,CAAC,CAAC,EACd,EAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KACjB,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAW/C;AAOM,mCAFc,CAAC,SADX,SAAS,CACC,CAAC,AADA,GAAG,WAAW,CACf,CAAC,AADgB,CAAC,CAAC,EAAE,GAC7B,OAAO,CAAC,CAAC,EAAE,CAAC,CAiBxB;AAED;;;;;GAKG;AACH,kCALU,CAAC,CAAC,EACX,KAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,SAAa,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,KAC1C,OAAO,CAAC,CAAC,CAAC,CAYd;AAgBG,iCAHgC,CAAC,uCAAD,CAAC,AAD5B,GACC,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAaxC;AAQD,+CAAoD;AAS7C,0BAF4B,CAAC,WAHzB,MAG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kB,CAAC,oCAA3B,GAAG,CAAC,IAAI,MAAkB,CAAC,AAAZ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAE"}
|
package/src/utils.js
CHANGED
|
@@ -12,13 +12,13 @@ const { quote: q, Fail } = assert;
|
|
|
12
12
|
|
|
13
13
|
export const BASIS_POINTS = 10_000n;
|
|
14
14
|
|
|
15
|
-
/** @import {
|
|
15
|
+
/** @import {ERef} from '@endo/far' */
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @template T
|
|
19
|
-
* @typedef {{[KeyType in keyof T]: T[KeyType]} & {}} Simplify
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
|
|
20
|
+
* type output to improve type hints shown in editors
|
|
21
|
+
* https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -27,19 +27,24 @@ export const BASIS_POINTS = 10_000n;
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* @template {{}} T
|
|
30
|
-
* @typedef {{
|
|
30
|
+
* @typedef {{
|
|
31
|
+
* [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>;
|
|
32
|
+
* }} DeeplyAwaitedObject
|
|
31
33
|
*/
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* @template T
|
|
35
|
-
* @typedef {T extends PromiseLike<any>
|
|
37
|
+
* @typedef {T extends PromiseLike<any>
|
|
38
|
+
* ? Awaited<T>
|
|
39
|
+
* : T extends {}
|
|
40
|
+
* ? Simplify<DeeplyAwaitedObject<T>>
|
|
41
|
+
* : Awaited<T>} DeeplyAwaited
|
|
36
42
|
*/
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* A more constrained version of {deeplyFulfilled} for type safety until
|
|
40
|
-
* https://github.com/endojs/endo/issues/1257
|
|
41
|
-
*
|
|
42
|
-
* in order to be durable.
|
|
46
|
+
* https://github.com/endojs/endo/issues/1257 Useful in starting contracts that
|
|
47
|
+
* need all terms to be fulfilled in order to be durable.
|
|
43
48
|
*
|
|
44
49
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
45
50
|
*/
|
|
@@ -54,7 +59,9 @@ export const deeplyFulfilledObject = async obj => {
|
|
|
54
59
|
* and report the result in seconds to match our telemetry standard.
|
|
55
60
|
*
|
|
56
61
|
* @param {typeof import('perf_hooks').performance.now} currentTimeMillisec
|
|
57
|
-
* @returns {<T>(
|
|
62
|
+
* @returns {<T>(
|
|
63
|
+
* fn: () => Promise<T>,
|
|
64
|
+
* ) => Promise<{ result: T; duration: number }>}
|
|
58
65
|
*/
|
|
59
66
|
export const makeMeasureSeconds = currentTimeMillisec => {
|
|
60
67
|
/** @param {() => any} fn */
|
|
@@ -92,7 +99,7 @@ export const PromiseAllOrErrors = async items => {
|
|
|
92
99
|
/**
|
|
93
100
|
* @type {<T>(
|
|
94
101
|
* trier: () => Promise<T>,
|
|
95
|
-
*
|
|
102
|
+
* finalizer: (error?: unknown) => Promise<void>,
|
|
96
103
|
* ) => Promise<T>}
|
|
97
104
|
*/
|
|
98
105
|
export const aggregateTryFinally = async (trier, finalizer) =>
|
|
@@ -109,7 +116,7 @@ export const aggregateTryFinally = async (trier, finalizer) =>
|
|
|
109
116
|
|
|
110
117
|
/**
|
|
111
118
|
* @template {Record<string, unknown>} T
|
|
112
|
-
* @typedef {{[P in keyof T]: Exclude<T[P], undefined
|
|
119
|
+
* @typedef {{ [P in keyof T]: Exclude<T[P], undefined> }} AllDefined
|
|
113
120
|
*/
|
|
114
121
|
|
|
115
122
|
/**
|
|
@@ -118,8 +125,8 @@ export const aggregateTryFinally = async (trier, finalizer) =>
|
|
|
118
125
|
*
|
|
119
126
|
* @template {Record<string, unknown>} T
|
|
120
127
|
* @param {T} obj
|
|
121
|
-
* @throws if any value in the object entries is not defined
|
|
122
128
|
* @returns {asserts obj is AllDefined<T>}
|
|
129
|
+
* @throws if any value in the object entries is not defined
|
|
123
130
|
*/
|
|
124
131
|
export const assertAllDefined = obj => {
|
|
125
132
|
const missing = [];
|
|
@@ -143,10 +150,9 @@ export const forever = asyncGenerate(() => notDone);
|
|
|
143
150
|
|
|
144
151
|
/**
|
|
145
152
|
* @template T
|
|
146
|
-
* @param {() => T} produce
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* themselves.
|
|
153
|
+
* @param {() => T} produce The value of `await produce()` is used for its
|
|
154
|
+
* truthiness vs falsiness. IOW, it is coerced to a boolean so the caller need
|
|
155
|
+
* not bother doing this themselves.
|
|
150
156
|
* @returns {AsyncIterable<Awaited<T>>}
|
|
151
157
|
*/
|
|
152
158
|
export const whileTrue = produce =>
|
|
@@ -163,10 +169,9 @@ export const whileTrue = produce =>
|
|
|
163
169
|
|
|
164
170
|
/**
|
|
165
171
|
* @template T
|
|
166
|
-
* @param {() => T} produce
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* themselves.
|
|
172
|
+
* @param {() => T} produce The value of `await produce()` is used for its
|
|
173
|
+
* truthiness vs falsiness. IOW, it is coerced to a boolean so the caller need
|
|
174
|
+
* not bother doing this themselves.
|
|
170
175
|
* @returns {AsyncIterable<Awaited<T>>}
|
|
171
176
|
*/
|
|
172
177
|
export const untilTrue = produce =>
|
|
@@ -184,10 +189,14 @@ export const untilTrue = produce =>
|
|
|
184
189
|
});
|
|
185
190
|
});
|
|
186
191
|
|
|
187
|
-
/** @type {
|
|
192
|
+
/** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
188
193
|
export const zip = (xs, ys) => harden(xs.map((x, i) => [x, ys[+i]]));
|
|
189
194
|
|
|
190
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* @type {<T extends Record<string, ERef<any>>>(
|
|
197
|
+
* obj: T,
|
|
198
|
+
* ) => Promise<{ [K in keyof T]: Awaited<T[K]> }>}
|
|
199
|
+
*/
|
|
191
200
|
export const allValues = async obj => {
|
|
192
201
|
const resolved = await Promise.all(values(obj));
|
|
193
202
|
// @ts-expect-error cast
|
|
@@ -195,9 +204,9 @@ export const allValues = async obj => {
|
|
|
195
204
|
};
|
|
196
205
|
|
|
197
206
|
/**
|
|
198
|
-
* A tee implementation where all readers are synchronized with each other.
|
|
199
|
-
*
|
|
200
|
-
*
|
|
207
|
+
* A tee implementation where all readers are synchronized with each other. They
|
|
208
|
+
* all consume the source stream in lockstep, and any one returning or throwing
|
|
209
|
+
* early will affect the others.
|
|
201
210
|
*
|
|
202
211
|
* @template [T=unknown]
|
|
203
212
|
* @param {AsyncIterator<T, void, void>} sourceStream
|
|
@@ -207,7 +216,11 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
207
216
|
/** @type {IteratorReturnResult<void> | undefined} */
|
|
208
217
|
let doneResult;
|
|
209
218
|
|
|
210
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* @typedef {IteratorResult<
|
|
221
|
+
* (value: PromiseLike<IteratorResult<T>>) => void
|
|
222
|
+
* >} QueuePayload
|
|
223
|
+
*/
|
|
211
224
|
/** @type {import('@endo/stream').AsyncQueue<QueuePayload>[]} */
|
|
212
225
|
const queues = [];
|
|
213
226
|
|
|
@@ -267,13 +280,21 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
267
280
|
/** @type {AsyncGenerator<T, void, void>} */
|
|
268
281
|
const reader = harden({
|
|
269
282
|
async next() {
|
|
270
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* @type {import('@endo/promise-kit').PromiseKit<
|
|
285
|
+
* IteratorResult<T>
|
|
286
|
+
* >}
|
|
287
|
+
*/
|
|
271
288
|
const { promise, resolve } = makePromiseKit();
|
|
272
289
|
queue.put({ value: resolve, done: false });
|
|
273
290
|
return promise;
|
|
274
291
|
},
|
|
275
292
|
async return() {
|
|
276
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* @type {import('@endo/promise-kit').PromiseKit<
|
|
295
|
+
* IteratorResult<T>
|
|
296
|
+
* >}
|
|
297
|
+
*/
|
|
277
298
|
const { promise, resolve } = makePromiseKit();
|
|
278
299
|
queue.put({ value: resolve, done: true });
|
|
279
300
|
return promise;
|