zois-core 1.0.7 → 1.0.9

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z"></path></svg>
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import s from"./styles.css";import{findModByName as u,registerMod as l}from"./modsApi";import{initVirtualDOM as f}from"./popups";let g;function c(e){if(!window.ZOISCORE){const t=document.createElement("style");t.innerHTML=s,document.head.append(t),f(),window.ZOISCORE=!0}g={...e},l()}function d(e){return new Promise(t=>setTimeout(t,e))}async function y(e,t=()=>!1){for(;!e();){if(t())return!1;await d(10)}return!0}function M(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function b(e,t){const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n++){const i=parseInt(r[n]||"0",10),a=parseInt(o[n]||"0",10);if(i>a)return!0;if(i<a)return!1}return!1}function w(e,t){return!e&&!t||!e&&t==="Default"||!t&&e==="Default"||e==="Default"&&Array.isArray(t)&&t.filter(r=>r==="Default").length===t.length||t==="Default"&&Array.isArray(e)&&e.filter(r=>r==="Default").length===e.length?!0:JSON.stringify(e)===JSON.stringify(t)}function x(e){return typeof e=="string"?Math.round(new TextEncoder().encode(e).byteLength/100)/10:Math.round(new TextEncoder().encode(JSON.stringify(e)).byteLength/100)/10}function D(e){if(e)return ChatRoomCharacter.find(t=>t.MemberNumber==e||t.Name.toLowerCase()===e||t.Nickname?.toLowerCase()===e)}function N(e){return CharacterNickname(e)}function C(){if(!u("Themed"))return null;const e=JSON.parse(LZString.decompressFromBase64(Player.ExtensionSettings.Themed??""));return!e?.GlobalModule?.themedEnabled||!e?.GlobalModule?.doVanillaGuiOverhaul?null:e.ColorsModule}export{g as MOD_DATA,w as colorsEqual,N as getNickname,D as getPlayer,M as getRandomNumber,x as getSizeInKbytes,C as getThemedColorsModule,b as isVersionNewer,c as registerCore,d as sleep,y as waitFor};
1
+ import s from"./styles.css";import{findModByName as u,registerMod as l}from"./modsApi";import{initVirtualDOM as f,useToastsStore as d,useDialogStore as g}from"./popups";import{version as E}from"../package.json";let m;function M(e){if(!window.ZOISCORE){const t=document.createElement("style");t.innerHTML=s,document.head.append(t),window.ZOISCORE=Object.freeze({loaded:!0,useToastsStore:d,useDialogStore:g}),f()}m={...e},l()}function h(e){return new Promise(t=>setTimeout(t,e))}async function b(e,t=()=>!1){for(;!e();){if(t())return!1;await h(10)}return!0}function x(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function D(e,t){const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n++){const i=parseInt(r[n]||"0",10),a=parseInt(o[n]||"0",10);if(i>a)return!0;if(i<a)return!1}return!1}function w(e,t){return!e&&!t||!e&&t==="Default"||!t&&e==="Default"||e==="Default"&&Array.isArray(t)&&t.filter(r=>r==="Default").length===t.length||t==="Default"&&Array.isArray(e)&&e.filter(r=>r==="Default").length===e.length?!0:JSON.stringify(e)===JSON.stringify(t)}function N(e){return typeof e=="string"?Math.round(new TextEncoder().encode(e).byteLength/100)/10:Math.round(new TextEncoder().encode(JSON.stringify(e)).byteLength/100)/10}function O(e){if(e)return ChatRoomCharacter.find(t=>t.MemberNumber==e||t.Name.toLowerCase()===e||t.Nickname?.toLowerCase()===e)}function C(e){return CharacterNickname(e)}function S(){if(!u("Themed"))return null;const e=JSON.parse(LZString.decompressFromBase64(Player.ExtensionSettings.Themed??""));return!e?.GlobalModule?.themedEnabled||!e?.GlobalModule?.doVanillaGuiOverhaul?null:e.ColorsModule}export{m as MOD_DATA,w as colorsEqual,C as getNickname,O as getPlayer,x as getRandomNumber,N as getSizeInKbytes,S as getThemedColorsModule,D as isVersionNewer,M as registerCore,h as sleep,E as version,b as waitFor};
package/dist/messaging.js CHANGED
@@ -1 +1 @@
1
- import{getRandomNumber as p,MOD_DATA as o}from"./index";const i=new Map,u=new Map;function y(t){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),e.style.background=o.chatMessageBackground??"#55edc095",e.style.color=o.chatMessageColor??"black",e.style.margin="0.15em 0",typeof t=="string"?e.textContent=t:e.appendChild(t),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}function C(t,e=void 0,n=[]){if(!t||!ServerPlayerIsInChatRoom())return;const s=CharacterPronounDescription(Player)==="She/Her",r=s?"Her":"His",a=s?"Her":"Him",c=s?"Herself":"Himself",l=s?"She":"He";t=t.replaceAll("<Possessive>",r).replaceAll("<possessive>",r.toLocaleLowerCase()).replaceAll("<Intensive>",a).replaceAll("<intensive>",a.toLocaleLowerCase()).replaceAll("<SelfIntensive>",c).replaceAll("<selfIntensive>",c.toLocaleLowerCase()).replaceAll("<Pronoun>",l).replaceAll("<pronoun>",l.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"LittlishClub_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": LittlishClub_CUSTOM_ACTION',Text:t},...n]})}function d(t,e=null,n=null){const s={Content:o.key,Dictionary:{msg:t},Type:"Hidden"};e&&(s.Dictionary.data=e),n&&(s.Target=n),ServerSend("ChatRoomChat",s)}function f(t,e){const n={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({type:o.key,...t})};ServerSend("AccountBeep",n)}function h(t,e,n){return new Promise((s,r)=>{const a=parseInt(`${Date.now()}${p(1e3,1e4)}`);i.set(a,{message:t,data:e,target:n,resolve:s,reject:r}),d("request",{requestId:a,message:t,data:e},n),setTimeout(()=>{i.delete(a),s({isError:!0})},6e3)})}function m(t,e){const n=i.get(t);n&&n.resolve({data:e})}function M(t,e,n,s){const r=u.get(e);if(!r)return;const a=r(n,s);a!==void 0&&d("requestResponse",{requestId:t,message:e,data:a},s.MemberNumber)}function T(t,e){u.set(t,e)}export{T as addRequestListener,C as chatSendActionMessage,f as chatSendBeepMessage,y as chatSendLocalMessage,d as chatSendModMessage,M as handleRequest,m as handleRequestResponse,h as sendRequest};
1
+ import{getPlayer as g,MOD_DATA as i}from"./index";import{hookFunction as y,HookPriority as C}from"./modsApi";const d=new Map,l=new Map;function v(o,t){const e=d.get(o);e&&e.resolve({data:t})}function q(o,t,e,n){const s=l.get(t);if(!s)return;const a=s(e,n);a!==void 0&&u.sendPacket("requestResponse",{requestId:o,message:t,data:a},n.MemberNumber)}function T(o,t){const e=d.get(o);e&&e.resolve({data:t})}function P(o,t,e,n){const s=l.get(t);if(console.log(s),!s)return;const a=s(e,n);a!==void 0&&u.sendBeep({type:`${i.key}_requestResponse`,requestId:o,message:t,data:a},n)}class R{sendBeep(t,e){const n={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({...t})};ServerSend("AccountBeep",n)}sendPacket(t,e,n){const s={Content:i.key,Dictionary:{msg:t},Type:"Hidden"};e&&(s.Dictionary.data=e),n&&(s.Target=n),ServerSend("ChatRoomChat",s)}sendAction(t,e=void 0,n=[]){if(!t||!ServerPlayerIsInChatRoom())return;const s=CharacterPronounDescription(Player)==="She/Her",a=s?"Her":"His",r=s?"Her":"Him",c=s?"Herself":"Himself",p=s?"She":"He";t=t.replaceAll("<Possessive>",a).replaceAll("<possessive>",a.toLocaleLowerCase()).replaceAll("<Intensive>",r).replaceAll("<intensive>",r.toLocaleLowerCase()).replaceAll("<SelfIntensive>",c).replaceAll("<selfIntensive>",c.toLocaleLowerCase()).replaceAll("<Pronoun>",p).replaceAll("<pronoun>",p.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"ZC_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION',Text:t},...n]})}sendRequest({message:t,data:e={},target:n,type:s="packet"}){const a=crypto.randomUUID();return new Promise((r,c)=>{d.set(a,{message:t,data:e,target:n,resolve:r,reject:c}),s==="packet"?u.sendPacket("request",{requestId:a,message:t,data:e},n):u.sendBeep({type:`${i.key}_request`,requestId:a,message:t,data:e},n),setTimeout(()=>{d.delete(a),r({isError:!0})},6e3)})}sendLocal(t){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),e.style.background=i.chatMessageBackground??"#55edc095",e.style.color=i.chatMessageColor??"black",e.style.margin="0.15em 0",typeof t=="string"?e.textContent=t:e.appendChild(t),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}sendChat(t){ServerSend("ChatRoomChat",{Type:"Chat",Content:t})}onRequest(t,e){l.set(t,e)}onPacket(t,e){y("ChatRoomMessage",C.ADD_BEHAVIOR,(n,s)=>{const a=n[0],r=g(a.Sender);return r&&a.Content===i.key&&a.Dictionary.msg===t&&!r.IsPlayer()&&e(a.Dictionary.data,r),s(n)})}}const u=new R;export{P as handleBeepRequest,T as handleBeepRequestResponse,q as handlePacketRequest,v as handlePacketRequestResponse,u as messagesManager};
package/dist/modsApi.js CHANGED
@@ -1 +1 @@
1
- import a from"bondage-club-mod-sdk";import{getPlayer as f,MOD_DATA as s}from"./index";import{getCurrentSubscreen as u}from"./ui";import{handleRequest as m,handleRequestResponse as p}from"./messaging";var g=(e=>(e[e.OBSERVE=0]="OBSERVE",e[e.ADD_BEHAVIOR=1]="ADD_BEHAVIOR",e[e.MODIFY_BEHAVIOR=5]="MODIFY_BEHAVIOR",e[e.OVERRIDE_BEHAVIOR=10]="OVERRIDE_BEHAVIOR",e[e.TOP=100]="TOP",e))(g||{});let r;function A(){r=a.registerMod({name:s.name,fullName:s.fullName,version:s.version,repository:s.repository}),c("GameKeyDown",1,(t,n)=>(CommonKey.IsPressed(t[0],"Escape")&&u()&&u().exit(),n(t))),c("ChatRoomMessage",1,(t,n)=>{const o=t[0],i=f(o.Sender);if(!i)return n(t);if(o.Content===s.key&&!i.IsPlayer()){const d=o.Dictionary.msg,e=o.Dictionary.data;if(d==="request"){if(typeof e.requestId!="number"||typeof e.message!="string")return;m(e.requestId,e.message,e.data,i)}if(d==="requestResponse"){if(typeof e.requestId!="number")return;p(e.requestId,e.data)}}})}function c(t,n,o){if(!r)throw new Error("zois-core is not registered");return r.hookFunction(t,n,o)}function O(t,n){if(!r)throw new Error("zois-core is not registered");r.patchFunction(t,n)}function T(t,n,o){if(!r)throw new Error("zois-core is not registered");return r.callOriginal(t,n)}function x(){return a.getModsInfo()}function F(t){return!!a.getModsInfo().find(n=>n.name===t)}export{g as HookPriority,T as callOriginal,F as findModByName,x as getLoadedMods,c as hookFunction,O as patchFunction,A as registerMod};
1
+ import d from"bondage-club-mod-sdk";import{getPlayer as p,MOD_DATA as s}from"./index";import{getCurrentSubscreen as c}from"./ui";import{handleBeepRequest as f,handleBeepRequestResponse as m,handlePacketRequest as g,handlePacketRequestResponse as l}from"./messaging";var y=(t=>(t[t.OBSERVE=0]="OBSERVE",t[t.ADD_BEHAVIOR=1]="ADD_BEHAVIOR",t[t.MODIFY_BEHAVIOR=5]="MODIFY_BEHAVIOR",t[t.OVERRIDE_BEHAVIOR=10]="OVERRIDE_BEHAVIOR",t[t.TOP=100]="TOP",t))(y||{});let i;function O(){i=d.registerMod({name:s.name,fullName:s.fullName,version:s.version,repository:s.repository}),a("GameKeyDown",1,(e,n)=>(CommonKey.IsPressed(e[0],"Escape")&&c()&&c().exit(),n(e))),a("ChatRoomMessage",1,(e,n)=>{const o=e[0],r=p(o.Sender);if(!r)return n(e);if(o.Content===s.key&&!r.IsPlayer()){const u=o.Dictionary.msg,t=o.Dictionary.data;if(u==="request"){if(typeof t.requestId!="string"||typeof t.message!="string")return;g(t.requestId,t.message,t.data,r)}if(u==="requestResponse"){if(typeof t.requestId!="string")return;l(t.requestId,t.data)}}return n(e)}),a("ServerAccountBeep",1,(e,n)=>{const o=e[0];if(o.BeepType!=="Leash")return n(e);let r;try{r=JSON.parse(o.Message)}catch{return n(e)}if(r.type===`${s.key}_request`){if(typeof r.requestId!="string"||typeof r.message!="string")return;f(r.requestId,r.message,r.data,o.MemberNumber)}if(r.type===`${s.key}_requestResponse`){if(typeof r.requestId!="string")return;m(r.requestId,r.data)}return n(e)})}function a(e,n,o){if(!i)throw new Error("zois-core is not registered");return i.hookFunction(e,n,o)}function B(e,n){if(!i)throw new Error("zois-core is not registered");i.patchFunction(e,n)}function T(e,n,o){if(!i)throw new Error("zois-core is not registered");return i.callOriginal(e,n)}function S(){return d.getModsInfo()}function F(e){return!!d.getModsInfo().find(n=>n.name===e)}export{y as HookPriority,T as callOriginal,F as findModByName,S as getLoadedMods,a as hookFunction,B as patchFunction,O as registerMod};
package/dist/popups.js CHANGED
@@ -1 +1 @@
1
- import{getRelativeWidth as D,getRelativeX as x,getRelativeY as z}from"./ui";import{MOD_DATA as T}from"./index";import{useState as m,useEffect as g}from"react";import P from"react-dom/client";import{create as y}from"zustand";import C from"./assets/errorWarningIcon.svg";import E from"@/assets/infoIcon.svg";import M from"@/assets/successIcon.svg";import{Fragment as h,jsx as n,jsxs as d}from"react/jsx-runtime";const u=y(t=>({toasts:[],addToast:e=>t(o=>({toasts:[...o.toasts,e]})),removeToast:e=>t(o=>({toasts:o.toasts.filter(i=>i.id!==e)})),clearToasts:()=>t({toasts:[]})})),v=y(t=>({dialog:null,setDialog:e=>t({dialog:e}),clearDialog:()=>t({dialog:null})}));function k({children:t}){const[e,o]=m({}),i=u(s=>s.clearToasts);return g(()=>{const s=()=>{o({fontFamily:T.fontFamily??"sans-serif",top:z(5)+"px",left:x(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),n("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(i,300)},children:t})}function I({title:t,message:e,type:o,duration:i,id:s}){const[c,a]=m({}),[r,l]=m(!1);return g(()=>{const p=()=>{const S=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,f=Math.min(S,b)/100;a({position:"relative",width:"100%",borderRadius:"0.1em",fontSize:3*f+"px",padding:1.5*f+"px"})};window.addEventListener("resize",p),p();const w=setTimeout(()=>l(!0),i);return()=>{clearTimeout(w),window.removeEventListener("resize",p)}},[]),d("div",{className:`zcToast ${r&&"exiting"}`,"data-zc-toast-type":o,style:c,children:[d("div",{style:{display:"flex",gap:"1vw",position:"relative",zIndex:5},children:[n("img",{src:o==="info"?E:o==="success"?M:C,style:{width:"2vw",gap:"0.5em"}}),d("div",{children:[t&&e&&d(h,{children:[n("p",{children:t}),n("p",{style:{color:o==="info"?"#b8b8ff":o==="success"?"#c7f9c7":o==="error"?"#f8bcbc":"#ffeec5",fontSize:"70%"},children:e})]}),(!t&&e||t&&!e)&&n("p",{style:{position:"relative",zIndex:5},children:t||e})]})]}),n("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${i}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%"}})]})}function O({dialog:t}){const e=v(a=>a.clearDialog),[o,i]=m({}),[s,c]=m([]);return g(()=>{const a=()=>{const r=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,p=Math.min(r,l)/100;i({width:D(t.width),position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(36, 36, 36, 0.96)",zIndex:20,fontFamily:T.fontFamily??"sans-serif",border:"none",padding:2*p})};return window.addEventListener("resize",a),a(),()=>{window.removeEventListener("resize",a)}},[]),d("dialog",{open:Object.keys(o).length>0,"data-zc-dialog-type":t.type,style:o,children:[t.title&&n("p",{style:{position:"absolute",top:0,left:0,fontWeight:"bold",color:"white",fontSize:"clamp(6px, 2vw, 24px)",padding:"0.25em",background:"#2d2d2d",width:"100%"},children:t.title}),n("p",{style:{padding:"1em",marginTop:"2vw",fontSize:"clamp(6px, 2vw, 24px)",color:"white"},children:t.body}),n("div",{style:{display:"flex",flexDirection:t.buttons.direction,justifyContent:"center",gap:"0.5vw"},children:t.buttons?.list?.map((a,r)=>n("button",{className:"zcDialogBtn","data-zc-picked":s.includes(r),style:{width:"100%",position:"relative"},onClick:()=>{t.type==="choice_one"?(e(),t.promise.resolve(a.value)):s.includes(r)?c(s.filter(l=>l!==r)):c([...s,r])},children:a.text}))}),t.type==="choice_multiple"&&n("button",{style:{cursor:"pointer",color:"white",background:"#4d4d4d",border:"none",marginTop:"1vw",fontSize:"clamp(8px,2.5vw,28px)",padding:"0.2em",borderRadius:"4px"},onClick:()=>{e(),t.promise.resolve(t.buttons.list.filter((a,r)=>s.includes(r)).map(a=>a.value))},children:"Confirm"})]})}class R{generateToastId(){const{toasts:e}=u.getState();return`${Date.now()}:${e.length+1}`}process({title:e,message:o,duration:i,type:s,id:c}){const{addToast:a,removeToast:r}=u.getState();a({id:c,title:e,message:o,duration:i,type:s}),setTimeout(()=>r(c),i+300)}info({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"info",id:s})}success({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"success",id:s})}warn({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"warning",id:s})}error({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"error",id:s})}}class L{showDialog({type:e,title:o,body:i,buttons:s,width:c}){const{setDialog:a}=v.getState();return new Promise((r,l)=>{a({width:c,type:e,title:o,body:i,buttons:s,promise:{resolve:r,reject:l}})})}}function N(){const t=u(o=>o.toasts),e=v(o=>o.dialog);return d(h,{children:[n(k,{children:t.map(({title:o,message:i,type:s,duration:c,id:a})=>n(I,{id:a,title:o,message:i,type:s,duration:c},a))}),e&&n(O,{dialog:e})]})}class W extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",4e3)}}function G(){customElements.define("zc-virtual-dom",W);const t=document.createElement("zc-virtual-dom");document.body.append(t),P.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(n(N,{}))}const K=new R,Q=new L;export{Q as dialogsManager,G as initVirtualDOM,K as toastsManager};
1
+ import{getRelativeWidth as y,getRelativeX as D,getRelativeY as b}from"./ui";import{MOD_DATA as v}from"./index";import{useState as m,useEffect as u}from"react";import x from"react-dom/client";import{create as w}from"zustand";import O from"./assets/warningIcon.svg";import z from"./assets/errorIcon.svg";import C from"./assets/infoIcon.svg";import E from"./assets/successIcon.svg";import{Fragment as f,jsx as a,jsxs as d}from"react/jsx-runtime";function P({children:o}){const[e,t]=m({}),i=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return u(()=>{const s=()=>{t({fontFamily:v.fontFamily??"sans-serif",bottom:b(5)+"px",left:D(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),a("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(i,300)},children:o})}function I({title:o,message:e,type:t,duration:i,id:s}){const[c,n]=m({}),[r,l]=m(!1);return u(()=>{const p=()=>{const T=MainCanvas.canvas.clientWidth,h=MainCanvas.canvas.clientHeight,g=Math.min(T,h)/100;n({position:"relative",width:"100%",borderRadius:"0.1em",fontSize:3*g+"px",padding:1.5*g+"px"})};window.addEventListener("resize",p),p();const S=setTimeout(()=>l(!0),i);return()=>{clearTimeout(S),window.removeEventListener("resize",p)}},[]),d("div",{className:`zcToast ${r&&"exiting"}`,"data-zc-toast-type":t,style:c,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[t==="spinner"?a("div",{className:"zcSpinner",style:{width:"2vw",height:"2vw"}}):a("img",{src:t==="info"?C:t==="success"?E:t==="warning"?O:z,style:{width:"2vw"}}),d("div",{children:[o&&e&&d(f,{children:[a("p",{children:o}),a("p",{style:{color:t==="info"?"#b8b8ff":t==="success"?"#c7f9c7":t==="error"?"#f8bcbc":"#ffeec5",fontSize:"70%"},children:e})]}),(!o&&e||o&&!e)&&a("p",{style:{position:"relative",zIndex:5},children:o||e})]})]}),a("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${i}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%"}})]})}function R({dialog:o}){const e=window.ZOISCORE.useDialogStore(n=>n.clearDialog),[t,i]=m({}),[s,c]=m([]);return u(()=>{const n=()=>{const r=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,p=Math.min(r,l)/100;i({width:y(o.width),position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(36, 36, 36, 0.96)",zIndex:20,fontFamily:v.fontFamily??"sans-serif",border:"none",padding:2*p})};return window.addEventListener("resize",n),n(),()=>{window.removeEventListener("resize",n)}},[]),d("dialog",{open:Object.keys(t).length>0,"data-zc-dialog-type":o.type,style:t,children:[o.title&&a("p",{style:{position:"absolute",top:0,left:0,fontWeight:"bold",color:"white",fontSize:"clamp(6px, 2vw, 24px)",padding:"0.25em",background:"#2d2d2d",width:"100%"},children:o.title}),a("p",{style:{padding:"1em",marginTop:"2vw",fontSize:"clamp(6px, 2vw, 24px)",color:"white"},children:o.body}),a("div",{style:{display:"flex",flexDirection:o.buttons.direction,justifyContent:"center",gap:"0.5vw"},children:o.buttons?.list?.map((n,r)=>a("button",{className:"zcDialogBtn","data-zc-picked":s.includes(r),style:{width:"100%",position:"relative"},onClick:()=>{o.type==="choice_one"?(e(),o.promise.resolve(n.value)):s.includes(r)?c(s.filter(l=>l!==r)):c([...s,r])},children:n.text}))}),o.type==="choice_multiple"&&a("button",{style:{cursor:"pointer",color:"white",background:"#4d4d4d",border:"none",marginTop:"1vw",fontSize:"clamp(8px,2.5vw,28px)",padding:"0.2em",borderRadius:"4px"},onClick:()=>{e(),o.promise.resolve(o.buttons.list.filter((n,r)=>s.includes(r)).map(n=>n.value))},children:"Confirm"})]})}class M{generateToastId(){const{toasts:e}=window.ZOISCORE.useToastsStore.getState();return`${Date.now()}:${e.length+1}`}process({title:e,message:t,duration:i,type:s,id:c}){const{addToast:n,removeToast:r}=window.ZOISCORE.useToastsStore.getState();n({id:c,title:e,message:t,duration:i,type:s}),setTimeout(()=>r(c),i+300)}info({title:e,message:t,duration:i}){const s=this.generateToastId();this.process({title:e,message:t,duration:i,type:"info",id:s})}success({title:e,message:t,duration:i}){const s=this.generateToastId();this.process({title:e,message:t,duration:i,type:"success",id:s})}warn({title:e,message:t,duration:i}){const s=this.generateToastId();this.process({title:e,message:t,duration:i,type:"warning",id:s})}error({title:e,message:t,duration:i}){const s=this.generateToastId();this.process({title:e,message:t,duration:i,type:"error",id:s})}spinner({title:e,message:t}){const i=this.generateToastId();return this.process({title:e,message:t,duration:1e6,type:"spinner",id:i}),i}removeSpinner(e){const{removeToast:t}=window.ZOISCORE.useToastsStore.getState();t(e)}}class k{showDialog({type:e,title:t,body:i,buttons:s,width:c}){const{setDialog:n}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,l)=>{n({width:c,type:e,title:t,body:i,buttons:s,promise:{resolve:r,reject:l}})})}}function L(){const o=window.ZOISCORE.useToastsStore(t=>t.toasts),e=window.ZOISCORE.useDialogStore(t=>t.dialog);return d(f,{children:[a(P,{children:o.map(({title:t,message:i,type:s,duration:c,id:n})=>a(I,{id:n,title:t,message:i,type:s,duration:c},n))}),e&&a(R,{dialog:e})]})}class N extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",4e3)}}const Y=w(o=>({toasts:[],addToast:e=>o(t=>({toasts:[...t.toasts,e]})),removeToast:e=>o(t=>({toasts:t.toasts.filter(i=>i.id!==e)})),clearToasts:()=>o({toasts:[]})})),G=w(o=>({dialog:null,setDialog:e=>o({dialog:e}),clearDialog:()=>o({dialog:null})}));function K(){customElements.define("zc-virtual-dom",N);const o=document.createElement("zc-virtual-dom");document.body.append(o),x.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(a(L,{}))}const Q=new M,U=new k;export{U as dialogsManager,K as initVirtualDOM,Q as toastsManager,G as useDialogStore,Y as useToastsStore};
package/dist/styles.css CHANGED
@@ -1 +1 @@
1
- *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;min-height:100%;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:10}.zcToast[data-zc-toast-type=info]{background:#5050df}.zcToast[data-zc-toast-type=success]{background:#42f08f}.zcToast[data-zc-toast-type=warning]{background:#ffdb82}.zcToast[data-zc-toast-type=error]{background:#d42e6b}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{animation:zcSlideInFromLeft .3s ease-out forwards}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast[data-zc-toast-type=info] .zcToast-ProgressBar{background:#6767ea}.zcToast[data-zc-toast-type=success] .zcToast-ProgressBar{background:#2fd178}.zcToast[data-zc-toast-type=warning] .zcToast-ProgressBar{background:#e1bd62}.zcToast[data-zc-toast-type=error] .zcToast-ProgressBar{background:#b7285c}.zcToast p{color:#fff}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn:before{content:"";position:absolute;left:1vw;top:50%;transform:translateY(-50%);border:2px solid white;width:.5em;aspect-ratio:1/1;border-radius:50%}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn[data-zc-picked=true]:before{background:#fff}.zcDialogBtn{cursor:pointer;background:#ffffff17;border:none;font-size:clamp(6px,2vw,24px);color:#fff;padding:.2em;border-radius:.5em}.zcDialogBtn:hover{background:#ffffff24}.zcDisabled{pointer-events:none;opacity:.6}
1
+ *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;min-height:100%;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcBackNextButton-btnDisabled{background:#ffa590;pointer-events:none}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:10}.zcToast[data-zc-toast-type=info],.zcToast[data-zc-toast-type=spinner]{background:#5050df}.zcToast[data-zc-toast-type=success]{background:#42f08f}.zcToast[data-zc-toast-type=warning]{background:#ffdb82}.zcToast[data-zc-toast-type=error]{background:#d42e6b}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{animation:zcSlideInFromLeft .3s ease-out forwards}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast[data-zc-toast-type=info] .zcToast-ProgressBar{background:#6767ea}.zcToast[data-zc-toast-type=success] .zcToast-ProgressBar{background:#2fd178}.zcToast[data-zc-toast-type=warning] .zcToast-ProgressBar{background:#e1bd62}.zcToast[data-zc-toast-type=error] .zcToast-ProgressBar{background:#b7285c}.zcToast p{color:#fff}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn:before{content:"";position:absolute;left:1vw;top:50%;transform:translateY(-50%);border:2px solid white;width:.5em;aspect-ratio:1/1;border-radius:50%}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn[data-zc-picked=true]:before{background:#fff}.zcDialogBtn{cursor:pointer;background:#ffffff17;border:none;font-size:clamp(6px,2vw,24px);color:#fff;padding:.2em;border-radius:.5em}.zcDialogBtn:hover{background:#ffffff24}@keyframes zcSpin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.zcSpinner{box-sizing:border-box;border:2px solid;border-radius:100%;border-color:#fff;border-right-color:#5050df;animation:zcSpin .65s linear infinite}.zcDisabled{pointer-events:none;opacity:.6}
@@ -8,6 +8,7 @@ interface ModData {
8
8
  chatMessageColor?: string;
9
9
  fontFamily?: string;
10
10
  }
11
+ export { version } from "../package.json";
11
12
  export declare let MOD_DATA: ModData;
12
13
  export declare function registerCore(modData: ModData): void;
13
14
  export declare function sleep(ms: number): Promise<() => {}>;
@@ -19,4 +20,3 @@ export declare function getSizeInKbytes(b: any): number;
19
20
  export declare function getPlayer(value: string | number): Character;
20
21
  export declare function getNickname(target: Character): string;
21
22
  export declare function getThemedColorsModule(): any;
22
- export {};
@@ -0,0 +1,25 @@
1
+ interface RequestResponse<T> {
2
+ data?: T;
3
+ isError: boolean;
4
+ }
5
+ export declare function handlePacketRequestResponse(requestId: string, data: any): void;
6
+ export declare function handlePacketRequest(requestId: string, message: string, _data: any, sender: Character): void;
7
+ export declare function handleBeepRequestResponse(requestId: string, data: any): void;
8
+ export declare function handleBeepRequest(requestId: string, message: string, _data: any, senderNumber: number): void;
9
+ declare class MessagesManager {
10
+ sendBeep<T>(data: T, targetId: number): void;
11
+ sendPacket<T>(msg: string, _data?: T, targetNumber?: number): void;
12
+ sendAction(msg: string, target?: undefined | number, dictionary?: ChatMessageDictionaryEntry[]): void;
13
+ sendRequest<T>({ message, data, target, type }: {
14
+ message: string;
15
+ data?: unknown;
16
+ target: number;
17
+ type: "packet" | "beep";
18
+ }): Promise<RequestResponse<T>>;
19
+ sendLocal(message: string | Node): void;
20
+ sendChat(message: string): void;
21
+ onRequest(message: string, listener: (data: any, sender: Character | number) => unknown): void;
22
+ onPacket(message: string, listener: (data: any, sender: Character) => void): void;
23
+ }
24
+ export declare const messagesManager: MessagesManager;
25
+ export {};
@@ -2,7 +2,7 @@ interface ToastProps {
2
2
  id: string;
3
3
  title?: string;
4
4
  message: string;
5
- type: "info" | "warning" | "error" | "success";
5
+ type: "info" | "warning" | "error" | "success" | "spinner";
6
6
  duration: number;
7
7
  }
8
8
  interface DialogProps {
@@ -23,16 +23,31 @@ interface DialogProps {
23
23
  };
24
24
  }
25
25
  declare class ToastsManager {
26
- generateToastId(): string;
27
- process({ title, message, duration, type, id }: ToastProps): void;
26
+ private generateToastId;
27
+ private process;
28
28
  info({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
29
29
  success({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
30
30
  warn({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
31
31
  error({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
32
+ spinner({ title, message }: Omit<ToastProps, "type" | "id" | "duration">): string;
33
+ removeSpinner(id: string): void;
32
34
  }
33
35
  declare class DialogsManager {
34
36
  showDialog({ type, title, body, buttons, width }: Omit<DialogProps, "promise">): Promise<unknown>;
35
37
  }
38
+ export interface ToastsStore {
39
+ toasts: ToastProps[];
40
+ addToast: (toast: ToastProps) => void;
41
+ removeToast: (id: string) => void;
42
+ clearToasts: () => void;
43
+ }
44
+ export interface DialogStore {
45
+ dialog: DialogProps | null;
46
+ setDialog: (props: DialogProps) => void;
47
+ clearDialog: () => void;
48
+ }
49
+ export declare const useToastsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ToastsStore>>;
50
+ export declare const useDialogStore: import("zustand").UseBoundStore<import("zustand").StoreApi<DialogStore>>;
36
51
  export declare function initVirtualDOM(): void;
37
52
  export declare const toastsManager: ToastsManager;
38
53
  export declare const dialogsManager: DialogsManager;
@@ -89,6 +89,7 @@ interface CreateImageArgs {
89
89
  y: number;
90
90
  width: number;
91
91
  anchor?: Anchor;
92
+ place?: boolean;
92
93
  }
93
94
  interface CreateBackNextButtonArgs {
94
95
  x: number;
@@ -99,8 +100,9 @@ interface CreateBackNextButtonArgs {
99
100
  currentIndex: number;
100
101
  isBold?: boolean;
101
102
  anchor?: Anchor;
103
+ place?: boolean;
102
104
  onChange?: (value: any) => void;
103
- isDisabled?: () => boolean;
105
+ isDisabled?: (value: any) => boolean;
104
106
  }
105
107
  interface CreateTabArgs {
106
108
  x: number;
@@ -109,7 +111,9 @@ interface CreateTabArgs {
109
111
  tabs: {
110
112
  name: string;
111
113
  load?: () => void;
114
+ unload?: () => void;
112
115
  run?: () => void;
116
+ exit?: () => void;
113
117
  }[];
114
118
  currentTabName: string;
115
119
  anchor?: Anchor;
@@ -134,17 +138,17 @@ export declare function setFontSize(element: HTMLElement, targetFontSize: number
134
138
  export declare function setFontFamily(element: HTMLElement, fontFamily?: string): void;
135
139
  export declare function setPadding(element: HTMLElement, targetPadding: number): void;
136
140
  export declare function autosetFontSize(element: HTMLElement): void;
137
- export declare function loadSubscreen(subscreen: BaseSubscreen): void;
138
141
  export declare function setPreviousSubscreen(): void;
139
142
  export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
140
143
  export declare function getCurrentSubscreen(): BaseSubscreen;
141
144
  export declare abstract class BaseSubscreen {
142
145
  private htmlElements;
143
146
  private resizeEventListeners;
144
- private tabRunHandler;
147
+ private tabHandlers;
145
148
  get currentSubscreen(): BaseSubscreen | null;
149
+ get previousSubscreen(): BaseSubscreen | null;
146
150
  get name(): string;
147
- run(): void;
151
+ run?(): void;
148
152
  load?(): void;
149
153
  unload?(): void;
150
154
  click?(): void;
@@ -158,8 +162,8 @@ export declare abstract class BaseSubscreen {
158
162
  createCheckbox({ text, x, y, isChecked, width, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLDivElement;
159
163
  createScrollView({ scroll, x, y, width, height, anchor }: CreateScrollViewArgs): HTMLDivElement;
160
164
  createInputList({ x, y, width, height, title, value, anchor, place, numbersOnly, isDisabled, onChange }: CreateInputListArgs): HTMLDivElement;
161
- createImage({ x, y, width, src, }: CreateImageArgs): HTMLImageElement;
162
- createBackNextButton({ x, y, width, height, items, currentIndex, isBold, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
165
+ createImage({ x, y, width, src, place, anchor }: CreateImageArgs): HTMLImageElement;
166
+ createBackNextButton({ x, y, width, height, items, currentIndex, isBold, anchor, place, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
163
167
  createTabs({ x, y, width, tabs, anchor, currentTabName }: CreateTabArgs): HTMLDivElement;
164
168
  drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
165
169
  }
package/dist/ui.js CHANGED
@@ -1,5 +1,5 @@
1
- import{getThemedColorsModule as W,MOD_DATA as L}from"./index";function j(s){return s*(MainCanvas.canvas.clientHeight/1e3)}function I(s){return s*(MainCanvas.canvas.clientWidth/2e3)}function O(s,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+s*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+s*o}function D(s,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+s*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+s*o}function E(s,e,o,c="top-left"){const f=c==="top-left"||c==="top-right"?"top":"bottom",a=c==="top-left"||c==="bottom-left"?"left":"right",t=O(o,f),d=D(e,a);Object.assign(s.style,{position:"fixed",[a]:d+"px",[f]:t+"px"})}function C(s,e,o){Object.assign(s.style,{width:I(e)+"px",height:j(o)+"px"})}function H(s,e){const o=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,f=Math.min(o,c)/100,a=e*f;Object.assign(s.style,{fontSize:a+"px"})}function z(s,e){s.style.fontFamily=e??"sans-serif"}function P(s,e){const o=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,f=Math.min(o,c)/100,a=e*f;Object.assign(s.style,{padding:a+"px"})}function k(s){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(s.style,{fontSize:e+"px"})}function V(s){s.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png"}).addEventListener("click",()=>s.exit()),s.name&&s.createText({text:s.name,x:100,y:60,fontSize:10}),s.load(),M[s.name]&&M[s.name].forEach(e=>e(s))}function R(){N(S)}function N(s){S=A,A=s,A&&V(A),S&&S.unload()}function X(){return A}let A,S=null;class Y{htmlElements=[];resizeEventListeners=[];tabRunHandler;get currentSubscreen(){return A}get name(){return""}run(){this.tabRunHandler&&this.tabRunHandler()}load(){}unload(){this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){R()}update(){}setPreviousSubscreen(){R()}setSubscreen(e){N(e)}createButton({text:e,x:o,y:c,width:f,height:a,fontSize:t="auto",anchor:d="top-left",padding:l,style:b="default",place:n=!0,icon:p,iconAbsolutePosition:r=!0,iconWidth:i,tooltip:m,onClick:h,isDisabled:g}){const u=document.createElement("button");if(u.classList.add("zcButton"),u.setAttribute("data-zc-style",b),u.style.display="flex",u.style.alignItems="center",u.style.justifyContent="center",u.style.columnGap="1.25vw",z(u,L.fontFamily),p){const v=document.createElement("img");v.src=p,i?v.style.width=i:v.style.height="80%",e&&r&&(v.style.position="absolute",v.style.left="1vw"),e&&!r&&(u.style.justifyContent=""),u.append(v)}if(e){const v=document.createElement("span");v.textContent=e,p&&!r&&i&&(v.style.width="100%",v.style.marginRight=i),u.append(v)}if(m){const v=document.createElement("span");v.classList.add("tooltip"),v.setAttribute("position",m.position),v.textContent=m.text,u.append(v)}const T=()=>{typeof o=="number"&&typeof c=="number"&&E(u,o,c,d),C(u,f,a),l&&P(u,l),t==="auto"?k(u):H(u,t)};return T(),typeof g=="function"&&g()&&u.classList.add("zcDisabled"),u.addEventListener("click",()=>{typeof g=="function"&&!g()&&typeof h=="function"&&h(),typeof g=="function"&&g()&&u.classList.add("zcDisabled")}),window.addEventListener("resize",T),n&&document.body.append(u),this.resizeEventListeners.push(T),this.htmlElements.push(u),u}createText({text:e,color:o,x:c,y:f,width:a,height:t,withBackground:d=!1,fontSize:l="auto",anchor:b="top-left",padding:n,place:p=!0}){const r=document.createElement("p");r.innerHTML=e,r.style.color=o??"var(--tmd-text, black)",d&&(r.style.background="var(--tmd-element,rgb(239, 239, 239))"),z(r,L.fontFamily);const i=()=>{typeof c=="number"&&typeof f=="number"&&E(r,c,f,b),C(r,a,t),n&&P(r,n),l==="auto"?k(r):H(r,l)};return i(),window.addEventListener("resize",i),p&&document.body.append(r),this.resizeEventListeners.push(i),this.htmlElements.push(r),r}createInput({value:e,placeholder:o,x:c,y:f,width:a,height:t,textArea:d=!1,fontSize:l="auto",anchor:b="top-left",padding:n,place:p=!0,onChange:r,onInput:i,isDisabled:m}){const h=document.createElement(d?"textarea":"input");h.classList.add("zcInput"),o&&(h.placeholder=o),e&&(h.value=e),z(h,L.fontFamily);const g=()=>{typeof c=="number"&&typeof f=="number"&&E(h,c,f,b),C(h,a,t),n&&P(h,n),l==="auto"?k(h):H(h,l)};return g(),typeof m=="function"&&m()&&h.classList.add("zcDisabled"),h.addEventListener("change",()=>{if(typeof m=="function"&&m())return h.classList.add("zcDisabled");typeof r=="function"&&r()}),h.addEventListener("input",()=>{if(typeof m=="function"&&m())return h.classList.add("zcDisabled");typeof i=="function"&&i()}),window.addEventListener("resize",g),p&&document.body.append(h),this.resizeEventListeners.push(g),this.htmlElements.push(h),h}createCheckbox({text:e,x:o,y:c,isChecked:f,width:a,anchor:t="top-left",place:d=!0,isDisabled:l,onChange:b}){const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.columnGap="1vw";const p=document.createElement("input");p.type="checkbox",p.checked=f,p.style.borderRadius="min(0.8dvh, 0.3dvw)",p.classList.add("zcCheckbox","checkbox");const r=document.createElement("p");r.textContent=e,r.style.color="var(--tmd-text, black)",z(r,L.fontFamily);const i=()=>{typeof o=="number"&&typeof c=="number"&&E(n,o,c,t),a&&(n.style.width=I(a)+"px"),H(r,5)};return i(),typeof l=="function"&&l()&&n.classList.add("zcDisabled"),n.addEventListener("change",()=>{if(typeof l=="function"&&l())return n.classList.add("zcDisabled");typeof b=="function"&&b()}),window.addEventListener("resize",i),n.append(p,r),d&&document.body.append(n),this.resizeEventListeners.push(i),this.htmlElements.push(n,r),n}createScrollView({scroll:e,x:o,y:c,width:f,height:a,anchor:t="top-left"}){const d=document.createElement("div");e==="all"&&(d.style.overflow="scroll"),e==="x"&&(d.style.overflowX="scroll"),e==="y"&&(d.style.overflowY="scroll");const l=()=>{typeof o=="number"&&typeof c=="number"&&E(d,o,c,t),C(d,f,a)};return l(),window.addEventListener("resize",l),document.body.append(d),this.resizeEventListeners.push(l),this.htmlElements.push(d),d}createInputList({x:e,y:o,width:c,height:f,title:a,value:t,anchor:d="top-left",place:l=!0,numbersOnly:b=!1,isDisabled:n,onChange:p}){const r=[],i=document.createElement("div");i.style.cssText=`
1
+ import{getThemedColorsModule as I,MOD_DATA as L}from"./index";function D(b){return b*(MainCanvas.canvas.clientHeight/1e3)}function F(b){return b*(MainCanvas.canvas.clientWidth/2e3)}function j(b,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+b*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+b*o}function R(b,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+b*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+b*o}function E(b,e,o,u="top-left"){const m=u==="top-left"||u==="top-right"?"top":"bottom",a=u==="top-left"||u==="bottom-left"?"left":"right",n=j(o,m),i=R(e,a);Object.assign(b.style,{position:"fixed",[a]:i+"px",[m]:n+"px"})}function w(b,e,o){Object.assign(b.style,{width:F(e)+"px",height:D(o)+"px"})}function H(b,e){const o=MainCanvas.canvas.clientWidth,u=MainCanvas.canvas.clientHeight,m=Math.min(o,u)/100,a=e*m;Object.assign(b.style,{fontSize:a+"px"})}function z(b,e){b.style.fontFamily=e??"sans-serif"}function P(b,e){const o=MainCanvas.canvas.clientWidth,u=MainCanvas.canvas.clientHeight,m=Math.min(o,u)/100,a=e*m;Object.assign(b.style,{padding:a+"px"})}function A(b){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(b.style,{fontSize:e+"px"})}function O(){W(M)}function W(b){M=k,k=b,k&&k.load(),M&&M.unload()}function G(){return k}let k,M=null;class X{htmlElements=[];resizeEventListeners=[];tabHandlers={};get currentSubscreen(){return k}get previousSubscreen(){return M}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png"}).addEventListener("click",()=>this.exit()),this.name&&this.createText({text:this.name,x:100,y:60,fontSize:10}),B[this.name]&&B[this.name].forEach(e=>e(this))}unload(){this.tabHandlers.unload?.(),this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){this.tabHandlers.exit?.(),this.setSubscreen(this.previousSubscreen)}update(){}setPreviousSubscreen(){O()}setSubscreen(e){W(e)}createButton({text:e,x:o,y:u,width:m,height:a,fontSize:n="auto",anchor:i="top-left",padding:l,style:y="default",place:s=!0,icon:f,iconAbsolutePosition:t=!0,iconWidth:c,tooltip:p,onClick:d,isDisabled:h}){const r=document.createElement("button");if(r.classList.add("zcButton"),r.setAttribute("data-zc-style",y),r.style.display="flex",r.style.alignItems="center",r.style.justifyContent="center",r.style.columnGap="1.25vw",z(r,L.fontFamily),f){const v=document.createElement("img");v.src=f,c?v.style.width=c:v.style.height="80%",e&&t&&(v.style.position="absolute",v.style.left="1vw"),e&&!t&&(r.style.justifyContent=""),r.append(v)}if(e){const v=document.createElement("span");v.textContent=e,f&&!t&&c&&(v.style.width="100%",v.style.marginRight=c),r.append(v)}if(p){const v=document.createElement("span");v.classList.add("tooltip"),v.setAttribute("position",p.position),v.textContent=p.text,r.append(v)}const C=()=>{typeof o=="number"&&typeof u=="number"&&E(r,o,u,i),w(r,m,a),l&&P(r,l),n==="auto"?A(r):H(r,n)};return C(),typeof h=="function"&&h()&&r.classList.add("zcDisabled"),r.addEventListener("click",()=>{if(typeof h=="function"&&h())return r.classList.add("zcDisabled");typeof d=="function"&&d()}),window.addEventListener("resize",C),s&&document.body.append(r),this.resizeEventListeners.push(C),this.htmlElements.push(r),r}createText({text:e,color:o,x:u,y:m,width:a,height:n,withBackground:i=!1,fontSize:l="auto",anchor:y="top-left",padding:s,place:f=!0}){const t=document.createElement("p");t.innerHTML=e,t.style.color=o??"var(--tmd-text, black)",i&&(t.style.background="var(--tmd-element,rgb(239, 239, 239))"),z(t,L.fontFamily);const c=()=>{typeof u=="number"&&typeof m=="number"&&E(t,u,m,y),w(t,a,n),s&&P(t,s),l==="auto"?A(t):H(t,l)};return c(),window.addEventListener("resize",c),f&&document.body.append(t),this.resizeEventListeners.push(c),this.htmlElements.push(t),t}createInput({value:e,placeholder:o,x:u,y:m,width:a,height:n,textArea:i=!1,fontSize:l="auto",anchor:y="top-left",padding:s,place:f=!0,onChange:t,onInput:c,isDisabled:p}){const d=document.createElement(i?"textarea":"input");d.classList.add("zcInput"),o&&(d.placeholder=o),e&&(d.value=e),z(d,L.fontFamily);const h=()=>{typeof u=="number"&&typeof m=="number"&&E(d,u,m,y),w(d,a,n),s&&P(d,s),l==="auto"?A(d):H(d,l)};return h(),typeof p=="function"&&p()&&d.classList.add("zcDisabled"),d.addEventListener("change",()=>{if(typeof p=="function"&&p())return d.classList.add("zcDisabled");typeof t=="function"&&t()}),d.addEventListener("input",()=>{if(typeof p=="function"&&p())return d.classList.add("zcDisabled");typeof c=="function"&&c()}),window.addEventListener("resize",h),f&&document.body.append(d),this.resizeEventListeners.push(h),this.htmlElements.push(d),d}createCheckbox({text:e,x:o,y:u,isChecked:m,width:a,anchor:n="top-left",place:i=!0,isDisabled:l,onChange:y}){const s=document.createElement("div");s.style.display="flex",s.style.alignItems="center",s.style.columnGap="1vw";const f=document.createElement("input");f.type="checkbox",f.checked=m,f.style.borderRadius="min(0.8dvh, 0.3dvw)",f.classList.add("zcCheckbox","checkbox");const t=document.createElement("p");t.textContent=e,t.style.color="var(--tmd-text, black)",z(t,L.fontFamily);const c=()=>{typeof o=="number"&&typeof u=="number"&&E(s,o,u,n),a&&(s.style.width=F(a)+"px"),H(t,5)};return c(),typeof l=="function"&&l()&&s.classList.add("zcDisabled"),s.addEventListener("change",()=>{if(typeof l=="function"&&l())return s.classList.add("zcDisabled");typeof y=="function"&&y()}),window.addEventListener("resize",c),s.append(f,t),i&&document.body.append(s),this.resizeEventListeners.push(c),this.htmlElements.push(s,t),s}createScrollView({scroll:e,x:o,y:u,width:m,height:a,anchor:n="top-left"}){const i=document.createElement("div");e==="all"&&(i.style.overflow="scroll"),e==="x"&&(i.style.overflowX="scroll"),e==="y"&&(i.style.overflowY="scroll");const l=()=>{typeof o=="number"&&typeof u=="number"&&E(i,o,u,n),w(i,m,a)};return l(),window.addEventListener("resize",l),document.body.append(i),this.resizeEventListeners.push(l),this.htmlElements.push(i),i}createInputList({x:e,y:o,width:u,height:m,title:a,value:n,anchor:i="top-left",place:l=!0,numbersOnly:y=!1,isDisabled:s,onChange:f}){const t=[],c=document.createElement("div");c.style.cssText=`
2
2
  display: flex; flex-direction: column; gap: 1vw; border: 2px solid var(--tmd-accent, black);
3
3
  border-radius: 4px; padding: 0.75vw; background: var(--tmd-element, none);
4
- `,z(i,L.fontFamily);const m=document.createElement("div");m.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const h=document.createElement("b");h.textContent=a+":",h.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const g=document.createElement("div");g.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
- overflow-y: scroll;`;const u=document.createElement("input");u.style.cssText="border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";const T=(y,x)=>{const w=document.createElement("button");w.style.cssText="cursor: pointer; display: grid; place-items: center; background: var(--tmd-element-hover, #e0e0e0); width: 10%; max-width: 40px; aspect-ratio: 1/1; border-radius: 8px; border: none;";const F=DrawGetImage(y);F.style.cssText="width: 90%;",w.append(F),m.append(w),w.addEventListener("click",x)},v=y=>{if(typeof n=="function"&&n())return i.classList.add("zcDisabled");const x=document.createElement("div");x.style.cssText="cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);",x.textContent=y,g.insertBefore(x,u),x.addEventListener("click",w=>{x.style.border===""?x.style.border="2px solid red":x.style.border="",w.stopPropagation()}),r.push(y),typeof p=="function"&&p(b?r.map(w=>parseInt(w)):r)},B=()=>{typeof e=="number"&&typeof o=="number"&&E(i,e,o,d),C(i,c,f)};return T("Icons/Cancel.png",()=>{if(typeof n=="function"&&n())return i.classList.add("zcDisabled");g.innerHTML="",r.splice(0,r.length),g.append(u),t.forEach(y=>v(String(y)))}),T("Icons/Trash.png",()=>{typeof n=="function"&&n()&&i.classList.add("zcDisabled");for(const y of[...g.children])y.getAttribute("style").includes("border: 2px solid red;")&&(r.splice(r.indexOf(y.textContent),1),y.remove())}),B(),typeof n=="function"&&n()&&i.classList.add("zcDisabled"),window.addEventListener("resize",B),u.addEventListener("keypress",y=>{if(document.activeElement===u)switch(y.key){case"Enter":if(b&&Number.isNaN(parseInt(u.value))||!b&&u.value.trim()==="")return;v(u.value),u.value="";break}}),i.addEventListener("click",y=>{y.currentTarget==i&&u.focus()}),g.append(u),i.append(m,h,g),document.body.append(i),this.resizeEventListeners.push(B),this.htmlElements.push(i),t.forEach(y=>v(String(y))),i}createImage({x:e,y:o,width:c,src:f}){const a=document.createElement("img");a.src=f;const t=()=>{typeof e=="number"&&typeof o=="number"&&E(a,e,o),C(a,c,0),a.style.height="auto"};return t(),window.addEventListener("resize",t),document.body.append(a),this.resizeEventListeners.push(t),this.htmlElements.push(a),a}createBackNextButton({x:e,y:o,width:c,height:f,items:a,currentIndex:t,isBold:d=!1,onChange:l,isDisabled:b}){const n=document.createElement("div");n.classList.add("zcBackNextButton"),z(n,L.fontFamily);const p=document.createElement("button");p.style.cssText="position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;",p.classList.add("zcButton"),p.textContent="\u{1F844}",p.addEventListener("click",()=>{if(typeof b=="function"&&b())return n.classList.add("zcDisabled");t!==0&&(t--,i.textContent=a[t][0],typeof l=="function"&&l(a[t][1]))});const r=document.createElement("button");r.style.cssText="position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;",r.classList.add("zcButton"),r.textContent="\u{1F846}",r.addEventListener("click",()=>{if(typeof b=="function"&&b())return n.classList.add("zcDisabled");t!==a.length-1&&(t++,i.textContent=a[t][0],typeof l=="function"&&l(a[t][1]))});const i=document.createElement("p");d&&(i.style.fontWeight="bold"),i.textContent=a[t][0],n.append(p,i,r);const m=()=>{typeof e=="number"&&typeof o=="number"&&E(n,e,o),C(n,c,f),k(i)};return m(),typeof b=="function"&&b()&&n.classList.add("zcDisabled"),window.addEventListener("resize",m),document.body.append(n),this.resizeEventListeners.push(m),this.htmlElements.push(n),n}createTabs({x:e,y:o,width:c,tabs:f,anchor:a="top-left",currentTabName:t}){let d=[];const l=document.createElement("div");l.classList.add("zcTabs"),z(l,L.fontFamily),f.forEach(n=>{const p=()=>{for(const m of l.children)m.removeAttribute("data-opened");for(const m of d)m instanceof Node&&document.body.removeChild(m);d=[],r.setAttribute("data-opened","true");const i=document.body.append.bind(document.body);document.body.append=(...m)=>{d.push(...m),i(...m)},n.load(),this.tabRunHandler=n.run,document.body.append=i},r=document.createElement("button");r.textContent=n.name,n.name===t&&p(),r.addEventListener("click",p),l.append(r)});const b=()=>{typeof e=="number"&&typeof o=="number"&&E(l,e,o,a),c&&(l.style.width=I(c)+"px"),k(l)};return b(),window.addEventListener("resize",b),document.body.append(l),this.resizeEventListeners.push(b),this.htmlElements.push(l),l}drawPolylineArrow({points:e,strokeColor:o=W()?.base?.text??"black",lineWidth:c=2,circleRadius:f=5,circleColor:a=W()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=o,t.lineWidth=c,t.fillStyle=a,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let d=1;d<e.length;d++)t.lineTo(e[d].x,e[d].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,f,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,f,0,Math.PI*2),t.fill(),t.restore()}}const M={};function _(s,e){M[s]||(M[s]=[]),M[s].push(e)}export{Y as BaseSubscreen,k as autosetFontSize,X as getCurrentSubscreen,j as getRelativeHeight,I as getRelativeWidth,D as getRelativeX,O as getRelativeY,_ as hookSubscreen,V as loadSubscreen,z as setFontFamily,H as setFontSize,P as setPadding,E as setPosition,R as setPreviousSubscreen,C as setSize,N as setSubscreen};
4
+ `,z(c,L.fontFamily);const p=document.createElement("div");p.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const d=document.createElement("b");d.textContent=a+":",d.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const h=document.createElement("div");h.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
+ overflow-y: scroll;`;const r=document.createElement("input");r.style.cssText="border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";const C=(g,x)=>{const T=document.createElement("button");T.style.cssText="cursor: pointer; display: grid; place-items: center; background: var(--tmd-element-hover, #e0e0e0); width: 10%; max-width: 40px; aspect-ratio: 1/1; border-radius: 8px; border: none;";const N=DrawGetImage(g);N.style.cssText="width: 90%;",T.append(N),p.append(T),T.addEventListener("click",x)},v=g=>{const x=document.createElement("div");x.style.cssText="cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);",x.textContent=g,h.insertBefore(x,r),x.addEventListener("click",T=>{x.style.border===""?x.style.border="2px solid red":x.style.border="",T.stopPropagation()}),t.push(g)},S=()=>{typeof e=="number"&&typeof o=="number"&&E(c,e,o,i),w(c,u,m)};return C("Icons/Cancel.png",()=>{if(typeof s=="function"&&s())return c.classList.add("zcDisabled");h.innerHTML="",t.splice(0,t.length),h.append(r),n.forEach(g=>v(String(g))),typeof f=="function"&&f(y?t.map(g=>parseInt(g)):t)}),C("Icons/Trash.png",()=>{if(typeof s=="function"&&s())return c.classList.add("zcDisabled");for(const g of[...h.children])g.getAttribute("style").includes("border: 2px solid red;")&&(t.splice(t.indexOf(g.textContent),1),g.remove());typeof f=="function"&&f(y?t.map(g=>parseInt(g)):t)}),S(),typeof s=="function"&&s()&&c.classList.add("zcDisabled"),window.addEventListener("resize",S),r.addEventListener("keypress",g=>{if(document.activeElement===r)switch(g.key){case"Enter":if(y&&Number.isNaN(parseInt(r.value))||r.value.trim()==="")return;if(typeof s=="function"&&s())return c.classList.add("zcDisabled");v(r.value),r.value="",typeof f=="function"&&f(y?t.map(x=>parseInt(x)):t);break}}),c.addEventListener("click",g=>{g.currentTarget==c&&r.focus()}),h.append(r),c.append(p,d,h),l&&document.body.append(c),this.resizeEventListeners.push(S),this.htmlElements.push(c),n.forEach(g=>v(String(g))),c}createImage({x:e,y:o,width:u,src:m,place:a=!0,anchor:n="top-left"}){const i=document.createElement("img");i.src=m;const l=()=>{typeof e=="number"&&typeof o=="number"&&E(i,e,o,n),w(i,u,0),i.style.height="auto"};return l(),window.addEventListener("resize",l),a&&document.body.append(i),this.resizeEventListeners.push(l),this.htmlElements.push(i),i}createBackNextButton({x:e,y:o,width:u,height:m,items:a,currentIndex:n,isBold:i=!1,anchor:l="top-left",place:y=!0,onChange:s,isDisabled:f}){const t=document.createElement("div");t.classList.add("zcBackNextButton"),z(t,L.fontFamily);const c=()=>{n===0||typeof f=="function"&&f(a[n-1][1])?p.classList.add("zcBackNextButton-btnDisabled"):p.classList.remove("zcBackNextButton-btnDisabled"),n===a.length-1||typeof f=="function"&&f(a[n+1][1])?d.classList.add("zcBackNextButton-btnDisabled"):d.classList.remove("zcBackNextButton-btnDisabled")},p=document.createElement("button");p.style.cssText="position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;",p.classList.add("zcButton"),p.textContent="\u{1F844}",p.addEventListener("click",()=>{if(n===0||typeof f=="function"&&f(a[n-1][1]))return p.classList.add("zcDisabled");n--,h.textContent=a[n][0],typeof s=="function"&&s(a[n][1]),c()});const d=document.createElement("button");d.style.cssText="position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;",d.classList.add("zcButton"),d.textContent="\u{1F846}",d.addEventListener("click",()=>{if(n===a.length-1||typeof f=="function"&&f(a[n+1][1]))return d.classList.add("zcDisabled");n++,h.textContent=a[n][0],typeof s=="function"&&s(a[n][1]),c()}),c();const h=document.createElement("p");i&&(h.style.fontWeight="bold"),h.textContent=a[n][0],t.append(p,h,d);const r=()=>{typeof e=="number"&&typeof o=="number"&&E(t,e,o,l),w(t,u,m),A(h)};return r(),window.addEventListener("resize",r),y&&document.body.append(t),this.resizeEventListeners.push(r),this.htmlElements.push(t),t}createTabs({x:e,y:o,width:u,tabs:m,anchor:a="top-left",currentTabName:n}){let i=[];const l=document.createElement("div");l.classList.add("zcTabs"),z(l,L.fontFamily),m.forEach(s=>{const f=()=>{for(const p of l.children)p.removeAttribute("data-opened");for(const p of i)p instanceof Node&&document.body.removeChild(p);i=[],t.setAttribute("data-opened","true");const c=document.body.append.bind(document.body);document.body.append=(...p)=>{i.push(...p),c(...p)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),s.load(),this.tabHandlers={run:s.run,load:s.load,unload:s.unload,exit:s.exit},document.body.append=c},t=document.createElement("button");t.textContent=s.name,s.name===n&&f(),t.addEventListener("click",f),l.append(t)});const y=()=>{typeof e=="number"&&typeof o=="number"&&E(l,e,o,a),u&&(l.style.width=F(u)+"px"),A(l)};return y(),window.addEventListener("resize",y),document.body.append(l),this.resizeEventListeners.push(y),this.htmlElements.push(l),l}drawPolylineArrow({points:e,strokeColor:o=I()?.base?.text??"black",lineWidth:u=2,circleRadius:m=5,circleColor:a=I()?.base?.text??"black"}){if(e.length<2)return;const n=MainCanvas.canvas.getContext("2d");n.save(),n.strokeStyle=o,n.lineWidth=u,n.fillStyle=a,n.beginPath(),n.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)n.lineTo(e[i].x,e[i].y);n.stroke(),n.beginPath(),n.arc(e[0].x,e[0].y,m,0,Math.PI*2),n.fill(),n.beginPath(),n.arc(e[e.length-1].x,e[e.length-1].y,m,0,Math.PI*2),n.fill(),n.restore()}}const B={};function Y(b,e){B[b]||(B[b]=[]),B[b].push(e)}export{X as BaseSubscreen,A as autosetFontSize,G as getCurrentSubscreen,D as getRelativeHeight,F as getRelativeWidth,R as getRelativeX,j as getRelativeY,Y as hookSubscreen,z as setFontFamily,H as setFontSize,P as setPadding,E as setPosition,O as setPreviousSubscreen,w as setSize,W as setSubscreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "The core for the my mods, which contains a shared code reused in all my mods",
5
5
  "author": "Zoi",
6
6
  "license": "MIT",
@@ -10,27 +10,27 @@
10
10
  "exports": {
11
11
  ".": {
12
12
  "import": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
13
+ "types": "./dist/types/index.d.ts"
14
14
  },
15
15
  "./messaging": {
16
16
  "import": "./dist/messaging.js",
17
- "types": "./dist/messaging.d.ts"
17
+ "types": "./dist/types/messaging.d.ts"
18
18
  },
19
19
  "./modsApi": {
20
20
  "import": "./dist/modsApi.js",
21
- "types": "./dist/modsApi.d.ts"
21
+ "types": "./dist/types/modsApi.d.ts"
22
22
  },
23
23
  "./ui": {
24
24
  "import": "./dist/ui.js",
25
- "types": "./dist/ui.d.ts"
25
+ "types": "./dist/types/ui.d.ts"
26
26
  },
27
27
  "./wardrobe": {
28
28
  "import": "./dist/wardrobe.js",
29
- "types": "./dist/wardrobe.d.ts"
29
+ "types": "./dist/types/wardrobe.d.ts"
30
30
  },
31
31
  "./popups": {
32
32
  "import": "./dist/popups.js",
33
- "types": "./dist/popups.d.ts"
33
+ "types": "./dist/types/popups.d.ts"
34
34
  }
35
35
  },
36
36
  "dependencies": {
@@ -1,13 +0,0 @@
1
- interface RequestResponse<T> {
2
- data?: T;
3
- isError: boolean;
4
- }
5
- export declare function chatSendLocalMessage(message: string | Node): void;
6
- export declare function chatSendActionMessage(msg: string, target?: undefined | number, dictionary?: ChatMessageDictionaryEntry[]): void;
7
- export declare function chatSendModMessage<T>(msg: string, _data?: T, targetNumber?: any): void;
8
- export declare function chatSendBeepMessage(data: any, targetId: number): void;
9
- export declare function sendRequest<T>(message: string, data: any, target: number): Promise<RequestResponse<T>>;
10
- export declare function handleRequestResponse(requestId: number, data: any): void;
11
- export declare function handleRequest(requestId: number, message: string, _data: any, sender: Character): void;
12
- export declare function addRequestListener(message: string, listener: (data: any, sender: Character) => any): void;
13
- export {};
File without changes
File without changes