@servlyadmin/runtime-core
Advanced tools
| // src/tailwind.ts | ||
| var DEFAULT_TAILWIND_CDN = "https://cdn.tailwindcss.com"; | ||
| var tailwindInjected = false; | ||
| var tailwindScript = null; | ||
| function injectTailwind(config = {}) { | ||
| return new Promise((resolve, reject) => { | ||
| if (tailwindInjected && tailwindScript) { | ||
| resolve(); | ||
| return; | ||
| } | ||
| if (typeof document === "undefined") { | ||
| resolve(); | ||
| return; | ||
| } | ||
| if (window.tailwind) { | ||
| tailwindInjected = true; | ||
| config.onReady?.(); | ||
| resolve(); | ||
| return; | ||
| } | ||
| const { | ||
| cdnUrl = DEFAULT_TAILWIND_CDN, | ||
| config: tailwindConfig, | ||
| plugins = [], | ||
| usePlayCdn = false, | ||
| onReady, | ||
| onError | ||
| } = config; | ||
| const script = document.createElement("script"); | ||
| script.src = usePlayCdn ? `${cdnUrl}?plugins=forms,typography,aspect-ratio` : cdnUrl; | ||
| script.async = true; | ||
| script.onload = () => { | ||
| tailwindInjected = true; | ||
| tailwindScript = script; | ||
| if (tailwindConfig && window.tailwind) { | ||
| window.tailwind.config = tailwindConfig; | ||
| } | ||
| onReady?.(); | ||
| resolve(); | ||
| }; | ||
| script.onerror = (event) => { | ||
| const error = new Error(`Failed to load Tailwind CSS from ${cdnUrl}`); | ||
| onError?.(error); | ||
| reject(error); | ||
| }; | ||
| document.head.appendChild(script); | ||
| }); | ||
| } | ||
| function removeTailwind() { | ||
| if (tailwindScript && tailwindScript.parentNode) { | ||
| tailwindScript.parentNode.removeChild(tailwindScript); | ||
| tailwindScript = null; | ||
| tailwindInjected = false; | ||
| delete window.tailwind; | ||
| } | ||
| } | ||
| function isTailwindLoaded() { | ||
| return tailwindInjected || !!window.tailwind; | ||
| } | ||
| function getTailwind() { | ||
| return window.tailwind; | ||
| } | ||
| function updateTailwindConfig(config) { | ||
| if (window.tailwind) { | ||
| window.tailwind.config = { | ||
| ...window.tailwind.config, | ||
| ...config | ||
| }; | ||
| } | ||
| } | ||
| function addCustomStyles(css, id) { | ||
| if (typeof document === "undefined") { | ||
| throw new Error("addCustomStyles can only be used in browser environment"); | ||
| } | ||
| const styleId = id || `servly-custom-styles-${Date.now()}`; | ||
| let existingStyle = document.getElementById(styleId); | ||
| if (existingStyle) { | ||
| existingStyle.textContent = css; | ||
| return existingStyle; | ||
| } | ||
| const style = document.createElement("style"); | ||
| style.id = styleId; | ||
| style.textContent = css; | ||
| document.head.appendChild(style); | ||
| return style; | ||
| } | ||
| function removeCustomStyles(id) { | ||
| if (typeof document === "undefined") return; | ||
| const style = document.getElementById(id); | ||
| if (style && style.parentNode) { | ||
| style.parentNode.removeChild(style); | ||
| } | ||
| } | ||
| var DEFAULT_SERVLY_TAILWIND_CONFIG = { | ||
| theme: { | ||
| extend: { | ||
| // Add any Servly-specific theme extensions here | ||
| } | ||
| }, | ||
| // Safelist common dynamic classes | ||
| safelist: [ | ||
| // Spacing | ||
| { pattern: /^(p|m|gap)-/ }, | ||
| // Sizing | ||
| { pattern: /^(w|h|min-w|min-h|max-w|max-h)-/ }, | ||
| // Flexbox | ||
| { pattern: /^(flex|justify|items|self)-/ }, | ||
| // Grid | ||
| { pattern: /^(grid|col|row)-/ }, | ||
| // Colors | ||
| { pattern: /^(bg|text|border|ring)-/ }, | ||
| // Typography | ||
| { pattern: /^(font|text|leading|tracking)-/ }, | ||
| // Borders | ||
| { pattern: /^(rounded|border)-/ }, | ||
| // Effects | ||
| { pattern: /^(shadow|opacity|blur)-/ }, | ||
| // Transforms | ||
| { pattern: /^(scale|rotate|translate|skew)-/ }, | ||
| // Transitions | ||
| { pattern: /^(transition|duration|ease|delay)-/ } | ||
| ] | ||
| }; | ||
| async function initServlyTailwind(customConfig) { | ||
| const config = customConfig ? { ...DEFAULT_SERVLY_TAILWIND_CONFIG, ...customConfig } : DEFAULT_SERVLY_TAILWIND_CONFIG; | ||
| await injectTailwind({ | ||
| config, | ||
| usePlayCdn: true | ||
| }); | ||
| } | ||
| var injectTailwindStyles = initServlyTailwind; | ||
| var tailwind_default = { | ||
| injectTailwind, | ||
| injectTailwindStyles, | ||
| removeTailwind, | ||
| isTailwindLoaded, | ||
| getTailwind, | ||
| updateTailwindConfig, | ||
| addCustomStyles, | ||
| removeCustomStyles, | ||
| initServlyTailwind, | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG | ||
| }; | ||
| export { | ||
| injectTailwind, | ||
| removeTailwind, | ||
| isTailwindLoaded, | ||
| getTailwind, | ||
| updateTailwindConfig, | ||
| addCustomStyles, | ||
| removeCustomStyles, | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG, | ||
| initServlyTailwind, | ||
| injectTailwindStyles, | ||
| tailwind_default | ||
| }; |
| import { | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG, | ||
| addCustomStyles, | ||
| getTailwind, | ||
| initServlyTailwind, | ||
| injectTailwind, | ||
| injectTailwindStyles, | ||
| isTailwindLoaded, | ||
| removeCustomStyles, | ||
| removeTailwind, | ||
| tailwind_default, | ||
| updateTailwindConfig | ||
| } from "./chunk-SMHCCKAZ.js"; | ||
| import "./chunk-MCKGQKYU.js"; | ||
| export { | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG, | ||
| addCustomStyles, | ||
| tailwind_default as default, | ||
| getTailwind, | ||
| initServlyTailwind, | ||
| injectTailwind, | ||
| injectTailwindStyles, | ||
| isTailwindLoaded, | ||
| removeCustomStyles, | ||
| removeTailwind, | ||
| updateTailwindConfig | ||
| }; |
+6
-6
| { | ||
| "name": "@servlyadmin/runtime-core", | ||
| "version": "0.1.30", | ||
| "version": "0.1.31", | ||
| "description": "Framework-agnostic core renderer for Servly components", | ||
| "type": "module", | ||
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.js", | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/index.mjs", | ||
| "types": "./dist/index.d.ts", | ||
@@ -12,5 +12,5 @@ "exports": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.cjs", | ||
| "default": "./dist/index.js" | ||
| "import": "./dist/index.mjs", | ||
| "require": "./dist/index.js", | ||
| "default": "./dist/index.mjs" | ||
| } | ||
@@ -17,0 +17,0 @@ }, |
| // src/tailwind.ts | ||
| var DEFAULT_TAILWIND_CDN = "https://cdn.tailwindcss.com"; | ||
| var tailwindInjected = false; | ||
| var tailwindScript = null; | ||
| function injectTailwind(config = {}) { | ||
| return new Promise((resolve, reject) => { | ||
| if (tailwindInjected && tailwindScript) { | ||
| resolve(); | ||
| return; | ||
| } | ||
| if (typeof document === "undefined") { | ||
| resolve(); | ||
| return; | ||
| } | ||
| if (window.tailwind) { | ||
| tailwindInjected = true; | ||
| config.onReady?.(); | ||
| resolve(); | ||
| return; | ||
| } | ||
| const { | ||
| cdnUrl = DEFAULT_TAILWIND_CDN, | ||
| config: tailwindConfig, | ||
| plugins = [], | ||
| usePlayCdn = false, | ||
| onReady, | ||
| onError | ||
| } = config; | ||
| const script = document.createElement("script"); | ||
| script.src = usePlayCdn ? `${cdnUrl}?plugins=forms,typography,aspect-ratio` : cdnUrl; | ||
| script.async = true; | ||
| script.onload = () => { | ||
| tailwindInjected = true; | ||
| tailwindScript = script; | ||
| if (tailwindConfig && window.tailwind) { | ||
| window.tailwind.config = tailwindConfig; | ||
| } | ||
| onReady?.(); | ||
| resolve(); | ||
| }; | ||
| script.onerror = (event) => { | ||
| const error = new Error(`Failed to load Tailwind CSS from ${cdnUrl}`); | ||
| onError?.(error); | ||
| reject(error); | ||
| }; | ||
| document.head.appendChild(script); | ||
| }); | ||
| } | ||
| function removeTailwind() { | ||
| if (tailwindScript && tailwindScript.parentNode) { | ||
| tailwindScript.parentNode.removeChild(tailwindScript); | ||
| tailwindScript = null; | ||
| tailwindInjected = false; | ||
| delete window.tailwind; | ||
| } | ||
| } | ||
| function isTailwindLoaded() { | ||
| return tailwindInjected || !!window.tailwind; | ||
| } | ||
| function getTailwind() { | ||
| return window.tailwind; | ||
| } | ||
| function updateTailwindConfig(config) { | ||
| if (window.tailwind) { | ||
| window.tailwind.config = { | ||
| ...window.tailwind.config, | ||
| ...config | ||
| }; | ||
| } | ||
| } | ||
| function addCustomStyles(css, id) { | ||
| if (typeof document === "undefined") { | ||
| throw new Error("addCustomStyles can only be used in browser environment"); | ||
| } | ||
| const styleId = id || `servly-custom-styles-${Date.now()}`; | ||
| let existingStyle = document.getElementById(styleId); | ||
| if (existingStyle) { | ||
| existingStyle.textContent = css; | ||
| return existingStyle; | ||
| } | ||
| const style = document.createElement("style"); | ||
| style.id = styleId; | ||
| style.textContent = css; | ||
| document.head.appendChild(style); | ||
| return style; | ||
| } | ||
| function removeCustomStyles(id) { | ||
| if (typeof document === "undefined") return; | ||
| const style = document.getElementById(id); | ||
| if (style && style.parentNode) { | ||
| style.parentNode.removeChild(style); | ||
| } | ||
| } | ||
| var DEFAULT_SERVLY_TAILWIND_CONFIG = { | ||
| theme: { | ||
| extend: { | ||
| // Add any Servly-specific theme extensions here | ||
| } | ||
| }, | ||
| // Safelist common dynamic classes | ||
| safelist: [ | ||
| // Spacing | ||
| { pattern: /^(p|m|gap)-/ }, | ||
| // Sizing | ||
| { pattern: /^(w|h|min-w|min-h|max-w|max-h)-/ }, | ||
| // Flexbox | ||
| { pattern: /^(flex|justify|items|self)-/ }, | ||
| // Grid | ||
| { pattern: /^(grid|col|row)-/ }, | ||
| // Colors | ||
| { pattern: /^(bg|text|border|ring)-/ }, | ||
| // Typography | ||
| { pattern: /^(font|text|leading|tracking)-/ }, | ||
| // Borders | ||
| { pattern: /^(rounded|border)-/ }, | ||
| // Effects | ||
| { pattern: /^(shadow|opacity|blur)-/ }, | ||
| // Transforms | ||
| { pattern: /^(scale|rotate|translate|skew)-/ }, | ||
| // Transitions | ||
| { pattern: /^(transition|duration|ease|delay)-/ } | ||
| ] | ||
| }; | ||
| async function initServlyTailwind(customConfig) { | ||
| const config = customConfig ? { ...DEFAULT_SERVLY_TAILWIND_CONFIG, ...customConfig } : DEFAULT_SERVLY_TAILWIND_CONFIG; | ||
| await injectTailwind({ | ||
| config, | ||
| usePlayCdn: true | ||
| }); | ||
| } | ||
| var tailwind_default = { | ||
| injectTailwind, | ||
| removeTailwind, | ||
| isTailwindLoaded, | ||
| getTailwind, | ||
| updateTailwindConfig, | ||
| addCustomStyles, | ||
| removeCustomStyles, | ||
| initServlyTailwind, | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG | ||
| }; | ||
| export { | ||
| injectTailwind, | ||
| removeTailwind, | ||
| isTailwindLoaded, | ||
| getTailwind, | ||
| updateTailwindConfig, | ||
| addCustomStyles, | ||
| removeCustomStyles, | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG, | ||
| initServlyTailwind, | ||
| tailwind_default | ||
| }; |
| import { | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG, | ||
| addCustomStyles, | ||
| getTailwind, | ||
| initServlyTailwind, | ||
| injectTailwind, | ||
| isTailwindLoaded, | ||
| removeCustomStyles, | ||
| removeTailwind, | ||
| tailwind_default, | ||
| updateTailwindConfig | ||
| } from "./chunk-IWFVKY5N.js"; | ||
| import "./chunk-MCKGQKYU.js"; | ||
| export { | ||
| DEFAULT_SERVLY_TAILWIND_CONFIG, | ||
| addCustomStyles, | ||
| tailwind_default as default, | ||
| getTailwind, | ||
| initServlyTailwind, | ||
| injectTailwind, | ||
| isTailwindLoaded, | ||
| removeCustomStyles, | ||
| removeTailwind, | ||
| updateTailwindConfig | ||
| }; |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 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
1680817
0.07%43463
0.09%