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/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.2.1",
3
+ "version": "2.0.1",
4
4
  "description": "The core for the my mods, which contains a shared code reused in all my mods",
5
+ "bin": {
6
+ "zois-core": "scripts/zois-core.mjs"
7
+ },
5
8
  "author": "Zoi",
6
9
  "license": "MIT",
7
10
  "files": [
@@ -12,57 +15,75 @@
12
15
  "import": "./dist/index.js",
13
16
  "types": "./dist/types/index.d.ts"
14
17
  },
18
+ "./core": {
19
+ "import": "./dist/core.js",
20
+ "types": "./dist/types/core.d.ts"
21
+ },
15
22
  "./messaging": {
16
23
  "import": "./dist/messaging.js",
17
24
  "types": "./dist/types/messaging.d.ts"
18
25
  },
19
- "./modsApi": {
20
- "import": "./dist/modsApi.js",
21
- "types": "./dist/types/modsApi.d.ts"
26
+ "./mod-sdk": {
27
+ "import": "./dist/modSdk.js",
28
+ "types": "./dist/types/modSdk.d.ts"
22
29
  },
23
30
  "./ui": {
24
31
  "import": "./dist/ui.js",
25
32
  "types": "./dist/types/ui.d.ts"
26
33
  },
27
- "./ui-modules": {
28
- "import": "./dist/ui-modules/index.js",
29
- "types": "./dist/types/ui-modules/index.d.ts"
34
+ "./shard-modules": {
35
+ "import": "./dist/shard-modules/index.js",
36
+ "types": "./dist/types/shard-modules/index.d.ts"
30
37
  },
31
- "./modules": {
32
- "import": "./dist/modules.js",
33
- "types": "./dist/types/modules.d.ts"
38
+ "./shards": {
39
+ "import": "./dist/shards/index.js",
40
+ "types": "./dist/types/shards/index.d.ts"
34
41
  },
35
42
  "./wardrobe": {
36
43
  "import": "./dist/wardrobe.js",
37
44
  "types": "./dist/types/wardrobe.d.ts"
38
45
  },
39
- "./popups": {
40
- "import": "./dist/popups.js",
41
- "types": "./dist/types/popups.d.ts"
46
+ "./dialogs": {
47
+ "import": "./dist/dialogs.js",
48
+ "types": "./dist/types/dialogs.d.ts"
49
+ },
50
+ "./toasts": {
51
+ "import": "./dist/toasts.js",
52
+ "types": "./dist/types/toasts.d.ts"
42
53
  },
43
54
  "./validation": {
44
55
  "import": "./dist/validation.js",
45
56
  "types": "./dist/types/validation.d.ts"
57
+ },
58
+ "./logging": {
59
+ "import": "./dist/logging.js",
60
+ "types": "./dist/types/logging.d.ts"
61
+ },
62
+ "./localization": {
63
+ "import": "./dist/localization.js",
64
+ "types": "./dist/types/localization.d.ts"
65
+ },
66
+ "./changelogs": {
67
+ "import": "./dist/changelogs.js",
68
+ "types": "./dist/types/changelogs.d.ts"
46
69
  }
47
70
  },
48
71
  "dependencies": {
72
+ "@octokit/rest": "^22.0.1",
49
73
  "bondage-club-mod-sdk": "^1.2.0",
74
+ "chalk": "^5.6.2",
50
75
  "class-transformer": "^0.5.1",
51
- "class-validator": "^0.14.2",
52
- "lucide": "^0.541.0",
53
- "lucide-react": "^0.542.0",
54
- "react": "^19.1.0",
55
- "react-dom": "^19.1.0",
56
- "reflect-metadata": "^0.2.2",
57
- "zustand": "^5.0.5"
76
+ "class-validator": "^0.14.4",
77
+ "lucide": "^1.24.0",
78
+ "reflect-metadata": "^0.2.2"
58
79
  },
59
80
  "devDependencies": {
60
- "@types/react": "^19.1.8",
61
- "@types/react-dom": "^19.1.6",
62
- "bc-stubs": "117.0.0-Beta.1",
63
- "esbuild": "^0.25.5",
64
- "nodemon": "^3.1.10",
65
- "typescript": "^5.8.3"
81
+ "bc-stubs": "130.0.0-Beta.1",
82
+ "esbuild": "^0.28.1",
83
+ "esbuild-plugin-copy": "^2.1.1",
84
+ "glob": "^13.0.6",
85
+ "nodemon": "^3.1.14",
86
+ "typescript": "^5.9.3"
66
87
  },
67
88
  "scripts": {
68
89
  "build": "node scripts/build.mjs"
@@ -0,0 +1,126 @@
1
+ import fs from "fs/promises";
2
+ import path from "path";
3
+ import chalk from 'chalk';
4
+ import { Octokit } from "@octokit/rest";
5
+
6
+ const octokit = new Octokit();
7
+ const args = process.argv.slice(2);
8
+ const command = args[0];
9
+
10
+ function getArg(name) {
11
+ const arg = args.find((a) => a.startsWith("--" + name));
12
+ if (arg) return arg.slice(name.length + 3);
13
+ return null;
14
+ }
15
+
16
+ switch (command) {
17
+ case "generate-changelog": {
18
+ generateChangelog().catch((err) => {
19
+ console.log(chalk.red("Script failed:"), err.message);
20
+ process.exit(1);
21
+ });
22
+ break;
23
+ }
24
+ default: {
25
+ console.log(chalk.red("Unknown command"), `"${chalk.cyan(command)}"`);
26
+ console.log("Available commands:")
27
+ console.log(`• ${chalk.cyan("generate-changelog")} — Generate changelog bundle`)
28
+ }
29
+ }
30
+
31
+ async function getCommitsSince(owner, repo, sinceSha, perPage = 50) {
32
+ const commits = [];
33
+ let page = 1;
34
+ let hasMore = true;
35
+
36
+ try {
37
+ while (hasMore) {
38
+ const { data } = await octokit.rest.repos.listCommits({
39
+ owner,
40
+ repo,
41
+ sha: "HEAD",
42
+ per_page: perPage,
43
+ page: page,
44
+ });
45
+
46
+ if (data.length === 0) break;
47
+
48
+ const startIndex = data.findIndex((commit) => commit.sha === sinceSha);
49
+
50
+ if (startIndex !== -1) {
51
+ commits.push(...data.slice(0, startIndex + 1));
52
+ break;
53
+ } else {
54
+ commits.push(...data);
55
+ }
56
+
57
+ page++;
58
+ hasMore = data.length === perPage;
59
+ }
60
+
61
+ return commits.map((commit) => ({
62
+ sha: commit.sha,
63
+ message: commit.commit.message,
64
+ date: commit.commit.author.date,
65
+ author: {
66
+ name: commit.author?.login || commit.commit.author.name,
67
+ avatar_url: commit.author?.avatar_url,
68
+ html_url: commit.author?.html_url,
69
+ },
70
+ committer: {
71
+ name: commit.committer?.login || commit.commit.committer.name,
72
+ avatar_url: commit.committer?.avatar_url,
73
+ }
74
+ }));
75
+
76
+ } catch (error) {
77
+ console.log(chalk.red("Error getting commits:"), error.message);
78
+ throw error;
79
+ }
80
+ }
81
+
82
+ async function generateChangelog() {
83
+ const owner = getArg("owner");
84
+ if (!owner) {
85
+ console.log(chalk.red("--owner argument not specified"));
86
+ process.exit(1);
87
+ }
88
+ const repo = getArg("repo");
89
+ if (!repo) {
90
+ console.log(chalk.red("--repo argument not specified"));
91
+ process.exit(1);
92
+ }
93
+ const fromCommit = getArg("from");
94
+ if (!fromCommit) {
95
+ console.log(chalk.red("--from argument not specified"));
96
+ process.exit(1);
97
+ }
98
+ console.log(`Generating changelog from commit ${chalk.cyan(fromCommit)}...`);
99
+
100
+ const commits = await getCommitsSince(owner, repo, fromCommit);
101
+
102
+ const resultToWrite = {
103
+ generated_at: (new Date()).toISOString(),
104
+ changes: commits.map((c) => ({
105
+ message: c.message,
106
+ sha: c.sha,
107
+ author: {
108
+ name: c.author.name,
109
+ avatar_url: c.author.avatar_url ?? "https://avatars.githubusercontent.com/" + c.author.name,
110
+ },
111
+ date: c.date,
112
+ tags: [],
113
+ commit_url: `https://github.com/${owner}/${repo}/commit/${c.sha}`
114
+ }))
115
+ };
116
+
117
+ const outputPath = path.join(process.cwd(), "changelog.json");
118
+
119
+ await fs.writeFile(
120
+ outputPath,
121
+ JSON.stringify(resultToWrite, null, 2),
122
+ "utf-8"
123
+ );
124
+
125
+ console.log(`Generated changelog.json. (${commits.length} commits)`);
126
+ }
package/dist/modsApi.js DELETED
@@ -1 +0,0 @@
1
- import c from"bondage-club-mod-sdk";import{MOD_DATA as o}from"./index";import{getCurrentSubscreen as u,setSubscreen as d}from"./ui";import{dialogsManager as m}from"./popups";var f=(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))(f||{});let s;function O(){window.ZOISCORE_MODS??=[],window.ZOISCORE_MODS.push({name:o.name,fullName:o.fullName,key:o.key,version:o.version,deepLinkSubscreens:o.deepLinkSubscreens??[]}),s=c.registerMod({name:o.name,fullName:o.fullName,version:o.version,repository:o.repository}),l("GameKeyDown",1,(e,n)=>{const r=u();if(CommonKey.IsPressed(e[0],"Escape")&&r)return r.exit(),!1;const i=document.querySelector(".zcDialog");return i instanceof HTMLDivElement?(i.focus(),!1):n(e)}),window.addEventListener("zoiscore:open",async e=>{const n=e.detail.subscreen,r=e.detail.mod;if(r&&r!==o.key||u()?.constructor.name===n)return;const a=o.deepLinkSubscreens?.find(t=>t.constructor.name===n);a&&await m.confirm({message:"This deep link wants to redirect you to another subscreen. Confirm the redirecting."})&&d(a)})}function l(e,n,r){if(!s)throw new Error("zois-core is not registered");return s.hookFunction(e,n,r)}function w(e,n){if(!s)throw new Error("zois-core is not registered");s.patchFunction(e,n)}function I(e,n,r){if(!s)throw new Error("zois-core is not registered");return s.callOriginal(e,n)}function y(){return c.getModsInfo()}function x(e){return!!c.getModsInfo().find(n=>n.name===e)}export{f as HookPriority,I as callOriginal,x as findModByName,y as getLoadedMods,l as hookFunction,s as modSdk,w as patchFunction,O as registerMod};
package/dist/modules.js DELETED
@@ -1 +0,0 @@
1
- class r{overrideProperties(e,t){return e}layoutEffect(e,t){}effect(e,t){}}export{r as BaseModule};
package/dist/popups.js DELETED
@@ -1 +0,0 @@
1
- import{getRelativeX as D,getRelativeY as P}from"./ui";import{MOD_DATA as g}from"./index";import{useState as u,useEffect as f,useRef as k}from"react";import x from"react-dom/client";import{create as w}from"zustand";import{CircleAlert as E,CircleCheck as O,CircleX as I,Info as R}from"lucide-react";import{Fragment as v,jsx as i,jsxs as d}from"react/jsx-runtime";function z({children:t}){const[e,o]=u({}),r=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return f(()=>{const s=()=>{o({fontFamily:CommonGetFontName(),bottom:P(5)+"px",left:D(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),i("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(r,300)},children:t})}const M=({type:t,theme:e})=>{switch(t){case"info":return i(R,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#addbff",stroke:e?e.iconStrokeColor:"#385073"}});case"success":return i(O,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#c3ffc3",stroke:e?e.iconStrokeColor:"#028f74"}});case"warning":return i(E,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffdfaf",stroke:e?e.iconStrokeColor:"#9c7633"}});case"error":return i(I,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffb2b2",stroke:e?e.iconStrokeColor:"#7f2828"}});case"spinner":return i("div",{style:{flexShrink:0,width:"1.65em",height:"1.65em",boxSizing:"border-box",border:"2px solid",borderRadius:"100%",borderColor:`transparent ${e?e.iconFillColor:"rgb(154 154 255)"}`,animation:"zcSpin 0.65s linear infinite"}})}},F=({title:t,message:e,type:o,duration:r,theme:s})=>{const[n,l]=u({}),[c,m]=u(!1),a=s?s.backgroundColor:o==="success"?"#3ece7e":o==="warning"?"#debf72":o==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)",p=s?s.titleColor:o==="info"||o==="spinner"?"rgb(47, 46, 104)":o==="success"?"#244428":o==="error"?"rgb(113, 2, 2)":"#5e4328",y=s?s.messageColor:o==="info"||o==="spinner"?"#b8b8ff":o==="success"?"#c7f9c7":o==="error"?"rgb(255, 152, 152)":"#ffeec5";return f(()=>{const T=()=>{const C=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,S=Math.min(C,b)/100;l({position:"relative",width:"100%",fontSize:3*S+"px",padding:1.5*S+"px",background:a})};window.addEventListener("resize",T),T();const h=setTimeout(()=>m(!0),r);return()=>{clearTimeout(h),window.removeEventListener("resize",T)}},[]),d("div",{className:`zcToast ${c&&"exiting"}`,"data-zc-toast-type":o,style:n,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[i(M,{type:o,theme:s}),d("div",{children:[t&&e&&d(v,{children:[i("p",{style:{color:p,fontWeight:"bold"},children:t}),i("p",{style:{color:y,fontSize:"70%",fontWeight:"bold",overflowWrap:"anywhere",marginTop:"0.25em"},children:e})]}),(!t&&e||t&&!e)&&i("p",{style:{position:"relative",zIndex:5,color:y,fontWeight:"bold",overflowWrap:"anywhere"},children:t||e})]})]}),o!=="spinner"&&i("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",borderRadius:"4px",background:s?s.progressBarColor:o==="info"?"rgb(103, 103, 234)":o==="success"?"#34bc71":o==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})};function W({dialog:t}){const e=window.ZOISCORE.useDialogStore(a=>a.clearDialog),[o,r]=u(""),[s,n]=u(t.type==="pick"?t.options?.[0]?.value:null),l=k(null),c=()=>{e(),t.type==="prompt"&&t.promise.resolve(o),t.type==="confirm"&&t.promise.resolve(!0),t.type==="pick"&&t.promise.resolve(s)},m=()=>{e(),t.promise.resolve(!1)};return f(()=>(document.body.style.pointerEvents="none",t.type==="prompt"&&l.current instanceof HTMLInputElement&&(console.log("Focus call"),l.current.focus()),()=>{document.body.style.pointerEvents=""}),[]),f(()=>{const a=p=>{(p.key==="Enter"||p.key==="Escape")&&(p.preventDefault(),p.stopPropagation()),p.key==="Enter"&&c(),p.key==="Escape"&&m()};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[c,m]),d(v,{children:[d("div",{className:"zcDialog","data-zc-dialog-type":t.type,style:{fontFamily:CommonGetFontName()},children:[i("p",{children:t.message}),t.type==="prompt"&&i("input",{ref:l,type:"text",value:o,style:{color:"white",marginTop:"1px",width:"90%",background:"rgb(82, 89, 104)",border:"none",borderRadius:"4px",padding:"0.45em"},onChange:a=>{console.log(a.currentTarget.value),r(a.currentTarget.value)}}),t.type==="pick"&&i("select",{style:{cursor:"pointer",width:"90%",background:"rgb(82, 89, 104)",border:"none",padding:"0.4em",color:"white",borderRadius:"4px"},children:t.options.map(a=>i("option",{onClick:()=>{n(a.value)},children:a.name},a.name))}),d("div",{style:{display:"flex",justifyContent:"end",columnGap:"0.75em",width:"100%",padding:"1em"},children:[i("button",{onClick:m,children:"Cancel"}),i("button",{onClick:c,children:"Ok"})]})]}),i("div",{style:{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"20",opacity:"0.5",background:"black"}})]})}class L{generateToastId(){return crypto.randomUUID()}process({title:e,message:o,duration:r,type:s,id:n,theme:l}){const{addToast:c,removeToast:m}=window.ZOISCORE.useToastsStore.getState();c({id:n,title:e,message:o,duration:r,type:s,theme:l}),setTimeout(()=>m(n),r+300)}info({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"info",id:s,theme:n})}success({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"success",id:s,theme:n})}warn({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"warning",id:s,theme:n})}error({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"error",id:s,theme:n})}spinner({title:e,message:o}){const r=this.generateToastId(),s=g.singleToastsTheme;return this.process({title:e,message:o,duration:1e6,type:"spinner",id:r,theme:s}),r}removeSpinner(e){const{removeToast:o}=window.ZOISCORE.useToastsStore.getState();o(e)}}class Z{prompt({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,s)=>{o({type:"prompt",message:e,promise:{resolve:r,reject:s}})})}confirm({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,s)=>{o({type:"confirm",message:e,promise:{resolve:r,reject:s}})})}pick({message:e,options:o}){const{setDialog:r}=window.ZOISCORE.useDialogStore.getState();return new Promise((s,n)=>{r({type:"pick",message:e,options:o,promise:{resolve:s,reject:n}})})}}function B(){const t=window.ZOISCORE.useToastsStore(o=>o.toasts),e=window.ZOISCORE.useDialogStore(o=>o.dialog);return d(v,{children:[i(z,{children:t.map(({title:o,message:r,type:s,duration:n,id:l,theme:c})=>i(F,{id:l,title:o,message:r,type:s,duration:n,theme:c},l))}),e&&i(W,{dialog:e})]})}class N extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const oe=w(t=>({toasts:[],addToast:e=>t(o=>({toasts:[...o.toasts,e]})),removeToast:e=>t(o=>({toasts:o.toasts.filter(r=>r.id!==e)})),clearToasts:()=>t({toasts:[]})})),te=w(t=>({dialog:null,setDialog:e=>t({dialog:e}),clearDialog:()=>t({dialog:null})}));function se(){customElements.define("zc-virtual-dom",N);const t=document.createElement("zc-virtual-dom");document.body.append(t),x.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(i(B,{}))}const re=new L,ie=new Z;export{ie as dialogsManager,se as initVirtualDOM,re as toastsManager,te as useDialogStore,oe as useToastsStore};
@@ -1,18 +0,0 @@
1
- import { Anchor } from "./ui";
2
- export interface Context {
3
- anchor?: Anchor;
4
- x?: number;
5
- y?: number;
6
- width?: number;
7
- height?: number;
8
- padding?: number;
9
- fontSize?: number | "auto";
10
- place?: boolean;
11
- element: HTMLElement;
12
- }
13
- export type ModuleTarget = HTMLElement | SVGElement;
14
- export declare abstract class BaseModule {
15
- overrideProperties(context: Context, target: ModuleTarget): Context;
16
- layoutEffect(context: Context, target: ModuleTarget): void;
17
- effect(context: Context, target: ModuleTarget): void;
18
- }
@@ -1,63 +0,0 @@
1
- import { ModData } from "./index";
2
- interface ToastProps {
3
- id: string;
4
- title?: string;
5
- message: string;
6
- type: "info" | "warning" | "error" | "success" | "spinner";
7
- duration: number;
8
- theme?: ModData["singleToastsTheme"];
9
- }
10
- interface BaseDialogProps<T> {
11
- type: "prompt" | "confirm" | "pick";
12
- message: string;
13
- promise: {
14
- resolve: (data: T) => void;
15
- reject: (data: T) => void;
16
- };
17
- }
18
- interface ConfirmDialogProps extends BaseDialogProps<boolean> {
19
- type: "confirm";
20
- }
21
- interface PromptDialogProps extends BaseDialogProps<string | false> {
22
- type: "prompt";
23
- }
24
- interface PickDialogProps<T> extends BaseDialogProps<T | false> {
25
- type: "pick";
26
- options: {
27
- name: string;
28
- value: T;
29
- }[];
30
- }
31
- type DialogProps = ConfirmDialogProps | PromptDialogProps | PickDialogProps<unknown>;
32
- declare class ToastsManager {
33
- private generateToastId;
34
- private process;
35
- info({ title, message, duration }: Omit<ToastProps, "type" | "id" | "theme">): void;
36
- success({ title, message, duration }: Omit<ToastProps, "type" | "id" | "theme">): void;
37
- warn({ title, message, duration }: Omit<ToastProps, "type" | "id" | "theme">): void;
38
- error({ title, message, duration }: Omit<ToastProps, "type" | "id" | "theme">): void;
39
- spinner({ title, message }: Omit<ToastProps, "type" | "id" | "duration" | "theme">): string;
40
- removeSpinner(id: string): void;
41
- }
42
- declare class DialogsManager {
43
- prompt({ message }: Omit<PromptDialogProps, "type" | "promise">): Promise<string | false>;
44
- confirm({ message }: Omit<ConfirmDialogProps, "type" | "promise">): Promise<boolean>;
45
- pick<T>({ message, options }: Omit<PickDialogProps<T>, "type" | "promise">): Promise<T | false>;
46
- }
47
- export interface ToastsStore {
48
- toasts: ToastProps[];
49
- addToast: (toast: ToastProps) => void;
50
- removeToast: (id: string) => void;
51
- clearToasts: () => void;
52
- }
53
- export interface DialogStore {
54
- dialog: DialogProps | null;
55
- setDialog: (props: DialogProps) => void;
56
- clearDialog: () => void;
57
- }
58
- export declare const useToastsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ToastsStore>>;
59
- export declare const useDialogStore: import("zustand").UseBoundStore<import("zustand").StoreApi<DialogStore>>;
60
- export declare function initVirtualDOM(): void;
61
- export declare const toastsManager: ToastsManager;
62
- export declare const dialogsManager: DialogsManager;
63
- export {};
@@ -1,6 +0,0 @@
1
- import { BaseModule, Context, ModuleTarget } from "../modules";
2
- export declare class AttributesModule extends BaseModule {
3
- private attributes;
4
- constructor(attributes: Record<string, string>);
5
- layoutEffect(context: Context, target: ModuleTarget): void;
6
- }
@@ -1,4 +0,0 @@
1
- import { BaseModule, Context } from "../modules";
2
- export declare class CenterModule extends BaseModule {
3
- overrideProperties(context: Context): Context;
4
- }
@@ -1,6 +0,0 @@
1
- import { BaseModule, Context, ModuleTarget } from "zois-core/modules";
2
- export declare class ClickModule extends BaseModule {
3
- private callback;
4
- constructor(callback: (target: ModuleTarget) => void);
5
- layoutEffect(context: Context, target: ModuleTarget): void;
6
- }
@@ -1,12 +0,0 @@
1
- import { BaseModule, Context, ModuleTarget } from "../modules";
2
- interface CounterUpModuleProps {
3
- duration: number;
4
- endValue: number;
5
- formattingFunction?: (value: number) => string;
6
- }
7
- export declare class CounterUpModule extends BaseModule {
8
- private props;
9
- constructor(props: CounterUpModuleProps);
10
- effect(context: Context, target: ModuleTarget): void;
11
- }
12
- export {};
@@ -1,7 +0,0 @@
1
- import { DynamicClassStyles } from "../ui";
2
- import { BaseModule, Context, ModuleTarget } from "../modules";
3
- export declare class DynamicClassModule extends BaseModule {
4
- private style;
5
- constructor(style: DynamicClassStyles);
6
- layoutEffect(context: Context, target: ModuleTarget): void;
7
- }
@@ -1,7 +0,0 @@
1
- import { BaseModule, Context, ModuleTarget } from "../modules";
2
- export declare class StyleModule extends BaseModule {
3
- private style;
4
- constructor(style: Partial<CSSStyleDeclaration>);
5
- private applyStyle;
6
- layoutEffect(context: Context, target: ModuleTarget): void;
7
- }
@@ -1,10 +0,0 @@
1
- import { BaseModule, Context, ModuleTarget } from "../modules";
2
- interface TypeModuleProps {
3
- duration: number;
4
- }
5
- export declare class TypeModule extends BaseModule {
6
- private props;
7
- constructor(props: TypeModuleProps);
8
- effect(context: Context, target: ModuleTarget): void;
9
- }
10
- export {};
@@ -1 +0,0 @@
1
- import{BaseModule as o}from"../modules";class c extends o{constructor(e){super();this.attributes=e}layoutEffect(e,r){for(const t of Object.keys(this.attributes))r.setAttribute(t,this.attributes[t])}}export{c as AttributesModule};
@@ -1 +0,0 @@
1
- import{BaseModule as r}from"../modules";class l extends r{overrideProperties(e){return e.element.style.cssText+="transform: translate(-50%, -50%);",e.x=1e3,e.y=500,e}}export{l as CenterModule};
@@ -1 +0,0 @@
1
- import{BaseModule as o}from"zois-core/modules";class i extends o{constructor(t){super();this.callback=t}layoutEffect(t,e){e.addEventListener("click",()=>this.callback(e))}}export{i as ClickModule};
@@ -1 +0,0 @@
1
- import{BaseModule as d}from"../modules";function f(n,a,r,e){if(!n)throw new Error("Element not found");let s=0,o,t;const i=m=>{o||(o=m);const l=m-o;let u=Math.min(l/r,1);const c=u*(2-u),p=parseInt(s+(a-s)*c);n.textContent=typeof e=="function"?e(p):p.toString(),u<1&&(t=requestAnimationFrame(i))};t&&cancelAnimationFrame(t),t=requestAnimationFrame(i)}class x extends d{constructor(r){super();this.props=r}effect(r,e){f(e,this.props.endValue,this.props.duration,this.props.formattingFunction)}}export{x as CounterUpModule};
@@ -1 +0,0 @@
1
- import{addDynamicClass as s}from"../ui";import{BaseModule as a}from"../modules";class y extends a{constructor(t){super();this.style=t}layoutEffect(t,e){s(e,this.style)}}export{y as DynamicClassModule};
@@ -1 +0,0 @@
1
- export*from"./centerModule";export*from"./counterUpModule";export*from"./typeModule";export*from"./styleModule";export*from"./dynamicClassModule";export*from"./attributesModule";export*from"./clickModule";
@@ -1 +0,0 @@
1
- import{BaseModule as a}from"../modules";class u extends a{constructor(o){super();this.style=o}applyStyle(o,t){for(const e of Object.keys(t))!isNaN(e)||typeof t[e]=="function"||(o.style[e]=t[e])}layoutEffect(o,t){this.applyStyle(t,this.style)}}export{u as StyleModule};
@@ -1 +0,0 @@
1
- import{BaseModule as d}from"../modules";function l(e,o){if(!e)throw new Error("Element not found");const t=e.textContent;e.textContent="\xA0",e.classList.add("zcCursor");let r,n;const s=u=>{r||(r=u);const c=u-r;let a=Math.min(c/o,1);const i=t.slice(0,parseInt(t.length*a));i.trim()!==""&&(e.textContent=i),a<1?n=requestAnimationFrame(s):setTimeout(()=>e.classList.remove("zcCursor"),o/t.length)};n=requestAnimationFrame(s)}class x extends d{constructor(t){super();this.props=t}effect(t,r){l(r,this.props.duration)}}export{x as TypeModule};