@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.
@@ -1,495 +1,24 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res) => function __init() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
- };
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
-
23
- // src/tailwind.ts
24
- var tailwind_exports = {};
25
- __export(tailwind_exports, {
26
- DEFAULT_SERVLY_TAILWIND_CONFIG: () => DEFAULT_SERVLY_TAILWIND_CONFIG,
27
- addCustomStyles: () => addCustomStyles,
28
- default: () => tailwind_default,
29
- getTailwind: () => getTailwind,
30
- initServlyTailwind: () => initServlyTailwind,
31
- injectTailwind: () => injectTailwind,
32
- isTailwindLoaded: () => isTailwindLoaded,
33
- removeCustomStyles: () => removeCustomStyles,
34
- removeTailwind: () => removeTailwind,
35
- updateTailwindConfig: () => updateTailwindConfig
36
- });
37
- function injectTailwind(config = {}) {
38
- return new Promise((resolve, reject) => {
39
- if (tailwindInjected && tailwindScript) {
40
- resolve();
41
- return;
42
- }
43
- if (typeof document === "undefined") {
44
- resolve();
45
- return;
46
- }
47
- if (window.tailwind) {
48
- tailwindInjected = true;
49
- config.onReady?.();
50
- resolve();
51
- return;
52
- }
53
- const {
54
- cdnUrl = DEFAULT_TAILWIND_CDN,
55
- config: tailwindConfig,
56
- plugins = [],
57
- usePlayCdn = false,
58
- onReady,
59
- onError
60
- } = config;
61
- const script = document.createElement("script");
62
- script.src = usePlayCdn ? `${cdnUrl}?plugins=forms,typography,aspect-ratio` : cdnUrl;
63
- script.async = true;
64
- script.onload = () => {
65
- tailwindInjected = true;
66
- tailwindScript = script;
67
- if (tailwindConfig && window.tailwind) {
68
- window.tailwind.config = tailwindConfig;
69
- }
70
- onReady?.();
71
- resolve();
72
- };
73
- script.onerror = (event) => {
74
- const error = new Error(`Failed to load Tailwind CSS from ${cdnUrl}`);
75
- onError?.(error);
76
- reject(error);
77
- };
78
- document.head.appendChild(script);
79
- });
80
- }
81
- function removeTailwind() {
82
- if (tailwindScript && tailwindScript.parentNode) {
83
- tailwindScript.parentNode.removeChild(tailwindScript);
84
- tailwindScript = null;
85
- tailwindInjected = false;
86
- delete window.tailwind;
87
- }
88
- }
89
- function isTailwindLoaded() {
90
- return tailwindInjected || !!window.tailwind;
91
- }
92
- function getTailwind() {
93
- return window.tailwind;
94
- }
95
- function updateTailwindConfig(config) {
96
- if (window.tailwind) {
97
- window.tailwind.config = {
98
- ...window.tailwind.config,
99
- ...config
100
- };
101
- }
102
- }
103
- function addCustomStyles(css, id) {
104
- if (typeof document === "undefined") {
105
- throw new Error("addCustomStyles can only be used in browser environment");
106
- }
107
- const styleId = id || `servly-custom-styles-${Date.now()}`;
108
- let existingStyle = document.getElementById(styleId);
109
- if (existingStyle) {
110
- existingStyle.textContent = css;
111
- return existingStyle;
112
- }
113
- const style = document.createElement("style");
114
- style.id = styleId;
115
- style.textContent = css;
116
- document.head.appendChild(style);
117
- return style;
118
- }
119
- function removeCustomStyles(id) {
120
- if (typeof document === "undefined") return;
121
- const style = document.getElementById(id);
122
- if (style && style.parentNode) {
123
- style.parentNode.removeChild(style);
124
- }
125
- }
126
- async function initServlyTailwind(customConfig) {
127
- const config = customConfig ? { ...DEFAULT_SERVLY_TAILWIND_CONFIG, ...customConfig } : DEFAULT_SERVLY_TAILWIND_CONFIG;
128
- await injectTailwind({
129
- config,
130
- usePlayCdn: true
131
- });
132
- }
133
- var DEFAULT_TAILWIND_CDN, tailwindInjected, tailwindScript, DEFAULT_SERVLY_TAILWIND_CONFIG, tailwind_default;
134
- var init_tailwind = __esm({
135
- "src/tailwind.ts"() {
136
- "use strict";
137
- DEFAULT_TAILWIND_CDN = "https://cdn.tailwindcss.com";
138
- tailwindInjected = false;
139
- tailwindScript = null;
140
- DEFAULT_SERVLY_TAILWIND_CONFIG = {
141
- theme: {
142
- extend: {
143
- // Add any Servly-specific theme extensions here
144
- }
145
- },
146
- // Safelist common dynamic classes
147
- safelist: [
148
- // Spacing
149
- { pattern: /^(p|m|gap)-/ },
150
- // Sizing
151
- { pattern: /^(w|h|min-w|min-h|max-w|max-h)-/ },
152
- // Flexbox
153
- { pattern: /^(flex|justify|items|self)-/ },
154
- // Grid
155
- { pattern: /^(grid|col|row)-/ },
156
- // Colors
157
- { pattern: /^(bg|text|border|ring)-/ },
158
- // Typography
159
- { pattern: /^(font|text|leading|tracking)-/ },
160
- // Borders
161
- { pattern: /^(rounded|border)-/ },
162
- // Effects
163
- { pattern: /^(shadow|opacity|blur)-/ },
164
- // Transforms
165
- { pattern: /^(scale|rotate|translate|skew)-/ },
166
- // Transitions
167
- { pattern: /^(transition|duration|ease|delay)-/ }
168
- ]
169
- };
170
- tailwind_default = {
171
- injectTailwind,
172
- removeTailwind,
173
- isTailwindLoaded,
174
- getTailwind,
175
- updateTailwindConfig,
176
- addCustomStyles,
177
- removeCustomStyles,
178
- initServlyTailwind,
179
- DEFAULT_SERVLY_TAILWIND_CONFIG
180
- };
181
- }
182
- });
183
-
184
- // src/registry.ts
185
- var registry_exports = {};
186
- __export(registry_exports, {
187
- buildRegistryFromBundle: () => buildRegistryFromBundle,
188
- collectAllDependencies: () => collectAllDependencies,
189
- createRegistry: () => createRegistry,
190
- detectCircularDependencies: () => detectCircularDependencies,
191
- extractDependencies: () => extractDependencies,
192
- extractDependenciesFromCode: () => extractDependenciesFromCode
193
- });
194
- function createRegistry() {
195
- const components = /* @__PURE__ */ new Map();
196
- return {
197
- get(id, version) {
198
- if (version) {
199
- const key = `${id}@${version}`;
200
- if (components.has(key)) {
201
- return components.get(key);
202
- }
203
- }
204
- for (const [key, component] of components) {
205
- if (key.startsWith(`${id}@`)) {
206
- return component;
207
- }
208
- }
209
- return components.get(id);
210
- },
211
- has(id, version) {
212
- if (version) {
213
- return components.has(`${id}@${version}`);
214
- }
215
- for (const key of components.keys()) {
216
- if (key.startsWith(`${id}@`) || key === id) {
217
- return true;
218
- }
219
- }
220
- return false;
221
- },
222
- set(id, version, component) {
223
- components.set(`${id}@${version}`, component);
224
- }
225
- };
226
- }
227
- function buildRegistryFromBundle(data) {
228
- const registry = createRegistry();
229
- registry.set(data.id, data.version, {
230
- layout: data.layout,
231
- propsInterface: data.propsInterface
232
- });
233
- if (data.bundle) {
234
- for (const [key, component] of Object.entries(data.bundle)) {
235
- const [id, version] = key.split("@");
236
- if (id && version) {
237
- registry.set(id, version, component);
238
- }
239
- }
240
- }
241
- return registry;
242
- }
243
- function extractDependencies(elements) {
244
- const dependencies = [];
245
- for (const element of elements) {
246
- const config = element.configuration;
247
- if (!config) continue;
248
- if (config.componentViewRef) {
249
- dependencies.push({
250
- id: config.componentViewRef,
251
- version: config.componentViewVersion,
252
- type: "viewRef",
253
- elementId: element.i
254
- });
255
- }
256
- if (config.blueprint) {
257
- dependencies.push({
258
- id: config.blueprint,
259
- version: config.blueprintVersion,
260
- type: "blueprint",
261
- elementId: element.i
262
- });
263
- }
264
- }
265
- return dependencies;
266
- }
267
- function extractDependenciesFromCode(code) {
268
- const dependencies = [];
269
- const pattern = /renderDynamicList\s*\(\s*\{[^}]*blueprint\s*:\s*["']([^"']+)["']/g;
270
- let match;
271
- while ((match = pattern.exec(code)) !== null) {
272
- dependencies.push({
273
- id: match[1],
274
- type: "blueprint"
275
- });
276
- }
277
- return dependencies;
278
- }
279
- async function collectAllDependencies(rootId, rootVersion, fetchComponent2, maxDepth = 10) {
280
- const manifest = {};
281
- const visited = /* @__PURE__ */ new Set();
282
- async function collect(id, version, via, depth) {
283
- if (depth > maxDepth) {
284
- console.warn(`Max dependency depth (${maxDepth}) reached for ${id}`);
285
- return;
286
- }
287
- const key = `${id}@${version || "latest"}`;
288
- if (visited.has(key)) {
289
- return;
290
- }
291
- visited.add(key);
292
- try {
293
- const component = await fetchComponent2(id, version);
294
- if (!component) {
295
- console.warn(`Dependency not found: ${id}@${version || "latest"}`);
296
- return;
297
- }
298
- manifest[id] = {
299
- version: version || "latest",
300
- resolved: component.version,
301
- type: via ? "viewRef" : "viewRef",
302
- // Will be set by caller
303
- via
304
- };
305
- const nestedDeps = extractDependencies(component.layout);
306
- for (const dep of nestedDeps) {
307
- await collect(dep.id, dep.version, id, depth + 1);
308
- }
309
- } catch (error) {
310
- console.error(`Failed to fetch dependency ${id}:`, error);
311
- }
312
- }
313
- const rootComponent = await fetchComponent2(rootId, rootVersion);
314
- if (rootComponent) {
315
- const rootDeps = extractDependencies(rootComponent.layout);
316
- for (const dep of rootDeps) {
317
- manifest[dep.id] = {
318
- version: dep.version || "latest",
319
- resolved: "",
320
- // Will be filled when fetched
321
- type: dep.type
322
- };
323
- await collect(dep.id, dep.version, void 0, 1);
324
- }
325
- }
326
- return manifest;
327
- }
328
- function detectCircularDependencies(manifest) {
329
- const graph = /* @__PURE__ */ new Map();
330
- for (const [id, entry] of Object.entries(manifest)) {
331
- if (entry.via) {
332
- const deps = graph.get(entry.via) || [];
333
- deps.push(id);
334
- graph.set(entry.via, deps);
335
- }
336
- }
337
- const visited = /* @__PURE__ */ new Set();
338
- const stack = /* @__PURE__ */ new Set();
339
- const path = [];
340
- function dfs(node) {
341
- if (stack.has(node)) {
342
- const cycleStart = path.indexOf(node);
343
- return [...path.slice(cycleStart), node];
344
- }
345
- if (visited.has(node)) {
346
- return null;
347
- }
348
- visited.add(node);
349
- stack.add(node);
350
- path.push(node);
351
- const neighbors = graph.get(node) || [];
352
- for (const neighbor of neighbors) {
353
- const cycle = dfs(neighbor);
354
- if (cycle) return cycle;
355
- }
356
- stack.delete(node);
357
- path.pop();
358
- return null;
359
- }
360
- for (const node of graph.keys()) {
361
- const cycle = dfs(node);
362
- if (cycle) return cycle;
363
- }
364
- return null;
365
- }
366
- var init_registry = __esm({
367
- "src/registry.ts"() {
368
- "use strict";
369
- }
370
- });
371
-
372
- // src/index.ts
373
- var index_exports = {};
374
- __export(index_exports, {
375
- AnalyticsCollector: () => AnalyticsCollector,
376
- DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
377
- DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
378
- DEFAULT_SERVLY_TAILWIND_CONFIG: () => DEFAULT_SERVLY_TAILWIND_CONFIG,
379
- EVENT_HANDLERS: () => EVENT_HANDLERS,
380
- EventSystem: () => EventSystem,
381
- LongTaskObserver: () => LongTaskObserver,
382
- MemorySampler: () => MemorySampler,
383
- OverrideSystem: () => OverrideSystem,
384
- SessionManager: () => SessionManager,
385
- StateManager: () => StateManager,
386
- addClass: () => addClass,
387
- addCustomStyles: () => addCustomStyles,
388
- analytics: () => analytics,
389
- applyStyles: () => applyStyles,
390
- batchFetchComponents: () => batchFetchComponents,
391
- buildClassName: () => buildClassName,
392
- buildElementStyles: () => buildElementStyles,
393
- buildRegistryFromBundle: () => buildRegistryFromBundle,
394
- bumpVersion: () => bumpVersion,
395
- camelToKebab: () => camelToKebab,
396
- clearAllCaches: () => clearAllCaches,
397
- clearLocalStorageCache: () => clearLocalStorageCache,
398
- clearMemoryCache: () => clearMemoryCache,
399
- clearStyles: () => clearStyles,
400
- collectAllDependencies: () => collectAllDependencies,
401
- collectAllViewDependencies: () => collectAllViewDependencies,
402
- compareVersions: () => compareVersions,
403
- configureAnalytics: () => configureAnalytics,
404
- createRegistry: () => createRegistry,
405
- createServlyRenderer: () => createServlyRenderer,
406
- createViewsMap: () => createViewsMap,
407
- deepMerge: () => deepMerge,
408
- deleteValueByPath: () => deleteValueByPath,
409
- detectCircularDependencies: () => detectCircularDependencies,
410
- extractBindingKeys: () => extractBindingKeys,
411
- extractDependencies: () => extractDependencies,
412
- extractDependenciesFromCode: () => extractDependenciesFromCode,
413
- extractOverrideDependencies: () => extractOverrideDependencies,
414
- extractReferencedViewIds: () => extractReferencedViewIds,
415
- fetchComponent: () => fetchComponent,
416
- fetchComponentWithDependencies: () => fetchComponentWithDependencies,
417
- formatStyleValue: () => formatStyleValue,
418
- formatVersion: () => formatVersion,
419
- generateTestCases: () => generateTestCases,
420
- getAnalytics: () => getAnalytics,
421
- getCacheKey: () => getCacheKey,
422
- getCleanupOverrides: () => getCleanupOverrides,
423
- getDependencyTree: () => getDependencyTree,
424
- getEventSystem: () => getEventSystem,
425
- getFromCache: () => getFromCache,
426
- getLocalStorage: () => getLocalStorage,
427
- getLongTaskObserver: () => getLongTaskObserver,
428
- getMemoryCacheSize: () => getMemoryCacheSize,
429
- getMemorySampler: () => getMemorySampler,
430
- getMountOverrides: () => getMountOverrides,
431
- getOverrideSystem: () => getOverrideSystem,
432
- getRegistryUrl: () => getRegistryUrl,
433
- getSessionManager: () => getSessionManager,
434
- getSessionStorage: () => getSessionStorage,
435
- getTailwind: () => getTailwind,
436
- getUrlInfo: () => getUrlInfo,
437
- getValueByPath: () => getValueByPath,
438
- goBack: () => goBack,
439
- goForward: () => goForward,
440
- hasClass: () => hasClass,
441
- hasDependencyOverrides: () => hasDependencyOverrides,
442
- hasOverrides: () => hasOverrides,
443
- hasTemplateSyntax: () => hasTemplateSyntax,
444
- initServlyTailwind: () => initServlyTailwind,
445
- injectTailwind: () => injectTailwind,
446
- invalidateCache: () => invalidateCache,
447
- isComponentAvailable: () => isComponentAvailable,
448
- isTailwindLoaded: () => isTailwindLoaded,
449
- isValidSpecifier: () => isValidSpecifier,
450
- navigateTo: () => navigateTo,
451
- parseVersion: () => parseVersion,
452
- prefetchComponents: () => prefetchComponents,
453
- processStyles: () => processStyles,
454
- removeClass: () => removeClass,
455
- removeCustomStyles: () => removeCustomStyles,
456
- removeLocalStorage: () => removeLocalStorage,
457
- removeSessionStorage: () => removeSessionStorage,
458
- removeTailwind: () => removeTailwind,
459
- render: () => render,
460
- renderDynamicList: () => renderDynamicList,
461
- renderInShadow: () => renderInShadow,
462
- renderNode: () => renderNode,
463
- resetAnalytics: () => resetAnalytics,
464
- resetEventSystem: () => resetEventSystem,
465
- resetLongTaskObserver: () => resetLongTaskObserver,
466
- resetMemorySampler: () => resetMemorySampler,
467
- resetOverrideSystem: () => resetOverrideSystem,
468
- resetSessionManager: () => resetSessionManager,
469
- resolveBindingPath: () => resolveBindingPath,
470
- resolveTemplate: () => resolveTemplate,
471
- resolveTemplateValue: () => resolveTemplateValue,
472
- resolveTemplatesDeep: () => resolveTemplatesDeep,
473
- resolveVersion: () => resolveVersion,
474
- runAllTests: () => runAllTests,
475
- runTestCase: () => runTestCase,
476
- satisfiesVersion: () => satisfiesVersion,
477
- setInCache: () => setInCache,
478
- setLocalStorage: () => setLocalStorage,
479
- setRegistryUrl: () => setRegistryUrl,
480
- setSessionStorage: () => setSessionStorage,
481
- setValueByPath: () => setValueByPath,
482
- toDomEventName: () => toDomEventName,
483
- toReactEventName: () => toReactEventName,
484
- toggleClass: () => toggleClass,
485
- updateStyles: () => updateStyles,
486
- updateTailwindConfig: () => updateTailwindConfig,
487
- validateAssertion: () => validateAssertion,
488
- validateProps: () => validateProps
489
- });
490
- module.exports = __toCommonJS(index_exports);
1
+ import {
2
+ DEFAULT_SERVLY_TAILWIND_CONFIG,
3
+ addCustomStyles,
4
+ getTailwind,
5
+ initServlyTailwind,
6
+ injectTailwind,
7
+ isTailwindLoaded,
8
+ removeCustomStyles,
9
+ removeTailwind,
10
+ updateTailwindConfig
11
+ } from "./chunk-RKUT63EF.mjs";
12
+ import {
13
+ buildRegistryFromBundle,
14
+ collectAllDependencies,
15
+ createRegistry,
16
+ detectCircularDependencies,
17
+ extractDependencies,
18
+ extractDependenciesFromCode
19
+ } from "./chunk-EQFZFPI7.mjs";
491
20
 
492
- // src/analyticsTypes.ts
21
+ // packages/runtime-core/src/analyticsTypes.ts
493
22
  var DEFAULT_ANALYTICS_CONFIG = {
494
23
  enabled: true,
495
24
  endpoint: "/api/v1/analytics/events",
@@ -507,7 +36,7 @@ var MAX_RETRY_ATTEMPTS = 3;
507
36
  var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
508
37
  var SDK_VERSION = "1.0.0";
509
38
 
510
- // src/sessionManager.ts
39
+ // packages/runtime-core/src/sessionManager.ts
511
40
  var SESSION_STORAGE_KEY = "servly_analytics_session";
512
41
  function generateUUID() {
513
42
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -569,8 +98,8 @@ function isSessionExpired(session) {
569
98
  return now - session.lastActivityAt > SESSION_TIMEOUT_MS;
570
99
  }
571
100
  var SessionManager = class {
101
+ session = null;
572
102
  constructor() {
573
- this.session = null;
574
103
  this.initialize();
575
104
  }
576
105
  /**
@@ -650,13 +179,15 @@ function resetSessionManager() {
650
179
  sessionManagerInstance = null;
651
180
  }
652
181
 
653
- // src/analytics.ts
182
+ // packages/runtime-core/src/analytics.ts
654
183
  var AnalyticsCollector = class {
184
+ config;
185
+ eventQueue = [];
186
+ flushTimer = null;
187
+ isEnabled;
188
+ isFlushing = false;
189
+ retryDelay = 1e3;
655
190
  constructor(config) {
656
- this.eventQueue = [];
657
- this.flushTimer = null;
658
- this.isFlushing = false;
659
- this.retryDelay = 1e3;
660
191
  this.config = { ...DEFAULT_ANALYTICS_CONFIG, ...config };
661
192
  this.isEnabled = this.config.enabled;
662
193
  this.startFlushTimer();
@@ -999,7 +530,7 @@ var analytics = {
999
530
  enable: () => getAnalytics().enable()
1000
531
  };
1001
532
 
1002
- // src/bindings.ts
533
+ // packages/runtime-core/src/bindings.ts
1003
534
  var BINDING_SOURCES = [
1004
535
  "props",
1005
536
  "state",
@@ -1383,7 +914,7 @@ function extractBindingKeys(template) {
1383
914
  return Array.from(keys);
1384
915
  }
1385
916
 
1386
- // src/styles.ts
917
+ // packages/runtime-core/src/styles.ts
1387
918
  var UNITLESS_PROPERTIES = /* @__PURE__ */ new Set([
1388
919
  "animationIterationCount",
1389
920
  "borderImageOutset",
@@ -1557,8 +1088,9 @@ function updateStyles(element, oldStyles, newStyles) {
1557
1088
  }
1558
1089
  }
1559
1090
 
1560
- // src/memorySampler.ts
1091
+ // packages/runtime-core/src/memorySampler.ts
1561
1092
  var MemorySampler = class {
1093
+ isSupported;
1562
1094
  constructor() {
1563
1095
  this.isSupported = this.checkSupport();
1564
1096
  }
@@ -1618,12 +1150,13 @@ function resetMemorySampler() {
1618
1150
  memorySamplerInstance = null;
1619
1151
  }
1620
1152
 
1621
- // src/longTaskObserver.ts
1153
+ // packages/runtime-core/src/longTaskObserver.ts
1622
1154
  var LongTaskObserver = class {
1155
+ observer = null;
1156
+ longTaskCount = 0;
1157
+ isSupported;
1158
+ isObserving = false;
1623
1159
  constructor() {
1624
- this.observer = null;
1625
- this.longTaskCount = 0;
1626
- this.isObserving = false;
1627
1160
  this.isSupported = this.checkSupport();
1628
1161
  }
1629
1162
  /**
@@ -1713,11 +1246,12 @@ function resetLongTaskObserver() {
1713
1246
  longTaskObserverInstance = null;
1714
1247
  }
1715
1248
 
1716
- // src/stateManager.ts
1249
+ // packages/runtime-core/src/stateManager.ts
1717
1250
  var StateManager = class {
1251
+ state = {};
1252
+ listeners = /* @__PURE__ */ new Set();
1253
+ config;
1718
1254
  constructor(config = {}) {
1719
- this.state = {};
1720
- this.listeners = /* @__PURE__ */ new Set();
1721
1255
  this.config = config;
1722
1256
  this.state = config.initialState || {};
1723
1257
  if (config.persistToLocalStorage && typeof localStorage !== "undefined") {
@@ -2103,7 +1637,7 @@ function getUrlInfo() {
2103
1637
  };
2104
1638
  }
2105
1639
 
2106
- // src/eventSystem.ts
1640
+ // packages/runtime-core/src/eventSystem.ts
2107
1641
  var builtInPlugins = {
2108
1642
  /**
2109
1643
  * Set state value
@@ -2369,9 +1903,11 @@ var builtInPlugins = {
2369
1903
  }
2370
1904
  };
2371
1905
  var EventSystem = class {
1906
+ config;
1907
+ pluginExecutors;
1908
+ debounceTimers = /* @__PURE__ */ new Map();
1909
+ throttleTimers = /* @__PURE__ */ new Map();
2372
1910
  constructor(config = {}) {
2373
- this.debounceTimers = /* @__PURE__ */ new Map();
2374
- this.throttleTimers = /* @__PURE__ */ new Map();
2375
1911
  this.config = config;
2376
1912
  this.pluginExecutors = {
2377
1913
  ...builtInPlugins,
@@ -2541,11 +2077,12 @@ function resetEventSystem() {
2541
2077
  }
2542
2078
  }
2543
2079
 
2544
- // src/overrides.ts
2080
+ // packages/runtime-core/src/overrides.ts
2545
2081
  var OverrideSystem = class {
2082
+ config;
2083
+ elementStates = /* @__PURE__ */ new Map();
2084
+ watchIntervals = /* @__PURE__ */ new Map();
2546
2085
  constructor(config = {}) {
2547
- this.elementStates = /* @__PURE__ */ new Map();
2548
- this.watchIntervals = /* @__PURE__ */ new Map();
2549
2086
  this.config = config;
2550
2087
  }
2551
2088
  /**
@@ -2762,7 +2299,317 @@ function resetOverrideSystem() {
2762
2299
  }
2763
2300
  }
2764
2301
 
2765
- // src/renderer.ts
2302
+ // packages/runtime-core/src/icons.ts
2303
+ var cdnEnabled = false;
2304
+ function setIconCdnEnabled(enabled) {
2305
+ cdnEnabled = enabled;
2306
+ }
2307
+ function isIconCdnEnabled() {
2308
+ return cdnEnabled;
2309
+ }
2310
+ var ICONIFY_COLLECTIONS = {
2311
+ Ai: "ant-design",
2312
+ Bi: "bi",
2313
+ Bs: "bi",
2314
+ Bx: "bx",
2315
+ Ci: "circum",
2316
+ Cg: "gg",
2317
+ Di: "devicon",
2318
+ Fi: "feather",
2319
+ Fc: "flat-color-icons",
2320
+ Fa: "fa-solid",
2321
+ Fa6: "fa6-solid",
2322
+ Gi: "game-icons",
2323
+ Go: "octicon",
2324
+ Gr: "grommet-icons",
2325
+ Hi: "heroicons-outline",
2326
+ Hi2: "heroicons",
2327
+ Im: "icomoon-free",
2328
+ Io: "ion",
2329
+ Io5: "ion",
2330
+ Lu: "lucide",
2331
+ Md: "ic",
2332
+ Pi: "ph",
2333
+ Ri: "ri",
2334
+ Rx: "radix-icons",
2335
+ Si: "simple-icons",
2336
+ Sl: "simple-line-icons",
2337
+ Tb: "tabler",
2338
+ Tfi: "themify",
2339
+ Vsc: "codicon",
2340
+ Wi: "wi"
2341
+ };
2342
+ var ICON_SET_STYLES = {
2343
+ Fi: { stroke: true },
2344
+ Lu: { stroke: true },
2345
+ Hi: { stroke: true },
2346
+ Hi2: { stroke: true },
2347
+ Tb: { stroke: true }
2348
+ };
2349
+ var iconCache = /* @__PURE__ */ new Map();
2350
+ var pendingFetches = /* @__PURE__ */ new Map();
2351
+ var registeredIcons = /* @__PURE__ */ new Map();
2352
+ function registerIcon(set, name, data) {
2353
+ const key = `${set}:${name}`;
2354
+ registeredIcons.set(key, data);
2355
+ iconCache.set(key, data);
2356
+ }
2357
+ function registerIcons(icons) {
2358
+ for (const [set, setIcons] of Object.entries(icons)) {
2359
+ for (const [name, data] of Object.entries(setIcons)) {
2360
+ registerIcon(set, name, data);
2361
+ }
2362
+ }
2363
+ }
2364
+ function isIconRegistered(icon) {
2365
+ const key = `${icon.set}:${icon.name}`;
2366
+ return registeredIcons.has(key);
2367
+ }
2368
+ function getRegisteredIconKeys() {
2369
+ return Array.from(registeredIcons.keys());
2370
+ }
2371
+ function toKebabCase(str) {
2372
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
2373
+ }
2374
+ function getIconifyName(name, set) {
2375
+ const prefixLength = set.length;
2376
+ let baseName = name;
2377
+ if (name.startsWith(set)) {
2378
+ baseName = name.slice(prefixLength);
2379
+ }
2380
+ let kebabName = toKebabCase(baseName);
2381
+ switch (set) {
2382
+ case "Md":
2383
+ if (baseName.startsWith("Outline")) {
2384
+ kebabName = toKebabCase(baseName.slice(7)) + "-outline";
2385
+ }
2386
+ kebabName = "baseline-" + kebabName;
2387
+ break;
2388
+ case "Hi2":
2389
+ if (baseName.startsWith("Outline")) {
2390
+ kebabName = toKebabCase(baseName.slice(7));
2391
+ } else if (baseName.startsWith("Solid")) {
2392
+ kebabName = toKebabCase(baseName.slice(5)) + "-solid";
2393
+ }
2394
+ break;
2395
+ case "Io":
2396
+ case "Io5":
2397
+ if (baseName.startsWith("Ios")) {
2398
+ kebabName = toKebabCase(baseName.slice(3));
2399
+ } else if (baseName.startsWith("Md")) {
2400
+ kebabName = toKebabCase(baseName.slice(2));
2401
+ }
2402
+ break;
2403
+ case "Pi":
2404
+ if (baseName.endsWith("Bold")) {
2405
+ kebabName = toKebabCase(baseName.slice(0, -4)) + "-bold";
2406
+ } else if (baseName.endsWith("Fill")) {
2407
+ kebabName = toKebabCase(baseName.slice(0, -4)) + "-fill";
2408
+ } else if (baseName.endsWith("Light")) {
2409
+ kebabName = toKebabCase(baseName.slice(0, -5)) + "-light";
2410
+ } else if (baseName.endsWith("Thin")) {
2411
+ kebabName = toKebabCase(baseName.slice(0, -4)) + "-thin";
2412
+ } else if (baseName.endsWith("Duotone")) {
2413
+ kebabName = toKebabCase(baseName.slice(0, -7)) + "-duotone";
2414
+ }
2415
+ break;
2416
+ }
2417
+ return kebabName;
2418
+ }
2419
+ async function fetchIconFromIconify(set, name) {
2420
+ if (!cdnEnabled) {
2421
+ return null;
2422
+ }
2423
+ const collection = ICONIFY_COLLECTIONS[set];
2424
+ if (!collection) {
2425
+ return null;
2426
+ }
2427
+ const iconName = getIconifyName(name, set);
2428
+ try {
2429
+ const url = `https://api.iconify.design/${collection}/${iconName}.svg`;
2430
+ const response = await fetch(url);
2431
+ if (!response.ok) {
2432
+ const altNames = [
2433
+ iconName.replace(/-outline$/, ""),
2434
+ iconName.replace(/-solid$/, ""),
2435
+ iconName.replace(/-fill$/, ""),
2436
+ iconName.replace(/^baseline-/, "")
2437
+ ].filter((alt) => alt !== iconName);
2438
+ for (const altName of altNames) {
2439
+ const altUrl = `https://api.iconify.design/${collection}/${altName}.svg`;
2440
+ const altResponse = await fetch(altUrl);
2441
+ if (altResponse.ok) {
2442
+ return parseSvgResponse(await altResponse.text());
2443
+ }
2444
+ }
2445
+ return null;
2446
+ }
2447
+ return parseSvgResponse(await response.text());
2448
+ } catch {
2449
+ return null;
2450
+ }
2451
+ }
2452
+ function parseSvgResponse(svgText) {
2453
+ try {
2454
+ const parser = new DOMParser();
2455
+ const doc = parser.parseFromString(svgText, "image/svg+xml");
2456
+ const svg = doc.querySelector("svg");
2457
+ if (!svg) {
2458
+ return null;
2459
+ }
2460
+ const viewBox = svg.getAttribute("viewBox");
2461
+ const width = parseInt(svg.getAttribute("width") || "24", 10);
2462
+ const height = parseInt(svg.getAttribute("height") || "24", 10);
2463
+ const body = svg.innerHTML;
2464
+ return {
2465
+ body,
2466
+ width,
2467
+ height,
2468
+ viewBox: viewBox || `0 0 ${width} ${height}`
2469
+ };
2470
+ } catch {
2471
+ return null;
2472
+ }
2473
+ }
2474
+ async function getIconData(icon) {
2475
+ const key = `${icon.set}:${icon.name}`;
2476
+ if (iconCache.has(key)) {
2477
+ return iconCache.get(key);
2478
+ }
2479
+ if (pendingFetches.has(key)) {
2480
+ return pendingFetches.get(key);
2481
+ }
2482
+ if (!cdnEnabled) {
2483
+ return null;
2484
+ }
2485
+ const fetchPromise = fetchIconFromIconify(icon.set, icon.name);
2486
+ pendingFetches.set(key, fetchPromise);
2487
+ const data = await fetchPromise;
2488
+ pendingFetches.delete(key);
2489
+ if (data) {
2490
+ iconCache.set(key, data);
2491
+ }
2492
+ return data;
2493
+ }
2494
+ function getIconDataSync(icon) {
2495
+ const key = `${icon.set}:${icon.name}`;
2496
+ return iconCache.get(key) || null;
2497
+ }
2498
+ function createIconSVG(icon, data, size = 24, color = "currentColor") {
2499
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2500
+ svg.setAttribute("width", String(size));
2501
+ svg.setAttribute("height", String(size));
2502
+ svg.setAttribute("viewBox", data.viewBox || "0 0 24 24");
2503
+ svg.setAttribute("data-icon-name", icon.name);
2504
+ svg.setAttribute("data-icon-set", icon.set);
2505
+ svg.setAttribute("class", `servly-icon servly-icon-${icon.set.toLowerCase()}`);
2506
+ const style = ICON_SET_STYLES[icon.set];
2507
+ if (style?.stroke) {
2508
+ svg.setAttribute("fill", "none");
2509
+ svg.setAttribute("stroke", color);
2510
+ svg.setAttribute("stroke-width", "2");
2511
+ svg.setAttribute("stroke-linecap", "round");
2512
+ svg.setAttribute("stroke-linejoin", "round");
2513
+ } else {
2514
+ svg.setAttribute("fill", color);
2515
+ }
2516
+ svg.innerHTML = data.body;
2517
+ const paths = svg.querySelectorAll("path, circle, rect, polygon, line, polyline");
2518
+ paths.forEach((el) => {
2519
+ if (!el.getAttribute("fill") || el.getAttribute("fill") === "currentColor") {
2520
+ if (style?.stroke) {
2521
+ el.setAttribute("stroke", color);
2522
+ } else {
2523
+ el.setAttribute("fill", color);
2524
+ }
2525
+ }
2526
+ });
2527
+ return svg;
2528
+ }
2529
+ function createPlaceholderIcon(icon, size = 24, color = "currentColor") {
2530
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2531
+ svg.setAttribute("width", String(size));
2532
+ svg.setAttribute("height", String(size));
2533
+ svg.setAttribute("viewBox", "0 0 24 24");
2534
+ svg.setAttribute("fill", "none");
2535
+ svg.setAttribute("stroke", color);
2536
+ svg.setAttribute("stroke-width", "2");
2537
+ svg.setAttribute("stroke-linecap", "round");
2538
+ svg.setAttribute("stroke-linejoin", "round");
2539
+ svg.setAttribute("data-icon-name", icon.name);
2540
+ svg.setAttribute("data-icon-set", icon.set);
2541
+ svg.setAttribute("data-icon-missing", "true");
2542
+ svg.setAttribute("class", "servly-icon servly-icon-placeholder");
2543
+ const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
2544
+ circle.setAttribute("cx", "12");
2545
+ circle.setAttribute("cy", "12");
2546
+ circle.setAttribute("r", "10");
2547
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
2548
+ path.setAttribute("d", "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3");
2549
+ const dot = document.createElementNS("http://www.w3.org/2000/svg", "line");
2550
+ dot.setAttribute("x1", "12");
2551
+ dot.setAttribute("y1", "17");
2552
+ dot.setAttribute("x2", "12.01");
2553
+ dot.setAttribute("y2", "17");
2554
+ svg.appendChild(circle);
2555
+ svg.appendChild(path);
2556
+ svg.appendChild(dot);
2557
+ return svg;
2558
+ }
2559
+ function renderIcon(container, icon, size = 24, color = "currentColor") {
2560
+ const cachedData = getIconDataSync(icon);
2561
+ if (cachedData) {
2562
+ const svg = createIconSVG(icon, cachedData, size, color);
2563
+ container.innerHTML = "";
2564
+ container.appendChild(svg);
2565
+ return;
2566
+ }
2567
+ if (!cdnEnabled) {
2568
+ const placeholder2 = createPlaceholderIcon(icon, size, color);
2569
+ container.innerHTML = "";
2570
+ container.appendChild(placeholder2);
2571
+ console.warn(
2572
+ `[Icons] Icon not bundled: ${icon.set}:${icon.name}. Use registerIcon() to bundle it, or enable CDN with setIconCdnEnabled(true).`
2573
+ );
2574
+ return;
2575
+ }
2576
+ const placeholder = createPlaceholderIcon(icon, size, color);
2577
+ placeholder.setAttribute("data-icon-loading", "true");
2578
+ placeholder.removeAttribute("data-icon-missing");
2579
+ container.innerHTML = "";
2580
+ container.appendChild(placeholder);
2581
+ getIconData(icon).then((data) => {
2582
+ if (data) {
2583
+ const svg = createIconSVG(icon, data, size, color);
2584
+ container.innerHTML = "";
2585
+ container.appendChild(svg);
2586
+ } else {
2587
+ placeholder.setAttribute("data-icon-missing", "true");
2588
+ placeholder.removeAttribute("data-icon-loading");
2589
+ }
2590
+ });
2591
+ }
2592
+ async function preloadIcons(icons) {
2593
+ await Promise.all(icons.map((icon) => getIconData(icon)));
2594
+ }
2595
+ function clearIconCache() {
2596
+ iconCache.clear();
2597
+ pendingFetches.clear();
2598
+ registeredIcons.forEach((data, key) => {
2599
+ iconCache.set(key, data);
2600
+ });
2601
+ }
2602
+ function isIconSetSupported(set) {
2603
+ return set in ICONIFY_COLLECTIONS;
2604
+ }
2605
+ function getSupportedIconSets() {
2606
+ return Object.keys(ICONIFY_COLLECTIONS);
2607
+ }
2608
+ function getIconifyCollection(set) {
2609
+ return ICONIFY_COLLECTIONS[set];
2610
+ }
2611
+
2612
+ // packages/runtime-core/src/renderer.ts
2766
2613
  var COMPONENT_TO_TAG = {
2767
2614
  container: "div",
2768
2615
  text: "span",
@@ -3144,6 +2991,9 @@ function renderElement(element, tree, context, eventHandlers, elementStates, sta
3144
2991
  if (element.componentId === "slot") {
3145
2992
  return renderSlotElement(element, tree, context, eventHandlers, elementStates, state, isRootElement);
3146
2993
  }
2994
+ if (element.componentId === "icon") {
2995
+ return renderIconElement(element, context, eventHandlers, elementStates, state, isRootElement);
2996
+ }
3147
2997
  const elementState = createElement(element, context, eventHandlers, isRootElement, state);
3148
2998
  elementStates.set(element.i, elementState);
3149
2999
  const config = element.configuration;
@@ -3161,6 +3011,40 @@ function renderElement(element, tree, context, eventHandlers, elementStates, sta
3161
3011
  }
3162
3012
  return elementState.domElement;
3163
3013
  }
3014
+ function renderIconElement(element, context, eventHandlers, elementStates, state, isRootElement) {
3015
+ const config = element.configuration || {};
3016
+ const icon = config.icon;
3017
+ const iconColor = config.iconColor || "currentColor";
3018
+ const iconSize = config.iconSize || 24;
3019
+ const wrapper = document.createElement("div");
3020
+ wrapper.setAttribute("data-servly-id", element.i);
3021
+ wrapper.className = "pointer-events-none";
3022
+ const styles = buildElementStyles(element, context);
3023
+ applyStyles(wrapper, styles);
3024
+ const className = buildClassName(element, context);
3025
+ if (className) {
3026
+ wrapper.className = `pointer-events-none ${className}`;
3027
+ }
3028
+ if (state.iconRenderer && icon) {
3029
+ const iconElement = state.iconRenderer(icon, iconSize, iconColor, "");
3030
+ if (iconElement) {
3031
+ wrapper.appendChild(iconElement);
3032
+ }
3033
+ } else if (icon) {
3034
+ renderIcon(wrapper, icon, iconSize, iconColor);
3035
+ }
3036
+ const elementState = {
3037
+ element,
3038
+ domElement: wrapper,
3039
+ styles,
3040
+ className: wrapper.className,
3041
+ textContent: "",
3042
+ eventListeners: /* @__PURE__ */ new Map()
3043
+ };
3044
+ elementStates.set(element.i, elementState);
3045
+ attachEventHandlers(wrapper, element, eventHandlers, context, elementState, isRootElement, state);
3046
+ return wrapper;
3047
+ }
3164
3048
  function renderComponentViewElement(element, tree, context, eventHandlers, elementStates, state, isRootElement) {
3165
3049
  const componentViewId = `${element.componentId}-${element.i}`;
3166
3050
  if (globalRenderingStack.has(componentViewId)) {
@@ -3180,7 +3064,15 @@ function renderComponentViewElement(element, tree, context, eventHandlers, eleme
3180
3064
  viewLayout = component.layout;
3181
3065
  }
3182
3066
  }
3067
+ if (!viewLayout && state.views === void 0 && state.viewsArray) {
3068
+ const viewsArray = state.viewsArray;
3069
+ const found = viewsArray.find((v) => v.id === element.componentId);
3070
+ if (found) {
3071
+ viewLayout = found.layout;
3072
+ }
3073
+ }
3183
3074
  if (!viewLayout) {
3075
+ console.warn(`[Servly] Component not found: ${element.componentId}. Available in views: ${state.views ? Array.from(state.views.keys()).join(", ") : "none"}. Registry has: ${state.componentRegistry?.has(element.componentId) ? "yes" : "no"}`);
3184
3076
  const placeholder = document.createElement("div");
3185
3077
  placeholder.className = "border-2 border-yellow-500 border-dashed p-4 bg-yellow-50";
3186
3078
  placeholder.innerHTML = `<p class="text-yellow-600 text-sm">Component not found: ${element.componentId}</p>`;
@@ -3294,14 +3186,26 @@ function render(options) {
3294
3186
  eventHandlers,
3295
3187
  componentRegistry,
3296
3188
  onDependencyNeeded,
3297
- views,
3189
+ views: viewsInput,
3298
3190
  enableStateManager,
3299
3191
  initialState,
3300
3192
  onStateChange,
3301
3193
  pluginExecutors,
3302
3194
  onNavigate,
3303
- onApiCall
3195
+ onApiCall,
3196
+ iconRenderer
3304
3197
  } = options;
3198
+ let views;
3199
+ if (viewsInput instanceof Map) {
3200
+ views = viewsInput;
3201
+ } else if (Array.isArray(viewsInput)) {
3202
+ views = /* @__PURE__ */ new Map();
3203
+ for (const view of viewsInput) {
3204
+ if (view && view.id) {
3205
+ views.set(view.id, view);
3206
+ }
3207
+ }
3208
+ }
3305
3209
  const startTime = performance.now();
3306
3210
  const memorySampler = getMemorySampler();
3307
3211
  const longTaskObserver = getLongTaskObserver();
@@ -3349,7 +3253,8 @@ function render(options) {
3349
3253
  eventSystem,
3350
3254
  stateManager,
3351
3255
  overrideSystem,
3352
- enableOverrides: hasAnyOverrides
3256
+ enableOverrides: hasAnyOverrides,
3257
+ iconRenderer
3353
3258
  };
3354
3259
  container.innerHTML = "";
3355
3260
  if (rootElements.length === 0) {
@@ -3626,7 +3531,7 @@ async function createServlyRenderer(options) {
3626
3531
  container = containerOption;
3627
3532
  }
3628
3533
  if (shouldInjectTailwind) {
3629
- const { initServlyTailwind: initServlyTailwind2 } = await Promise.resolve().then(() => (init_tailwind(), tailwind_exports));
3534
+ const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-UHWJOUFF.mjs");
3630
3535
  await initServlyTailwind2(tailwindConfig);
3631
3536
  }
3632
3537
  const activeRenders = [];
@@ -3724,7 +3629,7 @@ function collectAllViewDependencies(views, startViewId) {
3724
3629
  return collected;
3725
3630
  }
3726
3631
 
3727
- // src/cache.ts
3632
+ // packages/runtime-core/src/cache.ts
3728
3633
  var DEFAULT_CACHE_CONFIG = {
3729
3634
  maxEntries: 50,
3730
3635
  ttl: 5 * 60 * 1e3,
@@ -3968,8 +3873,7 @@ function invalidateCache(id, version, config = DEFAULT_CACHE_CONFIG) {
3968
3873
  }
3969
3874
  }
3970
3875
 
3971
- // src/fetcher.ts
3972
- init_registry();
3876
+ // packages/runtime-core/src/fetcher.ts
3973
3877
  var DEFAULT_RETRY_CONFIG = {
3974
3878
  maxRetries: 3,
3975
3879
  initialDelay: 1e3,
@@ -4199,7 +4103,7 @@ async function fetchComponent(id, options = {}) {
4199
4103
  async function fetchComponentWithDependencies(id, options = {}) {
4200
4104
  const result = await fetchComponent(id, { ...options, includeBundle: true });
4201
4105
  if (result.pendingDependencies && result.pendingDependencies.length > 0) {
4202
- const { createRegistry: createRegistry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
4106
+ const { createRegistry: createRegistry2 } = await import("./registry-HKUXXQ5V.mjs");
4203
4107
  const registry = result.registry || createRegistry2();
4204
4108
  await Promise.all(
4205
4109
  result.pendingDependencies.map(async (dep) => {
@@ -4305,7 +4209,7 @@ async function getDependencyTree(id, options = {}) {
4305
4209
  return data.data;
4306
4210
  }
4307
4211
 
4308
- // src/version.ts
4212
+ // packages/runtime-core/src/version.ts
4309
4213
  function parseVersion(version) {
4310
4214
  const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/);
4311
4215
  if (!match) return null;
@@ -4417,7 +4321,7 @@ function formatVersion(version) {
4417
4321
  return `v${parsed.major}.${parsed.minor}.${parsed.patch}`;
4418
4322
  }
4419
4323
 
4420
- // src/testRunner.ts
4324
+ // packages/runtime-core/src/testRunner.ts
4421
4325
  function runTestCase(elements, testCase, container) {
4422
4326
  const startTime = performance.now();
4423
4327
  const assertionResults = [];
@@ -4672,11 +4576,142 @@ function getSampleValue(def) {
4672
4576
  }
4673
4577
  }
4674
4578
 
4675
- // src/index.ts
4676
- init_registry();
4677
- init_tailwind();
4678
- // Annotate the CommonJS export names for ESM import in node:
4679
- 0 && (module.exports = {
4579
+ // packages/runtime-core/src/iconExtractor.ts
4580
+ var REACT_ICONS_PACKAGES = {
4581
+ Ai: "react-icons/ai",
4582
+ Bi: "react-icons/bi",
4583
+ Bs: "react-icons/bs",
4584
+ Cg: "react-icons/cg",
4585
+ Di: "react-icons/di",
4586
+ Fa: "react-icons/fa",
4587
+ Fa6: "react-icons/fa6",
4588
+ Fc: "react-icons/fc",
4589
+ Fi: "react-icons/fi",
4590
+ Gi: "react-icons/gi",
4591
+ Go: "react-icons/go",
4592
+ Gr: "react-icons/gr",
4593
+ Hi: "react-icons/hi",
4594
+ Hi2: "react-icons/hi2",
4595
+ Im: "react-icons/im",
4596
+ Io: "react-icons/io",
4597
+ Io5: "react-icons/io5",
4598
+ Lu: "react-icons/lu",
4599
+ Md: "react-icons/md",
4600
+ Pi: "react-icons/pi",
4601
+ Ri: "react-icons/ri",
4602
+ Rx: "react-icons/rx",
4603
+ Si: "react-icons/si",
4604
+ Sl: "react-icons/sl",
4605
+ Tb: "react-icons/tb",
4606
+ Tfi: "react-icons/tfi",
4607
+ Vsc: "react-icons/vsc",
4608
+ Wi: "react-icons/wi"
4609
+ };
4610
+ async function extractIconFromReactIcons(iconName, iconSet) {
4611
+ const packagePath = REACT_ICONS_PACKAGES[iconSet];
4612
+ if (!packagePath) {
4613
+ console.warn(`Unknown icon set: ${iconSet}`);
4614
+ return null;
4615
+ }
4616
+ try {
4617
+ const iconModule = await import(packagePath);
4618
+ const IconComponent = iconModule[iconName];
4619
+ if (!IconComponent) {
4620
+ console.warn(`Icon not found: ${iconName} in ${packagePath}`);
4621
+ return null;
4622
+ }
4623
+ const React = await import("react");
4624
+ const { renderToStaticMarkup } = await import("react-dom/server");
4625
+ const svgString = renderToStaticMarkup(React.createElement(IconComponent, { size: 24 }));
4626
+ return parseSvgString(svgString);
4627
+ } catch (error) {
4628
+ console.error(`Failed to extract icon ${iconSet}:${iconName}:`, error);
4629
+ return null;
4630
+ }
4631
+ }
4632
+ function parseSvgString(svgString) {
4633
+ const viewBoxMatch = svgString.match(/viewBox="([^"]+)"/);
4634
+ const viewBox = viewBoxMatch ? viewBoxMatch[1] : "0 0 24 24";
4635
+ const widthMatch = svgString.match(/width="(\d+)"/);
4636
+ const heightMatch = svgString.match(/height="(\d+)"/);
4637
+ const width = widthMatch ? parseInt(widthMatch[1], 10) : 24;
4638
+ const height = heightMatch ? parseInt(heightMatch[1], 10) : 24;
4639
+ const bodyMatch = svgString.match(/<svg[^>]*>([\s\S]*)<\/svg>/);
4640
+ const body = bodyMatch ? bodyMatch[1].trim() : "";
4641
+ if (!body) {
4642
+ return null;
4643
+ }
4644
+ return {
4645
+ body,
4646
+ viewBox,
4647
+ width,
4648
+ height
4649
+ };
4650
+ }
4651
+ function findIconsInLayout(elements) {
4652
+ const icons = [];
4653
+ const seen = /* @__PURE__ */ new Set();
4654
+ for (const element of elements) {
4655
+ if (element.componentId === "icon" && element.configuration?.icon) {
4656
+ const icon = element.configuration.icon;
4657
+ const key = `${icon.set}:${icon.name}`;
4658
+ if (!seen.has(key)) {
4659
+ seen.add(key);
4660
+ icons.push({
4661
+ name: icon.name,
4662
+ set: icon.set,
4663
+ setName: icon.setName
4664
+ });
4665
+ }
4666
+ }
4667
+ }
4668
+ return icons;
4669
+ }
4670
+ async function extractIconsForLayout(elements) {
4671
+ const icons = findIconsInLayout(elements);
4672
+ const result = {};
4673
+ for (const icon of icons) {
4674
+ const data = await extractIconFromReactIcons(icon.name, icon.set);
4675
+ if (data) {
4676
+ if (!result[icon.set]) {
4677
+ result[icon.set] = {};
4678
+ }
4679
+ result[icon.set][icon.name] = data;
4680
+ }
4681
+ }
4682
+ return result;
4683
+ }
4684
+ function generateIconBundle(icons) {
4685
+ const lines = [
4686
+ "// Auto-generated icon bundle",
4687
+ "// Do not edit manually",
4688
+ "",
4689
+ "import { registerIcons, type IconData } from '@servlyadmin/runtime-core';",
4690
+ "",
4691
+ "const BUNDLED_ICONS: Record<string, Record<string, IconData>> = {"
4692
+ ];
4693
+ for (const [set, setIcons] of Object.entries(icons)) {
4694
+ lines.push(` ${set}: {`);
4695
+ for (const [name, data] of Object.entries(setIcons)) {
4696
+ const escapedBody = data.body.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n");
4697
+ lines.push(` ${name}: {`);
4698
+ lines.push(` body: '${escapedBody}',`);
4699
+ lines.push(` viewBox: '${data.viewBox}',`);
4700
+ if (data.width) lines.push(` width: ${data.width},`);
4701
+ if (data.height) lines.push(` height: ${data.height},`);
4702
+ lines.push(` },`);
4703
+ }
4704
+ lines.push(` },`);
4705
+ }
4706
+ lines.push("};");
4707
+ lines.push("");
4708
+ lines.push("// Register all bundled icons");
4709
+ lines.push("registerIcons(BUNDLED_ICONS);");
4710
+ lines.push("");
4711
+ lines.push("export { BUNDLED_ICONS };");
4712
+ return lines.join("\n");
4713
+ }
4714
+ export {
4680
4715
  AnalyticsCollector,
4681
4716
  DEFAULT_CACHE_CONFIG,
4682
4717
  DEFAULT_RETRY_CONFIG,
@@ -4699,6 +4734,7 @@ init_tailwind();
4699
4734
  bumpVersion,
4700
4735
  camelToKebab,
4701
4736
  clearAllCaches,
4737
+ clearIconCache,
4702
4738
  clearLocalStorageCache,
4703
4739
  clearMemoryCache,
4704
4740
  clearStyles,
@@ -4706,6 +4742,8 @@ init_tailwind();
4706
4742
  collectAllViewDependencies,
4707
4743
  compareVersions,
4708
4744
  configureAnalytics,
4745
+ createIconSVG,
4746
+ createPlaceholderIcon,
4709
4747
  createRegistry,
4710
4748
  createServlyRenderer,
4711
4749
  createViewsMap,
@@ -4715,12 +4753,16 @@ init_tailwind();
4715
4753
  extractBindingKeys,
4716
4754
  extractDependencies,
4717
4755
  extractDependenciesFromCode,
4756
+ extractIconFromReactIcons,
4757
+ extractIconsForLayout,
4718
4758
  extractOverrideDependencies,
4719
4759
  extractReferencedViewIds,
4720
4760
  fetchComponent,
4721
4761
  fetchComponentWithDependencies,
4762
+ findIconsInLayout,
4722
4763
  formatStyleValue,
4723
4764
  formatVersion,
4765
+ generateIconBundle,
4724
4766
  generateTestCases,
4725
4767
  getAnalytics,
4726
4768
  getCacheKey,
@@ -4728,15 +4770,20 @@ init_tailwind();
4728
4770
  getDependencyTree,
4729
4771
  getEventSystem,
4730
4772
  getFromCache,
4773
+ getIconData,
4774
+ getIconDataSync,
4775
+ getIconifyCollection,
4731
4776
  getLocalStorage,
4732
4777
  getLongTaskObserver,
4733
4778
  getMemoryCacheSize,
4734
4779
  getMemorySampler,
4735
4780
  getMountOverrides,
4736
4781
  getOverrideSystem,
4782
+ getRegisteredIconKeys,
4737
4783
  getRegistryUrl,
4738
4784
  getSessionManager,
4739
4785
  getSessionStorage,
4786
+ getSupportedIconSets,
4740
4787
  getTailwind,
4741
4788
  getUrlInfo,
4742
4789
  getValueByPath,
@@ -4750,12 +4797,18 @@ init_tailwind();
4750
4797
  injectTailwind,
4751
4798
  invalidateCache,
4752
4799
  isComponentAvailable,
4800
+ isIconCdnEnabled,
4801
+ isIconRegistered,
4802
+ isIconSetSupported,
4753
4803
  isTailwindLoaded,
4754
4804
  isValidSpecifier,
4755
4805
  navigateTo,
4756
4806
  parseVersion,
4757
4807
  prefetchComponents,
4808
+ preloadIcons,
4758
4809
  processStyles,
4810
+ registerIcon,
4811
+ registerIcons,
4759
4812
  removeClass,
4760
4813
  removeCustomStyles,
4761
4814
  removeLocalStorage,
@@ -4763,6 +4816,7 @@ init_tailwind();
4763
4816
  removeTailwind,
4764
4817
  render,
4765
4818
  renderDynamicList,
4819
+ renderIcon,
4766
4820
  renderInShadow,
4767
4821
  renderNode,
4768
4822
  resetAnalytics,
@@ -4779,6 +4833,7 @@ init_tailwind();
4779
4833
  runAllTests,
4780
4834
  runTestCase,
4781
4835
  satisfiesVersion,
4836
+ setIconCdnEnabled,
4782
4837
  setInCache,
4783
4838
  setLocalStorage,
4784
4839
  setRegistryUrl,
@@ -4791,4 +4846,4 @@ init_tailwind();
4791
4846
  updateTailwindConfig,
4792
4847
  validateAssertion,
4793
4848
  validateProps
4794
- });
4849
+ };