@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.
Files changed (132) hide show
  1. package/package.json +32 -36
  2. package/src/action-types.d.ts +47 -20
  3. package/src/action-types.d.ts.map +1 -1
  4. package/src/action-types.js +21 -21
  5. package/src/ava-force-exit.d.mts +2 -0
  6. package/src/ava-force-exit.d.mts.map +1 -0
  7. package/src/ava-force-exit.mjs +7 -0
  8. package/src/batched-deliver.d.ts +2 -2
  9. package/src/batched-deliver.d.ts.map +1 -1
  10. package/src/batched-deliver.js +2 -3
  11. package/src/build-cache-types.d.ts +33 -0
  12. package/src/build-cache-types.d.ts.map +1 -0
  13. package/src/build-cache-types.js +42 -0
  14. package/src/build-cache.d.ts +12 -0
  15. package/src/build-cache.d.ts.map +1 -0
  16. package/src/build-cache.js +184 -0
  17. package/src/callback.d.ts +1 -1
  18. package/src/callback.d.ts.map +1 -1
  19. package/src/callback.js +1 -0
  20. package/src/chain-storage-paths.d.ts.map +1 -1
  21. package/src/chain-storage-paths.js +0 -2
  22. package/src/config.d.ts +3 -3
  23. package/src/config.d.ts.map +1 -1
  24. package/src/config.js +6 -5
  25. package/src/debug.d.ts +2 -2
  26. package/src/debug.d.ts.map +1 -1
  27. package/src/debug.js +19 -5
  28. package/src/hex.d.ts.map +1 -1
  29. package/src/hex.js +18 -22
  30. package/src/index.d.ts +1 -0
  31. package/src/index.js +1 -2
  32. package/src/js-utils.d.ts +17 -2
  33. package/src/js-utils.d.ts.map +1 -1
  34. package/src/js-utils.js +49 -3
  35. package/src/keyMirror.d.ts +3 -0
  36. package/src/keyMirror.d.ts.map +1 -0
  37. package/src/keyMirror.js +45 -0
  38. package/src/kv-store.d.ts +33 -0
  39. package/src/kv-store.d.ts.map +1 -0
  40. package/src/kv-store.js +265 -0
  41. package/src/lib-chainStorage.d.ts +25 -42
  42. package/src/lib-chainStorage.d.ts.map +1 -1
  43. package/src/lib-chainStorage.js +38 -14
  44. package/src/lib-nodejs/ava-unhandled-rejection.d.ts +18 -3
  45. package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -1
  46. package/src/lib-nodejs/ava-unhandled-rejection.js +217 -20
  47. package/src/lib-nodejs/engine-gc.js +2 -2
  48. package/src/lib-nodejs/gc-and-finalize.d.ts +2 -1
  49. package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -1
  50. package/src/lib-nodejs/gc-and-finalize.js +1 -0
  51. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +11 -4
  52. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
  53. package/src/lib-nodejs/spawnSubprocessWorker.js +14 -4
  54. package/src/lib-nodejs/worker-protocol.d.ts +1 -1
  55. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
  56. package/src/lib-nodejs/worker-protocol.js +5 -6
  57. package/src/magic-cookie-test-only.d.ts.map +1 -1
  58. package/src/magic-cookie-test-only.js +0 -2
  59. package/src/marshal/board-client-utils.d.ts.map +1 -1
  60. package/src/marshal/board-client-utils.js +4 -1
  61. package/src/marshal/cap-data.d.ts +9 -1
  62. package/src/marshal/cap-data.d.ts.map +1 -1
  63. package/src/marshal/cap-data.js +1 -2
  64. package/src/marshal/wrap-marshaller.d.ts +34 -7
  65. package/src/marshal/wrap-marshaller.d.ts.map +1 -1
  66. package/src/marshal/wrap-marshaller.js +64 -68
  67. package/src/metrics.d.ts +1 -4
  68. package/src/metrics.d.ts.map +1 -1
  69. package/src/metrics.js +7 -2
  70. package/src/module-utils.d.ts +1 -0
  71. package/src/module-utils.d.ts.map +1 -1
  72. package/src/module-utils.js +17 -0
  73. package/src/natural-sort.d.ts.map +1 -1
  74. package/src/natural-sort.js +7 -3
  75. package/src/netstring.d.ts +1 -1
  76. package/src/netstring.d.ts.map +1 -1
  77. package/src/netstring.js +5 -6
  78. package/src/node/buffer-line-transform.d.ts.map +1 -1
  79. package/src/node/buffer-line-transform.js +0 -1
  80. package/src/node/createBundles.d.ts +7 -3
  81. package/src/node/createBundles.d.ts.map +1 -1
  82. package/src/node/createBundles.js +31 -10
  83. package/src/node/fs-stream.d.ts +8 -5
  84. package/src/node/fs-stream.d.ts.map +1 -1
  85. package/src/node/fs-stream.js +120 -8
  86. package/src/node/read-json.d.ts +2 -0
  87. package/src/node/read-json.d.ts.map +1 -0
  88. package/src/node/read-json.js +16 -0
  89. package/src/node/shutdown.d.ts +6 -2
  90. package/src/node/shutdown.d.ts.map +1 -1
  91. package/src/node/shutdown.js +9 -3
  92. package/src/priority-senders.d.ts.map +1 -1
  93. package/src/priority-senders.js +1 -0
  94. package/src/queue.d.ts.map +1 -1
  95. package/src/queue.js +10 -2
  96. package/src/scratch.d.ts +32 -10
  97. package/src/scratch.d.ts.map +1 -1
  98. package/src/scratch.js +11 -0
  99. package/src/ses-utils.d.ts +14 -3
  100. package/src/ses-utils.d.ts.map +1 -1
  101. package/src/ses-utils.js +13 -15
  102. package/src/storage-test-utils.d.ts +4 -11
  103. package/src/storage-test-utils.d.ts.map +1 -1
  104. package/src/storage-test-utils.js +16 -14
  105. package/src/tagged.d.ts +18 -1
  106. package/src/testing-utils.d.ts +22 -1
  107. package/src/testing-utils.d.ts.map +1 -1
  108. package/src/testing-utils.js +131 -6
  109. package/src/tmpDir.d.ts.map +1 -1
  110. package/src/tmpDir.js +1 -1
  111. package/src/typeCheck.d.ts +4 -8
  112. package/src/typeCheck.d.ts.map +1 -1
  113. package/src/typeCheck.js +13 -6
  114. package/src/typeGuards.d.ts +5 -5
  115. package/src/typeGuards.d.ts.map +1 -1
  116. package/src/typeGuards.js +4 -5
  117. package/src/types-index.d.ts +1 -0
  118. package/src/types.d.ts +41 -14
  119. package/src/types.d.ts.map +1 -1
  120. package/src/types.js +161 -0
  121. package/src/upgrade-api.d.ts +2 -2
  122. package/src/upgrade-api.d.ts.map +1 -1
  123. package/src/upgrade-api.js +4 -3
  124. package/src/work-pool.d.ts.map +1 -1
  125. package/src/work-pool.js +9 -2
  126. package/vendor/anylogger.d.ts +98 -0
  127. package/vendor/anylogger.d.ts.map +1 -0
  128. package/vendor/anylogger.js +60 -0
  129. package/vendor/anylogger.ts +160 -0
  130. package/vendor/tsconfig.anylogger.json +15 -0
  131. package/exported.js +0 -2
  132. package/src/types.ts +0 -133
@@ -1,54 +1,193 @@
1
1
  // @ts-check
2
- import { spawn } from 'child_process';
3
- import { fileURLToPath } from 'url';
2
+ import { spawn } from 'node:child_process';
3
+ import { fileURLToPath } from 'node:url';
4
4
 
5
5
  import engineGC from './engine-gc.js';
6
6
  import { makeGcAndFinalize } from './gc-and-finalize.js';
7
7
 
8
8
  /**
9
- * @import {ExecutionContext, Macro, TestFn} from 'ava';
9
+ * @import {ExecutionContext, ImplementationFn, Macro, MacroDeclarationOptions,TestFn} from 'ava';
10
10
  */
11
11
 
12
- export const AVA_EXPECT_UNHANDLED_REJECTIONS =
12
+ /** Not an official AVA feature, so prefix with `AGORIC_` */
13
+ export const AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS =
13
14
  'AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS';
15
+ /** Backwards compatibility... */
16
+ export const AVA_EXPECT_UNHANDLED_REJECTIONS =
17
+ AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS;
18
+
19
+ const delayTurn = () => new Promise(resolve => setImmediate(resolve));
20
+ const settleUnhandled = async () => {
21
+ await delayTurn();
22
+ await delayTurn();
23
+ };
24
+
25
+ /** @param {'unhandledRejection' | 'rejectionHandled'} event */
26
+ const stripListeners = event => {
27
+ // @ts-expect-error the overload is per specific event name and can't handle the union
28
+ const listeners = process.listeners(event);
29
+ for (const listener of listeners) {
30
+ process.off(event, listener);
31
+ }
32
+ return () => {
33
+ for (const listener of listeners) {
34
+ process.on(event, listener);
35
+ }
36
+ };
37
+ };
38
+
39
+ const makeUnhandledTracker = () => {
40
+ let unhandled = 0;
41
+ let seenUnhandled = 0;
42
+ const pending = new Set();
43
+ const handledLate = new Set();
44
+ const tokenByPromise = new WeakMap();
45
+ // Finalization callbacks run on the main thread; `pending` is only mutated
46
+ // here and after the flushes in countUnhandled, so no extra synchronization
47
+ // is required.
48
+ const registry = new FinalizationRegistry(token => {
49
+ if (pending.delete(token)) {
50
+ // Don't count promises that were handled late.
51
+ if (!handledLate.delete(token)) {
52
+ unhandled += 1;
53
+ }
54
+ }
55
+ });
14
56
 
15
- export const SUBTEST_PREFIX = '(unhandled rejection subprocess): ';
57
+ /**
58
+ * @param {unknown} _reason
59
+ * @param {Promise<unknown>} promise
60
+ */
61
+ const onUnhandled = (_reason, promise) => {
62
+ seenUnhandled += 1;
63
+ const token = Symbol('unhandledRejection');
64
+ tokenByPromise.set(promise, token);
65
+ pending.add(token);
66
+ registry.register(promise, token, token);
67
+ };
68
+
69
+ /** @param {Promise<unknown>} promise */
70
+ const onHandledLate = promise => {
71
+ const token = tokenByPromise.get(promise);
72
+ tokenByPromise.delete(promise);
73
+ // Mark this token as handled late so it won't be counted when the
74
+ // finalizer runs. We remove it from `pending` to exclude it from
75
+ // the pending count, and track it in `handledLate` to avoid counting
76
+ // it when GC'd.
77
+ if (token && pending.delete(token)) {
78
+ handledLate.add(token);
79
+ }
80
+ };
81
+
82
+ const snapshot = () => ({ unhandled, pending: pending.size, seenUnhandled });
83
+
84
+ return {
85
+ onUnhandled,
86
+ onHandledLate,
87
+ snapshot,
88
+ };
89
+ };
16
90
 
17
91
  /**
92
+ * Count unhandled rejections for the given work by running it after removing
93
+ * any existing listeners (like AVA's) and waiting for GC/finalization.
94
+ *
95
+ * @param {() => any | Promise<any>} work
96
+ * @param {object} powers
97
+ * @param {() => Promise<void>} powers.gcAndFinalize
98
+ */
99
+ export const countUnhandled = async (work, { gcAndFinalize }) => {
100
+ await null; // for Jessie
101
+ const tracker = makeUnhandledTracker();
102
+ const restoreUnhandled = stripListeners('unhandledRejection');
103
+ const restoreHandled = stripListeners('rejectionHandled');
104
+ const flushUnhandled = async () => {
105
+ await settleUnhandled();
106
+ await gcAndFinalize();
107
+ };
108
+ process.on('unhandledRejection', tracker.onUnhandled);
109
+ process.on('rejectionHandled', tracker.onHandledLate);
110
+ try {
111
+ await work();
112
+ } finally {
113
+ // Two passes through settle+GC help ensure finalizers run before we snapshot
114
+ // the unhandled state across Node/XS runtimes, even when callbacks queue
115
+ // additional macrotasks. This count happens after the flushes so finalizer
116
+ // timing cannot race the snapshot.
117
+ await flushUnhandled();
118
+ await flushUnhandled();
119
+ await settleUnhandled();
120
+ process.off('unhandledRejection', tracker.onUnhandled);
121
+ process.off('rejectionHandled', tracker.onHandledLate);
122
+ restoreUnhandled();
123
+ restoreHandled();
124
+ }
125
+ return tracker.snapshot();
126
+ };
127
+
128
+ /**
129
+ * @deprecated Use `makeExpectUnhandledRejectionMacro` instead, which uses the
130
+ * test's first argument title instead of an explicit `name`, and can
131
+ * optionally wrap an inner `Macro`.
132
+ *
18
133
  * @template C
19
134
  * @param {object} powers
20
135
  * @param {TestFn<C>} powers.test
136
+ * @param {boolean} [powers.sameWorker]
21
137
  * @param {string} powers.importMetaUrl
22
- * @returns {(
23
- * expectedUnhandled: number,
24
- * ) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>}
138
+ * @returns {( expectedUnhandled: number) => Macro<[name: string, impl: (t:
139
+ * ExecutionContext<C>) => any], C>}
25
140
  */
26
- export const makeExpectUnhandledRejection = ({ test, importMetaUrl }) => {
141
+ export const makeExpectUnhandledRejection = ({
142
+ test,
143
+ sameWorker = false,
144
+ importMetaUrl,
145
+ }) => {
27
146
  const self = fileURLToPath(importMetaUrl);
28
147
  const gcAndFinalize = makeGcAndFinalize(engineGC);
29
148
 
30
- if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
31
- return _expectedUnhandled =>
149
+ if (sameWorker || process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
150
+ let mutex = Promise.resolve();
151
+ return expectedUnhandled =>
32
152
  test.macro({
33
- title: (_, name, _impl) => SUBTEST_PREFIX + name,
153
+ title: (_providedTitle = '', name, _impl) => name,
34
154
  exec: async (t, _name, impl) => {
35
- await null;
36
- try {
37
- const result = await impl(t);
38
- return result;
39
- } finally {
40
- await gcAndFinalize();
155
+ const rawExpected =
156
+ (sameWorker
157
+ ? undefined
158
+ : process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) ||
159
+ expectedUnhandled;
160
+ const expected = Number(rawExpected);
161
+ if (!Number.isSafeInteger(expected) || expected < 0) {
162
+ t.fail(
163
+ `expected unhandled rejection count to be a natural number, got ${rawExpected}`,
164
+ );
41
165
  }
166
+ const nextP = mutex.then(async () => {
167
+ const { unhandled, pending, seenUnhandled } = await countUnhandled(
168
+ () => impl(t),
169
+ { gcAndFinalize },
170
+ );
171
+ const totalUnhandled = unhandled + pending;
172
+ if (totalUnhandled !== expected) {
173
+ t.fail(
174
+ `expected ${expected} unhandled promise rejections, got ${totalUnhandled} (of ${seenUnhandled} seen, ${pending} pending finalization)`,
175
+ );
176
+ }
177
+ });
178
+ mutex = nextP.catch(() => {}); // don't let a failure block the next test
179
+ await nextP;
42
180
  },
43
181
  });
44
182
  }
45
183
 
46
184
  return expectedUnhandled =>
47
185
  test.macro({
48
- title: (_, name, _impl) => name,
186
+ title: (_providedTitle = '', name, _impl) =>
187
+ `${name} (unhandled: ${expectedUnhandled})`,
49
188
  exec: async (t, name, _impl) =>
50
189
  new Promise((resolve, reject) => {
51
- const ps = spawn('ava', [self, '-m', SUBTEST_PREFIX + name], {
190
+ const ps = spawn('ava', [self, '--match', name], {
52
191
  env: {
53
192
  ...process.env,
54
193
  [AVA_EXPECT_UNHANDLED_REJECTIONS]: `${expectedUnhandled}`,
@@ -64,3 +203,61 @@ export const makeExpectUnhandledRejection = ({ test, importMetaUrl }) => {
64
203
  }),
65
204
  });
66
205
  };
206
+
207
+ /**
208
+ * @template [C=unknown]
209
+ * @param {object} powers
210
+ * @param {TestFn<C>} powers.test
211
+ * @param {boolean} [powers.sameWorker] defaults to require in-process execution
212
+ * @param {string} powers.importMetaUrl
213
+ */
214
+ export const makeExpectUnhandledRejectionMacro = ({
215
+ test,
216
+ sameWorker = true,
217
+ importMetaUrl,
218
+ }) => {
219
+ const expectUnhandledRejection = makeExpectUnhandledRejection({
220
+ test,
221
+ sameWorker,
222
+ importMetaUrl,
223
+ });
224
+ /**
225
+ * @template {any[]} [A=[ImplementationFn<any[], any>, ...any[]]]
226
+ * @param {number} numUnhandled
227
+ * @param {Macro<A, C>} [innerMacro]
228
+ * @returns {Macro<A, C>}
229
+ */
230
+ return (numUnhandled, innerMacro) => {
231
+ const expector = expectUnhandledRejection(numUnhandled);
232
+
233
+ /**
234
+ * @param {ExecutionContext<C>} _t
235
+ * @param {A} args
236
+ * @returns {(t: ExecutionContext<C>) => any}
237
+ */
238
+ const makeImpl = (_t, args) =>
239
+ innerMacro
240
+ ? async t => innerMacro.exec(t, ...args)
241
+ : t => (0, args[0])(t, ...args);
242
+
243
+ return test.macro(
244
+ /** @type {MacroDeclarationOptions<A, C>} */ ({
245
+ title(providedTitle = '', ...args) {
246
+ let expectorName =
247
+ innerMacro?.title?.(providedTitle, ...args) ?? providedTitle;
248
+ const impl = () => {};
249
+ if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
250
+ expectorName =
251
+ expector.title?.(expectorName, expectorName, impl) ??
252
+ expectorName;
253
+ }
254
+ return expectorName;
255
+ },
256
+ async exec(t, ...args) {
257
+ const impl = makeImpl(t, args);
258
+ return expector.exec(t, t.title, impl);
259
+ },
260
+ }),
261
+ );
262
+ };
263
+ };
@@ -1,5 +1,5 @@
1
- import v8 from 'v8';
2
- import vm from 'vm';
1
+ import v8 from 'node:v8';
2
+ import vm from 'node:vm';
3
3
 
4
4
  /* global globalThis */
5
5
  let bestGC = globalThis.gc;
@@ -1,2 +1,3 @@
1
- export function makeGcAndFinalize(gcPower: any): () => Promise<void>;
1
+ /** @param {(() => void) | false} gcPower */
2
+ export function makeGcAndFinalize(gcPower: (() => void) | false): () => Promise<void>;
2
3
  //# sourceMappingURL=gc-and-finalize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gc-and-finalize.d.ts","sourceRoot":"","sources":["gc-and-finalize.js"],"names":[],"mappings":"AAkEA,qEAwBC"}
1
+ {"version":3,"file":"gc-and-finalize.d.ts","sourceRoot":"","sources":["gc-and-finalize.js"],"names":[],"mappings":"AAkEA,4CAA4C;AAC5C,2CADY,CAAC,MAAM,IAAI,CAAC,GAAG,KAAK,uBAyB/B"}
@@ -64,6 +64,7 @@
64
64
  * dummy pre-resolved Promise.
65
65
  */
66
66
 
67
+ /** @param {(() => void) | false} gcPower */
67
68
  export function makeGcAndFinalize(gcPower) {
68
69
  if (typeof gcPower !== 'function') {
69
70
  if (gcPower !== false) {
@@ -1,11 +1,18 @@
1
- export function startSubprocessWorker(execPath: any, procArgs?: any[], { netstringMaxChunkSize }?: {
2
- netstringMaxChunkSize?: undefined;
1
+ /**
2
+ * @param {string} execPath
3
+ * @param {readonly string[]} [procArgs]
4
+ * @param {{ netstringMaxChunkSize?: number }} [options]
5
+ */
6
+ export function startSubprocessWorker(execPath: string, procArgs?: readonly string[], { netstringMaxChunkSize }?: {
7
+ netstringMaxChunkSize?: number;
3
8
  }): {
4
9
  fromChild: {
5
- on: (...args: any[]) => import("stream").Transform;
10
+ /** @param {...unknown} args */
11
+ on: (...args: unknown[]) => import("stream").Transform;
6
12
  };
7
13
  toChild: {
8
- write: (...args: any[]) => boolean;
14
+ /** @param {...unknown} args */
15
+ write: (...args: unknown[]) => boolean;
9
16
  };
10
17
  terminate: () => void;
11
18
  done: Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"spawnSubprocessWorker.d.ts","sourceRoot":"","sources":["spawnSubprocessWorker.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;EA0DC"}
1
+ {"version":3,"file":"spawnSubprocessWorker.d.ts","sourceRoot":"","sources":["spawnSubprocessWorker.js"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,gDAJW,MAAM,aACN,SAAS,MAAM,EAAE,8BACjB;IAAE,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAAE;;QAyCzC,+BAA+B;sBAAhB,OAAO,EAAA;;;QAQtB,+BAA+B;yBAAhB,OAAO,EAAA;;;;EAazB"}
@@ -1,5 +1,5 @@
1
1
  // this file is loaded by the controller, in the start compartment
2
- import { spawn } from 'child_process';
2
+ import { spawn } from 'node:child_process';
3
3
  import { makePromiseKit } from '@endo/promise-kit';
4
4
  import { NonNullish } from '../errors.js';
5
5
  import { arrayEncoderStream, arrayDecoderStream } from './worker-protocol.js';
@@ -18,9 +18,12 @@ import {
18
18
  // toChild, fromChild } pair of Streams which accept/emit hardened Arrays of
19
19
  // JSON-serializable data.
20
20
 
21
- // eslint-disable-next-line no-unused-vars
22
- function parentLog(first, ...args) {
23
- // console.error(`--parent: ${first}`, ...args);
21
+ /**
22
+ * @param {unknown} _first
23
+ * @param {...unknown} _args
24
+ */
25
+ function parentLog(_first, ..._args) {
26
+ // console.error(`--parent: ${_first}`, ..._args);
24
27
  }
25
28
 
26
29
  // we send on fd3, and receive on fd4. We pass fd1/2 (stdout/err) through, so
@@ -30,6 +33,11 @@ function parentLog(first, ...args) {
30
33
  /** @type {IOType[]} */
31
34
  const stdio = harden(['inherit', 'inherit', 'inherit', 'pipe', 'pipe']);
32
35
 
36
+ /**
37
+ * @param {string} execPath
38
+ * @param {readonly string[]} [procArgs]
39
+ * @param {{ netstringMaxChunkSize?: number }} [options]
40
+ */
33
41
  export function startSubprocessWorker(
34
42
  execPath,
35
43
  procArgs = [],
@@ -69,6 +77,7 @@ export function startSubprocessWorker(
69
77
  // that get used
70
78
  /* @type {typeof fromChild} */
71
79
  const wrappedFromChild = {
80
+ /** @param {...unknown} args */
72
81
  on: (...args) =>
73
82
  fromChild.on(
74
83
  .../** @type {Parameters<(typeof fromChild)['on']>} */ (args),
@@ -76,6 +85,7 @@ export function startSubprocessWorker(
76
85
  };
77
86
  /* @type {typeof toChild} */
78
87
  const wrappedToChild = {
88
+ /** @param {...unknown} args */
79
89
  write: (...args) =>
80
90
  toChild.write(
81
91
  .../** @type {Parameters<(typeof toChild)['write']>} */ (args),
@@ -1,4 +1,4 @@
1
1
  export function arrayEncoderStream(): Transform;
2
2
  export function arrayDecoderStream(): Transform;
3
- import { Transform } from 'stream';
3
+ import { Transform } from 'node:stream';
4
4
  //# sourceMappingURL=worker-protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["worker-protocol.js"],"names":[],"mappings":"AAMA,gDAqBC;AAED,gDAwBC;0BApDyB,QAAQ"}
1
+ {"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["worker-protocol.js"],"names":[],"mappings":"AAKA,gDAqBC;AAED,gDAwBC;0BApDyB,aAAa"}
@@ -1,5 +1,4 @@
1
- /* eslint-env node */
2
- import { Transform } from 'stream';
1
+ import { Transform } from 'node:stream';
3
2
 
4
3
  // Transform objects which convert from hardened Arrays of JSON-serializable
5
4
  // data into Buffers suitable for netstring conversion.
@@ -7,11 +6,11 @@ import { Transform } from 'stream';
7
6
  export function arrayEncoderStream() {
8
7
  /**
9
8
  * @param {any} object
10
- * @param {BufferEncoding} encoding
9
+ * @param {BufferEncoding} _encoding
11
10
  * @param {any} callback
12
11
  * @this {{ push: (b: Buffer) => void }}
13
12
  */
14
- function transform(object, encoding, callback) {
13
+ function transform(object, _encoding, callback) {
15
14
  if (!Array.isArray(object)) {
16
15
  throw Error('stream requires Arrays');
17
16
  }
@@ -30,11 +29,11 @@ export function arrayEncoderStream() {
30
29
  export function arrayDecoderStream() {
31
30
  /**
32
31
  * @param {Buffer} buf
33
- * @param {BufferEncoding} encoding
32
+ * @param {BufferEncoding} _encoding
34
33
  * @param {any} callback
35
34
  * @this {{ push: (b: Buffer) => void }}
36
35
  */
37
- function transform(buf, encoding, callback) {
36
+ function transform(buf, _encoding, callback) {
38
37
  let err;
39
38
  try {
40
39
  if (!Buffer.isBuffer(buf)) {
@@ -1 +1 @@
1
- {"version":3,"file":"magic-cookie-test-only.d.ts","sourceRoot":"","sources":["magic-cookie-test-only.js"],"names":[],"mappings":"AAQO,0CAEN"}
1
+ {"version":3,"file":"magic-cookie-test-only.d.ts","sourceRoot":"","sources":["magic-cookie-test-only.js"],"names":[],"mappings":"AAMO,0CAEN"}
@@ -1,5 +1,3 @@
1
- // @jessie-check
2
-
3
1
  const cookie = harden({});
4
2
 
5
3
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"board-client-utils.d.ts","sourceRoot":"","sources":["board-client-utils.js"],"names":[],"mappings":"AAsBO,gCAJO,OAAO,sCACV;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,WAAW,CAAC,OAAO,CAAC,CAKhC;AAOM,kCAJO,OAAO,oBACV,OAAO,SACP,MAAM,wBAGoB;AAsB9B,wCAJO,OAAO,8BACV,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GACnC,IAAI,CAAC,QAAQ,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAU/D;AAYM,4CAPI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,YAAY,MAAM,CAAC,SACnB,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAClB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;wBArHa,OAAO,oBACR;IAAE,UAAU,EAAE,MAAM,OAAO,CAAA;CAAE,GAAG,eAAe;6BALM,eAAe;iCAAf,eAAe;qCAD/C,kBAAkB"}
1
+ {"version":3,"file":"board-client-utils.d.ts","sourceRoot":"","sources":["board-client-utils.js"],"names":[],"mappings":"AAsBO,gCAJO,OAAO,sCACV;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,WAAW,CAAC,OAAO,CAAC,CAKhC;AAOM,kCAJO,OAAO,oBACV,OAAO,SACP,MAAM,wBAGoB;AAyB9B,wCAJO,OAAO,8BACV,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GACnC,IAAI,CAAC,QAAQ,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAU/D;AAYM,4CAPI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,YAAY,MAAM,CAAC,SACnB,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAClB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;wBAxHa,OAAO,oBACR;IAAE,UAAU,EAAE,MAAM,OAAO,CAAA;CAAE,GAAG,eAAe;6BALM,eAAe;iCAAf,eAAe;qCAD/C,kBAAkB"}
@@ -34,8 +34,11 @@ export const slotToBoardRemote = (boardId, iface) =>
34
34
  makeBoardRemote({ boardId, iface });
35
35
 
36
36
  /**
37
+ * The result is cast to `ConvertValToSlot` at the sole call site
38
+ * (`boardSlottingMarshaller`), so the return type is left to inference rather
39
+ * than restated as a conditional type over the value `val`.
40
+ *
37
41
  * @param {BoardRemote<any> | object} val
38
- * @returns {val extends BoardRemote<infer BoardId> ? BoardId : never}
39
42
  */
40
43
  const boardValToSlot = val => {
41
44
  if ('getBoardId' in val) {
@@ -1,3 +1,11 @@
1
- export function assertCapData(data: unknown): asserts data is CapData<unknown>;
1
+ /**
2
+ * @import {CapData} from '@endo/marshal';
3
+ */
4
+ /**
5
+ * Assert that this is CapData
6
+ *
7
+ * @type {(data: unknown) => asserts data is CapData<unknown>}
8
+ */
9
+ export const assertCapData: (data: unknown) => asserts data is CapData<unknown>;
2
10
  import type { CapData } from '@endo/marshal';
3
11
  //# sourceMappingURL=cap-data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cap-data.d.ts","sourceRoot":"","sources":["cap-data.js"],"names":[],"mappings":"AAaO,oCAHI,OAAO,GACL,QAAQ,IAAI,IAAI,QAAQ,OAAO,CAAC,CAO5C;6BAdyB,eAAe"}
1
+ {"version":3,"file":"cap-data.d.ts","sourceRoot":"","sources":["cap-data.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;GAIG;AACH,4BAFU,CAAC,IAAI,EAAE,OAAO,KAAK,QAAQ,IAAI,IAAI,QAAQ,OAAO,CAAC,CAO3D;6BAbwB,eAAe"}
@@ -8,8 +8,7 @@ import { Fail } from '@endo/errors';
8
8
  /**
9
9
  * Assert that this is CapData
10
10
  *
11
- * @param {unknown} data
12
- * @returns {asserts data is CapData<unknown>}
11
+ * @type {(data: unknown) => asserts data is CapData<unknown>}
13
12
  */
14
13
  export const assertCapData = data => {
15
14
  assert.typeof(data, 'object');
@@ -14,7 +14,8 @@ export function wrapRemoteMarshaller<Slot = unknown>(marshaller: ERemote<Pick<EM
14
14
  * either a sync or async marshaller, usually through `E` eventual-sends.
15
15
  */
16
16
  export type EMarshaller<Slot = unknown> = Simplify<EOnly<Marshal<Slot>>>;
17
- export type SlotWrapper<Slot = unknown> = ReturnType<typeof slotToWrapper<Slot>>;
17
+ export type InterfaceSpec = "Remotable" | `Alleged: ${string}`;
18
+ export type RemotableSlotWrapper<Slot = unknown> = SlotWrapper<Slot> & PassStyled<"remotable", InterfaceSpec>;
18
19
  import type { ERemote } from '../types.js';
19
20
  import type { MakeMarshalOptions } from '@endo/marshal';
20
21
  import type { WeakMapAPI } from '@endo/cache-map';
@@ -22,12 +23,38 @@ import { Far } from '@endo/far';
22
23
  import type { Marshal } from '@endo/marshal';
23
24
  import type { EOnly } from '@endo/eventual-send';
24
25
  import type { Simplify } from '@endo/pass-style';
25
- declare function slotToWrapper<Slot = unknown>(slot: Slot, iface?: string): {
26
- /** @type {Slot} */
27
- "__#private@#slot": Slot;
26
+ /**
27
+ * @import {WeakMapAPI} from '@endo/cache-map';
28
+ * @import {EOnly} from '@endo/eventual-send';
29
+ * @import {PassStyled, Simplify} from '@endo/pass-style';
30
+ * @import {CapData, Passable, Marshal, MakeMarshalOptions} from '@endo/marshal';
31
+ * @import {ERemote} from '../types.js';
32
+ */
33
+ /**
34
+ * A Marshaller which methods may be async. Use this type to indicate accepting
35
+ * either a sync or async marshaller, usually through `E` eventual-sends.
36
+ *
37
+ * @template [Slot=unknown]
38
+ * @typedef {Simplify<EOnly<Marshal<Slot>>>} EMarshaller
39
+ */
40
+ /** @typedef {'Remotable' | `Alleged: ${string}`} InterfaceSpec */
41
+ /** @template [Slot=unknown] */
42
+ declare class SlotWrapper<Slot = unknown> {
43
+ /**
44
+ * @template [Slot=unknown]
45
+ * @param {SlotWrapper<Slot>} wrapper
46
+ * @returns {Slot}
47
+ */
48
+ static getSlot<Slot_1 = unknown>(wrapper: SlotWrapper<Slot_1>): Slot_1;
49
+ /**
50
+ * @param {Slot} slot
51
+ * @param {string} [iface]
52
+ */
53
+ constructor(slot: Slot, iface?: string);
28
54
  /** @type {InterfaceSpec} */
29
- [Symbol.toStringTag]: `Alleged: ${string}` | "Remotable";
30
- } & RemotableObject<`Alleged: ${string}` | "Remotable">;
31
- import type { RemotableObject } from '@endo/pass-style';
55
+ [Symbol.toStringTag]: InterfaceSpec;
56
+ #private;
57
+ }
58
+ import type { PassStyled } from '@endo/pass-style';
32
59
  export {};
33
60
  //# sourceMappingURL=wrap-marshaller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-marshaller.d.ts","sourceRoot":"","sources":["wrap-marshaller.js"],"names":[],"mappings":"AA4HO,kDATO,IAAI,wBACP,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,WA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