thedesk/app/node_modules/dmg-builder/out/licenseButtons.js.map
2019-09-12 23:38:13 +09:00

2 lines
9.8 KiB
Plaintext

{"version":3,"sources":["../src/licenseButtons.ts"],"names":[],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEO,eAAe,qBAAf,CAAqC,QAArC,EAAoE;AACzE,SAAO,iCAAiB,CAAC,MAAM,QAAQ,CAAC,YAAhB,EACrB,MADqB,CACd,EAAE,IAAG;AACX,UAAM,IAAI,GAAG,EAAE,CAAC,WAAH,EAAb,CADW,CAEX;;AACA,WAAO,IAAI,CAAC,UAAL,CAAgB,iBAAhB,MAAuC,IAAI,CAAC,QAAL,CAAc,OAAd,KAA0B,IAAI,CAAC,QAAL,CAAc,MAAd,CAAjE,CAAP;AACD,GALqB,CAAjB,EAKD,QALC,CAAP;AAMD;;AASM,eAAe,iBAAf,CAAiC,kBAAjC,EAAgF,cAAhF,EAAwG,EAAxG,EAAoH,IAApH,EAAgI;AACrI,MAAI,IAAI,GAAG,gDAAkB,cAAlB,EAAkC,EAAlC,EAAsC,IAAtC,CAAX;;AAEA,OAAK,MAAM,IAAX,IAAmB,kBAAnB,EAAuC;AACrC,QAAI,IAAI,CAAC,cAAL,KAAwB,cAA5B,EAA4C;AAC1C;AACD;;AAED,QAAI;AACF,YAAM,QAAQ,GAAG,yBAAS,MAAM,yBAAS,IAAI,CAAC,IAAd,EAAoB,OAApB,CAAf,EAAjB;AACA,YAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAV,E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B,EAAoC,CAApC,EAA+C,YAA/C,EAAgE;AAC9D,QAAM,IAAI,GAAG,GAAG,CAAC,UAAJ,CAAe,CAAf,CAAb;;AACA,MAAI,IAAI,GAAG,GAAX,EAAgB;AACd,WAAO,IAAI,CAAC,QAAL,CAAc,EAAd,CAAP;AACD,GAFD,MAGK,IAAI,IAAI,GAAG,GAAX,EAAgB;AACnB,WAAO,KAAK,GAAC,MAAN,CAAa,GAAG,CAAC,CAAD,CAAhB,EAAqB,UAArB,EAAiC,QAAjC,CAA0C,KAA1C,CAAP;AACD,GAFI,MAGA;AACH,SAAK,IAAI,CAAC,GAAG,CAAb,EAAgB,CAAC,GAAG,YAAY,CAAC,MAAjC,EAAyC,CAAC,EAA1C,EAA8C;AAC5C,YAAM,MAAM,GAAG,KAAK,GAAC,MAAN,CAAa,GAAG,CAAC,CAAD,CAAhB,EAAqB,YAAY,CAAC,CAAD,CAAjC,EAAsC,QAAtC,CAA+C,KAA/C,CAAf;;AACA,UAAI,MAAM,KAAK,SAAf,EAA0B;AACxB,eAAO,MAAP;AACD;AACF;AACF;;AACD,SAAO,IAAP;AACD,C","sourcesContent":["import { log } from \"builder-util\"\nimport { PlatformPackager } 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 { safeLoad } 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((await packager.resourceList)\n .filter(it => {\n const name = it.toLowerCase()\n // noinspection SpellCheckingInspection\n return name.startsWith(\"licensebuttons_\") && (name.endsWith(\".json\") || name.endsWith(\".yml\"))\n }), packager)\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 = safeLoad(await readFile(item.file, \"utf-8\")) as any\n const buttonsStr = 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 }\n catch (e) {\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 }\n catch (e) {\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 }\n else if (code < 256) {\n return iconv.encode(str[i], \"macroman\").toString(\"hex\")\n }\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}"],"sourceRoot":""}