zois-core 2.0.2 → 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 +38 -4
- 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/shard.js +1 -1
- 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/tabsShard.d.ts +1 -0
- package/dist/ui.js +3 -3
- 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
|
|
163
|
+
background: TAGS[tag].coloring.background,
|
|
164
|
+
color: TAGS[tag].coloring.text,
|
|
131
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) {
|
package/dist/shards/shard.js
CHANGED
|
@@ -29,7 +29,7 @@ class Shard {
|
|
|
29
29
|
}
|
|
30
30
|
processModules(stage) {
|
|
31
31
|
const modules = this.context.modules ?? {};
|
|
32
|
-
if (stage === "
|
|
32
|
+
if (stage === "overrideContext") {
|
|
33
33
|
for (const key of Object.keys(modules)) {
|
|
34
34
|
for (const module of modules[key] ?? []) {
|
|
35
35
|
if (module instanceof ShardModule) {
|
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;
|
|
@@ -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/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";
|
|
@@ -309,10 +309,10 @@ class BaseSubscreen {
|
|
|
309
309
|
}
|
|
310
310
|
drawPolylineArrow({
|
|
311
311
|
points,
|
|
312
|
-
strokeColor =
|
|
312
|
+
strokeColor = cssVar("--tmd-text", "black"),
|
|
313
313
|
lineWidth = 2,
|
|
314
314
|
circleRadius = 5,
|
|
315
|
-
circleColor =
|
|
315
|
+
circleColor = cssVar("--tmd-text", "black")
|
|
316
316
|
}) {
|
|
317
317
|
if (points.length < 2) return;
|
|
318
318
|
const ctx = MainCanvas.canvas.getContext("2d");
|