@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.
- package/README.md +9 -0
- package/package.json +77 -0
- package/type-dist/AddonPlugin.d.ts +155 -0
- package/type-dist/DecoratorUtils.d.ts +36 -0
- package/type-dist/DependenceChecker.d.ts +46 -0
- package/type-dist/HtmlTagSrcHook.d.ts +43 -0
- package/type-dist/IdbKeyValRef.d.ts +26 -0
- package/type-dist/JSZipLikeReadOnlyInterface.d.ts +41 -0
- package/type-dist/JqueryInjector.d.ts +4 -0
- package/type-dist/JsPreloader.d.ts +28 -0
- package/type-dist/LanguageManager.d.ts +21 -0
- package/type-dist/MergeSC2DataInfoCache.d.ts +9 -0
- package/type-dist/ModLoadController.d.ts +122 -0
- package/type-dist/ModLoader.d.ts +210 -0
- package/type-dist/ModOrderContainer.d.ts +190 -0
- package/type-dist/ModPack/ModMeta.d.ts +25 -0
- package/type-dist/ModPack/ModPack.d.ts +46 -0
- package/type-dist/ModPack/ModPackFileReaderInterface.d.ts +22 -0
- package/type-dist/ModPack/ModPackJsZipAdaptor.d.ts +75 -0
- package/type-dist/ModZipReader.d.ts +179 -0
- package/type-dist/PassageTracer.d.ts +12 -0
- package/type-dist/ReplacePatcher.d.ts +33 -0
- package/type-dist/SC2ApiRef.d.ts +136 -0
- package/type-dist/SC2DataInfoCache.d.ts +67 -0
- package/type-dist/SC2DataManager.d.ts +86 -0
- package/type-dist/SC2JsEvalContext.d.ts +17 -0
- package/type-dist/Sc2EventTracer.d.ts +24 -0
- package/type-dist/SemVer/InfiniteSemVer.d.ts +32 -0
- package/type-dist/SimulateMerge.d.ts +17 -0
- package/type-dist/SugarCube2.d.ts +18 -0
- package/type-dist/Utils/LazyIteratorAdaptor.d.ts +14 -0
- package/type-dist/Utils.d.ts +172 -0
- package/type-dist/WeakRefPool/WeakRefPool.d.ts +11 -0
- package/type-dist/WikifyTracer.d.ts +85 -0
- package/type-dist/export2window.d.ts +6 -0
- package/type-dist/expose-loader.d.ts +2 -0
- package/type-dist/extname.d.ts +4 -0
- package/type-dist/getGlobal.d.ts +4 -0
- package/type-dist/global.d.ts +17 -0
- package/type-dist/global.ts +19 -0
- package/type-dist/init-comp-mock.d.ts +1 -0
- package/type-dist/init-comp.d.ts +1 -0
- package/type-dist/init.d.ts +1 -0
- package/type-dist/polyfill.d.ts +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scml/sc2-modloader",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "SugarCube 2 Mod Loader Workspace",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Rikka",
|
|
9
|
+
"email": "admin@rikka.cc",
|
|
10
|
+
"url": "https://github.com/Muromi-Rikka"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"type-dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"types": "./type-dist/global.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./AddonPlugin": "./type-dist/AddonPlugin.d.ts",
|
|
20
|
+
"./DecoratorUtils": "./type-dist/DecoratorUtils.d.ts",
|
|
21
|
+
"./DependenceChecker": "./type-dist/DependenceChecker.d.ts",
|
|
22
|
+
"./export2window": "./type-dist/export2window.d.ts",
|
|
23
|
+
"./expose-loader": "./type-dist/expose-loader.d.ts",
|
|
24
|
+
"./extname": "./type-dist/extname.d.ts",
|
|
25
|
+
"./getGlobal": "./type-dist/getGlobal.d.ts",
|
|
26
|
+
"./HtmlTagSrcHook": "./type-dist/HtmlTagSrcHook.d.ts",
|
|
27
|
+
"./IdbKeyValRef": "./type-dist/IdbKeyValRef.d.ts",
|
|
28
|
+
"./JqueryInjector": "./type-dist/JqueryInjector.d.ts",
|
|
29
|
+
"./JsPreloader": "./type-dist/JsPreloader.d.ts",
|
|
30
|
+
"./JSZipLikeReadOnlyInterface": "./type-dist/JSZipLikeReadOnlyInterface.d.ts",
|
|
31
|
+
"./LanguageManager": "./type-dist/LanguageManager.d.ts",
|
|
32
|
+
"./MergeSC2DataInfoCache": "./type-dist/MergeSC2DataInfoCache.d.ts",
|
|
33
|
+
"./ModLoadController": "./type-dist/ModLoadController.d.ts",
|
|
34
|
+
"./ModLoader": "./type-dist/ModLoader.d.ts",
|
|
35
|
+
"./ModOrderContainer": "./type-dist/ModOrderContainer.d.ts",
|
|
36
|
+
"./ModZipReader": "./type-dist/ModZipReader.d.ts",
|
|
37
|
+
"./PassageTracer": "./type-dist/PassageTracer.d.ts",
|
|
38
|
+
"./polyfill": "./type-dist/polyfill.d.ts",
|
|
39
|
+
"./ReplacePatcher": "./type-dist/ReplacePatcher.d.ts",
|
|
40
|
+
"./SC2ApiRef": "./type-dist/SC2ApiRef.d.ts",
|
|
41
|
+
"./SC2DataInfoCache": "./type-dist/SC2DataInfoCache.d.ts",
|
|
42
|
+
"./SC2DataManager": "./type-dist/SC2DataManager.d.ts",
|
|
43
|
+
"./Sc2EventTracer": "./type-dist/Sc2EventTracer.d.ts",
|
|
44
|
+
"./SC2JsEvalContext": "./type-dist/SC2JsEvalContext.d.ts",
|
|
45
|
+
"./SimulateMerge": "./type-dist/SimulateMerge.d.ts",
|
|
46
|
+
"./SugarCube2": "./type-dist/SugarCube2.d.ts",
|
|
47
|
+
"./Utils": "./type-dist/Utils.d.ts",
|
|
48
|
+
"./WikifyTracer": "./type-dist/WikifyTracer.d.ts",
|
|
49
|
+
"./ModPack/ModMeta": "./type-dist/ModPack/ModMeta.d.ts",
|
|
50
|
+
"./ModPack/ModPack": "./type-dist/ModPack/ModPack.d.ts",
|
|
51
|
+
"./ModPack/ModPackFileReaderInterface": "./type-dist/ModPack/ModPackFileReaderInterface.d.ts",
|
|
52
|
+
"./ModPack/ModPackJsZipAdaptor": "./type-dist/ModPack/ModPackJsZipAdaptor.d.ts",
|
|
53
|
+
"./SemVer/InfiniteSemVer": "./type-dist/SemVer/InfiniteSemVer.d.ts",
|
|
54
|
+
"./Utils/LazyIteratorAdaptor.d.ts": "./type-dist/Utils/LazyIteratorAdaptor.d.ts",
|
|
55
|
+
"./WeakRefPool/WeakRefPool.d.ts": "./type-dist/WeakRefPool/WeakRefPool.d.ts"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/jquery": "^3.5.20",
|
|
59
|
+
"@types/libsodium-wrappers": "^0.7.11",
|
|
60
|
+
"@types/lodash": "^4.14.198",
|
|
61
|
+
"bson": "^6.10.4",
|
|
62
|
+
"idb": "^8.0.0",
|
|
63
|
+
"idb-keyval": "^6.2.1",
|
|
64
|
+
"json5": "^2.2.3",
|
|
65
|
+
"jszip": "^3.10.1",
|
|
66
|
+
"libsodium-wrappers-sumo": "^0.7.15",
|
|
67
|
+
"lru-cache": "^10.0.1",
|
|
68
|
+
"moment": "^2.29.4",
|
|
69
|
+
"uint8-to-base64": "^0.2.1",
|
|
70
|
+
"xxhash-wasm": "^1.1.0"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"download": "tsx src/download.ts",
|
|
74
|
+
"build": "tsdown && tsx src/after-build.ts",
|
|
75
|
+
"typecheck": "tsc --noEmit"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Passage } from "./SugarCube2.js";
|
|
2
|
+
import { ModZipReader } from "./ModZipReader.js";
|
|
3
|
+
import { Sc2EventTracerCallback } from "./Sc2EventTracer.js";
|
|
4
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
5
|
+
import { ModLoadController } from "./ModLoadController.js";
|
|
6
|
+
import { ModInfo } from "./ModLoader.js";
|
|
7
|
+
import JSZip from "jszip";
|
|
8
|
+
|
|
9
|
+
//#region remote/BeforeSC2/AddonPlugin.d.ts
|
|
10
|
+
type AddonPluginHookType = () => Promise<any>;
|
|
11
|
+
interface AddonPluginHookPoint {
|
|
12
|
+
afterInit?: AddonPluginHookType;
|
|
13
|
+
afterInjectEarlyLoad?: AddonPluginHookType;
|
|
14
|
+
afterModLoad?: AddonPluginHookType;
|
|
15
|
+
afterEarlyLoad?: AddonPluginHookType;
|
|
16
|
+
afterRegisterMod2Addon?: AddonPluginHookType;
|
|
17
|
+
beforePatchModToGame?: AddonPluginHookType;
|
|
18
|
+
afterPatchModToGame?: AddonPluginHookType;
|
|
19
|
+
afterPreload?: AddonPluginHookType;
|
|
20
|
+
}
|
|
21
|
+
type AddonPluginHookPoint_K = keyof AddonPluginHookPoint;
|
|
22
|
+
type AddonPluginHookPointWhenSC2 = {
|
|
23
|
+
whenSC2StoryReady?: () => Promise<any>;
|
|
24
|
+
whenSC2PassageInit?: (passage: Passage) => Promise<any>;
|
|
25
|
+
whenSC2PassageStart?: (passage: Passage, content: HTMLDivElement) => Promise<any>;
|
|
26
|
+
whenSC2PassageRender?: (passage: Passage, content: HTMLDivElement) => Promise<any>;
|
|
27
|
+
whenSC2PassageDisplay?: (passage: Passage, content: HTMLDivElement) => Promise<any>;
|
|
28
|
+
whenSC2PassageEnd?: (passage: Passage, content: HTMLDivElement) => Promise<any>;
|
|
29
|
+
};
|
|
30
|
+
type AddonPluginHookPointWhenSC2_T = AddonPluginHookPointWhenSC2;
|
|
31
|
+
type AddonPluginHookPointWhenSC2_K = keyof AddonPluginHookPointWhenSC2_T;
|
|
32
|
+
type AddonPluginHookPointExOptional = {
|
|
33
|
+
/**
|
|
34
|
+
* registerMod() will be called when export debug data, this is a chance to export addon data for debug, like when addon change data in memory
|
|
35
|
+
*
|
|
36
|
+
* registerMod() 会在导出 debug data 时被调用,这是导出 addon 数据的机会,比如当 addon 在内存中改变了数据。
|
|
37
|
+
* 举个例子,衣服扩展框架可以收集所有衣服mod的数据,统一在文件或内存中修改衣服数据,如果是在文件中修改那么会被默认导出,但如果是在内存中修改,则最好使用这个 hook 来导出数据以便 debug
|
|
38
|
+
*
|
|
39
|
+
* @optional
|
|
40
|
+
* @param zip the zip file to storage debug data
|
|
41
|
+
* @return return the same zip file or a new zip file, recommend return the same zip file
|
|
42
|
+
*/
|
|
43
|
+
exportDataZip?: (zip: JSZip) => Promise<JSZip>;
|
|
44
|
+
};
|
|
45
|
+
type AddonPluginHookPointExMustImplement = {
|
|
46
|
+
/**
|
|
47
|
+
* registerMod() will be called when mod loaded and that mod require this addon, addon can read info from mod and do something
|
|
48
|
+
*
|
|
49
|
+
* registerMod() 会在 mod 加载完毕并且 mod 需要这个 addon 时被调用,addon 可以从 mod 读取信息并做一些事情。
|
|
50
|
+
* 举个例子,衣服扩展框架可以在这里读取衣服mod的数据,然后统一修改衣服数据,这样就可以避免多个不同的衣服mod前后修改衣服数组导致意外损坏衣服数组的数据。
|
|
51
|
+
* @mustImplement
|
|
52
|
+
* @param addonName the mod require this addon
|
|
53
|
+
* @param mod the mod info
|
|
54
|
+
* @param modZip the mod zip file reader
|
|
55
|
+
*/
|
|
56
|
+
registerMod: (addonName: string, mod: ModInfo, modZip: ModZipReader) => Promise<any>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* AddonPluginHookPointEx is a interface for addon plugin to implement API Hook,
|
|
60
|
+
* addon plugin can implement any hook, but must implement registerMod(),
|
|
61
|
+
* addon can impl more API in there, to let mod call it to get more function.
|
|
62
|
+
*
|
|
63
|
+
* AddonPluginHookPointEx 是 addon plugin 用来实现 API Hook 的接口,
|
|
64
|
+
* addon plugin 可以实现任何 hook,但是必须实现 registerMod(),
|
|
65
|
+
* addon 可以在里面实现更多 API,让 mod 调用它来获得更多功能。
|
|
66
|
+
*/
|
|
67
|
+
interface AddonPluginHookPointEx extends AddonPluginHookPoint, AddonPluginHookPointExOptional, AddonPluginHookPointExMustImplement, AddonPluginHookPointWhenSC2 {}
|
|
68
|
+
declare class AddonPlugin {
|
|
69
|
+
modName: string;
|
|
70
|
+
addonName: string;
|
|
71
|
+
hookPoint: AddonPluginHookPointEx;
|
|
72
|
+
constructor(modName: string, addonName: string, hookPoint: AddonPluginHookPointEx);
|
|
73
|
+
}
|
|
74
|
+
declare class AddonPluginManager implements Sc2EventTracerCallback {
|
|
75
|
+
gSC2DataManager: SC2DataManager;
|
|
76
|
+
gModLoadController: ModLoadController;
|
|
77
|
+
private addonPluginTable;
|
|
78
|
+
private log;
|
|
79
|
+
private passageTracer;
|
|
80
|
+
private sc2EventTracer;
|
|
81
|
+
constructor(gSC2DataManager: SC2DataManager, gModLoadController: ModLoadController);
|
|
82
|
+
/**
|
|
83
|
+
* inner use
|
|
84
|
+
*/
|
|
85
|
+
whenSC2StoryReady(): Promise<any>;
|
|
86
|
+
/**
|
|
87
|
+
* inner use
|
|
88
|
+
*/
|
|
89
|
+
whenSC2PassageInit(passage: Passage): Promise<any>;
|
|
90
|
+
/**
|
|
91
|
+
* inner use
|
|
92
|
+
*/
|
|
93
|
+
whenSC2PassageStart(passage: Passage, content: HTMLDivElement): Promise<any>;
|
|
94
|
+
/**
|
|
95
|
+
* inner use
|
|
96
|
+
*/
|
|
97
|
+
whenSC2PassageRender(passage: Passage, content: HTMLDivElement): Promise<any>;
|
|
98
|
+
/**
|
|
99
|
+
* inner use
|
|
100
|
+
*/
|
|
101
|
+
whenSC2PassageDisplay(passage: Passage, content: HTMLDivElement): Promise<any>;
|
|
102
|
+
/**
|
|
103
|
+
* inner use
|
|
104
|
+
*/
|
|
105
|
+
whenSC2PassageEnd(passage: Passage, content: HTMLDivElement): Promise<any>;
|
|
106
|
+
/**
|
|
107
|
+
* call by ModLoader (inner use)
|
|
108
|
+
*
|
|
109
|
+
* register a mod to addon plugin, after all mod loaded and after EarlyLoad executed.
|
|
110
|
+
*
|
|
111
|
+
* @param mod
|
|
112
|
+
* @param modZip
|
|
113
|
+
*/
|
|
114
|
+
registerMod2Addon(mod: ModInfo, modZip: ModZipReader): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* call by ModLoaderGui (inner use)
|
|
117
|
+
* @param zip
|
|
118
|
+
*/
|
|
119
|
+
exportDataZip(zip: JSZip): Promise<JSZip>;
|
|
120
|
+
/**
|
|
121
|
+
* call by ModLoader (inner use)
|
|
122
|
+
* @param hook
|
|
123
|
+
*/
|
|
124
|
+
triggerHook(hook: AddonPluginHookPoint_K): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* call by ModLoader (inner use)
|
|
127
|
+
*/
|
|
128
|
+
triggerHookWhenSC2<K extends AddonPluginHookPointWhenSC2_K>(hook: K, ...params: Parameters<NonNullable<AddonPluginHookPointWhenSC2_T[K]>>): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* check if a addon plugin is duplicate
|
|
131
|
+
* @param modName
|
|
132
|
+
* @param addonName
|
|
133
|
+
*/
|
|
134
|
+
checkDuplicate(modName: string, addonName: string): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* register a addon plugin, call by addon plugin,
|
|
137
|
+
* this call must be done when InjectEarlyLoad.
|
|
138
|
+
*
|
|
139
|
+
* 注册一个 addon plugin,由 addon plugin 调用,必须在 InjectEarlyLoad 时调用此函数注册 Addon。
|
|
140
|
+
* @param modName addon plugin's mod name
|
|
141
|
+
* @param addonName addon plugin's name
|
|
142
|
+
* @param hookPoint addon plugin's hook point
|
|
143
|
+
*/
|
|
144
|
+
registerAddonPlugin(modName: string, addonName: string, hookPoint: AddonPluginHookPointEx): void;
|
|
145
|
+
/**
|
|
146
|
+
* get a addon plugin, call by mod
|
|
147
|
+
*
|
|
148
|
+
* 获取一个 addon plugin,由 mod 调用。 mod 可以读取 addon plugin 的 hookPoint 来调用 addon plugin 的 API
|
|
149
|
+
* @param modName addon plugin's mod name
|
|
150
|
+
* @param addonName addon plugin's name
|
|
151
|
+
*/
|
|
152
|
+
getAddonPlugin(modName: string, addonName: string): AddonPluginHookPointEx | undefined;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { AddonPlugin, AddonPluginHookPoint, AddonPluginHookPointEx, AddonPluginHookPointExMustImplement, AddonPluginHookPointExOptional, AddonPluginHookPointWhenSC2, AddonPluginHookPointWhenSC2_K, AddonPluginHookPointWhenSC2_T, AddonPluginHookPoint_K, AddonPluginManager };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region remote/BeforeSC2/DecoratorUtils.d.ts
|
|
2
|
+
declare function sealed<Class extends abstract new (...args: any) => any>(target: Class, context: ClassDecoratorContext<Class>): void;
|
|
3
|
+
declare namespace ClassDecoratorUtil {
|
|
4
|
+
interface InfoTypeItemConfig {
|
|
5
|
+
writable: false;
|
|
6
|
+
configurable: false;
|
|
7
|
+
enumerable: true;
|
|
8
|
+
}
|
|
9
|
+
interface InfoTypeItem {
|
|
10
|
+
info: ClassMemberDecoratorContext;
|
|
11
|
+
config: InfoTypeItemConfig;
|
|
12
|
+
}
|
|
13
|
+
interface ClassInfo {
|
|
14
|
+
seal?: boolean;
|
|
15
|
+
}
|
|
16
|
+
type InfoType = Map<string | symbol, InfoTypeItem>;
|
|
17
|
+
class InfoData {
|
|
18
|
+
configInfo: InfoType;
|
|
19
|
+
classInfo: ClassInfo;
|
|
20
|
+
}
|
|
21
|
+
type ThisClassType = {
|
|
22
|
+
[key: (string | symbol)]: any;
|
|
23
|
+
"ClassDecoratorUtil_InfoData": InfoData;
|
|
24
|
+
};
|
|
25
|
+
function finishClassDecorate(config: ClassInfo): <Class extends abstract new (...args: any) => any>(target: Class, context: ClassDecoratorContext<Class>) => Class;
|
|
26
|
+
function configField(config: InfoTypeItemConfig): <ThisClass extends ThisClassType>(value: undefined, context: ClassFieldDecoratorContext<ThisClass>) => <VType>(this: ThisClass, initialValue: VType) => VType;
|
|
27
|
+
function configMethod(config: InfoTypeItemConfig): <ThisClass extends ThisClassType, F extends (this: ThisClass, ...args: any) => any>(value: F, context: ClassMethodDecoratorContext<ThisClass, F>) => <VType>(this: ThisClass, initialValue: VType) => VType;
|
|
28
|
+
}
|
|
29
|
+
declare function sealedField<This>(value: undefined, context: ClassFieldDecoratorContext<This>): <VType>(this: This, initialValue: VType) => void;
|
|
30
|
+
declare function sealedField2<VType>(initialValue: VType): <This>(value: undefined, context: ClassFieldDecoratorContext<This>) => (this: This) => void;
|
|
31
|
+
declare function sealedMethod(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
32
|
+
declare function enumerable(value: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
33
|
+
declare function configurable(value: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
34
|
+
declare function loggedMethod<This, Args extends any[], Return>(target: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>): (this: This, ...args: Args) => Return;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ClassDecoratorUtil, configurable, enumerable, loggedMethod, sealed, sealedField, sealedField2, sealedMethod };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isWithinRange, parseInfiniteSemVer, parseVersionRange } from "./SemVer/InfiniteSemVer.js";
|
|
2
|
+
import { ModOrderContainer } from "./ModOrderContainer.js";
|
|
3
|
+
import { ModUtils } from "./Utils.js";
|
|
4
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
5
|
+
import { LogWrapper } from "./ModLoadController.js";
|
|
6
|
+
import { ModInfo } from "./ModLoader.js";
|
|
7
|
+
|
|
8
|
+
//#region remote/BeforeSC2/DependenceChecker.d.ts
|
|
9
|
+
declare class InfiniteSemVerApi {
|
|
10
|
+
parseRange: typeof parseVersionRange;
|
|
11
|
+
parseVersion: typeof parseInfiniteSemVer;
|
|
12
|
+
satisfies: typeof isWithinRange;
|
|
13
|
+
}
|
|
14
|
+
declare class DependenceChecker {
|
|
15
|
+
gSC2DataManager: SC2DataManager;
|
|
16
|
+
gModUtils: ModUtils;
|
|
17
|
+
log: LogWrapper;
|
|
18
|
+
constructor(gSC2DataManager: SC2DataManager, gModUtils: ModUtils);
|
|
19
|
+
getInfiniteSemVerApi(): InfiniteSemVerApi;
|
|
20
|
+
/**
|
|
21
|
+
* 检查指定mod是否满足指定mod集合作为前序mod的依赖关系
|
|
22
|
+
*
|
|
23
|
+
* check if the mod satisfies the dependencies of the specified mod set as the previous mod
|
|
24
|
+
*
|
|
25
|
+
* @param {ModInfo} mod - The mod to check for dependencies.
|
|
26
|
+
* @param {ModOrderContainer[]} modCaches - An array of mod order containers.
|
|
27
|
+
* @return {boolean} - Returns true if the mod satisfies its dependencies, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
checkFor(mod: ModInfo, modCaches: ModOrderContainer[]): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 检查整个加载完毕的mod列表是否满足依赖约束
|
|
32
|
+
*
|
|
33
|
+
* Checks the dependencies of the mod order and verifies if they are satisfied.
|
|
34
|
+
*
|
|
35
|
+
* @return {boolean} - Returns true if all dependencies are satisfied, otherwise returns false.
|
|
36
|
+
*/
|
|
37
|
+
check(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* this called by mod `CheckGameVersion`
|
|
40
|
+
* because the game version only can get after game loaded
|
|
41
|
+
* @param gameVersion
|
|
42
|
+
*/
|
|
43
|
+
checkGameVersion(gameVersion: string): boolean;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { DependenceChecker, InfiniteSemVerApi };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
2
|
+
import { LogWrapper } from "./ModLoadController.js";
|
|
3
|
+
|
|
4
|
+
//#region remote/BeforeSC2/HtmlTagSrcHook.d.ts
|
|
5
|
+
type HtmlTagSrcHookType = (el: HTMLImageElement | HTMLElement, mlSrc: string, field: string) => Promise<boolean>;
|
|
6
|
+
type HtmlTagSrcReturnModeHookType = (mlSrc: string) => Promise<[boolean, string]>;
|
|
7
|
+
type HtmlTagSrcHookCheckModType = (mlSrc: string) => boolean | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* this class replace html image tag src/href attribute ,
|
|
10
|
+
* redirect the image request to a mod like `ImgLoaderHooker` to load the image.
|
|
11
|
+
*/
|
|
12
|
+
declare class HtmlTagSrcHook {
|
|
13
|
+
gSC2DataManager: SC2DataManager;
|
|
14
|
+
logger: LogWrapper;
|
|
15
|
+
constructor(gSC2DataManager: SC2DataManager);
|
|
16
|
+
private hookTable;
|
|
17
|
+
private hookReturnModeTable;
|
|
18
|
+
private hookCheckExistTable;
|
|
19
|
+
addHook(hookKey: string, hook: HtmlTagSrcHookType): void;
|
|
20
|
+
addReturnModeHook(hookKey: string, hook: HtmlTagSrcReturnModeHookType): void;
|
|
21
|
+
addCheckExistHook(hookKey: string, hook: HtmlTagSrcHookCheckModType): void;
|
|
22
|
+
/**
|
|
23
|
+
* check image exist
|
|
24
|
+
*
|
|
25
|
+
* @param src
|
|
26
|
+
* @return true: exist ; false: not exist ; undefined: not exist but not sure (maybe exist but now not find.);
|
|
27
|
+
*/
|
|
28
|
+
checkImageExist(src: string): boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* get image from mod
|
|
31
|
+
* @param src image path
|
|
32
|
+
* @return image base64 string
|
|
33
|
+
*/
|
|
34
|
+
requestImageBySrc(src: string): Promise<string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* 归一化路径为相对路径格式
|
|
37
|
+
* @param path 待归一化的路径
|
|
38
|
+
* @returns 归一化后的相对路径(去除前导 / 和 ./)
|
|
39
|
+
*/
|
|
40
|
+
normalizePath(path: string): string;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { HtmlTagSrcHook, HtmlTagSrcHookCheckModType, HtmlTagSrcHookType, HtmlTagSrcReturnModeHookType };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { clear, createStore, del, entries, get, keys, set, setMany, values } from "idb-keyval";
|
|
2
|
+
import * as idbInstance from "idb";
|
|
3
|
+
import { deleteDB, openDB } from "idb";
|
|
4
|
+
|
|
5
|
+
//#region remote/BeforeSC2/IdbKeyValRef.d.ts
|
|
6
|
+
declare class IdbRef {
|
|
7
|
+
get idb_openDB(): typeof openDB;
|
|
8
|
+
get idb_deleteDB(): typeof deleteDB;
|
|
9
|
+
get idbInstance(): typeof idbInstance;
|
|
10
|
+
}
|
|
11
|
+
declare class IdbKeyValRef {
|
|
12
|
+
get keyval_get(): typeof get;
|
|
13
|
+
get keyval_set(): typeof set;
|
|
14
|
+
get keyval_del(): typeof del;
|
|
15
|
+
get get(): typeof get;
|
|
16
|
+
get set(): typeof set;
|
|
17
|
+
get del(): typeof del;
|
|
18
|
+
get createStore(): typeof createStore;
|
|
19
|
+
get setMany(): typeof setMany;
|
|
20
|
+
get clear(): typeof clear;
|
|
21
|
+
get keys(): typeof keys;
|
|
22
|
+
get values(): typeof values;
|
|
23
|
+
get entries(): typeof entries;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { IdbKeyValRef, IdbRef };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ModPackFileReaderJsZipAdaptor } from "./ModPack/ModPackJsZipAdaptor.js";
|
|
2
|
+
import JSZip from "jszip";
|
|
3
|
+
|
|
4
|
+
//#region remote/BeforeSC2/JSZipLikeReadOnlyInterface.d.ts
|
|
5
|
+
interface JSZipObjectLikeReadOnlyInterface {
|
|
6
|
+
async<T extends OutputType>(type: T, onUpdate?: any): Promise<OutputByType[T]>;
|
|
7
|
+
get name(): string;
|
|
8
|
+
get dir(): boolean;
|
|
9
|
+
}
|
|
10
|
+
interface InputByType {
|
|
11
|
+
base64: string;
|
|
12
|
+
string: string;
|
|
13
|
+
text: string;
|
|
14
|
+
binarystring: string;
|
|
15
|
+
array: number[];
|
|
16
|
+
uint8array: Uint8Array;
|
|
17
|
+
arraybuffer: ArrayBuffer;
|
|
18
|
+
blob: Blob;
|
|
19
|
+
}
|
|
20
|
+
interface OutputByType {
|
|
21
|
+
base64: string;
|
|
22
|
+
string: string;
|
|
23
|
+
uint8array: Uint8Array;
|
|
24
|
+
blob: Blob;
|
|
25
|
+
}
|
|
26
|
+
type InputFileFormat = InputByType[keyof InputByType] | Promise<InputByType[keyof InputByType]>;
|
|
27
|
+
type OutputType = keyof OutputByType;
|
|
28
|
+
interface JSZipLikeReadOnlyInterface {
|
|
29
|
+
file(path: string): JSZipObjectLikeReadOnlyInterface | null;
|
|
30
|
+
file(path: RegExp): JSZipObjectLikeReadOnlyInterface[] | null;
|
|
31
|
+
forEach(callback: (relativePath: string, file: JSZipObjectLikeReadOnlyInterface) => void): void;
|
|
32
|
+
filter(predicate: (relativePath: string, file: JSZipObjectLikeReadOnlyInterface) => boolean): JSZipObjectLikeReadOnlyInterface[];
|
|
33
|
+
loadAsync(data: InputFileFormat, options?: any): Promise<JSZipLikeReadOnlyInterface | undefined>;
|
|
34
|
+
is_JeremieModLoader_ModPack?: boolean;
|
|
35
|
+
hashString?: string;
|
|
36
|
+
generateAsync?: typeof JSZip['generateAsync'];
|
|
37
|
+
get files(): Record<string, JSZipObjectLikeReadOnlyInterface>;
|
|
38
|
+
}
|
|
39
|
+
declare function isModPackFileReaderJsZipAdaptor(obj: any): obj is ModPackFileReaderJsZipAdaptor;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { InputFileFormat, JSZipLikeReadOnlyInterface, JSZipObjectLikeReadOnlyInterface, OutputType, isModPackFileReaderJsZipAdaptor };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ModUtils } from "./Utils.js";
|
|
2
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
3
|
+
import { LogWrapper } from "./ModLoadController.js";
|
|
4
|
+
|
|
5
|
+
//#region remote/BeforeSC2/JsPreloader.d.ts
|
|
6
|
+
declare class StackLike<T> {
|
|
7
|
+
private _data;
|
|
8
|
+
push(v: T): void;
|
|
9
|
+
pop(): T | undefined;
|
|
10
|
+
peek(): T | undefined;
|
|
11
|
+
get length(): number;
|
|
12
|
+
get data(): T[];
|
|
13
|
+
get empty(): boolean;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
16
|
+
declare class JsPreloader {
|
|
17
|
+
pSC2DataManager: SC2DataManager;
|
|
18
|
+
modUtils: ModUtils;
|
|
19
|
+
thisWin: Window;
|
|
20
|
+
logger: LogWrapper;
|
|
21
|
+
constructor(pSC2DataManager: SC2DataManager, modUtils: ModUtils, thisWin: Window);
|
|
22
|
+
startLoadCalled: boolean;
|
|
23
|
+
startLoad(): Promise<any>;
|
|
24
|
+
runningMod: StackLike<string>;
|
|
25
|
+
JsRunner(content: string, name: string, modName: string, stage: string, pSC2DataManager: SC2DataManager, thisWin: Window, logger: LogWrapper): Promise<any>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { JsPreloader, StackLike };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
2
|
+
|
|
3
|
+
//#region remote/BeforeSC2/LanguageManager.d.ts
|
|
4
|
+
declare const MainLanguageTypeEnum: readonly ["en", "zh"];
|
|
5
|
+
declare class LanguageManager {
|
|
6
|
+
thisWin: Window;
|
|
7
|
+
gSC2DataManager: SC2DataManager;
|
|
8
|
+
private logger;
|
|
9
|
+
constructor(thisWin: Window, gSC2DataManager: SC2DataManager);
|
|
10
|
+
/**
|
|
11
|
+
* https://developer.mozilla.org/zh-CN/docs/Web/API/Navigator/language
|
|
12
|
+
* https://www.rfc-editor.org/rfc/bcp/bcp47.txt
|
|
13
|
+
* https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
|
14
|
+
*
|
|
15
|
+
* @return https://stackoverflow.com/questions/5580876/navigator-language-list-of-all-languages
|
|
16
|
+
*/
|
|
17
|
+
getLanguage(): string;
|
|
18
|
+
mainLanguage: typeof MainLanguageTypeEnum[number];
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { LanguageManager, MainLanguageTypeEnum };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SC2DataInfo } from "./SC2DataInfoCache.js";
|
|
2
|
+
|
|
3
|
+
//#region remote/BeforeSC2/MergeSC2DataInfoCache.d.ts
|
|
4
|
+
declare function replaceMergeSC2DataInfoCache(...ic: SC2DataInfo[]): SC2DataInfo;
|
|
5
|
+
declare function replaceMergeSC2DataInfoCacheForce(...ic: SC2DataInfo[]): SC2DataInfo;
|
|
6
|
+
declare function concatMergeSC2DataInfoCache(...ic: SC2DataInfo[]): SC2DataInfo;
|
|
7
|
+
declare function normalMergeSC2DataInfoCache(...ic: SC2DataInfo[]): SC2DataInfo;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { concatMergeSC2DataInfoCache, normalMergeSC2DataInfoCache, replaceMergeSC2DataInfoCache, replaceMergeSC2DataInfoCacheForce };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { JSZipLikeReadOnlyInterface } from "./JSZipLikeReadOnlyInterface.js";
|
|
2
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
3
|
+
import { ModBootJson, ModInfo } from "./ModLoader.js";
|
|
4
|
+
import JSZip from "jszip";
|
|
5
|
+
import moment from "moment/moment";
|
|
6
|
+
|
|
7
|
+
//#region remote/BeforeSC2/ModLoadController.d.ts
|
|
8
|
+
interface LogWrapper {
|
|
9
|
+
log: (s: string) => void;
|
|
10
|
+
warn: (s: string) => void;
|
|
11
|
+
error: (s: string) => void;
|
|
12
|
+
}
|
|
13
|
+
interface LifeTimeCircleHook extends Partial<ModLoadControllerCallback> {}
|
|
14
|
+
interface ModLoadControllerCallback {
|
|
15
|
+
/**
|
|
16
|
+
* ban a mod use this, need register this hook in `InjectEarlyLoad`
|
|
17
|
+
* @param bootJson
|
|
18
|
+
* @param zip
|
|
19
|
+
*/
|
|
20
|
+
canLoadThisMod(bootJson: ModBootJson, zip: JSZipLikeReadOnlyInterface): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* use this to modify a mod, like i18n a mod
|
|
23
|
+
* @param bootJson
|
|
24
|
+
* @param zip carefully modify zip file
|
|
25
|
+
* @param modInfo you can modify the all info in there. read: [ModZipReader.init()]
|
|
26
|
+
*/
|
|
27
|
+
afterModLoad(bootJson: ModBootJson, zip: JSZipLikeReadOnlyInterface, modInfo: ModInfo): Promise<any>;
|
|
28
|
+
InjectEarlyLoad_start(modName: string, fileName: string): Promise<any>;
|
|
29
|
+
InjectEarlyLoad_end(modName: string, fileName: string): Promise<any>;
|
|
30
|
+
EarlyLoad_start(modName: string, fileName: string): Promise<any>;
|
|
31
|
+
EarlyLoad_end(modName: string, fileName: string): Promise<any>;
|
|
32
|
+
LazyLoad_start(modName: string): Promise<any>;
|
|
33
|
+
LazyLoad_end(modName: string): Promise<any>;
|
|
34
|
+
Load_start(modName: string, fileName: string): Promise<any>;
|
|
35
|
+
Load_end(modName: string, fileName: string): Promise<any>;
|
|
36
|
+
PatchModToGame_start(): Promise<any>;
|
|
37
|
+
PatchModToGame_end(): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated
|
|
40
|
+
*/
|
|
41
|
+
ReplacePatcher_start(modName: string, fileName: string): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated
|
|
44
|
+
*/
|
|
45
|
+
ReplacePatcher_end(modName: string, fileName: string): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* Latest Hook On ModLoader When ALL Load End
|
|
48
|
+
*/
|
|
49
|
+
ModLoaderLoadEnd(): Promise<any>;
|
|
50
|
+
/**
|
|
51
|
+
* @useless useless for user
|
|
52
|
+
*/
|
|
53
|
+
logError(s: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* @useless useless for user
|
|
56
|
+
*/
|
|
57
|
+
logInfo(s: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* @useless useless for user
|
|
60
|
+
*/
|
|
61
|
+
logWarning(s: string): void;
|
|
62
|
+
exportDataZip(zip: JSZip): Promise<JSZip>;
|
|
63
|
+
}
|
|
64
|
+
declare function getLogFromModLoadControllerCallback(c: ModLoadControllerCallback): LogWrapper;
|
|
65
|
+
interface LogRecord {
|
|
66
|
+
type: 'info' | 'warning' | 'error';
|
|
67
|
+
time: moment.Moment;
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* ModLoader lifetime circle system,
|
|
72
|
+
* mod can register hook to this system, to listen to the lifetime circle of MpdLoader and error log.
|
|
73
|
+
*
|
|
74
|
+
* ModLoader 生命周期系统,
|
|
75
|
+
* mod 可以注册 hook 到这个系统,来监听 ModLoader 的生命周期和错误日志。
|
|
76
|
+
*/
|
|
77
|
+
declare class ModLoadController implements ModLoadControllerCallback {
|
|
78
|
+
gSC2DataManager: SC2DataManager;
|
|
79
|
+
constructor(gSC2DataManager: SC2DataManager);
|
|
80
|
+
logRecordBeforeAnyLogHookRegister: LogRecord[];
|
|
81
|
+
LazyLoad_end: (modName: string) => Promise<any>;
|
|
82
|
+
LazyLoad_start: (modName: string) => Promise<any>;
|
|
83
|
+
EarlyLoad_end: (modName: string, fileName: string) => Promise<any>;
|
|
84
|
+
EarlyLoad_start: (modName: string, fileName: string) => Promise<any>;
|
|
85
|
+
InjectEarlyLoad_end: (modName: string, fileName: string) => Promise<any>;
|
|
86
|
+
InjectEarlyLoad_start: (modName: string, fileName: string) => Promise<any>;
|
|
87
|
+
Load_end: (modName: string, fileName: string) => Promise<any>;
|
|
88
|
+
Load_start: (modName: string, fileName: string) => Promise<any>;
|
|
89
|
+
PatchModToGame_end: () => Promise<any>;
|
|
90
|
+
PatchModToGame_start: () => Promise<any>;
|
|
91
|
+
ReplacePatcher_end: (modName: string, fileName: string) => Promise<any>;
|
|
92
|
+
ReplacePatcher_start: (modName: string, fileName: string) => Promise<any>;
|
|
93
|
+
logError: (s: string) => void;
|
|
94
|
+
logInfo: (s: string) => void;
|
|
95
|
+
logWarning: (s: string) => void;
|
|
96
|
+
ModLoaderLoadEnd: () => Promise<any>;
|
|
97
|
+
canLoadThisMod(bootJson: ModBootJson, zip: JSZipLikeReadOnlyInterface): Promise<boolean>;
|
|
98
|
+
afterModLoad(bootJson: ModBootJson, zip: JSZipLikeReadOnlyInterface, modInfo: ModInfo): Promise<any>;
|
|
99
|
+
/**
|
|
100
|
+
* call by ModLoaderGui (inner use)
|
|
101
|
+
* @param zip
|
|
102
|
+
*/
|
|
103
|
+
exportDataZip(zip: JSZip): Promise<JSZip>;
|
|
104
|
+
private lifeTimeCircleHookTable;
|
|
105
|
+
addLifeTimeCircleHook(id: string, hook: LifeTimeCircleHook): void;
|
|
106
|
+
removeLifeTimeCircleHook(hook: LifeTimeCircleHook): void;
|
|
107
|
+
clearLifeTimeCircleHook(): void;
|
|
108
|
+
listModLocalStorage(): string[];
|
|
109
|
+
addModLocalStorage(name: string, modBase64String: string): void;
|
|
110
|
+
removeModLocalStorage(name: string): void;
|
|
111
|
+
checkModZipFileLocalStorage(modBase64String: string): Promise<string | ModBootJson>;
|
|
112
|
+
overwriteModIndexDBModList(modeList: string[]): Promise<void>;
|
|
113
|
+
overwriteModIndexDBHiddenModList(modeList: string[]): Promise<void>;
|
|
114
|
+
listModIndexDB(): Promise<string[]>;
|
|
115
|
+
loadHiddenModList(): Promise<string[]>;
|
|
116
|
+
addModIndexDB(name: string, modBase64String: string | Uint8Array): Promise<void>;
|
|
117
|
+
removeModIndexDB(name: string): Promise<void>;
|
|
118
|
+
checkModZipFileIndexDB(modBase64String: string | Uint8Array): Promise<string | ModBootJson>;
|
|
119
|
+
getLog(): LogWrapper;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { LifeTimeCircleHook, LogRecord, LogWrapper, ModLoadController, ModLoadControllerCallback, getLogFromModLoadControllerCallback };
|