@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.
Files changed (111) hide show
  1. package/README.md +1 -4
  2. package/package.json +29 -23
  3. package/src/action-types.d.ts +2 -1
  4. package/src/action-types.d.ts.map +1 -1
  5. package/src/action-types.js +4 -4
  6. package/src/batched-deliver.d.ts +6 -2
  7. package/src/batched-deliver.d.ts.map +1 -1
  8. package/src/batched-deliver.js +7 -2
  9. package/src/callback.d.ts +10 -12
  10. package/src/callback.d.ts.map +1 -1
  11. package/src/callback.js +23 -16
  12. package/src/chain-storage-paths.d.ts.map +1 -1
  13. package/src/chain-utils.d.ts +3 -1
  14. package/src/chain-utils.d.ts.map +1 -1
  15. package/src/chain-utils.js +6 -1
  16. package/src/cli-utils.d.ts +2 -0
  17. package/src/cli-utils.d.ts.map +1 -0
  18. package/src/cli-utils.js +21 -0
  19. package/src/config.d.ts +21 -4
  20. package/src/config.d.ts.map +1 -1
  21. package/src/config.js +25 -2
  22. package/src/debug.d.ts +4 -1
  23. package/src/debug.d.ts.map +1 -1
  24. package/src/debug.js +26 -13
  25. package/src/errors.d.ts +1 -1
  26. package/src/errors.d.ts.map +1 -1
  27. package/src/hex.d.ts +15 -0
  28. package/src/hex.d.ts.map +1 -0
  29. package/src/hex.js +105 -0
  30. package/src/index.d.ts +5 -3
  31. package/src/index.js +13 -4
  32. package/src/js-utils.d.ts +38 -1
  33. package/src/js-utils.d.ts.map +1 -1
  34. package/src/js-utils.js +184 -14
  35. package/src/lib-chainStorage.d.ts +45 -32
  36. package/src/lib-chainStorage.d.ts.map +1 -1
  37. package/src/lib-chainStorage.js +24 -32
  38. package/src/lib-nodejs/ava-unhandled-rejection.d.ts +13 -0
  39. package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -0
  40. package/src/lib-nodejs/ava-unhandled-rejection.js +66 -0
  41. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +0 -2
  42. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
  43. package/src/lib-nodejs/spawnSubprocessWorker.js +5 -3
  44. package/src/lib-nodejs/waitUntilQuiescent.d.ts +3 -0
  45. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -1
  46. package/src/lib-nodejs/waitUntilQuiescent.js +5 -1
  47. package/src/marshal/board-client-utils.d.ts +19 -0
  48. package/src/marshal/board-client-utils.d.ts.map +1 -0
  49. package/src/{marshal.js → marshal/board-client-utils.js} +30 -36
  50. package/src/marshal/cap-data.d.ts +3 -0
  51. package/src/marshal/cap-data.d.ts.map +1 -0
  52. package/src/marshal/cap-data.js +20 -0
  53. package/src/marshal/inaccessible-val.d.ts +2 -0
  54. package/src/marshal/inaccessible-val.d.ts.map +1 -0
  55. package/src/marshal/inaccessible-val.js +15 -0
  56. package/src/marshal/pure-data.d.ts +8 -0
  57. package/src/marshal/pure-data.d.ts.map +1 -0
  58. package/src/marshal/pure-data.js +14 -0
  59. package/src/marshal/wrap-marshaller.d.ts +33 -0
  60. package/src/marshal/wrap-marshaller.d.ts.map +1 -0
  61. package/src/marshal/wrap-marshaller.js +439 -0
  62. package/src/method-tools.d.ts.map +1 -1
  63. package/src/method-tools.js +8 -50
  64. package/src/metrics.d.ts +183 -0
  65. package/src/metrics.d.ts.map +1 -0
  66. package/src/metrics.js +476 -0
  67. package/src/module-utils.d.ts +2 -0
  68. package/src/module-utils.d.ts.map +1 -0
  69. package/src/module-utils.js +27 -0
  70. package/src/natural-sort.d.ts +2 -0
  71. package/src/natural-sort.d.ts.map +1 -0
  72. package/src/natural-sort.js +83 -0
  73. package/src/netstring.d.ts +2 -2
  74. package/src/netstring.d.ts.map +1 -1
  75. package/src/netstring.js +1 -0
  76. package/src/node/buffer-line-transform.d.ts +12 -7
  77. package/src/node/buffer-line-transform.d.ts.map +1 -1
  78. package/src/node/buffer-line-transform.js +8 -4
  79. package/src/node/fs-stream.d.ts +4 -1
  80. package/src/node/fs-stream.d.ts.map +1 -1
  81. package/src/node/fs-stream.js +28 -27
  82. package/src/node/shutdown.d.ts.map +1 -1
  83. package/src/node/shutdown.js +2 -0
  84. package/src/priority-senders.d.ts +3 -1
  85. package/src/priority-senders.d.ts.map +1 -1
  86. package/src/priority-senders.js +7 -2
  87. package/src/queue.d.ts +1 -1
  88. package/src/queue.d.ts.map +1 -1
  89. package/src/ses-utils.d.ts +24 -5
  90. package/src/ses-utils.d.ts.map +1 -1
  91. package/src/ses-utils.js +189 -15
  92. package/src/storage-test-utils.d.ts +25 -7
  93. package/src/storage-test-utils.d.ts.map +1 -1
  94. package/src/storage-test-utils.js +141 -22
  95. package/src/tagged.d.ts +4 -1
  96. package/src/testing-utils.js +1 -1
  97. package/src/tmpDir.d.ts +2 -0
  98. package/src/tmpDir.d.ts.map +1 -0
  99. package/src/tmpDir.js +17 -0
  100. package/src/tokens.d.ts.map +1 -1
  101. package/src/typeGuards.d.ts +19 -0
  102. package/src/typeGuards.d.ts.map +1 -1
  103. package/src/typeGuards.js +16 -0
  104. package/src/types.d.ts +30 -17
  105. package/src/types.d.ts.map +1 -1
  106. package/src/types.ts +43 -18
  107. package/src/work-pool.d.ts +13 -0
  108. package/src/work-pool.d.ts.map +1 -0
  109. package/src/work-pool.js +233 -0
  110. package/src/marshal.d.ts +0 -20
  111. package/src/marshal.d.ts.map +0 -1
@@ -8,10 +8,14 @@ import * as cb from './callback.js';
8
8
 
9
9
  /**
10
10
  * @import {ERef} from '@endo/far';
11
- * @import {PassableCap} from '@endo/marshal';
11
+ * @import {Marshal, Passable} from '@endo/marshal';
12
+ * @import {Remote, ERemote, TypedPattern} from './types.js';
13
+ * @import {EMarshaller} from './marshal/wrap-marshaller.js';
14
+ * @import {Zone} from '@agoric/base-zone';
15
+ * @import {Callback} from './types.js';
12
16
  */
13
17
 
14
- /** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */
18
+ /** @typedef {Marshal<unknown>} Marshaller */
15
19
  /** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */
16
20
 
17
21
  /**
@@ -27,10 +31,17 @@ import * as cb from './callback.js';
27
31
  /**
28
32
  * @template [T=unknown]
29
33
  * @typedef StreamCell
30
- * @property {string} blockHeight decimal representation of a natural number
34
+ * @property {string} blockHeight corresponding with the write of `values`
35
+ * (decimal representation of a natural number)
31
36
  * @property {T[]} values
32
37
  */
33
38
 
39
+ /** @type {TypedPattern<StreamCell>} */
40
+ export const StreamCellShape = harden({
41
+ blockHeight: M.string(),
42
+ values: M.array(),
43
+ });
44
+
34
45
  /**
35
46
  * This represents a node in an IAVL tree.
36
47
  *
@@ -77,21 +88,6 @@ export const isStreamCell = cell =>
77
88
  /^0$|^[1-9][0-9]*$/.test(cell.blockHeight);
78
89
  harden(isStreamCell);
79
90
 
80
- // TODO: Consolidate with `insistCapData` functions from swingset-liveslots,
81
- // swingset-xsnap-supervisor, etc.
82
- /**
83
- * @param {unknown} data
84
- * @returns {asserts data is import('@endo/marshal').CapData<string>}
85
- */
86
- export const assertCapData = data => {
87
- assert.typeof(data, 'object');
88
- assert(data);
89
- assert.typeof(data.body, 'string');
90
- assert(Array.isArray(data.slots));
91
- // XXX check that the .slots array elements are actually strings
92
- };
93
- harden(assertCapData);
94
-
95
91
  /**
96
92
  * @typedef {object} StoredFacet
97
93
  * @property {() => Promise<string>} getPath the chain storage path at which the
@@ -151,17 +147,15 @@ harden(assertPathSegment);
151
147
  */
152
148
 
153
149
  /**
154
- * @param {import('@agoric/base-zone').Zone} zone
150
+ * @param {Zone} zone
155
151
  */
156
152
  export const prepareChainStorageNode = zone => {
157
153
  /**
158
154
  * Create a storage node for a given backing storage interface and path.
159
155
  *
160
- * @param {import('./types.js').Callback<
161
- * (message: StorageMessage) => any
162
- * >} messenger
163
- * a callback for sending a storageMessage object to the storage
164
- * implementation (cf. golang/cosmos/x/vstorage/vstorage.go)
156
+ * @param {Callback<(message: StorageMessage) => any>} messenger a callback
157
+ * for sending a storageMessage object to the storage implementation (cf.
158
+ * golang/cosmos/x/vstorage/vstorage.go)
165
159
  * @param {string} path
166
160
  * @param {object} [options]
167
161
  * @param {boolean} [options.sequence] set values with `append` messages
@@ -174,9 +168,7 @@ export const prepareChainStorageNode = zone => {
174
168
  'ChainStorageNode',
175
169
  ChainStorageNodeI,
176
170
  /**
177
- * @param {import('./types.js').Callback<
178
- * (message: StorageMessage) => any
179
- * >} messenger
171
+ * @param {Callback<(message: StorageMessage) => any>} messenger
180
172
  * @param {string} path
181
173
  * @param {object} [options]
182
174
  * @param {boolean} [options.sequence]
@@ -289,9 +281,9 @@ const makeNullStorageNode = () => {
289
281
  * falling back to an inert object with the correct interface (but incomplete
290
282
  * behavior) when that is unavailable.
291
283
  *
292
- * @param {ERef<StorageNode?>} storageNodeRef
284
+ * @param {ERef<Remote<StorageNode> | null>} storageNodeRef
293
285
  * @param {string} childName
294
- * @returns {Promise<StorageNode>}
286
+ * @returns {Promise<Remote<StorageNode>>}
295
287
  */
296
288
  export async function makeStorageNodeChild(storageNodeRef, childName) {
297
289
  const existingStorageNode = await storageNodeRef;
@@ -302,9 +294,9 @@ harden(makeStorageNodeChild);
302
294
 
303
295
  // TODO find a better module for this
304
296
  /**
305
- * @param {ERef<StorageNode>} storageNode
306
- * @param {ERef<Marshaller>} marshaller
307
- * @returns {(value: PassableCap) => Promise<void>}
297
+ * @param {ERemote<StorageNode>} storageNode
298
+ * @param {ERemote<EMarshaller>} marshaller
299
+ * @returns {(value: Passable) => Promise<void>}
308
300
  */
309
301
  export const makeSerializeToStorage = (storageNode, marshaller) => {
310
302
  return async value => {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @import {ExecutionContext, Macro, TestFn} from 'ava';
3
+ */
4
+ export const AVA_EXPECT_UNHANDLED_REJECTIONS: "AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS";
5
+ export const SUBTEST_PREFIX: "(unhandled rejection subprocess): ";
6
+ export function makeExpectUnhandledRejection<C>({ test, importMetaUrl }: {
7
+ test: TestFn<C>;
8
+ importMetaUrl: string;
9
+ }): (expectedUnhandled: number) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>;
10
+ import type { TestFn } from 'ava';
11
+ import type { ExecutionContext } from 'ava';
12
+ import type { Macro } from 'ava';
13
+ //# sourceMappingURL=ava-unhandled-rejection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ava-unhandled-rejection.d.ts","sourceRoot":"","sources":["ava-unhandled-rejection.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH,8CACE,wCAAwC,CAAC;AAE3C,6BAA8B,oCAAoC,CAAC;AAW5D,6CARM,CAAC,2BAEX;IAA0B,IAAI,EAAtB,OAAO,CAAC,CAAC;IACM,aAAa,EAA5B,MAAM;CACd,GAAU,CACR,iBAAiB,EAAE,MAAM,KACtB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CA0CtE;4BAzDiD,KAAK;sCAAL,KAAK;2BAAL,KAAK"}
@@ -0,0 +1,66 @@
1
+ // @ts-check
2
+ import { spawn } from 'child_process';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ import engineGC from './engine-gc.js';
6
+ import { makeGcAndFinalize } from './gc-and-finalize.js';
7
+
8
+ /**
9
+ * @import {ExecutionContext, Macro, TestFn} from 'ava';
10
+ */
11
+
12
+ export const AVA_EXPECT_UNHANDLED_REJECTIONS =
13
+ 'AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS';
14
+
15
+ export const SUBTEST_PREFIX = '(unhandled rejection subprocess): ';
16
+
17
+ /**
18
+ * @template C
19
+ * @param {object} powers
20
+ * @param {TestFn<C>} powers.test
21
+ * @param {string} powers.importMetaUrl
22
+ * @returns {(
23
+ * expectedUnhandled: number,
24
+ * ) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>}
25
+ */
26
+ export const makeExpectUnhandledRejection = ({ test, importMetaUrl }) => {
27
+ const self = fileURLToPath(importMetaUrl);
28
+ const gcAndFinalize = makeGcAndFinalize(engineGC);
29
+
30
+ if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
31
+ return _expectedUnhandled =>
32
+ test.macro({
33
+ title: (_, name, _impl) => SUBTEST_PREFIX + name,
34
+ exec: async (t, _name, impl) => {
35
+ await null;
36
+ try {
37
+ const result = await impl(t);
38
+ return result;
39
+ } finally {
40
+ await gcAndFinalize();
41
+ }
42
+ },
43
+ });
44
+ }
45
+
46
+ return expectedUnhandled =>
47
+ test.macro({
48
+ title: (_, name, _impl) => name,
49
+ exec: async (t, name, _impl) =>
50
+ new Promise((resolve, reject) => {
51
+ const ps = spawn('ava', [self, '-m', SUBTEST_PREFIX + name], {
52
+ env: {
53
+ ...process.env,
54
+ [AVA_EXPECT_UNHANDLED_REJECTIONS]: `${expectedUnhandled}`,
55
+ },
56
+ stdio: ['ignore', 'inherit', 'inherit', 'ignore'],
57
+ });
58
+
59
+ ps.on('close', code => {
60
+ t.is(code, 0, `got exit code ${code}, expected 0 for ${name}`);
61
+ resolve();
62
+ });
63
+ ps.on('error', reject);
64
+ }),
65
+ });
66
+ };
@@ -10,6 +10,4 @@ export function startSubprocessWorker(execPath: any, procArgs?: any[], { netstri
10
10
  terminate: () => void;
11
11
  done: Promise<any>;
12
12
  };
13
- export type IOType = import("child_process").IOType;
14
- export type Writable = import("stream").Writable;
15
13
  //# sourceMappingURL=spawnSubprocessWorker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spawnSubprocessWorker.d.ts","sourceRoot":"","sources":["spawnSubprocessWorker.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;EA0DC;qBApEa,OAAO,eAAe,EAAE,MAAM;uBAC9B,OAAO,QAAQ,EAAE,QAAQ"}
1
+ {"version":3,"file":"spawnSubprocessWorker.d.ts","sourceRoot":"","sources":["spawnSubprocessWorker.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;EA0DC"}
@@ -8,6 +8,11 @@ import {
8
8
  netstringDecoderStream,
9
9
  } from '../netstring.js';
10
10
 
11
+ /**
12
+ * @import {IOType} from 'child_process'
13
+ * @import {Writable} from 'stream'
14
+ */
15
+
11
16
  // Start a subprocess from a given executable, and arrange a bidirectional
12
17
  // message channel with a "supervisor" within that process. Return a {
13
18
  // toChild, fromChild } pair of Streams which accept/emit hardened Arrays of
@@ -18,9 +23,6 @@ function parentLog(first, ...args) {
18
23
  // console.error(`--parent: ${first}`, ...args);
19
24
  }
20
25
 
21
- /** @typedef {import('child_process').IOType} IOType */
22
- /** @typedef {import('stream').Writable} Writable */
23
-
24
26
  // we send on fd3, and receive on fd4. We pass fd1/2 (stdout/err) through, so
25
27
  // console log/err from the child shows up normally. We don't use Node's
26
28
  // built-in serialization feature ('ipc') because the child process won't
@@ -1,2 +1,5 @@
1
+ /**
2
+ * @import {PromiseKit} from '@endo/promise-kit';
3
+ */
1
4
  export function waitUntilQuiescent(): Promise<void>;
2
5
  //# sourceMappingURL=waitUntilQuiescent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitUntilQuiescent.d.ts","sourceRoot":"","sources":["waitUntilQuiescent.js"],"names":[],"mappings":"AAMA,oDAWC"}
1
+ {"version":3,"file":"waitUntilQuiescent.d.ts","sourceRoot":"","sources":["waitUntilQuiescent.js"],"names":[],"mappings":"AAGA;;GAEG;AAKH,oDAWC"}
@@ -1,6 +1,10 @@
1
1
  /* global setImmediate */
2
2
  import { makePromiseKit } from '@endo/promise-kit';
3
3
 
4
+ /**
5
+ * @import {PromiseKit} from '@endo/promise-kit';
6
+ */
7
+
4
8
  // This can only be imported from the Start Compartment, where 'setImmediate'
5
9
  // is available.
6
10
 
@@ -11,7 +15,7 @@ export function waitUntilQuiescent() {
11
15
  // lower-priority than the Promise queue on browsers and Node 11, but on
12
16
  // Node 10 it is higher. So this trick requires Node 11.
13
17
  // https://jsblog.insiderattack.net/new-changes-to-timers-and-microtasks-from-node-v11-0-0-and-above-68d112743eb3
14
- /** @type {import('@endo/promise-kit').PromiseKit<void>} */
18
+ /** @type {PromiseKit<void>} */
15
19
  const { promise: queueEmptyP, resolve } = makePromiseKit();
16
20
  setImmediate(() => resolve());
17
21
  return queueEmptyP;
@@ -0,0 +1,19 @@
1
+ export function makeBoardRemote<BoardId = string | null>({ boardId, iface }: {
2
+ boardId: BoardId;
3
+ iface?: string;
4
+ }): BoardRemote<BoardId>;
5
+ export function slotToBoardRemote<BoardId = string>(boardId: BoardId, iface: string): BoardRemote<BoardId>;
6
+ export function boardSlottingMarshaller<BoardId = string | null>(slotToVal?: (slot: BoardId, iface: string) => any): Omit<Marshal<BoardId>, "serialize" | "unserialize">;
7
+ export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: FromCapData<string>, index: number): any;
8
+ export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): {
9
+ getItem: (key: string) => any;
10
+ children: (prefix: string) => string[];
11
+ has: (k: string) => boolean;
12
+ };
13
+ export type BoardRemote<BoardId = string | null> = {
14
+ getBoardId: () => BoardId;
15
+ } & RemotableObject;
16
+ import type { Marshal } from '@endo/marshal';
17
+ import type { FromCapData } from '@endo/marshal';
18
+ import type { RemotableObject } from '@endo/pass-style';
19
+ //# sourceMappingURL=board-client-utils.d.ts.map
@@ -0,0 +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"}
@@ -2,18 +2,23 @@
2
2
  import { Fail } from '@endo/errors';
3
3
  import { Far } from '@endo/far';
4
4
  import { makeMarshal } from '@endo/marshal';
5
- import { isStreamCell } from './lib-chainStorage.js';
5
+ import { isStreamCell } from '../lib-chainStorage.js';
6
+ import { assertCapData } from './cap-data.js';
6
7
 
7
8
  /**
8
- * Should be a union with Remotable, but that's `any`, making this type
9
- * meaningless
10
- *
11
- * @typedef {{ getBoardId: () => string | null }} BoardRemote
9
+ * @import {RemotableObject} from '@endo/pass-style';
10
+ * @import {CapData, FromCapData, ConvertValToSlot, Marshal} from '@endo/marshal';
12
11
  */
13
12
 
14
13
  /**
15
- * @param {{ boardId: string | null; iface?: string }} slotInfo
16
- * @returns {BoardRemote}
14
+ * @template [BoardId=(string | null)]
15
+ * @typedef {{ getBoardId: () => BoardId } & RemotableObject} BoardRemote
16
+ */
17
+
18
+ /**
19
+ * @template [BoardId=(string | null)]
20
+ * @param {{ boardId: BoardId; iface?: string }} slotInfo
21
+ * @returns {BoardRemote<BoardId>}
17
22
  */
18
23
  export const makeBoardRemote = ({ boardId, iface }) => {
19
24
  const nonalleged = iface ? iface.replace(/^Alleged: /, '') : '';
@@ -21,13 +26,17 @@ export const makeBoardRemote = ({ boardId, iface }) => {
21
26
  };
22
27
 
23
28
  /**
24
- * @param {string} boardId
29
+ * @template [BoardId=string]
30
+ * @param {BoardId} boardId
25
31
  * @param {string} iface
26
32
  */
27
33
  export const slotToBoardRemote = (boardId, iface) =>
28
34
  makeBoardRemote({ boardId, iface });
29
35
 
30
- /** @param {BoardRemote | object} val */
36
+ /**
37
+ * @param {BoardRemote<any> | object} val
38
+ * @returns {val extends BoardRemote<infer BoardId> ? BoardId : never}
39
+ */
31
40
  const boardValToSlot = val => {
32
41
  if ('getBoardId' in val) {
33
42
  return val.getBoardId();
@@ -40,41 +49,26 @@ const boardValToSlot = val => {
40
49
  * allows the caller to pick their slots. The deserializer is configurable: the
41
50
  * default cannot handle Remotable-bearing data.
42
51
  *
43
- * @param {(slot: string, iface: string) => any} [slotToVal]
44
- * @returns {Omit<
45
- * import('@endo/marshal').Marshal<string | null>,
46
- * 'serialize' | 'unserialize'
47
- * >}
52
+ * @template [BoardId=(string | null)]
53
+ * @param {(slot: BoardId, iface: string) => any} [slotToVal]
54
+ * @returns {Omit<Marshal<BoardId>, 'serialize' | 'unserialize'>}
48
55
  */
49
56
  export const boardSlottingMarshaller = (slotToVal = undefined) => {
50
- return makeMarshal(boardValToSlot, slotToVal, {
51
- serializeBodyFormat: 'smallcaps',
52
- });
53
- };
54
-
55
- // TODO: Consolidate with `insistCapData` functions from swingset-liveslots,
56
- // swingset-xsnap-supervisor, etc.
57
- /**
58
- * @param {unknown} data
59
- * @returns {asserts data is import('@endo/marshal').CapData<string>}
60
- */
61
- const assertCapData = data => {
62
- assert.typeof(data, 'object');
63
- assert(data);
64
- assert.typeof(data.body, 'string');
65
- assert(Array.isArray(data.slots));
66
- // XXX check that the .slots array elements are actually strings
57
+ return makeMarshal(
58
+ /** @type {ConvertValToSlot<BoardId>} */ (boardValToSlot),
59
+ slotToVal,
60
+ {
61
+ serializeBodyFormat: 'smallcaps',
62
+ },
63
+ );
67
64
  };
68
- harden(assertCapData);
69
65
 
70
66
  /**
71
67
  * Read and unmarshal a value from a map representation of vstorage data
72
68
  *
73
69
  * @param {Map<string, string>} data
74
70
  * @param {string} key
75
- * @param {ReturnType<
76
- * typeof import('@endo/marshal').makeMarshal
77
- * >['fromCapData']} fromCapData
71
+ * @param {FromCapData<string>} fromCapData
78
72
  * @param {number} index index of the desired value in a deserialized stream
79
73
  * cell
80
74
  * @returns {any}
@@ -95,7 +89,7 @@ export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
95
89
  const marshalled = values.at(index);
96
90
  assert.typeof(marshalled, 'string');
97
91
 
98
- /** @type {import('@endo/marshal').CapData<string>} */
92
+ /** @type {CapData<string>} */
99
93
  const capData = harden(JSON.parse(marshalled));
100
94
  assertCapData(capData);
101
95
 
@@ -0,0 +1,3 @@
1
+ export function assertCapData(data: unknown): asserts data is CapData<unknown>;
2
+ import type { CapData } from '@endo/marshal';
3
+ //# sourceMappingURL=cap-data.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,20 @@
1
+ // @ts-check
2
+ import { Fail } from '@endo/errors';
3
+
4
+ /**
5
+ * @import {CapData} from '@endo/marshal';
6
+ */
7
+
8
+ /**
9
+ * Assert that this is CapData
10
+ *
11
+ * @param {unknown} data
12
+ * @returns {asserts data is CapData<unknown>}
13
+ */
14
+ export const assertCapData = data => {
15
+ assert.typeof(data, 'object');
16
+ assert(data);
17
+ typeof data.body === 'string' || Fail`data has non-string .body ${data.body}`;
18
+ Array.isArray(data.slots) || Fail`data has non-Array slots ${data.slots}`;
19
+ };
20
+ harden(assertCapData);
@@ -0,0 +1,2 @@
1
+ export function makeInaccessibleVal(iface: string | undefined): any;
2
+ //# sourceMappingURL=inaccessible-val.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inaccessible-val.d.ts","sourceRoot":"","sources":["inaccessible-val.js"],"names":[],"mappings":"AASO,2CAHI,MAAM,GAAG,SAAS,GAChB,GAAG,CAOf"}
@@ -0,0 +1,15 @@
1
+ // @ts-check
2
+ import { Far } from '@endo/far';
3
+
4
+ const ifaceAllegedPrefix = 'Alleged: ';
5
+ const ifaceInaccessiblePrefix = 'SEVERED: ';
6
+ /**
7
+ * @param {string | undefined} iface
8
+ * @returns {any}
9
+ */
10
+ export const makeInaccessibleVal = iface => {
11
+ if (typeof iface === 'string' && iface.startsWith(ifaceAllegedPrefix)) {
12
+ iface = iface.slice(ifaceAllegedPrefix.length);
13
+ }
14
+ return Far(`${ifaceInaccessiblePrefix}${iface}`, {});
15
+ };
@@ -0,0 +1,8 @@
1
+ export const pureDataMarshaller: {
2
+ toCapData: import("@endo/marshal").ToCapData<CapData<unknown>>;
3
+ fromCapData: import("@endo/marshal").FromCapData<CapData<unknown>>;
4
+ serialize: import("@endo/marshal").ToCapData<CapData<unknown>>;
5
+ unserialize: import("@endo/marshal").FromCapData<CapData<unknown>>;
6
+ };
7
+ import type { CapData } from '@endo/marshal';
8
+ //# sourceMappingURL=pure-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure-data.d.ts","sourceRoot":"","sources":["pure-data.js"],"names":[],"mappings":"AAUA;;;;;EAEG;6BAPuB,eAAe"}
@@ -0,0 +1,14 @@
1
+ // @ts-check
2
+ import { Fail } from '@endo/errors';
3
+ import { makeMarshal } from '@endo/marshal';
4
+
5
+ /**
6
+ * @import {CapData} from '@endo/marshal';
7
+ */
8
+
9
+ /** @param {CapData<unknown>} cap */
10
+ const rejectOCap = cap => Fail`${cap} is not pure data`;
11
+ export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, {
12
+ serializeBodyFormat: 'smallcaps',
13
+ });
14
+ harden(pureDataMarshaller);
@@ -0,0 +1,33 @@
1
+ export function wrapRemoteMarshallerSendSlotsOnly<Slot = unknown>(marshaller: ERemote<Pick<EMarshaller<Slot>, "fromCapData" | "toCapData">>, { serializeBodyFormat, errorTagging, ...otherMarshalOptions }?: MakeMarshalOptions, { valToSlot, slotToVal, cacheSeveredVal, }?: {
2
+ valToSlot?: WeakMapAPI<any, Slot> | null | undefined;
3
+ slotToVal?: WeakMapAPI<Slot, any> | null | undefined;
4
+ cacheSeveredVal?: boolean | undefined;
5
+ }): ReturnType<typeof Far<EMarshaller<Slot>>>;
6
+ export function wrapRemoteMarshallerDirectSend<Slot = unknown>(marshaller: ERemote<Pick<EMarshaller<Slot>, "fromCapData" | "toCapData">>): ReturnType<typeof Far<EMarshaller<Slot>>>;
7
+ export function wrapRemoteMarshaller<Slot = unknown>(marshaller: ERemote<Pick<EMarshaller<Slot>, "fromCapData" | "toCapData">>, { serializeBodyFormat, errorTagging, ...otherMarshalOptions }?: MakeMarshalOptions, { valToSlot, slotToVal, cacheSeveredVal, }?: {
8
+ valToSlot?: WeakMapAPI<any, Slot> | null | undefined;
9
+ slotToVal?: WeakMapAPI<Slot, any> | null | undefined;
10
+ cacheSeveredVal?: boolean | undefined;
11
+ }): ReturnType<typeof Far<EMarshaller<Slot>>>;
12
+ /**
13
+ * A Marshaller which methods may be async. Use this type to indicate accepting
14
+ * either a sync or async marshaller, usually through `E` eventual-sends.
15
+ */
16
+ export type EMarshaller<Slot = unknown> = Simplify<EOnly<Marshal<Slot>>>;
17
+ export type SlotWrapper<Slot = unknown> = ReturnType<typeof slotToWrapper<Slot>>;
18
+ import type { ERemote } from '../types.js';
19
+ import type { MakeMarshalOptions } from '@endo/marshal';
20
+ import type { WeakMapAPI } from '@endo/cache-map';
21
+ import { Far } from '@endo/far';
22
+ import type { Marshal } from '@endo/marshal';
23
+ import type { EOnly } from '@endo/eventual-send';
24
+ import type { Simplify } from '@endo/pass-style';
25
+ declare function slotToWrapper<Slot = unknown>(slot: Slot, iface?: string): {
26
+ /** @type {Slot} */
27
+ "__#private@#slot": Slot;
28
+ /** @type {InterfaceSpec} */
29
+ [Symbol.toStringTag]: `Alleged: ${string}` | "Remotable";
30
+ } & RemotableObject<`Alleged: ${string}` | "Remotable">;
31
+ import type { RemotableObject } from '@endo/pass-style';
32
+ export {};
33
+ //# sourceMappingURL=wrap-marshaller.d.ts.map
@@ -0,0 +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,WAAW,CAAC,CAAC,kEAC7D,kBAAkB,+CAE1B;IAAiD,SAAS;IACT,SAAS;IACjC,eAAe;CACxC,GAAU,UAAU,CAAC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CA4RrD;AAOM,+CAJO,IAAI,wBACP,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,WAAW,CAAC,CAAC,GAC3D,UAAU,CAAC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAyBrD;AAxTM,qCATO,IAAI,wBACP,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,WAAW,CAAC,CAAC,kEAC7D,kBAAkB,+CAE1B;IAAiD,SAAS;IACT,SAAS;IACjC,eAAe;CACxC,GAAU,UAAU,CAAC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CA4RrD;;;;;wBAjYa,IAAI,cACL,SAAS,MAAM,QAAQ,IAAI,CAAC,CAAC,CAAC;wBA+D7B,IAAI,cAAoB,UAAU,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;6BAvElD,aAAa;wCAD0B,eAAe;gCAHnD,iBAAiB;oBAN1B,WAAW;6BASkC,eAAe;2BAFxD,qBAAqB;8BACD,kBAAkB;AA+D3C,+BAJD,IAAI,kBACP,IAAI,UACJ,MAAM,GAGJ;IA9Cb,mBAAmB;;IAGnB,4BAA4B;;IA2CK,mDAA8B,CAE5D;qCAlEqC,kBAAkB"}