ziko 0.65.0 → 0.67.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 +61 -107
- package/dist/ziko.js +61 -107
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +61 -107
- package/package.json +2 -2
- package/src/events/custom-events-registry/click-away.js +0 -1
- package/src/exp-events/controller/index.js +41 -0
- package/src/exp-events/custom-events-registry/click-away.js +39 -0
- package/src/exp-events/custom-events-registry/index.js +3 -0
- package/src/exp-events/custom-events-registry/swipe.js +76 -0
- package/src/exp-events/custom-events-registry/view.js +74 -0
- package/src/exp-events/details-setter/index.js +4 -0
- package/src/exp-events/details-setter/key.js +14 -0
- package/src/exp-events/details-setter/mouse.js +35 -0
- package/src/exp-events/details-setter/pointer.js +35 -0
- package/src/exp-events/details-setter/touch.js +37 -0
- package/src/exp-events/index.js +1 -0
- package/src/hooks/index.d.ts +11 -0
- package/src/hooks/use-derived.d.ts +14 -0
- package/src/hooks/use-event-emitter.d.ts +46 -0
- package/src/hooks/use-favicon.d.ts +41 -0
- package/src/hooks/use-ipc.d.ts +12 -0
- package/src/hooks/use-media-query.d.ts +24 -0
- package/src/hooks/use-reactive.d.ts +14 -0
- package/src/hooks/use-root.d.ts +15 -0
- package/src/hooks/use-state.d.ts +25 -0
- package/src/hooks/use-storage.d.ts +47 -0
- package/src/hooks/use-thread.d.ts +33 -0
- package/src/hooks/use-title.d.ts +37 -0
- package/src/index.d.ts +5 -0
- package/src/math/complex/index.d.ts +54 -0
- package/src/math/functions/index.d.ts +140 -0
- package/src/math/functions/logic/index.d.ts +11 -0
- package/src/math/functions/mapfun/index.d.ts +87 -0
- package/src/math/functions/utils/index.d.ts +1 -0
- package/src/math/functions/utils/mapfun.d.ts +43 -0
- package/src/math/index.d.ts +5 -0
- package/src/time/clocks/clock.d.ts +28 -0
- package/src/time/clocks/index.d.ts +3 -0
- package/src/time/clocks/scheduler.d.ts +42 -0
- package/src/time/clocks/tick.d.ts +26 -0
- package/src/time/decorators/index.d.ts +9 -0
- package/src/time/delay/index.d.ts +12 -0
- package/src/time/ease/index.d.ts +103 -0
- package/src/time/index.d.ts +4 -0
- package/src/time/loop/index.d.ts +50 -0
- package/src/ui/constructors/UIElement.js +19 -93
- package/src/ui/constructors/UIElementCore.d.ts +59 -0
- package/src/ui/constructors/UIElementCore.js +0 -9
- package/src/ui/constructors/UINode.d.ts +11 -0
- package/src/ui/constructors/UINode.js +1 -1
- package/src/ui/{__methods__ → constructors/mixins}/dom.js +1 -1
- package/src/ui/{__methods__ → constructors/mixins}/events.js +3 -3
- package/src/ui/{__methods__ → constructors/mixins}/style.js +1 -1
- package/src/ui/{__methods__ → constructors/mixins}/utils/index.js +4 -4
- package/src/ui/web-component/index.d.ts +14 -0
- package/src/ui/web-component/index.js +2 -2
- package/README.dep.md +0 -137
- package/src/--reactivity-deprecated/events/Input.js +0 -62
- package/src/--reactivity-deprecated/events/ZikoEvent.js +0 -92
- package/src/--reactivity-deprecated/events/__note__ +0 -1
- package/src/--reactivity-deprecated/events/custom-event.js +0 -57
- package/src/--reactivity-deprecated/events/hash.js +0 -47
- package/src/--reactivity-deprecated/events/index.js +0 -12
- package/src/--reactivity-deprecated/events/media.js +0 -1
- package/src/--reactivity-deprecated/events/mouse.js +0 -233
- package/src/--reactivity-deprecated/events/swipe.js +0 -149
- package/src/--reactivity-deprecated/events/touch.js +0 -0
- package/src/--reactivity-deprecated/hooks/Contexte/index.js +0 -1
- package/src/--reactivity-deprecated/hooks/Contexte/useSuccesifKeys.js +0 -14
- package/src/--reactivity-deprecated/hooks/UI/index.js +0 -6
- package/src/--reactivity-deprecated/hooks/UI/useCssLink.js +0 -0
- package/src/--reactivity-deprecated/hooks/UI/useLinearGradient.js +0 -0
- package/src/--reactivity-deprecated/hooks/UI/useMediaQuery.js +0 -43
- package/src/--reactivity-deprecated/hooks/UI/useRadialGradient.js +0 -0
- package/src/--reactivity-deprecated/hooks/UI/useRoot.js +0 -39
- package/src/--reactivity-deprecated/hooks/UI/useStyle.js +0 -79
- package/src/--reactivity-deprecated/hooks/UI/useTheme.js +0 -62
- package/src/--reactivity-deprecated/hooks/head/_useCssText.js +0 -21
- package/src/--reactivity-deprecated/hooks/head/index.js +0 -5
- package/src/--reactivity-deprecated/hooks/head/useFavIcon.js +0 -38
- package/src/--reactivity-deprecated/hooks/head/useHead.js +0 -28
- package/src/--reactivity-deprecated/hooks/head/useMeta.js +0 -52
- package/src/--reactivity-deprecated/hooks/head/useTitle.js +0 -30
- package/src/--reactivity-deprecated/hooks/index.js +0 -8
- package/src/--reactivity-deprecated/hooks/todo.md +0 -26
- package/src/--reactivity-deprecated/idea +0 -1
- package/src/--reactivity-deprecated/index.js +0 -3
- package/src/--reactivity-deprecated/observer/attributes.js +0 -28
- package/src/--reactivity-deprecated/observer/children.js +0 -37
- package/src/--reactivity-deprecated/observer/index.js +0 -6
- package/src/--reactivity-deprecated/observer/intersection.js +0 -44
- package/src/--reactivity-deprecated/observer/mutation.js +0 -113
- package/src/--reactivity-deprecated/observer/resize.js +0 -47
- package/src/--reactivity-deprecated/observer/screen.js +0 -45
- package/src/--reactivity-deprecated/observer/screen.js.txt +0 -84
- package/src/--reactivity-deprecated/observer/screen.txt +0 -13
- package/src/--use-deprecated/index.js +0 -11
- package/src/--use-deprecated/use-channel.js.txt +0 -61
- package/src/--use-deprecated/use-event-emmiter.js.txt +0 -64
- package/src/--use-deprecated/use-favicon.js +0 -0
- package/src/--use-deprecated/use-link.js +0 -0
- package/src/--use-deprecated/use-meta.js +0 -0
- package/src/--use-deprecated/use-root.js +0 -77
- package/src/--use-deprecated/use-storage.js.txt +0 -73
- package/src/--use-deprecated/use-thread.js +0 -44
- package/src/--use-deprecated/use-title.js +0 -0
- package/src/ui/constructors/_m.js.txt +0 -96
- package/src/ui/constructors/style/index.js +0 -506
- /package/src/ui/{__methods__ → constructors/mixins}/attrs.js +0 -0
- /package/src/ui/{__methods__ → constructors/mixins}/index.js +0 -0
- /package/src/ui/{__methods__ → constructors/mixins}/indexing.js +0 -0
- /package/src/ui/{__methods__ → constructors/mixins}/lifecycle.js +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare class UseEventEmitter {
|
|
2
|
+
constructor(maxListeners?: number);
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Register and listen for an event.
|
|
6
|
+
* The listener will be called every time the event is emitted.
|
|
7
|
+
*/
|
|
8
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Register and listen for an event ONCE.
|
|
12
|
+
* After the first call, the listener is automatically removed.
|
|
13
|
+
*/
|
|
14
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Remove a specific listener.
|
|
18
|
+
*/
|
|
19
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Emit an event and call all listeners associated with it.
|
|
23
|
+
* Returns true if the event had listeners; otherwise false.
|
|
24
|
+
*/
|
|
25
|
+
emit(event: string, data?: any): boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Remove all listeners for a specific event.
|
|
29
|
+
*/
|
|
30
|
+
remove(event: string): this;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Clear all events and their listeners.
|
|
34
|
+
*/
|
|
35
|
+
clear(): this;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set the maximum number of listeners allowed per event.
|
|
39
|
+
*/
|
|
40
|
+
setMaxListeners(max: number): this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Create a new event emitter instance */
|
|
44
|
+
declare const useEventEmitter: (maxListeners?: number) => UseEventEmitter;
|
|
45
|
+
|
|
46
|
+
export { UseEventEmitter, useEventEmitter };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare class UseFavIcon {
|
|
2
|
+
/**
|
|
3
|
+
* Create a favicon manager.
|
|
4
|
+
* @param FavIcon Initial favicon URL.
|
|
5
|
+
* @param withEmitter Whether to enable an internal event emitter (default: true).
|
|
6
|
+
*/
|
|
7
|
+
constructor(FavIcon?: string, withEmitter?: boolean);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sets the favicon URL.
|
|
11
|
+
* Emits "ziko:favicon-changed" if emitter is enabled.
|
|
12
|
+
*/
|
|
13
|
+
setFavicon(href: string): this;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current favicon URL.
|
|
17
|
+
*/
|
|
18
|
+
readonly current: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Listen for favicon changes.
|
|
22
|
+
* Callback receives the new href as a string.
|
|
23
|
+
*/
|
|
24
|
+
onChange(callback: (href: string) => void): this;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* To Do
|
|
28
|
+
* Disable or remove the internal event emitter entirely.
|
|
29
|
+
*/
|
|
30
|
+
removeEventEmitter(): this;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Enable the internal event emitter manually.
|
|
34
|
+
*/
|
|
35
|
+
useEventEmitter(): this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Factory function to create a `UseFavIcon` instance.
|
|
40
|
+
*/
|
|
41
|
+
export declare const useFavIcon: (FavIcon?: string, withEmitter?: boolean) => UseFavIcon;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class UseIPC {
|
|
2
|
+
emit(event: string, data: any, rooms?: string[]): this;
|
|
3
|
+
on(event: string, handler: (data: any) => void, rooms?: string | string[]): this;
|
|
4
|
+
off(event: string, handler: (data: any) => void): this;
|
|
5
|
+
once(event: string, handler: (data: any) => void, rooms?: string | string[]): this;
|
|
6
|
+
join(...rooms: string[]): this;
|
|
7
|
+
leave(...rooms: string[]): this;
|
|
8
|
+
close(): this;
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export declare const useIPC: (name?: string) => UseIPC;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface MediaQueryRule {
|
|
2
|
+
query: string;
|
|
3
|
+
callback: () => void;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class UseMediaQuery {
|
|
7
|
+
// Private fields (only for type awareness; not accessible)
|
|
8
|
+
private readonly #mediaQueryRules: MediaQueryRule[];
|
|
9
|
+
private readonly #fallback: () => void;
|
|
10
|
+
private #lastCalledCallback: (() => void) | null;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
mediaQueryRules?: MediaQueryRule[],
|
|
14
|
+
fallback?: () => void
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Helper function to create a UseMediaQuery instance.
|
|
20
|
+
*/
|
|
21
|
+
export function useMediaQuery(
|
|
22
|
+
mediaQueryRules?: MediaQueryRule[],
|
|
23
|
+
fallback?: () => void
|
|
24
|
+
): UseMediaQuery;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mapfun, MapfunResult } from "../math/utils/mapfun.d.ts";
|
|
2
|
+
import { useState } from "./use-state.d.ts";
|
|
3
|
+
|
|
4
|
+
export function useReactive<
|
|
5
|
+
T
|
|
6
|
+
>(
|
|
7
|
+
nested_value: T
|
|
8
|
+
): MapfunResult<
|
|
9
|
+
(n: any) => {
|
|
10
|
+
get: ReturnType<typeof useState<any>>[0];
|
|
11
|
+
set: ReturnType<typeof useState<any>>[1];
|
|
12
|
+
},
|
|
13
|
+
T
|
|
14
|
+
>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class UseRoot<PropMap extends Record<string, string>> {
|
|
2
|
+
constructor(PropsMap: PropMap, options?: UseRootOptions);
|
|
3
|
+
|
|
4
|
+
currentPropsMap: PropMap;
|
|
5
|
+
namespace: string;
|
|
6
|
+
ValidateCssProps: boolean;
|
|
7
|
+
|
|
8
|
+
/** Dynamically created CSS variable references */
|
|
9
|
+
[K in keyof PropMap]: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Apply a new set of properties
|
|
13
|
+
*/
|
|
14
|
+
use(PropsMap: PropMap): this;
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function useState<T>(
|
|
2
|
+
initialValue: T
|
|
3
|
+
): [
|
|
4
|
+
/** getter function */
|
|
5
|
+
() => {
|
|
6
|
+
value: T;
|
|
7
|
+
isStateGetter: () => true;
|
|
8
|
+
_subscribe: (fn: (value: T) => void) => void;
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
/** setter function */
|
|
12
|
+
(newValue: T | ((prev: T) => T)) => void,
|
|
13
|
+
|
|
14
|
+
/** controller */
|
|
15
|
+
{
|
|
16
|
+
pause: () => void;
|
|
17
|
+
resume: () => void;
|
|
18
|
+
clear: () => void;
|
|
19
|
+
force: (newValue: T | ((prev: T) => T)) => void;
|
|
20
|
+
getSubscribers: () => Set<(value: T) => void>;
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/** check if argument is a state getter */
|
|
25
|
+
export function isStateGetter(arg: any): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// use-storage.d.ts
|
|
2
|
+
|
|
3
|
+
export declare class UseStorage {
|
|
4
|
+
constructor(
|
|
5
|
+
storage: Storage,
|
|
6
|
+
globalKey: string,
|
|
7
|
+
initialValue?: Record<string, any>,
|
|
8
|
+
use_channel?: boolean
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
/** Current stored items */
|
|
12
|
+
readonly items: Record<string, any>;
|
|
13
|
+
|
|
14
|
+
/** Set entire storage */
|
|
15
|
+
set(data: Record<string, any>): this;
|
|
16
|
+
|
|
17
|
+
/** Merge new data into existing storage */
|
|
18
|
+
add(data: Record<string, any>): this;
|
|
19
|
+
|
|
20
|
+
/** Remove keys from storage */
|
|
21
|
+
remove(...keys: string[]): this;
|
|
22
|
+
|
|
23
|
+
/** Get a single key */
|
|
24
|
+
get(key: string): any;
|
|
25
|
+
|
|
26
|
+
/** Clear storage completely */
|
|
27
|
+
clear(): this;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Listen for any storage updates.
|
|
31
|
+
* Callback receives the data passed to the last .set() / .add() / .remove()
|
|
32
|
+
*/
|
|
33
|
+
onStorageUpdated(callback: (data: Record<string, any>) => void): this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Factory functions */
|
|
37
|
+
export declare const useLocaleStorage: (
|
|
38
|
+
key: string,
|
|
39
|
+
initialValue?: Record<string, any>,
|
|
40
|
+
use_channel?: boolean
|
|
41
|
+
) => UseStorage;
|
|
42
|
+
|
|
43
|
+
export declare const useSessionStorage: (
|
|
44
|
+
key: string,
|
|
45
|
+
initialValue?: Record<string, any>,
|
|
46
|
+
use_channel?: boolean
|
|
47
|
+
) => UseStorage;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// use-thread.d.ts
|
|
2
|
+
|
|
3
|
+
export declare class UseThread {
|
|
4
|
+
constructor();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Call a function inside the worker.
|
|
8
|
+
* @param func - Function to execute (cannot capture outer scope)
|
|
9
|
+
* @param callback - Callback receiving (result, error)
|
|
10
|
+
* @param args - Optional arguments array to pass to the function
|
|
11
|
+
* @param close - Automatically close the worker after execution (default true)
|
|
12
|
+
*/
|
|
13
|
+
call<T = any>(
|
|
14
|
+
func: (...args: any[]) => T,
|
|
15
|
+
callback: (result: T | null, error: string | null) => void,
|
|
16
|
+
args?: any[],
|
|
17
|
+
close?: boolean
|
|
18
|
+
): this;
|
|
19
|
+
|
|
20
|
+
/** Terminate the worker manually */
|
|
21
|
+
terminate(): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Helper function for single-use worker threads.
|
|
26
|
+
* Immediately executes the function and returns the UseThread instance.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useThread: <T = any>(
|
|
29
|
+
func: (...args: any[]) => T,
|
|
30
|
+
callback: (result: T | null, error: string | null) => void,
|
|
31
|
+
args?: any[],
|
|
32
|
+
close?: boolean
|
|
33
|
+
) => UseThread;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare class UseTitle {
|
|
2
|
+
/**
|
|
3
|
+
* Create a reactive title manager.
|
|
4
|
+
* @param title Initial title. Defaults to `document.title`.
|
|
5
|
+
* @param withEmitter Whether to create an internal event emitter. Default: true.
|
|
6
|
+
*/
|
|
7
|
+
constructor(title?: string, withEmitter?: boolean);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Enables the internal event emitter.
|
|
11
|
+
*/
|
|
12
|
+
useEventEmitter(): this;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sets the document title.
|
|
16
|
+
* Emits "ziko:title-changed" if emitter is enabled.
|
|
17
|
+
*/
|
|
18
|
+
setTitle(title: string): this;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the current document title.
|
|
22
|
+
*/
|
|
23
|
+
readonly current: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Listen for title changes.
|
|
27
|
+
*/
|
|
28
|
+
onChange(callback: (title: string) => void): this;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* To Do
|
|
32
|
+
* Disable or remove the internal event emitter entirely.
|
|
33
|
+
*/
|
|
34
|
+
removeEventEmitter(): this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export declare const useTitle: (title?: string, withEmitter?: boolean) => UseTitle;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare class Complex {
|
|
2
|
+
a: number;
|
|
3
|
+
b: number;
|
|
4
|
+
|
|
5
|
+
constructor(a?: number, b?: number);
|
|
6
|
+
constructor(c: Complex);
|
|
7
|
+
constructor(a:
|
|
8
|
+
{ a: number; b: number } |
|
|
9
|
+
{ a: number; z: number } |
|
|
10
|
+
{ a: number; phi: number } |
|
|
11
|
+
{ b: number; z: number } |
|
|
12
|
+
{ b: number; phi: number } |
|
|
13
|
+
{ z: number; phi: number }
|
|
14
|
+
);
|
|
15
|
+
constructor();
|
|
16
|
+
|
|
17
|
+
isComplex(): true;
|
|
18
|
+
toString(): string;
|
|
19
|
+
readonly __mapfun__ : boolean
|
|
20
|
+
readonly clone: Complex;
|
|
21
|
+
readonly z: number;
|
|
22
|
+
readonly phi: number;
|
|
23
|
+
readonly conj: Complex;
|
|
24
|
+
readonly inv: Complex;
|
|
25
|
+
readonly sqrt: Complex;
|
|
26
|
+
readonly cbrt: Complex;
|
|
27
|
+
readonly log: Complex;
|
|
28
|
+
readonly cos: Complex;
|
|
29
|
+
readonly sin: Complex;
|
|
30
|
+
readonly tan: Complex;
|
|
31
|
+
expo: [number, number];
|
|
32
|
+
|
|
33
|
+
add(...z: (number | Complex)[]): this;
|
|
34
|
+
sub(...z: (number | Complex)[]): this;
|
|
35
|
+
mul(...z: (number | Complex)[]): this;
|
|
36
|
+
div(...z: (number | Complex)[]): this;
|
|
37
|
+
pow(n: number): this;
|
|
38
|
+
nthr(n?: number): Complex;
|
|
39
|
+
|
|
40
|
+
static zero(): Complex;
|
|
41
|
+
static twiddle(K : number, N : number): Complex;
|
|
42
|
+
static fromPolar(z: number, phi: number): Complex;
|
|
43
|
+
|
|
44
|
+
static add(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
45
|
+
static sub(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
46
|
+
static mul(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
47
|
+
static div(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
48
|
+
static pow(c: Complex, n: number): Complex;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export declare function complex(a: number, b?: number): Complex;
|
|
52
|
+
export declare function complex(a: Complex): Complex;
|
|
53
|
+
export declare function complex(a: object): Complex;
|
|
54
|
+
export declare function complex(): Complex;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { Complex } from "../complex/index.js";
|
|
2
|
+
import type { MapfunResult, Mappable } from "../utils/mapfun.js";
|
|
3
|
+
|
|
4
|
+
/* -------------------- MapfunWrap -------------------- */
|
|
5
|
+
|
|
6
|
+
type MapfunWrap<F extends (x: any) => any, A extends Mappable[]> =
|
|
7
|
+
A["length"] extends 1
|
|
8
|
+
? MapfunResult<F, A[0]>
|
|
9
|
+
: { [K in keyof A]: MapfunResult<F, A[K]> };
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/* -------------------- mapfun-based simple operators -------------------- */
|
|
13
|
+
|
|
14
|
+
export declare function abs<A extends Mappable[]>(...x: A):
|
|
15
|
+
MapfunWrap<typeof Math.abs, A>;
|
|
16
|
+
|
|
17
|
+
export declare function sqrt<A extends Mappable[]>(...x: A):
|
|
18
|
+
MapfunWrap<typeof Math.sqrt, A>;
|
|
19
|
+
|
|
20
|
+
export declare function e<A extends Mappable[]>(...x: A):
|
|
21
|
+
MapfunWrap<typeof Math.exp, A>;
|
|
22
|
+
|
|
23
|
+
export declare function ln<A extends Mappable[]>(...x: A):
|
|
24
|
+
MapfunWrap<typeof Math.log, A>;
|
|
25
|
+
|
|
26
|
+
/* ---- Fixed-based operators ---- */
|
|
27
|
+
|
|
28
|
+
export declare function cos<A extends Mappable[]>(...x: A):
|
|
29
|
+
MapfunWrap<typeof Math.cos, A>;
|
|
30
|
+
|
|
31
|
+
export declare function sin<A extends Mappable[]>(...x: A):
|
|
32
|
+
MapfunWrap<Math.sin, A>;
|
|
33
|
+
|
|
34
|
+
export declare function tan<A extends Mappable[]>(...x: A):
|
|
35
|
+
MapfunWrap<Math.tan, A>;
|
|
36
|
+
|
|
37
|
+
export declare function sec<A extends Mappable[]>(...x: A):
|
|
38
|
+
MapfunWrap<Math.sec, A>;
|
|
39
|
+
|
|
40
|
+
export declare function sinc<A extends Mappable[]>(...x: A):
|
|
41
|
+
MapfunWrap<Math.sinc, A>;
|
|
42
|
+
|
|
43
|
+
export declare function csc<A extends Mappable[]>(...x: A):
|
|
44
|
+
MapfunWrap<Math.csc, A>;
|
|
45
|
+
|
|
46
|
+
export declare function cot<A extends Mappable[]>(...x: A):
|
|
47
|
+
MapfunWrap<Math.cot, A>;
|
|
48
|
+
|
|
49
|
+
export declare function acos<A extends Mappable[]>(...x: A):
|
|
50
|
+
MapfunWrap<Math.acos, A>;
|
|
51
|
+
|
|
52
|
+
export declare function asin<A extends Mappable[]>(...x: A):
|
|
53
|
+
MapfunWrap<Math.asin, A>;
|
|
54
|
+
|
|
55
|
+
export declare function atan<A extends Mappable[]>(...x: A):
|
|
56
|
+
MapfunWrap<Math.atan, A>;
|
|
57
|
+
|
|
58
|
+
export declare function acot<A extends Mappable[]>(...x: A):
|
|
59
|
+
MapfunWrap<Math.acot, A>;
|
|
60
|
+
|
|
61
|
+
export declare function cosh<A extends Mappable[]>(...x: A):
|
|
62
|
+
MapfunWrap<Math.cosh, A>;
|
|
63
|
+
|
|
64
|
+
export declare function sinh<A extends Mappable[]>(...x: A):
|
|
65
|
+
MapfunWrap<Math.sinh, A>;
|
|
66
|
+
|
|
67
|
+
export declare function tanh<A extends Mappable[]>(...x: A):
|
|
68
|
+
MapfunWrap<Math.tanh, A>;
|
|
69
|
+
|
|
70
|
+
export declare function coth<A extends Mappable[]>(...x: A):
|
|
71
|
+
MapfunWrap<Math.coth, A>;
|
|
72
|
+
|
|
73
|
+
export declare function acosh<A extends Mappable[]>(...x: A):
|
|
74
|
+
MapfunWrap<Math.acosh, A>;
|
|
75
|
+
|
|
76
|
+
export declare function asinh<A extends Mappable[]>(...x: A):
|
|
77
|
+
MapfunWrap<Math.asinh, A>;
|
|
78
|
+
|
|
79
|
+
export declare function atanh<A extends Mappable[]>(...x: A):
|
|
80
|
+
MapfunWrap<Math.atanh, A>;
|
|
81
|
+
|
|
82
|
+
/* ---- Math wrappers ---- */
|
|
83
|
+
|
|
84
|
+
export declare function ceil<A extends Mappable[]>(...x: A):
|
|
85
|
+
MapfunWrap<typeof Math.ceil, A>;
|
|
86
|
+
|
|
87
|
+
export declare function floor<A extends Mappable[]>(...x: A):
|
|
88
|
+
MapfunWrap<typeof Math.floor, A>;
|
|
89
|
+
|
|
90
|
+
export declare function round<A extends Mappable[]>(...x: A):
|
|
91
|
+
MapfunWrap<typeof Math.round, A>;
|
|
92
|
+
|
|
93
|
+
export declare function sign<A extends Mappable[]>(...x: A):
|
|
94
|
+
MapfunWrap<typeof Math.sign, A>;
|
|
95
|
+
|
|
96
|
+
export declare function sig<A extends Mappable[]>(...x: A):
|
|
97
|
+
MapfunWrap<(n: number) => number, A>;
|
|
98
|
+
|
|
99
|
+
export declare function fact<A extends Mappable[]>(...x: A):
|
|
100
|
+
MapfunWrap<(n: number) => number, A>;
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/* -------------------- pow -------------------- */
|
|
104
|
+
|
|
105
|
+
export declare function pow(x: number, n: number): number;
|
|
106
|
+
export declare function pow(x: number, n: Complex): Complex;
|
|
107
|
+
export declare function pow(x: number, n: Mappable): any;
|
|
108
|
+
|
|
109
|
+
export declare function pow(x: Complex, n: number): Complex;
|
|
110
|
+
export declare function pow(x: Complex, n: Complex): Complex;
|
|
111
|
+
export declare function pow(x: Complex, n: Mappable): any;
|
|
112
|
+
|
|
113
|
+
export declare function pow(x: Mappable[], n: number): any[];
|
|
114
|
+
export declare function pow(x: Mappable[], n: Mappable[]): any[];
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
/* -------------------- sqrtn -------------------- */
|
|
118
|
+
|
|
119
|
+
export declare function sqrtn(x: number, n: number): number;
|
|
120
|
+
export declare function sqrtn(x: number, n: Mappable): any;
|
|
121
|
+
|
|
122
|
+
export declare function sqrtn(x: Complex, n: number): Complex;
|
|
123
|
+
export declare function sqrtn(x: Complex, n: Mappable): any;
|
|
124
|
+
|
|
125
|
+
export declare function sqrtn(x: Mappable[], n: number): any[];
|
|
126
|
+
export declare function sqrtn(x: Mappable[], n: Mappable[]): any[];
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/* -------------------- atan2 -------------------- */
|
|
130
|
+
|
|
131
|
+
export declare function atan2(x: number, y: number, rad?: boolean): number;
|
|
132
|
+
export declare function atan2(x: number, y: Mappable, rad?: boolean): any;
|
|
133
|
+
export declare function atan2(x: Mappable, y: number, rad?: boolean): any;
|
|
134
|
+
export declare function atan2(x: Mappable[], y: Mappable[], rad?: boolean): any[];
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
/* -------------------- hypot -------------------- */
|
|
138
|
+
|
|
139
|
+
export declare function hypot(...x: number[]): number;
|
|
140
|
+
export declare function hypot(...x: Mappable[]): any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Complex } from "../../complex/index.d.ts";
|
|
2
|
+
// import type { Matrix } from "../../matrix/index.d.ts";
|
|
3
|
+
import { Matrix } from '../../../../src/math/matrix/index.js'
|
|
4
|
+
|
|
5
|
+
export declare const not: (x: 0 | 1 | Complex | Matrix) => 0 | 1 | Complex | Matrix;
|
|
6
|
+
export declare const and: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
|
|
7
|
+
export declare const or: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
|
|
8
|
+
export declare const xor: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
|
|
9
|
+
export declare const nand: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
|
|
10
|
+
export declare const nor: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
|
|
11
|
+
export declare const xnor: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
|
|
@@ -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]> }>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './mapfun'
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Matrix } from "../matrix/index.js";
|
|
2
|
+
import type { Complex } from "../complex/index.js";
|
|
3
|
+
|
|
4
|
+
export type Mappable =
|
|
5
|
+
| number
|
|
6
|
+
| string
|
|
7
|
+
| boolean
|
|
8
|
+
| bigint
|
|
9
|
+
| undefined
|
|
10
|
+
| null
|
|
11
|
+
| Complex
|
|
12
|
+
| Matrix
|
|
13
|
+
| object
|
|
14
|
+
| any[]
|
|
15
|
+
| Set<any>
|
|
16
|
+
| Map<any, any>;
|
|
17
|
+
|
|
18
|
+
export type MapfunResult<F, T> =
|
|
19
|
+
T extends Complex ? ReturnType<F> :
|
|
20
|
+
// T extends Matrix ? Matrix :
|
|
21
|
+
T extends Array<infer U> ? Array<MapfunResult<F, U>> :
|
|
22
|
+
T extends Set<infer U> ? Set<MapfunResult<F, U>> :
|
|
23
|
+
T extends Map<infer K, infer V> ? Map<K, MapfunResult<F, V>> :
|
|
24
|
+
T extends object ? { [K in keyof T]: MapfunResult<F, T[K]> } :
|
|
25
|
+
ReturnType<F>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Helper to unwrap single-element tuple
|
|
29
|
+
*/
|
|
30
|
+
type UnwrapSingle<T extends unknown[]> = T extends [infer U] ? U : { [K in keyof T]: T[K] };
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* mapfun:
|
|
34
|
+
* - if multiple values → return tuple
|
|
35
|
+
* - if single value → return mapped value directly
|
|
36
|
+
*/
|
|
37
|
+
export declare function mapfun<
|
|
38
|
+
F extends (x: any) => any,
|
|
39
|
+
A extends Mappable[]
|
|
40
|
+
>(
|
|
41
|
+
fun: F,
|
|
42
|
+
...values: A
|
|
43
|
+
): UnwrapSingle<{ [K in keyof A]: MapfunResult<F, A[K]> }>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Tick } from "./tick.js";
|
|
2
|
+
|
|
3
|
+
export interface ClockTickEvent {
|
|
4
|
+
elapsed: number;
|
|
5
|
+
delta: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare class Clock extends Tick {
|
|
9
|
+
elapsed: number;
|
|
10
|
+
protected _lastTime: number;
|
|
11
|
+
protected _callbacks: Set<(ev: ClockTickEvent) => void>;
|
|
12
|
+
|
|
13
|
+
constructor(tickMs?: number);
|
|
14
|
+
|
|
15
|
+
protected _tick(): void;
|
|
16
|
+
|
|
17
|
+
onTick(
|
|
18
|
+
cb: (ev: ClockTickEvent) => void
|
|
19
|
+
): () => boolean;
|
|
20
|
+
|
|
21
|
+
reset(): void;
|
|
22
|
+
|
|
23
|
+
pause(): void;
|
|
24
|
+
|
|
25
|
+
resume(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare function clock(tickMs?: number): Clock;
|