zois-core 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +23 -2
  2. package/dist/changelogs.js +167 -0
  3. package/dist/core-subscreen/coreSubscreen.js +81 -0
  4. package/dist/core-subscreen/developmentSubscreen.js +22 -0
  5. package/dist/core-subscreen/generalSubscreen.js +23 -0
  6. package/dist/core-subscreen/mainSubscreen.js +58 -0
  7. package/dist/core-subscreen/shards/coreButtonShard.js +30 -0
  8. package/dist/core-subscreen/shards/coreCheckboxShard.js +33 -0
  9. package/dist/core-subscreen/shards/coreInputListShard.js +38 -0
  10. package/dist/core-subscreen/shards/coreSelectShard.js +17 -0
  11. package/dist/core-subscreen/shards/coreTextShard.js +9 -0
  12. package/dist/core-subscreen/shards/index.js +5 -0
  13. package/dist/core-subscreen/toastsSubscreen.js +112 -0
  14. package/dist/core.js +178 -0
  15. package/dist/dialogs.js +110 -0
  16. package/dist/index.js +202 -1
  17. package/dist/localization.js +71 -0
  18. package/dist/logging.js +31 -0
  19. package/dist/messaging.js +234 -1
  20. package/dist/modSdk.js +63 -0
  21. package/dist/shard-modules/attributesModule.js +16 -0
  22. package/dist/shard-modules/centerModule.js +12 -0
  23. package/dist/shard-modules/clickModule.js +14 -0
  24. package/dist/shard-modules/counterUpModule.js +37 -0
  25. package/dist/shard-modules/dynamicClassModule.js +15 -0
  26. package/dist/shard-modules/index.js +9 -0
  27. package/dist/shard-modules/multiClickModule.js +41 -0
  28. package/dist/shard-modules/shardModule.js +12 -0
  29. package/dist/shard-modules/styleModule.js +20 -0
  30. package/dist/shard-modules/typeModule.js +37 -0
  31. package/dist/shards/backNextButtonShard.js +99 -0
  32. package/dist/shards/buttonShard.js +118 -0
  33. package/dist/shards/cardShard.js +35 -0
  34. package/dist/shards/checkboxShard.js +139 -0
  35. package/dist/shards/containerShard.js +16 -0
  36. package/dist/shards/imageShard.js +98 -0
  37. package/dist/shards/index.js +13 -0
  38. package/dist/shards/inputListShard.js +162 -0
  39. package/dist/shards/inputShard.js +33 -0
  40. package/dist/shards/selectShard.js +126 -0
  41. package/dist/shards/shard.js +79 -0
  42. package/dist/shards/svgShard.js +47 -0
  43. package/dist/shards/tabsShard.js +59 -0
  44. package/dist/shards/textShard.js +27 -0
  45. package/dist/styles.css +209 -1
  46. package/dist/toasts.js +188 -0
  47. package/dist/types/changelogs.d.ts +1 -0
  48. package/dist/types/core-subscreen/coreSubscreen.d.ts +15 -0
  49. package/dist/types/core-subscreen/developmentSubscreen.d.ts +5 -0
  50. package/dist/types/core-subscreen/generalSubscreen.d.ts +5 -0
  51. package/dist/types/core-subscreen/mainSubscreen.d.ts +6 -0
  52. package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +5 -0
  53. package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +6 -0
  54. package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +6 -0
  55. package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +5 -0
  56. package/dist/types/core-subscreen/shards/coreTextShard.d.ts +4 -0
  57. package/dist/types/core-subscreen/shards/index.d.ts +5 -0
  58. package/dist/types/core-subscreen/toastsSubscreen.d.ts +5 -0
  59. package/dist/types/core.d.ts +18 -0
  60. package/dist/types/dialogs.d.ts +29 -0
  61. package/dist/types/index.d.ts +55 -5
  62. package/dist/types/localization.d.ts +4 -0
  63. package/dist/types/logging.d.ts +16 -0
  64. package/dist/types/messaging.d.ts +5 -3
  65. package/dist/types/{modsApi.d.ts → modSdk.d.ts} +2 -2
  66. package/dist/types/shard-modules/attributesModule.d.ts +7 -0
  67. package/dist/types/shard-modules/centerModule.d.ts +5 -0
  68. package/dist/types/shard-modules/clickModule.d.ts +7 -0
  69. package/dist/types/shard-modules/counterUpModule.d.ts +13 -0
  70. package/dist/types/shard-modules/dynamicClassModule.d.ts +8 -0
  71. package/dist/types/{ui-modules → shard-modules}/index.d.ts +2 -0
  72. package/dist/types/shard-modules/multiClickModule.d.ts +12 -0
  73. package/dist/types/shard-modules/shardModule.d.ts +7 -0
  74. package/dist/types/shard-modules/styleModule.d.ts +8 -0
  75. package/dist/types/shard-modules/typeModule.d.ts +11 -0
  76. package/dist/types/shards/backNextButtonShard.d.ts +14 -0
  77. package/dist/types/shards/buttonShard.d.ts +20 -0
  78. package/dist/types/shards/cardShard.d.ts +10 -0
  79. package/dist/types/shards/checkboxShard.d.ts +19 -0
  80. package/dist/types/shards/containerShard.d.ts +7 -0
  81. package/dist/types/shards/imageShard.d.ts +11 -0
  82. package/dist/types/shards/index.d.ts +13 -0
  83. package/dist/types/shards/inputListShard.d.ts +16 -0
  84. package/dist/types/shards/inputShard.d.ts +14 -0
  85. package/dist/types/shards/selectShard.d.ts +17 -0
  86. package/dist/types/shards/shard.d.ts +21 -0
  87. package/dist/types/shards/svgShard.d.ts +12 -0
  88. package/dist/types/shards/tabsShard.d.ts +17 -0
  89. package/dist/types/shards/textShard.d.ts +13 -0
  90. package/dist/types/toasts.d.ts +21 -0
  91. package/dist/types/ui.d.ts +27 -147
  92. package/dist/ui.js +351 -11
  93. package/dist/validation.js +31 -1
  94. package/dist/wardrobe.js +167 -1
  95. package/package.json +44 -26
  96. package/scripts/generateChangelog.mjs +80 -0
  97. package/dist/modsApi.js +0 -1
  98. package/dist/modules.js +0 -1
  99. package/dist/popups.js +0 -1
  100. package/dist/types/modules.d.ts +0 -18
  101. package/dist/types/popups.d.ts +0 -63
  102. package/dist/types/ui-modules/attributesModule.d.ts +0 -6
  103. package/dist/types/ui-modules/centerModule.d.ts +0 -4
  104. package/dist/types/ui-modules/clickModule.d.ts +0 -6
  105. package/dist/types/ui-modules/counterUpModule.d.ts +0 -12
  106. package/dist/types/ui-modules/dynamicClassModule.d.ts +0 -7
  107. package/dist/types/ui-modules/styleModule.d.ts +0 -7
  108. package/dist/types/ui-modules/typeModule.d.ts +0 -10
  109. package/dist/ui-modules/attributesModule.js +0 -1
  110. package/dist/ui-modules/centerModule.js +0 -1
  111. package/dist/ui-modules/clickModule.js +0 -1
  112. package/dist/ui-modules/counterUpModule.js +0 -1
  113. package/dist/ui-modules/dynamicClassModule.js +0 -1
  114. package/dist/ui-modules/index.js +0 -1
  115. package/dist/ui-modules/styleModule.js +0 -1
  116. package/dist/ui-modules/typeModule.js +0 -1
package/dist/toasts.js ADDED
@@ -0,0 +1,188 @@
1
+ import { CircleAlert, CircleCheck, CircleX, createElement, Info } from "lucide";
2
+ import { MOD_DATA } from "./index";
3
+ import { setPosition } from "./ui";
4
+ import { logger } from "./logging";
5
+ function createToastsContainer() {
6
+ const container = document.createElement("div");
7
+ container.classList.add("zcToastsContainer");
8
+ container.addEventListener("click", () => {
9
+ const pos = window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left";
10
+ for (const toast of container.children) {
11
+ if (toast instanceof HTMLElement) {
12
+ toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
13
+ }
14
+ }
15
+ setTimeout(() => container.innerHTML = "", 300);
16
+ });
17
+ const update = () => {
18
+ container.style.cssText = `font-family: ${CommonGetFontName()};`;
19
+ setPosition(container, 5, 5, window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left");
20
+ };
21
+ window.addEventListener("resize", update);
22
+ document.body.append(container);
23
+ update();
24
+ document.addEventListener("zois-core:coresettingschanged", update);
25
+ return container;
26
+ }
27
+ function getToastIcon(type, theme) {
28
+ let icon;
29
+ switch (type) {
30
+ case "info":
31
+ icon = createElement(Info);
32
+ icon.style.fill = theme ? theme.iconFillColor : "rgb(68, 70, 202)";
33
+ icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(148, 178, 217)";
34
+ break;
35
+ case "warning":
36
+ icon = createElement(CircleAlert);
37
+ icon.style.fill = theme ? theme.iconFillColor : "rgb(198, 146, 25)";
38
+ icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(244, 220, 147)";
39
+ break;
40
+ case "error":
41
+ icon = createElement(CircleX);
42
+ icon.style.fill = theme ? theme.iconFillColor : "rgb(174, 1, 1)";
43
+ icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(255, 163, 163)";
44
+ break;
45
+ case "success":
46
+ icon = createElement(CircleCheck);
47
+ icon.style.fill = theme ? theme.iconFillColor : "rgb(49, 142, 68)";
48
+ icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(122, 213, 162)";
49
+ break;
50
+ case "spinner":
51
+ icon = document.createElement("div");
52
+ icon.style.cssText = `
53
+ box-sizing: border-box;
54
+ border: 2px solid;
55
+ border-radius: 100%;
56
+ border-color: transparent ${theme ? theme.iconFillColor : "rgb(68, 70, 202)"};
57
+ animation: zcSpin 0.65s linear infinite;
58
+ `;
59
+ break;
60
+ }
61
+ icon.style.cssText += `flex-shink: 0; width: 1.65em; height: 1.65em;`;
62
+ return icon;
63
+ }
64
+ function createToast({ title, message, type, duration, theme, id }) {
65
+ const pos = window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left";
66
+ const backgroundColor = theme ? theme.backgroundColor : type === "success" ? "rgb(122, 213, 162)" : type === "warning" ? "rgb(244, 220, 147)" : type === "error" ? "rgb(255, 163, 163)" : "rgb(148, 178, 217)";
67
+ const textColor = theme ? theme.titleColor : type === "info" || type === "spinner" ? "rgb(0, 2, 125)" : type === "success" ? "#244428" : type === "error" ? "rgb(128, 22, 22)" : "rgb(100, 74, 16)";
68
+ const progressBarColor = theme ? theme.progressBarColor : "#00000014";
69
+ const toastContainer = document.querySelector(".zcToastsContainer") ?? createToastsContainer();
70
+ const toast = document.createElement("div");
71
+ toast.classList.add("zcToast");
72
+ toast.setAttribute("data-zc-toast-type", type);
73
+ toast.setAttribute("data-zc-toast-id", id);
74
+ const update = () => {
75
+ const canvasWidth = MainCanvas.canvas.clientWidth;
76
+ const canvasHeight = MainCanvas.canvas.clientHeight;
77
+ const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
78
+ toast.style.cssText = `width: 100%; font-size: ${2.85 * scaleFactor}px; padding: ${1 * scaleFactor}px; background: ${backgroundColor}; border: 1px solid #555;`;
79
+ toast.style.animation = `${pos.includes("left") ? "zcSlideInFromLeft" : "zcSlideInFromRight"} 0.3s ease-out forwards`;
80
+ };
81
+ if (type !== "spinner") {
82
+ const progressBar = document.createElement("div");
83
+ progressBar.classList.add("zcToast-ProgressBar");
84
+ progressBar.style.cssText = `animation: zcToast-progress ${duration}ms linear 0s 1 alternate none; position: absolute; top: 0; left: 0; height: 100%; border-radius: 4px; background: ${progressBarColor};`;
85
+ toast.append(progressBar);
86
+ }
87
+ const textContainer = document.createElement("div");
88
+ if (title) {
89
+ const _title = document.createElement("p");
90
+ _title.style.color = textColor;
91
+ _title.style.fontWeight = "bold";
92
+ _title.style.fontSize = "0.9em";
93
+ _title.textContent = title;
94
+ textContainer.append(_title);
95
+ }
96
+ const _message = document.createElement("p");
97
+ _message.style.color = textColor;
98
+ _message.style.fontSize = !!title ? "0.7em" : "0.9em";
99
+ _message.style.overflowWrap = "anywhere";
100
+ if (!title) {
101
+ _message.style.fontWeight = "bold";
102
+ } else {
103
+ _message.style.marginTop = "0.15em";
104
+ }
105
+ _message.textContent = message;
106
+ textContainer.append(_message);
107
+ toast.append(getToastIcon(type, theme), textContainer);
108
+ update();
109
+ window.addEventListener("resize", update);
110
+ toastContainer.append(toast);
111
+ setTimeout(() => {
112
+ toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
113
+ }, duration);
114
+ setTimeout(() => toast.remove(), duration + 300);
115
+ }
116
+ class ToastsManager {
117
+ generateToastId() {
118
+ return crypto.randomUUID();
119
+ }
120
+ process({ title, message, duration, type, id, theme }) {
121
+ const coreSettings = window.ZOIS_CORE.getSettings();
122
+ if (coreSettings.toasts?.blacklist?.enabled && coreSettings.toasts.blacklist.content?.length !== 0) {
123
+ if (coreSettings.toasts.blacklist.content?.some((v) => {
124
+ const regexp = new RegExp(v);
125
+ return regexp.test(title ?? "") || regexp.test(message);
126
+ })) {
127
+ logger.log("Toast message blocked due to blacklist settings");
128
+ return;
129
+ }
130
+ }
131
+ if (coreSettings.toasts?.preventUsingSingleTheme) {
132
+ createToast({
133
+ id,
134
+ title,
135
+ message,
136
+ duration,
137
+ type
138
+ });
139
+ } else {
140
+ createToast({
141
+ id,
142
+ title,
143
+ message,
144
+ duration,
145
+ type,
146
+ theme
147
+ });
148
+ }
149
+ }
150
+ info({ title, message, duration }) {
151
+ const id = this.generateToastId();
152
+ const theme = MOD_DATA.singleToastsTheme;
153
+ this.process({ title, message, duration, type: "info", id, theme });
154
+ }
155
+ success({ title, message, duration }) {
156
+ const id = this.generateToastId();
157
+ const theme = MOD_DATA.singleToastsTheme;
158
+ this.process({ title, message, duration, type: "success", id, theme });
159
+ }
160
+ warn({ title, message, duration }) {
161
+ const id = this.generateToastId();
162
+ const theme = MOD_DATA.singleToastsTheme;
163
+ this.process({ title, message, duration, type: "warning", id, theme });
164
+ }
165
+ error({ title, message, duration }) {
166
+ const id = this.generateToastId();
167
+ const theme = MOD_DATA.singleToastsTheme;
168
+ this.process({ title, message, duration, type: "error", id, theme });
169
+ }
170
+ spinner({ title, message }) {
171
+ const id = this.generateToastId();
172
+ const theme = MOD_DATA.singleToastsTheme;
173
+ this.process({ title, message, duration: 1e6, type: "spinner", id, theme });
174
+ return id;
175
+ }
176
+ removeSpinner(id) {
177
+ const toast = document.querySelector(`div[data-zc-toast-id="${id}"]`);
178
+ if (!toast) return;
179
+ const pos = window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left";
180
+ toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
181
+ setTimeout(() => toast.remove(), 300);
182
+ }
183
+ }
184
+ const toastsManager = new ToastsManager();
185
+ export {
186
+ ToastsManager,
187
+ toastsManager
188
+ };
@@ -0,0 +1 @@
1
+ export declare function showChangelogModal(): Promise<void>;
@@ -0,0 +1,15 @@
1
+ import { BaseSubscreen } from "../ui";
2
+ import { ButtonShardContext, CheckboxShardContext, InputListShardContext, SelectShardContext, TextShardContext } from "../shards";
3
+ export declare abstract class CoreSubscreen extends BaseSubscreen {
4
+ private g;
5
+ private h;
6
+ private interval;
7
+ run(): void;
8
+ load(): void;
9
+ createText(ctx: TextShardContext): HTMLParagraphElement;
10
+ createButton(ctx: ButtonShardContext): HTMLButtonElement;
11
+ createCheckbox(ctx: CheckboxShardContext): HTMLDivElement;
12
+ createInputList(ctx: InputListShardContext): HTMLDivElement;
13
+ createSelect(ctx: SelectShardContext): HTMLDivElement;
14
+ unload(): void;
15
+ }
@@ -0,0 +1,5 @@
1
+ import { CoreSubscreen } from "./coreSubscreen";
2
+ export declare class DevelopmentSubscreen extends CoreSubscreen {
3
+ get name(): string;
4
+ load(): void;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { CoreSubscreen } from "./coreSubscreen";
2
+ export declare class GeneralSubscreen extends CoreSubscreen {
3
+ get name(): string;
4
+ load(): void;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { CoreSubscreen } from "./coreSubscreen";
2
+ export declare class MainSubscreen extends CoreSubscreen {
3
+ get name(): string;
4
+ load(): void;
5
+ exit(): void;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { DynamicClassStyles } from "../../ui";
2
+ import { ButtonShard } from "../../shards";
3
+ export declare class CoreButtonShard extends ButtonShard {
4
+ protected get dynamicClassButton(): DynamicClassStyles;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { CheckboxShard } from "../../shards";
2
+ import { DynamicClassStyles } from "../../ui";
3
+ export declare class CoreCheckboxShard extends CheckboxShard {
4
+ protected get dynamicClassInput(): DynamicClassStyles;
5
+ protected get textColor(): string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { InputListShard } from "../../shards";
2
+ import { DynamicClassStyles } from "../../ui";
3
+ export declare class CoreInputListShard extends InputListShard {
4
+ get dynamicClassContainer(): DynamicClassStyles;
5
+ get dynamicClassToolsButton(): DynamicClassStyles;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { SelectShard } from "../../shards";
2
+ import { DynamicClassStyles } from "../../ui";
3
+ export declare class CoreSelectShard extends SelectShard {
4
+ get dynamicClassContainer(): DynamicClassStyles;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { TextShard } from "../../shards";
2
+ export declare class CoreTextShard extends TextShard {
3
+ get defaultColor(): string;
4
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./coreButtonShard";
2
+ export * from "./coreTextShard";
3
+ export * from "./coreSelectShard";
4
+ export * from "./coreCheckboxShard";
5
+ export * from "./coreInputListShard";
@@ -0,0 +1,5 @@
1
+ import { CoreSubscreen } from "./coreSubscreen";
2
+ export declare class ToastsSubscreen extends CoreSubscreen {
3
+ get name(): string;
4
+ load(): void;
5
+ }
@@ -0,0 +1,18 @@
1
+ import { ModData } from "./index";
2
+ import { Anchor } from "./ui";
3
+ export interface CoreSettings {
4
+ devMode?: boolean;
5
+ toasts?: {
6
+ position?: Anchor;
7
+ preventUsingSingleTheme?: boolean;
8
+ singleTheme?: ModData["singleToastsTheme"];
9
+ blacklist?: {
10
+ enabled?: boolean;
11
+ content?: string[];
12
+ };
13
+ };
14
+ }
15
+ export declare let coreSettings: CoreSettings;
16
+ export declare function syncSettings(): void;
17
+ export declare function registerSubscreen(): void;
18
+ export declare function registerCore(): Promise<void>;
@@ -0,0 +1,29 @@
1
+ interface BaseDialogProps<T> {
2
+ type: "prompt" | "confirm" | "pick";
3
+ message: string;
4
+ promise: {
5
+ resolve: (data: T) => void;
6
+ reject: (data: T) => void;
7
+ };
8
+ }
9
+ interface ConfirmDialogProps extends BaseDialogProps<boolean> {
10
+ type: "confirm";
11
+ }
12
+ interface PromptDialogProps extends BaseDialogProps<string | false> {
13
+ type: "prompt";
14
+ }
15
+ interface PickDialogProps<T> extends BaseDialogProps<T | false> {
16
+ type: "pick";
17
+ options: {
18
+ name: string;
19
+ value: T;
20
+ }[];
21
+ }
22
+ export declare class DialogsManager {
23
+ private process;
24
+ prompt({ message }: Omit<PromptDialogProps, "type" | "promise">): Promise<string | false>;
25
+ confirm({ message }: Omit<ConfirmDialogProps, "type" | "promise">): Promise<boolean>;
26
+ pick<T>({ message, options }: Omit<PickDialogProps<T>, "type" | "promise">): Promise<T | false>;
27
+ }
28
+ export declare const dialogsManager: DialogsManager;
29
+ export {};
@@ -1,4 +1,4 @@
1
- import { BaseSubscreen } from "./ui";
1
+ import { BaseSubscreen, SubscreenConstructor } from "./ui";
2
2
  export interface ModData {
3
3
  name: string;
4
4
  fullName: string;
@@ -16,7 +16,24 @@ export interface ModData {
16
16
  iconFillColor: string;
17
17
  iconStrokeColor: string;
18
18
  };
19
- deepLinkSubscreens?: BaseSubscreen[];
19
+ subscreens?: Record<string, SubscreenConstructor>;
20
+ localization?: {
21
+ locales: {
22
+ default: string;
23
+ supported: string[];
24
+ };
25
+ translationsFolderPath: string;
26
+ };
27
+ changelog?: {
28
+ data: {
29
+ hash: string;
30
+ author: string;
31
+ message: string;
32
+ date: string;
33
+ }[];
34
+ repo: string;
35
+ owner: string;
36
+ };
20
37
  }
21
38
  interface ThemedColorsModule {
22
39
  base: {
@@ -43,16 +60,49 @@ interface ThemedColorsModule {
43
60
  }
44
61
  export { version } from "../package.json";
45
62
  export declare let MOD_DATA: ModData;
46
- export declare function registerCore(modData: ModData): void;
63
+ export declare function bootstrap(modData: ModData): void;
64
+ export declare function formatString(text: string): ({
65
+ html: string;
66
+ isBeatifulString: true;
67
+ } | {
68
+ isBeatifulString: false;
69
+ });
70
+ export declare class SetSubscreenEvent extends CustomEvent<{
71
+ target: string;
72
+ isTrusted: boolean;
73
+ }> {
74
+ constructor(detail: {
75
+ target: string;
76
+ isTrusted: boolean;
77
+ });
78
+ }
79
+ export declare class SubscreenLoadedEvent extends CustomEvent<{
80
+ subscreen: BaseSubscreen;
81
+ }> {
82
+ constructor(detail: {
83
+ subscreen: BaseSubscreen;
84
+ });
85
+ }
86
+ export declare class SubscreenUnloadedEvent extends CustomEvent<{
87
+ subscreen: BaseSubscreen;
88
+ }> {
89
+ constructor(detail: {
90
+ subscreen: BaseSubscreen;
91
+ });
92
+ }
93
+ export declare class CoreSettingsChangedEvent extends CustomEvent<never> {
94
+ constructor();
95
+ }
47
96
  export declare function sleep(ms: number): Promise<() => {}>;
48
97
  export declare function waitFor(func: () => boolean, cancelFunc?: () => boolean): Promise<boolean>;
49
98
  export declare function getRandomNumber(min: number, max: number): number;
50
99
  export declare function isVersionNewer(version1: string, version2: string): boolean;
51
100
  export declare function colorsEqual(c1: string[] | string | null | undefined, c2: string[] | string | null | undefined): boolean;
52
101
  export declare function getSizeInKbytes(b: any): number;
53
- export declare function getPlayer(value: string | number): Character;
102
+ export declare function getPlayer(value: string | number): Character | null;
54
103
  export declare function getNickname(target: Character): string;
55
104
  export declare function getThemedColorsModule(): ThemedColorsModule | null;
56
105
  export declare function injectStyles(stylesToInject: string): void;
57
106
  export declare function waitForStart(callback: () => void): void;
58
- export declare function normalizeObject(obj: unknown): any;
107
+ export declare function normalizeObject<T>(obj: T[]): T[];
108
+ export declare function normalizeObject<T extends object>(obj: T): T;
@@ -0,0 +1,4 @@
1
+ export declare function getText(tag: string, replacements?: Record<string, string | number>): string;
2
+ export declare function processReplacements(text: string, replacements: Record<string, string | number>): string;
3
+ export declare function loadLocalization(): Promise<void>;
4
+ export declare function fetchTranslationsForLocale(locale: string): Promise<void>;
@@ -0,0 +1,16 @@
1
+ type LogLevel = "debug" | "log" | "warn" | "error";
2
+ interface LogEntry {
3
+ level: LogLevel;
4
+ message: unknown[];
5
+ timestamp: number;
6
+ }
7
+ declare class Logger {
8
+ get logs(): LogEntry[];
9
+ private pushLog;
10
+ debug(...message: unknown[]): void;
11
+ log(...message: unknown[]): void;
12
+ warn(...message: unknown[]): void;
13
+ error(...message: unknown[]): void;
14
+ }
15
+ export declare const logger: Logger;
16
+ export {};
@@ -1,8 +1,10 @@
1
1
  import { ClassConstructor } from "class-transformer";
2
- interface RequestResponse<T> {
2
+ type RequestResponse<T> = {
3
3
  data?: T;
4
- isError: boolean;
5
- }
4
+ isError: false;
5
+ } | {
6
+ isError: true;
7
+ };
6
8
  declare class MessagesManager {
7
9
  sendBeep<T>(data: T, targetId: number): void;
8
10
  sendPacket<T>(msg: string, _data?: T, targetNumber?: number): void;
@@ -7,9 +7,9 @@ export declare enum HookPriority {
7
7
  TOP = 100
8
8
  }
9
9
  export declare let modSdk: ModSDKModAPI;
10
- export declare function registerMod(): void;
10
+ export declare function createModSdk(): void;
11
11
  export declare function hookFunction<TFunctionName extends string>(functionName: TFunctionName, priority: HookPriority, hook: PatchHook<GetDotedPathType<typeof globalThis, TFunctionName>>): () => void;
12
12
  export declare function patchFunction(functionName: string, patches: Record<string, string | null>): void;
13
- export declare function callOriginal<TFunctionName extends string>(target: TFunctionName, args: [...Parameters<GetDotedPathType<typeof globalThis, TFunctionName>>], context?: any): ReturnType<GetDotedPathType<typeof globalThis, TFunctionName>>;
13
+ export declare function callOriginal<TFunctionName extends string>(target: TFunctionName, args: [...Parameters<GetDotedPathType<typeof globalThis, TFunctionName>>], context?: any): ReturnType<GetDotedPathType<typeof globalThis, TFunctionName>> | undefined;
14
14
  export declare function getLoadedMods(): ModSDKModInfo[];
15
15
  export declare function findModByName(name: string): boolean;
@@ -0,0 +1,7 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ export declare class AttributesModule extends ShardModule {
4
+ private attributes;
5
+ constructor(attributes: Record<string, string>);
6
+ layoutEffect(context: ShardContext, target: ShardModuleTarget): void;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule } from "./shardModule";
3
+ export declare class CenterModule extends ShardModule<ShardContext> {
4
+ overrideContext(context: ShardContext, target: HTMLElement): ShardContext;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ export declare class ClickModule extends ShardModule {
4
+ private callback;
5
+ constructor(callback: (target: ShardModuleTarget) => void);
6
+ layoutEffect(context: ShardContext, target: ShardModuleTarget): void;
7
+ }
@@ -0,0 +1,13 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ interface CounterUpModuleProps {
4
+ duration: number;
5
+ endValue: number;
6
+ formattingFunction?: (value: number) => string;
7
+ }
8
+ export declare class CounterUpModule extends ShardModule {
9
+ private props;
10
+ constructor(props: CounterUpModuleProps);
11
+ effect(context: ShardContext, target: ShardModuleTarget): void;
12
+ }
13
+ export {};
@@ -0,0 +1,8 @@
1
+ import { DynamicClassStyles } from "../ui";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ import { ShardContext } from "../shards";
4
+ export declare class DynamicClassModule extends ShardModule {
5
+ private style;
6
+ constructor(style: DynamicClassStyles);
7
+ layoutEffect(context: ShardContext, target: ShardModuleTarget): void;
8
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./shardModule";
1
2
  export * from "./centerModule";
2
3
  export * from "./counterUpModule";
3
4
  export * from "./typeModule";
@@ -5,3 +6,4 @@ export * from "./styleModule";
5
6
  export * from "./dynamicClassModule";
6
7
  export * from "./attributesModule";
7
8
  export * from "./clickModule";
9
+ export * from "./multiClickModule";
@@ -0,0 +1,12 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ interface MultiClickModuleProps {
4
+ n: number;
5
+ callback: () => void;
6
+ }
7
+ export declare class MultiClickModule extends ShardModule<ShardContext> {
8
+ private readonly props;
9
+ constructor(props: MultiClickModuleProps);
10
+ effect(context: ShardContext<never>, target: ShardModuleTarget): void;
11
+ }
12
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ShardContext } from "../shards";
2
+ export type ShardModuleTarget = HTMLElement | SVGElement;
3
+ export declare abstract class ShardModule<Context extends ShardContext = ShardContext> {
4
+ overrideContext(context: Context, target: ShardModuleTarget): Context;
5
+ layoutEffect(context: Context, target: ShardModuleTarget): void;
6
+ effect(context: Context, target: ShardModuleTarget): void;
7
+ }
@@ -0,0 +1,8 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ export declare class StyleModule extends ShardModule {
4
+ private style;
5
+ constructor(style: Partial<CSSStyleDeclaration>);
6
+ private applyStyle;
7
+ layoutEffect(context: ShardContext, target: ShardModuleTarget): void;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { ShardContext } from "../shards";
2
+ import { ShardModule, ShardModuleTarget } from "./shardModule";
3
+ interface TypeModuleProps {
4
+ duration: number;
5
+ }
6
+ export declare class TypeModule extends ShardModule {
7
+ private readonly props;
8
+ constructor(props: TypeModuleProps);
9
+ effect(context: ShardContext, target: ShardModuleTarget): void;
10
+ }
11
+ export {};
@@ -0,0 +1,14 @@
1
+ import { DynamicClassStyles } from "../ui";
2
+ import { Shard, ShardContext } from "./shard";
3
+ export interface BackNextButtonShardContext extends ShardContext<"backButton" | "nextButton" | "text"> {
4
+ items: [string, any?][];
5
+ currentIndex: number;
6
+ onChange?: (value: any) => void;
7
+ isDisabled?: (value: any) => boolean;
8
+ }
9
+ export declare class BackNextButtonShard extends Shard<BackNextButtonShardContext> {
10
+ protected get dynamicClassContainer(): DynamicClassStyles;
11
+ protected get dynamicClassButton(): DynamicClassStyles;
12
+ generateBody(): Record<keyof NonNullable<BackNextButtonShardContext["modules"]>, HTMLElement | SVGElement>;
13
+ update(): void;
14
+ }
@@ -0,0 +1,20 @@
1
+ import { DynamicClassStyles } from "../ui";
2
+ import { Shard, ShardContext } from "./shard";
3
+ export interface ButtonShardContext extends ShardContext<"icon" | "text"> {
4
+ text?: string;
5
+ fontSize?: number | "auto";
6
+ style?: "default" | "green" | "inverted";
7
+ icon?: string | SVGElement;
8
+ iconAbsolutePosition?: boolean;
9
+ tooltip?: {
10
+ text: string;
11
+ position: "left" | "right";
12
+ };
13
+ onClick?: () => void;
14
+ isDisabled?: () => boolean;
15
+ }
16
+ export declare class ButtonShard extends Shard<ButtonShardContext> {
17
+ protected get dynamicClassButton(): DynamicClassStyles;
18
+ generateBody(): Record<keyof NonNullable<ButtonShardContext["modules"]>, HTMLElement | SVGElement>;
19
+ update(): void;
20
+ }
@@ -0,0 +1,10 @@
1
+ import { Shard, ShardContext } from "./shard";
2
+ export interface CardShardContext extends ShardContext<"base" | "name" | "value" | "icon"> {
3
+ name: string;
4
+ value: string | number;
5
+ icon?: SVGElement;
6
+ }
7
+ export declare class CardShard extends Shard<CardShardContext> {
8
+ generateBody(): Record<keyof NonNullable<CardShardContext["modules"]>, HTMLElement | SVGElement>;
9
+ update(): void;
10
+ }
@@ -0,0 +1,19 @@
1
+ import { DynamicClassStyles } from "../ui";
2
+ import { Shard, ShardContext } from "./shard";
3
+ export interface CheckboxShardContext extends ShardContext<"checkbox" | "label"> {
4
+ isChecked: boolean;
5
+ text: string;
6
+ tooltip?: {
7
+ position: "left" | "right";
8
+ text: string;
9
+ };
10
+ onChange?: () => void;
11
+ isDisabled?: () => boolean;
12
+ }
13
+ export declare class CheckboxShard extends Shard<CheckboxShardContext> {
14
+ protected get dynamicClassInput(): DynamicClassStyles;
15
+ protected get dynamicClassCheckmark(): DynamicClassStyles;
16
+ protected get textColor(): string;
17
+ generateBody(): Record<keyof NonNullable<CheckboxShardContext["modules"]>, HTMLElement | SVGElement>;
18
+ update(): void;
19
+ }
@@ -0,0 +1,7 @@
1
+ import { Shard, ShardContext } from "./shard";
2
+ export interface ContainerShardContext extends ShardContext {
3
+ scroll?: "x" | "y" | "all" | "auto";
4
+ }
5
+ export declare class ContainerShard extends Shard<ContainerShardContext> {
6
+ generateBody(): Record<keyof NonNullable<ContainerShardContext["modules"]>, HTMLElement | SVGElement>;
7
+ }