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C,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAA;QAEtE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,yCAAsB,CAAC,CAAA;QAC3D,MAAM,IAAA,qBAAU,EAAC,iBAAiB,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;QACxD,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,0DAA0D,CAAC,CAAA;QAE3E,IAAI,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,uBAAuB,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;YAC7I,OAAM;QACR,CAAC;QAED,MAAM,IAAA,4BAAS,EAAC;YACd,eAAe,EAAE,IAAI;YACrB,YAAY;YACZ,QAAQ;YACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAA;IACJ,CAAC;CACF;AA3CD,wCA2CC","sourcesContent":["import { Arch, InvalidConfigurationError, log } from \"builder-util\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport * as yaml from \"js-yaml\"\nimport * as path from \"path\"\nimport { SnapOptionsCustom } from \"../../options/SnapOptions\"\nimport { SnapCore } from \"./SnapTarget\"\nimport { SnapcraftYAML } from \"./snapcraft\"\nimport { buildSnap, SNAPCRAFT_YAML_OPTIONS } from \"./snapcraftBuilder\"\n\n/**\n * Pass-through snap builder for `base: \"custom\"`.\n *\n * electron-builder reads the file at `snapcraft.custom.yaml` (or the inline object),\n * writes it into the stage directory, and invokes snapcraft. **Nothing is injected or\n * modified in any way** — no plugs, extensions, organize mappings, desktop files,\n * environment variables, layout entries, or stage packages. `linux.*` configuration\n * is also not cascaded into the descriptor.\n *\n * Because electron-builder exerts no control over the descriptor's content, GitHub\n * issue support for snap runtime problems encountered with custom yaml files is limited.\n * Prefer a structured base (`core24`, `core22`, etc.) for a fully managed build.\n */\nexport class SnapCoreCustom extends SnapCore<SnapOptionsCustom> {\n  readonly defaultPlugs: string[] = []\n\n  async createDescriptor(_arch: Arch): Promise<SnapcraftYAML> {\n    const { yaml: yamlPath } = this.options\n    if (!yamlPath) {\n      throw new InvalidConfigurationError(\n        'snapcraft.base = \"custom\" requires an entry in snapcraft.custom.yaml (either a path to a snapcraft.yaml file or a SnapcraftYAML object directly in the configuration)'\n      )\n    }\n    if (typeof yamlPath !== \"string\") {\n      return yamlPath // fully defined SnapcraftYAML object provided directly in configuration, no file reading necessary\n    }\n    const resolved = path.resolve(this.packager.buildResourcesDir, yamlPath)\n    const buildResourcesDir = this.packager.buildResourcesDir\n    if (!resolved.startsWith(buildResourcesDir + path.sep) && resolved !== buildResourcesDir) {\n      throw new InvalidConfigurationError(`snapcraft.custom.yaml must resolve within the build resources directory (got \"${resolved}\")`)\n    }\n    const raw = await readFile(resolved, \"utf8\")\n    return yaml.load(raw) as SnapcraftYAML\n  }\n\n  async buildSnap(params: { snap: SnapcraftYAML; appOutDir: string; stageDir: string; snapArch: Arch; artifactPath: string }): Promise<void> {\n    const { snap, stageDir, artifactPath } = params\n\n    const snapDirResolved = path.resolve(stageDir, \"snap\")\n    const snapcraftYamlPath = path.join(snapDirResolved, \"snapcraft.yaml\")\n\n    const yamlContent = yaml.dump(snap, SNAPCRAFT_YAML_OPTIONS)\n    await outputFile(snapcraftYamlPath, yamlContent, \"utf8\")\n    log.debug(snap, \"using custom snapcraft.yaml (pass-through, no injection)\")\n\n    if (this.packager.packagerOptions.effectiveOptionComputed != null && (await this.packager.packagerOptions.effectiveOptionComputed({ snap }))) {\n      return\n    }\n\n    await buildSnap({\n      snapcraftConfig: snap,\n      artifactPath,\n      stageDir,\n      packager: this.packager,\n    })\n  }\n}\n"]}