@jsenv/core 22.5.1 → 23.0.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.
Files changed (99) hide show
  1. package/dist/jsenv_browser_system.js +203 -49
  2. package/dist/jsenv_browser_system.js.map +39 -8
  3. package/dist/jsenv_compile_proxy.js +186 -108
  4. package/dist/jsenv_compile_proxy.js.map +48 -42
  5. package/dist/jsenv_exploring_redirector.js +148 -71
  6. package/dist/jsenv_exploring_redirector.js.map +26 -20
  7. package/dist/jsenv_toolbar.js +215 -104
  8. package/dist/jsenv_toolbar.js.map +39 -26
  9. package/helpers/new_stylesheet/new_stylesheet.js +411 -0
  10. package/{LICENSE → license} +0 -0
  11. package/main.js +7 -7
  12. package/package.json +23 -19
  13. package/readme.md +5 -4
  14. package/src/execute.js +23 -10
  15. package/src/executeTestPlan.js +0 -4
  16. package/src/importUsingChildProcess.js +36 -32
  17. package/src/internal/{babel-plugin-replace-expressions.js → babel_plugin_replace_expressions.js} +0 -0
  18. package/src/internal/{babel-plugin-transform-import-meta.js → babel_plugin_transform_import_meta.js} +0 -0
  19. package/src/internal/browser-launcher/executeHtmlFile.js +6 -8
  20. package/src/internal/browser-launcher/jsenv-browser-system.js +3 -0
  21. package/src/internal/building/asset_url_versioning.js +5 -9
  22. package/src/internal/building/buildServiceWorker.js +6 -13
  23. package/src/internal/building/buildUsingRollup.js +34 -0
  24. package/src/internal/building/build_logs.js +11 -0
  25. package/src/internal/building/build_stats.js +7 -1
  26. package/src/internal/building/createJsenvRollupPlugin.js +380 -297
  27. package/src/internal/building/css/parseCssRessource.js +67 -71
  28. package/src/internal/building/css/parseCssUrls.js +2 -2
  29. package/src/internal/building/css/{postcss-urlhash-plugin.js → postcss_plugin_url_visitor.js} +43 -21
  30. package/src/internal/building/css/replaceCssUrls.js +17 -14
  31. package/src/internal/building/css_module.js +47 -0
  32. package/src/internal/building/html/parseHtmlRessource.js +44 -43
  33. package/src/internal/building/import_references.js +81 -0
  34. package/src/internal/building/importmap/parseImportmapRessource.js +5 -2
  35. package/src/internal/building/js/minifyJs.js +30 -3
  36. package/src/internal/building/js/parseJsRessource.js +70 -77
  37. package/src/internal/building/json/parseJsonRessource.js +3 -2
  38. package/src/internal/building/parseRessource.js +11 -8
  39. package/src/internal/building/parsing.utils.js +4 -15
  40. package/src/internal/building/ressource_builder.js +142 -114
  41. package/src/internal/building/ressource_builder_util.js +31 -18
  42. package/src/internal/building/{fetchSourcemap.js → sourcemap_loader.js} +29 -27
  43. package/src/internal/building/svg/parseSvgRessource.js +7 -3
  44. package/src/internal/building/url-versioning.js +2 -1
  45. package/src/internal/building/url_fetcher.js +79 -0
  46. package/src/internal/building/url_loader.js +267 -0
  47. package/src/internal/building/webmanifest/parseWebmanifestRessource.js +9 -4
  48. package/src/internal/compiling/{js-compilation-service/ensureGlobalThisImportBabelPlugin.js → babel_plugin_global_this_as_jsenv_import.js} +4 -2
  49. package/src/internal/compiling/babel_plugin_import_assertions.js +100 -0
  50. package/src/internal/compiling/babel_plugin_new_stylesheet_as_jsenv_import.js +109 -0
  51. package/src/internal/compiling/babel_plugin_transform_import_specifier.js +86 -0
  52. package/src/internal/compiling/babel_plugins.js +2 -0
  53. package/src/internal/compiling/createCompiledFileService.js +6 -8
  54. package/src/internal/compiling/html_source_file_service.js +2 -2
  55. package/src/internal/compiling/js-compilation-service/{transformBabelHelperToImportBabelPlugin.js → babel_plugin_babel_helpers_as_jsenv_imports.js} +1 -1
  56. package/src/internal/compiling/js-compilation-service/{ensureRegeneratorRuntimeImportBabelPlugin.js → babel_plugin_regenerator_runtime_as_jsenv_import.js} +1 -1
  57. package/src/internal/compiling/js-compilation-service/jsenvTransform.js +7 -16
  58. package/src/internal/compiling/js-compilation-service/transformJs.js +0 -2
  59. package/src/internal/compiling/rollup_plugin_commonjs_named_exports.js +2 -2
  60. package/src/internal/compiling/startCompileServer.js +11 -4
  61. package/src/internal/escapeTemplateStringSpecialCharacters.js +20 -0
  62. package/src/internal/executing/coverage/{babel-plugin-instrument.js → babel_plugin_instrument.js} +17 -6
  63. package/src/internal/executing/coverage/relativeUrlToEmptyCoverage.js +1 -1
  64. package/src/internal/executing/executeConcurrently.js +2 -2
  65. package/src/internal/executing/executePlan.js +16 -2
  66. package/src/internal/executing/generateFileExecutionSteps.js +2 -1
  67. package/src/internal/executing/launchAndExecute.js +43 -69
  68. package/src/internal/exploring/exploring.css +2 -1
  69. package/src/internal/exploring/exploring.redirector.js +0 -1
  70. package/src/internal/generateGroupMap/generateGroupMap.js +14 -10
  71. package/src/internal/generateGroupMap/jsenvBabelPluginCompatMap.js +30 -0
  72. package/src/internal/generateGroupMap/jsenvPluginCompatMap.js +0 -6
  73. package/src/internal/generateGroupMap/one_runtime_compat.js +9 -38
  74. package/src/internal/generateGroupMap/runtime_compat.js +9 -24
  75. package/src/internal/generateGroupMap/runtime_compat_composition.js +2 -12
  76. package/src/internal/generateGroupMap/runtime_support.js +53 -0
  77. package/src/internal/jsenvInternalFiles.js +0 -1
  78. package/src/internal/node-launcher/createControllableNodeProcess.js +2 -3
  79. package/src/internal/response_validation.js +143 -0
  80. package/src/internal/runtime/createBrowserRuntime/createBrowserRuntime.js +8 -3
  81. package/src/internal/runtime/createBrowserRuntime/createBrowserSystem.js +117 -0
  82. package/src/internal/runtime/createBrowserRuntime/displayErrorInDocument.js +1 -1
  83. package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +124 -68
  84. package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +8 -86
  85. package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +115 -0
  86. package/src/internal/runtime/module-registration.js +1 -2
  87. package/src/internal/runtime/resolveGroup.js +2 -3
  88. package/src/internal/toolbar/compilation/toolbar.compilation.js +15 -17
  89. package/src/internal/toolbar/eventsource/toolbar.eventsource.js +35 -8
  90. package/src/internal/toolbar/toolbar.main.js +7 -4
  91. package/src/internal/url_utils.js +20 -0
  92. package/src/launchBrowser.js +47 -34
  93. package/src/launchNode.js +6 -3
  94. package/src/requireUsingChildProcess.js +36 -32
  95. package/src/startExploring.js +23 -11
  96. package/src/internal/building/transformImportMetaUrlReferences.js +0 -71
  97. package/src/internal/runtime/resolveBrowserGroup.js +0 -5
  98. package/src/internal/runtime/resolveNodeGroup.js +0 -5
  99. package/src/internal/validateResponseStatusIsOk.js +0 -91
@@ -21,44 +21,6 @@
21
21
  return obj;
22
22
  });
23
23
 
24
- function ownKeys(object, enumerableOnly) {
25
- var keys = Object.keys(object);
26
-
27
- if (Object.getOwnPropertySymbols) {
28
- var symbols = Object.getOwnPropertySymbols(object);
29
-
30
- if (enumerableOnly) {
31
- symbols = symbols.filter(function (sym) {
32
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
33
- });
34
- }
35
-
36
- keys.push.apply(keys, symbols);
37
- }
38
-
39
- return keys;
40
- }
41
-
42
- function _objectSpread2(target) {
43
- for (var i = 1; i < arguments.length; i++) {
44
- var source = arguments[i] != null ? arguments[i] : {};
45
-
46
- if (i % 2) {
47
- ownKeys(Object(source), true).forEach(function (key) {
48
- _defineProperty(target, key, source[key]);
49
- });
50
- } else if (Object.getOwnPropertyDescriptors) {
51
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
52
- } else {
53
- ownKeys(Object(source)).forEach(function (key) {
54
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
55
- });
56
- }
57
- }
58
-
59
- return target;
60
- }
61
-
62
24
  // eslint-disable-next-line consistent-return
63
25
  var arrayWithHoles = (function (arr) {
64
26
  if (Array.isArray(arr)) return arr;
@@ -133,6 +95,44 @@
133
95
  return arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
134
96
  });
135
97
 
98
+ function ownKeys(object, enumerableOnly) {
99
+ var keys = Object.keys(object);
100
+
101
+ if (Object.getOwnPropertySymbols) {
102
+ var symbols = Object.getOwnPropertySymbols(object);
103
+
104
+ if (enumerableOnly) {
105
+ symbols = symbols.filter(function (sym) {
106
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
107
+ });
108
+ }
109
+
110
+ keys.push.apply(keys, symbols);
111
+ }
112
+
113
+ return keys;
114
+ }
115
+
116
+ function _objectSpread2(target) {
117
+ for (var i = 1; i < arguments.length; i++) {
118
+ var source = arguments[i] != null ? arguments[i] : {};
119
+
120
+ if (i % 2) {
121
+ ownKeys(Object(source), true).forEach(function (key) {
122
+ _defineProperty(target, key, source[key]);
123
+ });
124
+ } else if (Object.getOwnPropertyDescriptors) {
125
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
126
+ } else {
127
+ ownKeys(Object(source)).forEach(function (key) {
128
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
129
+ });
130
+ }
131
+ }
132
+
133
+ return target;
134
+ }
135
+
136
136
  var objectWithoutPropertiesLoose = (function (source, excluded) {
137
137
  if (source === null) return {};
138
138
  var target = {};
@@ -1158,21 +1158,17 @@
1158
1158
  version = _ref.version;
1159
1159
  return Object.keys(groupMap).find(function (compileIdCandidate) {
1160
1160
  var minRuntimeVersions = groupMap[compileIdCandidate].minRuntimeVersions;
1161
+ var versionForGroup = minRuntimeVersions[name];
1161
1162
 
1162
- if (name in minRuntimeVersions === false) {
1163
+ if (!versionForGroup) {
1163
1164
  return false;
1164
1165
  }
1165
1166
 
1166
- var versionForGroup = minRuntimeVersions[name];
1167
1167
  var highestVersion = findHighestVersion(version, versionForGroup);
1168
1168
  return highestVersion === version;
1169
1169
  });
1170
1170
  };
1171
1171
 
1172
- var resolveBrowserGroup = function resolveBrowserGroup(groupMap) {
1173
- return resolveGroup(detectBrowser(), groupMap);
1174
- };
1175
-
1176
1172
  function _await(value, then, direct) {
1177
1173
  if (direct) {
1178
1174
  return then ? then(value) : value;
@@ -1212,6 +1208,16 @@
1212
1208
  }
1213
1209
  }
1214
1210
 
1211
+ function _invoke(body, then) {
1212
+ var result = body();
1213
+
1214
+ if (result && result.then) {
1215
+ return result.then(then);
1216
+ }
1217
+
1218
+ return then(result);
1219
+ }
1220
+
1215
1221
  function _catch(body, recover) {
1216
1222
  try {
1217
1223
  var result = body();
@@ -1228,8 +1234,8 @@
1228
1234
 
1229
1235
  var scanBrowserRuntimeFeatures = _async(function () {
1230
1236
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1231
- _ref$coverageInstrume = _ref.coverageInstrumentationRequired,
1232
- coverageInstrumentationRequired = _ref$coverageInstrume === void 0 ? true : _ref$coverageInstrume,
1237
+ _ref$coverageHandledF = _ref.coverageHandledFromOutside,
1238
+ coverageHandledFromOutside = _ref$coverageHandledF === void 0 ? false : _ref$coverageHandledF,
1233
1239
  _ref$failFastOnFeatur = _ref.failFastOnFeatureDetection,
1234
1240
  failFastOnFeatureDetection = _ref$failFastOnFeatur === void 0 ? false : _ref$failFastOnFeatur;
1235
1241
 
@@ -1242,57 +1248,56 @@
1242
1248
  groupMap = _ref4[0],
1243
1249
  envJson = _ref4[1];
1244
1250
 
1251
+ var browser = detectBrowser();
1245
1252
  var compileId = computeCompileIdFromGroupId({
1246
- groupId: resolveBrowserGroup(groupMap),
1253
+ groupId: resolveGroup(browser, groupMap),
1247
1254
  groupMap: groupMap
1248
1255
  });
1249
1256
  var groupInfo = groupMap[compileId];
1250
1257
  var inlineImportMapIntoHTML = envJson.inlineImportMapIntoHTML,
1251
1258
  customCompilerPatterns = envJson.customCompilerPatterns;
1252
-
1253
- var _babelPluginRequiredN = babelPluginRequiredNamesFromGroupInfo(groupInfo, {
1254
- coverageInstrumentationRequired: coverageInstrumentationRequired
1255
- });
1256
-
1257
- return _await(getFeaturesReport({
1259
+ var featuresReport = {
1260
+ importmap: undefined,
1261
+ dynamicImport: undefined,
1262
+ topLevelAwait: undefined,
1263
+ jsonImportAssertions: undefined,
1264
+ cssImportAssertions: undefined,
1265
+ newStylesheet: undefined
1266
+ };
1267
+ return _await(detectSupportedFeatures({
1268
+ featuresReport: featuresReport,
1258
1269
  failFastOnFeatureDetection: failFastOnFeatureDetection,
1259
- groupInfo: groupInfo,
1260
- inlineImportMapIntoHTML: inlineImportMapIntoHTML,
1261
- customCompilerPatterns: customCompilerPatterns,
1262
- coverageInstrumentationRequired: coverageInstrumentationRequired
1263
- }), function (_getFeaturesReport) {
1264
- var featuresReport = _objectSpread2(_objectSpread2({
1265
- babelPluginRequiredNames: _babelPluginRequiredN
1266
- }, _getFeaturesReport), {}, {
1267
- customCompilerPatterns: customCompilerPatterns
1268
- });
1269
-
1270
- var canAvoidCompilation = featuresReport.customCompilerPatterns.length === 0 && featuresReport.jsenvPluginRequiredNames.length === 0 && featuresReport.babelPluginRequiredNames.length === 0 && featuresReport.importmapSupported && featuresReport.dynamicImportSupported && featuresReport.topLevelAwaitSupported;
1271
- return {
1270
+ inlineImportMapIntoHTML: inlineImportMapIntoHTML
1271
+ }), function () {
1272
+ return _await(pluginRequiredNamesFromGroupInfo(groupInfo, {
1272
1273
  featuresReport: featuresReport,
1273
- canAvoidCompilation: canAvoidCompilation,
1274
- inlineImportMapIntoHTML: inlineImportMapIntoHTML,
1275
- outDirectoryRelativeUrl: outDirectoryRelativeUrl,
1276
- compileId: compileId
1277
- };
1274
+ coverageHandledFromOutside: coverageHandledFromOutside
1275
+ }), function (pluginRequiredNameArray) {
1276
+ var canAvoidCompilation = customCompilerPatterns.length === 0 && pluginRequiredNameArray.length === 0 && featuresReport.importmap && featuresReport.dynamicImport && featuresReport.topLevelAwait;
1277
+ return {
1278
+ canAvoidCompilation: canAvoidCompilation,
1279
+ featuresReport: featuresReport,
1280
+ customCompilerPatterns: customCompilerPatterns,
1281
+ pluginRequiredNameArray: pluginRequiredNameArray,
1282
+ inlineImportMapIntoHTML: inlineImportMapIntoHTML,
1283
+ outDirectoryRelativeUrl: outDirectoryRelativeUrl,
1284
+ compileId: compileId,
1285
+ browser: browser
1286
+ };
1287
+ });
1278
1288
  });
1279
1289
  });
1280
1290
  });
1281
1291
  });
1282
1292
 
1283
- var getFeaturesReport = _async(function (_ref5) {
1284
- var failFastOnFeatureDetection = _ref5.failFastOnFeatureDetection,
1285
- groupInfo = _ref5.groupInfo,
1293
+ var detectSupportedFeatures = _async(function (_ref5) {
1294
+ var featuresReport = _ref5.featuresReport,
1295
+ failFastOnFeatureDetection = _ref5.failFastOnFeatureDetection,
1286
1296
  inlineImportMapIntoHTML = _ref5.inlineImportMapIntoHTML;
1287
- var featuresReport = {
1288
- jsenvPluginRequiredNames: [],
1289
- importmapSupported: undefined,
1290
- dynamicImportSupported: undefined,
1291
- topLevelAwaitSupported: undefined
1292
- };
1293
- var jsenvPluginRequiredNames = groupInfo.jsenvPluginRequiredNameArray;
1294
- featuresReport.jsenvPluginRequiredNames = jsenvPluginRequiredNames;
1295
- return jsenvPluginRequiredNames.length > 0 && failFastOnFeatureDetection ? featuresReport : _await(supportsImportmap({
1297
+ // start testing importmap support first and not in paralell
1298
+ // so that there is not module script loaded beore importmap is injected
1299
+ // it would log an error in chrome console and return undefined
1300
+ return _await(supportsImportmap({
1296
1301
  // chrome supports inline but not remote importmap
1297
1302
  // https://github.com/WICG/import-maps/issues/235
1298
1303
  // at this stage we won't know if the html file will use
@@ -1302,32 +1307,80 @@
1302
1307
  // and in that case we can test only the local importmap support
1303
1308
  // so we test importmap support and the remote one
1304
1309
  remote: !inlineImportMapIntoHTML
1305
- }), function (importmapSupported) {
1306
- featuresReport.importmapSupported = importmapSupported;
1307
- return !importmapSupported && failFastOnFeatureDetection ? featuresReport : _call(supportsDynamicImport, function (dynamicImportSupported) {
1308
- featuresReport.dynamicImportSupported = dynamicImportSupported;
1309
- return !dynamicImportSupported && failFastOnFeatureDetection ? featuresReport : _call(supportsTopLevelAwait, function (topLevelAwaitSupported) {
1310
- featuresReport.topLevelAwaitSupported = topLevelAwaitSupported;
1311
- return featuresReport;
1310
+ }), function (importmap) {
1311
+ featuresReport.importmap = importmap;
1312
+
1313
+ if (!importmap && failFastOnFeatureDetection) {
1314
+ return;
1315
+ }
1316
+
1317
+ return _call(supportsDynamicImport, function (dynamicImport) {
1318
+ featuresReport.dynamicImport = dynamicImport;
1319
+
1320
+ if (!dynamicImport && failFastOnFeatureDetection) {
1321
+ return;
1322
+ }
1323
+
1324
+ return _call(supportsTopLevelAwait, function (topLevelAwait) {
1325
+ featuresReport.topLevelAwait = topLevelAwait;
1312
1326
  });
1313
1327
  });
1314
1328
  });
1315
1329
  });
1316
1330
 
1317
- var babelPluginRequiredNamesFromGroupInfo = function babelPluginRequiredNamesFromGroupInfo(groupInfo, _ref6) {
1318
- var coverageInstrumentationRequired = _ref6.coverageInstrumentationRequired;
1319
- var babelPluginRequiredNameArray = groupInfo.babelPluginRequiredNameArray;
1320
- var babelPluginRequiredNames = babelPluginRequiredNameArray.slice(); // When instrumentation CAN be handed by playwright
1331
+ var pluginRequiredNamesFromGroupInfo = _async(function (groupInfo, _ref6) {
1332
+ var featuresReport = _ref6.featuresReport,
1333
+ coverageHandledFromOutside = _ref6.coverageHandledFromOutside;
1334
+ var pluginRequiredNameArray = groupInfo.pluginRequiredNameArray;
1335
+ var requiredPluginNames = pluginRequiredNameArray.slice();
1336
+
1337
+ var markPluginAsSupported = function markPluginAsSupported(name) {
1338
+ var index = requiredPluginNames.indexOf(name);
1339
+
1340
+ if (index > -1) {
1341
+ requiredPluginNames.splice(index, 1);
1342
+ }
1343
+ }; // When instrumentation CAN be handed by playwright
1321
1344
  // https://playwright.dev/docs/api/class-chromiumcoverage#chromiumcoveragestartjscoverageoptions
1322
- // coverageInstrumentationRequired is false and "transform-instrument" becomes non mandatory
1345
+ // coverageHandledFromOutside is true and "transform-instrument" becomes non mandatory
1323
1346
 
1324
- var transformInstrumentIndex = babelPluginRequiredNames.indexOf("transform-instrument");
1325
1347
 
1326
- if (transformInstrumentIndex > -1 && !coverageInstrumentationRequired) {
1327
- babelPluginRequiredNames.splice(transformInstrumentIndex, 1);
1348
+ if (coverageHandledFromOutside) {
1349
+ markPluginAsSupported("transform-instrument");
1328
1350
  }
1329
1351
 
1330
- return babelPluginRequiredNames;
1352
+ return _invoke(function () {
1353
+ if (pluginRequiredNameArray.includes("transform-import-assertions")) {
1354
+ return _call(supportsJsonImportAssertions, function (jsonImportAssertions) {
1355
+ featuresReport.jsonImportAssertions = jsonImportAssertions;
1356
+ return _call(supportsCssImportAssertions, function (cssImportAssertions) {
1357
+ featuresReport.cssImportAssertions = cssImportAssertions;
1358
+
1359
+ if (jsonImportAssertions && cssImportAssertions) {
1360
+ markPluginAsSupported("transform-import-assertions");
1361
+ }
1362
+ });
1363
+ });
1364
+ }
1365
+ }, function () {
1366
+ if (pluginRequiredNameArray.includes("new-stylesheet-as-jsenv-import")) {
1367
+ var newStylesheet = supportsNewStylesheet();
1368
+ featuresReport.newStylesheet = newStylesheet;
1369
+ markPluginAsSupported("new-stylesheet-as-jsenv-import");
1370
+ }
1371
+
1372
+ return requiredPluginNames;
1373
+ });
1374
+ });
1375
+
1376
+ var supportsNewStylesheet = function supportsNewStylesheet() {
1377
+ try {
1378
+ // eslint-disable-next-line no-new
1379
+ new CSSStyleSheet();
1380
+ return true;
1381
+ } catch (e) {
1382
+ return false;
1383
+ }
1331
1384
  };
1332
1385
 
1333
1386
  var supportsImportmap = _async(function () {
@@ -1335,9 +1388,9 @@
1335
1388
  _ref7$remote = _ref7.remote,
1336
1389
  remote = _ref7$remote === void 0 ? true : _ref7$remote;
1337
1390
 
1338
- var specifier = jsToTextUrl("export default false");
1391
+ var specifier = asBase64Url("export default false");
1339
1392
  var importMap = {
1340
- imports: _defineProperty({}, specifier, jsToTextUrl("export default true"))
1393
+ imports: _defineProperty({}, specifier, asBase64Url("export default true"))
1341
1394
  };
1342
1395
  var importmapScript = document.createElement("script");
1343
1396
  var importmapString = JSON.stringify(importMap, null, " ");
@@ -1352,7 +1405,7 @@
1352
1405
  document.body.appendChild(importmapScript);
1353
1406
  var scriptModule = document.createElement("script");
1354
1407
  scriptModule.type = "module";
1355
- scriptModule.src = jsToTextUrl("import supported from \"".concat(specifier, "\"; window.__importmap_supported = supported"));
1408
+ scriptModule.src = asBase64Url("import supported from \"".concat(specifier, "\"; window.__importmap_supported = supported"));
1356
1409
  return new Promise(function (resolve, reject) {
1357
1410
  scriptModule.onload = function () {
1358
1411
  var supported = window.__importmap_supported;
@@ -1372,12 +1425,8 @@
1372
1425
  });
1373
1426
  });
1374
1427
 
1375
- var jsToTextUrl = function jsToTextUrl(js) {
1376
- return "data:text/javascript;base64,".concat(window.btoa(js));
1377
- };
1378
-
1379
1428
  var supportsDynamicImport = _async(function () {
1380
- var moduleSource = jsToTextUrl("export default 42");
1429
+ var moduleSource = asBase64Url("export default 42");
1381
1430
  return _catch(function () {
1382
1431
  return _await(import(moduleSource), function (namespace) {
1383
1432
  return namespace.default === 42;
@@ -1388,7 +1437,7 @@
1388
1437
  });
1389
1438
 
1390
1439
  var supportsTopLevelAwait = _async(function () {
1391
- var moduleSource = jsToTextUrl("export default await Promise.resolve(42)");
1440
+ var moduleSource = asBase64Url("export default await Promise.resolve(42)");
1392
1441
  return _catch(function () {
1393
1442
  return _await(import(moduleSource), function (namespace) {
1394
1443
  return namespace.default === 42;
@@ -1398,6 +1447,35 @@
1398
1447
  });
1399
1448
  });
1400
1449
 
1450
+ var supportsJsonImportAssertions = _async(function () {
1451
+ var jsonBase64Url = asBase64Url("42", "application/json");
1452
+ var moduleSource = asBase64Url("export { default } from \"".concat(jsonBase64Url, "\" assert { type: \"json\" }"));
1453
+ return _catch(function () {
1454
+ return _await(import(moduleSource), function (namespace) {
1455
+ return namespace.default === 42;
1456
+ });
1457
+ }, function () {
1458
+ return false;
1459
+ });
1460
+ });
1461
+
1462
+ var supportsCssImportAssertions = _async(function () {
1463
+ var cssBase64Url = asBase64Url("p { color: red; }", "text/css");
1464
+ var moduleSource = asBase64Url("export { default } from \"".concat(cssBase64Url, "\" assert { type: \"css\" }"));
1465
+ return _catch(function () {
1466
+ return _await(import(moduleSource), function (namespace) {
1467
+ return namespace.default instanceof CSSStyleSheet;
1468
+ });
1469
+ }, function () {
1470
+ return false;
1471
+ });
1472
+ });
1473
+
1474
+ var asBase64Url = function asBase64Url(text) {
1475
+ var mimeType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "application/javascript";
1476
+ return "data:".concat(mimeType, ";base64,").concat(window.btoa(text));
1477
+ };
1478
+
1401
1479
  /* eslint-env browser */
1402
1480
  window.scanBrowserRuntimeFeatures = scanBrowserRuntimeFeatures;
1403
1481