UNPKG

1.45 kBTypeScriptView Raw
1import { PackMeta, ResourcePack, Resource, ResourceLocation } from "@xmcl/resourcepack";
2interface ResourceSourceWrapper {
3 source: ResourcePack;
4 info: PackMeta.Pack;
5 domains: string[];
6}
7/**
8 * The resource manager. Design to be able to use in both nodejs and browser environment.
9 * @template T The type of the resource content. If you use this in node, it's probably `Buffer`. If you are in browser, it might be `string`. Just align this with your `ResourceSource`
10 */
11export declare class ResourceManager {
12 private list;
13 get allResourcePacks(): PackMeta.Pack[];
14 private cache;
15 constructor(list?: Array<ResourceSourceWrapper>);
16 /**
17 * Add a new resource source to the end of the resource list.
18 */
19 addResourcePack(resourcePack: ResourcePack): Promise<void>;
20 /**
21 * Clear all cache
22 */
23 clearCache(): void;
24 /**
25 * Clear all resource source and cache
26 */
27 clearAll(): void;
28 /**
29 * Swap the resource source priority.
30 */
31 swap(first: number, second: number): void;
32 /**
33 * Invalidate the resource cache
34 */
35 invalidate(location: ResourceLocation): void;
36 load(location: ResourceLocation): Promise<Resource | undefined>;
37 load(location: ResourceLocation, urlOnly: false): Promise<Resource | undefined>;
38 load(location: ResourceLocation, urlOnly: true): Promise<Resource | undefined>;
39 private putCache;
40}
41export * from "./model-loader";