@apollion-dsi/tokens 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/README.md +14 -14
- package/lib/build.cjs +6 -5
- package/lib/build.esm.js +6 -5
- package/lib/builders/colors.d.ts +35 -0
- package/lib/builders/foundation.d.ts +19 -0
- package/lib/builders/spacing.d.ts +12 -0
- package/lib/builders/surface.d.ts +16 -0
- package/lib/cli.mjs +8 -7
- package/lib/runtime/v1.d.ts +35 -0
- package/package.json +7 -5
- package/src/build.ts +60 -26
- package/src/ir.ts +330 -20
- package/src/renderers/dtcg-project.ts +108 -0
- package/src/renderers/json.ts +17 -99
- package/src/renderers/resolver.ts +129 -0
- package/src/set-plan.ts +136 -0
- package/src/token-meta.ts +86 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @apollion-dsi/tokens
|
|
2
|
+
|
|
3
|
+
## 4.3.0
|
|
4
|
+
|
|
5
|
+
## 4.2.0
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- 12ae4e0: feat(tokens): DTCG 2025.10 remainders — dimension references, per-token metadata, and Resolver (R5)
|
|
10
|
+
- **Spacing + composite sub-value references**: `spacing` and `border.width`
|
|
11
|
+
now reference primitive scales (`{space.*}`, `{border-width.*}`) instead of
|
|
12
|
+
inlining literals. The `space` primitives are built per density via
|
|
13
|
+
`createSpacing`, so references resolve correctly under compact/normal/spacious.
|
|
14
|
+
- **`$deprecated` + `$description` per token**: populated from a `TOKEN_META`
|
|
15
|
+
registry through the IR into the JSON output (a stale-key guard fails the
|
|
16
|
+
build if a meta entry points at a non-existent token).
|
|
17
|
+
- **DTCG Resolver (R5)**: the JSON surface now emits a single `resolver.json`
|
|
18
|
+
plus composable `sets/` (axis-invariant `base` + per-axis colour/spacing sets)
|
|
19
|
+
instead of one fully-resolved document per variant — a hard cutover, made
|
|
20
|
+
pre-GA. A composition-equivalence test proves `base + colour + spacing`
|
|
21
|
+
reproduces the old per-variant document exactly. The CSS and TS surfaces are
|
|
22
|
+
unchanged: still per-variant, fully resolved, byte-identical.
|
|
23
|
+
|
|
24
|
+
## 4.1.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- 063e0e9: Align `@apollion-dsi/tokens` DTCG output with the Design Tokens Format Module 2025.10.
|
|
29
|
+
- **Structured values:** `color` `$value` is now an OKLch object `{ colorSpace, components, hex, alpha? }` and `dimension` is `{ value, unit }` (was bare hex / length strings).
|
|
30
|
+
- **Typed IR:** a single intermediate representation (`src/ir.ts`) drives the JSON/CSS/TS renderers as pure projections.
|
|
31
|
+
- **Reference graph:** JSON emits a `color` primitives layer (structural SSOT) and foundation `bg`/`text` colours reference it via DTCG aliases (`{color.primary.base}`), with inline fallback when a resolved value diverges (e.g. surface inversion).
|
|
32
|
+
- **Composite tokens:** `border` (dimension / strokeStyle), `typography` (fontFamily / fontWeight / number + dimension) and `shadow` (DTCG shadow composite) now ship; values DTCG cannot model (em `letterSpacing`, `textTransform`, `fontStyle`, `100%` radius) travel in `$extensions` under `com.apollion.*`.
|
|
33
|
+
|
|
34
|
+
`@apollion-dsi/core` now exports the `themes/{border,depth,font}` subpaths so tokens consumes them as the single source of truth.
|
|
35
|
+
|
|
36
|
+
CSS/TS outputs for the existing `bg`/`text`/`spacing` layers are byte-identical; JSON is the spec-interop surface.
|
|
37
|
+
|
|
38
|
+
## 4.0.0
|
|
39
|
+
|
|
40
|
+
### Major Changes
|
|
41
|
+
|
|
42
|
+
- bd7d6cb: # v4.0.0 — OKLch + Dimension + Token Split
|
|
43
|
+
|
|
44
|
+
The v4 epic per [ADR-006](../packages/core/docs/adr/ADR-006-v4-oklch-dimension-token-split.md) + [PRD-002](../packages/core/docs/prd/PRD-002-v4-epic-execution.md). DS-from-scratch (Q-G grilling 2026-05-24); no consumer migration. Greenfield adoption via [MIGRATION-v4.md](../packages/core/docs/migration/MIGRATION-v4.md).
|
|
45
|
+
|
|
46
|
+
## Breaking — `@apollion-dsi/core@4.0.0`
|
|
47
|
+
- **Root barrel removed.** `import { Button } from '@apollion-dsi/core'` no longer works. Use granular subpaths (`@apollion-dsi/core/elements/button`). ESLint rule flips warn → error. ADR-001 Slice 6 finalized here. ADR-006 §3.7 E7.
|
|
48
|
+
- **OKLch palette derivation.** All `mount*Colors` helpers + `getOppositeColor` migrated from `color@5` RGB lerp to `culori@4` OKLch lerp. Validated by `spike/culori-oklch-lerp-parity` (0 unexpected regressions; greyscale 19× more uniform in OKLAB L). ADR-006 §2 B1 + §6 S2.
|
|
49
|
+
- **`defaultInputColors.opposite` token value changed.** OKLch hue rotation differs from HSL rotation (the OKLch is the perceptually correct opposite). Audit `theme.colors.opposite.*` consumers.
|
|
50
|
+
- **Dimension axis added.** `<ApollionProvider dimension="compact|normal|spacious">` is a new prop; default `normal` preserves v3.x spacing byte-exact. ADR-006 §6 S3.
|
|
51
|
+
- **`vendors/Color` eliminated.** Internal `color@5` vendor deleted (zero call-sites after S6 migration). `color` + `@types/color` removed from `package.json#dependencies`. WCAG functions migrated to `culori.wcagContrast` + `culori.wcagLuminance` (100% bit-exact parity per `spike/culori-wcag-parity`).
|
|
52
|
+
- **`invertForSurface(theme, surface, mode)` 3-arg signature.** `mode` is additive optional — existing 2-arg calls continue to work; `mode` is a placeholder for future PRD-003 mode-aware inversion. ADR-006 §6 S6.
|
|
53
|
+
|
|
54
|
+
## Minor — `@apollion-dsi/eslint-config`
|
|
55
|
+
- `culori` + `zod` added to `VENDORED_V4_LIBS` — must import via `vendors/Culori|Zod`.
|
|
56
|
+
- `color` removed from `VENDORED_T2_LIBS` (eliminated).
|
|
57
|
+
- `no-restricted-imports` for `'@apollion-dsi/core'` root: `warn` → `error` (per v4 barrel removal above).
|
|
58
|
+
|
|
59
|
+
## Major — `@apollion-dsi/tokens@4.0.0` (first release)
|
|
60
|
+
|
|
61
|
+
New package — framework-agnostic design tokens consumed via `runtime/v1` versioned API + `apollion-tokens build` CLI.
|
|
62
|
+
- **Strangler Fig builders** duplicated from core (`colors.ts`, `spacing.ts`); Foundation + Surface re-exported. Parity enforced by `__tests__/parity.test.ts`. ADR-006 §3.1 + §6 S4.
|
|
63
|
+
- **Atomic + idempotent build CLI.** `apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`. Emits `dist/{css,json,ts}/*` + `dist/manifest.json` with sha256 audit trail. Rerun byte-identical. `--check` mode for CI gate. ADR-006 §3.5 + §6 S5.
|
|
64
|
+
- **DTCG-compliant JSON output** (tech-radar R1).
|
|
65
|
+
- **`as const` TypeScript output** (tech-radar R4).
|
|
66
|
+
- **CSS `@property` declarations** (tech-radar R3) + custom properties `--apollion-{layer}-{role}-{variant}`.
|
|
67
|
+
- **Sandboxed `apollion.config.mjs` loader** (`node:vm` + zod schema) — threat-model T2+E1 mitigation. ADR-006 §3.8 B3 + §6 S6.
|
|
68
|
+
- **Lockstep version** with `@apollion-dsi/core` via `.changeset/config.json#fixed`.
|
|
69
|
+
|
|
70
|
+
## Minor — `@apollion-dsi/scripts`
|
|
71
|
+
- `codemods/v4-migrate.mjs` — one-way codemod (Q-G10: no `--revert`; DEX/Jovian/Fanaticofc don't consume v3.x, no legacy to revert). Transforms `invertForSurface` to 3-arg, flags `createTheme` for manual hoist to `apollion.config.mjs`. Transcript JSONL audit log.
|
|
72
|
+
- `verify-no-install-scripts.js` — supply-chain hardening; blocks `preinstall`/`install`/`postinstall` in `@apollion-dsi/*` workspaces (threat-model E2 mitigation).
|
|
73
|
+
|
|
74
|
+
## Spike validation (preserved local, NOT merged to main)
|
|
75
|
+
- `spike/culori-wcag-parity` — 100.0000% bit-exact culori vs color@5 (262 measurements / 10 palettes). `vendors/Color` elimination LOCKED.
|
|
76
|
+
- `spike/culori-oklch-lerp-parity` — 0 unexpected regressions in 68 deltas; greyscale ramp 19× more uniform in OKLAB L. DECISION ✅ PROCEED.
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [032f81c]
|
|
81
|
+
- Updated dependencies [32f7a1d]
|
|
82
|
+
- Updated dependencies [2dadba5]
|
|
83
|
+
- Updated dependencies [820a612]
|
|
84
|
+
- Updated dependencies [c056ee3]
|
|
85
|
+
- Updated dependencies [d032437]
|
|
86
|
+
- Updated dependencies [00e0525]
|
|
87
|
+
- Updated dependencies [1c87be8]
|
|
88
|
+
- Updated dependencies [d1192da]
|
|
89
|
+
- Updated dependencies [3194fba]
|
|
90
|
+
- Updated dependencies [f359982]
|
|
91
|
+
- Updated dependencies [5d17ebc]
|
|
92
|
+
- Updated dependencies [bd7d6cb]
|
|
93
|
+
- Updated dependencies [6545751]
|
|
94
|
+
- Updated dependencies [36eaf4a]
|
|
95
|
+
- Updated dependencies [802828f]
|
|
96
|
+
- Updated dependencies [e14469c]
|
|
97
|
+
- Updated dependencies [81cd55b]
|
|
98
|
+
- Updated dependencies [c57c548]
|
|
99
|
+
- Updated dependencies [879eedd]
|
|
100
|
+
- Updated dependencies [e2abc9c]
|
|
101
|
+
- Updated dependencies [75961a1]
|
|
102
|
+
- Updated dependencies [e55019a]
|
|
103
|
+
- Updated dependencies [fba9a41]
|
|
104
|
+
- Updated dependencies [3a90653]
|
|
105
|
+
- Updated dependencies [5fca933]
|
|
106
|
+
- Updated dependencies [ea3dc3a]
|
|
107
|
+
- Updated dependencies [51f71f6]
|
|
108
|
+
- Updated dependencies [0a1baeb]
|
|
109
|
+
- Updated dependencies [6d1371e]
|
|
110
|
+
- Updated dependencies [e55019a]
|
|
111
|
+
- Updated dependencies [29081ae]
|
|
112
|
+
- @apollion-dsi/core@4.0.0
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Framework-agnostic design tokens for Apollion Design System v4+.
|
|
4
4
|
|
|
5
|
-
**Status:**
|
|
5
|
+
**Status:** ✅ **GA @ 4.2.0** — v4 epic shipped 2026-05-25 (ADR-006). Lockstep com `@apollion-dsi/core@4.2.0`.
|
|
6
6
|
|
|
7
7
|
## Versioned API
|
|
8
8
|
|
|
@@ -19,14 +19,14 @@ import { TOKENS_RUNTIME_API_VERSION } from '@apollion-dsi/tokens/runtime/v1';
|
|
|
19
19
|
- **In:** OKLch palette derivation (S2/S4), Dimension axis (S3), Foundation/Surface builders (S4), build-time CSS/JSON/TS variant emission (S5), Config-First loader (S6).
|
|
20
20
|
- **Out:** Runtime React components (lives in `@apollion-dsi/core`), framework adapters (Vue/Flutter consumers consume `dist/json/*.json` directly).
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## JSON output (`dist/json/*.json`)
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Tokens em JSON estruturado — values are **structured objects**, not shorthand strings:
|
|
25
25
|
|
|
26
|
-
- `color` → `{ "colorSpace": "oklch", "components": [L, C, H], "hex": "#rrggbb" }` — OKLch working space
|
|
26
|
+
- `color` → `{ "colorSpace": "oklch", "components": [L, C, H], "hex": "#rrggbb" }` — OKLch working space + sRGB `hex` fallback. `alpha` emitted only when below 1.
|
|
27
27
|
- `dimension` → `{ "value": <number>, "unit": "rem" }`.
|
|
28
28
|
|
|
29
|
-
`dist/css/*.css` and `dist/ts/*.d.ts` stay string-based (hex / `rem`) — JSON is the
|
|
29
|
+
`dist/css/*.css` and `dist/ts/*.d.ts` stay string-based (hex / `rem`) — JSON is the interop surface; CSS/TS are the resolved consumer surfaces.
|
|
30
30
|
|
|
31
31
|
## Coupling to `@apollion-dsi/core`
|
|
32
32
|
|
|
@@ -38,15 +38,15 @@ Hard rule per ADR-006 §3.1:
|
|
|
38
38
|
|
|
39
39
|
## Slicing (ADR-006 §6)
|
|
40
40
|
|
|
41
|
-
| Slice
|
|
42
|
-
|
|
|
43
|
-
| S1 — scaffold + versioned API
|
|
44
|
-
| S2 — culori vendor + OKLch lerp
|
|
45
|
-
| S3 — Dimension axis
|
|
46
|
-
| S4 — builders
|
|
47
|
-
| S5 — atomic+idempotent build CLI
|
|
48
|
-
| S6 — Config-First + sandboxed loader
|
|
49
|
-
| S7 — release `4.0.0`
|
|
41
|
+
| Slice | Status | Deliverable |
|
|
42
|
+
| ------------------------------------ | ---------- | ------------------------------------------------- |
|
|
43
|
+
| S1 — scaffold + versioned API | ✅ shipped | `runtime/v1` namespace, esbuild ESM/CJS dual emit |
|
|
44
|
+
| S2 — culori vendor + OKLch lerp | ✅ shipped | `vendors/Culori` in core; OKLch palette |
|
|
45
|
+
| S3 — Dimension axis | ✅ shipped | `compact/normal/spacious` multipliers |
|
|
46
|
+
| S4 — Foundation/Surface builders | ✅ shipped | Strangler Fig parity with core |
|
|
47
|
+
| S5 — atomic+idempotent build CLI | ✅ shipped | `apollion-tokens build` + `dist/manifest.json` |
|
|
48
|
+
| S6 — Config-First + sandboxed loader | ✅ shipped | `apollion.config.mjs` + zod schema |
|
|
49
|
+
| S7 — release `4.0.0` | ✅ shipped | lockstep changesets with core |
|
|
50
50
|
|
|
51
51
|
## Refs
|
|
52
52
|
|
package/lib/build.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var s=(e,o)=>w(e,"name",{value:o,configurable:!0});var Re=(e,o)=>{for(var n in o)w(e,n,{get:o[n],enumerable:!0})},ke=(e,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of he(o))!be.call(e,i)&&i!==n&&w(e,i,{get:()=>o[i],enumerable:!(r=ye(o,i))||r.enumerable});return e};var Ie=e=>ke(w({},"__esModule",{value:!0}),e);var ze={};Re(ze,{build:()=>_e,check:()=>Je});module.exports=Ie(ze);var u=require("node:fs/promises"),de=require("node:os"),b=require("node:path");var C=require("@apollion-dsi/core/themes/border"),v=require("@apollion-dsi/core/themes/depth"),h=require("@apollion-dsi/core/themes/font"),k=require("culori");var xe=(0,k.converter)("oklch");function R(e){return typeof e.type=="string"&&"value"in e}s(R,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function W(e){return e.split(".").map(I).join(".")}s(W,"kebabPath");function x(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(x,"rawValue");function S(e,o){return Number(e.toFixed(o))||0}s(S,"round");function G(e){let o=xe((0,k.parse)(e));if(!o)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let n=[S(o.l,4),S(o.c,4),S(o.h??0,2)],r=(0,k.formatHex)(o)??"#000000";return o.alpha!==void 0&&o.alpha!==1?{kind:"color",raw:e,components:n,alpha:S(o.alpha,4),hex:r}:{kind:"color",raw:e,components:n,hex:r}}s(G,"toColorValue");var _=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function $(e){let o=_.exec(e.trim());if(o)return{kind:"dimension",raw:e,value:Number(o[1]),unit:o[2]};let n=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(n)?n:0,unit:"rem"}}s($,"toDimensionValue");function d(e){return{type:"color",value:G(e)}}s(d,"colorToken");function H(e){let o={};for(let[n,r]of Object.entries(e))o[n]=d(r);return o}s(H,"recordColorGroup");var De=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Ve(e){let o={};for(let n of De){let r=e[n];o[n]={base:d(r.base),dark:d(r.dark),action:d(r.action),active:d(r.active),light:d(r.light)}}return o.grayscale=H(e.grayscale),o.neutral=H(e.neutral),o.baseDark=d(e.baseDark??"#000000"),o.baseLight=d(e.baseLight??"#ffffff"),o.deepDark=d(e.deepDark??"#000000"),o.deepLight=d(e.deepLight??"#ffffff"),o}s(Ve,"buildPrimitives");var Te={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},we={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Se(e,o){let n=e;for(let r of o.split(".").slice(1))if(n&&typeof n=="object"&&r in n)n=n[r];else return;return typeof n=="string"?n:void 0}s(Se,"lookupPrimitive");function P(e,o,n){let r={};for(let[i,t]of Object.entries(e)){let c=n[i],l=c?Se(o,c):void 0;r[i]=c&&l===t?{type:"color",value:{kind:"ref",path:c,resolved:G(t)}}:d(t)}return r}s(P,"colorRefGroup");function Ce(e){let o={};for(let[n,r]of Object.entries(e))o[n]={type:"dimension",value:$(r)};return o}s(Ce,"dimensionGroup");function $e(){let e={},o={};for(let[i,t]of Object.entries(C.defaultInputBorder.borderRadius))_.test(t)?e[i]={type:"dimension",value:$(t)}:o[i]=t;let n={};for(let[i,t]of Object.entries(C.defaultInputBorder.borderWidth))n[i]={type:"dimension",value:$(t)};let r={};for(let[i,t]of Object.entries(C.defaultInputBorder.borderStyle))r[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:t,style:t}};return{group:{radius:e,width:n,style:r},extensions:o}}s($e,"buildBorder");function ve(){let e={};for(let[t,c]of Object.entries(h.defaultInputFont.fontFamily)){let l=c.replace(/;\s*$/,"").trim();e[t]={type:"fontFamily",value:{kind:"fontFamily",raw:l,family:l}}}let o={};for(let[t,c]of Object.entries(h.defaultInputFont.fontSize))o[t]={type:"dimension",value:{kind:"dimension",raw:`${c}px`,value:c,unit:"px"}};let n={};for(let[t,c]of Object.entries(h.defaultInputFont.fontWeight))n[t]={type:"fontWeight",value:{kind:"fontWeight",raw:`${c}`,weight:c}};let r={};for(let[t,c]of Object.entries(h.defaultInputFont.lineHeight))r[t]={type:"number",value:{kind:"number",raw:`${c}`,number:c}};let i={letterSpacing:h.defaultInputFont.letterSpacing,textTransform:h.defaultInputFont.textTransform,fontStyle:h.defaultInputFont.fontStyle};return{group:{family:e,size:o,weight:n,lineHeight:r},extensions:i}}s(ve,"buildFont");var Oe=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Fe(e){let o=e.trim(),n=o.startsWith("inset");n&&(o=o.slice(5).trim());let r=o.match(Oe),i=r?r[0]:"#000000",c=(r?o.slice(0,r.index).trim():o).split(/\s+/).filter(Boolean),l=s(p=>$(c[p]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:G(i),offsetX:l(0),offsetY:l(1),blur:l(2),spread:l(3),inset:n}}}s(Fe,"parseShadow");function je(e){let o=(0,v.createDeth)(e),n={};for(let r of Object.keys(v.levelValues))n[r]={type:"shadow",value:Fe(o(r))};return n}s(je,"buildShadow");function J(e,o,n){let r={brand:n.brand,mode:n.mode,surface:n.surface,dimension:n.dimension},i=$e(),t=ve(),c={"com.apollion.variant":r,"com.apollion.font":t.extensions};return Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions}),{description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:Ve(o),groups:{bg:P(e.bg,o,Te),text:P(e.text,o,we),spacing:Ce(e.spacing),border:i.group,font:t.group,shadow:je(o)},extensions:c}}s(J,"buildIR");var Ee="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function z(e,o,n){for(let[r,i]of Object.entries(e)){let t=[...o,I(r)];R(i)?n.push(` --apollion-${t.join("-")}: ${x(i.value)};`):z(i,t,n)}}s(z,"emitVars");function X(e,o,n){for(let[r,i]of Object.entries(e)){let t=[...o,I(r)];R(i)?i.type==="color"&&n.push(` @property --apollion-${t.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${x(i.value)}; }`):X(i,t,n)}}s(X,"emitProperties");function U(e){let{brand:o,mode:n,surface:r,dimension:i}=e.meta,t=[Ee,""];return t.push(`/* Variant: brand=${o} mode=${n} surface=${r} dimension=${i} */`,"",":root {"),z(e.groups,[],t),t.push("}",""),t.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),X(e.groups,[],t),t.push("}",""),t.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(
|
|
4
|
-
`
|
|
5
|
-
`}s(
|
|
1
|
+
"use strict";var j=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Xe=Object.prototype.hasOwnProperty;var s=(e,n)=>j(e,"name",{value:n,configurable:!0});var Ye=(e,n)=>{for(var o in n)j(e,o,{get:n[o],enumerable:!0})},qe=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of ze(n))!Xe.call(e,i)&&i!==o&&j(e,i,{get:()=>n[i],enumerable:!(r=Ue(n,i))||r.enumerable});return e};var Ke=e=>qe(j({},"__esModule",{value:!0}),e);var wn={};Ye(wn,{build:()=>Sn,check:()=>xn});module.exports=Ke(wn);var f=require("node:fs/promises"),Je=require("node:os"),x=require("node:path");var C=require("@apollion-dsi/core/themes/border"),L=require("@apollion-dsi/core/themes/depth"),S=require("@apollion-dsi/core/themes/font"),z=require("@apollion-dsi/core/themes/spacing"),v=require("culori");var te=require("@apollion-dsi/core/themes/dimension");function M({multiplier:e=.25,alias:n},o){let r=o!==void 0?te.DIMENSION_MULTIPLIERS[o]:e;return(...i)=>i.map(t=>{let a=typeof t=="string"?n[t]:t;return`${r*a}rem`}).join(" ")}s(M,"createSpacing");var J={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function U(e){let n=Object.keys(J).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(U,"assertTokenMetaResolves");var Ze=(0,v.converter)("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function R(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(R,"kebab");function se(e){return e.split(".").map(R).join(".")}s(se,"kebabPath");function V(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(V,"rawValue");function F(e,n){return Number(e.toFixed(n))||0}s(F,"round");function X(e){let n=Ze((0,v.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[F(n.l,4),F(n.c,4),F(n.h??0,2)],r=(0,v.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:F(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(X,"toColorValue");var ae=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function T(e){let n=ae.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(T,"toDimensionValue");function y(e){return{type:"color",value:X(e)}}s(y,"colorToken");function ie(e){let n={};for(let[o,r]of Object.entries(e))n[o]=y(r);return n}s(ie,"recordColorGroup");var Qe=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ce(e){let n={};for(let o of Qe){let r=e[o];n[o]={base:y(r.base),dark:y(r.dark),action:y(r.action),active:y(r.active),light:y(r.light)}}return n.grayscale=ie(e.grayscale),n.neutral=ie(e.neutral),n.baseDark=y(e.baseDark??"#000000"),n.baseLight=y(e.baseLight??"#ffffff"),n.deepDark=y(e.deepDark??"#000000"),n.deepLight=y(e.deepLight??"#ffffff"),n}s(ce,"buildColorPrimitives");function le(e){let n=M(z.defaultInputSpacing,e),o={};for(let r of Object.keys(z.defaultInputSpacing.alias))o[r]={type:"dimension",value:T(n(r))};return o}s(le,"buildSpacePrimitives");function de(){let e={};for(let[n,o]of Object.entries(C.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:T(o)};return e}s(de,"buildBorderWidthPrimitives");function en(e,n){return{color:ce(e),space:le(n),borderWidth:de()}}s(en,"buildPrimitives");var ue={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},pe={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function nn(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(nn,"lookupPrimitive");function A(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=o[i],l=a?nn(n,a):void 0;r[i]=a&&l===t?{type:"color",value:{kind:"ref",path:a,resolved:X(t)}}:y(t)}return r}s(A,"colorRefGroup");var fe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},on={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function rn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],i=e[r];for(let t of o.slice(1))if(i&&!h(i)&&t in i)i=i[t];else return;return i&&h(i)&&i.value.kind==="dimension"?i.value.raw:void 0}s(rn,"lookupDimensionPrimitive");function Y(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=o[i],l=a?rn(n,a):void 0;r[i]=a&&l===t?{type:"dimension",value:{kind:"ref",path:a,resolved:T(t)}}:{type:"dimension",value:T(t)}}return r}s(Y,"dimensionRefGroup");function me(e){let n={},o={};for(let[t,a]of Object.entries(C.defaultInputBorder.borderRadius))ae.test(a)?n[t]={type:"dimension",value:T(a)}:o[t]=a;let r=Y(C.defaultInputBorder.borderWidth,e,on),i={};for(let[t,a]of Object.entries(C.defaultInputBorder.borderStyle))i[t]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:i},extensions:o}}s(me,"buildBorder");function ge(){let e={};for(let[t,a]of Object.entries(S.defaultInputFont.fontFamily)){let l=a.replace(/;\s*$/,"").trim();e[t]={type:"fontFamily",value:{kind:"fontFamily",raw:l,family:l}}}let n={};for(let[t,a]of Object.entries(S.defaultInputFont.fontSize))n[t]={type:"dimension",value:{kind:"dimension",raw:`${a}px`,value:a,unit:"px"}};let o={};for(let[t,a]of Object.entries(S.defaultInputFont.fontWeight))o[t]={type:"fontWeight",value:{kind:"fontWeight",raw:`${a}`,weight:a}};let r={};for(let[t,a]of Object.entries(S.defaultInputFont.lineHeight))r[t]={type:"number",value:{kind:"number",raw:`${a}`,number:a}};let i={letterSpacing:S.defaultInputFont.letterSpacing,textTransform:S.defaultInputFont.textTransform,fontStyle:S.defaultInputFont.fontStyle};return{group:{family:e,size:n,weight:o,lineHeight:r},extensions:i}}s(ge,"buildFont");var tn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function sn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(tn),i=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),l=s(m=>T(a[m]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:X(i),offsetX:l(0),offsetY:l(1),blur:l(2),spread:l(3),inset:o}}}s(sn,"parseShadow");function ye(e){let n=(0,L.createDeth)(e),o={};for(let r of Object.keys(L.levelValues))o[r]={type:"shadow",value:sn(n(r))};return o}s(ye,"buildShadow");function N(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=n?`${n}.${R(i)}`:R(i);if(h(t)){o.add(a);let l=J[a];r[i]=l&&(l.description!==void 0||l.deprecated!==void 0)?{...t,...l.description!==void 0?{description:l.description}:{},...l.deprecated!==void 0?{deprecated:l.deprecated}:{}}:t}else r[i]=N(t,a,o)}return r}s(N,"decorateGroup");function an(e){let n=new Set,o=N(e.primitives,"",n),r=N(e.groups,"",n);return U(n),{...e,primitives:o,groups:r}}s(an,"decorateMeta");function q(e,n){return N(e,"",n)}s(q,"decorateSlice");function he(e,n,o){for(let[r,i]of Object.entries(e)){let t=n?`${n}.${R(r)}`:R(r);h(i)?o.add(t):he(i,t,o)}}s(he,"collectPaths");function be(e){let n=new Set;for(let o of e)he(o.groups,"",n);U(n)}s(be,"assertSlicesMetaComplete");function Re(){let e=de(),o=me({borderWidth:e}),r=ge(),i={"com.apollion.font":r.extensions};Object.keys(o.extensions).length>0&&(i["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:q({"border-width":e,border:o.group,font:r.group},t),extensions:i}}s(Re,"buildBaseIR");function Ie(e,n){let o=ce(n),r=new Set;return{groups:q({color:o,bg:A(e.bg,n,ue),text:A(e.text,n,pe),shadow:ye(n)},r),extensions:{}}}s(Ie,"buildColorIR");function ke(e,n){let o=le(n),r={space:o},i=new Set;return{groups:q({space:o,spacing:Y(e.spacing,r,fe)},i),extensions:{}}}s(ke,"buildSpacingIR");function cn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},i=en(n,o.dimension),t=me(i),a=ge(),l={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(t.extensions).length>0&&(l["com.apollion.border"]={radius:t.extensions});let m={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:i,groups:{bg:A(e.bg,n,ue),text:A(e.text,n,pe),spacing:Y(e.spacing,i,fe),border:t.group,font:a.group,shadow:ye(n)},extensions:l};return an(m)}s(cn,"buildIR");var Se=cn;var ln="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function xe(e,n,o){for(let[r,i]of Object.entries(e)){let t=[...n,R(r)];h(i)?o.push(` --apollion-${t.join("-")}: ${V(i.value)};`):xe(i,t,o)}}s(xe,"emitVars");function De(e,n,o){for(let[r,i]of Object.entries(e)){let t=[...n,R(r)];h(i)?i.type==="color"&&o.push(` @property --apollion-${t.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${V(i.value)}; }`):De(i,t,o)}}s(De,"emitProperties");function we(e){let{brand:n,mode:o,surface:r,dimension:i}=e.meta,t=[ln,""];return t.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${i} */`,"",":root {"),xe(e.groups,[],t),t.push("}",""),t.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),De(e.groups,[],t),t.push("}",""),t.join(`
|
|
2
|
+
`)}s(we,"renderCss");function Te(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}s(Te,"colorValue");function $(e){return{value:e.value,unit:e.unit}}s($,"dimensionValue");function dn(e){let n=e.shadow,o={color:Te(n.color),offsetX:$(n.offsetX),offsetY:$(n.offsetY),blur:$(n.blur),spread:$(n.spread)};return n.inset&&(o.inset=!0),o}s(dn,"shadowValue");function un(e){switch(e.kind){case"ref":return`{${se(e.path)}}`;case"color":return Te(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 dn(e)}}s(un,"projectValue");function pn(e){let n={$value:un(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(pn,"projectToken");function K(e){let n={};for(let[o,r]of Object.entries(e))n[R(o)]=h(r)?pn(r):K(r);return n}s(K,"projectGroup");function Z(e,n){let o={$description:n,...K(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(Z,"renderSet");function ve(e){return Z(e,"Apollion DS \u2014 base set (axis-invariant: border + font). DTCG 2025.10.")}s(ve,"renderBaseSet");function Ce(e,n,o,r){return Z(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(Ce,"renderColorSet");function Ve(e,n){return Z(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Ve,"renderSpacingSet");function $e(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]}],t={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing set for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.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}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(t,null,2)}
|
|
4
|
+
`}s($e,"renderResolver");var fn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Ge(e,n,o){let r=" ".repeat(n);for(let[i,t]of Object.entries(e))h(t)?o.push(`${r}${JSON.stringify(i)}: ${JSON.stringify(V(t.value))},`):(o.push(`${r}${i}: {`),Ge(t,n+1,o),o.push(`${r}},`))}s(Ge,"emitGroup");function Oe(e){let{brand:n,mode:o,surface:r,dimension:i}=e.meta,t=[fn,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${i}`,"","export const tokens = {"];return Ge(e.groups,1,t),t.push("} as const;","","export type Tokens = typeof tokens;",""),t.join(`
|
|
5
|
+
`)}s(Oe,"renderTs");var mn=["light","dark"],gn=["positive","negative"],yn=["compact","normal","spacious"];function P(e){let n=e.modes??mn,o=e.surfaces??gn,r=e.dimensions??yn,i=Object.entries(e.brands).sort(([a],[l])=>a.localeCompare(l)),t=[];for(let[a,l]of i)for(let m of n)for(let g of o)for(let d of r)t.push({brand:a,colors:l,mode:m,surface:g,dimension:d});return t}s(P,"expandVariants");function Ee(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Ee,"variantName");var je=require("node:crypto");function ee(e){return(0,je.createHash)("sha256").update(e).digest("hex")}s(ee,"sha256");function ne(e){return ee(Q(e))}s(ne,"hashConfig");function Q(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Q).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Q(e[r])}`).join(",")}}`}s(Q,"stableStringify");function Me(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(Me,"detectGitCommit");function Fe(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Fe,"buildEnv");function Ae(e){let n=[...e.files].sort((r,i)=>r.path.localeCompare(i.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
6
|
+
`}s(Ae,"serializeManifest");var hn="json/sets",Ne="json/resolver.json";function oe(e){return`${hn}/${e}.json`}s(oe,"setFile");function bn(e,n,o){return`${e}.color.${n}.${o}`}s(bn,"colorSetName");function Rn(e){return`spacing.${e}`}s(Rn,"spacingSetName");function B(e,n){e.includes(n)||e.push(n)}s(B,"pushUnique");function Le(e){let n=P(e),o=[],r=[],i=[],t=[],a=new Set,l=[],m=new Set,g=[];for(let d of n){B(o,d.brand),B(r,d.mode),B(i,d.surface),B(t,d.dimension);let D=bn(d.brand,d.mode,d.surface);a.has(D)||(a.add(D),l.push({kind:"color",name:D,file:oe(D),brand:d.brand,mode:d.mode,surface:d.surface}));let u=Rn(d.dimension);m.has(u)||(m.add(u),g.push({kind:"spacing",name:u,file:oe(u),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:oe("base")},spacing:g,color:l,modifiers:{brand:o,mode:r,surface:i,dimension:t}}}s(Le,"planSets");var re=require("@apollion-dsi/core/themes/foundation"),_e=require("@apollion-dsi/core/themes/semantic"),He=require("@apollion-dsi/core/themes/spacing"),We=require("@apollion-dsi/core/themes/surface");var k=require("culori");var eo=(0,k.converter)("oklch");function c(e,n,o){let r=(0,k.parse)(e),i=(0,k.parse)(n);if(!r||!i)return e;let t=(0,k.interpolate)([r,i],"oklch");return(0,k.formatHex)(t(o))??e}s(c,"mixOklch");function In(e){return e?typeof e=="string"?e:e.base:"#000"}s(In,"coerceToHex");function b(e,n){let o=In(e),r=n.deepDark,i=n.deepLight;return{base:o,dark:c(o,r,.6),action:c(o,r,.2),active:c(o,i,.6),light:c(o,i,.9)}}s(b,"mountSingleColor");function Pe(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:c(n,o,.05),10:c(n,o,.1),20:c(n,o,.2),30:c(n,o,.3),40:c(n,o,.4),50:c(n,o,.5),60:c(n,o,.6),70:c(n,o,.7),80:c(n,o,.8),90:c(n,o,.9),100:c(n,o,1)}}s(Pe,"mountGreyscaleColors");function Be(e){let n=e.deepLight,o=e.deepDark,r=e.primary,i=s(a=>1/17*(a-1),"interpolation"),t=c(r,o,.5);return{0:c(t,n,i(18)),5:c(t,n,i(17.5)),10:c(t,n,i(17)),20:c(t,n,i(16)),30:c(t,n,i(15)),40:c(t,n,i(14)),50:c(t,n,i(13)),60:c(t,n,i(12)),70:c(t,n,i(11)),80:c(t,n,i(10)),90:c(t,n,i(9)),100:c(t,n,i(8)),110:c(t,n,i(7)),120:c(t,n,i(6)),130:c(t,n,i(5)),140:c(t,n,i(4)),150:c(t,n,i(3)),160:c(t,n,i(2)),170:t,180:c(t,o,.25)}}s(Be,"mountNeutralColors");function kn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:Be(e),grayscale:Pe(e),main:b(e.main,e),opposite:b(e.opposite,e),complementary:b(e.complementary,e),danger:b(e.danger,e),information:b(e.information,e),success:b(e.success,e),warning:b(e.warning,e),primary:b(e.primary,e),secondary:b(e.secondary,e),tertiary:b(e.tertiary,e)}}s(kn,"composeColors");function _(e,n=He.defaultInputSpacing){let o=kn(e.colors),r=M(n,e.dimension),i=(0,_e.createSemantic)({colors:o,spacing:r}),t=(0,re.createFoundation)(i);return e.surface==="negative"&&(t=(0,re.createFoundation)((0,We.invertForSurface)({semantic:i,colors:o},"negative").semantic)),{foundation:t,colors:o}}s(_,"buildVariantThemes");async function Sn(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:i=!1}=e,t=P(n),a=n.output??{};if(t.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let l=await(0,f.mkdtemp)((0,x.join)((0,Je.tmpdir)(),"apollion-tokens-"));try{let m=[],g=s(async(u,I)=>{await Dn(l,u,I),m.push({path:u,sha256:ee(I)}),i&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Le(n),I=[],G=Re();I.push(G),await g(u.base.file,ve(G));for(let p of u.spacing){let w=t.find(E=>E.dimension===p.dimension),{foundation:H}=_(w),O=ke(H,p.dimension);I.push(O),await g(p.file,Ve(O,p.dimension))}for(let p of u.color){let w=t.find(W=>W.brand===p.brand&&W.mode===p.mode&&W.surface===p.surface),{foundation:H,colors:O}=_(w),E=Ie(H,O);I.push(E),await g(p.file,Ce(E,p.brand,p.mode,p.surface))}be(I),await g(Ne,$e(n,u))}if(a.css||a.ts)for(let u of t){let{foundation:I,colors:G}=_(u),p=Se(I,G,u),w=Ee(u);a.css&&await g(`css/${w}.css`,we(p)),a.ts&&await g(`ts/${w}.d.ts`,Oe(p))}let d={configHash:ne(n),files:m,gitCommit:Me(r),buildEnv:Fe()},D=Ae(d);return await(0,f.writeFile)((0,x.join)(l,"manifest.json"),D),await(0,f.rm)(o,{recursive:!0,force:!0}),await(0,f.mkdir)((0,x.dirname)(o),{recursive:!0}),await(0,f.rename)(l,o),i&&console.log(`\u2713 ${m.length} files \u2192 ${o}`),{manifest:d,outDir:o}}catch(m){throw await(0,f.rm)(l,{recursive:!0,force:!0}).catch(()=>{}),m}}s(Sn,"build");async function xn(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,f.readFile)((0,x.join)(o,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===ne(n)}s(xn,"check");async function Dn(e,n,o){let r=(0,x.join)(e,n);await(0,f.mkdir)((0,x.dirname)(r),{recursive:!0}),await(0,f.writeFile)(r,o)}s(Dn,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
var ue=Object.defineProperty;var s=(e,o)=>ue(e,"name",{value:o,configurable:!0}),pe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as ie,mkdtemp as Xe,readFile as Ue,rename as Ye,rm as te,writeFile as se}from"node:fs/promises";import{tmpdir as qe}from"node:os";import{dirname as ae,join as V}from"node:path";import{defaultInputBorder as $}from"@apollion-dsi/core/themes/border";import{createDeth as fe,levelValues as de}from"@apollion-dsi/core/themes/depth";import{defaultInputFont as g}from"@apollion-dsi/core/themes/font";import{converter as me,formatHex as ge,parse as ye}from"culori";var he=me("oklch");function y(e){return typeof e.type=="string"&&"value"in e}s(y,"isToken");function h(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(h,"kebab");function A(e){return e.split(".").map(h).join(".")}s(A,"kebabPath");function b(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(b,"rawValue");function x(e,o){return Number(e.toFixed(o))||0}s(x,"round");function v(e){let o=he(ye(e));if(!o)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let n=[x(o.l,4),x(o.c,4),x(o.h??0,2)],r=ge(o)??"#000000";return o.alpha!==void 0&&o.alpha!==1?{kind:"color",raw:e,components:n,alpha:x(o.alpha,4),hex:r}:{kind:"color",raw:e,components:n,hex:r}}s(v,"toColorValue");var N=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function D(e){let o=N.exec(e.trim());if(o)return{kind:"dimension",raw:e,value:Number(o[1]),unit:o[2]};let n=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(n)?n:0,unit:"rem"}}s(D,"toDimensionValue");function f(e){return{type:"color",value:v(e)}}s(f,"colorToken");function G(e){let o={};for(let[n,r]of Object.entries(e))o[n]=f(r);return o}s(G,"recordColorGroup");var be=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Re(e){let o={};for(let n of be){let r=e[n];o[n]={base:f(r.base),dark:f(r.dark),action:f(r.action),active:f(r.active),light:f(r.light)}}return o.grayscale=G(e.grayscale),o.neutral=G(e.neutral),o.baseDark=f(e.baseDark??"#000000"),o.baseLight=f(e.baseLight??"#ffffff"),o.deepDark=f(e.deepDark??"#000000"),o.deepLight=f(e.deepLight??"#ffffff"),o}s(Re,"buildPrimitives");var ke={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 xe(e,o){let n=e;for(let r of o.split(".").slice(1))if(n&&typeof n=="object"&&r in n)n=n[r];else return;return typeof n=="string"?n:void 0}s(xe,"lookupPrimitive");function L(e,o,n){let r={};for(let[i,t]of Object.entries(e)){let c=n[i],l=c?xe(o,c):void 0;r[i]=c&&l===t?{type:"color",value:{kind:"ref",path:c,resolved:v(t)}}:f(t)}return r}s(L,"colorRefGroup");function De(e){let o={};for(let[n,r]of Object.entries(e))o[n]={type:"dimension",value:D(r)};return o}s(De,"dimensionGroup");function Ve(){let e={},o={};for(let[i,t]of Object.entries($.borderRadius))N.test(t)?e[i]={type:"dimension",value:D(t)}:o[i]=t;let n={};for(let[i,t]of Object.entries($.borderWidth))n[i]={type:"dimension",value:D(t)};let r={};for(let[i,t]of Object.entries($.borderStyle))r[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:t,style:t}};return{group:{radius:e,width:n,style:r},extensions:o}}s(Ve,"buildBorder");function Te(){let e={};for(let[t,c]of Object.entries(g.fontFamily)){let l=c.replace(/;\s*$/,"").trim();e[t]={type:"fontFamily",value:{kind:"fontFamily",raw:l,family:l}}}let o={};for(let[t,c]of Object.entries(g.fontSize))o[t]={type:"dimension",value:{kind:"dimension",raw:`${c}px`,value:c,unit:"px"}};let n={};for(let[t,c]of Object.entries(g.fontWeight))n[t]={type:"fontWeight",value:{kind:"fontWeight",raw:`${c}`,weight:c}};let r={};for(let[t,c]of Object.entries(g.lineHeight))r[t]={type:"number",value:{kind:"number",raw:`${c}`,number:c}};let i={letterSpacing:g.letterSpacing,textTransform:g.textTransform,fontStyle:g.fontStyle};return{group:{family:e,size:o,weight:n,lineHeight:r},extensions:i}}s(Te,"buildFont");var we=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Se(e){let o=e.trim(),n=o.startsWith("inset");n&&(o=o.slice(5).trim());let r=o.match(we),i=r?r[0]:"#000000",c=(r?o.slice(0,r.index).trim():o).split(/\s+/).filter(Boolean),l=s(u=>D(c[u]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:v(i),offsetX:l(0),offsetY:l(1),blur:l(2),spread:l(3),inset:n}}}s(Se,"parseShadow");function Ce(e){let o=fe(e),n={};for(let r of Object.keys(de))n[r]={type:"shadow",value:Se(o(r))};return n}s(Ce,"buildShadow");function M(e,o,n){let r={brand:n.brand,mode:n.mode,surface:n.surface,dimension:n.dimension},i=Ve(),t=Te(),c={"com.apollion.variant":r,"com.apollion.font":t.extensions};return Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions}),{description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:Re(o),groups:{bg:L(e.bg,o,ke),text:L(e.text,o,Ie),spacing:De(e.spacing),border:i.group,font:t.group,shadow:Ce(o)},extensions:c}}s(M,"buildIR");var $e="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function B(e,o,n){for(let[r,i]of Object.entries(e)){let t=[...o,h(r)];y(i)?n.push(` --apollion-${t.join("-")}: ${b(i.value)};`):B(i,t,n)}}s(B,"emitVars");function H(e,o,n){for(let[r,i]of Object.entries(e)){let t=[...o,h(r)];y(i)?i.type==="color"&&n.push(` @property --apollion-${t.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${b(i.value)}; }`):H(i,t,n)}}s(H,"emitProperties");function P(e){let{brand:o,mode:n,surface:r,dimension:i}=e.meta,t=[$e,""];return t.push(`/* Variant: brand=${o} mode=${n} surface=${r} dimension=${i} */`,"",":root {"),B(e.groups,[],t),t.push("}",""),t.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),H(e.groups,[],t),t.push("}",""),t.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`}s(
|
|
4
|
-
`
|
|
5
|
-
`}s(
|
|
1
|
+
var Pe=Object.defineProperty;var s=(e,n)=>Pe(e,"name",{value:n,configurable:!0}),Be=(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 Ae,mkdtemp as wn,readFile as Tn,rename as vn,rm as Fe,writeFile as Ne}from"node:fs/promises";import{tmpdir as Cn}from"node:os";import{dirname as Le,join as A}from"node:path";import{defaultInputBorder as G}from"@apollion-dsi/core/themes/border";import{createDeth as He,levelValues as We}from"@apollion-dsi/core/themes/depth";import{defaultInputFont as I}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as K}from"@apollion-dsi/core/themes/spacing";import{converter as Je,formatHex as Ue,parse as ze}from"culori";import{DIMENSION_MULTIPLIERS as _e}from"@apollion-dsi/core/themes/dimension";function V({multiplier:e=.25,alias:n},o){let r=o!==void 0?_e[o]:e;return(...i)=>i.map(t=>{let a=typeof t=="string"?n[t]:t;return`${r*a}rem`}).join(" ")}s(V,"createSpacing");var P={"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 B(e){let n=Object.keys(P).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(B,"assertTokenMetaResolves");var Xe=Je("oklch");function y(e){return typeof e.type=="string"&&"value"in e}s(y,"isToken");function b(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(b,"kebab");function Q(e){return e.split(".").map(b).join(".")}s(Q,"kebabPath");function D(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(D,"rawValue");function $(e,n){return Number(e.toFixed(n))||0}s($,"round");function _(e){let n=Xe(ze(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[$(n.l,4),$(n.c,4),$(n.h??0,2)],r=Ue(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:$(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(_,"toColorValue");var ee=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function x(e){let n=ee.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(x,"toDimensionValue");function g(e){return{type:"color",value:_(e)}}s(g,"colorToken");function Z(e){let n={};for(let[o,r]of Object.entries(e))n[o]=g(r);return n}s(Z,"recordColorGroup");var Ye=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function ne(e){let n={};for(let o of Ye){let r=e[o];n[o]={base:g(r.base),dark:g(r.dark),action:g(r.action),active:g(r.active),light:g(r.light)}}return n.grayscale=Z(e.grayscale),n.neutral=Z(e.neutral),n.baseDark=g(e.baseDark??"#000000"),n.baseLight=g(e.baseLight??"#ffffff"),n.deepDark=g(e.deepDark??"#000000"),n.deepLight=g(e.deepLight??"#ffffff"),n}s(ne,"buildColorPrimitives");function oe(e){let n=V(K,e),o={};for(let r of Object.keys(K.alias))o[r]={type:"dimension",value:x(n(r))};return o}s(oe,"buildSpacePrimitives");function re(){let e={};for(let[n,o]of Object.entries(G.borderWidth))e[n]={type:"dimension",value:x(o)};return e}s(re,"buildBorderWidthPrimitives");function qe(e,n){return{color:ne(e),space:oe(n),borderWidth:re()}}s(qe,"buildPrimitives");var te={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},ie={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Ke(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(Ke,"lookupPrimitive");function O(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=o[i],l=a?Ke(n,a):void 0;r[i]=a&&l===t?{type:"color",value:{kind:"ref",path:a,resolved:_(t)}}:g(t)}return r}s(O,"colorRefGroup");var se={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Ze={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Qe(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],i=e[r];for(let t of o.slice(1))if(i&&!y(i)&&t in i)i=i[t];else return;return i&&y(i)&&i.value.kind==="dimension"?i.value.raw:void 0}s(Qe,"lookupDimensionPrimitive");function H(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=o[i],l=a?Qe(n,a):void 0;r[i]=a&&l===t?{type:"dimension",value:{kind:"ref",path:a,resolved:x(t)}}:{type:"dimension",value:x(t)}}return r}s(H,"dimensionRefGroup");function ae(e){let n={},o={};for(let[t,a]of Object.entries(G.borderRadius))ee.test(a)?n[t]={type:"dimension",value:x(a)}:o[t]=a;let r=H(G.borderWidth,e,Ze),i={};for(let[t,a]of Object.entries(G.borderStyle))i[t]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:i},extensions:o}}s(ae,"buildBorder");function ce(){let e={};for(let[t,a]of Object.entries(I.fontFamily)){let l=a.replace(/;\s*$/,"").trim();e[t]={type:"fontFamily",value:{kind:"fontFamily",raw:l,family:l}}}let n={};for(let[t,a]of Object.entries(I.fontSize))n[t]={type:"dimension",value:{kind:"dimension",raw:`${a}px`,value:a,unit:"px"}};let o={};for(let[t,a]of Object.entries(I.fontWeight))o[t]={type:"fontWeight",value:{kind:"fontWeight",raw:`${a}`,weight:a}};let r={};for(let[t,a]of Object.entries(I.lineHeight))r[t]={type:"number",value:{kind:"number",raw:`${a}`,number:a}};let i={letterSpacing:I.letterSpacing,textTransform:I.textTransform,fontStyle:I.fontStyle};return{group:{family:e,size:n,weight:o,lineHeight:r},extensions:i}}s(ce,"buildFont");var en=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function nn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(en),i=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),l=s(f=>x(a[f]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:_(i),offsetX:l(0),offsetY:l(1),blur:l(2),spread:l(3),inset:o}}}s(nn,"parseShadow");function le(e){let n=He(e),o={};for(let r of Object.keys(We))o[r]={type:"shadow",value:nn(n(r))};return o}s(le,"buildShadow");function E(e,n,o){let r={};for(let[i,t]of Object.entries(e)){let a=n?`${n}.${b(i)}`:b(i);if(y(t)){o.add(a);let l=P[a];r[i]=l&&(l.description!==void 0||l.deprecated!==void 0)?{...t,...l.description!==void 0?{description:l.description}:{},...l.deprecated!==void 0?{deprecated:l.deprecated}:{}}:t}else r[i]=E(t,a,o)}return r}s(E,"decorateGroup");function on(e){let n=new Set,o=E(e.primitives,"",n),r=E(e.groups,"",n);return B(n),{...e,primitives:o,groups:r}}s(on,"decorateMeta");function W(e,n){return E(e,"",n)}s(W,"decorateSlice");function de(e,n,o){for(let[r,i]of Object.entries(e)){let t=n?`${n}.${b(r)}`:b(r);y(i)?o.add(t):de(i,t,o)}}s(de,"collectPaths");function ue(e){let n=new Set;for(let o of e)de(o.groups,"",n);B(n)}s(ue,"assertSlicesMetaComplete");function pe(){let e=re(),o=ae({borderWidth:e}),r=ce(),i={"com.apollion.font":r.extensions};Object.keys(o.extensions).length>0&&(i["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:W({"border-width":e,border:o.group,font:r.group},t),extensions:i}}s(pe,"buildBaseIR");function fe(e,n){let o=ne(n),r=new Set;return{groups:W({color:o,bg:O(e.bg,n,te),text:O(e.text,n,ie),shadow:le(n)},r),extensions:{}}}s(fe,"buildColorIR");function me(e,n){let o=oe(n),r={space:o},i=new Set;return{groups:W({space:o,spacing:H(e.spacing,r,se)},i),extensions:{}}}s(me,"buildSpacingIR");function rn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},i=qe(n,o.dimension),t=ae(i),a=ce(),l={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(t.extensions).length>0&&(l["com.apollion.border"]={radius:t.extensions});let f={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:i,groups:{bg:O(e.bg,n,te),text:O(e.text,n,ie),spacing:H(e.spacing,i,se),border:t.group,font:a.group,shadow:le(n)},extensions:l};return on(f)}s(rn,"buildIR");var ge=rn;var tn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function ye(e,n,o){for(let[r,i]of Object.entries(e)){let t=[...n,b(r)];y(i)?o.push(` --apollion-${t.join("-")}: ${D(i.value)};`):ye(i,t,o)}}s(ye,"emitVars");function he(e,n,o){for(let[r,i]of Object.entries(e)){let t=[...n,b(r)];y(i)?i.type==="color"&&o.push(` @property --apollion-${t.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${D(i.value)}; }`):he(i,t,o)}}s(he,"emitProperties");function be(e){let{brand:n,mode:o,surface:r,dimension:i}=e.meta,t=[tn,""];return t.push(`/* Variant: brand=${n} mode=${o} surface=${r} dimension=${i} */`,"",":root {"),ye(e.groups,[],t),t.push("}",""),t.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),he(e.groups,[],t),t.push("}",""),t.join(`
|
|
2
|
+
`)}s(be,"renderCss");function Re(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(Re,"colorValue");function w(e){return{value:e.value,unit:e.unit}}s(w,"dimensionValue");function sn(e){let n=e.shadow,o={color:Re(n.color),offsetX:w(n.offsetX),offsetY:w(n.offsetY),blur:w(n.blur),spread:w(n.spread)};return n.inset&&(o.inset=!0),o}s(sn,"shadowValue");function an(e){switch(e.kind){case"ref":return`{${Q(e.path)}}`;case"color":return Re(e);case"dimension":return w(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return sn(e)}}s(an,"projectValue");function cn(e){let n={$value:an(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(cn,"projectToken");function J(e){let n={};for(let[o,r]of Object.entries(e))n[b(o)]=y(r)?cn(r):J(r);return n}s(J,"projectGroup");function U(e,n){let o={$description:n,...J(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
3
|
+
`}s(U,"renderSet");function Ie(e){return U(e,"Apollion DS \u2014 base set (axis-invariant: border + font). DTCG 2025.10.")}s(Ie,"renderBaseSet");function ke(e,n,o,r){return U(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(ke,"renderColorSet");function Se(e,n){return U(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Se,"renderSpacingSet");function xe(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]}],t={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing set for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.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}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(t,null,2)}
|
|
4
|
+
`}s(xe,"renderResolver");var ln="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function De(e,n,o){let r=" ".repeat(n);for(let[i,t]of Object.entries(e))y(t)?o.push(`${r}${JSON.stringify(i)}: ${JSON.stringify(D(t.value))},`):(o.push(`${r}${i}: {`),De(t,n+1,o),o.push(`${r}},`))}s(De,"emitGroup");function we(e){let{brand:n,mode:o,surface:r,dimension:i}=e.meta,t=[ln,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${i}`,"","export const tokens = {"];return De(e.groups,1,t),t.push("} as const;","","export type Tokens = typeof tokens;",""),t.join(`
|
|
5
|
+
`)}s(we,"renderTs");var dn=["light","dark"],un=["positive","negative"],pn=["compact","normal","spacious"];function j(e){let n=e.modes??dn,o=e.surfaces??un,r=e.dimensions??pn,i=Object.entries(e.brands).sort(([a],[l])=>a.localeCompare(l)),t=[];for(let[a,l]of i)for(let f of n)for(let m of o)for(let d of r)t.push({brand:a,colors:l,mode:f,surface:m,dimension:d});return t}s(j,"expandVariants");function Te(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(Te,"variantName");import{createHash as fn}from"node:crypto";function X(e){return fn("sha256").update(e).digest("hex")}s(X,"sha256");function Y(e){return X(z(e))}s(Y,"hashConfig");function z(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(z).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${z(e[r])}`).join(",")}}`}s(z,"stableStringify");function ve(e){try{let{execSync:n}=Be("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(ve,"detectGitCommit");function Ce(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(Ce,"buildEnv");function Ve(e){let n=[...e.files].sort((r,i)=>r.path.localeCompare(i.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
6
|
+
`}s(Ve,"serializeManifest");var mn="json/sets",$e="json/resolver.json";function q(e){return`${mn}/${e}.json`}s(q,"setFile");function gn(e,n,o){return`${e}.color.${n}.${o}`}s(gn,"colorSetName");function yn(e){return`spacing.${e}`}s(yn,"spacingSetName");function M(e,n){e.includes(n)||e.push(n)}s(M,"pushUnique");function Ge(e){let n=j(e),o=[],r=[],i=[],t=[],a=new Set,l=[],f=new Set,m=[];for(let d of n){M(o,d.brand),M(r,d.mode),M(i,d.surface),M(t,d.dimension);let k=gn(d.brand,d.mode,d.surface);a.has(k)||(a.add(k),l.push({kind:"color",name:k,file:q(k),brand:d.brand,mode:d.mode,surface:d.surface}));let u=yn(d.dimension);f.has(u)||(f.add(u),m.push({kind:"spacing",name:u,file:q(u),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:q("base")},spacing:m,color:l,modifiers:{brand:o,mode:r,surface:i,dimension:t}}}s(Ge,"planSets");import{createFoundation as Me}from"@apollion-dsi/core/themes/foundation";import{createSemantic as kn}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Sn}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as xn}from"@apollion-dsi/core/themes/surface";import{converter as hn,formatHex as bn,interpolate as Rn,parse as Oe}from"culori";var fo=hn("oklch");function c(e,n,o){let r=Oe(e),i=Oe(n);if(!r||!i)return e;let t=Rn([r,i],"oklch");return bn(t(o))??e}s(c,"mixOklch");function In(e){return e?typeof e=="string"?e:e.base:"#000"}s(In,"coerceToHex");function h(e,n){let o=In(e),r=n.deepDark,i=n.deepLight;return{base:o,dark:c(o,r,.6),action:c(o,r,.2),active:c(o,i,.6),light:c(o,i,.9)}}s(h,"mountSingleColor");function Ee(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:c(n,o,.05),10:c(n,o,.1),20:c(n,o,.2),30:c(n,o,.3),40:c(n,o,.4),50:c(n,o,.5),60:c(n,o,.6),70:c(n,o,.7),80:c(n,o,.8),90:c(n,o,.9),100:c(n,o,1)}}s(Ee,"mountGreyscaleColors");function je(e){let n=e.deepLight,o=e.deepDark,r=e.primary,i=s(a=>1/17*(a-1),"interpolation"),t=c(r,o,.5);return{0:c(t,n,i(18)),5:c(t,n,i(17.5)),10:c(t,n,i(17)),20:c(t,n,i(16)),30:c(t,n,i(15)),40:c(t,n,i(14)),50:c(t,n,i(13)),60:c(t,n,i(12)),70:c(t,n,i(11)),80:c(t,n,i(10)),90:c(t,n,i(9)),100:c(t,n,i(8)),110:c(t,n,i(7)),120:c(t,n,i(6)),130:c(t,n,i(5)),140:c(t,n,i(4)),150:c(t,n,i(3)),160:c(t,n,i(2)),170:t,180:c(t,o,.25)}}s(je,"mountNeutralColors");function Dn(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:je(e),grayscale:Ee(e),main:h(e.main,e),opposite:h(e.opposite,e),complementary:h(e.complementary,e),danger:h(e.danger,e),information:h(e.information,e),success:h(e.success,e),warning:h(e.warning,e),primary:h(e.primary,e),secondary:h(e.secondary,e),tertiary:h(e.tertiary,e)}}s(Dn,"composeColors");function F(e,n=Sn){let o=Dn(e.colors),r=V(n,e.dimension),i=kn({colors:o,spacing:r}),t=Me(i);return e.surface==="negative"&&(t=Me(xn({semantic:i,colors:o},"negative").semantic)),{foundation:t,colors:o}}s(F,"buildVariantThemes");async function Mo(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:i=!1}=e,t=j(n),a=n.output??{};if(t.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let l=await wn(A(Cn(),"apollion-tokens-"));try{let f=[],m=s(async(u,R)=>{await Vn(l,u,R),f.push({path:u,sha256:X(R)}),i&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=Ge(n),R=[],T=pe();R.push(T),await m(u.base.file,Ie(T));for(let p of u.spacing){let S=t.find(C=>C.dimension===p.dimension),{foundation:N}=F(S),v=me(N,p.dimension);R.push(v),await m(p.file,Se(v,p.dimension))}for(let p of u.color){let S=t.find(L=>L.brand===p.brand&&L.mode===p.mode&&L.surface===p.surface),{foundation:N,colors:v}=F(S),C=fe(N,v);R.push(C),await m(p.file,ke(C,p.brand,p.mode,p.surface))}ue(R),await m($e,xe(n,u))}if(a.css||a.ts)for(let u of t){let{foundation:R,colors:T}=F(u),p=ge(R,T,u),S=Te(u);a.css&&await m(`css/${S}.css`,be(p)),a.ts&&await m(`ts/${S}.d.ts`,we(p))}let d={configHash:Y(n),files:f,gitCommit:ve(r),buildEnv:Ce()},k=Ve(d);return await Ne(A(l,"manifest.json"),k),await Fe(o,{recursive:!0,force:!0}),await Ae(Le(o),{recursive:!0}),await vn(l,o),i&&console.log(`\u2713 ${f.length} files \u2192 ${o}`),{manifest:d,outDir:o}}catch(f){throw await Fe(l,{recursive:!0,force:!0}).catch(()=>{}),f}}s(Mo,"build");async function Fo(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await Tn(A(o,"manifest.json"),"utf8"))}catch{return!1}return r.configHash===Y(n)}s(Fo,"check");async function Vn(e,n,o){let r=A(e,n);await Ae(Le(r),{recursive:!0}),await Ne(r,o)}s(Vn,"writeAt");export{Mo as build,Fo as check};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OKLch palette builders — **Strangler Fig duplicate** of
|
|
3
|
+
* `@apollion-dsi/core/themes/colors` (ADR-006 §6 S4, PRD-002 §S4).
|
|
4
|
+
*
|
|
5
|
+
* **Strangler Fig contract:** this file DUPLICATES the implementation from
|
|
6
|
+
* `packages/core/src/themes/Colors/Colors.helpers.ts` (S2 OKLch migration).
|
|
7
|
+
* It does NOT delegate to core. Rationale:
|
|
8
|
+
*
|
|
9
|
+
* - Core remains SSOT for v4.x release line.
|
|
10
|
+
* - Tokens v4.0.0 ships standalone — consumer that opts into
|
|
11
|
+
* `@apollion-dsi/tokens` (via `optionalDependencies` in core) gets a
|
|
12
|
+
* self-contained palette derivation without runtime dep on core internals.
|
|
13
|
+
* - Future PRD-003 (post-v4) consolidates by deleting either copy after
|
|
14
|
+
* real consumer adoption validates the API surface.
|
|
15
|
+
*
|
|
16
|
+
* Parity is enforced via `__tests__/parity.test.ts`: given identical input,
|
|
17
|
+
* `core.mountSingleColor(...) === tokens.mountSingleColor(...)` for every
|
|
18
|
+
* exported function. Drift = build fail.
|
|
19
|
+
*
|
|
20
|
+
* Types are imported from core via the stable subpath
|
|
21
|
+
* `@apollion-dsi/core/themes/colors` (NOT the root barrel that gets removed
|
|
22
|
+
* in E7) — types ARE shared SSOT; only logic is duplicated.
|
|
23
|
+
*
|
|
24
|
+
* @see ../../docs/adr/ADR-006-v4-oklch-dimension-token-split.md §3.1 §6 S4
|
|
25
|
+
* @see ../../docs/prd/PRD-002-v4-epic-execution.md §S4
|
|
26
|
+
*/
|
|
27
|
+
import type { AcceptColorType, ColorPalleteInterface, ColorsInput, GrayscaleColorsType, NeutralColorsType } from '@apollion-dsi/core/themes/colors';
|
|
28
|
+
/** Rotate hue 180° in OKLch space. Semantic shift vs HSL — see core for details. */
|
|
29
|
+
export declare function getOppositeColor(color: AcceptColorType): string;
|
|
30
|
+
/** Derive `{ base, dark, action, active, light }` via OKLch lerp. */
|
|
31
|
+
export declare function mountSingleColor(color: AcceptColorType, colors: ColorsInput): ColorPalleteInterface;
|
|
32
|
+
/** 12-step greyscale ramp — perceptually uniform via OKLch lerp. */
|
|
33
|
+
export declare function mountGreyscaleColors(colors: ColorsInput): Record<GrayscaleColorsType, string>;
|
|
34
|
+
/** 20-step neutral ramp anchored at n170 (primary mixed with darker). */
|
|
35
|
+
export declare function mountNeutralColors(colors: ColorsInput): Record<NeutralColorsType, string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foundation builder — **interim re-export** from
|
|
3
|
+
* `@apollion-dsi/core/themes/foundation` (ADR-006 §6 S4, PRD-002 §S4).
|
|
4
|
+
*
|
|
5
|
+
* **Interim contract:** Foundation is complex (ADR-002 §3) and ships
|
|
6
|
+
* unchanged in v4. Tokens re-exports `createFoundation` from core via the
|
|
7
|
+
* stable subpath. Strangler Fig consolidation to standalone implementation
|
|
8
|
+
* is deferred to PRD-003 post-v4 if/when real consumer adoption justifies
|
|
9
|
+
* the duplication cost.
|
|
10
|
+
*
|
|
11
|
+
* Unlike `./colors.ts` and `./spacing.ts` (full duplicates because v4 logic
|
|
12
|
+
* is new), Foundation logic exists pre-v4 and parity is enforced trivially
|
|
13
|
+
* by re-export identity.
|
|
14
|
+
*
|
|
15
|
+
* @see ./colors.ts (Strangler Fig contract notes)
|
|
16
|
+
* @see ../../docs/adr/ADR-002-layered-theme-aliases-and-surface.md §3
|
|
17
|
+
*/
|
|
18
|
+
export { createFoundation } from '@apollion-dsi/core/themes/foundation';
|
|
19
|
+
export type { FoundationLayer } from '@apollion-dsi/core/themes/foundation';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spacing builder — **Strangler Fig duplicate** of
|
|
3
|
+
* `@apollion-dsi/core/themes/spacing` (ADR-006 §6 S4).
|
|
4
|
+
*
|
|
5
|
+
* Same dimension override semantics as core: when `dimension` arg
|
|
6
|
+
* provided, its calibrated multiplier wins over `input.multiplier`.
|
|
7
|
+
*
|
|
8
|
+
* @see ./colors.ts (Strangler Fig contract notes)
|
|
9
|
+
*/
|
|
10
|
+
import type { Dimension } from '@apollion-dsi/core/themes/dimension';
|
|
11
|
+
import type { SpacingInput, SpacingThemeInterface } from '@apollion-dsi/core/themes/spacing';
|
|
12
|
+
export declare function createSpacing({ multiplier, alias }: SpacingInput, dimension?: Dimension): SpacingThemeInterface;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface builder — **interim re-export** from
|
|
3
|
+
* `@apollion-dsi/core/themes/surface` (ADR-006 §6 S4, PRD-002 §S4).
|
|
4
|
+
*
|
|
5
|
+
* **Interim contract:** Surface ships unchanged in v4 S4. Tokens re-exports
|
|
6
|
+
* `invertForSurface` from core via the stable subpath. Surface-within-mode
|
|
7
|
+
* extension (E6 in S6) will REPLACE the signature to
|
|
8
|
+
* `invertForSurface(theme, surface, mode)`; tokens will update its re-export
|
|
9
|
+
* accordingly in S6.
|
|
10
|
+
*
|
|
11
|
+
* @see ./colors.ts (Strangler Fig contract notes)
|
|
12
|
+
* @see ../../docs/adr/ADR-002-layered-theme-aliases-and-surface.md §3
|
|
13
|
+
* @see ../../docs/adr/ADR-006-v4-oklch-dimension-token-split.md §3.6 (E6 in S6)
|
|
14
|
+
*/
|
|
15
|
+
export { invertForSurface } from '@apollion-dsi/core/themes/surface';
|
|
16
|
+
export type { SurfaceMode } from '@apollion-dsi/core/themes/surface';
|