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D,SAAO,IAAP;AACD;;AAEK,SAAA,kBAAA,CAA6B,MAA7B,EAA6C,MAA7C,EAA6D,QAA7D,EAA4F;AAChG,MAAI,eAAe,GAAf,CAAmB,MAAnB,CAAJ,EAAgC;AAC9B,WAAO,KAAI,8BAAJ,EAAkB,MAAlB,EAA0B,MAA1B,EAAkC,QAAlC,CAAP;AACD,GAFD,MAGK,IAAI,WAAW,mBAAf,EAA2B;AAC9B,WAAO,IAAI,UAAJ,CAAe,mBAAf,CAAP;AACD,GAFI,MAGA;AACH,UAAM,IAAI,KAAJ,CAAU,mBAAmB,MAAM,EAAnC,CAAN;AACD;AACF;;AAEK,MAAA,UAAA,SAA0B,eAA1B,CAAgC;AAGpC,cAAY,IAAZ,EAAwB;AACtB,UAAM,IAAN;AAHO,SAAA,OAAA,GAAU,IAAV;AAIR;;AAED,MAAI,MAAJ,GAAU;AACR,UAAM,IAAI,KAAJ,CAAU,YAAV,CAAN;AACD;;AAEK,OAAN,CAAY,SAAZ,EAA+B,IAA/B,EAAyC,CACvC;;AADuC;AAExC;;AAbmC,C","sourcesContent":["import { addValue, Arch, archFromString, ArchType, asArray } from \"builder-util\"\nimport { PlatformSpecificBuildOptions, DEFAULT_TARGET, DIR_TARGET, Platform, Target, TargetConfiguration } from \"../index\"\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<Arch, Array<string>>, options: PlatformSpecificBuildOptions, platform: Platform): Map<Arch, Array<string>> {\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<ArchType> = 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(options.target).map<TargetConfiguration>(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 for (const arch of defaultArchs) {\n result.set(archFromString(arch), [])\n }\n }\n\n return result\n}\n\nexport function createTargets(nameToTarget: Map<string, Target>, rawList: Array<string>, outDir: string, packager: PlatformPackager<any>): Array<Target> {\n const result: Array<Target> = []\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<string>, defaultTarget: Array<string>): Array<string> {\n const list: Array<string> = []\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<any>): 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<any> {\n // no build\n }\n}"],"sourceRoot":""}
|