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QAChL,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;QAEzD,OAAO,YAAY,CAAA;IACrB,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,UAAkB,EAAE,IAAU,EAAE,aAAiD;QAC7G,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAE5B,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACxC,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAC7C,aAAa,EAAE,aAAa;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACxD,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;SACnD,CAAC,CAAA;IACJ,CAAC;CACF;AApFD,mCAoFC","sourcesContent":["import { Arch, deepAssign } from \"builder-util\"\nimport { UUID } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { MsiWrappedOptions } from \"../\"\nimport { TargetConfiguration } from \"../core\"\nimport { FinalCommonWindowsInstallerOptions } from \"../options/CommonWindowsInstallerConfiguration\"\nimport { WinPackager } from \"../winPackager\"\nimport MsiTarget from \"./MsiTarget\"\n\nconst ELECTRON_MSI_WRAPPED_NS_UUID = UUID.parse(\"467f7bb2-a83c-442f-b776-394d316e8e53\")\n\nexport default class MsiWrappedTarget extends MsiTarget {\n readonly options: MsiWrappedOptions = deepAssign(this.packager.platformSpecificBuildOptions, this.packager.config.msiWrapped)\n\n /** @private */\n private readonly archs: Map = new Map()\n\n constructor(packager: WinPackager, readonly outDir: string) {\n // must be synchronous so it can run after nsis\n super(packager, outDir, \"msiWrapped\", false)\n }\n\n private get productId(): string {\n // this id is only required to build the installer\n // however it serves no purpose as this msi is just\n // a wrapper for an exe\n return UUID.v5(this.packager.appInfo.id, ELECTRON_MSI_WRAPPED_NS_UUID).toUpperCase()\n }\n\n private validatePrerequisites(): void {\n const config = this.packager.config\n // this target requires nsis to be configured and executed\n // as this build re-bundles the nsis executable and wraps it in an msi\n\n if (!config.win || !config.win.target || !Array.isArray(config.win.target)) {\n throw new Error(\"No windows target found!\")\n }\n\n const target = config.win.target\n const nsisTarget = \"nsis\"\n if (\n !target\n .map((t: TargetConfiguration | string): string => {\n const result: string = typeof t === \"string\" ? t : t.target\n return result.toLowerCase().trim()\n })\n .some(t => t === nsisTarget)\n ) {\n throw new Error(\"No nsis target found! Please specify an nsis target\")\n }\n }\n\n build(appOutDir: string, arch: Arch): Promise {\n this.archs.set(arch, appOutDir)\n return Promise.resolve()\n }\n\n finishBuild(): Promise {\n // this target invokes `build` in `finishBuild` to guarantee\n // that the dependent target has already been built\n // this also affords us re-usability\n const [arch, appOutDir] = this.archs.entries().next().value\n\n this.validatePrerequisites()\n\n return super.build(appOutDir, arch)\n }\n\n protected get installerFilenamePattern(): string {\n // big assumption is made here for the moment that the pattern didn't change\n // tslint:disable:no-invalid-template-strings\n return \"${productName} Setup ${version}.${ext}\"\n }\n\n private getExeSourcePath(arch: Arch) {\n const packager = this.packager\n // in this case, we want .exe, this way we can wrap the existing package if it exists\n const artifactName = packager.expandArtifactNamePattern(this.options, \"exe\", arch, this.installerFilenamePattern, false, this.packager.platformSpecificBuildOptions.defaultArch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n return artifactPath\n }\n\n protected async writeManifest(_appOutDir: string, arch: Arch, commonOptions: FinalCommonWindowsInstallerOptions) {\n const exeSourcePath = this.getExeSourcePath(arch)\n const options = this.options\n\n return (await this.projectTemplate.value)({\n ...(await this.getBaseOptions(commonOptions)),\n exeSourcePath: exeSourcePath,\n productId: this.productId,\n impersonate: options.impersonate === true ? \"yes\" : \"no\",\n wrappedInstallerArgs: options.wrappedInstallerArgs,\n })\n }\n}\n"]}