zois-core 1.2.1 → 2.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 (118) hide show
  1. package/README.md +23 -2
  2. package/dist/assets/icons/exit.svg +17 -0
  3. package/dist/changelogs.js +153 -0
  4. package/dist/core-subscreen/coreSubscreen.js +81 -0
  5. package/dist/core-subscreen/developmentSubscreen.js +22 -0
  6. package/dist/core-subscreen/generalSubscreen.js +23 -0
  7. package/dist/core-subscreen/mainSubscreen.js +58 -0
  8. package/dist/core-subscreen/shards/coreButtonShard.js +30 -0
  9. package/dist/core-subscreen/shards/coreCheckboxShard.js +33 -0
  10. package/dist/core-subscreen/shards/coreInputListShard.js +38 -0
  11. package/dist/core-subscreen/shards/coreSelectShard.js +17 -0
  12. package/dist/core-subscreen/shards/coreTextShard.js +9 -0
  13. package/dist/core-subscreen/shards/index.js +5 -0
  14. package/dist/core-subscreen/toastsSubscreen.js +112 -0
  15. package/dist/core.js +178 -0
  16. package/dist/dialogs.js +110 -0
  17. package/dist/index.js +201 -1
  18. package/dist/localization.js +71 -0
  19. package/dist/logging.js +31 -0
  20. package/dist/messaging.js +234 -1
  21. package/dist/modSdk.js +63 -0
  22. package/dist/shard-modules/attributesModule.js +16 -0
  23. package/dist/shard-modules/centerModule.js +12 -0
  24. package/dist/shard-modules/clickModule.js +14 -0
  25. package/dist/shard-modules/counterUpModule.js +37 -0
  26. package/dist/shard-modules/dynamicClassModule.js +15 -0
  27. package/dist/shard-modules/index.js +9 -0
  28. package/dist/shard-modules/multiClickModule.js +41 -0
  29. package/dist/shard-modules/shardModule.js +12 -0
  30. package/dist/shard-modules/styleModule.js +20 -0
  31. package/dist/shard-modules/typeModule.js +37 -0
  32. package/dist/shards/backNextButtonShard.js +99 -0
  33. package/dist/shards/buttonShard.js +150 -0
  34. package/dist/shards/cardShard.js +35 -0
  35. package/dist/shards/checkboxShard.js +139 -0
  36. package/dist/shards/containerShard.js +16 -0
  37. package/dist/shards/imageShard.js +98 -0
  38. package/dist/shards/index.js +13 -0
  39. package/dist/shards/inputListShard.js +162 -0
  40. package/dist/shards/inputShard.js +33 -0
  41. package/dist/shards/selectShard.js +126 -0
  42. package/dist/shards/shard.js +79 -0
  43. package/dist/shards/svgShard.js +29 -0
  44. package/dist/shards/tabsShard.js +59 -0
  45. package/dist/shards/textShard.js +27 -0
  46. package/dist/styles.css +209 -1
  47. package/dist/toasts.js +189 -0
  48. package/dist/types/changelogs.d.ts +1 -0
  49. package/dist/types/core-subscreen/coreSubscreen.d.ts +15 -0
  50. package/dist/types/core-subscreen/developmentSubscreen.d.ts +5 -0
  51. package/dist/types/core-subscreen/generalSubscreen.d.ts +5 -0
  52. package/dist/types/core-subscreen/mainSubscreen.d.ts +6 -0
  53. package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +5 -0
  54. package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +6 -0
  55. package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +6 -0
  56. package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +5 -0
  57. package/dist/types/core-subscreen/shards/coreTextShard.d.ts +4 -0
  58. package/dist/types/core-subscreen/shards/index.d.ts +5 -0
  59. package/dist/types/core-subscreen/toastsSubscreen.d.ts +5 -0
  60. package/dist/types/core.d.ts +18 -0
  61. package/dist/types/dialogs.d.ts +29 -0
  62. package/dist/types/globals.d.ts +6 -0
  63. package/dist/types/index.d.ts +62 -6
  64. package/dist/types/localization.d.ts +4 -0
  65. package/dist/types/logging.d.ts +16 -0
  66. package/dist/types/messaging.d.ts +5 -3
  67. package/dist/types/{modsApi.d.ts → modSdk.d.ts} +2 -2
  68. package/dist/types/shard-modules/attributesModule.d.ts +7 -0
  69. package/dist/types/shard-modules/centerModule.d.ts +5 -0
  70. package/dist/types/shard-modules/clickModule.d.ts +7 -0
  71. package/dist/types/shard-modules/counterUpModule.d.ts +13 -0
  72. package/dist/types/shard-modules/dynamicClassModule.d.ts +8 -0
  73. package/dist/types/{ui-modules → shard-modules}/index.d.ts +2 -0
  74. package/dist/types/shard-modules/multiClickModule.d.ts +12 -0
  75. package/dist/types/shard-modules/shardModule.d.ts +7 -0
  76. package/dist/types/shard-modules/styleModule.d.ts +8 -0
  77. package/dist/types/shard-modules/typeModule.d.ts +11 -0
  78. package/dist/types/shards/backNextButtonShard.d.ts +14 -0
  79. package/dist/types/shards/buttonShard.d.ts +21 -0
  80. package/dist/types/shards/cardShard.d.ts +10 -0
  81. package/dist/types/shards/checkboxShard.d.ts +19 -0
  82. package/dist/types/shards/containerShard.d.ts +7 -0
  83. package/dist/types/shards/imageShard.d.ts +11 -0
  84. package/dist/types/shards/index.d.ts +13 -0
  85. package/dist/types/shards/inputListShard.d.ts +16 -0
  86. package/dist/types/shards/inputShard.d.ts +14 -0
  87. package/dist/types/shards/selectShard.d.ts +17 -0
  88. package/dist/types/shards/shard.d.ts +21 -0
  89. package/dist/types/shards/svgShard.d.ts +12 -0
  90. package/dist/types/shards/tabsShard.d.ts +17 -0
  91. package/dist/types/shards/textShard.d.ts +13 -0
  92. package/dist/types/toasts.d.ts +21 -0
  93. package/dist/types/ui.d.ts +35 -148
  94. package/dist/ui.js +375 -11
  95. package/dist/validation.js +31 -1
  96. package/dist/wardrobe.js +167 -1
  97. package/package.json +47 -26
  98. package/scripts/zois-core.mjs +126 -0
  99. package/dist/modsApi.js +0 -1
  100. package/dist/modules.js +0 -1
  101. package/dist/popups.js +0 -1
  102. package/dist/types/modules.d.ts +0 -18
  103. package/dist/types/popups.d.ts +0 -63
  104. package/dist/types/ui-modules/attributesModule.d.ts +0 -6
  105. package/dist/types/ui-modules/centerModule.d.ts +0 -4
  106. package/dist/types/ui-modules/clickModule.d.ts +0 -6
  107. package/dist/types/ui-modules/counterUpModule.d.ts +0 -12
  108. package/dist/types/ui-modules/dynamicClassModule.d.ts +0 -7
  109. package/dist/types/ui-modules/styleModule.d.ts +0 -7
  110. package/dist/types/ui-modules/typeModule.d.ts +0 -10
  111. package/dist/ui-modules/attributesModule.js +0 -1
  112. package/dist/ui-modules/centerModule.js +0 -1
  113. package/dist/ui-modules/clickModule.js +0 -1
  114. package/dist/ui-modules/counterUpModule.js +0 -1
  115. package/dist/ui-modules/dynamicClassModule.js +0 -1
  116. package/dist/ui-modules/index.js +0 -1
  117. package/dist/ui-modules/styleModule.js +0 -1
  118. package/dist/ui-modules/typeModule.js +0 -1
package/dist/messaging.js CHANGED
@@ -1 +1,234 @@
1
- import{getPlayer as f,MOD_DATA as d}from"./index";import{hookFunction as y,HookPriority as C}from"./modsApi";import{setFontFamily as v}from"./ui";import{validateData as R}from"./validation";class q{sendBeep(n,e){const u={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({...n})};ServerSend("AccountBeep",u)}sendPacket(n,e,u){const r={Content:d.key,Dictionary:{msg:n},Type:"Hidden"};e&&(r.Dictionary.data=e),u&&(r.Target=u),ServerSend("ChatRoomChat",r)}sendAction(n,e=void 0,u=[]){if(!n||!ServerPlayerIsInChatRoom())return;const r=CharacterPronounDescription(Player)==="She/Her",i=r?"Her":"His",p=r?"Her":"Him",c=r?"Herself":"Himself",t=r?"She":"He";n=n.replaceAll("<Possessive>",i).replaceAll("<possessive>",i.toLocaleLowerCase()).replaceAll("<Intensive>",p).replaceAll("<intensive>",p.toLocaleLowerCase()).replaceAll("<SelfIntensive>",c).replaceAll("<selfIntensive>",c.toLocaleLowerCase()).replaceAll("<Pronoun>",t).replaceAll("<pronoun>",t.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"ZC_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION',Text:n},...u]})}sendRequest({message:n,data:e={},target:u,type:r="packet"}){const i=crypto.randomUUID();return new Promise(p=>{let c;r==="packet"?(g.sendPacket("request",{requestId:i,message:n,data:e},u),c=y("ChatRoomMessage",C.ADD_BEHAVIOR,(t,o)=>{const a=t[0],s=f(a.Sender);if(!s)return o(t);if(a.Content===d.key&&!s.IsPlayer()){const m=a.Dictionary.msg,l=a.Dictionary.data;m==="requestResponse"&&l.requestId===i&&(c(),p({data:l.data,isError:!1}))}return o(t)})):(g.sendBeep({type:`${d.key}_request`,requestId:i,message:n,data:e},u),c=y("ServerAccountBeep",C.ADD_BEHAVIOR,(t,o)=>{const a=t[0];if(a.BeepType!=="Leash")return o(t);let s;try{s=JSON.parse(a.Message)}catch{return o(t)}return s.type===`${d.key}_requestResponse`&&s.requestId===i&&(c(),p({data:s.data,isError:!1})),o(t)})),setTimeout(()=>{c(),p({isError:!0})},6e3)})}sendLocal(n){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),v(e,d.fontFamily),e.style.background=d.chatMessageBackground??"#55edc095",e.style.color=d.chatMessageColor??"black",e.style.margin="0.15em 0",typeof n=="string"?e.innerHTML=n:e.appendChild(n),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}sendChat(n){ServerSend("ChatRoomChat",{Type:"Chat",Content:n})}onRequest(n,e,u){let r,i;typeof e=="function"&&e.prototype?.constructor==e?(i=e,r=u):r=e;const p=y("ChatRoomMessage",C.ADD_BEHAVIOR,async(t,o)=>{const a=t[0],s=f(a.Sender);if(!s)return o(t);if(a.Content===d.key&&!s.IsPlayer()){const m=a.Dictionary?.msg,l=a.Dictionary?.data;if(m==="request"&&l.message===n){if(typeof l.requestId!="string"||typeof l.message!="string")return;const h=await R(l.data,i);if(i&&!h.isValid)return console.warn(`${d.name} DTO Failure:`,h),o(t);const k=r(l.data,s);k!==void 0&&g.sendPacket("requestResponse",{requestId:l.requestId,message:l.message,data:k},s.MemberNumber)}}return o(t)}),c=y("ServerAccountBeep",C.ADD_BEHAVIOR,async(t,o)=>{const a=t[0];if(a.BeepType!=="Leash")return o(t);let s;try{s=JSON.parse(a.Message)}catch{return o(t)}if(s.type===`${d.key}_request`&&s.message===n){if(typeof s.requestId!="string")return;const m=await R(s.data,i);if(i&&!m.isValid)return console.warn(`${d.name} DTO Failure:`,m),o(t);const l=r(s.data,a.MemberNumber,a.MemberName);l!==void 0&&g.sendBeep({type:`${d.key}_requestResponse`,requestId:s.requestId,message:s.message,data:l},a.MemberNumber)}return o(t)});return()=>{p(),c()}}onPacket(n,e,u){return y("ChatRoomMessage",C.ADD_BEHAVIOR,async(r,i)=>{let p,c;typeof e=="function"&&e.prototype?.constructor==e?(c=e,p=u):p=e;const t=r[0],o=f(t.Sender);if(!o)return i(r);if(t.Content===d.key&&t.Dictionary.msg===n&&!o.IsPlayer()){const a=await R(t.Dictionary.data,c);if(c&&!a.isValid)return console.warn(`${d.name} DTO Failure:`,a),i(r);p(t.Dictionary.data,o)}return i(r)})}}const g=new q;export{g as messagesManager};
1
+ import { getPlayer, MOD_DATA } from "./index";
2
+ import { hookFunction, HookPriority } from "./modSdk";
3
+ import { setFontFamily } from "./ui";
4
+ import { validateData } from "./validation";
5
+ import { logger } from "./logging";
6
+ function isZoiChatRoomMessage(m) {
7
+ return m.Content === MOD_DATA.key;
8
+ }
9
+ function isClassConstructor(c) {
10
+ return typeof c === "function" && c.prototype?.constructor == c;
11
+ }
12
+ class MessagesManager {
13
+ sendBeep(data, targetId) {
14
+ const beep = {
15
+ IsSecret: true,
16
+ BeepType: "Leash",
17
+ MemberNumber: targetId,
18
+ Message: JSON.stringify({
19
+ ...data
20
+ })
21
+ };
22
+ ServerSend("AccountBeep", beep);
23
+ }
24
+ sendPacket(msg, _data, targetNumber) {
25
+ const data = {
26
+ Content: MOD_DATA.key,
27
+ Dictionary: {
28
+ msg
29
+ },
30
+ Type: "Hidden"
31
+ };
32
+ if (_data) data.Dictionary.data = _data;
33
+ if (targetNumber) data.Target = targetNumber;
34
+ ServerSend("ChatRoomChat", data);
35
+ }
36
+ sendAction(msg, target = void 0, dictionary = []) {
37
+ if (!msg || !ServerPlayerIsInChatRoom()) return;
38
+ const isFemale = CharacterPronounDescription(Player) === "She/Her";
39
+ const capPossessive = isFemale ? "Her" : "His";
40
+ const capIntensive = isFemale ? "Her" : "Him";
41
+ const capSelfIntensive = isFemale ? "Herself" : "Himself";
42
+ const capPronoun = isFemale ? "She" : "He";
43
+ msg = msg.replaceAll("<Possessive>", capPossessive).replaceAll("<possessive>", capPossessive.toLocaleLowerCase()).replaceAll("<Intensive>", capIntensive).replaceAll("<intensive>", capIntensive.toLocaleLowerCase()).replaceAll("<SelfIntensive>", capSelfIntensive).replaceAll("<selfIntensive>", capSelfIntensive.toLocaleLowerCase()).replaceAll("<Pronoun>", capPronoun).replaceAll("<pronoun>", capPronoun.toLocaleLowerCase());
44
+ ServerSend("ChatRoomChat", {
45
+ Content: "ZC_CUSTOM_ACTION",
46
+ Type: "Action",
47
+ Target: target ?? void 0,
48
+ Dictionary: [
49
+ { Tag: 'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION', Text: msg },
50
+ ...dictionary
51
+ ]
52
+ });
53
+ }
54
+ sendRequest({
55
+ message,
56
+ data = {},
57
+ target,
58
+ type = "packet"
59
+ }) {
60
+ const requestId = crypto.randomUUID();
61
+ return new Promise((resolve) => {
62
+ let deleteHook;
63
+ if (type === "packet") {
64
+ messagesManager.sendPacket("request", {
65
+ requestId,
66
+ message,
67
+ data
68
+ }, target);
69
+ deleteHook = hookFunction("ChatRoomMessage", HookPriority.ADD_BEHAVIOR, (args, next) => {
70
+ const _message = args[0];
71
+ const sender = getPlayer(_message.Sender);
72
+ if (!sender) return next(args);
73
+ if (isZoiChatRoomMessage(_message) && !sender.IsPlayer()) {
74
+ const msg = _message.Dictionary.msg;
75
+ const data2 = _message.Dictionary.data;
76
+ if (msg === "requestResponse" && data2.requestId === requestId) {
77
+ deleteHook();
78
+ resolve({
79
+ data: data2.data,
80
+ isError: false
81
+ });
82
+ }
83
+ }
84
+ return next(args);
85
+ });
86
+ } else {
87
+ messagesManager.sendBeep({
88
+ type: `${MOD_DATA.key}_request`,
89
+ requestId,
90
+ message,
91
+ data
92
+ }, target);
93
+ deleteHook = hookFunction("ServerAccountBeep", HookPriority.ADD_BEHAVIOR, (args, next) => {
94
+ const beep = args[0];
95
+ if (beep.BeepType !== "Leash") return next(args);
96
+ let data2;
97
+ try {
98
+ data2 = JSON.parse(beep.Message);
99
+ } catch {
100
+ return next(args);
101
+ }
102
+ if (data2.type === `${MOD_DATA.key}_requestResponse` && data2.requestId === requestId) {
103
+ deleteHook();
104
+ resolve({
105
+ data: data2.data,
106
+ isError: false
107
+ });
108
+ }
109
+ return next(args);
110
+ });
111
+ }
112
+ setTimeout(() => {
113
+ deleteHook();
114
+ resolve({
115
+ isError: true
116
+ });
117
+ }, 6e3);
118
+ });
119
+ }
120
+ sendLocal(message) {
121
+ if (!ServerPlayerIsInChatRoom()) return;
122
+ const div = document.createElement("div");
123
+ div.setAttribute("class", "ChatMessage ChatMessageLocalMessage");
124
+ div.setAttribute("data-time", ChatRoomCurrentTime());
125
+ div.setAttribute("data-sender", `${Player.MemberNumber}`);
126
+ setFontFamily(div, MOD_DATA.fontFamily);
127
+ div.style.background = MOD_DATA.chatMessageBackground ?? "#55edc095";
128
+ div.style.color = MOD_DATA.chatMessageColor ?? "black";
129
+ div.style.margin = "0.15em 0";
130
+ if (typeof message === "string") div.innerHTML = message;
131
+ else div.appendChild(message);
132
+ document.querySelector("#TextAreaChatLog")?.appendChild(div);
133
+ ElementScrollToEnd("TextAreaChatLog");
134
+ }
135
+ sendChat(message) {
136
+ ServerSend("ChatRoomChat", { Type: "Chat", Content: message });
137
+ }
138
+ onRequest(message, dtoOrListener, listener) {
139
+ let _listener;
140
+ let dto;
141
+ if (isClassConstructor(dtoOrListener)) {
142
+ dto = dtoOrListener;
143
+ _listener = listener;
144
+ } else {
145
+ _listener = dtoOrListener;
146
+ }
147
+ const rm1 = hookFunction("ChatRoomMessage", HookPriority.ADD_BEHAVIOR, async (args, next) => {
148
+ const _message = args[0];
149
+ const sender = getPlayer(_message.Sender);
150
+ if (!sender) return next(args);
151
+ if (isZoiChatRoomMessage(_message) && !sender.IsPlayer()) {
152
+ const msg = _message.Dictionary?.msg;
153
+ const data = _message.Dictionary?.data;
154
+ if (msg === "request" && data.message === message) {
155
+ if (typeof data.requestId !== "string" || typeof data.message !== "string") return;
156
+ const validationResult = await validateData(data.data, dto);
157
+ if (dto && !validationResult.isValid) {
158
+ logger.warn(`DTO Failure:`, validationResult);
159
+ return next(args);
160
+ }
161
+ const _data = _listener?.(data.data, sender);
162
+ if (_data !== void 0) {
163
+ messagesManager.sendPacket("requestResponse", {
164
+ requestId: data.requestId,
165
+ message: data.message,
166
+ data: _data
167
+ }, sender.MemberNumber);
168
+ }
169
+ }
170
+ }
171
+ return next(args);
172
+ });
173
+ const rm2 = hookFunction("ServerAccountBeep", HookPriority.ADD_BEHAVIOR, async (args, next) => {
174
+ const beep = args[0];
175
+ if (beep.BeepType !== "Leash") return next(args);
176
+ let data;
177
+ try {
178
+ data = JSON.parse(beep.Message);
179
+ } catch {
180
+ return next(args);
181
+ }
182
+ if (data.type === `${MOD_DATA.key}_request` && data.message === message) {
183
+ if (typeof data.requestId !== "string") return;
184
+ const validationResult = await validateData(data.data, dto);
185
+ if (dto && !validationResult.isValid) {
186
+ logger.warn(`DTO Failure:`, validationResult);
187
+ return next(args);
188
+ }
189
+ const _data = _listener?.(data.data, beep.MemberNumber, beep.MemberName);
190
+ if (_data !== void 0) {
191
+ messagesManager.sendBeep({
192
+ type: `${MOD_DATA.key}_requestResponse`,
193
+ requestId: data.requestId,
194
+ message: data.message,
195
+ data: _data
196
+ }, beep.MemberNumber);
197
+ }
198
+ }
199
+ return next(args);
200
+ });
201
+ return () => {
202
+ rm1();
203
+ rm2();
204
+ };
205
+ }
206
+ onPacket(message, dtoOrListener, listener) {
207
+ return hookFunction("ChatRoomMessage", HookPriority.ADD_BEHAVIOR, async (args, next) => {
208
+ let _listener;
209
+ let dto;
210
+ if (isClassConstructor(dtoOrListener)) {
211
+ dto = dtoOrListener;
212
+ _listener = listener;
213
+ } else {
214
+ _listener = dtoOrListener;
215
+ }
216
+ const _message = args[0];
217
+ const sender = getPlayer(_message.Sender);
218
+ if (!sender) return next(args);
219
+ if (isZoiChatRoomMessage(_message) && _message.Dictionary.msg === message && !sender.IsPlayer()) {
220
+ const validationResult = await validateData(_message.Dictionary.data, dto);
221
+ if (dto && !validationResult.isValid) {
222
+ logger.warn(`DTO Failure:`, validationResult);
223
+ return next(args);
224
+ }
225
+ _listener?.(_message.Dictionary.data, sender);
226
+ }
227
+ return next(args);
228
+ });
229
+ }
230
+ }
231
+ const messagesManager = new MessagesManager();
232
+ export {
233
+ messagesManager
234
+ };
package/dist/modSdk.js ADDED
@@ -0,0 +1,63 @@
1
+ import bcModSdk from "bondage-club-mod-sdk";
2
+ import { MOD_DATA } from "./index";
3
+ import { logger } from "./logging";
4
+ var HookPriority = /* @__PURE__ */ ((HookPriority2) => {
5
+ HookPriority2[HookPriority2["OBSERVE"] = 0] = "OBSERVE";
6
+ HookPriority2[HookPriority2["ADD_BEHAVIOR"] = 1] = "ADD_BEHAVIOR";
7
+ HookPriority2[HookPriority2["MODIFY_BEHAVIOR"] = 5] = "MODIFY_BEHAVIOR";
8
+ HookPriority2[HookPriority2["OVERRIDE_BEHAVIOR"] = 10] = "OVERRIDE_BEHAVIOR";
9
+ HookPriority2[HookPriority2["TOP"] = 100] = "TOP";
10
+ return HookPriority2;
11
+ })(HookPriority || {});
12
+ let modSdk;
13
+ function createModSdk() {
14
+ modSdk = bcModSdk.registerMod({
15
+ name: MOD_DATA.name,
16
+ fullName: MOD_DATA.fullName,
17
+ version: MOD_DATA.version,
18
+ repository: MOD_DATA.repository
19
+ });
20
+ }
21
+ function hookFunction(functionName, priority, hook) {
22
+ if (!modSdk) throw new Error("zois-core is not registered");
23
+ try {
24
+ return modSdk.hookFunction(functionName, priority, hook);
25
+ } catch (e) {
26
+ logger.error(e);
27
+ return () => {
28
+ };
29
+ }
30
+ }
31
+ function patchFunction(functionName, patches) {
32
+ if (!modSdk) throw new Error("zois-core is not registered");
33
+ try {
34
+ modSdk.patchFunction(functionName, patches);
35
+ } catch (e) {
36
+ logger.error(e);
37
+ }
38
+ }
39
+ function callOriginal(target, args, context) {
40
+ if (!modSdk) throw new Error("zois-core is not registered");
41
+ try {
42
+ return modSdk.callOriginal(target, args);
43
+ } catch (e) {
44
+ logger.error(e);
45
+ return void 0;
46
+ }
47
+ }
48
+ function getLoadedMods() {
49
+ return bcModSdk.getModsInfo();
50
+ }
51
+ function findModByName(name) {
52
+ return !!bcModSdk.getModsInfo().find((m) => m.name === name);
53
+ }
54
+ export {
55
+ HookPriority,
56
+ callOriginal,
57
+ createModSdk,
58
+ findModByName,
59
+ getLoadedMods,
60
+ hookFunction,
61
+ modSdk,
62
+ patchFunction
63
+ };
@@ -0,0 +1,16 @@
1
+ import { ShardModule } from "./shardModule";
2
+ class AttributesModule extends ShardModule {
3
+ constructor(attributes) {
4
+ super();
5
+ this.attributes = attributes;
6
+ }
7
+ attributes;
8
+ layoutEffect(context, target) {
9
+ for (const attributeProperty of Object.keys(this.attributes)) {
10
+ target.setAttribute(attributeProperty, this.attributes[attributeProperty]);
11
+ }
12
+ }
13
+ }
14
+ export {
15
+ AttributesModule
16
+ };
@@ -0,0 +1,12 @@
1
+ import { ShardModule } from "./shardModule";
2
+ class CenterModule extends ShardModule {
3
+ overrideContext(context, target) {
4
+ target.style.cssText += "transform: translate(-50%, -50%);";
5
+ context.x = 1e3;
6
+ context.y = 500;
7
+ return context;
8
+ }
9
+ }
10
+ export {
11
+ CenterModule
12
+ };
@@ -0,0 +1,14 @@
1
+ import { ShardModule } from "./shardModule";
2
+ class ClickModule extends ShardModule {
3
+ constructor(callback) {
4
+ super();
5
+ this.callback = callback;
6
+ }
7
+ callback;
8
+ layoutEffect(context, target) {
9
+ target.addEventListener("click", () => this.callback(target));
10
+ }
11
+ }
12
+ export {
13
+ ClickModule
14
+ };
@@ -0,0 +1,37 @@
1
+ import { ShardModule } from "./shardModule";
2
+ function countUp(element, endValue, duration, formattingFunction) {
3
+ if (!element) {
4
+ throw new Error("Element not found");
5
+ }
6
+ let startValue = 0;
7
+ let startTime;
8
+ let animationFrameId;
9
+ const animate = (timestamp) => {
10
+ if (!startTime) startTime = timestamp;
11
+ const elapsed = timestamp - startTime;
12
+ let progress = Math.min(elapsed / duration, 1);
13
+ const easedProgress = progress * (2 - progress);
14
+ const currentValue = parseInt(startValue + (endValue - startValue) * easedProgress);
15
+ element.textContent = typeof formattingFunction === "function" ? formattingFunction(currentValue) : currentValue.toString();
16
+ if (progress < 1) {
17
+ animationFrameId = requestAnimationFrame(animate);
18
+ }
19
+ };
20
+ if (animationFrameId) {
21
+ cancelAnimationFrame(animationFrameId);
22
+ }
23
+ animationFrameId = requestAnimationFrame(animate);
24
+ }
25
+ class CounterUpModule extends ShardModule {
26
+ constructor(props) {
27
+ super();
28
+ this.props = props;
29
+ }
30
+ props;
31
+ effect(context, target) {
32
+ countUp(target, this.props.endValue, this.props.duration, this.props.formattingFunction);
33
+ }
34
+ }
35
+ export {
36
+ CounterUpModule
37
+ };
@@ -0,0 +1,15 @@
1
+ import { addDynamicClass } from "../ui";
2
+ import { ShardModule } from "./shardModule";
3
+ class DynamicClassModule extends ShardModule {
4
+ constructor(style) {
5
+ super();
6
+ this.style = style;
7
+ }
8
+ style;
9
+ layoutEffect(context, target) {
10
+ addDynamicClass(target, this.style);
11
+ }
12
+ }
13
+ export {
14
+ DynamicClassModule
15
+ };
@@ -0,0 +1,9 @@
1
+ export * from "./shardModule";
2
+ export * from "./centerModule";
3
+ export * from "./counterUpModule";
4
+ export * from "./typeModule";
5
+ export * from "./styleModule";
6
+ export * from "./dynamicClassModule";
7
+ export * from "./attributesModule";
8
+ export * from "./clickModule";
9
+ export * from "./multiClickModule";
@@ -0,0 +1,41 @@
1
+ import { ShardModule } from "./shardModule";
2
+ function addMultiClickListener(element, n, callback, timeout = 400) {
3
+ let clickCount = 0;
4
+ let timer = null;
5
+ const handler = () => {
6
+ if (timer) {
7
+ clearTimeout(timer);
8
+ timer = null;
9
+ }
10
+ clickCount++;
11
+ if (clickCount === n) {
12
+ callback();
13
+ clickCount = 0;
14
+ return;
15
+ }
16
+ timer = setTimeout(() => {
17
+ clickCount = 0;
18
+ timer = null;
19
+ }, timeout);
20
+ };
21
+ element.addEventListener("click", handler);
22
+ return () => {
23
+ element.removeEventListener("click", handler);
24
+ if (timer) {
25
+ clearTimeout(timer);
26
+ }
27
+ };
28
+ }
29
+ class MultiClickModule extends ShardModule {
30
+ constructor(props) {
31
+ super();
32
+ this.props = props;
33
+ }
34
+ props;
35
+ effect(context, target) {
36
+ addMultiClickListener(target, this.props.n, this.props.callback);
37
+ }
38
+ }
39
+ export {
40
+ MultiClickModule
41
+ };
@@ -0,0 +1,12 @@
1
+ class ShardModule {
2
+ overrideContext(context, target) {
3
+ return context;
4
+ }
5
+ layoutEffect(context, target) {
6
+ }
7
+ effect(context, target) {
8
+ }
9
+ }
10
+ export {
11
+ ShardModule
12
+ };
@@ -0,0 +1,20 @@
1
+ import { ShardModule } from "./shardModule";
2
+ class StyleModule extends ShardModule {
3
+ constructor(style) {
4
+ super();
5
+ this.style = style;
6
+ }
7
+ style;
8
+ applyStyle(target, style) {
9
+ for (const styleProperty of Object.keys(style)) {
10
+ if (!isNaN(styleProperty) || typeof style[styleProperty] === "function" || typeof style[styleProperty] === "undefined") continue;
11
+ target.style[styleProperty] = style[styleProperty];
12
+ }
13
+ }
14
+ layoutEffect(context, target) {
15
+ this.applyStyle(target, this.style);
16
+ }
17
+ }
18
+ export {
19
+ StyleModule
20
+ };
@@ -0,0 +1,37 @@
1
+ import { ShardModule } from "./shardModule";
2
+ function type(element, duration) {
3
+ if (!element) {
4
+ throw new Error("Element not found");
5
+ }
6
+ const endValue = element.textContent;
7
+ element.textContent = "\xA0";
8
+ element.classList.add("zcCursor");
9
+ let startTime;
10
+ let animationFrameId;
11
+ const animate = (timestamp) => {
12
+ if (!startTime) startTime = timestamp;
13
+ const elapsed = timestamp - startTime;
14
+ let progress = Math.min(elapsed / duration, 1);
15
+ const currentValue = endValue.slice(0, parseInt(endValue.length * progress));
16
+ if (currentValue.trim() !== "") element.textContent = currentValue;
17
+ if (progress < 1) {
18
+ animationFrameId = requestAnimationFrame(animate);
19
+ } else {
20
+ setTimeout(() => element.classList.remove("zcCursor"), duration / endValue.length);
21
+ }
22
+ };
23
+ animationFrameId = requestAnimationFrame(animate);
24
+ }
25
+ class TypeModule extends ShardModule {
26
+ constructor(props) {
27
+ super();
28
+ this.props = props;
29
+ }
30
+ props;
31
+ effect(context, target) {
32
+ type(target, this.props.duration);
33
+ }
34
+ }
35
+ export {
36
+ TypeModule
37
+ };
@@ -0,0 +1,99 @@
1
+ import { MOD_DATA } from "..";
2
+ import { addDynamicClass, autosetFontSize, setFontFamily } from "../ui";
3
+ import { Shard } from "./shard";
4
+ class BackNextButtonShard extends Shard {
5
+ get dynamicClassContainer() {
6
+ return {
7
+ base: {
8
+ display: "flex",
9
+ columnGap: "2vw",
10
+ justifyContent: "center",
11
+ alignItems: "center",
12
+ background: "var(--tmd- element, white)",
13
+ color: "var(--tmd-text, black)",
14
+ border: "2px solid var(--tmd-accent, black)",
15
+ borderRadius: "4px"
16
+ }
17
+ };
18
+ }
19
+ get dynamicClassButton() {
20
+ return {
21
+ base: {
22
+ cursor: "pointer",
23
+ background: "var(--tmd-element, white)",
24
+ color: "var(--tmd-text, black)",
25
+ border: "2px solid var(--tmd-accent, rgb(34, 34, 34))",
26
+ borderRadius: "6px"
27
+ },
28
+ hover: {
29
+ background: "var(--tmd-element-hover, #ebf7fe)",
30
+ borderColor: "var(--tmd-accent-hover, #7dd3fc)",
31
+ color: "var(--tmd-accent-hover, #015a8c)"
32
+ },
33
+ disabled: {
34
+ background: "var(--tmd-element-disabled, #ffa590)",
35
+ pointerEvents: "none"
36
+ }
37
+ };
38
+ }
39
+ generateBody() {
40
+ const { onChange, isDisabled } = this.context;
41
+ const div = document.createElement("div");
42
+ addDynamicClass(div, this.dynamicClassContainer);
43
+ setFontFamily(div, MOD_DATA.fontFamily);
44
+ let currentIndex = this.context.currentIndex;
45
+ let items = this.context.items;
46
+ const updateClasses = () => {
47
+ if (currentIndex === 0 || typeof isDisabled === "function" && isDisabled(items[currentIndex - 1][1])) backBtn.disabled = true;
48
+ else backBtn.disabled = false;
49
+ if (currentIndex === items.length - 1 || typeof isDisabled === "function" && isDisabled(items[currentIndex + 1][1])) nextBtn.disabled = true;
50
+ else nextBtn.disabled = false;
51
+ ;
52
+ };
53
+ const backBtn = document.createElement("button");
54
+ backBtn.style.cssText = `
55
+ position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1;
56
+ height: 140%; background-image: url("Icons/Prev.png"); background-size: 100%;
57
+ `;
58
+ addDynamicClass(backBtn, this.dynamicClassButton);
59
+ backBtn.addEventListener("click", () => {
60
+ if (currentIndex === 0) return backBtn.classList.add("zcDisabled");
61
+ if (typeof isDisabled === "function" && isDisabled(items[currentIndex - 1][1])) return backBtn.classList.add("zcDisabled");
62
+ currentIndex--;
63
+ text.textContent = items[currentIndex][0];
64
+ if (typeof onChange === "function") onChange(items[currentIndex][1]);
65
+ updateClasses();
66
+ });
67
+ const nextBtn = document.createElement("button");
68
+ nextBtn.style.cssText = `
69
+ position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1;
70
+ height: 140%; background-image: url("Icons/Next.png"); background-size: 100%;
71
+ `;
72
+ addDynamicClass(nextBtn, this.dynamicClassButton);
73
+ nextBtn.addEventListener("click", () => {
74
+ if (currentIndex === items.length - 1) return nextBtn.classList.add("zcDisabled");
75
+ if (typeof isDisabled === "function" && isDisabled(items[currentIndex + 1][1])) return nextBtn.classList.add("zcDisabled");
76
+ currentIndex++;
77
+ text.textContent = items[currentIndex][0];
78
+ if (typeof onChange === "function") onChange(items[currentIndex][1]);
79
+ updateClasses();
80
+ });
81
+ updateClasses();
82
+ const text = document.createElement("b");
83
+ text.textContent = items[currentIndex][0];
84
+ div.append(backBtn, text, nextBtn);
85
+ return {
86
+ base: div,
87
+ backButton: backBtn,
88
+ nextButton: nextBtn,
89
+ text
90
+ };
91
+ }
92
+ update() {
93
+ super.update();
94
+ autosetFontSize(this.body.base);
95
+ }
96
+ }
97
+ export {
98
+ BackNextButtonShard
99
+ };