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.mjs 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
@@ -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,7 +3689,15 @@ 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
3703
  class extends HTMLElement {
@@ -4516,7 +4559,7 @@ class Complex extends ZikoMath{
4516
4559
  }
4517
4560
  else if(("a" in b && "z" in a)){
4518
4561
  this.a=a.a;
4519
- this.b=sqrt$1((a.z**2)-(a.a**2));
4562
+ this.b=sqrt$2((a.z**2)-(a.a**2));
4520
4563
  }
4521
4564
  else if(("a" in b && "phi" in a)){
4522
4565
  this.a=a.a;
@@ -4524,15 +4567,15 @@ class Complex extends ZikoMath{
4524
4567
  }
4525
4568
  else if(("b" in b && "z" in a)){
4526
4569
  this.b=a.b;
4527
- this.a=sqrt$1((a.z**2)-(a.b**2));
4570
+ this.a=sqrt$2((a.z**2)-(a.b**2));
4528
4571
  }
4529
4572
  else if(("b" in b && "phi" in a)){
4530
4573
  this.b=b;
4531
4574
  this.a=a.b/tan(a.phi);
4532
4575
  }
4533
4576
  else if(("z" in b && "phi" in a)){
4534
- this.a=a.z*cos$1(a.phi);
4535
- 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);
4536
4579
  }
4537
4580
  }
4538
4581
  else if(typeof(a)==="number"&&typeof(b)==="number"){
@@ -4600,8 +4643,8 @@ class Complex extends ZikoMath{
4600
4643
  }
4601
4644
  let Z=+prod(this.z,...z.map(n=>n.z)).toFixed(15);
4602
4645
  let phi=+sum(this.phi,...z.map(n=>n.phi)).toFixed(15);
4603
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(14);
4604
- 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);
4605
4648
  return this;
4606
4649
  }
4607
4650
  div(...z) {
@@ -4610,23 +4653,23 @@ class Complex extends ZikoMath{
4610
4653
  }
4611
4654
  let Z=+(this.z/prod(...z.map(n=>n.z))).toFixed(15);
4612
4655
  let phi=+(this.phi-sum(...z.map(n=>n.phi))).toFixed(15);
4613
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(15);
4614
- 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);
4615
4658
  return this;
4616
4659
  }
4617
4660
  pow(n) {
4618
4661
  if (floor(n) === n && n > 0) {
4619
4662
  let z=+(this.z**n).toFixed(15);
4620
4663
  let phi=+(this.phi*n).toFixed(15);
4621
- this.a=+(z*cos$1(phi).toFixed(15)).toFixed(15);
4622
- 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);
4623
4666
  }
4624
4667
  return this;
4625
4668
  }
4626
4669
  static fromExpo(z, phi) {
4627
4670
  return new Complex(
4628
- +(z * cos$1(phi)).toFixed(13),
4629
- +(z * sin$1(phi)).toFixed(13)
4671
+ +(z * cos$2(phi)).toFixed(13),
4672
+ +(z * sin$2(phi)).toFixed(13)
4630
4673
  );
4631
4674
  }
4632
4675
  get expo() {
@@ -4648,10 +4691,10 @@ class Complex extends ZikoMath{
4648
4691
  return z.clone.pow(n);
4649
4692
  }
4650
4693
  static xpowZ(x){
4651
- 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)));
4652
4695
  }
4653
4696
  sqrtn(n=2){
4654
- 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));
4655
4698
  }
4656
4699
  get sqrt(){
4657
4700
  return this.sqrtn(2);
@@ -4660,14 +4703,14 @@ class Complex extends ZikoMath{
4660
4703
  return complex(this.z,this.phi);
4661
4704
  }
4662
4705
  get cos(){
4663
- 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))
4664
4707
  }
4665
4708
  get sin(){
4666
- 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))
4667
4710
  }
4668
4711
  get tan(){
4669
- const de=cos$1(this.a*2)+cosh(this.b*2);
4670
- 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);
4671
4714
  }
4672
4715
  printInConsole() {
4673
4716
  let string = this.a + " + " + this.b + " * i";
@@ -4698,7 +4741,7 @@ const complex=(a,b)=>{
4698
4741
  // } from "../calculus/index.js";
4699
4742
 
4700
4743
  const abs=(...x)=>mapfun$1(Math.abs,...x);
4701
- const sqrt$1=(...x)=>mapfun$1(Math.sqrt,...x);
4744
+ const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
4702
4745
  const pow$1=(x,n)=>{
4703
4746
  if(typeof x === "number"){
4704
4747
  if(typeof n === "number")return Math.pow(x,n);
@@ -4746,8 +4789,8 @@ const sqrtn=(x,n)=>{
4746
4789
  };
4747
4790
  const e=(...x) => mapfun$1(Math.exp,...x);
4748
4791
  const ln=(...x) => mapfun$1(Math.log,...x);
4749
- const cos$1=(...x) => mapfun$1(Fixed.cos,...x);
4750
- 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);
4751
4794
  const tan=(...x) => mapfun$1(Fixed.tan,...x);
4752
4795
  const sec=(...x) => mapfun$1(Fixed.sec,...x);
4753
4796
  const sinc=(...x) => mapfun$1(Fixed.sinc,...x);
@@ -4757,8 +4800,8 @@ const acos$1=(...x) => mapfun$1(Fixed.acos,...x);
4757
4800
  const asin=(...x) => mapfun$1(Fixed.asin,...x);
4758
4801
  const atan=(...x) => mapfun$1(Fixed.atan,...x);
4759
4802
  const acot=(...x) => mapfun$1(Fixed.acot,...x);
4760
- const cosh=(...x) => mapfun$1(Fixed.cosh,...x);
4761
- 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);
4762
4805
  const tanh=(...x) => mapfun$1(Fixed.tanh,...x);
4763
4806
  const coth=(...x) => mapfun$1(Fixed.coth,...x);
4764
4807
  const acosh=(...x) => mapfun$1(Fixed.acosh,...x);
@@ -4807,12 +4850,12 @@ const hypot=(...x)=>{
4807
4850
  )
4808
4851
  };
4809
4852
 
4810
- const {PI, sqrt, cos, sin, acos, pow} = Math;
4853
+ const {PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow} = Math;
4811
4854
 
4812
4855
  const Linear = t => t;
4813
- const InSin = t => 1 - cos((t * PI) / 2);
4814
- const OutSin = t => sin((t * PI) / 2);
4815
- 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;
4816
4859
 
4817
4860
  const InQuad = t => t**2;
4818
4861
  const OutQuad = t => 1 - (1-t)**2;
@@ -4834,13 +4877,13 @@ const InExpo = t => t === 0 ? 0 : 2**(10*t - 10);
4834
4877
  const OutExpo = t => t === 1 ? 1 : 1 - 2**(-10 * t);
4835
4878
  const InOutExpo = t => t === 0? 0: t === 1? 1: t < 0.5 ? 2**(20 * t - 10) / 2: (2 - 2**(-20 * t + 10)) / 2;
4836
4879
 
4837
- const InCirc = t => 1 - sqrt(1 - t**2);
4838
- const OutCirc = t => sqrt(1 - (t-1)**2);
4839
- 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;
4840
4883
 
4841
- const Arc = t => 1 - sin(acos(t));
4884
+ const Arc = t => 1 - sin$1(acos(t));
4842
4885
  const Back = (t, x = 1) => (t**2) * ((x+1)*t - x);
4843
- 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);
4844
4887
 
4845
4888
  const InBack = (t, c1 = 1.70158, c3 = c1 + 1) => c3 * pow(t,3)- c1 * (t**2);
4846
4889
  const OutBack = (t, c1 = 1.70158, c3 = c1 + 1) => 1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
@@ -4851,7 +4894,7 @@ const InElastic = (t, c4 = 2*PI/3) => {
4851
4894
  ? 0
4852
4895
  : t === 1
4853
4896
  ? 1
4854
- : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
4897
+ : -pow(2, 10 * t - 10) * sin$1((t * 10 - 10.75) * c4);
4855
4898
  };
4856
4899
 
4857
4900
  const OutElastic = (t, c4 = 2*PI/3) => {
@@ -4859,7 +4902,7 @@ const OutElastic = (t, c4 = 2*PI/3) => {
4859
4902
  ? 0
4860
4903
  : t === 1
4861
4904
  ? 1
4862
- : pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
4905
+ : pow(2, -10 * t) * sin$1((t * 10 - 0.75) * c4) + 1;
4863
4906
  };
4864
4907
  const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4865
4908
  return t === 0
@@ -4867,8 +4910,8 @@ const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4867
4910
  : t === 1
4868
4911
  ? 1
4869
4912
  : t < 0.5
4870
- ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
4871
- : (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;
4872
4915
  };
4873
4916
 
4874
4917
  const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
@@ -4976,17 +5019,28 @@ const animation = (callback, {ease, t0, t1, start, duration} = {}) =>
4976
5019
  new TimeAnimation(callback, {ease, t0, t1, start, duration});
4977
5020
 
4978
5021
  class Tick {
4979
- constructor(ms, fn) {
5022
+ constructor(fn, ms, count = Infinity, start) {
4980
5023
  this.ms = ms;
4981
5024
  this.fn = fn;
5025
+ this.count = count;
5026
+ this.frame = 1;
4982
5027
  this.id = null;
4983
5028
  this.running = false;
5029
+ if(start) this.start();
4984
5030
  }
4985
5031
 
4986
5032
  start() {
4987
5033
  if (!this.running) {
4988
5034
  this.running = true;
4989
- 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);
4990
5044
  }
4991
5045
  return this;
4992
5046
  }
@@ -5004,7 +5058,9 @@ class Tick {
5004
5058
  return this.running;
5005
5059
  }
5006
5060
  }
5007
- 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);
5008
5064
 
5009
5065
  class Clock extends Tick {
5010
5066
  constructor(tickMs = 1000 / 60) {
@@ -5136,7 +5192,8 @@ const Scheduler = (tasks, { repeat = null} = {}) => new TimeScheduler(tasks, { r
5136
5192
  const step_fps = (step_or_fps) => 1000 / step_or_fps;
5137
5193
 
5138
5194
  const debounce=(fn,delay=1000)=>{
5139
- return (...args) => setTimeout(()=>fn(...args),delay);
5195
+ let id;
5196
+ return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
5140
5197
  };
5141
5198
  const throttle=(fn,delay)=>{
5142
5199
  let lastTime=0;
@@ -5541,57 +5598,37 @@ function findCommonPath(paths) {
5541
5598
  function useDerived(deriveFn, sources) {
5542
5599
  let value = deriveFn(...sources.map(s => s().value));
5543
5600
  const subscribers = new Set();
5544
- let paused = false;
5545
5601
 
5546
- function getValue() {
5547
- return {
5548
- value,
5549
- isStateGetter: () => true,
5550
- _subscribe: (fn) => {
5551
- subscribers.add(fn);
5552
- },
5553
- };
5554
- }
5555
-
5556
- function setValue(newValue) {
5557
- if (paused) return;
5558
- if (typeof newValue === "function") newValue = newValue(value);
5559
- if (newValue !== value) {
5560
- value = newValue;
5561
- subscribers.forEach(fn => fn(value));
5562
- }
5563
- }
5564
-
5565
- const controller = {
5566
- pause: () => { paused = true; },
5567
- resume: () => { paused = false; },
5568
- clear: () => { subscribers.clear(); },
5569
- force: (newValue) => {
5570
- if (typeof newValue === "function") newValue = newValue(value);
5571
- value = newValue;
5572
- subscribers.forEach(fn => fn(value));
5573
- },
5574
- getSubscribers: () => new Set(subscribers),
5575
- };
5576
-
5577
- // Subscribe to source states
5578
5602
  sources.forEach(source => {
5579
5603
  const srcValue = source(); // getValue()
5580
5604
  srcValue._subscribe(() => {
5581
- if (!paused) {
5605
+ {
5582
5606
  const newVal = deriveFn(...sources.map(s => s().value));
5583
5607
  if (newVal !== value) {
5584
5608
  value = newVal;
5585
5609
  subscribers.forEach(fn => fn(value));
5586
5610
  }
5587
5611
  }
5588
- }, { element: document.body }); // dummy UIElement
5612
+ });
5589
5613
  });
5590
-
5591
- return [getValue, setValue, controller];
5614
+ return () => ({
5615
+ value,
5616
+ isStateGetter : () => true,
5617
+ _subscribe: (fn) => subscribers.add(fn)
5618
+ })
5592
5619
  }
5593
5620
 
5594
- 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
+ );
5595
5632
 
5596
5633
  class ZikoUseChannel{
5597
5634
  constructor(name = ""){
@@ -5827,8 +5864,67 @@ class ZikoUseStorage{
5827
5864
  const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
5828
5865
  const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
5829
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
+
5830
5926
  if(globalThis?.document){
5831
5927
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5832
5928
  }
5833
5929
 
5834
- 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 };