@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,179 @@
1
+ import { JSZipLikeReadOnlyInterface } from "./JSZipLikeReadOnlyInterface.js";
2
+ import { LogWrapper, ModLoadControllerCallback } from "./ModLoadController.js";
3
+ import { ModBootJson, ModInfo } from "./ModLoader.js";
4
+ import * as xxhash_wasm0 from "xxhash-wasm";
5
+ import { UseStore } from "idb-keyval";
6
+
7
+ //#region remote/BeforeSC2/ModZipReader.d.ts
8
+ declare function getXxHash(): Promise<xxhash_wasm0.XXHashAPI>;
9
+ interface Twee2PassageR {
10
+ name: string;
11
+ tags: string[];
12
+ content: string;
13
+ }
14
+ declare function Twee2Passage2(s: string): Twee2PassageR[];
15
+ declare function Twee2Passage(s: string): Twee2PassageR[];
16
+ declare function imgWrapBase64Url(fileName: string, base64: string): string;
17
+ declare function blobToBase64(blob: Blob): Promise<string>;
18
+ declare class ModZipReaderHash {
19
+ _hash: string | undefined;
20
+ _zipBase64String: string | undefined;
21
+ constructor(zipBase64String: string | undefined, hash?: string | undefined);
22
+ protected digestMessage(message: string): Promise<string>;
23
+ protected XxHashH64Bigint2String(h64: bigint): string;
24
+ protected XxHashH32Number2String(h32: bigint): string;
25
+ init(): Promise<void>;
26
+ compare(h: ModZipReaderHash): boolean;
27
+ compareWithString(h: string): boolean;
28
+ toString(): string;
29
+ fromString(hash: string): (typeof this._hash);
30
+ }
31
+ declare class ModZipReader {
32
+ loaderBase: LoaderBase;
33
+ modLoadControllerCallback: ModLoadControllerCallback;
34
+ log: LogWrapper;
35
+ private gcFinalizationRegistry;
36
+ private _zip;
37
+ private _zipIsExist;
38
+ get zip(): JSZipLikeReadOnlyInterface;
39
+ modZipReaderHash: ModZipReaderHash;
40
+ constructor(zip: JSZipLikeReadOnlyInterface, zipBase64String: string, loaderBase: LoaderBase, modLoadControllerCallback: ModLoadControllerCallback);
41
+ get isModPack(): boolean;
42
+ get isJsZip(): boolean;
43
+ modInfo?: ModInfo;
44
+ getModInfo(): ModInfo | undefined;
45
+ getZipFile(): JSZipLikeReadOnlyInterface | undefined;
46
+ /**
47
+ * use this to release zip object ref, try to remove the object from memory.
48
+ */
49
+ gcReleaseZip(): void;
50
+ /**
51
+ * use this to debug check if the zip object is really released.
52
+ * @return [isRefExist(true), isWeakRefExist(false), isWeakRefCleanBeCall(true/(null if not support))]
53
+ * only when the return is [true, false, true] the zip object is really released.
54
+ */
55
+ gcCheckReleased(): [boolean,
56
+ /* boolean,*/
57
+ /* boolean,*/
58
+ boolean | null];
59
+ gcIsReleased(): boolean;
60
+ static validateBootJson(bootJ: any, log?: LogWrapper): bootJ is ModBootJson;
61
+ static modBootFilePath: string;
62
+ init(): Promise<boolean>;
63
+ refillCacheStyleFileItems(styleFileList: string[], keepOld: boolean): Promise<void>;
64
+ refillCachePassageDataItems(tweeFileList: string[], keepOld: boolean): Promise<void>;
65
+ refillCacheScriptFileItems(scriptFileList: string[], keepOld: boolean): Promise<void>;
66
+ constructModInfoCache(bootJ: ModBootJson, keepOld: boolean): Promise<void>;
67
+ }
68
+ declare class LoaderBase {
69
+ log: ModLoadControllerCallback;
70
+ loaderKeyConfig: LoaderKeyConfig;
71
+ modList: ModZipReader[];
72
+ modZipList: Map<string, ModZipReader[]>;
73
+ logger: Record<'log' | 'warn' | 'error', ((s: string) => void)>;
74
+ constructor(log: ModLoadControllerCallback, loaderKeyConfig: LoaderKeyConfig);
75
+ init(): void;
76
+ getZipFile(name: string): ModZipReader[] | undefined;
77
+ addZipFile(name: string, zip: ModZipReader): void;
78
+ load(): Promise<boolean>;
79
+ }
80
+ declare class LocalStorageLoader extends LoaderBase {
81
+ static modDataLocalStorageZipList: string;
82
+ static modDataLocalStorageZipPrefix: string;
83
+ init(): void;
84
+ load(): Promise<boolean>;
85
+ static listMod(): string[] | undefined;
86
+ static calcModNameKey(name: string): string;
87
+ static addMod(name: string, modBase64String: string): void;
88
+ static removeMod(name: string): void;
89
+ static checkModZipFile(modBase64String: string): Promise<string | ModBootJson>;
90
+ setConfigKey(modDataLocalStorageZipListKey?: string, modDataLocalStorageZipPrefix?: string): void;
91
+ }
92
+ declare class IndexDBLoader extends LoaderBase {
93
+ modLoadControllerCallback: ModLoadControllerCallback;
94
+ loaderKeyConfig: LoaderKeyConfig;
95
+ static dbName: string;
96
+ static storeName: string;
97
+ static modDataIndexDBZipListHidden: string;
98
+ static modDataIndexDBZipList: string;
99
+ static modDataIndexDBZipPrefix: string;
100
+ init(): void;
101
+ customStore: UseStore;
102
+ constructor(modLoadControllerCallback: ModLoadControllerCallback, loaderKeyConfig: LoaderKeyConfig);
103
+ load(): Promise<boolean>;
104
+ /**
105
+ * @param modeList must have same items as the list in listMod()
106
+ */
107
+ static reorderModList(modeList: string[]): Promise<void>;
108
+ static setModList(modeList: string[]): Promise<void>;
109
+ static setHiddenModList(modeList: string[]): Promise<void>;
110
+ static loadHiddenModList(): Promise<string[] | undefined>;
111
+ static listMod(): Promise<string[] | undefined>;
112
+ static calcModNameKey(name: string): string;
113
+ static addMod(name: string, modBase64String: string | Uint8Array): Promise<void>;
114
+ static removeMod(name: string): Promise<void>;
115
+ static checkModZipFile(modBase64String: string | Uint8Array): Promise<string | ModBootJson>;
116
+ setConfigKey(dbName?: string, storeName?: string, modDataIndexDBZipList?: string, modDataIndexDBZipListHidden?: string): void;
117
+ }
118
+ declare class Base64ZipStringLoader extends LoaderBase {
119
+ modLoadControllerCallback: ModLoadControllerCallback;
120
+ loaderKeyConfig: LoaderKeyConfig;
121
+ base64ZipStringList: string[];
122
+ constructor(modLoadControllerCallback: ModLoadControllerCallback, loaderKeyConfig: LoaderKeyConfig, base64ZipStringList: string[]);
123
+ load(): Promise<boolean>;
124
+ }
125
+ declare class LocalLoader extends LoaderBase {
126
+ modLoadControllerCallback: ModLoadControllerCallback;
127
+ loaderKeyConfig: LoaderKeyConfig;
128
+ thisWin: Window;
129
+ modDataValueZipListPath: string;
130
+ init(): void;
131
+ constructor(modLoadControllerCallback: ModLoadControllerCallback, loaderKeyConfig: LoaderKeyConfig, thisWin: Window);
132
+ load(): Promise<boolean>;
133
+ setConfigKey(modDataValueZipListPath?: string): void;
134
+ }
135
+ declare class RemoteLoader extends LoaderBase {
136
+ modDataRemoteListPath: string;
137
+ init(): void;
138
+ load(): Promise<boolean>;
139
+ setConfigKey(modDataRemoteListPath: string): void;
140
+ }
141
+ declare class LazyLoader extends LoaderBase {
142
+ add(modeZip: JSZipLikeReadOnlyInterface): Promise<ModZipReader>;
143
+ load(): Promise<boolean>;
144
+ }
145
+ declare const getModZipReaderStaticClassRef: () => {
146
+ LocalStorageLoader: typeof LocalStorageLoader;
147
+ IndexDBLoader: typeof IndexDBLoader;
148
+ LocalLoader: typeof LocalLoader;
149
+ RemoteLoader: typeof RemoteLoader;
150
+ };
151
+ declare class LoaderKeyConfig {
152
+ log: ModLoadControllerCallback;
153
+ modLoaderKeyConfigWinHookFunctionName: string;
154
+ logger: Record<'log' | 'warn' | 'error', ((s: string) => void)>;
155
+ constructor(log: ModLoadControllerCallback);
156
+ config: Map<string, string>;
157
+ getLoaderKey(k: string, d: string): string;
158
+ protected isInit: boolean;
159
+ protected init(): void;
160
+ /**
161
+ * @example
162
+ * @code
163
+ * ```
164
+ * window.modLoaderKeyConfigWinHookFunction = (loaderKeyConfig: LoaderKeyConfig) => {
165
+ * loaderKeyConfig.config.set('modDataIndexDBZipList', 'modDataIndexDBZipList123456789');
166
+ * };
167
+ * ```
168
+ *
169
+ * @protected
170
+ */
171
+ protected callWinHookFunction(): void;
172
+ /**
173
+ * @example URL: ./Degrees of Lewdity VERSION.html.mod.html?modDataIndexDBZipList=modDataIndexDBZipList123456789
174
+ * @protected
175
+ */
176
+ protected getConfigFromUrlHash(): void;
177
+ }
178
+ //#endregion
179
+ export { Base64ZipStringLoader, IndexDBLoader, LazyLoader, LoaderBase, LoaderKeyConfig, LocalLoader, LocalStorageLoader, ModZipReader, ModZipReaderHash, RemoteLoader, Twee2Passage, Twee2Passage2, Twee2PassageR, blobToBase64, getModZipReaderStaticClassRef, getXxHash, imgWrapBase64Url };
@@ -0,0 +1,12 @@
1
+ //#region remote/BeforeSC2/PassageTracer.d.ts
2
+ type whenPassageCome = (passageName: string) => void;
3
+ declare class PassageTracer {
4
+ thisWin: Window;
5
+ constructor(thisWin: Window);
6
+ init(): void;
7
+ private whenPassageComeCallback;
8
+ addCallback(cb: whenPassageCome): void;
9
+ newPassageCome(): void;
10
+ }
11
+ //#endregion
12
+ export { PassageTracer };
@@ -0,0 +1,33 @@
1
+ import { LogWrapper } from "./ModLoadController.js";
2
+ import { SC2DataInfo } from "./SC2DataInfoCache.js";
3
+
4
+ //#region remote/BeforeSC2/ReplacePatcher.d.ts
5
+ interface PatchInfo {
6
+ js?: PatchInfoItem[];
7
+ css?: PatchInfoItem[];
8
+ twee?: PatchInfoItem[];
9
+ }
10
+ interface PatchInfoItem {
11
+ from: string;
12
+ to: string;
13
+ fileName: string;
14
+ passageName?: string;
15
+ }
16
+ declare function checkPatchInfo(o: any): o is PatchInfo;
17
+ interface PatchInfoMap {
18
+ js: Map<string, PatchInfoItem[]>;
19
+ css: Map<string, PatchInfoItem[]>;
20
+ twee: Map<string, PatchInfoItem[]>;
21
+ }
22
+ declare class ReplacePatcher {
23
+ logger: LogWrapper;
24
+ modName: string;
25
+ patchFileName: string;
26
+ patchInfo_: any;
27
+ patchInfo: PatchInfo;
28
+ patchInfoMap: PatchInfoMap;
29
+ constructor(logger: LogWrapper, modName: string, patchFileName: string, patchInfo_: any);
30
+ applyReplacePatcher(modSC2DataInfoCache: SC2DataInfo): void;
31
+ }
32
+ //#endregion
33
+ export { PatchInfo, PatchInfoItem, ReplacePatcher, checkPatchInfo };
@@ -0,0 +1,136 @@
1
+ import { SC2DataManager } from "./SC2DataManager.js";
2
+
3
+ //#region remote/BeforeSC2/SC2ApiRef.d.ts
4
+ type throwErrorType = (place: Node, message: string, source?: string) => boolean;
5
+ interface SC2Passage {
6
+ title: string;
7
+ tags: string[];
8
+ element: any | undefined;
9
+ domId: string;
10
+ classes: string[];
11
+ readonly className: string;
12
+ readonly text: string;
13
+ description: () => string;
14
+ processText: () => string;
15
+ render: (options: any) => DocumentFragment;
16
+ }
17
+ declare namespace SC2Passage {
18
+ function getExcerptFromNode(node: Node, count: string): string;
19
+ function getExcerptFromText(text: string, count: string): string;
20
+ }
21
+ interface SC2Story {
22
+ load: () => void;
23
+ init: () => void;
24
+ readonly title: string;
25
+ readonly domId: string;
26
+ readonly ifId: string;
27
+ add: (passage: SC2Passage) => boolean;
28
+ has: (title: string) => boolean;
29
+ get: CallableFunction;
30
+ getAllInit: () => any[];
31
+ getAllRegular: () => any;
32
+ getAllScript: () => any[];
33
+ getAllStylesheet: () => any[];
34
+ getAllWidget: () => any[];
35
+ lookup: CallableFunction;
36
+ lookupWith: CallableFunction;
37
+ }
38
+ interface SC2MacroContext {
39
+ self: SC2MacroContext;
40
+ parent: SC2MacroContext;
41
+ passageObj: SC2Passage;
42
+ name: string;
43
+ displayName: string;
44
+ args: string[];
45
+ payload: string | any;
46
+ source: string;
47
+ parser: any;
48
+ readonly output: string;
49
+ readonly shadows: any[];
50
+ readonly shadowView: any[];
51
+ readonly debugView: any;
52
+ contextHas: (filter: any) => boolean;
53
+ contextSelect: (filter: any) => SC2MacroContext | undefined;
54
+ contextSelectAll: () => SC2MacroContext[];
55
+ addShadow: (...names: string[]) => void;
56
+ createShadowWrapper: (callback: Function, doneCallback: Function, startCallback: Function) => ((...args: any[]) => void);
57
+ createDebugView: (name: string, title: string) => any;
58
+ removeDebugView: () => void;
59
+ error: (message: string, source?: string) => ReturnType<throwErrorType>;
60
+ }
61
+ interface SC2MacroObject {
62
+ isWidget: boolean | undefined;
63
+ tags: string[] | undefined;
64
+ handler: (this: SC2MacroContext) => any;
65
+ }
66
+ interface SC2MacroTags {
67
+ register: (parent: string, bodyTags: string | string[]) => void;
68
+ unregister: (parent: string) => void;
69
+ has: (parent: string) => boolean;
70
+ get: (parent: string) => string[];
71
+ }
72
+ interface SC2Macro {
73
+ add: (name: string | string[], def: SC2MacroContext) => void;
74
+ delete: (name: string | string[]) => void;
75
+ isEmpty: () => boolean;
76
+ has: (name: string) => boolean;
77
+ get: (name: string) => undefined | SC2MacroContext;
78
+ init: (handler: string) => void;
79
+ tags: SC2MacroTags;
80
+ }
81
+ interface SC2Scripting {
82
+ parse: (rawCodeString: string) => string;
83
+ evalJavaScript: (code: string, output?: any, data?: any) => string;
84
+ evalTwineScript: (code: string, output?: any, data?: any) => string;
85
+ }
86
+ interface SC2Wikifier {
87
+ passageObj: SC2Passage;
88
+ source: string;
89
+ options: any;
90
+ nextMatch: number;
91
+ output: any;
92
+ subWikify: (output: Node, terminator: string | RegExp, options: any, passageObj: SC2Passage) => void;
93
+ outputText: (destination: Node, startPos: number, endPos: number) => void;
94
+ _callDepth: number;
95
+ _passageTitleLast: string;
96
+ _passageObjLast: SC2Passage | undefined;
97
+ _lastPassageQ: {
98
+ passageObj: SC2Passage;
99
+ passageTitle: string;
100
+ }[];
101
+ }
102
+ declare namespace SC2Wikifier {
103
+ function lastPassageQPush(passageObj: SC2Passage, passageTitle: string): number;
104
+ function lastPassageQPop(): number;
105
+ function lastPassageQSize(): number;
106
+ function lastPassageQFront(): [number, SC2Passage];
107
+ function lastPassageQBack(): [number, SC2Passage];
108
+ function getLastPossiblePassageTitle(): string;
109
+ function getPassageTitleLast(): string;
110
+ function getPassageObjLast(): SC2Passage;
111
+ function wikifyEval(text: string, passageObj?: SC2Passage, passageTitle?: string): DocumentFragment;
112
+ function createInternalLink(destination: DocumentFragment, passage: SC2Passage, text: string, callback: Function): DocumentFragment;
113
+ function createExternalLink(destination: DocumentFragment, url: string, text: string): DocumentFragment;
114
+ function isExternalLink(link: string): boolean;
115
+ }
116
+ interface SC2ApiType {
117
+ State: any;
118
+ Story: SC2Story;
119
+ Util: any;
120
+ Wikifier: SC2Wikifier;
121
+ Config: any;
122
+ Engine: any;
123
+ Macro: SC2Macro;
124
+ Scripting: SC2Scripting;
125
+ Setting: any;
126
+ Save: any;
127
+ Passage: SC2Passage;
128
+ }
129
+ declare class SC2ApiRef {
130
+ gSC2DataManager: SC2DataManager;
131
+ constructor(gSC2DataManager: SC2DataManager);
132
+ isInit: boolean;
133
+ init(): void;
134
+ }
135
+ //#endregion
136
+ export { SC2ApiRef, SC2ApiType, SC2Macro, SC2MacroContext, SC2MacroObject, SC2MacroTags, SC2Passage, SC2Scripting, SC2Story, SC2Wikifier, throwErrorType };
@@ -0,0 +1,67 @@
1
+ import { LogWrapper } from "./ModLoadController.js";
2
+
3
+ //#region remote/BeforeSC2/SC2DataInfoCache.d.ts
4
+ interface StyleTextFileItem {
5
+ id: number;
6
+ name: string;
7
+ content: string;
8
+ }
9
+ interface ScriptTextFileItem {
10
+ id: number;
11
+ name: string;
12
+ content: string;
13
+ }
14
+ interface PassageDataItem {
15
+ id: number;
16
+ name: string;
17
+ tags: string[];
18
+ content: string;
19
+ position?: string;
20
+ size?: string;
21
+ }
22
+ declare class CacheRecord<T extends {
23
+ name: string;
24
+ content: string;
25
+ }> {
26
+ log: LogWrapper;
27
+ dataSource: string;
28
+ cacheRecordName: string;
29
+ needBuildNoPathCache: boolean;
30
+ constructor(log: LogWrapper, dataSource: string, cacheRecordName: string, needBuildNoPathCache?: boolean);
31
+ getNoPathNameFromString(s: string): string;
32
+ noPathCache?: Map<string, string[]>;
33
+ buildNoPathCache(): void;
34
+ destroy(): void;
35
+ clean(): void;
36
+ items: T[];
37
+ fillMap(): void;
38
+ back2Array(): void;
39
+ map: Map<string, T>;
40
+ noName: T[];
41
+ replaceMerge(c: CacheRecord<T>, noWarnning?: boolean): void;
42
+ concatMerge(c: CacheRecord<T>): void;
43
+ getByNameWithNoPath(s: string): T | undefined;
44
+ getByNameWithOrWithoutPath(s: string): T | undefined;
45
+ }
46
+ declare class SC2DataInfo {
47
+ log: LogWrapper;
48
+ dataSource: string;
49
+ styleFileItems: CacheRecord<StyleTextFileItem>;
50
+ scriptFileItems: CacheRecord<ScriptTextFileItem>;
51
+ passageDataItems: CacheRecord<PassageDataItem>;
52
+ constructor(log: LogWrapper, dataSource: string);
53
+ clean(): void;
54
+ destroy(): void;
55
+ }
56
+ declare class SC2DataInfoCache extends SC2DataInfo {
57
+ log: LogWrapper;
58
+ dataSource: string;
59
+ scriptNode: HTMLScriptElement[];
60
+ styleNode: HTMLStyleElement[];
61
+ passageDataNodes: HTMLElement[];
62
+ cloneSC2DataInfo(): SC2DataInfo;
63
+ destroy(): void;
64
+ constructor(log: LogWrapper, dataSource: string, scriptNode: HTMLScriptElement[], styleNode: HTMLStyleElement[], passageDataNodes: HTMLElement[]);
65
+ }
66
+ //#endregion
67
+ export { CacheRecord, PassageDataItem, SC2DataInfo, SC2DataInfoCache, ScriptTextFileItem, StyleTextFileItem };
@@ -0,0 +1,86 @@
1
+ import { SimulateMergeResult } from "./SimulateMerge.js";
2
+ import { LanguageManager } from "./LanguageManager.js";
3
+ import { DependenceChecker } from "./DependenceChecker.js";
4
+ import { PassageTracer } from "./PassageTracer.js";
5
+ import { Sc2EventTracer } from "./Sc2EventTracer.js";
6
+ import { SC2JsEvalContext } from "./SC2JsEvalContext.js";
7
+ import { JsPreloader } from "./JsPreloader.js";
8
+ import { HtmlTagSrcHook } from "./HtmlTagSrcHook.js";
9
+ import { WikifyTracer } from "./WikifyTracer.js";
10
+ import { ModLoadController } from "./ModLoadController.js";
11
+ import { PassageDataItem, SC2DataInfo, SC2DataInfoCache } from "./SC2DataInfoCache.js";
12
+ import { ModLoader } from "./ModLoader.js";
13
+ import { AddonPluginManager } from "./AddonPlugin.js";
14
+
15
+ //#region remote/BeforeSC2/SC2DataManager.d.ts
16
+ declare class SC2DataManager {
17
+ thisWin: Window;
18
+ constructor(thisWin: Window);
19
+ private modUtils;
20
+ getModUtils(): any;
21
+ private modLoadController;
22
+ getModLoadController(): ModLoadController;
23
+ get rootNode(): Element;
24
+ get styleNode(): HTMLCollectionOf<HTMLStyleElement>;
25
+ get scriptNode(): HTMLCollectionOf<HTMLScriptElement>;
26
+ get passageDataNodeList(): Element[];
27
+ checkSC2Data(): boolean;
28
+ createNewSC2DataInfoFromNow(): SC2DataInfo;
29
+ /**
30
+ * 用于缓存原始的没有经过任何修改的原始的原版SC2Data
31
+ * never set it to undefined OR overwrite it
32
+ * @private
33
+ */
34
+ private originSC2DataInfoCache?;
35
+ earlyResetSC2DataInfoCache(): void;
36
+ cleanAllCacheAfterModLoadEnd(): void;
37
+ initSC2DataInfoCache(): void;
38
+ /**
39
+ * 读取原始的没有被修改过的SC2Data,
40
+ * 对于mod来说,如无必要不要使用这里的数据,
41
+ * 特别是合并时不要使用此处的数据作为数据源,而是使用 getSC2DataInfoAfterPatch(),否则会覆盖之前的mod的修改,导致之前的修改无效
42
+ */
43
+ getSC2DataInfoCache(): SC2DataInfoCache;
44
+ private modLoader?;
45
+ getModLoader(): ModLoader;
46
+ private passageTracer;
47
+ getPassageTracer(): PassageTracer;
48
+ private languageManager;
49
+ getLanguageManager(): LanguageManager;
50
+ private sc2EventTracer;
51
+ getSc2EventTracer(): Sc2EventTracer;
52
+ private jsPreloader;
53
+ getJsPreloader(): JsPreloader;
54
+ private addonPluginManager;
55
+ getAddonPluginManager(): AddonPluginManager;
56
+ private sC2JsEvalContext;
57
+ getSC2JsEvalContext(): SC2JsEvalContext;
58
+ private dependenceChecker;
59
+ getDependenceChecker(): DependenceChecker;
60
+ private htmlTagSrcHook;
61
+ getHtmlTagSrcHook(): HtmlTagSrcHook;
62
+ private wikifyTracer;
63
+ getWikifyTracer(): WikifyTracer;
64
+ private conflictResult?;
65
+ startInitOk: boolean;
66
+ startInit(): Promise<void>;
67
+ getConflictResult(): {
68
+ mod: SC2DataInfo;
69
+ result: SimulateMergeResult;
70
+ }[] | undefined;
71
+ private cSC2DataInfoAfterPatchCache?;
72
+ /**
73
+ * 获取最新的SC2Data,此处获得的是之前的mod修改后的最新的SC2Data数据,
74
+ * 此处使用了缓存,如果修改了SC2Data,请调用 flushAfterPatchCache() 来清除缓存,重新从html中读取最新的SC2Data
75
+ */
76
+ getSC2DataInfoAfterPatch(): SC2DataInfoCache;
77
+ flushAfterPatchCache(): void;
78
+ applyReplacePatcher(modSC2DataInfoCache: SC2DataInfo): Promise<void>;
79
+ patchModToGame(): Promise<void>;
80
+ makePassageNode(T: PassageDataItem): HTMLElement;
81
+ makeStyleNode(sc: SC2DataInfo): HTMLStyleElement;
82
+ makeScriptNode(sc: SC2DataInfo): HTMLScriptElement;
83
+ rePlacePassage(toRemovePassageDataNodeList: Element[], toAddPassageDataNodeList: Element[]): void;
84
+ }
85
+ //#endregion
86
+ export { SC2DataManager };
@@ -0,0 +1,17 @@
1
+ import { SC2DataManager } from "./SC2DataManager.js";
2
+
3
+ //#region remote/BeforeSC2/SC2JsEvalContext.d.ts
4
+ interface SC2JsEvalContextInfo {
5
+ contextThis: object;
6
+ }
7
+ declare class SC2JsEvalContext {
8
+ gSC2DataManager: SC2DataManager;
9
+ constructor(gSC2DataManager: SC2DataManager);
10
+ contextSet: SC2JsEvalContextInfo[];
11
+ /**
12
+ * call by SugarCube2 `Story.storyInit()`
13
+ */
14
+ newContext(id: string): object;
15
+ }
16
+ //#endregion
17
+ export { SC2JsEvalContext, SC2JsEvalContextInfo };
@@ -0,0 +1,24 @@
1
+ import { Passage } from "./SugarCube2.js";
2
+ import { WeakPoolRef } from "./WeakRefPool/WeakRefPool.js";
3
+ import { SC2DataManager } from "./SC2DataManager.js";
4
+
5
+ //#region remote/BeforeSC2/Sc2EventTracer.d.ts
6
+ interface Sc2EventTracerCallback {
7
+ whenSC2StoryReady?: () => any;
8
+ whenSC2PassageInit?: (passage: Passage) => any;
9
+ whenSC2PassageStart?: (passage: Passage, content: HTMLDivElement) => any;
10
+ whenSC2PassageRender?: (passage: Passage, content: HTMLDivElement) => any;
11
+ whenSC2PassageDisplay?: (passage: Passage, content: HTMLDivElement) => any;
12
+ whenSC2PassageEnd?: (passage: Passage, content: HTMLDivElement) => any;
13
+ }
14
+ declare class Sc2EventTracer {
15
+ thisWin: Window;
16
+ gSC2DataManager: SC2DataManager;
17
+ constructor(thisWin: Window, gSC2DataManager: SC2DataManager);
18
+ callback: Sc2EventTracerCallback[];
19
+ callbackLog: [string, WeakPoolRef<Sc2EventTracerCallback>, ...WeakPoolRef<any>[]][];
20
+ init(): void;
21
+ addCallback(cb: Sc2EventTracerCallback): void;
22
+ }
23
+ //#endregion
24
+ export { Sc2EventTracer, Sc2EventTracerCallback };
@@ -0,0 +1,32 @@
1
+ //#region remote/BeforeSC2/SemVer/InfiniteSemVer.d.ts
2
+ declare const BoundaryOperatorList: readonly [">=", "<=", ">", "<", "=", "^", undefined];
3
+ type BoundaryOperator = typeof BoundaryOperatorList[number];
4
+ type VersionBoundary = {
5
+ version: InfiniteSemVer;
6
+ operator: BoundaryOperator;
7
+ };
8
+ type VersionRange = VersionBoundarySet[];
9
+ type VersionBoundarySet = {
10
+ lower?: VersionBoundary;
11
+ upper?: VersionBoundary;
12
+ };
13
+ type InfiniteSemVer = {
14
+ version: number[];
15
+ preRelease?: string | undefined;
16
+ buildMetadata?: string | undefined;
17
+ };
18
+ declare function parseInfiniteSemVer(versionStr: string): VersionBoundary;
19
+ declare function compareString(a: string, b: string): number;
20
+ declare function compareInfiniteVersions(a: InfiniteSemVer, b: InfiniteSemVer, ignorePostfix?: boolean): number;
21
+ declare function parseVersionRange(rangeStr: string): VersionRange;
22
+ declare function isWithinRange(version: InfiniteSemVer, range: VersionRange, ignorePostfix?: boolean): boolean;
23
+ declare const parseRange: typeof parseVersionRange;
24
+ declare const parseVersion: typeof parseInfiniteSemVer;
25
+ declare const satisfies: typeof isWithinRange;
26
+ declare class SemVerToolsType {
27
+ parseRange: typeof parseVersionRange;
28
+ parseVersion: typeof parseInfiniteSemVer;
29
+ satisfies: typeof isWithinRange;
30
+ }
31
+ //#endregion
32
+ export { BoundaryOperator, BoundaryOperatorList, InfiniteSemVer, SemVerToolsType, VersionBoundary, VersionBoundarySet, VersionRange, compareInfiniteVersions, compareString, isWithinRange, parseInfiniteSemVer, parseRange, parseVersion, parseVersionRange, satisfies };
@@ -0,0 +1,17 @@
1
+ import { SC2DataInfo } from "./SC2DataInfoCache.js";
2
+
3
+ //#region remote/BeforeSC2/SimulateMerge.d.ts
4
+ interface SimulateMergeResultItem {
5
+ ok: Set<string>;
6
+ conflict: Set<string>;
7
+ }
8
+ interface SimulateMergeResult {
9
+ styleFileItems: SimulateMergeResultItem;
10
+ scriptFileItems: SimulateMergeResultItem;
11
+ passageDataItems: SimulateMergeResultItem;
12
+ dataSource: string;
13
+ }
14
+ declare function simulateMergeStep(a: Set<string>, b: Set<string>): SimulateMergeResultItem;
15
+ declare function simulateMergeSC2DataInfoCache(...ic: SC2DataInfo[]): SimulateMergeResult[];
16
+ //#endregion
17
+ export { SimulateMergeResult, SimulateMergeResultItem, simulateMergeSC2DataInfoCache, simulateMergeStep };
@@ -0,0 +1,18 @@
1
+ //#region remote/BeforeSC2/SugarCube2.d.ts
2
+ declare class Passage {
3
+ get className(): string;
4
+ get text(): string | any;
5
+ get title(): string | any;
6
+ description(): string | null;
7
+ processText(): string | null;
8
+ render(options): DocumentFragment;
9
+ static getExcerptFromNode(node, count): string;
10
+ static getExcerptFromText(node, count): string;
11
+ }
12
+ declare global {
13
+ interface SugarCube {
14
+ Passage: typeof Passage;
15
+ }
16
+ }
17
+ //#endregion
18
+ export { Passage };
@@ -0,0 +1,14 @@
1
+ //#region remote/BeforeSC2/Utils/LazyIteratorAdaptor.d.ts
2
+ declare class LazyIteratorAdaptor {
3
+ static find<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => boolean): T | undefined;
4
+ static findIndex<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => boolean): number;
5
+ static some<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => boolean): boolean;
6
+ static every<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => boolean): boolean;
7
+ static filter<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => boolean): T[];
8
+ static filterLazy<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => boolean): Generator<T>;
9
+ static map<T, U>(iterator: Iterator<T>, mapper: (value: T, index: number) => U): U[];
10
+ static mapLazy<T, U>(iterator: Iterator<T>, callback: (value: T, index: number) => U): Generator<U>;
11
+ static reduce<T, U>(iterator: Iterator<T>, reducer: (accumulator: U, value: T, index: number) => U, initialValue: U): U;
12
+ }
13
+ //#endregion
14
+ export { LazyIteratorAdaptor };