@jsenv/core 26.0.1 → 27.0.0-alpha.2
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/main.js +17 -24
- package/package.json +35 -71
- package/readme.md +30 -37
- package/src/build/build.js +737 -0
- package/src/build/build_urls_generator.js +64 -0
- package/src/build/inject_version_mappings.js +62 -0
- package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +225 -0
- package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +30 -0
- package/src/build/plugins/minify_js/jsenv_plugin_minify_js.js +47 -0
- package/src/dev/plugins/autoreload/babel_plugin_metadata_import_meta_hot.js +98 -0
- package/src/dev/plugins/autoreload/client/autoreload_preference.js +11 -0
- package/src/dev/plugins/autoreload/client/event_source_client.js +186 -0
- package/src/{internal/dev_server/event_source_client → dev/plugins/autoreload/client}/event_source_connection.js +21 -25
- package/src/dev/plugins/autoreload/client/import_meta_hot.js +80 -0
- package/src/dev/plugins/autoreload/client/reload.js +101 -0
- package/src/dev/plugins/autoreload/client/url_helpers.js +20 -0
- package/src/dev/plugins/autoreload/html_hot_dependencies.js +156 -0
- package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +374 -0
- package/src/dev/plugins/autoreload/sse_service.js +149 -0
- package/src/dev/plugins/explorer/client/explorer.html +607 -0
- package/src/{internal → dev/plugins/explorer/client}/jsenv.png +0 -0
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +74 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/animation/toolbar_animation.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/eventsource/eventsource.css +2 -2
- package/src/dev/plugins/toolbar/client/eventsource/toolbar_eventsource.js +57 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/execution/execution.css +0 -0
- package/src/dev/plugins/toolbar/client/execution/toolbar_execution.js +88 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/focus.css +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/toolbar_focus.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/jsenv_logo.svg +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/notification/toolbar_notification.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/overflow_menu.css +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/toolbar_responsive.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/settings.css +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/toolbar_settings.js +1 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/jsenv_theme.css +1 -15
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/light_theme.css +0 -17
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/toolbar_theme.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar.html +40 -199
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_injector.js +8 -28
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.css +0 -24
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.js +10 -56
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.css +1 -1
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/animation.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/dom.js +0 -0
- package/src/{internal/browser_utils → dev/plugins/toolbar/client/util}/fetch_using_xhr.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/fetching.js +2 -4
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/iframe_to_parent_href.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/jsenv_logger.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/preferences.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/responsive.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/util.js +0 -0
- package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/variant/variant.js +0 -0
- package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +62 -0
- package/src/dev/start_dev_server.js +105 -0
- package/src/execute/execute.js +132 -0
- package/src/execute/run.js +208 -0
- package/src/execute/runtimes/browsers/chromium.js +8 -0
- package/src/execute/runtimes/browsers/firefox.js +7 -0
- package/src/execute/runtimes/browsers/from_playwright.js +464 -0
- package/src/{browser_runtimes.js → execute/runtimes/browsers/webkit.js} +4 -18
- package/src/{internal/node_launcher/child_process_options.js → execute/runtimes/node/child_exec_options.js} +25 -36
- package/src/{internal/node_launcher/node_controllable_file.mjs → execute/runtimes/node/controllable_file.mjs} +1 -18
- package/src/{internal/node_launcher/node_controllable_process.js → execute/runtimes/node/controlled_process.js} +128 -150
- package/src/execute/runtimes/node/exec_options.js +44 -0
- package/src/{internal/node_launcher → execute/runtimes/node}/kill_process_tree.js +3 -1
- package/src/execute/runtimes/node/node_process.js +92 -0
- package/src/execute/runtimes/node/node_worker_thread.js +28 -0
- package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +29 -0
- package/src/{internal/compile_server/js → omega/core_plugins/babel/babel_helper}/babel_plugin_babel_helpers_as_jsenv_imports.js +15 -19
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/.eslintrc.cjs +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AsyncGenerator/AsyncGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AwaitValue/AwaitValue.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayLikeToArray/arrayLikeToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithHoles/arrayWithHoles.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithoutHoles/arrayWithoutHoles.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/assertThisInitialized/assertThisInitialized.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncIterator/asyncIterator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncToGenerator/asyncToGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCallCheck/classCallCheck.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classNameTDZError/classNameTDZError.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldGet/classPrivateFieldGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldSet/classPrivateFieldSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodGet/classPrivateMethodGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodSet/classPrivateMethodSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/construct/construct.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createClass/createClass.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createRawReactElement/createRawReactElement.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createSuper/createSuper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/decorate/decorate.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defaults/defaults.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineEnumerableProperties/defineEnumerableProperties.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineProperty/defineProperty.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/extends/extends.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/get/get.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/getPrototypeOf/getPrototypeOf.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inherits/inherits.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inheritsLoose/inheritsLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerDefineProperty/initializerDefineProperty.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerWarningHelper/initializerWarningHelper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/instanceof/instanceof.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireDefault/interopRequireDefault.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireWildcard/interopRequireWildcard.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeFunction/isNativeFunction.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArray/iterableToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimit/iterableToArrayLimit.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/jsx/jsx.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/maybeArrayLike/maybeArrayLike.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/newArrowCheck/newArrowCheck.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableRest/nonIterableRest.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableSpread/nonIterableSpread.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread/objectSpread.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread2/objectSpread2.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutProperties/objectWithoutProperties.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/possibleConstructorReturn/possibleConstructorReturn.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readOnlyError/readOnlyError.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readme.md +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/set/set.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/setPrototypeOf/setPrototypeOf.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArray/slicedToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArrayLoose/slicedToArrayLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/superPropBase/superPropBase.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/tdz/tdz.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalRef/temporalRef.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalUndefined/temporalUndefined.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toArray/toArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toConsumableArray/toConsumableArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPrimitive/toPrimitive.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPropertyKey/toPropertyKey.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/typeof/typeof.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapNativeSuper/wrapNativeSuper.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapRegExp/wrapRegExp.js +0 -0
- package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/writeOnlyError/writeOnlyError.js +0 -0
- package/src/omega/core_plugins/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +35 -0
- package/{helpers/global-this/global-this.js → src/omega/core_plugins/babel/global_this/client/global_this.js} +0 -0
- package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +187 -0
- package/src/{internal/features → omega/core_plugins/babel/helpers}/babel_plugins_compatibility.js +1 -24
- package/src/omega/core_plugins/babel/jsenv_plugin_babel.js +97 -0
- package/src/omega/core_plugins/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +117 -0
- package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +24 -0
- package/{helpers/new_stylesheet → src/omega/core_plugins/babel/new_stylesheet/client}/new_stylesheet.js +0 -0
- package/src/omega/core_plugins/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +34 -0
- package/{helpers/regenerator-runtime/regenerator-runtime.js → src/omega/core_plugins/babel/regenerator_runtime/client/regenerator_runtime.js} +0 -0
- package/src/omega/core_plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +169 -0
- package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +67 -0
- package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +58 -0
- package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_document.js +10 -16
- package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_notification.js +0 -0
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +168 -0
- package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +77 -0
- package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/perf_browser.js +0 -0
- package/src/{internal/runtime_client → omega/core_plugins/html_supervisor/client}/uneval_exception.js +0 -0
- package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +233 -0
- package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +98 -0
- package/src/{internal/building/import_assertions → omega/core_plugins/import_assertions/helpers}/json_module.js +3 -2
- package/src/omega/core_plugins/import_assertions/helpers/text_module.js +6 -0
- package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +211 -0
- package/src/omega/core_plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +80 -0
- package/src/omega/core_plugins/importmap/jsenv_plugin_importmap.js +212 -0
- package/src/omega/core_plugins/inline/client/inline_content.js +6 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_data_urls.js +70 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +13 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_inline_query_param.js +42 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +142 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +210 -0
- package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +12 -0
- package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +77 -0
- package/src/omega/core_plugins/url_resolution/jsenv_plugin_url_resolution.js +28 -0
- package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +50 -0
- package/src/omega/core_plugins.js +39 -0
- package/src/omega/errors.js +168 -0
- package/src/omega/file_url_converter.js +63 -0
- package/src/omega/kitchen.js +777 -0
- package/src/omega/omega_server.js +129 -0
- package/src/omega/plugin_controller.js +240 -0
- package/src/omega/runtime_support/default_runtime_support.js +13 -0
- package/src/omega/runtime_support/features_compatibility.js +91 -0
- package/src/omega/runtime_support/runtime_support.js +20 -0
- package/src/omega/server/file_service.js +155 -0
- package/src/omega/server/user_agent.js +22 -0
- package/src/omega/url_graph/url_graph_load.js +68 -0
- package/src/omega/url_graph/url_graph_report.js +151 -0
- package/src/omega/url_graph/url_graph_sort.js +29 -0
- package/src/omega/url_graph/url_info_transformations.js +161 -0
- package/src/omega/url_graph.js +132 -0
- package/src/omega/url_mentions/css_url_mentions.js +63 -0
- package/src/omega/url_mentions/html_url_mentions.js +185 -0
- package/src/omega/url_mentions/js_module_url_mentions.js +91 -0
- package/src/omega/url_mentions/parse_url_mentions.js +37 -0
- package/src/omega/url_mentions/worker_classic_url_mentions.js +37 -0
- package/src/{internal/executing → test}/execute_plan.js +154 -211
- package/src/{execute_test_plan.js → test/execute_test_plan.js} +26 -81
- package/src/{internal/executing → test}/execution_colors.js +0 -0
- package/src/{internal/executing → test}/execution_steps.js +2 -8
- package/src/{internal/executing → test}/gc.js +0 -0
- package/src/test/logs_file_execution.js +223 -0
- package/dist/browser_client/asset-manifest.json +0 -4
- package/dist/browser_client/browser_client_fb33eaa4.js +0 -5320
- package/dist/browser_client/browser_client_fb33eaa4.js.map +0 -1089
- package/dist/build_manifest.js +0 -12
- package/dist/compile_proxy/asset-manifest.json +0 -4
- package/dist/compile_proxy/compile_proxy.html__inline__20_651d1e7b.js.map +0 -343
- package/dist/compile_proxy/compile_proxy_62f952c4.html +0 -2245
- package/dist/event_source_client/asset-manifest.json +0 -4
- package/dist/event_source_client/event_source_client_69f48287.js +0 -354
- package/dist/event_source_client/event_source_client_69f48287.js.map +0 -128
- package/dist/redirector/asset-manifest.json +0 -4
- package/dist/redirector/redirector.html__inline__12_171e07b4.js.map +0 -349
- package/dist/redirector/redirector_8117ec92.html +0 -2290
- package/dist/toolbar/asset-manifest.json +0 -13
- package/dist/toolbar/assets/compilation.css_7421bd55.map +0 -12
- package/dist/toolbar/assets/eventsource.css_c0c71e7b.map +0 -12
- package/dist/toolbar/assets/execution.css_f3377c10.map +0 -12
- package/dist/toolbar/assets/focus.css_896f3e45.map +0 -12
- package/dist/toolbar/assets/light_theme.css_5bff0336.map +0 -12
- package/dist/toolbar/assets/overflow_menu.css_9a0fc3d8.map +0 -12
- package/dist/toolbar/assets/settings.css_942b5a9e.map +0 -12
- package/dist/toolbar/assets/toolbar_main.css_b1c67dd7.map +0 -28
- package/dist/toolbar/assets/tooltip.css_a94a8bdd.map +0 -12
- package/dist/toolbar/toolbar_b0c9100c.html +0 -4976
- package/dist/toolbar/toolbar_main_f54c1bb0.js.map +0 -776
- package/dist/toolbar_injector/asset-manifest.json +0 -5
- package/dist/toolbar_injector/assets/jsenv_logo_192011c2.svg +0 -95
- package/dist/toolbar_injector/toolbar_injector_65b501eb.js +0 -976
- package/dist/toolbar_injector/toolbar_injector_65b501eb.js.map +0 -294
- package/helpers/import-meta/import-meta-url-commonjs.js +0 -9
- package/helpers/import-meta/import-meta-url-global.js +0 -54
- package/src/build_project.js +0 -336
- package/src/commonjs_to_js_module.js +0 -180
- package/src/dev_server.js +0 -302
- package/src/execute.js +0 -184
- package/src/import_using_child_process.js +0 -68
- package/src/internal/browser_client/browser_client.js +0 -220
- package/src/internal/browser_client/browser_client_factory.js +0 -144
- package/src/internal/browser_client/browser_error_stack_remap.js +0 -43
- package/src/internal/browser_client/browser_system.js +0 -216
- package/src/internal/browser_client/module_namespace_transfer.js +0 -90
- package/src/internal/browser_detection/browser_detection.js +0 -65
- package/src/internal/browser_detection/detect_android.js +0 -13
- package/src/internal/browser_detection/detect_chrome.js +0 -28
- package/src/internal/browser_detection/detect_edge.js +0 -13
- package/src/internal/browser_detection/detect_electron.js +0 -1
- package/src/internal/browser_detection/detect_firefox.js +0 -17
- package/src/internal/browser_detection/detect_internet_explorer.js +0 -14
- package/src/internal/browser_detection/detect_ios.js +0 -19
- package/src/internal/browser_detection/detect_opera.js +0 -27
- package/src/internal/browser_detection/detect_safari.js +0 -13
- package/src/internal/browser_detection/user_agent_data.js +0 -25
- package/src/internal/browser_detection/util.js +0 -13
- package/src/internal/browser_launcher/browser_runtime_profile.js +0 -81
- package/src/internal/browser_launcher/execute_html_file.js +0 -355
- package/src/internal/browser_launcher/from_playwright.js +0 -320
- package/src/internal/browser_launcher/page_errors_and_logs.js +0 -77
- package/src/internal/browser_utils/fetch_and_eval.js +0 -27
- package/src/internal/browser_utils/fetch_and_eval_using_script.js +0 -47
- package/src/internal/browser_utils/fetch_browser.js +0 -34
- package/src/internal/browser_utils/fetch_json.js +0 -7
- package/src/internal/building/build_logs.js +0 -134
- package/src/internal/building/build_stats.js +0 -100
- package/src/internal/building/build_url_generator.js +0 -153
- package/src/internal/building/build_using_rollup.js +0 -359
- package/src/internal/building/css/apply_post_css.js +0 -55
- package/src/internal/building/css/jsenv_parse_css.js +0 -260
- package/src/internal/building/css/move_css_urls.js +0 -44
- package/src/internal/building/css/parse_css_urls.js +0 -38
- package/src/internal/building/css/postcss_plugin_url_visitor.js +0 -245
- package/src/internal/building/css/replace_css_urls.js +0 -68
- package/src/internal/building/global_format/es_to_system.js +0 -34
- package/src/internal/building/html/html_node_mutations.js +0 -29
- package/src/internal/building/html/html_scan.js +0 -70
- package/src/internal/building/html/jsenv_parse_html.js +0 -813
- package/src/internal/building/html/minify_html.js +0 -7
- package/src/internal/building/import_assertions/css_module.js +0 -43
- package/src/internal/building/import_references.js +0 -80
- package/src/internal/building/importmap/jsenv_parse_importmap.js +0 -28
- package/src/internal/building/js/babel_plugin_inline_worker_imports.js +0 -96
- package/src/internal/building/js/jsenv_parse_js.js +0 -122
- package/src/internal/building/js/minify_js.js +0 -33
- package/src/internal/building/js/transform_worker.js +0 -55
- package/src/internal/building/json/jsenv_parse_json.js +0 -11
- package/src/internal/building/parse_ressource.js +0 -207
- package/src/internal/building/ressource_builder.js +0 -1098
- package/src/internal/building/ressource_builder_util.js +0 -194
- package/src/internal/building/rollup_plugin_jsenv.js +0 -1965
- package/src/internal/building/sort_pathnames.js +0 -10
- package/src/internal/building/sourcemap/sourcemap_loader.js +0 -70
- package/src/internal/building/svg/jsenv_parse_svg.js +0 -112
- package/src/internal/building/url_fetcher.js +0 -85
- package/src/internal/building/url_loader.js +0 -127
- package/src/internal/building/url_trace.js +0 -229
- package/src/internal/building/url_versioning/resolve_import_url_helper.js +0 -12
- package/src/internal/building/url_versioning/url_versioning.js +0 -65
- package/src/internal/building/webmanifest/jsenv_parse_webmanifest.js +0 -48
- package/src/internal/compile_server/commonjs/rollup_plugin_commonjs_named_exports.js +0 -187
- package/src/internal/compile_server/compile_file.js +0 -273
- package/src/internal/compile_server/compile_server.js +0 -519
- package/src/internal/compile_server/compiled_file_service.js +0 -264
- package/src/internal/compile_server/html/html_ast.js +0 -534
- package/src/internal/compile_server/html/html_source_file_service.js +0 -453
- package/src/internal/compile_server/html/jsenv_compile_html.js +0 -674
- package/src/internal/compile_server/importmap/jsenv_compile_importmap.js +0 -28
- package/src/internal/compile_server/js/ansi_to_html.js +0 -9
- package/src/internal/compile_server/js/babelHelper.js +0 -145
- package/src/internal/compile_server/js/babel_parse_error.js +0 -9
- package/src/internal/compile_server/js/babel_plugin_global_this_as_jsenv_import.js +0 -34
- package/src/internal/compile_server/js/babel_plugin_import_assertions.js +0 -121
- package/src/internal/compile_server/js/babel_plugin_import_metadata.js +0 -18
- package/src/internal/compile_server/js/babel_plugin_import_visitor.js +0 -84
- package/src/internal/compile_server/js/babel_plugin_new_stylesheet_as_jsenv_import.js +0 -113
- package/src/internal/compile_server/js/babel_plugin_proxy_external_imports.js +0 -31
- package/src/internal/compile_server/js/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -48
- package/src/internal/compile_server/js/babel_plugin_replace_expressions.js +0 -101
- package/src/internal/compile_server/js/babel_plugin_systemjs_prepend.js +0 -23
- package/src/internal/compile_server/js/babel_plugin_transform_import_meta.js +0 -134
- package/src/internal/compile_server/js/babel_plugins.js +0 -37
- package/src/internal/compile_server/js/generateBabelHelper.js +0 -36
- package/src/internal/compile_server/js/js_transformer.js +0 -195
- package/src/internal/compile_server/js/jsenv_compile_js.js +0 -62
- package/src/internal/compile_server/js/load_babel_plugin_map_from_file.js +0 -49
- package/src/internal/compile_server/jsenv_directory/comparison_utils.js +0 -27
- package/src/internal/compile_server/jsenv_directory/compilation_result.js +0 -243
- package/src/internal/compile_server/jsenv_directory/compilation_result_from_build.js +0 -184
- package/src/internal/compile_server/jsenv_directory/compile_asset.js +0 -24
- package/src/internal/compile_server/jsenv_directory/compile_context.js +0 -60
- package/src/internal/compile_server/jsenv_directory/compile_profile.js +0 -217
- package/src/internal/compile_server/jsenv_directory/file_lock_registry.js +0 -24
- package/src/internal/compile_server/jsenv_directory/file_lock_registry.test.js +0 -47
- package/src/internal/compile_server/jsenv_directory/fs_optimized_for_cache.js +0 -57
- package/src/internal/compile_server/jsenv_directory/jsenv_directory.js +0 -183
- package/src/internal/compile_server/jsenv_directory/reuse_or_create_compiled_file.js +0 -269
- package/src/internal/compile_server/jsenv_directory/update_compile_cache.js +0 -131
- package/src/internal/compile_server/jsenv_directory/validate_compile_cache.js +0 -264
- package/src/internal/compile_server/sse_service/sse_service.js +0 -369
- package/src/internal/coverage/babel_plugin_instrument.js +0 -90
- package/src/internal/coverage/coverage_reporter_html_directory.js +0 -37
- package/src/internal/coverage/coverage_reporter_json_file.js +0 -22
- package/src/internal/coverage/coverage_reporter_text_log.js +0 -20
- package/src/internal/coverage/empty_coverage_factory.js +0 -70
- package/src/internal/coverage/file_by_file_coverage.js +0 -28
- package/src/internal/coverage/istanbul_coverage_composition.js +0 -28
- package/src/internal/coverage/istanbul_coverage_map_from_coverage.js +0 -16
- package/src/internal/coverage/list_files_not_covered.js +0 -20
- package/src/internal/coverage/missing_coverage.js +0 -46
- package/src/internal/coverage/report_to_coverage.js +0 -198
- package/src/internal/coverage/v8_and_istanbul.js +0 -38
- package/src/internal/coverage/v8_coverage_composition.js +0 -23
- package/src/internal/coverage/v8_coverage_from_directory.js +0 -86
- package/src/internal/coverage/v8_coverage_to_istanbul.js +0 -100
- package/src/internal/data_url.js +0 -54
- package/src/internal/dev_server/event_source_client/event_source_client.js +0 -63
- package/src/internal/dev_server/event_source_client/file_changes.js +0 -82
- package/src/internal/dev_server/event_source_client/livereload_preference.js +0 -13
- package/src/internal/dev_server/exploring/exploring.css +0 -237
- package/src/internal/dev_server/exploring/exploring.html +0 -79
- package/src/internal/dev_server/exploring/exploring.js +0 -243
- package/src/internal/dev_server/exploring/fetch_exploring_json.js +0 -19
- package/src/internal/dev_server/toolbar/compilation/compilation.css +0 -23
- package/src/internal/dev_server/toolbar/compilation/toolbar_compilation.js +0 -202
- package/src/internal/dev_server/toolbar/eventsource/toolbar_eventsource.js +0 -83
- package/src/internal/dev_server/toolbar/execution/toolbar_execution.js +0 -91
- package/src/internal/error_stack_remap/install_error_stack_remapping.js +0 -142
- package/src/internal/error_stack_remap/remap_call_site.js +0 -315
- package/src/internal/error_stack_remap/remap_stack.js +0 -218
- package/src/internal/error_stack_remap/stringify_stack.js +0 -9
- package/src/internal/executing/launch_and_execute.js +0 -458
- package/src/internal/executing/logs_file_execution.js +0 -160
- package/src/internal/executing/logs_plan_summary.js +0 -144
- package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +0 -20
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +0 -23
- package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +0 -25
- package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +0 -37
- package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +0 -9
- package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +0 -14
- package/src/internal/features/browser_feature_detection/browser_feature_detection.js +0 -89
- package/src/internal/features/browser_feature_detection/compile_proxy.html +0 -27
- package/src/internal/features/browser_feature_detection/execute_with_script_module.js +0 -24
- package/src/internal/features/features_compat_from_runtime.js +0 -38
- package/src/internal/features/features_compat_from_runtime_support.js +0 -31
- package/src/internal/features/features_compatibility.js +0 -37
- package/src/internal/features/node_feature_detection/feature_detect_dynamic_import.mjs +0 -5
- package/src/internal/features/node_feature_detection/feature_detect_top_level_await.mjs +0 -1
- package/src/internal/features/node_feature_detection/node_feature_detect_dynamic_import.js +0 -5
- package/src/internal/features/node_feature_detection/node_feature_detect_top_level_await.js +0 -16
- package/src/internal/features/node_feature_detection/node_feature_detection.js +0 -66
- package/src/internal/fetching.js +0 -28
- package/src/internal/import_resolution/default_extension.js +0 -40
- package/src/internal/import_resolution/import_resolver_importmap.js +0 -64
- package/src/internal/import_resolution/import_resolver_node.js +0 -254
- package/src/internal/import_resolution/importmap_default.js +0 -37
- package/src/internal/jsenv_builds.js +0 -19
- package/src/internal/jsenv_params_assertions.js +0 -12
- package/src/internal/jsenv_remote_directory.js +0 -156
- package/src/internal/logs/byte.js +0 -10
- package/src/internal/logs/byte_as_file_size.js +0 -9
- package/src/internal/logs/ms_as_duration.js +0 -12
- package/src/internal/memoize.js +0 -24
- package/src/internal/node_launcher/eval_source.js +0 -6
- package/src/internal/node_launcher/fetch_source.js +0 -8
- package/src/internal/node_launcher/node_error_stack_remap.js +0 -22
- package/src/internal/node_launcher/node_execution_dynamic_import.js +0 -75
- package/src/internal/node_launcher/node_execution_performance.js +0 -67
- package/src/internal/node_launcher/node_execution_systemjs.js +0 -125
- package/src/internal/node_launcher/node_runtime_report.js +0 -77
- package/src/internal/node_launcher/node_system.js +0 -192
- package/src/internal/node_launcher/perf_node.js +0 -13
- package/src/internal/node_launcher/process_options.js +0 -46
- package/src/internal/node_launcher/value_install.js +0 -14
- package/src/internal/origin_directory_converter.js +0 -62
- package/src/internal/promise_race.js +0 -19
- package/src/internal/redirector/redirector.html +0 -40
- package/src/internal/regexp_escape.js +0 -34
- package/src/internal/require.js +0 -3
- package/src/internal/response_validation.js +0 -130
- package/src/internal/runtime_client/module_registration.js +0 -207
- package/src/internal/runtime_client/s.js +0 -864
- package/src/internal/runtime_client/s.js.md +0 -1
- package/src/internal/runtime_support/jsenv_runtime_support.js +0 -15
- package/src/internal/runtime_support/runtime_support.js +0 -70
- package/src/internal/semantic_versioning/compare_versions.js +0 -28
- package/src/internal/semantic_versioning/highest_version.js +0 -11
- package/src/internal/semantic_versioning/is_above.js +0 -5
- package/src/internal/semantic_versioning/is_below.js +0 -5
- package/src/internal/semantic_versioning/is_equal.js +0 -3
- package/src/internal/semantic_versioning/lowest_version.js +0 -11
- package/src/internal/semantic_versioning/version_from_value.js +0 -42
- package/src/internal/sourcemap_utils.js +0 -112
- package/src/internal/template_string_escape.js +0 -20
- package/src/internal/url_conversion.js +0 -313
- package/src/internal/url_utils.js +0 -33
- package/src/internal/url_utils.test.js +0 -39
- package/src/internal/windows_file_path_utils.js +0 -16
- package/src/jsenv_file_urls.js +0 -35
- package/src/jsenv_service_worker_finalizer.js +0 -55
- package/src/json_to_js_module.js +0 -13
- package/src/node_runtime.js +0 -227
- package/src/require_using_child_process.js +0 -67
- package/src/text_to_js_module.js +0 -13
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jsenvAccessControlAllowedHeaders,
|
|
3
|
+
startServer,
|
|
4
|
+
composeServices,
|
|
5
|
+
pluginServerTiming,
|
|
6
|
+
pluginRequestWaitingCheck,
|
|
7
|
+
pluginCORS,
|
|
8
|
+
} from "@jsenv/server"
|
|
9
|
+
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/internal/convertFileSystemErrorToResponseProperties.js"
|
|
10
|
+
import { createCallbackListNotifiedOnce } from "@jsenv/abort"
|
|
11
|
+
import { loggerToLogLevel } from "@jsenv/logger"
|
|
12
|
+
|
|
13
|
+
import { createFileService } from "./server/file_service.js"
|
|
14
|
+
|
|
15
|
+
export const startOmegaServer = async ({
|
|
16
|
+
signal,
|
|
17
|
+
handleSIGINT,
|
|
18
|
+
logger,
|
|
19
|
+
protocol = "http",
|
|
20
|
+
http2 = protocol === "https",
|
|
21
|
+
privateKey,
|
|
22
|
+
certificate,
|
|
23
|
+
listenAnyIp,
|
|
24
|
+
ip,
|
|
25
|
+
port = 0,
|
|
26
|
+
keepProcessAlive = false,
|
|
27
|
+
onStop = () => {},
|
|
28
|
+
serverPlugins,
|
|
29
|
+
services,
|
|
30
|
+
|
|
31
|
+
rootDirectoryUrl,
|
|
32
|
+
scenario,
|
|
33
|
+
urlGraph,
|
|
34
|
+
kitchen,
|
|
35
|
+
}) => {
|
|
36
|
+
const serverStopCallbackList = createCallbackListNotifiedOnce()
|
|
37
|
+
const coreServices = {
|
|
38
|
+
"service:file": createFileService({
|
|
39
|
+
rootDirectoryUrl,
|
|
40
|
+
urlGraph,
|
|
41
|
+
kitchen,
|
|
42
|
+
scenario,
|
|
43
|
+
}),
|
|
44
|
+
}
|
|
45
|
+
const server = await startServer({
|
|
46
|
+
signal,
|
|
47
|
+
stopOnExit: false,
|
|
48
|
+
stopOnSIGINT: handleSIGINT,
|
|
49
|
+
stopOnInternalError: false,
|
|
50
|
+
keepProcessAlive,
|
|
51
|
+
logLevel: loggerToLogLevel(logger),
|
|
52
|
+
startLog: false,
|
|
53
|
+
|
|
54
|
+
protocol,
|
|
55
|
+
http2,
|
|
56
|
+
certificate,
|
|
57
|
+
privateKey,
|
|
58
|
+
listenAnyIp,
|
|
59
|
+
ip,
|
|
60
|
+
port,
|
|
61
|
+
plugins: {
|
|
62
|
+
...serverPlugins,
|
|
63
|
+
...pluginCORS({
|
|
64
|
+
accessControlAllowRequestOrigin: true,
|
|
65
|
+
accessControlAllowRequestMethod: true,
|
|
66
|
+
accessControlAllowRequestHeaders: true,
|
|
67
|
+
accessControlAllowedRequestHeaders: [
|
|
68
|
+
...jsenvAccessControlAllowedHeaders,
|
|
69
|
+
"x-jsenv-execution-id",
|
|
70
|
+
],
|
|
71
|
+
accessControlAllowCredentials: true,
|
|
72
|
+
}),
|
|
73
|
+
...pluginServerTiming(),
|
|
74
|
+
...pluginRequestWaitingCheck({
|
|
75
|
+
requestWaitingMs: 60 * 1000,
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
sendErrorDetails: true,
|
|
79
|
+
errorToResponse: (error, { request }) => {
|
|
80
|
+
const getResponseForError = () => {
|
|
81
|
+
if (error && error.asResponse) {
|
|
82
|
+
return error.asResponse()
|
|
83
|
+
}
|
|
84
|
+
if (error && error.statusText === "Unexpected directory operation") {
|
|
85
|
+
return {
|
|
86
|
+
status: 403,
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return convertFileSystemErrorToResponseProperties(error)
|
|
90
|
+
}
|
|
91
|
+
const response = getResponseForError()
|
|
92
|
+
if (!response) {
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
const isInspectRequest = new URL(
|
|
96
|
+
request.ressource,
|
|
97
|
+
request.origin,
|
|
98
|
+
).searchParams.has("__inspect__")
|
|
99
|
+
if (!isInspectRequest) {
|
|
100
|
+
return response
|
|
101
|
+
}
|
|
102
|
+
const body = JSON.stringify({
|
|
103
|
+
status: response.status,
|
|
104
|
+
statusText: response.statusText,
|
|
105
|
+
headers: response.headers,
|
|
106
|
+
body: response.body,
|
|
107
|
+
})
|
|
108
|
+
return {
|
|
109
|
+
status: 200,
|
|
110
|
+
headers: {
|
|
111
|
+
"content-type": "application/json",
|
|
112
|
+
"content-length": Buffer.byteLength(body),
|
|
113
|
+
},
|
|
114
|
+
body,
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
requestToResponse: composeServices({
|
|
118
|
+
...services,
|
|
119
|
+
...coreServices,
|
|
120
|
+
}),
|
|
121
|
+
onStop: (reason) => {
|
|
122
|
+
onStop()
|
|
123
|
+
serverStopCallbackList.notify(reason)
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
return {
|
|
127
|
+
...server,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
export const createPluginController = ({
|
|
2
|
+
plugins,
|
|
3
|
+
scenario,
|
|
4
|
+
hooks = [
|
|
5
|
+
"resolve",
|
|
6
|
+
"normalize",
|
|
7
|
+
"load",
|
|
8
|
+
"transform",
|
|
9
|
+
"transformReferencedUrl",
|
|
10
|
+
"formatReferencedUrl",
|
|
11
|
+
"finalize",
|
|
12
|
+
"cooked",
|
|
13
|
+
"destroy",
|
|
14
|
+
],
|
|
15
|
+
}) => {
|
|
16
|
+
plugins = flattenAndFilterPlugins(plugins, { scenario })
|
|
17
|
+
// precompute a list of hooks per hookName
|
|
18
|
+
// For one major reason:
|
|
19
|
+
// - When debugging, there is less iteration
|
|
20
|
+
// And also it should increase perf as there is less work to do
|
|
21
|
+
const hookGroups = {}
|
|
22
|
+
const addHook = (hookName) => {
|
|
23
|
+
const hooks = []
|
|
24
|
+
plugins.forEach((plugin) => {
|
|
25
|
+
const hook = plugin[hookName]
|
|
26
|
+
if (hook) {
|
|
27
|
+
hooks.push({
|
|
28
|
+
plugin,
|
|
29
|
+
hookName,
|
|
30
|
+
value: hook,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
hookGroups[hookName] = hooks
|
|
35
|
+
return hooks
|
|
36
|
+
}
|
|
37
|
+
hooks.forEach((hookName) => {
|
|
38
|
+
addHook(hookName)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
let currentPlugin = null
|
|
42
|
+
let currentHookName = null
|
|
43
|
+
const callHook = (hook, info, context) => {
|
|
44
|
+
const hookFn = getHookFunction(hook, info)
|
|
45
|
+
if (!hookFn) {
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
currentPlugin = hook.plugin
|
|
49
|
+
currentHookName = hook.hookName
|
|
50
|
+
let valueReturned = hookFn(info, context)
|
|
51
|
+
valueReturned = assertAndNormalizeReturnValue(hook.hookName, valueReturned)
|
|
52
|
+
currentPlugin = null
|
|
53
|
+
currentHookName = null
|
|
54
|
+
return valueReturned
|
|
55
|
+
}
|
|
56
|
+
const callAsyncHook = async (hook, info, context) => {
|
|
57
|
+
const hookFn = getHookFunction(hook, info)
|
|
58
|
+
if (!hookFn) {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
currentPlugin = hook.plugin
|
|
62
|
+
currentHookName = hook.hookName
|
|
63
|
+
let valueReturned = await hookFn(info, context)
|
|
64
|
+
valueReturned = assertAndNormalizeReturnValue(hook.hookName, valueReturned)
|
|
65
|
+
currentPlugin = null
|
|
66
|
+
currentHookName = null
|
|
67
|
+
return valueReturned
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const callHooks = (hookName, info, context, callback) => {
|
|
71
|
+
const hooks = hookGroups[hookName]
|
|
72
|
+
for (const hook of hooks) {
|
|
73
|
+
const returnValue = callHook(hook, info, context)
|
|
74
|
+
if (returnValue) {
|
|
75
|
+
callback(returnValue)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const callAsyncHooks = async (hookName, info, context, callback) => {
|
|
80
|
+
const hooks = hookGroups[hookName]
|
|
81
|
+
await hooks.reduce(async (previous, hook) => {
|
|
82
|
+
await previous
|
|
83
|
+
const returnValue = await callAsyncHook(hook, info, context)
|
|
84
|
+
if (returnValue && callback) {
|
|
85
|
+
await callback(returnValue)
|
|
86
|
+
}
|
|
87
|
+
}, Promise.resolve())
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const callHooksUntil = (hookName, info, context) => {
|
|
91
|
+
const hooks = hookGroups[hookName]
|
|
92
|
+
for (const hook of hooks) {
|
|
93
|
+
const returnValue = callHook(hook, info, context)
|
|
94
|
+
if (returnValue) {
|
|
95
|
+
return returnValue
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
const callAsyncHooksUntil = (hookName, info, context) => {
|
|
101
|
+
const hooks = hookGroups[hookName]
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
const visit = (index) => {
|
|
104
|
+
if (index >= hooks.length) {
|
|
105
|
+
return resolve()
|
|
106
|
+
}
|
|
107
|
+
const hook = hooks[index]
|
|
108
|
+
const returnValue = callAsyncHook(hook, info, context)
|
|
109
|
+
return Promise.resolve(returnValue).then((output) => {
|
|
110
|
+
if (output) {
|
|
111
|
+
return resolve(output)
|
|
112
|
+
}
|
|
113
|
+
return visit(index + 1)
|
|
114
|
+
}, reject)
|
|
115
|
+
}
|
|
116
|
+
visit(0)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
plugins,
|
|
122
|
+
addHook,
|
|
123
|
+
getHookFunction,
|
|
124
|
+
callHook,
|
|
125
|
+
callAsyncHook,
|
|
126
|
+
|
|
127
|
+
callHooks,
|
|
128
|
+
callHooksUntil,
|
|
129
|
+
callAsyncHooks,
|
|
130
|
+
callAsyncHooksUntil,
|
|
131
|
+
|
|
132
|
+
getCurrentPlugin: () => currentPlugin,
|
|
133
|
+
getCurrentHookName: () => currentHookName,
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const flattenAndFilterPlugins = (pluginsRaw, { scenario }) => {
|
|
138
|
+
const plugins = []
|
|
139
|
+
const visitPluginEntry = (pluginEntry) => {
|
|
140
|
+
if (Array.isArray(pluginEntry)) {
|
|
141
|
+
pluginEntry.forEach((value) => visitPluginEntry(value))
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
if (typeof pluginEntry === "object" && pluginEntry !== null) {
|
|
145
|
+
const { appliesDuring } = pluginEntry
|
|
146
|
+
if (appliesDuring === undefined) {
|
|
147
|
+
console.warn(`"appliesDuring" is undefined on ${pluginEntry.name}`)
|
|
148
|
+
}
|
|
149
|
+
if (appliesDuring === "*") {
|
|
150
|
+
plugins.push(pluginEntry)
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
if (appliesDuring && appliesDuring[scenario]) {
|
|
154
|
+
plugins.push(pluginEntry)
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
if (pluginEntry.destroy) {
|
|
158
|
+
pluginEntry.destroy()
|
|
159
|
+
}
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
throw new Error(`plugin must be objects, got ${pluginEntry}`)
|
|
163
|
+
}
|
|
164
|
+
pluginsRaw.forEach((plugin) => visitPluginEntry(plugin))
|
|
165
|
+
return plugins
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const getHookFunction = (
|
|
169
|
+
hook,
|
|
170
|
+
// can be undefined, reference, or urlInfo
|
|
171
|
+
info = {},
|
|
172
|
+
) => {
|
|
173
|
+
const hookValue = hook.value
|
|
174
|
+
if (typeof hookValue === "object") {
|
|
175
|
+
const hookForType = hookValue[info.type] || hookValue["*"]
|
|
176
|
+
if (!hookForType) {
|
|
177
|
+
return null
|
|
178
|
+
}
|
|
179
|
+
return hookForType
|
|
180
|
+
}
|
|
181
|
+
return hookValue
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const assertAndNormalizeReturnValue = (hookName, returnValue) => {
|
|
185
|
+
// all hooks are allowed to return null/undefined as a signal of "I don't do anything"
|
|
186
|
+
if (returnValue === null || returnValue === undefined) {
|
|
187
|
+
return returnValue
|
|
188
|
+
}
|
|
189
|
+
for (const returnValueAssertion of returnValueAssertions) {
|
|
190
|
+
if (!returnValueAssertion.appliesTo.includes(hookName)) {
|
|
191
|
+
continue
|
|
192
|
+
}
|
|
193
|
+
const assertionResult = returnValueAssertion.assertion(returnValue)
|
|
194
|
+
if (assertionResult !== undefined) {
|
|
195
|
+
// normalization
|
|
196
|
+
returnValue = assertionResult
|
|
197
|
+
break
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return returnValue
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const returnValueAssertions = [
|
|
204
|
+
{
|
|
205
|
+
name: "url_assertion",
|
|
206
|
+
appliesTo: ["resolve", "redirect"],
|
|
207
|
+
assertion: (valueReturned) => {
|
|
208
|
+
if (valueReturned instanceof URL) {
|
|
209
|
+
return valueReturned.href
|
|
210
|
+
}
|
|
211
|
+
if (typeof valueReturned === "string") {
|
|
212
|
+
return undefined
|
|
213
|
+
}
|
|
214
|
+
throw new Error(
|
|
215
|
+
`Unexpected value returned by plugin: it must be a string; got ${valueReturned}`,
|
|
216
|
+
)
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "content_assertion",
|
|
221
|
+
appliesTo: ["load", "transform", "finalize"],
|
|
222
|
+
assertion: (valueReturned) => {
|
|
223
|
+
if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) {
|
|
224
|
+
return { content: valueReturned }
|
|
225
|
+
}
|
|
226
|
+
if (typeof valueReturned === "object") {
|
|
227
|
+
const { content } = valueReturned
|
|
228
|
+
if (typeof content !== "string" && !Buffer.isBuffer(content)) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
`Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`,
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
return undefined
|
|
234
|
+
}
|
|
235
|
+
throw new Error(
|
|
236
|
+
`Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`,
|
|
237
|
+
)
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export const featuresCompatMap = {
|
|
2
|
+
script_type_module: {
|
|
3
|
+
edge: "16",
|
|
4
|
+
firefox: "60",
|
|
5
|
+
chrome: "61",
|
|
6
|
+
safari: "10.1",
|
|
7
|
+
opera: "48",
|
|
8
|
+
ios: "10.3",
|
|
9
|
+
android: "61",
|
|
10
|
+
samsung: "8.2",
|
|
11
|
+
},
|
|
12
|
+
import_meta: {
|
|
13
|
+
chrome: "64",
|
|
14
|
+
edge: "79",
|
|
15
|
+
firefox: "62",
|
|
16
|
+
safari: "11.1",
|
|
17
|
+
opera: "51",
|
|
18
|
+
ios: "12",
|
|
19
|
+
android: "9",
|
|
20
|
+
},
|
|
21
|
+
import_dynamic: {
|
|
22
|
+
edge: "79",
|
|
23
|
+
firefox: "67",
|
|
24
|
+
chrome: "63",
|
|
25
|
+
safari: "11.3",
|
|
26
|
+
opera: "50",
|
|
27
|
+
android: "8",
|
|
28
|
+
node: "13.2",
|
|
29
|
+
},
|
|
30
|
+
top_level_await: {
|
|
31
|
+
edge: "89",
|
|
32
|
+
chrome: "89",
|
|
33
|
+
firefox: "89",
|
|
34
|
+
opera: "75",
|
|
35
|
+
safari: "15",
|
|
36
|
+
samsung: "15",
|
|
37
|
+
ios: "15",
|
|
38
|
+
node: "14.8",
|
|
39
|
+
},
|
|
40
|
+
// https://caniuse.com/import-maps
|
|
41
|
+
importmap: {
|
|
42
|
+
edge: "89",
|
|
43
|
+
chrome: "89",
|
|
44
|
+
opera: "76",
|
|
45
|
+
samsung: "15",
|
|
46
|
+
},
|
|
47
|
+
import_type_json: {
|
|
48
|
+
chrome: "91",
|
|
49
|
+
edge: "91",
|
|
50
|
+
},
|
|
51
|
+
import_type_css: {
|
|
52
|
+
chrome: "93",
|
|
53
|
+
edge: "93",
|
|
54
|
+
},
|
|
55
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet#browser_compatibility
|
|
56
|
+
new_stylesheet: {
|
|
57
|
+
chrome: "73",
|
|
58
|
+
edge: "79",
|
|
59
|
+
opera: "53",
|
|
60
|
+
android: "73",
|
|
61
|
+
},
|
|
62
|
+
worker_type_module: {
|
|
63
|
+
chrome: "80",
|
|
64
|
+
edge: "80",
|
|
65
|
+
opera: "67",
|
|
66
|
+
android: "80",
|
|
67
|
+
},
|
|
68
|
+
worker_importmap: {},
|
|
69
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
|
|
70
|
+
global_this: {
|
|
71
|
+
edge: "79",
|
|
72
|
+
firefox: "65",
|
|
73
|
+
chrome: "71",
|
|
74
|
+
safari: "12.1",
|
|
75
|
+
opera: "58",
|
|
76
|
+
ios: "12.2",
|
|
77
|
+
android: "94",
|
|
78
|
+
node: "12",
|
|
79
|
+
},
|
|
80
|
+
async_generator_function: {
|
|
81
|
+
chrome: "63",
|
|
82
|
+
opera: "50",
|
|
83
|
+
edge: "79",
|
|
84
|
+
firefox: "57",
|
|
85
|
+
safari: "12",
|
|
86
|
+
node: "10",
|
|
87
|
+
ios: "12",
|
|
88
|
+
samsung: "8",
|
|
89
|
+
electron: "3",
|
|
90
|
+
},
|
|
91
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { findHighestVersion } from "@jsenv/utils/semantic_versioning/highest_version.js"
|
|
2
|
+
|
|
3
|
+
export const isFeatureSupportedOnRuntimes = (
|
|
4
|
+
runtimeSupport,
|
|
5
|
+
featureCompat = {},
|
|
6
|
+
) => {
|
|
7
|
+
const runtimeNames = Object.keys(runtimeSupport)
|
|
8
|
+
return runtimeNames.every((runtimeName) => {
|
|
9
|
+
const runtimeVersion = runtimeSupport[runtimeName]
|
|
10
|
+
const runtimeVersionCompatible = featureCompat[runtimeName] || "Infinity"
|
|
11
|
+
const highestVersion = findHighestVersion(
|
|
12
|
+
runtimeVersion,
|
|
13
|
+
runtimeVersionCompatible,
|
|
14
|
+
)
|
|
15
|
+
if (highestVersion !== runtimeVersion) {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
return true
|
|
19
|
+
})
|
|
20
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchFileSystem,
|
|
3
|
+
serveDirectory,
|
|
4
|
+
composeTwoResponses,
|
|
5
|
+
} from "@jsenv/server"
|
|
6
|
+
import { urlIsInsideOf, moveUrl } from "@jsenv/filesystem"
|
|
7
|
+
|
|
8
|
+
import { parseUserAgentHeader } from "./user_agent.js"
|
|
9
|
+
|
|
10
|
+
export const createFileService = ({
|
|
11
|
+
rootDirectoryUrl,
|
|
12
|
+
urlGraph,
|
|
13
|
+
kitchen,
|
|
14
|
+
scenario,
|
|
15
|
+
}) => {
|
|
16
|
+
kitchen.pluginController.addHook("serve")
|
|
17
|
+
kitchen.pluginController.addHook("augmentResponse")
|
|
18
|
+
const serveContext = {
|
|
19
|
+
rootDirectoryUrl,
|
|
20
|
+
urlGraph,
|
|
21
|
+
scenario,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const getResponse = async (request) => {
|
|
25
|
+
// serve file inside ".jsenv" directory
|
|
26
|
+
const requestFileUrl = new URL(request.ressource.slice(1), rootDirectoryUrl)
|
|
27
|
+
.href
|
|
28
|
+
if (urlIsInsideOf(requestFileUrl, kitchen.jsenvDirectoryUrl)) {
|
|
29
|
+
return fetchFileSystem(requestFileUrl, {
|
|
30
|
+
headers: request.headers,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
const responseFromPlugin =
|
|
34
|
+
await kitchen.pluginController.callAsyncHooksUntil(
|
|
35
|
+
"serve",
|
|
36
|
+
request,
|
|
37
|
+
serveContext,
|
|
38
|
+
)
|
|
39
|
+
if (responseFromPlugin) {
|
|
40
|
+
return responseFromPlugin
|
|
41
|
+
}
|
|
42
|
+
const { runtimeName, runtimeVersion } = parseUserAgentHeader(
|
|
43
|
+
request.headers["user-agent"],
|
|
44
|
+
)
|
|
45
|
+
const runtimeSupport = {
|
|
46
|
+
[runtimeName]: runtimeVersion,
|
|
47
|
+
}
|
|
48
|
+
const reference = kitchen.createReference({
|
|
49
|
+
parentUrl: inferParentFromRequest(request, rootDirectoryUrl),
|
|
50
|
+
type: "entry_point",
|
|
51
|
+
specifier: request.ressource,
|
|
52
|
+
})
|
|
53
|
+
const requestedUrlInfo = kitchen.resolveReference(reference)
|
|
54
|
+
const referenceFromGraph = urlGraph.inferReference(
|
|
55
|
+
reference.url,
|
|
56
|
+
reference.parentUrl,
|
|
57
|
+
)
|
|
58
|
+
try {
|
|
59
|
+
await kitchen.cook({
|
|
60
|
+
reference: referenceFromGraph || reference,
|
|
61
|
+
urlInfo: requestedUrlInfo,
|
|
62
|
+
outDirectoryUrl: `${rootDirectoryUrl}.jsenv/${scenario}/${runtimeName}@${runtimeVersion}/`,
|
|
63
|
+
runtimeSupport,
|
|
64
|
+
})
|
|
65
|
+
const { response, contentType, content } = requestedUrlInfo
|
|
66
|
+
if (response) {
|
|
67
|
+
return response
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
url: reference.url,
|
|
71
|
+
status: 200,
|
|
72
|
+
headers: {
|
|
73
|
+
"content-type": contentType,
|
|
74
|
+
"content-length": Buffer.byteLength(content),
|
|
75
|
+
"cache-control": `private,max-age=0,must-revalidate`,
|
|
76
|
+
},
|
|
77
|
+
body: content,
|
|
78
|
+
}
|
|
79
|
+
} catch (e) {
|
|
80
|
+
const code = e.code
|
|
81
|
+
if (code === "PARSE_ERROR") {
|
|
82
|
+
// let the browser re-throw the syntax error
|
|
83
|
+
return {
|
|
84
|
+
url: reference.url,
|
|
85
|
+
status: 200,
|
|
86
|
+
statusText: e.reason,
|
|
87
|
+
statusMessage: e.message,
|
|
88
|
+
headers: {
|
|
89
|
+
"content-type": requestedUrlInfo.contentType,
|
|
90
|
+
"content-length": Buffer.byteLength(requestedUrlInfo.content),
|
|
91
|
+
"cache-control": "no-store",
|
|
92
|
+
},
|
|
93
|
+
body: requestedUrlInfo.content,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (code === "EISDIR") {
|
|
97
|
+
return serveDirectory(reference.url, {
|
|
98
|
+
headers: {
|
|
99
|
+
accept: "text/html",
|
|
100
|
+
},
|
|
101
|
+
canReadDirectory: true,
|
|
102
|
+
rootDirectoryUrl,
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
if (code === "NOT_ALLOWED") {
|
|
106
|
+
return {
|
|
107
|
+
url: reference.url,
|
|
108
|
+
status: 403,
|
|
109
|
+
statusText: e.reason,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (code === "NOT_FOUND") {
|
|
113
|
+
return {
|
|
114
|
+
url: reference.url,
|
|
115
|
+
status: 404,
|
|
116
|
+
statusText: e.reason,
|
|
117
|
+
statusMessage: e.message,
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
url: reference.url,
|
|
122
|
+
status: 500,
|
|
123
|
+
statusText: e.reason,
|
|
124
|
+
statusMessage: e.stack,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return async (request) => {
|
|
129
|
+
let response = await getResponse(request)
|
|
130
|
+
if (response.url) {
|
|
131
|
+
kitchen.pluginController.callHooks(
|
|
132
|
+
"augmentResponse",
|
|
133
|
+
response,
|
|
134
|
+
{},
|
|
135
|
+
(returnValue) => {
|
|
136
|
+
response = composeTwoResponses(response, returnValue)
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
return response
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const inferParentFromRequest = (request, rootDirectoryUrl) => {
|
|
145
|
+
const { referer } = request.headers
|
|
146
|
+
if (!referer) {
|
|
147
|
+
return rootDirectoryUrl
|
|
148
|
+
}
|
|
149
|
+
return moveUrl({
|
|
150
|
+
url: referer,
|
|
151
|
+
from: `${request.origin}/`,
|
|
152
|
+
to: rootDirectoryUrl,
|
|
153
|
+
preferAbsolute: true,
|
|
154
|
+
})
|
|
155
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module"
|
|
2
|
+
|
|
3
|
+
const require = createRequire(import.meta.url)
|
|
4
|
+
|
|
5
|
+
export const parseUserAgentHeader = (userAgent) => {
|
|
6
|
+
if (userAgent.includes("node-fetch/")) {
|
|
7
|
+
// it's not really node and conceptually we can't assume the node version
|
|
8
|
+
// but good enough for now
|
|
9
|
+
return {
|
|
10
|
+
runtimeName: "node",
|
|
11
|
+
runtimeVersion: process.version.slice(1),
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const UA = require("@financial-times/polyfill-useragent-normaliser")
|
|
15
|
+
const { ua } = new UA(userAgent)
|
|
16
|
+
const { family, major, minor, patch } = ua
|
|
17
|
+
return {
|
|
18
|
+
runtimeName: family.toLowerCase(),
|
|
19
|
+
runtimeVersion:
|
|
20
|
+
family === "Other" ? "unknown" : `${major}.${minor}${patch}`,
|
|
21
|
+
}
|
|
22
|
+
}
|