@jsenv/core 29.3.0-alpha.1 → 29.3.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/main.js
CHANGED
|
@@ -8586,7 +8586,11 @@ const createKitchen = ({
|
|
|
8586
8586
|
debug = false
|
|
8587
8587
|
}) => {
|
|
8588
8588
|
if (typeof specifier !== "string") {
|
|
8589
|
-
|
|
8589
|
+
if (specifier instanceof URL) {
|
|
8590
|
+
specifier = specifier.href;
|
|
8591
|
+
} else {
|
|
8592
|
+
throw new TypeError(`"specifier" must be a string, got ${specifier}`);
|
|
8593
|
+
}
|
|
8590
8594
|
}
|
|
8591
8595
|
const reference = {
|
|
8592
8596
|
original: null,
|
|
@@ -20656,28 +20660,28 @@ const jsenvPluginExplorer = ({
|
|
|
20656
20660
|
};
|
|
20657
20661
|
|
|
20658
20662
|
const jsenvPluginRibbon = ({
|
|
20663
|
+
rootDirectoryUrl,
|
|
20659
20664
|
htmlInclude = "**/*.html",
|
|
20660
|
-
|
|
20661
|
-
|
|
20662
|
-
} = {}) => {
|
|
20665
|
+
devAndBuild = false
|
|
20666
|
+
}) => {
|
|
20663
20667
|
const ribbonClientFileUrl = new URL("./js/ribbon.js", import.meta.url);
|
|
20664
20668
|
const associations = URL_META.resolveAssociations({
|
|
20665
20669
|
ribbon: {
|
|
20666
20670
|
[htmlInclude]: true
|
|
20667
20671
|
}
|
|
20668
|
-
},
|
|
20672
|
+
}, rootDirectoryUrl);
|
|
20669
20673
|
return {
|
|
20670
20674
|
name: "jsenv:ribbon",
|
|
20671
20675
|
appliesDuring: "*",
|
|
20672
|
-
|
|
20676
|
+
transformUrlContent: {
|
|
20673
20677
|
html: (urlInfo, context) => {
|
|
20674
|
-
if (context.scenarios.build && !
|
|
20678
|
+
if (context.scenarios.build && !devAndBuild) {
|
|
20675
20679
|
return null;
|
|
20676
20680
|
}
|
|
20677
20681
|
const {
|
|
20678
20682
|
ribbon
|
|
20679
20683
|
} = URL_META.applyAssociations({
|
|
20680
|
-
url: urlInfo.url,
|
|
20684
|
+
url: asUrlWithoutSearch(urlInfo.url),
|
|
20681
20685
|
associations
|
|
20682
20686
|
});
|
|
20683
20687
|
if (!ribbon) {
|
|
@@ -20688,20 +20692,20 @@ const jsenvPluginRibbon = ({
|
|
|
20688
20692
|
type: "script_src",
|
|
20689
20693
|
subtype: "js_module",
|
|
20690
20694
|
expectedType: "js_module",
|
|
20691
|
-
specifier: ribbonClientFileUrl
|
|
20695
|
+
specifier: ribbonClientFileUrl.href
|
|
20692
20696
|
});
|
|
20693
|
-
|
|
20694
|
-
text: context.scenarios.dev ? "DEV" : "BUILD"
|
|
20695
|
-
|
|
20696
|
-
|
|
20697
|
-
injectHtmlNode(htmlAst, createHtmlNode({
|
|
20697
|
+
const paramsJson = JSON.stringify({
|
|
20698
|
+
text: context.scenarios.dev ? "DEV" : "BUILD"
|
|
20699
|
+
}, null, " ");
|
|
20700
|
+
const scriptNode = createHtmlNode({
|
|
20698
20701
|
tagName: "script",
|
|
20699
20702
|
type: "module",
|
|
20700
|
-
|
|
20701
|
-
import { injectRibbon} from ${ribbonClientFileReference.generatedSpecifier}
|
|
20703
|
+
textContent: `
|
|
20704
|
+
import { injectRibbon} from "${ribbonClientFileReference.generatedSpecifier}"
|
|
20702
20705
|
|
|
20703
|
-
injectRibbon(${
|
|
20704
|
-
})
|
|
20706
|
+
injectRibbon(${paramsJson})`
|
|
20707
|
+
});
|
|
20708
|
+
injectHtmlNode(htmlAst, scriptNode, "jsenv:ribbon");
|
|
20705
20709
|
return stringifyHtmlAst(htmlAst);
|
|
20706
20710
|
}
|
|
20707
20711
|
}
|
|
@@ -20746,6 +20750,11 @@ const getCorePlugins = ({
|
|
|
20746
20750
|
if (ribbon === true) {
|
|
20747
20751
|
ribbon = {};
|
|
20748
20752
|
}
|
|
20753
|
+
if (ribbon === "dev_and_build") {
|
|
20754
|
+
ribbon = {
|
|
20755
|
+
devAndBuild: true
|
|
20756
|
+
};
|
|
20757
|
+
}
|
|
20749
20758
|
return [jsenvPluginUrlAnalysis({
|
|
20750
20759
|
rootDirectoryUrl,
|
|
20751
20760
|
...urlAnalysis
|
|
@@ -20772,7 +20781,10 @@ const getCorePlugins = ({
|
|
|
20772
20781
|
})] : []), jsenvPluginCacheControl(), ...(explorer ? [jsenvPluginExplorer({
|
|
20773
20782
|
...explorer,
|
|
20774
20783
|
clientMainFileUrl
|
|
20775
|
-
})] : []), ...(ribbon ? [jsenvPluginRibbon(
|
|
20784
|
+
})] : []), ...(ribbon ? [jsenvPluginRibbon({
|
|
20785
|
+
rootDirectoryUrl,
|
|
20786
|
+
...ribbon
|
|
20787
|
+
})] : [])];
|
|
20776
20788
|
};
|
|
20777
20789
|
|
|
20778
20790
|
const GRAPH = {
|
|
@@ -22960,6 +22972,7 @@ const startDevServer = async ({
|
|
|
22960
22972
|
transpilation,
|
|
22961
22973
|
explorer = true,
|
|
22962
22974
|
// see jsenv_plugin_explorer.js
|
|
22975
|
+
ribbon = false,
|
|
22963
22976
|
// toolbar = false,
|
|
22964
22977
|
|
|
22965
22978
|
sourcemaps = "inline",
|
|
@@ -23100,6 +23113,7 @@ const startDevServer = async ({
|
|
|
23100
23113
|
clientMainFileUrl,
|
|
23101
23114
|
cooldownBetweenFileEvents,
|
|
23102
23115
|
explorer,
|
|
23116
|
+
ribbon,
|
|
23103
23117
|
sourcemaps,
|
|
23104
23118
|
sourcemapsSourcesProtocol,
|
|
23105
23119
|
sourcemapsSourcesContent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "29.3.0
|
|
3
|
+
"version": "29.3.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@c88/v8-coverage": "0.1.1",
|
|
67
67
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
68
68
|
"@jsenv/abort": "4.2.4",
|
|
69
|
-
"@jsenv/ast": "1.4.
|
|
69
|
+
"@jsenv/ast": "1.4.2",
|
|
70
70
|
"@jsenv/babel-plugins": "1.0.8",
|
|
71
71
|
"@jsenv/filesystem": "4.1.5",
|
|
72
72
|
"@jsenv/importmap": "1.2.1",
|
|
@@ -64,6 +64,7 @@ export const startDevServer = async ({
|
|
|
64
64
|
fileSystemMagicRedirection,
|
|
65
65
|
transpilation,
|
|
66
66
|
explorer = true, // see jsenv_plugin_explorer.js
|
|
67
|
+
ribbon = false,
|
|
67
68
|
// toolbar = false,
|
|
68
69
|
|
|
69
70
|
sourcemaps = "inline",
|
|
@@ -201,6 +202,7 @@ export const startDevServer = async ({
|
|
|
201
202
|
clientMainFileUrl,
|
|
202
203
|
cooldownBetweenFileEvents,
|
|
203
204
|
explorer,
|
|
205
|
+
ribbon,
|
|
204
206
|
sourcemaps,
|
|
205
207
|
sourcemapsSourcesProtocol,
|
|
206
208
|
sourcemapsSourcesContent,
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -100,7 +100,11 @@ export const createKitchen = ({
|
|
|
100
100
|
debug = false,
|
|
101
101
|
}) => {
|
|
102
102
|
if (typeof specifier !== "string") {
|
|
103
|
-
|
|
103
|
+
if (specifier instanceof URL) {
|
|
104
|
+
specifier = specifier.href
|
|
105
|
+
} else {
|
|
106
|
+
throw new TypeError(`"specifier" must be a string, got ${specifier}`)
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
109
|
const reference = {
|
|
106
110
|
original: null,
|
package/src/plugins/plugins.js
CHANGED
|
@@ -67,6 +67,11 @@ export const getCorePlugins = ({
|
|
|
67
67
|
if (ribbon === true) {
|
|
68
68
|
ribbon = {}
|
|
69
69
|
}
|
|
70
|
+
if (ribbon === "dev_and_build") {
|
|
71
|
+
ribbon = {
|
|
72
|
+
devAndBuild: true,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
return [
|
|
72
77
|
jsenvPluginUrlAnalysis({ rootDirectoryUrl, ...urlAnalysis }),
|
|
@@ -108,6 +113,6 @@ export const getCorePlugins = ({
|
|
|
108
113
|
...(explorer
|
|
109
114
|
? [jsenvPluginExplorer({ ...explorer, clientMainFileUrl })]
|
|
110
115
|
: []),
|
|
111
|
-
...(ribbon ? [jsenvPluginRibbon(ribbon)] : []),
|
|
116
|
+
...(ribbon ? [jsenvPluginRibbon({ rootDirectoryUrl, ...ribbon })] : []),
|
|
112
117
|
]
|
|
113
118
|
}
|
|
@@ -5,29 +5,30 @@ import {
|
|
|
5
5
|
injectHtmlNode,
|
|
6
6
|
} from "@jsenv/ast"
|
|
7
7
|
import { URL_META } from "@jsenv/url-meta"
|
|
8
|
+
import { asUrlWithoutSearch } from "@jsenv/urls"
|
|
8
9
|
|
|
9
10
|
export const jsenvPluginRibbon = ({
|
|
11
|
+
rootDirectoryUrl,
|
|
10
12
|
htmlInclude = "**/*.html",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = {}) => {
|
|
13
|
+
devAndBuild = false,
|
|
14
|
+
}) => {
|
|
14
15
|
const ribbonClientFileUrl = new URL("./client/ribbon.js", import.meta.url)
|
|
15
16
|
const associations = URL_META.resolveAssociations(
|
|
16
17
|
{
|
|
17
18
|
ribbon: { [htmlInclude]: true },
|
|
18
19
|
},
|
|
19
|
-
|
|
20
|
+
rootDirectoryUrl,
|
|
20
21
|
)
|
|
21
22
|
return {
|
|
22
23
|
name: "jsenv:ribbon",
|
|
23
24
|
appliesDuring: "*",
|
|
24
|
-
|
|
25
|
+
transformUrlContent: {
|
|
25
26
|
html: (urlInfo, context) => {
|
|
26
|
-
if (context.scenarios.build && !
|
|
27
|
+
if (context.scenarios.build && !devAndBuild) {
|
|
27
28
|
return null
|
|
28
29
|
}
|
|
29
30
|
const { ribbon } = URL_META.applyAssociations({
|
|
30
|
-
url: urlInfo.url,
|
|
31
|
+
url: asUrlWithoutSearch(urlInfo.url),
|
|
31
32
|
associations,
|
|
32
33
|
})
|
|
33
34
|
if (!ribbon) {
|
|
@@ -38,23 +39,22 @@ export const jsenvPluginRibbon = ({
|
|
|
38
39
|
type: "script_src",
|
|
39
40
|
subtype: "js_module",
|
|
40
41
|
expectedType: "js_module",
|
|
41
|
-
specifier: ribbonClientFileUrl,
|
|
42
|
+
specifier: ribbonClientFileUrl.href,
|
|
42
43
|
})
|
|
43
|
-
|
|
44
|
-
text: context.scenarios.dev ? "DEV" : "BUILD",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
injectHtmlNode(
|
|
48
|
-
htmlAst,
|
|
49
|
-
createHtmlNode({
|
|
50
|
-
tagName: "script",
|
|
51
|
-
type: "module",
|
|
52
|
-
content: `
|
|
53
|
-
import { injectRibbon} from ${ribbonClientFileReference.generatedSpecifier}
|
|
54
|
-
|
|
55
|
-
injectRibbon(${JSON.stringify(options, null, " ")})`,
|
|
56
|
-
}),
|
|
44
|
+
const paramsJson = JSON.stringify(
|
|
45
|
+
{ text: context.scenarios.dev ? "DEV" : "BUILD" },
|
|
46
|
+
null,
|
|
47
|
+
" ",
|
|
57
48
|
)
|
|
49
|
+
const scriptNode = createHtmlNode({
|
|
50
|
+
tagName: "script",
|
|
51
|
+
type: "module",
|
|
52
|
+
textContent: `
|
|
53
|
+
import { injectRibbon} from "${ribbonClientFileReference.generatedSpecifier}"
|
|
54
|
+
|
|
55
|
+
injectRibbon(${paramsJson})`,
|
|
56
|
+
})
|
|
57
|
+
injectHtmlNode(htmlAst, scriptNode, "jsenv:ribbon")
|
|
58
58
|
return stringifyHtmlAst(htmlAst)
|
|
59
59
|
},
|
|
60
60
|
},
|