@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
45 lines • 2.5 kB
TypeScript
import { LaunchArguments } from '../common/launch-arguments';
/**
* Holds the parsed CLI options of *forwarded* launches (see the `second-instance` handling in
* `ElectronMainApplication`) in the trusted Electron main process, keyed by the `webContents` id of
* the window that was opened for them.
*
* ### Why the arguments never travel on the window URL
*
* The URL is the one channel in the system that carries no trust: in a browser deployment it is
* attacker-writable, so putting per-window options such as `--session-preference` there would let a
* crafted link inject settings (some of which persist to the User scope). The arguments therefore
* stay here in the main process and are handed to the window over the per-window metadata channel
* (`CHANNEL_WC_METADATA`), where main identifies the calling window by `event.sender.id` rather than
* by any value from the URL. This is the single place that documents that rationale; other files
* point here.
*
* The entry is not consumed on first read, so that a plain `Reload Window`, which re-runs the
* renderer against the same window, still observes the arguments. It is removed when the window is
* closed, and when the window is redirected to a *different* frontend (e.g. into a dev container
* after a CLI attach), since the arguments describe the launch rather than whatever the window is
* navigated to afterwards. See `TheiaElectronWindow.reload`.
*
* @experimental
*/
export declare class LaunchArgsStore {
protected readonly argsByWindowId: Map<number, LaunchArguments>;
/**
* Associates the parsed options of a forwarded launch with the window identified by `windowId` (its
* `webContents` id). Must be called before the window loads its URL, so that the preload script
* cannot ask for the arguments before they are stored.
*/
store(windowId: number, args: LaunchArguments): void;
/**
* Returns the parsed launch options for the window identified by `windowId`, or `undefined`
* for a window that was not opened by a forwarded launch (a cold-start window), or one whose
* arguments were dropped. Repeatable, so a plain reload still sees the arguments.
*/
get(windowId: number): LaunchArguments | undefined;
/**
* Drops the arguments stored for `windowId`. Called when the window is closed, and when it is
* redirected to a different frontend.
*/
delete(windowId: number): void;
}
//# sourceMappingURL=launch-args-store.d.ts.map