@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { SimulateMergeResult } from "./SimulateMerge.js";
|
|
2
|
+
import { SemVerToolsType } from "./SemVer/InfiniteSemVer.js";
|
|
3
|
+
import { ModMeta } from "./ModPack/ModMeta.js";
|
|
4
|
+
import { JSZipLikeReadOnlyInterface } from "./JSZipLikeReadOnlyInterface.js";
|
|
5
|
+
import { IndexDBLoader, LocalLoader, LocalStorageLoader, ModZipReader, RemoteLoader, Twee2PassageR } from "./ModZipReader.js";
|
|
6
|
+
import { LanguageManager } from "./LanguageManager.js";
|
|
7
|
+
import { IdbKeyValRef, IdbRef } from "./IdbKeyValRef.js";
|
|
8
|
+
import { ModLoadFromSourceType } from "./ModOrderContainer.js";
|
|
9
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
10
|
+
import { LogWrapper, ModLoadController } from "./ModLoadController.js";
|
|
11
|
+
import { PassageDataItem, SC2DataInfo, SC2DataInfoCache } from "./SC2DataInfoCache.js";
|
|
12
|
+
import { ModBootJsonAddonPlugin, ModInfo, ModLoader } from "./ModLoader.js";
|
|
13
|
+
import { AddonPluginManager } from "./AddonPlugin.js";
|
|
14
|
+
import _ from "lodash";
|
|
15
|
+
|
|
16
|
+
//#region remote/BeforeSC2/Utils.d.ts
|
|
17
|
+
declare class ModUtils {
|
|
18
|
+
pSC2DataManager: SC2DataManager;
|
|
19
|
+
thisWin: Window;
|
|
20
|
+
get version(): string;
|
|
21
|
+
constructor(pSC2DataManager: SC2DataManager, thisWin: Window);
|
|
22
|
+
getThisWindow(): Window;
|
|
23
|
+
/**
|
|
24
|
+
* 获取所有mod的名字
|
|
25
|
+
* 以mod加载顺序为序
|
|
26
|
+
*/
|
|
27
|
+
getModListName(): string[];
|
|
28
|
+
getModListNameNoAlias(): string[];
|
|
29
|
+
getAnyModByNameNoAlias(name: string): ModInfo | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* 获取指定mod的信息
|
|
32
|
+
* @param name ModName
|
|
33
|
+
* @return ModInfo | undefined
|
|
34
|
+
*/
|
|
35
|
+
getMod(name: string): ModInfo | undefined;
|
|
36
|
+
getModAndFromInfo(name: string): undefined | {
|
|
37
|
+
name: string;
|
|
38
|
+
mod: ModInfo;
|
|
39
|
+
from: ModLoadFromSourceType;
|
|
40
|
+
};
|
|
41
|
+
getAllModInfoByFromType(from: ModLoadFromSourceType): {
|
|
42
|
+
name: string;
|
|
43
|
+
mod: ModInfo;
|
|
44
|
+
from: ModLoadFromSourceType;
|
|
45
|
+
}[];
|
|
46
|
+
/**
|
|
47
|
+
* 获取指定mod的Zip
|
|
48
|
+
* @param modName ModName
|
|
49
|
+
* @return ModZipReader | undefined
|
|
50
|
+
*/
|
|
51
|
+
getModZip(modName: string): ModZipReader | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* 获取指定Passage的信息
|
|
54
|
+
* @param name PassageName
|
|
55
|
+
* @return PassageDataItem | undefined
|
|
56
|
+
*/
|
|
57
|
+
getPassageData(name: string): PassageDataItem | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* 获取所有Passage的信息
|
|
60
|
+
* @return PassageDataItem[]
|
|
61
|
+
*/
|
|
62
|
+
getAllPassageData(): PassageDataItem[];
|
|
63
|
+
/**
|
|
64
|
+
* 获取当前最新的SC2DataInfo,其中存储了所有SC2引擎的数据,包括js/css/passage
|
|
65
|
+
* @return SC2DataInfo
|
|
66
|
+
*/
|
|
67
|
+
createNewSC2DataInfoFromNow(): SC2DataInfoCache;
|
|
68
|
+
/**
|
|
69
|
+
* 批量更新passage数据,如果存在则覆盖,如果不存在则创建
|
|
70
|
+
* @param pd 需要更新的passage列表
|
|
71
|
+
* @param replaceForce 强制覆盖而不提示警告
|
|
72
|
+
*/
|
|
73
|
+
updatePassageDataMany(pd: PassageDataItem[], replaceForce?: boolean): void;
|
|
74
|
+
replaceFollowSC2DataInfo(newSC2Data: SC2DataInfo, oldSC2DataCache: SC2DataInfoCache): void;
|
|
75
|
+
/**
|
|
76
|
+
* 更新passage数据,如果存在则覆盖,如果不存在则创建
|
|
77
|
+
* @param name passageName
|
|
78
|
+
* @param content passageContent
|
|
79
|
+
* @param tags passageTags [] OR ['widget']
|
|
80
|
+
* @param pid passagePid 默认是 0 , 如果不是故意覆盖已有的passage那么就填 0 即可
|
|
81
|
+
* @deprecated use `CodeExample/how-to-modify-sc2data.ts` instead
|
|
82
|
+
*/
|
|
83
|
+
updatePassageData(name: string, content: string, tags?: string[], pid?: undefined | number): void;
|
|
84
|
+
/**
|
|
85
|
+
* 从一个twee文件中分离出多个passage,工具函数
|
|
86
|
+
* @param fileString 文件内容字符串
|
|
87
|
+
*/
|
|
88
|
+
splitPassageFromTweeFile(fileString: string): Twee2PassageR[];
|
|
89
|
+
/**
|
|
90
|
+
* 获取mod冲突及覆盖的计算结果,可获知mod之间是否有互相覆盖的情况,如果没有mod则返回空数组
|
|
91
|
+
*
|
|
92
|
+
* 注意,此处只能获取模拟计算mod添加的文件互相的冲突关系,且不包含mod的js动态修改的内容,实际结果可能与这里不一致,
|
|
93
|
+
*
|
|
94
|
+
* @return { mod: SC2DataInfo, result: SimulateMergeResult }[]
|
|
95
|
+
* mod mod添加的内容,其中 dataSource 是 modName
|
|
96
|
+
* result 覆盖结果,其中的 ResultItem[conflict] (Set<string>) 就是互相覆盖的部分的名字(passageName或js/css文件名)
|
|
97
|
+
*/
|
|
98
|
+
getModConflictInfo(): {
|
|
99
|
+
mod: SC2DataInfo;
|
|
100
|
+
result: SimulateMergeResult;
|
|
101
|
+
}[];
|
|
102
|
+
/**
|
|
103
|
+
* 将字符串对正则表达式转义,用于直接将字符串用在正则表达式匹配前的消毒处理
|
|
104
|
+
* @param pattern 需要转义的字符串
|
|
105
|
+
* @return string 转义后的字符串
|
|
106
|
+
*/
|
|
107
|
+
escapedPatternString(pattern: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* 尝试在指定位置附近替换字符串
|
|
110
|
+
* @param content 原始字符串
|
|
111
|
+
* @param searchString 需要查找的字符串
|
|
112
|
+
* @param replaceString 需要替换的字符串
|
|
113
|
+
* @param positionHint 查找的位置
|
|
114
|
+
* @param tolerance1 第一阶快速查找容差 见 @ref tryStringSearch
|
|
115
|
+
* @param tolerance2Negative 第二阶正则查找(负方向)容差 见 @ref tryStringSearch
|
|
116
|
+
* @param tolerance2Positive 第二阶正则查找(正方向)容差 见 @ref tryStringSearch
|
|
117
|
+
* @return string 替换后的字符串
|
|
118
|
+
*/
|
|
119
|
+
tryStringReplace(content: string, searchString: string, replaceString: string, positionHint: number, tolerance1?: number, tolerance2Negative?: number, tolerance2Positive?: number): string;
|
|
120
|
+
/**
|
|
121
|
+
* 尝试在指定位置附近查找字符串
|
|
122
|
+
* @param content 原始字符串
|
|
123
|
+
* @param searchString 需要查找的字符串
|
|
124
|
+
* @param positionHint 查找的位置
|
|
125
|
+
* @param tolerance1 第一阶快速查找容差,(常数字符串比对),如果为0则不使用。此方法可在正负tolerance1个位置范围下查找
|
|
126
|
+
* @param tolerance2Negative 第二阶正则查找(负方向)容差,(正则字符串比对)。
|
|
127
|
+
* @param tolerance2Positive 第二阶正则查找(正方向)容差,(正则字符串比对)。如果正负都为0则不使用。此方法可在正负tolerance2Negative个位置范围下查找。
|
|
128
|
+
* @return number 查找到的位置,如果没有找到则返回undefined
|
|
129
|
+
*/
|
|
130
|
+
tryStringSearch(content: string, searchString: string, positionHint: number, tolerance1?: number, tolerance2Negative?: number, tolerance2Positive?: number): number | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* 在指定位置插入字符串
|
|
133
|
+
* @param content 原始字符串
|
|
134
|
+
* @param insertString 需要插入的字符串
|
|
135
|
+
* @param position 插入的位置
|
|
136
|
+
* @return string 插入后的字符串
|
|
137
|
+
*/
|
|
138
|
+
insertStringInPosition(content: string, insertString: string, position: number): string;
|
|
139
|
+
getLodash(): _.LoDashStatic;
|
|
140
|
+
getModLoadController(): ModLoadController;
|
|
141
|
+
getModLoader(): ModLoader;
|
|
142
|
+
getAddonPluginManager(): AddonPluginManager;
|
|
143
|
+
getLogger(): LogWrapper;
|
|
144
|
+
lazyRegisterNewModZipData(data: ArgumentTypes<JSZipLikeReadOnlyInterface['loadAsync']>[0], options?: any): Promise<boolean>;
|
|
145
|
+
parseModPack(modPackBuffer: Uint8Array, password?: string | undefined): Promise<ModMeta>;
|
|
146
|
+
getNowRunningModName(): string | undefined;
|
|
147
|
+
getSemVerTools(): SemVerToolsType;
|
|
148
|
+
getModZipReaderStaticClassRef: () => {
|
|
149
|
+
LocalStorageLoader: typeof LocalStorageLoader;
|
|
150
|
+
IndexDBLoader: typeof IndexDBLoader;
|
|
151
|
+
LocalLoader: typeof LocalLoader;
|
|
152
|
+
RemoteLoader: typeof RemoteLoader;
|
|
153
|
+
};
|
|
154
|
+
getImage(imagePath: string): Promise<string | undefined>;
|
|
155
|
+
getLanguageManager(): LanguageManager;
|
|
156
|
+
getNowMainLanguage(): 'en' | 'zh' | string;
|
|
157
|
+
getIdbKeyValRef(): IdbKeyValRef;
|
|
158
|
+
getIdbRef(): IdbRef;
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* const modAddonPluginsParams = window.modUtils.getAddonParamsFromModInfo(modInfo, 'BeautySelectorAddon', 'BeautySelectorAddon');
|
|
162
|
+
*
|
|
163
|
+
* @param modInfo params 2 of registerMod callback
|
|
164
|
+
* @param addonPluginModName params 1 of registerAddonPlugin
|
|
165
|
+
* @param addonName params 2 of registerAddonPlugin
|
|
166
|
+
*/
|
|
167
|
+
getAddonParamsFromModInfo<P>(modInfo: ModInfo, addonPluginModName: string, addonName: string): P | undefined;
|
|
168
|
+
getAddonParamsFromModInfo(modInfo: ModInfo, addonPluginModName: string, addonName: string): ModBootJsonAddonPlugin['params'] | undefined;
|
|
169
|
+
}
|
|
170
|
+
type ArgumentTypes<F extends Function> = F extends ((...args: infer A) => any) ? A : never;
|
|
171
|
+
//#endregion
|
|
172
|
+
export { ArgumentTypes, ModUtils };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region remote/BeforeSC2/WeakRefPool/WeakRefPool.d.ts
|
|
2
|
+
declare function newWeakPoolRef<T>(v: T): WeakPoolRef<T>;
|
|
3
|
+
declare class WeakPoolRef<T> {
|
|
4
|
+
constructor();
|
|
5
|
+
get deref(): T | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare class WeakRefPool<T> {
|
|
8
|
+
pool: WeakMap<WeakPoolRef<T>, T>;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { WeakPoolRef, WeakRefPool, newWeakPoolRef };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SC2Passage } from "./SC2ApiRef.js";
|
|
2
|
+
import { SC2DataManager } from "./SC2DataManager.js";
|
|
3
|
+
|
|
4
|
+
//#region remote/BeforeSC2/WikifyTracer.d.ts
|
|
5
|
+
interface WikifyTracerCallback {
|
|
6
|
+
/**
|
|
7
|
+
* 可以修改输入文本内容
|
|
8
|
+
* @param text 原始文本内容
|
|
9
|
+
* @param passageTitle passage标题
|
|
10
|
+
* @param passageObj passage对象
|
|
11
|
+
* @return string 返回修改后的文本内容
|
|
12
|
+
*/
|
|
13
|
+
beforePassage?: (text: string, passageTitle: string, passageObj: SC2Passage) => string;
|
|
14
|
+
/**
|
|
15
|
+
* 可以修改输出后的html树,只会在passage结束后调用
|
|
16
|
+
* @param text 原始文本内容
|
|
17
|
+
* @param passageTitle passage标题
|
|
18
|
+
* @param passageObj passage对象
|
|
19
|
+
* @param node 最终输出的html树
|
|
20
|
+
*/
|
|
21
|
+
afterPassage?: (text: string, passageTitle: string, passageObj: SC2Passage, node: DocumentFragment) => void;
|
|
22
|
+
beforeWikify?: (text: string) => string;
|
|
23
|
+
/**
|
|
24
|
+
* 可以修改输出后的html树,会在每一次wikify后调用,包括passage以及每个text节点
|
|
25
|
+
* @param text 原始文本内容
|
|
26
|
+
* @param node 最终输出的html树
|
|
27
|
+
*/
|
|
28
|
+
afterWikify?: (text: string, node: DocumentFragment) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 可以修改输入文本内容
|
|
31
|
+
* @param text 原始文本内容
|
|
32
|
+
* @param widgetName widget名称
|
|
33
|
+
* @param passageTitle passage标题
|
|
34
|
+
* @param passageObj passage对象
|
|
35
|
+
*/
|
|
36
|
+
beforeWidget?: (text: string, widgetName: string, passageTitle?: string, passageObj?: SC2Passage) => string;
|
|
37
|
+
/**
|
|
38
|
+
* 可以修改输出后的html树,会在每一次widget后调用
|
|
39
|
+
* @param text 原始文本内容
|
|
40
|
+
* @param widgetName widget名称
|
|
41
|
+
* @param passageTitle passage标题
|
|
42
|
+
* @param passageObj passage对象
|
|
43
|
+
* @param node 最终输出的html树
|
|
44
|
+
*/
|
|
45
|
+
afterWidget?: (text: string, widgetName: string, passageTitle: string | undefined, passageObj: SC2Passage | undefined, node: DocumentFragment) => void;
|
|
46
|
+
}
|
|
47
|
+
declare class WikifyTracerCallbackOrder {
|
|
48
|
+
beforePassage: string[];
|
|
49
|
+
afterPassage: string[];
|
|
50
|
+
beforeWikify: string[];
|
|
51
|
+
afterWikify: string[];
|
|
52
|
+
beforeWidget: string[];
|
|
53
|
+
afterWidget: string[];
|
|
54
|
+
addCallback(key: string, c: WikifyTracerCallback): void;
|
|
55
|
+
removeCallback(key: string, c: WikifyTracerCallback): void;
|
|
56
|
+
}
|
|
57
|
+
declare class WikifyTracerCallbackCount {
|
|
58
|
+
beforePassage: number;
|
|
59
|
+
afterPassage: number;
|
|
60
|
+
beforeWikify: number;
|
|
61
|
+
afterWikify: number;
|
|
62
|
+
beforeWidget: number;
|
|
63
|
+
afterWidget: number;
|
|
64
|
+
order: WikifyTracerCallbackOrder;
|
|
65
|
+
addCallback(key: string, c: WikifyTracerCallback): void;
|
|
66
|
+
removeCallback(key: string, c: WikifyTracerCallback): void;
|
|
67
|
+
checkDataValid(): boolean;
|
|
68
|
+
}
|
|
69
|
+
declare class WikifyTracer {
|
|
70
|
+
gSC2DataManager: SC2DataManager;
|
|
71
|
+
private logger;
|
|
72
|
+
constructor(gSC2DataManager: SC2DataManager);
|
|
73
|
+
private callbackTable;
|
|
74
|
+
private callbackOrder;
|
|
75
|
+
private callbackCount;
|
|
76
|
+
addCallback(key: string, callback: WikifyTracerCallback): void;
|
|
77
|
+
beforePassage(text: string, passageTitle: string, passageObj: SC2Passage): string;
|
|
78
|
+
afterPassage(text: string, passageTitle: string, passageObj: SC2Passage, node: DocumentFragment): void;
|
|
79
|
+
beforeWikify(text: string): string;
|
|
80
|
+
afterWikify(text: string, node: DocumentFragment): void;
|
|
81
|
+
beforeWidget(text: string, widgetName: string, passageTitle?: string, passageObj?: SC2Passage): string;
|
|
82
|
+
afterWidget(text: string, widgetName: string, passageTitle: string | undefined, passageObj: SC2Passage | undefined, node: DocumentFragment): void;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { WikifyTracer, WikifyTracerCallback, WikifyTracerCallbackCount, WikifyTracerCallbackOrder };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import JQueryStatic from "jquery/JQueryStatic";
|
|
2
|
+
|
|
3
|
+
//#region remote/BeforeSC2/global.d.ts
|
|
4
|
+
// declare var $: JQueryStatic;
|
|
5
|
+
// declare var jQuery: JQueryStatic;
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
jQuery: JQueryStatic;
|
|
9
|
+
$: JQueryStatic;
|
|
10
|
+
modSC2DataManager: SC2DataManager;
|
|
11
|
+
modUtils: ModUtils;
|
|
12
|
+
jsPreloader: JsPreloader;
|
|
13
|
+
modModLoadController: ModLoadController;
|
|
14
|
+
modAddonPluginManager: AddonPluginManager;
|
|
15
|
+
modSC2JsEvalContext: SC2JsEvalContext;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type JQueryStatic from "jquery/JQueryStatic";
|
|
2
|
+
import type { SC2DataManager } from "./SC2DataManager.d.ts";
|
|
3
|
+
import type { ModUtils } from "./Utils.d.ts";
|
|
4
|
+
import type { JsPreloader } from "./JsPreloader.d.ts";
|
|
5
|
+
import type { ModLoadController } from "./ModLoadController.d.ts";
|
|
6
|
+
import type { AddonPluginManager } from "./AddonPlugin.d.ts";
|
|
7
|
+
import type { SC2JsEvalContext } from "./SC2JsEvalContext.d.ts";
|
|
8
|
+
declare global {
|
|
9
|
+
interface window {
|
|
10
|
+
jQuery: JQueryStatic
|
|
11
|
+
"$": JQueryStatic
|
|
12
|
+
modSC2DataManager: SC2DataManager
|
|
13
|
+
modUtils: ModUtils
|
|
14
|
+
jsPreloader: JsPreloader
|
|
15
|
+
modModLoadController: ModLoadController
|
|
16
|
+
modAddonPluginManager: AddonPluginManager
|
|
17
|
+
modSC2JsEvalContext: SC2JsEvalContext
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./init.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "core-js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "core-js/full";
|