@jsenv/plugin-supervisor 1.1.1 → 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
CHANGED
|
@@ -150,7 +150,7 @@ window.__supervisor__ = (() => {
|
|
|
150
150
|
start();
|
|
151
151
|
currentScriptClone = prepareScriptToLoad(currentScript);
|
|
152
152
|
if (isReload) {
|
|
153
|
-
urlObject.searchParams.set("
|
|
153
|
+
urlObject.searchParams.set("hot", Date.now());
|
|
154
154
|
nodeToReplace = currentScriptClone;
|
|
155
155
|
currentScriptClone.src = urlObject.href;
|
|
156
156
|
} else {
|
|
@@ -227,7 +227,7 @@ window.__supervisor__ = (() => {
|
|
|
227
227
|
} = {}) => {
|
|
228
228
|
start();
|
|
229
229
|
if (isReload) {
|
|
230
|
-
urlObject.searchParams.set("
|
|
230
|
+
urlObject.searchParams.set("hot", Date.now());
|
|
231
231
|
}
|
|
232
232
|
try {
|
|
233
233
|
const namespace = await importFn(urlObject.href);
|
|
@@ -276,7 +276,7 @@ window.__supervisor__ = (() => {
|
|
|
276
276
|
start();
|
|
277
277
|
currentScriptClone = prepareScriptToLoad(currentScript);
|
|
278
278
|
if (isReload) {
|
|
279
|
-
urlObject.searchParams.set("
|
|
279
|
+
urlObject.searchParams.set("hot", Date.now());
|
|
280
280
|
nodeToReplace = currentScriptClone;
|
|
281
281
|
currentScriptClone.src = urlObject.href;
|
|
282
282
|
} else {
|
|
@@ -99,12 +99,22 @@ const urlToFilename = url => {
|
|
|
99
99
|
const generateInlineContentUrl = ({
|
|
100
100
|
url,
|
|
101
101
|
extension,
|
|
102
|
+
basename,
|
|
102
103
|
line,
|
|
103
104
|
column,
|
|
104
105
|
lineEnd,
|
|
105
106
|
columnEnd
|
|
106
107
|
}) => {
|
|
107
|
-
|
|
108
|
+
let generatedName = "";
|
|
109
|
+
if (basename !== undefined) {
|
|
110
|
+
generatedName += basename;
|
|
111
|
+
}
|
|
112
|
+
if (line !== undefined && column !== undefined) {
|
|
113
|
+
generatedName = "L".concat(line, "C").concat(column);
|
|
114
|
+
if (lineEnd !== undefined && columnEnd !== undefined) {
|
|
115
|
+
generatedName += "-L".concat(lineEnd, "C").concat(columnEnd);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
108
118
|
const filenameRaw = urlToFilename(url);
|
|
109
119
|
const filename = "".concat(filenameRaw, "@").concat(generatedName).concat(extension);
|
|
110
120
|
// ideally we should keep query params from url
|
|
@@ -912,7 +922,7 @@ const injectSupervisorIntoHTML = async ({
|
|
|
912
922
|
}
|
|
913
923
|
const src = getHtmlNodeAttribute(scriptNode, "src");
|
|
914
924
|
if (src) {
|
|
915
|
-
const urlObject = new URL(src, "http://example.com");
|
|
925
|
+
const urlObject = new URL(src, "http://example.com/");
|
|
916
926
|
if (urlObject.searchParams.has("inline")) {
|
|
917
927
|
return;
|
|
918
928
|
}
|
|
@@ -990,12 +1000,12 @@ const jsenvPluginSupervisor = ({
|
|
|
990
1000
|
return {
|
|
991
1001
|
name: "jsenv:supervisor",
|
|
992
1002
|
appliesDuring: "dev",
|
|
993
|
-
serve: async
|
|
994
|
-
if (request.pathname.startsWith("/__get_code_frame__/")) {
|
|
1003
|
+
serve: async serveInfo => {
|
|
1004
|
+
if (serveInfo.request.pathname.startsWith("/__get_code_frame__/")) {
|
|
995
1005
|
const {
|
|
996
1006
|
pathname,
|
|
997
1007
|
searchParams
|
|
998
|
-
} = new URL(request.url);
|
|
1008
|
+
} = new URL(serveInfo.request.url);
|
|
999
1009
|
let urlWithLineAndColumn = pathname.slice("/__get_code_frame__/".length);
|
|
1000
1010
|
urlWithLineAndColumn = decodeURIComponent(urlWithLineAndColumn);
|
|
1001
1011
|
const match = urlWithLineAndColumn.match(/:([0-9]+):([0-9]+)$/);
|
|
@@ -1008,7 +1018,7 @@ const jsenvPluginSupervisor = ({
|
|
|
1008
1018
|
const file = urlWithLineAndColumn.slice(0, match.index);
|
|
1009
1019
|
let line = parseInt(match[1]);
|
|
1010
1020
|
let column = parseInt(match[2]);
|
|
1011
|
-
const urlInfo =
|
|
1021
|
+
const urlInfo = serveInfo.kitchen.graph.getUrlInfo(file);
|
|
1012
1022
|
if (!urlInfo) {
|
|
1013
1023
|
return {
|
|
1014
1024
|
status: 204,
|
|
@@ -1051,8 +1061,8 @@ const jsenvPluginSupervisor = ({
|
|
|
1051
1061
|
body: codeFrame
|
|
1052
1062
|
};
|
|
1053
1063
|
}
|
|
1054
|
-
if (request.pathname.startsWith("/__get_error_cause__/")) {
|
|
1055
|
-
let file = request.pathname.slice("/__get_error_cause__/".length);
|
|
1064
|
+
if (serveInfo.request.pathname.startsWith("/__get_error_cause__/")) {
|
|
1065
|
+
let file = serveInfo.request.pathname.slice("/__get_error_cause__/".length);
|
|
1056
1066
|
file = decodeURIComponent(file);
|
|
1057
1067
|
if (!file) {
|
|
1058
1068
|
return {
|
|
@@ -1061,7 +1071,7 @@ const jsenvPluginSupervisor = ({
|
|
|
1061
1071
|
};
|
|
1062
1072
|
}
|
|
1063
1073
|
const getErrorCauseInfo = () => {
|
|
1064
|
-
const urlInfo =
|
|
1074
|
+
const urlInfo = serveInfo.kitchen.graph.getUrlInfo(file);
|
|
1065
1075
|
if (!urlInfo) {
|
|
1066
1076
|
return null;
|
|
1067
1077
|
}
|
|
@@ -1072,13 +1082,10 @@ const jsenvPluginSupervisor = ({
|
|
|
1072
1082
|
return error;
|
|
1073
1083
|
}
|
|
1074
1084
|
// search in direct dependencies (404 or 500)
|
|
1075
|
-
const {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
const dependencyUrlInfo = context.urlGraph.getUrlInfo(dependencyUrl);
|
|
1080
|
-
if (dependencyUrlInfo.error) {
|
|
1081
|
-
return dependencyUrlInfo.error;
|
|
1085
|
+
for (const referenceToOther of urlInfo.referenceToOthersSet) {
|
|
1086
|
+
const referencedUrlInfo = referenceToOther.urlInfo;
|
|
1087
|
+
if (referencedUrlInfo.error) {
|
|
1088
|
+
return referencedUrlInfo.error;
|
|
1082
1089
|
}
|
|
1083
1090
|
}
|
|
1084
1091
|
return null;
|
|
@@ -1101,8 +1108,8 @@ const jsenvPluginSupervisor = ({
|
|
|
1101
1108
|
body
|
|
1102
1109
|
};
|
|
1103
1110
|
}
|
|
1104
|
-
if (request.pathname.startsWith("/__open_in_editor__/")) {
|
|
1105
|
-
let file = request.pathname.slice("/__open_in_editor__/".length);
|
|
1111
|
+
if (serveInfo.request.pathname.startsWith("/__open_in_editor__/")) {
|
|
1112
|
+
let file = serveInfo.request.pathname.slice("/__open_in_editor__/".length);
|
|
1106
1113
|
file = decodeURIComponent(file);
|
|
1107
1114
|
if (!file) {
|
|
1108
1115
|
return {
|
|
@@ -1125,18 +1132,15 @@ const jsenvPluginSupervisor = ({
|
|
|
1125
1132
|
return null;
|
|
1126
1133
|
},
|
|
1127
1134
|
transformUrlContent: {
|
|
1128
|
-
html:
|
|
1129
|
-
|
|
1130
|
-
content
|
|
1131
|
-
}, context) => {
|
|
1132
|
-
const [supervisorFileReference] = context.referenceUtils.inject({
|
|
1135
|
+
html: htmlUrlInfo => {
|
|
1136
|
+
const supervisorFileReference = htmlUrlInfo.dependencies.inject({
|
|
1133
1137
|
type: "script",
|
|
1134
1138
|
expectedType: "js_classic",
|
|
1135
1139
|
specifier: supervisorFileUrl
|
|
1136
1140
|
});
|
|
1137
1141
|
return injectSupervisorIntoHTML({
|
|
1138
|
-
content,
|
|
1139
|
-
url
|
|
1142
|
+
content: htmlUrlInfo.content,
|
|
1143
|
+
url: htmlUrlInfo.url
|
|
1140
1144
|
}, {
|
|
1141
1145
|
supervisorScriptSrc: supervisorFileReference.generatedSpecifier,
|
|
1142
1146
|
supervisorOptions: {
|
|
@@ -1147,7 +1151,7 @@ const jsenvPluginSupervisor = ({
|
|
|
1147
1151
|
openInEditor
|
|
1148
1152
|
},
|
|
1149
1153
|
webServer: {
|
|
1150
|
-
rootDirectoryUrl: context.rootDirectoryUrl,
|
|
1154
|
+
rootDirectoryUrl: htmlUrlInfo.context.rootDirectoryUrl,
|
|
1151
1155
|
isJsenvDevServer: true
|
|
1152
1156
|
},
|
|
1153
1157
|
inlineAsRemote: true,
|
|
@@ -1159,7 +1163,7 @@ const jsenvPluginSupervisor = ({
|
|
|
1159
1163
|
line,
|
|
1160
1164
|
column
|
|
1161
1165
|
}) => {
|
|
1162
|
-
const
|
|
1166
|
+
const inlineScriptReference = htmlUrlInfo.dependencies.foundInline({
|
|
1163
1167
|
type: "script",
|
|
1164
1168
|
subtype: "inline",
|
|
1165
1169
|
expectedType: type,
|
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",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"/dist/"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@jsenv/ast": "
|
|
30
|
-
"@jsenv/urls": "2.
|
|
31
|
-
"@jsenv/sourcemap": "1.0
|
|
29
|
+
"@jsenv/ast": "5.0.0",
|
|
30
|
+
"@jsenv/urls": "2.1.0",
|
|
31
|
+
"@jsenv/sourcemap": "1.1.0",
|
|
32
32
|
"launch-editor": "2.6.0"
|
|
33
33
|
},
|
|
34
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,
|