extension-develop 3.15.1 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0~branding.mjs +26 -0
- package/dist/0~dev-server.mjs +488 -0
- package/dist/0~rslib-runtime.mjs +40 -0
- package/dist/0~rspack-config.mjs +8648 -0
- package/dist/0~stats-handler.mjs +25 -0
- package/dist/0~zip.mjs +34 -0
- package/dist/314.mjs +35 -0
- package/dist/526.mjs +23 -0
- package/dist/946.mjs +1670 -0
- package/dist/962.mjs +1389 -0
- package/dist/ensure-hmr-for-scripts.js +12 -56
- package/dist/{ensure-hmr-for-scripts.cjs → ensure-hmr-for-scripts.mjs} +12 -56
- package/dist/feature-scripts-content-script-wrapper.js +23 -98
- package/dist/{feature-scripts-content-script-wrapper.cjs → feature-scripts-content-script-wrapper.mjs} +23 -98
- package/dist/main-world-bridge.js +0 -18
- package/dist/{main-world-bridge.cjs → main-world-bridge.mjs} +0 -18
- package/dist/minimum-chromium-file.js +0 -5
- package/dist/minimum-chromium-file.mjs +5 -0
- package/dist/minimum-firefox-file.js +0 -5
- package/dist/minimum-firefox-file.mjs +5 -0
- package/dist/minimum-script-file.js +0 -18
- package/dist/{minimum-script-file.cjs → minimum-script-file.mjs} +0 -18
- package/dist/module.mjs +3 -0
- package/dist/package.json +1 -1
- package/dist/preact-refresh-shim.mjs +7 -0
- package/dist/preview.mjs +2 -0
- package/dist/resolve-paths-loader.js +1043 -1093
- package/dist/resolve-paths-loader.mjs +1300 -0
- package/package.json +8 -8
- package/dist/221.cjs +0 -513
- package/dist/442.cjs +0 -9226
- package/dist/504.cjs +0 -65
- package/dist/787.cjs +0 -44
- package/dist/minimum-chromium-file.cjs +0 -10
- package/dist/minimum-firefox-file.cjs +0 -10
- package/dist/module.cjs +0 -3479
- package/dist/preact-refresh-shim.cjs +0 -25
- package/dist/preview.cjs +0 -1464
- package/dist/resolve-paths-loader.cjs +0 -1350
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
+
import { scrubBrand } from "./0~branding.mjs";
|
|
3
|
+
function handleStatsErrors(stats) {
|
|
4
|
+
try {
|
|
5
|
+
const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
|
|
6
|
+
const str = stats.toString({
|
|
7
|
+
colors: true,
|
|
8
|
+
all: false,
|
|
9
|
+
errors: true,
|
|
10
|
+
warnings: !!verbose
|
|
11
|
+
});
|
|
12
|
+
if (str) console.error(scrubBrand(str));
|
|
13
|
+
} catch {
|
|
14
|
+
try {
|
|
15
|
+
const str = stats.toString({
|
|
16
|
+
colors: true,
|
|
17
|
+
all: false,
|
|
18
|
+
errors: true,
|
|
19
|
+
warnings: true
|
|
20
|
+
});
|
|
21
|
+
if (str) console.error(scrubBrand(str));
|
|
22
|
+
} catch {}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export { handleStatsErrors };
|
package/dist/0~zip.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
+
import adm_zip from "adm-zip";
|
|
3
|
+
import { unpackagingExtension, failedToDownloadOrExtractZIPFileError, invalidRemoteZip, unpackagedSuccessfully, downloadingText } from "./946.mjs";
|
|
4
|
+
import * as __rspack_external_path from "path";
|
|
5
|
+
async function downloadAndExtractZip(url, targetPath) {
|
|
6
|
+
const urlNoSearchParams = url.split('?')[0];
|
|
7
|
+
try {
|
|
8
|
+
console.log(downloadingText(urlNoSearchParams));
|
|
9
|
+
const res = await fetch(url, {
|
|
10
|
+
redirect: 'follow'
|
|
11
|
+
});
|
|
12
|
+
if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
13
|
+
const contentType = String(res.headers.get('content-type') || '');
|
|
14
|
+
const isZipExt = '.zip' === __rspack_external_path.extname(urlNoSearchParams).toLowerCase();
|
|
15
|
+
const isZipType = /zip|octet-stream/i.test(contentType);
|
|
16
|
+
if (!isZipExt && !isZipType) throw new Error(`${invalidRemoteZip(urlNoSearchParams, contentType)}`);
|
|
17
|
+
const extname = __rspack_external_path.extname(urlNoSearchParams);
|
|
18
|
+
const basename = __rspack_external_path.basename(urlNoSearchParams, extname);
|
|
19
|
+
const destinationPath = __rspack_external_path.join(targetPath, basename);
|
|
20
|
+
console.log(unpackagingExtension(destinationPath));
|
|
21
|
+
const arrayBuffer = await res.arrayBuffer();
|
|
22
|
+
const zipBuffer = Buffer.from(arrayBuffer);
|
|
23
|
+
const zip = new adm_zip(zipBuffer);
|
|
24
|
+
zip.extractAllTo(destinationPath, true);
|
|
25
|
+
console.log(unpackagedSuccessfully());
|
|
26
|
+
return destinationPath;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(failedToDownloadOrExtractZIPFileError(error));
|
|
29
|
+
const err = new Error(`${failedToDownloadOrExtractZIPFileError(error)}`);
|
|
30
|
+
err.code = 'EZIP';
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export { downloadAndExtractZip };
|
package/dist/314.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
+
import pintor from "pintor";
|
|
3
|
+
import * as __rspack_external_fs from "fs";
|
|
4
|
+
import * as __rspack_external_path from "path";
|
|
5
|
+
function findUpLocalSync(filename, options) {
|
|
6
|
+
const root = __rspack_external_path.parse(options.cwd).root;
|
|
7
|
+
let currentDir = options.cwd;
|
|
8
|
+
while(true){
|
|
9
|
+
const candidate = __rspack_external_path.join(currentDir, filename);
|
|
10
|
+
try {
|
|
11
|
+
const stat = __rspack_external_fs.statSync(candidate);
|
|
12
|
+
if (stat.isFile()) return candidate;
|
|
13
|
+
} catch {}
|
|
14
|
+
if (currentDir === root) return;
|
|
15
|
+
currentDir = __rspack_external_path.dirname(currentDir);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function findNearestPackageJsonSync(manifestPath) {
|
|
19
|
+
try {
|
|
20
|
+
const manifestDir = __rspack_external_path.dirname(manifestPath);
|
|
21
|
+
return findUpLocalSync('package.json', {
|
|
22
|
+
cwd: manifestDir
|
|
23
|
+
}) || null;
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function backgroundIsRequiredMessageOnly(backgroundChunkName) {
|
|
29
|
+
return `Check the ${pintor.yellow(backgroundChunkName.replace('/', '.'))} field in your ${pintor.yellow('manifest.json')} file.`;
|
|
30
|
+
}
|
|
31
|
+
function reservedScriptsFolder(relPath, indicators) {
|
|
32
|
+
const reasons = indicators.map((r)=>`- ${pintor.gray(r)}`).join('\n');
|
|
33
|
+
return `${pintor.red('ERROR')} scripts/ is a reserved folder in Extension.js.\nEvery file under ${pintor.yellow("scripts/")} is wrapped with the browser content-script mount runtime, so Node.js-only files placed here will fail to parse or run.\nRename the folder at the project root (for example ${pintor.yellow('bin/')}, ${pintor.yellow('tools/')}, ${pintor.yellow('ops/')}, ${pintor.yellow('tasks/')}, or ${pintor.yellow("ci-scripts/")}) or move the file out of scripts/.\n\n${pintor.red('NODE.JS SHAPE')}\n${reasons}\n${pintor.red('NOT ALLOWED')} ${pintor.underline(relPath)}`;
|
|
34
|
+
}
|
|
35
|
+
export { backgroundIsRequiredMessageOnly, findNearestPackageJsonSync, reservedScriptsFolder };
|
package/dist/526.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
+
const EXTENSIONJS_CONTENT_SCRIPT_LAYER = "extensionjs-content-script";
|
|
3
|
+
const CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX = "content_scripts/content-";
|
|
4
|
+
function getCanonicalContentScriptEntryName(index) {
|
|
5
|
+
return `${CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX}${index}`;
|
|
6
|
+
}
|
|
7
|
+
function getCanonicalContentScriptJsAssetName(index) {
|
|
8
|
+
return `${getCanonicalContentScriptEntryName(index)}.js`;
|
|
9
|
+
}
|
|
10
|
+
function getCanonicalContentScriptCssAssetName(index) {
|
|
11
|
+
return `${getCanonicalContentScriptEntryName(index)}.css`;
|
|
12
|
+
}
|
|
13
|
+
function parseCanonicalContentScriptAsset(assetName) {
|
|
14
|
+
const match = /^content_scripts\/content-(\d+)(?:\.[a-f0-9]+)?\.(js|css)$/i.exec(String(assetName || ''));
|
|
15
|
+
if (!match) return;
|
|
16
|
+
const index = Number(match[1]);
|
|
17
|
+
if (!Number.isInteger(index)) return;
|
|
18
|
+
return {
|
|
19
|
+
index,
|
|
20
|
+
extension: match[2]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX, EXTENSIONJS_CONTENT_SCRIPT_LAYER, getCanonicalContentScriptCssAssetName, getCanonicalContentScriptEntryName, getCanonicalContentScriptJsAssetName, parseCanonicalContentScriptAsset };
|