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.js 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
@@ -19,18 +19,18 @@
19
19
 
20
20
  const is_primitive = value => typeof value !== 'object' && typeof value !== 'function' || value === null;
21
21
 
22
- const mapfun=(fun,...X)=>{
22
+ const mapfun$1=(fun,...X)=>{
23
23
  const Y=X.map(x=>{
24
24
  if(is_primitive(x) || x?.__mapfun__) return fun(x)
25
- if(x instanceof Array) return x.map(n=>mapfun(fun,n));
25
+ if(x instanceof Array) return x.map(n=>mapfun$1(fun,n));
26
26
  if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
27
- if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
28
- if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
29
- if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
27
+ if(x instanceof Set) return new Set(mapfun$1(fun,...[...x]));
28
+ if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun$1(fun,n[1])]));
29
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun$1(x.arr.flat(1)))
30
30
  else if(x instanceof Object){
31
31
  return Object.fromEntries(
32
32
  Object.entries(x).map(
33
- n=>n=[n[0],mapfun(fun,n[1])]
33
+ n=>n=[n[0],mapfun$1(fun,n[1])]
34
34
  )
35
35
  )
36
36
  }
@@ -48,7 +48,7 @@
48
48
  x.cols,
49
49
  x.arr.flat(1).map(fn)
50
50
  )
51
- if (x instanceof Array) mapfun(fn, ...x);
51
+ if (x instanceof Array) mapfun$1(fn, ...x);
52
52
  return fn(x)
53
53
  };
54
54
 
@@ -531,7 +531,7 @@
531
531
 
532
532
  const PRECESION = 8;
533
533
 
534
- const abs = (...x) => mapfun(
534
+ const abs = (...x) => mapfun$1(
535
535
  x =>{
536
536
  if(x.isComplex?.()) return x.z;
537
537
  return Math.abs(x)
@@ -541,7 +541,7 @@
541
541
 
542
542
  const pow$1 = (...x) => {
543
543
  const n = x.pop();
544
- return mapfun(
544
+ return mapfun$1(
545
545
  x => {
546
546
  if(x.isComplex?.()) {
547
547
  if(n.isComplex?.()) return new x.constructor({
@@ -560,7 +560,7 @@
560
560
  )
561
561
  };
562
562
 
563
- const sqrt$2 = (...x) => mapfun(
563
+ const sqrt$2 = (...x) => mapfun$1(
564
564
  x=>{
565
565
  if(x.isComplex?.())
566
566
  return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
@@ -570,7 +570,7 @@
570
570
  ...x
571
571
  );
572
572
 
573
- const cbrt = (...x) => mapfun(
573
+ const cbrt = (...x) => mapfun$1(
574
574
  x=>{
575
575
  if(x.isComplex?.())
576
576
  return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
@@ -582,7 +582,7 @@
582
582
  const nthr = (...x) => {
583
583
  const n = x.pop();
584
584
  if(typeof n !== 'number') throw Error('nthr expects a real number n');
585
- return mapfun(
585
+ return mapfun$1(
586
586
  x => {
587
587
  if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
588
588
  if(x<0) return n %2 ===2
@@ -597,7 +597,7 @@
597
597
  const croot = (...x) =>{
598
598
  const c = x.pop();
599
599
  if(!c.isComplex?.()) throw Error('croot expect Complex number as root')
600
- return mapfun(
600
+ return mapfun$1(
601
601
  x => {
602
602
  if(typeof x === 'number') x = new c.constructor(x, 0);
603
603
  const {a : c_a, b : c_b} = c;
@@ -614,7 +614,7 @@
614
614
  )
615
615
  };
616
616
 
617
- const exp$1 = (...x) => mapfun(
617
+ const exp$1 = (...x) => mapfun$1(
618
618
  x => {
619
619
  if(x.isComplex?.()) return new x.constructor(
620
620
  Math.exp(x.a) * Math.cos(x.b),
@@ -625,7 +625,7 @@
625
625
  ,...x
626
626
  );
627
627
 
628
- const ln = (...x) => mapfun(
628
+ const ln = (...x) => mapfun$1(
629
629
  x => {
630
630
  if(x.isComplex?.()) return new x.constructor(
631
631
  Math.log(x.z),
@@ -636,7 +636,7 @@
636
636
  ,...x
637
637
  );
638
638
 
639
- const sign = (...x) => mapfun(
639
+ const sign = (...x) => mapfun$1(
640
640
  x => {
641
641
  if(x.isComplex?.()){
642
642
  const {z, phi} = x;
@@ -648,7 +648,7 @@
648
648
  ,...x
649
649
  );
650
650
 
651
- const floor = (...x) => mapfun(
651
+ const floor = (...x) => mapfun$1(
652
652
  x => {
653
653
  if(x.isComplex?.()) return new x.constructor(
654
654
  Math.floor(x.a),
@@ -658,7 +658,7 @@
658
658
  },
659
659
  ...x
660
660
  );
661
- const ceil = (...x) => mapfun(
661
+ const ceil = (...x) => mapfun$1(
662
662
  x => {
663
663
  if(x.isComplex?.()) return new x.constructor(
664
664
  Math.ceil(x.a),
@@ -668,7 +668,7 @@
668
668
  },
669
669
  ...x
670
670
  );
671
- const round = (...x) => mapfun(
671
+ const round = (...x) => mapfun$1(
672
672
  x => {
673
673
  if(x.isComplex?.()) return new x.constructor(
674
674
  Math.round(x.a),
@@ -679,7 +679,7 @@
679
679
  ...x
680
680
  );
681
681
 
682
- const trunc = (...x) => mapfun(
682
+ const trunc = (...x) => mapfun$1(
683
683
  x => {
684
684
  if(x.isComplex?.()) return new x.constructor(
685
685
  Math.trunc(x.a),
@@ -690,7 +690,7 @@
690
690
  ...x
691
691
  );
692
692
 
693
- const fract = (...x) => mapfun(
693
+ const fract = (...x) => mapfun$1(
694
694
  x => {
695
695
  if(x.isComplex?.()) return new x.constructor(
696
696
  x.a - Math.trunc(x.a),
@@ -701,7 +701,7 @@
701
701
  ...x
702
702
  );
703
703
 
704
- const cos$3 = (...x) => mapfun(
704
+ const cos$3 = (...x) => mapfun$1(
705
705
  x => {
706
706
  if(x.isComplex?.()) return new x.constructor(
707
707
  Math.cos(x.a) * Math.cosh(x.b),
@@ -712,7 +712,7 @@
712
712
  ,...x
713
713
  );
714
714
 
715
- const sin$3 = (...x) => mapfun(
715
+ const sin$3 = (...x) => mapfun$1(
716
716
  x =>{
717
717
  if(x?.isComplex) return new x.constructor(
718
718
  Math.sin(x.a) * Math.cosh(x.b),
@@ -723,7 +723,7 @@
723
723
  , ...x
724
724
  );
725
725
 
726
- const tan = (...x) => mapfun(
726
+ const tan = (...x) => mapfun$1(
727
727
  x =>{
728
728
  if(x?.isComplex){
729
729
  const D = Math.cos(2*x.a) + Math.cosh(2*x.b);
@@ -737,7 +737,7 @@
737
737
  ...x
738
738
  );
739
739
 
740
- const sec = (...x) => mapfun(
740
+ const sec = (...x) => mapfun$1(
741
741
  x => {
742
742
  if(x.isComplex?.()) ;
743
743
  return + (1 / Math.cos(x)).toFixed(PRECESION)
@@ -745,7 +745,7 @@
745
745
  ,...x
746
746
  );
747
747
 
748
- const acos$1 = (...x) => mapfun(
748
+ const acos$1 = (...x) => mapfun$1(
749
749
  x =>{
750
750
  if(x?.isComplex){
751
751
  const { a, b } = x;
@@ -763,7 +763,7 @@
763
763
  ...x
764
764
  );
765
765
 
766
- const asin = (...x) => mapfun(
766
+ const asin = (...x) => mapfun$1(
767
767
  x => {
768
768
  if(x?.isComplex){
769
769
  const { a, b } = x;
@@ -779,7 +779,7 @@
779
779
  ...x
780
780
  );
781
781
 
782
- const atan = (...x) => mapfun(
782
+ const atan = (...x) => mapfun$1(
783
783
  x => {
784
784
  if(x?.isComplex){
785
785
  const { a, b } = x;
@@ -793,7 +793,7 @@
793
793
  ...x
794
794
  );
795
795
 
796
- const acot = (...x) => mapfun(
796
+ const acot = (...x) => mapfun$1(
797
797
  x => {
798
798
  if(x?.isComplex){
799
799
  const { a, b } = x;
@@ -808,7 +808,7 @@
808
808
  );
809
809
 
810
810
 
811
- const cosh$2 = (...x) => mapfun(
811
+ const cosh$2 = (...x) => mapfun$1(
812
812
  x =>{
813
813
  if(x?.isComplex) return new x.constructor(
814
814
  Math.cosh(x.a) * Math.cos(x.b),
@@ -818,7 +818,7 @@
818
818
  },
819
819
  ...x
820
820
  );
821
- const sinh$1 = (...x) => mapfun(
821
+ const sinh$1 = (...x) => mapfun$1(
822
822
  x =>{
823
823
  if(x?.isComplex) return new x.constructor(
824
824
  Math.sinh(x.a) * Math.cos(x.b),
@@ -828,7 +828,7 @@
828
828
  },
829
829
  ...x
830
830
  );
831
- const tanh = (...x) => mapfun(
831
+ const tanh = (...x) => mapfun$1(
832
832
  x =>{
833
833
  if(x?.isComplex){
834
834
  const D = Math.cosh(2*a) + Math.cos(2*b);
@@ -842,7 +842,7 @@
842
842
  ...x
843
843
  );
844
844
 
845
- const coth = (...x) => mapfun(
845
+ const coth = (...x) => mapfun$1(
846
846
  x =>{
847
847
  if(x?.isComplex){
848
848
  const {a, b} = x;
@@ -857,7 +857,7 @@
857
857
  ...x
858
858
  );
859
859
 
860
- const acosh = (...x) => mapfun(
860
+ const acosh = (...x) => mapfun$1(
861
861
  x =>{
862
862
  if(x?.isComplex){
863
863
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
@@ -867,7 +867,7 @@
867
867
  ...x
868
868
  );
869
869
 
870
- const asinh = (...x) => mapfun(
870
+ const asinh = (...x) => mapfun$1(
871
871
  x =>{
872
872
  if(x?.isComplex){
873
873
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
@@ -877,7 +877,7 @@
877
877
  ...x
878
878
  );
879
879
 
880
- const atanh = (...x) => mapfun(
880
+ const atanh = (...x) => mapfun$1(
881
881
  x =>{
882
882
  if(x?.isComplex);
883
883
  return + Math.atanh(x).toFixed(PRECESION)
@@ -885,7 +885,7 @@
885
885
  ...x
886
886
  );
887
887
 
888
- const sig = (...x) => mapfun(
888
+ const sig = (...x) => mapfun$1(
889
889
  x =>{
890
890
  if(x?.isComplex);
891
891
  return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
@@ -893,8 +893,8 @@
893
893
  ...x
894
894
  );
895
895
 
896
- const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
897
- const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
896
+ const deg2rad = (...deg) => mapfun$1(x => x * Math.PI / 180, ...deg);
897
+ const rad2deg = (...rad) => mapfun$1(x => x / Math.PI * 180, ...rad);
898
898
 
899
899
  const norm = (x, min, max) => apply_fun(
900
900
  x,
@@ -925,10 +925,10 @@
925
925
 
926
926
  const atan2 = (y, x, rad = true) => {
927
927
  if (y instanceof Array && !(x instanceof Array))
928
- return mapfun(n => atan2(n, x, rad), ...y);
928
+ return mapfun$1(n => atan2(n, x, rad), ...y);
929
929
 
930
930
  if (x instanceof Array && !(y instanceof Array))
931
- return mapfun(n => atan2(y, n, rad), ...x);
931
+ return mapfun$1(n => atan2(y, n, rad), ...x);
932
932
 
933
933
  if (y instanceof Array && x instanceof Array)
934
934
  return y.map((v, i) => atan2(v, x[i], rad));
@@ -1165,7 +1165,7 @@
1165
1165
  return new Matrix(this.rows, this.cols, this.arr.flat(1));
1166
1166
  }
1167
1167
  toComplex(){
1168
- this.arr = mapfun(
1168
+ this.arr = mapfun$1(
1169
1169
  x => x?.isComplex?.() ? x : new Complex(x, 0),
1170
1170
  ...this.arr
1171
1171
  );
@@ -1629,7 +1629,7 @@
1629
1629
  return new Matrix(v.length, 1, v);
1630
1630
  }
1631
1631
  serialize() {
1632
- const arr = mapfun(x => x.serialize?.() || x, ...this.arr);
1632
+ const arr = mapfun$1(x => x.serialize?.() || x, ...this.arr);
1633
1633
  return JSON.stringify({
1634
1634
  type : 'matrix',
1635
1635
  data : {
@@ -1644,7 +1644,7 @@
1644
1644
  const {type, data} = json;
1645
1645
  if(type !== 'matrix') return TypeError('Not a valid Matrix')
1646
1646
  let {arr} = data;
1647
- arr = mapfun(x => {
1647
+ arr = mapfun$1(x => {
1648
1648
  if(typeof x === 'string') {
1649
1649
  const x_obj = JSON.parse(x);
1650
1650
  const {type} = x_obj;
@@ -1675,186 +1675,6 @@
1675
1675
  const matrix3=(...element)=>new Matrix(3, 3, element);
1676
1676
  const matrix4=(...element)=>new Matrix(4, 4, element);
1677
1677
 
1678
- const zeros=(n)=>new Array(n).fill(0);
1679
- const ones=(n)=>new Array(n).fill(1);
1680
- const nums=(num,n)=>new Array(n).fill(num);
1681
-
1682
- const arange=(a, b, step , include = false)=>{
1683
- let tab = [];
1684
- if(a<b){
1685
- for (let i = a; include?i<=b:i<b; i += step) tab.push((i * 10) / 10);
1686
- }
1687
- else {
1688
- for(let i = a; include?i>=b:i>b; i -= step) tab.push((i * 10) / 10);
1689
- }
1690
- return tab;
1691
- };
1692
- const linspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
1693
- if(Math.floor(n)!==n)return;
1694
- if([a,b].every(n=>typeof n==="number")){
1695
- const [max,min]=[a,b].sort((a,b)=>b-a);
1696
- var Y = [];
1697
- let step ;
1698
- endpoint ? step = (max - min) / (n - 1) : step = (max - min) / n;
1699
- for (var i = 0; i < n; i++) {
1700
- a<b?Y.push(min+step*i):Y.push(max-step*i);
1701
- }
1702
- return Y
1703
- }
1704
-
1705
- if([a,b].some(n=>n.isComplex?.())){
1706
- const z1 = new n.constructor(a);
1707
- const z2 = new n.constructor(b);
1708
- n=n||Math.abs(z1.a-z2.a)+1;
1709
- const X=linspace(z1.a,z2.a,n,endpoint);
1710
- const Y=linspace(z1.b,z2.b,n,endpoint);
1711
- let Z=new Array(n).fill(null);
1712
- Z=Z.map((n,i)=> new n.constructor(X[i],Y[i]));
1713
- return Z;
1714
- }
1715
- };
1716
- const logspace=(a,b,n=b-a+1,base=E,endpoint=true)=>{
1717
- return linspace(a,b,n,endpoint).map(n=>pow$1(base,n))
1718
- };
1719
- const geomspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
1720
- if(Math.floor(n)!==n)return;
1721
- if([a,b].every(n=>typeof n==="number")){
1722
- const [max,min]=[a,b].sort((a,b)=>b-a);
1723
- let base;
1724
- endpoint ? base = nthr(max/min,n-1) : base = nthr(max/min,n) ;
1725
- const Y = [min];
1726
- for (let i = 1; i < n; i++) {
1727
- Y.push(Y[i-1]*base);
1728
- }
1729
- return a<b?Y:Y.reverse()
1730
- }
1731
-
1732
- if([a,b].some(n=>n.isComplex?.())){
1733
- const z1 = new n.constructor(a);
1734
- const z2 = new n.constructor(b);
1735
- n=n||Math.abs(z1.a-z2.a)+1;
1736
- let base;
1737
- endpoint ? base = nthr(z2.div(z1),n-1) : base = nthr(z2.div(z1),n) ;
1738
- const Y = [z1];
1739
- for (let i = 1; i < n; i++) {
1740
- Y.push(mul(Y[i-1],base));
1741
- }
1742
- return Y;
1743
- }
1744
- };
1745
-
1746
- /** @module Math */
1747
- /**
1748
- * Checks if a value is within the specified range.
1749
- * @function
1750
- * @param {number} x - The value to check.
1751
- * @param {number} a - The start of the range.
1752
- * @param {number} b - The end of the range.
1753
- * @returns {boolean} Returns true if the value is within the range [a, b], otherwise false.
1754
- */
1755
- const inRange = (x, a, b) => {
1756
- const [min, max] = [Math.min(a, b), Math.max(a, b)];
1757
- return x >= min && x <= max;
1758
- };
1759
-
1760
- /**
1761
- * Checks if two numbers are approximately equal within a given error margin.
1762
- * @param {number} a - The first number.
1763
- * @param {number} b - The second number.
1764
- * @param {number} [Err=0.0001] - The maximum acceptable difference between the two numbers.
1765
- * @returns {boolean} Returns true if the two numbers are approximately equal within the specified error margin, otherwise false.
1766
- */
1767
- const isApproximatlyEqual = (a, b, Err = 0.0001) => {
1768
- return Math.abs(a - b) <= Err;
1769
- };
1770
-
1771
- /** @module Math */
1772
-
1773
- /**
1774
- * Computes the cartesian product of two arrays.
1775
- * @param {Array} a - The first array.
1776
- * @param {Array} b - The second array.
1777
- * @returns {Array} Returns an array representing the cartesian product of the input arrays.
1778
- */
1779
- const cartesianProduct = (a, b) => a.reduce((p, x) => [...p, ...b.map((y) => [x, y])], []);
1780
-
1781
- /**
1782
- * Computes the greatest common divisor (GCD) of two numbers.
1783
- * @param {number} n1 - The first number.
1784
- * @param {number} n2 - The second number.
1785
- * @returns {number} Returns the greatest common divisor of the two input numbers.
1786
- */
1787
- const pgcd = (n1, n2) => {
1788
- let i,
1789
- pgcd = 1;
1790
- if (n1 == floor(n1) && n2 == floor(n2)) {
1791
- for (i = 2; i <= n1 && i <= n2; ++i) {
1792
- if (n1 % i == 0 && n2 % i == 0) pgcd = i;
1793
- }
1794
- return pgcd;
1795
- } else console.log("error");
1796
- };
1797
-
1798
- /**
1799
- * Computes the least common multiple (LCM) of two numbers.
1800
- * @param {number} n1 - The first number.
1801
- * @param {number} n2 - The second number.
1802
- * @returns {number} Returns the least common multiple of the two input numbers.
1803
- */
1804
- const ppcm = (n1, n2) => {
1805
- let ppcm;
1806
- if (n1 == floor(n1) && n2 == floor(n2)) {
1807
- ppcm = n1 > n2 ? n1 : n2;
1808
- while (true) {
1809
- if (ppcm % n1 == 0 && ppcm % n2 == 0) break;
1810
- ++ppcm;
1811
- }
1812
- return ppcm;
1813
- } else console.log("error");
1814
- };
1815
-
1816
- // import { mapfun } from "../mapfun/index.js";
1817
- // import {
1818
- // add,
1819
- // sub,
1820
- // mul,
1821
- // div,
1822
- // modulo
1823
- // } from "./arithmetic.js";
1824
- const Utils={
1825
- // add,
1826
- // sub,
1827
- // mul,
1828
- // div,
1829
- // modulo,
1830
-
1831
- zeros,
1832
- ones,
1833
- nums,
1834
- // norm,
1835
- // lerp,
1836
- // map,
1837
- // clamp,
1838
- arange,
1839
- linspace,
1840
- logspace,
1841
- geomspace,
1842
-
1843
- // sum,
1844
- // prod,
1845
- // accum,
1846
-
1847
- cartesianProduct,
1848
- ppcm,
1849
- pgcd,
1850
-
1851
- // deg2rad,
1852
- // rad2deg,
1853
-
1854
- inRange,
1855
- isApproximatlyEqual
1856
- };
1857
-
1858
1678
  class UINode {
1859
1679
  constructor(node){
1860
1680
  this.cache = {
@@ -1871,7 +1691,7 @@
1871
1691
 
1872
1692
  // globalThis.node = (node) => new UINode(node);
1873
1693
 
1874
- function parseQueryParams$1(queryString) {
1694
+ function parseQueryParams$2(queryString) {
1875
1695
  const params = {};
1876
1696
  queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
1877
1697
  const [key, value] = match.split('=');
@@ -1884,7 +1704,7 @@
1884
1704
  Object.defineProperties(target, {
1885
1705
  'QueryParams': {
1886
1706
  get: function() {
1887
- return parseQueryParams$1(globalThis.location.search.substring(1));
1707
+ return parseQueryParams$2(globalThis.location.search.substring(1));
1888
1708
  },
1889
1709
  configurable: false,
1890
1710
  enumerable: true
@@ -3351,9 +3171,6 @@
3351
3171
  `munder`, `munderover`
3352
3172
  ];
3353
3173
 
3354
- // const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
3355
- // const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
3356
-
3357
3174
  const tags = new Proxy({}, {
3358
3175
  get(target, prop) {
3359
3176
  if (typeof prop !== 'string') return undefined;
@@ -4325,110 +4142,6 @@
4325
4142
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
4326
4143
  const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).mount(render);
4327
4144
 
4328
- // const obj2str=(object)=>{
4329
- // const recursiveToString = (obj) => {
4330
- // if (Array.isArray(obj)) return arr2str(obj);
4331
- // if (typeof obj === 'object' && obj !== null) {
4332
- // return `{ ${Object.entries(obj)
4333
- // .map(([key, value]) => `${key}:${recursiveToString(value)}`)
4334
- // .join(" , ")} }`;
4335
- // }
4336
- // return String(obj);
4337
- // };
4338
- // return recursiveToString(object);
4339
- // };
4340
- // const obj2str = (object) => {
4341
- // const recursiveToString = (obj, indentLevel = 0) => {
4342
- // const indent = ' '.repeat(indentLevel);
4343
- // const nextIndent = ' '.repeat(indentLevel + 1);
4344
- // if(Array.isArray(obj)) return arr2str(obj, indentLevel);
4345
- // if(obj instanceof Complex || obj instanceof Matrix) return obj.toString();
4346
- // if (typeof obj === 'object' && obj !== null) {
4347
- // const entries = Object.entries(obj)
4348
- // .map(([key, value]) => `${nextIndent}${key}: ${recursiveToString(value, indentLevel + 1)}`)
4349
- // .join(",\n");
4350
-
4351
- // return `{\n${entries}\n${indent}}`;
4352
- // }
4353
-
4354
- // return String(obj);
4355
- // };
4356
-
4357
- // return recursiveToString(object);
4358
- // };
4359
- // const obj2str = (object, useIndentation = true, indentLevel = 0) => {
4360
- // const recursiveToString = (obj, level = 0) => {
4361
- // const indent = useIndentation ? ' '.repeat(level) : '';
4362
- // const nextIndent = useIndentation ? ' '.repeat(level + 1) : '';
4363
- // if (Array.isArray(obj)) return arr2str(obj, false, level);
4364
- // if(obj instanceof Complex || obj instanceof Matrix) return obj.toString();
4365
- // if (typeof obj === 'object' && obj !== null) {
4366
- // const entries = Object.entries(obj)
4367
- // .map(([key, value]) => useIndentation
4368
- // ? `${nextIndent}${key}: ${recursiveToString(value, level + 1)}`
4369
- // : `${key}: ${recursiveToString(value, level + 1)}`
4370
- // ).join(useIndentation ? ",\n" : ", ");
4371
-
4372
- // return useIndentation
4373
- // ? `{\n${entries}\n${indent}}`
4374
- // : `{${entries}}`;
4375
- // }
4376
-
4377
- // return String(obj);
4378
- // };
4379
-
4380
- // return recursiveToString(object, indentLevel);
4381
- // };
4382
-
4383
- const obj2str=(obj)=>JSON.stringify(
4384
- mapfun(n=>{
4385
- if(["number","string","boolean","bigint"].includes(typeof n)) return String(n);
4386
- if(n instanceof Complex || n instanceof Matrix) return n.toString();
4387
- if(n instanceof Array) return arr2str(n)
4388
- },
4389
- obj), null, " ")
4390
- .replace(/"([^"]+)":/g, '$1:') // Remove Quotes from Keys
4391
- .replace(/: "([^"]+)"/g, ': $1'); // Remove Quotes from str values
4392
-
4393
- const getMaxDepth = arr=> {
4394
- if (!Array.isArray(arr)) return 0;
4395
- let maxDepth = 1;
4396
- for (const element of arr) {
4397
- if (Array.isArray(element)) {
4398
- const depth = getMaxDepth(element);
4399
- if (depth + 1 > maxDepth) {
4400
- maxDepth = depth + 1;
4401
- }
4402
- }
4403
- }
4404
- return maxDepth;
4405
- };
4406
- const arr2str = (arr) => {
4407
- let level = 0;
4408
- function arrStringify(arr) {
4409
- let max = getMaxDepth(arr);
4410
- let useIdentation = 0;
4411
- if (arr.some((n) => Array.isArray(n))) {
4412
- level++;
4413
- useIdentation = 1;
4414
- }
4415
- return (
4416
- "[" +
4417
- arr.map((n, i) => {
4418
- if (["number", "string", "boolean", "bigint"].includes(typeof n))
4419
- return String(n);
4420
- if (n instanceof Complex) return n.toString();
4421
- if (n instanceof Array) {
4422
- return `\n${" ".repeat(level)}${arrStringify(n)}${i === arr.length - 1 ? "\n" : ""}`;
4423
- }
4424
- if( n instanceof Object) return obj2str(n);
4425
- })
4426
- + `${" ".repeat((max+level+1) * useIdentation)}]`
4427
- );
4428
- }
4429
- return arrStringify(arr);
4430
- };
4431
-
4432
4145
  const json2css=(json, indentLevel = 0)=>{
4433
4146
  json = trimKeys(json);
4434
4147
  let cssText = '';
@@ -4595,20 +4308,17 @@
4595
4308
  // regEx
4596
4309
  */
4597
4310
 
4598
- function parseQueryParams(queryString) {
4599
- const params = {};
4600
- queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
4601
- const [key, value] = match.split('=');
4602
- params[key] = value;
4603
- });
4604
- return params;
4311
+ function parseQueryParams$1(queryString) {
4312
+ return Object.fromEntries(
4313
+ new URLSearchParams(location.search)
4314
+ );
4605
4315
  }
4606
4316
 
4607
4317
  function defineParamsGetter(target ){
4608
4318
  Object.defineProperties(target, {
4609
4319
  'QueryParams': {
4610
4320
  get: function() {
4611
- return parseQueryParams(globalThis.location.search.substring(1));
4321
+ return parseQueryParams$1(globalThis.location.search.substring(1));
4612
4322
  },
4613
4323
  configurable: false,
4614
4324
  enumerable: true
@@ -4704,6 +4414,49 @@
4704
4414
  })
4705
4415
  }
4706
4416
 
4417
+ const mapfun=(fun,...X)=>{
4418
+ const Y=X.map(x=>{
4419
+ if(
4420
+ x===null||
4421
+ ["number","string","boolean","bigint","undefined"].includes(typeof x)||
4422
+ x?.__mapfun__
4423
+ ) return fun(x)
4424
+ if(x instanceof Array) return x.map(n=>mapfun(fun,n));
4425
+ if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
4426
+ if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
4427
+ if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
4428
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
4429
+ // if(x.isComplex?.()){
4430
+ // const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
4431
+ // switch(fun){
4432
+ // // Moved to Fixed to avoid Circular Dep
4433
+ // // case Math.log: return new x.constructor(ln(z),phi); // Done
4434
+ // // case Math.exp: return new x.constructor(e(a)*cos(b),e(a)*sin(b)); // Done
4435
+ // // case Math.abs: return z; // Done
4436
+ // // case Math.sqrt: return new x.constructor(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
4437
+ // // case Fixed.cos: return new x.constructor(cos(a)*cosh(b),-(sin(a)*sinh(b)));
4438
+ // // case Fixed.sin: return new x.constructor(sin(a)*cosh(b),cos(a)*sinh(b));
4439
+ // // case Fixed.tan:{
4440
+ // // const DEN = cos(2*a)+cosh(2*b);
4441
+ // // return new x.constructor(sin(2*a)/DEN,sinh(2*b)/DEN);
4442
+ // // }
4443
+ // // case Fixed.cosh:return new x.constructor(cosh(a)*cos(b),sinh(a)*sin(b));
4444
+ // // case Fixed.sinh:return new x.constructor(sinh(a)*cos(b),cosh(a)*sin(b));
4445
+ // // case Fixed.tanh:{
4446
+ // // const DEN=cosh(2*a)+cos(2*b);
4447
+ // // return new x.constructor(sinh(2*a)/DEN,sin(2*b)/DEN)
4448
+ // // }
4449
+ // default : return fun(x)
4450
+ // }
4451
+ // }
4452
+ else if(x instanceof Object){
4453
+ return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
4454
+ // return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
4455
+ }
4456
+ });
4457
+ return Y.length==1? Y[0]: Y;
4458
+ };
4459
+
4707
4460
  const useReactive = (nested_value) => mapfun(
4708
4461
  n => {
4709
4462
  const state = useState(n);
@@ -5003,6 +4756,77 @@
5003
4756
 
5004
4757
  */
5005
4758
 
4759
+ const parseQueryParams = queryString => Object.fromEntries(new URLSearchParams(globalThis?.location?.search));
4760
+
4761
+ function useQueryParams() {
4762
+ const getParams = () =>
4763
+ parseQueryParams();
4764
+
4765
+ const setParams = (updates, merge = true) => {
4766
+ const current = getParams();
4767
+
4768
+ const next =
4769
+ typeof updates === "function"
4770
+ ? updates(current)
4771
+ : updates;
4772
+
4773
+ const finalParams = merge
4774
+ ? { ...current, ...next }
4775
+ : next;
4776
+
4777
+ const search = new URLSearchParams(finalParams).toString();
4778
+
4779
+ window.history.pushState(
4780
+ {},
4781
+ "",
4782
+ `${window.location.pathname}${search ? `?${search}` : ""}`
4783
+ );
4784
+
4785
+ window.dispatchEvent(
4786
+ new CustomEvent("queryparamschange", {
4787
+ detail: finalParams
4788
+ })
4789
+ );
4790
+ };
4791
+
4792
+ return [getParams, setParams];
4793
+ }
4794
+
4795
+ function watchQueryParams(callback) {
4796
+ let previousSearch = location.search;
4797
+
4798
+ const notify = () => {
4799
+ const currentSearch = location.search;
4800
+
4801
+ if (currentSearch === previousSearch) {
4802
+ return;
4803
+ }
4804
+
4805
+ previousSearch = currentSearch;
4806
+ callback(parseQueryParams());
4807
+ };
4808
+
4809
+ window.addEventListener("popstate", notify);
4810
+
4811
+ const pushState = history.pushState;
4812
+ history.pushState = function (...args) {
4813
+ pushState.apply(this, args);
4814
+ notify();
4815
+ };
4816
+
4817
+ const replaceState = history.replaceState;
4818
+ history.replaceState = function (...args) {
4819
+ replaceState.apply(this, args);
4820
+ notify();
4821
+ };
4822
+
4823
+ callback(parseQueryParams());
4824
+
4825
+ return () => {
4826
+ window.removeEventListener("popstate", notify);
4827
+ };
4828
+ }
4829
+
5006
4830
  let {sqrt, cos: cos$1, sin: sin$1, exp, log, cosh: cosh$1, sinh} = Math;
5007
4831
  // Math.abs = new Proxy(Math.abs, {
5008
4832
  // apply(target, thisArg, args) {
@@ -5102,7 +4926,6 @@
5102
4926
  exports.UIView = UIView;
5103
4927
  exports.UseRoot = UseRoot;
5104
4928
  exports.UseThread = UseThread;
5105
- exports.Utils = Utils;
5106
4929
  exports.View = View;
5107
4930
  exports.ViewEvent = ViewEvent;
5108
4931
  exports.ViewListeners = ViewListeners;
@@ -5122,9 +4945,7 @@
5122
4945
  exports.and = and;
5123
4946
  exports.animation = animation;
5124
4947
  exports.apply_fun = apply_fun;
5125
- exports.arange = arange;
5126
4948
  exports.arc = arc;
5127
- exports.arr2str = arr2str;
5128
4949
  exports.asin = asin;
5129
4950
  exports.asinh = asinh;
5130
4951
  exports.atan = atan;
@@ -5133,7 +4954,6 @@
5133
4954
  exports.back = back;
5134
4955
  exports.binomial = binomial;
5135
4956
  exports.call_with_optional_props = call_with_optional_props;
5136
- exports.cartesianProduct = cartesianProduct;
5137
4957
  exports.cbrt = cbrt;
5138
4958
  exports.ceil = ceil;
5139
4959
  exports.clamp = clamp;
@@ -5159,9 +4979,7 @@
5159
4979
  exports.exp = exp$1;
5160
4980
  exports.floor = floor;
5161
4981
  exports.fract = fract;
5162
- exports.geomspace = geomspace;
5163
4982
  exports.hypot = hypot;
5164
- exports.inRange = inRange;
5165
4983
  exports.in_back = in_back;
5166
4984
  exports.in_bounce = in_bounce;
5167
4985
  exports.in_circ = in_circ;
@@ -5182,7 +5000,6 @@
5182
5000
  exports.in_quart = in_quart;
5183
5001
  exports.in_quint = in_quint;
5184
5002
  exports.in_sin = in_sin;
5185
- exports.isApproximatlyEqual = isApproximatlyEqual;
5186
5003
  exports.isPrimitive = isPrimitive;
5187
5004
  exports.isStateGetter = isStateGetter;
5188
5005
  exports.json2arr = json2arr;
@@ -5196,12 +5013,10 @@
5196
5013
  exports.lerp = lerp;
5197
5014
  exports.linear = linear;
5198
5015
  exports.linkStyle = linkStyle;
5199
- exports.linspace = linspace;
5200
5016
  exports.ln = ln;
5201
- exports.logspace = logspace;
5202
5017
  exports.loop = loop;
5203
5018
  exports.map = map$1;
5204
- exports.mapfun = mapfun;
5019
+ exports.mapfun = mapfun$1;
5205
5020
  exports.matrix = matrix;
5206
5021
  exports.matrix2 = matrix2;
5207
5022
  exports.matrix3 = matrix3;
@@ -5217,9 +5032,6 @@
5217
5032
  exports.norm = norm;
5218
5033
  exports.normalize_css_value = normalize_css_value;
5219
5034
  exports.nthr = nthr;
5220
- exports.nums = nums;
5221
- exports.obj2str = obj2str;
5222
- exports.ones = ones;
5223
5035
  exports.or = or;
5224
5036
  exports.out_back = out_back;
5225
5037
  exports.out_bounce = out_bounce;
@@ -5232,9 +5044,7 @@
5232
5044
  exports.out_quint = out_quint;
5233
5045
  exports.out_sin = out_sin;
5234
5046
  exports.percentile = percentile;
5235
- exports.pgcd = pgcd;
5236
5047
  exports.pow = pow$1;
5237
- exports.ppcm = ppcm;
5238
5048
  exports.rad2deg = rad2deg;
5239
5049
  exports.register_click_away_event = register_click_away_event;
5240
5050
  exports.register_swipe_event = register_swipe_event;
@@ -5273,6 +5083,7 @@
5273
5083
  exports.useIPC = useIPC;
5274
5084
  exports.useLocaleStorage = useLocaleStorage;
5275
5085
  exports.useMediaQuery = useMediaQuery;
5086
+ exports.useQueryParams = useQueryParams;
5276
5087
  exports.useReactive = useReactive;
5277
5088
  exports.useRoot = useRoot;
5278
5089
  exports.useSessionStorage = useSessionStorage;
@@ -5284,8 +5095,8 @@
5284
5095
  exports.waitElm = waitElm;
5285
5096
  exports.waitForUIElm = waitForUIElm;
5286
5097
  exports.waitForUIElmSync = waitForUIElmSync;
5098
+ exports.watchQueryParams = watchQueryParams;
5287
5099
  exports.xnor = xnor;
5288
5100
  exports.xor = xor;
5289
- exports.zeros = zeros;
5290
5101
 
5291
5102
  }));