@apollion-dsi/tokens 4.10.0 → 4.11.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/lib/build.cjs +6 -6
- package/lib/build.esm.js +6 -6
- package/lib/cli.mjs +7 -7
- package/package.json +2 -2
- package/src/ir.ts +21 -0
package/lib/build.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var F=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var s=(e,n)=>F(e,"name",{value:n,configurable:!0});var Ke=(e,n)=>{for(var o in n)F(e,o,{get:n[o],enumerable:!0})},Ze=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Ye(n))!qe.call(e,t)&&t!==o&&F(e,t,{get:()=>n[t],enumerable:!(r=Xe(n,t))||r.enumerable});return e};var Qe=e=>Ze(F({},"__esModule",{value:!0}),e);var Cn={};Ke(Cn,{build:()=>wn,check:()=>Tn});module.exports=Qe(Cn);var g=require("node:fs/promises"),ze=require("node:os"),D=require("node:path");var C=require("@apollion-dsi/core/themes/border"),P=require("@apollion-dsi/core/themes/depth"),R=require("@apollion-dsi/core/themes/font"),q=require("@apollion-dsi/core/themes/spacing"),v=require("culori");var te=require("@apollion-dsi/core/themes/dimension");function j({multiplier:e=.25,alias:n},o){let r=o!==void 0?te.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 X={"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 Y(e){let n=Object.keys(X).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(Y,"assertTokenMetaResolves");var en=(0,v.converter)("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function se(e){return e.split(".").map(I).join(".")}s(se,"kebabPath");function V(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(V,"rawValue");function M(e,n){return Number(e.toFixed(n))||0}s(M,"round");function K(e){let n=en((0,v.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[M(n.l,4),M(n.c,4),M(n.h??0,2)],r=(0,v.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:M(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(K,"toColorValue");var ae=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function T(e){let n=ae.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(T,"toDimensionValue");function y(e){return{type:"color",value:K(e)}}s(y,"colorToken");function ie(e){let n={};for(let[o,r]of Object.entries(e))n[o]=y(r);return n}s(ie,"recordColorGroup");var nn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ce(e){let n={};for(let o of nn){let r=e[o];n[o]={base:y(r.base),dark:y(r.dark),action:y(r.action),active:y(r.active),light:y(r.light)}}return n.grayscale=ie(e.grayscale),n.neutral=ie(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}s(ce,"buildColorPrimitives");function le(e){let n=j(q.defaultInputSpacing,e),o={};for(let r of Object.keys(q.defaultInputSpacing.alias))o[r]={type:"dimension",value:T(n(r))};return o}s(le,"buildSpacePrimitives");function de(){let e={};for(let[n,o]of Object.entries(C.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:T(o)};return e}s(de,"buildBorderWidthPrimitives");function on(e,n){return{color:ce(e),space:le(n),borderWidth:de()}}s(on,"buildPrimitives");var ue={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"},pe={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function rn(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(rn,"lookupPrimitive");function A(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?rn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:K(i)}}:y(i)}return r}s(A,"colorRefGroup");var fe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},tn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function sn(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(sn,"lookupDimensionPrimitive");function Z(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?sn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:T(i)}}:{type:"dimension",value:T(i)}}return r}s(Z,"dimensionRefGroup");function me(e){let n={},o={};for(let[i,a]of Object.entries(C.defaultInputBorder.borderRadius))ae.test(a)?n[i]={type:"dimension",value:T(a)}:o[i]=a;let r=Z(C.defaultInputBorder.borderWidth,e,tn),t={};for(let[i,a]of Object.entries(C.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(me,"buildBorder");function ge(e){let n=(0,R.createFont)(R.defaultInputFont,e),o={};for(let[c,u]of Object.entries(R.defaultInputFont.fontFamily)){let f=u.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,u]of Object.entries(n.fontSize))r[c]={type:"dimension",value:T(u)};let t={};for(let[c,u]of Object.entries(R.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${u}`,weight:u}};let i={};for(let[c,u]of Object.entries(R.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${u}`,number:u}};let a={letterSpacing:R.defaultInputFont.letterSpacing,textTransform:R.defaultInputFont.textTransform,fontStyle:R.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(ge,"buildFont");var an=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function cn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(an),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(u=>T(a[u]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:K(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(cn,"parseShadow");function ye(e){let n=(0,P.createDeth)(e),o={};for(let r of Object.keys(P.levelValues))o[r]={type:"shadow",value:cn(n(r))};return o}s(ye,"buildShadow");function N(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(h(i)){o.add(a);let c=X[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]=N(i,a,o)}return r}s(N,"decorateGroup");function ln(e){let n=new Set,o=N(e.primitives,"",n),r=N(e.groups,"",n);return Y(n),{...e,primitives:o,groups:r}}s(ln,"decorateMeta");function L(e,n){return N(e,"",n)}s(L,"decorateSlice");function he(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);h(t)?o.add(i):he(t,i,o)}}s(he,"collectPaths");function be(e){let n=new Set;for(let o of e)he(o.groups,"",n);Y(n)}s(be,"assertSlicesMetaComplete");function Re(){let e=de(),o=me({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:L({"border-width":e,border:o.group},t),extensions:r}}s(Re,"buildBaseIR");function Ie(e){let n=ge(e),o=new Set;return{groups:L({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Ie,"buildFontIR");function ke(e,n){let o=ce(n),r=new Set;return{groups:L({color:o,bg:A(e.bg,n,ue),text:A(e.text,n,pe),shadow:ye(n)},r),extensions:{}}}s(ke,"buildColorIR");function Se(e,n){let o=le(n),r={space:o},t=new Set;return{groups:L({space:o,spacing:Z(e.spacing,r,fe)},t),extensions:{}}}s(Se,"buildSpacingIR");function dn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=on(n,o.dimension),i=me(t),a=ge(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 u={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:A(e.bg,n,ue),text:A(e.text,n,pe),spacing:Z(e.spacing,t,fe),border:i.group,font:a.group,shadow:ye(n)},extensions:c};return ln(u)}s(dn,"buildIR");var xe=dn;var un="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function De(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?o.push(` --apollion-${i.join("-")}: ${V(t.value)};`):De(t,i,o)}}s(De,"emitVars");function we(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${V(t.value)}; }`):we(t,i,o)}}s(we,"emitProperties");function Te(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[un,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),De(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),we(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(B,"renderSet");function
|
|
4
|
-
`}s(
|
|
5
|
-
`)}s(
|
|
6
|
-
`}s(
|
|
1
|
+
"use strict";var F=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var s=(e,n)=>F(e,"name",{value:n,configurable:!0});var Qe=(e,n)=>{for(var o in n)F(e,o,{get:n[o],enumerable:!0})},en=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Ke(n))!Ze.call(e,t)&&t!==o&&F(e,t,{get:()=>n[t],enumerable:!(r=qe(n,t))||r.enumerable});return e};var nn=e=>en(F({},"__esModule",{value:!0}),e);var $n={};Qe($n,{build:()=>vn,check:()=>Cn});module.exports=nn($n);var g=require("node:fs/promises"),Ye=require("node:os"),D=require("node:path");var C=require("@apollion-dsi/core/themes/border"),se=require("@apollion-dsi/core/themes/colors"),P=require("@apollion-dsi/core/themes/depth"),R=require("@apollion-dsi/core/themes/font"),q=require("@apollion-dsi/core/themes/spacing"),v=require("culori");var ie=require("@apollion-dsi/core/themes/dimension");function j({multiplier:e=.25,alias:n},o){let r=o!==void 0?ie.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 X={"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 Y(e){let n=Object.keys(X).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(Y,"assertTokenMetaResolves");var on=(0,v.converter)("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function ae(e){return e.split(".").map(I).join(".")}s(ae,"kebabPath");function V(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(V,"rawValue");function M(e,n){return Number(e.toFixed(n))||0}s(M,"round");function Z(e){let n=on((0,v.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[M(n.l,4),M(n.c,4),M(n.h??0,2)],r=(0,v.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:M(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(Z,"toColorValue");var ce=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function T(e){let n=ce.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(T,"toDimensionValue");function y(e){return{type:"color",value:Z(e)}}s(y,"colorToken");function K(e){let n={};for(let[o,r]of Object.entries(e))n[o]=y(r);return n}s(K,"recordColorGroup");function le(e){let n=(0,se.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=y(t);return o.neutral=K(n.neutral),o}s(le,"buildReadableTextGroup");var rn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function de(e){let n={};for(let o of rn){let r=e[o];n[o]={base:y(r.base),dark:y(r.dark),action:y(r.action),active:y(r.active),light:y(r.light)}}return n.grayscale=K(e.grayscale),n.neutral=K(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}s(de,"buildColorPrimitives");function ue(e){let n=j(q.defaultInputSpacing,e),o={};for(let r of Object.keys(q.defaultInputSpacing.alias))o[r]={type:"dimension",value:T(n(r))};return o}s(ue,"buildSpacePrimitives");function pe(){let e={};for(let[n,o]of Object.entries(C.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:T(o)};return e}s(pe,"buildBorderWidthPrimitives");function tn(e,n){return{color:de(e),space:ue(n),borderWidth:pe()}}s(tn,"buildPrimitives");var fe={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"},me={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 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(sn,"lookupPrimitive");function A(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?sn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:Z(i)}}:y(i)}return r}s(A,"colorRefGroup");var ge={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},an={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function cn(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(cn,"lookupDimensionPrimitive");function Q(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:"dimension",value:{kind:"ref",path:a,resolved:T(i)}}:{type:"dimension",value:T(i)}}return r}s(Q,"dimensionRefGroup");function ye(e){let n={},o={};for(let[i,a]of Object.entries(C.defaultInputBorder.borderRadius))ce.test(a)?n[i]={type:"dimension",value:T(a)}:o[i]=a;let r=Q(C.defaultInputBorder.borderWidth,e,an),t={};for(let[i,a]of Object.entries(C.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(ye,"buildBorder");function he(e){let n=(0,R.createFont)(R.defaultInputFont,e),o={};for(let[c,u]of Object.entries(R.defaultInputFont.fontFamily)){let f=u.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,u]of Object.entries(n.fontSize))r[c]={type:"dimension",value:T(u)};let t={};for(let[c,u]of Object.entries(R.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${u}`,weight:u}};let i={};for(let[c,u]of Object.entries(R.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${u}`,number:u}};let a={letterSpacing:R.defaultInputFont.letterSpacing,textTransform:R.defaultInputFont.textTransform,fontStyle:R.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(he,"buildFont");var ln=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function dn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(ln),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(u=>T(a[u]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Z(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(dn,"parseShadow");function be(e){let n=(0,P.createDeth)(e),o={};for(let r of Object.keys(P.levelValues))o[r]={type:"shadow",value:dn(n(r))};return o}s(be,"buildShadow");function N(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(h(i)){o.add(a);let c=X[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]=N(i,a,o)}return r}s(N,"decorateGroup");function un(e){let n=new Set,o=N(e.primitives,"",n),r=N(e.groups,"",n);return Y(n),{...e,primitives:o,groups:r}}s(un,"decorateMeta");function L(e,n){return N(e,"",n)}s(L,"decorateSlice");function Re(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);h(t)?o.add(i):Re(t,i,o)}}s(Re,"collectPaths");function Ie(e){let n=new Set;for(let o of e)Re(o.groups,"",n);Y(n)}s(Ie,"assertSlicesMetaComplete");function ke(){let e=pe(),o=ye({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:L({"border-width":e,border:o.group},t),extensions:r}}s(ke,"buildBaseIR");function Se(e){let n=he(e),o=new Set;return{groups:L({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Se,"buildFontIR");function xe(e,n){let o=de(n),r=new Set;return{groups:L({color:o,bg:A(e.bg,n,fe),text:A(e.text,n,me),tx:le(n),shadow:be(n)},r),extensions:{}}}s(xe,"buildColorIR");function De(e,n){let o=ue(n),r={space:o},t=new Set;return{groups:L({space:o,spacing:Q(e.spacing,r,ge)},t),extensions:{}}}s(De,"buildSpacingIR");function pn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=tn(n,o.dimension),i=ye(t),a=he(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 u={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:A(e.bg,n,fe),text:A(e.text,n,me),tx:le(n),spacing:Q(e.spacing,t,ge),border:i.group,font:a.group,shadow:be(n)},extensions:c};return un(u)}s(pn,"buildIR");var we=pn;var fn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?o.push(` --apollion-${i.join("-")}: ${V(t.value)};`):Te(t,i,o)}}s(Te,"emitVars");function ve(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${V(t.value)}; }`):ve(t,i,o)}}s(ve,"emitProperties");function Ce(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[fn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),Te(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ve(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
+
`)}s(Ce,"renderCss");function Ve(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(Ve,"colorValue");function $(e){return{value:e.value,unit:e.unit}}s($,"dimensionValue");function mn(e){let n=e.shadow,o={color:Ve(n.color),offsetX:$(n.offsetX),offsetY:$(n.offsetY),blur:$(n.blur),spread:$(n.spread)};return n.inset&&(o.inset=!0),o}s(mn,"shadowValue");function gn(e){switch(e.kind){case"ref":return`{${ae(e.path)}}`;case"color":return Ve(e);case"dimension":return $(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return mn(e)}}s(gn,"projectValue");function yn(e){let n={$value:gn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(yn,"projectToken");function ee(e){let n={};for(let[o,r]of Object.entries(e))n[I(o)]=h(r)?yn(r):ee(r);return n}s(ee,"projectGroup");function B(e,n){let o={$description:n,...ee(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(B,"renderSet");function $e(e){return B(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s($e,"renderBaseSet");function Ge(e,n,o,r){return B(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(Ge,"renderColorSet");function Oe(e,n){return B(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Oe,"renderSpacingSet");function Ee(e,n){return B(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(Ee,"renderFontSet");function Fe(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)}
|
|
4
|
+
`}s(Fe,"renderResolver");var hn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function je(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))h(i)?o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(V(i.value))},`):(o.push(`${r}${t}: {`),je(i,n+1,o),o.push(`${r}},`))}s(je,"emitGroup");function Me(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[hn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return je(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
5
|
+
`)}s(Me,"renderTs");var bn=["light","dark"],Rn=["positive","negative"],In=["compact","normal","spacious"];function _(e){let n=e.modes??bn,o=e.surfaces??Rn,r=e.dimensions??In,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let u of n)for(let f of o)for(let w of r)i.push({brand:a,colors:c,mode:u,surface:f,dimension:w});return i}s(_,"expandVariants");function Ae(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Ae,"variantName");var Ne=require("node:crypto");function oe(e){return(0,Ne.createHash)("sha256").update(e).digest("hex")}s(oe,"sha256");function re(e){return oe(ne(e))}s(re,"hashConfig");function ne(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(ne).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${ne(e[r])}`).join(",")}}`}s(ne,"stableStringify");function Pe(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(Pe,"detectGitCommit");function Le(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Le,"buildEnv");function Be(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)}
|
|
6
|
+
`}s(Be,"serializeManifest");var kn="json/sets",_e="json/resolver.json";function H(e){return`${kn}/${e}.json`}s(H,"setFile");function Sn(e,n,o){return`${e}.color.${n}.${o}`}s(Sn,"colorSetName");function xn(e){return`spacing.${e}`}s(xn,"spacingSetName");function Dn(e){return`font.${e}`}s(Dn,"fontSetName");function W(e,n){e.includes(n)||e.push(n)}s(W,"pushUnique");function He(e){let n=_(e),o=[],r=[],t=[],i=[],a=new Set,c=[],u=new Set,f=[],w=new Set,G=[];for(let d of n){W(o,d.brand),W(r,d.mode),W(t,d.surface),W(i,d.dimension);let m=Sn(d.brand,d.mode,d.surface);a.has(m)||(a.add(m),c.push({kind:"color",name:m,file:H(m),brand:d.brand,mode:d.mode,surface:d.surface}));let k=xn(d.dimension);u.has(k)||(u.add(k),f.push({kind:"spacing",name:k,file:H(k),dimension:d.dimension}));let p=Dn(d.dimension);w.has(p)||(w.add(p),G.push({kind:"font",name:p,file:H(p),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:H("base")},spacing:f,font:G,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(He,"planSets");var te=require("@apollion-dsi/core/themes/foundation"),Ue=require("@apollion-dsi/core/themes/semantic"),ze=require("@apollion-dsi/core/themes/spacing"),Xe=require("@apollion-dsi/core/themes/surface");var x=require("culori");var io=(0,x.converter)("oklch");function l(e,n,o){let r=(0,x.parse)(e),t=(0,x.parse)(n);if(!r||!t)return e;let i=(0,x.interpolate)([r,t],"oklch");return(0,x.formatHex)(i(o))??e}s(l,"mixOklch");function wn(e){return e?typeof e=="string"?e:e.base:"#000"}s(wn,"coerceToHex");function b(e,n){let o=wn(e),r=n.deepDark,t=n.deepLight;return{base:o,dark:l(o,r,.6),action:l(o,r,.2),active:l(o,t,.6),light:l(o,t,.9)}}s(b,"mountSingleColor");function We(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:l(n,o,.05),10:l(n,o,.1),20:l(n,o,.2),30:l(n,o,.3),40:l(n,o,.4),50:l(n,o,.5),60:l(n,o,.6),70:l(n,o,.7),80:l(n,o,.8),90:l(n,o,.9),100:l(n,o,1)}}s(We,"mountGreyscaleColors");function Je(e){let n=e.deepLight,o=e.deepDark,r=e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=l(r,o,.5);return{0:l(i,n,t(18)),5:l(i,n,t(17.5)),10:l(i,n,t(17)),20:l(i,n,t(16)),30:l(i,n,t(15)),40:l(i,n,t(14)),50:l(i,n,t(13)),60:l(i,n,t(12)),70:l(i,n,t(11)),80:l(i,n,t(10)),90:l(i,n,t(9)),100:l(i,n,t(8)),110:l(i,n,t(7)),120:l(i,n,t(6)),130:l(i,n,t(5)),140:l(i,n,t(4)),150:l(i,n,t(3)),160:l(i,n,t(2)),170:i,180:l(i,o,.25)}}s(Je,"mountNeutralColors");function Tn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Je(e),grayscale:We(e),main:b(e.main,e),opposite:b(e.opposite,e),complementary:b(e.complementary,e),danger:b(e.danger,e),information:b(e.information,e),success:b(e.success,e),warning:b(e.warning,e),primary:b(e.primary,e),secondary:b(e.secondary,e),tertiary:b(e.tertiary,e)}}s(Tn,"composeColors");function J(e,n=ze.defaultInputSpacing){let o=Tn(e.colors),r=j(n,e.dimension),t=(0,Ue.createSemantic)({colors:o,spacing:r}),i=(0,te.createFoundation)(t);return e.surface==="negative"&&(i=(0,te.createFoundation)((0,Xe.invertForSurface)({semantic:t,colors:o},"negative").semantic)),{foundation:i,colors:o}}s(J,"buildVariantThemes");async function vn(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=_(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,g.mkdtemp)((0,D.join)((0,Ye.tmpdir)(),"apollion-tokens-"));try{let u=[],f=s(async(d,m)=>{await Vn(c,d,m),u.push({path:d,sha256:oe(m)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=He(n),m=[],k=ke();m.push(k),await f(d.base.file,$e(k));for(let p of d.spacing){let S=i.find(E=>E.dimension===p.dimension),{foundation:U}=J(S),O=De(U,p.dimension);m.push(O),await f(p.file,Oe(O,p.dimension))}for(let p of d.font){let S=Se(p.dimension);m.push(S),await f(p.file,Ee(S,p.dimension))}for(let p of d.color){let S=i.find(z=>z.brand===p.brand&&z.mode===p.mode&&z.surface===p.surface),{foundation:U,colors:O}=J(S),E=xe(U,O);m.push(E),await f(p.file,Ge(E,p.brand,p.mode,p.surface))}Ie(m),await f(_e,Fe(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:m,colors:k}=J(d),p=we(m,k,d),S=Ae(d);a.css&&await f(`css/${S}.css`,Ce(p)),a.ts&&await f(`ts/${S}.d.ts`,Me(p))}let w={configHash:re(n),files:u,gitCommit:Pe(r),buildEnv:Le()},G=Be(w);return await(0,g.writeFile)((0,D.join)(c,"manifest.json"),G),await(0,g.rm)(o,{recursive:!0,force:!0}),await(0,g.mkdir)((0,D.dirname)(o),{recursive:!0}),await(0,g.rename)(c,o),t&&console.log(`\u2713 ${u.length} files \u2192 ${o}`),{manifest:w,outDir:o}}catch(u){throw await(0,g.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),u}}s(vn,"build");async function Cn(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,g.readFile)((0,D.join)(o,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===re(n)}s(Cn,"check");async function Vn(e,n,o){let r=(0,D.join)(e,n);await(0,g.mkdir)((0,D.dirname)(r),{recursive:!0}),await(0,g.writeFile)(r,o)}s(Vn,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var _e=Object.defineProperty;var s=(e,n)=>_e(e,"name",{value:n,configurable:!0}),He=(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 Pe,mkdtemp as Vn,readFile as $n,rename as Gn,rm as Ne,writeFile as Le}from"node:fs/promises";import{tmpdir as On}from"node:os";import{dirname as Be,join as L}from"node:path";import{defaultInputBorder as G}from"@apollion-dsi/core/themes/border";import{createDeth as Je,levelValues as Ue}from"@apollion-dsi/core/themes/depth";import{createFont as ze,defaultInputFont as S}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as K}from"@apollion-dsi/core/themes/spacing";import{converter as Xe,formatHex as Ye,parse as qe}from"culori";import{DIMENSION_MULTIPLIERS as We}from"@apollion-dsi/core/themes/dimension";function V({multiplier:e=.25,alias:n},o){let r=o!==void 0?We[o]:e;return(...i)=>i.map(t=>{let a=typeof t=="string"?n[t]:t;return`${r*a}rem`}).join(" ")}s(V,"createSpacing");var H={"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 W(e){let n=Object.keys(H).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(W,"assertTokenMetaResolves");var Ke=Xe("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 Q(e){return e.split(".").map(b).join(".")}s(Q,"kebabPath");function D(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(D,"rawValue");function $(e,n){return Number(e.toFixed(n))||0}s($,"round");function J(e){let n=Ke(qe(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[$(n.l,4),$(n.c,4),$(n.h??0,2)],r=Ye(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:$(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(J,"toColorValue");var ee=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function x(e){let n=ee.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:J(e)}}s(g,"colorToken");function Z(e){let n={};for(let[o,r]of Object.entries(e))n[o]=g(r);return n}s(Z,"recordColorGroup");var Ze=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ne(e){let n={};for(let o of Ze){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=Z(e.grayscale),n.neutral=Z(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(ne,"buildColorPrimitives");function oe(e){let n=V(K,e),o={};for(let r of Object.keys(K.alias))o[r]={type:"dimension",value:x(n(r))};return o}s(oe,"buildSpacePrimitives");function re(){let e={};for(let[n,o]of Object.entries(G.borderWidth))e[n]={type:"dimension",value:x(o)};return e}s(re,"buildBorderWidthPrimitives");function Qe(e,n){return{color:ne(e),space:oe(n),borderWidth:re()}}s(Qe,"buildPrimitives");var te={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 en(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(en,"lookupPrimitive");function O(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=o[i],c=a?en(n,a):void 0;r[i]=a&&c===t?{type:"color",value:{kind:"ref",path:a,resolved:J(t)}}:g(t)}return r}s(O,"colorRefGroup");var se={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},nn={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],i=e[r];for(let t of o.slice(1))if(i&&!y(i)&&t in i)i=i[t];else return;return i&&y(i)&&i.value.kind==="dimension"?i.value.raw:void 0}s(on,"lookupDimensionPrimitive");function U(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=o[i],c=a?on(n,a):void 0;r[i]=a&&c===t?{type:"dimension",value:{kind:"ref",path:a,resolved:x(t)}}:{type:"dimension",value:x(t)}}return r}s(U,"dimensionRefGroup");function ae(e){let n={},o={};for(let[t,a]of Object.entries(G.borderRadius))ee.test(a)?n[t]={type:"dimension",value:x(a)}:o[t]=a;let r=U(G.borderWidth,e,nn),i={};for(let[t,a]of Object.entries(G.borderStyle))i[t]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:i},extensions:o}}s(ae,"buildBorder");function ce(e){let n=ze(S,e),o={};for(let[c,u]of Object.entries(S.fontFamily)){let f=u.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,u]of Object.entries(n.fontSize))r[c]={type:"dimension",value:x(u)};let i={};for(let[c,u]of Object.entries(S.fontWeight))i[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${u}`,weight:u}};let t={};for(let[c,u]of Object.entries(S.lineHeight))t[c]={type:"number",value:{kind:"number",raw:`${u}`,number:u}};let a={letterSpacing:S.letterSpacing,textTransform:S.textTransform,fontStyle:S.fontStyle};return{group:{family:o,size:r,weight:i,lineHeight:t},extensions:a}}s(ce,"buildFont");var rn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function tn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(rn),i=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(u=>x(a[u]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:J(i),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(tn,"parseShadow");function le(e){let n=Je(e),o={};for(let r of Object.keys(Ue))o[r]={type:"shadow",value:tn(n(r))};return o}s(le,"buildShadow");function E(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=n?`${n}.${b(i)}`:b(i);if(y(t)){o.add(a);let c=H[a];r[i]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...t,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:t}else r[i]=E(t,a,o)}return r}s(E,"decorateGroup");function sn(e){let n=new Set,o=E(e.primitives,"",n),r=E(e.groups,"",n);return W(n),{...e,primitives:o,groups:r}}s(sn,"decorateMeta");function F(e,n){return E(e,"",n)}s(F,"decorateSlice");function de(e,n,o){for(let[r,i]of Object.entries(e)){let t=n?`${n}.${b(r)}`:b(r);y(i)?o.add(t):de(i,t,o)}}s(de,"collectPaths");function ue(e){let n=new Set;for(let o of e)de(o.groups,"",n);W(n)}s(ue,"assertSlicesMetaComplete");function pe(){let e=re(),o=ae({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let i=new Set;return{groups:F({"border-width":e,border:o.group},i),extensions:r}}s(pe,"buildBaseIR");function fe(e){let n=ce(e),o=new Set;return{groups:F({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(fe,"buildFontIR");function me(e,n){let o=ne(n),r=new Set;return{groups:F({color:o,bg:O(e.bg,n,te),text:O(e.text,n,ie),shadow:le(n)},r),extensions:{}}}s(me,"buildColorIR");function ge(e,n){let o=oe(n),r={space:o},i=new Set;return{groups:F({space:o,spacing:U(e.spacing,r,se)},i),extensions:{}}}s(ge,"buildSpacingIR");function an(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},i=Qe(n,o.dimension),t=ae(i),a=ce(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(t.extensions).length>0&&(c["com.apollion.border"]={radius:t.extensions});let u={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:i,groups:{bg:O(e.bg,n,te),text:O(e.text,n,ie),spacing:U(e.spacing,i,se),border:t.group,font:a.group,shadow:le(n)},extensions:c};return sn(u)}s(an,"buildIR");var ye=an;var cn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function he(e,n,o){for(let[r,i]of Object.entries(e)){let t=[...n,b(r)];y(i)?o.push(` --apollion-${t.join("-")}: ${D(i.value)};`):he(i,t,o)}}s(he,"emitVars");function be(e,n,o){for(let[r,i]of Object.entries(e)){let t=[...n,b(r)];y(i)?i.type==="color"&&o.push(` @property --apollion-${t.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${D(i.value)}; }`):be(i,t,o)}}s(be,"emitProperties");function Re(e){let{brand:n,mode:o,surface:r,dimension:i}=e.meta,t=[cn,""];return t.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${i} */`,"",":root {"),he(e.groups,[],t),t.push("}",""),t.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),be(e.groups,[],t),t.push("}",""),t.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(j,"renderSet");function
|
|
4
|
-
`}s(
|
|
5
|
-
`)}s(
|
|
6
|
-
`}s(
|
|
1
|
+
var He=Object.defineProperty;var s=(e,n)=>He(e,"name",{value:n,configurable:!0}),We=(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 Le,mkdtemp as Gn,readFile as On,rename as En,rm as Pe,writeFile as Be}from"node:fs/promises";import{tmpdir as Fn}from"node:os";import{dirname as _e,join as L}from"node:path";import{defaultInputBorder as G}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Ue}from"@apollion-dsi/core/themes/colors";import{createDeth as ze,levelValues as Xe}from"@apollion-dsi/core/themes/depth";import{createFont as Ye,defaultInputFont as S}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Z}from"@apollion-dsi/core/themes/spacing";import{converter as qe,formatHex as Ke,parse as Ze}from"culori";import{DIMENSION_MULTIPLIERS as Je}from"@apollion-dsi/core/themes/dimension";function V({multiplier:e=.25,alias:n},o){let r=o!==void 0?Je[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(V,"createSpacing");var H={"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 W(e){let n=Object.keys(H).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(W,"assertTokenMetaResolves");var Qe=qe("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 Q(e){return e.split(".").map(b).join(".")}s(Q,"kebabPath");function D(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(D,"rawValue");function $(e,n){return Number(e.toFixed(n))||0}s($,"round");function U(e){let n=Qe(Ze(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[$(n.l,4),$(n.c,4),$(n.h??0,2)],r=Ke(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:$(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(U,"toColorValue");var ee=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function x(e){let n=ee.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:U(e)}}s(g,"colorToken");function J(e){let n={};for(let[o,r]of Object.entries(e))n[o]=g(r);return n}s(J,"recordColorGroup");function ne(e){let n=Ue(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=g(t);return o.neutral=J(n.neutral),o}s(ne,"buildReadableTextGroup");var en=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function oe(e){let n={};for(let o of en){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=J(e.grayscale),n.neutral=J(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(oe,"buildColorPrimitives");function re(e){let n=V(Z,e),o={};for(let r of Object.keys(Z.alias))o[r]={type:"dimension",value:x(n(r))};return o}s(re,"buildSpacePrimitives");function te(){let e={};for(let[n,o]of Object.entries(G.borderWidth))e[n]={type:"dimension",value:x(o)};return e}s(te,"buildBorderWidthPrimitives");function nn(e,n){return{color:oe(e),space:re(n),borderWidth:te()}}s(nn,"buildPrimitives");var ie={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"},se={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function on(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(on,"lookupPrimitive");function O(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:"color",value:{kind:"ref",path:a,resolved:U(i)}}:g(i)}return r}s(O,"colorRefGroup");var ae={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},rn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function tn(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(tn,"lookupDimensionPrimitive");function z(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?tn(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(z,"dimensionRefGroup");function ce(e){let n={},o={};for(let[i,a]of Object.entries(G.borderRadius))ee.test(a)?n[i]={type:"dimension",value:x(a)}:o[i]=a;let r=z(G.borderWidth,e,rn),t={};for(let[i,a]of Object.entries(G.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 le(e){let n=Ye(S,e),o={};for(let[c,u]of Object.entries(S.fontFamily)){let f=u.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,u]of Object.entries(n.fontSize))r[c]={type:"dimension",value:x(u)};let t={};for(let[c,u]of Object.entries(S.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${u}`,weight:u}};let i={};for(let[c,u]of Object.entries(S.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${u}`,number:u}};let a={letterSpacing:S.letterSpacing,textTransform:S.textTransform,fontStyle:S.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(le,"buildFont");var sn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function an(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(sn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(u=>x(a[u]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:U(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(an,"parseShadow");function de(e){let n=ze(e),o={};for(let r of Object.keys(Xe))o[r]={type:"shadow",value:an(n(r))};return o}s(de,"buildShadow");function E(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=H[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]=E(i,a,o)}return r}s(E,"decorateGroup");function cn(e){let n=new Set,o=E(e.primitives,"",n),r=E(e.groups,"",n);return W(n),{...e,primitives:o,groups:r}}s(cn,"decorateMeta");function F(e,n){return E(e,"",n)}s(F,"decorateSlice");function ue(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${b(r)}`:b(r);y(t)?o.add(i):ue(t,i,o)}}s(ue,"collectPaths");function pe(e){let n=new Set;for(let o of e)ue(o.groups,"",n);W(n)}s(pe,"assertSlicesMetaComplete");function fe(){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:F({"border-width":e,border:o.group},t),extensions:r}}s(fe,"buildBaseIR");function me(e){let n=le(e),o=new Set;return{groups:F({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(me,"buildFontIR");function ge(e,n){let o=oe(n),r=new Set;return{groups:F({color:o,bg:O(e.bg,n,ie),text:O(e.text,n,se),tx:ne(n),shadow:de(n)},r),extensions:{}}}s(ge,"buildColorIR");function ye(e,n){let o=re(n),r={space:o},t=new Set;return{groups:F({space:o,spacing:z(e.spacing,r,ae)},t),extensions:{}}}s(ye,"buildSpacingIR");function ln(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=nn(n,o.dimension),i=ce(t),a=le(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 u={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:O(e.bg,n,ie),text:O(e.text,n,se),tx:ne(n),spacing:z(e.spacing,t,ae),border:i.group,font:a.group,shadow:de(n)},extensions:c};return cn(u)}s(ln,"buildIR");var he=ln;var dn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function be(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?o.push(` --apollion-${i.join("-")}: ${D(t.value)};`):be(t,i,o)}}s(be,"emitVars");function Re(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: ${D(t.value)}; }`):Re(t,i,o)}}s(Re,"emitProperties");function Ie(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[dn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),be(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Re(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
+
`)}s(Ie,"renderCss");function ke(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(ke,"colorValue");function w(e){return{value:e.value,unit:e.unit}}s(w,"dimensionValue");function un(e){let n=e.shadow,o={color:ke(n.color),offsetX:w(n.offsetX),offsetY:w(n.offsetY),blur:w(n.blur),spread:w(n.spread)};return n.inset&&(o.inset=!0),o}s(un,"shadowValue");function pn(e){switch(e.kind){case"ref":return`{${Q(e.path)}}`;case"color":return ke(e);case"dimension":return w(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return un(e)}}s(pn,"projectValue");function fn(e){let n={$value:pn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(fn,"projectToken");function X(e){let n={};for(let[o,r]of Object.entries(e))n[b(o)]=y(r)?fn(r):X(r);return n}s(X,"projectGroup");function j(e,n){let o={$description:n,...X(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(j,"renderSet");function Se(e){return j(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Se,"renderBaseSet");function xe(e,n,o,r){return j(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(xe,"renderColorSet");function De(e,n){return j(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(De,"renderSpacingSet");function we(e,n){return j(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(we,"renderFontSet");function Te(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)}
|
|
4
|
+
`}s(Te,"renderResolver");var mn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function ve(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))y(i)?o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(D(i.value))},`):(o.push(`${r}${t}: {`),ve(i,n+1,o),o.push(`${r}},`))}s(ve,"emitGroup");function Ce(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[mn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return ve(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
5
|
+
`)}s(Ce,"renderTs");var gn=["light","dark"],yn=["positive","negative"],hn=["compact","normal","spacious"];function M(e){let n=e.modes??gn,o=e.surfaces??yn,r=e.dimensions??hn,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let u of n)for(let f of o)for(let k of r)i.push({brand:a,colors:c,mode:u,surface:f,dimension:k});return i}s(M,"expandVariants");function Ve(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Ve,"variantName");import{createHash as bn}from"node:crypto";function q(e){return bn("sha256").update(e).digest("hex")}s(q,"sha256");function K(e){return q(Y(e))}s(K,"hashConfig");function Y(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Y).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Y(e[r])}`).join(",")}}`}s(Y,"stableStringify");function $e(e){try{let{execSync:n}=We("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s($e,"detectGitCommit");function Ge(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Ge,"buildEnv");function Oe(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)}
|
|
6
|
+
`}s(Oe,"serializeManifest");var Rn="json/sets",Ee="json/resolver.json";function A(e){return`${Rn}/${e}.json`}s(A,"setFile");function In(e,n,o){return`${e}.color.${n}.${o}`}s(In,"colorSetName");function kn(e){return`spacing.${e}`}s(kn,"spacingSetName");function Sn(e){return`font.${e}`}s(Sn,"fontSetName");function N(e,n){e.includes(n)||e.push(n)}s(N,"pushUnique");function Fe(e){let n=M(e),o=[],r=[],t=[],i=[],a=new Set,c=[],u=new Set,f=[],k=new Set,T=[];for(let d of n){N(o,d.brand),N(r,d.mode),N(t,d.surface),N(i,d.dimension);let m=In(d.brand,d.mode,d.surface);a.has(m)||(a.add(m),c.push({kind:"color",name:m,file:A(m),brand:d.brand,mode:d.mode,surface:d.surface}));let R=kn(d.dimension);u.has(R)||(u.add(R),f.push({kind:"spacing",name:R,file:A(R),dimension:d.dimension}));let p=Sn(d.dimension);k.has(p)||(k.add(p),T.push({kind:"font",name:p,file:A(p),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:A("base")},spacing:f,font:T,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Fe,"planSets");import{createFoundation as Ne}from"@apollion-dsi/core/themes/foundation";import{createSemantic as vn}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Cn}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Vn}from"@apollion-dsi/core/themes/surface";import{converter as xn,formatHex as Dn,interpolate as wn,parse as je}from"culori";var Io=xn("oklch");function l(e,n,o){let r=je(e),t=je(n);if(!r||!t)return e;let i=wn([r,t],"oklch");return Dn(i(o))??e}s(l,"mixOklch");function Tn(e){return e?typeof e=="string"?e:e.base:"#000"}s(Tn,"coerceToHex");function h(e,n){let o=Tn(e),r=n.deepDark,t=n.deepLight;return{base:o,dark:l(o,r,.6),action:l(o,r,.2),active:l(o,t,.6),light:l(o,t,.9)}}s(h,"mountSingleColor");function Me(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:l(n,o,.05),10:l(n,o,.1),20:l(n,o,.2),30:l(n,o,.3),40:l(n,o,.4),50:l(n,o,.5),60:l(n,o,.6),70:l(n,o,.7),80:l(n,o,.8),90:l(n,o,.9),100:l(n,o,1)}}s(Me,"mountGreyscaleColors");function Ae(e){let n=e.deepLight,o=e.deepDark,r=e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=l(r,o,.5);return{0:l(i,n,t(18)),5:l(i,n,t(17.5)),10:l(i,n,t(17)),20:l(i,n,t(16)),30:l(i,n,t(15)),40:l(i,n,t(14)),50:l(i,n,t(13)),60:l(i,n,t(12)),70:l(i,n,t(11)),80:l(i,n,t(10)),90:l(i,n,t(9)),100:l(i,n,t(8)),110:l(i,n,t(7)),120:l(i,n,t(6)),130:l(i,n,t(5)),140:l(i,n,t(4)),150:l(i,n,t(3)),160:l(i,n,t(2)),170:i,180:l(i,o,.25)}}s(Ae,"mountNeutralColors");function $n(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Ae(e),grayscale:Me(e),main:h(e.main,e),opposite:h(e.opposite,e),complementary:h(e.complementary,e),danger:h(e.danger,e),information:h(e.information,e),success:h(e.success,e),warning:h(e.warning,e),primary:h(e.primary,e),secondary:h(e.secondary,e),tertiary:h(e.tertiary,e)}}s($n,"composeColors");function P(e,n=Cn){let o=$n(e.colors),r=V(n,e.dimension),t=vn({colors:o,spacing:r}),i=Ne(t);return e.surface==="negative"&&(i=Ne(Vn({semantic:t,colors:o},"negative").semantic)),{foundation:i,colors:o}}s(P,"buildVariantThemes");async function _o(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=M(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await Gn(L(Fn(),"apollion-tokens-"));try{let u=[],f=s(async(d,m)=>{await jn(c,d,m),u.push({path:d,sha256:q(m)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=Fe(n),m=[],R=fe();m.push(R),await f(d.base.file,Se(R));for(let p of d.spacing){let I=i.find(C=>C.dimension===p.dimension),{foundation:B}=P(I),v=ye(B,p.dimension);m.push(v),await f(p.file,De(v,p.dimension))}for(let p of d.font){let I=me(p.dimension);m.push(I),await f(p.file,we(I,p.dimension))}for(let p of d.color){let I=i.find(_=>_.brand===p.brand&&_.mode===p.mode&&_.surface===p.surface),{foundation:B,colors:v}=P(I),C=ge(B,v);m.push(C),await f(p.file,xe(C,p.brand,p.mode,p.surface))}pe(m),await f(Ee,Te(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:m,colors:R}=P(d),p=he(m,R,d),I=Ve(d);a.css&&await f(`css/${I}.css`,Ie(p)),a.ts&&await f(`ts/${I}.d.ts`,Ce(p))}let k={configHash:K(n),files:u,gitCommit:$e(r),buildEnv:Ge()},T=Oe(k);return await Be(L(c,"manifest.json"),T),await Pe(o,{recursive:!0,force:!0}),await Le(_e(o),{recursive:!0}),await En(c,o),t&&console.log(`\u2713 ${u.length} files \u2192 ${o}`),{manifest:k,outDir:o}}catch(u){throw await Pe(c,{recursive:!0,force:!0}).catch(()=>{}),u}}s(_o,"build");async function Ho(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await On(L(o,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===K(n)}s(Ho,"check");async function jn(e,n,o){let r=L(e,n);await Le(_e(r),{recursive:!0}),await Be(r,o)}s(jn,"writeAt");export{_o as build,Ho as check};
|
package/lib/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Ze=Object.defineProperty;var s=(e,o)=>Ze(e,"name",{value:o,configurable:!0}),Qe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as Zo}from"node:fs/promises";import{resolve as ne}from"node:path";import{mkdir as Ue,mkdtemp as No,readFile as Lo,rename as _o,rm as We,writeFile as Je}from"node:fs/promises";import{tmpdir as Bo}from"node:os";import{dirname as ze,join as H}from"node:path";import{defaultInputBorder as G}from"@apollion-dsi/core/themes/border";import{createDeth as oo,levelValues as no}from"@apollion-dsi/core/themes/depth";import{createFont as ro,defaultInputFont as w}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as re}from"@apollion-dsi/core/themes/spacing";import{converter as to,formatHex as io,parse as so}from"culori";import{DIMENSION_MULTIPLIERS as eo}from"@apollion-dsi/core/themes/dimension";function A({multiplier:e=.25,alias:o},n){let r=n!==void 0?eo[n]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?o[i]:i;return`${r*a}rem`}).join(" ")}s(A,"createSpacing");var z={"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 X(e){let o=Object.keys(z).filter(n=>!e.has(n));if(o.length>0)throw new Error(`token-meta: ${o.length} stale TOKEN_META key(s) resolve to no IR node: ${o.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(X,"assertTokenMetaResolves");var ao=to("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 ie(e){return e.split(".").map(k).join(".")}s(ie,"kebabPath");function T(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(T,"rawValue");function j(e,o){return Number(e.toFixed(o))||0}s(j,"round");function q(e){let o=ao(so(e));if(!o)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let n=[j(o.l,4),j(o.c,4),j(o.h??0,2)],r=io(o)??"#000000";return o.alpha!==void 0&&o.alpha!==1?{kind:"color",raw:e,components:n,alpha:j(o.alpha,4),hex:r}:{kind:"color",raw:e,components:n,hex:r}}s(q,"toColorValue");var se=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let o=se.exec(e.trim());if(o)return{kind:"dimension",raw:e,value:Number(o[1]),unit:o[2]};let n=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(n)?n:0,unit:"rem"}}s(D,"toDimensionValue");function h(e){return{type:"color",value:q(e)}}s(h,"colorToken");function te(e){let o={};for(let[n,r]of Object.entries(e))o[n]=h(r);return o}s(te,"recordColorGroup");var co=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ae(e){let o={};for(let n of co){let r=e[n];o[n]={base:h(r.base),dark:h(r.dark),action:h(r.action),active:h(r.active),light:h(r.light)}}return o.grayscale=te(e.grayscale),o.neutral=te(e.neutral),o.baseDark=h(e.baseDark??"#000000"),o.baseLight=h(e.baseLight??"#ffffff"),o.deepDark=h(e.deepDark??"#000000"),o.deepLight=h(e.deepLight??"#ffffff"),o}s(ae,"buildColorPrimitives");function ce(e){let o=A(re,e),n={};for(let r of Object.keys(re.alias))n[r]={type:"dimension",value:D(o(r))};return n}s(ce,"buildSpacePrimitives");function le(){let e={};for(let[o,n]of Object.entries(G.borderWidth))e[o]={type:"dimension",value:D(n)};return e}s(le,"buildBorderWidthPrimitives");function lo(e,o){return{color:ae(e),space:ce(o),borderWidth:le()}}s(lo,"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 uo(e,o){let n=e;for(let r of o.split(".").slice(1))if(n&&typeof n=="object"&&r in n)n=n[r];else return;return typeof n=="string"?n:void 0}s(uo,"lookupPrimitive");function E(e,o,n){let r={};for(let[t,i]of Object.entries(e)){let a=n[t],c=a?uo(o,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:q(i)}}:h(i)}return r}s(E,"colorRefGroup");var pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},po={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function fo(e,o){let n=o.split("."),r=n[0]==="border-width"?"borderWidth":n[0],t=e[r];for(let i of n.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(fo,"lookupDimensionPrimitive");function Y(e,o,n){let r={};for(let[t,i]of Object.entries(e)){let a=n[t],c=a?fo(o,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:D(i)}}:{type:"dimension",value:D(i)}}return r}s(Y,"dimensionRefGroup");function fe(e){let o={},n={};for(let[i,a]of Object.entries(G.borderRadius))se.test(a)?o[i]={type:"dimension",value:D(a)}:n[i]=a;let r=Y(G.borderWidth,e,po),t={};for(let[i,a]of Object.entries(G.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:o,width:r,style:t},extensions:n}}s(fe,"buildBorder");function me(e){let o=ro(w,e),n={};for(let[c,l]of Object.entries(w.fontFamily)){let f=l.replace(/;\s*$/,"").trim();n[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,l]of Object.entries(o.fontSize))r[c]={type:"dimension",value:D(l)};let t={};for(let[c,l]of Object.entries(w.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(w.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:w.letterSpacing,textTransform:w.textTransform,fontStyle:w.fontStyle};return{group:{family:n,size:r,weight:t,lineHeight:i},extensions:a}}s(me,"buildFont");var mo=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function go(e){let o=e.trim(),n=o.startsWith("inset");n&&(o=o.slice(5).trim());let r=o.match(mo),t=r?r[0]:"#000000",a=(r?o.slice(0,r.index).trim():o).split(/\s+/).filter(Boolean),c=s(l=>D(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:q(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:n}}}s(go,"parseShadow");function ge(e){let o=oo(e),n={};for(let r of Object.keys(no))n[r]={type:"shadow",value:go(o(r))};return n}s(ge,"buildShadow");function F(e,o,n){let r={};for(let[t,i]of Object.entries(e)){let a=o?`${o}.${k(t)}`:k(t);if(b(i)){n.add(a);let c=z[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]=F(i,a,n)}return r}s(F,"decorateGroup");function yo(e){let o=new Set,n=F(e.primitives,"",o),r=F(e.groups,"",o);return X(o),{...e,primitives:n,groups:r}}s(yo,"decorateMeta");function P(e,o){return F(e,"",o)}s(P,"decorateSlice");function ye(e,o,n){for(let[r,t]of Object.entries(e)){let i=o?`${o}.${k(r)}`:k(r);b(t)?n.add(i):ye(t,i,n)}}s(ye,"collectPaths");function he(e){let o=new Set;for(let n of e)ye(n.groups,"",o);X(o)}s(he,"assertSlicesMetaComplete");function be(){let e=le(),n=fe({borderWidth:e}),r={};Object.keys(n.extensions).length>0&&(r["com.apollion.border"]={radius:n.extensions});let t=new Set;return{groups:P({"border-width":e,border:n.group},t),extensions:r}}s(be,"buildBaseIR");function Re(e){let o=me(e),n=new Set;return{groups:P({font:o.group},n),extensions:{"com.apollion.font":o.extensions}}}s(Re,"buildFontIR");function ke(e,o){let n=ae(o),r=new Set;return{groups:P({color:n,bg:E(e.bg,o,de),text:E(e.text,o,ue),shadow:ge(o)},r),extensions:{}}}s(ke,"buildColorIR");function Ie(e,o){let n=ce(o),r={space:n},t=new Set;return{groups:P({space:n,spacing:Y(e.spacing,r,pe)},t),extensions:{}}}s(Ie,"buildSpacingIR");function ho(e,o,n){let r={brand:n.brand,mode:n.mode,surface:n.surface,dimension:n.dimension},t=lo(o,n.dimension),i=fe(t),a=me(n.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(e.bg,o,de),text:E(e.text,o,ue),spacing:Y(e.spacing,t,pe),border:i.group,font:a.group,shadow:ge(o)},extensions:c};return yo(l)}s(ho,"buildIR");var Se=ho;var bo="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function xe(e,o,n){for(let[r,t]of Object.entries(e)){let i=[...o,k(r)];b(t)?n.push(` --apollion-${i.join("-")}: ${T(t.value)};`):xe(t,i,n)}}s(xe,"emitVars");function we(e,o,n){for(let[r,t]of Object.entries(e)){let i=[...o,k(r)];b(t)?t.type==="color"&&n.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${T(t.value)}; }`):we(t,i,n)}}s(we,"emitProperties");function De(e){let{brand:o,mode:n,surface:r,dimension:t}=e.meta,i=[bo,""];return i.push(`/* Variant: brand=${o} mode=${n} surface=${r} dimension=${t} */`,"",":root {"),xe(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),we(e.groups,[],i),i.push("}",""),i.join(`
|
|
3
|
-
`)}
|
|
4
|
-
`}
|
|
5
|
-
`}
|
|
6
|
-
`)}
|
|
7
|
-
`}
|
|
2
|
+
var Qe=Object.defineProperty;var i=(e,o)=>Qe(e,"name",{value:o,configurable:!0}),eo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as en}from"node:fs/promises";import{resolve as re}from"node:path";import{mkdir as Je,mkdtemp as _o,readFile as Bo,rename as Ho,rm as Ue,writeFile as ze}from"node:fs/promises";import{tmpdir as Wo}from"node:os";import{dirname as Xe,join as H}from"node:path";import{defaultInputBorder as A}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as no}from"@apollion-dsi/core/themes/colors";import{createDeth as ro,levelValues as to}from"@apollion-dsi/core/themes/depth";import{createFont as io,defaultInputFont as w}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as te}from"@apollion-dsi/core/themes/spacing";import{converter as so,formatHex as ao,parse as co}from"culori";import{DIMENSION_MULTIPLIERS as oo}from"@apollion-dsi/core/themes/dimension";function G({multiplier:e=.25,alias:o},n){let r=n!==void 0?oo[n]:e;return(...t)=>t.map(s=>{let a=typeof s=="string"?o[s]:s;return`${r*a}rem`}).join(" ")}i(G,"createSpacing");var z={"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 X(e){let o=Object.keys(z).filter(n=>!e.has(n));if(o.length>0)throw new Error(`token-meta: ${o.length} stale TOKEN_META key(s) resolve to no IR node: ${o.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}i(X,"assertTokenMetaResolves");var lo=so("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 ie(e){return e.split(".").map(k).join(".")}i(ie,"kebabPath");function T(e){return e.kind==="ref"?e.resolved.raw:e.raw}i(T,"rawValue");function j(e,o){return Number(e.toFixed(o))||0}i(j,"round");function Y(e){let o=lo(co(e));if(!o)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let n=[j(o.l,4),j(o.c,4),j(o.h??0,2)],r=ao(o)??"#000000";return o.alpha!==void 0&&o.alpha!==1?{kind:"color",raw:e,components:n,alpha:j(o.alpha,4),hex:r}:{kind:"color",raw:e,components:n,hex:r}}i(Y,"toColorValue");var se=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let o=se.exec(e.trim());if(o)return{kind:"dimension",raw:e,value:Number(o[1]),unit:o[2]};let n=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(n)?n:0,unit:"rem"}}i(D,"toDimensionValue");function y(e){return{type:"color",value:Y(e)}}i(y,"colorToken");function q(e){let o={};for(let[n,r]of Object.entries(e))o[n]=y(r);return o}i(q,"recordColorGroup");function ae(e){let o=no(e),n={};for(let[r,t]of Object.entries(o.palettes))n[r]=y(t);return n.neutral=q(o.neutral),n}i(ae,"buildReadableTextGroup");var uo=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ce(e){let o={};for(let n of uo){let r=e[n];o[n]={base:y(r.base),dark:y(r.dark),action:y(r.action),active:y(r.active),light:y(r.light)}}return o.grayscale=q(e.grayscale),o.neutral=q(e.neutral),o.baseDark=y(e.baseDark??"#000000"),o.baseLight=y(e.baseLight??"#ffffff"),o.deepDark=y(e.deepDark??"#000000"),o.deepLight=y(e.deepLight??"#ffffff"),o}i(ce,"buildColorPrimitives");function le(e){let o=G(te,e),n={};for(let r of Object.keys(te.alias))n[r]={type:"dimension",value:D(o(r))};return n}i(le,"buildSpacePrimitives");function de(){let e={};for(let[o,n]of Object.entries(A.borderWidth))e[o]={type:"dimension",value:D(n)};return e}i(de,"buildBorderWidthPrimitives");function po(e,o){return{color:ce(e),space:le(o),borderWidth:de()}}i(po,"buildPrimitives");var ue={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"},pe={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function fo(e,o){let n=e;for(let r of o.split(".").slice(1))if(n&&typeof n=="object"&&r in n)n=n[r];else return;return typeof n=="string"?n:void 0}i(fo,"lookupPrimitive");function E(e,o,n){let r={};for(let[t,s]of Object.entries(e)){let a=n[t],c=a?fo(o,a):void 0;r[t]=a&&c===s?{type:"color",value:{kind:"ref",path:a,resolved:Y(s)}}:y(s)}return r}i(E,"colorRefGroup");var fe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},mo={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function go(e,o){let n=o.split("."),r=n[0]==="border-width"?"borderWidth":n[0],t=e[r];for(let s of n.slice(1))if(t&&!b(t)&&s in t)t=t[s];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}i(go,"lookupDimensionPrimitive");function K(e,o,n){let r={};for(let[t,s]of Object.entries(e)){let a=n[t],c=a?go(o,a):void 0;r[t]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:D(s)}}:{type:"dimension",value:D(s)}}return r}i(K,"dimensionRefGroup");function me(e){let o={},n={};for(let[s,a]of Object.entries(A.borderRadius))se.test(a)?o[s]={type:"dimension",value:D(a)}:n[s]=a;let r=K(A.borderWidth,e,mo),t={};for(let[s,a]of Object.entries(A.borderStyle))t[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:o,width:r,style:t},extensions:n}}i(me,"buildBorder");function ge(e){let o=io(w,e),n={};for(let[c,l]of Object.entries(w.fontFamily)){let f=l.replace(/;\s*$/,"").trim();n[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,l]of Object.entries(o.fontSize))r[c]={type:"dimension",value:D(l)};let t={};for(let[c,l]of Object.entries(w.fontWeight))t[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:n,size:r,weight:t,lineHeight:s},extensions:a}}i(ge,"buildFont");var yo=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function ho(e){let o=e.trim(),n=o.startsWith("inset");n&&(o=o.slice(5).trim());let r=o.match(yo),t=r?r[0]:"#000000",a=(r?o.slice(0,r.index).trim():o).split(/\s+/).filter(Boolean),c=i(l=>D(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Y(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:n}}}i(ho,"parseShadow");function ye(e){let o=ro(e),n={};for(let r of Object.keys(to))n[r]={type:"shadow",value:ho(o(r))};return n}i(ye,"buildShadow");function F(e,o,n){let r={};for(let[t,s]of Object.entries(e)){let a=o?`${o}.${k(t)}`:k(t);if(b(s)){n.add(a);let c=z[a];r[t]=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 r[t]=F(s,a,n)}return r}i(F,"decorateGroup");function bo(e){let o=new Set,n=F(e.primitives,"",o),r=F(e.groups,"",o);return X(o),{...e,primitives:n,groups:r}}i(bo,"decorateMeta");function P(e,o){return F(e,"",o)}i(P,"decorateSlice");function he(e,o,n){for(let[r,t]of Object.entries(e)){let s=o?`${o}.${k(r)}`:k(r);b(t)?n.add(s):he(t,s,n)}}i(he,"collectPaths");function be(e){let o=new Set;for(let n of e)he(n.groups,"",o);X(o)}i(be,"assertSlicesMetaComplete");function Re(){let e=de(),n=me({borderWidth:e}),r={};Object.keys(n.extensions).length>0&&(r["com.apollion.border"]={radius:n.extensions});let t=new Set;return{groups:P({"border-width":e,border:n.group},t),extensions:r}}i(Re,"buildBaseIR");function ke(e){let o=ge(e),n=new Set;return{groups:P({font:o.group},n),extensions:{"com.apollion.font":o.extensions}}}i(ke,"buildFontIR");function Ie(e,o){let n=ce(o),r=new Set;return{groups:P({color:n,bg:E(e.bg,o,ue),text:E(e.text,o,pe),tx:ae(o),shadow:ye(o)},r),extensions:{}}}i(Ie,"buildColorIR");function Se(e,o){let n=le(o),r={space:n},t=new Set;return{groups:P({space:n,spacing:K(e.spacing,r,fe)},t),extensions:{}}}i(Se,"buildSpacingIR");function Ro(e,o,n){let r={brand:n.brand,mode:n.mode,surface:n.surface,dimension:n.dimension},t=po(o,n.dimension),s=me(t),a=ge(n.dimension),c={"com.apollion.variant":r,"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: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:E(e.bg,o,ue),text:E(e.text,o,pe),tx:ae(o),spacing:K(e.spacing,t,fe),border:s.group,font:a.group,shadow:ye(o)},extensions:c};return bo(l)}i(Ro,"buildIR");var xe=Ro;var ko="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function we(e,o,n){for(let[r,t]of Object.entries(e)){let s=[...o,k(r)];b(t)?n.push(` --apollion-${s.join("-")}: ${T(t.value)};`):we(t,s,n)}}i(we,"emitVars");function De(e,o,n){for(let[r,t]of Object.entries(e)){let s=[...o,k(r)];b(t)?t.type==="color"&&n.push(` @property --apollion-${s.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${T(t.value)}; }`):De(t,s,n)}}i(De,"emitProperties");function ve(e){let{brand:o,mode:n,surface:r,dimension:t}=e.meta,s=[ko,""];return s.push(`/* Variant: brand=${o} mode=${n} surface=${r} dimension=${t} */`,"",":root {"),we(e.groups,[],s),s.push("}",""),s.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),De(e.groups,[],s),s.push("}",""),s.join(`
|
|
3
|
+
`)}i(ve,"renderCss");function Te(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(Te,"colorValue");function C(e){return{value:e.value,unit:e.unit}}i(C,"dimensionValue");function Io(e){let o=e.shadow,n={color:Te(o.color),offsetX:C(o.offsetX),offsetY:C(o.offsetY),blur:C(o.blur),spread:C(o.spread)};return o.inset&&(n.inset=!0),n}i(Io,"shadowValue");function So(e){switch(e.kind){case"ref":return`{${ie(e.path)}}`;case"color":return Te(e);case"dimension":return C(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Io(e)}}i(So,"projectValue");function xo(e){let o={$value:So(e.value),$type:e.type};return e.description!==void 0&&(o.$description=e.description),e.deprecated!==void 0&&(o.$deprecated=e.deprecated),o}i(xo,"projectToken");function Z(e){let o={};for(let[n,r]of Object.entries(e))o[k(n)]=b(r)?xo(r):Z(r);return o}i(Z,"projectGroup");function M(e,o){let n={$description:o,...Z(e.groups)};return Object.keys(e.extensions).length>0&&(n.$extensions=e.extensions),`${JSON.stringify(n,null,2)}
|
|
4
|
+
`}i(M,"renderSet");function Ce(e){return M(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}i(Ce,"renderBaseSet");function $e(e,o,n,r){return M(e,`Apollion DS \u2014 colour set. brand=${o} mode=${n} surface=${r}. DTCG 2025.10.`)}i($e,"renderColorSet");function Ve(e,o){return M(e,`Apollion DS \u2014 spacing set. dimension=${o}. DTCG 2025.10.`)}i(Ve,"renderSpacingSet");function Oe(e,o){return M(e,`Apollion DS \u2014 font set. dimension=${o}. DTCG 2025.10.`)}i(Oe,"renderFontSet");function Ge(e,o){let{modifiers:n}=o,r=[{name:"brand",values:[...n.brand],default:n.brand[0]},{name:"mode",values:[...n.mode],default:n.mode[0]},{name:"surface",values:[...n.surface],default:n.surface[0]},{name:"dimension",values:[...n.dimension],default:n.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:o.base.name,source:o.base.file},...o.spacing.map(a=>({name:a.name,source:a.file})),...o.font.map(a=>({name:a.name,source:a.file})),...o.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[o.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(s,null,2)}
|
|
5
|
+
`}i(Ge,"renderResolver");var wo="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function je(e,o,n){let r=" ".repeat(o);for(let[t,s]of Object.entries(e))b(s)?n.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(T(s.value))},`):(n.push(`${r}${t}: {`),je(s,o+1,n),n.push(`${r}},`))}i(je,"emitGroup");function Ae(e){let{brand:o,mode:n,surface:r,dimension:t}=e.meta,s=[wo,`// Variant: brand=${o} mode=${n} surface=${r} dimension=${t}`,"","export const tokens = {"];return je(e.groups,1,s),s.push("} as const;","","export type Tokens = typeof tokens;",""),s.join(`
|
|
6
|
+
`)}i(Ae,"renderTs");var Do=["light","dark"],vo=["positive","negative"],To=["compact","normal","spacious"];function N(e){let o=e.modes??Do,n=e.surfaces??vo,r=e.dimensions??To,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),s=[];for(let[a,c]of t)for(let l of o)for(let f of n)for(let x of r)s.push({brand:a,colors:c,mode:l,surface:f,dimension:x});return s}i(N,"expandVariants");function Ee(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}i(Ee,"variantName");import{createHash as Co}from"node:crypto";function ee(e){return Co("sha256").update(e).digest("hex")}i(ee,"sha256");function oe(e){return ee(Q(e))}i(oe,"hashConfig");function Q(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Q).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Q(e[r])}`).join(",")}}`}i(Q,"stableStringify");function Fe(e){try{let{execSync:o}=eo("node:child_process");return o("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}i(Fe,"detectGitCommit");function Pe(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}i(Pe,"buildEnv");function Me(e){let o=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),n={configHash:e.configHash,files:o,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(n,null,2)}
|
|
7
|
+
`}i(Me,"serializeManifest");var $o="json/sets",Ne="json/resolver.json";function L(e){return`${$o}/${e}.json`}i(L,"setFile");function Vo(e,o,n){return`${e}.color.${o}.${n}`}i(Vo,"colorSetName");function Oo(e){return`spacing.${e}`}i(Oo,"spacingSetName");function Go(e){return`font.${e}`}i(Go,"fontSetName");function _(e,o){e.includes(o)||e.push(o)}i(_,"pushUnique");function Le(e){let o=N(e),n=[],r=[],t=[],s=[],a=new Set,c=[],l=new Set,f=[],x=new Set,$=[];for(let u of o){_(n,u.brand),_(r,u.mode),_(t,u.surface),_(s,u.dimension);let g=Vo(u.brand,u.mode,u.surface);a.has(g)||(a.add(g),c.push({kind:"color",name:g,file:L(g),brand:u.brand,mode:u.mode,surface:u.surface}));let I=Oo(u.dimension);l.has(I)||(l.add(I),f.push({kind:"spacing",name:I,file:L(I),dimension:u.dimension}));let p=Go(u.dimension);x.has(p)||(x.add(p),$.push({kind:"font",name:p,file:L(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:L("base")},spacing:f,font:$,color:c,modifiers:{brand:n,mode:r,surface:t,dimension:s}}}i(Le,"planSets");import{createFoundation as We}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Po}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Mo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as No}from"@apollion-dsi/core/themes/surface";import{converter as jo,formatHex as Ao,interpolate as Eo,parse as _e}from"culori";var Bn=jo("oklch");function d(e,o,n){let r=_e(e),t=_e(o);if(!r||!t)return e;let s=Eo([r,t],"oklch");return Ao(s(n))??e}i(d,"mixOklch");function Fo(e){return e?typeof e=="string"?e:e.base:"#000"}i(Fo,"coerceToHex");function R(e,o){let n=Fo(e),r=o.deepDark,t=o.deepLight;return{base:n,dark:d(n,r,.6),action:d(n,r,.2),active:d(n,t,.6),light:d(n,t,.9)}}i(R,"mountSingleColor");function Be(e){let o=e.deepLight,n=e.deepDark;return{0:o,5:d(o,n,.05),10:d(o,n,.1),20:d(o,n,.2),30:d(o,n,.3),40:d(o,n,.4),50:d(o,n,.5),60:d(o,n,.6),70:d(o,n,.7),80:d(o,n,.8),90:d(o,n,.9),100:d(o,n,1)}}i(Be,"mountGreyscaleColors");function He(e){let o=e.deepLight,n=e.deepDark,r=e.primary,t=i(a=>1/17*(a-1),"interpolation"),s=d(r,n,.5);return{0:d(s,o,t(18)),5:d(s,o,t(17.5)),10:d(s,o,t(17)),20:d(s,o,t(16)),30:d(s,o,t(15)),40:d(s,o,t(14)),50:d(s,o,t(13)),60:d(s,o,t(12)),70:d(s,o,t(11)),80:d(s,o,t(10)),90:d(s,o,t(9)),100:d(s,o,t(8)),110:d(s,o,t(7)),120:d(s,o,t(6)),130:d(s,o,t(5)),140:d(s,o,t(4)),150:d(s,o,t(3)),160:d(s,o,t(2)),170:s,180:d(s,n,.25)}}i(He,"mountNeutralColors");function Lo(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:He(e),grayscale:Be(e),main:R(e.main,e),opposite:R(e.opposite,e),complementary:R(e.complementary,e),danger:R(e.danger,e),information:R(e.information,e),success:R(e.success,e),warning:R(e.warning,e),primary:R(e.primary,e),secondary:R(e.secondary,e),tertiary:R(e.tertiary,e)}}i(Lo,"composeColors");function B(e,o=Mo){let n=Lo(e.colors),r=G(o,e.dimension),t=Po({colors:n,spacing:r}),s=We(t);return e.surface==="negative"&&(s=We(No({semantic:t,colors:n},"negative").semantic)),{foundation:s,colors:n}}i(B,"buildVariantThemes");async function qe(e){let{config:o,outDir:n,cwd:r=process.cwd(),verbose:t=!1}=e,s=N(o),a=o.output??{};if(s.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await _o(H(Wo(),"apollion-tokens-"));try{let l=[],f=i(async(u,g)=>{await Uo(c,u,g),l.push({path:u,sha256:ee(g)}),t&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Le(o),g=[],I=Re();g.push(I),await f(u.base.file,Ce(I));for(let p of u.spacing){let S=s.find(O=>O.dimension===p.dimension),{foundation:U}=B(S),V=Se(U,p.dimension);g.push(V),await f(p.file,Ve(V,p.dimension))}for(let p of u.font){let S=ke(p.dimension);g.push(S),await f(p.file,Oe(S,p.dimension))}for(let p of u.color){let S=s.find(J=>J.brand===p.brand&&J.mode===p.mode&&J.surface===p.surface),{foundation:U,colors:V}=B(S),O=Ie(U,V);g.push(O),await f(p.file,$e(O,p.brand,p.mode,p.surface))}be(g),await f(Ne,Ge(o,u))}if(a.css||a.ts)for(let u of s){let{foundation:g,colors:I}=B(u),p=xe(g,I,u),S=Ee(u);a.css&&await f(`css/${S}.css`,ve(p)),a.ts&&await f(`ts/${S}.d.ts`,Ae(p))}let x={configHash:oe(o),files:l,gitCommit:Fe(r),buildEnv:Pe()},$=Me(x);return await ze(H(c,"manifest.json"),$),await Ue(n,{recursive:!0,force:!0}),await Je(Xe(n),{recursive:!0}),await Ho(c,n),t&&console.log(`\u2713 ${l.length} files \u2192 ${n}`),{manifest:x,outDir:n}}catch(l){throw await Ue(c,{recursive:!0,force:!0}).catch(()=>{}),l}}i(qe,"build");async function Ye(e){let{config:o,outDir:n}=e,r;try{r=JSON.parse(await Bo(H(n,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===oe(o)}i(Ye,"check");async function Uo(e,o,n){let r=H(e,o);await Je(Xe(r),{recursive:!0}),await ze(r,n)}i(Uo,"writeAt");import{readFile as zo}from"node:fs/promises";import{resolve as Xo}from"node:path";import{createContext as qo,Script as Yo}from"node:vm";import{z as m}from"zod";var h=m.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),Jo=m.object({baseDark:m.string().optional(),baseLight:m.string().optional(),deepDark:h,deepLight:h,transparent:m.string().optional(),main:h.optional(),opposite:h.optional(),complementary:h.optional(),information:h.optional(),success:h.optional(),danger:h.optional(),warning:h.optional(),primary:h.optional(),secondary:h.optional(),tertiary:h.optional()}).passthrough(),Ke=m.object({brands:m.record(m.string(),Jo).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()}).passthrough().optional()}).passthrough();var Ko=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],Zo=1e3;var ne=class ne extends Error{constructor(n,r){super(n);this.configPath=r;this.name="ConfigLoadError"}};i(ne,"ConfigLoadError");var v=ne;async function Ze(e){let o=Xo(e.configPath),n=await zo(o,"utf8");for(let l of Ko)if(l.test(n))throw new v(`apollion.config: dynamic require/import not allowed (matched ${l}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,o);let r=n.replace(/(^|\n)\s*export\s+default\s+/,(l,f)=>`${f}__apollion_config_export = `);if(r===n)throw new v("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",o);let t={__apollion_config_export:void 0,console:Qo(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:i(l=>l,"defineConfig")},s=qo(t);try{new Yo(r,{filename:o}).runInContext(s,{timeout:Zo})}catch(l){throw new v(`apollion.config: evaluation failed \u2014 ${l instanceof Error?l.message:String(l)}`,o)}let a=t.__apollion_config_export;if(a===void 0)throw new v("apollion.config: `export default` produced undefined.",o);let c=Ke.safeParse(a);if(!c.success){let l=c.error.issues.map(f=>` ${f.path.join(".")||"(root)"}: ${f.message}`).join(`
|
|
8
8
|
`);throw new v(`apollion.config: schema validation failed \u2014
|
|
9
|
-
${l}`,o)}return c.data}
|
|
9
|
+
${l}`,o)}return c.data}i(Ze,"loadConfig");function Qo(){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(Qo,"makeReadOnlyConsole");function on(e){let o=e.slice(2),n=o[0];n!=="build"&&W(`Unknown command "${n??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let r="apollion.config.mjs",t="dist",s=!1,a=!1;for(let c=1;c<o.length;c++){let l=o[c];switch(l){case"--config":r=o[++c]??W("--config needs a path");break;case"--out":t=o[++c]??W("--out needs a path");break;case"--check":s=!0;break;case"--verbose":a=!0;break;default:W(`Unknown flag "${l}"`)}}return{command:n,configPath:r,outDir:t,check:s,verbose:a}}i(on,"parseArgs");function W(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}i(W,"fail");async function nn(e){let o=re(e);if(o.endsWith(".json")){let n=await en(o,"utf8");return JSON.parse(n)}return Ze({configPath:o})}i(nn,"loadConfigFromPath");async function rn(){let e=on(process.argv),o=await nn(e.configPath);if(e.check){await Ye({config:o,outDir:re(e.outDir)})||(console.error("apollion-tokens: dist/ is stale or missing (configHash mismatch). Re-run `apollion-tokens build` without --check."),process.exit(1)),console.log("apollion-tokens: dist/ is up-to-date with config.");return}let{manifest:n}=await qe({config:o,outDir:re(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${n.files.length} file(s) \u2014 configHash=${n.configHash.slice(0,12)}\u2026`)}i(rn,"main");rn().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollion-dsi/tokens",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "Apollion Design System — Framework-agnostic design tokens",
|
|
5
5
|
"homepage": "https://www.apollion.com.br",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@apollion-dsi/core": "workspace:*",
|
|
69
|
-
"@apollion-dsi/eslint-config": "0.
|
|
69
|
+
"@apollion-dsi/eslint-config": "0.9.0",
|
|
70
70
|
"@types/culori": "4.0.1",
|
|
71
71
|
"@types/jest": "30.0.0",
|
|
72
72
|
"@types/node": "25.7.0",
|
package/src/ir.ts
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
import { defaultInputBorder } from '@apollion-dsi/core/themes/border';
|
|
32
|
+
import { createReadableTextLayer } from '@apollion-dsi/core/themes/colors';
|
|
32
33
|
import { createDeth, levelValues } from '@apollion-dsi/core/themes/depth';
|
|
33
34
|
import type { Dimension } from '@apollion-dsi/core/themes/dimension';
|
|
34
35
|
import { createFont, defaultInputFont } from '@apollion-dsi/core/themes/font';
|
|
@@ -215,6 +216,24 @@ function recordColorGroup(record: Record<string, string>): IRGroup {
|
|
|
215
216
|
return out;
|
|
216
217
|
}
|
|
217
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Readable text-ink layer (`tx.*`) — the theme-aware legible-ink surface the
|
|
221
|
+
* brasil_2030 consumer reimplemented locally (contrast plan G2). Derived by
|
|
222
|
+
* core's `createReadableTextLayer` (single source — no duplicated math): per
|
|
223
|
+
* named palette, `readableColor(base, surface, 4.5)`; per high neutral index
|
|
224
|
+
* (text side of the ramp), the same against the theme's card surface
|
|
225
|
+
* (`neutral.10`). Emitted per variant, so when the mode axis becomes real
|
|
226
|
+
* (ADR-006 E6/S6) the `.dark.*` files pick up true dark inks with no
|
|
227
|
+
* topology change.
|
|
228
|
+
*/
|
|
229
|
+
function buildReadableTextGroup(colors: ColorsThemeInterface): IRGroup {
|
|
230
|
+
const layer = createReadableTextLayer(colors as never);
|
|
231
|
+
const out: Record<string, IRToken | IRGroup> = {};
|
|
232
|
+
for (const [name, hex] of Object.entries(layer.palettes)) out[name] = colorToken(hex);
|
|
233
|
+
out.neutral = recordColorGroup(layer.neutral as unknown as Record<string, string>);
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
|
|
218
237
|
const NAMED_PALETTES = [
|
|
219
238
|
'main',
|
|
220
239
|
'opposite',
|
|
@@ -669,6 +688,7 @@ export function buildColorIR(foundation: FoundationLayer, colors: ColorsThemeInt
|
|
|
669
688
|
color,
|
|
670
689
|
bg: colorRefGroup(foundation.bg as unknown as Record<string, string>, colors, BG_REF),
|
|
671
690
|
text: colorRefGroup(foundation.text as unknown as Record<string, string>, colors, TEXT_REF),
|
|
691
|
+
tx: buildReadableTextGroup(colors),
|
|
672
692
|
shadow: buildShadow(colors),
|
|
673
693
|
},
|
|
674
694
|
seen,
|
|
@@ -726,6 +746,7 @@ export function buildIR(foundation: FoundationLayer, colors: ColorsThemeInterfac
|
|
|
726
746
|
groups: {
|
|
727
747
|
bg: colorRefGroup(foundation.bg as unknown as Record<string, string>, colors, BG_REF),
|
|
728
748
|
text: colorRefGroup(foundation.text as unknown as Record<string, string>, colors, TEXT_REF),
|
|
749
|
+
tx: buildReadableTextGroup(colors),
|
|
729
750
|
spacing: dimensionRefGroup(foundation.spacing as unknown as Record<string, string>, primitives, SPACE_REF),
|
|
730
751
|
border: border.group,
|
|
731
752
|
font: font.group,
|