@apollion-dsi/tokens 5.2.0 → 5.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.
- package/README.md +5 -1
- package/lib/build.cjs +11 -6
- package/lib/build.esm.js +11 -6
- package/lib/builders/colors.d.ts +3 -3
- package/lib/cli.mjs +13 -8
- package/lib/config-loader.cjs +2 -2
- package/lib/config-loader.esm.js +1 -1
- package/lib/config-schema.cjs +1 -1
- package/lib/config-schema.esm.js +1 -1
- package/lib/runtime/v1.cjs +1 -1
- package/lib/runtime/v1.esm.js +1 -1
- package/package.json +3 -2
- package/src/build.ts +50 -4
- package/src/builders/colors.ts +45 -9
- package/src/cli.ts +1 -1
- package/src/config-schema-runtime.ts +2 -0
- package/src/config-schema.ts +10 -1
- package/src/ir.ts +3 -0
- package/src/manifest.ts +1 -1
- package/src/renderers/css.ts +36 -1
- package/src/renderers/design-md.ts +107 -0
- package/src/renderers/resolver.ts +4 -3
- package/src/renderers/tailwind.ts +195 -0
- package/src/renderers/ts.ts +16 -2
- package/src/theme-factory.ts +32 -8
package/README.md
CHANGED
|
@@ -23,13 +23,17 @@ import { TOKENS_RUNTIME_API_VERSION } from '@apollion-dsi/tokens/runtime/v1';
|
|
|
23
23
|
|
|
24
24
|
## JSON output (`dist/json/*.json`)
|
|
25
25
|
|
|
26
|
-
Tokens
|
|
26
|
+
Tokens as structured JSON — values are **structured objects**, not shorthand strings:
|
|
27
27
|
|
|
28
28
|
- `color` → `{ "colorSpace": "oklch", "components": [L, C, H], "hex": "#rrggbb" }` — OKLch working space + sRGB `hex` fallback. `alpha` emitted only when below 1.
|
|
29
29
|
- `dimension` → `{ "value": <number>, "unit": "rem" }`.
|
|
30
30
|
|
|
31
31
|
`dist/css/*.css` and `dist/ts/*.d.ts` stay string-based (hex / `rem`) — JSON is the interop surface; CSS/TS are the resolved consumer surfaces.
|
|
32
32
|
|
|
33
|
+
Tailwind stacks additionally get a generated naming layer via `output.tailwind`
|
|
34
|
+
(`dist/tailwind/preset.mjs` + `dist/tailwind/tw-merge.mjs`, mapping foundation
|
|
35
|
+
tokens to theme keys over `var(--apollion-*)`) — see the Output docs.
|
|
36
|
+
|
|
33
37
|
## Coupling to `@apollion-dsi/core`
|
|
34
38
|
|
|
35
39
|
Hard rule:
|
package/lib/build.cjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var an=Object.prototype.hasOwnProperty;var s=(e,n)=>M(e,"name",{value:n,configurable:!0});var cn=(e,n)=>{for(var o in n)M(e,o,{get:n[o],enumerable:!0})},ln=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of sn(n))!an.call(e,t)&&t!==o&&M(e,t,{get:()=>n[t],enumerable:!(r=tn(n,t))||r.enumerable});return e};var dn=e=>ln(M({},"__esModule",{value:!0}),e);var Nn={};cn(Nn,{build:()=>An,check:()=>Pn});module.exports=dn(Nn);var y=require("node:fs/promises"),rn=require("node:os"),T=require("node:path");var V=require("@apollion-dsi/core/themes/border"),le=require("@apollion-dsi/core/themes/colors"),N=require("@apollion-dsi/core/themes/depth"),I=require("@apollion-dsi/core/themes/font"),Z=require("@apollion-dsi/core/themes/spacing"),w=require("culori");var ce=require("@apollion-dsi/core/themes/dimension");function j({multiplier:e=.25,alias:n},o){let r=o!==void 0?ce.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(j,"createSpacing");var q={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function K(e){let n=Object.keys(q).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(K,"assertTokenMetaResolves");var un=(0,w.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(k,"kebab");function de(e){return e.split(".").map(k).join(".")}s(de,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}s($,"rawValue");function A(e,n){return Number(e.toFixed(n))||0}s(A,"round");function ee(e){let n=un((0,w.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[A(n.l,4),A(n.c,4),A(n.h??0,2)],r=(0,w.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:A(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ee,"toColorValue");var ue=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function v(e){let n=ue.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(v,"toDimensionValue");function h(e){return{type:"color",value:ee(e)}}s(h,"colorToken");function Q(e){let n={};for(let[o,r]of Object.entries(e))n[o]=h(r);return n}s(Q,"recordColorGroup");function pe(e){let n=(0,le.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=h(t);return o.neutral=Q(n.neutral),o}s(pe,"buildReadableTextGroup");var pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function fe(e){let n={};for(let o of pn){let r=e[o];n[o]={base:h(r.base),dark:h(r.dark),action:h(r.action),active:h(r.active),light:h(r.light)}}return n.grayscale=Q(e.grayscale),n.neutral=Q(e.neutral),n.baseDark=h(e.baseDark??"#000000"),n.baseLight=h(e.baseLight??"#ffffff"),n.deepDark=h(e.deepDark??"#000000"),n.deepLight=h(e.deepLight??"#ffffff"),n}s(fe,"buildColorPrimitives");function me(e){let n=j(Z.defaultInputSpacing,e),o={};for(let r of Object.keys(Z.defaultInputSpacing.alias))o[r]={type:"dimension",value:v(n(r))};return o}s(me,"buildSpacePrimitives");function ge(){let e={};for(let[n,o]of Object.entries(V.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:v(o)};return e}s(ge,"buildBorderWidthPrimitives");function fn(e,n){return{color:fe(e),space:me(n),borderWidth:ge()}}s(fn,"buildPrimitives");var ye={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},he={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function mn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(mn,"lookupPrimitive");function P(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?mn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ee(i)}}:h(i)}return r}s(P,"colorRefGroup");var be={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},gn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function yn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!b(t)&&i in t)t=t[i];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(yn,"lookupDimensionPrimitive");function ne(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?yn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:v(i)}}:{type:"dimension",value:v(i)}}return r}s(ne,"dimensionRefGroup");function Re(e){let n={},o={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderRadius))ue.test(a)?n[i]={type:"dimension",value:v(a)}:o[i]=a;let r=ne(V.defaultInputBorder.borderWidth,e,gn),t={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Re,"buildBorder");function Ie(e){let n=(0,I.createFont)(I.defaultInputFont,e),o={};for(let[c,d]of Object.entries(I.defaultInputFont.fontFamily)){let m=d.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,d]of Object.entries(n.fontSize))r[c]={type:"dimension",value:v(d)};let t={};for(let[c,d]of Object.entries(I.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${d}`,weight:d}};let i={};for(let[c,d]of Object.entries(I.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${d}`,number:d}};let a={letterSpacing:I.defaultInputFont.letterSpacing,textTransform:I.defaultInputFont.textTransform,fontStyle:I.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Ie,"buildFont");var hn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function bn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(hn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(d=>v(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ee(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(bn,"parseShadow");function ke(e){let n=(0,N.createDeth)(e),o={};for(let r of Object.keys(N.levelValues))o[r]={type:"shadow",value:bn(n(r))};return o}s(ke,"buildShadow");function L(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${k(t)}`:k(t);if(b(i)){o.add(a);let c=q[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=L(i,a,o)}return r}s(L,"decorateGroup");function Rn(e){let n=new Set,o=L(e.primitives,"",n),r=L(e.groups,"",n);return K(n),{...e,primitives:o,groups:r}}s(Rn,"decorateMeta");function B(e,n){return L(e,"",n)}s(B,"decorateSlice");function Se(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${k(r)}`:k(r);b(t)?o.add(i):Se(t,i,o)}}s(Se,"collectPaths");function xe(e){let n=new Set;for(let o of e)Se(o.groups,"",n);K(n)}s(xe,"assertSlicesMetaComplete");function Te(){let e=ge(),o=Re({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:B({"border-width":e,border:o.group},t),extensions:r}}s(Te,"buildBaseIR");function De(e){let n=Ie(e),o=new Set;return{groups:B({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(De,"buildFontIR");function ve(e,n){let o=fe(n),r=new Set;return{groups:B({color:o,bg:P(e.bg,n,ye),text:P(e.text,n,he),tx:pe(n),shadow:ke(n)},r),extensions:{}}}s(ve,"buildColorIR");function we(e,n){let o=me(n),r={space:o},t=new Set;return{groups:B({space:o,spacing:ne(e.spacing,r,be)},t),extensions:{}}}s(we,"buildSpacingIR");function In(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=fn(n,o.dimension),i=Re(t),a=Ie(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:P(e.bg,n,ye),text:P(e.text,n,he),tx:pe(n),spacing:ne(e.spacing,t,be),border:i.group,font:a.group,shadow:ke(n)},extensions:c};return Rn(d)}s(In,"buildIR");var Ce=In;var kn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Ve(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,k(r)];b(t)?o.push(` --apollion-${i.join("-")}: ${$(t.value)};`):Ve(t,i,o)}}s(Ve,"emitVars");function $e(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,k(r)];b(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(t.value)}; }`):$e(t,i,o)}}s($e,"emitProperties");function Ge(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[kn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),Ve(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),$e(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(
|
|
4
|
-
`}s(
|
|
5
|
-
`)}
|
|
6
|
-
|
|
1
|
+
"use strict";var P=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var xn=Object.prototype.hasOwnProperty;var s=(e,n)=>P(e,"name",{value:n,configurable:!0});var wn=(e,n)=>{for(var o in n)P(e,o,{get:n[o],enumerable:!0})},Tn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Sn(n))!xn.call(e,t)&&t!==o&&P(e,t,{get:()=>n[t],enumerable:!(r=kn(n,t))||r.enumerable});return e};var vn=e=>Tn(P({},"__esModule",{value:!0}),e);var lo={};wn(lo,{build:()=>so,check:()=>ao});module.exports=vn(lo);var b=require("node:fs/promises"),In=require("node:os"),v=require("node:path");var U=require("culori");var L=require("@apollion-dsi/core/themes/border"),Re=require("@apollion-dsi/core/themes/colors"),J=require("@apollion-dsi/core/themes/depth"),T=require("@apollion-dsi/core/themes/font"),ie=require("@apollion-dsi/core/themes/spacing"),M=require("culori");var be=require("@apollion-dsi/core/themes/dimension");function _({multiplier:e=.25,alias:n},o){let r=o!==void 0?be.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(_,"createSpacing");var re={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function te(e){let n=Object.keys(re).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(te,"assertTokenMetaResolves");var Dn=(0,M.converter)("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function S(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(S,"kebab");function Ie(e){return e.split(".").map(S).join(".")}s(Ie,"kebabPath");function E(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(E,"rawValue");function B(e,n){return Number(e.toFixed(n))||0}s(B,"round");function ae(e){let n=Dn((0,M.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[B(n.l,4),B(n.c,4),B(n.h??0,2)],r=(0,M.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:B(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ae,"toColorValue");var ke=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function O(e){let n=ke.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(O,"toDimensionValue");function k(e){return{type:"color",value:ae(e)}}s(k,"colorToken");function se(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(se,"recordColorGroup");function Se(e){let n=(0,Re.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=se(n.neutral),o}s(Se,"buildReadableTextGroup");var $n=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function xe(e){let n={};for(let o of $n){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=se(e.grayscale),n.neutral=se(e.neutral),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}s(xe,"buildColorPrimitives");function we(e){let n=_(ie.defaultInputSpacing,e),o={};for(let r of Object.keys(ie.defaultInputSpacing.alias))o[r]={type:"dimension",value:O(n(r))};return o}s(we,"buildSpacePrimitives");function Te(){let e={};for(let[n,o]of Object.entries(L.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:O(o)};return e}s(Te,"buildBorderWidthPrimitives");function Cn(e,n){return{color:xe(e),space:we(n),borderWidth:Te()}}s(Cn,"buildPrimitives");var ve={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},De={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Vn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(Vn,"lookupPrimitive");function H(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Vn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ae(i)}}:k(i)}return r}s(H,"colorRefGroup");var $e={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},On={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function En(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(En,"lookupDimensionPrimitive");function ce(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?En(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:O(i)}}:{type:"dimension",value:O(i)}}return r}s(ce,"dimensionRefGroup");function Ce(e){let n={},o={};for(let[i,a]of Object.entries(L.defaultInputBorder.borderRadius))ke.test(a)?n[i]={type:"dimension",value:O(a)}:o[i]=a;let r=ce(L.defaultInputBorder.borderWidth,e,On),t={};for(let[i,a]of Object.entries(L.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Ce,"buildBorder");function Ve(e){let n=(0,T.createFont)(T.defaultInputFont,e),o={};for(let[c,l]of Object.entries(T.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:O(l)};let t={};for(let[c,l]of Object.entries(T.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(T.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:T.defaultInputFont.letterSpacing,textTransform:T.defaultInputFont.textTransform,fontStyle:T.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Ve,"buildFont");var Gn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Mn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Gn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>O(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ae(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Mn,"parseShadow");function Oe(e){let n=(0,J.createDeth)(e),o={};for(let r of Object.keys(J.levelValues))o[r]={type:"shadow",value:Mn(n(r))};return o}s(Oe,"buildShadow");function W(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${S(t)}`:S(t);if(h(i)){o.add(a);let c=re[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=W(i,a,o)}return r}s(W,"decorateGroup");function jn(e){let n=new Set,o=W(e.primitives,"",n),r=W(e.groups,"",n);return te(n),{...e,primitives:o,groups:r}}s(jn,"decorateMeta");function z(e,n){return W(e,"",n)}s(z,"decorateSlice");function Ee(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${S(r)}`:S(r);h(t)?o.add(i):Ee(t,i,o)}}s(Ee,"collectPaths");function Ge(e){let n=new Set;for(let o of e)Ee(o.groups,"",n);te(n)}s(Ge,"assertSlicesMetaComplete");function Me(){let e=Te(),o=Ce({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:z({"border-width":e,border:o.group},t),extensions:r}}s(Me,"buildBaseIR");function je(e){let n=Ve(e),o=new Set;return{groups:z({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(je,"buildFontIR");function Ae(e,n){let o=xe(n),r=new Set;return{groups:z({color:o,bg:H(e.bg,n,ve),text:H(e.text,n,De),tx:Se(n),shadow:Oe(n)},r),extensions:{}}}s(Ae,"buildColorIR");function Le(e,n){let o=we(n),r={space:o},t=new Set;return{groups:z({space:o,spacing:ce(e.spacing,r,$e)},t),extensions:{}}}s(Le,"buildSpacingIR");function An(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=Cn(n,o.dimension),i=Ce(t),a=Ve(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:H(e.bg,n,ve),text:H(e.text,n,De),tx:Se(n),spacing:ce(e.spacing,t,$e),border:i.group,font:a.group,shadow:Oe(n)},extensions:c};return jn(l)}s(An,"buildIR");var q=An;var Ln=(0,U.converter)("rgb"),Ne="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function le(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(le,"colorPayload");function de(e){return e.alpha===void 0}s(de,"isOpaqueColor");function Fe(e){let n=Ln((0,U.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Fe,"rgbTriplet");function X(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,S(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of X(t,i))o.set(a,c)}return o}s(X,"flatTokens");function y(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(y,"groupAt");function Pe(e){let n=[];for(let o of["bg","text","tx"])for(let[r,t]of X(y(e.groups,o),[o])){let i=le(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:de(i)})}return n}s(Pe,"colorEntries");function $(e,n){return[...X(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s($,"varEntries");function C(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(C,"pushScale");function _e(e){let n=[Ne,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Pe(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),C(n,"spacing",$(y(e.groups,"spacing"),["spacing"])),C(n,"borderRadius",$(y(e.groups,"border","radius"),["border","radius"])),C(n,"borderWidth",$(y(e.groups,"border","width"),["border","width"])),C(n,"fontFamily",$(y(e.groups,"font","family"),["font","family"])),C(n,"fontSize",$(y(e.groups,"font","size"),["font","size"])),C(n,"fontWeight",$(y(e.groups,"font","weight"),["font","weight"])),C(n,"lineHeight",$(y(e.groups,"font","lineHeight"),["font","line-height"])),C(n,"boxShadow",$(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(_e,"renderTailwindPreset");function Be(e){let n=s(t=>[...X(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[Ne,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(Pe(e).map(t=>t.key))},`,` spacing: ${o(n(y(e.groups,"spacing")))},`,` borderRadius: ${o(n(y(e.groups,"border","radius")))},`,` borderWidth: ${o(n(y(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(y(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(y(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(y(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(y(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(y(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(Be,"renderTwMergeExtension");var Nn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function He(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,S(r)];h(t)?o.push(` --apollion-${i.join("-")}: ${E(t.value)};`):He(t,i,o)}}s(He,"emitVars");function We(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,S(r)];if(!h(t)){We(t,i,o);continue}let a=le(t);a&&de(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${Fe(a)};`)}}s(We,"emitRgbVars");function Je(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,S(r)];h(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${E(t.value)}; }`):Je(t,i,o)}}s(Je,"emitProperties");function ze(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[Nn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),He(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),We(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Je(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(ze,"renderCss");var Fn="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function ue(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;h(t)?o.push([i,E(t.value)]):ue(t,i,o)}}s(ue,"flatten");function Pn(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(Pn,"yamlEscape");function _n(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(_n,"variantKey");function qe(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let i=[];ue(t.groups,"",i),o.push(` ${_n(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${Pn(c)}`)}o.push("---");let r=["",Fn,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];ue(t.groups,"",l);let m=new Map;for(let[I,D]of l){let d=I.split(".")[0]??I,f=m.get(d)??[];f.push([I,D]),m.set(d,f)}for(let[I,D]of m){r.push(`### ${I}`,"","| Token | Value |","| --- | --- |");for(let[d,f]of D)r.push(`| \`${d}\` | \`${f}\` |`);r.push("")}}return`${o.join(`
|
|
5
|
+
`)}
|
|
6
|
+
${r.join(`
|
|
7
|
+
`)}`}s(qe,"renderDesignMd");function Ue(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}s(Ue,"colorValue");function N(e){return{value:e.value,unit:e.unit}}s(N,"dimensionValue");function Bn(e){let n=e.shadow,o={color:Ue(n.color),offsetX:N(n.offsetX),offsetY:N(n.offsetY),blur:N(n.blur),spread:N(n.spread)};return n.inset&&(o.inset=!0),o}s(Bn,"shadowValue");function Hn(e){switch(e.kind){case"ref":return`{${Ie(e.path)}}`;case"color":return Ue(e);case"dimension":return N(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Bn(e)}}s(Hn,"projectValue");function Wn(e){let n={$value:Hn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Wn,"projectToken");function pe(e){let n={};for(let[o,r]of Object.entries(e))n[S(o)]=h(r)?Wn(r):pe(r);return n}s(pe,"projectGroup");function Y(e,n){let o={$description:n,...pe(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
8
|
+
`}s(Y,"renderSet");function Xe(e){return Y(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Xe,"renderBaseSet");function Ye(e,n,o,r){return Y(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(Ye,"renderColorSet");function Ke(e,n){return Y(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Ke,"renderSpacingSet");function Ze(e,n){return Y(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(Ze,"renderFontSet");function Qe(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
|
|
9
|
+
`}s(Qe,"renderResolver");var Jn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function zn(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(zn,"emitDoc");function en(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))h(i)?(zn(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(E(i.value))},`)):(o.push(`${r}${t}: {`),en(i,n+1,o),o.push(`${r}},`))}s(en,"emitGroup");function nn(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[Jn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return en(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
10
|
+
`)}s(nn,"renderTs");var qn=["light","dark"],Un=["positive","negative"],Xn=["compact","normal","spacious"];function K(e){let n=e.modes??qn,o=e.surfaces??Un,r=e.dimensions??Xn,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let I of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:I});return i}s(K,"expandVariants");function on(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(on,"variantName");var rn=require("node:crypto");function Z(e){return(0,rn.createHash)("sha256").update(e).digest("hex")}s(Z,"sha256");function me(e){return Z(fe(e))}s(me,"hashConfig");function fe(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(fe).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${fe(e[r])}`).join(",")}}`}s(fe,"stableStringify");function tn(e){try{let{execSync:n}=require("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(tn,"detectGitCommit");function sn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(sn,"buildEnv");function an(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
11
|
+
`}s(an,"serializeManifest");var Yn="json/sets",cn="json/resolver.json";function Q(e){return`${Yn}/${e}.json`}s(Q,"setFile");function Kn(e,n,o){return`${e}.color.${n}.${o}`}s(Kn,"colorSetName");function Zn(e){return`spacing.${e}`}s(Zn,"spacingSetName");function Qn(e){return`font.${e}`}s(Qn,"fontSetName");function ee(e,n){e.includes(n)||e.push(n)}s(ee,"pushUnique");function ln(e){let n=K(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],I=new Set,D=[];for(let d of n){ee(o,d.brand),ee(r,d.mode),ee(t,d.surface),ee(i,d.dimension);let f=Kn(d.brand,d.mode,d.surface);a.has(f)||(a.add(f),c.push({kind:"color",name:f,file:Q(f),brand:d.brand,mode:d.mode,surface:d.surface}));let x=Zn(d.dimension);l.has(x)||(l.add(x),m.push({kind:"spacing",name:x,file:Q(x),dimension:d.dimension}));let p=Qn(d.dimension);I.has(p)||(I.add(p),D.push({kind:"font",name:p,file:Q(p),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:Q("base")},spacing:m,font:D,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(ln,"planSets");var ye=require("@apollion-dsi/core/themes/foundation"),yn=require("@apollion-dsi/core/themes/semantic"),bn=require("@apollion-dsi/core/themes/spacing"),Rn=require("@apollion-dsi/core/themes/surface");var g=require("culori");var he=(0,g.converter)("oklch");function u(e,n,o){let r=(0,g.parse)(e),t=(0,g.parse)(n);if(!r||!t)return e;let i=(0,g.interpolate)([r,t],"oklch");return(0,g.formatHex)(i(o))??e}s(u,"mixOklch");function eo(e){return e?typeof e=="string"?e:e.base:"#000"}s(eo,"coerceToHex");var ne=1.3,no=.05,dn=.04,V=s((e,n)=>{let o=(0,g.parse)(e),r=(0,g.parse)(n);return!o||!r?1:(0,g.wcagContrast)(o,r)},"contrastRatio"),ge=s(e=>{let n=he((0,g.parse)(e));return n?n.l??0:null},"oklchLightness"),oo=4.5;function un(e,n,o=oo){let r=(0,g.parse)(n),t=he((0,g.parse)(e));if(!r||!t)return e;let i=V("#fff",n)>=V("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,g.formatHex)(t)??e,l=(0,g.parse)(c);if(l&&(0,g.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,g.formatHex)(t)??e}s(un,"readableColor");var pn=s((e,n)=>{if(V(e,n)>=ne)return!0;let o=ge(e),r=ge(n);return o!==null&&r!==null&&Math.abs(o-r)>=no},"isPerceptibleState"),ro=s(e=>e?V("#fff",e)>V("#000",e):!1,"isDarkSurface");function fn(e,n,o){let r=he((0,g.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?dn:-dn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,g.formatHex)(t);if(l&&V(e,l)>=ne)return l}return(0,g.formatHex)(t)??null}s(fn,"derivePerceptibleState");function mn(e,n,o){let r=fn(e,n,o);if(r&&V(e,r)>=ne)return r;let t=fn(e,!n);return t&&V(e,t)>=ne?t:r??t}s(mn,"perceptibleStateFor");function w(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=eo(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:u(r,t,.6),action:u(r,t,.2),active:u(r,i,.6),light:u(r,i,.9),onLight:r};if((0,g.parse)(r)){let c=ro(n.baseLight),l=pn(r,a.action);if(l||(a.action=mn(r,c)??a.action),!pn(r,a.active)){let m=l?void 0:ge(a.action)??void 0;a.active=mn(r,c,m)??a.active}}if(a.onLight=un(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??un(c,l)}}return a}s(w,"mountSingleColor");function gn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:u(n,o,.05),10:u(n,o,.1),20:u(n,o,.2),30:u(n,o,.3),40:u(n,o,.4),50:u(n,o,.5),60:u(n,o,.6),70:u(n,o,.7),80:u(n,o,.8),90:u(n,o,.9),100:u(n,o,1)}}s(gn,"mountGreyscaleColors");function hn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=u(r,o,.5);return{0:u(i,n,t(18)),5:u(i,n,t(17.5)),10:u(i,n,t(17)),20:u(i,n,t(16)),30:u(i,n,t(15)),40:u(i,n,t(14)),50:u(i,n,t(13)),60:u(i,n,t(12)),70:u(i,n,t(11)),80:u(i,n,t(10)),90:u(i,n,t(9)),100:u(i,n,t(8)),110:u(i,n,t(7)),120:u(i,n,t(6)),130:u(i,n,t(5)),140:u(i,n,t(4)),150:u(i,n,t(3)),160:u(i,n,t(2)),170:i,180:u(i,o,.25)}}s(hn,"mountNeutralColors");function to(e){return{...e,baseDark:e.baseLight,baseLight:e.baseDark,deepDark:e.deepLight,deepLight:e.deepDark}}s(to,"toCanonicalDarkInput");function io(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:hn(e),grayscale:gn(e),main:w(e.main,e),opposite:w(e.opposite,e),complementary:w(e.complementary,e),danger:w(e.danger,e),information:w(e.information,e),success:w(e.success,e),warning:w(e.warning,e),primary:w(e.primary,e),secondary:w(e.secondary,e),tertiary:w(e.tertiary,e)}}s(io,"composeColors");function j(e,n=bn.defaultInputSpacing){let o=e.mode==="dark"?to(e.colors):e.colors,r=io(o),t=_(n,e.dimension),i=(0,yn.createSemantic)({colors:r,spacing:t}),a=(0,ye.createFoundation)(i);return e.surface==="negative"&&(a=(0,ye.createFoundation)((0,Rn.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(j,"buildVariantThemes");async function so(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=K(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,b.mkdtemp)((0,v.join)((0,In.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(d,f)=>{await co(c,d,f),l.push({path:d,sha256:Z(f)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=ln(n),f=[],x=Me();f.push(x),await m(d.base.file,Xe(x));for(let p of d.spacing){let R=i.find(F=>F.dimension===p.dimension),{foundation:A}=j(R),G=Le(A,p.dimension);f.push(G),await m(p.file,Ke(G,p.dimension))}for(let p of d.font){let R=je(p.dimension);f.push(R),await m(p.file,Ze(R,p.dimension))}for(let p of d.color){let R=i.find(oe=>oe.brand===p.brand&&oe.mode===p.mode&&oe.surface===p.surface),{foundation:A,colors:G}=j(R),F=Ae(A,G);f.push(F),await m(p.file,Ye(F,p.brand,p.mode,p.surface))}Ge(f),await m(cn,Qe(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:f,colors:x}=j(d),p=q(f,x,d),R=on(d);a.css&&await m(`css/${R}.css`,ze(p,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${R}.d.ts`,nn(p))}if(a.tailwind){let d=i[0],{foundation:f,colors:x}=j(d),p=q(f,x,d);await m("tailwind/preset.mjs",_e(p)),await m("tailwind/tw-merge.mjs",Be(p))}if(a.designMd){let d=[...new Set(i.map(f=>f.brand))];for(let f of d){let p=i.filter(R=>R.brand===f).map(R=>{let{foundation:A,colors:G}=j(R);return q(A,G,R)});await m(`design/${f}.design.md`,qe(f,p))}}let I={configHash:me(n),files:l,gitCommit:tn(r),buildEnv:sn()},D=an(I);return await(0,b.writeFile)((0,v.join)(c,"manifest.json"),D),await(0,b.rm)(o,{recursive:!0,force:!0}),await(0,b.mkdir)((0,v.dirname)(o),{recursive:!0}),await(0,b.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:I,outDir:o}}catch(l){throw await(0,b.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(so,"build");async function ao(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,b.readFile)((0,v.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==me(n))return!1;for(let t of r.files){let i;try{i=await(0,b.readFile)((0,v.join)(o,t.path))}catch{return!1}if(Z(i)!==t.sha256)return!1}return!0}s(ao,"check");async function co(e,n,o){let r=(0,v.join)(e,n);await(0,b.mkdir)((0,v.dirname)(r),{recursive:!0}),await(0,b.writeFile)(r,o)}s(co,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
var Ze=Object.defineProperty;var s=(e,n)=>Ze(e,"name",{value:n,configurable:!0}),Qe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as Ye,mkdtemp as _n,readFile as Hn,rename as Wn,rm as Xe,writeFile as qe}from"node:fs/promises";import{tmpdir as Jn}from"node:os";import{dirname as Ke,join as H}from"node:path";import{defaultInputBorder as E}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as nn}from"@apollion-dsi/core/themes/colors";import{createDeth as on,levelValues as rn}from"@apollion-dsi/core/themes/depth";import{createFont as tn,defaultInputFont as S}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as re}from"@apollion-dsi/core/themes/spacing";import{converter as sn,formatHex as an,parse as cn}from"culori";import{DIMENSION_MULTIPLIERS as en}from"@apollion-dsi/core/themes/dimension";function G({multiplier:e=.25,alias:n},o){let r=o!==void 0?en[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(G,"createSpacing");var U={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function z(e){let n=Object.keys(U).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(z,"assertTokenMetaResolves");var ln=sn("oklch");function y(e){return typeof e.type=="string"&&"value"in e}s(y,"isToken");function b(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(b,"kebab");function te(e){return e.split(".").map(b).join(".")}s(te,"kebabPath");function v(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(v,"rawValue");function O(e,n){return Number(e.toFixed(n))||0}s(O,"round");function Y(e){let n=ln(cn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[O(n.l,4),O(n.c,4),O(n.h??0,2)],r=an(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:O(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(Y,"toColorValue");var ie=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function x(e){let n=ie.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(x,"toDimensionValue");function g(e){return{type:"color",value:Y(e)}}s(g,"colorToken");function X(e){let n={};for(let[o,r]of Object.entries(e))n[o]=g(r);return n}s(X,"recordColorGroup");function se(e){let n=nn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=g(t);return o.neutral=X(n.neutral),o}s(se,"buildReadableTextGroup");var dn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ae(e){let n={};for(let o of dn){let r=e[o];n[o]={base:g(r.base),dark:g(r.dark),action:g(r.action),active:g(r.active),light:g(r.light)}}return n.grayscale=X(e.grayscale),n.neutral=X(e.neutral),n.baseDark=g(e.baseDark??"#000000"),n.baseLight=g(e.baseLight??"#ffffff"),n.deepDark=g(e.deepDark??"#000000"),n.deepLight=g(e.deepLight??"#ffffff"),n}s(ae,"buildColorPrimitives");function ce(e){let n=G(re,e),o={};for(let r of Object.keys(re.alias))o[r]={type:"dimension",value:x(n(r))};return o}s(ce,"buildSpacePrimitives");function le(){let e={};for(let[n,o]of Object.entries(E.borderWidth))e[n]={type:"dimension",value:x(o)};return e}s(le,"buildBorderWidthPrimitives");function un(e,n){return{color:ae(e),space:ce(n),borderWidth:le()}}s(un,"buildPrimitives");var de={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},ue={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function pn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(pn,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?pn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:Y(i)}}:g(i)}return r}s(F,"colorRefGroup");var pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},fn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function mn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!y(t)&&i in t)t=t[i];else return;return t&&y(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(mn,"lookupDimensionPrimitive");function q(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?mn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:x(i)}}:{type:"dimension",value:x(i)}}return r}s(q,"dimensionRefGroup");function fe(e){let n={},o={};for(let[i,a]of Object.entries(E.borderRadius))ie.test(a)?n[i]={type:"dimension",value:x(a)}:o[i]=a;let r=q(E.borderWidth,e,fn),t={};for(let[i,a]of Object.entries(E.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(fe,"buildBorder");function me(e){let n=tn(S,e),o={};for(let[c,d]of Object.entries(S.fontFamily)){let f=d.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,d]of Object.entries(n.fontSize))r[c]={type:"dimension",value:x(d)};let t={};for(let[c,d]of Object.entries(S.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${d}`,weight:d}};let i={};for(let[c,d]of Object.entries(S.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${d}`,number:d}};let a={letterSpacing:S.letterSpacing,textTransform:S.textTransform,fontStyle:S.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(me,"buildFont");var gn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function yn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(gn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(d=>x(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Y(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(yn,"parseShadow");function ge(e){let n=on(e),o={};for(let r of Object.keys(rn))o[r]={type:"shadow",value:yn(n(r))};return o}s(ge,"buildShadow");function M(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${b(t)}`:b(t);if(y(i)){o.add(a);let c=U[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=M(i,a,o)}return r}s(M,"decorateGroup");function hn(e){let n=new Set,o=M(e.primitives,"",n),r=M(e.groups,"",n);return z(n),{...e,primitives:o,groups:r}}s(hn,"decorateMeta");function j(e,n){return M(e,"",n)}s(j,"decorateSlice");function ye(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${b(r)}`:b(r);y(t)?o.add(i):ye(t,i,o)}}s(ye,"collectPaths");function he(e){let n=new Set;for(let o of e)ye(o.groups,"",n);z(n)}s(he,"assertSlicesMetaComplete");function be(){let e=le(),o=fe({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:j({"border-width":e,border:o.group},t),extensions:r}}s(be,"buildBaseIR");function Re(e){let n=me(e),o=new Set;return{groups:j({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Re,"buildFontIR");function Ie(e,n){let o=ae(n),r=new Set;return{groups:j({color:o,bg:F(e.bg,n,de),text:F(e.text,n,ue),tx:se(n),shadow:ge(n)},r),extensions:{}}}s(Ie,"buildColorIR");function ke(e,n){let o=ce(n),r={space:o},t=new Set;return{groups:j({space:o,spacing:q(e.spacing,r,pe)},t),extensions:{}}}s(ke,"buildSpacingIR");function bn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=un(n,o.dimension),i=fe(t),a=me(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,de),text:F(e.text,n,ue),tx:se(n),spacing:q(e.spacing,t,pe),border:i.group,font:a.group,shadow:ge(n)},extensions:c};return hn(d)}s(bn,"buildIR");var Se=bn;var Rn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function xe(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?o.push(` --apollion-${i.join("-")}: ${v(t.value)};`):xe(t,i,o)}}s(xe,"emitVars");function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${v(t.value)}; }`):Te(t,i,o)}}s(Te,"emitProperties");function De(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[Rn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),xe(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Te(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(
|
|
4
|
-
`}s(
|
|
5
|
-
`)}
|
|
6
|
-
|
|
1
|
+
var hn=Object.defineProperty;var s=(e,n)=>hn(e,"name",{value:n,configurable:!0}),yn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as fn,mkdtemp as mo,readFile as un,rename as go,rm as pn,writeFile as mn}from"node:fs/promises";import{tmpdir as ho}from"node:os";import{dirname as gn,join as A}from"node:path";import{converter as An,parse as Ln}from"culori";import{defaultInputBorder as P}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Rn}from"@apollion-dsi/core/themes/colors";import{createDeth as In,levelValues as kn}from"@apollion-dsi/core/themes/depth";import{createFont as Sn,defaultInputFont as $}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as pe}from"@apollion-dsi/core/themes/spacing";import{converter as xn,formatHex as wn,parse as Tn}from"culori";import{DIMENSION_MULTIPLIERS as bn}from"@apollion-dsi/core/themes/dimension";function N({multiplier:e=.25,alias:n},o){let r=o!==void 0?bn[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(N,"createSpacing");var Q={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function ee(e){let n=Object.keys(Q).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(ee,"assertTokenMetaResolves");var vn=xn("oklch");function g(e){return typeof e.type=="string"&&"value"in e}s(g,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function fe(e){return e.split(".").map(I).join(".")}s(fe,"kebabPath");function V(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(V,"rawValue");function F(e,n){return Number(e.toFixed(n))||0}s(F,"round");function oe(e){let n=vn(Tn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[F(n.l,4),F(n.c,4),F(n.h??0,2)],r=wn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:F(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(oe,"toColorValue");var me=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function C(e){let n=me.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(C,"toDimensionValue");function R(e){return{type:"color",value:oe(e)}}s(R,"colorToken");function ne(e){let n={};for(let[o,r]of Object.entries(e))n[o]=R(r);return n}s(ne,"recordColorGroup");function ge(e){let n=Rn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=R(t);return o.neutral=ne(n.neutral),o}s(ge,"buildReadableTextGroup");var Dn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function he(e){let n={};for(let o of Dn){let r=e[o];n[o]={base:R(r.base),dark:R(r.dark),action:R(r.action),active:R(r.active),light:R(r.light),onLight:R(r.onLight)}}return n.grayscale=ne(e.grayscale),n.neutral=ne(e.neutral),n.baseDark=R(e.baseDark??"#000000"),n.baseLight=R(e.baseLight??"#ffffff"),n.deepDark=R(e.deepDark??"#000000"),n.deepLight=R(e.deepLight??"#ffffff"),n}s(he,"buildColorPrimitives");function ye(e){let n=N(pe,e),o={};for(let r of Object.keys(pe.alias))o[r]={type:"dimension",value:C(n(r))};return o}s(ye,"buildSpacePrimitives");function be(){let e={};for(let[n,o]of Object.entries(P.borderWidth))e[n]={type:"dimension",value:C(o)};return e}s(be,"buildBorderWidthPrimitives");function $n(e,n){return{color:he(e),space:ye(n),borderWidth:be()}}s($n,"buildPrimitives");var Re={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},Ie={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Cn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(Cn,"lookupPrimitive");function _(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Cn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:oe(i)}}:R(i)}return r}s(_,"colorRefGroup");var ke={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Vn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function On(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!g(t)&&i in t)t=t[i];else return;return t&&g(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(On,"lookupDimensionPrimitive");function re(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?On(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:C(i)}}:{type:"dimension",value:C(i)}}return r}s(re,"dimensionRefGroup");function Se(e){let n={},o={};for(let[i,a]of Object.entries(P.borderRadius))me.test(a)?n[i]={type:"dimension",value:C(a)}:o[i]=a;let r=re(P.borderWidth,e,Vn),t={};for(let[i,a]of Object.entries(P.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Se,"buildBorder");function xe(e){let n=Sn($,e),o={};for(let[c,l]of Object.entries($.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:C(l)};let t={};for(let[c,l]of Object.entries($.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries($.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:$.letterSpacing,textTransform:$.textTransform,fontStyle:$.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(xe,"buildFont");var En=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Gn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(En),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>C(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:oe(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Gn,"parseShadow");function we(e){let n=In(e),o={};for(let r of Object.keys(kn))o[r]={type:"shadow",value:Gn(n(r))};return o}s(we,"buildShadow");function B(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(g(i)){o.add(a);let c=Q[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=B(i,a,o)}return r}s(B,"decorateGroup");function Mn(e){let n=new Set,o=B(e.primitives,"",n),r=B(e.groups,"",n);return ee(n),{...e,primitives:o,groups:r}}s(Mn,"decorateMeta");function H(e,n){return B(e,"",n)}s(H,"decorateSlice");function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);g(t)?o.add(i):Te(t,i,o)}}s(Te,"collectPaths");function ve(e){let n=new Set;for(let o of e)Te(o.groups,"",n);ee(n)}s(ve,"assertSlicesMetaComplete");function De(){let e=be(),o=Se({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:H({"border-width":e,border:o.group},t),extensions:r}}s(De,"buildBaseIR");function $e(e){let n=xe(e),o=new Set;return{groups:H({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s($e,"buildFontIR");function Ce(e,n){let o=he(n),r=new Set;return{groups:H({color:o,bg:_(e.bg,n,Re),text:_(e.text,n,Ie),tx:ge(n),shadow:we(n)},r),extensions:{}}}s(Ce,"buildColorIR");function Ve(e,n){let o=ye(n),r={space:o},t=new Set;return{groups:H({space:o,spacing:re(e.spacing,r,ke)},t),extensions:{}}}s(Ve,"buildSpacingIR");function jn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=$n(n,o.dimension),i=Se(t),a=xe(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:_(e.bg,n,Re),text:_(e.text,n,Ie),tx:ge(n),spacing:re(e.spacing,t,ke),border:i.group,font:a.group,shadow:we(n)},extensions:c};return Mn(l)}s(jn,"buildIR");var W=jn;var Nn=An("rgb"),Oe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function te(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(te,"colorPayload");function ie(e){return e.alpha===void 0}s(ie,"isOpaqueColor");function Ee(e){let n=Nn(Ln(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Ee,"rgbTriplet");function J(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(g(t))o.set(i.join("-"),t);else for(let[a,c]of J(t,i))o.set(a,c)}return o}s(J,"flatTokens");function h(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||g(o))return{};o=o[r]}return o&&!g(o)?o:{}}s(h,"groupAt");function Ge(e){let n=[];for(let o of["bg","text","tx"])for(let[r,t]of J(h(e.groups,o),[o])){let i=te(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:ie(i)})}return n}s(Ge,"colorEntries");function T(e,n){return[...J(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(T,"varEntries");function v(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(v,"pushScale");function Me(e){let n=[Oe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ge(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),v(n,"spacing",T(h(e.groups,"spacing"),["spacing"])),v(n,"borderRadius",T(h(e.groups,"border","radius"),["border","radius"])),v(n,"borderWidth",T(h(e.groups,"border","width"),["border","width"])),v(n,"fontFamily",T(h(e.groups,"font","family"),["font","family"])),v(n,"fontSize",T(h(e.groups,"font","size"),["font","size"])),v(n,"fontWeight",T(h(e.groups,"font","weight"),["font","weight"])),v(n,"lineHeight",T(h(e.groups,"font","lineHeight"),["font","line-height"])),v(n,"boxShadow",T(h(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(Me,"renderTailwindPreset");function je(e){let n=s(t=>[...J(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[Oe,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(Ge(e).map(t=>t.key))},`,` spacing: ${o(n(h(e.groups,"spacing")))},`,` borderRadius: ${o(n(h(e.groups,"border","radius")))},`,` borderWidth: ${o(n(h(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(h(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(h(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(h(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(h(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(h(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(je,"renderTwMergeExtension");var Fn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Ae(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];g(t)?o.push(` --apollion-${i.join("-")}: ${V(t.value)};`):Ae(t,i,o)}}s(Ae,"emitVars");function Le(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(!g(t)){Le(t,i,o);continue}let a=te(t);a&&ie(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${Ee(a)};`)}}s(Le,"emitRgbVars");function Ne(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];g(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${V(t.value)}; }`):Ne(t,i,o)}}s(Ne,"emitProperties");function Fe(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[Fn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),Ae(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),Le(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Ne(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(Fe,"renderCss");var Pn="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function se(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;g(t)?o.push([i,V(t.value)]):se(t,i,o)}}s(se,"flatten");function _n(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(_n,"yamlEscape");function Bn(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(Bn,"variantKey");function Pe(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let i=[];se(t.groups,"",i),o.push(` ${Bn(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${_n(c)}`)}o.push("---");let r=["",Pn,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];se(t.groups,"",l);let m=new Map;for(let[b,w]of l){let d=b.split(".")[0]??b,f=m.get(d)??[];f.push([b,w]),m.set(d,f)}for(let[b,w]of m){r.push(`### ${b}`,"","| Token | Value |","| --- | --- |");for(let[d,f]of w)r.push(`| \`${d}\` | \`${f}\` |`);r.push("")}}return`${o.join(`
|
|
5
|
+
`)}
|
|
6
|
+
${r.join(`
|
|
7
|
+
`)}`}s(Pe,"renderDesignMd");function _e(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}s(_e,"colorValue");function M(e){return{value:e.value,unit:e.unit}}s(M,"dimensionValue");function Hn(e){let n=e.shadow,o={color:_e(n.color),offsetX:M(n.offsetX),offsetY:M(n.offsetY),blur:M(n.blur),spread:M(n.spread)};return n.inset&&(o.inset=!0),o}s(Hn,"shadowValue");function Wn(e){switch(e.kind){case"ref":return`{${fe(e.path)}}`;case"color":return _e(e);case"dimension":return M(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Hn(e)}}s(Wn,"projectValue");function Jn(e){let n={$value:Wn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Jn,"projectToken");function ae(e){let n={};for(let[o,r]of Object.entries(e))n[I(o)]=g(r)?Jn(r):ae(r);return n}s(ae,"projectGroup");function z(e,n){let o={$description:n,...ae(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
8
|
+
`}s(z,"renderSet");function Be(e){return z(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Be,"renderBaseSet");function He(e,n,o,r){return z(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(He,"renderColorSet");function We(e,n){return z(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(We,"renderSpacingSet");function Je(e,n){return z(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(Je,"renderFontSet");function ze(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
|
|
9
|
+
`}s(ze,"renderResolver");var zn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function qn(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(qn,"emitDoc");function qe(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))g(i)?(qn(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(V(i.value))},`)):(o.push(`${r}${t}: {`),qe(i,n+1,o),o.push(`${r}},`))}s(qe,"emitGroup");function Ue(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[zn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return qe(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
10
|
+
`)}s(Ue,"renderTs");var Un=["light","dark"],Xn=["positive","negative"],Yn=["compact","normal","spacious"];function q(e){let n=e.modes??Un,o=e.surfaces??Xn,r=e.dimensions??Yn,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let b of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:b});return i}s(q,"expandVariants");function Xe(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Xe,"variantName");import{createHash as Kn}from"node:crypto";function U(e){return Kn("sha256").update(e).digest("hex")}s(U,"sha256");function le(e){return U(ce(e))}s(le,"hashConfig");function ce(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(ce).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${ce(e[r])}`).join(",")}}`}s(ce,"stableStringify");function Ye(e){try{let{execSync:n}=yn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(Ye,"detectGitCommit");function Ke(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Ke,"buildEnv");function Ze(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
11
|
+
`}s(Ze,"serializeManifest");var Zn="json/sets",Qe="json/resolver.json";function X(e){return`${Zn}/${e}.json`}s(X,"setFile");function Qn(e,n,o){return`${e}.color.${n}.${o}`}s(Qn,"colorSetName");function eo(e){return`spacing.${e}`}s(eo,"spacingSetName");function no(e){return`font.${e}`}s(no,"fontSetName");function Y(e,n){e.includes(n)||e.push(n)}s(Y,"pushUnique");function en(e){let n=q(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],b=new Set,w=[];for(let d of n){Y(o,d.brand),Y(r,d.mode),Y(t,d.surface),Y(i,d.dimension);let f=Qn(d.brand,d.mode,d.surface);a.has(f)||(a.add(f),c.push({kind:"color",name:f,file:X(f),brand:d.brand,mode:d.mode,surface:d.surface}));let k=eo(d.dimension);l.has(k)||(l.add(k),m.push({kind:"spacing",name:k,file:X(k),dimension:d.dimension}));let p=no(d.dimension);b.has(p)||(b.add(p),w.push({kind:"font",name:p,file:X(p),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:X("base")},spacing:m,font:w,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(en,"planSets");import{createFoundation as dn}from"@apollion-dsi/core/themes/foundation";import{createSemantic as co}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as lo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as uo}from"@apollion-dsi/core/themes/surface";import{converter as oo,formatHex as j,interpolate as ro,parse as x,wcagContrast as an}from"culori";var ue=oo("oklch");function u(e,n,o){let r=x(e),t=x(n);if(!r||!t)return e;let i=ro([r,t],"oklch");return j(i(o))??e}s(u,"mixOklch");function to(e){return e?typeof e=="string"?e:e.base:"#000"}s(to,"coerceToHex");var K=1.3,io=.05,nn=.04,D=s((e,n)=>{let o=x(e),r=x(n);return!o||!r?1:an(o,r)},"contrastRatio"),de=s(e=>{let n=ue(x(e));return n?n.l??0:null},"oklchLightness"),so=4.5;function on(e,n,o=so){let r=x(n),t=ue(x(e));if(!r||!t)return e;let i=D("#fff",n)>=D("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=j(t)??e,l=x(c);if(l&&an(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return j(t)??e}s(on,"readableColor");var rn=s((e,n)=>{if(D(e,n)>=K)return!0;let o=de(e),r=de(n);return o!==null&&r!==null&&Math.abs(o-r)>=io},"isPerceptibleState"),ao=s(e=>e?D("#fff",e)>D("#000",e):!1,"isDarkSurface");function tn(e,n,o){let r=ue(x(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?nn:-nn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=j(t);if(l&&D(e,l)>=K)return l}return j(t)??null}s(tn,"derivePerceptibleState");function sn(e,n,o){let r=tn(e,n,o);if(r&&D(e,r)>=K)return r;let t=tn(e,!n);return t&&D(e,t)>=K?t:r??t}s(sn,"perceptibleStateFor");function S(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=to(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:u(r,t,.6),action:u(r,t,.2),active:u(r,i,.6),light:u(r,i,.9),onLight:r};if(x(r)){let c=ao(n.baseLight),l=rn(r,a.action);if(l||(a.action=sn(r,c)??a.action),!rn(r,a.active)){let m=l?void 0:de(a.action)??void 0;a.active=sn(r,c,m)??a.active}}if(a.onLight=on(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??on(c,l)}}return a}s(S,"mountSingleColor");function cn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:u(n,o,.05),10:u(n,o,.1),20:u(n,o,.2),30:u(n,o,.3),40:u(n,o,.4),50:u(n,o,.5),60:u(n,o,.6),70:u(n,o,.7),80:u(n,o,.8),90:u(n,o,.9),100:u(n,o,1)}}s(cn,"mountGreyscaleColors");function ln(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=u(r,o,.5);return{0:u(i,n,t(18)),5:u(i,n,t(17.5)),10:u(i,n,t(17)),20:u(i,n,t(16)),30:u(i,n,t(15)),40:u(i,n,t(14)),50:u(i,n,t(13)),60:u(i,n,t(12)),70:u(i,n,t(11)),80:u(i,n,t(10)),90:u(i,n,t(9)),100:u(i,n,t(8)),110:u(i,n,t(7)),120:u(i,n,t(6)),130:u(i,n,t(5)),140:u(i,n,t(4)),150:u(i,n,t(3)),160:u(i,n,t(2)),170:i,180:u(i,o,.25)}}s(ln,"mountNeutralColors");function po(e){return{...e,baseDark:e.baseLight,baseLight:e.baseDark,deepDark:e.deepLight,deepLight:e.deepDark}}s(po,"toCanonicalDarkInput");function fo(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:ln(e),grayscale:cn(e),main:S(e.main,e),opposite:S(e.opposite,e),complementary:S(e.complementary,e),danger:S(e.danger,e),information:S(e.information,e),success:S(e.success,e),warning:S(e.warning,e),primary:S(e.primary,e),secondary:S(e.secondary,e),tertiary:S(e.tertiary,e)}}s(fo,"composeColors");function E(e,n=lo){let o=e.mode==="dark"?po(e.colors):e.colors,r=fo(o),t=N(n,e.dimension),i=co({colors:r,spacing:t}),a=dn(i);return e.surface==="negative"&&(a=dn(uo({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(E,"buildVariantThemes");async function Er(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=q(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await mo(A(ho(),"apollion-tokens-"));try{let l=[],m=s(async(d,f)=>{await yo(c,d,f),l.push({path:d,sha256:U(f)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=en(n),f=[],k=De();f.push(k),await m(d.base.file,Be(k));for(let p of d.spacing){let y=i.find(L=>L.dimension===p.dimension),{foundation:G}=E(y),O=Ve(G,p.dimension);f.push(O),await m(p.file,We(O,p.dimension))}for(let p of d.font){let y=$e(p.dimension);f.push(y),await m(p.file,Je(y,p.dimension))}for(let p of d.color){let y=i.find(Z=>Z.brand===p.brand&&Z.mode===p.mode&&Z.surface===p.surface),{foundation:G,colors:O}=E(y),L=Ce(G,O);f.push(L),await m(p.file,He(L,p.brand,p.mode,p.surface))}ve(f),await m(Qe,ze(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:f,colors:k}=E(d),p=W(f,k,d),y=Xe(d);a.css&&await m(`css/${y}.css`,Fe(p,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${y}.d.ts`,Ue(p))}if(a.tailwind){let d=i[0],{foundation:f,colors:k}=E(d),p=W(f,k,d);await m("tailwind/preset.mjs",Me(p)),await m("tailwind/tw-merge.mjs",je(p))}if(a.designMd){let d=[...new Set(i.map(f=>f.brand))];for(let f of d){let p=i.filter(y=>y.brand===f).map(y=>{let{foundation:G,colors:O}=E(y);return W(G,O,y)});await m(`design/${f}.design.md`,Pe(f,p))}}let b={configHash:le(n),files:l,gitCommit:Ye(r),buildEnv:Ke()},w=Ze(b);return await mn(A(c,"manifest.json"),w),await pn(o,{recursive:!0,force:!0}),await fn(gn(o),{recursive:!0}),await go(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:b,outDir:o}}catch(l){throw await pn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Er,"build");async function Gr(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await un(A(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==le(n))return!1;for(let t of r.files){let i;try{i=await un(A(o,t.path))}catch{return!1}if(U(i)!==t.sha256)return!1}return!0}s(Gr,"check");async function yo(e,n,o){let r=A(e,n);await fn(gn(r),{recursive:!0}),await mn(r,o)}s(yo,"writeAt");export{Er as build,Gr as check};
|
package/lib/builders/colors.d.ts
CHANGED
|
@@ -28,9 +28,9 @@ import type { AcceptColorType, ColorPalleteInterface, ColorPalleteOverrideInterf
|
|
|
28
28
|
/** Rotate hue 180° in OKLch space. Semantic shift vs HSL — see core for details. */
|
|
29
29
|
export declare function getOppositeColor(color: AcceptColorType): string;
|
|
30
30
|
/**
|
|
31
|
-
* Derive `{ base, dark, action, active, light }` via OKLch lerp,
|
|
32
|
-
*
|
|
33
|
-
* core (ADR-012; parity.test.ts).
|
|
31
|
+
* Derive `{ base, dark, action, active, light }` via OKLch lerp, with a
|
|
32
|
+
* mode-aware perceptual state floor on the interaction states — byte-for-byte
|
|
33
|
+
* mirror of the core (ADR-012; parity.test.ts). Per-slot overrides pass through verbatim.
|
|
34
34
|
*/
|
|
35
35
|
export declare function mountSingleColor(color: AcceptColorType | ColorPalleteOverrideInterface, colors: ColorsInput): ColorPalleteInterface;
|
|
36
36
|
/** 12-step greyscale ramp — perceptually uniform via OKLch lerp. */
|
package/lib/cli.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var ln=Object.defineProperty;var i=(e,n)=>ln(e,"name",{value:n,configurable:!0}),dn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as po}from"node:fs/promises";import{resolve as ce}from"node:path";import{mkdir as nn,mkdtemp as Zn,readFile as Qn,rename as eo,rm as en,writeFile as on}from"node:fs/promises";import{tmpdir as no}from"node:os";import{dirname as tn,join as J}from"node:path";import{defaultInputBorder as P}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as pn}from"@apollion-dsi/core/themes/colors";import{createDeth as fn,levelValues as mn}from"@apollion-dsi/core/themes/depth";import{createFont as gn,defaultInputFont as w}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as le}from"@apollion-dsi/core/themes/spacing";import{converter as yn,formatHex as hn,parse as bn}from"culori";import{DIMENSION_MULTIPLIERS as un}from"@apollion-dsi/core/themes/dimension";function j({multiplier:e=.25,alias:n},o){let t=o!==void 0?un[o]:e;return(...r)=>r.map(s=>{let a=typeof s=="string"?n[s]:s;return`${t*a}rem`}).join(" ")}i(j,"createSpacing");var Y={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function K(e){let n=Object.keys(Y).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}i(K,"assertTokenMetaResolves");var Rn=yn("oklch");function b(e){return typeof e.type=="string"&&"value"in e}i(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}i(k,"kebab");function de(e){return e.split(".").map(k).join(".")}i(de,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}i($,"rawValue");function G(e,n){return Number(e.toFixed(n))||0}i(G,"round");function Q(e){let n=Rn(bn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[G(n.l,4),G(n.c,4),G(n.h??0,2)],t=hn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:G(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}i(Q,"toColorValue");var ue=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let n=ue.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}i(D,"toDimensionValue");function y(e){return{type:"color",value:Q(e)}}i(y,"colorToken");function Z(e){let n={};for(let[o,t]of Object.entries(e))n[o]=y(t);return n}i(Z,"recordColorGroup");function pe(e){let n=pn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=y(r);return o.neutral=Z(n.neutral),o}i(pe,"buildReadableTextGroup");var kn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function fe(e){let n={};for(let o of kn){let t=e[o];n[o]={base:y(t.base),dark:y(t.dark),action:y(t.action),active:y(t.active),light:y(t.light)}}return n.grayscale=Z(e.grayscale),n.neutral=Z(e.neutral),n.baseDark=y(e.baseDark??"#000000"),n.baseLight=y(e.baseLight??"#ffffff"),n.deepDark=y(e.deepDark??"#000000"),n.deepLight=y(e.deepLight??"#ffffff"),n}i(fe,"buildColorPrimitives");function me(e){let n=j(le,e),o={};for(let t of Object.keys(le.alias))o[t]={type:"dimension",value:D(n(t))};return o}i(me,"buildSpacePrimitives");function ge(){let e={};for(let[n,o]of Object.entries(P.borderWidth))e[n]={type:"dimension",value:D(o)};return e}i(ge,"buildBorderWidthPrimitives");function In(e,n){return{color:fe(e),space:me(n),borderWidth:ge()}}i(In,"buildPrimitives");var ye={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},he={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Sn(e,n){let o=e;for(let t of n.split(".").slice(1))if(o&&typeof o=="object"&&t in o)o=o[t];else return;return typeof o=="string"?o:void 0}i(Sn,"lookupPrimitive");function F(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?Sn(n,a):void 0;t[r]=a&&c===s?{type:"color",value:{kind:"ref",path:a,resolved:Q(s)}}:y(s)}return t}i(F,"colorRefGroup");var be={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},xn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function wn(e,n){let o=n.split("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let s of o.slice(1))if(r&&!b(r)&&s in r)r=r[s];else return;return r&&b(r)&&r.value.kind==="dimension"?r.value.raw:void 0}i(wn,"lookupDimensionPrimitive");function ee(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?wn(n,a):void 0;t[r]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:D(s)}}:{type:"dimension",value:D(s)}}return t}i(ee,"dimensionRefGroup");function Re(e){let n={},o={};for(let[s,a]of Object.entries(P.borderRadius))ue.test(a)?n[s]={type:"dimension",value:D(a)}:o[s]=a;let t=ee(P.borderWidth,e,xn),r={};for(let[s,a]of Object.entries(P.borderStyle))r[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}i(Re,"buildBorder");function ke(e){let n=gn(w,e),o={};for(let[c,l]of Object.entries(w.fontFamily)){let f=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:D(l)};let r={};for(let[c,l]of Object.entries(w.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let s={};for(let[c,l]of Object.entries(w.lineHeight))s[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:w.letterSpacing,textTransform:w.textTransform,fontStyle:w.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:s},extensions:a}}i(ke,"buildFont");var Dn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function vn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let t=n.match(Dn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=i(l=>D(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Q(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}i(vn,"parseShadow");function Ie(e){let n=fn(e),o={};for(let t of Object.keys(mn))o[t]={type:"shadow",value:vn(n(t))};return o}i(Ie,"buildShadow");function M(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=n?`${n}.${k(r)}`:k(r);if(b(s)){o.add(a);let c=Y[a];t[r]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...s,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:s}else t[r]=M(s,a,o)}return t}i(M,"decorateGroup");function Tn(e){let n=new Set,o=M(e.primitives,"",n),t=M(e.groups,"",n);return K(n),{...e,primitives:o,groups:t}}i(Tn,"decorateMeta");function N(e,n){return M(e,"",n)}i(N,"decorateSlice");function Se(e,n,o){for(let[t,r]of Object.entries(e)){let s=n?`${n}.${k(t)}`:k(t);b(r)?o.add(s):Se(r,s,o)}}i(Se,"collectPaths");function xe(e){let n=new Set;for(let o of e)Se(o.groups,"",n);K(n)}i(xe,"assertSlicesMetaComplete");function we(){let e=ge(),o=Re({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:N({"border-width":e,border:o.group},r),extensions:t}}i(we,"buildBaseIR");function De(e){let n=ke(e),o=new Set;return{groups:N({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}i(De,"buildFontIR");function ve(e,n){let o=fe(n),t=new Set;return{groups:N({color:o,bg:F(e.bg,n,ye),text:F(e.text,n,he),tx:pe(n),shadow:Ie(n)},t),extensions:{}}}i(ve,"buildColorIR");function Te(e,n){let o=me(n),t={space:o},r=new Set;return{groups:N({space:o,spacing:ee(e.spacing,t,be)},r),extensions:{}}}i(Te,"buildSpacingIR");function Cn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=In(n,o.dimension),s=Re(r),a=ke(o.dimension),c={"com.apollion.variant":t,"com.apollion.font":a.extensions};Object.keys(s.extensions).length>0&&(c["com.apollion.border"]={radius:s.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:F(e.bg,n,ye),text:F(e.text,n,he),tx:pe(n),spacing:ee(e.spacing,r,be),border:s.group,font:a.group,shadow:Ie(n)},extensions:c};return Tn(l)}i(Cn,"buildIR");var Ce=Cn;var $n="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function $e(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,k(t)];b(r)?o.push(` --apollion-${s.join("-")}: ${$(r.value)};`):$e(r,s,o)}}i($e,"emitVars");function Ve(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,k(t)];b(r)?r.type==="color"&&o.push(` @property --apollion-${s.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(r.value)}; }`):Ve(r,s,o)}}i(Ve,"emitProperties");function Oe(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[$n,""];return s.push(`/* Variant: brand=${n} mode=${o} surface=${t} dimension=${r} */`,"",":root {"),$e(e.groups,[],s),s.push("}",""),s.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Ve(e.groups,[],s),s.push("}",""),s.join(`
|
|
3
|
-
`)}i(
|
|
4
|
-
`}i(
|
|
5
|
-
`}i(
|
|
6
|
-
`)}
|
|
7
|
-
|
|
8
|
-
`);
|
|
9
|
-
|
|
2
|
+
var Dn=Object.defineProperty;var i=(e,n)=>Dn(e,"name",{value:n,configurable:!0}),Tn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as Mo}from"node:fs/promises";import{resolve as ye}from"node:path";import{mkdir as Rn,mkdtemp as wo,readFile as yn,rename as vo,rm as bn,writeFile as kn}from"node:fs/promises";import{tmpdir as Do}from"node:os";import{dirname as In,join as F}from"node:path";import{converter as zn,parse as qn}from"culori";import{defaultInputBorder as H}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Cn}from"@apollion-dsi/core/themes/colors";import{createDeth as Vn,levelValues as On}from"@apollion-dsi/core/themes/depth";import{createFont as En,defaultInputFont as V}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as be}from"@apollion-dsi/core/themes/spacing";import{converter as An,formatHex as jn,parse as Gn}from"culori";import{DIMENSION_MULTIPLIERS as $n}from"@apollion-dsi/core/themes/dimension";function _({multiplier:e=.25,alias:n},o){let t=o!==void 0?$n[o]:e;return(...r)=>r.map(s=>{let a=typeof s=="string"?n[s]:s;return`${t*a}rem`}).join(" ")}i(_,"createSpacing");var te={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function re(e){let n=Object.keys(te).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}i(re,"assertTokenMetaResolves");var Mn=An("oklch");function h(e){return typeof e.type=="string"&&"value"in e}i(h,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}i(I,"kebab");function Re(e){return e.split(".").map(I).join(".")}i(Re,"kebabPath");function E(e){return e.kind==="ref"?e.resolved.raw:e.raw}i(E,"rawValue");function B(e,n){return Number(e.toFixed(n))||0}i(B,"round");function se(e){let n=Mn(Gn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[B(n.l,4),B(n.c,4),B(n.h??0,2)],t=jn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:B(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}i(se,"toColorValue");var ke=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function O(e){let n=ke.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}i(O,"toDimensionValue");function k(e){return{type:"color",value:se(e)}}i(k,"colorToken");function ie(e){let n={};for(let[o,t]of Object.entries(e))n[o]=k(t);return n}i(ie,"recordColorGroup");function Ie(e){let n=Cn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=k(r);return o.neutral=ie(n.neutral),o}i(Ie,"buildReadableTextGroup");var Pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function xe(e){let n={};for(let o of Pn){let t=e[o];n[o]={base:k(t.base),dark:k(t.dark),action:k(t.action),active:k(t.active),light:k(t.light),onLight:k(t.onLight)}}return n.grayscale=ie(e.grayscale),n.neutral=ie(e.neutral),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}i(xe,"buildColorPrimitives");function Se(e){let n=_(be,e),o={};for(let t of Object.keys(be.alias))o[t]={type:"dimension",value:O(n(t))};return o}i(Se,"buildSpacePrimitives");function we(){let e={};for(let[n,o]of Object.entries(H.borderWidth))e[n]={type:"dimension",value:O(o)};return e}i(we,"buildBorderWidthPrimitives");function Nn(e,n){return{color:xe(e),space:Se(n),borderWidth:we()}}i(Nn,"buildPrimitives");var ve={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},De={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Fn(e,n){let o=e;for(let t of n.split(".").slice(1))if(o&&typeof o=="object"&&t in o)o=o[t];else return;return typeof o=="string"?o:void 0}i(Fn,"lookupPrimitive");function W(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?Fn(n,a):void 0;t[r]=a&&c===s?{type:"color",value:{kind:"ref",path:a,resolved:se(s)}}:k(s)}return t}i(W,"colorRefGroup");var Te={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Ln={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function _n(e,n){let o=n.split("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let s of o.slice(1))if(r&&!h(r)&&s in r)r=r[s];else return;return r&&h(r)&&r.value.kind==="dimension"?r.value.raw:void 0}i(_n,"lookupDimensionPrimitive");function ae(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?_n(n,a):void 0;t[r]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:O(s)}}:{type:"dimension",value:O(s)}}return t}i(ae,"dimensionRefGroup");function $e(e){let n={},o={};for(let[s,a]of Object.entries(H.borderRadius))ke.test(a)?n[s]={type:"dimension",value:O(a)}:o[s]=a;let t=ae(H.borderWidth,e,Ln),r={};for(let[s,a]of Object.entries(H.borderStyle))r[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}i($e,"buildBorder");function Ce(e){let n=En(V,e),o={};for(let[c,l]of Object.entries(V.fontFamily)){let p=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:p,family:p}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:O(l)};let r={};for(let[c,l]of Object.entries(V.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let s={};for(let[c,l]of Object.entries(V.lineHeight))s[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:V.letterSpacing,textTransform:V.textTransform,fontStyle:V.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:s},extensions:a}}i(Ce,"buildFont");var Bn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Hn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let t=n.match(Bn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=i(l=>O(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:se(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}i(Hn,"parseShadow");function Ve(e){let n=Vn(e),o={};for(let t of Object.keys(On))o[t]={type:"shadow",value:Hn(n(t))};return o}i(Ve,"buildShadow");function J(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=n?`${n}.${I(r)}`:I(r);if(h(s)){o.add(a);let c=te[a];t[r]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...s,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:s}else t[r]=J(s,a,o)}return t}i(J,"decorateGroup");function Wn(e){let n=new Set,o=J(e.primitives,"",n),t=J(e.groups,"",n);return re(n),{...e,primitives:o,groups:t}}i(Wn,"decorateMeta");function z(e,n){return J(e,"",n)}i(z,"decorateSlice");function Oe(e,n,o){for(let[t,r]of Object.entries(e)){let s=n?`${n}.${I(t)}`:I(t);h(r)?o.add(s):Oe(r,s,o)}}i(Oe,"collectPaths");function Ee(e){let n=new Set;for(let o of e)Oe(o.groups,"",n);re(n)}i(Ee,"assertSlicesMetaComplete");function Ae(){let e=we(),o=$e({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:z({"border-width":e,border:o.group},r),extensions:t}}i(Ae,"buildBaseIR");function je(e){let n=Ce(e),o=new Set;return{groups:z({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}i(je,"buildFontIR");function Ge(e,n){let o=xe(n),t=new Set;return{groups:z({color:o,bg:W(e.bg,n,ve),text:W(e.text,n,De),tx:Ie(n),shadow:Ve(n)},t),extensions:{}}}i(Ge,"buildColorIR");function Me(e,n){let o=Se(n),t={space:o},r=new Set;return{groups:z({space:o,spacing:ae(e.spacing,t,Te)},r),extensions:{}}}i(Me,"buildSpacingIR");function Jn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=Nn(n,o.dimension),s=$e(r),a=Ce(o.dimension),c={"com.apollion.variant":t,"com.apollion.font":a.extensions};Object.keys(s.extensions).length>0&&(c["com.apollion.border"]={radius:s.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:W(e.bg,n,ve),text:W(e.text,n,De),tx:Ie(n),spacing:ae(e.spacing,r,Te),border:s.group,font:a.group,shadow:Ve(n)},extensions:c};return Wn(l)}i(Jn,"buildIR");var q=Jn;var Un=zn("rgb"),Pe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function ce(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}i(ce,"colorPayload");function le(e){return e.alpha===void 0}i(le,"isOpaqueColor");function Ne(e){let n=Un(qn(e.hex));if(!n)return"0 0 0";let o=i(t=>Math.min(255,Math.max(0,Math.round(t*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}i(Ne,"rgbTriplet");function U(e,n=[]){let o=new Map;for(let[t,r]of Object.entries(e)){let s=[...n,I(t)];if(h(r))o.set(s.join("-"),r);else for(let[a,c]of U(r,s))o.set(a,c)}return o}i(U,"flatTokens");function y(e,...n){let o=e[n[0]];for(let t of n.slice(1)){if(!o||h(o))return{};o=o[t]}return o&&!h(o)?o:{}}i(y,"groupAt");function Fe(e){let n=[];for(let o of["bg","text","tx"])for(let[t,r]of U(y(e.groups,o),[o])){let s=ce(r);s&&n.push({key:t,cssVar:`--apollion-${t}`,opaque:le(s)})}return n}i(Fe,"colorEntries");function T(e,n){return[...U(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}i(T,"varEntries");function $(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[t,r]of o)e.push(` ${JSON.stringify(t)}: ${JSON.stringify(r)},`);e.push(" },")}}i($,"pushScale");function Le(e){let n=[Pe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Fe(e);n.push(" colors: {");for(let{key:t,cssVar:r,opaque:s}of o)s?n.push(` ${JSON.stringify(t)}: ${JSON.stringify(`rgb(var(${r}-rgb) / <alpha-value>)`)},`):(n.push(` // ${t} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(t)}: ${JSON.stringify(`var(${r})`)},`));return n.push(" },"),$(n,"spacing",T(y(e.groups,"spacing"),["spacing"])),$(n,"borderRadius",T(y(e.groups,"border","radius"),["border","radius"])),$(n,"borderWidth",T(y(e.groups,"border","width"),["border","width"])),$(n,"fontFamily",T(y(e.groups,"font","family"),["font","family"])),$(n,"fontSize",T(y(e.groups,"font","size"),["font","size"])),$(n,"fontWeight",T(y(e.groups,"font","weight"),["font","weight"])),$(n,"lineHeight",T(y(e.groups,"font","lineHeight"),["font","line-height"])),$(n,"boxShadow",T(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
3
|
+
`)}i(Le,"renderTailwindPreset");function _e(e){let n=i(r=>[...U(r).keys()],"keys"),o=i(r=>`[${r.map(s=>JSON.stringify(s)).join(", ")}]`,"list");return[Pe,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(Fe(e).map(r=>r.key))},`,` spacing: ${o(n(y(e.groups,"spacing")))},`,` borderRadius: ${o(n(y(e.groups,"border","radius")))},`,` borderWidth: ${o(n(y(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(y(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(y(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(y(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(y(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(y(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
4
|
+
`)}i(_e,"renderTwMergeExtension");var Xn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Be(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,I(t)];h(r)?o.push(` --apollion-${s.join("-")}: ${E(r.value)};`):Be(r,s,o)}}i(Be,"emitVars");function He(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,I(t)];if(!h(r)){He(r,s,o);continue}let a=ce(r);a&&le(a)&&o.push(` --apollion-${s.join("-")}-rgb: ${Ne(a)};`)}}i(He,"emitRgbVars");function We(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,I(t)];h(r)?r.type==="color"&&o.push(` @property --apollion-${s.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${E(r.value)}; }`):We(r,s,o)}}i(We,"emitProperties");function Je(e,n={}){let{brand:o,mode:t,surface:r,dimension:s}=e.meta,a=[Xn,""];return a.push(`/* Variant: brand=${o} mode=${t} surface=${r} dimension=${s} */`,"",":root {"),Be(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),He(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),We(e.groups,[],a),a.push("}",""),a.join(`
|
|
5
|
+
`)}i(Je,"renderCss");var Yn="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function ue(e,n,o){for(let[t,r]of Object.entries(e)){let s=n?`${n}.${t}`:t;h(r)?o.push([s,E(r.value)]):ue(r,s,o)}}i(ue,"flatten");function Kn(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}i(Kn,"yamlEscape");function Zn(e){let{mode:n,surface:o,dimension:t}=e.meta;return`${n}.${o}.${t}`}i(Zn,"variantKey");function ze(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let r of n){let s=[];ue(r.groups,"",s),o.push(` ${Zn(r)}:`);for(let[a,c]of s)o.push(` ${a}: ${Kn(c)}`)}o.push("---");let t=["",Yn,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let r of n){let{mode:s,surface:a,dimension:c}=r.meta;t.push(`## Variant \`${s} \xB7 ${a} \xB7 ${c}\``,"");let l=[];ue(r.groups,"",l);let p=new Map;for(let[R,D]of l){let u=R.split(".")[0]??R,g=p.get(u)??[];g.push([R,D]),p.set(u,g)}for(let[R,D]of p){t.push(`### ${R}`,"","| Token | Value |","| --- | --- |");for(let[u,g]of D)t.push(`| \`${u}\` | \`${g}\` |`);t.push("")}}return`${o.join(`
|
|
6
|
+
`)}
|
|
7
|
+
${t.join(`
|
|
8
|
+
`)}`}i(ze,"renderDesignMd");function qe(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}i(qe,"colorValue");function P(e){return{value:e.value,unit:e.unit}}i(P,"dimensionValue");function Qn(e){let n=e.shadow,o={color:qe(n.color),offsetX:P(n.offsetX),offsetY:P(n.offsetY),blur:P(n.blur),spread:P(n.spread)};return n.inset&&(o.inset=!0),o}i(Qn,"shadowValue");function eo(e){switch(e.kind){case"ref":return`{${Re(e.path)}}`;case"color":return qe(e);case"dimension":return P(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Qn(e)}}i(eo,"projectValue");function no(e){let n={$value:eo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}i(no,"projectToken");function de(e){let n={};for(let[o,t]of Object.entries(e))n[I(o)]=h(t)?no(t):de(t);return n}i(de,"projectGroup");function X(e,n){let o={$description:n,...de(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}i(X,"renderSet");function Ue(e){return X(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}i(Ue,"renderBaseSet");function Xe(e,n,o,t){return X(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${t}. DTCG 2025.10.`)}i(Xe,"renderColorSet");function Ye(e,n){return X(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}i(Ye,"renderSpacingSet");function Ke(e,n){return X(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}i(Ke,"renderFontSet");function Ze(e,n){let{modifiers:o}=n,t=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],s={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:t,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(s,null,2)}
|
|
10
|
+
`}i(Ze,"renderResolver");var oo="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function to(e,n,o){let t=[];if(e.description!==void 0&&t.push(e.description),e.deprecated===!0?t.push("@deprecated"):typeof e.deprecated=="string"&&t.push(`@deprecated ${e.deprecated}`),t.length!==0){o.push(`${n}/**`);for(let r of t)o.push(`${n} * ${r.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}i(to,"emitDoc");function Qe(e,n,o){let t=" ".repeat(n);for(let[r,s]of Object.entries(e))h(s)?(to(s,t,o),o.push(`${t}${JSON.stringify(r)}: ${JSON.stringify(E(s.value))},`)):(o.push(`${t}${r}: {`),Qe(s,n+1,o),o.push(`${t}},`))}i(Qe,"emitGroup");function en(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[oo,`// Variant: brand=${n} mode=${o} surface=${t} dimension=${r}`,"","export const tokens = {"];return Qe(e.groups,1,s),s.push("} as const;","","export type Tokens = typeof tokens;",""),s.join(`
|
|
11
|
+
`)}i(en,"renderTs");var ro=["light","dark"],io=["positive","negative"],so=["compact","normal","spacious"];function Y(e){let n=e.modes??ro,o=e.surfaces??io,t=e.dimensions??so,r=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),s=[];for(let[a,c]of r)for(let l of n)for(let p of o)for(let R of t)s.push({brand:a,colors:c,mode:l,surface:p,dimension:R});return s}i(Y,"expandVariants");function nn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}i(nn,"variantName");import{createHash as ao}from"node:crypto";function K(e){return ao("sha256").update(e).digest("hex")}i(K,"sha256");function fe(e){return K(pe(e))}i(fe,"hashConfig");function pe(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(pe).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${pe(e[t])}`).join(",")}}`}i(pe,"stableStringify");function on(e){try{let{execSync:n}=Tn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}i(on,"detectGitCommit");function tn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}i(tn,"buildEnv");function rn(e){let n=[...e.files].sort((t,r)=>t.path.localeCompare(r.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
12
|
+
`}i(rn,"serializeManifest");var co="json/sets",sn="json/resolver.json";function Z(e){return`${co}/${e}.json`}i(Z,"setFile");function lo(e,n,o){return`${e}.color.${n}.${o}`}i(lo,"colorSetName");function uo(e){return`spacing.${e}`}i(uo,"spacingSetName");function po(e){return`font.${e}`}i(po,"fontSetName");function Q(e,n){e.includes(n)||e.push(n)}i(Q,"pushUnique");function an(e){let n=Y(e),o=[],t=[],r=[],s=[],a=new Set,c=[],l=new Set,p=[],R=new Set,D=[];for(let u of n){Q(o,u.brand),Q(t,u.mode),Q(r,u.surface),Q(s,u.dimension);let g=lo(u.brand,u.mode,u.surface);a.has(g)||(a.add(g),c.push({kind:"color",name:g,file:Z(g),brand:u.brand,mode:u.mode,surface:u.surface}));let x=uo(u.dimension);l.has(x)||(l.add(x),p.push({kind:"spacing",name:x,file:Z(x),dimension:u.dimension}));let f=po(u.dimension);R.has(f)||(R.add(f),D.push({kind:"font",name:f,file:Z(f),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:Z("base")},spacing:p,font:D,color:c,modifiers:{brand:o,mode:t,surface:r,dimension:s}}}i(an,"planSets");import{createFoundation as hn}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Ro}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as ko}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Io}from"@apollion-dsi/core/themes/surface";import{converter as fo,formatHex as N,interpolate as go,parse as v,wcagContrast as fn}from"culori";var me=fo("oklch");function d(e,n,o){let t=v(e),r=v(n);if(!t||!r)return e;let s=go([t,r],"oklch");return N(s(o))??e}i(d,"mixOklch");function mo(e){return e?typeof e=="string"?e:e.base:"#000"}i(mo,"coerceToHex");var ee=1.3,ho=.05,cn=.04,C=i((e,n)=>{let o=v(e),t=v(n);return!o||!t?1:fn(o,t)},"contrastRatio"),ge=i(e=>{let n=me(v(e));return n?n.l??0:null},"oklchLightness"),yo=4.5;function ln(e,n,o=yo){let t=v(n),r=me(v(e));if(!t||!r)return e;let s=C("#fff",n)>=C("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=N(r)??e,l=v(c);if(l&&fn(l,t)>=o)return c;let p=Math.min(1,Math.max(0,(r.l??0)+s));if(p===(r.l??0))break;r={...r,l:p}}return N(r)??e}i(ln,"readableColor");var un=i((e,n)=>{if(C(e,n)>=ee)return!0;let o=ge(e),t=ge(n);return o!==null&&t!==null&&Math.abs(o-t)>=ho},"isPerceptibleState"),bo=i(e=>e?C("#fff",e)>C("#000",e):!1,"isDarkSurface");function dn(e,n,o){let t=me(v(e));if(!t)return null;let r={...t,l:o??t.l??0},s=n?cn:-cn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(r.l??0)+s));if(c===(r.l??0))break;r={...r,l:c};let l=N(r);if(l&&C(e,l)>=ee)return l}return N(r)??null}i(dn,"derivePerceptibleState");function pn(e,n,o){let t=dn(e,n,o);if(t&&C(e,t)>=ee)return t;let r=dn(e,!n);return r&&C(e,r)>=ee?r:t??r}i(pn,"perceptibleStateFor");function w(e,n){let o=typeof e=="object"&&e!==null?e:void 0,t=mo(e),r=n.deepDark,s=n.deepLight,a={base:t,dark:d(t,r,.6),action:d(t,r,.2),active:d(t,s,.6),light:d(t,s,.9),onLight:t};if(v(t)){let c=bo(n.baseLight),l=un(t,a.action);if(l||(a.action=pn(t,c)??a.action),!un(t,a.active)){let p=l?void 0:ge(a.action)??void 0;a.active=pn(t,c,p)??a.active}}if(a.onLight=ln(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:t,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??ln(c,l)}}return a}i(w,"mountSingleColor");function gn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:d(n,o,.05),10:d(n,o,.1),20:d(n,o,.2),30:d(n,o,.3),40:d(n,o,.4),50:d(n,o,.5),60:d(n,o,.6),70:d(n,o,.7),80:d(n,o,.8),90:d(n,o,.9),100:d(n,o,1)}}i(gn,"mountGreyscaleColors");function mn(e){let n=e.deepLight,o=e.deepDark,t=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,r=i(a=>1/17*(a-1),"interpolation"),s=d(t,o,.5);return{0:d(s,n,r(18)),5:d(s,n,r(17.5)),10:d(s,n,r(17)),20:d(s,n,r(16)),30:d(s,n,r(15)),40:d(s,n,r(14)),50:d(s,n,r(13)),60:d(s,n,r(12)),70:d(s,n,r(11)),80:d(s,n,r(10)),90:d(s,n,r(9)),100:d(s,n,r(8)),110:d(s,n,r(7)),120:d(s,n,r(6)),130:d(s,n,r(5)),140:d(s,n,r(4)),150:d(s,n,r(3)),160:d(s,n,r(2)),170:s,180:d(s,o,.25)}}i(mn,"mountNeutralColors");function xo(e){return{...e,baseDark:e.baseLight,baseLight:e.baseDark,deepDark:e.deepLight,deepLight:e.deepDark}}i(xo,"toCanonicalDarkInput");function So(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:mn(e),grayscale:gn(e),main:w(e.main,e),opposite:w(e.opposite,e),complementary:w(e.complementary,e),danger:w(e.danger,e),information:w(e.information,e),success:w(e.success,e),warning:w(e.warning,e),primary:w(e.primary,e),secondary:w(e.secondary,e),tertiary:w(e.tertiary,e)}}i(So,"composeColors");function G(e,n=ko){let o=e.mode==="dark"?xo(e.colors):e.colors,t=So(o),r=_(n,e.dimension),s=Ro({colors:t,spacing:r}),a=hn(s);return e.surface==="negative"&&(a=hn(Io({semantic:s,colors:t},"negative").semantic)),{foundation:a,colors:t}}i(G,"buildVariantThemes");async function xn(e){let{config:n,outDir:o,cwd:t=process.cwd(),verbose:r=!1}=e,s=Y(n),a=n.output??{};if(s.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await wo(F(Do(),"apollion-tokens-"));try{let l=[],p=i(async(u,g)=>{await To(c,u,g),l.push({path:u,sha256:K(g)}),r&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=an(n),g=[],x=Ae();g.push(x),await p(u.base.file,Ue(x));for(let f of u.spacing){let b=s.find(L=>L.dimension===f.dimension),{foundation:M}=G(b),j=Me(M,f.dimension);g.push(j),await p(f.file,Ye(j,f.dimension))}for(let f of u.font){let b=je(f.dimension);g.push(b),await p(f.file,Ke(b,f.dimension))}for(let f of u.color){let b=s.find(oe=>oe.brand===f.brand&&oe.mode===f.mode&&oe.surface===f.surface),{foundation:M,colors:j}=G(b),L=Ge(M,j);g.push(L),await p(f.file,Xe(L,f.brand,f.mode,f.surface))}Ee(g),await p(sn,Ze(n,u))}if(a.css||a.ts)for(let u of s){let{foundation:g,colors:x}=G(u),f=q(g,x,u),b=nn(u);a.css&&await p(`css/${b}.css`,Je(f,{rgbCompanions:a.tailwind})),a.ts&&await p(`ts/${b}.d.ts`,en(f))}if(a.tailwind){let u=s[0],{foundation:g,colors:x}=G(u),f=q(g,x,u);await p("tailwind/preset.mjs",Le(f)),await p("tailwind/tw-merge.mjs",_e(f))}if(a.designMd){let u=[...new Set(s.map(g=>g.brand))];for(let g of u){let f=s.filter(b=>b.brand===g).map(b=>{let{foundation:M,colors:j}=G(b);return q(M,j,b)});await p(`design/${g}.design.md`,ze(g,f))}}let R={configHash:fe(n),files:l,gitCommit:on(t),buildEnv:tn()},D=rn(R);return await kn(F(c,"manifest.json"),D),await bn(o,{recursive:!0,force:!0}),await Rn(In(o),{recursive:!0}),await vo(c,o),r&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:R,outDir:o}}catch(l){throw await bn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}i(xn,"build");async function Sn(e){let{config:n,outDir:o}=e,t;try{t=JSON.parse(await yn(F(o,"manifest.json"),"utf8"))}catch{return!1}if(t.configHash!==fe(n))return!1;for(let r of t.files){let s;try{s=await yn(F(o,r.path))}catch{return!1}if(K(s)!==r.sha256)return!1}return!0}i(Sn,"check");async function To(e,n,o){let t=F(e,n);await Rn(In(t),{recursive:!0}),await kn(t,o)}i(To,"writeAt");import{readFile as Co}from"node:fs/promises";import{resolve as Vo}from"node:path";import{createContext as Oo,Script as Eo}from"node:vm";import{z as m}from"zod";var S=m.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),$o=m.object({baseDark:m.string().optional(),baseLight:m.string().optional(),deepDark:S,deepLight:S,transparent:m.string().optional(),main:S.optional(),opposite:S.optional(),complementary:S.optional(),information:S.optional(),success:S.optional(),danger:S.optional(),warning:S.optional(),primary:S.optional(),secondary:S.optional(),tertiary:S.optional()}).passthrough(),wn=m.object({brands:m.record(m.string(),$o).refine(e=>Object.keys(e).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:m.array(m.enum(["light","dark"])).optional(),surfaces:m.array(m.enum(["positive","negative"])).optional(),dimensions:m.array(m.enum(["compact","normal","spacious"])).optional(),output:m.object({runtime:m.boolean().optional(),css:m.boolean().optional(),json:m.boolean().optional(),ts:m.boolean().optional(),designMd:m.boolean().optional(),tailwind:m.boolean().optional()}).passthrough().optional()}).passthrough();var Ao=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],jo=1e3;var he=class he extends Error{constructor(o,t){super(o);this.configPath=t;this.name="ConfigLoadError"}};i(he,"ConfigLoadError");var A=he;async function vn(e){let n=Vo(e.configPath),o=await Co(n,"utf8");for(let l of Ao)if(l.test(o))throw new A(`apollion.config: dynamic require/import not allowed (matched ${l}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,n);let t=o.replace(/(^|\n)\s*export\s+default\s+/,(l,p)=>`${p}__apollion_config_export = `);if(t===o)throw new A("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",n);let r={__apollion_config_export:void 0,console:Go(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:i(l=>l,"defineConfig")},s=Oo(r);try{new Eo(t,{filename:n}).runInContext(s,{timeout:jo})}catch(l){throw new A(`apollion.config: evaluation failed \u2014 ${l instanceof Error?l.message:String(l)}`,n)}let a=r.__apollion_config_export;if(a===void 0)throw new A("apollion.config: `export default` produced undefined.",n);let c=wn.safeParse(a);if(!c.success){let l=c.error.issues.map(p=>` ${p.path.join(".")||"(root)"}: ${p.message}`).join(`
|
|
13
|
+
`);throw new A(`apollion.config: schema validation failed \u2014
|
|
14
|
+
${l}`,n)}return c.data}i(vn,"loadConfig");function Go(){return{log:i((...e)=>console.log("[apollion.config]",...e),"log"),warn:i((...e)=>console.warn("[apollion.config]",...e),"warn"),error:i((...e)=>console.error("[apollion.config]",...e),"error")}}i(Go,"makeReadOnlyConsole");function Po(e){let n=e.slice(2),o=n[0];o!=="build"&&ne(`Unknown command "${o??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let t="apollion.config.mjs",r="dist",s=!1,a=!1;for(let c=1;c<n.length;c++){let l=n[c];switch(l){case"--config":t=n[++c]??ne("--config needs a path");break;case"--out":r=n[++c]??ne("--out needs a path");break;case"--check":s=!0;break;case"--verbose":a=!0;break;default:ne(`Unknown flag "${l}"`)}}return{command:o,configPath:t,outDir:r,check:s,verbose:a}}i(Po,"parseArgs");function ne(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}i(ne,"fail");async function No(e){let n=ye(e);if(n.endsWith(".json")){let o=await Mo(n,"utf8");return JSON.parse(o)}return vn({configPath:n})}i(No,"loadConfigFromPath");async function Fo(){let e=Po(process.argv),n=await No(e.configPath);if(e.check){await Sn({config:n,outDir:ye(e.outDir)})||(console.error("apollion-tokens: dist/ is stale, missing, or has drifted from its manifest. Re-run `apollion-tokens build` without --check."),process.exit(1)),console.log("apollion-tokens: dist/ is up-to-date with config.");return}let{manifest:o}=await xn({config:n,outDir:ye(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${o.files.length} file(s) \u2014 configHash=${o.configHash.slice(0,12)}\u2026`)}i(Fo,"main");Fo().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
|
package/lib/config-loader.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var a=(
|
|
1
|
+
"use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var a=(n,t)=>f(n,"name",{value:t,configurable:!0});var k=(n,t)=>{for(var r in t)f(n,r,{get:t[r],enumerable:!0})},j=(n,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of C(t))!_.call(n,s)&&s!==r&&f(n,s,{get:()=>t[s],enumerable:!(p=y(t,s))||p.enumerable});return n};var A=n=>j(f({},"__esModule",{value:!0}),n);var v={};k(v,{ConfigLoadError:()=>l,defineConfig:()=>P,loadConfig:()=>D});module.exports=A(v);var b=require("node:fs/promises"),w=require("node:path"),g=require("node:vm");var o=require("zod"),i=o.z.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),S=o.z.object({baseDark:o.z.string().optional(),baseLight:o.z.string().optional(),deepDark:i,deepLight:i,transparent:o.z.string().optional(),main:i.optional(),opposite:i.optional(),complementary:i.optional(),information:i.optional(),success:i.optional(),danger:i.optional(),warning:i.optional(),primary:i.optional(),secondary:i.optional(),tertiary:i.optional()}).passthrough(),h=o.z.object({brands:o.z.record(o.z.string(),S).refine(n=>Object.keys(n).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:o.z.array(o.z.enum(["light","dark"])).optional(),surfaces:o.z.array(o.z.enum(["positive","negative"])).optional(),dimensions:o.z.array(o.z.enum(["compact","normal","spacious"])).optional(),output:o.z.object({runtime:o.z.boolean().optional(),css:o.z.boolean().optional(),json:o.z.boolean().optional(),ts:o.z.boolean().optional(),designMd:o.z.boolean().optional(),tailwind:o.z.boolean().optional()}).passthrough().optional()}).passthrough();var $=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],O=1e3;function P(n){return n}a(P,"defineConfig");var u=class u extends Error{constructor(r,p){super(r);this.configPath=p;this.name="ConfigLoadError"}};a(u,"ConfigLoadError");var l=u;async function D(n){let t=(0,w.resolve)(n.configPath),r=await(0,b.readFile)(t,"utf8");for(let e of $)if(e.test(r))throw new l(`apollion.config: dynamic require/import not allowed (matched ${e}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,t);let p=r.replace(/(^|\n)\s*export\s+default\s+/,(e,c)=>`${c}__apollion_config_export = `);if(p===r)throw new l("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",t);let s={__apollion_config_export:void 0,console:T(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:a(e=>e,"defineConfig")},x=(0,g.createContext)(s);try{new g.Script(p,{filename:t}).runInContext(x,{timeout:O})}catch(e){throw new l(`apollion.config: evaluation failed \u2014 ${e instanceof Error?e.message:String(e)}`,t)}let d=s.__apollion_config_export;if(d===void 0)throw new l("apollion.config: `export default` produced undefined.",t);let m=h.safeParse(d);if(!m.success){let e=m.error.issues.map(c=>` ${c.path.join(".")||"(root)"}: ${c.message}`).join(`
|
|
2
2
|
`);throw new l(`apollion.config: schema validation failed \u2014
|
|
3
|
-
${e}`,
|
|
3
|
+
${e}`,t)}return m.data}a(D,"loadConfig");function T(){return{log:a((...n)=>console.log("[apollion.config]",...n),"log"),warn:a((...n)=>console.warn("[apollion.config]",...n),"warn"),error:a((...n)=>console.error("[apollion.config]",...n),"error")}}a(T,"makeReadOnlyConsole");0&&(module.exports={ConfigLoadError,defineConfig,loadConfig});
|