@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
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fork } from "node:child_process"
|
|
2
|
+
import {
|
|
3
|
+
Abort,
|
|
4
|
+
raceCallbacks,
|
|
5
|
+
createCallbackListNotifiedOnce,
|
|
6
|
+
} from "@jsenv/abort"
|
|
7
|
+
import { uneval } from "@jsenv/uneval"
|
|
8
|
+
import { urlToFileSystemPath } from "@jsenv/urls"
|
|
9
|
+
import { createDetailedMessage } from "@jsenv/log"
|
|
10
|
+
import { memoize } from "@jsenv/utils/src/memoize/memoize.js"
|
|
11
|
+
|
|
12
|
+
import { createChildExecOptions } from "./child_exec_options.js"
|
|
13
|
+
import { ExecOptions } from "./exec_options.js"
|
|
14
|
+
import { killProcessTree } from "./kill_process_tree.js"
|
|
15
|
+
|
|
16
|
+
const NODE_CONTROLLABLE_FILE_URL = new URL(
|
|
17
|
+
"./controllable_file.mjs",
|
|
18
|
+
import.meta.url,
|
|
19
|
+
).href
|
|
2
20
|
|
|
3
21
|
export const nodeProcess = {
|
|
4
22
|
name: "node",
|
|
@@ -8,33 +26,32 @@ export const nodeProcess = {
|
|
|
8
26
|
nodeProcess.run = async ({
|
|
9
27
|
signal = new AbortController().signal,
|
|
10
28
|
logger,
|
|
11
|
-
logProcessCommand,
|
|
29
|
+
logProcessCommand = false,
|
|
12
30
|
rootDirectoryUrl,
|
|
13
31
|
fileRelativeUrl,
|
|
14
32
|
|
|
15
33
|
keepRunning,
|
|
16
34
|
gracefulStopAllocatedMs = 4000,
|
|
17
35
|
stopSignal,
|
|
18
|
-
onStop,
|
|
19
|
-
onError,
|
|
20
36
|
onConsole,
|
|
21
|
-
onResult,
|
|
22
37
|
|
|
23
|
-
measurePerformance,
|
|
24
|
-
collectPerformance,
|
|
25
38
|
collectCoverage = false,
|
|
26
39
|
coverageForceIstanbul,
|
|
40
|
+
collectPerformance,
|
|
27
41
|
|
|
28
42
|
debugPort,
|
|
29
43
|
debugMode,
|
|
30
44
|
debugModeInheritBreak,
|
|
31
45
|
env,
|
|
32
|
-
inheritProcessEnv,
|
|
46
|
+
inheritProcessEnv = true,
|
|
33
47
|
commandLineOptions = [],
|
|
34
|
-
stdin,
|
|
35
|
-
stdout,
|
|
36
|
-
stderr,
|
|
48
|
+
stdin = "pipe",
|
|
49
|
+
stdout = "pipe",
|
|
50
|
+
stderr = "pipe",
|
|
37
51
|
}) => {
|
|
52
|
+
if (env !== undefined && typeof env !== "object") {
|
|
53
|
+
throw new TypeError(`env must be an object, got ${env}`)
|
|
54
|
+
}
|
|
38
55
|
env = {
|
|
39
56
|
...env,
|
|
40
57
|
COVERAGE_ENABLED: collectCoverage,
|
|
@@ -49,44 +66,276 @@ nodeProcess.run = async ({
|
|
|
49
66
|
"--experimental-import-meta-resolve",
|
|
50
67
|
...commandLineOptions,
|
|
51
68
|
]
|
|
52
|
-
|
|
69
|
+
|
|
70
|
+
const cleanupCallbackList = createCallbackListNotifiedOnce()
|
|
71
|
+
const cleanup = async (reason) => {
|
|
72
|
+
await cleanupCallbackList.notify({ reason })
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const childExecOptions = await createChildExecOptions({
|
|
53
76
|
signal,
|
|
54
|
-
logger,
|
|
55
77
|
debugPort,
|
|
56
78
|
debugMode,
|
|
57
79
|
debugModeInheritBreak,
|
|
58
|
-
env,
|
|
59
|
-
inheritProcessEnv,
|
|
60
|
-
commandLineOptions,
|
|
61
|
-
stdin,
|
|
62
|
-
stdout,
|
|
63
|
-
stderr,
|
|
64
|
-
logProcessCommand,
|
|
65
|
-
|
|
66
|
-
stopSignal,
|
|
67
|
-
onStop,
|
|
68
|
-
onError,
|
|
69
|
-
onConsole,
|
|
70
80
|
})
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
const execArgv = ExecOptions.toExecArgv({
|
|
82
|
+
...childExecOptions,
|
|
83
|
+
...ExecOptions.fromExecArgv(commandLineOptions),
|
|
84
|
+
})
|
|
85
|
+
const envForChildProcess = {
|
|
86
|
+
...(inheritProcessEnv ? process.env : {}),
|
|
87
|
+
...env,
|
|
88
|
+
}
|
|
89
|
+
logger[logProcessCommand ? "info" : "debug"](
|
|
90
|
+
`${process.argv[0]} ${execArgv.join(" ")} ${urlToFileSystemPath(
|
|
91
|
+
NODE_CONTROLLABLE_FILE_URL,
|
|
92
|
+
)}`,
|
|
93
|
+
)
|
|
94
|
+
const childProcess = fork(urlToFileSystemPath(NODE_CONTROLLABLE_FILE_URL), {
|
|
95
|
+
execArgv,
|
|
96
|
+
// silent: true
|
|
97
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
98
|
+
env: envForChildProcess,
|
|
99
|
+
})
|
|
100
|
+
logger.debug(
|
|
101
|
+
createDetailedMessage(`child process forked (pid ${childProcess.pid})`, {
|
|
102
|
+
"execArgv": execArgv.join(`\n`),
|
|
103
|
+
"custom env": JSON.stringify(env, null, " "),
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
106
|
+
// if we pass stream, pipe them https://github.com/sindresorhus/execa/issues/81
|
|
107
|
+
if (typeof stdin === "object") {
|
|
108
|
+
stdin.pipe(childProcess.stdin)
|
|
109
|
+
}
|
|
110
|
+
if (typeof stdout === "object") {
|
|
111
|
+
childProcess.stdout.pipe(stdout)
|
|
112
|
+
}
|
|
113
|
+
if (typeof stderr === "object") {
|
|
114
|
+
childProcess.stderr.pipe(stderr)
|
|
115
|
+
}
|
|
116
|
+
const childProcessReadyPromise = new Promise((resolve) => {
|
|
117
|
+
onceProcessMessage(childProcess, "ready", resolve)
|
|
118
|
+
})
|
|
119
|
+
const removeOutputListener = installProcessOutputListener(
|
|
120
|
+
childProcess,
|
|
121
|
+
({ type, text }) => {
|
|
122
|
+
onConsole({ type, text })
|
|
79
123
|
},
|
|
124
|
+
)
|
|
125
|
+
const stop = memoize(async ({ gracefulStopAllocatedMs } = {}) => {
|
|
126
|
+
// all libraries are facing problem on windows when trying
|
|
127
|
+
// to kill a process spawning other processes.
|
|
128
|
+
// "killProcessTree" is theorically correct but sometimes keep process handing forever.
|
|
129
|
+
// Inside GitHub workflow the whole Virtual machine gets unresponsive and ends up being killed
|
|
130
|
+
// There is no satisfying solution to this problem so we stick to the basic
|
|
131
|
+
// childProcess.kill()
|
|
132
|
+
if (process.platform === "win32") {
|
|
133
|
+
childProcess.kill()
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
if (gracefulStopAllocatedMs) {
|
|
137
|
+
try {
|
|
138
|
+
await killProcessTree(childProcess.pid, {
|
|
139
|
+
signal: GRACEFUL_STOP_SIGNAL,
|
|
140
|
+
timeout: gracefulStopAllocatedMs,
|
|
141
|
+
})
|
|
142
|
+
return
|
|
143
|
+
} catch (e) {
|
|
144
|
+
if (e.code === "TIMEOUT") {
|
|
145
|
+
logger.debug(
|
|
146
|
+
`kill with SIGTERM because gracefulStop still pending after ${gracefulStopAllocatedMs}ms`,
|
|
147
|
+
)
|
|
148
|
+
await killProcessTree(childProcess.pid, {
|
|
149
|
+
signal: GRACEFUL_STOP_FAILED_SIGNAL,
|
|
150
|
+
})
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
throw e
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
await killProcessTree(childProcess.pid, { signal: STOP_SIGNAL })
|
|
157
|
+
return
|
|
80
158
|
})
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
159
|
+
|
|
160
|
+
const actionOperation = Abort.startOperation()
|
|
161
|
+
actionOperation.addAbortSignal(signal)
|
|
162
|
+
const winnerPromise = new Promise((resolve) => {
|
|
163
|
+
raceCallbacks(
|
|
164
|
+
{
|
|
165
|
+
aborted: (cb) => {
|
|
166
|
+
return actionOperation.addAbortCallback(cb)
|
|
167
|
+
},
|
|
168
|
+
// https://nodejs.org/api/child_process.html#child_process_event_disconnect
|
|
169
|
+
// disconnect: (cb) => {
|
|
170
|
+
// return onceProcessEvent(childProcess, "disconnect", cb)
|
|
171
|
+
// },
|
|
172
|
+
// https://nodejs.org/api/child_process.html#child_process_event_error
|
|
173
|
+
error: (cb) => {
|
|
174
|
+
return onceProcessEvent(childProcess, "error", cb)
|
|
175
|
+
},
|
|
176
|
+
exit: (cb) => {
|
|
177
|
+
return onceProcessEvent(childProcess, "exit", (code, signal) => {
|
|
178
|
+
cb({ code, signal })
|
|
179
|
+
})
|
|
180
|
+
},
|
|
181
|
+
response: (cb) => {
|
|
182
|
+
onceProcessMessage(childProcess, "action-result", cb)
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
resolve,
|
|
186
|
+
)
|
|
84
187
|
})
|
|
188
|
+
const getResult = async () => {
|
|
189
|
+
actionOperation.throwIfAborted()
|
|
190
|
+
await childProcessReadyPromise
|
|
191
|
+
actionOperation.throwIfAborted()
|
|
192
|
+
await sendToProcess(childProcess, "action", {
|
|
193
|
+
actionType: "execute-using-dynamic-import",
|
|
194
|
+
actionParams: {
|
|
195
|
+
fileUrl: new URL(fileRelativeUrl, rootDirectoryUrl).href,
|
|
196
|
+
collectPerformance,
|
|
197
|
+
},
|
|
198
|
+
})
|
|
199
|
+
const winner = await winnerPromise
|
|
200
|
+
if (winner.name === "aborted") {
|
|
201
|
+
return {
|
|
202
|
+
status: "aborted",
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (winner.name === "error") {
|
|
206
|
+
const error = winner.data
|
|
207
|
+
removeOutputListener()
|
|
208
|
+
return {
|
|
209
|
+
status: "errored",
|
|
210
|
+
error,
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (winner.name === "exit") {
|
|
214
|
+
const { code } = winner.data
|
|
215
|
+
await cleanup("process exit")
|
|
216
|
+
if (code === 12) {
|
|
217
|
+
return {
|
|
218
|
+
status: "errored",
|
|
219
|
+
error: new Error(
|
|
220
|
+
`node process exited with 12 (the forked child process wanted to use a non-available port for debug)`,
|
|
221
|
+
),
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (
|
|
225
|
+
code === null ||
|
|
226
|
+
code === 0 ||
|
|
227
|
+
code === SIGINT_EXIT_CODE ||
|
|
228
|
+
code === SIGTERM_EXIT_CODE ||
|
|
229
|
+
code === SIGABORT_EXIT_CODE
|
|
230
|
+
) {
|
|
231
|
+
return {
|
|
232
|
+
status: "errored",
|
|
233
|
+
error: new Error(`node process exited during execution`),
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// process.exit(1) in child process or process.exitCode = 1 + process.exit()
|
|
237
|
+
// means there was an error even if we don't know exactly what.
|
|
238
|
+
return {
|
|
239
|
+
status: "errored",
|
|
240
|
+
error: new Error(
|
|
241
|
+
`node process exited with code ${code} during execution`,
|
|
242
|
+
),
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const { status, value } = winner.data
|
|
246
|
+
if (status === "action-failed") {
|
|
247
|
+
return {
|
|
248
|
+
status: "errored",
|
|
249
|
+
error: value,
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
status: "completed",
|
|
254
|
+
...value,
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let result
|
|
259
|
+
try {
|
|
260
|
+
result = await getResult()
|
|
261
|
+
} catch (e) {
|
|
262
|
+
result = {
|
|
263
|
+
status: "errored",
|
|
264
|
+
error: e,
|
|
265
|
+
}
|
|
266
|
+
}
|
|
85
267
|
if (keepRunning) {
|
|
86
268
|
stopSignal.notify = stop
|
|
87
|
-
|
|
269
|
+
} else {
|
|
270
|
+
await stop({
|
|
271
|
+
gracefulStopAllocatedMs,
|
|
272
|
+
})
|
|
88
273
|
}
|
|
89
|
-
await
|
|
90
|
-
|
|
274
|
+
await actionOperation.end()
|
|
275
|
+
return result
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// https://nodejs.org/api/process.html#process_signal_events
|
|
279
|
+
const SIGINT_SIGNAL_NUMBER = 2
|
|
280
|
+
const SIGABORT_SIGNAL_NUMBER = 6
|
|
281
|
+
const SIGTERM_SIGNAL_NUMBER = 15
|
|
282
|
+
const SIGINT_EXIT_CODE = 128 + SIGINT_SIGNAL_NUMBER
|
|
283
|
+
const SIGABORT_EXIT_CODE = 128 + SIGABORT_SIGNAL_NUMBER
|
|
284
|
+
const SIGTERM_EXIT_CODE = 128 + SIGTERM_SIGNAL_NUMBER
|
|
285
|
+
// http://man7.org/linux/man-pages/man7/signal.7.html
|
|
286
|
+
// https:// github.com/nodejs/node/blob/1d9511127c419ec116b3ddf5fc7a59e8f0f1c1e4/lib/internal/child_process.js#L472
|
|
287
|
+
const GRACEFUL_STOP_SIGNAL = "SIGTERM"
|
|
288
|
+
const STOP_SIGNAL = "SIGKILL"
|
|
289
|
+
// it would be more correct if GRACEFUL_STOP_FAILED_SIGNAL was SIGHUP instead of SIGKILL.
|
|
290
|
+
// but I'm not sure and it changes nothing so just use SIGKILL
|
|
291
|
+
const GRACEFUL_STOP_FAILED_SIGNAL = "SIGKILL"
|
|
292
|
+
|
|
293
|
+
const sendToProcess = async (childProcess, type, data) => {
|
|
294
|
+
const source = uneval(data, { functionAllowed: true })
|
|
295
|
+
return new Promise((resolve, reject) => {
|
|
296
|
+
childProcess.send({ type, data: source }, (error) => {
|
|
297
|
+
if (error) {
|
|
298
|
+
reject(error)
|
|
299
|
+
} else {
|
|
300
|
+
resolve()
|
|
301
|
+
}
|
|
302
|
+
})
|
|
91
303
|
})
|
|
92
304
|
}
|
|
305
|
+
|
|
306
|
+
const installProcessOutputListener = (childProcess, callback) => {
|
|
307
|
+
// beware that we may receive ansi output here, should not be a problem but keep that in mind
|
|
308
|
+
const stdoutDataCallback = (chunk) => {
|
|
309
|
+
callback({ type: "log", text: String(chunk) })
|
|
310
|
+
}
|
|
311
|
+
childProcess.stdout.on("data", stdoutDataCallback)
|
|
312
|
+
const stdErrorDataCallback = (chunk) => {
|
|
313
|
+
callback({ type: "error", text: String(chunk) })
|
|
314
|
+
}
|
|
315
|
+
childProcess.stderr.on("data", stdErrorDataCallback)
|
|
316
|
+
return () => {
|
|
317
|
+
childProcess.stdout.removeListener("data", stdoutDataCallback)
|
|
318
|
+
childProcess.stderr.removeListener("data", stdoutDataCallback)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const onceProcessMessage = (childProcess, type, callback) => {
|
|
323
|
+
const onmessage = (message) => {
|
|
324
|
+
if (message.type === type) {
|
|
325
|
+
childProcess.removeListener("message", onmessage)
|
|
326
|
+
// eslint-disable-next-line no-eval
|
|
327
|
+
callback(message.data ? eval(`(${message.data})`) : "")
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
childProcess.on("message", onmessage)
|
|
331
|
+
return () => {
|
|
332
|
+
childProcess.removeListener("message", onmessage)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const onceProcessEvent = (childProcess, type, callback) => {
|
|
337
|
+
childProcess.once(type, callback)
|
|
338
|
+
return () => {
|
|
339
|
+
childProcess.removeListener(type, callback)
|
|
340
|
+
}
|
|
341
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { exec } from "node:child_process"
|
|
2
|
+
import { createDetailedMessage, createLogger, UNICODE } from "@jsenv/log"
|
|
3
|
+
|
|
4
|
+
export const executeCommand = (
|
|
5
|
+
command,
|
|
6
|
+
{
|
|
7
|
+
logLevel = "info",
|
|
8
|
+
signal = new AbortController().signal,
|
|
9
|
+
onStdout = () => {},
|
|
10
|
+
onStderr = () => {},
|
|
11
|
+
cwd,
|
|
12
|
+
env,
|
|
13
|
+
timeout,
|
|
14
|
+
} = {},
|
|
15
|
+
) => {
|
|
16
|
+
const logger = createLogger({ logLevel })
|
|
17
|
+
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
logger.debug(`${UNICODE.COMMAND} ${command}`)
|
|
20
|
+
const commandProcess = exec(command, {
|
|
21
|
+
signal,
|
|
22
|
+
cwd:
|
|
23
|
+
cwd && typeof cwd === "string" && cwd.startsWith("file:")
|
|
24
|
+
? new URL(cwd)
|
|
25
|
+
: cwd,
|
|
26
|
+
env,
|
|
27
|
+
timeout,
|
|
28
|
+
silent: true,
|
|
29
|
+
})
|
|
30
|
+
commandProcess.on("error", (error) => {
|
|
31
|
+
if (error && error.code === "ETIMEDOUT") {
|
|
32
|
+
logger.error(`timeout after ${timeout} ms`)
|
|
33
|
+
reject(error)
|
|
34
|
+
} else {
|
|
35
|
+
reject(error)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
const stdoutDatas = []
|
|
39
|
+
commandProcess.stdout.on("data", (data) => {
|
|
40
|
+
stdoutDatas.push(data)
|
|
41
|
+
logger.debug(data)
|
|
42
|
+
onStderr(data)
|
|
43
|
+
})
|
|
44
|
+
let stderrDatas = []
|
|
45
|
+
commandProcess.stderr.on("data", (data) => {
|
|
46
|
+
stderrDatas.push(data)
|
|
47
|
+
logger.debug(data)
|
|
48
|
+
onStdout(data)
|
|
49
|
+
})
|
|
50
|
+
if (commandProcess.stdin) {
|
|
51
|
+
commandProcess.stdin.on("error", (error) => {
|
|
52
|
+
reject(error)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
commandProcess.on("exit", (exitCode, signal) => {
|
|
56
|
+
if (signal) {
|
|
57
|
+
reject(new Error(`killed with ${signal}`))
|
|
58
|
+
}
|
|
59
|
+
if (exitCode) {
|
|
60
|
+
reject(
|
|
61
|
+
new Error(
|
|
62
|
+
createDetailedMessage(`failed with exit code ${exitCode}`, {
|
|
63
|
+
"command stderr": stderrDatas.join(""),
|
|
64
|
+
// "command stdout": stdoutDatas.join(""),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
resolve({ exitCode, signal })
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createSSERoom } from "@jsenv/server"
|
|
2
|
+
import { createCallbackListNotifiedOnce } from "@jsenv/abort"
|
|
3
|
+
|
|
4
|
+
export const createSSEService = ({ serverEventCallbackList }) => {
|
|
5
|
+
const destroyCallbackList = createCallbackListNotifiedOnce()
|
|
6
|
+
|
|
7
|
+
const cache = []
|
|
8
|
+
const sseRoomLimit = 100
|
|
9
|
+
const getOrCreateSSERoom = (request) => {
|
|
10
|
+
const htmlFileRelativeUrl = request.ressource.slice(1)
|
|
11
|
+
const cacheEntry = cache.find(
|
|
12
|
+
(cacheEntryCandidate) =>
|
|
13
|
+
cacheEntryCandidate.htmlFileRelativeUrl === htmlFileRelativeUrl,
|
|
14
|
+
)
|
|
15
|
+
if (cacheEntry) {
|
|
16
|
+
return cacheEntry.sseRoom
|
|
17
|
+
}
|
|
18
|
+
const sseRoom = createSSERoom({
|
|
19
|
+
retryDuration: 2000,
|
|
20
|
+
historyLength: 100,
|
|
21
|
+
welcomeEventEnabled: true,
|
|
22
|
+
effect: () => {
|
|
23
|
+
return serverEventCallbackList.add((event) => {
|
|
24
|
+
sseRoom.sendEvent(event)
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
const removeSSECleanupCallback = destroyCallbackList.add(() => {
|
|
29
|
+
removeSSECleanupCallback()
|
|
30
|
+
sseRoom.close()
|
|
31
|
+
})
|
|
32
|
+
cache.push({
|
|
33
|
+
htmlFileRelativeUrl,
|
|
34
|
+
sseRoom,
|
|
35
|
+
cleanup: () => {
|
|
36
|
+
removeSSECleanupCallback()
|
|
37
|
+
sseRoom.close()
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
if (cache.length >= sseRoomLimit) {
|
|
41
|
+
const firstCacheEntry = cache.shift()
|
|
42
|
+
firstCacheEntry.cleanup()
|
|
43
|
+
}
|
|
44
|
+
return sseRoom
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
getOrCreateSSERoom,
|
|
49
|
+
destroy: () => {
|
|
50
|
+
destroyCallbackList.notify()
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url"
|
|
2
|
+
import { Worker, workerData } from "node:worker_threads"
|
|
3
|
+
|
|
4
|
+
// https://nodejs.org/api/worker_threads.html
|
|
5
|
+
export const createReloadableWorker = (workerFileUrl, options = {}) => {
|
|
6
|
+
const workerFilePath = fileURLToPath(workerFileUrl)
|
|
7
|
+
const isPrimary = !workerData || workerData.workerFilePath !== workerFilePath
|
|
8
|
+
let worker
|
|
9
|
+
|
|
10
|
+
const terminate = async () => {
|
|
11
|
+
if (worker) {
|
|
12
|
+
let _worker = worker
|
|
13
|
+
worker = null
|
|
14
|
+
const exitPromise = new Promise((resolve) => {
|
|
15
|
+
_worker.once("exit", resolve)
|
|
16
|
+
})
|
|
17
|
+
_worker.terminate()
|
|
18
|
+
await exitPromise
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const load = async () => {
|
|
23
|
+
if (!isPrimary) {
|
|
24
|
+
throw new Error(`worker can be loaded from primary file only`)
|
|
25
|
+
}
|
|
26
|
+
worker = new Worker(workerFilePath, {
|
|
27
|
+
...options,
|
|
28
|
+
workerData: {
|
|
29
|
+
...options.workerData,
|
|
30
|
+
workerFilePath,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
worker.once("error", (error) => {
|
|
35
|
+
console.error(error)
|
|
36
|
+
})
|
|
37
|
+
await new Promise((resolve) => {
|
|
38
|
+
worker.once("online", resolve)
|
|
39
|
+
})
|
|
40
|
+
worker.once("exit", () => {
|
|
41
|
+
worker = null
|
|
42
|
+
})
|
|
43
|
+
return worker
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const reload = async () => {
|
|
47
|
+
await terminate()
|
|
48
|
+
await load()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
isPrimary,
|
|
53
|
+
load,
|
|
54
|
+
reload,
|
|
55
|
+
terminate,
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/main.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// dev
|
|
2
|
+
export { startDevServer } from "./dev/start_dev_server.js"
|
|
3
|
+
// test
|
|
4
|
+
export {
|
|
5
|
+
executeTestPlan,
|
|
6
|
+
defaultCoverageConfig,
|
|
7
|
+
} from "./test/execute_test_plan.js"
|
|
8
|
+
export {
|
|
9
|
+
chromium,
|
|
10
|
+
chromiumIsolatedTab,
|
|
11
|
+
} from "./execute/runtimes/browsers/chromium.js"
|
|
12
|
+
export {
|
|
13
|
+
firefox,
|
|
14
|
+
firefoxIsolatedTab,
|
|
15
|
+
} from "./execute/runtimes/browsers/firefox.js"
|
|
16
|
+
export {
|
|
17
|
+
webkit,
|
|
18
|
+
webkitIsolatedTab,
|
|
19
|
+
} from "./execute/runtimes/browsers/webkit.js"
|
|
20
|
+
export { nodeProcess } from "./execute/runtimes/node/node_process.js"
|
|
21
|
+
// build
|
|
22
|
+
export { build } from "./build/build.js"
|
|
23
|
+
export { startBuildServer } from "./build/start_build_server.js"
|
|
24
|
+
|
|
25
|
+
// advanced
|
|
26
|
+
export { execute } from "./execute/execute.js"
|
|
27
|
+
export { jsenvPluginInjectGlobals } from "./plugins/inject_globals/jsenv_plugin_inject_globals.js"
|
|
@@ -9,6 +9,15 @@ export const featureCompats = {
|
|
|
9
9
|
android: "61",
|
|
10
10
|
samsung: "8.2",
|
|
11
11
|
},
|
|
12
|
+
document_current_script: {
|
|
13
|
+
edge: "12",
|
|
14
|
+
firefox: "4",
|
|
15
|
+
chrome: "29",
|
|
16
|
+
safari: "8",
|
|
17
|
+
opera: "16",
|
|
18
|
+
android: "4.4",
|
|
19
|
+
samsung: "4",
|
|
20
|
+
},
|
|
12
21
|
import_meta: {
|
|
13
22
|
chrome: "64",
|
|
14
23
|
edge: "79",
|
|
@@ -18,13 +27,16 @@ export const featureCompats = {
|
|
|
18
27
|
ios: "12",
|
|
19
28
|
android: "9",
|
|
20
29
|
},
|
|
30
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
|
|
21
31
|
import_dynamic: {
|
|
32
|
+
android: "8",
|
|
33
|
+
chrome: "63",
|
|
22
34
|
edge: "79",
|
|
23
35
|
firefox: "67",
|
|
24
|
-
|
|
25
|
-
safari: "11.3",
|
|
36
|
+
ios: "11.3",
|
|
26
37
|
opera: "50",
|
|
27
|
-
|
|
38
|
+
safari: "11.3",
|
|
39
|
+
samsung: "8.0",
|
|
28
40
|
node: "13.2",
|
|
29
41
|
},
|
|
30
42
|
top_level_await: {
|
|
@@ -71,6 +83,14 @@ export const featureCompats = {
|
|
|
71
83
|
ios: "5",
|
|
72
84
|
android: "4.4",
|
|
73
85
|
},
|
|
86
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker#browser_compatibility
|
|
87
|
+
worker_type_module: {
|
|
88
|
+
chrome: "80",
|
|
89
|
+
edge: "80",
|
|
90
|
+
opera: "67",
|
|
91
|
+
android: "80",
|
|
92
|
+
},
|
|
93
|
+
worker_importmap: {},
|
|
74
94
|
service_worker: {
|
|
75
95
|
edge: "17",
|
|
76
96
|
firefox: "44",
|
|
@@ -86,14 +106,17 @@ export const featureCompats = {
|
|
|
86
106
|
opera: "67",
|
|
87
107
|
android: "80",
|
|
88
108
|
},
|
|
89
|
-
|
|
90
|
-
|
|
109
|
+
shared_worker: {
|
|
110
|
+
chrome: "4",
|
|
111
|
+
edge: "79",
|
|
112
|
+
firefox: "29",
|
|
113
|
+
opera: "10.6",
|
|
114
|
+
},
|
|
115
|
+
shared_worker_type_module: {
|
|
91
116
|
chrome: "80",
|
|
92
117
|
edge: "80",
|
|
93
118
|
opera: "67",
|
|
94
|
-
android: "80",
|
|
95
119
|
},
|
|
96
|
-
worker_importmap: {},
|
|
97
120
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
|
|
98
121
|
global_this: {
|
|
99
122
|
edge: "79",
|