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AAM,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACnF,YAAY;YACd,CAAC,CAAC;KACP,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { asArray, copyDir, DO_NOT_USE_HARD_LINKS, executeAppBuilder, isEmptyOrSpaces, log, MAX_FILE_REQUESTS, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { emptyDir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport injectFFMPEG from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n  projectName?: string\n  productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n  return {\n    projectName: opts.electronBranding?.projectName || \"electron\",\n    productName: opts.electronBranding?.productName || \"Electron\",\n  }\n}\n\nexport interface ElectronDownloadOptions {\n  // https://github.com/electron-userland/electron-builder/issues/3077\n  // must be optional\n  version?: string\n\n  /**\n   * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n   */\n  cache?: string | null\n\n  /**\n   * The mirror.\n   */\n  mirror?: string | null\n\n  /** @private */\n  customDir?: string | null\n  /** @private */\n  customFilename?: string | null\n\n  strictSSL?: boolean\n  isVerifyChecksum?: boolean\n\n  platform?: ElectronPlatformName\n  arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n  return {\n    platform,\n    arch,\n    version: electronVersion,\n    ...opts.electronDownload,\n  }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n  const { appOutDir, packager } = options\n  const electronBranding = createBrandingOpts(packager.config)\n  if (packager.platform === Platform.LINUX) {\n    const linuxPackager = packager as LinuxPackager\n    const executable = path.join(appOutDir, linuxPackager.executableName)\n    await rename(path.join(appOutDir, electronBranding.projectName), executable)\n  } else if (packager.platform === Platform.WINDOWS) {\n    const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n    await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n    if (options.asarIntegrity) {\n      await addWinAsarIntegrity(executable, options.asarIntegrity)\n    }\n  } else {\n    await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n  }\n  await removeUnusedLanguagesIfNeeded(options)\n}\n\nasync function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n  const {\n    packager: { config, platformSpecificBuildOptions },\n  } = options\n  const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n  if (!wantedLanguages.length) {\n    return\n  }\n\n  const { dirs, langFileExt } = getLocalesConfig(options)\n  // noinspection SpellCheckingInspection\n  const deletedFiles = async (dir: string) => {\n    await asyncPool(MAX_FILE_REQUESTS, await readdir(dir), async file => {\n      if (path.extname(file) !== langFileExt) {\n        return\n      }\n\n      const language = path.basename(file, langFileExt)\n      if (!wantedLanguages.includes(language)) {\n        return rm(path.join(dir, file), { recursive: true, force: true })\n      }\n      return\n    })\n  }\n  await Promise.all(dirs.map(deletedFiles))\n\n  function getLocalesConfig(options: BeforeCopyExtraFilesOptions) {\n    const { appOutDir, packager } = options\n    if (packager.platform === Platform.MAC) {\n      return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n    }\n    return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n  }\n}\n\nclass ElectronFramework implements Framework {\n  // noinspection JSUnusedGlobalSymbols\n  readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n  // noinspection JSUnusedGlobalSymbols\n  readonly defaultAppIdPrefix = \"com.electron.\"\n  // noinspection JSUnusedGlobalSymbols\n  readonly isCopyElevateHelper = true\n  // noinspection JSUnusedGlobalSymbols\n  readonly isNpmRebuildRequired = true\n\n  constructor(\n    readonly name: string,\n    readonly version: string,\n    readonly distMacOsAppName: string\n  ) {}\n\n  getDefaultIcon(platform: Platform) {\n    if (platform === Platform.LINUX) {\n      return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n    } else {\n      // default icon is embedded into app skeleton\n      return null\n    }\n  }\n\n  async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n    const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n    const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n    await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n    if (options.packager.config.downloadAlternateFFmpeg) {\n      await injectFFMPEG(options, this.version)\n    }\n  }\n\n  beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n    return beforeCopyExtraFiles(options)\n  }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n  let version = configuration.electronVersion\n  if (version == null) {\n    // for prepacked app asar no dev deps in the app.asar\n    if (packager.isPrepackedAppAsar) {\n      version = await getElectronVersionFromInstalled(packager.projectDir)\n      if (version == null) {\n        throw new Error(`Cannot compute electron version for prepacked asar`)\n      }\n    } else {\n      version = await computeElectronVersion(packager.projectDir)\n    }\n    configuration.electronVersion = version\n  }\n\n  const branding = createBrandingOpts(configuration)\n  return new ElectronFramework(branding.projectName, version, `${branding.productName}.app`)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, distMacOsAppName: string): Promise<boolean> {\n  const downloadUsingAdjustedConfig = (options: ElectronDownloadOptions) => {\n    return executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", appOutDir, \"--distMacOsAppName\", distMacOsAppName])\n  }\n\n  const copyUnpackedElectronDistribution = async (folderPath: string) => {\n    log.info({ electronDist: log.filePath(folderPath) }, \"using custom unpacked Electron distribution\")\n    const source = packager.getElectronSrcDir(folderPath)\n    const destination = packager.getElectronDestinationDir(appOutDir)\n    log.info({ source, destination }, \"copying unpacked Electron\")\n    await emptyDir(appOutDir)\n    await copyDir(source, destination, {\n      isUseHardLink: DO_NOT_USE_HARD_LINKS,\n    })\n    return false\n  }\n\n  const selectElectron = async (filepath: string) => {\n    const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath)\n\n    const electronDistStats = await statOrNull(resolvedDist)\n    if (!electronDistStats) {\n      throw new Error(\n        `The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`\n      )\n    }\n\n    if (resolvedDist.endsWith(\".zip\")) {\n      log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n      await downloadUsingAdjustedConfig({\n        ...downloadOptions,\n        cache: path.dirname(resolvedDist), // set custom directory to the zip file's directory\n        customFilename: path.basename(resolvedDist), // set custom filename to the zip file's name\n      })\n      return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n    }\n\n    if (electronDistStats.isDirectory()) {\n      // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n      const files = await readdir(resolvedDist)\n      if (files.includes(defaultZipName)) {\n        log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n        await downloadUsingAdjustedConfig({\n          ...downloadOptions,\n          cache: resolvedDist,\n          customFilename: defaultZipName,\n        })\n        return false\n      }\n      // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n      // e.g. we treat it as a custom already-unpacked Electron distribution\n      return await copyUnpackedElectronDistribution(resolvedDist)\n    }\n    throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n  }\n\n  const { packager, appOutDir, platformName } = prepareOptions\n  const { version, arch } = downloadOptions\n  const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n  const electronDist = packager.config.electronDist\n  if (typeof electronDist === \"string\" && !isEmptyOrSpaces(electronDist)) {\n    return selectElectron(electronDist)\n  }\n\n  let resolvedDist: string | null = null\n  try {\n    const electronDistHook: any = await resolveFunction(packager.appInfo.type, electronDist, \"electronDist\")\n    resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n  } catch (error: any) {\n    log.warn({ error }, \"Failed to resolve electronDist, using default unpack logic\")\n  }\n\n  if (resolvedDist == null) {\n    // if no custom electronDist is provided, use the default unpack logic\n    log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n    await downloadUsingAdjustedConfig(downloadOptions)\n    return true // indicates that we should clean up after unpacking\n  }\n  return selectElectron(resolvedDist)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n  const out = prepareOptions.appOutDir\n  const isMac = prepareOptions.packager.platform === Platform.MAC\n  const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n  return Promise.all([\n    isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n    isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n    isMac\n      ? Promise.resolve()\n      : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {\n          /* ignore */\n        }),\n  ])\n}\n"]}