@jsenv/core 30.2.0 → 30.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllable_child_process.mjs +1 -1
- package/dist/controllable_worker_thread.mjs +1 -1
- package/dist/js/execute_using_dynamic_import.js +2 -2
- package/dist/js/v8_coverage.js +4 -4
- package/dist/main.js +249 -91
- package/package.json +3 -3
- package/src/build/build.js +153 -44
- package/src/build/{inject_global_version_mappings.js → version_mappings_injection.js} +44 -33
- package/src/dev/file_service.js +12 -4
- package/src/kitchen/compat/features_compatibility.js +59 -0
- package/src/kitchen/kitchen.js +5 -1
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +13 -22
- package/src/plugins/transpilation/jsenv_plugin_import_meta_resolve.js +1 -5
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +1 -5
package/dist/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import { pathToFileURL, fileURLToPath } from "node:url";
|
|
|
3
3
|
import { chmod, stat, lstat, readdir, promises, unlink, openSync, closeSync, rmdir, readFile as readFile$1, readFileSync as readFileSync$1, watch, readdirSync, statSync, writeFile as writeFile$1, writeFileSync as writeFileSync$1, mkdirSync, createReadStream, existsSync, realpathSync } from "node:fs";
|
|
4
4
|
import crypto, { createHash } from "node:crypto";
|
|
5
5
|
import { dirname, extname } from "node:path";
|
|
6
|
-
import {
|
|
6
|
+
import { URL_META, filterV8Coverage } from "./js/v8_coverage.js";
|
|
7
7
|
import process$1, { memoryUsage } from "node:process";
|
|
8
8
|
import os, { networkInterfaces } from "node:os";
|
|
9
9
|
import tty from "node:tty";
|
|
@@ -7961,7 +7961,8 @@ const featuresCompatMap = {
|
|
|
7961
7961
|
edge: "89",
|
|
7962
7962
|
chrome: "89",
|
|
7963
7963
|
opera: "76",
|
|
7964
|
-
samsung: "15"
|
|
7964
|
+
samsung: "15",
|
|
7965
|
+
firefox: "108"
|
|
7965
7966
|
},
|
|
7966
7967
|
import_type_json: {
|
|
7967
7968
|
chrome: "91",
|
|
@@ -8056,6 +8057,64 @@ const featuresCompatMap = {
|
|
|
8056
8057
|
ios: "9",
|
|
8057
8058
|
android: "4",
|
|
8058
8059
|
node: "4"
|
|
8060
|
+
},
|
|
8061
|
+
arrow_function: {
|
|
8062
|
+
chrome: "47",
|
|
8063
|
+
opera: "34",
|
|
8064
|
+
edge: "13",
|
|
8065
|
+
firefox: "45",
|
|
8066
|
+
safari: "10",
|
|
8067
|
+
node: "6",
|
|
8068
|
+
ios: "10",
|
|
8069
|
+
samsung: "5",
|
|
8070
|
+
electron: "0.36"
|
|
8071
|
+
},
|
|
8072
|
+
const_bindings: {
|
|
8073
|
+
chrome: "41",
|
|
8074
|
+
opera: "28",
|
|
8075
|
+
edge: "12",
|
|
8076
|
+
firefox: "46",
|
|
8077
|
+
safari: "10",
|
|
8078
|
+
node: "4",
|
|
8079
|
+
ie: "11",
|
|
8080
|
+
ios: "10",
|
|
8081
|
+
samsung: "3.4",
|
|
8082
|
+
electron: "0.22"
|
|
8083
|
+
},
|
|
8084
|
+
object_properties_shorthand: {
|
|
8085
|
+
chrome: "43",
|
|
8086
|
+
opera: "30",
|
|
8087
|
+
edge: "12",
|
|
8088
|
+
firefox: "33",
|
|
8089
|
+
safari: "9",
|
|
8090
|
+
node: "4",
|
|
8091
|
+
ios: "9",
|
|
8092
|
+
samsung: "4",
|
|
8093
|
+
electron: "0.28"
|
|
8094
|
+
},
|
|
8095
|
+
reserved_words: {
|
|
8096
|
+
chrome: "13",
|
|
8097
|
+
opera: "10.50",
|
|
8098
|
+
edge: "12",
|
|
8099
|
+
firefox: "2",
|
|
8100
|
+
safari: "3.1",
|
|
8101
|
+
node: "0.10",
|
|
8102
|
+
ie: "9",
|
|
8103
|
+
android: "4.4",
|
|
8104
|
+
ios: "6",
|
|
8105
|
+
phantom: "2",
|
|
8106
|
+
samsung: "1",
|
|
8107
|
+
electron: "0.20"
|
|
8108
|
+
},
|
|
8109
|
+
symbols: {
|
|
8110
|
+
chrome: "38",
|
|
8111
|
+
opera: "25",
|
|
8112
|
+
edge: "12",
|
|
8113
|
+
firefox: "36",
|
|
8114
|
+
safari: "9",
|
|
8115
|
+
ios: "9",
|
|
8116
|
+
samsung: "4",
|
|
8117
|
+
node: "0.12"
|
|
8059
8118
|
}
|
|
8060
8119
|
};
|
|
8061
8120
|
|
|
@@ -8491,14 +8550,16 @@ const createKitchen = ({
|
|
|
8491
8550
|
signal,
|
|
8492
8551
|
logLevel,
|
|
8493
8552
|
rootDirectoryUrl,
|
|
8553
|
+
urlGraph,
|
|
8494
8554
|
dev = false,
|
|
8495
8555
|
build = false,
|
|
8496
8556
|
runtimeCompat,
|
|
8497
8557
|
// during dev/test clientRuntimeCompat is a single runtime
|
|
8498
8558
|
// during build clientRuntimeCompat is runtimeCompat
|
|
8499
8559
|
clientRuntimeCompat = runtimeCompat,
|
|
8500
|
-
|
|
8560
|
+
systemJsTranspilation,
|
|
8501
8561
|
plugins,
|
|
8562
|
+
minification,
|
|
8502
8563
|
sourcemaps = dev ? "inline" : "none",
|
|
8503
8564
|
// "programmatic" and "file" also allowed
|
|
8504
8565
|
sourcemapsSourcesProtocol,
|
|
@@ -8519,12 +8580,14 @@ const createKitchen = ({
|
|
|
8519
8580
|
build,
|
|
8520
8581
|
runtimeCompat,
|
|
8521
8582
|
clientRuntimeCompat,
|
|
8583
|
+
systemJsTranspilation,
|
|
8522
8584
|
isSupportedOnCurrentClients: feature => {
|
|
8523
8585
|
return RUNTIME_COMPAT.isSupported(clientRuntimeCompat, feature);
|
|
8524
8586
|
},
|
|
8525
8587
|
isSupportedOnFutureClients: feature => {
|
|
8526
8588
|
return RUNTIME_COMPAT.isSupported(runtimeCompat, feature);
|
|
8527
8589
|
},
|
|
8590
|
+
minification,
|
|
8528
8591
|
sourcemaps,
|
|
8529
8592
|
outDirectoryUrl
|
|
8530
8593
|
};
|
|
@@ -10867,7 +10930,7 @@ const babelPluginTransformImportMetaResolve = () => {
|
|
|
10867
10930
|
};
|
|
10868
10931
|
|
|
10869
10932
|
// eslint-disable-next-line import/no-default-export
|
|
10870
|
-
var helpers_string_1 = '// A type of promise-like that resolves synchronously and supports only one observer\nexport const _Pact = /*#__PURE__*/(function() {\n\tfunction _Pact() {}\n\t_Pact.prototype.then = function(onFulfilled, onRejected) {\n\t\tconst result = new _Pact();\n\t\tconst state = this.s;\n\t\tif (state) {\n\t\t\tconst callback = state & 1 ? onFulfilled : onRejected;\n\t\t\tif (callback) {\n\t\t\t\ttry {\n\t\t\t\t\t_settle(result, 1, callback(this.v));\n\t\t\t\t} catch (e) {\n\t\t\t\t\t_settle(result, 2, e);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t\tthis.o = function(_this) {\n\t\t\ttry {\n\t\t\t\tconst value = _this.v;\n\t\t\t\tif (_this.s & 1) {\n\t\t\t\t\t_settle(result, 1, onFulfilled ? onFulfilled(value) : value);\n\t\t\t\t} else if (onRejected) {\n\t\t\t\t\t_settle(result, 1, onRejected(value));\n\t\t\t\t} else {\n\t\t\t\t\t_settle(result, 2, value);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t_settle(result, 2, e);\n\t\t\t}\n\t\t};\n\t\treturn result;\n\t}\n\treturn _Pact;\n})();\n\n// Settles a pact synchronously\nexport function _settle(pact, state, value) {\n\tif (!pact.s) {\n\t\tif (value instanceof _Pact) {\n\t\t\tif (value.s) {\n\t\t\t\tif (state & 1) {\n\t\t\t\t\tstate = value.s;\n\t\t\t\t}\n\t\t\t\tvalue = value.v;\n\t\t\t} else {\n\t\t\t\tvalue.o = _settle.bind(null, pact, state);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (value && value.then) {\n\t\t\tvalue.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));\n\t\t\treturn;\n\t\t}\n\t\tpact.s = state;\n\t\tpact.v = value;\n\t\tconst observer = pact.o;\n\t\tif (observer) {\n\t\t\tobserver(pact);\n\t\t}\n\t}\n}\n\nexport function _isSettledPact(thenable) {\n\treturn thenable instanceof _Pact && thenable.s & 1;\n}\n\n// Converts argument to a function that always returns a Promise\nexport function _async(f) {\n\treturn function() {\n\t\tfor (var args = [], i = 0; i < arguments.length; i++) {\n\t\t\targs[i] = arguments[i];\n\t\t}\n\t\ttry {\n\t\t\treturn Promise.resolve(f.apply(this, args));\n\t\t} catch(e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n}\n\n// Awaits on a value that may or may not be a Promise (equivalent to the await keyword in ES2015, with continuations passed explicitly)\nexport function _await(value, then, direct) {\n\tif (direct) {\n\t\treturn then ? then(value) : value;\n\t}\n\tif (!value || !value.then) {\n\t\tvalue = Promise.resolve(value);\n\t}\n\treturn then ? value.then(then) : value;\n}\n\n// Awaits on a value that may or may not be a Promise, then ignores it\nexport function _awaitIgnored(value, direct) {\n\tif (!direct) {\n\t\treturn value && value.then ? value.then(_empty) : Promise.resolve();\n\t}\n}\n\n// Proceeds after a value has resolved, or proceeds immediately if the value is not thenable\nexport function _continue(value, then) {\n\treturn value && value.then ? value.then(then) : then(value);\n}\n\n// Proceeds after a value has resolved, or proceeds immediately if the value is not thenable\nexport function _continueIgnored(value) {\n\tif (value && value.then) {\n\t\treturn value.then(_empty);\n\t}\n}\n\n// Asynchronously iterate through an object that has a length property, passing the index as the first argument to the callback (even as the length property changes)\nexport function _forTo(array, body, check) {\n\tvar i = -1, pact, reject;\n\tfunction _cycle(result) {\n\t\ttry {\n\t\t\twhile (++i < array.length && (!check || !check())) {\n\t\t\t\tresult = body(i);\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pact) {\n\t\t\t\t_settle(pact, 1, result);\n\t\t\t} else {\n\t\t\t\tpact = result;\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t_settle(pact || (pact = new _Pact()), 2, e);\n\t\t}\n\t}\n\t_cycle();\n\treturn pact;\n}\n\n// Asynchronously iterate through an object\'s properties (including properties inherited from the prototype)\n// Uses a snapshot of the object\'s properties\nexport function _forIn(target, body, check) {\n\tvar keys = [];\n\tfor (var key in target) {\n\t\tkeys.push(key);\n\t}\n\treturn _forTo(keys, function(i) { return body(keys[i]); }, check);\n}\n\n// Asynchronously iterate through an object\'s own properties (excluding properties inherited from the prototype)\n// Uses a snapshot of the object\'s properties\nexport function _forOwn(target, body, check) {\n\tvar keys = [];\n\tfor (var key in target) {\n\t\tif (Object.prototype.hasOwnProperty.call(target, key)) {\n\t\t\tkeys.push(key);\n\t\t}\n\t}\n\treturn _forTo(keys, function(i) { return body(keys[i]); }, check);\n}\n\nexport const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";\n\n// Asynchronously iterate through an object\'s values\n// Uses for...of if the runtime supports it, otherwise iterates until length on a copy\nexport function _forOf(target, body, check) {\n\tif (typeof target[_iteratorSymbol] === "function") {\n\t\tvar iterator = target[_iteratorSymbol](), step, pact, reject;\n\t\tfunction _cycle(result) {\n\t\t\ttry {\n\t\t\t\twhile (!(step = iterator.next()).done && (!check || !check())) {\n\t\t\t\t\tresult = body(step.value);\n\t\t\t\t\tif (result && result.then) {\n\t\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (pact) {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t} else {\n\t\t\t\t\tpact = result;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t_settle(pact || (pact = new _Pact()), 2, e);\n\t\t\t}\n\t\t}\n\t\t_cycle();\n\t\tif (iterator.return) {\n\t\t\tvar _fixup = function(value) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!step.done) {\n\t\t\t\t\t\titerator.return();\n\t\t\t\t\t}\n\t\t\t\t} catch(e) {\n\t\t\t\t}\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (pact && pact.then) {\n\t\t\t\treturn pact.then(_fixup, function(e) {\n\t\t\t\t\tthrow _fixup(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\t_fixup();\n\t\t}\n\t\treturn pact;\n\t}\n\t// No support for Symbol.iterator\n\tif (!("length" in target)) {\n\t\tthrow new TypeError("Object is not iterable");\n\t}\n\t// Handle live collections properly\n\tvar values = [];\n\tfor (var i = 0; i < target.length; i++) {\n\t\tvalues.push(target[i]);\n\t}\n\treturn _forTo(values, function(i) { return body(values[i]); }, check);\n}\n\nexport const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";\n\n// Asynchronously iterate on a value using it\'s async iterator if present, or its synchronous iterator if missing\nexport function _forAwaitOf(target, body, check) {\n\tif (typeof target[_asyncIteratorSymbol] === "function") {\n\t\tvar pact = new _Pact();\n\t\tvar iterator = target[_asyncIteratorSymbol]();\n\t\titerator.next().then(_resumeAfterNext).then(void 0, _reject);\n\t\treturn pact;\n\t\tfunction _resumeAfterBody(result) {\n\t\t\tif (check && check()) {\n\t\t\t\treturn _settle(pact, 1, iterator.return ? iterator.return().then(function() { return result; }) : result);\n\t\t\t}\n\t\t\titerator.next().then(_resumeAfterNext).then(void 0, _reject);\n\t\t}\n\t\tfunction _resumeAfterNext(step) {\n\t\t\tif (step.done) {\n\t\t\t\t_settle(pact, 1);\n\t\t\t} else {\n\t\t\t\tPromise.resolve(body(step.value)).then(_resumeAfterBody).then(void 0, _reject);\n\t\t\t}\n\t\t}\n\t\tfunction _reject(error) {\n\t\t\t_settle(pact, 2, iterator.return ? iterator.return().then(function() { return error; }) : error);\n\t\t}\n\t}\n\treturn Promise.resolve(_forOf(target, function(value) { return Promise.resolve(value).then(body); }, check));\n}\n\n// Asynchronously implement a generic for loop\nexport function _for(test, update, body) {\n\tvar stage;\n\tfor (;;) {\n\t\tvar shouldContinue = test();\n\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\tshouldContinue = shouldContinue.v;\n\t\t}\n\t\tif (!shouldContinue) {\n\t\t\treturn result;\n\t\t}\n\t\tif (shouldContinue.then) {\n\t\t\tstage = 0;\n\t\t\tbreak;\n\t\t}\n\t\tvar result = body();\n\t\tif (result && result.then) {\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.s;\n\t\t\t} else {\n\t\t\t\tstage = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (update) {\n\t\t\tvar updateValue = update();\n\t\t\tif (updateValue && updateValue.then && !_isSettledPact(updateValue)) {\n\t\t\t\tstage = 2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tvar pact = new _Pact();\n\tvar reject = _settle.bind(null, pact, 2);\n\t(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterBody(value) {\n\t\tresult = value;\n\t\tdo {\n\t\t\tif (update) {\n\t\t\t\tupdateValue = update();\n\t\t\t\tif (updateValue && updateValue.then && !_isSettledPact(updateValue)) {\n\t\t\t\t\tupdateValue.then(_resumeAfterUpdate).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tshouldContinue = test();\n\t\t\tif (!shouldContinue || (_isSettledPact(shouldContinue) && !shouldContinue.v)) {\n\t\t\t\t_settle(pact, 1, result);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.v;\n\t\t\t}\n\t\t} while (!result || !result.then);\n\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t}\n\tfunction _resumeAfterTest(shouldContinue) {\n\t\tif (shouldContinue) {\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t} else {\n\t\t\t\t_resumeAfterBody(result);\n\t\t\t}\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n\tfunction _resumeAfterUpdate() {\n\t\tif (shouldContinue = test()) {\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t} else {\n\t\t\t\t_resumeAfterTest(shouldContinue);\n\t\t\t}\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n}\n\n// Asynchronously implement a do ... while loop\nexport function _do(body, test) {\n\tvar awaitBody;\n\tdo {\n\t\tvar result = body();\n\t\tif (result && result.then) {\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.v;\n\t\t\t} else {\n\t\t\t\tawaitBody = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tvar shouldContinue = test();\n\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\tshouldContinue = shouldContinue.v;\n\t\t}\n\t\tif (!shouldContinue) {\n\t\t\treturn result;\n\t\t}\n\t} while (!shouldContinue.then);\n\tconst pact = new _Pact();\n\tconst reject = _settle.bind(null, pact, 2);\n\t(awaitBody ? result.then(_resumeAfterBody) : shouldContinue.then(_resumeAfterTest)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterBody(value) {\n\t\tresult = value;\n\t\tfor (;;) {\n\t\t\tshouldContinue = test();\n\t\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\t\tshouldContinue = shouldContinue.v;\n\t\t\t}\n\t\t\tif (!shouldContinue) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\tresult = result.v;\n\t\t\t\t} else {\n\t\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_settle(pact, 1, result);\n\t}\n\tfunction _resumeAfterTest(shouldContinue) {\n\t\tif (shouldContinue) {\n\t\t\tdo {\n\t\t\t\tresult = body();\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tshouldContinue = test();\n\t\t\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\t\t\tshouldContinue = shouldContinue.v;\n\t\t\t\t}\n\t\t\t\tif (!shouldContinue) {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} while (!shouldContinue.then);\n\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n}\n\n// Asynchronously implement a switch statement\nexport function _switch(discriminant, cases) {\n\tvar dispatchIndex = -1;\n\tvar awaitBody;\n\touter: {\n\t\tfor (var i = 0; i < cases.length; i++) {\n\t\t\tvar test = cases[i][0];\n\t\t\tif (test) {\n\t\t\t\tvar testValue = test();\n\t\t\t\tif (testValue && testValue.then) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t\tif (testValue === discriminant) {\n\t\t\t\t\tdispatchIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Found the default case, set it as the pending dispatch case\n\t\t\t\tdispatchIndex = i;\n\t\t\t}\n\t\t}\n\t\tif (dispatchIndex !== -1) {\n\t\t\tdo {\n\t\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\t\twhile (!body) {\n\t\t\t\t\tdispatchIndex++;\n\t\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t\t}\n\t\t\t\tvar result = body();\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tawaitBody = true;\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\t\tdispatchIndex++;\n\t\t\t} while (fallthroughCheck && !fallthroughCheck());\n\t\t\treturn result;\n\t\t}\n\t}\n\tconst pact = new _Pact();\n\tconst reject = _settle.bind(null, pact, 2);\n\t(awaitBody ? result.then(_resumeAfterBody) : testValue.then(_resumeAfterTest)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterTest(value) {\n\t\tfor (;;) {\n\t\t\tif (value === discriminant) {\n\t\t\t\tdispatchIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (++i === cases.length) {\n\t\t\t\tif (dispatchIndex !== -1) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttest = cases[i][0];\n\t\t\tif (test) {\n\t\t\t\tvalue = test();\n\t\t\t\tif (value && value.then) {\n\t\t\t\t\tvalue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdispatchIndex = i;\n\t\t\t}\n\t\t}\n\t\tdo {\n\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\twhile (!body) {\n\t\t\t\tdispatchIndex++;\n\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t}\n\t\t\tvar result = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\tdispatchIndex++;\n\t\t} while (fallthroughCheck && !fallthroughCheck());\n\t\t_settle(pact, 1, result);\n\t}\n\tfunction _resumeAfterBody(result) {\n\t\tfor (;;) {\n\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\tif (!fallthroughCheck || fallthroughCheck()) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdispatchIndex++;\n\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\twhile (!body) {\n\t\t\t\tdispatchIndex++;\n\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t_settle(pact, 1, result);\n\t}\n}\n\n// Asynchronously call a function and pass the result to explicitly passed continuations\nexport function _call(body, then, direct) {\n\tif (direct) {\n\t\treturn then ? then(body()) : body();\n\t}\n\ttry {\n\t\tvar result = Promise.resolve(body());\n\t\treturn then ? result.then(then) : result;\n\t} catch (e) {\n\t\treturn Promise.reject(e);\n\t}\n}\n\n// Asynchronously call a function and swallow the result\nexport function _callIgnored(body, direct) {\n\treturn _call(body, _empty, direct);\n}\n\n// Asynchronously call a function and pass the result to explicitly passed continuations\nexport function _invoke(body, then) {\n\tvar result = body();\n\tif (result && result.then) {\n\t\treturn result.then(then);\n\t}\n\treturn then(result);\n}\n\n// Asynchronously call a function and swallow the result\nexport function _invokeIgnored(body) {\n\tvar result = body();\n\tif (result && result.then) {\n\t\treturn result.then(_empty);\n\t}\n}\n\n// Asynchronously call a function and send errors to recovery continuation\nexport function _catch(body, recover) {\n\ttry {\n\t\tvar result = body();\n\t} catch(e) {\n\t\treturn recover(e);\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(void 0, recover);\n\t}\n\treturn result;\n}\n\n// Asynchronously await a promise and pass the result to a finally continuation\nexport function _finallyRethrows(body, finalizer) {\n\ttry {\n\t\tvar result = body();\n\t} catch (e) {\n\t\treturn finalizer(true, e);\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(finalizer.bind(null, false), finalizer.bind(null, true));\n\t}\n\treturn finalizer(false, result);\n}\n\n// Asynchronously await a promise and invoke a finally continuation that always overrides the result\nexport function _finally(body, finalizer) {\n\ttry {\n\t\tvar result = body();\n\t} catch (e) {\n\t\treturn finalizer();\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(finalizer, finalizer);\n\t}\n\treturn finalizer();\n}\n\n// Rethrow or return a value from a finally continuation\nexport function _rethrow(thrown, value) {\n\tif (thrown)\n\t\tthrow value;\n\treturn value;\n}\n\n// Empty function to implement break and other control flow that ignores asynchronous results\nexport function _empty() {\n}\n\n// Sentinel value for early returns in generators \nexport const _earlyReturn = /*#__PURE__*/ {};\n\n// Asynchronously call a function and send errors to recovery continuation, skipping early returns\nexport function _catchInGenerator(body, recover) {\n\treturn _catch(body, function(e) {\n\t\tif (e === _earlyReturn) {\n\t\t\tthrow e;\n\t\t}\n\t\treturn recover(e);\n\t});\n}\n\n// Asynchronous generator class; accepts the entrypoint of the generator, to which it passes itself when the generator should start\nexport const _AsyncGenerator = /*#__PURE__*/(function() {\n\tfunction _AsyncGenerator(entry) {\n\t\tthis._entry = entry;\n\t\tthis._pact = null;\n\t\tthis._resolve = null;\n\t\tthis._return = null;\n\t\tthis._promise = null;\n\t}\n\n\tfunction _wrapReturnedValue(value) {\n\t\treturn { value: value, done: true };\n\t}\n\tfunction _wrapYieldedValue(value) {\n\t\treturn { value: value, done: false };\n\t}\n\n\t_AsyncGenerator.prototype._yield = function(value) {\n\t\t// Yield the value to the pending next call\n\t\tthis._resolve(value && value.then ? value.then(_wrapYieldedValue) : _wrapYieldedValue(value));\n\t\t// Return a pact for an upcoming next/return/throw call\n\t\treturn this._pact = new _Pact();\n\t};\n\t_AsyncGenerator.prototype.next = function(value) {\n\t\t// Advance the generator, starting it if it has yet to be started\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tconst _entry = _this._entry;\n\t\t\t\tif (_entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the next call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Start the generator\n\t\t\t\t_this._entry = null;\n\t\t\t\t_this._resolve = resolve;\n\t\t\t\tfunction returnValue(value) {\n\t\t\t\t\t_this._resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value));\n\t\t\t\t\t_this._pact = null;\n\t\t\t\t\t_this._resolve = null;\n\t\t\t\t}\n\t\t\t\tvar result = _entry(_this);\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tresult.then(returnValue, function(error) {\n\t\t\t\t\t\tif (error === _earlyReturn) {\n\t\t\t\t\t\t\treturnValue(_this._return);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst pact = new _Pact();\n\t\t\t\t\t\t\t_this._resolve(pact);\n\t\t\t\t\t\t\t_this._pact = null;\n\t\t\t\t\t\t\t_this._resolve = null;\n\t\t\t\t\t\t\t_resolve(pact, 2, error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturnValue(result);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Generator is started and a yield expression is pending, settle it\n\t\t\t\t_this._pact = null;\n\t\t\t\t_this._resolve = resolve;\n\t\t\t\t_settle(_pact, 1, value);\n\t\t\t}\n\t\t});\n\t};\n\t_AsyncGenerator.prototype.return = function(value) {\n\t\t// Early return from the generator if started, otherwise abandons the generator\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tif (_this._entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the return call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Generator is not started, abandon it and return the specified value\n\t\t\t\t_this._entry = null;\n\t\t\t\treturn resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value));\n\t\t\t}\n\t\t\t// Settle the yield expression with a rejected "early return" value\n\t\t\t_this._return = value;\n\t\t\t_this._resolve = resolve;\n\t\t\t_this._pact = null;\n\t\t\t_settle(_pact, 2, _earlyReturn);\n\t\t});\n\t};\n\t_AsyncGenerator.prototype.throw = function(error) {\n\t\t// Inject an exception into the pending yield expression\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve, reject) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tif (_this._entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the throw call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Generator is not started, abandon it and return a rejected Promise containing the error\n\t\t\t\t_this._entry = null;\n\t\t\t\treturn reject(error);\n\t\t\t}\n\t\t\t// Settle the yield expression with the value as a rejection\n\t\t\t_this._resolve = resolve;\n\t\t\t_this._pact = null;\n\t\t\t_settle(_pact, 2, error);\n\t\t});\n\t};\n\n\t_AsyncGenerator.prototype[_asyncIteratorSymbol] = function() {\n\t\treturn this;\n\t};\n\t\n\treturn _AsyncGenerator;\n})();\n';
|
|
10933
|
+
const helpers_string_1 = '// A type of promise-like that resolves synchronously and supports only one observer\nexport const _Pact = /*#__PURE__*/(function() {\n\tfunction _Pact() {}\n\t_Pact.prototype.then = function(onFulfilled, onRejected) {\n\t\tconst result = new _Pact();\n\t\tconst state = this.s;\n\t\tif (state) {\n\t\t\tconst callback = state & 1 ? onFulfilled : onRejected;\n\t\t\tif (callback) {\n\t\t\t\ttry {\n\t\t\t\t\t_settle(result, 1, callback(this.v));\n\t\t\t\t} catch (e) {\n\t\t\t\t\t_settle(result, 2, e);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t\tthis.o = function(_this) {\n\t\t\ttry {\n\t\t\t\tconst value = _this.v;\n\t\t\t\tif (_this.s & 1) {\n\t\t\t\t\t_settle(result, 1, onFulfilled ? onFulfilled(value) : value);\n\t\t\t\t} else if (onRejected) {\n\t\t\t\t\t_settle(result, 1, onRejected(value));\n\t\t\t\t} else {\n\t\t\t\t\t_settle(result, 2, value);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t_settle(result, 2, e);\n\t\t\t}\n\t\t};\n\t\treturn result;\n\t}\n\treturn _Pact;\n})();\n\n// Settles a pact synchronously\nexport function _settle(pact, state, value) {\n\tif (!pact.s) {\n\t\tif (value instanceof _Pact) {\n\t\t\tif (value.s) {\n\t\t\t\tif (state & 1) {\n\t\t\t\t\tstate = value.s;\n\t\t\t\t}\n\t\t\t\tvalue = value.v;\n\t\t\t} else {\n\t\t\t\tvalue.o = _settle.bind(null, pact, state);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (value && value.then) {\n\t\t\tvalue.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));\n\t\t\treturn;\n\t\t}\n\t\tpact.s = state;\n\t\tpact.v = value;\n\t\tconst observer = pact.o;\n\t\tif (observer) {\n\t\t\tobserver(pact);\n\t\t}\n\t}\n}\n\nexport function _isSettledPact(thenable) {\n\treturn thenable instanceof _Pact && thenable.s & 1;\n}\n\n// Converts argument to a function that always returns a Promise\nexport function _async(f) {\n\treturn function() {\n\t\tfor (var args = [], i = 0; i < arguments.length; i++) {\n\t\t\targs[i] = arguments[i];\n\t\t}\n\t\ttry {\n\t\t\treturn Promise.resolve(f.apply(this, args));\n\t\t} catch(e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n}\n\n// Awaits on a value that may or may not be a Promise (equivalent to the await keyword in ES2015, with continuations passed explicitly)\nexport function _await(value, then, direct) {\n\tif (direct) {\n\t\treturn then ? then(value) : value;\n\t}\n\tif (!value || !value.then) {\n\t\tvalue = Promise.resolve(value);\n\t}\n\treturn then ? value.then(then) : value;\n}\n\n// Awaits on a value that may or may not be a Promise, then ignores it\nexport function _awaitIgnored(value, direct) {\n\tif (!direct) {\n\t\treturn value && value.then ? value.then(_empty) : Promise.resolve();\n\t}\n}\n\n// Proceeds after a value has resolved, or proceeds immediately if the value is not thenable\nexport function _continue(value, then) {\n\treturn value && value.then ? value.then(then) : then(value);\n}\n\n// Proceeds after a value has resolved, or proceeds immediately if the value is not thenable\nexport function _continueIgnored(value) {\n\tif (value && value.then) {\n\t\treturn value.then(_empty);\n\t}\n}\n\n// Asynchronously iterate through an object that has a length property, passing the index as the first argument to the callback (even as the length property changes)\nexport function _forTo(array, body, check) {\n\tvar i = -1, pact, reject;\n\tfunction _cycle(result) {\n\t\ttry {\n\t\t\twhile (++i < array.length && (!check || !check())) {\n\t\t\t\tresult = body(i);\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pact) {\n\t\t\t\t_settle(pact, 1, result);\n\t\t\t} else {\n\t\t\t\tpact = result;\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t_settle(pact || (pact = new _Pact()), 2, e);\n\t\t}\n\t}\n\t_cycle();\n\treturn pact;\n}\n\n// Asynchronously iterate through an object\'s properties (including properties inherited from the prototype)\n// Uses a snapshot of the object\'s properties\nexport function _forIn(target, body, check) {\n\tvar keys = [];\n\tfor (var key in target) {\n\t\tkeys.push(key);\n\t}\n\treturn _forTo(keys, function(i) { return body(keys[i]); }, check);\n}\n\n// Asynchronously iterate through an object\'s own properties (excluding properties inherited from the prototype)\n// Uses a snapshot of the object\'s properties\nexport function _forOwn(target, body, check) {\n\tvar keys = [];\n\tfor (var key in target) {\n\t\tif (Object.prototype.hasOwnProperty.call(target, key)) {\n\t\t\tkeys.push(key);\n\t\t}\n\t}\n\treturn _forTo(keys, function(i) { return body(keys[i]); }, check);\n}\n\nexport const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";\n\n// Asynchronously iterate through an object\'s values\n// Uses for...of if the runtime supports it, otherwise iterates until length on a copy\nexport function _forOf(target, body, check) {\n\tif (typeof target[_iteratorSymbol] === "function") {\n\t\tvar iterator = target[_iteratorSymbol](), step, pact, reject;\n\t\tfunction _cycle(result) {\n\t\t\ttry {\n\t\t\t\twhile (!(step = iterator.next()).done && (!check || !check())) {\n\t\t\t\t\tresult = body(step.value);\n\t\t\t\t\tif (result && result.then) {\n\t\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (pact) {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t} else {\n\t\t\t\t\tpact = result;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t_settle(pact || (pact = new _Pact()), 2, e);\n\t\t\t}\n\t\t}\n\t\t_cycle();\n\t\tif (iterator.return) {\n\t\t\tvar _fixup = function(value) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!step.done) {\n\t\t\t\t\t\titerator.return();\n\t\t\t\t\t}\n\t\t\t\t} catch(e) {\n\t\t\t\t}\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (pact && pact.then) {\n\t\t\t\treturn pact.then(_fixup, function(e) {\n\t\t\t\t\tthrow _fixup(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\t_fixup();\n\t\t}\n\t\treturn pact;\n\t}\n\t// No support for Symbol.iterator\n\tif (!("length" in target)) {\n\t\tthrow new TypeError("Object is not iterable");\n\t}\n\t// Handle live collections properly\n\tvar values = [];\n\tfor (var i = 0; i < target.length; i++) {\n\t\tvalues.push(target[i]);\n\t}\n\treturn _forTo(values, function(i) { return body(values[i]); }, check);\n}\n\nexport const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";\n\n// Asynchronously iterate on a value using it\'s async iterator if present, or its synchronous iterator if missing\nexport function _forAwaitOf(target, body, check) {\n\tif (typeof target[_asyncIteratorSymbol] === "function") {\n\t\tvar pact = new _Pact();\n\t\tvar iterator = target[_asyncIteratorSymbol]();\n\t\titerator.next().then(_resumeAfterNext).then(void 0, _reject);\n\t\treturn pact;\n\t\tfunction _resumeAfterBody(result) {\n\t\t\tif (check && check()) {\n\t\t\t\treturn _settle(pact, 1, iterator.return ? iterator.return().then(function() { return result; }) : result);\n\t\t\t}\n\t\t\titerator.next().then(_resumeAfterNext).then(void 0, _reject);\n\t\t}\n\t\tfunction _resumeAfterNext(step) {\n\t\t\tif (step.done) {\n\t\t\t\t_settle(pact, 1);\n\t\t\t} else {\n\t\t\t\tPromise.resolve(body(step.value)).then(_resumeAfterBody).then(void 0, _reject);\n\t\t\t}\n\t\t}\n\t\tfunction _reject(error) {\n\t\t\t_settle(pact, 2, iterator.return ? iterator.return().then(function() { return error; }) : error);\n\t\t}\n\t}\n\treturn Promise.resolve(_forOf(target, function(value) { return Promise.resolve(value).then(body); }, check));\n}\n\n// Asynchronously implement a generic for loop\nexport function _for(test, update, body) {\n\tvar stage;\n\tfor (;;) {\n\t\tvar shouldContinue = test();\n\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\tshouldContinue = shouldContinue.v;\n\t\t}\n\t\tif (!shouldContinue) {\n\t\t\treturn result;\n\t\t}\n\t\tif (shouldContinue.then) {\n\t\t\tstage = 0;\n\t\t\tbreak;\n\t\t}\n\t\tvar result = body();\n\t\tif (result && result.then) {\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.s;\n\t\t\t} else {\n\t\t\t\tstage = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (update) {\n\t\t\tvar updateValue = update();\n\t\t\tif (updateValue && updateValue.then && !_isSettledPact(updateValue)) {\n\t\t\t\tstage = 2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tvar pact = new _Pact();\n\tvar reject = _settle.bind(null, pact, 2);\n\t(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterBody(value) {\n\t\tresult = value;\n\t\tdo {\n\t\t\tif (update) {\n\t\t\t\tupdateValue = update();\n\t\t\t\tif (updateValue && updateValue.then && !_isSettledPact(updateValue)) {\n\t\t\t\t\tupdateValue.then(_resumeAfterUpdate).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tshouldContinue = test();\n\t\t\tif (!shouldContinue || (_isSettledPact(shouldContinue) && !shouldContinue.v)) {\n\t\t\t\t_settle(pact, 1, result);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.v;\n\t\t\t}\n\t\t} while (!result || !result.then);\n\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t}\n\tfunction _resumeAfterTest(shouldContinue) {\n\t\tif (shouldContinue) {\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t} else {\n\t\t\t\t_resumeAfterBody(result);\n\t\t\t}\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n\tfunction _resumeAfterUpdate() {\n\t\tif (shouldContinue = test()) {\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t} else {\n\t\t\t\t_resumeAfterTest(shouldContinue);\n\t\t\t}\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n}\n\n// Asynchronously implement a do ... while loop\nexport function _do(body, test) {\n\tvar awaitBody;\n\tdo {\n\t\tvar result = body();\n\t\tif (result && result.then) {\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.v;\n\t\t\t} else {\n\t\t\t\tawaitBody = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tvar shouldContinue = test();\n\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\tshouldContinue = shouldContinue.v;\n\t\t}\n\t\tif (!shouldContinue) {\n\t\t\treturn result;\n\t\t}\n\t} while (!shouldContinue.then);\n\tconst pact = new _Pact();\n\tconst reject = _settle.bind(null, pact, 2);\n\t(awaitBody ? result.then(_resumeAfterBody) : shouldContinue.then(_resumeAfterTest)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterBody(value) {\n\t\tresult = value;\n\t\tfor (;;) {\n\t\t\tshouldContinue = test();\n\t\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\t\tshouldContinue = shouldContinue.v;\n\t\t\t}\n\t\t\tif (!shouldContinue) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\tresult = result.v;\n\t\t\t\t} else {\n\t\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_settle(pact, 1, result);\n\t}\n\tfunction _resumeAfterTest(shouldContinue) {\n\t\tif (shouldContinue) {\n\t\t\tdo {\n\t\t\t\tresult = body();\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tshouldContinue = test();\n\t\t\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\t\t\tshouldContinue = shouldContinue.v;\n\t\t\t\t}\n\t\t\t\tif (!shouldContinue) {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} while (!shouldContinue.then);\n\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n}\n\n// Asynchronously implement a switch statement\nexport function _switch(discriminant, cases) {\n\tvar dispatchIndex = -1;\n\tvar awaitBody;\n\touter: {\n\t\tfor (var i = 0; i < cases.length; i++) {\n\t\t\tvar test = cases[i][0];\n\t\t\tif (test) {\n\t\t\t\tvar testValue = test();\n\t\t\t\tif (testValue && testValue.then) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t\tif (testValue === discriminant) {\n\t\t\t\t\tdispatchIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Found the default case, set it as the pending dispatch case\n\t\t\t\tdispatchIndex = i;\n\t\t\t}\n\t\t}\n\t\tif (dispatchIndex !== -1) {\n\t\t\tdo {\n\t\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\t\twhile (!body) {\n\t\t\t\t\tdispatchIndex++;\n\t\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t\t}\n\t\t\t\tvar result = body();\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tawaitBody = true;\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\t\tdispatchIndex++;\n\t\t\t} while (fallthroughCheck && !fallthroughCheck());\n\t\t\treturn result;\n\t\t}\n\t}\n\tconst pact = new _Pact();\n\tconst reject = _settle.bind(null, pact, 2);\n\t(awaitBody ? result.then(_resumeAfterBody) : testValue.then(_resumeAfterTest)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterTest(value) {\n\t\tfor (;;) {\n\t\t\tif (value === discriminant) {\n\t\t\t\tdispatchIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (++i === cases.length) {\n\t\t\t\tif (dispatchIndex !== -1) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttest = cases[i][0];\n\t\t\tif (test) {\n\t\t\t\tvalue = test();\n\t\t\t\tif (value && value.then) {\n\t\t\t\t\tvalue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdispatchIndex = i;\n\t\t\t}\n\t\t}\n\t\tdo {\n\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\twhile (!body) {\n\t\t\t\tdispatchIndex++;\n\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t}\n\t\t\tvar result = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\tdispatchIndex++;\n\t\t} while (fallthroughCheck && !fallthroughCheck());\n\t\t_settle(pact, 1, result);\n\t}\n\tfunction _resumeAfterBody(result) {\n\t\tfor (;;) {\n\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\tif (!fallthroughCheck || fallthroughCheck()) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdispatchIndex++;\n\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\twhile (!body) {\n\t\t\t\tdispatchIndex++;\n\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t_settle(pact, 1, result);\n\t}\n}\n\n// Asynchronously call a function and pass the result to explicitly passed continuations\nexport function _call(body, then, direct) {\n\tif (direct) {\n\t\treturn then ? then(body()) : body();\n\t}\n\ttry {\n\t\tvar result = Promise.resolve(body());\n\t\treturn then ? result.then(then) : result;\n\t} catch (e) {\n\t\treturn Promise.reject(e);\n\t}\n}\n\n// Asynchronously call a function and swallow the result\nexport function _callIgnored(body, direct) {\n\treturn _call(body, _empty, direct);\n}\n\n// Asynchronously call a function and pass the result to explicitly passed continuations\nexport function _invoke(body, then) {\n\tvar result = body();\n\tif (result && result.then) {\n\t\treturn result.then(then);\n\t}\n\treturn then(result);\n}\n\n// Asynchronously call a function and swallow the result\nexport function _invokeIgnored(body) {\n\tvar result = body();\n\tif (result && result.then) {\n\t\treturn result.then(_empty);\n\t}\n}\n\n// Asynchronously call a function and send errors to recovery continuation\nexport function _catch(body, recover) {\n\ttry {\n\t\tvar result = body();\n\t} catch(e) {\n\t\treturn recover(e);\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(void 0, recover);\n\t}\n\treturn result;\n}\n\n// Asynchronously await a promise and pass the result to a finally continuation\nexport function _finallyRethrows(body, finalizer) {\n\ttry {\n\t\tvar result = body();\n\t} catch (e) {\n\t\treturn finalizer(true, e);\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(finalizer.bind(null, false), finalizer.bind(null, true));\n\t}\n\treturn finalizer(false, result);\n}\n\n// Asynchronously await a promise and invoke a finally continuation that always overrides the result\nexport function _finally(body, finalizer) {\n\ttry {\n\t\tvar result = body();\n\t} catch (e) {\n\t\treturn finalizer();\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(finalizer, finalizer);\n\t}\n\treturn finalizer();\n}\n\n// Rethrow or return a value from a finally continuation\nexport function _rethrow(thrown, value) {\n\tif (thrown)\n\t\tthrow value;\n\treturn value;\n}\n\n// Empty function to implement break and other control flow that ignores asynchronous results\nexport function _empty() {\n}\n\n// Sentinel value for early returns in generators \nexport const _earlyReturn = /*#__PURE__*/ {};\n\n// Asynchronously call a function and send errors to recovery continuation, skipping early returns\nexport function _catchInGenerator(body, recover) {\n\treturn _catch(body, function(e) {\n\t\tif (e === _earlyReturn) {\n\t\t\tthrow e;\n\t\t}\n\t\treturn recover(e);\n\t});\n}\n\n// Asynchronous generator class; accepts the entrypoint of the generator, to which it passes itself when the generator should start\nexport const _AsyncGenerator = /*#__PURE__*/(function() {\n\tfunction _AsyncGenerator(entry) {\n\t\tthis._entry = entry;\n\t\tthis._pact = null;\n\t\tthis._resolve = null;\n\t\tthis._return = null;\n\t\tthis._promise = null;\n\t}\n\n\tfunction _wrapReturnedValue(value) {\n\t\treturn { value: value, done: true };\n\t}\n\tfunction _wrapYieldedValue(value) {\n\t\treturn { value: value, done: false };\n\t}\n\n\t_AsyncGenerator.prototype._yield = function(value) {\n\t\t// Yield the value to the pending next call\n\t\tthis._resolve(value && value.then ? value.then(_wrapYieldedValue) : _wrapYieldedValue(value));\n\t\t// Return a pact for an upcoming next/return/throw call\n\t\treturn this._pact = new _Pact();\n\t};\n\t_AsyncGenerator.prototype.next = function(value) {\n\t\t// Advance the generator, starting it if it has yet to be started\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tconst _entry = _this._entry;\n\t\t\t\tif (_entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the next call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Start the generator\n\t\t\t\t_this._entry = null;\n\t\t\t\t_this._resolve = resolve;\n\t\t\t\tfunction returnValue(value) {\n\t\t\t\t\t_this._resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value));\n\t\t\t\t\t_this._pact = null;\n\t\t\t\t\t_this._resolve = null;\n\t\t\t\t}\n\t\t\t\tvar result = _entry(_this);\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tresult.then(returnValue, function(error) {\n\t\t\t\t\t\tif (error === _earlyReturn) {\n\t\t\t\t\t\t\treturnValue(_this._return);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst pact = new _Pact();\n\t\t\t\t\t\t\t_this._resolve(pact);\n\t\t\t\t\t\t\t_this._pact = null;\n\t\t\t\t\t\t\t_this._resolve = null;\n\t\t\t\t\t\t\t_resolve(pact, 2, error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturnValue(result);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Generator is started and a yield expression is pending, settle it\n\t\t\t\t_this._pact = null;\n\t\t\t\t_this._resolve = resolve;\n\t\t\t\t_settle(_pact, 1, value);\n\t\t\t}\n\t\t});\n\t};\n\t_AsyncGenerator.prototype.return = function(value) {\n\t\t// Early return from the generator if started, otherwise abandons the generator\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tif (_this._entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the return call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Generator is not started, abandon it and return the specified value\n\t\t\t\t_this._entry = null;\n\t\t\t\treturn resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value));\n\t\t\t}\n\t\t\t// Settle the yield expression with a rejected "early return" value\n\t\t\t_this._return = value;\n\t\t\t_this._resolve = resolve;\n\t\t\t_this._pact = null;\n\t\t\t_settle(_pact, 2, _earlyReturn);\n\t\t});\n\t};\n\t_AsyncGenerator.prototype.throw = function(error) {\n\t\t// Inject an exception into the pending yield expression\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve, reject) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tif (_this._entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the throw call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Generator is not started, abandon it and return a rejected Promise containing the error\n\t\t\t\t_this._entry = null;\n\t\t\t\treturn reject(error);\n\t\t\t}\n\t\t\t// Settle the yield expression with the value as a rejection\n\t\t\t_this._resolve = resolve;\n\t\t\t_this._pact = null;\n\t\t\t_settle(_pact, 2, error);\n\t\t});\n\t};\n\n\t_AsyncGenerator.prototype[_asyncIteratorSymbol] = function() {\n\t\treturn this;\n\t};\n\t\n\treturn _AsyncGenerator;\n})();\n';
|
|
10871
10934
|
|
|
10872
10935
|
const require = createRequire(import.meta.url);
|
|
10873
10936
|
const defaultConfigValues = {
|
|
@@ -14584,7 +14647,6 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14584
14647
|
systemJsInjection,
|
|
14585
14648
|
systemJsClientFileUrl
|
|
14586
14649
|
}) => {
|
|
14587
|
-
let shouldTransformScriptTypeModule;
|
|
14588
14650
|
const turnIntoJsClassicProxy = reference => {
|
|
14589
14651
|
return injectQueryParams(reference.url, {
|
|
14590
14652
|
as_js_classic: ""
|
|
@@ -14593,28 +14655,24 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14593
14655
|
return {
|
|
14594
14656
|
name: "jsenv:as_js_classic_html",
|
|
14595
14657
|
appliesDuring: "*",
|
|
14596
|
-
init: context => {
|
|
14597
|
-
const nodeRuntimeEnabled = Object.keys(context.runtimeCompat).includes("node");
|
|
14598
|
-
shouldTransformScriptTypeModule = nodeRuntimeEnabled ? false : !context.isSupportedOnCurrentClients("script_type_module") || !context.isSupportedOnCurrentClients("import_dynamic") || !context.isSupportedOnCurrentClients("import_meta");
|
|
14599
|
-
},
|
|
14600
14658
|
redirectUrl: {
|
|
14601
|
-
link_href: reference => {
|
|
14602
|
-
if (
|
|
14659
|
+
link_href: (reference, context) => {
|
|
14660
|
+
if (context.systemJsTranspilation && reference.subtype === "modulepreload") {
|
|
14603
14661
|
return turnIntoJsClassicProxy(reference);
|
|
14604
14662
|
}
|
|
14605
|
-
if (
|
|
14663
|
+
if (context.systemJsTranspilation && reference.subtype === "preload" && reference.expectedType === "js_module") {
|
|
14606
14664
|
return turnIntoJsClassicProxy(reference);
|
|
14607
14665
|
}
|
|
14608
14666
|
return null;
|
|
14609
14667
|
},
|
|
14610
|
-
script_src: reference => {
|
|
14611
|
-
if (
|
|
14668
|
+
script_src: (reference, context) => {
|
|
14669
|
+
if (context.systemJsTranspilation && reference.expectedType === "js_module") {
|
|
14612
14670
|
return turnIntoJsClassicProxy(reference);
|
|
14613
14671
|
}
|
|
14614
14672
|
return null;
|
|
14615
14673
|
},
|
|
14616
|
-
js_url: reference => {
|
|
14617
|
-
if (
|
|
14674
|
+
js_url: (reference, context) => {
|
|
14675
|
+
if (context.systemJsTranspilation && reference.expectedType === "js_module") {
|
|
14618
14676
|
return turnIntoJsClassicProxy(reference);
|
|
14619
14677
|
}
|
|
14620
14678
|
return null;
|
|
@@ -14638,7 +14696,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14638
14696
|
if (!isOrWasExpectingJsModule(reference)) {
|
|
14639
14697
|
return;
|
|
14640
14698
|
}
|
|
14641
|
-
if (rel === "modulepreload") {
|
|
14699
|
+
if (rel === "modulepreload" && reference.expectedType === "js_classic") {
|
|
14642
14700
|
mutations.push(() => {
|
|
14643
14701
|
setHtmlNodeAttributes(node, {
|
|
14644
14702
|
rel: "preload",
|
|
@@ -14647,7 +14705,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14647
14705
|
});
|
|
14648
14706
|
});
|
|
14649
14707
|
}
|
|
14650
|
-
if (rel === "preload") {
|
|
14708
|
+
if (rel === "preload" && reference.expectedType === "js_classic") {
|
|
14651
14709
|
mutations.push(() => {
|
|
14652
14710
|
setHtmlNodeAttributes(node, {
|
|
14653
14711
|
crossorigin: undefined
|
|
@@ -14675,7 +14733,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14675
14733
|
});
|
|
14676
14734
|
});
|
|
14677
14735
|
}
|
|
14678
|
-
} else if (
|
|
14736
|
+
} else if (context.systemJsTranspilation) {
|
|
14679
14737
|
mutations.push(() => {
|
|
14680
14738
|
setHtmlNodeAttributes(node, {
|
|
14681
14739
|
type: undefined
|
|
@@ -19085,8 +19143,7 @@ const jsenvPluginTopLevelAwait = () => {
|
|
|
19085
19143
|
return false;
|
|
19086
19144
|
}
|
|
19087
19145
|
// keep it untouched, systemjs will handle it
|
|
19088
|
-
|
|
19089
|
-
if (willTransformJsModules) {
|
|
19146
|
+
if (context.systemJsTranspilation) {
|
|
19090
19147
|
return false;
|
|
19091
19148
|
}
|
|
19092
19149
|
return true;
|
|
@@ -19168,9 +19225,8 @@ const jsenvPluginImportMetaResolve = () => {
|
|
|
19168
19225
|
if (context.isSupportedOnCurrentClients("import_meta_resolve")) {
|
|
19169
19226
|
return false;
|
|
19170
19227
|
}
|
|
19171
|
-
const willTransformJsModules = !context.isSupportedOnCurrentClients("script_type_module") || !context.isSupportedOnCurrentClients("import_dynamic") || !context.isSupportedOnCurrentClients("import_meta");
|
|
19172
19228
|
// keep it untouched, systemjs will handle it
|
|
19173
|
-
if (
|
|
19229
|
+
if (context.systemJsTranspilation) {
|
|
19174
19230
|
return false;
|
|
19175
19231
|
}
|
|
19176
19232
|
return true;
|
|
@@ -20268,11 +20324,10 @@ const determineDirectoryPath = ({
|
|
|
20268
20324
|
};
|
|
20269
20325
|
|
|
20270
20326
|
// https://bundlers.tooling.report/hashing/avoid-cascade/
|
|
20271
|
-
const
|
|
20327
|
+
const injectVersionMappingsAsGlobal = async ({
|
|
20272
20328
|
urlInfo,
|
|
20273
20329
|
kitchen,
|
|
20274
|
-
versionMappings
|
|
20275
|
-
minification
|
|
20330
|
+
versionMappings
|
|
20276
20331
|
}) => {
|
|
20277
20332
|
const injector = injectors[urlInfo.type];
|
|
20278
20333
|
if (injector) {
|
|
@@ -20281,7 +20336,7 @@ const injectVersionMappings = async ({
|
|
|
20281
20336
|
sourcemap
|
|
20282
20337
|
} = await injector(urlInfo, {
|
|
20283
20338
|
versionMappings,
|
|
20284
|
-
minification
|
|
20339
|
+
minification: kitchen.kitchenContext.minification
|
|
20285
20340
|
});
|
|
20286
20341
|
kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
|
|
20287
20342
|
content,
|
|
@@ -20294,9 +20349,6 @@ const injectors = {
|
|
|
20294
20349
|
versionMappings,
|
|
20295
20350
|
minification
|
|
20296
20351
|
}) => {
|
|
20297
|
-
// ideally we would inject an importmap but browser support is too low
|
|
20298
|
-
// (even worse for worker/service worker)
|
|
20299
|
-
// so for now we inject code into entry points
|
|
20300
20352
|
const htmlAst = parseHtmlString(urlInfo.content, {
|
|
20301
20353
|
storeOriginalPositions: false
|
|
20302
20354
|
});
|
|
@@ -20304,62 +20356,70 @@ const injectors = {
|
|
|
20304
20356
|
tagName: "script",
|
|
20305
20357
|
textContent: generateClientCodeForVersionMappings(versionMappings, {
|
|
20306
20358
|
globalName: "window",
|
|
20307
|
-
|
|
20359
|
+
minification
|
|
20308
20360
|
})
|
|
20309
20361
|
}), "jsenv:versioning");
|
|
20310
20362
|
return {
|
|
20311
20363
|
content: stringifyHtmlAst(htmlAst)
|
|
20312
20364
|
};
|
|
20313
20365
|
},
|
|
20314
|
-
js_classic: (
|
|
20315
|
-
|
|
20316
|
-
minification
|
|
20317
|
-
}) => {
|
|
20318
|
-
return jsInjector(urlInfo, {
|
|
20319
|
-
versionMappings,
|
|
20320
|
-
minify: minification || minification.js_classic
|
|
20321
|
-
});
|
|
20322
|
-
},
|
|
20323
|
-
js_module: (urlInfo, {
|
|
20324
|
-
versionMappings,
|
|
20325
|
-
minification
|
|
20326
|
-
}) => {
|
|
20327
|
-
return jsInjector(urlInfo, {
|
|
20328
|
-
versionMappings,
|
|
20329
|
-
minify: minification || minification.js_module
|
|
20330
|
-
});
|
|
20331
|
-
}
|
|
20366
|
+
js_classic: (...args) => jsInjector(...args),
|
|
20367
|
+
js_module: (...args) => jsInjector(...args)
|
|
20332
20368
|
};
|
|
20333
20369
|
const jsInjector = (urlInfo, {
|
|
20334
20370
|
versionMappings,
|
|
20335
|
-
|
|
20371
|
+
minification
|
|
20336
20372
|
}) => {
|
|
20337
20373
|
const magicSource = createMagicSource(urlInfo.content);
|
|
20338
20374
|
magicSource.prepend(generateClientCodeForVersionMappings(versionMappings, {
|
|
20339
20375
|
globalName: isWebWorkerUrlInfo(urlInfo) ? "self" : "window",
|
|
20340
|
-
|
|
20376
|
+
minification
|
|
20341
20377
|
}));
|
|
20342
20378
|
return magicSource.toContentAndSourcemap();
|
|
20343
20379
|
};
|
|
20344
20380
|
const generateClientCodeForVersionMappings = (versionMappings, {
|
|
20345
20381
|
globalName,
|
|
20346
|
-
|
|
20382
|
+
minification
|
|
20347
20383
|
}) => {
|
|
20348
|
-
if (
|
|
20384
|
+
if (minification) {
|
|
20349
20385
|
return `;(function(){var m = ${JSON.stringify(versionMappings)}; ${globalName}.__v__ = function (s) { return m[s] || s }; })();`;
|
|
20350
20386
|
}
|
|
20351
20387
|
return `
|
|
20352
20388
|
;(function() {
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20357
|
-
};
|
|
20358
|
-
|
|
20389
|
+
var __versionMappings__ = ${JSON.stringify(versionMappings, null, " ")};
|
|
20390
|
+
${globalName}.__v__ = function (specifier) {
|
|
20391
|
+
return __versionMappings__[specifier] || specifier
|
|
20392
|
+
};
|
|
20359
20393
|
})();
|
|
20360
|
-
|
|
20361
20394
|
`;
|
|
20362
20395
|
};
|
|
20396
|
+
const injectVersionMappingsAsImportmap = async ({
|
|
20397
|
+
urlInfo,
|
|
20398
|
+
kitchen,
|
|
20399
|
+
versionMappings
|
|
20400
|
+
}) => {
|
|
20401
|
+
const htmlAst = parseHtmlString(urlInfo.content, {
|
|
20402
|
+
storeOriginalPositions: false
|
|
20403
|
+
});
|
|
20404
|
+
// jsenv_plugin_importmap.js is removing importmap during build
|
|
20405
|
+
// it means at this point we know HTML has no importmap in it
|
|
20406
|
+
// we can safely inject one
|
|
20407
|
+
const importmapNode = createHtmlNode({
|
|
20408
|
+
tagName: "script",
|
|
20409
|
+
type: "importmap",
|
|
20410
|
+
textContent: kitchen.kitchenContext.minification ? JSON.stringify({
|
|
20411
|
+
imports: versionMappings
|
|
20412
|
+
}) : `
|
|
20413
|
+
{
|
|
20414
|
+
"imports": {${JSON.stringify(versionMappings, null, " ").slice(1, -1)} }
|
|
20415
|
+
}
|
|
20416
|
+
`
|
|
20417
|
+
});
|
|
20418
|
+
injectScriptNodeAsEarlyAsPossible(htmlAst, importmapNode, "jsenv:versioning");
|
|
20419
|
+
kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
|
|
20420
|
+
content: stringifyHtmlAst(htmlAst)
|
|
20421
|
+
});
|
|
20422
|
+
};
|
|
20363
20423
|
|
|
20364
20424
|
const ensureUnixLineBreaks = stringOrBuffer => {
|
|
20365
20425
|
if (typeof stringOrBuffer === "string") {
|
|
@@ -20472,12 +20532,12 @@ const build = async ({
|
|
|
20472
20532
|
signal = new AbortController().signal,
|
|
20473
20533
|
handleSIGINT = true,
|
|
20474
20534
|
logLevel = "info",
|
|
20475
|
-
runtimeCompat = defaultRuntimeCompat,
|
|
20476
20535
|
rootDirectoryUrl,
|
|
20477
20536
|
buildDirectoryUrl,
|
|
20478
20537
|
assetsDirectory = "",
|
|
20479
|
-
base = runtimeCompat.node ? "./" : "/",
|
|
20480
20538
|
entryPoints = {},
|
|
20539
|
+
runtimeCompat = defaultRuntimeCompat,
|
|
20540
|
+
base = runtimeCompat.node ? "./" : "/",
|
|
20481
20541
|
plugins = [],
|
|
20482
20542
|
sourcemaps = false,
|
|
20483
20543
|
sourcemapsSourcesContent,
|
|
@@ -20489,6 +20549,7 @@ const build = async ({
|
|
|
20489
20549
|
versioning = !runtimeCompat.node,
|
|
20490
20550
|
versioningMethod = "search_param",
|
|
20491
20551
|
// "filename", "search_param"
|
|
20552
|
+
versioningViaImportmap = true,
|
|
20492
20553
|
lineBreakNormalization = process.platform === "win32",
|
|
20493
20554
|
clientFiles = {
|
|
20494
20555
|
"./src/": true
|
|
@@ -20565,6 +20626,18 @@ build ${entryPointKeys.length} entry points`);
|
|
|
20565
20626
|
const versioningRedirections = new Map();
|
|
20566
20627
|
const entryUrls = [];
|
|
20567
20628
|
const rawGraph = createUrlGraph();
|
|
20629
|
+
const contextSharedDuringBuild = {
|
|
20630
|
+
systemJsTranspilation: (() => {
|
|
20631
|
+
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node");
|
|
20632
|
+
if (nodeRuntimeEnabled) return false;
|
|
20633
|
+
if (!RUNTIME_COMPAT.isSupported(runtimeCompat, "script_type_module")) return true;
|
|
20634
|
+
if (!RUNTIME_COMPAT.isSupported(runtimeCompat, "import_dynamic")) return true;
|
|
20635
|
+
if (!RUNTIME_COMPAT.isSupported(runtimeCompat, "import_meta")) return true;
|
|
20636
|
+
if (versioning && versioningViaImportmap && !RUNTIME_COMPAT.isSupported(runtimeCompat, "importmap")) return true;
|
|
20637
|
+
return false;
|
|
20638
|
+
})(),
|
|
20639
|
+
minification: plugins.some(plugin => plugin.name === "jsenv:minification")
|
|
20640
|
+
};
|
|
20568
20641
|
const rawGraphKitchen = createKitchen({
|
|
20569
20642
|
signal,
|
|
20570
20643
|
logLevel,
|
|
@@ -20572,6 +20645,7 @@ build ${entryPointKeys.length} entry points`);
|
|
|
20572
20645
|
urlGraph: rawGraph,
|
|
20573
20646
|
build: true,
|
|
20574
20647
|
runtimeCompat,
|
|
20648
|
+
...contextSharedDuringBuild,
|
|
20575
20649
|
plugins: [...plugins, {
|
|
20576
20650
|
appliesDuring: "build",
|
|
20577
20651
|
fetchUrlContent: (urlInfo, context) => {
|
|
@@ -20633,6 +20707,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
20633
20707
|
urlGraph: finalGraph,
|
|
20634
20708
|
build: true,
|
|
20635
20709
|
runtimeCompat,
|
|
20710
|
+
...contextSharedDuringBuild,
|
|
20636
20711
|
plugins: [urlAnalysisPlugin, jsenvPluginAsJsClassic({
|
|
20637
20712
|
jsClassicLibrary: false,
|
|
20638
20713
|
jsClassicFallback: true,
|
|
@@ -21134,6 +21209,62 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21134
21209
|
disabled: logger.levels.debug || !logger.levels.info
|
|
21135
21210
|
});
|
|
21136
21211
|
try {
|
|
21212
|
+
const canUseImportmap = versioningViaImportmap && finalEntryUrls.every(finalEntryUrl => {
|
|
21213
|
+
const finalEntryUrlInfo = finalGraph.getUrlInfo(finalEntryUrl);
|
|
21214
|
+
return finalEntryUrlInfo.type === "html";
|
|
21215
|
+
}) && finalGraphKitchen.kitchenContext.isSupportedOnCurrentClients("importmap");
|
|
21216
|
+
const workerReferenceSet = new Set();
|
|
21217
|
+
const isReferencedByWorker = (reference, graph) => {
|
|
21218
|
+
if (workerReferenceSet.has(reference)) {
|
|
21219
|
+
return true;
|
|
21220
|
+
}
|
|
21221
|
+
const urlInfo = graph.getUrlInfo(reference.url);
|
|
21222
|
+
const dependentWorker = graph.findDependent(urlInfo, dependentUrlInfo => {
|
|
21223
|
+
return isWebWorkerUrlInfo(dependentUrlInfo);
|
|
21224
|
+
});
|
|
21225
|
+
if (dependentWorker) {
|
|
21226
|
+
workerReferenceSet.add(reference);
|
|
21227
|
+
return true;
|
|
21228
|
+
}
|
|
21229
|
+
return Boolean(dependentWorker);
|
|
21230
|
+
};
|
|
21231
|
+
const preferWithoutVersioning = reference => {
|
|
21232
|
+
const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl);
|
|
21233
|
+
if (parentUrlInfo.jsQuote) {
|
|
21234
|
+
return {
|
|
21235
|
+
type: "global",
|
|
21236
|
+
source: `${parentUrlInfo.jsQuote}+__v__(${JSON.stringify(reference.specifier)})+${parentUrlInfo.jsQuote}`
|
|
21237
|
+
};
|
|
21238
|
+
}
|
|
21239
|
+
if (reference.type === "js_url") {
|
|
21240
|
+
return {
|
|
21241
|
+
type: "global",
|
|
21242
|
+
source: `__v__(${JSON.stringify(reference.specifier)})`
|
|
21243
|
+
};
|
|
21244
|
+
}
|
|
21245
|
+
if (reference.type === "js_import") {
|
|
21246
|
+
if (reference.subtype === "import_dynamic") {
|
|
21247
|
+
return {
|
|
21248
|
+
type: "global",
|
|
21249
|
+
source: `__v__(${JSON.stringify(reference.specifier)})`
|
|
21250
|
+
};
|
|
21251
|
+
}
|
|
21252
|
+
if (reference.subtype === "import_meta_resolve") {
|
|
21253
|
+
return {
|
|
21254
|
+
type: "global",
|
|
21255
|
+
source: `__v__(${JSON.stringify(reference.specifier)})`
|
|
21256
|
+
};
|
|
21257
|
+
}
|
|
21258
|
+
if (canUseImportmap && !isReferencedByWorker(reference, finalGraph)) {
|
|
21259
|
+
return {
|
|
21260
|
+
type: "importmap",
|
|
21261
|
+
source: JSON.stringify(reference.specifier)
|
|
21262
|
+
};
|
|
21263
|
+
}
|
|
21264
|
+
}
|
|
21265
|
+
return null;
|
|
21266
|
+
};
|
|
21267
|
+
|
|
21137
21268
|
// see also https://github.com/rollup/rollup/pull/4543
|
|
21138
21269
|
const contentVersionMap = new Map();
|
|
21139
21270
|
const hashCallbacks = [];
|
|
@@ -21190,13 +21321,11 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21190
21321
|
// (inline, data:, sourcemap, shouldHandle is false, ...)
|
|
21191
21322
|
return null;
|
|
21192
21323
|
}
|
|
21193
|
-
|
|
21194
|
-
|
|
21195
|
-
//
|
|
21196
|
-
|
|
21197
|
-
|
|
21198
|
-
if (reference.type === "js_url" || reference.subtype === "import_dynamic") {
|
|
21199
|
-
// __v__() makes versioning dynamic: no need to take into account
|
|
21324
|
+
if (preferWithoutVersioning(reference)) {
|
|
21325
|
+
// when versioning is dynamic no need to take into account
|
|
21326
|
+
// happend for:
|
|
21327
|
+
// - specifier mapped by window.__v__()
|
|
21328
|
+
// - specifier mapped by importmap
|
|
21200
21329
|
return null;
|
|
21201
21330
|
}
|
|
21202
21331
|
return dependencyContentVersion;
|
|
@@ -21243,13 +21372,15 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21243
21372
|
callback();
|
|
21244
21373
|
});
|
|
21245
21374
|
const versionMappings = {};
|
|
21246
|
-
const
|
|
21375
|
+
const versionMappingsOnGlobalMap = new Set();
|
|
21376
|
+
const versionMappingsOnImportmap = new Set();
|
|
21247
21377
|
const versioningKitchen = createKitchen({
|
|
21248
21378
|
logLevel: logger.level,
|
|
21249
21379
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
21250
21380
|
urlGraph: finalGraph,
|
|
21251
21381
|
build: true,
|
|
21252
21382
|
runtimeCompat,
|
|
21383
|
+
...contextSharedDuringBuild,
|
|
21253
21384
|
plugins: [urlAnalysisPlugin, jsenvPluginInline({
|
|
21254
21385
|
fetchInlineUrls: false,
|
|
21255
21386
|
analyzeConvertedScripts: true,
|
|
@@ -21309,15 +21440,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21309
21440
|
versionMappings[reference.specifier] = versionedSpecifier;
|
|
21310
21441
|
versioningRedirections.set(reference.url, versionedUrl);
|
|
21311
21442
|
buildUrls.set(versionedSpecifier, versionedUrl);
|
|
21312
|
-
const
|
|
21313
|
-
if (
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
|
|
21319
|
-
|
|
21320
|
-
return () => `__v__(${JSON.stringify(reference.specifier)})`;
|
|
21443
|
+
const withoutVersioning = preferWithoutVersioning(reference);
|
|
21444
|
+
if (withoutVersioning) {
|
|
21445
|
+
if (withoutVersioning.type === "importmap") {
|
|
21446
|
+
versionMappingsOnImportmap.add(reference.specifier);
|
|
21447
|
+
} else {
|
|
21448
|
+
versionMappingsOnGlobalMap.add(reference.specifier);
|
|
21449
|
+
}
|
|
21450
|
+
return () => withoutVersioning.source;
|
|
21321
21451
|
}
|
|
21322
21452
|
return versionedSpecifier;
|
|
21323
21453
|
},
|
|
@@ -21356,25 +21486,50 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21356
21486
|
});
|
|
21357
21487
|
});
|
|
21358
21488
|
await versioningUrlGraphLoader.getAllLoadDonePromise(buildOperation);
|
|
21359
|
-
|
|
21489
|
+
workerReferenceSet.clear();
|
|
21490
|
+
const actions = [];
|
|
21491
|
+
const visitors = [];
|
|
21492
|
+
if (versionMappingsOnImportmap.size) {
|
|
21360
21493
|
const versionMappingsNeeded = {};
|
|
21361
|
-
|
|
21494
|
+
versionMappingsOnImportmap.forEach(specifier => {
|
|
21362
21495
|
versionMappingsNeeded[specifier] = versionMappings[specifier];
|
|
21363
21496
|
});
|
|
21364
|
-
|
|
21365
|
-
|
|
21497
|
+
visitors.push(urlInfo => {
|
|
21498
|
+
if (urlInfo.type === "html" && urlInfo.isEntryPoint) {
|
|
21499
|
+
actions.push(async () => {
|
|
21500
|
+
await injectVersionMappingsAsImportmap({
|
|
21501
|
+
urlInfo,
|
|
21502
|
+
kitchen: finalGraphKitchen,
|
|
21503
|
+
versionMappings: versionMappingsNeeded
|
|
21504
|
+
});
|
|
21505
|
+
});
|
|
21506
|
+
}
|
|
21507
|
+
});
|
|
21508
|
+
}
|
|
21509
|
+
if (versionMappingsOnGlobalMap.size) {
|
|
21510
|
+
const versionMappingsNeeded = {};
|
|
21511
|
+
versionMappingsOnGlobalMap.forEach(specifier => {
|
|
21512
|
+
versionMappingsNeeded[specifier] = versionMappings[specifier];
|
|
21513
|
+
});
|
|
21514
|
+
visitors.push(urlInfo => {
|
|
21366
21515
|
if (urlInfo.isEntryPoint) {
|
|
21367
21516
|
actions.push(async () => {
|
|
21368
|
-
await
|
|
21517
|
+
await injectVersionMappingsAsGlobal({
|
|
21369
21518
|
urlInfo,
|
|
21370
21519
|
kitchen: finalGraphKitchen,
|
|
21371
|
-
versionMappings: versionMappingsNeeded
|
|
21372
|
-
minification: plugins.some(plugin => plugin.name === "jsenv:minification")
|
|
21520
|
+
versionMappings: versionMappingsNeeded
|
|
21373
21521
|
});
|
|
21374
21522
|
});
|
|
21375
21523
|
}
|
|
21376
21524
|
});
|
|
21377
|
-
|
|
21525
|
+
}
|
|
21526
|
+
if (visitors.length) {
|
|
21527
|
+
GRAPH.forEach(finalGraph, urlInfo => {
|
|
21528
|
+
visitors.forEach(visitor => visitor(urlInfo));
|
|
21529
|
+
});
|
|
21530
|
+
if (actions.length) {
|
|
21531
|
+
await Promise.all(actions.map(action => action()));
|
|
21532
|
+
}
|
|
21378
21533
|
}
|
|
21379
21534
|
} catch (e) {
|
|
21380
21535
|
versioningTask.fail();
|
|
@@ -22012,16 +22167,18 @@ const createFileService = ({
|
|
|
22012
22167
|
onUrlInfo(urlInfo);
|
|
22013
22168
|
});
|
|
22014
22169
|
});
|
|
22170
|
+
const clientRuntimeCompat = {
|
|
22171
|
+
[runtimeName]: runtimeVersion
|
|
22172
|
+
};
|
|
22015
22173
|
const kitchen = createKitchen({
|
|
22016
22174
|
signal,
|
|
22017
22175
|
logLevel,
|
|
22018
22176
|
rootDirectoryUrl,
|
|
22177
|
+
urlGraph,
|
|
22019
22178
|
dev: true,
|
|
22020
22179
|
runtimeCompat,
|
|
22021
|
-
clientRuntimeCompat
|
|
22022
|
-
|
|
22023
|
-
},
|
|
22024
|
-
urlGraph,
|
|
22180
|
+
clientRuntimeCompat,
|
|
22181
|
+
systemJsTranspilation: !RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "script_type_module") || !RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "import_dynamic") || !RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "import_meta"),
|
|
22025
22182
|
plugins: [...plugins, ...getCorePlugins({
|
|
22026
22183
|
rootDirectoryUrl,
|
|
22027
22184
|
runtimeCompat,
|
|
@@ -22037,6 +22194,7 @@ const createFileService = ({
|
|
|
22037
22194
|
explorer,
|
|
22038
22195
|
ribbon
|
|
22039
22196
|
})],
|
|
22197
|
+
minification: false,
|
|
22040
22198
|
sourcemaps,
|
|
22041
22199
|
sourcemapsSourcesProtocol,
|
|
22042
22200
|
sourcemapsSourcesContent,
|