@fynixorg/ui 1.0.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/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;
@@ -0,0 +1,236 @@
1
+ // global.d.ts - Fynix Global Type Declarations
2
+
3
+ /**
4
+ * Reactive state object
5
+ */
6
+ interface NixState<T> {
7
+ value: T;
8
+ _isNixState: true;
9
+ subscribe(callback: () => void): () => void;
10
+ }
11
+
12
+ /**
13
+ * Reactive store object
14
+ */
15
+ interface NixStore<T extends Record<string, any>> {
16
+ _isNixStore: true;
17
+ subscribe(callback: () => void): () => void;
18
+ getState(): T;
19
+ setState(updates: Partial<T> | ((state: T) => Partial<T>)): void;
20
+ [key: string]: any;
21
+ }
22
+
23
+ /**
24
+ * Async state result
25
+ */
26
+ interface NixAsyncResult<T> {
27
+ data: T | null;
28
+ loading: boolean;
29
+ error: Error | null;
30
+ refetch: () => Promise<void>;
31
+ }
32
+
33
+ /**
34
+ * Form field
35
+ */
36
+ interface NixFormField<T = any> {
37
+ value: T;
38
+ error: string | null;
39
+ touched: boolean;
40
+ }
41
+
42
+ /**
43
+ * Form state
44
+ */
45
+ interface NixFormState<T extends Record<string, any>> {
46
+ values: { [K in keyof T]: NixFormField<T[K]> };
47
+ isValid: boolean;
48
+ isSubmitting: boolean;
49
+ errors: { [K in keyof T]?: string };
50
+ handleSubmit: (onSubmit: (values: T) => void | Promise<void>) => (e?: Event) => Promise<void>;
51
+ reset: () => void;
52
+ setFieldValue: <K extends keyof T>(field: K, value: T[K]) => void;
53
+ setFieldError: <K extends keyof T>(field: K, error: string) => void;
54
+ }
55
+
56
+ /**
57
+ * Lazy component result
58
+ */
59
+ interface NixLazyComponent {
60
+ Component: any;
61
+ loading: boolean;
62
+ error: Error | null;
63
+ }
64
+
65
+ /**
66
+ * Fynix Router instance
67
+ */
68
+ interface FynixRouter {
69
+ mountRouter(selector?: string): void;
70
+ navigate(path: string, props?: Record<string, any>): void;
71
+ replace(path: string, props?: Record<string, any>): void;
72
+ back(): void;
73
+ cleanup(): void;
74
+ routes: Record<string, any>;
75
+ dynamicRoutes: Array<{
76
+ pattern: string;
77
+ regex: RegExp;
78
+ component: any;
79
+ params: string[];
80
+ }>;
81
+ }
82
+
83
+ /**
84
+ * Window object extensions for Fynix framework
85
+ */
86
+ interface Window {
87
+ /** Cache for router props to prevent memory leaks */
88
+ __fynixPropsCache?: Map<string, any>;
89
+
90
+ /** Link props namespace for router navigation */
91
+ __fynixLinkProps__?: Record<string, any>;
92
+
93
+ /** Last route props passed to components */
94
+ __lastRouteProps?: any;
95
+
96
+ /** Fynix global state and utilities */
97
+ __fynix__?: {
98
+ /** Current route props */
99
+ lastRouteProps?: any;
100
+ /** Force re-render function */
101
+ rerender?: () => void;
102
+ /** Hot Module Replacement handler */
103
+ hmr?: (ctx: { mod: any }) => void;
104
+ };
105
+ }
106
+
107
+ /**
108
+ * HTMLElement extensions for event delegation and Fynix internals
109
+ */
110
+ interface HTMLElement {
111
+ /** Event delegation ID for r-* event handlers */
112
+ _rest_eid?: number;
113
+
114
+ /** Fynix internal data storage */
115
+ _fynix_?: any;
116
+ }
117
+
118
+ /**
119
+ * Node extensions for Fynix virtual DOM
120
+ */
121
+ interface Node {
122
+ /** Event delegation ID */
123
+ _rest_eid?: number;
124
+ /** Fynix cleanup functions */
125
+ _fynixCleanups?: Array<() => void>;
126
+ }
127
+
128
+ /**
129
+ * Text node type with nodeValue
130
+ */
131
+ interface Text {
132
+ nodeValue: string | null;
133
+ }
134
+
135
+ /**
136
+ * Vite-specific import.meta extensions
137
+ */
138
+ interface ImportMeta {
139
+ /** Vite Hot Module Replacement API */
140
+ readonly hot?: {
141
+ /** Accept HMR updates */
142
+ accept: (cb?: (mod: any) => void) => void;
143
+ /** Cleanup before module disposal */
144
+ dispose: (cb: () => void) => void;
145
+ /** Decline HMR for this module */
146
+ decline?: () => void;
147
+ /** Invalidate and force full reload */
148
+ invalidate?: () => void;
149
+ /** Custom HMR event handling */
150
+ on?: (event: string, cb: (...args: any[]) => void) => void;
151
+ };
152
+
153
+ /** Vite glob import function */
154
+ readonly glob: <T = any>(
155
+ pattern: string,
156
+ options?: {
157
+ /** Load modules eagerly (at build time) */
158
+ eager?: boolean;
159
+ /** Import as URL strings */
160
+ as?: 'url' | 'raw';
161
+ /** Custom import query */
162
+ query?: Record<string, string | number | boolean>;
163
+ }
164
+ ) => Record<string, T>;
165
+
166
+ /** Environment variables */
167
+ readonly env: {
168
+ MODE: string;
169
+ BASE_URL: string;
170
+ PROD: boolean;
171
+ DEV: boolean;
172
+ SSR: boolean;
173
+ [key: string]: any;
174
+ };
175
+ }
176
+
177
+ /**
178
+ * Module declarations for non-TypeScript files
179
+ */
180
+ declare module '*.css' {
181
+ const content: string;
182
+ export default content;
183
+ }
184
+
185
+ declare module '*.scss' {
186
+ const content: string;
187
+ export default content;
188
+ }
189
+
190
+ declare module '*.svg' {
191
+ const content: string;
192
+ export default content;
193
+ }
194
+
195
+ declare module '*.png' {
196
+ const content: string;
197
+ export default content;
198
+ }
199
+
200
+ declare module '*.jpg' {
201
+ const content: string;
202
+ export default content;
203
+ }
204
+
205
+ declare module '*.jpeg' {
206
+ const content: string;
207
+ export default content;
208
+ }
209
+
210
+ declare module '*.gif' {
211
+ const content: string;
212
+ export default content;
213
+ }
214
+
215
+ declare module '*.webp' {
216
+ const content: string;
217
+ export default content;
218
+ }
219
+
220
+ /**
221
+ * Fynix-specific module patterns
222
+ */
223
+ declare module '*.fnx' {
224
+ const Component: any;
225
+ export default Component;
226
+ }
227
+
228
+ declare module '*.js' {
229
+ const Component: any;
230
+ export default Component;
231
+ }
232
+
233
+ /**
234
+ * Vite client types
235
+ */
236
+ /// <reference types="vite/client" />