@gjsify/cli 0.64.37 → 0.64.40

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.
@@ -52,6 +52,7 @@ import { isNodeRuntimeTarget, resolveNodeRuntime } from '../utils/ship/node-runt
52
52
  import { isUnder, SHARE } from '../utils/ship/share-dirs.js';
53
53
  import { compileSchemasForPayload, compileSchemasForStage } from '../utils/ship/schemas.js';
54
54
  import { buildMsi, MSI_PAYLOAD_DIR } from '../utils/ship/msi.js';
55
+ import { buildLinuxTarball } from '../utils/ship/tarball.js';
55
56
  import { buildZip, zipEntriesFromPayload } from '../utils/ship/zip.js';
56
57
  import { assertEntryRunsUnder } from '../utils/ship/entry-interpreter.js';
57
58
  import { scanGiRequirements } from '@gjsify/rolldown-plugin-gjsify';
@@ -1247,6 +1248,22 @@ async function packOne(input) {
1247
1248
  });
1248
1249
  break;
1249
1250
  }
1251
+ case 'linux-tar':
1252
+ case 'linux-tar-flatpak': {
1253
+ // FROM THE PAYLOAD, like every container here. The Flatpak variant adds
1254
+ // the one file the shared Linux stage cannot carry — see the `appimage`
1255
+ // arm for why the compile is on the pack path — and nothing else.
1256
+ const schemaCache = format.id === 'linux-tar-flatpak'
1257
+ ? await compileSchemasForPayload({ payload, workDir: join(outRoot, 'tar-schemas') })
1258
+ : undefined;
1259
+ writeFileSync(target, await buildLinuxTarball({
1260
+ settings,
1261
+ payload: schemaCache === undefined ? payload : [...payload, schemaCache],
1262
+ archLabel,
1263
+ mtime,
1264
+ }));
1265
+ break;
1266
+ }
1250
1267
  case 'macos-app':
1251
1268
  case 'windows-dir':
1252
1269
  // ONE STATEMENT FOR TWO ROWS, folded because the code really is
@@ -15,6 +15,7 @@ export declare const webextZipCommand: Command<unknown, WebextArgs>;
15
15
  export declare const webextDevCommand: Command<unknown, WebextArgs>;
16
16
  interface ListingArgs {
17
17
  store: string;
18
+ stores?: string;
18
19
  out?: string;
19
20
  check: boolean;
20
21
  metainfo?: string;
@@ -213,6 +213,10 @@ export const webextListingCommand = {
213
213
  type: 'string',
214
214
  choices: ['cws', 'edge', 'amo', 'all'],
215
215
  default: 'all',
216
+ })
217
+ .option('stores', {
218
+ description: 'Several stores at once, comma separated (cws,edge,amo) or all; wins over --store.',
219
+ type: 'string',
216
220
  })
217
221
  .option('out', { description: 'Output directory, emptied first (default: dist/listing).', type: 'string' })
218
222
  .option('check', {
@@ -243,7 +247,7 @@ export const webextListingCommand = {
243
247
  .option('globals', { description: 'Value for `gjsify build --globals` (default: auto).', type: 'string' }),
244
248
  handler: async (args) => {
245
249
  const cwd = process.cwd();
246
- const forwarded = ['listing', '--store', args.store];
250
+ const forwarded = ['listing', '--store', args.stores ?? args.store];
247
251
  if (args.root)
248
252
  forwarded.push('--root', resolve(cwd, args.root));
249
253
  if (args.out)
@@ -99,6 +99,35 @@ export declare function resolveGtkRuntime(target: GtkRuntimeTarget, options?: Re
99
99
  * built against, which is #910's failure shape wearing a convenience.
100
100
  */
101
101
  export declare function resolveNodeGiAddon(target: GtkRuntimeTarget, options?: ResolveRuntimeOptions): ResolvedNodeGiAddon | null;
102
+ /** The facade `@gjsify/adwaita-app` lists as an optionalDependency (ADR 0141). */
103
+ export declare const QUARTZ_BRIDGE_FACADE = "@gjsify/gtk-quartz-native";
104
+ /** The bridge's GI typelib and library, as both per-target companions name them. */
105
+ export declare const QUARTZ_BRIDGE_TYPELIB = "GjsifyQuartz-1.0.typelib";
106
+ export declare const QUARTZ_BRIDGE_LIBRARY = "libgjsifyquartz.dylib";
107
+ /** The per-target companion carrying the bridge's prebuild. Only darwin targets have one. */
108
+ export declare function quartzBridgePackageName(target: GtkRuntimeTarget): string;
109
+ /** The Dock-reopen bridge's prebuild, once found. */
110
+ export interface ResolvedQuartzBridge {
111
+ source: string;
112
+ typelibPath: string;
113
+ libraryPath: string;
114
+ }
115
+ /**
116
+ * Locate the Dock-reopen bridge (`GjsifyQuartz`, ADR 0141) for `target`.
117
+ *
118
+ * `null` = the app does not have the dependency, and the bundle stays as it was.
119
+ * `{ unpopulated }` = the app has it but this target's companion is not installed
120
+ * (npm installs the optionalDependency of the HOST's arch only) or holds no
121
+ * prebuild — reported, never fatal: the bridge is an optional fix.
122
+ *
123
+ * Found from the project, else through `@gjsify/adwaita-app` (the package that
124
+ * declares it) — the companion is an optionalDependency of the facade, which is
125
+ * an optionalDependency of adwaita-app, so a strict layout (pnpm) hides it from
126
+ * the project root but not from its parent.
127
+ */
128
+ export declare function resolveQuartzBridge(target: GtkRuntimeTarget, options?: ResolveRuntimeOptions): ResolvedQuartzBridge | {
129
+ unpopulated: string;
130
+ } | null;
102
131
  /** node-gi's JavaScript, as package-relative paths. */
103
132
  export interface ResolvedNodeGiPackage {
104
133
  source: string;
@@ -209,15 +209,87 @@ function resolveNodeGiRoot(options) {
209
209
  * answers from the runtime's global install cache for a project that merely has a
210
210
  * `package.json` and no `node_modules`, which would put files the author never
211
211
  * declared inside a `.app`. See that function for the measurement.
212
+ *
213
+ * `fromCli: false` drops the fallback to the CLI's own install: the Dock bridge is
214
+ * optional, so only the project (or adwaita-app inside it) may declare it. Else a
215
+ * CLI running from this monorepo, or a global install, stages it into every app.
212
216
  */
213
- function resolveStagedPackage(specifier, options) {
214
- const opts = { bundleUrl: import.meta.url };
217
+ function resolveStagedPackage(specifier, options, { fromCli = true } = {}) {
218
+ const opts = fromCli ? { bundleUrl: import.meta.url } : {};
215
219
  if (options.cwd !== undefined)
216
220
  opts.cwd = options.cwd;
217
221
  if (options.resolve !== undefined)
218
222
  opts.resolve = options.resolve;
219
223
  return resolveInstalledPackage(specifier, opts);
220
224
  }
225
+ /** The facade `@gjsify/adwaita-app` lists as an optionalDependency (ADR 0141). */
226
+ export const QUARTZ_BRIDGE_FACADE = '@gjsify/gtk-quartz-native';
227
+ /** The bridge's GI typelib and library, as both per-target companions name them. */
228
+ export const QUARTZ_BRIDGE_TYPELIB = 'GjsifyQuartz-1.0.typelib';
229
+ export const QUARTZ_BRIDGE_LIBRARY = 'libgjsifyquartz.dylib';
230
+ /** The per-target companion carrying the bridge's prebuild. Only darwin targets have one. */
231
+ export function quartzBridgePackageName(target) {
232
+ return `${QUARTZ_BRIDGE_FACADE}-${target}`;
233
+ }
234
+ /**
235
+ * Locate the Dock-reopen bridge (`GjsifyQuartz`, ADR 0141) for `target`.
236
+ *
237
+ * `null` = the app does not have the dependency, and the bundle stays as it was.
238
+ * `{ unpopulated }` = the app has it but this target's companion is not installed
239
+ * (npm installs the optionalDependency of the HOST's arch only) or holds no
240
+ * prebuild — reported, never fatal: the bridge is an optional fix.
241
+ *
242
+ * Found from the project, else through `@gjsify/adwaita-app` (the package that
243
+ * declares it) — the companion is an optionalDependency of the facade, which is
244
+ * an optionalDependency of adwaita-app, so a strict layout (pnpm) hides it from
245
+ * the project root but not from its parent.
246
+ */
247
+ export function resolveQuartzBridge(target, options = {}) {
248
+ if (!target.startsWith('darwin-'))
249
+ return null;
250
+ const companion = quartzBridgePackageName(target);
251
+ const dirOf = (specifier, from) => {
252
+ const entry = resolveStagedPackage(`${specifier}/package.json`, from, { fromCli: false });
253
+ return entry === null ? null : dirname(entry);
254
+ };
255
+ let companionDir = dirOf(companion, options);
256
+ let facadeDir = null;
257
+ if (companionDir === null) {
258
+ facadeDir = dirOf(QUARTZ_BRIDGE_FACADE, options);
259
+ if (facadeDir === null) {
260
+ const adwaitaEntry = resolveStagedPackage('@gjsify/adwaita-app', options, { fromCli: false });
261
+ const adwaitaDir = adwaitaEntry === null ? null : packageRootOf(adwaitaEntry);
262
+ if (adwaitaDir !== null)
263
+ facadeDir = dirOf(QUARTZ_BRIDGE_FACADE, { ...options, cwd: adwaitaDir });
264
+ }
265
+ if (facadeDir !== null)
266
+ companionDir = dirOf(companion, { ...options, cwd: facadeDir });
267
+ }
268
+ if (companionDir === null) {
269
+ return facadeDir === null ? null : { unpopulated: `${companion} is not installed` };
270
+ }
271
+ const prebuilds = join(companionDir, 'prebuilds', target);
272
+ const typelibPath = join(prebuilds, QUARTZ_BRIDGE_TYPELIB);
273
+ const libraryPath = join(prebuilds, QUARTZ_BRIDGE_LIBRARY);
274
+ if (!existsSync(typelibPath) || !existsSync(libraryPath)) {
275
+ return {
276
+ unpopulated: `${companion} holds no prebuilds/${target}/{${QUARTZ_BRIDGE_TYPELIB},${QUARTZ_BRIDGE_LIBRARY}}`,
277
+ };
278
+ }
279
+ return { source: companion, typelibPath, libraryPath };
280
+ }
281
+ /** The nearest directory above `file` holding a `package.json`. */
282
+ function packageRootOf(file) {
283
+ let dir = dirname(file);
284
+ for (;;) {
285
+ if (existsSync(join(dir, 'package.json')))
286
+ return dir;
287
+ const parent = dirname(dir);
288
+ if (parent === dir)
289
+ return null;
290
+ dir = parent;
291
+ }
292
+ }
221
293
  /**
222
294
  * The files a SHIPPED `.app` needs from `@gjsify/node-gi`, or `null`.
223
295
  *
@@ -357,6 +429,28 @@ export function stageAppRuntime(input) {
357
429
  }
358
430
  launcher.gtkRuntimeDir = paths.gtkDir;
359
431
  found.push(`GTK closure from ${gtk.source}`);
432
+ // The Dock-reopen bridge goes INTO the closure's own typelib and library
433
+ // directories (ADR 0141 § Node hosts). node-gi already puts exactly those
434
+ // two on GI's typelib and library search paths when the bundled GTK is the
435
+ // chosen one (`activateBundledGtkRuntime`, `activateGiLibraryPath`), so the
436
+ // launcher needs no new variable and `installDockReopen` finds the pair.
437
+ const bridge = resolveQuartzBridge(input.target, discoveryOptions(input));
438
+ if (bridge !== null && 'unpopulated' in bridge) {
439
+ missing.push(`Dock-click reopen bridge not carried — ${bridge.unpopulated}`);
440
+ }
441
+ else if (bridge !== null) {
442
+ files.push({
443
+ path: posix.join(paths.gtkDir, 'girepository-1.0', QUARTZ_BRIDGE_TYPELIB),
444
+ mode: 0o644,
445
+ source: { kind: 'file', path: bridge.typelibPath },
446
+ });
447
+ files.push({
448
+ path: posix.join(paths.gtkDir, nativeSubdirOf(input.target), QUARTZ_BRIDGE_LIBRARY),
449
+ mode: 0o755,
450
+ source: { kind: 'file', path: bridge.libraryPath },
451
+ });
452
+ found.push(`Dock-click reopen bridge from ${bridge.source}`);
453
+ }
360
454
  }
361
455
  else {
362
456
  // The native subdirectory is `bin` on win32 and `lib` everywhere else,
@@ -403,6 +497,9 @@ export function stageAppRuntime(input) {
403
497
  }
404
498
  return { files, launcher, found, missing };
405
499
  }
500
+ function nativeSubdirOf(target) {
501
+ return target.startsWith('win32-') ? 'bin' : 'lib';
502
+ }
406
503
  /**
407
504
  * The discovery options every piece is looked up with.
408
505
  *
@@ -100,6 +100,15 @@ const APPIMAGE_ARCH = {
100
100
  function appImageArch(arch, _archIndependent) {
101
101
  return lookupArch(APPIMAGE_ARCH, arch, 'AppImage');
102
102
  }
103
+ /**
104
+ * `process.arch` → the `uname -m` spelling a tarball name carries (and the
105
+ * Flatpak arch the `-flatpak` variant is consumed under). `archIndependent` is
106
+ * IGNORED: the name is a download label and Flatpak has no `noarch`.
107
+ */
108
+ const LINUX_TAR_ARCH = { x64: 'x86_64', arm64: 'aarch64' };
109
+ function linuxTarArch(arch, _archIndependent) {
110
+ return lookupArch(LINUX_TAR_ARCH, arch, 'Linux tarball');
111
+ }
103
112
  /**
104
113
  * `process.arch` → the name Apple's tools use.
105
114
  *
@@ -505,6 +514,75 @@ export const FORMATS = {
505
514
  // build beside the tool gate rather than after it inside the packer.
506
515
  requiresDesktopEntry: true,
507
516
  },
517
+ // THE FIFTH CONTAINER OVER THE LINUX TREE, and the first with no install
518
+ // step and no prefix at all: a gzip'd tar whose single top directory is
519
+ // `<binaryName>-<version>-linux-<arch>/`. It is a download to unpack anywhere,
520
+ // and the launcher computes its own prefix, so the same `bin/<name>` works.
521
+ // It is NOT a replacement for `.deb`/`.rpm` and NOT self-contained: it takes
522
+ // its interpreter from the machine, like them, with no field to declare it.
523
+ //
524
+ // `finishOn: ['linux']` and not `'any'` although nothing is exec'd, and the
525
+ // reason is `defaultFormatIds`: `'any'` is what makes a bare `gjsify ship` on
526
+ // Linux build a row, and that set is exactly `deb` + `rpm` today. Opt-in
527
+ // through `--target` or `gjsify.ship.targets`, like `appimage` and `flatpak`.
528
+ 'linux-tar': {
529
+ id: 'linux-tar',
530
+ layoutOs: 'linux',
531
+ // No install prefix: the packer names the top directory. Unused by it.
532
+ prefix: '',
533
+ host: {
534
+ finishOn: ['linux'],
535
+ requiredTools: [],
536
+ oracle: {
537
+ // This tree's own `parseTar` reads the artifact back in the unit
538
+ // suite; the e2e suite reads it with GNU `tar`, which shares no code
539
+ // with the writer (ADR 0024 § A3).
540
+ readWith: ['tar'],
541
+ readOn: ['linux'],
542
+ selfReading: false,
543
+ },
544
+ },
545
+ depends: null,
546
+ interpreters: ['gjs', 'node'],
547
+ interpreterGap: 'a tarball carries the application and takes its interpreter from the host, exactly as a distro ' +
548
+ 'package does — but with no dependency field to declare it in',
549
+ licenseDest: SHARE_LICENSE_DEST,
550
+ licenseKind: 'plain',
551
+ archName: linuxTarArch,
552
+ fileName: (s, archLabel) => `${s.binaryName}-${s.version}-linux-${archLabel}.tar.gz`,
553
+ artifactKind: 'file',
554
+ },
555
+ // THE FLATPAK-OPTIMISED VARIANT, a second row and not a flag. The payload is
556
+ // identical; what differs is one pack-time step — `gschemas.compiled` is
557
+ // compiled and shipped (`appimage`'s precedent, and for its reason: the Linux
558
+ // stage is shared with `.deb`/`.rpm`, so no stage carries the cache) — and
559
+ // the CONTRACT: this archive is meant to be an `extra-data` source under
560
+ // `org.gnome.Platform`, which provides gjs and GTK, so nothing is bundled.
561
+ // A row keeps `defaultFormatIds`, `--target`, the closed vocabulary and
562
+ // `TARGETS` table-driven; a flag would need a second axis in all four.
563
+ 'linux-tar-flatpak': {
564
+ id: 'linux-tar-flatpak',
565
+ layoutOs: 'linux',
566
+ prefix: '',
567
+ host: {
568
+ finishOn: ['linux'],
569
+ requiredTools: [SCHEMA_COMPILER],
570
+ installHint: `The schema compiler is packaged: ${SCHEMA_COMPILER_HINT}`,
571
+ oracle: { readWith: ['tar'], readOn: ['linux'], selfReading: false },
572
+ },
573
+ depends: null,
574
+ // GJS ONLY, like the Flatpak row: the runtime ships `gjs`, not `node`.
575
+ interpreters: ['gjs'],
576
+ interpreterGap: 'the archive is meant to run under `org.gnome.Platform`, which ships `gjs` and no `node`, and it ' +
577
+ 'bundles no interpreter',
578
+ licenseDest: SHARE_LICENSE_DEST,
579
+ licenseKind: 'plain',
580
+ archName: linuxTarArch,
581
+ // A name of its own: both variants of one build must be able to sit in one
582
+ // `out/` directory.
583
+ fileName: (s, archLabel) => `${s.binaryName}-${s.version}-linux-${archLabel}-flatpak.tar.gz`,
584
+ artifactKind: 'file',
585
+ },
508
586
  // ── macOS (#1354 M2a) ────────────────────────────────────────────────
509
587
  //
510
588
  // TWO ROWS FOR ONE TREE, and the pair is what `layoutOs` was added for. The
@@ -1189,6 +1267,8 @@ export function canCarryTicket(id) {
1189
1267
  case 'rpm':
1190
1268
  case 'flatpak':
1191
1269
  case 'appimage':
1270
+ case 'linux-tar':
1271
+ case 'linux-tar-flatpak':
1192
1272
  case 'windows-dir':
1193
1273
  case 'windows-dir-zip':
1194
1274
  case 'msi':
@@ -0,0 +1,25 @@
1
+ import type { PayloadEntry } from './payload.js';
2
+ import type { PackSettings } from './types.js';
3
+ /** The single top directory: `<binaryName>-<version>-linux-<arch>`. */
4
+ export declare function tarballTopDir(settings: PackSettings, archLabel: string): string;
5
+ /**
6
+ * Refuse a payload that carries what a release archive must never hold.
7
+ *
8
+ * The payload is the staged closure, so these are guards against a stage that
9
+ * grew something nobody meant to publish — a `.env`, a `.git`, a log — rather
10
+ * than checks a normal build trips. `node_modules` is legitimate exactly when
11
+ * the app runs on Node and the stage copied its closure; for `--app gjs` there
12
+ * is no reason for one to exist.
13
+ */
14
+ export declare function assertTarballHygiene(payload: readonly PayloadEntry[], settings: PackSettings): void;
15
+ /**
16
+ * The archive: one directory entry per ancestor, then the payload, all under
17
+ * {@link tarballTopDir}. The file list is the payload's and nothing else — the
18
+ * stage's own sidecar was never payload.
19
+ */
20
+ export declare function buildLinuxTarball(input: {
21
+ settings: PackSettings;
22
+ payload: readonly PayloadEntry[];
23
+ archLabel: string;
24
+ mtime: number;
25
+ }): Promise<Uint8Array>;
@@ -0,0 +1,69 @@
1
+ // A deterministic `.tar.gz` of the Linux payload, in-tree, execing nothing.
2
+ //
3
+ // Same argument as the hand-written `.deb` and `.rpm` (ADR 0024 § A3): a format
4
+ // this tree writes itself needs no tool on the packing host, which keeps GNU
5
+ // `tar` an independent reader. Backs `linux-tar` and `linux-tar-flatpak` (ADR 0142).
6
+ import { posix } from 'node:path';
7
+ import { createTarball } from '@gjsify/tar';
8
+ import { gzipDeterministic } from './gzip.js';
9
+ /** The single top directory: `<binaryName>-<version>-linux-<arch>`. */
10
+ export function tarballTopDir(settings, archLabel) {
11
+ return `${settings.binaryName}-${settings.version}-linux-${archLabel}`;
12
+ }
13
+ /**
14
+ * Refuse a payload that carries what a release archive must never hold.
15
+ *
16
+ * The payload is the staged closure, so these are guards against a stage that
17
+ * grew something nobody meant to publish — a `.env`, a `.git`, a log — rather
18
+ * than checks a normal build trips. `node_modules` is legitimate exactly when
19
+ * the app runs on Node and the stage copied its closure; for `--app gjs` there
20
+ * is no reason for one to exist.
21
+ */
22
+ export function assertTarballHygiene(payload, settings) {
23
+ const problems = [];
24
+ for (const entry of payload) {
25
+ const segments = entry.path.split('/');
26
+ const base = segments[segments.length - 1];
27
+ if (base === '.env' || base.startsWith('.env.'))
28
+ problems.push(`${entry.path} (environment file)`);
29
+ else if (segments.includes('.git'))
30
+ problems.push(`${entry.path} (version-control data)`);
31
+ else if (base.endsWith('.log'))
32
+ problems.push(`${entry.path} (log file)`);
33
+ else if (segments.includes('node_modules') && settings.app !== 'node')
34
+ problems.push(`${entry.path} (node_modules in a non-Node payload)`);
35
+ }
36
+ if (problems.length === 0)
37
+ return;
38
+ throw new Error(`gjsify ship: refusing to pack a tarball that would contain ${problems.slice(0, 5).join(', ')}` +
39
+ `${problems.length > 5 ? ` and ${problems.length - 5} more` : ''}.`);
40
+ }
41
+ /**
42
+ * The archive: one directory entry per ancestor, then the payload, all under
43
+ * {@link tarballTopDir}. The file list is the payload's and nothing else — the
44
+ * stage's own sidecar was never payload.
45
+ */
46
+ export async function buildLinuxTarball(input) {
47
+ assertTarballHygiene(input.payload, input.settings);
48
+ const top = tarballTopDir(input.settings, input.archLabel);
49
+ const directories = new Set([`${top}/`]);
50
+ for (const entry of input.payload) {
51
+ const dir = posix.dirname(entry.path);
52
+ const parts = dir === '.' ? [] : dir.split('/');
53
+ let current = top;
54
+ for (const part of parts) {
55
+ current = `${current}/${part}`;
56
+ directories.add(`${current}/`);
57
+ }
58
+ }
59
+ const entries = [
60
+ ...[...directories].sort().map((name) => ({ name, mode: 0o755, mtime: input.mtime, directory: true })),
61
+ ...input.payload.map((entry) => ({
62
+ name: `${top}/${entry.path}`,
63
+ body: entry.data,
64
+ mode: entry.mode,
65
+ mtime: input.mtime,
66
+ })),
67
+ ];
68
+ return gzipDeterministic(createTarball(entries));
69
+ }
@@ -61,7 +61,7 @@ export interface ShipArtifact {
61
61
  * TEXTUALLY and fails if a comment gives it a second match, which is why this one
62
62
  * describes the union without quoting its head.
63
63
  */
64
- export type FormatId = 'deb' | 'rpm' | 'flatpak' | 'appimage' | 'macos-app' | 'macos-app-zip' | 'macos-app-dmg' | 'windows-dir' | 'windows-dir-zip' | 'msi';
64
+ export type FormatId = 'deb' | 'rpm' | 'flatpak' | 'appimage' | 'linux-tar' | 'linux-tar-flatpak' | 'macos-app' | 'macos-app-zip' | 'macos-app-dmg' | 'windows-dir' | 'windows-dir-zip' | 'msi';
65
65
  /**
66
66
  * The formats whose ARTIFACT carries a distro dependency list.
67
67
  *
@@ -0,0 +1,227 @@
1
+ /** The stores `webext submit` knows by name. A store it does not know is refused by name, not by a missing case. */
2
+ export type StoreId = 'chrome' | 'edge' | 'amo';
3
+ export declare const STORE_IDS: readonly StoreId[];
4
+ /** One environment variable a store needs, and whether its value may ever be printed. */
5
+ export interface StoreCredentialField {
6
+ /** The variable's name, as a CI secret and as a shell export. */
7
+ readonly env: string;
8
+ /**
9
+ * False for an identifier that appears in a URL anyway (a publisher, item or
10
+ * product id), true for anything that AUTHORISES. Only `secret: false` values
11
+ * are allowed into a message; the rest are replaced by {@link redactSecrets}.
12
+ */
13
+ readonly secret: boolean;
14
+ /** What it is, in the words the vendor's dashboard uses — this is what a missing-credential error prints. */
15
+ readonly what: string;
16
+ }
17
+ /**
18
+ * Credentials per store, read from the environment and NEVER from
19
+ * `package.json#gjsify.webext`: that file is committed, and a token in a
20
+ * committed file is a token in the published package too.
21
+ *
22
+ * Deliberately NOT ADR 0126's `CREDENTIALS` table, which is keyed by `HostOs`
23
+ * because a signing identity is per host. A store credential is the same on every
24
+ * host and differs per STORE, it has no `install` counterpart (there is no
25
+ * keychain to build), and it can only touch one listing. The full argument, and
26
+ * the fact that `ship credentials` is accepted-but-unbuilt, is ADR 0077
27
+ * § Amendment 1.
28
+ */
29
+ export declare const STORE_CREDENTIALS: Readonly<Record<StoreId, readonly StoreCredentialField[]>>;
30
+ export interface StoreDescriptor {
31
+ readonly id: StoreId;
32
+ /** As a message names it: "Chrome Web Store", not "chrome". */
33
+ readonly label: string;
34
+ /**
35
+ * False while no backend implements this store. `submit` reads this to refuse
36
+ * early with {@link StoreUnsupportedError} rather than after reading
37
+ * credentials it would not use.
38
+ */
39
+ readonly implemented: boolean;
40
+ /**
41
+ * Whether the API can CREATE the listing. Both implemented stores answer no —
42
+ * a first version goes through the vendor's dashboard by hand — so `submit`
43
+ * says that in words instead of surfacing a 404 from an upload.
44
+ */
45
+ readonly createsListings: false;
46
+ }
47
+ export declare const STORES: Readonly<Record<StoreId, StoreDescriptor>>;
48
+ /** `id` as a {@link StoreId}, or null — the caller owns the message, same contract as `parseWebextTarget`'s callers. */
49
+ export declare function asStoreId(id: string): StoreId | null;
50
+ /** A store's resolved credentials: `env` name → value, every field of its row present. */
51
+ export type StoreCredentials = Readonly<Record<string, string>>;
52
+ /** Just enough of an environment to resolve credentials from — `process.env` satisfies it on both runtimes. */
53
+ export type EnvLike = Readonly<Record<string, string | undefined>>;
54
+ /**
55
+ * Every variable a store's row names, or a refusal listing ALL the missing ones.
56
+ *
57
+ * One run per fix, not one per variable — the same reason `resolveWebextConfig`
58
+ * collects its problems before throwing. An empty string counts as missing: a CI
59
+ * secret that was never set expands to one, and treating that as a credential
60
+ * sends an `Authorization: ApiKey ` header whose 401 says nothing about the cause.
61
+ */
62
+ export declare function resolveStoreCredentials(store: StoreId, env: EnvLike): StoreCredentials;
63
+ /** The values of a store's `secret: true` fields, for {@link redactSecrets}. */
64
+ export declare function secretValuesOf(store: StoreId, credentials: StoreCredentials): readonly string[];
65
+ export declare const REDACTED = "<redacted>";
66
+ /** Just enough of `Headers`/a plain object to redact — a backend may hold either. */
67
+ export type HeadersLike = Readonly<Record<string, string>>;
68
+ /**
69
+ * A copy of `headers` safe to print: every authorising value replaced, every
70
+ * other value verbatim, names lower-cased so two spellings of one header cannot
71
+ * disagree about whether they are secret.
72
+ *
73
+ * A name containing `token`, `secret` or `key` is redacted too, so a header added
74
+ * by a later backend is secret by DEFAULT and has to be named explicitly to be
75
+ * printed. The failure mode this prevents is the quiet one: a new header leaks
76
+ * because nobody edited a list.
77
+ */
78
+ export declare function redactHeaders(headers: HeadersLike): Record<string, string>;
79
+ /**
80
+ * `text` with every value in `secrets` replaced, for a log line, a debug dump or
81
+ * the message of a thrown error.
82
+ *
83
+ * Longest first, because a short secret that is a substring of a long one would
84
+ * otherwise leave the long one's remainder in the text. Empty and one-character
85
+ * values are skipped: redacting those rewrites the whole message into noise and
86
+ * says nothing, and a credential that short is not a credential.
87
+ */
88
+ export declare function redactSecrets(text: string, secrets: readonly string[]): string;
89
+ /** The store's row named variables this environment does not set. Lists all of them, with what each is. */
90
+ export declare class StoreCredentialsMissingError extends Error {
91
+ readonly store: StoreId;
92
+ readonly missing: readonly StoreCredentialField[];
93
+ constructor(store: StoreId, missing: readonly StoreCredentialField[]);
94
+ }
95
+ /** A store with a row and no backend — the AMO slot, or a store declared before its file exists. */
96
+ export declare class StoreUnsupportedError extends Error {
97
+ readonly store: StoreId;
98
+ constructor(store: StoreId, detail: string);
99
+ }
100
+ /**
101
+ * The store already holds this exact version, so there is nothing to do.
102
+ *
103
+ * NOT a failure. A `submit` retried after a dropped connection must be able to
104
+ * reach this and exit 0, because the alternative is a second upload against a
105
+ * draft whose state the client never read.
106
+ */
107
+ export declare class StoreVersionAlreadyThereError extends Error {
108
+ readonly store: StoreId;
109
+ readonly version: string;
110
+ constructor(store: StoreId, version: string);
111
+ }
112
+ /**
113
+ * A submission is in review, so this version cannot be uploaded or published now.
114
+ *
115
+ * Also not a failure of this run: the previous submit worked and the store is
116
+ * busy with it. Cancelling it is the user's decision (Chrome has
117
+ * `:cancelSubmission`; Edge does not document one), never this command's.
118
+ */
119
+ export declare class StoreInReviewError extends Error {
120
+ readonly store: StoreId;
121
+ constructor(store: StoreId, detail: string);
122
+ }
123
+ /**
124
+ * A real failure: a 4xx that is not one of the two above, a 5xx, a timeout, an
125
+ * answer that did not parse.
126
+ *
127
+ * `detail` is built by the backend and MUST have passed through
128
+ * {@link redactSecrets} — it is the one field that carries vendor text, and
129
+ * vendor text is where an echoed credential would appear.
130
+ */
131
+ export declare class StoreApiError extends Error {
132
+ readonly store: StoreId;
133
+ readonly httpStatus: number | undefined;
134
+ constructor(store: StoreId, httpStatus: number | undefined, detail: string);
135
+ }
136
+ /** True for the two outcomes a retried `submit` may report and exit 0 on. */
137
+ export declare function isIdempotentSkip(error: unknown): error is StoreVersionAlreadyThereError | StoreInReviewError;
138
+ /** What a submission is doing, classified. `unknown` is a state, not an error — the store did not say. */
139
+ export type StoreSubmissionState =
140
+ /** Uploaded and not submitted: a draft the store holds. */
141
+ 'draft'
142
+ /** The store is reviewing it. */
143
+ | 'in-review'
144
+ /** Live, or rolling out. */
145
+ | 'published'
146
+ /** The store refused it; `detail` carries the reason it gave. */
147
+ | 'rejected'
148
+ /**
149
+ * Nothing was established. Chrome's `lastAsyncUploadState` is only set for
150
+ * uploads from the past 24 h, so a poll that starts late legitimately has no
151
+ * state to read — reporting that as `draft` would invent a fact.
152
+ */
153
+ | 'unknown';
154
+ export interface StoreStatusResult {
155
+ readonly state: StoreSubmissionState;
156
+ /** The version the store reports, when it reports one. */
157
+ readonly version?: string;
158
+ /** One line naming the evidence this state rests on — it goes in the report verbatim. */
159
+ readonly detail: string;
160
+ }
161
+ export interface StoreUploadResult {
162
+ /**
163
+ * The store's handle for this upload, when it has one: Chrome's item resource
164
+ * name, Edge's operation id from the `Location` header. A backend that polls
165
+ * its own operation passes this to {@link StoreBackend.status}.
166
+ */
167
+ readonly operationId?: string;
168
+ /** True once the store has fully ingested the package, false while an async upload is still running. */
169
+ readonly ingested: boolean;
170
+ readonly detail: string;
171
+ }
172
+ export interface StorePublishResult {
173
+ readonly state: StoreSubmissionState;
174
+ readonly detail: string;
175
+ }
176
+ export interface StoreUploadInput {
177
+ /** Absolute path of the zip `webext zip` wrote. The backend reads it; it never builds one. */
178
+ readonly zipPath: string;
179
+ /** The version in the zip's manifest, for the "already there" check and for messages. */
180
+ readonly version: string;
181
+ }
182
+ export interface StorePublishInput {
183
+ readonly version: string;
184
+ /** What Chrome calls a staged rollout; a backend whose store has none refuses a value below 100. */
185
+ readonly deployPercentage?: number;
186
+ /** Edge's submission `notes`. Stores that take no note ignore it. */
187
+ readonly notes?: string;
188
+ }
189
+ /**
190
+ * What every store backend answers to. Three verbs, because that is what both
191
+ * vendor APIs expose: push the package, ask for review, read what happened.
192
+ *
193
+ * Each verb either returns its result or throws one of the error classes above —
194
+ * a backend never returns a half-success, and never reports "published" from
195
+ * anything but a store answer that said so.
196
+ */
197
+ export interface StoreBackend {
198
+ readonly store: StoreId;
199
+ upload(input: StoreUploadInput): Promise<StoreUploadResult>;
200
+ publish(input: StorePublishInput): Promise<StorePublishResult>;
201
+ status(): Promise<StoreStatusResult>;
202
+ }
203
+ /** What every backend's factory takes, beside its credentials. */
204
+ export interface StoreBackendOptions {
205
+ /** Injected in tests; resolved at call time so a `globalThis.fetch` stub is honoured (as in `publish-readback.ts`). */
206
+ readonly fetchImpl?: typeof fetch;
207
+ readonly sleep?: (ms: number) => Promise<void>;
208
+ readonly now?: () => number;
209
+ /** Called for each request under `GJSIFY_WEBEXT_DEBUG`. Whatever it prints has been redacted first. */
210
+ readonly log?: (msg: string) => void;
211
+ }
212
+ /** A store's backend factory, registered in {@link STORE_BACKENDS} by its own file. */
213
+ export type StoreBackendFactory = (credentials: StoreCredentials, options?: StoreBackendOptions) => StoreBackend;
214
+ /**
215
+ * Backend per store, EMPTY in this slice: the interface lands before the two
216
+ * implementations so they can be written against a file neither of them owns.
217
+ * `chrome.ts` and `edge.ts` each add their own row; nothing else changes.
218
+ */
219
+ export declare const STORE_BACKENDS: Partial<Record<StoreId, StoreBackendFactory>>;
220
+ /**
221
+ * The backend for a store, with its credentials resolved from `env`.
222
+ *
223
+ * The order matters: a store with no backend is refused BEFORE credentials are
224
+ * read, so `submit --store amo` says "not implemented" rather than asking for two
225
+ * variables it would not use.
226
+ */
227
+ export declare function createStoreBackend(store: StoreId, env: EnvLike, options?: StoreBackendOptions): StoreBackend;