isomorfeus-asset-manager 0.15.11 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isomorfeus/asset_manager/version.rb +1 -1
- data/node_modules/.package-lock.json +3 -3
- data/node_modules/esbuild-wasm/bin/esbuild +0 -42
- data/node_modules/esbuild-wasm/esbuild.wasm +0 -0
- data/node_modules/esbuild-wasm/esm/browser.d.ts +2 -2
- data/node_modules/esbuild-wasm/esm/browser.js +62 -46
- data/node_modules/esbuild-wasm/esm/browser.min.js +13 -8
- data/node_modules/esbuild-wasm/lib/browser.d.ts +2 -2
- data/node_modules/esbuild-wasm/lib/browser.js +62 -46
- data/node_modules/esbuild-wasm/lib/browser.min.js +13 -8
- data/node_modules/esbuild-wasm/lib/main.d.ts +2 -2
- data/node_modules/esbuild-wasm/lib/main.js +64 -48
- data/node_modules/esbuild-wasm/package.json +1 -1
- data/package.json +1 -1
- metadata +2 -3
- data/node_modules/esbuild-wasm/exit0.js +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4337a781d2f019e0d42084d7d9fc9a2eb06dc4a617739c72a04865007c0ea20
|
4
|
+
data.tar.gz: 6d6d1985ec536dc59dad847ab5c3357cb2f440f0bd3658d7eb13a0c253a0ae73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38656c3e97791cc192efd8ab91f9ffef7d6c65e60b62ad80da79327933bfbea66e0ca3b46a89d17e4d6db5132818b2c24f0db86e9db3982a4d3c8d8a33cfe8ba
|
7
|
+
data.tar.gz: 902b2896a302ca4d236080362030a7b5b389385d7a3d1d3d0353023bb1ddc1edd21a6b5f9f6a3cfb3351bfe3d8b7db9e41d90d4c36c3ea93a35549783ab76f8b
|
@@ -4,9 +4,9 @@
|
|
4
4
|
"requires": true,
|
5
5
|
"packages": {
|
6
6
|
"node_modules/esbuild-wasm": {
|
7
|
-
"version": "0.
|
8
|
-
"resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.
|
9
|
-
"integrity": "sha512-
|
7
|
+
"version": "0.16.3",
|
8
|
+
"resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.16.3.tgz",
|
9
|
+
"integrity": "sha512-rLDIM64R9Pc3hKAxQbFSsXdBIkquZN0w29od5/sSaQs2F8gnnRupu02XN6y/+d/odDuquwy6Dy3J+Prr8IhUaQ==",
|
10
10
|
"bin": {
|
11
11
|
"esbuild": "bin/esbuild"
|
12
12
|
},
|
@@ -3,11 +3,8 @@
|
|
3
3
|
// Forward to the automatically-generated WebAssembly loader from the Go compiler
|
4
4
|
|
5
5
|
const module_ = require('module');
|
6
|
-
const crypto = require('crypto');
|
7
6
|
const path = require('path');
|
8
|
-
const zlib = require('zlib');
|
9
7
|
const fs = require('fs');
|
10
|
-
const os = require('os');
|
11
8
|
|
12
9
|
const wasm_exec_node = path.join(__dirname, '..', 'wasm_exec_node.js');
|
13
10
|
const esbuild_wasm = path.join(__dirname, '..', 'esbuild.wasm');
|
@@ -23,45 +20,6 @@ function instantiate(bytes, importObject) {
|
|
23
20
|
return Promise.resolve({ instance, module });
|
24
21
|
}
|
25
22
|
|
26
|
-
// Node has an unfortunate bug where the node process is unnecessarily kept open while a
|
27
|
-
// WebAssembly module is being optimized: https://github.com/nodejs/node/issues/36616.
|
28
|
-
// This means cases where running "esbuild" should take a few milliseconds can end up
|
29
|
-
// taking many seconds instead. To work around this bug, it is possible to force node to
|
30
|
-
// exit by calling the operating system's exit function. That's what this code does.
|
31
|
-
process.on('exit', code => {
|
32
|
-
// If it's a non-zero exit code, we can just kill our own process to stop. This will
|
33
|
-
// preserve the fact that there is a non-zero exit code although the exit code will
|
34
|
-
// be different. We cannot use this if the exit code is supposed to be zero.
|
35
|
-
if (code !== 0) {
|
36
|
-
try {
|
37
|
-
process.kill(process.pid, 'SIGINT');
|
38
|
-
} catch (e) {
|
39
|
-
}
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
|
43
|
-
// Otherwise if the exit code is zero, try to fall back to a binary N-API module that
|
44
|
-
// calls the operating system's "exit(0)" function.
|
45
|
-
const nativeModule = `${process.platform}-${os.arch()}-${os.endianness()}.node`;
|
46
|
-
const base64 = require('../exit0')[nativeModule];
|
47
|
-
if (base64) {
|
48
|
-
try {
|
49
|
-
const data = zlib.inflateRawSync(Buffer.from(base64, 'base64'));
|
50
|
-
const hash = crypto.createHash('sha256').update(base64).digest().toString('hex').slice(0, 16);
|
51
|
-
const tempFile = path.join(os.tmpdir(), `${hash}-${nativeModule}`);
|
52
|
-
try {
|
53
|
-
if (fs.readFileSync(tempFile).equals(data)) {
|
54
|
-
require(tempFile);
|
55
|
-
}
|
56
|
-
} finally {
|
57
|
-
fs.writeFileSync(tempFile, data);
|
58
|
-
require(tempFile);
|
59
|
-
}
|
60
|
-
} catch (e) {
|
61
|
-
}
|
62
|
-
}
|
63
|
-
});
|
64
|
-
|
65
23
|
// Node has another bug where using "fs.read" to read from stdin reads
|
66
24
|
// everything successfully and then throws an error, but only on Windows. Go's
|
67
25
|
// WebAssembly support uses "fs.read" so it hits this problem. This is a patch
|
Binary file
|
@@ -193,8 +193,8 @@ export interface OutputFile {
|
|
193
193
|
path: string;
|
194
194
|
/** "text" as bytes */
|
195
195
|
contents: Uint8Array;
|
196
|
-
/** "contents" as text */
|
197
|
-
text: string;
|
196
|
+
/** "contents" as text (changes automatically with "contents") */
|
197
|
+
get text(): string;
|
198
198
|
}
|
199
199
|
|
200
200
|
export interface BuildInvalidate {
|
@@ -155,26 +155,30 @@ var ByteBuffer = class {
|
|
155
155
|
};
|
156
156
|
var encodeUTF8;
|
157
157
|
var decodeUTF8;
|
158
|
+
var encodeInvariant;
|
158
159
|
if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
|
159
160
|
let encoder = new TextEncoder();
|
160
161
|
let decoder = new TextDecoder();
|
161
162
|
encodeUTF8 = (text) => encoder.encode(text);
|
162
163
|
decodeUTF8 = (bytes) => decoder.decode(bytes);
|
164
|
+
encodeInvariant = 'new TextEncoder().encode("")';
|
163
165
|
} else if (typeof Buffer !== "undefined") {
|
164
|
-
encodeUTF8 = (text) =>
|
165
|
-
let buffer = Buffer.from(text);
|
166
|
-
if (!(buffer instanceof Uint8Array)) {
|
167
|
-
buffer = new Uint8Array(buffer);
|
168
|
-
}
|
169
|
-
return buffer;
|
170
|
-
};
|
166
|
+
encodeUTF8 = (text) => Buffer.from(text);
|
171
167
|
decodeUTF8 = (bytes) => {
|
172
168
|
let { buffer, byteOffset, byteLength } = bytes;
|
173
169
|
return Buffer.from(buffer, byteOffset, byteLength).toString();
|
174
170
|
};
|
171
|
+
encodeInvariant = 'Buffer.from("")';
|
175
172
|
} else {
|
176
173
|
throw new Error("No UTF-8 codec found");
|
177
174
|
}
|
175
|
+
if (!(encodeUTF8("") instanceof Uint8Array))
|
176
|
+
throw new Error(`Invariant violation: "${encodeInvariant} instanceof Uint8Array" is incorrectly false
|
177
|
+
|
178
|
+
This indicates that your JavaScript environment is broken. You cannot use
|
179
|
+
esbuild in this environment because esbuild relies on this invariant. This
|
180
|
+
is not a problem with esbuild. You need to fix your environment instead.
|
181
|
+
`);
|
178
182
|
function readUInt32LE(buffer, offset) {
|
179
183
|
return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;
|
180
184
|
}
|
@@ -186,10 +190,11 @@ function writeUInt32LE(buffer, value, offset) {
|
|
186
190
|
}
|
187
191
|
|
188
192
|
// lib/shared/common.ts
|
193
|
+
var quote = JSON.stringify;
|
189
194
|
var buildLogLevelDefault = "warning";
|
190
195
|
var transformLogLevelDefault = "silent";
|
191
196
|
function validateTarget(target) {
|
192
|
-
target
|
197
|
+
validateStringValue(target, "target");
|
193
198
|
if (target.indexOf(",") >= 0)
|
194
199
|
throw new Error(`Invalid target: ${target}`);
|
195
200
|
return target;
|
@@ -218,13 +223,13 @@ function getFlag(object, keys, key, mustBeFn) {
|
|
218
223
|
return void 0;
|
219
224
|
let mustBe = mustBeFn(value);
|
220
225
|
if (mustBe !== null)
|
221
|
-
throw new Error(
|
226
|
+
throw new Error(`${quote(key)} must be ${mustBe}`);
|
222
227
|
return value;
|
223
228
|
}
|
224
229
|
function checkForInvalidFlags(object, keys, where) {
|
225
230
|
for (let key in object) {
|
226
231
|
if (!(key in keys)) {
|
227
|
-
throw new Error(`Invalid option ${where}:
|
232
|
+
throw new Error(`Invalid option ${where}: ${quote(key)}`);
|
228
233
|
}
|
229
234
|
}
|
230
235
|
}
|
@@ -244,12 +249,12 @@ function validateMangleCache(mangleCache) {
|
|
244
249
|
let validated;
|
245
250
|
if (mangleCache !== void 0) {
|
246
251
|
validated = /* @__PURE__ */ Object.create(null);
|
247
|
-
for (let key
|
252
|
+
for (let key in mangleCache) {
|
248
253
|
let value = mangleCache[key];
|
249
254
|
if (typeof value === "string" || value === false) {
|
250
255
|
validated[key] = value;
|
251
256
|
} else {
|
252
|
-
throw new Error(`Expected ${
|
257
|
+
throw new Error(`Expected ${quote(key)} in mangle cache to map to either a string or false`);
|
253
258
|
}
|
254
259
|
}
|
255
260
|
}
|
@@ -266,6 +271,12 @@ function pushLogFlags(flags, options, keys, isTTY, logLevelDefault) {
|
|
266
271
|
flags.push(`--log-level=${logLevel || logLevelDefault}`);
|
267
272
|
flags.push(`--log-limit=${logLimit || 0}`);
|
268
273
|
}
|
274
|
+
function validateStringValue(value, what, key) {
|
275
|
+
if (typeof value !== "string") {
|
276
|
+
throw new Error(`Expected value for ${what}${key !== void 0 ? " " + quote(key) : ""} to be a string, got ${typeof value} instead`);
|
277
|
+
}
|
278
|
+
return value;
|
279
|
+
}
|
269
280
|
function pushCommonFlags(flags, options, keys) {
|
270
281
|
let legalComments = getFlag(options, keys, "legalComments", mustBeString);
|
271
282
|
let sourceRoot = getFlag(options, keys, "sourceRoot", mustBeString);
|
@@ -330,7 +341,7 @@ function pushCommonFlags(flags, options, keys) {
|
|
330
341
|
flags.push(`--ignore-annotations`);
|
331
342
|
if (drop)
|
332
343
|
for (let what of drop)
|
333
|
-
flags.push(`--drop:${what}`);
|
344
|
+
flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
334
345
|
if (mangleProps)
|
335
346
|
flags.push(`--mangle-props=${mangleProps.source}`);
|
336
347
|
if (reserveProps)
|
@@ -353,26 +364,29 @@ function pushCommonFlags(flags, options, keys) {
|
|
353
364
|
for (let key in define) {
|
354
365
|
if (key.indexOf("=") >= 0)
|
355
366
|
throw new Error(`Invalid define: ${key}`);
|
356
|
-
flags.push(`--define:${key}=${define[key]}`);
|
367
|
+
flags.push(`--define:${key}=${validateStringValue(define[key], "define", key)}`);
|
357
368
|
}
|
358
369
|
}
|
359
370
|
if (logOverride) {
|
360
371
|
for (let key in logOverride) {
|
361
372
|
if (key.indexOf("=") >= 0)
|
362
373
|
throw new Error(`Invalid log override: ${key}`);
|
363
|
-
flags.push(`--log-override:${key}=${logOverride[key]}`);
|
374
|
+
flags.push(`--log-override:${key}=${validateStringValue(logOverride[key], "log override", key)}`);
|
364
375
|
}
|
365
376
|
}
|
366
377
|
if (supported) {
|
367
378
|
for (let key in supported) {
|
368
379
|
if (key.indexOf("=") >= 0)
|
369
380
|
throw new Error(`Invalid supported: ${key}`);
|
370
|
-
|
381
|
+
const value = supported[key];
|
382
|
+
if (typeof value !== "boolean")
|
383
|
+
throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value} instead`);
|
384
|
+
flags.push(`--supported:${key}=${value}`);
|
371
385
|
}
|
372
386
|
}
|
373
387
|
if (pure)
|
374
388
|
for (let fn of pure)
|
375
|
-
flags.push(`--pure:${fn}`);
|
389
|
+
flags.push(`--pure:${validateStringValue(fn, "pure")}`);
|
376
390
|
if (keepNames)
|
377
391
|
flags.push(`--keep-names`);
|
378
392
|
}
|
@@ -454,7 +468,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
454
468
|
if (resolveExtensions) {
|
455
469
|
let values = [];
|
456
470
|
for (let value of resolveExtensions) {
|
457
|
-
value
|
471
|
+
validateStringValue(value, "resolve extension");
|
458
472
|
if (value.indexOf(",") >= 0)
|
459
473
|
throw new Error(`Invalid resolve extension: ${value}`);
|
460
474
|
values.push(value);
|
@@ -472,7 +486,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
472
486
|
if (mainFields) {
|
473
487
|
let values = [];
|
474
488
|
for (let value of mainFields) {
|
475
|
-
value
|
489
|
+
validateStringValue(value, "main field");
|
476
490
|
if (value.indexOf(",") >= 0)
|
477
491
|
throw new Error(`Invalid main field: ${value}`);
|
478
492
|
values.push(value);
|
@@ -482,7 +496,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
482
496
|
if (conditions) {
|
483
497
|
let values = [];
|
484
498
|
for (let value of conditions) {
|
485
|
-
value
|
499
|
+
validateStringValue(value, "condition");
|
486
500
|
if (value.indexOf(",") >= 0)
|
487
501
|
throw new Error(`Invalid condition: ${value}`);
|
488
502
|
values.push(value);
|
@@ -491,53 +505,53 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
491
505
|
}
|
492
506
|
if (external)
|
493
507
|
for (let name of external)
|
494
|
-
flags.push(`--external:${name}`);
|
508
|
+
flags.push(`--external:${validateStringValue(name, "external")}`);
|
495
509
|
if (alias) {
|
496
510
|
for (let old in alias) {
|
497
511
|
if (old.indexOf("=") >= 0)
|
498
512
|
throw new Error(`Invalid package name in alias: ${old}`);
|
499
|
-
flags.push(`--alias:${old}=${alias[old]}`);
|
513
|
+
flags.push(`--alias:${old}=${validateStringValue(alias[old], "alias", old)}`);
|
500
514
|
}
|
501
515
|
}
|
502
516
|
if (banner) {
|
503
517
|
for (let type in banner) {
|
504
518
|
if (type.indexOf("=") >= 0)
|
505
519
|
throw new Error(`Invalid banner file type: ${type}`);
|
506
|
-
flags.push(`--banner:${type}=${banner[type]}`);
|
520
|
+
flags.push(`--banner:${type}=${validateStringValue(banner[type], "banner", type)}`);
|
507
521
|
}
|
508
522
|
}
|
509
523
|
if (footer) {
|
510
524
|
for (let type in footer) {
|
511
525
|
if (type.indexOf("=") >= 0)
|
512
526
|
throw new Error(`Invalid footer file type: ${type}`);
|
513
|
-
flags.push(`--footer:${type}=${footer[type]}`);
|
527
|
+
flags.push(`--footer:${type}=${validateStringValue(footer[type], "footer", type)}`);
|
514
528
|
}
|
515
529
|
}
|
516
530
|
if (inject)
|
517
531
|
for (let path of inject)
|
518
|
-
flags.push(`--inject:${path}`);
|
532
|
+
flags.push(`--inject:${validateStringValue(path, "inject")}`);
|
519
533
|
if (loader) {
|
520
534
|
for (let ext in loader) {
|
521
535
|
if (ext.indexOf("=") >= 0)
|
522
536
|
throw new Error(`Invalid loader extension: ${ext}`);
|
523
|
-
flags.push(`--loader:${ext}=${loader[ext]}`);
|
537
|
+
flags.push(`--loader:${ext}=${validateStringValue(loader[ext], "loader", ext)}`);
|
524
538
|
}
|
525
539
|
}
|
526
540
|
if (outExtension) {
|
527
541
|
for (let ext in outExtension) {
|
528
542
|
if (ext.indexOf("=") >= 0)
|
529
543
|
throw new Error(`Invalid out extension: ${ext}`);
|
530
|
-
flags.push(`--out-extension:${ext}=${outExtension[ext]}`);
|
544
|
+
flags.push(`--out-extension:${ext}=${validateStringValue(outExtension[ext], "out extension", ext)}`);
|
531
545
|
}
|
532
546
|
}
|
533
547
|
if (entryPoints) {
|
534
548
|
if (Array.isArray(entryPoints)) {
|
535
549
|
for (let entryPoint of entryPoints) {
|
536
|
-
entries.push(["", entryPoint
|
550
|
+
entries.push(["", validateStringValue(entryPoint, "entry point")]);
|
537
551
|
}
|
538
552
|
} else {
|
539
|
-
for (let
|
540
|
-
entries.push([key
|
553
|
+
for (let key in entryPoints) {
|
554
|
+
entries.push([key, validateStringValue(entryPoints[key], "entry point", key)]);
|
541
555
|
}
|
542
556
|
}
|
543
557
|
}
|
@@ -553,7 +567,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
553
567
|
if (loader2)
|
554
568
|
flags.push(`--loader=${loader2}`);
|
555
569
|
if (resolveDir)
|
556
|
-
stdinResolveDir = resolveDir
|
570
|
+
stdinResolveDir = resolveDir;
|
557
571
|
if (typeof contents === "string")
|
558
572
|
stdinContents = encodeUTF8(contents);
|
559
573
|
else if (contents instanceof Uint8Array)
|
@@ -698,8 +712,8 @@ function createChannel(streamIn) {
|
|
698
712
|
if (isFirstPacket) {
|
699
713
|
isFirstPacket = false;
|
700
714
|
let binaryVersion = String.fromCharCode(...bytes);
|
701
|
-
if (binaryVersion !== "0.
|
702
|
-
throw new Error(`Cannot start service: Host version "${"0.
|
715
|
+
if (binaryVersion !== "0.16.3") {
|
716
|
+
throw new Error(`Cannot start service: Host version "${"0.16.3"}" does not match binary version ${quote(binaryVersion)}`);
|
703
717
|
}
|
704
718
|
return;
|
705
719
|
}
|
@@ -1181,7 +1195,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1181
1195
|
let setup = getFlag(item, keys, "setup", mustBeFunction);
|
1182
1196
|
if (typeof setup !== "function")
|
1183
1197
|
throw new Error(`Plugin is missing a setup function`);
|
1184
|
-
checkForInvalidFlags(item, keys, `on plugin ${
|
1198
|
+
checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);
|
1185
1199
|
let plugin = {
|
1186
1200
|
name,
|
1187
1201
|
onResolve: [],
|
@@ -1218,6 +1232,8 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1218
1232
|
request.resolveDir = resolveDir;
|
1219
1233
|
if (kind != null)
|
1220
1234
|
request.kind = kind;
|
1235
|
+
else
|
1236
|
+
throw new Error(`Must specify "kind" when calling "resolve"`);
|
1221
1237
|
if (pluginData != null)
|
1222
1238
|
request.pluginData = details.store(pluginData);
|
1223
1239
|
sendRequest(refs, request, (error, response) => {
|
@@ -1256,7 +1272,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1256
1272
|
let keys2 = {};
|
1257
1273
|
let filter = getFlag(options, keys2, "filter", mustBeRegExp);
|
1258
1274
|
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
1259
|
-
checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${
|
1275
|
+
checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${quote(name)}`);
|
1260
1276
|
if (filter == null)
|
1261
1277
|
throw new Error(`onResolve() call is missing a filter`);
|
1262
1278
|
let id = nextCallbackID++;
|
@@ -1269,7 +1285,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1269
1285
|
let keys2 = {};
|
1270
1286
|
let filter = getFlag(options, keys2, "filter", mustBeRegExp);
|
1271
1287
|
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
1272
|
-
checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${
|
1288
|
+
checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${quote(name)}`);
|
1273
1289
|
if (filter == null)
|
1274
1290
|
throw new Error(`onLoad() call is missing a filter`);
|
1275
1291
|
let id = nextCallbackID++;
|
@@ -1292,11 +1308,11 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1292
1308
|
let result = await callback();
|
1293
1309
|
if (result != null) {
|
1294
1310
|
if (typeof result !== "object")
|
1295
|
-
throw new Error(`Expected onStart() callback in plugin ${
|
1311
|
+
throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);
|
1296
1312
|
let keys = {};
|
1297
1313
|
let errors = getFlag(result, keys, "errors", mustBeArray);
|
1298
1314
|
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
1299
|
-
checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${
|
1315
|
+
checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote(name)}`);
|
1300
1316
|
if (errors != null)
|
1301
1317
|
response.errors.push(...sanitizeMessages(errors, "errors", details, name));
|
1302
1318
|
if (warnings != null)
|
@@ -1323,7 +1339,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1323
1339
|
});
|
1324
1340
|
if (result != null) {
|
1325
1341
|
if (typeof result !== "object")
|
1326
|
-
throw new Error(`Expected onResolve() callback in plugin ${
|
1342
|
+
throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
1327
1343
|
let keys = {};
|
1328
1344
|
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
1329
1345
|
let path = getFlag(result, keys, "path", mustBeString);
|
@@ -1336,7 +1352,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1336
1352
|
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
1337
1353
|
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
1338
1354
|
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
1339
|
-
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${
|
1355
|
+
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote(name)}`);
|
1340
1356
|
response.id = id2;
|
1341
1357
|
if (pluginName != null)
|
1342
1358
|
response.pluginName = pluginName;
|
@@ -1382,7 +1398,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1382
1398
|
});
|
1383
1399
|
if (result != null) {
|
1384
1400
|
if (typeof result !== "object")
|
1385
|
-
throw new Error(`Expected onLoad() callback in plugin ${
|
1401
|
+
throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);
|
1386
1402
|
let keys = {};
|
1387
1403
|
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
1388
1404
|
let contents = getFlag(result, keys, "contents", mustBeStringOrUint8Array);
|
@@ -1393,7 +1409,7 @@ var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn,
|
|
1393
1409
|
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
1394
1410
|
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
1395
1411
|
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
1396
|
-
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${
|
1412
|
+
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote(name)}`);
|
1397
1413
|
response.id = id2;
|
1398
1414
|
if (pluginName != null)
|
1399
1415
|
response.pluginName = pluginName;
|
@@ -1627,7 +1643,7 @@ function sanitizeStringArray(values, property) {
|
|
1627
1643
|
const result = [];
|
1628
1644
|
for (const value of values) {
|
1629
1645
|
if (typeof value !== "string")
|
1630
|
-
throw new Error(`${
|
1646
|
+
throw new Error(`${quote(property)} must be an array of strings`);
|
1631
1647
|
result.push(value);
|
1632
1648
|
}
|
1633
1649
|
return result;
|
@@ -1649,7 +1665,7 @@ function convertOutputFiles({ path, contents }) {
|
|
1649
1665
|
}
|
1650
1666
|
|
1651
1667
|
// lib/npm/browser.ts
|
1652
|
-
var version = "0.
|
1668
|
+
var version = "0.16.3";
|
1653
1669
|
var build = (options) => ensureServiceIsRunning().build(options);
|
1654
1670
|
var serve = () => {
|
1655
1671
|
throw new Error(`The "serve" API only works in node`);
|
@@ -1696,7 +1712,7 @@ var initialize = (options) => {
|
|
1696
1712
|
var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
1697
1713
|
let worker;
|
1698
1714
|
if (useWorker) {
|
1699
|
-
let blob = new Blob([`onmessage=${'((postMessage) => {\n // Copyright 2018 The Go Authors. All rights reserved.\n // Use of this source code is governed by a BSD-style\n // license that can be found in the LICENSE file.\n let onmessage;\n let globalThis = {};\n for (let o = self; o; o = Object.getPrototypeOf(o))\n for (let k of Object.getOwnPropertyNames(o))\n if (!(k in globalThis))\n Object.defineProperty(globalThis, k, { get: () => self[k] });\n "use strict";\n (() => {\n const enosys = () => {\n const err = new Error("not implemented");\n err.code = "ENOSYS";\n return err;\n };\n if (!globalThis.fs) {\n let outputBuf = "";\n globalThis.fs = {\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\n writeSync(fd, buf) {\n outputBuf += decoder.decode(buf);\n const nl = outputBuf.lastIndexOf("\\n");\n if (nl != -1) {\n console.log(outputBuf.substr(0, nl));\n outputBuf = outputBuf.substr(nl + 1);\n }\n return buf.length;\n },\n write(fd, buf, offset, length, position, callback) {\n if (offset !== 0 || length !== buf.length || position !== null) {\n callback(enosys());\n return;\n }\n const n = this.writeSync(fd, buf);\n callback(null, n);\n },\n chmod(path, mode, callback) {\n callback(enosys());\n },\n chown(path, uid, gid, callback) {\n callback(enosys());\n },\n close(fd, callback) {\n callback(enosys());\n },\n fchmod(fd, mode, callback) {\n callback(enosys());\n },\n fchown(fd, uid, gid, callback) {\n callback(enosys());\n },\n fstat(fd, callback) {\n callback(enosys());\n },\n fsync(fd, callback) {\n callback(null);\n },\n ftruncate(fd, length, callback) {\n callback(enosys());\n },\n lchown(path, uid, gid, callback) {\n callback(enosys());\n },\n link(path, link, callback) {\n callback(enosys());\n },\n lstat(path, callback) {\n callback(enosys());\n },\n mkdir(path, perm, callback) {\n callback(enosys());\n },\n open(path, flags, mode, callback) {\n callback(enosys());\n },\n read(fd, buffer, offset, length, position, callback) {\n callback(enosys());\n },\n readdir(path, callback) {\n callback(enosys());\n },\n readlink(path, callback) {\n callback(enosys());\n },\n rename(from, to, callback) {\n callback(enosys());\n },\n rmdir(path, callback) {\n callback(enosys());\n },\n stat(path, callback) {\n callback(enosys());\n },\n symlink(path, link, callback) {\n callback(enosys());\n },\n truncate(path, length, callback) {\n callback(enosys());\n },\n unlink(path, callback) {\n callback(enosys());\n },\n utimes(path, atime, mtime, callback) {\n callback(enosys());\n }\n };\n }\n if (!globalThis.process) {\n globalThis.process = {\n getuid() {\n return -1;\n },\n getgid() {\n return -1;\n },\n geteuid() {\n return -1;\n },\n getegid() {\n return -1;\n },\n getgroups() {\n throw enosys();\n },\n pid: -1,\n ppid: -1,\n umask() {\n throw enosys();\n },\n cwd() {\n throw enosys();\n },\n chdir() {\n throw enosys();\n }\n };\n }\n if (!globalThis.crypto) {\n throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");\n }\n if (!globalThis.performance) {\n throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");\n }\n if (!globalThis.TextEncoder) {\n throw new Error("globalThis.TextEncoder is not available, polyfill required");\n }\n if (!globalThis.TextDecoder) {\n throw new Error("globalThis.TextDecoder is not available, polyfill required");\n }\n const encoder = new TextEncoder("utf-8");\n const decoder = new TextDecoder("utf-8");\n globalThis.Go = class {\n constructor() {\n this.argv = ["js"];\n this.env = {};\n this.exit = (code) => {\n if (code !== 0) {\n console.warn("exit code:", code);\n }\n };\n this._exitPromise = new Promise((resolve) => {\n this._resolveExitPromise = resolve;\n });\n this._pendingEvent = null;\n this._scheduledTimeouts = /* @__PURE__ */ new Map();\n this._nextCallbackTimeoutID = 1;\n const setInt64 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, true);\n this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);\n };\n const getInt64 = (addr) => {\n const low = this.mem.getUint32(addr + 0, true);\n const high = this.mem.getInt32(addr + 4, true);\n return low + high * 4294967296;\n };\n const loadValue = (addr) => {\n const f = this.mem.getFloat64(addr, true);\n if (f === 0) {\n return void 0;\n }\n if (!isNaN(f)) {\n return f;\n }\n const id = this.mem.getUint32(addr, true);\n return this._values[id];\n };\n const storeValue = (addr, v) => {\n const nanHead = 2146959360;\n if (typeof v === "number" && v !== 0) {\n if (isNaN(v)) {\n this.mem.setUint32(addr + 4, nanHead, true);\n this.mem.setUint32(addr, 0, true);\n return;\n }\n this.mem.setFloat64(addr, v, true);\n return;\n }\n if (v === void 0) {\n this.mem.setFloat64(addr, 0, true);\n return;\n }\n let id = this._ids.get(v);\n if (id === void 0) {\n id = this._idPool.pop();\n if (id === void 0) {\n id = this._values.length;\n }\n this._values[id] = v;\n this._goRefCounts[id] = 0;\n this._ids.set(v, id);\n }\n this._goRefCounts[id]++;\n let typeFlag = 0;\n switch (typeof v) {\n case "object":\n if (v !== null) {\n typeFlag = 1;\n }\n break;\n case "string":\n typeFlag = 2;\n break;\n case "symbol":\n typeFlag = 3;\n break;\n case "function":\n typeFlag = 4;\n break;\n }\n this.mem.setUint32(addr + 4, nanHead | typeFlag, true);\n this.mem.setUint32(addr, id, true);\n };\n const loadSlice = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return new Uint8Array(this._inst.exports.mem.buffer, array, len);\n };\n const loadSliceOfValues = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n const a = new Array(len);\n for (let i = 0; i < len; i++) {\n a[i] = loadValue(array + i * 8);\n }\n return a;\n };\n const loadString = (addr) => {\n const saddr = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));\n };\n const timeOrigin = Date.now() - performance.now();\n this.importObject = {\n go: {\n "runtime.wasmExit": (sp) => {\n sp >>>= 0;\n const code = this.mem.getInt32(sp + 8, true);\n this.exited = true;\n delete this._inst;\n delete this._values;\n delete this._goRefCounts;\n delete this._ids;\n delete this._idPool;\n this.exit(code);\n },\n "runtime.wasmWrite": (sp) => {\n sp >>>= 0;\n const fd = getInt64(sp + 8);\n const p = getInt64(sp + 16);\n const n = this.mem.getInt32(sp + 24, true);\n globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));\n },\n "runtime.resetMemoryDataView": (sp) => {\n sp >>>= 0;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n "runtime.nanotime1": (sp) => {\n sp >>>= 0;\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n "runtime.walltime": (sp) => {\n sp >>>= 0;\n const msec = new Date().getTime();\n setInt64(sp + 8, msec / 1e3);\n this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);\n },\n "runtime.scheduleTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this._nextCallbackTimeoutID;\n this._nextCallbackTimeoutID++;\n this._scheduledTimeouts.set(id, setTimeout(\n () => {\n this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn("scheduleTimeoutEvent: missed timeout event");\n this._resume();\n }\n },\n getInt64(sp + 8) + 1\n ));\n this.mem.setInt32(sp + 16, id, true);\n },\n "runtime.clearTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this.mem.getInt32(sp + 8, true);\n clearTimeout(this._scheduledTimeouts.get(id));\n this._scheduledTimeouts.delete(id);\n },\n "runtime.getRandomData": (sp) => {\n sp >>>= 0;\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n "syscall/js.finalizeRef": (sp) => {\n sp >>>= 0;\n const id = this.mem.getUint32(sp + 8, true);\n this._goRefCounts[id]--;\n if (this._goRefCounts[id] === 0) {\n const v = this._values[id];\n this._values[id] = null;\n this._ids.delete(v);\n this._idPool.push(id);\n }\n },\n "syscall/js.stringVal": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, loadString(sp + 8));\n },\n "syscall/js.valueGet": (sp) => {\n sp >>>= 0;\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 32, result);\n },\n "syscall/js.valueSet": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\n },\n "syscall/js.valueDelete": (sp) => {\n sp >>>= 0;\n Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\n },\n "syscall/js.valueIndex": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\n },\n "syscall/js.valueSetIndex": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\n },\n "syscall/js.valueCall": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const m = Reflect.get(v, loadString(sp + 16));\n const args = loadSliceOfValues(sp + 32);\n const result = Reflect.apply(m, v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, result);\n this.mem.setUint8(sp + 64, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, err);\n this.mem.setUint8(sp + 64, 0);\n }\n },\n "syscall/js.valueInvoke": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.apply(v, void 0, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n "syscall/js.valueNew": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.construct(v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n "syscall/js.valueLength": (sp) => {\n sp >>>= 0;\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n "syscall/js.valuePrepareString": (sp) => {\n sp >>>= 0;\n const str = encoder.encode(String(loadValue(sp + 8)));\n storeValue(sp + 16, str);\n setInt64(sp + 24, str.length);\n },\n "syscall/js.valueLoadString": (sp) => {\n sp >>>= 0;\n const str = loadValue(sp + 8);\n loadSlice(sp + 16).set(str);\n },\n "syscall/js.valueInstanceOf": (sp) => {\n sp >>>= 0;\n this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);\n },\n "syscall/js.copyBytesToGo": (sp) => {\n sp >>>= 0;\n const dst = loadSlice(sp + 8);\n const src = loadValue(sp + 32);\n if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n "syscall/js.copyBytesToJS": (sp) => {\n sp >>>= 0;\n const dst = loadValue(sp + 8);\n const src = loadSlice(sp + 16);\n if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n "debug": (value) => {\n console.log(value);\n }\n }\n };\n }\n async run(instance) {\n if (!(instance instanceof WebAssembly.Instance)) {\n throw new Error("Go.run: WebAssembly.Instance expected");\n }\n this._inst = instance;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n this._values = [\n NaN,\n 0,\n null,\n true,\n false,\n globalThis,\n this\n ];\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\n this._ids = /* @__PURE__ */ new Map([\n [0, 1],\n [null, 2],\n [true, 3],\n [false, 4],\n [globalThis, 5],\n [this, 6]\n ]);\n this._idPool = [];\n this.exited = false;\n let offset = 4096;\n const strPtr = (str) => {\n const ptr = offset;\n const bytes = encoder.encode(str + "\\0");\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n offset += bytes.length;\n if (offset % 8 !== 0) {\n offset += 8 - offset % 8;\n }\n return ptr;\n };\n const argc = this.argv.length;\n const argvPtrs = [];\n this.argv.forEach((arg) => {\n argvPtrs.push(strPtr(arg));\n });\n argvPtrs.push(0);\n const keys = Object.keys(this.env).sort();\n keys.forEach((key) => {\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n });\n argvPtrs.push(0);\n const argv = offset;\n argvPtrs.forEach((ptr) => {\n this.mem.setUint32(offset, ptr, true);\n this.mem.setUint32(offset + 4, 0, true);\n offset += 8;\n });\n const wasmMinDataAddr = 4096 + 8192;\n if (offset >= wasmMinDataAddr) {\n throw new Error("total length of command line and environment variables exceeds limit");\n }\n this._inst.exports.run(argc, argv);\n if (this.exited) {\n this._resolveExitPromise();\n }\n await this._exitPromise;\n }\n _resume() {\n if (this.exited) {\n throw new Error("Go program has already exited");\n }\n this._inst.exports.resume();\n if (this.exited) {\n this._resolveExitPromise();\n }\n }\n _makeFuncWrapper(id) {\n const go = this;\n return function() {\n const event = { id, this: this, args: arguments };\n go._pendingEvent = event;\n go._resume();\n return event.result;\n };\n }\n };\n })();\n onmessage = ({ data: wasm }) => {\n let decoder = new TextDecoder();\n let fs = globalThis.fs;\n let stderr = "";\n fs.writeSync = (fd, buffer) => {\n if (fd === 1) {\n postMessage(buffer);\n } else if (fd === 2) {\n stderr += decoder.decode(buffer);\n let parts = stderr.split("\\n");\n if (parts.length > 1)\n console.log(parts.slice(0, -1).join("\\n"));\n stderr = parts[parts.length - 1];\n } else {\n throw new Error("Bad write");\n }\n return buffer.length;\n };\n let stdin = [];\n let resumeStdin;\n let stdinPos = 0;\n onmessage = ({ data }) => {\n if (data.length > 0) {\n stdin.push(data);\n if (resumeStdin)\n resumeStdin();\n }\n };\n fs.read = (fd, buffer, offset, length, position, callback) => {\n if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {\n throw new Error("Bad read");\n }\n if (stdin.length === 0) {\n resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);\n return;\n }\n let first = stdin[0];\n let count = Math.max(0, Math.min(length, first.length - stdinPos));\n buffer.set(first.subarray(stdinPos, stdinPos + count), offset);\n stdinPos += count;\n if (stdinPos === first.length) {\n stdin.shift();\n stdinPos = 0;\n }\n callback(null, count);\n };\n let go = new globalThis.Go();\n go.argv = ["", `--service=${"0.15.18"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n };\n async function tryToInstantiateModule(wasm, go) {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = await fetch(wasm);\n if (!res.ok)\n throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if ("instantiateStreaming" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get("Content-Type") || "")) {\n const result2 = await WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = await res.arrayBuffer();\n const result = await WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1715
|
+
let blob = new Blob([`onmessage=${'((postMessage) => {\n // Copyright 2018 The Go Authors. All rights reserved.\n // Use of this source code is governed by a BSD-style\n // license that can be found in the LICENSE file.\n let onmessage;\n let globalThis = {};\n for (let o = self; o; o = Object.getPrototypeOf(o))\n for (let k of Object.getOwnPropertyNames(o))\n if (!(k in globalThis))\n Object.defineProperty(globalThis, k, { get: () => self[k] });\n "use strict";\n (() => {\n const enosys = () => {\n const err = new Error("not implemented");\n err.code = "ENOSYS";\n return err;\n };\n if (!globalThis.fs) {\n let outputBuf = "";\n globalThis.fs = {\n constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 },\n writeSync(fd, buf) {\n outputBuf += decoder.decode(buf);\n const nl = outputBuf.lastIndexOf("\\n");\n if (nl != -1) {\n console.log(outputBuf.substr(0, nl));\n outputBuf = outputBuf.substr(nl + 1);\n }\n return buf.length;\n },\n write(fd, buf, offset, length, position, callback) {\n if (offset !== 0 || length !== buf.length || position !== null) {\n callback(enosys());\n return;\n }\n const n = this.writeSync(fd, buf);\n callback(null, n);\n },\n chmod(path, mode, callback) {\n callback(enosys());\n },\n chown(path, uid, gid, callback) {\n callback(enosys());\n },\n close(fd, callback) {\n callback(enosys());\n },\n fchmod(fd, mode, callback) {\n callback(enosys());\n },\n fchown(fd, uid, gid, callback) {\n callback(enosys());\n },\n fstat(fd, callback) {\n callback(enosys());\n },\n fsync(fd, callback) {\n callback(null);\n },\n ftruncate(fd, length, callback) {\n callback(enosys());\n },\n lchown(path, uid, gid, callback) {\n callback(enosys());\n },\n link(path, link, callback) {\n callback(enosys());\n },\n lstat(path, callback) {\n callback(enosys());\n },\n mkdir(path, perm, callback) {\n callback(enosys());\n },\n open(path, flags, mode, callback) {\n callback(enosys());\n },\n read(fd, buffer, offset, length, position, callback) {\n callback(enosys());\n },\n readdir(path, callback) {\n callback(enosys());\n },\n readlink(path, callback) {\n callback(enosys());\n },\n rename(from, to, callback) {\n callback(enosys());\n },\n rmdir(path, callback) {\n callback(enosys());\n },\n stat(path, callback) {\n callback(enosys());\n },\n symlink(path, link, callback) {\n callback(enosys());\n },\n truncate(path, length, callback) {\n callback(enosys());\n },\n unlink(path, callback) {\n callback(enosys());\n },\n utimes(path, atime, mtime, callback) {\n callback(enosys());\n }\n };\n }\n if (!globalThis.process) {\n globalThis.process = {\n getuid() {\n return -1;\n },\n getgid() {\n return -1;\n },\n geteuid() {\n return -1;\n },\n getegid() {\n return -1;\n },\n getgroups() {\n throw enosys();\n },\n pid: -1,\n ppid: -1,\n umask() {\n throw enosys();\n },\n cwd() {\n throw enosys();\n },\n chdir() {\n throw enosys();\n }\n };\n }\n if (!globalThis.crypto) {\n throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");\n }\n if (!globalThis.performance) {\n throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");\n }\n if (!globalThis.TextEncoder) {\n throw new Error("globalThis.TextEncoder is not available, polyfill required");\n }\n if (!globalThis.TextDecoder) {\n throw new Error("globalThis.TextDecoder is not available, polyfill required");\n }\n const encoder = new TextEncoder("utf-8");\n const decoder = new TextDecoder("utf-8");\n globalThis.Go = class {\n constructor() {\n this.argv = ["js"];\n this.env = {};\n this.exit = (code) => {\n if (code !== 0) {\n console.warn("exit code:", code);\n }\n };\n this._exitPromise = new Promise((resolve) => {\n this._resolveExitPromise = resolve;\n });\n this._pendingEvent = null;\n this._scheduledTimeouts = /* @__PURE__ */ new Map();\n this._nextCallbackTimeoutID = 1;\n const setInt64 = (addr, v) => {\n this.mem.setUint32(addr + 0, v, true);\n this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);\n };\n const getInt64 = (addr) => {\n const low = this.mem.getUint32(addr + 0, true);\n const high = this.mem.getInt32(addr + 4, true);\n return low + high * 4294967296;\n };\n const loadValue = (addr) => {\n const f = this.mem.getFloat64(addr, true);\n if (f === 0) {\n return void 0;\n }\n if (!isNaN(f)) {\n return f;\n }\n const id = this.mem.getUint32(addr, true);\n return this._values[id];\n };\n const storeValue = (addr, v) => {\n const nanHead = 2146959360;\n if (typeof v === "number" && v !== 0) {\n if (isNaN(v)) {\n this.mem.setUint32(addr + 4, nanHead, true);\n this.mem.setUint32(addr, 0, true);\n return;\n }\n this.mem.setFloat64(addr, v, true);\n return;\n }\n if (v === void 0) {\n this.mem.setFloat64(addr, 0, true);\n return;\n }\n let id = this._ids.get(v);\n if (id === void 0) {\n id = this._idPool.pop();\n if (id === void 0) {\n id = this._values.length;\n }\n this._values[id] = v;\n this._goRefCounts[id] = 0;\n this._ids.set(v, id);\n }\n this._goRefCounts[id]++;\n let typeFlag = 0;\n switch (typeof v) {\n case "object":\n if (v !== null) {\n typeFlag = 1;\n }\n break;\n case "string":\n typeFlag = 2;\n break;\n case "symbol":\n typeFlag = 3;\n break;\n case "function":\n typeFlag = 4;\n break;\n }\n this.mem.setUint32(addr + 4, nanHead | typeFlag, true);\n this.mem.setUint32(addr, id, true);\n };\n const loadSlice = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return new Uint8Array(this._inst.exports.mem.buffer, array, len);\n };\n const loadSliceOfValues = (addr) => {\n const array = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n const a = new Array(len);\n for (let i = 0; i < len; i++) {\n a[i] = loadValue(array + i * 8);\n }\n return a;\n };\n const loadString = (addr) => {\n const saddr = getInt64(addr + 0);\n const len = getInt64(addr + 8);\n return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));\n };\n const timeOrigin = Date.now() - performance.now();\n this.importObject = {\n go: {\n "runtime.wasmExit": (sp) => {\n sp >>>= 0;\n const code = this.mem.getInt32(sp + 8, true);\n this.exited = true;\n delete this._inst;\n delete this._values;\n delete this._goRefCounts;\n delete this._ids;\n delete this._idPool;\n this.exit(code);\n },\n "runtime.wasmWrite": (sp) => {\n sp >>>= 0;\n const fd = getInt64(sp + 8);\n const p = getInt64(sp + 16);\n const n = this.mem.getInt32(sp + 24, true);\n globalThis.fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));\n },\n "runtime.resetMemoryDataView": (sp) => {\n sp >>>= 0;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n },\n "runtime.nanotime1": (sp) => {\n sp >>>= 0;\n setInt64(sp + 8, (timeOrigin + performance.now()) * 1e6);\n },\n "runtime.walltime": (sp) => {\n sp >>>= 0;\n const msec = new Date().getTime();\n setInt64(sp + 8, msec / 1e3);\n this.mem.setInt32(sp + 16, msec % 1e3 * 1e6, true);\n },\n "runtime.scheduleTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this._nextCallbackTimeoutID;\n this._nextCallbackTimeoutID++;\n this._scheduledTimeouts.set(id, setTimeout(\n () => {\n this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn("scheduleTimeoutEvent: missed timeout event");\n this._resume();\n }\n },\n getInt64(sp + 8) + 1\n ));\n this.mem.setInt32(sp + 16, id, true);\n },\n "runtime.clearTimeoutEvent": (sp) => {\n sp >>>= 0;\n const id = this.mem.getInt32(sp + 8, true);\n clearTimeout(this._scheduledTimeouts.get(id));\n this._scheduledTimeouts.delete(id);\n },\n "runtime.getRandomData": (sp) => {\n sp >>>= 0;\n crypto.getRandomValues(loadSlice(sp + 8));\n },\n "syscall/js.finalizeRef": (sp) => {\n sp >>>= 0;\n const id = this.mem.getUint32(sp + 8, true);\n this._goRefCounts[id]--;\n if (this._goRefCounts[id] === 0) {\n const v = this._values[id];\n this._values[id] = null;\n this._ids.delete(v);\n this._idPool.push(id);\n }\n },\n "syscall/js.stringVal": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, loadString(sp + 8));\n },\n "syscall/js.valueGet": (sp) => {\n sp >>>= 0;\n const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 32, result);\n },\n "syscall/js.valueSet": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));\n },\n "syscall/js.valueDelete": (sp) => {\n sp >>>= 0;\n Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));\n },\n "syscall/js.valueIndex": (sp) => {\n sp >>>= 0;\n storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));\n },\n "syscall/js.valueSetIndex": (sp) => {\n sp >>>= 0;\n Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));\n },\n "syscall/js.valueCall": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const m = Reflect.get(v, loadString(sp + 16));\n const args = loadSliceOfValues(sp + 32);\n const result = Reflect.apply(m, v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, result);\n this.mem.setUint8(sp + 64, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 56, err);\n this.mem.setUint8(sp + 64, 0);\n }\n },\n "syscall/js.valueInvoke": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.apply(v, void 0, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n "syscall/js.valueNew": (sp) => {\n sp >>>= 0;\n try {\n const v = loadValue(sp + 8);\n const args = loadSliceOfValues(sp + 16);\n const result = Reflect.construct(v, args);\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, result);\n this.mem.setUint8(sp + 48, 1);\n } catch (err) {\n sp = this._inst.exports.getsp() >>> 0;\n storeValue(sp + 40, err);\n this.mem.setUint8(sp + 48, 0);\n }\n },\n "syscall/js.valueLength": (sp) => {\n sp >>>= 0;\n setInt64(sp + 16, parseInt(loadValue(sp + 8).length));\n },\n "syscall/js.valuePrepareString": (sp) => {\n sp >>>= 0;\n const str = encoder.encode(String(loadValue(sp + 8)));\n storeValue(sp + 16, str);\n setInt64(sp + 24, str.length);\n },\n "syscall/js.valueLoadString": (sp) => {\n sp >>>= 0;\n const str = loadValue(sp + 8);\n loadSlice(sp + 16).set(str);\n },\n "syscall/js.valueInstanceOf": (sp) => {\n sp >>>= 0;\n this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);\n },\n "syscall/js.copyBytesToGo": (sp) => {\n sp >>>= 0;\n const dst = loadSlice(sp + 8);\n const src = loadValue(sp + 32);\n if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n "syscall/js.copyBytesToJS": (sp) => {\n sp >>>= 0;\n const dst = loadValue(sp + 8);\n const src = loadSlice(sp + 16);\n if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {\n this.mem.setUint8(sp + 48, 0);\n return;\n }\n const toCopy = src.subarray(0, dst.length);\n dst.set(toCopy);\n setInt64(sp + 40, toCopy.length);\n this.mem.setUint8(sp + 48, 1);\n },\n "debug": (value) => {\n console.log(value);\n }\n }\n };\n }\n async run(instance) {\n if (!(instance instanceof WebAssembly.Instance)) {\n throw new Error("Go.run: WebAssembly.Instance expected");\n }\n this._inst = instance;\n this.mem = new DataView(this._inst.exports.mem.buffer);\n this._values = [\n NaN,\n 0,\n null,\n true,\n false,\n globalThis,\n this\n ];\n this._goRefCounts = new Array(this._values.length).fill(Infinity);\n this._ids = /* @__PURE__ */ new Map([\n [0, 1],\n [null, 2],\n [true, 3],\n [false, 4],\n [globalThis, 5],\n [this, 6]\n ]);\n this._idPool = [];\n this.exited = false;\n let offset = 4096;\n const strPtr = (str) => {\n const ptr = offset;\n const bytes = encoder.encode(str + "\\0");\n new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);\n offset += bytes.length;\n if (offset % 8 !== 0) {\n offset += 8 - offset % 8;\n }\n return ptr;\n };\n const argc = this.argv.length;\n const argvPtrs = [];\n this.argv.forEach((arg) => {\n argvPtrs.push(strPtr(arg));\n });\n argvPtrs.push(0);\n const keys = Object.keys(this.env).sort();\n keys.forEach((key) => {\n argvPtrs.push(strPtr(`${key}=${this.env[key]}`));\n });\n argvPtrs.push(0);\n const argv = offset;\n argvPtrs.forEach((ptr) => {\n this.mem.setUint32(offset, ptr, true);\n this.mem.setUint32(offset + 4, 0, true);\n offset += 8;\n });\n const wasmMinDataAddr = 4096 + 8192;\n if (offset >= wasmMinDataAddr) {\n throw new Error("total length of command line and environment variables exceeds limit");\n }\n this._inst.exports.run(argc, argv);\n if (this.exited) {\n this._resolveExitPromise();\n }\n await this._exitPromise;\n }\n _resume() {\n if (this.exited) {\n throw new Error("Go program has already exited");\n }\n this._inst.exports.resume();\n if (this.exited) {\n this._resolveExitPromise();\n }\n }\n _makeFuncWrapper(id) {\n const go = this;\n return function() {\n const event = { id, this: this, args: arguments };\n go._pendingEvent = event;\n go._resume();\n return event.result;\n };\n }\n };\n })();\n onmessage = ({ data: wasm }) => {\n let decoder = new TextDecoder();\n let fs = globalThis.fs;\n let stderr = "";\n fs.writeSync = (fd, buffer) => {\n if (fd === 1) {\n postMessage(buffer);\n } else if (fd === 2) {\n stderr += decoder.decode(buffer);\n let parts = stderr.split("\\n");\n if (parts.length > 1)\n console.log(parts.slice(0, -1).join("\\n"));\n stderr = parts[parts.length - 1];\n } else {\n throw new Error("Bad write");\n }\n return buffer.length;\n };\n let stdin = [];\n let resumeStdin;\n let stdinPos = 0;\n onmessage = ({ data }) => {\n if (data.length > 0) {\n stdin.push(data);\n if (resumeStdin)\n resumeStdin();\n }\n };\n fs.read = (fd, buffer, offset, length, position, callback) => {\n if (fd !== 0 || offset !== 0 || length !== buffer.length || position !== null) {\n throw new Error("Bad read");\n }\n if (stdin.length === 0) {\n resumeStdin = () => fs.read(fd, buffer, offset, length, position, callback);\n return;\n }\n let first = stdin[0];\n let count = Math.max(0, Math.min(length, first.length - stdinPos));\n buffer.set(first.subarray(stdinPos, stdinPos + count), offset);\n stdinPos += count;\n if (stdinPos === first.length) {\n stdin.shift();\n stdinPos = 0;\n }\n callback(null, count);\n };\n let go = new globalThis.Go();\n go.argv = ["", `--service=${"0.16.3"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n };\n async function tryToInstantiateModule(wasm, go) {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = await fetch(wasm);\n if (!res.ok)\n throw new Error(`Failed to download ${JSON.stringify(wasm)}`);\n if ("instantiateStreaming" in WebAssembly && /^application\\/wasm($|;)/i.test(res.headers.get("Content-Type") || "")) {\n const result2 = await WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = await res.arrayBuffer();\n const result = await WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1700
1716
|
worker = new Worker(URL.createObjectURL(blob));
|
1701
1717
|
} else {
|
1702
1718
|
let onmessage = ((postMessage) => {
|
@@ -2278,7 +2294,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2278
2294
|
callback(null, count);
|
2279
2295
|
};
|
2280
2296
|
let go = new globalThis.Go();
|
2281
|
-
go.argv = ["", `--service=${"0.
|
2297
|
+
go.argv = ["", `--service=${"0.16.3"}`];
|
2282
2298
|
tryToInstantiateModule(wasm, go).then(
|
2283
2299
|
(instance) => {
|
2284
2300
|
postMessage(null);
|