@zappie/tokens 0.1.2 → 0.2.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 +12 -0
- package/dist/chunk-LDNDK7PT.js +1 -0
- package/dist/chunk-PJ7JKK62.js +1 -0
- package/dist/compile.d.ts +1 -1
- package/dist/compile.js +4 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/schema-runtime.js +1 -1
- package/dist/{types-QqJ2gb0F.d.ts → types-DZJlcmNS.d.ts} +3 -2
- package/dist/validate.d.ts +2 -2
- package/dist/validate.js +1 -1
- package/package.json +1 -5
- package/dist/checkout.d.ts +0 -34
- package/dist/checkout.js +0 -1
- package/dist/chunk-3E5H65GJ.js +0 -1
- package/dist/chunk-5NS3743Z.js +0 -4
- package/dist/chunk-QDQDBQAL.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zappie/tokens
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 896ced7: Breaking: a storefront can no longer restyle the hosted checkout. It always draws in Zappie's own design and ignores a `theme` message. `embedCheckout` and `useCheckout` drop the `theme` option and the `CheckoutTheme` type, and send the checkout no theme. `@zappie/tokens` drops the `@zappie/tokens/checkout` entry with `toCheckoutTheme` and `CHECKOUT_TOKENS`, the `CheckoutTheme` and `CheckoutFont` types, and the `copy_truncated` issue code. `@zappie/tokens/validate`, `/compile`, `/schema-runtime` and the token CSS are unchanged. Both packages take a minor bump because they are below 1.0.
|
|
8
|
+
|
|
9
|
+
## 0.1.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b31a689: Build the declaration files with tsup 9. Type-only exports are now written as `export type { ... }` and shared declaration chunks have new file names. Foundations part props name their omitted attributes `PartOwnedAttributes`, so their declarations no longer depend on build order. Every entry point exports the same names with the same types. The JavaScript and source maps are unchanged.
|
|
14
|
+
|
|
3
15
|
## 0.1.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=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"}),n=Object.freeze({version:1,name:"Zappie",tokens:e,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"})});var t=["--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"],s=["--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=["--z-font-display","--z-font-body","--z-font-mono"],a=["--z-duration-fast","--z-duration-base","--z-duration-slow"],o=["--z-ease-out","--z-ease-in-out"],r=[...a,...o],p=[...t,...s,...z,...r],x=["--z-bg","--z-text","--z-accent","--z-accent-contrast"];export{e as a,n as b,t as c,s as d,z as e,a as f,o as g,r as h,p as i,x as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as q,c as A,d as z,e as S,f as I,i as L,j}from"./chunk-LDNDK7PT.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 j)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(L,n)){t(d,"unknown_token","Unknown semantic token");continue}let c,f=!1;x(A,n)?(c="invalid_color",f=typeof o=="string"&&b(o)!==null):x(z,n)?(c="invalid_length",f=typeof o=="string"&&O(o)):x(S,n)?(c="invalid_font",f=typeof o=="string"&&M(o)):(c="invalid_motion",f=typeof o=="string"&&k(o)&&(x(I,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={...q,...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};
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThemeJson, TokenName } from './index.js';
|
|
2
2
|
|
|
3
3
|
/** Fill every token; dark overrides inherit the theme's light values. Returns a fresh object. */
|
|
4
4
|
declare function resolveTokens(theme: ThemeJson, scheme: "light" | "dark"): Record<TokenName, string>;
|
package/dist/compile.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as k}from"./chunk-PJ7JKK62.js";import{a as g,f as p,i as l}from"./chunk-LDNDK7PT.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{N as compileTheme,$ as resolveTokens};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { T as ThemeJson, a as TokenName } from './types-
|
|
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-
|
|
3
|
-
export { CheckoutFont, CheckoutTheme } from './checkout.js';
|
|
1
|
+
import { T as ThemeJson, a as TokenName } from './types-DZJlcmNS.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-DZJlcmNS.js';
|
|
4
3
|
|
|
5
4
|
/** Host palette from styles/colors.ts; public fonts use a licence-free system stack. */
|
|
6
5
|
declare const DEFAULT_TOKENS: Readonly<Record<TokenName, string>>;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as T,b as e,c as E,d as o,e as N,f as O,g as m,h as S,i as _,j as r}from"./chunk-LDNDK7PT.js";export{E as COLOR_TOKENS,e as DEFAULT_THEME,T as DEFAULT_TOKENS,O as DURATION_TOKENS,m as EASING_TOKENS,N as FONT_TOKENS,o as LENGTH_TOKENS,S as MOTION_TOKENS,r as REQUIRED_TOKENS,_ as TOKEN_NAMES};
|
package/dist/schema-runtime.js
CHANGED
|
@@ -1 +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-
|
|
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-PJ7JKK62.js";import"./chunk-LDNDK7PT.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};
|
|
@@ -39,7 +39,7 @@ type ThemeJson = {
|
|
|
39
39
|
};
|
|
40
40
|
type ThemeIssue = {
|
|
41
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"
|
|
42
|
+
code: "unknown_token" | "invalid_color" | "invalid_length" | "low_contrast" | "missing_required" | "invalid_font" | "invalid_logo" | "invalid_theme" | "invalid_motion" | "unverified_contrast";
|
|
43
43
|
message: string;
|
|
44
44
|
severity: "error" | "warning";
|
|
45
45
|
};
|
|
@@ -52,4 +52,5 @@ type ThemeValidation = {
|
|
|
52
52
|
issues: ThemeIssue[];
|
|
53
53
|
};
|
|
54
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,
|
|
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, TOKEN_NAMES as c };
|
|
56
|
+
export type { ThemeJson as T, TokenName as a, ColorToken as b, ThemeFont as d, ThemeIssue as e, ThemeValidation as f, TokenValues as g };
|
package/dist/validate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as ThemeValidation } from './types-
|
|
2
|
-
export { e as ThemeIssue } from './types-
|
|
1
|
+
import { f as ThemeValidation } from './types-DZJlcmNS.js';
|
|
2
|
+
export { e as ThemeIssue } from './types-DZJlcmNS.js';
|
|
3
3
|
|
|
4
4
|
/** Validate untrusted theme JSON, including syntax, CSS injection and effective light/dark contrast. */
|
|
5
5
|
declare function validateTheme(input: unknown): ThemeValidation;
|
package/dist/validate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t}from"./chunk-
|
|
1
|
+
import{g as e,h as t}from"./chunk-PJ7JKK62.js";import"./chunk-LDNDK7PT.js";export{e as contrastRatio,t as validateTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Semantic design token contract for Zappie storefronts (--z-*).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -20,10 +20,6 @@
|
|
|
20
20
|
"types": "./dist/compile.d.ts",
|
|
21
21
|
"import": "./dist/compile.js"
|
|
22
22
|
},
|
|
23
|
-
"./checkout": {
|
|
24
|
-
"types": "./dist/checkout.d.ts",
|
|
25
|
-
"import": "./dist/checkout.js"
|
|
26
|
-
},
|
|
27
23
|
"./schema-runtime": {
|
|
28
24
|
"types": "./dist/schema-runtime.d.ts",
|
|
29
25
|
"import": "./dist/schema-runtime.js"
|
package/dist/checkout.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 };
|
package/dist/checkout.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/dist/chunk-3E5H65GJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/dist/chunk-5NS3743Z.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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};
|
package/dist/chunk-QDQDBQAL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|