@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
package/src/kitchen/url_graph.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { urlToRelativeUrl } from "@jsenv/urls"
|
|
1
|
+
import { urlToRelativeUrl } from "@jsenv/urls";
|
|
2
2
|
|
|
3
|
-
import { urlSpecifierEncoding } from "./url_specifier_encoding.js"
|
|
3
|
+
import { urlSpecifierEncoding } from "./url_specifier_encoding.js";
|
|
4
4
|
|
|
5
5
|
export const createUrlGraph = ({ name = "anonymous" } = {}) => {
|
|
6
|
-
const createUrlInfoCallbackRef = { current: () => {} }
|
|
7
|
-
const prunedUrlInfosCallbackRef = { current: () => {} }
|
|
6
|
+
const createUrlInfoCallbackRef = { current: () => {} };
|
|
7
|
+
const prunedUrlInfosCallbackRef = { current: () => {} };
|
|
8
8
|
|
|
9
|
-
const urlInfoMap = new Map()
|
|
10
|
-
const getUrlInfo = (url) => urlInfoMap.get(url)
|
|
9
|
+
const urlInfoMap = new Map();
|
|
10
|
+
const getUrlInfo = (url) => urlInfoMap.get(url);
|
|
11
11
|
const deleteUrlInfo = (url) => {
|
|
12
|
-
const urlInfo = urlInfoMap.get(url)
|
|
12
|
+
const urlInfo = urlInfoMap.get(url);
|
|
13
13
|
if (urlInfo) {
|
|
14
|
-
urlInfoMap.delete(url)
|
|
14
|
+
urlInfoMap.delete(url);
|
|
15
15
|
urlInfo.dependencies.forEach((dependencyUrl) => {
|
|
16
|
-
getUrlInfo(dependencyUrl).dependents.delete(url)
|
|
17
|
-
})
|
|
16
|
+
getUrlInfo(dependencyUrl).dependents.delete(url);
|
|
17
|
+
});
|
|
18
18
|
if (urlInfo.sourcemapReference) {
|
|
19
|
-
deleteUrlInfo(urlInfo.sourcemapReference.url)
|
|
19
|
+
deleteUrlInfo(urlInfo.sourcemapReference.url);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
const reuseOrCreateUrlInfo = (url) => {
|
|
24
|
-
const existingUrlInfo = getUrlInfo(url)
|
|
25
|
-
if (existingUrlInfo) return existingUrlInfo
|
|
26
|
-
const urlInfo = createUrlInfo(url)
|
|
27
|
-
urlInfoMap.set(url, urlInfo)
|
|
28
|
-
createUrlInfoCallbackRef.current(urlInfo)
|
|
29
|
-
return urlInfo
|
|
30
|
-
}
|
|
24
|
+
const existingUrlInfo = getUrlInfo(url);
|
|
25
|
+
if (existingUrlInfo) return existingUrlInfo;
|
|
26
|
+
const urlInfo = createUrlInfo(url);
|
|
27
|
+
urlInfoMap.set(url, urlInfo);
|
|
28
|
+
createUrlInfoCallbackRef.current(urlInfo);
|
|
29
|
+
return urlInfo;
|
|
30
|
+
};
|
|
31
31
|
const getParentIfInline = (urlInfo) => {
|
|
32
|
-
return urlInfo.isInline ? getUrlInfo(urlInfo.inlineUrlSite.url) : urlInfo
|
|
33
|
-
}
|
|
32
|
+
return urlInfo.isInline ? getUrlInfo(urlInfo.inlineUrlSite.url) : urlInfo;
|
|
33
|
+
};
|
|
34
34
|
|
|
35
35
|
const inferReference = (specifier, parentUrl) => {
|
|
36
|
-
const parentUrlInfo = getUrlInfo(parentUrl)
|
|
36
|
+
const parentUrlInfo = getUrlInfo(parentUrl);
|
|
37
37
|
if (!parentUrlInfo) {
|
|
38
|
-
return null
|
|
38
|
+
return null;
|
|
39
39
|
}
|
|
40
|
-
const seen = []
|
|
40
|
+
const seen = [];
|
|
41
41
|
const search = (urlInfo) => {
|
|
42
42
|
const firstReferenceFound = urlInfo.references.find((reference) => {
|
|
43
|
-
return urlSpecifierEncoding.decode(reference) === specifier
|
|
44
|
-
})
|
|
43
|
+
return urlSpecifierEncoding.decode(reference) === specifier;
|
|
44
|
+
});
|
|
45
45
|
if (firstReferenceFound) {
|
|
46
|
-
return firstReferenceFound
|
|
46
|
+
return firstReferenceFound;
|
|
47
47
|
}
|
|
48
48
|
for (const dependencyUrl of parentUrlInfo.dependencies) {
|
|
49
49
|
if (seen.includes(dependencyUrl)) {
|
|
50
|
-
continue
|
|
50
|
+
continue;
|
|
51
51
|
}
|
|
52
|
-
seen.push(dependencyUrl)
|
|
53
|
-
const dependencyUrlInfo = getUrlInfo(dependencyUrl)
|
|
52
|
+
seen.push(dependencyUrl);
|
|
53
|
+
const dependencyUrlInfo = getUrlInfo(dependencyUrl);
|
|
54
54
|
if (dependencyUrlInfo.isInline) {
|
|
55
|
-
const firstRef = search(dependencyUrlInfo)
|
|
55
|
+
const firstRef = search(dependencyUrlInfo);
|
|
56
56
|
if (firstRef) {
|
|
57
|
-
return firstRef
|
|
57
|
+
return firstRef;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
return null
|
|
62
|
-
}
|
|
63
|
-
return search(parentUrlInfo)
|
|
64
|
-
}
|
|
61
|
+
return null;
|
|
62
|
+
};
|
|
63
|
+
return search(parentUrlInfo);
|
|
64
|
+
};
|
|
65
65
|
const findDependent = (urlInfo, visitor) => {
|
|
66
|
-
const seen = [urlInfo.url]
|
|
67
|
-
let found = null
|
|
66
|
+
const seen = [urlInfo.url];
|
|
67
|
+
let found = null;
|
|
68
68
|
const iterate = (currentUrlInfo) => {
|
|
69
69
|
for (const dependentUrl of currentUrlInfo.dependents) {
|
|
70
70
|
if (seen.includes(dependentUrl)) {
|
|
71
|
-
continue
|
|
71
|
+
continue;
|
|
72
72
|
}
|
|
73
73
|
if (found) {
|
|
74
|
-
break
|
|
74
|
+
break;
|
|
75
75
|
}
|
|
76
|
-
seen.push(dependentUrl)
|
|
77
|
-
const dependentUrlInfo = getUrlInfo(dependentUrl)
|
|
76
|
+
seen.push(dependentUrl);
|
|
77
|
+
const dependentUrlInfo = getUrlInfo(dependentUrl);
|
|
78
78
|
if (visitor(dependentUrlInfo)) {
|
|
79
|
-
found = dependentUrlInfo
|
|
79
|
+
found = dependentUrlInfo;
|
|
80
80
|
}
|
|
81
81
|
if (found) {
|
|
82
|
-
break
|
|
82
|
+
break;
|
|
83
83
|
}
|
|
84
|
-
iterate(dependentUrlInfo)
|
|
84
|
+
iterate(dependentUrlInfo);
|
|
85
85
|
}
|
|
86
|
-
}
|
|
87
|
-
iterate(urlInfo)
|
|
88
|
-
return found
|
|
89
|
-
}
|
|
86
|
+
};
|
|
87
|
+
iterate(urlInfo);
|
|
88
|
+
return found;
|
|
89
|
+
};
|
|
90
90
|
|
|
91
91
|
const updateReferences = (urlInfo, references) => {
|
|
92
|
-
const setOfDependencyUrls = new Set()
|
|
93
|
-
const setOfImplicitUrls = new Set()
|
|
92
|
+
const setOfDependencyUrls = new Set();
|
|
93
|
+
const setOfImplicitUrls = new Set();
|
|
94
94
|
references.forEach((reference) => {
|
|
95
95
|
if (reference.isResourceHint) {
|
|
96
96
|
// resource hint are a special kind of reference.
|
|
@@ -99,113 +99,113 @@ export const createUrlGraph = ({ name = "anonymous" } = {}) => {
|
|
|
99
99
|
// have url.dependents.size === 0 and can be considered as not used
|
|
100
100
|
// It means html won't consider url referenced solely
|
|
101
101
|
// by <link> as dependency and it's fine
|
|
102
|
-
return
|
|
102
|
+
return;
|
|
103
103
|
}
|
|
104
|
-
const dependencyUrl = reference.url
|
|
105
|
-
setOfDependencyUrls.add(dependencyUrl)
|
|
104
|
+
const dependencyUrl = reference.url;
|
|
105
|
+
setOfDependencyUrls.add(dependencyUrl);
|
|
106
106
|
// an implicit reference do not appear in the file but a non-explicited file have an impact on it
|
|
107
107
|
// (package.json on import resolution for instance)
|
|
108
108
|
// in that case:
|
|
109
109
|
// - file depends on the implicit file (it must autoreload if package.json is modified)
|
|
110
110
|
// - cache validity for the file depends on the implicit file (it must be re-cooked in package.json is modified)
|
|
111
111
|
if (reference.isImplicit) {
|
|
112
|
-
setOfImplicitUrls.add(dependencyUrl)
|
|
112
|
+
setOfImplicitUrls.add(dependencyUrl);
|
|
113
113
|
}
|
|
114
|
-
})
|
|
114
|
+
});
|
|
115
115
|
setOfDependencyUrls.forEach((dependencyUrl) => {
|
|
116
|
-
urlInfo.dependencies.add(dependencyUrl)
|
|
117
|
-
const dependencyUrlInfo = reuseOrCreateUrlInfo(dependencyUrl)
|
|
118
|
-
dependencyUrlInfo.dependents.add(urlInfo.url)
|
|
119
|
-
})
|
|
116
|
+
urlInfo.dependencies.add(dependencyUrl);
|
|
117
|
+
const dependencyUrlInfo = reuseOrCreateUrlInfo(dependencyUrl);
|
|
118
|
+
dependencyUrlInfo.dependents.add(urlInfo.url);
|
|
119
|
+
});
|
|
120
120
|
setOfImplicitUrls.forEach((implicitUrl) => {
|
|
121
|
-
urlInfo.implicitUrls.add(implicitUrl)
|
|
121
|
+
urlInfo.implicitUrls.add(implicitUrl);
|
|
122
122
|
if (urlInfo.isInline) {
|
|
123
|
-
const parentUrlInfo = getUrlInfo(urlInfo.inlineUrlSite.url)
|
|
124
|
-
parentUrlInfo.implicitUrls.add(implicitUrl)
|
|
123
|
+
const parentUrlInfo = getUrlInfo(urlInfo.inlineUrlSite.url);
|
|
124
|
+
parentUrlInfo.implicitUrls.add(implicitUrl);
|
|
125
125
|
}
|
|
126
|
-
})
|
|
127
|
-
const prunedUrlInfos = []
|
|
126
|
+
});
|
|
127
|
+
const prunedUrlInfos = [];
|
|
128
128
|
const pruneDependency = (urlInfo, urlToClean) => {
|
|
129
|
-
urlInfo.dependencies.delete(urlToClean)
|
|
130
|
-
const dependencyUrlInfo = getUrlInfo(urlToClean)
|
|
129
|
+
urlInfo.dependencies.delete(urlToClean);
|
|
130
|
+
const dependencyUrlInfo = getUrlInfo(urlToClean);
|
|
131
131
|
if (!dependencyUrlInfo) {
|
|
132
|
-
return
|
|
132
|
+
return;
|
|
133
133
|
}
|
|
134
|
-
dependencyUrlInfo.dependents.delete(urlInfo.url)
|
|
134
|
+
dependencyUrlInfo.dependents.delete(urlInfo.url);
|
|
135
135
|
if (dependencyUrlInfo.dependents.size === 0) {
|
|
136
136
|
dependencyUrlInfo.dependencies.forEach((dependencyUrl) => {
|
|
137
|
-
pruneDependency(dependencyUrlInfo, dependencyUrl)
|
|
138
|
-
})
|
|
139
|
-
prunedUrlInfos.push(dependencyUrlInfo)
|
|
137
|
+
pruneDependency(dependencyUrlInfo, dependencyUrl);
|
|
138
|
+
});
|
|
139
|
+
prunedUrlInfos.push(dependencyUrlInfo);
|
|
140
140
|
}
|
|
141
|
-
}
|
|
141
|
+
};
|
|
142
142
|
urlInfo.dependencies.forEach((dependencyUrl) => {
|
|
143
143
|
if (!setOfDependencyUrls.has(dependencyUrl)) {
|
|
144
|
-
pruneDependency(urlInfo, dependencyUrl)
|
|
144
|
+
pruneDependency(urlInfo, dependencyUrl);
|
|
145
145
|
}
|
|
146
|
-
})
|
|
146
|
+
});
|
|
147
147
|
if (prunedUrlInfos.length) {
|
|
148
148
|
prunedUrlInfos.forEach((prunedUrlInfo) => {
|
|
149
|
-
prunedUrlInfo.modifiedTimestamp = Date.now()
|
|
149
|
+
prunedUrlInfo.modifiedTimestamp = Date.now();
|
|
150
150
|
if (prunedUrlInfo.isInline) {
|
|
151
151
|
// should we always delete?
|
|
152
|
-
deleteUrlInfo(prunedUrlInfo.url)
|
|
152
|
+
deleteUrlInfo(prunedUrlInfo.url);
|
|
153
153
|
}
|
|
154
|
-
})
|
|
155
|
-
prunedUrlInfosCallbackRef.current(prunedUrlInfos, urlInfo)
|
|
154
|
+
});
|
|
155
|
+
prunedUrlInfosCallbackRef.current(prunedUrlInfos, urlInfo);
|
|
156
156
|
}
|
|
157
157
|
urlInfo.implicitUrls.forEach((implicitUrl) => {
|
|
158
158
|
if (!setOfDependencyUrls.has(implicitUrl)) {
|
|
159
|
-
let implicitUrlComesFromInlineContent = false
|
|
159
|
+
let implicitUrlComesFromInlineContent = false;
|
|
160
160
|
for (const dependencyUrl of urlInfo.dependencies) {
|
|
161
|
-
const dependencyUrlInfo = getUrlInfo(dependencyUrl)
|
|
161
|
+
const dependencyUrlInfo = getUrlInfo(dependencyUrl);
|
|
162
162
|
if (
|
|
163
163
|
dependencyUrlInfo.isInline &&
|
|
164
164
|
dependencyUrlInfo.implicitUrls.has(implicitUrl)
|
|
165
165
|
) {
|
|
166
|
-
implicitUrlComesFromInlineContent = true
|
|
167
|
-
break
|
|
166
|
+
implicitUrlComesFromInlineContent = true;
|
|
167
|
+
break;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
if (!implicitUrlComesFromInlineContent) {
|
|
171
|
-
urlInfo.implicitUrls.delete(implicitUrl)
|
|
171
|
+
urlInfo.implicitUrls.delete(implicitUrl);
|
|
172
172
|
}
|
|
173
173
|
if (urlInfo.isInline) {
|
|
174
|
-
const parentUrlInfo = getUrlInfo(urlInfo.inlineUrlSite.url)
|
|
175
|
-
parentUrlInfo.implicitUrls.delete(implicitUrl)
|
|
174
|
+
const parentUrlInfo = getUrlInfo(urlInfo.inlineUrlSite.url);
|
|
175
|
+
parentUrlInfo.implicitUrls.delete(implicitUrl);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
})
|
|
179
|
-
urlInfo.references = references
|
|
180
|
-
return urlInfo
|
|
181
|
-
}
|
|
178
|
+
});
|
|
179
|
+
urlInfo.references = references;
|
|
180
|
+
return urlInfo;
|
|
181
|
+
};
|
|
182
182
|
|
|
183
183
|
const considerModified = (urlInfo, modifiedTimestamp = Date.now()) => {
|
|
184
|
-
const seen = []
|
|
184
|
+
const seen = [];
|
|
185
185
|
const iterate = (urlInfo) => {
|
|
186
186
|
if (seen.includes(urlInfo.url)) {
|
|
187
|
-
return
|
|
187
|
+
return;
|
|
188
188
|
}
|
|
189
|
-
seen.push(urlInfo.url)
|
|
190
|
-
urlInfo.modifiedTimestamp = modifiedTimestamp
|
|
191
|
-
urlInfo.originalContentEtag = undefined
|
|
192
|
-
urlInfo.contentEtag = undefined
|
|
189
|
+
seen.push(urlInfo.url);
|
|
190
|
+
urlInfo.modifiedTimestamp = modifiedTimestamp;
|
|
191
|
+
urlInfo.originalContentEtag = undefined;
|
|
192
|
+
urlInfo.contentEtag = undefined;
|
|
193
193
|
urlInfo.dependents.forEach((dependentUrl) => {
|
|
194
|
-
const dependentUrlInfo = getUrlInfo(dependentUrl)
|
|
195
|
-
const { hotAcceptDependencies = [] } = dependentUrlInfo.data
|
|
194
|
+
const dependentUrlInfo = getUrlInfo(dependentUrl);
|
|
195
|
+
const { hotAcceptDependencies = [] } = dependentUrlInfo.data;
|
|
196
196
|
if (!hotAcceptDependencies.includes(urlInfo.url)) {
|
|
197
|
-
iterate(dependentUrlInfo)
|
|
197
|
+
iterate(dependentUrlInfo);
|
|
198
198
|
}
|
|
199
|
-
})
|
|
199
|
+
});
|
|
200
200
|
urlInfo.dependencies.forEach((dependencyUrl) => {
|
|
201
|
-
const dependencyUrlInfo = getUrlInfo(dependencyUrl)
|
|
201
|
+
const dependencyUrlInfo = getUrlInfo(dependencyUrl);
|
|
202
202
|
if (dependencyUrlInfo.isInline) {
|
|
203
|
-
iterate(dependencyUrlInfo)
|
|
203
|
+
iterate(dependencyUrlInfo);
|
|
204
204
|
}
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
iterate(urlInfo)
|
|
208
|
-
}
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
iterate(urlInfo);
|
|
208
|
+
};
|
|
209
209
|
|
|
210
210
|
return {
|
|
211
211
|
name,
|
|
@@ -224,27 +224,27 @@ export const createUrlGraph = ({ name = "anonymous" } = {}) => {
|
|
|
224
224
|
findDependent,
|
|
225
225
|
|
|
226
226
|
toObject: () => {
|
|
227
|
-
const data = {}
|
|
227
|
+
const data = {};
|
|
228
228
|
urlInfoMap.forEach((urlInfo) => {
|
|
229
|
-
data[urlInfo.url] = urlInfo
|
|
230
|
-
})
|
|
231
|
-
return data
|
|
229
|
+
data[urlInfo.url] = urlInfo;
|
|
230
|
+
});
|
|
231
|
+
return data;
|
|
232
232
|
},
|
|
233
233
|
toJSON: (rootDirectoryUrl) => {
|
|
234
|
-
const data = {}
|
|
234
|
+
const data = {};
|
|
235
235
|
urlInfoMap.forEach((urlInfo) => {
|
|
236
|
-
const dependencyUrls = Array.from(urlInfo.dependencies)
|
|
236
|
+
const dependencyUrls = Array.from(urlInfo.dependencies);
|
|
237
237
|
if (dependencyUrls.length) {
|
|
238
|
-
const relativeUrl = urlToRelativeUrl(urlInfo.url, rootDirectoryUrl)
|
|
238
|
+
const relativeUrl = urlToRelativeUrl(urlInfo.url, rootDirectoryUrl);
|
|
239
239
|
data[relativeUrl] = dependencyUrls.map((dependencyUrl) =>
|
|
240
240
|
urlToRelativeUrl(dependencyUrl, rootDirectoryUrl),
|
|
241
|
-
)
|
|
241
|
+
);
|
|
242
242
|
}
|
|
243
|
-
})
|
|
244
|
-
return data
|
|
243
|
+
});
|
|
244
|
+
return data;
|
|
245
245
|
},
|
|
246
|
-
}
|
|
247
|
-
}
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
248
|
|
|
249
249
|
const createUrlInfo = (url) => {
|
|
250
250
|
const urlInfo = {
|
|
@@ -287,7 +287,7 @@ const createUrlInfo = (url) => {
|
|
|
287
287
|
timing: {},
|
|
288
288
|
headers: {},
|
|
289
289
|
debug: false,
|
|
290
|
-
}
|
|
290
|
+
};
|
|
291
291
|
// Object.preventExtensions(urlInfo) // useful to ensure all properties are declared here
|
|
292
|
-
return urlInfo
|
|
293
|
-
}
|
|
292
|
+
return urlInfo;
|
|
293
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
export const urlSpecifierEncoding = {
|
|
2
2
|
encode: (reference) => {
|
|
3
|
-
const { generatedSpecifier } = reference
|
|
3
|
+
const { generatedSpecifier } = reference;
|
|
4
4
|
if (generatedSpecifier.then) {
|
|
5
5
|
return generatedSpecifier.then((value) => {
|
|
6
|
-
reference.generatedSpecifier = value
|
|
7
|
-
return urlSpecifierEncoding.encode(reference)
|
|
8
|
-
})
|
|
6
|
+
reference.generatedSpecifier = value;
|
|
7
|
+
return urlSpecifierEncoding.encode(reference);
|
|
8
|
+
});
|
|
9
9
|
}
|
|
10
10
|
// allow plugin to return a function to bypas default formatting
|
|
11
11
|
// (which is to use JSON.stringify when url is referenced inside js)
|
|
12
12
|
if (typeof generatedSpecifier === "function") {
|
|
13
|
-
return generatedSpecifier()
|
|
13
|
+
return generatedSpecifier();
|
|
14
14
|
}
|
|
15
|
-
const formatter = formatters[reference.type]
|
|
15
|
+
const formatter = formatters[reference.type];
|
|
16
16
|
const value = formatter
|
|
17
17
|
? formatter.encode(generatedSpecifier)
|
|
18
|
-
: generatedSpecifier
|
|
18
|
+
: generatedSpecifier;
|
|
19
19
|
if (reference.escape) {
|
|
20
|
-
return reference.escape(value)
|
|
20
|
+
return reference.escape(value);
|
|
21
21
|
}
|
|
22
|
-
return value
|
|
22
|
+
return value;
|
|
23
23
|
},
|
|
24
24
|
decode: (reference) => {
|
|
25
|
-
const formatter = formatters[reference.type]
|
|
25
|
+
const formatter = formatters[reference.type];
|
|
26
26
|
return formatter
|
|
27
27
|
? formatter.decode(reference.generatedSpecifier)
|
|
28
|
-
: reference.generatedSpecifier
|
|
28
|
+
: reference.generatedSpecifier;
|
|
29
29
|
},
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
31
|
const formatters = {
|
|
32
32
|
"js_import": { encode: JSON.stringify, decode: JSON.parse },
|
|
33
33
|
"js_url": { encode: JSON.stringify, decode: JSON.parse },
|
|
@@ -36,24 +36,24 @@ const formatters = {
|
|
|
36
36
|
"css_url": {
|
|
37
37
|
encode: (url) => {
|
|
38
38
|
// If url is already wrapped in quotes, remove them
|
|
39
|
-
url = formatters.css_url.decode(url)
|
|
39
|
+
url = formatters.css_url.decode(url);
|
|
40
40
|
// Should url be wrapped?
|
|
41
41
|
// See https://drafts.csswg.org/css-values-3/#urls
|
|
42
42
|
if (/["'() \t\n]/.test(url)) {
|
|
43
|
-
return `"${url.replace(/"/g, '\\"').replace(/\n/g, "\\n")}"
|
|
43
|
+
return `"${url.replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`;
|
|
44
44
|
}
|
|
45
|
-
return url
|
|
45
|
+
return url;
|
|
46
46
|
},
|
|
47
47
|
decode: (url) => {
|
|
48
|
-
const firstChar = url[0]
|
|
49
|
-
const lastChar = url[url.length - 1]
|
|
48
|
+
const firstChar = url[0];
|
|
49
|
+
const lastChar = url[url.length - 1];
|
|
50
50
|
if (firstChar === `"` && lastChar === `"`) {
|
|
51
|
-
return url.slice(1, -1)
|
|
51
|
+
return url.slice(1, -1);
|
|
52
52
|
}
|
|
53
53
|
if (firstChar === `'` && lastChar === `'`) {
|
|
54
|
-
return url.slice(1, -1)
|
|
54
|
+
return url.slice(1, -1);
|
|
55
55
|
}
|
|
56
|
-
return url
|
|
56
|
+
return url;
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
|
-
}
|
|
59
|
+
};
|
|
@@ -6,22 +6,22 @@ export const isWebWorkerEntryPointReference = (reference) => {
|
|
|
6
6
|
if (reference.subtype === "new_url_first_arg") {
|
|
7
7
|
return ["worker", "service_worker", "shared_worker"].includes(
|
|
8
8
|
reference.expectedSubtype,
|
|
9
|
-
)
|
|
9
|
+
);
|
|
10
10
|
}
|
|
11
11
|
return [
|
|
12
12
|
"new_worker_first_arg",
|
|
13
13
|
"new_shared_worker_first_arg",
|
|
14
14
|
"service_worker_register_first_arg",
|
|
15
|
-
].includes(reference.subtype)
|
|
16
|
-
}
|
|
15
|
+
].includes(reference.subtype);
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
export const isWebWorkerUrlInfo = (urlInfo) => {
|
|
19
19
|
return (
|
|
20
20
|
urlInfo.subtype === "worker" ||
|
|
21
21
|
urlInfo.subtype === "service_worker" ||
|
|
22
22
|
urlInfo.subtype === "shared_worker"
|
|
23
|
-
)
|
|
24
|
-
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
25
|
|
|
26
26
|
// export const isEntryPoint = (urlInfo, urlGraph) => {
|
|
27
27
|
// if (urlInfo.data.isEntryPoint) {
|
package/src/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// dev
|
|
2
|
-
export { startDevServer } from "./dev/start_dev_server.js"
|
|
2
|
+
export { startDevServer } from "./dev/start_dev_server.js";
|
|
3
3
|
// build
|
|
4
|
-
export { build } from "./build/build.js"
|
|
5
|
-
export { startBuildServer } from "./build/start_build_server.js"
|
|
4
|
+
export { build } from "./build/build.js";
|
|
5
|
+
export { startBuildServer } from "./build/start_build_server.js";
|