@scml-dol-maplebirch/types 4.4.1 → 5.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/maplebirch.d.ts CHANGED
@@ -1,10 +1,4 @@
1
1
  import { Passage } from '@scml/types/sugarcube-2-ModLoader/SugarCube2';
2
- import { ModBootJson, ModInfo } from '@scml/types/sugarcube-2-ModLoader/ModLoader';
3
- import { InputFileFormat, JSZipLikeReadOnlyInterface } from '@scml/types/sugarcube-2-ModLoader/JSZipLikeReadOnlyInterface';
4
- import { ModZipReader } from '@scml/types/sugarcube-2-ModLoader/ModZipReader';
5
- import { SC2DataManager } from '@scml/types/sugarcube-2-ModLoader/SC2DataManager';
6
- import { WikifyTracerCallback } from '@scml/types/sugarcube-2-ModLoader/WikifyTracer';
7
- import { ModUtils } from '@scml/types/sugarcube-2-ModLoader/Utils';
8
2
  import { BrowserAPI } from '@scml/sc2-verlnir/src/browser';
9
3
  import { ConfigAPI } from '@scml/sc2-verlnir/src/config';
10
4
  import { DebugBarAPI } from '@scml/sc2-verlnir/src/debugbar';
@@ -28,13 +22,124 @@ import { VersionInfo } from '@scml/sc2-verlnir/src/version';
28
22
  import { VisibilityAPI } from '@scml/sc2-verlnir/src/visibility';
29
23
  import { WikifierAPI } from '@scml/sc2-verlnir/src/wikifier';
30
24
  import { SugarCubeStoryVariables, SugarCubeTemporaryVariables } from 'twine-sugarcube/userdata';
25
+ import { SC2DataManager } from '@scml/types/sugarcube-2-ModLoader/SC2DataManager';
26
+ import { WikifyTracerCallback } from '@scml/types/sugarcube-2-ModLoader/WikifyTracer';
31
27
  import { Gui } from '@scml/types/Mod_LoaderGui/Gui';
32
- import jsyaml from 'js-yaml';
33
- import { Howl, Howler } from 'howler';
34
28
  import * as marked from 'marked';
29
+ import jsyaml from 'js-yaml';
30
+ import { Howl, HowlOptions } from 'howler';
31
+ import { InputFileFormat, JSZipLikeReadOnlyInterface } from '@scml/types/sugarcube-2-ModLoader/JSZipLikeReadOnlyInterface';
32
+ import { ModBootJson, ModInfo } from '@scml/types/sugarcube-2-ModLoader/ModLoader';
33
+ import { ModZipReader } from '@scml/types/sugarcube-2-ModLoader/ModZipReader';
34
+ import { ModUtils } from '@scml/types/sugarcube-2-ModLoader/Utils';
35
35
  import { MacroContext } from 'twine-sugarcube';
36
36
  //#endregion
37
- //#region src/modules/Frameworks/Patches/Bodywriting.d.ts
37
+ //#region src/utils/object.d.ts
38
+ type MergeMode = 'replace' | 'concat' | 'merge';
39
+ type MergeFilterFn = (key: string, value: unknown, depth: number, targetValue: unknown) => boolean;
40
+ type MergeTuple<T extends readonly unknown[], S extends readonly unknown[]> = S extends readonly [infer Head, ...infer Rest]
41
+ ? T extends readonly [infer Previous, ...infer Tail]
42
+ ? [Merged<Previous, Head, 'merge'>, ...MergeTuple<Tail, Rest>]
43
+ : [...S]
44
+ : [...T];
45
+ type Merged<T, S, Mode extends MergeMode> = S extends readonly unknown[]
46
+ ? T extends readonly unknown[]
47
+ ? Mode extends 'replace'
48
+ ? [...S]
49
+ : Mode extends 'concat'
50
+ ? [...T, ...S]
51
+ : number extends T['length'] | S['length']
52
+ ? (T[number] | S[number])[]
53
+ : MergeTuple<T, S>
54
+ : [...S]
55
+ : S extends Record<string, unknown>
56
+ ? Omit<T, keyof S> & { [Key in keyof S]: Key extends keyof T ? Merged<T[Key], S[Key], Mode> : S[Key] }
57
+ : S;
58
+ type MergeResult<T, Sources extends readonly unknown[], Mode extends MergeMode = 'merge'> = Sources extends readonly [infer Source, ...infer Rest]
59
+ ? MergeResult<Merged<T, Source, Mode>, Rest, Mode>
60
+ : T;
61
+ declare function clone<T>(source: T, deep?: boolean, proto?: boolean, map?: WeakMap<object, unknown>): T;
62
+ declare function equal(a: unknown, b: unknown): boolean;
63
+ declare function merge<T, Sources extends unknown[]>(target: T, ...sources: Sources): MergeResult<T, Sources>;
64
+ declare function append<T, Sources extends unknown[]>(target: T, ...sources: Sources): MergeResult<T, Sources, 'concat'>;
65
+ declare function cover<T, Sources extends unknown[]>(target: T, ...sources: Sources): MergeResult<T, Sources, 'replace'>;
66
+ declare function mergeFn<T, Sources extends unknown[]>(target: T, filter: MergeFilterFn | null, ...sources: Sources): MergeResult<T, Sources>;
67
+ declare function appendFn<T, Sources extends unknown[]>(target: T, filter: MergeFilterFn | null, ...sources: Sources): MergeResult<T, Sources, 'concat'>;
68
+ declare function coverFn<T, Sources extends unknown[]>(target: T, filter: MergeFilterFn | null, ...sources: Sources): MergeResult<T, Sources, 'replace'>;
69
+ //#endregion
70
+ //#region src/utils/array.d.ts
71
+ type ContainsMode = 'all' | 'any' | 'none';
72
+ type ContainsOptions = {
73
+ case?: boolean;
74
+ compare?: (item: unknown, value: unknown) => boolean;
75
+ deep?: boolean;
76
+ };
77
+ declare function contains(array: readonly unknown[], value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
78
+ declare function randomNumber(min?: number, max?: number, float?: boolean): number;
79
+ declare function randomPick<T>(items: readonly T[], weights?: readonly number[] | null, allowNull?: boolean): T | null | undefined;
80
+ declare function clamp(value: unknown, min: number, max: number, fallback?: number): number;
81
+ //#endregion
82
+ //#region src/utils/string.d.ts
83
+ type ConvertMode$1 = 'lower' | 'upper' | 'capitalize' | 'title' | 'camel' | 'pascal' | 'snake' | 'kebab' | 'constant';
84
+ declare function convert(
85
+ value: string,
86
+ mode?: ConvertMode$1,
87
+ options?: {
88
+ delimiter?: string;
89
+ acronym?: boolean;
90
+ }
91
+ ): string;
92
+ declare function escapeHtmlText(value: string): string;
93
+ declare function widgets(content: string): string;
94
+ declare function widgets(...contents: string[]): string[];
95
+ //#endregion
96
+ //#region src/compat/Prototype.d.ts
97
+ declare global {
98
+ interface ObjectConstructor {
99
+ merge<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
100
+ append<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
101
+ cover<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
102
+ mergefn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
103
+ appendfn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
104
+ coverfn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
105
+ }
106
+ interface Array<T> {
107
+ contains(value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
108
+ either(weights?: number[], allowNull?: boolean): T | null | undefined;
109
+ }
110
+ interface ArrayConstructor {
111
+ merge<T>(...sources: readonly T[][]): T[];
112
+ append<T>(...sources: readonly T[][]): T[];
113
+ cover<T>(...sources: readonly T[][]): T[];
114
+ }
115
+ interface ReadonlyArray<T> {
116
+ contains(value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
117
+ either(weights?: number[], allowNull?: boolean): T | null | undefined;
118
+ }
119
+ interface String {
120
+ contains(
121
+ value: string,
122
+ options?: {
123
+ case?: boolean;
124
+ }
125
+ ): boolean;
126
+ convert(
127
+ mode?: ConvertMode$1,
128
+ options?: {
129
+ delimiter?: string;
130
+ acronym?: boolean;
131
+ }
132
+ ): string;
133
+ }
134
+ interface Math {
135
+ random(): number;
136
+ random(max: number): number;
137
+ random(min: number, max: number, float?: boolean): number;
138
+ clamp(value: unknown, min: number, max: number, fallback?: number): number;
139
+ }
140
+ }
141
+ //#endregion
142
+ //#region src/modules/DoL/Patches/Bodywriting.d.ts
38
143
  interface BodywritingConfig {
39
144
  writing?: string;
40
145
  writ_cn?: string;
@@ -69,7 +174,7 @@ declare class Bodywriting {
69
174
  private static set;
70
175
  }
71
176
  //#endregion
72
- //#region src/modules/Frameworks/Patches/Foodstuff.d.ts
177
+ //#region src/modules/DoL/Patches/Foodstuff.d.ts
73
178
  type FoodstuffSeason = 'spring' | 'summer' | 'autumn' | 'winter';
74
179
  type FoodstuffPlantingBed = 'earth' | 'water';
75
180
  type FoodstuffStallSize = 'small' | 'large';
@@ -133,7 +238,7 @@ declare class Foodstuff {
133
238
  private static ensureState;
134
239
  }
135
240
  //#endregion
136
- //#region src/modules/Frameworks/Patches/Location.d.ts
241
+ //#region src/modules/DoL/Patches/Location.d.ts
137
242
  interface LocationConfigOptions {
138
243
  overwrite?: boolean;
139
244
  layer?: string;
@@ -169,7 +274,7 @@ declare class Location {
169
274
  static apply(): void;
170
275
  }
171
276
  //#endregion
172
- //#region src/modules/Frameworks/Patches/Fishing.d.ts
277
+ //#region src/modules/DoL/Patches/Fishing.d.ts
173
278
  type FishingLocation = 'fishingBeach' | 'fishingPier' | 'fishingCoastPath' | 'fishingForestLake' | 'fishingMoor';
174
279
  type FishingSeason = 'spring' | 'summer' | 'autumn' | 'winter';
175
280
  type FishBehavior = 'runner' | 'darter' | 'panicked' | 'anchor' | 'thrasher' | 'slipper';
@@ -199,7 +304,7 @@ declare class Fishing {
199
304
  static apply(): void;
200
305
  }
201
306
  //#endregion
202
- //#region src/modules/Frameworks/Patches/Antiques.d.ts
307
+ //#region src/modules/DoL/Patches/Antiques.d.ts
203
308
  interface AntiqueConfig {
204
309
  hint: string;
205
310
  museum: string;
@@ -216,7 +321,7 @@ declare class Antiques {
216
321
  static syncState(): void;
217
322
  }
218
323
  //#endregion
219
- //#region src/modules/Frameworks/Patches/Traits.d.ts
324
+ //#region src/modules/DoL/Patches/Traits.d.ts
220
325
  interface TraitCategory {
221
326
  title: string;
222
327
  traits: Trait[];
@@ -682,76 +787,6 @@ declare global {
682
787
  }
683
788
  }
684
789
  //#endregion
685
- //#region src/constants.d.ts
686
- type LanguageCode = (typeof Languages)[number];
687
- declare const Languages: readonly ['EN', 'CN'];
688
- declare enum ModuleState {
689
- REGISTERED = 0,
690
- MOUNTED = 1,
691
- ERROR = 2,
692
- EXPOSED = 3,
693
- DISABLED = 4
694
- }
695
- //#endregion
696
- //#region src/utils/object.d.ts
697
- type MergeMode = 'replace' | 'concat' | 'merge';
698
- type MergeFilterFn = (key: string, value: unknown, depth: number, targetValue: unknown) => boolean;
699
- type MergeTuple<T extends readonly unknown[], S extends readonly unknown[]> = S extends readonly [infer Head, ...infer Rest]
700
- ? T extends readonly [infer Previous, ...infer Tail]
701
- ? [Merged<Previous, Head, 'merge'>, ...MergeTuple<Tail, Rest>]
702
- : [...S]
703
- : [...T];
704
- type Merged<T, S, Mode extends MergeMode> = S extends readonly unknown[]
705
- ? T extends readonly unknown[]
706
- ? Mode extends 'replace'
707
- ? [...S]
708
- : Mode extends 'concat'
709
- ? [...T, ...S]
710
- : number extends T['length'] | S['length']
711
- ? (T[number] | S[number])[]
712
- : MergeTuple<T, S>
713
- : [...S]
714
- : S extends Record<string, unknown>
715
- ? Omit<T, keyof S> & { [Key in keyof S]: Key extends keyof T ? Merged<T[Key], S[Key], Mode> : S[Key] }
716
- : S;
717
- type MergeResult<T, Sources extends readonly unknown[], Mode extends MergeMode = 'merge'> = Sources extends readonly [infer Source, ...infer Rest]
718
- ? MergeResult<Merged<T, Source, Mode>, Rest, Mode>
719
- : T;
720
- declare function clone<T>(source: T, deep?: boolean, proto?: boolean, map?: WeakMap<object, unknown>): T;
721
- declare function equal(a: unknown, b: unknown): boolean;
722
- declare function merge<T, Sources extends unknown[]>(target: T, ...sources: Sources): MergeResult<T, Sources>;
723
- declare function append<T, Sources extends unknown[]>(target: T, ...sources: Sources): MergeResult<T, Sources, 'concat'>;
724
- declare function cover<T, Sources extends unknown[]>(target: T, ...sources: Sources): MergeResult<T, Sources, 'replace'>;
725
- declare function mergeFn<T, Sources extends unknown[]>(target: T, filter: MergeFilterFn | null, ...sources: Sources): MergeResult<T, Sources>;
726
- declare function appendFn<T, Sources extends unknown[]>(target: T, filter: MergeFilterFn | null, ...sources: Sources): MergeResult<T, Sources, 'concat'>;
727
- declare function coverFn<T, Sources extends unknown[]>(target: T, filter: MergeFilterFn | null, ...sources: Sources): MergeResult<T, Sources, 'replace'>;
728
- //#endregion
729
- //#region src/utils/array.d.ts
730
- type ContainsMode = 'all' | 'any' | 'none';
731
- type ContainsOptions = {
732
- case?: boolean;
733
- compare?: (item: unknown, value: unknown) => boolean;
734
- deep?: boolean;
735
- };
736
- declare function contains(array: readonly unknown[], value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
737
- declare function randomNumber(min?: number, max?: number, float?: boolean): number;
738
- declare function randomPick<T>(items: readonly T[], weights?: readonly number[] | null, allowNull?: boolean): T | null | undefined;
739
- declare function clamp(value: unknown, min: number, max: number, fallback?: number): number;
740
- //#endregion
741
- //#region src/utils/string.d.ts
742
- type ConvertMode$1 = 'lower' | 'upper' | 'capitalize' | 'title' | 'camel' | 'pascal' | 'snake' | 'kebab' | 'constant';
743
- declare function convert(
744
- value: string,
745
- mode?: ConvertMode$1,
746
- options?: {
747
- delimiter?: string;
748
- acronym?: boolean;
749
- }
750
- ): string;
751
- declare function escapeHtmlText(value: string): string;
752
- declare function widgets(content: string): string;
753
- declare function widgets(...contents: string[]): string[];
754
- //#endregion
755
790
  //#region src/utils/binary.d.ts
756
791
  declare function textToBytes(value: string): Uint8Array;
757
792
  declare function jsonToBytes(value: unknown): Uint8Array;
@@ -762,12 +797,6 @@ declare function base64ToBytes(value: string): Uint8Array;
762
797
  declare function base64ToArrayBuffer(value: string): ArrayBuffer;
763
798
  declare function basicAuth(username: string, password: string): string;
764
799
  //#endregion
765
- //#region src/utils/path.d.ts
766
- declare function joinEncodedPath(...parts: string[]): string;
767
- //#endregion
768
- //#region src/utils/error.d.ts
769
- declare function errorMessage(error: unknown): string;
770
- //#endregion
771
800
  //#region src/utils/selector.d.ts
772
801
  type Comparator = '<' | '<=' | '>' | '>=';
773
802
  type ResultValue<Input, Result, Meta> = Result | ((input: Input, meta: Meta) => Result);
@@ -788,56 +817,6 @@ declare class SelectCase<Input = unknown, Result = unknown, Meta = Record<string
788
817
  private resolve;
789
818
  private validateType;
790
819
  }
791
- //#endregion
792
- //#region src/utils/image.d.ts
793
- declare function loadImage(src: string): string | false | Promise<string | false>;
794
- //#endregion
795
- //#region src/utils/prototype.d.ts
796
- declare global {
797
- interface ObjectConstructor {
798
- merge<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
799
- append<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
800
- cover<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
801
- mergefn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
802
- appendfn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
803
- coverfn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
804
- }
805
- interface Array<T> {
806
- contains(value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
807
- either(weights?: number[], allowNull?: boolean): T | null | undefined;
808
- }
809
- interface ArrayConstructor {
810
- merge<T>(...sources: readonly T[][]): T[];
811
- append<T>(...sources: readonly T[][]): T[];
812
- cover<T>(...sources: readonly T[][]): T[];
813
- }
814
- interface ReadonlyArray<T> {
815
- contains(value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
816
- either(weights?: number[], allowNull?: boolean): T | null | undefined;
817
- }
818
- interface String {
819
- contains(
820
- value: string,
821
- options?: {
822
- case?: boolean;
823
- }
824
- ): boolean;
825
- convert(
826
- mode?: ConvertMode$1,
827
- options?: {
828
- delimiter?: string;
829
- acronym?: boolean;
830
- }
831
- ): string;
832
- }
833
- interface Math {
834
- random(): number;
835
- random(max: number): number;
836
- random(min: number, max: number, float?: boolean): number;
837
- clamp(value: unknown, min: number, max: number, fallback?: number): number;
838
- }
839
- }
840
- declare function prototypeUtils(): void;
841
820
  declare namespace index_d_exports {
842
821
  export {
843
822
  SelectCase,
@@ -856,14 +835,10 @@ declare namespace index_d_exports {
856
835
  coverFn as coverfn,
857
836
  randomPick as either,
858
837
  equal,
859
- errorMessage,
860
838
  escapeHtmlText,
861
- joinEncodedPath,
862
839
  jsonToBytes,
863
- loadImage,
864
840
  merge,
865
841
  mergeFn as mergefn,
866
- prototypeUtils,
867
842
  publicUtils,
868
843
  randomNumber as random,
869
844
  textToBytes,
@@ -886,42 +861,166 @@ declare const publicUtils: Readonly<{
886
861
  SelectCase: typeof SelectCase;
887
862
  convert: typeof convert;
888
863
  clamp: typeof clamp;
889
- loadImage: typeof loadImage;
890
864
  }>;
891
865
  //#endregion
892
- //#region src/services/Logger.d.ts
893
- declare class Logger {
894
- readonly core: MaplebirchCore;
866
+ //#region src/infra/Logger.d.ts
867
+ type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
868
+ export declare class Logger {
869
+ readonly modloader?: ModLoader | undefined;
895
870
  private static readonly LEVELS;
896
871
  private static readonly CONFIG;
897
- private level;
898
- constructor(core: MaplebirchCore);
899
- fromIDB(): Promise<void>;
872
+ private static readonly FORWARD;
873
+ private static level;
874
+ constructor(modloader?: ModLoader | undefined);
875
+ static toLevel(level: string | number): LogLevel;
900
876
  log(message: string, levelName?: string | number, ...objects: unknown[]): void;
901
877
  set LevelName(levelName: string);
902
878
  get LevelName(): string;
903
879
  }
904
880
  //#endregion
905
- //#region src/services/EventEmitter.d.ts
906
- type EventCallback<Args extends unknown[] = unknown[]> = (...args: Args) => unknown;
907
- declare class EventEmitter {
908
- readonly core: MaplebirchCore;
909
- private readonly events;
910
- private readonly afters;
911
- private readonly triggering;
912
- private readonly stickyEvents;
913
- private readonly stickyArgs;
914
- private readonly synchronousEvents;
915
- constructor(core: MaplebirchCore);
916
- on<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>, description?: string): boolean;
917
- off<Args extends unknown[]>(eventName: string, identifier: EventCallback<Args> | string): boolean;
918
- once<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>, description?: string): boolean;
919
- trigger(eventName: string, ...args: unknown[]): Promise<void>;
920
- after<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>): void;
921
- private pending;
922
- private callSticky;
881
+ //#region src/infra/Diagnostics.d.ts
882
+ interface DiagnosticRecord {
883
+ at: string;
884
+ level: LogLevel;
885
+ scope?: string;
886
+ message: string;
887
+ data?: unknown;
923
888
  }
924
- //#endregion
889
+ interface PatchResult {
890
+ kind: 'passage' | 'script' | 'style' | 'source';
891
+ target: string;
892
+ index: number;
893
+ pattern: string;
894
+ matches: number;
895
+ applied: number;
896
+ status: 'applied' | 'unmatched' | 'missing' | 'invalid' | 'mismatch' | 'error';
897
+ expected?: number;
898
+ error?: string;
899
+ }
900
+ interface ModRequirement {
901
+ name: string;
902
+ range?: string;
903
+ version?: string;
904
+ status: 'available' | 'missing' | 'incompatible' | 'invalid';
905
+ error?: string;
906
+ }
907
+ interface ModConflict {
908
+ source: string;
909
+ dataSource: string;
910
+ passages: string[];
911
+ scripts: string[];
912
+ styles: string[];
913
+ }
914
+ type ScopedLog = (message: string, level?: string, ...objects: unknown[]) => void;
915
+ export declare class Diagnostics extends Logger {
916
+ readonly scope: string;
917
+ private static readonly entries;
918
+ private static readonly patchResults;
919
+ constructor(modloader?: ModLoader, scope?: string);
920
+ static message(error: unknown): string;
921
+ log(message: string, levelName?: string | number, ...objects: unknown[]): void;
922
+ record(message: string, level?: string, scope?: string, ...objects: unknown[]): void;
923
+ write(message: string, level?: string, scope?: string, ...objects: unknown[]): void;
924
+ scoped(scope: string): ScopedLog;
925
+ get history(): readonly DiagnosticRecord[];
926
+ get errors(): DiagnosticRecord[];
927
+ get patches(): PatchResult[];
928
+ recordPatch(result: PatchResult): void;
929
+ clearPatches(): void;
930
+ mod(name: string, range?: string): ModRequirement;
931
+ checkDependencies(): boolean;
932
+ get conflicts(): ModConflict[] | undefined;
933
+ export(): string;
934
+ clear(): void;
935
+ }
936
+ //#endregion
937
+ //#region src/host/Resources.d.ts
938
+ type ImageResult = string | false;
939
+ declare class Resources {
940
+ private readonly manager;
941
+ private readonly report;
942
+ private readonly cache;
943
+ private readonly pending;
944
+ constructor(manager: SC2DataManager, report: (path: string, error: unknown) => void);
945
+ normalize(path: string): string;
946
+ has(path: string): boolean | undefined;
947
+ load(path: string): ImageResult | Promise<ImageResult>;
948
+ clear(path?: string): void;
949
+ private resolve;
950
+ }
951
+ //#endregion
952
+ //#region src/host/ModLoader.d.ts
953
+ type Replacement = [RegExp, string];
954
+ type TwineAssetMode = 'append' | 'replace' | 'patch';
955
+ interface SourcePatch {
956
+ src?: string;
957
+ srcmatch?: RegExp;
958
+ srcmatchgroup?: RegExp;
959
+ to?: string;
960
+ applyafter?: string;
961
+ applybefore?: string;
962
+ expected?: number;
963
+ }
964
+ export declare class ModLoader {
965
+ readonly modSC2DataManager: SC2DataManager;
966
+ readonly modLoaderGui: Gui;
967
+ static getLodash(): ReturnType<ReturnType<SC2DataManager['getModUtils']>['getLodash']>;
968
+ readonly diagnostics: Diagnostics;
969
+ readonly resources: Resources;
970
+ constructor(modSC2DataManager: SC2DataManager, modLoaderGui: Gui);
971
+ replace(content: string, replacements: Replacement[], label?: string): string;
972
+ defineTwineAsset(type: 'script' | 'style', name: string, content: string | ((current: string) => string), mode?: TwineAssetMode): void;
973
+ disabled(modNames: string | string[], reload?: boolean): Promise<boolean>;
974
+ get modUtils(): ReturnType<SC2DataManager['getModUtils']>;
975
+ get modLoader(): ReturnType<SC2DataManager['getModLoader']>;
976
+ get loadController(): ReturnType<SC2DataManager['getModLoadController']>;
977
+ get dependence(): ReturnType<SC2DataManager['getDependenceChecker']>;
978
+ get conflict(): ReturnType<SC2DataManager['getConflictResult']>;
979
+ get lodash(): ReturnType<ReturnType<SC2DataManager['getModUtils']>['getLodash']>;
980
+ }
981
+ //#endregion
982
+ //#region src/host/SugarCube.d.ts
983
+ interface SaveObject {
984
+ state: {
985
+ history: DolStateMoment[];
986
+ index?: number;
987
+ [key: string]: unknown;
988
+ };
989
+ [key: string]: unknown;
990
+ }
991
+ export declare class Save {
992
+ private readonly state;
993
+ readonly details?: unknown;
994
+ readonly saveObj: SaveObject;
995
+ constructor(state: DolStateAPI, saveObj: unknown, details?: unknown);
996
+ get V(): Record<string, unknown>;
997
+ use<Result>(variables: Record<string, unknown>, callback: () => Result): Result;
998
+ }
999
+ export declare class SugarCube {
1000
+ runtime: TwineSugarCube | undefined;
1001
+ passage: Passage;
1002
+ require(): TwineSugarCube;
1003
+ save(saveObj: unknown, details?: unknown): Save;
1004
+ }
1005
+ //#endregion
1006
+ //#region src/infra/Emitter.d.ts
1007
+ type EventCallback<Args extends unknown[] = unknown[]> = (...args: Args) => unknown;
1008
+ export declare class Emitter extends Diagnostics {
1009
+ private readonly events;
1010
+ private readonly afters;
1011
+ private readonly triggering;
1012
+ private readonly stickyEvents;
1013
+ private readonly stickyArgs;
1014
+ private readonly synchronousEvents;
1015
+ on<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>, description?: string): boolean;
1016
+ off<Args extends unknown[]>(eventName: string, identifier: EventCallback<Args> | string): boolean;
1017
+ once<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>, description?: string): boolean;
1018
+ trigger(eventName: string, ...args: unknown[]): Promise<void>;
1019
+ after<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>): void;
1020
+ private pending;
1021
+ private callSticky;
1022
+ }
1023
+ //#endregion
925
1024
  //#region node_modules/idb/build/entry.d.ts
926
1025
  type KeyToKeyNoIndex<T> = { [K in keyof T]: string extends K ? never : number extends K ? never : K };
927
1026
  type ValuesOf<T> = T extends { [K in keyof T]: infer U } ? U : never;
@@ -1595,30 +1694,120 @@ interface IDBPCursorWithValueIteratorValue<
1595
1694
  continuePrimaryKey<T>(this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>): void;
1596
1695
  }
1597
1696
  //#endregion
1598
- //#region src/services/IndexedDBService.d.ts
1697
+ //#region src/infra/Catalog.d.ts
1698
+ export declare class Catalog<Key, Value> extends Diagnostics {
1699
+ protected readonly items: Map<Key, Value>;
1700
+ constructor(modloader?: ModLoader, entries?: Iterable<readonly [Key, Value]>);
1701
+ add(key: Key, value: Value): boolean;
1702
+ remove(key: Key): boolean;
1703
+ get(key: Key): Value | undefined;
1704
+ has(key: Key): boolean;
1705
+ list(): Value[];
1706
+ }
1707
+ //#endregion
1708
+ //#region src/services/IndexedDB.d.ts
1599
1709
  interface StoreIndex {
1600
1710
  name: string;
1601
1711
  keyPath: string | string[];
1602
1712
  options?: IDBIndexParameters;
1603
1713
  }
1714
+ interface StoreDefinition {
1715
+ options: IDBObjectStoreParameters;
1716
+ indexes: StoreIndex[];
1717
+ }
1604
1718
  type Transaction<Mode extends IDBTransactionMode = IDBTransactionMode> = IDBPTransaction<unknown, string[], Mode>;
1605
- declare class IndexedDBService {
1606
- readonly core: MaplebirchCore;
1719
+ export declare class IndexedDB extends Catalog<string, StoreDefinition> {
1607
1720
  static readonly DATABASE_NAME = 'maplebirch';
1608
1721
  static readonly DATABASE_VERSION: number;
1609
1722
  private db;
1610
1723
  private opening;
1611
- private readonly stores;
1612
- constructor(core: MaplebirchCore);
1613
- register(name: string, options?: IDBObjectStoreParameters, indexes?: StoreIndex[]): void;
1724
+ constructor(modloader?: ModLoader);
1725
+ define(name: string, options?: IDBObjectStoreParameters, indexes?: StoreIndex[]): boolean;
1726
+ loadLogLevel(): Promise<string | boolean | undefined>;
1614
1727
  init(): Promise<void>;
1615
1728
  private open;
1616
- withTransaction<T, Mode extends IDBTransactionMode>(storeNames: string | string[], mode: Mode, callback: (tx: Transaction<Mode>) => T | Promise<T>): Promise<T>;
1729
+ with<T, Mode extends IDBTransactionMode>(storeNames: string | string[], mode: Mode, callback: (tx: Transaction<Mode>) => T | Promise<T>): Promise<T>;
1617
1730
  clearStore(storeName: string): Promise<void>;
1618
1731
  deleteDatabase(): Promise<boolean>;
1619
1732
  }
1620
1733
  //#endregion
1621
- //#region src/services/CloudSaveService.d.ts
1734
+ //#region src/services/CredentialVault.d.ts
1735
+ type CredentialPeriod = 'day' | 'month';
1736
+ interface AuthConfig {
1737
+ key: string;
1738
+ subject?: string;
1739
+ name?: string;
1740
+ publicKey: JsonWebKey | string;
1741
+ prompt?: {
1742
+ title?: string;
1743
+ label?: string;
1744
+ placeholder?: string;
1745
+ hint?: string;
1746
+ };
1747
+ date?: {
1748
+ period?: CredentialPeriod;
1749
+ timezone?: string;
1750
+ graceDays?: number;
1751
+ };
1752
+ }
1753
+ interface AuthPayload {
1754
+ subject: string;
1755
+ key: string;
1756
+ date?: string;
1757
+ password: string;
1758
+ expiresAt?: number;
1759
+ }
1760
+ interface CryptContext {
1761
+ modName: string;
1762
+ credential?: string;
1763
+ payload?: AuthPayload;
1764
+ }
1765
+ interface CryptResult {
1766
+ data: Awaited<InputFileFormat>;
1767
+ auth?: AuthConfig | boolean | void;
1768
+ }
1769
+ interface CryptOptions {
1770
+ modName?: string;
1771
+ cache?: {
1772
+ subject: string;
1773
+ key: string;
1774
+ };
1775
+ password?: string;
1776
+ prompt?: AuthConfig['prompt'] & {
1777
+ name?: string;
1778
+ };
1779
+ lazyOptions?: unknown;
1780
+ decrypt(password: string, context: CryptContext): Promise<CryptResult | Awaited<InputFileFormat>>;
1781
+ }
1782
+ export declare class CredentialVault {
1783
+ readonly idb: IndexedDB;
1784
+ readonly modloader: ModLoader;
1785
+ readonly events: Emitter;
1786
+ readonly diagnostics: Diagnostics;
1787
+ readonly translate: (key: string) => string;
1788
+ private static readonly STORE;
1789
+ private static readonly TOKEN_PREFIX;
1790
+ private dialogQueue;
1791
+ private storageKey;
1792
+ constructor(idb: IndexedDB, modloader: ModLoader, events: Emitter, diagnostics: Diagnostics, translate: (key: string) => string);
1793
+ loadCrypt(options: CryptOptions): Promise<boolean>;
1794
+ private loadCredential;
1795
+ private decryptAndLoad;
1796
+ private decodeCredential;
1797
+ private verify;
1798
+ private credentialDate;
1799
+ private readStored;
1800
+ private storeStored;
1801
+ private forget;
1802
+ private ensurePromptStyle;
1803
+ private promptCredential;
1804
+ private ensureStorageKey;
1805
+ private loadStorageKey;
1806
+ private encryptRecord;
1807
+ private decryptRecord;
1808
+ }
1809
+ //#endregion
1810
+ //#region src/services/CloudSave.d.ts
1622
1811
  type CloudSaveSlot = number;
1623
1812
  type PanelAction = 'connectRemote' | 'uploadSlot' | 'downloadSlot' | 'refreshRemoteList' | 'deleteRemoteSlot' | 'exportCurrentCode' | 'exportSlotCode' | 'uploadCode' | 'downloadCode' | 'importCode';
1624
1813
  interface CloudSaveConfig {
@@ -1662,14 +1851,23 @@ interface SaveState {
1662
1851
  delta?: unknown;
1663
1852
  [key: string]: unknown;
1664
1853
  }
1665
- declare class CloudSaveService {
1666
- readonly core: MaplebirchCore;
1854
+ interface CloudSaveTools {
1855
+ isPlainObject(value: unknown): value is Record<string, unknown>;
1856
+ isFinite(value: unknown): boolean;
1857
+ isInteger(value: unknown): boolean;
1858
+ inRange(value: number, start: number, end: number): boolean;
1859
+ }
1860
+ export declare class CloudSave {
1861
+ readonly sugarcube: SugarCube;
1862
+ readonly translate: (key: string) => string;
1863
+ readonly tools: CloudSaveTools;
1864
+ readonly diagnostics: Diagnostics;
1667
1865
  private static readonly PANEL_STORAGE_KEY;
1668
1866
  private static readonly REQUEST_TIMEOUT;
1669
1867
  private config;
1670
1868
  private mountFrame;
1671
1869
  private busy;
1672
- constructor(core: MaplebirchCore);
1870
+ constructor(sugarcube: SugarCube, translate: (key: string) => string, tools: CloudSaveTools, diagnostics: Diagnostics);
1673
1871
  configure(config: CloudSaveConfig): this;
1674
1872
  /** 验证 Worker 与 Token 是否可用。 */
1675
1873
  connect(): Promise<void>;
@@ -1730,7 +1928,18 @@ declare class CloudSaveService {
1730
1928
  private get token();
1731
1929
  }
1732
1930
  //#endregion
1733
- //#region src/services/LanguageManager.d.ts
1931
+ //#region src/constants.d.ts
1932
+ type LanguageCode = (typeof Languages)[number];
1933
+ declare const Languages: readonly ['EN', 'CN'];
1934
+ declare enum ModuleState {
1935
+ REGISTERED = 0,
1936
+ MOUNTED = 1,
1937
+ ERROR = 2,
1938
+ EXPOSED = 3,
1939
+ DISABLED = 4
1940
+ }
1941
+ //#endregion
1942
+ //#region src/services/Translator.d.ts
1734
1943
  type Translation = Record<string, string>;
1735
1944
  interface ImportProgress {
1736
1945
  type: 'process' | 'complete' | 'error' | 'not_found';
@@ -1741,21 +1950,25 @@ interface ImportProgress {
1741
1950
  count?: number;
1742
1951
  error?: Error | null;
1743
1952
  }
1744
- declare class LanguageManager {
1745
- readonly core: MaplebirchCore;
1953
+ interface TranslationAddon {
1954
+ hook<T>(name: string, handler: (task: { modName: string; config: T }) => void | Promise<void>): boolean;
1955
+ }
1956
+ export declare class Translator extends Catalog<string, Translation> {
1957
+ readonly idb: IndexedDB;
1958
+ readonly events: Emitter;
1959
+ private readonly addon;
1746
1960
  static readonly DEFAULT_LANGS: readonly LanguageCode[];
1747
1961
  static readonly BATCH_SIZE = 500;
1748
1962
  language: LanguageCode;
1749
1963
  private readonly STORE;
1750
- private readonly translations;
1751
1964
  private readonly cache;
1752
1965
  private readonly sourceOrders;
1753
1966
  private preloaded;
1754
- constructor(core: MaplebirchCore);
1967
+ constructor(idb: IndexedDB, modloader: ModLoader, events: Emitter, addon: () => TranslationAddon | undefined);
1755
1968
  private initDB;
1756
1969
  setLanguage(language?: string): Promise<LanguageCode>;
1757
1970
  import(modName: string, languages?: readonly LanguageCode[]): AsyncGenerator<ImportProgress>;
1758
- importFile(modName: string, language: LanguageCode, path: string): AsyncGenerator<ImportProgress>;
1971
+ importFile(modName: string, language: LanguageCode, paths: string | readonly string[]): AsyncGenerator<ImportProgress>;
1759
1972
  t(translationKey: string, space?: boolean): string;
1760
1973
  auto(text: string): string;
1761
1974
  has(translationKey: string): boolean;
@@ -1779,10 +1992,33 @@ declare class LanguageManager {
1779
1992
  private rebuild;
1780
1993
  }
1781
1994
  //#endregion
1782
- //#region src/services/ModuleSystem.d.ts
1995
+ //#region src/infra/Lifecycle.d.ts
1996
+ type LifecyclePhase = 'preInit' | 'Init' | 'loadInit' | 'postInit';
1997
+ interface LifecycleTarget {
1998
+ preInit?(): void | Promise<void>;
1999
+ Init?(): void;
2000
+ loadInit?(): void;
2001
+ postInit?(): void;
2002
+ }
2003
+ interface LifecycleResult {
2004
+ called: boolean;
2005
+ ok: boolean;
2006
+ error?: unknown;
2007
+ }
2008
+ export declare class Lifecycle<Key = string, Target extends LifecycleTarget = LifecycleTarget> extends Catalog<Key, Target> {
2009
+ preInit(): void | Promise<void>;
2010
+ Init(): void;
2011
+ loadInit(): void;
2012
+ postInit(): void;
2013
+ execute(target: Target, phase: LifecyclePhase, scope?: string): Promise<LifecycleResult>;
2014
+ executeSync(target: Target, phase: Exclude<LifecyclePhase, 'preInit'>, scope?: string): LifecycleResult;
2015
+ }
2016
+ //#endregion
2017
+ //#region src/services/Modules.d.ts
1783
2018
  interface Module {
2019
+ log?: ScopedLog;
1784
2020
  dependencies?: string[];
1785
- exposed?: boolean;
2021
+ exposed?: boolean | 'window';
1786
2022
  preInit?(): void | Promise<void>;
1787
2023
  Init?(): void;
1788
2024
  loadInit?(): void;
@@ -1798,7 +2034,6 @@ interface ModuleRegistry {
1798
2034
  interface DependencyInfo {
1799
2035
  protected: boolean;
1800
2036
  mounted: boolean;
1801
- early: boolean;
1802
2037
  exposed: boolean;
1803
2038
  lifecycle: boolean;
1804
2039
  dependencies: string[];
@@ -1808,8 +2043,14 @@ interface DependencyInfo {
1808
2043
  source: string;
1809
2044
  }
1810
2045
  type DependencyGraph = Record<string, DependencyInfo>;
1811
- declare class ModuleSystem {
1812
- readonly core: MaplebirchCore;
2046
+ interface ModulesMeta {
2047
+ core: readonly string[];
2048
+ protected: readonly string[];
2049
+ }
2050
+ export declare class Modules extends Lifecycle<string, Module> {
2051
+ readonly owner: Record<string, unknown>;
2052
+ readonly meta: ModulesMeta;
2053
+ readonly idb: IndexedDB;
1813
2054
  readonly registry: ModuleRegistry;
1814
2055
  readonly initPhase: {
1815
2056
  preInitCompleted: boolean;
@@ -1822,7 +2063,7 @@ declare class ModuleSystem {
1822
2063
  private late;
1823
2064
  private preRunning;
1824
2065
  private preQueued;
1825
- constructor(core: MaplebirchCore);
2066
+ constructor(owner: Record<string, unknown>, meta: ModulesMeta, idb: IndexedDB, modloader?: ModLoader);
1826
2067
  static traverse(roots: Iterable<string>, links: ReadonlyMap<string, Iterable<string>>, excluded?: ReadonlySet<string>): Set<string>;
1827
2068
  with<T>(source: string, callback: () => T | Promise<T>): Promise<T>;
1828
2069
  register<T extends object>(name: string, module: T & Module, dependencies?: string[]): boolean;
@@ -1830,20 +2071,18 @@ declare class ModuleSystem {
1830
2071
  get dependencyGraph(): DependencyGraph;
1831
2072
  run(phase: 'pre'): Promise<void>;
1832
2073
  run(phase: 'init' | 'load' | 'post'): void;
1833
- private preInit;
2074
+ private prepare;
1834
2075
  private queuePre;
1835
2076
  private disable;
1836
2077
  private pre;
1837
2078
  private init;
1838
2079
  private phase;
1839
- private callHook;
1840
2080
  private ready;
1841
- private flushEarly;
2081
+ private flush;
1842
2082
  private topologicalOrder;
1843
2083
  private collect;
1844
2084
  private circular;
1845
- private lifecycle;
1846
- private promiseLike;
2085
+ private hasLifecycle;
1847
2086
  }
1848
2087
  //#endregion
1849
2088
  //#region src/services/GUIControl.d.ts
@@ -1860,14 +2099,25 @@ interface ModulesSettings {
1860
2099
  enabled: ModuleInfo[];
1861
2100
  disabled: ModuleInfo[];
1862
2101
  }
1863
- declare class GUIControl {
1864
- readonly core: MaplebirchCore;
2102
+ interface ScriptSource {
2103
+ jsFiles: Array<{
2104
+ modName: string;
2105
+ filePath: string;
2106
+ }>;
2107
+ }
2108
+ export declare class GUIControl {
2109
+ readonly idb: IndexedDB;
2110
+ readonly modloader: ModLoader;
2111
+ readonly events: Emitter;
2112
+ readonly modules: Modules;
2113
+ readonly translator: Translator;
2114
+ private readonly addon;
1865
2115
  enabledModules: ModuleInfo[];
1866
2116
  disabledModules: ModuleInfo[];
1867
2117
  enabledScripts: string[];
1868
2118
  disabledScripts: string[];
1869
2119
  private modSubUiAngularJsService;
1870
- constructor(core: MaplebirchCore);
2120
+ constructor(idb: IndexedDB, modloader: ModLoader, events: Emitter, modules: Modules, translator: Translator, addon: () => ScriptSource | undefined);
1871
2121
  private initSettings;
1872
2122
  init(): Promise<void>;
1873
2123
  private loadSettings;
@@ -1877,6 +2127,7 @@ declare class GUIControl {
1877
2127
  private modulesStore;
1878
2128
  private scriptsStore;
1879
2129
  saveModules(enabled: ModuleInfo[], disabled: ModuleInfo[]): Promise<void>;
2130
+ setModuleStates(states: Readonly<Record<string, boolean>>): Promise<boolean>;
1880
2131
  saveScripts(enabled: string[], disabled: string[]): Promise<void>;
1881
2132
  cascadeModules(action: 'enable' | 'disable', moduleName: string, modules: ModulesSettings): string[];
1882
2133
  private moduleLinks;
@@ -1884,169 +2135,245 @@ declare class GUIControl {
1884
2135
  private whenCreate;
1885
2136
  }
1886
2137
  //#endregion
1887
- //#region src/modules/Addon/Save.d.ts
1888
- interface SaveObject {
1889
- state: {
1890
- history: DolStateMoment[];
1891
- index?: number;
1892
- [key: string]: unknown;
1893
- };
1894
- [key: string]: unknown;
1895
- }
1896
- declare class Save {
1897
- private readonly state;
1898
- readonly details?: unknown;
1899
- readonly saveObj: SaveObject;
1900
- constructor(state: DolStateAPI, saveObj: unknown, details?: unknown);
1901
- get V(): Record<string, unknown>;
1902
- use<T>(variables: Record<string, unknown>, callback: () => T): T;
2138
+ //#region src/infra/Hooks.d.ts
2139
+ type HookCallback<Args extends unknown[] = unknown[], Result = unknown> = (...args: Args) => Result | Promise<Result>;
2140
+ export declare class Hooks<Args extends unknown[] = unknown[], Result = unknown> extends Catalog<string, HookCallback<Args, Result>> {
2141
+ private readonly order;
2142
+ constructor(modloader?: ModLoader);
2143
+ add(name: string, callback: HookCallback<Args, Result>, order?: number): boolean;
2144
+ remove(name: string): boolean;
2145
+ execute(...args: Args): Promise<Awaited<Result>[]>;
2146
+ call(name: string, ...args: Args): Promise<Awaited<Result> | undefined>;
1903
2147
  }
1904
2148
  //#endregion
1905
- //#region src/modules/TimeStateWeather/Event.d.ts
1906
- interface EventOptions {
1907
- priority?: number;
1908
- once?: boolean;
1909
- }
1910
- declare abstract class Event {
1911
- readonly id: string;
1912
- readonly priority: number;
1913
- readonly once: boolean;
1914
- protected abstract readonly eventName: string;
1915
- protected constructor(id: string, options?: EventOptions);
1916
- protected evaluate<T extends unknown[]>(label: string, callback: (...args: T) => boolean, ...args: T): boolean;
1917
- protected invoke<T extends unknown[]>(label: string, callback: ((...args: T) => void) | undefined, ...args: T): void;
2149
+ //#region src/services/AddonPlugin.d.ts
2150
+ interface FileItem {
2151
+ modName: string;
2152
+ filePath: string;
2153
+ content: string;
1918
2154
  }
1919
- //#endregion
1920
- //#region src/modules/TimeStateWeather/TimeEvents.d.ts
1921
- type TimeEventType = 'onSec' | 'onMin' | 'onHour' | 'onDay' | 'onWeek' | 'onMonth' | 'onYear' | 'onBefore' | 'onThread' | 'onAfter' | 'onTimeTravel';
1922
- type TimeUnit = 'sec' | 'min' | 'hour' | 'day' | 'week' | 'month' | 'year';
1923
- interface AccumulateConfig {
1924
- unit: TimeUnit;
1925
- target?: number;
2155
+ interface BootTask<T = unknown> {
2156
+ modName: string;
2157
+ modInfo: ModInfo;
2158
+ modZip: ModZipReader;
2159
+ config: T;
1926
2160
  }
1927
- interface TimeData {
1928
- prevDate?: DateTime;
1929
- currentDate?: DateTime;
1930
- changes?: Record<TimeUnit, number>;
1931
- triggeredByAccumulator?: {
1932
- unit: TimeUnit;
1933
- target: number;
1934
- count: number;
1935
- };
1936
- exactPoints?: {
1937
- min: boolean;
1938
- hour: boolean;
1939
- day: boolean;
1940
- week: boolean;
1941
- month: boolean;
1942
- year: boolean;
1943
- };
1944
- passed?: number;
1945
- sec?: number;
1946
- min?: number;
1947
- hour?: number;
1948
- day?: number;
1949
- week?: number;
1950
- month?: number;
1951
- year?: number;
1952
- weekday?: [number, number];
1953
- detailedDiff?: ReturnType<DateTime['compareWith']>;
1954
- timeStamp?: number;
1955
- prev?: DateTime;
1956
- current?: DateTime;
1957
- diffSeconds?: number;
1958
- direction?: 'forward' | 'backward';
1959
- isLeap?: boolean;
2161
+ type BootHandler<T = unknown> = (task: BootTask<T>) => void | Promise<void>;
2162
+ interface AddonServices {
2163
+ translator(): Translator;
2164
+ gui(): GUIControl;
2165
+ credential(): CredentialVault;
2166
+ }
2167
+ export declare class AddonPlugin extends Hooks<[BootTask], void> {
2168
+ readonly sugarcube: SugarCube;
2169
+ readonly events: Emitter;
2170
+ readonly idb: IndexedDB;
2171
+ readonly modules: Modules;
2172
+ private readonly services;
2173
+ onStart: boolean;
2174
+ get resources(): Resources;
2175
+ replace(content: string, replacements: Replacement[], label?: string): string;
2176
+ readonly info: Catalog<
2177
+ string,
2178
+ {
2179
+ addonName: string;
2180
+ mod: ModInfo;
2181
+ modZip: ModZipReader;
2182
+ }
2183
+ >;
2184
+ readonly modList: string[];
2185
+ readonly jsFiles: FileItem[];
2186
+ readonly moduleFiles: FileItem[];
2187
+ private readonly disabledMods;
2188
+ readonly blockedPassages: Set<string>;
2189
+ readonly excludedMods: Set<string>;
2190
+ private readonly bootQueue;
2191
+ private onSaveLoadTracer;
2192
+ private moduleFilesExecuted;
2193
+ private scriptFilesExecuted;
2194
+ private bootReady;
2195
+ constructor(modloader: ModLoader, sugarcube: SugarCube, events: Emitter, idb: IndexedDB, modules: Modules, services: AddonServices);
2196
+ get SC2DataManager(): SC2DataManager;
2197
+ get modUtils(): ModUtils;
2198
+ wikify(name: string, callbacks: WikifyTracerCallback): void;
2199
+ hook<T>(name: string, handler: BootHandler<T>): boolean;
2200
+ canLoadThisMod(bootJson: ModBootJson, _zip: JSZipLikeReadOnlyInterface): Promise<boolean>;
2201
+ afterInjectEarlyLoad(): Promise<void>;
2202
+ ModLoaderLoadEnd(): Promise<void>;
2203
+ afterEarlyLoad(): Promise<void>;
2204
+ registerMod(addonName: string, modInfo: ModInfo, modZip: ModZipReader): Promise<void>;
2205
+ afterRegisterMod2Addon(): Promise<void>;
2206
+ beforePatchModToGame(): Promise<void>;
2207
+ PatchModToGame_start(): Promise<void>;
2208
+ afterPatchModToGame(): Promise<void>;
2209
+ afterPreload(): Promise<void>;
2210
+ whenSC2StoryReady(): Promise<void>;
2211
+ whenSC2PassageInit(passage: Passage): Promise<void>;
2212
+ whenSC2PassageStart(passage: Passage, content: HTMLDivElement): Promise<void>;
2213
+ whenSC2PassageRender(passage: Passage, content: HTMLDivElement): Promise<void>;
2214
+ whenSC2PassageDisplay(passage: Passage, content: HTMLDivElement): Promise<void>;
2215
+ whenSC2PassageEnd(passage: Passage, content: HTMLDivElement): Promise<void>;
2216
+ loadCrypt(options: CryptOptions): Promise<boolean>;
2217
+ private scriptFiles;
2218
+ private loadFiles;
2219
+ private executeScripts;
2220
+ private process;
2221
+ private queue;
2222
+ private flush;
2223
+ private run;
2224
+ private config;
1960
2225
  }
1961
- interface TimeEventOptions extends EventOptions {
1962
- action?: (data: TimeData) => void;
1963
- cond?: (data: TimeData) => boolean;
1964
- accumulate?: AccumulateConfig;
1965
- exact?: boolean;
2226
+ //#endregion
2227
+ //#region src/core.d.ts
2228
+ declare global {
2229
+ interface MaplebirchExtensions {}
1966
2230
  }
1967
- interface TimeTravelOptions {
1968
- target?: DateTime;
1969
- year?: number;
1970
- month?: number;
1971
- day?: number;
1972
- hour?: number;
1973
- minute?: number;
1974
- second?: number;
1975
- addYears?: number;
1976
- addMonths?: number;
1977
- addDays?: number;
1978
- addHours?: number;
1979
- addMinutes?: number;
1980
- addSeconds?: number;
2231
+ interface Extensions extends MaplebirchExtensions {}
2232
+ interface CoreEvents {
2233
+ ':indexedDB': [];
2234
+ ':idbReady': [];
2235
+ ':import': [];
2236
+ ':variable': [];
2237
+ ':onSave': [save: Save];
2238
+ ':onLoad': [save: Save];
2239
+ ':language': [];
2240
+ ':storyready': [];
2241
+ ':passageinit': [passage: Passage];
2242
+ ':passagestart': [passage: Passage, content: HTMLDivElement];
2243
+ ':passagerender': [passage: Passage, content: HTMLDivElement];
2244
+ ':passagedisplay': [passage: Passage, content: HTMLDivElement];
2245
+ ':passageend': [passage: Passage, content: HTMLDivElement];
2246
+ ':sugarcube': [];
2247
+ ':modLoaderEnd': [];
1981
2248
  }
1982
- declare class TimeEvent extends Event {
1983
- readonly type: TimeEventType;
1984
- protected readonly eventName = 'TimeEvent';
1985
- private action?;
1986
- private cond;
1987
- private exact;
1988
- private accumulate?;
1989
- private accumulated;
1990
- private target;
1991
- constructor(id: string, type: TimeEventType, options?: TimeEventOptions);
1992
- tryRun(data: TimeData, accumulatedOnly?: boolean): boolean;
1993
- private runAccumulated;
1994
- private execute;
1995
- private match;
1996
- private runAction;
1997
- private isExactPoint;
2249
+ interface FrameworkHost {
2250
+ readonly sugarcube: SugarCube;
2251
+ readonly modLoader: ModLoader;
1998
2252
  }
1999
- declare class TimeManager {
2000
- private readonly manager;
2001
- private readonly eventTypes;
2002
- private readonly timeEvents;
2003
- private readonly sortedEventsCache;
2004
- readonly log: DynamicManager['log'];
2005
- readonly TimeConstants: Readonly<{
2006
- secondsPerDay: 86400;
2007
- secondsPerHour: 3600;
2008
- secondsPerMinute: 60;
2009
- minutesPerHour: 60;
2010
- standardYearMonths: readonly number[];
2011
- leapYearMonths: readonly number[];
2012
- synodicMonth: 29.53058867;
2013
- MIN_DATE: Readonly<{
2014
- timeStamp: -315537984000;
2015
- year: -9999;
2016
- month: 1;
2017
- day: 1;
2018
- hour: 0;
2019
- minute: 0;
2020
- second: 0;
2253
+ interface FrameworkInfra {
2254
+ readonly diagnostics: Diagnostics;
2255
+ readonly events: Emitter;
2256
+ }
2257
+ interface FrameworkServices {
2258
+ readonly indexedDB: IndexedDB;
2259
+ readonly modules: Modules;
2260
+ readonly addonPlugin: AddonPlugin;
2261
+ readonly translator: Translator;
2262
+ readonly credentialVault: CredentialVault;
2263
+ readonly cloudSave: CloudSave;
2264
+ readonly gui: GUIControl;
2265
+ }
2266
+ type MaplebirchCore = InstanceType<typeof MaplebirchCore> & Extensions;
2267
+ declare const MaplebirchCore: {
2268
+ new (
2269
+ modSC2DataManager: SC2DataManager,
2270
+ modLoaderGui: Gui
2271
+ ): {
2272
+ readonly meta: {
2273
+ name: 'maplebirch Frameworks';
2274
+ author: string;
2275
+ version: string;
2276
+ modifiedby: string;
2277
+ updateDate: string;
2278
+ Languages: readonly ['EN', 'CN'];
2279
+ core: readonly string[];
2280
+ protected: readonly string[];
2281
+ };
2282
+ readonly host: Readonly<FrameworkHost>;
2283
+ readonly infra: Readonly<FrameworkInfra>;
2284
+ readonly services: Readonly<FrameworkServices>;
2285
+ readonly utils: Readonly<{
2286
+ clone: typeof clone;
2287
+ equal: typeof equal;
2288
+ merge: typeof merge;
2289
+ append: typeof append;
2290
+ cover: typeof cover;
2291
+ mergefn: typeof mergeFn;
2292
+ appendfn: typeof appendFn;
2293
+ coverfn: typeof coverFn;
2294
+ contains: typeof contains;
2295
+ random: typeof randomNumber;
2296
+ either: typeof randomPick;
2297
+ SelectCase: typeof SelectCase;
2298
+ convert: typeof convert;
2299
+ clamp: typeof clamp;
2021
2300
  }>;
2022
- MAX_DATE: Readonly<{
2023
- timeStamp: 315537897599;
2024
- year: 9999;
2025
- month: 12;
2026
- day: 31;
2027
- hour: 23;
2028
- minute: 59;
2029
- second: 59;
2301
+ readonly yaml: Readonly<typeof jsyaml>;
2302
+ readonly howler: Readonly<{
2303
+ Howl: typeof Howl;
2304
+ Howler: HowlerGlobal;
2030
2305
  }>;
2031
- }>;
2032
- constructor(manager: DynamicManager);
2033
- get events(): Readonly<Record<string, ReadonlyMap<string, TimeEvent>>>;
2034
- init(): void;
2035
- patchDateTime(DateTimeClass: typeof DateTime): typeof DateTime;
2036
- patchTime(TimeObject: typeof Time): void;
2037
- register(type: TimeEventType, eventId: string, options: TimeEventOptions): boolean;
2038
- unregister(type: string, eventId: string): boolean;
2039
- timeTravel(options?: TimeTravelOptions): boolean;
2040
- updateTimeLanguage(choice?: 'JournalTime'): string | boolean;
2041
- private handleTimePass;
2042
- private handleTimeTravel;
2043
- private targetDate;
2044
- private timeData;
2045
- private triggerUnitEvents;
2046
- private trigger;
2306
+ log(message: string, level?: string, ...objects: unknown[]): void;
2307
+ get export(): string;
2308
+ get passage(): Passage;
2309
+ set passage(passage: Passage);
2310
+ get SugarCube(): TwineSugarCube;
2311
+ set SugarCube(runtime: TwineSugarCube);
2312
+ get modUtils(): ReturnType<SC2DataManager['getModUtils']>;
2313
+ get modLoader(): ReturnType<SC2DataManager['getModLoader']>;
2314
+ get lodash(): ModLoader['lodash'];
2315
+ get marked(): typeof marked;
2316
+ get Language(): string;
2317
+ set Language(language: string);
2318
+ get LogLevel(): string;
2319
+ set LogLevel(level: string);
2320
+ get dependencyGraph(): DependencyGraph;
2321
+ on<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>, description?: string): boolean;
2322
+ on<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>, description?: string): boolean;
2323
+ off<Args extends unknown[]>(eventName: string, identifier: string | EventCallback<Args>): boolean;
2324
+ once<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>, description?: string): boolean;
2325
+ once<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>, description?: string): boolean;
2326
+ after<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>): void;
2327
+ after<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>): void;
2328
+ trigger<Name extends keyof CoreEvents>(eventName: Name, ...args: CoreEvents[Name]): Promise<void>;
2329
+ trigger<Name extends string>(eventName: Name extends keyof CoreEvents ? never : Name, ...args: unknown[]): Promise<void>;
2330
+ define<T extends object>(name: string, module: T & Module, dependencies?: string[]): boolean;
2331
+ wikify(name: string, callbacks: WikifyTracerCallback): void;
2332
+ idb(name: string, options?: IDBObjectStoreParameters, indexes?: StoreIndex[]): boolean;
2333
+ with<T, Mode extends IDBTransactionMode>(storeNames: string | string[], mode: Mode, callback: (tx: Transaction<Mode>) => T | Promise<T>): Promise<T>;
2334
+ t(key: string, space?: boolean): string;
2335
+ auto(text: string): string;
2336
+ get<K extends keyof Extensions>(name: K): Extensions[K] | undefined;
2337
+ get(name: string): Module | undefined;
2338
+ };
2339
+ meta: {
2340
+ name: 'maplebirch Frameworks';
2341
+ author: string;
2342
+ version: string;
2343
+ modifiedby: string;
2344
+ updateDate: string;
2345
+ Languages: readonly ['EN', 'CN'];
2346
+ core: readonly string[];
2347
+ protected: readonly string[];
2348
+ };
2349
+ };
2350
+ declare var maplebirch: MaplebirchCore;
2351
+ //#endregion
2352
+ //#region src/modules/Dynamic.d.ts
2353
+ declare class Dynamic extends Lifecycle<string, LifecycleTarget> {
2354
+ readonly core: MaplebirchCore;
2355
+ readonly log: ScopedLog;
2356
+ constructor(core: MaplebirchCore);
2357
+ Init(): void;
2047
2358
  }
2048
2359
  //#endregion
2049
- //#region src/modules/TimeStateWeather/StateEvents.d.ts
2360
+ //#region src/modules/Event.d.ts
2361
+ interface EventOptions {
2362
+ priority?: number;
2363
+ once?: boolean;
2364
+ }
2365
+ declare abstract class Event {
2366
+ readonly id: string;
2367
+ protected readonly log: ScopedLog;
2368
+ readonly priority: number;
2369
+ readonly once: boolean;
2370
+ protected abstract readonly eventName: string;
2371
+ protected constructor(id: string, options: EventOptions, log: ScopedLog);
2372
+ protected evaluate<T extends unknown[]>(label: string, callback: (...args: T) => boolean, ...args: T): boolean;
2373
+ protected invoke<T extends unknown[]>(label: string, callback: ((...args: T) => void) | undefined, ...args: T): void;
2374
+ }
2375
+ //#endregion
2376
+ //#region src/modules/State.d.ts
2050
2377
  interface StateEventOptions extends EventOptions {
2051
2378
  output?: string;
2052
2379
  action?: () => void;
@@ -2070,121 +2397,27 @@ declare class StateEvent extends Event {
2070
2397
  private cond;
2071
2398
  private forceExit;
2072
2399
  private extra;
2073
- constructor(id: string, type: 'gate' | 'append', options?: StateEventOptions);
2400
+ constructor(id: string, type: 'gate' | 'append', options: StateEventOptions, log: Dynamic['log']);
2074
2401
  private checkPassage;
2075
2402
  tryRun(passageName?: string): StateEventResult | null;
2076
2403
  private match;
2077
2404
  private runAction;
2078
2405
  shouldForceExit(): boolean;
2079
2406
  }
2080
- declare class StateManager {
2407
+ export declare class StateManager {
2081
2408
  private readonly manager;
2082
2409
  private readonly stateEvents;
2083
2410
  private readonly log;
2084
- constructor(manager: DynamicManager);
2411
+ constructor(manager: Dynamic);
2085
2412
  get events(): Readonly<Record<'gate' | 'append', ReadonlyMap<string, StateEvent>>>;
2086
2413
  trigger(type: 'gate' | 'append'): string;
2087
2414
  private processGateEvents;
2088
2415
  private processAppendEvents;
2089
2416
  register(type: 'gate' | 'append', eventId: string, options: StateEventOptions): boolean;
2090
2417
  unregister(type: 'gate' | 'append', eventId: string): boolean;
2091
- init(): void;
2092
- }
2093
- //#endregion
2094
- //#region src/modules/TimeStateWeather/WeatherEvents.d.ts
2095
- interface WeatherEventOptions extends EventOptions {
2096
- condition?: () => boolean;
2097
- onEnter?: () => void;
2098
- onExit?: () => void;
2099
- [key: string]: any;
2100
- }
2101
- interface WeatherTypeConfig {
2102
- name: string;
2103
- iconType?: string | (() => string);
2104
- value: number;
2105
- probability: {
2106
- summer: number;
2107
- winter: number;
2108
- spring: number;
2109
- autumn: number;
2110
- };
2111
- cloudCount: {
2112
- small: () => number;
2113
- large: () => number;
2114
- };
2115
- tanningModifier: number;
2116
- overcast: number | (() => number);
2117
- precipitationIntensity: number;
2118
- visibility: number;
2119
- }
2120
- interface WeatherException {
2121
- date: () => DateTime;
2122
- duration: number;
2123
- weatherType: string;
2124
- temperature?: number;
2125
- }
2126
- declare class WeatherManager {
2127
- private readonly manager;
2128
- private readonly weatherEvents;
2129
- private readonly activeEvents;
2130
- private sortedEventsCache;
2131
- private readonly Exceptions;
2132
- private readonly WeatherTypes;
2133
- private readonly layerModifications;
2134
- private readonly effectModifications;
2135
- private weatherTriggered;
2136
- private readonly log;
2137
- constructor(manager: DynamicManager);
2138
- private checkEvents;
2139
- register(eventId: string, options: WeatherEventOptions): boolean;
2140
- unregister(eventId: string): boolean;
2141
- addLayer(layerName: string, patch: any, mode?: 'concat' | 'replace' | 'merge'): this;
2142
- addEffect(effectName: string, patch: any, mode?: 'concat' | 'replace' | 'merge'): this;
2143
- applyModifications(params: any): any;
2144
- addWeatherData(data: WeatherException | WeatherTypeConfig): boolean | void;
2145
- init(): void;
2146
- modifyWeatherJavaScript(manager: AddonPlugin): void;
2147
- }
2148
- //#endregion
2149
- //#region src/modules/Dynamic.d.ts
2150
- declare class DynamicManager {
2151
- readonly core: MaplebirchCore;
2152
- readonly Time: TimeManager;
2153
- readonly State: StateManager;
2154
- readonly Weather: WeatherManager;
2155
- readonly log: ReturnType<typeof createlog>;
2156
- constructor(core: MaplebirchCore);
2157
- regTimeEvent(type: TimeEventType, eventId: string, options: TimeEventOptions): boolean;
2158
- delTimeEvent(type: TimeEventType, eventId: string): boolean;
2159
- timeTravel(options?: TimeTravelOptions): boolean;
2160
- get TimeEvents(): TimeManager['events'];
2161
- regStateEvent(type: 'gate' | 'append', eventId: string, options: StateEventOptions): boolean;
2162
- delStateEvent(type: 'gate' | 'append', eventId: string): boolean;
2163
- trigger(type: 'gate' | 'append'): string;
2164
- get StateEvents(): StateManager['events'];
2165
- regWeatherEvent(eventId: string, options: WeatherEventOptions): boolean;
2166
- delWeatherEvent(eventId: string): boolean;
2167
- addWeather(data: WeatherException | WeatherTypeConfig): boolean | void;
2168
2418
  Init(): void;
2169
2419
  }
2170
2420
  //#endregion
2171
- //#region src/modules/Frameworks/TimeTravelCheat.d.ts
2172
- declare class TimeTravelCheat {
2173
- private readonly core;
2174
- private readonly ids;
2175
- constructor(core: MaplebirchCore);
2176
- fragment(): DocumentFragment;
2177
- private createRoot;
2178
- private bind;
2179
- private render;
2180
- private fieldInput;
2181
- private setFields;
2182
- private readFields;
2183
- private syncDayLimit;
2184
- private travel;
2185
- private status;
2186
- }
2187
- //#endregion
2188
2421
  //#region src/modules/Frameworks/ConsoleCheat.d.ts
2189
2422
  interface JSExecutionResult {
2190
2423
  success: boolean;
@@ -2214,7 +2447,6 @@ declare class CheatConsole {
2214
2447
  private readonly log;
2215
2448
  private readonly core;
2216
2449
  private readonly globals;
2217
- readonly timeTravel: TimeTravelCheat;
2218
2450
  private readonly jsStatus;
2219
2451
  private readonly twineStatus;
2220
2452
  private readonly twineOutputs;
@@ -2240,7 +2472,7 @@ interface PathRef {
2240
2472
  key: string;
2241
2473
  }
2242
2474
  interface Utils {
2243
- readonly log: ReturnType<typeof createlog>;
2475
+ readonly log: ScopedLog;
2244
2476
  path: (obj: Record<string, unknown>, path: string, create?: boolean) => PathRef | null;
2245
2477
  move: (data: Record<string, unknown>, from: string, to: string) => boolean;
2246
2478
  remove: (data: Record<string, unknown>, path: string) => boolean;
@@ -2248,9 +2480,9 @@ interface Utils {
2248
2480
  fill: (target: Record<string, unknown>, defaults: Record<string, unknown>, mode?: 'merge' | 'cover') => void;
2249
2481
  }
2250
2482
  declare class migration {
2251
- static readonly log: (message: string, level?: string, ...objects: unknown[]) => void;
2483
+ static readonly log: ScopedLog;
2252
2484
  static create(): migration;
2253
- readonly log: (message: string, level?: string, ...objects: unknown[]) => void;
2485
+ readonly log: ScopedLog;
2254
2486
  readonly utils: Utils;
2255
2487
  steps: Step[];
2256
2488
  private readonly unsafeKeys;
@@ -2269,9 +2501,9 @@ interface RandState {
2269
2501
  index: number;
2270
2502
  }
2271
2503
  declare class randSystem {
2272
- static readonly log: (message: string, level?: string, ...objects: unknown[]) => void;
2504
+ static readonly log: ScopedLog;
2273
2505
  static create(state?: Partial<RandState>): randSystem;
2274
- readonly log: (message: string, level?: string, ...objects: unknown[]) => void;
2506
+ readonly log: ScopedLog;
2275
2507
  readonly state: RandState;
2276
2508
  private readonly maxHistory;
2277
2509
  private readonly modulus;
@@ -2333,15 +2565,13 @@ type MacroTags = string[] | null | undefined;
2333
2565
  type SkipArgs = string[] | boolean | null | undefined;
2334
2566
  declare class defineMacros {
2335
2567
  readonly manager: ToolCollection;
2336
- readonly log: ReturnType<typeof createlog>;
2568
+ readonly log: ScopedLog;
2337
2569
  readonly macros: string[];
2338
2570
  readonly statFunctions: Record<string, StatFunction>;
2339
2571
  constructor(manager: ToolCollection);
2340
- get Macro(): MaplebirchCore['SugarCube']['Macro'];
2572
+ get Macro(): ReturnType<MaplebirchCore['host']['sugarcube']['require']>['Macro'];
2341
2573
  define<Args extends unknown[]>(macroName: string, macroFunction: MacroFunction<Args>, tags?: MacroTags, skipArgs?: SkipArgs, isAsync?: boolean): void;
2342
2574
  defineS<Args extends unknown[]>(macroName: string, macroFunction: SimpleMacroFunction<Args>, tags?: MacroTags, skipArgs?: SkipArgs, maintainContext?: boolean): void;
2343
- statChange(statType: string, amount: number, colorClass: string, condition?: () => boolean): DocumentFragment;
2344
- grace(amount: number, expectedRank?: string): DocumentFragment;
2345
2575
  create<Args extends unknown[]>(name: string, fn: StatFunction<Args>): void;
2346
2576
  callStatFunction(name: string, ...args: unknown[]): DocumentFragment;
2347
2577
  }
@@ -2368,76 +2598,26 @@ declare class Builder {
2368
2598
  line(content?: TextContent, style?: string): this;
2369
2599
  wikify(content: TextContent): this;
2370
2600
  raw(content: RawContent): this;
2371
- box(content: RawContent, style?: string): this;
2372
- }
2373
- declare class htmlTools {
2374
- readonly core: MaplebirchCore;
2375
- readonly log: ReturnType<typeof createlog>;
2376
- private uid;
2377
- private readonly store;
2378
- constructor(core: MaplebirchCore);
2379
- get Wikifier(): MaplebirchCore['SugarCube']['Wikifier'];
2380
- replaceText(oldText: string, newText: string, root?: HtmlRoot | null): number;
2381
- renameLink(target: string | Element, label: string, root?: HtmlRoot | null): boolean;
2382
- replaceLink(target: string | Element, source: string, root?: HtmlRoot | null): boolean;
2383
- private findLink;
2384
- add(key: string, handler: (tools: Builder) => void, id?: string): string | false;
2385
- delete(key: string, idOrHandler?: string | ((tools: Builder) => void)): boolean;
2386
- clear(): void;
2387
- renderFragment(keys: string | string[], context?: TextContext): DocumentFragment;
2388
- renderInto(root: HtmlRoot, keys: string | string[], context?: TextContext): void;
2389
- render(macro: MacroContext$1, keys: string | string[]): void;
2390
- makeTextOutput(options?: { CSV?: boolean }): MacroFunction;
2391
- }
2392
- //#endregion
2393
- //#region src/modules/Addon/Diagnostics.d.ts
2394
- interface PatchResult {
2395
- kind: 'passage' | 'script' | 'style' | 'source';
2396
- target: string;
2397
- index: number;
2398
- pattern: string;
2399
- matches: number;
2400
- applied: number;
2401
- status: 'applied' | 'unmatched' | 'missing' | 'invalid' | 'mismatch' | 'error';
2402
- expected?: number;
2403
- error?: string;
2404
- }
2405
- interface ModRequirement {
2406
- name: string;
2407
- range?: string;
2408
- version?: string;
2409
- status: 'available' | 'missing' | 'incompatible' | 'invalid';
2410
- error?: string;
2411
- }
2412
- interface ModConflict {
2413
- source: string;
2414
- dataSource: string;
2415
- passages: string[];
2416
- scripts: string[];
2417
- styles: string[];
2418
- }
2419
- declare class Diagnostics {
2420
- private readonly manager;
2421
- private readonly modUtils;
2422
- private readonly results;
2423
- constructor(manager: SC2DataManager, modUtils: ModUtils);
2424
- get patches(): PatchResult[];
2425
- recordPatch(result: PatchResult): void;
2426
- clearPatches(): void;
2427
- mod(name: string, range?: string): ModRequirement;
2428
- dependencies(): boolean;
2429
- get conflicts(): ModConflict[] | undefined;
2430
- }
2431
- //#endregion
2432
- //#region src/modules/Frameworks/SourcePatch.d.ts
2433
- interface SourcePatch {
2434
- src?: string;
2435
- srcmatch?: RegExp;
2436
- srcmatchgroup?: RegExp;
2437
- to?: string;
2438
- applyafter?: string;
2439
- applybefore?: string;
2440
- expected?: number;
2601
+ box(content: RawContent, style?: string): this;
2602
+ }
2603
+ declare class htmlTools {
2604
+ readonly core: MaplebirchCore;
2605
+ readonly log: ScopedLog;
2606
+ private uid;
2607
+ private readonly store;
2608
+ constructor(core: MaplebirchCore);
2609
+ get Wikifier(): ReturnType<MaplebirchCore['host']['sugarcube']['require']>['Wikifier'];
2610
+ replaceText(oldText: string, newText: string, root?: HtmlRoot | null): number;
2611
+ renameLink(target: string | Element, label: string, root?: HtmlRoot | null): boolean;
2612
+ replaceLink(target: string | Element, source: string, root?: HtmlRoot | null): boolean;
2613
+ private findLink;
2614
+ add(key: string, handler: (tools: Builder) => void, id?: string): string | false;
2615
+ delete(key: string, idOrHandler?: string | ((tools: Builder) => void)): boolean;
2616
+ clear(): void;
2617
+ renderFragment(keys: string | string[], context?: TextContext): DocumentFragment;
2618
+ renderInto(root: HtmlRoot, keys: string | string[], context?: TextContext): void;
2619
+ render(macro: MacroContext$1, keys: string | string[]): void;
2620
+ makeTextOutput(options?: { CSV?: boolean }): MacroFunction;
2441
2621
  }
2442
2622
  //#endregion
2443
2623
  //#region src/modules/Frameworks/ZonesManager.d.ts
@@ -2474,8 +2654,8 @@ interface CustomLinkGroup {
2474
2654
  }
2475
2655
  type InitFunction = string | ZoneFunction | InitObject;
2476
2656
  declare class zonesManager {
2477
- readonly log: ReturnType<typeof createlog>;
2478
- readonly core: ToolCollection['core'];
2657
+ readonly log: ScopedLog;
2658
+ readonly core: MaplebirchCore;
2479
2659
  data: Record<string, ZoneItem[]>;
2480
2660
  initFunction: InitFunction[];
2481
2661
  specialWidget: (string | ZoneFunction)[];
@@ -2486,14 +2666,14 @@ declare class zonesManager {
2486
2666
  private readonly functions;
2487
2667
  private readonly functionNames;
2488
2668
  private nextFunction;
2489
- constructor(manager: ToolCollection);
2669
+ constructor(core: MaplebirchCore);
2490
2670
  inject(...databases: Partial<Pick<zonesManager, 'specialWidget' | 'defaultData' | 'locationPassage' | 'widgetPassage'>>[]): void;
2491
2671
  onInit(...widgets: InitFunction[]): void;
2492
2672
  addTo(zone: string, ...widgets: ZoneWidget[]): void;
2493
2673
  storyInit(): void;
2494
2674
  call(name: string): unknown;
2495
2675
  play(zone: 'CustomLinkZone', passageTitle?: string): CustomLinkGroup[];
2496
- play(zone: 'BeforeLinkZone' | 'AfterLinkZone', passageTitle?: string): string;
2676
+ play(zone: 'State' | 'BeforeLinkZone' | 'AfterLinkZone', passageTitle?: string): string;
2497
2677
  play(zone: string, passageTitle?: string): string | CustomLinkGroup[];
2498
2678
  patchModToGame(manager: AddonPlugin, type: 'before' | 'after'): void;
2499
2679
  private get widgets();
@@ -2524,7 +2704,6 @@ interface LinkZoneConfig {
2524
2704
  onAfterApply?: ((result: boolean, config: LinkZoneConfig) => void) | null;
2525
2705
  debug: boolean;
2526
2706
  }
2527
- declare const log: (message: string, level?: string, ...objects: unknown[]) => void;
2528
2707
  declare class LinkZoneManager {
2529
2708
  readonly containerId: string;
2530
2709
  readonly linkSelector: string;
@@ -2535,8 +2714,8 @@ declare class LinkZoneManager {
2535
2714
  lastLink: Element | null;
2536
2715
  links: Element[];
2537
2716
  breakBeforeFirst: ChildNode | null;
2538
- readonly log: ReturnType<typeof createlog>;
2539
- constructor(containerId?: string, linkSelector?: string, logger?: typeof log);
2717
+ readonly log: ScopedLog;
2718
+ constructor(containerId: string | undefined, linkSelector: string | undefined, logger: ScopedLog);
2540
2719
  detect(): boolean;
2541
2720
  applyZones(config: LinkZoneConfig, customZones: CustomZone[]): boolean;
2542
2721
  private applyBefore;
@@ -2550,7 +2729,7 @@ declare class LinkZoneManager {
2550
2729
  }
2551
2730
  declare const applyLinkZone: typeof LinkZoneManager;
2552
2731
  //#endregion
2553
- //#region src/modules/Frameworks/Patches/Patch.d.ts
2732
+ //#region src/modules/Frameworks/Patch.d.ts
2554
2733
  type PatchPhase = 'init' | 'state';
2555
2734
  interface WidgetPatch {
2556
2735
  before?: (text: string) => string;
@@ -2584,56 +2763,318 @@ declare class Patch<Extensions extends Record<string, object> = Record<never, ne
2584
2763
  apply(phase: PatchPhase): void;
2585
2764
  }
2586
2765
  //#endregion
2587
- //#region src/modules/Frameworks/Patches/Tips.d.ts
2766
+ //#region src/modules/ToolCollection.d.ts
2767
+ type ToolConstructors = {
2768
+ console?: new (manager: ToolCollection) => CheatConsole;
2769
+ macro?: new (manager: ToolCollection) => defineMacros;
2770
+ };
2771
+ declare class ToolCollection {
2772
+ readonly core: MaplebirchCore;
2773
+ readonly log: ScopedLog;
2774
+ readonly console: CheatConsole;
2775
+ readonly migration: typeof migration;
2776
+ readonly rand: typeof randSystem;
2777
+ readonly macro: defineMacros;
2778
+ readonly text: htmlTools;
2779
+ readonly zone: zonesManager;
2780
+ readonly link: typeof applyLinkZone;
2781
+ readonly patch: Patch;
2782
+ constructor(core: MaplebirchCore, constructors?: ToolConstructors);
2783
+ onInit(...widgets: InitFunction[]): void;
2784
+ addTo(zone: string, ...widgets: ZoneWidget[]): void;
2785
+ inject(...databases: Parameters<zonesManager['inject']>): void;
2786
+ }
2787
+ //#endregion
2788
+ //#region src/host/DoL.d.ts
2789
+ type DoLVariables = typeof V;
2790
+ type DoLTemporary = typeof T;
2791
+ type DoLCharacters = typeof C;
2792
+ type DoLSetup = typeof setup;
2793
+ type DoLRenderer = typeof Renderer;
2794
+ type DoLGlobalName = 'V' | 'T' | 'C' | 'setup' | 'Renderer' | 'variables' | 'temporary' | 'characters' | 'renderer';
2795
+ interface DoLHost {
2796
+ readonly V: DoLVariables;
2797
+ readonly T: DoLTemporary;
2798
+ readonly C: DoLCharacters;
2799
+ readonly setup: DoLSetup;
2800
+ readonly Renderer: DoLRenderer;
2801
+ readonly variables: DoLVariables;
2802
+ readonly temporary: DoLTemporary;
2803
+ readonly characters: DoLCharacters;
2804
+ readonly renderer: DoLRenderer;
2805
+ readonly gameVersion: string;
2806
+ has(name: DoLGlobalName): boolean;
2807
+ }
2808
+ interface DoLGlobalScope {
2809
+ V?: DoLVariables;
2810
+ T?: DoLTemporary;
2811
+ C?: DoLCharacters;
2812
+ setup?: DoLSetup;
2813
+ Renderer?: DoLRenderer;
2814
+ }
2815
+ export declare class DoL implements DoLHost {
2816
+ private readonly scope;
2817
+ constructor(scope?: DoLGlobalScope);
2818
+ get V(): DoLVariables;
2819
+ get T(): DoLTemporary;
2820
+ get C(): DoLCharacters;
2821
+ get setup(): DoLSetup;
2822
+ get Renderer(): DoLRenderer;
2823
+ get variables(): DoLVariables;
2824
+ get temporary(): DoLTemporary;
2825
+ get characters(): DoLCharacters;
2826
+ get renderer(): DoLRenderer;
2827
+ get gameVersion(): string;
2828
+ has(name: DoLGlobalName): boolean;
2829
+ private require;
2830
+ }
2831
+ declare const dol: DoL;
2832
+ //#endregion
2833
+ //#region src/modules/TimeStateWeather/TimeEvents.d.ts
2834
+ type TimeEventType = 'onSec' | 'onMin' | 'onHour' | 'onDay' | 'onWeek' | 'onMonth' | 'onYear' | 'onBefore' | 'onThread' | 'onAfter' | 'onTimeTravel';
2835
+ type TimeUnit = 'sec' | 'min' | 'hour' | 'day' | 'week' | 'month' | 'year';
2836
+ interface AccumulateConfig {
2837
+ unit: TimeUnit;
2838
+ target?: number;
2839
+ }
2840
+ interface TimeData {
2841
+ prevDate?: DateTime;
2842
+ currentDate?: DateTime;
2843
+ changes?: Record<TimeUnit, number>;
2844
+ triggeredByAccumulator?: {
2845
+ unit: TimeUnit;
2846
+ target: number;
2847
+ count: number;
2848
+ };
2849
+ exactPoints?: {
2850
+ min: boolean;
2851
+ hour: boolean;
2852
+ day: boolean;
2853
+ week: boolean;
2854
+ month: boolean;
2855
+ year: boolean;
2856
+ };
2857
+ passed?: number;
2858
+ sec?: number;
2859
+ min?: number;
2860
+ hour?: number;
2861
+ day?: number;
2862
+ week?: number;
2863
+ month?: number;
2864
+ year?: number;
2865
+ weekday?: [number, number];
2866
+ detailedDiff?: ReturnType<DateTime['compareWith']>;
2867
+ timeStamp?: number;
2868
+ prev?: DateTime;
2869
+ current?: DateTime;
2870
+ diffSeconds?: number;
2871
+ direction?: 'forward' | 'backward';
2872
+ isLeap?: boolean;
2873
+ }
2874
+ interface TimeEventOptions extends EventOptions {
2875
+ action?: (data: TimeData) => void;
2876
+ cond?: (data: TimeData) => boolean;
2877
+ accumulate?: AccumulateConfig;
2878
+ exact?: boolean;
2879
+ }
2880
+ interface TimeTravelOptions {
2881
+ target?: DateTime;
2882
+ year?: number;
2883
+ month?: number;
2884
+ day?: number;
2885
+ hour?: number;
2886
+ minute?: number;
2887
+ second?: number;
2888
+ addYears?: number;
2889
+ addMonths?: number;
2890
+ addDays?: number;
2891
+ addHours?: number;
2892
+ addMinutes?: number;
2893
+ addSeconds?: number;
2894
+ }
2895
+ declare class TimeEvent extends Event {
2896
+ readonly type: TimeEventType;
2897
+ protected readonly eventName = 'TimeEvent';
2898
+ private action?;
2899
+ private cond;
2900
+ private exact;
2901
+ private accumulate?;
2902
+ private accumulated;
2903
+ private target;
2904
+ constructor(id: string, type: TimeEventType, options: TimeEventOptions, log: DoLDynamic['log']);
2905
+ tryRun(data: TimeData, accumulatedOnly?: boolean): boolean;
2906
+ private runAccumulated;
2907
+ private execute;
2908
+ private match;
2909
+ private runAction;
2910
+ private isExactPoint;
2911
+ }
2912
+ declare class TimeManager {
2913
+ private readonly manager;
2914
+ private readonly eventTypes;
2915
+ private readonly timeEvents;
2916
+ private readonly sortedEventsCache;
2917
+ readonly log: DoLDynamic['log'];
2918
+ readonly TimeConstants: Readonly<{
2919
+ secondsPerDay: 86400;
2920
+ secondsPerHour: 3600;
2921
+ secondsPerMinute: 60;
2922
+ minutesPerHour: 60;
2923
+ standardYearMonths: readonly number[];
2924
+ leapYearMonths: readonly number[];
2925
+ synodicMonth: 29.53058867;
2926
+ MIN_DATE: Readonly<{
2927
+ timeStamp: -315537984000;
2928
+ year: -9999;
2929
+ month: 1;
2930
+ day: 1;
2931
+ hour: 0;
2932
+ minute: 0;
2933
+ second: 0;
2934
+ }>;
2935
+ MAX_DATE: Readonly<{
2936
+ timeStamp: 315537897599;
2937
+ year: 9999;
2938
+ month: 12;
2939
+ day: 31;
2940
+ hour: 23;
2941
+ minute: 59;
2942
+ second: 59;
2943
+ }>;
2944
+ }>;
2945
+ constructor(manager: DoLDynamic);
2946
+ get events(): Readonly<Record<string, ReadonlyMap<string, TimeEvent>>>;
2947
+ Init(): void;
2948
+ patchDateTime(DateTimeClass: typeof DateTime): typeof DateTime;
2949
+ patchTime(TimeObject: typeof Time): void;
2950
+ register(type: TimeEventType, eventId: string, options: TimeEventOptions): boolean;
2951
+ unregister(type: string, eventId: string): boolean;
2952
+ timeTravel(options?: TimeTravelOptions): boolean;
2953
+ updateTimeLanguage(choice?: 'JournalTime'): string | boolean;
2954
+ private handleTimePass;
2955
+ private handleTimeTravel;
2956
+ private targetDate;
2957
+ private timeData;
2958
+ private triggerUnitEvents;
2959
+ private trigger;
2960
+ }
2961
+ //#endregion
2962
+ //#region src/modules/TimeStateWeather/WeatherEvents.d.ts
2963
+ interface WeatherEventOptions extends EventOptions {
2964
+ condition?: () => boolean;
2965
+ onEnter?: () => void;
2966
+ onExit?: () => void;
2967
+ [key: string]: any;
2968
+ }
2969
+ interface WeatherTypeConfig {
2970
+ name: string;
2971
+ iconType?: string | (() => string);
2972
+ value: number;
2973
+ probability: {
2974
+ summer: number;
2975
+ winter: number;
2976
+ spring: number;
2977
+ autumn: number;
2978
+ };
2979
+ cloudCount: {
2980
+ small: () => number;
2981
+ large: () => number;
2982
+ };
2983
+ tanningModifier: number;
2984
+ overcast: number | (() => number);
2985
+ precipitationIntensity: number;
2986
+ visibility: number;
2987
+ }
2988
+ interface WeatherException {
2989
+ date: () => DateTime;
2990
+ duration: number;
2991
+ weatherType: string;
2992
+ temperature?: number;
2993
+ }
2994
+ declare class WeatherManager {
2995
+ private readonly manager;
2996
+ private readonly weatherEvents;
2997
+ private readonly activeEvents;
2998
+ private sortedEventsCache;
2999
+ private readonly Exceptions;
3000
+ private readonly WeatherTypes;
3001
+ private readonly layerModifications;
3002
+ private readonly effectModifications;
3003
+ private weatherTriggered;
3004
+ private readonly log;
3005
+ constructor(manager: DoLDynamic);
3006
+ private checkEvents;
3007
+ register(eventId: string, options: WeatherEventOptions): boolean;
3008
+ unregister(eventId: string): boolean;
3009
+ addLayer(layerName: string, patch: any, mode?: 'concat' | 'replace' | 'merge'): this;
3010
+ addEffect(effectName: string, patch: any, mode?: 'concat' | 'replace' | 'merge'): this;
3011
+ applyModifications(params: any): any;
3012
+ addWeatherData(data: WeatherException | WeatherTypeConfig): boolean | void;
3013
+ Init(): void;
3014
+ modifyWeatherJavaScript(manager: AddonPlugin): void;
3015
+ }
3016
+ //#endregion
3017
+ //#region src/modules/DoL/Dynamic.d.ts
3018
+ declare class DoLDynamic extends Dynamic {
3019
+ get State(): StateManager;
3020
+ get Time(): TimeManager;
3021
+ get Weather(): WeatherManager;
3022
+ regStateEvent(type: 'gate' | 'append', eventId: string, options: StateEventOptions): boolean;
3023
+ delStateEvent(type: 'gate' | 'append', eventId: string): boolean;
3024
+ trigger(type: 'gate' | 'append'): string;
3025
+ get StateEvents(): StateManager['events'];
3026
+ regTimeEvent(type: TimeEventType, eventId: string, options: TimeEventOptions): boolean;
3027
+ delTimeEvent(type: TimeEventType, eventId: string): boolean;
3028
+ timeTravel(options?: TimeTravelOptions): boolean;
3029
+ get TimeEvents(): TimeManager['events'];
3030
+ regWeatherEvent(eventId: string, options: WeatherEventOptions): boolean;
3031
+ delWeatherEvent(eventId: string): boolean;
3032
+ addWeather(data: WeatherException | WeatherTypeConfig): boolean | void;
3033
+ Init(): void;
3034
+ private fixDynamicTask;
3035
+ }
3036
+ //#endregion
3037
+ //#region src/modules/Frameworks/TimeTravelCheat.d.ts
3038
+ declare class TimeTravelCheat {
3039
+ private readonly core;
3040
+ private readonly ids;
3041
+ constructor(core: MaplebirchCore);
3042
+ fragment(): DocumentFragment;
3043
+ private createRoot;
3044
+ private bind;
3045
+ private render;
3046
+ private fieldInput;
3047
+ private setFields;
3048
+ private readFields;
3049
+ private syncDayLimit;
3050
+ private travel;
3051
+ private status;
3052
+ }
3053
+ //#endregion
3054
+ //#region src/modules/Frameworks/DoLConsole.d.ts
3055
+ declare class DoLConsole extends CheatConsole {
3056
+ readonly timeTravel: TimeTravelCheat;
3057
+ constructor(manager: ToolCollection);
3058
+ }
3059
+ //#endregion
3060
+ //#region src/modules/Frameworks/DoLMacros.d.ts
3061
+ declare class DoLMacros extends defineMacros {
3062
+ statChange(statType: string, amount: number, colorClass: string, condition?: () => boolean): DocumentFragment;
3063
+ grace(amount: number, expectedRank?: string): DocumentFragment;
3064
+ }
3065
+ //#endregion
3066
+ //#region src/modules/DoL/Patches/Tips.d.ts
2588
3067
  declare class Tips {
2589
3068
  static add(category: string, ...tips: string[]): void;
2590
3069
  static apply(): void;
2591
3070
  static inject(data: string[]): string[];
2592
3071
  }
2593
3072
  //#endregion
2594
- //#region src/modules/Frameworks/Patches/index.d.ts
2595
- declare function create(core: MaplebirchCore): (Patch<{
2596
- traits: {
2597
- data: TraitConfig[];
2598
- add: typeof Traits.add;
2599
- inject: (data: Parameters<typeof Traits.inject>[0]) => TraitCategory[];
2600
- };
2601
- location: {
2602
- data: Record<string, LocationUpdate>;
2603
- configure: typeof Location.configure;
2604
- apply: typeof Location.apply;
2605
- };
2606
- bodywriting: {
2607
- data: Record<string, BodywritingData>;
2608
- add: typeof Bodywriting.add;
2609
- delete: typeof Bodywriting.delete;
2610
- apply: typeof Bodywriting.apply;
2611
- };
2612
- fishing: {
2613
- data: Record<string, FishConfig>;
2614
- locations: Partial<Record<FishingLocation, Record<string, number>>>;
2615
- add: typeof Fishing.addFish;
2616
- addBait: typeof Fishing.addBait;
2617
- configure: typeof Fishing.configureLocation;
2618
- apply: typeof Fishing.apply;
2619
- };
2620
- foodstuff: {
2621
- data: Record<string, FoodstuffConfig>;
2622
- add: typeof Foodstuff.add;
2623
- apply: typeof Foodstuff.apply;
2624
- };
2625
- antiques: {
2626
- data: Record<string, AntiqueConfig>;
2627
- add: typeof Antiques.add;
2628
- inject: typeof Antiques.inject;
2629
- };
2630
- tips: {
2631
- data: Record<string, string[]>;
2632
- add: typeof Tips.add;
2633
- apply: typeof Tips.apply;
2634
- inject: typeof Tips.inject;
2635
- };
2636
- }> & {
3073
+ //#region src/modules/DoL/Patches/index.d.ts
3074
+ declare function register(
3075
+ core: MaplebirchCore,
3076
+ patch: Patch
3077
+ ): (Patch<Record<never, never>> & {
2637
3078
  traitsData: TraitConfig[];
2638
3079
  addTraits: typeof Traits.add;
2639
3080
  injectTraits: (data: Parameters<typeof Traits.inject>[0]) => TraitCategory[];
@@ -2708,24 +3149,19 @@ declare function create(core: MaplebirchCore): (Patch<{
2708
3149
  inject: typeof Tips.inject;
2709
3150
  };
2710
3151
  };
2711
- type Patches = ReturnType<typeof create>;
3152
+ type Patches = ReturnType<typeof register>;
2712
3153
  //#endregion
2713
- //#region src/modules/ToolCollection.d.ts
2714
- declare class ToolCollection {
2715
- readonly core: MaplebirchCore;
2716
- readonly console: CheatConsole;
2717
- readonly migration: typeof migration;
2718
- readonly rand: typeof randSystem;
2719
- readonly macro: defineMacros;
2720
- readonly text: htmlTools;
2721
- readonly zone: zonesManager;
2722
- readonly link: typeof applyLinkZone;
3154
+ //#region src/modules/DoL/ToolCollection.d.ts
3155
+ declare class DoLToolCollection extends ToolCollection {
3156
+ readonly console: DoLConsole;
3157
+ readonly macro: DoLMacros;
2723
3158
  readonly patch: Patches;
2724
- readonly createlog: typeof createlog;
3159
+ private readonly macros;
3160
+ private readonly optionEvents;
3161
+ private readonly modI18N;
2725
3162
  constructor(core: MaplebirchCore);
2726
- onInit(...widgets: InitFunction[]): void;
2727
- addTo(zone: string, ...widgets: ZoneWidget[]): void;
2728
3163
  preInit(): void;
3164
+ Init(): void;
2729
3165
  }
2730
3166
  //#endregion
2731
3167
  //#region src/modules/AudioAddon/Track.d.ts
@@ -2773,6 +3209,22 @@ declare class Playlist {
2773
3209
  private shuffle;
2774
3210
  }
2775
3211
  //#endregion
3212
+ //#region src/modules/AudioAddon/Ambience.d.ts
3213
+ declare class Ambience {
3214
+ private readonly modloader;
3215
+ private active;
3216
+ private request;
3217
+ constructor(modloader: ModLoader);
3218
+ protected create(options: HowlOptions): Howl;
3219
+ play(modName: string, path: string, volume?: number, fadeMs?: number): Promise<boolean>;
3220
+ setVolume(volume: number, fadeMs?: number): void;
3221
+ stop(fadeMs?: number): void;
3222
+ private fadeOut;
3223
+ private dispose;
3224
+ private clamp;
3225
+ private duration;
3226
+ }
3227
+ //#endregion
2776
3228
  //#region src/modules/Audio.d.ts
2777
3229
  declare const PlayState: {
2778
3230
  readonly IDLE: 'idle';
@@ -2804,9 +3256,10 @@ interface AudioSnapshot {
2804
3256
  muted: boolean;
2805
3257
  progress: AudioProgress;
2806
3258
  }
2807
- declare class AudioManager {
3259
+ declare class Audio {
2808
3260
  readonly core: MaplebirchCore;
2809
- readonly log: ReturnType<typeof createlog>;
3261
+ readonly log: ScopedLog;
3262
+ readonly ambience: Ambience;
2810
3263
  private readonly STORE;
2811
3264
  private readonly playlists;
2812
3265
  private readonly playlistLoads;
@@ -2903,7 +3356,7 @@ declare class Variables {
2903
3356
  static get options(): Record<string, any>;
2904
3357
  version: string;
2905
3358
  readonly tool: MaplebirchCore['tool'];
2906
- readonly log: ReturnType<typeof createlog>;
3359
+ readonly log: ScopedLog;
2907
3360
  readonly migration: migration;
2908
3361
  readonly options: Options;
2909
3362
  constructor(core: MaplebirchCore);
@@ -2913,6 +3366,7 @@ declare class Variables {
2913
3366
  Init(): void;
2914
3367
  loadInit(): void;
2915
3368
  postInit(): void;
3369
+ private run;
2916
3370
  }
2917
3371
  //#endregion
2918
3372
  //#region src/modules/CharacterAddon/Pet.d.ts
@@ -3015,7 +3469,7 @@ interface TransformationOption extends EntryOptions {
3015
3469
  }
3016
3470
  declare class Transformation {
3017
3471
  private manager;
3018
- private log;
3472
+ private get log();
3019
3473
  private config;
3020
3474
  readonly decayConditions: Record<string, DecayCondition[]>;
3021
3475
  readonly suppressConditions: Record<string, SuppressCondition[]>;
@@ -3061,7 +3515,7 @@ interface LayerUseOptions {
3061
3515
  declare function mask(x?: number, rotation?: number, swap?: boolean, width?: number, height?: number): string;
3062
3516
  declare class Character {
3063
3517
  readonly core: MaplebirchCore;
3064
- readonly log: ReturnType<typeof createlog>;
3518
+ readonly log: ScopedLog;
3065
3519
  readonly mask: typeof mask;
3066
3520
  readonly faceStyleMap: Map<string, string[]>;
3067
3521
  private readonly handlers;
@@ -3426,6 +3880,11 @@ interface WardrobeWearOptions {
3426
3880
  when?: Condition;
3427
3881
  wetness?: WardrobeWetnessResolver;
3428
3882
  }
3883
+ interface WardrobeConditionGroup {
3884
+ location?: string | readonly string[];
3885
+ passage?: string | readonly string[];
3886
+ hours?: readonly [from: number, to: number];
3887
+ }
3429
3888
  type WardrobeWeightedChoice = readonly [key: string, weight: number];
3430
3889
  type WardrobeChoice = string | readonly WardrobeWeightedChoice[];
3431
3890
  type WardrobeLayerResolver = string | (() => string);
@@ -3440,16 +3899,19 @@ declare class NPCSidebarWardrobe {
3440
3899
  private readonly manager;
3441
3900
  private readonly templates;
3442
3901
  private readonly profiles;
3902
+ private readonly conditions;
3443
3903
  constructor(manager: NPCManager);
3444
3904
  init(): void;
3445
3905
  load(modName: string, filePath: string): Promise<void>;
3446
3906
  get(key: string): WardrobeItem | undefined;
3447
3907
  set(key: string, template: WardrobeItem): void;
3448
3908
  has(key: string): boolean;
3909
+ when(name: string, group?: WardrobeConditionGroup, condition?: Condition): () => boolean;
3449
3910
  wear(npcName: string, location: string | readonly string[], choice: WardrobeChoice, options?: Condition | WardrobeWearOptions): void;
3450
3911
  wet(npcName: string, wetness: WardrobeWetnessResolver, cond?: Condition): void;
3451
3912
  layer(npcName: string, source: WardrobeLayerResolver, cond?: Condition): void;
3452
- put(clothes: WardrobeItem, key: string): void;
3913
+ apply(clothes: WardrobeItem, slot: NPCClothesSlot, item: WardrobeClothing): void;
3914
+ put(clothes: WardrobeItem, key: string, slots?: NPCClothesSlot | readonly NPCClothesSlot[]): void;
3453
3915
  strip(clothes: WardrobeItem, slot: NPCClothesSlot | readonly NPCClothesSlot[]): void;
3454
3916
  base(npcName: string, modifier: WardrobeModifier): void;
3455
3917
  modify(npcName: string, modifier: WardrobeModifier): void;
@@ -3798,7 +4260,7 @@ declare const NamedNPC: {
3798
4260
  };
3799
4261
  declare class NPCManager {
3800
4262
  readonly core: MaplebirchCore;
3801
- readonly log: ReturnType<typeof createlog>;
4263
+ readonly log: ScopedLog;
3802
4264
  readonly data: Map<
3803
4265
  string,
3804
4266
  {
@@ -3836,18 +4298,23 @@ declare class NPCManager {
3836
4298
  postInit(): void;
3837
4299
  }
3838
4300
  //#endregion
3839
- //#region src/modules/CombatAddon/CombatAction.d.ts
4301
+ //#region src/modules/CombatAddon/CombatTypes.d.ts
3840
4302
  declare const actionTypes: readonly ['leftaction', 'rightaction', 'feetaction', 'mouthaction', 'penisaction', 'vaginaaction', 'anusaction', 'chestaction', 'thighaction'];
3841
4303
  type ActionType = (typeof actionTypes)[number];
3842
- type CombatType = 'Default' | 'Self' | 'Struggle' | 'Swarm' | 'Vore' | 'Machine' | 'Tentacle';
4304
+ declare const combatTypes: readonly ['Default', 'Self', 'Struggle', 'Swarm', 'Vore', 'Machine', 'Tentacle'];
4305
+ type CombatType = (typeof combatTypes)[number];
4306
+ //#endregion
4307
+ //#region src/modules/CombatAddon/CombatAction.d.ts
4308
+ type OptionType = ActionType | 'ask';
3843
4309
  type ActionValue = string | number;
3844
4310
  interface Context {
3845
- actionType?: ActionType;
4311
+ actionType?: OptionType;
3846
4312
  combatType?: CombatType;
3847
4313
  encounterType?: CombatType;
3848
4314
  action?: ActionValue;
3849
4315
  id?: string;
3850
4316
  originalCount?: number;
4317
+ label?: string;
3851
4318
  }
3852
4319
  interface ActionEntry {
3853
4320
  id: string;
@@ -3858,7 +4325,7 @@ interface ActionEntry {
3858
4325
  color: (ctx: Context) => string;
3859
4326
  difficulty: (ctx: Context) => string;
3860
4327
  effect: (ctx: Context) => string;
3861
- combatType: (ctx: Context) => CombatType;
4328
+ combatType: (ctx: Context) => CombatType | CombatType[];
3862
4329
  order: (ctx: Context) => number;
3863
4330
  }
3864
4331
  interface ActionConfig {
@@ -3870,7 +4337,16 @@ interface ActionConfig {
3870
4337
  color?: string | ((ctx: Context) => string);
3871
4338
  difficulty?: string | ((ctx: Context) => string);
3872
4339
  effect?: string | ((ctx: Context) => string);
3873
- combatType?: CombatType | ((ctx: Context) => CombatType);
4340
+ combatType?: CombatType | CombatType[] | ((ctx: Context) => CombatType | CombatType[]);
4341
+ order?: number | ((ctx: Context) => number);
4342
+ }
4343
+ interface ModificationConfig {
4344
+ id: string;
4345
+ actionType: OptionType | OptionType[];
4346
+ value: ActionValue;
4347
+ combatType?: CombatType | CombatType[] | ((ctx: Context) => CombatType | CombatType[]);
4348
+ cond?: (ctx: Context) => boolean;
4349
+ display?: string | ((ctx: Context) => string);
3874
4350
  order?: number | ((ctx: Context) => number);
3875
4351
  }
3876
4352
  interface OptionsTable {
@@ -3878,18 +4354,21 @@ interface OptionsTable {
3878
4354
  }
3879
4355
  declare class CombatActions {
3880
4356
  readonly actions: ActionEntry[];
4357
+ private readonly modifications;
4358
+ private matches;
3881
4359
  reg(...configs: ActionConfig[]): this;
4360
+ modify(...configs: ModificationConfig[]): this;
3882
4361
  private eval;
3883
- patchOptions(optionsTable: OptionsTable, actionType: ActionType, combatType?: CombatType): OptionsTable;
4362
+ patchOptions(optionsTable: OptionsTable, actionType: OptionType, combatType?: CombatType): OptionsTable;
3884
4363
  color(action: ActionValue, encounterType?: CombatType): string | null;
3885
4364
  difficulty(action: ActionValue, combatType?: CombatType): string | null;
3886
- effect(...actionTypes: ActionType[]): string;
4365
+ effect(combatType: CombatType | undefined, ...actionTypes: ActionType[]): string;
3887
4366
  }
3888
4367
  //#endregion
3889
4368
  //#region src/modules/Combat.d.ts
3890
- declare class CombatManager {
4369
+ declare class Combat {
3891
4370
  readonly core: MaplebirchCore;
3892
- readonly log: ReturnType<typeof createlog>;
4371
+ readonly log: ScopedLog;
3893
4372
  readonly CombatAction: CombatActions;
3894
4373
  constructor(core: MaplebirchCore);
3895
4374
  private _generateCombatAction;
@@ -3898,287 +4377,68 @@ declare class CombatManager {
3898
4377
  Init(): void;
3899
4378
  }
3900
4379
  //#endregion
3901
- //#region src/core.d.ts
3902
- interface Extensions {}
4380
+ //#region src/modules/DoL/types.d.ts
3903
4381
  interface CoreModules {
3904
- readonly addon: AddonPlugin;
3905
- readonly dynamic: DynamicManager;
3906
- readonly tool: ToolCollection;
3907
- readonly audio: AudioManager;
4382
+ readonly dynamic: DoLDynamic;
4383
+ readonly tool: DoLToolCollection;
4384
+ readonly audio: Audio;
3908
4385
  readonly var: Variables;
3909
4386
  readonly char: Character;
3910
4387
  readonly npc: NPCManager;
3911
- readonly combat: CombatManager;
3912
- }
3913
- interface CoreEvents {
3914
- ':indexedDB': [];
3915
- ':idbReady': [];
3916
- ':import': [];
3917
- ':variable': [];
3918
- ':onSave': [save: Save];
3919
- ':onLoad': [save: Save];
3920
- ':language': [];
3921
- ':storyready': [];
3922
- ':passageinit': [passage: Passage];
3923
- ':passagestart': [passage: Passage, content: HTMLDivElement];
3924
- ':passagerender': [passage: Passage, content: HTMLDivElement];
3925
- ':passagedisplay': [passage: Passage, content: HTMLDivElement];
3926
- ':passageend': [passage: Passage, content: HTMLDivElement];
3927
- ':sugarcube': [];
3928
- ':modLoaderEnd': [];
3929
- }
3930
- type Instance = MaplebirchCore & Extensions;
3931
- declare class MaplebirchCore {
3932
- static meta: {
3933
- name: 'maplebirch Frameworks';
3934
- author: string;
3935
- version: string;
3936
- modifiedby: string;
3937
- updateDate: string;
3938
- Languages: typeof Languages;
3939
- early: readonly string[];
3940
- core: readonly string[];
3941
- protected: readonly string[];
3942
- };
3943
- readonly meta: typeof MaplebirchCore.meta;
3944
- readonly utils: Readonly<{
3945
- clone: typeof clone;
3946
- equal: typeof equal;
3947
- merge: typeof merge;
3948
- append: typeof append;
3949
- cover: typeof cover;
3950
- mergefn: typeof mergeFn;
3951
- appendfn: typeof appendFn;
3952
- coverfn: typeof coverFn;
3953
- contains: typeof contains;
3954
- random: typeof randomNumber;
3955
- either: typeof randomPick;
3956
- SelectCase: typeof SelectCase;
3957
- convert: typeof convert;
3958
- clamp: typeof clamp;
3959
- loadImage: typeof loadImage;
3960
- }>;
3961
- readonly modList: string[];
3962
- readonly manager: {
3963
- modSC2DataManager: SC2DataManager;
3964
- modLoaderGui: Gui;
3965
- };
3966
- passage: Passage;
3967
- readonly yaml: typeof jsyaml;
3968
- readonly howler: {
3969
- Howl: typeof Howl;
3970
- Howler: typeof Howler;
3971
- };
3972
- readonly logger: Logger;
3973
- readonly tracer: EventEmitter;
3974
- readonly idb: IndexedDBService;
3975
- readonly credential: CredentialVault;
3976
- readonly cloudSave: CloudSaveService;
3977
- readonly lang: LanguageManager;
3978
- readonly modules: ModuleSystem;
3979
- readonly gui: GUIControl;
3980
- readonly addon: CoreModules['addon'];
3981
- readonly dynamic: CoreModules['dynamic'];
3982
- readonly tool: CoreModules['tool'];
3983
- readonly audio: CoreModules['audio'];
3984
- readonly var: CoreModules['var'];
3985
- readonly char: CoreModules['char'];
3986
- readonly npc: CoreModules['npc'];
3987
- readonly combat: CoreModules['combat'];
3988
- constructor(modSC2DataManager: SC2DataManager, modLoaderGui: Gui);
3989
- log(msg: string, level?: string, ...objs: unknown[]): void;
3990
- on<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>, description?: string): boolean;
3991
- on<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>, description?: string): boolean;
3992
- off<Args extends unknown[]>(eventName: string, identifier: string | EventCallback<Args>): boolean;
3993
- once<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>, description?: string): boolean;
3994
- once<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>, description?: string): boolean;
3995
- after<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>): void;
3996
- after<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>): void;
3997
- trigger<Name extends keyof CoreEvents>(eventName: Name, ...args: CoreEvents[Name]): Promise<void>;
3998
- trigger<Name extends string>(eventName: Name extends keyof CoreEvents ? never : Name, ...args: unknown[]): Promise<void>;
3999
- register<T extends object>(name: string, module: T & Module, dependencies?: string[]): boolean;
4000
- t(key: string, space?: boolean): string;
4001
- auto(text: string): string;
4002
- disabled(modNames: string | string[], reload?: boolean): Promise<boolean>;
4003
- get lodash(): ReturnType<ModUtils['getLodash']>;
4004
- get marked(): typeof marked;
4005
- set SugarCube(parts: TwineSugarCube);
4006
- get SugarCube(): TwineSugarCube;
4007
- set Language(lang: string);
4008
- get Language(): string;
4009
- set LogLevel(level: string);
4010
- get LogLevel(): string;
4011
- get<K extends keyof (CoreModules & Extensions)>(name: K): (CoreModules & Extensions)[K] | undefined;
4012
- get(name: string): Module | undefined;
4013
- get dependencyGraph(): DependencyGraph;
4014
- get modLoader(): ReturnType<SC2DataManager['getModLoader']>;
4015
- get modUtils(): ModUtils;
4016
- get gameVersion(): string;
4017
- }
4018
- declare var maplebirch: Instance;
4019
- declare function createlog(prefix: string): (message: string, level?: string, ...objects: unknown[]) => void;
4020
- //#endregion
4021
- //#region src/services/CredentialVault.d.ts
4022
- type CredentialPeriod = 'day' | 'month';
4023
- interface AuthConfig {
4024
- key: string;
4025
- subject?: string;
4026
- name?: string;
4027
- publicKey: JsonWebKey | string;
4028
- prompt?: {
4029
- title?: string;
4030
- label?: string;
4031
- placeholder?: string;
4032
- hint?: string;
4033
- };
4034
- date?: {
4035
- period?: CredentialPeriod;
4036
- timezone?: string;
4037
- graceDays?: number;
4038
- };
4039
- }
4040
- interface AuthPayload {
4041
- subject: string;
4042
- key: string;
4043
- date?: string;
4044
- password: string;
4045
- expiresAt?: number;
4046
- }
4047
- interface CryptContext {
4048
- modName: string;
4049
- credential?: string;
4050
- payload?: AuthPayload;
4051
- }
4052
- interface CryptResult {
4053
- data: Awaited<InputFileFormat>;
4054
- auth?: AuthConfig | boolean | void;
4055
- }
4056
- interface CryptOptions {
4057
- modName?: string;
4058
- cache?: {
4059
- subject: string;
4060
- key: string;
4061
- };
4062
- password?: string;
4063
- prompt?: AuthConfig['prompt'] & {
4064
- name?: string;
4065
- };
4066
- lazyOptions?: unknown;
4067
- decrypt(password: string, context: CryptContext): Promise<CryptResult | Awaited<InputFileFormat>>;
4068
- }
4069
- declare class CredentialVault {
4070
- readonly core: MaplebirchCore;
4071
- private static readonly STORE;
4072
- private static readonly TOKEN_PREFIX;
4073
- private dialogQueue;
4074
- private storageKey;
4075
- constructor(core: MaplebirchCore);
4076
- loadCrypt(options: CryptOptions): Promise<boolean>;
4077
- private loadCredential;
4078
- private decryptAndLoad;
4079
- private decodeCredential;
4080
- private verify;
4081
- private credentialDate;
4082
- private readStored;
4083
- private storeStored;
4084
- private forget;
4085
- private ensurePromptStyle;
4086
- private promptCredential;
4087
- private ensureStorageKey;
4088
- private loadStorageKey;
4089
- private encryptRecord;
4090
- private decryptRecord;
4388
+ readonly combat: Combat;
4091
4389
  }
4092
- //#endregion
4093
- //#region src/utils/twine.d.ts
4094
- type Replacement = [RegExp, string];
4095
- declare function replace(content: string, replacements: Replacement[], label?: string): string;
4096
- //#endregion
4097
- //#region src/modules/Addon/Resources.d.ts
4098
- type ImageResult = string | false;
4099
- declare class Resources {
4100
- private readonly manager;
4101
- private readonly report;
4102
- private readonly cache;
4103
- private readonly pending;
4104
- constructor(manager: SC2DataManager, report: (path: string, error: unknown) => void);
4105
- normalize(path: string): string;
4106
- has(path: string): boolean | undefined;
4107
- load(path: string): ImageResult | Promise<ImageResult>;
4108
- clear(path?: string): void;
4109
- private resolve;
4390
+ declare global {
4391
+ interface MaplebirchExtensions extends CoreModules {}
4110
4392
  }
4111
4393
  //#endregion
4112
- //#region src/modules/AddonPlugin.d.ts
4113
- interface FileItem {
4114
- modName: string;
4115
- filePath: string;
4116
- content: string;
4117
- }
4118
- interface BootTask<T = unknown> {
4119
- modName: string;
4120
- modInfo: ModInfo;
4121
- modZip: ModZipReader;
4122
- config: T;
4123
- }
4124
- type BootHandler<T = unknown> = (task: BootTask<T>) => void | Promise<void>;
4125
- declare class AddonPlugin {
4126
- readonly core: MaplebirchCore;
4127
- onStart: boolean;
4128
- readonly replace: typeof replace;
4129
- readonly SC2DataManager: SC2DataManager;
4130
- readonly modUtils: ModUtils;
4131
- readonly resources: Resources;
4132
- readonly diagnostics: Diagnostics;
4133
- readonly info: Map<
4134
- string,
4135
- {
4136
- addonName: string;
4137
- mod: ModInfo;
4138
- modZip: ModZipReader;
4139
- }
4140
- >;
4141
- readonly log: ReturnType<typeof createlog>;
4142
- readonly jsFiles: FileItem[];
4143
- readonly moduleFiles: FileItem[];
4144
- private readonly disabledMods;
4145
- private readonly blockedPassages;
4146
- private readonly bootHooks;
4147
- private readonly bootQueue;
4148
- private onSaveLoadTracer;
4149
- private moduleFilesExecuted;
4150
- private scriptFilesExecuted;
4151
- private bootReady;
4152
- constructor(core: MaplebirchCore);
4153
- wikify(name: string, callbacks: WikifyTracerCallback): void;
4154
- hook<T>(name: string, handler: BootHandler<T>): boolean;
4155
- canLoadThisMod(bootJson: ModBootJson, _zip: JSZipLikeReadOnlyInterface): Promise<boolean>;
4156
- afterInjectEarlyLoad(): Promise<void>;
4157
- ModLoaderLoadEnd(): Promise<void>;
4158
- afterEarlyLoad(): Promise<void>;
4159
- registerMod(addonName: string, modInfo: ModInfo, modZip: ModZipReader): Promise<void>;
4160
- afterRegisterMod2Addon(): Promise<void>;
4161
- beforePatchModToGame(): Promise<void>;
4162
- PatchModToGame_start(): Promise<void>;
4163
- afterPatchModToGame(): Promise<void>;
4164
- afterPreload(): Promise<void>;
4165
- whenSC2StoryReady(): Promise<void>;
4166
- whenSC2PassageInit(passage: Passage): Promise<void>;
4167
- whenSC2PassageStart(passage: Passage, content: HTMLDivElement): Promise<void>;
4168
- whenSC2PassageRender(passage: Passage, content: HTMLDivElement): Promise<void>;
4169
- whenSC2PassageDisplay(passage: Passage, content: HTMLDivElement): Promise<void>;
4170
- whenSC2PassageEnd(passage: Passage, content: HTMLDivElement): Promise<void>;
4171
- loadCrypt(options: CryptOptions): Promise<boolean>;
4172
- private scriptFiles;
4173
- private dataReplace;
4174
- private loadFiles;
4175
- private executeScripts;
4176
- private process;
4177
- private queue;
4178
- private flush;
4179
- private run;
4180
- private config;
4181
- private modifyOptionsDateFormat;
4394
+ //#region src/modules/Frameworks/ImageLoader.d.ts
4395
+ declare class ImageLoader {
4396
+ private static refreshTimer;
4397
+ static load(src: string): string | false | Promise<string | false>;
4398
+ private static queueRefresh;
4182
4399
  }
4183
4400
  //#endregion
4184
- export { type CoreEvents, type CoreModules, type Extensions, type MaplebirchCore, type Save, type SaveObject, maplebirch as default, index_d_exports as utils };
4401
+ export {
4402
+ type AddonServices,
4403
+ type BootHandler,
4404
+ type BootTask,
4405
+ type CloudSaveConfig,
4406
+ type CloudSaveRecord,
4407
+ type CloudSaveRemoteCode,
4408
+ type CloudSaveRemoteItem,
4409
+ type CoreEvents,
4410
+ type CoreModules,
4411
+ type DependencyGraph,
4412
+ type DependencyInfo,
4413
+ type DiagnosticRecord,
4414
+ DoLDynamic,
4415
+ type DoLGlobalScope,
4416
+ type DoLHost,
4417
+ DoLToolCollection,
4418
+ Dynamic,
4419
+ type EventCallback,
4420
+ type Extensions,
4421
+ type FrameworkHost,
4422
+ type FrameworkInfra,
4423
+ type FrameworkServices,
4424
+ type HookCallback,
4425
+ ImageLoader,
4426
+ type LifecyclePhase,
4427
+ type LifecycleResult,
4428
+ type LifecycleTarget,
4429
+ type LogLevel,
4430
+ type MaplebirchCore,
4431
+ type ModConflict,
4432
+ type ModRequirement,
4433
+ type Module,
4434
+ type ModulesMeta,
4435
+ type PatchResult,
4436
+ Resources,
4437
+ type SaveObject,
4438
+ type StateEventOptions,
4439
+ ToolCollection,
4440
+ type Translation,
4441
+ maplebirch as default,
4442
+ dol,
4443
+ index_d_exports as utils
4444
+ };