ziko 0.41.1 → 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.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Aug 22 2025 10:51:33 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
@@ -11,23 +11,23 @@
11
11
  const { PI: PI$2, E } = Math;
12
12
  const EPSILON=Number.EPSILON;
13
13
 
14
- 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;
14
+ 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;
15
15
  let Fixed={
16
- cos: cos$2,
17
- sin: sin$2,
16
+ cos: cos$3,
17
+ sin: sin$3,
18
18
  tan: tan$1,
19
- sinc: x => sin$2(PI$1*x)/(PI$1*x),
20
- sec: x => 1/cos$2(x),
21
- csc: x => 1/sin$2(x),
19
+ sinc: x => sin$3(PI$1*x)/(PI$1*x),
20
+ sec: x => 1/cos$3(x),
21
+ csc: x => 1/sin$3(x),
22
22
  cot: x => 1/tan$1(x),
23
23
  acos: acos$2,
24
24
  asin: asin$1,
25
25
  atan: atan$1,
26
26
  acot: x => PI$1/2-atan$1(x),
27
- cosh: cosh$1,
28
- sinh: sinh$1,
27
+ cosh: cosh$2,
28
+ sinh: sinh$2,
29
29
  tanh: tanh$1,
30
- coth: n => (1/2*log((1+n)/(1-n))),
30
+ coth: n => (1/2*log$1((1+n)/(1-n))),
31
31
  acosh: acosh$1,
32
32
  asinh: asinh$1,
33
33
  atanh: atanh$1,
@@ -61,20 +61,20 @@ const mapfun$1=(fun,...X)=>{
61
61
  const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
62
62
  switch(fun){
63
63
  case Math.log: return complex(ln(z),phi); // Done
64
- case Math.exp: return complex(e(a)*cos$1(b),e(a)*sin$1(b)); // Done
64
+ case Math.exp: return complex(e(a)*cos$2(b),e(a)*sin$2(b)); // Done
65
65
  case Math.abs: return z; // Done
66
- case Math.sqrt: return complex(sqrt$1(z)*cos$1(phi/2),sqrt$1(z)*sin$1(phi/2)); // Done
67
- case Fixed.cos: return complex(cos$1(a)*cosh(b),-(sin$1(a)*sinh(b)));
68
- case Fixed.sin: return complex(sin$1(a)*cosh(b),cos$1(a)*sinh(b));
66
+ case Math.sqrt: return complex(sqrt$2(z)*cos$2(phi/2),sqrt$2(z)*sin$2(phi/2)); // Done
67
+ case Fixed.cos: return complex(cos$2(a)*cosh$1(b),-(sin$2(a)*sinh$1(b)));
68
+ case Fixed.sin: return complex(sin$2(a)*cosh$1(b),cos$2(a)*sinh$1(b));
69
69
  case Fixed.tan:{
70
- const DEN = cos$1(2*a)+cosh(2*b);
71
- return complex(sin$1(2*a)/DEN,sinh(2*b)/DEN);
70
+ const DEN = cos$2(2*a)+cosh$1(2*b);
71
+ return complex(sin$2(2*a)/DEN,sinh$1(2*b)/DEN);
72
72
  }
73
- case Fixed.cosh:return complex(cosh(a)*cos$1(b),sinh(a)*sin$1(b));
74
- case Fixed.sinh:return complex(sinh(a)*cos$1(b),cosh(a)*sin$1(b));
73
+ case Fixed.cosh:return complex(cosh$1(a)*cos$2(b),sinh$1(a)*sin$2(b));
74
+ case Fixed.sinh:return complex(sinh$1(a)*cos$2(b),cosh$1(a)*sin$2(b));
75
75
  case Fixed.tanh:{
76
- const DEN=cosh(2*a)+cos$1(2*b);
77
- return complex(sinh(2*a)/DEN,sin$1(2*b)/DEN)
76
+ const DEN=cosh$1(2*a)+cos$2(2*b);
77
+ return complex(sinh$1(2*a)/DEN,sin$2(2*b)/DEN)
78
78
  }
79
79
  default : return fun(x)
80
80
  }
@@ -945,6 +945,21 @@ const preload=(url)=>{
945
945
  }
946
946
  };
947
947
 
948
+ async function fetchdom(url='https://github.com/zakarialaoui10'){
949
+ const data=await fetch(url);
950
+ const html=await data.text();
951
+ const dom= new DOMParser().parseFromString(html,'text/xml');
952
+ return dom.documentElement
953
+ }
954
+ function fetchdomSync(url='https://github.com/zakarialaoui10'){
955
+ const data=preload(url);
956
+ const dom= new DOMParser().parseFromString(data,'text/xml');
957
+ return dom.documentElement;
958
+ }
959
+
960
+ globalThis.fetchdom=fetchdom;
961
+ globalThis.fetchdomSync=fetchdomSync;
962
+
948
963
  const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
949
964
  const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
950
965
  const csv2object = (csv, delimiter = ",") => {
@@ -1100,59 +1115,180 @@ const register = (target, ...mixins) => {
1100
1115
  else register_to_instance(target, ...mixins);
1101
1116
  };
1102
1117
 
1118
+ function parseQueryParams$1(queryString) {
1119
+ const params = {};
1120
+ queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
1121
+ const [key, value] = match.split('=');
1122
+ params[key] = value;
1123
+ });
1124
+ return params;
1125
+ }
1126
+
1127
+ function defineParamsGetter$1(target ){
1128
+ Object.defineProperties(target, {
1129
+ 'QueryParams': {
1130
+ get: function() {
1131
+ return parseQueryParams$1(globalThis.location.search.substring(1));
1132
+ },
1133
+ configurable: false,
1134
+ enumerable: true
1135
+ },
1136
+ 'HashParams': {
1137
+ get: function() {
1138
+ const hash = globalThis.location.hash.substring(1);
1139
+ return hash.split("#");
1140
+ },
1141
+ configurable: false,
1142
+ enumerable: true
1143
+ }
1144
+ });
1145
+ }
1146
+
1147
+ const __UI__={
1148
+ __all__(){
1149
+ return Object.values(this)
1150
+ .filter(Array.isArray)
1151
+ .flat();
1152
+ },
1153
+ querySelectorAll(){
1154
+ return this.__all__().filter(n=>n)
1155
+ },
1156
+ getElementByIndex(index){
1157
+ return this.__all__().find(n=>n.ui_index===index);
1158
+ },
1159
+ getElementById(id){
1160
+ return null;
1161
+ },
1162
+ getElementsByClass(){
1163
+
1164
+ },
1165
+ getElementsByTagName(){
1166
+
1167
+ }
1168
+ };
1169
+
1170
+ const __Config__ = {
1171
+ default:{
1172
+ target:null,
1173
+ render:true,
1174
+ math:{
1175
+ mode:"deg"
1176
+ }
1177
+ },
1178
+ setDefault:function(pairs){
1179
+ const keys=Object.keys(pairs);
1180
+ const values=Object.values(pairs);
1181
+ for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
1182
+ },
1183
+ init:()=>{
1184
+ // document.documentElement.setAttribute("data-engine","zikojs")
1185
+ },
1186
+ renderingMode :"spa",
1187
+ isSSC : false,
1188
+ };
1189
+
1190
+ const __HYDRATION__ = {
1191
+ map : new Map(),
1192
+ index : 0,
1193
+ increment : function(){
1194
+ return this.index ++
1195
+ }
1196
+ };
1197
+
1198
+ const __CACHE__ = {
1199
+ ui_index : 0,
1200
+ get_ui_index:function(){
1201
+ return this.ui_index ++
1202
+ }
1203
+ };
1204
+
1205
+ const __State__ = {
1206
+ store : new Map(),
1207
+ index : import.meta.hot?.data?.__Ziko__?.__State__?.index ?? 0,
1208
+ register: function(state){
1209
+ console.log({
1210
+ hmr : import.meta.hot?.data.__Ziko__.__State__.index,
1211
+ index : this.index
1212
+ });
1213
+ this.store.set(this.index++, state);
1214
+ }
1215
+
1216
+ };
1217
+
1218
+ function __init__global__(){
1219
+ if ( !globalThis?.__Ziko__ ){
1220
+ globalThis.__Ziko__ = {
1221
+ __UI__,
1222
+ __HYDRATION__,
1223
+ __State__,
1224
+ // __HYDRATION_MAP__,
1225
+ __Config__,
1226
+ __CACHE__,
1227
+ };
1228
+ defineParamsGetter$1(__Ziko__);
1229
+ }
1230
+ }
1231
+
1232
+ if(!globalThis.__Ziko__) __init__global__();
1233
+
1234
+ // HMR persistence
1235
+ if (import.meta.hot) {
1236
+ import.meta.hot.data.__Ziko__ = import.meta.hot.data.__Ziko__ || globalThis.__Ziko__;
1237
+ globalThis.__Ziko__ = import.meta.hot.data.__Ziko__;
1238
+ // import.meta.hot.accept(n=>console.log(n));
1239
+ // console.log(import.meta.hot.data.__Ziko__.__State__.store)
1240
+ }
1241
+
1242
+
1243
+
1103
1244
  function useState(initialValue) {
1104
- let value = initialValue;
1105
- const subscribers = new Set();
1106
- let paused = false;
1245
+
1246
+ // console.log(import.meta.hot.data.__Ziko__.__State__.store.get(0))
1247
+
1248
+ const {store, index} = __Ziko__.__State__;
1249
+ __Ziko__.__State__.register({
1250
+ value : initialValue,
1251
+ subscribers : new Set(),
1252
+ paused : false
1253
+ });
1254
+
1255
+ const current = store.get(index);
1107
1256
 
1108
1257
  function getValue() {
1109
1258
  return {
1110
- value,
1259
+ value: current.value,
1111
1260
  isStateGetter: () => true,
1112
- _subscribe: (
1113
- fn,
1114
- // UIElement
1115
- ) => {
1116
- subscribers.add(fn);
1117
-
1118
- // const observer = new MutationObserver(() => {
1119
- // if (!document.body.contains(UIElement.element)) {
1120
- // subscribers.delete(fn);
1121
- // observer.disconnect();
1122
- // }
1123
- // });
1124
-
1125
- // observer.observe(document.body, { childList: true, subtree: true });
1126
- },
1261
+ _subscribe: (fn) => current.subscribers.add(fn),
1127
1262
  };
1128
1263
  }
1129
1264
 
1130
1265
  function setValue(newValue) {
1131
- if (paused) return;
1132
- if (typeof newValue === "function") newValue = newValue(value);
1133
- if (newValue !== value) {
1134
- value = newValue;
1135
- subscribers.forEach(fn => fn(value));
1266
+ if (current.paused) return;
1267
+ if (typeof newValue === "function") newValue = newValue(current.value);
1268
+ if (newValue !== current.value) {
1269
+ current.value = newValue;
1270
+ current.subscribers.forEach(fn => fn(current.value));
1136
1271
  }
1137
1272
  }
1138
1273
 
1139
1274
  const controller = {
1140
- pause: () => { paused = true; },
1141
- resume: () => { paused = false; },
1142
- clear: () => { subscribers.clear(); },
1143
- force: (newValue) => { // force update even if paused
1144
- if (typeof newValue === "function") newValue = newValue(value);
1145
- value = newValue;
1146
- subscribers.forEach(fn => fn(value));
1275
+ pause: () => { current.paused = true; },
1276
+ resume: () => { current.paused = false; },
1277
+ clear: () => { current.subscribers.clear(); },
1278
+ force: (newValue) => {
1279
+ if (typeof newValue === "function") newValue = newValue(current.value);
1280
+ current.value = newValue;
1281
+ current.subscribers.forEach(fn => fn(current.value));
1147
1282
  },
1148
- getSubscribers: () => new Set(subscribers),
1283
+ getSubscribers: () => new Set(current.subscribers),
1149
1284
  };
1150
1285
 
1151
1286
  return [getValue, setValue, controller];
1152
1287
  }
1153
1288
 
1289
+
1154
1290
  const isStateGetter = (arg) => {
1155
- return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
1291
+ return typeof arg === 'function' && arg?.()?.isStateGetter?.();
1156
1292
  };
1157
1293
 
1158
1294
  const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
@@ -2731,107 +2867,6 @@ class ZikoUseMediaQuery {
2731
2867
 
2732
2868
  const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
2733
2869
 
2734
- function parseQueryParams$1(queryString) {
2735
- const params = {};
2736
- queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
2737
- const [key, value] = match.split('=');
2738
- params[key] = value;
2739
- });
2740
- return params;
2741
- }
2742
-
2743
- function defineParamsGetter$1(target ){
2744
- Object.defineProperties(target, {
2745
- 'QueryParams': {
2746
- get: function() {
2747
- return parseQueryParams$1(globalThis.location.search.substring(1));
2748
- },
2749
- configurable: false,
2750
- enumerable: true
2751
- },
2752
- 'HashParams': {
2753
- get: function() {
2754
- const hash = globalThis.location.hash.substring(1);
2755
- return hash.split("#");
2756
- },
2757
- configurable: false,
2758
- enumerable: true
2759
- }
2760
- });
2761
- }
2762
-
2763
- const __UI__={
2764
- __all__(){
2765
- return Object.values(this)
2766
- .filter(Array.isArray)
2767
- .flat();
2768
- },
2769
- querySelectorAll(){
2770
- return this.__all__().filter(n=>n)
2771
- },
2772
- getElementByIndex(index){
2773
- return this.__all__().find(n=>n.ui_index===index);
2774
- },
2775
- getElementById(id){
2776
- return null;
2777
- },
2778
- getElementsByClass(){
2779
-
2780
- },
2781
- getElementsByTagName(){
2782
-
2783
- }
2784
- };
2785
-
2786
- const __Config__ = {
2787
- default:{
2788
- target:null,
2789
- render:true,
2790
- math:{
2791
- mode:"deg"
2792
- }
2793
- },
2794
- setDefault:function(pairs){
2795
- const keys=Object.keys(pairs);
2796
- const values=Object.values(pairs);
2797
- for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
2798
- },
2799
- init:()=>{
2800
- // document.documentElement.setAttribute("data-engine","zikojs")
2801
- },
2802
- renderingMode :"spa",
2803
- isSSC : false,
2804
- };
2805
-
2806
- const __HYDRATION__ = {
2807
- map : new Map(),
2808
- index : 0,
2809
- increment : function(){
2810
- return this.index ++
2811
- }
2812
- };
2813
- const __HYDRATION_MAP__ = new Map();
2814
-
2815
- const __CACHE__ = {
2816
- ui_index : 0,
2817
- get_ui_index:function(){
2818
- return this.ui_index ++
2819
- }
2820
- };
2821
-
2822
- function __init__global__(){
2823
- if ( !globalThis?.__Ziko__ ){
2824
- globalThis.__Ziko__ = {
2825
- __UI__,
2826
- __HYDRATION__,
2827
- __HYDRATION_MAP__,
2828
- __Config__,
2829
- __CACHE__,
2830
- };
2831
- defineParamsGetter$1(__Ziko__);
2832
- }
2833
- }
2834
-
2835
2870
  __init__global__();
2836
2871
  class UIElement extends UINode{
2837
2872
  constructor({element, name ='', type="html", useDefaultStyle=false}={}){
@@ -3654,38 +3689,45 @@ class ZikoUISvg extends UIElement {
3654
3689
 
3655
3690
  const Svg =(w,h)=>new ZikoUISvg(w,h);
3656
3691
 
3657
- function defineWC(name, UIElement, props = {}, { mode = 'open'} = {}){
3692
+ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
3693
+ if (globalThis.customElements?.get(name)) {
3694
+ console.warn(`Custom element "${name}" is already defined`);
3695
+ return; // skip redefinition
3696
+ }
3697
+ if(name.search('-') === -1){
3698
+ console.warn(`"${name}" is not a valid custom element name`);
3699
+ return;
3700
+ }
3658
3701
  globalThis.customElements?.define(
3659
3702
  name,
3660
- class extends HTMLElement{
3661
- static observedAttributes = ['style',...Object.keys(props)];
3662
- constructor(){
3703
+ class extends HTMLElement {
3704
+ static get observedAttributes() {
3705
+ return ['style', ...Object.keys(props)];
3706
+ }
3707
+
3708
+ constructor() {
3663
3709
  super();
3664
3710
  this.attachShadow({ mode });
3665
3711
  this.props = {};
3666
3712
  this.mask = {
3667
3713
  ...props,
3668
- // ...{
3669
- // style : { type : Object}
3670
- // }
3714
+ // style: { type: Object }
3671
3715
  };
3672
3716
  }
3673
- connectedCallback(){
3717
+
3718
+ connectedCallback() {
3674
3719
  this.render();
3675
- // console.log(this.props)
3676
3720
  }
3677
- render(){
3721
+
3722
+ render() {
3678
3723
  this.shadowRoot.innerHTML = '';
3679
- // this.UIElement = UIElement(this.props).render(this.shadowRoot)
3680
- UIElement({attrs:(key, value) => console.log({key, value})}).render(this.shadowRoot);
3681
- UIElement(a => console.log(a)).render(this.shadowRoot);
3682
- // this.UIElement = (()=>{
3683
- // UIElement(this.props).render(this.shadowRoot);
3684
- // })()
3685
- // this.UIElement.setTarget(this.shadowRoot);
3724
+ this.UIElement = UIElement(this.props).render(this.shadowRoot);
3686
3725
  }
3726
+
3687
3727
  attributeChangedCallback(name, _, newValue) {
3688
- Object.assign(this.props, {[name] : this.mask[name].type(newValue)});
3728
+ Object.assign(this.props, {
3729
+ [name]: this.mask[name].type(newValue)
3730
+ });
3689
3731
  this.render();
3690
3732
  }
3691
3733
  }
@@ -4517,7 +4559,7 @@ class Complex extends ZikoMath{
4517
4559
  }
4518
4560
  else if(("a" in b && "z" in a)){
4519
4561
  this.a=a.a;
4520
- this.b=sqrt$1((a.z**2)-(a.a**2));
4562
+ this.b=sqrt$2((a.z**2)-(a.a**2));
4521
4563
  }
4522
4564
  else if(("a" in b && "phi" in a)){
4523
4565
  this.a=a.a;
@@ -4525,15 +4567,15 @@ class Complex extends ZikoMath{
4525
4567
  }
4526
4568
  else if(("b" in b && "z" in a)){
4527
4569
  this.b=a.b;
4528
- this.a=sqrt$1((a.z**2)-(a.b**2));
4570
+ this.a=sqrt$2((a.z**2)-(a.b**2));
4529
4571
  }
4530
4572
  else if(("b" in b && "phi" in a)){
4531
4573
  this.b=b;
4532
4574
  this.a=a.b/tan(a.phi);
4533
4575
  }
4534
4576
  else if(("z" in b && "phi" in a)){
4535
- this.a=a.z*cos$1(a.phi);
4536
- this.a=a.z*sin$1(a.phi);
4577
+ this.a=a.z*cos$2(a.phi);
4578
+ this.a=a.z*sin$2(a.phi);
4537
4579
  }
4538
4580
  }
4539
4581
  else if(typeof(a)==="number"&&typeof(b)==="number"){
@@ -4601,8 +4643,8 @@ class Complex extends ZikoMath{
4601
4643
  }
4602
4644
  let Z=+prod(this.z,...z.map(n=>n.z)).toFixed(15);
4603
4645
  let phi=+sum(this.phi,...z.map(n=>n.phi)).toFixed(15);
4604
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(14);
4605
- this.b=+(Z*sin$1(phi).toFixed(15)).toFixed(14);
4646
+ this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(14);
4647
+ this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(14);
4606
4648
  return this;
4607
4649
  }
4608
4650
  div(...z) {
@@ -4611,23 +4653,23 @@ class Complex extends ZikoMath{
4611
4653
  }
4612
4654
  let Z=+(this.z/prod(...z.map(n=>n.z))).toFixed(15);
4613
4655
  let phi=+(this.phi-sum(...z.map(n=>n.phi))).toFixed(15);
4614
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(15);
4615
- this.b=+(Z*sin$1(phi).toFixed(15)).toFixed(15);
4656
+ this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(15);
4657
+ this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(15);
4616
4658
  return this;
4617
4659
  }
4618
4660
  pow(n) {
4619
4661
  if (floor(n) === n && n > 0) {
4620
4662
  let z=+(this.z**n).toFixed(15);
4621
4663
  let phi=+(this.phi*n).toFixed(15);
4622
- this.a=+(z*cos$1(phi).toFixed(15)).toFixed(15);
4623
- this.b=+(z*sin$1(phi).toFixed(15)).toFixed(15);
4664
+ this.a=+(z*cos$2(phi).toFixed(15)).toFixed(15);
4665
+ this.b=+(z*sin$2(phi).toFixed(15)).toFixed(15);
4624
4666
  }
4625
4667
  return this;
4626
4668
  }
4627
4669
  static fromExpo(z, phi) {
4628
4670
  return new Complex(
4629
- +(z * cos$1(phi)).toFixed(13),
4630
- +(z * sin$1(phi)).toFixed(13)
4671
+ +(z * cos$2(phi)).toFixed(13),
4672
+ +(z * sin$2(phi)).toFixed(13)
4631
4673
  );
4632
4674
  }
4633
4675
  get expo() {
@@ -4649,10 +4691,10 @@ class Complex extends ZikoMath{
4649
4691
  return z.clone.pow(n);
4650
4692
  }
4651
4693
  static xpowZ(x){
4652
- return complex((x**this.a)*cos$1(this.b*ln(x)),(x**this.a)*sin$1(this.b*ln(x)));
4694
+ return complex((x**this.a)*cos$2(this.b*ln(x)),(x**this.a)*sin$2(this.b*ln(x)));
4653
4695
  }
4654
4696
  sqrtn(n=2){
4655
- return complex(sqrtn(this.z,n)*cos$1(this.phi/n),sqrtn(this.z,n)*sin$1(this.phi/n));
4697
+ return complex(sqrtn(this.z,n)*cos$2(this.phi/n),sqrtn(this.z,n)*sin$2(this.phi/n));
4656
4698
  }
4657
4699
  get sqrt(){
4658
4700
  return this.sqrtn(2);
@@ -4661,14 +4703,14 @@ class Complex extends ZikoMath{
4661
4703
  return complex(this.z,this.phi);
4662
4704
  }
4663
4705
  get cos(){
4664
- return complex(cos$1(this.a)*cosh(this.b),sin$1(this.a)*sinh(this.b))
4706
+ return complex(cos$2(this.a)*cosh$1(this.b),sin$2(this.a)*sinh$1(this.b))
4665
4707
  }
4666
4708
  get sin(){
4667
- return complex(sin$1(this.a)*cosh(this.b),cos$1(this.a)*sinh(this.b))
4709
+ return complex(sin$2(this.a)*cosh$1(this.b),cos$2(this.a)*sinh$1(this.b))
4668
4710
  }
4669
4711
  get tan(){
4670
- const de=cos$1(this.a*2)+cosh(this.b*2);
4671
- return complex(sin$1(2*this.a)/de,sinh(2*this.b)/de);
4712
+ const de=cos$2(this.a*2)+cosh$1(this.b*2);
4713
+ return complex(sin$2(2*this.a)/de,sinh$1(2*this.b)/de);
4672
4714
  }
4673
4715
  printInConsole() {
4674
4716
  let string = this.a + " + " + this.b + " * i";
@@ -4699,7 +4741,7 @@ const complex=(a,b)=>{
4699
4741
  // } from "../calculus/index.js";
4700
4742
 
4701
4743
  const abs=(...x)=>mapfun$1(Math.abs,...x);
4702
- const sqrt$1=(...x)=>mapfun$1(Math.sqrt,...x);
4744
+ const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
4703
4745
  const pow$1=(x,n)=>{
4704
4746
  if(typeof x === "number"){
4705
4747
  if(typeof n === "number")return Math.pow(x,n);
@@ -4747,8 +4789,8 @@ const sqrtn=(x,n)=>{
4747
4789
  };
4748
4790
  const e=(...x) => mapfun$1(Math.exp,...x);
4749
4791
  const ln=(...x) => mapfun$1(Math.log,...x);
4750
- const cos$1=(...x) => mapfun$1(Fixed.cos,...x);
4751
- const sin$1=(...x) => mapfun$1(Fixed.sin,...x);
4792
+ const cos$2=(...x) => mapfun$1(Fixed.cos,...x);
4793
+ const sin$2=(...x) => mapfun$1(Fixed.sin,...x);
4752
4794
  const tan=(...x) => mapfun$1(Fixed.tan,...x);
4753
4795
  const sec=(...x) => mapfun$1(Fixed.sec,...x);
4754
4796
  const sinc=(...x) => mapfun$1(Fixed.sinc,...x);
@@ -4758,8 +4800,8 @@ const acos$1=(...x) => mapfun$1(Fixed.acos,...x);
4758
4800
  const asin=(...x) => mapfun$1(Fixed.asin,...x);
4759
4801
  const atan=(...x) => mapfun$1(Fixed.atan,...x);
4760
4802
  const acot=(...x) => mapfun$1(Fixed.acot,...x);
4761
- const cosh=(...x) => mapfun$1(Fixed.cosh,...x);
4762
- const sinh=(...x) => mapfun$1(Fixed.sinh,...x);
4803
+ const cosh$1=(...x) => mapfun$1(Fixed.cosh,...x);
4804
+ const sinh$1=(...x) => mapfun$1(Fixed.sinh,...x);
4763
4805
  const tanh=(...x) => mapfun$1(Fixed.tanh,...x);
4764
4806
  const coth=(...x) => mapfun$1(Fixed.coth,...x);
4765
4807
  const acosh=(...x) => mapfun$1(Fixed.acosh,...x);
@@ -4808,12 +4850,12 @@ const hypot=(...x)=>{
4808
4850
  )
4809
4851
  };
4810
4852
 
4811
- const {PI, sqrt, cos, sin, acos, pow} = Math;
4853
+ const {PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow} = Math;
4812
4854
 
4813
4855
  const Linear = t => t;
4814
- const InSin = t => 1 - cos((t * PI) / 2);
4815
- const OutSin = t => sin((t * PI) / 2);
4816
- const InOutSin = t => -(cos(PI * t) - 1) / 2;
4856
+ const InSin = t => 1 - cos$1((t * PI) / 2);
4857
+ const OutSin = t => sin$1((t * PI) / 2);
4858
+ const InOutSin = t => -(cos$1(PI * t) - 1) / 2;
4817
4859
 
4818
4860
  const InQuad = t => t**2;
4819
4861
  const OutQuad = t => 1 - (1-t)**2;
@@ -4835,13 +4877,13 @@ const InExpo = t => t === 0 ? 0 : 2**(10*t - 10);
4835
4877
  const OutExpo = t => t === 1 ? 1 : 1 - 2**(-10 * t);
4836
4878
  const InOutExpo = t => t === 0? 0: t === 1? 1: t < 0.5 ? 2**(20 * t - 10) / 2: (2 - 2**(-20 * t + 10)) / 2;
4837
4879
 
4838
- const InCirc = t => 1 - sqrt(1 - t**2);
4839
- const OutCirc = t => sqrt(1 - (t-1)**2);
4840
- const InOutCirc = t => t < 0.5? (1 - sqrt(1 - (2*t)**2)) / 2: (sqrt(1 - (-2*t+2)**2) + 1) / 2;
4880
+ const InCirc = t => 1 - sqrt$1(1 - t**2);
4881
+ const OutCirc = t => sqrt$1(1 - (t-1)**2);
4882
+ const InOutCirc = t => t < 0.5? (1 - sqrt$1(1 - (2*t)**2)) / 2: (sqrt$1(1 - (-2*t+2)**2) + 1) / 2;
4841
4883
 
4842
- const Arc = t => 1 - sin(acos(t));
4884
+ const Arc = t => 1 - sin$1(acos(t));
4843
4885
  const Back = (t, x = 1) => (t**2) * ((x+1)*t - x);
4844
- const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos(20 * PI * t / 3 * t);
4886
+ const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos$1(20 * PI * t / 3 * t);
4845
4887
 
4846
4888
  const InBack = (t, c1 = 1.70158, c3 = c1 + 1) => c3 * pow(t,3)- c1 * (t**2);
4847
4889
  const OutBack = (t, c1 = 1.70158, c3 = c1 + 1) => 1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
@@ -4852,7 +4894,7 @@ const InElastic = (t, c4 = 2*PI/3) => {
4852
4894
  ? 0
4853
4895
  : t === 1
4854
4896
  ? 1
4855
- : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
4897
+ : -pow(2, 10 * t - 10) * sin$1((t * 10 - 10.75) * c4);
4856
4898
  };
4857
4899
 
4858
4900
  const OutElastic = (t, c4 = 2*PI/3) => {
@@ -4860,7 +4902,7 @@ const OutElastic = (t, c4 = 2*PI/3) => {
4860
4902
  ? 0
4861
4903
  : t === 1
4862
4904
  ? 1
4863
- : pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
4905
+ : pow(2, -10 * t) * sin$1((t * 10 - 0.75) * c4) + 1;
4864
4906
  };
4865
4907
  const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4866
4908
  return t === 0
@@ -4868,8 +4910,8 @@ const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4868
4910
  : t === 1
4869
4911
  ? 1
4870
4912
  : t < 0.5
4871
- ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
4872
- : (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
4913
+ ? -(pow(2, 20 * t - 10) * sin$1((20 * t - 11.125) * c5)) / 2
4914
+ : (pow(2, -20 * t + 10) * sin$1((20 * t - 11.125) * c5)) / 2 + 1;
4873
4915
  };
4874
4916
 
4875
4917
  const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
@@ -4977,17 +5019,28 @@ const animation = (callback, {ease, t0, t1, start, duration} = {}) =>
4977
5019
  new TimeAnimation(callback, {ease, t0, t1, start, duration});
4978
5020
 
4979
5021
  class Tick {
4980
- constructor(ms, fn) {
5022
+ constructor(fn, ms, count = Infinity, start) {
4981
5023
  this.ms = ms;
4982
5024
  this.fn = fn;
5025
+ this.count = count;
5026
+ this.frame = 1;
4983
5027
  this.id = null;
4984
5028
  this.running = false;
5029
+ if(start) this.start();
4985
5030
  }
4986
5031
 
4987
5032
  start() {
4988
5033
  if (!this.running) {
4989
5034
  this.running = true;
4990
- this.id = setInterval(this.fn, this.ms);
5035
+ this.frame = 1;
5036
+ this.id = setInterval(() => {
5037
+ if (this.frame > this.count) {
5038
+ this.stop();
5039
+ return;
5040
+ }
5041
+ this.fn.call(null, this);
5042
+ this.frame++;
5043
+ }, this.ms);
4991
5044
  }
4992
5045
  return this;
4993
5046
  }
@@ -5005,7 +5058,9 @@ class Tick {
5005
5058
  return this.running;
5006
5059
  }
5007
5060
  }
5008
- const tick = (ms, fn) => new Tick(ms, fn);
5061
+
5062
+ // Helper factory
5063
+ const tick = (fn, ms, count = Infinity, start = true) => new Tick(fn, ms, count, start);
5009
5064
 
5010
5065
  class Clock extends Tick {
5011
5066
  constructor(tickMs = 1000 / 60) {
@@ -5137,7 +5192,8 @@ const Scheduler = (tasks, { repeat = null} = {}) => new TimeScheduler(tasks, { r
5137
5192
  const step_fps = (step_or_fps) => 1000 / step_or_fps;
5138
5193
 
5139
5194
  const debounce=(fn,delay=1000)=>{
5140
- return (...args) => setTimeout(()=>fn(...args),delay);
5195
+ let id;
5196
+ return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
5141
5197
  };
5142
5198
  const throttle=(fn,delay)=>{
5143
5199
  let lastTime=0;
@@ -5542,66 +5598,37 @@ function findCommonPath(paths) {
5542
5598
  function useDerived(deriveFn, sources) {
5543
5599
  let value = deriveFn(...sources.map(s => s().value));
5544
5600
  const subscribers = new Set();
5545
- let paused = false;
5546
-
5547
- function getValue() {
5548
- return {
5549
- value,
5550
- isStateGetter: () => true,
5551
- _subscribe: (fn, UIElement) => {
5552
- subscribers.add(fn);
5553
-
5554
- const observer = new MutationObserver(() => {
5555
- if (!document.body.contains(UIElement.element)) {
5556
- subscribers.delete(fn);
5557
- observer.disconnect();
5558
- }
5559
- });
5560
-
5561
- observer.observe(document.body, { childList: true, subtree: true });
5562
- },
5563
- };
5564
- }
5565
-
5566
- function setValue(newValue) {
5567
- if (paused) return;
5568
- if (typeof newValue === "function") newValue = newValue(value);
5569
- if (newValue !== value) {
5570
- value = newValue;
5571
- subscribers.forEach(fn => fn(value));
5572
- }
5573
- }
5574
-
5575
- const controller = {
5576
- pause: () => { paused = true; },
5577
- resume: () => { paused = false; },
5578
- clear: () => { subscribers.clear(); },
5579
- force: (newValue) => {
5580
- if (typeof newValue === "function") newValue = newValue(value);
5581
- value = newValue;
5582
- subscribers.forEach(fn => fn(value));
5583
- },
5584
- getSubscribers: () => new Set(subscribers),
5585
- };
5586
5601
 
5587
- // Subscribe to source states
5588
5602
  sources.forEach(source => {
5589
5603
  const srcValue = source(); // getValue()
5590
5604
  srcValue._subscribe(() => {
5591
- if (!paused) {
5605
+ {
5592
5606
  const newVal = deriveFn(...sources.map(s => s().value));
5593
5607
  if (newVal !== value) {
5594
5608
  value = newVal;
5595
5609
  subscribers.forEach(fn => fn(value));
5596
5610
  }
5597
5611
  }
5598
- }, { element: document.body }); // dummy UIElement
5612
+ });
5599
5613
  });
5600
-
5601
- return [getValue, setValue, controller];
5614
+ return () => ({
5615
+ value,
5616
+ isStateGetter : () => true,
5617
+ _subscribe: (fn) => subscribers.add(fn)
5618
+ })
5602
5619
  }
5603
5620
 
5604
- const useReactive = (nested_value) => mapfun$1(n => useState(n), nested_value);
5621
+ const useReactive = (nested_value) => mapfun$1(
5622
+ n => {
5623
+ const state = useState(n);
5624
+ // console.log(state)
5625
+ return {
5626
+ get : state[0],
5627
+ set : state[1],
5628
+ }
5629
+ },
5630
+ nested_value
5631
+ );
5605
5632
 
5606
5633
  class ZikoUseChannel{
5607
5634
  constructor(name = ""){
@@ -5837,8 +5864,67 @@ class ZikoUseStorage{
5837
5864
  const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
5838
5865
  const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
5839
5866
 
5867
+ let {sqrt, cos, sin, exp, log, cosh, sinh} = Math;
5868
+ // Math.abs = new Proxy(Math.abs, {
5869
+ // apply(target, thisArg, args) {
5870
+ // const x = args[0]
5871
+ // if(typeof x === 'number') return target.apply(thisArg, args);
5872
+ // if(x?.isComplex?.()){
5873
+ // const {a, b, z, phi} = x
5874
+ // const complex = (a, b) => new x.constructor(a, b)
5875
+ // switch(target.name){
5876
+ // case 'abs' : return a.z;
5877
+ // case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
5878
+ // }
5879
+ // }
5880
+
5881
+ // }
5882
+ // });
5883
+
5884
+
5885
+ for (const key of Object.getOwnPropertyNames(Math)) {
5886
+ const fn = Math[key];
5887
+ if (typeof fn === "function") {
5888
+ Math[key] = new Proxy(fn, {
5889
+ apply(target, thisArg, args) {
5890
+ // console.log(target)
5891
+ const x = args[0];
5892
+ if(typeof x === 'number' || args.length === 0) return target.apply(thisArg, args);
5893
+ if(x?.isComplex?.()){
5894
+ const {a, b, z, phi} = x;
5895
+ const complex = (a, b) => new x.constructor(a, b);
5896
+ switch(target.name){
5897
+ case 'abs' : return x.z;
5898
+ case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
5899
+ case 'log' : return complex(log(z), phi);
5900
+ case 'exp' : return complex(exp(a)*cos(b),exp(a)*sin(b));
5901
+ case 'cos' : return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
5902
+ case 'sin' : return complex(sin(a)*cosh(b),cos(a)*sinh(b));
5903
+ case 'tan' : {
5904
+ const DEN = cos(2*a)+cosh(2*b);
5905
+ return complex(sin(2*a) /DEN, sinh(2*b)/DEN);
5906
+ }
5907
+ case 'cosh' : return complex(cosh(a)*cos(b),sinh(a)*sin(b));
5908
+ case 'sinh' : return complex(sinh(a)*cos(b),cosh(a)*sin(b));
5909
+ case 'tanh' : {
5910
+ const DEN=cosh(2*a)+cos(2*b);
5911
+ return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
5912
+ }
5913
+ default : return target.apply(thisArg, args)
5914
+ }
5915
+ }
5916
+ // if( x.isMatrix?.()){
5917
+ // const {rows, cols, arr} = x
5918
+ // // return new x.constructor(rows, cols, arr.flat(1).map(n=>));
5919
+ // }
5920
+ throw new TypeError(`Math.${key} expects only numbers`);
5921
+ }
5922
+ });
5923
+ }
5924
+ }
5925
+
5840
5926
  if(globalThis?.document){
5841
5927
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5842
5928
  }
5843
5929
 
5844
- export { App, Arc, Back, Base, Canvas, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, Grid$1 as Grid, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Svg, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement, UINode, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUICanvas, ZikoUIFlex, ZikoUIGrid, ZikoUIHTMLWrapper, ZikoUISVGWrapper, ZikoUISuspense, ZikoUISvg, ZikoUIText, ZikoUIXMLWrapper, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindClickEvent, bindClipboardEvent, bindCustomEvent, bindDragEvent, bindFocusEvent, bindHashEvent, bindKeyEvent, bindMouseEvent, bindPointerEvent, bindTouchEvent, bindWheelEvent, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$1 as cos, cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, defineWC, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$1 as sin, sinc, sinh, sleep, sqrt$1 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
5930
+ export { App, Arc, Back, Base, Canvas, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, Grid$1 as Grid, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Svg, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement, UINode, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUICanvas, ZikoUIFlex, ZikoUIGrid, ZikoUIHTMLWrapper, ZikoUISVGWrapper, ZikoUISuspense, ZikoUISvg, ZikoUIText, ZikoUIXMLWrapper, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindClickEvent, bindClipboardEvent, bindCustomEvent, bindDragEvent, bindFocusEvent, bindHashEvent, bindKeyEvent, bindMouseEvent, bindPointerEvent, bindTouchEvent, bindWheelEvent, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };