@terrazzo/plugin-css 2.0.0-alpha.5 → 2.0.0-alpha.7
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/CHANGELOG.md +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
- [#568](https://github.com/terrazzoapp/terrazzo/pull/568) [`67c75be`](https://github.com/terrazzoapp/terrazzo/commit/67c75be78978cece52b61cf258ccc3a875e6af48) Thanks [@drwpow](https://github.com/drwpow)! - Fix border tokens not cascading correctly across modes
|
|
22
22
|
|
|
23
|
+
- [#606](https://github.com/terrazzoapp/terrazzo/pull/606) [`1fc1d99`](https://github.com/terrazzoapp/terrazzo/commit/1fc1d99e7156923e86e872e4750b7e28b6292b20) Thanks [@yuheiy](https://github.com/yuheiy)! - Allow partial utility CSS groups configuration
|
|
24
|
+
|
|
23
25
|
## 0.10.4
|
|
24
26
|
|
|
25
27
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface CSSPluginOptions {
|
|
|
20
20
|
/** Override certain token values */
|
|
21
21
|
transform?: (token: TokenNormalized, mode: string) => TokenTransformed['value'];
|
|
22
22
|
/** Generate utility CSS from groups */
|
|
23
|
-
utility?: Record<UtilityCSSGroup, string[]
|
|
23
|
+
utility?: Partial<Record<UtilityCSSGroup, string[]>>;
|
|
24
24
|
/**
|
|
25
25
|
* Output colors as hex-6/hex-8 instead of color() function
|
|
26
26
|
* @default false
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib.ts","../src/build/index.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;KAEY,eAAA;KAEA,gBAAA;AAFA,cAIC,SAAA,GAJc,KAA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AAA,CFLI,OAAA,CAAA,EEKgB,gBFLhB,CAAA,EEKmC,MFLnC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["output: string[]","mqSelectors: string[]","joinableSelectors: string[]","GROUP_REGEX: Record<UtilityCSSPrefix, RegExp>","output: CSSRule[]","declarations: Record<string, CSSRuleDeclaration>","rules: CSSRule[]","rootRule: CSSRule","p3Rule: CSSRule","rec2020Rule: CSSRule","selectorRule: CSSRule","selectorP3Rule: CSSRule","selectorRec2020Rule: CSSRule","selectorAliasDeclarations: CSSRule['declarations']","listingName: string | undefined","output: string[]"],"sources":["../src/lib.ts","../src/build/utility-css.ts","../src/build/index.ts","../src/index.ts"],"sourcesContent":["import type { TokenNormalized, TokenTransformed } from '@terrazzo/parser';\n\nexport type UtilityCSSGroup = 'bg' | 'border' | 'font' | 'layout' | 'shadow' | 'text';\n\nexport type UtilityCSSPrefix = 'bg' | 'border' | 'font' | 'gap' | 'm' | 'p' | 'shadow' | 'text';\n\nexport const FORMAT_ID = 'css';\n\nexport const FILE_PREFIX = `/* -------------------------------------------\n * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */`;\n\nexport interface CSSPluginOptions {\n /**\n * Where to output CSS\n * @default \"index.css\"\n */\n filename?: string;\n /** Glob patterns to exclude tokens from output */\n exclude?: string[];\n /** Define mode selectors as media queries or CSS classes */\n modeSelectors?: ModeSelector[];\n /** Control the final CSS variable name */\n variableName?: (token: TokenNormalized) => string;\n /** Override certain token values */\n transform?: (token: TokenNormalized, mode: string) => TokenTransformed['value'];\n /** Generate utility CSS from groups */\n utility?: Record<UtilityCSSGroup, string[]>;\n /**\n * Output colors as hex-6/hex-8 instead of color() function\n * @default false\n */\n legacyHex?: boolean;\n /**\n * Skip generating any `.css` files (useful if you are consuming values in your own plugin and don’t need any `.css` files written to disk).\n * @default false\n */\n skipBuild?: boolean;\n /**\n * Set the base selector, like \":root\" or \":host\".\n * @default \":root\"\n */\n baseSelector?: string;\n /**\n * Set the color-scheme CSS property for the base selector (e.g.: \"light\", \"dark\", \"light dark\")\n */\n baseScheme?: string;\n}\n\nexport interface ModeSelector {\n /** The name of the mode to match */\n mode: string;\n /** Provide token IDs to match. Globs are allowed (e.g: `[\"color.*\", \"shadow.dark\"]`) */\n tokens?: string[];\n /** Provide CSS selectors to generate. (e.g.: `[\"@media (prefers-color-scheme: dark)\", \"[data-color-theme='dark']\"]` ) */\n selectors: string[];\n /** Set the color-scheme CSS property for this mode (e.g.: \"light\", \"dark\", \"light dark\") */\n scheme?: string;\n}\n\n// A CSSRule is a sort of “we have AST at home” shortcut that provides the benefit of normalized formatting\n// but without the overhead/complexity of a full AST. It’s useful because we only generate a limited CSS\n// syntax, and is a good balance between spec-compliance vs ease-of-use.\nexport interface CSSRuleDeclaration {\n value: string;\n description?: string;\n}\nexport interface CSSRule {\n selectors: string[];\n nestedQuery?: string;\n declarations: Record<string, CSSRuleDeclaration>;\n}\n\n/** Convert CSSRules into a formatted, indented CSS string */\nexport function printRules(rules: CSSRule[]): string {\n const output: string[] = [];\n for (const rule of rules) {\n if (!rule.selectors.length || !Object.keys(rule.declarations).length) {\n continue;\n }\n\n const mqSelectors: string[] = [];\n const joinableSelectors: string[] = [];\n for (const s of rule.selectors) {\n (s.startsWith('@') ? mqSelectors : joinableSelectors).push(s);\n }\n // @media-query selectors get pushed individually\n for (const s of mqSelectors) {\n output.push(_printRule({ ...rule, selectors: [s] }));\n }\n // all other selectors get joined as one\n if (joinableSelectors.length) {\n output.push(_printRule({ ...rule, selectors: joinableSelectors }));\n }\n }\n return output.join('\\n\\n');\n}\n\nfunction _printRule(rule: CSSRule): string {\n const output: string[] = [];\n const isMediaQuery = rule.selectors.some((s) => s.startsWith('@'));\n let indent = '';\n\n // if both levels are media queries, preserve order\n if (rule.nestedQuery && isMediaQuery) {\n output.push(`${indent}${rule.selectors.join(`,\\n${indent}`)} {`);\n indent += ' ';\n output.push(`${indent}${rule.nestedQuery} {`);\n }\n // otherwise if nested query exists but parens aren’t media queries, reverse order (media queries on top)\n else if (rule.nestedQuery && !isMediaQuery) {\n output.push(`${indent}${rule.nestedQuery} {`);\n indent += ' ';\n output.push(`${indent}${rule.selectors.join(`,\\n${indent}`)} {`);\n }\n // if no media queries, just print selectors\n else {\n output.push(`${indent}${rule.selectors.join(`,\\n${indent}`)} {`);\n }\n indent += ' ';\n\n // note: this is ONLY dependent on whether the top level is a media query (ignores nestedQuery)\n if (isMediaQuery) {\n output.push(`${indent}:root {`);\n indent += ' ';\n }\n\n for (const [k, d] of Object.entries(rule.declarations)) {\n output.push(`${indent}${k}: ${d.value};${d.description ? ` /* ${d.description} */` : ''}`);\n }\n\n // base closing brackets on indent level\n while (indent !== '') {\n indent = indent.substring(0, indent.length - 2);\n output.push(`${indent}}`);\n }\n\n return output.join('\\n');\n}\n\nexport interface GetRuleOptions {\n /** Combine a selector with parent selectors (e.g. if adding a @media-query within another selector list) */\n parentSelectors?: string[];\n}\n","import type { TokenTransformed } from '@terrazzo/parser';\nimport { kebabCase } from '@terrazzo/token-tools';\nimport { makeCSSVar } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport type { CSSRule, CSSRuleDeclaration, UtilityCSSGroup, UtilityCSSPrefix } from '../lib.js';\n\n// micro-optimization: precompile all RegExs (which can be known) because dynamic compilation is a waste of resources\nconst GROUP_REGEX: Record<UtilityCSSPrefix, RegExp> = {\n bg: /(^bg-|-bg-)/,\n border: /(^border-|-border-)/,\n font: /(^font-|-font-)/,\n gap: /(^gap-|-gap-)/,\n m: /(^margin-|-margin-|)/,\n p: /(^padding-|-padding-|)/,\n shadow: /(^shadow-|-shadow-)/,\n text: /(^text-|-text-)/,\n};\n\n/** Make CSS class name from transformed token */\nfunction makeSelector(token: TokenTransformed, prefix: UtilityCSSPrefix, subgroup?: string): string {\n return `.${prefix}${subgroup || ''}-${kebabCase(token.token.id).replace(GROUP_REGEX[prefix], '')}`;\n}\n\nfunction makeVarValue(token: TokenTransformed): CSSRuleDeclaration {\n return { value: makeCSSVar(token.localID ?? token.token.id, { wrapVar: true }) };\n}\n\nexport default function generateUtilityCSS(\n groups: Record<UtilityCSSGroup, string[]>,\n tokens: TokenTransformed[],\n): CSSRule[] {\n const output: CSSRule[] = [];\n\n const groupEntries = Object.entries(groups);\n groupEntries.sort((a, b) => a[0].localeCompare(b[0]));\n\n for (const [group, selectors] of groupEntries) {\n const selectorMatcher = wcmatch(selectors);\n const matchingTokens = tokens.filter((token) => selectorMatcher(token.token.id));\n if (!matchingTokens.length) {\n // biome-ignore lint/suspicious/noConsole: intentional user log\n console.warn(`[@terrazzo/plugin-css] utility group \"${group}\" matched 0 tokens: ${JSON.stringify(selectors)}`);\n break;\n }\n switch (group) {\n case 'bg': {\n for (const token of matchingTokens) {\n const selector = makeSelector(token, 'bg');\n switch (token.token.$type) {\n case 'color': {\n output.push({ selectors: [selector], declarations: { 'background-color': makeVarValue(token) } });\n break;\n }\n case 'gradient': {\n output.push({\n selectors: [selector],\n declarations: {\n 'background-image': {\n value: `linear-gradient(${makeCSSVar(token.localID ?? token.token.id, { wrapVar: true })})`,\n },\n },\n });\n }\n }\n }\n break;\n }\n case 'border': {\n // ALL generic properties must come before specific properties\n for (const token of matchingTokens) {\n const property = {\n border: 'border',\n color: 'border-color',\n dimension: 'border-width',\n strokeStyle: 'border-style',\n }[token.token.$type as string];\n if (property) {\n output.push({\n selectors: [makeSelector(token, 'border')],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n }\n // specific properties\n for (const token of matchingTokens) {\n for (const side of ['top', 'right', 'bottom', 'left']) {\n const property = {\n border: `border-${side}`,\n color: `border-${side}-color`,\n dimension: `border-${side}-width`,\n strokeStyle: `border-${side}-style`,\n }[token.token.$type as string];\n if (property) {\n output.push({\n selectors: [makeSelector(token, 'border', `-${side}`)],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n }\n }\n break;\n }\n case 'font': {\n for (const token of matchingTokens) {\n const selector = makeSelector(token, 'font');\n\n if (token.token.$type === 'typography' && token.type === 'MULTI_VALUE') {\n const declarations: Record<string, CSSRuleDeclaration> = {};\n for (const k of Object.keys(token.value)) {\n declarations[k] = { value: makeCSSVar(`${token.localID ?? token.token.id}-${k}`, { wrapVar: true }) };\n }\n output.push({ selectors: [selector], declarations });\n } else {\n const property = {\n dimension: 'font-size',\n fontFamily: 'font-family',\n fontWeight: 'font-weight',\n }[token.token.$type as string];\n if (property) {\n output.push({\n selectors: [selector],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n }\n }\n break;\n }\n case 'layout': {\n const filteredTokens = matchingTokens.filter((t) => t.token.$type === 'dimension'); // only dimension tokens here\n // gap\n // ALL generic properties (gap) must come before specific properties (column-gap)\n for (const token of filteredTokens) {\n output.push({ selectors: [makeSelector(token, 'gap')], declarations: { gap: makeVarValue(token) } });\n }\n // specific properties\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, 'gap', '-col')],\n declarations: { 'column-gap': makeVarValue(token) },\n });\n }\n // specific properties\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, 'gap', '-row')],\n declarations: { 'row-gap': makeVarValue(token) },\n });\n }\n\n // margin/padding\n for (const prefix of ['m', 'p'] as const) {\n const property = prefix === 'm' ? 'margin' : 'padding';\n // note: ALL generic properties (margin: [value]) MUST come before specific properties (margin-top: [value])\n // this is why we loop through all tokens so many times\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, prefix, 'a')],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n output.push(\n {\n selectors: [makeSelector(token, prefix, 'x')],\n declarations: { [`${property}-left`]: value, [`${property}-right`]: value },\n },\n {\n selectors: [makeSelector(token, prefix, 'y')],\n declarations: { [`${property}-bottom`]: value, [`${property}-top`]: value },\n },\n );\n }\n for (const side of ['top', 'right', 'bottom', 'left']) {\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, prefix, side[0])],\n declarations: { [`${property}-${side}`]: makeVarValue(token) },\n });\n }\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n output.push(\n { selectors: [makeSelector(token, prefix, 's')], declarations: { [`${property}-inline-start`]: value } },\n { selectors: [makeSelector(token, prefix, 'e')], declarations: { [`${property}-inline-end`]: value } },\n );\n }\n }\n break;\n }\n case 'shadow': {\n for (const token of matchingTokens) {\n if (token.token.$type === 'shadow') {\n output.push({\n selectors: [makeSelector(token, 'shadow')],\n declarations: { 'box-shadow': makeVarValue(token) },\n });\n }\n }\n break;\n }\n case 'text': {\n for (const token of matchingTokens) {\n const selector = makeSelector(token, 'text');\n const value = makeVarValue(token);\n switch (token.token.$type) {\n case 'color': {\n output.push({ selectors: [selector], declarations: { color: value } });\n break;\n }\n case 'gradient': {\n output.push({\n selectors: [selector],\n declarations: {\n background: { value: `-webkit-linear-gradient(${value.value})` },\n '-webkit-background-clip': { value: 'text' },\n '-webkit-text-fill-color': { value: 'transparent' },\n },\n });\n break;\n }\n }\n }\n break;\n }\n default: {\n // biome-ignore lint/suspicious/noConsole: intentional user log\n console.warn(`[@terrazzo/plugin-css] unknown utility CSS group \"${group}\", ignoring`);\n break;\n }\n }\n }\n\n return output;\n}\n","import type { BuildHookOptions } from '@terrazzo/parser';\nimport { generateShorthand } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport { type CSSPluginOptions, type CSSRule, FORMAT_ID, printRules } from '../lib.js';\nimport generateUtilityCSS from './utility-css.js';\n\nconst P3_MQ = '@media (color-gamut: p3)';\nconst REC2020_MQ = '@media (color-gamut: rec2020)';\n\nexport interface BuildFormatOptions {\n exclude: CSSPluginOptions['exclude'];\n getTransforms: BuildHookOptions['getTransforms'];\n modeSelectors: CSSPluginOptions['modeSelectors'];\n utility: CSSPluginOptions['utility'];\n baseSelector: string;\n baseScheme: CSSPluginOptions['baseScheme'];\n}\n\nexport default function buildFormat({\n getTransforms,\n exclude,\n utility,\n modeSelectors,\n baseSelector,\n baseScheme,\n}: BuildFormatOptions): string {\n const rules: CSSRule[] = [];\n\n // :root\n const rootTokens = getTransforms({ format: FORMAT_ID, mode: '.' });\n if (rootTokens.length) {\n const rootRule: CSSRule = { selectors: [baseSelector], declarations: {} };\n\n // add base color-scheme declaration first if configured\n // (must be before other properties to ensure it appears first in output)\n if (baseScheme) {\n rootRule.declarations['color-scheme'] = { value: baseScheme };\n }\n\n // note: `nestedQuery` was designed specifically for higher-gamut colors to\n // apply color-gamut media queries to existing selectors (i.e. keep the same\n // targets, and apply another nested layer of media query filtering based on\n // hardware). Because of how CSS works they need to get built out into their\n // own selectors that have different structures depending on whether\n // `selectors` has a media query or not.\n const p3Rule: CSSRule = { selectors: [baseSelector], nestedQuery: P3_MQ, declarations: {} };\n const rec2020Rule: CSSRule = { selectors: [baseSelector], nestedQuery: REC2020_MQ, declarations: {} };\n rules.push(rootRule, p3Rule, rec2020Rule);\n\n const shouldExclude = wcmatch(exclude ?? []);\n\n for (const token of rootTokens) {\n // handle exclude (if any)\n if (shouldExclude(token.token.id)) {\n continue;\n }\n\n const localID = token.localID ?? token.token.id;\n\n // `aliasTokens` are an important concept unique to CSS: if the root value\n // changes in a scope, all downstream aliases MUST be redeclared,\n // otherwise the values are stale. here, `aliasedBy` is a reverse lookup\n // that lets us redeclare all CSS values again that are minimally-needed.\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n rootRule.declarations[localID] = { value: token.value, description: token.token.$description };\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n rootRule.declarations[localID] = { value: token.value.srgb!, description: token.token.$description };\n if (token.value.p3 !== token.value.srgb) {\n p3Rule.declarations[localID] = { value: token.value.p3!, description: token.token.$description };\n rec2020Rule.declarations[localID] = { value: token.value.rec2020!, description: token.token.$description };\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n p3Rule.declarations[alias.localID] ??= { value: alias.value, description: token.token.$description };\n rec2020Rule.declarations[alias.localID] ??= { value: alias.value, description: token.token.$description };\n }\n }\n }\n }\n\n // multi-value token\n else if (token.type === 'MULTI_VALUE') {\n for (const [name, value] of Object.entries(token.value)) {\n rootRule.declarations[name === '.' ? localID : [localID, name].join('-')] = {\n value,\n description: token.token.$description,\n };\n }\n // Note: always place shorthand after other values\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n rootRule.declarations[token.localID ?? token.token.id] = {\n value: shorthand,\n description: token.token.$description,\n };\n }\n }\n }\n }\n\n // modeSelectors (note: without these, modes won't get written to CSS)\n for (const { selectors, tokens, mode, scheme } of modeSelectors ?? []) {\n if (!selectors.length) {\n continue;\n }\n const selectorTokens = getTransforms({ format: FORMAT_ID, id: tokens, mode });\n if (!selectorTokens.length) {\n continue;\n }\n\n const selectorRule: CSSRule = { selectors, declarations: {} };\n\n // add color-scheme declaration first if configured for this mode\n // (must be before other properties to ensure it appears first in output)\n if (scheme) {\n selectorRule.declarations['color-scheme'] = { value: scheme };\n }\n\n const selectorP3Rule: CSSRule = { selectors, nestedQuery: P3_MQ, declarations: {} };\n const selectorRec2020Rule: CSSRule = { selectors, nestedQuery: REC2020_MQ, declarations: {} };\n const selectorAliasDeclarations: CSSRule['declarations'] = {};\n rules.push(selectorRule, selectorP3Rule, selectorRec2020Rule);\n\n for (const token of selectorTokens) {\n const localID = token.localID ?? token.token.id;\n\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n selectorRule.declarations[localID] = { value: token.value, description: token.token.$description };\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n selectorRule.declarations[localID] = { value: token.value.srgb!, description: token.token.$description };\n if (token.value.p3 !== token.value.srgb) {\n selectorP3Rule.declarations[localID] = { value: token.value.p3!, description: token.token.$description };\n selectorRec2020Rule.declarations[localID] = {\n value: token.value.rec2020!,\n description: token.token.$description,\n };\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n selectorP3Rule.declarations[alias.localID] ??= {\n value: alias.value,\n description: token.token.$description,\n };\n selectorRec2020Rule.declarations[alias.localID] ??= {\n value: alias.value,\n description: token.token.$description,\n };\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subvalue] of Object.entries(token.value)) {\n selectorRule.declarations[`${localID}-${name}`] = { value: subvalue, description: token.token.$description };\n }\n // Note: always generate shorthand after other declarations\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n selectorRule.declarations[localID] = { value: shorthand, description: token.token.$description };\n }\n }\n\n // redeclare aliases so they have the correct scope\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n selectorAliasDeclarations[alias.localID] = { value: alias.value, description: token.token.$description };\n }\n }\n }\n\n // after selector has settled, add in aliases if there are no conflicts\n for (const [name, { value, description }] of Object.entries(selectorAliasDeclarations)) {\n selectorRule.declarations[name] ??= { value, description };\n }\n }\n\n // add utility CSS\n if (utility && Object.keys(utility).length) {\n rules.push(...generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID, mode: '.' })));\n }\n\n return printRules(rules);\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport { type TokenNormalized, validateCustomTransform } from '@terrazzo/token-tools';\nimport { generateShorthand, makeCSSVar, transformCSSValue } from '@terrazzo/token-tools/css';\nimport buildFormat from './build/index.js';\nimport { type CSSPluginOptions, FILE_PREFIX, FORMAT_ID } from './lib.js';\n\nexport * from './build/index.js';\nexport * from './lib.js';\n\nexport default function cssPlugin(options?: CSSPluginOptions): Plugin {\n const {\n exclude,\n variableName,\n modeSelectors,\n transform: customTransform,\n utility,\n legacyHex,\n skipBuild,\n baseScheme,\n } = options ?? {};\n\n const filename = options?.filename ?? (options as any)?.fileName ?? 'index.css';\n const baseSelector = options?.baseSelector ?? ':root';\n\n function transformName(token: TokenNormalized) {\n const customName = variableName?.(token);\n if (customName !== undefined) {\n if (typeof customName !== 'string') {\n throw new Error(`variableName() must return a string; received ${customName}`);\n }\n return customName;\n }\n return makeCSSVar(token.id);\n }\n const transformAlias = (token: TokenNormalized) => `var(${transformName(token)})`;\n\n return {\n name: '@terrazzo/plugin-css',\n async transform({ tokens, getTransforms, setTransform }) {\n // skip work if another .css plugin has already run\n const cssTokens = getTransforms({ format: FORMAT_ID, id: '*', mode: '*' });\n if (cssTokens.length) {\n return;\n }\n\n for (const [id, token] of Object.entries(tokens)) {\n const localID = transformName(token);\n for (const mode of Object.keys(token.mode)) {\n if (customTransform) {\n const value = customTransform(token, mode);\n if (value !== undefined && value !== null) {\n validateCustomTransform(value, { $type: token.$type });\n setTransform(id, {\n format: FORMAT_ID,\n localID,\n value,\n mode,\n meta: { 'token-listing': { name: localID } },\n });\n continue;\n }\n }\n\n const transformedValue = transformCSSValue(token, {\n mode,\n tokensSet: tokens,\n transformAlias,\n color: { legacyHex },\n });\n if (transformedValue !== undefined) {\n let listingName: string | undefined = localID;\n\n // Composite tokens without a shorthand won't get generated in the output, so we don't list them.\n if (typeof transformedValue === 'object' && generateShorthand({ token, localID }) === undefined) {\n listingName = undefined;\n }\n\n setTransform(id, {\n format: FORMAT_ID,\n localID,\n value: transformedValue,\n mode,\n meta: { 'token-listing': { name: listingName } },\n });\n }\n }\n }\n },\n async build({ getTransforms, outputFile }) {\n if (skipBuild === true) {\n return;\n }\n\n const output: string[] = [FILE_PREFIX, ''];\n output.push(\n buildFormat({ exclude, getTransforms, modeSelectors, utility, baseSelector, baseScheme }),\n '\\n', // EOF newline\n );\n outputFile(filename, output.join('\\n'));\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAa,YAAY;AAEzB,MAAa,cAAc;;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zC,+BAAwB,OAAO,EAAE,OAAO,MAAM,OAAO,CAAC;AACtD,oBAAa,IAAI;QACf,QAAQ;QACR;QACA;QACA;QACA,MAAM,EAAE,iBAAiB,EAAE,MAAM,SAAS,EAAE;QAC7C,CAAC;AACF;;;KAIJ,MAAM,mBAAmB,kBAAkB,OAAO;MAChD;MACA,WAAW;MACX;MACA,OAAO,EAAE,WAAW;MACrB,CAAC;AACF,SAAI,qBAAqB,QAAW;MAClC,IAAIC,cAAkC;AAGtC,UAAI,OAAO,qBAAqB,YAAY,kBAAkB;OAAE;OAAO;OAAS,CAAC,KAAK,OACpF,eAAc;AAGhB,mBAAa,IAAI;OACf,QAAQ;OACR;OACA,OAAO;OACP;OACA,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,EAAE;OACjD,CAAC;;;;;EAKV,MAAM,MAAM,EAAE,eAAe,cAAc;AACzC,OAAI,cAAc,KAChB;GAGF,MAAMC,SAAmB,CAAC,aAAa,GAAG;AAC1C,UAAO,KACL,YAAY;IAAE;IAAS;IAAe;IAAe;IAAS;IAAc;IAAY,CAAC,EACzF,KACD;AACD,cAAW,UAAU,OAAO,KAAK,KAAK,CAAC;;EAE1C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["output: string[]","mqSelectors: string[]","joinableSelectors: string[]","GROUP_REGEX: Record<UtilityCSSPrefix, RegExp>","output: CSSRule[]","declarations: Record<string, CSSRuleDeclaration>","rules: CSSRule[]","rootRule: CSSRule","p3Rule: CSSRule","rec2020Rule: CSSRule","selectorRule: CSSRule","selectorP3Rule: CSSRule","selectorRec2020Rule: CSSRule","selectorAliasDeclarations: CSSRule['declarations']","listingName: string | undefined","output: string[]"],"sources":["../src/lib.ts","../src/build/utility-css.ts","../src/build/index.ts","../src/index.ts"],"sourcesContent":["import type { TokenNormalized, TokenTransformed } from '@terrazzo/parser';\n\nexport type UtilityCSSGroup = 'bg' | 'border' | 'font' | 'layout' | 'shadow' | 'text';\n\nexport type UtilityCSSPrefix = 'bg' | 'border' | 'font' | 'gap' | 'm' | 'p' | 'shadow' | 'text';\n\nexport const FORMAT_ID = 'css';\n\nexport const FILE_PREFIX = `/* -------------------------------------------\n * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */`;\n\nexport interface CSSPluginOptions {\n /**\n * Where to output CSS\n * @default \"index.css\"\n */\n filename?: string;\n /** Glob patterns to exclude tokens from output */\n exclude?: string[];\n /** Define mode selectors as media queries or CSS classes */\n modeSelectors?: ModeSelector[];\n /** Control the final CSS variable name */\n variableName?: (token: TokenNormalized) => string;\n /** Override certain token values */\n transform?: (token: TokenNormalized, mode: string) => TokenTransformed['value'];\n /** Generate utility CSS from groups */\n utility?: Partial<Record<UtilityCSSGroup, string[]>>;\n /**\n * Output colors as hex-6/hex-8 instead of color() function\n * @default false\n */\n legacyHex?: boolean;\n /**\n * Skip generating any `.css` files (useful if you are consuming values in your own plugin and don’t need any `.css` files written to disk).\n * @default false\n */\n skipBuild?: boolean;\n /**\n * Set the base selector, like \":root\" or \":host\".\n * @default \":root\"\n */\n baseSelector?: string;\n /**\n * Set the color-scheme CSS property for the base selector (e.g.: \"light\", \"dark\", \"light dark\")\n */\n baseScheme?: string;\n}\n\nexport interface ModeSelector {\n /** The name of the mode to match */\n mode: string;\n /** Provide token IDs to match. Globs are allowed (e.g: `[\"color.*\", \"shadow.dark\"]`) */\n tokens?: string[];\n /** Provide CSS selectors to generate. (e.g.: `[\"@media (prefers-color-scheme: dark)\", \"[data-color-theme='dark']\"]` ) */\n selectors: string[];\n /** Set the color-scheme CSS property for this mode (e.g.: \"light\", \"dark\", \"light dark\") */\n scheme?: string;\n}\n\n// A CSSRule is a sort of “we have AST at home” shortcut that provides the benefit of normalized formatting\n// but without the overhead/complexity of a full AST. It’s useful because we only generate a limited CSS\n// syntax, and is a good balance between spec-compliance vs ease-of-use.\nexport interface CSSRuleDeclaration {\n value: string;\n description?: string;\n}\nexport interface CSSRule {\n selectors: string[];\n nestedQuery?: string;\n declarations: Record<string, CSSRuleDeclaration>;\n}\n\n/** Convert CSSRules into a formatted, indented CSS string */\nexport function printRules(rules: CSSRule[]): string {\n const output: string[] = [];\n for (const rule of rules) {\n if (!rule.selectors.length || !Object.keys(rule.declarations).length) {\n continue;\n }\n\n const mqSelectors: string[] = [];\n const joinableSelectors: string[] = [];\n for (const s of rule.selectors) {\n (s.startsWith('@') ? mqSelectors : joinableSelectors).push(s);\n }\n // @media-query selectors get pushed individually\n for (const s of mqSelectors) {\n output.push(_printRule({ ...rule, selectors: [s] }));\n }\n // all other selectors get joined as one\n if (joinableSelectors.length) {\n output.push(_printRule({ ...rule, selectors: joinableSelectors }));\n }\n }\n return output.join('\\n\\n');\n}\n\nfunction _printRule(rule: CSSRule): string {\n const output: string[] = [];\n const isMediaQuery = rule.selectors.some((s) => s.startsWith('@'));\n let indent = '';\n\n // if both levels are media queries, preserve order\n if (rule.nestedQuery && isMediaQuery) {\n output.push(`${indent}${rule.selectors.join(`,\\n${indent}`)} {`);\n indent += ' ';\n output.push(`${indent}${rule.nestedQuery} {`);\n }\n // otherwise if nested query exists but parens aren’t media queries, reverse order (media queries on top)\n else if (rule.nestedQuery && !isMediaQuery) {\n output.push(`${indent}${rule.nestedQuery} {`);\n indent += ' ';\n output.push(`${indent}${rule.selectors.join(`,\\n${indent}`)} {`);\n }\n // if no media queries, just print selectors\n else {\n output.push(`${indent}${rule.selectors.join(`,\\n${indent}`)} {`);\n }\n indent += ' ';\n\n // note: this is ONLY dependent on whether the top level is a media query (ignores nestedQuery)\n if (isMediaQuery) {\n output.push(`${indent}:root {`);\n indent += ' ';\n }\n\n for (const [k, d] of Object.entries(rule.declarations)) {\n output.push(`${indent}${k}: ${d.value};${d.description ? ` /* ${d.description} */` : ''}`);\n }\n\n // base closing brackets on indent level\n while (indent !== '') {\n indent = indent.substring(0, indent.length - 2);\n output.push(`${indent}}`);\n }\n\n return output.join('\\n');\n}\n\nexport interface GetRuleOptions {\n /** Combine a selector with parent selectors (e.g. if adding a @media-query within another selector list) */\n parentSelectors?: string[];\n}\n","import type { TokenTransformed } from '@terrazzo/parser';\nimport { kebabCase } from '@terrazzo/token-tools';\nimport { makeCSSVar } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport type { CSSRule, CSSRuleDeclaration, UtilityCSSGroup, UtilityCSSPrefix } from '../lib.js';\n\n// micro-optimization: precompile all RegExs (which can be known) because dynamic compilation is a waste of resources\nconst GROUP_REGEX: Record<UtilityCSSPrefix, RegExp> = {\n bg: /(^bg-|-bg-)/,\n border: /(^border-|-border-)/,\n font: /(^font-|-font-)/,\n gap: /(^gap-|-gap-)/,\n m: /(^margin-|-margin-|)/,\n p: /(^padding-|-padding-|)/,\n shadow: /(^shadow-|-shadow-)/,\n text: /(^text-|-text-)/,\n};\n\n/** Make CSS class name from transformed token */\nfunction makeSelector(token: TokenTransformed, prefix: UtilityCSSPrefix, subgroup?: string): string {\n return `.${prefix}${subgroup || ''}-${kebabCase(token.token.id).replace(GROUP_REGEX[prefix], '')}`;\n}\n\nfunction makeVarValue(token: TokenTransformed): CSSRuleDeclaration {\n return { value: makeCSSVar(token.localID ?? token.token.id, { wrapVar: true }) };\n}\n\nexport default function generateUtilityCSS(\n groups: Partial<Record<UtilityCSSGroup, string[]>>,\n tokens: TokenTransformed[],\n): CSSRule[] {\n const output: CSSRule[] = [];\n\n const groupEntries = Object.entries(groups);\n groupEntries.sort((a, b) => a[0].localeCompare(b[0]));\n\n for (const [group, selectors] of groupEntries) {\n const selectorMatcher = wcmatch(selectors);\n const matchingTokens = tokens.filter((token) => selectorMatcher(token.token.id));\n if (!matchingTokens.length) {\n // biome-ignore lint/suspicious/noConsole: intentional user log\n console.warn(`[@terrazzo/plugin-css] utility group \"${group}\" matched 0 tokens: ${JSON.stringify(selectors)}`);\n break;\n }\n switch (group) {\n case 'bg': {\n for (const token of matchingTokens) {\n const selector = makeSelector(token, 'bg');\n switch (token.token.$type) {\n case 'color': {\n output.push({ selectors: [selector], declarations: { 'background-color': makeVarValue(token) } });\n break;\n }\n case 'gradient': {\n output.push({\n selectors: [selector],\n declarations: {\n 'background-image': {\n value: `linear-gradient(${makeCSSVar(token.localID ?? token.token.id, { wrapVar: true })})`,\n },\n },\n });\n }\n }\n }\n break;\n }\n case 'border': {\n // ALL generic properties must come before specific properties\n for (const token of matchingTokens) {\n const property = {\n border: 'border',\n color: 'border-color',\n dimension: 'border-width',\n strokeStyle: 'border-style',\n }[token.token.$type as string];\n if (property) {\n output.push({\n selectors: [makeSelector(token, 'border')],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n }\n // specific properties\n for (const token of matchingTokens) {\n for (const side of ['top', 'right', 'bottom', 'left']) {\n const property = {\n border: `border-${side}`,\n color: `border-${side}-color`,\n dimension: `border-${side}-width`,\n strokeStyle: `border-${side}-style`,\n }[token.token.$type as string];\n if (property) {\n output.push({\n selectors: [makeSelector(token, 'border', `-${side}`)],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n }\n }\n break;\n }\n case 'font': {\n for (const token of matchingTokens) {\n const selector = makeSelector(token, 'font');\n\n if (token.token.$type === 'typography' && token.type === 'MULTI_VALUE') {\n const declarations: Record<string, CSSRuleDeclaration> = {};\n for (const k of Object.keys(token.value)) {\n declarations[k] = { value: makeCSSVar(`${token.localID ?? token.token.id}-${k}`, { wrapVar: true }) };\n }\n output.push({ selectors: [selector], declarations });\n } else {\n const property = {\n dimension: 'font-size',\n fontFamily: 'font-family',\n fontWeight: 'font-weight',\n }[token.token.$type as string];\n if (property) {\n output.push({\n selectors: [selector],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n }\n }\n break;\n }\n case 'layout': {\n const filteredTokens = matchingTokens.filter((t) => t.token.$type === 'dimension'); // only dimension tokens here\n // gap\n // ALL generic properties (gap) must come before specific properties (column-gap)\n for (const token of filteredTokens) {\n output.push({ selectors: [makeSelector(token, 'gap')], declarations: { gap: makeVarValue(token) } });\n }\n // specific properties\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, 'gap', '-col')],\n declarations: { 'column-gap': makeVarValue(token) },\n });\n }\n // specific properties\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, 'gap', '-row')],\n declarations: { 'row-gap': makeVarValue(token) },\n });\n }\n\n // margin/padding\n for (const prefix of ['m', 'p'] as const) {\n const property = prefix === 'm' ? 'margin' : 'padding';\n // note: ALL generic properties (margin: [value]) MUST come before specific properties (margin-top: [value])\n // this is why we loop through all tokens so many times\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, prefix, 'a')],\n declarations: { [property]: makeVarValue(token) },\n });\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n output.push(\n {\n selectors: [makeSelector(token, prefix, 'x')],\n declarations: { [`${property}-left`]: value, [`${property}-right`]: value },\n },\n {\n selectors: [makeSelector(token, prefix, 'y')],\n declarations: { [`${property}-bottom`]: value, [`${property}-top`]: value },\n },\n );\n }\n for (const side of ['top', 'right', 'bottom', 'left']) {\n for (const token of filteredTokens) {\n output.push({\n selectors: [makeSelector(token, prefix, side[0])],\n declarations: { [`${property}-${side}`]: makeVarValue(token) },\n });\n }\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n output.push(\n { selectors: [makeSelector(token, prefix, 's')], declarations: { [`${property}-inline-start`]: value } },\n { selectors: [makeSelector(token, prefix, 'e')], declarations: { [`${property}-inline-end`]: value } },\n );\n }\n }\n break;\n }\n case 'shadow': {\n for (const token of matchingTokens) {\n if (token.token.$type === 'shadow') {\n output.push({\n selectors: [makeSelector(token, 'shadow')],\n declarations: { 'box-shadow': makeVarValue(token) },\n });\n }\n }\n break;\n }\n case 'text': {\n for (const token of matchingTokens) {\n const selector = makeSelector(token, 'text');\n const value = makeVarValue(token);\n switch (token.token.$type) {\n case 'color': {\n output.push({ selectors: [selector], declarations: { color: value } });\n break;\n }\n case 'gradient': {\n output.push({\n selectors: [selector],\n declarations: {\n background: { value: `-webkit-linear-gradient(${value.value})` },\n '-webkit-background-clip': { value: 'text' },\n '-webkit-text-fill-color': { value: 'transparent' },\n },\n });\n break;\n }\n }\n }\n break;\n }\n default: {\n // biome-ignore lint/suspicious/noConsole: intentional user log\n console.warn(`[@terrazzo/plugin-css] unknown utility CSS group \"${group}\", ignoring`);\n break;\n }\n }\n }\n\n return output;\n}\n","import type { BuildHookOptions } from '@terrazzo/parser';\nimport { generateShorthand } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport { type CSSPluginOptions, type CSSRule, FORMAT_ID, printRules } from '../lib.js';\nimport generateUtilityCSS from './utility-css.js';\n\nconst P3_MQ = '@media (color-gamut: p3)';\nconst REC2020_MQ = '@media (color-gamut: rec2020)';\n\nexport interface BuildFormatOptions {\n exclude: CSSPluginOptions['exclude'];\n getTransforms: BuildHookOptions['getTransforms'];\n modeSelectors: CSSPluginOptions['modeSelectors'];\n utility: CSSPluginOptions['utility'];\n baseSelector: string;\n baseScheme: CSSPluginOptions['baseScheme'];\n}\n\nexport default function buildFormat({\n getTransforms,\n exclude,\n utility,\n modeSelectors,\n baseSelector,\n baseScheme,\n}: BuildFormatOptions): string {\n const rules: CSSRule[] = [];\n\n // :root\n const rootTokens = getTransforms({ format: FORMAT_ID, mode: '.' });\n if (rootTokens.length) {\n const rootRule: CSSRule = { selectors: [baseSelector], declarations: {} };\n\n // add base color-scheme declaration first if configured\n // (must be before other properties to ensure it appears first in output)\n if (baseScheme) {\n rootRule.declarations['color-scheme'] = { value: baseScheme };\n }\n\n // note: `nestedQuery` was designed specifically for higher-gamut colors to\n // apply color-gamut media queries to existing selectors (i.e. keep the same\n // targets, and apply another nested layer of media query filtering based on\n // hardware). Because of how CSS works they need to get built out into their\n // own selectors that have different structures depending on whether\n // `selectors` has a media query or not.\n const p3Rule: CSSRule = { selectors: [baseSelector], nestedQuery: P3_MQ, declarations: {} };\n const rec2020Rule: CSSRule = { selectors: [baseSelector], nestedQuery: REC2020_MQ, declarations: {} };\n rules.push(rootRule, p3Rule, rec2020Rule);\n\n const shouldExclude = wcmatch(exclude ?? []);\n\n for (const token of rootTokens) {\n // handle exclude (if any)\n if (shouldExclude(token.token.id)) {\n continue;\n }\n\n const localID = token.localID ?? token.token.id;\n\n // `aliasTokens` are an important concept unique to CSS: if the root value\n // changes in a scope, all downstream aliases MUST be redeclared,\n // otherwise the values are stale. here, `aliasedBy` is a reverse lookup\n // that lets us redeclare all CSS values again that are minimally-needed.\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n rootRule.declarations[localID] = { value: token.value, description: token.token.$description };\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n rootRule.declarations[localID] = { value: token.value.srgb!, description: token.token.$description };\n if (token.value.p3 !== token.value.srgb) {\n p3Rule.declarations[localID] = { value: token.value.p3!, description: token.token.$description };\n rec2020Rule.declarations[localID] = { value: token.value.rec2020!, description: token.token.$description };\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n p3Rule.declarations[alias.localID] ??= { value: alias.value, description: token.token.$description };\n rec2020Rule.declarations[alias.localID] ??= { value: alias.value, description: token.token.$description };\n }\n }\n }\n }\n\n // multi-value token\n else if (token.type === 'MULTI_VALUE') {\n for (const [name, value] of Object.entries(token.value)) {\n rootRule.declarations[name === '.' ? localID : [localID, name].join('-')] = {\n value,\n description: token.token.$description,\n };\n }\n // Note: always place shorthand after other values\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n rootRule.declarations[token.localID ?? token.token.id] = {\n value: shorthand,\n description: token.token.$description,\n };\n }\n }\n }\n }\n\n // modeSelectors (note: without these, modes won't get written to CSS)\n for (const { selectors, tokens, mode, scheme } of modeSelectors ?? []) {\n if (!selectors.length) {\n continue;\n }\n const selectorTokens = getTransforms({ format: FORMAT_ID, id: tokens, mode });\n if (!selectorTokens.length) {\n continue;\n }\n\n const selectorRule: CSSRule = { selectors, declarations: {} };\n\n // add color-scheme declaration first if configured for this mode\n // (must be before other properties to ensure it appears first in output)\n if (scheme) {\n selectorRule.declarations['color-scheme'] = { value: scheme };\n }\n\n const selectorP3Rule: CSSRule = { selectors, nestedQuery: P3_MQ, declarations: {} };\n const selectorRec2020Rule: CSSRule = { selectors, nestedQuery: REC2020_MQ, declarations: {} };\n const selectorAliasDeclarations: CSSRule['declarations'] = {};\n rules.push(selectorRule, selectorP3Rule, selectorRec2020Rule);\n\n for (const token of selectorTokens) {\n const localID = token.localID ?? token.token.id;\n\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n selectorRule.declarations[localID] = { value: token.value, description: token.token.$description };\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n selectorRule.declarations[localID] = { value: token.value.srgb!, description: token.token.$description };\n if (token.value.p3 !== token.value.srgb) {\n selectorP3Rule.declarations[localID] = { value: token.value.p3!, description: token.token.$description };\n selectorRec2020Rule.declarations[localID] = {\n value: token.value.rec2020!,\n description: token.token.$description,\n };\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n selectorP3Rule.declarations[alias.localID] ??= {\n value: alias.value,\n description: token.token.$description,\n };\n selectorRec2020Rule.declarations[alias.localID] ??= {\n value: alias.value,\n description: token.token.$description,\n };\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subvalue] of Object.entries(token.value)) {\n selectorRule.declarations[`${localID}-${name}`] = { value: subvalue, description: token.token.$description };\n }\n // Note: always generate shorthand after other declarations\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n selectorRule.declarations[localID] = { value: shorthand, description: token.token.$description };\n }\n }\n\n // redeclare aliases so they have the correct scope\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n selectorAliasDeclarations[alias.localID] = { value: alias.value, description: token.token.$description };\n }\n }\n }\n\n // after selector has settled, add in aliases if there are no conflicts\n for (const [name, { value, description }] of Object.entries(selectorAliasDeclarations)) {\n selectorRule.declarations[name] ??= { value, description };\n }\n }\n\n // add utility CSS\n if (utility && Object.keys(utility).length) {\n rules.push(...generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID, mode: '.' })));\n }\n\n return printRules(rules);\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport { type TokenNormalized, validateCustomTransform } from '@terrazzo/token-tools';\nimport { generateShorthand, makeCSSVar, transformCSSValue } from '@terrazzo/token-tools/css';\nimport buildFormat from './build/index.js';\nimport { type CSSPluginOptions, FILE_PREFIX, FORMAT_ID } from './lib.js';\n\nexport * from './build/index.js';\nexport * from './lib.js';\n\nexport default function cssPlugin(options?: CSSPluginOptions): Plugin {\n const {\n exclude,\n variableName,\n modeSelectors,\n transform: customTransform,\n utility,\n legacyHex,\n skipBuild,\n baseScheme,\n } = options ?? {};\n\n const filename = options?.filename ?? (options as any)?.fileName ?? 'index.css';\n const baseSelector = options?.baseSelector ?? ':root';\n\n function transformName(token: TokenNormalized) {\n const customName = variableName?.(token);\n if (customName !== undefined) {\n if (typeof customName !== 'string') {\n throw new Error(`variableName() must return a string; received ${customName}`);\n }\n return customName;\n }\n return makeCSSVar(token.id);\n }\n const transformAlias = (token: TokenNormalized) => `var(${transformName(token)})`;\n\n return {\n name: '@terrazzo/plugin-css',\n async transform({ tokens, getTransforms, setTransform }) {\n // skip work if another .css plugin has already run\n const cssTokens = getTransforms({ format: FORMAT_ID, id: '*', mode: '*' });\n if (cssTokens.length) {\n return;\n }\n\n for (const [id, token] of Object.entries(tokens)) {\n const localID = transformName(token);\n for (const mode of Object.keys(token.mode)) {\n if (customTransform) {\n const value = customTransform(token, mode);\n if (value !== undefined && value !== null) {\n validateCustomTransform(value, { $type: token.$type });\n setTransform(id, {\n format: FORMAT_ID,\n localID,\n value,\n mode,\n meta: { 'token-listing': { name: localID } },\n });\n continue;\n }\n }\n\n const transformedValue = transformCSSValue(token, {\n mode,\n tokensSet: tokens,\n transformAlias,\n color: { legacyHex },\n });\n if (transformedValue !== undefined) {\n let listingName: string | undefined = localID;\n\n // Composite tokens without a shorthand won't get generated in the output, so we don't list them.\n if (typeof transformedValue === 'object' && generateShorthand({ token, localID }) === undefined) {\n listingName = undefined;\n }\n\n setTransform(id, {\n format: FORMAT_ID,\n localID,\n value: transformedValue,\n mode,\n meta: { 'token-listing': { name: listingName } },\n });\n }\n }\n }\n },\n async build({ getTransforms, outputFile }) {\n if (skipBuild === true) {\n return;\n }\n\n const output: string[] = [FILE_PREFIX, ''];\n output.push(\n buildFormat({ exclude, getTransforms, modeSelectors, utility, baseSelector, baseScheme }),\n '\\n', // EOF newline\n );\n outputFile(filename, output.join('\\n'));\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAa,YAAY;AAEzB,MAAa,cAAc;;;;AAkE3B,SAAgB,WAAW,OAA0B;CACnD,MAAMA,SAAmB,EAAE;AAC3B,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,KAAK,UAAU,UAAU,CAAC,OAAO,KAAK,KAAK,aAAa,CAAC,OAC5D;EAGF,MAAMC,cAAwB,EAAE;EAChC,MAAMC,oBAA8B,EAAE;AACtC,OAAK,MAAM,KAAK,KAAK,UACnB,EAAC,EAAE,WAAW,IAAI,GAAG,cAAc,mBAAmB,KAAK,EAAE;AAG/D,OAAK,MAAM,KAAK,YACd,QAAO,KAAK,WAAW;GAAE,GAAG;GAAM,WAAW,CAAC,EAAE;GAAE,CAAC,CAAC;AAGtD,MAAI,kBAAkB,OACpB,QAAO,KAAK,WAAW;GAAE,GAAG;GAAM,WAAW;GAAmB,CAAC,CAAC;;AAGtE,QAAO,OAAO,KAAK,OAAO;;AAG5B,SAAS,WAAW,MAAuB;CACzC,MAAMF,SAA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,CAAC,aAAa,GAAG;AAC1C,UAAO,KACL,YAAY;IAAE;IAAS;IAAe;IAAe;IAAS;IAAc;IAAY,CAAC,EACzF,KACD;AACD,cAAW,UAAU,OAAO,KAAK,KAAK,CAAC;;EAE1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrazzo/plugin-css",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.7",
|
|
4
4
|
"description": "Convert DTCG design tokens JSON into CSS variables for use in any web application or native app with webview.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,16 +27,17 @@
|
|
|
27
27
|
"directory": "./packages/plugin-css/"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@terrazzo/cli": "^2.0.0-alpha.
|
|
30
|
+
"@terrazzo/cli": "^2.0.0-alpha.7",
|
|
31
|
+
"@terrazzo/parser": "^2.0.0-alpha.7"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"wildcard-match": "^5.1.4",
|
|
34
|
-
"@terrazzo/token-tools": "^2.0.0-alpha.
|
|
35
|
+
"@terrazzo/token-tools": "^2.0.0-alpha.7"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"dtcg-examples": "^0.3.4",
|
|
38
|
-
"@terrazzo/cli": "^2.0.0-alpha.
|
|
39
|
-
"@terrazzo/parser": "^2.0.0-alpha.
|
|
39
|
+
"@terrazzo/cli": "^2.0.0-alpha.7",
|
|
40
|
+
"@terrazzo/parser": "^2.0.0-alpha.7"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
42
43
|
"build": "rolldown -c && attw --profile esm-only --pack .",
|