@servlyadmin/runtime-core 0.1.7 → 0.1.9

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.cts DELETED
@@ -1,1213 +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
- /** Input bindings for props */
56
- bindings?: {
57
- inputs?: Record<string, {
58
- source: 'static' | 'props' | 'state' | 'parent' | 'function';
59
- value?: any;
60
- path?: string;
61
- binding?: any;
62
- }>;
63
- };
64
- /** Reference to another component (for componentView elements) */
65
- componentViewRef?: string;
66
- /** Version specifier for the referenced component */
67
- componentViewVersion?: string;
68
- /** Props to pass to the referenced component */
69
- componentViewProps?: Record<string, any>;
70
- /** Blueprint ID for renderDynamicList */
71
- blueprint?: string;
72
- /** Blueprint version specifier */
73
- blueprintVersion?: string;
74
- /** Data attributes */
75
- [key: `data-${string}`]: string | undefined;
76
- /** Aria attributes */
77
- [key: `aria-${string}`]: string | undefined;
78
- }
79
- /**
80
- * A single element in the Layout JSON tree
81
- */
82
- interface LayoutElement {
83
- /** Unique element identifier */
84
- i: string;
85
- /** Component type (container, text, button, etc.) */
86
- componentId: string;
87
- /** Parent element ID (null for root elements) */
88
- parent?: string | null;
89
- /** Element configuration */
90
- configuration?: ElementConfig;
91
- /** Inline styles */
92
- style?: Record<string, any>;
93
- /** CSS class name */
94
- className?: string;
95
- /** Whether this is a group/container */
96
- isGroup?: boolean;
97
- /** Child element IDs */
98
- children?: string[];
99
- /** Element name for debugging */
100
- name?: string;
101
- }
102
- /**
103
- * Context for resolving template bindings
104
- */
105
- interface BindingContext {
106
- /** Props passed to the component */
107
- props: Record<string, any>;
108
- /** Component state */
109
- state?: Record<string, any>;
110
- /** Additional context data */
111
- context?: Record<string, any>;
112
- }
113
- /**
114
- * Registry of available components for dependency resolution
115
- */
116
- interface ComponentRegistry {
117
- /** Get component by ID and optional version */
118
- get(id: string, version?: string): BundledComponent | undefined;
119
- /** Check if component exists */
120
- has(id: string, version?: string): boolean;
121
- /** Register a component */
122
- set(id: string, version: string, component: BundledComponent): void;
123
- }
124
- /**
125
- * Options for rendering a component
126
- */
127
- interface RenderOptions {
128
- /** Container element to render into */
129
- container: HTMLElement;
130
- /** Layout elements to render */
131
- elements: LayoutElement[];
132
- /** Binding context for template resolution */
133
- context: BindingContext;
134
- /** Event handlers keyed by element ID then event name */
135
- eventHandlers?: Record<string, Record<string, (e: Event) => void>>;
136
- /** Registry of components for resolving componentViewRef and blueprints */
137
- componentRegistry?: ComponentRegistry;
138
- /** Callback when a dependency needs to be loaded */
139
- onDependencyNeeded?: (id: string, version?: string) => Promise<BundledComponent | undefined>;
140
- /** Callback when rendering a referenced component */
141
- onComponentRender?: (id: string, container: HTMLElement) => void;
142
- }
143
- /**
144
- * Result of a render operation
145
- */
146
- interface RenderResult {
147
- /** Root DOM element created */
148
- rootElement: HTMLElement | null;
149
- /** Update the rendered component with new context */
150
- update: (context: BindingContext) => void;
151
- /** Destroy the rendered component and clean up */
152
- destroy: () => void;
153
- }
154
- /**
155
- * Prop definition for a component
156
- */
157
- interface PropDefinition {
158
- /** Prop name */
159
- name: string;
160
- /** Prop type */
161
- type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';
162
- /** Whether the prop is required */
163
- required: boolean;
164
- /** Default value if not provided */
165
- defaultValue?: any;
166
- /** Description for documentation */
167
- description?: string;
168
- }
169
- /**
170
- * Test case assertion
171
- */
172
- interface Assertion$1 {
173
- /** CSS selector to find element */
174
- selector: string;
175
- /** Property to check */
176
- property: 'text' | 'attribute' | 'style' | 'exists' | 'class';
177
- /** Attribute name (for attribute checks) */
178
- attributeName?: string;
179
- /** Style property name (for style checks) */
180
- styleName?: string;
181
- /** Expected value */
182
- expected: any;
183
- }
184
- /**
185
- * Test case for component validation
186
- */
187
- interface TestCase$1 {
188
- /** Unique test case ID */
189
- id: string;
190
- /** Test case name */
191
- name: string;
192
- /** Props to use for this test */
193
- props: Record<string, any>;
194
- /** Assertions to validate */
195
- assertions?: Assertion$1[];
196
- }
197
- /**
198
- * Type of component dependency
199
- */
200
- type DependencyType = 'blueprint' | 'viewRef' | 'slot';
201
- /**
202
- * Single dependency entry in manifest
203
- */
204
- interface DependencyEntry {
205
- /** Requested version specifier (e.g., "^1.0.0") */
206
- version: string;
207
- /** Actual resolved version (e.g., "1.2.3") */
208
- resolved: string;
209
- /** Type of dependency */
210
- type: DependencyType;
211
- /** Parent dependency ID (for nested deps) */
212
- via?: string;
213
- /** If true, component works without this dependency */
214
- optional?: boolean;
215
- }
216
- /**
217
- * Manifest of all component dependencies
218
- */
219
- interface DependencyManifest {
220
- [componentId: string]: DependencyEntry;
221
- }
222
- /**
223
- * Bundled component data (minimal for bundle)
224
- */
225
- interface BundledComponent {
226
- /** Layout JSON elements */
227
- layout: LayoutElement[];
228
- /** Props interface definition */
229
- propsInterface?: PropDefinition[];
230
- }
231
- /**
232
- * Bundle of all dependencies
233
- * Key format: "componentId@version"
234
- */
235
- interface ComponentBundle {
236
- [componentIdAtVersion: string]: BundledComponent;
237
- }
238
- /**
239
- * Component data from registry
240
- */
241
- interface ComponentData {
242
- /** Component ID */
243
- id: string;
244
- /** Component name */
245
- name: string;
246
- /** Component description */
247
- description?: string;
248
- /** Component version */
249
- version: string;
250
- /** Layout JSON elements */
251
- layout: LayoutElement[];
252
- /** Props interface definition */
253
- propsInterface?: PropDefinition[];
254
- /** Test cases for validation */
255
- testCases?: TestCase$1[];
256
- /** CSS variables used */
257
- cssVariables?: Record<string, string>;
258
- /** Component tags for search */
259
- tags?: string[];
260
- /** Created timestamp */
261
- createdAt?: string;
262
- /** Updated timestamp */
263
- updatedAt?: string;
264
- /** Dependency manifest - lists all required components */
265
- dependencies?: DependencyManifest;
266
- /** Bundled dependencies - included component data */
267
- bundle?: ComponentBundle;
268
- }
269
- /**
270
- * Cache entry for component data
271
- */
272
- interface CacheEntry {
273
- /** Cached component data */
274
- data: ComponentData;
275
- /** Timestamp when cached */
276
- timestamp: number;
277
- /** Version of cached component */
278
- version: string;
279
- /** Number of times accessed */
280
- accessCount: number;
281
- /** Last access timestamp */
282
- lastAccessed: number;
283
- }
284
- /**
285
- * Cache configuration
286
- */
287
- interface CacheConfig {
288
- /** Maximum number of entries in cache */
289
- maxEntries?: number;
290
- /** Time-to-live in milliseconds */
291
- ttl?: number;
292
- /** Storage key prefix for localStorage */
293
- storageKeyPrefix?: string;
294
- }
295
- /**
296
- * Cache strategy type
297
- */
298
- type CacheStrategy = 'memory' | 'localStorage' | 'none';
299
- /**
300
- * Retry configuration for failed fetches
301
- */
302
- interface RetryConfig {
303
- /** Maximum number of retries */
304
- maxRetries?: number;
305
- /** Initial delay in ms */
306
- initialDelay?: number;
307
- /** Maximum delay in ms */
308
- maxDelay?: number;
309
- /** Backoff multiplier */
310
- backoffMultiplier?: number;
311
- }
312
- /**
313
- * Bundle loading strategy
314
- */
315
- type BundleStrategy = 'eager' | 'lazy' | 'none';
316
- /**
317
- * Options for fetching a component
318
- */
319
- interface FetchOptions {
320
- /** Version specifier */
321
- version?: string;
322
- /** API key for authentication */
323
- apiKey?: string;
324
- /** Cache strategy */
325
- cacheStrategy?: CacheStrategy;
326
- /** Cache configuration */
327
- cacheConfig?: CacheConfig;
328
- /** Retry configuration */
329
- retryConfig?: Partial<RetryConfig>;
330
- /** Skip cache and force fetch */
331
- forceRefresh?: boolean;
332
- /** Abort signal for cancellation */
333
- signal?: AbortSignal;
334
- /** How to handle dependencies: eager (bundle all), lazy (fetch on demand), none */
335
- bundleStrategy?: BundleStrategy;
336
- /** Include bundled dependencies in response */
337
- includeBundle?: boolean;
338
- /** Maximum bundle size in bytes before switching to lazy */
339
- maxBundleSize?: number;
340
- }
341
- /**
342
- * Result of a fetch operation
343
- */
344
- interface FetchResult {
345
- /** Fetched component data */
346
- data: ComponentData;
347
- /** Whether data came from cache */
348
- fromCache: boolean;
349
- /** Resolved version */
350
- version: string;
351
- /** Pre-built component registry from bundle */
352
- registry?: ComponentRegistry;
353
- /** List of dependencies that need lazy loading */
354
- pendingDependencies?: Array<{
355
- id: string;
356
- version: string;
357
- }>;
358
- }
359
- /**
360
- * Result of a single assertion
361
- */
362
- interface AssertionResult$1 {
363
- /** Whether assertion passed */
364
- passed: boolean;
365
- /** The assertion that was checked */
366
- assertion: Assertion$1;
367
- /** Actual value found */
368
- actual?: any;
369
- /** Error message if failed */
370
- error?: string;
371
- }
372
- /**
373
- * Result of running a test case
374
- */
375
- interface TestCaseResult {
376
- /** Test case ID */
377
- id: string;
378
- /** Test case name */
379
- name: string;
380
- /** Whether all assertions passed */
381
- passed: boolean;
382
- /** Individual assertion results */
383
- assertions: AssertionResult$1[];
384
- /** Execution time in ms */
385
- duration: number;
386
- }
387
- /**
388
- * Summary of all test results
389
- */
390
- interface TestSummary$1 {
391
- /** Total number of tests */
392
- total: number;
393
- /** Number of passed tests */
394
- passed: number;
395
- /** Number of failed tests */
396
- failed: number;
397
- /** Individual test results */
398
- results: TestCaseResult[];
399
- /** Total execution time in ms */
400
- duration: number;
401
- }
402
-
403
- /**
404
- * Vanilla DOM Renderer
405
- * Renders Layout JSON to native DOM elements
406
- * Supports component dependencies via componentViewRef and blueprint
407
- */
408
-
409
- /**
410
- * Render Layout JSON to DOM
411
- */
412
- declare function render(options: RenderOptions): RenderResult;
413
- /**
414
- * Render a dynamic list using a blueprint component
415
- * This is called by event handlers that use renderDynamicList
416
- */
417
- declare function renderDynamicList(options: {
418
- /** Target container element or selector */
419
- targetContainer: HTMLElement | string;
420
- /** Blueprint component ID */
421
- blueprint: string;
422
- /** Blueprint version (optional) */
423
- blueprintVersion?: string;
424
- /** Data array to render */
425
- data: any[];
426
- /** How to render: 'renderInto' clears container, 'append' adds to end */
427
- renderType?: 'renderInto' | 'append' | 'prepend';
428
- /** Item variable name in template (default: 'item') */
429
- itemKey?: string;
430
- /** Index variable name in template (default: 'index') */
431
- indexKey?: string;
432
- /** Component registry for blueprint lookup */
433
- componentRegistry: ComponentRegistry;
434
- /** Parent context */
435
- context?: BindingContext;
436
- }): RenderResult[];
437
-
438
- /**
439
- * Template Binding Resolution
440
- * Resolves {{path}} syntax in templates using binding context
441
- */
442
-
443
- /**
444
- * Check if a string contains template syntax
445
- */
446
- declare function hasTemplateSyntax(value: unknown): value is string;
447
- /**
448
- * Resolve a binding path to its value from context
449
- *
450
- * @param path - The path to resolve (e.g., "props.title", "state.count")
451
- * @param context - The binding context containing props, state, context
452
- * @returns The resolved value or undefined if not found
453
- */
454
- declare function resolveBindingPath(path: string, context: BindingContext): any;
455
- /**
456
- * Resolve a template string with bindings
457
- * Replaces all {{path}} occurrences with resolved values
458
- *
459
- * @param template - The template string containing {{path}} bindings
460
- * @param context - The binding context
461
- * @param componentId - Optional component ID for error tracking
462
- * @returns The resolved string
463
- */
464
- declare function resolveTemplate(template: string, context: BindingContext, componentId?: string): string;
465
- /**
466
- * Resolve a template and return the raw value (not stringified)
467
- * Useful for non-string values like objects, arrays, booleans
468
- *
469
- * @param template - The template string
470
- * @param context - The binding context
471
- * @param componentId - Optional component ID for error tracking
472
- */
473
- declare function resolveTemplateValue(template: string, context: BindingContext, componentId?: string): any;
474
- /**
475
- * Recursively resolve all template bindings in an object or array
476
- *
477
- * @param input - The input value (string, object, array, or primitive)
478
- * @param context - The binding context
479
- * @returns The input with all templates resolved
480
- */
481
- declare function resolveTemplatesDeep<T>(input: T, context: BindingContext): T;
482
- /**
483
- * Extract all binding keys from a template string
484
- *
485
- * @param template - The template string
486
- * @returns Array of binding keys found
487
- */
488
- declare function extractBindingKeys(template: string): string[];
489
-
490
- /**
491
- * Style Processing
492
- * Handles CSS styles, variables, and class names for DOM elements
493
- */
494
-
495
- /**
496
- * Convert camelCase to kebab-case
497
- */
498
- declare function camelToKebab(str: string): string;
499
- /**
500
- * Format a style value, adding px units if needed
501
- */
502
- declare function formatStyleValue(property: string, value: any): string;
503
- /**
504
- * Process a style object, resolving templates and formatting values
505
- */
506
- declare function processStyles(style: Record<string, any> | undefined, context: BindingContext): Record<string, string>;
507
- /**
508
- * Apply styles to a DOM element
509
- */
510
- declare function applyStyles(element: HTMLElement, styles: Record<string, string>): void;
511
- /**
512
- * Build combined styles from element configuration
513
- */
514
- declare function buildElementStyles(element: LayoutElement, context: BindingContext): Record<string, string>;
515
- /**
516
- * Build class name string from element configuration
517
- */
518
- declare function buildClassName(element: LayoutElement, context: BindingContext): string;
519
- /**
520
- * Clear all inline styles from an element
521
- */
522
- declare function clearStyles(element: HTMLElement): void;
523
- /**
524
- * Update styles on an element (diff and patch)
525
- */
526
- declare function updateStyles(element: HTMLElement, oldStyles: Record<string, string>, newStyles: Record<string, string>): void;
527
-
528
- /**
529
- * Component Cache System
530
- * In-memory and localStorage caching with LRU eviction
531
- */
532
-
533
- /** Default cache configuration */
534
- declare const DEFAULT_CACHE_CONFIG: Required<CacheConfig>;
535
- /**
536
- * Generate cache key for component
537
- */
538
- declare function getCacheKey(id: string, version?: string): string;
539
- /**
540
- * Clear memory cache
541
- */
542
- declare function clearMemoryCache(): void;
543
- /**
544
- * Get memory cache size
545
- */
546
- declare function getMemoryCacheSize(): number;
547
- /**
548
- * Clear localStorage cache
549
- */
550
- declare function clearLocalStorageCache(config?: CacheConfig): void;
551
- /**
552
- * Get component from cache (tries memory first, then localStorage)
553
- */
554
- declare function getFromCache(id: string, version?: string, strategy?: CacheStrategy, config?: CacheConfig): ComponentData | null;
555
- /**
556
- * Set component in cache
557
- */
558
- declare function setInCache(id: string, version: string, data: ComponentData, strategy?: CacheStrategy, config?: CacheConfig): void;
559
- /**
560
- * Clear all caches
561
- */
562
- declare function clearAllCaches(config?: CacheConfig): void;
563
- /**
564
- * Invalidate specific component from all caches
565
- */
566
- declare function invalidateCache(id: string, version?: string, config?: CacheConfig): void;
567
-
568
- /**
569
- * View Registry Fetcher
570
- * Fetches view data from the View Registry API with retry logic
571
- *
572
- * API Base: /api/views/registry
573
- * Supports: versioning, bundling, batch fetch, dependency resolution
574
- */
575
-
576
- /** Default retry configuration */
577
- declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
578
- /**
579
- * Configure the registry base URL
580
- */
581
- declare function setRegistryUrl(url: string): void;
582
- /**
583
- * Get the registry base URL
584
- */
585
- declare function getRegistryUrl(): string;
586
- /**
587
- * Fetch component with caching and retry
588
- */
589
- declare function fetchComponent(id: string, options?: FetchOptions): Promise<FetchResult>;
590
- /**
591
- * Fetch component with all dependencies resolved
592
- * Convenience wrapper that handles lazy loading
593
- */
594
- declare function fetchComponentWithDependencies(id: string, options?: FetchOptions): Promise<FetchResult>;
595
- /**
596
- * Batch fetch multiple views in a single request
597
- * Uses: POST /api/views/registry/batch
598
- */
599
- declare function batchFetchComponents(components: Array<{
600
- id: string;
601
- version?: string;
602
- }>, options?: Pick<FetchOptions, 'apiKey'>): Promise<Record<string, BundledComponent>>;
603
- /**
604
- * Prefetch views for faster loading
605
- * Uses: POST /api/views/registry/prefetch for version resolution
606
- */
607
- declare function prefetchComponents(ids: Array<{
608
- id: string;
609
- version?: string;
610
- }>, options?: Omit<FetchOptions, 'version'>): Promise<void>;
611
- /**
612
- * Check if view is available (in cache or online)
613
- * Uses: GET /api/views/registry/:viewId/available?version=^1.0.0
614
- */
615
- declare function isComponentAvailable(id: string, version?: string, options?: Pick<FetchOptions, 'apiKey' | 'cacheStrategy' | 'cacheConfig'>): Promise<{
616
- available: boolean;
617
- cached: boolean;
618
- version?: string;
619
- }>;
620
- /**
621
- * Get dependency tree for a view
622
- * Uses: GET /api/views/registry/:viewId/dependencies?version=^1.0.0&depth=10
623
- */
624
- declare function getDependencyTree(id: string, options?: {
625
- version?: string;
626
- depth?: number;
627
- apiKey?: string;
628
- }): Promise<{
629
- tree: any;
630
- totalDependencies: number;
631
- maxDepthReached: number;
632
- }>;
633
-
634
- /**
635
- * Semantic Version Utilities
636
- * Parsing, comparison, and range resolution for semver
637
- */
638
- /** Parsed semantic version */
639
- interface ParsedVersion {
640
- major: number;
641
- minor: number;
642
- patch: number;
643
- }
644
- /**
645
- * Parse a semantic version string
646
- * @returns Parsed version or null if invalid
647
- */
648
- declare function parseVersion(version: string): ParsedVersion | null;
649
- /**
650
- * Compare two versions
651
- * @returns -1 if a < b, 0 if a == b, 1 if a > b
652
- */
653
- declare function compareVersions(a: string, b: string): number;
654
- /**
655
- * Check if a version satisfies a specifier
656
- * Supports: exact (1.2.3), caret (^1.2.3), tilde (~1.2.3), latest, *
657
- */
658
- declare function satisfiesVersion(version: string, specifier: string): boolean;
659
- /**
660
- * Find the best matching version from a list
661
- * @param versions - Available versions (sorted newest first recommended)
662
- * @param specifier - Version specifier to match
663
- * @returns Best matching version or null if none match
664
- */
665
- declare function resolveVersion(versions: string[], specifier?: string): string | null;
666
- /**
667
- * Get next version based on bump type
668
- */
669
- declare function bumpVersion(currentVersion: string, bumpType: 'major' | 'minor' | 'patch'): string;
670
- /**
671
- * Check if a string is a valid version specifier
672
- */
673
- declare function isValidSpecifier(specifier: string): boolean;
674
- /**
675
- * Format a version for display
676
- */
677
- declare function formatVersion(version: string): string;
678
-
679
- /**
680
- * Test Runner for Servly Components
681
- *
682
- * Runs test cases against components to validate prop behavior
683
- * and DOM output matches expected assertions.
684
- */
685
-
686
- interface TestCase {
687
- id: string;
688
- name: string;
689
- description?: string;
690
- props: Record<string, any>;
691
- assertions: Assertion[];
692
- }
693
- interface Assertion {
694
- type: 'exists' | 'text' | 'attribute' | 'class' | 'style' | 'count' | 'visible';
695
- selector: string;
696
- expected?: any;
697
- attribute?: string;
698
- property?: string;
699
- }
700
- interface TestResult {
701
- testId: string;
702
- testName: string;
703
- passed: boolean;
704
- assertions: AssertionResult[];
705
- duration: number;
706
- error?: string;
707
- }
708
- interface AssertionResult {
709
- assertion: Assertion;
710
- passed: boolean;
711
- actual?: any;
712
- expected?: any;
713
- message?: string;
714
- }
715
- interface TestSummary {
716
- total: number;
717
- passed: number;
718
- failed: number;
719
- duration: number;
720
- results: TestResult[];
721
- }
722
- /**
723
- * Run a single test case against a component
724
- */
725
- declare function runTestCase(elements: LayoutElement[], testCase: TestCase, container?: HTMLElement): TestResult;
726
- /**
727
- * Run all test cases for a component
728
- */
729
- declare function runAllTests(elements: LayoutElement[], testCases: TestCase[]): TestSummary;
730
- /**
731
- * Validate a single assertion against the DOM
732
- */
733
- declare function validateAssertion(container: HTMLElement, assertion: Assertion): AssertionResult;
734
- /**
735
- * Validate props against prop definitions
736
- */
737
- declare function validateProps(props: Record<string, any>, definitions: PropDefinition[]): {
738
- valid: boolean;
739
- errors: string[];
740
- };
741
- /**
742
- * Generate test cases from prop definitions
743
- */
744
- declare function generateTestCases(definitions: PropDefinition[]): TestCase[];
745
-
746
- /**
747
- * Component Registry
748
- *
749
- * Manages a collection of components for dependency resolution.
750
- * Used by the renderer to resolve componentViewRef and blueprint references.
751
- */
752
-
753
- /**
754
- * Create a component registry from bundled data
755
- */
756
- declare function createRegistry(): ComponentRegistry;
757
- /**
758
- * Build a registry from component data with bundle
759
- */
760
- declare function buildRegistryFromBundle(data: ComponentData): ComponentRegistry;
761
- /**
762
- * Extract dependencies from layout elements
763
- * Scans for componentViewRef and blueprint references
764
- */
765
- declare function extractDependencies(elements: LayoutElement[]): Array<{
766
- id: string;
767
- version?: string;
768
- type: 'viewRef' | 'blueprint';
769
- elementId: string;
770
- }>;
771
- /**
772
- * Extract dependencies from event handler code
773
- * Looks for renderDynamicList calls
774
- */
775
- declare function extractDependenciesFromCode(code: string): Array<{
776
- id: string;
777
- type: 'blueprint';
778
- }>;
779
- /**
780
- * Recursively collect all dependencies from a component
781
- * Handles nested dependencies (A → B → C)
782
- */
783
- declare function collectAllDependencies(rootId: string, rootVersion: string, fetchComponent: (id: string, version?: string) => Promise<ComponentData | undefined>, maxDepth?: number): Promise<DependencyManifest>;
784
- /**
785
- * Check for circular dependencies
786
- */
787
- declare function detectCircularDependencies(manifest: DependencyManifest): string[] | null;
788
-
789
- /**
790
- * Component Analytics Types
791
- * Type definitions for analytics event collection and transmission
792
- */
793
- /**
794
- * Analytics configuration options
795
- */
796
- interface AnalyticsConfig {
797
- /** Enable/disable analytics collection */
798
- enabled: boolean;
799
- /** Analytics API endpoint */
800
- endpoint: string;
801
- /** API key for authentication */
802
- apiKey?: string;
803
- /** Application ID to include in all events */
804
- appId?: string;
805
- /** Batch size before auto-flush */
806
- batchSize: number;
807
- /** Flush interval in milliseconds */
808
- flushInterval: number;
809
- /** Sample rate (0-1) for high-volume events */
810
- sampleRate: number;
811
- /** Environment identifier */
812
- environment: 'development' | 'staging' | 'production';
813
- /** Enable debug logging */
814
- debug: boolean;
815
- }
816
- /**
817
- * Analytics event types
818
- */
819
- type AnalyticsEventType = 'render' | 'fetch' | 'error';
820
- /**
821
- * Base analytics event
822
- */
823
- interface AnalyticsEvent {
824
- /** Event type */
825
- type: AnalyticsEventType;
826
- /** Component identifier */
827
- componentId: string;
828
- /** Component version */
829
- version: string;
830
- /** Unix timestamp in milliseconds */
831
- timestamp: number;
832
- /** Anonymous session ID */
833
- sessionId?: string;
834
- /** Application ID */
835
- appId?: string;
836
- /** Duration in milliseconds */
837
- duration?: number;
838
- /** Event-specific metadata */
839
- metadata?: Record<string, unknown>;
840
- }
841
- /**
842
- * Metadata for render events
843
- */
844
- interface RenderMetadata {
845
- /** Number of DOM elements rendered */
846
- elementCount?: number;
847
- /** Whether component was served from cache */
848
- fromCache?: boolean;
849
- /** Memory heap change in KB (Chrome only) */
850
- heapDeltaKB?: number;
851
- /** Number of DOM nodes created */
852
- domNodesCreated?: number;
853
- /** Number of long tasks (>50ms) during render */
854
- longTaskCount?: number;
855
- /** Whether component has event handlers */
856
- hasEventHandlers?: boolean;
857
- /** Whether component has dependencies */
858
- hasDependencies?: boolean;
859
- }
860
- /**
861
- * Metadata for fetch events
862
- */
863
- interface FetchMetadata {
864
- /** Whether fetch was a cache hit */
865
- cacheHit: boolean;
866
- /** Fetch duration in milliseconds */
867
- fetchDuration: number;
868
- /** Bundle size in bytes */
869
- bundleSize?: number;
870
- /** Number of dependencies */
871
- dependencyCount?: number;
872
- }
873
- /**
874
- * Error types for error events
875
- */
876
- type ErrorType = 'render' | 'fetch' | 'binding';
877
- /**
878
- * Metadata for error events
879
- */
880
- interface ErrorMetadata {
881
- /** Type of error */
882
- errorType: ErrorType;
883
- /** Error message (max 1000 chars) */
884
- errorMessage: string;
885
- /** Stack trace (truncated to 500 chars) */
886
- stackTrace?: string;
887
- /** Failed binding path (for binding errors) */
888
- bindingPath?: string;
889
- /** Element ID where error occurred */
890
- elementId?: string;
891
- }
892
- /**
893
- * Client info included in batch requests
894
- */
895
- interface ClientInfo {
896
- /** SDK version */
897
- sdkVersion: string;
898
- /** Environment */
899
- environment: string;
900
- }
901
- /**
902
- * Batch events request body
903
- */
904
- interface BatchEventsRequest {
905
- /** Array of analytics events */
906
- events: AnalyticsEvent[];
907
- /** Client information */
908
- clientInfo: ClientInfo;
909
- }
910
- /**
911
- * Batch events response
912
- */
913
- interface BatchEventsResponse {
914
- /** Whether request was successful */
915
- success: boolean;
916
- /** Number of events accepted */
917
- accepted: number;
918
- /** Number of events rejected */
919
- rejected: number;
920
- /** Error messages for rejected events */
921
- errors?: string[];
922
- /** Retry-After header value (for rate limiting) */
923
- retryAfter?: number;
924
- }
925
- /**
926
- * Session information
927
- */
928
- interface SessionInfo {
929
- /** Session ID */
930
- id: string;
931
- /** Timestamp when session was created */
932
- createdAt: number;
933
- /** Timestamp of last activity */
934
- lastActivityAt: number;
935
- }
936
-
937
- /**
938
- * Component Analytics
939
- * Collects and transmits component usage, performance, and error metrics
940
- */
941
-
942
- /**
943
- * Analytics Collector class
944
- * Manages event collection, batching, and transmission
945
- */
946
- declare class AnalyticsCollector {
947
- private config;
948
- private eventQueue;
949
- private flushTimer;
950
- private isEnabled;
951
- private isFlushing;
952
- private retryDelay;
953
- constructor(config?: Partial<AnalyticsConfig>);
954
- /**
955
- * Configure analytics
956
- */
957
- configure(config: Partial<AnalyticsConfig>): void;
958
- /**
959
- * Disable analytics collection
960
- */
961
- disable(): void;
962
- /**
963
- * Enable analytics collection
964
- */
965
- enable(): void;
966
- /**
967
- * Destroy and cleanup
968
- */
969
- destroy(): void;
970
- /**
971
- * Track component render
972
- */
973
- trackRender(componentId: string, version: string, duration: number, metadata?: RenderMetadata): void;
974
- /**
975
- * Track component fetch
976
- */
977
- trackFetch(componentId: string, version: string, duration: number, fromCache: boolean, metadata?: Partial<FetchMetadata>): void;
978
- /**
979
- * Track error
980
- */
981
- trackError(componentId: string, version: string, error: Error, context?: Partial<ErrorMetadata>): void;
982
- /**
983
- * Check if event should be tracked (sampling + enabled)
984
- */
985
- private shouldTrack;
986
- /**
987
- * Add event to queue
988
- */
989
- private queueEvent;
990
- /**
991
- * Get current queue size
992
- */
993
- getQueueSize(): number;
994
- /**
995
- * Start the flush timer
996
- */
997
- private startFlushTimer;
998
- /**
999
- * Stop the flush timer
1000
- */
1001
- private stopFlushTimer;
1002
- /**
1003
- * Flush events to server
1004
- */
1005
- flush(): Promise<void>;
1006
- /**
1007
- * Perform the actual flush
1008
- */
1009
- private doFlush;
1010
- /**
1011
- * Send events to the API
1012
- */
1013
- private sendEvents;
1014
- /**
1015
- * Handle failed events (partial success)
1016
- */
1017
- private handleFailedEvents;
1018
- /**
1019
- * Handle network error
1020
- */
1021
- private handleNetworkError;
1022
- /**
1023
- * Schedule a retry flush
1024
- */
1025
- private scheduleRetry;
1026
- /**
1027
- * Truncate string to max length
1028
- */
1029
- private truncateString;
1030
- /**
1031
- * Log debug message
1032
- */
1033
- private log;
1034
- }
1035
- /**
1036
- * Get the analytics collector singleton
1037
- */
1038
- declare function getAnalytics(): AnalyticsCollector;
1039
- /**
1040
- * Configure analytics (convenience function)
1041
- */
1042
- declare function configureAnalytics(config: Partial<AnalyticsConfig>): void;
1043
- /**
1044
- * Reset analytics (for testing)
1045
- */
1046
- declare function resetAnalytics(): void;
1047
- declare const analytics: {
1048
- readonly instance: AnalyticsCollector;
1049
- configure: typeof configureAnalytics;
1050
- trackRender: (componentId: string, version: string, duration: number, metadata?: RenderMetadata) => void;
1051
- trackFetch: (componentId: string, version: string, duration: number, fromCache: boolean, metadata?: Partial<FetchMetadata>) => void;
1052
- trackError: (componentId: string, version: string, error: Error, context?: Partial<ErrorMetadata>) => void;
1053
- flush: () => Promise<void>;
1054
- disable: () => void;
1055
- enable: () => void;
1056
- };
1057
-
1058
- /**
1059
- * Session Manager
1060
- * Manages anonymous session IDs for analytics tracking
1061
- */
1062
-
1063
- /**
1064
- * Session Manager class
1065
- * Manages anonymous session IDs with automatic rotation
1066
- */
1067
- declare class SessionManager {
1068
- private session;
1069
- constructor();
1070
- /**
1071
- * Initialize session manager
1072
- */
1073
- private initialize;
1074
- /**
1075
- * Create a new session
1076
- */
1077
- private createNewSession;
1078
- /**
1079
- * Get current session ID
1080
- * Creates new session if expired
1081
- */
1082
- getSessionId(): string;
1083
- /**
1084
- * Update last activity timestamp
1085
- */
1086
- touch(): void;
1087
- /**
1088
- * Force create a new session
1089
- */
1090
- rotate(): void;
1091
- /**
1092
- * Clear current session
1093
- */
1094
- clear(): void;
1095
- /**
1096
- * Get session info (for debugging)
1097
- */
1098
- getSessionInfo(): SessionInfo | null;
1099
- }
1100
- /**
1101
- * Get the session manager singleton
1102
- */
1103
- declare function getSessionManager(): SessionManager;
1104
- /**
1105
- * Reset the session manager (for testing)
1106
- */
1107
- declare function resetSessionManager(): void;
1108
-
1109
- /**
1110
- * Memory Sampler
1111
- * Samples memory usage using Chrome's performance.memory API
1112
- * Gracefully degrades on unsupported browsers
1113
- */
1114
- /**
1115
- * Memory sample data
1116
- */
1117
- interface MemorySample {
1118
- /** Used JS heap size in KB */
1119
- heapUsedKB: number;
1120
- /** Total JS heap size in KB */
1121
- heapTotalKB: number;
1122
- /** Timestamp when sample was taken */
1123
- timestamp: number;
1124
- }
1125
- /**
1126
- * Memory Sampler class
1127
- * Provides memory sampling functionality for Chrome browsers
1128
- */
1129
- declare class MemorySampler {
1130
- private isSupported;
1131
- constructor();
1132
- /**
1133
- * Check if memory API is available
1134
- */
1135
- private checkSupport;
1136
- /**
1137
- * Check if memory sampling is available
1138
- */
1139
- isAvailable(): boolean;
1140
- /**
1141
- * Take a memory sample
1142
- * Returns null if memory API is not available
1143
- */
1144
- sample(): MemorySample | null;
1145
- /**
1146
- * Calculate heap delta between two samples
1147
- * Returns the difference in KB (positive = memory increased)
1148
- */
1149
- calculateDelta(before: MemorySample | null, after: MemorySample | null): number | null;
1150
- }
1151
- /**
1152
- * Get the memory sampler singleton
1153
- */
1154
- declare function getMemorySampler(): MemorySampler;
1155
- /**
1156
- * Reset the memory sampler (for testing)
1157
- */
1158
- declare function resetMemorySampler(): void;
1159
-
1160
- /**
1161
- * Long Task Observer
1162
- * Observes long tasks (>50ms) using PerformanceObserver API
1163
- * Gracefully degrades on unsupported browsers
1164
- */
1165
- /**
1166
- * Long Task Observer class
1167
- * Counts tasks that take longer than 50ms during a measurement period
1168
- */
1169
- declare class LongTaskObserver {
1170
- private observer;
1171
- private longTaskCount;
1172
- private isSupported;
1173
- private isObserving;
1174
- constructor();
1175
- /**
1176
- * Check if PerformanceObserver with longtask support is available
1177
- */
1178
- private checkSupport;
1179
- /**
1180
- * Check if long task observation is available
1181
- */
1182
- isAvailable(): boolean;
1183
- /**
1184
- * Start observing long tasks
1185
- */
1186
- start(): void;
1187
- /**
1188
- * Stop observing and return the count of long tasks
1189
- */
1190
- stop(): number;
1191
- /**
1192
- * Reset the long task counter
1193
- */
1194
- reset(): void;
1195
- /**
1196
- * Get current count without stopping observation
1197
- */
1198
- getCount(): number;
1199
- /**
1200
- * Check if currently observing
1201
- */
1202
- isActive(): boolean;
1203
- }
1204
- /**
1205
- * Get the long task observer singleton
1206
- */
1207
- declare function getLongTaskObserver(): LongTaskObserver;
1208
- /**
1209
- * Reset the long task observer (for testing)
1210
- */
1211
- declare function resetLongTaskObserver(): void;
1212
-
1213
- 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, type DependencyEntry, type DependencyManifest, type DependencyType, type ElementConfig, type ErrorMetadata, type ErrorType, type FetchMetadata, type FetchOptions, type FetchResult, type LayoutElement, LongTaskObserver, MemorySampler, type ParsedVersion, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type SessionInfo, SessionManager, 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, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, compareVersions, configureAnalytics, createRegistry, detectCircularDependencies, extractBindingKeys, extractDependencies, extractDependenciesFromCode, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getDependencyTree, getFromCache, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getRegistryUrl, getSessionManager, hasTemplateSyntax, invalidateCache, isComponentAvailable, isValidSpecifier, parseVersion, prefetchComponents, processStyles, render, renderDynamicList, resetAnalytics, resetLongTaskObserver, resetMemorySampler, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, setInCache, setRegistryUrl, updateStyles, validateAssertion, validateProps };