@yummacss/nitro
Advanced tools
| import{coreUtils as e,createColors as t,defaultMediaQueries as n}from"@yummacss/core";function r(e){let t=new Set,n=[/class(?:Name)?=["']([^"']+)["']/g,/class(?:Name)?=\{["']([^"']+)["']\}/g,/class(?:Name)?=\{`([^`]+)`\}/g],r=[/`([^`]+)`/g,/"([^"]+)"/g,/'([^']+)'/g],i=[/cva\s*\(\s*["'`]([^"'`]+)["'`]/g,/:\s*["'`]([^"'`]+)["'`]/g],a=[/\bcn\s*\(\s*["'`]([^"'`]+)["'`]/g,/\bcn\s*\(\s*\{\s*["'`]([^"'`]+)["'`]\s*:/g],o=[/clsx\s*\(\s*["'`]([^"'`]+)["'`]/g,/classnames\s*\(\s*["'`]([^"'`]+)["'`]/g,/clsx\s*\(\s*\{\s*["'`]([^"'`]+)["'`]\s*:/g,/classnames\s*\(\s*\{\s*["'`]([^"'`]+)["'`]\s*:/g],s=[...n,...r,...i,...a,...o];for(let n of s){let r;for(r=n.exec(e);r!==null;){let i=r[1];i&&i.split(/\s+/).filter(e=>{let t=e.replace(/^@+/,``);return t&&/^[a-z]/.test(t)&&t.includes(`-`)}).forEach(e=>{t.add(e)}),r=n.exec(e)}}return Array.from(t)}const i=`*, :before, :after { | ||
| box-sizing: border-box; | ||
| border: 0 solid; | ||
| } | ||
| * { | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
| html { | ||
| font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica Neue, Noto Sans, Liberation Sans, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji; | ||
| } | ||
| body { | ||
| -webkit-font-smoothing: antialiased; | ||
| font-family: inherit; | ||
| line-height: 1.5; | ||
| } | ||
| canvas, img, picture, svg, video { | ||
| max-width: 100%; | ||
| display: block; | ||
| } | ||
| button, input, optgroup, select, textarea { | ||
| background-color: transparent; | ||
| padding: .5rem; | ||
| font-family: inherit; | ||
| } | ||
| button:not([class]), input:not([class]), optgroup:not([class]), select:not([class]), textarea:not([class]) { | ||
| border: 1px solid #bfc2c7; | ||
| } | ||
| :is(a, button, input, select, summary, textarea):focus { | ||
| outline: 2px solid transparent; | ||
| } | ||
| textarea:not([rows]) { | ||
| min-height: 10em; | ||
| } | ||
| button { | ||
| cursor: pointer; | ||
| } | ||
| button:disabled, input:disabled, select:disabled, textarea:disabled { | ||
| cursor: not-allowed; | ||
| opacity: .5; | ||
| } | ||
| h1, h2, h3, h4, h5, h6, p { | ||
| overflow-wrap: break-word; | ||
| } | ||
| h1, h2, h3, h4, h5, h6 { | ||
| text-wrap: balance; | ||
| font-size: 1rem; | ||
| font-weight: 600; | ||
| } | ||
| p { | ||
| text-wrap: pretty; | ||
| } | ||
| b, strong { | ||
| font-weight: 700; | ||
| } | ||
| small { | ||
| font-size: 80%; | ||
| line-height: 1.4; | ||
| } | ||
| pre, code, kbd, samp { | ||
| font-family: monospace; | ||
| font-size: 1em; | ||
| } | ||
| a { | ||
| color: inherit; | ||
| text-decoration: none; | ||
| } | ||
| ol, ul { | ||
| padding: 0; | ||
| list-style: none; | ||
| } | ||
| th { | ||
| font-size: 1rem; | ||
| font-weight: 600; | ||
| } | ||
| hr { | ||
| border-top: 1px solid #bfc2c7; | ||
| height: 0; | ||
| margin: 1em 0; | ||
| } | ||
| details { | ||
| display: block; | ||
| } | ||
| summary { | ||
| display: list-item; | ||
| } | ||
| `;function a(e,t){let n=[];if(t.safelist)for(let n of t.safelist){let r=t.prefix&&!n.startsWith(t.prefix)?t.prefix+n:n;e.add(r)}(t.normalize??!0)&&n.push(i);let r=c(e,t);return r&&n.push(r),n.join(` | ||
| `)}function o(r){let i={...e()},a=null;if(r.theme?.colors){let{percentage:e,...n}=r.theme.colors;a=t(n,e?.light,e?.dark)}let o=[...n];if(r.theme?.screens){let e=Object.entries(r.theme.screens).map(([e,t])=>({prefix:e,value:`@media (min-width: ${t})`}));for(let t of e){let e=o.findIndex(e=>e.prefix===t.prefix);e===-1?o.push(t):o[e]=t}}for(let[e,t]of Object.entries(i)){let n=!1,s={...t};a&&`black`in s.values&&`white`in s.values&&(s.values={...s.values,...a},n=!0),r.theme?.screens&&s.variants&&(s.variants={...s.variants,mediaQueries:o},n=!0),n&&(i[e]=s)}return i}function s(e,t){let n=o(t),r=new Set;for(let e of t.safelist??[])r.add(e),t.prefix&&!e.startsWith(t.prefix)&&r.add(t.prefix+e);let i=[],a=[];for(let o of e){if(r.has(o)){i.push(o);continue}let e=o;if(t.prefix){if(!e.startsWith(t.prefix)){a.push(o);continue}e=e.slice(t.prefix.length)}d(e,n,o)?i.push(o):a.push(o)}return{valid:i,invalid:a}}function c(e,t){let n=o(t),r=[],i=new Map,a=new Set,s=Array.from(e).sort();for(let e of s){let o=e;if(t.prefix&&o.startsWith(t.prefix))o=o.slice(t.prefix.length);else if(t.prefix)continue;if(a.has(e))continue;let s=d(o,n,e);if(s){if(s.mediaQuery){let e=i.get(s.mediaQuery)||[];e.push(s.rule),i.set(s.mediaQuery,e)}else r.push(s.rule);a.add(e)}}let c=Array.from(i.entries()).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of c){let n=t.map(e=>e.replace(/^/gm,` `)).join(` | ||
| `);r.push(`${e} {\n${n}\n}`)}return r.join(` | ||
| `)}function l(e,t,n){let{properties:r,variants:i,prefix:a,values:o}=t,s=e,c,l=``,d=``,f=``,p=!0;for(;p;){if(p=!1,i?.mediaQueries){for(let e of i.mediaQueries)if(s.startsWith(`@${e.prefix}:`)){c=e.value,s=s.slice(e.prefix.length+2),p=!0;break}}if(!p){if(i?.pseudoElements){for(let e of i.pseudoElements)if(s.startsWith(`${e.prefix}::`)){d+=e.value,s=s.slice(e.prefix.length+2),p=!0;break}}if(!p&&i?.pseudoClasses){for(let e of i.pseudoClasses)if(s.startsWith(`${e.prefix}:`)&&!s.startsWith(`${e.prefix}::`)){l+=e.value,s=s.slice(e.prefix.length+1),p=!0;break}}}}if(i?.opacity){for(let e of i.opacity)if(s.endsWith(`/${e.prefix}`)){f=e.value,s=s.slice(0,-(e.prefix.length+1));break}}if(!s.startsWith(`${a}-`)&&s!==a)return null;let m=s===a?``:s.slice(a.length+1),h=!1,g=m;m.startsWith(`-`)&&(h=!0,g=m.slice(1));let _=o[g===``?`base`:g]||o[g];if(!_)return null;let v=_;h&&/^-?[\d.]/.test(_)&&(v=_.startsWith(`-`)?_.slice(1):`-${_}`);let y=f&&v.startsWith(`#`)&&v.length===7?`${v}${f}`:v,b=r.map(e=>`${e}: ${y};`).join(` | ||
| `);return{rule:`.${u(n)}${l}${d} {\n ${b}\n}`,mediaQuery:c}}function u(e){return e.replace(/:/g,`\\:`).replace(/\//g,`\\/`).replace(/@/g,`\\@`).replace(/%/g,`\\%`)}function d(e,t,n){for(let[r,i]of Object.entries(t)){let t=l(e,i,n);if(t)return t}return null}export{r as i,s as n,i as r,a as t}; |
| import { z } from "zod"; | ||
| //#region src/config/schema.d.ts | ||
| declare const configName = "yumma.config.mjs"; | ||
| /** | ||
| * Configure Yumma CSS. | ||
| */ | ||
| interface Config { | ||
| /** | ||
| * Files to scan for Yumma CSS classes. | ||
| * | ||
| * @example ["./src/**\/*.{ts,tsx}"] | ||
| * @default [""] | ||
| */ | ||
| source?: string[]; | ||
| /** | ||
| * Path to output the generated CSS file. | ||
| * | ||
| * @example "./dist/output.css" | ||
| * @default "" | ||
| */ | ||
| output?: string; | ||
| /** | ||
| * Prefix to namespace all generated classes. | ||
| * | ||
| * @example "ui-" | ||
| */ | ||
| prefix?: string; | ||
| /** | ||
| * Reset default browser styles. Provide false to skip generating base resets. | ||
| * | ||
| * @default true | ||
| */ | ||
| normalize?: boolean; | ||
| /** | ||
| * Classes that are always generated, regardless of whether they exist in source files. | ||
| * | ||
| * @example ["bg-red-5", "c-white"] | ||
| */ | ||
| safelist?: string[]; | ||
| /** | ||
| * Customize the default design system. | ||
| */ | ||
| theme?: { | ||
| /** | ||
| * Add custom colors to the palette. | ||
| * Provide base colors and Yumma CSS generates the full shade scale automatically. | ||
| * | ||
| * @example { purple: "#9333EA" } | ||
| */ | ||
| colors?: Record<string, string> & { | ||
| /** | ||
| * Control shade generation aggressiveness. | ||
| */ | ||
| percentage?: { | ||
| /** | ||
| * Adjust the percentage of white mixed into lighter shades per step. | ||
| * @default 14 | ||
| */ | ||
| light?: number; | ||
| /** | ||
| * Adjust the percentage of black mixed into darker shades per step. | ||
| * @default 14 | ||
| */ | ||
| dark?: number; | ||
| }; | ||
| }; | ||
| /** | ||
| * Override or extend the default breakpoints. | ||
| * | ||
| * @example { sm: "40rem", md: "48rem", lg: "64rem", xl: "80rem", xxl: "96rem" } | ||
| */ | ||
| screens?: Record<string, string>; | ||
| }; | ||
| } | ||
| declare const ConfigSchema: z.ZodObject<{ | ||
| source: z.ZodDefault<z.ZodArray<z.ZodString>>; | ||
| output: z.ZodDefault<z.ZodString>; | ||
| prefix: z.ZodOptional<z.ZodString>; | ||
| normalize: z.ZodDefault<z.ZodBoolean>; | ||
| safelist: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| theme: z.ZodOptional<z.ZodObject<{ | ||
| colors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; | ||
| screens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>; | ||
| /** | ||
| * Define your Yumma CSS configuration. | ||
| * | ||
| * @param config - The configuration options to customize Yumma CSS. | ||
| * @returns The resolved configuration object. | ||
| */ | ||
| declare function defineConfig(config: Config): Config; | ||
| //#endregion | ||
| //#region src/generator.d.ts | ||
| declare function generator(usedClasses: Set<string>, config: Config): string; | ||
| interface ValidationResult { | ||
| valid: string[]; | ||
| invalid: string[]; | ||
| } | ||
| /** | ||
| * Check class names against the same matching rules the generator uses, | ||
| * so a class is valid exactly when it produces CSS. Safelist entries | ||
| * always count as valid. | ||
| */ | ||
| declare function validateClasses(classNames: Iterable<string>, config: Config): ValidationResult; | ||
| //#endregion | ||
| //#region src/normalize.d.ts | ||
| declare const normalizeCSS = "*, :before, :after {\n box-sizing: border-box;\n border: 0 solid;\n}\n\n* {\n margin: 0;\n padding: 0;\n}\n\nhtml {\n font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica Neue, Noto Sans, Liberation Sans, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n\nbody {\n -webkit-font-smoothing: antialiased;\n font-family: inherit;\n line-height: 1.5;\n}\n\ncanvas, img, picture, svg, video {\n max-width: 100%;\n display: block;\n}\n\nbutton, input, optgroup, select, textarea {\n background-color: transparent;\n padding: .5rem;\n font-family: inherit;\n}\n\nbutton:not([class]), input:not([class]), optgroup:not([class]), select:not([class]), textarea:not([class]) {\n border: 1px solid #bfc2c7;\n}\n\n:is(a, button, input, select, summary, textarea):focus {\n outline: 2px solid transparent;\n}\n\ntextarea:not([rows]) {\n min-height: 10em;\n}\n\nbutton {\n cursor: pointer;\n}\n\nbutton:disabled, input:disabled, select:disabled, textarea:disabled {\n cursor: not-allowed;\n opacity: .5;\n}\n\nh1, h2, h3, h4, h5, h6, p {\n overflow-wrap: break-word;\n}\n\nh1, h2, h3, h4, h5, h6 {\n text-wrap: balance;\n font-size: 1rem;\n font-weight: 600;\n}\n\np {\n text-wrap: pretty;\n}\n\nb, strong {\n font-weight: 700;\n}\n\nsmall {\n font-size: 80%;\n line-height: 1.4;\n}\n\npre, code, kbd, samp {\n font-family: monospace;\n font-size: 1em;\n}\n\na {\n color: inherit;\n text-decoration: none;\n}\n\nol, ul {\n padding: 0;\n list-style: none;\n}\n\nth {\n font-size: 1rem;\n font-weight: 600;\n}\n\nhr {\n border-top: 1px solid #bfc2c7;\n height: 0;\n margin: 1em 0;\n}\n\ndetails {\n display: block;\n}\n\nsummary {\n display: list-item;\n}\n"; | ||
| //#endregion | ||
| export { Config as a, defineConfig as c, validateClasses as i, ValidationResult as n, ConfigSchema as o, generator as r, configName as s, normalizeCSS as t }; |
@@ -1,2 +0,2 @@ | ||
| import { n as generator, t as normalizeCSS } from "./normalize-Duay5QRP.mjs"; | ||
| import { r as generator, t as normalizeCSS } from "./normalize--Zn97zQz.mjs"; | ||
@@ -3,0 +3,0 @@ //#region src/tokenizer.d.ts |
+1
-1
@@ -1,1 +0,1 @@ | ||
| import{n as e,r as t,t as n}from"./generator-G2592ZuP.mjs";export{n as generator,e as normalizeCSS,t as tokenizer}; | ||
| import{i as e,r as t,t as n}from"./generator-xYIili8Z.mjs";export{n as generator,t as normalizeCSS,e as tokenizer}; |
+2
-2
@@ -1,2 +0,2 @@ | ||
| import { a as configName, i as ConfigSchema, n as generator, o as defineConfig, r as Config, t as normalizeCSS } from "./normalize-Duay5QRP.mjs"; | ||
| import { a as Config, c as defineConfig, i as validateClasses, n as ValidationResult, o as ConfigSchema, r as generator, s as configName, t as normalizeCSS } from "./normalize--Zn97zQz.mjs"; | ||
@@ -54,2 +54,2 @@ //#region src/config/load.d.ts | ||
| //#endregion | ||
| export { type Config, ConfigSchema, type LoadConfigOptions, type LoadedConfig, type ScanOptions, type ScanResult, configName, defineConfig, extractor, generator, loadConfig, normalizeCSS, scan }; | ||
| export { type Config, ConfigSchema, type LoadConfigOptions, type LoadedConfig, type ScanOptions, type ScanResult, type ValidationResult, configName, defineConfig, extractor, generator, loadConfig, normalizeCSS, scan, validateClasses }; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| import{n as e,r as t,t as n}from"./generator-G2592ZuP.mjs";import{readFileSync as r,statSync as i}from"node:fs";import{isAbsolute as a,join as o,resolve as s}from"node:path";import{pathToFileURL as c}from"node:url";import{z as l}from"zod";import{glob as u}from"tinyglobby";const d=`yumma.config.mjs`,f=l.object({source:l.array(l.string()).default([``]),output:l.string().default(``),prefix:l.string().optional(),normalize:l.boolean().default(!0),safelist:l.array(l.string()).optional(),theme:l.object({colors:l.record(l.string(),l.any()).optional(),screens:l.record(l.string(),l.string()).optional()}).optional()});function p(e){return e}async function m(e={}){if(e.config)return{config:f.parse(e.config),path:null};let t=e.cwd??process.cwd(),n=e.path?a(e.path)?e.path:o(t,e.path):o(t,d),r=i(n).mtimeMs,{default:s}=await import(`${c(n).href}?t=${r}`);return{config:f.parse(s),path:n}}async function h(e,n={}){let i=(await u(e,{cwd:n.cwd,absolute:!0})).map(e=>s(e)),a=new Set;for(let e of i)try{t(r(e,`utf-8`)).forEach(e=>{a.add(e)})}catch{}return{classes:a,files:i}}async function g(e){let{classes:t}=await h(e);return t}export{f as ConfigSchema,d as configName,p as defineConfig,g as extractor,n as generator,m as loadConfig,e as normalizeCSS,h as scan}; | ||
| import{i as e,n as t,r as n,t as r}from"./generator-xYIili8Z.mjs";import{readFileSync as i,statSync as a}from"node:fs";import{isAbsolute as o,join as s,resolve as c}from"node:path";import{pathToFileURL as l}from"node:url";import{z as u}from"zod";import{glob as d}from"tinyglobby";const f=`yumma.config.mjs`,p=u.object({source:u.array(u.string()).default([``]),output:u.string().default(``),prefix:u.string().optional(),normalize:u.boolean().default(!0),safelist:u.array(u.string()).optional(),theme:u.object({colors:u.record(u.string(),u.any()).optional(),screens:u.record(u.string(),u.string()).optional()}).optional()});function m(e){return e}async function h(e={}){if(e.config)return{config:p.parse(e.config),path:null};let t=e.cwd??process.cwd(),n=e.path?o(e.path)?e.path:s(t,e.path):s(t,f),r=a(n).mtimeMs,{default:i}=await import(`${l(n).href}?t=${r}`);return{config:p.parse(i),path:n}}async function g(t,n={}){let r=(await d(t,{cwd:n.cwd,absolute:!0})).map(e=>c(e)),a=new Set;for(let t of r)try{e(i(t,`utf-8`)).forEach(e=>{a.add(e)})}catch{}return{classes:a,files:r}}async function _(e){let{classes:t}=await g(e);return t}export{p as ConfigSchema,f as configName,m as defineConfig,_ as extractor,r as generator,h as loadConfig,n as normalizeCSS,g as scan,t as validateClasses}; |
+2
-2
| { | ||
| "name": "@yummacss/nitro", | ||
| "version": "3.26.0", | ||
| "version": "3.27.0", | ||
| "description": "Fast CSS generation for Yumma CSS", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
| "zod": "^4.3.4", | ||
| "@yummacss/core": "3.26.0" | ||
| "@yummacss/core": "3.27.0" | ||
| }, | ||
@@ -40,0 +40,0 @@ "publishConfig": { |
| import{coreUtils as e,createColors as t,defaultMediaQueries as n}from"@yummacss/core";function r(e){let t=new Set,n=[/class(?:Name)?=["']([^"']+)["']/g,/class(?:Name)?=\{["']([^"']+)["']\}/g,/class(?:Name)?=\{`([^`]+)`\}/g],r=[/`([^`]+)`/g,/"([^"]+)"/g,/'([^']+)'/g],i=[/cva\s*\(\s*["'`]([^"'`]+)["'`]/g,/:\s*["'`]([^"'`]+)["'`]/g],a=[/\bcn\s*\(\s*["'`]([^"'`]+)["'`]/g,/\bcn\s*\(\s*\{\s*["'`]([^"'`]+)["'`]\s*:/g],o=[/clsx\s*\(\s*["'`]([^"'`]+)["'`]/g,/classnames\s*\(\s*["'`]([^"'`]+)["'`]/g,/clsx\s*\(\s*\{\s*["'`]([^"'`]+)["'`]\s*:/g,/classnames\s*\(\s*\{\s*["'`]([^"'`]+)["'`]\s*:/g],s=[...n,...r,...i,...a,...o];for(let n of s){let r;for(r=n.exec(e);r!==null;){let i=r[1];i&&i.split(/\s+/).filter(e=>{let t=e.replace(/^@+/,``);return t&&/^[a-z]/.test(t)&&t.includes(`-`)}).forEach(e=>{t.add(e)}),r=n.exec(e)}}return Array.from(t)}const i=`*, :before, :after { | ||
| box-sizing: border-box; | ||
| border: 0 solid; | ||
| } | ||
| * { | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
| html { | ||
| font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica Neue, Noto Sans, Liberation Sans, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji; | ||
| } | ||
| body { | ||
| -webkit-font-smoothing: antialiased; | ||
| font-family: inherit; | ||
| line-height: 1.5; | ||
| } | ||
| canvas, img, picture, svg, video { | ||
| max-width: 100%; | ||
| display: block; | ||
| } | ||
| button, input, optgroup, select, textarea { | ||
| background-color: transparent; | ||
| padding: .5rem; | ||
| font-family: inherit; | ||
| } | ||
| button:not([class]), input:not([class]), optgroup:not([class]), select:not([class]), textarea:not([class]) { | ||
| border: 1px solid #bfc2c7; | ||
| } | ||
| :is(a, button, input, select, summary, textarea):focus { | ||
| outline: 2px solid transparent; | ||
| } | ||
| textarea:not([rows]) { | ||
| min-height: 10em; | ||
| } | ||
| button { | ||
| cursor: pointer; | ||
| } | ||
| button:disabled, input:disabled, select:disabled, textarea:disabled { | ||
| cursor: not-allowed; | ||
| opacity: .5; | ||
| } | ||
| h1, h2, h3, h4, h5, h6, p { | ||
| overflow-wrap: break-word; | ||
| } | ||
| h1, h2, h3, h4, h5, h6 { | ||
| text-wrap: balance; | ||
| font-size: 1rem; | ||
| font-weight: 600; | ||
| } | ||
| p { | ||
| text-wrap: pretty; | ||
| } | ||
| b, strong { | ||
| font-weight: 700; | ||
| } | ||
| small { | ||
| font-size: 80%; | ||
| line-height: 1.4; | ||
| } | ||
| pre, code, kbd, samp { | ||
| font-family: monospace; | ||
| font-size: 1em; | ||
| } | ||
| a { | ||
| color: inherit; | ||
| text-decoration: none; | ||
| } | ||
| ol, ul { | ||
| padding: 0; | ||
| list-style: none; | ||
| } | ||
| th { | ||
| font-size: 1rem; | ||
| font-weight: 600; | ||
| } | ||
| hr { | ||
| border-top: 1px solid #bfc2c7; | ||
| height: 0; | ||
| margin: 1em 0; | ||
| } | ||
| details { | ||
| display: block; | ||
| } | ||
| summary { | ||
| display: list-item; | ||
| } | ||
| `;function a(e,t){let n=[];if(t.safelist)for(let n of t.safelist){let r=t.prefix&&!n.startsWith(t.prefix)?t.prefix+n:n;e.add(r)}(t.normalize??!0)&&n.push(i);let r=o(e,t);return r&&n.push(r),n.join(` | ||
| `)}function o(r,i){let a={...e()},o=null;if(i.theme?.colors){let{percentage:e,...n}=i.theme.colors;o=t(n,e?.light,e?.dark)}let s=[...n];if(i.theme?.screens){let e=Object.entries(i.theme.screens).map(([e,t])=>({prefix:e,value:`@media (min-width: ${t})`}));for(let t of e){let e=s.findIndex(e=>e.prefix===t.prefix);e===-1?s.push(t):s[e]=t}}for(let[e,t]of Object.entries(a)){let n=!1,r={...t};o&&`black`in r.values&&`white`in r.values&&(r.values={...r.values,...o},n=!0),i.theme?.screens&&r.variants&&(r.variants={...r.variants,mediaQueries:s},n=!0),n&&(a[e]=r)}let c=[],u=new Map,d=new Set,f=Array.from(r).sort();for(let e of f){let t=e;if(i.prefix&&t.startsWith(i.prefix))t=t.slice(i.prefix.length);else if(i.prefix)continue;if(d.has(e))continue;let n=l(t,a,e);if(n){if(n.mediaQuery){let e=u.get(n.mediaQuery)||[];e.push(n.rule),u.set(n.mediaQuery,e)}else c.push(n.rule);d.add(e)}}let p=Array.from(u.entries()).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of p){let n=t.map(e=>e.replace(/^/gm,` `)).join(` | ||
| `);c.push(`${e} {\n${n}\n}`)}return c.join(` | ||
| `)}function s(e,t,n){let{properties:r,variants:i,prefix:a,values:o}=t,s=e,l,u=``,d=``,f=``,p=!0;for(;p;){if(p=!1,i?.mediaQueries){for(let e of i.mediaQueries)if(s.startsWith(`@${e.prefix}:`)){l=e.value,s=s.slice(e.prefix.length+2),p=!0;break}}if(!p){if(i?.pseudoElements){for(let e of i.pseudoElements)if(s.startsWith(`${e.prefix}::`)){d+=e.value,s=s.slice(e.prefix.length+2),p=!0;break}}if(!p&&i?.pseudoClasses){for(let e of i.pseudoClasses)if(s.startsWith(`${e.prefix}:`)&&!s.startsWith(`${e.prefix}::`)){u+=e.value,s=s.slice(e.prefix.length+1),p=!0;break}}}}if(i?.opacity){for(let e of i.opacity)if(s.endsWith(`/${e.prefix}`)){f=e.value,s=s.slice(0,-(e.prefix.length+1));break}}if(!s.startsWith(`${a}-`)&&s!==a)return null;let m=s===a?``:s.slice(a.length+1),h=!1,g=m;m.startsWith(`-`)&&(h=!0,g=m.slice(1));let _=o[g===``?`base`:g]||o[g];if(!_)return null;let v=_;h&&/^-?[\d.]/.test(_)&&(v=_.startsWith(`-`)?_.slice(1):`-${_}`);let y=f&&v.startsWith(`#`)&&v.length===7?`${v}${f}`:v,b=r.map(e=>`${e}: ${y};`).join(` | ||
| `);return{rule:`.${c(n)}${u}${d} {\n ${b}\n}`,mediaQuery:l}}function c(e){return e.replace(/:/g,`\\:`).replace(/\//g,`\\/`).replace(/@/g,`\\@`).replace(/%/g,`\\%`)}function l(e,t,n){for(let[r,i]of Object.entries(t)){let t=s(e,i,n);if(t)return t}return null}export{i as n,r,a as t}; |
| import { z } from "zod"; | ||
| //#region src/config/schema.d.ts | ||
| declare const configName = "yumma.config.mjs"; | ||
| /** | ||
| * Configure Yumma CSS. | ||
| */ | ||
| interface Config { | ||
| /** | ||
| * Files to scan for Yumma CSS classes. | ||
| * | ||
| * @example ["./src/**\/*.{ts,tsx}"] | ||
| * @default [""] | ||
| */ | ||
| source?: string[]; | ||
| /** | ||
| * Path to output the generated CSS file. | ||
| * | ||
| * @example "./dist/output.css" | ||
| * @default "" | ||
| */ | ||
| output?: string; | ||
| /** | ||
| * Prefix to namespace all generated classes. | ||
| * | ||
| * @example "ui-" | ||
| */ | ||
| prefix?: string; | ||
| /** | ||
| * Reset default browser styles. Provide false to skip generating base resets. | ||
| * | ||
| * @default true | ||
| */ | ||
| normalize?: boolean; | ||
| /** | ||
| * Classes that are always generated, regardless of whether they exist in source files. | ||
| * | ||
| * @example ["bg-red-5", "c-white"] | ||
| */ | ||
| safelist?: string[]; | ||
| /** | ||
| * Customize the default design system. | ||
| */ | ||
| theme?: { | ||
| /** | ||
| * Add custom colors to the palette. | ||
| * Provide base colors and Yumma CSS generates the full shade scale automatically. | ||
| * | ||
| * @example { purple: "#9333EA" } | ||
| */ | ||
| colors?: Record<string, string> & { | ||
| /** | ||
| * Control shade generation aggressiveness. | ||
| */ | ||
| percentage?: { | ||
| /** | ||
| * Adjust the percentage of white mixed into lighter shades per step. | ||
| * @default 14 | ||
| */ | ||
| light?: number; | ||
| /** | ||
| * Adjust the percentage of black mixed into darker shades per step. | ||
| * @default 14 | ||
| */ | ||
| dark?: number; | ||
| }; | ||
| }; | ||
| /** | ||
| * Override or extend the default breakpoints. | ||
| * | ||
| * @example { sm: "40rem", md: "48rem", lg: "64rem", xl: "80rem", xxl: "96rem" } | ||
| */ | ||
| screens?: Record<string, string>; | ||
| }; | ||
| } | ||
| declare const ConfigSchema: z.ZodObject<{ | ||
| source: z.ZodDefault<z.ZodArray<z.ZodString>>; | ||
| output: z.ZodDefault<z.ZodString>; | ||
| prefix: z.ZodOptional<z.ZodString>; | ||
| normalize: z.ZodDefault<z.ZodBoolean>; | ||
| safelist: z.ZodOptional<z.ZodArray<z.ZodString>>; | ||
| theme: z.ZodOptional<z.ZodObject<{ | ||
| colors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; | ||
| screens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>; | ||
| /** | ||
| * Define your Yumma CSS configuration. | ||
| * | ||
| * @param config - The configuration options to customize Yumma CSS. | ||
| * @returns The resolved configuration object. | ||
| */ | ||
| declare function defineConfig(config: Config): Config; | ||
| //#endregion | ||
| //#region src/generator.d.ts | ||
| declare function generator(usedClasses: Set<string>, config: Config): string; | ||
| //#endregion | ||
| //#region src/normalize.d.ts | ||
| declare const normalizeCSS = "*, :before, :after {\n box-sizing: border-box;\n border: 0 solid;\n}\n\n* {\n margin: 0;\n padding: 0;\n}\n\nhtml {\n font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica Neue, Noto Sans, Liberation Sans, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n\nbody {\n -webkit-font-smoothing: antialiased;\n font-family: inherit;\n line-height: 1.5;\n}\n\ncanvas, img, picture, svg, video {\n max-width: 100%;\n display: block;\n}\n\nbutton, input, optgroup, select, textarea {\n background-color: transparent;\n padding: .5rem;\n font-family: inherit;\n}\n\nbutton:not([class]), input:not([class]), optgroup:not([class]), select:not([class]), textarea:not([class]) {\n border: 1px solid #bfc2c7;\n}\n\n:is(a, button, input, select, summary, textarea):focus {\n outline: 2px solid transparent;\n}\n\ntextarea:not([rows]) {\n min-height: 10em;\n}\n\nbutton {\n cursor: pointer;\n}\n\nbutton:disabled, input:disabled, select:disabled, textarea:disabled {\n cursor: not-allowed;\n opacity: .5;\n}\n\nh1, h2, h3, h4, h5, h6, p {\n overflow-wrap: break-word;\n}\n\nh1, h2, h3, h4, h5, h6 {\n text-wrap: balance;\n font-size: 1rem;\n font-weight: 600;\n}\n\np {\n text-wrap: pretty;\n}\n\nb, strong {\n font-weight: 700;\n}\n\nsmall {\n font-size: 80%;\n line-height: 1.4;\n}\n\npre, code, kbd, samp {\n font-family: monospace;\n font-size: 1em;\n}\n\na {\n color: inherit;\n text-decoration: none;\n}\n\nol, ul {\n padding: 0;\n list-style: none;\n}\n\nth {\n font-size: 1rem;\n font-weight: 600;\n}\n\nhr {\n border-top: 1px solid #bfc2c7;\n height: 0;\n margin: 1em 0;\n}\n\ndetails {\n display: block;\n}\n\nsummary {\n display: list-item;\n}\n"; | ||
| //#endregion | ||
| export { configName as a, ConfigSchema as i, generator as n, defineConfig as o, Config as r, normalizeCSS as t }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
16076
5.83%101
2.02%1
Infinity%+ Added
- Removed
Updated