@jsenv/core 27.3.3 → 27.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/js/autoreload.js +359 -0
  2. package/dist/js/execute_using_dynamic_import.js +1 -1
  3. package/dist/js/html_supervisor_installer.js +524 -147
  4. package/dist/js/html_supervisor_setup.js +3 -4
  5. package/dist/js/new_stylesheet.js +26 -58
  6. package/dist/js/server_events_client.js +307 -0
  7. package/dist/main.js +7699 -7307
  8. package/package.json +15 -15
  9. package/{README.md → readme.md} +18 -7
  10. package/src/build/build.js +16 -18
  11. package/src/build/start_build_server.js +24 -28
  12. package/src/dev/start_dev_server.js +30 -94
  13. package/src/execute/execute.js +17 -35
  14. package/src/execute/run.js +2 -0
  15. package/src/omega/errors.js +43 -9
  16. package/src/omega/kitchen.js +42 -25
  17. package/src/omega/omega_server.js +96 -74
  18. package/src/omega/server/file_service.js +256 -28
  19. package/src/omega/url_graph.js +39 -20
  20. package/src/plugins/autoreload/client/autoreload.js +201 -0
  21. package/src/plugins/autoreload/{dev_sse/client → client}/autoreload_preference.js +0 -0
  22. package/src/plugins/autoreload/{dev_sse/client → client}/reload.js +29 -10
  23. package/src/plugins/autoreload/{dev_sse/client → client}/url_helpers.js +0 -0
  24. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +4 -8
  25. package/src/plugins/autoreload/{dev_sse/jsenv_plugin_dev_sse_client.js → jsenv_plugin_autoreload_client.js} +8 -8
  26. package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +196 -0
  27. package/src/{dev/plugins → plugins}/explorer/client/explorer.html +0 -0
  28. package/src/{dev/plugins → plugins}/explorer/client/jsenv.png +0 -0
  29. package/src/{dev/plugins → plugins}/explorer/jsenv_plugin_explorer.js +1 -3
  30. package/src/plugins/html_supervisor/client/error_overlay.js +401 -0
  31. package/src/plugins/html_supervisor/client/html_supervisor_installer.js +138 -23
  32. package/src/plugins/html_supervisor/client/html_supervisor_setup.js +3 -4
  33. package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +55 -23
  34. package/src/plugins/inline/jsenv_plugin_html_inline_content.js +97 -117
  35. package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +66 -58
  36. package/src/plugins/plugin_controller.js +102 -67
  37. package/src/plugins/plugins.js +10 -10
  38. package/src/{helpers/event_source/event_source.js → plugins/server_events/client/event_source_connection.js} +125 -33
  39. package/src/plugins/server_events/client/server_events_client.js +17 -0
  40. package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +48 -0
  41. package/src/plugins/server_events/server_events_dispatcher.js +69 -0
  42. package/src/{dev/plugins → plugins}/toolbar/client/animation/toolbar_animation.js +0 -0
  43. package/src/{dev/plugins → plugins}/toolbar/client/eventsource/eventsource.css +0 -0
  44. package/src/{dev/plugins → plugins}/toolbar/client/eventsource/toolbar_eventsource.js +0 -0
  45. package/src/{dev/plugins → plugins}/toolbar/client/execution/execution.css +0 -0
  46. package/src/{dev/plugins → plugins}/toolbar/client/execution/toolbar_execution.js +0 -0
  47. package/src/{dev/plugins → plugins}/toolbar/client/focus/focus.css +0 -0
  48. package/src/{dev/plugins → plugins}/toolbar/client/focus/toolbar_focus.js +0 -0
  49. package/src/{dev/plugins → plugins}/toolbar/client/jsenv_logo.svg +0 -0
  50. package/src/{dev/plugins → plugins}/toolbar/client/notification/toolbar_notification.js +0 -0
  51. package/src/{dev/plugins → plugins}/toolbar/client/responsive/overflow_menu.css +0 -0
  52. package/src/{dev/plugins → plugins}/toolbar/client/responsive/toolbar_responsive.js +0 -0
  53. package/src/{dev/plugins → plugins}/toolbar/client/settings/settings.css +0 -0
  54. package/src/{dev/plugins → plugins}/toolbar/client/settings/toolbar_settings.js +0 -0
  55. package/src/{dev/plugins → plugins}/toolbar/client/theme/jsenv_theme.css +0 -0
  56. package/src/{dev/plugins → plugins}/toolbar/client/theme/light_theme.css +0 -0
  57. package/src/{dev/plugins → plugins}/toolbar/client/theme/toolbar_theme.js +0 -0
  58. package/src/{dev/plugins → plugins}/toolbar/client/toolbar.html +0 -0
  59. package/src/{dev/plugins → plugins}/toolbar/client/toolbar_injector.js +0 -0
  60. package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.css +0 -0
  61. package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.js +0 -0
  62. package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.css +0 -0
  63. package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.js +0 -0
  64. package/src/{dev/plugins → plugins}/toolbar/client/util/animation.js +0 -0
  65. package/src/{dev/plugins → plugins}/toolbar/client/util/dom.js +0 -0
  66. package/src/{dev/plugins → plugins}/toolbar/client/util/fetch_using_xhr.js +0 -0
  67. package/src/{dev/plugins → plugins}/toolbar/client/util/fetching.js +0 -0
  68. package/src/{dev/plugins → plugins}/toolbar/client/util/iframe_to_parent_href.js +0 -0
  69. package/src/{dev/plugins → plugins}/toolbar/client/util/jsenv_logger.js +0 -0
  70. package/src/{dev/plugins → plugins}/toolbar/client/util/preferences.js +0 -0
  71. package/src/{dev/plugins → plugins}/toolbar/client/util/responsive.js +0 -0
  72. package/src/{dev/plugins → plugins}/toolbar/client/util/util.js +0 -0
  73. package/src/{dev/plugins → plugins}/toolbar/client/variant/variant.js +0 -0
  74. package/src/{dev/plugins → plugins}/toolbar/jsenv_plugin_toolbar.js +0 -0
  75. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +4 -3
  76. package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +25 -55
  77. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +44 -24
  78. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +6 -1
  79. package/src/plugins/url_analysis/html/html_urls.js +8 -8
  80. package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +3 -1
  81. package/src/test/execute_plan.js +36 -54
  82. package/src/test/execute_test_plan.js +2 -2
  83. package/src/test/logs_file_execution.js +60 -27
  84. package/src/test/logs_file_execution.test.mjs +41 -0
  85. package/dist/js/event_source_client.js +0 -528
  86. package/src/helpers/event_source/sse_service.js +0 -53
  87. package/src/plugins/autoreload/dev_sse/client/event_source_client.js +0 -193
  88. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +0 -203
  89. package/src/plugins/html_supervisor/client/error_in_document.js +0 -198
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.3.3",
3
+ "version": "27.5.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -43,7 +43,6 @@
43
43
  "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
44
44
  "dev": "node --conditions=development ./scripts/dev/dev.mjs",
45
45
  "test": "node --conditions=development ./scripts/test/test.mjs",
46
- "test:coverage": "cross-env NODE_V8_COVERAGE=.coverage/node npm run test -- --coverage",
47
46
  "test:workspace": "npm run test --workspaces --if-present -- --workspace",
48
47
  "build": "node --conditions=development ./scripts/build/build.mjs",
49
48
  "workspace:versions": "node ./scripts/publish/workspace_versions.mjs",
@@ -66,31 +65,33 @@
66
65
  "@c88/v8-coverage": "0.1.1",
67
66
  "@financial-times/polyfill-useragent-normaliser": "2.0.1",
68
67
  "@jsenv/abort": "4.2.3",
69
- "@jsenv/ast": "1.1.2",
68
+ "@jsenv/ast": "1.1.3",
70
69
  "@jsenv/babel-plugins": "1.0.6",
71
- "@jsenv/filesystem": "4.1.0",
70
+ "@jsenv/filesystem": "4.1.1",
72
71
  "@jsenv/importmap": "1.2.1",
73
72
  "@jsenv/integrity": "0.0.1",
74
73
  "@jsenv/log": "3.1.0",
75
74
  "@jsenv/node-esm-resolution": "0.1.0",
76
- "@jsenv/server": "12.8.0",
77
- "@jsenv/sourcemap": "1.0.1",
75
+ "@jsenv/server": "13.0.0",
76
+ "@jsenv/sourcemap": "1.0.2",
78
77
  "@jsenv/uneval": "1.6.0",
79
78
  "@jsenv/url-meta": "7.0.0",
80
- "@jsenv/urls": "1.2.6",
79
+ "@jsenv/urls": "1.2.7",
81
80
  "@jsenv/utils": "2.0.1",
82
81
  "acorn-import-assertions": "1.8.0",
82
+ "construct-style-sheets-polyfill": "3.1.0",
83
83
  "cuid": "2.1.8",
84
84
  "html-minifier": "4.0.0",
85
85
  "istanbul-lib-coverage": "3.2.0",
86
86
  "istanbul-lib-instrument": "5.2.0",
87
87
  "istanbul-lib-report": "3.0.0",
88
- "istanbul-reports": "3.1.4",
88
+ "istanbul-reports": "3.1.5",
89
+ "launch-editor": "2.4.0",
89
90
  "pidtree": "0.6.0",
90
- "rollup": "2.76.0",
91
+ "rollup": "2.77.0",
91
92
  "string-width": "5.1.2",
92
93
  "strip-ansi": "7.0.1",
93
- "terser": "5.14.1",
94
+ "terser": "5.14.2",
94
95
  "v8-to-istanbul": "9.0.1",
95
96
  "wrap-ansi": "8.0.1"
96
97
  },
@@ -98,17 +99,16 @@
98
99
  "@babel/eslint-parser": "7.18.2",
99
100
  "@babel/plugin-syntax-import-assertions": "7.18.6",
100
101
  "@jsenv/assert": "2.6.0",
101
- "@jsenv/eslint-config": "16.1.0",
102
+ "@jsenv/eslint-config": "16.2.1",
102
103
  "@jsenv/file-size-impact": "13.0.1",
103
104
  "@jsenv/https-local": "2.1.0",
104
105
  "@jsenv/package-workspace": "0.4.1",
105
106
  "@jsenv/performance-impact": "3.0.1",
106
- "cross-env": "7.0.3",
107
- "eslint": "8.19.0",
108
- "eslint-plugin-html": "6.2.0",
107
+ "eslint": "8.20.0",
108
+ "eslint-plugin-html": "7.0.0",
109
109
  "eslint-plugin-import": "2.26.0",
110
110
  "eslint-plugin-react": "7.30.1",
111
- "playwright": "1.23.2",
111
+ "playwright": "1.23.4",
112
112
  "prettier": "2.7.1"
113
113
  }
114
114
  }
@@ -1,21 +1,32 @@
1
1
  # @jsenv/core [![npm package](https://img.shields.io/npm/v/@jsenv/core.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/core)
2
2
 
3
- Jsenv was first created to write tests that could be executed in different runtimes. It has naturally evolved to cover the core needs of a JavaScript project.
3
+ Jsenv was first created to write tests that could be executed in different runtimes.
4
+ It has naturally evolved to cover the core needs of a JavaScript project: developement, testing and building for production.
4
5
 
5
- - :exploding_head: Directly execute HTML files as tests
6
- - :relieved: Consistent and integral developer experience (dev + test + build)
7
- - :relieved: Same dev experience for source and test files
6
+ - :exploding_head: Execute HTML files as tests
7
+ - :sparkles: A single tool for the whole developer experience
8
8
  - :ok_hand: Seamless integration with standard HTML, CSS and JS
9
9
 
10
10
  # Demo
11
11
 
12
- Run the following command to create a demo of a jsenv project on your machine.
12
+ The following command can be used to create a jsenv project on a machine.
13
13
 
14
14
  ```console
15
15
  npm create jsenv@latest
16
16
  ```
17
17
 
18
- > "web" demos are running tests in headless browsers. If you never have installed playwright on your machine npm install can take a bit of time.
18
+ This command prompts to choose a demo from a list.
19
+ Each demo contains preconfigured scripts such as:
20
+
21
+ - `npm run dev`: starts a dev server with autoreload.
22
+ - `npm run test`: execute test files on browsers(s) and/or Node.js.
23
+ - `npm run build`: generate files optimized for production.
24
+
25
+ > **Info**
26
+ > Executing "npm install" in web demos can take time.
27
+ > It is because in these demos tests are runned in headless browsers that needs to be installed first.
28
+
29
+ See also [packages/create-jsenv](./packages/create-jsenv).
19
30
 
20
31
  # Installation
21
32
 
@@ -23,7 +34,7 @@ npm create jsenv@latest
23
34
  npm install --save-dev @jsenv/core
24
35
  ```
25
36
 
26
- _@jsenv/core_ is tested on Mac, Windows, Linux on Node.js 18.5.0. Other operating systems and Node.js versions are not tested.
37
+ _@jsenv/core_ is tested on Mac, Windows, Linux with Node.js 18.5.0. Other operating systems and Node.js versions are not tested.
27
38
 
28
39
  # Documentation
29
40
 
@@ -102,7 +102,7 @@ export const build = async ({
102
102
  sourcemaps = false,
103
103
  sourcemapsSourcesContent,
104
104
  urlAnalysis = {},
105
- nodeEsmResolution,
105
+ nodeEsmResolution = true,
106
106
  fileSystemMagicResolution,
107
107
  directoryReferenceAllowed,
108
108
  transpilation = {},
@@ -228,7 +228,9 @@ build ${entryPointKeys.length} entry points`)
228
228
  startLoading: (cookEntryFile) => {
229
229
  Object.keys(entryPoints).forEach((key) => {
230
230
  const [, entryUrlInfo] = cookEntryFile({
231
- trace: `"${key}" in entryPoints parameter`,
231
+ trace: {
232
+ message: `"${key}" in entryPoints parameter`,
233
+ },
232
234
  type: "entry_point",
233
235
  specifier: key,
234
236
  })
@@ -415,8 +417,6 @@ build ${entryPointKeys.length} entry points`)
415
417
  })
416
418
  const postBuildRedirections = {}
417
419
  const finalGraph = createUrlGraph()
418
- const optimizeUrlContentHooks =
419
- rawGraphKitchen.pluginController.addHook("optimizeUrlContent")
420
420
  const finalGraphKitchen = createKitchen({
421
421
  logger,
422
422
  rootDirectoryUrl,
@@ -692,19 +692,17 @@ build ${entryPointKeys.length} entry points`)
692
692
  name: "jsenv:optimize",
693
693
  appliesDuring: "build",
694
694
  finalizeUrlContent: async (urlInfo, context) => {
695
- if (optimizeUrlContentHooks.length) {
696
- await rawGraphKitchen.pluginController.callAsyncHooks(
697
- "optimizeUrlContent",
698
- urlInfo,
699
- context,
700
- async (optimizeReturnValue) => {
701
- await finalGraphKitchen.urlInfoTransformer.applyFinalTransformations(
702
- urlInfo,
703
- optimizeReturnValue,
704
- )
705
- },
706
- )
707
- }
695
+ await rawGraphKitchen.pluginController.callAsyncHooks(
696
+ "optimizeUrlContent",
697
+ urlInfo,
698
+ context,
699
+ async (optimizeReturnValue) => {
700
+ await finalGraphKitchen.urlInfoTransformer.applyFinalTransformations(
701
+ urlInfo,
702
+ optimizeReturnValue,
703
+ )
704
+ },
705
+ )
708
706
  },
709
707
  },
710
708
  ],
@@ -722,7 +720,7 @@ build ${entryPointKeys.length} entry points`)
722
720
  startLoading: (cookEntryFile) => {
723
721
  entryUrls.forEach((entryUrl) => {
724
722
  const [, postBuildEntryUrlInfo] = cookEntryFile({
725
- trace: `entryPoint`,
723
+ trace: { message: `entryPoint` },
726
724
  type: "entry_point",
727
725
  specifier: entryUrl,
728
726
  })
@@ -17,12 +17,9 @@ import { parentPort } from "node:worker_threads"
17
17
  import {
18
18
  jsenvAccessControlAllowedHeaders,
19
19
  startServer,
20
- pluginServerTiming,
21
- pluginRequestWaitingCheck,
22
- pluginCORS,
23
20
  fetchFileSystem,
24
- composeServices,
25
- findFreePort,
21
+ jsenvServiceCORS,
22
+ jsenvServiceErrorHandler,
26
23
  } from "@jsenv/server"
27
24
  import {
28
25
  assertAndNormalizeDirectoryUrl,
@@ -43,10 +40,10 @@ export const startBuildServer = async ({
43
40
  http2,
44
41
  certificate,
45
42
  privateKey,
46
- listenAnyIp,
47
- ip,
43
+ acceptAnyIp,
44
+ host,
48
45
  port = 9779,
49
- services = {},
46
+ services = [],
50
47
  keepProcessAlive = true,
51
48
 
52
49
  rootDirectoryUrl,
@@ -94,9 +91,6 @@ export const startBuildServer = async ({
94
91
  )
95
92
  })
96
93
  }
97
- if (port === 0) {
98
- port = await findFreePort(port, { signal: operation.signal })
99
- }
100
94
 
101
95
  let reloadableWorker
102
96
  if (buildServerAutoreload) {
@@ -137,12 +131,12 @@ export const startBuildServer = async ({
137
131
  const messagePromise = new Promise((resolve) => {
138
132
  worker.once("message", resolve)
139
133
  })
140
- await messagePromise
134
+ const origin = await messagePromise
141
135
  // if (!keepProcessAlive) {
142
136
  // worker.unref()
143
137
  // }
144
138
  return {
145
- origin: `${protocol}://127.0.0.1:${port}`,
139
+ origin,
146
140
  stop: () => {
147
141
  stopWatchingBuildServerFiles()
148
142
  reloadableWorker.terminate()
@@ -168,30 +162,32 @@ export const startBuildServer = async ({
168
162
  http2,
169
163
  certificate,
170
164
  privateKey,
171
- listenAnyIp,
172
- ip,
165
+ acceptAnyIp,
166
+ host,
173
167
  port,
174
- plugins: {
175
- ...pluginCORS({
168
+ serverTiming: true,
169
+ requestWaitingMs: 60_000,
170
+ services: [
171
+ jsenvServiceCORS({
176
172
  accessControlAllowRequestOrigin: true,
177
173
  accessControlAllowRequestMethod: true,
178
174
  accessControlAllowRequestHeaders: true,
179
175
  accessControlAllowedRequestHeaders: jsenvAccessControlAllowedHeaders,
180
176
  accessControlAllowCredentials: true,
177
+ timingAllowOrigin: true,
181
178
  }),
182
- ...pluginServerTiming(),
183
- ...pluginRequestWaitingCheck({
184
- requestWaitingMs: 60 * 1000,
185
- }),
186
- },
187
- sendErrorDetails: true,
188
- requestToResponse: composeServices({
189
179
  ...services,
190
- build_files_service: createBuildFilesService({
191
- buildDirectoryUrl,
192
- buildIndexPath,
180
+ {
181
+ name: "jsenv:build_files_service",
182
+ handleRequest: createBuildFilesService({
183
+ buildDirectoryUrl,
184
+ buildIndexPath,
185
+ }),
186
+ },
187
+ jsenvServiceErrorHandler({
188
+ sendErrorDetails: true,
193
189
  }),
194
- }),
190
+ ],
195
191
  })
196
192
  startBuildServerTask.done()
197
193
  logger.info(``)
@@ -1,5 +1,4 @@
1
1
  import { parentPort } from "node:worker_threads"
2
- import { findFreePort } from "@jsenv/server"
3
2
  import {
4
3
  assertAndNormalizeDirectoryUrl,
5
4
  registerDirectoryLifecycle,
@@ -9,14 +8,8 @@ import { createLogger, loggerToLevels, createTaskLog } from "@jsenv/log"
9
8
  import { getCallerPosition } from "@jsenv/urls"
10
9
 
11
10
  import { createReloadableWorker } from "@jsenv/core/src/helpers/worker_reload.js"
12
- import { getCorePlugins } from "@jsenv/core/src/plugins/plugins.js"
13
- import { createUrlGraph } from "@jsenv/core/src/omega/url_graph.js"
14
- import { createKitchen } from "@jsenv/core/src/omega/kitchen.js"
15
11
  import { startOmegaServer } from "@jsenv/core/src/omega/omega_server.js"
16
12
 
17
- import { jsenvPluginExplorer } from "./plugins/explorer/jsenv_plugin_explorer.js"
18
- // import { jsenvPluginToolbar } from "./plugins/toolbar/jsenv_plugin_toolbar.js"
19
-
20
13
  export const startDevServer = async ({
21
14
  signal = new AbortController().signal,
22
15
  handleSIGINT = true,
@@ -24,14 +17,14 @@ export const startDevServer = async ({
24
17
  omegaServerLogLevel = "warn",
25
18
  port = 3456,
26
19
  protocol = "http",
27
- listenAnyIp,
20
+ acceptAnyIp,
28
21
  // it's better to use http1 by default because it allows to get statusText in devtools
29
22
  // which gives valuable information when there is errors
30
23
  http2 = false,
31
24
  certificate,
32
25
  privateKey,
33
26
  keepProcessAlive = true,
34
- serverPlugins,
27
+ services,
35
28
 
36
29
  rootDirectoryUrl,
37
30
  clientFiles = {
@@ -47,7 +40,6 @@ export const startDevServer = async ({
47
40
  devServerMainFile = getCallerPosition().url,
48
41
  cooldownBetweenFileEvents,
49
42
 
50
- sourcemaps = "inline",
51
43
  // default runtimeCompat assume dev server will be request by recent browsers
52
44
  // Used by "jsenv_plugin_node_runtime.js" to deactivate itself
53
45
  // If dev server can be requested by Node.js to exec files
@@ -64,16 +56,19 @@ export const startDevServer = async ({
64
56
  nodeEsmResolution,
65
57
  fileSystemMagicResolution,
66
58
  transpilation,
67
- explorerGroups = {
68
- source: {
69
- "./*.html": true,
70
- "./src/**/*.html": true,
71
- },
72
- test: {
73
- "./tests/**/*.test.html": true,
59
+ explorer = {
60
+ groups: {
61
+ src: {
62
+ "./src/**/*.html": true,
63
+ },
64
+ tests: {
65
+ "./tests/**/*.test.html": true,
66
+ },
74
67
  },
75
68
  },
76
69
  // toolbar = false,
70
+
71
+ sourcemaps = "inline",
77
72
  writeGeneratedFiles = true,
78
73
  }) => {
79
74
  const logger = createLogger({ logLevel })
@@ -90,9 +85,6 @@ export const startDevServer = async ({
90
85
  )
91
86
  })
92
87
  }
93
- if (port === 0) {
94
- port = await findFreePort(port, { signal: operation.signal })
95
- }
96
88
 
97
89
  let reloadableWorker
98
90
  if (devServerAutoreload) {
@@ -134,12 +126,12 @@ export const startDevServer = async ({
134
126
  const messagePromise = new Promise((resolve) => {
135
127
  worker.once("message", resolve)
136
128
  })
137
- await messagePromise
129
+ const origin = await messagePromise
138
130
  // if (!keepProcessAlive) {
139
131
  // worker.unref()
140
132
  // }
141
133
  return {
142
- origin: `${protocol}://127.0.0.1:${port}`,
134
+ origin,
143
135
  stop: () => {
144
136
  stopWatchingDevServerFiles()
145
137
  reloadableWorker.terminate()
@@ -152,82 +144,32 @@ export const startDevServer = async ({
152
144
  disabled: !loggerToLevels(logger).info,
153
145
  })
154
146
 
155
- const clientFileChangeCallbackList = []
156
- const clientFilesPruneCallbackList = []
157
- const clientFileChangeCallback = ({ relativeUrl, event }) => {
158
- const url = new URL(relativeUrl, rootDirectoryUrl).href
159
- clientFileChangeCallbackList.forEach((callback) => {
160
- callback({ url, event })
161
- })
162
- }
163
- const stopWatchingClientFiles = registerDirectoryLifecycle(rootDirectoryUrl, {
164
- watchPatterns: {
165
- ...clientFiles,
166
- ".jsenv/": false,
167
- },
168
- cooldownBetweenFileEvents,
169
- keepProcessAlive: false,
170
- recursive: true,
171
- added: ({ relativeUrl }) => {
172
- clientFileChangeCallback({ event: "added", relativeUrl })
173
- },
174
- updated: ({ relativeUrl }) => {
175
- clientFileChangeCallback({ event: "modified", relativeUrl })
176
- },
177
- removed: ({ relativeUrl }) => {
178
- clientFileChangeCallback({ event: "removed", relativeUrl })
179
- },
180
- })
181
- const urlGraph = createUrlGraph({
182
- clientFileChangeCallbackList,
183
- clientFilesPruneCallbackList,
184
- })
185
- const kitchen = createKitchen({
186
- signal,
187
- logger,
188
- rootDirectoryUrl,
189
- urlGraph,
190
- scenario: "dev",
191
- runtimeCompat,
192
- sourcemaps,
193
- writeGeneratedFiles,
194
- plugins: [
195
- ...plugins,
196
- ...getCorePlugins({
197
- rootDirectoryUrl,
198
- urlGraph,
199
- scenario: "dev",
200
- runtimeCompat,
201
-
202
- urlAnalysis,
203
- htmlSupervisor,
204
- nodeEsmResolution,
205
- fileSystemMagicResolution,
206
- transpilation,
207
- clientAutoreload,
208
- clientFileChangeCallbackList,
209
- clientFilesPruneCallbackList,
210
- }),
211
- jsenvPluginExplorer({
212
- groups: explorerGroups,
213
- }),
214
- // ...(toolbar ? [jsenvPluginToolbar(toolbar)] : []),
215
- ],
216
- })
217
147
  const server = await startOmegaServer({
218
148
  logLevel: omegaServerLogLevel,
219
149
  keepProcessAlive,
220
- listenAnyIp,
150
+ acceptAnyIp,
221
151
  port,
222
152
  protocol,
223
153
  http2,
224
154
  certificate,
225
155
  privateKey,
156
+ services,
157
+
226
158
  rootDirectoryUrl,
227
- urlGraph,
228
- kitchen,
229
159
  scenario: "dev",
230
- serverPlugins,
160
+ runtimeCompat,
161
+ plugins,
162
+ urlAnalysis,
163
+ htmlSupervisor,
164
+ nodeEsmResolution,
165
+ fileSystemMagicResolution,
166
+ transpilation,
167
+ clientFiles,
168
+ clientAutoreload,
169
+ cooldownBetweenFileEvents,
170
+ explorer,
171
+ sourcemaps,
172
+ writeGeneratedFiles,
231
173
  })
232
174
  startDevServerTask.done()
233
175
  logger.info(``)
@@ -235,18 +177,12 @@ export const startDevServer = async ({
235
177
  logger.info(`- ${server.origins[key]}`)
236
178
  })
237
179
  logger.info(``)
238
- server.addEffect(() => {
239
- return () => {
240
- kitchen.pluginController.callHooks("destroy", {})
241
- }
242
- })
243
180
  if (reloadableWorker && reloadableWorker.isWorker) {
244
181
  parentPort.postMessage(server.origin)
245
182
  }
246
183
  return {
247
184
  origin: server.origin,
248
185
  stop: () => {
249
- stopWatchingClientFiles()
250
186
  server.stop()
251
187
  },
252
188
  }
@@ -2,11 +2,8 @@ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
2
2
 
3
3
  import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem"
4
4
  import { createLogger } from "@jsenv/log"
5
- import { getCorePlugins } from "@jsenv/core/src/plugins/plugins.js"
6
- import { createUrlGraph } from "@jsenv/core/src/omega/url_graph.js"
7
- import { createKitchen } from "@jsenv/core/src/omega/kitchen.js"
8
- import { startOmegaServer } from "@jsenv/core/src/omega/omega_server.js"
9
5
 
6
+ import { startOmegaServer } from "@jsenv/core/src/omega/omega_server.js"
10
7
  import { run } from "./run.js"
11
8
 
12
9
  export const execute = async ({
@@ -19,6 +16,7 @@ export const execute = async ({
19
16
  allocatedMs,
20
17
  mirrorConsole = true,
21
18
  keepRunning = false,
19
+ services,
22
20
  collectConsole,
23
21
  collectCoverage,
24
22
  coverageTempDirectoryUrl,
@@ -27,12 +25,12 @@ export const execute = async ({
27
25
  runtimeParams,
28
26
 
29
27
  scenario = "dev",
30
- sourcemaps = "inline",
31
28
  plugins = [],
32
29
  nodeEsmResolution,
33
30
  fileSystemMagicResolution,
34
31
  transpilation,
35
32
  htmlSupervisor = true,
33
+ sourcemaps = "inline",
36
34
  writeGeneratedFiles = false,
37
35
 
38
36
  port,
@@ -65,45 +63,29 @@ export const execute = async ({
65
63
  ...runtimeParams,
66
64
  }
67
65
  if (runtime.needsServer) {
68
- const urlGraph = createUrlGraph()
69
- const runtimeCompat = { [runtime.name]: runtime.version }
70
- const kitchen = createKitchen({
71
- signal,
72
- logger,
73
- rootDirectoryUrl,
74
- urlGraph,
75
- scenario,
76
- sourcemaps,
77
- runtimeCompat,
78
- writeGeneratedFiles,
79
- plugins: [
80
- ...plugins,
81
- ...getCorePlugins({
82
- rootDirectoryUrl,
83
- urlGraph,
84
- scenario,
85
- runtimeCompat,
86
-
87
- htmlSupervisor,
88
- nodeEsmResolution,
89
- fileSystemMagicResolution,
90
- transpilation,
91
- }),
92
- ],
93
- })
94
66
  const server = await startOmegaServer({
95
67
  signal: executeOperation.signal,
96
68
  logLevel: "warn",
97
- rootDirectoryUrl,
98
- urlGraph,
99
- kitchen,
100
- scenario,
101
69
  keepProcessAlive: false,
70
+ services,
102
71
  port,
103
72
  protocol,
104
73
  http2,
105
74
  certificate,
106
75
  privateKey,
76
+
77
+ rootDirectoryUrl,
78
+ scenario,
79
+ runtimeCompat: { [runtime.name]: runtime.version },
80
+
81
+ plugins,
82
+
83
+ htmlSupervisor,
84
+ nodeEsmResolution,
85
+ fileSystemMagicResolution,
86
+ transpilation,
87
+ sourcemaps,
88
+ writeGeneratedFiles,
107
89
  })
108
90
  executeOperation.addEndCallback(async () => {
109
91
  await server.stop("execution done")
@@ -40,12 +40,14 @@ export const run = async ({
40
40
  timeoutAbortSource.signal.aborted
41
41
  ) {
42
42
  result.status = "timedout"
43
+ delete result.error
43
44
  }
44
45
  })
45
46
  }
46
47
  callbacks.push(() => {
47
48
  if (result.status === "errored" && Abort.isAbortError(result.error)) {
48
49
  result.status = "aborted"
50
+ delete result.error
49
51
  }
50
52
  })
51
53
  const consoleCalls = []