@apollion-dsi/tokens 5.6.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -38
- package/lib/build.cjs +10 -9
- package/lib/build.esm.js +10 -9
- package/lib/builders/colors.d.ts +27 -0
- package/lib/cli.mjs +13 -12
- package/lib/config-loader.cjs +1 -1
- package/lib/config-loader.esm.js +2 -2
- package/lib/config-schema.cjs +1 -1
- package/lib/runtime/v1.cjs +1 -1
- package/lib/runtime/v1.esm.js +1 -1
- package/package.json +1 -1
- package/src/build.ts +28 -1
- package/src/builders/breakpoints.ts +25 -0
- package/src/builders/colors.ts +34 -3
- package/src/builders/ladder.ts +116 -0
- package/src/builders/layout.ts +24 -0
- package/src/config-schema-runtime.ts +1 -0
- package/src/config-schema.ts +5 -0
- package/src/ir.ts +90 -7
- package/src/renderers/css.ts +48 -0
- package/src/renderers/tailwind.ts +14 -3
- package/src/theme-factory.ts +5 -1
- package/src/token-meta.ts +9 -0
package/README.md
CHANGED
|
@@ -1,67 +1,81 @@
|
|
|
1
1
|
# @apollion-dsi/tokens
|
|
2
2
|
|
|
3
3
|
Framework-agnostic design tokens for the **Apollion Design System** — an
|
|
4
|
-
OKLch-based
|
|
5
|
-
|
|
6
|
-
variants.
|
|
4
|
+
OKLch-based pipeline that emits CSS variables, structured JSON, TypeScript
|
|
5
|
+
types, and an optional Tailwind preset, in light **and** dark variants.
|
|
7
6
|
|
|
8
7
|
[](https://www.npmjs.com/package/@apollion-dsi/tokens)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
[](https://www.npmjs.com/package/@apollion-dsi/tokens)
|
|
9
|
+
[](https://www.npmjs.com/package/@apollion-dsi/tokens)
|
|
10
|
+
|
|
11
|
+
- **Works without React.** Vue, Flutter, native, or plain CSS stacks read the
|
|
12
|
+
emitted `dist/json` / `dist/css` directly — no framework adapter needed.
|
|
13
|
+
- **Light and dark from one source.** Every variant is emitted for both modes,
|
|
14
|
+
including a CSS-only dark switch for pages that never mount React.
|
|
15
|
+
- **OKLch working space.** Palettes are derived in OKLch with an sRGB `hex`
|
|
16
|
+
fallback, so color math stays perceptually even.
|
|
17
|
+
- **Config-first.** One `apollion.config.mjs` drives palette, dimension, and
|
|
18
|
+
which outputs to emit (CSS / JSON / TS / Tailwind).
|
|
19
|
+
- **Versioned in lockstep with `@apollion-dsi/core`** — both always release the
|
|
20
|
+
same version number.
|
|
13
21
|
|
|
14
22
|
## Installation
|
|
15
23
|
|
|
16
|
-
React consumers
|
|
17
|
-
|
|
18
|
-
non-React stacks (or standalone token builds), install it directly:
|
|
24
|
+
React consumers usually get this transitively via `@apollion-dsi/core`. For
|
|
25
|
+
non-React stacks or standalone token builds, install it directly:
|
|
19
26
|
|
|
20
27
|
```bash
|
|
21
28
|
yarn add @apollion-dsi/tokens
|
|
22
29
|
```
|
|
23
30
|
|
|
24
|
-
##
|
|
31
|
+
## Documentation
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
- **Docs & token reference:** <https://www.apollion.com.br>
|
|
34
|
+
- **Changelog:** <https://www.apollion.com.br/changelog>
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
## Runtime API
|
|
37
|
+
|
|
38
|
+
A single, versioned public runtime entry — `@apollion-dsi/tokens/runtime/v1`.
|
|
39
|
+
Future breaking changes go to `runtime/v2`, `runtime/v3`, …; `v1` is preserved
|
|
40
|
+
indefinitely, so consumers migrate on their own schedule.
|
|
30
41
|
|
|
31
42
|
```ts
|
|
32
43
|
import { TOKENS_RUNTIME_API_VERSION } from '@apollion-dsi/tokens/runtime/v1';
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
## Scope
|
|
36
|
-
|
|
37
|
-
- **In:** OKLch palette derivation, dimension scales, Foundation/Surface
|
|
38
|
-
builders, build-time emission of CSS/JSON/TS variants (light **and**
|
|
39
|
-
dark), config-first loader (`apollion.config.mjs`).
|
|
40
|
-
- **Out:** runtime React components (those live in `@apollion-dsi/core`);
|
|
41
|
-
framework adapters — Vue/Flutter/other consumers read `dist/json/*.json`
|
|
42
|
-
directly.
|
|
43
|
-
|
|
44
46
|
## Build outputs (`dist/*`)
|
|
45
47
|
|
|
46
|
-
The build
|
|
48
|
+
The build emits, per variant (light/dark):
|
|
47
49
|
|
|
48
50
|
- **`dist/css/*.css`** — fully resolved CSS custom properties.
|
|
49
|
-
- **`dist/json/*.json`** — tokens as structured
|
|
50
|
-
interop surface
|
|
51
|
+
- **`dist/json/*.json`** — tokens as **structured objects** (the cross-framework
|
|
52
|
+
interop surface), not shorthand strings:
|
|
51
53
|
- `color` → `{ "colorSpace": "oklch", "components": [L, C, H], "hex": "#rrggbb" }`
|
|
52
|
-
|
|
53
|
-
below 1).
|
|
54
|
+
(`alpha` only when below 1).
|
|
54
55
|
- `dimension` → `{ "value": <number>, "unit": "rem" }`.
|
|
55
|
-
- **`dist/ts/*.d.ts`** — typed token surfaces (
|
|
56
|
-
- **`dist/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
- **`dist/ts/*.d.ts`** — typed token surfaces (hex / `rem` strings).
|
|
57
|
+
- **`dist/css/<brand>.<surface>.<dimension>.modes.css`** — opt-in
|
|
58
|
+
(`output.cssModes`): both modes in one file, scoped by
|
|
59
|
+
`html[data-apollion-mode]` (+ `prefers-color-scheme` fallback) — the CSS-only
|
|
60
|
+
dark mode for pages without React.
|
|
61
|
+
- **`dist/tailwind/preset.mjs` + `tw-merge.mjs`** — opt-in (`output.tailwind`):
|
|
62
|
+
a Tailwind preset mapping foundation tokens over `var(--apollion-*)`, plus a
|
|
63
|
+
matching tailwind-merge extension. Its `screens` scale carries **literal px**
|
|
64
|
+
(custom properties are invalid inside a `@media` prelude).
|
|
65
|
+
|
|
66
|
+
## Breakpoint tokens
|
|
67
|
+
|
|
68
|
+
The viewport scale (`breakpoint.xs/sm/md/lg/xl` = `0/575/767/990/1200`, px) is
|
|
69
|
+
axis-invariant and mirrors `@apollion-dsi/core`:
|
|
70
|
+
|
|
71
|
+
- **Bands are half-open `[value, next)`** over ascending `min-width` sets — every
|
|
72
|
+
width belongs to exactly one band; JS predicates use strict `<` on the upper
|
|
73
|
+
bound.
|
|
74
|
+
- **Unit is px by decision** — the root is fixed at 16px and browser zoom scales
|
|
75
|
+
px media queries correctly.
|
|
76
|
+
- **CSS vars (`--apollion-breakpoint-*`) are informational** (for JS
|
|
77
|
+
`getComputedStyle` readers); the query-capable surfaces are the TS record and
|
|
78
|
+
the Tailwind `screens` scale.
|
|
65
79
|
|
|
66
80
|
## License
|
|
67
81
|
|
package/lib/build.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var xn=Object.getOwnPropertyNames;var wn=Object.prototype.hasOwnProperty;var s=(e,n)=>P(e,"name",{value:n,configurable:!0});var Tn=(e,n)=>{for(var o in n)P(e,o,{get:n[o],enumerable:!0})},vn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of xn(n))!wn.call(e,t)&&t!==o&&P(e,t,{get:()=>n[t],enumerable:!(r=Sn(n,t))||r.enumerable});return e};var Dn=e=>vn(P({},"__esModule",{value:!0}),e);var lo={};Tn(lo,{build:()=>so,check:()=>ao});module.exports=Dn(lo);var b=require("node:fs/promises"),kn=require("node:os"),v=require("node:path");var U=require("culori");var N=require("@apollion-dsi/core/themes/border"),Re=require("@apollion-dsi/core/themes/colors"),J=require("@apollion-dsi/core/themes/depth"),T=require("@apollion-dsi/core/themes/font"),ie=require("@apollion-dsi/core/themes/spacing"),M=require("culori");var be=require("@apollion-dsi/core/themes/dimension");function _({multiplier:e=.25,alias:n},o){let r=o!==void 0?be.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(_,"createSpacing");var re={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function te(e){let n=Object.keys(re).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(te,"assertTokenMetaResolves");var $n=(0,M.converter)("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function S(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(S,"kebab");function Ie(e){return e.split(".").map(S).join(".")}s(Ie,"kebabPath");function E(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(E,"rawValue");function B(e,n){return Number(e.toFixed(n))||0}s(B,"round");function ae(e){let n=$n((0,M.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[B(n.l,4),B(n.c,4),B(n.h??0,2)],r=(0,M.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:B(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ae,"toColorValue");var ke=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function O(e){let n=ke.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(O,"toDimensionValue");function k(e){return{type:"color",value:ae(e)}}s(k,"colorToken");function se(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(se,"recordColorGroup");function Se(e){let n=(0,Re.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=se(n.neutral),o}s(Se,"buildReadableTextGroup");var Cn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function xe(e){let n={};for(let o of Cn){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=se(e.grayscale),n.neutral=se(e.neutral),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}s(xe,"buildColorPrimitives");function we(e){let n=_(ie.defaultInputSpacing,e),o={};for(let r of Object.keys(ie.defaultInputSpacing.alias))o[r]={type:"dimension",value:O(n(r))};return o}s(we,"buildSpacePrimitives");function Te(){let e={};for(let[n,o]of Object.entries(N.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:O(o)};return e}s(Te,"buildBorderWidthPrimitives");function Vn(e,n){return{color:xe(e),space:we(n),borderWidth:Te()}}s(Vn,"buildPrimitives");var ve={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},De={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function On(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(On,"lookupPrimitive");function H(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?On(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ae(i)}}:k(i)}return r}s(H,"colorRefGroup");var $e={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},En={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Gn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Gn,"lookupDimensionPrimitive");function ce(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Gn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:O(i)}}:{type:"dimension",value:O(i)}}return r}s(ce,"dimensionRefGroup");function Ce(e){let n={},o={};for(let[i,a]of Object.entries(N.defaultInputBorder.borderRadius))ke.test(a)?n[i]={type:"dimension",value:O(a)}:o[i]=a;let r=ce(N.defaultInputBorder.borderWidth,e,En),t={};for(let[i,a]of Object.entries(N.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Ce,"buildBorder");function Ve(e){let n=(0,T.createFont)(T.defaultInputFont,e),o={};for(let[c,l]of Object.entries(T.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:O(l)};let t={};for(let[c,l]of Object.entries(T.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(T.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:T.defaultInputFont.letterSpacing,textTransform:T.defaultInputFont.textTransform,fontStyle:T.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Ve,"buildFont");var Mn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function jn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Mn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>O(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ae(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(jn,"parseShadow");function Oe(e){let n=(0,J.createDeth)(e),o={};for(let r of Object.keys(J.levelValues))o[r]={type:"shadow",value:jn(n(r))};return o}s(Oe,"buildShadow");function W(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${S(t)}`:S(t);if(h(i)){o.add(a);let c=re[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=W(i,a,o)}return r}s(W,"decorateGroup");function An(e){let n=new Set,o=W(e.primitives,"",n),r=W(e.groups,"",n);return te(n),{...e,primitives:o,groups:r}}s(An,"decorateMeta");function z(e,n){return W(e,"",n)}s(z,"decorateSlice");function Ee(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${S(r)}`:S(r);h(t)?o.add(i):Ee(t,i,o)}}s(Ee,"collectPaths");function Ge(e){let n=new Set;for(let o of e)Ee(o.groups,"",n);te(n)}s(Ge,"assertSlicesMetaComplete");function Me(){let e=Te(),o=Ce({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:z({"border-width":e,border:o.group},t),extensions:r}}s(Me,"buildBaseIR");function je(e){let n=Ve(e),o=new Set;return{groups:z({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(je,"buildFontIR");function Ae(e,n){let o=xe(n),r=new Set;return{groups:z({color:o,bg:H(e.bg,n,ve),text:H(e.text,n,De),tx:Se(n),shadow:Oe(n)},r),extensions:{}}}s(Ae,"buildColorIR");function Ne(e,n){let o=we(n),r={space:o},t=new Set;return{groups:z({space:o,spacing:ce(e.spacing,r,$e)},t),extensions:{}}}s(Ne,"buildSpacingIR");function Nn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=Vn(n,o.dimension),i=Ce(t),a=Ve(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:H(e.bg,n,ve),text:H(e.text,n,De),tx:Se(n),spacing:ce(e.spacing,t,$e),border:i.group,font:a.group,shadow:Oe(n)},extensions:c};return An(l)}s(Nn,"buildIR");var q=Nn;var Fn=(0,U.converter)("rgb"),Fe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function le(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(le,"colorPayload");function ue(e){return e.alpha===void 0}s(ue,"isOpaqueColor");function Le(e){let n=Fn((0,U.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Le,"rgbTriplet");function X(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,S(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of X(t,i))o.set(a,c)}return o}s(X,"flatTokens");function y(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(y,"groupAt");function Pe(e){let n=[];for(let o of["bg","text","tx"])for(let[r,t]of X(y(e.groups,o),[o])){let i=le(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:ue(i)})}return n}s(Pe,"colorEntries");function $(e,n){return[...X(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s($,"varEntries");function C(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(C,"pushScale");function _e(e){let n=[Fe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Pe(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),C(n,"spacing",$(y(e.groups,"spacing"),["spacing"])),C(n,"borderRadius",$(y(e.groups,"border","radius"),["border","radius"])),C(n,"borderWidth",$(y(e.groups,"border","width"),["border","width"])),C(n,"fontFamily",$(y(e.groups,"font","family"),["font","family"])),C(n,"fontSize",$(y(e.groups,"font","size"),["font","size"])),C(n,"fontWeight",$(y(e.groups,"font","weight"),["font","weight"])),C(n,"lineHeight",$(y(e.groups,"font","lineHeight"),["font","line-height"])),C(n,"boxShadow",$(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`)}s(
|
|
4
|
-
`)}s(
|
|
1
|
+
"use strict";var U=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Hn=Object.getOwnPropertyNames;var Wn=Object.prototype.hasOwnProperty;var s=(e,n)=>U(e,"name",{value:n,configurable:!0});var zn=(e,n)=>{for(var o in n)U(e,o,{get:n[o],enumerable:!0})},Jn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Hn(n))!Wn.call(e,t)&&t!==o&&U(e,t,{get:()=>n[t],enumerable:!(r=Bn(n,t))||r.enumerable});return e};var qn=e=>Jn(U({},"__esModule",{value:!0}),e);var Oo={};zn(Oo,{build:()=>Mo,check:()=>Eo});module.exports=qn(Oo);var x=require("node:fs/promises"),_n=require("node:os"),L=require("node:path");var oe=require("culori");var H=require("@apollion-dsi/core/themes/border"),Ee=require("@apollion-dsi/core/themes/colors"),ee=require("@apollion-dsi/core/themes/depth"),D=require("@apollion-dsi/core/themes/font"),ge=require("@apollion-dsi/core/themes/spacing"),P=require("culori");var Ce=require("@apollion-dsi/core/themes/breakpoints");function Ve(e=Ce.defaultInputBreakpoints){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s(Ve,"breakpointEntries");var X=require("@apollion-dsi/core/themes/layout");function Le(e=X.defaultInputContainerSizes){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s(Le,"containerSizeEntries");function Ae(e=X.defaultInputLayout){return[["page-max-width",`${e.pageMaxWidth}px`]]}s(Ae,"layoutEntries");var Me=require("@apollion-dsi/core/themes/dimension");function Y({multiplier:e=.25,alias:n},o){let r=o!==void 0?Me.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(Y,"createSpacing");var fe={"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)."},"bg.canvas":{description:"Page ground \u2014 the theme canvas (never pure black in dark)."},"bg.paper":{description:"Component ground (cards, inputs, tables) \u2014 lighter than the canvas in both modes."},"bg.overlay":{description:"Top of the elevation ladder \u2014 modal / dialog panels."},"text.primary":{description:"Primary neutral ink \u2014 AA + APCA Lc \u2265 75 over bg.paper and bg.canvas."},"text.muted":{description:"Muted neutral ink \u2014 AA + APCA Lc \u2265 45 over bg.paper."},"edge.border":{description:"Default control outline \u2014 primary ink at 20 % alpha, legible on any ground."},"edge.hairline":{description:"Dividers and card outlines \u2014 primary ink at 10 % alpha."},"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 me(e){let n=Object.keys(fe).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(me,"assertTokenMetaResolves");var Kn=(0,P.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function v(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(v,"kebab");function Ge(e){return e.split(".").map(v).join(".")}s(Ge,"kebabPath");function C(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(C,"rawValue");function Z(e,n){return Number(e.toFixed(n))||0}s(Z,"round");function he(e){let n=Kn((0,P.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[Z(n.l,4),Z(n.c,4),Z(n.h??0,2)],r=(0,P.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:Z(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(he,"toColorValue");var Oe=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function $(e){let n=Oe.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($,"toDimensionValue");function S(e){return{type:"color",value:he(e)}}s(S,"colorToken");function N(e){let n={};for(let[o,r]of Object.entries(e))n[o]=S(r);return n}s(N,"recordColorGroup");function Ne(e){let n=(0,Ee.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=S(t);return o.neutral=N(n.neutral),o}s(Ne,"buildReadableTextGroup");var Un=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function je(e){let n={};for(let o of Un){let r=e[o];n[o]={base:S(r.base),dark:S(r.dark),action:S(r.action),active:S(r.active),light:S(r.light),onLight:S(r.onLight)}}return n.grayscale=N(e.grayscale),n.neutral=N(e.neutral),n.surface=N(e.surface),n.ink=N(e.ink),n.edge=N(e.edge),n.wash=N(e.wash),n.baseDark=S(e.baseDark??"#000000"),n.baseLight=S(e.baseLight??"#ffffff"),n.deepDark=S(e.deepDark??"#000000"),n.deepLight=S(e.deepLight??"#ffffff"),n}s(je,"buildColorPrimitives");function Fe(e){let n=Y(ge.defaultInputSpacing,e),o={};for(let r of Object.keys(ge.defaultInputSpacing.alias))o[r]={type:"dimension",value:$(n(r))};return o}s(Fe,"buildSpacePrimitives");function Pe(){let e={};for(let[n,o]of Object.entries(H.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:$(o)};return e}s(Pe,"buildBorderWidthPrimitives");function Xn(e,n){return{color:je(e),space:Fe(n),borderWidth:Pe()}}s(Xn,"buildPrimitives");var _e={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",canvas:"color.surface.canvas",sunken:"color.surface.sunken",paper:"color.surface.paper",raised:"color.surface.raised",overlay:"color.surface.overlay"},Be={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight",primary:"color.ink.primary",secondary:"color.ink.secondary",muted:"color.ink.muted",disabled:"color.ink.disabled"},He={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function Yn(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(Yn,"lookupPrimitive");function F(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:"color",value:{kind:"ref",path:a,resolved:he(i)}}:S(i)}return r}s(F,"colorRefGroup");var We={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Zn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Qn(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(Qn,"lookupDimensionPrimitive");function ye(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Qn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:$(i)}}:{type:"dimension",value:$(i)}}return r}s(ye,"dimensionRefGroup");function ze(e){let n={},o={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderRadius))Oe.test(a)?n[i]={type:"dimension",value:$(a)}:o[i]=a;let r=ye(H.defaultInputBorder.borderWidth,e,Zn),t={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(ze,"buildBorder");function Je(e){let n=(0,D.createFont)(D.defaultInputFont,e),o={};for(let[c,l]of Object.entries(D.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:$(l)};let t={};for(let[c,l]of Object.entries(D.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(D.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:D.defaultInputFont.letterSpacing,textTransform:D.defaultInputFont.textTransform,fontStyle:D.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Je,"buildFont");var eo=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function no(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(eo),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>$(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:he(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(no,"parseShadow");function qe(e){let n=(0,ee.createDeth)(e),o={};for(let r of Object.keys(ee.levelValues))o[r]={type:"shadow",value:no(n(r))};return o}s(qe,"buildShadow");function Q(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${v(t)}`:v(t);if(b(i)){o.add(a);let c=fe[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]=Q(i,a,o)}return r}s(Q,"decorateGroup");function oo(e){let n=new Set,o=Q(e.primitives,"",n),r=Q(e.groups,"",n);return me(n),{...e,primitives:o,groups:r}}s(oo,"decorateMeta");function ne(e,n){return Q(e,"",n)}s(ne,"decorateSlice");function Ke(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${v(r)}`:v(r);b(t)?o.add(i):Ke(t,i,o)}}s(Ke,"collectPaths");function Ue(e){let n=new Set;for(let o of e)Ke(o.groups,"",n);me(n)}s(Ue,"assertSlicesMetaComplete");function Xe(){let e={};for(let[n,o]of Ve())e[n]={type:"dimension",value:$(o)};return e}s(Xe,"buildBreakpoints");function Ye(){let e={};for(let[n,o]of Le())e[n]={type:"dimension",value:$(o)};return e}s(Ye,"buildContainerSizes");function Ze(){let e={};for(let[n,o]of Ae())e[n]={type:"dimension",value:$(o)};return e}s(Ze,"buildLayoutConstants");var Qe={unit:"px",interval:"half-open [value, next) \u2014 min-width sets, ascending",cssVarsUsage:"informational only \u2014 var() is invalid inside a @media prelude"};function en(){let e=Pe(),o=ze({borderWidth:e}),r={"com.apollion.breakpoint":Qe};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:ne({"border-width":e,border:o.group,breakpoint:Xe(),"container-size":Ye(),layout:Ze()},t),extensions:r}}s(en,"buildBaseIR");function nn(e){let n=Je(e),o=new Set;return{groups:ne({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(nn,"buildFontIR");function on(e,n){let o=je(n),r=new Set;return{groups:ne({color:o,bg:F(e.bg,n,_e),text:F(e.text,n,Be),edge:F(e.edge,n,He),tx:Ne(n),shadow:qe(n)},r),extensions:{}}}s(on,"buildColorIR");function rn(e,n){let o=Fe(n),r={space:o},t=new Set;return{groups:ne({space:o,spacing:ye(e.spacing,r,We)},t),extensions:{}}}s(rn,"buildSpacingIR");function ro(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=Xn(n,o.dimension),i=ze(t),a=Je(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions,"com.apollion.breakpoint":Qe};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,_e),text:F(e.text,n,Be),edge:F(e.edge,n,He),tx:Ne(n),spacing:ye(e.spacing,t,We),border:i.group,breakpoint:Xe(),"container-size":Ye(),layout:Ze(),font:a.group,shadow:qe(n)},extensions:c};return oo(l)}s(ro,"buildIR");var _=ro;var to=(0,oe.converter)("rgb"),tn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function be(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(be,"colorPayload");function Re(e){return e.alpha===void 0}s(Re,"isOpaqueColor");function sn(e){let n=to((0,oe.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(sn,"rgbTriplet");function W(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(b(t))o.set(i.join("-"),t);else for(let[a,c]of W(t,i))o.set(a,c)}return o}s(W,"flatTokens");function R(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||b(o))return{};o=o[r]}return o&&!b(o)?o:{}}s(R,"groupAt");function an(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of W(R(e.groups,o),[o])){let i=be(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:Re(i)})}return n}s(an,"colorEntries");function E(e,n){return[...W(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(E,"varEntries");function V(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(V,"pushScale");function cn(e){let n=[tn,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=an(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),V(n,"screens",[...W(R(e.groups,"breakpoint"))].filter(([r])=>r!=="xs").map(([r,t])=>[r,C(t.value)])),V(n,"spacing",E(R(e.groups,"spacing"),["spacing"])),V(n,"borderRadius",E(R(e.groups,"border","radius"),["border","radius"])),V(n,"borderWidth",E(R(e.groups,"border","width"),["border","width"])),V(n,"fontFamily",E(R(e.groups,"font","family"),["font","family"])),V(n,"fontSize",E(R(e.groups,"font","size"),["font","size"])),V(n,"fontWeight",E(R(e.groups,"font","weight"),["font","weight"])),V(n,"lineHeight",E(R(e.groups,"font","lineHeight"),["font","line-height"])),V(n,"boxShadow",E(R(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(cn,"renderTailwindPreset");function ln(e){let n=s(t=>[...W(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[tn,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(an(e).map(t=>t.key))},`,` spacing: ${o(n(R(e.groups,"spacing")))},`,` borderRadius: ${o(n(R(e.groups,"border","radius")))},`,` borderWidth: ${o(n(R(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(R(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(R(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(R(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(R(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(R(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(ln,"renderTwMergeExtension");var dn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function re(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];b(t)?o.push(` --apollion-${i.join("-")}: ${C(t.value)};`):re(t,i,o)}}s(re,"emitVars");function te(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(!b(t)){te(t,i,o);continue}let a=be(t);a&&Re(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${sn(a)};`)}}s(te,"emitRgbVars");function ke(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];b(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${C(t.value)}; }`):ke(t,i,o)}}s(ke,"emitProperties");function un(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[dn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),re(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),te(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ke(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(un,"renderCss");function pn(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:i,surface:a,dimension:c}=e.meta,l=[dn,""],m=s((w,d,u)=>{l.push(`${w} {`,` color-scheme: ${u};`),re(d.groups,[],l),t&&te(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${i} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),m(`:root, html[${r}="light"]`,e,"light"),m(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let k=[];re(n.groups,[],k),t&&te(n.groups,[],k);for(let w of k)l.push(` ${w}`);return l.push(" }","}",""),l.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ke(e.groups,[],l),l.push("}",""),l.join(`
|
|
5
|
+
`)}s(pn,"renderCssModes");var io="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function Ie(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;b(t)?o.push([i,C(t.value)]):Ie(t,i,o)}}s(Ie,"flatten");function so(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(so,"yamlEscape");function ao(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(ao,"variantKey");function fn(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let i=[];Ie(t.groups,"",i),o.push(` ${ao(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${so(c)}`)}o.push("---");let r=["",io,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];Ie(t.groups,"",l);let m=new Map;for(let[k,w]of l){let d=k.split(".")[0]??k,u=m.get(d)??[];u.push([k,w]),m.set(d,u)}for(let[k,w]of m){r.push(`### ${k}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of w)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
|
|
5
6
|
`)}
|
|
6
7
|
${r.join(`
|
|
7
|
-
`)}`}s(
|
|
8
|
-
`}s(
|
|
9
|
-
`}s(
|
|
10
|
-
`)}s(
|
|
11
|
-
`}s(an,"serializeManifest");var Kn="json/sets",cn="json/resolver.json";function Q(e){return`${Kn}/${e}.json`}s(Q,"setFile");function Zn(e,n,o){return`${e}.color.${n}.${o}`}s(Zn,"colorSetName");function Qn(e){return`spacing.${e}`}s(Qn,"spacingSetName");function eo(e){return`font.${e}`}s(eo,"fontSetName");function ee(e,n){e.includes(n)||e.push(n)}s(ee,"pushUnique");function ln(e){let n=K(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],I=new Set,D=[];for(let u of n){ee(o,u.brand),ee(r,u.mode),ee(t,u.surface),ee(i,u.dimension);let f=Zn(u.brand,u.mode,u.surface);a.has(f)||(a.add(f),c.push({kind:"color",name:f,file:Q(f),brand:u.brand,mode:u.mode,surface:u.surface}));let x=Qn(u.dimension);l.has(x)||(l.add(x),m.push({kind:"spacing",name:x,file:Q(x),dimension:u.dimension}));let p=eo(u.dimension);I.has(p)||(I.add(p),D.push({kind:"font",name:p,file:Q(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:Q("base")},spacing:m,font:D,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(ln,"planSets");var yn=require("@apollion-dsi/core/themes/colors"),ye=require("@apollion-dsi/core/themes/foundation"),bn=require("@apollion-dsi/core/themes/semantic"),Rn=require("@apollion-dsi/core/themes/spacing"),In=require("@apollion-dsi/core/themes/surface");var g=require("culori");var he=(0,g.converter)("oklch");function d(e,n,o){let r=(0,g.parse)(e),t=(0,g.parse)(n);if(!r||!t)return e;let i=(0,g.interpolate)([r,t],"oklch");return(0,g.formatHex)(i(o))??e}s(d,"mixOklch");function no(e){return e?typeof e=="string"?e:e.base:"#000"}s(no,"coerceToHex");var ne=1.3,oo=.05,un=.04,V=s((e,n)=>{let o=(0,g.parse)(e),r=(0,g.parse)(n);return!o||!r?1:(0,g.wcagContrast)(o,r)},"contrastRatio"),ge=s(e=>{let n=he((0,g.parse)(e));return n?n.l??0:null},"oklchLightness"),ro=4.5;function dn(e,n,o=ro){let r=(0,g.parse)(n),t=he((0,g.parse)(e));if(!r||!t)return e;let i=V("#fff",n)>=V("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,g.formatHex)(t)??e,l=(0,g.parse)(c);if(l&&(0,g.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,g.formatHex)(t)??e}s(dn,"readableColor");var pn=s((e,n)=>{if(V(e,n)>=ne)return!0;let o=ge(e),r=ge(n);return o!==null&&r!==null&&Math.abs(o-r)>=oo},"isPerceptibleState"),to=s(e=>e?V("#fff",e)>V("#000",e):!1,"isDarkSurface");function fn(e,n,o){let r=he((0,g.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?un:-un;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,g.formatHex)(t);if(l&&V(e,l)>=ne)return l}return(0,g.formatHex)(t)??null}s(fn,"derivePerceptibleState");function mn(e,n,o){let r=fn(e,n,o);if(r&&V(e,r)>=ne)return r;let t=fn(e,!n);return t&&V(e,t)>=ne?t:r??t}s(mn,"perceptibleStateFor");function w(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=no(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:d(r,t,.6),action:d(r,t,.2),active:d(r,i,.6),light:d(r,i,.9),onLight:r};if((0,g.parse)(r)){let c=to(n.baseLight),l=pn(r,a.action);if(l||(a.action=mn(r,c)??a.action),!pn(r,a.active)){let m=l?void 0:ge(a.action)??void 0;a.active=mn(r,c,m)??a.active}}if(a.onLight=dn(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??dn(c,l)}}return a}s(w,"mountSingleColor");function gn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:d(n,o,.05),10:d(n,o,.1),20:d(n,o,.2),30:d(n,o,.3),40:d(n,o,.4),50:d(n,o,.5),60:d(n,o,.6),70:d(n,o,.7),80:d(n,o,.8),90:d(n,o,.9),100:d(n,o,1)}}s(gn,"mountGreyscaleColors");function hn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=d(r,o,.5);return{0:d(i,n,t(18)),5:d(i,n,t(17.5)),10:d(i,n,t(17)),20:d(i,n,t(16)),30:d(i,n,t(15)),40:d(i,n,t(14)),50:d(i,n,t(13)),60:d(i,n,t(12)),70:d(i,n,t(11)),80:d(i,n,t(10)),90:d(i,n,t(9)),100:d(i,n,t(8)),110:d(i,n,t(7)),120:d(i,n,t(6)),130:d(i,n,t(5)),140:d(i,n,t(4)),150:d(i,n,t(3)),160:d(i,n,t(2)),170:i,180:d(i,o,.25)}}s(hn,"mountNeutralColors");function io(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:hn(e),grayscale:gn(e),main:w(e.main,e),opposite:w(e.opposite,e),complementary:w(e.complementary,e),danger:w(e.danger,e),information:w(e.information,e),success:w(e.success,e),warning:w(e.warning,e),primary:w(e.primary,e),secondary:w(e.secondary,e),tertiary:w(e.tertiary,e)}}s(io,"composeColors");function j(e,n=Rn.defaultInputSpacing){let o=e.mode==="dark"?(0,yn.toDarkColors)(e.colors):e.colors,r=io(o),t=_(n,e.dimension),i=(0,bn.createSemantic)({colors:r,spacing:t}),a=(0,ye.createFoundation)(i);return e.surface==="negative"&&(a=(0,ye.createFoundation)((0,In.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(j,"buildVariantThemes");async function so(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=K(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,b.mkdtemp)((0,v.join)((0,kn.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(u,f)=>{await co(c,u,f),l.push({path:u,sha256:Z(f)}),t&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=ln(n),f=[],x=Me();f.push(x),await m(u.base.file,Xe(x));for(let p of u.spacing){let R=i.find(L=>L.dimension===p.dimension),{foundation:A}=j(R),G=Ne(A,p.dimension);f.push(G),await m(p.file,Ke(G,p.dimension))}for(let p of u.font){let R=je(p.dimension);f.push(R),await m(p.file,Ze(R,p.dimension))}for(let p of u.color){let R=i.find(oe=>oe.brand===p.brand&&oe.mode===p.mode&&oe.surface===p.surface),{foundation:A,colors:G}=j(R),L=Ae(A,G);f.push(L),await m(p.file,Ye(L,p.brand,p.mode,p.surface))}Ge(f),await m(cn,Qe(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:f,colors:x}=j(u),p=q(f,x,u),R=on(u);a.css&&await m(`css/${R}.css`,ze(p,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${R}.d.ts`,nn(p))}if(a.tailwind){let u=i[0],{foundation:f,colors:x}=j(u),p=q(f,x,u);await m("tailwind/preset.mjs",_e(p)),await m("tailwind/tw-merge.mjs",Be(p))}if(a.designMd){let u=[...new Set(i.map(f=>f.brand))];for(let f of u){let p=i.filter(R=>R.brand===f).map(R=>{let{foundation:A,colors:G}=j(R);return q(A,G,R)});await m(`design/${f}.design.md`,qe(f,p))}}let I={configHash:me(n),files:l,gitCommit:tn(r),buildEnv:sn()},D=an(I);return await(0,b.writeFile)((0,v.join)(c,"manifest.json"),D),await(0,b.rm)(o,{recursive:!0,force:!0}),await(0,b.mkdir)((0,v.dirname)(o),{recursive:!0}),await(0,b.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:I,outDir:o}}catch(l){throw await(0,b.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(so,"build");async function ao(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,b.readFile)((0,v.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==me(n))return!1;for(let t of r.files){let i;try{i=await(0,b.readFile)((0,v.join)(o,t.path))}catch{return!1}if(Z(i)!==t.sha256)return!1}return!0}s(ao,"check");async function co(e,n,o){let r=(0,v.join)(e,n);await(0,b.mkdir)((0,v.dirname)(r),{recursive:!0}),await(0,b.writeFile)(r,o)}s(co,"writeAt");0&&(module.exports={build,check});
|
|
8
|
+
`)}`}s(fn,"renderDesignMd");function mn(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(mn,"colorValue");function z(e){return{value:e.value,unit:e.unit}}s(z,"dimensionValue");function co(e){let n=e.shadow,o={color:mn(n.color),offsetX:z(n.offsetX),offsetY:z(n.offsetY),blur:z(n.blur),spread:z(n.spread)};return n.inset&&(o.inset=!0),o}s(co,"shadowValue");function lo(e){switch(e.kind){case"ref":return`{${Ge(e.path)}}`;case"color":return mn(e);case"dimension":return z(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return co(e)}}s(lo,"projectValue");function uo(e){let n={$value:lo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(uo,"projectToken");function xe(e){let n={};for(let[o,r]of Object.entries(e))n[v(o)]=b(r)?uo(r):xe(r);return n}s(xe,"projectGroup");function ie(e,n){let o={$description:n,...xe(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}s(ie,"renderSet");function gn(e){return ie(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(gn,"renderBaseSet");function hn(e,n,o,r){return ie(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(hn,"renderColorSet");function yn(e,n){return ie(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(yn,"renderSpacingSet");function bn(e,n){return ie(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(bn,"renderFontSet");function Rn(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
|
|
10
|
+
`}s(Rn,"renderResolver");var po="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function fo(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(fo,"emitDoc");function kn(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))b(i)?(fo(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(C(i.value))},`)):(o.push(`${r}${t}: {`),kn(i,n+1,o),o.push(`${r}},`))}s(kn,"emitGroup");function In(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[po,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return kn(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
11
|
+
`)}s(In,"renderTs");var mo=["light","dark"],go=["positive","negative"],ho=["compact","normal","spacious"];function se(e){let n=e.modes??mo,o=e.surfaces??go,r=e.dimensions??ho,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let k of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:k});return i}s(se,"expandVariants");function xn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(xn,"variantName");var Sn=require("node:crypto");function ae(e){return(0,Sn.createHash)("sha256").update(e).digest("hex")}s(ae,"sha256");function ve(e){return ae(Se(e))}s(ve,"hashConfig");function Se(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Se).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Se(e[r])}`).join(",")}}`}s(Se,"stableStringify");function vn(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(vn,"detectGitCommit");function wn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(wn,"buildEnv");function Tn(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
12
|
+
`}s(Tn,"serializeManifest");var yo="json/sets",Dn="json/resolver.json";function ce(e){return`${yo}/${e}.json`}s(ce,"setFile");function bo(e,n,o){return`${e}.color.${n}.${o}`}s(bo,"colorSetName");function Ro(e){return`spacing.${e}`}s(Ro,"spacingSetName");function ko(e){return`font.${e}`}s(ko,"fontSetName");function le(e,n){e.includes(n)||e.push(n)}s(le,"pushUnique");function $n(e){let n=se(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],k=new Set,w=[];for(let d of n){le(o,d.brand),le(r,d.mode),le(t,d.surface),le(i,d.dimension);let u=bo(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:ce(u),brand:d.brand,mode:d.mode,surface:d.surface}));let y=Ro(d.dimension);l.has(y)||(l.add(y),m.push({kind:"spacing",name:y,file:ce(y),dimension:d.dimension}));let f=ko(d.dimension);k.has(f)||(k.add(f),w.push({kind:"font",name:f,file:ce(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:ce("base")},spacing:m,font:w,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s($n,"planSets");var Nn=require("@apollion-dsi/core/themes/colors"),$e=require("@apollion-dsi/core/themes/foundation"),jn=require("@apollion-dsi/core/themes/semantic"),Fn=require("@apollion-dsi/core/themes/spacing"),Pn=require("@apollion-dsi/core/themes/surface");var h=require("culori");var q=(0,h.converter)("oklch"),Io=(0,h.converter)("rgb");function p(e,n,o){let r=(0,h.parse)(e),t=(0,h.parse)(n);if(!r||!t)return e;let i=(0,h.interpolate)([r,t],"oklch");return(0,h.formatHex)(i(o))??e}s(p,"mixOklch");function xo(e){return e?typeof e=="string"?e:e.base:"#000"}s(xo,"coerceToHex");var de=1.3,So=.05,Cn=.04,G=s((e,n)=>{let o=(0,h.parse)(e),r=(0,h.parse)(n);return!o||!r?1:(0,h.wcagContrast)(o,r)},"contrastRatio"),we=s(e=>{let n=q((0,h.parse)(e));return n?n.l??0:null},"oklchLightness"),vo=4.5;function J(e,n,o=vo){let r=(0,h.parse)(n),t=q((0,h.parse)(e));if(!r||!t)return e;let i=G("#fff",n)>=G("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,h.formatHex)(t)??e,l=(0,h.parse)(c);if(l&&(0,h.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,h.formatHex)(t)??e}s(J,"readableColor");var Vn=s((e,n)=>{if(G(e,n)>=de)return!0;let o=we(e),r=we(n);return o!==null&&r!==null&&Math.abs(o-r)>=So},"isPerceptibleState"),Te=s(e=>e?G("#fff",e)>G("#000",e):!1,"isDarkSurface");function Ln(e,n,o){let r=q((0,h.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?Cn:-Cn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,h.formatHex)(t);if(l&&G(e,l)>=de)return l}return(0,h.formatHex)(t)??null}s(Ln,"derivePerceptibleState");function An(e,n,o){let r=Ln(e,n,o);if(r&&G(e,r)>=de)return r;let t=Ln(e,!n);return t&&G(e,t)>=de?t:r??t}s(An,"perceptibleStateFor");function T(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=xo(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if((0,h.parse)(r)){let c=Te(n.baseLight),l=Vn(r,a.action);if(l||(a.action=An(r,c)??a.action),!Vn(r,a.active)){let m=l?void 0:we(a.action)??void 0;a.active=An(r,c,m)??a.active}}if(a.onLight=J(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??J(c,l)}}return a}s(T,"mountSingleColor");function Mn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:p(n,o,.05),10:p(n,o,.1),20:p(n,o,.2),30:p(n,o,.3),40:p(n,o,.4),50:p(n,o,.5),60:p(n,o,.6),70:p(n,o,.7),80:p(n,o,.8),90:p(n,o,.9),100:p(n,o,1)}}s(Mn,"mountGreyscaleColors");function En(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(En,"mountNeutralColors");function B(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return(0,h.formatHex)({...o,l:r})??e}s(B,"shiftLightness");function ue(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:(0,h.formatHex)({...o,l:Math.min(i,Math.max(t,r))})??e}s(ue,"clampLightness");function j(e,n){let o=Io((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(j,"toRgbaString");var g=require("@apollion-dsi/core/themes/colors");var wo="#FFFFFF",De="#000000";function To(e){return Te(e.baseLight)?"dark":"light"}s(To,"resolvePolarity");function Gn(e,n,o){if(Math.abs((0,g.apcaContrast)(e,n))>=o)return e;let r=Math.abs((0,g.apcaContrast)("#ffffff",n))>=Math.abs((0,g.apcaContrast)("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=B(t,r?.02:-.02);if(a===t||(t=a,Math.abs((0,g.apcaContrast)(t,n))>=o))break}return t}s(Gn,"ensureApca");function Do(e,n){let o=e.baseLight??wo,r=n==="dark",t=r?ue(o,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):o,i=B(t,g.LADDER_DELTAS.sunken);return{canvas:t,sunken:r?ue(i,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):i,paper:B(t,g.LADDER_DELTAS.paper),raised:B(t,g.LADDER_DELTAS.raised),overlay:B(t,g.LADDER_DELTAS.overlay),scrim:r?e.deepLight??De:e.neutral?.["180"]??e.baseDark??De}}s(Do,"deriveSurface");function $o(e,n){let o=e.baseDark??De,r=ue(Gn(J(o,n.paper,g.MIN_CONTRAST_AA),n.paper,g.INK_APCA_MIN.primary),{max:g.HALATION_FLOORS.INK_MAX_L}),t=s((i,a)=>Gn(J(p(r,n.canvas,i),n.paper,g.MIN_CONTRAST_AA),n.paper,a),"tier");return{primary:r,secondary:t(g.INK_MIX.secondary,g.INK_APCA_MIN.secondary),muted:t(g.INK_MIX.muted,g.INK_APCA_MIN.muted),disabled:p(r,n.canvas,g.INK_MIX.disabled)}}s($o,"deriveInk");function Co(e){return{hairline:j(e.primary,g.EDGE_ALPHA.hairline),border:j(e.primary,g.EDGE_ALPHA.border),strong:j(e.primary,g.EDGE_ALPHA.strong)}}s(Co,"deriveEdge");function Vo(e,n){let o=g.WASH_ALPHA[n];return{hover:j(e.primary,o.hover),pressed:j(e.primary,o.pressed),selected:j(e.primary,o.selected)}}s(Vo,"deriveWash");function Lo(e,n){return n?{surface:{...e.surface,...n.surface},ink:{...e.ink,...n.ink},edge:{...e.edge,...n.edge},wash:{...e.wash,...n.wash}}:e}s(Lo,"applyOverride");function On(e,n){let o=To(e),r=Do(e,o),t=$o(e,r),i={surface:r,ink:t,edge:Co(t),wash:Vo(t,o)};return Lo(i,n?.[o])}s(On,"resolveSurfaceLadder");function Ao(e){let n=En(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:Mn(e),...On({...e,neutral:n},e.ladder),main:T(e.main,e),opposite:T(e.opposite,e),complementary:T(e.complementary,e),danger:T(e.danger,e),information:T(e.information,e),success:T(e.success,e),warning:T(e.warning,e),primary:T(e.primary,e),secondary:T(e.secondary,e),tertiary:T(e.tertiary,e)}}s(Ao,"composeColors");function O(e,n=Fn.defaultInputSpacing){let o=e.mode==="dark"?(0,Nn.toDarkColors)(e.colors):e.colors,r=Ao(o),t=Y(n,e.dimension),i=(0,jn.createSemantic)({colors:r,spacing:t}),a=(0,$e.createFoundation)(i);return e.surface==="negative"&&(a=(0,$e.createFoundation)((0,Pn.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(O,"buildVariantThemes");async function Mo(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=se(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,x.mkdtemp)((0,L.join)((0,_n.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await Go(c,d,u),l.push({path:d,sha256:ae(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=$n(n),u=[],y=en();u.push(y),await m(d.base.file,gn(y));for(let f of d.spacing){let I=i.find(K=>K.dimension===f.dimension),{foundation:A}=O(I),M=rn(A,f.dimension);u.push(M),await m(f.file,yn(M,f.dimension))}for(let f of d.font){let I=nn(f.dimension);u.push(I),await m(f.file,bn(I,f.dimension))}for(let f of d.color){let I=i.find(pe=>pe.brand===f.brand&&pe.mode===f.mode&&pe.surface===f.surface),{foundation:A,colors:M}=O(I),K=on(A,M);u.push(K),await m(f.file,hn(K,f.brand,f.mode,f.surface))}Ue(u),await m(Dn,Rn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:y}=O(d),f=_(u,y,d),I=xn(d);a.css&&await m(`css/${I}.css`,un(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${I}.d.ts`,In(f))}if(a.cssModes){let d=new Map;for(let u of i){let y=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(y)??{};f[u.mode]=u,d.set(y,f)}for(let[u,{light:y,dark:f}]of d){if(!y||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let I=O(y),A=O(f),M=pn(_(I.foundation,I.colors,y),_(A.foundation,A.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,M)}}if(a.tailwind){let d=i[0],{foundation:u,colors:y}=O(d),f=_(u,y,d);await m("tailwind/preset.mjs",cn(f)),await m("tailwind/tw-merge.mjs",ln(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(I=>I.brand===u).map(I=>{let{foundation:A,colors:M}=O(I);return _(A,M,I)});await m(`design/${u}.design.md`,fn(u,f))}}let k={configHash:ve(n),files:l,gitCommit:vn(r),buildEnv:wn()},w=Tn(k);return await(0,x.writeFile)((0,L.join)(c,"manifest.json"),w),await(0,x.rm)(o,{recursive:!0,force:!0}),await(0,x.mkdir)((0,L.dirname)(o),{recursive:!0}),await(0,x.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:k,outDir:o}}catch(l){throw await(0,x.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Mo,"build");async function Eo(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,x.readFile)((0,L.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==ve(n))return!1;for(let t of r.files){let i;try{i=await(0,x.readFile)((0,L.join)(o,t.path))}catch{return!1}if(ae(i)!==t.sha256)return!1}return!0}s(Eo,"check");async function Go(e,n,o){let r=(0,L.join)(e,n);await(0,x.mkdir)((0,L.dirname)(r),{recursive:!0}),await(0,x.writeFile)(r,o)}s(Go,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
var hn=Object.defineProperty;var s=(e,n)=>hn(e,"name",{value:n,configurable:!0}),yn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as fn,mkdtemp as mo,readFile as dn,rename as go,rm as pn,writeFile as mn}from"node:fs/promises";import{tmpdir as ho}from"node:os";import{dirname as gn,join as A}from"node:path";import{converter as An,parse as Nn}from"culori";import{defaultInputBorder as P}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Rn}from"@apollion-dsi/core/themes/colors";import{createDeth as In,levelValues as kn}from"@apollion-dsi/core/themes/depth";import{createFont as Sn,defaultInputFont as $}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as pe}from"@apollion-dsi/core/themes/spacing";import{converter as xn,formatHex as wn,parse as Tn}from"culori";import{DIMENSION_MULTIPLIERS as bn}from"@apollion-dsi/core/themes/dimension";function F({multiplier:e=.25,alias:n},o){let r=o!==void 0?bn[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(F,"createSpacing");var Q={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function ee(e){let n=Object.keys(Q).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(ee,"assertTokenMetaResolves");var vn=xn("oklch");function g(e){return typeof e.type=="string"&&"value"in e}s(g,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function fe(e){return e.split(".").map(I).join(".")}s(fe,"kebabPath");function V(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(V,"rawValue");function L(e,n){return Number(e.toFixed(n))||0}s(L,"round");function oe(e){let n=vn(Tn(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)],r=wn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:L(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(oe,"toColorValue");var me=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function C(e){let n=me.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(C,"toDimensionValue");function R(e){return{type:"color",value:oe(e)}}s(R,"colorToken");function ne(e){let n={};for(let[o,r]of Object.entries(e))n[o]=R(r);return n}s(ne,"recordColorGroup");function ge(e){let n=Rn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=R(t);return o.neutral=ne(n.neutral),o}s(ge,"buildReadableTextGroup");var Dn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function he(e){let n={};for(let o of Dn){let r=e[o];n[o]={base:R(r.base),dark:R(r.dark),action:R(r.action),active:R(r.active),light:R(r.light),onLight:R(r.onLight)}}return n.grayscale=ne(e.grayscale),n.neutral=ne(e.neutral),n.baseDark=R(e.baseDark??"#000000"),n.baseLight=R(e.baseLight??"#ffffff"),n.deepDark=R(e.deepDark??"#000000"),n.deepLight=R(e.deepLight??"#ffffff"),n}s(he,"buildColorPrimitives");function ye(e){let n=F(pe,e),o={};for(let r of Object.keys(pe.alias))o[r]={type:"dimension",value:C(n(r))};return o}s(ye,"buildSpacePrimitives");function be(){let e={};for(let[n,o]of Object.entries(P.borderWidth))e[n]={type:"dimension",value:C(o)};return e}s(be,"buildBorderWidthPrimitives");function $n(e,n){return{color:he(e),space:ye(n),borderWidth:be()}}s($n,"buildPrimitives");var Re={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},Ie={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Cn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(Cn,"lookupPrimitive");function _(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Cn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:oe(i)}}:R(i)}return r}s(_,"colorRefGroup");var ke={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Vn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function On(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!g(t)&&i in t)t=t[i];else return;return t&&g(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(On,"lookupDimensionPrimitive");function re(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?On(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:C(i)}}:{type:"dimension",value:C(i)}}return r}s(re,"dimensionRefGroup");function Se(e){let n={},o={};for(let[i,a]of Object.entries(P.borderRadius))me.test(a)?n[i]={type:"dimension",value:C(a)}:o[i]=a;let r=re(P.borderWidth,e,Vn),t={};for(let[i,a]of Object.entries(P.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Se,"buildBorder");function xe(e){let n=Sn($,e),o={};for(let[c,l]of Object.entries($.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:C(l)};let t={};for(let[c,l]of Object.entries($.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries($.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:$.letterSpacing,textTransform:$.textTransform,fontStyle:$.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(xe,"buildFont");var En=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Gn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(En),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>C(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:oe(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Gn,"parseShadow");function we(e){let n=In(e),o={};for(let r of Object.keys(kn))o[r]={type:"shadow",value:Gn(n(r))};return o}s(we,"buildShadow");function B(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(g(i)){o.add(a);let c=Q[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=B(i,a,o)}return r}s(B,"decorateGroup");function Mn(e){let n=new Set,o=B(e.primitives,"",n),r=B(e.groups,"",n);return ee(n),{...e,primitives:o,groups:r}}s(Mn,"decorateMeta");function H(e,n){return B(e,"",n)}s(H,"decorateSlice");function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);g(t)?o.add(i):Te(t,i,o)}}s(Te,"collectPaths");function ve(e){let n=new Set;for(let o of e)Te(o.groups,"",n);ee(n)}s(ve,"assertSlicesMetaComplete");function De(){let e=be(),o=Se({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:H({"border-width":e,border:o.group},t),extensions:r}}s(De,"buildBaseIR");function $e(e){let n=xe(e),o=new Set;return{groups:H({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s($e,"buildFontIR");function Ce(e,n){let o=he(n),r=new Set;return{groups:H({color:o,bg:_(e.bg,n,Re),text:_(e.text,n,Ie),tx:ge(n),shadow:we(n)},r),extensions:{}}}s(Ce,"buildColorIR");function Ve(e,n){let o=ye(n),r={space:o},t=new Set;return{groups:H({space:o,spacing:re(e.spacing,r,ke)},t),extensions:{}}}s(Ve,"buildSpacingIR");function jn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=$n(n,o.dimension),i=Se(t),a=xe(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:_(e.bg,n,Re),text:_(e.text,n,Ie),tx:ge(n),spacing:re(e.spacing,t,ke),border:i.group,font:a.group,shadow:we(n)},extensions:c};return Mn(l)}s(jn,"buildIR");var W=jn;var Fn=An("rgb"),Oe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function te(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(te,"colorPayload");function ie(e){return e.alpha===void 0}s(ie,"isOpaqueColor");function Ee(e){let n=Fn(Nn(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Ee,"rgbTriplet");function J(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(g(t))o.set(i.join("-"),t);else for(let[a,c]of J(t,i))o.set(a,c)}return o}s(J,"flatTokens");function h(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||g(o))return{};o=o[r]}return o&&!g(o)?o:{}}s(h,"groupAt");function Ge(e){let n=[];for(let o of["bg","text","tx"])for(let[r,t]of J(h(e.groups,o),[o])){let i=te(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:ie(i)})}return n}s(Ge,"colorEntries");function T(e,n){return[...J(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(T,"varEntries");function v(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(v,"pushScale");function Me(e){let n=[Oe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ge(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),v(n,"spacing",T(h(e.groups,"spacing"),["spacing"])),v(n,"borderRadius",T(h(e.groups,"border","radius"),["border","radius"])),v(n,"borderWidth",T(h(e.groups,"border","width"),["border","width"])),v(n,"fontFamily",T(h(e.groups,"font","family"),["font","family"])),v(n,"fontSize",T(h(e.groups,"font","size"),["font","size"])),v(n,"fontWeight",T(h(e.groups,"font","weight"),["font","weight"])),v(n,"lineHeight",T(h(e.groups,"font","lineHeight"),["font","line-height"])),v(n,"boxShadow",T(h(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`)}s(
|
|
4
|
-
`)}s(
|
|
1
|
+
var _n=Object.defineProperty;var s=(e,n)=>_n(e,"name",{value:n,configurable:!0}),Bn=(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 jn,mkdtemp as Ko,readFile as On,rename as Uo,rm as Nn,writeFile as Fn}from"node:fs/promises";import{tmpdir as Xo}from"node:os";import{dirname as Pn,join as W}from"node:path";import{converter as uo,parse as po}from"culori";import{defaultInputBorder as K}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as qn}from"@apollion-dsi/core/themes/colors";import{createDeth as Kn,levelValues as Un}from"@apollion-dsi/core/themes/depth";import{createFont as Xn,defaultInputFont as M}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Ve}from"@apollion-dsi/core/themes/spacing";import{converter as Yn,formatHex as Zn,parse as Qn}from"culori";import{defaultInputBreakpoints as Hn}from"@apollion-dsi/core/themes/breakpoints";function De(e=Hn){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s(De,"breakpointEntries");import{defaultInputContainerSizes as Wn,defaultInputLayout as zn}from"@apollion-dsi/core/themes/layout";function $e(e=Wn){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s($e,"containerSizeEntries");function Ce(e=zn){return[["page-max-width",`${e.pageMaxWidth}px`]]}s(Ce,"layoutEntries");import{DIMENSION_MULTIPLIERS as Jn}from"@apollion-dsi/core/themes/dimension";function J({multiplier:e=.25,alias:n},o){let r=o!==void 0?Jn[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(J,"createSpacing");var le={"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)."},"bg.canvas":{description:"Page ground \u2014 the theme canvas (never pure black in dark)."},"bg.paper":{description:"Component ground (cards, inputs, tables) \u2014 lighter than the canvas in both modes."},"bg.overlay":{description:"Top of the elevation ladder \u2014 modal / dialog panels."},"text.primary":{description:"Primary neutral ink \u2014 AA + APCA Lc \u2265 75 over bg.paper and bg.canvas."},"text.muted":{description:"Muted neutral ink \u2014 AA + APCA Lc \u2265 45 over bg.paper."},"edge.border":{description:"Default control outline \u2014 primary ink at 20 % alpha, legible on any ground."},"edge.hairline":{description:"Dividers and card outlines \u2014 primary ink at 10 % alpha."},"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 de(e){let n=Object.keys(le).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(de,"assertTokenMetaResolves");var eo=Yn("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function Le(e){return e.split(".").map(I).join(".")}s(Le,"kebabPath");function T(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(T,"rawValue");function q(e,n){return Number(e.toFixed(n))||0}s(q,"round");function ue(e){let n=eo(Qn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[q(n.l,4),q(n.c,4),q(n.h??0,2)],r=Zn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:q(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ue,"toColorValue");var Ae=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function w(e){let n=Ae.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(w,"toDimensionValue");function k(e){return{type:"color",value:ue(e)}}s(k,"colorToken");function E(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(E,"recordColorGroup");function Me(e){let n=qn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=E(n.neutral),o}s(Me,"buildReadableTextGroup");var no=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Ee(e){let n={};for(let o of no){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=E(e.grayscale),n.neutral=E(e.neutral),n.surface=E(e.surface),n.ink=E(e.ink),n.edge=E(e.edge),n.wash=E(e.wash),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}s(Ee,"buildColorPrimitives");function Ge(e){let n=J(Ve,e),o={};for(let r of Object.keys(Ve.alias))o[r]={type:"dimension",value:w(n(r))};return o}s(Ge,"buildSpacePrimitives");function Oe(){let e={};for(let[n,o]of Object.entries(K.borderWidth))e[n]={type:"dimension",value:w(o)};return e}s(Oe,"buildBorderWidthPrimitives");function oo(e,n){return{color:Ee(e),space:Ge(n),borderWidth:Oe()}}s(oo,"buildPrimitives");var Ne={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",canvas:"color.surface.canvas",sunken:"color.surface.sunken",paper:"color.surface.paper",raised:"color.surface.raised",overlay:"color.surface.overlay"},je={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight",primary:"color.ink.primary",secondary:"color.ink.secondary",muted:"color.ink.muted",disabled:"color.ink.disabled"},Fe={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function ro(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(ro,"lookupPrimitive");function N(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?ro(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ue(i)}}:k(i)}return r}s(N,"colorRefGroup");var Pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},to={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function io(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(io,"lookupDimensionPrimitive");function pe(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?io(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:w(i)}}:{type:"dimension",value:w(i)}}return r}s(pe,"dimensionRefGroup");function _e(e){let n={},o={};for(let[i,a]of Object.entries(K.borderRadius))Ae.test(a)?n[i]={type:"dimension",value:w(a)}:o[i]=a;let r=pe(K.borderWidth,e,to),t={};for(let[i,a]of Object.entries(K.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(_e,"buildBorder");function Be(e){let n=Xn(M,e),o={};for(let[c,l]of Object.entries(M.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:w(l)};let t={};for(let[c,l]of Object.entries(M.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(M.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:M.letterSpacing,textTransform:M.textTransform,fontStyle:M.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Be,"buildFont");var so=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function ao(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(so),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>w(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ue(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(ao,"parseShadow");function He(e){let n=Kn(e),o={};for(let r of Object.keys(Un))o[r]={type:"shadow",value:ao(n(r))};return o}s(He,"buildShadow");function U(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(h(i)){o.add(a);let c=le[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]=U(i,a,o)}return r}s(U,"decorateGroup");function co(e){let n=new Set,o=U(e.primitives,"",n),r=U(e.groups,"",n);return de(n),{...e,primitives:o,groups:r}}s(co,"decorateMeta");function X(e,n){return U(e,"",n)}s(X,"decorateSlice");function We(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);h(t)?o.add(i):We(t,i,o)}}s(We,"collectPaths");function ze(e){let n=new Set;for(let o of e)We(o.groups,"",n);de(n)}s(ze,"assertSlicesMetaComplete");function Je(){let e={};for(let[n,o]of De())e[n]={type:"dimension",value:w(o)};return e}s(Je,"buildBreakpoints");function qe(){let e={};for(let[n,o]of $e())e[n]={type:"dimension",value:w(o)};return e}s(qe,"buildContainerSizes");function Ke(){let e={};for(let[n,o]of Ce())e[n]={type:"dimension",value:w(o)};return e}s(Ke,"buildLayoutConstants");var Ue={unit:"px",interval:"half-open [value, next) \u2014 min-width sets, ascending",cssVarsUsage:"informational only \u2014 var() is invalid inside a @media prelude"};function Xe(){let e=Oe(),o=_e({borderWidth:e}),r={"com.apollion.breakpoint":Ue};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:X({"border-width":e,border:o.group,breakpoint:Je(),"container-size":qe(),layout:Ke()},t),extensions:r}}s(Xe,"buildBaseIR");function Ye(e){let n=Be(e),o=new Set;return{groups:X({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Ye,"buildFontIR");function Ze(e,n){let o=Ee(n),r=new Set;return{groups:X({color:o,bg:N(e.bg,n,Ne),text:N(e.text,n,je),edge:N(e.edge,n,Fe),tx:Me(n),shadow:He(n)},r),extensions:{}}}s(Ze,"buildColorIR");function Qe(e,n){let o=Ge(n),r={space:o},t=new Set;return{groups:X({space:o,spacing:pe(e.spacing,r,Pe)},t),extensions:{}}}s(Qe,"buildSpacingIR");function lo(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=oo(n,o.dimension),i=_e(t),a=Be(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions,"com.apollion.breakpoint":Ue};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:N(e.bg,n,Ne),text:N(e.text,n,je),edge:N(e.edge,n,Fe),tx:Me(n),spacing:pe(e.spacing,t,Pe),border:i.group,breakpoint:Je(),"container-size":qe(),layout:Ke(),font:a.group,shadow:He(n)},extensions:c};return co(l)}s(lo,"buildIR");var j=lo;var fo=uo("rgb"),en="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function fe(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(fe,"colorPayload");function me(e){return e.alpha===void 0}s(me,"isOpaqueColor");function nn(e){let n=fo(po(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(nn,"rgbTriplet");function P(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of P(t,i))o.set(a,c)}return o}s(P,"flatTokens");function y(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(y,"groupAt");function on(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of P(y(e.groups,o),[o])){let i=fe(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:me(i)})}return n}s(on,"colorEntries");function V(e,n){return[...P(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(V,"varEntries");function D(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(D,"pushScale");function rn(e){let n=[en,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=on(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),D(n,"screens",[...P(y(e.groups,"breakpoint"))].filter(([r])=>r!=="xs").map(([r,t])=>[r,T(t.value)])),D(n,"spacing",V(y(e.groups,"spacing"),["spacing"])),D(n,"borderRadius",V(y(e.groups,"border","radius"),["border","radius"])),D(n,"borderWidth",V(y(e.groups,"border","width"),["border","width"])),D(n,"fontFamily",V(y(e.groups,"font","family"),["font","family"])),D(n,"fontSize",V(y(e.groups,"font","size"),["font","size"])),D(n,"fontWeight",V(y(e.groups,"font","weight"),["font","weight"])),D(n,"lineHeight",V(y(e.groups,"font","lineHeight"),["font","line-height"])),D(n,"boxShadow",V(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(rn,"renderTailwindPreset");function tn(e){let n=s(t=>[...P(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[en,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(on(e).map(t=>t.key))},`,` spacing: ${o(n(y(e.groups,"spacing")))},`,` borderRadius: ${o(n(y(e.groups,"border","radius")))},`,` borderWidth: ${o(n(y(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(y(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(y(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(y(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(y(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(y(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(tn,"renderTwMergeExtension");var sn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Y(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?o.push(` --apollion-${i.join("-")}: ${T(t.value)};`):Y(t,i,o)}}s(Y,"emitVars");function Z(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(!h(t)){Z(t,i,o);continue}let a=fe(t);a&&me(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${nn(a)};`)}}s(Z,"emitRgbVars");function ge(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${T(t.value)}; }`):ge(t,i,o)}}s(ge,"emitProperties");function an(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[sn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),Y(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),Z(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ge(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(an,"renderCss");function cn(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:i,surface:a,dimension:c}=e.meta,l=[sn,""],m=s((S,d,u)=>{l.push(`${S} {`,` color-scheme: ${u};`),Y(d.groups,[],l),t&&Z(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${i} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),m(`:root, html[${r}="light"]`,e,"light"),m(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let b=[];Y(n.groups,[],b),t&&Z(n.groups,[],b);for(let S of b)l.push(` ${S}`);return l.push(" }","}",""),l.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ge(e.groups,[],l),l.push("}",""),l.join(`
|
|
5
|
+
`)}s(cn,"renderCssModes");var mo="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function he(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;h(t)?o.push([i,T(t.value)]):he(t,i,o)}}s(he,"flatten");function go(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(go,"yamlEscape");function ho(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(ho,"variantKey");function ln(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let i=[];he(t.groups,"",i),o.push(` ${ho(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${go(c)}`)}o.push("---");let r=["",mo,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];he(t.groups,"",l);let m=new Map;for(let[b,S]of l){let d=b.split(".")[0]??b,u=m.get(d)??[];u.push([b,S]),m.set(d,u)}for(let[b,S]of m){r.push(`### ${b}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of S)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
|
|
5
6
|
`)}
|
|
6
7
|
${r.join(`
|
|
7
|
-
`)}`}s(
|
|
8
|
-
`}s(
|
|
9
|
-
`}s(
|
|
10
|
-
`)}s(
|
|
11
|
-
`}s(
|
|
8
|
+
`)}`}s(ln,"renderDesignMd");function dn(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(dn,"colorValue");function _(e){return{value:e.value,unit:e.unit}}s(_,"dimensionValue");function yo(e){let n=e.shadow,o={color:dn(n.color),offsetX:_(n.offsetX),offsetY:_(n.offsetY),blur:_(n.blur),spread:_(n.spread)};return n.inset&&(o.inset=!0),o}s(yo,"shadowValue");function bo(e){switch(e.kind){case"ref":return`{${Le(e.path)}}`;case"color":return dn(e);case"dimension":return _(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return yo(e)}}s(bo,"projectValue");function Ro(e){let n={$value:bo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Ro,"projectToken");function ye(e){let n={};for(let[o,r]of Object.entries(e))n[I(o)]=h(r)?Ro(r):ye(r);return n}s(ye,"projectGroup");function Q(e,n){let o={$description:n,...ye(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}s(Q,"renderSet");function un(e){return Q(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(un,"renderBaseSet");function pn(e,n,o,r){return Q(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(pn,"renderColorSet");function fn(e,n){return Q(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(fn,"renderSpacingSet");function mn(e,n){return Q(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(mn,"renderFontSet");function gn(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
|
|
10
|
+
`}s(gn,"renderResolver");var ko="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Io(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(Io,"emitDoc");function hn(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))h(i)?(Io(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(T(i.value))},`)):(o.push(`${r}${t}: {`),hn(i,n+1,o),o.push(`${r}},`))}s(hn,"emitGroup");function yn(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[ko,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return hn(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
11
|
+
`)}s(yn,"renderTs");var xo=["light","dark"],So=["positive","negative"],vo=["compact","normal","spacious"];function ee(e){let n=e.modes??xo,o=e.surfaces??So,r=e.dimensions??vo,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let b of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:b});return i}s(ee,"expandVariants");function bn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(bn,"variantName");import{createHash as wo}from"node:crypto";function ne(e){return wo("sha256").update(e).digest("hex")}s(ne,"sha256");function Re(e){return ne(be(e))}s(Re,"hashConfig");function be(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(be).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${be(e[r])}`).join(",")}}`}s(be,"stableStringify");function Rn(e){try{let{execSync:n}=Bn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(Rn,"detectGitCommit");function kn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(kn,"buildEnv");function In(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
12
|
+
`}s(In,"serializeManifest");var To="json/sets",xn="json/resolver.json";function oe(e){return`${To}/${e}.json`}s(oe,"setFile");function Do(e,n,o){return`${e}.color.${n}.${o}`}s(Do,"colorSetName");function $o(e){return`spacing.${e}`}s($o,"spacingSetName");function Co(e){return`font.${e}`}s(Co,"fontSetName");function re(e,n){e.includes(n)||e.push(n)}s(re,"pushUnique");function Sn(e){let n=ee(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],b=new Set,S=[];for(let d of n){re(o,d.brand),re(r,d.mode),re(t,d.surface),re(i,d.dimension);let u=Do(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:oe(u),brand:d.brand,mode:d.mode,surface:d.surface}));let g=$o(d.dimension);l.has(g)||(l.add(g),m.push({kind:"spacing",name:g,file:oe(g),dimension:d.dimension}));let f=Co(d.dimension);b.has(f)||(b.add(f),S.push({kind:"font",name:f,file:oe(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:oe("base")},spacing:m,font:S,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Sn,"planSets");import{toDarkColors as Ho}from"@apollion-dsi/core/themes/colors";import{createFoundation as Gn}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Wo}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as zo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Jo}from"@apollion-dsi/core/themes/surface";import{converter as $n,formatHex as G,interpolate as Vo,parse as x,wcagContrast as Cn}from"culori";var H=$n("oklch"),Lo=$n("rgb");function p(e,n,o){let r=x(e),t=x(n);if(!r||!t)return e;let i=Vo([r,t],"oklch");return G(i(o))??e}s(p,"mixOklch");function Ao(e){return e?typeof e=="string"?e:e.base:"#000"}s(Ao,"coerceToHex");var te=1.3,Mo=.05,vn=.04,L=s((e,n)=>{let o=x(e),r=x(n);return!o||!r?1:Cn(o,r)},"contrastRatio"),ke=s(e=>{let n=H(x(e));return n?n.l??0:null},"oklchLightness"),Eo=4.5;function B(e,n,o=Eo){let r=x(n),t=H(x(e));if(!r||!t)return e;let i=L("#fff",n)>=L("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=G(t)??e,l=x(c);if(l&&Cn(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return G(t)??e}s(B,"readableColor");var wn=s((e,n)=>{if(L(e,n)>=te)return!0;let o=ke(e),r=ke(n);return o!==null&&r!==null&&Math.abs(o-r)>=Mo},"isPerceptibleState"),Ie=s(e=>e?L("#fff",e)>L("#000",e):!1,"isDarkSurface");function Tn(e,n,o){let r=H(x(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?vn:-vn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=G(t);if(l&&L(e,l)>=te)return l}return G(t)??null}s(Tn,"derivePerceptibleState");function Dn(e,n,o){let r=Tn(e,n,o);if(r&&L(e,r)>=te)return r;let t=Tn(e,!n);return t&&L(e,t)>=te?t:r??t}s(Dn,"perceptibleStateFor");function v(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=Ao(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if(x(r)){let c=Ie(n.baseLight),l=wn(r,a.action);if(l||(a.action=Dn(r,c)??a.action),!wn(r,a.active)){let m=l?void 0:ke(a.action)??void 0;a.active=Dn(r,c,m)??a.active}}if(a.onLight=B(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??B(c,l)}}return a}s(v,"mountSingleColor");function Vn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:p(n,o,.05),10:p(n,o,.1),20:p(n,o,.2),30:p(n,o,.3),40:p(n,o,.4),50:p(n,o,.5),60:p(n,o,.6),70:p(n,o,.7),80:p(n,o,.8),90:p(n,o,.9),100:p(n,o,1)}}s(Vn,"mountGreyscaleColors");function Ln(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(Ln,"mountNeutralColors");function F(e,n){let o=H(x(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return G({...o,l:r})??e}s(F,"shiftLightness");function ie(e,n){let o=H(x(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:G({...o,l:Math.min(i,Math.max(t,r))})??e}s(ie,"clampLightness");function O(e,n){let o=Lo(x(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(O,"toRgbaString");import{apcaContrast as se,EDGE_ALPHA as xe,HALATION_FLOORS as we,INK_APCA_MIN as Se,INK_MIX as ve,LADDER_DELTAS as ae,MIN_CONTRAST_AA as An,WASH_ALPHA as Go}from"@apollion-dsi/core/themes/colors";var Oo="#FFFFFF",Te="#000000";function No(e){return Ie(e.baseLight)?"dark":"light"}s(No,"resolvePolarity");function Mn(e,n,o){if(Math.abs(se(e,n))>=o)return e;let r=Math.abs(se("#ffffff",n))>=Math.abs(se("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=F(t,r?.02:-.02);if(a===t||(t=a,Math.abs(se(t,n))>=o))break}return t}s(Mn,"ensureApca");function jo(e,n){let o=e.baseLight??Oo,r=n==="dark",t=r?ie(o,{min:we.CANVAS_MIN_L}):o,i=F(t,ae.sunken);return{canvas:t,sunken:r?ie(i,{min:we.CANVAS_MIN_L}):i,paper:F(t,ae.paper),raised:F(t,ae.raised),overlay:F(t,ae.overlay),scrim:r?e.deepLight??Te:e.neutral?.["180"]??e.baseDark??Te}}s(jo,"deriveSurface");function Fo(e,n){let o=e.baseDark??Te,r=ie(Mn(B(o,n.paper,An),n.paper,Se.primary),{max:we.INK_MAX_L}),t=s((i,a)=>Mn(B(p(r,n.canvas,i),n.paper,An),n.paper,a),"tier");return{primary:r,secondary:t(ve.secondary,Se.secondary),muted:t(ve.muted,Se.muted),disabled:p(r,n.canvas,ve.disabled)}}s(Fo,"deriveInk");function Po(e){return{hairline:O(e.primary,xe.hairline),border:O(e.primary,xe.border),strong:O(e.primary,xe.strong)}}s(Po,"deriveEdge");function _o(e,n){let o=Go[n];return{hover:O(e.primary,o.hover),pressed:O(e.primary,o.pressed),selected:O(e.primary,o.selected)}}s(_o,"deriveWash");function Bo(e,n){return n?{surface:{...e.surface,...n.surface},ink:{...e.ink,...n.ink},edge:{...e.edge,...n.edge},wash:{...e.wash,...n.wash}}:e}s(Bo,"applyOverride");function En(e,n){let o=No(e),r=jo(e,o),t=Fo(e,r),i={surface:r,ink:t,edge:Po(t),wash:_o(t,o)};return Bo(i,n?.[o])}s(En,"resolveSurfaceLadder");function qo(e){let n=Ln(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:Vn(e),...En({...e,neutral:n},e.ladder),main:v(e.main,e),opposite:v(e.opposite,e),complementary:v(e.complementary,e),danger:v(e.danger,e),information:v(e.information,e),success:v(e.success,e),warning:v(e.warning,e),primary:v(e.primary,e),secondary:v(e.secondary,e),tertiary:v(e.tertiary,e)}}s(qo,"composeColors");function A(e,n=zo){let o=e.mode==="dark"?Ho(e.colors):e.colors,r=qo(o),t=J(n,e.dimension),i=Wo({colors:r,spacing:t}),a=Gn(i);return e.surface==="negative"&&(a=Gn(Jo({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(A,"buildVariantThemes");async function Tt(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=ee(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await Ko(W(Xo(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await Yo(c,d,u),l.push({path:d,sha256:ne(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=Sn(n),u=[],g=Xe();u.push(g),await m(d.base.file,un(g));for(let f of d.spacing){let R=i.find(z=>z.dimension===f.dimension),{foundation:$}=A(R),C=Qe($,f.dimension);u.push(C),await m(f.file,fn(C,f.dimension))}for(let f of d.font){let R=Ye(f.dimension);u.push(R),await m(f.file,mn(R,f.dimension))}for(let f of d.color){let R=i.find(ce=>ce.brand===f.brand&&ce.mode===f.mode&&ce.surface===f.surface),{foundation:$,colors:C}=A(R),z=Ze($,C);u.push(z),await m(f.file,pn(z,f.brand,f.mode,f.surface))}ze(u),await m(xn,gn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:g}=A(d),f=j(u,g,d),R=bn(d);a.css&&await m(`css/${R}.css`,an(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${R}.d.ts`,yn(f))}if(a.cssModes){let d=new Map;for(let u of i){let g=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(g)??{};f[u.mode]=u,d.set(g,f)}for(let[u,{light:g,dark:f}]of d){if(!g||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let R=A(g),$=A(f),C=cn(j(R.foundation,R.colors,g),j($.foundation,$.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,C)}}if(a.tailwind){let d=i[0],{foundation:u,colors:g}=A(d),f=j(u,g,d);await m("tailwind/preset.mjs",rn(f)),await m("tailwind/tw-merge.mjs",tn(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(R=>R.brand===u).map(R=>{let{foundation:$,colors:C}=A(R);return j($,C,R)});await m(`design/${u}.design.md`,ln(u,f))}}let b={configHash:Re(n),files:l,gitCommit:Rn(r),buildEnv:kn()},S=In(b);return await Fn(W(c,"manifest.json"),S),await Nn(o,{recursive:!0,force:!0}),await jn(Pn(o),{recursive:!0}),await Uo(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:b,outDir:o}}catch(l){throw await Nn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Tt,"build");async function Dt(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await On(W(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==Re(n))return!1;for(let t of r.files){let i;try{i=await On(W(o,t.path))}catch{return!1}if(ne(i)!==t.sha256)return!1}return!0}s(Dt,"check");async function Yo(e,n,o){let r=W(e,n);await jn(Pn(r),{recursive:!0}),await Fn(r,o)}s(Yo,"writeAt");export{Tt as build,Dt as check};
|
package/lib/builders/colors.d.ts
CHANGED
|
@@ -25,8 +25,24 @@
|
|
|
25
25
|
* @see ../../docs/prd/PRD-002-v4-epic-execution.md §S4
|
|
26
26
|
*/
|
|
27
27
|
import type { AcceptColorType, ColorPalleteInterface, ColorPalleteOverrideInterface, ColorsInput, GrayscaleColorsType, NeutralColorsType } from '@apollion-dsi/core/themes/colors';
|
|
28
|
+
/**
|
|
29
|
+
* OKLch perceptual lerp wrapper. See core's S2 docs for rationale.
|
|
30
|
+
*
|
|
31
|
+
* Validation: `spike/culori-oklch-lerp-parity` (preservada local — ADR-006
|
|
32
|
+
* §11.5) confirmou 0 unexpected regressions em 68 deltas; greyscale ramp
|
|
33
|
+
* 19× mais uniforme em OKLAB L space.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mixOklch(a: string, b: string, t: number): string;
|
|
28
36
|
/** Rotate hue 180° in OKLch space. Semantic shift vs HSL — see core for details. */
|
|
29
37
|
export declare function getOppositeColor(color: AcceptColorType): string;
|
|
38
|
+
/**
|
|
39
|
+
* Adjusts the OKLch L of `color` until it passes `minRatio` against `background`,
|
|
40
|
+
* preserving hue/chroma — **byte-for-byte mirror** of the core's `readableColor`
|
|
41
|
+
* (`Colors.helpers.ts`; parity.test.ts). Used to derive the tonal ink
|
|
42
|
+
* `onLight` (APOLLION-CONTRAST-GUARANTEE).
|
|
43
|
+
*/
|
|
44
|
+
export declare function readableColor(color: string, background: string, minRatio?: number): string;
|
|
45
|
+
export declare const isDarkSurface: (baseLight?: string) => boolean;
|
|
30
46
|
/**
|
|
31
47
|
* Derive `{ base, dark, action, active, light }` via OKLch lerp, with a
|
|
32
48
|
* mode-aware perceptual state floor on the interaction states — byte-for-byte
|
|
@@ -37,3 +53,14 @@ export declare function mountSingleColor(color: AcceptColorType | ColorPalleteOv
|
|
|
37
53
|
export declare function mountGreyscaleColors(colors: ColorsInput): Record<GrayscaleColorsType, string>;
|
|
38
54
|
/** 20-step neutral ramp anchored at n170 (primary mixed with darker). */
|
|
39
55
|
export declare function mountNeutralColors(colors: ColorsInput): Record<NeutralColorsType, string>;
|
|
56
|
+
/**
|
|
57
|
+
* Ladder primitives — Strangler Fig mirror of core's `shiftLightness` /
|
|
58
|
+
* `clampLightness` / `toRgbaString` (APOLLION-DARK-MODE-ENGINE S0). Byte parity
|
|
59
|
+
* enforced in `__tests__/parity.test.ts`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function shiftLightness(color: string, delta: number): string;
|
|
62
|
+
export declare function clampLightness(color: string, range: {
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
}): string;
|
|
66
|
+
export declare function toRgbaString(color: string, alpha: number): string;
|