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ager } from \"app-builder-lib\"\nimport { getLicenseAssets } from \"app-builder-lib/out/util/license\"\nimport { readFile } from \"fs-extra\"\nimport * as iconv from \"iconv-lite\"\nimport { load } from \"js-yaml\"\nimport { serializeString } from \"./dmgUtil\"\nimport { getDefaultButtons } from \"./licenseDefaultButtons\"\n\nexport async function getLicenseButtonsFile(packager: PlatformPackager<any>): Promise<Array<LicenseButtonsFile>> {\n return getLicenseAssets(\n (await packager.resourceList).filter(it => {\n const name = it.toLowerCase()\n // noinspection SpellCheckingInspection\n return name.startsWith(\"licensebuttons_\") && (name.endsWith(\".json\") || name.endsWith(\".yml\"))\n }),\n packager\n )\n}\n\nexport interface LicenseButtonsFile {\n file: string\n lang: string\n langWithRegion: string\n langName: string\n}\n\nexport async function getLicenseButtons(licenseButtonFiles: Array<LicenseButtonsFile>, langWithRegion: string, id: number, name: string) {\n let data = getDefaultButtons(langWithRegion, id, name)\n\n for (const item of licenseButtonFiles) {\n if (item.langWithRegion !== langWithRegion) {\n continue\n }\n\n try {\n const fileData = load(await readFile(item.file, \"utf-8\")) as any\n const buttonsStr =\n labelToHex(fileData.lang, item.lang, item.langWithRegion) +\n labelToHex(fileData.agree, item.lang, item.langWithRegion) +\n labelToHex(fileData.disagree, item.lang, item.langWithRegion) +\n labelToHex(fileData.print, item.lang, item.langWithRegion) +\n labelToHex(fileData.save, item.lang, item.langWithRegion) +\n labelToHex(fileData.description, item.lang, item.langWithRegion)\n\n data = `data 'STR#' (${id}, \"${name}\") {\\n`\n data += serializeString(\"0006\" + buttonsStr)\n data += `\\n};`\n\n if (log.isDebugEnabled) {\n log.debug({ lang: item.langName, data }, `overwriting license buttons`)\n }\n return data\n } catch (e: any) {\n log.debug({ error: e }, \"cannot overwrite license buttons\")\n return data\n }\n }\n\n return data\n}\n\nfunction labelToHex(label: string, lang: string, langWithRegion: string) {\n const lbl = hexEncode(label, lang, langWithRegion).toString().toUpperCase()\n const len = numberToHex(lbl.length / 2)\n return len + lbl\n}\n\nfunction numberToHex(nb: number) {\n return (\"0\" + nb.toString(16)).slice(-2)\n}\n\nfunction hexEncode(str: string, lang: string, langWithRegion: string) {\n const macCodePages = getMacCodePage(lang, langWithRegion)\n let result = \"\"\n\n for (let i = 0; i < str.length; i++) {\n try {\n let hex = getMacHexCode(str, i, macCodePages)\n if (hex === undefined) {\n hex = \"3F\" //?\n }\n result += hex\n } catch (e: any) {\n log.debug({ error: e, char: str[i] }, \"cannot convert\")\n result += \"3F\" //?\n }\n }\n\n return result\n}\n\nfunction getMacCodePage(lang: string, langWithRegion: string) {\n switch (lang) {\n case \"ja\": //japanese\n return [\"euc-jp\"] //Apple Japanese\n case \"zh\": //chinese\n if (langWithRegion === \"zh_CN\") {\n return [\"gb2312\"] //Apple Simplified Chinese (GB 2312)\n }\n return [\"big5\"] //Apple Traditional Chinese (Big5)\n case \"ko\": //korean\n return [\"euc-kr\"] //Apple Korean\n case \"ar\": //arabic\n case \"ur\": //urdu\n return [\"macarabic\"] //Apple Arabic\n case \"he\": //hebrew\n return [\"machebrew\"] //Apple Hebrew\n case \"el\": //greek\n case \"elc\": //greek\n return [\"macgreek\"] //Apple Greek\n case \"ru\": //russian\n case \"be\": //belarussian\n case \"sr\": //serbian\n case \"bg\": //bulgarian\n case \"uz\": //uzbek\n return [\"maccyrillic\"] //Apple Macintosh Cyrillic\n case \"ro\": //romanian\n return [\"macromania\"] //Apple Romanian\n case \"uk\": //ukrainian\n return [\"macukraine\"] //Apple Ukrainian\n case \"th\": //thai\n return [\"macthai\"] //Apple Thai\n case \"et\": //estonian\n case \"lt\": //lithuanian\n case \"lv\": //latvian\n case \"pl\": //polish\n case \"hu\": //hungarian\n case \"cs\": //czech\n case \"sk\": //slovak\n return [\"maccenteuro\"] //Apple Macintosh Central Europe\n case \"is\": //icelandic\n case \"fo\": //faroese\n return [\"maciceland\"] //Apple Icelandic\n case \"tr\": //turkish\n return [\"macturkish\"] //Apple Turkish\n case \"hr\": //croatian\n case \"sl\": //slovenian\n return [\"maccroatian\"] //Apple Croatian\n default:\n return [\"macroman\"] //Apple Macintosh Roman\n }\n}\n\nfunction getMacHexCode(str: string, i: number, macCodePages: any) {\n const code = str.charCodeAt(i)\n if (code < 128) {\n return code.toString(16)\n } else if (code < 256) {\n return iconv.encode(str[i], \"macroman\").toString(\"hex\")\n } else {\n for (let i = 0; i < macCodePages.length; i++) {\n const result = iconv.encode(str[i], macCodePages[i]).toString(\"hex\")\n if (result !== undefined) {\n return result\n }\n }\n }\n return code\n}\n"]} |