@apollion-dsi/tokens 4.1.0 → 4.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/cli.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- var Re=Object.defineProperty;var s=(e,o)=>Re(e,"name",{value:o,configurable:!0}),Ie=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as ho}from"node:fs/promises";import{resolve as P}from"node:path";import{mkdir as pe,mkdtemp as to,readFile as ro,rename as io,rm as ue,writeFile as fe}from"node:fs/promises";import{tmpdir as so}from"node:os";import{dirname as de,join as S}from"node:path";import{defaultInputBorder as A}from"@apollion-dsi/core/themes/border";import{createDeth as xe,levelValues as we}from"@apollion-dsi/core/themes/depth";import{defaultInputFont as b}from"@apollion-dsi/core/themes/font";import{converter as De,formatHex as Ce,parse as Te}from"culori";var Se=De("oklch");function k(e){return typeof e.type=="string"&&"value"in e}s(k,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function H(e){return e.split(".").map(I).join(".")}s(H,"kebabPath");function x(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(x,"rawValue");function C(e,o){return Number(e.toFixed(o))||0}s(C,"round");function F(e){let o=Se(Te(e));if(!o)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let n=[C(o.l,4),C(o.c,4),C(o.h??0,2)],t=Ce(o)??"#000000";return o.alpha!==void 0&&o.alpha!==1?{kind:"color",raw:e,components:n,alpha:C(o.alpha,4),hex:t}:{kind:"color",raw:e,components:n,hex:t}}s(F,"toColorValue");var W=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function T(e){let o=W.exec(e.trim());if(o)return{kind:"dimension",raw:e,value:Number(o[1]),unit:o[2]};let n=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(n)?n:0,unit:"rem"}}s(T,"toDimensionValue");function m(e){return{type:"color",value:F(e)}}s(m,"colorToken");function _(e){let o={};for(let[n,t]of Object.entries(e))o[n]=m(t);return o}s(_,"recordColorGroup");var Ve=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function $e(e){let o={};for(let n of Ve){let t=e[n];o[n]={base:m(t.base),dark:m(t.dark),action:m(t.action),active:m(t.active),light:m(t.light)}}return o.grayscale=_(e.grayscale),o.neutral=_(e.neutral),o.baseDark=m(e.baseDark??"#000000"),o.baseLight=m(e.baseLight??"#ffffff"),o.deepDark=m(e.deepDark??"#000000"),o.deepLight=m(e.deepLight??"#ffffff"),o}s($e,"buildPrimitives");var ve={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},Oe={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function je(e,o){let n=e;for(let t of o.split(".").slice(1))if(n&&typeof n=="object"&&t in n)n=n[t];else return;return typeof n=="string"?n:void 0}s(je,"lookupPrimitive");function B(e,o,n){let t={};for(let[i,r]of Object.entries(e)){let a=n[i],l=a?je(o,a):void 0;t[i]=a&&l===r?{type:"color",value:{kind:"ref",path:a,resolved:F(r)}}:m(r)}return t}s(B,"colorRefGroup");function Ae(e){let o={};for(let[n,t]of Object.entries(e))o[n]={type:"dimension",value:T(t)};return o}s(Ae,"dimensionGroup");function Fe(){let e={},o={};for(let[i,r]of Object.entries(A.borderRadius))W.test(r)?e[i]={type:"dimension",value:T(r)}:o[i]=r;let n={};for(let[i,r]of Object.entries(A.borderWidth))n[i]={type:"dimension",value:T(r)};let t={};for(let[i,r]of Object.entries(A.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:r,style:r}};return{group:{radius:e,width:n,style:t},extensions:o}}s(Fe,"buildBorder");function Ee(){let e={};for(let[r,a]of Object.entries(b.fontFamily)){let l=a.replace(/;\s*$/,"").trim();e[r]={type:"fontFamily",value:{kind:"fontFamily",raw:l,family:l}}}let o={};for(let[r,a]of Object.entries(b.fontSize))o[r]={type:"dimension",value:{kind:"dimension",raw:`${a}px`,value:a,unit:"px"}};let n={};for(let[r,a]of Object.entries(b.fontWeight))n[r]={type:"fontWeight",value:{kind:"fontWeight",raw:`${a}`,weight:a}};let t={};for(let[r,a]of Object.entries(b.lineHeight))t[r]={type:"number",value:{kind:"number",raw:`${a}`,number:a}};let i={letterSpacing:b.letterSpacing,textTransform:b.textTransform,fontStyle:b.fontStyle};return{group:{family:e,size:o,weight:n,lineHeight:t},extensions:i}}s(Ee,"buildFont");var Ge=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Ne(e){let o=e.trim(),n=o.startsWith("inset");n&&(o=o.slice(5).trim());let t=o.match(Ge),i=t?t[0]:"#000000",a=(t?o.slice(0,t.index).trim():o).split(/\s+/).filter(Boolean),l=s(u=>T(a[u]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:F(i),offsetX:l(0),offsetY:l(1),blur:l(2),spread:l(3),inset:n}}}s(Ne,"parseShadow");function Le(e){let o=xe(e),n={};for(let t of Object.keys(we))n[t]={type:"shadow",value:Ne(o(t))};return n}s(Le,"buildShadow");function J(e,o,n){let t={brand:n.brand,mode:n.mode,surface:n.surface,dimension:n.dimension},i=Fe(),r=Ee(),a={"com.apollion.variant":t,"com.apollion.font":r.extensions};return Object.keys(i.extensions).length>0&&(a["com.apollion.border"]={radius:i.extensions}),{description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:$e(o),groups:{bg:B(e.bg,o,ve),text:B(e.text,o,Oe),spacing:Ae(e.spacing),border:i.group,font:r.group,shadow:Le(o)},extensions:a}}s(J,"buildIR");var Me="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function z(e,o,n){for(let[t,i]of Object.entries(e)){let r=[...o,I(t)];k(i)?n.push(` --apollion-${r.join("-")}: ${x(i.value)};`):z(i,r,n)}}s(z,"emitVars");function U(e,o,n){for(let[t,i]of Object.entries(e)){let r=[...o,I(t)];k(i)?i.type==="color"&&n.push(` @property --apollion-${r.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${x(i.value)}; }`):U(i,r,n)}}s(U,"emitProperties");function X(e){let{brand:o,mode:n,surface:t,dimension:i}=e.meta,r=[Me,""];return r.push(`/* Variant: brand=${o} mode=${n} surface=${t} dimension=${i} */`,"",":root {"),z(e.groups,[],r),r.push("}",""),r.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),U(e.groups,[],r),r.push("}",""),r.join(`
3
- `)}s(X,"renderCss");function Y(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(Y,"colorValue");function w(e){return{value:e.value,unit:e.unit}}s(w,"dimensionValue");function Pe(e){let o=e.shadow,n={color:Y(o.color),offsetX:w(o.offsetX),offsetY:w(o.offsetY),blur:w(o.blur),spread:w(o.spread)};return o.inset&&(n.inset=!0),n}s(Pe,"shadowValue");function _e(e){switch(e.kind){case"ref":return`{${H(e.path)}}`;case"color":return Y(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 Pe(e)}}s(_e,"projectValue");function Be(e){let o={$value:_e(e.value),$type:e.type};return e.description!==void 0&&(o.$description=e.description),e.deprecated!==void 0&&(o.$deprecated=e.deprecated),o}s(Be,"projectToken");function E(e){let o={};for(let[n,t]of Object.entries(e))o[I(n)]=k(t)?Be(t):E(t);return o}s(E,"projectGroup");function q(e){let o={$description:e.description,color:E(e.primitives),...E(e.groups),$extensions:e.extensions};return`${JSON.stringify(o,null,2)}
4
- `}s(q,"renderJson");var He="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Z(e,o,n){let t=" ".repeat(o);for(let[i,r]of Object.entries(e))k(r)?n.push(`${t}${JSON.stringify(i)}: ${JSON.stringify(x(r.value))},`):(n.push(`${t}${i}: {`),Z(r,o+1,n),n.push(`${t}},`))}s(Z,"emitGroup");function K(e){let{brand:o,mode:n,surface:t,dimension:i}=e.meta,r=[He,`// Variant: brand=${o} mode=${n} surface=${t} dimension=${i}`,"","export const tokens = {"];return Z(e.groups,1,r),r.push("} as const;","","export type Tokens = typeof tokens;",""),r.join(`
5
- `)}s(K,"renderTs");var We=["light","dark"],Je=["positive","negative"],ze=["compact","normal","spacious"];function Q(e){let o=e.modes??We,n=e.surfaces??Je,t=e.dimensions??ze,i=Object.entries(e.brands).sort(([a],[l])=>a.localeCompare(l)),r=[];for(let[a,l]of i)for(let u of o)for(let h of n)for(let $ of t)r.push({brand:a,colors:l,mode:u,surface:h,dimension:$});return r}s(Q,"expandVariants");function ee(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(ee,"variantName");import{createHash as Ue}from"node:crypto";function D(e){return Ue("sha256").update(e).digest("hex")}s(D,"sha256");function N(e){return D(G(e))}s(N,"hashConfig");function G(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(G).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${G(e[t])}`).join(",")}}`}s(G,"stableStringify");function oe(e){try{let{execSync:o}=Ie("node:child_process");return o("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(oe,"detectGitCommit");function ne(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(ne,"buildEnv");function te(e){let o=[...e.files].sort((t,i)=>t.path.localeCompare(i.path)),n={configHash:e.configHash,files:o,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(n,null,2)}
6
- `}s(te,"serializeManifest");import{createFoundation as ce}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Qe}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as eo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as oo}from"@apollion-dsi/core/themes/surface";import{converter as Xe,formatHex as Ye,interpolate as qe,parse as re}from"culori";var Bo=Xe("oklch");function c(e,o,n){let t=re(e),i=re(o);if(!t||!i)return e;let r=qe([t,i],"oklch");return Ye(r(n))??e}s(c,"mixOklch");function Ze(e){return e?typeof e=="string"?e:e.base:"#000"}s(Ze,"coerceToHex");function g(e,o){let n=Ze(e),t=o.deepDark,i=o.deepLight;return{base:n,dark:c(n,t,.6),action:c(n,t,.2),active:c(n,i,.6),light:c(n,i,.9)}}s(g,"mountSingleColor");function ie(e){let o=e.deepLight,n=e.deepDark;return{0:o,5:c(o,n,.05),10:c(o,n,.1),20:c(o,n,.2),30:c(o,n,.3),40:c(o,n,.4),50:c(o,n,.5),60:c(o,n,.6),70:c(o,n,.7),80:c(o,n,.8),90:c(o,n,.9),100:c(o,n,1)}}s(ie,"mountGreyscaleColors");function se(e){let o=e.deepLight,n=e.deepDark,t=e.primary,i=s(a=>1/17*(a-1),"interpolation"),r=c(t,n,.5);return{0:c(r,o,i(18)),5:c(r,o,i(17.5)),10:c(r,o,i(17)),20:c(r,o,i(16)),30:c(r,o,i(15)),40:c(r,o,i(14)),50:c(r,o,i(13)),60:c(r,o,i(12)),70:c(r,o,i(11)),80:c(r,o,i(10)),90:c(r,o,i(9)),100:c(r,o,i(8)),110:c(r,o,i(7)),120:c(r,o,i(6)),130:c(r,o,i(5)),140:c(r,o,i(4)),150:c(r,o,i(3)),160:c(r,o,i(2)),170:r,180:c(r,n,.25)}}s(se,"mountNeutralColors");import{DIMENSION_MULTIPLIERS as Ke}from"@apollion-dsi/core/themes/dimension";function ae({multiplier:e=.25,alias:o},n){let t=n!==void 0?Ke[n]:e;return(...i)=>i.map(r=>{let a=typeof r=="string"?o[r]:r;return`${t*a}rem`}).join(" ")}s(ae,"createSpacing");function no(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:se(e),grayscale:ie(e),main:g(e.main,e),opposite:g(e.opposite,e),complementary:g(e.complementary,e),danger:g(e.danger,e),information:g(e.information,e),success:g(e.success,e),warning:g(e.warning,e),primary:g(e.primary,e),secondary:g(e.secondary,e),tertiary:g(e.tertiary,e)}}s(no,"composeColors");function le(e,o=eo){let n=no(e.colors),t=ae(o,e.dimension),i=Qe({colors:n,spacing:t}),r=ce(i);return e.surface==="negative"&&(r=ce(oo({semantic:i,colors:n},"negative").semantic)),{foundation:r,colors:n}}s(le,"buildVariantThemes");async function me(e){let{config:o,outDir:n,cwd:t=process.cwd(),verbose:i=!1}=e,r=Q(o),a=o.output??{};if(r.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let l=await to(S(so(),"apollion-tokens-"));try{let u=[];for(let v of r){let{foundation:be,colors:ke}=le(v),O=J(be,ke,v),j=ee(v);if(a.css){let y=X(O),d=`css/${j}.css`;await L(l,d,y),u.push({path:d,sha256:D(y)}),i&&console.log(` \u2713 ${d}`)}if(a.json){let y=q(O),d=`json/${j}.json`;await L(l,d,y),u.push({path:d,sha256:D(y)}),i&&console.log(` \u2713 ${d}`)}if(a.ts){let y=K(O),d=`ts/${j}.d.ts`;await L(l,d,y),u.push({path:d,sha256:D(y)}),i&&console.log(` \u2713 ${d}`)}}let h={configHash:N(o),files:u,gitCommit:oe(t),buildEnv:ne()},$=te(h);return await fe(S(l,"manifest.json"),$),await ue(n,{recursive:!0,force:!0}),await pe(de(n),{recursive:!0}),await io(l,n),i&&console.log(`\u2713 ${u.length} files \u2192 ${n}`),{manifest:h,outDir:n}}catch(u){throw await ue(l,{recursive:!0,force:!0}).catch(()=>{}),u}}s(me,"build");async function ge(e){let{config:o,outDir:n}=e,t;try{t=JSON.parse(await ro(S(n,"manifest.json"),"utf8"))}catch{return!1}return t.configHash===N(o)}s(ge,"check");async function L(e,o,n){let t=S(e,o);await pe(de(t),{recursive:!0}),await fe(t,n)}s(L,"writeAt");import{readFile as co}from"node:fs/promises";import{resolve as lo}from"node:path";import{createContext as uo,Script as po}from"node:vm";import{z as p}from"zod";var f=p.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),ao=p.object({baseDark:p.string().optional(),baseLight:p.string().optional(),deepDark:f,deepLight:f,transparent:p.string().optional(),main:f.optional(),opposite:f.optional(),complementary:f.optional(),information:f.optional(),success:f.optional(),danger:f.optional(),warning:f.optional(),primary:f.optional(),secondary:f.optional(),tertiary:f.optional()}).passthrough(),he=p.object({brands:p.record(p.string(),ao).refine(e=>Object.keys(e).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:p.array(p.enum(["light","dark"])).optional(),surfaces:p.array(p.enum(["positive","negative"])).optional(),dimensions:p.array(p.enum(["compact","normal","spacious"])).optional(),output:p.object({runtime:p.boolean().optional(),css:p.boolean().optional(),json:p.boolean().optional(),ts:p.boolean().optional()}).passthrough().optional()}).passthrough();var fo=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],mo=1e3;var M=class M extends Error{constructor(n,t){super(n);this.configPath=t;this.name="ConfigLoadError"}};s(M,"ConfigLoadError");var R=M;async function ye(e){let o=lo(e.configPath),n=await co(o,"utf8");for(let u of fo)if(u.test(n))throw new R(`apollion.config: dynamic require/import not allowed (matched ${u}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,o);let t=n.replace(/(^|\n)\s*export\s+default\s+/,(u,h)=>`${h}__apollion_config_export = `);if(t===n)throw new R("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",o);let i={__apollion_config_export:void 0,console:go(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:s(u=>u,"defineConfig")},r=uo(i);try{new po(t,{filename:o}).runInContext(r,{timeout:mo})}catch(u){throw new R(`apollion.config: evaluation failed \u2014 ${u instanceof Error?u.message:String(u)}`,o)}let a=i.__apollion_config_export;if(a===void 0)throw new R("apollion.config: `export default` produced undefined.",o);let l=he.safeParse(a);if(!l.success){let u=l.error.issues.map(h=>` ${h.path.join(".")||"(root)"}: ${h.message}`).join(`
7
- `);throw new R(`apollion.config: schema validation failed \u2014
8
- ${u}`,o)}return l.data}s(ye,"loadConfig");function go(){return{log:s((...e)=>console.log("[apollion.config]",...e),"log"),warn:s((...e)=>console.warn("[apollion.config]",...e),"warn"),error:s((...e)=>console.error("[apollion.config]",...e),"error")}}s(go,"makeReadOnlyConsole");function yo(e){let o=e.slice(2),n=o[0];n!=="build"&&V(`Unknown command "${n??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let t="apollion.config.mjs",i="dist",r=!1,a=!1;for(let l=1;l<o.length;l++){let u=o[l];switch(u){case"--config":t=o[++l]??V("--config needs a path");break;case"--out":i=o[++l]??V("--out needs a path");break;case"--check":r=!0;break;case"--verbose":a=!0;break;default:V(`Unknown flag "${u}"`)}}return{command:n,configPath:t,outDir:i,check:r,verbose:a}}s(yo,"parseArgs");function V(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}s(V,"fail");async function bo(e){let o=P(e);if(o.endsWith(".json")){let n=await ho(o,"utf8");return JSON.parse(n)}return ye({configPath:o})}s(bo,"loadConfigFromPath");async function ko(){let e=yo(process.argv),o=await bo(e.configPath);if(e.check){await ge({config:o,outDir:P(e.outDir)})||(console.error("apollion-tokens: dist/ is stale or missing (configHash mismatch). Re-run `apollion-tokens build` without --check."),process.exit(1)),console.log("apollion-tokens: dist/ is up-to-date with config.");return}let{manifest:n}=await me({config:o,outDir:P(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${n.files.length} file(s) \u2014 configHash=${n.configHash.slice(0,12)}\u2026`)}s(ko,"main");ko().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
2
+ var Ye=Object.defineProperty;var s=(e,o)=>Ye(e,"name",{value:o,configurable:!0}),Ke=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as Xo}from"node:fs/promises";import{resolve as ne}from"node:path";import{mkdir as He,mkdtemp as Go,readFile as Po,rename as Mo,rm as Be,writeFile as We}from"node:fs/promises";import{tmpdir as Fo}from"node:os";import{dirname as Ue,join as L}from"node:path";import{defaultInputBorder as E}from"@apollion-dsi/core/themes/border";import{createDeth as Qe,levelValues as eo}from"@apollion-dsi/core/themes/depth";import{defaultInputFont as x}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as re}from"@apollion-dsi/core/themes/spacing";import{converter as oo,formatHex as no,parse as ro}from"culori";import{DIMENSION_MULTIPLIERS as Ze}from"@apollion-dsi/core/themes/dimension";function j({multiplier:e=.25,alias:o},n){let r=n!==void 0?Ze[n]:e;return(...i)=>i.map(t=>{let a=typeof t=="string"?o[t]:t;return`${r*a}rem`}).join(" ")}s(j,"createSpacing");var W={"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 U(e){let o=Object.keys(W).filter(n=>!e.has(n));if(o.length>0)throw new Error(`token-meta: ${o.length} stale TOKEN_META key(s) resolve to no IR node: ${o.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(U,"assertTokenMetaResolves");var to=oo("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function k(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(k,"kebab");function ie(e){return e.split(".").map(k).join(".")}s(ie,"kebabPath");function T(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(T,"rawValue");function A(e,o){return Number(e.toFixed(o))||0}s(A,"round");function J(e){let o=to(ro(e));if(!o)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let n=[A(o.l,4),A(o.c,4),A(o.h??0,2)],r=no(o)??"#000000";return o.alpha!==void 0&&o.alpha!==1?{kind:"color",raw:e,components:n,alpha:A(o.alpha,4),hex:r}:{kind:"color",raw:e,components:n,hex:r}}s(J,"toColorValue");var se=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function v(e){let o=se.exec(e.trim());if(o)return{kind:"dimension",raw:e,value:Number(o[1]),unit:o[2]};let n=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(n)?n:0,unit:"rem"}}s(v,"toDimensionValue");function h(e){return{type:"color",value:J(e)}}s(h,"colorToken");function te(e){let o={};for(let[n,r]of Object.entries(e))o[n]=h(r);return o}s(te,"recordColorGroup");var io=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ae(e){let o={};for(let n of io){let r=e[n];o[n]={base:h(r.base),dark:h(r.dark),action:h(r.action),active:h(r.active),light:h(r.light)}}return o.grayscale=te(e.grayscale),o.neutral=te(e.neutral),o.baseDark=h(e.baseDark??"#000000"),o.baseLight=h(e.baseLight??"#ffffff"),o.deepDark=h(e.deepDark??"#000000"),o.deepLight=h(e.deepLight??"#ffffff"),o}s(ae,"buildColorPrimitives");function ce(e){let o=j(re,e),n={};for(let r of Object.keys(re.alias))n[r]={type:"dimension",value:v(o(r))};return n}s(ce,"buildSpacePrimitives");function le(){let e={};for(let[o,n]of Object.entries(E.borderWidth))e[o]={type:"dimension",value:v(n)};return e}s(le,"buildBorderWidthPrimitives");function so(e,o){return{color:ae(e),space:ce(o),borderWidth:le()}}s(so,"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 ao(e,o){let n=e;for(let r of o.split(".").slice(1))if(n&&typeof n=="object"&&r in n)n=n[r];else return;return typeof n=="string"?n:void 0}s(ao,"lookupPrimitive");function G(e,o,n){let r={};for(let[i,t]of Object.entries(e)){let a=n[i],c=a?ao(o,a):void 0;r[i]=a&&c===t?{type:"color",value:{kind:"ref",path:a,resolved:J(t)}}:h(t)}return r}s(G,"colorRefGroup");var pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},co={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function lo(e,o){let n=o.split("."),r=n[0]==="border-width"?"borderWidth":n[0],i=e[r];for(let t of n.slice(1))if(i&&!b(i)&&t in i)i=i[t];else return;return i&&b(i)&&i.value.kind==="dimension"?i.value.raw:void 0}s(lo,"lookupDimensionPrimitive");function z(e,o,n){let r={};for(let[i,t]of Object.entries(e)){let a=n[i],c=a?lo(o,a):void 0;r[i]=a&&c===t?{type:"dimension",value:{kind:"ref",path:a,resolved:v(t)}}:{type:"dimension",value:v(t)}}return r}s(z,"dimensionRefGroup");function fe(e){let o={},n={};for(let[t,a]of Object.entries(E.borderRadius))se.test(a)?o[t]={type:"dimension",value:v(a)}:n[t]=a;let r=z(E.borderWidth,e,co),i={};for(let[t,a]of Object.entries(E.borderStyle))i[t]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:o,width:r,style:i},extensions:n}}s(fe,"buildBorder");function me(){let e={};for(let[t,a]of Object.entries(x.fontFamily)){let c=a.replace(/;\s*$/,"").trim();e[t]={type:"fontFamily",value:{kind:"fontFamily",raw:c,family:c}}}let o={};for(let[t,a]of Object.entries(x.fontSize))o[t]={type:"dimension",value:{kind:"dimension",raw:`${a}px`,value:a,unit:"px"}};let n={};for(let[t,a]of Object.entries(x.fontWeight))n[t]={type:"fontWeight",value:{kind:"fontWeight",raw:`${a}`,weight:a}};let r={};for(let[t,a]of Object.entries(x.lineHeight))r[t]={type:"number",value:{kind:"number",raw:`${a}`,number:a}};let i={letterSpacing:x.letterSpacing,textTransform:x.textTransform,fontStyle:x.fontStyle};return{group:{family:e,size:o,weight:n,lineHeight:r},extensions:i}}s(me,"buildFont");var uo=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function po(e){let o=e.trim(),n=o.startsWith("inset");n&&(o=o.slice(5).trim());let r=o.match(uo),i=r?r[0]:"#000000",a=(r?o.slice(0,r.index).trim():o).split(/\s+/).filter(Boolean),c=s(d=>v(a[d]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:J(i),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:n}}}s(po,"parseShadow");function ge(e){let o=Qe(e),n={};for(let r of Object.keys(eo))n[r]={type:"shadow",value:po(o(r))};return n}s(ge,"buildShadow");function P(e,o,n){let r={};for(let[i,t]of Object.entries(e)){let a=o?`${o}.${k(i)}`:k(i);if(b(t)){n.add(a);let c=W[a];r[i]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...t,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:t}else r[i]=P(t,a,n)}return r}s(P,"decorateGroup");function fo(e){let o=new Set,n=P(e.primitives,"",o),r=P(e.groups,"",o);return U(o),{...e,primitives:n,groups:r}}s(fo,"decorateMeta");function X(e,o){return P(e,"",o)}s(X,"decorateSlice");function ye(e,o,n){for(let[r,i]of Object.entries(e)){let t=o?`${o}.${k(r)}`:k(r);b(i)?n.add(t):ye(i,t,n)}}s(ye,"collectPaths");function he(e){let o=new Set;for(let n of e)ye(n.groups,"",o);U(o)}s(he,"assertSlicesMetaComplete");function be(){let e=le(),n=fe({borderWidth:e}),r=me(),i={"com.apollion.font":r.extensions};Object.keys(n.extensions).length>0&&(i["com.apollion.border"]={radius:n.extensions});let t=new Set;return{groups:X({"border-width":e,border:n.group,font:r.group},t),extensions:i}}s(be,"buildBaseIR");function Re(e,o){let n=ae(o),r=new Set;return{groups:X({color:n,bg:G(e.bg,o,de),text:G(e.text,o,ue),shadow:ge(o)},r),extensions:{}}}s(Re,"buildColorIR");function ke(e,o){let n=ce(o),r={space:n},i=new Set;return{groups:X({space:n,spacing:z(e.spacing,r,pe)},i),extensions:{}}}s(ke,"buildSpacingIR");function mo(e,o,n){let r={brand:n.brand,mode:n.mode,surface:n.surface,dimension:n.dimension},i=so(o,n.dimension),t=fe(i),a=me(),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(t.extensions).length>0&&(c["com.apollion.border"]={radius:t.extensions});let d={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:i,groups:{bg:G(e.bg,o,de),text:G(e.text,o,ue),spacing:z(e.spacing,i,pe),border:t.group,font:a.group,shadow:ge(o)},extensions:c};return fo(d)}s(mo,"buildIR");var Ie=mo;var go="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function xe(e,o,n){for(let[r,i]of Object.entries(e)){let t=[...o,k(r)];b(i)?n.push(` --apollion-${t.join("-")}: ${T(i.value)};`):xe(i,t,n)}}s(xe,"emitVars");function Se(e,o,n){for(let[r,i]of Object.entries(e)){let t=[...o,k(r)];b(i)?i.type==="color"&&n.push(` @property --apollion-${t.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${T(i.value)}; }`):Se(i,t,n)}}s(Se,"emitProperties");function we(e){let{brand:o,mode:n,surface:r,dimension:i}=e.meta,t=[go,""];return t.push(`/* Variant: brand=${o} mode=${n} surface=${r} dimension=${i} */`,"",":root {"),xe(e.groups,[],t),t.push("}",""),t.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Se(e.groups,[],t),t.push("}",""),t.join(`
3
+ `)}s(we,"renderCss");function De(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(De,"colorValue");function C(e){return{value:e.value,unit:e.unit}}s(C,"dimensionValue");function yo(e){let o=e.shadow,n={color:De(o.color),offsetX:C(o.offsetX),offsetY:C(o.offsetY),blur:C(o.blur),spread:C(o.spread)};return o.inset&&(n.inset=!0),n}s(yo,"shadowValue");function ho(e){switch(e.kind){case"ref":return`{${ie(e.path)}}`;case"color":return De(e);case"dimension":return C(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return yo(e)}}s(ho,"projectValue");function bo(e){let o={$value:ho(e.value),$type:e.type};return e.description!==void 0&&(o.$description=e.description),e.deprecated!==void 0&&(o.$deprecated=e.deprecated),o}s(bo,"projectToken");function q(e){let o={};for(let[n,r]of Object.entries(e))o[k(n)]=b(r)?bo(r):q(r);return o}s(q,"projectGroup");function Y(e,o){let n={$description:o,...q(e.groups)};return Object.keys(e.extensions).length>0&&(n.$extensions=e.extensions),`${JSON.stringify(n,null,2)}
4
+ `}s(Y,"renderSet");function ve(e){return Y(e,"Apollion DS \u2014 base set (axis-invariant: border + font). DTCG 2025.10.")}s(ve,"renderBaseSet");function Te(e,o,n,r){return Y(e,`Apollion DS \u2014 colour set. brand=${o} mode=${n} surface=${r}. DTCG 2025.10.`)}s(Te,"renderColorSet");function Ce(e,o){return Y(e,`Apollion DS \u2014 spacing set. dimension=${o}. DTCG 2025.10.`)}s(Ce,"renderSpacingSet");function $e(e,o){let{modifiers:n}=o,r=[{name:"brand",values:[...n.brand],default:n.brand[0]},{name:"mode",values:[...n.mode],default:n.mode[0]},{name:"surface",values:[...n.surface],default:n.surface[0]},{name:"dimension",values:[...n.dimension],default:n.dimension[0]}],t={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 set for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:o.base.name,source:o.base.file},...o.spacing.map(a=>({name:a.name,source:a.file})),...o.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[o.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(t,null,2)}
5
+ `}s($e,"renderResolver");var Ro="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Ve(e,o,n){let r=" ".repeat(o);for(let[i,t]of Object.entries(e))b(t)?n.push(`${r}${JSON.stringify(i)}: ${JSON.stringify(T(t.value))},`):(n.push(`${r}${i}: {`),Ve(t,o+1,n),n.push(`${r}},`))}s(Ve,"emitGroup");function Oe(e){let{brand:o,mode:n,surface:r,dimension:i}=e.meta,t=[Ro,`// Variant: brand=${o} mode=${n} surface=${r} dimension=${i}`,"","export const tokens = {"];return Ve(e.groups,1,t),t.push("} as const;","","export type Tokens = typeof tokens;",""),t.join(`
6
+ `)}s(Oe,"renderTs");var ko=["light","dark"],Io=["positive","negative"],xo=["compact","normal","spacious"];function M(e){let o=e.modes??ko,n=e.surfaces??Io,r=e.dimensions??xo,i=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),t=[];for(let[a,c]of i)for(let d of o)for(let m of n)for(let p of r)t.push({brand:a,colors:c,mode:d,surface:m,dimension:p});return t}s(M,"expandVariants");function je(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(je,"variantName");import{createHash as So}from"node:crypto";function Z(e){return So("sha256").update(e).digest("hex")}s(Z,"sha256");function Q(e){return Z(K(e))}s(Q,"hashConfig");function K(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(K).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${K(e[r])}`).join(",")}}`}s(K,"stableStringify");function Ae(e){try{let{execSync:o}=Ke("node:child_process");return o("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(Ae,"detectGitCommit");function Ee(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Ee,"buildEnv");function Ge(e){let o=[...e.files].sort((r,i)=>r.path.localeCompare(i.path)),n={configHash:e.configHash,files:o,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(n,null,2)}
7
+ `}s(Ge,"serializeManifest");var wo="json/sets",Pe="json/resolver.json";function ee(e){return`${wo}/${e}.json`}s(ee,"setFile");function Do(e,o,n){return`${e}.color.${o}.${n}`}s(Do,"colorSetName");function vo(e){return`spacing.${e}`}s(vo,"spacingSetName");function F(e,o){e.includes(o)||e.push(o)}s(F,"pushUnique");function Me(e){let o=M(e),n=[],r=[],i=[],t=[],a=new Set,c=[],d=new Set,m=[];for(let p of o){F(n,p.brand),F(r,p.mode),F(i,p.surface),F(t,p.dimension);let w=Do(p.brand,p.mode,p.surface);a.has(w)||(a.add(w),c.push({kind:"color",name:w,file:ee(w),brand:p.brand,mode:p.mode,surface:p.surface}));let f=vo(p.dimension);d.has(f)||(d.add(f),m.push({kind:"spacing",name:f,file:ee(f),dimension:p.dimension}))}return{base:{kind:"base",name:"base",file:ee("base")},spacing:m,color:c,modifiers:{brand:n,mode:r,surface:i,dimension:t}}}s(Me,"planSets");import{createFoundation as _e}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Oo}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as jo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Ao}from"@apollion-dsi/core/themes/surface";import{converter as To,formatHex as Co,interpolate as $o,parse as Fe}from"culori";var Gn=To("oklch");function l(e,o,n){let r=Fe(e),i=Fe(o);if(!r||!i)return e;let t=$o([r,i],"oklch");return Co(t(n))??e}s(l,"mixOklch");function Vo(e){return e?typeof e=="string"?e:e.base:"#000"}s(Vo,"coerceToHex");function R(e,o){let n=Vo(e),r=o.deepDark,i=o.deepLight;return{base:n,dark:l(n,r,.6),action:l(n,r,.2),active:l(n,i,.6),light:l(n,i,.9)}}s(R,"mountSingleColor");function Ne(e){let o=e.deepLight,n=e.deepDark;return{0:o,5:l(o,n,.05),10:l(o,n,.1),20:l(o,n,.2),30:l(o,n,.3),40:l(o,n,.4),50:l(o,n,.5),60:l(o,n,.6),70:l(o,n,.7),80:l(o,n,.8),90:l(o,n,.9),100:l(o,n,1)}}s(Ne,"mountGreyscaleColors");function Le(e){let o=e.deepLight,n=e.deepDark,r=e.primary,i=s(a=>1/17*(a-1),"interpolation"),t=l(r,n,.5);return{0:l(t,o,i(18)),5:l(t,o,i(17.5)),10:l(t,o,i(17)),20:l(t,o,i(16)),30:l(t,o,i(15)),40:l(t,o,i(14)),50:l(t,o,i(13)),60:l(t,o,i(12)),70:l(t,o,i(11)),80:l(t,o,i(10)),90:l(t,o,i(9)),100:l(t,o,i(8)),110:l(t,o,i(7)),120:l(t,o,i(6)),130:l(t,o,i(5)),140:l(t,o,i(4)),150:l(t,o,i(3)),160:l(t,o,i(2)),170:t,180:l(t,n,.25)}}s(Le,"mountNeutralColors");function Eo(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Le(e),grayscale:Ne(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(Eo,"composeColors");function N(e,o=jo){let n=Eo(e.colors),r=j(o,e.dimension),i=Oo({colors:n,spacing:r}),t=_e(i);return e.surface==="negative"&&(t=_e(Ao({semantic:i,colors:n},"negative").semantic)),{foundation:t,colors:n}}s(N,"buildVariantThemes");async function Je(e){let{config:o,outDir:n,cwd:r=process.cwd(),verbose:i=!1}=e,t=M(o),a=o.output??{};if(t.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await Go(L(Fo(),"apollion-tokens-"));try{let d=[],m=s(async(f,I)=>{await No(c,f,I),d.push({path:f,sha256:Z(I)}),i&&console.log(` \u2713 ${f}`)},"emit");if(a.json){let f=Me(o),I=[],$=be();I.push($),await m(f.base.file,ve($));for(let g of f.spacing){let D=t.find(O=>O.dimension===g.dimension),{foundation:B}=N(D),V=ke(B,g.dimension);I.push(V),await m(g.file,Ce(V,g.dimension))}for(let g of f.color){let D=t.find(H=>H.brand===g.brand&&H.mode===g.mode&&H.surface===g.surface),{foundation:B,colors:V}=N(D),O=Re(B,V);I.push(O),await m(g.file,Te(O,g.brand,g.mode,g.surface))}he(I),await m(Pe,$e(o,f))}if(a.css||a.ts)for(let f of t){let{foundation:I,colors:$}=N(f),g=Ie(I,$,f),D=je(f);a.css&&await m(`css/${D}.css`,we(g)),a.ts&&await m(`ts/${D}.d.ts`,Oe(g))}let p={configHash:Q(o),files:d,gitCommit:Ae(r),buildEnv:Ee()},w=Ge(p);return await We(L(c,"manifest.json"),w),await Be(n,{recursive:!0,force:!0}),await He(Ue(n),{recursive:!0}),await Mo(c,n),i&&console.log(`\u2713 ${d.length} files \u2192 ${n}`),{manifest:p,outDir:n}}catch(d){throw await Be(c,{recursive:!0,force:!0}).catch(()=>{}),d}}s(Je,"build");async function ze(e){let{config:o,outDir:n}=e,r;try{r=JSON.parse(await Po(L(n,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===Q(o)}s(ze,"check");async function No(e,o,n){let r=L(e,o);await He(Ue(r),{recursive:!0}),await We(r,n)}s(No,"writeAt");import{readFile as _o}from"node:fs/promises";import{resolve as Bo}from"node:path";import{createContext as Ho,Script as Wo}from"node:vm";import{z as u}from"zod";var y=u.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),Lo=u.object({baseDark:u.string().optional(),baseLight:u.string().optional(),deepDark:y,deepLight:y,transparent:u.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(),Xe=u.object({brands:u.record(u.string(),Lo).refine(e=>Object.keys(e).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:u.array(u.enum(["light","dark"])).optional(),surfaces:u.array(u.enum(["positive","negative"])).optional(),dimensions:u.array(u.enum(["compact","normal","spacious"])).optional(),output:u.object({runtime:u.boolean().optional(),css:u.boolean().optional(),json:u.boolean().optional(),ts:u.boolean().optional()}).passthrough().optional()}).passthrough();var Uo=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],Jo=1e3;var oe=class oe extends Error{constructor(n,r){super(n);this.configPath=r;this.name="ConfigLoadError"}};s(oe,"ConfigLoadError");var S=oe;async function qe(e){let o=Bo(e.configPath),n=await _o(o,"utf8");for(let d of Uo)if(d.test(n))throw new S(`apollion.config: dynamic require/import not allowed (matched ${d}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,o);let r=n.replace(/(^|\n)\s*export\s+default\s+/,(d,m)=>`${m}__apollion_config_export = `);if(r===n)throw new S("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",o);let i={__apollion_config_export:void 0,console:zo(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:s(d=>d,"defineConfig")},t=Ho(i);try{new Wo(r,{filename:o}).runInContext(t,{timeout:Jo})}catch(d){throw new S(`apollion.config: evaluation failed \u2014 ${d instanceof Error?d.message:String(d)}`,o)}let a=i.__apollion_config_export;if(a===void 0)throw new S("apollion.config: `export default` produced undefined.",o);let c=Xe.safeParse(a);if(!c.success){let d=c.error.issues.map(m=>` ${m.path.join(".")||"(root)"}: ${m.message}`).join(`
8
+ `);throw new S(`apollion.config: schema validation failed \u2014
9
+ ${d}`,o)}return c.data}s(qe,"loadConfig");function zo(){return{log:s((...e)=>console.log("[apollion.config]",...e),"log"),warn:s((...e)=>console.warn("[apollion.config]",...e),"warn"),error:s((...e)=>console.error("[apollion.config]",...e),"error")}}s(zo,"makeReadOnlyConsole");function qo(e){let o=e.slice(2),n=o[0];n!=="build"&&_(`Unknown command "${n??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let r="apollion.config.mjs",i="dist",t=!1,a=!1;for(let c=1;c<o.length;c++){let d=o[c];switch(d){case"--config":r=o[++c]??_("--config needs a path");break;case"--out":i=o[++c]??_("--out needs a path");break;case"--check":t=!0;break;case"--verbose":a=!0;break;default:_(`Unknown flag "${d}"`)}}return{command:n,configPath:r,outDir:i,check:t,verbose:a}}s(qo,"parseArgs");function _(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}s(_,"fail");async function Yo(e){let o=ne(e);if(o.endsWith(".json")){let n=await Xo(o,"utf8");return JSON.parse(n)}return qe({configPath:o})}s(Yo,"loadConfigFromPath");async function Ko(){let e=qo(process.argv),o=await Yo(e.configPath);if(e.check){await ze({config:o,outDir:ne(e.outDir)})||(console.error("apollion-tokens: dist/ is stale or missing (configHash mismatch). Re-run `apollion-tokens build` without --check."),process.exit(1)),console.log("apollion-tokens: dist/ is up-to-date with config.");return}let{manifest:n}=await Je({config:o,outDir:ne(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${n.files.length} file(s) \u2014 configHash=${n.configHash.slice(0,12)}\u2026`)}s(Ko,"main");Ko().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `@apollion-dsi/tokens/runtime/v1` — Versioned API surface for v4+.
3
+ *
4
+ * **Status:** S4 Strangler Fig builders (ADR-006 §6 S4).
5
+ *
6
+ * This is the ONLY public entry of `@apollion-dsi/tokens`. Bumping to `/v2`
7
+ * adds new exports without breaking `/v1` (versioned API decoupling per
8
+ * ADR-006 §3.3). Consumers import:
9
+ *
10
+ * ```ts
11
+ * import {
12
+ * mountSingleColor, mountGreyscaleColors, mountNeutralColors, getOppositeColor,
13
+ * createSpacing,
14
+ * createFoundation, invertForSurface,
15
+ * TOKENS_RUNTIME_API_VERSION,
16
+ * } from '@apollion-dsi/tokens/runtime/v1';
17
+ * ```
18
+ *
19
+ * **Strangler Fig:** `colors` + `spacing` builders are DUPLICATES of core's
20
+ * implementation (validated bit-equivalent via parity tests). `foundation`
21
+ * + `surface` are re-exports from core via stable subpaths. Both classes
22
+ * coexist orthogonally — core remains SSOT until PRD-003 post-v4
23
+ * consolidation.
24
+ *
25
+ * @see ADR-006 §3.3 (versioned API + decoupling B2 mitigation)
26
+ * @see ADR-006 §6 S1 + §6 S4
27
+ * @see PRD-002 §S4
28
+ */
29
+ export declare const TOKENS_RUNTIME_API_VERSION: "v1";
30
+ export { getOppositeColor, mountGreyscaleColors, mountNeutralColors, mountSingleColor } from '../builders/colors';
31
+ export { createSpacing } from '../builders/spacing';
32
+ export { createFoundation } from '../builders/foundation';
33
+ export type { FoundationLayer } from '../builders/foundation';
34
+ export { invertForSurface } from '../builders/surface';
35
+ export type { SurfaceMode } from '../builders/surface';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollion-dsi/tokens",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "Apollion Design System — Framework-agnostic design tokens",
5
5
  "homepage": "https://github.com/apollion-ds/apollion",
6
6
  "license": "MIT",
@@ -33,6 +33,8 @@
33
33
  "require": "./lib/config-loader.cjs"
34
34
  },
35
35
  "./dist/css/*": "./dist/css/*",
36
+ "./dist/json/resolver.json": "./dist/json/resolver.json",
37
+ "./dist/json/sets/*": "./dist/json/sets/*",
36
38
  "./dist/json/*": "./dist/json/*",
37
39
  "./dist/ts/*": "./dist/ts/*",
38
40
  "./dist/manifest.json": "./dist/manifest.json"
@@ -59,7 +61,7 @@
59
61
  "test": "jest --passWithNoTests",
60
62
  "coverage": "jest --coverage --passWithNoTests",
61
63
  "validate": "./scripts/validate.sh",
62
- "release": "yarn build && changeset publish"
64
+ "release": "yarn build && yarn run -T changeset publish"
63
65
  },
64
66
  "peerDependencies": {
65
67
  "@apollion-dsi/core": ">=4.0.0"
@@ -69,8 +71,8 @@
69
71
  "zod": "4.4.3"
70
72
  },
71
73
  "devDependencies": {
72
- "@apollion-dsi/core": "workspace:*",
73
- "@apollion-dsi/eslint-config": "0.7.0",
74
+ "@apollion-dsi/core": "4.3.0",
75
+ "@apollion-dsi/eslint-config": "0.8.0",
74
76
  "@types/culori": "4.0.1",
75
77
  "@types/jest": "30.0.0",
76
78
  "@types/node": "25.7.0",
@@ -81,4 +83,4 @@
81
83
  "ts-jest": "^29.4.11",
82
84
  "typescript": "6.0.3"
83
85
  }
84
- }
86
+ }
package/src/build.ts CHANGED
@@ -7,9 +7,16 @@
7
7
  * 3. Atomic `rename(tmpdir, outDir)` — if step 1 or 2 throws, `dist/` keeps
8
8
  * its previous state. Never partial.
9
9
  *
10
+ * **Output surfaces (R5):**
11
+ * - `dist/json/` — DTCG **Resolver**: `resolver.json` + reference-closed
12
+ * `sets/{base, spacing.<dimension>, <brand>.color.<mode>.<surface>}.json`.
13
+ * Hard cutover from the old per-variant JSON (pre-4.0 GA — no consumer reads
14
+ * `dist/json/*` yet). One manifest + O(b·m·s + d + 1) sets, not b·m·s·d docs.
15
+ * - `dist/css/` + `dist/ts/` — per-variant, fully resolved (unchanged).
16
+ *
10
17
  * **Idempotency contract:** rerunning with the same `(config, gitHead,
11
18
  * nodeVersion, platform)` produces byte-identical `dist/` + `manifest.json`.
12
- * Verified by `__tests__/build-idempotent.test.ts`.
19
+ * Verified by `__tests__/build.test.ts`.
13
20
  *
14
21
  * **`--check` mode (CI gate):** read existing `manifest.json`, recompute
15
22
  * the expected manifest from current config, compare. Exit 1 on drift.
@@ -24,13 +31,15 @@ import { tmpdir } from 'node:os';
24
31
  import { dirname, join } from 'node:path';
25
32
 
26
33
  import { renderCss } from './renderers/css';
27
- import { renderJson } from './renderers/json';
34
+ import { renderBaseSet, renderColorSet, renderResolver, renderSpacingSet } from './renderers/resolver';
28
35
  import { renderTs } from './renderers/ts';
29
36
  import type { ApollionConfig, Variant } from './config-schema';
30
37
  import { expandVariants, variantName } from './config-schema';
31
- import { buildIR } from './ir';
38
+ import type { IRSlice } from './ir';
39
+ import { assertSlicesMetaComplete, buildBaseIR, buildColorIR, buildFullIR, buildSpacingIR } from './ir';
32
40
  import type { BuildManifest, ManifestFileEntry } from './manifest';
33
41
  import { buildEnv, detectGitCommit, hashConfig, serializeManifest, sha256 } from './manifest';
42
+ import { planSets, RESOLVER_PATH } from './set-plan';
34
43
  import { buildVariantThemes } from './theme-factory';
35
44
 
36
45
  export interface BuildOptions {
@@ -59,34 +68,59 @@ export async function build(opts: BuildOptions): Promise<BuildResult> {
59
68
 
60
69
  try {
61
70
  const files: ManifestFileEntry[] = [];
71
+ const emit = async (path: string, content: string): Promise<void> => {
72
+ await writeAt(tmpRoot, path, content);
73
+ files.push({ path, sha256: sha256(content) });
74
+ if (verbose) console.log(` ✓ ${path}`);
75
+ };
62
76
 
63
- for (const variant of variants) {
64
- const { foundation, colors } = buildVariantThemes(variant);
65
- const ir = buildIR(foundation, colors, variant);
66
- const baseName = variantName(variant);
67
-
68
- if (output.css) {
69
- const content = renderCss(ir);
70
- const path = `css/${baseName}.css`;
71
- await writeAt(tmpRoot, path, content);
72
- files.push({ path, sha256: sha256(content) });
73
- if (verbose) console.log(` ✓ ${path}`);
77
+ // ── JSON surface (R5): Resolver manifest + reference-closed sets ─────────
78
+ // Hard cutover no per-variant JSON. The base set is axis-invariant; colour
79
+ // sets vary by (brand × mode × surface); spacing sets vary by dimension.
80
+ // bg/text are dimension-invariant and spacing is brand/surface-invariant, so
81
+ // a single representative variant resolves each set's foundation.
82
+ if (output.json) {
83
+ const plan = planSets(config);
84
+ const slices: IRSlice[] = [];
85
+
86
+ const baseSlice = buildBaseIR();
87
+ slices.push(baseSlice);
88
+ await emit(plan.base.file, renderBaseSet(baseSlice));
89
+
90
+ for (const set of plan.spacing) {
91
+ const variant = variants.find((v) => v.dimension === set.dimension)!;
92
+ const { foundation } = buildVariantThemes(variant);
93
+ const slice = buildSpacingIR(foundation, set.dimension);
94
+ slices.push(slice);
95
+ await emit(set.file, renderSpacingSet(slice, set.dimension));
74
96
  }
75
97
 
76
- if (output.json) {
77
- const content = renderJson(ir);
78
- const path = `json/${baseName}.json`;
79
- await writeAt(tmpRoot, path, content);
80
- files.push({ path, sha256: sha256(content) });
81
- if (verbose) console.log(` ✓ ${path}`);
98
+ for (const set of plan.color) {
99
+ const variant = variants.find(
100
+ (v) => v.brand === set.brand && v.mode === set.mode && v.surface === set.surface,
101
+ )!;
102
+ const { foundation, colors } = buildVariantThemes(variant);
103
+ const slice = buildColorIR(foundation, colors);
104
+ slices.push(slice);
105
+ await emit(set.file, renderColorSet(slice, set.brand, set.mode, set.surface));
82
106
  }
83
107
 
84
- if (output.ts) {
85
- const content = renderTs(ir);
86
- const path = `ts/${baseName}.d.ts`;
87
- await writeAt(tmpRoot, path, content);
88
- files.push({ path, sha256: sha256(content) });
89
- if (verbose) console.log(` ✓ ${path}`);
108
+ // Stale-key guard runs over the UNION of every emitted set (a single set
109
+ // is intentionally partial). Throws → atomic build aborts, dist untouched.
110
+ assertSlicesMetaComplete(slices);
111
+
112
+ await emit(RESOLVER_PATH, renderResolver(config, plan));
113
+ }
114
+
115
+ // ── CSS + TS surfaces: per-variant, fully resolved (unchanged) ───────────
116
+ if (output.css || output.ts) {
117
+ for (const variant of variants) {
118
+ const { foundation, colors } = buildVariantThemes(variant);
119
+ const ir = buildFullIR(foundation, colors, variant);
120
+ const baseName = variantName(variant);
121
+
122
+ if (output.css) await emit(`css/${baseName}.css`, renderCss(ir));
123
+ if (output.ts) await emit(`ts/${baseName}.d.ts`, renderTs(ir));
90
124
  }
91
125
  }
92
126