ziko 0.51.1 → 0.53.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.
@@ -1,7 +1,7 @@
1
1
  import {UINode} from "./UINode.js";
2
- // import {__init__global__} from '../../__ziko__/index.js';
2
+ import {__init__global__} from '../../__ziko__/index.js';
3
3
  import { UIStore } from "../../__ziko__/__ui__.js";
4
- // __init__global__()
4
+ __init__global__()
5
5
  class UIElementCore extends UINode{
6
6
  constructor(){
7
7
  super()
@@ -0,0 +1,4 @@
1
+ import type { Complex } from '../complex'
2
+ export declare function adapted_cos(x: Complex): Complex;
3
+ export declare function adapted_cos(x: number): number;
4
+
@@ -16,7 +16,7 @@ export declare class Complex {
16
16
 
17
17
  isComplex(): true;
18
18
  toString(): string;
19
-
19
+ readonly __mapfun__ : boolean
20
20
  readonly clone: Complex;
21
21
  readonly z: number;
22
22
  readonly phi: number;
@@ -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