@apollion-dsi/tokens 4.10.0 → 4.12.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/builders/colors.d.ts +7 -3
- package/lib/cli.mjs +8 -8
- package/lib/runtime/v1.cjs +1 -1
- package/lib/runtime/v1.esm.js +1 -1
- package/package.json +2 -2
- package/src/builders/colors.ts +105 -6
- 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(
|
|
4
|
-
`}s(
|
|
5
|
-
`)}s(
|
|
6
|
-
`}s(
|
|
1
|
+
"use strict";var M=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var an=Object.prototype.hasOwnProperty;var s=(e,n)=>M(e,"name",{value:n,configurable:!0});var cn=(e,n)=>{for(var o in n)M(e,o,{get:n[o],enumerable:!0})},ln=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of sn(n))!an.call(e,t)&&t!==o&&M(e,t,{get:()=>n[t],enumerable:!(r=tn(n,t))||r.enumerable});return e};var dn=e=>ln(M({},"__esModule",{value:!0}),e);var Nn={};cn(Nn,{build:()=>An,check:()=>Pn});module.exports=dn(Nn);var y=require("node:fs/promises"),rn=require("node:os"),T=require("node:path");var V=require("@apollion-dsi/core/themes/border"),le=require("@apollion-dsi/core/themes/colors"),N=require("@apollion-dsi/core/themes/depth"),I=require("@apollion-dsi/core/themes/font"),Z=require("@apollion-dsi/core/themes/spacing"),w=require("culori");var ce=require("@apollion-dsi/core/themes/dimension");function j({multiplier:e=.25,alias:n},o){let r=o!==void 0?ce.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(j,"createSpacing");var q={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function K(e){let n=Object.keys(q).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(K,"assertTokenMetaResolves");var un=(0,w.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(k,"kebab");function de(e){return e.split(".").map(k).join(".")}s(de,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}s($,"rawValue");function A(e,n){return Number(e.toFixed(n))||0}s(A,"round");function ee(e){let n=un((0,w.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[A(n.l,4),A(n.c,4),A(n.h??0,2)],r=(0,w.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:A(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ee,"toColorValue");var ue=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function v(e){let n=ue.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(v,"toDimensionValue");function h(e){return{type:"color",value:ee(e)}}s(h,"colorToken");function Q(e){let n={};for(let[o,r]of Object.entries(e))n[o]=h(r);return n}s(Q,"recordColorGroup");function pe(e){let n=(0,le.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=h(t);return o.neutral=Q(n.neutral),o}s(pe,"buildReadableTextGroup");var pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function fe(e){let n={};for(let o of pn){let r=e[o];n[o]={base:h(r.base),dark:h(r.dark),action:h(r.action),active:h(r.active),light:h(r.light)}}return n.grayscale=Q(e.grayscale),n.neutral=Q(e.neutral),n.baseDark=h(e.baseDark??"#000000"),n.baseLight=h(e.baseLight??"#ffffff"),n.deepDark=h(e.deepDark??"#000000"),n.deepLight=h(e.deepLight??"#ffffff"),n}s(fe,"buildColorPrimitives");function me(e){let n=j(Z.defaultInputSpacing,e),o={};for(let r of Object.keys(Z.defaultInputSpacing.alias))o[r]={type:"dimension",value:v(n(r))};return o}s(me,"buildSpacePrimitives");function ge(){let e={};for(let[n,o]of Object.entries(V.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:v(o)};return e}s(ge,"buildBorderWidthPrimitives");function fn(e,n){return{color:fe(e),space:me(n),borderWidth:ge()}}s(fn,"buildPrimitives");var ye={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},he={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function mn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(mn,"lookupPrimitive");function P(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?mn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ee(i)}}:h(i)}return r}s(P,"colorRefGroup");var be={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},gn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function yn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!b(t)&&i in t)t=t[i];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(yn,"lookupDimensionPrimitive");function ne(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?yn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:v(i)}}:{type:"dimension",value:v(i)}}return r}s(ne,"dimensionRefGroup");function Re(e){let n={},o={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderRadius))ue.test(a)?n[i]={type:"dimension",value:v(a)}:o[i]=a;let r=ne(V.defaultInputBorder.borderWidth,e,gn),t={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Re,"buildBorder");function Ie(e){let n=(0,I.createFont)(I.defaultInputFont,e),o={};for(let[c,d]of Object.entries(I.defaultInputFont.fontFamily)){let m=d.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,d]of Object.entries(n.fontSize))r[c]={type:"dimension",value:v(d)};let t={};for(let[c,d]of Object.entries(I.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${d}`,weight:d}};let i={};for(let[c,d]of Object.entries(I.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${d}`,number:d}};let a={letterSpacing:I.defaultInputFont.letterSpacing,textTransform:I.defaultInputFont.textTransform,fontStyle:I.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Ie,"buildFont");var hn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function bn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(hn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(d=>v(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ee(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(bn,"parseShadow");function ke(e){let n=(0,N.createDeth)(e),o={};for(let r of Object.keys(N.levelValues))o[r]={type:"shadow",value:bn(n(r))};return o}s(ke,"buildShadow");function L(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${k(t)}`:k(t);if(b(i)){o.add(a);let c=q[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=L(i,a,o)}return r}s(L,"decorateGroup");function Rn(e){let n=new Set,o=L(e.primitives,"",n),r=L(e.groups,"",n);return K(n),{...e,primitives:o,groups:r}}s(Rn,"decorateMeta");function B(e,n){return L(e,"",n)}s(B,"decorateSlice");function Se(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${k(r)}`:k(r);b(t)?o.add(i):Se(t,i,o)}}s(Se,"collectPaths");function xe(e){let n=new Set;for(let o of e)Se(o.groups,"",n);K(n)}s(xe,"assertSlicesMetaComplete");function Te(){let e=ge(),o=Re({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:B({"border-width":e,border:o.group},t),extensions:r}}s(Te,"buildBaseIR");function De(e){let n=Ie(e),o=new Set;return{groups:B({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(De,"buildFontIR");function ve(e,n){let o=fe(n),r=new Set;return{groups:B({color:o,bg:P(e.bg,n,ye),text:P(e.text,n,he),tx:pe(n),shadow:ke(n)},r),extensions:{}}}s(ve,"buildColorIR");function we(e,n){let o=me(n),r={space:o},t=new Set;return{groups:B({space:o,spacing:ne(e.spacing,r,be)},t),extensions:{}}}s(we,"buildSpacingIR");function In(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=fn(n,o.dimension),i=Re(t),a=Ie(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:P(e.bg,n,ye),text:P(e.text,n,he),tx:pe(n),spacing:ne(e.spacing,t,be),border:i.group,font:a.group,shadow:ke(n)},extensions:c};return Rn(d)}s(In,"buildIR");var Ce=In;var kn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Ve(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,k(r)];b(t)?o.push(` --apollion-${i.join("-")}: ${$(t.value)};`):Ve(t,i,o)}}s(Ve,"emitVars");function $e(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,k(r)];b(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(t.value)}; }`):$e(t,i,o)}}s($e,"emitProperties");function Ge(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[kn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),Ve(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),$e(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
+
`)}s(Ge,"renderCss");function Oe(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(Oe,"colorValue");function G(e){return{value:e.value,unit:e.unit}}s(G,"dimensionValue");function Sn(e){let n=e.shadow,o={color:Oe(n.color),offsetX:G(n.offsetX),offsetY:G(n.offsetY),blur:G(n.blur),spread:G(n.spread)};return n.inset&&(o.inset=!0),o}s(Sn,"shadowValue");function xn(e){switch(e.kind){case"ref":return`{${de(e.path)}}`;case"color":return Oe(e);case"dimension":return G(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Sn(e)}}s(xn,"projectValue");function Tn(e){let n={$value:xn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Tn,"projectToken");function oe(e){let n={};for(let[o,r]of Object.entries(e))n[k(o)]=b(r)?Tn(r):oe(r);return n}s(oe,"projectGroup");function _(e,n){let o={$description:n,...oe(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(_,"renderSet");function Ee(e){return _(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Ee,"renderBaseSet");function Fe(e,n,o,r){return _(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(Fe,"renderColorSet");function Me(e,n){return _(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Me,"renderSpacingSet");function je(e,n){return _(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(je,"renderFontSet");function Ae(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(Ae,"renderResolver");var Dn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Pe(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))b(i)?o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify($(i.value))},`):(o.push(`${r}${t}: {`),Pe(i,n+1,o),o.push(`${r}},`))}s(Pe,"emitGroup");function Le(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[Dn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return Pe(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
5
|
+
`)}s(Le,"renderTs");var vn=["light","dark"],wn=["positive","negative"],Cn=["compact","normal","spacious"];function H(e){let n=e.modes??vn,o=e.surfaces??wn,r=e.dimensions??Cn,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let d of n)for(let m of o)for(let D of r)i.push({brand:a,colors:c,mode:d,surface:m,dimension:D});return i}s(H,"expandVariants");function Ne(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Ne,"variantName");var Be=require("node:crypto");function te(e){return(0,Be.createHash)("sha256").update(e).digest("hex")}s(te,"sha256");function ie(e){return te(re(e))}s(ie,"hashConfig");function re(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(re).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${re(e[r])}`).join(",")}}`}s(re,"stableStringify");function _e(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(_e,"detectGitCommit");function He(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(He,"buildEnv");function We(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(We,"serializeManifest");var Vn="json/sets",Je="json/resolver.json";function W(e){return`${Vn}/${e}.json`}s(W,"setFile");function $n(e,n,o){return`${e}.color.${n}.${o}`}s($n,"colorSetName");function Gn(e){return`spacing.${e}`}s(Gn,"spacingSetName");function On(e){return`font.${e}`}s(On,"fontSetName");function J(e,n){e.includes(n)||e.push(n)}s(J,"pushUnique");function Ue(e){let n=H(e),o=[],r=[],t=[],i=[],a=new Set,c=[],d=new Set,m=[],D=new Set,O=[];for(let u of n){J(o,u.brand),J(r,u.mode),J(t,u.surface),J(i,u.dimension);let g=$n(u.brand,u.mode,u.surface);a.has(g)||(a.add(g),c.push({kind:"color",name:g,file:W(g),brand:u.brand,mode:u.mode,surface:u.surface}));let S=Gn(u.dimension);d.has(S)||(d.add(S),m.push({kind:"spacing",name:S,file:W(S),dimension:u.dimension}));let p=On(u.dimension);D.has(p)||(D.add(p),O.push({kind:"font",name:p,file:W(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:W("base")},spacing:m,font:O,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Ue,"planSets");var ae=require("@apollion-dsi/core/themes/foundation"),en=require("@apollion-dsi/core/themes/semantic"),nn=require("@apollion-dsi/core/themes/spacing"),on=require("@apollion-dsi/core/themes/surface");var f=require("culori");var Ke=(0,f.converter)("oklch");function l(e,n,o){let r=(0,f.parse)(e),t=(0,f.parse)(n);if(!r||!t)return e;let i=(0,f.interpolate)([r,t],"oklch");return(0,f.formatHex)(i(o))??e}s(l,"mixOklch");function En(e){return e?typeof e=="string"?e:e.base:"#000"}s(En,"coerceToHex");var U=1.3,Fn=.05,ze=.04,C=s((e,n)=>{let o=(0,f.parse)(e),r=(0,f.parse)(n);return!o||!r?1:(0,f.wcagContrast)(o,r)},"contrastRatio"),se=s(e=>{let n=Ke((0,f.parse)(e));return n?n.l??0:null},"oklchLightness"),Xe=s((e,n)=>{if(C(e,n)>=U)return!0;let o=se(e),r=se(n);return o!==null&&r!==null&&Math.abs(o-r)>=Fn},"isPerceptibleState"),Mn=s(e=>e?C("#fff",e)>C("#000",e):!1,"isDarkSurface");function Ye(e,n,o){let r=Ke((0,f.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?ze:-ze;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let d=(0,f.formatHex)(t);if(d&&C(e,d)>=U)return d}return(0,f.formatHex)(t)??null}s(Ye,"derivePerceptibleState");function qe(e,n,o){let r=Ye(e,n,o);if(r&&C(e,r)>=U)return r;let t=Ye(e,!n);return t&&C(e,t)>=U?t:r??t}s(qe,"perceptibleStateFor");function R(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=En(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:l(r,t,.6),action:l(r,t,.2),active:l(r,i,.6),light:l(r,i,.9)};if((0,f.parse)(r)){let c=Mn(n.baseLight),d=Xe(r,a.action);if(d||(a.action=qe(r,c)??a.action),!Xe(r,a.active)){let m=d?void 0:se(a.action)??void 0;a.active=qe(r,c,m)??a.active}}return o?{base:r,dark:o.dark??a.dark,action:o.action??a.action,active:o.active??a.active,light:o.light??a.light}:a}s(R,"mountSingleColor");function Ze(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(Ze,"mountGreyscaleColors");function Qe(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=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(Qe,"mountNeutralColors");function jn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Qe(e),grayscale:Ze(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)}}s(jn,"composeColors");function z(e,n=nn.defaultInputSpacing){let o=jn(e.colors),r=j(n,e.dimension),t=(0,en.createSemantic)({colors:o,spacing:r}),i=(0,ae.createFoundation)(t);return e.surface==="negative"&&(i=(0,ae.createFoundation)((0,on.invertForSurface)({semantic:t,colors:o},"negative").semantic)),{foundation:i,colors:o}}s(z,"buildVariantThemes");async function An(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=H(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,y.mkdtemp)((0,T.join)((0,rn.tmpdir)(),"apollion-tokens-"));try{let d=[],m=s(async(u,g)=>{await Ln(c,u,g),d.push({path:u,sha256:te(g)}),t&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Ue(n),g=[],S=Te();g.push(S),await m(u.base.file,Ee(S));for(let p of u.spacing){let x=i.find(F=>F.dimension===p.dimension),{foundation:X}=z(x),E=we(X,p.dimension);g.push(E),await m(p.file,Me(E,p.dimension))}for(let p of u.font){let x=De(p.dimension);g.push(x),await m(p.file,je(x,p.dimension))}for(let p of u.color){let x=i.find(Y=>Y.brand===p.brand&&Y.mode===p.mode&&Y.surface===p.surface),{foundation:X,colors:E}=z(x),F=ve(X,E);g.push(F),await m(p.file,Fe(F,p.brand,p.mode,p.surface))}xe(g),await m(Je,Ae(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:g,colors:S}=z(u),p=Ce(g,S,u),x=Ne(u);a.css&&await m(`css/${x}.css`,Ge(p)),a.ts&&await m(`ts/${x}.d.ts`,Le(p))}let D={configHash:ie(n),files:d,gitCommit:_e(r),buildEnv:He()},O=We(D);return await(0,y.writeFile)((0,T.join)(c,"manifest.json"),O),await(0,y.rm)(o,{recursive:!0,force:!0}),await(0,y.mkdir)((0,T.dirname)(o),{recursive:!0}),await(0,y.rename)(c,o),t&&console.log(`\u2713 ${d.length} files \u2192 ${o}`),{manifest:D,outDir:o}}catch(d){throw await(0,y.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),d}}s(An,"build");async function Pn(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,y.readFile)((0,T.join)(o,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===ie(n)}s(Pn,"check");async function Ln(e,n,o){let r=(0,T.join)(e,n);await(0,y.mkdir)((0,T.dirname)(r),{recursive:!0}),await(0,y.writeFile)(r,o)}s(Ln,"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(
|
|
4
|
-
`}s(
|
|
5
|
-
`)}s(
|
|
6
|
-
`}s(
|
|
1
|
+
var Ze=Object.defineProperty;var s=(e,n)=>Ze(e,"name",{value:n,configurable:!0}),Qe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as Ye,mkdtemp as _n,readFile as Hn,rename as Wn,rm as Xe,writeFile as qe}from"node:fs/promises";import{tmpdir as Jn}from"node:os";import{dirname as Ke,join as H}from"node:path";import{defaultInputBorder as E}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as nn}from"@apollion-dsi/core/themes/colors";import{createDeth as on,levelValues as rn}from"@apollion-dsi/core/themes/depth";import{createFont as tn,defaultInputFont as S}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as re}from"@apollion-dsi/core/themes/spacing";import{converter as sn,formatHex as an,parse as cn}from"culori";import{DIMENSION_MULTIPLIERS as en}from"@apollion-dsi/core/themes/dimension";function G({multiplier:e=.25,alias:n},o){let r=o!==void 0?en[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(G,"createSpacing");var U={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function z(e){let n=Object.keys(U).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(z,"assertTokenMetaResolves");var ln=sn("oklch");function y(e){return typeof e.type=="string"&&"value"in e}s(y,"isToken");function b(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(b,"kebab");function te(e){return e.split(".").map(b).join(".")}s(te,"kebabPath");function v(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(v,"rawValue");function O(e,n){return Number(e.toFixed(n))||0}s(O,"round");function Y(e){let n=ln(cn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[O(n.l,4),O(n.c,4),O(n.h??0,2)],r=an(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:O(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(Y,"toColorValue");var ie=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function x(e){let n=ie.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(x,"toDimensionValue");function g(e){return{type:"color",value:Y(e)}}s(g,"colorToken");function X(e){let n={};for(let[o,r]of Object.entries(e))n[o]=g(r);return n}s(X,"recordColorGroup");function se(e){let n=nn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=g(t);return o.neutral=X(n.neutral),o}s(se,"buildReadableTextGroup");var dn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ae(e){let n={};for(let o of dn){let r=e[o];n[o]={base:g(r.base),dark:g(r.dark),action:g(r.action),active:g(r.active),light:g(r.light)}}return n.grayscale=X(e.grayscale),n.neutral=X(e.neutral),n.baseDark=g(e.baseDark??"#000000"),n.baseLight=g(e.baseLight??"#ffffff"),n.deepDark=g(e.deepDark??"#000000"),n.deepLight=g(e.deepLight??"#ffffff"),n}s(ae,"buildColorPrimitives");function ce(e){let n=G(re,e),o={};for(let r of Object.keys(re.alias))o[r]={type:"dimension",value:x(n(r))};return o}s(ce,"buildSpacePrimitives");function le(){let e={};for(let[n,o]of Object.entries(E.borderWidth))e[n]={type:"dimension",value:x(o)};return e}s(le,"buildBorderWidthPrimitives");function un(e,n){return{color:ae(e),space:ce(n),borderWidth:le()}}s(un,"buildPrimitives");var de={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},ue={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function pn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(pn,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?pn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:Y(i)}}:g(i)}return r}s(F,"colorRefGroup");var pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},fn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function mn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!y(t)&&i in t)t=t[i];else return;return t&&y(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(mn,"lookupDimensionPrimitive");function q(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?mn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:x(i)}}:{type:"dimension",value:x(i)}}return r}s(q,"dimensionRefGroup");function fe(e){let n={},o={};for(let[i,a]of Object.entries(E.borderRadius))ie.test(a)?n[i]={type:"dimension",value:x(a)}:o[i]=a;let r=q(E.borderWidth,e,fn),t={};for(let[i,a]of Object.entries(E.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(fe,"buildBorder");function me(e){let n=tn(S,e),o={};for(let[c,d]of Object.entries(S.fontFamily)){let f=d.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,d]of Object.entries(n.fontSize))r[c]={type:"dimension",value:x(d)};let t={};for(let[c,d]of Object.entries(S.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${d}`,weight:d}};let i={};for(let[c,d]of Object.entries(S.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${d}`,number:d}};let a={letterSpacing:S.letterSpacing,textTransform:S.textTransform,fontStyle:S.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(me,"buildFont");var gn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function yn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(gn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(d=>x(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Y(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(yn,"parseShadow");function ge(e){let n=on(e),o={};for(let r of Object.keys(rn))o[r]={type:"shadow",value:yn(n(r))};return o}s(ge,"buildShadow");function M(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${b(t)}`:b(t);if(y(i)){o.add(a);let c=U[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=M(i,a,o)}return r}s(M,"decorateGroup");function hn(e){let n=new Set,o=M(e.primitives,"",n),r=M(e.groups,"",n);return z(n),{...e,primitives:o,groups:r}}s(hn,"decorateMeta");function j(e,n){return M(e,"",n)}s(j,"decorateSlice");function ye(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${b(r)}`:b(r);y(t)?o.add(i):ye(t,i,o)}}s(ye,"collectPaths");function he(e){let n=new Set;for(let o of e)ye(o.groups,"",n);z(n)}s(he,"assertSlicesMetaComplete");function be(){let e=le(),o=fe({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:j({"border-width":e,border:o.group},t),extensions:r}}s(be,"buildBaseIR");function Re(e){let n=me(e),o=new Set;return{groups:j({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Re,"buildFontIR");function Ie(e,n){let o=ae(n),r=new Set;return{groups:j({color:o,bg:F(e.bg,n,de),text:F(e.text,n,ue),tx:se(n),shadow:ge(n)},r),extensions:{}}}s(Ie,"buildColorIR");function ke(e,n){let o=ce(n),r={space:o},t=new Set;return{groups:j({space:o,spacing:q(e.spacing,r,pe)},t),extensions:{}}}s(ke,"buildSpacingIR");function bn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=un(n,o.dimension),i=fe(t),a=me(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,de),text:F(e.text,n,ue),tx:se(n),spacing:q(e.spacing,t,pe),border:i.group,font:a.group,shadow:ge(n)},extensions:c};return hn(d)}s(bn,"buildIR");var Se=bn;var Rn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function xe(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?o.push(` --apollion-${i.join("-")}: ${v(t.value)};`):xe(t,i,o)}}s(xe,"emitVars");function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${v(t.value)}; }`):Te(t,i,o)}}s(Te,"emitProperties");function De(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[Rn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),xe(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Te(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
+
`)}s(De,"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 w(e){return{value:e.value,unit:e.unit}}s(w,"dimensionValue");function In(e){let n=e.shadow,o={color:ve(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(In,"shadowValue");function kn(e){switch(e.kind){case"ref":return`{${te(e.path)}}`;case"color":return ve(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 In(e)}}s(kn,"projectValue");function Sn(e){let n={$value:kn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Sn,"projectToken");function K(e){let n={};for(let[o,r]of Object.entries(e))n[b(o)]=y(r)?Sn(r):K(r);return n}s(K,"projectGroup");function A(e,n){let o={$description:n,...K(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(A,"renderSet");function we(e){return A(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(we,"renderBaseSet");function Ce(e,n,o,r){return A(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(Ce,"renderColorSet");function Ve(e,n){return A(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Ve,"renderSpacingSet");function $e(e,n){return A(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s($e,"renderFontSet");function Ge(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(Ge,"renderResolver");var xn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Oe(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(v(i.value))},`):(o.push(`${r}${t}: {`),Oe(i,n+1,o),o.push(`${r}},`))}s(Oe,"emitGroup");function Ee(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[xn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return Oe(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
5
|
+
`)}s(Ee,"renderTs");var Tn=["light","dark"],Dn=["positive","negative"],vn=["compact","normal","spacious"];function P(e){let n=e.modes??Tn,o=e.surfaces??Dn,r=e.dimensions??vn,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let d of n)for(let f of o)for(let k of r)i.push({brand:a,colors:c,mode:d,surface:f,dimension:k});return i}s(P,"expandVariants");function Fe(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Fe,"variantName");import{createHash as wn}from"node:crypto";function Q(e){return wn("sha256").update(e).digest("hex")}s(Q,"sha256");function ee(e){return Q(Z(e))}s(ee,"hashConfig");function Z(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Z).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Z(e[r])}`).join(",")}}`}s(Z,"stableStringify");function Me(e){try{let{execSync:n}=Qe("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(Me,"detectGitCommit");function je(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(je,"buildEnv");function Ae(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(Ae,"serializeManifest");var Cn="json/sets",Pe="json/resolver.json";function L(e){return`${Cn}/${e}.json`}s(L,"setFile");function Vn(e,n,o){return`${e}.color.${n}.${o}`}s(Vn,"colorSetName");function $n(e){return`spacing.${e}`}s($n,"spacingSetName");function Gn(e){return`font.${e}`}s(Gn,"fontSetName");function N(e,n){e.includes(n)||e.push(n)}s(N,"pushUnique");function Le(e){let n=P(e),o=[],r=[],t=[],i=[],a=new Set,c=[],d=new Set,f=[],k=new Set,C=[];for(let u of n){N(o,u.brand),N(r,u.mode),N(t,u.surface),N(i,u.dimension);let m=Vn(u.brand,u.mode,u.surface);a.has(m)||(a.add(m),c.push({kind:"color",name:m,file:L(m),brand:u.brand,mode:u.mode,surface:u.surface}));let R=$n(u.dimension);d.has(R)||(d.add(R),f.push({kind:"spacing",name:R,file:L(R),dimension:u.dimension}));let p=Gn(u.dimension);k.has(p)||(k.add(p),C.push({kind:"font",name:p,file:L(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:L("base")},spacing:f,font:C,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Le,"planSets");import{createFoundation as ze}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Pn}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Ln}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Nn}from"@apollion-dsi/core/themes/surface";import{converter as On,formatHex as ne,interpolate as En,parse as T,wcagContrast as Fn}from"culori";var We=On("oklch");function l(e,n,o){let r=T(e),t=T(n);if(!r||!t)return e;let i=En([r,t],"oklch");return ne(i(o))??e}s(l,"mixOklch");function Mn(e){return e?typeof e=="string"?e:e.base:"#000"}s(Mn,"coerceToHex");var B=1.3,jn=.05,Ne=.04,D=s((e,n)=>{let o=T(e),r=T(n);return!o||!r?1:Fn(o,r)},"contrastRatio"),oe=s(e=>{let n=We(T(e));return n?n.l??0:null},"oklchLightness"),Be=s((e,n)=>{if(D(e,n)>=B)return!0;let o=oe(e),r=oe(n);return o!==null&&r!==null&&Math.abs(o-r)>=jn},"isPerceptibleState"),An=s(e=>e?D("#fff",e)>D("#000",e):!1,"isDarkSurface");function _e(e,n,o){let r=We(T(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?Ne:-Ne;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let d=ne(t);if(d&&D(e,d)>=B)return d}return ne(t)??null}s(_e,"derivePerceptibleState");function He(e,n,o){let r=_e(e,n,o);if(r&&D(e,r)>=B)return r;let t=_e(e,!n);return t&&D(e,t)>=B?t:r??t}s(He,"perceptibleStateFor");function h(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=Mn(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:l(r,t,.6),action:l(r,t,.2),active:l(r,i,.6),light:l(r,i,.9)};if(T(r)){let c=An(n.baseLight),d=Be(r,a.action);if(d||(a.action=He(r,c)??a.action),!Be(r,a.active)){let f=d?void 0:oe(a.action)??void 0;a.active=He(r,c,f)??a.active}}return o?{base:r,dark:o.dark??a.dark,action:o.action??a.action,active:o.active??a.active,light:o.light??a.light}:a}s(h,"mountSingleColor");function Je(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(Je,"mountGreyscaleColors");function Ue(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=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(Ue,"mountNeutralColors");function Bn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Ue(e),grayscale:Je(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(Bn,"composeColors");function _(e,n=Ln){let o=Bn(e.colors),r=G(n,e.dimension),t=Pn({colors:o,spacing:r}),i=ze(t);return e.surface==="negative"&&(i=ze(Nn({semantic:t,colors:o},"negative").semantic)),{foundation:i,colors:o}}s(_,"buildVariantThemes");async function Zo(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=P(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await _n(H(Jn(),"apollion-tokens-"));try{let d=[],f=s(async(u,m)=>{await Un(c,u,m),d.push({path:u,sha256:Q(m)}),t&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Le(n),m=[],R=be();m.push(R),await f(u.base.file,we(R));for(let p of u.spacing){let I=i.find($=>$.dimension===p.dimension),{foundation:W}=_(I),V=ke(W,p.dimension);m.push(V),await f(p.file,Ve(V,p.dimension))}for(let p of u.font){let I=Re(p.dimension);m.push(I),await f(p.file,$e(I,p.dimension))}for(let p of u.color){let I=i.find(J=>J.brand===p.brand&&J.mode===p.mode&&J.surface===p.surface),{foundation:W,colors:V}=_(I),$=Ie(W,V);m.push($),await f(p.file,Ce($,p.brand,p.mode,p.surface))}he(m),await f(Pe,Ge(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:m,colors:R}=_(u),p=Se(m,R,u),I=Fe(u);a.css&&await f(`css/${I}.css`,De(p)),a.ts&&await f(`ts/${I}.d.ts`,Ee(p))}let k={configHash:ee(n),files:d,gitCommit:Me(r),buildEnv:je()},C=Ae(k);return await qe(H(c,"manifest.json"),C),await Xe(o,{recursive:!0,force:!0}),await Ye(Ke(o),{recursive:!0}),await Wn(c,o),t&&console.log(`\u2713 ${d.length} files \u2192 ${o}`),{manifest:k,outDir:o}}catch(d){throw await Xe(c,{recursive:!0,force:!0}).catch(()=>{}),d}}s(Zo,"build");async function Qo(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await Hn(H(o,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===ee(n)}s(Qo,"check");async function Un(e,n,o){let r=H(e,n);await Ye(Ke(r),{recursive:!0}),await qe(r,o)}s(Un,"writeAt");export{Zo as build,Qo as check};
|
package/lib/builders/colors.d.ts
CHANGED
|
@@ -24,11 +24,15 @@
|
|
|
24
24
|
* @see ../../docs/adr/ADR-006-v4-oklch-dimension-token-split.md §3.1 §6 S4
|
|
25
25
|
* @see ../../docs/prd/PRD-002-v4-epic-execution.md §S4
|
|
26
26
|
*/
|
|
27
|
-
import type { AcceptColorType, ColorPalleteInterface, ColorsInput, GrayscaleColorsType, NeutralColorsType } from '@apollion-dsi/core/themes/colors';
|
|
27
|
+
import type { AcceptColorType, ColorPalleteInterface, ColorPalleteOverrideInterface, ColorsInput, GrayscaleColorsType, NeutralColorsType } from '@apollion-dsi/core/themes/colors';
|
|
28
28
|
/** Rotate hue 180° in OKLch space. Semantic shift vs HSL — see core for details. */
|
|
29
29
|
export declare function getOppositeColor(color: AcceptColorType): string;
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Derive `{ base, dark, action, active, light }` via OKLch lerp, com piso
|
|
32
|
+
* perceptual mode-aware nos estados de interação — espelho byte-a-byte do
|
|
33
|
+
* core (ADR-012; parity.test.ts). Overrides por slot passam verbatim.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mountSingleColor(color: AcceptColorType | ColorPalleteOverrideInterface, colors: ColorsInput): ColorPalleteInterface;
|
|
32
36
|
/** 12-step greyscale ramp — perceptually uniform via OKLch lerp. */
|
|
33
37
|
export declare function mountGreyscaleColors(colors: ColorsInput): Record<GrayscaleColorsType, string>;
|
|
34
38
|
/** 20-step neutral ramp anchored at n170 (primary mixed with darker). */
|
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
|
-
`}
|
|
8
|
-
`);throw new
|
|
9
|
-
${l}`,
|
|
2
|
+
var ln=Object.defineProperty;var i=(e,n)=>ln(e,"name",{value:n,configurable:!0}),dn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as po}from"node:fs/promises";import{resolve as ce}from"node:path";import{mkdir as nn,mkdtemp as Zn,readFile as Qn,rename as eo,rm as en,writeFile as on}from"node:fs/promises";import{tmpdir as no}from"node:os";import{dirname as tn,join as J}from"node:path";import{defaultInputBorder as P}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as pn}from"@apollion-dsi/core/themes/colors";import{createDeth as fn,levelValues as mn}from"@apollion-dsi/core/themes/depth";import{createFont as gn,defaultInputFont as w}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as le}from"@apollion-dsi/core/themes/spacing";import{converter as yn,formatHex as hn,parse as bn}from"culori";import{DIMENSION_MULTIPLIERS as un}from"@apollion-dsi/core/themes/dimension";function j({multiplier:e=.25,alias:n},o){let t=o!==void 0?un[o]:e;return(...r)=>r.map(s=>{let a=typeof s=="string"?n[s]:s;return`${t*a}rem`}).join(" ")}i(j,"createSpacing");var Y={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function K(e){let n=Object.keys(Y).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}i(K,"assertTokenMetaResolves");var Rn=yn("oklch");function b(e){return typeof e.type=="string"&&"value"in e}i(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}i(k,"kebab");function de(e){return e.split(".").map(k).join(".")}i(de,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}i($,"rawValue");function G(e,n){return Number(e.toFixed(n))||0}i(G,"round");function Q(e){let n=Rn(bn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[G(n.l,4),G(n.c,4),G(n.h??0,2)],t=hn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:G(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}i(Q,"toColorValue");var ue=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let n=ue.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}i(D,"toDimensionValue");function y(e){return{type:"color",value:Q(e)}}i(y,"colorToken");function Z(e){let n={};for(let[o,t]of Object.entries(e))n[o]=y(t);return n}i(Z,"recordColorGroup");function pe(e){let n=pn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=y(r);return o.neutral=Z(n.neutral),o}i(pe,"buildReadableTextGroup");var kn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function fe(e){let n={};for(let o of kn){let t=e[o];n[o]={base:y(t.base),dark:y(t.dark),action:y(t.action),active:y(t.active),light:y(t.light)}}return n.grayscale=Z(e.grayscale),n.neutral=Z(e.neutral),n.baseDark=y(e.baseDark??"#000000"),n.baseLight=y(e.baseLight??"#ffffff"),n.deepDark=y(e.deepDark??"#000000"),n.deepLight=y(e.deepLight??"#ffffff"),n}i(fe,"buildColorPrimitives");function me(e){let n=j(le,e),o={};for(let t of Object.keys(le.alias))o[t]={type:"dimension",value:D(n(t))};return o}i(me,"buildSpacePrimitives");function ge(){let e={};for(let[n,o]of Object.entries(P.borderWidth))e[n]={type:"dimension",value:D(o)};return e}i(ge,"buildBorderWidthPrimitives");function In(e,n){return{color:fe(e),space:me(n),borderWidth:ge()}}i(In,"buildPrimitives");var ye={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},he={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Sn(e,n){let o=e;for(let t of n.split(".").slice(1))if(o&&typeof o=="object"&&t in o)o=o[t];else return;return typeof o=="string"?o:void 0}i(Sn,"lookupPrimitive");function F(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?Sn(n,a):void 0;t[r]=a&&c===s?{type:"color",value:{kind:"ref",path:a,resolved:Q(s)}}:y(s)}return t}i(F,"colorRefGroup");var be={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},xn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function wn(e,n){let o=n.split("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let s of o.slice(1))if(r&&!b(r)&&s in r)r=r[s];else return;return r&&b(r)&&r.value.kind==="dimension"?r.value.raw:void 0}i(wn,"lookupDimensionPrimitive");function ee(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?wn(n,a):void 0;t[r]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:D(s)}}:{type:"dimension",value:D(s)}}return t}i(ee,"dimensionRefGroup");function Re(e){let n={},o={};for(let[s,a]of Object.entries(P.borderRadius))ue.test(a)?n[s]={type:"dimension",value:D(a)}:o[s]=a;let t=ee(P.borderWidth,e,xn),r={};for(let[s,a]of Object.entries(P.borderStyle))r[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}i(Re,"buildBorder");function ke(e){let n=gn(w,e),o={};for(let[c,l]of Object.entries(w.fontFamily)){let f=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:D(l)};let r={};for(let[c,l]of Object.entries(w.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let s={};for(let[c,l]of Object.entries(w.lineHeight))s[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:w.letterSpacing,textTransform:w.textTransform,fontStyle:w.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:s},extensions:a}}i(ke,"buildFont");var Dn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function vn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let t=n.match(Dn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=i(l=>D(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Q(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}i(vn,"parseShadow");function Ie(e){let n=fn(e),o={};for(let t of Object.keys(mn))o[t]={type:"shadow",value:vn(n(t))};return o}i(Ie,"buildShadow");function M(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=n?`${n}.${k(r)}`:k(r);if(b(s)){o.add(a);let c=Y[a];t[r]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...s,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:s}else t[r]=M(s,a,o)}return t}i(M,"decorateGroup");function Tn(e){let n=new Set,o=M(e.primitives,"",n),t=M(e.groups,"",n);return K(n),{...e,primitives:o,groups:t}}i(Tn,"decorateMeta");function N(e,n){return M(e,"",n)}i(N,"decorateSlice");function Se(e,n,o){for(let[t,r]of Object.entries(e)){let s=n?`${n}.${k(t)}`:k(t);b(r)?o.add(s):Se(r,s,o)}}i(Se,"collectPaths");function xe(e){let n=new Set;for(let o of e)Se(o.groups,"",n);K(n)}i(xe,"assertSlicesMetaComplete");function we(){let e=ge(),o=Re({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:N({"border-width":e,border:o.group},r),extensions:t}}i(we,"buildBaseIR");function De(e){let n=ke(e),o=new Set;return{groups:N({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}i(De,"buildFontIR");function ve(e,n){let o=fe(n),t=new Set;return{groups:N({color:o,bg:F(e.bg,n,ye),text:F(e.text,n,he),tx:pe(n),shadow:Ie(n)},t),extensions:{}}}i(ve,"buildColorIR");function Te(e,n){let o=me(n),t={space:o},r=new Set;return{groups:N({space:o,spacing:ee(e.spacing,t,be)},r),extensions:{}}}i(Te,"buildSpacingIR");function Cn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=In(n,o.dimension),s=Re(r),a=ke(o.dimension),c={"com.apollion.variant":t,"com.apollion.font":a.extensions};Object.keys(s.extensions).length>0&&(c["com.apollion.border"]={radius:s.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:F(e.bg,n,ye),text:F(e.text,n,he),tx:pe(n),spacing:ee(e.spacing,r,be),border:s.group,font:a.group,shadow:Ie(n)},extensions:c};return Tn(l)}i(Cn,"buildIR");var Ce=Cn;var $n="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function $e(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,k(t)];b(r)?o.push(` --apollion-${s.join("-")}: ${$(r.value)};`):$e(r,s,o)}}i($e,"emitVars");function Ve(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,k(t)];b(r)?r.type==="color"&&o.push(` @property --apollion-${s.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(r.value)}; }`):Ve(r,s,o)}}i(Ve,"emitProperties");function Oe(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[$n,""];return s.push(`/* Variant: brand=${n} mode=${o} surface=${t} dimension=${r} */`,"",":root {"),$e(e.groups,[],s),s.push("}",""),s.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Ve(e.groups,[],s),s.push("}",""),s.join(`
|
|
3
|
+
`)}i(Oe,"renderCss");function Ae(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(Ae,"colorValue");function V(e){return{value:e.value,unit:e.unit}}i(V,"dimensionValue");function Vn(e){let n=e.shadow,o={color:Ae(n.color),offsetX:V(n.offsetX),offsetY:V(n.offsetY),blur:V(n.blur),spread:V(n.spread)};return n.inset&&(o.inset=!0),o}i(Vn,"shadowValue");function On(e){switch(e.kind){case"ref":return`{${de(e.path)}}`;case"color":return Ae(e);case"dimension":return V(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Vn(e)}}i(On,"projectValue");function An(e){let n={$value:On(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}i(An,"projectToken");function ne(e){let n={};for(let[o,t]of Object.entries(e))n[k(o)]=b(t)?An(t):ne(t);return n}i(ne,"projectGroup");function L(e,n){let o={$description:n,...ne(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
4
|
+
`}i(L,"renderSet");function Ee(e){return L(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}i(Ee,"renderBaseSet");function je(e,n,o,t){return L(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${t}. DTCG 2025.10.`)}i(je,"renderColorSet");function Ge(e,n){return L(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}i(Ge,"renderSpacingSet");function Pe(e,n){return L(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}i(Pe,"renderFontSet");function Fe(e,n){let{modifiers:o}=n,t=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],s={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:t,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(s,null,2)}
|
|
5
|
+
`}i(Fe,"renderResolver");var En="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Me(e,n,o){let t=" ".repeat(n);for(let[r,s]of Object.entries(e))b(s)?o.push(`${t}${JSON.stringify(r)}: ${JSON.stringify($(s.value))},`):(o.push(`${t}${r}: {`),Me(s,n+1,o),o.push(`${t}},`))}i(Me,"emitGroup");function Ne(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[En,`// Variant: brand=${n} mode=${o} surface=${t} dimension=${r}`,"","export const tokens = {"];return Me(e.groups,1,s),s.push("} as const;","","export type Tokens = typeof tokens;",""),s.join(`
|
|
6
|
+
`)}i(Ne,"renderTs");var jn=["light","dark"],Gn=["positive","negative"],Pn=["compact","normal","spacious"];function _(e){let n=e.modes??jn,o=e.surfaces??Gn,t=e.dimensions??Pn,r=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),s=[];for(let[a,c]of r)for(let l of n)for(let f of o)for(let x of t)s.push({brand:a,colors:c,mode:l,surface:f,dimension:x});return s}i(_,"expandVariants");function Le(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}i(Le,"variantName");import{createHash as Fn}from"node:crypto";function te(e){return Fn("sha256").update(e).digest("hex")}i(te,"sha256");function re(e){return te(oe(e))}i(re,"hashConfig");function oe(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(oe).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${oe(e[t])}`).join(",")}}`}i(oe,"stableStringify");function _e(e){try{let{execSync:n}=dn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}i(_e,"detectGitCommit");function Be(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}i(Be,"buildEnv");function He(e){let n=[...e.files].sort((t,r)=>t.path.localeCompare(r.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
7
|
+
`}i(He,"serializeManifest");var Mn="json/sets",We="json/resolver.json";function B(e){return`${Mn}/${e}.json`}i(B,"setFile");function Nn(e,n,o){return`${e}.color.${n}.${o}`}i(Nn,"colorSetName");function Ln(e){return`spacing.${e}`}i(Ln,"spacingSetName");function _n(e){return`font.${e}`}i(_n,"fontSetName");function H(e,n){e.includes(n)||e.push(n)}i(H,"pushUnique");function Ue(e){let n=_(e),o=[],t=[],r=[],s=[],a=new Set,c=[],l=new Set,f=[],x=new Set,O=[];for(let u of n){H(o,u.brand),H(t,u.mode),H(r,u.surface),H(s,u.dimension);let g=Nn(u.brand,u.mode,u.surface);a.has(g)||(a.add(g),c.push({kind:"color",name:g,file:B(g),brand:u.brand,mode:u.mode,surface:u.surface}));let I=Ln(u.dimension);l.has(I)||(l.add(I),f.push({kind:"spacing",name:I,file:B(I),dimension:u.dimension}));let p=_n(u.dimension);x.has(p)||(x.add(p),O.push({kind:"font",name:p,file:B(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:B("base")},spacing:f,font:O,color:c,modifiers:{brand:o,mode:t,surface:r,dimension:s}}}i(Ue,"planSets");import{createFoundation as Qe}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Xn}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as qn}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Yn}from"@apollion-dsi/core/themes/surface";import{converter as Bn,formatHex as ie,interpolate as Hn,parse as v,wcagContrast as Wn}from"culori";var Ye=Bn("oklch");function d(e,n,o){let t=v(e),r=v(n);if(!t||!r)return e;let s=Hn([t,r],"oklch");return ie(s(o))??e}i(d,"mixOklch");function Un(e){return e?typeof e=="string"?e:e.base:"#000"}i(Un,"coerceToHex");var W=1.3,Jn=.05,Je=.04,C=i((e,n)=>{let o=v(e),t=v(n);return!o||!t?1:Wn(o,t)},"contrastRatio"),se=i(e=>{let n=Ye(v(e));return n?n.l??0:null},"oklchLightness"),ze=i((e,n)=>{if(C(e,n)>=W)return!0;let o=se(e),t=se(n);return o!==null&&t!==null&&Math.abs(o-t)>=Jn},"isPerceptibleState"),zn=i(e=>e?C("#fff",e)>C("#000",e):!1,"isDarkSurface");function Xe(e,n,o){let t=Ye(v(e));if(!t)return null;let r={...t,l:o??t.l??0},s=n?Je:-Je;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(r.l??0)+s));if(c===(r.l??0))break;r={...r,l:c};let l=ie(r);if(l&&C(e,l)>=W)return l}return ie(r)??null}i(Xe,"derivePerceptibleState");function qe(e,n,o){let t=Xe(e,n,o);if(t&&C(e,t)>=W)return t;let r=Xe(e,!n);return r&&C(e,r)>=W?r:t??r}i(qe,"perceptibleStateFor");function R(e,n){let o=typeof e=="object"&&e!==null?e:void 0,t=Un(e),r=n.deepDark,s=n.deepLight,a={base:t,dark:d(t,r,.6),action:d(t,r,.2),active:d(t,s,.6),light:d(t,s,.9)};if(v(t)){let c=zn(n.baseLight),l=ze(t,a.action);if(l||(a.action=qe(t,c)??a.action),!ze(t,a.active)){let f=l?void 0:se(a.action)??void 0;a.active=qe(t,c,f)??a.active}}return o?{base:t,dark:o.dark??a.dark,action:o.action??a.action,active:o.active??a.active,light:o.light??a.light}:a}i(R,"mountSingleColor");function Ke(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:d(n,o,.05),10:d(n,o,.1),20:d(n,o,.2),30:d(n,o,.3),40:d(n,o,.4),50:d(n,o,.5),60:d(n,o,.6),70:d(n,o,.7),80:d(n,o,.8),90:d(n,o,.9),100:d(n,o,1)}}i(Ke,"mountGreyscaleColors");function Ze(e){let n=e.deepLight,o=e.deepDark,t=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,r=i(a=>1/17*(a-1),"interpolation"),s=d(t,o,.5);return{0:d(s,n,r(18)),5:d(s,n,r(17.5)),10:d(s,n,r(17)),20:d(s,n,r(16)),30:d(s,n,r(15)),40:d(s,n,r(14)),50:d(s,n,r(13)),60:d(s,n,r(12)),70:d(s,n,r(11)),80:d(s,n,r(10)),90:d(s,n,r(9)),100:d(s,n,r(8)),110:d(s,n,r(7)),120:d(s,n,r(6)),130:d(s,n,r(5)),140:d(s,n,r(4)),150:d(s,n,r(3)),160:d(s,n,r(2)),170:s,180:d(s,o,.25)}}i(Ze,"mountNeutralColors");function Kn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Ze(e),grayscale:Ke(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(Kn,"composeColors");function U(e,n=qn){let o=Kn(e.colors),t=j(n,e.dimension),r=Xn({colors:o,spacing:t}),s=Qe(r);return e.surface==="negative"&&(s=Qe(Yn({semantic:r,colors:o},"negative").semantic)),{foundation:s,colors:o}}i(U,"buildVariantThemes");async function rn(e){let{config:n,outDir:o,cwd:t=process.cwd(),verbose:r=!1}=e,s=_(n),a=n.output??{};if(s.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await Zn(J(no(),"apollion-tokens-"));try{let l=[],f=i(async(u,g)=>{await oo(c,u,g),l.push({path:u,sha256:te(g)}),r&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Ue(n),g=[],I=we();g.push(I),await f(u.base.file,Ee(I));for(let p of u.spacing){let S=s.find(E=>E.dimension===p.dimension),{foundation:X}=U(S),A=Te(X,p.dimension);g.push(A),await f(p.file,Ge(A,p.dimension))}for(let p of u.font){let S=De(p.dimension);g.push(S),await f(p.file,Pe(S,p.dimension))}for(let p of u.color){let S=s.find(q=>q.brand===p.brand&&q.mode===p.mode&&q.surface===p.surface),{foundation:X,colors:A}=U(S),E=ve(X,A);g.push(E),await f(p.file,je(E,p.brand,p.mode,p.surface))}xe(g),await f(We,Fe(n,u))}if(a.css||a.ts)for(let u of s){let{foundation:g,colors:I}=U(u),p=Ce(g,I,u),S=Le(u);a.css&&await f(`css/${S}.css`,Oe(p)),a.ts&&await f(`ts/${S}.d.ts`,Ne(p))}let x={configHash:re(n),files:l,gitCommit:_e(t),buildEnv:Be()},O=He(x);return await on(J(c,"manifest.json"),O),await en(o,{recursive:!0,force:!0}),await nn(tn(o),{recursive:!0}),await eo(c,o),r&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:x,outDir:o}}catch(l){throw await en(c,{recursive:!0,force:!0}).catch(()=>{}),l}}i(rn,"build");async function sn(e){let{config:n,outDir:o}=e,t;try{t=JSON.parse(await Qn(J(o,"manifest.json"),"utf8"))}catch{return!1}return t.configHash===re(n)}i(sn,"check");async function oo(e,n,o){let t=J(e,n);await nn(tn(t),{recursive:!0}),await on(t,o)}i(oo,"writeAt");import{readFile as ro}from"node:fs/promises";import{resolve as io}from"node:path";import{createContext as so,Script as ao}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"'}),to=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(),an=m.object({brands:m.record(m.string(),to).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 co=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],lo=1e3;var ae=class ae extends Error{constructor(o,t){super(o);this.configPath=t;this.name="ConfigLoadError"}};i(ae,"ConfigLoadError");var T=ae;async function cn(e){let n=io(e.configPath),o=await ro(n,"utf8");for(let l of co)if(l.test(o))throw new T(`apollion.config: dynamic require/import not allowed (matched ${l}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,n);let t=o.replace(/(^|\n)\s*export\s+default\s+/,(l,f)=>`${f}__apollion_config_export = `);if(t===o)throw new T("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",n);let r={__apollion_config_export:void 0,console:uo(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:i(l=>l,"defineConfig")},s=so(r);try{new ao(t,{filename:n}).runInContext(s,{timeout:lo})}catch(l){throw new T(`apollion.config: evaluation failed \u2014 ${l instanceof Error?l.message:String(l)}`,n)}let a=r.__apollion_config_export;if(a===void 0)throw new T("apollion.config: `export default` produced undefined.",n);let c=an.safeParse(a);if(!c.success){let l=c.error.issues.map(f=>` ${f.path.join(".")||"(root)"}: ${f.message}`).join(`
|
|
8
|
+
`);throw new T(`apollion.config: schema validation failed \u2014
|
|
9
|
+
${l}`,n)}return c.data}i(cn,"loadConfig");function uo(){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(uo,"makeReadOnlyConsole");function fo(e){let n=e.slice(2),o=n[0];o!=="build"&&z(`Unknown command "${o??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let t="apollion.config.mjs",r="dist",s=!1,a=!1;for(let c=1;c<n.length;c++){let l=n[c];switch(l){case"--config":t=n[++c]??z("--config needs a path");break;case"--out":r=n[++c]??z("--out needs a path");break;case"--check":s=!0;break;case"--verbose":a=!0;break;default:z(`Unknown flag "${l}"`)}}return{command:o,configPath:t,outDir:r,check:s,verbose:a}}i(fo,"parseArgs");function z(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}i(z,"fail");async function mo(e){let n=ce(e);if(n.endsWith(".json")){let o=await po(n,"utf8");return JSON.parse(o)}return cn({configPath:n})}i(mo,"loadConfigFromPath");async function go(){let e=fo(process.argv),n=await mo(e.configPath);if(e.check){await sn({config:n,outDir:ce(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:o}=await rn({config:n,outDir:ce(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${o.files.length} file(s) \u2014 configHash=${o.configHash.slice(0,12)}\u2026`)}i(go,"main");go().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
|
package/lib/runtime/v1.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var l=(t,e)=>m(t,"name",{value:e,configurable:!0});var D=(t,e)=>{for(var r in e)m(t,r,{get:e[r],enumerable:!0})},F=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of M(e))!P.call(t,n)&&n!==r&&m(t,n,{get:()=>e[n],enumerable:!(o=E(e,n))||o.enumerable});return t};var R=t=>F(m({},"__esModule",{value:!0}),t);var H={};D(H,{TOKENS_RUNTIME_API_VERSION:()=>B,createFoundation:()=>y.createFoundation,createSpacing:()=>O,getOppositeColor:()=>b,invertForSurface:()=>C.invertForSurface,mountGreyscaleColors:()=>L,mountNeutralColors:()=>A,mountSingleColor:()=>v});module.exports=R(H);var a=require("culori");var h=(0,a.converter)("oklch");function i(t,e,r){let o=(0,a.parse)(t),n=(0,a.parse)(e);if(!o||!n)return t;let c=(0,a.interpolate)([o,n],"oklch");return(0,a.formatHex)(c(r))??t}l(i,"mixOklch");function k(t){return t?typeof t=="string"?t:t.base:"#000"}l(k,"coerceToHex");function b(t){let e=k(t),r=h((0,a.parse)(e));if(!r)return e;let o={...r,h:((r.h??0)+180)%360};return(0,a.formatHex)(o)??e}l(b,"getOppositeColor");var d=1.3,G=.05,S=.04,u=l((t,e)=>{let r=(0,a.parse)(t),o=(0,a.parse)(e);return!r||!o?1:(0,a.wcagContrast)(r,o)},"contrastRatio"),g=l(t=>{let e=h((0,a.parse)(t));return e?e.l??0:null},"oklchLightness"),T=l((t,e)=>{if(u(t,e)>=d)return!0;let r=g(t),o=g(e);return r!==null&&o!==null&&Math.abs(r-o)>=G},"isPerceptibleState"),j=l(t=>t?u("#fff",t)>u("#000",t):!1,"isDarkSurface");function I(t,e,r){let o=h((0,a.parse)(t));if(!o)return null;let n={...o,l:r??o.l??0},c=e?S:-S;for(let s=0;s<25;s+=1){let f=Math.min(1,Math.max(0,(n.l??0)+c));if(f===(n.l??0))break;n={...n,l:f};let p=(0,a.formatHex)(n);if(p&&u(t,p)>=d)return p}return(0,a.formatHex)(n)??null}l(I,"derivePerceptibleState");function x(t,e,r){let o=I(t,e,r);if(o&&u(t,o)>=d)return o;let n=I(t,!e);return n&&u(t,n)>=d?n:o??n}l(x,"perceptibleStateFor");function v(t,e){let r=typeof t=="object"&&t!==null?t:void 0,o=k(t),n=e.deepDark,c=e.deepLight,s={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,c,.6),light:i(o,c,.9)};if((0,a.parse)(o)){let f=j(e.baseLight),p=T(o,s.action);if(p||(s.action=x(o,f)??s.action),!T(o,s.active)){let _=p?void 0:g(s.action)??void 0;s.active=x(o,f,_)??s.active}}return r?{base:o,dark:r.dark??s.dark,action:r.action??s.action,active:r.active??s.active,light:r.light??s.light}:s}l(v,"mountSingleColor");function L(t){let e=t.deepLight,r=t.deepDark;return{0:e,5:i(e,r,.05),10:i(e,r,.1),20:i(e,r,.2),30:i(e,r,.3),40:i(e,r,.4),50:i(e,r,.5),60:i(e,r,.6),70:i(e,r,.7),80:i(e,r,.8),90:i(e,r,.9),100:i(e,r,1)}}l(L,"mountGreyscaleColors");function A(t){let e=t.deepLight,r=t.deepDark,o=typeof t.primary=="object"&&t.primary?t.primary.base:t.primary,n=l(s=>1/17*(s-1),"interpolation"),c=i(o,r,.5);return{0:i(c,e,n(18)),5:i(c,e,n(17.5)),10:i(c,e,n(17)),20:i(c,e,n(16)),30:i(c,e,n(15)),40:i(c,e,n(14)),50:i(c,e,n(13)),60:i(c,e,n(12)),70:i(c,e,n(11)),80:i(c,e,n(10)),90:i(c,e,n(9)),100:i(c,e,n(8)),110:i(c,e,n(7)),120:i(c,e,n(6)),130:i(c,e,n(5)),140:i(c,e,n(4)),150:i(c,e,n(3)),160:i(c,e,n(2)),170:c,180:i(c,r,.25)}}l(A,"mountNeutralColors");var N=require("@apollion-dsi/core/themes/dimension");function O({multiplier:t=.25,alias:e},r){let o=r!==void 0?N.DIMENSION_MULTIPLIERS[r]:t;return(...n)=>n.map(c=>{let s=typeof c=="string"?e[c]:c;return`${o*s}rem`}).join(" ")}l(O,"createSpacing");var y=require("@apollion-dsi/core/themes/foundation");var C=require("@apollion-dsi/core/themes/surface");var B="v1";0&&(module.exports={TOKENS_RUNTIME_API_VERSION,createFoundation,createSpacing,getOppositeColor,invertForSurface,mountGreyscaleColors,mountNeutralColors,mountSingleColor});
|
package/lib/runtime/v1.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty;var s=(t,e)=>k(t,"name",{value:e,configurable:!0});import{converter as b,formatHex as m,interpolate as v,parse as l,wcagContrast as L}from"culori";var h=b("oklch");function i(t,e,r){let o=l(t),n=l(e);if(!o||!n)return t;let c=v([o,n],"oklch");return m(c(r))??t}s(i,"mixOklch");function I(t){return t?typeof t=="string"?t:t.base:"#000"}s(I,"coerceToHex");function A(t){let e=I(t),r=h(l(e));if(!r)return e;let o={...r,h:((r.h??0)+180)%360};return m(o)??e}s(A,"getOppositeColor");var d=1.3,N=.05,y=.04,u=s((t,e)=>{let r=l(t),o=l(e);return!r||!o?1:L(r,o)},"contrastRatio"),g=s(t=>{let e=h(l(t));return e?e.l??0:null},"oklchLightness"),C=s((t,e)=>{if(u(t,e)>=d)return!0;let r=g(t),o=g(e);return r!==null&&o!==null&&Math.abs(r-o)>=N},"isPerceptibleState"),O=s(t=>t?u("#fff",t)>u("#000",t):!1,"isDarkSurface");function S(t,e,r){let o=h(l(t));if(!o)return null;let n={...o,l:r??o.l??0},c=e?y:-y;for(let a=0;a<25;a+=1){let f=Math.min(1,Math.max(0,(n.l??0)+c));if(f===(n.l??0))break;n={...n,l:f};let p=m(n);if(p&&u(t,p)>=d)return p}return m(n)??null}s(S,"derivePerceptibleState");function T(t,e,r){let o=S(t,e,r);if(o&&u(t,o)>=d)return o;let n=S(t,!e);return n&&u(t,n)>=d?n:o??n}s(T,"perceptibleStateFor");function _(t,e){let r=typeof t=="object"&&t!==null?t:void 0,o=I(t),n=e.deepDark,c=e.deepLight,a={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,c,.6),light:i(o,c,.9)};if(l(o)){let f=O(e.baseLight),p=C(o,a.action);if(p||(a.action=T(o,f)??a.action),!C(o,a.active)){let x=p?void 0:g(a.action)??void 0;a.active=T(o,f,x)??a.active}}return r?{base:o,dark:r.dark??a.dark,action:r.action??a.action,active:r.active??a.active,light:r.light??a.light}:a}s(_,"mountSingleColor");function E(t){let e=t.deepLight,r=t.deepDark;return{0:e,5:i(e,r,.05),10:i(e,r,.1),20:i(e,r,.2),30:i(e,r,.3),40:i(e,r,.4),50:i(e,r,.5),60:i(e,r,.6),70:i(e,r,.7),80:i(e,r,.8),90:i(e,r,.9),100:i(e,r,1)}}s(E,"mountGreyscaleColors");function M(t){let e=t.deepLight,r=t.deepDark,o=typeof t.primary=="object"&&t.primary?t.primary.base:t.primary,n=s(a=>1/17*(a-1),"interpolation"),c=i(o,r,.5);return{0:i(c,e,n(18)),5:i(c,e,n(17.5)),10:i(c,e,n(17)),20:i(c,e,n(16)),30:i(c,e,n(15)),40:i(c,e,n(14)),50:i(c,e,n(13)),60:i(c,e,n(12)),70:i(c,e,n(11)),80:i(c,e,n(10)),90:i(c,e,n(9)),100:i(c,e,n(8)),110:i(c,e,n(7)),120:i(c,e,n(6)),130:i(c,e,n(5)),140:i(c,e,n(4)),150:i(c,e,n(3)),160:i(c,e,n(2)),170:c,180:i(c,r,.25)}}s(M,"mountNeutralColors");import{DIMENSION_MULTIPLIERS as P}from"@apollion-dsi/core/themes/dimension";function D({multiplier:t=.25,alias:e},r){let o=r!==void 0?P[r]:t;return(...n)=>n.map(c=>{let a=typeof c=="string"?e[c]:c;return`${o*a}rem`}).join(" ")}s(D,"createSpacing");import{createFoundation as F}from"@apollion-dsi/core/themes/foundation";import{invertForSurface as R}from"@apollion-dsi/core/themes/surface";var z="v1";export{z as TOKENS_RUNTIME_API_VERSION,F as createFoundation,D as createSpacing,A as getOppositeColor,R as invertForSurface,E as mountGreyscaleColors,M as mountNeutralColors,_ as mountSingleColor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollion-dsi/tokens",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.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/builders/colors.ts
CHANGED
|
@@ -27,11 +27,13 @@
|
|
|
27
27
|
import type {
|
|
28
28
|
AcceptColorType,
|
|
29
29
|
ColorPalleteInterface,
|
|
30
|
+
ColorPalleteOverrideInterface,
|
|
31
|
+
ColorSeedInputType,
|
|
30
32
|
ColorsInput,
|
|
31
33
|
GrayscaleColorsType,
|
|
32
34
|
NeutralColorsType,
|
|
33
35
|
} from '@apollion-dsi/core/themes/colors';
|
|
34
|
-
import { converter, formatHex, interpolate, parse } from 'culori';
|
|
36
|
+
import { converter, formatHex, interpolate, parse, wcagContrast } from 'culori';
|
|
35
37
|
|
|
36
38
|
const toOklch = converter('oklch');
|
|
37
39
|
|
|
@@ -50,7 +52,7 @@ function mixOklch(a: string, b: string, t: number): string {
|
|
|
50
52
|
return formatHex(fn(t)) ?? a;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
function coerceToHex(color: AcceptColorType): string {
|
|
55
|
+
function coerceToHex(color: AcceptColorType | ColorSeedInputType): string {
|
|
54
56
|
if (!color) return '#000';
|
|
55
57
|
if (typeof color === 'string') return color;
|
|
56
58
|
return color.base;
|
|
@@ -65,19 +67,114 @@ export function getOppositeColor(color: AcceptColorType): string {
|
|
|
65
67
|
return formatHex(rotated) ?? hex;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
+
/** Piso perceptual base↔estado de interação (razão WCAG) — espelho do core (ADR-012). */
|
|
71
|
+
const MIN_STATE_CONTRAST = 1.3;
|
|
72
|
+
|
|
73
|
+
/** ΔL OKLch JND — critério alternativo onde a razão WCAG satura (quase-preto). */
|
|
74
|
+
const STATE_DELTA_L_JND = 0.05;
|
|
75
|
+
|
|
76
|
+
/** Passo de L por iteração na correção de estado. */
|
|
77
|
+
const STATE_L_STEP = 0.04;
|
|
78
|
+
|
|
79
|
+
const contrastRatio = (a: string, b: string): number => {
|
|
80
|
+
const parsedA = parse(a);
|
|
81
|
+
const parsedB = parse(b);
|
|
82
|
+
if (!parsedA || !parsedB) return 1;
|
|
83
|
+
return wcagContrast(parsedA, parsedB);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const oklchLightness = (color: string): number | null => {
|
|
87
|
+
const parsed = toOklch(parse(color));
|
|
88
|
+
return parsed ? (parsed.l ?? 0) : null;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const isPerceptibleState = (base: string, candidate: string): boolean => {
|
|
92
|
+
if (contrastRatio(base, candidate) >= MIN_STATE_CONTRAST) return true;
|
|
93
|
+
const baseL = oklchLightness(base);
|
|
94
|
+
const candidateL = oklchLightness(candidate);
|
|
95
|
+
return baseL !== null && candidateL !== null && Math.abs(baseL - candidateL) >= STATE_DELTA_L_JND;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const isDarkSurface = (baseLight?: string): boolean => {
|
|
99
|
+
if (!baseLight) return false;
|
|
100
|
+
return contrastRatio('#fff', baseLight) > contrastRatio('#000', baseLight);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
function derivePerceptibleState(base: string, lighten: boolean, startL?: number): string | null {
|
|
104
|
+
const baseOklch = toOklch(parse(base));
|
|
105
|
+
if (!baseOklch) return null;
|
|
106
|
+
|
|
107
|
+
let oklch = { ...baseOklch, l: startL ?? baseOklch.l ?? 0 };
|
|
108
|
+
const step = lighten ? STATE_L_STEP : -STATE_L_STEP;
|
|
109
|
+
|
|
110
|
+
for (let i = 0; i < 25; i += 1) {
|
|
111
|
+
const nextL = Math.min(1, Math.max(0, (oklch.l ?? 0) + step));
|
|
112
|
+
if (nextL === (oklch.l ?? 0)) break; // clampado em 0/1
|
|
113
|
+
oklch = { ...oklch, l: nextL };
|
|
114
|
+
const hex = formatHex(oklch);
|
|
115
|
+
if (hex && contrastRatio(base, hex) >= MIN_STATE_CONTRAST) return hex;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return formatHex(oklch) ?? null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function perceptibleStateFor(base: string, surfaceIsDark: boolean, startL?: number): string | null {
|
|
122
|
+
const preferred = derivePerceptibleState(base, surfaceIsDark, startL);
|
|
123
|
+
if (preferred && contrastRatio(base, preferred) >= MIN_STATE_CONTRAST) return preferred;
|
|
124
|
+
|
|
125
|
+
const fallback = derivePerceptibleState(base, !surfaceIsDark);
|
|
126
|
+
if (fallback && contrastRatio(base, fallback) >= MIN_STATE_CONTRAST) return fallback;
|
|
127
|
+
|
|
128
|
+
return preferred ?? fallback;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Derive `{ base, dark, action, active, light }` via OKLch lerp, com piso
|
|
133
|
+
* perceptual mode-aware nos estados de interação — espelho byte-a-byte do
|
|
134
|
+
* core (ADR-012; parity.test.ts). Overrides por slot passam verbatim.
|
|
135
|
+
*/
|
|
136
|
+
export function mountSingleColor(
|
|
137
|
+
color: AcceptColorType | ColorPalleteOverrideInterface,
|
|
138
|
+
colors: ColorsInput,
|
|
139
|
+
): ColorPalleteInterface {
|
|
140
|
+
const override = typeof color === 'object' && color !== null ? color : undefined;
|
|
70
141
|
const base = coerceToHex(color);
|
|
71
142
|
const darken = colors.deepDark;
|
|
72
143
|
const lighten = colors.deepLight;
|
|
73
144
|
|
|
74
|
-
|
|
145
|
+
const derived: ColorPalleteInterface = {
|
|
75
146
|
base,
|
|
76
147
|
dark: mixOklch(base, darken!, 0.6),
|
|
77
148
|
action: mixOklch(base, darken!, 0.2),
|
|
78
149
|
active: mixOklch(base, lighten!, 0.6),
|
|
79
150
|
light: mixOklch(base, lighten!, 0.9),
|
|
80
151
|
};
|
|
152
|
+
|
|
153
|
+
if (parse(base)) {
|
|
154
|
+
const surfaceIsDark = isDarkSurface(colors.baseLight);
|
|
155
|
+
const actionCompliant = isPerceptibleState(base, derived.action);
|
|
156
|
+
|
|
157
|
+
if (!actionCompliant) {
|
|
158
|
+
derived.action = perceptibleStateFor(base, surfaceIsDark) ?? derived.action;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!isPerceptibleState(base, derived.active)) {
|
|
162
|
+
const startL = actionCompliant ? undefined : (oklchLightness(derived.action) ?? undefined);
|
|
163
|
+
derived.active = perceptibleStateFor(base, surfaceIsDark, startL) ?? derived.active;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (override) {
|
|
168
|
+
return {
|
|
169
|
+
base,
|
|
170
|
+
dark: override.dark ?? derived.dark,
|
|
171
|
+
action: override.action ?? derived.action,
|
|
172
|
+
active: override.active ?? derived.active,
|
|
173
|
+
light: override.light ?? derived.light,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return derived;
|
|
81
178
|
}
|
|
82
179
|
|
|
83
180
|
/** 12-step greyscale ramp — perceptually uniform via OKLch lerp. */
|
|
@@ -105,7 +202,9 @@ export function mountGreyscaleColors(colors: ColorsInput): Record<GrayscaleColor
|
|
|
105
202
|
export function mountNeutralColors(colors: ColorsInput): Record<NeutralColorsType, string> {
|
|
106
203
|
const lighter = colors.deepLight!;
|
|
107
204
|
const darker = colors.deepDark!;
|
|
108
|
-
|
|
205
|
+
// Slot pode ser override por slot (ADR-012) — a rampa ancora só no seed.
|
|
206
|
+
const primary =
|
|
207
|
+
typeof colors.primary === 'object' && colors.primary ? colors.primary.base : (colors.primary as string);
|
|
109
208
|
|
|
110
209
|
const interpolation = (n: number): number => (1 / 17) * (n - 1);
|
|
111
210
|
const n170 = mixOklch(primary, darker, 0.5);
|
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,
|