isomorfeus-asset-manager 0.15.11 → 0.16.0
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
@@ -190,26 +190,30 @@ var ByteBuffer = class {
|
|
190
190
|
};
|
191
191
|
var encodeUTF8;
|
192
192
|
var decodeUTF8;
|
193
|
+
var encodeInvariant;
|
193
194
|
if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
|
194
195
|
let encoder = new TextEncoder();
|
195
196
|
let decoder = new TextDecoder();
|
196
197
|
encodeUTF8 = (text) => encoder.encode(text);
|
197
198
|
decodeUTF8 = (bytes) => decoder.decode(bytes);
|
199
|
+
encodeInvariant = 'new TextEncoder().encode("")';
|
198
200
|
} else if (typeof Buffer !== "undefined") {
|
199
|
-
encodeUTF8 = (text) =>
|
200
|
-
let buffer = Buffer.from(text);
|
201
|
-
if (!(buffer instanceof Uint8Array)) {
|
202
|
-
buffer = new Uint8Array(buffer);
|
203
|
-
}
|
204
|
-
return buffer;
|
205
|
-
};
|
201
|
+
encodeUTF8 = (text) => Buffer.from(text);
|
206
202
|
decodeUTF8 = (bytes) => {
|
207
203
|
let { buffer, byteOffset, byteLength } = bytes;
|
208
204
|
return Buffer.from(buffer, byteOffset, byteLength).toString();
|
209
205
|
};
|
206
|
+
encodeInvariant = 'Buffer.from("")';
|
210
207
|
} else {
|
211
208
|
throw new Error("No UTF-8 codec found");
|
212
209
|
}
|
210
|
+
if (!(encodeUTF8("") instanceof Uint8Array))
|
211
|
+
throw new Error(`Invariant violation: "${encodeInvariant} instanceof Uint8Array" is incorrectly false
|
212
|
+
|
213
|
+
This indicates that your JavaScript environment is broken. You cannot use
|
214
|
+
esbuild in this environment because esbuild relies on this invariant. This
|
215
|
+
is not a problem with esbuild. You need to fix your environment instead.
|
216
|
+
`);
|
213
217
|
function readUInt32LE(buffer, offset) {
|
214
218
|
return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;
|
215
219
|
}
|
@@ -221,10 +225,11 @@ function writeUInt32LE(buffer, value, offset) {
|
|
221
225
|
}
|
222
226
|
|
223
227
|
// lib/shared/common.ts
|
228
|
+
var quote = JSON.stringify;
|
224
229
|
var buildLogLevelDefault = "warning";
|
225
230
|
var transformLogLevelDefault = "silent";
|
226
231
|
function validateTarget(target) {
|
227
|
-
target
|
232
|
+
validateStringValue(target, "target");
|
228
233
|
if (target.indexOf(",") >= 0)
|
229
234
|
throw new Error(`Invalid target: ${target}`);
|
230
235
|
return target;
|
@@ -253,13 +258,13 @@ function getFlag(object, keys, key, mustBeFn) {
|
|
253
258
|
return void 0;
|
254
259
|
let mustBe = mustBeFn(value);
|
255
260
|
if (mustBe !== null)
|
256
|
-
throw new Error(
|
261
|
+
throw new Error(`${quote(key)} must be ${mustBe}`);
|
257
262
|
return value;
|
258
263
|
}
|
259
264
|
function checkForInvalidFlags(object, keys, where) {
|
260
265
|
for (let key in object) {
|
261
266
|
if (!(key in keys)) {
|
262
|
-
throw new Error(`Invalid option ${where}:
|
267
|
+
throw new Error(`Invalid option ${where}: ${quote(key)}`);
|
263
268
|
}
|
264
269
|
}
|
265
270
|
}
|
@@ -279,12 +284,12 @@ function validateMangleCache(mangleCache) {
|
|
279
284
|
let validated;
|
280
285
|
if (mangleCache !== void 0) {
|
281
286
|
validated = /* @__PURE__ */ Object.create(null);
|
282
|
-
for (let key
|
287
|
+
for (let key in mangleCache) {
|
283
288
|
let value = mangleCache[key];
|
284
289
|
if (typeof value === "string" || value === false) {
|
285
290
|
validated[key] = value;
|
286
291
|
} else {
|
287
|
-
throw new Error(`Expected ${
|
292
|
+
throw new Error(`Expected ${quote(key)} in mangle cache to map to either a string or false`);
|
288
293
|
}
|
289
294
|
}
|
290
295
|
}
|
@@ -301,6 +306,12 @@ function pushLogFlags(flags, options, keys, isTTY, logLevelDefault) {
|
|
301
306
|
flags.push(`--log-level=${logLevel || logLevelDefault}`);
|
302
307
|
flags.push(`--log-limit=${logLimit || 0}`);
|
303
308
|
}
|
309
|
+
function validateStringValue(value, what, key) {
|
310
|
+
if (typeof value !== "string") {
|
311
|
+
throw new Error(`Expected value for ${what}${key !== void 0 ? " " + quote(key) : ""} to be a string, got ${typeof value} instead`);
|
312
|
+
}
|
313
|
+
return value;
|
314
|
+
}
|
304
315
|
function pushCommonFlags(flags, options, keys) {
|
305
316
|
let legalComments = getFlag(options, keys, "legalComments", mustBeString);
|
306
317
|
let sourceRoot = getFlag(options, keys, "sourceRoot", mustBeString);
|
@@ -365,7 +376,7 @@ function pushCommonFlags(flags, options, keys) {
|
|
365
376
|
flags.push(`--ignore-annotations`);
|
366
377
|
if (drop)
|
367
378
|
for (let what of drop)
|
368
|
-
flags.push(`--drop:${what}`);
|
379
|
+
flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
369
380
|
if (mangleProps)
|
370
381
|
flags.push(`--mangle-props=${mangleProps.source}`);
|
371
382
|
if (reserveProps)
|
@@ -388,26 +399,29 @@ function pushCommonFlags(flags, options, keys) {
|
|
388
399
|
for (let key in define) {
|
389
400
|
if (key.indexOf("=") >= 0)
|
390
401
|
throw new Error(`Invalid define: ${key}`);
|
391
|
-
flags.push(`--define:${key}=${define[key]}`);
|
402
|
+
flags.push(`--define:${key}=${validateStringValue(define[key], "define", key)}`);
|
392
403
|
}
|
393
404
|
}
|
394
405
|
if (logOverride) {
|
395
406
|
for (let key in logOverride) {
|
396
407
|
if (key.indexOf("=") >= 0)
|
397
408
|
throw new Error(`Invalid log override: ${key}`);
|
398
|
-
flags.push(`--log-override:${key}=${logOverride[key]}`);
|
409
|
+
flags.push(`--log-override:${key}=${validateStringValue(logOverride[key], "log override", key)}`);
|
399
410
|
}
|
400
411
|
}
|
401
412
|
if (supported) {
|
402
413
|
for (let key in supported) {
|
403
414
|
if (key.indexOf("=") >= 0)
|
404
415
|
throw new Error(`Invalid supported: ${key}`);
|
405
|
-
|
416
|
+
const value = supported[key];
|
417
|
+
if (typeof value !== "boolean")
|
418
|
+
throw new Error(`Expected value for supported ${quote(key)} to be a boolean, got ${typeof value} instead`);
|
419
|
+
flags.push(`--supported:${key}=${value}`);
|
406
420
|
}
|
407
421
|
}
|
408
422
|
if (pure)
|
409
423
|
for (let fn of pure)
|
410
|
-
flags.push(`--pure:${fn}`);
|
424
|
+
flags.push(`--pure:${validateStringValue(fn, "pure")}`);
|
411
425
|
if (keepNames)
|
412
426
|
flags.push(`--keep-names`);
|
413
427
|
}
|
@@ -489,7 +503,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
489
503
|
if (resolveExtensions) {
|
490
504
|
let values = [];
|
491
505
|
for (let value of resolveExtensions) {
|
492
|
-
value
|
506
|
+
validateStringValue(value, "resolve extension");
|
493
507
|
if (value.indexOf(",") >= 0)
|
494
508
|
throw new Error(`Invalid resolve extension: ${value}`);
|
495
509
|
values.push(value);
|
@@ -507,7 +521,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
507
521
|
if (mainFields) {
|
508
522
|
let values = [];
|
509
523
|
for (let value of mainFields) {
|
510
|
-
value
|
524
|
+
validateStringValue(value, "main field");
|
511
525
|
if (value.indexOf(",") >= 0)
|
512
526
|
throw new Error(`Invalid main field: ${value}`);
|
513
527
|
values.push(value);
|
@@ -517,7 +531,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
517
531
|
if (conditions) {
|
518
532
|
let values = [];
|
519
533
|
for (let value of conditions) {
|
520
|
-
value
|
534
|
+
validateStringValue(value, "condition");
|
521
535
|
if (value.indexOf(",") >= 0)
|
522
536
|
throw new Error(`Invalid condition: ${value}`);
|
523
537
|
values.push(value);
|
@@ -526,53 +540,53 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
526
540
|
}
|
527
541
|
if (external)
|
528
542
|
for (let name of external)
|
529
|
-
flags.push(`--external:${name}`);
|
543
|
+
flags.push(`--external:${validateStringValue(name, "external")}`);
|
530
544
|
if (alias) {
|
531
545
|
for (let old in alias) {
|
532
546
|
if (old.indexOf("=") >= 0)
|
533
547
|
throw new Error(`Invalid package name in alias: ${old}`);
|
534
|
-
flags.push(`--alias:${old}=${alias[old]}`);
|
548
|
+
flags.push(`--alias:${old}=${validateStringValue(alias[old], "alias", old)}`);
|
535
549
|
}
|
536
550
|
}
|
537
551
|
if (banner) {
|
538
552
|
for (let type in banner) {
|
539
553
|
if (type.indexOf("=") >= 0)
|
540
554
|
throw new Error(`Invalid banner file type: ${type}`);
|
541
|
-
flags.push(`--banner:${type}=${banner[type]}`);
|
555
|
+
flags.push(`--banner:${type}=${validateStringValue(banner[type], "banner", type)}`);
|
542
556
|
}
|
543
557
|
}
|
544
558
|
if (footer) {
|
545
559
|
for (let type in footer) {
|
546
560
|
if (type.indexOf("=") >= 0)
|
547
561
|
throw new Error(`Invalid footer file type: ${type}`);
|
548
|
-
flags.push(`--footer:${type}=${footer[type]}`);
|
562
|
+
flags.push(`--footer:${type}=${validateStringValue(footer[type], "footer", type)}`);
|
549
563
|
}
|
550
564
|
}
|
551
565
|
if (inject)
|
552
566
|
for (let path of inject)
|
553
|
-
flags.push(`--inject:${path}`);
|
567
|
+
flags.push(`--inject:${validateStringValue(path, "inject")}`);
|
554
568
|
if (loader) {
|
555
569
|
for (let ext in loader) {
|
556
570
|
if (ext.indexOf("=") >= 0)
|
557
571
|
throw new Error(`Invalid loader extension: ${ext}`);
|
558
|
-
flags.push(`--loader:${ext}=${loader[ext]}`);
|
572
|
+
flags.push(`--loader:${ext}=${validateStringValue(loader[ext], "loader", ext)}`);
|
559
573
|
}
|
560
574
|
}
|
561
575
|
if (outExtension) {
|
562
576
|
for (let ext in outExtension) {
|
563
577
|
if (ext.indexOf("=") >= 0)
|
564
578
|
throw new Error(`Invalid out extension: ${ext}`);
|
565
|
-
flags.push(`--out-extension:${ext}=${outExtension[ext]}`);
|
579
|
+
flags.push(`--out-extension:${ext}=${validateStringValue(outExtension[ext], "out extension", ext)}`);
|
566
580
|
}
|
567
581
|
}
|
568
582
|
if (entryPoints) {
|
569
583
|
if (Array.isArray(entryPoints)) {
|
570
584
|
for (let entryPoint of entryPoints) {
|
571
|
-
entries.push(["", entryPoint
|
585
|
+
entries.push(["", validateStringValue(entryPoint, "entry point")]);
|
572
586
|
}
|
573
587
|
} else {
|
574
|
-
for (let
|
575
|
-
entries.push([key
|
588
|
+
for (let key in entryPoints) {
|
589
|
+
entries.push([key, validateStringValue(entryPoints[key], "entry point", key)]);
|
576
590
|
}
|
577
591
|
}
|
578
592
|
}
|
@@ -588,7 +602,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
588
602
|
if (loader2)
|
589
603
|
flags.push(`--loader=${loader2}`);
|
590
604
|
if (resolveDir)
|
591
|
-
stdinResolveDir = resolveDir
|
605
|
+
stdinResolveDir = resolveDir;
|
592
606
|
if (typeof contents === "string")
|
593
607
|
stdinContents = encodeUTF8(contents);
|
594
608
|
else if (contents instanceof Uint8Array)
|
@@ -733,8 +747,8 @@ function createChannel(streamIn) {
|
|
733
747
|
if (isFirstPacket) {
|
734
748
|
isFirstPacket = false;
|
735
749
|
let binaryVersion = String.fromCharCode(...bytes);
|
736
|
-
if (binaryVersion !== "0.
|
737
|
-
throw new Error(`Cannot start service: Host version "${"0.
|
750
|
+
if (binaryVersion !== "0.16.1") {
|
751
|
+
throw new Error(`Cannot start service: Host version "${"0.16.1"}" does not match binary version ${quote(binaryVersion)}`);
|
738
752
|
}
|
739
753
|
return;
|
740
754
|
}
|
@@ -1216,7 +1230,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1216
1230
|
let setup = getFlag(item, keys, "setup", mustBeFunction);
|
1217
1231
|
if (typeof setup !== "function")
|
1218
1232
|
throw new Error(`Plugin is missing a setup function`);
|
1219
|
-
checkForInvalidFlags(item, keys, `on plugin ${
|
1233
|
+
checkForInvalidFlags(item, keys, `on plugin ${quote(name)}`);
|
1220
1234
|
let plugin = {
|
1221
1235
|
name,
|
1222
1236
|
onResolve: [],
|
@@ -1253,6 +1267,8 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1253
1267
|
request.resolveDir = resolveDir;
|
1254
1268
|
if (kind != null)
|
1255
1269
|
request.kind = kind;
|
1270
|
+
else
|
1271
|
+
throw new Error(`Must specify "kind" when calling "resolve"`);
|
1256
1272
|
if (pluginData != null)
|
1257
1273
|
request.pluginData = details.store(pluginData);
|
1258
1274
|
sendRequest(refs, request, (error, response) => {
|
@@ -1291,7 +1307,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1291
1307
|
let keys2 = {};
|
1292
1308
|
let filter = getFlag(options, keys2, "filter", mustBeRegExp);
|
1293
1309
|
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
1294
|
-
checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${
|
1310
|
+
checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${quote(name)}`);
|
1295
1311
|
if (filter == null)
|
1296
1312
|
throw new Error(`onResolve() call is missing a filter`);
|
1297
1313
|
let id = nextCallbackID++;
|
@@ -1304,7 +1320,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1304
1320
|
let keys2 = {};
|
1305
1321
|
let filter = getFlag(options, keys2, "filter", mustBeRegExp);
|
1306
1322
|
let namespace = getFlag(options, keys2, "namespace", mustBeString);
|
1307
|
-
checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${
|
1323
|
+
checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${quote(name)}`);
|
1308
1324
|
if (filter == null)
|
1309
1325
|
throw new Error(`onLoad() call is missing a filter`);
|
1310
1326
|
let id = nextCallbackID++;
|
@@ -1327,11 +1343,11 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1327
1343
|
let result = yield callback();
|
1328
1344
|
if (result != null) {
|
1329
1345
|
if (typeof result !== "object")
|
1330
|
-
throw new Error(`Expected onStart() callback in plugin ${
|
1346
|
+
throw new Error(`Expected onStart() callback in plugin ${quote(name)} to return an object`);
|
1331
1347
|
let keys = {};
|
1332
1348
|
let errors = getFlag(result, keys, "errors", mustBeArray);
|
1333
1349
|
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
1334
|
-
checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${
|
1350
|
+
checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote(name)}`);
|
1335
1351
|
if (errors != null)
|
1336
1352
|
response.errors.push(...sanitizeMessages(errors, "errors", details, name));
|
1337
1353
|
if (warnings != null)
|
@@ -1358,7 +1374,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1358
1374
|
});
|
1359
1375
|
if (result != null) {
|
1360
1376
|
if (typeof result !== "object")
|
1361
|
-
throw new Error(`Expected onResolve() callback in plugin ${
|
1377
|
+
throw new Error(`Expected onResolve() callback in plugin ${quote(name)} to return an object`);
|
1362
1378
|
let keys = {};
|
1363
1379
|
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
1364
1380
|
let path = getFlag(result, keys, "path", mustBeString);
|
@@ -1371,7 +1387,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1371
1387
|
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
1372
1388
|
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
1373
1389
|
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
1374
|
-
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${
|
1390
|
+
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote(name)}`);
|
1375
1391
|
response.id = id2;
|
1376
1392
|
if (pluginName != null)
|
1377
1393
|
response.pluginName = pluginName;
|
@@ -1417,7 +1433,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1417
1433
|
});
|
1418
1434
|
if (result != null) {
|
1419
1435
|
if (typeof result !== "object")
|
1420
|
-
throw new Error(`Expected onLoad() callback in plugin ${
|
1436
|
+
throw new Error(`Expected onLoad() callback in plugin ${quote(name)} to return an object`);
|
1421
1437
|
let keys = {};
|
1422
1438
|
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
1423
1439
|
let contents = getFlag(result, keys, "contents", mustBeStringOrUint8Array);
|
@@ -1428,7 +1444,7 @@ var handlePlugins = (buildKey, sendRequest, sendResponse, refs, streamIn, reques
|
|
1428
1444
|
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
1429
1445
|
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
1430
1446
|
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
1431
|
-
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${
|
1447
|
+
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote(name)}`);
|
1432
1448
|
response.id = id2;
|
1433
1449
|
if (pluginName != null)
|
1434
1450
|
response.pluginName = pluginName;
|
@@ -1662,7 +1678,7 @@ function sanitizeStringArray(values, property) {
|
|
1662
1678
|
const result = [];
|
1663
1679
|
for (const value of values) {
|
1664
1680
|
if (typeof value !== "string")
|
1665
|
-
throw new Error(`${
|
1681
|
+
throw new Error(`${quote(property)} must be an array of strings`);
|
1666
1682
|
result.push(value);
|
1667
1683
|
}
|
1668
1684
|
return result;
|
@@ -1684,7 +1700,7 @@ function convertOutputFiles({ path, contents }) {
|
|
1684
1700
|
}
|
1685
1701
|
|
1686
1702
|
// lib/npm/browser.ts
|
1687
|
-
var version = "0.
|
1703
|
+
var version = "0.16.1";
|
1688
1704
|
var build = (options) => ensureServiceIsRunning().build(options);
|
1689
1705
|
var serve = () => {
|
1690
1706
|
throw new Error(`The "serve" API only works in node`);
|
@@ -1731,7 +1747,7 @@ var initialize = (options) => {
|
|
1731
1747
|
var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, null, function* () {
|
1732
1748
|
let worker;
|
1733
1749
|
if (useWorker) {
|
1734
|
-
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 var __async = (__this, __arguments, generator) => {\n return new Promise((resolve, reject) => {\n var fulfilled = (value) => {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n };\n var rejected = (value) => {\n try {\n step(generator.throw(value));\n } catch (e) {\n reject(e);\n }\n };\n var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);\n step((generator = generator.apply(__this, __arguments)).next());\n });\n };\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 run(instance) {\n return __async(this, null, function* () {\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 yield this._exitPromise;\n });\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 function tryToInstantiateModule(wasm, go) {\n return __async(this, null, function* () {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = yield 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 = yield WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = yield res.arrayBuffer();\n const result = yield WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n });\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1750
|
+
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 var __async = (__this, __arguments, generator) => {\n return new Promise((resolve, reject) => {\n var fulfilled = (value) => {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n };\n var rejected = (value) => {\n try {\n step(generator.throw(value));\n } catch (e) {\n reject(e);\n }\n };\n var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);\n step((generator = generator.apply(__this, __arguments)).next());\n });\n };\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 run(instance) {\n return __async(this, null, function* () {\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 yield this._exitPromise;\n });\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.1"}`];\n tryToInstantiateModule(wasm, go).then(\n (instance) => {\n postMessage(null);\n go.run(instance);\n },\n (error) => {\n postMessage(error);\n }\n );\n };\n function tryToInstantiateModule(wasm, go) {\n return __async(this, null, function* () {\n if (wasm instanceof WebAssembly.Module) {\n return WebAssembly.instantiate(wasm, go.importObject);\n }\n const res = yield 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 = yield WebAssembly.instantiateStreaming(res, go.importObject);\n return result2.instance;\n }\n const bytes = yield res.arrayBuffer();\n const result = yield WebAssembly.instantiate(bytes, go.importObject);\n return result.instance;\n });\n }\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1735
1751
|
worker = new Worker(URL.createObjectURL(blob));
|
1736
1752
|
} else {
|
1737
1753
|
let onmessage = ((postMessage) => {
|
@@ -2335,7 +2351,7 @@ var startRunningService = (wasmURL, wasmModule, useWorker) => __async(void 0, nu
|
|
2335
2351
|
callback(null, count);
|
2336
2352
|
};
|
2337
2353
|
let go = new globalThis.Go();
|
2338
|
-
go.argv = ["", `--service=${"0.
|
2354
|
+
go.argv = ["", `--service=${"0.16.1"}`];
|
2339
2355
|
tryToInstantiateModule(wasm, go).then(
|
2340
2356
|
(instance) => {
|
2341
2357
|
postMessage(null);
|