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,UAAM,IAAI,KAAJ,CAAU,YAAV,CAAN;AACD;;AAED,QAAM,KAAN,CAAY,SAAZ,EAA+B,IAA/B,EAAyC,CACvC;AACD;;AAbmC,C","sourcesContent":["import { addValue, Arch, archFromString, ArchType, asArray } from \"builder-util\"\nimport { DEFAULT_TARGET, DIR_TARGET, Platform, Target, TargetConfiguration } from \"..\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { ArchiveTarget } from \"./ArchiveTarget\"\n\nconst archiveTargets = new Set([\"zip\", \"7z\", \"tar.xz\", \"tar.lz\", \"tar.gz\", \"tar.bz2\"])\n\nexport function computeArchToTargetNamesMap(raw: Map>, platformPackager: PlatformPackager, platform: Platform): Map> {\n for (const targetNames of raw.values()) {\n if (targetNames.length > 0) {\n // https://github.com/electron-userland/electron-builder/issues/1355\n return raw\n }\n }\n\n const defaultArchs: Array = raw.size === 0 ? [platform === Platform.MAC ? \"x64\" : process.arch as ArchType] : Array.from(raw.keys()).map(it => Arch[it] as ArchType)\n const result = new Map(raw)\n for (const target of asArray(platformPackager.platformSpecificBuildOptions.target).map(it => typeof it === \"string\" ? {target: it} : it)) {\n let name = target.target\n let archs = target.arch\n const suffixPos = name.lastIndexOf(\":\")\n if (suffixPos > 0) {\n name = target.target.substring(0, suffixPos)\n if (archs == null) {\n archs = target.target.substring(suffixPos + 1) as ArchType\n }\n }\n\n for (const arch of archs == null ? defaultArchs : asArray(archs)) {\n addValue(result, archFromString(arch), name)\n }\n }\n\n if (result.size === 0) {\n const defaultTarget = platformPackager.defaultTarget\n if (raw.size === 0 && platform === Platform.LINUX && (process.platform === \"darwin\" || process.platform === \"win32\")) {\n result.set(Arch.x64, defaultTarget)\n // cannot enable arm because of native dependencies - e.g. keytar doesn't provide pre-builds for arm\n // result.set(Arch.armv7l, [\"snap\"])\n }\n else {\n for (const arch of defaultArchs) {\n result.set(archFromString(arch), defaultTarget)\n }\n }\n }\n\n return result\n}\n\nexport function createTargets(nameToTarget: Map, rawList: Array, outDir: string, packager: PlatformPackager): Array {\n const result: Array = []\n\n const mapper = (name: string, factory: (outDir: string) => Target) => {\n let target = nameToTarget.get(name)\n if (target == null) {\n target = factory(outDir)\n nameToTarget.set(name, target)\n }\n result.push(target)\n }\n\n const targets = normalizeTargets(rawList, packager.defaultTarget)\n packager.createTargets(targets, mapper)\n return result\n}\n\nfunction normalizeTargets(targets: Array, defaultTarget: Array): Array {\n const list: Array = []\n for (const t of targets) {\n const name = t.toLowerCase().trim()\n if (name === DEFAULT_TARGET) {\n list.push(...defaultTarget)\n }\n else {\n list.push(name)\n }\n }\n return list\n}\n\nexport function createCommonTarget(target: string, outDir: string, packager: PlatformPackager): Target {\n if (archiveTargets.has(target)) {\n return new ArchiveTarget(target, outDir, packager)\n }\n else if (target === DIR_TARGET) {\n return new NoOpTarget(DIR_TARGET)\n }\n else {\n throw new Error(`Unknown target: ${target}`)\n }\n}\n\nexport class NoOpTarget extends Target {\n readonly options = null\n\n constructor(name: string) {\n super(name)\n }\n\n get outDir(): string {\n throw new Error(\"NoOpTarget\")\n }\n\n async build(appOutDir: string, arch: Arch): Promise {\n // no build\n }\n}"],"sourceRoot":""}