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