zois-core 2.2.1 → 3.0.1

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 (159) hide show
  1. package/dist/assets/icons/toast-themes/abdl/bottle.svg +10 -0
  2. package/dist/assets/icons/toast-themes/abdl/diaper.svg +11 -0
  3. package/dist/assets/icons/toast-themes/abdl/heart.svg +7 -0
  4. package/dist/assets/icons/toast-themes/abdl/sparkle.svg +5 -0
  5. package/dist/assets/icons/toast-themes/abdl/star.svg +5 -0
  6. package/dist/assets/icons/toast-themes/abdl/teddy.svg +18 -0
  7. package/dist/assets/icons/toast-themes/anime/error.svg +20 -0
  8. package/dist/assets/icons/toast-themes/anime/info.svg +20 -0
  9. package/dist/assets/icons/toast-themes/anime/success.svg +16 -0
  10. package/dist/assets/icons/toast-themes/anime/warning.svg +19 -0
  11. package/dist/changelogs.js +628 -295
  12. package/dist/cssVars.js +46 -0
  13. package/dist/dialogs.js +523 -83
  14. package/dist/events.js +28 -6
  15. package/dist/index.js +27 -70
  16. package/dist/localization.js +250 -40
  17. package/dist/messaging.js +6 -6
  18. package/dist/migration.js +37 -0
  19. package/dist/modules/baseModule.js +110 -0
  20. package/dist/modules/index.js +4 -0
  21. package/dist/modules/loadingStrategy.js +20 -0
  22. package/dist/modules/moduleContext.js +67 -0
  23. package/dist/modules/modulesManager.js +175 -0
  24. package/dist/{modSdk.js → patching.js} +33 -9
  25. package/dist/rpc.js +139 -0
  26. package/dist/scripts/zois-core.js +14 -14
  27. package/dist/settings.js +90 -0
  28. package/dist/settingsDialog.js +1361 -0
  29. package/dist/shard-modules/{attributesModule.js → attributes.js} +2 -2
  30. package/dist/shard-modules/{shardModule.js → base.js} +2 -2
  31. package/dist/shard-modules/{centerModule.js → center.js} +4 -2
  32. package/dist/shard-modules/{clickModule.js → click.js} +2 -2
  33. package/dist/shard-modules/{counterUpModule.js → counterUp.js} +2 -2
  34. package/dist/shard-modules/{dynamicClassModule.js → dynamicClass.js} +2 -2
  35. package/dist/shard-modules/index.js +9 -9
  36. package/dist/shard-modules/{multiClickModule.js → multiClick.js} +2 -2
  37. package/dist/shard-modules/{styleModule.js → style.js} +2 -2
  38. package/dist/shard-modules/{typeModule.js → type.js} +2 -2
  39. package/dist/shards/backNextButton.js +173 -0
  40. package/dist/shards/{shard.js → base.js} +15 -15
  41. package/dist/shards/{buttonShard.js → button.js} +30 -52
  42. package/dist/shards/{cardShard.js → card.js} +4 -4
  43. package/dist/shards/{checkboxShard.js → checkbox.js} +8 -15
  44. package/dist/shards/{containerShard.js → container.js} +2 -2
  45. package/dist/shards/extensionsStorageBar.js +377 -0
  46. package/dist/shards/fileInput.js +180 -0
  47. package/dist/shards/flexContainer.js +30 -0
  48. package/dist/shards/gridContainer.js +34 -0
  49. package/dist/shards/{imageShard.js → image.js} +8 -6
  50. package/dist/shards/index.js +17 -13
  51. package/dist/shards/{inputShard.js → input.js} +8 -8
  52. package/dist/shards/{inputListShard.js → inputList.js} +22 -4
  53. package/dist/shards/select.js +201 -0
  54. package/dist/shards/svg.js +28 -0
  55. package/dist/shards/{tabsShard.js → tabs.js} +18 -19
  56. package/dist/shards/{textShard.js → text.js} +10 -6
  57. package/dist/shared.js +215 -0
  58. package/dist/styles.css +0 -51
  59. package/dist/subscreens/customTranslations.js +239 -0
  60. package/dist/subscreens/languageDetails.js +194 -0
  61. package/dist/subscreens/localization.js +115 -0
  62. package/dist/toast-themes/abdl.js +419 -0
  63. package/dist/toast-themes/anime.js +483 -0
  64. package/dist/toast-themes/base.js +40 -0
  65. package/dist/toast-themes/cyber.js +538 -0
  66. package/dist/toast-themes/default.js +282 -0
  67. package/dist/toastThemesDialog.js +274 -0
  68. package/dist/toasts.js +195 -174
  69. package/dist/types/cssVars.d.ts +1 -0
  70. package/dist/types/dialogs.d.ts +46 -18
  71. package/dist/types/events.d.ts +11 -2
  72. package/dist/types/global.d.ts +4 -3
  73. package/dist/types/index.d.ts +12 -19
  74. package/dist/types/localization.d.ts +25 -3
  75. package/dist/types/migration.d.ts +6 -0
  76. package/dist/types/modules/baseModule.d.ts +108 -0
  77. package/dist/types/modules/index.d.ts +4 -0
  78. package/dist/types/modules/loadingStrategy.d.ts +7 -0
  79. package/dist/types/modules/moduleContext.d.ts +10 -0
  80. package/dist/types/modules/modulesManager.d.ts +23 -0
  81. package/dist/types/{modSdk.d.ts → patching.d.ts} +2 -3
  82. package/dist/types/rpc.d.ts +72 -0
  83. package/dist/types/settings.d.ts +19 -0
  84. package/dist/types/settingsDialog.d.ts +4 -0
  85. package/dist/types/shard-modules/{attributesModule.d.ts → attributes.d.ts} +2 -2
  86. package/dist/types/shard-modules/{shardModule.d.ts → base.d.ts} +2 -2
  87. package/dist/types/shard-modules/{centerModule.d.ts → center.d.ts} +2 -1
  88. package/dist/types/shard-modules/{clickModule.d.ts → click.d.ts} +2 -2
  89. package/dist/types/shard-modules/{counterUpModule.d.ts → counterUp.d.ts} +2 -2
  90. package/dist/types/shard-modules/{dynamicClassModule.d.ts → dynamicClass.d.ts} +2 -2
  91. package/dist/types/shard-modules/index.d.ts +9 -9
  92. package/dist/types/shard-modules/{multiClickModule.d.ts → multiClick.d.ts} +2 -2
  93. package/dist/types/shard-modules/{styleModule.d.ts → style.d.ts} +2 -2
  94. package/dist/types/shard-modules/{typeModule.d.ts → type.d.ts} +2 -2
  95. package/dist/types/shards/{backNextButtonShard.d.ts → backNextButton.d.ts} +4 -3
  96. package/dist/types/shards/{shard.d.ts → base.d.ts} +3 -2
  97. package/dist/types/shards/{buttonShard.d.ts → button.d.ts} +6 -6
  98. package/dist/types/shards/{cardShard.d.ts → card.d.ts} +3 -3
  99. package/dist/types/shards/{checkboxShard.d.ts → checkbox.d.ts} +6 -6
  100. package/dist/types/shards/{containerShard.d.ts → container.d.ts} +2 -2
  101. package/dist/types/shards/extensionsStorageBar.d.ts +28 -0
  102. package/dist/types/shards/fileInput.d.ts +10 -0
  103. package/dist/types/shards/flexContainer.d.ts +14 -0
  104. package/dist/types/shards/gridContainer.d.ts +18 -0
  105. package/dist/types/shards/{imageShard.d.ts → image.d.ts} +2 -2
  106. package/dist/types/shards/index.d.ts +17 -13
  107. package/dist/types/shards/input.d.ts +14 -0
  108. package/dist/types/shards/{inputListShard.d.ts → inputList.d.ts} +3 -2
  109. package/dist/types/shards/{selectShard.d.ts → select.d.ts} +6 -4
  110. package/dist/types/shards/svg.d.ts +11 -0
  111. package/dist/types/shards/{tabsShard.d.ts → tabs.d.ts} +3 -6
  112. package/dist/types/shards/{textShard.d.ts → text.d.ts} +3 -3
  113. package/dist/types/shared.d.ts +7 -0
  114. package/dist/types/subscreens/customTranslations.d.ts +10 -0
  115. package/dist/types/subscreens/languageDetails.d.ts +14 -0
  116. package/dist/types/subscreens/localization.d.ts +5 -0
  117. package/dist/types/toast-themes/abdl.d.ts +9 -0
  118. package/dist/types/toast-themes/anime.d.ts +9 -0
  119. package/dist/types/toast-themes/base.d.ts +39 -0
  120. package/dist/types/toast-themes/cyber.d.ts +10 -0
  121. package/dist/types/toast-themes/default.d.ts +9 -0
  122. package/dist/types/toastThemesDialog.d.ts +1 -0
  123. package/dist/types/toasts.d.ts +48 -36
  124. package/dist/types/ui.d.ts +128 -49
  125. package/dist/types/validation.d.ts +5 -0
  126. package/dist/types/wardrobe.d.ts +1 -1
  127. package/dist/ui.js +414 -79
  128. package/dist/validation.js +79 -1
  129. package/dist/wardrobe.js +4 -4
  130. package/package.json +36 -14
  131. package/dist/core-subscreen/coreSubscreen.js +0 -81
  132. package/dist/core-subscreen/developmentSubscreen.js +0 -22
  133. package/dist/core-subscreen/generalSubscreen.js +0 -23
  134. package/dist/core-subscreen/mainSubscreen.js +0 -58
  135. package/dist/core-subscreen/shards/coreButtonShard.js +0 -30
  136. package/dist/core-subscreen/shards/coreCheckboxShard.js +0 -33
  137. package/dist/core-subscreen/shards/coreInputListShard.js +0 -38
  138. package/dist/core-subscreen/shards/coreSelectShard.js +0 -17
  139. package/dist/core-subscreen/shards/coreTextShard.js +0 -9
  140. package/dist/core-subscreen/shards/index.js +0 -5
  141. package/dist/core-subscreen/toastsSubscreen.js +0 -111
  142. package/dist/core.js +0 -192
  143. package/dist/shards/backNextButtonShard.js +0 -99
  144. package/dist/shards/selectShard.js +0 -131
  145. package/dist/shards/svgShard.js +0 -29
  146. package/dist/types/core-subscreen/coreSubscreen.d.ts +0 -15
  147. package/dist/types/core-subscreen/developmentSubscreen.d.ts +0 -5
  148. package/dist/types/core-subscreen/generalSubscreen.d.ts +0 -5
  149. package/dist/types/core-subscreen/mainSubscreen.d.ts +0 -6
  150. package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +0 -5
  151. package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +0 -6
  152. package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +0 -6
  153. package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +0 -5
  154. package/dist/types/core-subscreen/shards/coreTextShard.d.ts +0 -4
  155. package/dist/types/core-subscreen/shards/index.d.ts +0 -5
  156. package/dist/types/core-subscreen/toastsSubscreen.d.ts +0 -5
  157. package/dist/types/core.d.ts +0 -18
  158. package/dist/types/shards/inputShard.d.ts +0 -14
  159. package/dist/types/shards/svgShard.d.ts +0 -12
package/dist/toasts.js CHANGED
@@ -1,216 +1,237 @@
1
- import { CircleAlert, CircleCheck, CircleX, createElement, Info } from "lucide";
2
- import { MOD_DATA } from "./index";
3
- import { setPosition } from "./ui";
1
+ import { animeToastTheme } from "./toast-themes/anime";
2
+ import { cyberToastTheme } from "./toast-themes/cyber";
3
+ import { defaultToastTheme } from "./toast-themes/default";
4
4
  import { logger } from "./logging";
5
5
  import { eventBus } from "./events";
6
+ import { setPosition } from "./ui";
7
+ import { getSettings } from "./settings";
8
+ import { abdlToastTheme } from "./toast-themes/abdl";
9
+ const EXTENSIONS_CURRENT_TOAST_THEME_KEY = "ZC_TOAST_THEME";
10
+ const EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY = "ZC_TOAST_THEMES";
11
+ const themes = [
12
+ { id: 1e3, theme: defaultToastTheme },
13
+ { id: 1001, theme: cyberToastTheme },
14
+ { id: 1002, theme: animeToastTheme },
15
+ { id: 1003, theme: abdlToastTheme }
16
+ ];
17
+ function initToastThemes() {
18
+ try {
19
+ for (const entry of themes) {
20
+ entry.theme.init();
21
+ }
22
+ logger.log("Initialized toast themes of zois-core shared environment");
23
+ } catch (e) {
24
+ logger.error("Failed to initialize toast themes of zois-core shared environment", e);
25
+ }
26
+ }
27
+ function getToastThemeById(id) {
28
+ return themes.find((e) => e.id === id)?.theme;
29
+ }
30
+ function getToastThemeId(theme) {
31
+ return themes.find((e) => e.theme instanceof theme.constructor)?.id;
32
+ }
33
+ function getUnlockedToastThemeIds() {
34
+ if (typeof Player === "undefined" || !Player?.ExtensionSettings) return [];
35
+ const stored = Player.ExtensionSettings[EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY];
36
+ if (typeof stored !== "string" || stored.length === 0) return [];
37
+ const ids = /* @__PURE__ */ new Set();
38
+ for (const c of stored) {
39
+ ids.add(c.charCodeAt(0));
40
+ }
41
+ return [...ids];
42
+ }
43
+ function isToastThemeUnlocked(theme) {
44
+ const id = getToastThemeId(theme);
45
+ if (id === 1e3) return true;
46
+ if (id === void 0) return false;
47
+ return getUnlockedToastThemeIds().includes(id);
48
+ }
49
+ function unlockToastTheme(theme) {
50
+ if (typeof Player === "undefined" || !Player) return;
51
+ if (!Player.ExtensionSettings) {
52
+ Player.ExtensionSettings = {};
53
+ }
54
+ const current = typeof Player.ExtensionSettings[EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY] === "string" ? Player.ExtensionSettings[EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY] : "";
55
+ const id = getToastThemeId(theme);
56
+ if (id === void 0) return;
57
+ const ids = /* @__PURE__ */ new Set();
58
+ for (const c of current) {
59
+ ids.add(c.charCodeAt(0));
60
+ }
61
+ ids.add(id);
62
+ Player.ExtensionSettings[EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY] = [...ids].sort((a, b) => a - b).map((n) => String.fromCharCode(n)).join("");
63
+ ServerPlayerExtensionSettingsSync(EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY);
64
+ }
65
+ function resetToastThemes() {
66
+ Player.ExtensionSettings[EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY] = "";
67
+ Player.ExtensionSettings[EXTENSIONS_CURRENT_TOAST_THEME_KEY] = "";
68
+ ServerPlayerExtensionSettingsSync(EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY);
69
+ ServerPlayerExtensionSettingsSync(EXTENSIONS_CURRENT_TOAST_THEME_KEY);
70
+ }
71
+ function getActiveToastThemeId() {
72
+ const defaultTheme = themes[0];
73
+ const stored = typeof Player !== "undefined" && Player?.ExtensionSettings?.[EXTENSIONS_CURRENT_TOAST_THEME_KEY];
74
+ if (typeof stored !== "string" || stored.length === 0) {
75
+ return defaultTheme.id;
76
+ }
77
+ const id = stored.charCodeAt(0);
78
+ const found = getToastThemeById(id);
79
+ if (found === void 0) return defaultTheme.id;
80
+ if (!isToastThemeUnlocked(found)) return defaultTheme.id;
81
+ return id;
82
+ }
83
+ function setActiveToastTheme(theme) {
84
+ if (typeof Player === "undefined" || !Player) return;
85
+ if (!isToastThemeUnlocked(theme)) return;
86
+ const id = getToastThemeId(theme);
87
+ if (id === void 0) return;
88
+ if (!Player.ExtensionSettings) {
89
+ Player.ExtensionSettings = {};
90
+ }
91
+ Player.ExtensionSettings[EXTENSIONS_CURRENT_TOAST_THEME_KEY] = String.fromCharCode(id);
92
+ if (typeof ServerPlayerExtensionSettingsSync === "function") {
93
+ ServerPlayerExtensionSettingsSync(EXTENSIONS_CURRENT_TOAST_THEME_KEY);
94
+ }
95
+ }
96
+ function resolveActiveToastTheme() {
97
+ const id = getActiveToastThemeId();
98
+ return getToastThemeById(id) ?? themes[0].theme;
99
+ }
100
+ function dismissToast(toastElement) {
101
+ if (!toastElement || toastElement.dataset.dismissed === "true") return;
102
+ toastElement.dataset.dismissed = "true";
103
+ if (toastElement.hasAttribute("data-zc-cyber-toast")) {
104
+ toastElement.classList.remove("visible", "paused");
105
+ toastElement.classList.add("exiting");
106
+ setTimeout(() => {
107
+ if (toastElement.parentElement) toastElement.remove();
108
+ }, 400);
109
+ return;
110
+ }
111
+ const pos = getSettings().toasts?.position ?? "bottom-left";
112
+ toastElement.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
113
+ setTimeout(() => toastElement.remove(), 300);
114
+ }
6
115
  function createToastsContainer() {
7
116
  const container = document.createElement("div");
8
- container.classList.add("zcToastsContainer");
9
- container.addEventListener("click", () => {
10
- const pos = window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left";
11
- for (const toast of container.children) {
12
- if (toast instanceof HTMLElement) {
13
- toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
14
- }
15
- }
16
- setTimeout(() => container.innerHTML = "", 300);
17
- });
117
+ container.className = "zcToastsContainer";
18
118
  const update = () => {
19
119
  container.style.cssText = `font-family: ${CommonGetFontName()};`;
20
- setPosition(container, 5, 5, window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left");
120
+ setPosition(
121
+ container,
122
+ 5,
123
+ 5,
124
+ getSettings().toasts?.position ?? "bottom-left"
125
+ );
21
126
  };
22
- window.addEventListener("resize", update);
23
127
  document.body.append(container);
24
128
  update();
25
- eventBus?.on("zois-core:coreSettingsChanged", update);
129
+ eventBus?.on("coreSettingsChanged", update);
26
130
  return container;
27
131
  }
28
- function getToastIcon(type, theme) {
29
- let icon;
30
- switch (type) {
31
- case "info":
32
- icon = createElement(Info);
33
- icon.style.fill = theme ? theme.iconFillColor : "rgb(68, 70, 202)";
34
- icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(148, 178, 217)";
35
- break;
36
- case "warning":
37
- icon = createElement(CircleAlert);
38
- icon.style.fill = theme ? theme.iconFillColor : "rgb(198, 146, 25)";
39
- icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(244, 220, 147)";
40
- break;
41
- case "error":
42
- icon = createElement(CircleX);
43
- icon.style.fill = theme ? theme.iconFillColor : "rgb(174, 1, 1)";
44
- icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(255, 163, 163)";
45
- break;
46
- case "success":
47
- icon = createElement(CircleCheck);
48
- icon.style.fill = theme ? theme.iconFillColor : "rgb(49, 142, 68)";
49
- icon.style.stroke = theme ? theme.iconStrokeColor : "rgb(122, 213, 162)";
50
- break;
51
- case "spinner":
52
- icon = document.createElement("div");
53
- icon.style.cssText = `
54
- box-sizing: border-box;
55
- border: 2px solid;
56
- border-radius: 100%;
57
- border-color: transparent ${theme ? theme.iconFillColor : "rgb(68, 70, 202)"};
58
- animation: zcSpin 0.65s linear infinite;
59
- `;
60
- break;
61
- }
62
- icon.style.cssText += `flex-shink: 0; width: 1.65em; height: 1.65em;`;
63
- return icon;
132
+ function getOrCreateToastsContainer() {
133
+ return document.querySelector(".zcToastsContainer") ?? createToastsContainer();
64
134
  }
65
- function createToast({ title, message, type, duration, theme, id }) {
66
- const pos = window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left";
67
- 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)";
68
- 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)";
69
- const progressBarColor = theme ? theme.progressBarColor : "#00000014";
70
- const toastContainer = document.querySelector(".zcToastsContainer") ?? createToastsContainer();
71
- const toast = document.createElement("div");
72
- toast.classList.add("zcToast");
73
- toast.setAttribute("data-zc-toast-type", type);
74
- toast.setAttribute("data-zc-toast-id", id);
75
- const update = () => {
76
- const canvasWidth = MainCanvas.canvas.clientWidth;
77
- const canvasHeight = MainCanvas.canvas.clientHeight;
78
- const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
79
- toast.style.cssText = `width: 100%; font-size: ${2.85 * scaleFactor}px; padding: ${1 * scaleFactor}px; background: ${backgroundColor}; border: 1px solid #555;`;
80
- toast.style.animation = `${pos.includes("left") ? "zcSlideInFromLeft" : "zcSlideInFromRight"} 0.3s ease-out forwards`;
81
- };
82
- if (type !== "spinner") {
83
- const progressBar = document.createElement("div");
84
- progressBar.classList.add("zcToast-ProgressBar");
85
- 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};`;
86
- toast.append(progressBar);
87
- }
88
- const textContainer = document.createElement("div");
89
- if (title) {
90
- const _title = document.createElement("p");
91
- _title.style.color = textColor;
92
- _title.style.fontWeight = "bold";
93
- _title.style.fontSize = "0.9em";
94
- _title.textContent = title;
95
- textContainer.append(_title);
96
- }
97
- const _message = document.createElement("p");
98
- _message.style.color = textColor;
99
- _message.style.fontSize = !!title ? "0.7em" : "0.9em";
100
- _message.style.overflowWrap = "anywhere";
101
- if (!title) {
102
- _message.style.fontWeight = "bold";
103
- } else {
104
- _message.style.marginTop = "0.15em";
105
- }
106
- _message.textContent = message;
107
- textContainer.append(_message);
108
- toast.append(getToastIcon(type, theme), textContainer);
109
- window.addEventListener("resize", update);
110
- toastContainer.append(toast);
111
- update();
112
- void toast.offsetHeight;
113
- setTimeout(() => {
114
- toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
115
- }, duration);
116
- setTimeout(() => toast.remove(), duration + 300);
135
+ function createToast(data) {
136
+ const theme = resolveActiveToastTheme();
137
+ const toast = theme.render(data);
138
+ const container = getOrCreateToastsContainer();
139
+ container.appendChild(toast);
117
140
  }
118
141
  class ToastsManager {
119
142
  generateToastId() {
120
143
  return crypto.randomUUID();
121
144
  }
122
- process({ title, message, duration, type, id, theme }) {
123
- const coreSettings = window.ZOIS_CORE.getSettings();
124
- if (coreSettings.toasts?.blacklist?.enabled && coreSettings.toasts.blacklist.content?.length !== 0) {
125
- if (coreSettings.toasts.blacklist.content?.some((v) => {
145
+ process(toastProperties) {
146
+ const coreSettingsLocal = getSettings();
147
+ if (coreSettingsLocal.toasts?.blacklist?.enabled && coreSettingsLocal.toasts.blacklist.content?.length !== 0) {
148
+ if (coreSettingsLocal.toasts.blacklist.content?.some((v) => {
126
149
  const regexp = new RegExp(v);
127
- return regexp.test(title ?? "") || regexp.test(message);
150
+ return regexp.test(toastProperties.title ?? "") || regexp.test(toastProperties.message);
128
151
  })) {
129
152
  logger.log("Toast message blocked due to blacklist settings");
130
- return;
153
+ return false;
131
154
  }
132
155
  }
133
- if (coreSettings.toasts?.preventUsingSingleTheme) {
134
- createToast({
135
- id,
136
- title,
137
- message,
138
- duration,
139
- type
140
- });
141
- } else {
142
- createToast({
143
- id,
144
- title,
145
- message,
146
- duration,
147
- type,
148
- theme
149
- });
150
- }
156
+ const id = this.generateToastId();
157
+ createToast({
158
+ ...toastProperties,
159
+ id,
160
+ size: {
161
+ scaleWithCanvas: true,
162
+ scaleFactor: coreSettingsLocal.toasts?.scaleFactor ?? 1
163
+ }
164
+ });
165
+ return id;
151
166
  }
152
167
  /**
153
- * Displays informational toast.
154
- * @param options - Title, message and duration of toast.
155
- */
156
- info({ title, message, duration }) {
157
- const id = this.generateToastId();
158
- const theme = MOD_DATA.singleToastsTheme;
159
- this.process({ title, message, duration, type: "info", id, theme });
168
+ * Displays informational toast.
169
+ * @param options - Title, message and duration of toast.
170
+ */
171
+ info(toastProperties) {
172
+ this.process({ ...toastProperties, type: "info" });
160
173
  }
161
174
  /**
162
- * Displays success toast.
163
- * @param options - Title, message and duration of toast.
164
- */
165
- success({ title, message, duration }) {
166
- const id = this.generateToastId();
167
- const theme = MOD_DATA.singleToastsTheme;
168
- this.process({ title, message, duration, type: "success", id, theme });
175
+ * Displays success toast.
176
+ * @param options - Title, message and duration of toast.
177
+ */
178
+ success(toastProperties) {
179
+ this.process({ ...toastProperties, type: "success" });
169
180
  }
170
181
  /**
171
- * Displays warning toast.
172
- * @param options - Title, message and duration of toast.
173
- */
174
- warn({ title, message, duration }) {
175
- const id = this.generateToastId();
176
- const theme = MOD_DATA.singleToastsTheme;
177
- this.process({ title, message, duration, type: "warning", id, theme });
182
+ * Displays warning toast.
183
+ * @param options - Title, message and duration of toast.
184
+ */
185
+ warn(toastProperties) {
186
+ this.process({ ...toastProperties, type: "warning" });
178
187
  }
179
188
  /**
180
- * Displays error toast.
181
- * @param options - Title, message and duration of toast.
182
- */
183
- error({ title, message, duration }) {
184
- const id = this.generateToastId();
185
- const theme = MOD_DATA.singleToastsTheme;
186
- this.process({ title, message, duration, type: "error", id, theme });
189
+ * Displays error toast.
190
+ * @param options - Title, message and duration of toast.
191
+ */
192
+ error(toastProperties) {
193
+ this.process({ ...toastProperties, type: "error" });
187
194
  }
188
195
  /**
189
- * Displays a long-running spinner toast and returns its ID.
190
- * Toast can be deleted manually with `toastsManager.removeSpinner(ID)` or by the user by clicking.
191
- * @param options - Title and message of toast.
192
- * @returns The unique ID of the created spinner toast.
193
- */
194
- spinner({ title, message }) {
195
- const id = this.generateToastId();
196
- const theme = MOD_DATA.singleToastsTheme;
197
- this.process({ title, message, duration: 1e6, type: "spinner", id, theme });
198
- return id;
196
+ * Displays a long-running spinner toast and returns its ID.
197
+ * Toast can be deleted manually with `toastsManager.removeSpinner(ID)` or by the user by clicking.
198
+ * @param options - Title and message of toast.
199
+ * @returns The unique ID of the created spinner toast.
200
+ */
201
+ spinner(toastProperties) {
202
+ const result = this.process({ ...toastProperties, type: "spinner" });
203
+ if (result === false) return "";
204
+ return result;
199
205
  }
200
206
  /**
201
- * Removes a spinner toast by its ID.
202
- * @param id - Unique ID of the spinner toast to remove.
203
- */
207
+ * Removes a spinner toast by its ID.
208
+ * @param id - Unique ID of the spinner toast to remove.
209
+ */
204
210
  removeSpinner(id) {
205
- const toast = document.querySelector(`div[data-zc-toast-id="${id}"]`);
211
+ const toast = document.querySelector(
212
+ `div[data-zc-toast-id="${id}"]`
213
+ );
206
214
  if (!toast) return;
207
- const pos = window.ZOIS_CORE.getSettings().toasts?.position ?? "bottom-left";
208
- toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
209
- setTimeout(() => toast.remove(), 300);
215
+ dismissToast(toast);
210
216
  }
211
217
  }
212
218
  const toastsManager = new ToastsManager();
213
219
  export {
220
+ EXTENSIONS_CURRENT_TOAST_THEME_KEY,
221
+ EXTENSIONS_UNLOCKED_TOAST_THEMES_KEY,
214
222
  ToastsManager,
215
- toastsManager
223
+ dismissToast,
224
+ getActiveToastThemeId,
225
+ getOrCreateToastsContainer,
226
+ getToastThemeById,
227
+ getToastThemeId,
228
+ getUnlockedToastThemeIds,
229
+ initToastThemes,
230
+ isToastThemeUnlocked,
231
+ resetToastThemes,
232
+ resolveActiveToastTheme,
233
+ setActiveToastTheme,
234
+ themes,
235
+ toastsManager,
236
+ unlockToastTheme
216
237
  };
@@ -0,0 +1 @@
1
+ export declare function initCssVars(): void;
@@ -1,29 +1,57 @@
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
- };
1
+ import { BaseProps } from "tsx-dom";
2
+ interface DialogProps extends BaseProps {
3
+ wide?: boolean;
8
4
  }
9
- interface ConfirmDialogProps extends BaseDialogProps<boolean> {
10
- type: "confirm";
5
+ export declare function Dialog(props: DialogProps): JSX.Element;
6
+ type DialogButtonProps = BaseProps & JSX.IntrinsicElements["button"] & {
7
+ variant?: "primary" | "outline" | "danger";
8
+ };
9
+ export declare function DialogButton(props: DialogButtonProps): JSX.Element;
10
+ export declare function DialogButtons(props: BaseProps): JSX.Element;
11
+ type DialogTextProps = BaseProps & JSX.IntrinsicElements["p"];
12
+ export declare function DialogText(props: DialogTextProps): JSX.Element;
13
+ interface DialogInputProps extends BaseProps {
14
+ placeholder?: string;
11
15
  }
12
- interface PromptDialogProps extends BaseDialogProps<string | false> {
13
- type: "prompt";
16
+ export declare function DialogInput(props: DialogInputProps): JSX.Element;
17
+ export declare function DialogSelect(props: BaseProps): JSX.Element;
18
+ interface DialogCloseButtonProps extends BaseProps {
19
+ onClick: () => void;
14
20
  }
15
- interface PickDialogProps<T> extends BaseDialogProps<T | false> {
16
- type: "pick";
21
+ export declare function DialogCloseButton(props: DialogCloseButtonProps): JSX.Element;
22
+ export declare function createConfirmDialog({ message }: {
23
+ message: string;
24
+ }): Promise<boolean>;
25
+ export declare function createPromptDialog({ message }: {
26
+ message: string;
27
+ }): Promise<string | false>;
28
+ export declare function createPickDialog<T>({ message, options, }: {
29
+ message: string;
17
30
  options: {
18
31
  name: string;
19
32
  value: T;
20
33
  }[];
21
- }
34
+ }): Promise<T | false>;
35
+ export declare function createPickPlayerDialog({ message }?: {
36
+ message?: string;
37
+ }): Promise<number[] | false>;
22
38
  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>;
39
+ prompt({ message }: {
40
+ message: string;
41
+ }): Promise<string | false>;
42
+ confirm({ message }: {
43
+ message: string;
44
+ }): Promise<boolean>;
45
+ pick<T>({ message, options, }: {
46
+ message: string;
47
+ options: {
48
+ name: string;
49
+ value: T;
50
+ }[];
51
+ }): Promise<T | false>;
52
+ pickPlayers({ message }?: {
53
+ message?: string;
54
+ }): Promise<number[] | false>;
27
55
  }
28
56
  export declare const dialogsManager: DialogsManager;
29
57
  export {};
@@ -1,6 +1,7 @@
1
- import { CoreSettings } from "./core";
1
+ import type { CoreSettings } from "./settings";
2
2
  import { Shard } from "./shards";
3
3
  import { BaseSubscreen } from "./ui";
4
+ import { Locale } from "./localization";
4
5
  export type EventCallback<T = any> = (data: T) => void;
5
6
  export type KnownEventMap = {
6
7
  subscreenLoaded: {
@@ -28,6 +29,14 @@ export type KnownEventMap = {
28
29
  shard: Shard;
29
30
  sender: string;
30
31
  };
32
+ localeChanged: {
33
+ locale: Locale;
34
+ sender: string;
35
+ };
36
+ customTranslationChanged: {
37
+ targetMod: string;
38
+ sender: string;
39
+ };
31
40
  };
32
41
  type UnknownEventData = {
33
42
  sender: string;
@@ -46,5 +55,5 @@ export declare class EventBus {
46
55
  }
47
56
  export declare function getEventBus(id: string): EventBus;
48
57
  export declare let eventBus: EventBus | null;
49
- export declare function createEventBus(): void;
58
+ export declare function initEventBus(): void;
50
59
  export {};
@@ -1,8 +1,9 @@
1
1
  interface Window {
2
2
  ZOIS_CORE: {
3
3
  version: string
4
- enableDevMode: () => void
5
- getSettings: () => import("../core").CoreSettings
6
4
  getEventBus: typeof import("../events").getEventBus
5
+ getRPCBus: typeof import("../rpc").getRPCBus
6
+ getDependents: typeof import("../shared").getDependents
7
+ addDependent: typeof import("../shared").addDependent
7
8
  }
8
- }
9
+ }
@@ -1,5 +1,9 @@
1
1
  import { ChangelogEntryTag } from "./changelogs";
2
+ import { type Locale } from "./localization";
2
3
  import { SubscreenConstructor } from "./ui";
4
+ import { version } from "../package.json";
5
+ import { ModuleConstructor } from "./modules";
6
+ import { MigratorConstructor } from "./migration";
3
7
  export interface ModData {
4
8
  name: string;
5
9
  fullName: string;
@@ -9,25 +13,20 @@ export interface ModData {
9
13
  chatMessageBackground?: string;
10
14
  chatMessageColor?: string;
11
15
  fontFamily?: string;
12
- singleToastsTheme?: {
13
- backgroundColor: string;
14
- progressBarColor: string;
15
- titleColor: string;
16
- messageColor: string;
17
- iconFillColor: string;
18
- iconStrokeColor: string;
19
- };
16
+ modules?: Record<string, ModuleConstructor>;
17
+ migrators?: Record<string, MigratorConstructor>;
20
18
  subscreens?: Record<string, SubscreenConstructor>;
21
19
  localization?: {
22
20
  locales: {
23
- default: string;
24
- supported: string[];
21
+ default: Locale;
22
+ supported: Locale[];
25
23
  };
26
24
  translationsFolderPath: string;
27
25
  };
28
26
  changelog?: {
29
27
  data: {
30
- generated_at: string;
28
+ date: string;
29
+ version: string;
31
30
  contributors: {
32
31
  name: string;
33
32
  avatar_url: string;
@@ -42,23 +41,17 @@ export interface ModData {
42
41
  tags: ChangelogEntryTag[];
43
42
  commit_url: string;
44
43
  }[];
45
- };
44
+ }[];
46
45
  };
47
46
  onReady?: () => void;
48
47
  }
49
- export { version } from "../package.json";
48
+ export { version };
50
49
  export declare let MOD_DATA: ModData;
51
50
  /**
52
51
  * Bootstraps the mod by initializing core systems and setting up essential hooks and event listeners.
53
52
  * @param modData - The mod configuration.
54
53
  */
55
54
  export declare function bootstrap(modData: ModData): void;
56
- export declare function formatString(text: string): ({
57
- html: string;
58
- isBeatifulString: true;
59
- } | {
60
- isBeatifulString: false;
61
- });
62
55
  export declare function sleep(ms: number): Promise<() => {}>;
63
56
  /**
64
57
  * Waits until the provided condition function returns `true`.
@@ -1,4 +1,26 @@
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;
1
+ export interface LanguageEntry {
2
+ locale: Locale;
3
+ name: string;
4
+ flag: string;
5
+ }
6
+ export declare const LANGUAGES: LanguageEntry[];
7
+ export type Locale = "en" | "ru" | "uk" | "zh" | "ja" | "de" | "fr" | "hi";
8
+ export type TranslationData = Record<string, unknown>;
9
+ export interface CustomTranslationRecord {
10
+ name: string;
11
+ modKey: string;
12
+ data: TranslationData;
13
+ }
14
+ export declare function getLocale(): Locale | null;
15
+ export declare function setLocale(locale: Locale): void;
16
+ export declare function addCustomTranslation(name: string, data: TranslationData, modKey: string): Promise<void>;
17
+ export declare function removeCustomTranslation(name: string): Promise<void>;
18
+ export declare function getCustomTranslation(name: string): Promise<CustomTranslationRecord | null>;
19
+ export declare function getAllCustomTranslations(): Promise<CustomTranslationRecord[]>;
20
+ export declare function setActiveCustomTranslation(name: string): Promise<void>;
21
+ export declare function getActiveCustomTranslation(modKey: string): Promise<CustomTranslationRecord | null>;
22
+ export declare function clearActiveCustomTranslation(name: string): Promise<void>;
23
+ export declare function fetchTranslation(locale: Locale): Promise<TranslationData>;
3
24
  export declare function loadLocalization(): Promise<void>;
4
- export declare function fetchTranslationsForLocale(locale: string): Promise<void>;
25
+ export declare function processReplacements(text: string, replacements: Record<string, string | number>): string;
26
+ export declare function getText(tag: string, replacements?: Record<string, string | number>): string;
@@ -0,0 +1,6 @@
1
+ export type MigratorConstructor = new () => BaseMigrator;
2
+ export declare abstract class BaseMigrator {
3
+ abstract readonly migrationVersion: string;
4
+ abstract migrate(): void;
5
+ }
6
+ export declare function runMigrations(savedVersion: string): void;