@jsenv/core 35.0.3 → 35.0.5
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/html/explorer.html +107 -107
- package/dist/js/new_stylesheet.js +3 -0
- package/dist/js/s.js.map +3 -3
- package/package.json +2 -2
- package/src/build/build.js +589 -587
- package/src/build/build_urls_generator.js +44 -44
- package/src/build/graph_utils.js +14 -14
- package/src/build/jsenv_plugin_line_break_normalization.js +6 -6
- package/src/build/line_break_unix.js +11 -11
- package/src/build/start_build_server.js +37 -37
- package/src/build/version_generator.js +7 -7
- package/src/build/version_mappings_injection.js +23 -23
- package/src/dev/file_service.js +132 -132
- package/src/dev/start_dev_server.js +56 -56
- package/src/dev/user_agent.js +8 -8
- package/src/helpers/basic_fetch.js +24 -24
- package/src/helpers/command/command.js +28 -28
- package/src/helpers/lookup_package_directory.js +19 -16
- package/src/helpers/ping_server.js +17 -17
- package/src/helpers/require_from_jsenv.js +2 -2
- package/src/helpers/watch_source_files.js +9 -9
- package/src/helpers/web_url_converter.js +10 -10
- package/src/helpers/worker_reload.js +27 -27
- package/src/kitchen/compat/features_compatibility.js +1 -1
- package/src/kitchen/compat/runtime_compat.js +26 -24
- package/src/kitchen/errors.js +75 -75
- package/src/kitchen/fetched_content_compliance.js +8 -8
- package/src/kitchen/kitchen.js +251 -250
- package/src/kitchen/url_graph/sort_by_dependencies.js +17 -17
- package/src/kitchen/url_graph/url_graph_loader.js +30 -30
- package/src/kitchen/url_graph/url_graph_report.js +57 -57
- package/src/kitchen/url_graph/url_info_transformations.js +77 -77
- package/src/kitchen/url_graph.js +121 -121
- package/src/kitchen/url_specifier_encoding.js +21 -21
- package/src/kitchen/web_workers.js +5 -5
- package/src/main.js +3 -3
- package/src/plugins/autoreload/client/autoreload.js +96 -96
- package/src/plugins/autoreload/client/reload.js +56 -56
- package/src/plugins/autoreload/client/url_helpers.js +13 -13
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +5 -5
- package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +9 -9
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +61 -60
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +15 -15
- package/src/plugins/cache_control/jsenv_plugin_cache_control.js +5 -5
- package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +57 -57
- package/src/plugins/explorer/client/explorer.html +107 -107
- package/src/plugins/explorer/jsenv_plugin_explorer.js +20 -20
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +60 -60
- package/src/plugins/global_scenarios/jsenv_plugin_global_scenarios.js +5 -5
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +3 -3
- package/src/plugins/import_meta_hot/babel_plugin_metadata_import_meta_hot.js +35 -35
- package/src/plugins/import_meta_hot/client/import_meta_hot.js +26 -26
- package/src/plugins/import_meta_hot/html_hot_dependencies.js +43 -43
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +44 -40
- package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +35 -35
- package/src/plugins/import_meta_url/client/import_meta_url_browser.js +21 -21
- package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +3 -3
- package/src/plugins/importmap/jsenv_plugin_importmap.js +54 -54
- package/src/plugins/inline_content_analysis/client/inline_content.js +3 -3
- package/src/plugins/inline_content_analysis/jsenv_plugin_data_urls.js +26 -26
- package/src/plugins/inline_content_analysis/jsenv_plugin_html_inline_content_analysis.js +47 -47
- package/src/plugins/inline_content_analysis/jsenv_plugin_inline_content_analysis.js +9 -9
- package/src/plugins/inline_content_analysis/jsenv_plugin_js_inline_content_analysis.js +101 -101
- package/src/plugins/inlining/jsenv_plugin_inlining.js +9 -9
- package/src/plugins/inlining/jsenv_plugin_inlining_as_data_url.js +11 -11
- package/src/plugins/inlining/jsenv_plugin_inlining_into_html.js +48 -46
- package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +4 -4
- package/src/plugins/plugin_controller.js +124 -124
- package/src/plugins/plugins.js +27 -27
- package/src/plugins/ribbon/client/ribbon.js +6 -6
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +15 -15
- package/src/plugins/server_events/client/connection_manager.js +52 -52
- package/src/plugins/server_events/client/event_source_connection.js +36 -36
- package/src/plugins/server_events/client/events_manager.js +37 -37
- package/src/plugins/server_events/client/server_events_client.js +7 -7
- package/src/plugins/server_events/client/web_socket_connection.js +39 -39
- package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +9 -9
- package/src/plugins/server_events/server_events_dispatcher.js +43 -43
- package/src/plugins/supervisor/client/supervisor.js +455 -450
- package/src/plugins/supervisor/html_supervisor_injection.js +64 -62
- package/src/plugins/supervisor/js_supervisor_injection.js +67 -67
- package/src/plugins/supervisor/jsenv_plugin_supervisor.js +54 -51
- package/src/plugins/transpilation/as_js_module/convert_js_classic_to_js_module.js +13 -13
- package/src/plugins/transpilation/as_js_module/jsenv_plugin_as_js_module.js +19 -19
- package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +10 -10
- package/src/plugins/transpilation/babel/global_this/client/global_this.js +8 -8
- package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +16 -16
- package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +36 -36
- package/src/plugins/transpilation/babel/helpers/babel_plugins_compatibility.js +3 -3
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +24 -24
- package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +44 -44
- package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +166 -166
- package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +10 -10
- package/src/plugins/transpilation/babel/require_babel_plugin.js +6 -6
- package/src/plugins/transpilation/css/jsenv_plugin_css_transpilation.js +20 -20
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +62 -62
- package/src/plugins/transpilation/js_module_fallback/client/s.js +214 -209
- package/src/plugins/transpilation/js_module_fallback/convert_js_module_to_js_classic.js +45 -45
- package/src/plugins/transpilation/js_module_fallback/helpers/babel_plugin_transform_import_meta_resolve.js +6 -6
- package/src/plugins/transpilation/js_module_fallback/helpers/babel_plugin_transform_import_meta_url.js +17 -17
- package/src/plugins/transpilation/js_module_fallback/helpers-string.js +1 -1
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_conversion.js +32 -32
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback.js +17 -17
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +63 -63
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js +15 -15
- package/src/plugins/transpilation/jsenv_plugin_import_meta_resolve.js +20 -20
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +23 -23
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +11 -11
- package/src/plugins/url_analysis/css/css_urls.js +12 -12
- package/src/plugins/url_analysis/html/html_urls.js +85 -85
- package/src/plugins/url_analysis/js/js_urls.js +16 -16
- package/src/plugins/url_analysis/jsenv_plugin_reference_expected_types.js +16 -16
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +40 -40
- package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +12 -12
- package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +35 -35
- package/src/plugins/url_resolution/node_esm_resolver.js +26 -26
- package/src/plugins/url_version/jsenv_plugin_url_version.js +11 -11
|
@@ -10,58 +10,58 @@
|
|
|
10
10
|
* But for now (as it is simpler) we let the browser throw the error
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { urlToFilename, injectQueryParams } from "@jsenv/urls"
|
|
13
|
+
import { urlToFilename, injectQueryParams } from "@jsenv/urls";
|
|
14
14
|
|
|
15
|
-
import { JS_QUOTES } from "@jsenv/utils/src/string/js_quotes.js"
|
|
15
|
+
import { JS_QUOTES } from "@jsenv/utils/src/string/js_quotes.js";
|
|
16
16
|
|
|
17
17
|
export const jsenvPluginImportAssertions = ({
|
|
18
18
|
json = "auto",
|
|
19
19
|
css = "auto",
|
|
20
20
|
text = "auto",
|
|
21
21
|
}) => {
|
|
22
|
-
const transpilations = { json, css, text }
|
|
22
|
+
const transpilations = { json, css, text };
|
|
23
23
|
const shouldTranspileImportAssertion = (context, type) => {
|
|
24
|
-
const transpilation = transpilations[type]
|
|
24
|
+
const transpilation = transpilations[type];
|
|
25
25
|
if (transpilation === true) {
|
|
26
|
-
return true
|
|
26
|
+
return true;
|
|
27
27
|
}
|
|
28
28
|
if (transpilation === "auto") {
|
|
29
|
-
return !context.isSupportedOnCurrentClients(`import_type_${type}`)
|
|
29
|
+
return !context.isSupportedOnCurrentClients(`import_type_${type}`);
|
|
30
30
|
}
|
|
31
|
-
return false
|
|
32
|
-
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
33
|
const markAsJsModuleProxy = (reference) => {
|
|
34
|
-
reference.expectedType = "js_module"
|
|
35
|
-
reference.filename = `${urlToFilename(reference.url)}.js
|
|
36
|
-
}
|
|
34
|
+
reference.expectedType = "js_module";
|
|
35
|
+
reference.filename = `${urlToFilename(reference.url)}.js`;
|
|
36
|
+
};
|
|
37
37
|
const turnIntoJsModuleProxy = (reference, type) => {
|
|
38
38
|
reference.mutation = (magicSource) => {
|
|
39
|
-
const { assertNode } = reference
|
|
39
|
+
const { assertNode } = reference;
|
|
40
40
|
if (reference.subtype === "import_dynamic") {
|
|
41
41
|
const assertPropertyNode = assertNode.properties.find(
|
|
42
42
|
(prop) => prop.key.name === "assert",
|
|
43
|
-
)
|
|
44
|
-
const assertPropertyValue = assertPropertyNode.value
|
|
43
|
+
);
|
|
44
|
+
const assertPropertyValue = assertPropertyNode.value;
|
|
45
45
|
const typePropertyNode = assertPropertyValue.properties.find(
|
|
46
46
|
(prop) => prop.key.name === "type",
|
|
47
|
-
)
|
|
47
|
+
);
|
|
48
48
|
magicSource.remove({
|
|
49
49
|
start: typePropertyNode.start,
|
|
50
50
|
end: typePropertyNode.end,
|
|
51
|
-
})
|
|
51
|
+
});
|
|
52
52
|
} else {
|
|
53
53
|
magicSource.remove({
|
|
54
54
|
start: assertNode.start,
|
|
55
55
|
end: assertNode.end,
|
|
56
|
-
})
|
|
56
|
+
});
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
59
|
const newUrl = injectQueryParams(reference.url, {
|
|
60
60
|
[`as_${type}_module`]: "",
|
|
61
|
-
})
|
|
62
|
-
markAsJsModuleProxy(reference)
|
|
63
|
-
return newUrl
|
|
64
|
-
}
|
|
61
|
+
});
|
|
62
|
+
markAsJsModuleProxy(reference);
|
|
63
|
+
return newUrl;
|
|
64
|
+
};
|
|
65
65
|
|
|
66
66
|
const importAssertions = {
|
|
67
67
|
name: "jsenv:import_assertions",
|
|
@@ -73,39 +73,39 @@ export const jsenvPluginImportAssertions = ({
|
|
|
73
73
|
// - means rollup can bundle more js file together
|
|
74
74
|
// - means url versioning can work for css inlined in js
|
|
75
75
|
if (context.build) {
|
|
76
|
-
transpilations.json = true
|
|
77
|
-
transpilations.css = true
|
|
78
|
-
transpilations.text = true
|
|
76
|
+
transpilations.json = true;
|
|
77
|
+
transpilations.css = true;
|
|
78
|
+
transpilations.text = true;
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
redirectUrl: (reference, context) => {
|
|
82
82
|
if (!reference.assert) {
|
|
83
|
-
return null
|
|
83
|
+
return null;
|
|
84
84
|
}
|
|
85
|
-
const { searchParams } = reference
|
|
85
|
+
const { searchParams } = reference;
|
|
86
86
|
if (
|
|
87
87
|
searchParams.has("as_json_module") ||
|
|
88
88
|
searchParams.has("as_css_module") ||
|
|
89
89
|
searchParams.has("as_text_module")
|
|
90
90
|
) {
|
|
91
|
-
markAsJsModuleProxy(reference)
|
|
92
|
-
return null
|
|
91
|
+
markAsJsModuleProxy(reference);
|
|
92
|
+
return null;
|
|
93
93
|
}
|
|
94
|
-
const type = reference.assert.type
|
|
94
|
+
const type = reference.assert.type;
|
|
95
95
|
if (shouldTranspileImportAssertion(context, type)) {
|
|
96
|
-
return turnIntoJsModuleProxy(reference, type)
|
|
96
|
+
return turnIntoJsModuleProxy(reference, type);
|
|
97
97
|
}
|
|
98
|
-
return null
|
|
98
|
+
return null;
|
|
99
99
|
},
|
|
100
|
-
}
|
|
101
|
-
return [importAssertions, ...jsenvPluginAsModules()]
|
|
102
|
-
}
|
|
100
|
+
};
|
|
101
|
+
return [importAssertions, ...jsenvPluginAsModules()];
|
|
102
|
+
};
|
|
103
103
|
|
|
104
104
|
const jsenvPluginAsModules = () => {
|
|
105
105
|
const inlineContentClientFileUrl = new URL(
|
|
106
106
|
"../../inline_content_analysis/client/inline_content.js",
|
|
107
107
|
import.meta.url,
|
|
108
|
-
).href
|
|
108
|
+
).href;
|
|
109
109
|
|
|
110
110
|
const asJsonModule = {
|
|
111
111
|
name: `jsenv:as_json_module`,
|
|
@@ -116,24 +116,24 @@ const jsenvPluginAsModules = () => {
|
|
|
116
116
|
context,
|
|
117
117
|
searchParam: "as_json_module",
|
|
118
118
|
expectedType: "json",
|
|
119
|
-
})
|
|
119
|
+
});
|
|
120
120
|
if (!jsonReference) {
|
|
121
|
-
return null
|
|
121
|
+
return null;
|
|
122
122
|
}
|
|
123
123
|
await context.fetchUrlContent(jsonUrlInfo, {
|
|
124
124
|
reference: jsonReference,
|
|
125
|
-
})
|
|
125
|
+
});
|
|
126
126
|
if (context.dev) {
|
|
127
127
|
context.referenceUtils.found({
|
|
128
128
|
type: "js_import",
|
|
129
129
|
subtype: jsonReference.subtype,
|
|
130
130
|
specifier: jsonReference.url,
|
|
131
131
|
expectedType: "js_module",
|
|
132
|
-
})
|
|
132
|
+
});
|
|
133
133
|
} else if (context.build && jsonUrlInfo.dependents.size === 0) {
|
|
134
|
-
context.urlGraph.deleteUrlInfo(jsonUrlInfo.url)
|
|
134
|
+
context.urlGraph.deleteUrlInfo(jsonUrlInfo.url);
|
|
135
135
|
}
|
|
136
|
-
const jsonText = JSON.stringify(jsonUrlInfo.content.trim())
|
|
136
|
+
const jsonText = JSON.stringify(jsonUrlInfo.content.trim());
|
|
137
137
|
return {
|
|
138
138
|
// here we could `export default ${jsonText}`:
|
|
139
139
|
// but js engine are optimized to recognize JSON.parse
|
|
@@ -144,9 +144,9 @@ const jsenvPluginAsModules = () => {
|
|
|
144
144
|
originalUrl: jsonUrlInfo.originalUrl,
|
|
145
145
|
originalContent: jsonUrlInfo.originalContent,
|
|
146
146
|
data: jsonUrlInfo.data,
|
|
147
|
-
}
|
|
147
|
+
};
|
|
148
148
|
},
|
|
149
|
-
}
|
|
149
|
+
};
|
|
150
150
|
|
|
151
151
|
const asCssModule = {
|
|
152
152
|
name: `jsenv:as_css_module`,
|
|
@@ -157,29 +157,29 @@ const jsenvPluginAsModules = () => {
|
|
|
157
157
|
context,
|
|
158
158
|
searchParam: "as_css_module",
|
|
159
159
|
expectedType: "css",
|
|
160
|
-
})
|
|
160
|
+
});
|
|
161
161
|
if (!cssReference) {
|
|
162
|
-
return null
|
|
162
|
+
return null;
|
|
163
163
|
}
|
|
164
164
|
await context.fetchUrlContent(cssUrlInfo, {
|
|
165
165
|
reference: cssReference,
|
|
166
|
-
})
|
|
166
|
+
});
|
|
167
167
|
if (context.dev) {
|
|
168
168
|
context.referenceUtils.found({
|
|
169
169
|
type: "js_import",
|
|
170
170
|
subtype: cssReference.subtype,
|
|
171
171
|
specifier: cssReference.url,
|
|
172
172
|
expectedType: "js_module",
|
|
173
|
-
})
|
|
173
|
+
});
|
|
174
174
|
} else if (context.build && cssUrlInfo.dependents.size === 0) {
|
|
175
|
-
context.urlGraph.deleteUrlInfo(cssUrlInfo.url)
|
|
175
|
+
context.urlGraph.deleteUrlInfo(cssUrlInfo.url);
|
|
176
176
|
}
|
|
177
177
|
const cssText = JS_QUOTES.escapeSpecialChars(cssUrlInfo.content, {
|
|
178
178
|
// If template string is choosen and runtime do not support template literals
|
|
179
179
|
// it's ok because "jsenv:new_inline_content" plugin executes after this one
|
|
180
180
|
// and convert template strings into raw strings
|
|
181
181
|
canUseTemplateString: true,
|
|
182
|
-
})
|
|
182
|
+
});
|
|
183
183
|
return {
|
|
184
184
|
content: `import { InlineContent } from ${JSON.stringify(
|
|
185
185
|
inlineContentClientFileUrl,
|
|
@@ -194,9 +194,9 @@ const jsenvPluginAsModules = () => {
|
|
|
194
194
|
originalUrl: cssUrlInfo.originalUrl,
|
|
195
195
|
originalContent: cssUrlInfo.originalContent,
|
|
196
196
|
data: cssUrlInfo.data,
|
|
197
|
-
}
|
|
197
|
+
};
|
|
198
198
|
},
|
|
199
|
-
}
|
|
199
|
+
};
|
|
200
200
|
|
|
201
201
|
const asTextModule = {
|
|
202
202
|
name: `jsenv:as_text_module`,
|
|
@@ -207,29 +207,29 @@ const jsenvPluginAsModules = () => {
|
|
|
207
207
|
context,
|
|
208
208
|
searchParam: "as_text_module",
|
|
209
209
|
expectedType: "text",
|
|
210
|
-
})
|
|
210
|
+
});
|
|
211
211
|
if (!textReference) {
|
|
212
|
-
return null
|
|
212
|
+
return null;
|
|
213
213
|
}
|
|
214
214
|
await context.fetchUrlContent(textUrlInfo, {
|
|
215
215
|
reference: textReference,
|
|
216
|
-
})
|
|
216
|
+
});
|
|
217
217
|
if (context.dev) {
|
|
218
218
|
context.referenceUtils.found({
|
|
219
219
|
type: "js_import",
|
|
220
220
|
subtype: textReference.subtype,
|
|
221
221
|
specifier: textReference.url,
|
|
222
222
|
expectedType: "js_module",
|
|
223
|
-
})
|
|
223
|
+
});
|
|
224
224
|
} else if (context.build && textUrlInfo.dependents.size === 0) {
|
|
225
|
-
context.urlGraph.deleteUrlInfo(textUrlInfo.url)
|
|
225
|
+
context.urlGraph.deleteUrlInfo(textUrlInfo.url);
|
|
226
226
|
}
|
|
227
227
|
const textPlain = JS_QUOTES.escapeSpecialChars(urlInfo.content, {
|
|
228
228
|
// If template string is choosen and runtime do not support template literals
|
|
229
229
|
// it's ok because "jsenv:new_inline_content" plugin executes after this one
|
|
230
230
|
// and convert template strings into raw strings
|
|
231
231
|
canUseTemplateString: true,
|
|
232
|
-
})
|
|
232
|
+
});
|
|
233
233
|
return {
|
|
234
234
|
content: `import { InlineContent } from ${JSON.stringify(
|
|
235
235
|
inlineContentClientFileUrl,
|
|
@@ -242,9 +242,9 @@ export default inlineContent.text`,
|
|
|
242
242
|
originalUrl: textUrlInfo.originalUrl,
|
|
243
243
|
originalContent: textUrlInfo.originalContent,
|
|
244
244
|
data: textUrlInfo.data,
|
|
245
|
-
}
|
|
245
|
+
};
|
|
246
246
|
},
|
|
247
|
-
}
|
|
247
|
+
};
|
|
248
248
|
|
|
249
|
-
return [asJsonModule, asCssModule, asTextModule]
|
|
250
|
-
}
|
|
249
|
+
return [asJsonModule, asCssModule, asTextModule];
|
|
250
|
+
};
|