@scml/sc2-modloader 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +9 -0
  2. package/package.json +77 -0
  3. package/type-dist/AddonPlugin.d.ts +155 -0
  4. package/type-dist/DecoratorUtils.d.ts +36 -0
  5. package/type-dist/DependenceChecker.d.ts +46 -0
  6. package/type-dist/HtmlTagSrcHook.d.ts +43 -0
  7. package/type-dist/IdbKeyValRef.d.ts +26 -0
  8. package/type-dist/JSZipLikeReadOnlyInterface.d.ts +41 -0
  9. package/type-dist/JqueryInjector.d.ts +4 -0
  10. package/type-dist/JsPreloader.d.ts +28 -0
  11. package/type-dist/LanguageManager.d.ts +21 -0
  12. package/type-dist/MergeSC2DataInfoCache.d.ts +9 -0
  13. package/type-dist/ModLoadController.d.ts +122 -0
  14. package/type-dist/ModLoader.d.ts +210 -0
  15. package/type-dist/ModOrderContainer.d.ts +190 -0
  16. package/type-dist/ModPack/ModMeta.d.ts +25 -0
  17. package/type-dist/ModPack/ModPack.d.ts +46 -0
  18. package/type-dist/ModPack/ModPackFileReaderInterface.d.ts +22 -0
  19. package/type-dist/ModPack/ModPackJsZipAdaptor.d.ts +75 -0
  20. package/type-dist/ModZipReader.d.ts +179 -0
  21. package/type-dist/PassageTracer.d.ts +12 -0
  22. package/type-dist/ReplacePatcher.d.ts +33 -0
  23. package/type-dist/SC2ApiRef.d.ts +136 -0
  24. package/type-dist/SC2DataInfoCache.d.ts +67 -0
  25. package/type-dist/SC2DataManager.d.ts +86 -0
  26. package/type-dist/SC2JsEvalContext.d.ts +17 -0
  27. package/type-dist/Sc2EventTracer.d.ts +24 -0
  28. package/type-dist/SemVer/InfiniteSemVer.d.ts +32 -0
  29. package/type-dist/SimulateMerge.d.ts +17 -0
  30. package/type-dist/SugarCube2.d.ts +18 -0
  31. package/type-dist/Utils/LazyIteratorAdaptor.d.ts +14 -0
  32. package/type-dist/Utils.d.ts +172 -0
  33. package/type-dist/WeakRefPool/WeakRefPool.d.ts +11 -0
  34. package/type-dist/WikifyTracer.d.ts +85 -0
  35. package/type-dist/export2window.d.ts +6 -0
  36. package/type-dist/expose-loader.d.ts +2 -0
  37. package/type-dist/extname.d.ts +4 -0
  38. package/type-dist/getGlobal.d.ts +4 -0
  39. package/type-dist/global.d.ts +17 -0
  40. package/type-dist/global.ts +19 -0
  41. package/type-dist/init-comp-mock.d.ts +1 -0
  42. package/type-dist/init-comp.d.ts +1 -0
  43. package/type-dist/init.d.ts +1 -0
  44. package/type-dist/polyfill.d.ts +1 -0
@@ -0,0 +1,210 @@
1
+ import { SimulateMergeResult } from "./SimulateMerge.js";
2
+ import { JSZipLikeReadOnlyInterface } from "./JSZipLikeReadOnlyInterface.js";
3
+ import { IndexDBLoader, LazyLoader, LoaderKeyConfig, LocalLoader, LocalStorageLoader, ModZipReader, RemoteLoader } from "./ModZipReader.js";
4
+ import { ModLoadFromSourceType, ModOrderContainer, ModOrderContainer_OneAlias_ReadonlyMap, ModOrderContainer_One_ReadonlyMap, ModOrderItem } from "./ModOrderContainer.js";
5
+ import { SC2DataManager } from "./SC2DataManager.js";
6
+ import { LogWrapper, ModLoadControllerCallback } from "./ModLoadController.js";
7
+ import { SC2DataInfo } from "./SC2DataInfoCache.js";
8
+ import { ReplacePatcher } from "./ReplacePatcher.js";
9
+ import { LRUCache } from "lru-cache";
10
+
11
+ //#region remote/BeforeSC2/ModLoader.d.ts
12
+ interface IModImgGetter {
13
+ /**
14
+ * @return Promise<string> base64 img string
15
+ */
16
+ getBase64Image(): Promise<string | undefined>;
17
+ imgCache?: string;
18
+ invalid: boolean;
19
+ forceCache(): Promise<any>;
20
+ }
21
+ interface ImgLruCacheItemType {
22
+ imageBase64: string;
23
+ invalid: boolean;
24
+ }
25
+ declare const StaticModImgLruCache: LRUCache<string, ImgLruCacheItemType, unknown>;
26
+ interface IModImgGetterLRUCache {
27
+ get(path: string): ImgLruCacheItemType | undefined;
28
+ set(path: string, data: ImgLruCacheItemType): IModImgGetterLRUCache;
29
+ }
30
+ declare class ModImgGetterDefault implements IModImgGetter {
31
+ modName: string;
32
+ zip: ModZipReader;
33
+ imgPath: string;
34
+ logger: LogWrapper;
35
+ constructor(modName: string, zip: ModZipReader, imgPath: string, logger: LogWrapper);
36
+ invalid: boolean;
37
+ imgCache?: string;
38
+ forceCache(): Promise<void>;
39
+ getBase64Image(): Promise<string | undefined>;
40
+ }
41
+ interface ModImg {
42
+ getter: IModImgGetter;
43
+ path: string;
44
+ }
45
+ interface ModBootJsonAddonPlugin {
46
+ modName: string;
47
+ addonName: string;
48
+ modVersion: string;
49
+ params?: any[] | {
50
+ [key: string]: any;
51
+ };
52
+ }
53
+ declare function checkModBootJsonAddonPlugin(v: any): v is ModBootJsonAddonPlugin;
54
+ interface DependenceInfo {
55
+ modName: string;
56
+ version: string;
57
+ }
58
+ declare function checkDependenceInfo(v: any): v is DependenceInfo;
59
+ type ModNickName = ({ [key in string]?: string } & {
60
+ cn?: string;
61
+ en?: string;
62
+ }) | string | undefined;
63
+ interface ModBootJson {
64
+ name: string;
65
+ nickName?: ModNickName;
66
+ alias?: string[];
67
+ version: string;
68
+ styleFileList: string[];
69
+ scriptFileList: string[];
70
+ scriptFileList_preload?: string[];
71
+ scriptFileList_earlyload?: string[];
72
+ scriptFileList_inject_early?: string[];
73
+ tweeFileList: string[];
74
+ imgFileList: string[];
75
+ replacePatchList?: string[];
76
+ additionFile: string[];
77
+ additionBinaryFile?: string[];
78
+ addonPlugin?: ModBootJsonAddonPlugin[];
79
+ dependenceInfo?: DependenceInfo[];
80
+ }
81
+ interface ModInfo {
82
+ name: string;
83
+ nickName?: ModNickName;
84
+ alias: string[];
85
+ version: string;
86
+ cache: SC2DataInfo;
87
+ imgs: ModImg[];
88
+ /**
89
+ * origin path, replace path
90
+ *
91
+ * @deprecated the imgFileReplaceList not work and never implemented, don't use it.
92
+ * Please use `ImageLoaderAddon` or `BeautySelectorAddon` instead.
93
+ * @see `ImageLoaderAddon` https://github.com/Lyoko-Jeremie/DoL_ImgLoaderHooker
94
+ * @see `BeautySelectorAddon` https://github.com/Lyoko-Jeremie/DoL_BeautySelectorAddonMod
95
+ */
96
+ imgFileReplaceList: [string, string][];
97
+ /**
98
+ * file name, file content
99
+ */
100
+ scriptFileList_preload: [string, string][];
101
+ /**
102
+ * file name, file content
103
+ */
104
+ scriptFileList_earlyload: [string, string][];
105
+ /**
106
+ * file name, file content
107
+ */
108
+ scriptFileList_inject_early: [string, string][];
109
+ replacePatcher: ReplacePatcher[];
110
+ bootJson: ModBootJson;
111
+ modRef: {
112
+ [key: string]: any;
113
+ } | undefined;
114
+ }
115
+ declare enum ModDataLoadType {
116
+ 'Remote' = "Remote",
117
+ 'Local' = "Local",
118
+ 'LocalStorage' = "LocalStorage",
119
+ 'IndexDB' = "IndexDB"
120
+ }
121
+ declare class ModLoader {
122
+ gSC2DataManager: SC2DataManager;
123
+ modLoadControllerCallback: ModLoadControllerCallback;
124
+ thisWin: Window;
125
+ logger: LogWrapper;
126
+ constructor(gSC2DataManager: SC2DataManager, modLoadControllerCallback: ModLoadControllerCallback, thisWin: Window);
127
+ /**
128
+ * 已读取的mod列表(加载但没有初始化)
129
+ * The mod list that already read (load but not init)
130
+ */
131
+ private modReadCache;
132
+ /**
133
+ * 已加载的mod列表(加载并完成初始化)
134
+ * The mod list that already loaded (load and init)
135
+ */
136
+ private modCache;
137
+ /**
138
+ * 已加载的Lazy mod列表(使用 `lazyRegisterNewMod` 加载但未完成初始化)
139
+ * The Lazy mod list that already loaded (load use `lazyRegisterNewMod` but not init)
140
+ */
141
+ private modLazyCache;
142
+ modLoadRecord: ModOrderItem[];
143
+ /**
144
+ * O(2n)
145
+ */
146
+ getModCacheOneArray(): ModOrderItem[];
147
+ /**
148
+ O(n)
149
+ */
150
+ getModCacheArray(): ModOrderItem[];
151
+ getModAllName(): string[];
152
+ /**
153
+ O(1)
154
+ */
155
+ getModCacheMap(): ModOrderContainer_One_ReadonlyMap;
156
+ getModCacheMapWithAlias(): ModOrderContainer_OneAlias_ReadonlyMap;
157
+ /**
158
+ * O(n+2log(n))
159
+ */
160
+ checkModCacheData(): boolean;
161
+ /**
162
+ O(n)
163
+ */
164
+ checkModCacheUniq(): boolean;
165
+ /**
166
+ O(1)
167
+ */
168
+ getModCacheByNameOne(modName: string): ModOrderItem | undefined;
169
+ getModCacheByAliseOne(modName: string): ModOrderItem | undefined;
170
+ getModCacheByFromType(from: ModLoadFromSourceType): ModOrderItem[];
171
+ getModReadCache(): ModOrderContainer;
172
+ checkModConflictList(): {
173
+ mod: SC2DataInfo;
174
+ result: SimulateMergeResult;
175
+ }[];
176
+ private modLoaderKeyConfig?;
177
+ private modIndexDBLoader?;
178
+ private modLocalStorageLoader?;
179
+ private modLocalLoader?;
180
+ private modRemoteLoader?;
181
+ private modLazyLoader?;
182
+ getLoaderKeyConfig(): LoaderKeyConfig;
183
+ getIndexDBLoader(): IndexDBLoader;
184
+ getLocalStorageLoader(): LocalStorageLoader;
185
+ getLocalLoader(): LocalLoader;
186
+ getRemoteLoader(): RemoteLoader;
187
+ getLazyLoader(): LazyLoader;
188
+ loadOrder: ModDataLoadType[];
189
+ private addModReadZip;
190
+ loadMod(loadOrder: ModDataLoadType[]): Promise<boolean>;
191
+ private registerMod2Addon;
192
+ protected triggerAfterModLoad(): Promise<void>;
193
+ protected filterModCanLoad(modeC: ModOrderContainer): Promise<ModOrderContainer>;
194
+ lazyRegisterNewMod(modeZip: JSZipLikeReadOnlyInterface): Promise<boolean>;
195
+ private do_initModInjectEarlyLoadInDomScript;
196
+ private initModInjectEarlyLoadInDomScript;
197
+ private do_initModEarlyLoadScript;
198
+ private initModEarlyLoadScript;
199
+ getModEarlyLoadCache(): ModOrderContainer;
200
+ getModByNameOne(modName: string): ModOrderItem | undefined;
201
+ getModZip(modName: string): ModZipReader | undefined;
202
+ private loadEndModList?;
203
+ private toLoadModList?;
204
+ private nowLoadedMod?;
205
+ private newNowMod?;
206
+ private replacedNowMod?;
207
+ private tryInitWaitingLazyLoadMod;
208
+ }
209
+ //#endregion
210
+ export { DependenceInfo, IModImgGetter, IModImgGetterLRUCache, ImgLruCacheItemType, ModBootJson, ModBootJsonAddonPlugin, ModDataLoadType, ModImg, ModImgGetterDefault, ModInfo, ModLoader, ModNickName, StaticModImgLruCache, checkDependenceInfo, checkModBootJsonAddonPlugin };
@@ -0,0 +1,190 @@
1
+ import { ModZipReader } from "./ModZipReader.js";
2
+ import { ModInfo } from "./ModLoader.js";
3
+
4
+ //#region remote/BeforeSC2/ModOrderContainer.d.ts
5
+ declare enum ModLoadFromSourceType {
6
+ 'Remote' = "Remote",
7
+ 'Local' = "Local",
8
+ 'LocalStorage' = "LocalStorage",
9
+ 'IndexDB' = "IndexDB",
10
+ 'SideLazy' = "SideLazy"
11
+ }
12
+ declare function isModOrderItem(a: any): a is ModOrderItem;
13
+ interface ModOrderItem {
14
+ name: string;
15
+ from: ModLoadFromSourceType;
16
+ mod: ModInfo;
17
+ zip: ModZipReader;
18
+ }
19
+ declare abstract class CustomReadonlyMapHelper<K, V> implements ReadonlyMap<K, V> {
20
+ abstract get size(): number;
21
+ abstract get(key: K): V | undefined;
22
+ abstract has(key: K): boolean;
23
+ abstract entries(): IterableIterator<[K, V]>;
24
+ [Symbol.iterator](): IterableIterator<[K, V]>;
25
+ forEach(callback: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
26
+ keys(): IterableIterator<K>;
27
+ values(): IterableIterator<V>;
28
+ }
29
+ declare class ModOrderContainer_One_ReadonlyMap extends CustomReadonlyMapHelper<string, ModOrderItem> {
30
+ parent: ModOrderContainer;
31
+ constructor(parent: ModOrderContainer);
32
+ get size(): number;
33
+ entries(): IterableIterator<[string, ModOrderItem]>;
34
+ get(key: string): ModOrderItem | undefined;
35
+ has(key: string): boolean;
36
+ }
37
+ declare class ModOrderContainer_OneAlias_ReadonlyMap extends CustomReadonlyMapHelper<string, ModOrderItem> {
38
+ parent: ModOrderContainer;
39
+ constructor(parent: ModOrderContainer);
40
+ get size(): number;
41
+ entries(): IterableIterator<[string, ModOrderItem]>;
42
+ get(key: string): ModOrderItem | undefined;
43
+ has(key: string): boolean;
44
+ }
45
+ declare function isModOrderContainer(a: any): a is ModOrderContainer;
46
+ /**
47
+ * a multi-index container designed for mod load cache list. work like a C++ Boost.MultiIndexContainer
48
+ * can keep mod `order` , optional keep mod `unique` , remember mod load `from source`
49
+ */
50
+ declare class ModOrderContainer {
51
+ container: Map<string, Map<ModLoadFromSourceType, ModOrderItem>>;
52
+ order: ModOrderItem[];
53
+ nameRefWithAlias: Map<string, string>;
54
+ constructor();
55
+ /**
56
+ * O(1)
57
+ *
58
+ * add addition limit that keep mod name unique
59
+ */
60
+ get_One_Map(): ModOrderContainer_One_ReadonlyMap;
61
+ get_One_Map_WithAlias(): ModOrderContainer_OneAlias_ReadonlyMap;
62
+ /**
63
+ * O(2n)
64
+ *
65
+ * add addition limit that keep mod name unique
66
+ */
67
+ get_One_Array(): ModOrderItem[];
68
+ /**
69
+ * O(n)
70
+ */
71
+ get_Array(): ModOrderItem[];
72
+ /**
73
+ * O(n)
74
+ */
75
+ getAllName(): string[];
76
+ /**
77
+ * O(1)
78
+ */
79
+ getHasByName(name: string): boolean;
80
+ /**
81
+ * O(1)
82
+ */
83
+ getHasByNameWithAlias(name: string): boolean;
84
+ /**
85
+ * O(1)
86
+ */
87
+ getHasByNameFrom(name: string, from: ModLoadFromSourceType): boolean;
88
+ /**
89
+ * O(1)
90
+ */
91
+ getByName(name: string): Map<ModLoadFromSourceType, ModOrderItem> | undefined;
92
+ /**
93
+ * O(1)
94
+ */
95
+ getModOrderItemByNameWithAlias(name: string): Map<ModLoadFromSourceType, ModOrderItem> | undefined;
96
+ /**
97
+ * O(1)
98
+ */
99
+ getByNameOne(name: string, noError?: boolean): ModOrderItem | undefined;
100
+ /**
101
+ * O(1)
102
+ */
103
+ getByNameOneWithAlias(name: string, noError?: boolean): ModOrderItem | undefined;
104
+ /**
105
+ * O(n)
106
+ */
107
+ getByFromTypeByOrder(from: ModLoadFromSourceType): ModOrderItem[];
108
+ /**
109
+ * O(n)
110
+ */
111
+ getByOrder(name: string): ModOrderItem[];
112
+ /**
113
+ * O(n)
114
+ */
115
+ checkNameUniq(): boolean;
116
+ /**
117
+ * O(n)
118
+ */
119
+ checkAlias(): boolean;
120
+ /**
121
+ * O(n+2log(n))
122
+ */
123
+ checkData(): boolean;
124
+ /**
125
+ * O(n)
126
+ */
127
+ delete(name: string, from: ModLoadFromSourceType): boolean;
128
+ /**
129
+ * O(n)
130
+ */
131
+ deleteAll(name: string): boolean;
132
+ /**
133
+ * O(1)
134
+ */
135
+ createModOrderItem(zip: ModZipReader, from: ModLoadFromSourceType): ModOrderItem | undefined;
136
+ /**
137
+ * O(2n)
138
+ */
139
+ pushFront(zip: ModZipReader, from: ModLoadFromSourceType): boolean;
140
+ /**
141
+ * O(2n)
142
+ */
143
+ pushBack(zip: ModZipReader, from: ModLoadFromSourceType): boolean;
144
+ /**
145
+ * O(2n)
146
+ */
147
+ insertReplace(zip: ModZipReader, from: ModLoadFromSourceType): boolean;
148
+ /**
149
+ * O(n)
150
+ */
151
+ popOut(name: string, from: ModLoadFromSourceType): ModOrderItem | undefined;
152
+ /**
153
+ * O(n)
154
+ */
155
+ popOutAll(name: string): ModOrderItem[] | undefined;
156
+ /**
157
+ * O(1)
158
+ */
159
+ popFront(): ModOrderItem | undefined;
160
+ /**
161
+ * O(1)
162
+ */
163
+ clear(): void;
164
+ /**
165
+ * O(1)
166
+ */
167
+ get size(): number;
168
+ /**
169
+ * O(2n)
170
+ */
171
+ clone(): ModOrderContainer;
172
+ private rebuildNameRefWithAlias;
173
+ private addModNameRefWithAlias;
174
+ private removeModNameRefWithAlias;
175
+ /**
176
+ * O(n)
177
+ */
178
+ private rebuildContainerFromOrder;
179
+ /**
180
+ * O(2n)
181
+ */
182
+ splitCloneInArray(name: string, from: ModLoadFromSourceType): {
183
+ before: ModOrderContainer;
184
+ current: ModOrderItem;
185
+ after: ModOrderContainer;
186
+ } | undefined;
187
+ static mergeModOrderContainer(nnn: (ModOrderContainer | ModOrderItem)[]): ModOrderContainer;
188
+ }
189
+ //#endregion
190
+ export { ModLoadFromSourceType, ModOrderContainer, ModOrderContainer_OneAlias_ReadonlyMap, ModOrderContainer_One_ReadonlyMap, ModOrderItem, isModOrderContainer, isModOrderItem };
@@ -0,0 +1,25 @@
1
+ //#region remote/BeforeSC2/ModPack/ModMeta.d.ts
2
+ interface FileMeta {
3
+ b: number;
4
+ e: number;
5
+ l: number;
6
+ }
7
+ interface CryptoInfo {
8
+ Xchacha20NonceBase64: string;
9
+ PwhashSaltBase64: string;
10
+ }
11
+ declare const MagicNumber: Uint8Array<ArrayBuffer>;
12
+ declare const ModMetaProtocolVersion = 1;
13
+ declare const BlockSize = 64;
14
+ interface ModMeta {
15
+ magicNumber: string;
16
+ name: string;
17
+ protocolVersion: number;
18
+ blockSize: number;
19
+ cryptoInfo?: CryptoInfo;
20
+ fileTreeBlock: FileMeta;
21
+ bootJsonFile: FileMeta;
22
+ fileMeta: Record<string, FileMeta>;
23
+ }
24
+ //#endregion
25
+ export { BlockSize, CryptoInfo, FileMeta, MagicNumber, ModMeta, ModMetaProtocolVersion };
@@ -0,0 +1,46 @@
1
+ import { FileMeta, ModMeta } from "./ModMeta.js";
2
+ import { ModPackFileReaderInterface } from "./ModPackFileReaderInterface.js";
3
+ import xxhash from "xxhash-wasm";
4
+
5
+ //#region remote/BeforeSC2/ModPack/ModPack.d.ts
6
+ declare function XxHashH64Bigint2String(h64: bigint): string;
7
+ declare function XxHashH32Number2String(h32: bigint): string;
8
+ declare function calcXxHash64(data: Uint8Array, xxhashApi: Awaited<ReturnType<typeof xxhash>>): bigint;
9
+ declare function covertFromZipMod(modName: string, filePathList: string[], fileReaderFunc: (filePath: string) => Promise<Uint8Array | undefined>, password?: string | undefined, progressCallback?: (progress: number) => any | Promise<any>, bootFilePath?: string): Promise<{
10
+ modMeta: ModMeta;
11
+ modPackBuffer: Uint8Array<ArrayBuffer>;
12
+ ext: string;
13
+ hash: bigint;
14
+ hashString: string;
15
+ }>;
16
+ declare class ModPackFileReader implements ModPackFileReaderInterface {
17
+ constructor();
18
+ get isInit(): boolean;
19
+ private password?;
20
+ private modMeta;
21
+ private fileDataStartPos;
22
+ private xchacha20Key?;
23
+ private xchacha20Nonce?;
24
+ private modPackBuffer;
25
+ private fileTree?;
26
+ static xxhashApi?: Awaited<ReturnType<typeof xxhash>>;
27
+ private xxHashValue?;
28
+ protected _progressCallback?: (progress: number) => any | Promise<any>;
29
+ set progressCallback(callback: (progress: number) => any | Promise<any>);
30
+ get modPackBufferSize(): number;
31
+ get modMetaInfo(): ModMeta;
32
+ get hash(): bigint;
33
+ get hashString(): string;
34
+ checkHash(modPackBuffer: Uint8Array): Promise<boolean>;
35
+ load(modPackBuffer: Uint8Array, password?: string): Promise<ModMeta>;
36
+ getFileList(): string[];
37
+ protected getFileByMeta(fileMeta: FileMeta, filePath: string): Promise<Uint8Array | undefined>;
38
+ getFile(filePath: string): Promise<Uint8Array | undefined>;
39
+ readFile(filePath: string): Promise<Uint8Array | undefined>;
40
+ getBootJson(): Promise<Uint8Array | undefined>;
41
+ getFileTree(): Promise<Record<string, any> | undefined>;
42
+ get fileTreeRef(): Record<string, any> | undefined;
43
+ checkValid(): Promise<boolean>;
44
+ }
45
+ //#endregion
46
+ export { ModPackFileReader, XxHashH32Number2String, XxHashH64Bigint2String, calcXxHash64, covertFromZipMod };
@@ -0,0 +1,22 @@
1
+ import { ModMeta } from "./ModMeta.js";
2
+
3
+ //#region remote/BeforeSC2/ModPack/ModPackFileReaderInterface.d.ts
4
+ interface ModPackFileReaderInterface {
5
+ isInit: boolean;
6
+ modPackBufferSize: number;
7
+ modMetaInfo: ModMeta;
8
+ hash: bigint;
9
+ hashString: string;
10
+ fileTreeRef: Record<string, any> | undefined;
11
+ progressCallback?: (progress: number) => any | Promise<any>;
12
+ load(modPackBuffer: Uint8Array, password?: string): Promise<ModMeta>;
13
+ checkHash(modPackBuffer: Uint8Array): Promise<boolean>;
14
+ getFileTree(): Record<string, any> | undefined;
15
+ getFileList(): string[];
16
+ getFile(filePath: string): Promise<Uint8Array | undefined>;
17
+ readFile(filePath: string): Promise<Uint8Array | undefined>;
18
+ getBootJson(): Promise<Uint8Array | undefined>;
19
+ checkValid(): Promise<boolean>;
20
+ }
21
+ //#endregion
22
+ export { ModPackFileReaderInterface };
@@ -0,0 +1,75 @@
1
+ import { ModPackFileReader } from "./ModPack.js";
2
+
3
+ //#region remote/BeforeSC2/ModPack/ModPackJsZipAdaptor.d.ts
4
+ interface OutputByType {
5
+ base64: string;
6
+ string: string;
7
+ text: string;
8
+ binarystring: string;
9
+ array: number[];
10
+ uint8array: Uint8Array;
11
+ arraybuffer: ArrayBuffer;
12
+ blob: Blob;
13
+ }
14
+ interface InputByType {
15
+ base64: string;
16
+ string: string;
17
+ text: string;
18
+ binarystring: string;
19
+ array: number[];
20
+ uint8array: Uint8Array;
21
+ arraybuffer: ArrayBuffer;
22
+ blob: Blob;
23
+ }
24
+ type InputFileFormat = InputByType[keyof InputByType] | Promise<InputByType[keyof InputByType]>;
25
+ interface JSZipSupport {
26
+ arraybuffer: boolean;
27
+ uint8array: boolean;
28
+ blob: boolean;
29
+ nodebuffer: boolean;
30
+ }
31
+ type Compression = 'STORE' | 'DEFLATE';
32
+ interface JSZipObjectOptions {
33
+ compression: Compression;
34
+ }
35
+ declare class ModPackJsZipObjectAdaptor {
36
+ protected readonly ref: ModPackFileReader;
37
+ protected readonly parent: ModPackJsZipObjectAdaptor | undefined;
38
+ protected myPathInFileTree: string[];
39
+ protected treeLevelRef: Record<string, any>;
40
+ protected _isFile: boolean;
41
+ protected _isFolder: boolean;
42
+ protected _isValid: boolean;
43
+ constructor(filePath: string, ref: ModPackFileReader, parent: ModPackJsZipObjectAdaptor | undefined);
44
+ get dir(): boolean;
45
+ get name(): string;
46
+ get path(): string;
47
+ async<T extends keyof OutputByType>(type: T, onUpdate_Useless?: any): Promise<OutputByType[T]>;
48
+ protected _files?: Record<string, ModPackJsZipObjectAdaptor>;
49
+ get files(): Record<string, ModPackJsZipObjectAdaptor>;
50
+ get isFile(): boolean;
51
+ get isFolder(): boolean;
52
+ get isValid(): boolean;
53
+ get options(): JSZipObjectOptions;
54
+ }
55
+ declare class ModPackFileReaderJsZipAdaptor extends ModPackFileReader {
56
+ get is_JeremieModLoader_ModPack(): boolean;
57
+ protected _files?: Record<string, ModPackJsZipObjectAdaptor>;
58
+ protected _isPrepared: boolean;
59
+ protected zipAdaptorPassword?: string;
60
+ prepareSetPassword(password: string | undefined): void;
61
+ prepareForZipAdaptor(): Promise<void>;
62
+ get files(): Record<string, ModPackJsZipObjectAdaptor>;
63
+ file(path: string): ModPackJsZipObjectAdaptor | null;
64
+ file(path: RegExp): ModPackJsZipObjectAdaptor[] | null;
65
+ forEach(callback: (relativePath: string, file: ModPackJsZipObjectAdaptor) => void): void;
66
+ filter(predicate: (relativePath: string, file: ModPackJsZipObjectAdaptor) => boolean): ModPackJsZipObjectAdaptor[];
67
+ get support(): JSZipSupport;
68
+ static checkByHash(modPackBuffer: Uint8Array): Promise<boolean>;
69
+ loadAsync(data: InputFileFormat, options?: any & {
70
+ password?: string;
71
+ base64?: boolean;
72
+ }): Promise<ModPackFileReaderJsZipAdaptor | undefined>;
73
+ }
74
+ //#endregion
75
+ export { ModPackFileReaderJsZipAdaptor, ModPackJsZipObjectAdaptor };