stoop 0.2.1 → 0.4.0

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.
Files changed (56) hide show
  1. package/README.md +48 -103
  2. package/dist/api/core-api.d.ts +34 -0
  3. package/dist/api/core-api.js +135 -0
  4. package/dist/api/global-css.d.ts +0 -11
  5. package/dist/api/global-css.js +42 -0
  6. package/dist/api/styled.d.ts +0 -1
  7. package/dist/api/styled.js +419 -0
  8. package/dist/api/theme-provider.d.ts +41 -0
  9. package/dist/api/theme-provider.js +223 -0
  10. package/dist/constants.d.ts +13 -4
  11. package/dist/constants.js +154 -0
  12. package/dist/core/cache.d.ts +5 -9
  13. package/dist/core/cache.js +68 -0
  14. package/dist/core/compiler.d.ts +11 -0
  15. package/dist/core/compiler.js +206 -0
  16. package/dist/core/theme-manager.d.ts +27 -4
  17. package/dist/core/theme-manager.js +107 -0
  18. package/dist/core/variants.js +38 -0
  19. package/dist/create-stoop-internal.d.ts +30 -0
  20. package/dist/create-stoop-internal.js +123 -0
  21. package/dist/create-stoop-ssr.d.ts +10 -0
  22. package/dist/create-stoop-ssr.js +26 -0
  23. package/dist/create-stoop.d.ts +32 -4
  24. package/dist/create-stoop.js +156 -0
  25. package/dist/inject.d.ts +113 -0
  26. package/dist/inject.js +308 -0
  27. package/dist/types/index.d.ts +157 -17
  28. package/dist/types/index.js +5 -0
  29. package/dist/types/react-polymorphic-types.d.ts +15 -8
  30. package/dist/utils/auto-preload.d.ts +45 -0
  31. package/dist/utils/auto-preload.js +167 -0
  32. package/dist/utils/helpers.d.ts +64 -0
  33. package/dist/utils/helpers.js +150 -0
  34. package/dist/utils/storage.d.ts +148 -0
  35. package/dist/utils/storage.js +396 -0
  36. package/dist/utils/{string.d.ts → theme-utils.d.ts} +36 -12
  37. package/dist/utils/theme-utils.js +353 -0
  38. package/dist/utils/theme.d.ts +17 -5
  39. package/dist/utils/theme.js +304 -0
  40. package/package.json +48 -24
  41. package/LICENSE.md +0 -21
  42. package/dist/api/create-theme.d.ts +0 -13
  43. package/dist/api/css.d.ts +0 -16
  44. package/dist/api/keyframes.d.ts +0 -16
  45. package/dist/api/provider.d.ts +0 -19
  46. package/dist/api/use-theme.d.ts +0 -13
  47. package/dist/index.d.ts +0 -6
  48. package/dist/index.js +0 -13
  49. package/dist/inject/browser.d.ts +0 -59
  50. package/dist/inject/dedup.d.ts +0 -29
  51. package/dist/inject/index.d.ts +0 -41
  52. package/dist/inject/ssr.d.ts +0 -28
  53. package/dist/utils/theme-map.d.ts +0 -25
  54. package/dist/utils/theme-validation.d.ts +0 -13
  55. package/dist/utils/type-guards.d.ts +0 -26
  56. package/dist/utils/utilities.d.ts +0 -14
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "stoop",
3
3
  "description": "CSS-in-JS library with type inference, theme creation, and variants support.",
4
- "version": "0.2.1",
4
+ "version": "0.4.0",
5
5
  "author": "Jackson Dolman <mail@dolmios.com>",
6
- "main": "./dist/index.js",
6
+ "main": "./dist/create-stoop.js",
7
+ "types": "./dist/create-stoop.d.ts",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "https://github.com/dolmios/stoop.git"
@@ -16,22 +17,48 @@
16
17
  "react-polymorphic-types": "^2.0.0"
17
18
  },
18
19
  "devDependencies": {
19
- "@types/node": "^22.17.0",
20
- "@types/react": "^19.1.9",
21
- "@types/react-dom": "^19.1.7",
22
- "bun-types": "^1.2.19",
23
- "eslint": "^9.32.0",
24
- "eslint-config-dolmios": "^2.0.10",
25
- "prettier": "^3.6.2",
26
- "react": "^19.1.1",
27
- "react-dom": "^19.1.1",
28
- "typescript": "^5.9.2"
20
+ "@types/node": "^25.0.3",
21
+ "@types/react": "^19.2.7",
22
+ "@types/react-dom": "^19.2.3",
23
+ "bun-types": "^1.3.5",
24
+ "typescript": "^5.9.3"
29
25
  },
30
26
  "exports": {
31
27
  ".": {
32
- "types": "./dist/index.d.ts",
33
- "import": "./dist/index.js",
34
- "require": "./dist/index.js"
28
+ "types": "./dist/create-stoop.d.ts",
29
+ "import": "./dist/create-stoop.js",
30
+ "require": "./dist/create-stoop.js",
31
+ "default": "./dist/create-stoop.js"
32
+ },
33
+ "./utils/storage": {
34
+ "types": "./dist/utils/storage.d.ts",
35
+ "import": "./dist/utils/storage.js",
36
+ "require": "./dist/utils/storage.js",
37
+ "default": "./dist/utils/storage.js"
38
+ },
39
+ "./utils/auto-preload": {
40
+ "types": "./dist/utils/auto-preload.d.ts",
41
+ "import": "./dist/utils/auto-preload.js",
42
+ "require": "./dist/utils/auto-preload.js",
43
+ "default": "./dist/utils/auto-preload.js"
44
+ },
45
+ "./types": {
46
+ "types": "./dist/types/index.d.ts",
47
+ "import": "./dist/types/index.js",
48
+ "require": "./dist/types/index.js",
49
+ "default": "./dist/types/index.js"
50
+ },
51
+ "./inject": {
52
+ "types": "./dist/inject.d.ts",
53
+ "import": "./dist/inject.js",
54
+ "require": "./dist/inject.js",
55
+ "default": "./dist/inject.js"
56
+ },
57
+ "./ssr": {
58
+ "types": "./dist/create-stoop-ssr.d.ts",
59
+ "import": "./dist/create-stoop-ssr.js",
60
+ "require": "./dist/create-stoop-ssr.js",
61
+ "default": "./dist/create-stoop-ssr.js"
35
62
  }
36
63
  },
37
64
  "files": [
@@ -69,19 +96,16 @@
69
96
  "react": ">=16.8.0",
70
97
  "react-dom": ">=16.8.0"
71
98
  },
72
- "prettier": "eslint-config-dolmios/configs/prettier",
73
99
  "sideEffects": false,
74
100
  "type": "module",
75
101
  "scripts": {
76
- "build": "bun run build:clean && bun run build:js && bun run build:types && bun run build:copy-declarations",
102
+ "build": "bun run build:clean && bun run build:js && bun run build:js:ssr && bun run build:types",
77
103
  "build:clean": "rm -rf dist",
78
- "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 || true",
79
- "build:js": "bun build ./src/index.ts --outdir ./dist --target browser --minify --jsx=react --splitting --external react --external react-dom",
80
- "build:types": "bunx tsc src/index.ts src/**/*.ts --declaration --emitDeclarationOnly --outDir dist --skipLibCheck --jsx react-jsx --module ESNext --moduleResolution bundler --target ES2022 --lib dom,dom.iterable,esnext --rootDir src",
81
- "dev": "bun run build && bun --bun preview/index.html",
82
- "format": "prettier --write src preview",
83
- "kill": "lsof -ti:3000,420 | xargs kill -9 2>/dev/null || true",
84
- "lint": "eslint . --ext .ts,.tsx --fix",
104
+ "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\"'",
107
+ "build:types": "bunx tsc --project tsconfig.build.json && bun run build:copy-declarations",
108
+ "lint": "eslint src --fix",
85
109
  "test": "bun test",
86
110
  "test:coverage": "bun test --coverage",
87
111
  "test:watch": "bun test --watch"
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Jackson Dolman
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,13 +0,0 @@
1
- /**
2
- * Theme extension API.
3
- * Creates a function that deep merges theme overrides with a base theme.
4
- */
5
- import type { Theme } from "../types";
6
- /**
7
- * Creates a function that extends a base theme with overrides.
8
- * The returned function deep merges theme overrides with the base theme.
9
- *
10
- * @param baseTheme - Base theme to extend
11
- * @returns Function that accepts theme overrides and returns a merged theme
12
- */
13
- export declare function createTheme(baseTheme: Theme): (themeOverrides: Partial<Theme>) => Theme;
package/dist/api/css.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * CSS class generation API.
3
- * Creates a function that compiles CSS objects into class names.
4
- */
5
- import type { CSS, Theme, ThemeScale, UtilityFunction } from "../types";
6
- /**
7
- * Creates a CSS function that compiles CSS objects into class names.
8
- *
9
- * @param defaultTheme - Default theme for token resolution
10
- * @param prefix - Optional prefix for generated class names
11
- * @param media - Optional media query breakpoints
12
- * @param utils - Optional utility functions
13
- * @param themeMap - Optional theme scale mappings
14
- * @returns Function that accepts CSS objects and returns class names
15
- */
16
- export declare function createCSSFunction(defaultTheme: Theme, prefix?: string, media?: Record<string, string>, utils?: Record<string, UtilityFunction>, themeMap?: Record<string, ThemeScale>): (styles: CSS) => string;
@@ -1,16 +0,0 @@
1
- /**
2
- * CSS keyframes animation API.
3
- * Creates a function that generates and injects @keyframes rules.
4
- * Caches animations by content hash to prevent duplicates.
5
- */
6
- import type { CSS, Theme, ThemeScale } from "../types";
7
- /**
8
- * Creates a keyframes animation function.
9
- * Generates and injects @keyframes rules with caching to prevent duplicates.
10
- *
11
- * @param prefix - Optional prefix for animation names
12
- * @param theme - Optional theme for token resolution
13
- * @param themeMap - Optional theme scale mappings
14
- * @returns Function that accepts keyframes objects and returns animation names
15
- */
16
- export declare function createKeyframesFunction(prefix?: string, theme?: Theme, themeMap?: Record<string, ThemeScale>): (keyframes: Record<string, CSS>) => string;
@@ -1,19 +0,0 @@
1
- /**
2
- * Theme Provider component.
3
- * Manages theme state, localStorage persistence, and centralized theme variable updates.
4
- */
5
- import { type ComponentType, type Context } from "react";
6
- import type { ProviderProps, Theme, ThemeContextValue, ThemeManagementContextValue } from "../types";
7
- /**
8
- * Creates a Provider component for theme management.
9
- *
10
- * @param ThemeContext - Stoop's theme context for styled components
11
- * @param themes - Map of theme names to theme objects
12
- * @param defaultTheme - Default theme object
13
- * @param prefix - Optional prefix for CSS variable scoping
14
- * @returns Provider component and theme management context
15
- */
16
- export declare function createProvider(ThemeContext: Context<ThemeContextValue | null>, themes: Record<string, Theme>, defaultTheme: Theme, prefix?: string): {
17
- Provider: ComponentType<ProviderProps>;
18
- ThemeManagementContext: Context<ThemeManagementContextValue | null>;
19
- };
@@ -1,13 +0,0 @@
1
- /**
2
- * Theme management hook.
3
- * Provides access to theme state and theme switching functions.
4
- */
5
- import { type Context } from "react";
6
- import type { ThemeManagementContextValue } from "../types";
7
- /**
8
- * Creates a useTheme hook for a specific theme management context.
9
- *
10
- * @param ThemeManagementContext - React context for theme management
11
- * @returns Hook function that returns theme management context value
12
- */
13
- export declare function createUseThemeHook(ThemeManagementContext: Context<ThemeManagementContextValue | null>): () => ThemeManagementContextValue;
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Main entry point for Stoop CSS-in-JS library.
3
- * Exports the createStoop factory function and essential public types.
4
- */
5
- export { createStoop } from "./create-stoop";
6
- export type { CSS, StoopConfig, StoopInstance, StyledComponentProps, Theme, UtilityFunction, Variants, } from "./types";
package/dist/index.js DELETED
@@ -1,13 +0,0 @@
1
- import{createContext as C4}from"react";import{createContext as W4}from"react";var YJ=Object.freeze({}),PJ=1e4,XJ=5000,GJ=10,NJ=W4(null),QJ=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","letterSpacings","shadows","zIndices","transitions"],a={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",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"},t=Symbol.for("stoop.component");function BJ(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");let $=J,Z=[];for(let X in $){if(X==="media")continue;if(!QJ.includes(X))Z.push(X)}if(Z.length>0){let X=`[Stoop] Theme contains invalid scales: ${Z.join(", ")}. Only these scales are allowed: ${QJ.join(", ")}`;if(typeof process!=="undefined"&&process.env?.NODE_ENV!=="production")throw new Error(X);console.warn(X)}return J}function C(J){return typeof J==="object"&&J!==null}function D4(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function wJ(J){return C(J)&&!D4(J)}function o(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function xJ(J){return function $(Z){let X=BJ(Z);function q(Y,Q){let G={...Y},W=Object.keys(Q);for(let B of W){let D=Q[B],H=Y[B];if(o(D)&&o(H))G[B]={...H,...D};else if(D!==void 0)G[B]=D}let F=Object.keys(Y);for(let B of F)if(!(B in G))G[B]=Y[B];return G}return q(J,X)}}var gJ=new Map;class UJ 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 Z=this.keys().next().value;if(Z!==void 0)super.delete(Z)}return super.set(J,$),this}}var p=new UJ(XJ),e=new UJ(XJ);function bJ(J){return gJ.has(J)}function vJ(J){gJ.set(J,J)}function TJ(){if(p.size>XJ){let J=p.keys().next().value;if(J)p.delete(J),e.delete(J)}}function FJ(J){let $=0;for(let Z=0;Z<J.length;Z++){let X=J.charCodeAt(Z);$=($<<5)-$+X,$=$&$}return Math.abs($).toString(36)}function WJ(J){try{return FJ(JSON.stringify(J))}catch{return FJ(String(J))}}function H4(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function h(J){return String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ")}function P(J){let $=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,"");if(!$.trim()||/^[>+~:.#[\]&@()\s]+$/.test($))return"";return $}function f(J){return J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid"}function kJ(J){return String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ").replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ")}function M(J){if(!J)return"";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||""}function CJ(J){if(!J)return"";return J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function DJ(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 fJ(J){if(!J||typeof J!=="string")return"";let $=J.trim().split(/\s+/),Z=[];for(let X of $){if(!X)continue;let Y=X.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(Y&&/^[a-zA-Z-_]/.test(Y))Z.push(Y)}return Z.join(" ")}function c(J){if(!J||typeof J!=="string")return"";return H4(J).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||""}function SJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let Z=parseFloat(J);return Z>=0&&Z<=100}return!1}function L4(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 dJ(J,$){if($&&J in $)return $[J];if(J in a)return a[J];return L4(J)}var yJ=new WeakMap;function w4(J){let $=yJ.get(J);if($)return $;let Z=new Map;function X(q,Y=[]){let Q=Object.keys(q).sort();for(let G of Q){let W=q[G],F=[...Y,G];if(o(W))X(W,F);else{let B=Z.get(G);if(B)B.push(F);else Z.set(G,[F])}}}X(J);for(let[q,Y]of Z.entries())if(Y.length>1){if(Y.sort((Q,G)=>{let W=Q.length-G.length;if(W!==0)return W;let F=Q.join("."),B=G.join(".");return F.localeCompare(B)}),typeof process!=="undefined"&&process.env?.NODE_ENV!=="production")console.warn(`[Stoop] Ambiguous token "$${q}" found in multiple categories: ${Y.map((Q)=>Q.join(".")).join(", ")}. Using "${Y[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${Y[0].join(".")}" to be explicit.`)}return yJ.set(J,Z),Z}function U4(J,$){let Z=Object.keys(J).filter((q)=>q!=="media"),X=Object.keys($).filter((q)=>q!=="media");if(Z.length!==X.length)return!1;for(let q of Z)if(!(q in $))return!1;return!0}function uJ(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!U4(J,$))return!1;let Z={...J},X={...$};return delete Z.media,delete X.media,JSON.stringify(Z)===JSON.stringify(X)}function RJ(J,$,Z){if(Z&&Z in J){let Y=J[Z];if(Y&&typeof Y==="object"&&!Array.isArray(Y)&&$ in Y)return[Z,$]}let q=w4(J).get($);if(!q||q.length===0)return null;return q[0]}function R4(J,$,Z,X){if(!J.startsWith("$"))return J;let q=J.slice(1);if(q.includes("$")||q.includes("."))return`var(${`--${(q.includes("$")?q.split("$"):q.split(".")).map((B)=>f(B)).join("-")}`})`;if($&&Z){let G=dJ(Z,X);if(G){let F=RJ($,q,G);if(F)return`var(${`--${F.map((H)=>f(H)).join("-")}`})`}let W=RJ($,q);if(W)return`var(${`--${W.map((D)=>f(D)).join("-")}`})`}else if($){let G=RJ($,q);if(G)return`var(${`--${G.map((B)=>f(B)).join("-")}`})`}return`var(${`--${f(q)}`})`}function n(J,$=""){let Z=CJ($),X=Z?`:root[data-stoop="${Z}"]`:":root",q=[];function Y(Q,G=[]){let W=Object.keys(Q).sort();for(let F of W){if(F==="media")continue;let B=Q[F],D=[...G,F];if(o(B))Y(B,D);else{let L=`--${D.map((R)=>f(R)).join("-")}`,O=typeof B==="string"||typeof B==="number"?kJ(B):String(B);q.push(` ${L}: ${O};`)}}}if(Y(J),q.length===0)return"";return`${X} {
2
- ${q.join(`
3
- `)}
4
- }`}function S(J,$,Z,X){if(!J||typeof J!=="object")return J;let q={};for(let Y in J){let Q=J[Y];if(C(Q))q[Y]=S(Q,$,Z,X);else if(typeof Q==="string"&&Q.includes("$")){let G=X||Y;q[Y]=Q.replace(/(calc\()?(-?)(\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g,(W,F,B,D,H,L)=>{let O=R4(D,$,G,Z),R=L.slice(Math.max(0,H-10),H),A=R.includes("calc(")&&!R.includes(")");if(B==="-"){if(A||F==="calc(")return`${F||""}-${O}`;return`calc(-1 * ${O})`}if(F==="calc(")return`${F}${O}`;return O})}else q[Y]=Q}return q}var AJ=new Map;function g(J){return AJ.has(J)}function N(J,$){AJ.set(J,$)}function HJ(){return new Map(AJ)}var m=[];function JJ(J){if(m.includes(J))return;if(m.length>=PJ)m.shift();m.push(J)}function IJ(){return m.join(`
5
- `)}function pJ(J){return m.includes(J)}var U=null,_J=new Map,cJ=new Map,A4=new Map,l=new Map,d=null;if(typeof document!=="undefined")(function J(){if(!U)U=document.createElement("style"),U.setAttribute("data-stoop","stoop"),document.head.appendChild(U)})();function nJ(){if(l.size===0||!U||!U.parentNode){d=null;return}let J=Array.from(l.values()).join(`
6
- `);if(!J){l.clear(),d=null;return}let{sheet:$}=U;if($&&$.insertRule&&!J.includes("@")&&!J.includes("&"))try{let X=J.split(/(?<=})\s*(?=\S)/),q=!0;for(let Y of X){let Q=Y.trim();if(Q)try{$.insertRule(Q,$.cssRules.length)}catch{q=!1;break}}if(q){l.clear(),d=null;return}}catch{}let Z=U.textContent||"";U.textContent=Z+(Z?`
7
- `:"")+J,l.clear(),d=null}function I4(J,$){if(l.set($,J),!d&&typeof requestAnimationFrame!=="undefined")d=requestAnimationFrame(nJ);else if(!d)nJ()}function KJ(J=""){if(typeof document==="undefined")throw new Error("Cannot access document in SSR context");let $=M(J);if(U){if(U.parentNode)return U;if(U.textContent)try{return document.head.appendChild(U),U}catch{}U=null}return U=document.createElement("style"),U.setAttribute("data-stoop",$||"stoop"),document.head.appendChild(U),U}function OJ(J,$,Z=""){if(!J)return;let X=M(Z),q=`__theme_vars_${X}`;if((cJ.get(q)??null)===J){if((_J.get(q)??null)!==$)_J.set(q,$);return}if(_J.set(q,$),cJ.set(q,J),typeof document==="undefined"){JJ(J);return}let Q=KJ(X),G=Q.textContent||"";if(g(q)){let W=X?`:root[data-stoop="${X}"]`:":root",F=new RegExp(`${W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\{[\\s\\S]*?\\}`,"g"),B=G.replace(F,"").trim();Q.textContent=J+(B?`
8
- `+B:""),N(q,J)}else Q.textContent=J+(G?`
9
- `+G:""),N(q,J)}function mJ(J,$=""){let Z=M($);if(A4.set(Z,J),typeof document!=="undefined"){KJ(Z);let X=n(J,Z);OJ(X,J,Z)}}function _4(J,$,Z=""){if(typeof document==="undefined")return;let X=M(Z);if(U&&U.parentNode){let q=U.textContent||"",Y=J.replace(/\s+/g," ").trim();if(q.replace(/\s+/g," ").trim().includes(Y)){if(!g($))N($,J);return}}try{let q=KJ(X),Y=q.textContent||"",Q=J.replace(/\s+/g," ").trim();if(Y.replace(/\s+/g," ").trim().includes(Q)){if(!g($))N($,J);return}if(!Y){let W=HJ();if(W.size>0){let F=Array.from(W.entries()).filter(([B])=>!B.startsWith("__theme_vars_")&&B!==$).map(([,B])=>B).join(`
10
- `);q.textContent=F+(F?`
11
- `:"")+J}else q.textContent=J}else I4(J,$);if(!g($))N($,J)}catch{if(!g($))N($,J)}if(!pJ(J))JJ(J)}function lJ(J,$,Z=""){if(g($))return;if(N($,J),bJ(J))return;vJ(J);let X=M(Z);if(U&&U.parentNode)try{let q=U.textContent||"",Y=J.replace(/\s+/g," ").trim();if(q.replace(/\s+/g," ").trim().includes(Y))return}catch{}_4(J,$,X)}function iJ(){return U}function T(J,$="",Z){let X=Z||J;if(typeof document==="undefined"){if(!g(X))N(X,J);JJ(J);return}lJ(J,X,$)}function rJ(J,$,Z=""){OJ(J,$,Z)}function sJ(J,$=""){mJ(J,$)}function aJ(){if(typeof document!=="undefined"){let J=iJ();if(J&&J.parentNode){let $=J.textContent||"";if(!$&&HJ().size>0)return IJ();return $}}return IJ()}function $J(J,$){if(!$||!J||typeof J!=="object")return J;let Z={},X=Object.keys($);for(let q in J){let Y=J[q];if(X.includes(q)&&$[q])try{let Q=$[q](Y);if(Q&&typeof Q==="object")Object.assign(Z,Q)}catch{Z[q]=Y}else if(C(Y))Z[q]=$J(Y,$);else Z[q]=Y}return Z}function O4(J,$){if(typeof J==="symbol"&&J===t)return!0;if(typeof $==="object"&&$!==null&&t in $)return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function E4(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 x(J,$="",Z=0,X){if(!J||typeof J!=="object")return"";if(Z>GJ)return"";let q="",Y="";for(let G in J){let W=J[G];if(O4(G,W)){let F=E4(G,W);if(!F)continue;let B=P(F);if(!B)continue;let D=`.${B}`,H=wJ(W)?x(W,D,Z+1,X):"";Y+=H;continue}if(wJ(W))if(X&&G in X){let F=DJ(X[G]);if(F){let B=x(W,$,Z+1,X);Y+=`${F} { ${B} }`}}else if(G.startsWith("@")){let F=P(G);if(F){let B=x(W,$,Z+1,X);Y+=`${F} { ${B} }`}}else if(G.includes("&")){let F=P(G);if(F){let B=F.replace(/&/g,$),D=x(W,B,Z+1,X);Y+=D}}else if(G.startsWith(":")){let F=P(G);if(F){let B=`${$}${F}`,D=x(W,B,Z+1,X);Y+=D}}else if(G.includes(" ")||G.includes(">")||G.includes("+")||G.includes("~")){let F=P(G);if(F){let B=`${$} ${F}`,D=x(W,B,Z+1,X);Y+=D}}else{let F=P(G);if(F){let B=$?`${$} ${F}`:F,D=x(W,B,Z+1,X);Y+=D}}else if(W!==void 0){let F=c(G);if(F&&(typeof W==="string"||typeof W==="number")){let B=h(W);q+=`${F}: ${B}; `}}}return(q?`${$} { ${q.trim()}}`:"")+Y}function y(J,$,Z="",X,q,Y){let Q=M(Z),G=$J(J,q),W=S(G,$,Y),F=x(W,"",0,X),B=FJ(F),D=`${Q}:${B}`,H=p.get(D);if(H){let R=e.get(D);if(R)return T(R,Q,D),H;let A=x(W,`.${H}`,0,X);return e.set(D,A),T(A,Q,D),H}let L=Q?`${Q}-${B}`:`css-${B}`,O=x(W,`.${L}`,0,X);return p.set(D,L),e.set(D,O),TJ(),T(O,Q,D),L}function tJ(J,$="",Z,X,q){return function Y(Q){return y(Q,J,$,Z,X,q)}}function eJ(J,$="",Z,X,q){let Y=new Set;return function Q(G){if(typeof document==="undefined")return()=>{};let W=WJ(G);if(Y.has(W))return()=>{};Y.add(W);function F(O,R=0){if(R>GJ)return"";let A="";return Object.entries(O).forEach(([z,_])=>{if(C(_))if(Z&&z in Z){let K=DJ(Z[z]);if(K){let w=F(_,R+1);A+=`${K} { ${w} }`}}else if(z.startsWith("@")){let K=P(z);if(K){let w=F(_,R+1);A+=`${K} { ${w} }`}}else{let K=P(z);if(K){let w=F(_,R+1);A+=`${K} { ${w} }`}}else if(_!==void 0){let K=c(z);if(K&&(typeof _==="string"||typeof _==="number")){let w=h(_);A+=`${K}: ${w}; `}}}),A}let B=M($),D=$J(G,X),H=S(D,J,q),L=F(H);return T(L,B,`__global_${W}`),()=>{Y.delete(W)}}}function M4(J,$,Z,X){let q=`@keyframes ${$} {`,Y=Object.keys(J).sort((Q,G)=>{let W=parseFloat(Q.replace("%","")),F=parseFloat(G.replace("%",""));if(Q==="from")return-1;if(G==="from")return 1;if(Q==="to")return 1;if(G==="to")return-1;return W-F});for(let Q of Y){if(!SJ(Q))continue;let G=J[Q];if(!G||typeof G!=="object")continue;q+=` ${Q} {`;let W=S(G,Z,X);for(let F in W){let B=W[F];if(B!==void 0&&(typeof B==="string"||typeof B==="number")){let D=c(F);if(D){let H=h(B);q+=` ${D}: ${H};`}}}q+=" }"}return q+=" }",q}function J4(J="",$,Z){let X=M(J),q=new Map;return function Y(Q){let G=WJ(Q),W=q.get(G);if(W)return W;let F=G.slice(0,8),B=X?`${X}-${F}`:`stoop-${F}`,D=M4(Q,B,$,Z),H=`__keyframes_${B}`;return T(D,X,H),q.set(G,B),B}}import{createContext as V4,useCallback as EJ,useLayoutEffect as q4,useMemo as MJ,useState as P4}from"react";var $4=new Map;function Z4(J,$=""){let Z=$||"";$4.set(Z,J)}function z4(J=""){let $=J||"";return $4.get($)||null}function j4(J,$=""){let Z=z4($);if(!Z)return J;if(uJ(J,Z))return J;let X={...Z},q=Object.keys(J);for(let Y of q){if(Y==="media")continue;let Q=J[Y],G=Z[Y];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&G&&typeof G==="object"&&!Array.isArray(G))X[Y]={...G,...Q};else if(Q!==void 0)X[Y]=Q}return X}function LJ(J,$=""){if(typeof document==="undefined")return;let Z=j4(J,$),X=n(Z,$);rJ(X,Z,$)}import{jsxDEV as Y4}from"react/jsx-dev-runtime";function X4(J,$,Z,X=""){let q=V4(null),Y=Object.keys($),Q=Y[0]||"default";function G({attribute:W="data-theme",children:F,defaultTheme:B,storageKey:D="stoop-theme"}){let H=EJ(()=>{if(typeof window==="undefined")return B||Q;try{let w=localStorage.getItem(D);if(w&&$[w])return w}catch{}return B||Q},[B,D]),[L,O]=P4(H),R=MJ(()=>{return $[L]||$[B||Q]||Z},[L,B]);q4(()=>{if(R)LJ(R,X)},[R]),q4(()=>{if(typeof document!=="undefined"&&W)document.documentElement.setAttribute(W,L)},[L,W]);let A=EJ((w)=>{if($[w]){O(w);try{localStorage.setItem(D,w)}catch{}}else if(typeof process!=="undefined"&&process.env?.NODE_ENV!=="production")console.warn(`[Stoop] Theme "${w}" not found. Available themes: ${Y.join(", ")}`)},[D]),z=MJ(()=>({theme:R,themeName:L}),[R,L]),_=EJ(()=>{let V=(Y.indexOf(L)+1)%Y.length,k=Y[V];A(k)},[L,A]),K=MJ(()=>({availableThemes:Y,setTheme:A,theme:R,themeName:L,toggleTheme:_}),[R,L,A,_]);return Y4(J.Provider,{value:z,children:Y4(q.Provider,{value:K,children:F},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return{Provider:G,ThemeManagementContext:q}}import{useMemo as zJ,forwardRef as N4,createElement as x4,useContext as g4}from"react";function G4(J,$,Z){let X=!1,q=[];for(let Y in J){let Q=$[Y];if(Q===void 0)continue;let G=J[Y],W=Q===!0?"true":Q===!1?"false":String(Q);if(G[W])q.push(G[W]),X=!0}return X?Object.assign({},Z,...q):Z}function b4(J){return{__isStoopStyled:!0,__stoopClassName:J,[t]:J,toString:()=>`__STOOP_COMPONENT_${J}`}}function v4(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&J.__isStoopStyled===!0}function T4(J,$){if(!$)return{elementProps:J,variantProps:{}};let Z=new Set(Object.keys($)),X={},q={};for(let Y in J)if(Z.has(Y))X[Y]=J[Y];else q[Y]=J[Y];return{elementProps:q,variantProps:X}}function Q4(J,$="",Z,X,q,Y){return function Q(G,W,F){let B=W||YJ,D=F;if(W&&"variants"in W&&typeof W.variants==="object"){D=W.variants;let{compoundVariants:A,variants:z,..._}=W;B=_}let H=y(B,J,$,Z,X,q),L;if(typeof G!=="string"&&v4(G))L=G.__stoopClassName;let R=N4(function A(z,_){let{as:K,className:w,css:V,...k}=z,I=K||G,E=V&&typeof V==="object"&&V!==null?V:YJ,{elementProps:b,variantProps:v}=T4(k,D),i=g4(Y||NJ)?.theme||J,qJ=i.media||Z,r=zJ(()=>{if(!D)return"";let j=Object.entries(v);if(j.length===0)return"";return j.sort(([u],[s])=>u.localeCompare(s)).map(([u,s])=>`${u}:${String(s)}`).join("|")},[D,...Object.values(v)]),jJ=zJ(()=>{let j=B;if(D&&r)j=G4(D,v,B);if(E!==YJ)j=Object.assign({},j,E);return j},[r,E]),F4=zJ(()=>{let j=[];if(L)j.push(L);let u=y(jJ,i,$,qJ,X,q);if(u)j.push(u);if(w){let s=typeof w==="string"?w:String(w),VJ=fJ(s);if(VJ)j.push(VJ)}return j.length>0?j.join(" "):void 0},[jJ,i,$,qJ,X,q,w,L]);return x4(I,{...b,className:F4,ref:_})});return R.selector=b4(H),R}}import{useContext as k4}from"react";function B4(J){return function $(){let Z=k4(J);if(!Z)throw new Error("useTheme must be used within a Provider");return Z}}function f4(J){let{media:$,prefix:Z="",theme:X,themeMap:q,utils:Y}=J,Q=M(Z),G=BJ(X),W=G.media||$,F={...a,...q},B=C4(null);Z4(G,Q),sJ(G,Q);let D=tJ(G,Q,W,Y,F),H=xJ(G),L=eJ(G,Q,W,Y,F),O=J4(Q,G,F),R=Q4(G,Q,W,Y,F,B),A=Object.freeze({...G});function z(I){for(let E of I)try{y(E,G,Q,W,Y,F)}catch{}}function _(I){let E;if(typeof I==="string")if(J.themes&&J.themes[I])E=J.themes[I];else{if(typeof process!=="undefined"&&process.env?.NODE_ENV!=="production")console.warn(`[Stoop] Theme "${I}" not found. Available themes: ${J.themes?Object.keys(J.themes).join(", "):"none"}`);return}else E=I;LJ(E,Q)}function K(I){let E=G;if(I)if(typeof I==="string"){if(J.themes&&J.themes[I])E=J.themes[I];else if(typeof process!=="undefined"&&process.env?.NODE_ENV!=="production")console.warn(`[Stoop] Theme "${I}" not found. Using default theme. Available: ${J.themes?Object.keys(J.themes).join(", "):"none"}`)}else E=I;let b="",v=n(E,Q);if(v)b+=v+`
12
- `;let ZJ=aJ(),i=Q?`:root[data-stoop="${Q}"]`:":root",qJ=new RegExp(`${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\{[^}]*\\}`,"g"),r=ZJ.replace(qJ,"").trim();if(r)b+=(b?`
13
- `:"")+r;return b}let w,V;if(J.themes){let I={};for(let[v,ZJ]of Object.entries(J.themes))I[v]=H(ZJ);let{Provider:E,ThemeManagementContext:b}=X4(B,I,G,Q);w=E,V=B4(b)}let k={config:{...J,prefix:Q},createTheme:H,css:D,getCssText:K,globalCss:L,keyframes:O,preloadTheme:_,styled:R,theme:A,warmCache:z};if(w)k.Provider=w;if(V)k.useTheme=V;return k}export{f4 as createStoop};
@@ -1,59 +0,0 @@
1
- /**
2
- * Browser-specific CSS injection.
3
- * Manages a single stylesheet element that gets updated with new CSS rules.
4
- * Handles theme variable injection, deduplication, and stylesheet lifecycle.
5
- */
6
- import type { Theme } from "../types";
7
- /**
8
- * Gets or creates the stylesheet element for CSS injection.
9
- *
10
- * @param prefix - Optional prefix for stylesheet identification
11
- * @returns HTMLStyleElement
12
- * @throws Error if called in SSR context
13
- */
14
- export declare function getStylesheet(prefix?: string): HTMLStyleElement;
15
- /**
16
- * Injects theme CSS variables into the stylesheet.
17
- * Automatically ensures stylesheet exists before injection.
18
- *
19
- * @param cssVars - CSS variables string
20
- * @param theme - Theme object
21
- * @param prefix - Optional prefix for CSS variables
22
- */
23
- export declare function injectThemeVariables(cssVars: string, theme: Theme, prefix?: string): void;
24
- /**
25
- * Registers a theme for injection (browser-specific).
26
- * Automatically ensures stylesheet exists and injects theme variables.
27
- * Note: This is typically called with the default theme from createStoop.
28
- * Additional themes should use updateThemeVariables which handles merging.
29
- *
30
- * @param theme - Theme object to register
31
- * @param prefix - Optional prefix for CSS variables
32
- */
33
- export declare function registerTheme(theme: Theme, prefix?: string): void;
34
- /**
35
- * Updates the stylesheet with new CSS rules.
36
- *
37
- * @param css - CSS string to inject
38
- * @param ruleKey - Unique key for deduplication
39
- * @param prefix - Optional prefix for CSS rules
40
- */
41
- export declare function updateStylesheet(css: string, ruleKey: string, prefix?: string): void;
42
- /**
43
- * Injects CSS into the browser stylesheet with deduplication.
44
- *
45
- * @param css - CSS string to inject
46
- * @param ruleKey - Unique key for deduplication
47
- * @param prefix - Optional prefix for CSS rules
48
- */
49
- export declare function injectBrowserCSS(css: string, ruleKey: string, prefix?: string): void;
50
- /**
51
- * Gets the current stylesheet element.
52
- *
53
- * @returns HTMLStyleElement or null if not created
54
- */
55
- export declare function getStylesheetElement(): HTMLStyleElement | null;
56
- /**
57
- * Clears the stylesheet and all pending updates.
58
- */
59
- export declare function clearStylesheet(): void;
@@ -1,29 +0,0 @@
1
- /**
2
- * CSS injection deduplication.
3
- * Tracks which CSS rules have been injected to prevent duplicates.
4
- * Used by both browser and SSR injection systems.
5
- */
6
- /**
7
- * Checks if a CSS rule has already been injected.
8
- *
9
- * @param key - Rule key to check
10
- * @returns True if rule is already injected
11
- */
12
- export declare function isInjectedRule(key: string): boolean;
13
- /**
14
- * Marks a CSS rule as injected.
15
- *
16
- * @param key - Rule key
17
- * @param css - CSS string
18
- */
19
- export declare function markRuleAsInjected(key: string, css: string): void;
20
- /**
21
- * Gets all injected rules as a new Map.
22
- *
23
- * @returns Map of all injected rules
24
- */
25
- export declare function getAllInjectedRules(): Map<string, string>;
26
- /**
27
- * Clears all injected rule tracking.
28
- */
29
- export declare function clearInjectedRules(): void;
@@ -1,41 +0,0 @@
1
- /**
2
- * CSS injection public API.
3
- * Composes browser, SSR, and deduplication modules into a unified interface.
4
- * Provides single stylesheet injection with automatic SSR support.
5
- */
6
- import type { Theme } from "../types";
7
- export { isInjectedRule } from "./dedup";
8
- /**
9
- * Injects CSS into the document with automatic SSR support.
10
- *
11
- * @param css - CSS string to inject
12
- * @param prefix - Optional prefix for CSS rules
13
- * @param ruleKey - Optional unique key for deduplication
14
- */
15
- export declare function injectCSS(css: string, prefix?: string, ruleKey?: string): void;
16
- /**
17
- * Injects theme CSS variables into the document.
18
- *
19
- * @param cssVars - CSS variables string
20
- * @param theme - Theme object
21
- * @param prefix - Optional prefix for CSS variables
22
- */
23
- export declare function injectThemeVariables(cssVars: string, theme: Theme, prefix?: string): void;
24
- /**
25
- * Registers a theme for injection.
26
- * Automatically ensures stylesheet exists and injects theme variables.
27
- *
28
- * @param theme - Theme object to register
29
- * @param prefix - Optional prefix for CSS variables
30
- */
31
- export declare function registerTheme(theme: Theme, prefix?: string): void;
32
- /**
33
- * Gets all injected CSS text (browser or SSR).
34
- *
35
- * @returns CSS text string
36
- */
37
- export declare function getCssText(): string;
38
- /**
39
- * Clears all injected CSS and caches.
40
- */
41
- export declare function clearStylesheet(): void;
@@ -1,28 +0,0 @@
1
- /**
2
- * SSR cache management for CSS injection.
3
- * Maintains a cache of CSS text for server-side rendering.
4
- * Implements FIFO eviction to prevent memory leaks.
5
- */
6
- /**
7
- * Adds CSS to the SSR cache with FIFO eviction.
8
- *
9
- * @param css - CSS string to cache
10
- */
11
- export declare function addToSSRCache(css: string): void;
12
- /**
13
- * Gets all cached CSS text for SSR.
14
- *
15
- * @returns Joined CSS text string
16
- */
17
- export declare function getSSRCacheText(): string;
18
- /**
19
- * Clears the SSR cache.
20
- */
21
- export declare function clearSSRCache(): void;
22
- /**
23
- * Checks if CSS is already in the SSR cache.
24
- *
25
- * @param css - CSS string to check
26
- * @returns True if CSS is cached
27
- */
28
- export declare function isInSSRCache(css: string): boolean;
@@ -1,25 +0,0 @@
1
- /**
2
- * ThemeMap utilities for property-aware token resolution.
3
- * Maps CSS properties to theme scales for deterministic token resolution.
4
- */
5
- import type { ThemeScale } from "../types";
6
- import { APPROVED_THEME_SCALES, DEFAULT_THEME_MAP } from "../constants";
7
- export { APPROVED_THEME_SCALES, DEFAULT_THEME_MAP };
8
- export type { ThemeScale };
9
- /**
10
- * Auto-detects theme scale from CSS property name using pattern matching.
11
- * Used as fallback when property is not in DEFAULT_THEME_MAP.
12
- *
13
- * @param property - CSS property name
14
- * @returns Theme scale name or undefined if no pattern matches
15
- */
16
- export declare function autoDetectScale(property: string): ThemeScale | undefined;
17
- /**
18
- * Gets the theme scale for a CSS property.
19
- * Checks user themeMap first, then default themeMap, then pattern matching.
20
- *
21
- * @param property - CSS property name
22
- * @param userThemeMap - Optional user-provided themeMap override
23
- * @returns Theme scale name or undefined if no mapping found
24
- */
25
- export declare function getScaleForProperty(property: string, userThemeMap?: Record<string, ThemeScale>): ThemeScale | undefined;
@@ -1,13 +0,0 @@
1
- /**
2
- * Theme validation utilities.
3
- * Ensures theme objects only contain approved scales.
4
- */
5
- import type { DefaultTheme } from "../types";
6
- /**
7
- * Validates that a theme object only contains approved scales.
8
- *
9
- * @param theme - Theme object to validate
10
- * @returns Validated theme as DefaultTheme
11
- * @throws Error if theme contains invalid scales (in development)
12
- */
13
- export declare function validateTheme(theme: unknown): DefaultTheme;
@@ -1,26 +0,0 @@
1
- /**
2
- * Type guard utilities.
3
- * Provides runtime type checking for CSS objects, themes, and styled component references.
4
- */
5
- import type { CSS, Theme } from "../types";
6
- /**
7
- * Type guard for CSS objects.
8
- *
9
- * @param value - Value to check
10
- * @returns True if value is a CSS object
11
- */
12
- export declare function isCSSObject(value: unknown): value is CSS;
13
- /**
14
- * Type guard for valid CSS objects (excludes styled component references).
15
- *
16
- * @param value - Value to check
17
- * @returns True if value is a valid CSS object
18
- */
19
- export declare function isValidCSSObject(value: unknown): value is CSS;
20
- /**
21
- * Type guard for theme objects.
22
- *
23
- * @param value - Value to check
24
- * @returns True if value is a theme object
25
- */
26
- export declare function isThemeObject(value: unknown): value is Theme;
@@ -1,14 +0,0 @@
1
- /**
2
- * Utility function application.
3
- * Applies utility functions (e.g., px, py) to transform shorthand properties into CSS.
4
- * Recursively processes nested CSS objects.
5
- */
6
- import type { CSS, UtilityFunction } from "../types";
7
- /**
8
- * Applies utility functions to transform shorthand properties into CSS.
9
- *
10
- * @param styles - CSS object to process
11
- * @param utils - Optional utility functions object
12
- * @returns CSS object with utilities applied
13
- */
14
- export declare function applyUtilities(styles: CSS, utils?: Record<string, UtilityFunction>): CSS;