@agoric/internal 0.3.3-upgrade-16-fi-dev-8879538.0 → 0.3.3-upgrade-16-dev-f908f89.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.
Files changed (50) hide show
  1. package/package.json +5 -5
  2. package/src/batched-deliver.d.ts +4 -1
  3. package/src/batched-deliver.d.ts.map +1 -1
  4. package/src/batched-deliver.js +4 -1
  5. package/src/callback.d.ts.map +1 -1
  6. package/src/callback.js +24 -22
  7. package/src/chain-storage-paths.d.ts +2 -3
  8. package/src/chain-storage-paths.d.ts.map +1 -1
  9. package/src/chain-storage-paths.js +2 -3
  10. package/src/config.d.ts +7 -5
  11. package/src/config.d.ts.map +1 -1
  12. package/src/config.js +12 -8
  13. package/src/lib-chainStorage.d.ts +26 -11
  14. package/src/lib-chainStorage.d.ts.map +1 -1
  15. package/src/lib-chainStorage.js +69 -35
  16. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
  17. package/src/lib-nodejs/spawnSubprocessWorker.js +7 -5
  18. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
  19. package/src/lib-nodejs/worker-protocol.js +5 -7
  20. package/src/magic-cookie-test-only.js +2 -2
  21. package/src/marshal.d.ts +3 -2
  22. package/src/marshal.d.ts.map +1 -1
  23. package/src/marshal.js +18 -12
  24. package/src/method-tools.d.ts.map +1 -1
  25. package/src/method-tools.js +17 -16
  26. package/src/netstring.d.ts +4 -5
  27. package/src/netstring.d.ts.map +1 -1
  28. package/src/netstring.js +8 -11
  29. package/src/node/buffer-line-transform.d.ts +15 -10
  30. package/src/node/buffer-line-transform.d.ts.map +1 -1
  31. package/src/node/buffer-line-transform.js +11 -8
  32. package/src/node/fs-stream.js +1 -1
  33. package/src/node/utils.d.ts +9 -0
  34. package/src/node/utils.d.ts.map +1 -0
  35. package/src/node/utils.js +46 -0
  36. package/src/priority-senders.d.ts.map +1 -1
  37. package/src/priority-senders.js +7 -3
  38. package/src/queue.js +2 -2
  39. package/src/storage-test-utils.d.ts +17 -8
  40. package/src/storage-test-utils.d.ts.map +1 -1
  41. package/src/storage-test-utils.js +84 -33
  42. package/src/testing-utils.d.ts.map +1 -1
  43. package/src/testing-utils.js +7 -5
  44. package/src/types.d.ts +10 -1
  45. package/src/upgrade-api.d.ts +2 -2
  46. package/src/upgrade-api.d.ts.map +1 -1
  47. package/src/upgrade-api.js +8 -8
  48. package/src/utils.d.ts +23 -21
  49. package/src/utils.d.ts.map +1 -1
  50. package/src/utils.js +49 -68
@@ -6,11 +6,10 @@ import { Transform } from 'stream';
6
6
 
7
7
  export function arrayEncoderStream() {
8
8
  /**
9
- *
10
- * @this {{ push: (b: Buffer) => void }}
11
- * @param {*} object
9
+ * @param {any} object
12
10
  * @param {BufferEncoding} encoding
13
- * @param {*} callback
11
+ * @param {any} callback
12
+ * @this {{ push: (b: Buffer) => void }}
14
13
  */
15
14
  function transform(object, encoding, callback) {
16
15
  if (!Array.isArray(object)) {
@@ -30,11 +29,10 @@ export function arrayEncoderStream() {
30
29
 
31
30
  export function arrayDecoderStream() {
32
31
  /**
33
- *
34
- * @this {{ push: (b: Buffer) => void }}
35
32
  * @param {Buffer} buf
36
33
  * @param {BufferEncoding} encoding
37
- * @param {*} callback
34
+ * @param {any} callback
35
+ * @this {{ push: (b: Buffer) => void }}
38
36
  */
39
37
  function transform(buf, encoding, callback) {
40
38
  let err;
@@ -3,8 +3,8 @@
3
3
  const cookie = harden({});
4
4
 
5
5
  /**
6
- * Facilitate static analysis to prevent
7
- * demo/test facilities from being bundled in production.
6
+ * Facilitate static analysis to prevent demo/test facilities from being bundled
7
+ * in production.
8
8
  */
9
9
  export const notForProductionUse = () => {
10
10
  return cookie;
package/src/marshal.d.ts CHANGED
@@ -5,13 +5,14 @@ export function makeBoardRemote({ boardId, iface }: {
5
5
  export function slotToBoardRemote(boardId: string, iface: string): BoardRemote;
6
6
  export function boardSlottingMarshaller(slotToVal?: ((slot: string, iface: string) => any) | undefined): Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
7
7
  export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import("@endo/marshal").makeMarshal>["fromCapData"], index: number): any;
8
- export function makeHistoryReviver(entries: Array<[string, string]>, slotToVal?: ((slot: string, iface?: string) => any) | undefined): {
8
+ export function makeHistoryReviver(entries: [string, string][], slotToVal?: ((slot: string, iface?: string) => any) | undefined): {
9
9
  getItem: (key: string) => any;
10
10
  children: (prefix: string) => string[];
11
11
  has: (k: string) => boolean;
12
12
  };
13
13
  /**
14
- * Should be a union with Remotable, but that's `any`, making this type meaningless
14
+ * Should be a union with Remotable, but that's `any`, making this type
15
+ * meaningless
15
16
  */
16
17
  export type BoardRemote = {
17
18
  getBoardId: () => string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAiBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAmB9B,4DAHW,MAAM,SAAS,MAAM,KAAK,GAAG,gBAClC,IAAI,CAAC,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAM7F;AA0BM,4CANI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,UAAU,CAAC,cAAc,eAAe,EAAE,WAAW,CAAC,CAAC,aAAa,CAAC,SACrE,MAAM,GACL,GAAG,CAwBd;AASM,4CAHI,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,sBAChB,MAAM,UAAU,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;;;;0BAzHY;IAAE,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAE"}
1
+ {"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAkBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,4DANW,MAAM,SAAS,MAAM,KAAK,GAAG,gBAClC,IAAI,CAChB,OAAW,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAClD,WAAe,GAAG,aAAa,CAC5B,CAMH;AA6BM,4CATI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,UAAU,CACpB,cAAkB,eAAe,EAAE,WAAW,CAC3C,CAAC,aAAa,CAAC,SACR,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,sBACX,MAAM,UAAU,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;;;;;0BA9HY;IAAE,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAE"}
package/src/marshal.js CHANGED
@@ -6,13 +6,14 @@ import { isStreamCell } from './lib-chainStorage.js';
6
6
  const { Fail } = assert;
7
7
 
8
8
  /**
9
- * Should be a union with Remotable, but that's `any`, making this type meaningless
9
+ * Should be a union with Remotable, but that's `any`, making this type
10
+ * meaningless
10
11
  *
11
12
  * @typedef {{ getBoardId: () => string | null }} BoardRemote
12
13
  */
13
14
 
14
15
  /**
15
- * @param {{ boardId: string | null, iface?: string }} slotInfo
16
+ * @param {{ boardId: string | null; iface?: string }} slotInfo
16
17
  * @returns {BoardRemote}
17
18
  */
18
19
  export const makeBoardRemote = ({ boardId, iface }) => {
@@ -36,13 +37,15 @@ const boardValToSlot = val => {
36
37
  };
37
38
 
38
39
  /**
39
- * A marshaller which can serialize getBoardId() -bearing
40
- * Remotables. This allows the caller to pick their slots. The
41
- * deserializer is configurable: the default cannot handle
42
- * Remotable-bearing data.
40
+ * A marshaller which can serialize getBoardId() -bearing Remotables. This
41
+ * allows the caller to pick their slots. The deserializer is configurable: the
42
+ * default cannot handle Remotable-bearing data.
43
43
  *
44
44
  * @param {(slot: string, iface: string) => any} [slotToVal]
45
- * @returns {Omit<import('@endo/marshal').Marshal<string | null>, 'serialize' | 'unserialize'>}
45
+ * @returns {Omit<
46
+ * import('@endo/marshal').Marshal<string | null>,
47
+ * 'serialize' | 'unserialize'
48
+ * >}
46
49
  */
47
50
  export const boardSlottingMarshaller = (slotToVal = undefined) => {
48
51
  return makeMarshal(boardValToSlot, slotToVal, {
@@ -70,9 +73,12 @@ harden(assertCapData);
70
73
  *
71
74
  * @param {Map<string, string>} data
72
75
  * @param {string} key
73
- * @param {ReturnType<typeof import('@endo/marshal').makeMarshal>['fromCapData']} fromCapData
74
- * @param {number} index index of the desired value in a deserialized stream cell
75
- * @return {any}
76
+ * @param {ReturnType<
77
+ * typeof import('@endo/marshal').makeMarshal
78
+ * >['fromCapData']} fromCapData
79
+ * @param {number} index index of the desired value in a deserialized stream
80
+ * cell
81
+ * @returns {any}
76
82
  */
77
83
  export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
78
84
  const serialized = data.get(key) || Fail`no data for ${key}`;
@@ -90,7 +96,7 @@ export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
90
96
  const marshalled = values.at(index);
91
97
  assert.typeof(marshalled, 'string');
92
98
 
93
- /** @type {import("@endo/marshal").CapData<string>} */
99
+ /** @type {import('@endo/marshal').CapData<string>} */
94
100
  const capData = harden(JSON.parse(marshalled));
95
101
  assertCapData(capData);
96
102
 
@@ -102,7 +108,7 @@ harden(unmarshalFromVstorage);
102
108
  /**
103
109
  * Provide access to object graphs serialized in vstorage.
104
110
  *
105
- * @param {Array<[string, string]>} entries
111
+ * @param {[string, string][]} entries
106
112
  * @param {(slot: string, iface?: string) => any} [slotToVal]
107
113
  */
108
114
  export const makeHistoryReviver = (entries, slotToVal = undefined) => {
@@ -1 +1 @@
1
- {"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"AAyCO,+BAFM,CAAC,2BADH,MAAM,CACJ,CAAC,AADK,EAAE,GAAG,CAAC,GACZ,CAAC,EAAE,CAsBf;AAUM,qCAHW,CAAC,2BAAR,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,MAAM,EAAE,CAKlB;AA+BI,+BAFM,CAAC,wCAAD,CAAC,AADF,GACC,CAAC,CAiBX"}
1
+ {"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"AA0CO,+BAFM,CAAC,2BADH,MAAM,CACJ,CAAC,AADK,EAAE,GAAG,CAAC,GACZ,CAAC,EAAE,CAsBf;AAUM,qCAHW,CAAC,2BAAR,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,MAAM,EAAE,CAKlB;AA+BI,+BAFM,CAAC,wCAAD,CAAC,AADF,GACC,CAAC,CAiBX"}
@@ -2,7 +2,8 @@
2
2
  import { isObject } from '@endo/marshal';
3
3
 
4
4
  /**
5
- * @file method-tools use dynamic property lookup, which is not Jessie-compatible
5
+ * @file method-tools use dynamic property lookup, which is not
6
+ * Jessie-compatible
6
7
  */
7
8
 
8
9
  const { getPrototypeOf, create, fromEntries, getOwnPropertyDescriptors } =
@@ -12,8 +13,8 @@ const { ownKeys, apply } = Reflect;
12
13
  /**
13
14
  * Prioritize symbols as earlier than strings.
14
15
  *
15
- * @param {string|symbol} a
16
- * @param {string|symbol} b
16
+ * @param {string | symbol} a
17
+ * @param {string | symbol} b
17
18
  * @returns {-1 | 0 | 1}
18
19
  */
19
20
  const compareStringified = (a, b) => {
@@ -77,22 +78,22 @@ export const getStringMethodNames = val =>
77
78
  /**
78
79
  * TODO This function exists only to ease the
79
80
  * https://github.com/Agoric/agoric-sdk/pull/5970 transition, from all methods
80
- * being own properties to methods being inherited from a common prototype.
81
- * This transition breaks two patterns used in prior code: autobinding,
82
- * and enumerating methods by enumerating own properties. For both, the
83
- * preferred repairs are
84
- * * autobinding: Replace, for example,
85
- * `foo(obj.method)` with `foo(arg => `obj.method(arg))`. IOW, stop relying
86
- * on expressions like `obj.method` to extract a method still bound to the
87
- * state of `obj` because, for virtual and durable objects,
88
- * they no longer will after #5970.
89
- * * method enumeration: Replace, for example
90
- * `Reflect.ownKeys(obj)` with `getMethodNames(obj)`.
81
+ * being own properties to methods being inherited from a common prototype. This
82
+ * transition breaks two patterns used in prior code: autobinding, and
83
+ * enumerating methods by enumerating own properties. For both, the preferred
84
+ * repairs are
85
+ *
86
+ * - autobinding: Replace, for example, `foo(obj.method)` with `foo(arg =>
87
+ * `obj.method(arg))`. IOW, stop relying on expressions like `obj.method`to
88
+ * extract a method still bound to the state of`obj` because, for virtual and
89
+ * durable objects, they no longer will after #5970.
90
+ * - method enumeration: Replace, for example `Reflect.ownKeys(obj)` with
91
+ * `getMethodNames(obj)`.
91
92
  *
92
93
  * Once all problematic cases have been converted in this manner, this
93
94
  * `bindAllMethods` hack can and TODO should be deleted. However, we currently
94
- * have no reliable static way to track down and fix all autobinding sites.
95
- * For those objects that have not yet been fully repaired by the above two
95
+ * have no reliable static way to track down and fix all autobinding sites. For
96
+ * those objects that have not yet been fully repaired by the above two
96
97
  * techniques, `bindAllMethods` creates an object that acts much like the
97
98
  * pre-#5970 objects, with all their methods as instance-bound own properties.
98
99
  * It does this by making a new object inheriting from `obj` where the new
@@ -5,19 +5,18 @@
5
5
  export function encode(data: Buffer): Buffer;
6
6
  export function netstringEncoderStream(): Transform;
7
7
  /**
8
- *
9
8
  * @param {Buffer} data containing zero or more netstrings and maybe some
10
- * leftover bytes
9
+ * leftover bytes
11
10
  * @param {number} [optMaxChunkSize]
12
- * @returns {{ leftover: Buffer, payloads: Buffer[] }} zero or more decoded Buffers, one per netstring,
11
+ * @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
12
+ * Buffers, one per netstring,
13
13
  */
14
14
  export function decode(data: Buffer, optMaxChunkSize?: number | undefined): {
15
15
  leftover: Buffer;
16
16
  payloads: Buffer[];
17
17
  };
18
18
  /**
19
- *
20
- * @param {number} [optMaxChunkSize ]
19
+ * @param {number} [optMaxChunkSize]
21
20
  * @returns {Transform}
22
21
  */
23
22
  export function netstringDecoderStream(optMaxChunkSize?: number | undefined): Transform;
@@ -1 +1 @@
1
- {"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAuBC;AAED;;;;;;GAMG;AACH,6BALW,MAAM,yCAGJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAkCpD;AAED;;;;GAIG;AAEH,8EAHa,SAAS,CAqCrB;0BA1HyB,QAAQ"}
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,yCAGJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCpD;AAED;;;GAGG;AAEH,8EAHa,SAAS,CAoCrB;0BAvHyB,QAAQ"}
package/src/netstring.js CHANGED
@@ -20,11 +20,10 @@ export function encode(data) {
20
20
  // input is a sequence of strings, output is a byte pipe
21
21
  export function netstringEncoderStream() {
22
22
  /**
23
- *
24
- * @this {{ push: (b: Buffer) => void }}
25
23
  * @param {Buffer} chunk
26
24
  * @param {BufferEncoding} encoding
27
- * @param {*} callback
25
+ * @param {any} callback
26
+ * @this {{ push: (b: Buffer) => void }}
28
27
  */
29
28
  function transform(chunk, encoding, callback) {
30
29
  if (!Buffer.isBuffer(chunk)) {
@@ -44,11 +43,11 @@ export function netstringEncoderStream() {
44
43
  }
45
44
 
46
45
  /**
47
- *
48
46
  * @param {Buffer} data containing zero or more netstrings and maybe some
49
- * leftover bytes
47
+ * leftover bytes
50
48
  * @param {number} [optMaxChunkSize]
51
- * @returns {{ leftover: Buffer, payloads: Buffer[] }} zero or more decoded Buffers, one per netstring,
49
+ * @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
50
+ * Buffers, one per netstring,
52
51
  */
53
52
  export function decode(data, optMaxChunkSize) {
54
53
  // TODO: it would be more efficient to accumulate pending data in an array,
@@ -85,19 +84,17 @@ export function decode(data, optMaxChunkSize) {
85
84
  }
86
85
 
87
86
  /**
88
- *
89
- * @param {number} [optMaxChunkSize ]
87
+ * @param {number} [optMaxChunkSize]
90
88
  * @returns {Transform}
91
89
  */
92
90
  // input is a byte pipe, output is a sequence of Buffers
93
91
  export function netstringDecoderStream(optMaxChunkSize) {
94
92
  let buffered = Buffer.from('');
95
93
  /**
96
- *
97
- * @this {{ push: (b: Buffer) => void }}
98
94
  * @param {Buffer} chunk
99
95
  * @param {BufferEncoding} encoding
100
- * @param {*} callback
96
+ * @param {any} callback
97
+ * @this {{ push: (b: Buffer) => void }}
101
98
  */
102
99
  function transform(chunk, encoding, callback) {
103
100
  if (!Buffer.isBuffer(chunk)) {
@@ -1,26 +1,29 @@
1
1
  /**
2
2
  * @typedef {object} BufferLineTransformOptions
3
- * @property {Buffer | string | number} [break] line break matcher for Buffer.indexOf() (default: 10)
4
- * @property {BufferEncoding} [breakEncoding] if break is a string, the encoding to use
3
+ * @property {Buffer | string | number} [break] line break matcher for
4
+ * Buffer.indexOf() (default: 10)
5
+ * @property {BufferEncoding} [breakEncoding] if break is a string, the encoding
6
+ * to use
5
7
  */
6
8
  export default class BufferLineTransform extends Transform {
7
9
  /**
8
- * The BufferLineTransform is reading String or Buffer content from a Readable stream
9
- * and writing each line as a Buffer in object mode
10
+ * The BufferLineTransform is reading String or Buffer content from a Readable
11
+ * stream and writing each line as a Buffer in object mode
10
12
  *
11
- * @param {import('node:stream').TransformOptions & BufferLineTransformOptions} [options]
13
+ * @param {import('node:stream').TransformOptions &
14
+ * BufferLineTransformOptions} [options]
12
15
  */
13
16
  constructor(options?: (import("stream").TransformOptions & BufferLineTransformOptions) | undefined);
14
17
  _breakValue: string | number | Buffer;
15
18
  _breakEncoding: BufferEncoding | undefined;
16
19
  _breakLength: number;
17
- /** @type {Array<Buffer>} */
18
- _chunks: Array<Buffer>;
20
+ /** @type {Buffer[]} */
21
+ _chunks: Buffer[];
19
22
  /**
20
- * @override
21
23
  * @param {any} chunk
22
24
  * @param {BufferEncoding | 'buffer'} encoding
23
25
  * @param {import('node:stream').TransformCallback} cb
26
+ * @override
24
27
  */
25
28
  override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb: import("node:stream").TransformCallback): void;
26
29
  /** @param {Buffer} line */
@@ -28,11 +31,13 @@ export default class BufferLineTransform extends Transform {
28
31
  }
29
32
  export type BufferLineTransformOptions = {
30
33
  /**
31
- * line break matcher for Buffer.indexOf() (default: 10)
34
+ * line break matcher for
35
+ * Buffer.indexOf() (default: 10)
32
36
  */
33
37
  break?: string | number | Buffer | undefined;
34
38
  /**
35
- * if break is a string, the encoding to use
39
+ * if break is a string, the encoding
40
+ * to use
36
41
  */
37
42
  breakEncoding?: BufferEncoding | undefined;
38
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;GAIG;AAEH;IACE;;;;;OAKG;IACH,oGAuBC;IAhBC,sCAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,4BAA4B;IAC5B,SADW,KAAK,CAAC,MAAM,CAAC,CACP;IAGnB;;;;;OAKG;IACH,2BAJW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,OAAO,aAAa,EAAE,iBAAiB,QAgDjD;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;0BAnHyB,aAAa"}
1
+ {"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE;;;;;;OAMG;IACH,oGAuBC;IAhBC,sCAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,uBAAuB;IACvB,SADW,MAAM,EAAE,CACF;IAGnB;;;;;OAKG;IACH,2BALW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,OAAO,aAAa,EAAE,iBAAiB,QAiDjD;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;;;0BAtHyB,aAAa"}
@@ -5,16 +5,19 @@ import { Transform } from 'node:stream';
5
5
 
6
6
  /**
7
7
  * @typedef {object} BufferLineTransformOptions
8
- * @property {Buffer | string | number} [break] line break matcher for Buffer.indexOf() (default: 10)
9
- * @property {BufferEncoding} [breakEncoding] if break is a string, the encoding to use
8
+ * @property {Buffer | string | number} [break] line break matcher for
9
+ * Buffer.indexOf() (default: 10)
10
+ * @property {BufferEncoding} [breakEncoding] if break is a string, the encoding
11
+ * to use
10
12
  */
11
13
 
12
14
  export default class BufferLineTransform extends Transform {
13
15
  /**
14
- * The BufferLineTransform is reading String or Buffer content from a Readable stream
15
- * and writing each line as a Buffer in object mode
16
+ * The BufferLineTransform is reading String or Buffer content from a Readable
17
+ * stream and writing each line as a Buffer in object mode
16
18
  *
17
- * @param {import('node:stream').TransformOptions & BufferLineTransformOptions} [options]
19
+ * @param {import('node:stream').TransformOptions &
20
+ * BufferLineTransformOptions} [options]
18
21
  */
19
22
  constructor(options) {
20
23
  const {
@@ -37,15 +40,15 @@ export default class BufferLineTransform extends Transform {
37
40
  }
38
41
  this._breakLength = breakLength;
39
42
 
40
- /** @type {Array<Buffer>} */
43
+ /** @type {Buffer[]} */
41
44
  this._chunks = [];
42
45
  }
43
46
 
44
47
  /**
45
- * @override
46
48
  * @param {any} chunk
47
49
  * @param {BufferEncoding | 'buffer'} encoding
48
50
  * @param {import('node:stream').TransformCallback} cb
51
+ * @override
49
52
  */
50
53
  _transform(chunk, encoding, cb) {
51
54
  try {
@@ -96,8 +99,8 @@ export default class BufferLineTransform extends Transform {
96
99
  }
97
100
 
98
101
  /**
99
- * @override
100
102
  * @param {import('node:stream').TransformCallback} cb
103
+ * @override
101
104
  */
102
105
  _flush(cb) {
103
106
  if (this._chunks.length) {
@@ -2,7 +2,7 @@ import { createWriteStream } from 'node:fs';
2
2
  import { open } from 'node:fs/promises';
3
3
 
4
4
  /**
5
- * @param {import("fs").ReadStream | import("fs").WriteStream} stream
5
+ * @param {import('fs').ReadStream | import('fs').WriteStream} stream
6
6
  * @returns {Promise<void>}
7
7
  */
8
8
  export const fsStreamReady = stream =>
@@ -0,0 +1,9 @@
1
+ export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
2
+ /**
3
+ * @type {<T>(
4
+ * trier: () => Promise<T>,
5
+ * finalizer: (error?: unknown) => Promise<void>,
6
+ * ) => Promise<T>}
7
+ */
8
+ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAYO,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"}
@@ -0,0 +1,46 @@
1
+ // @ts-check
2
+ // @jessie-check
3
+
4
+ // These tools seem cross platform, but they rely on AggregateError in the error
5
+ // handling path, which is currently not available in xsnap
6
+ import 'node:process';
7
+
8
+ /**
9
+ * @template T
10
+ * @param {readonly (T | PromiseLike<T>)[]} items
11
+ * @returns {Promise<T[]>}
12
+ */
13
+ export const PromiseAllOrErrors = async items => {
14
+ return Promise.allSettled(items).then(results => {
15
+ const errors = /** @type {PromiseRejectedResult[]} */ (
16
+ results.filter(({ status }) => status === 'rejected')
17
+ ).map(result => result.reason);
18
+ if (!errors.length) {
19
+ return /** @type {PromiseFulfilledResult<T>[]} */ (results).map(
20
+ result => result.value,
21
+ );
22
+ } else if (errors.length === 1) {
23
+ throw errors[0];
24
+ } else {
25
+ throw AggregateError(errors);
26
+ }
27
+ });
28
+ };
29
+
30
+ /**
31
+ * @type {<T>(
32
+ * trier: () => Promise<T>,
33
+ * finalizer: (error?: unknown) => Promise<void>,
34
+ * ) => Promise<T>}
35
+ */
36
+ export const aggregateTryFinally = async (trier, finalizer) =>
37
+ trier().then(
38
+ async result => finalizer().then(() => result),
39
+ async tryError =>
40
+ finalizer(tryError)
41
+ .then(
42
+ () => tryError,
43
+ finalizeError => AggregateError([tryError, finalizeError]),
44
+ )
45
+ .then(error => Promise.reject(error)),
46
+ );
@@ -1 +1 @@
1
- {"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,IAAI,CAAC,OAAO,uBAAuB,EAAE,WAAW,CAAC;IAsCxD;;;;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"}
1
+ {"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,IAAI,CAAC,OAAO,uBAAuB,EAAE,WAAW,CAAC;IA0CxD;;;;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"}
@@ -20,9 +20,13 @@ harden(normalizeSenderNamespace);
20
20
  */
21
21
  export const makePrioritySendersManager = sendersNode => {
22
22
  /**
23
- * address to tuple with storage node and set of namespaces that requested priority
23
+ * address to tuple with storage node and set of namespaces that requested
24
+ * priority
24
25
  *
25
- * @type {Map<string, readonly [node: StorageNode, namespaces: Set<string>]>}
26
+ * @type {Map<
27
+ * string,
28
+ * readonly [node: StorageNode, namespaces: Set<string>]
29
+ * >}
26
30
  */
27
31
  const addressRecords = new Map();
28
32
 
@@ -47,7 +51,7 @@ export const makePrioritySendersManager = sendersNode => {
47
51
  const node = await E(sendersNode).makeChildNode(address, {
48
52
  sequence: false,
49
53
  });
50
- /** @type {readonly [ node: StorageNode, namespaces: Set<string> ]} */
54
+ /** @type {readonly [node: StorageNode, namespaces: Set<string>]} */
51
55
  const r = [node, new Set()];
52
56
  addressRecords.set(address, r);
53
57
  return r;
package/src/queue.js CHANGED
@@ -3,8 +3,8 @@
3
3
  import { makePromiseKit } from '@endo/promise-kit';
4
4
 
5
5
  /**
6
- * Return a function that can wrap an async or sync method, but
7
- * ensures only one of them (in order) is running at a time.
6
+ * Return a function that can wrap an async or sync method, but ensures only one
7
+ * of them (in order) is running at a time.
8
8
  */
9
9
  export const makeWithQueue = () => {
10
10
  const queue = [];
@@ -1,7 +1,7 @@
1
1
  export function slotToRemotable(_slotId: string, iface?: string): import("@endo/marshal").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>;
2
2
  /**
3
- * A basic marshaller whose unserializer produces Remotables. It can
4
- * only serialize plain data, not Remotables.
3
+ * A basic marshaller whose unserializer produces Remotables. It can only
4
+ * serialize plain data, not Remotables.
5
5
  */
6
6
  export const defaultMarshaller: {
7
7
  toCapData: import("@endo/marshal").ToCapData<string>;
@@ -27,9 +27,18 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
27
27
  } | null | undefined;
28
28
  };
29
29
  export function makeMockChainStorageRoot(): MockChainStorageRoot;
30
+ export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({
31
+ note: string;
32
+ } | {
33
+ node: string;
34
+ owner: string;
35
+ }) & ({
36
+ pattern: string;
37
+ replacement: string;
38
+ } | {})): Promise<void>;
30
39
  /**
31
- * A map corresponding with a total function such that `get(key)`
32
- * is assumed to always succeed.
40
+ * A map corresponding with a total function such that `get(key)` is assumed to
41
+ * always succeed.
33
42
  */
34
43
  export type TotalMap<K, V> = { [k in Exclude<keyof Map<K, V>, "get">]: Map<K, V>[k]; } & {
35
44
  get: (key: K) => V;
@@ -38,10 +47,10 @@ export type TotalMapFrom<T> = T extends Map<infer K, infer V> ? TotalMap<K, V> :
38
47
  export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>;
39
48
  export type MockChainStorageRootMethods = {
40
49
  /**
41
- * Defaults to deserializing slot references into plain Remotable
42
- * objects having the specified interface name (as from `Far(iface)`),
43
- * but can accept a different marshaller for producing Remotables
44
- * that e.g. embed the slot string in their iface name.
50
+ * Defaults to deserializing slot references into plain Remotable objects having
51
+ * the specified interface name (as from `Far(iface)`), but can accept a
52
+ * different marshaller for producing Remotables that e.g. embed the slot
53
+ * string in their iface name.
45
54
  */
46
55
  getBody: (path: string, marshaller?: {
47
56
  toCapData: import("@endo/marshal").ToCapData<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAmCO,yCAHI,MAAM,UACN,MAAM,0GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBwB,GAAG,KAAK,GAAG,CAsB8B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;uDA+FtC;YAAE,QAAQ,CAAC,UAAS;SAAC;;;UAUf,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;EAIvC;AAgBM,4CADO,oBAAoB,CAyBjC;;;;;qBAhOiF,CAAC,EAAK,CAAC,IAA5E,GAAE,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAA6C,CAAC,AAA5C,EAAiD,CAAC,AAA/C,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,CAAyB,CAAC,AAAxB,EAA6B,CAAC,AAA3B,CAAC,CAAC,CAAC,CAAC,GAAC,GAAG;IAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;CAAC;yBAI7E,CAAC,IAAD,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK;6BAsLvD,UAAU,CAAE,OAAO,kBAAkB,CAAC;;;;;;;;oBAI/B,MAAM;;;;;2BAAmC,MAAM,KAAK,OAAO;UAKlE,MAAM,MAAM,EAAE;;;qCAnNuB,uBAAuB;iCAIF,uBAAuB;oCAAvB,uBAAuB"}
1
+ {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAsCO,yCAHI,MAAM,UACN,MAAM,0GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;uDAkGtB;YAAE,QAAS,CAAC,UAAS;SAAE;;;UAOjC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;EAIvC;AAoBM,4CADO,oBAAoB,CA6BjC;AAQM,yCALI,OAAO,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,WACvC,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,iBAkCnD;;;;;qBAjRe,CAAC,EAAK,CAAC,IADV,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CACtB,CAAC,AADuB,EAClB,CAAC,AADoB,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,CAC1C,CAAC,AAD2C,EACtC,CAAC,AADwC,CAAC,CAAC,CAAC,CAAC,GAAE,GAAG;IACvE,GAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;CACpB;yBAIS,CAAC,IAAD,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK;6BAsLvD,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;oBAKxC,MAAM;;;;;2BAEJ,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;;qCA1NuB,uBAAuB;iCAKF,uBAAuB;oCAAvB,uBAAuB"}