@stacksjs/browser-extension 0.70.165 → 0.70.167

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.
@@ -2,8 +2,14 @@ import type { ExtensionConfig, FirefoxAddonsConfig } from './types';
2
2
  export declare function firefoxSignArgs(options: FirefoxSignArgsOptions): string[];
3
3
  /** Metadata accepted by AMO v5 when web-ext creates the first listed version. */
4
4
  export declare function firefoxListingMetadata(config: ExtensionConfig, store: FirefoxAddonsConfig): Record<string, unknown> | undefined;
5
- /** Resolve web-ext from PATH or from this package's declared dependency. */
6
- export declare function resolveWebExtExecutable(which?: (command: string) => string | null): string | undefined;
5
+ /**
6
+ * Resolve web-ext from PATH, or from wherever the app installed it.
7
+ *
8
+ * web-ext is an optional peer dependency: it is only needed to sign and
9
+ * submit a Firefox build, so extensions targeting Chrome or Safari (and every
10
+ * app that never builds an extension at all) skip a ~40MB install.
11
+ */
12
+ export declare function resolveWebExtExecutable(which?: (command: string) => string | null, resolvePackage?: (specifier: string) => string): string | undefined;
7
13
  /** Build and submit a Firefox extension through Mozilla's official web-ext/AMO v5 flow. */
8
14
  export declare function publishFirefoxExtension(config: ExtensionConfig, options: FirefoxPublishOptions): Promise<FirefoxPublishResult>;
9
15
  export declare interface FirefoxAddonsAuth {
@@ -41,12 +41,12 @@ export function firefoxListingMetadata(config, store) {
41
41
  requires_payment: store.requiresPayment ?? !1
42
42
  };
43
43
  }
44
- export function resolveWebExtExecutable(which = Bun.which) {
44
+ export function resolveWebExtExecutable(which = Bun.which, resolvePackage = (specifier) => createRequire(import.meta.url).resolve(specifier)) {
45
45
  const fromPath = which("web-ext");
46
46
  if (fromPath)
47
47
  return fromPath;
48
48
  try {
49
- const packagePath = createRequire(import.meta.url).resolve("web-ext/package.json"), packageJson = JSON.parse(readFileSync(packagePath, "utf8")), relativeBin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.["web-ext"];
49
+ const packagePath = resolvePackage("web-ext/package.json"), packageJson = JSON.parse(readFileSync(packagePath, "utf8")), relativeBin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.["web-ext"];
50
50
  if (!relativeBin)
51
51
  return;
52
52
  const executable = resolve(packagePath, "..", relativeBin);
@@ -63,7 +63,7 @@ export async function publishFirefoxExtension(config, options) {
63
63
  await buildExtension(config, { target: "firefox", version: options.version, cwd });
64
64
  const sourceDir = resolve(cwd, resolveOutdir(config, "firefox")), artifactsDir = resolve(cwd, store.artifactsDir ?? "web-ext-artifacts"), executable = resolveWebExtExecutable();
65
65
  if (!executable)
66
- throw Error("[browser-extension] web-ext is unavailable; reinstall @stacksjs/browser-extension dependencies");
66
+ throw Error("[browser-extension] Firefox publishing needs web-ext, an optional peer dependency. Install it with `bun add -d web-ext`.");
67
67
  await mkdir(artifactsDir, { recursive: !0 });
68
68
  const before = new Set(existsSync(artifactsDir) ? readdirSync(artifactsDir) : []), tempDir = await mkdtemp(join(tmpdir(), "stacks-firefox-publish-"));
69
69
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/browser-extension",
3
3
  "type": "module",
4
- "version": "0.70.165",
4
+ "version": "0.70.167",
5
5
  "description": "Build MV3 browser extensions (Chrome, Firefox, Safari) the Stacks way — manifest, content/background scripts, DNR rules, packaging, Safari container app, all config-driven.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -57,10 +57,15 @@
57
57
  "typecheck": "bun tsc --noEmit",
58
58
  "prepublishOnly": "bun run build"
59
59
  },
60
+ "peerDependencies": {
61
+ "web-ext": ">=8"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "web-ext": {
65
+ "optional": true
66
+ }
67
+ },
60
68
  "devDependencies": {
61
69
  "better-dx": "^0.2.17"
62
- },
63
- "dependencies": {
64
- "web-ext": "^10.5.0"
65
70
  }
66
71
  }