{"version":3,"file":"SnapOptions.js","sourceRoot":"","sources":["../../src/options/SnapOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { TargetSpecificOptions } from \"../core\"\nimport { SnapcraftYAML } from \"../targets/snap/snapcraft\"\nimport { CommonLinuxOptions } from \"./linuxOptions\"\n\n/**\n * New-style snap configuration. Use this via the `snapcraft` key in your build config.\n * Selects the snapcraft core version and its per-core options.\n */\nexport interface SnapcraftOptions extends TargetSpecificOptions {\n  /**\n   * The snap base to use as the execution environment. Determines which set of per-core options\n   * (`core18`, `core20`, `core22`, `core24`, `custom`) is active.\n   *\n   * Only one core may be selected per build target.\n   */\n  readonly base: \"core18\" | \"core20\" | \"core22\" | \"core24\" | \"custom\"\n\n  /**\n   * Snapcraft Store credentials — base64-encoded credentials string or file path.\n   * Accepts the same formats as `WIN_CSC_LINK` / `CSC_LINK`: base64 data,\n   * absolute/relative/`~/` file paths, and `file://` URIs.\n   * Relative paths are resolved against the build resources directory.\n   *\n   * Injected as `SNAPCRAFT_STORE_CREDENTIALS` into every snapcraft subprocess\n   * (core18/core20/core22/core24 builds and `snapcraft upload`).\n   * Not applied for `base: \"custom\"` — inject credentials manually via environment variables.\n   *\n   * The `SNAP_CSC_LINK` environment variable is the CI-friendly alternative.\n   * Generate with: `snapcraft export-login - | base64 -w0`\n   */\n  readonly cscLink?: string\n\n  /**\n   * Configuration for a core18 build. Only active when `base` is `\"core18\"`.\n   */\n  readonly core18?: SnapOptionsLegacy | null\n  /**\n   * Configuration for a core20 build. Only active when `base` is `\"core20\"`.\n   */\n  readonly core20?: SnapOptionsLegacy | null\n  /**\n   * Configuration for a core22 build. Only active when `base` is `\"core22\"`.\n   */\n  readonly core22?: SnapOptionsLegacy | null\n\n  /**\n   * **[Beta]** Options for building a core24 snap. Uses the snapcraft CLI directly.\n   * Inherits desktop-entry fields from `CommonLinuxOptions` and publish config from `TargetSpecificOptions`.\n   * @beta\n   */\n  readonly core24?: SnapOptions24 | null\n  /**\n   * **[Beta]** Pass-through custom snap configuration. electron-builder will read the\n   * snapcraft.yaml at `yamlPath` and use it verbatim — no plugs, extensions,\n   * organize mappings, or desktop files are injected.\n   * @beta\n   */\n  readonly custom?: SnapOptionsCustom | null\n}\n// Internal alias used by the core18/20/22 backward-compat fields in SnapcraftOptions.\n// Not tagged @deprecated itself to avoid cascading TS6385 hints onto those properties.\nexport type SnapOptionsLegacy = Omit<SnapOptions, \"base\">\n\nexport interface SnapOptionsCustom {\n  /**\n   * Supports 2 routes:\n   * - Path to an existing `snapcraft.yaml` file, relative to `buildResourcesDir`. electron-builder reads the file and passes it through without modification.\n   * - A `SnapcraftYAML` object directly in the configuration. electron-builder uses the object to generate a `snapcraft.yaml` file, which is then passed through without modification.\n   */\n  readonly yaml?: string | SnapcraftYAML | null\n}\n\n/**\n * Flat snap options. Used via the `snap` key in your build config.\n *\n * @deprecated Prefer the `snapcraft` key with an explicit `base` field (e.g.\n * `{ \"snapcraft\": { \"base\": \"core24\", \"core24\": { ... } } }`). The flat `snap`\n * interface is maintained for backward compatibility and targets `core22` and\n * older snap bases only.\n *\n * Fields inherited from {@link CommonLinuxOptions} (e.g. `description`, `category`,\n * `mimeTypes`, `executableArgs`) are automatically populated from `linux.*` configuration\n * and do not need to be repeated here. Per-core values take precedence when both are set.\n */\nexport interface SnapOptions extends CommonLinuxOptions, TargetSpecificOptions {\n  /**\n   * The snap base to use as the execution environment.\n   * Examples: `core18`, `core20`, `core22`.\n   *\n   * For new projects, use the `snapcraft` key with `base: \"core24\"` instead of\n   * this legacy interface.\n   */\n  readonly base?: string | null\n\n  /**\n   * Whether to use the pre-built Electron snap template for faster builds.\n   * When `true`, electron-builder delegates snap assembly to the upstream Electron snap\n   * template rather than running a full snapcraft build, significantly reducing build time.\n   * Defaults to `true` when `stagePackages` is not customised.\n   * Only applicable to x64 and armv7l builds.\n   */\n  readonly useTemplateApp?: boolean\n\n  /**\n   * The type of [snap confinement](https://snapcraft.io/docs/reference/confinement).\n   * - `strict` — recommended; the snap runs in a fully isolated sandbox.\n   * - `devmode` — sandbox violations are logged but not enforced; for development only.\n   * - `classic` — no confinement; equivalent to a traditionally packaged application.\n   *   Requires Snap Store approval before publishing.\n   * @default strict\n   */\n  readonly confinement?: \"devmode\" | \"strict\" | \"classic\" | null\n\n  /**\n   * Environment variables injected into the snap's runtime environment.\n   * Merged with the electron-builder default `{ TMPDIR: \"$XDG_RUNTIME_DIR\" }`.\n   * User-supplied values take precedence.\n   */\n  readonly environment?: { [key: string]: string } | null\n\n  /**\n   * A short summary of the snap (max 78 characters).\n   * Defaults to [productName](./configuration.md#productName).\n   */\n  readonly summary?: string | null\n\n  /**\n   * The quality grade of the snap.\n   * - `stable` — suitable for all channels, including `stable` and `candidate`.\n   * - `devel` — development snapshot; cannot be promoted to `stable` or `candidate`.\n   * @default stable\n   */\n  readonly grade?: \"devel\" | \"stable\" | null\n\n  /**\n   * [Snapd features](https://snapcraft.io/docs/snapcraft-yaml-reference#assumes) that must\n   * be present on the host before the snap can be installed.\n   */\n  readonly assumes?: Array<string> | string | null\n\n  /**\n   * Debian packages required at **build** time (installed inside the build environment).\n   */\n  readonly buildPackages?: Array<string> | null\n\n  /**\n   * Ubuntu packages to **stage** alongside the app (equivalent to `depends` for deb).\n   * Defaults to `[\"libnspr4\", \"libnss3\", \"libxss1\", \"libappindicator3-1\", \"libsecret-1-0\"]`.\n   *\n   * Use the `\"default\"` keyword to extend the default list:\n   * `[\"default\", \"my-extra-lib\"]` appends `my-extra-lib` to the defaults.\n   */\n  readonly stagePackages?: Array<string> | null\n\n  /**\n   * Directory containing [snap hooks](https://snapcraft.io/docs/snap-hooks), relative to\n   * the build resources directory (`build/`).\n   * @default build/snap-hooks\n   */\n  readonly hooks?: string | null\n\n  /**\n   * [Plugs](https://snapcraft.io/docs/reference/interfaces) (consumed interfaces) to declare\n   * for the app entry point.\n   * Defaults to `[\"desktop\", \"desktop-legacy\", \"home\", \"x11\", \"wayland\", \"unity7\",\n   * \"browser-support\", \"network\", \"gsettings\", \"audio-playback\", \"pulseaudio\", \"opengl\"]`.\n   *\n   * Use `\"default\"` in the list to keep the defaults and append extras:\n   * `[\"default\", \"camera\"]` adds `camera` to the standard set.\n   *\n   * To configure plug attributes (e.g. `allow-sandbox` for Chromium's internal sandbox),\n   * use a descriptor object:\n   * ```json\n   * [\n   *   { \"browser-sandbox\": { \"interface\": \"browser-support\", \"allow-sandbox\": true } },\n   *   \"another-simple-plug-name\"\n   * ]\n   * ```\n   */\n  readonly plugs?: Array<string | PlugDescriptor> | PlugDescriptor | null\n\n  /**\n   * [Slots](https://snapcraft.io/docs/reference/interfaces) (provided interfaces) to declare\n   * for the app.\n   *\n   * To expose an MPRIS player under the Chromium bus name (required for strict confinement):\n   * ```json\n   * [{ \"mpris\": { \"name\": \"chromium\" } }]\n   * ```\n   * Chromium [hard-codes](https://source.chromium.org/chromium/chromium/src/+/master:components/system_media_controls/linux/system_media_controls_linux.cc;l=51;bpv=0;bpt=1)\n   * the bus name `chromium`, so the slot name must match for snapd to\n   * [allow it](https://forum.snapcraft.io/t/unable-to-use-mpris-interface/15360/7).\n   */\n  readonly slots?: Array<string | SlotDescriptor> | SlotDescriptor | null\n\n  /**\n   * Names of snapcraft parts that must be built before the app part.\n   * Defaults to `[\"desktop-gtk2\"]`.\n   *\n   * Use `\"default\"` to keep the default and add extras:\n   * `[\"default\", \"my-helper-part\"]`.\n   */\n  readonly after?: Array<string> | null\n\n  /**\n   * Whether the snap should automatically start on login.\n   * @default false\n   */\n  readonly autoStart?: boolean\n\n  /**\n   * [Snap layouts](https://snapcraft.io/docs/snap-layouts) — bind-mount or symlink host paths\n   * into the snap's namespace, making libraries or config at `/usr`, `/var`, `/etc`, etc.\n   * accessible inside the confined environment.\n   */\n  readonly layout?: { [key: string]: { [key: string]: string } } | null\n\n  /**\n   * Filesets controlling which files from the app part are staged into the snap.\n   * Supports individual files, directories, globs, globstars, and exclusions (prefix `!`).\n   * See [Snapcraft filesets](https://snapcraft.io/docs/snapcraft-filesets).\n   * When not set, the snap template's default stage list is used for legacy bases (core18/core20/core22).\n   */\n  readonly appPartStage?: Array<string> | null\n\n  /**\n   * Display title for the snap (may contain uppercase letters and spaces).\n   * Defaults to `productName`.\n   * See [snap format](https://snapcraft.io/docs/snap-format).\n   */\n  readonly title?: string | null\n\n  /**\n   * Compression algorithm for the snap SquashFS image.\n   * - `xz` — smaller file, slower decompression (good for distribution).\n   * - `lzo` — larger file, faster decompression (good for development iteration).\n   * Omit to use snapcraft's default (`xz`).\n   *\n   * When not set, `linux.compression` is mapped automatically:\n   * `\"store\"` → `\"lzo\"`, `\"maximum\"` → `\"xz\"`, `\"normal\"` → snapcraft default.\n   * Explicitly setting this field always overrides the mapped value.\n   */\n  readonly compression?: \"xz\" | \"lzo\" | null\n\n  /**\n   * Allow the snap to run with native Wayland support (`--ozone-platform=wayland`).\n   * Defaults to `false` for Electron < 38 (legacy behaviour); `true` for Electron ≥ 38.\n   * Set explicitly to override the version-based default.\n   */\n  readonly allowNativeWayland?: boolean | null\n}\n\n/**\n * Configuration for a remote snap build on [Launchpad](https://launchpad.net/).\n * Remote builds run on Canonical's infrastructure without requiring native hardware or nested virtualisation.\n *\n * Each electron-builder build invocation targets exactly one architecture — to build for multiple\n * architectures, configure the top-level `arch` option (e.g. `arch: [\"x64\", \"arm64\"]`); each arch\n * spawns a separate `snapcraft remote-build` job on Launchpad.\n *\n * Authentication is resolved in this order:\n * 1. `cscLink` config field — base64-encoded credentials or a file path\n * 2. `SNAP_CSC_LINK` environment variable — same format as `cscLink`\n *    (CI-recommended; follows the same pattern as `WIN_CSC_LINK` for Windows code signing)\n * 3. `SNAPCRAFT_STORE_CREDENTIALS` environment variable (read directly by snapcraft)\n * 4. An active interactive `snapcraft login` session\n *\n * **CI setup** (set once as a CI secret):\n * ```sh\n * export SNAP_CSC_LINK=$(snapcraft export-login - | base64 -w0)\n * ```\n * The resolved credentials are injected only into the spawned `snapcraft` subprocess\n * environment and never exposed through `process.env`.\n */\nexport interface RemoteBuildOptions {\n  /**\n   * Whether to enable remote build on Launchpad. Must be set explicitly to `true` to opt in.\n   */\n  enabled: boolean\n\n  /**\n   * Your Launchpad username. Used to select the correct Launchpad account when more than\n   * one set of credentials is available.\n   */\n  launchpadUsername?: string\n\n  /**\n   * Target architecture for the remote build. Accepts a single snapcraft arch string\n   * (e.g. `\"amd64\"`, `\"arm64\"`, `\"armhf\"`).\n   *\n   * To build for multiple architectures, configure electron-builder's top-level `arch` option\n   * (e.g. `arch: [\"x64\", \"arm64\"]`) — each arch spawns a separate remote-build job on Launchpad,\n   * keeping the one-build-per-artifact contract intact.\n   * @example \"amd64\"\n   */\n  buildFor?: string\n\n  /**\n   * Suppress the Launchpad public-upload consent prompt by automatically accepting it.\n   * Your source code will be uploaded to a **public** Launchpad repository.\n   * Set to `true` in CI once you understand the implications.\n   */\n  acceptPublicUpload?: boolean\n\n  /**\n   * Launchpad project name to use for a **private** source upload.\n   * The project must already exist and you must have write access.\n   */\n  privateProject?: string\n\n  /**\n   * Resume a previously interrupted remote build rather than starting a new one.\n   */\n  recover?: boolean\n\n  /**\n   * Maximum time in seconds to wait for the remote build to complete before aborting.\n   * Passed to `snapcraft remote-build` as `--timeout <seconds>`.\n   *\n   * @example 1800  // 30 minutes\n   */\n  timeout?: number\n\n  /**\n   * Controls whether snapcraft may fall back to a different remote build strategy.\n   * - `\"disable-fallback\"` — always use the primary strategy, fail if unavailable.\n   * - `\"force-fallback\"` — always use the fallback strategy.\n   */\n  strategy?: \"disable-fallback\" | \"force-fallback\"\n}\n\n/**\n * **[Beta]** Options for building a core24 snap. This interface does not extend the legacy\n * `SnapBaseOptions` — it uses the snapcraft CLI directly.\n *\n * Fields inherited from {@link CommonLinuxOptions} (`description`, `category`, `mimeTypes`,\n * `executableArgs`, `desktop`, `synopsis`) are automatically populated from the root `linux.*`\n * configuration. You do not need to duplicate them here; values set directly on this interface\n * take precedence over the cascaded `linux.*` values.\n *\n * @beta\n */\nexport interface SnapOptions24 extends CommonLinuxOptions, TargetSpecificOptions {\n  // ─── Build environment (mutually exclusive) ─────────────────────────────────\n\n  /**\n   * Use [LXD](https://canonical.com/lxd) as the isolated build environment.\n   * Preferred over Multipass on most Linux CI systems where nested virtualisation is unavailable.\n   * Mutually exclusive with `useMultipass` and `useDestructiveMode`.\n   */\n  readonly useLXD?: boolean | null\n\n  /**\n   * Use [Multipass](https://multipass.run/) as the isolated build environment.\n   * Mutually exclusive with `useLXD` and `useDestructiveMode`.\n   */\n  readonly useMultipass?: boolean | null\n\n  /**\n   * Build directly on the host without an isolated VM or container (snapcraft `--destructive-mode`).\n   * Equivalent to setting `SNAPCRAFT_BUILD_ENVIRONMENT=host`.\n   *\n   * **Not recommended for most use cases.** Destructive mode pollutes the host environment\n   * and produces builds that are difficult to reproduce — any library or tool present on the\n   * host at build time can silently end up in the snap. Prefer `useLXD` or `useMultipass`\n   * for clean, reproducible builds; use `remoteBuild` for multi-architecture CI.\n   *\n   * Valid reasons to enable this option:\n   * - Building inside a Docker container where nested virtualisation (LXD / Multipass) is\n   *   unavailable and a remote Launchpad build is not acceptable.\n   * - Running test suites in CI where the environment is already fully controlled.\n   *\n   * The `gnome` extension is incompatible with this mode enabled — do not include it in `extensions`.\n   * @see https://snapcraft.io/docs/build-options\n   */\n  readonly useDestructiveMode?: boolean | null\n\n  /**\n   * Configuration for a remote build on [Launchpad](https://launchpad.net/).\n   * Enables cross-architecture builds in CI without native hardware or nested virtualisation.\n   * Each build invocation targets one arch; use `arch: [\"x64\", \"arm64\"]` to build for multiple.\n   */\n  readonly remoteBuild?: RemoteBuildOptions | null\n\n  // ─── Snapcraft extensions ────────────────────────────────────────────────────\n\n  /**\n   * [Snapcraft extensions](https://snapcraft.io/docs/snapcraft-extensions) to apply to the app.\n   * Defaults to `[\"gnome\"]` in normal builds (recommended for Electron apps on Ubuntu 24.04+).\n   * Automatically set to `[]` in `useDestructiveMode` builds, where the gnome extension is\n   * incompatible. Explicitly including `\"gnome\"` while `useDestructiveMode` is set will throw.\n   * See: https://snapcraft.io/docs/gnome-extension\n   */\n  readonly extensions?: Array<string> | null\n\n  // ─── Snap metadata ───────────────────────────────────────────────────────────\n\n  /**\n   * The type of [confinement](https://snapcraft.io/docs/reference/confinement) supported by the snap.\n   * @default strict\n   */\n  readonly confinement?: \"devmode\" | \"strict\" | \"classic\" | null\n\n  /**\n   * The quality grade of the snap.\n   * `devel` — not publishable to stable/candidate channels.\n   * `stable` — suitable for all channels.\n   * @default stable\n   */\n  readonly grade?: \"devel\" | \"stable\" | null\n\n  /**\n   * A short summary of the snap (max 78 characters). Defaults to `productName`.\n   */\n  readonly summary?: string | null\n\n  /**\n   * An optional display title (may contain uppercase letters and spaces). Defaults to `productName`.\n   * See [snap format](https://snapcraft.io/docs/snap-format).\n   */\n  readonly title?: string | null\n\n  /**\n   * Compression algorithm for the snap SquashFS image.\n   * - `xz` — smaller file, slower decompression (recommended for distribution).\n   * - `lzo` — larger file, faster decompression (useful for development iteration).\n   * Omit to use snapcraft's default (`xz`).\n   *\n   * When not set, `linux.compression` is mapped automatically:\n   * `\"store\"` → `\"lzo\"`, `\"maximum\"` → `\"xz\"`, `\"normal\"` → snapcraft default.\n   * Explicitly setting this field always overrides the mapped value.\n   */\n  readonly compression?: \"xz\" | \"lzo\" | null\n\n  /**\n   * Features that must be supported by the host snapd before the snap can be installed.\n   * See [assumes](https://snapcraft.io/docs/snapcraft-yaml-reference#assumes).\n   */\n  readonly assumes?: Array<string> | string | null\n\n  // ─── Build packages / stage packages ────────────────────────────────────────\n\n  /**\n   * Debian packages required at **build** time (installed inside the build environment).\n   */\n  readonly buildPackages?: Array<string> | null\n\n  /**\n   * Ubuntu packages to **stage** alongside the app (equivalent to `depends` for deb).\n   * Defaults to `[\"libnspr4\", \"libnss3\", \"libxss1\", \"libappindicator3-1\", \"libsecret-1-0\"]`.\n   * Supports the `\"default\"` keyword to reference the default list:\n   * `[\"default\", \"my-extra-lib\"]` appends `my-extra-lib` to the defaults.\n   */\n  readonly stagePackages?: Array<string> | null\n\n  /**\n   * Filesets controlling which files from the app part are staged into the snap.\n   * Supports glob patterns and exclusions. See [filesets](https://snapcraft.io/docs/snapcraft-filesets).\n   */\n  readonly appPartStage?: Array<string> | null\n\n  /**\n   * Names of other snapcraft parts that must be built before the app part.\n   */\n  readonly after?: Array<string> | null\n\n  // ─── Snap interfaces ─────────────────────────────────────────────────────────\n\n  /**\n   * [Plugs](https://snapcraft.io/docs/reference/interfaces) (consumed interfaces) for the app.\n   * When the `gnome` extension is active, content-snap plugs (themes, GNOME platform, GPU)\n   * are added automatically — only list custom plugs here.\n   * Without any extension, defaults to the standard Electron plug set.\n   *\n   * Supports descriptor objects for plugs with attributes:\n   * ```json\n   * [{ \"browser-sandbox\": { \"interface\": \"browser-support\", \"allow-sandbox\": true } }]\n   * ```\n   */\n  readonly plugs?: Array<string | PlugDescriptor> | PlugDescriptor | null\n\n  /**\n   * [Slots](https://snapcraft.io/docs/reference/interfaces) (provided interfaces) for the app.\n   * Use for MPRIS, D-Bus services, etc.\n   *\n   * Example — expose MPRIS under the Chromium bus name:\n   * ```json\n   * [{ \"mpris\": { \"name\": \"chromium\" } }]\n   * ```\n   */\n  readonly slots?: Array<string | SlotDescriptor> | SlotDescriptor | null\n\n  /**\n   * [Snap layouts](https://snapcraft.io/docs/snap-layouts) — bind-mount or symlink host paths\n   * into the snap's namespace. User-provided layouts always override the extension defaults.\n   */\n  readonly layout?: { [key: string]: { [key: string]: string } } | null\n\n  // ─── Runtime environment ─────────────────────────────────────────────────────\n\n  /**\n   * Additional environment variables injected into the snap's runtime environment.\n   * Merged with the electron-builder defaults (`TMPDIR=$XDG_RUNTIME_DIR`).\n   * User-supplied values take precedence.\n   */\n  readonly environment?: { [key: string]: string } | null\n\n  /**\n   * Whether the app should auto-start on login (creates an autostart desktop entry).\n   * @default false\n   */\n  readonly autoStart?: boolean\n\n  /**\n   * Set to `true` to force X11 by injecting `--ozone-platform=x11` into the snap command line.\n   * When unset or `false`, no flag is injected and native Wayland is allowed.\n   * Unlike the legacy `snap.allowNativeWayland`, there is no electron-version-based default here —\n   * core24 always allows Wayland unless this is explicitly `true`.\n   */\n  readonly forceX11?: boolean | null\n\n  // ─── Hooks ───────────────────────────────────────────────────────────────────\n\n  /**\n   * Directory containing [snap hooks](https://snapcraft.io/docs/snap-hooks), relative to\n   * the build resources directory.\n   * @default build/snap-hooks\n   */\n  readonly hooks?: string | null\n}\n\n/**\n * Maps a named plug to its attribute object.\n * `null` uses snapd defaults for that interface.\n *\n * @example\n * ```json\n * { \"browser-sandbox\": { \"interface\": \"browser-support\", \"allow-sandbox\": true } }\n * ```\n */\nexport interface PlugDescriptor {\n  [key: string]: { [key: string]: any } | null\n}\n\n/**\n * Maps a named slot to its attribute object.\n * `null` uses snapd defaults for that interface.\n *\n * @example\n * ```json\n * { \"mpris\": { \"name\": \"chromium\" } }\n * ```\n */\nexport interface SlotDescriptor {\n  [key: string]: { [key: string]: any } | null\n}\n"]}