extension-develop 3.14.5 → 3.15.0-next.1
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/{481.cjs → 221.cjs} +1 -1
- package/dist/{750.cjs → 504.cjs} +2 -2
- package/dist/{740.cjs → 512.cjs} +5 -4
- package/dist/{893.cjs → 787.cjs} +1 -1
- package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chrome/content_scripts/styles.305cf4cf.css +2 -0
- package/dist/extension-js-devtools/chrome/devtools/index.js +1 -1
- package/dist/extension-js-devtools/chrome/manifest.json +1 -1
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/chrome/scripts/logger-client.js +0 -1
- package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chromium/content_scripts/styles.305cf4cf.css +2 -0
- package/dist/extension-js-devtools/chromium/devtools/index.js +1 -1
- package/dist/extension-js-devtools/chromium/manifest.json +1 -1
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/chromium/scripts/logger-client.js +0 -1
- package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/edge/content_scripts/styles.305cf4cf.css +2 -0
- package/dist/extension-js-devtools/edge/devtools/index.js +1 -1
- package/dist/extension-js-devtools/edge/manifest.json +1 -1
- package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/edge/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/edge/scripts/logger-client.js +0 -1
- package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
- package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/firefox/content_scripts/styles.305cf4cf.css +2 -0
- package/dist/extension-js-devtools/firefox/devtools/index.js +1 -1
- package/dist/extension-js-devtools/firefox/manifest.json +1 -2
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/firefox/scripts/logger-client.js +0 -1
- package/dist/module.cjs +1800 -1792
- package/dist/preview.cjs +1187 -1187
- package/package.json +10 -10
- package/dist/extension-js-devtools/chrome/content_scripts/styles.5456c644.css +0 -2
- package/dist/extension-js-devtools/chromium/content_scripts/styles.5456c644.css +0 -2
- package/dist/extension-js-devtools/edge/content_scripts/styles.5456c644.css +0 -2
- package/dist/extension-js-devtools/firefox/content_scripts/styles.5456c644.css +0 -2
package/dist/preview.cjs
CHANGED
|
@@ -137,1302 +137,1302 @@ var __webpack_modules__ = {
|
|
|
137
137
|
return `${getLoggingPrefix('error')} Your project declares dependencies that are managed by ${pintor__rspack_import_2_default().blue('Extension.js')} and referenced in ${pintor__rspack_import_2_default().underline('extension.config.js')}\n${pintor__rspack_import_2_default().red('This can cause version conflicts and break the development/build process.')}\n\n${pintor__rspack_import_2_default().gray('Managed dependencies (remove these from your package.json):')}\n${list}\n\n${pintor__rspack_import_2_default().gray('PATH')} ${pintor__rspack_import_2_default().underline(userPackageJsonPath)}\nIf you need a different version, open an issue so we can consider bundling it safely.\nOperation aborted.`;
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
module.exports = require("fs");
|
|
145
|
-
},
|
|
146
|
-
path (module) {
|
|
147
|
-
module.exports = require("path");
|
|
148
|
-
},
|
|
149
|
-
pintor (module) {
|
|
150
|
-
module.exports = require("pintor");
|
|
151
|
-
},
|
|
152
|
-
"./package.json" (module) {
|
|
153
|
-
module.exports = JSON.parse('{"rE":"3.14.5","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^1.7.5","@rspack/dev-server":"^1.2.1","@rspack/plugin-preact-refresh":"1.1.4","@rspack/plugin-react-refresh":"1.6.0","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.0","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.6","postcss-loader":"8.2.0","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.6","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","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"}}');
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
var __webpack_module_cache__ = {};
|
|
157
|
-
function __webpack_require__(moduleId) {
|
|
158
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
159
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
160
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
161
|
-
exports: {}
|
|
162
|
-
};
|
|
163
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
164
|
-
return module.exports;
|
|
165
|
-
}
|
|
166
|
-
__webpack_require__.m = __webpack_modules__;
|
|
167
|
-
(()=>{
|
|
168
|
-
__webpack_require__.n = (module)=>{
|
|
169
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
170
|
-
__webpack_require__.d(getter, {
|
|
171
|
-
a: getter
|
|
172
|
-
});
|
|
173
|
-
return getter;
|
|
174
|
-
};
|
|
175
|
-
})();
|
|
176
|
-
(()=>{
|
|
177
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
178
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
179
|
-
enumerable: true,
|
|
180
|
-
get: definition[key]
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
})();
|
|
184
|
-
(()=>{
|
|
185
|
-
__webpack_require__.f = {};
|
|
186
|
-
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
187
|
-
__webpack_require__.f[key](chunkId, promises);
|
|
188
|
-
return promises;
|
|
189
|
-
}, []));
|
|
190
|
-
})();
|
|
191
|
-
(()=>{
|
|
192
|
-
__webpack_require__.u = (chunkId)=>"" + chunkId + ".cjs";
|
|
193
|
-
})();
|
|
194
|
-
(()=>{
|
|
195
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
196
|
-
})();
|
|
197
|
-
(()=>{
|
|
198
|
-
__webpack_require__.r = (exports1)=>{
|
|
199
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
200
|
-
value: 'Module'
|
|
201
|
-
});
|
|
202
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
203
|
-
value: true
|
|
140
|
+
"./preview-entry.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
141
|
+
__webpack_require__.r(__webpack_exports__);
|
|
142
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
143
|
+
extensionPreview: ()=>extensionPreview
|
|
204
144
|
});
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
var __webpack_exports__ = {};
|
|
222
|
-
(()=>{
|
|
223
|
-
__webpack_require__.r(__webpack_exports__);
|
|
224
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
225
|
-
extensionPreview: ()=>extensionPreview
|
|
226
|
-
});
|
|
227
|
-
var external_path_ = __webpack_require__("path");
|
|
228
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_);
|
|
229
|
-
var external_fs_ = __webpack_require__("fs");
|
|
230
|
-
var lib_messages = __webpack_require__("./lib/messages.ts");
|
|
231
|
-
async function findUpLocal(filename, options) {
|
|
232
|
-
const root = external_path_.parse(options.cwd).root;
|
|
233
|
-
let currentDir = options.cwd;
|
|
234
|
-
while(true){
|
|
235
|
-
const candidate = external_path_.join(currentDir, filename);
|
|
236
|
-
try {
|
|
237
|
-
const stat = await external_fs_.promises.stat(candidate);
|
|
238
|
-
if (stat.isFile()) return candidate;
|
|
239
|
-
} catch {}
|
|
240
|
-
if (currentDir === root) return;
|
|
241
|
-
currentDir = external_path_.dirname(currentDir);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
async function findNearestPackageJson(manifestPath) {
|
|
245
|
-
try {
|
|
246
|
-
const manifestDir = external_path_.dirname(manifestPath);
|
|
247
|
-
const packageJsonPath = await findUpLocal('package.json', {
|
|
248
|
-
cwd: manifestDir
|
|
249
|
-
});
|
|
250
|
-
return packageJsonPath || null;
|
|
251
|
-
} catch (error) {
|
|
252
|
-
console.warn('Failed to find package.json:', error);
|
|
253
|
-
return null;
|
|
145
|
+
var external_path_ = __webpack_require__("path");
|
|
146
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_);
|
|
147
|
+
var external_fs_ = __webpack_require__("fs");
|
|
148
|
+
var lib_messages = __webpack_require__("./lib/messages.ts");
|
|
149
|
+
async function findUpLocal(filename, options) {
|
|
150
|
+
const root = external_path_.parse(options.cwd).root;
|
|
151
|
+
let currentDir = options.cwd;
|
|
152
|
+
while(true){
|
|
153
|
+
const candidate = external_path_.join(currentDir, filename);
|
|
154
|
+
try {
|
|
155
|
+
const stat = await external_fs_.promises.stat(candidate);
|
|
156
|
+
if (stat.isFile()) return candidate;
|
|
157
|
+
} catch {}
|
|
158
|
+
if (currentDir === root) return;
|
|
159
|
+
currentDir = external_path_.dirname(currentDir);
|
|
160
|
+
}
|
|
254
161
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
162
|
+
async function findNearestPackageJson(manifestPath) {
|
|
163
|
+
try {
|
|
164
|
+
const manifestDir = external_path_.dirname(manifestPath);
|
|
165
|
+
const packageJsonPath = await findUpLocal('package.json', {
|
|
166
|
+
cwd: manifestDir
|
|
167
|
+
});
|
|
168
|
+
return packageJsonPath || null;
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.warn('Failed to find package.json:', error);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
265
173
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
174
|
+
function validatePackageJson(packageJsonPath) {
|
|
175
|
+
try {
|
|
176
|
+
if (!external_fs_.existsSync(packageJsonPath)) return false;
|
|
177
|
+
const content = external_fs_.readFileSync(packageJsonPath, 'utf-8');
|
|
178
|
+
JSON.parse(content);
|
|
179
|
+
return true;
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.warn('Invalid package.json at:', packageJsonPath, error);
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
273
184
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
];
|
|
294
|
-
while(stack.length){
|
|
295
|
-
const current = stack.pop();
|
|
296
|
-
const items = external_fs_.readdirSync(current, {
|
|
297
|
-
withFileTypes: true
|
|
298
|
-
});
|
|
299
|
-
for (const it of items){
|
|
300
|
-
if (it.isFile() && 'manifest.json' === it.name) return true;
|
|
301
|
-
if (it.isDirectory() && 'node_modules' !== it.name && 'dist' !== it.name && !it.name.startsWith('.')) stack.push(external_path_.join(current, it.name));
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return false;
|
|
305
|
-
};
|
|
306
|
-
if (hasManifest(expectedPath)) return expectedPath;
|
|
307
|
-
external_fs_.rmSync(expectedPath, {
|
|
185
|
+
const isUrl = (url)=>{
|
|
186
|
+
try {
|
|
187
|
+
new URL(url);
|
|
188
|
+
return true;
|
|
189
|
+
} catch (e) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
async function importUrlSourceFromGithub(pathOrRemoteUrl, text) {
|
|
194
|
+
const cwd = process.cwd();
|
|
195
|
+
const url = new URL(pathOrRemoteUrl);
|
|
196
|
+
const segments = url.pathname.split('/').filter(Boolean);
|
|
197
|
+
const repoName = segments.length >= 2 ? segments[1] : segments[segments.length - 1];
|
|
198
|
+
const treeIndex = segments.indexOf('tree');
|
|
199
|
+
const expectedName = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments[segments.length - 1] : repoName;
|
|
200
|
+
const expectedPath = external_path_.resolve(cwd, expectedName);
|
|
201
|
+
if (external_fs_.existsSync(expectedPath)) try {
|
|
202
|
+
const entries = external_fs_.readdirSync(expectedPath);
|
|
203
|
+
if (0 === entries.length) external_fs_.rmSync(expectedPath, {
|
|
308
204
|
recursive: true,
|
|
309
205
|
force: true
|
|
310
206
|
});
|
|
207
|
+
else {
|
|
208
|
+
const hasManifest = (dir)=>{
|
|
209
|
+
const stack = [
|
|
210
|
+
dir
|
|
211
|
+
];
|
|
212
|
+
while(stack.length){
|
|
213
|
+
const current = stack.pop();
|
|
214
|
+
const items = external_fs_.readdirSync(current, {
|
|
215
|
+
withFileTypes: true
|
|
216
|
+
});
|
|
217
|
+
for (const it of items){
|
|
218
|
+
if (it.isFile() && 'manifest.json' === it.name) return true;
|
|
219
|
+
if (it.isDirectory() && 'node_modules' !== it.name && 'dist' !== it.name && !it.name.startsWith('.')) stack.push(external_path_.join(current, it.name));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
};
|
|
224
|
+
if (hasManifest(expectedPath)) return expectedPath;
|
|
225
|
+
external_fs_.rmSync(expectedPath, {
|
|
226
|
+
recursive: true,
|
|
227
|
+
force: true
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
} catch {}
|
|
231
|
+
async function tryGitClone() {
|
|
232
|
+
const { default: goGitIt } = await import("go-git-it");
|
|
233
|
+
await goGitIt(pathOrRemoteUrl, cwd, text);
|
|
234
|
+
}
|
|
235
|
+
async function tryZipFallback() {
|
|
236
|
+
const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
|
|
237
|
+
const owner = segments[0];
|
|
238
|
+
const repo = segments[1];
|
|
239
|
+
const subdir = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments.slice(treeIndex + 2).join('/') : '';
|
|
240
|
+
const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${branch}`;
|
|
241
|
+
const extractedPath = await importUrlSourceFromZip(zipUrl);
|
|
242
|
+
const extractedDirs = external_fs_.readdirSync(extractedPath, {
|
|
243
|
+
withFileTypes: true
|
|
244
|
+
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
245
|
+
const repoRootDir = extractedDirs.find((d)=>d.startsWith(`${repo}-${branch}`));
|
|
246
|
+
const repoRoot = repoRootDir ? external_path_.join(extractedPath, repoRootDir) : extractedPath;
|
|
247
|
+
return subdir ? external_path_.join(repoRoot, subdir) : repoRoot;
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
await tryGitClone();
|
|
251
|
+
} catch {
|
|
252
|
+
return await tryZipFallback();
|
|
253
|
+
}
|
|
254
|
+
const candidates = [];
|
|
255
|
+
if (-1 !== treeIndex && segments.length > treeIndex + 2) candidates.push(segments[segments.length - 1]);
|
|
256
|
+
candidates.push(repoName);
|
|
257
|
+
for (const name of candidates){
|
|
258
|
+
const p = external_path_.resolve(cwd, name);
|
|
259
|
+
if (external_fs_.existsSync(p)) return p;
|
|
311
260
|
}
|
|
312
|
-
} catch {}
|
|
313
|
-
async function tryGitClone() {
|
|
314
|
-
const { default: goGitIt } = await import("go-git-it");
|
|
315
|
-
await goGitIt(pathOrRemoteUrl, cwd, text);
|
|
316
|
-
}
|
|
317
|
-
async function tryZipFallback() {
|
|
318
|
-
const branch = -1 !== treeIndex && segments.length > treeIndex + 1 ? segments[treeIndex + 1] : 'main';
|
|
319
|
-
const owner = segments[0];
|
|
320
|
-
const repo = segments[1];
|
|
321
|
-
const subdir = -1 !== treeIndex && segments.length > treeIndex + 2 ? segments.slice(treeIndex + 2).join('/') : '';
|
|
322
|
-
const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${branch}`;
|
|
323
|
-
const extractedPath = await importUrlSourceFromZip(zipUrl);
|
|
324
|
-
const extractedDirs = external_fs_.readdirSync(extractedPath, {
|
|
325
|
-
withFileTypes: true
|
|
326
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
327
|
-
const repoRootDir = extractedDirs.find((d)=>d.startsWith(`${repo}-${branch}`));
|
|
328
|
-
const repoRoot = repoRootDir ? external_path_.join(extractedPath, repoRootDir) : extractedPath;
|
|
329
|
-
return subdir ? external_path_.join(repoRoot, subdir) : repoRoot;
|
|
330
|
-
}
|
|
331
|
-
try {
|
|
332
|
-
await tryGitClone();
|
|
333
|
-
} catch {
|
|
334
|
-
return await tryZipFallback();
|
|
335
|
-
}
|
|
336
|
-
const candidates = [];
|
|
337
|
-
if (-1 !== treeIndex && segments.length > treeIndex + 2) candidates.push(segments[segments.length - 1]);
|
|
338
|
-
candidates.push(repoName);
|
|
339
|
-
for (const name of candidates){
|
|
340
|
-
const p = external_path_.resolve(cwd, name);
|
|
341
|
-
if (external_fs_.existsSync(p)) return p;
|
|
342
|
-
}
|
|
343
|
-
const dirs = external_fs_.readdirSync(cwd, {
|
|
344
|
-
withFileTypes: true
|
|
345
|
-
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
346
|
-
for (const dir of dirs){
|
|
347
|
-
const manifestPath = external_path_.join(cwd, dir, 'manifest.json');
|
|
348
|
-
if (external_fs_.existsSync(manifestPath)) return external_path_.join(cwd, dir);
|
|
349
|
-
}
|
|
350
|
-
try {
|
|
351
261
|
const dirs = external_fs_.readdirSync(cwd, {
|
|
352
262
|
withFileTypes: true
|
|
353
263
|
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
264
|
+
for (const dir of dirs){
|
|
265
|
+
const manifestPath = external_path_.join(cwd, dir, 'manifest.json');
|
|
266
|
+
if (external_fs_.existsSync(manifestPath)) return external_path_.join(cwd, dir);
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
const dirs = external_fs_.readdirSync(cwd, {
|
|
270
|
+
withFileTypes: true
|
|
271
|
+
}).filter((d)=>d.isDirectory()).map((d)=>d.name);
|
|
272
|
+
const ghRoot = dirs.find((d)=>/-main$|-master$/.test(d));
|
|
273
|
+
if (ghRoot) return external_path_.join(cwd, ghRoot);
|
|
274
|
+
} catch {}
|
|
275
|
+
throw new Error(lib_messages.ax(cwd, candidates));
|
|
276
|
+
}
|
|
277
|
+
async function importUrlSourceFromZip(pathOrRemoteUrl) {
|
|
278
|
+
const cwd = process.cwd();
|
|
279
|
+
const { downloadAndExtractZip } = await __webpack_require__.e(787).then(__webpack_require__.bind(__webpack_require__, "./lib/zip.ts"));
|
|
280
|
+
const extractedPath = await downloadAndExtractZip(pathOrRemoteUrl, cwd);
|
|
281
|
+
return extractedPath;
|
|
282
|
+
}
|
|
283
|
+
async function getProjectPath(pathOrRemoteUrl) {
|
|
284
|
+
if (!pathOrRemoteUrl) return process.cwd();
|
|
285
|
+
if (isUrl(pathOrRemoteUrl)) {
|
|
286
|
+
const url = new URL(pathOrRemoteUrl);
|
|
287
|
+
if (url.protocol.startsWith('http')) {
|
|
288
|
+
const pathname = url.pathname.toLowerCase();
|
|
289
|
+
if (pathname.endsWith('.zip')) return await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
290
|
+
if ('https://github.com' !== url.origin) {
|
|
291
|
+
const urlSource = await importUrlSourceFromZip(pathOrRemoteUrl);
|
|
292
|
+
return urlSource;
|
|
293
|
+
}
|
|
294
|
+
const urlData = url.pathname.split('/');
|
|
295
|
+
const owner = urlData.slice(1, 3)[0];
|
|
296
|
+
const project = urlData.slice(1, 3)[1];
|
|
297
|
+
console.log(lib_messages.tQ(owner, project));
|
|
298
|
+
const projectName = external_path_.basename(url.pathname);
|
|
299
|
+
const urlSource = await importUrlSourceFromGithub(pathOrRemoteUrl, lib_messages.F$(projectName));
|
|
300
|
+
console.log(lib_messages.W4(url.pathname));
|
|
374
301
|
return urlSource;
|
|
375
302
|
}
|
|
376
|
-
const urlData = url.pathname.split('/');
|
|
377
|
-
const owner = urlData.slice(1, 3)[0];
|
|
378
|
-
const project = urlData.slice(1, 3)[1];
|
|
379
|
-
console.log(lib_messages.tQ(owner, project));
|
|
380
|
-
const projectName = external_path_.basename(url.pathname);
|
|
381
|
-
const urlSource = await importUrlSourceFromGithub(pathOrRemoteUrl, lib_messages.F$(projectName));
|
|
382
|
-
console.log(lib_messages.W4(url.pathname));
|
|
383
|
-
return urlSource;
|
|
384
303
|
}
|
|
304
|
+
return external_path_.resolve(process.cwd(), pathOrRemoteUrl);
|
|
385
305
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (found) return found;
|
|
306
|
+
async function getProjectStructure(pathOrRemoteUrl) {
|
|
307
|
+
const projectPath = await getProjectPath(pathOrRemoteUrl);
|
|
308
|
+
const isUnderDir = (baseDir, candidatePath)=>{
|
|
309
|
+
const rel = external_path_.relative(baseDir, candidatePath);
|
|
310
|
+
return Boolean(rel && !rel.startsWith('..') && !external_path_.isAbsolute(rel));
|
|
311
|
+
};
|
|
312
|
+
const packageJsonPathFromProject = await findNearestPackageJson(external_path_.join(projectPath, 'manifest.json'));
|
|
313
|
+
const packageJsonDirFromProject = packageJsonPathFromProject ? external_path_.dirname(packageJsonPathFromProject) : void 0;
|
|
314
|
+
const rootManifestPath = external_path_.join(projectPath, 'manifest.json');
|
|
315
|
+
const srcManifestPath = external_path_.join(projectPath, 'src', 'manifest.json');
|
|
316
|
+
let manifestPath = external_fs_.existsSync(srcManifestPath) ? srcManifestPath : rootManifestPath;
|
|
317
|
+
if (!external_fs_.existsSync(manifestPath)) {
|
|
318
|
+
if (packageJsonDirFromProject) throw new Error(lib_messages.dx(manifestPath));
|
|
319
|
+
const findManifest = (dir)=>{
|
|
320
|
+
const files = external_fs_.readdirSync(dir, {
|
|
321
|
+
withFileTypes: true
|
|
322
|
+
});
|
|
323
|
+
for (const file of files){
|
|
324
|
+
if (file.isFile() && 'manifest.json' === file.name) return external_path_.join(dir, file.name);
|
|
325
|
+
if (file.isDirectory() && !file.name.startsWith('.') && 'node_modules' !== file.name && 'dist' !== file.name && 'public' !== file.name) {
|
|
326
|
+
const found = findManifest(external_path_.join(dir, file.name));
|
|
327
|
+
if (found) return found;
|
|
328
|
+
}
|
|
410
329
|
}
|
|
330
|
+
return null;
|
|
331
|
+
};
|
|
332
|
+
const foundManifest = findManifest(projectPath);
|
|
333
|
+
if (foundManifest) manifestPath = foundManifest;
|
|
334
|
+
else throw new Error(lib_messages.dx(manifestPath));
|
|
335
|
+
}
|
|
336
|
+
const packageJsonPath = await findNearestPackageJson(manifestPath);
|
|
337
|
+
const packageJsonDir = packageJsonPath ? external_path_.dirname(packageJsonPath) : void 0;
|
|
338
|
+
if (packageJsonDir) {
|
|
339
|
+
const publicRoot = external_path_.join(packageJsonDir, 'public');
|
|
340
|
+
if (isUnderDir(publicRoot, manifestPath)) {
|
|
341
|
+
const fallbackSrc = external_path_.join(packageJsonDir, 'src', 'manifest.json');
|
|
342
|
+
const fallbackRoot = external_path_.join(packageJsonDir, 'manifest.json');
|
|
343
|
+
if (external_fs_.existsSync(fallbackSrc)) manifestPath = fallbackSrc;
|
|
344
|
+
else if (external_fs_.existsSync(fallbackRoot)) manifestPath = fallbackRoot;
|
|
345
|
+
else throw new Error(lib_messages.dx(fallbackRoot));
|
|
411
346
|
}
|
|
412
|
-
return null;
|
|
413
|
-
};
|
|
414
|
-
const foundManifest = findManifest(projectPath);
|
|
415
|
-
if (foundManifest) manifestPath = foundManifest;
|
|
416
|
-
else throw new Error(lib_messages.dx(manifestPath));
|
|
417
|
-
}
|
|
418
|
-
const packageJsonPath = await findNearestPackageJson(manifestPath);
|
|
419
|
-
const packageJsonDir = packageJsonPath ? external_path_.dirname(packageJsonPath) : void 0;
|
|
420
|
-
if (packageJsonDir) {
|
|
421
|
-
const publicRoot = external_path_.join(packageJsonDir, 'public');
|
|
422
|
-
if (isUnderDir(publicRoot, manifestPath)) {
|
|
423
|
-
const fallbackSrc = external_path_.join(packageJsonDir, 'src', 'manifest.json');
|
|
424
|
-
const fallbackRoot = external_path_.join(packageJsonDir, 'manifest.json');
|
|
425
|
-
if (external_fs_.existsSync(fallbackSrc)) manifestPath = fallbackSrc;
|
|
426
|
-
else if (external_fs_.existsSync(fallbackRoot)) manifestPath = fallbackRoot;
|
|
427
|
-
else throw new Error(lib_messages.dx(fallbackRoot));
|
|
428
347
|
}
|
|
348
|
+
if (!packageJsonPath || !validatePackageJson(packageJsonPath)) return {
|
|
349
|
+
manifestPath
|
|
350
|
+
};
|
|
351
|
+
return {
|
|
352
|
+
manifestPath,
|
|
353
|
+
packageJsonPath
|
|
354
|
+
};
|
|
429
355
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
exports
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
function findNearestWorkspaceRoot(startDir) {
|
|
460
|
-
let current = external_path_.resolve(startDir);
|
|
461
|
-
while(true){
|
|
462
|
-
if (external_fs_.existsSync(external_path_.join(current, 'pnpm-workspace.yaml'))) return current;
|
|
463
|
-
const parent = external_path_.dirname(current);
|
|
464
|
-
if (parent === current) return;
|
|
465
|
-
current = parent;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
function preloadEnvFilesFromDir(envDir, options) {
|
|
469
|
-
let loadedAny = false;
|
|
470
|
-
try {
|
|
471
|
-
const defaultsPath = external_path_.join(envDir, '.env.defaults');
|
|
472
|
-
if (external_fs_.existsSync(defaultsPath)) {
|
|
473
|
-
external_dotenv_default().config({
|
|
474
|
-
path: defaultsPath,
|
|
475
|
-
override: Boolean(options?.override),
|
|
476
|
-
quiet: true
|
|
477
|
-
});
|
|
478
|
-
loadedAny = true;
|
|
356
|
+
const external_os_namespaceObject = require("os");
|
|
357
|
+
const external_vm_namespaceObject = require("vm");
|
|
358
|
+
const external_url_namespaceObject = require("url");
|
|
359
|
+
const external_module_namespaceObject = require("module");
|
|
360
|
+
const external_dotenv_namespaceObject = require("dotenv");
|
|
361
|
+
var external_dotenv_default = /*#__PURE__*/ __webpack_require__.n(external_dotenv_namespaceObject);
|
|
362
|
+
function loadCommonJsConfigWithStableDirname(absolutePath) {
|
|
363
|
+
const code = external_fs_.readFileSync(absolutePath, 'utf-8');
|
|
364
|
+
const dirname = external_path_.dirname(absolutePath);
|
|
365
|
+
const requireFn = (0, external_module_namespaceObject.createRequire)(absolutePath);
|
|
366
|
+
const module = {
|
|
367
|
+
exports: {}
|
|
368
|
+
};
|
|
369
|
+
const exports1 = module.exports;
|
|
370
|
+
const wrapped = `(function (exports, require, module, __filename, __dirname) {\n${code}\n})`;
|
|
371
|
+
const fn = new external_vm_namespaceObject.Script(wrapped, {
|
|
372
|
+
filename: absolutePath
|
|
373
|
+
}).runInThisContext();
|
|
374
|
+
fn(exports1, requireFn, module, absolutePath, dirname);
|
|
375
|
+
return module.exports?.default || module.exports;
|
|
376
|
+
}
|
|
377
|
+
function findNearestWorkspaceRoot(startDir) {
|
|
378
|
+
let current = external_path_.resolve(startDir);
|
|
379
|
+
while(true){
|
|
380
|
+
if (external_fs_.existsSync(external_path_.join(current, 'pnpm-workspace.yaml'))) return current;
|
|
381
|
+
const parent = external_path_.dirname(current);
|
|
382
|
+
if (parent === current) return;
|
|
383
|
+
current = parent;
|
|
479
384
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const filePath = external_path_.join(envDir, filename);
|
|
487
|
-
if (external_fs_.existsSync(filePath)) {
|
|
385
|
+
}
|
|
386
|
+
function preloadEnvFilesFromDir(envDir, options) {
|
|
387
|
+
let loadedAny = false;
|
|
388
|
+
try {
|
|
389
|
+
const defaultsPath = external_path_.join(envDir, '.env.defaults');
|
|
390
|
+
if (external_fs_.existsSync(defaultsPath)) {
|
|
488
391
|
external_dotenv_default().config({
|
|
489
|
-
path:
|
|
392
|
+
path: defaultsPath,
|
|
490
393
|
override: Boolean(options?.override),
|
|
491
394
|
quiet: true
|
|
492
395
|
});
|
|
493
396
|
loadedAny = true;
|
|
494
|
-
break;
|
|
495
397
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const local = preloadEnvFilesFromDir(projectDir);
|
|
513
|
-
if (local.loadedAny) return local;
|
|
514
|
-
const workspaceRoot = findNearestWorkspaceRoot(projectDir);
|
|
515
|
-
if (workspaceRoot && workspaceRoot !== projectDir) return preloadEnvFilesFromDir(workspaceRoot);
|
|
516
|
-
return local;
|
|
517
|
-
}
|
|
518
|
-
async function loadConfigFile(configPath) {
|
|
519
|
-
const absolutePath = external_path_.resolve(configPath);
|
|
520
|
-
const projectDir = external_path_.dirname(absolutePath);
|
|
521
|
-
preloadEnvFiles(projectDir);
|
|
522
|
-
try {
|
|
523
|
-
if (absolutePath.endsWith('.cjs')) {
|
|
524
|
-
const requireFn = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
525
|
-
const required = requireFn(absolutePath);
|
|
526
|
-
return required?.default || required;
|
|
527
|
-
}
|
|
528
|
-
let esmImportPath = absolutePath;
|
|
529
|
-
try {
|
|
530
|
-
const originalContent = external_fs_.readFileSync(absolutePath, 'utf-8');
|
|
531
|
-
if (originalContent.includes('import.meta.env')) {
|
|
532
|
-
const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_namespaceObject.tmpdir(), 'extension-config-esm-'));
|
|
533
|
-
const tmpPath = external_path_.join(tmpDir, external_path_.basename(absolutePath));
|
|
534
|
-
const envObjectLiteral = JSON.stringify(Object.fromEntries(Object.entries(process.env).map(([k, v])=>[
|
|
535
|
-
k,
|
|
536
|
-
v
|
|
537
|
-
])), null, 0);
|
|
538
|
-
const shimHeader = `const __IMPORT_META_ENV__ = Object.freeze(${envObjectLiteral});\n`;
|
|
539
|
-
const replaced = originalContent.replace(/import\.meta\.env/g, '__IMPORT_META_ENV__');
|
|
540
|
-
external_fs_.writeFileSync(tmpPath, `${shimHeader}${replaced}`, 'utf-8');
|
|
541
|
-
esmImportPath = tmpPath;
|
|
398
|
+
const envCandidates = [
|
|
399
|
+
'.env.development',
|
|
400
|
+
'.env.local',
|
|
401
|
+
'.env'
|
|
402
|
+
];
|
|
403
|
+
for (const filename of envCandidates){
|
|
404
|
+
const filePath = external_path_.join(envDir, filename);
|
|
405
|
+
if (external_fs_.existsSync(filePath)) {
|
|
406
|
+
external_dotenv_default().config({
|
|
407
|
+
path: filePath,
|
|
408
|
+
override: Boolean(options?.override),
|
|
409
|
+
quiet: true
|
|
410
|
+
});
|
|
411
|
+
loadedAny = true;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
542
414
|
}
|
|
543
415
|
} catch {}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
416
|
+
return {
|
|
417
|
+
loadedAny,
|
|
418
|
+
envDir
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function findConfigFile(projectPath) {
|
|
422
|
+
const candidates = [
|
|
423
|
+
external_path_.join(projectPath, 'extension.config.js'),
|
|
424
|
+
external_path_.join(projectPath, 'extension.config.mjs'),
|
|
425
|
+
external_path_.join(projectPath, 'extension.config.cjs')
|
|
426
|
+
];
|
|
427
|
+
return candidates.find((p)=>external_fs_.existsSync(p));
|
|
428
|
+
}
|
|
429
|
+
function preloadEnvFiles(projectDir) {
|
|
430
|
+
const local = preloadEnvFilesFromDir(projectDir);
|
|
431
|
+
if (local.loadedAny) return local;
|
|
432
|
+
const workspaceRoot = findNearestWorkspaceRoot(projectDir);
|
|
433
|
+
if (workspaceRoot && workspaceRoot !== projectDir) return preloadEnvFilesFromDir(workspaceRoot);
|
|
434
|
+
return local;
|
|
435
|
+
}
|
|
436
|
+
async function loadConfigFile(configPath) {
|
|
437
|
+
const absolutePath = external_path_.resolve(configPath);
|
|
438
|
+
const projectDir = external_path_.dirname(absolutePath);
|
|
439
|
+
preloadEnvFiles(projectDir);
|
|
548
440
|
try {
|
|
549
|
-
if (
|
|
441
|
+
if (absolutePath.endsWith('.cjs')) {
|
|
550
442
|
const requireFn = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
551
|
-
|
|
552
|
-
try {
|
|
553
|
-
required = requireFn(absolutePath);
|
|
554
|
-
} catch (requireErr) {
|
|
555
|
-
const message = String(error?.message || '') + ' ' + String(requireErr?.message || '');
|
|
556
|
-
const looksLikeCommonJsInEsm = message.includes('require is not defined in ES module scope') || message.includes('Cannot use import statement outside a module') || message.includes('ERR_REQUIRE_ESM');
|
|
557
|
-
if (looksLikeCommonJsInEsm) try {
|
|
558
|
-
required = loadCommonJsConfigWithStableDirname(absolutePath);
|
|
559
|
-
} catch {
|
|
560
|
-
const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_namespaceObject.tmpdir(), 'extension-config-'));
|
|
561
|
-
const tmpCjsPath = external_path_.join(tmpDir, external_path_.basename(absolutePath, external_path_.extname(absolutePath)) + '.cjs');
|
|
562
|
-
external_fs_.copyFileSync(absolutePath, tmpCjsPath);
|
|
563
|
-
required = requireFn(tmpCjsPath);
|
|
564
|
-
}
|
|
565
|
-
else throw requireErr;
|
|
566
|
-
}
|
|
443
|
+
const required = requireFn(absolutePath);
|
|
567
444
|
return required?.default || required;
|
|
568
445
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
transpilePackages: userConfig.transpilePackages
|
|
588
|
-
} : {};
|
|
589
|
-
const perCommand = userConfig && userConfig.commands && userConfig.commands[command] ? userConfig.commands[command] : {};
|
|
590
|
-
return {
|
|
591
|
-
...baseExtensions,
|
|
592
|
-
...baseTranspilePackages,
|
|
593
|
-
...perCommand
|
|
594
|
-
};
|
|
446
|
+
let esmImportPath = absolutePath;
|
|
447
|
+
try {
|
|
448
|
+
const originalContent = external_fs_.readFileSync(absolutePath, 'utf-8');
|
|
449
|
+
if (originalContent.includes('import.meta.env')) {
|
|
450
|
+
const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_namespaceObject.tmpdir(), 'extension-config-esm-'));
|
|
451
|
+
const tmpPath = external_path_.join(tmpDir, external_path_.basename(absolutePath));
|
|
452
|
+
const envObjectLiteral = JSON.stringify(Object.fromEntries(Object.entries(process.env).map(([k, v])=>[
|
|
453
|
+
k,
|
|
454
|
+
v
|
|
455
|
+
])), null, 0);
|
|
456
|
+
const shimHeader = `const __IMPORT_META_ENV__ = Object.freeze(${envObjectLiteral});\n`;
|
|
457
|
+
const replaced = originalContent.replace(/import\.meta\.env/g, '__IMPORT_META_ENV__');
|
|
458
|
+
external_fs_.writeFileSync(tmpPath, `${shimHeader}${replaced}`, 'utf-8');
|
|
459
|
+
esmImportPath = tmpPath;
|
|
460
|
+
}
|
|
461
|
+
} catch {}
|
|
462
|
+
const module = await import((0, external_url_namespaceObject.pathToFileURL)(esmImportPath).href);
|
|
463
|
+
return module.default || module;
|
|
595
464
|
} catch (err) {
|
|
596
465
|
const error = err;
|
|
597
|
-
|
|
598
|
-
|
|
466
|
+
try {
|
|
467
|
+
if (!absolutePath.endsWith('.mjs')) {
|
|
468
|
+
const requireFn = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
469
|
+
let required;
|
|
470
|
+
try {
|
|
471
|
+
required = requireFn(absolutePath);
|
|
472
|
+
} catch (requireErr) {
|
|
473
|
+
const message = String(error?.message || '') + ' ' + String(requireErr?.message || '');
|
|
474
|
+
const looksLikeCommonJsInEsm = message.includes('require is not defined in ES module scope') || message.includes('Cannot use import statement outside a module') || message.includes('ERR_REQUIRE_ESM');
|
|
475
|
+
if (looksLikeCommonJsInEsm) try {
|
|
476
|
+
required = loadCommonJsConfigWithStableDirname(absolutePath);
|
|
477
|
+
} catch {
|
|
478
|
+
const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_namespaceObject.tmpdir(), 'extension-config-'));
|
|
479
|
+
const tmpCjsPath = external_path_.join(tmpDir, external_path_.basename(absolutePath, external_path_.extname(absolutePath)) + '.cjs');
|
|
480
|
+
external_fs_.copyFileSync(absolutePath, tmpCjsPath);
|
|
481
|
+
required = requireFn(tmpCjsPath);
|
|
482
|
+
}
|
|
483
|
+
else throw requireErr;
|
|
484
|
+
}
|
|
485
|
+
return required?.default || required;
|
|
486
|
+
}
|
|
487
|
+
} catch {}
|
|
488
|
+
try {
|
|
489
|
+
const content = external_fs_.readFileSync(absolutePath, 'utf-8');
|
|
490
|
+
return JSON.parse(content);
|
|
491
|
+
} catch (jsonErr) {
|
|
492
|
+
throw new Error(`Failed to load config file: ${configPath}\nError: ${error.message || error}`);
|
|
493
|
+
}
|
|
599
494
|
}
|
|
600
495
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
496
|
+
async function loadCommandConfig(projectPath, command) {
|
|
497
|
+
const configPath = findConfigFile(projectPath);
|
|
498
|
+
if (configPath) {
|
|
499
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
500
|
+
const userConfig = await loadConfigFile(configPath);
|
|
501
|
+
const baseExtensions = userConfig && userConfig.extensions ? {
|
|
502
|
+
extensions: userConfig.extensions
|
|
503
|
+
} : {};
|
|
504
|
+
const baseTranspilePackages = userConfig && Array.isArray(userConfig.transpilePackages) ? {
|
|
505
|
+
transpilePackages: userConfig.transpilePackages
|
|
506
|
+
} : {};
|
|
507
|
+
const perCommand = userConfig && userConfig.commands && userConfig.commands[command] ? userConfig.commands[command] : {};
|
|
508
|
+
return {
|
|
509
|
+
...baseExtensions,
|
|
510
|
+
...baseTranspilePackages,
|
|
511
|
+
...perCommand
|
|
512
|
+
};
|
|
513
|
+
} catch (err) {
|
|
514
|
+
const error = err;
|
|
515
|
+
console.error(lib_messages.f7(configPath, error));
|
|
516
|
+
throw err;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return {};
|
|
520
|
+
}
|
|
521
|
+
async function loadBrowserConfig(projectPath, browser = 'chrome') {
|
|
522
|
+
const configPath = findConfigFile(projectPath);
|
|
523
|
+
if (configPath) {
|
|
524
|
+
if (await isUsingExperimentalConfig(projectPath)) try {
|
|
525
|
+
const userConfig = await loadConfigFile(configPath);
|
|
526
|
+
if (userConfig && userConfig.browser) {
|
|
527
|
+
const browsers = userConfig.browser;
|
|
528
|
+
if ('chromium-based' === browser) {
|
|
529
|
+
if (browsers['chromium-based']) return browsers['chromium-based'];
|
|
530
|
+
if (browsers.chromium) return browsers.chromium;
|
|
531
|
+
} else if ('gecko-based' === browser) {
|
|
532
|
+
if (browsers['gecko-based']) return browsers['gecko-based'];
|
|
533
|
+
if (browsers.firefox) return browsers.firefox;
|
|
534
|
+
} else {
|
|
535
|
+
const direct = browsers[browser];
|
|
536
|
+
if (direct) return direct;
|
|
537
|
+
}
|
|
619
538
|
}
|
|
539
|
+
} catch (err) {
|
|
540
|
+
const error = err;
|
|
541
|
+
console.error(lib_messages.f7(configPath, error));
|
|
542
|
+
throw err;
|
|
620
543
|
}
|
|
621
|
-
} catch (err) {
|
|
622
|
-
const error = err;
|
|
623
|
-
console.error(lib_messages.f7(configPath, error));
|
|
624
|
-
throw err;
|
|
625
544
|
}
|
|
545
|
+
return {
|
|
546
|
+
browser: browser || 'chrome'
|
|
547
|
+
};
|
|
626
548
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(lib_messages.BX('extension.config.js'));
|
|
637
|
-
userMessageDelivered = true;
|
|
549
|
+
let userMessageDelivered = false;
|
|
550
|
+
async function isUsingExperimentalConfig(projectPath) {
|
|
551
|
+
const configPath = findConfigFile(projectPath);
|
|
552
|
+
if (configPath) {
|
|
553
|
+
if (!userMessageDelivered) {
|
|
554
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(lib_messages.BX('extension.config.js'));
|
|
555
|
+
userMessageDelivered = true;
|
|
556
|
+
}
|
|
557
|
+
return true;
|
|
638
558
|
}
|
|
639
|
-
return
|
|
559
|
+
return false;
|
|
640
560
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
561
|
+
var package_0 = __webpack_require__("./package.json");
|
|
562
|
+
function assertNoManagedDependencyConflicts(userPackageJsonPath, projectPath) {
|
|
563
|
+
try {
|
|
564
|
+
const raw = external_fs_.readFileSync(userPackageJsonPath, 'utf-8');
|
|
565
|
+
const userPackageJson = JSON.parse(raw);
|
|
566
|
+
const userDeps = Array.from(new Set([
|
|
567
|
+
...Object.keys(userPackageJson.dependencies || {}),
|
|
568
|
+
...Object.keys(userPackageJson.devDependencies || {}),
|
|
569
|
+
...Object.keys(userPackageJson.optionalDependencies || {}),
|
|
570
|
+
...Object.keys(userPackageJson.peerDependencies || {})
|
|
571
|
+
]));
|
|
572
|
+
const managedDeps = new Set([
|
|
573
|
+
...Object.keys(package_0.El || {}),
|
|
574
|
+
...Object.keys(package_0.optionalDependencies || {})
|
|
575
|
+
]);
|
|
576
|
+
managedDeps.delete('webpack');
|
|
577
|
+
const userConfigJs = external_path_.join(projectPath, 'extension.config.js');
|
|
578
|
+
const userConfigMjs = external_path_.join(projectPath, 'extension.config.mjs');
|
|
579
|
+
const hasConfig = external_fs_.existsSync(userConfigJs) || external_fs_.existsSync(userConfigMjs);
|
|
580
|
+
if (!hasConfig) return;
|
|
581
|
+
const configPath = external_fs_.existsSync(userConfigJs) ? userConfigJs : userConfigMjs;
|
|
582
|
+
const configSource = external_fs_.readFileSync(configPath, 'utf-8');
|
|
583
|
+
const duplicates = userDeps.filter((d)=>managedDeps.has(d)).filter((d)=>configSource.includes(d)).sort();
|
|
584
|
+
if (duplicates.length > 0) {
|
|
585
|
+
console.error(lib_messages.H3(duplicates, userPackageJsonPath));
|
|
586
|
+
process.exit(1);
|
|
587
|
+
}
|
|
588
|
+
} catch (error) {
|
|
589
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(error);
|
|
669
590
|
}
|
|
670
|
-
} catch (error) {
|
|
671
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(error);
|
|
672
591
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
return external_path_.isAbsolute(p) ? p : external_path_.resolve(p);
|
|
676
|
-
}
|
|
677
|
-
function getDirs(struct) {
|
|
678
|
-
const manifestDir = asAbsolute(external_path_.dirname(struct.manifestPath));
|
|
679
|
-
const packageJsonDir = asAbsolute(struct.packageJsonPath ? external_path_.dirname(struct.packageJsonPath) : manifestDir);
|
|
680
|
-
return {
|
|
681
|
-
manifestDir,
|
|
682
|
-
packageJsonDir
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
|
|
686
|
-
const requested = String(browser || '');
|
|
687
|
-
if (chromiumBinary) {
|
|
688
|
-
if (!requested || 'chromium-based' === requested) return 'chromium-based';
|
|
689
|
-
if ('chromium' === requested) return 'chromium';
|
|
690
|
-
if ('edge' === requested) return 'edge';
|
|
691
|
-
if ('chrome' === requested) return 'chrome';
|
|
692
|
-
}
|
|
693
|
-
if (geckoBinary) {
|
|
694
|
-
if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
|
|
695
|
-
if ('firefox' === requested) return 'firefox';
|
|
696
|
-
}
|
|
697
|
-
switch(requested){
|
|
698
|
-
case 'chrome':
|
|
699
|
-
return 'chrome';
|
|
700
|
-
case 'edge':
|
|
701
|
-
return 'edge';
|
|
702
|
-
case 'chromium':
|
|
703
|
-
return 'chromium';
|
|
704
|
-
case 'chromium-based':
|
|
705
|
-
return 'chromium-based';
|
|
706
|
-
case 'firefox':
|
|
707
|
-
return 'firefox';
|
|
708
|
-
case 'gecko-based':
|
|
709
|
-
case 'firefox-based':
|
|
710
|
-
return 'gecko-based';
|
|
711
|
-
default:
|
|
712
|
-
return browser || 'chrome';
|
|
592
|
+
function asAbsolute(p) {
|
|
593
|
+
return external_path_.isAbsolute(p) ? p : external_path_.resolve(p);
|
|
713
594
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (struct.packageJsonPath) {
|
|
722
|
-
const distDir = getDistPath(packageJsonDir, browser);
|
|
723
|
-
try {
|
|
724
|
-
if (external_fs_.existsSync(external_path_.join(distDir, 'manifest.json'))) return distDir;
|
|
725
|
-
} catch {}
|
|
595
|
+
function getDirs(struct) {
|
|
596
|
+
const manifestDir = asAbsolute(external_path_.dirname(struct.manifestPath));
|
|
597
|
+
const packageJsonDir = asAbsolute(struct.packageJsonPath ? external_path_.dirname(struct.packageJsonPath) : manifestDir);
|
|
598
|
+
return {
|
|
599
|
+
manifestDir,
|
|
600
|
+
packageJsonDir
|
|
601
|
+
};
|
|
726
602
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
return '
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
return '
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
603
|
+
function normalizeBrowser(browser, chromiumBinary, geckoBinary) {
|
|
604
|
+
const requested = String(browser || '');
|
|
605
|
+
if (chromiumBinary) {
|
|
606
|
+
if (!requested || 'chromium-based' === requested) return 'chromium-based';
|
|
607
|
+
if ('chromium' === requested) return 'chromium';
|
|
608
|
+
if ('edge' === requested) return 'edge';
|
|
609
|
+
if ('chrome' === requested) return 'chrome';
|
|
610
|
+
}
|
|
611
|
+
if (geckoBinary) {
|
|
612
|
+
if (!requested || 'gecko-based' === requested || 'firefox-based' === requested) return 'gecko-based';
|
|
613
|
+
if ('firefox' === requested) return 'firefox';
|
|
614
|
+
}
|
|
615
|
+
switch(requested){
|
|
616
|
+
case 'chrome':
|
|
617
|
+
return 'chrome';
|
|
618
|
+
case 'edge':
|
|
619
|
+
return 'edge';
|
|
620
|
+
case 'chromium':
|
|
621
|
+
return 'chromium';
|
|
622
|
+
case 'chromium-based':
|
|
623
|
+
return 'chromium-based';
|
|
624
|
+
case 'firefox':
|
|
625
|
+
return 'firefox';
|
|
626
|
+
case 'gecko-based':
|
|
627
|
+
case 'firefox-based':
|
|
628
|
+
return 'gecko-based';
|
|
629
|
+
default:
|
|
630
|
+
return browser || 'chrome';
|
|
631
|
+
}
|
|
743
632
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
633
|
+
function getDistPath(packageJsonDir, browser) {
|
|
634
|
+
return asAbsolute(external_path_.join(packageJsonDir, 'dist', browser));
|
|
635
|
+
}
|
|
636
|
+
function computePreviewOutputPath(struct, browser, explicitOutputPath) {
|
|
637
|
+
const { manifestDir, packageJsonDir } = getDirs(struct);
|
|
638
|
+
if (explicitOutputPath) return asAbsolute(explicitOutputPath);
|
|
639
|
+
if (struct.packageJsonPath) {
|
|
640
|
+
const distDir = getDistPath(packageJsonDir, browser);
|
|
641
|
+
try {
|
|
642
|
+
if (external_fs_.existsSync(external_path_.join(distDir, 'manifest.json'))) return distDir;
|
|
643
|
+
} catch {}
|
|
644
|
+
}
|
|
645
|
+
return manifestDir;
|
|
646
|
+
}
|
|
647
|
+
function devtoolsEngineFor(browser) {
|
|
648
|
+
switch(browser){
|
|
649
|
+
case 'chrome':
|
|
650
|
+
return 'chrome';
|
|
651
|
+
case 'edge':
|
|
652
|
+
return 'edge';
|
|
653
|
+
case 'chromium':
|
|
654
|
+
case 'chromium-based':
|
|
655
|
+
return 'chromium';
|
|
656
|
+
case 'firefox':
|
|
657
|
+
case 'gecko-based':
|
|
658
|
+
return 'firefox';
|
|
659
|
+
default:
|
|
660
|
+
return 'chrome';
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function _define_property(obj, key, value) {
|
|
664
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
665
|
+
value: value,
|
|
666
|
+
enumerable: true,
|
|
667
|
+
configurable: true,
|
|
668
|
+
writable: true
|
|
765
669
|
});
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
function getPlaywrightMetadataDir(packageJsonDir, browser) {
|
|
776
|
-
return asAbsolute(external_path_.join(packageJsonDir, 'dist', 'extension-js', browser));
|
|
777
|
-
}
|
|
778
|
-
function createPlaywrightMetadataWriter(options) {
|
|
779
|
-
const metadataDir = getPlaywrightMetadataDir(options.packageJsonDir, options.browser);
|
|
780
|
-
const readyPath = asAbsolute(external_path_.join(metadataDir, 'ready.json'));
|
|
781
|
-
const eventsPath = asAbsolute(external_path_.join(metadataDir, 'events.ndjson'));
|
|
782
|
-
const base = {
|
|
783
|
-
command: options.command,
|
|
784
|
-
browser: options.browser,
|
|
785
|
-
runId: createRunId(),
|
|
786
|
-
startedAt: nowISO(),
|
|
787
|
-
distPath: options.distPath,
|
|
788
|
-
manifestPath: options.manifestPath,
|
|
789
|
-
port: (()=>{
|
|
790
|
-
if ('number' == typeof options.port && Number.isFinite(options.port)) return options.port;
|
|
791
|
-
if ('string' == typeof options.port) {
|
|
792
|
-
const parsed = parseInt(options.port, 10);
|
|
793
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
794
|
-
}
|
|
795
|
-
return null;
|
|
796
|
-
})()
|
|
797
|
-
};
|
|
798
|
-
function writeReady(status, extra) {
|
|
799
|
-
plugin_playwright_ensureDirSync(metadataDir);
|
|
800
|
-
const payload = {
|
|
801
|
-
...base,
|
|
802
|
-
status,
|
|
803
|
-
pid: process.pid,
|
|
804
|
-
ts: nowISO(),
|
|
805
|
-
compiledAt: extra?.compiledAt ?? null,
|
|
806
|
-
errors: Array.isArray(extra?.errors) ? extra.errors : []
|
|
807
|
-
};
|
|
808
|
-
if (extra?.code) payload.code = extra.code;
|
|
809
|
-
if (extra?.message) payload.message = extra.message;
|
|
810
|
-
writeJsonAtomic(readyPath, payload);
|
|
670
|
+
else obj[key] = value;
|
|
671
|
+
return obj;
|
|
672
|
+
}
|
|
673
|
+
function nowISO() {
|
|
674
|
+
return new Date().toISOString();
|
|
675
|
+
}
|
|
676
|
+
function createRunId() {
|
|
677
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
811
678
|
}
|
|
812
|
-
function
|
|
813
|
-
plugin_playwright_ensureDirSync(metadataDir);
|
|
679
|
+
function plugin_playwright_ensureDirSync(dirPath) {
|
|
814
680
|
try {
|
|
815
|
-
external_fs_.
|
|
681
|
+
external_fs_.mkdirSync(dirPath, {
|
|
682
|
+
recursive: true
|
|
683
|
+
});
|
|
816
684
|
} catch {}
|
|
817
685
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
686
|
+
function writeJsonAtomic(filePath, value) {
|
|
687
|
+
try {
|
|
688
|
+
const tmpPath = `${filePath}.tmp-${process.pid}`;
|
|
689
|
+
external_fs_.writeFileSync(tmpPath, JSON.stringify(value, null, 2) + '\n', 'utf-8');
|
|
690
|
+
external_fs_.renameSync(tmpPath, filePath);
|
|
691
|
+
} catch {}
|
|
692
|
+
}
|
|
693
|
+
function getPlaywrightMetadataDir(packageJsonDir, browser) {
|
|
694
|
+
return asAbsolute(external_path_.join(packageJsonDir, 'dist', 'extension-js', browser));
|
|
695
|
+
}
|
|
696
|
+
function createPlaywrightMetadataWriter(options) {
|
|
697
|
+
const metadataDir = getPlaywrightMetadataDir(options.packageJsonDir, options.browser);
|
|
698
|
+
const readyPath = asAbsolute(external_path_.join(metadataDir, 'ready.json'));
|
|
699
|
+
const eventsPath = asAbsolute(external_path_.join(metadataDir, 'events.ndjson'));
|
|
700
|
+
const base = {
|
|
701
|
+
command: options.command,
|
|
702
|
+
browser: options.browser,
|
|
703
|
+
runId: createRunId(),
|
|
704
|
+
startedAt: nowISO(),
|
|
705
|
+
distPath: options.distPath,
|
|
706
|
+
manifestPath: options.manifestPath,
|
|
707
|
+
port: (()=>{
|
|
708
|
+
if ('number' == typeof options.port && Number.isFinite(options.port)) return options.port;
|
|
709
|
+
if ('string' == typeof options.port) {
|
|
710
|
+
const parsed = parseInt(options.port, 10);
|
|
711
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
712
|
+
}
|
|
713
|
+
return null;
|
|
714
|
+
})()
|
|
715
|
+
};
|
|
716
|
+
function writeReady(status, extra) {
|
|
717
|
+
plugin_playwright_ensureDirSync(metadataDir);
|
|
718
|
+
const payload = {
|
|
719
|
+
...base,
|
|
720
|
+
status,
|
|
721
|
+
pid: process.pid,
|
|
847
722
|
ts: nowISO(),
|
|
848
|
-
|
|
849
|
-
|
|
723
|
+
compiledAt: extra?.compiledAt ?? null,
|
|
724
|
+
errors: Array.isArray(extra?.errors) ? extra.errors : []
|
|
725
|
+
};
|
|
726
|
+
if (extra?.code) payload.code = extra.code;
|
|
727
|
+
if (extra?.message) payload.message = extra.message;
|
|
728
|
+
writeJsonAtomic(readyPath, payload);
|
|
729
|
+
}
|
|
730
|
+
function appendEvent(event) {
|
|
731
|
+
plugin_playwright_ensureDirSync(metadataDir);
|
|
732
|
+
try {
|
|
733
|
+
external_fs_.appendFileSync(eventsPath, `${JSON.stringify(event)}\n`, 'utf-8');
|
|
734
|
+
} catch {}
|
|
735
|
+
}
|
|
736
|
+
return {
|
|
737
|
+
metadataDir,
|
|
738
|
+
readyPath,
|
|
739
|
+
eventsPath,
|
|
740
|
+
writeStarting () {
|
|
741
|
+
writeReady('starting');
|
|
742
|
+
},
|
|
743
|
+
writeReady (compiledAt) {
|
|
744
|
+
writeReady('ready', {
|
|
745
|
+
compiledAt: compiledAt || nowISO()
|
|
746
|
+
});
|
|
747
|
+
},
|
|
748
|
+
writeError (code, message, errors) {
|
|
749
|
+
writeReady('error', {
|
|
750
|
+
code,
|
|
751
|
+
message,
|
|
752
|
+
errors: Array.isArray(errors) ? errors : [],
|
|
753
|
+
compiledAt: null
|
|
754
|
+
});
|
|
755
|
+
},
|
|
756
|
+
appendEvent
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
class PlaywrightPlugin {
|
|
760
|
+
apply(compiler) {
|
|
761
|
+
this.writer.writeStarting();
|
|
762
|
+
compiler.hooks.compile.tap(PlaywrightPlugin.name, ()=>{
|
|
763
|
+
this.writer.appendEvent({
|
|
764
|
+
type: 'compile_start',
|
|
765
|
+
ts: nowISO(),
|
|
766
|
+
command: this.command,
|
|
767
|
+
browser: this.browser
|
|
768
|
+
});
|
|
850
769
|
});
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
errors
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
errors:
|
|
861
|
-
|
|
862
|
-
|
|
770
|
+
compiler.hooks.done.tap(PlaywrightPlugin.name, (stats)=>{
|
|
771
|
+
const durationMs = Number((stats?.compilation?.endTime || 0) - (stats?.compilation?.startTime || 0));
|
|
772
|
+
const hasErrors = Boolean(stats?.hasErrors?.());
|
|
773
|
+
const errorsCount = Number(Array.isArray(stats?.toJson?.({
|
|
774
|
+
all: false,
|
|
775
|
+
errors: true
|
|
776
|
+
})?.errors) ? stats.toJson({
|
|
777
|
+
all: false,
|
|
778
|
+
errors: true
|
|
779
|
+
}).errors.length : 0);
|
|
780
|
+
if (hasErrors) {
|
|
781
|
+
this.writer.appendEvent({
|
|
782
|
+
type: 'compile_error',
|
|
783
|
+
ts: nowISO(),
|
|
784
|
+
command: this.command,
|
|
785
|
+
browser: this.browser,
|
|
786
|
+
durationMs: Number.isFinite(durationMs) ? durationMs : void 0,
|
|
787
|
+
errorCount: Number.isFinite(errorsCount) ? errorsCount : 1
|
|
788
|
+
});
|
|
789
|
+
this.writer.writeError('compile_error', 'Compilation failed', [
|
|
790
|
+
`errors: ${String(errorsCount || 1)}`
|
|
791
|
+
]);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
863
794
|
this.writer.appendEvent({
|
|
864
|
-
type: '
|
|
795
|
+
type: 'compile_success',
|
|
865
796
|
ts: nowISO(),
|
|
866
797
|
command: this.command,
|
|
867
798
|
browser: this.browser,
|
|
868
799
|
durationMs: Number.isFinite(durationMs) ? durationMs : void 0,
|
|
869
|
-
errorCount:
|
|
800
|
+
errorCount: 0
|
|
870
801
|
});
|
|
871
|
-
this.writer.
|
|
872
|
-
`errors: ${String(errorsCount || 1)}`
|
|
873
|
-
]);
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
this.writer.appendEvent({
|
|
877
|
-
type: 'compile_success',
|
|
878
|
-
ts: nowISO(),
|
|
879
|
-
command: this.command,
|
|
880
|
-
browser: this.browser,
|
|
881
|
-
durationMs: Number.isFinite(durationMs) ? durationMs : void 0,
|
|
882
|
-
errorCount: 0
|
|
802
|
+
this.writer.writeReady(nowISO());
|
|
883
803
|
});
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
804
|
+
compiler.hooks.failed.tap(PlaywrightPlugin.name, (error)=>{
|
|
805
|
+
this.writer.appendEvent({
|
|
806
|
+
type: 'compile_error',
|
|
807
|
+
ts: nowISO(),
|
|
808
|
+
command: this.command,
|
|
809
|
+
browser: this.browser,
|
|
810
|
+
errorCount: 1
|
|
811
|
+
});
|
|
812
|
+
this.writer.writeError('compile_failed', error instanceof Error ? error.message : String(error));
|
|
893
813
|
});
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
814
|
+
compiler.hooks.watchClose.tap(PlaywrightPlugin.name, ()=>{
|
|
815
|
+
this.writer.appendEvent({
|
|
816
|
+
type: 'shutdown',
|
|
817
|
+
ts: nowISO(),
|
|
818
|
+
command: this.command,
|
|
819
|
+
browser: this.browser
|
|
820
|
+
});
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
constructor(options){
|
|
824
|
+
_define_property(this, "writer", void 0);
|
|
825
|
+
_define_property(this, "command", void 0);
|
|
826
|
+
_define_property(this, "browser", void 0);
|
|
827
|
+
this.browser = String(options.browser || 'chromium');
|
|
828
|
+
this.command = options.command || ('development' === options.mode ? 'dev' : 'start');
|
|
829
|
+
this.writer = createPlaywrightMetadataWriter({
|
|
830
|
+
packageJsonDir: options.packageJsonDir,
|
|
831
|
+
browser: this.browser,
|
|
900
832
|
command: this.command,
|
|
901
|
-
|
|
833
|
+
distPath: options.outputPath,
|
|
834
|
+
manifestPath: options.manifestPath,
|
|
835
|
+
port: options.port
|
|
902
836
|
});
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
constructor(options){
|
|
906
|
-
_define_property(this, "writer", void 0);
|
|
907
|
-
_define_property(this, "command", void 0);
|
|
908
|
-
_define_property(this, "browser", void 0);
|
|
909
|
-
this.browser = String(options.browser || 'chromium');
|
|
910
|
-
this.command = options.command || ('development' === options.mode ? 'dev' : 'start');
|
|
911
|
-
this.writer = createPlaywrightMetadataWriter({
|
|
912
|
-
packageJsonDir: options.packageJsonDir,
|
|
913
|
-
browser: this.browser,
|
|
914
|
-
command: this.command,
|
|
915
|
-
distPath: options.outputPath,
|
|
916
|
-
manifestPath: options.manifestPath,
|
|
917
|
-
port: options.port
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
_define_property(PlaywrightPlugin, "name", 'plugin-playwright');
|
|
922
|
-
function sanitize(obj) {
|
|
923
|
-
return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
|
|
924
|
-
}
|
|
925
|
-
const external_extension_from_store_namespaceObject = require("extension-from-store");
|
|
926
|
-
function isDir(p) {
|
|
927
|
-
try {
|
|
928
|
-
return external_fs_.existsSync(p) && external_fs_.statSync(p).isDirectory();
|
|
929
|
-
} catch {
|
|
930
|
-
return false;
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
function isFile(p) {
|
|
934
|
-
try {
|
|
935
|
-
return external_fs_.existsSync(p) && external_fs_.statSync(p).isFile();
|
|
936
|
-
} catch {
|
|
937
|
-
return false;
|
|
837
|
+
}
|
|
938
838
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
function isValidExtensionRoot(dir) {
|
|
944
|
-
if (!isDir(dir)) return false;
|
|
945
|
-
return isFile(external_path_.join(dir, 'manifest.json'));
|
|
946
|
-
}
|
|
947
|
-
function normalizeCompanionConfig(config) {
|
|
948
|
-
const explicitPaths = [];
|
|
949
|
-
let scanDir;
|
|
950
|
-
if (Array.isArray(config)) explicitPaths.push(...config.filter((p)=>'string' == typeof p));
|
|
951
|
-
else if (config && 'object' == typeof config) {
|
|
952
|
-
if (Array.isArray(config.paths)) explicitPaths.push(...config.paths.filter((p)=>'string' == typeof p));
|
|
953
|
-
if ('string' == typeof config.dir && config.dir.trim().length > 0) scanDir = config.dir.trim();
|
|
954
|
-
}
|
|
955
|
-
return {
|
|
956
|
-
dir: scanDir,
|
|
957
|
-
paths: explicitPaths
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
function isPathLike(value) {
|
|
961
|
-
if (external_path_.isAbsolute(value)) return true;
|
|
962
|
-
if (value.startsWith('./') || value.startsWith('../')) return true;
|
|
963
|
-
return value.includes('/') || value.includes('\\');
|
|
964
|
-
}
|
|
965
|
-
function isSubpathOf(parent, child) {
|
|
966
|
-
const rel = external_path_.relative(parent, child);
|
|
967
|
-
return '' !== rel && !rel.startsWith('..') && !external_path_.isAbsolute(rel);
|
|
968
|
-
}
|
|
969
|
-
function getBrowserFolder(browser) {
|
|
970
|
-
if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return 'firefox';
|
|
971
|
-
if ('edge' === browser) return 'edge';
|
|
972
|
-
return 'chrome';
|
|
973
|
-
}
|
|
974
|
-
function parseChromeWebStoreId(url) {
|
|
975
|
-
if ('chromewebstore.google.com' !== url.hostname) return null;
|
|
976
|
-
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
977
|
-
return match ? match[1] : null;
|
|
978
|
-
}
|
|
979
|
-
function parseEdgeAddonsId(url) {
|
|
980
|
-
if ('microsoftedge.microsoft.com' !== url.hostname) return null;
|
|
981
|
-
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
982
|
-
return match ? match[1] : null;
|
|
983
|
-
}
|
|
984
|
-
function parseAmoSlug(url) {
|
|
985
|
-
if ('addons.mozilla.org' !== url.hostname) return null;
|
|
986
|
-
const match = url.pathname.match(/\/addon\/([^/]+)(?:\/|$)/i);
|
|
987
|
-
return match ? match[1] : null;
|
|
988
|
-
}
|
|
989
|
-
function parseStoreUrl(raw) {
|
|
990
|
-
let url;
|
|
991
|
-
try {
|
|
992
|
-
url = new URL(raw);
|
|
993
|
-
} catch {
|
|
994
|
-
return null;
|
|
839
|
+
_define_property(PlaywrightPlugin, "name", 'plugin-playwright');
|
|
840
|
+
function sanitize(obj) {
|
|
841
|
+
return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
|
|
995
842
|
}
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
browser: 'chrome',
|
|
999
|
-
id: chromeId
|
|
1000
|
-
};
|
|
1001
|
-
const edgeId = parseEdgeAddonsId(url);
|
|
1002
|
-
if (edgeId) return {
|
|
1003
|
-
browser: 'edge',
|
|
1004
|
-
id: edgeId
|
|
1005
|
-
};
|
|
1006
|
-
const amoSlug = parseAmoSlug(url);
|
|
1007
|
-
if (amoSlug) return {
|
|
1008
|
-
browser: 'firefox',
|
|
1009
|
-
id: amoSlug
|
|
1010
|
-
};
|
|
1011
|
-
return null;
|
|
1012
|
-
}
|
|
1013
|
-
function ensurePathsUnderExtensions(projectRoot, paths) {
|
|
1014
|
-
const extensionsRoot = external_path_.resolve(projectRoot, 'extensions');
|
|
1015
|
-
return paths.map((p)=>{
|
|
1016
|
-
const abs = toAbs(projectRoot, p);
|
|
1017
|
-
if (abs !== extensionsRoot && !isSubpathOf(extensionsRoot, abs) && external_path_.resolve(abs) !== extensionsRoot) throw new Error(`Companion extensions must be inside ${extensionsRoot}.\nInvalid path: ${abs}`);
|
|
1018
|
-
return abs;
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
function findExtensionRoots(dir, maxDepth = 3) {
|
|
1022
|
-
const found = [];
|
|
1023
|
-
function walk(current, depth) {
|
|
1024
|
-
if (depth > maxDepth) return;
|
|
1025
|
-
if (!isDir(current)) return;
|
|
1026
|
-
if (isValidExtensionRoot(current)) return void found.push(current);
|
|
1027
|
-
let entries = [];
|
|
843
|
+
const external_extension_from_store_namespaceObject = require("extension-from-store");
|
|
844
|
+
function isDir(p) {
|
|
1028
845
|
try {
|
|
1029
|
-
|
|
1030
|
-
withFileTypes: true
|
|
1031
|
-
});
|
|
846
|
+
return external_fs_.existsSync(p) && external_fs_.statSync(p).isDirectory();
|
|
1032
847
|
} catch {
|
|
1033
|
-
return;
|
|
848
|
+
return false;
|
|
1034
849
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
850
|
+
}
|
|
851
|
+
function isFile(p) {
|
|
852
|
+
try {
|
|
853
|
+
return external_fs_.existsSync(p) && external_fs_.statSync(p).isFile();
|
|
854
|
+
} catch {
|
|
855
|
+
return false;
|
|
1037
856
|
}
|
|
1038
857
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
async function resolveStoreExtensionToPath(opts) {
|
|
1055
|
-
const { projectRoot, storeUrl, browser, id } = opts;
|
|
1056
|
-
const extensionsRoot = external_path_.resolve(projectRoot, 'extensions');
|
|
1057
|
-
const targetRoot = external_path_.join(extensionsRoot, browser, id);
|
|
1058
|
-
const manifestPath = external_path_.join(targetRoot, 'manifest.json');
|
|
1059
|
-
if (isFile(manifestPath)) return targetRoot;
|
|
1060
|
-
await runExtensionFromStore(storeUrl, external_path_.join(extensionsRoot, browser));
|
|
1061
|
-
const candidates = findExtensionRoots(external_path_.join(extensionsRoot, browser));
|
|
1062
|
-
let selected;
|
|
1063
|
-
if (1 === candidates.length) selected = candidates[0];
|
|
1064
|
-
else if (candidates.length > 1) {
|
|
1065
|
-
const directMatch = candidates.find((c)=>external_path_.basename(c) === id);
|
|
1066
|
-
const versionedMatch = candidates.find((c)=>external_path_.basename(c).startsWith(`${id}@`));
|
|
1067
|
-
if (directMatch) selected = directMatch;
|
|
1068
|
-
else if (versionedMatch) selected = versionedMatch;
|
|
1069
|
-
}
|
|
1070
|
-
if (!selected) throw new Error(`Could not locate an unpacked extension from ${storeUrl}.`);
|
|
1071
|
-
external_fs_.mkdirSync(external_path_.dirname(targetRoot), {
|
|
1072
|
-
recursive: true
|
|
1073
|
-
});
|
|
1074
|
-
if (external_path_.basename(selected).startsWith(`${id}@`)) external_fs_.renameSync(selected, targetRoot);
|
|
1075
|
-
return targetRoot;
|
|
1076
|
-
}
|
|
1077
|
-
async function resolveCompanionExtensionsConfig(opts) {
|
|
1078
|
-
const { projectRoot, browser, config } = opts;
|
|
1079
|
-
if (!config) return;
|
|
1080
|
-
const normalized = normalizeCompanionConfig(config);
|
|
1081
|
-
const runtimeBrowser = getBrowserFolder(browser);
|
|
1082
|
-
const resolvedPaths = [];
|
|
1083
|
-
const localPaths = [];
|
|
1084
|
-
for (const entry of normalized.paths){
|
|
1085
|
-
const parsedStore = parseStoreUrl(entry);
|
|
1086
|
-
if (parsedStore) {
|
|
1087
|
-
if (parsedStore.browser !== runtimeBrowser) continue;
|
|
1088
|
-
const resolvedPath = await resolveStoreExtensionToPath({
|
|
1089
|
-
projectRoot,
|
|
1090
|
-
storeUrl: entry,
|
|
1091
|
-
browser: parsedStore.browser,
|
|
1092
|
-
id: parsedStore.id
|
|
1093
|
-
});
|
|
1094
|
-
resolvedPaths.push(resolvedPath);
|
|
1095
|
-
continue;
|
|
858
|
+
function toAbs(projectRoot, p) {
|
|
859
|
+
return external_path_.isAbsolute(p) ? p : external_path_.resolve(projectRoot, p);
|
|
860
|
+
}
|
|
861
|
+
function isValidExtensionRoot(dir) {
|
|
862
|
+
if (!isDir(dir)) return false;
|
|
863
|
+
return isFile(external_path_.join(dir, 'manifest.json'));
|
|
864
|
+
}
|
|
865
|
+
function normalizeCompanionConfig(config) {
|
|
866
|
+
const explicitPaths = [];
|
|
867
|
+
let scanDir;
|
|
868
|
+
if (Array.isArray(config)) explicitPaths.push(...config.filter((p)=>'string' == typeof p));
|
|
869
|
+
else if (config && 'object' == typeof config) {
|
|
870
|
+
if (Array.isArray(config.paths)) explicitPaths.push(...config.paths.filter((p)=>'string' == typeof p));
|
|
871
|
+
if ('string' == typeof config.dir && config.dir.trim().length > 0) scanDir = config.dir.trim();
|
|
1096
872
|
}
|
|
1097
|
-
|
|
873
|
+
return {
|
|
874
|
+
dir: scanDir,
|
|
875
|
+
paths: explicitPaths
|
|
876
|
+
};
|
|
1098
877
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
878
|
+
function isPathLike(value) {
|
|
879
|
+
if (external_path_.isAbsolute(value)) return true;
|
|
880
|
+
if (value.startsWith('./') || value.startsWith('../')) return true;
|
|
881
|
+
return value.includes('/') || value.includes('\\');
|
|
882
|
+
}
|
|
883
|
+
function isSubpathOf(parent, child) {
|
|
884
|
+
const rel = external_path_.relative(parent, child);
|
|
885
|
+
return '' !== rel && !rel.startsWith('..') && !external_path_.isAbsolute(rel);
|
|
886
|
+
}
|
|
887
|
+
function getBrowserFolder(browser) {
|
|
888
|
+
if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return 'firefox';
|
|
889
|
+
if ('edge' === browser) return 'edge';
|
|
890
|
+
return 'chrome';
|
|
891
|
+
}
|
|
892
|
+
function parseChromeWebStoreId(url) {
|
|
893
|
+
if ('chromewebstore.google.com' !== url.hostname) return null;
|
|
894
|
+
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
895
|
+
return match ? match[1] : null;
|
|
896
|
+
}
|
|
897
|
+
function parseEdgeAddonsId(url) {
|
|
898
|
+
if ('microsoftedge.microsoft.com' !== url.hostname) return null;
|
|
899
|
+
const match = url.pathname.match(/\/([a-z]{32})(?:\/|$)/i);
|
|
900
|
+
return match ? match[1] : null;
|
|
901
|
+
}
|
|
902
|
+
function parseAmoSlug(url) {
|
|
903
|
+
if ('addons.mozilla.org' !== url.hostname) return null;
|
|
904
|
+
const match = url.pathname.match(/\/addon\/([^/]+)(?:\/|$)/i);
|
|
905
|
+
return match ? match[1] : null;
|
|
906
|
+
}
|
|
907
|
+
function parseStoreUrl(raw) {
|
|
908
|
+
let url;
|
|
909
|
+
try {
|
|
910
|
+
url = new URL(raw);
|
|
911
|
+
} catch {
|
|
912
|
+
return null;
|
|
913
|
+
}
|
|
914
|
+
const chromeId = parseChromeWebStoreId(url);
|
|
915
|
+
if (chromeId) return {
|
|
916
|
+
browser: 'chrome',
|
|
917
|
+
id: chromeId
|
|
918
|
+
};
|
|
919
|
+
const edgeId = parseEdgeAddonsId(url);
|
|
920
|
+
if (edgeId) return {
|
|
921
|
+
browser: 'edge',
|
|
922
|
+
id: edgeId
|
|
923
|
+
};
|
|
924
|
+
const amoSlug = parseAmoSlug(url);
|
|
925
|
+
if (amoSlug) return {
|
|
926
|
+
browser: 'firefox',
|
|
927
|
+
id: amoSlug
|
|
928
|
+
};
|
|
929
|
+
return null;
|
|
1102
930
|
}
|
|
1103
|
-
|
|
1104
|
-
if ('string' == typeof normalized.dir) {
|
|
1105
|
-
const absDir = toAbs(projectRoot, normalized.dir);
|
|
931
|
+
function ensurePathsUnderExtensions(projectRoot, paths) {
|
|
1106
932
|
const extensionsRoot = external_path_.resolve(projectRoot, 'extensions');
|
|
1107
|
-
|
|
1108
|
-
|
|
933
|
+
return paths.map((p)=>{
|
|
934
|
+
const abs = toAbs(projectRoot, p);
|
|
935
|
+
if (abs !== extensionsRoot && !isSubpathOf(extensionsRoot, abs) && external_path_.resolve(abs) !== extensionsRoot) throw new Error(`Companion extensions must be inside ${extensionsRoot}.\nInvalid path: ${abs}`);
|
|
936
|
+
return abs;
|
|
937
|
+
});
|
|
1109
938
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
const explicitPaths = normalized.paths;
|
|
1117
|
-
const scanDir = normalized.dir;
|
|
1118
|
-
const found = [];
|
|
1119
|
-
for (const p of explicitPaths){
|
|
1120
|
-
const abs = toAbs(projectRoot, p);
|
|
1121
|
-
if (isValidExtensionRoot(abs)) found.push(abs);
|
|
1122
|
-
}
|
|
1123
|
-
if (scanDir) {
|
|
1124
|
-
const absScan = toAbs(projectRoot, scanDir);
|
|
1125
|
-
if (isDir(absScan)) {
|
|
939
|
+
function findExtensionRoots(dir, maxDepth = 3) {
|
|
940
|
+
const found = [];
|
|
941
|
+
function walk(current, depth) {
|
|
942
|
+
if (depth > maxDepth) return;
|
|
943
|
+
if (!isDir(current)) return;
|
|
944
|
+
if (isValidExtensionRoot(current)) return void found.push(current);
|
|
1126
945
|
let entries = [];
|
|
1127
946
|
try {
|
|
1128
|
-
entries = external_fs_.readdirSync(
|
|
947
|
+
entries = external_fs_.readdirSync(current, {
|
|
1129
948
|
withFileTypes: true
|
|
1130
949
|
});
|
|
1131
950
|
} catch {
|
|
1132
|
-
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
for (const ent of entries)if (ent.isDirectory()) {
|
|
954
|
+
if (!ent.name.startsWith('.')) walk(external_path_.join(current, ent.name), depth + 1);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
walk(dir, 0);
|
|
958
|
+
return found;
|
|
959
|
+
}
|
|
960
|
+
async function runExtensionFromStore(url, outDir) {
|
|
961
|
+
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
962
|
+
await (0, external_extension_from_store_namespaceObject.fetchExtensionFromStore)(url, {
|
|
963
|
+
outDir,
|
|
964
|
+
extract: true,
|
|
965
|
+
logger: isAuthor ? {
|
|
966
|
+
onInfo: (message)=>console.log(message),
|
|
967
|
+
onWarn: (message)=>console.warn(message),
|
|
968
|
+
onError: (message, error)=>console.error(message, error)
|
|
969
|
+
} : void 0
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
async function resolveStoreExtensionToPath(opts) {
|
|
973
|
+
const { projectRoot, storeUrl, browser, id } = opts;
|
|
974
|
+
const extensionsRoot = external_path_.resolve(projectRoot, 'extensions');
|
|
975
|
+
const targetRoot = external_path_.join(extensionsRoot, browser, id);
|
|
976
|
+
const manifestPath = external_path_.join(targetRoot, 'manifest.json');
|
|
977
|
+
if (isFile(manifestPath)) return targetRoot;
|
|
978
|
+
await runExtensionFromStore(storeUrl, external_path_.join(extensionsRoot, browser));
|
|
979
|
+
const candidates = findExtensionRoots(external_path_.join(extensionsRoot, browser));
|
|
980
|
+
let selected;
|
|
981
|
+
if (1 === candidates.length) selected = candidates[0];
|
|
982
|
+
else if (candidates.length > 1) {
|
|
983
|
+
const directMatch = candidates.find((c)=>external_path_.basename(c) === id);
|
|
984
|
+
const versionedMatch = candidates.find((c)=>external_path_.basename(c).startsWith(`${id}@`));
|
|
985
|
+
if (directMatch) selected = directMatch;
|
|
986
|
+
else if (versionedMatch) selected = versionedMatch;
|
|
987
|
+
}
|
|
988
|
+
if (!selected) throw new Error(`Could not locate an unpacked extension from ${storeUrl}.`);
|
|
989
|
+
external_fs_.mkdirSync(external_path_.dirname(targetRoot), {
|
|
990
|
+
recursive: true
|
|
991
|
+
});
|
|
992
|
+
if (external_path_.basename(selected).startsWith(`${id}@`)) external_fs_.renameSync(selected, targetRoot);
|
|
993
|
+
return targetRoot;
|
|
994
|
+
}
|
|
995
|
+
async function resolveCompanionExtensionsConfig(opts) {
|
|
996
|
+
const { projectRoot, browser, config } = opts;
|
|
997
|
+
if (!config) return;
|
|
998
|
+
const normalized = normalizeCompanionConfig(config);
|
|
999
|
+
const runtimeBrowser = getBrowserFolder(browser);
|
|
1000
|
+
const resolvedPaths = [];
|
|
1001
|
+
const localPaths = [];
|
|
1002
|
+
for (const entry of normalized.paths){
|
|
1003
|
+
const parsedStore = parseStoreUrl(entry);
|
|
1004
|
+
if (parsedStore) {
|
|
1005
|
+
if (parsedStore.browser !== runtimeBrowser) continue;
|
|
1006
|
+
const resolvedPath = await resolveStoreExtensionToPath({
|
|
1007
|
+
projectRoot,
|
|
1008
|
+
storeUrl: entry,
|
|
1009
|
+
browser: parsedStore.browser,
|
|
1010
|
+
id: parsedStore.id
|
|
1011
|
+
});
|
|
1012
|
+
resolvedPaths.push(resolvedPath);
|
|
1013
|
+
continue;
|
|
1133
1014
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1015
|
+
if (isPathLike(entry)) localPaths.push(entry);
|
|
1016
|
+
}
|
|
1017
|
+
if (localPaths.length > 0) {
|
|
1018
|
+
const absLocalPaths = ensurePathsUnderExtensions(projectRoot, localPaths);
|
|
1019
|
+
resolvedPaths.push(...absLocalPaths);
|
|
1020
|
+
}
|
|
1021
|
+
const output = {};
|
|
1022
|
+
if ('string' == typeof normalized.dir) {
|
|
1023
|
+
const absDir = toAbs(projectRoot, normalized.dir);
|
|
1024
|
+
const extensionsRoot = external_path_.resolve(projectRoot, 'extensions');
|
|
1025
|
+
if (absDir !== extensionsRoot && !isSubpathOf(extensionsRoot, absDir)) throw new Error(`extensions.dir must be inside ${extensionsRoot}.\nInvalid dir: ${absDir}`);
|
|
1026
|
+
output.dir = normalized.dir;
|
|
1027
|
+
}
|
|
1028
|
+
if (resolvedPaths.length > 0) output.paths = resolvedPaths;
|
|
1029
|
+
return output;
|
|
1030
|
+
}
|
|
1031
|
+
function resolveCompanionExtensionDirs(opts) {
|
|
1032
|
+
const { projectRoot, config } = opts;
|
|
1033
|
+
const normalized = normalizeCompanionConfig(config);
|
|
1034
|
+
const explicitPaths = normalized.paths;
|
|
1035
|
+
const scanDir = normalized.dir;
|
|
1036
|
+
const found = [];
|
|
1037
|
+
for (const p of explicitPaths){
|
|
1038
|
+
const abs = toAbs(projectRoot, p);
|
|
1039
|
+
if (isValidExtensionRoot(abs)) found.push(abs);
|
|
1040
|
+
}
|
|
1041
|
+
if (scanDir) {
|
|
1042
|
+
const absScan = toAbs(projectRoot, scanDir);
|
|
1043
|
+
if (isDir(absScan)) {
|
|
1044
|
+
let entries = [];
|
|
1136
1045
|
try {
|
|
1137
|
-
|
|
1046
|
+
entries = external_fs_.readdirSync(absScan, {
|
|
1138
1047
|
withFileTypes: true
|
|
1139
1048
|
});
|
|
1140
1049
|
} catch {
|
|
1141
|
-
|
|
1050
|
+
entries = [];
|
|
1142
1051
|
}
|
|
1143
|
-
|
|
1052
|
+
const scanOneLevel = (rootDir)=>{
|
|
1053
|
+
let dirEntries = [];
|
|
1054
|
+
try {
|
|
1055
|
+
dirEntries = external_fs_.readdirSync(rootDir, {
|
|
1056
|
+
withFileTypes: true
|
|
1057
|
+
});
|
|
1058
|
+
} catch {
|
|
1059
|
+
dirEntries = [];
|
|
1060
|
+
}
|
|
1061
|
+
for (const ent of dirEntries){
|
|
1062
|
+
if (!ent.isDirectory()) continue;
|
|
1063
|
+
if (ent.name.startsWith('.')) continue;
|
|
1064
|
+
const candidate = external_path_.join(rootDir, ent.name);
|
|
1065
|
+
if (isValidExtensionRoot(candidate)) found.push(candidate);
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
scanOneLevel(absScan);
|
|
1069
|
+
if ('extensions' === external_path_.basename(absScan)) for (const ent of entries){
|
|
1144
1070
|
if (!ent.isDirectory()) continue;
|
|
1145
1071
|
if (ent.name.startsWith('.')) continue;
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1072
|
+
const browserDir = external_path_.join(absScan, ent.name);
|
|
1073
|
+
scanOneLevel(browserDir);
|
|
1148
1074
|
}
|
|
1149
|
-
};
|
|
1150
|
-
scanOneLevel(absScan);
|
|
1151
|
-
if ('extensions' === external_path_.basename(absScan)) for (const ent of entries){
|
|
1152
|
-
if (!ent.isDirectory()) continue;
|
|
1153
|
-
if (ent.name.startsWith('.')) continue;
|
|
1154
|
-
const browserDir = external_path_.join(absScan, ent.name);
|
|
1155
|
-
scanOneLevel(browserDir);
|
|
1156
1075
|
}
|
|
1157
1076
|
}
|
|
1077
|
+
const unique = [];
|
|
1078
|
+
const seen = new Set();
|
|
1079
|
+
for (const p of found)if (!seen.has(p)) {
|
|
1080
|
+
seen.add(p);
|
|
1081
|
+
unique.push(p);
|
|
1082
|
+
}
|
|
1083
|
+
return unique;
|
|
1084
|
+
}
|
|
1085
|
+
const external_browser_extension_manifest_fields_namespaceObject = require("browser-extension-manifest-fields");
|
|
1086
|
+
function isUnderPublicDir(entry, projectRoot, publicDir) {
|
|
1087
|
+
if (!entry) return false;
|
|
1088
|
+
const normalizedEntry = String(entry);
|
|
1089
|
+
const candidate = external_path_default().isAbsolute(normalizedEntry) ? normalizedEntry : external_path_default().join(projectRoot, normalizedEntry);
|
|
1090
|
+
const rel = external_path_default().relative(publicDir, candidate);
|
|
1091
|
+
return Boolean(rel && !rel.startsWith('..') && !external_path_default().isAbsolute(rel));
|
|
1092
|
+
}
|
|
1093
|
+
function filterPublicEntrypoints(list, projectRoot, publicDir) {
|
|
1094
|
+
const next = {};
|
|
1095
|
+
for (const [key, value] of Object.entries(list || {})){
|
|
1096
|
+
if (Array.isArray(value)) {
|
|
1097
|
+
const filtered = value.filter((entry)=>!isUnderPublicDir(String(entry), projectRoot, publicDir));
|
|
1098
|
+
if (filtered.length > 0) next[key] = filtered;
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1101
|
+
if ('string' == typeof value) {
|
|
1102
|
+
if (!isUnderPublicDir(value, projectRoot, publicDir)) next[key] = value;
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return next;
|
|
1158
1107
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1108
|
+
function getSpecialFoldersDataForProjectRoot(projectRoot) {
|
|
1109
|
+
const publicDir = external_path_default().join(projectRoot, 'public');
|
|
1110
|
+
const data = (0, external_browser_extension_manifest_fields_namespaceObject.getSpecialFoldersData)({
|
|
1111
|
+
manifestPath: external_path_default().join(projectRoot, 'package.json')
|
|
1112
|
+
});
|
|
1113
|
+
return finalizeSpecialFoldersData(data, projectRoot, publicDir);
|
|
1114
|
+
}
|
|
1115
|
+
function finalizeSpecialFoldersData(data, projectRoot, publicDir) {
|
|
1116
|
+
return {
|
|
1117
|
+
...data,
|
|
1118
|
+
pages: filterPublicEntrypoints(data.pages, projectRoot, publicDir),
|
|
1119
|
+
scripts: filterPublicEntrypoints(data.scripts, projectRoot, publicDir),
|
|
1120
|
+
extensions: {
|
|
1121
|
+
dir: './extensions'
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1164
1124
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
function filterPublicEntrypoints(list, projectRoot, publicDir) {
|
|
1176
|
-
const next = {};
|
|
1177
|
-
for (const [key, value] of Object.entries(list || {})){
|
|
1178
|
-
if (Array.isArray(value)) {
|
|
1179
|
-
const filtered = value.filter((entry)=>!isUnderPublicDir(String(entry), projectRoot, publicDir));
|
|
1180
|
-
if (filtered.length > 0) next[key] = filtered;
|
|
1181
|
-
continue;
|
|
1182
|
-
}
|
|
1183
|
-
if ('string' == typeof value) {
|
|
1184
|
-
if (!isUnderPublicDir(value, projectRoot, publicDir)) next[key] = value;
|
|
1185
|
-
continue;
|
|
1125
|
+
function hasNewTabOverride(extensionDir) {
|
|
1126
|
+
const manifestPath = external_path_.join(extensionDir, 'manifest.json');
|
|
1127
|
+
if (!external_fs_.existsSync(manifestPath)) return false;
|
|
1128
|
+
try {
|
|
1129
|
+
const raw = external_fs_.readFileSync(manifestPath, 'utf-8');
|
|
1130
|
+
const manifest = JSON.parse(raw);
|
|
1131
|
+
const newtab = manifest?.chrome_url_overrides?.newtab;
|
|
1132
|
+
return 'string' == typeof newtab && newtab.trim().length > 0;
|
|
1133
|
+
} catch {
|
|
1134
|
+
return false;
|
|
1186
1135
|
}
|
|
1187
1136
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
pages: filterPublicEntrypoints(data.pages, projectRoot, publicDir),
|
|
1201
|
-
scripts: filterPublicEntrypoints(data.scripts, projectRoot, publicDir),
|
|
1202
|
-
extensions: {
|
|
1203
|
-
dir: './extensions'
|
|
1137
|
+
function resolveBuiltInExtensionForBrowser(input) {
|
|
1138
|
+
const engine = devtoolsEngineFor(input.browser);
|
|
1139
|
+
const packageRelativeCandidates = [
|
|
1140
|
+
external_path_.join('dist', input.packageName, engine)
|
|
1141
|
+
];
|
|
1142
|
+
const normalizedBaseDir = external_path_.normalize(input.baseDir);
|
|
1143
|
+
const parentName = external_path_.basename(external_path_.dirname(normalizedBaseDir));
|
|
1144
|
+
const baseName = external_path_.basename(normalizedBaseDir);
|
|
1145
|
+
if ('programs' === parentName && 'develop' === baseName) packageRelativeCandidates.push(external_path_.join('..', '..', 'extensions', input.packageName, 'dist', engine));
|
|
1146
|
+
for (const rel of packageRelativeCandidates){
|
|
1147
|
+
const candidate = external_path_.resolve(input.baseDir, rel);
|
|
1148
|
+
if (external_fs_.existsSync(candidate)) return candidate;
|
|
1204
1149
|
}
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
function hasNewTabOverride(extensionDir) {
|
|
1208
|
-
const manifestPath = external_path_.join(extensionDir, 'manifest.json');
|
|
1209
|
-
if (!external_fs_.existsSync(manifestPath)) return false;
|
|
1210
|
-
try {
|
|
1211
|
-
const raw = external_fs_.readFileSync(manifestPath, 'utf-8');
|
|
1212
|
-
const manifest = JSON.parse(raw);
|
|
1213
|
-
const newtab = manifest?.chrome_url_overrides?.newtab;
|
|
1214
|
-
return 'string' == typeof newtab && newtab.trim().length > 0;
|
|
1215
|
-
} catch {
|
|
1216
|
-
return false;
|
|
1217
1150
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1151
|
+
function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath, extraExtensionDirs = [], userManifestPath) {
|
|
1152
|
+
const list = [];
|
|
1153
|
+
try {
|
|
1154
|
+
const devtoolsForBrowser = resolveBuiltInExtensionForBrowser({
|
|
1155
|
+
baseDir,
|
|
1156
|
+
packageName: 'extension-js-devtools',
|
|
1157
|
+
browser
|
|
1158
|
+
});
|
|
1159
|
+
const themeForBrowser = resolveBuiltInExtensionForBrowser({
|
|
1160
|
+
baseDir,
|
|
1161
|
+
packageName: 'extension-js-theme',
|
|
1162
|
+
browser
|
|
1163
|
+
});
|
|
1164
|
+
const userHasNewTabOverride = hasNewTabOverride(userExtensionOutputPath) || ('string' == typeof userManifestPath ? hasNewTabOverride(external_path_.dirname(userManifestPath)) : false);
|
|
1165
|
+
const devtoolsHasNewTabOverride = devtoolsForBrowser ? hasNewTabOverride(devtoolsForBrowser) : false;
|
|
1166
|
+
const shouldSkipDevtoolsForNtpConflict = userHasNewTabOverride && devtoolsHasNewTabOverride;
|
|
1167
|
+
if (devtoolsForBrowser && !shouldSkipDevtoolsForNtpConflict) list.push(devtoolsForBrowser);
|
|
1168
|
+
if (themeForBrowser) list.push(themeForBrowser);
|
|
1169
|
+
} catch {}
|
|
1170
|
+
for (const p of extraExtensionDirs)list.push(p);
|
|
1171
|
+
list.push(userExtensionOutputPath);
|
|
1172
|
+
return list;
|
|
1173
|
+
}
|
|
1174
|
+
function getDarkModeDefaults(browser) {
|
|
1175
|
+
if ('chrome' === browser || 'edge' === browser || 'chromium' === browser || 'chromium-based' === browser) return {
|
|
1176
|
+
browserFlags: [
|
|
1177
|
+
'--force-dark-mode',
|
|
1178
|
+
'--enable-features=WebUIDarkMode'
|
|
1179
|
+
],
|
|
1180
|
+
preferences: {}
|
|
1181
|
+
};
|
|
1182
|
+
if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return {
|
|
1183
|
+
browserFlags: [],
|
|
1184
|
+
preferences: {
|
|
1185
|
+
'ui.systemUsesDarkTheme': 1,
|
|
1186
|
+
'layout.css.prefers-color-scheme.content-override': 2,
|
|
1187
|
+
'devtools.theme': 'dark'
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
return {
|
|
1191
|
+
browserFlags: [],
|
|
1192
|
+
preferences: {}
|
|
1193
|
+
};
|
|
1231
1194
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
if (themeForBrowser) list.push(themeForBrowser);
|
|
1251
|
-
} catch {}
|
|
1252
|
-
for (const p of extraExtensionDirs)list.push(p);
|
|
1253
|
-
list.push(userExtensionOutputPath);
|
|
1254
|
-
return list;
|
|
1255
|
-
}
|
|
1256
|
-
function getDarkModeDefaults(browser) {
|
|
1257
|
-
if ('chrome' === browser || 'edge' === browser || 'chromium' === browser || 'chromium-based' === browser) return {
|
|
1258
|
-
browserFlags: [
|
|
1259
|
-
'--force-dark-mode',
|
|
1260
|
-
'--enable-features=WebUIDarkMode'
|
|
1261
|
-
],
|
|
1262
|
-
preferences: {}
|
|
1263
|
-
};
|
|
1264
|
-
if ('firefox' === browser || 'gecko-based' === browser || 'firefox-based' === browser) return {
|
|
1265
|
-
browserFlags: [],
|
|
1266
|
-
preferences: {
|
|
1267
|
-
'ui.systemUsesDarkTheme': 1,
|
|
1268
|
-
'layout.css.prefers-color-scheme.content-override': 2,
|
|
1269
|
-
'devtools.theme': 'dark'
|
|
1270
|
-
}
|
|
1271
|
-
};
|
|
1272
|
-
return {
|
|
1273
|
-
browserFlags: [],
|
|
1274
|
-
preferences: {}
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
function withDarkMode(config) {
|
|
1278
|
-
const defaults = getDarkModeDefaults(config.browser);
|
|
1279
|
-
const existingFlags = Array.isArray(config.browserFlags) ? [
|
|
1280
|
-
...config.browserFlags
|
|
1281
|
-
] : [];
|
|
1282
|
-
const nextFlags = [
|
|
1283
|
-
...existingFlags
|
|
1284
|
-
];
|
|
1285
|
-
for (const flag of defaults.browserFlags || [])if (!nextFlags.some((f)=>String(f).trim() === flag)) nextFlags.push(flag);
|
|
1286
|
-
const nextPreferences = {
|
|
1287
|
-
...config.preferences || {},
|
|
1288
|
-
...Object.fromEntries(Object.entries(defaults.preferences || {}).filter(([k])=>!(k in (config.preferences || {}))))
|
|
1289
|
-
};
|
|
1290
|
-
return {
|
|
1291
|
-
...config,
|
|
1292
|
-
browserFlags: nextFlags,
|
|
1293
|
-
preferences: nextPreferences
|
|
1294
|
-
};
|
|
1295
|
-
}
|
|
1296
|
-
var external_pintor_ = __webpack_require__("pintor");
|
|
1297
|
-
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
|
|
1298
|
-
function readJsonRecord(filePath) {
|
|
1299
|
-
try {
|
|
1300
|
-
return JSON.parse(external_fs_.readFileSync(filePath, 'utf8'));
|
|
1301
|
-
} catch {
|
|
1302
|
-
return null;
|
|
1195
|
+
function withDarkMode(config) {
|
|
1196
|
+
const defaults = getDarkModeDefaults(config.browser);
|
|
1197
|
+
const existingFlags = Array.isArray(config.browserFlags) ? [
|
|
1198
|
+
...config.browserFlags
|
|
1199
|
+
] : [];
|
|
1200
|
+
const nextFlags = [
|
|
1201
|
+
...existingFlags
|
|
1202
|
+
];
|
|
1203
|
+
for (const flag of defaults.browserFlags || [])if (!nextFlags.some((f)=>String(f).trim() === flag)) nextFlags.push(flag);
|
|
1204
|
+
const nextPreferences = {
|
|
1205
|
+
...config.preferences || {},
|
|
1206
|
+
...Object.fromEntries(Object.entries(defaults.preferences || {}).filter(([k])=>!(k in (config.preferences || {}))))
|
|
1207
|
+
};
|
|
1208
|
+
return {
|
|
1209
|
+
...config,
|
|
1210
|
+
browserFlags: nextFlags,
|
|
1211
|
+
preferences: nextPreferences
|
|
1212
|
+
};
|
|
1303
1213
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
}
|
|
1308
|
-
function getExtensionVersion() {
|
|
1309
|
-
return process.env.EXTENSION_DEVELOP_VERSION || process.env.EXTENSION_CLI_VERSION || (()=>{
|
|
1214
|
+
var external_pintor_ = __webpack_require__("pintor");
|
|
1215
|
+
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
|
|
1216
|
+
function readJsonRecord(filePath) {
|
|
1310
1217
|
try {
|
|
1311
|
-
return
|
|
1218
|
+
return JSON.parse(external_fs_.readFileSync(filePath, 'utf8'));
|
|
1312
1219
|
} catch {
|
|
1313
|
-
return
|
|
1220
|
+
return null;
|
|
1314
1221
|
}
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
metadata.writeError('preview_manifest_missing', `Expected manifest at ${manifestAtOutput}`);
|
|
1364
|
-
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.`);
|
|
1365
|
-
}
|
|
1366
|
-
const commandConfig = await loadCommandConfig(packageJsonDir, metadataCommand);
|
|
1367
|
-
const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
|
|
1368
|
-
console.log(lib_messages.V_(browser));
|
|
1369
|
-
if (previewOptions.noBrowser) {
|
|
1370
|
-
console.log(lib_messages.k4(browser));
|
|
1371
|
-
metadata.writeReady();
|
|
1372
|
-
console.log(spacerLine());
|
|
1373
|
-
const browserLabel = String(browser || 'unknown');
|
|
1374
|
-
console.log(browserRunnerDisabled({
|
|
1375
|
-
browser: browserLabel,
|
|
1222
|
+
}
|
|
1223
|
+
function capitalizeToken(value) {
|
|
1224
|
+
return value.split('-').filter(Boolean).map((token)=>token.charAt(0).toUpperCase() + token.slice(1)).join('-');
|
|
1225
|
+
}
|
|
1226
|
+
function getExtensionVersion() {
|
|
1227
|
+
return process.env.EXTENSION_DEVELOP_VERSION || process.env.EXTENSION_CLI_VERSION || (()=>{
|
|
1228
|
+
try {
|
|
1229
|
+
return __webpack_require__("./package.json").rE;
|
|
1230
|
+
} catch {
|
|
1231
|
+
return 'unknown';
|
|
1232
|
+
}
|
|
1233
|
+
})();
|
|
1234
|
+
}
|
|
1235
|
+
function browserRunnerDisabled(args) {
|
|
1236
|
+
const manifest = readJsonRecord(args.manifestPath);
|
|
1237
|
+
const ready = readJsonRecord(args.readyPath);
|
|
1238
|
+
const browserLabel = capitalizeToken(String(args.browser || 'unknown'));
|
|
1239
|
+
const runId = String(ready?.runId || '').trim();
|
|
1240
|
+
const pid = Number.isInteger(ready?.pid) ? String(ready?.pid) : '';
|
|
1241
|
+
const runLabel = runId ? `${external_pintor_default().gray(runId)}${pid ? ` · ${external_pintor_default().gray(`PID ${pid}`)}` : ''}` : pid ? external_pintor_default().gray(`PID ${pid}`) : external_pintor_default().gray('n/a');
|
|
1242
|
+
const extensionName = String(manifest?.name || 'Extension');
|
|
1243
|
+
const extensionVersion = String(manifest?.version || '').trim();
|
|
1244
|
+
const extensionLabel = extensionVersion ? `${extensionName} ${extensionVersion}` : extensionName;
|
|
1245
|
+
const extensionJsVersion = getExtensionVersion();
|
|
1246
|
+
return [
|
|
1247
|
+
` 🧩 ${external_pintor_default().brightBlue('Extension.js')} ${external_pintor_default().gray(extensionJsVersion)}`,
|
|
1248
|
+
` Browser ${external_pintor_default().gray(args.browserModeLabel || `${browserLabel} (build-only mode)`)}`,
|
|
1249
|
+
` Extension ${external_pintor_default().gray(extensionLabel)}`,
|
|
1250
|
+
` Run ID ${runLabel}`
|
|
1251
|
+
].join('\n');
|
|
1252
|
+
}
|
|
1253
|
+
function spacerLine() {
|
|
1254
|
+
return ' ';
|
|
1255
|
+
}
|
|
1256
|
+
async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher) {
|
|
1257
|
+
const projectStructure = await getProjectStructure(pathOrRemoteUrl);
|
|
1258
|
+
const debug = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
1259
|
+
const { manifestDir, packageJsonDir } = getDirs(projectStructure);
|
|
1260
|
+
if (projectStructure.packageJsonPath) assertNoManagedDependencyConflicts(projectStructure.packageJsonPath, packageJsonDir);
|
|
1261
|
+
const browser = normalizeBrowser(previewOptions.browser || 'chrome', previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary);
|
|
1262
|
+
const outputPath = computePreviewOutputPath(projectStructure, browser, previewOptions.outputPath);
|
|
1263
|
+
const distPath = getDistPath(packageJsonDir, browser);
|
|
1264
|
+
const metadataCommand = 'start' === previewOptions.metadataCommand ? 'start' : 'preview';
|
|
1265
|
+
const metadata = createPlaywrightMetadataWriter({
|
|
1266
|
+
packageJsonDir,
|
|
1267
|
+
browser: String(browser),
|
|
1268
|
+
command: metadataCommand,
|
|
1269
|
+
distPath,
|
|
1376
1270
|
manifestPath: projectStructure.manifestPath,
|
|
1271
|
+
port: 'number' == typeof previewOptions.port ? previewOptions.port : 'string' == typeof previewOptions.port ? parseInt(previewOptions.port, 10) : null
|
|
1272
|
+
});
|
|
1273
|
+
metadata.writeStarting();
|
|
1274
|
+
if (debug) {
|
|
1275
|
+
console.log(lib_messages.SG(manifestDir, packageJsonDir));
|
|
1276
|
+
console.log(lib_messages._A(browser, previewOptions.chromiumBinary, previewOptions.geckoBinary || previewOptions.firefoxBinary));
|
|
1277
|
+
console.log(lib_messages.jV(outputPath, distPath));
|
|
1278
|
+
}
|
|
1279
|
+
const manifestAtOutput = external_path_.join(outputPath, 'manifest.json');
|
|
1280
|
+
if (!external_fs_.existsSync(manifestAtOutput)) {
|
|
1281
|
+
metadata.writeError('preview_manifest_missing', `Expected manifest at ${manifestAtOutput}`);
|
|
1282
|
+
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.`);
|
|
1283
|
+
}
|
|
1284
|
+
const commandConfig = await loadCommandConfig(packageJsonDir, metadataCommand);
|
|
1285
|
+
const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
|
|
1286
|
+
console.log(lib_messages.V_(browser));
|
|
1287
|
+
if (previewOptions.noBrowser) {
|
|
1288
|
+
console.log(lib_messages.k4(browser));
|
|
1289
|
+
metadata.writeReady();
|
|
1290
|
+
console.log(spacerLine());
|
|
1291
|
+
const browserLabel = String(browser || 'unknown');
|
|
1292
|
+
console.log(browserRunnerDisabled({
|
|
1293
|
+
browser: browserLabel,
|
|
1294
|
+
manifestPath: projectStructure.manifestPath,
|
|
1295
|
+
readyPath: metadata.readyPath,
|
|
1296
|
+
browserModeLabel: `${browserLabel.charAt(0).toUpperCase() + browserLabel.slice(1)} (no-browser mode)`
|
|
1297
|
+
}));
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
const safeBrowserConfig = sanitize(browserConfig);
|
|
1301
|
+
const safeCommandConfig = sanitize(commandConfig);
|
|
1302
|
+
const safePreviewOptions = sanitize(previewOptions);
|
|
1303
|
+
const specialFoldersData = getSpecialFoldersDataForProjectRoot(packageJsonDir);
|
|
1304
|
+
const mergedExtensionsConfig = safePreviewOptions.extensions ?? safeCommandConfig.extensions ?? safeBrowserConfig.extensions ?? specialFoldersData.extensions;
|
|
1305
|
+
const resolvedExtensionsConfig = await resolveCompanionExtensionsConfig({
|
|
1306
|
+
projectRoot: packageJsonDir,
|
|
1307
|
+
browser,
|
|
1308
|
+
config: mergedExtensionsConfig
|
|
1309
|
+
});
|
|
1310
|
+
const mergedGeckoBinary = safePreviewOptions.geckoBinary || safePreviewOptions.firefoxBinary || safeCommandConfig.geckoBinary || safeCommandConfig.firefoxBinary || safeBrowserConfig.geckoBinary || safeBrowserConfig.firefoxBinary;
|
|
1311
|
+
const mergedChromiumBinary = safePreviewOptions.chromiumBinary || safeCommandConfig.chromiumBinary || safeBrowserConfig.chromiumBinary;
|
|
1312
|
+
const merged = {
|
|
1313
|
+
...safeBrowserConfig,
|
|
1314
|
+
...safeCommandConfig,
|
|
1315
|
+
...safePreviewOptions,
|
|
1316
|
+
extensions: resolvedExtensionsConfig,
|
|
1317
|
+
chromiumBinary: mergedChromiumBinary,
|
|
1318
|
+
geckoBinary: mergedGeckoBinary
|
|
1319
|
+
};
|
|
1320
|
+
const darkDefaults = withDarkMode({
|
|
1321
|
+
browser,
|
|
1322
|
+
browserFlags: merged.browserFlags,
|
|
1323
|
+
preferences: merged.preferences
|
|
1324
|
+
});
|
|
1325
|
+
const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
|
|
1326
|
+
projectRoot: packageJsonDir,
|
|
1327
|
+
config: merged.extensions
|
|
1328
|
+
});
|
|
1329
|
+
const unpackedExtensionDirsToLoad = computeExtensionsToLoad(external_path_.resolve(__dirname, '..'), 'production', browser, outputPath, companionUnpackedExtensionDirs, projectStructure.manifestPath);
|
|
1330
|
+
const resolvedOpts = {
|
|
1331
|
+
browser,
|
|
1332
|
+
outPath: outputPath,
|
|
1333
|
+
contextDir: packageJsonDir,
|
|
1377
1334
|
readyPath: metadata.readyPath,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1335
|
+
extensionsToLoad: unpackedExtensionDirsToLoad,
|
|
1336
|
+
noOpen: merged.noOpen,
|
|
1337
|
+
profile: merged.profile,
|
|
1338
|
+
persistProfile: merged.persistProfile,
|
|
1339
|
+
preferences: darkDefaults.preferences,
|
|
1340
|
+
browserFlags: darkDefaults.browserFlags,
|
|
1341
|
+
excludeBrowserFlags: merged.excludeBrowserFlags,
|
|
1342
|
+
startingUrl: merged.startingUrl,
|
|
1343
|
+
chromiumBinary: merged.chromiumBinary,
|
|
1344
|
+
geckoBinary: merged.geckoBinary,
|
|
1345
|
+
instanceId: merged.instanceId,
|
|
1346
|
+
port: merged.port,
|
|
1347
|
+
dryRun: merged.dryRun
|
|
1348
|
+
};
|
|
1349
|
+
if (!browserLauncher) throw new Error("extensionPreview requires a browserLauncher callback. The browser launch code has moved to programs/extension/browsers/.");
|
|
1350
|
+
await browserLauncher(resolvedOpts);
|
|
1351
|
+
metadata.writeReady();
|
|
1352
|
+
}
|
|
1353
|
+
},
|
|
1354
|
+
"adm-zip" (module) {
|
|
1355
|
+
module.exports = require("adm-zip");
|
|
1356
|
+
},
|
|
1357
|
+
fs (module) {
|
|
1358
|
+
module.exports = require("fs");
|
|
1359
|
+
},
|
|
1360
|
+
path (module) {
|
|
1361
|
+
module.exports = require("path");
|
|
1362
|
+
},
|
|
1363
|
+
pintor (module) {
|
|
1364
|
+
module.exports = require("pintor");
|
|
1365
|
+
},
|
|
1366
|
+
"./package.json" (module) {
|
|
1367
|
+
module.exports = JSON.parse('{"rE":"3.15.0-next.1","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.0.1","@rspack/dev-server":"^2.0.1","@rspack/plugin-preact-refresh":"1.1.5","@rspack/plugin-react-refresh":"1.6.2","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.2","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.10","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.7","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","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"}}');
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
var __webpack_module_cache__ = {};
|
|
1371
|
+
function __webpack_require__(moduleId) {
|
|
1372
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
1373
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
1374
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
1375
|
+
exports: {}
|
|
1376
|
+
};
|
|
1377
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
1378
|
+
return module.exports;
|
|
1379
|
+
}
|
|
1380
|
+
__webpack_require__.m = __webpack_modules__;
|
|
1381
|
+
(()=>{
|
|
1382
|
+
__webpack_require__.n = (module)=>{
|
|
1383
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
1384
|
+
__webpack_require__.d(getter, {
|
|
1385
|
+
a: getter
|
|
1391
1386
|
});
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1387
|
+
return getter;
|
|
1388
|
+
};
|
|
1389
|
+
})();
|
|
1390
|
+
(()=>{
|
|
1391
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
1392
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
1393
|
+
enumerable: true,
|
|
1394
|
+
get: definition[key]
|
|
1395
|
+
});
|
|
1396
|
+
};
|
|
1397
|
+
})();
|
|
1398
|
+
(()=>{
|
|
1399
|
+
__webpack_require__.f = {};
|
|
1400
|
+
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
1401
|
+
__webpack_require__.f[key](chunkId, promises);
|
|
1402
|
+
return promises;
|
|
1403
|
+
}, []));
|
|
1404
|
+
})();
|
|
1405
|
+
(()=>{
|
|
1406
|
+
__webpack_require__.u = (chunkId)=>"" + chunkId + ".cjs";
|
|
1407
|
+
})();
|
|
1408
|
+
(()=>{
|
|
1409
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1410
|
+
})();
|
|
1411
|
+
(()=>{
|
|
1412
|
+
__webpack_require__.r = (exports1)=>{
|
|
1413
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
1414
|
+
value: 'Module'
|
|
1406
1415
|
});
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
config: merged.extensions
|
|
1416
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
1417
|
+
value: true
|
|
1410
1418
|
});
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
geckoBinary: merged.geckoBinary,
|
|
1427
|
-
instanceId: merged.instanceId,
|
|
1428
|
-
port: merged.port,
|
|
1429
|
-
dryRun: merged.dryRun
|
|
1430
|
-
};
|
|
1431
|
-
if (!browserLauncher) throw new Error("extensionPreview requires a browserLauncher callback. The browser launch code has moved to programs/extension/browsers/.");
|
|
1432
|
-
await browserLauncher(resolvedOpts);
|
|
1433
|
-
metadata.writeReady();
|
|
1434
|
-
}
|
|
1419
|
+
};
|
|
1420
|
+
})();
|
|
1421
|
+
(()=>{
|
|
1422
|
+
var installedChunks = {
|
|
1423
|
+
534: 1
|
|
1424
|
+
};
|
|
1425
|
+
var installChunk = (chunk)=>{
|
|
1426
|
+
var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;
|
|
1427
|
+
for(var moduleId in moreModules)if (__webpack_require__.o(moreModules, moduleId)) __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
1428
|
+
if (runtime) runtime(__webpack_require__);
|
|
1429
|
+
for(var i = 0; i < chunkIds.length; i++)installedChunks[chunkIds[i]] = 1;
|
|
1430
|
+
};
|
|
1431
|
+
__webpack_require__.f.require = (chunkId, promises)=>{
|
|
1432
|
+
if (!installedChunks[chunkId]) installChunk(require("./" + __webpack_require__.u(chunkId)));
|
|
1433
|
+
};
|
|
1435
1434
|
})();
|
|
1435
|
+
var __webpack_exports__ = __webpack_require__("./preview-entry.ts");
|
|
1436
1436
|
exports.extensionPreview = __webpack_exports__.extensionPreview;
|
|
1437
1437
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
1438
1438
|
"extensionPreview"
|