@servlyadmin/runtime-core 0.1.35 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,8 +17,8 @@ pnpm add @servlyadmin/runtime-core
17
17
  ```typescript
18
18
  import { render, fetchComponent } from '@servlyadmin/runtime-core';
19
19
 
20
- // Fetch a component from the registry
21
- const { data } = await fetchComponent('my-component', { version: 'latest' });
20
+ // Fetch a component from the registry (uses Servly's default registry)
21
+ const { data } = await fetchComponent('my-component-id');
22
22
 
23
23
  // Render to a container
24
24
  const result = render({
@@ -42,6 +42,47 @@ result.update({
42
42
  result.destroy();
43
43
  ```
44
44
 
45
+ ## Registry Configuration
46
+
47
+ By default, components are fetched from Servly's production registry:
48
+ - **Default URL**: `https://core-api.servly.app/v1/views/registry`
49
+
50
+ You can override this if you have a custom registry:
51
+
52
+ ```typescript
53
+ import { setRegistryUrl } from '@servlyadmin/runtime-core';
54
+
55
+ // Use a custom registry
56
+ setRegistryUrl('https://your-api.com/v1/views/registry');
57
+ ```
58
+
59
+ ## Cache Strategies
60
+
61
+ The runtime supports three caching strategies to optimize component loading:
62
+
63
+ | Strategy | Description | Persistence | Best For |
64
+ |----------|-------------|-------------|----------|
65
+ | `localStorage` | Persists across browser sessions | Yes | Production apps (default) |
66
+ | `memory` | In-memory cache, cleared on page refresh | No | Development, SSR |
67
+ | `none` | No caching, always fetches fresh | No | Testing, debugging |
68
+
69
+ **Default**: `localStorage` - Components are cached in the browser's localStorage for fast subsequent loads.
70
+
71
+ ```typescript
72
+ // Use default localStorage caching
73
+ const { data } = await fetchComponent('my-component');
74
+
75
+ // Explicitly set cache strategy
76
+ const { data } = await fetchComponent('my-component', {
77
+ cacheStrategy: 'memory', // or 'localStorage' or 'none'
78
+ });
79
+
80
+ // Force refresh (bypass cache)
81
+ const { data } = await fetchComponent('my-component', {
82
+ forceRefresh: true,
83
+ });
84
+ ```
85
+
45
86
  ## Core Concepts
46
87
 
47
88
  ### Layout Elements
@@ -51,14 +92,15 @@ Components are defined as a tree of layout elements:
51
92
  ```typescript
52
93
  interface LayoutElement {
53
94
  i: string; // Unique identifier
54
- type: string; // HTML tag or component type
95
+ componentId: string; // Element type (container, text, button, etc.)
55
96
  configuration?: { // Element configuration
56
- className?: string;
97
+ classNames?: string;
57
98
  style?: Record<string, any>;
58
- textContent?: string;
99
+ text?: string;
59
100
  // ... other attributes
60
101
  };
61
- children?: LayoutElement[]; // Nested elements
102
+ children?: string[]; // Child element IDs
103
+ parent?: string; // Parent element ID
62
104
  }
63
105
  ```
64
106
 
@@ -82,10 +124,10 @@ Use `{{path}}` syntax to bind data:
82
124
  const elements = [
83
125
  {
84
126
  i: 'greeting',
85
- type: 'h1',
127
+ componentId: 'text',
86
128
  configuration: {
87
- textContent: 'Hello, {{props.name}}!',
88
- className: '{{props.className}}',
129
+ text: 'Hello, {{props.name}}!',
130
+ classNames: '{{props.className}}',
89
131
  },
90
132
  },
91
133
  ];
@@ -118,18 +160,33 @@ interface RenderResult {
118
160
  Fetches a component from the registry.
119
161
 
120
162
  ```typescript
121
- const { data, fromCache } = await fetchComponent('component-id', {
122
- version: 'latest', // Version specifier
123
- cacheStrategy: 'memory', // 'memory' | 'localStorage' | 'none'
124
- forceRefresh: false, // Bypass cache
125
- timeout: 30000, // Request timeout in ms
163
+ const { data, fromCache, version } = await fetchComponent('component-id', {
164
+ version: 'latest', // Version specifier (default: 'latest')
165
+ cacheStrategy: 'localStorage', // 'localStorage' | 'memory' | 'none' (default: 'localStorage')
166
+ forceRefresh: false, // Bypass cache (default: false)
126
167
  retryConfig: {
127
- maxRetries: 3,
128
- retryDelay: 1000,
168
+ maxRetries: 3, // Number of retry attempts (default: 3)
169
+ initialDelay: 1000, // Initial retry delay in ms (default: 1000)
170
+ maxDelay: 10000, // Maximum retry delay in ms (default: 10000)
171
+ backoffMultiplier: 2, // Exponential backoff multiplier (default: 2)
129
172
  },
130
173
  });
131
174
  ```
132
175
 
176
+ ### setRegistryUrl(url)
177
+
178
+ Configure a custom registry URL.
179
+
180
+ ```typescript
181
+ import { setRegistryUrl, DEFAULT_REGISTRY_URL } from '@servlyadmin/runtime-core';
182
+
183
+ // Use custom registry
184
+ setRegistryUrl('https://your-api.com/v1/views/registry');
185
+
186
+ // Reset to default
187
+ setRegistryUrl(DEFAULT_REGISTRY_URL);
188
+ ```
189
+
133
190
  ### StateManager
134
191
 
135
192
  Manages component state with subscriptions.
@@ -140,25 +197,17 @@ import { StateManager } from '@servlyadmin/runtime-core';
140
197
  const stateManager = new StateManager({ count: 0 });
141
198
 
142
199
  // Get/set state
143
- stateManager.setState({ count: 1 });
144
- stateManager.getValue('count'); // 1
145
- stateManager.setValue('user.name', 'John');
200
+ stateManager.set('count', 1);
201
+ stateManager.get('count'); // 1
202
+ stateManager.set('user.name', 'John');
146
203
 
147
204
  // Subscribe to changes
148
- const unsubscribe = stateManager.subscribe((state) => {
149
- console.log('State changed:', state);
205
+ const unsubscribe = stateManager.subscribe((event) => {
206
+ console.log('State changed:', event.path, event.value);
150
207
  });
151
208
 
152
- // Subscribe to specific path
153
- stateManager.subscribeToPath('count', (value) => {
154
- console.log('Count changed:', value);
155
- });
156
-
157
- // Batch updates
158
- stateManager.batch(() => {
159
- stateManager.setValue('a', 1);
160
- stateManager.setValue('b', 2);
161
- }); // Only one notification
209
+ // Cleanup
210
+ stateManager.clear();
162
211
  ```
163
212
 
164
213
  ### EventSystem
@@ -166,59 +215,52 @@ stateManager.batch(() => {
166
215
  Handles events with plugin-based actions.
167
216
 
168
217
  ```typescript
169
- import { EventSystem } from '@servlyadmin/runtime-core';
218
+ import { EventSystem, getEventSystem } from '@servlyadmin/runtime-core';
170
219
 
171
- const eventSystem = new EventSystem();
220
+ const eventSystem = getEventSystem();
172
221
 
173
222
  // Register custom plugin
174
- eventSystem.registerPlugin('my-action', async (config, context) => {
175
- console.log('Action executed with:', config);
176
- });
177
-
178
- // Create event handler
179
- const handler = eventSystem.createHandler([
180
- { key: 'prevent-default', config: {} },
181
- { key: 'set-state', config: { path: 'clicked', value: true } },
182
- { key: 'my-action', config: { message: 'Button clicked!' } },
183
- ]);
184
-
185
- // Use with element
186
- button.addEventListener('click', (e) => {
187
- handler(e, 'button-id', bindingContext);
223
+ eventSystem.registerPlugin('my-action', async (action, context) => {
224
+ console.log('Action executed with:', action.config);
188
225
  });
189
226
  ```
190
227
 
191
228
  #### Built-in Plugins
192
229
 
193
- - `console-log` - Log messages to console
194
- - `set-state` - Update state values
230
+ - `executeCode` - Execute arbitrary JavaScript code
231
+ - `state-setState` - Update state values
232
+ - `navigateTo` - Navigate to URL
233
+ - `localStorage-set/get/remove` - LocalStorage operations
234
+ - `sessionStorage-set/get` - SessionStorage operations
235
+ - `alert` - Show alert dialog
236
+ - `console-log` - Log to console
237
+ - `clipboard-copy` - Copy text to clipboard
238
+ - `scrollTo` - Scroll to element
239
+ - `focus/blur` - Focus/blur elements
240
+ - `addClass/removeClass/toggleClass` - CSS class manipulation
241
+ - `setAttribute/removeAttribute` - Attribute manipulation
242
+ - `dispatchEvent` - Dispatch custom events
195
243
  - `delay` - Add delay between actions
196
- - `prevent-default` - Call event.preventDefault()
197
- - `stop-propagation` - Call event.stopPropagation()
198
244
 
199
- ### Cache
200
-
201
- Component caching with multiple strategies.
245
+ ### Cache Management
202
246
 
203
247
  ```typescript
204
- import { ComponentCache } from '@servlyadmin/runtime-core';
205
-
206
- const cache = new ComponentCache({
207
- maxSize: 100,
208
- strategy: 'memory', // 'memory' | 'localStorage' | 'none'
209
- });
248
+ import {
249
+ clearAllCaches,
250
+ clearMemoryCache,
251
+ clearLocalStorageCache,
252
+ getMemoryCacheSize
253
+ } from '@servlyadmin/runtime-core';
210
254
 
211
- // Set with TTL
212
- cache.set('key', data, { ttl: 60000 }); // 1 minute
255
+ // Clear all caches
256
+ clearAllCaches();
213
257
 
214
- // Component-specific methods
215
- cache.setComponent('comp-id', '1.0.0', componentData);
216
- cache.getComponent('comp-id', 'latest');
217
- cache.invalidateComponent('comp-id');
258
+ // Clear specific cache
259
+ clearMemoryCache();
260
+ clearLocalStorageCache();
218
261
 
219
- // Statistics
220
- const stats = cache.getStats();
221
- console.log(`Hit rate: ${stats.hitRate * 100}%`);
262
+ // Get cache size
263
+ const size = getMemoryCacheSize();
222
264
  ```
223
265
 
224
266
  ### Bindings
@@ -226,7 +268,7 @@ console.log(`Hit rate: ${stats.hitRate * 100}%`);
226
268
  Template resolution utilities.
227
269
 
228
270
  ```typescript
229
- import { resolveTemplate, resolveBindings, isTemplate } from '@servlyadmin/runtime-core';
271
+ import { resolveTemplate, hasTemplateSyntax } from '@servlyadmin/runtime-core';
230
272
 
231
273
  const context = {
232
274
  props: { name: 'World', count: 42 },
@@ -237,16 +279,9 @@ const context = {
237
279
  // Resolve single template
238
280
  resolveTemplate('Hello, {{props.name}}!', context); // "Hello, World!"
239
281
 
240
- // Check if string is a template
241
- isTemplate('{{props.name}}'); // true
242
- isTemplate('static text'); // false
243
-
244
- // Resolve all bindings in an object
245
- resolveBindings({
246
- title: '{{props.name}}',
247
- subtitle: 'Count: {{props.count}}',
248
- }, context);
249
- // { title: 'World', subtitle: 'Count: 42' }
282
+ // Check if string has template syntax
283
+ hasTemplateSyntax('{{props.name}}'); // true
284
+ hasTemplateSyntax('static text'); // false
250
285
  ```
251
286
 
252
287
  ## Slots
@@ -257,24 +292,25 @@ Components can define slots for content injection:
257
292
  const elements = [
258
293
  {
259
294
  i: 'card',
260
- type: 'div',
261
- configuration: { className: 'card' },
262
- children: [
263
- {
264
- i: 'header-slot',
265
- type: 'div',
266
- configuration: {
267
- 'data-slot': 'header', // Slot placeholder
268
- },
269
- },
270
- {
271
- i: 'content-slot',
272
- type: 'div',
273
- configuration: {
274
- 'data-slot': 'default',
275
- },
276
- },
277
- ],
295
+ componentId: 'container',
296
+ configuration: { classNames: 'card' },
297
+ children: ['header-slot', 'content-slot'],
298
+ },
299
+ {
300
+ i: 'header-slot',
301
+ componentId: 'slot',
302
+ configuration: {
303
+ slotName: 'header',
304
+ },
305
+ parent: 'card',
306
+ },
307
+ {
308
+ i: 'content-slot',
309
+ componentId: 'slot',
310
+ configuration: {
311
+ slotName: 'default',
312
+ },
313
+ parent: 'card',
278
314
  },
279
315
  ];
280
316
  ```
@@ -290,9 +326,12 @@ import type {
290
326
  LayoutElement,
291
327
  BindingContext,
292
328
  RenderResult,
329
+ RenderOptions,
293
330
  ComponentData,
294
331
  CacheStrategy,
295
332
  RetryConfig,
333
+ FetchOptions,
334
+ FetchResult,
296
335
  } from '@servlyadmin/runtime-core';
297
336
  ```
298
337
 
package/dist/index.cjs CHANGED
@@ -377,6 +377,7 @@ var index_exports = {};
377
377
  __export(index_exports, {
378
378
  AnalyticsCollector: () => AnalyticsCollector,
379
379
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
380
+ DEFAULT_REGISTRY_URL: () => DEFAULT_REGISTRY_URL,
380
381
  DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
381
382
  DEFAULT_SERVLY_TAILWIND_CONFIG: () => DEFAULT_SERVLY_TAILWIND_CONFIG,
382
383
  EVENT_HANDLERS: () => EVENT_HANDLERS,
@@ -3475,6 +3476,27 @@ function resolveComponentViewInputs(bindings, context, parentInputs) {
3475
3476
  if (resolvedValue !== void 0 && typeof resolvedValue === "function") {
3476
3477
  resolved[key] = resolvedValue;
3477
3478
  }
3479
+ } else if (binding.binding?.type === "servly" && binding.binding?.plugins) {
3480
+ const plugins = binding.binding.plugins;
3481
+ resolved[key] = (event) => {
3482
+ for (const plugin of plugins) {
3483
+ const pluginType = plugin.type || plugin.key;
3484
+ if (pluginType === "executeCode" && plugin.code) {
3485
+ try {
3486
+ const fn = new Function(
3487
+ "event",
3488
+ "props",
3489
+ "state",
3490
+ "context",
3491
+ plugin.code
3492
+ );
3493
+ fn(event, context.props || {}, context.state || {}, context.context || {});
3494
+ } catch (error) {
3495
+ console.error("[Servly] executeCode error:", error);
3496
+ }
3497
+ }
3498
+ }
3499
+ };
3478
3500
  }
3479
3501
  break;
3480
3502
  default:
@@ -4401,7 +4423,8 @@ var DEFAULT_RETRY_CONFIG = {
4401
4423
  maxDelay: 1e4,
4402
4424
  backoffMultiplier: 2
4403
4425
  };
4404
- var registryBaseUrl = "/api/views/registry";
4426
+ var DEFAULT_REGISTRY_URL = "https://core-api.servly.app/v1/views/registry";
4427
+ var registryBaseUrl = DEFAULT_REGISTRY_URL;
4405
4428
  function setRegistryUrl(url) {
4406
4429
  registryBaseUrl = url;
4407
4430
  }
@@ -4536,7 +4559,7 @@ async function fetchComponent(id, options = {}) {
4536
4559
  const {
4537
4560
  version = "latest",
4538
4561
  apiKey,
4539
- cacheStrategy = "memory",
4562
+ cacheStrategy = "localStorage",
4540
4563
  cacheConfig = DEFAULT_CACHE_CONFIG,
4541
4564
  retryConfig = {},
4542
4565
  forceRefresh = false,
@@ -4704,7 +4727,7 @@ async function prefetchComponents(ids, options = {}) {
4704
4727
  await Promise.all(promises);
4705
4728
  }
4706
4729
  async function isComponentAvailable(id, version = "latest", options = {}) {
4707
- const { cacheStrategy = "memory", cacheConfig = DEFAULT_CACHE_CONFIG } = options;
4730
+ const { cacheStrategy = "localStorage", cacheConfig = DEFAULT_CACHE_CONFIG } = options;
4708
4731
  const cached = getFromCache(id, version, cacheStrategy, cacheConfig);
4709
4732
  if (cached) {
4710
4733
  return { available: true, cached: true, version: cached.version };
@@ -5128,6 +5151,7 @@ init_tailwind();
5128
5151
  0 && (module.exports = {
5129
5152
  AnalyticsCollector,
5130
5153
  DEFAULT_CACHE_CONFIG,
5154
+ DEFAULT_REGISTRY_URL,
5131
5155
  DEFAULT_RETRY_CONFIG,
5132
5156
  DEFAULT_SERVLY_TAILWIND_CONFIG,
5133
5157
  EVENT_HANDLERS,
package/dist/index.d.cts CHANGED
@@ -778,6 +778,8 @@ declare function invalidateCache(id: string, version?: string, config?: CacheCon
778
778
 
779
779
  /** Default retry configuration */
780
780
  declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
781
+ /** Default Servly Registry API URL */
782
+ declare const DEFAULT_REGISTRY_URL = "https://core-api.servly.app/v1/views/registry";
781
783
  /**
782
784
  * Configure the registry base URL
783
785
  */
@@ -1970,4 +1972,4 @@ declare function getSupportedIconSets(): string[];
1970
1972
  */
1971
1973
  declare function getIconifyCollection(set: string): string | undefined;
1972
1974
 
1973
- 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 };
1975
+ 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 };
package/dist/index.d.ts CHANGED
@@ -778,6 +778,8 @@ declare function invalidateCache(id: string, version?: string, config?: CacheCon
778
778
 
779
779
  /** Default retry configuration */
780
780
  declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
781
+ /** Default Servly Registry API URL */
782
+ declare const DEFAULT_REGISTRY_URL = "https://core-api.servly.app/v1/views/registry";
781
783
  /**
782
784
  * Configure the registry base URL
783
785
  */
@@ -1970,4 +1972,4 @@ declare function getSupportedIconSets(): string[];
1970
1972
  */
1971
1973
  declare function getIconifyCollection(set: string): string | undefined;
1972
1974
 
1973
- 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 };
1975
+ 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 };
package/dist/index.js CHANGED
@@ -2984,6 +2984,27 @@ function resolveComponentViewInputs(bindings, context, parentInputs) {
2984
2984
  if (resolvedValue !== void 0 && typeof resolvedValue === "function") {
2985
2985
  resolved[key] = resolvedValue;
2986
2986
  }
2987
+ } else if (binding.binding?.type === "servly" && binding.binding?.plugins) {
2988
+ const plugins = binding.binding.plugins;
2989
+ resolved[key] = (event) => {
2990
+ for (const plugin of plugins) {
2991
+ const pluginType = plugin.type || plugin.key;
2992
+ if (pluginType === "executeCode" && plugin.code) {
2993
+ try {
2994
+ const fn = new Function(
2995
+ "event",
2996
+ "props",
2997
+ "state",
2998
+ "context",
2999
+ plugin.code
3000
+ );
3001
+ fn(event, context.props || {}, context.state || {}, context.context || {});
3002
+ } catch (error) {
3003
+ console.error("[Servly] executeCode error:", error);
3004
+ }
3005
+ }
3006
+ }
3007
+ };
2987
3008
  }
2988
3009
  break;
2989
3010
  default:
@@ -3909,7 +3930,8 @@ var DEFAULT_RETRY_CONFIG = {
3909
3930
  maxDelay: 1e4,
3910
3931
  backoffMultiplier: 2
3911
3932
  };
3912
- var registryBaseUrl = "/api/views/registry";
3933
+ var DEFAULT_REGISTRY_URL = "https://core-api.servly.app/v1/views/registry";
3934
+ var registryBaseUrl = DEFAULT_REGISTRY_URL;
3913
3935
  function setRegistryUrl(url) {
3914
3936
  registryBaseUrl = url;
3915
3937
  }
@@ -4044,7 +4066,7 @@ async function fetchComponent(id, options = {}) {
4044
4066
  const {
4045
4067
  version = "latest",
4046
4068
  apiKey,
4047
- cacheStrategy = "memory",
4069
+ cacheStrategy = "localStorage",
4048
4070
  cacheConfig = DEFAULT_CACHE_CONFIG,
4049
4071
  retryConfig = {},
4050
4072
  forceRefresh = false,
@@ -4212,7 +4234,7 @@ async function prefetchComponents(ids, options = {}) {
4212
4234
  await Promise.all(promises);
4213
4235
  }
4214
4236
  async function isComponentAvailable(id, version = "latest", options = {}) {
4215
- const { cacheStrategy = "memory", cacheConfig = DEFAULT_CACHE_CONFIG } = options;
4237
+ const { cacheStrategy = "localStorage", cacheConfig = DEFAULT_CACHE_CONFIG } = options;
4216
4238
  const cached = getFromCache(id, version, cacheStrategy, cacheConfig);
4217
4239
  if (cached) {
4218
4240
  return { available: true, cached: true, version: cached.version };
@@ -4631,6 +4653,7 @@ function getSampleValue(def) {
4631
4653
  export {
4632
4654
  AnalyticsCollector,
4633
4655
  DEFAULT_CACHE_CONFIG,
4656
+ DEFAULT_REGISTRY_URL,
4634
4657
  DEFAULT_RETRY_CONFIG,
4635
4658
  DEFAULT_SERVLY_TAILWIND_CONFIG,
4636
4659
  EVENT_HANDLERS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servlyadmin/runtime-core",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "Framework-agnostic core renderer for Servly components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",