@servlyadmin/runtime-core 0.1.37 → 0.1.38

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/dist/index.js CHANGED
@@ -6,10 +6,16 @@ import {
6
6
  injectTailwind,
7
7
  injectTailwindStyles,
8
8
  isTailwindLoaded,
9
+ isTailwindReady,
10
+ markElementReady,
11
+ preloadTailwind,
12
+ preventFOUC,
9
13
  removeCustomStyles,
14
+ removeFOUCPrevention,
10
15
  removeTailwind,
11
- updateTailwindConfig
12
- } from "./chunk-SMHCCKAZ.js";
16
+ updateTailwindConfig,
17
+ waitForTailwind
18
+ } from "./chunk-5O72RMSO.js";
13
19
  import {
14
20
  buildRegistryFromBundle,
15
21
  collectAllDependencies,
@@ -2946,7 +2952,30 @@ function resolveComponentViewInputs(bindings, context, parentInputs) {
2946
2952
  case "static":
2947
2953
  case "value":
2948
2954
  case "constant":
2949
- resolved[key] = binding.value;
2955
+ if (binding.value && typeof binding.value === "object" && Array.isArray(binding.value.plugins)) {
2956
+ const plugins = binding.value.plugins;
2957
+ resolved[key] = (event) => {
2958
+ for (const plugin of plugins) {
2959
+ const pluginType = plugin.type || plugin.key;
2960
+ if (pluginType === "executeCode" && plugin.code) {
2961
+ try {
2962
+ const fn = new Function(
2963
+ "event",
2964
+ "props",
2965
+ "state",
2966
+ "context",
2967
+ plugin.code
2968
+ );
2969
+ fn(event, context.props || {}, context.state || {}, context.context || {});
2970
+ } catch (error) {
2971
+ console.error("[Servly] executeCode error:", error);
2972
+ }
2973
+ }
2974
+ }
2975
+ };
2976
+ } else {
2977
+ resolved[key] = binding.value;
2978
+ }
2950
2979
  break;
2951
2980
  case "state":
2952
2981
  if (binding.path && context.state) {
@@ -3581,7 +3610,7 @@ async function createServlyRenderer(options) {
3581
3610
  container = containerOption;
3582
3611
  }
3583
3612
  if (shouldInjectTailwind) {
3584
- const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-DMUQ7TOT.js");
3613
+ const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-4IK6HZC6.js");
3585
3614
  await initServlyTailwind2(tailwindConfig);
3586
3615
  }
3587
3616
  const activeRenders = [];
@@ -4738,16 +4767,21 @@ export {
4738
4767
  isIconRegistered,
4739
4768
  isIconSetSupported,
4740
4769
  isTailwindLoaded,
4770
+ isTailwindReady,
4741
4771
  isValidSpecifier,
4772
+ markElementReady,
4742
4773
  navigateTo,
4743
4774
  parseVersion,
4744
4775
  prefetchComponents,
4745
4776
  preloadIcons,
4777
+ preloadTailwind,
4778
+ preventFOUC,
4746
4779
  processStyles,
4747
4780
  registerIcon,
4748
4781
  registerIcons,
4749
4782
  removeClass,
4750
4783
  removeCustomStyles,
4784
+ removeFOUCPrevention,
4751
4785
  removeLocalStorage,
4752
4786
  removeSessionStorage,
4753
4787
  removeTailwind,
@@ -4782,5 +4816,6 @@ export {
4782
4816
  updateStyles,
4783
4817
  updateTailwindConfig,
4784
4818
  validateAssertion,
4785
- validateProps
4819
+ validateProps,
4820
+ waitForTailwind
4786
4821
  };
@@ -6,11 +6,17 @@ import {
6
6
  injectTailwind,
7
7
  injectTailwindStyles,
8
8
  isTailwindLoaded,
9
+ isTailwindReady,
10
+ markElementReady,
11
+ preloadTailwind,
12
+ preventFOUC,
9
13
  removeCustomStyles,
14
+ removeFOUCPrevention,
10
15
  removeTailwind,
11
16
  tailwind_default,
12
- updateTailwindConfig
13
- } from "./chunk-SMHCCKAZ.js";
17
+ updateTailwindConfig,
18
+ waitForTailwind
19
+ } from "./chunk-5O72RMSO.js";
14
20
  export {
15
21
  DEFAULT_SERVLY_TAILWIND_CONFIG,
16
22
  addCustomStyles,
@@ -20,7 +26,13 @@ export {
20
26
  injectTailwind,
21
27
  injectTailwindStyles,
22
28
  isTailwindLoaded,
29
+ isTailwindReady,
30
+ markElementReady,
31
+ preloadTailwind,
32
+ preventFOUC,
23
33
  removeCustomStyles,
34
+ removeFOUCPrevention,
24
35
  removeTailwind,
25
- updateTailwindConfig
36
+ updateTailwindConfig,
37
+ waitForTailwind
26
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servlyadmin/runtime-core",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "Framework-agnostic core renderer for Servly components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,157 +0,0 @@
1
- // src/tailwind.ts
2
- var DEFAULT_TAILWIND_CDN = "https://cdn.tailwindcss.com";
3
- var tailwindInjected = false;
4
- var tailwindScript = null;
5
- function injectTailwind(config = {}) {
6
- return new Promise((resolve, reject) => {
7
- if (tailwindInjected && tailwindScript) {
8
- resolve();
9
- return;
10
- }
11
- if (typeof document === "undefined") {
12
- resolve();
13
- return;
14
- }
15
- if (window.tailwind) {
16
- tailwindInjected = true;
17
- config.onReady?.();
18
- resolve();
19
- return;
20
- }
21
- const {
22
- cdnUrl = DEFAULT_TAILWIND_CDN,
23
- config: tailwindConfig,
24
- plugins = [],
25
- usePlayCdn = false,
26
- onReady,
27
- onError
28
- } = config;
29
- const script = document.createElement("script");
30
- script.src = usePlayCdn ? `${cdnUrl}?plugins=forms,typography,aspect-ratio` : cdnUrl;
31
- script.async = true;
32
- script.onload = () => {
33
- tailwindInjected = true;
34
- tailwindScript = script;
35
- if (tailwindConfig && window.tailwind) {
36
- window.tailwind.config = tailwindConfig;
37
- }
38
- onReady?.();
39
- resolve();
40
- };
41
- script.onerror = (event) => {
42
- const error = new Error(`Failed to load Tailwind CSS from ${cdnUrl}`);
43
- onError?.(error);
44
- reject(error);
45
- };
46
- document.head.appendChild(script);
47
- });
48
- }
49
- function removeTailwind() {
50
- if (tailwindScript && tailwindScript.parentNode) {
51
- tailwindScript.parentNode.removeChild(tailwindScript);
52
- tailwindScript = null;
53
- tailwindInjected = false;
54
- delete window.tailwind;
55
- }
56
- }
57
- function isTailwindLoaded() {
58
- return tailwindInjected || !!window.tailwind;
59
- }
60
- function getTailwind() {
61
- return window.tailwind;
62
- }
63
- function updateTailwindConfig(config) {
64
- if (window.tailwind) {
65
- window.tailwind.config = {
66
- ...window.tailwind.config,
67
- ...config
68
- };
69
- }
70
- }
71
- function addCustomStyles(css, id) {
72
- if (typeof document === "undefined") {
73
- throw new Error("addCustomStyles can only be used in browser environment");
74
- }
75
- const styleId = id || `servly-custom-styles-${Date.now()}`;
76
- let existingStyle = document.getElementById(styleId);
77
- if (existingStyle) {
78
- existingStyle.textContent = css;
79
- return existingStyle;
80
- }
81
- const style = document.createElement("style");
82
- style.id = styleId;
83
- style.textContent = css;
84
- document.head.appendChild(style);
85
- return style;
86
- }
87
- function removeCustomStyles(id) {
88
- if (typeof document === "undefined") return;
89
- const style = document.getElementById(id);
90
- if (style && style.parentNode) {
91
- style.parentNode.removeChild(style);
92
- }
93
- }
94
- var DEFAULT_SERVLY_TAILWIND_CONFIG = {
95
- theme: {
96
- extend: {
97
- // Add any Servly-specific theme extensions here
98
- }
99
- },
100
- // Safelist common dynamic classes
101
- safelist: [
102
- // Spacing
103
- { pattern: /^(p|m|gap)-/ },
104
- // Sizing
105
- { pattern: /^(w|h|min-w|min-h|max-w|max-h)-/ },
106
- // Flexbox
107
- { pattern: /^(flex|justify|items|self)-/ },
108
- // Grid
109
- { pattern: /^(grid|col|row)-/ },
110
- // Colors
111
- { pattern: /^(bg|text|border|ring)-/ },
112
- // Typography
113
- { pattern: /^(font|text|leading|tracking)-/ },
114
- // Borders
115
- { pattern: /^(rounded|border)-/ },
116
- // Effects
117
- { pattern: /^(shadow|opacity|blur)-/ },
118
- // Transforms
119
- { pattern: /^(scale|rotate|translate|skew)-/ },
120
- // Transitions
121
- { pattern: /^(transition|duration|ease|delay)-/ }
122
- ]
123
- };
124
- async function initServlyTailwind(customConfig) {
125
- const config = customConfig ? { ...DEFAULT_SERVLY_TAILWIND_CONFIG, ...customConfig } : DEFAULT_SERVLY_TAILWIND_CONFIG;
126
- await injectTailwind({
127
- config,
128
- usePlayCdn: true
129
- });
130
- }
131
- var injectTailwindStyles = initServlyTailwind;
132
- var tailwind_default = {
133
- injectTailwind,
134
- injectTailwindStyles,
135
- removeTailwind,
136
- isTailwindLoaded,
137
- getTailwind,
138
- updateTailwindConfig,
139
- addCustomStyles,
140
- removeCustomStyles,
141
- initServlyTailwind,
142
- DEFAULT_SERVLY_TAILWIND_CONFIG
143
- };
144
-
145
- export {
146
- injectTailwind,
147
- removeTailwind,
148
- isTailwindLoaded,
149
- getTailwind,
150
- updateTailwindConfig,
151
- addCustomStyles,
152
- removeCustomStyles,
153
- DEFAULT_SERVLY_TAILWIND_CONFIG,
154
- initServlyTailwind,
155
- injectTailwindStyles,
156
- tailwind_default
157
- };