@servlyadmin/runtime-core
Advanced tools
+3
-1
@@ -781,2 +781,4 @@ /** | ||
| declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>; | ||
| /** Default Servly Registry API URL */ | ||
| declare const DEFAULT_REGISTRY_URL = "https://core-api.servly.app/v1/views/registry"; | ||
| /** | ||
@@ -1974,2 +1976,2 @@ * Configure the registry base URL | ||
| export { AnalyticsCollector, type AnalyticsConfig, type AnalyticsEvent, type AnalyticsEventType, type Assertion$1 as Assertion, type AssertionResult$1 as AssertionResult, type BatchEventsRequest, type BatchEventsResponse, type BindingContext, type BundleStrategy, type BundledComponent, type CacheConfig, type CacheEntry, type CacheStrategy, type ClientInfo, type ComponentBundle, type ComponentData, type ComponentRegistry, DEFAULT_CACHE_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SERVLY_TAILWIND_CONFIG, type DependencyEntry, type DependencyManifest, type DependencyType, EVENT_HANDLERS, type ElementConfig, type ErrorMetadata, type ErrorType, type EventContext, type EventHandlerConfig, EventSystem, type EventSystemConfig, type FetchMetadata, type FetchOptions, type FetchResult, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isValidSpecifier, navigateTo, parseVersion, prefetchComponents, preloadIcons, processStyles, registerIcon, registerIcons, removeClass, removeCustomStyles, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps }; | ||
| 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 IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isValidSpecifier, navigateTo, parseVersion, prefetchComponents, preloadIcons, processStyles, registerIcon, registerIcons, removeClass, removeCustomStyles, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps }; |
+3
-1
@@ -781,2 +781,4 @@ /** | ||
| declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>; | ||
| /** Default Servly Registry API URL */ | ||
| declare const DEFAULT_REGISTRY_URL = "https://core-api.servly.app/v1/views/registry"; | ||
| /** | ||
@@ -1974,2 +1976,2 @@ * Configure the registry base URL | ||
| export { AnalyticsCollector, type AnalyticsConfig, type AnalyticsEvent, type AnalyticsEventType, type Assertion$1 as Assertion, type AssertionResult$1 as AssertionResult, type BatchEventsRequest, type BatchEventsResponse, type BindingContext, type BundleStrategy, type BundledComponent, type CacheConfig, type CacheEntry, type CacheStrategy, type ClientInfo, type ComponentBundle, type ComponentData, type ComponentRegistry, DEFAULT_CACHE_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SERVLY_TAILWIND_CONFIG, type DependencyEntry, type DependencyManifest, type DependencyType, EVENT_HANDLERS, type ElementConfig, type ErrorMetadata, type ErrorType, type EventContext, type EventHandlerConfig, EventSystem, type EventSystemConfig, type FetchMetadata, type FetchOptions, type FetchResult, type IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isValidSpecifier, navigateTo, parseVersion, prefetchComponents, preloadIcons, processStyles, registerIcon, registerIcons, removeClass, removeCustomStyles, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps }; | ||
| 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 IconConfig, type IconData, type IconRenderer, type LayoutElement, LongTaskObserver, MemorySampler, type NavigationOptions, type Override, type OverrideState, OverrideSystem, type OverrideSystemConfig, type ParsedVersion, type PluginExecutor, type PropDefinition, type RenderMetadata, type RenderOptions, type RenderResult, type RetryConfig, type ServlyEventHandler, type ServlyPluginAction, type SessionInfo, SessionManager, type StateChangeEvent, StateManager, type StateManagerConfig, type TailwindConfig, type AssertionResult as TestAssertionResult, type TestCase$1 as TestCase, type TestCase as TestCaseInput, type TestCaseResult, type TestResult, type TestSummary as TestRunSummary, type TestSummary$1 as TestSummary, type ViewData, addClass, addCustomStyles, analytics, applyStyles, batchFetchComponents, buildClassName, buildElementStyles, buildRegistryFromBundle, bumpVersion, camelToKebab, clearAllCaches, clearIconCache, clearLocalStorageCache, clearMemoryCache, clearStyles, collectAllDependencies, collectAllViewDependencies, compareVersions, configureAnalytics, createIconSVG, createPlaceholderIcon, createRegistry, createServlyRenderer, createViewsMap, deepMerge, deleteValueByPath, detectCircularDependencies, extractBindingKeys, extractDependencies, extractDependenciesFromCode, extractOverrideDependencies, extractReferencedViewIds, fetchComponent, fetchComponentWithDependencies, formatStyleValue, formatVersion, generateTestCases, getAnalytics, getCacheKey, getCleanupOverrides, getDependencyTree, getEventSystem, getFromCache, getIconData, getIconDataSync, getIconifyCollection, getLocalStorage, getLongTaskObserver, getMemoryCacheSize, getMemorySampler, getMountOverrides, getOverrideSystem, getRegisteredIconKeys, getRegistryUrl, getSessionManager, getSessionStorage, getSupportedIconSets, getTailwind, getUrlInfo, getValueByPath, goBack, goForward, hasClass, hasDependencyOverrides, hasOverrides, hasTemplateSyntax, initServlyTailwind, injectTailwind, injectTailwindStyles, invalidateCache, isComponentAvailable, isIconCdnEnabled, isIconRegistered, isIconSetSupported, isTailwindLoaded, isValidSpecifier, navigateTo, parseVersion, prefetchComponents, preloadIcons, processStyles, registerIcon, registerIcons, removeClass, removeCustomStyles, removeLocalStorage, removeSessionStorage, removeTailwind, render, renderDynamicList, renderIcon, renderInShadow, renderNode, resetAnalytics, resetEventSystem, resetLongTaskObserver, resetMemorySampler, resetOverrideSystem, resetSessionManager, resolveBindingPath, resolveTemplate, resolveTemplateValue, resolveTemplatesDeep, resolveVersion, runAllTests, runTestCase, satisfiesVersion, setIconCdnEnabled, setInCache, setLocalStorage, setRegistryUrl, setSessionStorage, setValueByPath, toDomEventName, toReactEventName, toggleClass, updateStyles, updateTailwindConfig, validateAssertion, validateProps }; |
+1
-1
| { | ||
| "name": "@servlyadmin/runtime-core", | ||
| "version": "0.1.36", | ||
| "version": "0.1.37", | ||
| "description": "Framework-agnostic core renderer for Servly components", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+137
-98
@@ -20,4 +20,4 @@ # @servlyadmin/runtime-core | ||
| // Fetch a component from the registry | ||
| const { data } = await fetchComponent('my-component', { version: 'latest' }); | ||
| // Fetch a component from the registry (uses Servly's default registry) | ||
| const { data } = await fetchComponent('my-component-id'); | ||
@@ -46,2 +46,43 @@ // Render to a container | ||
| ## Registry Configuration | ||
| By default, components are fetched from Servly's production registry: | ||
| - **Default URL**: `https://core-api.servly.app/v1/views/registry` | ||
| You can override this if you have a custom registry: | ||
| ```typescript | ||
| import { setRegistryUrl } from '@servlyadmin/runtime-core'; | ||
| // Use a custom registry | ||
| setRegistryUrl('https://your-api.com/v1/views/registry'); | ||
| ``` | ||
| ## Cache Strategies | ||
| The runtime supports three caching strategies to optimize component loading: | ||
| | Strategy | Description | Persistence | Best For | | ||
| |----------|-------------|-------------|----------| | ||
| | `localStorage` | Persists across browser sessions | Yes | Production apps (default) | | ||
| | `memory` | In-memory cache, cleared on page refresh | No | Development, SSR | | ||
| | `none` | No caching, always fetches fresh | No | Testing, debugging | | ||
| **Default**: `localStorage` - Components are cached in the browser's localStorage for fast subsequent loads. | ||
| ```typescript | ||
| // Use default localStorage caching | ||
| const { data } = await fetchComponent('my-component'); | ||
| // Explicitly set cache strategy | ||
| const { data } = await fetchComponent('my-component', { | ||
| cacheStrategy: 'memory', // or 'localStorage' or 'none' | ||
| }); | ||
| // Force refresh (bypass cache) | ||
| const { data } = await fetchComponent('my-component', { | ||
| forceRefresh: true, | ||
| }); | ||
| ``` | ||
| ## Core Concepts | ||
@@ -56,10 +97,11 @@ | ||
| i: string; // Unique identifier | ||
| type: string; // HTML tag or component type | ||
| componentId: string; // Element type (container, text, button, etc.) | ||
| configuration?: { // Element configuration | ||
| className?: string; | ||
| classNames?: string; | ||
| style?: Record<string, any>; | ||
| textContent?: string; | ||
| text?: string; | ||
| // ... other attributes | ||
| }; | ||
| children?: LayoutElement[]; // Nested elements | ||
| children?: string[]; // Child element IDs | ||
| parent?: string; // Parent element ID | ||
| } | ||
@@ -88,6 +130,6 @@ ``` | ||
| i: 'greeting', | ||
| type: 'h1', | ||
| componentId: 'text', | ||
| configuration: { | ||
| textContent: 'Hello, {{props.name}}!', | ||
| className: '{{props.className}}', | ||
| text: 'Hello, {{props.name}}!', | ||
| classNames: '{{props.className}}', | ||
| }, | ||
@@ -125,10 +167,11 @@ }, | ||
| ```typescript | ||
| const { data, fromCache } = await fetchComponent('component-id', { | ||
| version: 'latest', // Version specifier | ||
| cacheStrategy: 'memory', // 'memory' | 'localStorage' | 'none' | ||
| forceRefresh: false, // Bypass cache | ||
| timeout: 30000, // Request timeout in ms | ||
| const { data, fromCache, version } = await fetchComponent('component-id', { | ||
| version: 'latest', // Version specifier (default: 'latest') | ||
| cacheStrategy: 'localStorage', // 'localStorage' | 'memory' | 'none' (default: 'localStorage') | ||
| forceRefresh: false, // Bypass cache (default: false) | ||
| retryConfig: { | ||
| maxRetries: 3, | ||
| retryDelay: 1000, | ||
| maxRetries: 3, // Number of retry attempts (default: 3) | ||
| initialDelay: 1000, // Initial retry delay in ms (default: 1000) | ||
| maxDelay: 10000, // Maximum retry delay in ms (default: 10000) | ||
| backoffMultiplier: 2, // Exponential backoff multiplier (default: 2) | ||
| }, | ||
@@ -138,2 +181,16 @@ }); | ||
| ### setRegistryUrl(url) | ||
| Configure a custom registry URL. | ||
| ```typescript | ||
| import { setRegistryUrl, DEFAULT_REGISTRY_URL } from '@servlyadmin/runtime-core'; | ||
| // Use custom registry | ||
| setRegistryUrl('https://your-api.com/v1/views/registry'); | ||
| // Reset to default | ||
| setRegistryUrl(DEFAULT_REGISTRY_URL); | ||
| ``` | ||
| ### StateManager | ||
@@ -149,21 +206,13 @@ | ||
| // Get/set state | ||
| stateManager.setState({ count: 1 }); | ||
| stateManager.getValue('count'); // 1 | ||
| stateManager.setValue('user.name', 'John'); | ||
| stateManager.set('count', 1); | ||
| stateManager.get('count'); // 1 | ||
| stateManager.set('user.name', 'John'); | ||
| // Subscribe to changes | ||
| const unsubscribe = stateManager.subscribe((state) => { | ||
| console.log('State changed:', state); | ||
| const unsubscribe = stateManager.subscribe((event) => { | ||
| console.log('State changed:', event.path, event.value); | ||
| }); | ||
| // Subscribe to specific path | ||
| stateManager.subscribeToPath('count', (value) => { | ||
| console.log('Count changed:', value); | ||
| }); | ||
| // Batch updates | ||
| stateManager.batch(() => { | ||
| stateManager.setValue('a', 1); | ||
| stateManager.setValue('b', 2); | ||
| }); // Only one notification | ||
| // Cleanup | ||
| stateManager.clear(); | ||
| ``` | ||
@@ -176,22 +225,10 @@ | ||
| ```typescript | ||
| import { EventSystem } from '@servlyadmin/runtime-core'; | ||
| import { EventSystem, getEventSystem } from '@servlyadmin/runtime-core'; | ||
| const eventSystem = new EventSystem(); | ||
| const eventSystem = getEventSystem(); | ||
| // Register custom plugin | ||
| eventSystem.registerPlugin('my-action', async (config, context) => { | ||
| console.log('Action executed with:', config); | ||
| eventSystem.registerPlugin('my-action', async (action, context) => { | ||
| console.log('Action executed with:', action.config); | ||
| }); | ||
| // Create event handler | ||
| const handler = eventSystem.createHandler([ | ||
| { key: 'prevent-default', config: {} }, | ||
| { key: 'set-state', config: { path: 'clicked', value: true } }, | ||
| { key: 'my-action', config: { message: 'Button clicked!' } }, | ||
| ]); | ||
| // Use with element | ||
| button.addEventListener('click', (e) => { | ||
| handler(e, 'button-id', bindingContext); | ||
| }); | ||
| ``` | ||
@@ -201,31 +238,36 @@ | ||
| - `console-log` - Log messages to console | ||
| - `set-state` - Update state values | ||
| - `executeCode` - Execute arbitrary JavaScript code | ||
| - `state-setState` - Update state values | ||
| - `navigateTo` - Navigate to URL | ||
| - `localStorage-set/get/remove` - LocalStorage operations | ||
| - `sessionStorage-set/get` - SessionStorage operations | ||
| - `alert` - Show alert dialog | ||
| - `console-log` - Log to console | ||
| - `clipboard-copy` - Copy text to clipboard | ||
| - `scrollTo` - Scroll to element | ||
| - `focus/blur` - Focus/blur elements | ||
| - `addClass/removeClass/toggleClass` - CSS class manipulation | ||
| - `setAttribute/removeAttribute` - Attribute manipulation | ||
| - `dispatchEvent` - Dispatch custom events | ||
| - `delay` - Add delay between actions | ||
| - `prevent-default` - Call event.preventDefault() | ||
| - `stop-propagation` - Call event.stopPropagation() | ||
| ### Cache | ||
| ### Cache Management | ||
| Component caching with multiple strategies. | ||
| ```typescript | ||
| import { ComponentCache } from '@servlyadmin/runtime-core'; | ||
| import { | ||
| clearAllCaches, | ||
| clearMemoryCache, | ||
| clearLocalStorageCache, | ||
| getMemoryCacheSize | ||
| } from '@servlyadmin/runtime-core'; | ||
| const cache = new ComponentCache({ | ||
| maxSize: 100, | ||
| strategy: 'memory', // 'memory' | 'localStorage' | 'none' | ||
| }); | ||
| // Clear all caches | ||
| clearAllCaches(); | ||
| // Set with TTL | ||
| cache.set('key', data, { ttl: 60000 }); // 1 minute | ||
| // Clear specific cache | ||
| clearMemoryCache(); | ||
| clearLocalStorageCache(); | ||
| // Component-specific methods | ||
| cache.setComponent('comp-id', '1.0.0', componentData); | ||
| cache.getComponent('comp-id', 'latest'); | ||
| cache.invalidateComponent('comp-id'); | ||
| // Statistics | ||
| const stats = cache.getStats(); | ||
| console.log(`Hit rate: ${stats.hitRate * 100}%`); | ||
| // Get cache size | ||
| const size = getMemoryCacheSize(); | ||
| ``` | ||
@@ -238,3 +280,3 @@ | ||
| ```typescript | ||
| import { resolveTemplate, resolveBindings, isTemplate } from '@servlyadmin/runtime-core'; | ||
| import { resolveTemplate, hasTemplateSyntax } from '@servlyadmin/runtime-core'; | ||
@@ -250,12 +292,5 @@ const context = { | ||
| // Check if string is a template | ||
| isTemplate('{{props.name}}'); // true | ||
| isTemplate('static text'); // false | ||
| // Resolve all bindings in an object | ||
| resolveBindings({ | ||
| title: '{{props.name}}', | ||
| subtitle: 'Count: {{props.count}}', | ||
| }, context); | ||
| // { title: 'World', subtitle: 'Count: 42' } | ||
| // Check if string has template syntax | ||
| hasTemplateSyntax('{{props.name}}'); // true | ||
| hasTemplateSyntax('static text'); // false | ||
| ``` | ||
@@ -271,21 +306,22 @@ | ||
| i: 'card', | ||
| type: 'div', | ||
| configuration: { className: 'card' }, | ||
| children: [ | ||
| { | ||
| i: 'header-slot', | ||
| type: 'div', | ||
| configuration: { | ||
| 'data-slot': 'header', // Slot placeholder | ||
| }, | ||
| }, | ||
| { | ||
| i: 'content-slot', | ||
| type: 'div', | ||
| configuration: { | ||
| 'data-slot': 'default', | ||
| }, | ||
| }, | ||
| ], | ||
| componentId: 'container', | ||
| configuration: { classNames: 'card' }, | ||
| children: ['header-slot', 'content-slot'], | ||
| }, | ||
| { | ||
| i: 'header-slot', | ||
| componentId: 'slot', | ||
| configuration: { | ||
| slotName: 'header', | ||
| }, | ||
| parent: 'card', | ||
| }, | ||
| { | ||
| i: 'content-slot', | ||
| componentId: 'slot', | ||
| configuration: { | ||
| slotName: 'default', | ||
| }, | ||
| parent: 'card', | ||
| }, | ||
| ]; | ||
@@ -305,5 +341,8 @@ ``` | ||
| RenderResult, | ||
| RenderOptions, | ||
| ComponentData, | ||
| CacheStrategy, | ||
| RetryConfig, | ||
| FetchOptions, | ||
| FetchResult, | ||
| } from '@servlyadmin/runtime-core'; | ||
@@ -310,0 +349,0 @@ ``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
440436
0.47%12371
0.06%348
12.62%