zois-core 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/changelogs.js +39 -5
- package/dist/index.js +1 -14
- package/dist/localization.js +4 -4
- package/dist/shard-modules/centerModule.js +1 -1
- package/dist/shards/buttonShard.js +2 -0
- package/dist/shards/checkboxShard.js +1 -1
- package/dist/shards/containerShard.js +122 -5
- package/dist/shards/shard.js +10 -7
- package/dist/shards/tabsShard.js +12 -0
- package/dist/shards/textShard.js +1 -0
- package/dist/types/changelogs.d.ts +1 -0
- package/dist/types/index.d.ts +2 -25
- package/dist/types/shards/containerShard.d.ts +5 -2
- package/dist/types/shards/shard.d.ts +1 -0
- package/dist/types/shards/tabsShard.d.ts +1 -0
- package/dist/types/ui.d.ts +2 -0
- package/dist/ui.js +14 -6
- package/package.json +1 -1
package/dist/changelogs.js
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { MOD_DATA } from ".";
|
|
2
2
|
import { logger } from "./logging";
|
|
3
3
|
import { addDynamicClass } from "./ui";
|
|
4
|
+
const TAGS = {
|
|
5
|
+
fix: {
|
|
6
|
+
name: "Fix",
|
|
7
|
+
coloring: {
|
|
8
|
+
text: "#771515",
|
|
9
|
+
background: "#f9b4b4",
|
|
10
|
+
border: "#ca6565"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
chore: {
|
|
14
|
+
name: "Chore",
|
|
15
|
+
coloring: {
|
|
16
|
+
text: "#464646",
|
|
17
|
+
background: "#f2f2f2",
|
|
18
|
+
border: "#e2e2e2"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
feature: {
|
|
22
|
+
name: "Feature",
|
|
23
|
+
coloring: {
|
|
24
|
+
text: "#147914",
|
|
25
|
+
background: "#cbffcbc7",
|
|
26
|
+
border: "#4eea4e"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
localization: {
|
|
30
|
+
name: "Localization",
|
|
31
|
+
coloring: {
|
|
32
|
+
text: "#09093e",
|
|
33
|
+
background: "#a1e0f4",
|
|
34
|
+
border: "#66adec"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
4
38
|
function showChangelogModal() {
|
|
5
39
|
const changelog = MOD_DATA.changelog;
|
|
6
40
|
const { data } = changelog;
|
|
@@ -120,17 +154,17 @@ function createCommitElement(changelogCommit) {
|
|
|
120
154
|
tags.style.cssText = "display: flex; gap: 4px; position: absolute; right: 2px; top: 2px;";
|
|
121
155
|
for (const tag of changelogCommit.tags) {
|
|
122
156
|
const tagEl = document.createElement("p");
|
|
123
|
-
tagEl.textContent = tag;
|
|
157
|
+
tagEl.textContent = TAGS[tag].name;
|
|
124
158
|
addDynamicClass(tagEl, {
|
|
125
159
|
base: {
|
|
126
160
|
fontSize: "0.85em",
|
|
127
161
|
padding: "2px 6px",
|
|
128
162
|
borderRadius: "6px",
|
|
129
|
-
background: tag
|
|
130
|
-
color: tag
|
|
131
|
-
borderWidth: "
|
|
163
|
+
background: TAGS[tag].coloring.background,
|
|
164
|
+
color: TAGS[tag].coloring.text,
|
|
165
|
+
borderWidth: "1px",
|
|
132
166
|
borderStyle: "solid",
|
|
133
|
-
borderColor: tag
|
|
167
|
+
borderColor: TAGS[tag].coloring.border
|
|
134
168
|
}
|
|
135
169
|
});
|
|
136
170
|
tags.append(tagEl);
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { registerCore } from "./core";
|
|
2
2
|
import { dialogsManager } from "./dialogs";
|
|
3
3
|
import { loadLocalization } from "./localization";
|
|
4
|
-
import { createModSdk,
|
|
4
|
+
import { createModSdk, hookFunction, HookPriority } from "./modSdk";
|
|
5
5
|
import { getCurrentSubscreen, setSubscreen } from "./ui";
|
|
6
6
|
import { version } from "../package.json";
|
|
7
7
|
let MOD_DATA;
|
|
@@ -151,18 +151,6 @@ function getPlayer(value) {
|
|
|
151
151
|
function getNickname(target) {
|
|
152
152
|
return CharacterNickname(target);
|
|
153
153
|
}
|
|
154
|
-
function getThemedColorsModule() {
|
|
155
|
-
if (!findModByName("Themed")) return null;
|
|
156
|
-
const data = LZString.decompressFromBase64(Player.ExtensionSettings.Themed ?? "") ?? "{}";
|
|
157
|
-
let themedData;
|
|
158
|
-
try {
|
|
159
|
-
themedData = JSON.parse(data);
|
|
160
|
-
} catch {
|
|
161
|
-
}
|
|
162
|
-
;
|
|
163
|
-
if (!themedData?.GlobalModule?.themedEnabled || !themedData?.GlobalModule?.doVanillaGuiOverhaul) return null;
|
|
164
|
-
return themedData.ColorsModule;
|
|
165
|
-
}
|
|
166
154
|
function injectStyles(stylesToInject) {
|
|
167
155
|
const style = document.createElement("style");
|
|
168
156
|
style.innerHTML = stylesToInject;
|
|
@@ -191,7 +179,6 @@ export {
|
|
|
191
179
|
getPlayer,
|
|
192
180
|
getRandomNumber,
|
|
193
181
|
getSizeInKbytes,
|
|
194
|
-
getThemedColorsModule,
|
|
195
182
|
injectStyles,
|
|
196
183
|
isVersionNewer,
|
|
197
184
|
normalizeObject,
|
package/dist/localization.js
CHANGED
|
@@ -8,7 +8,7 @@ function getText(tag, replacements) {
|
|
|
8
8
|
return tag;
|
|
9
9
|
}
|
|
10
10
|
const defaultLocale = MOD_DATA.localization.locales.default;
|
|
11
|
-
const preferredLocale = TranslationLanguage;
|
|
11
|
+
const preferredLocale = TranslationLanguage.toLowerCase();
|
|
12
12
|
const value = getNestedValue(translations[preferredLocale], tag) ?? getNestedValue(translations[defaultLocale], tag);
|
|
13
13
|
if (!value) {
|
|
14
14
|
logger.warn("Unknown translation tag:", tag);
|
|
@@ -39,15 +39,15 @@ async function loadLocalization() {
|
|
|
39
39
|
}
|
|
40
40
|
const supportedLocales = MOD_DATA.localization.locales.supported;
|
|
41
41
|
const defaultLocale = MOD_DATA.localization.locales.default;
|
|
42
|
-
const preferredLocale = TranslationLanguage;
|
|
42
|
+
const preferredLocale = TranslationLanguage.toLowerCase();
|
|
43
43
|
if (!supportedLocales.includes(defaultLocale)) {
|
|
44
44
|
logger.warn(`Default locale ${defaultLocale} isn't supported, fix configuration`);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
hookFunction("TranslationSwitchLanguage", HookPriority.OBSERVE, (args, next) => {
|
|
48
48
|
const value = next(args);
|
|
49
|
-
if (supportedLocales.includes(TranslationLanguage) && !(TranslationLanguage in translations)) {
|
|
50
|
-
fetchTranslationsForLocale(TranslationLanguage);
|
|
49
|
+
if (supportedLocales.includes(TranslationLanguage.toLowerCase()) && !(TranslationLanguage.toLowerCase() in translations)) {
|
|
50
|
+
fetchTranslationsForLocale(TranslationLanguage.toLowerCase());
|
|
51
51
|
}
|
|
52
52
|
return value;
|
|
53
53
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ShardModule } from "./shardModule";
|
|
2
2
|
class CenterModule extends ShardModule {
|
|
3
3
|
overrideContext(context, target) {
|
|
4
|
-
target.style.
|
|
4
|
+
target.style.transform = "translate(-50%, -50%)";
|
|
5
5
|
context.x = 1e3;
|
|
6
6
|
context.y = 500;
|
|
7
7
|
return context;
|
|
@@ -107,6 +107,8 @@ class ButtonShard extends Shard {
|
|
|
107
107
|
if (text) {
|
|
108
108
|
textElement = document.createElement("span");
|
|
109
109
|
textElement.textContent = text;
|
|
110
|
+
textElement.style.height = "100%";
|
|
111
|
+
textElement.style.overflow = "scroll";
|
|
110
112
|
btn.append(textElement);
|
|
111
113
|
}
|
|
112
114
|
if (tooltip) {
|
|
@@ -15,7 +15,7 @@ class CheckboxShard extends Shard {
|
|
|
15
15
|
display: "flex",
|
|
16
16
|
alignItems: "center",
|
|
17
17
|
justifyContent: "center",
|
|
18
|
-
transition: "
|
|
18
|
+
transition: "background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
19
19
|
appearance: "none"
|
|
20
20
|
},
|
|
21
21
|
":checked": {
|
|
@@ -1,13 +1,130 @@
|
|
|
1
|
+
import { addDynamicClass } from "../ui";
|
|
1
2
|
import { Shard } from "./shard";
|
|
2
3
|
class ContainerShard extends Shard {
|
|
4
|
+
get dynamicClassContainer() {
|
|
5
|
+
return {
|
|
6
|
+
base: {},
|
|
7
|
+
"> div:first-child::-webkit-scrollbar": {
|
|
8
|
+
display: "none"
|
|
9
|
+
},
|
|
10
|
+
"> div:first-child": {
|
|
11
|
+
scrollbarWidth: "none"
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
get mountReturnValue() {
|
|
16
|
+
return this.body?.content ?? null;
|
|
17
|
+
}
|
|
3
18
|
generateBody() {
|
|
19
|
+
const scrollMode = this.context.scroll ?? "auto";
|
|
4
20
|
const container = document.createElement("div");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
container.style.position = "relative";
|
|
22
|
+
addDynamicClass(container, this.dynamicClassContainer);
|
|
23
|
+
const mayNeedVerticalScrollbar = scrollMode === "y" || scrollMode === "all" || scrollMode === "auto";
|
|
24
|
+
const containerContent = document.createElement("div");
|
|
25
|
+
containerContent.style.width = "100%";
|
|
26
|
+
containerContent.style.height = "100%";
|
|
27
|
+
containerContent.style.boxSizing = "border-box";
|
|
28
|
+
switch (scrollMode) {
|
|
29
|
+
case "all":
|
|
30
|
+
containerContent.style.overflow = "scroll";
|
|
31
|
+
break;
|
|
32
|
+
case "x":
|
|
33
|
+
containerContent.style.overflowX = "scroll";
|
|
34
|
+
containerContent.style.overflowY = "hidden";
|
|
35
|
+
break;
|
|
36
|
+
case "y":
|
|
37
|
+
containerContent.style.overflowY = "scroll";
|
|
38
|
+
containerContent.style.overflowX = "hidden";
|
|
39
|
+
break;
|
|
40
|
+
case "none":
|
|
41
|
+
containerContent.style.overflow = "unset";
|
|
42
|
+
break;
|
|
43
|
+
case "auto":
|
|
44
|
+
default:
|
|
45
|
+
containerContent.style.overflow = "auto";
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
const scrollbar = document.createElement("div");
|
|
49
|
+
scrollbar.style.cssText = `
|
|
50
|
+
position: absolute;
|
|
51
|
+
right: 0;
|
|
52
|
+
top: 50%;
|
|
53
|
+
display: none;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
gap: calc(var(--size-unit) * 1.25px);
|
|
56
|
+
transform: translateY(-50%);
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
z-index: 10;
|
|
59
|
+
width: calc(var(--size-unit) * 1.25px);
|
|
60
|
+
`;
|
|
61
|
+
const diamonds = [];
|
|
62
|
+
for (let i = 0; i < 6; i++) {
|
|
63
|
+
const diamond = document.createElement("div");
|
|
64
|
+
diamond.style.cssText = `
|
|
65
|
+
transform: rotate(45deg);
|
|
66
|
+
width: 100%;
|
|
67
|
+
aspect-ratio: 1/1;
|
|
68
|
+
background: var(--tmd-element, gray);
|
|
69
|
+
border: 1px solid var(--tmd-accent, black);
|
|
70
|
+
transition: background 0.15s ease, transform 0.15s ease;
|
|
71
|
+
`;
|
|
72
|
+
scrollbar.append(diamond);
|
|
73
|
+
diamonds.push(diamond);
|
|
74
|
+
}
|
|
75
|
+
const updateIndicators = () => {
|
|
76
|
+
const maxScroll = containerContent.scrollHeight - containerContent.clientHeight;
|
|
77
|
+
if (maxScroll <= 1) {
|
|
78
|
+
diamonds.forEach((d) => {
|
|
79
|
+
d.style.background = "var(--tmd-element, gray)";
|
|
80
|
+
d.style.transform = "rotate(45deg) scale(1)";
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const progress = Math.min(1, Math.max(0, containerContent.scrollTop / maxScroll));
|
|
85
|
+
const activeIndex = Math.round(progress * (diamonds.length - 1));
|
|
86
|
+
diamonds.forEach((diamond, i) => {
|
|
87
|
+
if (i === activeIndex) {
|
|
88
|
+
diamond.style.background = "var(--tmd-accent, #fff)";
|
|
89
|
+
diamond.style.transform = "rotate(45deg) scale(1.25)";
|
|
90
|
+
} else if (i < activeIndex) {
|
|
91
|
+
diamond.style.background = "var(--tmd-element, #aaa)";
|
|
92
|
+
diamond.style.transform = "rotate(45deg) scale(1)";
|
|
93
|
+
} else {
|
|
94
|
+
diamond.style.background = "var(--tmd-element-hover, gray)";
|
|
95
|
+
diamond.style.transform = "rotate(45deg) scale(1)";
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
containerContent.addEventListener("scroll", updateIndicators, { passive: true });
|
|
100
|
+
const needsVerticalScrollbar = scrollMode === "y" || scrollMode === "all";
|
|
101
|
+
const updateScrollbarVisibility = () => {
|
|
102
|
+
const isOverflowing = containerContent.scrollHeight - containerContent.clientHeight > 1;
|
|
103
|
+
const shouldShow = needsVerticalScrollbar || scrollMode === "auto" && isOverflowing;
|
|
104
|
+
containerContent.style.paddingRight = shouldShow ? "min(2vw, 2vh)" : "";
|
|
105
|
+
scrollbar.style.display = shouldShow ? "flex" : "none";
|
|
106
|
+
updateIndicators();
|
|
107
|
+
};
|
|
108
|
+
if (mayNeedVerticalScrollbar) {
|
|
109
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
110
|
+
requestAnimationFrame(updateScrollbarVisibility);
|
|
111
|
+
});
|
|
112
|
+
resizeObserver.observe(containerContent);
|
|
113
|
+
const mutationObserver = new MutationObserver(() => {
|
|
114
|
+
requestAnimationFrame(updateScrollbarVisibility);
|
|
115
|
+
});
|
|
116
|
+
mutationObserver.observe(containerContent, {
|
|
117
|
+
childList: true,
|
|
118
|
+
subtree: true,
|
|
119
|
+
characterData: true
|
|
120
|
+
});
|
|
121
|
+
requestAnimationFrame(updateScrollbarVisibility);
|
|
122
|
+
}
|
|
123
|
+
container.append(containerContent, scrollbar);
|
|
9
124
|
return {
|
|
10
|
-
base: container
|
|
125
|
+
base: container,
|
|
126
|
+
content: containerContent,
|
|
127
|
+
scrollbar
|
|
11
128
|
};
|
|
12
129
|
}
|
|
13
130
|
}
|
package/dist/shards/shard.js
CHANGED
|
@@ -11,6 +11,9 @@ class Shard {
|
|
|
11
11
|
}
|
|
12
12
|
context;
|
|
13
13
|
body = null;
|
|
14
|
+
get mountReturnValue() {
|
|
15
|
+
return this.body?.base ?? null;
|
|
16
|
+
}
|
|
14
17
|
mount(parentElement = this.context.parent ?? document.body) {
|
|
15
18
|
parentElement.append(this.body.base);
|
|
16
19
|
this.update();
|
|
@@ -22,18 +25,18 @@ class Shard {
|
|
|
22
25
|
window.removeEventListener("zois-core:subscreenunloaded", onUnload);
|
|
23
26
|
};
|
|
24
27
|
window.addEventListener("zois-core:subscreenunloaded", onUnload);
|
|
25
|
-
return this.
|
|
28
|
+
return this.mountReturnValue;
|
|
26
29
|
}
|
|
27
30
|
processModules(stage) {
|
|
28
31
|
const modules = this.context.modules ?? {};
|
|
29
|
-
if (stage === "
|
|
32
|
+
if (stage === "overrideContext") {
|
|
30
33
|
for (const key of Object.keys(modules)) {
|
|
31
34
|
for (const module of modules[key] ?? []) {
|
|
32
35
|
if (module instanceof ShardModule) {
|
|
33
36
|
try {
|
|
34
37
|
this.context = module.overrideContext(this.context, this.body[key]);
|
|
35
38
|
} catch (e) {
|
|
36
|
-
logger.error("OverrideContext call failed in", module);
|
|
39
|
+
logger.error("OverrideContext call failed in", module, e);
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -45,8 +48,8 @@ class Shard {
|
|
|
45
48
|
if (module instanceof ShardModule) {
|
|
46
49
|
try {
|
|
47
50
|
module.layoutEffect(this.context, this.body[key]);
|
|
48
|
-
} catch {
|
|
49
|
-
logger.error("LayoutEffect call failed in", module);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
logger.error("LayoutEffect call failed in", module, e);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
@@ -58,8 +61,8 @@ class Shard {
|
|
|
58
61
|
if (module instanceof ShardModule) {
|
|
59
62
|
try {
|
|
60
63
|
module.effect(this.context, this.body[key]);
|
|
61
|
-
} catch {
|
|
62
|
-
logger.error("Effect call failed in", module);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
logger.error("Effect call failed in", module, e);
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
}
|
package/dist/shards/tabsShard.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { MOD_DATA } from "../index";
|
|
2
|
+
import { hookFunction, HookPriority } from "../modSdk";
|
|
2
3
|
import { autosetFontSize, setFontFamily } from "../ui";
|
|
3
4
|
import { Shard } from "./shard";
|
|
4
5
|
class TabsShard extends Shard {
|
|
5
6
|
tabHandlers = {};
|
|
7
|
+
clearDrawProcessHook = null;
|
|
6
8
|
constructor(context) {
|
|
7
9
|
super(context);
|
|
8
10
|
}
|
|
9
11
|
generateBody() {
|
|
10
12
|
this.tabHandlers ??= {};
|
|
13
|
+
this.clearDrawProcessHook = null;
|
|
11
14
|
const { tabs, currentTabName } = this.context;
|
|
12
15
|
let tabElements = [];
|
|
13
16
|
const tabsEl = document.createElement("div");
|
|
@@ -28,6 +31,7 @@ class TabsShard extends Shard {
|
|
|
28
31
|
tabElements.push(...nodes);
|
|
29
32
|
originalAppend(...nodes);
|
|
30
33
|
};
|
|
34
|
+
this.clearDrawProcessHook?.();
|
|
31
35
|
this.tabHandlers.unload?.();
|
|
32
36
|
this.tabHandlers.exit?.();
|
|
33
37
|
this.tabHandlers = {
|
|
@@ -36,7 +40,14 @@ class TabsShard extends Shard {
|
|
|
36
40
|
unload: tab.unload,
|
|
37
41
|
exit: tab.exit
|
|
38
42
|
};
|
|
43
|
+
this.clearDrawProcessHook = null;
|
|
39
44
|
this.tabHandlers.load?.();
|
|
45
|
+
if (tab.run) {
|
|
46
|
+
this.clearDrawProcessHook = hookFunction("DrawProcess", HookPriority.ADD_BEHAVIOR, (args, next) => {
|
|
47
|
+
next(args);
|
|
48
|
+
tab.run?.();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
40
51
|
document.body.append = originalAppend;
|
|
41
52
|
};
|
|
42
53
|
const tabEl = document.createElement("button");
|
|
@@ -45,6 +56,7 @@ class TabsShard extends Shard {
|
|
|
45
56
|
tabEl.addEventListener("click", switchTab);
|
|
46
57
|
tabsEl.append(tabEl);
|
|
47
58
|
});
|
|
59
|
+
window.addEventListener("zois-core:subscreenunloaded", () => this.clearDrawProcessHook?.(), { once: true });
|
|
48
60
|
return {
|
|
49
61
|
base: tabsEl
|
|
50
62
|
};
|
package/dist/shards/textShard.js
CHANGED
|
@@ -9,6 +9,7 @@ class TextShard extends Shard {
|
|
|
9
9
|
const p = document.createElement("p");
|
|
10
10
|
p.innerHTML = this.context.text ?? "";
|
|
11
11
|
p.style.color = this.context.color ?? this.defaultColor;
|
|
12
|
+
p.style.overflow = "scroll";
|
|
12
13
|
if (this.context.withBackground) p.style.background = "var(--tmd-element,rgb(239, 239, 239))";
|
|
13
14
|
if (this.context.withBorder) p.style.border = "2px solid var(--tmd-accent, rgb(236, 236, 236))";
|
|
14
15
|
setFontFamily(p, MOD_DATA.fontFamily);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChangelogEntryTag } from "./changelogs";
|
|
1
2
|
import { BaseSubscreen, SubscreenConstructor } from "./ui";
|
|
2
3
|
export interface ModData {
|
|
3
4
|
name: string;
|
|
@@ -35,36 +36,13 @@ export interface ModData {
|
|
|
35
36
|
avatar_url: string;
|
|
36
37
|
};
|
|
37
38
|
date: string;
|
|
38
|
-
tags:
|
|
39
|
+
tags: ChangelogEntryTag[];
|
|
39
40
|
commit_url: string;
|
|
40
41
|
}[];
|
|
41
42
|
};
|
|
42
43
|
};
|
|
43
44
|
onReady?: () => void;
|
|
44
45
|
}
|
|
45
|
-
interface ThemedColorsModule {
|
|
46
|
-
base: {
|
|
47
|
-
accent: string;
|
|
48
|
-
accentDisabled: string;
|
|
49
|
-
accentHover: string;
|
|
50
|
-
element: string;
|
|
51
|
-
elementDisabled: string;
|
|
52
|
-
elementHint: string;
|
|
53
|
-
elementHover: string;
|
|
54
|
-
main: string;
|
|
55
|
-
text: string;
|
|
56
|
-
};
|
|
57
|
-
special: {
|
|
58
|
-
allowed: string;
|
|
59
|
-
blocked: string;
|
|
60
|
-
crafted: string;
|
|
61
|
-
equipped: string;
|
|
62
|
-
limited: string;
|
|
63
|
-
roomBlocked: string;
|
|
64
|
-
roomFriend: string;
|
|
65
|
-
roomGame: string;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
46
|
export { version } from "../package.json";
|
|
69
47
|
export declare let MOD_DATA: ModData;
|
|
70
48
|
export declare function bootstrap(modData: ModData): void;
|
|
@@ -108,7 +86,6 @@ export declare function colorsEqual(c1: string[] | string | null | undefined, c2
|
|
|
108
86
|
export declare function getSizeInKbytes(b: any): number;
|
|
109
87
|
export declare function getPlayer(value: string | number): Character | null;
|
|
110
88
|
export declare function getNickname(target: Character): string;
|
|
111
|
-
export declare function getThemedColorsModule(): ThemedColorsModule | null;
|
|
112
89
|
export declare function injectStyles(stylesToInject: string): void;
|
|
113
90
|
export declare function normalizeObject<T>(obj: T[]): T[];
|
|
114
91
|
export declare function normalizeObject<T extends object>(obj: T): T;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { DynamicClassStyles } from "../ui";
|
|
1
2
|
import { Shard, ShardContext } from "./shard";
|
|
2
|
-
export interface ContainerShardContext extends ShardContext {
|
|
3
|
-
scroll?: "x" | "y" | "all" | "auto";
|
|
3
|
+
export interface ContainerShardContext extends ShardContext<"content" | "scrollbar"> {
|
|
4
|
+
scroll?: "x" | "y" | "all" | "none" | "auto";
|
|
4
5
|
}
|
|
5
6
|
export declare class ContainerShard extends Shard<ContainerShardContext> {
|
|
7
|
+
protected get dynamicClassContainer(): DynamicClassStyles;
|
|
8
|
+
protected get mountReturnValue(): HTMLElement | SVGElement | null;
|
|
6
9
|
generateBody(): Record<keyof NonNullable<ContainerShardContext["modules"]>, HTMLElement | SVGElement>;
|
|
7
10
|
}
|
|
@@ -13,6 +13,7 @@ export interface ShardContext<T extends string = never> {
|
|
|
13
13
|
export declare abstract class Shard<Context extends ShardContext = ShardContext> {
|
|
14
14
|
protected context: Context;
|
|
15
15
|
protected body: Record<keyof NonNullable<Context["modules"]>, HTMLElement | SVGElement> | null;
|
|
16
|
+
protected get mountReturnValue(): HTMLElement | SVGElement;
|
|
16
17
|
constructor(context: Context);
|
|
17
18
|
mount(parentElement?: HTMLElement): HTMLElement | SVGElement;
|
|
18
19
|
protected abstract generateBody(): Record<keyof NonNullable<Context["modules"]>, HTMLElement | SVGElement>;
|
|
@@ -11,6 +11,7 @@ export interface TabsShardContext extends Omit<ShardContext, "height"> {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class TabsShard extends Shard<TabsShardContext> {
|
|
13
13
|
private tabHandlers;
|
|
14
|
+
private clearDrawProcessHook;
|
|
14
15
|
constructor(context: TabsShardContext);
|
|
15
16
|
generateBody(): Record<keyof NonNullable<TabsShardContext["modules"]>, HTMLElement | SVGElement>;
|
|
16
17
|
update(): void;
|
package/dist/types/ui.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare function setFontSize(element: HTMLElement, targetFontSize: number
|
|
|
42
42
|
export declare function setFontFamily(element: HTMLElement, fontFamily?: string): void;
|
|
43
43
|
export declare function setPadding(element: HTMLElement, targetPadding: number): void;
|
|
44
44
|
export declare function autosetFontSize(element: HTMLElement): void;
|
|
45
|
+
export declare function setSizeUnitVariable(): void;
|
|
45
46
|
export declare function addDynamicClass(targetElement: HTMLElement | SVGElement, styles: DynamicClassStyles): void;
|
|
46
47
|
export declare function setPreviousSubscreen(): void;
|
|
47
48
|
export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
|
|
@@ -58,6 +59,7 @@ export declare abstract class BaseSubscreen {
|
|
|
58
59
|
click(): void;
|
|
59
60
|
exit(): void;
|
|
60
61
|
update(): void;
|
|
62
|
+
resize(): void;
|
|
61
63
|
setPreviousSubscreen(): void;
|
|
62
64
|
create(shard: Shard): HTMLElement;
|
|
63
65
|
createButton(ctx: ButtonShardContext): HTMLButtonElement;
|
package/dist/ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SubscreenLoadedEvent, SubscreenUnloadedEvent } from "./index";
|
|
2
2
|
import { StyleModule } from "./shard-modules";
|
|
3
3
|
import { MOD_DATA } from "./index";
|
|
4
4
|
import { ButtonShard, TextShard, InputShard, CheckboxShard, InputListShard, ImageShard, SvgShard, BackNextButtonShard, TabsShard, CardShard, SelectShard, ContainerShard } from "./shards";
|
|
@@ -107,6 +107,12 @@ function autosetFontSize(element) {
|
|
|
107
107
|
fontSize: Font + "px"
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
+
function setSizeUnitVariable() {
|
|
111
|
+
const canvasWidth = MainCanvas.canvas.clientWidth;
|
|
112
|
+
const canvasHeight = MainCanvas.canvas.clientHeight;
|
|
113
|
+
const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
|
|
114
|
+
document.documentElement.style.setProperty("--size-unit", scaleFactor.toString());
|
|
115
|
+
}
|
|
110
116
|
const createdDynamicClasses = [];
|
|
111
117
|
function generateDynamicClassCacheKey(styles) {
|
|
112
118
|
const sortedStringify = (obj) => {
|
|
@@ -209,6 +215,7 @@ class BaseSubscreen {
|
|
|
209
215
|
run() {
|
|
210
216
|
}
|
|
211
217
|
load() {
|
|
218
|
+
setSizeUnitVariable();
|
|
212
219
|
this.createButton({
|
|
213
220
|
x: 1815,
|
|
214
221
|
y: 75,
|
|
@@ -235,9 +242,6 @@ class BaseSubscreen {
|
|
|
235
242
|
fontSize: 8
|
|
236
243
|
}).style.cssText += "max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;";
|
|
237
244
|
}
|
|
238
|
-
if (subscreenHooks[this.constructor.name]) {
|
|
239
|
-
subscreenHooks[this.name].forEach((hook) => hook(this));
|
|
240
|
-
}
|
|
241
245
|
}
|
|
242
246
|
unload() {
|
|
243
247
|
}
|
|
@@ -248,6 +252,9 @@ class BaseSubscreen {
|
|
|
248
252
|
}
|
|
249
253
|
update() {
|
|
250
254
|
}
|
|
255
|
+
resize() {
|
|
256
|
+
setSizeUnitVariable();
|
|
257
|
+
}
|
|
251
258
|
setPreviousSubscreen() {
|
|
252
259
|
setPreviousSubscreen();
|
|
253
260
|
}
|
|
@@ -302,10 +309,10 @@ class BaseSubscreen {
|
|
|
302
309
|
}
|
|
303
310
|
drawPolylineArrow({
|
|
304
311
|
points,
|
|
305
|
-
strokeColor =
|
|
312
|
+
strokeColor = cssVar("--tmd-text", "black"),
|
|
306
313
|
lineWidth = 2,
|
|
307
314
|
circleRadius = 5,
|
|
308
|
-
circleColor =
|
|
315
|
+
circleColor = cssVar("--tmd-text", "black")
|
|
309
316
|
}) {
|
|
310
317
|
if (points.length < 2) return;
|
|
311
318
|
const ctx = MainCanvas.canvas.getContext("2d");
|
|
@@ -371,5 +378,6 @@ export {
|
|
|
371
378
|
setPosition,
|
|
372
379
|
setPreviousSubscreen,
|
|
373
380
|
setSize,
|
|
381
|
+
setSizeUnitVariable,
|
|
374
382
|
setSubscreen
|
|
375
383
|
};
|