91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
/**
|
|
* Type definitions for @metatrom/ior-resolver
|
|
*/
|
|
|
|
export interface IORResolverContext {
|
|
originModulePath: string;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export interface IORResolverResult {
|
|
type: 'sourceFile';
|
|
filePath: string;
|
|
}
|
|
|
|
export type IORResolver = (
|
|
context: IORResolverContext,
|
|
moduleName: string,
|
|
platform?: string
|
|
) => IORResolverResult | undefined;
|
|
|
|
export interface RemoteComponentConfig {
|
|
type: 'github' | 'gitea' | 'ipfs' | 'p2p';
|
|
owner?: string;
|
|
repository?: string;
|
|
componentName?: string;
|
|
version?: string;
|
|
branch?: string;
|
|
instance?: string;
|
|
hash?: string;
|
|
peerId?: string;
|
|
}
|
|
|
|
/**
|
|
* Create an IOR resolver for Metro bundler
|
|
* @param projectRoot - The root directory of the project
|
|
* @returns A resolver function for Metro
|
|
*/
|
|
export function createIORResolver(projectRoot: string): IORResolver;
|
|
|
|
/**
|
|
* Create a hot-reloadable IOR resolver for Metro bundler
|
|
* @param projectRoot - The root directory of the project
|
|
* @returns A resolver function for Metro with hot reload support
|
|
*/
|
|
export function createHotReloadableResolver(projectRoot: string): IORResolver;
|
|
|
|
/**
|
|
* Build mappings for local IOR components
|
|
* @param projectRoot - The root directory of the project
|
|
* @returns A Map of IOR to file path mappings
|
|
*/
|
|
export function buildIORMappings(projectRoot: string): Map<string, string>;
|
|
|
|
/**
|
|
* Build mappings for local IOR components
|
|
* @param projectRoot - The root directory of the project
|
|
* @returns A Map of IOR to file path mappings
|
|
*/
|
|
export function buildLocalIORMappings(projectRoot: string): Map<string, string>;
|
|
|
|
/**
|
|
* Fetch a remote component based on IOR
|
|
* @param ior - The IOR string to resolve
|
|
* @returns Promise resolving to the cached component path
|
|
*/
|
|
export function fetchRemoteComponent(ior: string): Promise<string>;
|
|
|
|
/**
|
|
* Parse a remote IOR string
|
|
* @param ior - The IOR string to parse
|
|
* @returns The parsed configuration or null if invalid
|
|
*/
|
|
export function parseRemoteIOR(ior: string): RemoteComponentConfig | null;
|
|
|
|
/**
|
|
* Clear the remote component cache
|
|
*/
|
|
export function clearRemoteCache(): void;
|
|
|
|
/**
|
|
* Metro resolver module
|
|
*/
|
|
export const metro: {
|
|
createIORResolver: typeof createIORResolver;
|
|
createHotReloadableResolver: typeof createHotReloadableResolver;
|
|
buildIORMappings: typeof buildIORMappings;
|
|
buildLocalIORMappings: typeof buildLocalIORMappings;
|
|
fetchRemoteComponent: typeof fetchRemoteComponent;
|
|
parseRemoteIOR: typeof parseRemoteIOR;
|
|
clearRemoteCache: typeof clearRemoteCache;
|
|
}; |