@uniweb/runtime 0.11.0 → 0.11.2

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.
Files changed (35) hide show
  1. package/package.json +7 -5
  2. package/dist/app/_importmap/@uniweb-core.js +0 -1
  3. package/dist/app/_importmap/@uniweb-runtime-default-fetcher.js +0 -1
  4. package/dist/app/_importmap/@uniweb-runtime-foundation-loader.js +0 -1
  5. package/dist/app/_importmap/@uniweb-runtime-provider.js +0 -1
  6. package/dist/app/_importmap/@uniweb-runtime-setup.js +0 -1
  7. package/dist/app/_importmap/@uniweb-theming.js +0 -53
  8. package/dist/app/_importmap/react-dom-client.js +0 -1
  9. package/dist/app/_importmap/react-dom-server.js +0 -53
  10. package/dist/app/_importmap/react-dom.js +0 -1
  11. package/dist/app/_importmap/react-jsx-dev-runtime.js +0 -1
  12. package/dist/app/_importmap/react-jsx-runtime.js +0 -1
  13. package/dist/app/_importmap/react-router-dom.js +0 -1
  14. package/dist/app/_importmap/react.js +0 -1
  15. package/dist/app/assets/_commonjsHelpers-CqkleIqs.js +0 -1
  16. package/dist/app/assets/_importmap_react-CrAkajDz.js +0 -1
  17. package/dist/app/assets/_importmap_react-router-dom-CLbp1nUY.js +0 -3
  18. package/dist/app/assets/client-CQjOKqaN.js +0 -9
  19. package/dist/app/assets/index-BjwnhO24.js +0 -1
  20. package/dist/app/assets/index-C_CSAb0x.js +0 -59
  21. package/dist/app/assets/index-CxUeIbEw.js +0 -1
  22. package/dist/app/assets/index-VvOM7xKK.js +0 -1
  23. package/dist/app/assets/index-n0uF7vTr.js +0 -74
  24. package/dist/app/assets/jsx-runtime-0PlsXv6K.js +0 -1
  25. package/dist/app/assets/normalize-DbApPPeG.js +0 -1
  26. package/dist/app/assets/setup-BeQi33In.js +0 -1
  27. package/dist/app/assets/shade-generator-BBzWo1IN.js +0 -1
  28. package/dist/app/index.html +0 -50
  29. package/dist/app/manifest.json +0 -33
  30. package/dist/shims/react-dom.js +0 -18
  31. package/dist/shims/react-jsx-runtime.js +0 -7
  32. package/dist/shims/react.js +0 -48
  33. package/dist/shims/uniweb-core.js +0 -35
  34. package/dist/worker-runtime-entry.js +0 -10
  35. package/dist/worker-runtime.js +0 -30554
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/runtime",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Minimal runtime for loading Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "files": [
15
15
  "src",
16
- "dist",
17
- "!dist/app/**/*.map"
16
+ "dist/ssr.js",
17
+ "dist/ssr.js.map"
18
18
  ],
19
19
  "keywords": [
20
20
  "uniweb",
@@ -44,7 +44,7 @@
44
44
  "esbuild": "^0.21.0 || ^0.23.0 || ^0.24.0 || ^0.25.0 || ^0.27.0",
45
45
  "vite": "^7.3.1",
46
46
  "vitest": "^4.1.7",
47
- "@uniweb/build": "0.17.0"
47
+ "@uniweb/build": "0.18.1"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": "^19.0.0",
@@ -57,6 +57,8 @@
57
57
  "build": "npm run build:ssr && npm run build:app",
58
58
  "build:worker": "node build-worker.js",
59
59
  "test": "vitest run",
60
- "test:watch": "vitest"
60
+ "test:watch": "vitest",
61
+ "relock": "node scripts/relock.js",
62
+ "standalone:check": "node scripts/standalone-manifest.js --check"
61
63
  }
62
64
  }
@@ -1 +0,0 @@
1
- import{B as g,D as f,a as p,E as d,F as _,O as m,P as S,U as b,W as V,c as v,b as y,d as C,g as x,i as F,e as L,f as O,n as k,h as w,r as P,j as T,k as U,v as j}from"../assets/index-C_CSAb0x.js";import{H as E,G as R,I as $,J as D,K as I,O as N,F as W}from"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";import"../assets/normalize-DbApPPeG.js";const n=[50,100,200,300,400,500,600,700,800,900,950],r=["light","medium","dark"];class i{constructor(e={}){this._data=e,this._palettes=e.palettes||e.colors||{},this._rawColors=e.colors||{},this._contexts=e.contexts||{},this._fonts=e.fonts||{},this._appearance=e.appearance||{default:"light"},this._foundationVars=e.foundationVars||{},this._css=e.css||null,Object.seal(this)}get css(){return this._css}get data(){return this._data}getColor(e,t=500){const s=this._palettes[e];return s&&s[t]||null}getPalette(e){return this._palettes[e]||null}getPaletteNames(){return Object.keys(this._palettes)}hasPalette(e){return e in this._palettes}getColorVar(e,t=500){return`var(--${e}-${t})`}getContextClass(e){return r.includes(e)?`context-${e}`:(console.warn(`Invalid context: ${e}. Using 'light'.`),"context-light")}isValidContext(e){return r.includes(e)}getValidContexts(){return[...r]}getAppearance(){return{default:this._appearance.default||"light",allowToggle:this._appearance.allowToggle||!1,respectSystemPreference:this._appearance.respectSystemPreference??!0,schemes:this._appearance.schemes||["light"]}}getDefaultScheme(){return this._appearance.default||"light"}supportsScheme(e){return(this._appearance.schemes||["light"]).includes(e)}hasSchemeToggle(){return this._appearance.allowToggle===!0}getSchemeClass(e){return`scheme-${e}`}getFonts(){return{...this._fonts}}getFont(e){return this._fonts[e]||null}getFontVar(e){return`var(--font-${e})`}getFoundationVar(e){const t=this._foundationVars[e];return t?typeof t=="object"?t.default:t:null}getFoundationVars(){const e={};for(const[t,s]of Object.entries(this._foundationVars))e[t]=typeof s=="object"?s.default:s;return e}getFoundationVarRef(e){return`var(--${e})`}getShadeLevels(){return[...n]}hasCustomization(){return Object.keys(this._palettes).length>0||Object.keys(this._contexts).length>0||Object.keys(this._fonts).length>0}toJSON(){return{palettes:this._palettes,colors:this._rawColors,contexts:this._contexts,fonts:this._fonts,appearance:this._appearance,foundationVars:this._foundationVars}}}function c(a={}){return!!(a.allowToggle||a.default==="dark"||a.default==="system"||a.schemes?.includes("dark"))}export{g as Block,f as DATA_DIR,p as DATA_URL_PREFIX,E as DataStore,d as EntityStore,_ as FetcherDispatcher,m as ObservableState,S as Page,i as Theme,b as Uniweb,V as Website,v as collectionDataUrl,y as collectionNameFromUrl,C as createUniweb,R as deriveCacheKey,$ as evaluateWhere,x as getUniweb,c as hasDarkScheme,F as isDataUrl,L as isRichSchema,O as isWildcardLanguages,D as listRequestStyleNames,I as matchWhere,k as normalizeLanguageList,w as normalizeSchema,P as recordDataUrl,T as resolveDefaultLocale,U as resolvePublishableLocales,N as resolveRequestStyle,W as substitutePlaceholders,j as validateLanguageConfig};
@@ -1 +0,0 @@
1
- import{O as L,F as D,G as I,K as V}from"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";const R=new Set(["where","limit","sort"]);function se({basePath:e="",config:t={},dev:n=!1}={}){const r=e&&e!=="/"?e.replace(/\/$/,""):"",a=typeof t?.baseUrl=="string"?t.baseUrl.replace(/\/$/,""):"",i=B(t?.headers),m=Q(t?.supports),y=t?.request&&typeof t.request=="object"?t.request:{},w=typeof y.style=="string"?y.style:null,p=L(w,{dev:n}),U=M(y.rename,p,{dev:n}),G=t?.envelope&&typeof t.envelope=="object"?t.envelope:null,z={...p.defaultEnvelope||{},...G||{}};return{cacheKey(s){const S=I(s),l={};for(const f of m)p.canPush.has(f)&&s[f]!==void 0&&(l[f]=s[f]);return Object.keys(l).length===0&&p.name==="json-body"?S:S+"::style="+p.name+"::"+JSON.stringify(l)},async resolve(s,S={}){if(!s)return{data:null};const{path:l,url:f,transform:J,body:j}=s;let d=(s.method||"GET").toUpperCase();d!=="GET"&&d!=="POST"&&(console.warn(`[default-fetcher] method "${s.method}" is not supported — falling back to GET.`),d="GET");let h,v;if(l)h=r&&l.startsWith("/")&&!l.startsWith("//")?r+l:l,v=!1;else if(f)h=ee(f)?f:te(a,f),v=!0;else return{data:[],error:"No path or url specified"};const P={signal:S.signal,method:d},b={};v&&i&&Object.assign(b,i);const C=new Set;if(v)for(const o of R)m.has(o)&&p.canPush.has(o)&&s[o]!==void 0&&s[o]!==null&&C.add(o);const O=C.size>0?p.encode(s,{method:d,pushCandidates:C,rename:U}):{queryParams:[],bodyMerge:null,pushed:new Set},K=O.pushed;if(O.queryParams.length>0&&d==="GET"&&(h=_(h,O.queryParams)),d==="POST"){const o=s.dynamicContext,k=j!=null&&o&&o.paramName?D(j,{[o.paramName]:o.paramValue},{encode:!1}):j,u=X(k,O.bodyMerge);u!==null&&(q(b,"Content-Type")||(b["Content-Type"]="application/json"),P.body=typeof u=="string"?u:JSON.stringify(u))}Object.keys(b).length&&(P.headers=b);try{const o=await fetch(h,P),u=(s.envelope&&typeof s.envelope=="object"?s.envelope:null)??z;if(!o.ok){let g;if(u.error)try{const H=await o.text(),A=ne(H);if(A!==void 0){const N=T(A,u.error);typeof N=="string"&&N.length&&(g=N)}}catch{}return{data:[],error:g??`HTTP ${o.status}: ${o.statusText}`}}const W=o.headers.get("content-type")||"";let c;if(W.includes("application/json"))c=await o.json();else{const g=await o.text();try{c=JSON.parse(g)}catch{c=g}}const F=!!s.dynamicContext,E=J||(F?u.item:u.collection);return E&&c!==null&&c!==void 0&&(c=T(c,E)),c=Y(c,s,K),{data:c??[]}}catch(o){return o?.name==="AbortError"?{data:[],error:"aborted"}:{data:[],error:o?.message||String(o)}}}}}function M(e,t,{dev:n}){if(!e||typeof e!="object"||Array.isArray(e))return null;const r={};for(const[a,i]of Object.entries(e))typeof i!="string"||i.length===0||(n&&!t.canPush.has(a)&&!x.has(a)&&(x.add(a),console.warn(`[default-fetcher] request.rename: operator "${a}" is not pushed by style "${t.name}" — rename has no effect. Known operators for this style: ${[...t.canPush].join(", ")||"(none)"}.`)),r[a]=i);return Object.keys(r).length?r:null}const x=new Set;function Q(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e)typeof n=="string"&&(R.has(n)?t.add(n):$.has(n)||($.add(n),console.warn(`[default-fetcher] supports: unknown operator "${n}" — ignored.`)));return t}const $=new Set;function _(e,t){if(!t||t.length===0)return e;const n=t.map(([a,i])=>encodeURIComponent(a)+"="+encodeURIComponent(i)),r=e.includes("?")?"&":"?";return e+r+n.join("&")}function X(e,t){return t?typeof e=="string"?e:{...e&&typeof e=="object"?e:{},...t}:e===void 0?null:e}function Y(e,t,n){if(!Array.isArray(e))return e;let r=e;return t.where&&!n.has("where")&&(r=V(t.where,r)),t.sort&&!n.has("sort")&&(r=Z(r,t.sort)),typeof t.limit=="number"&&t.limit>0&&!n.has("limit")&&(r=r.slice(0,t.limit)),r}function Z(e,t){const n=String(t).split(",").map(r=>{const[a,i="asc"]=r.trim().split(/\s+/);return{field:a,desc:i.toLowerCase()==="desc"}});return[...e].sort((r,a)=>{for(const{field:i,desc:m}of n){const y=T(r,i)??"",w=T(a,i)??"";if(y<w)return m?1:-1;if(y>w)return m?-1:1}return 0})}function B(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t={};for(const[n,r]of Object.entries(e))r!=null&&(t[n]=String(r));return Object.keys(t).length?t:null}function q(e,t){const n=t.toLowerCase();return Object.keys(e).some(r=>r.toLowerCase()===n)}function ee(e){return typeof e!="string"?!1:e.startsWith("//")?!0:/^[a-z][a-z0-9+.-]*:\/\//i.test(e)}function te(e,t){return e?t.startsWith("/")?e+t:e+"/"+t:t}function T(e,t){if(!e||!t)return e;let n=e;for(const r of t.split(".")){if(n==null)return;n=n[r]}return n}function ne(e){try{return JSON.parse(e)}catch{return}}export{se as createDefaultFetcher};
@@ -1 +0,0 @@
1
- function s(n){return typeof n!="string"||!n||typeof window>"u"||!window.location||/^([a-z][a-z0-9+.-]*:)?\/\//i.test(n)?n:n.startsWith("/")?window.location.origin+n:n}async function d(n){if(n&&!document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return new Promise(t=>{const o=document.createElement("link");o.rel="stylesheet",o.href=n,o.onload=()=>{console.log("[Runtime] Foundation CSS loaded"),t()},o.onerror=()=>{console.warn("[Runtime] Could not load foundation CSS from:",n),t()},document.head.appendChild(o)})}async function c(n){const t=typeof n=="string"?n:n.url,o=typeof n=="object"?n.cssUrl:t.replace(/[^/]+\.js$/,"assets/style.css"),e=s(t),a=o&&s(o);console.log(`[Runtime] Loading foundation from: ${e}`);try{const[,i]=await Promise.all([a?d(a):Promise.resolve(),import(e)]),l=Object.keys(i).filter(r=>r!=="default");return console.log("[Runtime] Foundation loaded. Available components:",l),i}catch(i){throw console.error("[Runtime] Failed to load foundation:",i),i}}async function f(n){if(!n?.length)return[];const t=await Promise.allSettled(n.map(e=>c(e))),o=[];for(let e=0;e<t.length;e++)t[e].status==="fulfilled"?(o.push(t[e].value),console.log(`[Runtime] Extension loaded: ${n[e]}`)):console.warn(`[Runtime] Extension failed to load: ${n[e]}`,t[e].reason);return o}export{f as loadExtensions,c as loadFoundation};
@@ -1 +0,0 @@
1
- import{j as i}from"../assets/jsx-runtime-0PlsXv6K.js";import{r as a,R}from"../assets/_importmap_react-CrAkajDz.js";import{p as j,a as P,P as A}from"../assets/setup-BeQi33In.js";import{u as T,a as C,b as B,B as M,R as W,c as I}from"../assets/_importmap_react-router-dom-CLbp1nUY.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";import"../assets/index-C_CSAb0x.js";import"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";import"../assets/normalize-DbApPPeG.js";import"./@uniweb-runtime-default-fetcher.js";import"./@uniweb-theming.js";const w="uniweb-theme";function N(){return typeof document>"u"?!1:document.getElementById(w)!==null}function F({css:e,children:t}){const n=a.useRef(null);return a.useEffect(()=>{if(!e||N())return;const r=document.createElement("style");return r.id=w,r.textContent=e,document.head.appendChild(r),n.current=r,()=>{n.current&&n.current.parentNode&&(n.current.parentNode.removeChild(n.current),n.current=null)}},[e]),a.useEffect(()=>{if(!e)return;const r=document.getElementById(w);r&&r.textContent!==e&&(r.textContent=e)},[e]),i.jsx(i.Fragment,{children:t})}const E=new Map;function v(e){return e===window?window.scrollY:e.scrollTop}function D(){const e=globalThis.uniweb.activeWebsite,t=e.activePage?.getLayoutName(),r=(t?e.getLayoutMeta(t):null)?.scroll??globalThis.uniweb.foundationConfig?.scroll??null;return r==="self"?null:r&&document.querySelector(r)||window}function q(e={}){const{enabled:t=!0,resetBlockStates:n=!0}=e,r=T(),s=C(),f=a.useRef(r.key),d=a.useRef(null),c=a.useRef(window),h=a.useCallback(()=>{const o=c.current;o&&E.set(f.current,v(o))},[]);a.useEffect(()=>{if(!t)return;const o=c.current;if(o)return o.addEventListener("scroll",h,{passive:!0}),()=>o.removeEventListener("scroll",h)},[r.key,t,h]),a.useLayoutEffect(()=>{s==="POP"?d.current=E.get(r.key)??null:d.current=null,f.current=r.key,c.current=t?D():null},[r.key,s,t]),a.useEffect(()=>{if(!t)return;const o=c.current;if(o){if(n){const l=globalThis.uniweb.activeWebsite.activePage;l&&typeof l.resetBlockStates=="function"&&l.resetBlockStates()}if(!r.hash)if(s==="POP"){const l=d.current;if(l==null)return;let u,p=0;const m=()=>{o.scrollTo(0,l),Math.abs(v(o)-l)>5&&p<30&&(p++,u=requestAnimationFrame(m))};return u=requestAnimationFrame(m),()=>cancelAnimationFrame(u)}else o.scrollTo(0,0)}},[r.key,s,t,n,r.hash])}function K(e){if(!e)return!1;if(e.startsWith("#")||e.startsWith("/")&&!e.startsWith("//"))return!0;try{return new URL(e,window.location.origin).origin===window.location.origin}catch{return!0}}function V(e){return!(e.defaultPrevented||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.button!==0)}function Y(e){let t=e;for(;t&&t!==document.body;){if(t.tagName==="A")return t;t=t.parentElement}return null}function y(e,t=5){const n=document.getElementById(e);if(n){n.scrollIntoView({behavior:"smooth"});return}t>0&&requestAnimationFrame(()=>{setTimeout(()=>y(e,t-1),50)})}function _(e={}){const{enabled:t=!0}=e,n=B(),r=T();a.useEffect(()=>{if(!t||!r.hash)return;const s=r.hash.slice(1);s&&requestAnimationFrame(()=>{y(s)})},[t,r.pathname,r.hash]),a.useEffect(()=>{if(!t)return;function s(f){if(!V(f))return;const d=Y(f.target);if(!d)return;const c=d.getAttribute("href");if(!c||!K(c)||d.hasAttribute("download")||d.hasAttribute("data-reload"))return;const h=d.getAttribute("target");if(h&&h!=="_self")return;const o=globalThis.uniweb?.activeWebsite,l=o?.basePath||"";let u=c;if(l&&c.startsWith(l)&&(u=c.slice(l.length)||"/"),o?.hasMultipleLocales()){const m=o.getActiveLocale(),L=o.getDefaultLocale(),S=o.getLocales().map(k=>k.code),g=u.match(/^\/([a-z]{2,3}(?:-[A-Za-z]{2,4})?)(?:\/|$)/)?.[1];let b=!1;if(g&&S.includes(g)?b=g!==m:b=m!==L,b)return}if(f.preventDefault(),u.startsWith("#")){const m=u.slice(1);m&&(y(m),window.history.pushState(null,"",c));return}o?.viewTransitions&&document.startViewTransition&&!j?document.startViewTransition(async()=>{await P(u),n(u)}):n(u)}return document.addEventListener("click",s),()=>{document.removeEventListener("click",s)}},[t,n])}function z(){const e=globalThis.uniweb.activeWebsite;if(_({enabled:!0}),q({enabled:!0}),!e)return i.jsx("div",{className:"website-loading",style:{padding:"2rem",textAlign:"center",color:"#64748b"},children:"Loading website..."});const t=e.themeData?.css;return i.jsx(F,{css:t,children:i.jsx(A,{})})}class x extends R.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("[Runtime] Error caught by boundary:",t,n)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:i.jsxs("div",{style:{padding:"2rem",margin:"1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"0.5rem",color:"#dc2626"},children:[i.jsx("h2",{style:{margin:"0 0 1rem"},children:"Something went wrong"}),i.jsx("p",{children:this.state.error?.message||"An unexpected error occurred"}),!1]}):this.props.children}}function oe({basename:e,development:t=!1,externalRouter:n=!1}){const r=globalThis.uniweb?.activeWebsite;if(!r)return null;r.setBasePath&&r.setBasePath(e||"");const s=i.jsx(W,{children:i.jsx(I,{path:"/*",element:i.jsx(z,{})})}),f=n?i.jsx(x,{children:s}):i.jsx(x,{children:i.jsx(M,{basename:e,children:s})});return t?i.jsx(R.StrictMode,{children:f}):f}export{oe as default};
@@ -1 +0,0 @@
1
- import{d as h,h as D,i as b,p as u,a as w}from"../assets/setup-BeQi33In.js";import"../assets/_importmap_react-CrAkajDz.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";import"../assets/index-C_CSAb0x.js";import"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";import"../assets/normalize-DbApPPeG.js";import"./@uniweb-runtime-default-fetcher.js";import"../assets/jsx-runtime-0PlsXv6K.js";import"./@uniweb-theming.js";import"../assets/_importmap_react-router-dom-CLbp1nUY.js";export{h as decodeData,D as hydrateDataStore,b as initUniweb,u as prefersReducedMotion,w as prefetchContent};
@@ -1,53 +0,0 @@
1
- import{g as U,i as R}from"../assets/shade-generator-BBzWo1IN.js";import{f as De,a as ze,b as Me,c as We,p as Be}from"../assets/shade-generator-BBzWo1IN.js";import{n as W}from"../assets/normalize-DbApPPeG.js";const A={light:{section:"var(--neutral-50)",card:"var(--neutral-100)",muted:"var(--neutral-200)",body:"var(--neutral-950)",heading:"var(--neutral-900)",subtle:"var(--neutral-600)",border:"var(--neutral-200)",ring:"var(--primary-500)",link:"var(--primary-600)","link-hover":"var(--primary-700)",accent:"var(--accent-500)",primary:"var(--primary-600)","primary-foreground":"white","primary-hover":"var(--primary-700)","primary-border":"transparent",secondary:"white","secondary-foreground":"var(--neutral-900)","secondary-hover":"var(--neutral-100)","secondary-border":"var(--neutral-300)",success:"#16a34a","success-subtle":"#f0fdf4",warning:"#d97706","warning-subtle":"#fffbeb",error:"#dc2626","error-subtle":"#fef2f2",info:"#2563eb","info-subtle":"#eff6ff"},medium:{section:"var(--neutral-100)",card:"var(--neutral-200)",muted:"var(--neutral-300)",body:"var(--neutral-950)",heading:"var(--neutral-900)",subtle:"var(--neutral-700)",border:"var(--neutral-300)",ring:"var(--primary-500)",link:"var(--primary-600)","link-hover":"var(--primary-700)",accent:"var(--accent-500)",primary:"var(--primary-600)","primary-foreground":"white","primary-hover":"var(--primary-700)","primary-border":"transparent",secondary:"white","secondary-foreground":"var(--neutral-900)","secondary-hover":"var(--neutral-100)","secondary-border":"var(--neutral-300)",success:"#16a34a","success-subtle":"#f0fdf4",warning:"#d97706","warning-subtle":"#fffbeb",error:"#dc2626","error-subtle":"#fef2f2",info:"#2563eb","info-subtle":"#eff6ff"},dark:{section:"var(--neutral-950)",card:"var(--neutral-800)",muted:"var(--neutral-700)",body:"var(--neutral-50)",heading:"white",subtle:"var(--neutral-400)",border:"var(--neutral-700)",ring:"var(--primary-500)",link:"var(--primary-400)","link-hover":"var(--primary-300)",accent:"var(--accent-400)",primary:"var(--primary-500)","primary-foreground":"white","primary-hover":"var(--primary-400)","primary-border":"transparent",secondary:"var(--neutral-800)","secondary-foreground":"var(--neutral-100)","secondary-hover":"var(--neutral-700)","secondary-border":"var(--neutral-600)",success:"#4ade80","success-subtle":"#052e16",warning:"#fbbf24","warning-subtle":"#451a03",error:"#f87171","error-subtle":"#450a0a",info:"#60a5fa","info-subtle":"#172554"}},B={primary:"#3b82f6",secondary:"#64748b",accent:"#8b5cf6",neutral:"#78716c"},Q=[50,100,200,300,400,500,600,700,800,900,950];function I(e,t=" "){return Object.entries(e).map(([o,n])=>`${t}--${o}: ${n};`).join(`
2
- `)}function X(e){const t=[];for(const[o,n]of Object.entries(e))for(const r of Q)n[r]&&t.push(` --${o}-${r}: ${n[r]};`);return t.join(`
3
- `)}function N(e,t={},o={}){const r={...A[e]||A.light,...t},s=o[e]||{},i={...r,...s},l=I(i);return`.context-${e} {
4
- ${l}
5
- }`}function q(e={},t={},o={}){const n=e.default==="system",r=o.dark||{},s={...A.dark,...t,...r},i=I(s);let l=`/* Dark scheme (user preference) */
6
- `;if(l+=`.scheme-dark {
7
- ${i}
8
- }
9
- `,n){l+=`
10
- @media (prefers-color-scheme: dark) {
11
- `,l+=` :root:not(.scheme-light) {
12
- `;for(const[p,u]of Object.entries(s))l+=` --${p}: ${u};
13
- `;l+=` }
14
- `,l+=`}
15
- `}return l}const Z=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-monospace","ui-serif","ui-sans-serif","ui-rounded","math","emoji","fangsong","inherit","initial","revert","unset"]);function ee(e={}){const t=new Set,o=n=>{if(typeof n=="string")for(const r of n.split(",")){const s=r.trim().replace(/^["']|["']$/g,"").toLowerCase();!s||Z.has(s)||/^\d/.test(s)||t.add(s)}};for(const n of Object.values(e))n&&n.load&&o(n.value);return t}function te(e,t){try{const o=new URL(e),n=o.searchParams.getAll("family");if(n.length===0)return e;const r=n.filter(s=>{const i=s.split(":")[0].trim().toLowerCase();return t.has(i)});if(r.length===0)return null;o.searchParams.delete("family");for(const s of r)o.searchParams.append("family",s);return o.toString()}catch{return e}}function ne(e,t){if(!e||!t||t==="/"||!e.startsWith("/")||e.startsWith("//"))return e;const o=t.endsWith("/")?t.slice(0,-1):t;return e===o||e.startsWith(o+"/")?e:o+e}function oe(e){try{return new URL(e).hostname==="fonts.googleapis.com"}catch{return!1}}const Re="<!--uniweb-fonts-->";function re(e={},t={},o="/"){const n=[],r=[],s=ee(e),i={woff2:"font/woff2",woff:"font/woff",truetype:"font/ttf",opentype:"font/otf"};if(t.faces&&Array.isArray(t.faces)){for(const a of t.faces){if(!a.family||!a.src||!s.has(a.family.toLowerCase()))continue;const f=a.format||(a.src.endsWith(".woff2")?"woff2":"woff"),y=ne(a.src,o);n.push("@font-face {",` font-family: ${a.family};`,` src: url('${y}') format('${f}');`,` font-weight: ${a.weight||400};`,` font-style: ${a.style||"normal"};`," font-display: swap;","}");const m=i[f];m&&r.push(`<link rel="preload" href="${y}" as="font" type="${m}" crossorigin>`)}n.length>0&&n.push("")}const l=[],p=new Set;if(t.import&&Array.isArray(t.import)){for(const a of t.import)if(a.url)if(oe(a.url)){const f=te(a.url,s);f&&l.push(f)}else{r.push(`<link rel="stylesheet" href="${a.url}">`);try{p.add(new URL(a.url).origin)}catch{}}}for(const a of p)r.unshift(`<link rel="preconnect" href="${a}">`);if(l.length>0){const a=[];let f="swap";for(const y of l)try{const m=new URL(y);a.push(...m.searchParams.getAll("family")),m.searchParams.get("display")&&(f=m.searchParams.get("display"))}catch{}if(a.length>0){const m=`https://fonts.googleapis.com/css2?${a.map(k=>`family=${k.trim().replace(/\s+/g,"+")}`).join("&")}&display=${f}`;r.unshift('<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link rel="stylesheet" href="${m}">`)}}const u=[];for(const[a,f]of Object.entries(e))f.value&&u.push(` --font-${a}: ${f.value};`);u.length>0&&(n.push(":root {"),n.push(...u),n.push("}"));const h=[];for(const[a,f]of Object.entries(e)){if(!f.apply||!f.applyTo?.length)continue;const y=f.applyTo.join(", ");h.push(`${y} { font-family: var(--font-${a}); }`)}return h.length>0&&(n.push(""),n.push(...h)),{css:n.join(`
16
- `),links:r.join(`
17
- `)}}const se=new Set(["section","card","muted","body","heading","subtle","border","ring","link","link-hover","accent","primary","primary-foreground","primary-hover","primary-border","secondary","secondary-foreground","secondary-hover","secondary-border","success","success-subtle","warning","warning-subtle","error","error-subtle","info","info-subtle"]),ae=/^(primary|secondary|accent|neutral)-\d+$/;function ie(e={}){if(!e||Object.keys(e).length===0)return"";const t=[];for(const[o,n]of Object.entries(e)){(se.has(o)||ae.test(o))&&console.warn(`Warning: Foundation var '${o}' collides with a theme token. Rename it to avoid unexpected behavior (e.g., '${o}-value' or '${o}-size').`);const r=typeof n=="object"?n.default:n;r!==void 0&&t.push(` --${o}: ${r};`)}return t.length===0?"":`:root {
18
- ${t.join(`
19
- `)}
20
- }`}function G(e={},t={}){const{base:o="/"}=t,{colors:n=B,contexts:r={},fonts:s={},fontRoles:i={},appearance:l={},foundationVars:p={},colorVars:u={}}=e,h=[],a=re(i,s,o);a.css&&h.push(`/* Typography */
21
- `+a.css);const f=U(n),y=X(f);h.push(`/* Color Palettes */
22
- :root {
23
- ${y}
24
- }`);const m=u.light||{},k={...A.light,...r.light||{},...m},w=I(k);h.push(`/* Default Semantic Tokens */
25
- :root {
26
- ${w}
27
- }
28
-
29
- /* Section backgrounds — applied once, resolves via context tokens */
30
- [id^="section-"] {
31
- background-color: var(--section);
32
- }`);const g=[N("light",r.light,u),N("medium",r.medium,u),N("dark",r.dark,u)];h.push(`/* Color Contexts */
33
- `+g.join(`
34
-
35
- `));const $=ie(p);if($&&h.push(`/* Foundation Variables */
36
- `+$),(l.allowToggle||l.default==="dark"||l.default==="system"||l.schemes?.includes("dark"))&&h.push(q(l,r.dark,u)),h.push(`/* Site Background */
37
- body {
38
- background: ${e.background||"var(--section)"};
39
- }`),e.inline&&typeof e.inline=="object"){const j=Object.entries(e.inline).filter(([,v])=>v&&typeof v=="object").map(([v,V])=>{const b=Object.entries(V).map(([F,L])=>` ${F}: ${L};`).join(`
40
- `);return`span[${v}] {
41
- ${b}
42
- }`});j.length>0&&h.push(`/* Inline Text Styles */
43
- `+j.join(`
44
-
45
- `))}return{css:h.join(`
46
-
47
- `),links:a.links}}function ce(){return JSON.parse(JSON.stringify(A))}function le(){return{...B}}const P={stone:"#78716c",zinc:"#71717a",gray:"#6b7280",slate:"#64748b",neutral:"#737373"},fe={accent:{color:"var(--accent)","font-weight":"600"},callout:{color:"var(--accent)","font-weight":"600"},muted:{color:"var(--subtle)"}},D={default:"light",allowToggle:!1,respectSystemPreference:!0},ue={body:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',heading:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',code:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace'},de={body:["body"],heading:["h1","h2","h3"],code:["code","pre","kbd","samp"]},pe=new Set(["font-weight","font-style","font-size","font-stretch","font-feature-settings","font-variation-settings","font-variant","font-kerning","font-optical-sizing","font-synthesis","font-size-adjust","font-smoothing","font-palette","font-language-override"]);function he(e,t){return(typeof t=="object"?t?.type:void 0)==="font"?!0:e.startsWith("font-")&&!pe.has(e)}function z(e){return e.startsWith("font-")?e.slice(5):e}function me(e){if(e==null)return null;const o=(Array.isArray(e)?e:String(e).split(",")).map(n=>String(n).trim()).filter(Boolean);return o.length?o:null}function ye(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};for(const[o,n]of Object.entries(e))if(!(typeof n=="object"&&n!==null)){if(typeof n!="string"){t.push(`Color "${o}" must be a string or shade object, got ${typeof n}`);continue}o==="neutral"&&P[n]||R(n)||t.push(`Color "${o}" has invalid value: ${n}`)}return{valid:t.length===0,errors:t}}function ge(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};const o=["light","medium","dark"];for(const[n,r]of Object.entries(e)){if(!o.includes(n)){t.push(`Unknown context "${n}". Valid contexts: ${o.join(", ")}`);continue}(typeof r!="object"||r===null)&&t.push(`Context "${n}" must be an object`)}return{valid:t.length===0,errors:t}}function be(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};if(e.import!==void 0)if(!Array.isArray(e.import))t.push("fonts.import must be an array");else for(const[o,n]of e.import.entries())(typeof n!="object"||!n.url)&&t.push(`fonts.import[${o}] must have a "url" property`);return{valid:t.length===0,errors:t}}function ve(e){const t=[];if(!e||typeof e!="object")return typeof e=="string"&&(["light","dark","system"].includes(e)||t.push(`Invalid appearance value: ${e}. Must be "light", "dark", or "system"`)),{valid:t.length===0,errors:t};if(e.default&&!["light","dark","system"].includes(e.default)&&t.push(`Invalid appearance.default: ${e.default}`),e.schemes!==void 0)if(!Array.isArray(e.schemes))t.push("appearance.schemes must be an array");else{const o=["light","dark"];for(const n of e.schemes)o.includes(n)||t.push(`Invalid scheme: ${n}. Valid schemes: ${o.join(", ")}`)}return{valid:t.length===0,errors:t}}function je(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};for(const[o,n]of Object.entries(e)){if(typeof n!="string"){t.push(`code.${o} must be a string, got ${typeof n}`);continue}R(n)||t.push(`code.${o} has invalid color value: ${n}`)}return{valid:t.length===0,errors:t}}const M=new Set(["color","gradient"]);function ke(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};for(const[o,n]of Object.entries(e))/^[a-z][a-z0-9-]*$/i.test(o)||t.push(`Invalid variable name "${o}". Use lowercase letters, numbers, and hyphens.`),typeof n!="object"&&typeof n!="string"&&typeof n!="number"&&t.push(`Variable "${o}" must have a string, number, or config object value`);return{valid:t.length===0,errors:t}}function $e(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:[]};const o=ye(e.colors),n=ge(e.contexts),r=be(e.fonts),s=ve(e.appearance),i=je(e.code);return t.push(...o.errors),t.push(...n.errors),t.push(...r.errors),t.push(...s.errors),t.push(...i.errors),{valid:t.length===0,errors:t}}function Oe(e,t){const o={...e};for(const[n,r]of Object.entries(t||{}))o[n]=r&&typeof r=="object"&&!Array.isArray(r)?{...e[n]||{},...r}:r;return o}function Se(e){return e?typeof e=="string"?{default:e,allowToggle:!1,respectSystemPreference:e==="system"}:{...D,...e}:{...D}}function we(e={},t={}){const o={},n={};for(const[r,s]of Object.entries(e)){const i=typeof s=="object"?{...s}:{default:s};if(M.has(i.type)){const p=i.default||"";n[r]={light:p,dark:p}}else o[r]=i}for(const[r,s]of Object.entries(t)){const i=e[r],l=typeof i=="object"?i?.type:void 0;if(M.has(l))if(typeof s=="object"&&s!==null&&(s.light||s.dark))n[r]={...n[r]||{},...s};else{const u=String(s);n[r]={light:u,dark:u}}else o[r]?o[r].default=s:o[r]={default:s}}return{flat:o,colorVars:n}}function H(e={},t={}){const{foundationVars:o={},strict:n=!1}=t,r=[],s=[],i=$e(e);if(!i.valid&&(r.push(...i.errors),n))throw new Error(`Theme configuration errors:
48
- ${r.join(`
49
- `)}`);const l=le(),p={...e.colors||{}};typeof p.neutral=="string"&&P[p.neutral]&&(p.neutral=P[p.neutral]);const u=p.primary??l.primary,h=c=>typeof c=="object"&&c!==null||R(c);p.accent===void 0&&h(u)&&(p.accent=u);const a={};for(const[c,d]of Object.entries({...l,...p}))(typeof d=="object"&&d!==null||R(d))&&(a[c]=d);const f=a,y=U(f);e.colors?.primary||s.push("No primary color specified, using default blue (#3b82f6)"),e.colors?.neutral||s.push("No neutral color specified, using default stone (#78716c)");const m=ce(),k=e.contexts||{},w={};for(const c of["light","medium","dark"]){const d=k[c]||{},O={};for(const[S,x]of Object.entries(d))O[S]=W(x);w[c]={...m[c],...O}}const g={...e.fonts||{}},$=Se(e.appearance),{flat:j,colorVars:v}=we(o,e.vars||e.foundationVars||{}),V=ke(j);V.valid||s.push(...V.errors);const b={};for(const[c,d]of Object.entries(de))b[c]={value:ue[c],applyTo:[...d],foundationOwned:!1,userSet:!1};const F={};for(const[c,d]of Object.entries(j)){if(!he(c,d)){F[c]=d;continue}const O=z(c),S=typeof d=="object"?d:{default:d},x=b[O];b[O]={value:S.default??x?.value,applyTo:S.applyTo!==void 0?me(S.applyTo):x?.applyTo??null,foundationOwned:!0,userSet:!1}}const L=new Set(["import","faces"]);for(const[c,d]of Object.entries(g)){if(L.has(c))continue;const O=z(c),S=b[O];b[O]={value:d,applyTo:S?.applyTo??null,foundationOwned:S?.foundationOwned??!1,userSet:!0}}for(const c of Object.values(b)){const d=c.foundationOwned||c.userSet;c.apply=d&&Array.isArray(c.applyTo)&&c.applyTo.length>0,c.load=d}g.mono!==void 0&&!b.mono?.foundationOwned&&s.push("theme.yml `fonts.mono` is not a built-in font role — the code/monospace role is `code`. Rename `fonts.mono` → `fonts.code`.");const E={};g.import!==void 0&&(E.import=g.import),g.faces!==void 0&&(E.faces=g.faces);for(const[c,d]of Object.entries(b))E[c]=d.value;const K=e.code??null,Y=e.background||null,J=Oe(fe,e.inline);return{config:{colors:f,palettes:y,contexts:w,fonts:E,fontRoles:b,appearance:$,foundationVars:F,colorVars:v,code:K,background:Y,inline:J},errors:r,warnings:s}}function Le(e){if(!e)return{};const t=e.default||e;return t.vars||t}function Ne(e){return e?._self?.vars!=null||e?._self?.themeVars!=null||e?.themeVars!=null}function Ve(e){if(!e)return!1;const{colors:t,foundationStyles:o}=e;if(o&&Object.keys(o).length>0)return!0;if(!t)return!1;const n=t.colors?.light&&Object.keys(t.colors.light).length>0,r=t.elements&&Object.values(t.elements).some(s=>s&&Object.keys(s).length>0);return n||r}function Te(e){if(!e||Object.keys(e).length===0)return[];const t=[],o=U(e);for(const[n,r]of Object.entries(o))for(const[s,i]of Object.entries(r))t.push(` --${n}-${s}: ${i};`);return t}function _(e){if(!e||Object.keys(e).length===0)return[];const t=[];for(const[o,n]of Object.entries(e))n===""||n==null||t.push(` --${o}: ${W(n)};`);return t}function T(e){if(!e||Object.keys(e).length===0)return[];const t=[];for(const[o,n]of Object.entries(e))n===""||n==null||typeof n=="object"||t.push(` --${o}: ${n};`);return t}function Ae(e){if(!e||Object.keys(e).length===0)return{flat:{},contexts:{}};const t={},o={};for(const[n,r]of Object.entries(e))if(r!=null)if(typeof r=="object")for(const[s,i]of Object.entries(r))i===""||i==null||(o[s]||(o[s]={}),o[s][n]=i);else t[n]=r;return{flat:t,contexts:o}}function C(e,t){return t.length===0?"":`${e} {
50
- ${t.join(`
51
- `)}
52
- }
53
- `}function _e(e,t={}){if(!e||e.length===0)return"";let o="";for(const n of e){const r=Ve(n.standardOptions),s=n.componentVars&&Object.keys(n.componentVars).length>0;if(!r&&!s)continue;const{colors:i,foundationStyles:l}=n.standardOptions||{},u=`#section-${n.stableId||n.id}`,h=!n.themeName,a=t.allowToggle,f=Te(i?.colors?.light),{flat:y,contexts:m}=Ae(l),k=T(y),w=T(n.componentVars);if(h&&a){const g=_(i?.elements?.light),$=_(i?.elements?.dark),j=T(m.light),v=T(m.dark),V=[...f,...k,...w];o+=C(u,V),o+=C(`:root:not(.scheme-dark) ${u}`,[...g,...j]),o+=C(`.scheme-dark ${u}`,[...$,...v])}else{const g=a&&n.themeName||"light",$=_(i?.elements?.[g]),j=T(m[g]),v=[...f,...$,...k,...w,...j];o+=C(u,v)}}return o}function Fe(e={},t={}){const{config:o,errors:n,warnings:r}=H(e,t),{css:s,links:i}=G(o,{base:t.base});return{css:s,links:i,config:o,errors:n,warnings:r}}const Pe={buildTheme:Fe,processTheme:H,generateThemeCSS:G};export{Re as FONT_LINKS_MARKER,_e as buildSectionOverrides,Fe as buildTheme,Pe as default,Le as extractFoundationVars,ee as extractUsedFamilies,De as formatHex,ze as formatOklch,Ne as foundationHasVars,N as generateContextCSS,ie as generateFoundationVars,X as generatePaletteVars,U as generatePalettes,Me as generateShades,G as generateThemeCSS,le as getDefaultColors,ce as getDefaultContextTokens,We as getShadeLevels,he as isFontVar,R as isValidColor,W as normalizeTokenValue,Be as parseColor,H as processTheme,$e as validateThemeConfig};
@@ -1 +0,0 @@
1
- import{c as o}from"../assets/client-CQjOKqaN.js";import{a as n}from"../assets/client-CQjOKqaN.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";import"../assets/index-VvOM7xKK.js";const s=o.createRoot,c=o.hydrateRoot,i=o.version;export{s as createRoot,n as default,c as hydrateRoot,i as version};