@jsenv/core 36.0.2 → 36.1.0

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.
@@ -1,5 +1,3 @@
1
- import { URL_META } from "@jsenv/url-meta";
2
-
3
1
  import { jsenvPluginReferenceExpectedTypes } from "./jsenv_plugin_reference_expected_types.js";
4
2
  import { jsenvPluginDirectoryReferenceAnalysis } from "./directory/jsenv_plugin_directory_reference_analysis.js";
5
3
  import { jsenvPluginDataUrlsAnalysis } from "./data_urls/jsenv_plugin_data_urls_analysis.js";
@@ -9,21 +7,12 @@ import { jsenvPluginCssReferenceAnalysis } from "./css/jsenv_plugin_css_referenc
9
7
  import { jsenvPluginJsReferenceAnalysis } from "./js/jsenv_plugin_js_reference_analysis.js";
10
8
 
11
9
  export const jsenvPluginReferenceAnalysis = ({
12
- include,
13
- supportedProtocols = ["file:", "data:", "virtual:", "http:", "https:"],
14
-
15
- ignoreProtocol = "remove",
16
10
  inlineContent = true,
17
11
  inlineConvertedScript = false,
18
12
  fetchInlineUrls = true,
19
13
  allowEscapeForVersioning = false,
20
14
  }) => {
21
15
  return [
22
- jsenvPluginReferenceAnalysisInclude({
23
- include,
24
- supportedProtocols,
25
- ignoreProtocol,
26
- }),
27
16
  jsenvPluginDirectoryReferenceAnalysis(),
28
17
  jsenvPluginHtmlReferenceAnalysis({
29
18
  inlineContent,
@@ -43,83 +32,6 @@ export const jsenvPluginReferenceAnalysis = ({
43
32
  ];
44
33
  };
45
34
 
46
- const jsenvPluginReferenceAnalysisInclude = ({
47
- include,
48
- supportedProtocols,
49
- ignoreProtocol,
50
- }) => {
51
- // eslint-disable-next-line no-unused-vars
52
- let getIncludeInfo = (url) => undefined;
53
-
54
- return {
55
- name: "jsenv:reference_analysis_include",
56
- appliesDuring: "*",
57
- init: ({ rootDirectoryUrl }) => {
58
- if (include) {
59
- const associations = URL_META.resolveAssociations(
60
- { include },
61
- rootDirectoryUrl,
62
- );
63
- getIncludeInfo = (url) => {
64
- const { include } = URL_META.applyAssociations({
65
- url,
66
- associations,
67
- });
68
- return include;
69
- };
70
- }
71
- },
72
- redirectReference: (reference) => {
73
- if (reference.mustIgnore !== undefined) {
74
- return;
75
- }
76
- if (
77
- reference.specifier[0] === "#" &&
78
- // For Html, css and in general "#" refer to a resource in the page
79
- // so that urls must be kept intact
80
- // However for js import specifiers they have a different meaning and we want
81
- // to resolve them (https://nodejs.org/api/packages.html#imports for instance)
82
- reference.type !== "js_import"
83
- ) {
84
- reference.mustIgnore = true;
85
- return;
86
- }
87
- if (reference.url.startsWith("ignore:")) {
88
- reference.mustIgnore = true;
89
- if (ignoreProtocol === "remove") {
90
- reference.specifier = reference.specifier.slice("ignore:".length);
91
- }
92
- return;
93
- }
94
- const includeInfo = getIncludeInfo(reference.url);
95
- if (includeInfo === true) {
96
- reference.mustIgnore = false;
97
- return;
98
- }
99
- if (includeInfo === false) {
100
- reference.mustIgnore = true;
101
- return;
102
- }
103
- const { protocol } = new URL(reference.url);
104
- const protocolIsSupported = supportedProtocols.some(
105
- (supportedProtocol) => protocol === supportedProtocol,
106
- );
107
- if (!protocolIsSupported) {
108
- reference.mustIgnore = true;
109
- }
110
- },
111
- formatReference: (reference) => {
112
- if (
113
- ignoreProtocol === "inject" &&
114
- reference.mustIgnore &&
115
- !reference.url.startsWith("ignore:")
116
- ) {
117
- reference.specifier = `ignore:${reference.specifier}`;
118
- }
119
- },
120
- };
121
- };
122
-
123
35
  const jsenvPluginInlineContentFetcher = () => {
124
36
  return {
125
37
  name: "jsenv:inline_content_fetcher",