ziko 0.41.2 → 0.42.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 : 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
@@ -13,23 +13,23 @@
13
13
  const { PI: PI$2, E } = Math;
14
14
  const EPSILON=Number.EPSILON;
15
15
 
16
- 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;
16
+ 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;
17
17
  let Fixed={
18
- cos: cos$2,
19
- sin: sin$2,
18
+ cos: cos$3,
19
+ sin: sin$3,
20
20
  tan: tan$1,
21
- sinc: x => sin$2(PI$1*x)/(PI$1*x),
22
- sec: x => 1/cos$2(x),
23
- csc: x => 1/sin$2(x),
21
+ sinc: x => sin$3(PI$1*x)/(PI$1*x),
22
+ sec: x => 1/cos$3(x),
23
+ csc: x => 1/sin$3(x),
24
24
  cot: x => 1/tan$1(x),
25
25
  acos: acos$2,
26
26
  asin: asin$1,
27
27
  atan: atan$1,
28
28
  acot: x => PI$1/2-atan$1(x),
29
- cosh: cosh$1,
30
- sinh: sinh$1,
29
+ cosh: cosh$2,
30
+ sinh: sinh$2,
31
31
  tanh: tanh$1,
32
- coth: n => (1/2*log((1+n)/(1-n))),
32
+ coth: n => (1/2*log$1((1+n)/(1-n))),
33
33
  acosh: acosh$1,
34
34
  asinh: asinh$1,
35
35
  atanh: atanh$1,
@@ -63,20 +63,20 @@ const mapfun$1=(fun,...X)=>{
63
63
  const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
64
64
  switch(fun){
65
65
  case Math.log: return complex(ln(z),phi); // Done
66
- case Math.exp: return complex(e(a)*cos$1(b),e(a)*sin$1(b)); // Done
66
+ case Math.exp: return complex(e(a)*cos$2(b),e(a)*sin$2(b)); // Done
67
67
  case Math.abs: return z; // Done
68
- case Math.sqrt: return complex(sqrt$1(z)*cos$1(phi/2),sqrt$1(z)*sin$1(phi/2)); // Done
69
- case Fixed.cos: return complex(cos$1(a)*cosh(b),-(sin$1(a)*sinh(b)));
70
- case Fixed.sin: return complex(sin$1(a)*cosh(b),cos$1(a)*sinh(b));
68
+ case Math.sqrt: return complex(sqrt$2(z)*cos$2(phi/2),sqrt$2(z)*sin$2(phi/2)); // Done
69
+ case Fixed.cos: return complex(cos$2(a)*cosh$1(b),-(sin$2(a)*sinh$1(b)));
70
+ case Fixed.sin: return complex(sin$2(a)*cosh$1(b),cos$2(a)*sinh$1(b));
71
71
  case Fixed.tan:{
72
- const DEN = cos$1(2*a)+cosh(2*b);
73
- return complex(sin$1(2*a)/DEN,sinh(2*b)/DEN);
72
+ const DEN = cos$2(2*a)+cosh$1(2*b);
73
+ return complex(sin$2(2*a)/DEN,sinh$1(2*b)/DEN);
74
74
  }
75
- case Fixed.cosh:return complex(cosh(a)*cos$1(b),sinh(a)*sin$1(b));
76
- case Fixed.sinh:return complex(sinh(a)*cos$1(b),cosh(a)*sin$1(b));
75
+ case Fixed.cosh:return complex(cosh$1(a)*cos$2(b),sinh$1(a)*sin$2(b));
76
+ case Fixed.sinh:return complex(sinh$1(a)*cos$2(b),cosh$1(a)*sin$2(b));
77
77
  case Fixed.tanh:{
78
- const DEN=cosh(2*a)+cos$1(2*b);
79
- return complex(sinh(2*a)/DEN,sin$1(2*b)/DEN)
78
+ const DEN=cosh$1(2*a)+cos$2(2*b);
79
+ return complex(sinh$1(2*a)/DEN,sin$2(2*b)/DEN)
80
80
  }
81
81
  default : return fun(x)
82
82
  }
@@ -947,6 +947,21 @@ const preload=(url)=>{
947
947
  }
948
948
  };
949
949
 
950
+ async function fetchdom(url='https://github.com/zakarialaoui10'){
951
+ const data=await fetch(url);
952
+ const html=await data.text();
953
+ const dom= new DOMParser().parseFromString(html,'text/xml');
954
+ return dom.documentElement
955
+ }
956
+ function fetchdomSync(url='https://github.com/zakarialaoui10'){
957
+ const data=preload(url);
958
+ const dom= new DOMParser().parseFromString(data,'text/xml');
959
+ return dom.documentElement;
960
+ }
961
+
962
+ globalThis.fetchdom=fetchdom;
963
+ globalThis.fetchdomSync=fetchdomSync;
964
+
950
965
  const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
951
966
  const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
952
967
  const csv2object = (csv, delimiter = ",") => {
@@ -1102,59 +1117,180 @@ const register = (target, ...mixins) => {
1102
1117
  else register_to_instance(target, ...mixins);
1103
1118
  };
1104
1119
 
1120
+ function parseQueryParams$1(queryString) {
1121
+ const params = {};
1122
+ queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
1123
+ const [key, value] = match.split('=');
1124
+ params[key] = value;
1125
+ });
1126
+ return params;
1127
+ }
1128
+
1129
+ function defineParamsGetter$1(target ){
1130
+ Object.defineProperties(target, {
1131
+ 'QueryParams': {
1132
+ get: function() {
1133
+ return parseQueryParams$1(globalThis.location.search.substring(1));
1134
+ },
1135
+ configurable: false,
1136
+ enumerable: true
1137
+ },
1138
+ 'HashParams': {
1139
+ get: function() {
1140
+ const hash = globalThis.location.hash.substring(1);
1141
+ return hash.split("#");
1142
+ },
1143
+ configurable: false,
1144
+ enumerable: true
1145
+ }
1146
+ });
1147
+ }
1148
+
1149
+ const __UI__={
1150
+ __all__(){
1151
+ return Object.values(this)
1152
+ .filter(Array.isArray)
1153
+ .flat();
1154
+ },
1155
+ querySelectorAll(){
1156
+ return this.__all__().filter(n=>n)
1157
+ },
1158
+ getElementByIndex(index){
1159
+ return this.__all__().find(n=>n.ui_index===index);
1160
+ },
1161
+ getElementById(id){
1162
+ return null;
1163
+ },
1164
+ getElementsByClass(){
1165
+
1166
+ },
1167
+ getElementsByTagName(){
1168
+
1169
+ }
1170
+ };
1171
+
1172
+ const __Config__ = {
1173
+ default:{
1174
+ target:null,
1175
+ render:true,
1176
+ math:{
1177
+ mode:"deg"
1178
+ }
1179
+ },
1180
+ setDefault:function(pairs){
1181
+ const keys=Object.keys(pairs);
1182
+ const values=Object.values(pairs);
1183
+ for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
1184
+ },
1185
+ init:()=>{
1186
+ // document.documentElement.setAttribute("data-engine","zikojs")
1187
+ },
1188
+ renderingMode :"spa",
1189
+ isSSC : false,
1190
+ };
1191
+
1192
+ const __HYDRATION__ = {
1193
+ map : new Map(),
1194
+ index : 0,
1195
+ increment : function(){
1196
+ return this.index ++
1197
+ }
1198
+ };
1199
+
1200
+ const __CACHE__ = {
1201
+ ui_index : 0,
1202
+ get_ui_index:function(){
1203
+ return this.ui_index ++
1204
+ }
1205
+ };
1206
+
1207
+ const __State__ = {
1208
+ store : new Map(),
1209
+ index : undefined?.data?.__Ziko__?.__State__?.index ?? 0,
1210
+ register: function(state){
1211
+ console.log({
1212
+ hmr : undefined?.data.__Ziko__.__State__.index,
1213
+ index : this.index
1214
+ });
1215
+ this.store.set(this.index++, state);
1216
+ }
1217
+
1218
+ };
1219
+
1220
+ function __init__global__(){
1221
+ if ( !globalThis?.__Ziko__ ){
1222
+ globalThis.__Ziko__ = {
1223
+ __UI__,
1224
+ __HYDRATION__,
1225
+ __State__,
1226
+ // __HYDRATION_MAP__,
1227
+ __Config__,
1228
+ __CACHE__,
1229
+ };
1230
+ defineParamsGetter$1(__Ziko__);
1231
+ }
1232
+ }
1233
+
1234
+ if(!globalThis.__Ziko__) __init__global__();
1235
+
1236
+ // HMR persistence
1237
+ if (undefined) {
1238
+ undefined.data.__Ziko__ = undefined.data.__Ziko__ || globalThis.__Ziko__;
1239
+ globalThis.__Ziko__ = undefined.data.__Ziko__;
1240
+ // import.meta.hot.accept(n=>console.log(n));
1241
+ // console.log(import.meta.hot.data.__Ziko__.__State__.store)
1242
+ }
1243
+
1244
+
1245
+
1105
1246
  function useState(initialValue) {
1106
- let value = initialValue;
1107
- const subscribers = new Set();
1108
- let paused = false;
1247
+
1248
+ // console.log(import.meta.hot.data.__Ziko__.__State__.store.get(0))
1249
+
1250
+ const {store, index} = __Ziko__.__State__;
1251
+ __Ziko__.__State__.register({
1252
+ value : initialValue,
1253
+ subscribers : new Set(),
1254
+ paused : false
1255
+ });
1256
+
1257
+ const current = store.get(index);
1109
1258
 
1110
1259
  function getValue() {
1111
1260
  return {
1112
- value,
1261
+ value: current.value,
1113
1262
  isStateGetter: () => true,
1114
- _subscribe: (
1115
- fn,
1116
- // UIElement
1117
- ) => {
1118
- subscribers.add(fn);
1119
-
1120
- // const observer = new MutationObserver(() => {
1121
- // if (!document.body.contains(UIElement.element)) {
1122
- // subscribers.delete(fn);
1123
- // observer.disconnect();
1124
- // }
1125
- // });
1126
-
1127
- // observer.observe(document.body, { childList: true, subtree: true });
1128
- },
1263
+ _subscribe: (fn) => current.subscribers.add(fn),
1129
1264
  };
1130
1265
  }
1131
1266
 
1132
1267
  function setValue(newValue) {
1133
- if (paused) return;
1134
- if (typeof newValue === "function") newValue = newValue(value);
1135
- if (newValue !== value) {
1136
- value = newValue;
1137
- subscribers.forEach(fn => fn(value));
1268
+ if (current.paused) return;
1269
+ if (typeof newValue === "function") newValue = newValue(current.value);
1270
+ if (newValue !== current.value) {
1271
+ current.value = newValue;
1272
+ current.subscribers.forEach(fn => fn(current.value));
1138
1273
  }
1139
1274
  }
1140
1275
 
1141
1276
  const controller = {
1142
- pause: () => { paused = true; },
1143
- resume: () => { paused = false; },
1144
- clear: () => { subscribers.clear(); },
1145
- force: (newValue) => { // force update even if paused
1146
- if (typeof newValue === "function") newValue = newValue(value);
1147
- value = newValue;
1148
- subscribers.forEach(fn => fn(value));
1277
+ pause: () => { current.paused = true; },
1278
+ resume: () => { current.paused = false; },
1279
+ clear: () => { current.subscribers.clear(); },
1280
+ force: (newValue) => {
1281
+ if (typeof newValue === "function") newValue = newValue(current.value);
1282
+ current.value = newValue;
1283
+ current.subscribers.forEach(fn => fn(current.value));
1149
1284
  },
1150
- getSubscribers: () => new Set(subscribers),
1285
+ getSubscribers: () => new Set(current.subscribers),
1151
1286
  };
1152
1287
 
1153
1288
  return [getValue, setValue, controller];
1154
1289
  }
1155
1290
 
1291
+
1156
1292
  const isStateGetter = (arg) => {
1157
- return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
1293
+ return typeof arg === 'function' && arg?.()?.isStateGetter?.();
1158
1294
  };
1159
1295
 
1160
1296
  const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
@@ -2733,107 +2869,6 @@ class ZikoUseMediaQuery {
2733
2869
 
2734
2870
  const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
2735
2871
 
2736
- function parseQueryParams$1(queryString) {
2737
- const params = {};
2738
- queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
2739
- const [key, value] = match.split('=');
2740
- params[key] = value;
2741
- });
2742
- return params;
2743
- }
2744
-
2745
- function defineParamsGetter$1(target ){
2746
- Object.defineProperties(target, {
2747
- 'QueryParams': {
2748
- get: function() {
2749
- return parseQueryParams$1(globalThis.location.search.substring(1));
2750
- },
2751
- configurable: false,
2752
- enumerable: true
2753
- },
2754
- 'HashParams': {
2755
- get: function() {
2756
- const hash = globalThis.location.hash.substring(1);
2757
- return hash.split("#");
2758
- },
2759
- configurable: false,
2760
- enumerable: true
2761
- }
2762
- });
2763
- }
2764
-
2765
- const __UI__={
2766
- __all__(){
2767
- return Object.values(this)
2768
- .filter(Array.isArray)
2769
- .flat();
2770
- },
2771
- querySelectorAll(){
2772
- return this.__all__().filter(n=>n)
2773
- },
2774
- getElementByIndex(index){
2775
- return this.__all__().find(n=>n.ui_index===index);
2776
- },
2777
- getElementById(id){
2778
- return null;
2779
- },
2780
- getElementsByClass(){
2781
-
2782
- },
2783
- getElementsByTagName(){
2784
-
2785
- }
2786
- };
2787
-
2788
- const __Config__ = {
2789
- default:{
2790
- target:null,
2791
- render:true,
2792
- math:{
2793
- mode:"deg"
2794
- }
2795
- },
2796
- setDefault:function(pairs){
2797
- const keys=Object.keys(pairs);
2798
- const values=Object.values(pairs);
2799
- for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
2800
- },
2801
- init:()=>{
2802
- // document.documentElement.setAttribute("data-engine","zikojs")
2803
- },
2804
- renderingMode :"spa",
2805
- isSSC : false,
2806
- };
2807
-
2808
- const __HYDRATION__ = {
2809
- map : new Map(),
2810
- index : 0,
2811
- increment : function(){
2812
- return this.index ++
2813
- }
2814
- };
2815
- const __HYDRATION_MAP__ = new Map();
2816
-
2817
- const __CACHE__ = {
2818
- ui_index : 0,
2819
- get_ui_index:function(){
2820
- return this.ui_index ++
2821
- }
2822
- };
2823
-
2824
- function __init__global__(){
2825
- if ( !globalThis?.__Ziko__ ){
2826
- globalThis.__Ziko__ = {
2827
- __UI__,
2828
- __HYDRATION__,
2829
- __HYDRATION_MAP__,
2830
- __Config__,
2831
- __CACHE__,
2832
- };
2833
- defineParamsGetter$1(__Ziko__);
2834
- }
2835
- }
2836
-
2837
2872
  __init__global__();
2838
2873
  class UIElement extends UINode{
2839
2874
  constructor({element, name ='', type="html", useDefaultStyle=false}={}){
@@ -3656,7 +3691,15 @@ class ZikoUISvg extends UIElement {
3656
3691
 
3657
3692
  const Svg =(w,h)=>new ZikoUISvg(w,h);
3658
3693
 
3659
- function defineWC(name, UIElement, props = {}, { mode = 'open'} = {}) {
3694
+ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
3695
+ if (globalThis.customElements?.get(name)) {
3696
+ console.warn(`Custom element "${name}" is already defined`);
3697
+ return; // skip redefinition
3698
+ }
3699
+ if(name.search('-') === -1){
3700
+ console.warn(`"${name}" is not a valid custom element name`);
3701
+ return;
3702
+ }
3660
3703
  globalThis.customElements?.define(
3661
3704
  name,
3662
3705
  class extends HTMLElement {
@@ -4518,7 +4561,7 @@ class Complex extends ZikoMath{
4518
4561
  }
4519
4562
  else if(("a" in b && "z" in a)){
4520
4563
  this.a=a.a;
4521
- this.b=sqrt$1((a.z**2)-(a.a**2));
4564
+ this.b=sqrt$2((a.z**2)-(a.a**2));
4522
4565
  }
4523
4566
  else if(("a" in b && "phi" in a)){
4524
4567
  this.a=a.a;
@@ -4526,15 +4569,15 @@ class Complex extends ZikoMath{
4526
4569
  }
4527
4570
  else if(("b" in b && "z" in a)){
4528
4571
  this.b=a.b;
4529
- this.a=sqrt$1((a.z**2)-(a.b**2));
4572
+ this.a=sqrt$2((a.z**2)-(a.b**2));
4530
4573
  }
4531
4574
  else if(("b" in b && "phi" in a)){
4532
4575
  this.b=b;
4533
4576
  this.a=a.b/tan(a.phi);
4534
4577
  }
4535
4578
  else if(("z" in b && "phi" in a)){
4536
- this.a=a.z*cos$1(a.phi);
4537
- this.a=a.z*sin$1(a.phi);
4579
+ this.a=a.z*cos$2(a.phi);
4580
+ this.a=a.z*sin$2(a.phi);
4538
4581
  }
4539
4582
  }
4540
4583
  else if(typeof(a)==="number"&&typeof(b)==="number"){
@@ -4602,8 +4645,8 @@ class Complex extends ZikoMath{
4602
4645
  }
4603
4646
  let Z=+prod(this.z,...z.map(n=>n.z)).toFixed(15);
4604
4647
  let phi=+sum(this.phi,...z.map(n=>n.phi)).toFixed(15);
4605
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(14);
4606
- this.b=+(Z*sin$1(phi).toFixed(15)).toFixed(14);
4648
+ this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(14);
4649
+ this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(14);
4607
4650
  return this;
4608
4651
  }
4609
4652
  div(...z) {
@@ -4612,23 +4655,23 @@ class Complex extends ZikoMath{
4612
4655
  }
4613
4656
  let Z=+(this.z/prod(...z.map(n=>n.z))).toFixed(15);
4614
4657
  let phi=+(this.phi-sum(...z.map(n=>n.phi))).toFixed(15);
4615
- this.a=+(Z*cos$1(phi).toFixed(15)).toFixed(15);
4616
- this.b=+(Z*sin$1(phi).toFixed(15)).toFixed(15);
4658
+ this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(15);
4659
+ this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(15);
4617
4660
  return this;
4618
4661
  }
4619
4662
  pow(n) {
4620
4663
  if (floor(n) === n && n > 0) {
4621
4664
  let z=+(this.z**n).toFixed(15);
4622
4665
  let phi=+(this.phi*n).toFixed(15);
4623
- this.a=+(z*cos$1(phi).toFixed(15)).toFixed(15);
4624
- this.b=+(z*sin$1(phi).toFixed(15)).toFixed(15);
4666
+ this.a=+(z*cos$2(phi).toFixed(15)).toFixed(15);
4667
+ this.b=+(z*sin$2(phi).toFixed(15)).toFixed(15);
4625
4668
  }
4626
4669
  return this;
4627
4670
  }
4628
4671
  static fromExpo(z, phi) {
4629
4672
  return new Complex(
4630
- +(z * cos$1(phi)).toFixed(13),
4631
- +(z * sin$1(phi)).toFixed(13)
4673
+ +(z * cos$2(phi)).toFixed(13),
4674
+ +(z * sin$2(phi)).toFixed(13)
4632
4675
  );
4633
4676
  }
4634
4677
  get expo() {
@@ -4650,10 +4693,10 @@ class Complex extends ZikoMath{
4650
4693
  return z.clone.pow(n);
4651
4694
  }
4652
4695
  static xpowZ(x){
4653
- return complex((x**this.a)*cos$1(this.b*ln(x)),(x**this.a)*sin$1(this.b*ln(x)));
4696
+ return complex((x**this.a)*cos$2(this.b*ln(x)),(x**this.a)*sin$2(this.b*ln(x)));
4654
4697
  }
4655
4698
  sqrtn(n=2){
4656
- return complex(sqrtn(this.z,n)*cos$1(this.phi/n),sqrtn(this.z,n)*sin$1(this.phi/n));
4699
+ return complex(sqrtn(this.z,n)*cos$2(this.phi/n),sqrtn(this.z,n)*sin$2(this.phi/n));
4657
4700
  }
4658
4701
  get sqrt(){
4659
4702
  return this.sqrtn(2);
@@ -4662,14 +4705,14 @@ class Complex extends ZikoMath{
4662
4705
  return complex(this.z,this.phi);
4663
4706
  }
4664
4707
  get cos(){
4665
- return complex(cos$1(this.a)*cosh(this.b),sin$1(this.a)*sinh(this.b))
4708
+ return complex(cos$2(this.a)*cosh$1(this.b),sin$2(this.a)*sinh$1(this.b))
4666
4709
  }
4667
4710
  get sin(){
4668
- return complex(sin$1(this.a)*cosh(this.b),cos$1(this.a)*sinh(this.b))
4711
+ return complex(sin$2(this.a)*cosh$1(this.b),cos$2(this.a)*sinh$1(this.b))
4669
4712
  }
4670
4713
  get tan(){
4671
- const de=cos$1(this.a*2)+cosh(this.b*2);
4672
- return complex(sin$1(2*this.a)/de,sinh(2*this.b)/de);
4714
+ const de=cos$2(this.a*2)+cosh$1(this.b*2);
4715
+ return complex(sin$2(2*this.a)/de,sinh$1(2*this.b)/de);
4673
4716
  }
4674
4717
  printInConsole() {
4675
4718
  let string = this.a + " + " + this.b + " * i";
@@ -4700,7 +4743,7 @@ const complex=(a,b)=>{
4700
4743
  // } from "../calculus/index.js";
4701
4744
 
4702
4745
  const abs=(...x)=>mapfun$1(Math.abs,...x);
4703
- const sqrt$1=(...x)=>mapfun$1(Math.sqrt,...x);
4746
+ const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
4704
4747
  const pow$1=(x,n)=>{
4705
4748
  if(typeof x === "number"){
4706
4749
  if(typeof n === "number")return Math.pow(x,n);
@@ -4748,8 +4791,8 @@ const sqrtn=(x,n)=>{
4748
4791
  };
4749
4792
  const e=(...x) => mapfun$1(Math.exp,...x);
4750
4793
  const ln=(...x) => mapfun$1(Math.log,...x);
4751
- const cos$1=(...x) => mapfun$1(Fixed.cos,...x);
4752
- const sin$1=(...x) => mapfun$1(Fixed.sin,...x);
4794
+ const cos$2=(...x) => mapfun$1(Fixed.cos,...x);
4795
+ const sin$2=(...x) => mapfun$1(Fixed.sin,...x);
4753
4796
  const tan=(...x) => mapfun$1(Fixed.tan,...x);
4754
4797
  const sec=(...x) => mapfun$1(Fixed.sec,...x);
4755
4798
  const sinc=(...x) => mapfun$1(Fixed.sinc,...x);
@@ -4759,8 +4802,8 @@ const acos$1=(...x) => mapfun$1(Fixed.acos,...x);
4759
4802
  const asin=(...x) => mapfun$1(Fixed.asin,...x);
4760
4803
  const atan=(...x) => mapfun$1(Fixed.atan,...x);
4761
4804
  const acot=(...x) => mapfun$1(Fixed.acot,...x);
4762
- const cosh=(...x) => mapfun$1(Fixed.cosh,...x);
4763
- const sinh=(...x) => mapfun$1(Fixed.sinh,...x);
4805
+ const cosh$1=(...x) => mapfun$1(Fixed.cosh,...x);
4806
+ const sinh$1=(...x) => mapfun$1(Fixed.sinh,...x);
4764
4807
  const tanh=(...x) => mapfun$1(Fixed.tanh,...x);
4765
4808
  const coth=(...x) => mapfun$1(Fixed.coth,...x);
4766
4809
  const acosh=(...x) => mapfun$1(Fixed.acosh,...x);
@@ -4809,12 +4852,12 @@ const hypot=(...x)=>{
4809
4852
  )
4810
4853
  };
4811
4854
 
4812
- const {PI, sqrt, cos, sin, acos, pow} = Math;
4855
+ const {PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow} = Math;
4813
4856
 
4814
4857
  const Linear = t => t;
4815
- const InSin = t => 1 - cos((t * PI) / 2);
4816
- const OutSin = t => sin((t * PI) / 2);
4817
- const InOutSin = t => -(cos(PI * t) - 1) / 2;
4858
+ const InSin = t => 1 - cos$1((t * PI) / 2);
4859
+ const OutSin = t => sin$1((t * PI) / 2);
4860
+ const InOutSin = t => -(cos$1(PI * t) - 1) / 2;
4818
4861
 
4819
4862
  const InQuad = t => t**2;
4820
4863
  const OutQuad = t => 1 - (1-t)**2;
@@ -4836,13 +4879,13 @@ const InExpo = t => t === 0 ? 0 : 2**(10*t - 10);
4836
4879
  const OutExpo = t => t === 1 ? 1 : 1 - 2**(-10 * t);
4837
4880
  const InOutExpo = t => t === 0? 0: t === 1? 1: t < 0.5 ? 2**(20 * t - 10) / 2: (2 - 2**(-20 * t + 10)) / 2;
4838
4881
 
4839
- const InCirc = t => 1 - sqrt(1 - t**2);
4840
- const OutCirc = t => sqrt(1 - (t-1)**2);
4841
- const InOutCirc = t => t < 0.5? (1 - sqrt(1 - (2*t)**2)) / 2: (sqrt(1 - (-2*t+2)**2) + 1) / 2;
4882
+ const InCirc = t => 1 - sqrt$1(1 - t**2);
4883
+ const OutCirc = t => sqrt$1(1 - (t-1)**2);
4884
+ const InOutCirc = t => t < 0.5? (1 - sqrt$1(1 - (2*t)**2)) / 2: (sqrt$1(1 - (-2*t+2)**2) + 1) / 2;
4842
4885
 
4843
- const Arc = t => 1 - sin(acos(t));
4886
+ const Arc = t => 1 - sin$1(acos(t));
4844
4887
  const Back = (t, x = 1) => (t**2) * ((x+1)*t - x);
4845
- const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos(20 * PI * t / 3 * t);
4888
+ const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos$1(20 * PI * t / 3 * t);
4846
4889
 
4847
4890
  const InBack = (t, c1 = 1.70158, c3 = c1 + 1) => c3 * pow(t,3)- c1 * (t**2);
4848
4891
  const OutBack = (t, c1 = 1.70158, c3 = c1 + 1) => 1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
@@ -4853,7 +4896,7 @@ const InElastic = (t, c4 = 2*PI/3) => {
4853
4896
  ? 0
4854
4897
  : t === 1
4855
4898
  ? 1
4856
- : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
4899
+ : -pow(2, 10 * t - 10) * sin$1((t * 10 - 10.75) * c4);
4857
4900
  };
4858
4901
 
4859
4902
  const OutElastic = (t, c4 = 2*PI/3) => {
@@ -4861,7 +4904,7 @@ const OutElastic = (t, c4 = 2*PI/3) => {
4861
4904
  ? 0
4862
4905
  : t === 1
4863
4906
  ? 1
4864
- : pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
4907
+ : pow(2, -10 * t) * sin$1((t * 10 - 0.75) * c4) + 1;
4865
4908
  };
4866
4909
  const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4867
4910
  return t === 0
@@ -4869,8 +4912,8 @@ const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
4869
4912
  : t === 1
4870
4913
  ? 1
4871
4914
  : t < 0.5
4872
- ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
4873
- : (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
4915
+ ? -(pow(2, 20 * t - 10) * sin$1((20 * t - 11.125) * c5)) / 2
4916
+ : (pow(2, -20 * t + 10) * sin$1((20 * t - 11.125) * c5)) / 2 + 1;
4874
4917
  };
4875
4918
 
4876
4919
  const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
@@ -4978,17 +5021,28 @@ const animation = (callback, {ease, t0, t1, start, duration} = {}) =>
4978
5021
  new TimeAnimation(callback, {ease, t0, t1, start, duration});
4979
5022
 
4980
5023
  class Tick {
4981
- constructor(ms, fn) {
5024
+ constructor(fn, ms, count = Infinity, start) {
4982
5025
  this.ms = ms;
4983
5026
  this.fn = fn;
5027
+ this.count = count;
5028
+ this.frame = 1;
4984
5029
  this.id = null;
4985
5030
  this.running = false;
5031
+ if(start) this.start();
4986
5032
  }
4987
5033
 
4988
5034
  start() {
4989
5035
  if (!this.running) {
4990
5036
  this.running = true;
4991
- this.id = setInterval(this.fn, this.ms);
5037
+ this.frame = 1;
5038
+ this.id = setInterval(() => {
5039
+ if (this.frame > this.count) {
5040
+ this.stop();
5041
+ return;
5042
+ }
5043
+ this.fn.call(null, this);
5044
+ this.frame++;
5045
+ }, this.ms);
4992
5046
  }
4993
5047
  return this;
4994
5048
  }
@@ -5006,7 +5060,9 @@ class Tick {
5006
5060
  return this.running;
5007
5061
  }
5008
5062
  }
5009
- const tick = (ms, fn) => new Tick(ms, fn);
5063
+
5064
+ // Helper factory
5065
+ const tick = (fn, ms, count = Infinity, start = true) => new Tick(fn, ms, count, start);
5010
5066
 
5011
5067
  class Clock extends Tick {
5012
5068
  constructor(tickMs = 1000 / 60) {
@@ -5138,7 +5194,8 @@ const Scheduler = (tasks, { repeat = null} = {}) => new TimeScheduler(tasks, { r
5138
5194
  const step_fps = (step_or_fps) => 1000 / step_or_fps;
5139
5195
 
5140
5196
  const debounce=(fn,delay=1000)=>{
5141
- return (...args) => setTimeout(()=>fn(...args),delay);
5197
+ let id;
5198
+ return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
5142
5199
  };
5143
5200
  const throttle=(fn,delay)=>{
5144
5201
  let lastTime=0;
@@ -5543,57 +5600,37 @@ function findCommonPath(paths) {
5543
5600
  function useDerived(deriveFn, sources) {
5544
5601
  let value = deriveFn(...sources.map(s => s().value));
5545
5602
  const subscribers = new Set();
5546
- let paused = false;
5547
5603
 
5548
- function getValue() {
5549
- return {
5550
- value,
5551
- isStateGetter: () => true,
5552
- _subscribe: (fn) => {
5553
- subscribers.add(fn);
5554
- },
5555
- };
5556
- }
5557
-
5558
- function setValue(newValue) {
5559
- if (paused) return;
5560
- if (typeof newValue === "function") newValue = newValue(value);
5561
- if (newValue !== value) {
5562
- value = newValue;
5563
- subscribers.forEach(fn => fn(value));
5564
- }
5565
- }
5566
-
5567
- const controller = {
5568
- pause: () => { paused = true; },
5569
- resume: () => { paused = false; },
5570
- clear: () => { subscribers.clear(); },
5571
- force: (newValue) => {
5572
- if (typeof newValue === "function") newValue = newValue(value);
5573
- value = newValue;
5574
- subscribers.forEach(fn => fn(value));
5575
- },
5576
- getSubscribers: () => new Set(subscribers),
5577
- };
5578
-
5579
- // Subscribe to source states
5580
5604
  sources.forEach(source => {
5581
5605
  const srcValue = source(); // getValue()
5582
5606
  srcValue._subscribe(() => {
5583
- if (!paused) {
5607
+ {
5584
5608
  const newVal = deriveFn(...sources.map(s => s().value));
5585
5609
  if (newVal !== value) {
5586
5610
  value = newVal;
5587
5611
  subscribers.forEach(fn => fn(value));
5588
5612
  }
5589
5613
  }
5590
- }, { element: document.body }); // dummy UIElement
5614
+ });
5591
5615
  });
5592
-
5593
- return [getValue, setValue, controller];
5616
+ return () => ({
5617
+ value,
5618
+ isStateGetter : () => true,
5619
+ _subscribe: (fn) => subscribers.add(fn)
5620
+ })
5594
5621
  }
5595
5622
 
5596
- const useReactive = (nested_value) => mapfun$1(n => useState(n), nested_value);
5623
+ const useReactive = (nested_value) => mapfun$1(
5624
+ n => {
5625
+ const state = useState(n);
5626
+ // console.log(state)
5627
+ return {
5628
+ get : state[0],
5629
+ set : state[1],
5630
+ }
5631
+ },
5632
+ nested_value
5633
+ );
5597
5634
 
5598
5635
  class ZikoUseChannel{
5599
5636
  constructor(name = ""){
@@ -5829,6 +5866,65 @@ class ZikoUseStorage{
5829
5866
  const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
5830
5867
  const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
5831
5868
 
5869
+ let {sqrt, cos, sin, exp, log, cosh, sinh} = Math;
5870
+ // Math.abs = new Proxy(Math.abs, {
5871
+ // apply(target, thisArg, args) {
5872
+ // const x = args[0]
5873
+ // if(typeof x === 'number') return target.apply(thisArg, args);
5874
+ // if(x?.isComplex?.()){
5875
+ // const {a, b, z, phi} = x
5876
+ // const complex = (a, b) => new x.constructor(a, b)
5877
+ // switch(target.name){
5878
+ // case 'abs' : return a.z;
5879
+ // case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
5880
+ // }
5881
+ // }
5882
+
5883
+ // }
5884
+ // });
5885
+
5886
+
5887
+ for (const key of Object.getOwnPropertyNames(Math)) {
5888
+ const fn = Math[key];
5889
+ if (typeof fn === "function") {
5890
+ Math[key] = new Proxy(fn, {
5891
+ apply(target, thisArg, args) {
5892
+ // console.log(target)
5893
+ const x = args[0];
5894
+ if(typeof x === 'number' || args.length === 0) return target.apply(thisArg, args);
5895
+ if(x?.isComplex?.()){
5896
+ const {a, b, z, phi} = x;
5897
+ const complex = (a, b) => new x.constructor(a, b);
5898
+ switch(target.name){
5899
+ case 'abs' : return x.z;
5900
+ case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
5901
+ case 'log' : return complex(log(z), phi);
5902
+ case 'exp' : return complex(exp(a)*cos(b),exp(a)*sin(b));
5903
+ case 'cos' : return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
5904
+ case 'sin' : return complex(sin(a)*cosh(b),cos(a)*sinh(b));
5905
+ case 'tan' : {
5906
+ const DEN = cos(2*a)+cosh(2*b);
5907
+ return complex(sin(2*a) /DEN, sinh(2*b)/DEN);
5908
+ }
5909
+ case 'cosh' : return complex(cosh(a)*cos(b),sinh(a)*sin(b));
5910
+ case 'sinh' : return complex(sinh(a)*cos(b),cosh(a)*sin(b));
5911
+ case 'tanh' : {
5912
+ const DEN=cosh(2*a)+cos(2*b);
5913
+ return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
5914
+ }
5915
+ default : return target.apply(thisArg, args)
5916
+ }
5917
+ }
5918
+ // if( x.isMatrix?.()){
5919
+ // const {rows, cols, arr} = x
5920
+ // // return new x.constructor(rows, cols, arr.flat(1).map(n=>));
5921
+ // }
5922
+ throw new TypeError(`Math.${key} expects only numbers`);
5923
+ }
5924
+ });
5925
+ }
5926
+ }
5927
+
5832
5928
  if(globalThis?.document){
5833
5929
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5834
5930
  }
@@ -5957,8 +6053,8 @@ exports.clamp = clamp;
5957
6053
  exports.clock = clock;
5958
6054
  exports.combinaison = combinaison;
5959
6055
  exports.complex = complex;
5960
- exports.cos = cos$1;
5961
- exports.cosh = cosh;
6056
+ exports.cos = cos$2;
6057
+ exports.cosh = cosh$1;
5962
6058
  exports.cot = cot;
5963
6059
  exports.coth = coth;
5964
6060
  exports.csc = csc;
@@ -5969,7 +6065,7 @@ exports.csv2object = csv2object;
5969
6065
  exports.csv2sql = csv2sql;
5970
6066
  exports.debounce = debounce;
5971
6067
  exports.defineParamsGetter = defineParamsGetter;
5972
- exports.defineWC = defineWC;
6068
+ exports.define_wc = define_wc;
5973
6069
  exports.deg2rad = deg2rad;
5974
6070
  exports.div = div;
5975
6071
  exports.e = e;
@@ -6019,11 +6115,11 @@ exports.round = round;
6019
6115
  exports.sec = sec;
6020
6116
  exports.sig = sig;
6021
6117
  exports.sign = sign;
6022
- exports.sin = sin$1;
6118
+ exports.sin = sin$2;
6023
6119
  exports.sinc = sinc;
6024
- exports.sinh = sinh;
6120
+ exports.sinh = sinh$1;
6025
6121
  exports.sleep = sleep;
6026
- exports.sqrt = sqrt$1;
6122
+ exports.sqrt = sqrt$2;
6027
6123
  exports.sqrtn = sqrtn;
6028
6124
  exports.step_fps = step_fps;
6029
6125
  exports.sub = sub;