import { ProtectedEventEmitter } from './utils/ProtectedEventEmitter'; import { Debugger } from './utils/Debugger'; import type { CrossOrigin } from './Def'; export declare enum ResourceType { JS = "JS", CSS = "CSS" } export declare enum ResourceState { NOT_LOADED = "NOT_LOADED", LOADING = "LOADING", UNLOADING = "UNLOADING", LOADED = "LOADED", LOAD_ERROR = "LOAD_ERROR" } export interface ResourceEvent { statechange: { state: ResourceState; }; refcountchange: { refCount: number; }; } export declare abstract class Resource extends Debugger implements ProtectedEventEmitter { #private; off(event: T, listener: (ev: ResourceEvent[T]) => unknown, context?: unknown): this; on(event: T, listener: (ev: ResourceEvent[T]) => unknown, context?: unknown): this; once(event: T, listener: (ev: ResourceEvent[T]) => unknown, context?: unknown): this; protected constructor(src: string, type: ResourceType, crossOrigin?: CrossOrigin); abstract get [Symbol.toStringTag](): string; protected get debugName(): string; toString(): string; protected get crossOrigin(): CrossOrigin; /** * Create a new resource by src and optional type. * @param src Source url of the resource. * @param type Type of resource, only CSS and JS are supported. * @returns Resource */ static create(src: string, type?: ResourceType, crossOrigin?: CrossOrigin): Resource; get src(): string; get refCount(): number; get state(): ResourceState; get type(): ResourceType; ref(obj: unknown): Promise; deref(obj: unknown): Promise; abstract get element(): HTMLScriptElement | HTMLLinkElement | null; protected load(): Promise; protected unload(): Promise; protected abstract fetchInBrowser(): Promise; protected abstract promiseUnload(): Promise; }