@jsenv/core 37.1.1 → 37.1.3
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/jsenv_core.js
CHANGED
|
@@ -12108,6 +12108,16 @@ const createPluginController = (kitchenContext) => {
|
|
|
12108
12108
|
});
|
|
12109
12109
|
};
|
|
12110
12110
|
|
|
12111
|
+
const getPluginMeta = (id) => {
|
|
12112
|
+
for (const plugin of plugins) {
|
|
12113
|
+
const { meta } = plugin;
|
|
12114
|
+
if (meta && meta[id] !== undefined) {
|
|
12115
|
+
return meta[id];
|
|
12116
|
+
}
|
|
12117
|
+
}
|
|
12118
|
+
return undefined;
|
|
12119
|
+
};
|
|
12120
|
+
|
|
12111
12121
|
return {
|
|
12112
12122
|
plugins,
|
|
12113
12123
|
pushPlugin,
|
|
@@ -12121,6 +12131,8 @@ const createPluginController = (kitchenContext) => {
|
|
|
12121
12131
|
callAsyncHooks,
|
|
12122
12132
|
callAsyncHooksUntil,
|
|
12123
12133
|
|
|
12134
|
+
getPluginMeta,
|
|
12135
|
+
|
|
12124
12136
|
getLastPluginUsed: () => lastPluginUsed,
|
|
12125
12137
|
getCurrentPlugin: () => currentPlugin,
|
|
12126
12138
|
getCurrentHookName: () => currentHookName,
|
|
@@ -13150,6 +13162,7 @@ const createKitchen = ({
|
|
|
13150
13162
|
inlineContentClientFileUrl,
|
|
13151
13163
|
isSupportedOnCurrentClients: memoizeIsSupported(clientRuntimeCompat),
|
|
13152
13164
|
isSupportedOnFutureClients: memoizeIsSupported(runtimeCompat),
|
|
13165
|
+
getPluginMeta: null,
|
|
13153
13166
|
sourcemaps,
|
|
13154
13167
|
outDirectoryUrl,
|
|
13155
13168
|
},
|
|
@@ -13169,6 +13182,9 @@ const createKitchen = ({
|
|
|
13169
13182
|
|
|
13170
13183
|
const pluginController = createPluginController(kitchenContext);
|
|
13171
13184
|
kitchen.pluginController = pluginController;
|
|
13185
|
+
kitchenContext.getPluginMeta = memoizeGetPluginMeta(
|
|
13186
|
+
pluginController.getPluginMeta,
|
|
13187
|
+
);
|
|
13172
13188
|
plugins.forEach((pluginEntry) => {
|
|
13173
13189
|
pluginController.pushPlugin(pluginEntry);
|
|
13174
13190
|
});
|
|
@@ -13695,6 +13711,19 @@ const memoizeCook = (cook) => {
|
|
|
13695
13711
|
};
|
|
13696
13712
|
};
|
|
13697
13713
|
|
|
13714
|
+
const memoizeGetPluginMeta = (getPluginMeta) => {
|
|
13715
|
+
const cache = new Map();
|
|
13716
|
+
return (id) => {
|
|
13717
|
+
const fromCache = cache.get(id);
|
|
13718
|
+
if (fromCache) {
|
|
13719
|
+
return fromCache;
|
|
13720
|
+
}
|
|
13721
|
+
const value = getPluginMeta(id);
|
|
13722
|
+
cache.set(id, value);
|
|
13723
|
+
return value;
|
|
13724
|
+
};
|
|
13725
|
+
};
|
|
13726
|
+
|
|
13698
13727
|
const memoizeIsSupported = (runtimeCompat) => {
|
|
13699
13728
|
const cache = new Map();
|
|
13700
13729
|
return (feature, featureCompat) => {
|
|
@@ -18703,7 +18732,14 @@ const jsenvPluginRibbon = ({
|
|
|
18703
18732
|
appliesDuring: "dev",
|
|
18704
18733
|
transformUrlContent: {
|
|
18705
18734
|
html: (urlInfo) => {
|
|
18706
|
-
|
|
18735
|
+
const jsenvToolbarHtmlClientFileUrl = urlInfo.context.getPluginMeta(
|
|
18736
|
+
"jsenvToolbarHtmlClientFileUrl",
|
|
18737
|
+
);
|
|
18738
|
+
if (
|
|
18739
|
+
jsenvToolbarHtmlClientFileUrl &&
|
|
18740
|
+
// startsWith to ignore search params
|
|
18741
|
+
urlInfo.url.startsWith(jsenvToolbarHtmlClientFileUrl)
|
|
18742
|
+
) {
|
|
18707
18743
|
return null;
|
|
18708
18744
|
}
|
|
18709
18745
|
const { ribbon } = URL_META.applyAssociations({
|
|
@@ -19044,7 +19080,9 @@ const injectVersionMappingsAsGlobal = async (
|
|
|
19044
19080
|
type: "js_classic",
|
|
19045
19081
|
content: generateClientCodeForVersionMappings(versionMappings, {
|
|
19046
19082
|
globalName: "window",
|
|
19047
|
-
minification:
|
|
19083
|
+
minification: Boolean(
|
|
19084
|
+
urlInfo.context.getPluginMeta("willMinifyJsClassic"),
|
|
19085
|
+
),
|
|
19048
19086
|
}),
|
|
19049
19087
|
});
|
|
19050
19088
|
return;
|
|
@@ -19054,7 +19092,9 @@ const injectVersionMappingsAsGlobal = async (
|
|
|
19054
19092
|
type: "js_classic",
|
|
19055
19093
|
content: generateClientCodeForVersionMappings(versionMappings, {
|
|
19056
19094
|
globalName: isWebWorkerUrlInfo(urlInfo) ? "self" : "window",
|
|
19057
|
-
minification:
|
|
19095
|
+
minification: Boolean(
|
|
19096
|
+
urlInfo.context.getPluginMeta("willMinifyJsClassic"),
|
|
19097
|
+
),
|
|
19058
19098
|
}),
|
|
19059
19099
|
});
|
|
19060
19100
|
return;
|
|
@@ -19087,12 +19127,15 @@ const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
|
|
|
19087
19127
|
// jsenv_plugin_importmap.js is removing importmap during build
|
|
19088
19128
|
// it means at this point we know HTML has no importmap in it
|
|
19089
19129
|
// we can safely inject one
|
|
19130
|
+
const importmapMinification = Boolean(
|
|
19131
|
+
urlInfo.context.getPluginMeta("willMinifyJson"),
|
|
19132
|
+
);
|
|
19090
19133
|
injectHtmlNodeAsEarlyAsPossible(
|
|
19091
19134
|
htmlAst,
|
|
19092
19135
|
createHtmlNode({
|
|
19093
19136
|
tagName: "script",
|
|
19094
19137
|
type: "importmap",
|
|
19095
|
-
textContent:
|
|
19138
|
+
textContent: importmapMinification
|
|
19096
19139
|
? JSON.stringify({ imports: versionMappings })
|
|
19097
19140
|
: JSON.stringify({ imports: versionMappings }, null, " "),
|
|
19098
19141
|
}),
|
|
@@ -19847,9 +19890,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
19847
19890
|
return true;
|
|
19848
19891
|
return false;
|
|
19849
19892
|
})(),
|
|
19850
|
-
minification: plugins.some(
|
|
19851
|
-
(plugin) => plugin.name === "jsenv:minification",
|
|
19852
|
-
),
|
|
19853
19893
|
};
|
|
19854
19894
|
const rawKitchen = createKitchen({
|
|
19855
19895
|
signal,
|
package/package.json
CHANGED
package/src/build/build.js
CHANGED
|
@@ -19,7 +19,9 @@ export const injectVersionMappingsAsGlobal = async (
|
|
|
19
19
|
type: "js_classic",
|
|
20
20
|
content: generateClientCodeForVersionMappings(versionMappings, {
|
|
21
21
|
globalName: "window",
|
|
22
|
-
minification:
|
|
22
|
+
minification: Boolean(
|
|
23
|
+
urlInfo.context.getPluginMeta("willMinifyJsClassic"),
|
|
24
|
+
),
|
|
23
25
|
}),
|
|
24
26
|
});
|
|
25
27
|
return;
|
|
@@ -29,7 +31,9 @@ export const injectVersionMappingsAsGlobal = async (
|
|
|
29
31
|
type: "js_classic",
|
|
30
32
|
content: generateClientCodeForVersionMappings(versionMappings, {
|
|
31
33
|
globalName: isWebWorkerUrlInfo(urlInfo) ? "self" : "window",
|
|
32
|
-
minification:
|
|
34
|
+
minification: Boolean(
|
|
35
|
+
urlInfo.context.getPluginMeta("willMinifyJsClassic"),
|
|
36
|
+
),
|
|
33
37
|
}),
|
|
34
38
|
});
|
|
35
39
|
return;
|
|
@@ -62,12 +66,15 @@ export const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
|
|
|
62
66
|
// jsenv_plugin_importmap.js is removing importmap during build
|
|
63
67
|
// it means at this point we know HTML has no importmap in it
|
|
64
68
|
// we can safely inject one
|
|
69
|
+
const importmapMinification = Boolean(
|
|
70
|
+
urlInfo.context.getPluginMeta("willMinifyJson"),
|
|
71
|
+
);
|
|
65
72
|
injectHtmlNodeAsEarlyAsPossible(
|
|
66
73
|
htmlAst,
|
|
67
74
|
createHtmlNode({
|
|
68
75
|
tagName: "script",
|
|
69
76
|
type: "importmap",
|
|
70
|
-
textContent:
|
|
77
|
+
textContent: importmapMinification
|
|
71
78
|
? JSON.stringify({ imports: versionMappings })
|
|
72
79
|
: JSON.stringify({ imports: versionMappings }, null, " "),
|
|
73
80
|
}),
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -70,6 +70,7 @@ export const createKitchen = ({
|
|
|
70
70
|
inlineContentClientFileUrl,
|
|
71
71
|
isSupportedOnCurrentClients: memoizeIsSupported(clientRuntimeCompat),
|
|
72
72
|
isSupportedOnFutureClients: memoizeIsSupported(runtimeCompat),
|
|
73
|
+
getPluginMeta: null,
|
|
73
74
|
sourcemaps,
|
|
74
75
|
outDirectoryUrl,
|
|
75
76
|
},
|
|
@@ -89,6 +90,9 @@ export const createKitchen = ({
|
|
|
89
90
|
|
|
90
91
|
const pluginController = createPluginController(kitchenContext);
|
|
91
92
|
kitchen.pluginController = pluginController;
|
|
93
|
+
kitchenContext.getPluginMeta = memoizeGetPluginMeta(
|
|
94
|
+
pluginController.getPluginMeta,
|
|
95
|
+
);
|
|
92
96
|
plugins.forEach((pluginEntry) => {
|
|
93
97
|
pluginController.pushPlugin(pluginEntry);
|
|
94
98
|
});
|
|
@@ -615,6 +619,19 @@ const memoizeCook = (cook) => {
|
|
|
615
619
|
};
|
|
616
620
|
};
|
|
617
621
|
|
|
622
|
+
const memoizeGetPluginMeta = (getPluginMeta) => {
|
|
623
|
+
const cache = new Map();
|
|
624
|
+
return (id) => {
|
|
625
|
+
const fromCache = cache.get(id);
|
|
626
|
+
if (fromCache) {
|
|
627
|
+
return fromCache;
|
|
628
|
+
}
|
|
629
|
+
const value = getPluginMeta(id);
|
|
630
|
+
cache.set(id, value);
|
|
631
|
+
return value;
|
|
632
|
+
};
|
|
633
|
+
};
|
|
634
|
+
|
|
618
635
|
const memoizeIsSupported = (runtimeCompat) => {
|
|
619
636
|
const cache = new Map();
|
|
620
637
|
return (feature, featureCompat) => {
|
|
@@ -251,6 +251,16 @@ export const createPluginController = (kitchenContext) => {
|
|
|
251
251
|
});
|
|
252
252
|
};
|
|
253
253
|
|
|
254
|
+
const getPluginMeta = (id) => {
|
|
255
|
+
for (const plugin of plugins) {
|
|
256
|
+
const { meta } = plugin;
|
|
257
|
+
if (meta && meta[id] !== undefined) {
|
|
258
|
+
return meta[id];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
};
|
|
263
|
+
|
|
254
264
|
return {
|
|
255
265
|
plugins,
|
|
256
266
|
pushPlugin,
|
|
@@ -264,6 +274,8 @@ export const createPluginController = (kitchenContext) => {
|
|
|
264
274
|
callAsyncHooks,
|
|
265
275
|
callAsyncHooksUntil,
|
|
266
276
|
|
|
277
|
+
getPluginMeta,
|
|
278
|
+
|
|
267
279
|
getLastPluginUsed: () => lastPluginUsed,
|
|
268
280
|
getCurrentPlugin: () => currentPlugin,
|
|
269
281
|
getCurrentHookName: () => currentHookName,
|
|
@@ -25,7 +25,14 @@ export const jsenvPluginRibbon = ({
|
|
|
25
25
|
appliesDuring: "dev",
|
|
26
26
|
transformUrlContent: {
|
|
27
27
|
html: (urlInfo) => {
|
|
28
|
-
|
|
28
|
+
const jsenvToolbarHtmlClientFileUrl = urlInfo.context.getPluginMeta(
|
|
29
|
+
"jsenvToolbarHtmlClientFileUrl",
|
|
30
|
+
);
|
|
31
|
+
if (
|
|
32
|
+
jsenvToolbarHtmlClientFileUrl &&
|
|
33
|
+
// startsWith to ignore search params
|
|
34
|
+
urlInfo.url.startsWith(jsenvToolbarHtmlClientFileUrl)
|
|
35
|
+
) {
|
|
29
36
|
return null;
|
|
30
37
|
}
|
|
31
38
|
const { ribbon } = URL_META.applyAssociations({
|