extension-develop 4.1.12 → 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.
- package/dist/0~dev-server.mjs +147 -81
- package/dist/0~rspack-config.mjs +1096 -694
- package/dist/0~zip.mjs +1 -1
- package/dist/101.mjs +185 -900
- package/dist/129.mjs +89 -0
- package/dist/278.mjs +52 -0
- package/dist/292.mjs +61 -0
- package/dist/372.mjs +87 -0
- package/dist/518.mjs +434 -0
- package/dist/77.mjs +928 -0
- package/dist/839.mjs +176 -39
- package/dist/845.mjs +10 -1
- package/dist/887.mjs +1 -1
- package/dist/bridge-entry.d.ts +2 -1
- package/dist/bridge.mjs +56 -7
- package/dist/css-parse-guard-loader.mjs +3 -0
- package/dist/dead-css-url-loader.mjs +51 -24
- package/dist/dev-server/cleanup.d.ts +2 -1
- package/dist/dev-server/control-bridge/broker.d.ts +1 -0
- package/dist/dev-server/control-bridge/contracts.d.ts +2 -0
- package/dist/dev-server/control-bridge/logs-query.d.ts +12 -1
- package/dist/dev-server/control-bridge/producer-runtime.d.ts +1 -1
- package/dist/dev-server/messages.d.ts +8 -0
- package/dist/dev-server/session-restart.d.ts +29 -0
- package/dist/ensure-hmr-for-scripts.js +37 -20
- package/dist/ensure-hmr-for-scripts.mjs +37 -20
- package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
- package/dist/feature-scripts-classic-concat-loader.js +58 -5
- package/dist/feature-scripts-classic-concat-loader.mjs +58 -5
- package/dist/feature-scripts-content-script-wrapper.js +14 -17
- package/dist/feature-scripts-content-script-wrapper.mjs +14 -17
- package/dist/feature-scripts-native-geturl-import-loader.mjs +10 -3
- package/dist/lib/asset-source-maps.d.ts +7 -0
- package/dist/lib/config-loader.d.ts +7 -34
- package/dist/lib/loader-source-maps.d.ts +17 -0
- package/dist/lib/messages.d.ts +1 -0
- package/dist/lib/msg-placeholders.d.ts +2 -0
- package/dist/lib/paths.d.ts +2 -0
- package/dist/lib/project.d.ts +3 -0
- package/dist/lib/session-project-root.d.ts +1 -0
- package/dist/minimum-script-file.js +41 -1
- package/dist/minimum-script-file.mjs +41 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +1 -1
- package/dist/plugin-css/css-lib/dead-url-refs.d.ts +5 -0
- package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +32 -0
- package/dist/plugin-css/css-lib/messages.d.ts +3 -0
- package/dist/plugin-css/css-lib/verbatim-css.d.ts +9 -0
- package/dist/plugin-css/css-parse-guard-loader.d.ts +3 -0
- package/dist/plugin-css/css-tools/postcss.d.ts +1 -0
- package/dist/plugin-css/dead-css-url-loader.d.ts +8 -4
- package/dist/plugin-css/index.d.ts +1 -0
- package/dist/plugin-js-frameworks/js-frameworks-lib/jsx-transform.d.ts +10 -0
- package/dist/plugin-js-frameworks/js-tools/solid-jsx-runtime.d.ts +8 -0
- package/dist/plugin-js-frameworks/js-tools/solid.d.ts +3 -0
- package/dist/plugin-js-frameworks/swc-targets.d.ts +3 -0
- package/dist/plugin-reload/classify-reload.d.ts +6 -0
- package/dist/plugin-reload/index.d.ts +2 -1
- package/dist/plugin-reload/reload-dispatch.d.ts +1 -0
- package/dist/plugin-special-folders/folder-extensions/resolve-dirs.d.ts +1 -0
- package/dist/plugin-special-folders/folder-extensions/utils.d.ts +3 -0
- package/dist/plugin-special-folders/messages.d.ts +2 -0
- package/dist/plugin-special-folders/resolve-public-folder.d.ts +13 -0
- package/dist/plugin-web-extension/feature-html/html-lib/assets.d.ts +1 -1
- package/dist/plugin-web-extension/feature-html/html-lib/base-href.d.ts +11 -0
- package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +2 -2
- package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +13 -0
- package/dist/plugin-web-extension/feature-html/index.d.ts +1 -0
- package/dist/plugin-web-extension/feature-html/steps/ensure-hmr-for-scripts.d.ts +1 -1
- package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +2 -0
- package/dist/plugin-web-extension/feature-icons/omnibox-fields.d.ts +2 -0
- package/dist/plugin-web-extension/feature-icons/theme-image-fields.d.ts +2 -0
- package/dist/plugin-web-extension/feature-json/json-validation.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/index.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/manifest.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/storage.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/theme.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/chrome_settings_overrides.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/theme_experiment.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +2 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/declarative_net_request.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/messages.d.ts +2 -0
- package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +4 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-csp.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/steps/native-geturl-import-loader.d.ts +7 -2
- package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
- package/dist/plugin-web-extension/index.d.ts +1 -0
- package/dist/plugin-web-extension/shared/html-surfaces.d.ts +19 -0
- package/dist/plugin-web-extension/shared/manifest-fields-change-detector.d.ts +1 -0
- package/dist/plugin-web-extension/shared/manifest-fields.d.ts +18 -0
- package/dist/plugin-web-extension/shared/manifest-path-assets.d.ts +4 -0
- package/dist/plugin-web-extension/shared/paths.d.ts +1 -0
- package/dist/solid-jsx-runtime.mjs +15 -0
- package/dist/types.d.ts +20 -7
- package/package.json +1 -1
- package/dist/494.mjs +0 -89
- package/dist/86.mjs +0 -36
package/dist/101.mjs
CHANGED
|
@@ -2,16 +2,16 @@ import { createRequire as __extjsCreateRequire } from "node:module"; const requi
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
|
-
import pintor from "pintor";
|
|
6
5
|
import { createHash } from "node:crypto";
|
|
7
6
|
import { fetchExtensionFromStore } from "extension-from-store";
|
|
8
7
|
import node_fs from "node:fs";
|
|
9
8
|
import node_path from "node:path";
|
|
10
9
|
import { getSpecialFoldersData } from "browser-extension-manifest-fields";
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
10
|
+
import pintor from "pintor";
|
|
11
|
+
import { devtoolsEngineFor, managedDependencyConflict, resolveProjectStructureSync, getDirs, computePreviewOutputPath, eventsPath as session_paths_eventsPath, anotherDevSessionActive, previewingSourceFallback, asAbsolute, previewing, starting, debugPreviewOutput, ensureSessionArtifactsIgnoreFile, debugDirs, debugBrowser, readyContractPath, configLoadingError, normalizeBrowser, previewingCustomOutput, browserArtifactsDir, getProjectStructure, isUsingExperimentalConfig as messages_isUsingExperimentalConfig, getDistPath, configBrowserOrThrow } from "./77.mjs";
|
|
12
|
+
import { humanWarn, isDebug, browserRowValue, artifactNoun, prefix as messaging_prefix, card, humanLine } from "./349.mjs";
|
|
13
|
+
import { readProjectDependencies } from "./80.mjs";
|
|
13
14
|
import { stripBom, parseJsonSafe } from "./23.mjs";
|
|
14
|
-
import { readyContractPath, browserArtifactsDir, eventsPath as session_paths_eventsPath } from "./494.mjs";
|
|
15
15
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
16
16
|
import { dirname as __rspack_dirname } from "node:path";
|
|
17
17
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
@@ -59,382 +59,22 @@ function isGeckoBasedBrowser(browser) {
|
|
|
59
59
|
function isWebkitBasedBrowser(browser) {
|
|
60
60
|
return WEBKIT_BASED_BROWSERS.includes(browser) || String(browser).includes('webkit');
|
|
61
61
|
}
|
|
62
|
-
function getLoggingPrefix(type) {
|
|
63
|
-
return messaging_prefix(type);
|
|
64
|
-
}
|
|
65
|
-
function isPathLike(input) {
|
|
66
|
-
return input.includes('/') || input.includes('\\') || __rspack_external_node_path_c5b9b54f.isAbsolute(input);
|
|
67
|
-
}
|
|
68
|
-
function resolvedWorkspaceManifest(projectPath, manifestPath) {
|
|
69
|
-
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
70
|
-
const packageDir = 'src' === __rspack_external_node_path_c5b9b54f.basename(manifestDir) ? __rspack_external_node_path_c5b9b54f.dirname(manifestDir) : manifestDir;
|
|
71
|
-
const display = __rspack_external_node_path_c5b9b54f.relative(projectPath, packageDir) || packageDir;
|
|
72
|
-
return `${getLoggingPrefix('info')} ${pintor.gray('Workspace root detected.')}\n${pintor.gray('PACKAGE')} ${pintor.underline(display)}`;
|
|
73
|
-
}
|
|
74
|
-
function remoteFetchTimedOut(target, ms) {
|
|
75
|
-
return `${getLoggingPrefix('error')} Timed out after ${Math.round(ms / 1000)} s fetching the remote file.\n${pintor.gray('URL')} ${pintor.underline(target)}\nCheck your network, or set ${pintor.blue('EXTENSION_FETCH_TIMEOUT_MS')} to allow more time.`;
|
|
76
|
-
}
|
|
77
|
-
function manifestInvalidJson(manifestPath, error) {
|
|
78
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
79
|
-
return `${getLoggingPrefix('error')} Couldn't parse manifest.json as JSON.\n${pintor.gray('PATH')} ${pintor.underline(manifestPath)}\n${pintor.gray('REASON')} ${pintor.red(detail)}\nFix the syntax error, then run the command again.`;
|
|
80
|
-
}
|
|
81
|
-
function notAnExtensionManifestError(manifestPath) {
|
|
82
|
-
return `${getLoggingPrefix('error')} manifest.json isn't a browser extension manifest.\nIt has no ${pintor.blue('manifest_version')} field, so it looks like a PWA web-app manifest.\n${pintor.gray('PATH')} ${pintor.underline(manifestPath)}\nPoint Extension.js at the directory that contains your extension manifest.`;
|
|
83
|
-
}
|
|
84
|
-
function manifestNotFoundError(manifestPath, candidates = []) {
|
|
85
|
-
const base = `${getLoggingPrefix('error')} Manifest file not found.\n${pintor.gray('NOT FOUND')} ${pintor.underline(manifestPath)}\nEnsure the path to your extension exists, then try again.`;
|
|
86
|
-
if (!candidates.length) return base;
|
|
87
|
-
const projectRoot = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
88
|
-
const hint = 1 === candidates.length ? "Did you mean to point at this workspace package?" : "Did you mean to point at one of these workspace packages?";
|
|
89
|
-
const suggestions = candidates.map((candidate)=>{
|
|
90
|
-
const dir = 'manifest.json' === __rspack_external_node_path_c5b9b54f.basename(candidate) ? __rspack_external_node_path_c5b9b54f.dirname(candidate) : candidate;
|
|
91
|
-
const normalized = 'src' === __rspack_external_node_path_c5b9b54f.basename(dir) ? __rspack_external_node_path_c5b9b54f.dirname(dir) : dir;
|
|
92
|
-
const display = __rspack_external_node_path_c5b9b54f.isAbsolute(normalized) ? __rspack_external_node_path_c5b9b54f.relative(projectRoot, normalized) || normalized : normalized;
|
|
93
|
-
return ` extension dev ${display}`;
|
|
94
|
-
}).join('\n');
|
|
95
|
-
return `${base}\n\n${pintor.gray(hint)}\n${pintor.blue(suggestions)}`;
|
|
96
|
-
}
|
|
97
|
-
function previewingSourceFallback(browser, distDir) {
|
|
98
|
-
return `${getLoggingPrefix('warn')} No production build found at ${distDir}, previewing the source manifest directory instead.\nRun \`extension build --browser ${String(browser)}\` first to preview the built output.`;
|
|
99
|
-
}
|
|
100
|
-
function previewing(browser, noBrowser) {
|
|
101
|
-
const suffix = noBrowser ? ' (no-browser mode)' : '';
|
|
102
|
-
return `${getLoggingPrefix('info')} Previewing on ${capitalizedBrowserName(browser)}${suffix}.`;
|
|
103
|
-
}
|
|
104
|
-
function starting(browser, noBrowser) {
|
|
105
|
-
const suffix = noBrowser ? ' (no-browser mode)' : '';
|
|
106
|
-
return `${getLoggingPrefix('info')} Starting on ${capitalizedBrowserName(browser)}${suffix}.`;
|
|
107
|
-
}
|
|
108
|
-
function extensionLoadRecovered() {
|
|
109
|
-
return `${getLoggingPrefix('success')} The browser accepted the extension.\nIt's running now.`;
|
|
110
|
-
}
|
|
111
|
-
function extensionLoadStillRefused(reason) {
|
|
112
|
-
return `${getLoggingPrefix('error')} The browser still refuses to load this extension.\n${pintor.gray('REASON')} ${pintor.red(reason)}`;
|
|
113
|
-
}
|
|
114
|
-
function browserLaunchFailed(browser, reason) {
|
|
115
|
-
return `${getLoggingPrefix('error')} ${capitalizedBrowserName(browser)} couldn't start, so the extension isn't running.\n${reason}\nThe dev server keeps watching, but nothing will load until this is fixed.`;
|
|
116
|
-
}
|
|
117
|
-
function authorInstallNotice(target) {
|
|
118
|
-
return `${messaging_prefix('debug')} install target=${target}`;
|
|
119
|
-
}
|
|
120
|
-
function projectInstallFallbackToNpm(pmName) {
|
|
121
|
-
return `${getLoggingPrefix('warn')} Dependency install with ${pmName} failed.\nExtension.js retries once with npm so the build can continue.`;
|
|
122
|
-
}
|
|
123
|
-
function projectInstallScriptsDisabled(pmName) {
|
|
124
|
-
return `${getLoggingPrefix('info')} Installing the project dependencies with ${pmName}…\nLifecycle scripts are disabled for safety.\nSet ${pintor.blue('EXTENSION_ALLOW_INSTALL_SCRIPTS=true')} to run them.`;
|
|
125
|
-
}
|
|
126
|
-
function anotherDevSessionActive(browser, pid, runId) {
|
|
127
|
-
const run = runId ? `, run ${runId}` : '';
|
|
128
|
-
return `${getLoggingPrefix('warn')} Another dev session is already writing dist/${browser} (PID ${pid}${run}).\nBoth sessions rebuild the same output, so the last compile wins.\nStop the other session, or pass ${fmt.code('--instance-id')} to run them side by side.`;
|
|
129
|
-
}
|
|
130
|
-
function buildAssetsTree(stats) {
|
|
131
|
-
const statsJson = stats?.toJson?.({
|
|
132
|
-
all: false,
|
|
133
|
-
assets: true
|
|
134
|
-
});
|
|
135
|
-
const assets = statsJson?.assets || [];
|
|
136
|
-
return getAssetsTree(assets);
|
|
137
|
-
}
|
|
138
|
-
function buildComplete(browser, distDisplayPath, totalBytes) {
|
|
139
|
-
const noun = artifactNoun(String(browser));
|
|
140
|
-
const size = 'number' == typeof totalBytes && totalBytes > 0 ? ` (${getHumanSize(totalBytes)})` : '';
|
|
141
|
-
return `${getLoggingPrefix('success')} ${noun} built for production in ${pintor.underline(distDisplayPath)}${size}.`;
|
|
142
|
-
}
|
|
143
|
-
function platformDocsUrl() {
|
|
144
|
-
return String(process.env.EXTENSION_DEV_DOCS_URL || '').trim().replace(/\/+$/, '');
|
|
145
|
-
}
|
|
146
|
-
function buildShareHint() {
|
|
147
|
-
const docs = platformDocsUrl();
|
|
148
|
-
if (!docs) return '';
|
|
149
|
-
return `${getLoggingPrefix('info')} Send this build to someone for review: ` + pintor.underline(`${docs}/share/unpublished-build-for-review?utm_source=cli-build`);
|
|
150
|
-
}
|
|
151
|
-
function buildFailed(errorCount) {
|
|
152
|
-
const count = Math.max(1, Math.floor(errorCount || 1));
|
|
153
|
-
const noun = 1 === count ? 'error' : 'errors';
|
|
154
|
-
return `${getLoggingPrefix('error')} Build failed with ${count} ${noun}.`;
|
|
155
|
-
}
|
|
156
|
-
function stripModuleWarningWrapper(message) {
|
|
157
|
-
return message.replace(/^Module (?:Warning|Error) \(from [^)]*\):\s*/, '');
|
|
158
|
-
}
|
|
159
|
-
function getWarningMessage(warning) {
|
|
160
|
-
if (!warning) return '';
|
|
161
|
-
if ('string' == typeof warning) return stripModuleWarningWrapper(warning.trim());
|
|
162
|
-
const candidates = [
|
|
163
|
-
warning.message,
|
|
164
|
-
warning.details,
|
|
165
|
-
warning.reason,
|
|
166
|
-
warning.description
|
|
167
|
-
];
|
|
168
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return stripModuleWarningWrapper(candidate.trim());
|
|
169
|
-
return '';
|
|
170
|
-
}
|
|
171
|
-
function getWarningSource(warning) {
|
|
172
|
-
if (!warning || 'string' == typeof warning) return 'bundler';
|
|
173
|
-
const candidates = [
|
|
174
|
-
warning.name,
|
|
175
|
-
warning.moduleName,
|
|
176
|
-
warning.moduleIdentifier,
|
|
177
|
-
warning.originName,
|
|
178
|
-
warning.pluginName
|
|
179
|
-
];
|
|
180
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
181
|
-
return 'bundler';
|
|
182
|
-
}
|
|
183
|
-
function getWarningArtifact(warning) {
|
|
184
|
-
if (!warning || 'string' == typeof warning) return '';
|
|
185
|
-
const candidates = [
|
|
186
|
-
warning.file,
|
|
187
|
-
warning.chunkName,
|
|
188
|
-
warning.moduleName
|
|
189
|
-
];
|
|
190
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
191
|
-
return '';
|
|
192
|
-
}
|
|
193
|
-
function classifyWarning(message, source) {
|
|
194
|
-
const haystack = `${message} ${source}`.toLowerCase();
|
|
195
|
-
if (haystack.includes('performance') || haystack.includes('asset size') || haystack.includes('entrypoint size') || haystack.includes('exceeds the recommended size') || haystack.includes('hints')) return 'Performance';
|
|
196
|
-
if (haystack.includes('deprecat') || haystack.includes('[dep_') || haystack.includes('legacy')) return 'Deprecation';
|
|
197
|
-
if (haystack.includes('invalid') || haystack.includes('unknown option') || haystack.includes('configuration') || haystack.includes('schema')) return 'Configuration';
|
|
198
|
-
if (haystack.includes('manifest') || haystack.includes('browser') || haystack.includes('target')) return 'Compatibility';
|
|
199
|
-
if (haystack.includes('runtime') || haystack.includes('will fail') || haystack.includes('cannot resolve') || haystack.includes('service_worker')) return 'Runtime-risk';
|
|
200
|
-
return 'Warning';
|
|
201
|
-
}
|
|
202
|
-
function suggestedHintForWarning(category) {
|
|
203
|
-
if ('Performance' === category) return 'Inspect the largest startup bundles and split optional code paths.';
|
|
204
|
-
if ('Deprecation' === category) return 'Move to the supported API or plugin path before the next update.';
|
|
205
|
-
if ('Configuration' === category) return 'Review extension and bundler config keys, then remove or rename invalid options.';
|
|
206
|
-
if ('Compatibility' === category) return 'Verify browser target and manifest compatibility for this build.';
|
|
207
|
-
if ('Runtime-risk' === category) return 'Address this before release. It may fail or degrade at runtime.';
|
|
208
|
-
return 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning details.';
|
|
209
|
-
}
|
|
210
|
-
function buildWarningsDetails(warnings) {
|
|
211
|
-
if (!Array.isArray(warnings) || 0 === warnings.length) return '';
|
|
212
|
-
const blocks = [];
|
|
213
|
-
warnings.forEach((warning, index)=>{
|
|
214
|
-
const message = getWarningMessage(warning);
|
|
215
|
-
const source = getWarningSource(warning);
|
|
216
|
-
const artifact = getWarningArtifact(warning);
|
|
217
|
-
const category = classifyWarning(message, source);
|
|
218
|
-
const hint = suggestedHintForWarning(category);
|
|
219
|
-
if (!message) return void blocks.push(`${getLoggingPrefix('warn')} Warning ${index + 1}: details were suppressed by tool output.\n${formatWarningLabelLine('Source', pintor.gray(source))}\n${formatWarningLabelLine('Hint', 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning messages.')}`);
|
|
220
|
-
const performanceWarning = parsePerformanceWarning(warning, source, artifact);
|
|
221
|
-
if (performanceWarning) return void blocks.push(performanceWarning);
|
|
222
|
-
const oneLine = message.replace(/\s+/g, ' ').trim();
|
|
223
|
-
const artifactSuffix = artifact ? ` ${pintor.gray(`(${artifact})`)}` : '';
|
|
224
|
-
blocks.push(`${getLoggingPrefix('warn')} ${category}: ${oneLine}${artifactSuffix}\n${formatWarningLabelLine('Source', pintor.gray(source))}\n${formatWarningLabelLine('Hint', hint)}`);
|
|
225
|
-
});
|
|
226
|
-
return blocks.join('\n\n');
|
|
227
|
-
}
|
|
228
|
-
function fetchingProjectPath(owner, project) {
|
|
229
|
-
return fmt.block('Fetching project', [
|
|
230
|
-
[
|
|
231
|
-
'URL',
|
|
232
|
-
fmt.val(`https://github.com/${owner}/${project}`)
|
|
233
|
-
]
|
|
234
|
-
]);
|
|
235
|
-
}
|
|
236
|
-
function downloadingProjectPath(projectName) {
|
|
237
|
-
const formatted = isPathLike(projectName) ? pintor.underline(projectName) : projectName;
|
|
238
|
-
return `${getLoggingPrefix('info')} Downloading ${formatted}…`;
|
|
239
|
-
}
|
|
240
|
-
function creatingProjectPath(projectPath) {
|
|
241
|
-
return `${getLoggingPrefix('info')} Creating a new browser extension…\n${pintor.gray('PATH')} ${pintor.underline(projectPath)}`;
|
|
242
|
-
}
|
|
243
|
-
function downloadedProjectFolderNotFound(cwd, candidates) {
|
|
244
|
-
return `${getLoggingPrefix('error')} Downloaded project folder not found.\n${pintor.gray('PATH')} ${pintor.underline(cwd)}\n${pintor.gray('NOT FOUND')} ${pintor.underline(candidates.join(', '))}`;
|
|
245
|
-
}
|
|
246
|
-
function packagingSourceFiles(zipPath) {
|
|
247
|
-
return `${messaging_prefix('debug')} zip pack=source gitignore=excluded path=${zipPath}`;
|
|
248
|
-
}
|
|
249
|
-
function zipArtifactReady(zipPath, sizeInBytes) {
|
|
250
|
-
return `${getLoggingPrefix('success')} Packaged ${pintor.underline(zipPath)} (${getHumanSize(sizeInBytes)}).`;
|
|
251
|
-
}
|
|
252
|
-
function packagingDistributionFiles(zipPath) {
|
|
253
|
-
return `${messaging_prefix('debug')} zip pack=dist path=${zipPath}`;
|
|
254
|
-
}
|
|
255
|
-
function treeWithSourceAndDistFiles(browser, name, sourceZip, destZip) {
|
|
256
|
-
return `${messaging_prefix('debug')} zip name=${name} browser=${String(browser)} source=${sourceZip} dist=${destZip}`;
|
|
257
|
-
}
|
|
258
|
-
function treeWithDistFilesBrowser(name, ext, browser, zipPath) {
|
|
259
|
-
return `${messaging_prefix('debug')} zip name=${name}.${ext} browser=${String(browser)} dist=${zipPath}`;
|
|
260
|
-
}
|
|
261
|
-
function treeWithSourceFiles(name, ext, browser, zipPath) {
|
|
262
|
-
return `${messaging_prefix('debug')} zip name=${name}-source.${ext} browser=${String(browser)} source=${zipPath}`;
|
|
263
|
-
}
|
|
264
|
-
function writingTypeDefinitions(manifest) {
|
|
265
|
-
return `${getLoggingPrefix('info')} Writing the type definitions for ${manifest.name || 'the extension'}…`;
|
|
266
|
-
}
|
|
267
|
-
function writingTypeDefinitionsError(error) {
|
|
268
|
-
return `${getLoggingPrefix('error')} Couldn't write the extension type definitions.\n${pintor.gray('REASON')} ${pintor.red(String(error))}\nCheck the file permissions, then try again.`;
|
|
269
|
-
}
|
|
270
|
-
function downloadingText(url) {
|
|
271
|
-
return fmt.block('Downloading extension', [
|
|
272
|
-
[
|
|
273
|
-
'URL',
|
|
274
|
-
fmt.val(url)
|
|
275
|
-
]
|
|
276
|
-
]);
|
|
277
|
-
}
|
|
278
|
-
function unpackagingExtension(zipFilePath) {
|
|
279
|
-
return `${getLoggingPrefix('info')} Unpackaging the browser extension…\n${pintor.gray('PATH')} ${pintor.underline(zipFilePath)}`;
|
|
280
|
-
}
|
|
281
|
-
function unpackagedSuccessfully() {
|
|
282
|
-
return `${getLoggingPrefix('success')} Extension unpackaged.`;
|
|
283
|
-
}
|
|
284
|
-
function failedToDownloadOrExtractZIPFileError(error) {
|
|
285
|
-
return `${getLoggingPrefix('error')} Couldn't download or extract the ZIP file.\n${pintor.gray('REASON')} ${pintor.red(String(error))}\nCheck the URL and your network, then try again.`;
|
|
286
|
-
}
|
|
287
|
-
function invalidRemoteZip(url, contentType) {
|
|
288
|
-
return `${getLoggingPrefix('error')} The remote URL doesn't point to a ZIP archive.\n${pintor.gray('URL')} ${pintor.underline(url)}\n${pintor.gray('GOT')} ${pintor.underline(contentType || 'unknown')}\nUse a direct-download URL, or download the file and pass the local path.`;
|
|
289
|
-
}
|
|
290
|
-
function notAZipArchive(source, contentType) {
|
|
291
|
-
return `${getLoggingPrefix('error')} The downloaded content isn't a ZIP archive.\n${pintor.gray('SOURCE')} ${pintor.underline(source)}\n` + (contentType ? `${pintor.gray('GOT')} ${pintor.underline(contentType)}\n` : '') + `The URL likely requires authentication and returned an HTML login page instead of the file.\n` + `This happens with Slack, Google Drive, and Dropbox file pages.\n` + "Download the ZIP in the browser and pass the local path, or use a direct-download URL.";
|
|
292
|
-
}
|
|
293
|
-
function localZipNotFound(zipFilePath) {
|
|
294
|
-
return `${getLoggingPrefix('error')} ZIP file not found.\n${pintor.gray('NOT FOUND')} ${pintor.underline(zipFilePath)}\nCheck the path, then try again.`;
|
|
295
|
-
}
|
|
296
|
-
function capitalizedBrowserName(browser) {
|
|
297
|
-
const b = String(browser || '');
|
|
298
|
-
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
299
|
-
return pintor.yellow(`${cap}`);
|
|
300
|
-
}
|
|
301
|
-
function getFileSize(fileSizeInBytes) {
|
|
302
|
-
return `${(fileSizeInBytes / 1024).toFixed(2)}KB`;
|
|
303
|
-
}
|
|
304
|
-
function getHumanSize(sizeInBytes) {
|
|
305
|
-
const bytes = Math.max(0, sizeInBytes || 0);
|
|
306
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
307
|
-
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
308
|
-
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
309
|
-
}
|
|
310
|
-
function printTree(node, prefix = '') {
|
|
311
|
-
let output = '';
|
|
312
|
-
Object.keys(node).forEach((key, index, array)=>{
|
|
313
|
-
const isLast = index === array.length - 1;
|
|
314
|
-
const connector = isLast ? '└─' : '├─';
|
|
315
|
-
const child = node[key];
|
|
316
|
-
const childNode = child && 'object' == typeof child ? child : void 0;
|
|
317
|
-
const isLeaf = 'number' == typeof childNode?.size;
|
|
318
|
-
const sizeInKB = isLeaf ? ` (${getFileSize(childNode?.size ?? 0)})` : '';
|
|
319
|
-
output += `${pintor.gray(prefix)}${pintor.gray(connector)} ${key}${pintor.gray(sizeInKB)}\n`;
|
|
320
|
-
if (childNode && !isLeaf) output += printTree(childNode, `${prefix}${isLast ? ' ' : pintor.gray('│ ')}`);
|
|
321
|
-
});
|
|
322
|
-
return output;
|
|
323
|
-
}
|
|
324
|
-
function getAssetsTree(assets) {
|
|
325
|
-
const assetTree = {};
|
|
326
|
-
assets?.forEach((asset)=>{
|
|
327
|
-
if ('string' != typeof asset?.name) return;
|
|
328
|
-
const paths = asset.name.split('/');
|
|
329
|
-
let currentLevel = assetTree;
|
|
330
|
-
paths.forEach((part, index)=>{
|
|
331
|
-
if (!currentLevel[part]) currentLevel[part] = {};
|
|
332
|
-
if (index === paths.length - 1) currentLevel[part] = {
|
|
333
|
-
size: asset.size
|
|
334
|
-
};
|
|
335
|
-
else currentLevel = currentLevel[part];
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
if (0 === Object.keys(assetTree).length) return '';
|
|
339
|
-
return `.\n${printTree(assetTree)}`;
|
|
340
|
-
}
|
|
341
|
-
function formatWarningLabelLine(label, value) {
|
|
342
|
-
return `${pintor.gray('│')} ${pintor.gray(`${label}:`)} ${value}`;
|
|
343
|
-
}
|
|
344
|
-
function parsePerformanceWarning(warning, source, _artifact) {
|
|
345
|
-
const normalized = getWarningBody(warning).replace(/\r/g, '');
|
|
346
|
-
const lower = normalized.toLowerCase();
|
|
347
|
-
const threshold = normalized.match(/\(([\d.]+\s(?:KiB|MiB|GiB|KB|MB|GB))\)/)?.[1] || '';
|
|
348
|
-
if (lower.includes('asset size limit')) return formatPerformanceWarningBlock({
|
|
349
|
-
title: 'asset size limit exceeded',
|
|
350
|
-
threshold,
|
|
351
|
-
impact: 'Large emitted files can increase package size and slow extension startup.',
|
|
352
|
-
source,
|
|
353
|
-
hint: 'Inspect the largest startup bundles and split optional code paths.'
|
|
354
|
-
});
|
|
355
|
-
if (lower.includes('entrypoint size limit')) return formatPerformanceWarningBlock({
|
|
356
|
-
title: 'entrypoint size limit exceeded',
|
|
357
|
-
threshold,
|
|
358
|
-
impact: 'Startup entrypoints are heavier than recommended.',
|
|
359
|
-
source,
|
|
360
|
-
hint: 'Keep startup entrypoints thin and defer non-critical code.'
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
function formatPerformanceWarningBlock(options) {
|
|
364
|
-
const lines = [
|
|
365
|
-
`${getLoggingPrefix('warn')} Performance: ${options.title}`
|
|
366
|
-
];
|
|
367
|
-
if (options.threshold) lines.push(formatWarningLabelLine('Threshold', options.threshold));
|
|
368
|
-
lines.push(formatWarningLabelLine('Impact', options.impact));
|
|
369
|
-
lines.push(pintor.gray('│'));
|
|
370
|
-
lines.push(formatWarningLabelLine('Source', pintor.gray(options.source)));
|
|
371
|
-
lines.push(formatWarningLabelLine('Hint', options.hint));
|
|
372
|
-
return lines.join('\n');
|
|
373
|
-
}
|
|
374
|
-
function getWarningBody(warning) {
|
|
375
|
-
if (!warning) return '';
|
|
376
|
-
if ('string' == typeof warning) return warning;
|
|
377
|
-
return [
|
|
378
|
-
warning.message,
|
|
379
|
-
warning.details,
|
|
380
|
-
warning.reason,
|
|
381
|
-
warning.description
|
|
382
|
-
].filter((value)=>'string' == typeof value && value.trim().length > 0).join('\n');
|
|
383
|
-
}
|
|
384
|
-
function isUsingExperimentalConfig(integration) {
|
|
385
|
-
return `${messaging_prefix('debug')} config using=${String(integration)}`;
|
|
386
|
-
}
|
|
387
|
-
function debugDirs(manifestDir, packageJsonDir) {
|
|
388
|
-
return `${messaging_prefix('debug')} dirs manifest=${manifestDir} pkg=${packageJsonDir}`;
|
|
389
|
-
}
|
|
390
|
-
function debugBrowser(browser, chromiumBinary, geckoBinary) {
|
|
391
|
-
return `${messaging_prefix('debug')} browser target=${String(browser)} chromiumBinary=${String(chromiumBinary || 'auto')} geckoBinary=${String(geckoBinary || 'auto')}`;
|
|
392
|
-
}
|
|
393
|
-
function debugOutputPath(pathValue) {
|
|
394
|
-
return `${messaging_prefix('debug')} output path=${pathValue}`;
|
|
395
|
-
}
|
|
396
|
-
function debugPreviewOutput(outputPath, distPath) {
|
|
397
|
-
return `${messaging_prefix('debug')} preview output=${outputPath} dist=${distPath}`;
|
|
398
|
-
}
|
|
399
|
-
function debugContextPath(packageJsonDir) {
|
|
400
|
-
return `${messaging_prefix('debug')} context path=${packageJsonDir}`;
|
|
401
|
-
}
|
|
402
|
-
function debugExtensionsToLoad(extensions) {
|
|
403
|
-
return `${messaging_prefix('debug')} extensions count=${extensions.length} paths=${extensions.join(',')}`;
|
|
404
|
-
}
|
|
405
|
-
function noCompanionExtensionsResolved() {
|
|
406
|
-
return `${getLoggingPrefix('warn')} No companion extensions resolved from the ${pintor.blue('extensions')} config.\nPoint each entry at an unpacked extension directory that contains a manifest.json, for example ./extensions/<name>/manifest.json.`;
|
|
407
|
-
}
|
|
408
|
-
function configLoadingError(configPath, error) {
|
|
409
|
-
return `${getLoggingPrefix('error')} Couldn't load ${pintor.blue('extension.config.js')}.\n${fmt.label('PATH')} ${fmt.val(configPath)}\n${pintor.red(fmt.truncate(error, 1200))}\nFix the config file, then run the command again.`;
|
|
410
|
-
}
|
|
411
|
-
function buildCommandFailed(error) {
|
|
412
|
-
const message = (()=>{
|
|
413
|
-
if (error instanceof Error && error.message) return error.message;
|
|
414
|
-
return String(error || 'Unknown error');
|
|
415
|
-
})();
|
|
416
|
-
if (message.includes(getLoggingPrefix('error'))) return message;
|
|
417
|
-
return `${getLoggingPrefix('error')} ${pintor.red(fmt.truncate(message, 1200))}`;
|
|
418
|
-
}
|
|
419
|
-
function devCommandFailed(error) {
|
|
420
|
-
const message = (()=>{
|
|
421
|
-
if (error instanceof Error && error.message) return error.message;
|
|
422
|
-
return String(error || 'Unknown error');
|
|
423
|
-
})();
|
|
424
|
-
return `${getLoggingPrefix('error')} Dev mode failed.\n${pintor.red(fmt.truncate(message, 1200))}`;
|
|
425
|
-
}
|
|
426
|
-
function managedDependencyConflict(duplicates, userPackageJsonPath) {
|
|
427
|
-
const list = duplicates.map((d)=>`- ${pintor.yellow(d)}`).join('\n');
|
|
428
|
-
return `${getLoggingPrefix('error')} Your project declares dependencies that Extension.js already manages, so the build was aborted.\n${pintor.red('Duplicate declarations can cause version conflicts and break the build.')}\n\n${pintor.gray('Remove these from your package.json:')}\n${list}\n\n${pintor.gray('PATH')} ${pintor.underline(userPackageJsonPath)}\nIf you need a different version, open an issue so we can consider bundling it safely.`;
|
|
429
|
-
}
|
|
430
62
|
const preloadedEnvKeys = new Set();
|
|
431
63
|
function getPreloadedEnvKeys() {
|
|
432
64
|
return preloadedEnvKeys;
|
|
433
65
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
66
|
+
const ENV_PRELOAD_ORDER = [
|
|
67
|
+
'.env.defaults',
|
|
68
|
+
'.env',
|
|
69
|
+
'.env.local',
|
|
70
|
+
'.env.development'
|
|
71
|
+
];
|
|
72
|
+
function applyEnvFile(filePath, shellOwned) {
|
|
73
|
+
const parsed = dotenv.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(filePath));
|
|
74
|
+
for (const [key, value] of Object.entries(parsed))if (!shellOwned.has(key)) {
|
|
75
|
+
process.env[key] = value;
|
|
76
|
+
preloadedEnvKeys.add(key);
|
|
77
|
+
}
|
|
438
78
|
}
|
|
439
79
|
function loadCommonJsConfigWithStableDirname(absolutePath) {
|
|
440
80
|
const code = __rspack_external_node_fs_5ea92f0c.readFileSync(absolutePath, 'utf-8');
|
|
@@ -460,51 +100,46 @@ function findNearestWorkspaceRoot(startDir) {
|
|
|
460
100
|
current = parent;
|
|
461
101
|
}
|
|
462
102
|
}
|
|
463
|
-
function preloadEnvFilesFromDir(envDir
|
|
103
|
+
function preloadEnvFilesFromDir(envDir) {
|
|
464
104
|
let loadedAny = false;
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
path: defaultsPath,
|
|
471
|
-
override: Boolean(options?.override),
|
|
472
|
-
quiet: true
|
|
473
|
-
});
|
|
105
|
+
const shellOwned = new Set(Object.keys(process.env).filter((key)=>!preloadedEnvKeys.has(key)));
|
|
106
|
+
for (const filename of ENV_PRELOAD_ORDER){
|
|
107
|
+
const filePath = __rspack_external_node_path_c5b9b54f.join(envDir, filename);
|
|
108
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(filePath)) try {
|
|
109
|
+
applyEnvFile(filePath, shellOwned);
|
|
474
110
|
loadedAny = true;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
'.env.development',
|
|
478
|
-
'.env.local',
|
|
479
|
-
'.env'
|
|
480
|
-
];
|
|
481
|
-
for (const filename of envCandidates){
|
|
482
|
-
const filePath = __rspack_external_node_path_c5b9b54f.join(envDir, filename);
|
|
483
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(filePath)) {
|
|
484
|
-
recordPreloadedKeys(filePath);
|
|
485
|
-
dotenv.config({
|
|
486
|
-
path: filePath,
|
|
487
|
-
override: Boolean(options?.override),
|
|
488
|
-
quiet: true
|
|
489
|
-
});
|
|
490
|
-
loadedAny = true;
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
} catch {}
|
|
111
|
+
} catch {}
|
|
112
|
+
}
|
|
495
113
|
return {
|
|
496
114
|
loadedAny,
|
|
497
115
|
envDir
|
|
498
116
|
};
|
|
499
117
|
}
|
|
500
|
-
function
|
|
118
|
+
function findConfigFileIn(dir) {
|
|
501
119
|
const candidates = [
|
|
502
|
-
__rspack_external_node_path_c5b9b54f.join(
|
|
503
|
-
__rspack_external_node_path_c5b9b54f.join(
|
|
504
|
-
__rspack_external_node_path_c5b9b54f.join(
|
|
120
|
+
__rspack_external_node_path_c5b9b54f.join(dir, 'extension.config.js'),
|
|
121
|
+
__rspack_external_node_path_c5b9b54f.join(dir, 'extension.config.mjs'),
|
|
122
|
+
__rspack_external_node_path_c5b9b54f.join(dir, 'extension.config.cjs')
|
|
505
123
|
];
|
|
506
124
|
return candidates.find((p)=>__rspack_external_node_fs_5ea92f0c.existsSync(p));
|
|
507
125
|
}
|
|
126
|
+
function resolveManifestDir(projectPath) {
|
|
127
|
+
try {
|
|
128
|
+
const structure = resolveProjectStructureSync(projectPath, {
|
|
129
|
+
quiet: true
|
|
130
|
+
});
|
|
131
|
+
return __rspack_external_node_path_c5b9b54f.dirname(structure.manifestPath);
|
|
132
|
+
} catch {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function findConfigFile(projectPath) {
|
|
137
|
+
const atRoot = findConfigFileIn(projectPath);
|
|
138
|
+
if (atRoot) return atRoot;
|
|
139
|
+
const manifestDir = resolveManifestDir(projectPath);
|
|
140
|
+
if (!manifestDir || __rspack_external_node_path_c5b9b54f.resolve(manifestDir) === __rspack_external_node_path_c5b9b54f.resolve(projectPath)) return;
|
|
141
|
+
return findConfigFileIn(manifestDir);
|
|
142
|
+
}
|
|
508
143
|
function preloadEnvFiles(projectDir) {
|
|
509
144
|
const local = preloadEnvFilesFromDir(projectDir);
|
|
510
145
|
if (local.loadedAny) return local;
|
|
@@ -607,7 +242,7 @@ async function loadConfigFileUncached(absolutePath) {
|
|
|
607
242
|
async function loadCustomConfig(projectPath) {
|
|
608
243
|
const configPath = findConfigFile(projectPath);
|
|
609
244
|
if (configPath) {
|
|
610
|
-
if (await
|
|
245
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
611
246
|
const userConfig = await loadConfigFile(configPath);
|
|
612
247
|
if (userConfig && 'function' == typeof userConfig.config) return userConfig.config;
|
|
613
248
|
if (userConfig?.config && 'object' == typeof userConfig.config) {
|
|
@@ -626,27 +261,21 @@ async function loadCustomConfig(projectPath) {
|
|
|
626
261
|
}
|
|
627
262
|
return (config)=>config;
|
|
628
263
|
}
|
|
629
|
-
async function
|
|
264
|
+
async function loadProjectConfigDefaults(projectPath) {
|
|
630
265
|
const configPath = findConfigFile(projectPath);
|
|
631
266
|
if (configPath) {
|
|
632
|
-
if (await
|
|
267
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
633
268
|
const userConfig = await loadConfigFile(configPath);
|
|
634
|
-
const configExtras = userConfig;
|
|
635
|
-
const baseExtensions = configExtras && configExtras.extensions ? {
|
|
636
|
-
extensions: configExtras.extensions
|
|
637
|
-
} : {};
|
|
638
|
-
const baseTranspilePackages = configExtras && Array.isArray(configExtras.transpilePackages) ? {
|
|
639
|
-
transpilePackages: configExtras.transpilePackages
|
|
640
|
-
} : {};
|
|
641
|
-
const basePerfBudgets = configExtras && configExtras.perfBudgets && 'object' == typeof configExtras.perfBudgets ? {
|
|
642
|
-
perfBudgets: configExtras.perfBudgets
|
|
643
|
-
} : {};
|
|
644
|
-
const perCommand = userConfig?.commands?.[command] ? userConfig.commands[command] : {};
|
|
645
269
|
return {
|
|
646
|
-
...
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
...
|
|
270
|
+
...userConfig?.extensions ? {
|
|
271
|
+
extensions: userConfig.extensions
|
|
272
|
+
} : {},
|
|
273
|
+
...Array.isArray(userConfig?.transpilePackages) ? {
|
|
274
|
+
transpilePackages: userConfig.transpilePackages
|
|
275
|
+
} : {},
|
|
276
|
+
...userConfig?.perfBudgets && 'object' == typeof userConfig.perfBudgets ? {
|
|
277
|
+
perfBudgets: userConfig.perfBudgets
|
|
278
|
+
} : {}
|
|
650
279
|
};
|
|
651
280
|
} catch (err) {
|
|
652
281
|
const error = err;
|
|
@@ -656,10 +285,24 @@ async function loadCommandConfig(projectPath, command) {
|
|
|
656
285
|
}
|
|
657
286
|
return {};
|
|
658
287
|
}
|
|
288
|
+
async function loadCommandConfig(projectPath, command) {
|
|
289
|
+
const configPath = findConfigFile(projectPath);
|
|
290
|
+
if (configPath) {
|
|
291
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
292
|
+
const userConfig = await loadConfigFile(configPath);
|
|
293
|
+
return userConfig?.commands?.[command] || {};
|
|
294
|
+
} catch (err) {
|
|
295
|
+
const error = err;
|
|
296
|
+
console.error(configLoadingError(configPath, error));
|
|
297
|
+
throw err;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return {};
|
|
301
|
+
}
|
|
659
302
|
async function loadBrowserConfig(projectPath, browser = 'chrome') {
|
|
660
303
|
const configPath = findConfigFile(projectPath);
|
|
661
304
|
if (configPath) {
|
|
662
|
-
if (await
|
|
305
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
663
306
|
const userConfig = await loadConfigFile(configPath);
|
|
664
307
|
if (userConfig?.browser) {
|
|
665
308
|
const browsers = userConfig.browser;
|
|
@@ -693,142 +336,18 @@ async function loadBrowserConfig(projectPath, browser = 'chrome') {
|
|
|
693
336
|
};
|
|
694
337
|
}
|
|
695
338
|
let userMessageDelivered = false;
|
|
696
|
-
async function
|
|
339
|
+
async function isUsingExperimentalConfig(projectPath) {
|
|
697
340
|
const configPath = findConfigFile(projectPath);
|
|
698
341
|
if (configPath) {
|
|
699
342
|
if (!userMessageDelivered) {
|
|
700
|
-
if (isDebug()) console.log(
|
|
343
|
+
if (isDebug()) console.log(messages_isUsingExperimentalConfig('extension.config.js'));
|
|
701
344
|
userMessageDelivered = true;
|
|
702
345
|
}
|
|
703
346
|
return true;
|
|
704
347
|
}
|
|
705
348
|
return false;
|
|
706
349
|
}
|
|
707
|
-
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.
|
|
708
|
-
function asAbsolute(p) {
|
|
709
|
-
return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
|
|
710
|
-
}
|
|
711
|
-
function toPosixPath(p) {
|
|
712
|
-
return p.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
713
|
-
}
|
|
714
|
-
function getDirs(struct) {
|
|
715
|
-
const manifestDir = asAbsolute(__rspack_external_node_path_c5b9b54f.dirname(struct.manifestPath));
|
|
716
|
-
const projectManifestPath = struct.packageJsonPath || struct.denoJsonPath;
|
|
717
|
-
const packageJsonDir = asAbsolute(projectManifestPath ? __rspack_external_node_path_c5b9b54f.dirname(projectManifestPath) : manifestDir);
|
|
718
|
-
return {
|
|
719
|
-
manifestDir,
|
|
720
|
-
packageJsonDir
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
function getNodeModulesDir(packageJsonDir) {
|
|
724
|
-
return asAbsolute(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'node_modules'));
|
|
725
|
-
}
|
|
726
|
-
function needsInstall(packageJsonDir) {
|
|
727
|
-
const nm = getNodeModulesDir(packageJsonDir);
|
|
728
|
-
const hasManifest = PROJECT_MANIFEST_FILENAMES.some((filename)=>__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, filename)));
|
|
729
|
-
if (!hasManifest) return false;
|
|
730
|
-
try {
|
|
731
|
-
const deps = Object.keys(readProjectDependencies(packageJsonDir));
|
|
732
|
-
if (0 === deps.length) return false;
|
|
733
|
-
if (!__rspack_external_node_fs_5ea92f0c.existsSync(nm)) return true;
|
|
734
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.pnpm'))) return false;
|
|
735
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.modules.yaml'))) return false;
|
|
736
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.deno'))) return false;
|
|
737
|
-
const hasInstalledDep = deps.some((dep)=>__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, dep)));
|
|
738
|
-
return !hasInstalledDep;
|
|
739
|
-
} catch {
|
|
740
|
-
return true;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
function normalizeBrowser(browser, chromiumBinary, geckoBinary, safariBinary) {
|
|
744
|
-
const requested = String(browser || '');
|
|
745
|
-
if (chromiumBinary) {
|
|
746
|
-
if (!requested || 'chromium-based' === requested) return 'chromium-based';
|
|
747
|
-
if ('chromium' === requested) return 'chromium';
|
|
748
|
-
if ('edge' === requested) return 'edge';
|
|
749
|
-
if ('chrome' === requested) return 'chrome';
|
|
750
|
-
}
|
|
751
|
-
if (geckoBinary) {
|
|
752
|
-
if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
|
|
753
|
-
if ('firefox' === requested) return 'firefox';
|
|
754
|
-
}
|
|
755
|
-
if (safariBinary) {
|
|
756
|
-
if (!requested || 'webkit-based' === requested) return 'webkit-based';
|
|
757
|
-
if ('safari' === requested) return 'safari';
|
|
758
|
-
}
|
|
759
|
-
switch(requested){
|
|
760
|
-
case 'chrome':
|
|
761
|
-
return 'chrome';
|
|
762
|
-
case 'edge':
|
|
763
|
-
return 'edge';
|
|
764
|
-
case 'chromium':
|
|
765
|
-
return 'chromium';
|
|
766
|
-
case 'brave':
|
|
767
|
-
return 'brave';
|
|
768
|
-
case 'opera':
|
|
769
|
-
return 'opera';
|
|
770
|
-
case 'vivaldi':
|
|
771
|
-
return 'vivaldi';
|
|
772
|
-
case 'yandex':
|
|
773
|
-
return 'yandex';
|
|
774
|
-
case 'chromium-based':
|
|
775
|
-
return 'chromium-based';
|
|
776
|
-
case 'firefox':
|
|
777
|
-
return 'firefox';
|
|
778
|
-
case 'waterfox':
|
|
779
|
-
return 'waterfox';
|
|
780
|
-
case 'librewolf':
|
|
781
|
-
return 'librewolf';
|
|
782
|
-
case 'gecko-based':
|
|
783
|
-
case 'firefox-based':
|
|
784
|
-
return 'gecko-based';
|
|
785
|
-
case 'safari':
|
|
786
|
-
return 'safari';
|
|
787
|
-
case 'webkit-based':
|
|
788
|
-
return 'webkit-based';
|
|
789
|
-
default:
|
|
790
|
-
return 'chrome';
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
function getDistPath(packageJsonDir, browser) {
|
|
794
|
-
return asAbsolute(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist', browser));
|
|
795
|
-
}
|
|
796
|
-
function computePreviewOutputPath(struct, browser, explicitOutputPath) {
|
|
797
|
-
const { manifestDir, packageJsonDir } = getDirs(struct);
|
|
798
|
-
if (explicitOutputPath) return asAbsolute(explicitOutputPath);
|
|
799
|
-
if (struct.packageJsonPath || struct.denoJsonPath) {
|
|
800
|
-
const distDir = getDistPath(packageJsonDir, browser);
|
|
801
|
-
try {
|
|
802
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(distDir, 'manifest.json'))) return distDir;
|
|
803
|
-
} catch {}
|
|
804
|
-
}
|
|
805
|
-
return manifestDir;
|
|
806
|
-
}
|
|
807
|
-
function devtoolsEngineFor(browser) {
|
|
808
|
-
switch(browser){
|
|
809
|
-
case 'chrome':
|
|
810
|
-
return 'chrome';
|
|
811
|
-
case 'edge':
|
|
812
|
-
return 'edge';
|
|
813
|
-
case 'chromium':
|
|
814
|
-
case 'chromium-based':
|
|
815
|
-
case 'brave':
|
|
816
|
-
case 'opera':
|
|
817
|
-
case 'vivaldi':
|
|
818
|
-
case 'yandex':
|
|
819
|
-
return 'chromium';
|
|
820
|
-
case 'firefox':
|
|
821
|
-
case 'gecko-based':
|
|
822
|
-
case 'waterfox':
|
|
823
|
-
case 'librewolf':
|
|
824
|
-
return 'firefox';
|
|
825
|
-
case 'safari':
|
|
826
|
-
case 'webkit-based':
|
|
827
|
-
return 'safari';
|
|
828
|
-
default:
|
|
829
|
-
return 'chrome';
|
|
830
|
-
}
|
|
831
|
-
}
|
|
350
|
+
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.13","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.3.1","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
|
|
832
351
|
function sanitize(obj) {
|
|
833
352
|
return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
|
|
834
353
|
}
|
|
@@ -917,315 +436,6 @@ function mergeOptionLayers(defaults, ...layers) {
|
|
|
917
436
|
for (const layer of layers)result = mergeLayer(result, layer || {});
|
|
918
437
|
return result;
|
|
919
438
|
}
|
|
920
|
-
async function findUpLocal(filename, options) {
|
|
921
|
-
const root = __rspack_external_node_path_c5b9b54f.parse(options.cwd).root;
|
|
922
|
-
let currentDir = options.cwd;
|
|
923
|
-
while(true){
|
|
924
|
-
const candidate = __rspack_external_node_path_c5b9b54f.join(currentDir, filename);
|
|
925
|
-
try {
|
|
926
|
-
const stat = await __rspack_external_node_fs_5ea92f0c.promises.stat(candidate);
|
|
927
|
-
if (stat.isFile()) return candidate;
|
|
928
|
-
} catch {}
|
|
929
|
-
if (currentDir === root) return;
|
|
930
|
-
currentDir = __rspack_external_node_path_c5b9b54f.dirname(currentDir);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
async function findNearestPackageJson(manifestPath) {
|
|
934
|
-
try {
|
|
935
|
-
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
936
|
-
const packageJsonPath = await findUpLocal('package.json', {
|
|
937
|
-
cwd: manifestDir
|
|
938
|
-
});
|
|
939
|
-
return packageJsonPath || null;
|
|
940
|
-
} catch (error) {
|
|
941
|
-
console.warn('Failed to find package.json:', error);
|
|
942
|
-
return null;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
function validatePackageJson(packageJsonPath) {
|
|
946
|
-
try {
|
|
947
|
-
if (!__rspack_external_node_fs_5ea92f0c.existsSync(packageJsonPath)) return false;
|
|
948
|
-
const content = __rspack_external_node_fs_5ea92f0c.readFileSync(packageJsonPath, 'utf-8');
|
|
949
|
-
JSON.parse(content);
|
|
950
|
-
return true;
|
|
951
|
-
} catch (error) {
|
|
952
|
-
console.warn('Invalid package.json at:', packageJsonPath, error);
|
|
953
|
-
return false;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
const isUrl = (url)=>{
|
|
957
|
-
try {
|
|
958
|
-
new URL(url);
|
|
959
|
-
return true;
|
|
960
|
-
} catch (e) {
|
|
961
|
-
return false;
|
|
962
|
-
}
|
|
963
|
-
};
|
|
964
|
-
const REMOTE_FETCH_TIMEOUT_MS = (()=>{
|
|
965
|
-
const raw = parseInt(String(process.env.EXTENSION_FETCH_TIMEOUT_MS || ''), 10);
|
|
966
|
-
return Number.isFinite(raw) && raw > 0 ? raw : 60000;
|
|
967
|
-
})();
|
|
968
|
-
function withTimeout(task, ms, label) {
|
|
969
|
-
let timer;
|
|
970
|
-
const timeout = new Promise((_, reject)=>{
|
|
971
|
-
timer = setTimeout(()=>reject(new Error(remoteFetchTimedOut(label, ms))), ms);
|
|
972
|
-
});
|
|
973
|
-
return Promise.race([
|
|
974
|
-
task,
|
|
975
|
-
timeout
|
|
976
|
-
]).finally(()=>{
|
|
977
|
-
if (timer) clearTimeout(timer);
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
|
|
981
|
-
const cwd = process.cwd();
|
|
982
|
-
const url = new URL(pathOrRemoteUrl);
|
|
983
|
-
const segments = url.pathname.split('/').filter(Boolean);
|
|
984
|
-
const repoName = segments.length >= 2 ? segments[1] : segments[segments.length - 1];
|
|
985
|
-
const treeIndex = segments.indexOf('tree');
|
|
986
|
-
const expectedName = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments[segments.length - 1] : repoName;
|
|
987
|
-
const expectedPath = __rspack_external_node_path_c5b9b54f.resolve(cwd, expectedName);
|
|
988
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(expectedPath)) try {
|
|
989
|
-
const entries = __rspack_external_node_fs_5ea92f0c.readdirSync(expectedPath);
|
|
990
|
-
if (0 === entries.length) __rspack_external_node_fs_5ea92f0c.rmSync(expectedPath, {
|
|
991
|
-
recursive: true,
|
|
992
|
-
force: true
|
|
993
|
-
});
|
|
994
|
-
else {
|
|
995
|
-
const hasManifest = (dir)=>{
|
|
996
|
-
const stack = [
|
|
997
|
-
dir
|
|
998
|
-
];
|
|
999
|
-
while(stack.length){
|
|
1000
|
-
const current = stack.pop();
|
|
1001
|
-
const items = __rspack_external_node_fs_5ea92f0c.readdirSync(current, {
|
|
1002
|
-
withFileTypes: true
|
|
1003
|
-
});
|
|
1004
|
-
for (const it of items){
|
|
1005
|
-
if (it.isFile() && 'manifest.json' === it.name) return true;
|
|
1006
|
-
if (it.isDirectory() && 'node_modules' !== it.name && 'dist' !== it.name && !it.name.startsWith('.')) stack.push(__rspack_external_node_path_c5b9b54f.join(current, it.name));
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
return false;
|
|
1010
|
-
};
|
|
1011
|
-
if (hasManifest(expectedPath)) return expectedPath;
|
|
1012
|
-
__rspack_external_node_fs_5ea92f0c.rmSync(expectedPath, {
|
|
1013
|
-
recursive: true,
|
|
1014
|
-
force: true
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
} catch {}
|
|
1018
|
-
async function tryGitClone() {
|
|
1019
|
-
const { default: goGitIt } = await import("go-git-it");
|
|
1020
|
-
await withTimeout(goGitIt(pathOrRemoteUrl, cwd, text), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
|
|
1021
|
-
}
|
|
1022
|
-
async function tryZipFallback() {
|
|
1023
|
-
const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
|
|
1024
|
-
const owner = segments[0];
|
|
1025
|
-
const repo = segments[1];
|
|
1026
|
-
const subdir = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments.slice(treeIndex + 2).join('/') : '';
|
|
1027
|
-
const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${branch}`;
|
|
1028
|
-
const extractedPath = await importUrlSourceFromZip(zipUrl);
|
|
1029
|
-
const extractedDirs = __rspack_external_node_fs_5ea92f0c.readdirSync(extractedPath, {
|
|
1030
|
-
withFileTypes: true
|
|
1031
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1032
|
-
const repoRootDir = extractedDirs.find((d)=>d.startsWith(`${repo}-${branch}`));
|
|
1033
|
-
const repoRoot = repoRootDir ? __rspack_external_node_path_c5b9b54f.join(extractedPath, repoRootDir) : extractedPath;
|
|
1034
|
-
return subdir ? __rspack_external_node_path_c5b9b54f.join(repoRoot, subdir) : repoRoot;
|
|
1035
|
-
}
|
|
1036
|
-
try {
|
|
1037
|
-
await tryGitClone();
|
|
1038
|
-
} catch {
|
|
1039
|
-
return await tryZipFallback();
|
|
1040
|
-
}
|
|
1041
|
-
const candidates = [];
|
|
1042
|
-
if (-1 !== treeIndex && segments.length > treeIndex + 2) candidates.push(segments[segments.length - 1]);
|
|
1043
|
-
candidates.push(repoName);
|
|
1044
|
-
for (const name of candidates){
|
|
1045
|
-
const p = __rspack_external_node_path_c5b9b54f.resolve(cwd, name);
|
|
1046
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(p)) return p;
|
|
1047
|
-
}
|
|
1048
|
-
const dirs = __rspack_external_node_fs_5ea92f0c.readdirSync(cwd, {
|
|
1049
|
-
withFileTypes: true
|
|
1050
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1051
|
-
for (const dir of dirs){
|
|
1052
|
-
const manifestPath = __rspack_external_node_path_c5b9b54f.join(cwd, dir, 'manifest.json');
|
|
1053
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) return __rspack_external_node_path_c5b9b54f.join(cwd, dir);
|
|
1054
|
-
}
|
|
1055
|
-
try {
|
|
1056
|
-
const dirs = __rspack_external_node_fs_5ea92f0c.readdirSync(cwd, {
|
|
1057
|
-
withFileTypes: true
|
|
1058
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1059
|
-
const ghRoot = dirs.find((d)=>/-main$|-master$/.test(d));
|
|
1060
|
-
if (ghRoot) return __rspack_external_node_path_c5b9b54f.join(cwd, ghRoot);
|
|
1061
|
-
} catch {}
|
|
1062
|
-
throw new Error(downloadedProjectFolderNotFound(cwd, candidates));
|
|
1063
|
-
}
|
|
1064
|
-
async function importUrlSourceFromZip(pathOrRemoteUrl) {
|
|
1065
|
-
const cwd = process.cwd();
|
|
1066
|
-
const { downloadAndExtractZip } = await import("./0~zip.mjs");
|
|
1067
|
-
const extractedPath = await withTimeout(downloadAndExtractZip(pathOrRemoteUrl, cwd), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
|
|
1068
|
-
return extractedPath;
|
|
1069
|
-
}
|
|
1070
|
-
async function importLocalSourceFromZip(zipFilePath) {
|
|
1071
|
-
const cwd = process.cwd();
|
|
1072
|
-
const { extractLocalZip } = await import("./0~zip.mjs");
|
|
1073
|
-
return await extractLocalZip(zipFilePath, cwd);
|
|
1074
|
-
}
|
|
1075
|
-
async function getProjectPath(pathOrRemoteUrl) {
|
|
1076
|
-
if (!pathOrRemoteUrl) return process.cwd();
|
|
1077
|
-
if (isUrl(pathOrRemoteUrl)) {
|
|
1078
|
-
const url = new URL(pathOrRemoteUrl);
|
|
1079
|
-
if (url.protocol.startsWith('http')) {
|
|
1080
|
-
const pathname = url.pathname.toLowerCase();
|
|
1081
|
-
if (pathname.endsWith('.zip')) return await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
1082
|
-
if ('https://github.com' !== url.origin) {
|
|
1083
|
-
const urlSource = await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
1084
|
-
return urlSource;
|
|
1085
|
-
}
|
|
1086
|
-
const urlData = url.pathname.split('/');
|
|
1087
|
-
const owner = urlData.slice(1, 3)[0];
|
|
1088
|
-
const project = urlData.slice(1, 3)[1];
|
|
1089
|
-
console.log(fetchingProjectPath(owner, project));
|
|
1090
|
-
const projectName = __rspack_external_node_path_c5b9b54f.basename(url.pathname);
|
|
1091
|
-
const urlSource = await importUrlSourceFromGithub(pathOrRemoteUrl, downloadingProjectPath(projectName));
|
|
1092
|
-
console.log(creatingProjectPath(url.pathname));
|
|
1093
|
-
return urlSource;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
const resolvedPath = __rspack_external_node_path_c5b9b54f.resolve(process.cwd(), pathOrRemoteUrl);
|
|
1097
|
-
if ('.zip' === __rspack_external_node_path_c5b9b54f.extname(resolvedPath).toLowerCase() && __rspack_external_node_fs_5ea92f0c.existsSync(resolvedPath) && __rspack_external_node_fs_5ea92f0c.statSync(resolvedPath).isFile()) return await importLocalSourceFromZip(resolvedPath);
|
|
1098
|
-
return resolvedPath;
|
|
1099
|
-
}
|
|
1100
|
-
function collectManifestCandidates(rootDir, maxDepth) {
|
|
1101
|
-
const SKIP_DIRS = new Set([
|
|
1102
|
-
'node_modules',
|
|
1103
|
-
'dist',
|
|
1104
|
-
'build',
|
|
1105
|
-
'out',
|
|
1106
|
-
'.git',
|
|
1107
|
-
'.turbo',
|
|
1108
|
-
'.next',
|
|
1109
|
-
'coverage',
|
|
1110
|
-
'.cache',
|
|
1111
|
-
'.vercel'
|
|
1112
|
-
]);
|
|
1113
|
-
const results = [];
|
|
1114
|
-
const walk = (dir, depth)=>{
|
|
1115
|
-
if (depth > maxDepth || results.length >= 10) return;
|
|
1116
|
-
let entries;
|
|
1117
|
-
try {
|
|
1118
|
-
entries = __rspack_external_node_fs_5ea92f0c.readdirSync(dir, {
|
|
1119
|
-
withFileTypes: true
|
|
1120
|
-
});
|
|
1121
|
-
} catch {
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
for (const entry of entries){
|
|
1125
|
-
if (entry.isFile() && 'manifest.json' === entry.name) {
|
|
1126
|
-
results.push(__rspack_external_node_path_c5b9b54f.join(dir, entry.name));
|
|
1127
|
-
continue;
|
|
1128
|
-
}
|
|
1129
|
-
if (entry.isDirectory() && !entry.name.startsWith('.') && !SKIP_DIRS.has(entry.name)) walk(__rspack_external_node_path_c5b9b54f.join(dir, entry.name), depth + 1);
|
|
1130
|
-
}
|
|
1131
|
-
};
|
|
1132
|
-
walk(rootDir, 0);
|
|
1133
|
-
return results;
|
|
1134
|
-
}
|
|
1135
|
-
async function getProjectStructure(pathOrRemoteUrl) {
|
|
1136
|
-
const projectPath = await getProjectPath(pathOrRemoteUrl);
|
|
1137
|
-
const isUnderDir = (baseDir, candidatePath)=>{
|
|
1138
|
-
const rel = __rspack_external_node_path_c5b9b54f.relative(baseDir, candidatePath);
|
|
1139
|
-
return Boolean(rel && !rel.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(rel));
|
|
1140
|
-
};
|
|
1141
|
-
const packageJsonPathFromProject = await findNearestPackageJson(__rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json'));
|
|
1142
|
-
const denoJsonPathFromProject = findNearestDenoConfigSync(__rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json'));
|
|
1143
|
-
const packageJsonDirFromProject = packageJsonPathFromProject ? __rspack_external_node_path_c5b9b54f.dirname(packageJsonPathFromProject) : denoJsonPathFromProject ? __rspack_external_node_path_c5b9b54f.dirname(denoJsonPathFromProject) : void 0;
|
|
1144
|
-
const rootManifestPath = __rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json');
|
|
1145
|
-
const srcManifestPath = __rspack_external_node_path_c5b9b54f.join(projectPath, 'src', 'manifest.json');
|
|
1146
|
-
let manifestPath = __rspack_external_node_fs_5ea92f0c.existsSync(srcManifestPath) ? srcManifestPath : rootManifestPath;
|
|
1147
|
-
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) if (packageJsonDirFromProject) {
|
|
1148
|
-
const absoluteCandidates = collectManifestCandidates(projectPath, 3);
|
|
1149
|
-
const relativeCandidates = absoluteCandidates.map((candidate)=>__rspack_external_node_path_c5b9b54f.relative(projectPath, candidate) || candidate);
|
|
1150
|
-
if (1 === absoluteCandidates.length) {
|
|
1151
|
-
manifestPath = absoluteCandidates[0];
|
|
1152
|
-
console.log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
1153
|
-
} else throw new Error(manifestNotFoundError(manifestPath, relativeCandidates));
|
|
1154
|
-
} else {
|
|
1155
|
-
const MAX_DEPTH = 5;
|
|
1156
|
-
const findManifest = (dir, depth)=>{
|
|
1157
|
-
if (depth > MAX_DEPTH) return null;
|
|
1158
|
-
let files;
|
|
1159
|
-
try {
|
|
1160
|
-
files = __rspack_external_node_fs_5ea92f0c.readdirSync(dir, {
|
|
1161
|
-
withFileTypes: true
|
|
1162
|
-
});
|
|
1163
|
-
} catch {
|
|
1164
|
-
return null;
|
|
1165
|
-
}
|
|
1166
|
-
for (const file of files){
|
|
1167
|
-
if (file.isFile() && 'manifest.json' === file.name) return __rspack_external_node_path_c5b9b54f.join(dir, file.name);
|
|
1168
|
-
if (file.isDirectory() && !file.name.startsWith('.') && 'node_modules' !== file.name && 'dist' !== file.name && 'public' !== file.name) {
|
|
1169
|
-
const found = findManifest(__rspack_external_node_path_c5b9b54f.join(dir, file.name), depth + 1);
|
|
1170
|
-
if (found) return found;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
return null;
|
|
1174
|
-
};
|
|
1175
|
-
const foundManifest = findManifest(projectPath, 0);
|
|
1176
|
-
if (foundManifest) manifestPath = foundManifest;
|
|
1177
|
-
else throw new Error(manifestNotFoundError(manifestPath));
|
|
1178
|
-
}
|
|
1179
|
-
const readManifestObject = (candidatePath)=>{
|
|
1180
|
-
try {
|
|
1181
|
-
const parsed = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(candidatePath));
|
|
1182
|
-
if (null === parsed || 'object' != typeof parsed || Array.isArray(parsed)) return;
|
|
1183
|
-
return parsed;
|
|
1184
|
-
} catch {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
const isPwaManifest = (candidatePath)=>{
|
|
1189
|
-
const parsed = readManifestObject(candidatePath);
|
|
1190
|
-
if (!parsed || null != parsed.manifest_version) return false;
|
|
1191
|
-
return Array.isArray(parsed.icons) || 'string' == typeof parsed.start_url || 'string' == typeof parsed.display || null != parsed.related_applications || null != parsed.prefer_related_applications;
|
|
1192
|
-
};
|
|
1193
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath) && isPwaManifest(manifestPath)) {
|
|
1194
|
-
const alternatives = collectManifestCandidates(projectPath, 3).filter((candidate)=>__rspack_external_node_path_c5b9b54f.resolve(candidate) !== __rspack_external_node_path_c5b9b54f.resolve(manifestPath) && readManifestObject(candidate)?.manifest_version != null);
|
|
1195
|
-
if (1 === alternatives.length) {
|
|
1196
|
-
manifestPath = alternatives[0];
|
|
1197
|
-
console.log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
1198
|
-
} else throw new Error(notAnExtensionManifestError(manifestPath));
|
|
1199
|
-
}
|
|
1200
|
-
const packageJsonPath = await findNearestPackageJson(manifestPath);
|
|
1201
|
-
const packageJsonDir = packageJsonPath ? __rspack_external_node_path_c5b9b54f.dirname(packageJsonPath) : void 0;
|
|
1202
|
-
const nearestDenoJsonPath = findNearestDenoConfigSync(manifestPath);
|
|
1203
|
-
const denoJsonPath = nearestDenoJsonPath && validateDenoConfig(nearestDenoJsonPath) ? nearestDenoJsonPath : void 0;
|
|
1204
|
-
const projectRootDir = packageJsonDir ?? (denoJsonPath ? __rspack_external_node_path_c5b9b54f.dirname(denoJsonPath) : void 0);
|
|
1205
|
-
if (projectRootDir) {
|
|
1206
|
-
const publicRoot = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'public');
|
|
1207
|
-
if (isUnderDir(publicRoot, manifestPath)) {
|
|
1208
|
-
const fallbackSrc = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'src', 'manifest.json');
|
|
1209
|
-
const fallbackRoot = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'manifest.json');
|
|
1210
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(fallbackSrc)) manifestPath = fallbackSrc;
|
|
1211
|
-
else if (__rspack_external_node_fs_5ea92f0c.existsSync(fallbackRoot)) manifestPath = fallbackRoot;
|
|
1212
|
-
else throw new Error(manifestNotFoundError(fallbackRoot));
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
if (!packageJsonPath || !validatePackageJson(packageJsonPath)) return {
|
|
1216
|
-
manifestPath,
|
|
1217
|
-
...denoJsonPath ? {
|
|
1218
|
-
denoJsonPath
|
|
1219
|
-
} : {}
|
|
1220
|
-
};
|
|
1221
|
-
return {
|
|
1222
|
-
manifestPath,
|
|
1223
|
-
packageJsonPath,
|
|
1224
|
-
...denoJsonPath ? {
|
|
1225
|
-
denoJsonPath
|
|
1226
|
-
} : {}
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
439
|
function isReferencedAsModuleSpecifier(configSource, dep) {
|
|
1230
440
|
const escaped = dep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1231
441
|
const specifierRe = new RegExp(`['"\`]${escaped}(?:/[^'"\`]*)?['"\`]`);
|
|
@@ -1374,7 +584,7 @@ function readManifestProvenance(manifestPath) {
|
|
|
1374
584
|
return {};
|
|
1375
585
|
}
|
|
1376
586
|
}
|
|
1377
|
-
function
|
|
587
|
+
function ensureDirSync(dirPath) {
|
|
1378
588
|
try {
|
|
1379
589
|
__rspack_external_node_fs_5ea92f0c.mkdirSync(dirPath, {
|
|
1380
590
|
recursive: true
|
|
@@ -1465,7 +675,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
1465
675
|
};
|
|
1466
676
|
function writeReady(status, extra) {
|
|
1467
677
|
if (foreignLiveDevSession) return;
|
|
1468
|
-
|
|
678
|
+
ensureDirSync(metadataDir);
|
|
1469
679
|
let prev;
|
|
1470
680
|
try {
|
|
1471
681
|
if (__rspack_external_node_fs_5ea92f0c.existsSync(readyPath)) prev = JSON.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(readyPath, 'utf-8'));
|
|
@@ -1522,7 +732,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
1522
732
|
}
|
|
1523
733
|
function appendEvent(event) {
|
|
1524
734
|
if (foreignLiveDevSession) return;
|
|
1525
|
-
|
|
735
|
+
ensureDirSync(metadataDir);
|
|
1526
736
|
try {
|
|
1527
737
|
__rspack_external_node_fs_5ea92f0c.appendFileSync(eventsPath, `${JSON.stringify({
|
|
1528
738
|
...event,
|
|
@@ -1540,7 +750,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
1540
750
|
},
|
|
1541
751
|
writeStarting () {
|
|
1542
752
|
if (foreignLiveDevSession) return;
|
|
1543
|
-
|
|
753
|
+
ensureDirSync(metadataDir);
|
|
1544
754
|
try {
|
|
1545
755
|
__rspack_external_node_fs_5ea92f0c.writeFileSync(eventsPath, '', 'utf-8');
|
|
1546
756
|
} catch {}
|
|
@@ -1720,7 +930,23 @@ function normalizeCompanionConfig(config) {
|
|
|
1720
930
|
paths: explicitPaths
|
|
1721
931
|
};
|
|
1722
932
|
}
|
|
1723
|
-
|
|
933
|
+
const BROWSER_COMPANION_FOLDERS = new Set([
|
|
934
|
+
'chrome',
|
|
935
|
+
'edge',
|
|
936
|
+
'firefox'
|
|
937
|
+
]);
|
|
938
|
+
function isBrowserNamedCompanionFolder(name) {
|
|
939
|
+
return BROWSER_COMPANION_FOLDERS.has(name.toLowerCase());
|
|
940
|
+
}
|
|
941
|
+
function companionFolderForBrowser(browser) {
|
|
942
|
+
if (browser && isGeckoBasedBrowser(String(browser))) return 'firefox';
|
|
943
|
+
if ('edge' === browser) return 'edge';
|
|
944
|
+
return 'chrome';
|
|
945
|
+
}
|
|
946
|
+
function companionFolderMatchesBrowser(name, browser) {
|
|
947
|
+
return name.toLowerCase() === companionFolderForBrowser(browser);
|
|
948
|
+
}
|
|
949
|
+
function isPathLike(value) {
|
|
1724
950
|
if (__rspack_external_node_path_c5b9b54f.isAbsolute(value)) return true;
|
|
1725
951
|
if (value.startsWith('./') || value.startsWith('../')) return true;
|
|
1726
952
|
return value.includes('/') || value.includes('\\');
|
|
@@ -1735,27 +961,46 @@ function getBrowserFolder(browser) {
|
|
|
1735
961
|
return 'chrome';
|
|
1736
962
|
}
|
|
1737
963
|
function parseChromeWebStoreId(url) {
|
|
1738
|
-
|
|
964
|
+
const host = stripWww(url.hostname);
|
|
965
|
+
const legacy = 'chrome.google.com' === host && /^\/webstore(?:\/|$)/i.test(url.pathname);
|
|
966
|
+
if ('chromewebstore.google.com' !== host && !legacy) return null;
|
|
1739
967
|
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
1740
968
|
return match ? match[1] : null;
|
|
1741
969
|
}
|
|
1742
970
|
function parseEdgeAddonsId(url) {
|
|
1743
|
-
if ('microsoftedge.microsoft.com' !== url.hostname) return null;
|
|
971
|
+
if ('microsoftedge.microsoft.com' !== stripWww(url.hostname)) return null;
|
|
1744
972
|
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
1745
973
|
return match ? match[1] : null;
|
|
1746
974
|
}
|
|
1747
975
|
function parseAmoSlug(url) {
|
|
1748
|
-
if ('addons.mozilla.org' !== url.hostname) return null;
|
|
976
|
+
if ('addons.mozilla.org' !== stripWww(url.hostname)) return null;
|
|
1749
977
|
const match = url.pathname.match(/\/addon\/([^/]+)(?:\/|$)/i);
|
|
1750
978
|
return match ? match[1] : null;
|
|
1751
979
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
980
|
+
const STORE_HOSTS = new Set([
|
|
981
|
+
'chromewebstore.google.com',
|
|
982
|
+
'chrome.google.com',
|
|
983
|
+
'microsoftedge.microsoft.com',
|
|
984
|
+
'addons.mozilla.org'
|
|
985
|
+
]);
|
|
986
|
+
function stripWww(hostname) {
|
|
987
|
+
return hostname.toLowerCase().replace(/^www\./, '');
|
|
988
|
+
}
|
|
989
|
+
function toWebUrl(raw) {
|
|
1754
990
|
try {
|
|
1755
|
-
url = new URL(raw);
|
|
991
|
+
const url = new URL(raw);
|
|
992
|
+
if ('http:' === url.protocol || 'https:' === url.protocol) return url;
|
|
993
|
+
return null;
|
|
994
|
+
} catch {}
|
|
995
|
+
const match = raw.match(/^([a-z0-9.-]+)(?:[/?#].*)?$/i);
|
|
996
|
+
if (!match || !STORE_HOSTS.has(stripWww(match[1]))) return null;
|
|
997
|
+
try {
|
|
998
|
+
return new URL(`https://${raw}`);
|
|
1756
999
|
} catch {
|
|
1757
1000
|
return null;
|
|
1758
1001
|
}
|
|
1002
|
+
}
|
|
1003
|
+
function parseStoreUrl(url) {
|
|
1759
1004
|
const chromeId = parseChromeWebStoreId(url);
|
|
1760
1005
|
if (chromeId) return {
|
|
1761
1006
|
browser: 'chrome',
|
|
@@ -1845,19 +1090,26 @@ async function resolveCompanionExtensionsConfig(opts) {
|
|
|
1845
1090
|
const resolvedPaths = [];
|
|
1846
1091
|
const localPaths = [];
|
|
1847
1092
|
for (const entry of normalized.paths){
|
|
1848
|
-
const
|
|
1849
|
-
if (
|
|
1093
|
+
const url = toWebUrl(entry);
|
|
1094
|
+
if (url) {
|
|
1095
|
+
const parsedStore = parseStoreUrl(url);
|
|
1096
|
+
if (!parsedStore) throw new Error(`Companion extension link is not a store link this resolver recognises: ${entry}\nSupported links: https://chromewebstore.google.com/detail/<name>/<id>, https://microsoftedge.microsoft.com/addons/detail/<name>/<id>, https://addons.mozilla.org/<locale>/firefox/addon/<slug>`);
|
|
1850
1097
|
if (parsedStore.browser !== runtimeBrowser) continue;
|
|
1851
1098
|
const resolvedPath = await resolveStoreExtensionToPath({
|
|
1852
1099
|
projectRoot,
|
|
1853
|
-
storeUrl:
|
|
1100
|
+
storeUrl: url.href,
|
|
1854
1101
|
browser: parsedStore.browser,
|
|
1855
1102
|
id: parsedStore.id
|
|
1856
1103
|
});
|
|
1857
1104
|
resolvedPaths.push(resolvedPath);
|
|
1858
1105
|
continue;
|
|
1859
1106
|
}
|
|
1860
|
-
if (
|
|
1107
|
+
if (isPathLike(entry)) {
|
|
1108
|
+
localPaths.push(entry);
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
if (/^[a-p]{32}$/i.test(entry)) throw new Error(`Companion extension entry looks like a store id, not a store link: ${entry}\nUse the full store link so the browser it belongs to is known, for example https://chromewebstore.google.com/detail/<name>/${entry}`);
|
|
1112
|
+
throw new Error(`Companion extension entry is neither a store link nor a folder path: ${entry}\nGive a store link or a path under ./extensions`);
|
|
1861
1113
|
}
|
|
1862
1114
|
if (localPaths.length > 0) {
|
|
1863
1115
|
const absLocalPaths = ensurePathsUnderExtensions(projectRoot, localPaths);
|
|
@@ -1876,6 +1128,15 @@ async function resolveCompanionExtensionsConfig(opts) {
|
|
|
1876
1128
|
function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
|
|
1877
1129
|
return `${messaging_prefix('warn')} ${addingOrRemoving} ${pintor.yellow(typeOfAsset)} in ${pintor.underline(`${folder}/`)} changes the extension entrypoints.\nRestart the dev server to apply the change.`;
|
|
1878
1130
|
}
|
|
1131
|
+
function displayPath(absolutePath) {
|
|
1132
|
+
return absolutePath.replace(/\\/g, '/');
|
|
1133
|
+
}
|
|
1134
|
+
function publicMustBeAtProjectRoot(foundAt, expectedAt) {
|
|
1135
|
+
return `The public folder sits in the legacy next-to-manifest location.\nGOT ${displayPath(foundAt)}\nEXPECTED ${displayPath(expectedAt)}\nStatic files ship from the extension root, so public/ is canonically placed at the project root.\nThe build uses it either way.\nMove the folder to the project root to silence this warning.`;
|
|
1136
|
+
}
|
|
1137
|
+
function publicFolderShadowed(usedAt, ignoredAt) {
|
|
1138
|
+
return `Two public folders were found and only one is copied into the build.\nUSING ${displayPath(usedAt)}\nIGNORED ${displayPath(ignoredAt)}\npublic/ is canonically placed at the project root, and that copy wins.\nFiles that exist only in the ignored folder do not ship.\nMove or merge the ignored folder to silence this warning.`;
|
|
1139
|
+
}
|
|
1879
1140
|
function specialFoldersSetupSummary(hasPublic, copyEnabled, ignoredCount) {
|
|
1880
1141
|
return `${messaging_prefix('debug')} folders setup public=${String(hasPublic)} copy=${String(copyEnabled)} ignored=${String(ignoredCount)}`;
|
|
1881
1142
|
}
|
|
@@ -2238,14 +1499,14 @@ function withDarkMode(config) {
|
|
|
2238
1499
|
};
|
|
2239
1500
|
}
|
|
2240
1501
|
const cjsRequire = createRequire(import.meta.url);
|
|
2241
|
-
function
|
|
1502
|
+
function getLoggingPrefix(type) {
|
|
2242
1503
|
return messaging_prefix(type);
|
|
2243
1504
|
}
|
|
2244
1505
|
function messages_ready(mode, browser) {
|
|
2245
1506
|
const noun = artifactNoun(browser);
|
|
2246
1507
|
const state = pintor.green(`ready for ${mode}`);
|
|
2247
1508
|
const watching = 'development' === mode ? ' Watching for file changes.' : '';
|
|
2248
|
-
return `${
|
|
1509
|
+
return `${getLoggingPrefix('success')} ${noun} ${state}.${watching}`;
|
|
2249
1510
|
}
|
|
2250
1511
|
function readJsonRecord(filePath) {
|
|
2251
1512
|
try {
|
|
@@ -2316,37 +1577,46 @@ function shouldWarnPortConflict(requested, actual) {
|
|
|
2316
1577
|
return Number.isFinite(requestedPort) && 0 !== requestedPort && requestedPort !== actual;
|
|
2317
1578
|
}
|
|
2318
1579
|
function portInUse(requestedPort, newPort) {
|
|
2319
|
-
return `${
|
|
1580
|
+
return `${getLoggingPrefix('warn')} Port ${requestedPort} is in use.\nThe dev server listens on port ${newPort} instead.`;
|
|
2320
1581
|
}
|
|
2321
1582
|
function extensionJsRunnerError(error) {
|
|
2322
|
-
return `${
|
|
1583
|
+
return `${getLoggingPrefix('error')} Extension.js couldn't start the runner.\n${pintor.red(String(error))}`;
|
|
2323
1584
|
}
|
|
2324
1585
|
function autoExitModeEnabled(ms) {
|
|
2325
|
-
return `${
|
|
1586
|
+
return `${getLoggingPrefix('info')} Auto-exit is enabled.\nThe process exits after ${ms} ms of idle time.`;
|
|
2326
1587
|
}
|
|
2327
1588
|
function autoExitTriggered(ms) {
|
|
2328
|
-
return `${
|
|
1589
|
+
return `${getLoggingPrefix('info')} Auto-exit triggered after ${ms} ms.\nThe process cleans up and exits now.`;
|
|
2329
1590
|
}
|
|
2330
1591
|
function autoExitForceKill(ms) {
|
|
2331
|
-
return `${
|
|
1592
|
+
return `${getLoggingPrefix('warn')} The process didn't exit within ${ms} ms, so it exits forcibly now.`;
|
|
2332
1593
|
}
|
|
2333
1594
|
function devServerStartTimeout(ms) {
|
|
2334
1595
|
return [
|
|
2335
|
-
`${
|
|
1596
|
+
`${getLoggingPrefix('warn')} The dev server didn't start within ${ms} ms.`,
|
|
2336
1597
|
"The bundler may have hit an error before emitting the first build.",
|
|
2337
1598
|
`If nothing else prints, set ${pintor.blue('EXTENSION_VERBOSE=1')} to see more logs.`
|
|
2338
1599
|
].join('\n');
|
|
2339
1600
|
}
|
|
2340
1601
|
function bundlerFatalError(error) {
|
|
2341
1602
|
const text = error instanceof Error ? error.stack || error.message : String(error);
|
|
2342
|
-
return `${
|
|
1603
|
+
return `${getLoggingPrefix('error')} The build failed to start.\n${pintor.red(text)}`;
|
|
1604
|
+
}
|
|
1605
|
+
function devServerRestarting(request) {
|
|
1606
|
+
const what = 'icons' === request.reason ? 'a manifest icon' : 'html' === request.reason ? 'an HTML entrypoint' : 'json' === request.reason ? 'a manifest JSON entry' : "a manifest script entry";
|
|
1607
|
+
const lines = [
|
|
1608
|
+
`${getLoggingPrefix('info')} Restarting the dev server to pick up ${what} change…`
|
|
1609
|
+
];
|
|
1610
|
+
if (request.pathBefore) lines.push(`${pintor.gray('BEFORE')} ${pintor.underline(request.pathBefore)}`);
|
|
1611
|
+
if (request.pathAfter) lines.push(`${pintor.gray('AFTER')} ${pintor.underline(request.pathAfter)}`);
|
|
1612
|
+
return lines.join('\n');
|
|
2343
1613
|
}
|
|
2344
1614
|
function bundlerRecompiling() {
|
|
2345
|
-
return `${
|
|
1615
|
+
return `${getLoggingPrefix('info')} Recompiling due to file changes…`;
|
|
2346
1616
|
}
|
|
2347
1617
|
function noEntrypointsDetected(port) {
|
|
2348
1618
|
return [
|
|
2349
|
-
`${
|
|
1619
|
+
`${getLoggingPrefix('warn')} The first compilation produced no entrypoints or assets.`,
|
|
2350
1620
|
`The dev server is running on 127.0.0.1:${port}, but nothing is being built.`,
|
|
2351
1621
|
"Possible causes:",
|
|
2352
1622
|
"- Empty or missing entry configuration.",
|
|
@@ -2358,6 +1628,15 @@ function noEntrypointsDetected(port) {
|
|
|
2358
1628
|
function spacerLine() {
|
|
2359
1629
|
return ' ';
|
|
2360
1630
|
}
|
|
1631
|
+
function runnerCleanupError(error) {
|
|
1632
|
+
return `${messaging_prefix('error')} The dev server could not shut down cleanly: ${String(error?.message || error)}`;
|
|
1633
|
+
}
|
|
1634
|
+
function runnerUncaughtException(error) {
|
|
1635
|
+
return `${messaging_prefix('error')} Uncaught exception in the dev server: ${String(error?.message || error)}`;
|
|
1636
|
+
}
|
|
1637
|
+
function runnerUnhandledRejection(reason) {
|
|
1638
|
+
return `${messaging_prefix('error')} Unhandled rejection in the dev server: ${String(reason?.message || reason)}`;
|
|
1639
|
+
}
|
|
2361
1640
|
function hasNewTabOverride(extensionDir) {
|
|
2362
1641
|
const manifestPath = __rspack_external_node_path_c5b9b54f.join(extensionDir, 'manifest.json');
|
|
2363
1642
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) return false;
|
|
@@ -2433,7 +1712,7 @@ function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath
|
|
|
2433
1712
|
return dedupeByResolvedPath(list);
|
|
2434
1713
|
}
|
|
2435
1714
|
function resolveCompanionExtensionDirs(opts) {
|
|
2436
|
-
const { projectRoot, config } = opts;
|
|
1715
|
+
const { projectRoot, config, browser } = opts;
|
|
2437
1716
|
const normalized = normalizeCompanionConfig(config);
|
|
2438
1717
|
const explicitPaths = normalized.paths;
|
|
2439
1718
|
const scanDir = normalized.dir;
|
|
@@ -2473,6 +1752,7 @@ function resolveCompanionExtensionDirs(opts) {
|
|
|
2473
1752
|
for (const ent of entries){
|
|
2474
1753
|
if (!ent.isDirectory()) continue;
|
|
2475
1754
|
if (ent.name.startsWith('.')) continue;
|
|
1755
|
+
if (browser && isBrowserNamedCompanionFolder(ent.name) && !companionFolderMatchesBrowser(ent.name, browser)) continue;
|
|
2476
1756
|
const browserDir = __rspack_external_node_path_c5b9b54f.join(absScan, ent.name);
|
|
2477
1757
|
scanOneLevel(browserDir);
|
|
2478
1758
|
}
|
|
@@ -2500,16 +1780,17 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2500
1780
|
const { manifestDir, packageJsonDir } = getDirs(projectStructure);
|
|
2501
1781
|
const userManifestPath = projectStructure.packageJsonPath || projectStructure.denoJsonPath;
|
|
2502
1782
|
if (userManifestPath) assertNoManagedDependencyConflicts(userManifestPath, packageJsonDir);
|
|
2503
|
-
const
|
|
1783
|
+
const metadataCommand = 'start' === previewOptions.metadataCommand ? 'start' : 'preview';
|
|
1784
|
+
const configBrowser = previewOptions.browser ? void 0 : configBrowserOrThrow((await loadCommandConfig(packageJsonDir, metadataCommand)).browser, metadataCommand);
|
|
1785
|
+
const browser = normalizeBrowser(previewOptions.browser || configBrowser || 'chrome', previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary);
|
|
2504
1786
|
const outputPath = computePreviewOutputPath(projectStructure, browser, previewOptions.outputPath);
|
|
2505
1787
|
const distPath = getDistPath(packageJsonDir, browser);
|
|
2506
|
-
const metadataCommand = 'start' === previewOptions.metadataCommand ? 'start' : 'preview';
|
|
2507
1788
|
const runningMessage = 'start' === metadataCommand ? starting : previewing;
|
|
2508
1789
|
const metadata = createPlaywrightMetadataWriter({
|
|
2509
1790
|
packageJsonDir,
|
|
2510
1791
|
browser: String(browser),
|
|
2511
1792
|
command: metadataCommand,
|
|
2512
|
-
distPath,
|
|
1793
|
+
distPath: outputPath,
|
|
2513
1794
|
manifestPath: projectStructure.manifestPath,
|
|
2514
1795
|
port: 'number' == typeof previewOptions.port ? previewOptions.port : 'string' == typeof previewOptions.port ? parseInt(previewOptions.port, 10) : null
|
|
2515
1796
|
});
|
|
@@ -2520,11 +1801,13 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2520
1801
|
humanLine(debugBrowser(browser, previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary));
|
|
2521
1802
|
humanLine(debugPreviewOutput(outputPath, distPath));
|
|
2522
1803
|
}
|
|
1804
|
+
ensureSessionArtifactsIgnoreFile(packageJsonDir);
|
|
2523
1805
|
const manifestAtOutput = __rspack_external_node_path_c5b9b54f.join(outputPath, 'manifest.json');
|
|
2524
1806
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestAtOutput)) {
|
|
2525
1807
|
metadata.writeError('preview_manifest_missing', `Expected manifest at ${manifestAtOutput}`);
|
|
2526
1808
|
throw new Error(`Preview is run-only and does not compile.\nExpected an unpacked extension at:\n ${manifestAtOutput}\n\nRun \`extension build\` or \`extension dev\` first, or pass --output-path to an existing unpacked extension directory.`);
|
|
2527
1809
|
}
|
|
1810
|
+
const projectConfig = await loadProjectConfigDefaults(packageJsonDir);
|
|
2528
1811
|
const commandConfig = await loadCommandConfig(packageJsonDir, metadataCommand);
|
|
2529
1812
|
const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
|
|
2530
1813
|
if (previewOptions.noBrowser) {
|
|
@@ -2542,12 +1825,13 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2542
1825
|
return;
|
|
2543
1826
|
}
|
|
2544
1827
|
humanLine(runningMessage(browser));
|
|
2545
|
-
if (
|
|
1828
|
+
if (__rspack_external_node_path_c5b9b54f.resolve(outputPath) !== __rspack_external_node_path_c5b9b54f.resolve(distPath)) humanLine(previewOptions.outputPath ? previewingCustomOutput(browser, outputPath, distPath) : previewingSourceFallback(browser, distPath));
|
|
1829
|
+
const safeProjectConfig = sanitize(projectConfig);
|
|
2546
1830
|
const safeBrowserConfig = sanitize(browserConfig);
|
|
2547
1831
|
const safeCommandConfig = sanitize(commandConfig);
|
|
2548
1832
|
const safePreviewOptions = sanitize(previewOptions);
|
|
2549
1833
|
const specialFoldersData = getSpecialFoldersDataForProjectRoot(packageJsonDir);
|
|
2550
|
-
const mergedExtensionsConfig = safePreviewOptions.extensions ?? safeCommandConfig.extensions ?? safeBrowserConfig.extensions ?? specialFoldersData.extensions;
|
|
1834
|
+
const mergedExtensionsConfig = safePreviewOptions.extensions ?? safeCommandConfig.extensions ?? safeBrowserConfig.extensions ?? safeProjectConfig.extensions ?? specialFoldersData.extensions;
|
|
2551
1835
|
const resolvedExtensionsConfig = await resolveCompanionExtensionsConfig({
|
|
2552
1836
|
projectRoot: packageJsonDir,
|
|
2553
1837
|
browser,
|
|
@@ -2556,7 +1840,7 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2556
1840
|
const mergedGeckoBinary = safePreviewOptions.geckoBinary || safePreviewOptions.firefoxBinary || safeCommandConfig.geckoBinary || safeCommandConfig.firefoxBinary || safeBrowserConfig.geckoBinary || safeBrowserConfig.firefoxBinary;
|
|
2557
1841
|
const mergedChromiumBinary = safePreviewOptions.chromiumBinary || safeCommandConfig.chromiumBinary || safeBrowserConfig.chromiumBinary;
|
|
2558
1842
|
const merged = {
|
|
2559
|
-
...mergeOptionLayers(SERVE_COMMAND_DEFAULTS, safeBrowserConfig, safeCommandConfig, safePreviewOptions),
|
|
1843
|
+
...mergeOptionLayers(SERVE_COMMAND_DEFAULTS, safeProjectConfig, safeBrowserConfig, safeCommandConfig, safePreviewOptions),
|
|
2560
1844
|
extensions: resolvedExtensionsConfig,
|
|
2561
1845
|
chromiumBinary: mergedChromiumBinary,
|
|
2562
1846
|
geckoBinary: mergedGeckoBinary
|
|
@@ -2569,7 +1853,8 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2569
1853
|
});
|
|
2570
1854
|
const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
|
|
2571
1855
|
projectRoot: packageJsonDir,
|
|
2572
|
-
config: merged.extensions
|
|
1856
|
+
config: merged.extensions,
|
|
1857
|
+
browser
|
|
2573
1858
|
});
|
|
2574
1859
|
const unpackedExtensionDirsToLoad = computeExtensionsToLoad(__rspack_external_node_path_c5b9b54f.resolve(__rspack_import_meta_dirname__, '..'), 'production', browser, outputPath, companionUnpackedExtensionDirs, projectStructure.manifestPath);
|
|
2575
1860
|
metadata.setManagedExtensionDirs(unpackedExtensionDirsToLoad.filter((dir)=>__rspack_external_node_path_c5b9b54f.resolve(dir) !== __rspack_external_node_path_c5b9b54f.resolve(outputPath)));
|
|
@@ -2603,4 +1888,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2603
1888
|
await browserLauncher(resolvedOpts);
|
|
2604
1889
|
metadata.writeReady();
|
|
2605
1890
|
}
|
|
2606
|
-
export { BUILD_COMMAND_DEFAULTS, CHROMIUM_FAMILY_ALIASES, DEV_COMMAND_DEFAULTS, GECKO_FAMILY_ALIASES, PlaywrightPlugin, START_BUILD_DEFAULTS,
|
|
1891
|
+
export { BUILD_COMMAND_DEFAULTS, CHROMIUM_FAMILY_ALIASES, DEV_COMMAND_DEFAULTS, GECKO_FAMILY_ALIASES, PlaywrightPlugin, START_BUILD_DEFAULTS, assertNoManagedDependencyConflicts, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserRunnerDisabled, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, devServerRestarting, devServerStartTimeout, extensionJsRunnerError, extensionPreview, getPreloadedEnvKeys, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, isChromiumBasedBrowser, isGeckoBasedBrowser, isWebkitBasedBrowser, loadBrowserConfig, loadCommandConfig, loadCustomConfig, loadProjectConfigDefaults, mergeOptionLayers, messages_ready, noEntrypointsDetected, package_namespaceObject, portInUse, publicFolderShadowed, publicMustBeAtProjectRoot, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, runnerCleanupError, runnerUncaughtException, runnerUnhandledRejection, sanitize, serverRestartRequiredFromSpecialFolderMessageOnly, shouldWarnPortConflict, spacerLine, specialFolderChangeDetected, specialFoldersSetupSummary, stampReadyDistExtensionId, stampReadyKnownExtensionId, withDarkMode };
|