extension-develop 4.1.12 → 4.1.14
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 +1098 -694
- package/dist/0~zip.mjs +1 -1
- package/dist/101.mjs +190 -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 +933 -0
- package/dist/80.mjs +6 -4
- 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/77.mjs
ADDED
|
@@ -0,0 +1,933 @@
|
|
|
1
|
+
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
+
import pintor from "pintor";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fmt, prefix as messaging_prefix, artifactNoun } from "./349.mjs";
|
|
5
|
+
import { findNearestDenoConfigSync, validateDenoConfig, PROJECT_MANIFEST_FILENAMES, readProjectDependencies } from "./80.mjs";
|
|
6
|
+
import { parseJsonSafe } from "./23.mjs";
|
|
7
|
+
import * as __rspack_external_node_path_c5b9b54f from "node:path";
|
|
8
|
+
import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
|
|
9
|
+
function getLoggingPrefix(type) {
|
|
10
|
+
return messaging_prefix(type);
|
|
11
|
+
}
|
|
12
|
+
function isPathLike(input) {
|
|
13
|
+
return input.includes('/') || input.includes('\\') || __rspack_external_node_path_c5b9b54f.isAbsolute(input);
|
|
14
|
+
}
|
|
15
|
+
function resolvedWorkspaceManifest(projectPath, manifestPath) {
|
|
16
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
17
|
+
const packageDir = 'src' === __rspack_external_node_path_c5b9b54f.basename(manifestDir) ? __rspack_external_node_path_c5b9b54f.dirname(manifestDir) : manifestDir;
|
|
18
|
+
const display = __rspack_external_node_path_c5b9b54f.relative(projectPath, packageDir) || packageDir;
|
|
19
|
+
return `${getLoggingPrefix('info')} ${pintor.gray('Workspace root detected.')}\n${pintor.gray('PACKAGE')} ${pintor.underline(display)}`;
|
|
20
|
+
}
|
|
21
|
+
function remoteFetchTimedOut(target, ms) {
|
|
22
|
+
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.`;
|
|
23
|
+
}
|
|
24
|
+
function manifestInvalidJson(manifestPath, error) {
|
|
25
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
26
|
+
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.`;
|
|
27
|
+
}
|
|
28
|
+
function notAnExtensionManifestError(manifestPath) {
|
|
29
|
+
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.`;
|
|
30
|
+
}
|
|
31
|
+
function manifestNotFoundError(manifestPath, candidates = []) {
|
|
32
|
+
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.`;
|
|
33
|
+
if (!candidates.length) return base;
|
|
34
|
+
const projectRoot = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
35
|
+
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?";
|
|
36
|
+
const suggestions = candidates.map((candidate)=>{
|
|
37
|
+
const dir = 'manifest.json' === __rspack_external_node_path_c5b9b54f.basename(candidate) ? __rspack_external_node_path_c5b9b54f.dirname(candidate) : candidate;
|
|
38
|
+
const normalized = 'src' === __rspack_external_node_path_c5b9b54f.basename(dir) ? __rspack_external_node_path_c5b9b54f.dirname(dir) : dir;
|
|
39
|
+
const display = __rspack_external_node_path_c5b9b54f.isAbsolute(normalized) ? __rspack_external_node_path_c5b9b54f.relative(projectRoot, normalized) || normalized : normalized;
|
|
40
|
+
return ` extension dev ${display}`;
|
|
41
|
+
}).join('\n');
|
|
42
|
+
return `${base}\n\n${pintor.gray(hint)}\n${pintor.blue(suggestions)}`;
|
|
43
|
+
}
|
|
44
|
+
function previewingSourceFallback(browser, distDir) {
|
|
45
|
+
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.`;
|
|
46
|
+
}
|
|
47
|
+
function previewing(browser, noBrowser) {
|
|
48
|
+
const suffix = noBrowser ? ' (no-browser mode)' : '';
|
|
49
|
+
return `${getLoggingPrefix('info')} Previewing on ${capitalizedBrowserName(browser)}${suffix}.`;
|
|
50
|
+
}
|
|
51
|
+
function starting(browser, noBrowser) {
|
|
52
|
+
const suffix = noBrowser ? ' (no-browser mode)' : '';
|
|
53
|
+
return `${getLoggingPrefix('info')} Starting on ${capitalizedBrowserName(browser)}${suffix}.`;
|
|
54
|
+
}
|
|
55
|
+
function extensionLoadRecovered() {
|
|
56
|
+
return `${getLoggingPrefix('success')} The browser accepted the extension.\nIt's running now.`;
|
|
57
|
+
}
|
|
58
|
+
function extensionLoadStillRefused(reason) {
|
|
59
|
+
return `${getLoggingPrefix('error')} The browser still refuses to load this extension.\n${pintor.gray('REASON')} ${pintor.red(reason)}`;
|
|
60
|
+
}
|
|
61
|
+
function browserLaunchFailed(browser, reason) {
|
|
62
|
+
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.`;
|
|
63
|
+
}
|
|
64
|
+
function authorInstallNotice(target) {
|
|
65
|
+
return `${messaging_prefix('debug')} install target=${target}`;
|
|
66
|
+
}
|
|
67
|
+
function projectInstallFallbackToNpm(pmName) {
|
|
68
|
+
return `${getLoggingPrefix('warn')} Dependency install with ${pmName} failed.\nExtension.js retries once with npm so the build can continue.`;
|
|
69
|
+
}
|
|
70
|
+
function projectInstallScriptsDisabled(pmName) {
|
|
71
|
+
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.`;
|
|
72
|
+
}
|
|
73
|
+
function anotherDevSessionActive(browser, pid, runId) {
|
|
74
|
+
const run = runId ? `, run ${runId}` : '';
|
|
75
|
+
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.`;
|
|
76
|
+
}
|
|
77
|
+
function buildAssetsTree(stats) {
|
|
78
|
+
const statsJson = stats?.toJson?.({
|
|
79
|
+
all: false,
|
|
80
|
+
assets: true
|
|
81
|
+
});
|
|
82
|
+
const assets = statsJson?.assets || [];
|
|
83
|
+
return getAssetsTree(assets);
|
|
84
|
+
}
|
|
85
|
+
function buildComplete(browser, distDisplayPath, totalBytes) {
|
|
86
|
+
const noun = artifactNoun(String(browser));
|
|
87
|
+
const size = 'number' == typeof totalBytes && totalBytes > 0 ? ` (${getHumanSize(totalBytes)})` : '';
|
|
88
|
+
return `${getLoggingPrefix('success')} ${noun} built for production in ${pintor.underline(distDisplayPath)}${size}.`;
|
|
89
|
+
}
|
|
90
|
+
function platformDocsUrl() {
|
|
91
|
+
return String(process.env.EXTENSION_DEV_DOCS_URL || '').trim().replace(/\/+$/, '');
|
|
92
|
+
}
|
|
93
|
+
function buildShareHint() {
|
|
94
|
+
const docs = platformDocsUrl();
|
|
95
|
+
if (!docs) return '';
|
|
96
|
+
return `${getLoggingPrefix('info')} Send this build to someone for review: ` + pintor.underline(`${docs}/share/unpublished-build-for-review?utm_source=cli-build`);
|
|
97
|
+
}
|
|
98
|
+
function buildFailed(errorCount) {
|
|
99
|
+
const count = Math.max(1, Math.floor(errorCount || 1));
|
|
100
|
+
const noun = 1 === count ? 'error' : 'errors';
|
|
101
|
+
return `${getLoggingPrefix('error')} Build failed with ${count} ${noun}.`;
|
|
102
|
+
}
|
|
103
|
+
function stripModuleWarningWrapper(message) {
|
|
104
|
+
return message.replace(/^Module (?:Warning|Error) \(from [^)]*\):\s*/, '');
|
|
105
|
+
}
|
|
106
|
+
function getWarningMessage(warning) {
|
|
107
|
+
if (!warning) return '';
|
|
108
|
+
if ('string' == typeof warning) return stripModuleWarningWrapper(warning.trim());
|
|
109
|
+
const candidates = [
|
|
110
|
+
warning.message,
|
|
111
|
+
warning.details,
|
|
112
|
+
warning.reason,
|
|
113
|
+
warning.description
|
|
114
|
+
];
|
|
115
|
+
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return stripModuleWarningWrapper(candidate.trim());
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
function getWarningSource(warning) {
|
|
119
|
+
if (!warning || 'string' == typeof warning) return 'bundler';
|
|
120
|
+
const candidates = [
|
|
121
|
+
warning.name,
|
|
122
|
+
warning.moduleName,
|
|
123
|
+
warning.moduleIdentifier,
|
|
124
|
+
warning.originName,
|
|
125
|
+
warning.pluginName
|
|
126
|
+
];
|
|
127
|
+
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
128
|
+
return 'bundler';
|
|
129
|
+
}
|
|
130
|
+
function getWarningArtifact(warning) {
|
|
131
|
+
if (!warning || 'string' == typeof warning) return '';
|
|
132
|
+
const candidates = [
|
|
133
|
+
warning.file,
|
|
134
|
+
warning.chunkName,
|
|
135
|
+
warning.moduleName
|
|
136
|
+
];
|
|
137
|
+
for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
|
|
138
|
+
return '';
|
|
139
|
+
}
|
|
140
|
+
function classifyWarning(message, source) {
|
|
141
|
+
const haystack = `${message} ${source}`.toLowerCase();
|
|
142
|
+
if (haystack.includes('performance') || haystack.includes('asset size') || haystack.includes('entrypoint size') || haystack.includes('exceeds the recommended size') || haystack.includes('hints')) return 'Performance';
|
|
143
|
+
if (haystack.includes('deprecat') || haystack.includes('[dep_') || haystack.includes('legacy')) return 'Deprecation';
|
|
144
|
+
if (haystack.includes('invalid') || haystack.includes('unknown option') || haystack.includes('configuration') || haystack.includes('schema')) return 'Configuration';
|
|
145
|
+
if (haystack.includes('manifest') || haystack.includes('browser') || haystack.includes('target')) return 'Compatibility';
|
|
146
|
+
if (haystack.includes('runtime') || haystack.includes('will fail') || haystack.includes('cannot resolve') || haystack.includes('service_worker')) return 'Runtime-risk';
|
|
147
|
+
return 'Warning';
|
|
148
|
+
}
|
|
149
|
+
function suggestedHintForWarning(category) {
|
|
150
|
+
if ('Performance' === category) return 'Inspect the largest startup bundles and split optional code paths.';
|
|
151
|
+
if ('Deprecation' === category) return 'Move to the supported API or plugin path before the next update.';
|
|
152
|
+
if ('Configuration' === category) return 'Review extension and bundler config keys, then remove or rename invalid options.';
|
|
153
|
+
if ('Compatibility' === category) return 'Verify browser target and manifest compatibility for this build.';
|
|
154
|
+
if ('Runtime-risk' === category) return 'Address this before release. It may fail or degrade at runtime.';
|
|
155
|
+
return 'Re-run with EXTENSION_VERBOSE=1 to inspect full warning details.';
|
|
156
|
+
}
|
|
157
|
+
function buildWarningsDetails(warnings) {
|
|
158
|
+
if (!Array.isArray(warnings) || 0 === warnings.length) return '';
|
|
159
|
+
const blocks = [];
|
|
160
|
+
warnings.forEach((warning, index)=>{
|
|
161
|
+
const message = getWarningMessage(warning);
|
|
162
|
+
const source = getWarningSource(warning);
|
|
163
|
+
const artifact = getWarningArtifact(warning);
|
|
164
|
+
const category = classifyWarning(message, source);
|
|
165
|
+
const hint = suggestedHintForWarning(category);
|
|
166
|
+
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.')}`);
|
|
167
|
+
const performanceWarning = parsePerformanceWarning(warning, source, artifact);
|
|
168
|
+
if (performanceWarning) return void blocks.push(performanceWarning);
|
|
169
|
+
const oneLine = message.replace(/\s+/g, ' ').trim();
|
|
170
|
+
const artifactSuffix = artifact ? ` ${pintor.gray(`(${artifact})`)}` : '';
|
|
171
|
+
blocks.push(`${getLoggingPrefix('warn')} ${category}: ${oneLine}${artifactSuffix}\n${formatWarningLabelLine('Source', pintor.gray(source))}\n${formatWarningLabelLine('Hint', hint)}`);
|
|
172
|
+
});
|
|
173
|
+
return blocks.join('\n\n');
|
|
174
|
+
}
|
|
175
|
+
function fetchingProjectPath(owner, project) {
|
|
176
|
+
return fmt.block('Fetching project', [
|
|
177
|
+
[
|
|
178
|
+
'URL',
|
|
179
|
+
fmt.val(`https://github.com/${owner}/${project}`)
|
|
180
|
+
]
|
|
181
|
+
]);
|
|
182
|
+
}
|
|
183
|
+
function downloadingProjectPath(projectName) {
|
|
184
|
+
const formatted = isPathLike(projectName) ? pintor.underline(projectName) : projectName;
|
|
185
|
+
return `${getLoggingPrefix('info')} Downloading ${formatted}…`;
|
|
186
|
+
}
|
|
187
|
+
function creatingProjectPath(projectPath) {
|
|
188
|
+
return `${getLoggingPrefix('info')} Creating a new browser extension…\n${pintor.gray('PATH')} ${pintor.underline(projectPath)}`;
|
|
189
|
+
}
|
|
190
|
+
function downloadedProjectFolderNotFound(cwd, candidates) {
|
|
191
|
+
return `${getLoggingPrefix('error')} Downloaded project folder not found.\n${pintor.gray('PATH')} ${pintor.underline(cwd)}\n${pintor.gray('NOT FOUND')} ${pintor.underline(candidates.join(', '))}`;
|
|
192
|
+
}
|
|
193
|
+
function packagingSourceFiles(zipPath) {
|
|
194
|
+
return `${messaging_prefix('debug')} zip pack=source gitignore=excluded path=${zipPath}`;
|
|
195
|
+
}
|
|
196
|
+
function zipArtifactReady(zipPath, sizeInBytes) {
|
|
197
|
+
return `${getLoggingPrefix('success')} Packaged ${pintor.underline(zipPath)} (${getHumanSize(sizeInBytes)}).`;
|
|
198
|
+
}
|
|
199
|
+
function packagingDistributionFiles(zipPath) {
|
|
200
|
+
return `${messaging_prefix('debug')} zip pack=dist path=${zipPath}`;
|
|
201
|
+
}
|
|
202
|
+
function treeWithSourceAndDistFiles(browser, name, sourceZip, destZip) {
|
|
203
|
+
return `${messaging_prefix('debug')} zip name=${name} browser=${String(browser)} source=${sourceZip} dist=${destZip}`;
|
|
204
|
+
}
|
|
205
|
+
function treeWithDistFilesBrowser(name, ext, browser, zipPath) {
|
|
206
|
+
return `${messaging_prefix('debug')} zip name=${name}.${ext} browser=${String(browser)} dist=${zipPath}`;
|
|
207
|
+
}
|
|
208
|
+
function treeWithSourceFiles(name, ext, browser, zipPath) {
|
|
209
|
+
return `${messaging_prefix('debug')} zip name=${name}-source.${ext} browser=${String(browser)} source=${zipPath}`;
|
|
210
|
+
}
|
|
211
|
+
function writingTypeDefinitions(manifest) {
|
|
212
|
+
return `${getLoggingPrefix('info')} Writing the type definitions for ${manifest.name || 'the extension'}…`;
|
|
213
|
+
}
|
|
214
|
+
function writingTypeDefinitionsError(error) {
|
|
215
|
+
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.`;
|
|
216
|
+
}
|
|
217
|
+
function downloadingText(url) {
|
|
218
|
+
return fmt.block('Downloading extension', [
|
|
219
|
+
[
|
|
220
|
+
'URL',
|
|
221
|
+
fmt.val(url)
|
|
222
|
+
]
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
function unpackagingExtension(zipFilePath) {
|
|
226
|
+
return `${getLoggingPrefix('info')} Unpackaging the browser extension…\n${pintor.gray('PATH')} ${pintor.underline(zipFilePath)}`;
|
|
227
|
+
}
|
|
228
|
+
function unpackagedSuccessfully() {
|
|
229
|
+
return `${getLoggingPrefix('success')} Extension unpackaged.`;
|
|
230
|
+
}
|
|
231
|
+
function failedToDownloadOrExtractZIPFileError(error) {
|
|
232
|
+
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.`;
|
|
233
|
+
}
|
|
234
|
+
function invalidRemoteZip(url, contentType) {
|
|
235
|
+
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.`;
|
|
236
|
+
}
|
|
237
|
+
function notAZipArchive(source, contentType) {
|
|
238
|
+
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.";
|
|
239
|
+
}
|
|
240
|
+
function localZipNotFound(zipFilePath) {
|
|
241
|
+
return `${getLoggingPrefix('error')} ZIP file not found.\n${pintor.gray('NOT FOUND')} ${pintor.underline(zipFilePath)}\nCheck the path, then try again.`;
|
|
242
|
+
}
|
|
243
|
+
function capitalizedBrowserName(browser) {
|
|
244
|
+
const b = String(browser || '');
|
|
245
|
+
const cap = b.charAt(0).toUpperCase() + b.slice(1);
|
|
246
|
+
return pintor.yellow(`${cap}`);
|
|
247
|
+
}
|
|
248
|
+
function getFileSize(fileSizeInBytes) {
|
|
249
|
+
return `${(fileSizeInBytes / 1024).toFixed(2)}KB`;
|
|
250
|
+
}
|
|
251
|
+
function getHumanSize(sizeInBytes) {
|
|
252
|
+
const bytes = Math.max(0, sizeInBytes || 0);
|
|
253
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
254
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
255
|
+
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
256
|
+
}
|
|
257
|
+
function printTree(node, prefix = '') {
|
|
258
|
+
let output = '';
|
|
259
|
+
Object.keys(node).forEach((key, index, array)=>{
|
|
260
|
+
const isLast = index === array.length - 1;
|
|
261
|
+
const connector = isLast ? '└─' : '├─';
|
|
262
|
+
const child = node[key];
|
|
263
|
+
const childNode = child && 'object' == typeof child ? child : void 0;
|
|
264
|
+
const isLeaf = 'number' == typeof childNode?.size;
|
|
265
|
+
const sizeInKB = isLeaf ? ` (${getFileSize(childNode?.size ?? 0)})` : '';
|
|
266
|
+
output += `${pintor.gray(prefix)}${pintor.gray(connector)} ${key}${pintor.gray(sizeInKB)}\n`;
|
|
267
|
+
if (childNode && !isLeaf) output += printTree(childNode, `${prefix}${isLast ? ' ' : pintor.gray('│ ')}`);
|
|
268
|
+
});
|
|
269
|
+
return output;
|
|
270
|
+
}
|
|
271
|
+
function getAssetsTree(assets) {
|
|
272
|
+
const assetTree = {};
|
|
273
|
+
assets?.forEach((asset)=>{
|
|
274
|
+
if ('string' != typeof asset?.name) return;
|
|
275
|
+
const paths = asset.name.split('/');
|
|
276
|
+
let currentLevel = assetTree;
|
|
277
|
+
paths.forEach((part, index)=>{
|
|
278
|
+
if (!currentLevel[part]) currentLevel[part] = {};
|
|
279
|
+
if (index === paths.length - 1) currentLevel[part] = {
|
|
280
|
+
size: asset.size
|
|
281
|
+
};
|
|
282
|
+
else currentLevel = currentLevel[part];
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
if (0 === Object.keys(assetTree).length) return '';
|
|
286
|
+
return `.\n${printTree(assetTree)}`;
|
|
287
|
+
}
|
|
288
|
+
function formatWarningLabelLine(label, value) {
|
|
289
|
+
return `${pintor.gray('│')} ${pintor.gray(`${label}:`)} ${value}`;
|
|
290
|
+
}
|
|
291
|
+
function parsePerformanceWarning(warning, source, _artifact) {
|
|
292
|
+
const normalized = getWarningBody(warning).replace(/\r/g, '');
|
|
293
|
+
const lower = normalized.toLowerCase();
|
|
294
|
+
const threshold = normalized.match(/\(([\d.]+\s(?:KiB|MiB|GiB|KB|MB|GB))\)/)?.[1] || '';
|
|
295
|
+
if (lower.includes('asset size limit')) return formatPerformanceWarningBlock({
|
|
296
|
+
title: 'asset size limit exceeded',
|
|
297
|
+
threshold,
|
|
298
|
+
impact: 'Large emitted files can increase package size and slow extension startup.',
|
|
299
|
+
source,
|
|
300
|
+
hint: 'Inspect the largest startup bundles and split optional code paths.'
|
|
301
|
+
});
|
|
302
|
+
if (lower.includes('entrypoint size limit')) return formatPerformanceWarningBlock({
|
|
303
|
+
title: 'entrypoint size limit exceeded',
|
|
304
|
+
threshold,
|
|
305
|
+
impact: 'Startup entrypoints are heavier than recommended.',
|
|
306
|
+
source,
|
|
307
|
+
hint: 'Keep startup entrypoints thin and defer non-critical code.'
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function formatPerformanceWarningBlock(options) {
|
|
311
|
+
const lines = [
|
|
312
|
+
`${getLoggingPrefix('warn')} Performance: ${options.title}`
|
|
313
|
+
];
|
|
314
|
+
if (options.threshold) lines.push(formatWarningLabelLine('Threshold', options.threshold));
|
|
315
|
+
lines.push(formatWarningLabelLine('Impact', options.impact));
|
|
316
|
+
lines.push(pintor.gray('│'));
|
|
317
|
+
lines.push(formatWarningLabelLine('Source', pintor.gray(options.source)));
|
|
318
|
+
lines.push(formatWarningLabelLine('Hint', options.hint));
|
|
319
|
+
return lines.join('\n');
|
|
320
|
+
}
|
|
321
|
+
function getWarningBody(warning) {
|
|
322
|
+
if (!warning) return '';
|
|
323
|
+
if ('string' == typeof warning) return warning;
|
|
324
|
+
return [
|
|
325
|
+
warning.message,
|
|
326
|
+
warning.details,
|
|
327
|
+
warning.reason,
|
|
328
|
+
warning.description
|
|
329
|
+
].filter((value)=>'string' == typeof value && value.trim().length > 0).join('\n');
|
|
330
|
+
}
|
|
331
|
+
function isUsingExperimentalConfig(integration) {
|
|
332
|
+
return `${messaging_prefix('debug')} config using=${String(integration)}`;
|
|
333
|
+
}
|
|
334
|
+
function debugDirs(manifestDir, packageJsonDir) {
|
|
335
|
+
return `${messaging_prefix('debug')} dirs manifest=${manifestDir} pkg=${packageJsonDir}`;
|
|
336
|
+
}
|
|
337
|
+
function debugBrowser(browser, chromiumBinary, geckoBinary) {
|
|
338
|
+
return `${messaging_prefix('debug')} browser target=${String(browser)} chromiumBinary=${String(chromiumBinary || 'auto')} geckoBinary=${String(geckoBinary || 'auto')}`;
|
|
339
|
+
}
|
|
340
|
+
function debugOutputPath(pathValue) {
|
|
341
|
+
return `${messaging_prefix('debug')} output path=${pathValue}`;
|
|
342
|
+
}
|
|
343
|
+
function previewingCustomOutput(browser, outputPath, distPath) {
|
|
344
|
+
return `${getLoggingPrefix('info')} Previewing ${String(browser)} from ${outputPath}.\nThis is not the build folder ${distPath}. The run record describes the folder loaded.`;
|
|
345
|
+
}
|
|
346
|
+
function debugPreviewOutput(outputPath, distPath) {
|
|
347
|
+
return `${messaging_prefix('debug')} preview output=${outputPath} dist=${distPath}`;
|
|
348
|
+
}
|
|
349
|
+
function debugContextPath(packageJsonDir) {
|
|
350
|
+
return `${messaging_prefix('debug')} context path=${packageJsonDir}`;
|
|
351
|
+
}
|
|
352
|
+
function debugExtensionsToLoad(extensions) {
|
|
353
|
+
return `${messaging_prefix('debug')} extensions count=${extensions.length} paths=${extensions.join(',')}`;
|
|
354
|
+
}
|
|
355
|
+
function noCompanionExtensionsResolved() {
|
|
356
|
+
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.`;
|
|
357
|
+
}
|
|
358
|
+
function configLoadingError(configPath, error) {
|
|
359
|
+
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.`;
|
|
360
|
+
}
|
|
361
|
+
function buildCommandFailed(error) {
|
|
362
|
+
const message = (()=>{
|
|
363
|
+
if (error instanceof Error && error.message) return error.message;
|
|
364
|
+
return String(error || 'Unknown error');
|
|
365
|
+
})();
|
|
366
|
+
if (message.includes(getLoggingPrefix('error'))) return message;
|
|
367
|
+
return `${getLoggingPrefix('error')} ${pintor.red(fmt.truncate(message, 1200))}`;
|
|
368
|
+
}
|
|
369
|
+
function devCommandFailed(error) {
|
|
370
|
+
const message = (()=>{
|
|
371
|
+
if (error instanceof Error && error.message) return error.message;
|
|
372
|
+
return String(error || 'Unknown error');
|
|
373
|
+
})();
|
|
374
|
+
return `${getLoggingPrefix('error')} Dev mode failed.\n${pintor.red(fmt.truncate(message, 1200))}`;
|
|
375
|
+
}
|
|
376
|
+
function managedDependencyConflict(duplicates, userPackageJsonPath) {
|
|
377
|
+
const list = duplicates.map((d)=>`- ${pintor.yellow(d)}`).join('\n');
|
|
378
|
+
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.`;
|
|
379
|
+
}
|
|
380
|
+
function isUrlShaped(target) {
|
|
381
|
+
return /^(?:\.[\\/])?[a-z][a-z0-9+.-]+:[\\/]+/i.test(target);
|
|
382
|
+
}
|
|
383
|
+
function findUpLocalSync(filename, options) {
|
|
384
|
+
if (isUrlShaped(options.cwd)) return;
|
|
385
|
+
const root = __rspack_external_node_path_c5b9b54f.parse(__rspack_external_node_path_c5b9b54f.resolve(options.cwd)).root;
|
|
386
|
+
let currentDir = __rspack_external_node_path_c5b9b54f.resolve(options.cwd);
|
|
387
|
+
while(true){
|
|
388
|
+
const candidate = __rspack_external_node_path_c5b9b54f.join(currentDir, filename);
|
|
389
|
+
try {
|
|
390
|
+
const stat = __rspack_external_node_fs_5ea92f0c.statSync(candidate);
|
|
391
|
+
if (stat.isFile()) return candidate;
|
|
392
|
+
} catch {}
|
|
393
|
+
const parentDir = __rspack_external_node_path_c5b9b54f.dirname(currentDir);
|
|
394
|
+
if (currentDir === root || parentDir === currentDir) return;
|
|
395
|
+
currentDir = parentDir;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function findNearestPackageJsonSync(manifestPath) {
|
|
399
|
+
try {
|
|
400
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
401
|
+
const packageJsonPath = findUpLocalSync('package.json', {
|
|
402
|
+
cwd: manifestDir
|
|
403
|
+
});
|
|
404
|
+
return packageJsonPath || null;
|
|
405
|
+
} catch (error) {
|
|
406
|
+
console.warn('Failed to find package.json:', error);
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function validatePackageJson(packageJsonPath) {
|
|
411
|
+
try {
|
|
412
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(packageJsonPath)) return false;
|
|
413
|
+
const content = __rspack_external_node_fs_5ea92f0c.readFileSync(packageJsonPath, 'utf-8');
|
|
414
|
+
JSON.parse(content);
|
|
415
|
+
return true;
|
|
416
|
+
} catch (error) {
|
|
417
|
+
console.warn('Invalid package.json at:', packageJsonPath, error);
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const isUrl = (url)=>{
|
|
422
|
+
try {
|
|
423
|
+
new URL(url);
|
|
424
|
+
return true;
|
|
425
|
+
} catch (e) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
const REMOTE_FETCH_TIMEOUT_MS = (()=>{
|
|
430
|
+
const raw = parseInt(String(process.env.EXTENSION_FETCH_TIMEOUT_MS || ''), 10);
|
|
431
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 60000;
|
|
432
|
+
})();
|
|
433
|
+
function withTimeout(task, ms, label) {
|
|
434
|
+
let timer;
|
|
435
|
+
const timeout = new Promise((_, reject)=>{
|
|
436
|
+
timer = setTimeout(()=>reject(new Error(remoteFetchTimedOut(label, ms))), ms);
|
|
437
|
+
});
|
|
438
|
+
return Promise.race([
|
|
439
|
+
task,
|
|
440
|
+
timeout
|
|
441
|
+
]).finally(()=>{
|
|
442
|
+
if (timer) clearTimeout(timer);
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
|
|
446
|
+
const cwd = process.cwd();
|
|
447
|
+
const url = new URL(pathOrRemoteUrl);
|
|
448
|
+
const segments = url.pathname.split('/').filter(Boolean);
|
|
449
|
+
const repoName = segments.length >= 2 ? segments[1] : segments[segments.length - 1];
|
|
450
|
+
const treeIndex = segments.indexOf('tree');
|
|
451
|
+
const expectedName = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments[segments.length - 1] : repoName;
|
|
452
|
+
const expectedPath = __rspack_external_node_path_c5b9b54f.resolve(cwd, expectedName);
|
|
453
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(expectedPath)) try {
|
|
454
|
+
const entries = __rspack_external_node_fs_5ea92f0c.readdirSync(expectedPath);
|
|
455
|
+
if (0 === entries.length) __rspack_external_node_fs_5ea92f0c.rmSync(expectedPath, {
|
|
456
|
+
recursive: true,
|
|
457
|
+
force: true
|
|
458
|
+
});
|
|
459
|
+
else {
|
|
460
|
+
const hasManifest = (dir)=>{
|
|
461
|
+
const stack = [
|
|
462
|
+
dir
|
|
463
|
+
];
|
|
464
|
+
while(stack.length){
|
|
465
|
+
const current = stack.pop();
|
|
466
|
+
const items = __rspack_external_node_fs_5ea92f0c.readdirSync(current, {
|
|
467
|
+
withFileTypes: true
|
|
468
|
+
});
|
|
469
|
+
for (const it of items){
|
|
470
|
+
if (it.isFile() && 'manifest.json' === it.name) return true;
|
|
471
|
+
if (it.isDirectory() && 'node_modules' !== it.name && 'dist' !== it.name && !it.name.startsWith('.')) stack.push(__rspack_external_node_path_c5b9b54f.join(current, it.name));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return false;
|
|
475
|
+
};
|
|
476
|
+
if (hasManifest(expectedPath)) return expectedPath;
|
|
477
|
+
__rspack_external_node_fs_5ea92f0c.rmSync(expectedPath, {
|
|
478
|
+
recursive: true,
|
|
479
|
+
force: true
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
} catch {}
|
|
483
|
+
async function tryGitClone() {
|
|
484
|
+
const { default: goGitIt } = await import("go-git-it");
|
|
485
|
+
await withTimeout(goGitIt(pathOrRemoteUrl, cwd, text), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
|
|
486
|
+
}
|
|
487
|
+
async function tryZipFallback() {
|
|
488
|
+
const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
|
|
489
|
+
const owner = segments[0];
|
|
490
|
+
const repo = segments[1];
|
|
491
|
+
const subdir = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments.slice(treeIndex + 2).join('/') : '';
|
|
492
|
+
const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${branch}`;
|
|
493
|
+
const extractedPath = await importUrlSourceFromZip(zipUrl);
|
|
494
|
+
const extractedDirs = __rspack_external_node_fs_5ea92f0c.readdirSync(extractedPath, {
|
|
495
|
+
withFileTypes: true
|
|
496
|
+
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
497
|
+
const repoRootDir = extractedDirs.find((d)=>d.startsWith(`${repo}-${branch}`));
|
|
498
|
+
const repoRoot = repoRootDir ? __rspack_external_node_path_c5b9b54f.join(extractedPath, repoRootDir) : extractedPath;
|
|
499
|
+
return subdir ? __rspack_external_node_path_c5b9b54f.join(repoRoot, subdir) : repoRoot;
|
|
500
|
+
}
|
|
501
|
+
try {
|
|
502
|
+
await tryGitClone();
|
|
503
|
+
} catch {
|
|
504
|
+
return await tryZipFallback();
|
|
505
|
+
}
|
|
506
|
+
const candidates = [];
|
|
507
|
+
if (-1 !== treeIndex && segments.length > treeIndex + 2) candidates.push(segments[segments.length - 1]);
|
|
508
|
+
candidates.push(repoName);
|
|
509
|
+
for (const name of candidates){
|
|
510
|
+
const p = __rspack_external_node_path_c5b9b54f.resolve(cwd, name);
|
|
511
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(p)) return p;
|
|
512
|
+
}
|
|
513
|
+
const dirs = __rspack_external_node_fs_5ea92f0c.readdirSync(cwd, {
|
|
514
|
+
withFileTypes: true
|
|
515
|
+
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
516
|
+
for (const dir of dirs){
|
|
517
|
+
const manifestPath = __rspack_external_node_path_c5b9b54f.join(cwd, dir, 'manifest.json');
|
|
518
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) return __rspack_external_node_path_c5b9b54f.join(cwd, dir);
|
|
519
|
+
}
|
|
520
|
+
try {
|
|
521
|
+
const dirs = __rspack_external_node_fs_5ea92f0c.readdirSync(cwd, {
|
|
522
|
+
withFileTypes: true
|
|
523
|
+
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
524
|
+
const ghRoot = dirs.find((d)=>/-main$|-master$/.test(d));
|
|
525
|
+
if (ghRoot) return __rspack_external_node_path_c5b9b54f.join(cwd, ghRoot);
|
|
526
|
+
} catch {}
|
|
527
|
+
throw new Error(downloadedProjectFolderNotFound(cwd, candidates));
|
|
528
|
+
}
|
|
529
|
+
async function importUrlSourceFromZip(pathOrRemoteUrl) {
|
|
530
|
+
const cwd = process.cwd();
|
|
531
|
+
const { downloadAndExtractZip } = await import("./0~zip.mjs");
|
|
532
|
+
const extractedPath = await withTimeout(downloadAndExtractZip(pathOrRemoteUrl, cwd), REMOTE_FETCH_TIMEOUT_MS, pathOrRemoteUrl);
|
|
533
|
+
return extractedPath;
|
|
534
|
+
}
|
|
535
|
+
async function importLocalSourceFromZip(zipFilePath) {
|
|
536
|
+
const cwd = process.cwd();
|
|
537
|
+
const { extractLocalZip } = await import("./0~zip.mjs");
|
|
538
|
+
return await extractLocalZip(zipFilePath, cwd);
|
|
539
|
+
}
|
|
540
|
+
async function getProjectPath(pathOrRemoteUrl) {
|
|
541
|
+
if (!pathOrRemoteUrl) return process.cwd();
|
|
542
|
+
if (isUrl(pathOrRemoteUrl)) {
|
|
543
|
+
const url = new URL(pathOrRemoteUrl);
|
|
544
|
+
if (url.protocol.startsWith('http')) {
|
|
545
|
+
const pathname = url.pathname.toLowerCase();
|
|
546
|
+
if (pathname.endsWith('.zip')) return await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
547
|
+
if ('https://github.com' !== url.origin) {
|
|
548
|
+
const urlSource = await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
549
|
+
return urlSource;
|
|
550
|
+
}
|
|
551
|
+
const urlData = url.pathname.split('/');
|
|
552
|
+
const owner = urlData.slice(1, 3)[0];
|
|
553
|
+
const project = urlData.slice(1, 3)[1];
|
|
554
|
+
console.log(fetchingProjectPath(owner, project));
|
|
555
|
+
const projectName = __rspack_external_node_path_c5b9b54f.basename(url.pathname);
|
|
556
|
+
const urlSource = await importUrlSourceFromGithub(pathOrRemoteUrl, downloadingProjectPath(projectName));
|
|
557
|
+
console.log(creatingProjectPath(url.pathname));
|
|
558
|
+
return urlSource;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const resolvedPath = __rspack_external_node_path_c5b9b54f.resolve(process.cwd(), pathOrRemoteUrl);
|
|
562
|
+
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);
|
|
563
|
+
return resolvedPath;
|
|
564
|
+
}
|
|
565
|
+
function collectManifestCandidates(rootDir, maxDepth) {
|
|
566
|
+
const SKIP_DIRS = new Set([
|
|
567
|
+
'node_modules',
|
|
568
|
+
'dist',
|
|
569
|
+
'build',
|
|
570
|
+
'out',
|
|
571
|
+
'.git',
|
|
572
|
+
'.turbo',
|
|
573
|
+
'.next',
|
|
574
|
+
'coverage',
|
|
575
|
+
'.cache',
|
|
576
|
+
'.vercel'
|
|
577
|
+
]);
|
|
578
|
+
const results = [];
|
|
579
|
+
const walk = (dir, depth)=>{
|
|
580
|
+
if (depth > maxDepth || results.length >= 10) return;
|
|
581
|
+
let entries;
|
|
582
|
+
try {
|
|
583
|
+
entries = __rspack_external_node_fs_5ea92f0c.readdirSync(dir, {
|
|
584
|
+
withFileTypes: true
|
|
585
|
+
});
|
|
586
|
+
} catch {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
for (const entry of entries){
|
|
590
|
+
if (entry.isFile() && 'manifest.json' === entry.name) {
|
|
591
|
+
results.push(__rspack_external_node_path_c5b9b54f.join(dir, entry.name));
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && !SKIP_DIRS.has(entry.name)) walk(__rspack_external_node_path_c5b9b54f.join(dir, entry.name), depth + 1);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
walk(rootDir, 0);
|
|
598
|
+
return results;
|
|
599
|
+
}
|
|
600
|
+
async function getProjectStructure(pathOrRemoteUrl) {
|
|
601
|
+
const projectPath = await getProjectPath(pathOrRemoteUrl);
|
|
602
|
+
return resolveProjectStructureSync(projectPath);
|
|
603
|
+
}
|
|
604
|
+
function resolveProjectStructureSync(projectPath, options = {}) {
|
|
605
|
+
const log = (line)=>{
|
|
606
|
+
if (!options.quiet) console.log(line);
|
|
607
|
+
};
|
|
608
|
+
const isUnderDir = (baseDir, candidatePath)=>{
|
|
609
|
+
const rel = __rspack_external_node_path_c5b9b54f.relative(baseDir, candidatePath);
|
|
610
|
+
return Boolean(rel && !rel.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(rel));
|
|
611
|
+
};
|
|
612
|
+
const packageJsonPathFromProject = findNearestPackageJsonSync(__rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json'));
|
|
613
|
+
const denoJsonPathFromProject = findNearestDenoConfigSync(__rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json'));
|
|
614
|
+
const packageJsonDirFromProject = packageJsonPathFromProject ? __rspack_external_node_path_c5b9b54f.dirname(packageJsonPathFromProject) : denoJsonPathFromProject ? __rspack_external_node_path_c5b9b54f.dirname(denoJsonPathFromProject) : void 0;
|
|
615
|
+
const rootManifestPath = __rspack_external_node_path_c5b9b54f.join(projectPath, 'manifest.json');
|
|
616
|
+
const srcManifestPath = __rspack_external_node_path_c5b9b54f.join(projectPath, 'src', 'manifest.json');
|
|
617
|
+
let manifestPath = __rspack_external_node_fs_5ea92f0c.existsSync(srcManifestPath) ? srcManifestPath : rootManifestPath;
|
|
618
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) if (packageJsonDirFromProject) {
|
|
619
|
+
const absoluteCandidates = collectManifestCandidates(projectPath, 3);
|
|
620
|
+
const relativeCandidates = absoluteCandidates.map((candidate)=>__rspack_external_node_path_c5b9b54f.relative(projectPath, candidate) || candidate);
|
|
621
|
+
if (1 === absoluteCandidates.length) {
|
|
622
|
+
manifestPath = absoluteCandidates[0];
|
|
623
|
+
log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
624
|
+
} else throw new Error(manifestNotFoundError(manifestPath, relativeCandidates));
|
|
625
|
+
} else {
|
|
626
|
+
const MAX_DEPTH = 5;
|
|
627
|
+
const findManifest = (dir, depth)=>{
|
|
628
|
+
if (depth > MAX_DEPTH) return null;
|
|
629
|
+
let files;
|
|
630
|
+
try {
|
|
631
|
+
files = __rspack_external_node_fs_5ea92f0c.readdirSync(dir, {
|
|
632
|
+
withFileTypes: true
|
|
633
|
+
});
|
|
634
|
+
} catch {
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
637
|
+
for (const file of files){
|
|
638
|
+
if (file.isFile() && 'manifest.json' === file.name) return __rspack_external_node_path_c5b9b54f.join(dir, file.name);
|
|
639
|
+
if (file.isDirectory() && !file.name.startsWith('.') && 'node_modules' !== file.name && 'dist' !== file.name && 'public' !== file.name) {
|
|
640
|
+
const found = findManifest(__rspack_external_node_path_c5b9b54f.join(dir, file.name), depth + 1);
|
|
641
|
+
if (found) return found;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return null;
|
|
645
|
+
};
|
|
646
|
+
const foundManifest = findManifest(projectPath, 0);
|
|
647
|
+
if (foundManifest) manifestPath = foundManifest;
|
|
648
|
+
else throw new Error(manifestNotFoundError(manifestPath));
|
|
649
|
+
}
|
|
650
|
+
const readManifestObject = (candidatePath)=>{
|
|
651
|
+
try {
|
|
652
|
+
const parsed = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(candidatePath));
|
|
653
|
+
if (null === parsed || 'object' != typeof parsed || Array.isArray(parsed)) return;
|
|
654
|
+
return parsed;
|
|
655
|
+
} catch {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
const isPwaManifest = (candidatePath)=>{
|
|
660
|
+
const parsed = readManifestObject(candidatePath);
|
|
661
|
+
if (!parsed || null != parsed.manifest_version) return false;
|
|
662
|
+
return Array.isArray(parsed.icons) || 'string' == typeof parsed.start_url || 'string' == typeof parsed.display || null != parsed.related_applications || null != parsed.prefer_related_applications;
|
|
663
|
+
};
|
|
664
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath) && isPwaManifest(manifestPath)) {
|
|
665
|
+
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);
|
|
666
|
+
if (1 === alternatives.length) {
|
|
667
|
+
manifestPath = alternatives[0];
|
|
668
|
+
log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
669
|
+
} else throw new Error(notAnExtensionManifestError(manifestPath));
|
|
670
|
+
}
|
|
671
|
+
const packageJsonPath = findNearestPackageJsonSync(manifestPath);
|
|
672
|
+
const packageJsonDir = packageJsonPath ? __rspack_external_node_path_c5b9b54f.dirname(packageJsonPath) : void 0;
|
|
673
|
+
const nearestDenoJsonPath = findNearestDenoConfigSync(manifestPath);
|
|
674
|
+
const denoJsonPath = nearestDenoJsonPath && validateDenoConfig(nearestDenoJsonPath) ? nearestDenoJsonPath : void 0;
|
|
675
|
+
const projectRootDir = packageJsonDir ?? (denoJsonPath ? __rspack_external_node_path_c5b9b54f.dirname(denoJsonPath) : void 0);
|
|
676
|
+
if (projectRootDir) {
|
|
677
|
+
const publicRoot = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'public');
|
|
678
|
+
if (isUnderDir(publicRoot, manifestPath)) {
|
|
679
|
+
const fallbackSrc = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'src', 'manifest.json');
|
|
680
|
+
const fallbackRoot = __rspack_external_node_path_c5b9b54f.join(projectRootDir, 'manifest.json');
|
|
681
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(fallbackSrc)) manifestPath = fallbackSrc;
|
|
682
|
+
else if (__rspack_external_node_fs_5ea92f0c.existsSync(fallbackRoot)) manifestPath = fallbackRoot;
|
|
683
|
+
else throw new Error(manifestNotFoundError(fallbackRoot));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (!packageJsonPath || !validatePackageJson(packageJsonPath)) return {
|
|
687
|
+
manifestPath,
|
|
688
|
+
...denoJsonPath ? {
|
|
689
|
+
denoJsonPath
|
|
690
|
+
} : {}
|
|
691
|
+
};
|
|
692
|
+
return {
|
|
693
|
+
manifestPath,
|
|
694
|
+
packageJsonPath,
|
|
695
|
+
...denoJsonPath ? {
|
|
696
|
+
denoJsonPath
|
|
697
|
+
} : {}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
function asAbsolute(p) {
|
|
701
|
+
return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
|
|
702
|
+
}
|
|
703
|
+
function toPosixPath(p) {
|
|
704
|
+
return p.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
705
|
+
}
|
|
706
|
+
function getDirs(struct) {
|
|
707
|
+
const manifestDir = asAbsolute(__rspack_external_node_path_c5b9b54f.dirname(struct.manifestPath));
|
|
708
|
+
const projectManifestPath = struct.packageJsonPath || struct.denoJsonPath;
|
|
709
|
+
const packageJsonDir = asAbsolute(projectManifestPath ? __rspack_external_node_path_c5b9b54f.dirname(projectManifestPath) : manifestDir);
|
|
710
|
+
return {
|
|
711
|
+
manifestDir,
|
|
712
|
+
packageJsonDir
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
function getNodeModulesDir(packageJsonDir) {
|
|
716
|
+
return asAbsolute(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'node_modules'));
|
|
717
|
+
}
|
|
718
|
+
function needsInstall(packageJsonDir) {
|
|
719
|
+
const nm = getNodeModulesDir(packageJsonDir);
|
|
720
|
+
const hasManifest = PROJECT_MANIFEST_FILENAMES.some((filename)=>__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, filename)));
|
|
721
|
+
if (!hasManifest) return false;
|
|
722
|
+
try {
|
|
723
|
+
const deps = Object.keys(readProjectDependencies(packageJsonDir));
|
|
724
|
+
if (0 === deps.length) return false;
|
|
725
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(nm)) return true;
|
|
726
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.pnpm'))) return false;
|
|
727
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.modules.yaml'))) return false;
|
|
728
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, '.deno'))) return false;
|
|
729
|
+
const hasInstalledDep = deps.some((dep)=>__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(nm, dep)));
|
|
730
|
+
return !hasInstalledDep;
|
|
731
|
+
} catch {
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
const KNOWN_BROWSER_NAMES = new Set([
|
|
736
|
+
'chrome',
|
|
737
|
+
'edge',
|
|
738
|
+
'chromium',
|
|
739
|
+
'brave',
|
|
740
|
+
'opera',
|
|
741
|
+
'vivaldi',
|
|
742
|
+
'yandex',
|
|
743
|
+
'chromium-based',
|
|
744
|
+
'firefox',
|
|
745
|
+
'waterfox',
|
|
746
|
+
'librewolf',
|
|
747
|
+
'gecko-based',
|
|
748
|
+
'firefox-based',
|
|
749
|
+
'safari',
|
|
750
|
+
'webkit-based'
|
|
751
|
+
]);
|
|
752
|
+
function isKnownBrowserName(name) {
|
|
753
|
+
return 'string' == typeof name && KNOWN_BROWSER_NAMES.has(name);
|
|
754
|
+
}
|
|
755
|
+
function configBrowserOrThrow(configBrowser, command) {
|
|
756
|
+
if (null == configBrowser) return;
|
|
757
|
+
if (!isKnownBrowserName(configBrowser)) throw new Error(`Unsupported browser in extension.config commands.${command}.browser: ${String(configBrowser)}`);
|
|
758
|
+
return configBrowser;
|
|
759
|
+
}
|
|
760
|
+
function normalizeBrowser(browser, chromiumBinary, geckoBinary, safariBinary) {
|
|
761
|
+
const requested = String(browser || '');
|
|
762
|
+
if (chromiumBinary) {
|
|
763
|
+
if (!requested || 'chromium-based' === requested) return 'chromium-based';
|
|
764
|
+
if ('chromium' === requested) return 'chromium';
|
|
765
|
+
if ('edge' === requested) return 'edge';
|
|
766
|
+
if ('chrome' === requested) return 'chrome';
|
|
767
|
+
}
|
|
768
|
+
if (geckoBinary) {
|
|
769
|
+
if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
|
|
770
|
+
if ('firefox' === requested) return 'firefox';
|
|
771
|
+
}
|
|
772
|
+
if (safariBinary) {
|
|
773
|
+
if (!requested || 'webkit-based' === requested) return 'webkit-based';
|
|
774
|
+
if ('safari' === requested) return 'safari';
|
|
775
|
+
}
|
|
776
|
+
switch(requested){
|
|
777
|
+
case 'chrome':
|
|
778
|
+
return 'chrome';
|
|
779
|
+
case 'edge':
|
|
780
|
+
return 'edge';
|
|
781
|
+
case 'chromium':
|
|
782
|
+
return 'chromium';
|
|
783
|
+
case 'brave':
|
|
784
|
+
return 'brave';
|
|
785
|
+
case 'opera':
|
|
786
|
+
return 'opera';
|
|
787
|
+
case 'vivaldi':
|
|
788
|
+
return 'vivaldi';
|
|
789
|
+
case 'yandex':
|
|
790
|
+
return 'yandex';
|
|
791
|
+
case 'chromium-based':
|
|
792
|
+
return 'chromium-based';
|
|
793
|
+
case 'firefox':
|
|
794
|
+
return 'firefox';
|
|
795
|
+
case 'waterfox':
|
|
796
|
+
return 'waterfox';
|
|
797
|
+
case 'librewolf':
|
|
798
|
+
return 'librewolf';
|
|
799
|
+
case 'gecko-based':
|
|
800
|
+
case 'firefox-based':
|
|
801
|
+
return 'gecko-based';
|
|
802
|
+
case 'safari':
|
|
803
|
+
return 'safari';
|
|
804
|
+
case 'webkit-based':
|
|
805
|
+
return 'webkit-based';
|
|
806
|
+
default:
|
|
807
|
+
return 'chrome';
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function getDistPath(packageJsonDir, browser) {
|
|
811
|
+
return asAbsolute(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist', browser));
|
|
812
|
+
}
|
|
813
|
+
function computePreviewOutputPath(struct, browser, explicitOutputPath) {
|
|
814
|
+
const { manifestDir, packageJsonDir } = getDirs(struct);
|
|
815
|
+
if (explicitOutputPath) return asAbsolute(explicitOutputPath);
|
|
816
|
+
if (struct.packageJsonPath || struct.denoJsonPath) {
|
|
817
|
+
const distDir = getDistPath(packageJsonDir, browser);
|
|
818
|
+
try {
|
|
819
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(distDir, 'manifest.json'))) return distDir;
|
|
820
|
+
} catch {}
|
|
821
|
+
}
|
|
822
|
+
return manifestDir;
|
|
823
|
+
}
|
|
824
|
+
function devtoolsEngineFor(browser) {
|
|
825
|
+
switch(browser){
|
|
826
|
+
case 'chrome':
|
|
827
|
+
return 'chrome';
|
|
828
|
+
case 'edge':
|
|
829
|
+
return 'edge';
|
|
830
|
+
case 'chromium':
|
|
831
|
+
case 'chromium-based':
|
|
832
|
+
case 'brave':
|
|
833
|
+
case 'opera':
|
|
834
|
+
case 'vivaldi':
|
|
835
|
+
case 'yandex':
|
|
836
|
+
return 'chromium';
|
|
837
|
+
case 'firefox':
|
|
838
|
+
case 'gecko-based':
|
|
839
|
+
case 'waterfox':
|
|
840
|
+
case 'librewolf':
|
|
841
|
+
return 'firefox';
|
|
842
|
+
case 'safari':
|
|
843
|
+
case 'webkit-based':
|
|
844
|
+
return 'safari';
|
|
845
|
+
default:
|
|
846
|
+
return 'chrome';
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
function sessionStateDir(projectPath) {
|
|
850
|
+
return __rspack_external_node_path_c5b9b54f.resolve(projectPath, '.extension-js');
|
|
851
|
+
}
|
|
852
|
+
function controlPortFilePath(projectPath, browser) {
|
|
853
|
+
return __rspack_external_node_path_c5b9b54f.join(sessionStateDir(projectPath), `control-port-${browser}`);
|
|
854
|
+
}
|
|
855
|
+
function legacyControlPortFilePath(projectPath, browser) {
|
|
856
|
+
return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'control-port');
|
|
857
|
+
}
|
|
858
|
+
function controlTokenPath(projectPath, browser) {
|
|
859
|
+
return __rspack_external_node_path_c5b9b54f.join(sessionStateDir(projectPath), `control-token-${browser}`);
|
|
860
|
+
}
|
|
861
|
+
function legacyControlTokenPath(projectPath) {
|
|
862
|
+
return __rspack_external_node_path_c5b9b54f.join(sessionStateDir(projectPath), 'control.token');
|
|
863
|
+
}
|
|
864
|
+
function sessionArtifactsRootDir(projectPath) {
|
|
865
|
+
return __rspack_external_node_path_c5b9b54f.resolve(projectPath, 'dist', 'extension-js');
|
|
866
|
+
}
|
|
867
|
+
const SESSION_ARTIFACTS_IGNORE_CONTENT = "# Extension.js session state: managed browser profiles (cookies, history,\n# logins), session logs and machine contracts. Personal data lives here:\n# this directory must never be committed or shipped.\n*\n";
|
|
868
|
+
function sessionArtifactsIgnoreFilePath(projectPath) {
|
|
869
|
+
return __rspack_external_node_path_c5b9b54f.join(sessionArtifactsRootDir(projectPath), '.gitignore');
|
|
870
|
+
}
|
|
871
|
+
function ensureSessionArtifactsIgnoreFile(projectPath) {
|
|
872
|
+
try {
|
|
873
|
+
const ignoreFile = sessionArtifactsIgnoreFilePath(projectPath);
|
|
874
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(ignoreFile)) return;
|
|
875
|
+
__rspack_external_node_fs_5ea92f0c.mkdirSync(__rspack_external_node_path_c5b9b54f.dirname(ignoreFile), {
|
|
876
|
+
recursive: true
|
|
877
|
+
});
|
|
878
|
+
__rspack_external_node_fs_5ea92f0c.writeFileSync(ignoreFile, SESSION_ARTIFACTS_IGNORE_CONTENT);
|
|
879
|
+
} catch {}
|
|
880
|
+
}
|
|
881
|
+
function isAlreadyIgnoredByGit(projectPath) {
|
|
882
|
+
try {
|
|
883
|
+
const result = spawnSync('git', [
|
|
884
|
+
'check-ignore',
|
|
885
|
+
'-q',
|
|
886
|
+
'--',
|
|
887
|
+
'.extension-js/'
|
|
888
|
+
], {
|
|
889
|
+
cwd: projectPath,
|
|
890
|
+
stdio: 'ignore'
|
|
891
|
+
});
|
|
892
|
+
return 0 === result.status;
|
|
893
|
+
} catch {
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
function ensureSessionStateInProjectGitignore(projectPath) {
|
|
898
|
+
try {
|
|
899
|
+
const gitignorePath = __rspack_external_node_path_c5b9b54f.resolve(projectPath, '.gitignore');
|
|
900
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(gitignorePath)) return;
|
|
901
|
+
const content = __rspack_external_node_fs_5ea92f0c.readFileSync(gitignorePath, 'utf8');
|
|
902
|
+
const lines = content.split(/\r?\n/).map((line)=>line.trim());
|
|
903
|
+
if (lines.includes('.extension-js') || lines.includes('.extension-js/')) return;
|
|
904
|
+
if (isAlreadyIgnoredByGit(projectPath)) return;
|
|
905
|
+
const prefix = content.length > 0 && !content.endsWith('\n') ? '\n' : '';
|
|
906
|
+
__rspack_external_node_fs_5ea92f0c.appendFileSync(gitignorePath, `${prefix}\n# Extension.js local session state\n.extension-js\n`);
|
|
907
|
+
} catch {}
|
|
908
|
+
}
|
|
909
|
+
function browserArtifactsDir(projectPath, browser) {
|
|
910
|
+
return __rspack_external_node_path_c5b9b54f.join(sessionArtifactsRootDir(projectPath), browser);
|
|
911
|
+
}
|
|
912
|
+
function browserProfileRootDir(projectPath, browser) {
|
|
913
|
+
return __rspack_external_node_path_c5b9b54f.join(sessionArtifactsRootDir(projectPath), 'profiles', `${browser}-profile`);
|
|
914
|
+
}
|
|
915
|
+
function browserDistDir(projectPath, browser) {
|
|
916
|
+
return __rspack_external_node_path_c5b9b54f.resolve(projectPath, 'dist', browser);
|
|
917
|
+
}
|
|
918
|
+
function readyContractPath(projectPath, browser) {
|
|
919
|
+
return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'ready.json');
|
|
920
|
+
}
|
|
921
|
+
function eventsPath(projectPath, browser) {
|
|
922
|
+
return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'events.ndjson');
|
|
923
|
+
}
|
|
924
|
+
function logsPath(projectPath, browser) {
|
|
925
|
+
return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'logs.ndjson');
|
|
926
|
+
}
|
|
927
|
+
function actionsPath(projectPath, browser) {
|
|
928
|
+
return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'actions.ndjson');
|
|
929
|
+
}
|
|
930
|
+
function buildSummaryPath(projectPath, browser) {
|
|
931
|
+
return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'build-summary.json');
|
|
932
|
+
}
|
|
933
|
+
export { actionsPath, anotherDevSessionActive, asAbsolute, authorInstallNotice, browserArtifactsDir, browserDistDir, browserLaunchFailed, browserProfileRootDir, buildAssetsTree, buildCommandFailed, buildComplete, buildFailed, buildShareHint, buildSummaryPath, buildWarningsDetails, computePreviewOutputPath, configBrowserOrThrow, configLoadingError, controlPortFilePath, controlTokenPath, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, debugPreviewOutput, devCommandFailed, devtoolsEngineFor, downloadingText, ensureSessionArtifactsIgnoreFile, ensureSessionStateInProjectGitignore, eventsPath, extensionLoadRecovered, extensionLoadStillRefused, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, invalidRemoteZip, isUsingExperimentalConfig, legacyControlPortFilePath, legacyControlTokenPath, localZipNotFound, logsPath, managedDependencyConflict, manifestInvalidJson, needsInstall, noCompanionExtensionsResolved, normalizeBrowser, notAZipArchive, packagingDistributionFiles, packagingSourceFiles, previewing, previewingCustomOutput, previewingSourceFallback, projectInstallFallbackToNpm, projectInstallScriptsDisabled, readyContractPath, resolveProjectStructureSync, sessionArtifactsRootDir, sessionStateDir, starting, toPosixPath, treeWithDistFilesBrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError, zipArtifactReady };
|