Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 8 Examples of "lazy-val in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'lazy-val' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

export async function installAppDeps(args: any) {
  try {
    log.info({version: PACKAGE_VERSION}, "electron-builder")
  }
  catch (e) {
    // error in dev mode without babel
    if (!(e instanceof ReferenceError)) {
      throw e
    }
  }

  const projectDir = process.cwd()
  const packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))
  const config = await getConfig(projectDir, null, null, packageMetadata)
  const results = await Promise.all([
    computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
    getElectronVersion(projectDir, config, packageMetadata),
  ])

  // if two package.json — force full install (user wants to install/update app deps in addition to dev)
  await installOrRebuild(config, results[0], {
    frameworkInfo: {version: results[1], useCustomDist: true},
    platform: args.platform,
    arch: args.arch,
    productionDeps: createLazyProductionDeps(results[0], null),
  }, results[0] !== projectDir)
}
import { archive, ArchiveOptions } from "../archive"
import { appendBlockmap, configureDifferentialAwareArchiveOptions, createBlockmap, createNsisWebDifferentialUpdateInfo } from "../differentialUpdateInfoBuilder"
import { getWindowsInstallationDirName } from "../targetUtil"
import { addCustomMessageFileInclude, createAddLangsMacro, LangConfigurator } from "./nsisLang"
import { computeLicensePage } from "./nsisLicense"
import { NsisOptions, PortableOptions } from "./nsisOptions"
import { NsisScriptGenerator } from "./nsisScriptGenerator"
import { AppPackageHelper, NSIS_PATH, nsisTemplatesDir, UninstallerReader } from "./nsisUtil"

const debug = _debug("electron-builder:nsis")

// noinspection SpellCheckingInspection
const ELECTRON_BUILDER_NS_UUID = UUID.parse("50e065bc-3134-11e6-9bab-38c9862bdaf3")

// noinspection SpellCheckingInspection
const nsisResourcePathPromise = new Lazy(() => getBinFromUrl("nsis-resources", "3.4.1", "Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q=="))

const USE_NSIS_BUILT_IN_COMPRESSOR = false

export class NsisTarget extends Target {
  readonly options: NsisOptions

  /** @private */
  readonly archs: Map = new Map()

  constructor(readonly packager: WinPackager, readonly outDir: string, targetName: string, protected readonly packageHelper: AppPackageHelper) {
    super(targetName)

    this.packageHelper.refCount++

    this.options = targetName === "portable" ? Object.create(null) : {
      preCompressedFileExtensions: [".avi", ".mov", ".m4v", ".mp4", ".m4p", ".qt", ".mkv", ".webm", ".vmdk"],
import BluebirdPromise from "bluebird-lst"
import { Arch, log } from "builder-util"
import { PackageFileInfo } from "builder-util-runtime"
import { getBinFromUrl } from "../../binDownload"
import { copyFile } from "builder-util/out/fs"
import { unlink } from "fs-extra"
import { Lazy } from "lazy-val"
import * as path from "path"
import { getTemplatePath } from "../../util/pathManager"
import { NsisTarget } from "./NsisTarget"
import fs from "fs"
import zlib from "zlib"

export const nsisTemplatesDir = getTemplatePath("nsis")

export const NSIS_PATH = new Lazy(() => {
  const custom = process.env.ELECTRON_BUILDER_NSIS_DIR
  if (custom != null && custom.length > 0) {
    return Promise.resolve(custom.trim())
  }
  // noinspection SpellCheckingInspection
  return getBinFromUrl("nsis", "3.0.4.1", "VKMiizYdmNdJOWpRGz4trl4lD++BvYP2irAXpMilheUP0pc93iKlWAoP843Vlraj8YG19CVn0j+dCo/hURz9+Q==")
})

export class AppPackageHelper {
  private readonly archToFileInfo = new Map>()
  private readonly infoToIsDelete = new Map()

  /** @private */
  refCount = 0

  constructor(private readonly elevateHelper: CopyElevateHelper) {
export async function createUpdateInfoTasks(event: ArtifactCreated, _publishConfigs: Array): Promise> {
  const packager = event.packager
  const publishConfigs = await getPublishConfigsForUpdateInfo(packager, _publishConfigs, event.arch)
  if (publishConfigs == null || publishConfigs.length === 0) {
    return []
  }

  const outDir = event.target!.outDir
  const version = packager.appInfo.version
  const sha2 = new Lazy(() => hashFile(event.file!, "sha256", "hex"))
  const isMac = packager.platform === Platform.MAC
  const createdFiles = new Set()
  const sharedInfo = await createUpdateInfo(version, event, await getReleaseInfo(packager))
  const tasks: Array = []
  const electronUpdaterCompatibility = packager.platformSpecificBuildOptions.electronUpdaterCompatibility || packager.config.electronUpdaterCompatibility || ">=2.15"
  for (const publishConfiguration of publishConfigs) {
    const isBintray = publishConfiguration.provider === "bintray"
    let dir = outDir
    // Bintray uses different variant of channel file info, better to generate it to a separate dir by always
    if (isBintray || (publishConfigs.length > 1 && publishConfiguration !== publishConfigs[0])) {
      dir = path.join(outDir, publishConfiguration.provider)
    }

    let isElectronUpdater1xCompatibility = computeIsisElectronUpdater1xCompatibility(electronUpdaterCompatibility, publishConfiguration, packager.info)

    let info = sharedInfo
export async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise {
  let version = configuration.electronVersion
  if (version == null) {
    // for prepacked app asar no dev deps in the app.asar
    if (packager.isPrepackedAppAsar) {
      version = await getElectronVersionFromInstalled(packager.projectDir)
      if (version == null) {
        throw new Error(`Cannot compute electron version for prepacked asar`)
      }
    }
    else {
      version = await computeElectronVersion(packager.projectDir, new Lazy(() => Promise.resolve(packager.metadata)))
    }
    configuration.electronVersion = version
  }

  return new ElectronFramework("electron", version, "Electron.app")
}
const titleFromOptions = configurator.electronWebpackConfiguration.title
  if (titleFromOptions == null || titleFromOptions === false) {
    return null
  }

  if (titleFromOptions !== true) {
    return titleFromOptions
  }

  let title: string | null | undefined = (configurator.metadata as any).productName
  if (title == null) {
    const electronBuilderConfig = await getConfig({
      packageKey: "build",
      configFilename: "electron-builder",
      projectDir: configurator.projectDir,
      packageMetadata: new Lazy(() => Promise.resolve(configurator.metadata))
    })
    if (electronBuilderConfig != null) {
      title = electronBuilderConfig.result.productName
    }
  }

  if (title == null) {
    title = configurator.metadata.name
  }
  return title
}
export async function getConfig(projectDir: string,
                                configPath: string | null,
                                configFromOptions: Configuration | null | undefined,
                                packageMetadata: Lazy<{ [key: string]: any } | null> = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))): Promise {
  const configRequest: ReadConfigRequest = {packageKey: "build", configFilename: "electron-builder", projectDir, packageMetadata}
  const configAndEffectiveFile = await _getConfig(configRequest, configPath)
  const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result
  if (configFromOptions != null) {
    mergePublish(config, configFromOptions)
  }

  if (configAndEffectiveFile != null) {
    log.info({file: configAndEffectiveFile.configFile == null ? 'package.json ("build" field)' : configAndEffectiveFile.configFile}, "loaded configuration")
  }

  if (config.extends == null && config.extends !== null) {
    const metadata = await packageMetadata.value || {}
    const devDependencies = metadata.devDependencies
    const dependencies = metadata.dependencies
    if ((dependencies != null && "react-scripts" in dependencies) || (devDependencies != null && "react-scripts" in devDependencies)) {
export function createLazyProductionDeps(projectDir: string, excludedDependencies: Array | null) {
  return new Lazy(async () => {
    const args = ["node-dep-tree", "--dir", projectDir]
    if (excludedDependencies != null) {
      for (const name of excludedDependencies) {
        args.push("--exclude-dep", name)
      }
    }
    return executeAppBuilderAsJson>(args)
  })
}

Is your System Free of Underlying Vulnerabilities?
Find Out Now