extension-develop 4.1.11 → 4.1.13

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.
Files changed (110) hide show
  1. package/dist/0~dev-server.mjs +147 -81
  2. package/dist/0~rspack-config.mjs +1096 -694
  3. package/dist/0~zip.mjs +1 -1
  4. package/dist/101.mjs +185 -895
  5. package/dist/129.mjs +89 -0
  6. package/dist/278.mjs +52 -0
  7. package/dist/292.mjs +61 -0
  8. package/dist/372.mjs +87 -0
  9. package/dist/518.mjs +434 -0
  10. package/dist/77.mjs +928 -0
  11. package/dist/839.mjs +178 -40
  12. package/dist/845.mjs +10 -1
  13. package/dist/887.mjs +1 -1
  14. package/dist/bridge-entry.d.ts +2 -1
  15. package/dist/bridge.mjs +56 -7
  16. package/dist/css-parse-guard-loader.mjs +3 -0
  17. package/dist/dead-css-url-loader.mjs +51 -24
  18. package/dist/dev-server/cleanup.d.ts +2 -1
  19. package/dist/dev-server/control-bridge/broker.d.ts +1 -0
  20. package/dist/dev-server/control-bridge/contracts.d.ts +2 -0
  21. package/dist/dev-server/control-bridge/logs-query.d.ts +12 -1
  22. package/dist/dev-server/control-bridge/producer-runtime.d.ts +1 -1
  23. package/dist/dev-server/messages.d.ts +8 -0
  24. package/dist/dev-server/session-restart.d.ts +29 -0
  25. package/dist/ensure-hmr-for-scripts.js +37 -20
  26. package/dist/ensure-hmr-for-scripts.mjs +37 -20
  27. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  28. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
  29. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  30. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
  31. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  32. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
  33. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  34. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
  35. package/dist/feature-scripts-classic-concat-loader.js +58 -5
  36. package/dist/feature-scripts-classic-concat-loader.mjs +58 -5
  37. package/dist/feature-scripts-content-script-wrapper.js +14 -17
  38. package/dist/feature-scripts-content-script-wrapper.mjs +14 -17
  39. package/dist/feature-scripts-native-geturl-import-loader.mjs +10 -3
  40. package/dist/lib/asset-source-maps.d.ts +7 -0
  41. package/dist/lib/config-loader.d.ts +7 -34
  42. package/dist/lib/loader-source-maps.d.ts +17 -0
  43. package/dist/lib/messages.d.ts +1 -0
  44. package/dist/lib/msg-placeholders.d.ts +2 -0
  45. package/dist/lib/paths.d.ts +2 -0
  46. package/dist/lib/project.d.ts +3 -0
  47. package/dist/lib/session-project-root.d.ts +1 -0
  48. package/dist/minimum-script-file.js +41 -1
  49. package/dist/minimum-script-file.mjs +41 -1
  50. package/dist/module.d.ts +1 -1
  51. package/dist/module.mjs +1 -1
  52. package/dist/plugin-css/css-lib/dead-url-refs.d.ts +5 -0
  53. package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +32 -0
  54. package/dist/plugin-css/css-lib/messages.d.ts +3 -0
  55. package/dist/plugin-css/css-lib/verbatim-css.d.ts +9 -0
  56. package/dist/plugin-css/css-parse-guard-loader.d.ts +3 -0
  57. package/dist/plugin-css/css-tools/postcss.d.ts +1 -0
  58. package/dist/plugin-css/dead-css-url-loader.d.ts +8 -4
  59. package/dist/plugin-css/index.d.ts +1 -0
  60. package/dist/plugin-js-frameworks/js-frameworks-lib/jsx-transform.d.ts +10 -0
  61. package/dist/plugin-js-frameworks/js-tools/solid-jsx-runtime.d.ts +8 -0
  62. package/dist/plugin-js-frameworks/js-tools/solid.d.ts +3 -0
  63. package/dist/plugin-js-frameworks/swc-targets.d.ts +3 -0
  64. package/dist/plugin-reload/classify-reload.d.ts +6 -0
  65. package/dist/plugin-reload/index.d.ts +2 -1
  66. package/dist/plugin-reload/reload-dispatch.d.ts +1 -0
  67. package/dist/plugin-special-folders/folder-extensions/resolve-dirs.d.ts +1 -0
  68. package/dist/plugin-special-folders/folder-extensions/utils.d.ts +3 -0
  69. package/dist/plugin-special-folders/messages.d.ts +2 -0
  70. package/dist/plugin-special-folders/resolve-public-folder.d.ts +13 -0
  71. package/dist/plugin-web-extension/feature-html/html-lib/assets.d.ts +1 -1
  72. package/dist/plugin-web-extension/feature-html/html-lib/base-href.d.ts +11 -0
  73. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +2 -2
  74. package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +13 -0
  75. package/dist/plugin-web-extension/feature-html/index.d.ts +1 -0
  76. package/dist/plugin-web-extension/feature-html/steps/ensure-hmr-for-scripts.d.ts +1 -1
  77. package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +2 -0
  78. package/dist/plugin-web-extension/feature-icons/omnibox-fields.d.ts +2 -0
  79. package/dist/plugin-web-extension/feature-icons/theme-image-fields.d.ts +2 -0
  80. package/dist/plugin-web-extension/feature-json/json-validation.d.ts +1 -0
  81. package/dist/plugin-web-extension/feature-manifest/index.d.ts +1 -0
  82. package/dist/plugin-web-extension/feature-manifest/manifest-lib/manifest.d.ts +1 -1
  83. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/index.d.ts +1 -1
  84. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
  85. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/storage.d.ts +1 -1
  86. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/theme.d.ts +1 -1
  87. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/index.d.ts +1 -1
  88. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/chrome_settings_overrides.d.ts +1 -1
  89. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/index.d.ts +1 -1
  90. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/theme_experiment.d.ts +1 -1
  91. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +2 -1
  92. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/declarative_net_request.d.ts +1 -1
  93. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/index.d.ts +1 -1
  94. package/dist/plugin-web-extension/feature-manifest/messages.d.ts +2 -0
  95. package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +4 -0
  96. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-csp.d.ts +1 -1
  97. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults.d.ts +1 -0
  98. package/dist/plugin-web-extension/feature-scripts/steps/native-geturl-import-loader.d.ts +7 -2
  99. package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
  100. package/dist/plugin-web-extension/index.d.ts +1 -0
  101. package/dist/plugin-web-extension/shared/html-surfaces.d.ts +19 -0
  102. package/dist/plugin-web-extension/shared/manifest-fields-change-detector.d.ts +1 -0
  103. package/dist/plugin-web-extension/shared/manifest-fields.d.ts +18 -0
  104. package/dist/plugin-web-extension/shared/manifest-path-assets.d.ts +4 -0
  105. package/dist/plugin-web-extension/shared/paths.d.ts +1 -0
  106. package/dist/solid-jsx-runtime.mjs +15 -0
  107. package/dist/types.d.ts +20 -7
  108. package/package.json +1 -1
  109. package/dist/494.mjs +0 -89
  110. package/dist/86.mjs +0 -36
package/dist/518.mjs ADDED
@@ -0,0 +1,434 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import { inspectPublicFolders } from "./278.mjs";
3
+ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
4
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
5
+ import * as __rspack_external_parse5_utilities_78b19c6a from "parse5-utilities";
6
+ function normalizeManifestOutputPath(originalPath) {
7
+ if (!originalPath) return originalPath;
8
+ const unixPath = originalPath.replace(/\\/g, '/');
9
+ if (/^\/public\//i.test(unixPath)) return unixPath.replace(/^\/public\//i, '');
10
+ if (/^(?:\.\/)?public\//i.test(unixPath)) return unixPath.replace(/^(?:\.\/)?public\//i, '');
11
+ if (/^\//.test(unixPath)) return unixPath.replace(/^\//, '');
12
+ return unixPath;
13
+ }
14
+ function manifestPageOutputTarget(raw, compiledTarget, manifestPath) {
15
+ const unixPath = raw.replace(/\\/g, '/');
16
+ if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(unixPath)) return normalizeManifestOutputPath(unixPath);
17
+ if (/^\//.test(unixPath)) {
18
+ const rest = unixPath.replace(/^\/+/, '');
19
+ if (manifestPath && rest) {
20
+ const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
21
+ const inPublic = __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestDir, 'public', rest));
22
+ const inRoot = __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestDir, rest));
23
+ if (inRoot && !inPublic) return compiledTarget;
24
+ }
25
+ return normalizeManifestOutputPath(unixPath);
26
+ }
27
+ return compiledTarget;
28
+ }
29
+ function manifestJsonOutputTarget(raw, compiledTarget, manifestPath, projectPath) {
30
+ const unixPath = raw.replace(/\\/g, '/');
31
+ if (/^(?:\/public\/|(?:\.\/)?public\/|\/)/i.test(unixPath) || !manifestPath) return manifestPageOutputTarget(unixPath, compiledTarget, manifestPath);
32
+ const rest = unixPath.replace(/^\.\//, '');
33
+ if (!rest || rest.split('/').includes('..')) return compiledTarget;
34
+ const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
35
+ if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestDir, rest))) return compiledTarget;
36
+ const { publicDir } = inspectPublicFolders(manifestPath, projectPath);
37
+ if (publicDir && __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(publicDir, rest))) return rest;
38
+ return compiledTarget;
39
+ }
40
+ function pathEscapesExtensionRoot(normalized) {
41
+ return !normalized || normalized.split('/').includes('..') || /^[A-Za-z]:/.test(normalized);
42
+ }
43
+ function externalAssetOutputPath(normalized, root) {
44
+ const unix = normalized.replace(/\\/g, '/');
45
+ const noDrive = unix.replace(/^([A-Za-z]):(?:\/|$)/, '_drive_$1/');
46
+ const safe = noDrive.split('/').map((segment)=>{
47
+ if ('..' === segment) return '_';
48
+ if ('.' === segment || !segment) return '';
49
+ return segment.replace(/[<>:"|?*\x00-\x1F]/g, '_');
50
+ }).filter(Boolean).join('/');
51
+ return safe ? `${root}/${safe}` : `${root}/external`;
52
+ }
53
+ function iconOutputPath(raw) {
54
+ if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
55
+ const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
56
+ if (!pathEscapesExtensionRoot(normalized)) return normalized;
57
+ return externalAssetOutputPath(normalized, 'icons');
58
+ }
59
+ function themeIconOutputPath(raw, folder) {
60
+ return featureAssetOutputPath(raw, folder);
61
+ }
62
+ function themeImageOutputPath(raw) {
63
+ return featureAssetOutputPath(raw, 'theme/images');
64
+ }
65
+ function featureAssetOutputPath(raw, folder) {
66
+ if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
67
+ const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
68
+ if (!pathEscapesExtensionRoot(normalized)) return `${folder}/${normalized}`;
69
+ return externalAssetOutputPath(normalized, folder);
70
+ }
71
+ function isUrl(src) {
72
+ try {
73
+ new URL(src);
74
+ return true;
75
+ } catch (err) {
76
+ return false;
77
+ }
78
+ }
79
+ function emitSrcsetCandidates(srcset, node, assetType, attributeName, onResourceFound) {
80
+ for (const candidate of srcset.split(',')){
81
+ const url = candidate.trim().split(/\s+/)[0];
82
+ if (!url) continue;
83
+ const { cleanPath } = cleanAssetUrl(url);
84
+ if (cleanPath && !isUrl(cleanPath)) onResourceFound({
85
+ filePath: url,
86
+ childNode: node,
87
+ assetType,
88
+ attributeName
89
+ });
90
+ }
91
+ }
92
+ function parseHtml(node, onResourceFound) {
93
+ if ('#comment' === node.nodeName || '#text' === node.nodeName) return;
94
+ if ("script" === node.nodeName) {
95
+ const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
96
+ if (!src) return;
97
+ if (isUrl(src)) return;
98
+ onResourceFound({
99
+ filePath: src,
100
+ childNode: node,
101
+ assetType: "script"
102
+ });
103
+ } else if ('link' === node.nodeName) {
104
+ const href = node.attrs?.find((attr)=>'href' === attr.name)?.value;
105
+ const rel = node.attrs?.find((attr)=>'rel' === attr.name)?.value;
106
+ const imagesrcset = node.attrs?.find((attr)=>'imagesrcset' === attr.name)?.value;
107
+ if (imagesrcset) emitSrcsetCandidates(imagesrcset, node, 'staticHref', 'imagesrcset', onResourceFound);
108
+ if (!href) return;
109
+ if (isUrl(href)) return;
110
+ const nonStylesheetRelTokens = [
111
+ 'dns-prefetch',
112
+ 'icon',
113
+ 'apple-touch-icon',
114
+ 'apple-touch-icon-precomposed',
115
+ 'mask-icon',
116
+ 'manifest',
117
+ 'modulepreload',
118
+ 'preconnect',
119
+ 'prefetch',
120
+ 'preload',
121
+ 'prerender'
122
+ ];
123
+ const relTokens = rel ? rel.toLowerCase().split(/\s+/) : [];
124
+ onResourceFound(relTokens.some((token)=>nonStylesheetRelTokens.includes(token)) ? {
125
+ filePath: href,
126
+ childNode: node,
127
+ assetType: 'staticHref',
128
+ attributeName: 'href'
129
+ } : {
130
+ filePath: href,
131
+ childNode: node,
132
+ assetType: 'css'
133
+ });
134
+ } else if ('audio' === node.nodeName || 'embed' === node.nodeName || 'iframe' === node.nodeName || 'img' === node.nodeName || 'input' === node.nodeName || 'source' === node.nodeName || 'track' === node.nodeName || 'video' === node.nodeName) {
135
+ const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
136
+ if (src && !isUrl(src)) onResourceFound({
137
+ filePath: src,
138
+ childNode: node,
139
+ assetType: 'staticSrc',
140
+ attributeName: 'src'
141
+ });
142
+ const srcset = node.attrs?.find((attr)=>'srcset' === attr.name)?.value;
143
+ if (srcset) emitSrcsetCandidates(srcset, node, 'staticSrc', 'srcset', onResourceFound);
144
+ if ('video' === node.nodeName) {
145
+ const poster = node.attrs?.find((attr)=>'poster' === attr.name)?.value;
146
+ if (poster && !isUrl(poster)) onResourceFound({
147
+ filePath: poster,
148
+ childNode: node,
149
+ assetType: 'staticSrc',
150
+ attributeName: 'poster'
151
+ });
152
+ }
153
+ }
154
+ const { childNodes = [] } = node;
155
+ for (const childNode of childNodes)if ('#comment' !== childNode.nodeName && '#text' !== childNode.nodeName) parseHtml(childNode, onResourceFound);
156
+ }
157
+ const cloneParsedHtmlAsset = (assets)=>({
158
+ css: [
159
+ ...assets.css || []
160
+ ],
161
+ js: [
162
+ ...assets.js || []
163
+ ],
164
+ moduleJs: [
165
+ ...assets.moduleJs || []
166
+ ],
167
+ static: [
168
+ ...assets.static || []
169
+ ]
170
+ });
171
+ const assetsFromHtmlCache = new Map();
172
+ function getAssetsFromHtml(htmlFilePath, htmlContent) {
173
+ const assets = {
174
+ css: [],
175
+ js: [],
176
+ moduleJs: [],
177
+ static: []
178
+ };
179
+ if (!htmlFilePath) return assets;
180
+ let cacheKey;
181
+ if (void 0 === htmlContent) try {
182
+ const stat = __rspack_external_node_fs_5ea92f0c.statSync(htmlFilePath);
183
+ cacheKey = `${stat.mtimeMs}:${stat.size}`;
184
+ const cached = assetsFromHtmlCache.get(htmlFilePath);
185
+ if (cached && cached.key === cacheKey) return cloneParsedHtmlAsset(cached.assets);
186
+ } catch {
187
+ cacheKey = void 0;
188
+ }
189
+ try {
190
+ const htmlString = htmlContent || __rspack_external_node_fs_5ea92f0c.readFileSync(htmlFilePath, {
191
+ encoding: 'utf8'
192
+ });
193
+ if (!htmlString) return assets;
194
+ const htmlDocument = __rspack_external_parse5_utilities_78b19c6a.parse(htmlString);
195
+ const baseHref = getBaseHref(htmlDocument);
196
+ const getAbsolutePath = (htmlFilePath, filePathWithParts)=>{
197
+ const { cleanPath } = cleanAssetUrl(filePathWithParts);
198
+ return resolveHtmlRefPath(htmlFilePath, baseHref, cleanPath);
199
+ };
200
+ parseHtml(htmlDocument, ({ filePath, childNode, assetType })=>{
201
+ const fileAbsolutePath = getAbsolutePath(htmlFilePath, filePath);
202
+ switch(assetType){
203
+ case "script":
204
+ {
205
+ assets.js?.push(fileAbsolutePath);
206
+ const scriptType = childNode?.attrs?.find((attr)=>'type' === attr.name)?.value;
207
+ if ('module' === String(scriptType || '').toLowerCase()) assets.moduleJs?.push(fileAbsolutePath);
208
+ break;
209
+ }
210
+ case 'css':
211
+ assets.css?.push(fileAbsolutePath);
212
+ break;
213
+ case 'staticSrc':
214
+ case 'staticHref':
215
+ if (filePath.startsWith('#')) break;
216
+ assets.static?.push(fileAbsolutePath);
217
+ break;
218
+ default:
219
+ break;
220
+ }
221
+ });
222
+ } catch (error) {
223
+ const code = error?.code;
224
+ if (void 0 === htmlContent && 'ENOENT' === code) {
225
+ assetsFromHtmlCache.delete(htmlFilePath);
226
+ throw error;
227
+ }
228
+ return assets;
229
+ }
230
+ if (cacheKey) assetsFromHtmlCache.set(htmlFilePath, {
231
+ key: cacheKey,
232
+ assets: cloneParsedHtmlAsset(assets)
233
+ });
234
+ return assets;
235
+ }
236
+ function getHtmlPageDeclaredAssetPath(filepathList, filePath, extension) {
237
+ const entryname = Object.keys(filepathList).find((key)=>{
238
+ const includePath = filepathList[key];
239
+ if (includePath === filePath) return true;
240
+ if (!includePath || !__rspack_external_node_fs_5ea92f0c.existsSync(includePath)) return false;
241
+ const assets = getAssetsFromHtml(includePath);
242
+ return Boolean(assets?.js?.includes(filePath) || assets?.css?.includes(filePath));
243
+ }) || '';
244
+ const extname = getExtname(filePath);
245
+ if (!entryname) return `${filePath.replace(extname, '')}${extension}`;
246
+ return `/${entryname.replace(extname, '')}${extension}`;
247
+ }
248
+ function getExtname(filePath) {
249
+ return __rspack_external_node_path_c5b9b54f.extname(filePath);
250
+ }
251
+ function getFilePath(filePath, extension, isPublic) {
252
+ if (isPublic) return `/${filePath}${extension}`;
253
+ return `${filePath}${extension}`;
254
+ }
255
+ function isFromIncludeList(filePath, includeList) {
256
+ return Object.values(includeList || {}).some((value)=>value === filePath);
257
+ }
258
+ function utils_isUrl(src) {
259
+ try {
260
+ new URL(src);
261
+ return true;
262
+ } catch (err) {
263
+ return false;
264
+ }
265
+ }
266
+ function resolveStaticAttributeName(assetType, attributeName) {
267
+ if (attributeName) return attributeName;
268
+ return 'staticSrc' === assetType ? 'src' : 'href';
269
+ }
270
+ function rewriteSrcsetCandidate(srcset, fromCleanPath, toUrl) {
271
+ return srcset.split(',').map((candidate)=>{
272
+ const match = candidate.match(/^(\s*)(\S+)(.*)$/);
273
+ if (!match) return candidate;
274
+ const [, lead, url, rest] = match;
275
+ const { cleanPath } = cleanAssetUrl(url);
276
+ if (cleanPath !== fromCleanPath && url !== fromCleanPath) return candidate;
277
+ return `${lead}${toUrl}${rest}`;
278
+ }).join(',');
279
+ }
280
+ function applyRewrittenStaticUrl(node, attributeName, cleanPath, value) {
281
+ if ('srcset' === attributeName || 'imagesrcset' === attributeName) {
282
+ const current = __rspack_external_parse5_utilities_78b19c6a.getAttribute(node, attributeName) || '';
283
+ return __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, attributeName, rewriteSrcsetCandidate(current, cleanPath, value));
284
+ }
285
+ return __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, attributeName, value);
286
+ }
287
+ function cleanAssetUrl(url) {
288
+ const hashIndex = url.indexOf('#');
289
+ const queryIndex = url.indexOf('?');
290
+ let endIndex = url.length;
291
+ if (-1 !== hashIndex && -1 !== queryIndex) endIndex = Math.min(hashIndex, queryIndex);
292
+ else if (-1 !== hashIndex) endIndex = hashIndex;
293
+ else if (-1 !== queryIndex) endIndex = queryIndex;
294
+ const cleanPath = url.slice(0, endIndex);
295
+ const hash = -1 !== hashIndex ? url.slice(hashIndex) : '';
296
+ const search = -1 !== queryIndex ? url.slice(queryIndex, -1 !== hashIndex ? hashIndex : void 0) : '';
297
+ return {
298
+ cleanPath,
299
+ hash,
300
+ search
301
+ };
302
+ }
303
+ function isHttpLike(inputUrl) {
304
+ return /^https?:\/\//i.test(inputUrl) || inputUrl.startsWith('//');
305
+ }
306
+ function isSpecialScheme(u) {
307
+ return /^(data:|blob:|chrome-extension:|javascript:|about:)/i.test(u);
308
+ }
309
+ function cleanLeading(s) {
310
+ return s.replace(/^\/+/, '').replace(/^\.\//, '').replace(/^\./, '');
311
+ }
312
+ function joinEmittedAssetName(prefix, rel) {
313
+ const parts = __rspack_external_node_path_c5b9b54f.posix.join(prefix, rel).split('/');
314
+ let i = 0;
315
+ while(i < parts.length && ('..' === parts[i] || '.' === parts[i]))i++;
316
+ return parts.slice(i).join('/') || __rspack_external_node_path_c5b9b54f.posix.basename(rel);
317
+ }
318
+ function htmlStaticAssetOutputName(manifestDir, htmlEntry, absolutePath) {
319
+ if ('string' == typeof manifestDir && manifestDir) {
320
+ const rel = __rspack_external_node_path_c5b9b54f.relative(manifestDir, absolutePath);
321
+ if (rel && !__rspack_external_node_path_c5b9b54f.isAbsolute(rel)) {
322
+ const posix = rel.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
323
+ const escapes = posix.split('/').includes('..');
324
+ return escapes ? externalAssetOutputPath(posix, 'assets') : joinEmittedAssetName('assets', posix);
325
+ }
326
+ }
327
+ return joinEmittedAssetName('assets', computePosixRelative(htmlEntry, absolutePath));
328
+ }
329
+ function computePosixRelative(fromPath, toPath) {
330
+ const fromRoot = __rspack_external_node_path_c5b9b54f.parse(fromPath).root;
331
+ const toRoot = __rspack_external_node_path_c5b9b54f.parse(toPath).root;
332
+ if (fromRoot && toRoot && String(fromRoot).toLowerCase() !== String(toRoot).toLowerCase()) {
333
+ const base = __rspack_external_node_path_c5b9b54f.basename(toPath);
334
+ return base.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
335
+ }
336
+ const rel = __rspack_external_node_path_c5b9b54f.relative(__rspack_external_node_path_c5b9b54f.dirname(fromPath), toPath) || toPath;
337
+ return rel.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
338
+ }
339
+ function resolveAbsoluteFsPath(params) {
340
+ const { asset, projectRoot, publicRootForResource, outputRoot, manifestRoot } = params;
341
+ const looksLikeRootUrl = asset.startsWith('/') && !(asset.startsWith(projectRoot) || asset.startsWith(publicRootForResource) || asset.startsWith(outputRoot));
342
+ const rootUrlIsClaimed = (value)=>{
343
+ const normalized = cleanLeading(value.slice(1));
344
+ const withoutPublicPrefix = normalized.replace(/^public\//, '');
345
+ if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(publicRootForResource, withoutPublicPrefix))) return true;
346
+ return Boolean(manifestRoot && __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestRoot, normalized)));
347
+ };
348
+ const isRootUrl = looksLikeRootUrl && (rootUrlIsClaimed(asset) || !__rspack_external_node_fs_5ea92f0c.existsSync(asset));
349
+ const isDotPublic = asset.startsWith('./public/');
350
+ const isPlainPublic = asset.startsWith('public/');
351
+ const absoluteFsPath = isRootUrl ? (()=>{
352
+ const rootRelative = asset.slice(1);
353
+ const normalized = cleanLeading(rootRelative);
354
+ const withoutPublicPrefix = normalized.replace(/^public\//, '');
355
+ const candidate = __rspack_external_node_path_c5b9b54f.join(publicRootForResource, withoutPublicPrefix);
356
+ if (__rspack_external_node_fs_5ea92f0c.existsSync(candidate)) return candidate;
357
+ const manifestCandidate = manifestRoot ? __rspack_external_node_path_c5b9b54f.join(manifestRoot, normalized) : '';
358
+ if (manifestCandidate && __rspack_external_node_fs_5ea92f0c.existsSync(manifestCandidate)) return manifestCandidate;
359
+ return manifestCandidate || candidate;
360
+ })() : isDotPublic ? __rspack_external_node_path_c5b9b54f.join(projectRoot, cleanLeading(asset)) : isPlainPublic ? __rspack_external_node_path_c5b9b54f.join(projectRoot, asset.replace(/^\./, '')) : __rspack_external_node_path_c5b9b54f.isAbsolute(asset) ? asset : __rspack_external_node_path_c5b9b54f.join(projectRoot, asset);
361
+ const relToPublic = __rspack_external_node_path_c5b9b54f.relative(publicRootForResource, absoluteFsPath);
362
+ const isUnderPublicRoot = relToPublic && !relToPublic.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(relToPublic);
363
+ return {
364
+ absoluteFsPath,
365
+ isUnderPublicRoot: Boolean(isUnderPublicRoot),
366
+ isRootUrl
367
+ };
368
+ }
369
+ function resolveHtmlRefPath(htmlFilePath, baseHref, cleanPath) {
370
+ if (utils_isUrl(cleanPath)) return cleanPath;
371
+ if (cleanPath.startsWith('/')) return cleanPath;
372
+ const htmlDir = __rspack_external_node_path_c5b9b54f.dirname(htmlFilePath);
373
+ const pageRelative = __rspack_external_node_path_c5b9b54f.join(htmlDir, cleanPath);
374
+ if (!baseHref || utils_isUrl(baseHref)) return pageRelative;
375
+ const throughBase = __rspack_external_node_path_c5b9b54f.join(htmlDir, baseHref, cleanPath);
376
+ if (__rspack_external_node_fs_5ea92f0c.existsSync(throughBase) || !__rspack_external_node_fs_5ea92f0c.existsSync(pageRelative)) return throughBase;
377
+ return pageRelative;
378
+ }
379
+ function getBaseHref(htmlDocument) {
380
+ return getBaseNode(htmlDocument)?.attrs?.find((a)=>'href' === a.name)?.value;
381
+ }
382
+ function getBaseNode(htmlDocument) {
383
+ const htmlChildren = htmlDocument.childNodes || [];
384
+ for (const node of htmlChildren)if (node?.nodeName === 'html') {
385
+ for (const child of node.childNodes || [])if (child?.nodeName === 'head') {
386
+ for (const headChild of child.childNodes || [])if (headChild?.nodeName === 'base') {
387
+ const href = headChild.attrs?.find((a)=>'href' === a.name)?.value;
388
+ if (href) return headChild;
389
+ }
390
+ }
391
+ }
392
+ }
393
+ const ASSET_EXT = /\.(png|jpe?g|gif|webp|svg|avif|ico|bmp|cur|woff2?|ttf|otf|eot|mp3|mp4|webm|ogg|wav)$/i;
394
+ const URL_REF = /url\(\s*(?:"([^"\n]*)"|'([^'\n]*)'|([^)'"\s]*))\s*\)/g;
395
+ function toPosixPath(value) {
396
+ return String(value).split(__rspack_external_node_path_c5b9b54f.sep).join('/');
397
+ }
398
+ function isDeadCssUrlRef(rawRequest, { issuerDir, roots }) {
399
+ const req = String(rawRequest).split('?')[0].split('#')[0];
400
+ if (!req || req.startsWith('//') || /^[a-z][a-z0-9+.-]*:/i.test(req)) return false;
401
+ if (req.startsWith('~') || req.startsWith('@')) return false;
402
+ const isRootRef = req.startsWith('/');
403
+ const isRelativeRef = req.startsWith('./') || req.startsWith('../');
404
+ const isBareAssetRef = !isRootRef && !isRelativeRef && ASSET_EXT.test(req);
405
+ if (!isRootRef && !isRelativeRef && !isBareAssetRef) return false;
406
+ const candidates = isRootRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req.slice(1))) : [
407
+ __rspack_external_node_path_c5b9b54f.resolve(issuerDir, req),
408
+ ...isBareAssetRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req)) : []
409
+ ];
410
+ return !candidates.some((candidate)=>__rspack_external_node_fs_5ea92f0c.existsSync(candidate));
411
+ }
412
+ function replaceCssUrlRefs(source, replacer) {
413
+ return source.replace(URL_REF, (whole, dq, sq, bare)=>{
414
+ const request = dq ?? sq ?? bare ?? '';
415
+ if (!request) return whole;
416
+ const next = replacer(request);
417
+ if (void 0 === next) return whole;
418
+ return `url("${next.replace(/["\\]/g, '\\$&')}")`;
419
+ });
420
+ }
421
+ function extractCssUrlRefs(source) {
422
+ const found = [];
423
+ const seen = new Set();
424
+ URL_REF.lastIndex = 0;
425
+ let match;
426
+ while(null !== (match = URL_REF.exec(source))){
427
+ const request = match[1] ?? match[2] ?? match[3] ?? '';
428
+ if (!request || seen.has(request)) continue;
429
+ seen.add(request);
430
+ found.push(request);
431
+ }
432
+ return found;
433
+ }
434
+ export { applyRewrittenStaticUrl, cleanAssetUrl, cleanLeading, extractCssUrlRefs, getAssetsFromHtml, getBaseHref, getBaseNode, getExtname, getFilePath, getHtmlPageDeclaredAssetPath, htmlStaticAssetOutputName, iconOutputPath, isDeadCssUrlRef, isFromIncludeList, isHttpLike, isSpecialScheme, manifestJsonOutputTarget, manifestPageOutputTarget, normalizeManifestOutputPath, parseHtml, replaceCssUrlRefs, resolveAbsoluteFsPath, resolveHtmlRefPath, resolveStaticAttributeName, themeIconOutputPath, themeImageOutputPath, toPosixPath, utils_isUrl };