@jsenv/core 35.0.3 → 35.0.4
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 +1 -1
- 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
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url"
|
|
2
|
-
import { Worker, workerData } from "node:worker_threads"
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { Worker, workerData } from "node:worker_threads";
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/worker_threads.html
|
|
5
5
|
export const createReloadableWorker = (workerFileUrl, options = {}) => {
|
|
6
|
-
const workerFilePath = fileURLToPath(workerFileUrl)
|
|
7
|
-
const isPrimary = !workerData || workerData.workerFilePath !== workerFilePath
|
|
8
|
-
let worker
|
|
6
|
+
const workerFilePath = fileURLToPath(workerFileUrl);
|
|
7
|
+
const isPrimary = !workerData || workerData.workerFilePath !== workerFilePath;
|
|
8
|
+
let worker;
|
|
9
9
|
|
|
10
10
|
const terminate = async () => {
|
|
11
11
|
if (worker) {
|
|
12
|
-
let _worker = worker
|
|
13
|
-
worker = null
|
|
12
|
+
let _worker = worker;
|
|
13
|
+
worker = null;
|
|
14
14
|
const exitPromise = new Promise((resolve) => {
|
|
15
|
-
_worker.once("exit", resolve)
|
|
16
|
-
})
|
|
17
|
-
_worker.terminate()
|
|
18
|
-
await exitPromise
|
|
15
|
+
_worker.once("exit", resolve);
|
|
16
|
+
});
|
|
17
|
+
_worker.terminate();
|
|
18
|
+
await exitPromise;
|
|
19
19
|
}
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
|
|
22
22
|
const load = async () => {
|
|
23
23
|
if (!isPrimary) {
|
|
24
|
-
throw new Error(`worker can be loaded from primary file only`)
|
|
24
|
+
throw new Error(`worker can be loaded from primary file only`);
|
|
25
25
|
}
|
|
26
26
|
worker = new Worker(workerFilePath, {
|
|
27
27
|
...options,
|
|
@@ -29,23 +29,23 @@ export const createReloadableWorker = (workerFileUrl, options = {}) => {
|
|
|
29
29
|
...options.workerData,
|
|
30
30
|
workerFilePath,
|
|
31
31
|
},
|
|
32
|
-
})
|
|
32
|
+
});
|
|
33
33
|
worker.once("error", (error) => {
|
|
34
|
-
console.error(error)
|
|
35
|
-
})
|
|
34
|
+
console.error(error);
|
|
35
|
+
});
|
|
36
36
|
worker.once("exit", () => {
|
|
37
|
-
worker = null
|
|
38
|
-
})
|
|
37
|
+
worker = null;
|
|
38
|
+
});
|
|
39
39
|
await new Promise((resolve) => {
|
|
40
|
-
worker.once("online", resolve)
|
|
41
|
-
})
|
|
42
|
-
return worker
|
|
43
|
-
}
|
|
40
|
+
worker.once("online", resolve);
|
|
41
|
+
});
|
|
42
|
+
return worker;
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
const reload = async () => {
|
|
46
|
-
await terminate()
|
|
47
|
-
await load()
|
|
48
|
-
}
|
|
46
|
+
await terminate();
|
|
47
|
+
await load();
|
|
48
|
+
};
|
|
49
49
|
|
|
50
50
|
return {
|
|
51
51
|
isPrimary,
|
|
@@ -53,5 +53,5 @@ export const createReloadableWorker = (workerFileUrl, options = {}) => {
|
|
|
53
53
|
load,
|
|
54
54
|
reload,
|
|
55
55
|
terminate,
|
|
56
|
-
}
|
|
57
|
-
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
import { findHighestVersion } from "@jsenv/utils/src/semantic_versioning/highest_version.js"
|
|
1
|
+
import { findHighestVersion } from "@jsenv/utils/src/semantic_versioning/highest_version.js";
|
|
2
2
|
|
|
3
|
-
import { featuresCompatMap } from "./features_compatibility.js"
|
|
3
|
+
import { featuresCompatMap } from "./features_compatibility.js";
|
|
4
4
|
|
|
5
5
|
export const RUNTIME_COMPAT = {
|
|
6
6
|
featuresCompatMap,
|
|
7
7
|
|
|
8
8
|
add: (originalRuntimeCompat, feature) => {
|
|
9
|
-
const featureCompat = getFeatureCompat(feature)
|
|
9
|
+
const featureCompat = getFeatureCompat(feature);
|
|
10
10
|
const runtimeCompat = {
|
|
11
11
|
...originalRuntimeCompat,
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
Object.keys(originalRuntimeCompat).forEach((runtimeName) => {
|
|
14
|
-
const secondVersion = featureCompat[runtimeName] // the version supported by the feature
|
|
14
|
+
const secondVersion = featureCompat[runtimeName]; // the version supported by the feature
|
|
15
15
|
if (secondVersion) {
|
|
16
|
-
const firstVersion = originalRuntimeCompat[runtimeName]
|
|
16
|
+
const firstVersion = originalRuntimeCompat[runtimeName];
|
|
17
17
|
runtimeCompat[runtimeName] = findHighestVersion(
|
|
18
18
|
firstVersion,
|
|
19
19
|
secondVersion,
|
|
20
|
-
)
|
|
20
|
+
);
|
|
21
21
|
}
|
|
22
|
-
})
|
|
23
|
-
return runtimeCompat
|
|
22
|
+
});
|
|
23
|
+
return runtimeCompat;
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
isSupported: (runtimeCompat, feature) => {
|
|
27
|
-
const featureCompat = getFeatureCompat(feature)
|
|
28
|
-
const runtimeNames = Object.keys(runtimeCompat)
|
|
27
|
+
const featureCompat = getFeatureCompat(feature);
|
|
28
|
+
const runtimeNames = Object.keys(runtimeCompat);
|
|
29
29
|
const runtimeWithoutCompat = runtimeNames.find((runtimeName) => {
|
|
30
|
-
const runtimeVersion = runtimeCompat[runtimeName]
|
|
31
|
-
const runtimeVersionCompatible = featureCompat[runtimeName] || "Infinity"
|
|
30
|
+
const runtimeVersion = runtimeCompat[runtimeName];
|
|
31
|
+
const runtimeVersionCompatible = featureCompat[runtimeName] || "Infinity";
|
|
32
32
|
const highestVersion = findHighestVersion(
|
|
33
33
|
runtimeVersion,
|
|
34
34
|
runtimeVersionCompatible,
|
|
35
|
-
)
|
|
36
|
-
return highestVersion !== runtimeVersion
|
|
37
|
-
})
|
|
38
|
-
return !runtimeWithoutCompat
|
|
35
|
+
);
|
|
36
|
+
return highestVersion !== runtimeVersion;
|
|
37
|
+
});
|
|
38
|
+
return !runtimeWithoutCompat;
|
|
39
39
|
},
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
const getFeatureCompat = (feature) => {
|
|
43
43
|
if (typeof feature === "string") {
|
|
44
|
-
const compat = featuresCompatMap[feature]
|
|
44
|
+
const compat = featuresCompatMap[feature];
|
|
45
45
|
if (!compat) {
|
|
46
|
-
throw new Error(`"${feature}" feature is unknown`)
|
|
46
|
+
throw new Error(`"${feature}" feature is unknown`);
|
|
47
47
|
}
|
|
48
|
-
return compat
|
|
48
|
+
return compat;
|
|
49
49
|
}
|
|
50
50
|
if (typeof feature !== "object") {
|
|
51
|
-
throw new TypeError(
|
|
51
|
+
throw new TypeError(
|
|
52
|
+
`feature must be a string or an object, got ${feature}`,
|
|
53
|
+
);
|
|
52
54
|
}
|
|
53
|
-
return feature
|
|
54
|
-
}
|
|
55
|
+
return feature;
|
|
56
|
+
};
|
package/src/kitchen/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createDetailedMessage } from "@jsenv/log"
|
|
2
|
-
import { stringifyUrlSite } from "@jsenv/urls"
|
|
1
|
+
import { createDetailedMessage } from "@jsenv/log";
|
|
2
|
+
import { stringifyUrlSite } from "@jsenv/urls";
|
|
3
3
|
|
|
4
4
|
export const createResolveUrlError = ({
|
|
5
5
|
pluginController,
|
|
@@ -19,29 +19,29 @@ export const createResolveUrlError = ({
|
|
|
19
19
|
"specifier trace": reference.trace.message,
|
|
20
20
|
...detailsFromPluginController(pluginController),
|
|
21
21
|
}),
|
|
22
|
-
)
|
|
23
|
-
resolveError.name = "RESOLVE_URL_ERROR"
|
|
24
|
-
resolveError.code = code
|
|
25
|
-
resolveError.reason = reason
|
|
26
|
-
resolveError.asResponse = error.asResponse
|
|
27
|
-
return resolveError
|
|
28
|
-
}
|
|
22
|
+
);
|
|
23
|
+
resolveError.name = "RESOLVE_URL_ERROR";
|
|
24
|
+
resolveError.code = code;
|
|
25
|
+
resolveError.reason = reason;
|
|
26
|
+
resolveError.asResponse = error.asResponse;
|
|
27
|
+
return resolveError;
|
|
28
|
+
};
|
|
29
29
|
if (error.message === "NO_RESOLVE") {
|
|
30
30
|
return createFailedToResolveUrlError({
|
|
31
31
|
reason: `no plugin has handled the specifier during "resolveUrl" hook`,
|
|
32
|
-
})
|
|
32
|
+
});
|
|
33
33
|
}
|
|
34
34
|
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
35
35
|
error.message = createDetailedMessage(error.message, {
|
|
36
36
|
"reference trace": reference.trace.message,
|
|
37
|
-
})
|
|
38
|
-
return error
|
|
37
|
+
});
|
|
38
|
+
return error;
|
|
39
39
|
}
|
|
40
40
|
return createFailedToResolveUrlError({
|
|
41
41
|
reason: `An error occured during specifier resolution`,
|
|
42
42
|
...detailsFromValueThrown(error),
|
|
43
|
-
})
|
|
44
|
-
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
45
|
|
|
46
46
|
export const createFetchUrlContentError = ({
|
|
47
47
|
pluginController,
|
|
@@ -62,43 +62,43 @@ export const createFetchUrlContentError = ({
|
|
|
62
62
|
"url reference trace": reference.trace.message,
|
|
63
63
|
...detailsFromPluginController(pluginController),
|
|
64
64
|
}),
|
|
65
|
-
)
|
|
66
|
-
fetchError.name = "FETCH_URL_CONTENT_ERROR"
|
|
67
|
-
fetchError.code = code
|
|
68
|
-
fetchError.reason = reason
|
|
69
|
-
fetchError.url = urlInfo.url
|
|
65
|
+
);
|
|
66
|
+
fetchError.name = "FETCH_URL_CONTENT_ERROR";
|
|
67
|
+
fetchError.code = code;
|
|
68
|
+
fetchError.reason = reason;
|
|
69
|
+
fetchError.url = urlInfo.url;
|
|
70
70
|
if (code === "PARSE_ERROR") {
|
|
71
|
-
fetchError.traceUrl = error.traceUrl
|
|
72
|
-
fetchError.traceLine = error.traceLine
|
|
73
|
-
fetchError.traceColumn = error.traceColumn
|
|
74
|
-
fetchError.traceMessage = error.traceMessage
|
|
71
|
+
fetchError.traceUrl = error.traceUrl;
|
|
72
|
+
fetchError.traceLine = error.traceLine;
|
|
73
|
+
fetchError.traceColumn = error.traceColumn;
|
|
74
|
+
fetchError.traceMessage = error.traceMessage;
|
|
75
75
|
} else {
|
|
76
|
-
fetchError.traceUrl = reference.trace.url
|
|
77
|
-
fetchError.traceLine = reference.trace.line
|
|
78
|
-
fetchError.traceColumn = reference.trace.column
|
|
79
|
-
fetchError.traceMessage = reference.trace.message
|
|
76
|
+
fetchError.traceUrl = reference.trace.url;
|
|
77
|
+
fetchError.traceLine = reference.trace.line;
|
|
78
|
+
fetchError.traceColumn = reference.trace.column;
|
|
79
|
+
fetchError.traceMessage = reference.trace.message;
|
|
80
80
|
}
|
|
81
|
-
fetchError.asResponse = error.asResponse
|
|
82
|
-
return fetchError
|
|
83
|
-
}
|
|
81
|
+
fetchError.asResponse = error.asResponse;
|
|
82
|
+
return fetchError;
|
|
83
|
+
};
|
|
84
84
|
|
|
85
85
|
if (error.code === "EPERM") {
|
|
86
86
|
return createFailedToFetchUrlContentError({
|
|
87
87
|
code: "NOT_ALLOWED",
|
|
88
88
|
reason: `not allowed to read entry on filesystem`,
|
|
89
|
-
})
|
|
89
|
+
});
|
|
90
90
|
}
|
|
91
91
|
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
92
92
|
return createFailedToFetchUrlContentError({
|
|
93
93
|
code: "DIRECTORY_REFERENCE_NOT_ALLOWED",
|
|
94
94
|
reason: `found a directory on filesystem`,
|
|
95
|
-
})
|
|
95
|
+
});
|
|
96
96
|
}
|
|
97
97
|
if (error.code === "ENOENT") {
|
|
98
98
|
return createFailedToFetchUrlContentError({
|
|
99
99
|
code: "NOT_FOUND",
|
|
100
100
|
reason: "no entry on filesystem",
|
|
101
|
-
})
|
|
101
|
+
});
|
|
102
102
|
}
|
|
103
103
|
if (error.code === "PARSE_ERROR") {
|
|
104
104
|
return createFailedToFetchUrlContentError({
|
|
@@ -106,13 +106,13 @@ export const createFetchUrlContentError = ({
|
|
|
106
106
|
"reason": error.reason,
|
|
107
107
|
"parse error message": error.cause.message,
|
|
108
108
|
"parse error trace": error.traceMessage,
|
|
109
|
-
})
|
|
109
|
+
});
|
|
110
110
|
}
|
|
111
111
|
return createFailedToFetchUrlContentError({
|
|
112
112
|
reason: `An error occured during "fetchUrlContent"`,
|
|
113
113
|
...detailsFromValueThrown(error),
|
|
114
|
-
})
|
|
115
|
-
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
116
|
|
|
117
117
|
export const createTransformUrlContentError = ({
|
|
118
118
|
pluginController,
|
|
@@ -121,7 +121,7 @@ export const createTransformUrlContentError = ({
|
|
|
121
121
|
error,
|
|
122
122
|
}) => {
|
|
123
123
|
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
124
|
-
return error
|
|
124
|
+
return error;
|
|
125
125
|
}
|
|
126
126
|
const createFailedToTransformError = ({
|
|
127
127
|
code = error.code || "TRANSFORM_URL_CONTENT_ERROR",
|
|
@@ -139,47 +139,47 @@ export const createTransformUrlContentError = ({
|
|
|
139
139
|
...detailsFromPluginController(pluginController),
|
|
140
140
|
},
|
|
141
141
|
),
|
|
142
|
-
)
|
|
143
|
-
transformError.name = "TRANSFORM_URL_CONTENT_ERROR"
|
|
144
|
-
transformError.code = code
|
|
145
|
-
transformError.reason = reason
|
|
146
|
-
transformError.stack = error.stack
|
|
147
|
-
transformError.url = urlInfo.url
|
|
148
|
-
transformError.traceUrl = reference.trace.url
|
|
149
|
-
transformError.traceLine = reference.trace.line
|
|
150
|
-
transformError.traceColumn = reference.trace.column
|
|
151
|
-
transformError.traceMessage = reference.trace.message
|
|
142
|
+
);
|
|
143
|
+
transformError.name = "TRANSFORM_URL_CONTENT_ERROR";
|
|
144
|
+
transformError.code = code;
|
|
145
|
+
transformError.reason = reason;
|
|
146
|
+
transformError.stack = error.stack;
|
|
147
|
+
transformError.url = urlInfo.url;
|
|
148
|
+
transformError.traceUrl = reference.trace.url;
|
|
149
|
+
transformError.traceLine = reference.trace.line;
|
|
150
|
+
transformError.traceColumn = reference.trace.column;
|
|
151
|
+
transformError.traceMessage = reference.trace.message;
|
|
152
152
|
if (code === "PARSE_ERROR") {
|
|
153
|
-
transformError.reason = `parse error on ${urlInfo.type}
|
|
154
|
-
transformError.cause = error
|
|
153
|
+
transformError.reason = `parse error on ${urlInfo.type}`;
|
|
154
|
+
transformError.cause = error;
|
|
155
155
|
if (urlInfo.isInline) {
|
|
156
|
-
transformError.traceLine = reference.trace.line + error.line - 1
|
|
157
|
-
transformError.traceColumn = reference.trace.column + error.column
|
|
156
|
+
transformError.traceLine = reference.trace.line + error.line - 1;
|
|
157
|
+
transformError.traceColumn = reference.trace.column + error.column;
|
|
158
158
|
transformError.traceMessage = stringifyUrlSite({
|
|
159
159
|
url: urlInfo.inlineUrlSite.url,
|
|
160
160
|
line: transformError.traceLine,
|
|
161
161
|
column: transformError.traceColumn,
|
|
162
162
|
content: urlInfo.inlineUrlSite.content,
|
|
163
|
-
})
|
|
163
|
+
});
|
|
164
164
|
} else {
|
|
165
|
-
transformError.traceLine = error.line
|
|
166
|
-
transformError.traceColumn = error.column
|
|
165
|
+
transformError.traceLine = error.line;
|
|
166
|
+
transformError.traceColumn = error.column;
|
|
167
167
|
transformError.traceMessage = stringifyUrlSite({
|
|
168
168
|
url: urlInfo.url,
|
|
169
169
|
line: error.line - 1,
|
|
170
170
|
column: error.column,
|
|
171
171
|
content: urlInfo.content,
|
|
172
|
-
})
|
|
172
|
+
});
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
transformError.asResponse = error.asResponse
|
|
176
|
-
return transformError
|
|
177
|
-
}
|
|
175
|
+
transformError.asResponse = error.asResponse;
|
|
176
|
+
return transformError;
|
|
177
|
+
};
|
|
178
178
|
return createFailedToTransformError({
|
|
179
179
|
reason: `"transformUrlContent" error on "${urlInfo.type}"`,
|
|
180
180
|
...detailsFromValueThrown(error),
|
|
181
|
-
})
|
|
182
|
-
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
183
|
|
|
184
184
|
export const createFinalizeUrlContentError = ({
|
|
185
185
|
pluginController,
|
|
@@ -194,36 +194,36 @@ export const createFinalizeUrlContentError = ({
|
|
|
194
194
|
"url reference trace": reference.trace.message,
|
|
195
195
|
...detailsFromPluginController(pluginController),
|
|
196
196
|
}),
|
|
197
|
-
)
|
|
197
|
+
);
|
|
198
198
|
if (error && error instanceof Error) {
|
|
199
|
-
finalizeError.cause = error
|
|
199
|
+
finalizeError.cause = error;
|
|
200
200
|
}
|
|
201
|
-
finalizeError.name = "FINALIZE_URL_CONTENT_ERROR"
|
|
202
|
-
finalizeError.reason = `"finalizeUrlContent" error on "${urlInfo.type}"
|
|
203
|
-
finalizeError.asResponse = error.asResponse
|
|
204
|
-
return finalizeError
|
|
205
|
-
}
|
|
201
|
+
finalizeError.name = "FINALIZE_URL_CONTENT_ERROR";
|
|
202
|
+
finalizeError.reason = `"finalizeUrlContent" error on "${urlInfo.type}"`;
|
|
203
|
+
finalizeError.asResponse = error.asResponse;
|
|
204
|
+
return finalizeError;
|
|
205
|
+
};
|
|
206
206
|
|
|
207
207
|
const detailsFromPluginController = (pluginController) => {
|
|
208
|
-
const currentPlugin = pluginController.getCurrentPlugin()
|
|
208
|
+
const currentPlugin = pluginController.getCurrentPlugin();
|
|
209
209
|
if (!currentPlugin) {
|
|
210
|
-
return null
|
|
210
|
+
return null;
|
|
211
211
|
}
|
|
212
|
-
return { "plugin name": `"${currentPlugin.name}"` }
|
|
213
|
-
}
|
|
212
|
+
return { "plugin name": `"${currentPlugin.name}"` };
|
|
213
|
+
};
|
|
214
214
|
|
|
215
215
|
const detailsFromValueThrown = (valueThrownByPlugin) => {
|
|
216
216
|
if (valueThrownByPlugin && valueThrownByPlugin instanceof Error) {
|
|
217
217
|
return {
|
|
218
218
|
"error stack": valueThrownByPlugin.stack,
|
|
219
|
-
}
|
|
219
|
+
};
|
|
220
220
|
}
|
|
221
221
|
if (valueThrownByPlugin === undefined) {
|
|
222
222
|
return {
|
|
223
223
|
error: "undefined",
|
|
224
|
-
}
|
|
224
|
+
};
|
|
225
225
|
}
|
|
226
226
|
return {
|
|
227
227
|
error: JSON.stringify(valueThrownByPlugin),
|
|
228
|
-
}
|
|
229
|
-
}
|
|
228
|
+
};
|
|
229
|
+
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { validateResponseIntegrity } from "@jsenv/integrity"
|
|
1
|
+
import { validateResponseIntegrity } from "@jsenv/integrity";
|
|
2
2
|
|
|
3
3
|
export const assertFetchedContentCompliance = ({ reference, urlInfo }) => {
|
|
4
|
-
const { expectedContentType } = reference
|
|
4
|
+
const { expectedContentType } = reference;
|
|
5
5
|
if (expectedContentType && urlInfo.contentType !== expectedContentType) {
|
|
6
6
|
throw new Error(
|
|
7
7
|
`Unexpected content-type on url: "${expectedContentType}" was expected but got "${urlInfo.contentType}`,
|
|
8
|
-
)
|
|
8
|
+
);
|
|
9
9
|
}
|
|
10
|
-
const { expectedType } = reference
|
|
10
|
+
const { expectedType } = reference;
|
|
11
11
|
if (expectedType && urlInfo.type !== expectedType) {
|
|
12
12
|
throw new Error(
|
|
13
13
|
`Unexpected type on url: "${expectedType}" was expected but got "${urlInfo.type}"`,
|
|
14
|
-
)
|
|
14
|
+
);
|
|
15
15
|
}
|
|
16
|
-
const { integrity } = reference
|
|
16
|
+
const { integrity } = reference;
|
|
17
17
|
if (integrity) {
|
|
18
18
|
validateResponseIntegrity({
|
|
19
19
|
url: urlInfo.url,
|
|
20
20
|
type: "basic",
|
|
21
21
|
dataRepresentation: urlInfo.content,
|
|
22
|
-
})
|
|
22
|
+
});
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
};
|