@coherent.js/core 1.0.0-beta.2

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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +130 -0
  3. package/dist/coherent.d.ts +472 -0
  4. package/dist/coherent.d.ts.map +1 -0
  5. package/dist/coherent.js +590 -0
  6. package/dist/coherent.js.map +1 -0
  7. package/dist/components/component-system.d.ts +1138 -0
  8. package/dist/components/component-system.d.ts.map +1 -0
  9. package/dist/components/component-system.js +2220 -0
  10. package/dist/components/component-system.js.map +1 -0
  11. package/dist/components/lifecycle.d.ts +212 -0
  12. package/dist/components/lifecycle.d.ts.map +1 -0
  13. package/dist/components/lifecycle.js +525 -0
  14. package/dist/components/lifecycle.js.map +1 -0
  15. package/dist/core/html-utils.d.ts +14 -0
  16. package/dist/core/html-utils.d.ts.map +1 -0
  17. package/dist/core/html-utils.js +166 -0
  18. package/dist/core/html-utils.js.map +1 -0
  19. package/dist/core/object-factory.d.ts +38 -0
  20. package/dist/core/object-factory.d.ts.map +1 -0
  21. package/dist/core/object-factory.js +63 -0
  22. package/dist/core/object-factory.js.map +1 -0
  23. package/dist/core/object-utils.d.ts +77 -0
  24. package/dist/core/object-utils.d.ts.map +1 -0
  25. package/dist/core/object-utils.js +502 -0
  26. package/dist/core/object-utils.js.map +1 -0
  27. package/dist/dev/dev-tools.d.ts +194 -0
  28. package/dist/dev/dev-tools.d.ts.map +1 -0
  29. package/dist/dev/dev-tools.js +846 -0
  30. package/dist/dev/dev-tools.js.map +1 -0
  31. package/dist/forms/validation.d.ts +271 -0
  32. package/dist/forms/validation.d.ts.map +1 -0
  33. package/dist/forms/validation.js +573 -0
  34. package/dist/forms/validation.js.map +1 -0
  35. package/dist/index.cjs +5281 -0
  36. package/dist/index.cjs.map +7 -0
  37. package/dist/index.js +5204 -0
  38. package/dist/index.js.map +7 -0
  39. package/dist/performance/bundle-optimizer.d.ts +95 -0
  40. package/dist/performance/bundle-optimizer.d.ts.map +1 -0
  41. package/dist/performance/bundle-optimizer.js +192 -0
  42. package/dist/performance/bundle-optimizer.js.map +1 -0
  43. package/dist/performance/cache-manager.d.ts +107 -0
  44. package/dist/performance/cache-manager.d.ts.map +1 -0
  45. package/dist/performance/cache-manager.js +314 -0
  46. package/dist/performance/cache-manager.js.map +1 -0
  47. package/dist/performance/component-cache.d.ts +120 -0
  48. package/dist/performance/component-cache.d.ts.map +1 -0
  49. package/dist/performance/component-cache.js +364 -0
  50. package/dist/performance/component-cache.js.map +1 -0
  51. package/dist/performance/monitor.d.ts +189 -0
  52. package/dist/performance/monitor.d.ts.map +1 -0
  53. package/dist/performance/monitor.js +347 -0
  54. package/dist/performance/monitor.js.map +1 -0
  55. package/dist/rendering/base-renderer.d.ts +140 -0
  56. package/dist/rendering/base-renderer.d.ts.map +1 -0
  57. package/dist/rendering/base-renderer.js +409 -0
  58. package/dist/rendering/base-renderer.js.map +1 -0
  59. package/dist/rendering/css-manager.d.ts +73 -0
  60. package/dist/rendering/css-manager.d.ts.map +1 -0
  61. package/dist/rendering/css-manager.js +176 -0
  62. package/dist/rendering/css-manager.js.map +1 -0
  63. package/dist/rendering/dom-renderer.d.ts +62 -0
  64. package/dist/rendering/dom-renderer.d.ts.map +1 -0
  65. package/dist/rendering/dom-renderer.js +252 -0
  66. package/dist/rendering/dom-renderer.js.map +1 -0
  67. package/dist/rendering/html-renderer.d.ts +67 -0
  68. package/dist/rendering/html-renderer.d.ts.map +1 -0
  69. package/dist/rendering/html-renderer.js +444 -0
  70. package/dist/rendering/html-renderer.js.map +1 -0
  71. package/dist/rendering/renderer-config.d.ts +282 -0
  72. package/dist/rendering/renderer-config.d.ts.map +1 -0
  73. package/dist/rendering/renderer-config.js +144 -0
  74. package/dist/rendering/renderer-config.js.map +1 -0
  75. package/dist/rendering/streaming-renderer.d.ts +117 -0
  76. package/dist/rendering/streaming-renderer.d.ts.map +1 -0
  77. package/dist/rendering/streaming-renderer.js +326 -0
  78. package/dist/rendering/streaming-renderer.js.map +1 -0
  79. package/dist/rendering/vdom-diff.d.ts +47 -0
  80. package/dist/rendering/vdom-diff.d.ts.map +1 -0
  81. package/dist/rendering/vdom-diff.js +416 -0
  82. package/dist/rendering/vdom-diff.js.map +1 -0
  83. package/dist/routing/router.d.ts +241 -0
  84. package/dist/routing/router.d.ts.map +1 -0
  85. package/dist/routing/router.js +648 -0
  86. package/dist/routing/router.js.map +1 -0
  87. package/dist/state/reactive-state.d.ts +166 -0
  88. package/dist/state/reactive-state.d.ts.map +1 -0
  89. package/dist/state/reactive-state.js +546 -0
  90. package/dist/state/reactive-state.js.map +1 -0
  91. package/dist/state/state-manager.d.ts +45 -0
  92. package/dist/state/state-manager.d.ts.map +1 -0
  93. package/dist/state/state-manager.js +151 -0
  94. package/dist/state/state-manager.js.map +1 -0
  95. package/dist/types/constants.d.ts +8 -0
  96. package/dist/types/constants.d.ts.map +1 -0
  97. package/dist/types/constants.js +36 -0
  98. package/dist/types/constants.js.map +1 -0
  99. package/dist/utils/dependency-utils.d.ts +43 -0
  100. package/dist/utils/dependency-utils.d.ts.map +1 -0
  101. package/dist/utils/dependency-utils.js +105 -0
  102. package/dist/utils/dependency-utils.js.map +1 -0
  103. package/dist/utils/error-handler.d.ts +148 -0
  104. package/dist/utils/error-handler.d.ts.map +1 -0
  105. package/dist/utils/error-handler.js +468 -0
  106. package/dist/utils/error-handler.js.map +1 -0
  107. package/dist/utils/normalization.d.ts +3 -0
  108. package/dist/utils/normalization.d.ts.map +1 -0
  109. package/dist/utils/normalization.js +24 -0
  110. package/dist/utils/normalization.js.map +1 -0
  111. package/dist/utils/validation.d.ts +10 -0
  112. package/dist/utils/validation.d.ts.map +1 -0
  113. package/dist/utils/validation.js +32 -0
  114. package/dist/utils/validation.js.map +1 -0
  115. package/package.json +44 -0
  116. package/types/index.d.ts +734 -0
@@ -0,0 +1,734 @@
1
+ /**
2
+ * Coherent.js Core Types
3
+ * TypeScript definitions for the core Coherent.js framework
4
+ *
5
+ * @version 1.0.0-beta.1
6
+ */
7
+
8
+ // ============================================================================
9
+ // Basic Types
10
+ // ============================================================================
11
+
12
+ /** Primitive values that can be rendered as HTML */
13
+ export type Primitive = string | number | boolean | null | undefined;
14
+
15
+ /** HTML attributes object */
16
+ export interface HTMLAttributes {
17
+ [key: string]: Primitive | (() => Primitive);
18
+ className?: string;
19
+ class?: string;
20
+ id?: string;
21
+ style?: string | Record<string, string | number>;
22
+ onClick?: string | (() => void);
23
+ onSubmit?: string | (() => void);
24
+ href?: string;
25
+ src?: string;
26
+ alt?: string;
27
+ title?: string;
28
+ disabled?: boolean;
29
+ checked?: boolean;
30
+ value?: string | number;
31
+ placeholder?: string;
32
+ type?: string;
33
+ name?: string;
34
+ method?: string;
35
+ action?: string;
36
+ target?: string;
37
+ rel?: string;
38
+ role?: string;
39
+ 'aria-label'?: string;
40
+ 'aria-describedby'?: string;
41
+ 'data-'?: string;
42
+ }
43
+
44
+ /** Element properties including children and text */
45
+ export interface ElementProps extends HTMLAttributes {
46
+ children?: CoherentNode | CoherentNode[];
47
+ text?: Primitive;
48
+ }
49
+
50
+ /** A Coherent.js HTML element definition */
51
+ export interface CoherentElement {
52
+ [tagName: string]: ElementProps | string;
53
+ }
54
+
55
+ /** Valid nodes that can be rendered */
56
+ export type CoherentNode =
57
+ | Primitive
58
+ | CoherentElement
59
+ | CoherentNode[]
60
+ | CoherentComponent
61
+ | ContextProvider
62
+ | (() => CoherentNode);
63
+
64
+ /** Text-only element for simple content */
65
+ export interface TextElement {
66
+ text: Primitive;
67
+ }
68
+
69
+ // ============================================================================
70
+ // Component System
71
+ // ============================================================================
72
+
73
+ /** Props passed to a component function */
74
+ export interface ComponentProps {
75
+ [key: string]: any;
76
+ children?: CoherentNode | CoherentNode[];
77
+ }
78
+
79
+ /** State object for component state management */
80
+ export interface ComponentState {
81
+ [key: string]: any;
82
+ }
83
+
84
+ /** Context object passed through component tree */
85
+ export interface ComponentContext {
86
+ [key: string]: any;
87
+ }
88
+
89
+ /** A functional component */
90
+ export interface CoherentComponent<P extends ComponentProps = ComponentProps> {
91
+ (props?: P, state?: ComponentState, context?: ComponentContext): CoherentNode;
92
+ displayName?: string;
93
+ componentName?: string;
94
+ definition?: ComponentDefinition;
95
+ }
96
+
97
+ /** Component lifecycle hooks */
98
+ export interface ComponentLifecycleHooks {
99
+ beforeCreate?(): void;
100
+ created?(): void;
101
+ beforeMount?(): void;
102
+ mounted?(): void;
103
+ beforeUpdate?(): void;
104
+ updated?(): void;
105
+ beforeDestroy?(): void;
106
+ destroyed?(): void;
107
+ errorCaptured?(error: Error): void;
108
+ }
109
+
110
+ /** Component methods */
111
+ export interface ComponentMethods {
112
+ [methodName: string]: Function;
113
+ }
114
+
115
+ /** Computed properties */
116
+ export interface ComputedProperties {
117
+ [key: string]: (this: ComponentInstance) => any;
118
+ }
119
+
120
+ /** Watchers for reactive properties */
121
+ export interface ComponentWatchers {
122
+ [key: string]: (newValue: any, oldValue: any) => void;
123
+ }
124
+
125
+ /** Component definition object */
126
+ export interface ComponentDefinition extends ComponentLifecycleHooks {
127
+ name?: string;
128
+ render?: (this: ComponentInstance, props: ComponentProps, state: ComponentState) => CoherentNode;
129
+ template?: CoherentNode | ((props: ComponentProps, state: ComponentState) => CoherentNode) | string;
130
+ state?: ComponentState;
131
+ methods?: ComponentMethods;
132
+ computed?: ComputedProperties;
133
+ watch?: ComponentWatchers;
134
+ }
135
+
136
+ /** Component class instance */
137
+ export interface ComponentInstance {
138
+ name: string;
139
+ props: ComponentProps;
140
+ state: ComponentStateManager;
141
+ children: ComponentInstance[];
142
+ parent: ComponentInstance | null;
143
+ rendered: CoherentNode | null;
144
+ isMounted: boolean;
145
+ isDestroyed: boolean;
146
+ definition: ComponentDefinition;
147
+ hooks: Required<ComponentLifecycleHooks>;
148
+ methods: ComponentMethods;
149
+ computed: ComputedProperties;
150
+ computedCache: Map<string, any>;
151
+ watchers: ComponentWatchers;
152
+
153
+ render(props?: ComponentProps): CoherentNode;
154
+ mount(): ComponentInstance;
155
+ update(): ComponentInstance;
156
+ destroy(): ComponentInstance;
157
+ clone(overrides?: Partial<ComponentDefinition>): ComponentInstance;
158
+ getMetadata(): ComponentMetadata;
159
+ callHook(hookName: keyof ComponentLifecycleHooks, ...args: any[]): any;
160
+ handleError(error: Error, context?: string): void;
161
+ }
162
+
163
+ /** Component metadata for debugging/profiling */
164
+ export interface ComponentMetadata {
165
+ createdAt: number;
166
+ updateCount: number;
167
+ renderCount: number;
168
+ }
169
+
170
+ /** Component state manager with reactive updates */
171
+ export interface ComponentStateManager {
172
+ get(): ComponentState;
173
+ get<K extends keyof ComponentState>(key: K): ComponentState[K];
174
+ set(updates: Partial<ComponentState> | ((state: ComponentState) => Partial<ComponentState>)): ComponentStateManager;
175
+ subscribe(listener: StateListener): () => void;
176
+ notifyListeners(oldState: ComponentState, newState: ComponentState): void;
177
+ }
178
+
179
+ /** State change listener */
180
+ export type StateListener = (newState: ComponentState, oldState: ComponentState) => void;
181
+
182
+ // ============================================================================
183
+ // State Management
184
+ // ============================================================================
185
+
186
+ /** State container for request/render cycles */
187
+ export interface StateContainer {
188
+ get<K extends string>(key: K): any;
189
+ set<K extends string>(key: K, value: any): StateContainer;
190
+ has<K extends string>(key: K): boolean;
191
+ delete<K extends string>(key: K): boolean;
192
+ clear(): StateContainer;
193
+ toObject(): Record<string, any>;
194
+ _internal: Map<string, any>;
195
+ }
196
+
197
+ /** Global state manager */
198
+ export interface GlobalStateManager {
199
+ set<K extends string>(key: K, value: any): void;
200
+ get<K extends string>(key: K): any;
201
+ has<K extends string>(key: K): boolean;
202
+ clear(): void;
203
+ createRequestState(): StateContainer;
204
+ }
205
+
206
+ /** Context provider function */
207
+ export interface ContextProvider {
208
+ (renderFunction?: (children: CoherentNode) => CoherentNode): CoherentNode;
209
+ }
210
+
211
+ /** State utilities for withState HOC */
212
+ export interface StateUtilities<S extends ComponentState = ComponentState> {
213
+ setState(newState: Partial<S> | ((state: S) => Partial<S>)): void;
214
+ getState(): S;
215
+ resetState(): void;
216
+ updateState(updater: Partial<S> | ((state: S) => Partial<S>)): void;
217
+ batchUpdate(updates: Array<Partial<S> | ((container: any) => void)>): void;
218
+ }
219
+
220
+ /** Enhanced props with state for withState HOC */
221
+ export interface WithStateProps<P extends ComponentProps, S extends ComponentState> extends P {
222
+ state: S;
223
+ setState: (newState: Partial<S> | ((state: S) => Partial<S>)) => void;
224
+ stateUtils: StateUtilities<S>;
225
+ }
226
+
227
+ // ============================================================================
228
+ // Higher-Order Components (HOCs)
229
+ // ============================================================================
230
+
231
+ /** HOC that adds state to a component */
232
+ export interface WithStateHOC {
233
+ <P extends ComponentProps, S extends ComponentState>(
234
+ initialStateOrComponent: S | CoherentComponent<P>,
235
+ maybeInitialState?: S
236
+ ): CoherentComponent<WithStateProps<P, S>>;
237
+ <S extends ComponentState>(initialState: S): <P extends ComponentProps>(
238
+ component: CoherentComponent<P>
239
+ ) => CoherentComponent<WithStateProps<P, S>>;
240
+ }
241
+
242
+ /** Memoization options */
243
+ export interface MemoOptions {
244
+ strategy?: 'lru' | 'ttl' | 'weak' | 'simple';
245
+ maxSize?: number;
246
+ ttl?: number;
247
+ keyFn?: (...args: any[]) => string;
248
+ keySerializer?: (value: any) => string;
249
+ compareFn?: (a: any, b: any) => boolean;
250
+ shallow?: boolean;
251
+ onHit?: (key: string, value: any, args: any[]) => void;
252
+ onMiss?: (key: string, args: any[]) => void;
253
+ onEvict?: (key: string, value: any) => void;
254
+ stats?: boolean;
255
+ debug?: boolean;
256
+ }
257
+
258
+ /** Memoized function with utilities */
259
+ export interface MemoizedFunction<T extends (...args: any[]) => any> extends T {
260
+ cache: Map<string, any>;
261
+ clear(): void;
262
+ delete(key: string): boolean;
263
+ has(key: string): boolean;
264
+ size(): number;
265
+ refresh(...args: Parameters<T>): ReturnType<T>;
266
+ stats?(): { hits: number; misses: number; evictions: number };
267
+ resetStats?(): void;
268
+ }
269
+
270
+ /** Props transformation function */
271
+ export type PropsTransform<P, T> = (props: P, state?: ComponentState, context?: ComponentContext) => T | Promise<T>;
272
+
273
+ /** WithProps HOC options */
274
+ export interface WithPropsOptions<P, T> {
275
+ merge?: boolean;
276
+ override?: boolean;
277
+ validate?: (props: any) => boolean;
278
+ memoize?: boolean;
279
+ memoOptions?: MemoOptions;
280
+ onError?: (error: Error, props: P) => void;
281
+ fallbackProps?: Partial<T>;
282
+ displayName?: string;
283
+ debug?: boolean;
284
+ onPropsChange?: (finalProps: any, original: P, transformed: T) => void;
285
+ shouldUpdate?: (finalProps: any, original: P, state: ComponentState) => boolean;
286
+ }
287
+
288
+ /** WithProps HOC */
289
+ export interface WithPropsHOC {
290
+ <P extends ComponentProps, T>(
291
+ propsTransform: PropsTransform<P, T> | T,
292
+ options?: WithPropsOptions<P, T>
293
+ ): <C extends CoherentComponent<P & T>>(component: C) => CoherentComponent<P>;
294
+ }
295
+
296
+ // ============================================================================
297
+ // Lazy Loading
298
+ // ============================================================================
299
+
300
+ /** Lazy evaluation options */
301
+ export interface LazyOptions {
302
+ cache?: boolean;
303
+ timeout?: number;
304
+ fallback?: any;
305
+ onError?: (error: Error) => void;
306
+ dependencies?: any[];
307
+ }
308
+
309
+ /** Lazy wrapper interface */
310
+ export interface LazyWrapper<T> {
311
+ __isLazy: true;
312
+ __factory: (...args: any[]) => T;
313
+ __options: LazyOptions;
314
+
315
+ evaluate(...args: any[]): T;
316
+ invalidate(): LazyWrapper<T>;
317
+ isEvaluated(): boolean;
318
+ getCachedValue(): T | null;
319
+ map<U>(transform: (value: T) => U): LazyWrapper<U>;
320
+ flatMap<U>(transform: (value: T) => LazyWrapper<U> | U): LazyWrapper<U>;
321
+ toString(): string;
322
+ toJSON(): T;
323
+ }
324
+
325
+ // ============================================================================
326
+ // Composition Utilities
327
+ // ============================================================================
328
+
329
+ /** Component composition utilities */
330
+ export interface ComposeUtils {
331
+ combine(...components: CoherentComponent[]): CoherentComponent;
332
+ conditional<P extends ComponentProps>(
333
+ condition: boolean | ((props: P) => boolean),
334
+ trueComponent: CoherentComponent<P>,
335
+ falseComponent?: CoherentComponent<P> | null
336
+ ): CoherentComponent<P>;
337
+ loop<T, P extends ComponentProps>(
338
+ data: T[] | ((props: P) => T[]),
339
+ itemComponent: CoherentComponent<P & { item: T; index: number; key: any }>,
340
+ keyFn?: (item: T, index: number) => any
341
+ ): CoherentComponent<P>;
342
+ }
343
+
344
+ /** Component utilities */
345
+ export interface ComponentUtils {
346
+ getComponentTree(component: ComponentInstance): ComponentTree;
347
+ findComponent(component: ComponentInstance, name: string): ComponentInstance | null;
348
+ getPerformanceMetrics(component: ComponentInstance): PerformanceMetrics;
349
+ validateDefinition(definition: ComponentDefinition): string[];
350
+ }
351
+
352
+ /** Component tree structure */
353
+ export interface ComponentTree {
354
+ name: string;
355
+ props: ComponentProps;
356
+ state: ComponentState;
357
+ children: ComponentTree[];
358
+ metadata: ComponentMetadata;
359
+ }
360
+
361
+ /** Performance metrics */
362
+ export interface PerformanceMetrics {
363
+ renderCount: number;
364
+ updateCount: number;
365
+ createdAt: number;
366
+ age: number;
367
+ }
368
+
369
+ // ============================================================================
370
+ // Core Functions
371
+ // ============================================================================
372
+
373
+ /** Render a Coherent node to HTML string */
374
+ export function render(obj: CoherentNode): string;
375
+
376
+ /** Alias for render */
377
+ export function render(obj: CoherentNode): string;
378
+
379
+ /** Synchronous version of render */
380
+ export function renderSync(obj: CoherentNode): string;
381
+
382
+ /** Escape HTML characters in text */
383
+ export function escapeHtml(text: string): string;
384
+
385
+ /** Check if tag is a void element */
386
+ export function isVoidElement(tagName: string): boolean;
387
+
388
+ /** Format HTML attributes */
389
+ export function formatAttributes(attrs: HTMLAttributes): string;
390
+
391
+ /** Higher-order component for state management */
392
+ export const withState: WithStateHOC;
393
+
394
+ /** Memoization function */
395
+ export function memo<T extends (...args: any[]) => any>(
396
+ fn: T,
397
+ options?: MemoOptions
398
+ ): MemoizedFunction<T>;
399
+
400
+ /** Component memoization */
401
+ export function memoComponent<P extends ComponentProps>(
402
+ component: CoherentComponent<P>,
403
+ options?: { propsEqual?: (a: P, b: P) => boolean; name?: string }
404
+ ): CoherentComponent<P>;
405
+
406
+ /** Higher-order component for props transformation */
407
+ export const withProps: WithPropsHOC;
408
+
409
+ /** Validate component structure */
410
+ export function validateComponent(obj: any, name?: string): boolean;
411
+
412
+ /** Check if object is a Coherent object */
413
+ export function isCoherentObject(obj: any): obj is CoherentElement;
414
+
415
+ /** Deep clone utility */
416
+ export function deepClone<T>(obj: T): T;
417
+
418
+ /** Create lazy evaluation wrapper */
419
+ export function lazy<T>(factory: (...args: any[]) => T, options?: LazyOptions): LazyWrapper<T>;
420
+
421
+ /** Check if value is lazy */
422
+ export function isLazy<T>(value: any): value is LazyWrapper<T>;
423
+
424
+ /** Evaluate lazy values recursively */
425
+ export function evaluateLazy<T>(obj: T, ...args: any[]): T;
426
+
427
+ /** Create lazy component */
428
+ export function lazyComponent<P extends ComponentProps>(
429
+ componentFactory: () => CoherentComponent<P>,
430
+ options?: LazyOptions
431
+ ): LazyWrapper<CoherentComponent<P>>;
432
+
433
+ // ============================================================================
434
+ // Component System Classes and Functions
435
+ // ============================================================================
436
+
437
+ /** Component class constructor */
438
+ export class Component implements ComponentInstance {
439
+ constructor(definition?: ComponentDefinition);
440
+
441
+ name: string;
442
+ props: ComponentProps;
443
+ state: ComponentStateManager;
444
+ children: ComponentInstance[];
445
+ parent: ComponentInstance | null;
446
+ rendered: CoherentNode | null;
447
+ isMounted: boolean;
448
+ isDestroyed: boolean;
449
+ definition: ComponentDefinition;
450
+ hooks: Required<ComponentLifecycleHooks>;
451
+ methods: ComponentMethods;
452
+ computed: ComputedProperties;
453
+ computedCache: Map<string, any>;
454
+ watchers: ComponentWatchers;
455
+
456
+ render(props?: ComponentProps): CoherentNode;
457
+ mount(): ComponentInstance;
458
+ update(): ComponentInstance;
459
+ destroy(): ComponentInstance;
460
+ clone(overrides?: Partial<ComponentDefinition>): ComponentInstance;
461
+ getMetadata(): ComponentMetadata;
462
+ callHook(hookName: keyof ComponentLifecycleHooks, ...args: any[]): any;
463
+ handleError(error: Error, context?: string): void;
464
+ }
465
+
466
+ /** Create a component instance */
467
+ export function createComponent(definition: ComponentDefinition | CoherentComponent): Component;
468
+
469
+ /** Define a component factory */
470
+ export function defineComponent<P extends ComponentProps>(
471
+ definition: ComponentDefinition
472
+ ): CoherentComponent<P>;
473
+
474
+ /** Register a global component */
475
+ export function registerComponent<P extends ComponentProps>(
476
+ name: string,
477
+ definition: ComponentDefinition | CoherentComponent<P>
478
+ ): CoherentComponent<P>;
479
+
480
+ /** Get a registered component */
481
+ export function getComponent<P extends ComponentProps>(name: string): CoherentComponent<P> | undefined;
482
+
483
+ /** Get all registered components */
484
+ export function getRegisteredComponents(): Map<string, CoherentComponent>;
485
+
486
+ /** Create a higher-order component */
487
+ export function createHOC<P extends ComponentProps, E extends ComponentProps>(
488
+ enhancer: (WrappedComponent: CoherentComponent<P>, props: E) => CoherentNode
489
+ ): (WrappedComponent: CoherentComponent<P>) => CoherentComponent<E>;
490
+
491
+ // ============================================================================
492
+ // State Management Functions
493
+ // ============================================================================
494
+
495
+ /** Create a state container */
496
+ export function createState(initialState?: Record<string, any>): StateContainer;
497
+
498
+ /** Global state manager instance */
499
+ export const globalStateManager: GlobalStateManager;
500
+
501
+ /** Provide context to children */
502
+ export function provideContext<T>(key: string, value: T): void;
503
+
504
+ /** Create a context provider component */
505
+ export function createContextProvider<T>(
506
+ key: string,
507
+ value: T,
508
+ children: CoherentNode
509
+ ): ContextProvider;
510
+
511
+ /** Restore context to previous value */
512
+ export function restoreContext(key: string): void;
513
+
514
+ /** Clear all context stacks */
515
+ export function clearAllContexts(): void;
516
+
517
+ /** Use context value */
518
+ export function useContext<T>(key: string): T | undefined;
519
+
520
+ // ============================================================================
521
+ // Virtual DOM Types (Additional)
522
+ // ============================================================================
523
+
524
+ /** Virtual DOM node */
525
+ export interface VNode {
526
+ type: string | Function;
527
+ props: Record<string, any>;
528
+ children: VNode[];
529
+ key?: string | number;
530
+ }
531
+
532
+ /** VDOM operation types */
533
+ export const VDOM_OPERATIONS: {
534
+ CREATE: string;
535
+ REMOVE: string;
536
+ REPLACE: string;
537
+ UPDATE: string;
538
+ };
539
+
540
+ /** VDOM patch operation */
541
+ export interface VDOMPatch {
542
+ type: string;
543
+ path: (string | number)[];
544
+ value?: any;
545
+ oldValue?: any;
546
+ props?: Record<string, any>;
547
+ }
548
+
549
+ /** Create a virtual node */
550
+ export function createVNode(type: string | Function, props?: Record<string, any>, children?: VNode[]): VNode;
551
+
552
+ /** Convert object to virtual node */
553
+ export function objectToVNode(component: CoherentNode, depth?: number): VNode;
554
+
555
+ /** Diff two virtual nodes */
556
+ export function diff(oldVNode: VNode, newVNode: VNode, patches?: VDOMPatch[], path?: (string | number)[]): VDOMPatch[];
557
+
558
+ /** Apply patches to DOM element */
559
+ export function patch(element: HTMLElement, patches: VDOMPatch[]): void;
560
+
561
+ /** VDOM differ class */
562
+ export class VDOMDiffer {
563
+ diff(oldVNode: VNode, newVNode: VNode): VDOMPatch[];
564
+ patch(element: HTMLElement, patches: VDOMPatch[]): void;
565
+ }
566
+
567
+ // ============================================================================
568
+ // Advanced Rendering Functions (Additional)
569
+ // ============================================================================
570
+
571
+ /** Render options */
572
+ export interface RenderOptions {
573
+ cache?: boolean;
574
+ pretty?: boolean;
575
+ minify?: boolean;
576
+ streaming?: boolean;
577
+ chunkSize?: number;
578
+ }
579
+
580
+ /** Render component to string */
581
+ export function render(component: CoherentNode, options?: RenderOptions): string;
582
+
583
+ /** Render multiple components in batch */
584
+ export function renderBatch(components: CoherentNode[], options?: RenderOptions): string[];
585
+
586
+ /** Render to chunks generator */
587
+ export function renderToChunks(component: CoherentNode, options?: RenderOptions): Generator<string, void, unknown>;
588
+
589
+ /** Render to stream async generator */
590
+ export function renderToStream(component: CoherentNode, options?: RenderOptions): AsyncGenerator<string, void, unknown>;
591
+
592
+ /** Get rendering cache */
593
+ export function getCache(): Map<string, any>;
594
+
595
+ /** Reset rendering cache */
596
+ export function resetCache(): void;
597
+
598
+ /** Get rendering statistics */
599
+ export function getRenderingStats(): {
600
+ totalRenders: number;
601
+ cacheHits: number;
602
+ cacheMisses: number;
603
+ averageRenderTime: number;
604
+ };
605
+
606
+ /** Precompile component for faster rendering */
607
+ export function precompileComponent(component: CoherentNode, options?: RenderOptions): any;
608
+
609
+ /** Render with timing information */
610
+ export function renderWithTiming(component: CoherentNode, options?: RenderOptions): {
611
+ html: string;
612
+ time: number;
613
+ metrics: Record<string, any>;
614
+ };
615
+
616
+ // ============================================================================
617
+ // CSS Management (Additional)
618
+ // ============================================================================
619
+
620
+ /** CSS manager for component styles */
621
+ export class CSSManager {
622
+ addStyles(componentId: string, styles: string | Record<string, any>): void;
623
+ removeStyles(componentId: string): void;
624
+ getStyles(componentId?: string): string;
625
+ getAllStyles(): string;
626
+ clearStyles(): void;
627
+ hasStyles(componentId: string): boolean;
628
+ }
629
+
630
+ // ============================================================================
631
+ // Performance Monitoring (Additional)
632
+ // ============================================================================
633
+
634
+ /** Performance monitor class */
635
+ export class PerformanceMonitor {
636
+ startRender(id?: string): string;
637
+ endRender(id: string): number;
638
+ recordRender(type: string, duration: number, metadata?: any): void;
639
+ getMetrics(): Record<string, any>;
640
+ clearMetrics(): void;
641
+ enableMonitoring(): void;
642
+ disableMonitoring(): void;
643
+ isEnabled(): boolean;
644
+ }
645
+
646
+ /** Global performance monitor instance */
647
+ export const performanceMonitor: PerformanceMonitor;
648
+
649
+ // ============================================================================
650
+ // Cache Management (Additional)
651
+ // ============================================================================
652
+
653
+ /** Cache manager options */
654
+ export interface CacheManagerOptions {
655
+ maxSize?: number;
656
+ ttl?: number;
657
+ strategy?: 'lru' | 'fifo' | 'lfu';
658
+ }
659
+
660
+ /** Cache manager interface */
661
+ export interface CacheManager {
662
+ get(key: string): any;
663
+ set(key: string, value: any, ttl?: number): void;
664
+ has(key: string): boolean;
665
+ delete(key: string): boolean;
666
+ clear(): void;
667
+ size(): number;
668
+ prune(): void;
669
+ }
670
+
671
+ /** Create cache manager */
672
+ export function createCacheManager(options?: CacheManagerOptions): CacheManager;
673
+
674
+ /** Global cache manager instance */
675
+ export const cacheManager: CacheManager;
676
+
677
+ // ============================================================================
678
+ // Bundle Optimization (Additional)
679
+ // ============================================================================
680
+
681
+ /** Bundle optimizer class */
682
+ export class BundleOptimizer {
683
+ analyze(bundle: any): any;
684
+ optimize(bundle: any): any;
685
+ splitChunks(bundle: any): any[];
686
+ treeshake(bundle: any): any;
687
+ }
688
+
689
+ /** Global bundle optimizer instance */
690
+ export const bundleOptimizer: BundleOptimizer;
691
+
692
+ // ============================================================================
693
+ // Component Cache (Additional)
694
+ // ============================================================================
695
+
696
+ /** Component cache class */
697
+ export class ComponentCache {
698
+ cache(key: string, component: CoherentNode): void;
699
+ get(key: string): CoherentNode | undefined;
700
+ invalidate(key: string): void;
701
+ invalidateAll(): void;
702
+ }
703
+
704
+ /** Create component cache */
705
+ export function createComponentCache(options?: CacheManagerOptions): ComponentCache;
706
+
707
+ // ============================================================================
708
+ // Utility Types and Constants
709
+ // ============================================================================
710
+
711
+ /** Framework version */
712
+ export const VERSION: string;
713
+
714
+ /** Composition utilities */
715
+ export const compose: ComposeUtils;
716
+
717
+ /** Component utilities */
718
+ export const componentUtils: ComponentUtils;
719
+
720
+ /** Default export with all core functionality */
721
+ declare const coherent: {
722
+ render: typeof render;
723
+ render: typeof render;
724
+ renderSync: typeof renderSync;
725
+ withState: typeof withState;
726
+ memo: typeof memo;
727
+ validateComponent: typeof validateComponent;
728
+ isCoherentObject: typeof isCoherentObject;
729
+ deepClone: typeof deepClone;
730
+ escapeHtml: typeof escapeHtml;
731
+ VERSION: typeof VERSION;
732
+ };
733
+
734
+ export default coherent;