ziko 0.41.2 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sat Aug 23 2025 14:24:46 GMT+0100 (UTC+01:00)
5
+ Date : Sun Aug 24 2025 12:13:24 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -17,23 +17,23 @@
17
17
  const { PI: PI$2, E } = Math;
18
18
  const EPSILON=Number.EPSILON;
19
19
 
20
- const {PI: PI$1, cos: cos$2, sin: sin$2, tan: tan$1, acos: acos$2, asin: asin$1, atan: atan$1, cosh: cosh$1, sinh: sinh$1, tanh: tanh$1, acosh: acosh$1, asinh: asinh$1, atanh: atanh$1, log} = Math;
20
+ const {PI: PI$1, cos: cos$3, sin: sin$3, tan: tan$1, acos: acos$2, asin: asin$1, atan: atan$1, cosh: cosh$2, sinh: sinh$2, tanh: tanh$1, acosh: acosh$1, asinh: asinh$1, atanh: atanh$1, log: log$1} = Math;
21
21
  let Fixed={
22
- cos: cos$2,
23
- sin: sin$2,
22
+ cos: cos$3,
23
+ sin: sin$3,
24
24
  tan: tan$1,
25
- sinc: x => sin$2(PI$1*x)/(PI$1*x),
26
- sec: x => 1/cos$2(x),
27
- csc: x => 1/sin$2(x),
25
+ sinc: x => sin$3(PI$1*x)/(PI$1*x),
26
+ sec: x => 1/cos$3(x),
27
+ csc: x => 1/sin$3(x),
28
28
  cot: x => 1/tan$1(x),
29
29
  acos: acos$2,
30
30
  asin: asin$1,
31
31
  atan: atan$1,
32
32
  acot: x => PI$1/2-atan$1(x),
33
- cosh: cosh$1,
34
- sinh: sinh$1,
33
+ cosh: cosh$2,
34
+ sinh: sinh$2,
35
35
  tanh: tanh$1,
36
- coth: n => (1/2*log((1+n)/(1-n))),
36
+ coth: n => (1/2*log$1((1+n)/(1-n))),
37
37
  acosh: acosh$1,
38
38
  asinh: asinh$1,
39
39
  atanh: atanh$1,
@@ -67,20 +67,20 @@
67
67
  const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
68
68
  switch(fun){
69
69
  case Math.log: return complex(ln(z),phi); // Done
70
- case Math.exp: return complex(e(a)*cos$1(b),e(a)*sin$1(b)); // Done
70
+ case Math.exp: return complex(e(a)*cos$2(b),e(a)*sin$2(b)); // Done
71
71
  case Math.abs: return z; // Done
72
- case Math.sqrt: return complex(sqrt$1(z)*cos$1(phi/2),sqrt$1(z)*sin$1(phi/2)); // Done
73
- case Fixed.cos: return complex(cos$1(a)*cosh(b),-(sin$1(a)*sinh(b)));
74
- case Fixed.sin: return complex(sin$1(a)*cosh(b),cos$1(a)*sinh(b));
72
+ case Math.sqrt: return complex(sqrt$2(z)*cos$2(phi/2),sqrt$2(z)*sin$2(phi/2)); // Done
73
+ case Fixed.cos: return complex(cos$2(a)*cosh$1(b),-(sin$2(a)*sinh$1(b)));
74
+ case Fixed.sin: return complex(sin$2(a)*cosh$1(b),cos$2(a)*sinh$1(b));
75
75
  case Fixed.tan:{
76
- const DEN = cos$1(2*a)+cosh(2*b);
77
- return complex(sin$1(2*a)/DEN,sinh(2*b)/DEN);
76
+ const DEN = cos$2(2*a)+cosh$1(2*b);
77
+ return complex(sin$2(2*a)/DEN,sinh$1(2*b)/DEN);
78
78
  }
79
- case Fixed.cosh:return complex(cosh(a)*cos$1(b),sinh(a)*sin$1(b));
80
- case Fixed.sinh:return complex(sinh(a)*cos$1(b),cosh(a)*sin$1(b));
79
+ case Fixed.cosh:return complex(cosh$1(a)*cos$2(b),sinh$1(a)*sin$2(b));
80
+ case Fixed.sinh:return complex(sinh$1(a)*cos$2(b),cosh$1(a)*sin$2(b));
81
81
  case Fixed.tanh:{
82
- const DEN=cosh(2*a)+cos$1(2*b);
83
- return complex(sinh(2*a)/DEN,sin$1(2*b)/DEN)
82
+ const DEN=cosh$1(2*a)+cos$2(2*b);
83
+ return complex(sinh$1(2*a)/DEN,sin$2(2*b)/DEN)
84
84
  }
85
85
  default : return fun(x)
86
86
  }
@@ -951,6 +951,21 @@
951
951
  }
952
952
  };
953
953
 
954
+ async function fetchdom(url='https://github.com/zakarialaoui10'){
955
+ const data=await fetch(url);
956
+ const html=await data.text();
957
+ const dom= new DOMParser().parseFromString(html,'text/xml');
958
+ return dom.documentElement
959
+ }
960
+ function fetchdomSync(url='https://github.com/zakarialaoui10'){
961
+ const data=preload(url);
962
+ const dom= new DOMParser().parseFromString(data,'text/xml');
963
+ return dom.documentElement;
964
+ }
965
+
966
+ globalThis.fetchdom=fetchdom;
967
+ globalThis.fetchdomSync=fetchdomSync;
968
+
954
969
  const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
955
970
  const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
956
971
  const csv2object = (csv, delimiter = ",") => {
@@ -1106,59 +1121,180 @@
1106
1121
  else register_to_instance(target, ...mixins);
1107
1122
  };
1108
1123
 
1124
+ function parseQueryParams$1(queryString) {
1125
+ const params = {};
1126
+ queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
1127
+ const [key, value] = match.split('=');
1128
+ params[key] = value;
1129
+ });
1130
+ return params;
1131
+ }
1132
+
1133
+ function defineParamsGetter$1(target ){
1134
+ Object.defineProperties(target, {
1135
+ 'QueryParams': {
1136
+ get: function() {
1137
+ return parseQueryParams$1(globalThis.location.search.substring(1));
1138
+ },
1139
+ configurable: false,
1140
+ enumerable: true
1141
+ },
1142
+ 'HashParams': {
1143
+ get: function() {
1144
+ const hash = globalThis.location.hash.substring(1);
1145
+ return hash.split("#");
1146
+ },
1147
+ configurable: false,
1148
+ enumerable: true
1149
+ }
1150
+ });
1151
+ }
1152
+
1153
+ const __UI__={
1154
+ __all__(){
1155
+ return Object.values(this)
1156
+ .filter(Array.isArray)
1157
+ .flat();
1158
+ },
1159
+ querySelectorAll(){
1160
+ return this.__all__().filter(n=>n)
1161
+ },
1162
+ getElementByIndex(index){
1163
+ return this.__all__().find(n=>n.ui_index===index);
1164
+ },
1165
+ getElementById(id){
1166
+ return null;
1167
+ },
1168
+ getElementsByClass(){
1169
+
1170
+ },
1171
+ getElementsByTagName(){
1172
+
1173
+ }
1174
+ };
1175
+
1176
+ const __Config__ = {
1177
+ default:{
1178
+ target:null,
1179
+ render:true,
1180
+ math:{
1181
+ mode:"deg"
1182
+ }
1183
+ },
1184
+ setDefault:function(pairs){
1185
+ const keys=Object.keys(pairs);
1186
+ const values=Object.values(pairs);
1187
+ for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
1188
+ },
1189
+ init:()=>{
1190
+ // document.documentElement.setAttribute("data-engine","zikojs")
1191
+ },
1192
+ renderingMode :"spa",
1193
+ isSSC : false,
1194
+ };
1195
+
1196
+ const __HYDRATION__ = {
1197
+ map : new Map(),
1198
+ index : 0,
1199
+ increment : function(){
1200
+ return this.index ++
1201
+ }
1202
+ };
1203
+
1204
+ const __CACHE__ = {
1205
+ ui_index : 0,
1206
+ get_ui_index:function(){
1207
+ return this.ui_index ++
1208
+ }
1209
+ };
1210
+
1211
+ const __State__ = {
1212
+ store : new Map(),
1213
+ index : undefined?.data?.__Ziko__?.__State__?.index ?? 0,
1214
+ register: function(state){
1215
+ console.log({
1216
+ hmr : undefined?.data.__Ziko__.__State__.index,
1217
+ index : this.index
1218
+ });
1219
+ this.store.set(this.index++, state);
1220
+ }
1221
+
1222
+ };
1223
+
1224
+ function __init__global__(){
1225
+ if ( !globalThis?.__Ziko__ ){
1226
+ globalThis.__Ziko__ = {
1227
+ __UI__,
1228
+ __HYDRATION__,
1229
+ __State__,
1230
+ // __HYDRATION_MAP__,
1231
+ __Config__,
1232
+ __CACHE__,
1233
+ };
1234
+ defineParamsGetter$1(__Ziko__);
1235
+ }
1236
+ }
1237
+
1238
+ if(!globalThis.__Ziko__) __init__global__();
1239
+
1240
+ // HMR persistence
1241
+ if (undefined) {
1242
+ undefined.data.__Ziko__ = undefined.data.__Ziko__ || globalThis.__Ziko__;
1243
+ globalThis.__Ziko__ = undefined.data.__Ziko__;
1244
+ // import.meta.hot.accept(n=>console.log(n));
1245
+ // console.log(import.meta.hot.data.__Ziko__.__State__.store)
1246
+ }
1247
+
1248
+
1249
+
1109
1250
  function useState(initialValue) {
1110
- let value = initialValue;
1111
- const subscribers = new Set();
1112
- let paused = false;
1251
+
1252
+ // console.log(import.meta.hot.data.__Ziko__.__State__.store.get(0))
1253
+
1254
+ const {store, index} = __Ziko__.__State__;
1255
+ __Ziko__.__State__.register({
1256
+ value : initialValue,
1257
+ subscribers : new Set(),
1258
+ paused : false
1259
+ });
1260
+
1261
+ const current = store.get(index);
1113
1262
 
1114
1263
  function getValue() {
1115
1264
  return {
1116
- value,
1265
+ value: current.value,
1117
1266
  isStateGetter: () => true,
1118
- _subscribe: (
1119
- fn,
1120
- // UIElement
1121
- ) => {
1122
- subscribers.add(fn);
1123
-
1124
- // const observer = new MutationObserver(() => {
1125
- // if (!document.body.contains(UIElement.element)) {
1126
- // subscribers.delete(fn);
1127
- // observer.disconnect();
1128
- // }
1129
- // });
1130
-
1131
- // observer.observe(document.body, { childList: true, subtree: true });
1132
- },
1267
+ _subscribe: (fn) => current.subscribers.add(fn),
1133
1268
  };
1134
1269
  }
1135
1270
 
1136
1271
  function setValue(newValue) {
1137
- if (paused) return;
1138
- if (typeof newValue === "function") newValue = newValue(value);
1139
- if (newValue !== value) {
1140
- value = newValue;
1141
- subscribers.forEach(fn => fn(value));
1272
+ if (current.paused) return;
1273
+ if (typeof newValue === "function") newValue = newValue(current.value);
1274
+ if (newValue !== current.value) {
1275
+ current.value = newValue;
1276
+ current.subscribers.forEach(fn => fn(current.value));
1142
1277
  }
1143
1278
  }
1144
1279
 
1145
1280
  const controller = {
1146
- pause: () => { paused = true; },
1147
- resume: () => { paused = false; },
1148
- clear: () => { subscribers.clear(); },
1149
- force: (newValue) => { // force update even if paused
1150
- if (typeof newValue === "function") newValue = newValue(value);
1151
- value = newValue;
1152
- subscribers.forEach(fn => fn(value));
1281
+ pause: () => { current.paused = true; },
1282
+ resume: () => { current.paused = false; },
1283
+ clear: () => { current.subscribers.clear(); },
1284
+ force: (newValue) => {
1285
+ if (typeof newValue === "function") newValue = newValue(current.value);
1286
+ current.value = newValue;
1287
+ current.subscribers.forEach(fn => fn(current.value));
1153
1288
  },
1154
- getSubscribers: () => new Set(subscribers),
1289
+ getSubscribers: () => new Set(current.subscribers),
1155
1290
  };
1156
1291
 
1157
1292
  return [getValue, setValue, controller];
1158
1293
  }
1159
1294
 
1295
+
1160
1296
  const isStateGetter = (arg) => {
1161
- return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
1297
+ return typeof arg === 'function' && arg?.()?.isStateGetter?.();
1162
1298
  };
1163
1299
 
1164
1300
  const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
@@ -2737,107 +2873,6 @@
2737
2873
 
2738
2874
  const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
2739
2875
 
2740
- function parseQueryParams$1(queryString) {
2741
- const params = {};
2742
- queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
2743
- const [key, value] = match.split('=');
2744
- params[key] = value;
2745
- });
2746
- return params;
2747
- }
2748
-
2749
- function defineParamsGetter$1(target ){
2750
- Object.defineProperties(target, {
2751
- 'QueryParams': {
2752
- get: function() {
2753
- return parseQueryParams$1(globalThis.location.search.substring(1));
2754
- },
2755
- configurable: false,
2756
- enumerable: true
2757
- },
2758
- 'HashParams': {
2759
- get: function() {
2760
- const hash = globalThis.location.hash.substring(1);
2761
- return hash.split("#");
2762
- },
2763
- configurable: false,
2764
- enumerable: true
2765
- }
2766
- });
2767
- }
2768
-
2769
- const __UI__={
2770
- __all__(){
2771
- return Object.values(this)
2772
- .filter(Array.isArray)
2773
- .flat();
2774
- },
2775
- querySelectorAll(){
2776
- return this.__all__().filter(n=>n)
2777
- },
2778
- getElementByIndex(index){
2779
- return this.__all__().find(n=>n.ui_index===index);
2780
- },
2781
- getElementById(id){
2782
- return null;
2783
- },
2784
- getElementsByClass(){
2785
-
2786
- },
2787
- getElementsByTagName(){
2788
-
2789
- }
2790
- };
2791
-
2792
- const __Config__ = {
2793
- default:{
2794
- target:null,
2795
- render:true,
2796
- math:{
2797
- mode:"deg"
2798
- }
2799
- },
2800
- setDefault:function(pairs){
2801
- const keys=Object.keys(pairs);
2802
- const values=Object.values(pairs);
2803
- for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
2804
- },
2805
- init:()=>{
2806
- // document.documentElement.setAttribute("data-engine","zikojs")
2807
- },
2808
- renderingMode :"spa",
2809
- isSSC : false,
2810
- };
2811
-
2812
- const __HYDRATION__ = {
2813
- map : new Map(),
2814
- index : 0,
2815
- increment : function(){
2816
- return this.index ++
2817
- }
2818
- };
2819
- const __HYDRATION_MAP__ = new Map();
2820
-
2821
- const __CACHE__ = {
2822
- ui_index : 0,
2823
- get_ui_index:function(){
2824
- return this.ui_index ++
2825
- }
2826
- };
2827
-
2828
- function __init__global__(){
2829
- if ( !globalThis?.__Ziko__ ){
2830
- globalThis.__Ziko__ = {
2831
- __UI__,
2832
- __HYDRATION__,
2833
- __HYDRATION_MAP__,
2834
- __Config__,
2835
- __CACHE__,
2836
- };
2837
- defineParamsGetter$1(__Ziko__);
2838
- }
2839
- }
2840
-
2841
2876
  __init__global__();
2842
2877
  class UIElement extends UINode{
2843
2878
  constructor({element, name ='', type="html", useDefaultStyle=false}={}){
@@ -3660,7 +3695,15 @@
3660
3695
 
3661
3696
  const Svg =(w,h)=>new ZikoUISvg(w,h);
3662
3697
 
3663
- function defineWC(name, UIElement, props = {}, { mode = 'open'} = {}) {
3698
+ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
3699
+ if (globalThis.customElements?.get(name)) {
3700
+ console.warn(`Custom element "${name}" is already defined`);
3701
+ return; // skip redefinition
3702
+ }
3703
+ if(name.search('-') === -1){
3704
+ console.warn(`"${name}" is not a valid custom element name`);
3705
+ return;
3706
+ }
3664
3707
  globalThis.customElements?.define(
3665
3708
  name,
3666
3709
  class extends HTMLElement {
@@ -4522,7 +4565,7 @@
4522
4565
  }
4523
4566
  else if(("a" in b && "z" in a)){
4524
4567
  this.a=a.a;
4525
- this.b=sqrt$1((a.z**2)-(a.a**2));
4568
+ this.b=sqrt$2((a.z**2)-(a.a**2));
4526
4569
  }
4527
4570
  else if(("a" in b && "phi" in a)){
4528
4571
  this.a=a.a;
@@ -4530,15 +4573,15 @@
4530
4573
  }
4531
4574
  else if(("b" in b && "z" in a)){
4532
4575
  this.b=a.b;
4533
- this.a=sqrt$1((a.z**2)-(a.b**2));
4576
+ this.a=sqrt$2((a.z**2)-(a.b**2));
4534
4577
  }
4535
4578
  else if(("b" in b && "phi" in a)){
4536
4579
  this.b=b;
4537
4580
  this.a=a.b/tan(a.phi);
4538
4581
  }
4539
4582
  else if(("z" in b && "phi" in a)){
4540
- this.a=a.z*cos$1(a.phi);
4541
- this.a=a.z*sin$1(a.phi);
4583
+ this.a=a.z*cos$2(a.phi);
4584
+ this.a=a.z*sin$2(a.phi);
4542
4585
  }
4543
4586
  }
4544
4587
  else if(typeof(a)==="number"&&typeof(b)==="number"){
@@ -4606,8 +4649,8 @@
4606
4649
  }
4607
4650
  let Z=+prod(this.z,...z.map(n=>n.z)).toFixed(15);
4608
4651
  let phi=+sum(this.phi,...z.map(n=>n.phi)).toFixed(15);
4609
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(14);
4610
- this.b=+(Z*sin$1(phi).toFixed(15)).toFixed(14);
4652
+ this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(14);
4653
+ this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(14);
4611
4654
  return this;
4612
4655
  }
4613
4656
  div(...z) {
@@ -4616,23 +4659,23 @@
4616
4659
  }
4617
4660
  let Z=+(this.z/prod(...z.map(n=>n.z))).toFixed(15);
4618
4661
  let phi=+(this.phi-sum(...z.map(n=>n.phi))).toFixed(15);
4619
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(15);
4620
- this.b=+(Z*sin$1(phi).toFixed(15)).toFixed(15);
4662
+ this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(15);
4663
+ this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(15);
4621
4664
  return this;
4622
4665
  }
4623
4666
  pow(n) {
4624
4667
  if (floor(n) === n && n > 0) {
4625
4668
  let z=+(this.z**n).toFixed(15);
4626
4669
  let phi=+(this.phi*n).toFixed(15);
4627
- this.a=+(z*cos$1(phi).toFixed(15)).toFixed(15);
4628
- this.b=+(z*sin$1(phi).toFixed(15)).toFixed(15);
4670
+ this.a=+(z*cos$2(phi).toFixed(15)).toFixed(15);
4671
+ this.b=+(z*sin$2(phi).toFixed(15)).toFixed(15);
4629
4672
  }
4630
4673
  return this;
4631
4674
  }
4632
4675
  static fromExpo(z, phi) {
4633
4676
  return new Complex(
4634
- +(z * cos$1(phi)).toFixed(13),
4635
- +(z * sin$1(phi)).toFixed(13)
4677
+ +(z * cos$2(phi)).toFixed(13),
4678
+ +(z * sin$2(phi)).toFixed(13)
4636
4679
  );
4637
4680
  }
4638
4681
  get expo() {
@@ -4654,10 +4697,10 @@
4654
4697
  return z.clone.pow(n);
4655
4698
  }
4656
4699
  static xpowZ(x){
4657
- return complex((x**this.a)*cos$1(this.b*ln(x)),(x**this.a)*sin$1(this.b*ln(x)));
4700
+ return complex((x**this.a)*cos$2(this.b*ln(x)),(x**this.a)*sin$2(this.b*ln(x)));
4658
4701
  }
4659
4702
  sqrtn(n=2){
4660
- return complex(sqrtn(this.z,n)*cos$1(this.phi/n),sqrtn(this.z,n)*sin$1(this.phi/n));
4703
+ return complex(sqrtn(this.z,n)*cos$2(this.phi/n),sqrtn(this.z,n)*sin$2(this.phi/n));
4661
4704
  }
4662
4705
  get sqrt(){
4663
4706
  return this.sqrtn(2);
@@ -4666,14 +4709,14 @@
4666
4709
  return complex(this.z,this.phi);
4667
4710
  }
4668
4711
  get cos(){
4669
- return complex(cos$1(this.a)*cosh(this.b),sin$1(this.a)*sinh(this.b))
4712
+ return complex(cos$2(this.a)*cosh$1(this.b),sin$2(this.a)*sinh$1(this.b))
4670
4713
  }
4671
4714
  get sin(){
4672
- return complex(sin$1(this.a)*cosh(this.b),cos$1(this.a)*sinh(this.b))
4715
+ return complex(sin$2(this.a)*cosh$1(this.b),cos$2(this.a)*sinh$1(this.b))
4673
4716
  }
4674
4717
  get tan(){
4675
- const de=cos$1(this.a*2)+cosh(this.b*2);
4676
- return complex(sin$1(2*this.a)/de,sinh(2*this.b)/de);
4718
+ const de=cos$2(this.a*2)+cosh$1(this.b*2);
4719
+ return complex(sin$2(2*this.a)/de,sinh$1(2*this.b)/de);
4677
4720
  }
4678
4721
  printInConsole() {
4679
4722
  let string = this.a + " + " + this.b + " * i";
@@ -4704,7 +4747,7 @@
4704
4747
  // } from "../calculus/index.js";
4705
4748
 
4706
4749
  const abs=(...x)=>mapfun$1(Math.abs,...x);
4707
- const sqrt$1=(...x)=>mapfun$1(Math.sqrt,...x);
4750
+ const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
4708
4751
  const pow$1=(x,n)=>{
4709
4752
  if(typeof x === "number"){
4710
4753
  if(typeof n === "number")return Math.pow(x,n);
@@ -4752,8 +4795,8 @@
4752
4795
  };
4753
4796
  const e=(...x) => mapfun$1(Math.exp,...x);
4754
4797
  const ln=(...x) => mapfun$1(Math.log,...x);
4755
- const cos$1=(...x) => mapfun$1(Fixed.cos,...x);
4756
- const sin$1=(...x) => mapfun$1(Fixed.sin,...x);
4798
+ const cos$2=(...x) => mapfun$1(Fixed.cos,...x);
4799
+ const sin$2=(...x) => mapfun$1(Fixed.sin,...x);
4757
4800
  const tan=(...x) => mapfun$1(Fixed.tan,...x);
4758
4801
  const sec=(...x) => mapfun$1(Fixed.sec,...x);
4759
4802
  const sinc=(...x) => mapfun$1(Fixed.sinc,...x);
@@ -4763,8 +4806,8 @@
4763
4806
  const asin=(...x) => mapfun$1(Fixed.asin,...x);
4764
4807
  const atan=(...x) => mapfun$1(Fixed.atan,...x);
4765
4808
  const acot=(...x) => mapfun$1(Fixed.acot,...x);
4766
- const cosh=(...x) => mapfun$1(Fixed.cosh,...x);
4767
- const sinh=(...x) => mapfun$1(Fixed.sinh,...x);
4809
+ const cosh$1=(...x) => mapfun$1(Fixed.cosh,...x);
4810
+ const sinh$1=(...x) => mapfun$1(Fixed.sinh,...x);
4768
4811
  const tanh=(...x) => mapfun$1(Fixed.tanh,...x);
4769
4812
  const coth=(...x) => mapfun$1(Fixed.coth,...x);
4770
4813
  const acosh=(...x) => mapfun$1(Fixed.acosh,...x);
@@ -4813,12 +4856,12 @@
4813
4856
  )
4814
4857
  };
4815
4858
 
4816
- const {PI, sqrt, cos, sin, acos, pow} = Math;
4859
+ const {PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow} = Math;
4817
4860
 
4818
4861
  const Linear = t => t;
4819
- const InSin = t => 1 - cos((t * PI) / 2);
4820
- const OutSin = t => sin((t * PI) / 2);
4821
- const InOutSin = t => -(cos(PI * t) - 1) / 2;
4862
+ const InSin = t => 1 - cos$1((t * PI) / 2);
4863
+ const OutSin = t => sin$1((t * PI) / 2);
4864
+ const InOutSin = t => -(cos$1(PI * t) - 1) / 2;
4822
4865
 
4823
4866
  const InQuad = t => t**2;
4824
4867
  const OutQuad = t => 1 - (1-t)**2;
@@ -4840,13 +4883,13 @@
4840
4883
  const OutExpo = t => t === 1 ? 1 : 1 - 2**(-10 * t);
4841
4884
  const InOutExpo = t => t === 0? 0: t === 1? 1: t < 0.5 ? 2**(20 * t - 10) / 2: (2 - 2**(-20 * t + 10)) / 2;
4842
4885
 
4843
- const InCirc = t => 1 - sqrt(1 - t**2);
4844
- const OutCirc = t => sqrt(1 - (t-1)**2);
4845
- const InOutCirc = t => t < 0.5? (1 - sqrt(1 - (2*t)**2)) / 2: (sqrt(1 - (-2*t+2)**2) + 1) / 2;
4886
+ const InCirc = t => 1 - sqrt$1(1 - t**2);
4887
+ const OutCirc = t => sqrt$1(1 - (t-1)**2);
4888
+ const InOutCirc = t => t < 0.5? (1 - sqrt$1(1 - (2*t)**2)) / 2: (sqrt$1(1 - (-2*t+2)**2) + 1) / 2;
4846
4889
 
4847
- const Arc = t => 1 - sin(acos(t));
4890
+ const Arc = t => 1 - sin$1(acos(t));
4848
4891
  const Back = (t, x = 1) => (t**2) * ((x+1)*t - x);
4849
- const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos(20 * PI * t / 3 * t);
4892
+ const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos$1(20 * PI * t / 3 * t);
4850
4893
 
4851
4894
  const InBack = (t, c1 = 1.70158, c3 = c1 + 1) => c3 * pow(t,3)- c1 * (t**2);
4852
4895
  const OutBack = (t, c1 = 1.70158, c3 = c1 + 1) => 1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
@@ -4857,7 +4900,7 @@
4857
4900
  ? 0
4858
4901
  : t === 1
4859
4902
  ? 1
4860
- : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
4903
+ : -pow(2, 10 * t - 10) * sin$1((t * 10 - 10.75) * c4);
4861
4904
  };
4862
4905
 
4863
4906
  const OutElastic = (t, c4 = 2*PI/3) => {
@@ -4865,7 +4908,7 @@
4865
4908
  ? 0
4866
4909
  : t === 1
4867
4910
  ? 1
4868
- : pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
4911
+ : pow(2, -10 * t) * sin$1((t * 10 - 0.75) * c4) + 1;
4869
4912
  };
4870
4913
  const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4871
4914
  return t === 0
@@ -4873,8 +4916,8 @@
4873
4916
  : t === 1
4874
4917
  ? 1
4875
4918
  : t < 0.5
4876
- ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
4877
- : (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
4919
+ ? -(pow(2, 20 * t - 10) * sin$1((20 * t - 11.125) * c5)) / 2
4920
+ : (pow(2, -20 * t + 10) * sin$1((20 * t - 11.125) * c5)) / 2 + 1;
4878
4921
  };
4879
4922
 
4880
4923
  const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
@@ -4982,17 +5025,28 @@
4982
5025
  new TimeAnimation(callback, {ease, t0, t1, start, duration});
4983
5026
 
4984
5027
  class Tick {
4985
- constructor(ms, fn) {
5028
+ constructor(fn, ms, count = Infinity, start) {
4986
5029
  this.ms = ms;
4987
5030
  this.fn = fn;
5031
+ this.count = count;
5032
+ this.frame = 1;
4988
5033
  this.id = null;
4989
5034
  this.running = false;
5035
+ if(start) this.start();
4990
5036
  }
4991
5037
 
4992
5038
  start() {
4993
5039
  if (!this.running) {
4994
5040
  this.running = true;
4995
- this.id = setInterval(this.fn, this.ms);
5041
+ this.frame = 1;
5042
+ this.id = setInterval(() => {
5043
+ if (this.frame > this.count) {
5044
+ this.stop();
5045
+ return;
5046
+ }
5047
+ this.fn.call(null, this);
5048
+ this.frame++;
5049
+ }, this.ms);
4996
5050
  }
4997
5051
  return this;
4998
5052
  }
@@ -5010,7 +5064,9 @@
5010
5064
  return this.running;
5011
5065
  }
5012
5066
  }
5013
- const tick = (ms, fn) => new Tick(ms, fn);
5067
+
5068
+ // Helper factory
5069
+ const tick = (fn, ms, count = Infinity, start = true) => new Tick(fn, ms, count, start);
5014
5070
 
5015
5071
  class Clock extends Tick {
5016
5072
  constructor(tickMs = 1000 / 60) {
@@ -5142,7 +5198,8 @@
5142
5198
  const step_fps = (step_or_fps) => 1000 / step_or_fps;
5143
5199
 
5144
5200
  const debounce=(fn,delay=1000)=>{
5145
- return (...args) => setTimeout(()=>fn(...args),delay);
5201
+ let id;
5202
+ return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
5146
5203
  };
5147
5204
  const throttle=(fn,delay)=>{
5148
5205
  let lastTime=0;
@@ -5547,57 +5604,37 @@
5547
5604
  function useDerived(deriveFn, sources) {
5548
5605
  let value = deriveFn(...sources.map(s => s().value));
5549
5606
  const subscribers = new Set();
5550
- let paused = false;
5551
5607
 
5552
- function getValue() {
5553
- return {
5554
- value,
5555
- isStateGetter: () => true,
5556
- _subscribe: (fn) => {
5557
- subscribers.add(fn);
5558
- },
5559
- };
5560
- }
5561
-
5562
- function setValue(newValue) {
5563
- if (paused) return;
5564
- if (typeof newValue === "function") newValue = newValue(value);
5565
- if (newValue !== value) {
5566
- value = newValue;
5567
- subscribers.forEach(fn => fn(value));
5568
- }
5569
- }
5570
-
5571
- const controller = {
5572
- pause: () => { paused = true; },
5573
- resume: () => { paused = false; },
5574
- clear: () => { subscribers.clear(); },
5575
- force: (newValue) => {
5576
- if (typeof newValue === "function") newValue = newValue(value);
5577
- value = newValue;
5578
- subscribers.forEach(fn => fn(value));
5579
- },
5580
- getSubscribers: () => new Set(subscribers),
5581
- };
5582
-
5583
- // Subscribe to source states
5584
5608
  sources.forEach(source => {
5585
5609
  const srcValue = source(); // getValue()
5586
5610
  srcValue._subscribe(() => {
5587
- if (!paused) {
5611
+ {
5588
5612
  const newVal = deriveFn(...sources.map(s => s().value));
5589
5613
  if (newVal !== value) {
5590
5614
  value = newVal;
5591
5615
  subscribers.forEach(fn => fn(value));
5592
5616
  }
5593
5617
  }
5594
- }, { element: document.body }); // dummy UIElement
5618
+ });
5595
5619
  });
5596
-
5597
- return [getValue, setValue, controller];
5620
+ return () => ({
5621
+ value,
5622
+ isStateGetter : () => true,
5623
+ _subscribe: (fn) => subscribers.add(fn)
5624
+ })
5598
5625
  }
5599
5626
 
5600
- const useReactive = (nested_value) => mapfun$1(n => useState(n), nested_value);
5627
+ const useReactive = (nested_value) => mapfun$1(
5628
+ n => {
5629
+ const state = useState(n);
5630
+ // console.log(state)
5631
+ return {
5632
+ get : state[0],
5633
+ set : state[1],
5634
+ }
5635
+ },
5636
+ nested_value
5637
+ );
5601
5638
 
5602
5639
  class ZikoUseChannel{
5603
5640
  constructor(name = ""){
@@ -5833,6 +5870,65 @@
5833
5870
  const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
5834
5871
  const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
5835
5872
 
5873
+ let {sqrt, cos, sin, exp, log, cosh, sinh} = Math;
5874
+ // Math.abs = new Proxy(Math.abs, {
5875
+ // apply(target, thisArg, args) {
5876
+ // const x = args[0]
5877
+ // if(typeof x === 'number') return target.apply(thisArg, args);
5878
+ // if(x?.isComplex?.()){
5879
+ // const {a, b, z, phi} = x
5880
+ // const complex = (a, b) => new x.constructor(a, b)
5881
+ // switch(target.name){
5882
+ // case 'abs' : return a.z;
5883
+ // case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
5884
+ // }
5885
+ // }
5886
+
5887
+ // }
5888
+ // });
5889
+
5890
+
5891
+ for (const key of Object.getOwnPropertyNames(Math)) {
5892
+ const fn = Math[key];
5893
+ if (typeof fn === "function") {
5894
+ Math[key] = new Proxy(fn, {
5895
+ apply(target, thisArg, args) {
5896
+ // console.log(target)
5897
+ const x = args[0];
5898
+ if(typeof x === 'number' || args.length === 0) return target.apply(thisArg, args);
5899
+ if(x?.isComplex?.()){
5900
+ const {a, b, z, phi} = x;
5901
+ const complex = (a, b) => new x.constructor(a, b);
5902
+ switch(target.name){
5903
+ case 'abs' : return x.z;
5904
+ case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
5905
+ case 'log' : return complex(log(z), phi);
5906
+ case 'exp' : return complex(exp(a)*cos(b),exp(a)*sin(b));
5907
+ case 'cos' : return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
5908
+ case 'sin' : return complex(sin(a)*cosh(b),cos(a)*sinh(b));
5909
+ case 'tan' : {
5910
+ const DEN = cos(2*a)+cosh(2*b);
5911
+ return complex(sin(2*a) /DEN, sinh(2*b)/DEN);
5912
+ }
5913
+ case 'cosh' : return complex(cosh(a)*cos(b),sinh(a)*sin(b));
5914
+ case 'sinh' : return complex(sinh(a)*cos(b),cosh(a)*sin(b));
5915
+ case 'tanh' : {
5916
+ const DEN=cosh(2*a)+cos(2*b);
5917
+ return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
5918
+ }
5919
+ default : return target.apply(thisArg, args)
5920
+ }
5921
+ }
5922
+ // if( x.isMatrix?.()){
5923
+ // const {rows, cols, arr} = x
5924
+ // // return new x.constructor(rows, cols, arr.flat(1).map(n=>));
5925
+ // }
5926
+ throw new TypeError(`Math.${key} expects only numbers`);
5927
+ }
5928
+ });
5929
+ }
5930
+ }
5931
+
5836
5932
  if(globalThis?.document){
5837
5933
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5838
5934
  }
@@ -5961,8 +6057,8 @@
5961
6057
  exports.clock = clock;
5962
6058
  exports.combinaison = combinaison;
5963
6059
  exports.complex = complex;
5964
- exports.cos = cos$1;
5965
- exports.cosh = cosh;
6060
+ exports.cos = cos$2;
6061
+ exports.cosh = cosh$1;
5966
6062
  exports.cot = cot;
5967
6063
  exports.coth = coth;
5968
6064
  exports.csc = csc;
@@ -5973,7 +6069,7 @@
5973
6069
  exports.csv2sql = csv2sql;
5974
6070
  exports.debounce = debounce;
5975
6071
  exports.defineParamsGetter = defineParamsGetter;
5976
- exports.defineWC = defineWC;
6072
+ exports.define_wc = define_wc;
5977
6073
  exports.deg2rad = deg2rad;
5978
6074
  exports.div = div;
5979
6075
  exports.e = e;
@@ -6023,11 +6119,11 @@
6023
6119
  exports.sec = sec;
6024
6120
  exports.sig = sig;
6025
6121
  exports.sign = sign;
6026
- exports.sin = sin$1;
6122
+ exports.sin = sin$2;
6027
6123
  exports.sinc = sinc;
6028
- exports.sinh = sinh;
6124
+ exports.sinh = sinh$1;
6029
6125
  exports.sleep = sleep;
6030
- exports.sqrt = sqrt$1;
6126
+ exports.sqrt = sqrt$2;
6031
6127
  exports.sqrtn = sqrtn;
6032
6128
  exports.step_fps = step_fps;
6033
6129
  exports.sub = sub;