@agoric/xsnap 0.14.3-upgrade-14-dev-c8f9e7b.0 → 0.14.3-upgrade-16-dev-8879538.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/README.md +3 -3
- package/api.js +4 -2
- package/moddable/modules/data/base64/base64.js +28 -0
- package/moddable/modules/data/base64/manifest.json +11 -0
- package/moddable/modules/data/base64/modBase64.c +188 -0
- package/moddable/modules/data/binaryMessage/BinaryMessage.js +106 -0
- package/moddable/modules/data/crc/crc.c +205 -0
- package/moddable/modules/data/crc/crc.js +36 -0
- package/moddable/modules/data/crc/manifest.json +8 -0
- package/moddable/modules/data/hex/hex.js +28 -0
- package/moddable/modules/data/hex/manifest.json +11 -0
- package/moddable/modules/data/hex/modHex.c +139 -0
- package/moddable/modules/data/logical/logical.js +32 -0
- package/moddable/modules/data/logical/modLogical.c +98 -0
- package/moddable/modules/data/qrcode/manifest.json +9 -0
- package/moddable/modules/data/qrcode/qrcode.c +93 -0
- package/moddable/modules/data/qrcode/qrcode.js +23 -0
- package/moddable/modules/data/qrcode/qrcodegen.c +1025 -0
- package/moddable/modules/data/qrcode/qrcodegen.h +267 -0
- package/moddable/modules/data/text/decoder/manifest.json +8 -0
- package/moddable/modules/data/text/decoder/textdecoder.c +480 -0
- package/moddable/modules/data/text/decoder/textdecoder.js +27 -0
- package/moddable/modules/data/text/encoder/manifest.json +8 -0
- package/moddable/modules/data/text/encoder/textencoder.c +232 -0
- package/moddable/modules/data/text/encoder/textencoder.js +24 -0
- package/moddable/modules/data/tinyint/tinyint.c +150 -0
- package/moddable/modules/data/tinyint/tinyint.js +53 -0
- package/moddable/modules/data/url/manifest.json +17 -0
- package/moddable/modules/data/url/url.c +1959 -0
- package/moddable/modules/data/url/url.js +210 -0
- package/moddable/modules/data/wavreader/manifest.json +8 -0
- package/moddable/modules/data/wavreader/wavreader.js +128 -0
- package/moddable/modules/data/zlib/deflate.c +161 -0
- package/moddable/modules/data/zlib/deflate.js +63 -0
- package/moddable/modules/data/zlib/inflate.c +145 -0
- package/moddable/modules/data/zlib/inflate.js +66 -0
- package/moddable/modules/data/zlib/manifest_deflate.json +9 -0
- package/moddable/modules/data/zlib/manifest_inflate.json +9 -0
- package/moddable/modules/data/zlib/miniz.c +4924 -0
- package/moddable/xs/includes/xs.d.ts +73 -0
- package/moddable/xs/includes/xs.h +1533 -0
- package/moddable/xs/includes/xsmc.h +206 -0
- package/moddable/xs/makefiles/lin/makefile +33 -0
- package/moddable/xs/makefiles/lin/xsc.mk +118 -0
- package/moddable/xs/makefiles/lin/xsid.mk +90 -0
- package/moddable/xs/makefiles/lin/xsl.mk +168 -0
- package/moddable/xs/makefiles/lin/xst.mk +201 -0
- package/moddable/xs/makefiles/mac/makefile +33 -0
- package/moddable/xs/makefiles/mac/xsc.mk +130 -0
- package/moddable/xs/makefiles/mac/xsid.mk +102 -0
- package/moddable/xs/makefiles/mac/xsl.mk +177 -0
- package/moddable/xs/makefiles/mac/xst.mk +203 -0
- package/moddable/xs/makefiles/mac/xst_no_asan.txt +52 -0
- package/moddable/xs/makefiles/win/build.bat +26 -0
- package/moddable/xs/makefiles/win/xsc.mak +142 -0
- package/moddable/xs/makefiles/win/xsid.mak +113 -0
- package/moddable/xs/makefiles/win/xsl.mak +186 -0
- package/moddable/xs/makefiles/win/xst.mak +195 -0
- package/moddable/xs/platforms/lin_xs.h +99 -0
- package/moddable/xs/platforms/mac_xs.h +97 -0
- package/moddable/xs/platforms/wasm_xs.h +79 -0
- package/moddable/xs/platforms/win_xs.h +104 -0
- package/moddable/xs/platforms/xsHost.h +63 -0
- package/moddable/xs/platforms/xsPlatform.h +618 -0
- package/moddable/xs/sources/xsAPI.c +2555 -0
- package/moddable/xs/sources/xsAll.c +294 -0
- package/moddable/xs/sources/xsAll.h +2741 -0
- package/moddable/xs/sources/xsArguments.c +222 -0
- package/moddable/xs/sources/xsArray.c +2657 -0
- package/moddable/xs/sources/xsAtomics.c +844 -0
- package/moddable/xs/sources/xsBigInt.c +1859 -0
- package/moddable/xs/sources/xsBoolean.c +109 -0
- package/moddable/xs/sources/xsCode.c +4493 -0
- package/moddable/xs/sources/xsCommon.c +1710 -0
- package/moddable/xs/sources/xsCommon.h +1142 -0
- package/moddable/xs/sources/xsDataView.c +2890 -0
- package/moddable/xs/sources/xsDate.c +1541 -0
- package/moddable/xs/sources/xsDebug.c +2710 -0
- package/moddable/xs/sources/xsDefaults.c +134 -0
- package/moddable/xs/sources/xsError.c +353 -0
- package/moddable/xs/sources/xsFunction.c +776 -0
- package/moddable/xs/sources/xsGenerator.c +865 -0
- package/moddable/xs/sources/xsGlobal.c +839 -0
- package/moddable/xs/sources/xsJSON.c +1091 -0
- package/moddable/xs/sources/xsLexical.c +1969 -0
- package/moddable/xs/sources/xsLockdown.c +933 -0
- package/moddable/xs/sources/xsMapSet.c +1649 -0
- package/moddable/xs/sources/xsMarshall.c +1020 -0
- package/moddable/xs/sources/xsMath.c +624 -0
- package/moddable/xs/sources/xsMemory.c +1941 -0
- package/moddable/xs/sources/xsModule.c +3101 -0
- package/moddable/xs/sources/xsNumber.c +560 -0
- package/moddable/xs/sources/xsObject.c +1102 -0
- package/moddable/xs/sources/xsPlatforms.c +480 -0
- package/moddable/xs/sources/xsProfile.c +577 -0
- package/moddable/xs/sources/xsPromise.c +1199 -0
- package/moddable/xs/sources/xsProperty.c +636 -0
- package/moddable/xs/sources/xsProxy.c +1014 -0
- package/moddable/xs/sources/xsRegExp.c +1168 -0
- package/moddable/xs/sources/xsRun.c +4889 -0
- package/moddable/xs/sources/xsScope.c +1293 -0
- package/moddable/xs/sources/xsScript.c +288 -0
- package/moddable/xs/sources/xsScript.h +1186 -0
- package/moddable/xs/sources/xsSnapshot.c +2161 -0
- package/moddable/xs/sources/xsSnapshot.h +51 -0
- package/moddable/xs/sources/xsSourceMap.c +218 -0
- package/moddable/xs/sources/xsString.c +3332 -0
- package/moddable/xs/sources/xsSymbol.c +503 -0
- package/moddable/xs/sources/xsSyntaxical.c +4193 -0
- package/moddable/xs/sources/xsTree.c +1893 -0
- package/moddable/xs/sources/xsType.c +1488 -0
- package/moddable/xs/sources/xsdtoa.c +6672 -0
- package/moddable/xs/sources/xsmc.c +340 -0
- package/moddable/xs/sources/xsre.c +7578 -0
- package/package.json +35 -20
- package/src/avaAssertXS.js +4 -2
- package/src/avaHandler.cjs +2 -5
- package/src/avaXS.js +7 -8
- package/src/build.js +126 -26
- package/src/replay.js +0 -3
- package/src/xsnap.js +105 -91
- package/src/xsrepl.js +2 -3
- package/xsnap-native/xsnap/makefiles/lin/makefile +10 -0
- package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +153 -0
- package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +144 -0
- package/xsnap-native/xsnap/makefiles/mac/makefile +10 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +162 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +153 -0
- package/xsnap-native/xsnap/sources/xsnap-worker.c +996 -0
- package/xsnap-native/xsnap/sources/xsnap.c +716 -0
- package/xsnap-native/xsnap/sources/xsnap.h +142 -0
- package/xsnap-native/xsnap/sources/xsnapPlatform.c +1496 -0
- package/xsnap-native/xsnap/sources/xsnapPlatform.h +105 -0
- package/CHANGELOG.md +0 -646
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/xsnap",
|
|
3
|
-
"version": "0.14.3-upgrade-
|
|
3
|
+
"version": "0.14.3-upgrade-16-dev-8879538.0+8879538",
|
|
4
4
|
"description": "Snapshotting VM worker based on Moddable's XS Javascript engine",
|
|
5
5
|
"author": "Agoric",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,53 +13,68 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"repl": "node src/xsrepl.js",
|
|
15
15
|
"build:bin": "if test -d ./test; then node src/build.js; else yarn build:from-env; fi",
|
|
16
|
-
"build:env": "
|
|
16
|
+
"build:env": "node src/build.js --show-env > build.env",
|
|
17
17
|
"build:from-env": "{ cat build.env; echo node src/build.js; } | xargs env",
|
|
18
18
|
"build": "yarn build:bin && yarn build:env",
|
|
19
|
-
"postinstall": "
|
|
19
|
+
"postinstall": "npm run build:from-env",
|
|
20
20
|
"clean": "rm -rf xsnap-native/xsnap/build",
|
|
21
21
|
"lint": "run-s --continue-on-error lint:*",
|
|
22
22
|
"lint:js": "eslint 'src/**/*.js' 'test/**/*.js' api.js",
|
|
23
|
-
"lint:types": "tsc
|
|
23
|
+
"lint:types": "tsc",
|
|
24
24
|
"lint-fix": "eslint --fix 'src/**/*.js' 'test/**/*.js' api.js",
|
|
25
25
|
"test": "ava",
|
|
26
26
|
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
|
|
27
27
|
"test:xs": "exit 0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agoric/assert": "0.6.1-upgrade-
|
|
31
|
-
"@agoric/internal": "0.
|
|
32
|
-
"@agoric/xsnap-lockdown": "0.14.1-upgrade-
|
|
33
|
-
"@endo/bundle-source": "2.
|
|
34
|
-
"@endo/eventual-send": "
|
|
35
|
-
"@endo/init": "
|
|
36
|
-
"@endo/netstring": "0.
|
|
37
|
-
"@endo/promise-kit": "
|
|
38
|
-
"@endo/stream": "
|
|
39
|
-
"@endo/stream-node": "
|
|
30
|
+
"@agoric/assert": "0.6.1-upgrade-16-dev-8879538.0+8879538",
|
|
31
|
+
"@agoric/internal": "0.3.3-upgrade-16-dev-8879538.0+8879538",
|
|
32
|
+
"@agoric/xsnap-lockdown": "0.14.1-upgrade-16-dev-8879538.0+8879538",
|
|
33
|
+
"@endo/bundle-source": "^3.2.3",
|
|
34
|
+
"@endo/eventual-send": "^1.2.2",
|
|
35
|
+
"@endo/init": "^1.1.2",
|
|
36
|
+
"@endo/netstring": "^1.0.7",
|
|
37
|
+
"@endo/promise-kit": "^1.1.2",
|
|
38
|
+
"@endo/stream": "^1.2.2",
|
|
39
|
+
"@endo/stream-node": "^1.1.2",
|
|
40
40
|
"glob": "^7.1.6",
|
|
41
41
|
"tmp": "^0.2.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@endo/base64": "0.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
44
|
+
"@endo/base64": "^1.0.5",
|
|
45
|
+
"@endo/nat": "^5.0.7",
|
|
46
|
+
"@types/glob": "^8.1.0",
|
|
47
|
+
"ava": "^5.3.0",
|
|
48
|
+
"c8": "^9.1.0"
|
|
47
49
|
},
|
|
48
50
|
"files": [
|
|
49
51
|
"LICENSE*",
|
|
50
52
|
"api.js",
|
|
51
53
|
"build.env",
|
|
52
|
-
"
|
|
54
|
+
"moddable/modules/data",
|
|
55
|
+
"moddable/xs/includes",
|
|
56
|
+
"moddable/xs/makefiles",
|
|
57
|
+
"moddable/xs/platforms/*.h",
|
|
58
|
+
"moddable/xs/sources",
|
|
59
|
+
"src",
|
|
60
|
+
"xsnap-native/xsnap/makefiles",
|
|
61
|
+
"xsnap-native/xsnap/sources"
|
|
53
62
|
],
|
|
54
63
|
"publishConfig": {
|
|
55
64
|
"access": "public"
|
|
56
65
|
},
|
|
57
66
|
"ava": {
|
|
58
67
|
"files": [
|
|
59
|
-
"test
|
|
68
|
+
"test/**/*.test.*"
|
|
69
|
+
],
|
|
70
|
+
"require": [
|
|
71
|
+
"@endo/init/debug.js"
|
|
60
72
|
],
|
|
61
73
|
"timeout": "2m",
|
|
62
74
|
"workerThreads": false
|
|
63
75
|
},
|
|
64
|
-
"
|
|
76
|
+
"typeCoverage": {
|
|
77
|
+
"atLeast": 94.04
|
|
78
|
+
},
|
|
79
|
+
"gitHead": "8879538cd1d125a08346f02dd5701d0d70c90bb8"
|
|
65
80
|
}
|
package/src/avaAssertXS.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* global globalThis */
|
|
2
|
-
/* eslint-disable no-await-in-loop, @jessie.js/no-nested-await -- test code */
|
|
3
2
|
/** global print */
|
|
4
3
|
|
|
5
4
|
const { assign, freeze, keys } = Object;
|
|
@@ -67,7 +66,7 @@ function deepDifference(x, y) {
|
|
|
67
66
|
* @param {(msg: TapMessage) => void} send
|
|
68
67
|
*
|
|
69
68
|
* @typedef { ReturnType<typeof tapFormat> } TapFormat
|
|
70
|
-
* @
|
|
69
|
+
* @import {TapMessage} from './avaXS.js'
|
|
71
70
|
*/
|
|
72
71
|
function tapFormat(send) {
|
|
73
72
|
return freeze({
|
|
@@ -300,6 +299,7 @@ function makeTester(htest, out) {
|
|
|
300
299
|
expectation,
|
|
301
300
|
message = `should reject like ${expectation}`,
|
|
302
301
|
) {
|
|
302
|
+
await null;
|
|
303
303
|
try {
|
|
304
304
|
await (typeof thrower === 'function' ? thrower() : thrower);
|
|
305
305
|
assert(false, message);
|
|
@@ -310,6 +310,7 @@ function makeTester(htest, out) {
|
|
|
310
310
|
},
|
|
311
311
|
/** @type {(thrower: () => Promise<unknown>, message?: string) => Promise<void> } */
|
|
312
312
|
async notThrowsAsync(nonThrower, message) {
|
|
313
|
+
await null;
|
|
313
314
|
try {
|
|
314
315
|
await (typeof nonThrower === 'function' ? nonThrower() : nonThrower);
|
|
315
316
|
} catch (ex) {
|
|
@@ -335,6 +336,7 @@ const test = (label, run, htestOpt) => {
|
|
|
335
336
|
htest.queue(label, async () => {
|
|
336
337
|
const out = tapFormat(htest.send);
|
|
337
338
|
const t = makeTester(htest, out);
|
|
339
|
+
await null;
|
|
338
340
|
try {
|
|
339
341
|
// out.diagnostic('start', label);
|
|
340
342
|
await run(t);
|
package/src/avaHandler.cjs
CHANGED
|
@@ -12,7 +12,6 @@ HandledPromise is defined by eventual send shim.
|
|
|
12
12
|
/// <reference types="ses" />
|
|
13
13
|
/// <reference types="@endo/eventual-send" />
|
|
14
14
|
|
|
15
|
-
// @ts-expect-error cannot redeclare encoder
|
|
16
15
|
const encoder = new TextEncoder();
|
|
17
16
|
const decoder = new TextDecoder();
|
|
18
17
|
|
|
@@ -20,7 +19,7 @@ const decoder = new TextDecoder();
|
|
|
20
19
|
* @param {{ testNames: string[]} |
|
|
21
20
|
* { bundleSource: [string, ...unknown[]] } |
|
|
22
21
|
* TapMessage | Summary } item
|
|
23
|
-
* @
|
|
22
|
+
* @import {Summary} from './avaXS'
|
|
24
23
|
*/
|
|
25
24
|
function send(item) {
|
|
26
25
|
const msg = encoder.encode(JSON.stringify(item)).buffer;
|
|
@@ -33,7 +32,6 @@ function send(item) {
|
|
|
33
32
|
*/
|
|
34
33
|
const bundleSource = async (startFilename, ...args) => {
|
|
35
34
|
const msg = await send({ bundleSource: [startFilename, ...args] });
|
|
36
|
-
// @ts-expect-error send() returns void
|
|
37
35
|
return JSON.parse(decoder.decode(msg));
|
|
38
36
|
};
|
|
39
37
|
|
|
@@ -79,7 +77,7 @@ function handler(rawMessage) {
|
|
|
79
77
|
const { source } = msg;
|
|
80
78
|
const virtualObjectGlobals =
|
|
81
79
|
// @ts-expect-error
|
|
82
|
-
|
|
80
|
+
|
|
83
81
|
typeof VatData !== 'undefined' ? { VatData } : {};
|
|
84
82
|
const c = new Compartment({
|
|
85
83
|
require: testRequire,
|
|
@@ -87,7 +85,6 @@ function handler(rawMessage) {
|
|
|
87
85
|
__filename,
|
|
88
86
|
console,
|
|
89
87
|
assert,
|
|
90
|
-
// @ts-expect-error
|
|
91
88
|
HandledPromise,
|
|
92
89
|
URL: class URLStub {
|
|
93
90
|
constructor(url, base) {
|
package/src/avaXS.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Usage:
|
|
4
4
|
|
|
5
|
-
node avaXS.js [--debug] test
|
|
5
|
+
node avaXS.js [--debug] *.test.js
|
|
6
6
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
/* eslint-disable no-await-in-loop, @jessie.js/no-nested-await -- test code */
|
|
10
9
|
import '@endo/init';
|
|
11
10
|
|
|
12
11
|
import fs from 'fs';
|
|
@@ -69,8 +68,6 @@ function isMatch(specimen, pattern) {
|
|
|
69
68
|
*
|
|
70
69
|
* It also calls back if a test calls `bundleSource`.
|
|
71
70
|
*
|
|
72
|
-
* @typedef {{ moduleFormat: string, source: string }} Bundle
|
|
73
|
-
*
|
|
74
71
|
* And finally it reports back a summary of assertion results.
|
|
75
72
|
*
|
|
76
73
|
* @typedef {{
|
|
@@ -84,7 +81,7 @@ function isMatch(specimen, pattern) {
|
|
|
84
81
|
* @param {{ verbose?: boolean, titleMatch?: string }} options
|
|
85
82
|
* @param {{
|
|
86
83
|
* spawnXSnap: (opts: object) => XSnap,
|
|
87
|
-
* bundleSource: (
|
|
84
|
+
* bundleSource: import('@endo/bundle-source').BundleSource,
|
|
88
85
|
* resolve: ResolveFn,
|
|
89
86
|
* dirname: typeof import('path').dirname,
|
|
90
87
|
* basename: typeof import('path').basename,
|
|
@@ -93,7 +90,7 @@ function isMatch(specimen, pattern) {
|
|
|
93
90
|
*
|
|
94
91
|
* @typedef {{ total: number, pass: number, fail: { filename: string, name: string }[] }} TestResults
|
|
95
92
|
* @typedef { 'ok' | 'not ok' | 'SKIP' } Status
|
|
96
|
-
* @typedef {ReturnType<typeof import('./xsnap').xsnap>} XSnap
|
|
93
|
+
* @typedef {ReturnType<typeof import('./xsnap.js').xsnap>} XSnap
|
|
97
94
|
*/
|
|
98
95
|
async function runTestScript(
|
|
99
96
|
filename,
|
|
@@ -120,7 +117,7 @@ async function runTestScript(
|
|
|
120
117
|
/**
|
|
121
118
|
* See also send() in avaHandler.cjs
|
|
122
119
|
*
|
|
123
|
-
* @type { TapMessage | { testNames: string[] } | { bundleSource:
|
|
120
|
+
* @type { TapMessage | { testNames: string[] } | { bundleSource: Parameters<import('@endo/bundle-source').BundleSource> } | Summary }
|
|
124
121
|
*/
|
|
125
122
|
const msg = JSON.parse(decoder.decode(message));
|
|
126
123
|
// console.log(input, msg, qty, byStatus);
|
|
@@ -129,6 +126,7 @@ async function runTestScript(
|
|
|
129
126
|
testNames = msg.testNames;
|
|
130
127
|
}
|
|
131
128
|
|
|
129
|
+
await null;
|
|
132
130
|
if ('bundleSource' in msg) {
|
|
133
131
|
const [startFilename, ...rest] = msg.bundleSource;
|
|
134
132
|
// see also makeBundleResolve() below
|
|
@@ -244,6 +242,7 @@ async function avaConfig(args, options, { glob, readFile }) {
|
|
|
244
242
|
let debug = false;
|
|
245
243
|
let verbose = false;
|
|
246
244
|
let titleMatch;
|
|
245
|
+
await null;
|
|
247
246
|
while (args.length > 0) {
|
|
248
247
|
const arg = args.shift();
|
|
249
248
|
assert.typeof(arg, 'string');
|
|
@@ -301,7 +300,7 @@ async function avaConfig(args, options, { glob, readFile }) {
|
|
|
301
300
|
/**
|
|
302
301
|
* @param {string[]} args - CLI args (excluding node interpreter, script name)
|
|
303
302
|
* @param {{
|
|
304
|
-
* bundleSource:
|
|
303
|
+
* bundleSource: import('@endo/bundle-source').BundleSource,
|
|
305
304
|
* spawn: typeof import('child_process')['spawn'],
|
|
306
305
|
* osType: typeof import('os')['type'],
|
|
307
306
|
* readFile: typeof import('fs')['promises']['readFile'],
|
package/src/build.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* global process */
|
|
3
|
-
/* eslint-disable @jessie.js/no-nested-await -- test/build code */
|
|
4
3
|
import * as childProcessTop from 'child_process';
|
|
5
4
|
import fsTop from 'fs';
|
|
6
5
|
import osTop from 'os';
|
|
@@ -140,7 +139,7 @@ const makeSubmodule = (path, repoUrl, { git }) => {
|
|
|
140
139
|
};
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
|
-
* @param {
|
|
142
|
+
* @param {boolean} showEnv
|
|
144
143
|
* @param {{
|
|
145
144
|
* env: Record<string, string | undefined>,
|
|
146
145
|
* stdout: typeof process.stdout,
|
|
@@ -150,12 +149,9 @@ const makeSubmodule = (path, repoUrl, { git }) => {
|
|
|
150
149
|
* rmdirSync: typeof import('fs').rmdirSync,
|
|
151
150
|
* readFile: typeof import('fs').promises.readFile,
|
|
152
151
|
* },
|
|
153
|
-
* os: {
|
|
154
|
-
* type: typeof import('os').type,
|
|
155
|
-
* }
|
|
156
152
|
* }} io
|
|
157
153
|
*/
|
|
158
|
-
async
|
|
154
|
+
const updateSubmodules = async (showEnv, { env, stdout, spawn, fs }) => {
|
|
159
155
|
const git = makeCLI('git', { spawn });
|
|
160
156
|
|
|
161
157
|
// When changing/adding entries here, make sure to search the whole project
|
|
@@ -176,13 +172,13 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
176
172
|
},
|
|
177
173
|
];
|
|
178
174
|
|
|
179
|
-
|
|
175
|
+
await null;
|
|
176
|
+
if (showEnv) {
|
|
180
177
|
for (const submodule of submodules) {
|
|
181
178
|
const { path, envPrefix, commitHash } = submodule;
|
|
182
179
|
if (!commitHash) {
|
|
183
180
|
// We need to glean the commitHash and url from Git.
|
|
184
181
|
const sm = makeSubmodule(path, '?', { git });
|
|
185
|
-
// eslint-disable-next-line no-await-in-loop
|
|
186
182
|
const [[{ hash }], url] = await Promise.all([
|
|
187
183
|
sm.status(),
|
|
188
184
|
sm.config('url'),
|
|
@@ -208,17 +204,29 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
208
204
|
// ignore
|
|
209
205
|
}
|
|
210
206
|
if (!fs.existsSync(submodule.path)) {
|
|
211
|
-
// eslint-disable-next-line no-await-in-loop
|
|
212
207
|
await submodule.clone();
|
|
213
208
|
}
|
|
214
|
-
// eslint-disable-next-line no-await-in-loop
|
|
215
209
|
await submodule.checkout(commitHash);
|
|
216
210
|
} else {
|
|
217
|
-
// eslint-disable-next-line no-await-in-loop
|
|
218
211
|
await submodule.init();
|
|
219
212
|
}
|
|
220
213
|
}
|
|
214
|
+
};
|
|
221
215
|
|
|
216
|
+
/**
|
|
217
|
+
* @param {{
|
|
218
|
+
* spawn: typeof import('child_process').spawn,
|
|
219
|
+
* fs: {
|
|
220
|
+
* existsSync: typeof import('fs').existsSync,
|
|
221
|
+
* rmdirSync: typeof import('fs').rmdirSync,
|
|
222
|
+
* readFile: typeof import('fs').promises.readFile,
|
|
223
|
+
* },
|
|
224
|
+
* os: {
|
|
225
|
+
* type: typeof import('os').type,
|
|
226
|
+
* }
|
|
227
|
+
* }} io
|
|
228
|
+
*/
|
|
229
|
+
const makeXsnap = async ({ spawn, fs, os }) => {
|
|
222
230
|
const pjson = await fs.readFile(asset('../package.json'), 'utf-8');
|
|
223
231
|
const pkg = JSON.parse(pjson);
|
|
224
232
|
|
|
@@ -229,7 +237,6 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
229
237
|
|
|
230
238
|
const make = makeCLI(platform.make || 'make', { spawn });
|
|
231
239
|
for (const goal of ModdableSDK.buildGoals) {
|
|
232
|
-
// eslint-disable-next-line no-await-in-loop
|
|
233
240
|
await make.run(
|
|
234
241
|
[
|
|
235
242
|
`MODDABLE=${ModdableSDK.MODDABLE}`,
|
|
@@ -244,21 +251,114 @@ async function main(args, { env, stdout, spawn, fs, os }) {
|
|
|
244
251
|
},
|
|
245
252
|
);
|
|
246
253
|
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @param {string[]} args
|
|
258
|
+
* @param {{
|
|
259
|
+
* env: Record<string, string | undefined>,
|
|
260
|
+
* stdout: typeof process.stdout,
|
|
261
|
+
* spawn: typeof import('child_process').spawn,
|
|
262
|
+
* fs: {
|
|
263
|
+
* existsSync: typeof import('fs').existsSync,
|
|
264
|
+
* rmdirSync: typeof import('fs').rmdirSync,
|
|
265
|
+
* readFile: typeof import('fs').promises.readFile,
|
|
266
|
+
* },
|
|
267
|
+
* os: {
|
|
268
|
+
* type: typeof import('os').type,
|
|
269
|
+
* }
|
|
270
|
+
* }} io
|
|
271
|
+
*/
|
|
272
|
+
async function main(args, { env, stdout, spawn, fs, os }) {
|
|
273
|
+
// I solemnly swear I will do no synchronous work followed by a variable
|
|
274
|
+
// number turns of the event loop.
|
|
275
|
+
await null;
|
|
276
|
+
|
|
277
|
+
const osType = os.type();
|
|
278
|
+
const platform = {
|
|
279
|
+
Linux: 'lin',
|
|
280
|
+
Darwin: 'mac',
|
|
281
|
+
// Windows_NT: 'win', // One can dream.
|
|
282
|
+
}[osType];
|
|
283
|
+
if (platform === undefined) {
|
|
284
|
+
throw Error(`xsnap does not support platform ${osType}`);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// If this is a working copy of xsnap in a checkout of agoric-sdk, we need to
|
|
288
|
+
// either clone or update submodules.
|
|
289
|
+
// Otherwise, we are running from an extracted npm tarball and we should not
|
|
290
|
+
// attempt to update Git submodules and should make the binary from the
|
|
291
|
+
// published source.
|
|
292
|
+
//
|
|
293
|
+
// These steps will avoid rebuilding native xsnap in the common case for end
|
|
294
|
+
// users.
|
|
295
|
+
//
|
|
296
|
+
// || | X || git
|
|
297
|
+
// || X | X || make
|
|
298
|
+
// || ---- | ---- || ----
|
|
299
|
+
// | bin | src | .git || pack | work ||
|
|
300
|
+
// | --- | --- | ---- || ---- | ---- ||
|
|
301
|
+
// | | | || | X ||
|
|
302
|
+
// | | | X || | ||
|
|
303
|
+
// | | X | || X | ||
|
|
304
|
+
// | | X | X || | X ||
|
|
305
|
+
// | X | | || | ||
|
|
306
|
+
// | X | | X || | ||
|
|
307
|
+
// | X | X | || X | ||
|
|
308
|
+
// | X | X | X || | X ||
|
|
309
|
+
//
|
|
310
|
+
// We build both release and debug, so checking for one should suffice.
|
|
311
|
+
// XXX This will need to account for the .exe extension if we recover support
|
|
312
|
+
// for Windows.
|
|
313
|
+
const hasBin = fs.existsSync(
|
|
314
|
+
asset(`../xsnap-native/xsnap/build/bin/${platform}/release/xsnap-worker`),
|
|
315
|
+
);
|
|
316
|
+
let hasSource = fs.existsSync(asset('../moddable/xs/includes/xs.h'));
|
|
317
|
+
const hasGit = fs.existsSync(asset('../moddable/.git'));
|
|
318
|
+
const isWorkingCopy = hasGit || (!hasSource && !hasBin);
|
|
319
|
+
const showEnv = args.includes('--show-env');
|
|
320
|
+
|
|
321
|
+
if (isWorkingCopy || showEnv) {
|
|
322
|
+
if (showEnv && !isWorkingCopy) {
|
|
323
|
+
throw new Error('XSnap requires a working copy and git to --show-env');
|
|
324
|
+
}
|
|
325
|
+
await updateSubmodules(showEnv, { env, stdout, spawn, fs });
|
|
326
|
+
hasSource = true;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (!showEnv) {
|
|
330
|
+
if (hasSource) {
|
|
331
|
+
await makeXsnap({ spawn, fs, os });
|
|
332
|
+
} else if (!hasBin) {
|
|
333
|
+
throw new Error(
|
|
334
|
+
'XSnap has neither sources nor a pre-built binary. Docker? .dockerignore? npm files?',
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
247
338
|
}
|
|
248
339
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
340
|
+
const run = () =>
|
|
341
|
+
main(process.argv.slice(2), {
|
|
342
|
+
env: { ...process.env },
|
|
343
|
+
stdout: process.stdout,
|
|
344
|
+
spawn: childProcessTop.spawn,
|
|
345
|
+
fs: {
|
|
346
|
+
readFile: fsTop.promises.readFile,
|
|
347
|
+
existsSync: fsTop.existsSync,
|
|
348
|
+
rmdirSync: fsTop.rmdirSync,
|
|
349
|
+
},
|
|
350
|
+
os: {
|
|
351
|
+
type: osTop.type,
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
process.exitCode = 1;
|
|
356
|
+
run().then(
|
|
357
|
+
() => {
|
|
358
|
+
process.exitCode = 0;
|
|
257
359
|
},
|
|
258
|
-
|
|
259
|
-
|
|
360
|
+
err => {
|
|
361
|
+
console.error('Failed with', err);
|
|
362
|
+
process.exit(process.exitCode || 1);
|
|
260
363
|
},
|
|
261
|
-
|
|
262
|
-
console.error(e);
|
|
263
|
-
process.exit(1);
|
|
264
|
-
});
|
|
364
|
+
);
|
package/src/replay.js
CHANGED
|
@@ -227,14 +227,12 @@ export async function replayXSnap(
|
|
|
227
227
|
const seq = parseInt(digits, 10);
|
|
228
228
|
console.log(folder, seq, kind);
|
|
229
229
|
if (running && !['command', 'reply'].includes(kind)) {
|
|
230
|
-
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
231
230
|
await running;
|
|
232
231
|
running = undefined;
|
|
233
232
|
}
|
|
234
233
|
const file = rd.file(step);
|
|
235
234
|
switch (kind) {
|
|
236
235
|
case 'isReady':
|
|
237
|
-
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
238
236
|
await it.isReady();
|
|
239
237
|
break;
|
|
240
238
|
case 'evaluate':
|
|
@@ -254,7 +252,6 @@ export async function replayXSnap(
|
|
|
254
252
|
console.log(folder, step, 'ignoring remaining steps from', folder);
|
|
255
253
|
return;
|
|
256
254
|
} else {
|
|
257
|
-
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
258
255
|
await (async () => {
|
|
259
256
|
const snapshotPath = file.getText();
|
|
260
257
|
const snapFile = await opts.fs.open(snapshotPath, 'w');
|