ziko 0.51.1 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +1638 -1456
- package/dist/ziko.js +853 -810
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +853 -810
- package/package.json +1 -1
- package/src/{__helpers__ → helpers}/register/index.js +1 -1
- package/src/hooks/use-ipc.js +1 -3
- package/src/math/adapted/index.js +7 -0
- package/src/math/complex/index.js +5 -2
- package/src/math/functions/helper.js +68 -17
- package/src/math/functions/index.js +3 -2
- package/src/math/functions/primitives/index.js +176 -0
- package/src/math/mapfun/index.js +19 -0
- package/src/math/utils/index.js +1 -1
- package/src/math/utils/mapfun.js +30 -30
- package/src/ui/constructors/UIElement.js +9 -9
- package/src/ui/constructors/UIElementCore.js +2 -2
- package/types/math/adapted/index.d.ts +4 -0
- package/types/math/complex/index.d.ts +1 -1
- package/types/math/mapfun/index.d.ts +87 -0
- /package/src/{__helpers__ → helpers}/checkers/index.js +0 -0
- /package/src/{__helpers__ → helpers}/index.js +0 -0
- /package/src/{__helpers__ → helpers}/register/register-to-class.js +0 -0
- /package/src/{__helpers__ → helpers}/register/register-to-instance.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { register_to_class } from "./register-to-class.js";
|
|
2
|
-
import { register_to_instance } from "./register-to-instance"; // Not Overridable
|
|
2
|
+
import { register_to_instance } from "./register-to-instance.js"; // Not Overridable
|
|
3
3
|
export const register = (target, ...mixins) => {
|
|
4
4
|
console.log(target)
|
|
5
5
|
// return register_to_class(target, ...mixins)
|
package/src/hooks/use-ipc.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Random } from "../math/random/index.js";
|
|
2
|
-
|
|
3
1
|
class UseIPC {
|
|
4
2
|
#channel;
|
|
5
3
|
#eventData;
|
|
@@ -11,7 +9,7 @@ class UseIPC {
|
|
|
11
9
|
this.#channel = new BroadcastChannel(name);
|
|
12
10
|
this.#eventData = new Map();
|
|
13
11
|
this.#handlers = new Map(); // Map<event, Array<{fn, rooms}>>
|
|
14
|
-
this.#uuid = "ziko-channel:" +
|
|
12
|
+
this.#uuid = "ziko-channel:" + (Math.random()*10e16); // To Be Replaced by UUID
|
|
15
13
|
this.#subscribers = new Set([this.#uuid]);
|
|
16
14
|
this.#currentRooms = new Set();
|
|
17
15
|
this.#channel.addEventListener("message", (e) => {
|
|
@@ -41,8 +41,8 @@ class Complex{
|
|
|
41
41
|
this.a=a.b/tan(a.phi);
|
|
42
42
|
}
|
|
43
43
|
else if(("z" in a && "phi" in a)){
|
|
44
|
-
this.a=a.z*cos(a.phi);
|
|
45
|
-
this.
|
|
44
|
+
this.a = +a.z*cos(a.phi).toFixed(15);
|
|
45
|
+
this.b = +a.z*sin(a.phi).toFixed(15);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
else if(typeof(a)==="number"&&typeof(b)==="number"){
|
|
@@ -50,6 +50,9 @@ class Complex{
|
|
|
50
50
|
this.b = +b.toFixed(32);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
get __mapfun__(){
|
|
54
|
+
return true
|
|
55
|
+
}
|
|
53
56
|
isComplex(){
|
|
54
57
|
return true
|
|
55
58
|
}
|
|
@@ -1,30 +1,81 @@
|
|
|
1
1
|
const {PI, cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh, log} = Math
|
|
2
2
|
export let Fixed={
|
|
3
|
-
cos
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
cos : x=> {
|
|
4
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
5
|
+
cos(x.a)*cosh(x.b),
|
|
6
|
+
-(sin(x.a)*sinh(x.b))
|
|
7
|
+
);
|
|
8
|
+
return cos(x)
|
|
9
|
+
},
|
|
10
|
+
sin : x=>{
|
|
11
|
+
if(x?.isComplex) return new x.constructor(
|
|
12
|
+
sin(x.a)*cosh(x.b),
|
|
13
|
+
cos(x.a)*sinh(x.b)
|
|
14
|
+
);
|
|
15
|
+
return sin(x)
|
|
16
|
+
},
|
|
17
|
+
tan : x=>{
|
|
18
|
+
if(x?.isComplex){
|
|
19
|
+
const DEN = cos(2*x.a)+cosh(2*x.b);
|
|
20
|
+
return new x.constructor(
|
|
21
|
+
sin(2*x.a)/DEN,
|
|
22
|
+
sinh(2*x.b)/DEN
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return tan(x)
|
|
26
|
+
},
|
|
6
27
|
sinc: x => sin(PI*x)/(PI*x),
|
|
7
28
|
sec: x => 1/cos(x),
|
|
8
29
|
csc: x => 1/sin(x),
|
|
9
30
|
cot: x => 1/tan(x),
|
|
10
|
-
acos
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
acos: x=>{
|
|
32
|
+
if(x?.isComplex) return
|
|
33
|
+
return sin(x)
|
|
34
|
+
},
|
|
35
|
+
asin: x=>{
|
|
36
|
+
if(x?.isComplex) return
|
|
37
|
+
return sin(x)
|
|
38
|
+
},
|
|
39
|
+
atan: x=>{
|
|
40
|
+
if(x?.isComplex) return
|
|
41
|
+
return sin(x)
|
|
42
|
+
},
|
|
13
43
|
acot: x => PI/2-atan(x),
|
|
14
|
-
cosh
|
|
15
|
-
|
|
16
|
-
|
|
44
|
+
cosh: x=>{
|
|
45
|
+
if(x?.isComplex) return new x.constructor(
|
|
46
|
+
cosh(x.a)*cos(x.b),
|
|
47
|
+
sinh(x.a)*sin(x.b)
|
|
48
|
+
);
|
|
49
|
+
return cosh(x)
|
|
50
|
+
},
|
|
51
|
+
sinh: x=>{
|
|
52
|
+
if(x?.isComplex) return new x.constructor(
|
|
53
|
+
sinh(x.a)*cos(x.b),
|
|
54
|
+
cosh(x.a)*sin(x.b)
|
|
55
|
+
);
|
|
56
|
+
return sinh(x)
|
|
57
|
+
},
|
|
58
|
+
tanh: x=>{
|
|
59
|
+
if(x?.isComplex){
|
|
60
|
+
const DEN=cosh(2*a)+cos(2*b);
|
|
61
|
+
return new x.constructor(
|
|
62
|
+
sinh(2*a)/DEN,
|
|
63
|
+
sin(2*b)/DEN
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
return tanh(x)
|
|
67
|
+
},
|
|
17
68
|
coth: n => (1/2*log((1+n)/(1-n))),
|
|
18
69
|
acosh,
|
|
19
70
|
asinh,
|
|
20
71
|
atanh,
|
|
21
72
|
}
|
|
22
73
|
|
|
23
|
-
Fixed = new Proxy(Fixed, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
74
|
+
// Fixed = new Proxy(Fixed, {
|
|
75
|
+
// get(target, prop) {
|
|
76
|
+
// if(prop in target){
|
|
77
|
+
// return x => + target[prop](x).toFixed(15);
|
|
78
|
+
// }
|
|
79
|
+
// return undefined;
|
|
80
|
+
// }
|
|
81
|
+
// })
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Fixed } from "./helper.js";
|
|
2
|
-
import { mapfun } from "../
|
|
2
|
+
import { mapfun } from "../mapfun/index.js";
|
|
3
3
|
import {
|
|
4
4
|
min,
|
|
5
5
|
max
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
from "../statistics/index.js";
|
|
7
8
|
|
|
8
9
|
const abs=(...x)=>mapfun(Math.abs,...x);
|
|
9
10
|
const sqrt=(...x)=>mapfun(Math.sqrt,...x);
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { mapfun } from '../../mapfun/index.js';
|
|
2
|
+
|
|
3
|
+
export const abs = (...x) => mapfun(
|
|
4
|
+
x =>{
|
|
5
|
+
if(x.isComplex?.()) return x.z;
|
|
6
|
+
return Math.abs(x)
|
|
7
|
+
},
|
|
8
|
+
...x
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
export const sqrt = (...x) => mapfun(
|
|
12
|
+
x=>{
|
|
13
|
+
if(x.isComplex?.()){
|
|
14
|
+
const {z, phi} = x
|
|
15
|
+
return new x.constructor(
|
|
16
|
+
Math.sqrt(z) * Math.cos(phi/2),
|
|
17
|
+
Math.sqrt(z) * Math.sin(phi/2)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return Math.sqrt(x);
|
|
21
|
+
},
|
|
22
|
+
...x
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export const e = (...x) => mapfun(
|
|
26
|
+
x => {
|
|
27
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
28
|
+
Math.exp(x.a) * Math.cos(x.b),
|
|
29
|
+
Math.exp(x.a) * Math.sin(x.b)
|
|
30
|
+
);
|
|
31
|
+
return Math.ln(x)
|
|
32
|
+
}
|
|
33
|
+
,...x
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const ln = (...x) => mapfun(
|
|
37
|
+
x => {
|
|
38
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
39
|
+
Math.log(x.z),
|
|
40
|
+
x.phi
|
|
41
|
+
);
|
|
42
|
+
return Math.ln(x)
|
|
43
|
+
}
|
|
44
|
+
,...x
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const sign = (...x) => mapfun(
|
|
48
|
+
x => {
|
|
49
|
+
if(x.isComplex?.()){
|
|
50
|
+
const {z, phi} = x;
|
|
51
|
+
if(z===0) return new x.constructor(0, 0);
|
|
52
|
+
return new x.constructor({z:1, phi})
|
|
53
|
+
}
|
|
54
|
+
return Math.sign(x)
|
|
55
|
+
}
|
|
56
|
+
,...x
|
|
57
|
+
);
|
|
58
|
+
export const cos = (...x) => mapfun(
|
|
59
|
+
x => {
|
|
60
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
61
|
+
Math.cos(x.a) * Math.cosh(x.b),
|
|
62
|
+
-Math.sin(x.a) * Math.sinh(x.b)
|
|
63
|
+
);
|
|
64
|
+
return Math.cos(x)
|
|
65
|
+
}
|
|
66
|
+
,...x
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export const sin = (...x) => mapfun(
|
|
70
|
+
x =>{
|
|
71
|
+
if(x?.isComplex) return new x.constructor(
|
|
72
|
+
Math.sin(x.a) * Math.cosh(x.b),
|
|
73
|
+
Math.cos(x.a) * Math.sinh(x.b)
|
|
74
|
+
);
|
|
75
|
+
return Math.sin(x)
|
|
76
|
+
}
|
|
77
|
+
, ...x
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export const tan = (...x) => mapfun(
|
|
81
|
+
x =>{
|
|
82
|
+
if(x?.isComplex){
|
|
83
|
+
const DEN = Math.cos(2*x.a) + Math.cosh(2*x.b);
|
|
84
|
+
return new x.constructor(
|
|
85
|
+
Math.sin(2*x.a) / DEN,
|
|
86
|
+
Math.sinh(2*x.b) / DEN
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return Math.tan(x)
|
|
90
|
+
},
|
|
91
|
+
...x
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export const acos = (...x) => mapfun(
|
|
95
|
+
x =>{
|
|
96
|
+
if(x?.isComplex){
|
|
97
|
+
const { a, b } = x;
|
|
98
|
+
const Rp = Math.hypot(a + 1, b);
|
|
99
|
+
const Rm = Math.hypot(a - 1, b);
|
|
100
|
+
globalThis.Rp = Rp
|
|
101
|
+
globalThis.Rm = Rm
|
|
102
|
+
console.log({a, b, Rp, Rm})
|
|
103
|
+
return new x.constructor(
|
|
104
|
+
Math.acos((Rp - Rm) / 2),
|
|
105
|
+
-Math.acosh((Rp + Rm) / 2),
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
return Math.acos(x)
|
|
109
|
+
},
|
|
110
|
+
...x
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
export const asin = (...x) => mapfun(
|
|
114
|
+
x => {
|
|
115
|
+
if(x?.isComplex){
|
|
116
|
+
const { a, b } = x;
|
|
117
|
+
const Rp = Math.hypot(a + 1, b);
|
|
118
|
+
const Rm = Math.hypot(a - 1, b);
|
|
119
|
+
return new x.constructor(
|
|
120
|
+
Math.asin((Rp - Rm) / 2),
|
|
121
|
+
Math.acosh((Rp + Rm) / 2)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return Math.asin(x);
|
|
125
|
+
},
|
|
126
|
+
...x
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
export const atan = (...x) => mapfun(
|
|
130
|
+
x => {
|
|
131
|
+
if(x?.isComplex){
|
|
132
|
+
const { a, b } = x;
|
|
133
|
+
return new x.constructor(
|
|
134
|
+
Math.atan((a*2/(1-a**2-b**2)))/2,
|
|
135
|
+
Math.log((a**2 + (1+b)**2)/(a**2 + (1-b)**2))/4
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
return Math.atan(x);
|
|
139
|
+
},
|
|
140
|
+
...x
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
export const cosh = (...x) => mapfun(
|
|
145
|
+
x =>{
|
|
146
|
+
if(x?.isComplex) return new x.constructor(
|
|
147
|
+
cosh(x.a)*cos(x.b),
|
|
148
|
+
sinh(x.a)*sin(x.b)
|
|
149
|
+
);
|
|
150
|
+
return cosh(x)
|
|
151
|
+
},
|
|
152
|
+
...x
|
|
153
|
+
)
|
|
154
|
+
export const sinh = (...x) => mapfun(
|
|
155
|
+
x =>{
|
|
156
|
+
if(x?.isComplex) return new x.constructor(
|
|
157
|
+
sinh(x.a)*cos(x.b),
|
|
158
|
+
cosh(x.a)*sin(x.b)
|
|
159
|
+
);
|
|
160
|
+
return sinh(x)
|
|
161
|
+
},
|
|
162
|
+
...x
|
|
163
|
+
)
|
|
164
|
+
export const tanh = (...x) => mapfun(
|
|
165
|
+
x =>{
|
|
166
|
+
if(x?.isComplex){
|
|
167
|
+
const DEN=cosh(2*a)+cos(2*b);
|
|
168
|
+
return new x.constructor(
|
|
169
|
+
sinh(2*a)/DEN,
|
|
170
|
+
sin(2*b)/DEN
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
return tanh(x)
|
|
174
|
+
},
|
|
175
|
+
...x
|
|
176
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { is_primitive } from "../../helpers/checkers/index.js";
|
|
2
|
+
export const mapfun=(fun,...X)=>{
|
|
3
|
+
const Y=X.map(x=>{
|
|
4
|
+
if(is_primitive(x) || x?.__mapfun__) return fun(x)
|
|
5
|
+
if(x instanceof Array) return x.map(n=>mapfun(fun,n));
|
|
6
|
+
if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
|
|
7
|
+
if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
|
|
8
|
+
if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
|
|
9
|
+
if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
|
|
10
|
+
else if(x instanceof Object){
|
|
11
|
+
return Object.fromEntries(
|
|
12
|
+
Object.entries(x).map(
|
|
13
|
+
n=>n=[n[0],mapfun(fun,n[1])]
|
|
14
|
+
)
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return Y.length==1? Y[0]: Y;
|
|
19
|
+
}
|
package/src/math/utils/index.js
CHANGED
package/src/math/utils/mapfun.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import {ln,e,cos,sin,sqrt,cosh,sinh} from "../functions/index.js";
|
|
2
|
-
import { Fixed } from "../functions/helper.js";
|
|
3
|
-
// To generalise
|
|
4
1
|
const mapfun=(fun,...X)=>{
|
|
5
2
|
const Y=X.map(x=>{
|
|
6
|
-
if(
|
|
7
|
-
|
|
3
|
+
if(
|
|
4
|
+
x===null||
|
|
5
|
+
["number","string","boolean","bigint","undefined"].includes(typeof x)||
|
|
6
|
+
x?.__mapfun__
|
|
7
|
+
) return fun(x)
|
|
8
8
|
if(x instanceof Array) return x.map(n=>mapfun(fun,n));
|
|
9
9
|
if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
|
|
10
10
|
if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
|
|
11
11
|
if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
|
|
12
12
|
if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
|
|
13
|
-
if(x.isComplex?.()){
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
13
|
+
// if(x.isComplex?.()){
|
|
14
|
+
// const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
|
|
15
|
+
// switch(fun){
|
|
16
|
+
// // Moved to Fixed to avoid Circular Dep
|
|
17
|
+
// // case Math.log: return new x.constructor(ln(z),phi); // Done
|
|
18
|
+
// // case Math.exp: return new x.constructor(e(a)*cos(b),e(a)*sin(b)); // Done
|
|
19
|
+
// // case Math.abs: return z; // Done
|
|
20
|
+
// // case Math.sqrt: return new x.constructor(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
|
|
21
|
+
// // case Fixed.cos: return new x.constructor(cos(a)*cosh(b),-(sin(a)*sinh(b)));
|
|
22
|
+
// // case Fixed.sin: return new x.constructor(sin(a)*cosh(b),cos(a)*sinh(b));
|
|
23
|
+
// // case Fixed.tan:{
|
|
24
|
+
// // const DEN = cos(2*a)+cosh(2*b);
|
|
25
|
+
// // return new x.constructor(sin(2*a)/DEN,sinh(2*b)/DEN);
|
|
26
|
+
// // }
|
|
27
|
+
// // case Fixed.cosh:return new x.constructor(cosh(a)*cos(b),sinh(a)*sin(b));
|
|
28
|
+
// // case Fixed.sinh:return new x.constructor(sinh(a)*cos(b),cosh(a)*sin(b));
|
|
29
|
+
// // case Fixed.tanh:{
|
|
30
|
+
// // const DEN=cosh(2*a)+cos(2*b);
|
|
31
|
+
// // return new x.constructor(sinh(2*a)/DEN,sin(2*b)/DEN)
|
|
32
|
+
// // }
|
|
33
|
+
// default : return fun(x)
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
36
|
else if(x instanceof Object){
|
|
37
37
|
return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
|
|
38
|
-
return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
|
|
38
|
+
// return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
return Y.length==1?Y[0]:Y;
|
|
41
|
+
return Y.length==1? Y[0]: Y;
|
|
42
42
|
}
|
|
43
43
|
export {mapfun}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIElementCore } from "./UIElementCore.js";
|
|
2
|
-
import { register_to_class } from "../../
|
|
2
|
+
import { register_to_class } from "../../helpers/register/register-to-class.js";
|
|
3
3
|
import {
|
|
4
4
|
LifecycleMethods,
|
|
5
5
|
AttrsMethods,
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
EventsMethodes,
|
|
9
9
|
StyleMethods
|
|
10
10
|
} from "../__methods__/index.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "../../--reactivity-deprecated/events/custom-event.js"
|
|
11
|
+
// import {
|
|
12
|
+
// // useCustomEvent,
|
|
13
|
+
// // useSwipeEvent,
|
|
14
|
+
// // watchIntersection,
|
|
15
|
+
// // watchSize,
|
|
16
|
+
// // watchAttr,
|
|
17
|
+
// // watchChildren
|
|
18
|
+
// } from "../../--reactivity-deprecated/events/custom-event.js"
|
|
19
19
|
class UIElement extends UIElementCore{
|
|
20
20
|
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
21
21
|
super()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {UINode} from "./UINode.js";
|
|
2
|
-
|
|
2
|
+
import {__init__global__} from '../../__ziko__/index.js';
|
|
3
3
|
import { UIStore } from "../../__ziko__/__ui__.js";
|
|
4
|
-
|
|
4
|
+
__init__global__()
|
|
5
5
|
class UIElementCore extends UINode{
|
|
6
6
|
constructor(){
|
|
7
7
|
super()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Complex } from "../../../src/math/index.js";
|
|
2
|
+
import { Matrix } from "../../../src/math/matrix/index.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Objects that behave like primitives for mapfun,
|
|
6
|
+
* meaning fun(x) is applied directly without recursion.
|
|
7
|
+
*/
|
|
8
|
+
export interface MapfunPrimitiveLike {
|
|
9
|
+
__mapfun__?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PrimitiveLike =
|
|
13
|
+
| number
|
|
14
|
+
| boolean
|
|
15
|
+
| string
|
|
16
|
+
| bigint
|
|
17
|
+
| undefined
|
|
18
|
+
| null
|
|
19
|
+
| { readonly __mapfun__: boolean };
|
|
20
|
+
|
|
21
|
+
export type Mappable =
|
|
22
|
+
| number
|
|
23
|
+
| string
|
|
24
|
+
| boolean
|
|
25
|
+
| bigint
|
|
26
|
+
| undefined
|
|
27
|
+
| null
|
|
28
|
+
| Matrix
|
|
29
|
+
| MapfunPrimitiveLike
|
|
30
|
+
| any[]
|
|
31
|
+
| Set<any>
|
|
32
|
+
| Map<any, any>
|
|
33
|
+
| object;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* mapfun transform rules
|
|
37
|
+
*/
|
|
38
|
+
export type MapfunResult<F extends (x: any) => any, T> =
|
|
39
|
+
// Objects with __mapfun__ → treat as primitive (call fun(x))
|
|
40
|
+
// T extends MapfunPrimitiveLike
|
|
41
|
+
// ? ReturnType<F> :
|
|
42
|
+
|
|
43
|
+
// Matrix → always return Matrix (your JS logic rebuilds a new Matrix)
|
|
44
|
+
|
|
45
|
+
T extends PrimitiveLike
|
|
46
|
+
? ReturnType<F> :
|
|
47
|
+
// T extends Complex
|
|
48
|
+
// ? T :
|
|
49
|
+
T extends Matrix
|
|
50
|
+
? T :
|
|
51
|
+
|
|
52
|
+
// Array → deep-map
|
|
53
|
+
T extends Array<infer U>
|
|
54
|
+
? Array<MapfunResult<F, U>> :
|
|
55
|
+
|
|
56
|
+
// Set → deep-map
|
|
57
|
+
T extends Set<infer U>
|
|
58
|
+
? Set<MapfunResult<F, U>> :
|
|
59
|
+
|
|
60
|
+
// Map → deep-map values
|
|
61
|
+
T extends Map<infer K, infer V>
|
|
62
|
+
? Map<K, MapfunResult<F, V>> :
|
|
63
|
+
|
|
64
|
+
// Other objects → recursively map fields
|
|
65
|
+
T extends object
|
|
66
|
+
? { [K in keyof T]: MapfunResult<F, T[K]> } :
|
|
67
|
+
|
|
68
|
+
// Primitive
|
|
69
|
+
ReturnType<F>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* If only one argument → return mapped value
|
|
73
|
+
* If multiple → return tuple of mapped values
|
|
74
|
+
*/
|
|
75
|
+
type UnwrapSingle<T extends unknown[]> =
|
|
76
|
+
T extends [infer U] ? U : { [K in keyof T]: T[K] };
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* mapfun main declaration
|
|
80
|
+
*/
|
|
81
|
+
export declare function mapfun<
|
|
82
|
+
F extends (x: any) => any,
|
|
83
|
+
A extends Mappable[]
|
|
84
|
+
>(
|
|
85
|
+
fun: F,
|
|
86
|
+
...values: A
|
|
87
|
+
): UnwrapSingle<{ [K in keyof A]: MapfunResult<F, A[K]> }>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|