Theia API Documentation v1.77.0
    Preparing search index...

    Provides paths to resources that are bundled with the application, in a form that can also be used by processes which do not run inside the application, such as shells, debug adapters or other external tools.

    When an Electron application is packaged with asar: true, the resources of the application are stored in an app.asar archive. Paths pointing into such an archive can only be read through Electron's patched fs module, so handing them to an external process fails. Therefore, always resolve a bundled resource through this service before passing its path to a process outside of the application.

    Implements

    Index
    envVariablesServer: EnvVariablesServer
    extractionFolder: "bundled-resources" = 'bundled-resources'

    The folder within the configuration directory into which resources are extracted.

    fileSystemLocking: FileSystemLocking
    logger: ILogger
    resolved: Map<string, Promise<string>> = ...
    staleExtractionAge: number = ...

    Resources extracted for another application version are removed when they are older than this.

    temporaryExtractionPath: Promise<string> | undefined
    • Collect the files of the given resource as paths relative to it. The relative path of a resource that is a plain file is the empty string.

      Parameters

      • resourcePath: string
      • relativePath: string = ''

      Returns Promise<string[]>

    • Find the archive that the given resource is packaged into, if any.

      Parameters

      • resourcePath: string

      Returns string | undefined

      the path of the archive, i.e. the shortest prefix of the given path ending in an .asar segment, which is also how Electron itself determines the archive that a path refers to.

    • Identify the content of the given archive. process.noAsar is toggled around the synchronous stat call to get the stats of the archive file itself rather than of the directory that it appears as.

      Parameters

      • archivePath: string

      Returns string

    • The directory into which resources of the given archive are extracted. It is specific to the content of the archive, so that updating the application invalidates previously extracted copies.

      Parameters

      • archivePath: string

      Returns Promise<string>

    • Fallback for applications whose configuration directory cannot be written to. The directory is unique to this run of the application, so that resources are extracted again whenever the application is started.

      Returns Promise<string>

    • Whether every file of the given resource is already available at the given target path. Packaging tools only unpack the files that the application configured them to unpack, so a partial copy must be ignored.

      Parameters

      • resourcePath: string
      • targetPath: string

      Returns Promise<boolean>

    • Remove resources that were extracted from an earlier version of the archive, unless they were used recently, because another application instance may still be running on that version.

      Parameters

      • extractionRoot: string
      • prefix: string
      • currentPath: string

      Returns void

    • Resolve the given path of a bundled file or directory to a path that external processes can read.

      If the resource is not packaged into an archive, its path is returned unchanged. Otherwise the copy that the packaging step has left outside of the archive is used, if it is complete, and the resource is extracted from the archive into the configuration directory as a last resort.

      Results are cached, so that a resource is extracted at most once per application version.

      Parameters

      • resourcePath: string

        the path of the bundled resource, typically resolved against __dirname.

      Returns Promise<string>

      the path to use outside of the application.

      if the resource does not exist or cannot be made available.