@jsenv/core 27.0.0-alpha.9 → 27.0.0-alpha.92
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/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
- package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -0
- package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
- package/dist/babel_helpers/applyDecs/applyDecs.js +756 -0
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
- package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +78 -0
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
- package/dist/babel_helpers/classCallCheck/classCallCheck.js +5 -0
- package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
- package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
- package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
- package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
- package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
- package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
- package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
- package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
- package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
- package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
- package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
- package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
- package/dist/babel_helpers/construct/construct.js +15 -0
- package/dist/babel_helpers/createClass/createClass.js +18 -0
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
- package/dist/babel_helpers/createSuper/createSuper.js +22 -0
- package/dist/babel_helpers/decorate/decorate.js +622 -0
- package/dist/babel_helpers/defaults/defaults.js +14 -0
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
- package/dist/babel_helpers/defineProperty/defineProperty.js +19 -0
- package/dist/babel_helpers/extends/extends.js +16 -0
- package/dist/babel_helpers/get/get.js +21 -0
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
- package/dist/babel_helpers/identity/identity.js +3 -0
- package/dist/babel_helpers/inherits/inherits.js +21 -0
- package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
- package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
- package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
- package/dist/babel_helpers/instanceof/instanceof.js +7 -0
- package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
- package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
- package/dist/babel_helpers/iterableToArray/iterableToArray.js +3 -0
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
- package/dist/babel_helpers/jsx/jsx.js +49 -0
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
- package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
- package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
- package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
- package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
- package/dist/babel_helpers/objectSpread/objectSpread.js +22 -0
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +41 -0
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
- package/dist/babel_helpers/readOnlyError/readOnlyError.js +4 -0
- package/dist/babel_helpers/set/set.js +51 -0
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
- package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
- package/dist/babel_helpers/slicedToArray/slicedToArray.js +5 -0
- package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
- package/dist/babel_helpers/superPropBase/superPropBase.js +10 -0
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
- package/dist/babel_helpers/tdz/tdz.js +4 -0
- package/dist/babel_helpers/temporalRef/temporalRef.js +5 -0
- package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
- package/dist/babel_helpers/toArray/toArray.js +5 -0
- package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +14 -0
- package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
- package/dist/babel_helpers/typeof/typeof.js +7 -0
- package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
- package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
- package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
- package/dist/html/explorer.html +557 -0
- package/dist/js/controllable_file.mjs +227 -0
- package/dist/js/event_source_client.js +528 -0
- package/dist/js/global_this.js +32 -0
- package/dist/js/html_supervisor_installer.js +522 -0
- package/dist/js/html_supervisor_setup.js +82 -0
- package/dist/js/import_meta_hot.js +84 -0
- package/dist/js/inline_content.js +8 -0
- package/dist/js/new_stylesheet.js +409 -0
- package/dist/js/regenerator_runtime.js +721 -0
- package/dist/js/s.js +429 -0
- package/dist/js/uneval.js +804 -0
- package/dist/main.js +25163 -0
- package/dist/other/jsenv.png +0 -0
- package/dist/s.js +626 -0
- package/dist/s.js.map +205 -0
- package/package.json +61 -57
- package/readme.md +6 -14
- package/src/build/build.js +1040 -551
- package/src/build/build_urls_generator.js +65 -25
- package/src/build/graph_utils.js +31 -0
- package/src/build/inject_global_version_mappings.js +93 -0
- package/src/build/inject_service_worker_urls.js +79 -0
- package/src/build/resync_ressource_hints.js +114 -0
- package/src/build/start_build_server.js +217 -0
- package/src/build/version_generator.js +60 -0
- package/src/dev/plugins/explorer/client/explorer.html +1 -1
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +9 -14
- package/src/dev/plugins/toolbar/client/util/fetching.js +1 -1
- package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +6 -4
- package/src/dev/start_dev_server.js +173 -38
- package/src/execute/execute.js +35 -8
- package/src/execute/run.js +21 -57
- package/src/execute/runtimes/browsers/from_playwright.js +224 -153
- package/src/execute/runtimes/node/child_exec_options.js +1 -1
- package/src/execute/runtimes/node/controllable_file.mjs +26 -10
- package/src/execute/runtimes/node/kill_process_tree.js +2 -4
- package/src/execute/runtimes/node/node_execution_performance.js +67 -0
- package/src/execute/runtimes/node/node_process.js +288 -39
- package/src/helpers/command/command.js +73 -0
- package/src/{dev/plugins/autoreload/client/event_source_connection.js → helpers/event_source/event_source.js} +2 -0
- package/src/helpers/event_source/sse_service.js +53 -0
- package/src/helpers/worker_reload.js +57 -0
- package/src/main.js +27 -0
- package/src/omega/{runtime_support/features_compatibility.js → compat/features_compats.js} +30 -7
- package/src/omega/{runtime_support/runtime_support.js → compat/runtime_compat.js} +16 -17
- package/src/omega/errors.js +63 -67
- package/src/omega/fetched_content_compliance.js +24 -0
- package/src/omega/file_url_converter.js +9 -51
- package/src/omega/kitchen.js +607 -466
- package/src/omega/omega_server.js +2 -3
- package/src/omega/server/file_service.js +88 -41
- package/src/omega/server/user_agent.js +5 -5
- package/src/omega/url_graph/{url_graph_sort.js → sort_by_dependencies.js} +3 -5
- package/src/omega/url_graph/url_graph_load.js +31 -23
- package/src/omega/url_graph/url_graph_report.js +94 -51
- package/src/omega/url_graph/url_info_transformations.js +54 -24
- package/src/omega/url_graph.js +88 -19
- package/src/omega/url_specifier_encoding.js +59 -0
- package/src/omega/web_workers.js +42 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js +0 -0
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js +19 -12
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/reload.js +6 -3
- package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/url_helpers.js +0 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +41 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +204 -0
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +25 -0
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +35 -0
- package/src/plugins/bundling/css/bundle_css.js +140 -0
- package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +13 -0
- package/src/plugins/bundling/js_module/bundle_js_module.js +362 -0
- package/src/plugins/bundling/jsenv_plugin_bundling.js +54 -0
- package/src/plugins/cache_control/jsenv_plugin_cache_control.js +34 -0
- package/src/{omega/core_plugins → plugins}/commonjs_globals/jsenv_plugin_commonjs_globals.js +56 -43
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +190 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_document.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_notification.js +0 -0
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +254 -0
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +82 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/perf_browser.js +0 -0
- package/src/{omega/core_plugins → plugins}/html_supervisor/client/uneval_exception.js +0 -0
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +239 -0
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +16 -0
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/babel_plugin_metadata_import_meta_hot.js +4 -5
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/client/import_meta_hot.js +3 -1
- package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/html_hot_dependencies.js +15 -18
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +100 -0
- package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +35 -10
- package/src/plugins/import_meta_url/client/import_meta_url_browser.js +52 -0
- package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +9 -0
- package/src/{omega/core_plugins → plugins}/importmap/jsenv_plugin_importmap.js +56 -54
- package/src/plugins/inject_globals/inject_globals.js +57 -0
- package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +24 -0
- package/src/{omega/core_plugins → plugins}/inline/client/inline_content.js +0 -0
- package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_data_urls.js +22 -21
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +159 -0
- package/src/plugins/inline/jsenv_plugin_inline.js +36 -0
- package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_inline_query_param.js +8 -11
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +294 -0
- package/src/plugins/leading_slash/jsenv_plugin_leading_slash.js +13 -0
- package/src/plugins/minification/css/minify_css.js +9 -0
- package/src/plugins/minification/html/minify_html.js +13 -0
- package/src/{build/plugins/minify_js/jsenv_plugin_minify_js.js → plugins/minification/js/minify_js.js} +6 -22
- package/src/plugins/minification/jsenv_plugin_minification.js +78 -0
- package/src/plugins/minification/json/minify_json.js +8 -0
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +162 -0
- package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
- package/src/{omega → plugins}/plugin_controller.js +57 -12
- package/src/plugins/plugins.js +91 -0
- package/src/plugins/transpilation/as_js_classic/client/s.js +429 -0
- package/src/plugins/transpilation/as_js_classic/helpers/babel_plugin_transform_import_meta_url.js +47 -0
- package/src/plugins/transpilation/as_js_classic/helpers/systemjs_old.js +43 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +209 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +282 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_workers.js +55 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +2 -3
- package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/client/global_this.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +3 -4
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_structure.js +14 -17
- package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugins_compatibility.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/jsenv_plugin_babel.js +40 -33
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +32 -9
- package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/new_stylesheet.js +0 -0
- package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +2 -3
- package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/client/regenerator_runtime.js +0 -0
- package/src/plugins/transpilation/babel/require_babel_plugin.js +8 -0
- package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +18 -0
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +184 -0
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +80 -0
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +46 -0
- package/src/plugins/url_analysis/css/css_urls.js +48 -0
- package/src/plugins/url_analysis/html/html_urls.js +257 -0
- package/src/plugins/url_analysis/js/js_urls.js +69 -0
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +110 -0
- package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +20 -0
- package/src/{omega/core_plugins → plugins}/url_resolution/jsenv_plugin_url_resolution.js +9 -5
- package/src/plugins/url_version/jsenv_plugin_url_version.js +28 -0
- package/src/require_from_jsenv.js +3 -0
- package/src/test/coverage/babel_plugin_instrument.js +82 -0
- package/src/test/coverage/coverage_reporter_html_directory.js +36 -0
- package/src/test/coverage/coverage_reporter_json_file.js +22 -0
- package/src/test/coverage/coverage_reporter_text_log.js +19 -0
- package/src/test/coverage/empty_coverage_factory.js +52 -0
- package/src/test/coverage/file_by_file_coverage.js +25 -0
- package/src/test/coverage/istanbul_coverage_composition.js +28 -0
- package/src/test/coverage/istanbul_coverage_map_from_coverage.js +16 -0
- package/src/test/coverage/list_files_not_covered.js +15 -0
- package/src/test/coverage/missing_coverage.js +41 -0
- package/src/test/coverage/report_to_coverage.js +196 -0
- package/src/test/coverage/v8_and_istanbul.js +37 -0
- package/src/test/coverage/v8_coverage_composition.js +24 -0
- package/src/test/coverage/v8_coverage_from_directory.js +87 -0
- package/src/test/coverage/v8_coverage_to_istanbul.js +99 -0
- package/src/test/execute_plan.js +87 -46
- package/src/test/execute_test_plan.js +40 -28
- package/src/test/execution_steps.js +2 -5
- package/src/test/logs_file_execution.js +56 -49
- package/main.js +0 -19
- package/src/build/inject_version_mappings.js +0 -62
- package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +0 -227
- package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +0 -30
- package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +0 -374
- package/src/dev/plugins/autoreload/sse_service.js +0 -149
- package/src/execute/runtimes/node/controlled_process.js +0 -316
- package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
- package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +0 -67
- package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -58
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +0 -168
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +0 -77
- package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +0 -233
- package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -98
- package/src/omega/core_plugins/import_assertions/helpers/json_module.js +0 -12
- package/src/omega/core_plugins/import_assertions/helpers/text_module.js +0 -6
- package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +0 -211
- package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +0 -13
- package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +0 -142
- package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +0 -207
- package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +0 -12
- package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +0 -77
- package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +0 -50
- package/src/omega/core_plugins.js +0 -39
- package/src/omega/runtime_support/default_runtime_support.js +0 -13
- package/src/omega/url_mentions/css_url_mentions.js +0 -63
- package/src/omega/url_mentions/html_url_mentions.js +0 -185
- package/src/omega/url_mentions/js_module_url_mentions.js +0 -91
- package/src/omega/url_mentions/parse_url_mentions.js +0 -37
- package/src/omega/url_mentions/worker_classic_url_mentions.js +0 -37
package/src/omega/kitchen.js
CHANGED
|
@@ -1,162 +1,221 @@
|
|
|
1
1
|
import {
|
|
2
2
|
urlIsInsideOf,
|
|
3
|
-
writeFileSync,
|
|
4
|
-
isFileSystemPath,
|
|
5
|
-
fileSystemPathToUrl,
|
|
6
3
|
moveUrl,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
getCallerPosition,
|
|
5
|
+
stringifyUrlSite,
|
|
6
|
+
normalizeUrl,
|
|
7
|
+
setUrlFilename,
|
|
8
|
+
} from "@jsenv/urls"
|
|
9
|
+
import { writeFileSync, ensureWindowsDriveLetter } from "@jsenv/filesystem"
|
|
10
|
+
import { createDetailedMessage } from "@jsenv/log"
|
|
11
|
+
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js"
|
|
11
12
|
|
|
13
|
+
import { createPluginController } from "../plugins/plugin_controller.js"
|
|
14
|
+
import { urlSpecifierEncoding } from "./url_specifier_encoding.js"
|
|
12
15
|
import { createUrlInfoTransformer } from "./url_graph/url_info_transformations.js"
|
|
13
|
-
import {
|
|
14
|
-
import { fileUrlConverter } from "./file_url_converter.js"
|
|
15
|
-
import { parseUrlMentions } from "./url_mentions/parse_url_mentions.js"
|
|
16
|
+
import { RUNTIME_COMPAT } from "./compat/runtime_compat.js"
|
|
16
17
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
createResolveUrlError,
|
|
19
|
+
createFetchUrlContentError,
|
|
20
|
+
createTransformUrlContentError,
|
|
21
|
+
createFinalizeUrlContentError,
|
|
21
22
|
} from "./errors.js"
|
|
22
|
-
import {
|
|
23
|
+
import { assertFetchedContentCompliance } from "./fetched_content_compliance.js"
|
|
24
|
+
import { isWebWorkerEntryPointReference } from "./web_workers.js"
|
|
23
25
|
|
|
24
26
|
export const createKitchen = ({
|
|
25
27
|
signal,
|
|
26
28
|
logger,
|
|
27
29
|
rootDirectoryUrl,
|
|
28
30
|
urlGraph,
|
|
31
|
+
|
|
29
32
|
plugins,
|
|
30
33
|
scenario,
|
|
31
|
-
|
|
32
34
|
sourcemaps = {
|
|
33
35
|
dev: "inline", // "programmatic" and "file" also allowed
|
|
34
36
|
test: "inline",
|
|
35
37
|
build: "none",
|
|
36
38
|
}[scenario],
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
writeOnFileSystem = true,
|
|
39
|
+
sourcemapsSourcesContent = {
|
|
40
|
+
// during dev/test, chrome is able to find the sourcemap sources
|
|
41
|
+
// as long as they use file:// protocol in the sourcemap files
|
|
42
|
+
dev: false,
|
|
43
|
+
test: false,
|
|
44
|
+
build: true,
|
|
45
|
+
}[scenario],
|
|
46
|
+
sourcemapsRelativeSources,
|
|
47
|
+
runtimeCompat,
|
|
48
|
+
writeGeneratedFiles,
|
|
48
49
|
}) => {
|
|
49
50
|
const pluginController = createPluginController({
|
|
50
51
|
plugins,
|
|
51
52
|
scenario,
|
|
52
53
|
})
|
|
53
54
|
const jsenvDirectoryUrl = new URL(".jsenv/", rootDirectoryUrl).href
|
|
54
|
-
const
|
|
55
|
+
const kitchenContext = {
|
|
55
56
|
signal,
|
|
56
57
|
logger,
|
|
57
58
|
rootDirectoryUrl,
|
|
58
59
|
sourcemaps,
|
|
59
60
|
urlGraph,
|
|
60
61
|
scenario,
|
|
62
|
+
runtimeCompat,
|
|
63
|
+
isSupportedOnFutureClients: (feature) => {
|
|
64
|
+
return RUNTIME_COMPAT.isSupported(runtimeCompat, feature)
|
|
65
|
+
},
|
|
61
66
|
}
|
|
62
67
|
const createReference = ({
|
|
63
68
|
data = {},
|
|
69
|
+
node,
|
|
64
70
|
trace,
|
|
65
71
|
parentUrl,
|
|
66
72
|
type,
|
|
67
73
|
subtype,
|
|
74
|
+
expectedContentType,
|
|
75
|
+
expectedType,
|
|
76
|
+
expectedSubtype,
|
|
77
|
+
filename,
|
|
78
|
+
integrity,
|
|
79
|
+
crossorigin,
|
|
68
80
|
specifier,
|
|
81
|
+
specifierStart,
|
|
82
|
+
specifierEnd,
|
|
83
|
+
specifierLine,
|
|
84
|
+
specifierColumn,
|
|
85
|
+
baseUrl,
|
|
86
|
+
isOriginalPosition,
|
|
87
|
+
shouldHandle,
|
|
69
88
|
isInline = false,
|
|
89
|
+
injected = false,
|
|
90
|
+
isRessourceHint = false,
|
|
70
91
|
content,
|
|
71
92
|
contentType,
|
|
93
|
+
assert,
|
|
94
|
+
assertNode,
|
|
95
|
+
typePropertyNode,
|
|
72
96
|
}) => {
|
|
97
|
+
if (typeof specifier !== "string") {
|
|
98
|
+
throw new TypeError(`"specifier" must be a string, got ${specifier}`)
|
|
99
|
+
}
|
|
73
100
|
return {
|
|
101
|
+
original: null,
|
|
102
|
+
prev: null,
|
|
103
|
+
next: null,
|
|
74
104
|
data,
|
|
105
|
+
node,
|
|
75
106
|
trace,
|
|
76
107
|
parentUrl,
|
|
77
108
|
type,
|
|
78
109
|
subtype,
|
|
110
|
+
expectedContentType,
|
|
111
|
+
expectedType,
|
|
112
|
+
expectedSubtype,
|
|
113
|
+
filename,
|
|
114
|
+
integrity,
|
|
115
|
+
crossorigin,
|
|
79
116
|
specifier,
|
|
117
|
+
specifierStart,
|
|
118
|
+
specifierEnd,
|
|
119
|
+
specifierLine,
|
|
120
|
+
specifierColumn,
|
|
121
|
+
baseUrl,
|
|
122
|
+
isOriginalPosition,
|
|
123
|
+
shouldHandle,
|
|
80
124
|
isInline,
|
|
125
|
+
injected,
|
|
126
|
+
isRessourceHint,
|
|
81
127
|
// for inline ressources the reference contains the content
|
|
82
128
|
content,
|
|
83
129
|
contentType,
|
|
130
|
+
timing: {},
|
|
131
|
+
assert,
|
|
132
|
+
assertNode,
|
|
133
|
+
typePropertyNode,
|
|
84
134
|
}
|
|
85
135
|
}
|
|
136
|
+
const mutateReference = (reference, newReference) => {
|
|
137
|
+
reference.next = newReference
|
|
138
|
+
newReference.prev = reference
|
|
139
|
+
newReference.original = reference.original || reference
|
|
140
|
+
}
|
|
86
141
|
const resolveReference = (reference) => {
|
|
87
142
|
try {
|
|
88
|
-
|
|
89
|
-
"
|
|
143
|
+
let resolvedUrl = pluginController.callHooksUntil(
|
|
144
|
+
"resolveUrl",
|
|
90
145
|
reference,
|
|
91
|
-
|
|
146
|
+
kitchenContext,
|
|
92
147
|
)
|
|
93
148
|
if (!resolvedUrl) {
|
|
94
149
|
throw new Error(`NO_RESOLVE`)
|
|
95
150
|
}
|
|
151
|
+
resolvedUrl = normalizeUrl(resolvedUrl)
|
|
96
152
|
reference.url = resolvedUrl
|
|
97
153
|
pluginController.callHooks(
|
|
98
|
-
"
|
|
154
|
+
"redirectUrl",
|
|
99
155
|
reference,
|
|
100
|
-
|
|
156
|
+
kitchenContext,
|
|
101
157
|
(returnValue) => {
|
|
102
|
-
|
|
158
|
+
const normalizedReturnValue = normalizeUrl(returnValue)
|
|
159
|
+
if (normalizedReturnValue === reference.url) {
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
const previousReference = { ...reference }
|
|
163
|
+
reference.url = normalizedReturnValue
|
|
164
|
+
mutateReference(previousReference, reference)
|
|
103
165
|
},
|
|
104
166
|
)
|
|
105
|
-
|
|
106
|
-
// some plugin use URLSearchParams to alter the url search params
|
|
107
|
-
// which can result into "file:///file.css?css_module"
|
|
108
|
-
// becoming "file:///file.css?css_module="
|
|
109
|
-
// we want to get rid of the "=" and consider it's the same url
|
|
110
|
-
if (
|
|
111
|
-
// disable on data urls (would mess up base64 encoding)
|
|
112
|
-
!reference.url.startsWith("data:")
|
|
113
|
-
) {
|
|
114
|
-
reference.url = reference.url.replace(/[=](?=&|$)/g, "")
|
|
115
|
-
}
|
|
167
|
+
|
|
116
168
|
const urlInfo = urlGraph.reuseOrCreateUrlInfo(reference.url)
|
|
117
|
-
|
|
169
|
+
applyReferenceEffectsOnUrlInfo(reference, urlInfo, kitchenContext)
|
|
118
170
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
171
|
+
const referenceUrlObject = new URL(reference.url)
|
|
172
|
+
reference.searchParams = referenceUrlObject.searchParams
|
|
173
|
+
reference.generatedUrl = reference.url
|
|
174
|
+
// This hook must touch reference.generatedUrl, NOT reference.url
|
|
175
|
+
// And this is because this hook inject query params used to:
|
|
176
|
+
// - bypass browser cache (?v)
|
|
177
|
+
// - convey information (?hmr)
|
|
178
|
+
// But do not represent an other ressource, it is considered as
|
|
179
|
+
// the same ressource under the hood
|
|
124
180
|
pluginController.callHooks(
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
181
|
+
"transformUrlSearchParams",
|
|
182
|
+
reference,
|
|
183
|
+
kitchenContext,
|
|
128
184
|
(returnValue) => {
|
|
129
|
-
|
|
185
|
+
Object.keys(returnValue).forEach((key) => {
|
|
186
|
+
referenceUrlObject.searchParams.set(key, returnValue[key])
|
|
187
|
+
})
|
|
188
|
+
reference.generatedUrl = normalizeUrl(referenceUrlObject.href)
|
|
130
189
|
},
|
|
131
190
|
)
|
|
132
|
-
reference.generatedUrl = referencedCopy.url
|
|
133
191
|
const returnValue = pluginController.callHooksUntil(
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
192
|
+
"formatUrl",
|
|
193
|
+
reference,
|
|
194
|
+
kitchenContext,
|
|
137
195
|
)
|
|
138
196
|
reference.generatedSpecifier = returnValue || reference.generatedUrl
|
|
139
|
-
reference.generatedSpecifier =
|
|
197
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference)
|
|
140
198
|
return urlInfo
|
|
141
199
|
} catch (error) {
|
|
142
|
-
throw
|
|
200
|
+
throw createResolveUrlError({
|
|
143
201
|
pluginController,
|
|
144
202
|
reference,
|
|
145
203
|
error,
|
|
146
204
|
})
|
|
147
205
|
}
|
|
148
206
|
}
|
|
207
|
+
kitchenContext.resolveReference = resolveReference
|
|
149
208
|
const urlInfoTransformer = createUrlInfoTransformer({
|
|
150
209
|
logger,
|
|
151
210
|
urlGraph,
|
|
152
211
|
sourcemaps,
|
|
153
|
-
|
|
212
|
+
sourcemapsSourcesContent,
|
|
213
|
+
sourcemapsRelativeSources,
|
|
154
214
|
injectSourcemapPlaceholder: ({ urlInfo, specifier }) => {
|
|
155
215
|
const sourcemapReference = createReference({
|
|
156
216
|
trace: `sourcemap comment placeholder for ${urlInfo.url}`,
|
|
157
217
|
type: "sourcemap_comment",
|
|
158
|
-
subtype:
|
|
159
|
-
urlInfo.contentType === "application/javascript" ? "js" : "css",
|
|
218
|
+
subtype: urlInfo.contentType === "text/javascript" ? "js" : "css",
|
|
160
219
|
parentUrl: urlInfo.url,
|
|
161
220
|
specifier,
|
|
162
221
|
})
|
|
@@ -164,19 +223,27 @@ export const createKitchen = ({
|
|
|
164
223
|
sourcemapUrlInfo.type = "sourcemap"
|
|
165
224
|
return [sourcemapReference, sourcemapUrlInfo]
|
|
166
225
|
},
|
|
167
|
-
foundSourcemap: ({
|
|
226
|
+
foundSourcemap: ({
|
|
227
|
+
urlInfo,
|
|
228
|
+
type,
|
|
229
|
+
specifier,
|
|
230
|
+
specifierLine,
|
|
231
|
+
specifierColumn,
|
|
232
|
+
}) => {
|
|
168
233
|
const sourcemapReference = createReference({
|
|
169
234
|
trace: stringifyUrlSite(
|
|
170
235
|
adjustUrlSite(urlInfo, {
|
|
171
236
|
urlGraph,
|
|
172
237
|
url: urlInfo.url,
|
|
173
|
-
line,
|
|
174
|
-
column,
|
|
238
|
+
line: specifierLine,
|
|
239
|
+
column: specifierColumn,
|
|
175
240
|
}),
|
|
176
241
|
),
|
|
177
242
|
type,
|
|
178
243
|
parentUrl: urlInfo.url,
|
|
179
244
|
specifier,
|
|
245
|
+
specifierLine,
|
|
246
|
+
specifierColumn,
|
|
180
247
|
})
|
|
181
248
|
const sourcemapUrlInfo = resolveReference(sourcemapReference)
|
|
182
249
|
sourcemapUrlInfo.type = "sourcemap"
|
|
@@ -184,61 +251,82 @@ export const createKitchen = ({
|
|
|
184
251
|
},
|
|
185
252
|
})
|
|
186
253
|
|
|
187
|
-
const
|
|
254
|
+
const fetchUrlContent = async (urlInfo, { reference, context }) => {
|
|
188
255
|
try {
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
256
|
+
const fetchUrlContentReturnValue =
|
|
257
|
+
await pluginController.callAsyncHooksUntil(
|
|
258
|
+
"fetchUrlContent",
|
|
259
|
+
urlInfo,
|
|
260
|
+
context,
|
|
261
|
+
)
|
|
262
|
+
if (!fetchUrlContentReturnValue) {
|
|
263
|
+
logger.warn(
|
|
264
|
+
createDetailedMessage(
|
|
265
|
+
`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`,
|
|
266
|
+
{
|
|
267
|
+
"url": urlInfo.url,
|
|
268
|
+
"url reference trace": reference.trace,
|
|
269
|
+
},
|
|
270
|
+
),
|
|
271
|
+
)
|
|
272
|
+
return
|
|
194
273
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
contentType = "application/octet-stream",
|
|
198
|
-
content, // can be a buffer (used for binary files) or a string
|
|
199
|
-
sourcemap,
|
|
200
|
-
// during build urls info are reused and load returns originalContent
|
|
201
|
-
// that we want to keep
|
|
202
|
-
originalContent = content,
|
|
203
|
-
data,
|
|
204
|
-
} = loadReturnValue
|
|
205
|
-
Object.assign(urlInfo, {
|
|
274
|
+
let {
|
|
275
|
+
content,
|
|
206
276
|
contentType,
|
|
277
|
+
data,
|
|
278
|
+
type,
|
|
279
|
+
subtype,
|
|
280
|
+
originalUrl,
|
|
207
281
|
originalContent,
|
|
208
|
-
content,
|
|
209
282
|
sourcemap,
|
|
210
|
-
|
|
283
|
+
filename,
|
|
284
|
+
|
|
285
|
+
status = 200,
|
|
286
|
+
headers = {},
|
|
287
|
+
body,
|
|
288
|
+
} = fetchUrlContentReturnValue
|
|
289
|
+
if (status !== 200) {
|
|
290
|
+
throw new Error(`unexpected status, ${status}`)
|
|
291
|
+
}
|
|
292
|
+
if (content === undefined) {
|
|
293
|
+
content = body
|
|
294
|
+
}
|
|
295
|
+
if (contentType === undefined) {
|
|
296
|
+
contentType = headers["content-type"] || "application/octet-stream"
|
|
297
|
+
}
|
|
298
|
+
urlInfo.contentType = contentType
|
|
299
|
+
urlInfo.headers = headers
|
|
300
|
+
urlInfo.type =
|
|
301
|
+
type ||
|
|
302
|
+
reference.expectedType ||
|
|
303
|
+
inferUrlInfoType({ url: urlInfo.url, contentType })
|
|
304
|
+
urlInfo.subtype =
|
|
305
|
+
subtype ||
|
|
306
|
+
reference.expectedSubtype ||
|
|
307
|
+
inferUrlInfoSubtype({
|
|
308
|
+
url: urlInfo.url,
|
|
309
|
+
type: urlInfo.type,
|
|
310
|
+
subtype: urlInfo.subtype,
|
|
311
|
+
})
|
|
312
|
+
// during build urls info are reused and load returns originalUrl/originalContent
|
|
313
|
+
urlInfo.originalUrl = originalUrl || urlInfo.originalUrl
|
|
314
|
+
urlInfo.originalContent =
|
|
315
|
+
originalContent === undefined ? content : originalContent
|
|
316
|
+
urlInfo.content = content
|
|
317
|
+
urlInfo.sourcemap = sourcemap
|
|
211
318
|
if (data) {
|
|
212
319
|
Object.assign(urlInfo.data, data)
|
|
213
320
|
}
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
if (type === "js") {
|
|
217
|
-
const urlObject = new URL(urlInfo.url)
|
|
218
|
-
if (urlObject.searchParams.has("worker_type_classic")) {
|
|
219
|
-
urlInfo.type = "js_classic"
|
|
220
|
-
urlInfo.subtype = "worker"
|
|
221
|
-
} else if (
|
|
222
|
-
urlObject.searchParams.has("service_worker_type_classic")
|
|
223
|
-
) {
|
|
224
|
-
urlInfo.type = "js_classic"
|
|
225
|
-
urlInfo.subtype = "service_worker"
|
|
226
|
-
} else if (urlObject.searchParams.has("js_classic")) {
|
|
227
|
-
urlInfo.type = "js_classic"
|
|
228
|
-
} else {
|
|
229
|
-
urlInfo.type = "js_module"
|
|
230
|
-
}
|
|
231
|
-
if (urlObject.searchParams.has("worker")) {
|
|
232
|
-
urlInfo.subtype = "worker"
|
|
233
|
-
} else if (urlObject.searchParams.has("service_worker")) {
|
|
234
|
-
urlInfo.subtype = "service_worker"
|
|
235
|
-
}
|
|
236
|
-
} else {
|
|
237
|
-
urlInfo.type = type
|
|
238
|
-
}
|
|
321
|
+
if (filename) {
|
|
322
|
+
urlInfo.filename = filename
|
|
239
323
|
}
|
|
324
|
+
assertFetchedContentCompliance({
|
|
325
|
+
reference,
|
|
326
|
+
urlInfo,
|
|
327
|
+
})
|
|
240
328
|
} catch (error) {
|
|
241
|
-
throw
|
|
329
|
+
throw createFetchUrlContentError({
|
|
242
330
|
pluginController,
|
|
243
331
|
urlInfo,
|
|
244
332
|
reference,
|
|
@@ -246,270 +334,238 @@ export const createKitchen = ({
|
|
|
246
334
|
})
|
|
247
335
|
}
|
|
248
336
|
urlInfo.generatedUrl = determineFileUrlForOutDirectory({
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
url: urlInfo.url,
|
|
337
|
+
urlInfo,
|
|
338
|
+
context,
|
|
252
339
|
})
|
|
253
340
|
await urlInfoTransformer.initTransformations(urlInfo, context)
|
|
254
341
|
}
|
|
255
342
|
|
|
256
|
-
const _cook = async ({
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
343
|
+
const _cook = async (urlInfo, dishContext) => {
|
|
344
|
+
// during dev/test clientRuntimeCompat is a single runtime
|
|
345
|
+
// during build clientRuntimeCompat is runtimeCompat
|
|
346
|
+
const { clientRuntimeCompat = runtimeCompat } = dishContext
|
|
347
|
+
kitchenContext.isSupportedOnCurrentClients = (feature) => {
|
|
348
|
+
return RUNTIME_COMPAT.isSupported(clientRuntimeCompat, feature)
|
|
349
|
+
}
|
|
263
350
|
const context = {
|
|
264
|
-
...
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
runtimeSupport,
|
|
268
|
-
isSupportedOnRuntime: (feature) => {
|
|
269
|
-
return RUNTIME_SUPPORT.isSupported(runtimeSupport, feature)
|
|
270
|
-
},
|
|
271
|
-
cook: (params) => {
|
|
272
|
-
return cookDuringCook({
|
|
273
|
-
outDirectoryUrl,
|
|
274
|
-
runtimeSupport,
|
|
275
|
-
...params,
|
|
276
|
-
})
|
|
277
|
-
},
|
|
278
|
-
load: (params) => {
|
|
279
|
-
return load({
|
|
280
|
-
context,
|
|
281
|
-
...params,
|
|
282
|
-
})
|
|
283
|
-
},
|
|
351
|
+
...kitchenContext,
|
|
352
|
+
...dishContext,
|
|
353
|
+
clientRuntimeCompat,
|
|
284
354
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const references = []
|
|
291
|
-
const addReference = (props) => {
|
|
292
|
-
const reference = createReference({
|
|
293
|
-
parentUrl: urlInfo.url,
|
|
294
|
-
...props,
|
|
355
|
+
const { cookDuringCook = cook } = dishContext
|
|
356
|
+
context.cook = (urlInfo, nestedDishContext) => {
|
|
357
|
+
return cookDuringCook(urlInfo, {
|
|
358
|
+
...dishContext,
|
|
359
|
+
...nestedDishContext,
|
|
295
360
|
})
|
|
296
|
-
references.push(reference)
|
|
297
|
-
return [reference, resolveReference(reference)]
|
|
298
361
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
362
|
+
context.fetchUrlContent = (urlInfo, { reference }) => {
|
|
363
|
+
return fetchUrlContent(urlInfo, { reference, context })
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (urlInfo.shouldHandle) {
|
|
367
|
+
// "fetchUrlContent" hook
|
|
368
|
+
await fetchUrlContent(urlInfo, { reference: context.reference, context })
|
|
369
|
+
|
|
370
|
+
// parsing
|
|
371
|
+
const references = []
|
|
372
|
+
const addReference = (props) => {
|
|
373
|
+
const reference = createReference({
|
|
374
|
+
parentUrl: urlInfo.url,
|
|
375
|
+
...props,
|
|
376
|
+
})
|
|
377
|
+
references.push(reference)
|
|
378
|
+
const referencedUrlInfo = resolveReference(reference)
|
|
379
|
+
return [reference, referencedUrlInfo]
|
|
380
|
+
}
|
|
381
|
+
const referenceUtils = {
|
|
382
|
+
readGeneratedSpecifier: async (reference) => {
|
|
383
|
+
// "formatReferencedUrl" can be async BUT this is an exception
|
|
384
|
+
// for most cases it will be sync. We want to favor the sync signature to keep things simpler
|
|
385
|
+
// The only case where it needs to be async is when
|
|
386
|
+
// the specifier is a `data:*` url
|
|
387
|
+
// in this case we'll wait for the promise returned by
|
|
388
|
+
// "formatReferencedUrl"
|
|
389
|
+
if (reference.generatedSpecifier.then) {
|
|
390
|
+
return reference.generatedSpecifier.then((value) => {
|
|
391
|
+
reference.generatedSpecifier = value
|
|
392
|
+
return value
|
|
393
|
+
})
|
|
306
394
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
trace
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
:
|
|
315
|
-
|
|
316
|
-
|
|
395
|
+
return reference.generatedSpecifier
|
|
396
|
+
},
|
|
397
|
+
found: ({ trace, ...rest }) => {
|
|
398
|
+
if (trace === undefined) {
|
|
399
|
+
trace = stringifyUrlSite(
|
|
400
|
+
adjustUrlSite(urlInfo, {
|
|
401
|
+
urlGraph,
|
|
402
|
+
url: urlInfo.url,
|
|
403
|
+
line: rest.specifierLine,
|
|
404
|
+
column: rest.specifierColumn,
|
|
405
|
+
}),
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
// console.log(trace)
|
|
409
|
+
return addReference({
|
|
410
|
+
trace,
|
|
411
|
+
...rest,
|
|
317
412
|
})
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const parentContent = isOriginal
|
|
335
|
-
? urlInfo.originalContent
|
|
336
|
-
: urlInfo.content
|
|
337
|
-
const [inlineReference, inlineUrlInfo] = addReference({
|
|
338
|
-
trace: stringifyUrlSite({
|
|
339
|
-
url: parentUrl,
|
|
340
|
-
content: parentContent,
|
|
413
|
+
},
|
|
414
|
+
foundInline: ({ isOriginalPosition, line, column, ...rest }) => {
|
|
415
|
+
const parentUrl = isOriginalPosition
|
|
416
|
+
? urlInfo.url
|
|
417
|
+
: urlInfo.generatedUrl
|
|
418
|
+
const parentContent = isOriginalPosition
|
|
419
|
+
? urlInfo.originalContent
|
|
420
|
+
: urlInfo.content
|
|
421
|
+
return addReference({
|
|
422
|
+
trace: stringifyUrlSite({
|
|
423
|
+
url: parentUrl,
|
|
424
|
+
content: parentContent,
|
|
425
|
+
line,
|
|
426
|
+
column,
|
|
427
|
+
}),
|
|
428
|
+
isOriginalPosition,
|
|
341
429
|
line,
|
|
342
430
|
column,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const index = references.findIndex(
|
|
363
|
-
(ref) => ref.generatedSpecifier === generatedSpecifier,
|
|
364
|
-
)
|
|
365
|
-
if (index === -1) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
`Cannot find a reference for the following generatedSpecifier "${generatedSpecifier}"`,
|
|
431
|
+
isInline: true,
|
|
432
|
+
...rest,
|
|
433
|
+
})
|
|
434
|
+
},
|
|
435
|
+
update: (currentReference, newReferenceParams) => {
|
|
436
|
+
const index = references.indexOf(currentReference)
|
|
437
|
+
if (index === -1) {
|
|
438
|
+
throw new Error(`reference do not exists`)
|
|
439
|
+
}
|
|
440
|
+
const previousReference = currentReference
|
|
441
|
+
const nextReference = createReference({
|
|
442
|
+
...previousReference,
|
|
443
|
+
...newReferenceParams,
|
|
444
|
+
})
|
|
445
|
+
references[index] = nextReference
|
|
446
|
+
mutateReference(previousReference, nextReference)
|
|
447
|
+
const newUrlInfo = resolveReference(nextReference)
|
|
448
|
+
const currentUrlInfo = context.urlGraph.getUrlInfo(
|
|
449
|
+
currentReference.url,
|
|
368
450
|
)
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
451
|
+
if (
|
|
452
|
+
currentUrlInfo &&
|
|
453
|
+
currentUrlInfo !== newUrlInfo &&
|
|
454
|
+
currentUrlInfo.dependents.size === 0
|
|
455
|
+
) {
|
|
456
|
+
context.urlGraph.deleteUrlInfo(currentReference.url)
|
|
457
|
+
}
|
|
458
|
+
return [nextReference, newUrlInfo]
|
|
459
|
+
},
|
|
460
|
+
becomesInline: (
|
|
461
|
+
reference,
|
|
462
|
+
{
|
|
463
|
+
isOriginalPosition,
|
|
464
|
+
specifier,
|
|
465
|
+
specifierLine,
|
|
466
|
+
specifierColumn,
|
|
467
|
+
contentType,
|
|
468
|
+
content,
|
|
377
469
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
: urlInfo.content
|
|
392
|
-
reference.trace = stringifyUrlSite({
|
|
393
|
-
url: parentUrl,
|
|
394
|
-
content: parentContent,
|
|
395
|
-
line,
|
|
396
|
-
column,
|
|
397
|
-
})
|
|
398
|
-
reference.isInline = true
|
|
399
|
-
reference.specifier = specifier
|
|
400
|
-
reference.contentType = contentType
|
|
401
|
-
reference.content = content
|
|
402
|
-
const inlineUrlInfo = resolveReference(reference)
|
|
403
|
-
inlineUrlInfo.isInline = true
|
|
404
|
-
inlineUrlInfo.inlineUrlSite = {
|
|
405
|
-
url: urlInfo.url,
|
|
406
|
-
content: parentContent,
|
|
407
|
-
line,
|
|
408
|
-
column,
|
|
409
|
-
}
|
|
410
|
-
inlineUrlInfo.contentType = contentType
|
|
411
|
-
inlineUrlInfo.content = content
|
|
412
|
-
return reference
|
|
413
|
-
},
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
let parseResult
|
|
417
|
-
try {
|
|
418
|
-
parseResult = await parseUrlMentions({
|
|
419
|
-
type: urlInfo.type,
|
|
420
|
-
url: urlInfo.data.sourceUrl || urlInfo.url,
|
|
421
|
-
generatedUrl: urlInfo.generatedUrl,
|
|
422
|
-
content: urlInfo.content,
|
|
423
|
-
})
|
|
424
|
-
} catch (error) {
|
|
425
|
-
throw createParseError({
|
|
426
|
-
reference,
|
|
427
|
-
urlInfo,
|
|
428
|
-
error,
|
|
429
|
-
})
|
|
430
|
-
}
|
|
431
|
-
if (parseResult) {
|
|
432
|
-
Object.assign(urlInfo.data, parseResult.data)
|
|
433
|
-
const { urlMentions, replaceUrls } = parseResult
|
|
434
|
-
for (const urlMention of urlMentions) {
|
|
435
|
-
const [reference] = addReference({
|
|
436
|
-
trace: stringifyUrlSite(
|
|
437
|
-
adjustUrlSite(urlInfo, {
|
|
438
|
-
urlGraph,
|
|
439
|
-
url: urlInfo.url,
|
|
440
|
-
line: urlMention.line,
|
|
441
|
-
column: urlMention.column,
|
|
470
|
+
) => {
|
|
471
|
+
const parentUrl = isOriginalPosition
|
|
472
|
+
? urlInfo.url
|
|
473
|
+
: urlInfo.generatedUrl
|
|
474
|
+
const parentContent = isOriginalPosition
|
|
475
|
+
? urlInfo.originalContent
|
|
476
|
+
: urlInfo.content
|
|
477
|
+
return referenceUtils.update(reference, {
|
|
478
|
+
trace: stringifyUrlSite({
|
|
479
|
+
url: parentUrl,
|
|
480
|
+
content: parentContent,
|
|
481
|
+
line: specifierLine,
|
|
482
|
+
column: specifierColumn,
|
|
442
483
|
}),
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
484
|
+
isOriginalPosition,
|
|
485
|
+
isInline: true,
|
|
486
|
+
specifier,
|
|
487
|
+
specifierLine,
|
|
488
|
+
specifierColumn,
|
|
489
|
+
contentType,
|
|
490
|
+
content,
|
|
491
|
+
})
|
|
492
|
+
},
|
|
493
|
+
inject: ({ trace, ...rest }) => {
|
|
494
|
+
if (trace === undefined) {
|
|
495
|
+
const { url, line, column } = getCallerPosition()
|
|
496
|
+
trace = stringifyUrlSite({
|
|
497
|
+
url,
|
|
498
|
+
line,
|
|
499
|
+
column,
|
|
500
|
+
})
|
|
501
|
+
}
|
|
502
|
+
return addReference({
|
|
503
|
+
trace,
|
|
504
|
+
injected: true,
|
|
505
|
+
...rest,
|
|
506
|
+
})
|
|
507
|
+
},
|
|
508
|
+
findByGeneratedSpecifier: (generatedSpecifier) => {
|
|
509
|
+
const reference = references.find(
|
|
510
|
+
(ref) => ref.generatedSpecifier === generatedSpecifier,
|
|
511
|
+
)
|
|
512
|
+
if (!reference) {
|
|
513
|
+
throw new Error(
|
|
514
|
+
`No reference found using the following generatedSpecifier: "${generatedSpecifier}"`,
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
return reference
|
|
518
|
+
},
|
|
449
519
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
520
|
+
|
|
521
|
+
// "transform" hook
|
|
522
|
+
urlInfo.references = references
|
|
523
|
+
context.referenceUtils = referenceUtils
|
|
524
|
+
try {
|
|
525
|
+
await pluginController.callAsyncHooks(
|
|
526
|
+
"transformUrlContent",
|
|
527
|
+
urlInfo,
|
|
528
|
+
context,
|
|
529
|
+
async (transformReturnValue) => {
|
|
530
|
+
await urlInfoTransformer.applyIntermediateTransformations(
|
|
531
|
+
urlInfo,
|
|
532
|
+
transformReturnValue,
|
|
533
|
+
)
|
|
534
|
+
},
|
|
464
535
|
)
|
|
465
|
-
|
|
466
|
-
|
|
536
|
+
} catch (error) {
|
|
537
|
+
throw createTransformUrlContentError({
|
|
538
|
+
pluginController,
|
|
539
|
+
reference: context.reference,
|
|
540
|
+
urlInfo,
|
|
541
|
+
error,
|
|
467
542
|
})
|
|
468
|
-
|
|
543
|
+
}
|
|
544
|
+
// after "transform" all references from originalContent
|
|
545
|
+
// and the one injected by plugin are known
|
|
546
|
+
urlGraph.updateReferences(urlInfo, references)
|
|
547
|
+
|
|
548
|
+
// "finalize" hook
|
|
549
|
+
try {
|
|
550
|
+
const finalizeReturnValue = await pluginController.callAsyncHooksUntil(
|
|
551
|
+
"finalizeUrlContent",
|
|
552
|
+
urlInfo,
|
|
553
|
+
context,
|
|
554
|
+
)
|
|
555
|
+
await urlInfoTransformer.applyFinalTransformations(
|
|
469
556
|
urlInfo,
|
|
470
|
-
|
|
557
|
+
finalizeReturnValue,
|
|
471
558
|
)
|
|
559
|
+
} catch (error) {
|
|
560
|
+
throw createFinalizeUrlContentError({
|
|
561
|
+
pluginController,
|
|
562
|
+
reference: context.reference,
|
|
563
|
+
urlInfo,
|
|
564
|
+
error,
|
|
565
|
+
})
|
|
472
566
|
}
|
|
473
567
|
}
|
|
474
568
|
|
|
475
|
-
// "transform" hook
|
|
476
|
-
urlInfo.references = references
|
|
477
|
-
context.referenceUtils = referenceUtils
|
|
478
|
-
try {
|
|
479
|
-
await pluginController.callAsyncHooks(
|
|
480
|
-
"transform",
|
|
481
|
-
urlInfo,
|
|
482
|
-
context,
|
|
483
|
-
async (transformReturnValue) => {
|
|
484
|
-
await urlInfoTransformer.applyIntermediateTransformations(
|
|
485
|
-
urlInfo,
|
|
486
|
-
transformReturnValue,
|
|
487
|
-
)
|
|
488
|
-
},
|
|
489
|
-
)
|
|
490
|
-
} catch (error) {
|
|
491
|
-
throw createTransformError({
|
|
492
|
-
pluginController,
|
|
493
|
-
reference,
|
|
494
|
-
urlInfo,
|
|
495
|
-
error,
|
|
496
|
-
})
|
|
497
|
-
}
|
|
498
|
-
// after "transform" all references from originalContent
|
|
499
|
-
// and the one injected by plugin are known
|
|
500
|
-
urlGraph.updateReferences(urlInfo, references)
|
|
501
|
-
|
|
502
|
-
// "finalize" hook
|
|
503
|
-
const finalizeReturnValue = await pluginController.callHooksUntil(
|
|
504
|
-
"finalize",
|
|
505
|
-
urlInfo,
|
|
506
|
-
context,
|
|
507
|
-
)
|
|
508
|
-
await urlInfoTransformer.applyFinalTransformations(
|
|
509
|
-
urlInfo,
|
|
510
|
-
finalizeReturnValue,
|
|
511
|
-
)
|
|
512
|
-
|
|
513
569
|
// "cooked" hook
|
|
514
570
|
pluginController.callHooks(
|
|
515
571
|
"cooked",
|
|
@@ -532,53 +588,165 @@ export const createKitchen = ({
|
|
|
532
588
|
},
|
|
533
589
|
)
|
|
534
590
|
}
|
|
535
|
-
const cook = async (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
591
|
+
const cook = memoizeCook(async (urlInfo, context) => {
|
|
592
|
+
if (!writeGeneratedFiles || !context.outDirectoryUrl) {
|
|
593
|
+
await _cook(urlInfo, context)
|
|
594
|
+
return
|
|
595
|
+
}
|
|
596
|
+
// writing result inside ".jsenv" directory (debug purposes)
|
|
597
|
+
try {
|
|
598
|
+
await _cook(urlInfo, context)
|
|
599
|
+
} finally {
|
|
542
600
|
const { generatedUrl } = urlInfo
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
601
|
+
if (generatedUrl && generatedUrl.startsWith("file:")) {
|
|
602
|
+
if (urlInfo.type === "directory") {
|
|
603
|
+
// no need to write the directory
|
|
604
|
+
} else {
|
|
605
|
+
writeFileSync(new URL(generatedUrl), urlInfo.content)
|
|
606
|
+
const { sourcemapGeneratedUrl, sourcemap } = urlInfo
|
|
607
|
+
if (sourcemapGeneratedUrl && sourcemap) {
|
|
608
|
+
writeFileSync(
|
|
609
|
+
new URL(sourcemapGeneratedUrl),
|
|
610
|
+
JSON.stringify(sourcemap, null, " "),
|
|
611
|
+
)
|
|
612
|
+
}
|
|
613
|
+
}
|
|
556
614
|
}
|
|
557
615
|
}
|
|
616
|
+
})
|
|
617
|
+
kitchenContext.fetchUrlContent = fetchUrlContent
|
|
618
|
+
kitchenContext.cook = cook
|
|
558
619
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
...rest,
|
|
564
|
-
})
|
|
565
|
-
writeFiles({ gotError: false })
|
|
566
|
-
} catch (e) {
|
|
567
|
-
writeFiles({ gotError: true })
|
|
568
|
-
throw e
|
|
569
|
-
}
|
|
620
|
+
const prepareEntryPoint = (params) => {
|
|
621
|
+
const entryReference = createReference(params)
|
|
622
|
+
const entryUrlInfo = resolveReference(entryReference)
|
|
623
|
+
return [entryReference, entryUrlInfo]
|
|
570
624
|
}
|
|
571
625
|
|
|
572
|
-
|
|
626
|
+
const injectReference = (params) => {
|
|
627
|
+
const ref = createReference(params)
|
|
628
|
+
const urlInfo = resolveReference(ref)
|
|
629
|
+
return [ref, urlInfo]
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const fetchOriginalUrlInfo = async ({
|
|
633
|
+
urlInfo,
|
|
634
|
+
context,
|
|
635
|
+
searchParam,
|
|
636
|
+
expectedType,
|
|
637
|
+
}) => {
|
|
638
|
+
const urlObject = new URL(urlInfo.url)
|
|
639
|
+
const { searchParams } = urlObject
|
|
640
|
+
if (!searchParams.has(searchParam)) {
|
|
641
|
+
return null
|
|
642
|
+
}
|
|
643
|
+
searchParams.delete(searchParam)
|
|
644
|
+
const originalUrl = urlObject.href
|
|
645
|
+
const originalReference = {
|
|
646
|
+
...(context.reference.original || context.reference),
|
|
647
|
+
expectedType,
|
|
648
|
+
}
|
|
649
|
+
originalReference.url = originalUrl
|
|
650
|
+
const originalUrlInfo = context.urlGraph.reuseOrCreateUrlInfo(
|
|
651
|
+
originalReference.url,
|
|
652
|
+
)
|
|
653
|
+
if (originalUrlInfo.originalUrl === undefined) {
|
|
654
|
+
applyReferenceEffectsOnUrlInfo(
|
|
655
|
+
originalReference,
|
|
656
|
+
originalUrlInfo,
|
|
657
|
+
context,
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
await context.fetchUrlContent(originalUrlInfo, {
|
|
661
|
+
reference: originalReference,
|
|
662
|
+
})
|
|
663
|
+
if (originalUrlInfo.dependents.size === 0) {
|
|
664
|
+
context.urlGraph.deleteUrlInfo(originalUrlInfo.url)
|
|
665
|
+
}
|
|
666
|
+
return originalUrlInfo
|
|
667
|
+
}
|
|
668
|
+
kitchenContext.fetchOriginalUrlInfo = fetchOriginalUrlInfo
|
|
573
669
|
|
|
574
670
|
return {
|
|
575
671
|
pluginController,
|
|
576
672
|
urlInfoTransformer,
|
|
577
673
|
rootDirectoryUrl,
|
|
578
674
|
jsenvDirectoryUrl,
|
|
579
|
-
|
|
580
|
-
resolveReference,
|
|
675
|
+
kitchenContext,
|
|
581
676
|
cook,
|
|
677
|
+
prepareEntryPoint,
|
|
678
|
+
injectReference,
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
const memoizeCook = (cook) => {
|
|
683
|
+
const pendingDishes = new Map()
|
|
684
|
+
return async (urlInfo, context) => {
|
|
685
|
+
const { url, modifiedTimestamp } = urlInfo
|
|
686
|
+
const pendingDish = pendingDishes.get(url)
|
|
687
|
+
if (pendingDish) {
|
|
688
|
+
if (!modifiedTimestamp) {
|
|
689
|
+
await pendingDish.promise
|
|
690
|
+
return
|
|
691
|
+
}
|
|
692
|
+
if (pendingDish.timestamp > modifiedTimestamp) {
|
|
693
|
+
await pendingDish.promise
|
|
694
|
+
return
|
|
695
|
+
}
|
|
696
|
+
pendingDishes.delete(url)
|
|
697
|
+
}
|
|
698
|
+
const timestamp = Date.now()
|
|
699
|
+
const promise = cook(urlInfo, context)
|
|
700
|
+
pendingDishes.set(url, {
|
|
701
|
+
timestamp,
|
|
702
|
+
promise,
|
|
703
|
+
})
|
|
704
|
+
try {
|
|
705
|
+
await promise
|
|
706
|
+
} finally {
|
|
707
|
+
pendingDishes.delete(url)
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
|
|
713
|
+
if (reference.shouldHandle) {
|
|
714
|
+
urlInfo.shouldHandle = true
|
|
715
|
+
} else {
|
|
716
|
+
urlInfo.shouldHandle = false
|
|
717
|
+
}
|
|
718
|
+
urlInfo.originalUrl = urlInfo.originalUrl || reference.url
|
|
719
|
+
|
|
720
|
+
Object.assign(urlInfo.data, reference.data)
|
|
721
|
+
Object.assign(urlInfo.timing, reference.timing)
|
|
722
|
+
if (reference.injected) {
|
|
723
|
+
urlInfo.data.injected = true
|
|
724
|
+
}
|
|
725
|
+
if (reference.filename) {
|
|
726
|
+
urlInfo.filename = reference.filename
|
|
727
|
+
}
|
|
728
|
+
if (reference.isInline) {
|
|
729
|
+
urlInfo.isInline = true
|
|
730
|
+
const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
|
|
731
|
+
urlInfo.inlineUrlSite = {
|
|
732
|
+
url: parentUrlInfo.url,
|
|
733
|
+
content: reference.isOriginalPosition
|
|
734
|
+
? parentUrlInfo.originalContent
|
|
735
|
+
: parentUrlInfo.content,
|
|
736
|
+
line: reference.specifierLine,
|
|
737
|
+
column: reference.specifierColumn,
|
|
738
|
+
}
|
|
739
|
+
urlInfo.contentType = reference.contentType
|
|
740
|
+
urlInfo.originalContent =
|
|
741
|
+
context === "build"
|
|
742
|
+
? urlInfo.originalContent === undefined
|
|
743
|
+
? reference.content
|
|
744
|
+
: urlInfo.originalContent
|
|
745
|
+
: reference.content
|
|
746
|
+
urlInfo.content = reference.content
|
|
747
|
+
}
|
|
748
|
+
if (isWebWorkerEntryPointReference(reference)) {
|
|
749
|
+
urlInfo.data.isWebWorkerEntryPoint = true
|
|
582
750
|
}
|
|
583
751
|
}
|
|
584
752
|
|
|
@@ -616,104 +784,77 @@ const adjustUrlSite = (urlInfo, { urlGraph, url, line, column }) => {
|
|
|
616
784
|
)
|
|
617
785
|
}
|
|
618
786
|
|
|
619
|
-
const inferUrlInfoType = ({ contentType }) => {
|
|
787
|
+
const inferUrlInfoType = ({ url, contentType }) => {
|
|
620
788
|
if (contentType === "text/html") {
|
|
621
789
|
return "html"
|
|
622
790
|
}
|
|
623
791
|
if (contentType === "text/css") {
|
|
624
792
|
return "css"
|
|
625
793
|
}
|
|
626
|
-
if (contentType === "
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
794
|
+
if (contentType === "text/javascript") {
|
|
795
|
+
const urlObject = new URL(url)
|
|
796
|
+
if (urlObject.searchParams.has("js_classic")) {
|
|
797
|
+
return "js_classic"
|
|
798
|
+
}
|
|
799
|
+
return "js_module"
|
|
631
800
|
}
|
|
632
801
|
if (contentType === "application/importmap+json") {
|
|
633
802
|
return "importmap"
|
|
634
803
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const determineFileUrlForOutDirectory = ({
|
|
639
|
-
rootDirectoryUrl,
|
|
640
|
-
outDirectoryUrl,
|
|
641
|
-
url,
|
|
642
|
-
}) => {
|
|
643
|
-
if (!outDirectoryUrl) {
|
|
644
|
-
return url
|
|
804
|
+
if (contentType === "application/manifest+json") {
|
|
805
|
+
return "webmanifest"
|
|
645
806
|
}
|
|
646
|
-
if (
|
|
647
|
-
return
|
|
807
|
+
if (contentType === "image/svg+xml") {
|
|
808
|
+
return "svg"
|
|
648
809
|
}
|
|
649
|
-
if (
|
|
650
|
-
|
|
810
|
+
if (CONTENT_TYPE.isJson(contentType)) {
|
|
811
|
+
return "json"
|
|
651
812
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
preferAbsolute: true,
|
|
657
|
-
})
|
|
813
|
+
if (CONTENT_TYPE.isTextual(contentType)) {
|
|
814
|
+
return "text"
|
|
815
|
+
}
|
|
816
|
+
return "other"
|
|
658
817
|
}
|
|
659
818
|
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
const
|
|
663
|
-
if (
|
|
664
|
-
return
|
|
665
|
-
reference.generatedSpecifier = value
|
|
666
|
-
return specifierFormat.encode(reference)
|
|
667
|
-
})
|
|
819
|
+
const inferUrlInfoSubtype = ({ type, subtype, url }) => {
|
|
820
|
+
if (type === "js_classic" || type === "js_module") {
|
|
821
|
+
const urlObject = new URL(url)
|
|
822
|
+
if (urlObject.searchParams.has("worker")) {
|
|
823
|
+
return "worker"
|
|
668
824
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (typeof generatedSpecifier === "function") {
|
|
672
|
-
return generatedSpecifier()
|
|
825
|
+
if (urlObject.searchParams.has("service_worker")) {
|
|
826
|
+
return "service_worker"
|
|
673
827
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
? formatter.encode(generatedSpecifier)
|
|
677
|
-
: generatedSpecifier
|
|
678
|
-
if (reference.escape) {
|
|
679
|
-
return reference.escape(value)
|
|
828
|
+
if (urlObject.searchParams.has("shared_worker")) {
|
|
829
|
+
return "shared_worker"
|
|
680
830
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
return formatter
|
|
686
|
-
? formatter.decode(reference.generatedSpecifier)
|
|
687
|
-
: reference.generatedSpecifier
|
|
688
|
-
},
|
|
831
|
+
// if we are currently inside a worker, all deps are consider inside worker too
|
|
832
|
+
return subtype
|
|
833
|
+
}
|
|
834
|
+
return ""
|
|
689
835
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
return url.slice(1, -1)
|
|
713
|
-
}
|
|
714
|
-
return url
|
|
715
|
-
},
|
|
716
|
-
},
|
|
836
|
+
|
|
837
|
+
const determineFileUrlForOutDirectory = ({ urlInfo, context }) => {
|
|
838
|
+
if (!context.outDirectoryUrl) {
|
|
839
|
+
return urlInfo.url
|
|
840
|
+
}
|
|
841
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
842
|
+
return urlInfo.url
|
|
843
|
+
}
|
|
844
|
+
let url = urlInfo.url
|
|
845
|
+
if (!urlIsInsideOf(urlInfo.url, context.rootDirectoryUrl)) {
|
|
846
|
+
const fsRootUrl = ensureWindowsDriveLetter("file:///", urlInfo.url)
|
|
847
|
+
url = `${context.rootDirectoryUrl}@fs/${url.slice(fsRootUrl.length)}`
|
|
848
|
+
}
|
|
849
|
+
if (urlInfo.filename) {
|
|
850
|
+
url = setUrlFilename(url, urlInfo.filename)
|
|
851
|
+
}
|
|
852
|
+
return moveUrl({
|
|
853
|
+
url,
|
|
854
|
+
from: context.rootDirectoryUrl,
|
|
855
|
+
to: context.outDirectoryUrl,
|
|
856
|
+
preferAbsolute: true,
|
|
857
|
+
})
|
|
717
858
|
}
|
|
718
859
|
|
|
719
860
|
// import { getOriginalPosition } from "@jsenv/core/src/utils/sourcemap/original_position.js"
|