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,CAAgC,UAAhC,EAAyD;AACvD,SAAO,WAAW,IAAX,CAAgB,MAAM,GAAG,QAAH,CAAY,SAAZ,KAA0B,GAAG,QAAH,CAAY,cAAZ,CAAhD,CAAP;AACD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { Arch, asArray, InvalidConfigurationError, log, deepAssign } from \"builder-util\"\nimport { copyOrLinkFile, walk } from \"builder-util/out/fs\"\nimport { emptyDir, readdir, readFile, writeFile } from \"fs-extra-p\"\nimport * as path from \"path\"\nimport { AppXOptions } from \"../\"\nimport { Target } from \"../core\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { VmManager } from \"../vm/vm\"\nimport { getSignVendorPath, isOldWin6 } from \"../windowsCodeSign\"\nimport { WinPackager } from \"../winPackager\"\nimport { createStageDir } from \"./targetUtil\"\n\nconst APPX_ASSETS_DIR_NAME = \"appx\"\n\nconst vendorAssetsForDefaultAssets: { [key: string]: string; } = {\n \"StoreLogo.png\": \"SampleAppx.50x50.png\",\n \"Square150x150Logo.png\": \"SampleAppx.150x150.png\",\n \"Square44x44Logo.png\": \"SampleAppx.44x44.png\",\n \"Wide310x150Logo.png\": \"SampleAppx.310x150.png\",\n}\n\nconst DEFAULT_RESOURCE_LANG = \"en-US\"\n\nexport default class AppXTarget extends Target {\n readonly options: AppXOptions = deepAssign({}, this.packager.platformSpecificBuildOptions, this.packager.config.appx)\n\n constructor(private readonly packager: WinPackager, readonly outDir: string) {\n super(\"appx\")\n\n if (process.platform !== \"darwin\" && (process.platform !== \"win32\" || isOldWin6())) {\n throw new Error(\"AppX is supported only on Windows 10 or Windows Server 2012 R2 (version number 6.3+)\")\n }\n }\n\n // https://docs.microsoft.com/en-us/windows/uwp/packaging/create-app-package-with-makeappx-tool#mapping-files\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n const artifactName = packager.expandArtifactNamePattern(this.options, \"appx\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n this.logBuilding(\"AppX\", artifactPath, arch)\n\n const vendorPath = await getSignVendorPath()\n const vm = await packager.vm.value\n\n const stageDir = await createStageDir(this, packager, arch)\n\n const mappingFile = stageDir.getTempFile(\"mapping.txt\")\n const makeAppXArgs = [\"pack\", \"/o\" /* overwrite the output file if it exists */,\n \"/f\", vm.toVmFile(mappingFile),\n \"/p\", vm.toVmFile(artifactPath),\n ]\n if (packager.compression === \"store\") {\n makeAppXArgs.push(\"/nc\")\n }\n\n const mappingList: Array<Array<string>> = []\n mappingList.push(await BluebirdPromise.map(walk(appOutDir), file => {\n let appxPath = file.substring(appOutDir.length + 1)\n if (path.sep !== \"\\\\\") {\n appxPath = appxPath.replace(/\\//g, \"\\\\\")\n }\n return `\"${vm.toVmFile(file)}\" \"app\\\\${appxPath}\"`\n }))\n\n const userAssetDir = await this.packager.getResource(undefined, APPX_ASSETS_DIR_NAME)\n const assetInfo = await AppXTarget.computeUserAssets(vm, vendorPath, userAssetDir)\n const userAssets = assetInfo.userAssets\n\n const manifestFile = stageDir.getTempFile(\"AppxManifest.xml\")\n await this.writeManifest(manifestFile, arch, await this.computePublisherName(), userAssets)\n mappingList.push(assetInfo.mappings)\n mappingList.push([`\"${vm.toVmFile(manifestFile)}\" \"AppxManifest.xml\"`])\n\n if (isScaledAssetsProvided(userAssets)) {\n const outFile = vm.toVmFile(stageDir.getTempFile(\"resources.pri\"))\n const makePriPath = vm.toVmFile(path.join(vendorPath, \"windows-10\", Arch[arch], \"makepri.exe\"))\n\n const assetRoot = stageDir.getTempFile(\"appx/assets\")\n await emptyDir(assetRoot)\n await BluebirdPromise.map(assetInfo.allAssets, it => copyOrLinkFile(it, path.join(assetRoot, path.basename(it))))\n\n await vm.exec(makePriPath, [\"new\",\n \"/Overwrite\",\n \"/Manifest\", vm.toVmFile(manifestFile),\n \"/ProjectRoot\", vm.toVmFile(path.dirname(assetRoot)),\n \"/ConfigXml\", vm.toVmFile(path.join(getTemplatePath(\"appx\"), \"priconfig.xml\")),\n \"/OutputFile\", outFile,\n ])\n\n // in addition to resources.pri, resources.scale-140.pri and other such files will be generated\n for (const resourceFile of (await readdir(stageDir.dir)).filter(it => it.startsWith(\"resources.\")).sort()) {\n mappingList.push([`\"${vm.toVmFile(stageDir.getTempFile(resourceFile))}\" \"${resourceFile}\"`])\n }\n makeAppXArgs.push(\"/l\")\n }\n\n let mapping = \"[Files]\"\n for (const list of mappingList) {\n mapping += \"\\r\\n\" + list.join(\"\\r\\n\")\n }\n await writeFile(mappingFile, mapping)\n packager.debugLogger.add(\"appx.mapping\", mapping)\n\n if (this.options.makeappxArgs != null) {\n makeAppXArgs.push(...this.options.makeappxArgs)\n }\n await vm.exec(vm.toVmFile(path.join(vendorPath, \"windows-10\", Arch[arch], \"makeappx.exe\")), makeAppXArgs)\n await packager.sign(artifactPath)\n\n await stageDir.cleanup()\n\n packager.info.dispatchArtifactCreated({\n file: artifactPath,\n packager,\n arch,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"appx\"),\n target: this,\n isWriteUpdateInfo: this.options.electronUpdaterAware,\n })\n }\n\n private static async computeUserAssets(vm: VmManager, vendorPath: string, userAssetDir: string | null) {\n const mappings: Array<string> = []\n let userAssets: Array<string>\n const allAssets: Array<string> = []\n if (userAssetDir == null) {\n userAssets = []\n }\n else {\n userAssets = (await readdir(userAssetDir)).filter(it => !it.startsWith(\".\") && !it.endsWith(\".db\") && it.includes(\".\"))\n for (const name of userAssets) {\n mappings.push(`\"${vm.toVmFile(userAssetDir)}${vm.pathSep}${name}\" \"assets\\\\${name}\"`)\n allAssets.push(path.join(userAssetDir, name))\n }\n }\n\n for (const defaultAsset of Object.keys(vendorAssetsForDefaultAssets)) {\n if (userAssets.length === 0 || !isDefaultAssetIncluded(userAssets, defaultAsset)) {\n const file = path.join(vendorPath, \"appxAssets\", vendorAssetsForDefaultAssets[defaultAsset])\n mappings.push(`\"${vm.toVmFile(file)}\" \"assets\\\\${defaultAsset}\"`)\n allAssets.push(file)\n }\n }\n\n // we do not use process.arch to build path to tools, because even if you are on x64, ia32 appx tool must be used if you build appx for ia32\n return {userAssets, mappings, allAssets}\n }\n\n // https://github.com/electron-userland/electron-builder/issues/2108#issuecomment-333200711\n private async computePublisherName() {\n if (await this.packager.cscInfo.value == null) {\n log.info({reason: \"Windows Store only build\"}, \"AppX is not signed\")\n return this.options.publisher || \"CN=ms\"\n }\n\n const publisher = await this.packager.computedPublisherSubjectOnWindowsOnly.value\n if (!publisher) {\n throw new Error(\"Internal error: cannot compute subject using certificate info\")\n }\n return publisher\n }\n\n private async writeManifest(outFile: string, arch: Arch, publisher: string, userAssets: Array<string>) {\n const appInfo = this.packager.appInfo\n const options = this.options\n const executable = `app\\\\${appInfo.productFilename}.exe`\n const displayName = options.displayName || appInfo.productName\n const manifest = (await readFile(path.join(getTemplatePath(\"appx\"), \"appxmanifest.xml\"), \"utf8\"))\n .replace(/\\${([a-zA-Z0-9]+)}/g, (match, p1): string => {\n switch (p1) {\n case \"publisher\":\n return publisher\n\n case \"publisherDisplayName\":\n const name = options.publisherDisplayName || appInfo.companyName\n if (name == null) {\n throw new InvalidConfigurationError(`Please specify \"author\" in the application package.json — it is required because \"appx.publisherDisplayName\" is not set.`)\n }\n return name\n\n case \"version\":\n return appInfo.versionInWeirdWindowsForm\n\n case \"applicationId\":\n const result = options.applicationId || options.identityName || appInfo.name\n if (!isNaN(parseInt(result[0], 10))) {\n let message = `AppX Application.Id can’t start with numbers: \"${result}\"`\n if (options.applicationId == null) {\n message += `\\nPlease set appx.applicationId (or correct appx.identityName or name)`\n }\n throw new InvalidConfigurationError(message)\n }\n return result\n\n case \"identityName\":\n return options.identityName || appInfo.name\n\n case \"executable\":\n return executable\n\n case \"displayName\":\n return displayName\n\n case \"description\":\n return appInfo.description || appInfo.productName\n\n case \"backgroundColor\":\n return options.backgroundColor || \"#464646\"\n\n case \"logo\":\n return \"assets\\\\StoreLogo.png\"\n\n case \"square150x150Logo\":\n return \"assets\\\\Square150x150Logo.png\"\n\n case \"square44x44Logo\":\n return \"assets\\\\Square44x44Logo.png\"\n\n case \"lockScreen\":\n return lockScreenTag(userAssets)\n\n case \"defaultTile\":\n return defaultTileTag(userAssets)\n\n case \"splashScreen\":\n return splashScreenTag(userAssets)\n\n case \"arch\":\n return arch === Arch.ia32 ? \"x86\" : \"x64\"\n\n case \"resourceLanguages\":\n return resourceLanguageTag(asArray(options.languages))\n\n case \"extensions\":\n return this.getExtensions(executable, displayName)\n\n default:\n throw new Error(`Macro ${p1} is not defined`)\n }\n })\n await writeFile(outFile, manifest)\n }\n\n private getExtensions(executable: string, displayName: string): string {\n let isAddAutoLaunchExtension = this.options.addAutoLaunchExtension\n if (isAddAutoLaunchExtension === undefined) {\n const deps = this.packager.info.metadata.dependencies\n isAddAutoLaunchExtension = deps != null && deps[\"electron-winstore-auto-launch\"] != null\n }\n\n if (!isAddAutoLaunchExtension) {\n return \"\"\n }\n\n return `<Extensions>\n <desktop:Extension Category=\"windows.startupTask\" Executable=\"${executable}\" EntryPoint=\"Windows.FullTrustApplication\">\n <desktop:StartupTask TaskId=\"SlackStartup\" Enabled=\"true\" DisplayName=\"${displayName}\" />\n </desktop:Extension>\n </Extensions>`\n }\n}\n\n// get the resource - language tag, see https://docs.microsoft.com/en-us/windows/uwp/globalizing/manage-language-and-region#specify-the-supported-languages-in-the-apps-manifest\nfunction resourceLanguageTag(userLanguages: Array<string> | null | undefined): string {\n if (userLanguages == null || userLanguages.length === 0) {\n userLanguages = [DEFAULT_RESOURCE_LANG]\n }\n return userLanguages.map(it => `<Resource Language=\"${it.replace(/_/g, \"-\")}\" />`).join(\"\\n\")\n}\n\nfunction lockScreenTag(userAssets: Array<string>): string {\n if (isDefaultAssetIncluded(userAssets, \"BadgeLogo.png\")) {\n return '<uap:LockScreen Notification=\"badgeAndTileText\" BadgeLogo=\"assets\\\\BadgeLogo.png\" />'\n }\n else {\n return \"\"\n }\n}\n\nfunction defaultTileTag(userAssets: Array<string>): string {\n const defaultTiles: Array<string> = [\"<uap:DefaultTile\", 'Wide310x150Logo=\"assets\\\\Wide310x150Logo.png\"']\n\n if (isDefaultAssetIncluded(userAssets, \"LargeTile.png\")) {\n defaultTiles.push('Square310x310Logo=\"assets\\\\LargeTile.png\"')\n }\n if (isDefaultAssetIncluded(userAssets, \"SmallTile.png\")) {\n defaultTiles.push('Square71x71Logo=\"assets\\\\SmallTile.png\"')\n }\n\n defaultTiles.push(\"/>\")\n return defaultTiles.join(\" \")\n}\n\nfunction splashScreenTag(userAssets: Array<string>): string {\n if (isDefaultAssetIncluded(userAssets, \"SplashScreen.png\")) {\n return '<uap:SplashScreen Image=\"assets\\\\SplashScreen.png\" />'\n }\n else {\n return \"\"\n }\n}\n\nfunction isDefaultAssetIncluded(userAssets: Array<string>, defaultAsset: string) {\n const defaultAssetName = defaultAsset.substring(0, defaultAsset.indexOf(\".\"))\n return userAssets.some(it => it.includes(defaultAssetName))\n}\n\nfunction isScaledAssetsProvided(userAssets: Array<string>) {\n return userAssets.some(it => it.includes(\".scale-\") || it.includes(\".targetsize-\"))\n}"],"sourceRoot":""}
|