UNPKG

@mlightcad/common

Version:

The common package provides shared utilities and base classes that are used across the RealDWG-Web ecosystem. This package contains fundamental components for color management, event handling, logging, performance monitoring, and file loading operations.

92 lines 3.89 kB
import { AcCmLoadingManager, AcCmOnErrorCallback } from './AcCmLoadingManager'; export type AcCmLoaderProgressCallback = (progress: ProgressEvent) => void; /** * Base class for implementing loaders. */ export declare abstract class AcCmLoader { manager: AcCmLoadingManager; /** * The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS. * Default is anonymous. */ crossOrigin: string; /** * Whether the XMLHttpRequest uses credentials. Default is false. */ withCredentials: boolean; /** * The base path from which the asset will be loaded. Default is the empty string. */ path: string; /** * The base path from which additional resources like textures will be loaded. * Default is the empty string. */ resourcePath: string; /** * The request header used in HTTP request. */ requestHeader: HeadersInit; /** * Creates a new AcCmLoader instance. * @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager. */ constructor(manager?: AcCmLoadingManager); /** * This method needs to be implement by all concrete loaders. It holds the logic for loading * the asset from the backend. * @param url The path or URL to the file. This can also be a Data URI. * @param onLoad (optional) — Will be called when loading completes. * @param onProgress (optional) — Will be called while load progresses. * @param onError (optional) — Will be called if an error occurs. */ abstract load(url: string, onLoad?: (data: unknown) => void, onProgress?: AcCmLoaderProgressCallback, onError?: AcCmOnErrorCallback): void; /** * This method is equivalent to 'load', but returns a Promise. * @param url A string containing the path/URL of the file to be loaded. * @param onProgress (optional) — A function to be called while the loading is in progress. * The argument will be the ProgressEvent instance, which contains .lengthComputable, .total * and .loaded. If the server does not set the Content-Length header; .total will be 0. * @returns Return a promise. */ loadAsync(url: string, onProgress: AcCmLoaderProgressCallback): Promise<unknown>; /** * This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset. */ parse(_data: unknown): void; /** * Set the crossOrigin string to implement CORS for loading the url from a different domain that allows * CORS. * @param crossOrigin The crossOrigin string * @returns Return this object */ setCrossOrigin(crossOrigin: string): this; /** * Set whether the XMLHttpRequest uses credentials such as cookies, authorization headers or TLS * client certificates. * Note that this has no effect if you are loading files locally or from the same domain. * @param value The flag whether the XMLHttpRequest uses credentials. * @returns Return this object */ setWithCredentials(value: boolean): this; /** * Set the base path for the asset. * @param path The base path for the asset. * @returns Return this object */ setPath(path: string): this; /** * Set the base path for dependent resources like textures. * @param resourcePath The base path for dependent resources like textures. * @returns Return this object */ setResourcePath(resourcePath: string): this; /** * Set the request header used in HTTP request. * @param requestHeader key: The name of the header whose value is to be set. value: The value * to set as the body of the header. * @returns Return this object */ setRequestHeader(requestHeader: HeadersInit): this; } //# sourceMappingURL=AcCmLoader.d.ts.map