@servlyadmin/runtime-core 0.1.36 → 0.1.38

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/index.d.ts DELETED
@@ -1,1973 +0,0 @@
1
- /**
2
- * Servly Runtime Core Types
3
- * Framework-agnostic type definitions for Layout JSON rendering
4
- */
5
- /**
6
- * Configuration options for an element
7
- */
8
- interface ElementConfig {
9
- /** HTML tag override */
10
- tag?: string;
11
- /** Static text content */
12
- text?: string;
13
- /** Dynamic text with template bindings */
14
- dynamicText?: string;
15
- /** CSS class name */
16
- className?: string;
17
- /** Additional CSS class names */
18
- classNames?: string;
19
- /** Dynamic class name with template bindings */
20
- dynamicClassName?: string;
21
- /** CSS variables to apply */
22
- cssVariables?: Record<string, string>;
23
- /** Element ID */
24
- id?: string;
25
- /** Image source */
26
- src?: string;
27
- /** Dynamic image source */
28
- dynamicSrc?: string;
29
- /** Dynamic href */
30
- dynamicHref?: string;
31
- /** Dynamic value */
32
- dynamicValue?: string;
33
- /** Alt text for images */
34
- alt?: string;
35
- /** Link href */
36
- href?: string;
37
- /** Link target */
38
- target?: string;
39
- /** Input placeholder */
40
- placeholder?: string;
41
- /** Input type */
42
- type?: string;
43
- /** Input name */
44
- name?: string;
45
- /** Input value */
46
- value?: string;
47
- /** Disabled state */
48
- disabled?: boolean;
49
- /** Required state */
50
- required?: boolean;
51
- /** Read-only state */
52
- readOnly?: boolean;
53
- /** Inline styles */
54
- style?: Record<string, any>;
55
- /** Icon configuration for icon elements */
56
- icon?: {
57
- /** Icon name (e.g., 'FaHouse', 'MdSettings') */
58
- name: string;
59
- /** Icon set prefix (e.g., 'Fa6', 'Md', 'Lu') */
60
- set: string;
61
- /** Human-readable icon set name */
62
- setName?: string;
63
- };
64
- /** Icon color */
65
- iconColor?: string;
66
- /** Icon size in pixels */
67
- iconSize?: number;
68
- /** Input bindings for props */
69
- bindings?: {
70
- inputs?: Record<string, {
71
- source: 'static' | 'props' | 'state' | 'parent' | 'function';
72
- value?: any;
73
- path?: string;
74
- binding?: any;
75
- }>;
76
- };
77
- /** Reference to another component (for componentView elements) */
78
- componentViewRef?: string;
79
- /** Version specifier for the referenced component */
80
- componentViewVersion?: string;
81
- /** Props to pass to the referenced component */
82
- componentViewProps?: Record<string, any>;
83
- /** Blueprint ID for renderDynamicList */
84
- blueprint?: string;
85
- /** Blueprint version specifier */
86
- blueprintVersion?: string;
87
- /** Slot name for slot elements */
88
- slotName?: string;
89
- /** Fallback content for empty slots */
90
- fallback?: any[];
91
- /** Data attributes */
92
- [key: `data-${string}`]: string | undefined;
93
- /** Aria attributes */
94
- [key: `aria-${string}`]: string | undefined;
95
- }
96
- /**
97
- * A single element in the Layout JSON tree
98
- */
99
- interface LayoutElement {
100
- /** Unique element identifier */
101
- i: string;
102
- /** Component type (container, text, button, etc.) */
103
- componentId: string;
104
- /** Parent element ID (null for root elements) */
105
- parent?: string | null;
106
- /** Element configuration */
107
- configuration?: ElementConfig;
108
- /** Inline styles */
109
- style?: Record<string, any>;
110
- /** CSS class name */
111
- className?: string;
112
- /** Whether this is a group/container */
113
- isGroup?: boolean;
114
- /** Child element IDs */
115
- children?: string[];
116
- /** Element name for debugging */
117
- name?: string;
118
- /** Slot name (for slot elements that can receive external content) */
119
- slotName?: string;
120
- }
121
- /**
122
- * Context for resolving template bindings
123
- */
124
- interface BindingContext {
125
- /** Props passed to the component */
126
- props: Record<string, any>;
127
- /** Component state */
128
- state?: Record<string, any>;
129
- /** Additional context data */
130
- context?: Record<string, any>;
131
- }
132
- /**
133
- * Registry of available components for dependency resolution
134
- */
135
- interface ComponentRegistry {
136
- /** Get component by ID and optional version */
137
- get(id: string, version?: string): BundledComponent | undefined;
138
- /** Check if component exists */
139
- has(id: string, version?: string): boolean;
140
- /** Register a component */
141
- set(id: string, version: string, component: BundledComponent): void;
142
- }
143
- /**
144
- * Icon renderer callback type
145
- * Returns an HTMLElement representing the icon, or null if icon not found
146
- */
147
- type IconRenderer = (icon: {
148
- name: string;
149
- set: string;
150
- setName?: string;
151
- }, size?: number, color?: string, className?: string) => HTMLElement | null;
152
- /**
153
- * Options for rendering a component
154
- */
155
- interface RenderOptions {
156
- /** Container element to render into */
157
- container: HTMLElement;
158
- /** Layout elements to render */
159
- elements: LayoutElement[];
160
- /** Binding context for template resolution */
161
- context: BindingContext;
162
- /** Event handlers keyed by element ID then event name */
163
- eventHandlers?: Record<string, Record<string, (e: Event) => void>>;
164
- /** Registry of components for resolving componentViewRef and blueprints */
165
- componentRegistry?: ComponentRegistry;
166
- /** Callback when a dependency needs to be loaded */
167
- onDependencyNeeded?: (id: string, version?: string) => Promise<BundledComponent | undefined>;
168
- /** Callback when rendering a referenced component */
169
- onComponentRender?: (id: string, container: HTMLElement) => void;
170
- /**
171
- * Views for isComponentView resolution
172
- * Can be either:
173
- * - Map<string, { id: string; layout: LayoutElement[]; props?: any }> (pre-converted)
174
- * - Array<{ id: string; layout: LayoutElement[]; props?: any }> (direct from API)
175
- */
176
- views?: Map<string, {
177
- id: string;
178
- layout: LayoutElement[];
179
- props?: any;
180
- }> | Array<{
181
- id: string;
182
- layout: LayoutElement[];
183
- props?: any;
184
- }>;
185
- /** Enable built-in state management for Servly plugin actions */
186
- enableStateManager?: boolean;
187
- /** Initial state for the state manager */
188
- initialState?: Record<string, any>;
189
- /** Callback when state changes */
190
- onStateChange?: (event: {
191
- key: string;
192
- value: any;
193
- previousValue: any;
194
- }) => void;
195
- /** Custom plugin executors for event system */
196
- pluginExecutors?: Record<string, (action: any, context: any) => any>;
197
- /** Callback when navigation is requested */
198
- onNavigate?: (url: string, options?: {
199
- replace?: boolean;
200
- state?: any;
201
- }) => void;
202
- /** Callback for external API calls */
203
- onApiCall?: (config: any) => Promise<any>;
204
- /** Custom icon renderer callback for rendering icon elements */
205
- iconRenderer?: IconRenderer;
206
- /** Disable automatic Tailwind CSS injection (default: false) */
207
- disableTailwind?: boolean;
208
- }
209
- /**
210
- * Result of a render operation
211
- */
212
- interface RenderResult {
213
- /** Root DOM element created */
214
- rootElement: HTMLElement | null;
215
- /** Update the rendered component with new context */
216
- update: (context: BindingContext) => void;
217
- /** Destroy the rendered component and clean up */
218
- destroy: () => void;
219
- }
220
- /**
221
- * Prop definition for a component
222
- */
223
- interface PropDefinition {
224
- /** Prop name */
225
- name: string;
226
- /** Prop type */
227
- type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';
228
- /** Whether the prop is required */
229
- required: boolean;
230
- /** Default value if not provided */
231
- defaultValue?: any;
232
- /** Description for documentation */
233
- description?: string;
234
- }
235
- /**
236
- * Test case assertion
237
- */
238
- interface Assertion$1 {
239
- /** CSS selector to find element */
240
- selector: string;
241
- /** Property to check */
242
- property: 'text' | 'attribute' | 'style' | 'exists' | 'class';
243
- /** Attribute name (for attribute checks) */
244
- attributeName?: string;
245
- /** Style property name (for style checks) */
246
- styleName?: string;
247
- /** Expected value */
248
- expected: any;
249
- }
250
- /**
251
- * Test case for component validation
252
- */
253
- interface TestCase$1 {
254
- /** Unique test case ID */
255
- id: string;
256
- /** Test case name */
257
- name: string;
258
- /** Props to use for this test */
259
- props: Record<string, any>;
260
- /** Assertions to validate */
261
- assertions?: Assertion$1[];
262
- }
263
- /**
264
- * Type of component dependency
265
- */
266
- type DependencyType = 'blueprint' | 'viewRef' | 'slot';
267
- /**
268
- * Single dependency entry in manifest
269
- */
270
- interface DependencyEntry {
271
- /** Requested version specifier (e.g., "^1.0.0") */
272
- version: string;
273
- /** Actual resolved version (e.g., "1.2.3") */
274
- resolved: string;
275
- /** Type of dependency */
276
- type: DependencyType;
277
- /** Parent dependency ID (for nested deps) */
278
- via?: string;
279
- /** If true, component works without this dependency */
280
- optional?: boolean;
281
- }
282
- /**
283
- * Manifest of all component dependencies
284
- */
285
- interface DependencyManifest {
286
- [componentId: string]: DependencyEntry;
287
- }
288
- /**
289
- * Bundled component data (minimal for bundle)
290
- */
291
- interface BundledComponent {
292
- /** Layout JSON elements */
293
- layout: LayoutElement[];
294
- /** Props interface definition */
295
- propsInterface?: PropDefinition[];
296
- }
297
- /**
298
- * Bundle of all dependencies
299
- * Key format: "componentId@version"
300
- */
301
- interface ComponentBundle {
302
- [componentIdAtVersion: string]: BundledComponent;
303
- }
304
- /**
305
- * View data structure (matches application views)
306
- */
307
- interface ViewData {
308
- /** View ID */
309
- id: string;
310
- /** View name */
311
- name?: string;
312
- /** Layout JSON elements */
313
- layout: LayoutElement[];
314
- /** Props interface definition */
315
- propsInterface?: PropDefinition[];
316
- /** Whether this is the main/entry view */
317
- isMain?: boolean;
318
- }
319
- /**
320
- * Component data from registry
321
- */
322
- interface ComponentData {
323
- /** Component ID */
324
- id: string;
325
- /** Component name */
326
- name: string;
327
- /** Component description */
328
- description?: string;
329
- /** Component version */
330
- version: string;
331
- /** Layout JSON elements */
332
- layout: LayoutElement[];
333
- /** Props interface definition */
334
- propsInterface?: PropDefinition[];
335
- /** Test cases for validation */
336
- testCases?: TestCase$1[];
337
- /** CSS variables used */
338
- cssVariables?: Record<string, string>;
339
- /** Component tags for search */
340
- tags?: string[];
341
- /** Created timestamp */
342
- createdAt?: string;
343
- /** Updated timestamp */
344
- updatedAt?: string;
345
- /** Dependency manifest - lists all required components */
346
- dependencies?: DependencyManifest;
347
- /** Bundled dependencies - included component data */
348
- bundle?: ComponentBundle;
349
- /** All views needed to render this component (returned by API) */
350
- views?: ViewData[];
351
- }
352
- /**
353
- * Cache entry for component data
354
- */
355
- interface CacheEntry {
356
- /** Cached component data */
357
- data: ComponentData;
358
- /** Timestamp when cached */
359
- timestamp: number;
360
- /** Version of cached component */
361
- version: string;
362
- /** Number of times accessed */
363
- accessCount: number;
364
- /** Last access timestamp */
365
- lastAccessed: number;
366
- }
367
- /**
368
- * Cache configuration
369
- */
370
- interface CacheConfig {
371
- /** Maximum number of entries in cache */
372
- maxEntries?: number;
373
- /** Time-to-live in milliseconds */
374
- ttl?: number;
375
- /** Storage key prefix for localStorage */
376
- storageKeyPrefix?: string;
377
- }
378
- /**
379
- * Cache strategy type
380
- */
381
- type CacheStrategy = 'memory' | 'localStorage' | 'none';
382
- /**
383
- * Retry configuration for failed fetches
384
- */
385
- interface RetryConfig {
386
- /** Maximum number of retries */
387
- maxRetries?: number;
388
- /** Initial delay in ms */
389
- initialDelay?: number;
390
- /** Maximum delay in ms */
391
- maxDelay?: number;
392
- /** Backoff multiplier */
393
- backoffMultiplier?: number;
394
- }
395
- /**
396
- * Bundle loading strategy
397
- */
398
- type BundleStrategy = 'eager' | 'lazy' | 'none';
399
- /**
400
- * Options for fetching a component
401
- */
402
- interface FetchOptions {
403
- /** Version specifier */
404
- version?: string;
405
- /** API key for authentication */
406
- apiKey?: string;
407
- /** Cache strategy */
408
- cacheStrategy?: CacheStrategy;
409
- /** Cache configuration */
410
- cacheConfig?: CacheConfig;
411
- /** Retry configuration */
412
- retryConfig?: Partial<RetryConfig>;
413
- /** Skip cache and force fetch */
414
- forceRefresh?: boolean;
415
- /** Abort signal for cancellation */
416
- signal?: AbortSignal;
417
- /** How to handle dependencies: eager (bundle all), lazy (fetch on demand), none */
418
- bundleStrategy?: BundleStrategy;
419
- /** Include bundled dependencies in response */
420
- includeBundle?: boolean;
421
- /** Maximum bundle size in bytes before switching to lazy */
422
- maxBundleSize?: number;
423
- /** Include all views needed to render this component (default: true) */
424
- includeViews?: boolean;
425
- }
426
- /**
427
- * Result of a fetch operation
428
- */
429
- interface FetchResult {
430
- /** Fetched component data */
431
- data: ComponentData;
432
- /** Whether data came from cache */
433
- fromCache: boolean;
434
- /** Resolved version */
435
- version: string;
436
- /** Pre-built component registry from bundle */
437
- registry?: ComponentRegistry;
438
- /** List of dependencies that need lazy loading */
439
- pendingDependencies?: Array<{
440
- id: string;
441
- version: string;
442
- }>;
443
- /** Views map built from API response (ready for render()) */
444
- views?: Map<string, {
445
- id: string;
446
- layout: LayoutElement[];
447
- props?: any;
448
- }>;
449
- }
450
- /**
451
- * Result of a single assertion
452
- */
453
- interface AssertionResult$1 {
454
- /** Whether assertion passed */
455
- passed: boolean;
456
- /** The assertion that was checked */
457
- assertion: Assertion$1;
458
- /** Actual value found */
459
- actual?: any;
460
- /** Error message if failed */
461
- error?: string;
462
- }
463
- /**
464
- * Result of running a test case
465
- */
466
- interface TestCaseResult {
467
- /** Test case ID */
468
- id: string;
469
- /** Test case name */
470
- name: string;
471
- /** Whether all assertions passed */
472
- passed: boolean;
473
- /** Individual assertion results */
474
- assertions: AssertionResult$1[];
475
- /** Execution time in ms */
476
- duration: number;
477
- }
478
- /**
479
- * Summary of all test results
480
- */
481
- interface TestSummary$1 {
482
- /** Total number of tests */
483
- total: number;
484
- /** Number of passed tests */
485
- passed: number;
486
- /** Number of failed tests */
487
- failed: number;
488
- /** Individual test results */
489
- results: TestCaseResult[];
490
- /** Total execution time in ms */
491
- duration: number;
492
- }
493
-
494
- /**
495
- * Vanilla DOM Renderer
496
- * Renders Layout JSON to native DOM elements
497
- * Supports component dependencies via componentViewRef, isComponentView, and blueprint
498
- *
499
- * This renderer is designed to produce output consistent with RenderElements.tsx
500
- * in the builder, enabling preview and production rendering to match.
501
- */
502
-
503
- /**
504
- * Render Layout JSON to DOM
505
- */
506
- declare function render(options: RenderOptions): RenderResult;
507
- /**
508
- * Render a dynamic list using a blueprint component
509
- * This is called by event handlers that use renderDynamicList
510
- */
511
- declare function renderDynamicList(options: {
512
- /** Target container element or selector */
513
- targetContainer: HTMLElement | string;
514
- /** Blueprint component ID */
515
- blueprint: string;
516
- /** Blueprint version (optional) */
517
- blueprintVersion?: string;
518
- /** Data array to render */
519
- data: any[];
520
- /** How to render: 'renderInto' clears container, 'append' adds to end */
521
- renderType?: 'renderInto' | 'append' | 'prepend';
522
- /** Item variable name in template (default: 'item') */
523
- itemKey?: string;
524
- /** Index variable name in template (default: 'index') */
525
- indexKey?: string;
526
- /** Component registry for blueprint lookup */
527
- componentRegistry: ComponentRegistry;
528
- /** Parent context */
529
- context?: BindingContext;
530
- }): RenderResult[];
531
- /**
532
- * Render a single node/element by ID from a layout
533
- * Useful for rendering specific parts of a component
534
- */
535
- declare function renderNode(options: {
536
- /** Container element to render into */
537
- container: HTMLElement;
538
- /** All layout elements */
539
- elements: LayoutElement[];
540
- /** ID of the node to render */
541
- nodeId: string;
542
- /** Binding context */
543
- context: BindingContext;
544
- /** Whether to include children */
545
- includeChildren?: boolean;
546
- /** Event handlers */
547
- eventHandlers?: Record<string, Record<string, (e: Event) => void>>;
548
- /** Component registry */
549
- componentRegistry?: ComponentRegistry;
550
- /** Views map */
551
- views?: Map<string, {
552
- id: string;
553
- layout: LayoutElement[];
554
- props?: any;
555
- }>;
556
- }): RenderResult | null;
557
- /**
558
- * Render into a shadow DOM for style isolation
559
- */
560
- declare function renderInShadow(options: RenderOptions & {
561
- /** Shadow DOM mode */
562
- mode?: 'open' | 'closed';
563
- /** Styles to inject into shadow DOM */
564
- styles?: string;
565
- /** Whether to inject Tailwind CSS */
566
- injectTailwind?: boolean;
567
- }): RenderResult & {
568
- shadowRoot: ShadowRoot;
569
- };
570
- /**
571
- * Create a standalone Servly renderer with Tailwind CSS
572
- * This is the main entry point for standalone usage
573
- */
574
- declare function createServlyRenderer(options: {
575
- /** Container element or selector */
576
- container: HTMLElement | string;
577
- /** Whether to inject Tailwind CSS */
578
- injectTailwind?: boolean;
579
- /** Custom Tailwind config */
580
- tailwindConfig?: Record<string, any>;
581
- /** Initial state */
582
- initialState?: Record<string, any>;
583
- /** State change callback */
584
- onStateChange?: (event: {
585
- key: string;
586
- value: any;
587
- previousValue: any;
588
- }) => void;
589
- /** Navigation callback */
590
- onNavigate?: (url: string, options?: {
591
- replace?: boolean;
592
- state?: any;
593
- }) => void;
594
- }): Promise<{
595
- render: (elements: LayoutElement[], context?: BindingContext) => RenderResult;
596
- renderNode: (elements: LayoutElement[], nodeId: string, context?: BindingContext) => RenderResult | null;
597
- renderDynamicList: typeof renderDynamicList;
598
- destroy: () => void;
599
- }>;
600
- /**
601
- * Create a views Map from an array of view objects
602
- * Helper function to convert application views to the format expected by render()
603
- *
604
- * @param views - Array of view objects with id and layout
605
- * @returns Map of view ID to view data
606
- */
607
- declare function createViewsMap(views: Array<{
608
- id?: string;
609
- _id?: string;
610
- layout: LayoutElement[];
611
- props?: any;
612
- }>): Map<string, {
613
- id: string;
614
- layout: LayoutElement[];
615
- props?: any;
616
- }>;
617
- /**
618
- * Extract all component view IDs referenced in a layout
619
- * Useful for pre-fetching required views
620
- *
621
- * @param elements - Layout elements to scan
622
- * @returns Array of unique view IDs referenced
623
- */
624
- declare function extractReferencedViewIds(elements: LayoutElement[]): string[];
625
- /**
626
- * Recursively extract all view IDs from a set of views
627
- * Follows component view references to find all dependencies
628
- *
629
- * @param views - Map of all available views
630
- * @param startViewId - The view to start from
631
- * @returns Set of all view IDs needed to render the start view
632
- */
633
- declare function collectAllViewDependencies(views: Map<string, {
634
- id: string;
635
- layout: LayoutElement[];
636
- }>, startViewId: string): Set<string>;
637
-
638
- /**
639
- * Template Binding Resolution
640
- * Resolves {{path}} syntax in templates using binding context
641
- *
642
- * This module provides template resolution similar to RenderElements.tsx's
643
- * retrieveBody function, but in a framework-agnostic way.
644
- */
645
-
646
- /**
647
- * Check if a string contains template syntax
648
- */
649
- declare function hasTemplateSyntax(value: unknown): value is string;
650
- /**
651
- * Resolve a binding path to its value from context
652
- *
653
- * @param path - The path to resolve (e.g., "props.title", "state.count")
654
- * @param context - The binding context containing props, state, context
655
- * @returns The resolved value or undefined if not found
656
- */
657
- declare function resolveBindingPath(path: string, context: BindingContext): any;
658
- /**
659
- * Resolve a template string with bindings
660
- * Replaces all {{path}} occurrences with resolved values
661
- *
662
- * @param template - The template string containing {{path}} bindings
663
- * @param context - The binding context
664
- * @param componentId - Optional component ID for error tracking
665
- * @returns The resolved string
666
- */
667
- declare function resolveTemplate(template: string, context: BindingContext, componentId?: string): string;
668
- /**
669
- * Resolve a template and return the raw value (not stringified)
670
- * Useful for non-string values like objects, arrays, booleans
671
- *
672
- * @param template - The template string
673
- * @param context - The binding context
674
- * @param componentId - Optional component ID for error tracking
675
- */
676
- declare function resolveTemplateValue(template: string, context: BindingContext, componentId?: string): any;
677
- /**
678
- * Recursively resolve all template bindings in an object or array
679
- *
680
- * @param input - The input value (string, object, array, or primitive)
681
- * @param context - The binding context
682
- * @returns The input with all templates resolved
683
- */
684
- declare function resolveTemplatesDeep<T>(input: T, context: BindingContext): T;
685
- /**
686
- * Extract all binding keys from a template string
687
- *
688
- * @param template - The template string
689
- * @returns Array of binding keys found
690
- */
691
- declare function extractBindingKeys(template: string): string[];
692
-
693
- /**
694
- * Style Processing
695
- * Handles CSS styles, variables, and class names for DOM elements
696
- */
697
-
698
- /**
699
- * Convert camelCase to kebab-case
700
- */
701
- declare function camelToKebab(str: string): string;
702
- /**
703
- * Format a style value, adding px units if needed
704
- */
705
- declare function formatStyleValue(property: string, value: any): string;
706
- /**
707
- * Process a style object, resolving templates and formatting values
708
- */
709
- declare function processStyles(style: Record<string, any> | undefined, context: BindingContext): Record<string, string>;
710
- /**
711
- * Apply styles to a DOM element
712
- */
713
- declare function applyStyles(element: HTMLElement, styles: Record<string, string>): void;
714
- /**
715
- * Build combined styles from element configuration
716
- */
717
- declare function buildElementStyles(element: LayoutElement, context: BindingContext): Record<string, string>;
718
- /**
719
- * Build class name string from element configuration
720
- */
721
- declare function buildClassName(element: LayoutElement, context: BindingContext): string;
722
- /**
723
- * Clear all inline styles from an element
724
- */
725
- declare function clearStyles(element: HTMLElement): void;
726
- /**
727
- * Update styles on an element (diff and patch)
728
- */
729
- declare function updateStyles(element: HTMLElement, oldStyles: Record<string, string>, newStyles: Record<string, string>): void;
730
-
731
- /**
732
- * Component Cache System
733
- * In-memory and localStorage caching with LRU eviction
734
- */
735
-
736
- /** Default cache configuration */
737
- declare const DEFAULT_CACHE_CONFIG: Required<CacheConfig>;
738
- /**
739
- * Generate cache key for component
740
- */
741
- declare function getCacheKey(id: string, version?: string): string;
742
- /**
743
- * Clear memory cache
744
- */
745
- declare function clearMemoryCache(): void;
746
- /**
747
- * Get memory cache size
748
- */
749
- declare function getMemoryCacheSize(): number;
750
- /**
751
- * Clear localStorage cache
752
- */
753
- declare function clearLocalStorageCache(config?: CacheConfig): void;
754
- /**
755
- * Get component from cache (tries memory first, then localStorage)
756
- */
757
- declare function getFromCache(id: string, version?: string, strategy?: CacheStrategy, config?: CacheConfig): ComponentData | null;
758
- /**
759
- * Set component in cache
760
- */
761
- declare function setInCache(id: string, version: string, data: ComponentData, strategy?: CacheStrategy, config?: CacheConfig): void;
762
- /**
763
- * Clear all caches
764
- */
765
- declare function clearAllCaches(config?: CacheConfig): void;
766
- /**
767
- * Invalidate specific component from all caches
768
- */
769
- declare function invalidateCache(id: string, version?: string, config?: CacheConfig): void;
770
-
771
- /**
772
- * View Registry Fetcher
773
- * Fetches view data from the View Registry API with retry logic
774
- *
775
- * API Base: /api/views/registry
776
- * Supports: versioning, bundling, batch fetch, dependency resolution
777
- */
778
-
779
- /** Default retry configuration */
780
- declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
781
- /**
782
- * Configure the registry base URL
783
- */
784
- declare function setRegistryUrl(url: string): void;
785
- /**
786
- * Get the registry base URL
787
- */
788
- declare function getRegistryUrl(): string;
789
- /**
790
- * Fetch component with caching and retry
791
- */
792
- declare function fetchComponent(id: string, options?: FetchOptions): Promise<FetchResult>;
793
- /**
794
- * Fetch component with all dependencies resolved
795
- * Convenience wrapper that handles lazy loading
796
- */
797
- declare function fetchComponentWithDependencies(id: string, options?: FetchOptions): Promise<FetchResult>;
798
- /**
799
- * Batch fetch multiple views in a single request
800
- * Uses: POST /api/views/registry/batch
801
- */
802
- declare function batchFetchComponents(components: Array<{
803
- id: string;
804
- version?: string;
805
- }>, options?: Pick<FetchOptions, 'apiKey'>): Promise<Record<string, BundledComponent>>;
806
- /**
807
- * Prefetch views for faster loading
808
- * Uses: POST /api/views/registry/prefetch for version resolution
809
- */
810
- declare function prefetchComponents(ids: Array<{
811
- id: string;
812
- version?: string;
813
- }>, options?: Omit<FetchOptions, 'version'>): Promise<void>;
814
- /**
815
- * Check if view is available (in cache or online)
816
- * Uses: GET /api/views/registry/:viewId/available?version=^1.0.0
817
- */
818
- declare function isComponentAvailable(id: string, version?: string, options?: Pick<FetchOptions, 'apiKey' | 'cacheStrategy' | 'cacheConfig'>): Promise<{
819
- available: boolean;
820
- cached: boolean;
821
- version?: string;
822
- }>;
823
- /**
824
- * Get dependency tree for a view
825
- * Uses: GET /api/views/registry/:viewId/dependencies?version=^1.0.0&depth=10
826
- */
827
- declare function getDependencyTree(id: string, options?: {
828
- version?: string;
829
- depth?: number;
830
- apiKey?: string;
831
- }): Promise<{
832
- tree: any;
833
- totalDependencies: number;
834
- maxDepthReached: number;
835
- }>;
836
-
837
- /**
838
- * Semantic Version Utilities
839
- * Parsing, comparison, and range resolution for semver
840
- */
841
- /** Parsed semantic version */
842
- interface ParsedVersion {
843
- major: number;
844
- minor: number;
845
- patch: number;
846
- }
847
- /**
848
- * Parse a semantic version string
849
- * @returns Parsed version or null if invalid
850
- */
851
- declare function parseVersion(version: string): ParsedVersion | null;
852
- /**
853
- * Compare two versions
854
- * @returns -1 if a < b, 0 if a == b, 1 if a > b
855
- */
856
- declare function compareVersions(a: string, b: string): number;
857
- /**
858
- * Check if a version satisfies a specifier
859
- * Supports: exact (1.2.3), caret (^1.2.3), tilde (~1.2.3), latest, *
860
- */
861
- declare function satisfiesVersion(version: string, specifier: string): boolean;
862
- /**
863
- * Find the best matching version from a list
864
- * @param versions - Available versions (sorted newest first recommended)
865
- * @param specifier - Version specifier to match
866
- * @returns Best matching version or null if none match
867
- */
868
- declare function resolveVersion(versions: string[], specifier?: string): string | null;
869
- /**
870
- * Get next version based on bump type
871
- */
872
- declare function bumpVersion(currentVersion: string, bumpType: 'major' | 'minor' | 'patch'): string;
873
- /**
874
- * Check if a string is a valid version specifier
875
- */
876
- declare function isValidSpecifier(specifier: string): boolean;
877
- /**
878
- * Format a version for display
879
- */
880
- declare function formatVersion(version: string): string;
881
-
882
- /**
883
- * Test Runner for Servly Components
884
- *
885
- * Runs test cases against components to validate prop behavior
886
- * and DOM output matches expected assertions.
887
- */
888
-
889
- interface TestCase {
890
- id: string;
891
- name: string;
892
- description?: string;
893
- props: Record<string, any>;
894
- assertions: Assertion[];
895
- }
896
- interface Assertion {
897
- type: 'exists' | 'text' | 'attribute' | 'class' | 'style' | 'count' | 'visible';
898
- selector: string;
899
- expected?: any;
900
- attribute?: string;
901
- property?: string;
902
- }
903
- interface TestResult {
904
- testId: string;
905
- testName: string;
906
- passed: boolean;
907
- assertions: AssertionResult[];
908
- duration: number;
909
- error?: string;
910
- }
911
- interface AssertionResult {
912
- assertion: Assertion;
913
- passed: boolean;
914
- actual?: any;
915
- expected?: any;
916
- message?: string;
917
- }
918
- interface TestSummary {
919
- total: number;
920
- passed: number;
921
- failed: number;
922
- duration: number;
923
- results: TestResult[];
924
- }
925
- /**
926
- * Run a single test case against a component
927
- */
928
- declare function runTestCase(elements: LayoutElement[], testCase: TestCase, container?: HTMLElement): TestResult;
929
- /**
930
- * Run all test cases for a component
931
- */
932
- declare function runAllTests(elements: LayoutElement[], testCases: TestCase[]): TestSummary;
933
- /**
934
- * Validate a single assertion against the DOM
935
- */
936
- declare function validateAssertion(container: HTMLElement, assertion: Assertion): AssertionResult;
937
- /**
938
- * Validate props against prop definitions
939
- */
940
- declare function validateProps(props: Record<string, any>, definitions: PropDefinition[]): {
941
- valid: boolean;
942
- errors: string[];
943
- };
944
- /**
945
- * Generate test cases from prop definitions
946
- */
947
- declare function generateTestCases(definitions: PropDefinition[]): TestCase[];
948
-
949
- /**
950
- * Component Registry
951
- *
952
- * Manages a collection of components for dependency resolution.
953
- * Used by the renderer to resolve componentViewRef and blueprint references.
954
- */
955
-
956
- /**
957
- * Create a component registry from bundled data
958
- */
959
- declare function createRegistry(): ComponentRegistry;
960
- /**
961
- * Build a registry from component data with bundle
962
- */
963
- declare function buildRegistryFromBundle(data: ComponentData): ComponentRegistry;
964
- /**
965
- * Extract dependencies from layout elements
966
- * Scans for componentViewRef and blueprint references
967
- */
968
- declare function extractDependencies(elements: LayoutElement[]): Array<{
969
- id: string;
970
- version?: string;
971
- type: 'viewRef' | 'blueprint';
972
- elementId: string;
973
- }>;
974
- /**
975
- * Extract dependencies from event handler code
976
- * Looks for renderDynamicList calls
977
- */
978
- declare function extractDependenciesFromCode(code: string): Array<{
979
- id: string;
980
- type: 'blueprint';
981
- }>;
982
- /**
983
- * Recursively collect all dependencies from a component
984
- * Handles nested dependencies (A → B → C)
985
- */
986
- declare function collectAllDependencies(rootId: string, rootVersion: string, fetchComponent: (id: string, version?: string) => Promise<ComponentData | undefined>, maxDepth?: number): Promise<DependencyManifest>;
987
- /**
988
- * Check for circular dependencies
989
- */
990
- declare function detectCircularDependencies(manifest: DependencyManifest): string[] | null;
991
-
992
- /**
993
- * Component Analytics Types
994
- * Type definitions for analytics event collection and transmission
995
- */
996
- /**
997
- * Analytics configuration options
998
- */
999
- interface AnalyticsConfig {
1000
- /** Enable/disable analytics collection */
1001
- enabled: boolean;
1002
- /** Analytics API endpoint */
1003
- endpoint: string;
1004
- /** API key for authentication */
1005
- apiKey?: string;
1006
- /** Application ID to include in all events */
1007
- appId?: string;
1008
- /** Batch size before auto-flush */
1009
- batchSize: number;
1010
- /** Flush interval in milliseconds */
1011
- flushInterval: number;
1012
- /** Sample rate (0-1) for high-volume events */
1013
- sampleRate: number;
1014
- /** Environment identifier */
1015
- environment: 'development' | 'staging' | 'production';
1016
- /** Enable debug logging */
1017
- debug: boolean;
1018
- }
1019
- /**
1020
- * Analytics event types
1021
- */
1022
- type AnalyticsEventType = 'render' | 'fetch' | 'error';
1023
- /**
1024
- * Base analytics event
1025
- */
1026
- interface AnalyticsEvent {
1027
- /** Event type */
1028
- type: AnalyticsEventType;
1029
- /** Component identifier */
1030
- componentId: string;
1031
- /** Component version */
1032
- version: string;
1033
- /** Unix timestamp in milliseconds */
1034
- timestamp: number;
1035
- /** Anonymous session ID */
1036
- sessionId?: string;
1037
- /** Application ID */
1038
- appId?: string;
1039
- /** Duration in milliseconds */
1040
- duration?: number;
1041
- /** Event-specific metadata */
1042
- metadata?: Record<string, unknown>;
1043
- }
1044
- /**
1045
- * Metadata for render events
1046
- */
1047
- interface RenderMetadata {
1048
- /** Number of DOM elements rendered */
1049
- elementCount?: number;
1050
- /** Whether component was served from cache */
1051
- fromCache?: boolean;
1052
- /** Memory heap change in KB (Chrome only) */
1053
- heapDeltaKB?: number;
1054
- /** Number of DOM nodes created */
1055
- domNodesCreated?: number;
1056
- /** Number of long tasks (>50ms) during render */
1057
- longTaskCount?: number;
1058
- /** Whether component has event handlers */
1059
- hasEventHandlers?: boolean;
1060
- /** Whether component has dependencies */
1061
- hasDependencies?: boolean;
1062
- }
1063
- /**
1064
- * Metadata for fetch events
1065
- */
1066
- interface FetchMetadata {
1067
- /** Whether fetch was a cache hit */
1068
- cacheHit: boolean;
1069
- /** Fetch duration in milliseconds */
1070
- fetchDuration: number;
1071
- /** Bundle size in bytes */
1072
- bundleSize?: number;
1073
- /** Number of dependencies */
1074
- dependencyCount?: number;
1075
- }
1076
- /**
1077
- * Error types for error events
1078
- */
1079
- type ErrorType = 'render' | 'fetch' | 'binding';
1080
- /**
1081
- * Metadata for error events
1082
- */
1083
- interface ErrorMetadata {
1084
- /** Type of error */
1085
- errorType: ErrorType;
1086
- /** Error message (max 1000 chars) */
1087
- errorMessage: string;
1088
- /** Stack trace (truncated to 500 chars) */
1089
- stackTrace?: string;
1090
- /** Failed binding path (for binding errors) */
1091
- bindingPath?: string;
1092
- /** Element ID where error occurred */
1093
- elementId?: string;
1094
- }
1095
- /**
1096
- * Client info included in batch requests
1097
- */
1098
- interface ClientInfo {
1099
- /** SDK version */
1100
- sdkVersion: string;
1101
- /** Environment */
1102
- environment: string;
1103
- }
1104
- /**
1105
- * Batch events request body
1106
- */
1107
- interface BatchEventsRequest {
1108
- /** Array of analytics events */
1109
- events: AnalyticsEvent[];
1110
- /** Client information */
1111
- clientInfo: ClientInfo;
1112
- }
1113
- /**
1114
- * Batch events response
1115
- */
1116
- interface BatchEventsResponse {
1117
- /** Whether request was successful */
1118
- success: boolean;
1119
- /** Number of events accepted */
1120
- accepted: number;
1121
- /** Number of events rejected */
1122
- rejected: number;
1123
- /** Error messages for rejected events */
1124
- errors?: string[];
1125
- /** Retry-After header value (for rate limiting) */
1126
- retryAfter?: number;
1127
- }
1128
- /**
1129
- * Session information
1130
- */
1131
- interface SessionInfo {
1132
- /** Session ID */
1133
- id: string;
1134
- /** Timestamp when session was created */
1135
- createdAt: number;
1136
- /** Timestamp of last activity */
1137
- lastActivityAt: number;
1138
- }
1139
-
1140
- /**
1141
- * Component Analytics
1142
- * Collects and transmits component usage, performance, and error metrics
1143
- */
1144
-
1145
- /**
1146
- * Analytics Collector class
1147
- * Manages event collection, batching, and transmission
1148
- */
1149
- declare class AnalyticsCollector {
1150
- private config;
1151
- private eventQueue;
1152
- private flushTimer;
1153
- private isEnabled;
1154
- private isFlushing;
1155
- private retryDelay;
1156
- constructor(config?: Partial<AnalyticsConfig>);
1157
- /**
1158
- * Configure analytics
1159
- */
1160
- configure(config: Partial<AnalyticsConfig>): void;
1161
- /**
1162
- * Disable analytics collection
1163
- */
1164
- disable(): void;
1165
- /**
1166
- * Enable analytics collection
1167
- */
1168
- enable(): void;
1169
- /**
1170
- * Destroy and cleanup
1171
- */
1172
- destroy(): void;
1173
- /**
1174
- * Track component render
1175
- */
1176
- trackRender(componentId: string, version: string, duration: number, metadata?: RenderMetadata): void;
1177
- /**
1178
- * Track component fetch
1179
- */
1180
- trackFetch(componentId: string, version: string, duration: number, fromCache: boolean, metadata?: Partial<FetchMetadata>): void;
1181
- /**
1182
- * Track error
1183
- */
1184
- trackError(componentId: string, version: string, error: Error, context?: Partial<ErrorMetadata>): void;
1185
- /**
1186
- * Check if event should be tracked (sampling + enabled)
1187
- */
1188
- private shouldTrack;
1189
- /**
1190
- * Add event to queue
1191
- */
1192
- private queueEvent;
1193
- /**
1194
- * Get current queue size
1195
- */
1196
- getQueueSize(): number;
1197
- /**
1198
- * Start the flush timer
1199
- */
1200
- private startFlushTimer;
1201
- /**
1202
- * Stop the flush timer
1203
- */
1204
- private stopFlushTimer;
1205
- /**
1206
- * Flush events to server
1207
- */
1208
- flush(): Promise<void>;
1209
- /**
1210
- * Perform the actual flush
1211
- */
1212
- private doFlush;
1213
- /**
1214
- * Send events to the API
1215
- */
1216
- private sendEvents;
1217
- /**
1218
- * Handle failed events (partial success)
1219
- */
1220
- private handleFailedEvents;
1221
- /**
1222
- * Handle network error
1223
- */
1224
- private handleNetworkError;
1225
- /**
1226
- * Schedule a retry flush
1227
- */
1228
- private scheduleRetry;
1229
- /**
1230
- * Truncate string to max length
1231
- */
1232
- private truncateString;
1233
- /**
1234
- * Log debug message
1235
- */
1236
- private log;
1237
- }
1238
- /**
1239
- * Get the analytics collector singleton
1240
- */
1241
- declare function getAnalytics(): AnalyticsCollector;
1242
- /**
1243
- * Configure analytics (convenience function)
1244
- */
1245
- declare function configureAnalytics(config: Partial<AnalyticsConfig>): void;
1246
- /**
1247
- * Reset analytics (for testing)
1248
- */
1249
- declare function resetAnalytics(): void;
1250
- declare const analytics: {
1251
- readonly instance: AnalyticsCollector;
1252
- configure: typeof configureAnalytics;
1253
- trackRender: (componentId: string, version: string, duration: number, metadata?: RenderMetadata) => void;
1254
- trackFetch: (componentId: string, version: string, duration: number, fromCache: boolean, metadata?: Partial<FetchMetadata>) => void;
1255
- trackError: (componentId: string, version: string, error: Error, context?: Partial<ErrorMetadata>) => void;
1256
- flush: () => Promise<void>;
1257
- disable: () => void;
1258
- enable: () => void;
1259
- };
1260
-
1261
- /**
1262
- * Session Manager
1263
- * Manages anonymous session IDs for analytics tracking
1264
- */
1265
-
1266
- /**
1267
- * Session Manager class
1268
- * Manages anonymous session IDs with automatic rotation
1269
- */
1270
- declare class SessionManager {
1271
- private session;
1272
- constructor();
1273
- /**
1274
- * Initialize session manager
1275
- */
1276
- private initialize;
1277
- /**
1278
- * Create a new session
1279
- */
1280
- private createNewSession;
1281
- /**
1282
- * Get current session ID
1283
- * Creates new session if expired
1284
- */
1285
- getSessionId(): string;
1286
- /**
1287
- * Update last activity timestamp
1288
- */
1289
- touch(): void;
1290
- /**
1291
- * Force create a new session
1292
- */
1293
- rotate(): void;
1294
- /**
1295
- * Clear current session
1296
- */
1297
- clear(): void;
1298
- /**
1299
- * Get session info (for debugging)
1300
- */
1301
- getSessionInfo(): SessionInfo | null;
1302
- }
1303
- /**
1304
- * Get the session manager singleton
1305
- */
1306
- declare function getSessionManager(): SessionManager;
1307
- /**
1308
- * Reset the session manager (for testing)
1309
- */
1310
- declare function resetSessionManager(): void;
1311
-
1312
- /**
1313
- * Memory Sampler
1314
- * Samples memory usage using Chrome's performance.memory API
1315
- * Gracefully degrades on unsupported browsers
1316
- */
1317
- /**
1318
- * Memory sample data
1319
- */
1320
- interface MemorySample {
1321
- /** Used JS heap size in KB */
1322
- heapUsedKB: number;
1323
- /** Total JS heap size in KB */
1324
- heapTotalKB: number;
1325
- /** Timestamp when sample was taken */
1326
- timestamp: number;
1327
- }
1328
- /**
1329
- * Memory Sampler class
1330
- * Provides memory sampling functionality for Chrome browsers
1331
- */
1332
- declare class MemorySampler {
1333
- private isSupported;
1334
- constructor();
1335
- /**
1336
- * Check if memory API is available
1337
- */
1338
- private checkSupport;
1339
- /**
1340
- * Check if memory sampling is available
1341
- */
1342
- isAvailable(): boolean;
1343
- /**
1344
- * Take a memory sample
1345
- * Returns null if memory API is not available
1346
- */
1347
- sample(): MemorySample | null;
1348
- /**
1349
- * Calculate heap delta between two samples
1350
- * Returns the difference in KB (positive = memory increased)
1351
- */
1352
- calculateDelta(before: MemorySample | null, after: MemorySample | null): number | null;
1353
- }
1354
- /**
1355
- * Get the memory sampler singleton
1356
- */
1357
- declare function getMemorySampler(): MemorySampler;
1358
- /**
1359
- * Reset the memory sampler (for testing)
1360
- */
1361
- declare function resetMemorySampler(): void;
1362
-
1363
- /**
1364
- * Long Task Observer
1365
- * Observes long tasks (>50ms) using PerformanceObserver API
1366
- * Gracefully degrades on unsupported browsers
1367
- */
1368
- /**
1369
- * Long Task Observer class
1370
- * Counts tasks that take longer than 50ms during a measurement period
1371
- */
1372
- declare class LongTaskObserver {
1373
- private observer;
1374
- private longTaskCount;
1375
- private isSupported;
1376
- private isObserving;
1377
- constructor();
1378
- /**
1379
- * Check if PerformanceObserver with longtask support is available
1380
- */
1381
- private checkSupport;
1382
- /**
1383
- * Check if long task observation is available
1384
- */
1385
- isAvailable(): boolean;
1386
- /**
1387
- * Start observing long tasks
1388
- */
1389
- start(): void;
1390
- /**
1391
- * Stop observing and return the count of long tasks
1392
- */
1393
- stop(): number;
1394
- /**
1395
- * Reset the long task counter
1396
- */
1397
- reset(): void;
1398
- /**
1399
- * Get current count without stopping observation
1400
- */
1401
- getCount(): number;
1402
- /**
1403
- * Check if currently observing
1404
- */
1405
- isActive(): boolean;
1406
- }
1407
- /**
1408
- * Get the long task observer singleton
1409
- */
1410
- declare function getLongTaskObserver(): LongTaskObserver;
1411
- /**
1412
- * Reset the long task observer (for testing)
1413
- */
1414
- declare function resetLongTaskObserver(): void;
1415
-
1416
- /**
1417
- * State Manager for Runtime Core
1418
- * Provides state management capabilities similar to RenderElements.tsx
1419
- * but in a framework-agnostic way.
1420
- */
1421
- interface StateChangeEvent {
1422
- key: string;
1423
- value: any;
1424
- previousValue: any;
1425
- operation: 'set' | 'merge' | 'delete' | 'append' | 'prepend' | 'toggle';
1426
- elementId?: string;
1427
- timestamp: number;
1428
- }
1429
- interface StateManagerConfig {
1430
- /** Initial state */
1431
- initialState?: Record<string, any>;
1432
- /** Callback when state changes */
1433
- onStateChange?: (event: StateChangeEvent) => void;
1434
- /** Whether to persist state to localStorage */
1435
- persistToLocalStorage?: boolean;
1436
- /** localStorage key prefix */
1437
- localStoragePrefix?: string;
1438
- /** Whether to sync with sessionStorage */
1439
- syncWithSessionStorage?: boolean;
1440
- }
1441
- /**
1442
- * Framework-agnostic state manager
1443
- * Provides setState, getState, and state change notifications
1444
- */
1445
- declare class StateManager {
1446
- private state;
1447
- private listeners;
1448
- private config;
1449
- constructor(config?: StateManagerConfig);
1450
- /**
1451
- * Get value by path from state
1452
- */
1453
- get(path: string): any;
1454
- /**
1455
- * Get the entire state object
1456
- */
1457
- getState(): Record<string, any>;
1458
- /**
1459
- * Set a value in state
1460
- */
1461
- set(key: string, value: any, elementId?: string): void;
1462
- /**
1463
- * Merge an object into state at the given path
1464
- */
1465
- merge(key: string, value: Record<string, any>, deep?: boolean, elementId?: string): void;
1466
- /**
1467
- * Delete a key from state
1468
- */
1469
- delete(key: string, elementId?: string): void;
1470
- /**
1471
- * Append to an array in state
1472
- */
1473
- append(key: string, value: any, elementId?: string): void;
1474
- /**
1475
- * Prepend to an array in state
1476
- */
1477
- prepend(key: string, value: any, elementId?: string): void;
1478
- /**
1479
- * Toggle a boolean value in state
1480
- */
1481
- toggle(key: string, elementId?: string): void;
1482
- /**
1483
- * Subscribe to state changes
1484
- */
1485
- subscribe(listener: (event: StateChangeEvent) => void): () => void;
1486
- /**
1487
- * Notify all listeners of a state change
1488
- */
1489
- private notifyChange;
1490
- /**
1491
- * Load state from localStorage
1492
- */
1493
- private loadFromLocalStorage;
1494
- /**
1495
- * Save state to localStorage
1496
- */
1497
- private saveToLocalStorage;
1498
- /**
1499
- * Clear all state
1500
- */
1501
- clear(): void;
1502
- }
1503
- /**
1504
- * Get value by dot-notation path
1505
- */
1506
- declare function getValueByPath(obj: any, path: string): any;
1507
- /**
1508
- * Set value by dot-notation path
1509
- */
1510
- declare function setValueByPath(obj: any, path: string, value: any): void;
1511
- /**
1512
- * Delete value by dot-notation path
1513
- */
1514
- declare function deleteValueByPath(obj: any, path: string): void;
1515
- /**
1516
- * Deep merge two objects
1517
- */
1518
- declare function deepMerge(target: any, source: any): any;
1519
- /**
1520
- * Add a class to an element's className string
1521
- */
1522
- declare function addClass(currentClasses: string, classToAdd: string): string;
1523
- /**
1524
- * Remove a class from an element's className string
1525
- */
1526
- declare function removeClass(currentClasses: string, classToRemove: string): string;
1527
- /**
1528
- * Toggle a class in an element's className string
1529
- */
1530
- declare function toggleClass(currentClasses: string, classToToggle: string): string;
1531
- /**
1532
- * Check if a className string contains a specific class
1533
- */
1534
- declare function hasClass(currentClasses: string, classToCheck: string): boolean;
1535
- /**
1536
- * Get value from localStorage with JSON parsing
1537
- */
1538
- declare function getLocalStorage(key: string, defaultValue?: any): any;
1539
- /**
1540
- * Set value in localStorage with JSON stringification
1541
- */
1542
- declare function setLocalStorage(key: string, value: any): void;
1543
- /**
1544
- * Remove value from localStorage
1545
- */
1546
- declare function removeLocalStorage(key: string): void;
1547
- /**
1548
- * Get value from sessionStorage with JSON parsing
1549
- */
1550
- declare function getSessionStorage(key: string, defaultValue?: any): any;
1551
- /**
1552
- * Set value in sessionStorage with JSON stringification
1553
- */
1554
- declare function setSessionStorage(key: string, value: any): void;
1555
- /**
1556
- * Remove value from sessionStorage
1557
- */
1558
- declare function removeSessionStorage(key: string): void;
1559
- interface NavigationOptions {
1560
- /** Replace current history entry instead of pushing */
1561
- replace?: boolean;
1562
- /** State to pass to the new route */
1563
- state?: any;
1564
- /** Open in new tab */
1565
- newTab?: boolean;
1566
- }
1567
- /**
1568
- * Navigate to a URL
1569
- * Works with both hash-based and history-based routing
1570
- */
1571
- declare function navigateTo(url: string, options?: NavigationOptions): void;
1572
- /**
1573
- * Go back in history
1574
- */
1575
- declare function goBack(): void;
1576
- /**
1577
- * Go forward in history
1578
- */
1579
- declare function goForward(): void;
1580
- /**
1581
- * Get current URL information
1582
- */
1583
- declare function getUrlInfo(): {
1584
- href: string;
1585
- pathname: string;
1586
- search: string;
1587
- hash: string;
1588
- searchParams: Record<string, string>;
1589
- };
1590
-
1591
- /**
1592
- * Event System for Runtime Core
1593
- * Provides event handling capabilities similar to RenderElements.tsx
1594
- * but in a framework-agnostic way.
1595
- *
1596
- * This module provides:
1597
- * - Event handler creation and management
1598
- * - Event delegation and bubbling control
1599
- * - Integration with state management
1600
- * - Support for Servly plugin format (via callbacks)
1601
- */
1602
-
1603
- interface EventHandlerConfig {
1604
- /** Prevent default browser behavior */
1605
- preventDefault?: boolean;
1606
- /** Stop event propagation */
1607
- stopPropagation?: boolean;
1608
- /** Debounce delay in ms */
1609
- debounce?: number;
1610
- /** Throttle delay in ms */
1611
- throttle?: number;
1612
- /** Only trigger once */
1613
- once?: boolean;
1614
- }
1615
- interface ServlyPluginAction {
1616
- /** Plugin key (e.g., 'state-setState', 'navigateTo') */
1617
- key: string;
1618
- /** Plugin configuration */
1619
- config?: Record<string, any>;
1620
- /** Plugin name for debugging */
1621
- name?: string;
1622
- }
1623
- interface ServlyEventHandler {
1624
- /** Array of plugin actions to execute */
1625
- plugins?: ServlyPluginAction[];
1626
- /** Event handler configuration */
1627
- preventDefault?: boolean;
1628
- stopPropagation?: boolean;
1629
- }
1630
- interface EventContext {
1631
- /** The DOM event */
1632
- event: Event;
1633
- /** Element ID that triggered the event */
1634
- elementId: string;
1635
- /** Current binding context */
1636
- context: BindingContext;
1637
- /** State manager instance */
1638
- stateManager?: StateManager;
1639
- /** Current item data (for list items) */
1640
- currentItem?: any;
1641
- /** Current index (for list items) */
1642
- currentIndex?: number;
1643
- }
1644
- type PluginExecutor = (action: ServlyPluginAction, eventContext: EventContext) => Promise<any> | any;
1645
- interface EventSystemConfig {
1646
- /** State manager instance */
1647
- stateManager?: StateManager;
1648
- /** Custom plugin executors */
1649
- pluginExecutors?: Record<string, PluginExecutor>;
1650
- /** Callback when an event is triggered */
1651
- onEvent?: (eventName: string, elementId: string, event: Event) => void;
1652
- /** Callback when a plugin action is executed */
1653
- onPluginExecute?: (action: ServlyPluginAction, result: any) => void;
1654
- /** Callback for navigation requests */
1655
- onNavigate?: (url: string, options?: {
1656
- replace?: boolean;
1657
- state?: any;
1658
- }) => void;
1659
- /** Callback for external API calls */
1660
- onApiCall?: (config: any) => Promise<any>;
1661
- }
1662
- /**
1663
- * Event system for managing event handlers in runtime-core
1664
- */
1665
- declare class EventSystem {
1666
- private config;
1667
- private pluginExecutors;
1668
- private debounceTimers;
1669
- private throttleTimers;
1670
- constructor(config?: EventSystemConfig);
1671
- /**
1672
- * Register a custom plugin executor
1673
- */
1674
- registerPlugin(key: string, executor: PluginExecutor): void;
1675
- /**
1676
- * Create an event handler from Servly plugin format
1677
- */
1678
- createHandler(elementId: string, handlerConfig: ServlyEventHandler, context: BindingContext, options?: EventHandlerConfig): (event: Event) => void;
1679
- /**
1680
- * Execute a sequence of plugin actions
1681
- */
1682
- executePlugins(plugins: ServlyPluginAction[], eventContext: EventContext): Promise<any[]>;
1683
- /**
1684
- * Create a debounced event handler
1685
- */
1686
- createDebouncedHandler(elementId: string, handler: (event: Event) => void, delay: number): (event: Event) => void;
1687
- /**
1688
- * Create a throttled event handler
1689
- */
1690
- createThrottledHandler(elementId: string, handler: (event: Event) => void, delay: number): (event: Event) => void;
1691
- /**
1692
- * Clean up all timers
1693
- */
1694
- destroy(): void;
1695
- }
1696
- /**
1697
- * Standard DOM event names that map to React-style event props
1698
- */
1699
- declare const EVENT_HANDLERS: Record<string, string>;
1700
- /**
1701
- * Convert React-style event name to DOM event name
1702
- */
1703
- declare function toDomEventName(reactEventName: string): string;
1704
- /**
1705
- * Convert DOM event name to React-style event name
1706
- */
1707
- declare function toReactEventName(domEventName: string): string;
1708
- declare function getEventSystem(config?: EventSystemConfig): EventSystem;
1709
- declare function resetEventSystem(): void;
1710
-
1711
- /**
1712
- * Tailwind CSS Utilities for Runtime Core
1713
- * Provides automatic Tailwind CSS injection for standalone rendering
1714
- */
1715
- interface TailwindConfig {
1716
- /** Custom CDN URL for Tailwind */
1717
- cdnUrl?: string;
1718
- /** Tailwind configuration object */
1719
- config?: Record<string, any>;
1720
- /** Custom plugins to load */
1721
- plugins?: string[];
1722
- /** Whether to use the Play CDN (includes all plugins) */
1723
- usePlayCdn?: boolean;
1724
- /** Callback when Tailwind is ready */
1725
- onReady?: () => void;
1726
- /** Callback on error */
1727
- onError?: (error: Error) => void;
1728
- }
1729
- /**
1730
- * Inject Tailwind CSS into the document
1731
- * Uses the Tailwind CDN for quick setup
1732
- */
1733
- declare function injectTailwind(config?: TailwindConfig): Promise<void>;
1734
- /**
1735
- * Remove Tailwind CSS from the document
1736
- */
1737
- declare function removeTailwind(): void;
1738
- /**
1739
- * Check if Tailwind CSS is loaded
1740
- */
1741
- declare function isTailwindLoaded(): boolean;
1742
- /**
1743
- * Get the Tailwind instance (if loaded)
1744
- */
1745
- declare function getTailwind(): any;
1746
- /**
1747
- * Update Tailwind configuration at runtime
1748
- */
1749
- declare function updateTailwindConfig(config: Record<string, any>): void;
1750
- /**
1751
- * Add custom CSS to the document
1752
- * Useful for adding custom styles alongside Tailwind
1753
- */
1754
- declare function addCustomStyles(css: string, id?: string): HTMLStyleElement;
1755
- /**
1756
- * Remove custom styles by ID
1757
- */
1758
- declare function removeCustomStyles(id: string): void;
1759
- /**
1760
- * Default Tailwind configuration for Servly components
1761
- */
1762
- declare const DEFAULT_SERVLY_TAILWIND_CONFIG: {
1763
- theme: {
1764
- extend: {};
1765
- };
1766
- safelist: {
1767
- pattern: RegExp;
1768
- }[];
1769
- };
1770
- /**
1771
- * Initialize Tailwind with Servly defaults
1772
- */
1773
- declare function initServlyTailwind(customConfig?: Record<string, any>): Promise<void>;
1774
- declare const injectTailwindStyles: typeof initServlyTailwind;
1775
-
1776
- /**
1777
- * Overrides System for Runtime Core
1778
- * Handles element overrides with dependency tracking
1779
- *
1780
- * Overrides are stored in element.configuration._overrides_ and contain:
1781
- * - plugins: Array of plugin actions to execute
1782
- * - dependencies: Array of template strings to watch for changes
1783
- * - isCleanUp: Boolean flag for unmount actions
1784
- */
1785
-
1786
- interface Override {
1787
- /** Plugin actions to execute */
1788
- plugins?: ServlyPluginAction[];
1789
- /** Template strings to watch for changes */
1790
- dependencies?: string[];
1791
- /** Whether this is a cleanup override (runs on unmount) */
1792
- isCleanUp?: boolean;
1793
- /** Override name for debugging */
1794
- name?: string;
1795
- }
1796
- interface OverrideState {
1797
- /** Previous resolved dependency values */
1798
- previousValues: Map<number, any[]>;
1799
- /** Whether the override has been initialized */
1800
- initialized: boolean;
1801
- /** Abort controller for cancelling pending operations */
1802
- abortController?: AbortController;
1803
- }
1804
- interface OverrideSystemConfig {
1805
- /** Event system for executing plugins */
1806
- eventSystem?: EventSystem;
1807
- /** State manager for state operations */
1808
- stateManager?: StateManager;
1809
- /** Callback when an override is triggered */
1810
- onOverrideTrigger?: (elementId: string, override: Override, eventType: string) => void;
1811
- /** Callback when dependencies change */
1812
- onDependencyChange?: (elementId: string, dependencies: string[], values: any[]) => void;
1813
- }
1814
- /**
1815
- * Manages element overrides with dependency tracking
1816
- */
1817
- declare class OverrideSystem {
1818
- private config;
1819
- private elementStates;
1820
- private watchIntervals;
1821
- constructor(config?: OverrideSystemConfig);
1822
- /**
1823
- * Get overrides from an element
1824
- */
1825
- getOverrides(element: LayoutElement): Override[];
1826
- /**
1827
- * Initialize overrides for an element (called on mount)
1828
- */
1829
- initializeElement(element: LayoutElement, context: BindingContext): Promise<void>;
1830
- /**
1831
- * Check and process dependency changes for an element
1832
- */
1833
- checkDependencies(element: LayoutElement, context: BindingContext): Promise<void>;
1834
- /**
1835
- * Cleanup overrides for an element (called on unmount)
1836
- */
1837
- cleanupElement(element: LayoutElement, context: BindingContext): Promise<void>;
1838
- /**
1839
- * Process a list of overrides
1840
- */
1841
- private processOverrides;
1842
- /**
1843
- * Start watching an element for dependency changes
1844
- */
1845
- startWatching(element: LayoutElement, context: BindingContext, intervalMs?: number): void;
1846
- /**
1847
- * Stop watching an element
1848
- */
1849
- stopWatching(elementId: string): void;
1850
- /**
1851
- * Destroy the override system
1852
- */
1853
- destroy(): void;
1854
- }
1855
- /**
1856
- * Extract all dependencies from overrides
1857
- */
1858
- declare function extractOverrideDependencies(element: LayoutElement): string[];
1859
- /**
1860
- * Check if an element has overrides
1861
- */
1862
- declare function hasOverrides(element: LayoutElement): boolean;
1863
- /**
1864
- * Check if an element has dependency-based overrides
1865
- */
1866
- declare function hasDependencyOverrides(element: LayoutElement): boolean;
1867
- /**
1868
- * Get mount overrides for an element
1869
- */
1870
- declare function getMountOverrides(element: LayoutElement): Override[];
1871
- /**
1872
- * Get cleanup overrides for an element
1873
- */
1874
- declare function getCleanupOverrides(element: LayoutElement): Override[];
1875
- declare function getOverrideSystem(config?: OverrideSystemConfig): OverrideSystem;
1876
- declare function resetOverrideSystem(): void;
1877
-
1878
- /**
1879
- * Universal Icon System
1880
- * Framework-agnostic icon rendering using SVG paths
1881
- *
1882
- * Priority order:
1883
- * 1. Pre-registered/bundled icons (registerIcon/registerIcons)
1884
- * 2. CDN fetch (if enabled)
1885
- * 3. Placeholder icon
1886
- */
1887
- interface IconConfig {
1888
- /** Icon name (e.g., 'PiHouse', 'FaHome') */
1889
- name: string;
1890
- /** Icon set prefix (e.g., 'Pi', 'Fa6', 'Lu') */
1891
- set: string;
1892
- /** Human-readable icon set name */
1893
- setName?: string;
1894
- }
1895
- interface IconData {
1896
- /** SVG body (inner content of SVG) */
1897
- body: string;
1898
- /** Width */
1899
- width?: number;
1900
- /** Height */
1901
- height?: number;
1902
- /** ViewBox (default: "0 0 24 24") */
1903
- viewBox?: string;
1904
- }
1905
- /**
1906
- * Enable or disable CDN fallback for icons not in bundle
1907
- * Disabled by default for security - only bundled icons will render
1908
- */
1909
- declare function setIconCdnEnabled(enabled: boolean): void;
1910
- /**
1911
- * Check if CDN fallback is enabled
1912
- */
1913
- declare function isIconCdnEnabled(): boolean;
1914
- /**
1915
- * Register icon data for bundled icons
1916
- * Use this to pre-register icons without fetching from CDN
1917
- */
1918
- declare function registerIcon(set: string, name: string, data: IconData): void;
1919
- /**
1920
- * Register multiple icons at once
1921
- */
1922
- declare function registerIcons(icons: Record<string, Record<string, IconData>>): void;
1923
- /**
1924
- * Check if an icon is registered/bundled
1925
- */
1926
- declare function isIconRegistered(icon: IconConfig): boolean;
1927
- /**
1928
- * Get all registered icon keys
1929
- */
1930
- declare function getRegisteredIconKeys(): string[];
1931
- /**
1932
- * Get icon data (from cache, registry, or CDN if enabled)
1933
- */
1934
- declare function getIconData(icon: IconConfig): Promise<IconData | null>;
1935
- /**
1936
- * Get icon data synchronously (only returns cached/registered icons)
1937
- */
1938
- declare function getIconDataSync(icon: IconConfig): IconData | null;
1939
- /**
1940
- * Create an SVG element for an icon
1941
- */
1942
- declare function createIconSVG(icon: IconConfig, data: IconData, size?: number, color?: string): SVGSVGElement;
1943
- /**
1944
- * Create a placeholder icon SVG (question mark)
1945
- */
1946
- declare function createPlaceholderIcon(icon: IconConfig, size?: number, color?: string): SVGSVGElement;
1947
- /**
1948
- * Render an icon to a container element
1949
- * Uses bundled icons first, falls back to CDN if enabled, otherwise shows placeholder
1950
- */
1951
- declare function renderIcon(container: HTMLElement, icon: IconConfig, size?: number, color?: string): void;
1952
- /**
1953
- * Preload icons for faster rendering
1954
- */
1955
- declare function preloadIcons(icons: IconConfig[]): Promise<void>;
1956
- /**
1957
- * Clear the icon cache (keeps registered icons)
1958
- */
1959
- declare function clearIconCache(): void;
1960
- /**
1961
- * Check if an icon set is supported
1962
- */
1963
- declare function isIconSetSupported(set: string): boolean;
1964
- /**
1965
- * Get all supported icon sets
1966
- */
1967
- declare function getSupportedIconSets(): string[];
1968
- /**
1969
- * Get Iconify collection name for an icon set
1970
- */
1971
- declare function getIconifyCollection(set: string): string | undefined;
1972
-
1973
- export { AnalyticsCollector, type AnalyticsConfig, type AnalyticsEvent, type AnalyticsEventType, type Assertion$1 as Assertion, type AssertionResult$1 as AssertionResult, type BatchEventsRequest, type BatchEventsResponse, type BindingContext, type BundleStrategy, type BundledComponent, type CacheConfig, type CacheEntry, type CacheStrategy, type ClientInfo, type ComponentBundle, type ComponentData, type ComponentRegistry, DEFAULT_CACHE_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SERVLY_TAILWIND_CONFIG, type DependencyEntry, type DependencyManifest, type DependencyType, EVENT_HANDLERS, type ElementConfig, type ErrorMetadata, type ErrorType, type EventContext, type EventHandlerConfig, EventSystem, type EventSystemConfig, type FetchMetadata, type FetchOptions, type FetchResult, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isValidSpecifier, navigateTo, parseVersion, prefetchComponents, preloadIcons, processStyles, registerIcon, registerIcons, removeClass, removeCustomStyles, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps };