@agoric/xsnap 0.14.3-dev-5d70529.0 → 0.14.3-dev-c87930e.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/xsnap",
3
- "version": "0.14.3-dev-5d70529.0+5d70529",
3
+ "version": "0.14.3-dev-c87930e.0+c87930e",
4
4
  "description": "Snapshotting VM worker based on Moddable's XS Javascript engine",
5
5
  "author": "Agoric",
6
6
  "license": "Apache-2.0",
@@ -28,8 +28,8 @@
28
28
  "test:xs": "exit 0"
29
29
  },
30
30
  "dependencies": {
31
- "@agoric/internal": "0.3.3-dev-5d70529.0+5d70529",
32
- "@agoric/xsnap-lockdown": "0.14.1-dev-5d70529.0+5d70529",
31
+ "@agoric/internal": "0.3.3-dev-c87930e.0+c87930e",
32
+ "@agoric/xsnap-lockdown": "0.14.1-dev-c87930e.0+c87930e",
33
33
  "@endo/bundle-source": "^3.2.3",
34
34
  "@endo/errors": "^1.2.2",
35
35
  "@endo/eventual-send": "^1.2.2",
@@ -78,5 +78,5 @@
78
78
  "typeCoverage": {
79
79
  "atLeast": 93.99
80
80
  },
81
- "gitHead": "5d705299d437b90b473274c5eb073185c23f51cb"
81
+ "gitHead": "c87930eadf94cb146f054d5f31429c5156c7dacd"
82
82
  }
package/src/xsnap.js CHANGED
@@ -10,18 +10,14 @@ import { makeNodeReader, makeNodeWriter } from '@endo/stream-node';
10
10
  import { makePromiseKit, racePromises } from '@endo/promise-kit';
11
11
  import { forever } from '@agoric/internal';
12
12
  import { ErrorCode, ErrorSignal, ErrorMessage, METER_TYPE } from '../api.js';
13
- import { defer } from './defer.js';
13
+
14
+ /** @import {PromiseKit} from '@endo/promise-kit' */
14
15
 
15
16
  /**
16
17
  * @typedef {typeof import('child_process').spawn} Spawn
17
18
  * @import {Writable} from 'stream'
18
19
  */
19
20
 
20
- /**
21
- * @template T
22
- * @typedef {import('./defer.js').Deferred<T>} Deferred
23
- */
24
-
25
21
  // This will need adjustment, but seems to be fine for a start.
26
22
  export const DEFAULT_CRANK_METERING_LIMIT = 1e8;
27
23
 
@@ -185,8 +181,8 @@ export async function xsnap(options) {
185
181
  import.meta.url,
186
182
  ).pathname;
187
183
 
188
- /** @type {Deferred<void>} */
189
- const vatExit = defer();
184
+ /** @type {PromiseKit<void>} */
185
+ const vatExit = makePromiseKit();
190
186
 
191
187
  assert(!/^-/.test(name), `name '${name}' cannot start with hyphen`);
192
188
 
package/src/xsrepl.js CHANGED
@@ -4,17 +4,15 @@
4
4
 
5
5
  import '@endo/init';
6
6
 
7
- /**
8
- * @template T
9
- * @typedef {import('./defer.js').Deferred<T>} Deferred
10
- */
11
7
  import * as childProcess from 'child_process';
12
8
  import fs from 'fs';
13
9
  import { tmpName } from 'tmp';
14
10
  import * as os from 'os';
15
11
  import * as readline from 'readline';
12
+ import { makePromiseKit } from '@endo/promise-kit';
16
13
  import { xsnap } from './xsnap.js';
17
- import { defer } from './defer.js';
14
+
15
+ /** @import {PromiseKit} from '@endo/promise-kit' */
18
16
 
19
17
  const decoder = new TextDecoder();
20
18
 
@@ -65,7 +63,9 @@ async function main() {
65
63
  * @returns {Promise<string>}
66
64
  */
67
65
  function ask(prompt) {
68
- const { promise, resolve } = /** @type {Deferred<string>} */ (defer());
66
+ const { promise, resolve } = /** @type {PromiseKit<string>} */ (
67
+ makePromiseKit()
68
+ );
69
69
  rl.question(prompt, resolve);
70
70
  return promise;
71
71
  }
package/src/defer.js DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * @param {boolean} _flag
3
- * @returns {asserts _flag}
4
- */
5
-
6
- function assert(_flag) {}
7
-
8
- /**
9
- * @template T
10
- * @typedef {{
11
- * resolve(value?: T | Promise<T>): void,
12
- * reject(error: Error): void,
13
- * promise: Promise<T>
14
- * }} Deferred
15
- */
16
-
17
- /**
18
- * @template T
19
- * @returns {Deferred<T>}
20
- */
21
- export function defer() {
22
- let resolve;
23
- let reject;
24
- const promise = new Promise((res, rej) => {
25
- resolve = res;
26
- reject = rej;
27
- });
28
- assert(resolve !== undefined);
29
- assert(reject !== undefined);
30
- return { promise, resolve, reject };
31
- }