import { LoadingGraph, FetchedScript, LightLibraryQueryString } from './inputs.models'; import { VirtualDOM } from '@youwol/flux-view'; export type LibraryName = string; export type Version = string; /** * Encapsulates installations data at the time of instance creation. * * @category State */ export declare class Monitoring { /** * Dictionary with key of form `${libName}#${libVersion}` */ readonly exportedSymbols: { [k: string]: { symbol: string; apiKey: string; }; }; /** * Dictionary `libName->versions`. */ readonly importedBundles: { [k: string]: string[]; }; /** * Dictionary `libName->latest version`. */ readonly latestVersion: { [k: string]: string; }; /** * Create a VirtualDOM (see [fluxView](https://github.com/youwol/flux-view)) * representing the current state of installation (modules installed & available symbols). */ readonly view: VirtualDOM; constructor(); } /** * Provides extra-controls regarding dependencies and URL resolution. * * None of the methods exposed should be used in regular scenario. * * @category State */ export declare class State { /** * Pin some dependencies to use whenever a loading graph is resolved, * it will over-ride natural resolution from packages description. * */ static pinDependencies(dependencies: LightLibraryQueryString[]): void; /** * Register a 'patcher' for URLs to fetch resource: any time a request is done to the target resource, * the URL is actually replaced by the registered patch. * * This is provided if somehow a saved loading graph reference resources that have been moved to other location. * @param patcher function that takes `{ name, version, assetId, url }` as argument and return the patched URLs * (which should be the original if no transformation is required). */ static registerUrlPatcher(patcher: ({ name, version, assetId, url }: { name: any; version: any; assetId: any; url: any; }) => string): void; /** * Remove installed modules & reset the cache. * It makes its best to clear modules & associated side effects, but it is not perfect. * It is mostly intended at helping 'tear down' methods in tests. * * @param executingWindow where the resources have been installed */ static clear(executingWindow?: Window): void; } /** * Singleton object that gathers history of fetched modules, scripts & CSS. * It also acts as a cache store. * * This is essentially a 'friend' class used by {@link Client} which should not be exposed. */ export declare class StateImplementation { /** * Dictionary of `${libName}#${libVersion}` -> `{ symbol: string; apiKey: string }` * */ static exportedSymbolsDict: { [k: string]: { symbol: string; apiKey: string; aliases: string[]; }; }; /** * Return the exported symbol name of a library. * * For now implementation is based on a hard coded dictionary. * * @param name name of the library * @param version version of the library */ static getExportedSymbol(name: string, version: string): { symbol: string; apiKey: string; aliases: string[]; }; static updateExportedSymbolsDict(modules: { name: string; version: string; exportedSymbol: string; apiKey: string; aliases: string[]; }[]): void; /** * Imported modules: mapping between {@link LibraryName} and list of installed {@link Version}. */ static importedBundles: Map; /** * Fetched loading graph: mapping between a loading graph's body uid and corresponding computed loading graph. * @hidden */ static fetchedLoadingGraph: Map>; /** * Installed loading graph: mapping between a loading graph's body uid and window state */ static importedLoadingGraphs: Map>; /** * Installed script: mapping between a script's uid and a {@link FetchedScript}. * @hidden */ static importedScripts: Map>; /** * Latest version of modules installed: mapping between library name and latest version */ static latestVersion: Map; /** * Return whether a library at particular version hase been already installed with a compatible version. * Compatible version means a greater version with same major. * * @param libName library name * @param version version */ static isCompatibleVersionInstalled(libName: string, version: string): boolean; /** * @param aliases * @param executingWindow * @hidden */ static installAliases(aliases: { [key: string]: string | ((Window: any) => unknown); }, executingWindow: WindowOrWorkerGlobalScope): void; /** * Reset the cache, but keep installed modules. * @hidden */ static resetCache(): void; /** * Remove installed modules & reset the cache. * It makes its best to clear modules & associated side effects, but it is not perfect. * It is not expose anyway and serves at helping tests mostly. * * @param executingWindow where the resources have been installed * @hidden */ static clear(executingWindow?: Window): void; /** * Update the various properties after new modules have been imported. * * @param modules modules installed * @param executingWindow the executing window (where to expose the latest version if change need be). * @hidden */ static registerImportedModules(modules: { name: string; version: string; }[], executingWindow: WindowOrWorkerGlobalScope): void; /** * Update {@link StateImplementation.latestVersion} given a provided installed {@link LoadingGraph}. * It also exposes the latest version in `executingWindow` using original symbol name if need be. * * @param modules installed {@link LoadingGraph} * @param executingWindow where to expose the latest version if change need be * @hidden */ private static updateLatestBundleVersion; private static pinedDependencies; /** * return the (static) list of pined dependencies. */ static getPinedDependencies(): string[]; /** * Pin some dependencies to use whenever a loading graph is resolved, * it will over-ride natural resolution from packages description. * */ static pinDependencies(dependencies: LightLibraryQueryString[]): void; /** * * @hidden */ private static urlPatcher; /** * * @param name name of the asset * @param version version of the asset * @param assetId id of the asset * @param url original URL */ static getPatchedUrl({ name, version, assetId, url }: { name: any; version: any; assetId: any; url: any; }): string; /** * Register a 'patcher' for URLs to fetch resource: any time a request is done to the target resource, * the URL is actually replaced by the registered patch. * * This is provided if somehow a saved loading graph reference resources that have been moved to other location. */ static registerUrlPatcher(patcher: ({ name, version, assetId, url }: { name: any; version: any; assetId: any; url: any; }) => string): void; static view(): VirtualDOM; }