@servlyadmin/runtime-core 0.1.40 → 0.1.41
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.
|
@@ -145,7 +145,8 @@ function injectTailwind(config = {}) {
|
|
|
145
145
|
if (enablePreload) {
|
|
146
146
|
preloadTailwind(cdnUrl, usePlayCdn);
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
const existingScript = document.querySelector('script[src*="tailwindcss.com"]');
|
|
149
|
+
if (existingScript || window.tailwind) {
|
|
149
150
|
tailwindInjected = true;
|
|
150
151
|
markTailwindAsLoaded();
|
|
151
152
|
if (shouldPreventFOUC) {
|
|
@@ -209,7 +210,32 @@ function removeTailwind() {
|
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
function isTailwindLoaded() {
|
|
212
|
-
|
|
213
|
+
if (typeof window === "undefined") return false;
|
|
214
|
+
if (window.tailwind) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
if (typeof document !== "undefined") {
|
|
218
|
+
try {
|
|
219
|
+
for (const sheet of document.styleSheets) {
|
|
220
|
+
try {
|
|
221
|
+
const rules = sheet.cssRules || sheet.rules;
|
|
222
|
+
if (rules) {
|
|
223
|
+
for (let i = 0; i < Math.min(rules.length, 100); i++) {
|
|
224
|
+
const rule = rules[i];
|
|
225
|
+
if (rule instanceof CSSStyleRule) {
|
|
226
|
+
if (rule.selectorText?.match(/^\.(flex|grid|p-|m-|w-|h-|bg-|text-)/)) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
} catch {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
} catch {
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return tailwindInjected;
|
|
213
239
|
}
|
|
214
240
|
function getTailwind() {
|
|
215
241
|
return window.tailwind;
|
|
@@ -223,18 +249,37 @@ function updateTailwindConfig(config) {
|
|
|
223
249
|
}
|
|
224
250
|
}
|
|
225
251
|
function refreshTailwind() {
|
|
226
|
-
if (typeof window === "undefined") return;
|
|
252
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
227
253
|
const tw = window.tailwind;
|
|
228
254
|
if (tw && typeof tw.refresh === "function") {
|
|
229
255
|
tw.refresh();
|
|
256
|
+
return;
|
|
230
257
|
}
|
|
258
|
+
const servlyElements = document.querySelectorAll("[data-servly-id]");
|
|
259
|
+
servlyElements.forEach((el) => {
|
|
260
|
+
el.classList.add("__tw-refresh__");
|
|
261
|
+
queueMicrotask(() => {
|
|
262
|
+
el.classList.remove("__tw-refresh__");
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
document.body.classList.add("__tw-refresh__");
|
|
266
|
+
queueMicrotask(() => {
|
|
267
|
+
document.body.classList.remove("__tw-refresh__");
|
|
268
|
+
});
|
|
231
269
|
}
|
|
232
270
|
function scheduleRefresh(delayMs = 0) {
|
|
233
271
|
if (typeof window === "undefined") return;
|
|
272
|
+
const doRefresh = () => {
|
|
273
|
+
if (window.tailwind) {
|
|
274
|
+
refreshTailwind();
|
|
275
|
+
} else {
|
|
276
|
+
setTimeout(doRefresh, 100);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
234
279
|
if (delayMs === 0) {
|
|
235
|
-
requestAnimationFrame(
|
|
280
|
+
requestAnimationFrame(doRefresh);
|
|
236
281
|
} else {
|
|
237
|
-
setTimeout(
|
|
282
|
+
setTimeout(doRefresh, delayMs);
|
|
238
283
|
}
|
|
239
284
|
}
|
|
240
285
|
function addCustomStyles(css, id) {
|
package/dist/index.cjs
CHANGED
|
@@ -173,7 +173,8 @@ function injectTailwind(config = {}) {
|
|
|
173
173
|
if (enablePreload) {
|
|
174
174
|
preloadTailwind(cdnUrl, usePlayCdn);
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
const existingScript = document.querySelector('script[src*="tailwindcss.com"]');
|
|
177
|
+
if (existingScript || window.tailwind) {
|
|
177
178
|
tailwindInjected = true;
|
|
178
179
|
markTailwindAsLoaded();
|
|
179
180
|
if (shouldPreventFOUC) {
|
|
@@ -237,7 +238,32 @@ function removeTailwind() {
|
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
function isTailwindLoaded() {
|
|
240
|
-
|
|
241
|
+
if (typeof window === "undefined") return false;
|
|
242
|
+
if (window.tailwind) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
if (typeof document !== "undefined") {
|
|
246
|
+
try {
|
|
247
|
+
for (const sheet of document.styleSheets) {
|
|
248
|
+
try {
|
|
249
|
+
const rules = sheet.cssRules || sheet.rules;
|
|
250
|
+
if (rules) {
|
|
251
|
+
for (let i = 0; i < Math.min(rules.length, 100); i++) {
|
|
252
|
+
const rule = rules[i];
|
|
253
|
+
if (rule instanceof CSSStyleRule) {
|
|
254
|
+
if (rule.selectorText?.match(/^\.(flex|grid|p-|m-|w-|h-|bg-|text-)/)) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return tailwindInjected;
|
|
241
267
|
}
|
|
242
268
|
function getTailwind() {
|
|
243
269
|
return window.tailwind;
|
|
@@ -251,18 +277,37 @@ function updateTailwindConfig(config) {
|
|
|
251
277
|
}
|
|
252
278
|
}
|
|
253
279
|
function refreshTailwind() {
|
|
254
|
-
if (typeof window === "undefined") return;
|
|
280
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
255
281
|
const tw = window.tailwind;
|
|
256
282
|
if (tw && typeof tw.refresh === "function") {
|
|
257
283
|
tw.refresh();
|
|
284
|
+
return;
|
|
258
285
|
}
|
|
286
|
+
const servlyElements = document.querySelectorAll("[data-servly-id]");
|
|
287
|
+
servlyElements.forEach((el) => {
|
|
288
|
+
el.classList.add("__tw-refresh__");
|
|
289
|
+
queueMicrotask(() => {
|
|
290
|
+
el.classList.remove("__tw-refresh__");
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
document.body.classList.add("__tw-refresh__");
|
|
294
|
+
queueMicrotask(() => {
|
|
295
|
+
document.body.classList.remove("__tw-refresh__");
|
|
296
|
+
});
|
|
259
297
|
}
|
|
260
298
|
function scheduleRefresh(delayMs = 0) {
|
|
261
299
|
if (typeof window === "undefined") return;
|
|
300
|
+
const doRefresh = () => {
|
|
301
|
+
if (window.tailwind) {
|
|
302
|
+
refreshTailwind();
|
|
303
|
+
} else {
|
|
304
|
+
setTimeout(doRefresh, 100);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
262
307
|
if (delayMs === 0) {
|
|
263
|
-
requestAnimationFrame(
|
|
308
|
+
requestAnimationFrame(doRefresh);
|
|
264
309
|
} else {
|
|
265
|
-
setTimeout(
|
|
310
|
+
setTimeout(doRefresh, delayMs);
|
|
266
311
|
}
|
|
267
312
|
}
|
|
268
313
|
function addCustomStyles(css, id) {
|
|
@@ -3322,11 +3367,9 @@ var tailwindAutoInjected = false;
|
|
|
3322
3367
|
function ensureTailwind() {
|
|
3323
3368
|
if (tailwindAutoInjected || typeof document === "undefined") return;
|
|
3324
3369
|
tailwindAutoInjected = true;
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
});
|
|
3329
|
-
}
|
|
3370
|
+
injectTailwind({ usePlayCdn: true }).catch((err) => {
|
|
3371
|
+
console.warn("Failed to auto-inject Tailwind CSS:", err);
|
|
3372
|
+
});
|
|
3330
3373
|
}
|
|
3331
3374
|
var COMPONENT_TO_TAG = {
|
|
3332
3375
|
container: "div",
|
package/dist/index.d.cts
CHANGED
|
@@ -1774,6 +1774,7 @@ declare function injectTailwind(config?: TailwindConfig): Promise<void>;
|
|
|
1774
1774
|
declare function removeTailwind(): void;
|
|
1775
1775
|
/**
|
|
1776
1776
|
* Check if Tailwind CSS is loaded
|
|
1777
|
+
* Checks for both CDN (window.tailwind) and build-time Tailwind (style rules)
|
|
1777
1778
|
*/
|
|
1778
1779
|
declare function isTailwindLoaded(): boolean;
|
|
1779
1780
|
/**
|
|
@@ -1787,7 +1788,7 @@ declare function updateTailwindConfig(config: Record<string, any>): void;
|
|
|
1787
1788
|
/**
|
|
1788
1789
|
* Trigger Tailwind to refresh/rescan the DOM
|
|
1789
1790
|
* This is needed when content is rendered after Tailwind CDN loads
|
|
1790
|
-
*
|
|
1791
|
+
* Uses multiple strategies to ensure Tailwind processes new content
|
|
1791
1792
|
*/
|
|
1792
1793
|
declare function refreshTailwind(): void;
|
|
1793
1794
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1774,6 +1774,7 @@ declare function injectTailwind(config?: TailwindConfig): Promise<void>;
|
|
|
1774
1774
|
declare function removeTailwind(): void;
|
|
1775
1775
|
/**
|
|
1776
1776
|
* Check if Tailwind CSS is loaded
|
|
1777
|
+
* Checks for both CDN (window.tailwind) and build-time Tailwind (style rules)
|
|
1777
1778
|
*/
|
|
1778
1779
|
declare function isTailwindLoaded(): boolean;
|
|
1779
1780
|
/**
|
|
@@ -1787,7 +1788,7 @@ declare function updateTailwindConfig(config: Record<string, any>): void;
|
|
|
1787
1788
|
/**
|
|
1788
1789
|
* Trigger Tailwind to refresh/rescan the DOM
|
|
1789
1790
|
* This is needed when content is rendered after Tailwind CDN loads
|
|
1790
|
-
*
|
|
1791
|
+
* Uses multiple strategies to ensure Tailwind processes new content
|
|
1791
1792
|
*/
|
|
1792
1793
|
declare function refreshTailwind(): void;
|
|
1793
1794
|
/**
|
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-E4BRYI54.js";
|
|
21
21
|
import {
|
|
22
22
|
buildRegistryFromBundle,
|
|
23
23
|
collectAllDependencies,
|
|
@@ -2645,11 +2645,9 @@ var tailwindAutoInjected = false;
|
|
|
2645
2645
|
function ensureTailwind() {
|
|
2646
2646
|
if (tailwindAutoInjected || typeof document === "undefined") return;
|
|
2647
2647
|
tailwindAutoInjected = true;
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
});
|
|
2652
|
-
}
|
|
2648
|
+
injectTailwind({ usePlayCdn: true }).catch((err) => {
|
|
2649
|
+
console.warn("Failed to auto-inject Tailwind CSS:", err);
|
|
2650
|
+
});
|
|
2653
2651
|
}
|
|
2654
2652
|
var COMPONENT_TO_TAG = {
|
|
2655
2653
|
container: "div",
|
|
@@ -3615,7 +3613,7 @@ async function createServlyRenderer(options) {
|
|
|
3615
3613
|
container = containerOption;
|
|
3616
3614
|
}
|
|
3617
3615
|
if (shouldInjectTailwind) {
|
|
3618
|
-
const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-
|
|
3616
|
+
const { initServlyTailwind: initServlyTailwind2 } = await import("./tailwind-XSRG6OMQ.js");
|
|
3619
3617
|
await initServlyTailwind2(tailwindConfig);
|
|
3620
3618
|
}
|
|
3621
3619
|
const activeRenders = [];
|