@scml-dol-maplebirch/types 5.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/compat/DoLPcompat.d.ts +55 -0
  2. package/compat/ModI18N.d.ts +10 -0
  3. package/compat/Prototype.d.ts +43 -0
  4. package/compat/SimpleFrameworks.d.ts +1 -0
  5. package/constants.d.ts +52 -0
  6. package/core.d.ts +143 -0
  7. package/host/DoL.d.ts +44 -0
  8. package/host/ModLoader.d.ts +37 -0
  9. package/host/Resources.d.ts +15 -0
  10. package/host/SugarCube.d.ts +25 -0
  11. package/index.d.ts +11 -30
  12. package/infra/Catalog.d.ts +14 -0
  13. package/infra/Diagnostics.d.ts +48 -0
  14. package/infra/Emitter.d.ts +18 -0
  15. package/infra/Hooks.d.ts +15 -0
  16. package/infra/Lifecycle.d.ts +24 -0
  17. package/infra/Logger.d.ts +15 -0
  18. package/macros/helpers.d.ts +54 -0
  19. package/macros/index.d.ts +8 -0
  20. package/macros/lanButton.d.ts +2 -0
  21. package/macros/lanLink.d.ts +2 -0
  22. package/macros/lanListbox.d.ts +2 -0
  23. package/macros/lanSwitch.d.ts +3 -0
  24. package/macros/language.d.ts +2 -0
  25. package/macros/macros.d.ts +14 -0
  26. package/macros/maplebirchReplace.d.ts +1 -0
  27. package/macros/radiobuttonsfrom.d.ts +2 -0
  28. package/main.d.ts +22 -0
  29. package/maplebirch.d.ts +11 -4440
  30. package/modules/Audio.d.ts +118 -0
  31. package/modules/AudioAddon/Ambience.d.ts +17 -0
  32. package/modules/AudioAddon/AudioBufferPlayer.d.ts +20 -0
  33. package/modules/AudioAddon/Playlist.d.ts +29 -0
  34. package/modules/AudioAddon/Track.d.ts +15 -0
  35. package/modules/Character.d.ts +39 -0
  36. package/modules/CharacterAddon/Pet.d.ts +61 -0
  37. package/modules/CharacterAddon/Transformation.d.ts +70 -0
  38. package/modules/CharacterAddon/TransformationConfig.d.ts +20 -0
  39. package/modules/Combat.d.ts +17 -0
  40. package/modules/CombatAddon/CombatAction.d.ts +63 -0
  41. package/modules/CombatAddon/CombatTypes.d.ts +4 -0
  42. package/modules/DoL/Config.d.ts +50 -0
  43. package/modules/DoL/Dynamic.d.ts +23 -0
  44. package/modules/DoL/Integration.d.ts +13 -0
  45. package/modules/DoL/Patches/Antiques.d.ts +17 -0
  46. package/modules/DoL/Patches/Bodywriting.d.ts +33 -0
  47. package/modules/DoL/Patches/Fishing.d.ts +32 -0
  48. package/modules/DoL/Patches/Foodstuff.d.ts +64 -0
  49. package/modules/DoL/Patches/Location.d.ts +36 -0
  50. package/modules/DoL/Patches/Tips.d.ts +7 -0
  51. package/modules/DoL/Patches/Traits.d.ts +24 -0
  52. package/modules/DoL/Patches/config.d.ts +2 -0
  53. package/modules/DoL/Patches/index.d.ts +86 -0
  54. package/modules/DoL/Replacements.d.ts +189 -0
  55. package/modules/DoL/ToolCollection.d.ts +17 -0
  56. package/modules/DoL/index.d.ts +1 -0
  57. package/modules/DoL/types.d.ts +20 -0
  58. package/modules/Dynamic.d.ts +10 -0
  59. package/modules/Event.d.ts +16 -0
  60. package/modules/Frameworks/ApplyLinkZone.d.ts +40 -0
  61. package/modules/Frameworks/ConsoleCheat.d.ts +43 -0
  62. package/modules/Frameworks/DoLConsole.d.ts +8 -0
  63. package/modules/Frameworks/DoLMacros.d.ts +6 -0
  64. package/modules/Frameworks/HtmlTools.d.ts +49 -0
  65. package/modules/Frameworks/ImageLoader.d.ts +6 -0
  66. package/modules/Frameworks/OptionEvents.d.ts +15 -0
  67. package/modules/Frameworks/Patch.d.ts +24 -0
  68. package/modules/Frameworks/RandSystem.d.ts +27 -0
  69. package/modules/Frameworks/TextStore.d.ts +7 -0
  70. package/modules/Frameworks/TimeTravelCheat.d.ts +17 -0
  71. package/modules/Frameworks/ZonesManager.d.ts +69 -0
  72. package/modules/Frameworks/macros.d.ts +27 -0
  73. package/modules/Frameworks/migration.d.ts +33 -0
  74. package/modules/NamedNPC.d.ts +164 -0
  75. package/modules/NamedNPCAddon/NPCClothes/Condition.d.ts +3 -0
  76. package/modules/NamedNPCAddon/NPCClothes/NPCOutfitSets.d.ts +38 -0
  77. package/modules/NamedNPCAddon/NPCClothes/NPCSidebarArt.d.ts +25 -0
  78. package/modules/NamedNPCAddon/NPCClothes/NPCSidebarWardrobe.d.ts +60 -0
  79. package/modules/NamedNPCAddon/NPCClothes.d.ts +12 -0
  80. package/modules/NamedNPCAddon/NPCFluids.d.ts +17 -0
  81. package/modules/NamedNPCAddon/NPCPregnancy.d.ts +127 -0
  82. package/modules/NamedNPCAddon/NPCSchedules.d.ts +77 -0
  83. package/modules/NamedNPCAddon/NPCSidebar.d.ts +28 -0
  84. package/modules/NamedNPCAddon/NPCSidebarConfig/base_layers.d.ts +212 -0
  85. package/modules/NamedNPCAddon/NPCSidebarConfig/face_layers.d.ts +220 -0
  86. package/modules/NamedNPCAddon/NPCSidebarConfig/feet_layers.d.ts +274 -0
  87. package/modules/NamedNPCAddon/NPCSidebarConfig/fluids_layers.d.ts +109 -0
  88. package/modules/NamedNPCAddon/NPCSidebarConfig/functions.d.ts +509 -0
  89. package/modules/NamedNPCAddon/NPCSidebarConfig/handheld_layers.d.ts +292 -0
  90. package/modules/NamedNPCAddon/NPCSidebarConfig/hands_layers.d.ts +381 -0
  91. package/modules/NamedNPCAddon/NPCSidebarConfig/head_layers.d.ts +490 -0
  92. package/modules/NamedNPCAddon/NPCSidebarConfig/legs_layers.d.ts +274 -0
  93. package/modules/NamedNPCAddon/NPCSidebarConfig/lower_layers.d.ts +800 -0
  94. package/modules/NamedNPCAddon/NPCSidebarConfig/neck_layers.d.ts +112 -0
  95. package/modules/NamedNPCAddon/NPCSidebarConfig/transformation_layers.d.ts +1672 -0
  96. package/modules/NamedNPCAddon/NPCSidebarConfig/types.d.ts +130 -0
  97. package/modules/NamedNPCAddon/NPCSidebarConfig/upper_layers.d.ts +1516 -0
  98. package/modules/NamedNPCAddon/NPCTransformation.d.ts +51 -0
  99. package/modules/NamedNPCAddon/NPCUtils.d.ts +8 -0
  100. package/modules/State.d.ts +46 -0
  101. package/modules/TimeStateWeather/DateTime.d.ts +4 -0
  102. package/modules/TimeStateWeather/Time.d.ts +14 -0
  103. package/modules/TimeStateWeather/TimeEvents.d.ts +130 -0
  104. package/modules/TimeStateWeather/WeatherEvents.d.ts +56 -0
  105. package/modules/ToolCollection.d.ts +33 -0
  106. package/modules/Variables.d.ts +32 -0
  107. package/package.d.ts +30 -0
  108. package/package.json +5 -7
  109. package/services/AddonPlugin.d.ts +92 -0
  110. package/services/CloudSave.d.ts +124 -0
  111. package/services/CredentialVault.d.ts +80 -0
  112. package/services/GUIControl.d.ts +54 -0
  113. package/services/IndexedDB.d.ts +28 -0
  114. package/services/Modules.d.ts +75 -0
  115. package/services/Translator.d.ts +60 -0
  116. package/types/global.d.ts +123 -0
  117. package/types/twine-sugarcube.d.ts +456 -0
  118. package/utils/array.d.ts +10 -0
  119. package/utils/binary.d.ts +8 -0
  120. package/utils/condition.d.ts +1 -0
  121. package/utils/index.d.ts +22 -0
  122. package/utils/object.d.ts +16 -0
  123. package/utils/selector.d.ts +20 -0
  124. package/utils/string.d.ts +8 -0
@@ -0,0 +1,55 @@
1
+ import type { MaplebirchCore } from '../core.js';
2
+ import type { BuildUpdater, DecayCondition, NativeHistoryEntry, NativeMacroMap, NativeTransformState, SuppressCondition } from '../modules/CharacterAddon/TransformationConfig.js';
3
+ interface TransformationPart {
4
+ name: string;
5
+ tfRequired: number;
6
+ default?: string;
7
+ [key: string]: unknown;
8
+ }
9
+ interface SetupTransformation {
10
+ name: string;
11
+ readonly level: number;
12
+ readonly build: number;
13
+ type: 'physicalTransform' | 'specialTransform';
14
+ parts: TransformationPart[];
15
+ traits: TransformationPart[];
16
+ }
17
+ interface TransformationPatch {
18
+ parts?: TransformationPart[];
19
+ traits?: TransformationPart[];
20
+ }
21
+ declare class Transformations {
22
+ private static active;
23
+ static readonly DecayConditions: Record<string, DecayCondition[]>;
24
+ static readonly SuppressConditions: Record<string, SuppressCondition[]>;
25
+ static readonly AnimalTransforms: NativeTransformState[];
26
+ static readonly AnimalMacros: NativeMacroMap;
27
+ static readonly HistoryTransforms: NativeHistoryEntry[];
28
+ static readonly BuildUpdaters: Record<string, BuildUpdater>;
29
+ static readonly TransformationPatches: Record<string, TransformationPatch>;
30
+ static readonly Transformations: SetupTransformation[];
31
+ static readonly PreservedTraits: string[];
32
+ static change(change: number): number;
33
+ static composite(): void;
34
+ private static forceAngel;
35
+ static extend(valid: {
36
+ names: Set<string>;
37
+ traits: Set<string>;
38
+ }): void;
39
+ static merge<T extends {
40
+ name?: string;
41
+ parts?: TransformationPart[];
42
+ traits?: TransformationPart[];
43
+ }>(base: T[]): Array<T | SetupTransformation>;
44
+ private static mergeProperties;
45
+ private static mergeParts;
46
+ }
47
+ declare class DoLPcompat {
48
+ static get isDoLP(): boolean;
49
+ static install(core: MaplebirchCore): void;
50
+ static readonly Transformations: typeof Transformations;
51
+ static nnpc: {
52
+ showfn: (options: Record<string, any>) => boolean;
53
+ };
54
+ }
55
+ export default DoLPcompat;
@@ -0,0 +1,10 @@
1
+ import type ModLoader from '../host/ModLoader.js';
2
+ import type Translator from '../services/Translator.js';
3
+ declare class ModI18N {
4
+ private readonly translator;
5
+ private readonly modloader;
6
+ private installed;
7
+ constructor(translator: Translator, modloader: ModLoader);
8
+ install(): void;
9
+ }
10
+ export default ModI18N;
@@ -0,0 +1,43 @@
1
+ import type { MergeFilterFn } from '../utils/object.js';
2
+ import type { ContainsMode, ContainsOptions } from '../utils/array.js';
3
+ import type { ConvertMode } from '../utils/string.js';
4
+ declare global {
5
+ interface ObjectConstructor {
6
+ merge<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
7
+ append<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
8
+ cover<T extends object = Record<string, unknown>>(...sources: unknown[]): T;
9
+ mergefn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
10
+ appendfn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
11
+ coverfn<T extends object = Record<string, unknown>>(filterFn: MergeFilterFn | null, ...sources: unknown[]): T;
12
+ }
13
+ interface Array<T> {
14
+ contains(value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
15
+ either(weights?: number[], allowNull?: boolean): T | null | undefined;
16
+ }
17
+ interface ArrayConstructor {
18
+ merge<T>(...sources: readonly T[][]): T[];
19
+ append<T>(...sources: readonly T[][]): T[];
20
+ cover<T>(...sources: readonly T[][]): T[];
21
+ }
22
+ interface ReadonlyArray<T> {
23
+ contains(value: unknown, mode?: ContainsMode, options?: ContainsOptions): boolean;
24
+ either(weights?: number[], allowNull?: boolean): T | null | undefined;
25
+ }
26
+ interface String {
27
+ contains(value: string, options?: {
28
+ case?: boolean;
29
+ }): boolean;
30
+ convert(mode?: ConvertMode, options?: {
31
+ delimiter?: string;
32
+ acronym?: boolean;
33
+ }): string;
34
+ }
35
+ interface Math {
36
+ random(): number;
37
+ random(max: number): number;
38
+ random(min: number, max: number, float?: boolean): number;
39
+ clamp(value: unknown, min: number, max: number, fallback?: number): number;
40
+ }
41
+ }
42
+ declare function prototypeUtils(): void;
43
+ export default prototypeUtils;
@@ -0,0 +1 @@
1
+ export {};
package/constants.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ export type LanguageCode = (typeof Languages)[number];
2
+ export declare const version: string;
3
+ export declare const Languages: readonly ['EN', 'CN'];
4
+ export declare const Config: {
5
+ Title: string[];
6
+ DEBUG: string[];
7
+ DEBUGSTATUS: string[];
8
+ EnabledSTATUS: string[];
9
+ DisabledSTATUS: string[];
10
+ Languages: [string, string][];
11
+ LanguageSelection: string[];
12
+ EnableModule: string[];
13
+ DisableModule: string[];
14
+ EnableScript: string[];
15
+ DisableScript: string[];
16
+ ClearIndexedDB: string[];
17
+ };
18
+ export declare enum ModuleState {
19
+ REGISTERED = 0,
20
+ MOUNTED = 1,
21
+ ERROR = 2,
22
+ EXPOSED = 3,
23
+ DISABLED = 4
24
+ }
25
+ export declare const Translations: Record<LanguageCode, readonly string[]>;
26
+ export declare const TimeConstants: Readonly<{
27
+ secondsPerDay: 86400;
28
+ secondsPerHour: 3600;
29
+ secondsPerMinute: 60;
30
+ minutesPerHour: 60;
31
+ standardYearMonths: readonly number[];
32
+ leapYearMonths: readonly number[];
33
+ synodicMonth: 29.53058867;
34
+ MIN_DATE: Readonly<{
35
+ timeStamp: -315537984000;
36
+ year: -9999;
37
+ month: 1;
38
+ day: 1;
39
+ hour: 0;
40
+ minute: 0;
41
+ second: 0;
42
+ }>;
43
+ MAX_DATE: Readonly<{
44
+ timeStamp: 315537897599;
45
+ year: 9999;
46
+ month: 12;
47
+ day: 31;
48
+ hour: 23;
49
+ minute: 59;
50
+ second: 59;
51
+ }>;
52
+ }>;
package/core.d.ts ADDED
@@ -0,0 +1,143 @@
1
+ import type { Passage } from '@scml/types/sugarcube-2-ModLoader/SugarCube2';
2
+ import type { TwineSugarCube } from './types/twine-sugarcube.js';
3
+ import type { SC2DataManager } from '@scml/types/sugarcube-2-ModLoader/SC2DataManager';
4
+ import type { Gui } from '@scml/types/Mod_LoaderGui/Gui';
5
+ import * as marked from 'marked';
6
+ import jsyaml from 'js-yaml';
7
+ import { Howl } from 'howler';
8
+ import * as utils from './utils/index.js';
9
+ import ModLoader from './host/ModLoader.js';
10
+ import SugarCube, { type Save } from './host/SugarCube.js';
11
+ import Diagnostics from './infra/Diagnostics.js';
12
+ import Emitter, { type EventCallback } from './infra/Emitter.js';
13
+ import IndexedDB, { type StoreIndex, type Transaction } from './services/IndexedDB.js';
14
+ import CredentialVault from './services/CredentialVault.js';
15
+ import CloudSave from './services/CloudSave.js';
16
+ import Translator from './services/Translator.js';
17
+ import Modules, { type Module, type DependencyGraph } from './services/Modules.js';
18
+ import GUIControl from './services/GUIControl.js';
19
+ import AddonPlugin from './services/AddonPlugin.js';
20
+ declare global {
21
+ interface MaplebirchExtensions {
22
+ }
23
+ }
24
+ interface Extensions extends MaplebirchExtensions {
25
+ }
26
+ interface CoreEvents {
27
+ ':indexedDB': [];
28
+ ':idbReady': [];
29
+ ':import': [];
30
+ ':variable': [];
31
+ ':onSave': [save: Save];
32
+ ':onLoad': [save: Save];
33
+ ':language': [];
34
+ ':storyready': [];
35
+ ':passageinit': [passage: Passage];
36
+ ':passagestart': [passage: Passage, content: HTMLDivElement];
37
+ ':passagerender': [passage: Passage, content: HTMLDivElement];
38
+ ':passagedisplay': [passage: Passage, content: HTMLDivElement];
39
+ ':passageend': [passage: Passage, content: HTMLDivElement];
40
+ ':sugarcube': [];
41
+ ':modLoaderEnd': [];
42
+ }
43
+ export interface FrameworkHost {
44
+ readonly sugarcube: SugarCube;
45
+ readonly modLoader: ModLoader;
46
+ }
47
+ export interface FrameworkInfra {
48
+ readonly diagnostics: Diagnostics;
49
+ readonly events: Emitter;
50
+ }
51
+ export interface FrameworkServices {
52
+ readonly indexedDB: IndexedDB;
53
+ readonly modules: Modules;
54
+ readonly addonPlugin: AddonPlugin;
55
+ readonly translator: Translator;
56
+ readonly credentialVault: CredentialVault;
57
+ readonly cloudSave: CloudSave;
58
+ readonly gui: GUIControl;
59
+ }
60
+ type MaplebirchCore = InstanceType<typeof MaplebirchCore> & Extensions;
61
+ declare const MaplebirchCore: {
62
+ new (modSC2DataManager: SC2DataManager, modLoaderGui: Gui): {
63
+ readonly meta: {
64
+ name: 'maplebirch Frameworks';
65
+ author: string;
66
+ version: string;
67
+ modifiedby: string;
68
+ updateDate: string;
69
+ Languages: readonly ["EN", "CN"];
70
+ core: readonly string[];
71
+ protected: readonly string[];
72
+ };
73
+ readonly host: Readonly<FrameworkHost>;
74
+ readonly infra: Readonly<FrameworkInfra>;
75
+ readonly services: Readonly<FrameworkServices>;
76
+ readonly utils: Readonly<{
77
+ clone: typeof utils.clone;
78
+ equal: typeof utils.equal;
79
+ merge: typeof utils.merge;
80
+ append: typeof utils.append;
81
+ cover: typeof utils.cover;
82
+ mergefn: typeof utils.mergefn;
83
+ appendfn: typeof utils.appendfn;
84
+ coverfn: typeof utils.coverfn;
85
+ contains: typeof utils.contains;
86
+ random: typeof utils.random;
87
+ either: typeof utils.either;
88
+ SelectCase: typeof utils.SelectCase;
89
+ convert: typeof utils.convert;
90
+ clamp: typeof utils.clamp;
91
+ }>;
92
+ readonly yaml: Readonly<typeof jsyaml>;
93
+ readonly howler: Readonly<{
94
+ Howl: typeof Howl;
95
+ Howler: HowlerGlobal;
96
+ }>;
97
+ log(message: string, level?: string, ...objects: unknown[]): void;
98
+ get export(): string;
99
+ get passage(): Passage;
100
+ set passage(passage: Passage);
101
+ get SugarCube(): TwineSugarCube;
102
+ set SugarCube(runtime: TwineSugarCube);
103
+ get modUtils(): ReturnType<SC2DataManager['getModUtils']>;
104
+ get modLoader(): ReturnType<SC2DataManager['getModLoader']>;
105
+ get lodash(): ModLoader['lodash'];
106
+ get marked(): typeof marked;
107
+ get Language(): string;
108
+ set Language(language: string);
109
+ get LogLevel(): string;
110
+ set LogLevel(level: string);
111
+ get dependencyGraph(): DependencyGraph;
112
+ get modList(): string[];
113
+ on<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>, description?: string): boolean;
114
+ on<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>, description?: string): boolean;
115
+ off<Args extends unknown[]>(eventName: string, identifier: string | EventCallback<Args>): boolean;
116
+ once<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>, description?: string): boolean;
117
+ once<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>, description?: string): boolean;
118
+ after<Name extends keyof CoreEvents>(eventName: Name, callback: EventCallback<CoreEvents[Name]>): void;
119
+ after<Name extends string, Args extends unknown[]>(eventName: Name extends keyof CoreEvents ? never : Name, callback: EventCallback<Args>): void;
120
+ trigger<Name extends keyof CoreEvents>(eventName: Name, ...args: CoreEvents[Name]): Promise<void>;
121
+ trigger<Name extends string>(eventName: Name extends keyof CoreEvents ? never : Name, ...args: unknown[]): Promise<void>;
122
+ define<T extends object>(name: string, module: T & Module, dependencies?: string[]): boolean;
123
+ idb(name: string, options?: IDBObjectStoreParameters, indexes?: StoreIndex[]): boolean;
124
+ with<T, Mode extends IDBTransactionMode>(storeNames: string | string[], mode: Mode, callback: (tx: Transaction<Mode>) => T | Promise<T>): Promise<T>;
125
+ t(key: string, space?: boolean): string;
126
+ auto(text: string): string;
127
+ get<K extends keyof Extensions>(name: K): Extensions[K] | undefined;
128
+ get(name: string): Module | undefined;
129
+ };
130
+ meta: {
131
+ name: 'maplebirch Frameworks';
132
+ author: string;
133
+ version: string;
134
+ modifiedby: string;
135
+ updateDate: string;
136
+ Languages: readonly ["EN", "CN"];
137
+ core: readonly string[];
138
+ protected: readonly string[];
139
+ };
140
+ };
141
+ declare var maplebirch: MaplebirchCore;
142
+ export { MaplebirchCore, type CoreEvents, type Extensions };
143
+ export default maplebirch;
package/host/DoL.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ export type DoLVariables = typeof V;
2
+ export type DoLTemporary = typeof T;
3
+ export type DoLCharacters = typeof C;
4
+ export type DoLSetup = typeof setup;
5
+ export type DoLRenderer = typeof Renderer;
6
+ export type DoLGlobalName = 'V' | 'T' | 'C' | 'setup' | 'Renderer' | 'variables' | 'temporary' | 'characters' | 'renderer';
7
+ export interface DoLHost {
8
+ readonly V: DoLVariables;
9
+ readonly T: DoLTemporary;
10
+ readonly C: DoLCharacters;
11
+ readonly setup: DoLSetup;
12
+ readonly Renderer: DoLRenderer;
13
+ readonly variables: DoLVariables;
14
+ readonly temporary: DoLTemporary;
15
+ readonly characters: DoLCharacters;
16
+ readonly renderer: DoLRenderer;
17
+ readonly gameVersion: string;
18
+ has(name: DoLGlobalName): boolean;
19
+ }
20
+ export interface DoLGlobalScope {
21
+ V?: DoLVariables;
22
+ T?: DoLTemporary;
23
+ C?: DoLCharacters;
24
+ setup?: DoLSetup;
25
+ Renderer?: DoLRenderer;
26
+ }
27
+ export declare class DoL implements DoLHost {
28
+ private readonly scope;
29
+ constructor(scope?: DoLGlobalScope);
30
+ get V(): DoLVariables;
31
+ get T(): DoLTemporary;
32
+ get C(): DoLCharacters;
33
+ get setup(): DoLSetup;
34
+ get Renderer(): DoLRenderer;
35
+ get variables(): DoLVariables;
36
+ get temporary(): DoLTemporary;
37
+ get characters(): DoLCharacters;
38
+ get renderer(): DoLRenderer;
39
+ get gameVersion(): string;
40
+ has(name: DoLGlobalName): boolean;
41
+ private require;
42
+ }
43
+ declare const dol: DoL;
44
+ export default dol;
@@ -0,0 +1,37 @@
1
+ import type { Gui } from '@scml/types/Mod_LoaderGui/Gui';
2
+ import type { SC2DataManager } from '@scml/types/sugarcube-2-ModLoader/SC2DataManager';
3
+ import Diagnostics, { type PatchResult } from '../infra/Diagnostics.js';
4
+ import Resources from './Resources.js';
5
+ export type Replacement = [RegExp, string];
6
+ type TwineAssetMode = 'append' | 'replace' | 'patch';
7
+ export interface SourcePatch {
8
+ src?: string;
9
+ srcmatch?: RegExp;
10
+ srcmatchgroup?: RegExp;
11
+ to?: string;
12
+ applyafter?: string;
13
+ applybefore?: string;
14
+ expected?: number;
15
+ }
16
+ export interface SourcePatchResult extends Pick<PatchResult, 'pattern' | 'matches' | 'applied' | 'status' | 'expected' | 'error'> {
17
+ content: string;
18
+ }
19
+ export declare function applySourcePatch(source: string, patch: SourcePatch): SourcePatchResult;
20
+ export declare class ModLoader {
21
+ readonly modSC2DataManager: SC2DataManager;
22
+ readonly modLoaderGui: Gui;
23
+ static getLodash(): ReturnType<ReturnType<SC2DataManager['getModUtils']>['getLodash']>;
24
+ readonly diagnostics: Diagnostics;
25
+ readonly resources: Resources;
26
+ constructor(modSC2DataManager: SC2DataManager, modLoaderGui: Gui);
27
+ replace(content: string, replacements: Replacement[], label?: string): string;
28
+ defineTwineAsset(type: 'script' | 'style', name: string, content: string | ((current: string) => string), mode?: TwineAssetMode): void;
29
+ disabled(modNames: string | string[], reload?: boolean): Promise<boolean>;
30
+ get modUtils(): ReturnType<SC2DataManager['getModUtils']>;
31
+ get modLoader(): ReturnType<SC2DataManager['getModLoader']>;
32
+ get loadController(): ReturnType<SC2DataManager['getModLoadController']>;
33
+ get dependence(): ReturnType<SC2DataManager['getDependenceChecker']>;
34
+ get conflict(): ReturnType<SC2DataManager['getConflictResult']>;
35
+ get lodash(): ReturnType<ReturnType<SC2DataManager['getModUtils']>['getLodash']>;
36
+ }
37
+ export default ModLoader;
@@ -0,0 +1,15 @@
1
+ import type { SC2DataManager } from '@scml/types/sugarcube-2-ModLoader/SC2DataManager';
2
+ type ImageResult = string | false;
3
+ declare class Resources {
4
+ private readonly manager;
5
+ private readonly report;
6
+ private readonly cache;
7
+ private readonly pending;
8
+ constructor(manager: SC2DataManager, report: (path: string, error: unknown) => void);
9
+ normalize(path: string): string;
10
+ has(path: string): boolean | undefined;
11
+ load(path: string): ImageResult | Promise<ImageResult>;
12
+ clear(path?: string): void;
13
+ private resolve;
14
+ }
15
+ export default Resources;
@@ -0,0 +1,25 @@
1
+ import type { Passage } from '@scml/types/sugarcube-2-ModLoader/SugarCube2';
2
+ import type { DolStateAPI, DolStateMoment, TwineSugarCube } from '../types/twine-sugarcube.js';
3
+ export interface SaveObject {
4
+ state: {
5
+ history: DolStateMoment[];
6
+ index?: number;
7
+ [key: string]: unknown;
8
+ };
9
+ [key: string]: unknown;
10
+ }
11
+ export declare class Save {
12
+ private readonly state;
13
+ readonly details?: unknown;
14
+ readonly saveObj: SaveObject;
15
+ constructor(state: DolStateAPI, saveObj: unknown, details?: unknown);
16
+ get V(): Record<string, unknown>;
17
+ use<Result>(variables: Record<string, unknown>, callback: () => Result): Result;
18
+ }
19
+ export declare class SugarCube {
20
+ runtime: TwineSugarCube | undefined;
21
+ passage: Passage;
22
+ require(): TwineSugarCube;
23
+ save(saveObj: unknown, details?: unknown): Save;
24
+ }
25
+ export default SugarCube;
package/index.d.ts CHANGED
@@ -1,30 +1,11 @@
1
- import instance, * as types from './maplebirch';
2
-
3
- type Utils = typeof types.utils.publicUtils;
4
-
5
- declare global {
6
- const maplebirch: typeof instance;
7
- function clone<T>(...args: Parameters<typeof types.utils.clone<T>>): ReturnType<typeof types.utils.clone<T>>;
8
- const equal: Utils['equal'];
9
- const merge: Utils['merge'];
10
- const append: Utils['append'];
11
- const cover: Utils['cover'];
12
- const mergefn: Utils['mergefn'];
13
- const appendfn: Utils['appendfn'];
14
- const coverfn: Utils['coverfn'];
15
- const contains: Utils['contains'];
16
- function random(...args: Parameters<Utils['random']>): ReturnType<Utils['random']>;
17
- function either<T>(...args: Parameters<typeof types.utils.either<T>>): ReturnType<typeof types.utils.either<T>>;
18
- const SelectCase: Utils['SelectCase'];
19
- const convert: Utils['convert'];
20
- const clamp: Utils['clamp'];
21
- const loadImage: typeof types.ImageLoader.load;
22
-
23
- interface Window extends Readonly<Utils> {
24
- readonly maplebirch: typeof instance;
25
- readonly loadImage: typeof types.ImageLoader.load;
26
- }
27
- }
28
-
29
- export default instance;
30
- export * from './maplebirch';
1
+ import './modules/DoL/index.js';
2
+ import './compat/SimpleFrameworks.js';
3
+ import './compat/Prototype.js';
4
+ import './types/global.js';
5
+ export { default } from './main.js';
6
+ export * from './main.js';
7
+ export { default as dol, DoL, type DoLHost, type DoLGlobalScope } from './host/DoL.js';
8
+ export type { CoreModules } from './modules/DoL/types.js';
9
+ export { default as DoLDynamic } from './modules/DoL/Dynamic.js';
10
+ export { default as DoLToolCollection } from './modules/DoL/ToolCollection.js';
11
+ export { default as ImageLoader } from './modules/Frameworks/ImageLoader.js';
@@ -0,0 +1,14 @@
1
+ import type ModLoader from '../host/ModLoader.js';
2
+ import Diagnostics from './Diagnostics.js';
3
+ export declare class Catalog<Key, Value> extends Diagnostics {
4
+ protected readonly items: Map<Key, Value>;
5
+ constructor(modloader?: ModLoader, entries?: Iterable<readonly [Key, Value]>);
6
+ add(key: Key, value: Value): boolean;
7
+ remove(key: Key): boolean;
8
+ get(key: Key): Value | undefined;
9
+ has(key: Key): boolean;
10
+ list(): Value[];
11
+ clear(): void;
12
+ get entries(): ReadonlyMap<Key, Value>;
13
+ }
14
+ export default Catalog;
@@ -0,0 +1,48 @@
1
+ import type ModLoader from '../host/ModLoader.js';
2
+ import Logger, { type LogLevel } from './Logger.js';
3
+ export interface DiagnosticRecord {
4
+ at: string;
5
+ level: LogLevel;
6
+ scope?: string;
7
+ message: string;
8
+ data?: unknown;
9
+ }
10
+ export interface PatchResult {
11
+ kind: 'passage' | 'script' | 'style' | 'source';
12
+ target: string;
13
+ index: number;
14
+ pattern: string;
15
+ matches: number;
16
+ applied: number;
17
+ status: 'applied' | 'unmatched' | 'missing' | 'invalid' | 'mismatch' | 'error';
18
+ expected?: number;
19
+ error?: string;
20
+ }
21
+ export interface ModConflict {
22
+ source: string;
23
+ dataSource: string;
24
+ passages: string[];
25
+ scripts: string[];
26
+ styles: string[];
27
+ }
28
+ export type ScopedLog = (message: string, level?: string, ...objects: unknown[]) => void;
29
+ export declare class Diagnostics extends Logger {
30
+ readonly scope: string;
31
+ private static readonly entries;
32
+ private static readonly patchResults;
33
+ constructor(modloader?: ModLoader, scope?: string);
34
+ static message(error: unknown): string;
35
+ log(message: string, levelName?: string | number, ...objects: unknown[]): void;
36
+ record(message: string, level?: string, scope?: string, ...objects: unknown[]): void;
37
+ write(message: string, level?: string, scope?: string, ...objects: unknown[]): void;
38
+ scoped(scope: string): ScopedLog;
39
+ get history(): readonly DiagnosticRecord[];
40
+ get errors(): DiagnosticRecord[];
41
+ get patches(): PatchResult[];
42
+ recordPatch(result: PatchResult): void;
43
+ clearPatches(): void;
44
+ get conflicts(): ModConflict[] | undefined;
45
+ export(): string;
46
+ reset(): void;
47
+ }
48
+ export default Diagnostics;
@@ -0,0 +1,18 @@
1
+ import Diagnostics from './Diagnostics.js';
2
+ export type EventCallback<Args extends unknown[] = unknown[]> = (...args: Args) => unknown;
3
+ export declare class Emitter extends Diagnostics {
4
+ private readonly events;
5
+ private readonly afters;
6
+ private readonly triggering;
7
+ private readonly stickyEvents;
8
+ private readonly stickyArgs;
9
+ private readonly synchronousEvents;
10
+ on<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>, description?: string): boolean;
11
+ off<Args extends unknown[]>(eventName: string, identifier: EventCallback<Args> | string): boolean;
12
+ once<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>, description?: string): boolean;
13
+ trigger(eventName: string, ...args: unknown[]): Promise<void>;
14
+ after<Args extends unknown[]>(eventName: string, callback: EventCallback<Args>): void;
15
+ private pending;
16
+ private callSticky;
17
+ }
18
+ export default Emitter;
@@ -0,0 +1,15 @@
1
+ import type ModLoader from '../host/ModLoader.js';
2
+ import Catalog from './Catalog.js';
3
+ export type HookCallback<Args extends unknown[] = unknown[], Result = unknown> = (...args: Args) => Result | Promise<Result>;
4
+ export type HookErrorPolicy = 'throw' | 'continue';
5
+ export declare class Hooks<Args extends unknown[] = unknown[], Result = unknown> extends Catalog<string, HookCallback<Args, Result>> {
6
+ private readonly onError;
7
+ private readonly order;
8
+ constructor(modloader?: ModLoader, onError?: HookErrorPolicy);
9
+ add(name: string, callback: HookCallback<Args, Result>, order?: number): boolean;
10
+ remove(name: string): boolean;
11
+ clear(): void;
12
+ execute(...args: Args): Result[];
13
+ call(name: string, ...args: Args): Promise<Awaited<Result> | undefined>;
14
+ }
15
+ export default Hooks;
@@ -0,0 +1,24 @@
1
+ import Catalog from './Catalog.js';
2
+ export type LifecyclePhase = 'preInit' | 'Init' | 'loadInit' | 'postInit';
3
+ export interface LifecycleTarget {
4
+ preInit?(): void | Promise<void>;
5
+ Init?(): void;
6
+ loadInit?(): void;
7
+ postInit?(): void;
8
+ }
9
+ export interface LifecycleResult {
10
+ called: boolean;
11
+ ok: boolean;
12
+ error?: unknown;
13
+ }
14
+ export declare class Lifecycle<Key = string, Target extends LifecycleTarget = LifecycleTarget> extends Catalog<Key, Target> {
15
+ preInit(): void | Promise<void>;
16
+ Init(): void;
17
+ loadInit(): void;
18
+ postInit(): void;
19
+ execute(target: Target, phase: 'preInit', scope?: string): Promise<LifecycleResult>;
20
+ execute(target: Target, phase: Exclude<LifecyclePhase, 'preInit'>, scope?: string): LifecycleResult;
21
+ execute(target: Target, phase: LifecyclePhase, scope?: string): LifecycleResult | Promise<LifecycleResult>;
22
+ private failure;
23
+ }
24
+ export default Lifecycle;
@@ -0,0 +1,15 @@
1
+ import type ModLoader from '../host/ModLoader.js';
2
+ export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
3
+ export declare class Logger {
4
+ readonly modloader?: ModLoader | undefined;
5
+ private static readonly LEVELS;
6
+ private static readonly CONFIG;
7
+ private static readonly FORWARD;
8
+ private static level;
9
+ constructor(modloader?: ModLoader | undefined);
10
+ static toLevel(level: string | number): LogLevel;
11
+ log(message: string, levelName?: string | number, ...objects: unknown[]): void;
12
+ set LevelName(levelName: string);
13
+ get LevelName(): string;
14
+ }
15
+ export default Logger;