@agoric/internal 0.3.3-other-dev-3eb1a1d.0 → 0.3.3-other-dev-d15096d.0.d15096d
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 +29 -23
- package/src/action-types.d.ts +2 -1
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +4 -4
- package/src/batched-deliver.d.ts +6 -2
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +7 -2
- package/src/callback.d.ts +10 -12
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +23 -16
- package/src/chain-storage-paths.d.ts.map +1 -1
- 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/cli-utils.d.ts +2 -0
- package/src/cli-utils.d.ts.map +1 -0
- package/src/cli-utils.js +21 -0
- package/src/config.d.ts +21 -4
- package/src/config.d.ts.map +1 -1
- package/src/config.js +25 -2
- package/src/debug.d.ts +4 -1
- package/src/debug.d.ts.map +1 -1
- package/src/debug.js +26 -13
- package/src/errors.d.ts +1 -1
- package/src/errors.d.ts.map +1 -1
- package/src/hex.d.ts +15 -0
- package/src/hex.d.ts.map +1 -0
- package/src/hex.js +105 -0
- package/src/index.d.ts +5 -3
- package/src/index.js +13 -4
- package/src/js-utils.d.ts +38 -1
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +184 -14
- package/src/lib-chainStorage.d.ts +45 -32
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +24 -32
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +13 -0
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -0
- package/src/lib-nodejs/ava-unhandled-rejection.js +66 -0
- 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 +5 -3
- 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/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} +30 -36
- package/src/marshal/cap-data.d.ts +3 -0
- package/src/marshal/cap-data.d.ts.map +1 -0
- package/src/marshal/cap-data.js +20 -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 +33 -0
- package/src/marshal/wrap-marshaller.d.ts.map +1 -0
- package/src/marshal/wrap-marshaller.js +439 -0
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +8 -50
- package/src/metrics.d.ts +183 -0
- package/src/metrics.d.ts.map +1 -0
- package/src/metrics.js +476 -0
- package/src/module-utils.d.ts +2 -0
- package/src/module-utils.d.ts.map +1 -0
- package/src/module-utils.js +27 -0
- package/src/natural-sort.d.ts +2 -0
- package/src/natural-sort.d.ts.map +1 -0
- package/src/natural-sort.js +83 -0
- package/src/netstring.d.ts +2 -2
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +1 -0
- package/src/node/buffer-line-transform.d.ts +12 -7
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +8 -4
- 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 +28 -27
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +2 -0
- package/src/priority-senders.d.ts +3 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +7 -2
- package/src/queue.d.ts +1 -1
- package/src/queue.d.ts.map +1 -1
- package/src/ses-utils.d.ts +24 -5
- package/src/ses-utils.d.ts.map +1 -1
- package/src/ses-utils.js +189 -15
- package/src/storage-test-utils.d.ts +25 -7
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +141 -22
- package/src/tagged.d.ts +4 -1
- package/src/testing-utils.js +1 -1
- package/src/tmpDir.d.ts +2 -0
- package/src/tmpDir.d.ts.map +1 -0
- package/src/tmpDir.js +17 -0
- package/src/tokens.d.ts.map +1 -1
- package/src/typeGuards.d.ts +19 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +16 -0
- package/src/types.d.ts +30 -17
- package/src/types.d.ts.map +1 -1
- package/src/types.ts +43 -18
- 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/src/marshal.d.ts +0 -20
- package/src/marshal.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"natural-sort.d.ts","sourceRoot":"","sources":["natural-sort.js"],"names":[],"mappings":"AAgDO,kCAJI,MAAM,KACN,MAAM,GACJ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAmCtB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { provideLazyMap } from './js-utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} a
|
|
5
|
+
* @param {string} b
|
|
6
|
+
* @returns {-1 | 0 | 1}
|
|
7
|
+
*/
|
|
8
|
+
const compareNats = (a, b) => {
|
|
9
|
+
// Default to IEEE 754 number arithmetic for speed, but fall back on bigint
|
|
10
|
+
// arithmetic to resolve ties because big numbers can lose resolution
|
|
11
|
+
// (sometimes even becoming infinite) and then ultimately on length to resolve
|
|
12
|
+
// ties by ascending count of leading zeros.
|
|
13
|
+
const diff = +a - +b;
|
|
14
|
+
const finiteDiff =
|
|
15
|
+
(Number.isFinite(diff) && diff) ||
|
|
16
|
+
(a === b ? 0 : Number(BigInt(a) - BigInt(b)) || a.length - b.length);
|
|
17
|
+
|
|
18
|
+
// @ts-expect-error this call really does return -1 | 0 | 1
|
|
19
|
+
return Math.sign(finiteDiff);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// TODO: compareByCodePoints
|
|
23
|
+
// https://github.com/endojs/endo/pull/2008
|
|
24
|
+
// eslint-disable-next-line no-nested-ternary
|
|
25
|
+
const compareStrings = (a, b) => (a > b ? 1 : a < b ? -1 : 0);
|
|
26
|
+
|
|
27
|
+
const rCaptureDigits = /([0-9]+)/;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Splitting by regular expression can be expensive; we don't want to repeat
|
|
31
|
+
* that for every comparison against the same string.
|
|
32
|
+
*
|
|
33
|
+
* @type {Map<string, string[]>}
|
|
34
|
+
*/
|
|
35
|
+
const partsCache = new Map();
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Perform a multi-level natural-sort comparison, finding the decimal digit
|
|
39
|
+
* sequences in each operand and comparing first by each ([possibly empty]
|
|
40
|
+
* string prefix, integer) pair in turn, with a final comparision by string
|
|
41
|
+
* suffix as necessary (e.g., sorting 'ko42' before 'ko100' as ['ko', 42] vs.
|
|
42
|
+
* ['ko', 100] and 'parent1.child8' before 'parent1.child10' as ['parent', 1,
|
|
43
|
+
* 'child', 8] vs. ['parent', 1, 'child', 10]).
|
|
44
|
+
*
|
|
45
|
+
* @param {string} a
|
|
46
|
+
* @param {string} b
|
|
47
|
+
* @returns {-1 | 0 | 1}
|
|
48
|
+
*/
|
|
49
|
+
export const naturalCompare = (a, b) => {
|
|
50
|
+
// We want to maintain a cache only for the duration of each call to
|
|
51
|
+
// array.sort, and leverage the synchronous nature of that method in the first
|
|
52
|
+
// invocation of each turn (indicated by an empty cache) to schedule cache
|
|
53
|
+
// clearing in the *next* turn.
|
|
54
|
+
if (!partsCache.size) void Promise.resolve().then(() => partsCache.clear());
|
|
55
|
+
|
|
56
|
+
const aParts = provideLazyMap(partsCache, a, () => a.split(rCaptureDigits));
|
|
57
|
+
const bParts = provideLazyMap(partsCache, b, () => b.split(rCaptureDigits));
|
|
58
|
+
|
|
59
|
+
// An even index corresponds with a string part; an odd one with a digit part.
|
|
60
|
+
let i = 0;
|
|
61
|
+
for (; i + 1 < aParts.length; i += 2) {
|
|
62
|
+
if (i + 1 < bParts.length) {
|
|
63
|
+
// Both `a` and `b` have a digit part here, but we compare the preceding
|
|
64
|
+
// string part first in case those are unequal.
|
|
65
|
+
const result =
|
|
66
|
+
compareStrings(aParts[i], bParts[i]) ||
|
|
67
|
+
compareNats(aParts[i + 1], bParts[i + 1]);
|
|
68
|
+
if (result) return result;
|
|
69
|
+
} else {
|
|
70
|
+
// After a (possibly empty) common prefix, `a` has digits where `b` does
|
|
71
|
+
// not, so we use string comparison of `${aString}${aDigits}` vs.
|
|
72
|
+
// `${bString}`.
|
|
73
|
+
return compareStrings(`${aParts[i]}${aParts[i + 1]}`, bParts[i]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (bParts.length > aParts.length) {
|
|
77
|
+
// `b` has digits where `a` does not.
|
|
78
|
+
return compareStrings(aParts[i], `${bParts[i]}${bParts[i + 1]}`);
|
|
79
|
+
}
|
|
80
|
+
// If `a` and `b` differ, it's only in the final string suffix.
|
|
81
|
+
return compareStrings(aParts[i], bParts[i]);
|
|
82
|
+
};
|
|
83
|
+
harden(naturalCompare);
|
package/src/netstring.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function netstringEncoderStream(): Transform;
|
|
|
11
11
|
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
|
|
12
12
|
* Buffers, one per netstring,
|
|
13
13
|
*/
|
|
14
|
-
export function decode(data: Buffer, optMaxChunkSize?: number
|
|
14
|
+
export function decode(data: Buffer, optMaxChunkSize?: number): {
|
|
15
15
|
leftover: Buffer;
|
|
16
16
|
payloads: Buffer[];
|
|
17
17
|
};
|
|
@@ -19,6 +19,6 @@ export function decode(data: Buffer, optMaxChunkSize?: number | undefined): {
|
|
|
19
19
|
* @param {number} [optMaxChunkSize]
|
|
20
20
|
* @returns {Transform}
|
|
21
21
|
*/
|
|
22
|
-
export function netstringDecoderStream(optMaxChunkSize?: number
|
|
22
|
+
export function netstringDecoderStream(optMaxChunkSize?: number): Transform;
|
|
23
23
|
import { Transform } from 'stream';
|
|
24
24
|
//# sourceMappingURL=netstring.d.ts.map
|
package/src/netstring.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAsBC;AAED;;;;;;GAMG;AACH,6BANW,MAAM,
|
|
1
|
+
{"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAsBC;AAED;;;;;;GAMG;AACH,6BANW,MAAM,oBAEN,MAAM,GACJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCpD;AAED;;;GAGG;AAEH,yDAJW,MAAM,GACJ,SAAS,CAqCrB;0BAxHyB,QAAQ"}
|
package/src/netstring.js
CHANGED
|
@@ -89,6 +89,7 @@ export function decode(data, optMaxChunkSize) {
|
|
|
89
89
|
*/
|
|
90
90
|
// input is a byte pipe, output is a sequence of Buffers
|
|
91
91
|
export function netstringDecoderStream(optMaxChunkSize) {
|
|
92
|
+
/** @type {Buffer<ArrayBufferLike>} */
|
|
92
93
|
let buffered = Buffer.from('');
|
|
93
94
|
/**
|
|
94
95
|
* @param {Buffer} chunk
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {TransformOptions} from 'node:stream';
|
|
3
|
+
* @import {TransformCallback} from 'node:stream';
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* @typedef {object} BufferLineTransformOptions
|
|
3
7
|
* @property {Buffer | string | number} [break] line break matcher for
|
|
@@ -10,11 +14,10 @@ export default class BufferLineTransform extends Transform {
|
|
|
10
14
|
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
11
15
|
* stream and writing each line as a Buffer in object mode
|
|
12
16
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* BufferLineTransformOptions} [options]
|
|
17
|
+
* @param {TransformOptions & BufferLineTransformOptions} [options]
|
|
15
18
|
*/
|
|
16
|
-
constructor(options?:
|
|
17
|
-
_breakValue: string | number | Buffer
|
|
19
|
+
constructor(options?: TransformOptions & BufferLineTransformOptions);
|
|
20
|
+
_breakValue: string | number | Buffer<ArrayBufferLike>;
|
|
18
21
|
_breakEncoding: BufferEncoding | undefined;
|
|
19
22
|
_breakLength: number;
|
|
20
23
|
/** @type {Buffer[]} */
|
|
@@ -22,10 +25,10 @@ export default class BufferLineTransform extends Transform {
|
|
|
22
25
|
/**
|
|
23
26
|
* @param {any} chunk
|
|
24
27
|
* @param {BufferEncoding | 'buffer'} encoding
|
|
25
|
-
* @param {
|
|
28
|
+
* @param {TransformCallback} cb
|
|
26
29
|
* @override
|
|
27
30
|
*/
|
|
28
|
-
override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb:
|
|
31
|
+
override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb: TransformCallback): void;
|
|
29
32
|
/** @param {Buffer} line */
|
|
30
33
|
_writeItem(line: Buffer): void;
|
|
31
34
|
}
|
|
@@ -34,7 +37,7 @@ export type BufferLineTransformOptions = {
|
|
|
34
37
|
* line break matcher for
|
|
35
38
|
* Buffer.indexOf() (default: 10)
|
|
36
39
|
*/
|
|
37
|
-
break?: string | number | Buffer | undefined;
|
|
40
|
+
break?: string | number | Buffer<ArrayBufferLike> | undefined;
|
|
38
41
|
/**
|
|
39
42
|
* if break is a string, the encoding
|
|
40
43
|
* to use
|
|
@@ -42,4 +45,6 @@ export type BufferLineTransformOptions = {
|
|
|
42
45
|
breakEncoding?: BufferEncoding | undefined;
|
|
43
46
|
};
|
|
44
47
|
import { Transform } from 'node:stream';
|
|
48
|
+
import type { TransformCallback } from 'node:stream';
|
|
49
|
+
import type { TransformOptions } from 'node:stream';
|
|
45
50
|
//# sourceMappingURL=buffer-line-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE
|
|
1
|
+
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;;;;GAMG;AAEH;IACE;;;;;OAKG;IACH,sBAFW,gBAAgB,GAAG,0BAA0B,EAyBvD;IAhBC,uDAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,uBAAuB;IACvB,SADW,MAAM,EAAE,CACF;IAGnB;;;;;OAKG;IACH,2BALW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,iBAAiB,QAiD3B;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;;;0BA1HyB,aAAa;uCAIH,aAAa;sCADd,aAAa"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { Transform } from 'node:stream';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @import {TransformOptions} from 'node:stream';
|
|
8
|
+
* @import {TransformCallback} from 'node:stream';
|
|
9
|
+
*/
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* @typedef {object} BufferLineTransformOptions
|
|
8
13
|
* @property {Buffer | string | number} [break] line break matcher for
|
|
@@ -16,8 +21,7 @@ export default class BufferLineTransform extends Transform {
|
|
|
16
21
|
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
17
22
|
* stream and writing each line as a Buffer in object mode
|
|
18
23
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
* BufferLineTransformOptions} [options]
|
|
24
|
+
* @param {TransformOptions & BufferLineTransformOptions} [options]
|
|
21
25
|
*/
|
|
22
26
|
constructor(options) {
|
|
23
27
|
const {
|
|
@@ -47,7 +51,7 @@ export default class BufferLineTransform extends Transform {
|
|
|
47
51
|
/**
|
|
48
52
|
* @param {any} chunk
|
|
49
53
|
* @param {BufferEncoding | 'buffer'} encoding
|
|
50
|
-
* @param {
|
|
54
|
+
* @param {TransformCallback} cb
|
|
51
55
|
* @override
|
|
52
56
|
*/
|
|
53
57
|
_transform(chunk, encoding, cb) {
|
|
@@ -99,7 +103,7 @@ export default class BufferLineTransform extends Transform {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
/**
|
|
102
|
-
* @param {
|
|
106
|
+
* @param {TransformCallback} cb
|
|
103
107
|
* @override
|
|
104
108
|
*/
|
|
105
109
|
_flush(cb) {
|
package/src/node/fs-stream.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export function fsStreamReady(stream:
|
|
1
|
+
export function fsStreamReady(stream: ReadStream | WriteStream | Socket): Promise<void>;
|
|
2
2
|
export function makeFsStreamWriter(filePath: string | undefined | null): Promise<{
|
|
3
3
|
write: (data: any) => Promise<void>;
|
|
4
4
|
flush: () => Promise<void>;
|
|
5
5
|
close: () => Promise<void>;
|
|
6
6
|
} | undefined>;
|
|
7
7
|
export type FsStreamWriter = NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>;
|
|
8
|
+
import type { ReadStream } from 'fs';
|
|
9
|
+
import type { WriteStream } from 'fs';
|
|
10
|
+
import type { Socket } from 'net';
|
|
8
11
|
//# sourceMappingURL=fs-stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAcO,sCAHI,UAAU,GAAG,WAAW,GAAG,MAAM,GAC/B,OAAO,CAAC,IAAI,CAAC,CAgCtB;AAIG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eAsEpC;6BAvEa,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;gCAzC5C,IAAI;iCACH,IAAI;4BACT,KAAK"}
|
package/src/node/fs-stream.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { createWriteStream } from 'node:fs';
|
|
2
|
-
import process from 'node:process';
|
|
3
1
|
import { open } from 'node:fs/promises';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { promisify } from 'node:util';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @import {ReadStream} from 'fs';
|
|
7
|
+
* @import {WriteStream} from 'fs';
|
|
8
|
+
* @import {Socket} from 'net';
|
|
9
|
+
*/
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
|
-
* @param {
|
|
7
|
-
* | import('fs').WriteStream
|
|
8
|
-
* | import('net').Socket} stream
|
|
12
|
+
* @param {ReadStream | WriteStream | Socket} stream
|
|
9
13
|
* @returns {Promise<void>}
|
|
10
14
|
*/
|
|
11
15
|
export const fsStreamReady = stream =>
|
|
@@ -40,10 +44,6 @@ export const fsStreamReady = stream =>
|
|
|
40
44
|
stream.on('error', onError);
|
|
41
45
|
});
|
|
42
46
|
|
|
43
|
-
const noPath = /** @type {import('fs').PathLike} */ (
|
|
44
|
-
/** @type {unknown} */ (undefined)
|
|
45
|
-
);
|
|
46
|
-
|
|
47
47
|
/** @typedef {NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>} FsStreamWriter */
|
|
48
48
|
/** @param {string | undefined | null} filePath */
|
|
49
49
|
export const makeFsStreamWriter = async filePath => {
|
|
@@ -51,12 +51,20 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const useStdout = filePath === '-';
|
|
55
|
+
const { handle, stream } = await (async () => {
|
|
56
|
+
if (useStdout) {
|
|
57
|
+
return { handle: undefined, stream: process.stdout };
|
|
58
|
+
}
|
|
59
|
+
const fh = await open(filePath, 'a');
|
|
60
|
+
return { handle: fh, stream: fh.createWriteStream({ flush: true }) };
|
|
61
|
+
})();
|
|
59
62
|
await fsStreamReady(stream);
|
|
63
|
+
const writeAsync = promisify(stream.write.bind(stream));
|
|
64
|
+
const closeAsync =
|
|
65
|
+
useStdout || !(/** @type {any} */ (stream).close)
|
|
66
|
+
? undefined
|
|
67
|
+
: promisify(/** @type {WriteStream} */ (stream).close.bind(stream));
|
|
60
68
|
|
|
61
69
|
let flushed = Promise.resolve();
|
|
62
70
|
let closed = false;
|
|
@@ -77,20 +85,14 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
77
85
|
};
|
|
78
86
|
|
|
79
87
|
const write = async data => {
|
|
80
|
-
/** @type {Promise<void>} */
|
|
81
88
|
const written = closed
|
|
82
89
|
? Promise.reject(Error('Stream closed'))
|
|
83
|
-
:
|
|
84
|
-
stream.write(data, err => {
|
|
85
|
-
if (err) {
|
|
86
|
-
reject(err);
|
|
87
|
-
} else {
|
|
88
|
-
resolve();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
90
|
+
: writeAsync(data);
|
|
92
91
|
updateFlushed(written);
|
|
93
|
-
|
|
92
|
+
const waitForDrain = await written;
|
|
93
|
+
if (waitForDrain) {
|
|
94
|
+
await new Promise(resolve => stream.once('drain', resolve));
|
|
95
|
+
}
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
const flush = async () => {
|
|
@@ -107,8 +109,7 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
107
109
|
// TODO: Consider creating a single Error here to use a write rejection
|
|
108
110
|
closed = true;
|
|
109
111
|
await flush();
|
|
110
|
-
|
|
111
|
-
stream.close?.();
|
|
112
|
+
await closeAsync?.();
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
stream.on('error', err => updateFlushed(Promise.reject(err)));
|
|
@@ -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":"AAOO;;EA8DN;AAGM,wDAON"}
|
package/src/node/shutdown.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import anylogger from 'anylogger';
|
|
3
3
|
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-ignore TODO remove when anylogger has types
|
|
4
6
|
const console = anylogger('shutdown');
|
|
5
7
|
|
|
6
8
|
export const makeFreshShutdown = (verbose = true) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @type {(namespace: string) => string} */
|
|
2
2
|
export const normalizeSenderNamespace: (namespace: string) => string;
|
|
3
|
-
export function makePrioritySendersManager(sendersNode: ERef<
|
|
3
|
+
export function makePrioritySendersManager(sendersNode: ERef<StorageNode>): {
|
|
4
4
|
/**
|
|
5
5
|
* @param {string} rawNamespace
|
|
6
6
|
* @param {string} address
|
|
@@ -28,4 +28,6 @@ export function makePrioritySendersManager(sendersNode: ERef<import("./lib-chain
|
|
|
28
28
|
remove: (rawNamespace: string, address: string) => Promise<void>;
|
|
29
29
|
}>;
|
|
30
30
|
export type PrioritySendersManager = ReturnType<typeof makePrioritySendersManager>;
|
|
31
|
+
import type { StorageNode } from './lib-chainStorage.js';
|
|
32
|
+
import type { ERef } from '@endo/far';
|
|
31
33
|
//# sourceMappingURL=priority-senders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"
|
|
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;IA0CxB;;;;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;iCA1G7B,uBAAuB;0BAD9B,WAAW"}
|
package/src/priority-senders.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Fail, q } from '@endo/errors';
|
|
2
2
|
import { E, Far } from '@endo/far';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {ERef} from '@endo/far';
|
|
6
|
+
* @import {StorageNode} from './lib-chainStorage.js';
|
|
7
|
+
*/
|
|
8
|
+
|
|
4
9
|
const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/;
|
|
5
10
|
|
|
6
11
|
/** @type {(namespace: string) => string} */
|
|
@@ -15,7 +20,7 @@ harden(normalizeSenderNamespace);
|
|
|
15
20
|
/**
|
|
16
21
|
* XXX lets holder manage sender list for all namespaces
|
|
17
22
|
*
|
|
18
|
-
* @param {ERef<
|
|
23
|
+
* @param {ERef<StorageNode>} sendersNode
|
|
19
24
|
*/
|
|
20
25
|
export const makePrioritySendersManager = sendersNode => {
|
|
21
26
|
/**
|
|
@@ -32,7 +37,7 @@ export const makePrioritySendersManager = sendersNode => {
|
|
|
32
37
|
/**
|
|
33
38
|
* Write a list of namespaces into a storage node.
|
|
34
39
|
*
|
|
35
|
-
* @param {
|
|
40
|
+
* @param {StorageNode} node
|
|
36
41
|
* @param {Set<string>} namespaces
|
|
37
42
|
*/
|
|
38
43
|
const refreshVstorage = (node, namespaces) => {
|
package/src/queue.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makeWithQueue():
|
|
1
|
+
export function makeWithQueue(): (inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
2
2
|
//# sourceMappingURL=queue.d.ts.map
|
package/src/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,kCA2BqB,OAFf,CAEoB,MAKH,GAAG,MAHlB,UAAU,CAAC,CAAC,CAGU,KAFpB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAkB/C"}
|
package/src/ses-utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export function makeLimitedConsole(makeLogger: (level: string) => (...args: unknown[]) => void): LimitedConsole;
|
|
2
2
|
/**
|
|
3
3
|
* @template T
|
|
4
4
|
* @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
* @template T
|
|
19
19
|
* @typedef {T extends PromiseLike<any>
|
|
20
20
|
* ? Awaited<T>
|
|
21
|
-
* : T extends
|
|
22
|
-
* ?
|
|
23
|
-
* :
|
|
21
|
+
* : T extends RemotableBrand<any, any> | RemotableObject
|
|
22
|
+
* ? T
|
|
23
|
+
* : T extends {}
|
|
24
|
+
* ? Simplify<DeeplyAwaitedObject<T>>
|
|
25
|
+
* : Awaited<T>} DeeplyAwaited
|
|
24
26
|
*/
|
|
25
27
|
/**
|
|
26
28
|
* A more constrained version of {deeplyFulfilled} for type safety until
|
|
@@ -30,10 +32,17 @@
|
|
|
30
32
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
31
33
|
*/
|
|
32
34
|
export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>;
|
|
35
|
+
export function stripPrefix(prefix: string, str: string): string;
|
|
36
|
+
export function throwErrorCode<Code extends string>(details: Parameters<typeof makeError>[0], code: Code, opts?: Parameters<typeof makeError>[2] & {
|
|
37
|
+
constructor?: Parameters<typeof makeError>[1];
|
|
38
|
+
}): never;
|
|
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
|
+
export function tryJsonParse(jsonText: string, onError: string | ((err: Error) => unknown)): any;
|
|
33
41
|
export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
34
42
|
export function aggregateTryFinally<T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<unknown>): ReturnType<() => Promise<T>>;
|
|
35
43
|
export function withDeferredCleanup<T>(fn: (addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>): ReturnType<(addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>>;
|
|
36
44
|
export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
|
|
45
|
+
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>;
|
|
37
46
|
export const forever: AsyncIterable<undefined>;
|
|
38
47
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
39
48
|
export function untilTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
@@ -54,7 +63,17 @@ export function synchronizedTee<T = unknown>(sourceStream: AsyncIterator<T, void
|
|
|
54
63
|
export type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
55
64
|
export type Callable = (...args: any[]) => any;
|
|
56
65
|
export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>; };
|
|
57
|
-
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
66
|
+
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends RemotableBrand<any, any> | RemotableObject ? T : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
58
67
|
export type AllDefined<T extends Record<string, unknown>> = { [P in keyof T]: Exclude<T[P], undefined>; };
|
|
68
|
+
import { objectMap } from '@endo/common/object-map.js';
|
|
69
|
+
import { objectMetaMap } from '@endo/common/object-meta-map.js';
|
|
70
|
+
import { fromUniqueEntries } from '@endo/common/from-unique-entries.js';
|
|
71
|
+
import type { LimitedConsole } from './js-utils.js';
|
|
72
|
+
import { makeError } from '@endo/errors';
|
|
73
|
+
import type { Permit } from './types.js';
|
|
74
|
+
import type { Attenuated } from './types.js';
|
|
59
75
|
import type { ERef } from '@endo/far';
|
|
76
|
+
import type { RemotableBrand } from '@endo/eventual-send';
|
|
77
|
+
import type { RemotableObject } from '@endo/pass-style';
|
|
78
|
+
export { objectMap, objectMetaMap, fromUniqueEntries };
|
|
60
79
|
//# sourceMappingURL=ses-utils.d.ts.map
|
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,"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