@apollion-dsi/tokens 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/build.cjs +6 -6
- package/lib/build.esm.js +6 -6
- package/lib/cli.mjs +8 -8
- package/lib/runtime/v1.cjs +1 -1
- package/lib/runtime/v1.esm.js +1 -1
- package/package.json +1 -1
- package/src/builders/colors.ts +38 -2
- package/src/ir.ts +3 -0
package/lib/build.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var an=Object.prototype.hasOwnProperty;var s=(e,n)=>M(e,"name",{value:n,configurable:!0});var cn=(e,n)=>{for(var o in n)M(e,o,{get:n[o],enumerable:!0})},ln=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of sn(n))!an.call(e,t)&&t!==o&&M(e,t,{get:()=>n[t],enumerable:!(r=tn(n,t))||r.enumerable});return e};var dn=e=>ln(M({},"__esModule",{value:!0}),e);var Nn={};cn(Nn,{build:()=>An,check:()=>Pn});module.exports=dn(Nn);var y=require("node:fs/promises"),rn=require("node:os"),T=require("node:path");var V=require("@apollion-dsi/core/themes/border"),le=require("@apollion-dsi/core/themes/colors"),N=require("@apollion-dsi/core/themes/depth"),I=require("@apollion-dsi/core/themes/font"),Z=require("@apollion-dsi/core/themes/spacing"),w=require("culori");var ce=require("@apollion-dsi/core/themes/dimension");function j({multiplier:e=.25,alias:n},o){let r=o!==void 0?ce.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(j,"createSpacing");var q={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function K(e){let n=Object.keys(q).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(K,"assertTokenMetaResolves");var un=(0,w.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(k,"kebab");function de(e){return e.split(".").map(k).join(".")}s(de,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}s($,"rawValue");function A(e,n){return Number(e.toFixed(n))||0}s(A,"round");function ee(e){let n=un((0,w.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[A(n.l,4),A(n.c,4),A(n.h??0,2)],r=(0,w.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:A(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ee,"toColorValue");var ue=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function v(e){let n=ue.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(v,"toDimensionValue");function h(e){return{type:"color",value:ee(e)}}s(h,"colorToken");function Q(e){let n={};for(let[o,r]of Object.entries(e))n[o]=h(r);return n}s(Q,"recordColorGroup");function pe(e){let n=(0,le.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=h(t);return o.neutral=Q(n.neutral),o}s(pe,"buildReadableTextGroup");var pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function fe(e){let n={};for(let o of pn){let r=e[o];n[o]={base:h(r.base),dark:h(r.dark),action:h(r.action),active:h(r.active),light:h(r.light)}}return n.grayscale=Q(e.grayscale),n.neutral=Q(e.neutral),n.baseDark=h(e.baseDark??"#000000"),n.baseLight=h(e.baseLight??"#ffffff"),n.deepDark=h(e.deepDark??"#000000"),n.deepLight=h(e.deepLight??"#ffffff"),n}s(fe,"buildColorPrimitives");function me(e){let n=j(Z.defaultInputSpacing,e),o={};for(let r of Object.keys(Z.defaultInputSpacing.alias))o[r]={type:"dimension",value:v(n(r))};return o}s(me,"buildSpacePrimitives");function ge(){let e={};for(let[n,o]of Object.entries(V.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:v(o)};return e}s(ge,"buildBorderWidthPrimitives");function fn(e,n){return{color:fe(e),space:me(n),borderWidth:ge()}}s(fn,"buildPrimitives");var ye={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},he={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function mn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(mn,"lookupPrimitive");function P(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?mn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ee(i)}}:h(i)}return r}s(P,"colorRefGroup");var be={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},gn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function yn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!b(t)&&i in t)t=t[i];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(yn,"lookupDimensionPrimitive");function ne(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?yn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:v(i)}}:{type:"dimension",value:v(i)}}return r}s(ne,"dimensionRefGroup");function Re(e){let n={},o={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderRadius))ue.test(a)?n[i]={type:"dimension",value:v(a)}:o[i]=a;let r=ne(V.defaultInputBorder.borderWidth,e,gn),t={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Re,"buildBorder");function Ie(e){let n=(0,I.createFont)(I.defaultInputFont,e),o={};for(let[c,d]of Object.entries(I.defaultInputFont.fontFamily)){let m=d.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,d]of Object.entries(n.fontSize))r[c]={type:"dimension",value:v(d)};let t={};for(let[c,d]of Object.entries(I.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${d}`,weight:d}};let i={};for(let[c,d]of Object.entries(I.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${d}`,number:d}};let a={letterSpacing:I.defaultInputFont.letterSpacing,textTransform:I.defaultInputFont.textTransform,fontStyle:I.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Ie,"buildFont");var hn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function bn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(hn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(d=>v(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ee(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(bn,"parseShadow");function ke(e){let n=(0,N.createDeth)(e),o={};for(let r of Object.keys(N.levelValues))o[r]={type:"shadow",value:bn(n(r))};return o}s(ke,"buildShadow");function L(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${k(t)}`:k(t);if(b(i)){o.add(a);let c=q[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=L(i,a,o)}return r}s(L,"decorateGroup");function Rn(e){let n=new Set,o=L(e.primitives,"",n),r=L(e.groups,"",n);return K(n),{...e,primitives:o,groups:r}}s(Rn,"decorateMeta");function B(e,n){return L(e,"",n)}s(B,"decorateSlice");function Se(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${k(r)}`:k(r);b(t)?o.add(i):Se(t,i,o)}}s(Se,"collectPaths");function xe(e){let n=new Set;for(let o of e)Se(o.groups,"",n);K(n)}s(xe,"assertSlicesMetaComplete");function Te(){let e=ge(),o=Re({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:B({"border-width":e,border:o.group},t),extensions:r}}s(Te,"buildBaseIR");function De(e){let n=Ie(e),o=new Set;return{groups:B({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(De,"buildFontIR");function ve(e,n){let o=fe(n),r=new Set;return{groups:B({color:o,bg:P(e.bg,n,ye),text:P(e.text,n,he),tx:pe(n),shadow:ke(n)},r),extensions:{}}}s(ve,"buildColorIR");function we(e,n){let o=me(n),r={space:o},t=new Set;return{groups:B({space:o,spacing:ne(e.spacing,r,be)},t),extensions:{}}}s(we,"buildSpacingIR");function In(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=fn(n,o.dimension),i=Re(t),a=Ie(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:P(e.bg,n,ye),text:P(e.text,n,he),tx:pe(n),spacing:ne(e.spacing,t,be),border:i.group,font:a.group,shadow:ke(n)},extensions:c};return Rn(d)}s(In,"buildIR");var Ce=In;var kn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Ve(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,k(r)];b(t)?o.push(` --apollion-${i.join("-")}: ${$(t.value)};`):Ve(t,i,o)}}s(Ve,"emitVars");function $e(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,k(r)];b(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(t.value)}; }`):$e(t,i,o)}}s($e,"emitProperties");function Ge(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[kn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),Ve(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),$e(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(
|
|
4
|
-
`}s(
|
|
5
|
-
`)}s(
|
|
6
|
-
`}s(
|
|
1
|
+
"use strict";var F=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var cn=Object.prototype.hasOwnProperty;var s=(e,n)=>F(e,"name",{value:n,configurable:!0});var ln=(e,n)=>{for(var o in n)F(e,o,{get:n[o],enumerable:!0})},dn=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of an(n))!cn.call(e,r)&&r!==o&&F(e,r,{get:()=>n[r],enumerable:!(t=sn(n,r))||t.enumerable});return e};var un=e=>dn(F({},"__esModule",{value:!0}),e);var Bn={};ln(Bn,{build:()=>Pn,check:()=>Nn});module.exports=un(Bn);var y=require("node:fs/promises"),rn=require("node:os"),D=require("node:path");var V=require("@apollion-dsi/core/themes/border"),de=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"),C=require("culori");var le=require("@apollion-dsi/core/themes/dimension");function M({multiplier:e=.25,alias:n},o){let t=o!==void 0?le.DIMENSION_MULTIPLIERS[o]:e;return(...r)=>r.map(i=>{let a=typeof i=="string"?n[i]:i;return`${t*a}rem`}).join(" ")}s(M,"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 pn=(0,C.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 ue(e){return e.split(".").map(k).join(".")}s(ue,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}s($,"rawValue");function L(e,n){return Number(e.toFixed(n))||0}s(L,"round");function ee(e){let n=pn((0,C.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[L(n.l,4),L(n.c,4),L(n.h??0,2)],t=(0,C.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:L(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}s(ee,"toColorValue");var pe=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function w(e){let n=pe.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(w,"toDimensionValue");function h(e){return{type:"color",value:ee(e)}}s(h,"colorToken");function Q(e){let n={};for(let[o,t]of Object.entries(e))n[o]=h(t);return n}s(Q,"recordColorGroup");function fe(e){let n=(0,de.createReadableTextLayer)(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=h(r);return o.neutral=Q(n.neutral),o}s(fe,"buildReadableTextGroup");var fn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function me(e){let n={};for(let o of fn){let t=e[o];n[o]={base:h(t.base),dark:h(t.dark),action:h(t.action),active:h(t.active),light:h(t.light),onLight:h(t.onLight)}}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(me,"buildColorPrimitives");function ge(e){let n=M(Z.defaultInputSpacing,e),o={};for(let t of Object.keys(Z.defaultInputSpacing.alias))o[t]={type:"dimension",value:w(n(t))};return o}s(ge,"buildSpacePrimitives");function ye(){let e={};for(let[n,o]of Object.entries(V.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:w(o)};return e}s(ye,"buildBorderWidthPrimitives");function mn(e,n){return{color:me(e),space:ge(n),borderWidth:ye()}}s(mn,"buildPrimitives");var he={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"},be={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function gn(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}s(gn,"lookupPrimitive");function j(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=o[r],c=a?gn(n,a):void 0;t[r]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ee(i)}}:h(i)}return t}s(j,"colorRefGroup");var Re={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},yn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function hn(e,n){let o=n.split("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let i of o.slice(1))if(r&&!b(r)&&i in r)r=r[i];else return;return r&&b(r)&&r.value.kind==="dimension"?r.value.raw:void 0}s(hn,"lookupDimensionPrimitive");function ne(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=o[r],c=a?hn(n,a):void 0;t[r]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:w(i)}}:{type:"dimension",value:w(i)}}return t}s(ne,"dimensionRefGroup");function Ie(e){let n={},o={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderRadius))pe.test(a)?n[i]={type:"dimension",value:w(a)}:o[i]=a;let t=ne(V.defaultInputBorder.borderWidth,e,yn),r={};for(let[i,a]of Object.entries(V.defaultInputBorder.borderStyle))r[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}s(Ie,"buildBorder");function ke(e){let n=(0,I.createFont)(I.defaultInputFont,e),o={};for(let[c,l]of Object.entries(I.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:w(l)};let r={};for(let[c,l]of Object.entries(I.defaultInputFont.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(I.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:I.defaultInputFont.letterSpacing,textTransform:I.defaultInputFont.textTransform,fontStyle:I.defaultInputFont.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:i},extensions:a}}s(ke,"buildFont");var bn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Rn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let t=n.match(bn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>w(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ee(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Rn,"parseShadow");function Se(e){let n=(0,N.createDeth)(e),o={};for(let t of Object.keys(N.levelValues))o[t]={type:"shadow",value:Rn(n(t))};return o}s(Se,"buildShadow");function P(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=n?`${n}.${k(r)}`:k(r);if(b(i)){o.add(a);let c=q[a];t[r]=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 t[r]=P(i,a,o)}return t}s(P,"decorateGroup");function In(e){let n=new Set,o=P(e.primitives,"",n),t=P(e.groups,"",n);return K(n),{...e,primitives:o,groups:t}}s(In,"decorateMeta");function _(e,n){return P(e,"",n)}s(_,"decorateSlice");function xe(e,n,o){for(let[t,r]of Object.entries(e)){let i=n?`${n}.${k(t)}`:k(t);b(r)?o.add(i):xe(r,i,o)}}s(xe,"collectPaths");function Te(e){let n=new Set;for(let o of e)xe(o.groups,"",n);K(n)}s(Te,"assertSlicesMetaComplete");function De(){let e=ye(),o=Ie({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:_({"border-width":e,border:o.group},r),extensions:t}}s(De,"buildBaseIR");function ve(e){let n=ke(e),o=new Set;return{groups:_({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(ve,"buildFontIR");function we(e,n){let o=me(n),t=new Set;return{groups:_({color:o,bg:j(e.bg,n,he),text:j(e.text,n,be),tx:fe(n),shadow:Se(n)},t),extensions:{}}}s(we,"buildColorIR");function Ce(e,n){let o=ge(n),t={space:o},r=new Set;return{groups:_({space:o,spacing:ne(e.spacing,t,Re)},r),extensions:{}}}s(Ce,"buildSpacingIR");function kn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=mn(n,o.dimension),i=Ie(r),a=ke(o.dimension),c={"com.apollion.variant":t,"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: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:j(e.bg,n,he),text:j(e.text,n,be),tx:fe(n),spacing:ne(e.spacing,r,Re),border:i.group,font:a.group,shadow:Se(n)},extensions:c};return In(l)}s(kn,"buildIR");var Ve=kn;var Sn="/* 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 i=[...n,k(t)];b(r)?o.push(` --apollion-${i.join("-")}: ${$(r.value)};`):$e(r,i,o)}}s($e,"emitVars");function Ge(e,n,o){for(let[t,r]of Object.entries(e)){let i=[...n,k(t)];b(r)?r.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(r.value)}; }`):Ge(r,i,o)}}s(Ge,"emitProperties");function Oe(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,i=[Sn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${t} dimension=${r} */`,"",":root {"),$e(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Ge(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
+
`)}s(Oe,"renderCss");function Ee(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(Ee,"colorValue");function G(e){return{value:e.value,unit:e.unit}}s(G,"dimensionValue");function xn(e){let n=e.shadow,o={color:Ee(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(xn,"shadowValue");function Tn(e){switch(e.kind){case"ref":return`{${ue(e.path)}}`;case"color":return Ee(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 xn(e)}}s(Tn,"projectValue");function Dn(e){let n={$value:Tn(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Dn,"projectToken");function oe(e){let n={};for(let[o,t]of Object.entries(e))n[k(o)]=b(t)?Dn(t):oe(t);return n}s(oe,"projectGroup");function B(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(B,"renderSet");function Ae(e){return B(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Ae,"renderBaseSet");function Fe(e,n,o,t){return B(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${t}. DTCG 2025.10.`)}s(Fe,"renderColorSet");function Me(e,n){return B(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Me,"renderSpacingSet");function Le(e,n){return B(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(Le,"renderFontSet");function je(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]}],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: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(i,null,2)}
|
|
4
|
+
`}s(je,"renderResolver");var vn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Pe(e,n,o){let t=" ".repeat(n);for(let[r,i]of Object.entries(e))b(i)?o.push(`${t}${JSON.stringify(r)}: ${JSON.stringify($(i.value))},`):(o.push(`${t}${r}: {`),Pe(i,n+1,o),o.push(`${t}},`))}s(Pe,"emitGroup");function Ne(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,i=[vn,`// Variant: brand=${n} mode=${o} surface=${t} dimension=${r}`,"","export const tokens = {"];return Pe(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
5
|
+
`)}s(Ne,"renderTs");var wn=["light","dark"],Cn=["positive","negative"],Vn=["compact","normal","spacious"];function H(e){let n=e.modes??wn,o=e.surfaces??Cn,t=e.dimensions??Vn,r=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of r)for(let l of n)for(let m of o)for(let v of t)i.push({brand:a,colors:c,mode:l,surface:m,dimension:v});return i}s(H,"expandVariants");function _e(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(_e,"variantName");var Be=require("node:crypto");function re(e){return(0,Be.createHash)("sha256").update(e).digest("hex")}s(re,"sha256");function ie(e){return re(te(e))}s(ie,"hashConfig");function te(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(te).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${te(e[t])}`).join(",")}}`}s(te,"stableStringify");function He(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(He,"detectGitCommit");function We(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(We,"buildEnv");function Je(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)}
|
|
6
|
+
`}s(Je,"serializeManifest");var $n="json/sets",Ue="json/resolver.json";function W(e){return`${$n}/${e}.json`}s(W,"setFile");function Gn(e,n,o){return`${e}.color.${n}.${o}`}s(Gn,"colorSetName");function On(e){return`spacing.${e}`}s(On,"spacingSetName");function En(e){return`font.${e}`}s(En,"fontSetName");function J(e,n){e.includes(n)||e.push(n)}s(J,"pushUnique");function ze(e){let n=H(e),o=[],t=[],r=[],i=[],a=new Set,c=[],l=new Set,m=[],v=new Set,O=[];for(let u of n){J(o,u.brand),J(t,u.mode),J(r,u.surface),J(i,u.dimension);let g=Gn(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=On(u.dimension);l.has(S)||(l.add(S),m.push({kind:"spacing",name:S,file:W(S),dimension:u.dimension}));let p=En(u.dimension);v.has(p)||(v.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:t,surface:r,dimension:i}}}s(ze,"planSets");var ce=require("@apollion-dsi/core/themes/foundation"),nn=require("@apollion-dsi/core/themes/semantic"),on=require("@apollion-dsi/core/themes/spacing"),tn=require("@apollion-dsi/core/themes/surface");var f=require("culori");var ae=(0,f.converter)("oklch");function d(e,n,o){let t=(0,f.parse)(e),r=(0,f.parse)(n);if(!t||!r)return e;let i=(0,f.interpolate)([t,r],"oklch");return(0,f.formatHex)(i(o))??e}s(d,"mixOklch");function An(e){return e?typeof e=="string"?e:e.base:"#000"}s(An,"coerceToHex");var U=1.3,Fn=.05,Xe=.04,T=s((e,n)=>{let o=(0,f.parse)(e),t=(0,f.parse)(n);return!o||!t?1:(0,f.wcagContrast)(o,t)},"contrastRatio"),se=s(e=>{let n=ae((0,f.parse)(e));return n?n.l??0:null},"oklchLightness"),Mn=4.5;function Ye(e,n,o=Mn){let t=(0,f.parse)(n),r=ae((0,f.parse)(e));if(!t||!r)return e;let i=T("#fff",n)>=T("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,f.formatHex)(r)??e,l=(0,f.parse)(c);if(l&&(0,f.wcagContrast)(l,t)>=o)return c;let m=Math.min(1,Math.max(0,(r.l??0)+i));if(m===(r.l??0))break;r={...r,l:m}}return(0,f.formatHex)(r)??e}s(Ye,"readableColor");var qe=s((e,n)=>{if(T(e,n)>=U)return!0;let o=se(e),t=se(n);return o!==null&&t!==null&&Math.abs(o-t)>=Fn},"isPerceptibleState"),Ln=s(e=>e?T("#fff",e)>T("#000",e):!1,"isDarkSurface");function Ke(e,n,o){let t=ae((0,f.parse)(e));if(!t)return null;let r={...t,l:o??t.l??0},i=n?Xe:-Xe;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(r.l??0)+i));if(c===(r.l??0))break;r={...r,l:c};let l=(0,f.formatHex)(r);if(l&&T(e,l)>=U)return l}return(0,f.formatHex)(r)??null}s(Ke,"derivePerceptibleState");function Ze(e,n,o){let t=Ke(e,n,o);if(t&&T(e,t)>=U)return t;let r=Ke(e,!n);return r&&T(e,r)>=U?r:t??r}s(Ze,"perceptibleStateFor");function R(e,n){let o=typeof e=="object"&&e!==null?e:void 0,t=An(e),r=n.deepDark,i=n.deepLight,a={base:t,dark:d(t,r,.6),action:d(t,r,.2),active:d(t,i,.6),light:d(t,i,.9),onLight:t};if((0,f.parse)(t)){let c=Ln(n.baseLight),l=qe(t,a.action);if(l||(a.action=Ze(t,c)??a.action),!qe(t,a.active)){let m=l?void 0:se(a.action)??void 0;a.active=Ze(t,c,m)??a.active}}if(a.onLight=Ye(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:t,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??Ye(c,l)}}return a}s(R,"mountSingleColor");function Qe(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)}}s(Qe,"mountGreyscaleColors");function en(e){let n=e.deepLight,o=e.deepDark,t=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,r=s(a=>1/17*(a-1),"interpolation"),i=d(t,o,.5);return{0:d(i,n,r(18)),5:d(i,n,r(17.5)),10:d(i,n,r(17)),20:d(i,n,r(16)),30:d(i,n,r(15)),40:d(i,n,r(14)),50:d(i,n,r(13)),60:d(i,n,r(12)),70:d(i,n,r(11)),80:d(i,n,r(10)),90:d(i,n,r(9)),100:d(i,n,r(8)),110:d(i,n,r(7)),120:d(i,n,r(6)),130:d(i,n,r(5)),140:d(i,n,r(4)),150:d(i,n,r(3)),160:d(i,n,r(2)),170:i,180:d(i,o,.25)}}s(en,"mountNeutralColors");function jn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:en(e),grayscale:Qe(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=on.defaultInputSpacing){let o=jn(e.colors),t=M(n,e.dimension),r=(0,nn.createSemantic)({colors:o,spacing:t}),i=(0,ce.createFoundation)(r);return e.surface==="negative"&&(i=(0,ce.createFoundation)((0,tn.invertForSurface)({semantic:r,colors:o},"negative").semantic)),{foundation:i,colors:o}}s(z,"buildVariantThemes");async function Pn(e){let{config:n,outDir:o,cwd:t=process.cwd(),verbose:r=!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,D.join)((0,rn.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(u,g)=>{await _n(c,u,g),l.push({path:u,sha256:re(g)}),r&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=ze(n),g=[],S=De();g.push(S),await m(u.base.file,Ae(S));for(let p of u.spacing){let x=i.find(A=>A.dimension===p.dimension),{foundation:X}=z(x),E=Ce(X,p.dimension);g.push(E),await m(p.file,Me(E,p.dimension))}for(let p of u.font){let x=ve(p.dimension);g.push(x),await m(p.file,Le(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),A=we(X,E);g.push(A),await m(p.file,Fe(A,p.brand,p.mode,p.surface))}Te(g),await m(Ue,je(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:g,colors:S}=z(u),p=Ve(g,S,u),x=_e(u);a.css&&await m(`css/${x}.css`,Oe(p)),a.ts&&await m(`ts/${x}.d.ts`,Ne(p))}let v={configHash:ie(n),files:l,gitCommit:He(t),buildEnv:We()},O=Je(v);return await(0,y.writeFile)((0,D.join)(c,"manifest.json"),O),await(0,y.rm)(o,{recursive:!0,force:!0}),await(0,y.mkdir)((0,D.dirname)(o),{recursive:!0}),await(0,y.rename)(c,o),r&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:v,outDir:o}}catch(l){throw await(0,y.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Pn,"build");async function Nn(e){let{config:n,outDir:o}=e,t;try{t=JSON.parse(await(0,y.readFile)((0,D.join)(o,"manifest.json"),"utf8"))}catch{return!1}return t.configHash===ie(n)}s(Nn,"check");async function _n(e,n,o){let t=(0,D.join)(e,n);await(0,y.mkdir)((0,D.dirname)(t),{recursive:!0}),await(0,y.writeFile)(t,o)}s(_n,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Ze=Object.defineProperty;var s=(e,n)=>Ze(e,"name",{value:n,configurable:!0}),Qe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as Ye,mkdtemp as _n,readFile as Hn,rename as Wn,rm as Xe,writeFile as qe}from"node:fs/promises";import{tmpdir as Jn}from"node:os";import{dirname as Ke,join as H}from"node:path";import{defaultInputBorder as E}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as nn}from"@apollion-dsi/core/themes/colors";import{createDeth as on,levelValues as rn}from"@apollion-dsi/core/themes/depth";import{createFont as tn,defaultInputFont as S}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as re}from"@apollion-dsi/core/themes/spacing";import{converter as sn,formatHex as an,parse as cn}from"culori";import{DIMENSION_MULTIPLIERS as en}from"@apollion-dsi/core/themes/dimension";function G({multiplier:e=.25,alias:n},o){let r=o!==void 0?en[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(G,"createSpacing");var U={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function z(e){let n=Object.keys(U).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(z,"assertTokenMetaResolves");var ln=sn("oklch");function y(e){return typeof e.type=="string"&&"value"in e}s(y,"isToken");function b(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(b,"kebab");function te(e){return e.split(".").map(b).join(".")}s(te,"kebabPath");function v(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(v,"rawValue");function O(e,n){return Number(e.toFixed(n))||0}s(O,"round");function Y(e){let n=ln(cn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[O(n.l,4),O(n.c,4),O(n.h??0,2)],r=an(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:O(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(Y,"toColorValue");var ie=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function x(e){let n=ie.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(x,"toDimensionValue");function g(e){return{type:"color",value:Y(e)}}s(g,"colorToken");function X(e){let n={};for(let[o,r]of Object.entries(e))n[o]=g(r);return n}s(X,"recordColorGroup");function se(e){let n=nn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=g(t);return o.neutral=X(n.neutral),o}s(se,"buildReadableTextGroup");var dn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ae(e){let n={};for(let o of dn){let r=e[o];n[o]={base:g(r.base),dark:g(r.dark),action:g(r.action),active:g(r.active),light:g(r.light)}}return n.grayscale=X(e.grayscale),n.neutral=X(e.neutral),n.baseDark=g(e.baseDark??"#000000"),n.baseLight=g(e.baseLight??"#ffffff"),n.deepDark=g(e.deepDark??"#000000"),n.deepLight=g(e.deepLight??"#ffffff"),n}s(ae,"buildColorPrimitives");function ce(e){let n=G(re,e),o={};for(let r of Object.keys(re.alias))o[r]={type:"dimension",value:x(n(r))};return o}s(ce,"buildSpacePrimitives");function le(){let e={};for(let[n,o]of Object.entries(E.borderWidth))e[n]={type:"dimension",value:x(o)};return e}s(le,"buildBorderWidthPrimitives");function un(e,n){return{color:ae(e),space:ce(n),borderWidth:le()}}s(un,"buildPrimitives");var de={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},ue={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function pn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(pn,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?pn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:Y(i)}}:g(i)}return r}s(F,"colorRefGroup");var pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},fn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function mn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!y(t)&&i in t)t=t[i];else return;return t&&y(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(mn,"lookupDimensionPrimitive");function q(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?mn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:x(i)}}:{type:"dimension",value:x(i)}}return r}s(q,"dimensionRefGroup");function fe(e){let n={},o={};for(let[i,a]of Object.entries(E.borderRadius))ie.test(a)?n[i]={type:"dimension",value:x(a)}:o[i]=a;let r=q(E.borderWidth,e,fn),t={};for(let[i,a]of Object.entries(E.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(fe,"buildBorder");function me(e){let n=tn(S,e),o={};for(let[c,d]of Object.entries(S.fontFamily)){let f=d.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,d]of Object.entries(n.fontSize))r[c]={type:"dimension",value:x(d)};let t={};for(let[c,d]of Object.entries(S.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${d}`,weight:d}};let i={};for(let[c,d]of Object.entries(S.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${d}`,number:d}};let a={letterSpacing:S.letterSpacing,textTransform:S.textTransform,fontStyle:S.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(me,"buildFont");var gn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function yn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(gn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(d=>x(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Y(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(yn,"parseShadow");function ge(e){let n=on(e),o={};for(let r of Object.keys(rn))o[r]={type:"shadow",value:yn(n(r))};return o}s(ge,"buildShadow");function M(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${b(t)}`:b(t);if(y(i)){o.add(a);let c=U[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=M(i,a,o)}return r}s(M,"decorateGroup");function hn(e){let n=new Set,o=M(e.primitives,"",n),r=M(e.groups,"",n);return z(n),{...e,primitives:o,groups:r}}s(hn,"decorateMeta");function j(e,n){return M(e,"",n)}s(j,"decorateSlice");function ye(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${b(r)}`:b(r);y(t)?o.add(i):ye(t,i,o)}}s(ye,"collectPaths");function he(e){let n=new Set;for(let o of e)ye(o.groups,"",n);z(n)}s(he,"assertSlicesMetaComplete");function be(){let e=le(),o=fe({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:j({"border-width":e,border:o.group},t),extensions:r}}s(be,"buildBaseIR");function Re(e){let n=me(e),o=new Set;return{groups:j({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Re,"buildFontIR");function Ie(e,n){let o=ae(n),r=new Set;return{groups:j({color:o,bg:F(e.bg,n,de),text:F(e.text,n,ue),tx:se(n),shadow:ge(n)},r),extensions:{}}}s(Ie,"buildColorIR");function ke(e,n){let o=ce(n),r={space:o},t=new Set;return{groups:j({space:o,spacing:q(e.spacing,r,pe)},t),extensions:{}}}s(ke,"buildSpacingIR");function bn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=un(n,o.dimension),i=fe(t),a=me(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,de),text:F(e.text,n,ue),tx:se(n),spacing:q(e.spacing,t,pe),border:i.group,font:a.group,shadow:ge(n)},extensions:c};return hn(d)}s(bn,"buildIR");var Se=bn;var Rn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function xe(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?o.push(` --apollion-${i.join("-")}: ${v(t.value)};`):xe(t,i,o)}}s(xe,"emitVars");function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,b(r)];y(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${v(t.value)}; }`):Te(t,i,o)}}s(Te,"emitProperties");function De(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[Rn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${t} */`,"",":root {"),xe(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Te(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(
|
|
4
|
-
`}s(
|
|
5
|
-
`)}s(
|
|
6
|
-
`}s(
|
|
1
|
+
var en=Object.defineProperty;var s=(e,n)=>en(e,"name",{value:n,configurable:!0}),nn=(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 Ke,mkdtemp as Wn,readFile as Jn,rename as Un,rm as qe,writeFile as Ze}from"node:fs/promises";import{tmpdir as zn}from"node:os";import{dirname as Qe,join as W}from"node:path";import{defaultInputBorder as A}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as tn}from"@apollion-dsi/core/themes/colors";import{createDeth as rn,levelValues as sn}from"@apollion-dsi/core/themes/depth";import{createFont as an,defaultInputFont as T}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as re}from"@apollion-dsi/core/themes/spacing";import{converter as cn,formatHex as ln,parse as dn}from"culori";import{DIMENSION_MULTIPLIERS as on}from"@apollion-dsi/core/themes/dimension";function O({multiplier:e=.25,alias:n},o){let t=o!==void 0?on[o]:e;return(...r)=>r.map(i=>{let a=typeof i=="string"?n[i]:i;return`${t*a}rem`}).join(" ")}s(O,"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 n=Object.keys(z).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(X,"assertTokenMetaResolves");var un=cn("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 ie(e){return e.split(".").map(b).join(".")}s(ie,"kebabPath");function v(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(v,"rawValue");function E(e,n){return Number(e.toFixed(n))||0}s(E,"round");function q(e){let n=un(dn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[E(n.l,4),E(n.c,4),E(n.h??0,2)],t=ln(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:E(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}s(q,"toColorValue");var se=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let n=se.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(D,"toDimensionValue");function g(e){return{type:"color",value:q(e)}}s(g,"colorToken");function Y(e){let n={};for(let[o,t]of Object.entries(e))n[o]=g(t);return n}s(Y,"recordColorGroup");function ae(e){let n=tn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=g(r);return o.neutral=Y(n.neutral),o}s(ae,"buildReadableTextGroup");var pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ce(e){let n={};for(let o of pn){let t=e[o];n[o]={base:g(t.base),dark:g(t.dark),action:g(t.action),active:g(t.active),light:g(t.light),onLight:g(t.onLight)}}return n.grayscale=Y(e.grayscale),n.neutral=Y(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(ce,"buildColorPrimitives");function le(e){let n=O(re,e),o={};for(let t of Object.keys(re.alias))o[t]={type:"dimension",value:D(n(t))};return o}s(le,"buildSpacePrimitives");function de(){let e={};for(let[n,o]of Object.entries(A.borderWidth))e[n]={type:"dimension",value:D(o)};return e}s(de,"buildBorderWidthPrimitives");function fn(e,n){return{color:ce(e),space:le(n),borderWidth:de()}}s(fn,"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 mn(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}s(mn,"lookupPrimitive");function F(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=o[r],c=a?mn(n,a):void 0;t[r]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:q(i)}}:g(i)}return t}s(F,"colorRefGroup");var fe={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("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let i of o.slice(1))if(r&&!y(r)&&i in r)r=r[i];else return;return r&&y(r)&&r.value.kind==="dimension"?r.value.raw:void 0}s(yn,"lookupDimensionPrimitive");function K(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=o[r],c=a?yn(n,a):void 0;t[r]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:D(i)}}:{type:"dimension",value:D(i)}}return t}s(K,"dimensionRefGroup");function me(e){let n={},o={};for(let[i,a]of Object.entries(A.borderRadius))se.test(a)?n[i]={type:"dimension",value:D(a)}:o[i]=a;let t=K(A.borderWidth,e,gn),r={};for(let[i,a]of Object.entries(A.borderStyle))r[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}s(me,"buildBorder");function ge(e){let n=an(T,e),o={};for(let[c,l]of Object.entries(T.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(T.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(T.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:T.letterSpacing,textTransform:T.textTransform,fontStyle:T.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:i},extensions:a}}s(ge,"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 t=n.match(hn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=s(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}}}s(bn,"parseShadow");function ye(e){let n=rn(e),o={};for(let t of Object.keys(sn))o[t]={type:"shadow",value:bn(n(t))};return o}s(ye,"buildShadow");function M(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=n?`${n}.${b(r)}`:b(r);if(y(i)){o.add(a);let c=z[a];t[r]=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 t[r]=M(i,a,o)}return t}s(M,"decorateGroup");function Rn(e){let n=new Set,o=M(e.primitives,"",n),t=M(e.groups,"",n);return X(n),{...e,primitives:o,groups:t}}s(Rn,"decorateMeta");function L(e,n){return M(e,"",n)}s(L,"decorateSlice");function he(e,n,o){for(let[t,r]of Object.entries(e)){let i=n?`${n}.${b(t)}`:b(t);y(r)?o.add(i):he(r,i,o)}}s(he,"collectPaths");function be(e){let n=new Set;for(let o of e)he(o.groups,"",n);X(n)}s(be,"assertSlicesMetaComplete");function Re(){let e=de(),o=me({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:L({"border-width":e,border:o.group},r),extensions:t}}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),t=new Set;return{groups:L({color:o,bg:F(e.bg,n,ue),text:F(e.text,n,pe),tx:ae(n),shadow:ye(n)},t),extensions:{}}}s(ke,"buildColorIR");function Se(e,n){let o=le(n),t={space:o},r=new Set;return{groups:L({space:o,spacing:K(e.spacing,t,fe)},r),extensions:{}}}s(Se,"buildSpacingIR");function In(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=fn(n,o.dimension),i=me(r),a=ge(o.dimension),c={"com.apollion.variant":t,"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: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:F(e.bg,n,ue),text:F(e.text,n,pe),tx:ae(n),spacing:K(e.spacing,r,fe),border:i.group,font:a.group,shadow:ye(n)},extensions:c};return Rn(l)}s(In,"buildIR");var xe=In;var kn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Te(e,n,o){for(let[t,r]of Object.entries(e)){let i=[...n,b(t)];y(r)?o.push(` --apollion-${i.join("-")}: ${v(r.value)};`):Te(r,i,o)}}s(Te,"emitVars");function De(e,n,o){for(let[t,r]of Object.entries(e)){let i=[...n,b(t)];y(r)?r.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${v(r.value)}; }`):De(r,i,o)}}s(De,"emitProperties");function ve(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,i=[kn,""];return i.push(`/* Variant: brand=${n} mode=${o} surface=${t} dimension=${r} */`,"",":root {"),Te(e.groups,[],i),i.push("}",""),i.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),De(e.groups,[],i),i.push("}",""),i.join(`
|
|
2
|
+
`)}s(ve,"renderCss");function we(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(we,"colorValue");function w(e){return{value:e.value,unit:e.unit}}s(w,"dimensionValue");function Sn(e){let n=e.shadow,o={color:we(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(Sn,"shadowValue");function xn(e){switch(e.kind){case"ref":return`{${ie(e.path)}}`;case"color":return we(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 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 Z(e){let n={};for(let[o,t]of Object.entries(e))n[b(o)]=y(t)?Tn(t):Z(t);return n}s(Z,"projectGroup");function j(e,n){let o={$description:n,...Z(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(j,"renderSet");function Ce(e){return j(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Ce,"renderBaseSet");function Ve(e,n,o,t){return j(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${t}. DTCG 2025.10.`)}s(Ve,"renderColorSet");function $e(e,n){return j(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s($e,"renderSpacingSet");function Ge(e,n){return j(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(Ge,"renderFontSet");function Oe(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]}],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: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(i,null,2)}
|
|
4
|
+
`}s(Oe,"renderResolver");var Dn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Ee(e,n,o){let t=" ".repeat(n);for(let[r,i]of Object.entries(e))y(i)?o.push(`${t}${JSON.stringify(r)}: ${JSON.stringify(v(i.value))},`):(o.push(`${t}${r}: {`),Ee(i,n+1,o),o.push(`${t}},`))}s(Ee,"emitGroup");function Ae(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,i=[Dn,`// Variant: brand=${n} mode=${o} surface=${t} dimension=${r}`,"","export const tokens = {"];return Ee(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
5
|
+
`)}s(Ae,"renderTs");var vn=["light","dark"],wn=["positive","negative"],Cn=["compact","normal","spacious"];function P(e){let n=e.modes??vn,o=e.surfaces??wn,t=e.dimensions??Cn,r=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of r)for(let l of n)for(let f of o)for(let x of t)i.push({brand:a,colors:c,mode:l,surface:f,dimension:x});return i}s(P,"expandVariants");function Fe(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Fe,"variantName");import{createHash as Vn}from"node:crypto";function ee(e){return Vn("sha256").update(e).digest("hex")}s(ee,"sha256");function ne(e){return ee(Q(e))}s(ne,"hashConfig");function Q(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Q).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Q(e[t])}`).join(",")}}`}s(Q,"stableStringify");function Me(e){try{let{execSync:n}=nn("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 Le(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Le,"buildEnv");function je(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)}
|
|
6
|
+
`}s(je,"serializeManifest");var $n="json/sets",Pe="json/resolver.json";function N(e){return`${$n}/${e}.json`}s(N,"setFile");function Gn(e,n,o){return`${e}.color.${n}.${o}`}s(Gn,"colorSetName");function On(e){return`spacing.${e}`}s(On,"spacingSetName");function En(e){return`font.${e}`}s(En,"fontSetName");function _(e,n){e.includes(n)||e.push(n)}s(_,"pushUnique");function Ne(e){let n=P(e),o=[],t=[],r=[],i=[],a=new Set,c=[],l=new Set,f=[],x=new Set,V=[];for(let u of n){_(o,u.brand),_(t,u.mode),_(r,u.surface),_(i,u.dimension);let m=Gn(u.brand,u.mode,u.surface);a.has(m)||(a.add(m),c.push({kind:"color",name:m,file:N(m),brand:u.brand,mode:u.mode,surface:u.surface}));let I=On(u.dimension);l.has(I)||(l.add(I),f.push({kind:"spacing",name:I,file:N(I),dimension:u.dimension}));let p=En(u.dimension);x.has(p)||(x.add(p),V.push({kind:"font",name:p,file:N(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:N("base")},spacing:f,font:V,color:c,modifiers:{brand:o,mode:t,surface:r,dimension:i}}}s(Ne,"planSets");import{createFoundation as Ye}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Nn}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as _n}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Bn}from"@apollion-dsi/core/themes/surface";import{converter as An,formatHex as C,interpolate as Fn,parse as R,wcagContrast as Ue}from"culori";var te=An("oklch");function d(e,n,o){let t=R(e),r=R(n);if(!t||!r)return e;let i=Fn([t,r],"oklch");return C(i(o))??e}s(d,"mixOklch");function Mn(e){return e?typeof e=="string"?e:e.base:"#000"}s(Mn,"coerceToHex");var B=1.3,Ln=.05,_e=.04,S=s((e,n)=>{let o=R(e),t=R(n);return!o||!t?1:Ue(o,t)},"contrastRatio"),oe=s(e=>{let n=te(R(e));return n?n.l??0:null},"oklchLightness"),jn=4.5;function Be(e,n,o=jn){let t=R(n),r=te(R(e));if(!t||!r)return e;let i=S("#fff",n)>=S("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=C(r)??e,l=R(c);if(l&&Ue(l,t)>=o)return c;let f=Math.min(1,Math.max(0,(r.l??0)+i));if(f===(r.l??0))break;r={...r,l:f}}return C(r)??e}s(Be,"readableColor");var He=s((e,n)=>{if(S(e,n)>=B)return!0;let o=oe(e),t=oe(n);return o!==null&&t!==null&&Math.abs(o-t)>=Ln},"isPerceptibleState"),Pn=s(e=>e?S("#fff",e)>S("#000",e):!1,"isDarkSurface");function We(e,n,o){let t=te(R(e));if(!t)return null;let r={...t,l:o??t.l??0},i=n?_e:-_e;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(r.l??0)+i));if(c===(r.l??0))break;r={...r,l:c};let l=C(r);if(l&&S(e,l)>=B)return l}return C(r)??null}s(We,"derivePerceptibleState");function Je(e,n,o){let t=We(e,n,o);if(t&&S(e,t)>=B)return t;let r=We(e,!n);return r&&S(e,r)>=B?r:t??r}s(Je,"perceptibleStateFor");function h(e,n){let o=typeof e=="object"&&e!==null?e:void 0,t=Mn(e),r=n.deepDark,i=n.deepLight,a={base:t,dark:d(t,r,.6),action:d(t,r,.2),active:d(t,i,.6),light:d(t,i,.9),onLight:t};if(R(t)){let c=Pn(n.baseLight),l=He(t,a.action);if(l||(a.action=Je(t,c)??a.action),!He(t,a.active)){let f=l?void 0:oe(a.action)??void 0;a.active=Je(t,c,f)??a.active}}if(a.onLight=Be(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:t,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??Be(c,l)}}return a}s(h,"mountSingleColor");function ze(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)}}s(ze,"mountGreyscaleColors");function Xe(e){let n=e.deepLight,o=e.deepDark,t=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,r=s(a=>1/17*(a-1),"interpolation"),i=d(t,o,.5);return{0:d(i,n,r(18)),5:d(i,n,r(17.5)),10:d(i,n,r(17)),20:d(i,n,r(16)),30:d(i,n,r(15)),40:d(i,n,r(14)),50:d(i,n,r(13)),60:d(i,n,r(12)),70:d(i,n,r(11)),80:d(i,n,r(10)),90:d(i,n,r(9)),100:d(i,n,r(8)),110:d(i,n,r(7)),120:d(i,n,r(6)),130:d(i,n,r(5)),140:d(i,n,r(4)),150:d(i,n,r(3)),160:d(i,n,r(2)),170:i,180:d(i,o,.25)}}s(Xe,"mountNeutralColors");function Hn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Xe(e),grayscale:ze(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(Hn,"composeColors");function H(e,n=_n){let o=Hn(e.colors),t=O(n,e.dimension),r=Nn({colors:o,spacing:t}),i=Ye(r);return e.surface==="negative"&&(i=Ye(Bn({semantic:r,colors:o},"negative").semantic)),{foundation:i,colors:o}}s(H,"buildVariantThemes");async function et(e){let{config:n,outDir:o,cwd:t=process.cwd(),verbose:r=!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 Wn(W(zn(),"apollion-tokens-"));try{let l=[],f=s(async(u,m)=>{await Xn(c,u,m),l.push({path:u,sha256:ee(m)}),r&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Ne(n),m=[],I=Re();m.push(I),await f(u.base.file,Ce(I));for(let p of u.spacing){let k=i.find(G=>G.dimension===p.dimension),{foundation:J}=H(k),$=Se(J,p.dimension);m.push($),await f(p.file,$e($,p.dimension))}for(let p of u.font){let k=Ie(p.dimension);m.push(k),await f(p.file,Ge(k,p.dimension))}for(let p of u.color){let k=i.find(U=>U.brand===p.brand&&U.mode===p.mode&&U.surface===p.surface),{foundation:J,colors:$}=H(k),G=ke(J,$);m.push(G),await f(p.file,Ve(G,p.brand,p.mode,p.surface))}be(m),await f(Pe,Oe(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:m,colors:I}=H(u),p=xe(m,I,u),k=Fe(u);a.css&&await f(`css/${k}.css`,ve(p)),a.ts&&await f(`ts/${k}.d.ts`,Ae(p))}let x={configHash:ne(n),files:l,gitCommit:Me(t),buildEnv:Le()},V=je(x);return await Ze(W(c,"manifest.json"),V),await qe(o,{recursive:!0,force:!0}),await Ke(Qe(o),{recursive:!0}),await Un(c,o),r&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:x,outDir:o}}catch(l){throw await qe(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(et,"build");async function nt(e){let{config:n,outDir:o}=e,t;try{t=JSON.parse(await Jn(W(o,"manifest.json"),"utf8"))}catch{return!1}return t.configHash===ne(n)}s(nt,"check");async function Xn(e,n,o){let t=W(e,n);await Ke(Qe(t),{recursive:!0}),await Ze(t,o)}s(Xn,"writeAt");export{et as build,nt as check};
|
package/lib/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var ln=Object.defineProperty;var i=(e,n)=>ln(e,"name",{value:n,configurable:!0}),dn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as po}from"node:fs/promises";import{resolve as ce}from"node:path";import{mkdir as nn,mkdtemp as Zn,readFile as Qn,rename as eo,rm as en,writeFile as on}from"node:fs/promises";import{tmpdir as no}from"node:os";import{dirname as tn,join as J}from"node:path";import{defaultInputBorder as P}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as pn}from"@apollion-dsi/core/themes/colors";import{createDeth as fn,levelValues as mn}from"@apollion-dsi/core/themes/depth";import{createFont as gn,defaultInputFont as w}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as le}from"@apollion-dsi/core/themes/spacing";import{converter as yn,formatHex as hn,parse as bn}from"culori";import{DIMENSION_MULTIPLIERS as un}from"@apollion-dsi/core/themes/dimension";function j({multiplier:e=.25,alias:n},o){let t=o!==void 0?un[o]:e;return(...r)=>r.map(s=>{let a=typeof s=="string"?n[s]:s;return`${t*a}rem`}).join(" ")}i(j,"createSpacing");var Y={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function K(e){let n=Object.keys(Y).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}i(K,"assertTokenMetaResolves");var Rn=yn("oklch");function b(e){return typeof e.type=="string"&&"value"in e}i(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}i(k,"kebab");function de(e){return e.split(".").map(k).join(".")}i(de,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}i($,"rawValue");function G(e,n){return Number(e.toFixed(n))||0}i(G,"round");function Q(e){let n=Rn(bn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[G(n.l,4),G(n.c,4),G(n.h??0,2)],t=hn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:G(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}i(Q,"toColorValue");var ue=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let n=ue.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}i(D,"toDimensionValue");function y(e){return{type:"color",value:Q(e)}}i(y,"colorToken");function Z(e){let n={};for(let[o,t]of Object.entries(e))n[o]=y(t);return n}i(Z,"recordColorGroup");function pe(e){let n=pn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=y(r);return o.neutral=Z(n.neutral),o}i(pe,"buildReadableTextGroup");var kn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function fe(e){let n={};for(let o of kn){let t=e[o];n[o]={base:y(t.base),dark:y(t.dark),action:y(t.action),active:y(t.active),light:y(t.light)}}return n.grayscale=Z(e.grayscale),n.neutral=Z(e.neutral),n.baseDark=y(e.baseDark??"#000000"),n.baseLight=y(e.baseLight??"#ffffff"),n.deepDark=y(e.deepDark??"#000000"),n.deepLight=y(e.deepLight??"#ffffff"),n}i(fe,"buildColorPrimitives");function me(e){let n=j(le,e),o={};for(let t of Object.keys(le.alias))o[t]={type:"dimension",value:D(n(t))};return o}i(me,"buildSpacePrimitives");function ge(){let e={};for(let[n,o]of Object.entries(P.borderWidth))e[n]={type:"dimension",value:D(o)};return e}i(ge,"buildBorderWidthPrimitives");function In(e,n){return{color:fe(e),space:me(n),borderWidth:ge()}}i(In,"buildPrimitives");var ye={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},he={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Sn(e,n){let o=e;for(let t of n.split(".").slice(1))if(o&&typeof o=="object"&&t in o)o=o[t];else return;return typeof o=="string"?o:void 0}i(Sn,"lookupPrimitive");function F(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?Sn(n,a):void 0;t[r]=a&&c===s?{type:"color",value:{kind:"ref",path:a,resolved:Q(s)}}:y(s)}return t}i(F,"colorRefGroup");var be={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},xn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function wn(e,n){let o=n.split("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let s of o.slice(1))if(r&&!b(r)&&s in r)r=r[s];else return;return r&&b(r)&&r.value.kind==="dimension"?r.value.raw:void 0}i(wn,"lookupDimensionPrimitive");function ee(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?wn(n,a):void 0;t[r]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:D(s)}}:{type:"dimension",value:D(s)}}return t}i(ee,"dimensionRefGroup");function Re(e){let n={},o={};for(let[s,a]of Object.entries(P.borderRadius))ue.test(a)?n[s]={type:"dimension",value:D(a)}:o[s]=a;let t=ee(P.borderWidth,e,xn),r={};for(let[s,a]of Object.entries(P.borderStyle))r[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}i(Re,"buildBorder");function ke(e){let n=gn(w,e),o={};for(let[c,l]of Object.entries(w.fontFamily)){let f=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:D(l)};let r={};for(let[c,l]of Object.entries(w.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let s={};for(let[c,l]of Object.entries(w.lineHeight))s[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:w.letterSpacing,textTransform:w.textTransform,fontStyle:w.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:s},extensions:a}}i(ke,"buildFont");var Dn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function vn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let t=n.match(Dn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=i(l=>D(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:Q(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}i(vn,"parseShadow");function Ie(e){let n=fn(e),o={};for(let t of Object.keys(mn))o[t]={type:"shadow",value:vn(n(t))};return o}i(Ie,"buildShadow");function M(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=n?`${n}.${k(r)}`:k(r);if(b(s)){o.add(a);let c=Y[a];t[r]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...s,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:s}else t[r]=M(s,a,o)}return t}i(M,"decorateGroup");function Tn(e){let n=new Set,o=M(e.primitives,"",n),t=M(e.groups,"",n);return K(n),{...e,primitives:o,groups:t}}i(Tn,"decorateMeta");function N(e,n){return M(e,"",n)}i(N,"decorateSlice");function Se(e,n,o){for(let[t,r]of Object.entries(e)){let s=n?`${n}.${k(t)}`:k(t);b(r)?o.add(s):Se(r,s,o)}}i(Se,"collectPaths");function xe(e){let n=new Set;for(let o of e)Se(o.groups,"",n);K(n)}i(xe,"assertSlicesMetaComplete");function we(){let e=ge(),o=Re({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:N({"border-width":e,border:o.group},r),extensions:t}}i(we,"buildBaseIR");function De(e){let n=ke(e),o=new Set;return{groups:N({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}i(De,"buildFontIR");function ve(e,n){let o=fe(n),t=new Set;return{groups:N({color:o,bg:F(e.bg,n,ye),text:F(e.text,n,he),tx:pe(n),shadow:Ie(n)},t),extensions:{}}}i(ve,"buildColorIR");function Te(e,n){let o=me(n),t={space:o},r=new Set;return{groups:N({space:o,spacing:ee(e.spacing,t,be)},r),extensions:{}}}i(Te,"buildSpacingIR");function Cn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=In(n,o.dimension),s=Re(r),a=ke(o.dimension),c={"com.apollion.variant":t,"com.apollion.font":a.extensions};Object.keys(s.extensions).length>0&&(c["com.apollion.border"]={radius:s.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:F(e.bg,n,ye),text:F(e.text,n,he),tx:pe(n),spacing:ee(e.spacing,r,be),border:s.group,font:a.group,shadow:Ie(n)},extensions:c};return Tn(l)}i(Cn,"buildIR");var Ce=Cn;var $n="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function $e(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,k(t)];b(r)?o.push(` --apollion-${s.join("-")}: ${$(r.value)};`):$e(r,s,o)}}i($e,"emitVars");function Ve(e,n,o){for(let[t,r]of Object.entries(e)){let s=[...n,k(t)];b(r)?r.type==="color"&&o.push(` @property --apollion-${s.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${$(r.value)}; }`):Ve(r,s,o)}}i(Ve,"emitProperties");function Oe(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[$n,""];return s.push(`/* Variant: brand=${n} mode=${o} surface=${t} dimension=${r} */`,"",":root {"),$e(e.groups,[],s),s.push("}",""),s.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Ve(e.groups,[],s),s.push("}",""),s.join(`
|
|
3
|
-
`)}i(Oe,"renderCss");function
|
|
4
|
-
`}i(
|
|
5
|
-
`}i(
|
|
6
|
-
`)}i(Ne,"renderTs");var
|
|
7
|
-
`}i(
|
|
8
|
-
`);throw new
|
|
9
|
-
${l}`,n)}return c.data}i(
|
|
2
|
+
var un=Object.defineProperty;var i=(e,n)=>un(e,"name",{value:n,configurable:!0}),pn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as mo}from"node:fs/promises";import{resolve as le}from"node:path";import{mkdir as tn,mkdtemp as eo,readFile as no,rename as oo,rm as on,writeFile as rn}from"node:fs/promises";import{tmpdir as to}from"node:os";import{dirname as sn,join as z}from"node:path";import{defaultInputBorder as F}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as mn}from"@apollion-dsi/core/themes/colors";import{createDeth as gn,levelValues as hn}from"@apollion-dsi/core/themes/depth";import{createFont as yn,defaultInputFont as v}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as de}from"@apollion-dsi/core/themes/spacing";import{converter as bn,formatHex as Rn,parse as kn}from"culori";import{DIMENSION_MULTIPLIERS as fn}from"@apollion-dsi/core/themes/dimension";function G({multiplier:e=.25,alias:n},o){let t=o!==void 0?fn[o]:e;return(...r)=>r.map(s=>{let a=typeof s=="string"?n[s]:s;return`${t*a}rem`}).join(" ")}i(G,"createSpacing");var K={"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(K).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(Z,"assertTokenMetaResolves");var In=bn("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 ue(e){return e.split(".").map(k).join(".")}i(ue,"kebabPath");function $(e){return e.kind==="ref"?e.resolved.raw:e.raw}i($,"rawValue");function P(e,n){return Number(e.toFixed(n))||0}i(P,"round");function ee(e){let n=In(kn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[P(n.l,4),P(n.c,4),P(n.h??0,2)],t=Rn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:P(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}i(ee,"toColorValue");var pe=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function T(e){let n=pe.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(T,"toDimensionValue");function h(e){return{type:"color",value:ee(e)}}i(h,"colorToken");function Q(e){let n={};for(let[o,t]of Object.entries(e))n[o]=h(t);return n}i(Q,"recordColorGroup");function fe(e){let n=mn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=h(r);return o.neutral=Q(n.neutral),o}i(fe,"buildReadableTextGroup");var Sn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function me(e){let n={};for(let o of Sn){let t=e[o];n[o]={base:h(t.base),dark:h(t.dark),action:h(t.action),active:h(t.active),light:h(t.light),onLight:h(t.onLight)}}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}i(me,"buildColorPrimitives");function ge(e){let n=G(de,e),o={};for(let t of Object.keys(de.alias))o[t]={type:"dimension",value:T(n(t))};return o}i(ge,"buildSpacePrimitives");function he(){let e={};for(let[n,o]of Object.entries(F.borderWidth))e[n]={type:"dimension",value:T(o)};return e}i(he,"buildBorderWidthPrimitives");function xn(e,n){return{color:me(e),space:ge(n),borderWidth:he()}}i(xn,"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"},be={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function wn(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(wn,"lookupPrimitive");function M(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:"color",value:{kind:"ref",path:a,resolved:ee(s)}}:h(s)}return t}i(M,"colorRefGroup");var Re={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Dn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function vn(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(vn,"lookupDimensionPrimitive");function ne(e,n,o){let t={};for(let[r,s]of Object.entries(e)){let a=o[r],c=a?vn(n,a):void 0;t[r]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:T(s)}}:{type:"dimension",value:T(s)}}return t}i(ne,"dimensionRefGroup");function ke(e){let n={},o={};for(let[s,a]of Object.entries(F.borderRadius))pe.test(a)?n[s]={type:"dimension",value:T(a)}:o[s]=a;let t=ne(F.borderWidth,e,Dn),r={};for(let[s,a]of Object.entries(F.borderStyle))r[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}i(ke,"buildBorder");function Ie(e){let n=yn(v,e),o={};for(let[c,l]of Object.entries(v.fontFamily)){let p=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:p,family:p}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:T(l)};let r={};for(let[c,l]of Object.entries(v.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let s={};for(let[c,l]of Object.entries(v.lineHeight))s[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:v.letterSpacing,textTransform:v.textTransform,fontStyle:v.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:s},extensions:a}}i(Ie,"buildFont");var Tn=/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 t=n.match(Tn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=i(l=>T(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ee(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}i(Cn,"parseShadow");function Se(e){let n=gn(e),o={};for(let t of Object.keys(hn))o[t]={type:"shadow",value:Cn(n(t))};return o}i(Se,"buildShadow");function L(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=K[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]=L(s,a,o)}return t}i(L,"decorateGroup");function $n(e){let n=new Set,o=L(e.primitives,"",n),t=L(e.groups,"",n);return Z(n),{...e,primitives:o,groups:t}}i($n,"decorateMeta");function N(e,n){return L(e,"",n)}i(N,"decorateSlice");function xe(e,n,o){for(let[t,r]of Object.entries(e)){let s=n?`${n}.${k(t)}`:k(t);b(r)?o.add(s):xe(r,s,o)}}i(xe,"collectPaths");function we(e){let n=new Set;for(let o of e)xe(o.groups,"",n);Z(n)}i(we,"assertSlicesMetaComplete");function De(){let e=he(),o=ke({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(De,"buildBaseIR");function ve(e){let n=Ie(e),o=new Set;return{groups:N({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}i(ve,"buildFontIR");function Te(e,n){let o=me(n),t=new Set;return{groups:N({color:o,bg:M(e.bg,n,ye),text:M(e.text,n,be),tx:fe(n),shadow:Se(n)},t),extensions:{}}}i(Te,"buildColorIR");function Ce(e,n){let o=ge(n),t={space:o},r=new Set;return{groups:N({space:o,spacing:ne(e.spacing,t,Re)},r),extensions:{}}}i(Ce,"buildSpacingIR");function Vn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=xn(n,o.dimension),s=ke(r),a=Ie(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:M(e.bg,n,ye),text:M(e.text,n,be),tx:fe(n),spacing:ne(e.spacing,r,Re),border:s.group,font:a.group,shadow:Se(n)},extensions:c};return $n(l)}i(Vn,"buildIR");var $e=Vn;var An="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Ve(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)};`):Ve(r,s,o)}}i(Ve,"emitVars");function Ae(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)}; }`):Ae(r,s,o)}}i(Ae,"emitProperties");function Oe(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[An,""];return s.push(`/* Variant: brand=${n} mode=${o} surface=${t} dimension=${r} */`,"",":root {"),Ve(e.groups,[],s),s.push("}",""),s.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Ae(e.groups,[],s),s.push("}",""),s.join(`
|
|
3
|
+
`)}i(Oe,"renderCss");function Ee(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(Ee,"colorValue");function V(e){return{value:e.value,unit:e.unit}}i(V,"dimensionValue");function On(e){let n=e.shadow,o={color:Ee(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(On,"shadowValue");function En(e){switch(e.kind){case"ref":return`{${ue(e.path)}}`;case"color":return Ee(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 On(e)}}i(En,"projectValue");function jn(e){let n={$value:En(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}i(jn,"projectToken");function oe(e){let n={};for(let[o,t]of Object.entries(e))n[k(o)]=b(t)?jn(t):oe(t);return n}i(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)}
|
|
4
|
+
`}i(_,"renderSet");function je(e){return _(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}i(je,"renderBaseSet");function Ge(e,n,o,t){return _(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${t}. DTCG 2025.10.`)}i(Ge,"renderColorSet");function Pe(e,n){return _(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}i(Pe,"renderSpacingSet");function Fe(e,n){return _(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}i(Fe,"renderFontSet");function Me(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(Me,"renderResolver");var Gn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Le(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}: {`),Le(s,n+1,o),o.push(`${t}},`))}i(Le,"emitGroup");function Ne(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,s=[Gn,`// Variant: brand=${n} mode=${o} surface=${t} dimension=${r}`,"","export const tokens = {"];return Le(e.groups,1,s),s.push("} as const;","","export type Tokens = typeof tokens;",""),s.join(`
|
|
6
|
+
`)}i(Ne,"renderTs");var Pn=["light","dark"],Fn=["positive","negative"],Mn=["compact","normal","spacious"];function B(e){let n=e.modes??Pn,o=e.surfaces??Fn,t=e.dimensions??Mn,r=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),s=[];for(let[a,c]of r)for(let l of n)for(let p of o)for(let D of t)s.push({brand:a,colors:c,mode:l,surface:p,dimension:D});return s}i(B,"expandVariants");function _e(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}i(_e,"variantName");import{createHash as Ln}from"node:crypto";function re(e){return Ln("sha256").update(e).digest("hex")}i(re,"sha256");function ie(e){return re(te(e))}i(ie,"hashConfig");function te(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(te).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${te(e[t])}`).join(",")}}`}i(te,"stableStringify");function Be(e){try{let{execSync:n}=pn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}i(Be,"detectGitCommit");function He(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}i(He,"buildEnv");function We(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(We,"serializeManifest");var Nn="json/sets",Ue="json/resolver.json";function H(e){return`${Nn}/${e}.json`}i(H,"setFile");function _n(e,n,o){return`${e}.color.${n}.${o}`}i(_n,"colorSetName");function Bn(e){return`spacing.${e}`}i(Bn,"spacingSetName");function Hn(e){return`font.${e}`}i(Hn,"fontSetName");function W(e,n){e.includes(n)||e.push(n)}i(W,"pushUnique");function Je(e){let n=B(e),o=[],t=[],r=[],s=[],a=new Set,c=[],l=new Set,p=[],D=new Set,O=[];for(let u of n){W(o,u.brand),W(t,u.mode),W(r,u.surface),W(s,u.dimension);let g=_n(u.brand,u.mode,u.surface);a.has(g)||(a.add(g),c.push({kind:"color",name:g,file:H(g),brand:u.brand,mode:u.mode,surface:u.surface}));let S=Bn(u.dimension);l.has(S)||(l.add(S),p.push({kind:"spacing",name:S,file:H(S),dimension:u.dimension}));let f=Hn(u.dimension);D.has(f)||(D.add(f),O.push({kind:"font",name:f,file:H(f),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:H("base")},spacing:p,font:O,color:c,modifiers:{brand:o,mode:t,surface:r,dimension:s}}}i(Je,"planSets");import{createFoundation as nn}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Yn}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Kn}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Zn}from"@apollion-dsi/core/themes/surface";import{converter as Wn,formatHex as A,interpolate as Un,parse as I,wcagContrast as Ze}from"culori";var ae=Wn("oklch");function d(e,n,o){let t=I(e),r=I(n);if(!t||!r)return e;let s=Un([t,r],"oklch");return A(s(o))??e}i(d,"mixOklch");function Jn(e){return e?typeof e=="string"?e:e.base:"#000"}i(Jn,"coerceToHex");var U=1.3,zn=.05,ze=.04,w=i((e,n)=>{let o=I(e),t=I(n);return!o||!t?1:Ze(o,t)},"contrastRatio"),se=i(e=>{let n=ae(I(e));return n?n.l??0:null},"oklchLightness"),Xn=4.5;function Xe(e,n,o=Xn){let t=I(n),r=ae(I(e));if(!t||!r)return e;let s=w("#fff",n)>=w("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=A(r)??e,l=I(c);if(l&&Ze(l,t)>=o)return c;let p=Math.min(1,Math.max(0,(r.l??0)+s));if(p===(r.l??0))break;r={...r,l:p}}return A(r)??e}i(Xe,"readableColor");var qe=i((e,n)=>{if(w(e,n)>=U)return!0;let o=se(e),t=se(n);return o!==null&&t!==null&&Math.abs(o-t)>=zn},"isPerceptibleState"),qn=i(e=>e?w("#fff",e)>w("#000",e):!1,"isDarkSurface");function Ye(e,n,o){let t=ae(I(e));if(!t)return null;let r={...t,l:o??t.l??0},s=n?ze:-ze;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=A(r);if(l&&w(e,l)>=U)return l}return A(r)??null}i(Ye,"derivePerceptibleState");function Ke(e,n,o){let t=Ye(e,n,o);if(t&&w(e,t)>=U)return t;let r=Ye(e,!n);return r&&w(e,r)>=U?r:t??r}i(Ke,"perceptibleStateFor");function R(e,n){let o=typeof e=="object"&&e!==null?e:void 0,t=Jn(e),r=n.deepDark,s=n.deepLight,a={base:t,dark:d(t,r,.6),action:d(t,r,.2),active:d(t,s,.6),light:d(t,s,.9),onLight:t};if(I(t)){let c=qn(n.baseLight),l=qe(t,a.action);if(l||(a.action=Ke(t,c)??a.action),!qe(t,a.active)){let p=l?void 0:se(a.action)??void 0;a.active=Ke(t,c,p)??a.active}}if(a.onLight=Xe(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:t,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??Xe(c,l)}}return a}i(R,"mountSingleColor");function Qe(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(Qe,"mountGreyscaleColors");function en(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(en,"mountNeutralColors");function Qn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:en(e),grayscale:Qe(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(Qn,"composeColors");function J(e,n=Kn){let o=Qn(e.colors),t=G(n,e.dimension),r=Yn({colors:o,spacing:t}),s=nn(r);return e.surface==="negative"&&(s=nn(Zn({semantic:r,colors:o},"negative").semantic)),{foundation:s,colors:o}}i(J,"buildVariantThemes");async function an(e){let{config:n,outDir:o,cwd:t=process.cwd(),verbose:r=!1}=e,s=B(n),a=n.output??{};if(s.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await eo(z(to(),"apollion-tokens-"));try{let l=[],p=i(async(u,g)=>{await ro(c,u,g),l.push({path:u,sha256:re(g)}),r&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Je(n),g=[],S=De();g.push(S),await p(u.base.file,je(S));for(let f of u.spacing){let x=s.find(j=>j.dimension===f.dimension),{foundation:q}=J(x),E=Ce(q,f.dimension);g.push(E),await p(f.file,Pe(E,f.dimension))}for(let f of u.font){let x=ve(f.dimension);g.push(x),await p(f.file,Fe(x,f.dimension))}for(let f of u.color){let x=s.find(Y=>Y.brand===f.brand&&Y.mode===f.mode&&Y.surface===f.surface),{foundation:q,colors:E}=J(x),j=Te(q,E);g.push(j),await p(f.file,Ge(j,f.brand,f.mode,f.surface))}we(g),await p(Ue,Me(n,u))}if(a.css||a.ts)for(let u of s){let{foundation:g,colors:S}=J(u),f=$e(g,S,u),x=_e(u);a.css&&await p(`css/${x}.css`,Oe(f)),a.ts&&await p(`ts/${x}.d.ts`,Ne(f))}let D={configHash:ie(n),files:l,gitCommit:Be(t),buildEnv:He()},O=We(D);return await rn(z(c,"manifest.json"),O),await on(o,{recursive:!0,force:!0}),await tn(sn(o),{recursive:!0}),await oo(c,o),r&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:D,outDir:o}}catch(l){throw await on(c,{recursive:!0,force:!0}).catch(()=>{}),l}}i(an,"build");async function cn(e){let{config:n,outDir:o}=e,t;try{t=JSON.parse(await no(z(o,"manifest.json"),"utf8"))}catch{return!1}return t.configHash===ie(n)}i(cn,"check");async function ro(e,n,o){let t=z(e,n);await tn(sn(t),{recursive:!0}),await rn(t,o)}i(ro,"writeAt");import{readFile as so}from"node:fs/promises";import{resolve as ao}from"node:path";import{createContext as co,Script as lo}from"node:vm";import{z as m}from"zod";var y=m.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),io=m.object({baseDark:m.string().optional(),baseLight:m.string().optional(),deepDark:y,deepLight:y,transparent:m.string().optional(),main:y.optional(),opposite:y.optional(),complementary:y.optional(),information:y.optional(),success:y.optional(),danger:y.optional(),warning:y.optional(),primary:y.optional(),secondary:y.optional(),tertiary:y.optional()}).passthrough(),ln=m.object({brands:m.record(m.string(),io).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 uo=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],po=1e3;var ce=class ce extends Error{constructor(o,t){super(o);this.configPath=t;this.name="ConfigLoadError"}};i(ce,"ConfigLoadError");var C=ce;async function dn(e){let n=ao(e.configPath),o=await so(n,"utf8");for(let l of uo)if(l.test(o))throw new C(`apollion.config: dynamic require/import not allowed (matched ${l}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,n);let t=o.replace(/(^|\n)\s*export\s+default\s+/,(l,p)=>`${p}__apollion_config_export = `);if(t===o)throw new C("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",n);let r={__apollion_config_export:void 0,console:fo(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:i(l=>l,"defineConfig")},s=co(r);try{new lo(t,{filename:n}).runInContext(s,{timeout:po})}catch(l){throw new C(`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 C("apollion.config: `export default` produced undefined.",n);let c=ln.safeParse(a);if(!c.success){let l=c.error.issues.map(p=>` ${p.path.join(".")||"(root)"}: ${p.message}`).join(`
|
|
8
|
+
`);throw new C(`apollion.config: schema validation failed \u2014
|
|
9
|
+
${l}`,n)}return c.data}i(dn,"loadConfig");function fo(){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(fo,"makeReadOnlyConsole");function go(e){let n=e.slice(2),o=n[0];o!=="build"&&X(`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]??X("--config needs a path");break;case"--out":r=n[++c]??X("--out needs a path");break;case"--check":s=!0;break;case"--verbose":a=!0;break;default:X(`Unknown flag "${l}"`)}}return{command:o,configPath:t,outDir:r,check:s,verbose:a}}i(go,"parseArgs");function X(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}i(X,"fail");async function ho(e){let n=le(e);if(n.endsWith(".json")){let o=await mo(n,"utf8");return JSON.parse(o)}return dn({configPath:n})}i(ho,"loadConfigFromPath");async function yo(){let e=go(process.argv),n=await ho(e.configPath);if(e.check){await cn({config:n,outDir:le(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 an({config:n,outDir:le(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${o.files.length} file(s) \u2014 configHash=${o.configHash.slice(0,12)}\u2026`)}i(yo,"main");yo().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 g=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var l=(e,t)=>g(e,"name",{value:t,configurable:!0});var R=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},F=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of E(t))!D.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(o=P(t,n))||o.enumerable});return e};var G=e=>F(g({},"__esModule",{value:!0}),e);var V={};R(V,{TOKENS_RUNTIME_API_VERSION:()=>U,createFoundation:()=>C.createFoundation,createSpacing:()=>O,getOppositeColor:()=>A,invertForSurface:()=>S.invertForSurface,mountGreyscaleColors:()=>N,mountNeutralColors:()=>M,mountSingleColor:()=>v});module.exports=G(V);var a=require("culori");var h=(0,a.converter)("oklch");function i(e,t,r){let o=(0,a.parse)(e),n=(0,a.parse)(t);if(!o||!n)return e;let c=(0,a.interpolate)([o,n],"oklch");return(0,a.formatHex)(c(r))??e}l(i,"mixOklch");function L(e){return e?typeof e=="string"?e:e.base:"#000"}l(L,"coerceToHex");function A(e){let t=L(e),r=h((0,a.parse)(t));if(!r)return t;let o={...r,h:((r.h??0)+180)%360};return(0,a.formatHex)(o)??t}l(A,"getOppositeColor");var d=1.3,j=.05,T=.04,f=l((e,t)=>{let r=(0,a.parse)(e),o=(0,a.parse)(t);return!r||!o?1:(0,a.wcagContrast)(r,o)},"contrastRatio"),y=l(e=>{let t=h((0,a.parse)(e));return t?t.l??0:null},"oklchLightness"),B=4.5;function x(e,t,r=B){let o=(0,a.parse)(t),n=h((0,a.parse)(e));if(!o||!n)return e;let c=f("#fff",t)>=f("#000",t)?.04:-.04;for(let s=0;s<25;s+=1){let u=(0,a.formatHex)(n)??e,p=(0,a.parse)(u);if(p&&(0,a.wcagContrast)(p,o)>=r)return u;let m=Math.min(1,Math.max(0,(n.l??0)+c));if(m===(n.l??0))break;n={...n,l:m}}return(0,a.formatHex)(n)??e}l(x,"readableColor");var I=l((e,t)=>{if(f(e,t)>=d)return!0;let r=y(e),o=y(t);return r!==null&&o!==null&&Math.abs(r-o)>=j},"isPerceptibleState"),H=l(e=>e?f("#fff",e)>f("#000",e):!1,"isDarkSurface");function b(e,t,r){let o=h((0,a.parse)(e));if(!o)return null;let n={...o,l:r??o.l??0},c=t?T:-T;for(let s=0;s<25;s+=1){let u=Math.min(1,Math.max(0,(n.l??0)+c));if(u===(n.l??0))break;n={...n,l:u};let p=(0,a.formatHex)(n);if(p&&f(e,p)>=d)return p}return(0,a.formatHex)(n)??null}l(b,"derivePerceptibleState");function k(e,t,r){let o=b(e,t,r);if(o&&f(e,o)>=d)return o;let n=b(e,!t);return n&&f(e,n)>=d?n:o??n}l(k,"perceptibleStateFor");function v(e,t){let r=typeof e=="object"&&e!==null?e:void 0,o=L(e),n=t.deepDark,c=t.deepLight,s={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,c,.6),light:i(o,c,.9),onLight:o};if((0,a.parse)(o)){let u=H(t.baseLight),p=I(o,s.action);if(p||(s.action=k(o,u)??s.action),!I(o,s.active)){let m=p?void 0:y(s.action)??void 0;s.active=k(o,u,m)??s.active}}if(s.onLight=x(s.action,s.light),r){let u=r.action??s.action,p=r.light??s.light;return{base:o,dark:r.dark??s.dark,action:u,active:r.active??s.active,light:p,onLight:r.onLight??x(u,p)}}return s}l(v,"mountSingleColor");function N(e){let t=e.deepLight,r=e.deepDark;return{0:t,5:i(t,r,.05),10:i(t,r,.1),20:i(t,r,.2),30:i(t,r,.3),40:i(t,r,.4),50:i(t,r,.5),60:i(t,r,.6),70:i(t,r,.7),80:i(t,r,.8),90:i(t,r,.9),100:i(t,r,1)}}l(N,"mountGreyscaleColors");function M(e){let t=e.deepLight,r=e.deepDark,o=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,n=l(s=>1/17*(s-1),"interpolation"),c=i(o,r,.5);return{0:i(c,t,n(18)),5:i(c,t,n(17.5)),10:i(c,t,n(17)),20:i(c,t,n(16)),30:i(c,t,n(15)),40:i(c,t,n(14)),50:i(c,t,n(13)),60:i(c,t,n(12)),70:i(c,t,n(11)),80:i(c,t,n(10)),90:i(c,t,n(9)),100:i(c,t,n(8)),110:i(c,t,n(7)),120:i(c,t,n(6)),130:i(c,t,n(5)),140:i(c,t,n(4)),150:i(c,t,n(3)),160:i(c,t,n(2)),170:c,180:i(c,r,.25)}}l(M,"mountNeutralColors");var _=require("@apollion-dsi/core/themes/dimension");function O({multiplier:e=.25,alias:t},r){let o=r!==void 0?_.DIMENSION_MULTIPLIERS[r]:e;return(...n)=>n.map(c=>{let s=typeof c=="string"?t[c]:c;return`${o*s}rem`}).join(" ")}l(O,"createSpacing");var C=require("@apollion-dsi/core/themes/foundation");var S=require("@apollion-dsi/core/themes/surface");var U="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 L=Object.defineProperty;var s=(e,t)=>L(e,"name",{value:t,configurable:!0});import{converter as A,formatHex as m,interpolate as v,parse as u,wcagContrast as b}from"culori";var h=A("oklch");function i(e,t,r){let o=u(e),n=u(t);if(!o||!n)return e;let c=v([o,n],"oklch");return m(c(r))??e}s(i,"mixOklch");function k(e){return e?typeof e=="string"?e:e.base:"#000"}s(k,"coerceToHex");function N(e){let t=k(e),r=h(u(t));if(!r)return t;let o={...r,h:((r.h??0)+180)%360};return m(o)??t}s(N,"getOppositeColor");var d=1.3,M=.05,C=.04,f=s((e,t)=>{let r=u(e),o=u(t);return!r||!o?1:b(r,o)},"contrastRatio"),y=s(e=>{let t=h(u(e));return t?t.l??0:null},"oklchLightness"),_=4.5;function S(e,t,r=_){let o=u(t),n=h(u(e));if(!o||!n)return e;let c=f("#fff",t)>=f("#000",t)?.04:-.04;for(let a=0;a<25;a+=1){let p=m(n)??e,l=u(p);if(l&&b(l,o)>=r)return p;let g=Math.min(1,Math.max(0,(n.l??0)+c));if(g===(n.l??0))break;n={...n,l:g}}return m(n)??e}s(S,"readableColor");var T=s((e,t)=>{if(f(e,t)>=d)return!0;let r=y(e),o=y(t);return r!==null&&o!==null&&Math.abs(r-o)>=M},"isPerceptibleState"),O=s(e=>e?f("#fff",e)>f("#000",e):!1,"isDarkSurface");function x(e,t,r){let o=h(u(e));if(!o)return null;let n={...o,l:r??o.l??0},c=t?C:-C;for(let a=0;a<25;a+=1){let p=Math.min(1,Math.max(0,(n.l??0)+c));if(p===(n.l??0))break;n={...n,l:p};let l=m(n);if(l&&f(e,l)>=d)return l}return m(n)??null}s(x,"derivePerceptibleState");function I(e,t,r){let o=x(e,t,r);if(o&&f(e,o)>=d)return o;let n=x(e,!t);return n&&f(e,n)>=d?n:o??n}s(I,"perceptibleStateFor");function P(e,t){let r=typeof e=="object"&&e!==null?e:void 0,o=k(e),n=t.deepDark,c=t.deepLight,a={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,c,.6),light:i(o,c,.9),onLight:o};if(u(o)){let p=O(t.baseLight),l=T(o,a.action);if(l||(a.action=I(o,p)??a.action),!T(o,a.active)){let g=l?void 0:y(a.action)??void 0;a.active=I(o,p,g)??a.active}}if(a.onLight=S(a.action,a.light),r){let p=r.action??a.action,l=r.light??a.light;return{base:o,dark:r.dark??a.dark,action:p,active:r.active??a.active,light:l,onLight:r.onLight??S(p,l)}}return a}s(P,"mountSingleColor");function E(e){let t=e.deepLight,r=e.deepDark;return{0:t,5:i(t,r,.05),10:i(t,r,.1),20:i(t,r,.2),30:i(t,r,.3),40:i(t,r,.4),50:i(t,r,.5),60:i(t,r,.6),70:i(t,r,.7),80:i(t,r,.8),90:i(t,r,.9),100:i(t,r,1)}}s(E,"mountGreyscaleColors");function D(e){let t=e.deepLight,r=e.deepDark,o=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,n=s(a=>1/17*(a-1),"interpolation"),c=i(o,r,.5);return{0:i(c,t,n(18)),5:i(c,t,n(17.5)),10:i(c,t,n(17)),20:i(c,t,n(16)),30:i(c,t,n(15)),40:i(c,t,n(14)),50:i(c,t,n(13)),60:i(c,t,n(12)),70:i(c,t,n(11)),80:i(c,t,n(10)),90:i(c,t,n(9)),100:i(c,t,n(8)),110:i(c,t,n(7)),120:i(c,t,n(6)),130:i(c,t,n(5)),140:i(c,t,n(4)),150:i(c,t,n(3)),160:i(c,t,n(2)),170:c,180:i(c,r,.25)}}s(D,"mountNeutralColors");import{DIMENSION_MULTIPLIERS as R}from"@apollion-dsi/core/themes/dimension";function F({multiplier:e=.25,alias:t},r){let o=r!==void 0?R[r]:e;return(...n)=>n.map(c=>{let a=typeof c=="string"?t[c]:c;return`${o*a}rem`}).join(" ")}s(F,"createSpacing");import{createFoundation as G}from"@apollion-dsi/core/themes/foundation";import{invertForSurface as j}from"@apollion-dsi/core/themes/surface";var W="v1";export{W as TOKENS_RUNTIME_API_VERSION,G as createFoundation,F as createSpacing,N as getOppositeColor,j as invertForSurface,E as mountGreyscaleColors,D as mountNeutralColors,P as mountSingleColor};
|
package/package.json
CHANGED
package/src/builders/colors.ts
CHANGED
|
@@ -88,6 +88,34 @@ const oklchLightness = (color: string): number | null => {
|
|
|
88
88
|
return parsed ? (parsed.l ?? 0) : null;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
/** Piso de contraste WCAG AA (texto normal) — espelho do core. */
|
|
92
|
+
const MIN_CONTRAST_AA = 4.5;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Ajusta o L OKLch de `color` até passar `minRatio` contra `background`,
|
|
96
|
+
* preservando hue/croma — **espelho byte-a-byte** de `readableColor` do core
|
|
97
|
+
* (`Colors.helpers.ts`; parity.test.ts). Usado para derivar o ink tonal
|
|
98
|
+
* `onLight` (APOLLION-CONTRAST-GUARANTEE).
|
|
99
|
+
*/
|
|
100
|
+
function readableColor(color: string, background: string, minRatio = MIN_CONTRAST_AA): string {
|
|
101
|
+
const bgParsed = parse(background);
|
|
102
|
+
let oklch = toOklch(parse(color));
|
|
103
|
+
if (!bgParsed || !oklch) return color;
|
|
104
|
+
|
|
105
|
+
const step = contrastRatio('#fff', background) >= contrastRatio('#000', background) ? 0.04 : -0.04;
|
|
106
|
+
|
|
107
|
+
for (let i = 0; i < 25; i += 1) {
|
|
108
|
+
const hex = formatHex(oklch) ?? color;
|
|
109
|
+
const parsed = parse(hex);
|
|
110
|
+
if (parsed && wcagContrast(parsed, bgParsed) >= minRatio) return hex;
|
|
111
|
+
const nextL = Math.min(1, Math.max(0, (oklch.l ?? 0) + step));
|
|
112
|
+
if (nextL === (oklch.l ?? 0)) break;
|
|
113
|
+
oklch = { ...oklch, l: nextL };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return formatHex(oklch) ?? color;
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
const isPerceptibleState = (base: string, candidate: string): boolean => {
|
|
92
120
|
if (contrastRatio(base, candidate) >= MIN_STATE_CONTRAST) return true;
|
|
93
121
|
const baseL = oklchLightness(base);
|
|
@@ -148,6 +176,8 @@ export function mountSingleColor(
|
|
|
148
176
|
action: mixOklch(base, darken!, 0.2),
|
|
149
177
|
active: mixOklch(base, lighten!, 0.6),
|
|
150
178
|
light: mixOklch(base, lighten!, 0.9),
|
|
179
|
+
// Placeholder — recalculado do `action` FINAL abaixo (espelho do core).
|
|
180
|
+
onLight: base,
|
|
151
181
|
};
|
|
152
182
|
|
|
153
183
|
if (parse(base)) {
|
|
@@ -164,13 +194,19 @@ export function mountSingleColor(
|
|
|
164
194
|
}
|
|
165
195
|
}
|
|
166
196
|
|
|
197
|
+
// Ink tonal AA por construção (APOLLION-CONTRAST-GUARANTEE) — espelho do core.
|
|
198
|
+
derived.onLight = readableColor(derived.action, derived.light);
|
|
199
|
+
|
|
167
200
|
if (override) {
|
|
201
|
+
const finalAction = override.action ?? derived.action;
|
|
202
|
+
const finalLight = override.light ?? derived.light;
|
|
168
203
|
return {
|
|
169
204
|
base,
|
|
170
205
|
dark: override.dark ?? derived.dark,
|
|
171
|
-
action:
|
|
206
|
+
action: finalAction,
|
|
172
207
|
active: override.active ?? derived.active,
|
|
173
|
-
light:
|
|
208
|
+
light: finalLight,
|
|
209
|
+
onLight: override.onLight ?? readableColor(finalAction, finalLight),
|
|
174
210
|
};
|
|
175
211
|
}
|
|
176
212
|
|
package/src/ir.ts
CHANGED
|
@@ -258,6 +258,9 @@ function buildColorPrimitives(colors: ColorsThemeInterface): IRGroup {
|
|
|
258
258
|
action: colorToken(palette.action),
|
|
259
259
|
active: colorToken(palette.active),
|
|
260
260
|
light: colorToken(palette.light),
|
|
261
|
+
// Par tonal AA (APOLLION-CONTRAST-GUARANTEE): ink legível sobre `light`,
|
|
262
|
+
// emitido como `--apollion-color-<paleta>-on-light`.
|
|
263
|
+
onLight: colorToken(palette.onLight),
|
|
261
264
|
};
|
|
262
265
|
}
|
|
263
266
|
out.grayscale = recordColorGroup(colors.grayscale);
|