ziko 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ziko.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Feb 26 2026 13:06:11 GMT+0000 (UTC)
5
+ Date : Tue Jul 28 2026 17:04:51 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
@@ -15,18 +15,18 @@ const EPSILON=Number.EPSILON;
15
15
 
16
16
  const is_primitive = value => typeof value !== 'object' && typeof value !== 'function' || value === null;
17
17
 
18
- const mapfun=(fun,...X)=>{
18
+ const mapfun$1=(fun,...X)=>{
19
19
  const Y=X.map(x=>{
20
20
  if(is_primitive(x) || x?.__mapfun__) return fun(x)
21
- if(x instanceof Array) return x.map(n=>mapfun(fun,n));
21
+ if(x instanceof Array) return x.map(n=>mapfun$1(fun,n));
22
22
  if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
23
- if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
24
- if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
25
- if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
23
+ if(x instanceof Set) return new Set(mapfun$1(fun,...[...x]));
24
+ if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun$1(fun,n[1])]));
25
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun$1(x.arr.flat(1)))
26
26
  else if(x instanceof Object){
27
27
  return Object.fromEntries(
28
28
  Object.entries(x).map(
29
- n=>n=[n[0],mapfun(fun,n[1])]
29
+ n=>n=[n[0],mapfun$1(fun,n[1])]
30
30
  )
31
31
  )
32
32
  }
@@ -44,7 +44,7 @@ const apply_fun = (x, fn) => {
44
44
  x.cols,
45
45
  x.arr.flat(1).map(fn)
46
46
  )
47
- if (x instanceof Array) mapfun(fn, ...x);
47
+ if (x instanceof Array) mapfun$1(fn, ...x);
48
48
  return fn(x)
49
49
  };
50
50
 
@@ -527,7 +527,7 @@ const complex=(a,b)=>{
527
527
 
528
528
  const PRECESION = 8;
529
529
 
530
- const abs = (...x) => mapfun(
530
+ const abs = (...x) => mapfun$1(
531
531
  x =>{
532
532
  if(x.isComplex?.()) return x.z;
533
533
  return Math.abs(x)
@@ -537,7 +537,7 @@ const abs = (...x) => mapfun(
537
537
 
538
538
  const pow$1 = (...x) => {
539
539
  const n = x.pop();
540
- return mapfun(
540
+ return mapfun$1(
541
541
  x => {
542
542
  if(x.isComplex?.()) {
543
543
  if(n.isComplex?.()) return new x.constructor({
@@ -556,7 +556,7 @@ const pow$1 = (...x) => {
556
556
  )
557
557
  };
558
558
 
559
- const sqrt$2 = (...x) => mapfun(
559
+ const sqrt$2 = (...x) => mapfun$1(
560
560
  x=>{
561
561
  if(x.isComplex?.())
562
562
  return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
@@ -566,7 +566,7 @@ const sqrt$2 = (...x) => mapfun(
566
566
  ...x
567
567
  );
568
568
 
569
- const cbrt = (...x) => mapfun(
569
+ const cbrt = (...x) => mapfun$1(
570
570
  x=>{
571
571
  if(x.isComplex?.())
572
572
  return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
@@ -578,7 +578,7 @@ const cbrt = (...x) => mapfun(
578
578
  const nthr = (...x) => {
579
579
  const n = x.pop();
580
580
  if(typeof n !== 'number') throw Error('nthr expects a real number n');
581
- return mapfun(
581
+ return mapfun$1(
582
582
  x => {
583
583
  if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
584
584
  if(x<0) return n %2 ===2
@@ -593,7 +593,7 @@ const nthr = (...x) => {
593
593
  const croot = (...x) =>{
594
594
  const c = x.pop();
595
595
  if(!c.isComplex?.()) throw Error('croot expect Complex number as root')
596
- return mapfun(
596
+ return mapfun$1(
597
597
  x => {
598
598
  if(typeof x === 'number') x = new c.constructor(x, 0);
599
599
  const {a : c_a, b : c_b} = c;
@@ -610,7 +610,7 @@ const croot = (...x) =>{
610
610
  )
611
611
  };
612
612
 
613
- const exp$1 = (...x) => mapfun(
613
+ const exp$1 = (...x) => mapfun$1(
614
614
  x => {
615
615
  if(x.isComplex?.()) return new x.constructor(
616
616
  Math.exp(x.a) * Math.cos(x.b),
@@ -621,7 +621,7 @@ const exp$1 = (...x) => mapfun(
621
621
  ,...x
622
622
  );
623
623
 
624
- const ln = (...x) => mapfun(
624
+ const ln = (...x) => mapfun$1(
625
625
  x => {
626
626
  if(x.isComplex?.()) return new x.constructor(
627
627
  Math.log(x.z),
@@ -632,7 +632,7 @@ const ln = (...x) => mapfun(
632
632
  ,...x
633
633
  );
634
634
 
635
- const sign = (...x) => mapfun(
635
+ const sign = (...x) => mapfun$1(
636
636
  x => {
637
637
  if(x.isComplex?.()){
638
638
  const {z, phi} = x;
@@ -644,7 +644,7 @@ const sign = (...x) => mapfun(
644
644
  ,...x
645
645
  );
646
646
 
647
- const floor = (...x) => mapfun(
647
+ const floor = (...x) => mapfun$1(
648
648
  x => {
649
649
  if(x.isComplex?.()) return new x.constructor(
650
650
  Math.floor(x.a),
@@ -654,7 +654,7 @@ const floor = (...x) => mapfun(
654
654
  },
655
655
  ...x
656
656
  );
657
- const ceil = (...x) => mapfun(
657
+ const ceil = (...x) => mapfun$1(
658
658
  x => {
659
659
  if(x.isComplex?.()) return new x.constructor(
660
660
  Math.ceil(x.a),
@@ -664,7 +664,7 @@ const ceil = (...x) => mapfun(
664
664
  },
665
665
  ...x
666
666
  );
667
- const round = (...x) => mapfun(
667
+ const round = (...x) => mapfun$1(
668
668
  x => {
669
669
  if(x.isComplex?.()) return new x.constructor(
670
670
  Math.round(x.a),
@@ -675,7 +675,7 @@ const round = (...x) => mapfun(
675
675
  ...x
676
676
  );
677
677
 
678
- const trunc = (...x) => mapfun(
678
+ const trunc = (...x) => mapfun$1(
679
679
  x => {
680
680
  if(x.isComplex?.()) return new x.constructor(
681
681
  Math.trunc(x.a),
@@ -686,7 +686,7 @@ const trunc = (...x) => mapfun(
686
686
  ...x
687
687
  );
688
688
 
689
- const fract = (...x) => mapfun(
689
+ const fract = (...x) => mapfun$1(
690
690
  x => {
691
691
  if(x.isComplex?.()) return new x.constructor(
692
692
  x.a - Math.trunc(x.a),
@@ -697,7 +697,7 @@ const fract = (...x) => mapfun(
697
697
  ...x
698
698
  );
699
699
 
700
- const cos$3 = (...x) => mapfun(
700
+ const cos$3 = (...x) => mapfun$1(
701
701
  x => {
702
702
  if(x.isComplex?.()) return new x.constructor(
703
703
  Math.cos(x.a) * Math.cosh(x.b),
@@ -708,7 +708,7 @@ const cos$3 = (...x) => mapfun(
708
708
  ,...x
709
709
  );
710
710
 
711
- const sin$3 = (...x) => mapfun(
711
+ const sin$3 = (...x) => mapfun$1(
712
712
  x =>{
713
713
  if(x?.isComplex) return new x.constructor(
714
714
  Math.sin(x.a) * Math.cosh(x.b),
@@ -719,7 +719,7 @@ const sin$3 = (...x) => mapfun(
719
719
  , ...x
720
720
  );
721
721
 
722
- const tan = (...x) => mapfun(
722
+ const tan = (...x) => mapfun$1(
723
723
  x =>{
724
724
  if(x?.isComplex){
725
725
  const D = Math.cos(2*x.a) + Math.cosh(2*x.b);
@@ -733,7 +733,7 @@ const tan = (...x) => mapfun(
733
733
  ...x
734
734
  );
735
735
 
736
- const sec = (...x) => mapfun(
736
+ const sec = (...x) => mapfun$1(
737
737
  x => {
738
738
  if(x.isComplex?.()) ;
739
739
  return + (1 / Math.cos(x)).toFixed(PRECESION)
@@ -741,7 +741,7 @@ const sec = (...x) => mapfun(
741
741
  ,...x
742
742
  );
743
743
 
744
- const acos$1 = (...x) => mapfun(
744
+ const acos$1 = (...x) => mapfun$1(
745
745
  x =>{
746
746
  if(x?.isComplex){
747
747
  const { a, b } = x;
@@ -759,7 +759,7 @@ const acos$1 = (...x) => mapfun(
759
759
  ...x
760
760
  );
761
761
 
762
- const asin = (...x) => mapfun(
762
+ const asin = (...x) => mapfun$1(
763
763
  x => {
764
764
  if(x?.isComplex){
765
765
  const { a, b } = x;
@@ -775,7 +775,7 @@ const asin = (...x) => mapfun(
775
775
  ...x
776
776
  );
777
777
 
778
- const atan = (...x) => mapfun(
778
+ const atan = (...x) => mapfun$1(
779
779
  x => {
780
780
  if(x?.isComplex){
781
781
  const { a, b } = x;
@@ -789,7 +789,7 @@ const atan = (...x) => mapfun(
789
789
  ...x
790
790
  );
791
791
 
792
- const acot = (...x) => mapfun(
792
+ const acot = (...x) => mapfun$1(
793
793
  x => {
794
794
  if(x?.isComplex){
795
795
  const { a, b } = x;
@@ -804,7 +804,7 @@ const acot = (...x) => mapfun(
804
804
  );
805
805
 
806
806
 
807
- const cosh$2 = (...x) => mapfun(
807
+ const cosh$2 = (...x) => mapfun$1(
808
808
  x =>{
809
809
  if(x?.isComplex) return new x.constructor(
810
810
  Math.cosh(x.a) * Math.cos(x.b),
@@ -814,7 +814,7 @@ const cosh$2 = (...x) => mapfun(
814
814
  },
815
815
  ...x
816
816
  );
817
- const sinh$1 = (...x) => mapfun(
817
+ const sinh$1 = (...x) => mapfun$1(
818
818
  x =>{
819
819
  if(x?.isComplex) return new x.constructor(
820
820
  Math.sinh(x.a) * Math.cos(x.b),
@@ -824,7 +824,7 @@ const sinh$1 = (...x) => mapfun(
824
824
  },
825
825
  ...x
826
826
  );
827
- const tanh = (...x) => mapfun(
827
+ const tanh = (...x) => mapfun$1(
828
828
  x =>{
829
829
  if(x?.isComplex){
830
830
  const D = Math.cosh(2*a) + Math.cos(2*b);
@@ -838,7 +838,7 @@ const tanh = (...x) => mapfun(
838
838
  ...x
839
839
  );
840
840
 
841
- const coth = (...x) => mapfun(
841
+ const coth = (...x) => mapfun$1(
842
842
  x =>{
843
843
  if(x?.isComplex){
844
844
  const {a, b} = x;
@@ -853,7 +853,7 @@ const coth = (...x) => mapfun(
853
853
  ...x
854
854
  );
855
855
 
856
- const acosh = (...x) => mapfun(
856
+ const acosh = (...x) => mapfun$1(
857
857
  x =>{
858
858
  if(x?.isComplex){
859
859
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
@@ -863,7 +863,7 @@ const acosh = (...x) => mapfun(
863
863
  ...x
864
864
  );
865
865
 
866
- const asinh = (...x) => mapfun(
866
+ const asinh = (...x) => mapfun$1(
867
867
  x =>{
868
868
  if(x?.isComplex){
869
869
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
@@ -873,7 +873,7 @@ const asinh = (...x) => mapfun(
873
873
  ...x
874
874
  );
875
875
 
876
- const atanh = (...x) => mapfun(
876
+ const atanh = (...x) => mapfun$1(
877
877
  x =>{
878
878
  if(x?.isComplex);
879
879
  return + Math.atanh(x).toFixed(PRECESION)
@@ -881,7 +881,7 @@ const atanh = (...x) => mapfun(
881
881
  ...x
882
882
  );
883
883
 
884
- const sig = (...x) => mapfun(
884
+ const sig = (...x) => mapfun$1(
885
885
  x =>{
886
886
  if(x?.isComplex);
887
887
  return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
@@ -889,8 +889,8 @@ const sig = (...x) => mapfun(
889
889
  ...x
890
890
  );
891
891
 
892
- const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
893
- const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
892
+ const deg2rad = (...deg) => mapfun$1(x => x * Math.PI / 180, ...deg);
893
+ const rad2deg = (...rad) => mapfun$1(x => x / Math.PI * 180, ...rad);
894
894
 
895
895
  const norm = (x, min, max) => apply_fun(
896
896
  x,
@@ -921,10 +921,10 @@ const hypot = (...x) => {
921
921
 
922
922
  const atan2 = (y, x, rad = true) => {
923
923
  if (y instanceof Array && !(x instanceof Array))
924
- return mapfun(n => atan2(n, x, rad), ...y);
924
+ return mapfun$1(n => atan2(n, x, rad), ...y);
925
925
 
926
926
  if (x instanceof Array && !(y instanceof Array))
927
- return mapfun(n => atan2(y, n, rad), ...x);
927
+ return mapfun$1(n => atan2(y, n, rad), ...x);
928
928
 
929
929
  if (y instanceof Array && x instanceof Array)
930
930
  return y.map((v, i) => atan2(v, x[i], rad));
@@ -1161,7 +1161,7 @@ class Matrix{
1161
1161
  return new Matrix(this.rows, this.cols, this.arr.flat(1));
1162
1162
  }
1163
1163
  toComplex(){
1164
- this.arr = mapfun(
1164
+ this.arr = mapfun$1(
1165
1165
  x => x?.isComplex?.() ? x : new Complex(x, 0),
1166
1166
  ...this.arr
1167
1167
  );
@@ -1625,7 +1625,7 @@ class Matrix{
1625
1625
  return new Matrix(v.length, 1, v);
1626
1626
  }
1627
1627
  serialize() {
1628
- const arr = mapfun(x => x.serialize?.() || x, ...this.arr);
1628
+ const arr = mapfun$1(x => x.serialize?.() || x, ...this.arr);
1629
1629
  return JSON.stringify({
1630
1630
  type : 'matrix',
1631
1631
  data : {
@@ -1640,7 +1640,7 @@ class Matrix{
1640
1640
  const {type, data} = json;
1641
1641
  if(type !== 'matrix') return TypeError('Not a valid Matrix')
1642
1642
  let {arr} = data;
1643
- arr = mapfun(x => {
1643
+ arr = mapfun$1(x => {
1644
1644
  if(typeof x === 'string') {
1645
1645
  const x_obj = JSON.parse(x);
1646
1646
  const {type} = x_obj;
@@ -1671,186 +1671,6 @@ const matrix2=(...element)=>new Matrix(2, 2, element);
1671
1671
  const matrix3=(...element)=>new Matrix(3, 3, element);
1672
1672
  const matrix4=(...element)=>new Matrix(4, 4, element);
1673
1673
 
1674
- const zeros=(n)=>new Array(n).fill(0);
1675
- const ones=(n)=>new Array(n).fill(1);
1676
- const nums=(num,n)=>new Array(n).fill(num);
1677
-
1678
- const arange=(a, b, step , include = false)=>{
1679
- let tab = [];
1680
- if(a<b){
1681
- for (let i = a; include?i<=b:i<b; i += step) tab.push((i * 10) / 10);
1682
- }
1683
- else {
1684
- for(let i = a; include?i>=b:i>b; i -= step) tab.push((i * 10) / 10);
1685
- }
1686
- return tab;
1687
- };
1688
- const linspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
1689
- if(Math.floor(n)!==n)return;
1690
- if([a,b].every(n=>typeof n==="number")){
1691
- const [max,min]=[a,b].sort((a,b)=>b-a);
1692
- var Y = [];
1693
- let step ;
1694
- endpoint ? step = (max - min) / (n - 1) : step = (max - min) / n;
1695
- for (var i = 0; i < n; i++) {
1696
- a<b?Y.push(min+step*i):Y.push(max-step*i);
1697
- }
1698
- return Y
1699
- }
1700
-
1701
- if([a,b].some(n=>n.isComplex?.())){
1702
- const z1 = new n.constructor(a);
1703
- const z2 = new n.constructor(b);
1704
- n=n||Math.abs(z1.a-z2.a)+1;
1705
- const X=linspace(z1.a,z2.a,n,endpoint);
1706
- const Y=linspace(z1.b,z2.b,n,endpoint);
1707
- let Z=new Array(n).fill(null);
1708
- Z=Z.map((n,i)=> new n.constructor(X[i],Y[i]));
1709
- return Z;
1710
- }
1711
- };
1712
- const logspace=(a,b,n=b-a+1,base=E,endpoint=true)=>{
1713
- return linspace(a,b,n,endpoint).map(n=>pow$1(base,n))
1714
- };
1715
- const geomspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
1716
- if(Math.floor(n)!==n)return;
1717
- if([a,b].every(n=>typeof n==="number")){
1718
- const [max,min]=[a,b].sort((a,b)=>b-a);
1719
- let base;
1720
- endpoint ? base = nthr(max/min,n-1) : base = nthr(max/min,n) ;
1721
- const Y = [min];
1722
- for (let i = 1; i < n; i++) {
1723
- Y.push(Y[i-1]*base);
1724
- }
1725
- return a<b?Y:Y.reverse()
1726
- }
1727
-
1728
- if([a,b].some(n=>n.isComplex?.())){
1729
- const z1 = new n.constructor(a);
1730
- const z2 = new n.constructor(b);
1731
- n=n||Math.abs(z1.a-z2.a)+1;
1732
- let base;
1733
- endpoint ? base = nthr(z2.div(z1),n-1) : base = nthr(z2.div(z1),n) ;
1734
- const Y = [z1];
1735
- for (let i = 1; i < n; i++) {
1736
- Y.push(mul(Y[i-1],base));
1737
- }
1738
- return Y;
1739
- }
1740
- };
1741
-
1742
- /** @module Math */
1743
- /**
1744
- * Checks if a value is within the specified range.
1745
- * @function
1746
- * @param {number} x - The value to check.
1747
- * @param {number} a - The start of the range.
1748
- * @param {number} b - The end of the range.
1749
- * @returns {boolean} Returns true if the value is within the range [a, b], otherwise false.
1750
- */
1751
- const inRange = (x, a, b) => {
1752
- const [min, max] = [Math.min(a, b), Math.max(a, b)];
1753
- return x >= min && x <= max;
1754
- };
1755
-
1756
- /**
1757
- * Checks if two numbers are approximately equal within a given error margin.
1758
- * @param {number} a - The first number.
1759
- * @param {number} b - The second number.
1760
- * @param {number} [Err=0.0001] - The maximum acceptable difference between the two numbers.
1761
- * @returns {boolean} Returns true if the two numbers are approximately equal within the specified error margin, otherwise false.
1762
- */
1763
- const isApproximatlyEqual = (a, b, Err = 0.0001) => {
1764
- return Math.abs(a - b) <= Err;
1765
- };
1766
-
1767
- /** @module Math */
1768
-
1769
- /**
1770
- * Computes the cartesian product of two arrays.
1771
- * @param {Array} a - The first array.
1772
- * @param {Array} b - The second array.
1773
- * @returns {Array} Returns an array representing the cartesian product of the input arrays.
1774
- */
1775
- const cartesianProduct = (a, b) => a.reduce((p, x) => [...p, ...b.map((y) => [x, y])], []);
1776
-
1777
- /**
1778
- * Computes the greatest common divisor (GCD) of two numbers.
1779
- * @param {number} n1 - The first number.
1780
- * @param {number} n2 - The second number.
1781
- * @returns {number} Returns the greatest common divisor of the two input numbers.
1782
- */
1783
- const pgcd = (n1, n2) => {
1784
- let i,
1785
- pgcd = 1;
1786
- if (n1 == floor(n1) && n2 == floor(n2)) {
1787
- for (i = 2; i <= n1 && i <= n2; ++i) {
1788
- if (n1 % i == 0 && n2 % i == 0) pgcd = i;
1789
- }
1790
- return pgcd;
1791
- } else console.log("error");
1792
- };
1793
-
1794
- /**
1795
- * Computes the least common multiple (LCM) of two numbers.
1796
- * @param {number} n1 - The first number.
1797
- * @param {number} n2 - The second number.
1798
- * @returns {number} Returns the least common multiple of the two input numbers.
1799
- */
1800
- const ppcm = (n1, n2) => {
1801
- let ppcm;
1802
- if (n1 == floor(n1) && n2 == floor(n2)) {
1803
- ppcm = n1 > n2 ? n1 : n2;
1804
- while (true) {
1805
- if (ppcm % n1 == 0 && ppcm % n2 == 0) break;
1806
- ++ppcm;
1807
- }
1808
- return ppcm;
1809
- } else console.log("error");
1810
- };
1811
-
1812
- // import { mapfun } from "../mapfun/index.js";
1813
- // import {
1814
- // add,
1815
- // sub,
1816
- // mul,
1817
- // div,
1818
- // modulo
1819
- // } from "./arithmetic.js";
1820
- const Utils={
1821
- // add,
1822
- // sub,
1823
- // mul,
1824
- // div,
1825
- // modulo,
1826
-
1827
- zeros,
1828
- ones,
1829
- nums,
1830
- // norm,
1831
- // lerp,
1832
- // map,
1833
- // clamp,
1834
- arange,
1835
- linspace,
1836
- logspace,
1837
- geomspace,
1838
-
1839
- // sum,
1840
- // prod,
1841
- // accum,
1842
-
1843
- cartesianProduct,
1844
- ppcm,
1845
- pgcd,
1846
-
1847
- // deg2rad,
1848
- // rad2deg,
1849
-
1850
- inRange,
1851
- isApproximatlyEqual
1852
- };
1853
-
1854
1674
  class UINode {
1855
1675
  constructor(node){
1856
1676
  this.cache = {
@@ -1867,7 +1687,7 @@ class UINode {
1867
1687
 
1868
1688
  // globalThis.node = (node) => new UINode(node);
1869
1689
 
1870
- function parseQueryParams$1(queryString) {
1690
+ function parseQueryParams$2(queryString) {
1871
1691
  const params = {};
1872
1692
  queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
1873
1693
  const [key, value] = match.split('=');
@@ -1880,7 +1700,7 @@ function defineParamsGetter$1(target ){
1880
1700
  Object.defineProperties(target, {
1881
1701
  'QueryParams': {
1882
1702
  get: function() {
1883
- return parseQueryParams$1(globalThis.location.search.substring(1));
1703
+ return parseQueryParams$2(globalThis.location.search.substring(1));
1884
1704
  },
1885
1705
  configurable: false,
1886
1706
  enumerable: true
@@ -3347,9 +3167,6 @@ const MathMLTags = [
3347
3167
  `munder`, `munderover`
3348
3168
  ];
3349
3169
 
3350
- // const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
3351
- // const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
3352
-
3353
3170
  const tags = new Proxy({}, {
3354
3171
  get(target, prop) {
3355
3172
  if (typeof prop !== 'string') return undefined;
@@ -4321,110 +4138,6 @@ const svg2ascii=svg=>btoa(svg2str(svg));
4321
4138
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
4322
4139
  const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).mount(render);
4323
4140
 
4324
- // const obj2str=(object)=>{
4325
- // const recursiveToString = (obj) => {
4326
- // if (Array.isArray(obj)) return arr2str(obj);
4327
- // if (typeof obj === 'object' && obj !== null) {
4328
- // return `{ ${Object.entries(obj)
4329
- // .map(([key, value]) => `${key}:${recursiveToString(value)}`)
4330
- // .join(" , ")} }`;
4331
- // }
4332
- // return String(obj);
4333
- // };
4334
- // return recursiveToString(object);
4335
- // };
4336
- // const obj2str = (object) => {
4337
- // const recursiveToString = (obj, indentLevel = 0) => {
4338
- // const indent = ' '.repeat(indentLevel);
4339
- // const nextIndent = ' '.repeat(indentLevel + 1);
4340
- // if(Array.isArray(obj)) return arr2str(obj, indentLevel);
4341
- // if(obj instanceof Complex || obj instanceof Matrix) return obj.toString();
4342
- // if (typeof obj === 'object' && obj !== null) {
4343
- // const entries = Object.entries(obj)
4344
- // .map(([key, value]) => `${nextIndent}${key}: ${recursiveToString(value, indentLevel + 1)}`)
4345
- // .join(",\n");
4346
-
4347
- // return `{\n${entries}\n${indent}}`;
4348
- // }
4349
-
4350
- // return String(obj);
4351
- // };
4352
-
4353
- // return recursiveToString(object);
4354
- // };
4355
- // const obj2str = (object, useIndentation = true, indentLevel = 0) => {
4356
- // const recursiveToString = (obj, level = 0) => {
4357
- // const indent = useIndentation ? ' '.repeat(level) : '';
4358
- // const nextIndent = useIndentation ? ' '.repeat(level + 1) : '';
4359
- // if (Array.isArray(obj)) return arr2str(obj, false, level);
4360
- // if(obj instanceof Complex || obj instanceof Matrix) return obj.toString();
4361
- // if (typeof obj === 'object' && obj !== null) {
4362
- // const entries = Object.entries(obj)
4363
- // .map(([key, value]) => useIndentation
4364
- // ? `${nextIndent}${key}: ${recursiveToString(value, level + 1)}`
4365
- // : `${key}: ${recursiveToString(value, level + 1)}`
4366
- // ).join(useIndentation ? ",\n" : ", ");
4367
-
4368
- // return useIndentation
4369
- // ? `{\n${entries}\n${indent}}`
4370
- // : `{${entries}}`;
4371
- // }
4372
-
4373
- // return String(obj);
4374
- // };
4375
-
4376
- // return recursiveToString(object, indentLevel);
4377
- // };
4378
-
4379
- const obj2str=(obj)=>JSON.stringify(
4380
- mapfun(n=>{
4381
- if(["number","string","boolean","bigint"].includes(typeof n)) return String(n);
4382
- if(n instanceof Complex || n instanceof Matrix) return n.toString();
4383
- if(n instanceof Array) return arr2str(n)
4384
- },
4385
- obj), null, " ")
4386
- .replace(/"([^"]+)":/g, '$1:') // Remove Quotes from Keys
4387
- .replace(/: "([^"]+)"/g, ': $1'); // Remove Quotes from str values
4388
-
4389
- const getMaxDepth = arr=> {
4390
- if (!Array.isArray(arr)) return 0;
4391
- let maxDepth = 1;
4392
- for (const element of arr) {
4393
- if (Array.isArray(element)) {
4394
- const depth = getMaxDepth(element);
4395
- if (depth + 1 > maxDepth) {
4396
- maxDepth = depth + 1;
4397
- }
4398
- }
4399
- }
4400
- return maxDepth;
4401
- };
4402
- const arr2str = (arr) => {
4403
- let level = 0;
4404
- function arrStringify(arr) {
4405
- let max = getMaxDepth(arr);
4406
- let useIdentation = 0;
4407
- if (arr.some((n) => Array.isArray(n))) {
4408
- level++;
4409
- useIdentation = 1;
4410
- }
4411
- return (
4412
- "[" +
4413
- arr.map((n, i) => {
4414
- if (["number", "string", "boolean", "bigint"].includes(typeof n))
4415
- return String(n);
4416
- if (n instanceof Complex) return n.toString();
4417
- if (n instanceof Array) {
4418
- return `\n${" ".repeat(level)}${arrStringify(n)}${i === arr.length - 1 ? "\n" : ""}`;
4419
- }
4420
- if( n instanceof Object) return obj2str(n);
4421
- })
4422
- + `${" ".repeat((max+level+1) * useIdentation)}]`
4423
- );
4424
- }
4425
- return arrStringify(arr);
4426
- };
4427
-
4428
4141
  const json2css=(json, indentLevel = 0)=>{
4429
4142
  json = trimKeys(json);
4430
4143
  let cssText = '';
@@ -4591,20 +4304,17 @@ const SPA=({head, wrapper, target, routes})=>new ZikoSPA({head, wrapper, target,
4591
4304
  // regEx
4592
4305
  */
4593
4306
 
4594
- function parseQueryParams(queryString) {
4595
- const params = {};
4596
- queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
4597
- const [key, value] = match.split('=');
4598
- params[key] = value;
4599
- });
4600
- return params;
4307
+ function parseQueryParams$1(queryString) {
4308
+ return Object.fromEntries(
4309
+ new URLSearchParams(location.search)
4310
+ );
4601
4311
  }
4602
4312
 
4603
4313
  function defineParamsGetter(target ){
4604
4314
  Object.defineProperties(target, {
4605
4315
  'QueryParams': {
4606
4316
  get: function() {
4607
- return parseQueryParams(globalThis.location.search.substring(1));
4317
+ return parseQueryParams$1(globalThis.location.search.substring(1));
4608
4318
  },
4609
4319
  configurable: false,
4610
4320
  enumerable: true
@@ -4700,6 +4410,49 @@ function useDerived(deriveFn, sources) {
4700
4410
  })
4701
4411
  }
4702
4412
 
4413
+ const mapfun=(fun,...X)=>{
4414
+ const Y=X.map(x=>{
4415
+ if(
4416
+ x===null||
4417
+ ["number","string","boolean","bigint","undefined"].includes(typeof x)||
4418
+ x?.__mapfun__
4419
+ ) return fun(x)
4420
+ if(x instanceof Array) return x.map(n=>mapfun(fun,n));
4421
+ if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
4422
+ if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
4423
+ if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
4424
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
4425
+ // if(x.isComplex?.()){
4426
+ // const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
4427
+ // switch(fun){
4428
+ // // Moved to Fixed to avoid Circular Dep
4429
+ // // case Math.log: return new x.constructor(ln(z),phi); // Done
4430
+ // // case Math.exp: return new x.constructor(e(a)*cos(b),e(a)*sin(b)); // Done
4431
+ // // case Math.abs: return z; // Done
4432
+ // // case Math.sqrt: return new x.constructor(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
4433
+ // // case Fixed.cos: return new x.constructor(cos(a)*cosh(b),-(sin(a)*sinh(b)));
4434
+ // // case Fixed.sin: return new x.constructor(sin(a)*cosh(b),cos(a)*sinh(b));
4435
+ // // case Fixed.tan:{
4436
+ // // const DEN = cos(2*a)+cosh(2*b);
4437
+ // // return new x.constructor(sin(2*a)/DEN,sinh(2*b)/DEN);
4438
+ // // }
4439
+ // // case Fixed.cosh:return new x.constructor(cosh(a)*cos(b),sinh(a)*sin(b));
4440
+ // // case Fixed.sinh:return new x.constructor(sinh(a)*cos(b),cosh(a)*sin(b));
4441
+ // // case Fixed.tanh:{
4442
+ // // const DEN=cosh(2*a)+cos(2*b);
4443
+ // // return new x.constructor(sinh(2*a)/DEN,sin(2*b)/DEN)
4444
+ // // }
4445
+ // default : return fun(x)
4446
+ // }
4447
+ // }
4448
+ else if(x instanceof Object){
4449
+ return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
4450
+ // return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
4451
+ }
4452
+ });
4453
+ return Y.length==1? Y[0]: Y;
4454
+ };
4455
+
4703
4456
  const useReactive = (nested_value) => mapfun(
4704
4457
  n => {
4705
4458
  const state = useState(n);
@@ -4999,6 +4752,77 @@ tags.p("Test useRoot ").style({
4999
4752
 
5000
4753
  */
5001
4754
 
4755
+ const parseQueryParams = queryString => Object.fromEntries(new URLSearchParams(globalThis?.location?.search));
4756
+
4757
+ function useQueryParams() {
4758
+ const getParams = () =>
4759
+ parseQueryParams();
4760
+
4761
+ const setParams = (updates, merge = true) => {
4762
+ const current = getParams();
4763
+
4764
+ const next =
4765
+ typeof updates === "function"
4766
+ ? updates(current)
4767
+ : updates;
4768
+
4769
+ const finalParams = merge
4770
+ ? { ...current, ...next }
4771
+ : next;
4772
+
4773
+ const search = new URLSearchParams(finalParams).toString();
4774
+
4775
+ window.history.pushState(
4776
+ {},
4777
+ "",
4778
+ `${window.location.pathname}${search ? `?${search}` : ""}`
4779
+ );
4780
+
4781
+ window.dispatchEvent(
4782
+ new CustomEvent("queryparamschange", {
4783
+ detail: finalParams
4784
+ })
4785
+ );
4786
+ };
4787
+
4788
+ return [getParams, setParams];
4789
+ }
4790
+
4791
+ function watchQueryParams(callback) {
4792
+ let previousSearch = location.search;
4793
+
4794
+ const notify = () => {
4795
+ const currentSearch = location.search;
4796
+
4797
+ if (currentSearch === previousSearch) {
4798
+ return;
4799
+ }
4800
+
4801
+ previousSearch = currentSearch;
4802
+ callback(parseQueryParams());
4803
+ };
4804
+
4805
+ window.addEventListener("popstate", notify);
4806
+
4807
+ const pushState = history.pushState;
4808
+ history.pushState = function (...args) {
4809
+ pushState.apply(this, args);
4810
+ notify();
4811
+ };
4812
+
4813
+ const replaceState = history.replaceState;
4814
+ history.replaceState = function (...args) {
4815
+ replaceState.apply(this, args);
4816
+ notify();
4817
+ };
4818
+
4819
+ callback(parseQueryParams());
4820
+
4821
+ return () => {
4822
+ window.removeEventListener("popstate", notify);
4823
+ };
4824
+ }
4825
+
5002
4826
  let {sqrt, cos: cos$1, sin: sin$1, exp, log, cosh: cosh$1, sinh} = Math;
5003
4827
  // Math.abs = new Proxy(Math.abs, {
5004
4828
  // apply(target, thisArg, args) {
@@ -5098,7 +4922,6 @@ exports.UISwitch = UISwitch;
5098
4922
  exports.UIView = UIView;
5099
4923
  exports.UseRoot = UseRoot;
5100
4924
  exports.UseThread = UseThread;
5101
- exports.Utils = Utils;
5102
4925
  exports.View = View;
5103
4926
  exports.ViewEvent = ViewEvent;
5104
4927
  exports.ViewListeners = ViewListeners;
@@ -5118,9 +4941,7 @@ exports.add_vendor_prefix = add_vendor_prefix;
5118
4941
  exports.and = and;
5119
4942
  exports.animation = animation;
5120
4943
  exports.apply_fun = apply_fun;
5121
- exports.arange = arange;
5122
4944
  exports.arc = arc;
5123
- exports.arr2str = arr2str;
5124
4945
  exports.asin = asin;
5125
4946
  exports.asinh = asinh;
5126
4947
  exports.atan = atan;
@@ -5129,7 +4950,6 @@ exports.atanh = atanh;
5129
4950
  exports.back = back;
5130
4951
  exports.binomial = binomial;
5131
4952
  exports.call_with_optional_props = call_with_optional_props;
5132
- exports.cartesianProduct = cartesianProduct;
5133
4953
  exports.cbrt = cbrt;
5134
4954
  exports.ceil = ceil;
5135
4955
  exports.clamp = clamp;
@@ -5155,9 +4975,7 @@ exports.elastic = elastic;
5155
4975
  exports.exp = exp$1;
5156
4976
  exports.floor = floor;
5157
4977
  exports.fract = fract;
5158
- exports.geomspace = geomspace;
5159
4978
  exports.hypot = hypot;
5160
- exports.inRange = inRange;
5161
4979
  exports.in_back = in_back;
5162
4980
  exports.in_bounce = in_bounce;
5163
4981
  exports.in_circ = in_circ;
@@ -5178,7 +4996,6 @@ exports.in_quad = in_quad;
5178
4996
  exports.in_quart = in_quart;
5179
4997
  exports.in_quint = in_quint;
5180
4998
  exports.in_sin = in_sin;
5181
- exports.isApproximatlyEqual = isApproximatlyEqual;
5182
4999
  exports.isPrimitive = isPrimitive;
5183
5000
  exports.isStateGetter = isStateGetter;
5184
5001
  exports.json2arr = json2arr;
@@ -5192,12 +5009,10 @@ exports.json2ymlFile = json2ymlFile;
5192
5009
  exports.lerp = lerp;
5193
5010
  exports.linear = linear;
5194
5011
  exports.linkStyle = linkStyle;
5195
- exports.linspace = linspace;
5196
5012
  exports.ln = ln;
5197
- exports.logspace = logspace;
5198
5013
  exports.loop = loop;
5199
5014
  exports.map = map$1;
5200
- exports.mapfun = mapfun;
5015
+ exports.mapfun = mapfun$1;
5201
5016
  exports.matrix = matrix;
5202
5017
  exports.matrix2 = matrix2;
5203
5018
  exports.matrix3 = matrix3;
@@ -5213,9 +5028,6 @@ exports.nor = nor;
5213
5028
  exports.norm = norm;
5214
5029
  exports.normalize_css_value = normalize_css_value;
5215
5030
  exports.nthr = nthr;
5216
- exports.nums = nums;
5217
- exports.obj2str = obj2str;
5218
- exports.ones = ones;
5219
5031
  exports.or = or;
5220
5032
  exports.out_back = out_back;
5221
5033
  exports.out_bounce = out_bounce;
@@ -5228,9 +5040,7 @@ exports.out_quart = out_quart;
5228
5040
  exports.out_quint = out_quint;
5229
5041
  exports.out_sin = out_sin;
5230
5042
  exports.percentile = percentile;
5231
- exports.pgcd = pgcd;
5232
5043
  exports.pow = pow$1;
5233
- exports.ppcm = ppcm;
5234
5044
  exports.rad2deg = rad2deg;
5235
5045
  exports.register_click_away_event = register_click_away_event;
5236
5046
  exports.register_swipe_event = register_swipe_event;
@@ -5269,6 +5079,7 @@ exports.useEventEmitter = useEventEmitter;
5269
5079
  exports.useIPC = useIPC;
5270
5080
  exports.useLocaleStorage = useLocaleStorage;
5271
5081
  exports.useMediaQuery = useMediaQuery;
5082
+ exports.useQueryParams = useQueryParams;
5272
5083
  exports.useReactive = useReactive;
5273
5084
  exports.useRoot = useRoot;
5274
5085
  exports.useSessionStorage = useSessionStorage;
@@ -5280,6 +5091,6 @@ exports.wait = wait;
5280
5091
  exports.waitElm = waitElm;
5281
5092
  exports.waitForUIElm = waitForUIElm;
5282
5093
  exports.waitForUIElmSync = waitForUIElmSync;
5094
+ exports.watchQueryParams = watchQueryParams;
5283
5095
  exports.xnor = xnor;
5284
5096
  exports.xor = xor;
5285
- exports.zeros = zeros;