@jsenv/core 29.2.1 → 29.3.0-alpha.1
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/ribbon.js +53 -0
- package/dist/main.js +66 -5
- package/package.json +4 -4
- package/src/build/build.js +2 -0
- package/src/dev/file_service.js +2 -0
- package/src/plugins/plugins.js +8 -6
- package/src/plugins/ribbon/client/ribbon.js +51 -0
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +62 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const injectRibbon = ({
|
|
2
|
+
text
|
|
3
|
+
}) => {
|
|
4
|
+
const css = /* css */`
|
|
5
|
+
#jsenv_ribbon_container {
|
|
6
|
+
position: absolute;
|
|
7
|
+
z-index: 1001;
|
|
8
|
+
top: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
width: 100px;
|
|
11
|
+
height: 100px;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
opacity: 0.5;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
#jsenv_ribbon {
|
|
17
|
+
position: absolute;
|
|
18
|
+
top: -10px;
|
|
19
|
+
right: -10px;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
}
|
|
23
|
+
#jsenv_ribbon_text {
|
|
24
|
+
position: absolute;
|
|
25
|
+
left: 0px;
|
|
26
|
+
top: 20px;
|
|
27
|
+
transform: rotate(45deg);
|
|
28
|
+
display: block;
|
|
29
|
+
width: 125px;
|
|
30
|
+
line-height: 36px;
|
|
31
|
+
background-color: orange;
|
|
32
|
+
color: rgb(55, 7, 7);
|
|
33
|
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
|
|
34
|
+
font-weight: 700;
|
|
35
|
+
font-size: 16px;
|
|
36
|
+
font-family: "Lato", sans-serif;
|
|
37
|
+
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
|
|
38
|
+
text-align: center;
|
|
39
|
+
user-select: none;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const html = /* html */`<div id="jsenv_ribbon_container">
|
|
43
|
+
<style>${css}</style>
|
|
44
|
+
<div id="jsenv_ribbon">
|
|
45
|
+
<div id="jsenv_ribbon_text">${text}</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>`;
|
|
48
|
+
const node = document.createElement("div");
|
|
49
|
+
node.innerHTML = html;
|
|
50
|
+
document.body.appendChild(node.firstChild);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { injectRibbon };
|
package/dist/main.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Readable, Stream, Writable } from "node:stream";
|
|
|
16
16
|
import { Http2ServerResponse } from "node:http2";
|
|
17
17
|
import { lookup } from "node:dns";
|
|
18
18
|
import { SOURCEMAP, generateSourcemapFileUrl, composeTwoSourcemaps, generateSourcemapDataUrl, createMagicSource, sourcemapConverter, getOriginalPosition } from "@jsenv/sourcemap";
|
|
19
|
-
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, applyPostCss, postCssPluginUrlVisitor, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText, transpileWithParcel, injectJsImport, minifyWithParcel, analyzeLinkNode } from "@jsenv/ast";
|
|
19
|
+
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, applyPostCss, postCssPluginUrlVisitor, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText, transpileWithParcel, injectJsImport, minifyWithParcel, analyzeLinkNode, injectHtmlNode } from "@jsenv/ast";
|
|
20
20
|
import { createRequire } from "node:module";
|
|
21
21
|
import babelParser from "@babel/parser";
|
|
22
22
|
import v8, { takeCoverage } from "node:v8";
|
|
@@ -20655,6 +20655,59 @@ const jsenvPluginExplorer = ({
|
|
|
20655
20655
|
};
|
|
20656
20656
|
};
|
|
20657
20657
|
|
|
20658
|
+
const jsenvPluginRibbon = ({
|
|
20659
|
+
htmlInclude = "**/*.html",
|
|
20660
|
+
allowDuringBuild = false,
|
|
20661
|
+
options = {}
|
|
20662
|
+
} = {}) => {
|
|
20663
|
+
const ribbonClientFileUrl = new URL("./js/ribbon.js", import.meta.url);
|
|
20664
|
+
const associations = URL_META.resolveAssociations({
|
|
20665
|
+
ribbon: {
|
|
20666
|
+
[htmlInclude]: true
|
|
20667
|
+
}
|
|
20668
|
+
}, "file://");
|
|
20669
|
+
return {
|
|
20670
|
+
name: "jsenv:ribbon",
|
|
20671
|
+
appliesDuring: "*",
|
|
20672
|
+
transformHtmlContent: {
|
|
20673
|
+
html: (urlInfo, context) => {
|
|
20674
|
+
if (context.scenarios.build && !allowDuringBuild) {
|
|
20675
|
+
return null;
|
|
20676
|
+
}
|
|
20677
|
+
const {
|
|
20678
|
+
ribbon
|
|
20679
|
+
} = URL_META.applyAssociations({
|
|
20680
|
+
url: urlInfo.url,
|
|
20681
|
+
associations
|
|
20682
|
+
});
|
|
20683
|
+
if (!ribbon) {
|
|
20684
|
+
return null;
|
|
20685
|
+
}
|
|
20686
|
+
const htmlAst = parseHtmlString(urlInfo.content);
|
|
20687
|
+
const [ribbonClientFileReference] = context.referenceUtils.inject({
|
|
20688
|
+
type: "script_src",
|
|
20689
|
+
subtype: "js_module",
|
|
20690
|
+
expectedType: "js_module",
|
|
20691
|
+
specifier: ribbonClientFileUrl
|
|
20692
|
+
});
|
|
20693
|
+
options = {
|
|
20694
|
+
text: context.scenarios.dev ? "DEV" : "BUILD",
|
|
20695
|
+
...options
|
|
20696
|
+
};
|
|
20697
|
+
injectHtmlNode(htmlAst, createHtmlNode({
|
|
20698
|
+
tagName: "script",
|
|
20699
|
+
type: "module",
|
|
20700
|
+
content: `
|
|
20701
|
+
import { injectRibbon} from ${ribbonClientFileReference.generatedSpecifier}
|
|
20702
|
+
|
|
20703
|
+
injectRibbon(${JSON.stringify(options, null, " ")})`
|
|
20704
|
+
}));
|
|
20705
|
+
return stringifyHtmlAst(htmlAst);
|
|
20706
|
+
}
|
|
20707
|
+
}
|
|
20708
|
+
};
|
|
20709
|
+
};
|
|
20710
|
+
|
|
20658
20711
|
const getCorePlugins = ({
|
|
20659
20712
|
rootDirectoryUrl,
|
|
20660
20713
|
runtimeCompat,
|
|
@@ -20670,7 +20723,8 @@ const getCorePlugins = ({
|
|
|
20670
20723
|
clientAutoreload = false,
|
|
20671
20724
|
clientFileChangeCallbackList,
|
|
20672
20725
|
clientFilesPruneCallbackList,
|
|
20673
|
-
explorer
|
|
20726
|
+
explorer,
|
|
20727
|
+
ribbon = false
|
|
20674
20728
|
} = {}) => {
|
|
20675
20729
|
if (explorer === true) {
|
|
20676
20730
|
explorer = {};
|
|
@@ -20689,6 +20743,9 @@ const getCorePlugins = ({
|
|
|
20689
20743
|
} else {
|
|
20690
20744
|
clientMainFileUrl = String(clientMainFileUrl);
|
|
20691
20745
|
}
|
|
20746
|
+
if (ribbon === true) {
|
|
20747
|
+
ribbon = {};
|
|
20748
|
+
}
|
|
20692
20749
|
return [jsenvPluginUrlAnalysis({
|
|
20693
20750
|
rootDirectoryUrl,
|
|
20694
20751
|
...urlAnalysis
|
|
@@ -20715,7 +20772,7 @@ const getCorePlugins = ({
|
|
|
20715
20772
|
})] : []), jsenvPluginCacheControl(), ...(explorer ? [jsenvPluginExplorer({
|
|
20716
20773
|
...explorer,
|
|
20717
20774
|
clientMainFileUrl
|
|
20718
|
-
})] : [])];
|
|
20775
|
+
})] : []), ...(ribbon ? [jsenvPluginRibbon(ribbon)] : [])];
|
|
20719
20776
|
};
|
|
20720
20777
|
|
|
20721
20778
|
const GRAPH = {
|
|
@@ -21077,6 +21134,7 @@ const build = async ({
|
|
|
21077
21134
|
versioningMethod = "search_param",
|
|
21078
21135
|
// "filename", "search_param"
|
|
21079
21136
|
lineBreakNormalization = process.platform === "win32",
|
|
21137
|
+
ribbon,
|
|
21080
21138
|
clientFiles = {
|
|
21081
21139
|
"./src/": true
|
|
21082
21140
|
},
|
|
@@ -21166,7 +21224,8 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21166
21224
|
jsClassicFallback: false
|
|
21167
21225
|
},
|
|
21168
21226
|
minification,
|
|
21169
|
-
bundling
|
|
21227
|
+
bundling,
|
|
21228
|
+
ribbon
|
|
21170
21229
|
})],
|
|
21171
21230
|
sourcemaps,
|
|
21172
21231
|
sourcemapsSourcesContent,
|
|
@@ -22447,6 +22506,7 @@ const createFileService = ({
|
|
|
22447
22506
|
clientMainFileUrl,
|
|
22448
22507
|
cooldownBetweenFileEvents,
|
|
22449
22508
|
explorer,
|
|
22509
|
+
ribbon,
|
|
22450
22510
|
sourcemaps,
|
|
22451
22511
|
sourcemapsSourcesProtocol,
|
|
22452
22512
|
sourcemapsSourcesContent,
|
|
@@ -22550,7 +22610,8 @@ const createFileService = ({
|
|
|
22550
22610
|
clientAutoreload,
|
|
22551
22611
|
clientFileChangeCallbackList,
|
|
22552
22612
|
clientFilesPruneCallbackList,
|
|
22553
|
-
explorer
|
|
22613
|
+
explorer,
|
|
22614
|
+
ribbon
|
|
22554
22615
|
})],
|
|
22555
22616
|
sourcemaps,
|
|
22556
22617
|
sourcemapsSourcesProtocol,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.3.0-alpha.1",
|
|
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.
|
|
69
|
+
"@jsenv/ast": "1.4.1",
|
|
70
70
|
"@jsenv/babel-plugins": "1.0.8",
|
|
71
71
|
"@jsenv/filesystem": "4.1.5",
|
|
72
72
|
"@jsenv/importmap": "1.2.1",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@babel/eslint-parser": "7.19.1",
|
|
101
101
|
"@babel/plugin-syntax-import-assertions": "7.18.6",
|
|
102
|
-
"@jsenv/assert": "
|
|
103
|
-
"@jsenv/eslint-config": "
|
|
102
|
+
"@jsenv/assert": "./packages/assert/",
|
|
103
|
+
"@jsenv/eslint-config": "./packages/eslint-config/",
|
|
104
104
|
"@jsenv/file-size-impact": "13.0.1",
|
|
105
105
|
"@jsenv/https-local": "3.0.1",
|
|
106
106
|
"@jsenv/package-workspace": "0.5.0",
|
package/src/build/build.js
CHANGED
|
@@ -132,6 +132,7 @@ export const build = async ({
|
|
|
132
132
|
versioning = true,
|
|
133
133
|
versioningMethod = "search_param", // "filename", "search_param"
|
|
134
134
|
lineBreakNormalization = process.platform === "win32",
|
|
135
|
+
ribbon,
|
|
135
136
|
|
|
136
137
|
clientFiles = {
|
|
137
138
|
"./src/": true,
|
|
@@ -231,6 +232,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
231
232
|
},
|
|
232
233
|
minification,
|
|
233
234
|
bundling,
|
|
235
|
+
ribbon,
|
|
234
236
|
}),
|
|
235
237
|
],
|
|
236
238
|
sourcemaps,
|
package/src/dev/file_service.js
CHANGED
|
@@ -35,6 +35,7 @@ export const createFileService = ({
|
|
|
35
35
|
clientMainFileUrl,
|
|
36
36
|
cooldownBetweenFileEvents,
|
|
37
37
|
explorer,
|
|
38
|
+
ribbon,
|
|
38
39
|
sourcemaps,
|
|
39
40
|
sourcemapsSourcesProtocol,
|
|
40
41
|
sourcemapsSourcesContent,
|
|
@@ -138,6 +139,7 @@ export const createFileService = ({
|
|
|
138
139
|
clientFileChangeCallbackList,
|
|
139
140
|
clientFilesPruneCallbackList,
|
|
140
141
|
explorer,
|
|
142
|
+
ribbon,
|
|
141
143
|
}),
|
|
142
144
|
],
|
|
143
145
|
sourcemaps,
|
package/src/plugins/plugins.js
CHANGED
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
explorerHtmlFileUrl,
|
|
23
23
|
jsenvPluginExplorer,
|
|
24
24
|
} from "./explorer/jsenv_plugin_explorer.js"
|
|
25
|
+
// other
|
|
26
|
+
import { jsenvPluginRibbon } from "./ribbon/jsenv_plugin_ribbon.js"
|
|
25
27
|
|
|
26
28
|
export const getCorePlugins = ({
|
|
27
29
|
rootDirectoryUrl,
|
|
@@ -41,6 +43,7 @@ export const getCorePlugins = ({
|
|
|
41
43
|
clientFileChangeCallbackList,
|
|
42
44
|
clientFilesPruneCallbackList,
|
|
43
45
|
explorer,
|
|
46
|
+
ribbon = false,
|
|
44
47
|
} = {}) => {
|
|
45
48
|
if (explorer === true) {
|
|
46
49
|
explorer = {}
|
|
@@ -61,6 +64,9 @@ export const getCorePlugins = ({
|
|
|
61
64
|
} else {
|
|
62
65
|
clientMainFileUrl = String(clientMainFileUrl)
|
|
63
66
|
}
|
|
67
|
+
if (ribbon === true) {
|
|
68
|
+
ribbon = {}
|
|
69
|
+
}
|
|
64
70
|
|
|
65
71
|
return [
|
|
66
72
|
jsenvPluginUrlAnalysis({ rootDirectoryUrl, ...urlAnalysis }),
|
|
@@ -100,12 +106,8 @@ export const getCorePlugins = ({
|
|
|
100
106
|
: []),
|
|
101
107
|
jsenvPluginCacheControl(),
|
|
102
108
|
...(explorer
|
|
103
|
-
? [
|
|
104
|
-
jsenvPluginExplorer({
|
|
105
|
-
...explorer,
|
|
106
|
-
clientMainFileUrl,
|
|
107
|
-
}),
|
|
108
|
-
]
|
|
109
|
+
? [jsenvPluginExplorer({ ...explorer, clientMainFileUrl })]
|
|
109
110
|
: []),
|
|
111
|
+
...(ribbon ? [jsenvPluginRibbon(ribbon)] : []),
|
|
110
112
|
]
|
|
111
113
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const injectRibbon = ({ text }) => {
|
|
2
|
+
const css = /* css */ `
|
|
3
|
+
#jsenv_ribbon_container {
|
|
4
|
+
position: absolute;
|
|
5
|
+
z-index: 1001;
|
|
6
|
+
top: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
width: 100px;
|
|
9
|
+
height: 100px;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
opacity: 0.5;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
}
|
|
14
|
+
#jsenv_ribbon {
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: -10px;
|
|
17
|
+
right: -10px;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
#jsenv_ribbon_text {
|
|
22
|
+
position: absolute;
|
|
23
|
+
left: 0px;
|
|
24
|
+
top: 20px;
|
|
25
|
+
transform: rotate(45deg);
|
|
26
|
+
display: block;
|
|
27
|
+
width: 125px;
|
|
28
|
+
line-height: 36px;
|
|
29
|
+
background-color: orange;
|
|
30
|
+
color: rgb(55, 7, 7);
|
|
31
|
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
|
|
32
|
+
font-weight: 700;
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
font-family: "Lato", sans-serif;
|
|
35
|
+
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
|
|
36
|
+
text-align: center;
|
|
37
|
+
user-select: none;
|
|
38
|
+
}
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
const html = /* html */ `<div id="jsenv_ribbon_container">
|
|
42
|
+
<style>${css}</style>
|
|
43
|
+
<div id="jsenv_ribbon">
|
|
44
|
+
<div id="jsenv_ribbon_text">${text}</span>
|
|
45
|
+
</div>
|
|
46
|
+
</div>`
|
|
47
|
+
|
|
48
|
+
const node = document.createElement("div")
|
|
49
|
+
node.innerHTML = html
|
|
50
|
+
document.body.appendChild(node.firstChild)
|
|
51
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseHtmlString,
|
|
3
|
+
stringifyHtmlAst,
|
|
4
|
+
createHtmlNode,
|
|
5
|
+
injectHtmlNode,
|
|
6
|
+
} from "@jsenv/ast"
|
|
7
|
+
import { URL_META } from "@jsenv/url-meta"
|
|
8
|
+
|
|
9
|
+
export const jsenvPluginRibbon = ({
|
|
10
|
+
htmlInclude = "**/*.html",
|
|
11
|
+
allowDuringBuild = false,
|
|
12
|
+
options = {},
|
|
13
|
+
} = {}) => {
|
|
14
|
+
const ribbonClientFileUrl = new URL("./client/ribbon.js", import.meta.url)
|
|
15
|
+
const associations = URL_META.resolveAssociations(
|
|
16
|
+
{
|
|
17
|
+
ribbon: { [htmlInclude]: true },
|
|
18
|
+
},
|
|
19
|
+
"file://",
|
|
20
|
+
)
|
|
21
|
+
return {
|
|
22
|
+
name: "jsenv:ribbon",
|
|
23
|
+
appliesDuring: "*",
|
|
24
|
+
transformHtmlContent: {
|
|
25
|
+
html: (urlInfo, context) => {
|
|
26
|
+
if (context.scenarios.build && !allowDuringBuild) {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
const { ribbon } = URL_META.applyAssociations({
|
|
30
|
+
url: urlInfo.url,
|
|
31
|
+
associations,
|
|
32
|
+
})
|
|
33
|
+
if (!ribbon) {
|
|
34
|
+
return null
|
|
35
|
+
}
|
|
36
|
+
const htmlAst = parseHtmlString(urlInfo.content)
|
|
37
|
+
const [ribbonClientFileReference] = context.referenceUtils.inject({
|
|
38
|
+
type: "script_src",
|
|
39
|
+
subtype: "js_module",
|
|
40
|
+
expectedType: "js_module",
|
|
41
|
+
specifier: ribbonClientFileUrl,
|
|
42
|
+
})
|
|
43
|
+
options = {
|
|
44
|
+
text: context.scenarios.dev ? "DEV" : "BUILD",
|
|
45
|
+
...options,
|
|
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
|
+
}),
|
|
57
|
+
)
|
|
58
|
+
return stringifyHtmlAst(htmlAst)
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
}
|