stoop 0.0.20 → 0.2.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.
- package/LICENSE.md +21 -0
- package/README.md +144 -35
- package/dist/api/create-theme.d.ts +13 -0
- package/dist/api/css.d.ts +16 -0
- package/dist/api/global-css.d.ts +18 -0
- package/dist/api/keyframes.d.ts +16 -0
- package/dist/api/provider.d.ts +19 -0
- package/dist/api/styled.d.ts +41 -0
- package/dist/api/use-theme.d.ts +13 -0
- package/dist/constants.d.ts +21 -0
- package/dist/core/cache.d.ts +39 -0
- package/dist/core/compiler.d.ts +19 -0
- package/dist/core/theme-manager.d.ts +30 -0
- package/dist/core/variants.d.ts +15 -0
- package/dist/create-stoop.d.ts +12 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +13 -36
- package/dist/inject/browser.d.ts +59 -0
- package/dist/inject/dedup.d.ts +29 -0
- package/dist/inject/index.d.ts +41 -0
- package/dist/inject/ssr.d.ts +28 -0
- package/dist/types/index.d.ts +141 -0
- package/dist/types/react-polymorphic-types.d.ts +17 -0
- package/dist/utils/string.d.ts +102 -0
- package/dist/utils/theme-map.d.ts +25 -0
- package/dist/utils/theme-validation.d.ts +13 -0
- package/dist/utils/theme.d.ts +43 -0
- package/dist/utils/type-guards.d.ts +26 -0
- package/dist/utils/utilities.d.ts +14 -0
- package/package.json +66 -39
- package/dist/components/Button/Button.d.ts +0 -4
- package/dist/index.css +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme token resolution utilities.
|
|
3
|
+
* Converts theme tokens to CSS variables for runtime theme switching.
|
|
4
|
+
* Uses cached token index for efficient lookups and theme comparison.
|
|
5
|
+
*/
|
|
6
|
+
import type { CSS, Theme, ThemeScale } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Compares two themes for equality by structure and values.
|
|
9
|
+
* Excludes 'media' property from comparison since it's not a CSS variable scale.
|
|
10
|
+
*
|
|
11
|
+
* @param theme1 - First theme to compare
|
|
12
|
+
* @param theme2 - Second theme to compare
|
|
13
|
+
* @returns True if themes are equal, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function themesAreEqual(theme1: Theme | null, theme2: Theme | null): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a theme token string to a CSS variable reference.
|
|
18
|
+
*
|
|
19
|
+
* @param token - Token string (e.g., "$primary" or "$colors$primary")
|
|
20
|
+
* @param theme - Optional theme for token resolution
|
|
21
|
+
* @param property - Optional CSS property name for scale detection
|
|
22
|
+
* @param themeMap - Optional theme scale mappings
|
|
23
|
+
* @returns CSS variable reference string
|
|
24
|
+
*/
|
|
25
|
+
export declare function tokenToCSSVar(token: string, theme?: Theme, property?: string, themeMap?: Record<string, ThemeScale>): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generates CSS custom properties from a theme object.
|
|
28
|
+
*
|
|
29
|
+
* @param theme - Theme object to convert to CSS variables
|
|
30
|
+
* @param prefix - Optional prefix for CSS variable names
|
|
31
|
+
* @returns CSS string with :root selector and CSS variables
|
|
32
|
+
*/
|
|
33
|
+
export declare function generateCSSVariables(theme: Theme, prefix?: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Recursively replaces theme tokens with CSS variable references in a CSS object.
|
|
36
|
+
*
|
|
37
|
+
* @param obj - CSS object to process
|
|
38
|
+
* @param theme - Optional theme for token resolution
|
|
39
|
+
* @param themeMap - Optional theme scale mappings
|
|
40
|
+
* @param property - Optional CSS property name for scale detection
|
|
41
|
+
* @returns CSS object with tokens replaced by CSS variables
|
|
42
|
+
*/
|
|
43
|
+
export declare function replaceThemeTokensWithVars(obj: CSS, theme?: Theme, themeMap?: Record<string, ThemeScale>, property?: string): CSS;
|
|
@@ -0,0 +1,26 @@
|
|
|
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,62 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stoop",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.0
|
|
3
|
+
"description": "CSS-in-JS library with type inference, theme creation, and variants support.",
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": "Jackson Dolman <mail@dolmios.com>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"sideEffects": [
|
|
9
|
-
"**/*.css",
|
|
10
|
-
"./dist/index.js"
|
|
11
|
-
],
|
|
12
6
|
"main": "./dist/index.js",
|
|
13
|
-
"
|
|
14
|
-
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dolmios/stoop.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/dolmios/stoop/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/dolmios/stoop#readme",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"react-polymorphic-types": "^2.0.0"
|
|
17
|
+
},
|
|
18
|
+
"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"
|
|
29
|
+
},
|
|
15
30
|
"exports": {
|
|
16
31
|
".": {
|
|
17
32
|
"types": "./dist/index.d.ts",
|
|
18
33
|
"import": "./dist/index.js",
|
|
19
34
|
"require": "./dist/index.js"
|
|
20
|
-
}
|
|
21
|
-
"./styles": "./dist/index.css"
|
|
35
|
+
}
|
|
22
36
|
},
|
|
23
37
|
"files": [
|
|
24
38
|
"dist"
|
|
25
39
|
],
|
|
26
40
|
"keywords": [
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
41
|
+
"css variables",
|
|
42
|
+
"css-in-ts",
|
|
43
|
+
"css-in-ts alternative",
|
|
44
|
+
"css-in-js",
|
|
45
|
+
"css-in-js alternative",
|
|
46
|
+
"emotion",
|
|
47
|
+
"emotion alternative",
|
|
48
|
+
"lightweight",
|
|
49
|
+
"minimal",
|
|
50
|
+
"next.js",
|
|
30
51
|
"nextjs",
|
|
52
|
+
"performance",
|
|
53
|
+
"react",
|
|
54
|
+
"react styling",
|
|
55
|
+
"stitches",
|
|
56
|
+
"stitches alternative",
|
|
57
|
+
"stitches-alternative",
|
|
58
|
+
"styled-components",
|
|
59
|
+
"styled-components alternative",
|
|
60
|
+
"styling",
|
|
31
61
|
"theme",
|
|
32
|
-
"
|
|
62
|
+
"theme switching",
|
|
63
|
+
"type-safe",
|
|
64
|
+
"typescript",
|
|
65
|
+
"variants"
|
|
33
66
|
],
|
|
34
|
-
"
|
|
35
|
-
"@types/node": "^22.13.10",
|
|
36
|
-
"@types/react": "^19.0.11",
|
|
37
|
-
"@types/react-dom": "^19.0.4",
|
|
38
|
-
"bun-types": "^1.2.5",
|
|
39
|
-
"clsx": "^2.1.0",
|
|
40
|
-
"eslint": "^9.22.0",
|
|
41
|
-
"eslint-config-dolmios": "^2.0.6",
|
|
42
|
-
"prettier": "^3.5.3",
|
|
43
|
-
"react": "^19.0.0",
|
|
44
|
-
"react-dom": "^19.0.0",
|
|
45
|
-
"typescript": "^5.8.2"
|
|
46
|
-
},
|
|
67
|
+
"license": "MIT",
|
|
47
68
|
"peerDependencies": {
|
|
48
69
|
"react": ">=19.0.0",
|
|
49
70
|
"react-dom": ">=19.0.0"
|
|
50
71
|
},
|
|
72
|
+
"prettier": "eslint-config-dolmios/configs/prettier",
|
|
73
|
+
"sideEffects": false,
|
|
74
|
+
"type": "module",
|
|
51
75
|
"scripts": {
|
|
52
|
-
"build": "bun run build:clean && bun run build:types && bun run build:
|
|
76
|
+
"build": "bun run build:clean && bun run build:js && bun run build:types && bun run build:copy-declarations",
|
|
53
77
|
"build:clean": "rm -rf dist",
|
|
54
|
-
"build:
|
|
55
|
-
"build:
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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",
|
|
85
|
+
"test": "bun test",
|
|
86
|
+
"test:coverage": "bun test --coverage",
|
|
87
|
+
"test:watch": "bun test --watch"
|
|
88
|
+
}
|
|
89
|
+
}
|
package/dist/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
:root{--color-text:#000;--color-background:#fff;--color-border:#0000001a;--color-primary:#000;--color-muted:#666;--space-smallest:.25rem;--space-smaller:.5rem;--space-small:.75rem;--space-medium:1rem;--space-large:1.5rem;--space-larger:2rem;--space-largest:10rem;--radius-small:.25rem;--radius-large:.5rem;--radius-round:9999px;--shadow-default:0 0 0 1px #0000001a;--breakpoint-phone:800px;--breakpoint-tablet:1024px;--breakpoint-desktop:1440px}@media (prefers-color-scheme:dark){:root{--color-text:#fff;--color-background:#000;--color-border:#ffffff1a;--color-primary:#fff;--color-muted:#999}}*{box-sizing:border-box;margin:0;padding:0}html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-behavior:smooth;background-color:var(--color-background);color:var(--color-text);font-size:62.5%}body{margin:0;padding:0;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:1.6rem;line-height:1.5}.button_5RnP0A{background-color:var(--color-primary);color:var(--color-background);padding:var(--space-small)var(--space-medium);border-radius:var(--radius-small);cursor:pointer;border:none;transition:opacity .2s;font-size:1.6rem}.button_5RnP0A:hover{opacity:.9}.button_5RnP0A:active{opacity:.8}
|