@jsenv/core 30.3.6 → 30.3.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.
- package/dist/main.js +66 -25
- package/package.json +2 -2
- package/src/build/build.js +1 -1
- package/src/kitchen/kitchen.js +4 -1
- package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +1 -1
- package/src/plugins/import_meta_hot/html_hot_dependencies.js +1 -1
- package/src/plugins/importmap/jsenv_plugin_importmap.js +1 -1
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +37 -6
- package/src/plugins/inline/jsenv_plugin_inline_query_param.js +2 -1
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +1 -1
- package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +1 -1
- package/src/plugins/server_events/server_events_dispatcher.js +11 -2
- package/src/plugins/supervisor/jsenv_plugin_supervisor.js +3 -2
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +3 -3
- package/src/plugins/url_analysis/html/html_urls.js +2 -2
- package/src/plugins/url_analysis/jsenv_plugin_reference_expected_types.js +1 -1
- package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +2 -1
package/dist/main.js
CHANGED
|
@@ -6905,13 +6905,18 @@ const createServerEventsDispatcher = () => {
|
|
|
6905
6905
|
const firstClient = clients.shift();
|
|
6906
6906
|
firstClient.close();
|
|
6907
6907
|
}
|
|
6908
|
-
|
|
6909
|
-
client.close();
|
|
6908
|
+
const removeClient = () => {
|
|
6910
6909
|
const index = clients.indexOf(client);
|
|
6911
6910
|
if (index > -1) {
|
|
6912
6911
|
clients.splice(index, 1);
|
|
6913
6912
|
}
|
|
6914
6913
|
};
|
|
6914
|
+
client.onclose = () => {
|
|
6915
|
+
removeClient();
|
|
6916
|
+
};
|
|
6917
|
+
return () => {
|
|
6918
|
+
client.close();
|
|
6919
|
+
};
|
|
6915
6920
|
};
|
|
6916
6921
|
return {
|
|
6917
6922
|
addWebsocket: (websocket, request) => {
|
|
@@ -6946,6 +6951,10 @@ const createServerEventsDispatcher = () => {
|
|
|
6946
6951
|
client.sendEvent({
|
|
6947
6952
|
type: "welcome"
|
|
6948
6953
|
});
|
|
6954
|
+
websocket.onclose = () => {
|
|
6955
|
+
client.onclose();
|
|
6956
|
+
};
|
|
6957
|
+
client.onclose = () => {};
|
|
6949
6958
|
return addClient(client);
|
|
6950
6959
|
},
|
|
6951
6960
|
// we could add "addEventSource" and let clients connect using
|
|
@@ -9056,12 +9065,15 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9056
9065
|
await urlInfoTransformer.applyIntermediateTransformations(urlInfo, transformReturnValue);
|
|
9057
9066
|
});
|
|
9058
9067
|
} catch (error) {
|
|
9059
|
-
|
|
9068
|
+
urlGraph.updateReferences(urlInfo, references); // ensure reference are updated even in case of error
|
|
9069
|
+
const transformError = createTransformUrlContentError({
|
|
9060
9070
|
pluginController,
|
|
9061
9071
|
reference: context.reference,
|
|
9062
9072
|
urlInfo,
|
|
9063
9073
|
error
|
|
9064
9074
|
});
|
|
9075
|
+
urlInfo.error = transformError;
|
|
9076
|
+
throw transformError;
|
|
9065
9077
|
}
|
|
9066
9078
|
// after "transform" all references from originalContent
|
|
9067
9079
|
// and the one injected by plugin are known
|
|
@@ -9651,7 +9663,7 @@ const jsenvPluginReferenceExpectedTypes = () => {
|
|
|
9651
9663
|
name: "jsenv:reference_expected_types",
|
|
9652
9664
|
appliesDuring: "*",
|
|
9653
9665
|
redirectUrl: {
|
|
9654
|
-
|
|
9666
|
+
script: redirectJsUrls,
|
|
9655
9667
|
js_url: redirectJsUrls,
|
|
9656
9668
|
js_import: redirectJsUrls
|
|
9657
9669
|
}
|
|
@@ -9860,7 +9872,7 @@ const visitHtmlUrls = ({
|
|
|
9860
9872
|
return;
|
|
9861
9873
|
}
|
|
9862
9874
|
visitAttributeAsUrlSpecifier({
|
|
9863
|
-
type: "
|
|
9875
|
+
type: "script",
|
|
9864
9876
|
subtype: type,
|
|
9865
9877
|
expectedType: type,
|
|
9866
9878
|
node,
|
|
@@ -9945,7 +9957,7 @@ const decideLinkExpectedType = (linkMention, mentions) => {
|
|
|
9945
9957
|
return "css";
|
|
9946
9958
|
}
|
|
9947
9959
|
if (as === "script") {
|
|
9948
|
-
const firstScriptOnThisUrl = mentions.find(mentionCandidate => mentionCandidate.url === linkMention.url && mentionCandidate.type === "
|
|
9960
|
+
const firstScriptOnThisUrl = mentions.find(mentionCandidate => mentionCandidate.url === linkMention.url && mentionCandidate.type === "script");
|
|
9949
9961
|
if (firstScriptOnThisUrl) {
|
|
9950
9962
|
return firstScriptOnThisUrl.expectedType;
|
|
9951
9963
|
}
|
|
@@ -10176,6 +10188,28 @@ const findOriginalDirectoryReference = (urlInfo, context) => {
|
|
|
10176
10188
|
const jsenvPluginHtmlInlineContent = ({
|
|
10177
10189
|
analyzeConvertedScripts
|
|
10178
10190
|
}) => {
|
|
10191
|
+
const cookInlineContent = async ({
|
|
10192
|
+
context,
|
|
10193
|
+
inlineContentUrlInfo,
|
|
10194
|
+
inlineContentReference
|
|
10195
|
+
}) => {
|
|
10196
|
+
try {
|
|
10197
|
+
await context.cook(inlineContentUrlInfo, {
|
|
10198
|
+
reference: inlineContentReference
|
|
10199
|
+
});
|
|
10200
|
+
} catch (e) {
|
|
10201
|
+
if (e.code === "PARSE_ERROR") {
|
|
10202
|
+
// When something like <style> or <script> contains syntax error
|
|
10203
|
+
// the HTML in itself it still valid
|
|
10204
|
+
// keep the syntax error and continue with the HTML
|
|
10205
|
+
const messageStart = inlineContentUrlInfo.type === "css" ? `Syntax error on css declared inside <style>` : `Syntax error on js declared inside <script>`;
|
|
10206
|
+
context.logger.error(`${messageStart}: ${e.cause.reasonCode}
|
|
10207
|
+
${e.traceMessage}`);
|
|
10208
|
+
} else {
|
|
10209
|
+
throw e;
|
|
10210
|
+
}
|
|
10211
|
+
}
|
|
10212
|
+
};
|
|
10179
10213
|
return {
|
|
10180
10214
|
name: "jsenv:html_inline_content",
|
|
10181
10215
|
appliesDuring: "*",
|
|
@@ -10210,7 +10244,7 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
10210
10244
|
const debug = getHtmlNodeAttribute(styleNode, "jsenv-debug") !== undefined;
|
|
10211
10245
|
const [inlineStyleReference, inlineStyleUrlInfo] = context.referenceUtils.foundInline({
|
|
10212
10246
|
node: styleNode,
|
|
10213
|
-
type: "
|
|
10247
|
+
type: "style",
|
|
10214
10248
|
expectedType: "css",
|
|
10215
10249
|
isOriginalPosition: isOriginal,
|
|
10216
10250
|
// we remove 1 to the line because imagine the following html:
|
|
@@ -10224,8 +10258,10 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
10224
10258
|
debug
|
|
10225
10259
|
});
|
|
10226
10260
|
actions.push(async () => {
|
|
10227
|
-
await
|
|
10228
|
-
|
|
10261
|
+
await cookInlineContent({
|
|
10262
|
+
context,
|
|
10263
|
+
inlineContentUrlInfo: inlineStyleUrlInfo,
|
|
10264
|
+
inlineContentReference: inlineStyleReference
|
|
10229
10265
|
});
|
|
10230
10266
|
});
|
|
10231
10267
|
mutations.push(() => {
|
|
@@ -10274,7 +10310,7 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
10274
10310
|
const debug = getHtmlNodeAttribute(scriptNode, "jsenv-debug") !== undefined;
|
|
10275
10311
|
const [inlineScriptReference, inlineScriptUrlInfo] = context.referenceUtils.foundInline({
|
|
10276
10312
|
node: scriptNode,
|
|
10277
|
-
type: "
|
|
10313
|
+
type: "script",
|
|
10278
10314
|
expectedType: type,
|
|
10279
10315
|
// we remove 1 to the line because imagine the following html:
|
|
10280
10316
|
// <script>console.log('ok')</script>
|
|
@@ -10288,8 +10324,10 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
10288
10324
|
debug
|
|
10289
10325
|
});
|
|
10290
10326
|
actions.push(async () => {
|
|
10291
|
-
await
|
|
10292
|
-
|
|
10327
|
+
await cookInlineContent({
|
|
10328
|
+
context,
|
|
10329
|
+
inlineContentUrlInfo: inlineScriptUrlInfo,
|
|
10330
|
+
inlineContentReference: inlineScriptReference
|
|
10293
10331
|
});
|
|
10294
10332
|
});
|
|
10295
10333
|
mutations.push(() => {
|
|
@@ -10814,7 +10852,8 @@ const jsenvPluginInlineQueryParam = () => {
|
|
|
10814
10852
|
// this should be done during dev and postbuild but not build
|
|
10815
10853
|
// so that the bundled file gets inlined and not the entry point
|
|
10816
10854
|
"link_href": () => null,
|
|
10817
|
-
"
|
|
10855
|
+
"style": () => null,
|
|
10856
|
+
"script": () => null,
|
|
10818
10857
|
// if the referenced url is a worker we could use
|
|
10819
10858
|
// https://www.oreilly.com/library/view/web-workers/9781449322120/ch04.html
|
|
10820
10859
|
// but maybe we should rather use ?object_url
|
|
@@ -14675,7 +14714,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14675
14714
|
}
|
|
14676
14715
|
return null;
|
|
14677
14716
|
},
|
|
14678
|
-
|
|
14717
|
+
script: (reference, context) => {
|
|
14679
14718
|
if (context.systemJsTranspilation && reference.expectedType === "js_module") {
|
|
14680
14719
|
return turnIntoJsClassicProxy(reference);
|
|
14681
14720
|
}
|
|
@@ -14732,7 +14771,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14732
14771
|
}
|
|
14733
14772
|
const src = getHtmlNodeAttribute(node, "src");
|
|
14734
14773
|
if (src) {
|
|
14735
|
-
const reference = context.referenceUtils.find(ref => ref.generatedSpecifier === src && ref.type === "
|
|
14774
|
+
const reference = context.referenceUtils.find(ref => ref.generatedSpecifier === src && ref.type === "script" && ref.subtype === "js_module");
|
|
14736
14775
|
if (!reference) {
|
|
14737
14776
|
return;
|
|
14738
14777
|
}
|
|
@@ -14803,7 +14842,7 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
14803
14842
|
});
|
|
14804
14843
|
}
|
|
14805
14844
|
const [systemJsReference, systemJsUrlInfo] = context.referenceUtils.inject({
|
|
14806
|
-
type: "
|
|
14845
|
+
type: "script",
|
|
14807
14846
|
expectedType: "js_classic",
|
|
14808
14847
|
isInline: true,
|
|
14809
14848
|
contentType: "text/javascript",
|
|
@@ -15739,7 +15778,7 @@ const jsenvPluginImportmap = () => {
|
|
|
15739
15778
|
columnEnd
|
|
15740
15779
|
});
|
|
15741
15780
|
const [inlineImportmapReference, inlineImportmapUrlInfo] = context.referenceUtils.foundInline({
|
|
15742
|
-
type: "
|
|
15781
|
+
type: "script",
|
|
15743
15782
|
isOriginalPosition: isOriginal,
|
|
15744
15783
|
specifierLine: line - 1,
|
|
15745
15784
|
specifierColumn: column,
|
|
@@ -16874,7 +16913,8 @@ const addRelationshipWithPackageJson = ({
|
|
|
16874
16913
|
* - "http_request"
|
|
16875
16914
|
* - "entry_point"
|
|
16876
16915
|
* - "link_href"
|
|
16877
|
-
* - "
|
|
16916
|
+
* - "style"
|
|
16917
|
+
* - "script"
|
|
16878
16918
|
* - "a_href"
|
|
16879
16919
|
* - "iframe_src
|
|
16880
16920
|
* - "img_src"
|
|
@@ -17411,7 +17451,8 @@ const jsenvPluginSupervisor = ({
|
|
|
17411
17451
|
columnEnd
|
|
17412
17452
|
});
|
|
17413
17453
|
const [inlineScriptReference] = context.referenceUtils.foundInline({
|
|
17414
|
-
type: "
|
|
17454
|
+
type: "script",
|
|
17455
|
+
subtype: "inline",
|
|
17415
17456
|
expectedType: type,
|
|
17416
17457
|
isOriginalPosition: isOriginal,
|
|
17417
17458
|
specifierLine: line - 1,
|
|
@@ -17484,7 +17525,7 @@ const jsenvPluginSupervisor = ({
|
|
|
17484
17525
|
specifier: scriptTypeModuleSupervisorFileUrl
|
|
17485
17526
|
});
|
|
17486
17527
|
const [supervisorFileReference] = context.referenceUtils.inject({
|
|
17487
|
-
type: "
|
|
17528
|
+
type: "script",
|
|
17488
17529
|
expectedType: "js_classic",
|
|
17489
17530
|
specifier: supervisorFileUrl
|
|
17490
17531
|
});
|
|
@@ -19464,7 +19505,7 @@ const htmlNodeCanHotReload = node => {
|
|
|
19464
19505
|
return rel === "icon";
|
|
19465
19506
|
}
|
|
19466
19507
|
return [
|
|
19467
|
-
// "
|
|
19508
|
+
// "script", // script cannot hot reload
|
|
19468
19509
|
"a",
|
|
19469
19510
|
// Iframe will have their own event source client
|
|
19470
19511
|
// and can hot reload independently
|
|
@@ -19723,7 +19764,7 @@ const jsenvPluginAutoreloadClient = () => {
|
|
|
19723
19764
|
html: (htmlUrlInfo, context) => {
|
|
19724
19765
|
const htmlAst = parseHtmlString(htmlUrlInfo.content);
|
|
19725
19766
|
const [autoreloadClientReference] = context.referenceUtils.inject({
|
|
19726
|
-
type: "
|
|
19767
|
+
type: "script",
|
|
19727
19768
|
subtype: "js_module",
|
|
19728
19769
|
expectedType: "js_module",
|
|
19729
19770
|
specifier: autoreloadClientFileUrl
|
|
@@ -20078,7 +20119,7 @@ const jsenvPluginRibbon = ({
|
|
|
20078
20119
|
}
|
|
20079
20120
|
const htmlAst = parseHtmlString(urlInfo.content);
|
|
20080
20121
|
const [ribbonClientFileReference] = context.referenceUtils.inject({
|
|
20081
|
-
type: "
|
|
20122
|
+
type: "script",
|
|
20082
20123
|
subtype: "js_module",
|
|
20083
20124
|
expectedType: "js_module",
|
|
20084
20125
|
specifier: ribbonClientFileUrl.href
|
|
@@ -21088,7 +21129,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21088
21129
|
const dependentUrlInfo = rawGraph.getUrlInfo(dependent);
|
|
21089
21130
|
for (const reference of dependentUrlInfo.references) {
|
|
21090
21131
|
if (reference.url === referencedUrlInfo.url) {
|
|
21091
|
-
willAlreadyBeBundled = reference.subtype === "import_dynamic" || reference.type === "
|
|
21132
|
+
willAlreadyBeBundled = reference.subtype === "import_dynamic" || reference.type === "script";
|
|
21092
21133
|
}
|
|
21093
21134
|
}
|
|
21094
21135
|
}
|
|
@@ -22036,7 +22077,7 @@ const jsenvPluginServerEventsClientInjection = () => {
|
|
|
22036
22077
|
html: (htmlUrlInfo, context) => {
|
|
22037
22078
|
const htmlAst = parseHtmlString(htmlUrlInfo.content);
|
|
22038
22079
|
const [serverEventsClientFileReference] = context.referenceUtils.inject({
|
|
22039
|
-
type: "
|
|
22080
|
+
type: "script",
|
|
22040
22081
|
subtype: "js_module",
|
|
22041
22082
|
expectedType: "js_module",
|
|
22042
22083
|
specifier: serverEventsClientFileUrl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "30.3.
|
|
3
|
+
"version": "30.3.7",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@c88/v8-coverage": "0.1.1",
|
|
68
68
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
69
69
|
"@jsenv/abort": "4.2.4",
|
|
70
|
-
"@jsenv/ast": "3.0.
|
|
70
|
+
"@jsenv/ast": "3.0.2",
|
|
71
71
|
"@jsenv/babel-plugins": "1.1.3",
|
|
72
72
|
"@jsenv/plugin-bundling": "1.1.2",
|
|
73
73
|
"@jsenv/filesystem": "4.1.9",
|
package/src/build/build.js
CHANGED
package/src/kitchen/kitchen.js
CHANGED
|
@@ -593,12 +593,15 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
593
593
|
},
|
|
594
594
|
)
|
|
595
595
|
} catch (error) {
|
|
596
|
-
|
|
596
|
+
urlGraph.updateReferences(urlInfo, references) // ensure reference are updated even in case of error
|
|
597
|
+
const transformError = createTransformUrlContentError({
|
|
597
598
|
pluginController,
|
|
598
599
|
reference: context.reference,
|
|
599
600
|
urlInfo,
|
|
600
601
|
error,
|
|
601
602
|
})
|
|
603
|
+
urlInfo.error = transformError
|
|
604
|
+
throw transformError
|
|
602
605
|
}
|
|
603
606
|
// after "transform" all references from originalContent
|
|
604
607
|
// and the one injected by plugin are known
|
|
@@ -18,7 +18,7 @@ export const jsenvPluginAutoreloadClient = () => {
|
|
|
18
18
|
html: (htmlUrlInfo, context) => {
|
|
19
19
|
const htmlAst = parseHtmlString(htmlUrlInfo.content)
|
|
20
20
|
const [autoreloadClientReference] = context.referenceUtils.inject({
|
|
21
|
-
type: "
|
|
21
|
+
type: "script",
|
|
22
22
|
subtype: "js_module",
|
|
23
23
|
expectedType: "js_module",
|
|
24
24
|
specifier: autoreloadClientFileUrl,
|
|
@@ -130,7 +130,7 @@ const htmlNodeCanHotReload = (node) => {
|
|
|
130
130
|
return rel === "icon"
|
|
131
131
|
}
|
|
132
132
|
return [
|
|
133
|
-
// "
|
|
133
|
+
// "script", // script cannot hot reload
|
|
134
134
|
"a",
|
|
135
135
|
// Iframe will have their own event source client
|
|
136
136
|
// and can hot reload independently
|
|
@@ -121,7 +121,7 @@ export const jsenvPluginImportmap = () => {
|
|
|
121
121
|
})
|
|
122
122
|
const [inlineImportmapReference, inlineImportmapUrlInfo] =
|
|
123
123
|
context.referenceUtils.foundInline({
|
|
124
|
-
type: "
|
|
124
|
+
type: "script",
|
|
125
125
|
isOriginalPosition: isOriginal,
|
|
126
126
|
specifierLine: line - 1,
|
|
127
127
|
specifierColumn: column,
|
|
@@ -13,6 +13,33 @@ import {
|
|
|
13
13
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js"
|
|
14
14
|
|
|
15
15
|
export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
16
|
+
const cookInlineContent = async ({
|
|
17
|
+
context,
|
|
18
|
+
inlineContentUrlInfo,
|
|
19
|
+
inlineContentReference,
|
|
20
|
+
}) => {
|
|
21
|
+
try {
|
|
22
|
+
await context.cook(inlineContentUrlInfo, {
|
|
23
|
+
reference: inlineContentReference,
|
|
24
|
+
})
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (e.code === "PARSE_ERROR") {
|
|
27
|
+
// When something like <style> or <script> contains syntax error
|
|
28
|
+
// the HTML in itself it still valid
|
|
29
|
+
// keep the syntax error and continue with the HTML
|
|
30
|
+
const messageStart =
|
|
31
|
+
inlineContentUrlInfo.type === "css"
|
|
32
|
+
? `Syntax error on css declared inside <style>`
|
|
33
|
+
: `Syntax error on js declared inside <script>`
|
|
34
|
+
|
|
35
|
+
context.logger.error(`${messageStart}: ${e.cause.reasonCode}
|
|
36
|
+
${e.traceMessage}`)
|
|
37
|
+
} else {
|
|
38
|
+
throw e
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
16
43
|
return {
|
|
17
44
|
name: "jsenv:html_inline_content",
|
|
18
45
|
appliesDuring: "*",
|
|
@@ -44,7 +71,7 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
44
71
|
const [inlineStyleReference, inlineStyleUrlInfo] =
|
|
45
72
|
context.referenceUtils.foundInline({
|
|
46
73
|
node: styleNode,
|
|
47
|
-
type: "
|
|
74
|
+
type: "style",
|
|
48
75
|
expectedType: "css",
|
|
49
76
|
isOriginalPosition: isOriginal,
|
|
50
77
|
// we remove 1 to the line because imagine the following html:
|
|
@@ -58,8 +85,10 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
58
85
|
debug,
|
|
59
86
|
})
|
|
60
87
|
actions.push(async () => {
|
|
61
|
-
await
|
|
62
|
-
|
|
88
|
+
await cookInlineContent({
|
|
89
|
+
context,
|
|
90
|
+
inlineContentUrlInfo: inlineStyleUrlInfo,
|
|
91
|
+
inlineContentReference: inlineStyleReference,
|
|
63
92
|
})
|
|
64
93
|
})
|
|
65
94
|
mutations.push(() => {
|
|
@@ -113,7 +142,7 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
113
142
|
const [inlineScriptReference, inlineScriptUrlInfo] =
|
|
114
143
|
context.referenceUtils.foundInline({
|
|
115
144
|
node: scriptNode,
|
|
116
|
-
type: "
|
|
145
|
+
type: "script",
|
|
117
146
|
expectedType: type,
|
|
118
147
|
// we remove 1 to the line because imagine the following html:
|
|
119
148
|
// <script>console.log('ok')</script>
|
|
@@ -127,8 +156,10 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
127
156
|
debug,
|
|
128
157
|
})
|
|
129
158
|
actions.push(async () => {
|
|
130
|
-
await
|
|
131
|
-
|
|
159
|
+
await cookInlineContent({
|
|
160
|
+
context,
|
|
161
|
+
inlineContentUrlInfo: inlineScriptUrlInfo,
|
|
162
|
+
inlineContentReference: inlineScriptReference,
|
|
132
163
|
})
|
|
133
164
|
})
|
|
134
165
|
mutations.push(() => {
|
|
@@ -9,7 +9,8 @@ export const jsenvPluginInlineQueryParam = () => {
|
|
|
9
9
|
// this should be done during dev and postbuild but not build
|
|
10
10
|
// so that the bundled file gets inlined and not the entry point
|
|
11
11
|
"link_href": () => null,
|
|
12
|
-
"
|
|
12
|
+
"style": () => null,
|
|
13
|
+
"script": () => null,
|
|
13
14
|
// if the referenced url is a worker we could use
|
|
14
15
|
// https://www.oreilly.com/library/view/web-workers/9781449322120/ch04.html
|
|
15
16
|
// but maybe we should rather use ?object_url
|
|
@@ -37,7 +37,7 @@ export const jsenvPluginRibbon = ({
|
|
|
37
37
|
}
|
|
38
38
|
const htmlAst = parseHtmlString(urlInfo.content)
|
|
39
39
|
const [ribbonClientFileReference] = context.referenceUtils.inject({
|
|
40
|
-
type: "
|
|
40
|
+
type: "script",
|
|
41
41
|
subtype: "js_module",
|
|
42
42
|
expectedType: "js_module",
|
|
43
43
|
specifier: ribbonClientFileUrl.href,
|
|
@@ -24,7 +24,7 @@ export const jsenvPluginServerEventsClientInjection = () => {
|
|
|
24
24
|
const htmlAst = parseHtmlString(htmlUrlInfo.content)
|
|
25
25
|
const [serverEventsClientFileReference] = context.referenceUtils.inject(
|
|
26
26
|
{
|
|
27
|
-
type: "
|
|
27
|
+
type: "script",
|
|
28
28
|
subtype: "js_module",
|
|
29
29
|
expectedType: "js_module",
|
|
30
30
|
specifier: serverEventsClientFileUrl,
|
|
@@ -8,13 +8,18 @@ export const createServerEventsDispatcher = () => {
|
|
|
8
8
|
const firstClient = clients.shift()
|
|
9
9
|
firstClient.close()
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
client.close()
|
|
11
|
+
const removeClient = () => {
|
|
13
12
|
const index = clients.indexOf(client)
|
|
14
13
|
if (index > -1) {
|
|
15
14
|
clients.splice(index, 1)
|
|
16
15
|
}
|
|
17
16
|
}
|
|
17
|
+
client.onclose = () => {
|
|
18
|
+
removeClient(client)
|
|
19
|
+
}
|
|
20
|
+
return () => {
|
|
21
|
+
client.close()
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
return {
|
|
@@ -48,6 +53,10 @@ export const createServerEventsDispatcher = () => {
|
|
|
48
53
|
},
|
|
49
54
|
}
|
|
50
55
|
client.sendEvent({ type: "welcome" })
|
|
56
|
+
websocket.onclose = () => {
|
|
57
|
+
client.onclose()
|
|
58
|
+
}
|
|
59
|
+
client.onclose = () => {}
|
|
51
60
|
return addClient(client)
|
|
52
61
|
},
|
|
53
62
|
// we could add "addEventSource" and let clients connect using
|
|
@@ -232,7 +232,8 @@ export const jsenvPluginSupervisor = ({
|
|
|
232
232
|
columnEnd,
|
|
233
233
|
})
|
|
234
234
|
const [inlineScriptReference] = context.referenceUtils.foundInline({
|
|
235
|
-
type: "
|
|
235
|
+
type: "script",
|
|
236
|
+
subtype: "inline",
|
|
236
237
|
expectedType: type,
|
|
237
238
|
isOriginalPosition: isOriginal,
|
|
238
239
|
specifierLine: line - 1,
|
|
@@ -307,7 +308,7 @@ export const jsenvPluginSupervisor = ({
|
|
|
307
308
|
specifier: scriptTypeModuleSupervisorFileUrl,
|
|
308
309
|
})
|
|
309
310
|
const [supervisorFileReference] = context.referenceUtils.inject({
|
|
310
|
-
type: "
|
|
311
|
+
type: "script",
|
|
311
312
|
expectedType: "js_classic",
|
|
312
313
|
specifier: supervisorFileUrl,
|
|
313
314
|
})
|
|
@@ -47,7 +47,7 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
47
47
|
}
|
|
48
48
|
return null
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
script: (reference, context) => {
|
|
51
51
|
if (
|
|
52
52
|
context.systemJsTranspilation &&
|
|
53
53
|
reference.expectedType === "js_module"
|
|
@@ -117,7 +117,7 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
117
117
|
const reference = context.referenceUtils.find(
|
|
118
118
|
(ref) =>
|
|
119
119
|
ref.generatedSpecifier === src &&
|
|
120
|
-
ref.type === "
|
|
120
|
+
ref.type === "script" &&
|
|
121
121
|
ref.subtype === "js_module",
|
|
122
122
|
)
|
|
123
123
|
if (!reference) {
|
|
@@ -192,7 +192,7 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
192
192
|
}
|
|
193
193
|
const [systemJsReference, systemJsUrlInfo] =
|
|
194
194
|
context.referenceUtils.inject({
|
|
195
|
-
type: "
|
|
195
|
+
type: "script",
|
|
196
196
|
expectedType: "js_classic",
|
|
197
197
|
isInline: true,
|
|
198
198
|
contentType: "text/javascript",
|
|
@@ -212,7 +212,7 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
|
|
|
212
212
|
return
|
|
213
213
|
}
|
|
214
214
|
visitAttributeAsUrlSpecifier({
|
|
215
|
-
type: "
|
|
215
|
+
type: "script",
|
|
216
216
|
subtype: type,
|
|
217
217
|
expectedType: type,
|
|
218
218
|
node,
|
|
@@ -301,7 +301,7 @@ const decideLinkExpectedType = (linkMention, mentions) => {
|
|
|
301
301
|
const firstScriptOnThisUrl = mentions.find(
|
|
302
302
|
(mentionCandidate) =>
|
|
303
303
|
mentionCandidate.url === linkMention.url &&
|
|
304
|
-
mentionCandidate.type === "
|
|
304
|
+
mentionCandidate.type === "script",
|
|
305
305
|
)
|
|
306
306
|
if (firstScriptOnThisUrl) {
|
|
307
307
|
return firstScriptOnThisUrl.expectedType
|
|
@@ -44,7 +44,7 @@ export const jsenvPluginReferenceExpectedTypes = () => {
|
|
|
44
44
|
name: "jsenv:reference_expected_types",
|
|
45
45
|
appliesDuring: "*",
|
|
46
46
|
redirectUrl: {
|
|
47
|
-
|
|
47
|
+
script: redirectJsUrls,
|
|
48
48
|
js_url: redirectJsUrls,
|
|
49
49
|
js_import: redirectJsUrls,
|
|
50
50
|
},
|