@zappie/tokens 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zappie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2015 Dmitry Ivanov
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,170 @@
1
- # Temporary Holding Version
1
+ # @zappie/tokens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The closed, framework-independent theme contract for storefronts. No runtime dependencies, DOM access, or host imports. The package remains private until the public-package release phase.
4
+
5
+ ## Imports
6
+
7
+ ```ts
8
+ import { DEFAULT_THEME, TOKEN_NAMES, type ThemeJson } from '@zappie/tokens';
9
+ import { validateTheme, contrastRatio } from '@zappie/tokens/validate';
10
+ import { compileTheme, resolveTokens } from '@zappie/tokens/compile';
11
+ import { toCheckoutTheme } from '@zappie/tokens/checkout';
12
+ ```
13
+
14
+ The core exports token constants, defaults and types and stays below **4,000 bytes gzipped**, measured with every core export retained. Color parsing, validation, compilation and checkout projection are separate imports. Those entry points share build chunks but are outside the core budget. Types, including `CheckoutTheme`, can be imported from the core without pulling in runtime helpers.
15
+
16
+ ```css
17
+ @import '@zappie/tokens/tokens.css';
18
+ /* In a Tailwind v4 stylesheet, after importing Tailwind: */
19
+ @import '@zappie/tokens/tailwind.css';
20
+ ```
21
+
22
+ The default CSS is below **3,000 bytes uncompressed**. Tailwind aliases include `bg-z-surface`, `text-z-muted`, `rounded-z-md`, `p-z-4`, `font-z-display`, `text-z-lg`, `ease-z-out` and `duration-z-base`. Importing aliases alone does not assign runtime token values; also import the default CSS or supply compiled theme CSS.
23
+
24
+ ## Theme JSON
25
+
26
+ ```ts
27
+ const theme: ThemeJson = {
28
+ version: 1,
29
+ name: 'My store',
30
+ tokens: {
31
+ '--z-bg': '#fff',
32
+ '--z-text': '#101828',
33
+ '--z-accent': '#9FE870',
34
+ '--z-accent-contrast': '#163300',
35
+ },
36
+ logo: { light: '/logo.svg', alt: 'My store' },
37
+ fonts: [{ family: 'Inter', source: 'google', role: 'body', weights: [400, 700] }],
38
+ };
39
+ const result = validateTheme(theme);
40
+ if (!result.ok) console.error(result.issues);
41
+ else {
42
+ console.warn(result.warnings);
43
+ const css = compileTheme(result.theme, { scope: '[data-zappie-theme="store"]' });
44
+ // Install css using your framework's stylesheet pipeline.
45
+ }
46
+ ```
47
+
48
+ Only background, text, accent and accent-contrast are required. Missing values inherit defaults. Unknown fields and tokens are errors. Validation reports every issue in one pass: structural and syntax errors, plus effective light and dark contrast for every pair whose colours parse. Text/background, text/surface and accent-contrast/accent require 4.5:1; muted/background below 3:1 is a warning. Translucent foregrounds are composited; contrast backgrounds must be opaque. `contrastRatio()` returns `NaN` for unsupported colors or a translucent background.
49
+
50
+ Colors support hex (3/4/6/8 digits), named colors, `rgb()/rgba()`, `hsl()/hsla()` and `oklch()` converted to sRGB. Context-dependent colors (`var()`, `currentColor`) and injection syntax are rejected. Lengths support nonnegative px/rem/em/%/dvh/vh/vw, unitless zero, nested min/max/clamp, and calc with whitespace-separated addition/subtraction. Multiplication, division and variable references are outside this contract. Font families are unquoted comma-separated names, excluding CSS-wide keywords such as `inherit`; font declarations take one family each. Font roles must be unique, with at most three declarations. Self-hosted fonts require an HTTPS `.woff2` URL. Logo assets accept HTTPS or relative paths, with required alternative text.
51
+
52
+ `darkMode` defaults to `light`. `dark` inherits the theme's light values. An explicit dark choice on the root, `data-theme="dark"` or the `.dark` class the host and Tailwind use, applies the overrides in `light` and `auto`. Only `auto` also follows `prefers-color-scheme`, unless the root has `data-theme="light"`; `light` ignores the OS so a merchant's colours aren't decided by the visitor's system. `dark` is always dark. Scope accepts `:root`, one class/id, or one double-quoted data attribute selector. Google imports precede rules; self-hosted fonts emit `@font-face`. Font declarations apply globally even with scoped tokens. A declared font leads its role's token stack, keeping the theme's own stack as the fallback. Compilation validates its input and throws on errors.
53
+
54
+ `motion.reduce: true` zeros all duration tokens. Compiled themes always also honor `prefers-reduced-motion`. Components must consume those durations for the preference to affect their animations.
55
+
56
+ ## Checkout projection
57
+
58
+ ```ts
59
+ const checkoutTheme = toCheckoutTheme(theme, {
60
+ scheme: 'light', // Resolve auto mode using the caller's current scheme.
61
+ origin: 'https://shop.example', // Makes a relative logo absolute.
62
+ copy: { payButton: 'Pay now', successTitle: 'Thank you' },
63
+ onWarning: issue => console.warn(issue.message),
64
+ });
65
+ ```
66
+
67
+ The result is `{ version: 1, tokens, logo?, fonts?, copy? }` with only the 13 names in `CHECKOUT_TOKENS`. The checkout runs on its own origin, so the selected logo becomes an absolute `{ url, alt }`: a relative path is resolved against `origin` (HTTPS, or HTTP on localhost), and without one the logo is omitted with an `invalid_logo` warning. `fonts` lists the Google body and display fonts the checkout loads itself; self-hosted fonts are dropped with an `invalid_font` warning and fall back to the rest of the stack. Copy is limited to 40 Unicode code points per field; truncation calls `onWarning` (or `console.warn` when omitted). An omitted scheme uses dark only when `darkMode` is explicitly dark; auto needs a caller-supplied scheme. This workstream defines the payload; it does not wire the hosted checkout to it.
68
+
69
+ ## JSON Schema
70
+
71
+ The generated schema is exported at `@zappie/tokens/schema/theme.v1.json`. It provides editor structure/completion. Full validation requires its custom color/length formats and semantic keyword, because ordinary JSON Schema cannot calculate WCAG contrast or enforce unique font roles:
72
+
73
+ ```ts
74
+ import Ajv2020 from 'ajv/dist/2020.js';
75
+ import schema from '@zappie/tokens/schema/theme.v1.json';
76
+ import { themeFormats, themeSemanticsKeyword } from '@zappie/tokens/schema-runtime';
77
+
78
+ const ajv = new Ajv2020({ allErrors: true });
79
+ for (const [name, validate] of Object.entries(themeFormats)) ajv.addFormat(name, validate);
80
+ ajv.addKeyword(themeSemanticsKeyword);
81
+ const valid = ajv.compile(schema)(theme);
82
+ ```
83
+
84
+ AJV is a development dependency only; applications may use `validateTheme()` directly. Schema validation returns a boolean; use `validateTheme()` for detailed semantic issues and warnings. The declared remote schema URL is the intended registry location, not a deployment performed by this package.
85
+
86
+ ## Defaults and fixtures
87
+
88
+ Public defaults use system fonts; the host can continue using its licensed Cereal font through its own theme. The palette follows the existing host values in `styles/colors.ts`, inherited by the default template. `fixtures/default-template.theme.json` records this approved reference instead of the PRD's unavailable Inside Out PDF fixture. `valid-minimal`, `valid-full`, `low-contrast` and `unknown-token` cover validation and schema parity. Fixture logo/font URLs are illustrative and are not fetched by the package.
89
+
90
+ The table below is generated from the token constants and default values.
91
+
92
+ <!-- tokens:start -->
93
+ | Token | Default |
94
+ | --- | --- |
95
+ | `--z-bg` | `#F9FAFB` |
96
+ | `--z-surface` | `#FFFFFF` |
97
+ | `--z-surface-raised` | `#FFFFFF` |
98
+ | `--z-overlay` | `#00000080` |
99
+ | `--z-text` | `#101828` |
100
+ | `--z-text-muted` | `#344054` |
101
+ | `--z-text-inverse` | `#FFFFFF` |
102
+ | `--z-accent` | `#9FE870` |
103
+ | `--z-accent-contrast` | `#163300` |
104
+ | `--z-brand-1` | `#9FE870` |
105
+ | `--z-brand-2` | `#163300` |
106
+ | `--z-brand-3` | `#EDC843` |
107
+ | `--z-success` | `#027A48` |
108
+ | `--z-warning` | `#ED7A37` |
109
+ | `--z-danger` | `#F04438` |
110
+ | `--z-border` | `#EAECF0` |
111
+ | `--z-focus-ring` | `#163300` |
112
+ | `--z-radius-sm` | `6px` |
113
+ | `--z-radius-md` | `12px` |
114
+ | `--z-radius-lg` | `20px` |
115
+ | `--z-radius-pill` | `9999px` |
116
+ | `--z-space-1` | `4px` |
117
+ | `--z-space-2` | `8px` |
118
+ | `--z-space-3` | `12px` |
119
+ | `--z-space-4` | `16px` |
120
+ | `--z-space-5` | `24px` |
121
+ | `--z-space-6` | `32px` |
122
+ | `--z-space-7` | `48px` |
123
+ | `--z-space-8` | `64px` |
124
+ | `--z-text-xs` | `12px` |
125
+ | `--z-text-sm` | `14px` |
126
+ | `--z-text-md` | `16px` |
127
+ | `--z-text-lg` | `18px` |
128
+ | `--z-text-xl` | `20px` |
129
+ | `--z-text-2xl` | `24px` |
130
+ | `--z-text-3xl` | `32px` |
131
+ | `--z-drawer-width` | `420px` |
132
+ | `--z-dialog-width` | `min(1000px, calc(100vw - 32px))` |
133
+ | `--z-dialog-height` | `min(780px, 90dvh)` |
134
+ | `--z-media-sm` | `64px` |
135
+ | `--z-font-display` | `system-ui, sans-serif` |
136
+ | `--z-font-body` | `system-ui, sans-serif` |
137
+ | `--z-font-mono` | `ui-monospace, monospace` |
138
+ | `--z-duration-fast` | `120ms` |
139
+ | `--z-duration-base` | `200ms` |
140
+ | `--z-duration-slow` | `320ms` |
141
+ | `--z-ease-out` | `cubic-bezier(0, 0, 0.2, 1)` |
142
+ | `--z-ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` |
143
+ <!-- tokens:end -->
144
+
145
+ ## Migration from designTokens
146
+
147
+ Existing `StorefrontClientTemplateDefinition.designTokens` remains unchanged. When migrating a template in its own workstream:
148
+
149
+ 1. Map public styling to the closed semantic names. Keep decorative private variables in the template stylesheet, outside `theme.tokens`.
150
+ 2. Replace `--cart-review-dialog-width` and `--cart-review-dialog-height` with `--z-dialog-width` and `--z-dialog-height` in components that consume the new contract.
151
+ 3. Add version/name and the four required tokens. Move fonts to the `ThemeFont[]` form and provide `logo.alt`.
152
+ 4. Validate and compile the theme under the template's scope. Pass `toCheckoutTheme()` output to a checkout that supports the canonical payload.
153
+
154
+ This package does not rename variables in existing host components or migrate templates automatically.
155
+
156
+ ## Development
157
+
158
+ The Open Storefronts ESLint override requires braces around every conditional and loop body, with multiline blocks. It covers the public PRD packages (`tokens`, `sdk`, `foundations`, `kit`), themes and their workspace smoke test; it does not change the host or legacy SDK's style rules.
159
+
160
+ ```sh
161
+ pnpm --filter @zappie/tokens build
162
+ pnpm --filter @zappie/tokens check-generated
163
+ pnpm --filter @zappie/tokens size
164
+ pnpm vitest run packages/tokens
165
+ pnpm --filter @zappie/tokens check-types
166
+ ```
167
+
168
+ Build regenerates the schema, both CSS exports, and this token table from the source contract. Commit those generated files. CI checks their freshness and the size budgets. Tests live in `test/` because the repository reserves/excludes `tests/` for other test harnesses.
169
+
170
+ The CSS named-color lookup includes MIT-licensed data from color-name; see `LICENSE.color-name`.
@@ -0,0 +1,34 @@
1
+ import { T as ThemeJson, e as ThemeIssue } from './types-QqJ2gb0F.js';
2
+
3
+ declare const CHECKOUT_TOKENS: readonly ["--z-bg", "--z-surface", "--z-text", "--z-text-muted", "--z-accent", "--z-accent-contrast", "--z-border", "--z-danger", "--z-success", "--z-radius-md", "--z-radius-lg", "--z-font-body", "--z-font-display"];
4
+ /** A Google font the checkout loads itself; it can't reach the site's own font files. */
5
+ type CheckoutFont = {
6
+ family: string;
7
+ role: "body" | "display";
8
+ weights?: number[];
9
+ };
10
+ type CheckoutTheme = {
11
+ version: 1;
12
+ tokens: Partial<Record<(typeof CHECKOUT_TOKENS)[number], string>>;
13
+ logo?: {
14
+ url: string;
15
+ alt: string;
16
+ };
17
+ fonts?: CheckoutFont[];
18
+ copy?: {
19
+ payButton?: string;
20
+ successTitle?: string;
21
+ };
22
+ };
23
+ /**
24
+ * Project a theme onto the checkout contract. `origin` is the site's origin, used to make a
25
+ * relative logo absolute. Copy is capped at 40 Unicode code points.
26
+ */
27
+ declare function toCheckoutTheme(theme: ThemeJson, opts?: {
28
+ scheme?: "light" | "dark";
29
+ origin?: string;
30
+ copy?: CheckoutTheme["copy"];
31
+ onWarning?: (issue: ThemeIssue) => void;
32
+ }): CheckoutTheme;
33
+
34
+ export { CHECKOUT_TOKENS, type CheckoutFont, type CheckoutTheme, toCheckoutTheme };
@@ -0,0 +1 @@
1
+ import{a as f}from"./chunk-5NS3743Z.js";import{f as u}from"./chunk-QDQDBQAL.js";import"./chunk-3E5H65GJ.js";var h=["--z-bg","--z-surface","--z-text","--z-text-muted","--z-accent","--z-accent-contrast","--z-border","--z-danger","--z-success","--z-radius-md","--z-radius-lg","--z-font-body","--z-font-display"];function d(t,n){if(u(t,!1))return t;if(n===void 0)return null;try{let s=new URL(t,n),c=s.hostname==="localhost"||s.hostname==="127.0.0.1";return s.protocol==="https:"||s.protocol==="http:"&&c?s.href:null}catch{return null}}function p(t,n={}){let s=(e,o,i)=>{let a={path:e,code:o,message:i,severity:"warning"};n.onWarning?n.onWarning(a):console.warn(a.message,a.path)},c=n.scheme??(t.darkMode==="dark"?"dark":"light"),g=f(t,c),r={version:1,tokens:Object.fromEntries(h.map(e=>[e,g[e]]))};if(t.logo){let e=c==="dark"&&t.logo.dark?"dark":"light",o=d(t.logo[e],n.origin);o?r.logo={url:o,alt:t.logo.alt}:s(`logo.${e}`,"invalid_logo","A relative logo needs the site's HTTPS origin; the checkout logo was omitted")}let l=[];for(let[e,o]of(t.fonts??[]).entries())if(!(o.role==="mono"||o.source==="system")){if(o.source==="self"){s(`fonts[${e}]`,"invalid_font","Checkout loads Google fonts only; it falls back to the rest of the font stack");continue}l.push({family:o.family,role:o.role,...o.weights?{weights:[...o.weights]}:{}})}if(l.length&&(r.fonts=l),n.copy){r.copy={};for(let e of["payButton","successTitle"]){let o=n.copy[e];if(o===void 0)continue;let i=Array.from(o);r.copy[e]=i.slice(0,40).join(""),i.length>40&&s(`copy.${e}`,"copy_truncated","Checkout copy was truncated to 40 characters")}}return r}export{h as CHECKOUT_TOKENS,p as toCheckoutTheme};
@@ -0,0 +1 @@
1
+ var e=["--z-bg","--z-surface","--z-surface-raised","--z-overlay","--z-text","--z-text-muted","--z-text-inverse","--z-accent","--z-accent-contrast","--z-brand-1","--z-brand-2","--z-brand-3","--z-success","--z-warning","--z-danger","--z-border","--z-focus-ring"],t=["--z-radius-sm","--z-radius-md","--z-radius-lg","--z-radius-pill","--z-space-1","--z-space-2","--z-space-3","--z-space-4","--z-space-5","--z-space-6","--z-space-7","--z-space-8","--z-text-xs","--z-text-sm","--z-text-md","--z-text-lg","--z-text-xl","--z-text-2xl","--z-text-3xl","--z-drawer-width","--z-dialog-width","--z-dialog-height","--z-media-sm"],s=["--z-font-display","--z-font-body","--z-font-mono"],z=["--z-duration-fast","--z-duration-base","--z-duration-slow"],a=["--z-ease-out","--z-ease-in-out"],o=[...z,...a],n=[...e,...t,...s,...o],c=["--z-bg","--z-text","--z-accent","--z-accent-contrast"];var r=Object.freeze({"--z-bg":"#F9FAFB","--z-surface":"#FFFFFF","--z-surface-raised":"#FFFFFF","--z-overlay":"#00000080","--z-text":"#101828","--z-text-muted":"#344054","--z-text-inverse":"#FFFFFF","--z-accent":"#9FE870","--z-accent-contrast":"#163300","--z-brand-1":"#9FE870","--z-brand-2":"#163300","--z-brand-3":"#EDC843","--z-success":"#027A48","--z-warning":"#ED7A37","--z-danger":"#F04438","--z-border":"#EAECF0","--z-focus-ring":"#163300","--z-radius-sm":"6px","--z-radius-md":"12px","--z-radius-lg":"20px","--z-radius-pill":"9999px","--z-space-1":"4px","--z-space-2":"8px","--z-space-3":"12px","--z-space-4":"16px","--z-space-5":"24px","--z-space-6":"32px","--z-space-7":"48px","--z-space-8":"64px","--z-font-display":"system-ui, sans-serif","--z-font-body":"system-ui, sans-serif","--z-font-mono":"ui-monospace, monospace","--z-text-xs":"12px","--z-text-sm":"14px","--z-text-md":"16px","--z-text-lg":"18px","--z-text-xl":"20px","--z-text-2xl":"24px","--z-text-3xl":"32px","--z-duration-fast":"120ms","--z-duration-base":"200ms","--z-duration-slow":"320ms","--z-ease-out":"cubic-bezier(0, 0, 0.2, 1)","--z-ease-in-out":"cubic-bezier(0.4, 0, 0.2, 1)","--z-drawer-width":"420px","--z-dialog-width":"min(1000px, calc(100vw - 32px))","--z-dialog-height":"min(780px, 90dvh)","--z-media-sm":"64px"}),x=Object.freeze({version:1,name:"Zappie",tokens:r,darkMode:"light",dark:Object.freeze({"--z-bg":"#000000","--z-surface":"#242424","--z-surface-raised":"#333333","--z-text":"#FFFFFF","--z-text-muted":"#BFBFBF","--z-text-inverse":"#101828","--z-border":"#474747","--z-focus-ring":"#9FE870"})});export{e as a,t as b,s as c,z as d,a as e,o as f,n as g,c as h,r as i,x as j};
@@ -0,0 +1,4 @@
1
+ import{h as k}from"./chunk-QDQDBQAL.js";import{d as p,g as l,i as g}from"./chunk-3E5H65GJ.js";function h(o){let c=k(o);if(!c.ok)throw new TypeError(c.issues.map(r=>`${r.path}: ${r.message}`).join(`
2
+ `))}function $(o,c){h(o);let r={...g,...o.tokens,...c==="dark"?o.dark:{}};for(let n of o.fonts??[]){let a=`--z-font-${n.role}`,i=r[a],d=i.split(",")[0].trim().toLowerCase();r[a]=d===n.family.toLowerCase()?i:`${n.family}, ${i}`}if(o.motion?.reduce)for(let n of p)r[n]="0ms";return r}var w=':is([data-theme="dark"],.dark)';function N(o,c={}){let r=c.scope??":root";if(!/^(:root|[.#][a-zA-Z_][\w-]*|\[data-[\w-]+="[\w-]+"\])$/.test(r))throw new TypeError("Invalid theme scope");let n=$(o,o.darkMode==="dark"?"dark":"light"),a=(t,e,f)=>`${t}{${l.filter(s=>e[s]!==void 0).map(s=>`${s}:${e[s]};`).join("")}${f?`color-scheme:${f};`:""}}`,i=[],d=(o.fonts??[]).filter(t=>t.source==="google");d.length&&i.push(`@import url("https://fonts.googleapis.com/css2?${d.map(t=>`family=${encodeURIComponent(t.family)}${t.weights?.length?":wght@"+[...new Set(t.weights)].sort((e,f)=>e-f).join(";"):""}`).join("&")}&display=swap");`);for(let t of o.fonts??[])if(t.source==="self")for(let e of t.weights??[400])i.push(`@font-face{font-family:"${t.family}";src:url("${t.url}") format("woff2");font-weight:${e};font-display:swap;}`);let u=o.darkMode==="dark"?"dark":"light",m=[...i,a(r,n,u)];if(o.darkMode!=="dark"&&o.dark){let t=$(o,"dark"),e=Object.fromEntries(l.filter(s=>t[s]!==n[s]).map(s=>[s,t[s]])),f=s=>r===":root"?`:root${s}`:`:root${s} ${r}`;o.darkMode==="auto"&&m.push(`@media(prefers-color-scheme:dark){${a(f(':not([data-theme="light"])'),e,"dark")}}`),m.push(a(f(w),e,"dark"))}return m.push(`@media(prefers-reduced-motion:reduce){${a(r,Object.fromEntries(p.map(t=>[t,"0ms"])))}}`),m.join(`
3
+ `)+`
4
+ `}export{$ as a,N as b};
@@ -0,0 +1 @@
1
+ import{a as q,b as A,c as z,d as S,g as I,h as L,i as j}from"./chunk-3E5H65GJ.js";var N={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};var R=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,k=e=>e.length<=512&&!/[;{}<>\\\x00-\x1f]|\/\*|url\s*\(|expression\s*\(/i.test(e),v=e=>Math.max(0,Math.min(1,e));function h(e,i=1){let t=e.endsWith("%"),s=t?e.slice(0,-1):e,l=R.test(s)?Number(s)/(t?100:i):NaN;return Number.isFinite(l)?l:NaN}function U(e){let i=/^(.*?)(deg|rad|grad|turn)?$/.exec(e);if(!i||!R.test(i[1]))return NaN;let t={deg:1,rad:180/Math.PI,grad:.9,turn:360};return Number(i[1])*(t[i[2]??"deg"]??1)}function b(e){if(!k(e))return null;let i=e.trim().toLowerCase();if(i==="transparent")return[0,0,0,0];if(Object.prototype.hasOwnProperty.call(N,i)&&(i="#"+N[i]),/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/.test(i)){let f=i.slice(1);return f.length<5&&(f=[...f].map(u=>u+u).join("")),f.length===6&&(f+="ff"),[0,2,4,6].map(u=>parseInt(f.slice(u,u+2),16)/255)}let t=/^(rgba?|hsla?|oklch)\(([^()]*)\)$/.exec(i);if(!t)return null;let s=t[1],l=t[2].trim(),a=l.includes(",");if(a&&(l.includes("/")||s==="oklch"))return null;let r=a?l.split(",").map(f=>f.trim()):l.split(/\s*\/\s*/),n,o;if(a){if(r.length!==3&&r.length!==4)return null;n=r.slice(0,3),o=r[3]}else{if(r.length>2)return null;n=r[0].split(/\s+/),o=r[1]}if(n.length!==3)return null;let d=o===void 0?1:h(o),c;if(s.startsWith("rgb")){if(a&&n.some(f=>f.endsWith("%"))&&!n.every(f=>f.endsWith("%")))return null;c=n.map(f=>h(f,255))}else if(s.startsWith("hsl")){if(!n[1].endsWith("%")||!n[2].endsWith("%"))return null;let f=(U(n[0])%360+360)%360,u=v(h(n[1])),m=v(h(n[2])),g=u*Math.min(m,1-m);c=[0,8,4].map(w=>{let y=(w+f/30)%12;return m-g*Math.max(-1,Math.min(y-3,9-y,1))})}else{let f=v(h(n[0])),u=Math.max(0,h(n[1])*(n[1].endsWith("%")?.4:1)),m=U(n[2])*Math.PI/180,g=u*Math.cos(m),w=u*Math.sin(m),y=(f+.3963377774*g+.2158037573*w)**3,$=(f-.1055613458*g-.0638541728*w)**3,T=(f-.0894841775*g-1.291485548*w)**3;c=[4.0767416621*y-3.3077115913*$+.2309699292*T,-1.2684380046*y+2.6097574011*$-.3413193965*T,-.0041960863*y-.7034186147*$+1.707614701*T].map(E=>E<=.0031308?12.92*E:1.055*E**(1/2.4)-.055)}return[...c,d].every(Number.isFinite)?[...c.map(v),v(d)]:null}function O(e,i=0){if(!k(e)||i>8)return!1;let t=e.trim();if(/^(?:0|(?:\d+(?:\.\d*)?|\.\d+)(?:px|rem|em|%|dvh|vh|vw))$/.test(t))return!0;let s=/^(min|max|clamp|calc)\((.*)\)$/.exec(t);if(!s)return!1;let l=0,a=0,r=[];for(let n=0;n<s[2].length;n++){let o=s[2][n];if(o==="("&&l++,o===")"&&--l<0)return!1;let d=s[1]==="calc"?(o==="+"||o==="-")&&/\s/.test(s[2][n-1]??"")&&/\s/.test(s[2][n+1]??""):o===",";l===0&&d&&(r.push(s[2].slice(a,n)),a=n+1)}return r.push(s[2].slice(a)),l===0&&(s[1]!=="clamp"||r.length===3)&&r.every(n=>O(n,i+1))}var K=/^(?:inherit|initial|unset|revert|revert-layer|default)$/i;function M(e){return k(e)&&e.split(",").every(i=>{let t=i.trim();return/^[a-zA-Z][a-zA-Z0-9 -]*$/.test(t)&&!K.test(t)})}function W(e){return/^(?:\d+(?:\.\d+)?|\.\d+)(?:ms|s)$/.test(e)}function F(e){if(/^(linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/.test(e))return!0;let i=/^cubic-bezier\((.*)\)$/.exec(e);if(!i)return!1;let t=i[1].split(",").map(s=>R.test(s.trim())?h(s.trim()):NaN);return t.length===4&&t.every(Number.isFinite)&&t[0]>=0&&t[0]<=1&&t[2]>=0&&t[2]<=1}function _(e,i=!0){if(!e||!k(e)||/[\s"'()]/.test(e))return!1;if(i&&!/^[a-z][\w+.-]*:/i.test(e)&&!e.startsWith("//"))return!0;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function C(e,i){let t=b(e),s=b(i);if(!t||!s||s[3]!==1)return NaN;let l=n=>n.map(o=>o<=.04045?o/12.92:((o+.055)/1.055)**2.4).reduce((o,d,c)=>o+d*[.2126,.7152,.0722][c],0),a=l(t.slice(0,3).map((n,o)=>n*t[3]+s[o]*(1-t[3]))),r=l(s.slice(0,3));return(Math.max(a,r)+.05)/(Math.min(a,r)+.05)}var p=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),x=(e,i)=>e.includes(i);function X(e){let i=[],t=(a,r,n,o="error")=>i.push({path:a,code:r,message:n,severity:o}),s=(a,r,n)=>{for(let o of Object.keys(a))r.includes(o)||t(n?`${n}.${o}`:o,"invalid_theme","Unknown field")};if(!p(e))return{ok:!1,issues:[{path:"",code:"invalid_theme",message:"Expected a theme object",severity:"error"}]};s(e,["$schema","version","name","tokens","dark","darkMode","fonts","logo","motion"],""),e.version!==1&&t("version","invalid_theme","Expected version 1"),(typeof e.name!="string"||!e.name.trim()||e.name.length>100)&&t("name","missing_required","Expected a name of 1\u2013100 characters"),e.$schema!==void 0&&(typeof e.$schema!="string"||!_(e.$schema,!1))&&t("$schema","invalid_theme","Expected an HTTPS schema URL"),e.darkMode!==void 0&&(typeof e.darkMode!="string"||!["auto","light","dark"].includes(e.darkMode))&&t("darkMode","invalid_theme","Expected auto, light or dark");for(let a of["tokens","dark"]){let r=e[a];if(!(a==="dark"&&r===void 0)){if(!p(r)){t(a,"missing_required","Expected a token object");continue}if(a==="tokens")for(let n of L)Object.prototype.hasOwnProperty.call(r,n)||t(`${a}.${n}`,"missing_required","Required token");for(let[n,o]of Object.entries(r)){let d=`${a}.${n}`;if(!x(I,n)){t(d,"unknown_token","Unknown semantic token");continue}let c,f=!1;x(q,n)?(c="invalid_color",f=typeof o=="string"&&b(o)!==null):x(A,n)?(c="invalid_length",f=typeof o=="string"&&O(o)):x(z,n)?(c="invalid_font",f=typeof o=="string"&&M(o)):(c="invalid_motion",f=typeof o=="string"&&k(o)&&(x(S,n)?W(o):F(o))),f||t(d,c,"Invalid or unsafe token value")}}}if(e.fonts!==void 0)if(!Array.isArray(e.fonts)||e.fonts.length>3)t("fonts","invalid_font","Expected at most three fonts");else{let a=new Set;e.fonts.forEach((r,n)=>{let o=`fonts[${n}]`;if(!p(r)){t(o,"invalid_font","Expected a font object");return}s(r,["family","source","url","weights","role"],o),(typeof r.family!="string"||!M(r.family)||r.family.includes(","))&&t(`${o}.family`,"invalid_font","Expected one unquoted font family"),(typeof r.source!="string"||!["google","self","system"].includes(r.source))&&t(`${o}.source`,"invalid_font","Unknown font source"),(typeof r.role!="string"||!["display","body","mono"].includes(r.role)||a.has(r.role))&&t(`${o}.role`,"invalid_font","Expected a unique font role"),a.add(String(r.role)),(r.source==="self"||r.url!==void 0)&&(typeof r.url!="string"||!_(r.url,!1)||!new URL(r.url).pathname.endsWith(".woff2"))&&t(`${o}.url`,"invalid_font","Expected an HTTPS .woff2 URL"),r.weights!==void 0&&(!Array.isArray(r.weights)||!r.weights.length||r.weights.length>9||r.weights.some(d=>typeof d!="number"||!Number.isInteger(d)||d<1||d>1e3))&&t(`${o}.weights`,"invalid_font","Expected 1\u20139 integer weights between 1 and 1000")})}if(e.logo!==void 0)if(!p(e.logo))t("logo","invalid_logo","Expected a logo object");else{s(e.logo,["light","dark","mark","alt"],"logo"),(typeof e.logo.alt!="string"||!e.logo.alt.trim())&&t("logo.alt","invalid_logo","Logo alternative text is required");for(let a of["light","dark","mark"]){let r=e.logo[a];(a==="light"||r!==void 0)&&(typeof r!="string"||!_(r))&&t(`logo.${a}`,"invalid_logo","Expected HTTPS or a relative asset path")}}e.motion!==void 0&&(p(e.motion)?(s(e.motion,["reduce"],"motion"),e.motion.reduce!==void 0&&typeof e.motion.reduce!="boolean"&&t("motion.reduce","invalid_motion","Expected a boolean")):t("motion","invalid_motion","Expected a motion object"));let l=a=>p(a)?a:{};for(let a of p(e.dark)?["tokens","dark"]:["tokens"]){let r={...j,...l(e.tokens),...a==="dark"?l(e.dark):{}},n=[["--z-text","--z-bg",4.5,"error"],["--z-text","--z-surface",4.5,"error"],["--z-accent-contrast","--z-accent",4.5,"error"],["--z-text-muted","--z-bg",3,"warning"]];for(let[o,d,c,f]of n){let u=r[o],m=r[d];if(typeof u!="string"||typeof m!="string"||!b(u)||!b(m))continue;let g=C(u,m);Number.isFinite(g)?g<c&&t(`${a}.${o}`,"low_contrast",`Contrast against ${d} must be at least ${c}:1`,f):t(`${a}.${d}`,"unverified_contrast","A contrast background must be opaque","error")}}return i.some(a=>a.severity==="error")?{ok:!1,issues:i}:{ok:!0,theme:e,warnings:i}}export{b as a,O as b,M as c,W as d,F as e,_ as f,C as g,X as h};
@@ -0,0 +1,14 @@
1
+ import { T as ThemeJson, a as TokenName } from './types-QqJ2gb0F.js';
2
+
3
+ /** Fill every token; dark overrides inherit the theme's light values. Returns a fresh object. */
4
+ declare function resolveTokens(theme: ThemeJson, scheme: "light" | "dark"): Record<TokenName, string>;
5
+ /**
6
+ * Compile validated themes to CSS. Scope accepts :root, one class/id or one data attribute.
7
+ * `auto` follows the OS unless the root is explicitly light; `light` ignores the OS but still
8
+ * honours an explicit dark choice; `dark` is always dark.
9
+ */
10
+ declare function compileTheme(theme: ThemeJson, opts?: {
11
+ scope?: string;
12
+ }): string;
13
+
14
+ export { compileTheme, resolveTokens };
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-5NS3743Z.js";import"./chunk-QDQDBQAL.js";import"./chunk-3E5H65GJ.js";export{b as compileTheme,a as resolveTokens};
@@ -0,0 +1,9 @@
1
+ import { T as ThemeJson, a as TokenName } from './types-QqJ2gb0F.js';
2
+ export { C as COLOR_TOKENS, b as ColorToken, D as DURATION_TOKENS, E as EASING_TOKENS, F as FONT_TOKENS, L as LENGTH_TOKENS, M as MOTION_TOKENS, R as REQUIRED_TOKENS, c as TOKEN_NAMES, d as ThemeFont, e as ThemeIssue, f as ThemeValidation, g as TokenValues } from './types-QqJ2gb0F.js';
3
+ export { CheckoutFont, CheckoutTheme } from './checkout.js';
4
+
5
+ /** Host palette from styles/colors.ts; public fonts use a licence-free system stack. */
6
+ declare const DEFAULT_TOKENS: Readonly<Record<TokenName, string>>;
7
+ declare const DEFAULT_THEME: ThemeJson;
8
+
9
+ export { DEFAULT_THEME, DEFAULT_TOKENS, ThemeJson, TokenName };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{a as e,b as T,c as o,d as E,e as N,f as t,g as O,h as m,i as r,j as S}from"./chunk-3E5H65GJ.js";export{e as COLOR_TOKENS,S as DEFAULT_THEME,r as DEFAULT_TOKENS,E as DURATION_TOKENS,N as EASING_TOKENS,o as FONT_TOKENS,T as LENGTH_TOKENS,t as MOTION_TOKENS,m as REQUIRED_TOKENS,O as TOKEN_NAMES};
@@ -0,0 +1,28 @@
1
+ /** Restricted, recursively parsed CSS lengths; arithmetic is allowed only inside calc(). */
2
+ declare function isLength(value: string, depth?: number): boolean;
3
+ declare function isFontFamily(value: string): boolean;
4
+ declare function isDuration(value: string): boolean;
5
+ declare function isEasing(value: string): boolean;
6
+ declare function isAssetUrl(value: string, relative?: boolean): boolean;
7
+
8
+ /** Register these string formats when using the theme schema with Ajv 2020. */
9
+ declare const themeFormats: {
10
+ "zappie-color": (value: string) => boolean;
11
+ "zappie-length": typeof isLength;
12
+ "zappie-font": typeof isFontFamily;
13
+ "zappie-family": (value: string) => boolean;
14
+ "zappie-duration": typeof isDuration;
15
+ "zappie-easing": typeof isEasing;
16
+ "zappie-asset": typeof isAssetUrl;
17
+ "zappie-https": (value: string) => boolean;
18
+ "zappie-woff2": (value: string) => boolean;
19
+ };
20
+ /** Standard JSON Schema cannot express color contrast or uniqueness by font role. */
21
+ declare const themeSemanticsKeyword: {
22
+ keyword: string;
23
+ type: "object";
24
+ schemaType: "boolean";
25
+ validate: (enabled: boolean, value: unknown) => boolean;
26
+ };
27
+
28
+ export { themeFormats, themeSemanticsKeyword };
@@ -0,0 +1 @@
1
+ import{a as o,b as t,c as i,d as s,e as p,f as a,h as n}from"./chunk-QDQDBQAL.js";import"./chunk-3E5H65GJ.js";var f={"zappie-color":e=>o(e)!==null,"zappie-length":t,"zappie-font":i,"zappie-family":e=>i(e)&&!e.includes(","),"zappie-duration":s,"zappie-easing":p,"zappie-asset":a,"zappie-https":e=>a(e,!1),"zappie-woff2":e=>a(e,!1)&&new URL(e).pathname.endsWith(".woff2")},h={keyword:"zappieTheme",type:"object",schemaType:"boolean",validate:(e,r)=>!e||n(r).ok};export{f as themeFormats,h as themeSemanticsKeyword};
@@ -0,0 +1,48 @@
1
+ /* Generated by scripts/build-schema.mjs. Do not edit. */
2
+ @theme inline {
3
+ --color-z-bg: var(--z-bg);
4
+ --color-z-surface: var(--z-surface);
5
+ --color-z-surface-raised: var(--z-surface-raised);
6
+ --color-z-overlay: var(--z-overlay);
7
+ --color-z-text: var(--z-text);
8
+ --color-z-text-muted: var(--z-text-muted);
9
+ --color-z-text-inverse: var(--z-text-inverse);
10
+ --color-z-accent: var(--z-accent);
11
+ --color-z-accent-contrast: var(--z-accent-contrast);
12
+ --color-z-brand-1: var(--z-brand-1);
13
+ --color-z-brand-2: var(--z-brand-2);
14
+ --color-z-brand-3: var(--z-brand-3);
15
+ --color-z-success: var(--z-success);
16
+ --color-z-warning: var(--z-warning);
17
+ --color-z-danger: var(--z-danger);
18
+ --color-z-border: var(--z-border);
19
+ --color-z-focus-ring: var(--z-focus-ring);
20
+ --radius-z-sm: var(--z-radius-sm);
21
+ --radius-z-md: var(--z-radius-md);
22
+ --radius-z-lg: var(--z-radius-lg);
23
+ --radius-z-pill: var(--z-radius-pill);
24
+ --spacing-z-1: var(--z-space-1);
25
+ --spacing-z-2: var(--z-space-2);
26
+ --spacing-z-3: var(--z-space-3);
27
+ --spacing-z-4: var(--z-space-4);
28
+ --spacing-z-5: var(--z-space-5);
29
+ --spacing-z-6: var(--z-space-6);
30
+ --spacing-z-7: var(--z-space-7);
31
+ --spacing-z-8: var(--z-space-8);
32
+ --text-z-xs: var(--z-text-xs);
33
+ --text-z-sm: var(--z-text-sm);
34
+ --text-z-md: var(--z-text-md);
35
+ --text-z-lg: var(--z-text-lg);
36
+ --text-z-xl: var(--z-text-xl);
37
+ --text-z-2xl: var(--z-text-2xl);
38
+ --text-z-3xl: var(--z-text-3xl);
39
+ --font-z-display: var(--z-font-display);
40
+ --font-z-body: var(--z-font-body);
41
+ --font-z-mono: var(--z-font-mono);
42
+ --ease-z-out: var(--z-ease-out);
43
+ --ease-z-in-out: var(--z-ease-in-out);
44
+ --color-z-muted: var(--z-text-muted);
45
+ }
46
+ @utility duration-z-fast { transition-duration: var(--z-duration-fast); }
47
+ @utility duration-z-base { transition-duration: var(--z-duration-base); }
48
+ @utility duration-z-slow { transition-duration: var(--z-duration-slow); }
@@ -0,0 +1,537 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://registry.zappie.ai/schemas/theme.v1.json",
4
+ "title": "Zappie storefront theme v1",
5
+ "$comment": "For full validation register themeFormats and themeSemanticsKeyword from @zappie/tokens/schema-runtime. Editors provide structural completion only.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "$schema": {
10
+ "type": "string",
11
+ "format": "zappie-https"
12
+ },
13
+ "version": {
14
+ "const": 1
15
+ },
16
+ "name": {
17
+ "type": "string",
18
+ "minLength": 1,
19
+ "maxLength": 100,
20
+ "pattern": "\\S"
21
+ },
22
+ "tokens": {
23
+ "type": "object",
24
+ "additionalProperties": false,
25
+ "properties": {
26
+ "--z-bg": {
27
+ "type": "string",
28
+ "format": "zappie-color"
29
+ },
30
+ "--z-surface": {
31
+ "type": "string",
32
+ "format": "zappie-color"
33
+ },
34
+ "--z-surface-raised": {
35
+ "type": "string",
36
+ "format": "zappie-color"
37
+ },
38
+ "--z-overlay": {
39
+ "type": "string",
40
+ "format": "zappie-color"
41
+ },
42
+ "--z-text": {
43
+ "type": "string",
44
+ "format": "zappie-color"
45
+ },
46
+ "--z-text-muted": {
47
+ "type": "string",
48
+ "format": "zappie-color"
49
+ },
50
+ "--z-text-inverse": {
51
+ "type": "string",
52
+ "format": "zappie-color"
53
+ },
54
+ "--z-accent": {
55
+ "type": "string",
56
+ "format": "zappie-color"
57
+ },
58
+ "--z-accent-contrast": {
59
+ "type": "string",
60
+ "format": "zappie-color"
61
+ },
62
+ "--z-brand-1": {
63
+ "type": "string",
64
+ "format": "zappie-color"
65
+ },
66
+ "--z-brand-2": {
67
+ "type": "string",
68
+ "format": "zappie-color"
69
+ },
70
+ "--z-brand-3": {
71
+ "type": "string",
72
+ "format": "zappie-color"
73
+ },
74
+ "--z-success": {
75
+ "type": "string",
76
+ "format": "zappie-color"
77
+ },
78
+ "--z-warning": {
79
+ "type": "string",
80
+ "format": "zappie-color"
81
+ },
82
+ "--z-danger": {
83
+ "type": "string",
84
+ "format": "zappie-color"
85
+ },
86
+ "--z-border": {
87
+ "type": "string",
88
+ "format": "zappie-color"
89
+ },
90
+ "--z-focus-ring": {
91
+ "type": "string",
92
+ "format": "zappie-color"
93
+ },
94
+ "--z-radius-sm": {
95
+ "type": "string",
96
+ "format": "zappie-length"
97
+ },
98
+ "--z-radius-md": {
99
+ "type": "string",
100
+ "format": "zappie-length"
101
+ },
102
+ "--z-radius-lg": {
103
+ "type": "string",
104
+ "format": "zappie-length"
105
+ },
106
+ "--z-radius-pill": {
107
+ "type": "string",
108
+ "format": "zappie-length"
109
+ },
110
+ "--z-space-1": {
111
+ "type": "string",
112
+ "format": "zappie-length"
113
+ },
114
+ "--z-space-2": {
115
+ "type": "string",
116
+ "format": "zappie-length"
117
+ },
118
+ "--z-space-3": {
119
+ "type": "string",
120
+ "format": "zappie-length"
121
+ },
122
+ "--z-space-4": {
123
+ "type": "string",
124
+ "format": "zappie-length"
125
+ },
126
+ "--z-space-5": {
127
+ "type": "string",
128
+ "format": "zappie-length"
129
+ },
130
+ "--z-space-6": {
131
+ "type": "string",
132
+ "format": "zappie-length"
133
+ },
134
+ "--z-space-7": {
135
+ "type": "string",
136
+ "format": "zappie-length"
137
+ },
138
+ "--z-space-8": {
139
+ "type": "string",
140
+ "format": "zappie-length"
141
+ },
142
+ "--z-text-xs": {
143
+ "type": "string",
144
+ "format": "zappie-length"
145
+ },
146
+ "--z-text-sm": {
147
+ "type": "string",
148
+ "format": "zappie-length"
149
+ },
150
+ "--z-text-md": {
151
+ "type": "string",
152
+ "format": "zappie-length"
153
+ },
154
+ "--z-text-lg": {
155
+ "type": "string",
156
+ "format": "zappie-length"
157
+ },
158
+ "--z-text-xl": {
159
+ "type": "string",
160
+ "format": "zappie-length"
161
+ },
162
+ "--z-text-2xl": {
163
+ "type": "string",
164
+ "format": "zappie-length"
165
+ },
166
+ "--z-text-3xl": {
167
+ "type": "string",
168
+ "format": "zappie-length"
169
+ },
170
+ "--z-drawer-width": {
171
+ "type": "string",
172
+ "format": "zappie-length"
173
+ },
174
+ "--z-dialog-width": {
175
+ "type": "string",
176
+ "format": "zappie-length"
177
+ },
178
+ "--z-dialog-height": {
179
+ "type": "string",
180
+ "format": "zappie-length"
181
+ },
182
+ "--z-media-sm": {
183
+ "type": "string",
184
+ "format": "zappie-length"
185
+ },
186
+ "--z-font-display": {
187
+ "type": "string",
188
+ "format": "zappie-font"
189
+ },
190
+ "--z-font-body": {
191
+ "type": "string",
192
+ "format": "zappie-font"
193
+ },
194
+ "--z-font-mono": {
195
+ "type": "string",
196
+ "format": "zappie-font"
197
+ },
198
+ "--z-duration-fast": {
199
+ "type": "string",
200
+ "format": "zappie-duration"
201
+ },
202
+ "--z-duration-base": {
203
+ "type": "string",
204
+ "format": "zappie-duration"
205
+ },
206
+ "--z-duration-slow": {
207
+ "type": "string",
208
+ "format": "zappie-duration"
209
+ },
210
+ "--z-ease-out": {
211
+ "type": "string",
212
+ "format": "zappie-easing"
213
+ },
214
+ "--z-ease-in-out": {
215
+ "type": "string",
216
+ "format": "zappie-easing"
217
+ }
218
+ },
219
+ "required": [
220
+ "--z-bg",
221
+ "--z-text",
222
+ "--z-accent",
223
+ "--z-accent-contrast"
224
+ ]
225
+ },
226
+ "dark": {
227
+ "type": "object",
228
+ "additionalProperties": false,
229
+ "properties": {
230
+ "--z-bg": {
231
+ "type": "string",
232
+ "format": "zappie-color"
233
+ },
234
+ "--z-surface": {
235
+ "type": "string",
236
+ "format": "zappie-color"
237
+ },
238
+ "--z-surface-raised": {
239
+ "type": "string",
240
+ "format": "zappie-color"
241
+ },
242
+ "--z-overlay": {
243
+ "type": "string",
244
+ "format": "zappie-color"
245
+ },
246
+ "--z-text": {
247
+ "type": "string",
248
+ "format": "zappie-color"
249
+ },
250
+ "--z-text-muted": {
251
+ "type": "string",
252
+ "format": "zappie-color"
253
+ },
254
+ "--z-text-inverse": {
255
+ "type": "string",
256
+ "format": "zappie-color"
257
+ },
258
+ "--z-accent": {
259
+ "type": "string",
260
+ "format": "zappie-color"
261
+ },
262
+ "--z-accent-contrast": {
263
+ "type": "string",
264
+ "format": "zappie-color"
265
+ },
266
+ "--z-brand-1": {
267
+ "type": "string",
268
+ "format": "zappie-color"
269
+ },
270
+ "--z-brand-2": {
271
+ "type": "string",
272
+ "format": "zappie-color"
273
+ },
274
+ "--z-brand-3": {
275
+ "type": "string",
276
+ "format": "zappie-color"
277
+ },
278
+ "--z-success": {
279
+ "type": "string",
280
+ "format": "zappie-color"
281
+ },
282
+ "--z-warning": {
283
+ "type": "string",
284
+ "format": "zappie-color"
285
+ },
286
+ "--z-danger": {
287
+ "type": "string",
288
+ "format": "zappie-color"
289
+ },
290
+ "--z-border": {
291
+ "type": "string",
292
+ "format": "zappie-color"
293
+ },
294
+ "--z-focus-ring": {
295
+ "type": "string",
296
+ "format": "zappie-color"
297
+ },
298
+ "--z-radius-sm": {
299
+ "type": "string",
300
+ "format": "zappie-length"
301
+ },
302
+ "--z-radius-md": {
303
+ "type": "string",
304
+ "format": "zappie-length"
305
+ },
306
+ "--z-radius-lg": {
307
+ "type": "string",
308
+ "format": "zappie-length"
309
+ },
310
+ "--z-radius-pill": {
311
+ "type": "string",
312
+ "format": "zappie-length"
313
+ },
314
+ "--z-space-1": {
315
+ "type": "string",
316
+ "format": "zappie-length"
317
+ },
318
+ "--z-space-2": {
319
+ "type": "string",
320
+ "format": "zappie-length"
321
+ },
322
+ "--z-space-3": {
323
+ "type": "string",
324
+ "format": "zappie-length"
325
+ },
326
+ "--z-space-4": {
327
+ "type": "string",
328
+ "format": "zappie-length"
329
+ },
330
+ "--z-space-5": {
331
+ "type": "string",
332
+ "format": "zappie-length"
333
+ },
334
+ "--z-space-6": {
335
+ "type": "string",
336
+ "format": "zappie-length"
337
+ },
338
+ "--z-space-7": {
339
+ "type": "string",
340
+ "format": "zappie-length"
341
+ },
342
+ "--z-space-8": {
343
+ "type": "string",
344
+ "format": "zappie-length"
345
+ },
346
+ "--z-text-xs": {
347
+ "type": "string",
348
+ "format": "zappie-length"
349
+ },
350
+ "--z-text-sm": {
351
+ "type": "string",
352
+ "format": "zappie-length"
353
+ },
354
+ "--z-text-md": {
355
+ "type": "string",
356
+ "format": "zappie-length"
357
+ },
358
+ "--z-text-lg": {
359
+ "type": "string",
360
+ "format": "zappie-length"
361
+ },
362
+ "--z-text-xl": {
363
+ "type": "string",
364
+ "format": "zappie-length"
365
+ },
366
+ "--z-text-2xl": {
367
+ "type": "string",
368
+ "format": "zappie-length"
369
+ },
370
+ "--z-text-3xl": {
371
+ "type": "string",
372
+ "format": "zappie-length"
373
+ },
374
+ "--z-drawer-width": {
375
+ "type": "string",
376
+ "format": "zappie-length"
377
+ },
378
+ "--z-dialog-width": {
379
+ "type": "string",
380
+ "format": "zappie-length"
381
+ },
382
+ "--z-dialog-height": {
383
+ "type": "string",
384
+ "format": "zappie-length"
385
+ },
386
+ "--z-media-sm": {
387
+ "type": "string",
388
+ "format": "zappie-length"
389
+ },
390
+ "--z-font-display": {
391
+ "type": "string",
392
+ "format": "zappie-font"
393
+ },
394
+ "--z-font-body": {
395
+ "type": "string",
396
+ "format": "zappie-font"
397
+ },
398
+ "--z-font-mono": {
399
+ "type": "string",
400
+ "format": "zappie-font"
401
+ },
402
+ "--z-duration-fast": {
403
+ "type": "string",
404
+ "format": "zappie-duration"
405
+ },
406
+ "--z-duration-base": {
407
+ "type": "string",
408
+ "format": "zappie-duration"
409
+ },
410
+ "--z-duration-slow": {
411
+ "type": "string",
412
+ "format": "zappie-duration"
413
+ },
414
+ "--z-ease-out": {
415
+ "type": "string",
416
+ "format": "zappie-easing"
417
+ },
418
+ "--z-ease-in-out": {
419
+ "type": "string",
420
+ "format": "zappie-easing"
421
+ }
422
+ }
423
+ },
424
+ "darkMode": {
425
+ "enum": [
426
+ "auto",
427
+ "light",
428
+ "dark"
429
+ ],
430
+ "default": "light"
431
+ },
432
+ "logo": {
433
+ "type": "object",
434
+ "additionalProperties": false,
435
+ "properties": {
436
+ "light": {
437
+ "type": "string",
438
+ "format": "zappie-asset"
439
+ },
440
+ "dark": {
441
+ "type": "string",
442
+ "format": "zappie-asset"
443
+ },
444
+ "mark": {
445
+ "type": "string",
446
+ "format": "zappie-asset"
447
+ },
448
+ "alt": {
449
+ "type": "string",
450
+ "minLength": 1,
451
+ "pattern": "\\S"
452
+ }
453
+ },
454
+ "required": [
455
+ "light",
456
+ "alt"
457
+ ]
458
+ },
459
+ "fonts": {
460
+ "type": "array",
461
+ "maxItems": 3,
462
+ "items": {
463
+ "type": "object",
464
+ "additionalProperties": false,
465
+ "properties": {
466
+ "family": {
467
+ "type": "string",
468
+ "format": "zappie-family"
469
+ },
470
+ "source": {
471
+ "enum": [
472
+ "google",
473
+ "self",
474
+ "system"
475
+ ]
476
+ },
477
+ "url": {
478
+ "type": "string",
479
+ "format": "zappie-woff2"
480
+ },
481
+ "role": {
482
+ "enum": [
483
+ "display",
484
+ "body",
485
+ "mono"
486
+ ]
487
+ },
488
+ "weights": {
489
+ "type": "array",
490
+ "minItems": 1,
491
+ "maxItems": 9,
492
+ "items": {
493
+ "type": "integer",
494
+ "minimum": 1,
495
+ "maximum": 1000
496
+ }
497
+ }
498
+ },
499
+ "required": [
500
+ "family",
501
+ "source",
502
+ "role"
503
+ ],
504
+ "if": {
505
+ "properties": {
506
+ "source": {
507
+ "const": "self"
508
+ }
509
+ },
510
+ "required": [
511
+ "source"
512
+ ]
513
+ },
514
+ "then": {
515
+ "required": [
516
+ "url"
517
+ ]
518
+ }
519
+ }
520
+ },
521
+ "motion": {
522
+ "type": "object",
523
+ "additionalProperties": false,
524
+ "properties": {
525
+ "reduce": {
526
+ "type": "boolean"
527
+ }
528
+ }
529
+ }
530
+ },
531
+ "required": [
532
+ "version",
533
+ "name",
534
+ "tokens"
535
+ ],
536
+ "zappieTheme": true
537
+ }
@@ -0,0 +1,4 @@
1
+ /* Generated by scripts/build-schema.mjs. Do not edit. */
2
+ :root{--z-bg:#F9FAFB;--z-surface:#FFFFFF;--z-surface-raised:#FFFFFF;--z-overlay:#00000080;--z-text:#101828;--z-text-muted:#344054;--z-text-inverse:#FFFFFF;--z-accent:#9FE870;--z-accent-contrast:#163300;--z-brand-1:#9FE870;--z-brand-2:#163300;--z-brand-3:#EDC843;--z-success:#027A48;--z-warning:#ED7A37;--z-danger:#F04438;--z-border:#EAECF0;--z-focus-ring:#163300;--z-radius-sm:6px;--z-radius-md:12px;--z-radius-lg:20px;--z-radius-pill:9999px;--z-space-1:4px;--z-space-2:8px;--z-space-3:12px;--z-space-4:16px;--z-space-5:24px;--z-space-6:32px;--z-space-7:48px;--z-space-8:64px;--z-text-xs:12px;--z-text-sm:14px;--z-text-md:16px;--z-text-lg:18px;--z-text-xl:20px;--z-text-2xl:24px;--z-text-3xl:32px;--z-drawer-width:420px;--z-dialog-width:min(1000px, calc(100vw - 32px));--z-dialog-height:min(780px, 90dvh);--z-media-sm:64px;--z-font-display:system-ui, sans-serif;--z-font-body:system-ui, sans-serif;--z-font-mono:ui-monospace, monospace;--z-duration-fast:120ms;--z-duration-base:200ms;--z-duration-slow:320ms;--z-ease-out:cubic-bezier(0, 0, 0.2, 1);--z-ease-in-out:cubic-bezier(0.4, 0, 0.2, 1);color-scheme:light;}
3
+ :root:is([data-theme="dark"],.dark){--z-bg:#000000;--z-surface:#242424;--z-surface-raised:#333333;--z-text:#FFFFFF;--z-text-muted:#BFBFBF;--z-text-inverse:#101828;--z-border:#474747;--z-focus-ring:#9FE870;color-scheme:dark;}
4
+ @media(prefers-reduced-motion:reduce){:root{--z-duration-fast:0ms;--z-duration-base:0ms;--z-duration-slow:0ms;}}
@@ -0,0 +1,55 @@
1
+ /** Closed semantic token vocabulary. Theme-private CSS variables stay outside this contract. */
2
+ declare const COLOR_TOKENS: readonly ["--z-bg", "--z-surface", "--z-surface-raised", "--z-overlay", "--z-text", "--z-text-muted", "--z-text-inverse", "--z-accent", "--z-accent-contrast", "--z-brand-1", "--z-brand-2", "--z-brand-3", "--z-success", "--z-warning", "--z-danger", "--z-border", "--z-focus-ring"];
3
+ declare const LENGTH_TOKENS: readonly ["--z-radius-sm", "--z-radius-md", "--z-radius-lg", "--z-radius-pill", "--z-space-1", "--z-space-2", "--z-space-3", "--z-space-4", "--z-space-5", "--z-space-6", "--z-space-7", "--z-space-8", "--z-text-xs", "--z-text-sm", "--z-text-md", "--z-text-lg", "--z-text-xl", "--z-text-2xl", "--z-text-3xl", "--z-drawer-width", "--z-dialog-width", "--z-dialog-height", "--z-media-sm"];
4
+ declare const FONT_TOKENS: readonly ["--z-font-display", "--z-font-body", "--z-font-mono"];
5
+ declare const DURATION_TOKENS: readonly ["--z-duration-fast", "--z-duration-base", "--z-duration-slow"];
6
+ declare const EASING_TOKENS: readonly ["--z-ease-out", "--z-ease-in-out"];
7
+ declare const MOTION_TOKENS: readonly ["--z-duration-fast", "--z-duration-base", "--z-duration-slow", "--z-ease-out", "--z-ease-in-out"];
8
+ declare const TOKEN_NAMES: readonly ["--z-bg", "--z-surface", "--z-surface-raised", "--z-overlay", "--z-text", "--z-text-muted", "--z-text-inverse", "--z-accent", "--z-accent-contrast", "--z-brand-1", "--z-brand-2", "--z-brand-3", "--z-success", "--z-warning", "--z-danger", "--z-border", "--z-focus-ring", "--z-radius-sm", "--z-radius-md", "--z-radius-lg", "--z-radius-pill", "--z-space-1", "--z-space-2", "--z-space-3", "--z-space-4", "--z-space-5", "--z-space-6", "--z-space-7", "--z-space-8", "--z-text-xs", "--z-text-sm", "--z-text-md", "--z-text-lg", "--z-text-xl", "--z-text-2xl", "--z-text-3xl", "--z-drawer-width", "--z-dialog-width", "--z-dialog-height", "--z-media-sm", "--z-font-display", "--z-font-body", "--z-font-mono", "--z-duration-fast", "--z-duration-base", "--z-duration-slow", "--z-ease-out", "--z-ease-in-out"];
9
+ declare const REQUIRED_TOKENS: readonly ["--z-bg", "--z-text", "--z-accent", "--z-accent-contrast"];
10
+ type TokenName = (typeof TOKEN_NAMES)[number];
11
+ type ColorToken = (typeof COLOR_TOKENS)[number];
12
+ type TokenValues = Partial<Record<TokenName, string>>;
13
+
14
+ /** A font source is emitted only by compileTheme, never fetched during validation. */
15
+ type ThemeFont = {
16
+ family: string;
17
+ source: "google" | "self" | "system";
18
+ url?: string;
19
+ weights?: number[];
20
+ role: "display" | "body" | "mono";
21
+ };
22
+ type ThemeJson = {
23
+ $schema?: string;
24
+ version: 1;
25
+ name: string;
26
+ tokens: TokenValues;
27
+ dark?: TokenValues;
28
+ darkMode?: "auto" | "light" | "dark";
29
+ logo?: {
30
+ light: string;
31
+ dark?: string;
32
+ mark?: string;
33
+ alt: string;
34
+ };
35
+ fonts?: ThemeFont[];
36
+ motion?: {
37
+ reduce?: boolean;
38
+ };
39
+ };
40
+ type ThemeIssue = {
41
+ path: string;
42
+ code: "unknown_token" | "invalid_color" | "invalid_length" | "low_contrast" | "missing_required" | "invalid_font" | "invalid_logo" | "invalid_theme" | "invalid_motion" | "unverified_contrast" | "copy_truncated";
43
+ message: string;
44
+ severity: "error" | "warning";
45
+ };
46
+ type ThemeValidation = {
47
+ ok: true;
48
+ theme: ThemeJson;
49
+ warnings: ThemeIssue[];
50
+ } | {
51
+ ok: false;
52
+ issues: ThemeIssue[];
53
+ };
54
+
55
+ export { COLOR_TOKENS as C, DURATION_TOKENS as D, EASING_TOKENS as E, FONT_TOKENS as F, LENGTH_TOKENS as L, MOTION_TOKENS as M, REQUIRED_TOKENS as R, type ThemeJson as T, type TokenName as a, type ColorToken as b, TOKEN_NAMES as c, type ThemeFont as d, type ThemeIssue as e, type ThemeValidation as f, type TokenValues as g };
@@ -0,0 +1,10 @@
1
+ import { f as ThemeValidation } from './types-QqJ2gb0F.js';
2
+ export { e as ThemeIssue } from './types-QqJ2gb0F.js';
3
+
4
+ /** Validate untrusted theme JSON, including syntax, CSS injection and effective light/dark contrast. */
5
+ declare function validateTheme(input: unknown): ThemeValidation;
6
+
7
+ /** WCAG contrast for absolute colors. A translucent background needs an explicit backdrop. */
8
+ declare function contrastRatio(fg: string, bg: string): number;
9
+
10
+ export { ThemeValidation, contrastRatio, validateTheme };
@@ -0,0 +1 @@
1
+ import{g as e,h as t}from"./chunk-QDQDBQAL.js";import"./chunk-3E5H65GJ.js";export{e as contrastRatio,t as validateTheme};
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@zappie/tokens",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Semantic design token contract for Zappie storefronts (--z-*).",
5
+ "type": "module",
6
+ "sideEffects": [
7
+ "**/*.css"
8
+ ],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./tokens.css": "./dist/tokens.css",
15
+ "./validate": {
16
+ "types": "./dist/validate.d.ts",
17
+ "import": "./dist/validate.js"
18
+ },
19
+ "./compile": {
20
+ "types": "./dist/compile.d.ts",
21
+ "import": "./dist/compile.js"
22
+ },
23
+ "./checkout": {
24
+ "types": "./dist/checkout.d.ts",
25
+ "import": "./dist/checkout.js"
26
+ },
27
+ "./schema-runtime": {
28
+ "types": "./dist/schema-runtime.d.ts",
29
+ "import": "./dist/schema-runtime.js"
30
+ },
31
+ "./tailwind.css": "./dist/tailwind.css",
32
+ "./schema/theme.v1.json": "./dist/theme.v1.json"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "provenance": false
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "LICENSE.color-name"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/zappie/storefront.git",
45
+ "directory": "packages/tokens"
46
+ },
47
+ "devDependencies": {
48
+ "ajv": "^8.18.0",
49
+ "esbuild": "^0.27.7"
50
+ },
51
+ "license": "MIT",
52
+ "homepage": "https://github.com/zappie/storefront#readme",
53
+ "bugs": {
54
+ "url": "https://github.com/zappie/storefront/issues"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup && node scripts/build-schema.mjs",
58
+ "check-generated": "node scripts/build-schema.mjs --check",
59
+ "size": "node scripts/check-size.mjs",
60
+ "check-types": "tsc -p tsconfig.json"
61
+ }
6
62
  }