stoop 0.4.0 → 0.4.1

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.
@@ -1,26 +1,16 @@
1
- /**
2
- * SSR-safe entry point for Stoop.
3
- * Exports only server-safe APIs that don't require React.
4
- * Use this import in Server Components: import { createStoop } from "stoop/ssr"
5
- *
6
- * This file does NOT import React types or create React components.
7
- */
8
- // Import createStoopBase from create-stoop-internal to avoid React type imports
9
- // create-stoop-internal.ts is a copy of create-stoop.ts without React imports at module level
10
- import { createStoopBase } from "./create-stoop-internal";
11
- export function createStoop(config) {
12
- const base = createStoopBase(config);
13
- // Return only server-safe APIs (no React components)
14
- // Ensure config.prefix is always a string (not undefined) for type compatibility
15
- return {
16
- config: { ...base.config, prefix: base.sanitizedPrefix },
17
- createTheme: base.createTheme,
18
- css: base.css,
19
- getCssText: base.getCssText,
20
- globalCss: base.globalCss,
21
- keyframes: base.keyframes,
22
- preloadTheme: base.preloadTheme,
23
- theme: base.theme,
24
- warmCache: base.warmCache,
25
- };
26
- }
1
+ var J0=Object.freeze({}),j=1e4,GJ=5000,QJ=10,FJ=500,P=1000;var c=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],N={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},ZJ=Symbol.for("stoop.component");class L extends Map{maxSize;constructor(J){super();this.maxSize=J}get(J){let $=super.get(J);if($!==void 0)super.delete(J),super.set(J,$);return $}set(J,$){if(super.has(J))super.delete(J);else if(this.size>=this.maxSize){let Y=this.keys().next().value;if(Y!==void 0)super.delete(Y)}return super.set(J,$),this}}var WJ=new L(GJ),n=new L(j);function K(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function g(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function v(J){return typeof J==="object"&&J!==null}function p(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function m(J){return v(J)&&!p(J)}function o(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function x(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(g())return J;let $=J,Y=[];for(let q in $){if(q==="media")continue;if(!c.includes(q))Y.push(q)}if(Y.length>0){let q=`[Stoop] Theme contains invalid scales: ${Y.join(", ")}. Only these scales are allowed: ${c.join(", ")}`;throw new Error(q)}return J}function z(J,$){if(!$||!J||typeof J!=="object")return J;let Y={},q=Object.keys($);for(let X in J){let F=J[X];if(q.includes(X)&&$[X])try{let Q=$[X](F);if(Q&&typeof Q==="object")for(let Z in Q)Y[Z]=Q[Z]}catch{Y[X]=F}else if(v(F))Y[X]=z(F,$);else Y[X]=F}return Y}var l=null,DJ=new L(P),wJ=new L(P),Z0=new L(P),HJ=new L(P);function b(J){let q=2166136261;for(let X=0;X<J.length;X++)q^=J.charCodeAt(X),q=Math.imul(q,16777619);return q^=J.length,(q>>>0).toString(36)}function T(J){try{return b(JSON.stringify(J))}catch{return b(String(J))}}function cJ(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function UJ(J,$=!1){let q=String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if($)q=q.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return q}function BJ(J){return UJ(J,!1)}function I(J){let $=DJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),q=!Y.trim()||/^[>+~:.#[\]&@()\s]+$/.test(Y)?"":Y;return DJ.set(J,q),q}function R(J){let $=HJ.get(J);if($!==void 0)return $;let X=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return HJ.set(J,X),X}function LJ(J){return UJ(J,!0)}function B(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function _J(J){if(!J||typeof J!=="string")return"";let $=J.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!$.trim()||!/[a-zA-Z]/.test($))return"";return $}function C(J){if(!J||typeof J!=="string")return"";let $=wJ.get(J);if($!==void 0)return $;let X=cJ(J).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return wJ.set(J,X),X}function AJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let Y=parseFloat(J);return Y>=0&&Y<=100}return!1}function KJ(J=""){if(!l){let Y=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=new RegExp(`${Y}\\s*\\{[\\s\\S]*\\}`)}return l}function nJ(J){if(J.includes("Color")||J==="fill"||J==="stroke"||J==="accentColor"||J==="caretColor"||J==="border"||J==="outline"||J.includes("background")&&!J.includes("Size")&&!J.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(J)||J.includes("Block")||J.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(J)||J.includes("BlockSize")||J.includes("InlineSize"))return"sizes";if(J==="fontSize"||J==="font"&&!J.includes("Family"))return"fontSizes";if(J==="fontFamily"||J.includes("FontFamily"))return"fonts";if(J==="fontWeight"||J.includes("FontWeight"))return"fontWeights";if(J==="letterSpacing"||J.includes("LetterSpacing"))return"letterSpacings";if(J.includes("Radius")||J.includes("radius"))return"radii";if(J.includes("Shadow")||J.includes("shadow")||J==="filter"||J==="backdropFilter")return"shadows";if(J==="zIndex"||J.includes("ZIndex")||J.includes("z-index"))return"zIndices";if(J==="opacity"||J.includes("Opacity"))return"opacities";if(J.startsWith("transition")||J.startsWith("animation")||J.includes("Transition")||J.includes("Animation"))return"transitions";return}function OJ(J,$){if($&&J in $)return $[J];if(J in N)return N[J];return nJ(J)}var r=new Map;function S(J){return r.has(J)}function f(J,$){r.set(J,$)}var i=new L(j);function MJ(J){if(!i.has(J))i.set(J,!0)}function IJ(){return Array.from(i.keys()).join(`
2
+ `)}var k=new Map;var RJ=new Map;function EJ(J="stoop"){if(!K())throw new Error("Cannot access document in SSR context");let $=B(J),Y=k.get($);if(!Y||!Y.parentNode){let q=document.getElementById("stoop-ssr");if(q){let X=q.getAttribute("data-stoop");if(!X||X===$)return Y=q,Y.setAttribute("data-stoop",$),k.set($,Y),Y}Y=document.createElement("style"),Y.setAttribute("data-stoop",$),Y.setAttribute("id",`stoop-${$}`),document.head.appendChild(Y),k.set($,Y)}return Y}function a(J){let $=J,Y=KJ("");$=$.replace(Y,"").trim();let q=$.indexOf("[data-theme=");while(q!==-1){let X=$.indexOf("{",q);if(X===-1)break;let F=1,Q=X+1;while(Q<$.length&&F>0){if($[Q]==="{")F++;else if($[Q]==="}")F--;Q++}if(F===0){let Z=$.substring(0,q).trim(),G=$.substring(Q).trim();$=(Z+`
3
+ `+G).trim()}else break;q=$.indexOf("[data-theme=")}return $.trim()}function VJ(J,$="stoop"){if(!J)return;let Y=B($),q=`__all_theme_vars_${Y}`;if((RJ.get(q)??null)===J)return;if(RJ.set(q,J),!K()){MJ(J);return}let F=EJ(Y),Q=F.textContent||"",Z=Q.includes(":root")||Q.includes("[data-theme=");if(S(q)||Z){let G=a(Q);F.textContent=J+(G?`
4
+
5
+ `+G:""),f(q,J)}else F.textContent=J+(Q?`
6
+
7
+ `+Q:""),f(q,J)}function pJ(J,$,Y="stoop"){if(!K())return;let q=B(Y);if(S($))return;let X=EJ(q),F=X.textContent||"";X.textContent=F+(F?`
8
+ `:"")+J,f($,J)}function mJ(J,$,Y="stoop"){if(S($))return;let q=B(Y);pJ(J,$,q)}function oJ(J="stoop"){let $=B(J);return k.get($)||null}function lJ(){return new Map(r)}function M(J,$="stoop",Y){let q=Y||J;if(!K()){if(!S(q))f(q,J);MJ(J);return}mJ(J,q,$)}function PJ(J="stoop"){if(K()){let $=B(J),Y=oJ($);if(Y&&Y.parentNode){let q=Y.textContent||"";if(!q&&lJ().size>0)return IJ();return q}}return IJ()}var iJ=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function t(J){let $=new Map;function Y(q,X=[]){let F=Object.keys(q);for(let Q of F){let Z=q[Q],G=[...X,Q];if(o(Z))Y(Z,G);else{let D=$.get(Q);if(D)D.push(G);else $.set(Q,[G])}}}Y(J);for(let[,q]of $.entries())if(q.length>1)q.sort((X,F)=>{let Q=X.length-F.length;if(Q!==0)return Q;let Z=X.join("."),G=F.join(".");return Z.localeCompare(G)});return $}function rJ(J,$){let Y=Object.keys(J).filter((X)=>X!=="media"),q=Object.keys($).filter((X)=>X!=="media");if(Y.length!==q.length)return!1;for(let X of Y)if(!(X in $))return!1;return!0}function zJ(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!rJ(J,$))return!1;let Y={...J},q={...$};return delete Y.media,delete q.media,JSON.stringify(Y)===JSON.stringify(q)}function s(J,$,Y){if(Y&&Y in J){let F=J[Y];if(F&&typeof F==="object"&&!Array.isArray(F)&&$ in F)return[Y,$]}let X=t(J).get($);if(!X||X.length===0)return null;return X[0]}function NJ(J,$,Y,q){if(!J.startsWith("$"))return J;let X=J.slice(1);if(X.includes("$")||X.includes("."))return`var(${`--${(X.includes("$")?X.split("$"):X.split(".")).map((W)=>R(W)).join("-")}`})`;if($&&Y){let Z=OJ(Y,q);if(Z){let w=s($,X,Z);if(w)return`var(${`--${w.map((A)=>R(A)).join("-")}`})`}let D=t($).get(X);if(D&&D.length>1){if(!g()){let w=Z?`Property "${Y}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${Y}". `;console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${D.map((H)=>H.join(".")).join(", ")}. ${w}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let W=s($,X);if(W)return`var(${`--${W.map((U)=>R(U)).join("-")}`})`}else if($){let G=t($).get(X);if(G&&G.length>1){if(!g())console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${G.map((W)=>W.join(".")).join(", ")}. Using "${G[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${G[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let D=s($,X);if(D)return`var(${`--${D.map((H)=>R(H)).join("-")}`})`}return`var(${`--${R(X)}`})`}function e(J,$="stoop",Y){let q=Y||":root",X=[];function F(Q,Z=[]){let G=Object.keys(Q).sort();for(let D of G){if(D==="media")continue;let W=Q[D],w=[...Z,D];if(o(W))F(W,w);else{let U=`--${w.map((y)=>R(y)).join("-")}`,A=typeof W==="string"||typeof W==="number"?LJ(W):String(W);X.push(` ${U}: ${A};`)}}}if(F(J),X.length===0)return"";return`${q} {
9
+ ${X.join(`
10
+ `)}
11
+ }`}function d(J,$="stoop",Y="data-theme"){let q=[];for(let[X,F]of Object.entries(J)){let Q=`[${Y}="${X}"]`,Z=e(F,$,Q);if(Z)q.push(Z)}return q.join(`
12
+
13
+ `)}function E(J,$,Y,q){if(!J||typeof J!=="object")return J;let X={},F=!1,Q=Object.keys(J).sort();for(let Z of Q){let G=J[Z];if(v(G)){let D=E(G,$,Y,void 0);if(X[Z]=D,D!==G)F=!0}else if(typeof G==="string"&&G.includes("$")){F=!0;let D=q||Z;X[Z]=G.replace(iJ,(W)=>{if(W.startsWith("-$")){let w=W.slice(1);return`calc(-1 * ${NJ(w,$,D,Y)})`}return NJ(W,$,D,Y)})}else X[Z]=G}if(!F)return J;return X}function aJ(J,$){if(typeof J==="symbol"&&J===ZJ)return!0;if(p($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function sJ(J,$){if(typeof $==="object"&&$!==null&&"__stoopClassName"in $&&typeof $.__stoopClassName==="string")return $.__stoopClassName;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return J.replace("__STOOP_COMPONENT_","");return""}function _(J,$="",Y=0,q){if(!J||typeof J!=="object")return"";if(Y>QJ)return"";let X=[],F=[],Q=Object.keys(J).sort();for(let G of Q){let D=J[G];if(aJ(G,D)){let W=sJ(G,D);if(!W)continue;let w=I(W);if(!w)continue;let H=$?`${$} .${w}`:`.${w}`,U=m(D)?_(D,H,Y+1,q):"";if(U)F.push(U);continue}if(m(D))if(q&&G in q){let W=_J(q[G]);if(W){let w=_(D,$,Y+1,q);if(w)F.push(`${W} { ${w} }`)}}else if(G.startsWith("@")){let W=I(G);if(W){let w=_(D,$,Y+1,q);if(w)F.push(`${W} { ${w} }`)}}else if(G.includes("&")){let W=I(G);if(W){let H=W.split("&").join($),U=_(D,H,Y+1,q);if(U)F.push(U)}}else if(G.startsWith(":")){let W=I(G);if(W){let w=`${$}${W}`,H=_(D,w,Y+1,q);if(H)F.push(H)}}else if(G.includes(" ")||G.includes(">")||G.includes("+")||G.includes("~")){let W=I(G);if(W){let H=/^[\s>+~]/.test(W.trim())?`${$}${W}`:`${$} ${W}`,U=_(D,H,Y+1,q);if(U)F.push(U)}}else{let W=I(G);if(W){let w=$?`${$} ${W}`:W,H=_(D,w,Y+1,q);if(H)F.push(H)}}else if(D!==void 0){let W=C(G);if(W&&(typeof D==="string"||typeof D==="number")){let w=BJ(D);X.push(`${W}: ${w};`)}}}let Z=[];if(X.length>0)Z.push(`${$} { ${X.join(" ")} }`);return Z.push(...F),Z.join("")}function u(J,$,Y="stoop",q,X,F){let Q=B(Y),Z=z(J,X),G=E(Z,$,F),D=_(G,"",0,q),W=b(D),w=Q?`${Q}-${W}`:`css-${W}`,H=`${Q}:${w}`,U=n.get(H);if(U)return M(U,Q,H),w;let A=_(G,`.${w}`,0,q);return n.set(H,A),WJ.set(H,w),M(A,Q,H),w}var jJ=new Map;function gJ(J,$="stoop"){let Y=$||"";jJ.set(Y,J)}function tJ(J="stoop"){let $=J||"";return jJ.get($)||null}function JJ(J,$){let Y={...J},q=Object.keys($);for(let X of q){if(X==="media")continue;let F=$[X],Q=J[X];if(F&&typeof F==="object"&&!Array.isArray(F)&&Q&&typeof Q==="object"&&!Array.isArray(Q))Y[X]={...Q,...F};else if(F!==void 0)Y[X]=F}return Y}function $J(J,$="stoop"){let Y=tJ($);if(!Y)return J;if(zJ(J,Y))return J;return JJ(Y,J)}function vJ(J,$="stoop",Y="data-theme"){if(!K())return;let q={};for(let[F,Q]of Object.entries(J))q[F]=$J(Q,$);let X=d(q,$,Y);VJ(X,$)}function xJ(J){return function $(Y={}){let q=x(Y);return JJ(J,q)}}function bJ(J,$="stoop",Y,q,X){return function F(Q){return u(Q,J,$,Y,q,X)}}function eJ(J,$,Y,q){let X=`@keyframes ${$} {`,F=Object.keys(J).sort((Q,Z)=>{let G=parseFloat(Q.replace("%","")),D=parseFloat(Z.replace("%",""));if(Q==="from")return-1;if(Z==="from")return 1;if(Q==="to")return 1;if(Z==="to")return-1;return G-D});for(let Q of F){if(!AJ(Q))continue;let Z=J[Q];if(!Z||typeof Z!=="object")continue;X+=` ${Q} {`;let G=E(Z,Y,q),D=Object.keys(G).sort();for(let W of D){let w=G[W];if(w!==void 0&&(typeof w==="string"||typeof w==="number")){let H=C(W);if(H){let U=String(w);X+=` ${H}: ${U};`}}}X+=" }"}return X+=" }",X}function TJ(J="stoop",$,Y){let q=B(J),X=new L(FJ);return function F(Q){let Z=T(Q),G=X.get(Z);if(G)return G;let D=Z.slice(0,8),W=q?`${q}-${D}`:`stoop-${D}`,w=eJ(Q,W,$,Y),H=`__keyframes_${W}`;return M(w,q,H),X.set(Z,W),W}}var YJ=new Set;function CJ(J,$="stoop",Y,q,X){return function F(Q){let Z=T(Q);if(YJ.has(Z))return()=>{};YJ.add(Z);let G=B($),D=z(Q,q),W=E(D,J,X),w=_(W,"",0,Y);return M(w,G,`__global_${Z}`),()=>{YJ.delete(Z)}}}function kJ(J){let{globalCss:$,media:Y,prefix:q="stoop",theme:X,themeMap:F,utils:Q}=J,Z=B(q),G=x(X),D=G.media||Y,W={...N,...F};gJ(G,Z);let w=bJ(G,Z,D,Q,W),H=xJ(G),U=CJ(G,Z,D,Q,W),A=TJ(Z,G,W),y=Object.freeze({...G});function fJ(h){for(let O of h)try{u(O,G,Z,D,Q,W)}catch{}}function SJ(h){if(!J.themes||Object.keys(J.themes).length===0)return;vJ(J.themes,Z)}function dJ(h){let O="";if(J.themes&&Object.keys(J.themes).length>0){let V={};for(let[yJ,hJ]of Object.entries(J.themes))V[yJ]=$J(hJ,Z);let XJ=d(V,Z,"data-theme");if(XJ)O+=XJ+`
14
+ `}else{let V=e(G,Z);if(V)O+=V+`
15
+ `}let uJ=PJ(),qJ=a(uJ).trim();if(qJ)O+=(O?`
16
+ `:"")+qJ;return O}return{config:{...J,prefix:Z},createTheme:H,css:w,getCssText:dJ,globalCss:U,globalCssConfig:$,keyframes:A,media:D,mergedThemeMap:W,preloadTheme:SJ,sanitizedPrefix:Z,theme:y,utils:Q,validatedTheme:G,warmCache:fJ}}function Y1(J){let $=kJ(J);return{config:{...$.config,prefix:$.sanitizedPrefix},createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,theme:$.theme,warmCache:$.warmCache}}export{Y1 as createStoop};
@@ -1,156 +1,16 @@
1
- /**
2
- * Factory function that creates a Stoop instance.
3
- * Supports both client-side (with React APIs) and server-side (without React) usage.
4
- * Automatically detects environment and includes appropriate APIs.
5
- */
6
- import { createTheme as createThemeFactory, createCSSFunction, createKeyframesFunction, } from "./api/core-api";
7
- import { createGlobalCSSFunction } from "./api/global-css";
8
- import { createStyledFunction } from "./api/styled";
9
- import { createProvider, createUseThemeHook } from "./api/theme-provider";
10
- import { DEFAULT_THEME_MAP } from "./constants";
11
- import { compileCSS } from "./core/compiler";
12
- import { mergeWithDefaultTheme, registerDefaultTheme, injectAllThemes } from "./core/theme-manager";
13
- import { getCssText as getCssTextBase, removeThemeVariableBlocks } from "./inject";
14
- import { validateTheme } from "./utils/helpers";
15
- import { generateAllThemeVariables, generateCSSVariables } from "./utils/theme";
16
- import { sanitizePrefix } from "./utils/theme-utils";
17
- /**
18
- * Shared implementation for creating Stoop instances.
19
- * Handles common setup logic for both client and server instances.
20
- * Exported for use in SSR entry point.
21
- */
22
- export function createStoopBase(config) {
23
- const { globalCss: globalCssConfig, media: configMedia, prefix = "stoop", theme, themeMap: userThemeMap, utils, } = config;
24
- const sanitizedPrefix = sanitizePrefix(prefix);
25
- const validatedTheme = validateTheme(theme);
26
- const media = validatedTheme.media || configMedia;
27
- const mergedThemeMap = {
28
- ...DEFAULT_THEME_MAP,
29
- ...userThemeMap,
30
- };
31
- registerDefaultTheme(validatedTheme, sanitizedPrefix);
32
- const css = createCSSFunction(validatedTheme, sanitizedPrefix, media, utils, mergedThemeMap);
33
- const createTheme = createThemeFactory(validatedTheme);
34
- const globalCss = createGlobalCSSFunction(validatedTheme, sanitizedPrefix, media, utils, mergedThemeMap);
35
- const keyframes = createKeyframesFunction(sanitizedPrefix, validatedTheme, mergedThemeMap);
36
- const themeObject = Object.freeze({ ...validatedTheme });
37
- /**
38
- * Pre-compiles CSS objects to warm the cache.
39
- * Useful for eliminating FOUC by pre-compiling common styles.
40
- *
41
- * @param styles - Array of CSS objects to pre-compile
42
- */
43
- function warmCache(styles) {
44
- for (const style of styles) {
45
- try {
46
- compileCSS(style, validatedTheme, sanitizedPrefix, media, utils, mergedThemeMap);
47
- }
48
- catch {
49
- // Skip invalid styles
50
- }
51
- }
52
- }
53
- /**
54
- * Preloads a theme by injecting its CSS variables before React renders.
55
- * Useful for preventing FOUC when loading a non-default theme from localStorage.
56
- * Uses injectAllThemes to ensure all themes are available.
57
- *
58
- * @param theme - Theme to preload (can be theme name string or Theme object)
59
- */
60
- function preloadTheme(theme) {
61
- if (!config.themes || Object.keys(config.themes).length === 0) {
62
- return;
63
- }
64
- // Always inject all themes for consistency and to prevent FOUC
65
- injectAllThemes(config.themes, sanitizedPrefix);
66
- }
67
- /**
68
- * Gets all injected CSS text for server-side rendering.
69
- * Always includes all theme CSS variables using attribute selectors.
70
- *
71
- * @param theme - Deprecated parameter, kept for backward compatibility but ignored
72
- * @returns CSS text string with theme variables and component styles
73
- */
74
- function getCssText(theme) {
75
- let result = "";
76
- // Always include all themes using attribute selectors for consistency
77
- if (config.themes && Object.keys(config.themes).length > 0) {
78
- // Merge all themes with default theme for consistency with client-side behavior
79
- const mergedThemes = {};
80
- for (const [themeName, theme] of Object.entries(config.themes)) {
81
- mergedThemes[themeName] = mergeWithDefaultTheme(theme, sanitizedPrefix);
82
- }
83
- const allThemeVars = generateAllThemeVariables(mergedThemes, sanitizedPrefix, "data-theme");
84
- if (allThemeVars) {
85
- result += allThemeVars + "\n";
86
- }
87
- }
88
- else {
89
- // No themes configured, just use default theme
90
- const themeVars = generateCSSVariables(validatedTheme, sanitizedPrefix);
91
- if (themeVars) {
92
- result += themeVars + "\n";
93
- }
94
- }
95
- const baseCss = getCssTextBase();
96
- // Remove any existing theme variable blocks (they're already included above)
97
- const cleanedCss = removeThemeVariableBlocks(baseCss).trim();
98
- if (cleanedCss) {
99
- result += (result ? "\n" : "") + cleanedCss;
100
- }
101
- return result;
102
- }
103
- return {
104
- config: { ...config, prefix: sanitizedPrefix },
105
- createTheme,
106
- css,
107
- getCssText,
108
- globalCss,
109
- globalCssConfig,
110
- keyframes,
111
- media,
112
- mergedThemeMap,
113
- preloadTheme,
114
- sanitizedPrefix,
115
- theme: themeObject,
116
- utils,
117
- // Internal values for React API creation
118
- validatedTheme,
119
- warmCache,
120
- };
121
- }
122
- export function createStoop(config) {
123
- const base = createStoopBase(config);
124
- // Create full client instance (React APIs may be undefined in SSR contexts)
125
- // Create Provider and useTheme if themes are configured
126
- let Provider;
127
- let useTheme;
128
- let themeContext;
129
- if (config.themes) {
130
- const mergedThemesForProvider = {};
131
- for (const [themeName, themeOverride] of Object.entries(config.themes)) {
132
- mergedThemesForProvider[themeName] = base.createTheme(themeOverride);
133
- }
134
- const { Provider: ProviderComponent, ThemeContext, ThemeManagementContext, } = createProvider(mergedThemesForProvider, base.validatedTheme, base.sanitizedPrefix, base.globalCssConfig, base.globalCss);
135
- themeContext = ThemeContext;
136
- Provider = ProviderComponent;
137
- useTheme = createUseThemeHook(ThemeManagementContext);
138
- }
139
- // Create styled function
140
- const styled = createStyledFunction(base.validatedTheme, base.sanitizedPrefix, base.media, base.utils, base.mergedThemeMap, themeContext);
141
- // Return instance with all APIs
142
- return {
143
- config: base.config,
144
- createTheme: base.createTheme,
145
- css: base.css,
146
- getCssText: base.getCssText,
147
- globalCss: base.globalCss,
148
- keyframes: base.keyframes,
149
- preloadTheme: base.preloadTheme,
150
- Provider,
151
- styled,
152
- theme: base.theme,
153
- useTheme,
154
- warmCache: base.warmCache,
155
- };
156
- }
1
+ var r=Object.freeze({}),s=1e4,T0=5000,C0=10,f0=500,c=1000,k0=31536000,S0="/",W0=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],n={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},a=Symbol.for("stoop.component");class E extends Map{maxSize;constructor($){super();this.maxSize=$}get($){let J=super.get($);if(J!==void 0)super.delete($),super.set($,J);return J}set($,J){if(super.has($))super.delete($);else if(this.size>=this.maxSize){let q=this.keys().next().value;if(q!==void 0)super.delete(q)}return super.set($,J),this}}var d0=new E(T0),D0=new E(s);function w(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function u(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function t($){return typeof $==="object"&&$!==null}function m($){return typeof $==="object"&&$!==null&&"__isStoopStyled"in $&&"__stoopClassName"in $&&$.__isStoopStyled===!0}function U0($){return t($)&&!m($)}function H0($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function e($){if(!$||typeof $!=="object"||Array.isArray($))throw new Error("[Stoop] Theme must be a non-null object");if(u())return $;let J=$,q=[];for(let X in J){if(X==="media")continue;if(!W0.includes(X))q.push(X)}if(q.length>0){let X=`[Stoop] Theme contains invalid scales: ${q.join(", ")}. Only these scales are allowed: ${W0.join(", ")}`;throw new Error(X)}return $}function i($,J){if(!J||!$||typeof $!=="object")return $;let q={},X=Object.keys(J);for(let Y in $){let Q=$[Y];if(X.includes(Y)&&J[Y])try{let G=J[Y](Q);if(G&&typeof G==="object")for(let Z in G)q[Z]=G[Z]}catch{q[Y]=Q}else if(t(Q))q[Y]=i(Q,J);else q[Y]=Q}return q}var F0=null,u0=new E(c),y0=new E(c),p0=new E(c),h0=new E(c);function y($){let X=2166136261;for(let Y=0;Y<$.length;Y++)X^=$.charCodeAt(Y),X=Math.imul(X,16777619);return X^=$.length,(X>>>0).toString(36)}function $0($){try{return y(JSON.stringify($))}catch{return y(String($))}}function O1($){return $.replace(/([A-Z])/g,"-$1").toLowerCase()}function c0($,J=!1){let X=String($).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if(J)X=X.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return X}function n0($){return c0($,!1)}function T($){let J=u0.get($);if(J!==void 0)return J;let q=$.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),X=!q.trim()||/^[>+~:.#[\]&@()\s]+$/.test(q)?"":q;return u0.set($,X),X}function C($){let J=h0.get($);if(J!==void 0)return J;let Y=$.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return h0.set($,Y),Y}function m0($){return c0($,!0)}function R($){if(!$)return"stoop";return $.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function i0($){if(!$||typeof $!=="string")return"";let J=$.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!J.trim()||!/[a-zA-Z]/.test(J))return"";return J}function o0($){if(!$||typeof $!=="string")return"";let J=p0.get($);if(J!==void 0)return J;let q=$.trim().split(/\s+/),X=[];for(let Q of q){if(!Q)continue;let Z=Q.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(Z&&/^[a-zA-Z-_]/.test(Z))X.push(Z)}let Y=X.join(" ");return p0.set($,Y),Y}function J0($){if(!$||typeof $!=="string")return"";let J=y0.get($);if(J!==void 0)return J;let Y=O1($).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return y0.set($,Y),Y}function l0($){if(!$||typeof $!=="string")return!1;if($==="from"||$==="to")return!0;if(/^\d+(\.\d+)?%$/.test($)){let q=parseFloat($);return q>=0&&q<=100}return!1}function r0($=""){if(!F0){let q=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");F0=new RegExp(`${q}\\s*\\{[\\s\\S]*\\}`)}return F0}function M1($){if($.includes("Color")||$==="fill"||$==="stroke"||$==="accentColor"||$==="caretColor"||$==="border"||$==="outline"||$.includes("background")&&!$.includes("Size")&&!$.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test($)||$.includes("Block")||$.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test($)||$.includes("BlockSize")||$.includes("InlineSize"))return"sizes";if($==="fontSize"||$==="font"&&!$.includes("Family"))return"fontSizes";if($==="fontFamily"||$.includes("FontFamily"))return"fonts";if($==="fontWeight"||$.includes("FontWeight"))return"fontWeights";if($==="letterSpacing"||$.includes("LetterSpacing"))return"letterSpacings";if($.includes("Radius")||$.includes("radius"))return"radii";if($.includes("Shadow")||$.includes("shadow")||$==="filter"||$==="backdropFilter")return"shadows";if($==="zIndex"||$.includes("ZIndex")||$.includes("z-index"))return"zIndices";if($==="opacity"||$.includes("Opacity"))return"opacities";if($.startsWith("transition")||$.startsWith("animation")||$.includes("Transition")||$.includes("Animation"))return"transitions";return}function s0($,J){if(J&&$ in J)return J[$];if($ in n)return n[$];return M1($)}var w0=new Map;function Y0($){return w0.has($)}function X0($,J){w0.set($,J)}var L0=new E(s);function e0($){if(!L0.has($))L0.set($,!0)}function a0(){return Array.from(L0.keys()).join(`
2
+ `)}var q0=new Map;var t0=new Map;function $1($="stoop"){if(!w())throw new Error("Cannot access document in SSR context");let J=R($),q=q0.get(J);if(!q||!q.parentNode){let X=document.getElementById("stoop-ssr");if(X){let Y=X.getAttribute("data-stoop");if(!Y||Y===J)return q=X,q.setAttribute("data-stoop",J),q0.set(J,q),q}q=document.createElement("style"),q.setAttribute("data-stoop",J),q.setAttribute("id",`stoop-${J}`),document.head.appendChild(q),q0.set(J,q)}return q}function B0($){let J=$,q=r0("");J=J.replace(q,"").trim();let X=J.indexOf("[data-theme=");while(X!==-1){let Y=J.indexOf("{",X);if(Y===-1)break;let Q=1,G=Y+1;while(G<J.length&&Q>0){if(J[G]==="{")Q++;else if(J[G]==="}")Q--;G++}if(Q===0){let Z=J.substring(0,X).trim(),W=J.substring(G).trim();J=(Z+`
3
+ `+W).trim()}else break;X=J.indexOf("[data-theme=")}return J.trim()}function J1($,J="stoop"){if(!$)return;let q=R(J),X=`__all_theme_vars_${q}`;if((t0.get(X)??null)===$)return;if(t0.set(X,$),!w()){e0($);return}let Q=$1(q),G=Q.textContent||"",Z=G.includes(":root")||G.includes("[data-theme=");if(Y0(X)||Z){let W=B0(G);Q.textContent=$+(W?`
4
+
5
+ `+W:""),X0(X,$)}else Q.textContent=$+(G?`
6
+
7
+ `+G:""),X0(X,$)}function z1($,J,q="stoop"){if(!w())return;let X=R(q);if(Y0(J))return;let Y=$1(X),Q=Y.textContent||"";Y.textContent=Q+(Q?`
8
+ `:"")+$,X0(J,$)}function E1($,J,q="stoop"){if(Y0(J))return;let X=R(q);z1($,J,X)}function K1($="stoop"){let J=R($);return q0.get(J)||null}function j1(){return new Map(w0)}function f($,J="stoop",q){let X=q||$;if(!w()){if(!Y0(X))X0(X,$);e0($);return}E1($,X,J)}function q1($="stoop"){if(w()){let J=R($),q=K1(J);if(q&&q.parentNode){let X=q.textContent||"";if(!X&&j1().size>0)return a0();return X}}return a0()}var P1=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function _0($){let J=new Map;function q(X,Y=[]){let Q=Object.keys(X);for(let G of Q){let Z=X[G],W=[...Y,G];if(H0(Z))q(Z,W);else{let U=J.get(G);if(U)U.push(W);else J.set(G,[W])}}}q($);for(let[,X]of J.entries())if(X.length>1)X.sort((Y,Q)=>{let G=Y.length-Q.length;if(G!==0)return G;let Z=Y.join("."),W=Q.join(".");return Z.localeCompare(W)});return J}function V1($,J){let q=Object.keys($).filter((Y)=>Y!=="media"),X=Object.keys(J).filter((Y)=>Y!=="media");if(q.length!==X.length)return!1;for(let Y of q)if(!(Y in J))return!1;return!0}function Y1($,J){if($===J)return!0;if(!$||!J)return!1;if(!V1($,J))return!1;let q={...$},X={...J};return delete q.media,delete X.media,JSON.stringify(q)===JSON.stringify(X)}function A0($,J,q){if(q&&q in $){let Q=$[q];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&J in Q)return[q,J]}let Y=_0($).get(J);if(!Y||Y.length===0)return null;return Y[0]}function X1($,J,q,X){if(!$.startsWith("$"))return $;let Y=$.slice(1);if(Y.includes("$")||Y.includes("."))return`var(${`--${(Y.includes("$")?Y.split("$"):Y.split(".")).map((D)=>C(D)).join("-")}`})`;if(J&&q){let Z=s0(q,X);if(Z){let H=A0(J,Y,Z);if(H)return`var(${`--${H.map((O)=>C(O)).join("-")}`})`}let U=_0(J).get(Y);if(U&&U.length>1){if(!u()){let H=Z?`Property "${q}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${q}". `;console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${U.map((F)=>F.join(".")).join(", ")}. ${H}Using "${U[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${U[0].join(".")}" to be explicit.`)}}let D=A0(J,Y);if(D)return`var(${`--${D.map((L)=>C(L)).join("-")}`})`}else if(J){let W=_0(J).get(Y);if(W&&W.length>1){if(!u())console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${W.map((D)=>D.join(".")).join(", ")}. Using "${W[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${W[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let U=A0(J,Y);if(U)return`var(${`--${U.map((F)=>C(F)).join("-")}`})`}return`var(${`--${C(Y)}`})`}function I0($,J="stoop",q){let X=q||":root",Y=[];function Q(G,Z=[]){let W=Object.keys(G).sort();for(let U of W){if(U==="media")continue;let D=G[U],H=[...Z,U];if(H0(D))Q(D,H);else{let L=`--${H.map((_)=>C(_)).join("-")}`,O=typeof D==="string"||typeof D==="number"?m0(D):String(D);Y.push(` ${L}: ${O};`)}}}if(Q($),Y.length===0)return"";return`${X} {
9
+ ${Y.join(`
10
+ `)}
11
+ }`}function G0($,J="stoop",q="data-theme"){let X=[];for(let[Y,Q]of Object.entries($)){let G=`[${q}="${Y}"]`,Z=I0(Q,J,G);if(Z)X.push(Z)}return X.join(`
12
+
13
+ `)}function k($,J,q,X){if(!$||typeof $!=="object")return $;let Y={},Q=!1,G=Object.keys($).sort();for(let Z of G){let W=$[Z];if(t(W)){let U=k(W,J,q,void 0);if(Y[Z]=U,U!==W)Q=!0}else if(typeof W==="string"&&W.includes("$")){Q=!0;let U=X||Z;Y[Z]=W.replace(P1,(D)=>{if(D.startsWith("-$")){let H=D.slice(1);return`calc(-1 * ${X1(H,J,U,q)})`}return X1(D,J,U,q)})}else Y[Z]=W}if(!Q)return $;return Y}function N1($,J){if(typeof $==="symbol"&&$===a)return!0;if(m(J))return!0;if(typeof $==="string"&&$.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function x1($,J){if(typeof J==="object"&&J!==null&&"__stoopClassName"in J&&typeof J.__stoopClassName==="string")return J.__stoopClassName;if(typeof $==="string"&&$.startsWith("__STOOP_COMPONENT_"))return $.replace("__STOOP_COMPONENT_","");return""}function K($,J="",q=0,X){if(!$||typeof $!=="object")return"";if(q>C0)return"";let Y=[],Q=[],G=Object.keys($).sort();for(let W of G){let U=$[W];if(N1(W,U)){let D=x1(W,U);if(!D)continue;let H=T(D);if(!H)continue;let F=J?`${J} .${H}`:`.${H}`,L=U0(U)?K(U,F,q+1,X):"";if(L)Q.push(L);continue}if(U0(U))if(X&&W in X){let D=i0(X[W]);if(D){let H=K(U,J,q+1,X);if(H)Q.push(`${D} { ${H} }`)}}else if(W.startsWith("@")){let D=T(W);if(D){let H=K(U,J,q+1,X);if(H)Q.push(`${D} { ${H} }`)}}else if(W.includes("&")){let D=T(W);if(D){let F=D.split("&").join(J),L=K(U,F,q+1,X);if(L)Q.push(L)}}else if(W.startsWith(":")){let D=T(W);if(D){let H=`${J}${D}`,F=K(U,H,q+1,X);if(F)Q.push(F)}}else if(W.includes(" ")||W.includes(">")||W.includes("+")||W.includes("~")){let D=T(W);if(D){let F=/^[\s>+~]/.test(D.trim())?`${J}${D}`:`${J} ${D}`,L=K(U,F,q+1,X);if(L)Q.push(L)}}else{let D=T(W);if(D){let H=J?`${J} ${D}`:D,F=K(U,H,q+1,X);if(F)Q.push(F)}}else if(U!==void 0){let D=J0(W);if(D&&(typeof U==="string"||typeof U==="number")){let H=n0(U);Y.push(`${D}: ${H};`)}}}let Z=[];if(Y.length>0)Z.push(`${J} { ${Y.join(" ")} }`);return Z.push(...Q),Z.join("")}function p($,J,q="stoop",X,Y,Q){let G=R(q),Z=i($,Y),W=k(Z,J,Q),U=K(W,"",0,X),D=y(U),H=G?`${G}-${D}`:`css-${D}`,F=`${G}:${H}`,L=D0.get(F);if(L)return f(L,G,F),H;let O=K(W,`.${H}`,0,X);return D0.set(F,O),d0.set(F,H),f(O,G,F),H}var G1=new Map;function Q1($,J="stoop"){let q=J||"";G1.set(q,$)}function v1($="stoop"){let J=$||"";return G1.get(J)||null}function R0($,J){let q={...$},X=Object.keys(J);for(let Y of X){if(Y==="media")continue;let Q=J[Y],G=$[Y];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&G&&typeof G==="object"&&!Array.isArray(G))q[Y]={...G,...Q};else if(Q!==void 0)q[Y]=Q}return q}function O0($,J="stoop"){let q=v1(J);if(!q)return $;if(Y1($,q))return $;return R0(q,$)}function Q0($,J="stoop",q="data-theme"){if(!w())return;let X={};for(let[Q,G]of Object.entries($))X[Q]=O0(G,J);let Y=G0(X,J,q);J1(Y,J)}function Z1($){return function J(q={}){let X=e(q);return R0($,X)}}function W1($,J="stoop",q,X,Y){return function Q(G){return p(G,$,J,q,X,Y)}}function b1($,J,q,X){let Y=`@keyframes ${J} {`,Q=Object.keys($).sort((G,Z)=>{let W=parseFloat(G.replace("%","")),U=parseFloat(Z.replace("%",""));if(G==="from")return-1;if(Z==="from")return 1;if(G==="to")return 1;if(Z==="to")return-1;return W-U});for(let G of Q){if(!l0(G))continue;let Z=$[G];if(!Z||typeof Z!=="object")continue;Y+=` ${G} {`;let W=k(Z,q,X),U=Object.keys(W).sort();for(let D of U){let H=W[D];if(H!==void 0&&(typeof H==="string"||typeof H==="number")){let F=J0(D);if(F){let L=String(H);Y+=` ${F}: ${L};`}}}Y+=" }"}return Y+=" }",Y}function D1($="stoop",J,q){let X=R($),Y=new E(f0);return function Q(G){let Z=$0(G),W=Y.get(Z);if(W)return W;let U=Z.slice(0,8),D=X?`${X}-${U}`:`stoop-${U}`,H=b1(G,D,J,q),F=`__keyframes_${D}`;return f(H,X,F),Y.set(Z,D),D}}var M0=new Set;function U1($,J="stoop",q,X,Y){return function Q(G){let Z=$0(G);if(M0.has(Z))return()=>{};M0.add(Z);let W=R(J),U=i(G,X),D=k(U,$,Y),H=K(D,"",0,q);return f(H,W,`__global_${Z}`),()=>{M0.delete(Z)}}}import{useMemo as Z0,forwardRef as g1,createElement as T1,useContext as C1,createContext as f1}from"react";function H1($,J,q){let X=!1,Y=[];for(let G in $){let Z=J[G];if(Z===void 0)continue;let W=$[G],U=Z===!0?"true":Z===!1?"false":String(Z);if(W[U])Y.push(W[U]),X=!0}if(!X)return q;let Q={...Y[0]};for(let G=1;G<Y.length;G++)Object.assign(Q,Y[G]);return{...q,...Q}}var z0=null;function k1(){if(!z0)z0=f1(null);return z0}function S1($){return{__isStoopStyled:!0,__stoopClassName:$,[a]:$,toString:()=>`__STOOP_COMPONENT_${$}`}}function d1($){return m($)}var u1=new Set(["alignContent","alignItems","alignSelf","animation","animationDelay","animationDirection","animationDuration","animationFillMode","animationIterationCount","animationName","animationPlayState","animationTimingFunction","aspectRatio","backdropFilter","backfaceVisibility","background","backgroundAttachment","backgroundBlendMode","backgroundClip","backgroundColor","backgroundImage","backgroundOrigin","backgroundPosition","backgroundRepeat","backgroundSize","border","borderBottom","borderBottomColor","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderImage","borderImageOutset","borderImageRepeat","borderImageSlice","borderImageSource","borderImageWidth","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRadius","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderSpacing","borderStyle","borderTop","borderTopColor","borderTopLeftRadius","borderTopRightRadius","borderTopStyle","borderTopWidth","borderWidth","bottom","boxShadow","boxSizing","captionSide","caretColor","clear","clip","clipPath","color","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","columns","content","counterIncrement","counterReset","cursor","direction","display","emptyCells","filter","flex","flexBasis","flexDirection","flexFlow","flexGrow","flexShrink","flexWrap","float","font","fontFamily","fontFeatureSettings","fontKerning","fontLanguageOverride","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontSynthesis","fontVariant","fontVariantAlternates","fontVariantCaps","fontVariantEastAsian","fontVariantLigatures","fontVariantNumeric","fontVariantPosition","fontWeight","gap","grid","gridArea","gridAutoColumns","gridAutoFlow","gridAutoRows","gridColumn","gridColumnEnd","gridColumnGap","gridColumnStart","gridGap","gridRow","gridRowEnd","gridRowGap","gridRowStart","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","hyphens","imageOrientation","imageRendering","imageResolution","imeMode","inlineSize","isolation","justifyContent","justifyItems","justifySelf","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginBottom","marginLeft","marginRight","marginTop","maxHeight","maxWidth","minHeight","minWidth","objectFit","objectPosition","opacity","order","orphans","outline","outlineColor","outlineOffset","outlineStyle","outlineWidth","overflow","overflowWrap","overflowX","overflowY","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","pageBreakAfter","pageBreakBefore","pageBreakInside","perspective","perspectiveOrigin","placeContent","placeItems","placeSelf","pointerEvents","position","quotes","resize","right","rowGap","scrollBehavior","tabSize","tableLayout","textAlign","textAlignLast","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textIndent","textJustify","textOverflow","textShadow","textTransform","textUnderlinePosition","top","transform","transformOrigin","transformStyle","transition","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","unicodeBidi","userSelect","verticalAlign","visibility","whiteSpace","width","wordBreak","wordSpacing","wordWrap","writingMode","zIndex"]);function y1($){return u1.has($)}function p1($,J){let q=J?new Set(Object.keys(J)):new Set,X={},Y={},Q={};for(let G in $)if(q.has(G))X[G]=$[G];else if(y1(G))Y[G]=$[G];else Q[G]=$[G];return{cssProps:Y,elementProps:Q,variantProps:X}}function F1($,J="stoop",q,X,Y,Q){return function G(Z,W,U){let D=W||r,H=U;if(W&&"variants"in W&&typeof W.variants==="object"){H=W.variants;let{variants:v,...x}=W;D=x}let F;if(typeof Z!=="string"&&d1(Z))F=Z.__stoopClassName;let L=g1(function v(x,j){let{as:z,className:P,css:M,...N}=x,b=z||Z,g=Z0(()=>M&&typeof M==="object"&&M!==null?M:r,[M]),{cssProps:B,elementProps:V,variantProps:S}=p1(N,H),l=C1(Q||k1())?.theme||$,x0=l.media?{...q,...l.media}:q,v0=Z0(()=>{if(!H)return"";let I=Object.entries(S);if(I.length===0)return"";return I.sort(([d],[h])=>d.localeCompare(h)).map(([d,h])=>`${d}:${String(h)}`).join("|")},[S]),b0=Z0(()=>{let I=D;if(H&&v0)I=H1(H,S,D);if(Object.keys(B).length>0)I=Object.assign({},I,B);if(g!==r)I=Object.assign({},I,g);return I},[v0,g,B,D,H,S]),R1=Z0(()=>{let I=[];if(F)I.push(F);let d=p(b0,l,J,x0,X,Y);if(d)I.push(d);if(P){let h=typeof P==="string"?P:String(P),g0=o0(h);if(g0)I.push(g0)}return I.length>0?I.join(" "):void 0},[b0,P,F,l,J,x0,X,Y]);return T1(b,{...V,className:R1,ref:j})}),O=y(JSON.stringify(D)),_=`${J}-${O}`,A=L;return A.selector=S1(_),A}}import{createContext as w1,useCallback as B1,useContext as h1,useLayoutEffect as o,useMemo as P0,useRef as V0,useState as c1}from"react";function E0($){if(!w())return{error:"Not in browser environment",success:!1,value:null};try{return{source:"localStorage",success:!0,value:localStorage.getItem($)}}catch(J){return{error:J instanceof Error?J.message:"localStorage access failed",success:!1,value:null}}}function K0($,J){if(!w())return{error:"Not in browser environment",success:!1,value:void 0};try{return localStorage.setItem($,J),{success:!0,value:void 0}}catch(q){return{error:q instanceof Error?q.message:"localStorage write failed",success:!1,value:void 0}}}function j0($){if(!w())return null;let q=`; ${document.cookie}`.split(`; ${$}=`);if(q.length===2)return q.pop()?.split(";").shift()||null;return null}function L1($,J,q={}){if(!w())return!1;let{maxAge:X=k0,path:Y=S0,secure:Q=!1}=q;try{return document.cookie=`${$}=${J}; path=${Y}; max-age=${X}${Q?"; secure":""}`,!0}catch{return!1}}import{jsx as A1}from"react/jsx-runtime";function N0($,J,q){if(!w())return;let X=J?j0(J):null,Y=E0(q),Q=Y.success?Y.value:null;if(X===$&&Q!==$)K0(q,$);if(Q===$&&J&&X!==$)L1(J,$)}function n1($,J,q){if(!w())return null;if($!==void 0){let Q=j0($);if(Q&&q[Q])return Q}let X=E0(J),Y=X.success?X.value:null;if(Y&&q[Y])return Y;return null}function _1($,J,q="stoop",X,Y){let Q=w1(null),G=w1(null),Z=Object.keys($),W=Z[0]||"default",U=X&&Y?Y(X):void 0;function D({attribute:H="data-theme",children:F,cookieKey:L,defaultTheme:O,storageKey:_="stoop-theme"}){let[A,v]=c1(O||W),x=V0(!1);o(()=>{if(!w()||x.current)return;let B=n1(L,_,$);if(B){if(N0(B,L,_),B!==A)v(B)}x.current=!0},[L,_,$]),o(()=>{if(!w())return;let B=(V)=>{if(V.key===_&&V.newValue&&$[V.newValue]&&V.newValue!==A)v(V.newValue),N0(V.newValue,L,_)};return window.addEventListener("storage",B),()=>{window.removeEventListener("storage",B)}},[_,L,A,$]);let j=P0(()=>{return $[A]||$[O||W]||J},[A,O,W,$,J]),z=V0(!1),P=V0(!1);o(()=>{if(!w()||z.current)return;Q0($,q,H),z.current=!0},[$,q,H]),o(()=>{if(!w()||P.current)return;if(U)U(),P.current=!0},[U]),o(()=>{if(!w())return;if(H)document.documentElement.setAttribute(H,A)},[A,H]);let M=B1((B)=>{if($[B])v(B),K0(_,B),N0(B,L,_);else if(!u())console.warn(`[Stoop] Theme "${B}" not found. Available themes: ${Z.join(", ")}`)},[_,L,$,Z,A]),N=P0(()=>({theme:j,themeName:A}),[j,A]),b=B1(()=>{let V=(Z.indexOf(A)+1)%Z.length,S=Z[V];M(S)},[A,M,Z]),g=P0(()=>({availableThemes:Z,setTheme:M,theme:j,themeName:A,toggleTheme:b}),[j,A,M,b]);return A1(Q.Provider,{value:N,children:A1(G.Provider,{value:g,children:F})})}return{Provider:D,ThemeContext:Q,ThemeManagementContext:G}}function I1($){return function J(){let q=h1($);if(!q)throw new Error("useTheme must be used within a Provider");return q}}function m1($){let{globalCss:J,media:q,prefix:X="stoop",theme:Y,themeMap:Q,utils:G}=$,Z=R(X),W=e(Y),U=W.media||q,D={...n,...Q};Q1(W,Z);let H=W1(W,Z,U,G,D),F=Z1(W),L=U1(W,Z,U,G,D),O=D1(Z,W,D),_=Object.freeze({...W});function A(j){for(let z of j)try{p(z,W,Z,U,G,D)}catch{}}function v(j){if(!$.themes||Object.keys($.themes).length===0)return;Q0($.themes,Z)}function x(j){let z="";if($.themes&&Object.keys($.themes).length>0){let N={};for(let[g,B]of Object.entries($.themes))N[g]=O0(B,Z);let b=G0(N,Z,"data-theme");if(b)z+=b+`
14
+ `}else{let N=I0(W,Z);if(N)z+=N+`
15
+ `}let P=q1(),M=B0(P).trim();if(M)z+=(z?`
16
+ `:"")+M;return z}return{config:{...$,prefix:Z},createTheme:F,css:H,getCssText:x,globalCss:L,globalCssConfig:J,keyframes:O,media:U,mergedThemeMap:D,preloadTheme:v,sanitizedPrefix:Z,theme:_,utils:G,validatedTheme:W,warmCache:A}}function U5($){let J=m1($),q,X,Y;if($.themes){let G={};for(let[D,H]of Object.entries($.themes))G[D]=J.createTheme(H);let{Provider:Z,ThemeContext:W,ThemeManagementContext:U}=_1(G,J.validatedTheme,J.sanitizedPrefix,J.globalCssConfig,J.globalCss);Y=W,q=Z,X=I1(U)}let Q=F1(J.validatedTheme,J.sanitizedPrefix,J.media,J.utils,J.mergedThemeMap,Y);return{config:J.config,createTheme:J.createTheme,css:J.css,getCssText:J.getCssText,globalCss:J.globalCss,keyframes:J.keyframes,preloadTheme:J.preloadTheme,Provider:q,styled:Q,theme:J.theme,useTheme:X,warmCache:J.warmCache}}export{m1 as createStoopBase,U5 as createStoop};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stoop",
3
3
  "description": "CSS-in-JS library with type inference, theme creation, and variants support.",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "author": "Jackson Dolman <mail@dolmios.com>",
6
6
  "main": "./dist/create-stoop.js",
7
7
  "types": "./dist/create-stoop.d.ts",
@@ -96,18 +96,20 @@
96
96
  "react": ">=16.8.0",
97
97
  "react-dom": ">=16.8.0"
98
98
  },
99
- "sideEffects": false,
100
- "type": "module",
101
99
  "scripts": {
102
100
  "build": "bun run build:clean && bun run build:js && bun run build:js:ssr && bun run build:types",
103
101
  "build:clean": "rm -rf dist",
104
102
  "build:copy-declarations": "mkdir -p dist/types && cp src/types/react-polymorphic-types.d.ts dist/types/react-polymorphic-types.d.ts 2>/dev/null || :",
105
- "build:js": "NODE_ENV=production bun build ./src/create-stoop.ts --outdir ./dist --target node --minify --jsx=automatic --splitting --external react --external react-dom --external react/jsx-runtime --define process.env.NODE_ENV='\"production\"'",
106
- "build:js:ssr": "NODE_ENV=production bun build ./src/create-stoop-ssr.ts --outdir ./dist --target node --minify --jsx=automatic --external react --external react-dom --external react/jsx-runtime --define process.env.NODE_ENV='\"production\"'",
103
+ "build:js": "NODE_ENV=production bun build ./src/create-stoop.ts --outfile ./dist/create-stoop.js --target browser --format esm --minify --jsx=automatic --external react --external react-dom --external react/jsx-runtime --define process.env.NODE_ENV='\"production\"'",
104
+ "build:js:ssr": "NODE_ENV=production bun build ./src/create-stoop-ssr.ts --outfile ./dist/create-stoop-ssr.js --target browser --format esm --minify --jsx=automatic --external react --external react-dom --external react/jsx-runtime --define process.env.NODE_ENV='\"production\"'",
107
105
  "build:types": "bunx tsc --project tsconfig.build.json && bun run build:copy-declarations",
108
106
  "lint": "eslint src --fix",
107
+ "prepare": "bun run build",
109
108
  "test": "bun test",
110
109
  "test:coverage": "bun test --coverage",
111
110
  "test:watch": "bun test --watch"
112
- }
113
- }
111
+ },
112
+ "sideEffects": false,
113
+ "type": "module"
114
+ }
115
+
@@ -1,135 +0,0 @@
1
- /**
2
- * Core API functions.
3
- * Consolidates theme creation, CSS class generation, and keyframes animation APIs.
4
- */
5
- import { LRUCache } from "../core/cache";
6
- import { compileCSS } from "../core/compiler";
7
- import { mergeThemes } from "../core/theme-manager";
8
- import { injectCSS } from "../inject";
9
- import { validateTheme } from "../utils/helpers";
10
- import { replaceThemeTokensWithVars } from "../utils/theme";
11
- import { hashObject, sanitizeCSSPropertyName, sanitizePrefix, validateKeyframeKey, } from "../utils/theme-utils";
12
- // ============================================================================
13
- // Theme Creation API
14
- // ============================================================================
15
- /**
16
- * Creates a function that extends a base theme with overrides.
17
- * The returned function deep merges theme overrides with the base theme.
18
- *
19
- * @param baseTheme - Base theme to extend
20
- * @returns Function that accepts theme overrides and returns a merged theme
21
- */
22
- export function createTheme(baseTheme) {
23
- return function createTheme(themeOverrides = {}) {
24
- const validatedOverrides = validateTheme(themeOverrides);
25
- // Use shared mergeThemes function instead of duplicate deepMerge
26
- return mergeThemes(baseTheme, validatedOverrides);
27
- };
28
- }
29
- // ============================================================================
30
- // CSS Class Generation API
31
- // ============================================================================
32
- /**
33
- * Creates a CSS function that compiles CSS objects into class names.
34
- *
35
- * @param defaultTheme - Default theme for token resolution
36
- * @param prefix - Optional prefix for generated class names
37
- * @param media - Optional media query breakpoints
38
- * @param utils - Optional utility functions
39
- * @param themeMap - Optional theme scale mappings
40
- * @returns Function that accepts CSS objects and returns class names
41
- */
42
- export function createCSSFunction(defaultTheme, prefix = "stoop", media, utils, themeMap) {
43
- return function css(styles) {
44
- return compileCSS(styles, defaultTheme, prefix, media, utils, themeMap);
45
- };
46
- }
47
- // ============================================================================
48
- // Keyframes Animation API
49
- // ============================================================================
50
- /**
51
- * Converts a keyframes object to a CSS @keyframes rule string.
52
- *
53
- * @param keyframesObj - Keyframes object with percentage/from/to keys
54
- * @param animationName - Name for the animation
55
- * @param theme - Optional theme for token resolution
56
- * @param themeMap - Optional theme scale mappings
57
- * @returns CSS @keyframes rule string
58
- */
59
- function keyframesToCSS(keyframesObj, animationName, theme, themeMap) {
60
- let css = `@keyframes ${animationName} {`;
61
- const sortedKeys = Object.keys(keyframesObj).sort((a, b) => {
62
- const aNum = parseFloat(a.replace("%", ""));
63
- const bNum = parseFloat(b.replace("%", ""));
64
- if (a === "from") {
65
- return -1;
66
- }
67
- if (b === "from") {
68
- return 1;
69
- }
70
- if (a === "to") {
71
- return 1;
72
- }
73
- if (b === "to") {
74
- return -1;
75
- }
76
- return aNum - bNum;
77
- });
78
- for (const key of sortedKeys) {
79
- if (!validateKeyframeKey(key)) {
80
- continue;
81
- }
82
- const styles = keyframesObj[key];
83
- if (!styles || typeof styles !== "object") {
84
- continue;
85
- }
86
- css += ` ${key} {`;
87
- const themedStyles = replaceThemeTokensWithVars(styles, theme, themeMap);
88
- // Sort properties for deterministic CSS generation
89
- const sortedProps = Object.keys(themedStyles).sort();
90
- for (const prop of sortedProps) {
91
- const value = themedStyles[prop];
92
- if (value !== undefined && (typeof value === "string" || typeof value === "number")) {
93
- const sanitizedProp = sanitizeCSSPropertyName(prop);
94
- if (sanitizedProp) {
95
- // Don't escape keyframe values - escaping breaks complex CSS functions
96
- const cssValue = String(value);
97
- css += ` ${sanitizedProp}: ${cssValue};`;
98
- }
99
- }
100
- }
101
- css += " }";
102
- }
103
- css += " }";
104
- return css;
105
- }
106
- import { KEYFRAME_CACHE_LIMIT } from "../constants";
107
- /**
108
- * Creates a keyframes animation function.
109
- * Generates and injects @keyframes rules with caching to prevent duplicates.
110
- *
111
- * @param prefix - Optional prefix for animation names
112
- * @param theme - Optional theme for token resolution
113
- * @param themeMap - Optional theme scale mappings
114
- * @returns Function that accepts keyframes objects and returns animation names
115
- */
116
- export function createKeyframesFunction(prefix = "stoop", theme, themeMap) {
117
- const sanitizedPrefix = sanitizePrefix(prefix);
118
- const animationCache = new LRUCache(KEYFRAME_CACHE_LIMIT);
119
- return function keyframes(keyframesObj) {
120
- const keyframesKey = hashObject(keyframesObj);
121
- const cachedName = animationCache.get(keyframesKey);
122
- if (cachedName) {
123
- return cachedName;
124
- }
125
- const hashValue = keyframesKey.slice(0, 8);
126
- const animationName = sanitizedPrefix
127
- ? `${sanitizedPrefix}-${hashValue}`
128
- : `stoop-${hashValue}`;
129
- const css = keyframesToCSS(keyframesObj, animationName, theme, themeMap);
130
- const ruleKey = `__keyframes_${animationName}`;
131
- injectCSS(css, sanitizedPrefix, ruleKey);
132
- animationCache.set(keyframesKey, animationName);
133
- return animationName;
134
- };
135
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Global CSS injection API.
3
- * Creates a function that injects global styles into the document.
4
- * Supports media queries, nested selectors, and theme tokens.
5
- */
6
- import { cssObjectToString } from "../core/compiler";
7
- import { injectCSS } from "../inject";
8
- import { applyUtilities } from "../utils/helpers";
9
- import { replaceThemeTokensWithVars } from "../utils/theme";
10
- import { hashObject, sanitizePrefix } from "../utils/theme-utils";
11
- /**
12
- * Creates a global CSS injection function.
13
- * Injects styles directly into the document with deduplication support.
14
- *
15
- * @param defaultTheme - Default theme for token resolution
16
- * @param prefix - Optional prefix for CSS rules
17
- * @param media - Optional media query breakpoints
18
- * @param utils - Optional utility functions
19
- * @param themeMap - Optional theme scale mappings
20
- * @returns Function that accepts CSS objects and returns a cleanup function
21
- */
22
- // Use CSS hash as key instead of theme object reference for better deduplication
23
- const globalInjectedStyles = new Set();
24
- export function createGlobalCSSFunction(defaultTheme, prefix = "stoop", media, utils, themeMap) {
25
- return function globalCss(styles) {
26
- const cssKey = hashObject(styles);
27
- if (globalInjectedStyles.has(cssKey)) {
28
- return () => { };
29
- }
30
- globalInjectedStyles.add(cssKey);
31
- const sanitizedPrefix = sanitizePrefix(prefix);
32
- const stylesWithUtils = applyUtilities(styles, utils);
33
- const themedStyles = replaceThemeTokensWithVars(stylesWithUtils, defaultTheme, themeMap);
34
- // Use cssObjectToString from compiler.ts instead of duplicate generateGlobalCSS
35
- // Empty selector for global CSS (no base selector needed)
36
- const cssText = cssObjectToString(themedStyles, "", 0, media);
37
- injectCSS(cssText, sanitizedPrefix, `__global_${cssKey}`);
38
- return () => {
39
- globalInjectedStyles.delete(cssKey);
40
- };
41
- };
42
- }