@jsenv/core 30.1.0 → 30.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 { U as URL_META, f as filterV8Coverage } from "./js/v8_coverage.js";
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
- urlGraph,
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 (shouldTransformScriptTypeModule && reference.subtype === "modulepreload") {
14659
+ link_href: (reference, context) => {
14660
+ if (context.systemJsTranspilation && reference.subtype === "modulepreload") {
14603
14661
  return turnIntoJsClassicProxy(reference);
14604
14662
  }
14605
- if (shouldTransformScriptTypeModule && reference.subtype === "preload" && reference.expectedType === "js_module") {
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 (shouldTransformScriptTypeModule && reference.expectedType === "js_module") {
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 (shouldTransformScriptTypeModule && reference.expectedType === "js_module") {
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 (shouldTransformScriptTypeModule) {
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
- const willTransformJsModules = !context.isSupportedOnCurrentClients("script_type_module") || !context.isSupportedOnCurrentClients("import_dynamic") || !context.isSupportedOnCurrentClients("import_meta");
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 (willTransformJsModules) {
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 injectVersionMappings = async ({
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,93 +20356,81 @@ const injectors = {
20304
20356
  tagName: "script",
20305
20357
  textContent: generateClientCodeForVersionMappings(versionMappings, {
20306
20358
  globalName: "window",
20307
- minify: minification || minification.js_classic
20359
+ minification
20308
20360
  })
20309
20361
  }), "jsenv:versioning");
20310
20362
  return {
20311
20363
  content: stringifyHtmlAst(htmlAst)
20312
20364
  };
20313
20365
  },
20314
- js_classic: (urlInfo, {
20315
- versionMappings,
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
- minify
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
- minify
20376
+ minification
20341
20377
  }));
20342
20378
  return magicSource.toContentAndSourcemap();
20343
20379
  };
20344
20380
  const generateClientCodeForVersionMappings = (versionMappings, {
20345
20381
  globalName,
20346
- minify
20382
+ minification
20347
20383
  }) => {
20348
- if (minify) {
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
- var __versionMappings__ = ${JSON.stringify(versionMappings, null, " ")};
20355
- ${globalName}.__v__ = function (specifier) {
20356
- return __versionMappings__[specifier] || specifier
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
  };
20363
-
20364
- // https://github.com/rollup/rollup/blob/19e50af3099c2f627451a45a84e2fa90d20246d5/src/utils/FileEmitter.ts#L47
20365
- // https://github.com/rollup/rollup/blob/5a5391971d695c808eed0c5d7d2c6ccb594fc689/src/Chunk.ts#L870
20366
- const createVersionGenerator = () => {
20367
- const hash = createHash("sha256");
20368
- return {
20369
- augmentWithContent: ({
20370
- content,
20371
- contentType = "application/octet-stream",
20372
- lineBreakNormalization = false
20373
- }) => {
20374
- hash.update(lineBreakNormalization && CONTENT_TYPE.isTextual(contentType) ? normalizeLineBreaks(content) : content);
20375
- },
20376
- augment: value => {
20377
- hash.update(value);
20378
- },
20379
- generate: () => {
20380
- return hash.digest("hex").slice(0, 8);
20381
- }
20382
- };
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
+ });
20383
20422
  };
20384
- const normalizeLineBreaks = stringOrBuffer => {
20423
+
20424
+ const ensureUnixLineBreaks = stringOrBuffer => {
20385
20425
  if (typeof stringOrBuffer === "string") {
20386
20426
  const stringWithLinuxBreaks = stringOrBuffer.replace(/\r\n/g, "\n");
20387
20427
  return stringWithLinuxBreaks;
20388
20428
  }
20389
- return normalizeLineBreaksForBuffer(stringOrBuffer);
20429
+ return ensureUnixLineBreaksOnBuffer(stringOrBuffer);
20390
20430
  };
20391
20431
 
20392
20432
  // https://github.com/nodejs/help/issues/1738#issuecomment-458460503
20393
- const normalizeLineBreaksForBuffer = buffer => {
20433
+ const ensureUnixLineBreaksOnBuffer = buffer => {
20394
20434
  const int32Array = new Int32Array(buffer, 0, buffer.length);
20395
20435
  const int32ArrayWithLineBreaksNormalized = int32Array.filter((element, index, typedArray) => {
20396
20436
  if (element === 0x0d) {
@@ -20406,6 +20446,27 @@ const normalizeLineBreaksForBuffer = buffer => {
20406
20446
  return Buffer.from(int32ArrayWithLineBreaksNormalized);
20407
20447
  };
20408
20448
 
20449
+ // https://github.com/rollup/rollup/blob/19e50af3099c2f627451a45a84e2fa90d20246d5/src/utils/FileEmitter.ts#L47
20450
+ // https://github.com/rollup/rollup/blob/5a5391971d695c808eed0c5d7d2c6ccb594fc689/src/Chunk.ts#L870
20451
+ const createVersionGenerator = () => {
20452
+ const hash = createHash("sha256");
20453
+ return {
20454
+ augmentWithContent: ({
20455
+ content,
20456
+ contentType = "application/octet-stream",
20457
+ lineBreakNormalization = false
20458
+ }) => {
20459
+ hash.update(lineBreakNormalization && CONTENT_TYPE.isTextual(contentType) ? ensureUnixLineBreaks(content) : content);
20460
+ },
20461
+ augment: value => {
20462
+ hash.update(value);
20463
+ },
20464
+ generate: () => {
20465
+ return hash.digest("hex").slice(0, 8);
20466
+ }
20467
+ };
20468
+ };
20469
+
20409
20470
  /*
20410
20471
  * Build is split in 3 steps:
20411
20472
  * 1. craft
@@ -20471,12 +20532,12 @@ const build = async ({
20471
20532
  signal = new AbortController().signal,
20472
20533
  handleSIGINT = true,
20473
20534
  logLevel = "info",
20474
- runtimeCompat = defaultRuntimeCompat,
20475
20535
  rootDirectoryUrl,
20476
20536
  buildDirectoryUrl,
20477
20537
  assetsDirectory = "",
20478
- base = runtimeCompat.node ? "./" : "/",
20479
20538
  entryPoints = {},
20539
+ runtimeCompat = defaultRuntimeCompat,
20540
+ base = runtimeCompat.node ? "./" : "/",
20480
20541
  plugins = [],
20481
20542
  sourcemaps = false,
20482
20543
  sourcemapsSourcesContent,
@@ -20488,6 +20549,7 @@ const build = async ({
20488
20549
  versioning = !runtimeCompat.node,
20489
20550
  versioningMethod = "search_param",
20490
20551
  // "filename", "search_param"
20552
+ versioningViaImportmap = true,
20491
20553
  lineBreakNormalization = process.platform === "win32",
20492
20554
  clientFiles = {
20493
20555
  "./src/": true
@@ -20564,6 +20626,18 @@ build ${entryPointKeys.length} entry points`);
20564
20626
  const versioningRedirections = new Map();
20565
20627
  const entryUrls = [];
20566
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
+ };
20567
20641
  const rawGraphKitchen = createKitchen({
20568
20642
  signal,
20569
20643
  logLevel,
@@ -20571,6 +20645,7 @@ build ${entryPointKeys.length} entry points`);
20571
20645
  urlGraph: rawGraph,
20572
20646
  build: true,
20573
20647
  runtimeCompat,
20648
+ ...contextSharedDuringBuild,
20574
20649
  plugins: [...plugins, {
20575
20650
  appliesDuring: "build",
20576
20651
  fetchUrlContent: (urlInfo, context) => {
@@ -20632,6 +20707,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
20632
20707
  urlGraph: finalGraph,
20633
20708
  build: true,
20634
20709
  runtimeCompat,
20710
+ ...contextSharedDuringBuild,
20635
20711
  plugins: [urlAnalysisPlugin, jsenvPluginAsJsClassic({
20636
20712
  jsClassicLibrary: false,
20637
20713
  jsClassicFallback: true,
@@ -21133,6 +21209,47 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
21133
21209
  disabled: logger.levels.debug || !logger.levels.info
21134
21210
  });
21135
21211
  try {
21212
+ const canUseImportmap = finalEntryUrls.every(finalEntryUrl => {
21213
+ const finalEntryUrlInfo = finalGraph.getUrlInfo(finalEntryUrl);
21214
+ return finalEntryUrlInfo.type === "html";
21215
+ }) && finalGraphKitchen.kitchenContext.isSupportedOnCurrentClients("importmap");
21216
+ const preferWithoutVersioning = reference => {
21217
+ const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl);
21218
+ if (parentUrlInfo.jsQuote) {
21219
+ return {
21220
+ type: "global",
21221
+ source: `${parentUrlInfo.jsQuote}+__v__(${JSON.stringify(reference.specifier)})+${parentUrlInfo.jsQuote}`
21222
+ };
21223
+ }
21224
+ if (reference.type === "js_url") {
21225
+ return {
21226
+ type: "global",
21227
+ source: `__v__(${JSON.stringify(reference.specifier)})`
21228
+ };
21229
+ }
21230
+ if (reference.type === "js_import") {
21231
+ if (reference.subtype === "import_dynamic") {
21232
+ return {
21233
+ type: "global",
21234
+ source: `__v__(${JSON.stringify(reference.specifier)})`
21235
+ };
21236
+ }
21237
+ if (reference.subtype === "import_meta_resolve") {
21238
+ return {
21239
+ type: "global",
21240
+ source: `__v__(${JSON.stringify(reference.specifier)})`
21241
+ };
21242
+ }
21243
+ if (canUseImportmap && !isReferencedByWorker(reference, finalGraph)) {
21244
+ return {
21245
+ type: "importmap",
21246
+ source: JSON.stringify(reference.specifier)
21247
+ };
21248
+ }
21249
+ }
21250
+ return null;
21251
+ };
21252
+
21136
21253
  // see also https://github.com/rollup/rollup/pull/4543
21137
21254
  const contentVersionMap = new Map();
21138
21255
  const hashCallbacks = [];
@@ -21189,13 +21306,11 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
21189
21306
  // (inline, data:, sourcemap, shouldHandle is false, ...)
21190
21307
  return null;
21191
21308
  }
21192
- const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl);
21193
- if (parentUrlInfo.jsQuote) {
21194
- // __v__() makes versioning dynamic: no need to take into account
21195
- return null;
21196
- }
21197
- if (reference.type === "js_url" || reference.subtype === "import_dynamic") {
21198
- // __v__() makes versioning dynamic: no need to take into account
21309
+ if (preferWithoutVersioning(reference)) {
21310
+ // when versioning is dynamic no need to take into account
21311
+ // happend for:
21312
+ // - specifier mapped by window.__v__()
21313
+ // - specifier mapped by importmap
21199
21314
  return null;
21200
21315
  }
21201
21316
  return dependencyContentVersion;
@@ -21242,13 +21357,15 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
21242
21357
  callback();
21243
21358
  });
21244
21359
  const versionMappings = {};
21245
- const usedVersionMappings = new Set();
21360
+ const versionMappingsOnGlobalMap = new Set();
21361
+ const versionMappingsOnImportmap = new Set();
21246
21362
  const versioningKitchen = createKitchen({
21247
21363
  logLevel: logger.level,
21248
21364
  rootDirectoryUrl: buildDirectoryUrl,
21249
21365
  urlGraph: finalGraph,
21250
21366
  build: true,
21251
21367
  runtimeCompat,
21368
+ ...contextSharedDuringBuild,
21252
21369
  plugins: [urlAnalysisPlugin, jsenvPluginInline({
21253
21370
  fetchInlineUrls: false,
21254
21371
  analyzeConvertedScripts: true,
@@ -21308,15 +21425,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
21308
21425
  versionMappings[reference.specifier] = versionedSpecifier;
21309
21426
  versioningRedirections.set(reference.url, versionedUrl);
21310
21427
  buildUrls.set(versionedSpecifier, versionedUrl);
21311
- const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl);
21312
- if (parentUrlInfo.jsQuote) {
21313
- // the url is inline inside js quotes
21314
- usedVersionMappings.add(reference.specifier);
21315
- return () => `${parentUrlInfo.jsQuote}+__v__(${JSON.stringify(reference.specifier)})+${parentUrlInfo.jsQuote}`;
21316
- }
21317
- if (reference.type === "js_url" || reference.subtype === "import_dynamic" || reference.subtype === "import_meta_resolve") {
21318
- usedVersionMappings.add(reference.specifier);
21319
- return () => `__v__(${JSON.stringify(reference.specifier)})`;
21428
+ const withoutVersioning = preferWithoutVersioning(reference);
21429
+ if (withoutVersioning) {
21430
+ if (withoutVersioning.type === "importmap") {
21431
+ versionMappingsOnImportmap.add(reference.specifier);
21432
+ } else {
21433
+ versionMappingsOnGlobalMap.add(reference.specifier);
21434
+ }
21435
+ return () => withoutVersioning.source;
21320
21436
  }
21321
21437
  return versionedSpecifier;
21322
21438
  },
@@ -21355,25 +21471,49 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
21355
21471
  });
21356
21472
  });
21357
21473
  await versioningUrlGraphLoader.getAllLoadDonePromise(buildOperation);
21358
- if (usedVersionMappings.size) {
21474
+ const actions = [];
21475
+ const visitors = [];
21476
+ if (versionMappingsOnImportmap.size) {
21359
21477
  const versionMappingsNeeded = {};
21360
- usedVersionMappings.forEach(specifier => {
21478
+ versionMappingsOnImportmap.forEach(specifier => {
21361
21479
  versionMappingsNeeded[specifier] = versionMappings[specifier];
21362
21480
  });
21363
- const actions = [];
21364
- GRAPH.forEach(finalGraph, urlInfo => {
21481
+ visitors.push(urlInfo => {
21482
+ if (urlInfo.type === "html" && urlInfo.isEntryPoint) {
21483
+ actions.push(async () => {
21484
+ await injectVersionMappingsAsImportmap({
21485
+ urlInfo,
21486
+ kitchen: finalGraphKitchen,
21487
+ versionMappings: versionMappingsNeeded
21488
+ });
21489
+ });
21490
+ }
21491
+ });
21492
+ }
21493
+ if (versionMappingsOnGlobalMap.size) {
21494
+ const versionMappingsNeeded = {};
21495
+ versionMappingsOnGlobalMap.forEach(specifier => {
21496
+ versionMappingsNeeded[specifier] = versionMappings[specifier];
21497
+ });
21498
+ visitors.push(urlInfo => {
21365
21499
  if (urlInfo.isEntryPoint) {
21366
21500
  actions.push(async () => {
21367
- await injectVersionMappings({
21501
+ await injectVersionMappingsAsGlobal({
21368
21502
  urlInfo,
21369
21503
  kitchen: finalGraphKitchen,
21370
- versionMappings: versionMappingsNeeded,
21371
- minification: plugins.some(plugin => plugin.name === "jsenv:minification")
21504
+ versionMappings: versionMappingsNeeded
21372
21505
  });
21373
21506
  });
21374
21507
  }
21375
21508
  });
21376
- await Promise.all(actions.map(action => action()));
21509
+ }
21510
+ if (visitors.length) {
21511
+ GRAPH.forEach(finalGraph, urlInfo => {
21512
+ visitors.forEach(visitor => visitor(urlInfo));
21513
+ });
21514
+ if (actions.length) {
21515
+ await Promise.all(actions.map(action => action()));
21516
+ }
21377
21517
  }
21378
21518
  } catch (e) {
21379
21519
  versioningTask.fail();
@@ -21802,6 +21942,13 @@ const canUseVersionedUrl = urlInfo => {
21802
21942
  }
21803
21943
  return urlInfo.type !== "webmanifest";
21804
21944
  };
21945
+ const isReferencedByWorker = (reference, graph) => {
21946
+ const urlInfo = graph.getUrlInfo(reference.url);
21947
+ const dependentWorker = graph.findDependent(urlInfo, dependentUrlInfo => {
21948
+ return isWebWorkerUrlInfo(dependentUrlInfo);
21949
+ });
21950
+ return Boolean(dependentWorker);
21951
+ };
21805
21952
 
21806
21953
  // https://nodejs.org/api/worker_threads.html
21807
21954
  const createReloadableWorker = (workerFileUrl, options = {}) => {
@@ -22011,16 +22158,18 @@ const createFileService = ({
22011
22158
  onUrlInfo(urlInfo);
22012
22159
  });
22013
22160
  });
22161
+ const clientRuntimeCompat = {
22162
+ [runtimeName]: runtimeVersion
22163
+ };
22014
22164
  const kitchen = createKitchen({
22015
22165
  signal,
22016
22166
  logLevel,
22017
22167
  rootDirectoryUrl,
22168
+ urlGraph,
22018
22169
  dev: true,
22019
22170
  runtimeCompat,
22020
- clientRuntimeCompat: {
22021
- [runtimeName]: runtimeVersion
22022
- },
22023
- urlGraph,
22171
+ clientRuntimeCompat,
22172
+ systemJsTranspilation: !RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "script_type_module") || !RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "import_dynamic") || !RUNTIME_COMPAT.isSupported(clientRuntimeCompat, "import_meta"),
22024
22173
  plugins: [...plugins, ...getCorePlugins({
22025
22174
  rootDirectoryUrl,
22026
22175
  runtimeCompat,
@@ -22036,6 +22185,7 @@ const createFileService = ({
22036
22185
  explorer,
22037
22186
  ribbon
22038
22187
  })],
22188
+ minification: false,
22039
22189
  sourcemaps,
22040
22190
  sourcemapsSourcesProtocol,
22041
22191
  sourcemapsSourcesContent,