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AE,EAAE,GAhFmB;AAiFvB,EAAA,KAAK,EAAE,GAjFgB;AAkFvB,EAAA,EAAE,EAAE,GAlFmB;AAmFvB,EAAA,KAAK,EAAE,GAnFgB;AAoFvB,EAAA,EAAE,EAAE,GApFmB;AAqFvB,EAAA,KAAK,EAAE;AArFgB,CAAzB,C","sourcesContent":["import { exec, log } from \"builder-util\"\nimport { PlatformPackager } from \"app-builder-lib\"\nimport { getLicenseFiles } from \"app-builder-lib/out/util/license\"\nimport { outputFile, readFile } from \"fs-extra\"\nimport { serializeString } from \"./dmgUtil\"\nimport { getLicenseButtons, getLicenseButtonsFile } from \"./licenseButtons\"\n\n// DropDMG/dmgbuild a in any case (even if no english, but only ru/de) set to 0 (en_US), well, without docs, just believe that's correct\nconst DEFAULT_REGION_CODE = 0\n\nexport async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath: string): Promise<string | null> {\n // http://www.owsiak.org/?p=700\n const licenseFiles = await getLicenseFiles(packager)\n if (licenseFiles.length === 0) {\n return null\n }\n\n const licenseButtonFiles = await getLicenseButtonsFile(packager)\n packager.debugLogger.add(\"dmg.licenseFiles\", licenseFiles)\n packager.debugLogger.add(\"dmg.licenseButtons\", licenseButtonFiles)\n\n const style: Array<string> = []\n const rtfs: Array<string> = []\n const defaultButtons: Array<string> = []\n\n let counter = 5000\n const addedRegionCodes: Array<number> = []\n for (const item of licenseFiles) {\n log.info({lang: item.langName}, \"adding license\")\n\n // value from DropDMG, data the same for any language\n // noinspection SpellCheckingInspection\n style.push(`data 'styl' (${counter}, \"${item.langName}\") {\n $\"0001 0000 0000 000E 0011 0015 0000 000C\"\n $\"0000 0000 0000\"\n};`)\n\n let data = `data 'RTF ' (${counter}, \"${item.langName}\") {\\n`\n const fileData = await readFile(item.file, \"utf-8\")\n const isRtf = item.file.endsWith(\".rtf\") || item.file.endsWith(\".RTF\")\n data += isRtf ? serializeString((Buffer.from(fileData)).toString(\"hex\")) : wrapInRtf(await readFile(item.file, \"utf-8\"))\n data += \"\\n};\"\n rtfs.push(data)\n\n defaultButtons.push(await getLicenseButtons(licenseButtonFiles, item.langWithRegion, counter, item.langName))\n addedRegionCodes.push(getRegionCode(item.langWithRegion))\n counter++\n }\n\n const buffer = Buffer.allocUnsafe((2 + (3 * addedRegionCodes.length)) * 2)\n let offset = 0\n buffer.writeUInt16BE(DEFAULT_REGION_CODE, offset)\n offset += 2\n buffer.writeUInt16BE(addedRegionCodes.length, offset)\n offset += 2\n\n for (let i = 0; i < addedRegionCodes.length; i++) {\n const regionCode = addedRegionCodes[i]\n buffer.writeUInt16BE(regionCode, offset)\n offset += 2\n buffer.writeUInt16BE(i, offset)\n offset += 2\n buffer.writeUInt16BE(/* is two byte */ [14, 51, 52, 53].includes(regionCode) ? 1 : 0, offset)\n offset += 2\n }\n\n const lPic = `data 'LPic' (5000) {\\n${serializeString(buffer.toString(\"hex\"))}\\n};`\n const data = style\n .concat(rtfs)\n .concat(lPic)\n .concat(defaultButtons)\n .join(\"\\n\\n\")\n\n packager.debugLogger.add(\"dmg.licenseResource\", data)\n const tempFile = await packager.getTempFile(\".r\")\n await outputFile(tempFile, data)\n await exec(\"hdiutil\", [\"unflatten\", dmgPath])\n await exec(\"Rez\", [\"-a\", tempFile, \"-o\", dmgPath])\n await exec(\"hdiutil\", [\"flatten\", dmgPath])\n\n return data\n}\n\nfunction getRtfUnicodeEscapedString(text: string) {\n let result = \"\"\n for (let i = 0; i < text.length; i++) {\n if (text[i] === \"\\\\\" || text[i] === \"{\" || text[i] === \"}\" || text[i] === \"\\n\") {\n result += `\\\\${text[i]}`\n }\n else if (text[i] === \"\\r\") {\n // ignore\n }\n else if (text.charCodeAt(i) <= 0x7f) {\n result += text[i]\n }\n else {\n result += `\\\\u${text.codePointAt(i)}`\n }\n }\n return result\n}\n\nfunction wrapInRtf(text: string) {\n return ` $\"7B5C 7274 6631 5C61 6E73 695C 616E 7369\"\n $\"6370 6731 3235 325C 636F 636F 6172 7466\"\n $\"3135 3034 5C63 6F63 6F61 7375 6272 7466\"\n $\"3833 300A 7B5C 666F 6E74 7462 6C5C 6630\"\n $\"5C66 7377 6973 735C 6663 6861 7273 6574\"\n $\"3020 4865 6C76 6574 6963 613B 7D0A 7B5C\"\n $\"636F 6C6F 7274 626C 3B5C 7265 6432 3535\"\n $\"5C67 7265 656E 3235 355C 626C 7565 3235\"\n $\"353B 7D0A 7B5C 2A5C 6578 7061 6E64 6564\"\n $\"636F 6C6F 7274 626C 3B3B 7D0A 5C70 6172\"\n $\"645C 7478 3536 305C 7478 3131 3230 5C74\"\n $\"7831 3638 305C 7478 3232 3430 5C74 7832\"\n $\"3830 305C 7478 3333 3630 5C74 7833 3932\"\n $\"305C 7478 3434 3830 5C74 7835 3034 305C\"\n $\"7478 3536 3030 5C74 7836 3136 305C 7478\"\n $\"3637 3230 5C70 6172 6469 726E 6174 7572\"\n $\"616C 5C70 6172 7469 6768 7465 6E66 6163\"\n $\"746F 7230 0A0A 5C66 305C 6673 3234 205C\"\n${serializeString(\"63663020\" + Buffer.from(getRtfUnicodeEscapedString(text)).toString(\"hex\").toUpperCase() + \"7D\")}`\n // ^ to produce correctly splitted output, this two leading chunks from default wrapper appended here\n}\n\nfunction getRegionCode(langWithRegion: string) {\n const result = regionCodes[langWithRegion]\n if (result == null) {\n throw new Error(`Cannot determine region code for ${langWithRegion}`)\n }\n return result\n}\n\n// noinspection SpellCheckingInspection\nconst regionCodes: any = {\n en_US: 0,\n fr_FR: 1,\n en_GB: 2,\n de_DE: 3,\n it_IT: 4,\n nl_NL: 5,\n nl_BE: 6,\n sv_SE: 7,\n es_ES: 8,\n da_DK: 9,\n pt_PT: 10,\n fr_CA: 11,\n nb_NO: 12,\n he_IL: 13,\n ja_JP: 14,\n en_AU: 15,\n ar: 16,\n fi_FI: 17,\n fr_CH: 18,\n de_CH: 19,\n el_GR: 20,\n is_IS: 21,\n mt_MT: 22,\n el_CY: 23,\n tr_TR: 24,\n hi_IN: 33,\n ur_PK: 34,\n it_CH: 36,\n ro_RO: 39,\n grc: 40,\n lt_LT: 41,\n pl_PL: 42,\n hu_HU: 43,\n et_EE: 44,\n lv_LV: 45,\n se: 46,\n fo_FO: 47,\n fa_IR: 48,\n ru_RU: 49,\n ga_IE: 50,\n ko_KR: 51,\n zh_CN: 52,\n zh_TW: 53,\n th_TH: 54,\n cs_CZ: 56,\n sk_SK: 57,\n bn: 60,\n be_BY: 61,\n uk_UA: 62,\n sr_RS: 65,\n sl_SI: 66,\n mk_MK: 67,\n hr_HR: 68,\n pt_BR: 71,\n bg_BG: 72,\n ca_ES: 73,\n gd: 75,\n gv: 76,\n br: 77,\n iu_CA: 78,\n cy: 79,\n \"ga-Latg_IE\": 81,\n en_CA: 82,\n dz_BT: 83,\n hy_AM: 84,\n ka_GE: 85,\n es_419: 86,\n to_TO: 88,\n fr_001: 91,\n de_AT: 92,\n gu_IN: 94,\n pa: 95,\n ur_IN: 96,\n vi_VN: 97,\n fr_BE: 98,\n uz_UZ: 99,\n en_SG: 100,\n nn_NO: 101,\n af_ZA: 102,\n eo: 103,\n mr_IN: 104,\n bo: 105,\n ne_NP: 106,\n kl: 107,\n en_IE: 108\n}"],"sourceRoot":""}
|