isomorfeus-asset-manager 0.14.24 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/LICENSE.md +21 -0
- data/node_modules/esbuild-wasm/esbuild.wasm +0 -0
- data/node_modules/esbuild-wasm/esm/browser.d.ts +16 -8
- data/node_modules/esbuild-wasm/esm/browser.js +87 -55
- data/node_modules/esbuild-wasm/esm/browser.min.js +8 -8
- data/node_modules/esbuild-wasm/lib/browser.d.ts +16 -8
- data/node_modules/esbuild-wasm/lib/browser.js +88 -55
- data/node_modules/esbuild-wasm/lib/browser.min.js +8 -8
- data/node_modules/esbuild-wasm/lib/main.d.ts +16 -8
- data/node_modules/esbuild-wasm/lib/main.js +135 -105
- data/node_modules/esbuild-wasm/package.json +1 -1
- data/package.json +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b2068375a8e86664b7421e506e7e0d2a5da55192fe0790da111127c4f13403
|
4
|
+
data.tar.gz: 127c9861ebd48810db3192243d738fc5f6fb205ab96899305ed9f72e101bfa67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2d4a04d90804b0f321c2dcf229650796140012ad55fa875d547e74ce7b8fb65d6ba5965fe9bf90c7863f4d6d51f74bb0b95bafe5edd3b27f619aa68c74c5a60
|
7
|
+
data.tar.gz: 76506bf2309b362de9928430290b0f3687d1f0586faae01fb08394e75e2180a87c29f492611513ff614ed77cb64cd5c709363ae480e7985fe011c76630d57efc
|
@@ -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.15.0",
|
8
|
+
"resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.15.0.tgz",
|
9
|
+
"integrity": "sha512-zkCXQzJgVYxS6sCFFQl22lIJQ1V/dkPrv+qOKSgQMdTrZR4qUQh0siDhJLDeM3T6SZgBgQ89qDCkc7weEVvnoA==",
|
10
10
|
"bin": {
|
11
11
|
"esbuild": "bin/esbuild"
|
12
12
|
},
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Evan Wallace
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export type Platform = 'browser' | 'node' | 'neutral';
|
2
2
|
export type Format = 'iife' | 'cjs' | 'esm';
|
3
|
-
export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default';
|
3
|
+
export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'copy' | 'default';
|
4
4
|
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
|
5
5
|
export type Charset = 'ascii' | 'utf8';
|
6
6
|
export type Drop = 'console' | 'debugger';
|
@@ -17,10 +17,14 @@ interface CommonOptions {
|
|
17
17
|
|
18
18
|
/** Documentation: https://esbuild.github.io/api/#format */
|
19
19
|
format?: Format;
|
20
|
-
/** Documentation: https://esbuild.github.io/api/#
|
20
|
+
/** Documentation: https://esbuild.github.io/api/#global-name */
|
21
21
|
globalName?: string;
|
22
22
|
/** Documentation: https://esbuild.github.io/api/#target */
|
23
23
|
target?: string | string[];
|
24
|
+
/** Documentation: https://esbuild.github.io/api/#supported */
|
25
|
+
supported?: Record<string, boolean>;
|
26
|
+
/** Documentation: https://esbuild.github.io/api/#platform */
|
27
|
+
platform?: Platform;
|
24
28
|
|
25
29
|
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
26
30
|
mangleProps?: RegExp;
|
@@ -48,11 +52,15 @@ interface CommonOptions {
|
|
48
52
|
ignoreAnnotations?: boolean;
|
49
53
|
|
50
54
|
/** Documentation: https://esbuild.github.io/api/#jsx */
|
51
|
-
jsx?: 'transform' | 'preserve';
|
55
|
+
jsx?: 'transform' | 'preserve' | 'automatic';
|
52
56
|
/** Documentation: https://esbuild.github.io/api/#jsx-factory */
|
53
57
|
jsxFactory?: string;
|
54
58
|
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */
|
55
59
|
jsxFragment?: string;
|
60
|
+
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */
|
61
|
+
jsxImportSource?: string;
|
62
|
+
/** Documentation: https://esbuild.github.io/api/#jsx-development */
|
63
|
+
jsxDev?: boolean;
|
56
64
|
|
57
65
|
/** Documentation: https://esbuild.github.io/api/#define */
|
58
66
|
define?: { [key: string]: string };
|
@@ -86,15 +94,13 @@ export interface BuildOptions extends CommonOptions {
|
|
86
94
|
outdir?: string;
|
87
95
|
/** Documentation: https://esbuild.github.io/api/#outbase */
|
88
96
|
outbase?: string;
|
89
|
-
/** Documentation: https://esbuild.github.io/api/#platform */
|
90
|
-
platform?: Platform;
|
91
97
|
/** Documentation: https://esbuild.github.io/api/#external */
|
92
98
|
external?: string[];
|
93
99
|
/** Documentation: https://esbuild.github.io/api/#loader */
|
94
100
|
loader?: { [ext: string]: Loader };
|
95
101
|
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */
|
96
102
|
resolveExtensions?: string[];
|
97
|
-
/** Documentation: https://esbuild.github.io/api/#
|
103
|
+
/** Documentation: https://esbuild.github.io/api/#main-fields */
|
98
104
|
mainFields?: string[];
|
99
105
|
/** Documentation: https://esbuild.github.io/api/#conditions */
|
100
106
|
conditions?: string[];
|
@@ -141,13 +147,14 @@ export interface WatchMode {
|
|
141
147
|
}
|
142
148
|
|
143
149
|
export interface StdinOptions {
|
144
|
-
contents: string;
|
150
|
+
contents: string | Uint8Array;
|
145
151
|
resolveDir?: string;
|
146
152
|
sourcefile?: string;
|
147
153
|
loader?: Loader;
|
148
154
|
}
|
149
155
|
|
150
156
|
export interface Message {
|
157
|
+
id: string;
|
151
158
|
pluginName: string;
|
152
159
|
text: string;
|
153
160
|
location: Location | null;
|
@@ -402,6 +409,7 @@ export interface OnLoadResult {
|
|
402
409
|
}
|
403
410
|
|
404
411
|
export interface PartialMessage {
|
412
|
+
id?: string;
|
405
413
|
pluginName?: string;
|
406
414
|
text?: string;
|
407
415
|
location?: Partial<Location> | null;
|
@@ -491,7 +499,7 @@ export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOpt
|
|
491
499
|
*
|
492
500
|
* Documentation: https://esbuild.github.io/api/#transform-api
|
493
501
|
*/
|
494
|
-
export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
|
502
|
+
export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>;
|
495
503
|
|
496
504
|
/**
|
497
505
|
* Converts log messages to formatted message strings suitable for printing in
|
@@ -302,10 +302,14 @@ function pushCommonFlags(flags, options, keys) {
|
|
302
302
|
let jsx = getFlag(options, keys, "jsx", mustBeString);
|
303
303
|
let jsxFactory = getFlag(options, keys, "jsxFactory", mustBeString);
|
304
304
|
let jsxFragment = getFlag(options, keys, "jsxFragment", mustBeString);
|
305
|
+
let jsxImportSource = getFlag(options, keys, "jsxImportSource", mustBeString);
|
306
|
+
let jsxDev = getFlag(options, keys, "jsxDev", mustBeBoolean);
|
305
307
|
let define = getFlag(options, keys, "define", mustBeObject);
|
306
308
|
let logOverride = getFlag(options, keys, "logOverride", mustBeObject);
|
309
|
+
let supported = getFlag(options, keys, "supported", mustBeObject);
|
307
310
|
let pure = getFlag(options, keys, "pure", mustBeArray);
|
308
311
|
let keepNames = getFlag(options, keys, "keepNames", mustBeBoolean);
|
312
|
+
let platform = getFlag(options, keys, "platform", mustBeString);
|
309
313
|
if (legalComments)
|
310
314
|
flags.push(`--legal-comments=${legalComments}`);
|
311
315
|
if (sourceRoot !== void 0)
|
@@ -322,6 +326,8 @@ function pushCommonFlags(flags, options, keys) {
|
|
322
326
|
flags.push(`--format=${format}`);
|
323
327
|
if (globalName)
|
324
328
|
flags.push(`--global-name=${globalName}`);
|
329
|
+
if (platform)
|
330
|
+
flags.push(`--platform=${platform}`);
|
325
331
|
if (minify)
|
326
332
|
flags.push("--minify");
|
327
333
|
if (minifySyntax)
|
@@ -351,6 +357,10 @@ function pushCommonFlags(flags, options, keys) {
|
|
351
357
|
flags.push(`--jsx-factory=${jsxFactory}`);
|
352
358
|
if (jsxFragment)
|
353
359
|
flags.push(`--jsx-fragment=${jsxFragment}`);
|
360
|
+
if (jsxImportSource)
|
361
|
+
flags.push(`--jsx-import-source=${jsxImportSource}`);
|
362
|
+
if (jsxDev)
|
363
|
+
flags.push(`--jsx-dev`);
|
354
364
|
if (define) {
|
355
365
|
for (let key in define) {
|
356
366
|
if (key.indexOf("=") >= 0)
|
@@ -365,6 +375,13 @@ function pushCommonFlags(flags, options, keys) {
|
|
365
375
|
flags.push(`--log-override:${key}=${logOverride[key]}`);
|
366
376
|
}
|
367
377
|
}
|
378
|
+
if (supported) {
|
379
|
+
for (let key in supported) {
|
380
|
+
if (key.indexOf("=") >= 0)
|
381
|
+
throw new Error(`Invalid supported: ${key}`);
|
382
|
+
flags.push(`--supported:${key}=${supported[key]}`);
|
383
|
+
}
|
384
|
+
}
|
368
385
|
if (pure)
|
369
386
|
for (let fn of pure)
|
370
387
|
flags.push(`--pure:${fn}`);
|
@@ -390,7 +407,6 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
390
407
|
let outfile = getFlag(options, keys, "outfile", mustBeString);
|
391
408
|
let outdir = getFlag(options, keys, "outdir", mustBeString);
|
392
409
|
let outbase = getFlag(options, keys, "outbase", mustBeString);
|
393
|
-
let platform = getFlag(options, keys, "platform", mustBeString);
|
394
410
|
let tsconfig = getFlag(options, keys, "tsconfig", mustBeString);
|
395
411
|
let resolveExtensions = getFlag(options, keys, "resolveExtensions", mustBeArray);
|
396
412
|
let nodePathsInput = getFlag(options, keys, "nodePaths", mustBeArray);
|
@@ -444,8 +460,6 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
444
460
|
flags.push(`--outdir=${outdir}`);
|
445
461
|
if (outbase)
|
446
462
|
flags.push(`--outbase=${outbase}`);
|
447
|
-
if (platform)
|
448
|
-
flags.push(`--platform=${platform}`);
|
449
463
|
if (tsconfig)
|
450
464
|
flags.push(`--tsconfig=${tsconfig}`);
|
451
465
|
if (resolveExtensions) {
|
@@ -533,7 +547,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
533
547
|
}
|
534
548
|
if (stdin) {
|
535
549
|
let stdinKeys = /* @__PURE__ */ Object.create(null);
|
536
|
-
let contents = getFlag(stdin, stdinKeys, "contents",
|
550
|
+
let contents = getFlag(stdin, stdinKeys, "contents", mustBeStringOrUint8Array);
|
537
551
|
let resolveDir = getFlag(stdin, stdinKeys, "resolveDir", mustBeString);
|
538
552
|
let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
|
539
553
|
let loader2 = getFlag(stdin, stdinKeys, "loader", mustBeString);
|
@@ -544,7 +558,10 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
|
|
544
558
|
flags.push(`--loader=${loader2}`);
|
545
559
|
if (resolveDir)
|
546
560
|
stdinResolveDir = resolveDir + "";
|
547
|
-
|
561
|
+
if (typeof contents === "string")
|
562
|
+
stdinContents = encodeUTF8(contents);
|
563
|
+
else if (contents instanceof Uint8Array)
|
564
|
+
stdinContents = contents;
|
548
565
|
}
|
549
566
|
let nodePaths = [];
|
550
567
|
if (nodePathsInput) {
|
@@ -739,8 +756,8 @@ function createChannel(streamIn) {
|
|
739
756
|
if (isFirstPacket) {
|
740
757
|
isFirstPacket = false;
|
741
758
|
let binaryVersion = String.fromCharCode(...bytes);
|
742
|
-
if (binaryVersion !== "0.
|
743
|
-
throw new Error(`Cannot start service: Host version "${"0.
|
759
|
+
if (binaryVersion !== "0.15.0") {
|
760
|
+
throw new Error(`Cannot start service: Host version "${"0.15.0"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
|
744
761
|
}
|
745
762
|
return;
|
746
763
|
}
|
@@ -1127,24 +1144,27 @@ function createChannel(streamIn) {
|
|
1127
1144
|
if (plugins && plugins.length > 0) {
|
1128
1145
|
if (streamIn.isSync)
|
1129
1146
|
return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
|
1130
|
-
handlePlugins(options, plugins, key, details, refs).then(
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1147
|
+
handlePlugins(options, plugins, key, details, refs).then(
|
1148
|
+
(result) => {
|
1149
|
+
if (!result.ok) {
|
1150
|
+
handleError(result.error, result.pluginName);
|
1151
|
+
} else {
|
1152
|
+
try {
|
1153
|
+
buildOrServeContinue(__spreadProps(__spreadValues({}, args), {
|
1154
|
+
key,
|
1155
|
+
details,
|
1156
|
+
logPluginError,
|
1157
|
+
requestPlugins: result.requestPlugins,
|
1158
|
+
runOnEndCallbacks: result.runOnEndCallbacks,
|
1159
|
+
pluginRefs: result.pluginRefs
|
1160
|
+
}));
|
1161
|
+
} catch (e) {
|
1162
|
+
handleError(e, "");
|
1163
|
+
}
|
1145
1164
|
}
|
1146
|
-
}
|
1147
|
-
|
1165
|
+
},
|
1166
|
+
(e) => handleError(e, "")
|
1167
|
+
);
|
1148
1168
|
} else {
|
1149
1169
|
try {
|
1150
1170
|
buildOrServeContinue(__spreadProps(__spreadValues({}, args), {
|
@@ -1189,7 +1209,7 @@ function createChannel(streamIn) {
|
|
1189
1209
|
callerRefs.unref();
|
1190
1210
|
}
|
1191
1211
|
};
|
1192
|
-
let writeDefault = !streamIn.
|
1212
|
+
let writeDefault = !streamIn.isWriteUnavailable;
|
1193
1213
|
let {
|
1194
1214
|
entries,
|
1195
1215
|
flags,
|
@@ -1247,18 +1267,22 @@ function createChannel(streamIn) {
|
|
1247
1267
|
rebuild = () => new Promise((resolve, reject) => {
|
1248
1268
|
if (isDisposed || closeData)
|
1249
1269
|
throw new Error("Cannot rebuild");
|
1250
|
-
sendRequest(
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1270
|
+
sendRequest(
|
1271
|
+
refs,
|
1272
|
+
{ command: "rebuild", key },
|
1273
|
+
(error2, response2) => {
|
1274
|
+
if (error2) {
|
1275
|
+
const message = { id: "", pluginName: "", text: error2, location: null, notes: [], detail: void 0 };
|
1276
|
+
return callback2(failureErrorWithLog("Build failed", [message], []), null);
|
1277
|
+
}
|
1278
|
+
buildResponseToResult(response2, (error3, result3) => {
|
1279
|
+
if (error3)
|
1280
|
+
reject(error3);
|
1281
|
+
else
|
1282
|
+
resolve(result3);
|
1283
|
+
});
|
1254
1284
|
}
|
1255
|
-
|
1256
|
-
if (error3)
|
1257
|
-
reject(error3);
|
1258
|
-
else
|
1259
|
-
resolve(result3);
|
1260
|
-
});
|
1261
|
-
});
|
1285
|
+
);
|
1262
1286
|
});
|
1263
1287
|
refs.ref();
|
1264
1288
|
rebuild.dispose = () => {
|
@@ -1317,8 +1341,8 @@ function createChannel(streamIn) {
|
|
1317
1341
|
callback2(null, result);
|
1318
1342
|
});
|
1319
1343
|
};
|
1320
|
-
if (write && streamIn.
|
1321
|
-
throw new Error(`
|
1344
|
+
if (write && streamIn.isWriteUnavailable)
|
1345
|
+
throw new Error(`The "write" option is unavailable in this environment`);
|
1322
1346
|
if (incremental && streamIn.isSync)
|
1323
1347
|
throw new Error(`Cannot use "incremental" with a synchronous build`);
|
1324
1348
|
if (watch && streamIn.isSync)
|
@@ -1353,8 +1377,8 @@ function createChannel(streamIn) {
|
|
1353
1377
|
const details = createObjectStash();
|
1354
1378
|
let start = (inputPath) => {
|
1355
1379
|
try {
|
1356
|
-
if (typeof input !== "string")
|
1357
|
-
throw new Error('The input to "transform" must be a string');
|
1380
|
+
if (typeof input !== "string" && !(input instanceof Uint8Array))
|
1381
|
+
throw new Error('The input to "transform" must be a string or a Uint8Array');
|
1358
1382
|
let {
|
1359
1383
|
flags,
|
1360
1384
|
mangleCache
|
@@ -1363,7 +1387,7 @@ function createChannel(streamIn) {
|
|
1363
1387
|
command: "transform",
|
1364
1388
|
flags,
|
1365
1389
|
inputFS: inputPath !== null,
|
1366
|
-
input: inputPath !== null ? inputPath : input
|
1390
|
+
input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === "string" ? encodeUTF8(input) : input
|
1367
1391
|
};
|
1368
1392
|
if (mangleCache)
|
1369
1393
|
request.mangleCache = mangleCache;
|
@@ -1420,7 +1444,7 @@ function createChannel(streamIn) {
|
|
1420
1444
|
});
|
1421
1445
|
}
|
1422
1446
|
};
|
1423
|
-
if (typeof input === "string" && input.length > 1024 * 1024) {
|
1447
|
+
if ((typeof input === "string" || input instanceof Uint8Array) && input.length > 1024 * 1024) {
|
1424
1448
|
let next = start;
|
1425
1449
|
start = () => fs.writeFile(input, next);
|
1426
1450
|
}
|
@@ -1532,7 +1556,7 @@ function extractErrorMessageV8(e, streamIn, stash, note, pluginName) {
|
|
1532
1556
|
location = parseStackLinesV8(streamIn, (e.stack + "").split("\n"), "");
|
1533
1557
|
} catch (e2) {
|
1534
1558
|
}
|
1535
|
-
return { pluginName, text, location, notes: note ? [note] : [], detail: stash ? stash.store(e) : -1 };
|
1559
|
+
return { id: "", pluginName, text, location, notes: note ? [note] : [], detail: stash ? stash.store(e) : -1 };
|
1536
1560
|
}
|
1537
1561
|
function parseStackLinesV8(streamIn, lines, ident) {
|
1538
1562
|
let at = " at ";
|
@@ -1631,6 +1655,7 @@ function sanitizeMessages(messages, property, stash, fallbackPluginName) {
|
|
1631
1655
|
let index = 0;
|
1632
1656
|
for (const message of messages) {
|
1633
1657
|
let keys = {};
|
1658
|
+
let id = getFlag(message, keys, "id", mustBeString);
|
1634
1659
|
let pluginName = getFlag(message, keys, "pluginName", mustBeString);
|
1635
1660
|
let text = getFlag(message, keys, "text", mustBeString);
|
1636
1661
|
let location = getFlag(message, keys, "location", mustBeObjectOrNull);
|
@@ -1652,6 +1677,7 @@ function sanitizeMessages(messages, property, stash, fallbackPluginName) {
|
|
1652
1677
|
}
|
1653
1678
|
}
|
1654
1679
|
messagesClone.push({
|
1680
|
+
id: id || "",
|
1655
1681
|
pluginName: pluginName || fallbackPluginName,
|
1656
1682
|
text: text || "",
|
1657
1683
|
location: sanitizeLocation(location, where),
|
@@ -1677,15 +1703,18 @@ function convertOutputFiles({ path, contents }) {
|
|
1677
1703
|
path,
|
1678
1704
|
contents,
|
1679
1705
|
get text() {
|
1680
|
-
|
1681
|
-
|
1706
|
+
const binary = this.contents;
|
1707
|
+
if (text === null || binary !== contents) {
|
1708
|
+
contents = binary;
|
1709
|
+
text = decodeUTF8(binary);
|
1710
|
+
}
|
1682
1711
|
return text;
|
1683
1712
|
}
|
1684
1713
|
};
|
1685
1714
|
}
|
1686
1715
|
|
1687
1716
|
// lib/npm/browser.ts
|
1688
|
-
var version = "0.
|
1717
|
+
var version = "0.15.0";
|
1689
1718
|
var build = (options) => ensureServiceIsRunning().build(options);
|
1690
1719
|
var serve = () => {
|
1691
1720
|
throw new Error(`The "serve" API only works in node`);
|
@@ -1741,7 +1770,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
1741
1770
|
}
|
1742
1771
|
let worker;
|
1743
1772
|
if (useWorker) {
|
1744
|
-
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 this._resume();\n while (this._scheduledTimeouts.has(id)) {\n console.warn("scheduleTimeoutEvent: missed timeout event");\n this._resume();\n }\n }, getInt64(sp + 8) + 1));\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.14.42"}`];\n if (wasm instanceof WebAssembly.Module) {\n WebAssembly.instantiate(wasm, go.importObject).then((instance) => go.run(instance));\n } else {\n WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));\n }\n };\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1773
|
+
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.0"}`];\n if (wasm instanceof WebAssembly.Module) {\n WebAssembly.instantiate(wasm, go.importObject).then((instance) => go.run(instance));\n } else {\n WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));\n }\n };\n return (m) => onmessage(m);\n })'}(postMessage)`], { type: "text/javascript" });
|
1745
1774
|
worker = new Worker(URL.createObjectURL(blob));
|
1746
1775
|
} else {
|
1747
1776
|
let onmessage = ((postMessage) => {
|
@@ -2036,13 +2065,16 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2036
2065
|
sp >>>= 0;
|
2037
2066
|
const id = this._nextCallbackTimeoutID;
|
2038
2067
|
this._nextCallbackTimeoutID++;
|
2039
|
-
this._scheduledTimeouts.set(id, setTimeout(
|
2040
|
-
|
2041
|
-
while (this._scheduledTimeouts.has(id)) {
|
2042
|
-
console.warn("scheduleTimeoutEvent: missed timeout event");
|
2068
|
+
this._scheduledTimeouts.set(id, setTimeout(
|
2069
|
+
() => {
|
2043
2070
|
this._resume();
|
2044
|
-
|
2045
|
-
|
2071
|
+
while (this._scheduledTimeouts.has(id)) {
|
2072
|
+
console.warn("scheduleTimeoutEvent: missed timeout event");
|
2073
|
+
this._resume();
|
2074
|
+
}
|
2075
|
+
},
|
2076
|
+
getInt64(sp + 8) + 1
|
2077
|
+
));
|
2046
2078
|
this.mem.setInt32(sp + 16, id, true);
|
2047
2079
|
},
|
2048
2080
|
"runtime.clearTimeoutEvent": (sp) => {
|
@@ -2320,7 +2352,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2320
2352
|
callback(null, count);
|
2321
2353
|
};
|
2322
2354
|
let go = new globalThis.Go();
|
2323
|
-
go.argv = ["", `--service=${"0.
|
2355
|
+
go.argv = ["", `--service=${"0.15.0"}`];
|
2324
2356
|
if (wasm instanceof WebAssembly.Module) {
|
2325
2357
|
WebAssembly.instantiate(wasm, go.importObject).then((instance) => go.run(instance));
|
2326
2358
|
} else {
|
@@ -2343,7 +2375,7 @@ var startRunningService = async (wasmURL, wasmModule, useWorker) => {
|
|
2343
2375
|
worker.postMessage(bytes);
|
2344
2376
|
},
|
2345
2377
|
isSync: false,
|
2346
|
-
|
2378
|
+
isWriteUnavailable: true,
|
2347
2379
|
esbuild: browser_exports
|
2348
2380
|
});
|
2349
2381
|
longLivedService = {
|