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;;AACA,MAAI,MAAM,kBAAO,UAAP,CAAV,EAA8B;AAC5B,UAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAP,CAAmB;AAAC,MAAA,MAAM,EAAE;AAAT,KAAnB,CAAvB;AACA,UAAM,yBAAK,UAAL,EAAiB,CAAC,gBAAD,EAAmB,IAAnB,EAAyB,UAAzB,EAAqC,MAArC,EAA6C,QAA7C,CAAjB,CAAN;AACA,WAAO,QAAP;AACD;;AAED,SAAO,IAAP;AACD;AAED;;;AACM,SAAU,eAAV,CAA0B,IAA1B,EAAsC;AAC1C,SAAO,SAAS,IAAI,CAAC,KAAL,CAAW,UAAX,EAAyB,GAAzB,CAA6B,EAAE,IAAI,EAAE,CAAC,KAAH,CAAS,SAAT,EAAsB,IAAtB,CAA2B,GAA3B,CAAnC,EAAoE,IAApE,CAAyE,SAAzE,CAAT,GAA+F,GAAtG;AACD,C","sourcesContent":["import { exec } from \"builder-util\"\nimport { PlatformPackager } from \"app-builder-lib\"\nimport { exists } from \"builder-util/out/fs\"\nimport { executeFinally } from \"builder-util/out/promise\"\nimport * as path from \"path\"\nimport { TmpDir } from \"temp-file\"\n\nexport { DmgTarget } from \"./dmg\"\n\nconst root = path.join(__dirname, \"..\")\n\nexport function getDmgTemplatePath() {\n return path.join(root, \"templates\")\n}\n\nexport function getDmgVendorPath() {\n return path.join(root, \"vendor\")\n}\n\nexport async function attachAndExecute(dmgPath: string, readWrite: boolean, task: () => Promise<any>) {\n //noinspection SpellCheckingInspection\n const args = [\"attach\", \"-noverify\", \"-noautoopen\"]\n if (readWrite) {\n args.push(\"-readwrite\")\n }\n\n args.push(dmgPath)\n const attachResult = await exec(\"hdiutil\", args)\n const deviceResult = attachResult == null ? null : /^(\\/dev\\/\\w+)/.exec(attachResult)\n const device = deviceResult == null || deviceResult.length !== 2 ? null : deviceResult[1]\n if (device == null) {\n throw new Error(`Cannot mount: ${attachResult}`)\n }\n\n return await executeFinally(task(), () => detach(device))\n}\n\nexport async function detach(name: string) {\n try {\n await exec(\"hdiutil\", [\"detach\", \"-quiet\", name])\n }\n catch (e) {\n await new Promise((resolve, reject) => {\n setTimeout(() => {\n exec(\"hdiutil\", [\"detach\", \"-force\", name])\n .then(resolve)\n .catch(reject)\n }, 1000)\n })\n }\n}\n\nexport async function computeBackground(packager: PlatformPackager<any>): Promise<string> {\n const resourceList = await packager.resourceList\n if (resourceList.includes(\"background.tiff\")) {\n return path.join(packager.buildResourcesDir, \"background.tiff\")\n }\n else if (resourceList.includes(\"background.png\")) {\n return path.join(packager.buildResourcesDir, \"background.png\")\n }\n else {\n return path.join(getDmgTemplatePath(), \"background.tiff\")\n }\n}\n\nexport async function transformBackgroundFileIfNeed(file: string, tmpDir: TmpDir): Promise<string> {\n if (file.endsWith(\".tiff\") || file.endsWith(\".TIFF\")) {\n return file\n }\n\n const retinaFile = file.replace(/\\.([a-z]+)$/, \"@2x.$1\")\n if (await exists(retinaFile)) {\n const tiffFile = await tmpDir.getTempFile({suffix: \".tiff\"})\n await exec(\"tiffutil\", [\"-cathidpicheck\", file, retinaFile, \"-out\", tiffFile])\n return tiffFile\n }\n\n return file\n}\n\n/** @internal */\nexport function serializeString(data: string) {\n return ' $\"' + data.match(/.{1,32}/g)!!.map(it => it.match(/.{1,4}/g)!!.join(\" \")).join('\"\\n $\"') + '\"'\n}"],"sourceRoot":""}
|