@fynixorg/ui 1.0.8 → 1.0.10
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/plugins/vite-plugin-res.js +17 -80
- package/dist/plugins/vite-plugin-res.js.map +2 -2
- package/package.json +3 -2
- package/runtime.d.ts +83 -0
- package/dist/build.d.ts +0 -1
- package/dist/context/context.d.ts +0 -99
- package/dist/custom/Outlet.d.ts +0 -0
- package/dist/custom/button.d.ts +0 -62
- package/dist/custom/index.d.ts +0 -2
- package/dist/custom/path.d.ts +0 -71
- package/dist/error/errorOverlay.d.ts +0 -26
- package/dist/fynix/index.d.ts +0 -4
- package/dist/hooks/nixAsync.d.ts +0 -13
- package/dist/hooks/nixAsyncCache.d.ts +0 -7
- package/dist/hooks/nixAsyncDebounce.d.ts +0 -28
- package/dist/hooks/nixAsyncQuery.d.ts +0 -40
- package/dist/hooks/nixCallback.d.ts +0 -30
- package/dist/hooks/nixComputed.d.ts +0 -93
- package/dist/hooks/nixDebounce.d.ts +0 -32
- package/dist/hooks/nixEffect.d.ts +0 -64
- package/dist/hooks/nixForm.d.ts +0 -15
- package/dist/hooks/nixFormAsync.d.ts +0 -20
- package/dist/hooks/nixInterval.d.ts +0 -26
- package/dist/hooks/nixLazy.d.ts +0 -19
- package/dist/hooks/nixLazyAsync.d.ts +0 -26
- package/dist/hooks/nixLazyFormAsync.d.ts +0 -29
- package/dist/hooks/nixLocalStorage.d.ts +0 -22
- package/dist/hooks/nixMemo.d.ts +0 -8
- package/dist/hooks/nixPrevious.d.ts +0 -18
- package/dist/hooks/nixRef.d.ts +0 -10
- package/dist/hooks/nixState.d.ts +0 -73
- package/dist/hooks/nixStore.d.ts +0 -9
- package/dist/plugins/vite-plugin-res.d.ts +0 -16
- package/dist/router/router.d.ts +0 -53
- package/dist/runtime.d.ts +0 -91
|
@@ -2,89 +2,29 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { transform } from "esbuild";
|
|
4
4
|
function fynix() {
|
|
5
|
-
const failedFiles = /* @__PURE__ */ new Set();
|
|
6
|
-
const COMPILE_SUCCESS_COLOR = "\x1B[32m";
|
|
7
|
-
const COMPILE_ERROR_COLOR = "\x1B[31m";
|
|
8
|
-
const RESET_COLOR = "\x1B[0m";
|
|
9
|
-
const BOLD = "\x1B[1m";
|
|
10
5
|
return {
|
|
11
|
-
name: "vite-plugin-
|
|
6
|
+
name: "vite-plugin-res",
|
|
12
7
|
enforce: "pre",
|
|
13
8
|
async transform(code, id) {
|
|
14
|
-
if (
|
|
9
|
+
if (!id.includes("/src/"))
|
|
15
10
|
return null;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
console.log(
|
|
31
|
-
`${COMPILE_SUCCESS_COLOR}\u2713${RESET_COLOR} ${BOLD}${fileName}${RESET_COLOR} ${COMPILE_SUCCESS_COLOR}compiled successfully!${RESET_COLOR} ${timestamp}`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
code: result.code,
|
|
36
|
-
map: result.map
|
|
37
|
-
};
|
|
38
|
-
} catch (error) {
|
|
39
|
-
failedFiles.add(id);
|
|
40
|
-
const lines = code.split("\n");
|
|
41
|
-
const errorLine = error.location?.line || 1;
|
|
42
|
-
const errorColumn = error.location?.column || 0;
|
|
43
|
-
const start = Math.max(0, errorLine - 4);
|
|
44
|
-
const end = Math.min(lines.length, errorLine + 3);
|
|
45
|
-
const codeFrame = lines.slice(start, end).map((line, i) => {
|
|
46
|
-
const lineNum = start + i + 1;
|
|
47
|
-
const isErrorLine = lineNum === errorLine;
|
|
48
|
-
const prefix = isErrorLine ? "> " : " ";
|
|
49
|
-
const formattedLine = `${prefix}${lineNum.toString().padStart(4)} | ${line}`;
|
|
50
|
-
if (isErrorLine && errorColumn > 0) {
|
|
51
|
-
const pointer = " ".repeat(prefix.length + 6 + errorColumn) + "^";
|
|
52
|
-
return `${formattedLine}
|
|
53
|
-
${pointer}`;
|
|
54
|
-
}
|
|
55
|
-
return formattedLine;
|
|
56
|
-
}).join("\n");
|
|
57
|
-
const fileName = id.split("/").pop();
|
|
58
|
-
const errorMessage = `
|
|
59
|
-
${COMPILE_ERROR_COLOR}\u2717 Fynix Transform Error${RESET_COLOR} in ${BOLD}${fileName}${RESET_COLOR}
|
|
60
|
-
|
|
61
|
-
${error.text || error.message}
|
|
62
|
-
|
|
63
|
-
${codeFrame}
|
|
64
|
-
`.trim();
|
|
65
|
-
console.error(errorMessage);
|
|
66
|
-
const viteError = Object.assign(
|
|
67
|
-
new Error(error.text || error.message),
|
|
68
|
-
{
|
|
69
|
-
id,
|
|
70
|
-
plugin: "vite-plugin-fynix",
|
|
71
|
-
loc: {
|
|
72
|
-
file: id,
|
|
73
|
-
line: errorLine,
|
|
74
|
-
column: errorColumn
|
|
75
|
-
},
|
|
76
|
-
frame: codeFrame
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
this.error(viteError);
|
|
80
|
-
}
|
|
11
|
+
if (!id.endsWith(".ts") && !id.endsWith(".js") && !id.endsWith(".fnx"))
|
|
12
|
+
return null;
|
|
13
|
+
this.addWatchFile(id);
|
|
14
|
+
const result = await transform(code, {
|
|
15
|
+
loader: "jsx",
|
|
16
|
+
jsxFactory: "Fynix",
|
|
17
|
+
jsxFragment: "Fynix.Fragment",
|
|
18
|
+
sourcemap: true,
|
|
19
|
+
sourcefile: id
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
code: result.code,
|
|
23
|
+
map: result.map
|
|
24
|
+
};
|
|
81
25
|
},
|
|
82
26
|
handleHotUpdate({ file, server }) {
|
|
83
|
-
if (
|
|
84
|
-
server.ws.send({
|
|
85
|
-
type: "custom",
|
|
86
|
-
event: "fynix:clear-overlay"
|
|
87
|
-
});
|
|
27
|
+
if (file.endsWith(".ts") || file.endsWith(".js") || file.endsWith(".fnx")) {
|
|
88
28
|
server.ws.send({ type: "full-reload" });
|
|
89
29
|
return [];
|
|
90
30
|
}
|
|
@@ -92,7 +32,4 @@ ${codeFrame}
|
|
|
92
32
|
};
|
|
93
33
|
}
|
|
94
34
|
__name(fynix, "fynix");
|
|
95
|
-
export {
|
|
96
|
-
fynix
|
|
97
|
-
};
|
|
98
35
|
//# sourceMappingURL=vite-plugin-res.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../plugins/vite-plugin-res.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["import { transform } from \"esbuild\";\r\nfunction fynix() {\r\n return {\r\n name: \"vite-plugin-res\",\r\n enforce: \"pre\",\r\n async transform(code, id) {\r\n if (!id.includes(\"/src/\")) return null;\r\n if (!id.endsWith(\".ts\") && !id.endsWith(\".js\") && !id.endsWith(\".fnx\"))\r\n return null;\r\n this.addWatchFile(id);\r\n const result = await transform(code, {\r\n loader: \"jsx\",\r\n jsxFactory: \"Fynix\",\r\n jsxFragment: \"Fynix.Fragment\",\r\n sourcemap: true,\r\n sourcefile: id,\r\n });\r\n return {\r\n code: result.code,\r\n map: result.map,\r\n };\r\n },\r\n handleHotUpdate({ file, server }) {\r\n if (\r\n file.endsWith(\".ts\") ||\r\n file.endsWith(\".js\") ||\r\n file.endsWith(\".fnx\")\r\n ) {\r\n server.ws.send({ type: \"full-reload\" });\r\n return [];\r\n }\r\n },\r\n };\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,iBAAiB;AAC1B,SAAS,QAAQ;AACf,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,UAAU,MAAM,IAAI;AACxB,UAAI,CAAC,GAAG,SAAS,OAAO;AAAG,eAAO;AAClC,UAAI,CAAC,GAAG,SAAS,KAAK,KAAK,CAAC,GAAG,SAAS,KAAK,KAAK,CAAC,GAAG,SAAS,MAAM;AACnE,eAAO;AACT,WAAK,aAAa,EAAE;AACpB,YAAM,SAAS,MAAM,UAAU,MAAM;AAAA,QACnC,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,aAAa;AAAA,QACb,WAAW;AAAA,QACX,YAAY;AAAA,MACd,CAAC;AACD,aAAO;AAAA,QACL,MAAM,OAAO;AAAA,QACb,KAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,IACA,gBAAgB,EAAE,MAAM,OAAO,GAAG;AAChC,UACE,KAAK,SAAS,KAAK,KACnB,KAAK,SAAS,KAAK,KACnB,KAAK,SAAS,MAAM,GACpB;AACA,eAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;AACtC,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAhCS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fynixorg/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core package for Fynix UI framework.",
|
|
6
6
|
"main": "dist/fynix/index.js",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"dist/",
|
|
43
|
-
"types/"
|
|
43
|
+
"types/",
|
|
44
|
+
"runtime.d.ts"
|
|
44
45
|
],
|
|
45
46
|
"keywords": [
|
|
46
47
|
"fynix",
|
package/runtime.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Type definitions for Fynix Runtime
|
|
2
|
+
// This file provides TypeScript support for the Fynix framework
|
|
3
|
+
|
|
4
|
+
/// <reference path="./types/jsx.d.ts" />
|
|
5
|
+
/// <reference path="./types/global.d.ts" />
|
|
6
|
+
|
|
7
|
+
export const TEXT: unique symbol;
|
|
8
|
+
export const Fragment: unique symbol;
|
|
9
|
+
|
|
10
|
+
export interface VNode {
|
|
11
|
+
type: string | symbol | ((props: any) => any);
|
|
12
|
+
props: Record<string, any>;
|
|
13
|
+
key: string | number | null;
|
|
14
|
+
_domNode?: Node;
|
|
15
|
+
_rendered?: VNode;
|
|
16
|
+
_state?: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type Element =
|
|
20
|
+
| VNode
|
|
21
|
+
| string
|
|
22
|
+
| number
|
|
23
|
+
| boolean
|
|
24
|
+
| null
|
|
25
|
+
| undefined
|
|
26
|
+
| Element[];
|
|
27
|
+
|
|
28
|
+
export type ComponentFunction<P = {}> = (props: P) => Element;
|
|
29
|
+
|
|
30
|
+
export function Fynix(
|
|
31
|
+
type: string | symbol | ComponentFunction,
|
|
32
|
+
props?: Record<string, any> | null,
|
|
33
|
+
...children: any[]
|
|
34
|
+
): VNode;
|
|
35
|
+
|
|
36
|
+
export namespace Fynix {
|
|
37
|
+
export function Fragment(props: { children?: any }): any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const h: typeof Fynix;
|
|
41
|
+
|
|
42
|
+
export function createTextVNode(text: string | number | any): VNode;
|
|
43
|
+
|
|
44
|
+
export function mount(
|
|
45
|
+
AppComponent: ComponentFunction,
|
|
46
|
+
root: string | Element,
|
|
47
|
+
hydrate?: boolean,
|
|
48
|
+
props?: Record<string, any>
|
|
49
|
+
): void;
|
|
50
|
+
|
|
51
|
+
export function renderComponent(
|
|
52
|
+
Component: ComponentFunction,
|
|
53
|
+
props?: Record<string, any>
|
|
54
|
+
): VNode;
|
|
55
|
+
|
|
56
|
+
// Hooks
|
|
57
|
+
export function nixState<T>(initialValue: T): any;
|
|
58
|
+
export function nixStore<T extends Record<string, any>>(initialState: T): any;
|
|
59
|
+
export function nixComputed<T>(fn: () => T): any;
|
|
60
|
+
export function nixRef<T = any>(initial?: T): { current: T };
|
|
61
|
+
export function nixEffect(fn: () => void | (() => void), deps?: any[]): void;
|
|
62
|
+
export function nixEffectAlways(fn: () => void | (() => void)): void;
|
|
63
|
+
export function nixEffectOnce(fn: () => void | (() => void)): void;
|
|
64
|
+
export function nixInterval(callback: () => void, delay: number): void;
|
|
65
|
+
export function nixMemo<T>(fn: () => T, deps?: any[]): T;
|
|
66
|
+
export function nixCallback<T extends (...args: any[]) => any>(fn: T, deps?: any[]): T;
|
|
67
|
+
export function nixPrevious<T>(value: T): T | undefined;
|
|
68
|
+
export function nixAsync<T>(fn: (signal: AbortSignal) => Promise<T>): any;
|
|
69
|
+
export function nixAsyncCached<T>(fn: () => Promise<T>, cacheKey?: string): any;
|
|
70
|
+
export function nixAsyncDebounce<T>(fn: () => Promise<T>, delay: number): any;
|
|
71
|
+
export function nixAsyncQuery<T>(queryKey: any, queryFn: () => Promise<T>, options?: any): any;
|
|
72
|
+
export function nixDebounce<T extends (...args: any[]) => any>(fn: T, delay: number): T;
|
|
73
|
+
export function nixLocalStorage<T>(key: string, initialValue: T): any;
|
|
74
|
+
export function nixLazy(loader: () => Promise<any>): any;
|
|
75
|
+
export function nixLazyAsync(loader: () => Promise<any>): any;
|
|
76
|
+
export function nixForm<T extends Record<string, any>>(initialValues: T, options?: any): any;
|
|
77
|
+
export function nixFormAsync<T extends Record<string, any>>(initialValues: T, options?: any): any;
|
|
78
|
+
export function nixLazyFormAsync<T extends Record<string, any>>(loader: () => Promise<any>, options?: any): any;
|
|
79
|
+
|
|
80
|
+
// Components
|
|
81
|
+
export const Suspense: any;
|
|
82
|
+
export const Path: any;
|
|
83
|
+
export const Button: any;
|
package/dist/build.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set the active component context.
|
|
3
|
-
* Called internally by the runtime when entering/exiting component rendering.
|
|
4
|
-
*
|
|
5
|
-
* @param {ComponentContext|null} ctx - The component context to set as active, or null to clear
|
|
6
|
-
* @returns {void}
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Internal usage in runtime
|
|
10
|
-
* setActiveContext(componentContext);
|
|
11
|
-
* const result = Component(props);
|
|
12
|
-
* setActiveContext(null);
|
|
13
|
-
*/
|
|
14
|
-
export function setActiveContext(ctx: ComponentContext | null): void;
|
|
15
|
-
/**
|
|
16
|
-
* @fileoverview Component context management for Fynix framework.
|
|
17
|
-
* Tracks the currently rendering component to enable hooks to access component state.
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {Object} ComponentContext
|
|
21
|
-
* @property {Array<any>} hooks - Array of hook states
|
|
22
|
-
* @property {number} hookIndex - Current hook index during render
|
|
23
|
-
* @property {Array<Function>} effects - Array of effect cleanup functions
|
|
24
|
-
* @property {Array<Function>} cleanups - Array of cleanup functions
|
|
25
|
-
* @property {Array<Function>} [stateCleanups] - Array of state cleanup functions
|
|
26
|
-
* @property {Object} _vnode - Associated virtual node
|
|
27
|
-
* @property {Set<any>} _accessedStates - Set of states accessed during render
|
|
28
|
-
* @property {Set<any>} _subscriptions - Set of active subscriptions
|
|
29
|
-
* @property {Array<Function>} _subscriptionCleanups - Array of subscription cleanup functions
|
|
30
|
-
* @property {number} version - Component version for tracking updates
|
|
31
|
-
* @property {Function|null} rerender - Function to trigger component re-render
|
|
32
|
-
* @property {Function} Component - Component function
|
|
33
|
-
* @property {boolean} _isMounted - Whether component is mounted
|
|
34
|
-
* @property {boolean} _isRerendering - Whether component is currently re-rendering
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* The currently active component context.
|
|
38
|
-
* This is set during component rendering to allow hooks to access the component's state.
|
|
39
|
-
* @type {ComponentContext|null}
|
|
40
|
-
*/
|
|
41
|
-
export let activeContext: ComponentContext | null;
|
|
42
|
-
export type ComponentContext = {
|
|
43
|
-
/**
|
|
44
|
-
* - Array of hook states
|
|
45
|
-
*/
|
|
46
|
-
hooks: Array<any>;
|
|
47
|
-
/**
|
|
48
|
-
* - Current hook index during render
|
|
49
|
-
*/
|
|
50
|
-
hookIndex: number;
|
|
51
|
-
/**
|
|
52
|
-
* - Array of effect cleanup functions
|
|
53
|
-
*/
|
|
54
|
-
effects: Array<Function>;
|
|
55
|
-
/**
|
|
56
|
-
* - Array of cleanup functions
|
|
57
|
-
*/
|
|
58
|
-
cleanups: Array<Function>;
|
|
59
|
-
/**
|
|
60
|
-
* - Array of state cleanup functions
|
|
61
|
-
*/
|
|
62
|
-
stateCleanups?: Array<Function>;
|
|
63
|
-
/**
|
|
64
|
-
* - Associated virtual node
|
|
65
|
-
*/
|
|
66
|
-
_vnode: any;
|
|
67
|
-
/**
|
|
68
|
-
* - Set of states accessed during render
|
|
69
|
-
*/
|
|
70
|
-
_accessedStates: Set<any>;
|
|
71
|
-
/**
|
|
72
|
-
* - Set of active subscriptions
|
|
73
|
-
*/
|
|
74
|
-
_subscriptions: Set<any>;
|
|
75
|
-
/**
|
|
76
|
-
* - Array of subscription cleanup functions
|
|
77
|
-
*/
|
|
78
|
-
_subscriptionCleanups: Array<Function>;
|
|
79
|
-
/**
|
|
80
|
-
* - Component version for tracking updates
|
|
81
|
-
*/
|
|
82
|
-
version: number;
|
|
83
|
-
/**
|
|
84
|
-
* - Function to trigger component re-render
|
|
85
|
-
*/
|
|
86
|
-
rerender: Function | null;
|
|
87
|
-
/**
|
|
88
|
-
* - Component function
|
|
89
|
-
*/
|
|
90
|
-
Component: Function;
|
|
91
|
-
/**
|
|
92
|
-
* - Whether component is mounted
|
|
93
|
-
*/
|
|
94
|
-
_isMounted: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* - Whether component is currently re-rendering
|
|
97
|
-
*/
|
|
98
|
-
_isRerendering: boolean;
|
|
99
|
-
};
|
package/dist/custom/Outlet.d.ts
DELETED
|
File without changes
|
package/dist/custom/button.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} ButtonProps
|
|
3
|
-
* @property {string} [value=""] - Button text content
|
|
4
|
-
* @property {string} [type="button"] - Button type (button, submit, reset)
|
|
5
|
-
* @property {boolean} [disabled=false] - Whether button is disabled
|
|
6
|
-
* @property {string} [rc] - Reactive class attribute (Fynix-specific)
|
|
7
|
-
* @property {string} [class] - CSS class names
|
|
8
|
-
* @property {(this: HTMLElement, event: MouseEvent) => void} [r-click] - Click event handler
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Button component for Fynix applications.
|
|
12
|
-
* Renders a native HTML button element with Fynix event handling.
|
|
13
|
-
*
|
|
14
|
-
* @param {ButtonProps & Record<string, any>} props - Component props
|
|
15
|
-
* @returns {VNode} Button element virtual node
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Basic button
|
|
19
|
-
* <Button value="Click Me" />
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* // With click handler
|
|
23
|
-
* <Button
|
|
24
|
-
* value="Submit"
|
|
25
|
-
* r-click={() => console.log('Clicked!')}
|
|
26
|
-
* />
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // Submit button with styling
|
|
30
|
-
* <Button
|
|
31
|
-
* value="Save"
|
|
32
|
-
* type="submit"
|
|
33
|
-
* rc="px-4 py-2 bg-blue-500 text-white rounded"
|
|
34
|
-
* />
|
|
35
|
-
*/
|
|
36
|
-
export function Button({ value, ...props }: ButtonProps & Record<string, any>): VNode;
|
|
37
|
-
export type ButtonProps = {
|
|
38
|
-
/**
|
|
39
|
-
* - Button text content
|
|
40
|
-
*/
|
|
41
|
-
value?: string;
|
|
42
|
-
/**
|
|
43
|
-
* - Button type (button, submit, reset)
|
|
44
|
-
*/
|
|
45
|
-
type?: string;
|
|
46
|
-
/**
|
|
47
|
-
* - Whether button is disabled
|
|
48
|
-
*/
|
|
49
|
-
disabled?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* - Reactive class attribute (Fynix-specific)
|
|
52
|
-
*/
|
|
53
|
-
rc?: string;
|
|
54
|
-
/**
|
|
55
|
-
* - CSS class names
|
|
56
|
-
*/
|
|
57
|
-
class?: string;
|
|
58
|
-
/**
|
|
59
|
-
* - Click event handler
|
|
60
|
-
*/
|
|
61
|
-
"r-click"?: (this: HTMLElement, event: MouseEvent) => void;
|
|
62
|
-
};
|
package/dist/custom/index.d.ts
DELETED
package/dist/custom/path.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SPA navigation link component for Fynix router.
|
|
3
|
-
* Automatically handles client-side navigation and prop passing between routes.
|
|
4
|
-
*
|
|
5
|
-
* @param {PathProps & Record<string, any>} options - Component props
|
|
6
|
-
* @returns {VNode} Anchor element virtual node
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Basic navigation
|
|
10
|
-
* <Path to="/about" value="About Us" />
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // Navigate with props
|
|
14
|
-
* <Path
|
|
15
|
-
* to="/user/123"
|
|
16
|
-
* value="View Profile"
|
|
17
|
-
* props={{ userId: 123, fromSearch: true }}
|
|
18
|
-
* />
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // External link
|
|
22
|
-
* <Path
|
|
23
|
-
* to="https://github.com"
|
|
24
|
-
* value="GitHub"
|
|
25
|
-
* target="_blank"
|
|
26
|
-
* rel="noopener noreferrer"
|
|
27
|
-
* />
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // With styling
|
|
31
|
-
* <Path
|
|
32
|
-
* to="/dashboard"
|
|
33
|
-
* value="Dashboard"
|
|
34
|
-
* rc="px-4 py-2 bg-blue-500 text-white rounded"
|
|
35
|
-
* />
|
|
36
|
-
*/
|
|
37
|
-
export function Path({ to, value, props: routeProps, ...attrs }: PathProps & Record<string, any>): VNode;
|
|
38
|
-
export type PathProps = {
|
|
39
|
-
/**
|
|
40
|
-
* - URL to navigate to (relative or absolute)
|
|
41
|
-
*/
|
|
42
|
-
to?: string;
|
|
43
|
-
/**
|
|
44
|
-
* - Link text content
|
|
45
|
-
*/
|
|
46
|
-
value?: string;
|
|
47
|
-
/**
|
|
48
|
-
* - Props to pass to the destination route component
|
|
49
|
-
*/
|
|
50
|
-
props?: Record<string, any>;
|
|
51
|
-
/**
|
|
52
|
-
* - Link target (_blank, _self, etc.)
|
|
53
|
-
*/
|
|
54
|
-
target?: string;
|
|
55
|
-
/**
|
|
56
|
-
* - Link relationship (noopener, noreferrer, etc.)
|
|
57
|
-
*/
|
|
58
|
-
rel?: string;
|
|
59
|
-
/**
|
|
60
|
-
* - Reactive class attribute (Fynix-specific)
|
|
61
|
-
*/
|
|
62
|
-
rc?: string;
|
|
63
|
-
/**
|
|
64
|
-
* - CSS class names
|
|
65
|
-
*/
|
|
66
|
-
class?: string;
|
|
67
|
-
/**
|
|
68
|
-
* - Element ID
|
|
69
|
-
*/
|
|
70
|
-
id?: string;
|
|
71
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Development error overlay for Fynix applications.
|
|
3
|
-
* Displays runtime errors in a user-friendly overlay during development.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Display an error overlay with error details.
|
|
7
|
-
* Shows error message, stack trace, and a close button.
|
|
8
|
-
*
|
|
9
|
-
* @param {Error} error - The error object to display
|
|
10
|
-
* @returns {void}
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* try {
|
|
14
|
-
* // some code
|
|
15
|
-
* } catch (err) {
|
|
16
|
-
* showErrorOverlay(err);
|
|
17
|
-
* }
|
|
18
|
-
*/
|
|
19
|
-
export function showErrorOverlay(error: Error): void;
|
|
20
|
-
/**
|
|
21
|
-
* Remove the error overlay from the DOM.
|
|
22
|
-
* Fades out the overlay before removing it.
|
|
23
|
-
*
|
|
24
|
-
* @returns {void}
|
|
25
|
-
*/
|
|
26
|
-
export function removeErrorOverlay(): void;
|
package/dist/fynix/index.d.ts
DELETED
package/dist/hooks/nixAsync.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Async state helper with AbortController support.
|
|
3
|
-
*
|
|
4
|
-
* @template T
|
|
5
|
-
* @param {(signal: AbortSignal) => Promise<T>} promiseFactory
|
|
6
|
-
*/
|
|
7
|
-
export function nixAsync<T>(promiseFactory: (signal: AbortSignal) => Promise<T>): {
|
|
8
|
-
data: import("./nixState").NixState;
|
|
9
|
-
error: import("./nixState").NixState;
|
|
10
|
-
loading: import("./nixState").NixState;
|
|
11
|
-
run: () => Promise<void>;
|
|
12
|
-
cancel: () => void;
|
|
13
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Debounced and cancellable async data fetcher with caching and deduping.
|
|
3
|
-
*
|
|
4
|
-
* @param {() => Promise<any>} promiseFactory - Async function that returns a promise.
|
|
5
|
-
* @param {Object} [options={}] - Options for debounce, caching, and abort.
|
|
6
|
-
* @param {number} [options.delay=300] - Debounce delay in ms.
|
|
7
|
-
* @param {boolean} [options.leading=false] - Run on leading edge.
|
|
8
|
-
* @param {boolean} [options.trailing=true] - Run on trailing edge.
|
|
9
|
-
* @param {number} [options.maxWait] - Max wait time before forced invocation.
|
|
10
|
-
* @param {boolean} [options.cache=true] - Enable caching of last result.
|
|
11
|
-
* @param {AbortSignal} [options.signal] - Optional AbortSignal to cancel request.
|
|
12
|
-
* @returns {Object} { data, error, loading, run, cancel }
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const controller = new AbortController();
|
|
16
|
-
* const { data, error, loading, run, cancel } = nixAsyncDebounce(
|
|
17
|
-
* () => fetch('/api/data').then(r => r.json()),
|
|
18
|
-
* { delay: 500, maxWait: 2000, leading: true, signal: controller.signal }
|
|
19
|
-
* );
|
|
20
|
-
*/
|
|
21
|
-
export function nixAsyncDebounce(promiseFactory: () => Promise<any>, options?: {
|
|
22
|
-
delay?: number;
|
|
23
|
-
leading?: boolean;
|
|
24
|
-
trailing?: boolean;
|
|
25
|
-
maxWait?: number;
|
|
26
|
-
cache?: boolean;
|
|
27
|
-
signal?: AbortSignal;
|
|
28
|
-
}): any;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified async query helper with:
|
|
3
|
-
* - AbortController cancellation
|
|
4
|
-
* - Request deduping
|
|
5
|
-
* - Shared caching
|
|
6
|
-
*
|
|
7
|
-
* @template T
|
|
8
|
-
* @param {string} key
|
|
9
|
-
* Unique cache key representing the request
|
|
10
|
-
*
|
|
11
|
-
* @param {(signal: AbortSignal) => Promise<T>} queryFn
|
|
12
|
-
* Function that performs the async operation
|
|
13
|
-
*
|
|
14
|
-
* @param {{
|
|
15
|
-
* ttl?: number
|
|
16
|
-
* }} [options]
|
|
17
|
-
*
|
|
18
|
-
* @returns {{
|
|
19
|
-
* data: { value: T | null },
|
|
20
|
-
* error: { value: Error | null },
|
|
21
|
-
* loading: { value: boolean },
|
|
22
|
-
* run: () => Promise<void>,
|
|
23
|
-
* cancel: () => void
|
|
24
|
-
* }}
|
|
25
|
-
*/
|
|
26
|
-
export function nixAsyncQuery<T>(key: string, queryFn: (signal: AbortSignal) => Promise<T>, options?: {
|
|
27
|
-
ttl?: number;
|
|
28
|
-
}): {
|
|
29
|
-
data: {
|
|
30
|
-
value: T | null;
|
|
31
|
-
};
|
|
32
|
-
error: {
|
|
33
|
-
value: Error | null;
|
|
34
|
-
};
|
|
35
|
-
loading: {
|
|
36
|
-
value: boolean;
|
|
37
|
-
};
|
|
38
|
-
run: () => Promise<void>;
|
|
39
|
-
cancel: () => void;
|
|
40
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memoizes a callback function based on a dependency array.
|
|
3
|
-
* Similar to React's useCallback.
|
|
4
|
-
*
|
|
5
|
-
* @param {Function} fn
|
|
6
|
-
* Function to memoize. Should be pure and not mutate external state.
|
|
7
|
-
*
|
|
8
|
-
* @param {Array<any>} [deps=[]]
|
|
9
|
-
* Dependency array. Callback identity changes only when deps change.
|
|
10
|
-
*
|
|
11
|
-
* @returns {Function}
|
|
12
|
-
* Memoized callback function.
|
|
13
|
-
*
|
|
14
|
-
* @throws {Error}
|
|
15
|
-
* If called outside of a component context.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const onClick = nixCallback(() => {
|
|
19
|
-
* console.log(count.value);
|
|
20
|
-
* }, [count.value]);
|
|
21
|
-
*
|
|
22
|
-
* @security
|
|
23
|
-
* - Avoids JSON.stringify to prevent crashes on circular references
|
|
24
|
-
* - Limits dependency array size to prevent performance abuse
|
|
25
|
-
*
|
|
26
|
-
* @memory
|
|
27
|
-
* - Does not allocate large temporary strings
|
|
28
|
-
* - Reuses function reference when deps are unchanged
|
|
29
|
-
*/
|
|
30
|
-
export function nixCallback(fn: Function, deps?: Array<any>): Function;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template T
|
|
3
|
-
* @typedef {Object} ComputedState
|
|
4
|
-
* @property {T} value - Get the computed value (read-only)
|
|
5
|
-
* @property {(fn: (value: T) => void) => (() => void)} subscribe - Subscribe to computed value changes
|
|
6
|
-
* @property {() => void} cleanup - Cleanup all subscriptions and dependencies
|
|
7
|
-
* @property {() => number} getSubscriberCount - Get number of active subscribers (debugging)
|
|
8
|
-
* @property {() => number} getDependencyCount - Get number of tracked dependencies (debugging)
|
|
9
|
-
* @property {() => boolean} isDestroyed - Check if computed state has been destroyed
|
|
10
|
-
* @property {boolean} _isNixState - Internal flag (computed states behave like states)
|
|
11
|
-
* @property {boolean} _isComputed - Internal flag to identify computed states
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Create a derived/computed state from other states.
|
|
15
|
-
* Automatically tracks dependencies and updates when any dependency changes.
|
|
16
|
-
*
|
|
17
|
-
* @template T
|
|
18
|
-
* @param {() => T} computeFn - Function that computes the derived value
|
|
19
|
-
* @returns {ComputedState<T>} A reactive state object with the computed value
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const count = nixState(5);
|
|
23
|
-
* const doubled = nixComputed(() => count.value * 2);
|
|
24
|
-
* console.log(doubled.value); // 10
|
|
25
|
-
* count.value = 10;
|
|
26
|
-
* console.log(doubled.value); // 20
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // Multiple dependencies
|
|
30
|
-
* const a = nixState(5);
|
|
31
|
-
* const b = nixState(10);
|
|
32
|
-
* const sum = nixComputed(() => a.value + b.value);
|
|
33
|
-
* console.log(sum.value); // 15
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // Conditional dependencies
|
|
37
|
-
* const flag = nixState(true);
|
|
38
|
-
* const x = nixState(1);
|
|
39
|
-
* const y = nixState(2);
|
|
40
|
-
* const result = nixComputed(() => flag.value ? x.value : y.value);
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* // With cleanup
|
|
44
|
-
* const MyComponent = () => {
|
|
45
|
-
* const count = nixState(0);
|
|
46
|
-
* const doubled = nixComputed(() => count.value * 2);
|
|
47
|
-
*
|
|
48
|
-
* nixEffect(() => {
|
|
49
|
-
* return () => {
|
|
50
|
-
* doubled.cleanup();
|
|
51
|
-
* count.cleanup();
|
|
52
|
-
* };
|
|
53
|
-
* }, []);
|
|
54
|
-
* };
|
|
55
|
-
*
|
|
56
|
-
* @throws {Error} If called outside a component context
|
|
57
|
-
* @throws {TypeError} If computeFn is not a function
|
|
58
|
-
*/
|
|
59
|
-
export function nixComputed<T>(computeFn: () => T): ComputedState<T>;
|
|
60
|
-
export type ComputedState<T> = {
|
|
61
|
-
/**
|
|
62
|
-
* - Get the computed value (read-only)
|
|
63
|
-
*/
|
|
64
|
-
value: T;
|
|
65
|
-
/**
|
|
66
|
-
* - Subscribe to computed value changes
|
|
67
|
-
*/
|
|
68
|
-
subscribe: (fn: (value: T) => void) => (() => void);
|
|
69
|
-
/**
|
|
70
|
-
* - Cleanup all subscriptions and dependencies
|
|
71
|
-
*/
|
|
72
|
-
cleanup: () => void;
|
|
73
|
-
/**
|
|
74
|
-
* - Get number of active subscribers (debugging)
|
|
75
|
-
*/
|
|
76
|
-
getSubscriberCount: () => number;
|
|
77
|
-
/**
|
|
78
|
-
* - Get number of tracked dependencies (debugging)
|
|
79
|
-
*/
|
|
80
|
-
getDependencyCount: () => number;
|
|
81
|
-
/**
|
|
82
|
-
* - Check if computed state has been destroyed
|
|
83
|
-
*/
|
|
84
|
-
isDestroyed: () => boolean;
|
|
85
|
-
/**
|
|
86
|
-
* - Internal flag (computed states behave like states)
|
|
87
|
-
*/
|
|
88
|
-
_isNixState: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* - Internal flag to identify computed states
|
|
91
|
-
*/
|
|
92
|
-
_isComputed: boolean;
|
|
93
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Debounce utility function with advanced options.
|
|
3
|
-
* Supports leading/trailing edge invocation, maxWait, and AbortController.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Debounce a function with options for leading, trailing, maxWait, and AbortController support.
|
|
7
|
-
*
|
|
8
|
-
* @param {Function} fn - The function to debounce
|
|
9
|
-
* @param {number} [delay=300] - Delay in milliseconds
|
|
10
|
-
* @param {Object} [options={}] - Debounce options
|
|
11
|
-
* @param {boolean} [options.leading=false] - Invoke on the leading edge
|
|
12
|
-
* @param {boolean} [options.trailing=true] - Invoke on the trailing edge
|
|
13
|
-
* @param {number} [options.maxWait] - Maximum wait time before forced invocation
|
|
14
|
-
* @param {AbortSignal} [options.signal] - Optional AbortSignal to cancel pending calls
|
|
15
|
-
* @returns {Function} Debounced function with `.cancel()` method
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const controller = new AbortController();
|
|
19
|
-
* const debounced = nixDebounce(() => console.log('Hello'), 500, {
|
|
20
|
-
* leading: true,
|
|
21
|
-
* maxWait: 2000,
|
|
22
|
-
* signal: controller.signal
|
|
23
|
-
* });
|
|
24
|
-
* debounced();
|
|
25
|
-
* controller.abort(); // Cancel pending invocation
|
|
26
|
-
*/
|
|
27
|
-
export function nixDebounce(fn: Function, delay?: number, options?: {
|
|
28
|
-
leading?: boolean;
|
|
29
|
-
trailing?: boolean;
|
|
30
|
-
maxWait?: number;
|
|
31
|
-
signal?: AbortSignal;
|
|
32
|
-
}): Function;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execute side effects in a component with automatic cleanup.
|
|
3
|
-
* Similar to React's useEffect.
|
|
4
|
-
*
|
|
5
|
-
* @param {() => (void | (() => void))} effect - Effect function, optionally returns cleanup function
|
|
6
|
-
* @param {Array<any>} [deps=[]] - Dependency array. Effect re-runs when dependencies change.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Run once on mount
|
|
10
|
-
* nixEffect(() => {
|
|
11
|
-
* console.log('Component mounted');
|
|
12
|
-
* return () => console.log('Component unmounted');
|
|
13
|
-
* }, []);
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // Run when count changes
|
|
17
|
-
* const count = nixState(0);
|
|
18
|
-
* nixEffect(() => {
|
|
19
|
-
* console.log('Count is:', count.value);
|
|
20
|
-
* }, [count.value]);
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Timer with cleanup
|
|
24
|
-
* nixEffect(() => {
|
|
25
|
-
* const timer = setInterval(() => console.log('tick'), 1000);
|
|
26
|
-
* return () => clearInterval(timer);
|
|
27
|
-
* }, []);
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // Event listener with cleanup
|
|
31
|
-
* nixEffect(() => {
|
|
32
|
-
* const handler = (e) => console.log('clicked', e);
|
|
33
|
-
* document.addEventListener('click', handler);
|
|
34
|
-
* return () => document.removeEventListener('click', handler);
|
|
35
|
-
* }, []);
|
|
36
|
-
*
|
|
37
|
-
* @throws {Error} If called outside a component context
|
|
38
|
-
*/
|
|
39
|
-
export function nixEffect(effect: () => (void | (() => void)), deps?: Array<any>): void;
|
|
40
|
-
/**
|
|
41
|
-
* Run an effect only once on component mount.
|
|
42
|
-
* Convenience wrapper around nixEffect.
|
|
43
|
-
*
|
|
44
|
-
* @param {() => (void | (() => void))} effect - Effect function
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* nixEffectOnce(() => {
|
|
48
|
-
* console.log('Mounted');
|
|
49
|
-
* return () => console.log('Unmounted');
|
|
50
|
-
* });
|
|
51
|
-
*/
|
|
52
|
-
export function nixEffectOnce(effect: () => (void | (() => void))): void;
|
|
53
|
-
/**
|
|
54
|
-
* Run an effect every time the component renders.
|
|
55
|
-
* Use with caution - can cause performance issues.
|
|
56
|
-
*
|
|
57
|
-
* @param {() => (void | (() => void))} effect - Effect function
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* nixEffectAlways(() => {
|
|
61
|
-
* console.log('Component rendered');
|
|
62
|
-
* });
|
|
63
|
-
*/
|
|
64
|
-
export function nixEffectAlways(effect: () => (void | (() => void))): void;
|
package/dist/hooks/nixForm.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reactive form handler with validation, reactive state, and safe async submit.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} [initialValues={}] - Initial values for form fields.
|
|
5
|
-
* @param {Object} [validationRules={}] - Validation rules for fields.
|
|
6
|
-
* @returns {Object} Form utilities: values, errors, touched, isSubmitting, isValid,
|
|
7
|
-
* handleChange, handleBlur, handleSubmit, reset, getFieldProps, cancelSubmit
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const form = nixForm({ email: "" }, {
|
|
11
|
-
* email: { required: true, pattern: /^\S+@\S+$/, message: "Invalid email" }
|
|
12
|
-
* });
|
|
13
|
-
* form.handleSubmit(async (values) => { await api.submit(values); });
|
|
14
|
-
*/
|
|
15
|
-
export function nixForm(initialValues?: any, validationRules?: any): any;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Full-featured reactive form with debounced async API submission.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} [initialValues={}] - Initial field values.
|
|
5
|
-
* @param {Object} [validationRules={}] - Validation rules for each field.
|
|
6
|
-
* @param {Object} [options={}] - Async submit options.
|
|
7
|
-
* @param {number} [options.delay=300] - Debounce delay in ms.
|
|
8
|
-
* @param {boolean} [options.leading=false] - Invoke submit on leading edge.
|
|
9
|
-
* @param {boolean} [options.trailing=true] - Invoke submit on trailing edge.
|
|
10
|
-
* @param {number} [options.maxWait] - Maximum wait time before forced invocation.
|
|
11
|
-
* @param {boolean} [options.cache=true] - Cache last submission result.
|
|
12
|
-
* @returns {Object} Form API with state, validation, and debounced async submission.
|
|
13
|
-
*/
|
|
14
|
-
export function nixFormAsync(initialValues?: any, validationRules?: any, options?: {
|
|
15
|
-
delay?: number;
|
|
16
|
-
leading?: boolean;
|
|
17
|
-
trailing?: boolean;
|
|
18
|
-
maxWait?: number;
|
|
19
|
-
cache?: boolean;
|
|
20
|
-
}): any;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Safe interval utility with automatic cleanup support.
|
|
3
|
-
* Provides AbortController integration for cancellable intervals.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Safe interval with automatic cleanup support and optional AbortController.
|
|
7
|
-
* Must be called within a component and cleaned up on unmount.
|
|
8
|
-
*
|
|
9
|
-
* @param {() => void} fn - Function to run at each interval
|
|
10
|
-
* @param {number} ms - Interval duration in milliseconds
|
|
11
|
-
* @param {AbortSignal} [signal] - Optional AbortSignal to cancel the interval
|
|
12
|
-
* @returns {() => void} Cleanup function to stop the interval
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const cancel = nixInterval(() => console.log('tick'), 1000);
|
|
16
|
-
* // stop interval
|
|
17
|
-
* cancel();
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const controller = new AbortController();
|
|
21
|
-
* nixInterval(() => console.log('tick'), 1000, controller.signal);
|
|
22
|
-
* controller.abort(); // automatically clears interval
|
|
23
|
-
*
|
|
24
|
-
* @throws {TypeError} If fn is not a function or ms is not a non-negative number
|
|
25
|
-
*/
|
|
26
|
-
export function nixInterval(fn: () => void, ms: number, signal?: AbortSignal): () => void;
|
package/dist/hooks/nixLazy.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazy-load a module/component with caching.
|
|
3
|
-
*
|
|
4
|
-
* @param {() => Promise<any>} importFn - Function that returns a dynamic import.
|
|
5
|
-
* @returns {Function} Component wrapper for lazy-loaded module.
|
|
6
|
-
*/
|
|
7
|
-
export function nixLazy(importFn: () => Promise<any>): Function;
|
|
8
|
-
/**
|
|
9
|
-
* Suspense-like wrapper for lazy components.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} props
|
|
12
|
-
* @param {any} props.fallback - Element to render while loading.
|
|
13
|
-
* @param {Function} props.children - Function returning child component.
|
|
14
|
-
* @returns {any} Rendered fallback or child.
|
|
15
|
-
*/
|
|
16
|
-
export function Suspense({ fallback, children }: {
|
|
17
|
-
fallback: any;
|
|
18
|
-
children: Function;
|
|
19
|
-
}): any;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazy-load a module/component with caching, retry, and abort support.
|
|
3
|
-
*
|
|
4
|
-
* @param {() => Promise<any>} importFn - Function returning a dynamic import.
|
|
5
|
-
* @param {Object} [options={}] - Options for lazy loading.
|
|
6
|
-
* @param {number} [options.retry=0] - Number of retry attempts on failure.
|
|
7
|
-
* @returns {Function} Component wrapper for lazy-loaded module.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const LazyComp = nixLazyAsync(() => import("./MyComponent"), { retry: 2 });
|
|
11
|
-
*/
|
|
12
|
-
export function nixLazyAsync(importFn: () => Promise<any>, options?: {
|
|
13
|
-
retry?: number;
|
|
14
|
-
}): Function;
|
|
15
|
-
/**
|
|
16
|
-
* Suspense wrapper to catch pending promises and render fallback.
|
|
17
|
-
*
|
|
18
|
-
* @param {Object} props
|
|
19
|
-
* @param {any} props.fallback - Element to render while loading.
|
|
20
|
-
* @param {Function} props.children - Function returning child component.
|
|
21
|
-
* @returns {any} Rendered fallback or child component.
|
|
22
|
-
*/
|
|
23
|
-
export function Suspense({ fallback, children }: {
|
|
24
|
-
fallback: any;
|
|
25
|
-
children: Function;
|
|
26
|
-
}): any;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazy-load a form component and manage its state with debounced async submissions.
|
|
3
|
-
*
|
|
4
|
-
* @param {() => Promise<any>} importFn - Function returning a dynamic import of the form component.
|
|
5
|
-
* @param {Object} [formOptions={}] - Initial values and validation rules.
|
|
6
|
-
* @param {Object} [formOptions.initialValues={}] - Initial field values.
|
|
7
|
-
* @param {Object} [formOptions.validationRules={}] - Validation rules per field.
|
|
8
|
-
* @param {Object} [submitOptions={}] - Debounce and async submission options.
|
|
9
|
-
* @param {number} [submitOptions.delay=300] - Debounce delay.
|
|
10
|
-
* @param {boolean} [submitOptions.leading=false] - Invoke submit on leading edge.
|
|
11
|
-
* @param {boolean} [submitOptions.trailing=true] - Invoke submit on trailing edge.
|
|
12
|
-
* @param {number} [submitOptions.maxWait] - Max wait before forced submission.
|
|
13
|
-
* @param {boolean} [submitOptions.cache=true] - Cache last submission result.
|
|
14
|
-
* @param {Object} [lazyOptions={}] - Options for lazy-loaded component import.
|
|
15
|
-
* @param {number} [lazyOptions.retry=0] - Retry count for lazy-loaded component import.
|
|
16
|
-
* @returns {Object} Lazy-loaded form component and reactive form API.
|
|
17
|
-
*/
|
|
18
|
-
export function nixLazyFormAsync(importFn: () => Promise<any>, formOptions?: {
|
|
19
|
-
initialValues?: any;
|
|
20
|
-
validationRules?: any;
|
|
21
|
-
}, submitOptions?: {
|
|
22
|
-
delay?: number;
|
|
23
|
-
leading?: boolean;
|
|
24
|
-
trailing?: boolean;
|
|
25
|
-
maxWait?: number;
|
|
26
|
-
cache?: boolean;
|
|
27
|
-
}, lazyOptions?: {
|
|
28
|
-
retry?: number;
|
|
29
|
-
}): any;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reactive wrapper around localStorage with safe JSON parsing/stringifying.
|
|
3
|
-
* Automatically persists state changes to localStorage.
|
|
4
|
-
*
|
|
5
|
-
* @template T
|
|
6
|
-
* @param {string} key - LocalStorage key
|
|
7
|
-
* @param {T} initial - Initial value if key does not exist
|
|
8
|
-
* @returns {{ value: T, set: (v: T) => void }} Object with value getter and setter
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const theme = nixLocalStorage('theme', 'light');
|
|
12
|
-
* console.log(theme.value); // 'light' or stored value
|
|
13
|
-
* theme.set('dark'); // Updates state and localStorage
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const user = nixLocalStorage('user', { name: '', age: 0 });
|
|
17
|
-
* user.set({ name: 'John', age: 30 });
|
|
18
|
-
*/
|
|
19
|
-
export function nixLocalStorage<T>(key: string, initial: T): {
|
|
20
|
-
value: T;
|
|
21
|
-
set: (v: T) => void;
|
|
22
|
-
};
|
package/dist/hooks/nixMemo.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memoize a value based on dependencies, similar to React's useMemo.
|
|
3
|
-
*
|
|
4
|
-
* @param {() => any} factory - Function to compute the memoized value
|
|
5
|
-
* @param {Array<any>} deps - Dependency array
|
|
6
|
-
* @returns {any} Memoized value
|
|
7
|
-
*/
|
|
8
|
-
export function nixMemo(factory: () => any, deps?: Array<any>): any;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the previous value of a variable across renders.
|
|
3
|
-
* Useful for detecting changes and implementing undo functionality.
|
|
4
|
-
*
|
|
5
|
-
* @template T
|
|
6
|
-
* @param {T} val - Current value
|
|
7
|
-
* @returns {T | undefined} Previous value (undefined on first render)
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const count = nixState(0);
|
|
11
|
-
* const prevCount = nixPrevious(count.value);
|
|
12
|
-
*
|
|
13
|
-
* // prevCount will be undefined on first render
|
|
14
|
-
* // then will hold the previous value on subsequent renders
|
|
15
|
-
*
|
|
16
|
-
* @throws {Error} If called outside a component context
|
|
17
|
-
*/
|
|
18
|
-
export function nixPrevious<T>(val: T): T | undefined;
|
package/dist/hooks/nixRef.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a mutable ref object that persists across renders.
|
|
3
|
-
* Similar to React's useRef.
|
|
4
|
-
*
|
|
5
|
-
* @param {any} initial - Initial value for the ref
|
|
6
|
-
* @returns {{ current: any }} Ref object
|
|
7
|
-
*/
|
|
8
|
-
export function nixRef(initial?: any): {
|
|
9
|
-
current: any;
|
|
10
|
-
};
|
package/dist/hooks/nixState.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a reactive state value that triggers component re-renders when changed.
|
|
3
|
-
* Must be called within a component function.
|
|
4
|
-
*
|
|
5
|
-
* @param {any} initial - The initial value for the state
|
|
6
|
-
* @returns {NixState} A reactive state object with value getter/setter and subscription methods
|
|
7
|
-
*
|
|
8
|
-
* @typedef {Object} NixState
|
|
9
|
-
* @property {any} value - Get/set the current state value. Getting tracks the dependency, setting triggers subscribers.
|
|
10
|
-
* @property {(fn: Function) => Function} subscribe - Subscribe to state changes. Returns unsubscribe function.
|
|
11
|
-
* @property {() => void} cleanup - Cleanup all subscriptions to prevent memory leaks
|
|
12
|
-
* @property {() => number} getSubscriberCount - Get number of active subscribers (debugging)
|
|
13
|
-
* @property {() => boolean} isDestroyed - Check if state has been destroyed
|
|
14
|
-
* @property {() => Object} asReadOnly - Get read-only version of the state
|
|
15
|
-
* @property {boolean} _isNixState - Internal flag to identify nixState objects
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const Counter = () => {
|
|
19
|
-
* const count = nixState(0);
|
|
20
|
-
*
|
|
21
|
-
* return h("div", {},
|
|
22
|
-
* h("p", {}, "Count: ", count),
|
|
23
|
-
* h("button", { "r-click": () => count.value++ }, "Increment")
|
|
24
|
-
* );
|
|
25
|
-
* };
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* // With cleanup
|
|
29
|
-
* const MyComponent = () => {
|
|
30
|
-
* const state = nixState(0);
|
|
31
|
-
*
|
|
32
|
-
* nixEffect(() => {
|
|
33
|
-
* return () => state.cleanup(); // Clean up on unmount
|
|
34
|
-
* }, []);
|
|
35
|
-
* };
|
|
36
|
-
*
|
|
37
|
-
* @throws {Error} If called outside a component context
|
|
38
|
-
*/
|
|
39
|
-
export function nixState(initial: any): NixState;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a reactive state value that triggers component re-renders when changed.
|
|
42
|
-
* Must be called within a component function.
|
|
43
|
-
*/
|
|
44
|
-
export type NixState = {
|
|
45
|
-
/**
|
|
46
|
-
* - Get/set the current state value. Getting tracks the dependency, setting triggers subscribers.
|
|
47
|
-
*/
|
|
48
|
-
value: any;
|
|
49
|
-
/**
|
|
50
|
-
* - Subscribe to state changes. Returns unsubscribe function.
|
|
51
|
-
*/
|
|
52
|
-
subscribe: (fn: Function) => Function;
|
|
53
|
-
/**
|
|
54
|
-
* - Cleanup all subscriptions to prevent memory leaks
|
|
55
|
-
*/
|
|
56
|
-
cleanup: () => void;
|
|
57
|
-
/**
|
|
58
|
-
* - Get number of active subscribers (debugging)
|
|
59
|
-
*/
|
|
60
|
-
getSubscriberCount: () => number;
|
|
61
|
-
/**
|
|
62
|
-
* - Check if state has been destroyed
|
|
63
|
-
*/
|
|
64
|
-
isDestroyed: () => boolean;
|
|
65
|
-
/**
|
|
66
|
-
* - Get read-only version of the state
|
|
67
|
-
*/
|
|
68
|
-
asReadOnly: () => any;
|
|
69
|
-
/**
|
|
70
|
-
* - Internal flag to identify nixState objects
|
|
71
|
-
*/
|
|
72
|
-
_isNixState: boolean;
|
|
73
|
-
};
|
package/dist/hooks/nixStore.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reactive store hook with subscription support.
|
|
3
|
-
* Memory-safe: cleans up subscribers on component unmount.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} path - Optional path identifier
|
|
6
|
-
* @param {any} initial - Initial value
|
|
7
|
-
* @returns {Object} Reactive store object with get/set/subscribe
|
|
8
|
-
*/
|
|
9
|
-
export function nixStore(path: string, initial: any): any;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vite plugin for transforming Fynix JSX files.
|
|
3
|
-
* Automatically transforms .js and .fnx files.
|
|
4
|
-
*
|
|
5
|
-
* @returns {Object} Vite plugin object
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // vite.config.js
|
|
9
|
-
* import { defineConfig } from 'vite';
|
|
10
|
-
* import { fynix } from '@fynixorg/ui/plugins/vite-plugin-fynix';
|
|
11
|
-
*
|
|
12
|
-
* export default defineConfig({
|
|
13
|
-
* plugins: [fynix()]
|
|
14
|
-
* });
|
|
15
|
-
*/
|
|
16
|
-
export function fynix(): any;
|
package/dist/router/router.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} FynixRouter
|
|
3
|
-
* @property {function(string=): void} mountRouter - Mount router to DOM element
|
|
4
|
-
* @property {function(string, Object=): void} navigate - Navigate to path with props
|
|
5
|
-
* @property {function(string, Object=): void} replace - Replace current path
|
|
6
|
-
* @property {function(): void} back - Navigate back
|
|
7
|
-
* @property {function(): void} cleanup - Cleanup router instance
|
|
8
|
-
* @property {Object} routes - Static routes map
|
|
9
|
-
* @property {Array} dynamicRoutes - Dynamic routes array
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Fynix Router Factory
|
|
13
|
-
* @returns {FynixRouter}
|
|
14
|
-
*/
|
|
15
|
-
export default function createFynix(): FynixRouter;
|
|
16
|
-
/**
|
|
17
|
-
* Helper: Set props for links
|
|
18
|
-
*/
|
|
19
|
-
export function setLinkProps(key: any, props: any): void;
|
|
20
|
-
/**
|
|
21
|
-
* Helper: Clear link props
|
|
22
|
-
*/
|
|
23
|
-
export function clearLinkProps(key: any): void;
|
|
24
|
-
export type FynixRouter = {
|
|
25
|
-
/**
|
|
26
|
-
* - Mount router to DOM element
|
|
27
|
-
*/
|
|
28
|
-
mountRouter: (arg0: string | undefined) => void;
|
|
29
|
-
/**
|
|
30
|
-
* - Navigate to path with props
|
|
31
|
-
*/
|
|
32
|
-
navigate: (arg0: string, arg1: any | undefined) => void;
|
|
33
|
-
/**
|
|
34
|
-
* - Replace current path
|
|
35
|
-
*/
|
|
36
|
-
replace: (arg0: string, arg1: any | undefined) => void;
|
|
37
|
-
/**
|
|
38
|
-
* - Navigate back
|
|
39
|
-
*/
|
|
40
|
-
back: () => void;
|
|
41
|
-
/**
|
|
42
|
-
* - Cleanup router instance
|
|
43
|
-
*/
|
|
44
|
-
cleanup: () => void;
|
|
45
|
-
/**
|
|
46
|
-
* - Static routes map
|
|
47
|
-
*/
|
|
48
|
-
routes: any;
|
|
49
|
-
/**
|
|
50
|
-
* - Dynamic routes array
|
|
51
|
-
*/
|
|
52
|
-
dynamicRoutes: any[];
|
|
53
|
-
};
|
package/dist/runtime.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a virtual text node, supporting reactive state.
|
|
3
|
-
* @param {string|number|object} text
|
|
4
|
-
* @returns {object} vnode
|
|
5
|
-
*/
|
|
6
|
-
export function createTextVNode(text: string | number | object): object;
|
|
7
|
-
/**
|
|
8
|
-
* Create a virtual DOM node (element, fragment, or component).
|
|
9
|
-
* @param {string|function|symbol} type
|
|
10
|
-
* @param {object} [props={}]
|
|
11
|
-
* @param {...any} children
|
|
12
|
-
* @returns {object} vnode
|
|
13
|
-
*/
|
|
14
|
-
export function h(type: string | Function | symbol, props?: object, ...children: any[]): object;
|
|
15
|
-
export namespace h {
|
|
16
|
-
function Fragment({ children }: {
|
|
17
|
-
children: any;
|
|
18
|
-
}): any;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Safely render a component
|
|
22
|
-
* @param {function} Component
|
|
23
|
-
* @param {object} props
|
|
24
|
-
* @returns {object} vnode
|
|
25
|
-
*/
|
|
26
|
-
export function renderComponent(Component: Function, props?: object): object;
|
|
27
|
-
/**
|
|
28
|
-
* Patch a parent DOM node based on oldVNode -> newVNode changes
|
|
29
|
-
* @param {Node} parent
|
|
30
|
-
* @param {object|string|number} newVNode
|
|
31
|
-
* @param {object|string|number} oldVNode
|
|
32
|
-
* @returns {Promise<void>}
|
|
33
|
-
*/
|
|
34
|
-
export function patch(parent: Node, newVNode: object | string | number, oldVNode: object | string | number): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Mount the app component to a root DOM node
|
|
37
|
-
* @param {function} AppComponent
|
|
38
|
-
* @param {string|Element} root
|
|
39
|
-
* @param {boolean} [hydrate=false]
|
|
40
|
-
* @param {object} [props={}]
|
|
41
|
-
*/
|
|
42
|
-
export function mount(AppComponent: Function, root: string | Element, hydrate?: boolean, props?: object): void;
|
|
43
|
-
/**
|
|
44
|
-
* Symbol for text nodes
|
|
45
|
-
* @type {symbol}
|
|
46
|
-
*/
|
|
47
|
-
export const TEXT: symbol;
|
|
48
|
-
/**
|
|
49
|
-
* Symbol for fragments
|
|
50
|
-
* @type {symbol}
|
|
51
|
-
*/
|
|
52
|
-
export const Fragment: symbol;
|
|
53
|
-
/**
|
|
54
|
-
* Create a virtual DOM node (element, fragment, or component).
|
|
55
|
-
* @param {string|function|symbol} type
|
|
56
|
-
* @param {object} [props={}]
|
|
57
|
-
* @param {...any} children
|
|
58
|
-
* @returns {object} vnode
|
|
59
|
-
*/
|
|
60
|
-
export function Fynix(type: string | Function | symbol, props?: object, ...children: any[]): object;
|
|
61
|
-
export namespace Fynix {
|
|
62
|
-
import Fragment = h.Fragment;
|
|
63
|
-
export { Fragment };
|
|
64
|
-
}
|
|
65
|
-
import { nixState } from "./hooks/nixState";
|
|
66
|
-
import { nixEffect } from "./hooks/nixEffect";
|
|
67
|
-
import { nixStore } from "./hooks/nixStore";
|
|
68
|
-
import { nixInterval } from "./hooks/nixInterval";
|
|
69
|
-
import { nixAsync } from "./hooks/nixAsync";
|
|
70
|
-
import { nixCallback } from "./hooks/nixCallback";
|
|
71
|
-
import { nixComputed } from "./hooks/nixComputed";
|
|
72
|
-
import { nixMemo } from "./hooks/nixMemo";
|
|
73
|
-
import { nixDebounce } from "./hooks/nixDebounce";
|
|
74
|
-
import { nixPrevious } from "./hooks/nixPrevious";
|
|
75
|
-
import { nixLocalStorage } from "./hooks/nixLocalStorage";
|
|
76
|
-
import { nixRef } from "./hooks/nixRef";
|
|
77
|
-
import { nixLazy } from "./hooks/nixLazy.js";
|
|
78
|
-
import { Suspense } from "./hooks/nixLazy.js";
|
|
79
|
-
import { nixForm } from "./hooks/nixForm.js";
|
|
80
|
-
import { nixAsyncCached } from "./hooks/nixAsyncCache";
|
|
81
|
-
import { nixAsyncDebounce } from "./hooks/nixAsyncDebounce";
|
|
82
|
-
import { nixAsyncQuery } from "./hooks/nixAsyncQuery";
|
|
83
|
-
import { nixEffectAlways } from "./hooks/nixEffect";
|
|
84
|
-
import { nixEffectOnce } from "./hooks/nixEffect";
|
|
85
|
-
import { nixFormAsync } from "./hooks/nixFormAsync";
|
|
86
|
-
import { nixLazyAsync } from "./hooks/nixLazyAsync";
|
|
87
|
-
import { nixLazyFormAsync } from "./hooks/nixLazyFormAsync";
|
|
88
|
-
import { Path } from "./custom/index.js";
|
|
89
|
-
import { Button } from "./custom/index.js";
|
|
90
|
-
import createFynix from "./router/router.js";
|
|
91
|
-
export { nixState, nixEffect, nixStore, nixInterval, nixAsync, nixCallback, nixComputed, nixMemo, nixDebounce, nixPrevious, nixLocalStorage, nixRef, nixLazy, Suspense, nixForm, nixAsyncCached, nixAsyncDebounce, nixAsyncQuery, nixEffectAlways, nixEffectOnce, nixFormAsync, nixLazyAsync, nixLazyFormAsync, Path, Button, createFynix };
|