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.
- 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 -895
- 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 +178 -40
- 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,377 +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 buildShareHint() {
|
|
144
|
-
return `${getLoggingPrefix('info')} Send this build to someone for review: ` + pintor.underline('https://docs.extension.dev/share/unpublished-build-for-review?utm_source=cli-build');
|
|
145
|
-
}
|
|
146
|
-
function buildFailed(errorCount) {
|
|
147
|
-
const count = Math.max(1, Math.floor(errorCount || 1));
|
|
148
|
-
const noun = 1 === count ? 'error' : 'errors';
|
|
149
|
-
return `${getLoggingPrefix('error')} Build failed with ${count} ${noun}.`;
|
|
150
|
-
}
|
|
151
|
-
function stripModuleWarningWrapper(message) {
|
|
152
|
-
return message.replace(/^Module (?:Warning|Error) \(from [^)]*\):\s*/, '');
|
|
153
|
-
}
|
|
154
|
-
function getWarningMessage(warning) {
|
|
155
|
-
if (!warning) return '';
|
|
156
|
-
if ('string' == typeof warning) return stripModuleWarningWrapper(warning.trim());
|
|
157
|
-
const candidates = [
|
|
158
|
-
warning.message,
|
|
159
|
-
warning.details,
|
|
160
|
-
warning.reason,
|
|
161
|
-
warning.description
|
|
162
|
-
];
|
|
163
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return stripModuleWarningWrapper(candidate.trim());
|
|
164
|
-
return '';
|
|
165
|
-
}
|
|
166
|
-
function getWarningSource(warning) {
|
|
167
|
-
if (!warning || 'string' == typeof warning) return 'bundler';
|
|
168
|
-
const candidates = [
|
|
169
|
-
warning.name,
|
|
170
|
-
warning.moduleName,
|
|
171
|
-
warning.moduleIdentifier,
|
|
172
|
-
warning.originName,
|
|
173
|
-
warning.pluginName
|
|
174
|
-
];
|
|
175
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
176
|
-
return 'bundler';
|
|
177
|
-
}
|
|
178
|
-
function getWarningArtifact(warning) {
|
|
179
|
-
if (!warning || 'string' == typeof warning) return '';
|
|
180
|
-
const candidates = [
|
|
181
|
-
warning.file,
|
|
182
|
-
warning.chunkName,
|
|
183
|
-
warning.moduleName
|
|
184
|
-
];
|
|
185
|
-
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
186
|
-
return '';
|
|
187
|
-
}
|
|
188
|
-
function classifyWarning(message, source) {
|
|
189
|
-
const haystack = `${message} ${source}`.toLowerCase();
|
|
190
|
-
if (haystack.includes('performance') || haystack.includes('asset size') || haystack.includes('entrypoint size') || haystack.includes('exceeds the recommended size') || haystack.includes('hints')) return 'Performance';
|
|
191
|
-
if (haystack.includes('deprecat') || haystack.includes('[dep_') || haystack.includes('legacy')) return 'Deprecation';
|
|
192
|
-
if (haystack.includes('invalid') || haystack.includes('unknown option') || haystack.includes('configuration') || haystack.includes('schema')) return 'Configuration';
|
|
193
|
-
if (haystack.includes('manifest') || haystack.includes('browser') || haystack.includes('target')) return 'Compatibility';
|
|
194
|
-
if (haystack.includes('runtime') || haystack.includes('will fail') || haystack.includes('cannot resolve') || haystack.includes('service_worker')) return 'Runtime-risk';
|
|
195
|
-
return 'Warning';
|
|
196
|
-
}
|
|
197
|
-
function suggestedHintForWarning(category) {
|
|
198
|
-
if ('Performance' === category) return 'Inspect the largest startup bundles and split optional code paths.';
|
|
199
|
-
if ('Deprecation' === category) return 'Move to the supported API or plugin path before the next update.';
|
|
200
|
-
if ('Configuration' === category) return 'Review extension and bundler config keys, then remove or rename invalid options.';
|
|
201
|
-
if ('Compatibility' === category) return 'Verify browser target and manifest compatibility for this build.';
|
|
202
|
-
if ('Runtime-risk' === category) return 'Address this before release. It may fail or degrade at runtime.';
|
|
203
|
-
return 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning details.';
|
|
204
|
-
}
|
|
205
|
-
function buildWarningsDetails(warnings) {
|
|
206
|
-
if (!Array.isArray(warnings) || 0 === warnings.length) return '';
|
|
207
|
-
const blocks = [];
|
|
208
|
-
warnings.forEach((warning, index)=>{
|
|
209
|
-
const message = getWarningMessage(warning);
|
|
210
|
-
const source = getWarningSource(warning);
|
|
211
|
-
const artifact = getWarningArtifact(warning);
|
|
212
|
-
const category = classifyWarning(message, source);
|
|
213
|
-
const hint = suggestedHintForWarning(category);
|
|
214
|
-
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.')}`);
|
|
215
|
-
const performanceWarning = parsePerformanceWarning(warning, source, artifact);
|
|
216
|
-
if (performanceWarning) return void blocks.push(performanceWarning);
|
|
217
|
-
const oneLine = message.replace(/\s+/g, ' ').trim();
|
|
218
|
-
const artifactSuffix = artifact ? ` ${pintor.gray(`(${artifact})`)}` : '';
|
|
219
|
-
blocks.push(`${getLoggingPrefix('warn')} ${category}: ${oneLine}${artifactSuffix}\n${formatWarningLabelLine('Source', pintor.gray(source))}\n${formatWarningLabelLine('Hint', hint)}`);
|
|
220
|
-
});
|
|
221
|
-
return blocks.join('\n\n');
|
|
222
|
-
}
|
|
223
|
-
function fetchingProjectPath(owner, project) {
|
|
224
|
-
return fmt.block('Fetching project', [
|
|
225
|
-
[
|
|
226
|
-
'URL',
|
|
227
|
-
fmt.val(`https://github.com/${owner}/${project}`)
|
|
228
|
-
]
|
|
229
|
-
]);
|
|
230
|
-
}
|
|
231
|
-
function downloadingProjectPath(projectName) {
|
|
232
|
-
const formatted = isPathLike(projectName) ? pintor.underline(projectName) : projectName;
|
|
233
|
-
return `${getLoggingPrefix('info')} Downloading ${formatted}…`;
|
|
234
|
-
}
|
|
235
|
-
function creatingProjectPath(projectPath) {
|
|
236
|
-
return `${getLoggingPrefix('info')} Creating a new browser extension…\n${pintor.gray('PATH')} ${pintor.underline(projectPath)}`;
|
|
237
|
-
}
|
|
238
|
-
function downloadedProjectFolderNotFound(cwd, candidates) {
|
|
239
|
-
return `${getLoggingPrefix('error')} Downloaded project folder not found.\n${pintor.gray('PATH')} ${pintor.underline(cwd)}\n${pintor.gray('NOT FOUND')} ${pintor.underline(candidates.join(', '))}`;
|
|
240
|
-
}
|
|
241
|
-
function packagingSourceFiles(zipPath) {
|
|
242
|
-
return `${messaging_prefix('debug')} zip pack=source gitignore=excluded path=${zipPath}`;
|
|
243
|
-
}
|
|
244
|
-
function zipArtifactReady(zipPath, sizeInBytes) {
|
|
245
|
-
return `${getLoggingPrefix('success')} Packaged ${pintor.underline(zipPath)} (${getHumanSize(sizeInBytes)}).`;
|
|
246
|
-
}
|
|
247
|
-
function packagingDistributionFiles(zipPath) {
|
|
248
|
-
return `${messaging_prefix('debug')} zip pack=dist path=${zipPath}`;
|
|
249
|
-
}
|
|
250
|
-
function treeWithSourceAndDistFiles(browser, name, sourceZip, destZip) {
|
|
251
|
-
return `${messaging_prefix('debug')} zip name=${name} browser=${String(browser)} source=${sourceZip} dist=${destZip}`;
|
|
252
|
-
}
|
|
253
|
-
function treeWithDistFilesBrowser(name, ext, browser, zipPath) {
|
|
254
|
-
return `${messaging_prefix('debug')} zip name=${name}.${ext} browser=${String(browser)} dist=${zipPath}`;
|
|
255
|
-
}
|
|
256
|
-
function treeWithSourceFiles(name, ext, browser, zipPath) {
|
|
257
|
-
return `${messaging_prefix('debug')} zip name=${name}-source.${ext} browser=${String(browser)} source=${zipPath}`;
|
|
258
|
-
}
|
|
259
|
-
function writingTypeDefinitions(manifest) {
|
|
260
|
-
return `${getLoggingPrefix('info')} Writing the type definitions for ${manifest.name || 'the extension'}…`;
|
|
261
|
-
}
|
|
262
|
-
function writingTypeDefinitionsError(error) {
|
|
263
|
-
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.`;
|
|
264
|
-
}
|
|
265
|
-
function downloadingText(url) {
|
|
266
|
-
return fmt.block('Downloading extension', [
|
|
267
|
-
[
|
|
268
|
-
'URL',
|
|
269
|
-
fmt.val(url)
|
|
270
|
-
]
|
|
271
|
-
]);
|
|
272
|
-
}
|
|
273
|
-
function unpackagingExtension(zipFilePath) {
|
|
274
|
-
return `${getLoggingPrefix('info')} Unpackaging the browser extension…\n${pintor.gray('PATH')} ${pintor.underline(zipFilePath)}`;
|
|
275
|
-
}
|
|
276
|
-
function unpackagedSuccessfully() {
|
|
277
|
-
return `${getLoggingPrefix('success')} Extension unpackaged.`;
|
|
278
|
-
}
|
|
279
|
-
function failedToDownloadOrExtractZIPFileError(error) {
|
|
280
|
-
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.`;
|
|
281
|
-
}
|
|
282
|
-
function invalidRemoteZip(url, contentType) {
|
|
283
|
-
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.`;
|
|
284
|
-
}
|
|
285
|
-
function notAZipArchive(source, contentType) {
|
|
286
|
-
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.";
|
|
287
|
-
}
|
|
288
|
-
function localZipNotFound(zipFilePath) {
|
|
289
|
-
return `${getLoggingPrefix('error')} ZIP file not found.\n${pintor.gray('NOT FOUND')} ${pintor.underline(zipFilePath)}\nCheck the path, then try again.`;
|
|
290
|
-
}
|
|
291
|
-
function capitalizedBrowserName(browser) {
|
|
292
|
-
const b = String(browser || '');
|
|
293
|
-
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
294
|
-
return pintor.yellow(`${cap}`);
|
|
295
|
-
}
|
|
296
|
-
function getFileSize(fileSizeInBytes) {
|
|
297
|
-
return `${(fileSizeInBytes / 1024).toFixed(2)}KB`;
|
|
298
|
-
}
|
|
299
|
-
function getHumanSize(sizeInBytes) {
|
|
300
|
-
const bytes = Math.max(0, sizeInBytes || 0);
|
|
301
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
302
|
-
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
303
|
-
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
304
|
-
}
|
|
305
|
-
function printTree(node, prefix = '') {
|
|
306
|
-
let output = '';
|
|
307
|
-
Object.keys(node).forEach((key, index, array)=>{
|
|
308
|
-
const isLast = index === array.length - 1;
|
|
309
|
-
const connector = isLast ? '└─' : '├─';
|
|
310
|
-
const child = node[key];
|
|
311
|
-
const childNode = child && 'object' == typeof child ? child : void 0;
|
|
312
|
-
const isLeaf = 'number' == typeof childNode?.size;
|
|
313
|
-
const sizeInKB = isLeaf ? ` (${getFileSize(childNode?.size ?? 0)})` : '';
|
|
314
|
-
output += `${pintor.gray(prefix)}${pintor.gray(connector)} ${key}${pintor.gray(sizeInKB)}\n`;
|
|
315
|
-
if (childNode && !isLeaf) output += printTree(childNode, `${prefix}${isLast ? ' ' : pintor.gray('│ ')}`);
|
|
316
|
-
});
|
|
317
|
-
return output;
|
|
318
|
-
}
|
|
319
|
-
function getAssetsTree(assets) {
|
|
320
|
-
const assetTree = {};
|
|
321
|
-
assets?.forEach((asset)=>{
|
|
322
|
-
if ('string' != typeof asset?.name) return;
|
|
323
|
-
const paths = asset.name.split('/');
|
|
324
|
-
let currentLevel = assetTree;
|
|
325
|
-
paths.forEach((part, index)=>{
|
|
326
|
-
if (!currentLevel[part]) currentLevel[part] = {};
|
|
327
|
-
if (index === paths.length - 1) currentLevel[part] = {
|
|
328
|
-
size: asset.size
|
|
329
|
-
};
|
|
330
|
-
else currentLevel = currentLevel[part];
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
if (0 === Object.keys(assetTree).length) return '';
|
|
334
|
-
return `.\n${printTree(assetTree)}`;
|
|
335
|
-
}
|
|
336
|
-
function formatWarningLabelLine(label, value) {
|
|
337
|
-
return `${pintor.gray('│')} ${pintor.gray(`${label}:`)} ${value}`;
|
|
338
|
-
}
|
|
339
|
-
function parsePerformanceWarning(warning, source, _artifact) {
|
|
340
|
-
const normalized = getWarningBody(warning).replace(/\r/g, '');
|
|
341
|
-
const lower = normalized.toLowerCase();
|
|
342
|
-
const threshold = normalized.match(/\(([\d.]+\s(?:KiB|MiB|GiB|KB|MB|GB))\)/)?.[1] || '';
|
|
343
|
-
if (lower.includes('asset size limit')) return formatPerformanceWarningBlock({
|
|
344
|
-
title: 'asset size limit exceeded',
|
|
345
|
-
threshold,
|
|
346
|
-
impact: 'Large emitted files can increase package size and slow extension startup.',
|
|
347
|
-
source,
|
|
348
|
-
hint: 'Inspect the largest startup bundles and split optional code paths.'
|
|
349
|
-
});
|
|
350
|
-
if (lower.includes('entrypoint size limit')) return formatPerformanceWarningBlock({
|
|
351
|
-
title: 'entrypoint size limit exceeded',
|
|
352
|
-
threshold,
|
|
353
|
-
impact: 'Startup entrypoints are heavier than recommended.',
|
|
354
|
-
source,
|
|
355
|
-
hint: 'Keep startup entrypoints thin and defer non-critical code.'
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
function formatPerformanceWarningBlock(options) {
|
|
359
|
-
const lines = [
|
|
360
|
-
`${getLoggingPrefix('warn')} Performance: ${options.title}`
|
|
361
|
-
];
|
|
362
|
-
if (options.threshold) lines.push(formatWarningLabelLine('Threshold', options.threshold));
|
|
363
|
-
lines.push(formatWarningLabelLine('Impact', options.impact));
|
|
364
|
-
lines.push(pintor.gray('│'));
|
|
365
|
-
lines.push(formatWarningLabelLine('Source', pintor.gray(options.source)));
|
|
366
|
-
lines.push(formatWarningLabelLine('Hint', options.hint));
|
|
367
|
-
return lines.join('\n');
|
|
368
|
-
}
|
|
369
|
-
function getWarningBody(warning) {
|
|
370
|
-
if (!warning) return '';
|
|
371
|
-
if ('string' == typeof warning) return warning;
|
|
372
|
-
return [
|
|
373
|
-
warning.message,
|
|
374
|
-
warning.details,
|
|
375
|
-
warning.reason,
|
|
376
|
-
warning.description
|
|
377
|
-
].filter((value)=>'string' == typeof value && value.trim().length > 0).join('\n');
|
|
378
|
-
}
|
|
379
|
-
function isUsingExperimentalConfig(integration) {
|
|
380
|
-
return `${messaging_prefix('debug')} config using=${String(integration)}`;
|
|
381
|
-
}
|
|
382
|
-
function debugDirs(manifestDir, packageJsonDir) {
|
|
383
|
-
return `${messaging_prefix('debug')} dirs manifest=${manifestDir} pkg=${packageJsonDir}`;
|
|
384
|
-
}
|
|
385
|
-
function debugBrowser(browser, chromiumBinary, geckoBinary) {
|
|
386
|
-
return `${messaging_prefix('debug')} browser target=${String(browser)} chromiumBinary=${String(chromiumBinary || 'auto')} geckoBinary=${String(geckoBinary || 'auto')}`;
|
|
387
|
-
}
|
|
388
|
-
function debugOutputPath(pathValue) {
|
|
389
|
-
return `${messaging_prefix('debug')} output path=${pathValue}`;
|
|
390
|
-
}
|
|
391
|
-
function debugPreviewOutput(outputPath, distPath) {
|
|
392
|
-
return `${messaging_prefix('debug')} preview output=${outputPath} dist=${distPath}`;
|
|
393
|
-
}
|
|
394
|
-
function debugContextPath(packageJsonDir) {
|
|
395
|
-
return `${messaging_prefix('debug')} context path=${packageJsonDir}`;
|
|
396
|
-
}
|
|
397
|
-
function debugExtensionsToLoad(extensions) {
|
|
398
|
-
return `${messaging_prefix('debug')} extensions count=${extensions.length} paths=${extensions.join(',')}`;
|
|
399
|
-
}
|
|
400
|
-
function noCompanionExtensionsResolved() {
|
|
401
|
-
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.`;
|
|
402
|
-
}
|
|
403
|
-
function configLoadingError(configPath, error) {
|
|
404
|
-
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.`;
|
|
405
|
-
}
|
|
406
|
-
function buildCommandFailed(error) {
|
|
407
|
-
const message = (()=>{
|
|
408
|
-
if (error instanceof Error && error.message) return error.message;
|
|
409
|
-
return String(error || 'Unknown error');
|
|
410
|
-
})();
|
|
411
|
-
if (message.includes(getLoggingPrefix('error'))) return message;
|
|
412
|
-
return `${getLoggingPrefix('error')} ${pintor.red(fmt.truncate(message, 1200))}`;
|
|
413
|
-
}
|
|
414
|
-
function devCommandFailed(error) {
|
|
415
|
-
const message = (()=>{
|
|
416
|
-
if (error instanceof Error && error.message) return error.message;
|
|
417
|
-
return String(error || 'Unknown error');
|
|
418
|
-
})();
|
|
419
|
-
return `${getLoggingPrefix('error')} Dev mode failed.\n${pintor.red(fmt.truncate(message, 1200))}`;
|
|
420
|
-
}
|
|
421
|
-
function managedDependencyConflict(duplicates, userPackageJsonPath) {
|
|
422
|
-
const list = duplicates.map((d)=>`- ${pintor.yellow(d)}`).join('\n');
|
|
423
|
-
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.`;
|
|
424
|
-
}
|
|
425
62
|
const preloadedEnvKeys = new Set();
|
|
426
63
|
function getPreloadedEnvKeys() {
|
|
427
64
|
return preloadedEnvKeys;
|
|
428
65
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
+
}
|
|
433
78
|
}
|
|
434
79
|
function loadCommonJsConfigWithStableDirname(absolutePath) {
|
|
435
80
|
const code = __rspack_external_node_fs_5ea92f0c.readFileSync(absolutePath, 'utf-8');
|
|
@@ -455,51 +100,46 @@ function findNearestWorkspaceRoot(startDir) {
|
|
|
455
100
|
current = parent;
|
|
456
101
|
}
|
|
457
102
|
}
|
|
458
|
-
function preloadEnvFilesFromDir(envDir
|
|
103
|
+
function preloadEnvFilesFromDir(envDir) {
|
|
459
104
|
let loadedAny = false;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
path: defaultsPath,
|
|
466
|
-
override: Boolean(options?.override),
|
|
467
|
-
quiet: true
|
|
468
|
-
});
|
|
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);
|
|
469
110
|
loadedAny = true;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
'.env.development',
|
|
473
|
-
'.env.local',
|
|
474
|
-
'.env'
|
|
475
|
-
];
|
|
476
|
-
for (const filename of envCandidates){
|
|
477
|
-
const filePath = __rspack_external_node_path_c5b9b54f.join(envDir, filename);
|
|
478
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(filePath)) {
|
|
479
|
-
recordPreloadedKeys(filePath);
|
|
480
|
-
dotenv.config({
|
|
481
|
-
path: filePath,
|
|
482
|
-
override: Boolean(options?.override),
|
|
483
|
-
quiet: true
|
|
484
|
-
});
|
|
485
|
-
loadedAny = true;
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
} catch {}
|
|
111
|
+
} catch {}
|
|
112
|
+
}
|
|
490
113
|
return {
|
|
491
114
|
loadedAny,
|
|
492
115
|
envDir
|
|
493
116
|
};
|
|
494
117
|
}
|
|
495
|
-
function
|
|
118
|
+
function findConfigFileIn(dir) {
|
|
496
119
|
const candidates = [
|
|
497
|
-
__rspack_external_node_path_c5b9b54f.join(
|
|
498
|
-
__rspack_external_node_path_c5b9b54f.join(
|
|
499
|
-
__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')
|
|
500
123
|
];
|
|
501
124
|
return candidates.find((p)=>__rspack_external_node_fs_5ea92f0c.existsSync(p));
|
|
502
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
|
+
}
|
|
503
143
|
function preloadEnvFiles(projectDir) {
|
|
504
144
|
const local = preloadEnvFilesFromDir(projectDir);
|
|
505
145
|
if (local.loadedAny) return local;
|
|
@@ -602,7 +242,7 @@ async function loadConfigFileUncached(absolutePath) {
|
|
|
602
242
|
async function loadCustomConfig(projectPath) {
|
|
603
243
|
const configPath = findConfigFile(projectPath);
|
|
604
244
|
if (configPath) {
|
|
605
|
-
if (await
|
|
245
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
606
246
|
const userConfig = await loadConfigFile(configPath);
|
|
607
247
|
if (userConfig && 'function' == typeof userConfig.config) return userConfig.config;
|
|
608
248
|
if (userConfig?.config && 'object' == typeof userConfig.config) {
|
|
@@ -621,27 +261,21 @@ async function loadCustomConfig(projectPath) {
|
|
|
621
261
|
}
|
|
622
262
|
return (config)=>config;
|
|
623
263
|
}
|
|
624
|
-
async function
|
|
264
|
+
async function loadProjectConfigDefaults(projectPath) {
|
|
625
265
|
const configPath = findConfigFile(projectPath);
|
|
626
266
|
if (configPath) {
|
|
627
|
-
if (await
|
|
267
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
628
268
|
const userConfig = await loadConfigFile(configPath);
|
|
629
|
-
const configExtras = userConfig;
|
|
630
|
-
const baseExtensions = configExtras && configExtras.extensions ? {
|
|
631
|
-
extensions: configExtras.extensions
|
|
632
|
-
} : {};
|
|
633
|
-
const baseTranspilePackages = configExtras && Array.isArray(configExtras.transpilePackages) ? {
|
|
634
|
-
transpilePackages: configExtras.transpilePackages
|
|
635
|
-
} : {};
|
|
636
|
-
const basePerfBudgets = configExtras && configExtras.perfBudgets && 'object' == typeof configExtras.perfBudgets ? {
|
|
637
|
-
perfBudgets: configExtras.perfBudgets
|
|
638
|
-
} : {};
|
|
639
|
-
const perCommand = userConfig?.commands?.[command] ? userConfig.commands[command] : {};
|
|
640
269
|
return {
|
|
641
|
-
...
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
...
|
|
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
|
+
} : {}
|
|
645
279
|
};
|
|
646
280
|
} catch (err) {
|
|
647
281
|
const error = err;
|
|
@@ -651,10 +285,24 @@ async function loadCommandConfig(projectPath, command) {
|
|
|
651
285
|
}
|
|
652
286
|
return {};
|
|
653
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
|
+
}
|
|
654
302
|
async function loadBrowserConfig(projectPath, browser = 'chrome') {
|
|
655
303
|
const configPath = findConfigFile(projectPath);
|
|
656
304
|
if (configPath) {
|
|
657
|
-
if (await
|
|
305
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
658
306
|
const userConfig = await loadConfigFile(configPath);
|
|
659
307
|
if (userConfig?.browser) {
|
|
660
308
|
const browsers = userConfig.browser;
|
|
@@ -688,142 +336,18 @@ async function loadBrowserConfig(projectPath, browser = 'chrome') {
|
|
|
688
336
|
};
|
|
689
337
|
}
|
|
690
338
|
let userMessageDelivered = false;
|
|
691
|
-
async function
|
|
339
|
+
async function isUsingExperimentalConfig(projectPath) {
|
|
692
340
|
const configPath = findConfigFile(projectPath);
|
|
693
341
|
if (configPath) {
|
|
694
342
|
if (!userMessageDelivered) {
|
|
695
|
-
if (isDebug()) console.log(
|
|
343
|
+
if (isDebug()) console.log(messages_isUsingExperimentalConfig('extension.config.js'));
|
|
696
344
|
userMessageDelivered = true;
|
|
697
345
|
}
|
|
698
346
|
return true;
|
|
699
347
|
}
|
|
700
348
|
return false;
|
|
701
349
|
}
|
|
702
|
-
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.
|
|
703
|
-
function asAbsolute(p) {
|
|
704
|
-
return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
|
|
705
|
-
}
|
|
706
|
-
function toPosixPath(p) {
|
|
707
|
-
return p.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
708
|
-
}
|
|
709
|
-
function getDirs(struct) {
|
|
710
|
-
const manifestDir = asAbsolute(__rspack_external_node_path_c5b9b54f.dirname(struct.manifestPath));
|
|
711
|
-
const projectManifestPath = struct.packageJsonPath || struct.denoJsonPath;
|
|
712
|
-
const packageJsonDir = asAbsolute(projectManifestPath ? __rspack_external_node_path_c5b9b54f.dirname(projectManifestPath) : manifestDir);
|
|
713
|
-
return {
|
|
714
|
-
manifestDir,
|
|
715
|
-
packageJsonDir
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
function getNodeModulesDir(packageJsonDir) {
|
|
719
|
-
return asAbsolute(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'node_modules'));
|
|
720
|
-
}
|
|
721
|
-
function needsInstall(packageJsonDir) {
|
|
722
|
-
const nm = getNodeModulesDir(packageJsonDir);
|
|
723
|
-
const hasManifest = PROJECT_MANIFEST_FILENAMES.some((filename)=>__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, filename)));
|
|
724
|
-
if (!hasManifest) return false;
|
|
725
|
-
try {
|
|
726
|
-
const deps = Object.keys(readProjectDependencies(packageJsonDir));
|
|
727
|
-
if (0 === deps.length) return false;
|
|
728
|
-
if (!__rspack_external_node_fs_5ea92f0c.existsSync(nm)) return true;
|
|
729
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.pnpm'))) return false;
|
|
730
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.modules.yaml'))) return false;
|
|
731
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.deno'))) return false;
|
|
732
|
-
const hasInstalledDep = deps.some((dep)=>__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, dep)));
|
|
733
|
-
return !hasInstalledDep;
|
|
734
|
-
} catch {
|
|
735
|
-
return true;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
function normalizeBrowser(browser, chromiumBinary, geckoBinary, safariBinary) {
|
|
739
|
-
const requested = String(browser || '');
|
|
740
|
-
if (chromiumBinary) {
|
|
741
|
-
if (!requested || 'chromium-based' === requested) return 'chromium-based';
|
|
742
|
-
if ('chromium' === requested) return 'chromium';
|
|
743
|
-
if ('edge' === requested) return 'edge';
|
|
744
|
-
if ('chrome' === requested) return 'chrome';
|
|
745
|
-
}
|
|
746
|
-
if (geckoBinary) {
|
|
747
|
-
if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
|
|
748
|
-
if ('firefox' === requested) return 'firefox';
|
|
749
|
-
}
|
|
750
|
-
if (safariBinary) {
|
|
751
|
-
if (!requested || 'webkit-based' === requested) return 'webkit-based';
|
|
752
|
-
if ('safari' === requested) return 'safari';
|
|
753
|
-
}
|
|
754
|
-
switch(requested){
|
|
755
|
-
case 'chrome':
|
|
756
|
-
return 'chrome';
|
|
757
|
-
case 'edge':
|
|
758
|
-
return 'edge';
|
|
759
|
-
case 'chromium':
|
|
760
|
-
return 'chromium';
|
|
761
|
-
case 'brave':
|
|
762
|
-
return 'brave';
|
|
763
|
-
case 'opera':
|
|
764
|
-
return 'opera';
|
|
765
|
-
case 'vivaldi':
|
|
766
|
-
return 'vivaldi';
|
|
767
|
-
case 'yandex':
|
|
768
|
-
return 'yandex';
|
|
769
|
-
case 'chromium-based':
|
|
770
|
-
return 'chromium-based';
|
|
771
|
-
case 'firefox':
|
|
772
|
-
return 'firefox';
|
|
773
|
-
case 'waterfox':
|
|
774
|
-
return 'waterfox';
|
|
775
|
-
case 'librewolf':
|
|
776
|
-
return 'librewolf';
|
|
777
|
-
case 'gecko-based':
|
|
778
|
-
case 'firefox-based':
|
|
779
|
-
return 'gecko-based';
|
|
780
|
-
case 'safari':
|
|
781
|
-
return 'safari';
|
|
782
|
-
case 'webkit-based':
|
|
783
|
-
return 'webkit-based';
|
|
784
|
-
default:
|
|
785
|
-
return 'chrome';
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function getDistPath(packageJsonDir, browser) {
|
|
789
|
-
return asAbsolute(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist', browser));
|
|
790
|
-
}
|
|
791
|
-
function computePreviewOutputPath(struct, browser, explicitOutputPath) {
|
|
792
|
-
const { manifestDir, packageJsonDir } = getDirs(struct);
|
|
793
|
-
if (explicitOutputPath) return asAbsolute(explicitOutputPath);
|
|
794
|
-
if (struct.packageJsonPath || struct.denoJsonPath) {
|
|
795
|
-
const distDir = getDistPath(packageJsonDir, browser);
|
|
796
|
-
try {
|
|
797
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(distDir, 'manifest.json'))) return distDir;
|
|
798
|
-
} catch {}
|
|
799
|
-
}
|
|
800
|
-
return manifestDir;
|
|
801
|
-
}
|
|
802
|
-
function devtoolsEngineFor(browser) {
|
|
803
|
-
switch(browser){
|
|
804
|
-
case 'chrome':
|
|
805
|
-
return 'chrome';
|
|
806
|
-
case 'edge':
|
|
807
|
-
return 'edge';
|
|
808
|
-
case 'chromium':
|
|
809
|
-
case 'chromium-based':
|
|
810
|
-
case 'brave':
|
|
811
|
-
case 'opera':
|
|
812
|
-
case 'vivaldi':
|
|
813
|
-
case 'yandex':
|
|
814
|
-
return 'chromium';
|
|
815
|
-
case 'firefox':
|
|
816
|
-
case 'gecko-based':
|
|
817
|
-
case 'waterfox':
|
|
818
|
-
case 'librewolf':
|
|
819
|
-
return 'firefox';
|
|
820
|
-
case 'safari':
|
|
821
|
-
case 'webkit-based':
|
|
822
|
-
return 'safari';
|
|
823
|
-
default:
|
|
824
|
-
return 'chrome';
|
|
825
|
-
}
|
|
826
|
-
}
|
|
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"}}');
|
|
827
351
|
function sanitize(obj) {
|
|
828
352
|
return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
|
|
829
353
|
}
|
|
@@ -912,315 +436,6 @@ function mergeOptionLayers(defaults, ...layers) {
|
|
|
912
436
|
for (const layer of layers)result = mergeLayer(result, layer || {});
|
|
913
437
|
return result;
|
|
914
438
|
}
|
|
915
|
-
async function findUpLocal(filename, options) {
|
|
916
|
-
const root = __rspack_external_node_path_c5b9b54f.parse(options.cwd).root;
|
|
917
|
-
let currentDir = options.cwd;
|
|
918
|
-
while(true){
|
|
919
|
-
const candidate = __rspack_external_node_path_c5b9b54f.join(currentDir, filename);
|
|
920
|
-
try {
|
|
921
|
-
const stat = await __rspack_external_node_fs_5ea92f0c.promises.stat(candidate);
|
|
922
|
-
if (stat.isFile()) return candidate;
|
|
923
|
-
} catch {}
|
|
924
|
-
if (currentDir === root) return;
|
|
925
|
-
currentDir = __rspack_external_node_path_c5b9b54f.dirname(currentDir);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
async function findNearestPackageJson(manifestPath) {
|
|
929
|
-
try {
|
|
930
|
-
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
931
|
-
const packageJsonPath = await findUpLocal('package.json', {
|
|
932
|
-
cwd: manifestDir
|
|
933
|
-
});
|
|
934
|
-
return packageJsonPath || null;
|
|
935
|
-
} catch (error) {
|
|
936
|
-
console.warn('Failed to find package.json:', error);
|
|
937
|
-
return null;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
function validatePackageJson(packageJsonPath) {
|
|
941
|
-
try {
|
|
942
|
-
if (!__rspack_external_node_fs_5ea92f0c.existsSync(packageJsonPath)) return false;
|
|
943
|
-
const content = __rspack_external_node_fs_5ea92f0c.readFileSync(packageJsonPath, 'utf-8');
|
|
944
|
-
JSON.parse(content);
|
|
945
|
-
return true;
|
|
946
|
-
} catch (error) {
|
|
947
|
-
console.warn('Invalid package.json at:', packageJsonPath, error);
|
|
948
|
-
return false;
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
const isUrl = (url)=>{
|
|
952
|
-
try {
|
|
953
|
-
new URL(url);
|
|
954
|
-
return true;
|
|
955
|
-
} catch (e) {
|
|
956
|
-
return false;
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
const REMOTE_FETCH_TIMEOUT_MS = (()=>{
|
|
960
|
-
const raw = parseInt(String(process.env.EXTENSION_FETCH_TIMEOUT_MS || ''), 10);
|
|
961
|
-
return Number.isFinite(raw) && raw > 0 ? raw : 60000;
|
|
962
|
-
})();
|
|
963
|
-
function withTimeout(task, ms, label) {
|
|
964
|
-
let timer;
|
|
965
|
-
const timeout = new Promise((_, reject)=>{
|
|
966
|
-
timer = setTimeout(()=>reject(new Error(remoteFetchTimedOut(label, ms))), ms);
|
|
967
|
-
});
|
|
968
|
-
return Promise.race([
|
|
969
|
-
task,
|
|
970
|
-
timeout
|
|
971
|
-
]).finally(()=>{
|
|
972
|
-
if (timer) clearTimeout(timer);
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
|
|
976
|
-
const cwd = process.cwd();
|
|
977
|
-
const url = new URL(pathOrRemoteUrl);
|
|
978
|
-
const segments = url.pathname.split('/').filter(Boolean);
|
|
979
|
-
const repoName = segments.length >= 2 ? segments[1] : segments[segments.length - 1];
|
|
980
|
-
const treeIndex = segments.indexOf('tree');
|
|
981
|
-
const expectedName = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments[segments.length - 1] : repoName;
|
|
982
|
-
const expectedPath = __rspack_external_node_path_c5b9b54f.resolve(cwd, expectedName);
|
|
983
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(expectedPath)) try {
|
|
984
|
-
const entries = __rspack_external_node_fs_5ea92f0c.readdirSync(expectedPath);
|
|
985
|
-
if (0 === entries.length) __rspack_external_node_fs_5ea92f0c.rmSync(expectedPath, {
|
|
986
|
-
recursive: true,
|
|
987
|
-
force: true
|
|
988
|
-
});
|
|
989
|
-
else {
|
|
990
|
-
const hasManifest = (dir)=>{
|
|
991
|
-
const stack = [
|
|
992
|
-
dir
|
|
993
|
-
];
|
|
994
|
-
while(stack.length){
|
|
995
|
-
const current = stack.pop();
|
|
996
|
-
const items = __rspack_external_node_fs_5ea92f0c.readdirSync(current, {
|
|
997
|
-
withFileTypes: true
|
|
998
|
-
});
|
|
999
|
-
for (const it of items){
|
|
1000
|
-
if (it.isFile() && 'manifest.json' === it.name) return true;
|
|
1001
|
-
if (it.isDirectory() && 'node_modules' !== it.name && 'dist' !== it.name && !it.name.startsWith('.')) stack.push(__rspack_external_node_path_c5b9b54f.join(current, it.name));
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return false;
|
|
1005
|
-
};
|
|
1006
|
-
if (hasManifest(expectedPath)) return expectedPath;
|
|
1007
|
-
__rspack_external_node_fs_5ea92f0c.rmSync(expectedPath, {
|
|
1008
|
-
recursive: true,
|
|
1009
|
-
force: true
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
} catch {}
|
|
1013
|
-
async function tryGitClone() {
|
|
1014
|
-
const { default: goGitIt } = await import("go-git-it");
|
|
1015
|
-
await withTimeout(goGitIt(pathOrRemoteUrl, cwd, text), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
|
|
1016
|
-
}
|
|
1017
|
-
async function tryZipFallback() {
|
|
1018
|
-
const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
|
|
1019
|
-
const owner = segments[0];
|
|
1020
|
-
const repo = segments[1];
|
|
1021
|
-
const subdir = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments.slice(treeIndex + 2).join('/') : '';
|
|
1022
|
-
const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${branch}`;
|
|
1023
|
-
const extractedPath = await importUrlSourceFromZip(zipUrl);
|
|
1024
|
-
const extractedDirs = __rspack_external_node_fs_5ea92f0c.readdirSync(extractedPath, {
|
|
1025
|
-
withFileTypes: true
|
|
1026
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1027
|
-
const repoRootDir = extractedDirs.find((d)=>d.startsWith(`${repo}-${branch}`));
|
|
1028
|
-
const repoRoot = repoRootDir ? __rspack_external_node_path_c5b9b54f.join(extractedPath, repoRootDir) : extractedPath;
|
|
1029
|
-
return subdir ? __rspack_external_node_path_c5b9b54f.join(repoRoot, subdir) : repoRoot;
|
|
1030
|
-
}
|
|
1031
|
-
try {
|
|
1032
|
-
await tryGitClone();
|
|
1033
|
-
} catch {
|
|
1034
|
-
return await tryZipFallback();
|
|
1035
|
-
}
|
|
1036
|
-
const candidates = [];
|
|
1037
|
-
if (-1 !== treeIndex && segments.length > treeIndex + 2) candidates.push(segments[segments.length - 1]);
|
|
1038
|
-
candidates.push(repoName);
|
|
1039
|
-
for (const name of candidates){
|
|
1040
|
-
const p = __rspack_external_node_path_c5b9b54f.resolve(cwd, name);
|
|
1041
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(p)) return p;
|
|
1042
|
-
}
|
|
1043
|
-
const dirs = __rspack_external_node_fs_5ea92f0c.readdirSync(cwd, {
|
|
1044
|
-
withFileTypes: true
|
|
1045
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1046
|
-
for (const dir of dirs){
|
|
1047
|
-
const manifestPath = __rspack_external_node_path_c5b9b54f.join(cwd, dir, 'manifest.json');
|
|
1048
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) return __rspack_external_node_path_c5b9b54f.join(cwd, dir);
|
|
1049
|
-
}
|
|
1050
|
-
try {
|
|
1051
|
-
const dirs = __rspack_external_node_fs_5ea92f0c.readdirSync(cwd, {
|
|
1052
|
-
withFileTypes: true
|
|
1053
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
1054
|
-
const ghRoot = dirs.find((d)=>/-main$|-master$/.test(d));
|
|
1055
|
-
if (ghRoot) return __rspack_external_node_path_c5b9b54f.join(cwd, ghRoot);
|
|
1056
|
-
} catch {}
|
|
1057
|
-
throw new Error(downloadedProjectFolderNotFound(cwd, candidates));
|
|
1058
|
-
}
|
|
1059
|
-
async function importUrlSourceFromZip(pathOrRemoteUrl) {
|
|
1060
|
-
const cwd = process.cwd();
|
|
1061
|
-
const { downloadAndExtractZip } = await import("./0~zip.mjs");
|
|
1062
|
-
const extractedPath = await withTimeout(downloadAndExtractZip(pathOrRemoteUrl, cwd), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
|
|
1063
|
-
return extractedPath;
|
|
1064
|
-
}
|
|
1065
|
-
async function importLocalSourceFromZip(zipFilePath) {
|
|
1066
|
-
const cwd = process.cwd();
|
|
1067
|
-
const { extractLocalZip } = await import("./0~zip.mjs");
|
|
1068
|
-
return await extractLocalZip(zipFilePath, cwd);
|
|
1069
|
-
}
|
|
1070
|
-
async function getProjectPath(pathOrRemoteUrl) {
|
|
1071
|
-
if (!pathOrRemoteUrl) return process.cwd();
|
|
1072
|
-
if (isUrl(pathOrRemoteUrl)) {
|
|
1073
|
-
const url = new URL(pathOrRemoteUrl);
|
|
1074
|
-
if (url.protocol.startsWith('http')) {
|
|
1075
|
-
const pathname = url.pathname.toLowerCase();
|
|
1076
|
-
if (pathname.endsWith('.zip')) return await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
1077
|
-
if ('https://github.com' !== url.origin) {
|
|
1078
|
-
const urlSource = await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
1079
|
-
return urlSource;
|
|
1080
|
-
}
|
|
1081
|
-
const urlData = url.pathname.split('/');
|
|
1082
|
-
const owner = urlData.slice(1, 3)[0];
|
|
1083
|
-
const project = urlData.slice(1, 3)[1];
|
|
1084
|
-
console.log(fetchingProjectPath(owner, project));
|
|
1085
|
-
const projectName = __rspack_external_node_path_c5b9b54f.basename(url.pathname);
|
|
1086
|
-
const urlSource = await importUrlSourceFromGithub(pathOrRemoteUrl, downloadingProjectPath(projectName));
|
|
1087
|
-
console.log(creatingProjectPath(url.pathname));
|
|
1088
|
-
return urlSource;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
const resolvedPath = __rspack_external_node_path_c5b9b54f.resolve(process.cwd(), pathOrRemoteUrl);
|
|
1092
|
-
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);
|
|
1093
|
-
return resolvedPath;
|
|
1094
|
-
}
|
|
1095
|
-
function collectManifestCandidates(rootDir, maxDepth) {
|
|
1096
|
-
const SKIP_DIRS = new Set([
|
|
1097
|
-
'node_modules',
|
|
1098
|
-
'dist',
|
|
1099
|
-
'build',
|
|
1100
|
-
'out',
|
|
1101
|
-
'.git',
|
|
1102
|
-
'.turbo',
|
|
1103
|
-
'.next',
|
|
1104
|
-
'coverage',
|
|
1105
|
-
'.cache',
|
|
1106
|
-
'.vercel'
|
|
1107
|
-
]);
|
|
1108
|
-
const results = [];
|
|
1109
|
-
const walk = (dir, depth)=>{
|
|
1110
|
-
if (depth > maxDepth || results.length >= 10) return;
|
|
1111
|
-
let entries;
|
|
1112
|
-
try {
|
|
1113
|
-
entries = __rspack_external_node_fs_5ea92f0c.readdirSync(dir, {
|
|
1114
|
-
withFileTypes: true
|
|
1115
|
-
});
|
|
1116
|
-
} catch {
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1119
|
-
for (const entry of entries){
|
|
1120
|
-
if (entry.isFile() && 'manifest.json' === entry.name) {
|
|
1121
|
-
results.push(__rspack_external_node_path_c5b9b54f.join(dir, entry.name));
|
|
1122
|
-
continue;
|
|
1123
|
-
}
|
|
1124
|
-
if (entry.isDirectory() && !entry.name.startsWith('.') && !SKIP_DIRS.has(entry.name)) walk(__rspack_external_node_path_c5b9b54f.join(dir, entry.name), depth + 1);
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
walk(rootDir, 0);
|
|
1128
|
-
return results;
|
|
1129
|
-
}
|
|
1130
|
-
async function getProjectStructure(pathOrRemoteUrl) {
|
|
1131
|
-
const projectPath = await getProjectPath(pathOrRemoteUrl);
|
|
1132
|
-
const isUnderDir = (baseDir, candidatePath)=>{
|
|
1133
|
-
const rel = __rspack_external_node_path_c5b9b54f.relative(baseDir, candidatePath);
|
|
1134
|
-
return Boolean(rel && !rel.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(rel));
|
|
1135
|
-
};
|
|
1136
|
-
const packageJsonPathFromProject = await findNearestPackageJson(__rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json'));
|
|
1137
|
-
const denoJsonPathFromProject = findNearestDenoConfigSync(__rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json'));
|
|
1138
|
-
const packageJsonDirFromProject = packageJsonPathFromProject ? __rspack_external_node_path_c5b9b54f.dirname(packageJsonPathFromProject) : denoJsonPathFromProject ? __rspack_external_node_path_c5b9b54f.dirname(denoJsonPathFromProject) : void 0;
|
|
1139
|
-
const rootManifestPath = __rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json');
|
|
1140
|
-
const srcManifestPath = __rspack_external_node_path_c5b9b54f.join(projectPath, 'src', 'manifest.json');
|
|
1141
|
-
let manifestPath = __rspack_external_node_fs_5ea92f0c.existsSync(srcManifestPath) ? srcManifestPath : rootManifestPath;
|
|
1142
|
-
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) if (packageJsonDirFromProject) {
|
|
1143
|
-
const absoluteCandidates = collectManifestCandidates(projectPath, 3);
|
|
1144
|
-
const relativeCandidates = absoluteCandidates.map((candidate)=>__rspack_external_node_path_c5b9b54f.relative(projectPath, candidate) || candidate);
|
|
1145
|
-
if (1 === absoluteCandidates.length) {
|
|
1146
|
-
manifestPath = absoluteCandidates[0];
|
|
1147
|
-
console.log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
1148
|
-
} else throw new Error(manifestNotFoundError(manifestPath, relativeCandidates));
|
|
1149
|
-
} else {
|
|
1150
|
-
const MAX_DEPTH = 5;
|
|
1151
|
-
const findManifest = (dir, depth)=>{
|
|
1152
|
-
if (depth > MAX_DEPTH) return null;
|
|
1153
|
-
let files;
|
|
1154
|
-
try {
|
|
1155
|
-
files = __rspack_external_node_fs_5ea92f0c.readdirSync(dir, {
|
|
1156
|
-
withFileTypes: true
|
|
1157
|
-
});
|
|
1158
|
-
} catch {
|
|
1159
|
-
return null;
|
|
1160
|
-
}
|
|
1161
|
-
for (const file of files){
|
|
1162
|
-
if (file.isFile() && 'manifest.json' === file.name) return __rspack_external_node_path_c5b9b54f.join(dir, file.name);
|
|
1163
|
-
if (file.isDirectory() && !file.name.startsWith('.') && 'node_modules' !== file.name && 'dist' !== file.name && 'public' !== file.name) {
|
|
1164
|
-
const found = findManifest(__rspack_external_node_path_c5b9b54f.join(dir, file.name), depth + 1);
|
|
1165
|
-
if (found) return found;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
return null;
|
|
1169
|
-
};
|
|
1170
|
-
const foundManifest = findManifest(projectPath, 0);
|
|
1171
|
-
if (foundManifest) manifestPath = foundManifest;
|
|
1172
|
-
else throw new Error(manifestNotFoundError(manifestPath));
|
|
1173
|
-
}
|
|
1174
|
-
const readManifestObject = (candidatePath)=>{
|
|
1175
|
-
try {
|
|
1176
|
-
const parsed = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(candidatePath));
|
|
1177
|
-
if (null === parsed || 'object' != typeof parsed || Array.isArray(parsed)) return;
|
|
1178
|
-
return parsed;
|
|
1179
|
-
} catch {
|
|
1180
|
-
return;
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
const isPwaManifest = (candidatePath)=>{
|
|
1184
|
-
const parsed = readManifestObject(candidatePath);
|
|
1185
|
-
if (!parsed || null != parsed.manifest_version) return false;
|
|
1186
|
-
return Array.isArray(parsed.icons) || 'string' == typeof parsed.start_url || 'string' == typeof parsed.display || null != parsed.related_applications || null != parsed.prefer_related_applications;
|
|
1187
|
-
};
|
|
1188
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath) && isPwaManifest(manifestPath)) {
|
|
1189
|
-
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);
|
|
1190
|
-
if (1 === alternatives.length) {
|
|
1191
|
-
manifestPath = alternatives[0];
|
|
1192
|
-
console.log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
1193
|
-
} else throw new Error(notAnExtensionManifestError(manifestPath));
|
|
1194
|
-
}
|
|
1195
|
-
const packageJsonPath = await findNearestPackageJson(manifestPath);
|
|
1196
|
-
const packageJsonDir = packageJsonPath ? __rspack_external_node_path_c5b9b54f.dirname(packageJsonPath) : void 0;
|
|
1197
|
-
const nearestDenoJsonPath = findNearestDenoConfigSync(manifestPath);
|
|
1198
|
-
const denoJsonPath = nearestDenoJsonPath && validateDenoConfig(nearestDenoJsonPath) ? nearestDenoJsonPath : void 0;
|
|
1199
|
-
const projectRootDir = packageJsonDir ?? (denoJsonPath ? __rspack_external_node_path_c5b9b54f.dirname(denoJsonPath) : void 0);
|
|
1200
|
-
if (projectRootDir) {
|
|
1201
|
-
const publicRoot = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'public');
|
|
1202
|
-
if (isUnderDir(publicRoot, manifestPath)) {
|
|
1203
|
-
const fallbackSrc = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'src', 'manifest.json');
|
|
1204
|
-
const fallbackRoot = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'manifest.json');
|
|
1205
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(fallbackSrc)) manifestPath = fallbackSrc;
|
|
1206
|
-
else if (__rspack_external_node_fs_5ea92f0c.existsSync(fallbackRoot)) manifestPath = fallbackRoot;
|
|
1207
|
-
else throw new Error(manifestNotFoundError(fallbackRoot));
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
if (!packageJsonPath || !validatePackageJson(packageJsonPath)) return {
|
|
1211
|
-
manifestPath,
|
|
1212
|
-
...denoJsonPath ? {
|
|
1213
|
-
denoJsonPath
|
|
1214
|
-
} : {}
|
|
1215
|
-
};
|
|
1216
|
-
return {
|
|
1217
|
-
manifestPath,
|
|
1218
|
-
packageJsonPath,
|
|
1219
|
-
...denoJsonPath ? {
|
|
1220
|
-
denoJsonPath
|
|
1221
|
-
} : {}
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
439
|
function isReferencedAsModuleSpecifier(configSource, dep) {
|
|
1225
440
|
const escaped = dep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1226
441
|
const specifierRe = new RegExp(`['"\`]${escaped}(?:/[^'"\`]*)?['"\`]`);
|
|
@@ -1369,7 +584,7 @@ function readManifestProvenance(manifestPath) {
|
|
|
1369
584
|
return {};
|
|
1370
585
|
}
|
|
1371
586
|
}
|
|
1372
|
-
function
|
|
587
|
+
function ensureDirSync(dirPath) {
|
|
1373
588
|
try {
|
|
1374
589
|
__rspack_external_node_fs_5ea92f0c.mkdirSync(dirPath, {
|
|
1375
590
|
recursive: true
|
|
@@ -1460,7 +675,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
1460
675
|
};
|
|
1461
676
|
function writeReady(status, extra) {
|
|
1462
677
|
if (foreignLiveDevSession) return;
|
|
1463
|
-
|
|
678
|
+
ensureDirSync(metadataDir);
|
|
1464
679
|
let prev;
|
|
1465
680
|
try {
|
|
1466
681
|
if (__rspack_external_node_fs_5ea92f0c.existsSync(readyPath)) prev = JSON.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(readyPath, 'utf-8'));
|
|
@@ -1517,7 +732,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
1517
732
|
}
|
|
1518
733
|
function appendEvent(event) {
|
|
1519
734
|
if (foreignLiveDevSession) return;
|
|
1520
|
-
|
|
735
|
+
ensureDirSync(metadataDir);
|
|
1521
736
|
try {
|
|
1522
737
|
__rspack_external_node_fs_5ea92f0c.appendFileSync(eventsPath, `${JSON.stringify({
|
|
1523
738
|
...event,
|
|
@@ -1535,7 +750,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
1535
750
|
},
|
|
1536
751
|
writeStarting () {
|
|
1537
752
|
if (foreignLiveDevSession) return;
|
|
1538
|
-
|
|
753
|
+
ensureDirSync(metadataDir);
|
|
1539
754
|
try {
|
|
1540
755
|
__rspack_external_node_fs_5ea92f0c.writeFileSync(eventsPath, '', 'utf-8');
|
|
1541
756
|
} catch {}
|
|
@@ -1715,7 +930,23 @@ function normalizeCompanionConfig(config) {
|
|
|
1715
930
|
paths: explicitPaths
|
|
1716
931
|
};
|
|
1717
932
|
}
|
|
1718
|
-
|
|
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) {
|
|
1719
950
|
if (__rspack_external_node_path_c5b9b54f.isAbsolute(value)) return true;
|
|
1720
951
|
if (value.startsWith('./') || value.startsWith('../')) return true;
|
|
1721
952
|
return value.includes('/') || value.includes('\\');
|
|
@@ -1730,27 +961,46 @@ function getBrowserFolder(browser) {
|
|
|
1730
961
|
return 'chrome';
|
|
1731
962
|
}
|
|
1732
963
|
function parseChromeWebStoreId(url) {
|
|
1733
|
-
|
|
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;
|
|
1734
967
|
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
1735
968
|
return match ? match[1] : null;
|
|
1736
969
|
}
|
|
1737
970
|
function parseEdgeAddonsId(url) {
|
|
1738
|
-
if ('microsoftedge.microsoft.com' !== url.hostname) return null;
|
|
971
|
+
if ('microsoftedge.microsoft.com' !== stripWww(url.hostname)) return null;
|
|
1739
972
|
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
1740
973
|
return match ? match[1] : null;
|
|
1741
974
|
}
|
|
1742
975
|
function parseAmoSlug(url) {
|
|
1743
|
-
if ('addons.mozilla.org' !== url.hostname) return null;
|
|
976
|
+
if ('addons.mozilla.org' !== stripWww(url.hostname)) return null;
|
|
1744
977
|
const match = url.pathname.match(/\/addon\/([^/]+)(?:\/|$)/i);
|
|
1745
978
|
return match ? match[1] : null;
|
|
1746
979
|
}
|
|
1747
|
-
|
|
1748
|
-
|
|
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) {
|
|
1749
990
|
try {
|
|
1750
|
-
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}`);
|
|
1751
999
|
} catch {
|
|
1752
1000
|
return null;
|
|
1753
1001
|
}
|
|
1002
|
+
}
|
|
1003
|
+
function parseStoreUrl(url) {
|
|
1754
1004
|
const chromeId = parseChromeWebStoreId(url);
|
|
1755
1005
|
if (chromeId) return {
|
|
1756
1006
|
browser: 'chrome',
|
|
@@ -1840,19 +1090,26 @@ async function resolveCompanionExtensionsConfig(opts) {
|
|
|
1840
1090
|
const resolvedPaths = [];
|
|
1841
1091
|
const localPaths = [];
|
|
1842
1092
|
for (const entry of normalized.paths){
|
|
1843
|
-
const
|
|
1844
|
-
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>`);
|
|
1845
1097
|
if (parsedStore.browser !== runtimeBrowser) continue;
|
|
1846
1098
|
const resolvedPath = await resolveStoreExtensionToPath({
|
|
1847
1099
|
projectRoot,
|
|
1848
|
-
storeUrl:
|
|
1100
|
+
storeUrl: url.href,
|
|
1849
1101
|
browser: parsedStore.browser,
|
|
1850
1102
|
id: parsedStore.id
|
|
1851
1103
|
});
|
|
1852
1104
|
resolvedPaths.push(resolvedPath);
|
|
1853
1105
|
continue;
|
|
1854
1106
|
}
|
|
1855
|
-
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`);
|
|
1856
1113
|
}
|
|
1857
1114
|
if (localPaths.length > 0) {
|
|
1858
1115
|
const absLocalPaths = ensurePathsUnderExtensions(projectRoot, localPaths);
|
|
@@ -1871,6 +1128,15 @@ async function resolveCompanionExtensionsConfig(opts) {
|
|
|
1871
1128
|
function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
|
|
1872
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.`;
|
|
1873
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
|
+
}
|
|
1874
1140
|
function specialFoldersSetupSummary(hasPublic, copyEnabled, ignoredCount) {
|
|
1875
1141
|
return `${messaging_prefix('debug')} folders setup public=${String(hasPublic)} copy=${String(copyEnabled)} ignored=${String(ignoredCount)}`;
|
|
1876
1142
|
}
|
|
@@ -2233,14 +1499,14 @@ function withDarkMode(config) {
|
|
|
2233
1499
|
};
|
|
2234
1500
|
}
|
|
2235
1501
|
const cjsRequire = createRequire(import.meta.url);
|
|
2236
|
-
function
|
|
1502
|
+
function getLoggingPrefix(type) {
|
|
2237
1503
|
return messaging_prefix(type);
|
|
2238
1504
|
}
|
|
2239
1505
|
function messages_ready(mode, browser) {
|
|
2240
1506
|
const noun = artifactNoun(browser);
|
|
2241
1507
|
const state = pintor.green(`ready for ${mode}`);
|
|
2242
1508
|
const watching = 'development' === mode ? ' Watching for file changes.' : '';
|
|
2243
|
-
return `${
|
|
1509
|
+
return `${getLoggingPrefix('success')} ${noun} ${state}.${watching}`;
|
|
2244
1510
|
}
|
|
2245
1511
|
function readJsonRecord(filePath) {
|
|
2246
1512
|
try {
|
|
@@ -2311,37 +1577,46 @@ function shouldWarnPortConflict(requested, actual) {
|
|
|
2311
1577
|
return Number.isFinite(requestedPort) && 0 !== requestedPort && requestedPort !== actual;
|
|
2312
1578
|
}
|
|
2313
1579
|
function portInUse(requestedPort, newPort) {
|
|
2314
|
-
return `${
|
|
1580
|
+
return `${getLoggingPrefix('warn')} Port ${requestedPort} is in use.\nThe dev server listens on port ${newPort} instead.`;
|
|
2315
1581
|
}
|
|
2316
1582
|
function extensionJsRunnerError(error) {
|
|
2317
|
-
return `${
|
|
1583
|
+
return `${getLoggingPrefix('error')} Extension.js couldn't start the runner.\n${pintor.red(String(error))}`;
|
|
2318
1584
|
}
|
|
2319
1585
|
function autoExitModeEnabled(ms) {
|
|
2320
|
-
return `${
|
|
1586
|
+
return `${getLoggingPrefix('info')} Auto-exit is enabled.\nThe process exits after ${ms} ms of idle time.`;
|
|
2321
1587
|
}
|
|
2322
1588
|
function autoExitTriggered(ms) {
|
|
2323
|
-
return `${
|
|
1589
|
+
return `${getLoggingPrefix('info')} Auto-exit triggered after ${ms} ms.\nThe process cleans up and exits now.`;
|
|
2324
1590
|
}
|
|
2325
1591
|
function autoExitForceKill(ms) {
|
|
2326
|
-
return `${
|
|
1592
|
+
return `${getLoggingPrefix('warn')} The process didn't exit within ${ms} ms, so it exits forcibly now.`;
|
|
2327
1593
|
}
|
|
2328
1594
|
function devServerStartTimeout(ms) {
|
|
2329
1595
|
return [
|
|
2330
|
-
`${
|
|
1596
|
+
`${getLoggingPrefix('warn')} The dev server didn't start within ${ms} ms.`,
|
|
2331
1597
|
"The bundler may have hit an error before emitting the first build.",
|
|
2332
1598
|
`If nothing else prints, set ${pintor.blue('EXTENSION_VERBOSE=1')} to see more logs.`
|
|
2333
1599
|
].join('\n');
|
|
2334
1600
|
}
|
|
2335
1601
|
function bundlerFatalError(error) {
|
|
2336
1602
|
const text = error instanceof Error ? error.stack || error.message : String(error);
|
|
2337
|
-
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');
|
|
2338
1613
|
}
|
|
2339
1614
|
function bundlerRecompiling() {
|
|
2340
|
-
return `${
|
|
1615
|
+
return `${getLoggingPrefix('info')} Recompiling due to file changes…`;
|
|
2341
1616
|
}
|
|
2342
1617
|
function noEntrypointsDetected(port) {
|
|
2343
1618
|
return [
|
|
2344
|
-
`${
|
|
1619
|
+
`${getLoggingPrefix('warn')} The first compilation produced no entrypoints or assets.`,
|
|
2345
1620
|
`The dev server is running on 127.0.0.1:${port}, but nothing is being built.`,
|
|
2346
1621
|
"Possible causes:",
|
|
2347
1622
|
"- Empty or missing entry configuration.",
|
|
@@ -2353,6 +1628,15 @@ function noEntrypointsDetected(port) {
|
|
|
2353
1628
|
function spacerLine() {
|
|
2354
1629
|
return ' ';
|
|
2355
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
|
+
}
|
|
2356
1640
|
function hasNewTabOverride(extensionDir) {
|
|
2357
1641
|
const manifestPath = __rspack_external_node_path_c5b9b54f.join(extensionDir, 'manifest.json');
|
|
2358
1642
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) return false;
|
|
@@ -2428,7 +1712,7 @@ function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath
|
|
|
2428
1712
|
return dedupeByResolvedPath(list);
|
|
2429
1713
|
}
|
|
2430
1714
|
function resolveCompanionExtensionDirs(opts) {
|
|
2431
|
-
const { projectRoot, config } = opts;
|
|
1715
|
+
const { projectRoot, config, browser } = opts;
|
|
2432
1716
|
const normalized = normalizeCompanionConfig(config);
|
|
2433
1717
|
const explicitPaths = normalized.paths;
|
|
2434
1718
|
const scanDir = normalized.dir;
|
|
@@ -2468,6 +1752,7 @@ function resolveCompanionExtensionDirs(opts) {
|
|
|
2468
1752
|
for (const ent of entries){
|
|
2469
1753
|
if (!ent.isDirectory()) continue;
|
|
2470
1754
|
if (ent.name.startsWith('.')) continue;
|
|
1755
|
+
if (browser && isBrowserNamedCompanionFolder(ent.name) && !companionFolderMatchesBrowser(ent.name, browser)) continue;
|
|
2471
1756
|
const browserDir = __rspack_external_node_path_c5b9b54f.join(absScan, ent.name);
|
|
2472
1757
|
scanOneLevel(browserDir);
|
|
2473
1758
|
}
|
|
@@ -2495,16 +1780,17 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2495
1780
|
const { manifestDir, packageJsonDir } = getDirs(projectStructure);
|
|
2496
1781
|
const userManifestPath = projectStructure.packageJsonPath || projectStructure.denoJsonPath;
|
|
2497
1782
|
if (userManifestPath) assertNoManagedDependencyConflicts(userManifestPath, packageJsonDir);
|
|
2498
|
-
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);
|
|
2499
1786
|
const outputPath = computePreviewOutputPath(projectStructure, browser, previewOptions.outputPath);
|
|
2500
1787
|
const distPath = getDistPath(packageJsonDir, browser);
|
|
2501
|
-
const metadataCommand = 'start' === previewOptions.metadataCommand ? 'start' : 'preview';
|
|
2502
1788
|
const runningMessage = 'start' === metadataCommand ? starting : previewing;
|
|
2503
1789
|
const metadata = createPlaywrightMetadataWriter({
|
|
2504
1790
|
packageJsonDir,
|
|
2505
1791
|
browser: String(browser),
|
|
2506
1792
|
command: metadataCommand,
|
|
2507
|
-
distPath,
|
|
1793
|
+
distPath: outputPath,
|
|
2508
1794
|
manifestPath: projectStructure.manifestPath,
|
|
2509
1795
|
port: 'number' == typeof previewOptions.port ? previewOptions.port : 'string' == typeof previewOptions.port ? parseInt(previewOptions.port, 10) : null
|
|
2510
1796
|
});
|
|
@@ -2515,11 +1801,13 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2515
1801
|
humanLine(debugBrowser(browser, previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary));
|
|
2516
1802
|
humanLine(debugPreviewOutput(outputPath, distPath));
|
|
2517
1803
|
}
|
|
1804
|
+
ensureSessionArtifactsIgnoreFile(packageJsonDir);
|
|
2518
1805
|
const manifestAtOutput = __rspack_external_node_path_c5b9b54f.join(outputPath, 'manifest.json');
|
|
2519
1806
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestAtOutput)) {
|
|
2520
1807
|
metadata.writeError('preview_manifest_missing', `Expected manifest at ${manifestAtOutput}`);
|
|
2521
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.`);
|
|
2522
1809
|
}
|
|
1810
|
+
const projectConfig = await loadProjectConfigDefaults(packageJsonDir);
|
|
2523
1811
|
const commandConfig = await loadCommandConfig(packageJsonDir, metadataCommand);
|
|
2524
1812
|
const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
|
|
2525
1813
|
if (previewOptions.noBrowser) {
|
|
@@ -2537,12 +1825,13 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2537
1825
|
return;
|
|
2538
1826
|
}
|
|
2539
1827
|
humanLine(runningMessage(browser));
|
|
2540
|
-
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);
|
|
2541
1830
|
const safeBrowserConfig = sanitize(browserConfig);
|
|
2542
1831
|
const safeCommandConfig = sanitize(commandConfig);
|
|
2543
1832
|
const safePreviewOptions = sanitize(previewOptions);
|
|
2544
1833
|
const specialFoldersData = getSpecialFoldersDataForProjectRoot(packageJsonDir);
|
|
2545
|
-
const mergedExtensionsConfig = safePreviewOptions.extensions ?? safeCommandConfig.extensions ?? safeBrowserConfig.extensions ?? specialFoldersData.extensions;
|
|
1834
|
+
const mergedExtensionsConfig = safePreviewOptions.extensions ?? safeCommandConfig.extensions ?? safeBrowserConfig.extensions ?? safeProjectConfig.extensions ?? specialFoldersData.extensions;
|
|
2546
1835
|
const resolvedExtensionsConfig = await resolveCompanionExtensionsConfig({
|
|
2547
1836
|
projectRoot: packageJsonDir,
|
|
2548
1837
|
browser,
|
|
@@ -2551,7 +1840,7 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2551
1840
|
const mergedGeckoBinary = safePreviewOptions.geckoBinary || safePreviewOptions.firefoxBinary || safeCommandConfig.geckoBinary || safeCommandConfig.firefoxBinary || safeBrowserConfig.geckoBinary || safeBrowserConfig.firefoxBinary;
|
|
2552
1841
|
const mergedChromiumBinary = safePreviewOptions.chromiumBinary || safeCommandConfig.chromiumBinary || safeBrowserConfig.chromiumBinary;
|
|
2553
1842
|
const merged = {
|
|
2554
|
-
...mergeOptionLayers(SERVE_COMMAND_DEFAULTS, safeBrowserConfig, safeCommandConfig, safePreviewOptions),
|
|
1843
|
+
...mergeOptionLayers(SERVE_COMMAND_DEFAULTS, safeProjectConfig, safeBrowserConfig, safeCommandConfig, safePreviewOptions),
|
|
2555
1844
|
extensions: resolvedExtensionsConfig,
|
|
2556
1845
|
chromiumBinary: mergedChromiumBinary,
|
|
2557
1846
|
geckoBinary: mergedGeckoBinary
|
|
@@ -2564,7 +1853,8 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2564
1853
|
});
|
|
2565
1854
|
const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
|
|
2566
1855
|
projectRoot: packageJsonDir,
|
|
2567
|
-
config: merged.extensions
|
|
1856
|
+
config: merged.extensions,
|
|
1857
|
+
browser
|
|
2568
1858
|
});
|
|
2569
1859
|
const unpackedExtensionDirsToLoad = computeExtensionsToLoad(__rspack_external_node_path_c5b9b54f.resolve(__rspack_import_meta_dirname__, '..'), 'production', browser, outputPath, companionUnpackedExtensionDirs, projectStructure.manifestPath);
|
|
2570
1860
|
metadata.setManagedExtensionDirs(unpackedExtensionDirsToLoad.filter((dir)=>__rspack_external_node_path_c5b9b54f.resolve(dir) !== __rspack_external_node_path_c5b9b54f.resolve(outputPath)));
|
|
@@ -2598,4 +1888,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
2598
1888
|
await browserLauncher(resolvedOpts);
|
|
2599
1889
|
metadata.writeReady();
|
|
2600
1890
|
}
|
|
2601
|
-
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 };
|