@servlyadmin/runtime-core 0.1.6 → 0.1.8
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/chunk-IWFVKY5N.js +154 -0
- package/dist/index.cjs +2136 -160
- package/dist/index.d.cts +631 -2
- package/dist/index.d.ts +631 -2
- package/dist/index.js +1955 -178
- package/dist/tailwind-CGAHPC3O.js +24 -0
- package/package.json +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
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 tailwind_default = {
|
|
132
|
+
injectTailwind,
|
|
133
|
+
removeTailwind,
|
|
134
|
+
isTailwindLoaded,
|
|
135
|
+
getTailwind,
|
|
136
|
+
updateTailwindConfig,
|
|
137
|
+
addCustomStyles,
|
|
138
|
+
removeCustomStyles,
|
|
139
|
+
initServlyTailwind,
|
|
140
|
+
DEFAULT_SERVLY_TAILWIND_CONFIG
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
injectTailwind,
|
|
145
|
+
removeTailwind,
|
|
146
|
+
isTailwindLoaded,
|
|
147
|
+
getTailwind,
|
|
148
|
+
updateTailwindConfig,
|
|
149
|
+
addCustomStyles,
|
|
150
|
+
removeCustomStyles,
|
|
151
|
+
DEFAULT_SERVLY_TAILWIND_CONFIG,
|
|
152
|
+
initServlyTailwind,
|
|
153
|
+
tailwind_default
|
|
154
|
+
};
|