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 +335 -239
- package/dist/ziko.js +365 -262
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +360 -257
- package/package.json +2 -2
- package/src/__ziko__/__cache__.js +3 -0
- package/src/__ziko__/__hydration__.js +4 -5
- package/src/__ziko__/__state__.js +12 -0
- package/src/__ziko__/__ui__.js +27 -21
- package/src/__ziko__/index.js +4 -2
- package/src/hooks/use-derived.js +6 -35
- package/src/hooks/use-reactive.js +11 -1
- package/src/hooks/use-state.js +42 -35
- package/src/time/clocks/tick.js +19 -5
- package/src/ui/__methods__/style.js +18 -18
- package/src/ui/constructors/UIElement.js +43 -26
- package/src/ui/web-component/index.js +9 -1
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Sun Aug 24 2025 12:52:45 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -11,23 +11,23 @@
|
|
|
11
11
|
const { PI: PI$2, E } = Math;
|
|
12
12
|
const EPSILON=Number.EPSILON;
|
|
13
13
|
|
|
14
|
-
const {PI: PI$1, cos: cos$
|
|
14
|
+
const {PI: PI$1, cos: cos$3, sin: sin$3, tan: tan$1, acos: acos$2, asin: asin$1, atan: atan$1, cosh: cosh$2, sinh: sinh$2, tanh: tanh$1, acosh: acosh$1, asinh: asinh$1, atanh: atanh$1, log: log$1} = Math;
|
|
15
15
|
let Fixed={
|
|
16
|
-
cos: cos$
|
|
17
|
-
sin: sin$
|
|
16
|
+
cos: cos$3,
|
|
17
|
+
sin: sin$3,
|
|
18
18
|
tan: tan$1,
|
|
19
|
-
sinc: x => sin$
|
|
20
|
-
sec: x => 1/cos$
|
|
21
|
-
csc: x => 1/sin$
|
|
19
|
+
sinc: x => sin$3(PI$1*x)/(PI$1*x),
|
|
20
|
+
sec: x => 1/cos$3(x),
|
|
21
|
+
csc: x => 1/sin$3(x),
|
|
22
22
|
cot: x => 1/tan$1(x),
|
|
23
23
|
acos: acos$2,
|
|
24
24
|
asin: asin$1,
|
|
25
25
|
atan: atan$1,
|
|
26
26
|
acot: x => PI$1/2-atan$1(x),
|
|
27
|
-
cosh: cosh$
|
|
28
|
-
sinh: sinh$
|
|
27
|
+
cosh: cosh$2,
|
|
28
|
+
sinh: sinh$2,
|
|
29
29
|
tanh: tanh$1,
|
|
30
|
-
coth: n => (1/2*log((1+n)/(1-n))),
|
|
30
|
+
coth: n => (1/2*log$1((1+n)/(1-n))),
|
|
31
31
|
acosh: acosh$1,
|
|
32
32
|
asinh: asinh$1,
|
|
33
33
|
atanh: atanh$1,
|
|
@@ -61,20 +61,20 @@ const mapfun$1=(fun,...X)=>{
|
|
|
61
61
|
const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
|
|
62
62
|
switch(fun){
|
|
63
63
|
case Math.log: return complex(ln(z),phi); // Done
|
|
64
|
-
case Math.exp: return complex(e(a)*cos$
|
|
64
|
+
case Math.exp: return complex(e(a)*cos$2(b),e(a)*sin$2(b)); // Done
|
|
65
65
|
case Math.abs: return z; // Done
|
|
66
|
-
case Math.sqrt: return complex(sqrt$
|
|
67
|
-
case Fixed.cos: return complex(cos$
|
|
68
|
-
case Fixed.sin: return complex(sin$
|
|
66
|
+
case Math.sqrt: return complex(sqrt$2(z)*cos$2(phi/2),sqrt$2(z)*sin$2(phi/2)); // Done
|
|
67
|
+
case Fixed.cos: return complex(cos$2(a)*cosh$1(b),-(sin$2(a)*sinh$1(b)));
|
|
68
|
+
case Fixed.sin: return complex(sin$2(a)*cosh$1(b),cos$2(a)*sinh$1(b));
|
|
69
69
|
case Fixed.tan:{
|
|
70
|
-
const DEN = cos$
|
|
71
|
-
return complex(sin$
|
|
70
|
+
const DEN = cos$2(2*a)+cosh$1(2*b);
|
|
71
|
+
return complex(sin$2(2*a)/DEN,sinh$1(2*b)/DEN);
|
|
72
72
|
}
|
|
73
|
-
case Fixed.cosh:return complex(cosh(a)*cos$
|
|
74
|
-
case Fixed.sinh:return complex(sinh(a)*cos$
|
|
73
|
+
case Fixed.cosh:return complex(cosh$1(a)*cos$2(b),sinh$1(a)*sin$2(b));
|
|
74
|
+
case Fixed.sinh:return complex(sinh$1(a)*cos$2(b),cosh$1(a)*sin$2(b));
|
|
75
75
|
case Fixed.tanh:{
|
|
76
|
-
const DEN=cosh(2*a)+cos$
|
|
77
|
-
return complex(sinh(2*a)/DEN,sin$
|
|
76
|
+
const DEN=cosh$1(2*a)+cos$2(2*b);
|
|
77
|
+
return complex(sinh$1(2*a)/DEN,sin$2(2*b)/DEN)
|
|
78
78
|
}
|
|
79
79
|
default : return fun(x)
|
|
80
80
|
}
|
|
@@ -945,6 +945,21 @@ const preload=(url)=>{
|
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
947
|
|
|
948
|
+
async function fetchdom(url='https://github.com/zakarialaoui10'){
|
|
949
|
+
const data=await fetch(url);
|
|
950
|
+
const html=await data.text();
|
|
951
|
+
const dom= new DOMParser().parseFromString(html,'text/xml');
|
|
952
|
+
return dom.documentElement
|
|
953
|
+
}
|
|
954
|
+
function fetchdomSync(url='https://github.com/zakarialaoui10'){
|
|
955
|
+
const data=preload(url);
|
|
956
|
+
const dom= new DOMParser().parseFromString(data,'text/xml');
|
|
957
|
+
return dom.documentElement;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
globalThis.fetchdom=fetchdom;
|
|
961
|
+
globalThis.fetchdomSync=fetchdomSync;
|
|
962
|
+
|
|
948
963
|
const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
|
|
949
964
|
const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
|
|
950
965
|
const csv2object = (csv, delimiter = ",") => {
|
|
@@ -1100,59 +1115,188 @@ const register = (target, ...mixins) => {
|
|
|
1100
1115
|
else register_to_instance(target, ...mixins);
|
|
1101
1116
|
};
|
|
1102
1117
|
|
|
1118
|
+
function parseQueryParams$1(queryString) {
|
|
1119
|
+
const params = {};
|
|
1120
|
+
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1121
|
+
const [key, value] = match.split('=');
|
|
1122
|
+
params[key] = value;
|
|
1123
|
+
});
|
|
1124
|
+
return params;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function defineParamsGetter$1(target ){
|
|
1128
|
+
Object.defineProperties(target, {
|
|
1129
|
+
'QueryParams': {
|
|
1130
|
+
get: function() {
|
|
1131
|
+
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1132
|
+
},
|
|
1133
|
+
configurable: false,
|
|
1134
|
+
enumerable: true
|
|
1135
|
+
},
|
|
1136
|
+
'HashParams': {
|
|
1137
|
+
get: function() {
|
|
1138
|
+
const hash = globalThis.location.hash.substring(1);
|
|
1139
|
+
return hash.split("#");
|
|
1140
|
+
},
|
|
1141
|
+
configurable: false,
|
|
1142
|
+
enumerable: true
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
class UIStore extends Array {
|
|
1148
|
+
constructor(...args) {
|
|
1149
|
+
super(...args);
|
|
1150
|
+
}
|
|
1151
|
+
getItemById(id) {
|
|
1152
|
+
return this.find(n => n.element.id === id);
|
|
1153
|
+
}
|
|
1154
|
+
getItemsByTagName(tag) {
|
|
1155
|
+
return this.filter(n => n.element.tagName.toLowerCase() === tag.toLowerCase());
|
|
1156
|
+
}
|
|
1157
|
+
getElementsByClassName(className) {
|
|
1158
|
+
return this.filter(n => n.element.classList?.contains(className));
|
|
1159
|
+
}
|
|
1160
|
+
querySelector(selector) {
|
|
1161
|
+
const el = globalThis?.document?.querySelector(selector);
|
|
1162
|
+
if (!el) return null;
|
|
1163
|
+
return this.find(ui => ui.element === el) || null;
|
|
1164
|
+
}
|
|
1165
|
+
querySelectorAll(selector) {
|
|
1166
|
+
const els = globalThis?.document?.querySelectorAll(selector);
|
|
1167
|
+
return Array.from(els)
|
|
1168
|
+
.map(el => this.find(ui => ui.element === el))
|
|
1169
|
+
.filter(Boolean);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// create the singleton
|
|
1174
|
+
const __UI__ = new UIStore();
|
|
1175
|
+
|
|
1176
|
+
const __Config__ = {
|
|
1177
|
+
default:{
|
|
1178
|
+
target:null,
|
|
1179
|
+
render:true,
|
|
1180
|
+
math:{
|
|
1181
|
+
mode:"deg"
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
setDefault:function(pairs){
|
|
1185
|
+
const keys=Object.keys(pairs);
|
|
1186
|
+
const values=Object.values(pairs);
|
|
1187
|
+
for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
|
|
1188
|
+
},
|
|
1189
|
+
init:()=>{
|
|
1190
|
+
// document.documentElement.setAttribute("data-engine","zikojs")
|
|
1191
|
+
},
|
|
1192
|
+
renderingMode :"spa",
|
|
1193
|
+
isSSC : false,
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
const __HYDRATION__ = {
|
|
1197
|
+
store : new Map(),
|
|
1198
|
+
index : 0,
|
|
1199
|
+
register: function(component){
|
|
1200
|
+
this.store.set(this.index++, component);
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
const __CACHE__ = {
|
|
1205
|
+
ui_index : 0,
|
|
1206
|
+
get_ui_index:function(){
|
|
1207
|
+
return this.ui_index ++
|
|
1208
|
+
},
|
|
1209
|
+
register_ui: function(UIElement){
|
|
1210
|
+
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
const __State__ = {
|
|
1215
|
+
store : new Map(),
|
|
1216
|
+
index : import.meta.hot?.data?.__Ziko__?.__State__?.index ?? 0,
|
|
1217
|
+
register: function(state){
|
|
1218
|
+
console.log({
|
|
1219
|
+
hmr : import.meta.hot?.data.__Ziko__.__State__.index,
|
|
1220
|
+
index : this.index
|
|
1221
|
+
});
|
|
1222
|
+
this.store.set(this.index++, state);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
function __init__global__(){
|
|
1228
|
+
if ( !globalThis?.__Ziko__ ){
|
|
1229
|
+
globalThis.__Ziko__ = {
|
|
1230
|
+
__UI__,
|
|
1231
|
+
__HYDRATION__,
|
|
1232
|
+
__State__,
|
|
1233
|
+
__Config__,
|
|
1234
|
+
__CACHE__,
|
|
1235
|
+
};
|
|
1236
|
+
defineParamsGetter$1(__Ziko__);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
if(!globalThis.__Ziko__) __init__global__();
|
|
1241
|
+
|
|
1242
|
+
// HMR persistence
|
|
1243
|
+
if (import.meta.hot) {
|
|
1244
|
+
import.meta.hot.data.__Ziko__ = import.meta.hot.data.__Ziko__ || globalThis.__Ziko__;
|
|
1245
|
+
globalThis.__Ziko__ = import.meta.hot.data.__Ziko__;
|
|
1246
|
+
// import.meta.hot.accept(n=>console.log(n));
|
|
1247
|
+
// console.log(import.meta.hot.data.__Ziko__.__State__.store)
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1103
1252
|
function useState(initialValue) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1253
|
+
|
|
1254
|
+
// console.log(import.meta.hot.data.__Ziko__.__State__.store.get(0))
|
|
1255
|
+
|
|
1256
|
+
const {store, index} = __Ziko__.__State__;
|
|
1257
|
+
__Ziko__.__State__.register({
|
|
1258
|
+
value : initialValue,
|
|
1259
|
+
subscribers : new Set(),
|
|
1260
|
+
paused : false
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
const current = store.get(index);
|
|
1107
1264
|
|
|
1108
1265
|
function getValue() {
|
|
1109
1266
|
return {
|
|
1110
|
-
value,
|
|
1267
|
+
value: current.value,
|
|
1111
1268
|
isStateGetter: () => true,
|
|
1112
|
-
_subscribe: (
|
|
1113
|
-
fn,
|
|
1114
|
-
// UIElement
|
|
1115
|
-
) => {
|
|
1116
|
-
subscribers.add(fn);
|
|
1117
|
-
|
|
1118
|
-
// const observer = new MutationObserver(() => {
|
|
1119
|
-
// if (!document.body.contains(UIElement.element)) {
|
|
1120
|
-
// subscribers.delete(fn);
|
|
1121
|
-
// observer.disconnect();
|
|
1122
|
-
// }
|
|
1123
|
-
// });
|
|
1124
|
-
|
|
1125
|
-
// observer.observe(document.body, { childList: true, subtree: true });
|
|
1126
|
-
},
|
|
1269
|
+
_subscribe: (fn) => current.subscribers.add(fn),
|
|
1127
1270
|
};
|
|
1128
1271
|
}
|
|
1129
1272
|
|
|
1130
1273
|
function setValue(newValue) {
|
|
1131
|
-
if (paused) return;
|
|
1132
|
-
if (typeof newValue === "function") newValue = newValue(value);
|
|
1133
|
-
if (newValue !== value) {
|
|
1134
|
-
value = newValue;
|
|
1135
|
-
subscribers.forEach(fn => fn(value));
|
|
1274
|
+
if (current.paused) return;
|
|
1275
|
+
if (typeof newValue === "function") newValue = newValue(current.value);
|
|
1276
|
+
if (newValue !== current.value) {
|
|
1277
|
+
current.value = newValue;
|
|
1278
|
+
current.subscribers.forEach(fn => fn(current.value));
|
|
1136
1279
|
}
|
|
1137
1280
|
}
|
|
1138
1281
|
|
|
1139
1282
|
const controller = {
|
|
1140
|
-
pause: () => { paused = true; },
|
|
1141
|
-
resume: () => { paused = false; },
|
|
1142
|
-
clear: () => { subscribers.clear(); },
|
|
1143
|
-
force: (newValue) => {
|
|
1144
|
-
if (typeof newValue === "function") newValue = newValue(value);
|
|
1145
|
-
value = newValue;
|
|
1146
|
-
subscribers.forEach(fn => fn(value));
|
|
1283
|
+
pause: () => { current.paused = true; },
|
|
1284
|
+
resume: () => { current.paused = false; },
|
|
1285
|
+
clear: () => { current.subscribers.clear(); },
|
|
1286
|
+
force: (newValue) => {
|
|
1287
|
+
if (typeof newValue === "function") newValue = newValue(current.value);
|
|
1288
|
+
current.value = newValue;
|
|
1289
|
+
current.subscribers.forEach(fn => fn(current.value));
|
|
1147
1290
|
},
|
|
1148
|
-
getSubscribers: () => new Set(subscribers),
|
|
1291
|
+
getSubscribers: () => new Set(current.subscribers),
|
|
1149
1292
|
};
|
|
1150
1293
|
|
|
1151
1294
|
return [getValue, setValue, controller];
|
|
1152
1295
|
}
|
|
1153
1296
|
|
|
1297
|
+
|
|
1154
1298
|
const isStateGetter = (arg) => {
|
|
1155
|
-
return typeof
|
|
1299
|
+
return typeof arg === 'function' && arg?.()?.isStateGetter?.();
|
|
1156
1300
|
};
|
|
1157
1301
|
|
|
1158
1302
|
const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
@@ -2731,110 +2875,9 @@ class ZikoUseMediaQuery {
|
|
|
2731
2875
|
|
|
2732
2876
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
2733
2877
|
|
|
2734
|
-
function parseQueryParams$1(queryString) {
|
|
2735
|
-
const params = {};
|
|
2736
|
-
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
2737
|
-
const [key, value] = match.split('=');
|
|
2738
|
-
params[key] = value;
|
|
2739
|
-
});
|
|
2740
|
-
return params;
|
|
2741
|
-
}
|
|
2742
|
-
|
|
2743
|
-
function defineParamsGetter$1(target ){
|
|
2744
|
-
Object.defineProperties(target, {
|
|
2745
|
-
'QueryParams': {
|
|
2746
|
-
get: function() {
|
|
2747
|
-
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
2748
|
-
},
|
|
2749
|
-
configurable: false,
|
|
2750
|
-
enumerable: true
|
|
2751
|
-
},
|
|
2752
|
-
'HashParams': {
|
|
2753
|
-
get: function() {
|
|
2754
|
-
const hash = globalThis.location.hash.substring(1);
|
|
2755
|
-
return hash.split("#");
|
|
2756
|
-
},
|
|
2757
|
-
configurable: false,
|
|
2758
|
-
enumerable: true
|
|
2759
|
-
}
|
|
2760
|
-
});
|
|
2761
|
-
}
|
|
2762
|
-
|
|
2763
|
-
const __UI__={
|
|
2764
|
-
__all__(){
|
|
2765
|
-
return Object.values(this)
|
|
2766
|
-
.filter(Array.isArray)
|
|
2767
|
-
.flat();
|
|
2768
|
-
},
|
|
2769
|
-
querySelectorAll(){
|
|
2770
|
-
return this.__all__().filter(n=>n)
|
|
2771
|
-
},
|
|
2772
|
-
getElementByIndex(index){
|
|
2773
|
-
return this.__all__().find(n=>n.ui_index===index);
|
|
2774
|
-
},
|
|
2775
|
-
getElementById(id){
|
|
2776
|
-
return null;
|
|
2777
|
-
},
|
|
2778
|
-
getElementsByClass(){
|
|
2779
|
-
|
|
2780
|
-
},
|
|
2781
|
-
getElementsByTagName(){
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2784
|
-
};
|
|
2785
|
-
|
|
2786
|
-
const __Config__ = {
|
|
2787
|
-
default:{
|
|
2788
|
-
target:null,
|
|
2789
|
-
render:true,
|
|
2790
|
-
math:{
|
|
2791
|
-
mode:"deg"
|
|
2792
|
-
}
|
|
2793
|
-
},
|
|
2794
|
-
setDefault:function(pairs){
|
|
2795
|
-
const keys=Object.keys(pairs);
|
|
2796
|
-
const values=Object.values(pairs);
|
|
2797
|
-
for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
|
|
2798
|
-
},
|
|
2799
|
-
init:()=>{
|
|
2800
|
-
// document.documentElement.setAttribute("data-engine","zikojs")
|
|
2801
|
-
},
|
|
2802
|
-
renderingMode :"spa",
|
|
2803
|
-
isSSC : false,
|
|
2804
|
-
};
|
|
2805
|
-
|
|
2806
|
-
const __HYDRATION__ = {
|
|
2807
|
-
map : new Map(),
|
|
2808
|
-
index : 0,
|
|
2809
|
-
increment : function(){
|
|
2810
|
-
return this.index ++
|
|
2811
|
-
}
|
|
2812
|
-
};
|
|
2813
|
-
const __HYDRATION_MAP__ = new Map();
|
|
2814
|
-
|
|
2815
|
-
const __CACHE__ = {
|
|
2816
|
-
ui_index : 0,
|
|
2817
|
-
get_ui_index:function(){
|
|
2818
|
-
return this.ui_index ++
|
|
2819
|
-
}
|
|
2820
|
-
};
|
|
2821
|
-
|
|
2822
|
-
function __init__global__(){
|
|
2823
|
-
if ( !globalThis?.__Ziko__ ){
|
|
2824
|
-
globalThis.__Ziko__ = {
|
|
2825
|
-
__UI__,
|
|
2826
|
-
__HYDRATION__,
|
|
2827
|
-
__HYDRATION_MAP__,
|
|
2828
|
-
__Config__,
|
|
2829
|
-
__CACHE__,
|
|
2830
|
-
};
|
|
2831
|
-
defineParamsGetter$1(__Ziko__);
|
|
2832
|
-
}
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
2878
|
__init__global__();
|
|
2836
2879
|
class UIElement extends UINode{
|
|
2837
|
-
constructor({element, name ='', type="html", useDefaultStyle=false}={}){
|
|
2880
|
+
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
2838
2881
|
super();
|
|
2839
2882
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
2840
2883
|
if(typeof element === "string") {
|
|
@@ -2885,8 +2928,8 @@ class UIElement extends UINode{
|
|
|
2885
2928
|
resize:null,
|
|
2886
2929
|
intersection:null
|
|
2887
2930
|
};
|
|
2888
|
-
if(element)Object.assign(this.cache,{element});
|
|
2889
|
-
this.uuid = `${this.cache.name}-${Random.string(16)}
|
|
2931
|
+
if(element) Object.assign(this.cache,{element});
|
|
2932
|
+
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
2890
2933
|
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
2891
2934
|
useDefaultStyle && this.style({
|
|
2892
2935
|
position: "relative",
|
|
@@ -2896,9 +2939,9 @@ class UIElement extends UINode{
|
|
|
2896
2939
|
width : "auto",
|
|
2897
2940
|
height : "auto"
|
|
2898
2941
|
});
|
|
2899
|
-
this.items =
|
|
2942
|
+
this.items = new UIStore();
|
|
2900
2943
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
2901
|
-
element &&
|
|
2944
|
+
element && render && this?.render?.();
|
|
2902
2945
|
if(
|
|
2903
2946
|
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
2904
2947
|
// &&
|
|
@@ -2907,9 +2950,9 @@ class UIElement extends UINode{
|
|
|
2907
2950
|
this.isInteractive()
|
|
2908
2951
|
){
|
|
2909
2952
|
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
2910
|
-
globalThis.__Ziko__.__HYDRATION__.
|
|
2911
|
-
globalThis.__Ziko__.__HYDRATION__.increment();
|
|
2953
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
2912
2954
|
}
|
|
2955
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
2913
2956
|
}
|
|
2914
2957
|
get element(){
|
|
2915
2958
|
return this.cache.element;
|
|
@@ -2960,14 +3003,13 @@ class UIElement extends UINode{
|
|
|
2960
3003
|
return this.element.getBoundingClientRect().left;
|
|
2961
3004
|
}
|
|
2962
3005
|
clone(render=false) {
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
return UI.render(render);
|
|
3006
|
+
// UI.__proto__=this.__proto__;
|
|
3007
|
+
// if(this.items.length){
|
|
3008
|
+
// const items = [...this.items].map(n=>n.clone());
|
|
3009
|
+
// UI.append(...items);
|
|
3010
|
+
// }
|
|
3011
|
+
// else UI.element=this.element.cloneNode(true);
|
|
3012
|
+
// return UI.render(render);
|
|
2971
3013
|
}
|
|
2972
3014
|
[Symbol.iterator]() {
|
|
2973
3015
|
return this.items[Symbol.iterator]();
|
|
@@ -2986,14 +3028,14 @@ class UIElement extends UINode{
|
|
|
2986
3028
|
this.cache.isFrozzen=freeze;
|
|
2987
3029
|
return this;
|
|
2988
3030
|
}
|
|
2989
|
-
setTarget(tg) {
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
}
|
|
3031
|
+
// setTarget(tg) {
|
|
3032
|
+
// if(this.isBody) return ;
|
|
3033
|
+
// if (tg?.isZikoUIElement) tg = tg.element;
|
|
3034
|
+
// this.unrender();
|
|
3035
|
+
// this.target = tg;
|
|
3036
|
+
// this.render();
|
|
3037
|
+
// return this;
|
|
3038
|
+
// }
|
|
2997
3039
|
describe(label){
|
|
2998
3040
|
if(label)this.setAttr("aria-label",label);
|
|
2999
3041
|
}
|
|
@@ -3654,7 +3696,15 @@ class ZikoUISvg extends UIElement {
|
|
|
3654
3696
|
|
|
3655
3697
|
const Svg =(w,h)=>new ZikoUISvg(w,h);
|
|
3656
3698
|
|
|
3657
|
-
function
|
|
3699
|
+
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3700
|
+
if (globalThis.customElements?.get(name)) {
|
|
3701
|
+
console.warn(`Custom element "${name}" is already defined`);
|
|
3702
|
+
return; // skip redefinition
|
|
3703
|
+
}
|
|
3704
|
+
if(name.search('-') === -1){
|
|
3705
|
+
console.warn(`"${name}" is not a valid custom element name`);
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3658
3708
|
globalThis.customElements?.define(
|
|
3659
3709
|
name,
|
|
3660
3710
|
class extends HTMLElement {
|
|
@@ -4516,7 +4566,7 @@ class Complex extends ZikoMath{
|
|
|
4516
4566
|
}
|
|
4517
4567
|
else if(("a" in b && "z" in a)){
|
|
4518
4568
|
this.a=a.a;
|
|
4519
|
-
this.b=sqrt$
|
|
4569
|
+
this.b=sqrt$2((a.z**2)-(a.a**2));
|
|
4520
4570
|
}
|
|
4521
4571
|
else if(("a" in b && "phi" in a)){
|
|
4522
4572
|
this.a=a.a;
|
|
@@ -4524,15 +4574,15 @@ class Complex extends ZikoMath{
|
|
|
4524
4574
|
}
|
|
4525
4575
|
else if(("b" in b && "z" in a)){
|
|
4526
4576
|
this.b=a.b;
|
|
4527
|
-
this.a=sqrt$
|
|
4577
|
+
this.a=sqrt$2((a.z**2)-(a.b**2));
|
|
4528
4578
|
}
|
|
4529
4579
|
else if(("b" in b && "phi" in a)){
|
|
4530
4580
|
this.b=b;
|
|
4531
4581
|
this.a=a.b/tan(a.phi);
|
|
4532
4582
|
}
|
|
4533
4583
|
else if(("z" in b && "phi" in a)){
|
|
4534
|
-
this.a=a.z*cos$
|
|
4535
|
-
this.a=a.z*sin$
|
|
4584
|
+
this.a=a.z*cos$2(a.phi);
|
|
4585
|
+
this.a=a.z*sin$2(a.phi);
|
|
4536
4586
|
}
|
|
4537
4587
|
}
|
|
4538
4588
|
else if(typeof(a)==="number"&&typeof(b)==="number"){
|
|
@@ -4600,8 +4650,8 @@ class Complex extends ZikoMath{
|
|
|
4600
4650
|
}
|
|
4601
4651
|
let Z=+prod(this.z,...z.map(n=>n.z)).toFixed(15);
|
|
4602
4652
|
let phi=+sum(this.phi,...z.map(n=>n.phi)).toFixed(15);
|
|
4603
|
-
this.a=+(Z*cos$
|
|
4604
|
-
this.b=+(Z*sin$
|
|
4653
|
+
this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(14);
|
|
4654
|
+
this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(14);
|
|
4605
4655
|
return this;
|
|
4606
4656
|
}
|
|
4607
4657
|
div(...z) {
|
|
@@ -4610,23 +4660,23 @@ class Complex extends ZikoMath{
|
|
|
4610
4660
|
}
|
|
4611
4661
|
let Z=+(this.z/prod(...z.map(n=>n.z))).toFixed(15);
|
|
4612
4662
|
let phi=+(this.phi-sum(...z.map(n=>n.phi))).toFixed(15);
|
|
4613
|
-
this.a=+(Z*cos$
|
|
4614
|
-
this.b=+(Z*sin$
|
|
4663
|
+
this.a=+(Z*cos$2(phi).toFixed(15)).toFixed(15);
|
|
4664
|
+
this.b=+(Z*sin$2(phi).toFixed(15)).toFixed(15);
|
|
4615
4665
|
return this;
|
|
4616
4666
|
}
|
|
4617
4667
|
pow(n) {
|
|
4618
4668
|
if (floor(n) === n && n > 0) {
|
|
4619
4669
|
let z=+(this.z**n).toFixed(15);
|
|
4620
4670
|
let phi=+(this.phi*n).toFixed(15);
|
|
4621
|
-
this.a=+(z*cos$
|
|
4622
|
-
this.b=+(z*sin$
|
|
4671
|
+
this.a=+(z*cos$2(phi).toFixed(15)).toFixed(15);
|
|
4672
|
+
this.b=+(z*sin$2(phi).toFixed(15)).toFixed(15);
|
|
4623
4673
|
}
|
|
4624
4674
|
return this;
|
|
4625
4675
|
}
|
|
4626
4676
|
static fromExpo(z, phi) {
|
|
4627
4677
|
return new Complex(
|
|
4628
|
-
+(z * cos$
|
|
4629
|
-
+(z * sin$
|
|
4678
|
+
+(z * cos$2(phi)).toFixed(13),
|
|
4679
|
+
+(z * sin$2(phi)).toFixed(13)
|
|
4630
4680
|
);
|
|
4631
4681
|
}
|
|
4632
4682
|
get expo() {
|
|
@@ -4648,10 +4698,10 @@ class Complex extends ZikoMath{
|
|
|
4648
4698
|
return z.clone.pow(n);
|
|
4649
4699
|
}
|
|
4650
4700
|
static xpowZ(x){
|
|
4651
|
-
return complex((x**this.a)*cos$
|
|
4701
|
+
return complex((x**this.a)*cos$2(this.b*ln(x)),(x**this.a)*sin$2(this.b*ln(x)));
|
|
4652
4702
|
}
|
|
4653
4703
|
sqrtn(n=2){
|
|
4654
|
-
return complex(sqrtn(this.z,n)*cos$
|
|
4704
|
+
return complex(sqrtn(this.z,n)*cos$2(this.phi/n),sqrtn(this.z,n)*sin$2(this.phi/n));
|
|
4655
4705
|
}
|
|
4656
4706
|
get sqrt(){
|
|
4657
4707
|
return this.sqrtn(2);
|
|
@@ -4660,14 +4710,14 @@ class Complex extends ZikoMath{
|
|
|
4660
4710
|
return complex(this.z,this.phi);
|
|
4661
4711
|
}
|
|
4662
4712
|
get cos(){
|
|
4663
|
-
return complex(cos$
|
|
4713
|
+
return complex(cos$2(this.a)*cosh$1(this.b),sin$2(this.a)*sinh$1(this.b))
|
|
4664
4714
|
}
|
|
4665
4715
|
get sin(){
|
|
4666
|
-
return complex(sin$
|
|
4716
|
+
return complex(sin$2(this.a)*cosh$1(this.b),cos$2(this.a)*sinh$1(this.b))
|
|
4667
4717
|
}
|
|
4668
4718
|
get tan(){
|
|
4669
|
-
const de=cos$
|
|
4670
|
-
return complex(sin$
|
|
4719
|
+
const de=cos$2(this.a*2)+cosh$1(this.b*2);
|
|
4720
|
+
return complex(sin$2(2*this.a)/de,sinh$1(2*this.b)/de);
|
|
4671
4721
|
}
|
|
4672
4722
|
printInConsole() {
|
|
4673
4723
|
let string = this.a + " + " + this.b + " * i";
|
|
@@ -4698,7 +4748,7 @@ const complex=(a,b)=>{
|
|
|
4698
4748
|
// } from "../calculus/index.js";
|
|
4699
4749
|
|
|
4700
4750
|
const abs=(...x)=>mapfun$1(Math.abs,...x);
|
|
4701
|
-
const sqrt$
|
|
4751
|
+
const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
|
|
4702
4752
|
const pow$1=(x,n)=>{
|
|
4703
4753
|
if(typeof x === "number"){
|
|
4704
4754
|
if(typeof n === "number")return Math.pow(x,n);
|
|
@@ -4746,8 +4796,8 @@ const sqrtn=(x,n)=>{
|
|
|
4746
4796
|
};
|
|
4747
4797
|
const e=(...x) => mapfun$1(Math.exp,...x);
|
|
4748
4798
|
const ln=(...x) => mapfun$1(Math.log,...x);
|
|
4749
|
-
const cos$
|
|
4750
|
-
const sin$
|
|
4799
|
+
const cos$2=(...x) => mapfun$1(Fixed.cos,...x);
|
|
4800
|
+
const sin$2=(...x) => mapfun$1(Fixed.sin,...x);
|
|
4751
4801
|
const tan=(...x) => mapfun$1(Fixed.tan,...x);
|
|
4752
4802
|
const sec=(...x) => mapfun$1(Fixed.sec,...x);
|
|
4753
4803
|
const sinc=(...x) => mapfun$1(Fixed.sinc,...x);
|
|
@@ -4757,8 +4807,8 @@ const acos$1=(...x) => mapfun$1(Fixed.acos,...x);
|
|
|
4757
4807
|
const asin=(...x) => mapfun$1(Fixed.asin,...x);
|
|
4758
4808
|
const atan=(...x) => mapfun$1(Fixed.atan,...x);
|
|
4759
4809
|
const acot=(...x) => mapfun$1(Fixed.acot,...x);
|
|
4760
|
-
const cosh=(...x) => mapfun$1(Fixed.cosh,...x);
|
|
4761
|
-
const sinh=(...x) => mapfun$1(Fixed.sinh,...x);
|
|
4810
|
+
const cosh$1=(...x) => mapfun$1(Fixed.cosh,...x);
|
|
4811
|
+
const sinh$1=(...x) => mapfun$1(Fixed.sinh,...x);
|
|
4762
4812
|
const tanh=(...x) => mapfun$1(Fixed.tanh,...x);
|
|
4763
4813
|
const coth=(...x) => mapfun$1(Fixed.coth,...x);
|
|
4764
4814
|
const acosh=(...x) => mapfun$1(Fixed.acosh,...x);
|
|
@@ -4807,12 +4857,12 @@ const hypot=(...x)=>{
|
|
|
4807
4857
|
)
|
|
4808
4858
|
};
|
|
4809
4859
|
|
|
4810
|
-
const {PI, sqrt, cos, sin, acos, pow} = Math;
|
|
4860
|
+
const {PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow} = Math;
|
|
4811
4861
|
|
|
4812
4862
|
const Linear = t => t;
|
|
4813
|
-
const InSin = t => 1 - cos((t * PI) / 2);
|
|
4814
|
-
const OutSin = t => sin((t * PI) / 2);
|
|
4815
|
-
const InOutSin = t => -(cos(PI * t) - 1) / 2;
|
|
4863
|
+
const InSin = t => 1 - cos$1((t * PI) / 2);
|
|
4864
|
+
const OutSin = t => sin$1((t * PI) / 2);
|
|
4865
|
+
const InOutSin = t => -(cos$1(PI * t) - 1) / 2;
|
|
4816
4866
|
|
|
4817
4867
|
const InQuad = t => t**2;
|
|
4818
4868
|
const OutQuad = t => 1 - (1-t)**2;
|
|
@@ -4834,13 +4884,13 @@ const InExpo = t => t === 0 ? 0 : 2**(10*t - 10);
|
|
|
4834
4884
|
const OutExpo = t => t === 1 ? 1 : 1 - 2**(-10 * t);
|
|
4835
4885
|
const InOutExpo = t => t === 0? 0: t === 1? 1: t < 0.5 ? 2**(20 * t - 10) / 2: (2 - 2**(-20 * t + 10)) / 2;
|
|
4836
4886
|
|
|
4837
|
-
const InCirc = t => 1 - sqrt(1 - t**2);
|
|
4838
|
-
const OutCirc = t => sqrt(1 - (t-1)**2);
|
|
4839
|
-
const InOutCirc = t => t < 0.5? (1 - sqrt(1 - (2*t)**2)) / 2: (sqrt(1 - (-2*t+2)**2) + 1) / 2;
|
|
4887
|
+
const InCirc = t => 1 - sqrt$1(1 - t**2);
|
|
4888
|
+
const OutCirc = t => sqrt$1(1 - (t-1)**2);
|
|
4889
|
+
const InOutCirc = t => t < 0.5? (1 - sqrt$1(1 - (2*t)**2)) / 2: (sqrt$1(1 - (-2*t+2)**2) + 1) / 2;
|
|
4840
4890
|
|
|
4841
|
-
const Arc = t => 1 - sin(acos(t));
|
|
4891
|
+
const Arc = t => 1 - sin$1(acos(t));
|
|
4842
4892
|
const Back = (t, x = 1) => (t**2) * ((x+1)*t - x);
|
|
4843
|
-
const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos(20 * PI * t / 3 * t);
|
|
4893
|
+
const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos$1(20 * PI * t / 3 * t);
|
|
4844
4894
|
|
|
4845
4895
|
const InBack = (t, c1 = 1.70158, c3 = c1 + 1) => c3 * pow(t,3)- c1 * (t**2);
|
|
4846
4896
|
const OutBack = (t, c1 = 1.70158, c3 = c1 + 1) => 1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
|
|
@@ -4851,7 +4901,7 @@ const InElastic = (t, c4 = 2*PI/3) => {
|
|
|
4851
4901
|
? 0
|
|
4852
4902
|
: t === 1
|
|
4853
4903
|
? 1
|
|
4854
|
-
: -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
|
|
4904
|
+
: -pow(2, 10 * t - 10) * sin$1((t * 10 - 10.75) * c4);
|
|
4855
4905
|
};
|
|
4856
4906
|
|
|
4857
4907
|
const OutElastic = (t, c4 = 2*PI/3) => {
|
|
@@ -4859,7 +4909,7 @@ const OutElastic = (t, c4 = 2*PI/3) => {
|
|
|
4859
4909
|
? 0
|
|
4860
4910
|
: t === 1
|
|
4861
4911
|
? 1
|
|
4862
|
-
: pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
|
|
4912
|
+
: pow(2, -10 * t) * sin$1((t * 10 - 0.75) * c4) + 1;
|
|
4863
4913
|
};
|
|
4864
4914
|
const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
|
|
4865
4915
|
return t === 0
|
|
@@ -4867,8 +4917,8 @@ const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
|
|
|
4867
4917
|
: t === 1
|
|
4868
4918
|
? 1
|
|
4869
4919
|
: t < 0.5
|
|
4870
|
-
? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
|
|
4871
|
-
: (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
|
|
4920
|
+
? -(pow(2, 20 * t - 10) * sin$1((20 * t - 11.125) * c5)) / 2
|
|
4921
|
+
: (pow(2, -20 * t + 10) * sin$1((20 * t - 11.125) * c5)) / 2 + 1;
|
|
4872
4922
|
};
|
|
4873
4923
|
|
|
4874
4924
|
const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
|
|
@@ -4976,17 +5026,28 @@ const animation = (callback, {ease, t0, t1, start, duration} = {}) =>
|
|
|
4976
5026
|
new TimeAnimation(callback, {ease, t0, t1, start, duration});
|
|
4977
5027
|
|
|
4978
5028
|
class Tick {
|
|
4979
|
-
constructor(ms,
|
|
5029
|
+
constructor(fn, ms, count = Infinity, start) {
|
|
4980
5030
|
this.ms = ms;
|
|
4981
5031
|
this.fn = fn;
|
|
5032
|
+
this.count = count;
|
|
5033
|
+
this.frame = 1;
|
|
4982
5034
|
this.id = null;
|
|
4983
5035
|
this.running = false;
|
|
5036
|
+
if(start) this.start();
|
|
4984
5037
|
}
|
|
4985
5038
|
|
|
4986
5039
|
start() {
|
|
4987
5040
|
if (!this.running) {
|
|
4988
5041
|
this.running = true;
|
|
4989
|
-
this.
|
|
5042
|
+
this.frame = 1;
|
|
5043
|
+
this.id = setInterval(() => {
|
|
5044
|
+
if (this.frame > this.count) {
|
|
5045
|
+
this.stop();
|
|
5046
|
+
return;
|
|
5047
|
+
}
|
|
5048
|
+
this.fn.call(null, this);
|
|
5049
|
+
this.frame++;
|
|
5050
|
+
}, this.ms);
|
|
4990
5051
|
}
|
|
4991
5052
|
return this;
|
|
4992
5053
|
}
|
|
@@ -5004,7 +5065,9 @@ class Tick {
|
|
|
5004
5065
|
return this.running;
|
|
5005
5066
|
}
|
|
5006
5067
|
}
|
|
5007
|
-
|
|
5068
|
+
|
|
5069
|
+
// Helper factory
|
|
5070
|
+
const tick = (fn, ms, count = Infinity, start = true) => new Tick(fn, ms, count, start);
|
|
5008
5071
|
|
|
5009
5072
|
class Clock extends Tick {
|
|
5010
5073
|
constructor(tickMs = 1000 / 60) {
|
|
@@ -5136,7 +5199,8 @@ const Scheduler = (tasks, { repeat = null} = {}) => new TimeScheduler(tasks, { r
|
|
|
5136
5199
|
const step_fps = (step_or_fps) => 1000 / step_or_fps;
|
|
5137
5200
|
|
|
5138
5201
|
const debounce=(fn,delay=1000)=>{
|
|
5139
|
-
|
|
5202
|
+
let id;
|
|
5203
|
+
return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
5140
5204
|
};
|
|
5141
5205
|
const throttle=(fn,delay)=>{
|
|
5142
5206
|
let lastTime=0;
|
|
@@ -5541,57 +5605,37 @@ function findCommonPath(paths) {
|
|
|
5541
5605
|
function useDerived(deriveFn, sources) {
|
|
5542
5606
|
let value = deriveFn(...sources.map(s => s().value));
|
|
5543
5607
|
const subscribers = new Set();
|
|
5544
|
-
let paused = false;
|
|
5545
5608
|
|
|
5546
|
-
function getValue() {
|
|
5547
|
-
return {
|
|
5548
|
-
value,
|
|
5549
|
-
isStateGetter: () => true,
|
|
5550
|
-
_subscribe: (fn) => {
|
|
5551
|
-
subscribers.add(fn);
|
|
5552
|
-
},
|
|
5553
|
-
};
|
|
5554
|
-
}
|
|
5555
|
-
|
|
5556
|
-
function setValue(newValue) {
|
|
5557
|
-
if (paused) return;
|
|
5558
|
-
if (typeof newValue === "function") newValue = newValue(value);
|
|
5559
|
-
if (newValue !== value) {
|
|
5560
|
-
value = newValue;
|
|
5561
|
-
subscribers.forEach(fn => fn(value));
|
|
5562
|
-
}
|
|
5563
|
-
}
|
|
5564
|
-
|
|
5565
|
-
const controller = {
|
|
5566
|
-
pause: () => { paused = true; },
|
|
5567
|
-
resume: () => { paused = false; },
|
|
5568
|
-
clear: () => { subscribers.clear(); },
|
|
5569
|
-
force: (newValue) => {
|
|
5570
|
-
if (typeof newValue === "function") newValue = newValue(value);
|
|
5571
|
-
value = newValue;
|
|
5572
|
-
subscribers.forEach(fn => fn(value));
|
|
5573
|
-
},
|
|
5574
|
-
getSubscribers: () => new Set(subscribers),
|
|
5575
|
-
};
|
|
5576
|
-
|
|
5577
|
-
// Subscribe to source states
|
|
5578
5609
|
sources.forEach(source => {
|
|
5579
5610
|
const srcValue = source(); // getValue()
|
|
5580
5611
|
srcValue._subscribe(() => {
|
|
5581
|
-
|
|
5612
|
+
{
|
|
5582
5613
|
const newVal = deriveFn(...sources.map(s => s().value));
|
|
5583
5614
|
if (newVal !== value) {
|
|
5584
5615
|
value = newVal;
|
|
5585
5616
|
subscribers.forEach(fn => fn(value));
|
|
5586
5617
|
}
|
|
5587
5618
|
}
|
|
5588
|
-
}
|
|
5619
|
+
});
|
|
5589
5620
|
});
|
|
5590
|
-
|
|
5591
|
-
|
|
5621
|
+
return () => ({
|
|
5622
|
+
value,
|
|
5623
|
+
isStateGetter : () => true,
|
|
5624
|
+
_subscribe: (fn) => subscribers.add(fn)
|
|
5625
|
+
})
|
|
5592
5626
|
}
|
|
5593
5627
|
|
|
5594
|
-
const useReactive = (nested_value) => mapfun$1(
|
|
5628
|
+
const useReactive = (nested_value) => mapfun$1(
|
|
5629
|
+
n => {
|
|
5630
|
+
const state = useState(n);
|
|
5631
|
+
// console.log(state)
|
|
5632
|
+
return {
|
|
5633
|
+
get : state[0],
|
|
5634
|
+
set : state[1],
|
|
5635
|
+
}
|
|
5636
|
+
},
|
|
5637
|
+
nested_value
|
|
5638
|
+
);
|
|
5595
5639
|
|
|
5596
5640
|
class ZikoUseChannel{
|
|
5597
5641
|
constructor(name = ""){
|
|
@@ -5827,8 +5871,67 @@ class ZikoUseStorage{
|
|
|
5827
5871
|
const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
|
|
5828
5872
|
const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
|
|
5829
5873
|
|
|
5874
|
+
let {sqrt, cos, sin, exp, log, cosh, sinh} = Math;
|
|
5875
|
+
// Math.abs = new Proxy(Math.abs, {
|
|
5876
|
+
// apply(target, thisArg, args) {
|
|
5877
|
+
// const x = args[0]
|
|
5878
|
+
// if(typeof x === 'number') return target.apply(thisArg, args);
|
|
5879
|
+
// if(x?.isComplex?.()){
|
|
5880
|
+
// const {a, b, z, phi} = x
|
|
5881
|
+
// const complex = (a, b) => new x.constructor(a, b)
|
|
5882
|
+
// switch(target.name){
|
|
5883
|
+
// case 'abs' : return a.z;
|
|
5884
|
+
// case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
|
|
5885
|
+
// }
|
|
5886
|
+
// }
|
|
5887
|
+
|
|
5888
|
+
// }
|
|
5889
|
+
// });
|
|
5890
|
+
|
|
5891
|
+
|
|
5892
|
+
for (const key of Object.getOwnPropertyNames(Math)) {
|
|
5893
|
+
const fn = Math[key];
|
|
5894
|
+
if (typeof fn === "function") {
|
|
5895
|
+
Math[key] = new Proxy(fn, {
|
|
5896
|
+
apply(target, thisArg, args) {
|
|
5897
|
+
// console.log(target)
|
|
5898
|
+
const x = args[0];
|
|
5899
|
+
if(typeof x === 'number' || args.length === 0) return target.apply(thisArg, args);
|
|
5900
|
+
if(x?.isComplex?.()){
|
|
5901
|
+
const {a, b, z, phi} = x;
|
|
5902
|
+
const complex = (a, b) => new x.constructor(a, b);
|
|
5903
|
+
switch(target.name){
|
|
5904
|
+
case 'abs' : return x.z;
|
|
5905
|
+
case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
|
|
5906
|
+
case 'log' : return complex(log(z), phi);
|
|
5907
|
+
case 'exp' : return complex(exp(a)*cos(b),exp(a)*sin(b));
|
|
5908
|
+
case 'cos' : return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
|
|
5909
|
+
case 'sin' : return complex(sin(a)*cosh(b),cos(a)*sinh(b));
|
|
5910
|
+
case 'tan' : {
|
|
5911
|
+
const DEN = cos(2*a)+cosh(2*b);
|
|
5912
|
+
return complex(sin(2*a) /DEN, sinh(2*b)/DEN);
|
|
5913
|
+
}
|
|
5914
|
+
case 'cosh' : return complex(cosh(a)*cos(b),sinh(a)*sin(b));
|
|
5915
|
+
case 'sinh' : return complex(sinh(a)*cos(b),cosh(a)*sin(b));
|
|
5916
|
+
case 'tanh' : {
|
|
5917
|
+
const DEN=cosh(2*a)+cos(2*b);
|
|
5918
|
+
return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
|
|
5919
|
+
}
|
|
5920
|
+
default : return target.apply(thisArg, args)
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
// if( x.isMatrix?.()){
|
|
5924
|
+
// const {rows, cols, arr} = x
|
|
5925
|
+
// // return new x.constructor(rows, cols, arr.flat(1).map(n=>));
|
|
5926
|
+
// }
|
|
5927
|
+
throw new TypeError(`Math.${key} expects only numbers`);
|
|
5928
|
+
}
|
|
5929
|
+
});
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5932
|
+
|
|
5830
5933
|
if(globalThis?.document){
|
|
5831
5934
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5832
5935
|
}
|
|
5833
5936
|
|
|
5834
|
-
export { App, Arc, Back, Base, Canvas, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, Grid$1 as Grid, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Svg, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement, UINode, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUICanvas, ZikoUIFlex, ZikoUIGrid, ZikoUIHTMLWrapper, ZikoUISVGWrapper, ZikoUISuspense, ZikoUISvg, ZikoUIText, ZikoUIXMLWrapper, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindClickEvent, bindClipboardEvent, bindCustomEvent, bindDragEvent, bindFocusEvent, bindHashEvent, bindKeyEvent, bindMouseEvent, bindPointerEvent, bindTouchEvent, bindWheelEvent, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$
|
|
5937
|
+
export { App, Arc, Back, Base, Canvas, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, Grid$1 as Grid, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Svg, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement, UINode, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUICanvas, ZikoUIFlex, ZikoUIGrid, ZikoUIHTMLWrapper, ZikoUISVGWrapper, ZikoUISuspense, ZikoUISvg, ZikoUIText, ZikoUIXMLWrapper, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindClickEvent, bindClipboardEvent, bindCustomEvent, bindDragEvent, bindFocusEvent, bindHashEvent, bindKeyEvent, bindMouseEvent, bindPointerEvent, bindTouchEvent, bindWheelEvent, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|