@jsenv/plugin-supervisor 1.1.0 → 1.2.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.
- package/dist/js/supervisor.js +1088 -0
- package/dist/jsenv_plugin_supervisor.js +1185 -0
- package/package.json +6 -5
- package/src/client/supervisor.js +3 -3
- package/src/jsenv_plugin_supervisor.js +24 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-supervisor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"main": "./src/main.js",
|
|
24
24
|
"files": [
|
|
25
|
-
"/src/"
|
|
25
|
+
"/src/",
|
|
26
|
+
"/dist/"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@jsenv/ast": "
|
|
29
|
-
"@jsenv/urls": "2.
|
|
30
|
-
"@jsenv/sourcemap": "1.0
|
|
29
|
+
"@jsenv/ast": "5.0.0",
|
|
30
|
+
"@jsenv/urls": "2.1.0",
|
|
31
|
+
"@jsenv/sourcemap": "1.1.0",
|
|
31
32
|
"launch-editor": "2.6.0"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
package/src/client/supervisor.js
CHANGED
|
@@ -149,7 +149,7 @@ window.__supervisor__ = (() => {
|
|
|
149
149
|
start();
|
|
150
150
|
currentScriptClone = prepareScriptToLoad(currentScript);
|
|
151
151
|
if (isReload) {
|
|
152
|
-
urlObject.searchParams.set("
|
|
152
|
+
urlObject.searchParams.set("hot", Date.now());
|
|
153
153
|
nodeToReplace = currentScriptClone;
|
|
154
154
|
currentScriptClone.src = urlObject.href;
|
|
155
155
|
} else {
|
|
@@ -214,7 +214,7 @@ window.__supervisor__ = (() => {
|
|
|
214
214
|
const execute = async ({ isReload } = {}) => {
|
|
215
215
|
start();
|
|
216
216
|
if (isReload) {
|
|
217
|
-
urlObject.searchParams.set("
|
|
217
|
+
urlObject.searchParams.set("hot", Date.now());
|
|
218
218
|
}
|
|
219
219
|
try {
|
|
220
220
|
const namespace = await importFn(urlObject.href);
|
|
@@ -258,7 +258,7 @@ window.__supervisor__ = (() => {
|
|
|
258
258
|
start();
|
|
259
259
|
currentScriptClone = prepareScriptToLoad(currentScript);
|
|
260
260
|
if (isReload) {
|
|
261
|
-
urlObject.searchParams.set("
|
|
261
|
+
urlObject.searchParams.set("hot", Date.now());
|
|
262
262
|
nodeToReplace = currentScriptClone;
|
|
263
263
|
currentScriptClone.src = urlObject.href;
|
|
264
264
|
} else {
|
|
@@ -23,9 +23,9 @@ export const jsenvPluginSupervisor = ({
|
|
|
23
23
|
return {
|
|
24
24
|
name: "jsenv:supervisor",
|
|
25
25
|
appliesDuring: "dev",
|
|
26
|
-
serve: async (
|
|
27
|
-
if (request.pathname.startsWith("/__get_code_frame__/")) {
|
|
28
|
-
const { pathname, searchParams } = new URL(request.url);
|
|
26
|
+
serve: async (serveInfo) => {
|
|
27
|
+
if (serveInfo.request.pathname.startsWith("/__get_code_frame__/")) {
|
|
28
|
+
const { pathname, searchParams } = new URL(serveInfo.request.url);
|
|
29
29
|
let urlWithLineAndColumn = pathname.slice(
|
|
30
30
|
"/__get_code_frame__/".length,
|
|
31
31
|
);
|
|
@@ -40,7 +40,7 @@ export const jsenvPluginSupervisor = ({
|
|
|
40
40
|
const file = urlWithLineAndColumn.slice(0, match.index);
|
|
41
41
|
let line = parseInt(match[1]);
|
|
42
42
|
let column = parseInt(match[2]);
|
|
43
|
-
const urlInfo =
|
|
43
|
+
const urlInfo = serveInfo.kitchen.graph.getUrlInfo(file);
|
|
44
44
|
if (!urlInfo) {
|
|
45
45
|
return {
|
|
46
46
|
status: 204,
|
|
@@ -83,8 +83,10 @@ export const jsenvPluginSupervisor = ({
|
|
|
83
83
|
body: codeFrame,
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
if (request.pathname.startsWith("/__get_error_cause__/")) {
|
|
87
|
-
let file = request.pathname.slice(
|
|
86
|
+
if (serveInfo.request.pathname.startsWith("/__get_error_cause__/")) {
|
|
87
|
+
let file = serveInfo.request.pathname.slice(
|
|
88
|
+
"/__get_error_cause__/".length,
|
|
89
|
+
);
|
|
88
90
|
file = decodeURIComponent(file);
|
|
89
91
|
if (!file) {
|
|
90
92
|
return {
|
|
@@ -93,7 +95,7 @@ export const jsenvPluginSupervisor = ({
|
|
|
93
95
|
};
|
|
94
96
|
}
|
|
95
97
|
const getErrorCauseInfo = () => {
|
|
96
|
-
const urlInfo =
|
|
98
|
+
const urlInfo = serveInfo.kitchen.graph.getUrlInfo(file);
|
|
97
99
|
if (!urlInfo) {
|
|
98
100
|
return null;
|
|
99
101
|
}
|
|
@@ -102,12 +104,10 @@ export const jsenvPluginSupervisor = ({
|
|
|
102
104
|
return error;
|
|
103
105
|
}
|
|
104
106
|
// search in direct dependencies (404 or 500)
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (dependencyUrlInfo.error) {
|
|
110
|
-
return dependencyUrlInfo.error;
|
|
107
|
+
for (const referenceToOther of urlInfo.referenceToOthersSet) {
|
|
108
|
+
const referencedUrlInfo = referenceToOther.urlInfo;
|
|
109
|
+
if (referencedUrlInfo.error) {
|
|
110
|
+
return referencedUrlInfo.error;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
return null;
|
|
@@ -138,8 +138,10 @@ export const jsenvPluginSupervisor = ({
|
|
|
138
138
|
body,
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
if (request.pathname.startsWith("/__open_in_editor__/")) {
|
|
142
|
-
let file = request.pathname.slice(
|
|
141
|
+
if (serveInfo.request.pathname.startsWith("/__open_in_editor__/")) {
|
|
142
|
+
let file = serveInfo.request.pathname.slice(
|
|
143
|
+
"/__open_in_editor__/".length,
|
|
144
|
+
);
|
|
143
145
|
file = decodeURIComponent(file);
|
|
144
146
|
if (!file) {
|
|
145
147
|
return {
|
|
@@ -162,8 +164,8 @@ export const jsenvPluginSupervisor = ({
|
|
|
162
164
|
return null;
|
|
163
165
|
},
|
|
164
166
|
transformUrlContent: {
|
|
165
|
-
html: (
|
|
166
|
-
const
|
|
167
|
+
html: (htmlUrlInfo) => {
|
|
168
|
+
const supervisorFileReference = htmlUrlInfo.dependencies.inject({
|
|
167
169
|
type: "script",
|
|
168
170
|
expectedType: "js_classic",
|
|
169
171
|
specifier: supervisorFileUrl,
|
|
@@ -171,8 +173,8 @@ export const jsenvPluginSupervisor = ({
|
|
|
171
173
|
|
|
172
174
|
return injectSupervisorIntoHTML(
|
|
173
175
|
{
|
|
174
|
-
content,
|
|
175
|
-
url,
|
|
176
|
+
content: htmlUrlInfo.content,
|
|
177
|
+
url: htmlUrlInfo.url,
|
|
176
178
|
},
|
|
177
179
|
{
|
|
178
180
|
supervisorScriptSrc: supervisorFileReference.generatedSpecifier,
|
|
@@ -184,7 +186,7 @@ export const jsenvPluginSupervisor = ({
|
|
|
184
186
|
openInEditor,
|
|
185
187
|
},
|
|
186
188
|
webServer: {
|
|
187
|
-
rootDirectoryUrl: context.rootDirectoryUrl,
|
|
189
|
+
rootDirectoryUrl: htmlUrlInfo.context.rootDirectoryUrl,
|
|
188
190
|
isJsenvDevServer: true,
|
|
189
191
|
},
|
|
190
192
|
inlineAsRemote: true,
|
|
@@ -196,8 +198,8 @@ export const jsenvPluginSupervisor = ({
|
|
|
196
198
|
line,
|
|
197
199
|
column,
|
|
198
200
|
}) => {
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
+
const inlineScriptReference =
|
|
202
|
+
htmlUrlInfo.dependencies.foundInline({
|
|
201
203
|
type: "script",
|
|
202
204
|
subtype: "inline",
|
|
203
205
|
expectedType: type,
|