@jsenv/core 40.1.6 → 40.1.7

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.
@@ -8122,7 +8122,7 @@ const jsenvPluginChromeDevtoolsJson = () => {
8122
8122
  appliesDuring: "dev",
8123
8123
  devServerRoutes: [
8124
8124
  {
8125
- route: "GET /.well-known/appspecific/com.chrome.devtools.json",
8125
+ endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
8126
8126
  fetch: (request, { kitchen }) => {
8127
8127
  const { rootDirectoryUrl } = kitchen.context;
8128
8128
  return Response.json({
@@ -8137,6 +8137,39 @@ const jsenvPluginChromeDevtoolsJson = () => {
8137
8137
  };
8138
8138
  };
8139
8139
 
8140
+ const jsenvPluginAutoreloadOnServerRestart = () => {
8141
+ const autoreloadOnRestartClientFileUrl = import.meta.resolve(
8142
+ "@jsenv/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js",
8143
+ );
8144
+
8145
+ return {
8146
+ name: "jsenv:autoreload_on_server_restart",
8147
+ appliesDuring: "dev",
8148
+ transformUrlContent: {
8149
+ html: (urlInfo) => {
8150
+ // we should not do this for inspector and 4xx.html
8151
+ const htmlAst = parseHtml({
8152
+ html: urlInfo.content,
8153
+ url: urlInfo.url,
8154
+ });
8155
+ const autoreloadOnRestartClientFileReference =
8156
+ urlInfo.dependencies.inject({
8157
+ type: "script",
8158
+ subtype: "js_classic",
8159
+ expectedType: "js_classic",
8160
+ specifier: autoreloadOnRestartClientFileUrl,
8161
+ });
8162
+ injectJsenvScript(htmlAst, {
8163
+ "src": autoreloadOnRestartClientFileReference.generatedSpecifier,
8164
+ "pluginName": "jsenv:autoreload_on_server_restart",
8165
+ "data-ws-endpoint": "/.internal/events.websocket",
8166
+ });
8167
+ return stringifyHtmlAst(htmlAst);
8168
+ },
8169
+ },
8170
+ };
8171
+ };
8172
+
8140
8173
  // tslint:disable:ordered-imports
8141
8174
 
8142
8175
 
@@ -8229,6 +8262,7 @@ const getCorePlugins = ({
8229
8262
 
8230
8263
  // "jsenvPluginSupervisor" MUST be after "jsenvPluginInlining" as it needs inline script to be cooked
8231
8264
  ...(supervisor ? [jsenvPluginSupervisor(supervisor)] : []),
8265
+ jsenvPluginAutoreloadOnServerRestart(),
8232
8266
 
8233
8267
  jsenvPluginCommonJsGlobals(),
8234
8268
  jsenvPluginImportMetaScenarios(),
@@ -8163,7 +8163,7 @@ const jsenvPluginChromeDevtoolsJson = () => {
8163
8163
  appliesDuring: "dev",
8164
8164
  devServerRoutes: [
8165
8165
  {
8166
- route: "GET /.well-known/appspecific/com.chrome.devtools.json",
8166
+ endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
8167
8167
  fetch: (request, { kitchen }) => {
8168
8168
  const { rootDirectoryUrl } = kitchen.context;
8169
8169
  return Response.json({
@@ -8178,6 +8178,39 @@ const jsenvPluginChromeDevtoolsJson = () => {
8178
8178
  };
8179
8179
  };
8180
8180
 
8181
+ const jsenvPluginAutoreloadOnServerRestart = () => {
8182
+ const autoreloadOnRestartClientFileUrl = import.meta.resolve(
8183
+ "@jsenv/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js",
8184
+ );
8185
+
8186
+ return {
8187
+ name: "jsenv:autoreload_on_server_restart",
8188
+ appliesDuring: "dev",
8189
+ transformUrlContent: {
8190
+ html: (urlInfo) => {
8191
+ // we should not do this for inspector and 4xx.html
8192
+ const htmlAst = parseHtml({
8193
+ html: urlInfo.content,
8194
+ url: urlInfo.url,
8195
+ });
8196
+ const autoreloadOnRestartClientFileReference =
8197
+ urlInfo.dependencies.inject({
8198
+ type: "script",
8199
+ subtype: "js_classic",
8200
+ expectedType: "js_classic",
8201
+ specifier: autoreloadOnRestartClientFileUrl,
8202
+ });
8203
+ injectJsenvScript(htmlAst, {
8204
+ "src": autoreloadOnRestartClientFileReference.generatedSpecifier,
8205
+ "pluginName": "jsenv:autoreload_on_server_restart",
8206
+ "data-ws-endpoint": "/.internal/events.websocket",
8207
+ });
8208
+ return stringifyHtmlAst(htmlAst);
8209
+ },
8210
+ },
8211
+ };
8212
+ };
8213
+
8181
8214
  // tslint:disable:ordered-imports
8182
8215
 
8183
8216
 
@@ -8270,6 +8303,7 @@ const getCorePlugins = ({
8270
8303
 
8271
8304
  // "jsenvPluginSupervisor" MUST be after "jsenvPluginInlining" as it needs inline script to be cooked
8272
8305
  ...(supervisor ? [jsenvPluginSupervisor(supervisor)] : []),
8306
+ jsenvPluginAutoreloadOnServerRestart(),
8273
8307
 
8274
8308
  jsenvPluginCommonJsGlobals(),
8275
8309
  jsenvPluginImportMetaScenarios(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "40.1.6",
3
+ "version": "40.1.7",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -90,7 +90,7 @@
90
90
  "@jsenv/plugin-minification": "1.6.2",
91
91
  "@jsenv/plugin-supervisor": "1.6.12",
92
92
  "@jsenv/plugin-transpilation": "1.5.9",
93
- "@jsenv/server": "16.0.6",
93
+ "@jsenv/server": "16.0.7",
94
94
  "@jsenv/sourcemap": "1.3.4",
95
95
  "@jsenv/url-meta": "8.5.6",
96
96
  "@jsenv/urls": "2.7.1",
@@ -0,0 +1,34 @@
1
+ import { injectJsenvScript, parseHtml, stringifyHtmlAst } from "@jsenv/ast";
2
+
3
+ export const jsenvPluginAutoreloadOnServerRestart = () => {
4
+ const autoreloadOnRestartClientFileUrl = import.meta.resolve(
5
+ "@jsenv/server/src/services/autoreload_on_server_restart/client/autoreload_on_server_restart.js",
6
+ );
7
+
8
+ return {
9
+ name: "jsenv:autoreload_on_server_restart",
10
+ appliesDuring: "dev",
11
+ transformUrlContent: {
12
+ html: (urlInfo) => {
13
+ // we should not do this for inspector and 4xx.html
14
+ const htmlAst = parseHtml({
15
+ html: urlInfo.content,
16
+ url: urlInfo.url,
17
+ });
18
+ const autoreloadOnRestartClientFileReference =
19
+ urlInfo.dependencies.inject({
20
+ type: "script",
21
+ subtype: "js_classic",
22
+ expectedType: "js_classic",
23
+ specifier: autoreloadOnRestartClientFileUrl,
24
+ });
25
+ injectJsenvScript(htmlAst, {
26
+ "src": autoreloadOnRestartClientFileReference.generatedSpecifier,
27
+ "pluginName": "jsenv:autoreload_on_server_restart",
28
+ "data-ws-endpoint": "/.internal/events.websocket",
29
+ });
30
+ return stringifyHtmlAst(htmlAst);
31
+ },
32
+ },
33
+ };
34
+ };
@@ -27,7 +27,7 @@ export const jsenvPluginChromeDevtoolsJson = () => {
27
27
  appliesDuring: "dev",
28
28
  devServerRoutes: [
29
29
  {
30
- route: "GET /.well-known/appspecific/com.chrome.devtools.json",
30
+ endpoint: "GET /.well-known/appspecific/com.chrome.devtools.json",
31
31
  fetch: (request, { kitchen }) => {
32
32
  const { rootDirectoryUrl } = kitchen.context;
33
33
  return Response.json({
@@ -24,6 +24,7 @@ import { jsenvPluginCacheControl } from "./cache_control/jsenv_plugin_cache_cont
24
24
  import { jsenvPluginRibbon } from "./ribbon/jsenv_plugin_ribbon.js";
25
25
  import { jsenvPluginCleanHTML } from "./clean_html/jsenv_plugin_clean_html.js";
26
26
  import { jsenvPluginChromeDevtoolsJson } from "./chrome_devtools_json/jsenv_plugin_chrome_devtools_json.js";
27
+ import { jsenvPluginAutoreloadOnServerRestart } from "./autoreload_on_server_restart/jsenv_plugin_autoreload_on_server_restart.js";
27
28
 
28
29
  export const getCorePlugins = ({
29
30
  rootDirectoryUrl,
@@ -114,6 +115,7 @@ export const getCorePlugins = ({
114
115
 
115
116
  // "jsenvPluginSupervisor" MUST be after "jsenvPluginInlining" as it needs inline script to be cooked
116
117
  ...(supervisor ? [jsenvPluginSupervisor(supervisor)] : []),
118
+ jsenvPluginAutoreloadOnServerRestart(),
117
119
 
118
120
  jsenvPluginCommonJsGlobals(),
119
121
  jsenvPluginImportMetaScenarios(),