@servlyadmin/runtime-core 0.1.44 → 0.1.45
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.
|
@@ -33,6 +33,7 @@ function markTailwindAsLoaded() {
|
|
|
33
33
|
function preloadTailwind(cdnUrl, usePlayCdn) {
|
|
34
34
|
if (typeof document === "undefined") return;
|
|
35
35
|
if (document.querySelector("link[data-servly-tailwind-preload]")) return;
|
|
36
|
+
if (document.querySelector('script[src*="tailwindcss.com"]')) return;
|
|
36
37
|
const url = cdnUrl || DEFAULT_TAILWIND_CDN;
|
|
37
38
|
const fullUrl = usePlayCdn ? `${url}?plugins=forms,typography,aspect-ratio` : url;
|
|
38
39
|
const link = document.createElement("link");
|
|
@@ -40,15 +41,18 @@ function preloadTailwind(cdnUrl, usePlayCdn) {
|
|
|
40
41
|
link.as = "script";
|
|
41
42
|
link.href = fullUrl;
|
|
42
43
|
link.setAttribute("data-servly-tailwind-preload", "true");
|
|
44
|
+
link.setAttribute("crossorigin", "anonymous");
|
|
43
45
|
if (document.head.firstChild) {
|
|
44
46
|
document.head.insertBefore(link, document.head.firstChild);
|
|
45
47
|
} else {
|
|
46
48
|
document.head.appendChild(link);
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (!document.querySelector('link[rel="dns-prefetch"][href*="tailwindcss.com"]')) {
|
|
51
|
+
const dnsPrefetch = document.createElement("link");
|
|
52
|
+
dnsPrefetch.rel = "dns-prefetch";
|
|
53
|
+
dnsPrefetch.href = "https://cdn.tailwindcss.com";
|
|
54
|
+
document.head.appendChild(dnsPrefetch);
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
function preventFOUC() {
|
|
54
58
|
if (typeof document === "undefined") return;
|
|
@@ -135,7 +139,6 @@ function injectTailwind(config = {}) {
|
|
|
135
139
|
const {
|
|
136
140
|
cdnUrl = DEFAULT_TAILWIND_CDN,
|
|
137
141
|
config: tailwindConfig,
|
|
138
|
-
plugins = [],
|
|
139
142
|
usePlayCdn = false,
|
|
140
143
|
onReady,
|
|
141
144
|
onError,
|
package/dist/index.cjs
CHANGED
|
@@ -61,6 +61,7 @@ function markTailwindAsLoaded() {
|
|
|
61
61
|
function preloadTailwind(cdnUrl, usePlayCdn) {
|
|
62
62
|
if (typeof document === "undefined") return;
|
|
63
63
|
if (document.querySelector("link[data-servly-tailwind-preload]")) return;
|
|
64
|
+
if (document.querySelector('script[src*="tailwindcss.com"]')) return;
|
|
64
65
|
const url = cdnUrl || DEFAULT_TAILWIND_CDN;
|
|
65
66
|
const fullUrl = usePlayCdn ? `${url}?plugins=forms,typography,aspect-ratio` : url;
|
|
66
67
|
const link = document.createElement("link");
|
|
@@ -68,15 +69,18 @@ function preloadTailwind(cdnUrl, usePlayCdn) {
|
|
|
68
69
|
link.as = "script";
|
|
69
70
|
link.href = fullUrl;
|
|
70
71
|
link.setAttribute("data-servly-tailwind-preload", "true");
|
|
72
|
+
link.setAttribute("crossorigin", "anonymous");
|
|
71
73
|
if (document.head.firstChild) {
|
|
72
74
|
document.head.insertBefore(link, document.head.firstChild);
|
|
73
75
|
} else {
|
|
74
76
|
document.head.appendChild(link);
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
if (!document.querySelector('link[rel="dns-prefetch"][href*="tailwindcss.com"]')) {
|
|
79
|
+
const dnsPrefetch = document.createElement("link");
|
|
80
|
+
dnsPrefetch.rel = "dns-prefetch";
|
|
81
|
+
dnsPrefetch.href = "https://cdn.tailwindcss.com";
|
|
82
|
+
document.head.appendChild(dnsPrefetch);
|
|
83
|
+
}
|
|
80
84
|
}
|
|
81
85
|
function preventFOUC() {
|
|
82
86
|
if (typeof document === "undefined") return;
|
|
@@ -163,7 +167,6 @@ function injectTailwind(config = {}) {
|
|
|
163
167
|
const {
|
|
164
168
|
cdnUrl = DEFAULT_TAILWIND_CDN,
|
|
165
169
|
config: tailwindConfig,
|
|
166
|
-
plugins = [],
|
|
167
170
|
usePlayCdn = false,
|
|
168
171
|
onReady,
|
|
169
172
|
onError,
|
|
@@ -695,6 +698,7 @@ __export(index_exports, {
|
|
|
695
698
|
camelToKebab: () => camelToKebab,
|
|
696
699
|
clearAllCaches: () => clearAllCaches,
|
|
697
700
|
clearIconCache: () => clearIconCache,
|
|
701
|
+
clearIconStorageCache: () => clearIconStorageCache,
|
|
698
702
|
clearLocalStorageCache: () => clearLocalStorageCache,
|
|
699
703
|
clearMemoryCache: () => clearMemoryCache,
|
|
700
704
|
clearStyles: () => clearStyles,
|
|
@@ -3127,6 +3131,58 @@ function resetOverrideSystem() {
|
|
|
3127
3131
|
|
|
3128
3132
|
// src/icons.ts
|
|
3129
3133
|
var cdnEnabled = true;
|
|
3134
|
+
var ICON_CACHE_KEY = "servly-icon-cache";
|
|
3135
|
+
var ICON_CACHE_VERSION = "1";
|
|
3136
|
+
var localStorageLoaded = false;
|
|
3137
|
+
function loadIconCacheFromStorage() {
|
|
3138
|
+
if (localStorageLoaded) return;
|
|
3139
|
+
localStorageLoaded = true;
|
|
3140
|
+
if (typeof localStorage === "undefined") return;
|
|
3141
|
+
try {
|
|
3142
|
+
const cached = localStorage.getItem(ICON_CACHE_KEY);
|
|
3143
|
+
if (!cached) return;
|
|
3144
|
+
const parsed = JSON.parse(cached);
|
|
3145
|
+
if (parsed.version !== ICON_CACHE_VERSION) {
|
|
3146
|
+
localStorage.removeItem(ICON_CACHE_KEY);
|
|
3147
|
+
return;
|
|
3148
|
+
}
|
|
3149
|
+
for (const [key, data] of Object.entries(parsed.icons)) {
|
|
3150
|
+
if (!iconCache.has(key) && !registeredIcons.has(key)) {
|
|
3151
|
+
iconCache.set(key, data);
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
} catch {
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
function saveIconToStorage(key, data) {
|
|
3158
|
+
if (typeof localStorage === "undefined") return;
|
|
3159
|
+
try {
|
|
3160
|
+
const cached = localStorage.getItem(ICON_CACHE_KEY);
|
|
3161
|
+
let cacheData;
|
|
3162
|
+
if (cached) {
|
|
3163
|
+
cacheData = JSON.parse(cached);
|
|
3164
|
+
if (cacheData.version !== ICON_CACHE_VERSION) {
|
|
3165
|
+
cacheData = { version: ICON_CACHE_VERSION, icons: {} };
|
|
3166
|
+
}
|
|
3167
|
+
} else {
|
|
3168
|
+
cacheData = { version: ICON_CACHE_VERSION, icons: {} };
|
|
3169
|
+
}
|
|
3170
|
+
cacheData.icons[key] = data;
|
|
3171
|
+
const keys = Object.keys(cacheData.icons);
|
|
3172
|
+
if (keys.length > 500) {
|
|
3173
|
+
keys.slice(0, 100).forEach((k) => delete cacheData.icons[k]);
|
|
3174
|
+
}
|
|
3175
|
+
localStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cacheData));
|
|
3176
|
+
} catch {
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
function clearIconStorageCache() {
|
|
3180
|
+
if (typeof localStorage === "undefined") return;
|
|
3181
|
+
try {
|
|
3182
|
+
localStorage.removeItem(ICON_CACHE_KEY);
|
|
3183
|
+
} catch {
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3130
3186
|
function setIconCdnEnabled(enabled) {
|
|
3131
3187
|
cdnEnabled = enabled;
|
|
3132
3188
|
}
|
|
@@ -3299,6 +3355,7 @@ function parseSvgResponse(svgText) {
|
|
|
3299
3355
|
}
|
|
3300
3356
|
async function getIconData(icon) {
|
|
3301
3357
|
const key = `${icon.set}:${icon.name}`;
|
|
3358
|
+
loadIconCacheFromStorage();
|
|
3302
3359
|
if (iconCache.has(key)) {
|
|
3303
3360
|
return iconCache.get(key);
|
|
3304
3361
|
}
|
|
@@ -3314,11 +3371,13 @@ async function getIconData(icon) {
|
|
|
3314
3371
|
pendingFetches.delete(key);
|
|
3315
3372
|
if (data) {
|
|
3316
3373
|
iconCache.set(key, data);
|
|
3374
|
+
saveIconToStorage(key, data);
|
|
3317
3375
|
}
|
|
3318
3376
|
return data;
|
|
3319
3377
|
}
|
|
3320
3378
|
function getIconDataSync(icon) {
|
|
3321
3379
|
const key = `${icon.set}:${icon.name}`;
|
|
3380
|
+
loadIconCacheFromStorage();
|
|
3322
3381
|
return iconCache.get(key) || null;
|
|
3323
3382
|
}
|
|
3324
3383
|
function createIconSVG(icon, data, size = 24, color = "currentColor") {
|
|
@@ -3418,12 +3477,15 @@ function renderIcon(container, icon, size = 24, color = "currentColor") {
|
|
|
3418
3477
|
async function preloadIcons(icons) {
|
|
3419
3478
|
await Promise.all(icons.map((icon) => getIconData(icon)));
|
|
3420
3479
|
}
|
|
3421
|
-
function clearIconCache() {
|
|
3480
|
+
function clearIconCache(clearStorage = false) {
|
|
3422
3481
|
iconCache.clear();
|
|
3423
3482
|
pendingFetches.clear();
|
|
3424
3483
|
registeredIcons.forEach((data, key) => {
|
|
3425
3484
|
iconCache.set(key, data);
|
|
3426
3485
|
});
|
|
3486
|
+
if (clearStorage) {
|
|
3487
|
+
clearIconStorageCache();
|
|
3488
|
+
}
|
|
3427
3489
|
}
|
|
3428
3490
|
function isIconSetSupported(set) {
|
|
3429
3491
|
return set in ICONIFY_COLLECTIONS;
|
|
@@ -4483,10 +4545,9 @@ function renderInShadow(options) {
|
|
|
4483
4545
|
shadowRoot.insertBefore(styleEl, innerContainer);
|
|
4484
4546
|
}
|
|
4485
4547
|
if (shouldInjectTailwind) {
|
|
4486
|
-
const
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
shadowRoot.insertBefore(tailwindLink, innerContainer);
|
|
4548
|
+
const tailwindScript2 = document.createElement("script");
|
|
4549
|
+
tailwindScript2.src = "https://cdn.tailwindcss.com";
|
|
4550
|
+
shadowRoot.insertBefore(tailwindScript2, innerContainer);
|
|
4490
4551
|
}
|
|
4491
4552
|
const result = render({
|
|
4492
4553
|
...renderOptions,
|
|
@@ -5618,6 +5679,7 @@ init_tailwind();
|
|
|
5618
5679
|
camelToKebab,
|
|
5619
5680
|
clearAllCaches,
|
|
5620
5681
|
clearIconCache,
|
|
5682
|
+
clearIconStorageCache,
|
|
5621
5683
|
clearLocalStorageCache,
|
|
5622
5684
|
clearMemoryCache,
|
|
5623
5685
|
clearStyles,
|
package/dist/index.d.cts
CHANGED
|
@@ -1718,6 +1718,7 @@ declare function resetEventSystem(): void;
|
|
|
1718
1718
|
/**
|
|
1719
1719
|
* Add preload link for Tailwind CDN to start loading earlier
|
|
1720
1720
|
* This helps the browser start fetching before we actually need it
|
|
1721
|
+
* Note: Only preload if we're going to use the script immediately after
|
|
1721
1722
|
*/
|
|
1722
1723
|
declare function preloadTailwind(cdnUrl?: string, usePlayCdn?: boolean): void;
|
|
1723
1724
|
/**
|
|
@@ -2000,6 +2001,10 @@ interface IconData {
|
|
|
2000
2001
|
/** ViewBox (default: "0 0 24 24") */
|
|
2001
2002
|
viewBox?: string;
|
|
2002
2003
|
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Clear icon cache from localStorage
|
|
2006
|
+
*/
|
|
2007
|
+
declare function clearIconStorageCache(): void;
|
|
2003
2008
|
/**
|
|
2004
2009
|
* Enable or disable CDN fallback for icons not in bundle
|
|
2005
2010
|
* Disabled by default for security - only bundled icons will render
|
|
@@ -2027,11 +2032,11 @@ declare function isIconRegistered(icon: IconConfig): boolean;
|
|
|
2027
2032
|
*/
|
|
2028
2033
|
declare function getRegisteredIconKeys(): string[];
|
|
2029
2034
|
/**
|
|
2030
|
-
* Get icon data (from cache, registry, or CDN if enabled)
|
|
2035
|
+
* Get icon data (from cache, registry, localStorage, or CDN if enabled)
|
|
2031
2036
|
*/
|
|
2032
2037
|
declare function getIconData(icon: IconConfig): Promise<IconData | null>;
|
|
2033
2038
|
/**
|
|
2034
|
-
* Get icon data synchronously (only returns cached/registered icons)
|
|
2039
|
+
* Get icon data synchronously (only returns cached/registered/localStorage icons)
|
|
2035
2040
|
*/
|
|
2036
2041
|
declare function getIconDataSync(icon: IconConfig): IconData | null;
|
|
2037
2042
|
/**
|
|
@@ -2052,9 +2057,9 @@ declare function renderIcon(container: HTMLElement, icon: IconConfig, size?: num
|
|
|
2052
2057
|
*/
|
|
2053
2058
|
declare function preloadIcons(icons: IconConfig[]): Promise<void>;
|
|
2054
2059
|
/**
|
|
2055
|
-
* Clear the icon cache (keeps registered icons)
|
|
2060
|
+
* Clear the icon cache (keeps registered icons, optionally clears localStorage)
|
|
2056
2061
|
*/
|
|
2057
|
-
declare function clearIconCache(): void;
|
|
2062
|
+
declare function clearIconCache(clearStorage?: boolean): void;
|
|
2058
2063
|
/**
|
|
2059
2064
|
* Check if an icon set is supported
|
|
2060
2065
|
*/
|
|
@@ -2068,4 +2073,4 @@ declare function getSupportedIconSets(): string[];
|
|
|
2068
2073
|
*/
|
|
2069
2074
|
declare function getIconifyCollection(set: string): string | undefined;
|
|
2070
2075
|
|
|
2071
|
-
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_REGISTRY_URL, 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 FontConfig, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, addFontPreconnect, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, ensureFonts, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDefaultFonts, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLoadedFonts, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initFonts, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isFontLoaded, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isTailwindReady, isValidSpecifier, loadDefaultFonts, loadFont, loadFonts, markElementReady, navigateTo, parseVersion, prefetchComponents, preloadIcons, preloadTailwind, preventFOUC, processStyles, refreshTailwind, registerIcon, registerIcons, removeClass, removeCustomStyles, removeFOUCPrevention, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, scheduleRefresh, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps, waitForTailwind };
|
|
2076
|
+
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_REGISTRY_URL, 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 FontConfig, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, addFontPreconnect, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearIconStorageCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, ensureFonts, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDefaultFonts, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLoadedFonts, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initFonts, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isFontLoaded, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isTailwindReady, isValidSpecifier, loadDefaultFonts, loadFont, loadFonts, markElementReady, navigateTo, parseVersion, prefetchComponents, preloadIcons, preloadTailwind, preventFOUC, processStyles, refreshTailwind, registerIcon, registerIcons, removeClass, removeCustomStyles, removeFOUCPrevention, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, scheduleRefresh, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps, waitForTailwind };
|
package/dist/index.d.ts
CHANGED
|
@@ -1718,6 +1718,7 @@ declare function resetEventSystem(): void;
|
|
|
1718
1718
|
/**
|
|
1719
1719
|
* Add preload link for Tailwind CDN to start loading earlier
|
|
1720
1720
|
* This helps the browser start fetching before we actually need it
|
|
1721
|
+
* Note: Only preload if we're going to use the script immediately after
|
|
1721
1722
|
*/
|
|
1722
1723
|
declare function preloadTailwind(cdnUrl?: string, usePlayCdn?: boolean): void;
|
|
1723
1724
|
/**
|
|
@@ -2000,6 +2001,10 @@ interface IconData {
|
|
|
2000
2001
|
/** ViewBox (default: "0 0 24 24") */
|
|
2001
2002
|
viewBox?: string;
|
|
2002
2003
|
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Clear icon cache from localStorage
|
|
2006
|
+
*/
|
|
2007
|
+
declare function clearIconStorageCache(): void;
|
|
2003
2008
|
/**
|
|
2004
2009
|
* Enable or disable CDN fallback for icons not in bundle
|
|
2005
2010
|
* Disabled by default for security - only bundled icons will render
|
|
@@ -2027,11 +2032,11 @@ declare function isIconRegistered(icon: IconConfig): boolean;
|
|
|
2027
2032
|
*/
|
|
2028
2033
|
declare function getRegisteredIconKeys(): string[];
|
|
2029
2034
|
/**
|
|
2030
|
-
* Get icon data (from cache, registry, or CDN if enabled)
|
|
2035
|
+
* Get icon data (from cache, registry, localStorage, or CDN if enabled)
|
|
2031
2036
|
*/
|
|
2032
2037
|
declare function getIconData(icon: IconConfig): Promise<IconData | null>;
|
|
2033
2038
|
/**
|
|
2034
|
-
* Get icon data synchronously (only returns cached/registered icons)
|
|
2039
|
+
* Get icon data synchronously (only returns cached/registered/localStorage icons)
|
|
2035
2040
|
*/
|
|
2036
2041
|
declare function getIconDataSync(icon: IconConfig): IconData | null;
|
|
2037
2042
|
/**
|
|
@@ -2052,9 +2057,9 @@ declare function renderIcon(container: HTMLElement, icon: IconConfig, size?: num
|
|
|
2052
2057
|
*/
|
|
2053
2058
|
declare function preloadIcons(icons: IconConfig[]): Promise<void>;
|
|
2054
2059
|
/**
|
|
2055
|
-
* Clear the icon cache (keeps registered icons)
|
|
2060
|
+
* Clear the icon cache (keeps registered icons, optionally clears localStorage)
|
|
2056
2061
|
*/
|
|
2057
|
-
declare function clearIconCache(): void;
|
|
2062
|
+
declare function clearIconCache(clearStorage?: boolean): void;
|
|
2058
2063
|
/**
|
|
2059
2064
|
* Check if an icon set is supported
|
|
2060
2065
|
*/
|
|
@@ -2068,4 +2073,4 @@ declare function getSupportedIconSets(): string[];
|
|
|
2068
2073
|
*/
|
|
2069
2074
|
declare function getIconifyCollection(set: string): string | undefined;
|
|
2070
2075
|
|
|
2071
|
-
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_REGISTRY_URL, 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 FontConfig, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, addFontPreconnect, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, ensureFonts, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDefaultFonts, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLoadedFonts, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initFonts, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isFontLoaded, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isTailwindReady, isValidSpecifier, loadDefaultFonts, loadFont, loadFonts, markElementReady, navigateTo, parseVersion, prefetchComponents, preloadIcons, preloadTailwind, preventFOUC, processStyles, refreshTailwind, registerIcon, registerIcons, removeClass, removeCustomStyles, removeFOUCPrevention, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, scheduleRefresh, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps, waitForTailwind };
|
|
2076
|
+
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_REGISTRY_URL, 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 FontConfig, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, addFontPreconnect, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearIconStorageCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, ensureFonts, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDefaultFonts, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLoadedFonts, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initFonts, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isFontLoaded, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isTailwindReady, isValidSpecifier, loadDefaultFonts, loadFont, loadFonts, markElementReady, navigateTo, parseVersion, prefetchComponents, preloadIcons, preloadTailwind, preventFOUC, processStyles, refreshTailwind, registerIcon, registerIcons, removeClass, removeCustomStyles, removeFOUCPrevention, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, scheduleRefresh, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps, waitForTailwind };
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
scheduleRefresh,
|
|
18
18
|
updateTailwindConfig,
|
|
19
19
|
waitForTailwind
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GN6KAMNI.js";
|
|
21
21
|
import {
|
|
22
22
|
buildRegistryFromBundle,
|
|
23
23
|
collectAllDependencies,
|
|
@@ -2332,6 +2332,58 @@ function resetOverrideSystem() {
|
|
|
2332
2332
|
|
|
2333
2333
|
// src/icons.ts
|
|
2334
2334
|
var cdnEnabled = true;
|
|
2335
|
+
var ICON_CACHE_KEY = "servly-icon-cache";
|
|
2336
|
+
var ICON_CACHE_VERSION = "1";
|
|
2337
|
+
var localStorageLoaded = false;
|
|
2338
|
+
function loadIconCacheFromStorage() {
|
|
2339
|
+
if (localStorageLoaded) return;
|
|
2340
|
+
localStorageLoaded = true;
|
|
2341
|
+
if (typeof localStorage === "undefined") return;
|
|
2342
|
+
try {
|
|
2343
|
+
const cached = localStorage.getItem(ICON_CACHE_KEY);
|
|
2344
|
+
if (!cached) return;
|
|
2345
|
+
const parsed = JSON.parse(cached);
|
|
2346
|
+
if (parsed.version !== ICON_CACHE_VERSION) {
|
|
2347
|
+
localStorage.removeItem(ICON_CACHE_KEY);
|
|
2348
|
+
return;
|
|
2349
|
+
}
|
|
2350
|
+
for (const [key, data] of Object.entries(parsed.icons)) {
|
|
2351
|
+
if (!iconCache.has(key) && !registeredIcons.has(key)) {
|
|
2352
|
+
iconCache.set(key, data);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
} catch {
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
function saveIconToStorage(key, data) {
|
|
2359
|
+
if (typeof localStorage === "undefined") return;
|
|
2360
|
+
try {
|
|
2361
|
+
const cached = localStorage.getItem(ICON_CACHE_KEY);
|
|
2362
|
+
let cacheData;
|
|
2363
|
+
if (cached) {
|
|
2364
|
+
cacheData = JSON.parse(cached);
|
|
2365
|
+
if (cacheData.version !== ICON_CACHE_VERSION) {
|
|
2366
|
+
cacheData = { version: ICON_CACHE_VERSION, icons: {} };
|
|
2367
|
+
}
|
|
2368
|
+
} else {
|
|
2369
|
+
cacheData = { version: ICON_CACHE_VERSION, icons: {} };
|
|
2370
|
+
}
|
|
2371
|
+
cacheData.icons[key] = data;
|
|
2372
|
+
const keys = Object.keys(cacheData.icons);
|
|
2373
|
+
if (keys.length > 500) {
|
|
2374
|
+
keys.slice(0, 100).forEach((k) => delete cacheData.icons[k]);
|
|
2375
|
+
}
|
|
2376
|
+
localStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cacheData));
|
|
2377
|
+
} catch {
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
function clearIconStorageCache() {
|
|
2381
|
+
if (typeof localStorage === "undefined") return;
|
|
2382
|
+
try {
|
|
2383
|
+
localStorage.removeItem(ICON_CACHE_KEY);
|
|
2384
|
+
} catch {
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2335
2387
|
function setIconCdnEnabled(enabled) {
|
|
2336
2388
|
cdnEnabled = enabled;
|
|
2337
2389
|
}
|
|
@@ -2504,6 +2556,7 @@ function parseSvgResponse(svgText) {
|
|
|
2504
2556
|
}
|
|
2505
2557
|
async function getIconData(icon) {
|
|
2506
2558
|
const key = `${icon.set}:${icon.name}`;
|
|
2559
|
+
loadIconCacheFromStorage();
|
|
2507
2560
|
if (iconCache.has(key)) {
|
|
2508
2561
|
return iconCache.get(key);
|
|
2509
2562
|
}
|
|
@@ -2519,11 +2572,13 @@ async function getIconData(icon) {
|
|
|
2519
2572
|
pendingFetches.delete(key);
|
|
2520
2573
|
if (data) {
|
|
2521
2574
|
iconCache.set(key, data);
|
|
2575
|
+
saveIconToStorage(key, data);
|
|
2522
2576
|
}
|
|
2523
2577
|
return data;
|
|
2524
2578
|
}
|
|
2525
2579
|
function getIconDataSync(icon) {
|
|
2526
2580
|
const key = `${icon.set}:${icon.name}`;
|
|
2581
|
+
loadIconCacheFromStorage();
|
|
2527
2582
|
return iconCache.get(key) || null;
|
|
2528
2583
|
}
|
|
2529
2584
|
function createIconSVG(icon, data, size = 24, color = "currentColor") {
|
|
@@ -2623,12 +2678,15 @@ function renderIcon(container, icon, size = 24, color = "currentColor") {
|
|
|
2623
2678
|
async function preloadIcons(icons) {
|
|
2624
2679
|
await Promise.all(icons.map((icon) => getIconData(icon)));
|
|
2625
2680
|
}
|
|
2626
|
-
function clearIconCache() {
|
|
2681
|
+
function clearIconCache(clearStorage = false) {
|
|
2627
2682
|
iconCache.clear();
|
|
2628
2683
|
pendingFetches.clear();
|
|
2629
2684
|
registeredIcons.forEach((data, key) => {
|
|
2630
2685
|
iconCache.set(key, data);
|
|
2631
2686
|
});
|
|
2687
|
+
if (clearStorage) {
|
|
2688
|
+
clearIconStorageCache();
|
|
2689
|
+
}
|
|
2632
2690
|
}
|
|
2633
2691
|
function isIconSetSupported(set) {
|
|
2634
2692
|
return set in ICONIFY_COLLECTIONS;
|
|
@@ -3685,10 +3743,9 @@ function renderInShadow(options) {
|
|
|
3685
3743
|
shadowRoot.insertBefore(styleEl, innerContainer);
|
|
3686
3744
|
}
|
|
3687
3745
|
if (shouldInjectTailwind) {
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
shadowRoot.insertBefore(tailwindLink, innerContainer);
|
|
3746
|
+
const tailwindScript = document.createElement("script");
|
|
3747
|
+
tailwindScript.src = "https://cdn.tailwindcss.com";
|
|
3748
|
+
shadowRoot.insertBefore(tailwindScript, innerContainer);
|
|
3692
3749
|
}
|
|
3693
3750
|
const result = render({
|
|
3694
3751
|
...renderOptions,
|
|
@@ -3719,7 +3776,7 @@ async function createServlyRenderer(options) {
|
|
|
3719
3776
|
container = containerOption;
|
|
3720
3777
|
}
|
|
3721
3778
|
if (shouldInjectTailwind) {
|
|
3722
|
-
const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-
|
|
3779
|
+
const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-MYAEYQPY.js");
|
|
3723
3780
|
await initServlyTailwind2(tailwindConfig);
|
|
3724
3781
|
}
|
|
3725
3782
|
const activeRenders = [];
|
|
@@ -4814,6 +4871,7 @@ export {
|
|
|
4814
4871
|
camelToKebab,
|
|
4815
4872
|
clearAllCaches,
|
|
4816
4873
|
clearIconCache,
|
|
4874
|
+
clearIconStorageCache,
|
|
4817
4875
|
clearLocalStorageCache,
|
|
4818
4876
|
clearMemoryCache,
|
|
4819
4877
|
clearStyles,
|