@symbo.ls/brender 3.14.661 → 3.14.663

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 CHANGED
@@ -1,5 +1,79 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.663
4
+
5
+ ### Patch Changes
6
+
7
+ - Server rendering is correct and fast, opt-in hydration, and Cloudflare deploys run the full build (FW-BRENDER-HYDRATION-AND-CF-DEPLOY-PROVIDER-1, FW-PUBLISH-TIME-PRERENDER-SSRCACHE-1).
8
+
9
+ Behaviour changes (check these first):
10
+
11
+ - `smbls build` copies `public/` into the output root (never replacing a file the bundler wrote), so `_redirects`, `_headers` and `404.html` ship with every bundler.
12
+ - Booting over a pre-rendered page removes only `style[data-emotion="smbls"]` and `style[data-brender]`; the host page's own `<style>` tags stay.
13
+ - The Cloudflare worker (`renderProjectHtml` without eval) keeps the client render instead of painting a wrong pre-render; a stored pre-render (`ssrCache` / `__ssr`) is still served. `ssrWithoutEval: true` opts back in.
14
+
15
+ Fixes:
16
+
17
+ - Every server render after the first one paints its theme colours again (linkedom made `deepClone` copy nothing nested).
18
+ - Server pages ship their own reset, keyframes and `:root` once, also in the Cloudflare worker (`generateGlobalCSS` read the wrong keys, wrote files and cached across projects).
19
+ - A pre-render waits for its own requests instead of a flat 2 s; server renders stop rescanning the head for every inserted rule.
20
+ - The server render gets the project's `globalScope` and context keys, as the client does; a `<select>` with a value no longer drops its parent.
21
+
22
+ New, opt-in:
23
+
24
+ - Hydration: `hydrate: true` (or `window.__BRENDER_HYDRATE__` from the server, with `__BR_REGISTRY__`) adopts the server DOM instead of replacing it; a mismatch falls back to a fresh node, a throw to the fresh render. brender `renderPage({ adoptDom })` ships the registry and the recorded GET answers; `@symbo.ls/fetch` exports `createEarlySeedScript`, `earlyKey`, `EARLY_KEY`.
25
+ - `smbls deploy --provider cloudflare [--target pages|workers] [--dry-run] [--no-brender]` runs the full `smbls build` pipeline; `--target workers` writes Workers Static Assets config.
26
+ - `smbls publish --ssr` (or `"prerender": true` in `symbols.json`) pre-renders every static route and stores it as `__ssr`, which the platform renderer serves; off by default.
27
+
28
+ - Updated dependencies
29
+ - smbls@3.14.828
30
+ - @symbo.ls/element@3.14.800
31
+ - @symbo.ls/css@3.14.775
32
+ - @symbo.ls/fetch@3.14.663
33
+
34
+ ## 3.14.662
35
+
36
+ ### Patch Changes
37
+
38
+ - Fixes for the 42 issues reported while building xma.info (FW-XMA-EXCEPTIONS-UPSTREAM-1).
39
+
40
+ Behaviour changes (check these first):
41
+
42
+ - CSS precedence across `extends`: a later layer's shorthand that states a longhand now beats a longhand an earlier layer declared (`borderWidth: '0'` no longer loses to a base `borderBottomWidth`; a derived `border: 'hairline solid …'` now paints over a base `borderWidth: '0'`). Positional shorthands (`background`, `transition`, `font`, `flex`, `grid`…) never remove a base longhand. A `:focus-visible` longhand (`outlineColor`) now paints over Link/Focusable's ring.
43
+ - Built-in `Img` no longer copies `alt` into `title`. `Link` leaves Ctrl/Cmd/Shift/Alt, middle, `target` and `download` clicks to the browser.
44
+ - `X<` breakpoints start at N.02px, so no width matches both `X` and `X<`.
45
+ - Helmet renders the head as the merge of mounted layers: keys a page leaves out fall back instead of staying from the previous page.
46
+ - `smbls build` with `"brender": true` pre-renders again (it rendered nothing since 3.14.6): every static route is written, `/*` becomes `404.html`, `:param` routes are skipped and listed, and the build exits 1 when no route renders.
47
+ - `onStateInit`, `onStateCreated` and `onBeforeStateUpdate` run again (`onBeforeStateUpdate` returning `false` cancels the update).
48
+ - `onWindowLoad` runs once right after creation when the page had already loaded.
49
+ - The first render no longer forces a style+layout pass per microtask.
50
+ - socket.io-client loads only when a sync transport is configured; the ESM build ships it as `dist/smbls.socket-io-client.esm.js` (keep it beside `smbls.esm.js`).
51
+
52
+ New, opt-in:
53
+
54
+ - `designSystem.focusableRing`; `vars` and top-level `'--x'` keys set reactive custom properties; `fill`/`stroke` are CSS outside `<svg>`; attributes inside `.isX` / `'!isX'` blocks apply.
55
+ - Design-system tokens resolve inside `style: {}` blocks; `sizes` tokens negate (`-hairline2`) and publish `--size-<name>`.
56
+ - `fetchpriority` and every multi-word attribute work flat in both spellings.
57
+ - `inertOutside`, the `Bridge` host for DOM-owning libraries, element events with `{ capture, passive, once, selector, handler }`, `TooltipLayer` for `[data-tooltip]` nodes.
58
+ - Router `scrollRestoration: 'restore'`; guards that refuse Back/Forward put the address back; lazy route groups (`context.lazy`, `el.call('loadLazy')`).
59
+ - Fetch: `el.call('invalidateQueries')` and friends, `invalidates` on rpc, `fetch.early` pre-boot requests, `fetch.reads` anonymous GET reads without a CORS preflight.
60
+ - Polyglot `setLang` switches text, `<html lang>` and fonts in one frame; `getPendingLang`.
61
+ - `s.$settled()` / `settled()` await the DOM a state write produces; `onMediaQueryChange` takes design-system media keys; the `animation` shorthand resolves tokens.
62
+ - `smbls/ssr` entry for server rendering; `smbls push` publishes `new URL('<path>', import.meta.url)` assets.
63
+ - frank-audit: FA105 per-tag, FA410 (history writes), wider FA701; opt-in FA211, FA810, FA811, FA812; unknown `--rule` ids are reported.
64
+
65
+ - Updated dependencies [95d31cb]
66
+ - Updated dependencies [13c4922]
67
+ - Updated dependencies
68
+ - @symbo.ls/css@3.14.774
69
+ - smbls@3.14.827
70
+ - @symbo.ls/utils@3.14.784
71
+ - @symbo.ls/fetch@3.14.662
72
+ - @symbo.ls/helmet@3.14.669
73
+ - @symbo.ls/element@3.14.799
74
+ - @symbo.ls/scratch@3.14.786
75
+ - @symbo.ls/default-config@3.14.785
76
+
3
77
  ## 3.14.658
4
78
 
5
79
  ### Patch Changes
package/dist/esm/env.js CHANGED
@@ -1 +1 @@
1
- import{parseHTML as i}from"linkedom";const c=(r="<!DOCTYPE html><html><head></head><body></body></html>")=>{const{window:e,document:l}=i(r);e.requestAnimationFrame||(e.requestAnimationFrame=o=>{const t=setTimeout(o,0);return t?.unref&&t.unref(),t}),e.cancelAnimationFrame||(e.cancelAnimationFrame=o=>clearTimeout(o)),e.history||(e.history={pushState:()=>{},replaceState:()=>{},state:null}),e.location||(e.location={pathname:"/",search:"",hash:"",origin:"http://localhost"}),e.URL||(e.URL=URL),e.scrollTo||(e.scrollTo=()=>{});const a=()=>{const o={};return{getItem:t=>o[t]??null,setItem:(t,s)=>{o[t]=String(s)},removeItem:t=>{delete o[t]},clear:()=>{for(const t in o)delete o[t]},get length(){return Object.keys(o).length},key:t=>Object.keys(o)[t]??null}};return e.localStorage||(e.localStorage=a()),e.sessionStorage||(e.sessionStorage=a()),globalThis.localStorage||(globalThis.localStorage=e.localStorage),globalThis.sessionStorage||(globalThis.sessionStorage=e.sessionStorage),e.MutationObserver||(e.MutationObserver=class{constructor(){}observe(){}disconnect(){}takeRecords(){return[]}}),globalThis.window=e,globalThis.document=l,globalThis.Node=e.Node||globalThis.Node,globalThis.Element=e.Element||globalThis.Element,globalThis.HTMLElement=e.HTMLElement||globalThis.HTMLElement,globalThis.MutationObserver=e.MutationObserver,globalThis.Window=e.constructor,{window:e,document:l}};export{c as createEnv};
1
+ import{parseHTML as c}from"linkedom";const a=new WeakSet;class h{static[Symbol.hasInstance](e){return a.has(e)}}const u=n=>{let e=Object.getPrototypeOf(n.createElement("select")),l;for(;e&&!(l=Object.getOwnPropertyDescriptor(e,"value"));)e=Object.getPrototypeOf(e);!e||!l||!l.get||l.set||Object.defineProperty(e,"value",{configurable:!0,enumerable:l.enumerable,get:l.get,set(r){const o=r==null?"":String(r);let t=!1;for(const s of this.querySelectorAll("option")){const i=s.hasAttribute("value")?s.getAttribute("value"):s.textContent;!t&&i===o?(s.setAttribute("selected",""),t=!0):s.removeAttribute("selected")}}})},b=(n="<!DOCTYPE html><html><head></head><body></body></html>")=>{const{window:e,document:l}=c(n);e.requestAnimationFrame||(e.requestAnimationFrame=o=>{const t=setTimeout(o,0);return t?.unref&&t.unref(),t}),e.cancelAnimationFrame||(e.cancelAnimationFrame=o=>clearTimeout(o)),e.history||(e.history={pushState:()=>{},replaceState:()=>{},state:null}),e.location||(e.location={pathname:"/",search:"",hash:"",origin:"http://localhost",protocol:"http:",host:"localhost",hostname:"localhost",port:"",href:"http://localhost/"}),e.URL||(e.URL=URL),e.scrollTo||(e.scrollTo=()=>{});const r=()=>{const o={};return{getItem:t=>o[t]??null,setItem:(t,s)=>{o[t]=String(s)},removeItem:t=>{delete o[t]},clear:()=>{for(const t in o)delete o[t]},get length(){return Object.keys(o).length},key:t=>Object.keys(o)[t]??null}};return e.localStorage||(e.localStorage=r()),e.sessionStorage||(e.sessionStorage=r()),globalThis.localStorage||(globalThis.localStorage=e.localStorage),globalThis.sessionStorage||(globalThis.sessionStorage=e.sessionStorage),u(l),e.MutationObserver||(e.MutationObserver=class{constructor(){}observe(){}disconnect(){}takeRecords(){return[]}}),globalThis.window=e,globalThis.document=l,globalThis.Node=e.Node||globalThis.Node,globalThis.Element=e.Element||globalThis.Element,globalThis.HTMLElement=e.HTMLElement||globalThis.HTMLElement,globalThis.MutationObserver=e.MutationObserver,a.add(e),e.constructor&&e.constructor!==Object?globalThis.Window=e.constructor:(typeof globalThis.Window!="function"||globalThis.Window===Object)&&(globalThis.Window=h),{window:e,document:l}};export{b as createEnv};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{createEnv as e}from"./env.js";import{resetKeys as r,assignKeys as t,mapKeysToElements as o}from"./keys.js";import{loadProject as a,loadAndRenderAll as m}from"./load.js";import{render as d,renderElement as n,renderRoute as l,renderPage as p,resetGlobalCSSCache as i,getAccumulatedEmotionCSS as c,replaceEmotionCSS as f}from"./render.js";import{extractMetadata as s,generateHeadHtml as S}from"./metadata.js";import{collectBrNodes as g,hydrate as E}from"./hydrate.js";import{generateSitemap as h}from"./sitemap.js";import{prefetchPageData as u,injectPrefetchedState as y}from"./prefetch.js";var b={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:a,loadAndRenderAll:m,render:d,renderElement:n,renderRoute:l,renderPage:p,resetGlobalCSSCache:i,getAccumulatedEmotionCSS:c,replaceEmotionCSS:f,extractMetadata:s,generateHeadHtml:S,collectBrNodes:g,hydrate:E,generateSitemap:h,prefetchPageData:u,injectPrefetchedState:y};export{t as assignKeys,g as collectBrNodes,e as createEnv,b as default,s as extractMetadata,S as generateHeadHtml,h as generateSitemap,c as getAccumulatedEmotionCSS,E as hydrate,y as injectPrefetchedState,m as loadAndRenderAll,a as loadProject,o as mapKeysToElements,u as prefetchPageData,d as render,n as renderElement,p as renderPage,l as renderRoute,f as replaceEmotionCSS,i as resetGlobalCSSCache,r as resetKeys};
1
+ import{createEnv as e}from"./env.js";import{resetKeys as r,assignKeys as t,mapKeysToElements as o}from"./keys.js";import{loadProject as m,loadAndRenderAll as a}from"./load.js";import{render as p,renderElement as n,renderRoute as d,renderPage as i,resetGlobalCSSCache as l,getAccumulatedEmotionCSS as c,replaceEmotionCSS as f,adoptionScripts as s}from"./render.js";import{extractMetadata as S,generateHeadHtml as g}from"./metadata.js";import{collectBrNodes as h,hydrate as E}from"./hydrate.js";import{generateSitemap as u}from"./sitemap.js";import{prefetchPageData as y,injectPrefetchedState as C}from"./prefetch.js";import{composeIntoShell as P}from"./shell.js";var D={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:m,loadAndRenderAll:a,render:p,renderElement:n,renderRoute:d,renderPage:i,resetGlobalCSSCache:l,getAccumulatedEmotionCSS:c,replaceEmotionCSS:f,extractMetadata:S,generateHeadHtml:g,collectBrNodes:h,hydrate:E,generateSitemap:u,prefetchPageData:y,injectPrefetchedState:C,composeIntoShell:P,adoptionScripts:s};export{s as adoptionScripts,t as assignKeys,h as collectBrNodes,P as composeIntoShell,e as createEnv,D as default,S as extractMetadata,g as generateHeadHtml,u as generateSitemap,c as getAccumulatedEmotionCSS,E as hydrate,C as injectPrefetchedState,a as loadAndRenderAll,m as loadProject,o as mapKeysToElements,y as prefetchPageData,p as render,n as renderElement,i as renderPage,d as renderRoute,f as replaceEmotionCSS,l as resetGlobalCSSCache,r as resetKeys};
@@ -1 +1 @@
1
- const h=t=>typeof t=="function",b=t=>Array.isArray(t),y=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),S=(t,r)=>{if(t){if(h(t))try{return t({state:r||{},call:()=>{},__ref:{}},r||{})}catch{return}return t}},_=(t,r)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const n=h(t)?null:{...t};return!n||(n.method||(n.method="select"),h(n.params)&&(n.params=S(n.params,r)),n.method==="insert"||n.method==="update"||n.method==="upsert"||n.method==="delete")||n.on&&n.on!=="create"?null:n},A=(t,r="")=>{if(!t||typeof t!="object")return[];if(h(t))return[];const n=[],s=t.state||{};if(t.fetch){const e=b(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=_(c,s);o&&n.push({config:o,stateKey:o.as,path:r,elementState:s})}}for(const e in t)e==="fetch"||e==="state"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs"||e.charAt(0)>="A"&&e.charAt(0)<="Z"&&y(t[e])&&n.push(...A(t[e],r?`${r}.${e}`:e));return n},w=async t=>null,k=async(t,r)=>{try{const{method:n,from:s,params:e,transform:c,limit:o,offset:i,order:l,single:u}=r;let f;n==="rpc"?f=await t.rpc({from:s,params:e}):f=await t.select({from:s,select:r.select,params:e,limit:o,offset:i,order:l,single:u});let a=f?.data??null;if(f?.error)return null;if(a&&c&&h(c))try{a=c(a)}catch{}return a}catch{return null}},x=async(t,r="/",n={})=>{const e=(t.pages||{})[r];if(!e)return new Map;const c=t.config||t.settings||{},o=c.fetch||t.fetch||c.db||t.db;if(!o)return new Map;const i=await w(o);if(!i)return new Map;const l=A(e);if(!l.length)return new Map;const u=new Map,f=await Promise.allSettled(l.map(async({config:a,stateKey:p,path:m})=>{const g=await k(i,a);if(g!==null){const d=u.get(m)||{};p?d[p]=g:y(g)&&Object.assign(d,g),u.set(m,d)}}));return u},M=async t=>{const r=t.config||{},n=r.polyglot||t.polyglot;if(!n?.fetch)return null;const s=r.fetch||t.fetch||r.db||t.db;if(!s)return null;const e=await w(s);if(!e)return null;const c=n.fetch,o=c.rpc||c.from||"get_translations_if_changed",i=n.languages||[n.defaultLang||"en"],l={},u=await Promise.allSettled(i.map(async f=>{try{const a=await e.rpc({from:o,params:{p_lang:f,p_cached_version:0}});if(a.error||!a.data)return;const p=a.data;p.translations&&(l[f]=p.translations)}catch(a){console.warn("[brender] SSR translation fetch failed:",a.message)}}));return Object.keys(l).length?l:null},j=(t,r)=>{if(!(!t||typeof t!="object")){for(const n in t)if(!(n==="state"||n==="fetch"||n==="props"||n==="attr"||n==="on"||n==="define"||n==="childExtends"||n==="childProps"||n==="childrenAs")&&n.charAt(0)>="A"&&n.charAt(0)<="Z"&&y(t[n])){const s=t[n],e=s.state&&typeof s.state=="object"?{...r,...s.state}:r;if(h(s.children))try{const c={state:e,call:i=>{if(i==="getActiveLang"||i==="getLang")return e?.lang||"ka";if(i==="polyglot")return arguments[1]||""},__ref:{}},o=s.children(c,e);b(o)&&o.length>0&&(s.children=o)}catch{}j(s,e)}}},P=(t,r)=>{if(!(!r||!r.size))for(const[n,s]of r){let e=t;if(n){const c=n.split(".");for(const o of c){if(!e||typeof e!="object")break;e=e[o]}}e&&typeof e=="object"&&((!e.state||typeof e.state!="object")&&(e.state={}),Object.assign(e.state,s),j(e,e.state))}};export{M as fetchSSRTranslations,P as injectPrefetchedState,x as prefetchPageData};
1
+ const o=t=>typeof t=="function",b=t=>Array.isArray(t),g=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),j=(t,r)=>{if(t){if(o(t))try{return t({state:r||{},call:()=>{},__ref:{}},r||{})}catch{return}return t}},k=(t,r)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const e=o(t)?null:{...t};return!e||(e.method||(e.method="select"),o(e.params)&&(e.params=j(e.params,r)),e.method==="insert"||e.method==="update"||e.method==="upsert"||e.method==="delete")||e.on&&e.on!=="create"?null:e},S=(t,r="")=>{if(!t||typeof t!="object")return[];if(o(t))return[];const e=[],s=t.state||{};if(t.fetch){const n=b(t.fetch)?t.fetch:[t.fetch];for(const c of n){const a=k(c,s);a&&e.push({config:a,stateKey:a.as,path:r,elementState:s})}}for(const n in t)n==="fetch"||n==="state"||n==="props"||n==="attr"||n==="on"||n==="define"||n==="childExtends"||n==="childProps"||n==="childrenAs"||n.charAt(0)>="A"&&n.charAt(0)<="Z"&&g(t[n])&&e.push(...S(t[n],r?`${r}.${n}`:n));return e},M=["rest","local"],w=new WeakMap,A=async t=>{if(!t)return null;if(g(t)&&(o(t.select)||o(t.rpc)))return t;const r=typeof t=="string"?{adapter:t}:t;if(!g(r)||typeof r.adapter!="string")return null;if(w.has(r))return w.get(r);const e=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(o(s.hasAdapter)?s.hasAdapter(r.adapter):M.includes(r.adapter)))return null;try{return await s.resolveDb(r)}catch(c){return console.warn(`[brender] SSR adapter "${r.adapter}" unavailable: ${c.message}`),null}})();return w.set(r,e),e},P=async(t,r)=>{try{const{method:e,from:s,params:n,transform:c,limit:a,offset:l,order:u,single:h,headers:d,baseUrl:i}=r;let f;if(e==="rpc"){if(!o(t.rpc))return null;f=await t.rpc({from:s,params:n,headers:d,baseUrl:i})}else{if(!o(t.select))return null;f=await t.select({from:s,select:r.select,params:n,limit:a,offset:l,order:u,single:h,headers:d,baseUrl:i})}let p=f?.data??null;if(f?.error)return null;if(p&&c&&o(c))try{p=c(p)}catch{}return p}catch{return null}},x=async(t,r="/",e={})=>{const n=(t.pages||{})[r];if(!n)return new Map;const c=t.config||t.settings||{},a=c.fetch||t.fetch||c.db||t.db;if(!a)return new Map;const l=await A(a);if(!l)return new Map;const u=S(n);if(!u.length)return new Map;const h=new Map,d=await Promise.allSettled(u.map(async({config:i,stateKey:f,path:p})=>{const y=await P(l,i);if(y!==null){const m=h.get(p)||{};f?m[f]=y:g(y)&&Object.assign(m,y),h.set(p,m)}}));return h},E=async t=>{const r=t.config||{},e=r.polyglot||t.polyglot;if(!e?.fetch)return null;const s=r.fetch||t.fetch||r.db||t.db;if(!s)return null;const n=await A(s);if(!n)return null;const c=e.fetch,a=c.rpc||c.from||"get_translations_if_changed",l=e.languages||[e.defaultLang||"en"],u={},h=await Promise.allSettled(l.map(async d=>{try{if(!o(n.rpc))return;const i=await n.rpc({from:a,params:{p_lang:d,p_cached_version:0}});if(i.error||!i.data)return;const f=i.data;f.translations&&(u[d]=f.translations)}catch(i){console.warn("[brender] SSR translation fetch failed:",i.message)}}));return Object.keys(u).length?u:null},_=(t,r)=>{if(!(!t||typeof t!="object")){for(const e in t)if(!(e==="state"||e==="fetch"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs")&&e.charAt(0)>="A"&&e.charAt(0)<="Z"&&g(t[e])){const s=t[e],n=s.state&&typeof s.state=="object"?{...r,...s.state}:r;if(o(s.children))try{const c={state:n,call:l=>{if(l==="getActiveLang"||l==="getLang")return n?.lang||"ka";if(l==="polyglot")return arguments[1]||""},__ref:{}},a=s.children(c,n);b(a)&&a.length>0&&(s.children=a)}catch{}_(s,n)}}},D=(t,r)=>{if(!(!r||!r.size))for(const[e,s]of r){let n=t;if(e){const c=e.split(".");for(const a of c){if(!n||typeof n!="object")break;n=n[a]}}n&&typeof n=="object"&&((!n.state||typeof n.state!="object")&&(n.state={}),Object.assign(n.state,s),_(n,n.state))}};export{A as createSSRAdapter,E as fetchSSRTranslations,D as injectPrefetchedState,x as prefetchPageData};
@@ -1,87 +1,25 @@
1
- import{resolve as d,join as tt,dirname as q}from"path";import{existsSync as b,unlinkSync as kt,readFileSync as K,realpathSync as $t}from"fs";import{resolvePackageEntry as Ct}from"./packageEntry.js";import{tmpdir as Ot}from"os";import{randomBytes as Tt}from"crypto";import{createRequire as et}from"module";import{createEnv as nt}from"./env.js";import{resetKeys as st,assignKeys as rt,mapKeysToElements as it}from"./keys.js";import{extractMetadata as ct,generateHeadHtml as Lt}from"./metadata.js";import"./hydrate.js";import{prefetchPageData as At,injectPrefetchedState as It,fetchSSRTranslations as Pt}from"./prefetch.js";let z=null;const qt=async()=>{if(z)return z;try{return z=(await import("@symbo.ls/funcql")).funcqlPlugin,z}catch{return null}};import"linkedom";import{reset as vt}from"@symbo.ls/css";const ot=(t,e)=>{if(!t||!e)return;if(t[e]!==void 0)return t[e];const o=e.split(".");let n=t;for(const r of o){if(n==null||typeof n!="object")return;n=n[r]}return n},Et=function(t,e){if(!t)return"";const o=this?.context,n=o?.polyglot,r=e||n?.defaultLang||"en";if(n?.translations){const c=n.translations[r];if(c){const i=ot(c,t);if(i!==void 0)return i}}const f=this?.state?.root||o?.state?.root;if(f?.translations){const c=f.translations[r];if(c){const i=ot(c,t);if(i!==void 0)return i}}const u=n?.defaultLang||"en";if(u!==r&&n?.translations){const c=n.translations[u];if(c){const i=ot(c,t);if(i!==void 0)return i}}return t},lt=function(){const t=this?.context;return this?.state?.root?.lang||t?.polyglot?.defaultLang||"en"},N=(t,e=new WeakMap)=>{if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(Array.isArray(t)){const n=[];e.set(t,n);for(const r of t)n.push(typeof r=="object"&&r!==null?N(r,e):r);return n}const o={};e.set(t,o);for(const n of Object.keys(t)){const r=t[n];o[n]=typeof r=="object"&&r!==null?N(r,e):r}return o},at=()=>{const t=new WeakSet;return(e,o)=>{if(typeof o!="function"){if(typeof o=="object"&&o!==null){if(t.has(o))return;t.add(o)}return o}}};let B=null;try{import.meta.url&&(B=et(import.meta.url))}catch{}const ft=()=>{if(!import.meta.url||!B)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:i=>i};const t=$t(new URL(".",import.meta.url).pathname),e=d(t,"../..");if(b(d(e,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:e};let n;try{const i=B.resolve("smbls/package.json");n=q(i)}catch{let i=t;for(;i!==q(i);){const s=d(i,"node_modules","smbls");if(b(d(s,"package.json"))){n=s;break}i=q(i)}}let r=B;if(n)try{r=et(d(n,"package.json"))}catch{}let f,u=process.cwd();for(;u!==q(u);){if(b(d(u,"package.json"))){f=u;break}u=q(u)}let c=r;if(f)try{c=et(d(f,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:t,projectRoot:f,_smblsRequire:r,_projectRequire:c}},G=(t,e)=>{const o=t.isMonorepo?[B]:[t._smblsRequire,t._projectRequire,B].filter(Boolean);for(const n of o)try{return n.resolve(e)}catch{}return null},pe=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages",e,...o);const n=G(t,`${e}/package.json`);return n?d(q(n),...o):null},de=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"plugins",e,...o);const n=G(t,`@symbo.ls/${e}/package.json`);return n?d(q(n),...o):null},H=(t,e,...o)=>{if(t.isMonorepo){for(const r of["packages","plugins"]){const f=d(t.monorepoRoot,r,e,...o);if(b(f))return f}return null}const n=G(t,`@symbo.ls/${e}/package.json`);return n?d(q(n),...o):null},Y=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages","domql","packages",e,...o);const n=G(t,`@symbo.ls/${e}/package.json`);return n?d(q(n),...o):null};let Z=null;const Dt=async()=>{if(Z)return Z;const t=ft();if(!B)try{const c=await import("./dist/createDomql.bundled.mjs");return Z=c,c}catch(c){throw new Error(`brender: pre-bundled createDomql not available in bundled runtime: ${c.message}`)}let e;if(t.isMonorepo)e=d(t.monorepoRoot,"packages","smbls","src","createDomql.js");else if(t.smblsRoot){const c=d(t.smblsRoot,"src","createDomql.js"),i=d(t.smblsRoot,"dist","esm","src","createDomql.js");e=b(c)?c:i}if(!e||!b(e))throw new Error(`brender: cannot find createDomql.js (isMonorepo=${t.isMonorepo}, entry=${e})`);const o=await import("esbuild"),n=tt(Ot(),`br_createDomql_${Tt(6).toString("hex")}.mjs`),r=Ct,f={name:"workspace-resolve",setup(c){c.onResolve({filter:/^smbls/},i=>{const s=i.path.replace(/^smbls\/?/,""),l=t.isMonorepo?d(t.monorepoRoot,"packages","smbls"):t.smblsRoot;if(!l)return;if(!s){const m=r(l);return m?{path:m}:void 0}const p=d(l,s);if(b(p))return{path:p};if(b(p+".js"))return{path:p+".js"};const a=d(p,"index.js");if(b(a))return{path:a}}),c.onResolve({filter:/^domql$/},i=>{if(t.isMonorepo){const s=d(t.monorepoRoot,"packages","domql","src","index.js");if(b(s))return{path:s};const l=d(t.monorepoRoot,"packages","domql","index.js");if(b(l))return{path:l}}else try{const s=_require.resolve("domql/package.json"),l=r(q(s));if(l)return{path:l}}catch{}}),c.onResolve({filter:/^@symbo\.ls\//},i=>{const s=i.path.replace("@symbo.ls/","");if(s==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(t.isMonorepo){for(const p of["packages","plugins"]){const a=d(t.monorepoRoot,p,s,"src","index.js");if(b(a))return{path:a};const m=d(t.monorepoRoot,p,s,"index.js");if(b(m))return{path:m}}const l=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(s==="default-config"&&b(l))return{path:l}}else{const l=H(t,s,"src","index.js");if(l&&b(l))return{path:l};const p=H(t,s,"index.js");if(p&&b(p))return{path:p};if(s==="default-config"){const a=H(t,"default-config","blank","index.js");if(a&&b(a))return{path:a}}}}),c.onResolve({filter:/^@domql\//},i=>{const s=i.path.replace("@symbo.ls/","");if(t.isMonorepo){const l=d(t.monorepoRoot,"packages","domql","packages",s,"src","index.js");if(b(l))return{path:l};const p=d(t.monorepoRoot,"packages","domql","packages",s,"index.js");if(b(p))return{path:p}}else{const l=Y(t,s,"src","index.js");if(l&&b(l))return{path:l};const p=Y(t,s,"index.js");if(p&&b(p))return{path:p}}}),c.onResolve({filter:/^css-in-props/},i=>{let s;if(t.isMonorepo)s=d(t.monorepoRoot,"packages","css-in-props");else{const a=G(t,"css-in-props/package.json");a&&(s=q(a))}if(!s)return;const l=i.path.replace(/^css-in-props\/?/,"");if(l){const a=d(s,l),m=d(a,"index.js");if(b(m))return{path:m};if(b(a+".js"))return{path:a+".js"};if(b(a))return{path:a}}const p=r(s);if(p)return{path:p}}),c.onResolve({filter:/^@emotion\//},i=>{let s;if(t.isMonorepo)s=d(t.monorepoRoot,"node_modules",i.path);else{const l=G(t,`${i.path}/package.json`);if(!l)return;s=q(l)}if(b(s)){const l=d(s,"package.json");if(b(l))try{const p=JSON.parse(K(l,"utf8")),a=p.module||p.main||"dist/emotion-css.esm.js";return{path:d(s,a)}}catch{}return{path:s}}}),c.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const s=d(i.resolveDir,i.path);if(b(s))return{path:s}}}),c.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let s=K(i.path,"utf8");return s=s.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),c.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let s=K(i.path,"utf8");return s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),c.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),c.onLoad({filter:/smbls\/src\/router\.js$/},async i=>{let s=K(i.path,"utf8");return s=s.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:s,loader:"js"}}),c.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let s=K(i.path,"utf8");return s=s.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:s,loader:"js"}})}};await o.build({entryPoints:[e],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[f],nodePaths:t.isMonorepo?[d(t.monorepoRoot,"node_modules")]:[...t.smblsRoot?[d(t.smblsRoot,"node_modules")]:[],...t.projectRoot?[d(t.projectRoot,"node_modules")]:[],...t.smblsRoot?[d(t.smblsRoot,"..","..","node_modules")]:[]].filter(c=>b(c)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const u=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{kt(n)}catch{}return Z=u,u},Mt={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:t=>t.href,target:t=>t.target,rel:t=>t.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:t=>{let e=t.src;return typeof e=="string"&&e.includes("{{")&&(e=t.call("replaceLiteralsWithObjectFields",e,t.state)),e},alt:t=>t.alt,loading:t=>t.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},ut=(t,e="")=>{if(!t||!t.__ref)return{};const o={},n=t.__ref.__brKey;if(n&&(o[e===""?"__root":e]=n),t.__ref.__children)for(const r of t.__ref.__children){const f=t[r];if(f&&f.__ref){const u=e===""?r:`${e}.${r}`;Object.assign(o,ut(f,u))}}return o},pt=async(t,e={})=>{const{route:o="/",pathname:n,state:r,context:f,prefetch:u=!1}=e,c=n||o,i=globalThis.location,s=globalThis.window;(!globalThis.location||globalThis.location.pathname!==c)&&(globalThis.location={pathname:c,href:c,search:"",hash:"",origin:""}),globalThis.window||(globalThis.window={location:globalThis.location});let l;if(u)try{const g=t.pages||{};l={...g};const P=await At(t,o);if(P.size){const V=JSON.parse(JSON.stringify(g[o],(v,F)=>{if(typeof F!="function")return F})),U=(v,F)=>{if(!(!v||!F))for(const E in v)typeof v[E]=="function"?F[E]=v[E]:typeof v[E]=="object"&&v[E]!==null&&!Array.isArray(v[E])&&typeof F[E]=="object"&&F[E]!==null&&U(v[E],F[E])};U(g[o],V),It(V,P),l[o]=V}}catch(g){console.error("[brender] Prefetch error:",g),l=t.pages}let p;if(u)try{p=await Pt(t)}catch(g){console.warn("[brender] SSR translation fetch failed:",g.message)}i!==void 0?globalThis.location=i:delete globalThis.location,s!==void 0?globalThis.window=s:delete globalThis.window;const{window:a,document:m}=nt(),x=m.body;a.location.pathname=c;const h=globalThis.document,y=globalThis.location;globalThis.document=m,globalThis.location=a.location;const{createDomqlElement:A}=await Dt(),L=N(t.app||{}),R={...t.config||{}};t.polyglot&&!R.polyglot&&(R.polyglot=t.polyglot),t.fetch&&!R.fetch&&(R.fetch=t.fetch),t.router&&!R.router&&(R.router=t.router);for(const g of["useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDefaultConfig","useDocumentTheme"])t[g]!=null&&R[g]==null&&(R[g]=t[g]);const $=R.polyglot?{...R.polyglot}:void 0;p&&$&&($.translations={...$.translations||{},...p});const C=N(t.state||{});(p||$)&&(C.root||(C.root={}),$&&(C.root.lang=C.root.lang||$.defaultLang||"en"),p&&(C.root.translations={...C.root.translations||{},...p})),vt();const T={state:C,...r?{state:{...C,...r}}:{},dependencies:N(t.dependencies||{}),components:N(t.components||{}),snippets:N(t.snippets||{}),pages:N(l||t.pages||{}),functions:{...t.functions||{},polyglot:Et,getActiveLang:lt,getLang:lt},methods:t.methods||{},designSystem:N(t.designSystem||{}),files:t.files||{},sharedLibraries:t.sharedLibraries||[],...R,...$?{polyglot:$}:{},document:m,window:a,parent:{node:x},initOptions:{},domqlOptions:{sourcemap:!1},...f||{}},D=await qt();D&&(T.plugins=T.plugins||[],T.plugins.some(g=>g.name==="funcql")||T.plugins.push(D)),st();const I=await A(L,T),M=u?2e3:50;await new Promise(g=>setTimeout(g,M)),rt(x);const _=it(I),k=ut(I),w=ct(t,o,I,I?.state),S=[],j=m.head||m.querySelector("head");if(j)for(const g of j.querySelectorAll("style")){if(g.sheet&&g.sheet.cssRules)for(const P of g.sheet.cssRules)P.cssText&&S.push(P.cssText);if(!S.length){const P=g.textContent||"";P&&S.push(P)}}let O=dt(x.innerHTML);if(p){const g=$?.defaultLang||"en",P=p[g]||Object.values(p)[0]||{};O=O.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(V,U)=>{const v=U.trim();return P[v]??V})}return h!==void 0?globalThis.document=h:delete globalThis.document,y!==void 0?globalThis.location=y:delete globalThis.location,{html:O,metadata:w,registry:_,brRegistry:k,element:I,emotionCSS:S,document:m,window:a,ssrTranslations:p,prefetchedPages:l}},me=async(t,e={})=>{const{context:o={}}=e,{window:n,document:r}=nt(),f=r.body,{create:u}=await import("@symbo.ls/element"),c=await import("@symbo.ls/utils"),i={...Mt,...o.components||{}},s={...c,...o.utils||{},...o.functions||{}};st();let l;try{l=u(t,{node:f},"root",{context:{document:r,window:n,...o,components:i,utils:s}})}catch{}rt(f);const p=l?it(l):{};return{html:dt(f.innerHTML),registry:p,element:l}},dt=t=>t.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(e,o,n,r)=>{if(n.includes("&lt;")){const f=n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+f+r}return e});let W=null;const Nt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],mt=t=>{if(!t||typeof t!="object")return null;if(t.config&&typeof t.config=="object")return t.config;const e={};let o=!1;for(const n of Nt)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n],o=!0);return o?e:t.settings||null},gt=(t,e,o)=>{const n=Object.entries(e||{}).map(([r,f])=>`${o} ${r}: ${f}`).join(`;
2
- `);return n?`${o}${t} {
3
- ${n};
4
- ${o}}`:""},Ft=t=>Object.entries(t||{}).map(([e,o])=>{if(!e.startsWith("@"))return gt(e,o,"");const n=Object.entries(o||{}).map(([r,f])=>gt(r,f," ")).filter(Boolean).join(`
5
- `);return n?`${e} {
6
- ${n}
1
+ import{resolve as d,join as At,dirname as T}from"path";import{existsSync as y,unlinkSync as Pt,readFileSync as V,realpathSync as qt}from"fs";import{resolvePackageEntry as It}from"./packageEntry.js";import{tmpdir as vt}from"os";import{randomBytes as Dt}from"crypto";import{createRequire as ot}from"module";import{createEnv as at}from"./env.js";import{resetKeys as ft,assignKeys as ut,mapKeysToElements as pt}from"./keys.js";import{extractMetadata as st,generateHeadHtml as Mt}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as Bt}from"./shell.js";import{prefetchPageData as Ft,injectPrefetchedState as Nt,fetchSSRTranslations as Wt}from"./prefetch.js";import{createEarlySeedScript as Ht}from"@symbo.ls/fetch";let X=null;const Gt=async()=>{if(X)return X;try{return X=(await import("@symbo.ls/funcql")).funcqlPlugin,X}catch{return null}};import"linkedom";import{reset as Jt}from"@symbo.ls/css";const rt=(t,e)=>{if(!t||!e)return;if(t[e]!==void 0)return t[e];const n=e.split(".");let o=t;for(const i of n){if(o==null||typeof o!="object")return;o=o[i]}return o},Kt=function(t,e){if(!t)return"";const n=this?.context,o=n?.polyglot,i=e||o?.defaultLang||"en";if(o?.translations){const a=o.translations[i];if(a){const r=rt(a,t);if(r!==void 0)return r}}const c=this?.state?.root||n?.state?.root;if(c?.translations){const a=c.translations[i];if(a){const r=rt(a,t);if(r!==void 0)return r}}const u=o?.defaultLang||"en";if(u!==i&&o?.translations){const a=o.translations[u];if(a){const r=rt(a,t);if(r!==void 0)return r}}return t},dt=function(){const t=this?.context;return this?.state?.root?.lang||t?.polyglot?.defaultLang||"en"},A=(t,e=new WeakMap)=>{if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(Array.isArray(t)){const o=[];e.set(t,o);for(const i of t)o.push(typeof i=="object"&&i!==null?A(i,e):i);return o}const n={};e.set(t,n);for(const o of Object.keys(t)){const i=t[o];n[o]=typeof i=="object"&&i!==null?A(i,e):i}return n};let F=null;try{import.meta.url&&(F=ot(import.meta.url))}catch{}const zt=()=>{if(!import.meta.url||!F)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:r=>r};const t=qt(new URL(".",import.meta.url).pathname),e=d(t,"../..");if(y(d(e,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:e};let o;try{const r=F.resolve("smbls/package.json");o=T(r)}catch{let r=t;for(;r!==T(r);){const s=d(r,"node_modules","smbls");if(y(d(s,"package.json"))){o=s;break}r=T(r)}}let i=F;if(o)try{i=ot(d(o,"package.json"))}catch{}let c,u=process.cwd();for(;u!==T(u);){if(y(d(u,"package.json"))){c=u;break}u=T(u)}let a=i;if(c)try{a=ot(d(c,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:o,brenderDir:t,projectRoot:c,_smblsRequire:i,_projectRequire:a}},K=(t,e)=>{const n=t.isMonorepo?[F]:[t._smblsRequire,t._projectRequire,F].filter(Boolean);for(const o of n)try{return o.resolve(e)}catch{}return null},qe=(t,e,...n)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages",e,...n);const o=K(t,`${e}/package.json`);return o?d(T(o),...n):null},Ie=(t,e,...n)=>{if(t.isMonorepo)return d(t.monorepoRoot,"plugins",e,...n);const o=K(t,`@symbo.ls/${e}/package.json`);return o?d(T(o),...n):null},it=(t,e,...n)=>{if(t.isMonorepo){for(const i of["packages","plugins"]){const c=d(t.monorepoRoot,i,e,...n);if(y(c))return c}return null}const o=K(t,`@symbo.ls/${e}/package.json`);return o?d(T(o),...n):null},mt=(t,e,...n)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages","domql","packages",e,...n);const o=K(t,`@symbo.ls/${e}/package.json`);return o?d(T(o),...n):null};let N=null;const gt="smbls/ssr",ht=async()=>{const t=await import("smbls/ssr");if(typeof t?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return t},Ut=async()=>{if(N)return N;const t=zt();if(!F)try{return N=await ht(),N}catch(a){throw new Error(`brender: ${gt} is not available in this bundled runtime (${a.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`)}let e;if(t.isMonorepo)e=d(t.monorepoRoot,"packages","smbls","src","createDomql.js");else{let a;try{return N=await ht(),N}catch(s){a=s}const r=t.smblsRoot&&d(t.smblsRoot,"src","createDomql.js");if(r&&y(r))e=r;else throw new Error(`brender: cannot load ${gt} (${a.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(t.smblsRoot?` (found smbls at ${t.smblsRoot}).`:" (no smbls package found)."))}const n=await import("esbuild"),o=At(vt(),`br_createDomql_${Dt(6).toString("hex")}.mjs`),i=It,c={name:"workspace-resolve",setup(a){a.onResolve({filter:/^smbls/},r=>{const s=r.path.replace(/^smbls\/?/,""),f=t.isMonorepo?d(t.monorepoRoot,"packages","smbls"):t.smblsRoot;if(!f)return;if(!s){const h=i(f);return h?{path:h}:void 0}const l=d(f,s);if(y(l))return{path:l};if(y(l+".js"))return{path:l+".js"};const p=d(l,"index.js");if(y(p))return{path:p}}),a.onResolve({filter:/^domql$/},r=>{if(t.isMonorepo){const s=d(t.monorepoRoot,"packages","domql","src","index.js");if(y(s))return{path:s};const f=d(t.monorepoRoot,"packages","domql","index.js");if(y(f))return{path:f}}else try{const s=_require.resolve("domql/package.json"),f=i(T(s));if(f)return{path:f}}catch{}}),a.onResolve({filter:/^@symbo\.ls\//},r=>{const s=r.path.replace("@symbo.ls/","");if(s==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(t.isMonorepo){for(const l of["packages","plugins"]){const p=d(t.monorepoRoot,l,s,"src","index.js");if(y(p))return{path:p};const h=d(t.monorepoRoot,l,s,"index.js");if(y(h))return{path:h}}const f=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(s==="default-config"&&y(f))return{path:f}}else{const f=it(t,s,"src","index.js");if(f&&y(f))return{path:f};const l=it(t,s,"index.js");if(l&&y(l))return{path:l};if(s==="default-config"){const p=it(t,"default-config","blank","index.js");if(p&&y(p))return{path:p}}}}),a.onResolve({filter:/^@domql\//},r=>{const s=r.path.replace("@symbo.ls/","");if(t.isMonorepo){const f=d(t.monorepoRoot,"packages","domql","packages",s,"src","index.js");if(y(f))return{path:f};const l=d(t.monorepoRoot,"packages","domql","packages",s,"index.js");if(y(l))return{path:l}}else{const f=mt(t,s,"src","index.js");if(f&&y(f))return{path:f};const l=mt(t,s,"index.js");if(l&&y(l))return{path:l}}}),a.onResolve({filter:/^css-in-props/},r=>{let s;if(t.isMonorepo)s=d(t.monorepoRoot,"packages","css-in-props");else{const p=K(t,"css-in-props/package.json");p&&(s=T(p))}if(!s)return;const f=r.path.replace(/^css-in-props\/?/,"");if(f){const p=d(s,f),h=d(p,"index.js");if(y(h))return{path:h};if(y(p+".js"))return{path:p+".js"};if(y(p))return{path:p}}const l=i(s);if(l)return{path:l}}),a.onResolve({filter:/^@emotion\//},r=>{let s;if(t.isMonorepo)s=d(t.monorepoRoot,"node_modules",r.path);else{const f=K(t,`${r.path}/package.json`);if(!f)return;s=T(f)}if(y(s)){const f=d(s,"package.json");if(y(f))try{const l=JSON.parse(V(f,"utf8")),p=l.module||l.main||"dist/emotion-css.esm.js";return{path:d(s,p)}}catch{}return{path:s}}}),a.onResolve({filter:/\.json$/},r=>{if(r.resolveDir){const s=d(r.resolveDir,r.path);if(y(s))return{path:s}}}),a.onLoad({filter:/smbls\/.*options\.js$/},async r=>{if(!r.path.includes("smbls/")||!r.path.endsWith("options.js"))return;let s=V(r.path,"utf8");return s=s.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),a.onLoad({filter:/smbls\/.*init\.js$/},async r=>{if(!r.path.includes("smbls/")||!r.path.endsWith("init.js"))return;let s=V(r.path,"utf8");return s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),a.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),a.onLoad({filter:/smbls\/src\/router\.js$/},async r=>{let s=V(r.path,"utf8");return s=s.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:s,loader:"js"}}),a.onLoad({filter:/fetchOnCreate\.js$/},async r=>{if(!r.path.includes("smbls/"))return;let s=V(r.path,"utf8");return s=s.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:s,loader:"js"}})}};await n.build({entryPoints:[e],bundle:!0,format:"esm",platform:"node",outfile:o,write:!0,logLevel:"warning",plugins:[c],nodePaths:t.isMonorepo?[d(t.monorepoRoot,"node_modules")]:[...t.smblsRoot?[d(t.smblsRoot,"node_modules")]:[],...t.projectRoot?[d(t.projectRoot,"node_modules")]:[],...t.smblsRoot?[d(t.smblsRoot,"..","..","node_modules")]:[]].filter(a=>y(a)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const u=await import(`file://${o}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",o);else try{Pt(o)}catch{}return N=u,u},Yt={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:t=>t.href,target:t=>t.target,rel:t=>t.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:t=>{let e=t.src;return typeof e=="string"&&e.includes("{{")&&(e=t.call("replaceLiteralsWithObjectFields",e,t.state)),e},alt:t=>t.alt,loading:t=>t.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},yt=(t,e="")=>{if(!t||!t.__ref)return{};const n={},o=t.__ref.__brKey;if(o&&(n[e===""?"__root":e]=o),t.__ref.__children)for(const i of t.__ref.__children){const c=t[i];if(c&&c.__ref){const u=e===""?i:`${e}.${i}`;Object.assign(n,yt(c,u))}}return n};let z=0;const bt=Symbol.for("brender.fetchTracked"),St=()=>z,Vt=256*1024,Xt=1024*1024,Zt=new Set(["accept-language","accept"]);let lt=0,q=null;const Qt=t=>{const[e,n]=t,o=e&&typeof e=="object"&&typeof e.url=="string",i=o?e.url:String(e),c=String(n&&n.method||o&&e.method||"GET").toUpperCase(),u={},a=r=>{if(r)if(typeof r.forEach=="function"&&!Array.isArray(r))r.forEach((s,f)=>{u[String(f).toLowerCase()]=String(s)});else if(Array.isArray(r))for(const[s,f]of r)u[String(s).toLowerCase()]=String(f);else for(const s in r)r[s]!=null&&(u[s.toLowerCase()]=String(r[s]))};return o&&a(e.headers),n&&a(n.headers),{url:i,method:c,headers:u}},te=(t,e,n,o)=>{if(!n||!n.ok||typeof n.clone!="function")return;const i=n.headers&&n.headers.get&&n.headers.get("content-type")||"";if(!/json|^text\//i.test(i))return;let c;try{c=n.clone()}catch{return}o(c.text().then(u=>{t.tainted||u.length>Vt||t.bytes+u.length>Xt||(t.bytes+=u.length,t.entries.push({url:e.url,lang:e.headers["accept-language"]||"",status:n.status,type:i,body:u}))},()=>{}))},ee=()=>{const t=globalThis.fetch;if(typeof t!="function"||t[bt])return;const e=function(...n){z++;let o=!1;const i=()=>{o||(o=!0,z--)},c=s=>{z++,s.then(()=>{z--},()=>{z--})},u=q&&!q.tainted?q:null;let a=null;if(u)try{a=Qt(n),(a.method!=="GET"||!/^https?:/i.test(a.url)||Object.keys(a.headers).some(s=>!Zt.has(s)))&&(a=null)}catch{a=null}let r;try{r=t.apply(this,n)}catch(s){throw i(),s}return r&&typeof r.then=="function"?r.then(s=>{a&&te(u,a,s,c),i()},i):i(),r};e[bt]=!0,globalThis.fetch=e},ct=({brRegistry:t,fetchSeed:e}={})=>!t||!Object.keys(t).length?"":`<script>window.__BR_REGISTRY__=${JSON.stringify(t).replace(/</g,"\\u003c")};window.__BRENDER_HYDRATE__=true<\/script>`+(e&&e.length?`
2
+ `+Ht(e):""),wt=async(t,e={})=>{const{route:n="/",pathname:o,state:i,context:c,prefetch:u=!1}=e,a=o||n,r=globalThis.location,s=globalThis.window;(!globalThis.location||globalThis.location.pathname!==a)&&(globalThis.location={pathname:a,href:a,search:"",hash:"",origin:""}),globalThis.window||(globalThis.window={location:globalThis.location});let f;if(u)try{const g=t.pages||{};f={...g};const b=await Ft(t,n);if(b.size){const P=JSON.parse(JSON.stringify(g[n],(C,D)=>{if(typeof D!="function")return D})),J=(C,D)=>{if(!(!C||!D))for(const O in C)typeof C[O]=="function"?D[O]=C[O]:typeof C[O]=="object"&&C[O]!==null&&!Array.isArray(C[O])&&typeof D[O]=="object"&&D[O]!==null&&J(C[O],D[O])};J(g[n],P),Nt(P,b),f[n]=P}}catch(g){console.error("[brender] Prefetch error:",g),f=t.pages}let l;if(u)try{l=await Wt(t)}catch(g){console.warn("[brender] SSR translation fetch failed:",g.message)}r!==void 0?globalThis.location=r:delete globalThis.location,s!==void 0?globalThis.window=s:delete globalThis.window;const{window:p,document:h}=at(),S=h.body;p.location.pathname=a;const w=globalThis.document,m=globalThis.location;globalThis.document=h,globalThis.location=p.location;const{createDomqlElement:R}=await Ut(),E=A(t.app||{}),x={...t.config||{}};t.polyglot&&!x.polyglot&&(x.polyglot=t.polyglot),t.fetch&&!x.fetch&&(x.fetch=t.fetch),t.router&&!x.router&&(x.router=t.router);for(const g of ne)t[g]!=null&&x[g]==null&&(x[g]=t[g]);const _=x.polyglot?{...x.polyglot}:void 0;l&&_&&(_.translations={..._.translations||{},...l});const j=A(t.state||{});(l||_)&&(j.root||(j.root={}),_&&(j.root.lang=j.root.lang||_.defaultLang||"en"),l&&(j.root.translations={...j.root.translations||{},...l})),Jt();const W={};for(const g in t){if(g==="app"||g==="config"||g==="pages"||g==="components"||g==="state"||g==="snippets"||g==="designSystem"||g==="dependencies")continue;const b=t[g];W[g]=b&&typeof b=="object"?A(b):b}const H={...W,state:j,...i?{state:{...j,...i}}:{},dependencies:A(t.dependencies||{}),components:A(t.components||{}),snippets:A(t.snippets||{}),pages:A(f||t.pages||{}),functions:{...t.functions||{},polyglot:Kt,getActiveLang:dt,getLang:dt},methods:t.methods||{},designSystem:A(t.designSystem||{}),files:t.files||{},sharedLibraries:t.sharedLibraries||[],...x,..._?{polyglot:_}:{},document:h,window:p,parent:{node:S},initOptions:{},domqlOptions:{sourcemap:!1},sync:!1,inspect:!1,notifications:!1,...c||{}},k=await Gt();k&&(H.plugins=H.plugins||[],H.plugins.some(g=>g.name==="funcql")||H.plugins.push(k)),ft(),ee(),lt++,lt===1?q={entries:[],bytes:0,tainted:!1}:q&&(q.tainted=!0);const L=q;let $;try{$=await R(E,H);const g=Date.now(),b=u?2e3:50,P=J=>new Promise(C=>setTimeout(C,J));for(await P(Math.min(50,b));u&&St()>0&&Date.now()-g<b;){for(;St()>0&&Date.now()-g<b;)await P(10);await P(Math.max(0,Math.min(50,b-(Date.now()-g))))}}finally{lt--,q===L&&(q=null)}const G=L&&!L.tainted?L.entries.slice():[];ut(S);const U=pt($),M=yt($),et=st(t,n,$,$?.state),I=[],v=[],B=h.head||h.querySelector("head");if(B)for(const g of B.querySelectorAll("style")){if(g.sheet&&g.sheet.cssRules)for(const b of g.sheet.cssRules)b.cssText&&(I.push(b.cssText),v.push(b));if(!I.length){const b=g.textContent||"";b&&(I.push(b),v.push({cssText:b}))}}const{globalCSS:Y,classRules:Ot}=ie(v);let nt=Rt(S.innerHTML);if(l){const g=_?.defaultLang||"en",b=l[g]||Object.values(l)[0]||{};nt=nt.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(P,J)=>{const C=J.trim();return b[C]??P})}return w!==void 0?globalThis.document=w:delete globalThis.document,m!==void 0?globalThis.location=m:delete globalThis.location,{html:nt,metadata:et,registry:U,brRegistry:M,element:$,emotionCSS:I,globalCSS:Y,classRules:Ot,fetchSeed:G,document:h,window:p,ssrTranslations:l,prefetchedPages:f}},ve=async(t,e={})=>{const{context:n={}}=e,{window:o,document:i}=at(),c=i.body,{create:u}=await import("@symbo.ls/element"),a=await import("@symbo.ls/utils"),r={...Yt,...n.components||{}},s={...a,...n.utils||{},...n.functions||{}};ft();let f;try{f=u(t,{node:c},"root",{context:{document:i,window:o,...n,components:r,utils:s}})}catch{}ut(c);const l=f?pt(f):{};return{html:Rt(c.innerHTML),registry:l,element:f}},Rt=t=>t.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(e,n,o,i)=>{if(o.includes("&lt;")){const c=o.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return n+c+i}return e}),ne=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],xt=(t,e,n)=>{const o=Object.entries(e||{}).map(([i,c])=>`${n} ${i}: ${c}`).join(`;
3
+ `);return o?`${n}${t} {
4
+ ${o};
5
+ ${n}}`:""},De=t=>Object.entries(t||{}).map(([e,n])=>{if(!e.startsWith("@"))return xt(e,n,"");const o=Object.entries(n||{}).map(([i,c])=>xt(i,c," ")).filter(Boolean).join(`
6
+ `);return o?`${e} {
7
+ ${o}
7
8
  }`:""}).filter(Boolean).join(`
8
9
 
9
- `),ht=async(t,e)=>{if(W)return W;try{const{existsSync:o,writeFileSync:n,unlinkSync:r}=await import("fs"),{tmpdir:f}=await import("os"),{randomBytes:u}=await import("crypto");try{f()}catch{return{}}const c=await import("esbuild"),i=JSON.stringify(t||{},at()),s=JSON.stringify(e||{},at()),l=tt(f(),`br_global_${u(6).toString("hex")}.mjs`),p=tt(f(),`br_global_${u(6).toString("hex")}_out.mjs`);n(l,`
10
- import { set, getActiveConfig, getFontFaceString } from '@symbo.ls/scratch'
11
- // Namespace access for the skin builder: a scratch without it (version
12
- // skew) gives an empty skin block instead of failing this whole bundle
13
- // and, with it, every global rule.
14
- import * as scratchNs from '@symbo.ls/scratch'
15
- import { DEFAULT_CONFIG } from '@symbo.ls/default-config'
16
-
17
- const ds = ${i}
18
- const cfg = ${s}
19
-
20
- // Merge with defaults (same as initEmotion)
21
- const merged = {}
22
- for (const k in DEFAULT_CONFIG) merged[k] = DEFAULT_CONFIG[k]
23
- for (const k in ds) {
24
- if (typeof ds[k] === 'object' && !Array.isArray(ds[k]) && typeof merged[k] === 'object' && !Array.isArray(merged[k])) {
25
- merged[k] = { ...merged[k], ...ds[k] }
26
- } else {
27
- merged[k] = ds[k]
28
- }
29
- }
30
-
31
- const conf = set({
32
- useReset: true,
33
- useVariable: true,
34
- useFontImport: true,
35
- useDocumentTheme: true,
36
- useDefaultConfig: true,
37
- globalTheme: 'auto',
38
- ...merged,
39
- ...cfg
40
- }, { newConfig: {} })
41
-
42
- const result = {
43
- CSS_VARS: conf.CSS_VARS || {},
44
- CSS_MEDIA_VARS: conf.CSS_MEDIA_VARS || {},
45
- // Skin rules \u2014 the same builder smbls init() injects on the client
46
- // (FW-SCRATCH-SKINS-DIMENSION-1).
47
- CSS_SKIN_RULES: typeof scratchNs.buildSkinVarStyles === 'function'
48
- ? scratchNs.buildSkinVarStyles(conf.cssSkinVars, conf.cssSkinFallback, ':root')
49
- : {},
50
- reset: conf.reset || {},
51
- animation: conf.animation || {}
52
- }
53
- // Export as globalThis so we can read it
54
- globalThis.__BR_GLOBAL_CSS__ = result
55
- export default result
56
- `);const a=ft(),m={name:"workspace-resolve",setup(_){_.onResolve({filter:/^@symbo\.ls\//},k=>{const w=k.path.replace("@symbo.ls/","");if(a.isMonorepo){for(const j of["packages","plugins"]){const O=d(a.monorepoRoot,j,w,"src","index.js");if(o(O))return{path:O};const g=d(a.monorepoRoot,j,w,"index.js");if(o(g))return{path:g}}const S=d(a.monorepoRoot,"packages","default-config","blank","index.js");if(w==="default-config"&&o(S))return{path:S}}else{const S=H(a,w,"src","index.js");if(S&&o(S))return{path:S};const j=H(a,w,"index.js");if(j&&o(j))return{path:j};if(w==="default-config"){const O=H(a,"default-config","blank","index.js");if(O&&o(O))return{path:O}}}}),_.onResolve({filter:/^@domql\//},k=>{const w=k.path.replace("@symbo.ls/","");if(a.isMonorepo){const S=d(a.monorepoRoot,"packages","domql","packages",w,"src","index.js");if(o(S))return{path:S}}else{const S=Y(a,w,"src","index.js");if(S&&o(S))return{path:S};const j=Y(a,w,"index.js");if(j&&o(j))return{path:j}}})}};await c.build({entryPoints:[l],bundle:!0,format:"esm",platform:"node",outfile:p,write:!0,logLevel:"silent",plugins:[m],nodePaths:a.isMonorepo?[d(a.monorepoRoot,"node_modules")]:[...a.smblsRoot?[d(a.smblsRoot,"node_modules")]:[],...a.projectRoot?[d(a.projectRoot,"node_modules")]:[],...a.smblsRoot?[d(a.smblsRoot,"..","..","node_modules")]:[]].filter(_=>o(_)),external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker"]});const h=(await import(`file://${p}`)).default||{};try{r(l)}catch{}try{r(p)}catch{}const y=h.CSS_VARS||{},A=h.CSS_MEDIA_VARS||{},L=h.RESET||{},R=h.ANIMATION||{},$=Object.entries(y).map(([_,k])=>` ${_}: ${k}`).join(`;
57
- `);let C=$?`:root {
58
- ${$};
59
- }`:"";const T=Object.entries(A).map(([_,k])=>{const w=Object.entries(k).map(([S,j])=>` ${S}: ${j}`).join(`;
60
- `);return w?_.startsWith("@media")?`${_} {
61
- :root:not([data-theme]) {
62
- ${w};
63
- }
64
- }`:`${_} {
65
- ${w};
66
- }`:""}).filter(Boolean).join(`
67
-
68
- `);T&&(C+=`
69
-
70
- `+T);const D=Ft(h.CSS_SKIN_RULES);D&&(C+=(C?`
71
-
72
- `:"")+D);const I=xt(L),M=[];for(const _ in R){const k=R[_];if(!k||typeof k!="object")continue;const w=Object.entries(k).map(([S,j])=>{if(typeof j!="object")return"";const O=Object.entries(j).map(([g,P])=>`${J(g)}: ${P}`).join("; ");return` ${S} { ${O}; }`}).join(`
73
- `);M.push(`@keyframes ${_} {
74
- ${w}
75
- }`)}return W={rootRule:C,resetRules:I,fontFaceCSS:"",keyframeRules:M.join(`
76
- `)},W}catch(o){return console.warn("generateGlobalCSS failed:",o.message,o.stack),W={rootRule:"",resetRules:"",fontFaceCSS:"",keyframeRules:""},W}};let X=new Set;const ge=()=>{W=null,X=new Set},he=()=>Array.from(X).join(`
77
- `),ye=(t,e)=>t.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,e?`<style data-emotion="smbls">
10
+ `),oe=/\.[A-Za-z_\\-]/,se=t=>{if(typeof t!="string"||!t)return!1;const e=t.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!oe.test(e)},re=/^\s*(:root|\[data-theme|\[data-skin)/,_t=t=>{const e=t&&t.cssText;if(typeof e!="string")return null;if(/^@(-webkit-)?keyframes\b/.test(e))return"keyframes";if(e.startsWith("@font-face"))return null;if(typeof t.selectorText=="string")return se(t.selectorText)?re.test(t.selectorText)?"root":"reset":null;const n=t.cssRules&&Array.from(t.cssRules);if(n&&n.length&&/^@(media|supports|container)\b/.test(e)){const o=new Set(n.map(_t));return o.has(null)||o.size!==1?o.has(null)?null:"reset":[...o][0]}return null},ie=t=>{const e={root:[],reset:[],keyframes:[]},n=[];for(const o of t||[]){const i=_t(o);i?e[i].push(o.cssText):o&&o.cssText&&n.push(o.cssText)}return{globalCSS:{rootRule:e.root.join(`
11
+ `),resetRules:e.reset.join(`
12
+ `),keyframeRules:e.keyframes.join(`
13
+ `),fontFaceCSS:""},classRules:n}};let Z=new Set;const Me=()=>{Z=new Set},Be=()=>Array.from(Z).join(`
14
+ `),Fe=(t,e)=>t.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,e?`<style data-emotion="smbls">
78
15
  ${e}
79
- </style>`:""),be=async(t,e={})=>{const{route:o="/",pathname:n}=e,r=await pt(t,{route:o,pathname:n,prefetch:!0});if(!r)return null;const f=t.designSystem||{},u=await ht(f,mt(t));let c=null,i=null;try{const s=r.element,l=s?.context?.polyglot||t.polyglot||t.config?.polyglot;if(i=s?.state?.root?.lang||l?.defaultLang||"en",r.prefetchedPages&&r.prefetchedPages[o]){const p=r.prefetchedPages[o],a=(m,x={})=>{if(!m||typeof m!="object")return x;if(m.state&&typeof m.state=="object")for(const[h,y]of Object.entries(m.state))y!=null&&typeof y!="function"&&(x[h]=y);for(const[h,y]of Object.entries(m))h==="state"||h==="props"||h==="attr"||h==="on"||h==="define"||h==="__ref"||h.startsWith("__")||y&&typeof y=="object"&&!Array.isArray(y)&&a(y,x);return x};c=a(p)}}catch{}return{html:r.html,css:r.emotionCSS?r.emotionCSS.join(`
80
- `):"",globalCSS:u,resetCss:u.resetRules||xt(f.reset),fontLinks:_t(f),metadata:r.metadata||ct(t,o),brKeyCount:r.registry?Object.keys(r.registry).length:0,brRegistry:r.brRegistry||{},ssrTranslations:r.ssrTranslations,prefetchedState:c,activeLang:i}},Se=async(t,e="/",o={})=>{const{lang:n,themeColor:r,isr:f,hydrate:u=!0,prefetch:c=!0}=o,i=n||t.state?.lang||t.app?.metadata?.lang||"en",s=await pt(t,{route:e,prefetch:c});if(!s)return null;const l={...s.metadata};r&&(l["theme-color"]=r);const p=Lt(l);if(s.emotionCSS&&s.emotionCSS.length)for(const T of s.emotionCSS)T&&X.add(T);const a=Array.from(X).join(`
81
- `),m=t.designSystem||{},x=await ht(m,mt(t)),h=_t(m),y=Object.keys(s.registry).length;let A="";if(f&&f.clientScript){const T=e==="/"?0:e.replace(/^\/|\/$/g,"").split("/").length,D=T>0?"../".repeat(T):"./";if(u){let I="";if(s.ssrTranslations){const k=t.polyglot||t.config?.polyglot,w=k?.storagePrefix||"",S=k?.storageLangKey||"",j=[];for(const O in s.ssrTranslations){const g=s.ssrTranslations[O];g&&typeof g=="object"&&j.push(`localStorage.setItem(${JSON.stringify(w+O)},${JSON.stringify(JSON.stringify(g))})`)}if(S){const O=k?.defaultLang||"en";j.push(`if(!localStorage.getItem(${JSON.stringify(S)}))localStorage.setItem(${JSON.stringify(S)},${JSON.stringify(O)})`)}j.length&&(I=`<script>try{${j.join(";")}}catch(e){}<\/script>
82
- `)}const M=s.brRegistry&&Object.keys(s.brRegistry).length?JSON.stringify(s.brRegistry):null,_=M?`<script>window.__BR_REGISTRY__=${M}<\/script>
83
- `:"";A=`${I}${_}<script>window.__BRENDER__=true<\/script>
84
- <script type="module" src="${D}${f.clientScript}"><\/script>`}else A=`<script type="module">
16
+ </style>`:""),Ne=async(t,e={})=>{const{route:n="/",pathname:o,prefetch:i=!0}=e,c=await wt(t,{route:n,pathname:o,prefetch:i});if(!c)return null;const u=t.designSystem||{},a=c.globalCSS;let r=null,s=null;try{const f=c.element,l=f?.context?.polyglot||t.polyglot||t.config?.polyglot;if(s=f?.state?.root?.lang||l?.defaultLang||"en",c.prefetchedPages&&c.prefetchedPages[n]){const p=c.prefetchedPages[n],h=(S,w={})=>{if(!S||typeof S!="object")return w;if(S.state&&typeof S.state=="object")for(const[m,R]of Object.entries(S.state))R!=null&&typeof R!="function"&&(w[m]=R);for(const[m,R]of Object.entries(S))m==="state"||m==="props"||m==="attr"||m==="on"||m==="define"||m==="__ref"||m.startsWith("__")||R&&typeof R=="object"&&!Array.isArray(R)&&h(R,w);return w};r=h(p)}}catch{}return{html:c.html,css:c.classRules.join(`
17
+ `),classRules:c.classRules.slice(),globalCSS:a,resetCss:a.resetRules,fontLinks:Lt(u),metadata:c.metadata||st(t,n),brKeyCount:c.registry?Object.keys(c.registry).length:0,brRegistry:c.brRegistry||{},fetchSeed:c.fetchSeed||[],ssrTranslations:c.ssrTranslations,prefetchedState:r,activeLang:s}},We=async(t,e="/",n={})=>{const{lang:o,themeColor:i,isr:c,hydrate:u=!0,prefetch:a=!0,shell:r,adoptDom:s=!1}=n,f=o||t.state?.lang||t.app?.metadata?.lang||"en",l=await wt(t,{route:e,prefetch:a});if(!l)return null;const p={...l.metadata};if(i&&(p["theme-color"]=i),typeof r=="string"&&!t.name){const k="\0brender-undeclared-title\0";if(st({...t,name:k},e,l.element,l.element?.state).title===k)for(const $ of["title","og:title","twitter:title"])p[$]===l.metadata.title&&delete p[$]}const h=Mt(p);for(const k of l.classRules)k&&Z.add(k);const S=Array.from(Z).join(`
18
+ `),w=t.designSystem||{},m=l.globalCSS,R=Lt(w),E=Object.keys(l.registry).length;let x="";if(c&&c.clientScript){const k=Number.isInteger(n.depth)?n.depth:e==="/"?0:e.replace(/^\/|\/$/g,"").split("/").length,L=k>0?"../".repeat(k):"./";if(u){let $="";if(l.ssrTranslations){const M=t.polyglot||t.config?.polyglot,et=M?.storagePrefix||"",I=M?.storageLangKey||"",v=[];for(const B in l.ssrTranslations){const Y=l.ssrTranslations[B];Y&&typeof Y=="object"&&v.push(`localStorage.setItem(${JSON.stringify(et+B)},${JSON.stringify(JSON.stringify(Y))})`)}if(I){const B=M?.defaultLang||"en";v.push(`if(!localStorage.getItem(${JSON.stringify(I)}))localStorage.setItem(${JSON.stringify(I)},${JSON.stringify(B)})`)}v.length&&($=`<script>try{${v.join(";")}}catch(e){}<\/script>
19
+ `)}const G=l.brRegistry&&Object.keys(l.brRegistry).length?JSON.stringify(l.brRegistry):null,U=s?ct(l)?ct(l)+`
20
+ `:"":G?`<script>window.__BR_REGISTRY__=${G}<\/script>
21
+ `:"";x=`${$}${U}<script>window.__BRENDER__=true<\/script>
22
+ <script type="module" src="${L}${c.clientScript}"><\/script>`}else x=`<script type="module">
85
23
  {
86
24
  const brEls = document.querySelectorAll('body > :not(script):not(style)')
87
25
  const observer = new MutationObserver((mutations) => {
@@ -98,30 +36,36 @@ ${e}
98
36
  observer.observe(document.body, { childList: true })
99
37
  }
100
38
  <\/script>
101
- <script type="module" src="${D}${f.clientScript}"><\/script>`}const L={...t.config||{}};t.polyglot&&!L.polyglot&&(L.polyglot=t.polyglot);const R=L.polyglot;let $=p;if(R){const T=R.defaultLang||"en",I={...R.translations||{},...s.ssrTranslations||{}}[T]||{};$=p.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(M,_)=>{const k=_.trim();return I[k]??M})}return{html:`<!DOCTYPE html>
102
- <html lang="${i}">
39
+ <script type="module" src="${L}${c.clientScript}"><\/script>`}const _={...t.config||{}};t.polyglot&&!_.polyglot&&(_.polyglot=t.polyglot);const j=_.polyglot;let W=h;if(j){const k=j.defaultLang||"en",$={...j.translations||{},...l.ssrTranslations||{}}[k]||{};W=h.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(G,U)=>{const M=U.trim();return $[M]??G})}if(typeof r=="string"){const k=[m.fontFaceCSS?`<style data-brender>${m.fontFaceCSS}</style>`:"",`<style data-brender>
40
+ ${m.rootRule||""}
41
+ ${m.resetRules||""}
42
+ ${m.keyframeRules||""}
43
+ </style>`,S?`<style data-emotion="smbls">
44
+ ${S}
45
+ </style>`:""];return{html:Bt(r,{headTags:W,headEnd:[R,...k].filter(Boolean).join(`
46
+ `),body:l.html,depth:Number.isInteger(n.depth)?n.depth:0,bootScripts:s?ct(l):""}),route:e,brKeyCount:E,shell:!0}}return{html:`<!DOCTYPE html>
47
+ <html lang="${f}">
103
48
  <head>
104
- ${$}
105
- ${h}
106
- ${x.fontFaceCSS?`<style>${x.fontFaceCSS}</style>`:""}
107
- <style>
108
- ${x.rootRule||""}
109
- ${x.resetRules||""}
110
- ${x.keyframeRules||""}
49
+ ${W}
50
+ ${R}
51
+ ${m.fontFaceCSS?`<style data-brender>${m.fontFaceCSS}</style>`:""}
52
+ <style data-brender>
53
+ ${m.rootRule||""}
54
+ ${m.resetRules||""}
55
+ ${m.keyframeRules||""}
111
56
  </style>
112
- ${a?`<style data-emotion="smbls">
113
- ${a}
57
+ ${S?`<style data-emotion="smbls">
58
+ ${S}
114
59
  </style>`:""}
115
60
  </head>
116
61
  <body>
117
- ${s.html}
118
- ${A}
62
+ ${l.html}
63
+ ${x}
119
64
  </body>
120
- </html>`,route:e,brKeyCount:y}},Bt={U:-6,V:-5,W:-4,X:-3,Y:-2,Z:-1,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15},yt=new Set(["padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingBlock","paddingInline","paddingBlockStart","paddingBlockEnd","paddingInlineStart","paddingInlineEnd","margin","marginTop","marginRight","marginBottom","marginLeft","marginBlock","marginInline","marginBlockStart","marginBlockEnd","marginInlineStart","marginInlineEnd","gap","rowGap","columnGap","top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","fontSize","lineHeight","letterSpacing","borderWidth","borderRadius","outlineWidth","outlineOffset","inset","insetBlock","insetInline","boxSize","round"]),bt=(t,e)=>{if(!t||typeof t!="string"||!e)return null;const o=e.base||16,n=e.ratio||1.618,r=e.unit||"px",f=e.subSequence!==!1;if(t.includes(" "))return t.split(" ").map(y=>y==="-"||y===""?y:bt(y,e)||y).join(" ");if(/^(none|auto|inherit|initial|unset|0)$/i.test(t)||/\d+(px|em|rem|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc|fr|s|ms)$/i.test(t)||/^(#|rgb|hsl|var\()/i.test(t))return null;const u=t.startsWith("-"),i=(u?t.slice(1):t).match(/^([A-Z])(\d)?$/i);if(!i)return null;const s=i[1].toUpperCase(),l=i[2]?parseInt(i[2]):0,p=Bt[s];if(p===void 0)return null;let a=o*Math.pow(n,p);if(l>0&&f){const h=o*Math.pow(n,p+1),A=(h-a)/n,L=h-A,R=a+A,$=(L+R)/2,C=~~h-~~a>16?[L,$,R]:[L,R];l<=C.length&&(a=C[l-1])}const m=Math.round(a*100)/100;return`${u?"-":""}${m}${r}`},Wt=new Set([...yt].map(t=>t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()))),Q=(t,e,o)=>{if(typeof e!="string")return e;if(Jt.has(t)){const n=o?.color||{};if(n[e])return n[e]}if(yt.has(t)||Wt.has(t)){const n=o?.spacing||{},r=bt(e,n);if(r)return r}return e},Jt=new Set(["color","background","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor","fill","stroke"]),St=new Set(["href","src","alt","title","id","name","type","value","placeholder","target","rel","loading","srcset","sizes","media","role","tabindex","for","action","method","enctype","autocomplete","autofocus","theme","__element","update","childrenAs","childExtends","childProps","children"]),J=t=>t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),jt=(t,e)=>{if(typeof e>"u"||e===null)return null;if(t==="flow"&&typeof e=="string"){let[o,n]=(e||"row").split(" ");return(e.startsWith("x")||e==="row")&&(o="row"),(e.startsWith("y")||e==="column")&&(o="column"),{display:"flex","flex-flow":(o||"")+" "+(n||"")}}if(t==="wrap")return{display:"flex","flex-wrap":e};if((t==="align"||t==="flexAlign")&&typeof e=="string"){const[o,n]=e.split(" "),r={display:"flex","align-items":o};return n&&(r["justify-content"]=n),r}if(t==="gridAlign"&&typeof e=="string"){const[o,n]=e.split(" "),r={display:"grid","align-items":o};return n&&(r["justify-content"]=n),r}if(t==="flexFlow"&&typeof e=="string"){let[o,n]=(e||"row").split(" ");return(e.startsWith("x")||e==="row")&&(o="row"),(e.startsWith("y")||e==="column")&&(o="column"),{display:"flex","flex-flow":(o||"")+" "+(n||"")}}if(t==="flexWrap")return{display:"flex","flex-wrap":e};if(t==="backgroundImage"&&typeof e=="string"&&!e.startsWith("url(")&&!e.startsWith("linear-gradient")&&!e.startsWith("radial-gradient")&&!e.startsWith("none"))return{"background-image":`url(${e})`};if(t==="round"||t==="borderRadius"&&e)return{"border-radius":typeof e=="number"?e+"px":e};if(t==="boxSize"&&typeof e=="string"){const[o,n]=e.split(" ");return{height:o,width:n||o}}if(t==="widthRange"&&typeof e=="string"){const[o,n]=e.split(" ");return{"min-width":o,"max-width":n||o}}if(t==="heightRange"&&typeof e=="string"){const[o,n]=e.split(" ");return{"min-height":o,"max-height":n||o}}return t==="column"?{"grid-column":e}:t==="columns"?{"grid-template-columns":e}:t==="templateColumns"?{"grid-template-columns":e}:t==="row"?{"grid-row":e}:t==="rows"?{"grid-template-rows":e}:t==="templateRows"?{"grid-template-rows":e}:t==="area"?{"grid-area":e}:t==="template"?{"grid-template":e}:t==="templateAreas"?{"grid-template-areas":e}:t==="autoColumns"?{"grid-auto-columns":e}:t==="autoRows"?{"grid-auto-rows":e}:t==="autoFlow"?{"grid-auto-flow":e}:t==="columnStart"?{"grid-column-start":e}:t==="rowStart"?{"grid-row-start":e}:null},Rt=(t,e)=>{const o={};for(const n in t){const r=t[n],f=jt(n,r);if(f){for(const u in f)o[u]=Q(u,f[u],e);continue}typeof r!="string"&&typeof r!="number"||(o[J(n)]=Q(n,r,e))}return o},Gt=(t,e,o)=>{const n={},r={},f={};for(const u in t){const c=t[u];if(u.charCodeAt(0)===64&&typeof c=="object"){const s=o?.[u.slice(1)];if(s){const l=Rt(c,e);Object.keys(l).length&&(r[s]=l)}continue}if(u.charCodeAt(0)===58&&typeof c=="object"){const s=Rt(c,e);Object.keys(s).length&&(f[u]=s);continue}if(typeof c!="string"&&typeof c!="number"||u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90||St.has(u))continue;const i=jt(u,c);if(i){for(const s in i)n[s]=Q(s,i[s],e);continue}n[J(u)]=Q(u,c,e)}return{base:n,mediaRules:r,pseudoRules:f}},Ht=(t,{base:e,mediaRules:o,pseudoRules:n})=>{const r=[],f=Object.entries(e).map(([u,c])=>`${u}: ${c}`).join("; ");f&&r.push(`${t} { ${f}; }`);for(const[u,c]of Object.entries(n)){const i=Object.entries(c).map(([s,l])=>`${s}: ${l}`).join("; ");i&&r.push(`${t}${u} { ${i}; }`)}for(const[u,c]of Object.entries(o)){const i=Object.entries(c).map(([l,p])=>`${l}: ${p}`).join("; "),s=u.startsWith("@")?u:`@media ${u}`;i&&r.push(`${s} { ${t} { ${i}; } }`)}return r.join(`
121
- `)},wt={Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Block:{display:"block"},Inline:{display:"inline"}},Vt=t=>{const e=t.__ref?.__extends;if(!e||!Array.isArray(e))return null;for(const o of e)if(wt[o])return wt[o];return null},Kt=t=>{let e;for(const o in t){if(typeof t[o]!="function"||St.has(o)||o.charCodeAt(0)>=65&&o.charCodeAt(0)<=90||o.startsWith("on")||o.startsWith("__"))continue;e||(e={});let n;try{n=t[o](t,t.state||{})}catch{try{const r={root:{},...t.state||{}};n=t[o](t,r)}catch{}}n!=null&&n!==!1&&(e[o]=n)}return e||t},je=(t,e)=>{const o=e?.media||{},n=e?.animation||{},r=[],f=new Set,u=new Set,c=s=>{if(!s||!s.__ref)return;const l=Kt(s);if(l&&s.node){const p=s.node.getAttribute?.("class");if(p&&!f.has(p)){f.add(p);const a=Gt(l,e,o),m=Vt(s);if(m)for(const[y,A]of Object.entries(m)){const L=J(y);a.base[L]||(a.base[L]=A)}(Object.keys(a.base).length||Object.keys(a.mediaRules).length||Object.keys(a.pseudoRules).length)&&r.push(Ht("."+p.split(" ")[0],a));const h=l.animation||l.animationName;if(typeof h=="string"){const y=h.split(" ")[0];n[y]&&u.add(y)}}}if(s.__ref?.__children)for(const p of s.__ref.__children)s[p]?.__ref&&c(s[p])};c(t);const i=[];for(const s of u){const l=n[s],p=Object.entries(l).map(([a,m])=>{const x=Object.entries(m).map(([h,y])=>`${J(h)}: ${y}`).join("; ");return` ${a} { ${x}; }`}).join(`
122
- `);i.push(`@keyframes ${s} {
123
- ${p}
124
- }`)}return[...i,...r].join(`
125
- `)},xt=t=>{if(!t)return"";const e=[];for(const[o,n]of Object.entries(t)){if(!n||typeof n!="object")continue;const r=[],f=[];for(const[u,c]of Object.entries(n)){if(typeof c=="object"&&c!==null){if(u.startsWith("@media")||u.startsWith("@")){const i=Object.entries(c).filter(([,s])=>typeof s!="object").map(([s,l])=>`${J(s)}: ${l}`).join("; ");i&&f.push(`${u} { ${o} { ${i}; } }`)}continue}r.push(`${J(u)}: ${c}`)}r.length&&e.push(`${o} { ${r.join("; ")}; }`),e.push(...f)}return e.join(`
126
- `)},_t=t=>{if(!t)return"";const e=t.font_family||t.fontFamily||{},o=new Set;for(const r of Object.values(e)){if(typeof r!="string")continue;const f=r.match(/'([^']+)'/);f&&o.add(f[1])}return o.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...o].map(r=>`family=${r.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
127
- `):""};export{he as getAccumulatedEmotionCSS,pt as render,me as renderElement,Se as renderPage,be as renderRoute,ye as replaceEmotionCSS,ge as resetGlobalCSSCache,Ft as skinRulesToCSS};
65
+ </html>`,route:e,brKeyCount:E}},le={U:-6,V:-5,W:-4,X:-3,Y:-2,Z:-1,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15},jt=new Set(["padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingBlock","paddingInline","paddingBlockStart","paddingBlockEnd","paddingInlineStart","paddingInlineEnd","margin","marginTop","marginRight","marginBottom","marginLeft","marginBlock","marginInline","marginBlockStart","marginBlockEnd","marginInlineStart","marginInlineEnd","gap","rowGap","columnGap","top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","fontSize","lineHeight","letterSpacing","borderWidth","borderRadius","outlineWidth","outlineOffset","inset","insetBlock","insetInline","boxSize","round"]),kt=(t,e)=>{if(!t||typeof t!="string"||!e)return null;const n=e.base||16,o=e.ratio||1.618,i=e.unit||"px",c=e.subSequence!==!1;if(t.includes(" "))return t.split(" ").map(m=>m==="-"||m===""?m:kt(m,e)||m).join(" ");if(/^(none|auto|inherit|initial|unset|0)$/i.test(t)||/\d+(px|em|rem|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc|fr|s|ms)$/i.test(t)||/^(#|rgb|hsl|var\()/i.test(t))return null;const u=t.startsWith("-"),r=(u?t.slice(1):t).match(/^([A-Z])(\d)?$/i);if(!r)return null;const s=r[1].toUpperCase(),f=r[2]?parseInt(r[2]):0,l=le[s];if(l===void 0)return null;let p=n*Math.pow(o,l);if(f>0&&c){const w=n*Math.pow(o,l+1),R=(w-p)/o,E=w-R,x=p+R,_=(E+x)/2,j=~~w-~~p>16?[E,_,x]:[E,x];f<=j.length&&(p=j[f-1])}const h=Math.round(p*100)/100;return`${u?"-":""}${h}${i}`},ce=new Set([...jt].map(t=>t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()))),Q=(t,e,n)=>{if(typeof e!="string")return e;if(ae.has(t)){const o=n?.color||{};if(o[e])return o[e]}if(jt.has(t)||ce.has(t)){const o=n?.spacing||{},i=kt(e,o);if(i)return i}return e},ae=new Set(["color","background","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor","fill","stroke"]),$t=new Set(["href","src","alt","title","id","name","type","value","placeholder","target","rel","loading","srcset","sizes","media","role","tabindex","for","action","method","enctype","autocomplete","autofocus","theme","__element","update","childrenAs","childExtends","childProps","children"]),tt=t=>t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),Ct=(t,e)=>{if(typeof e>"u"||e===null)return null;if(t==="flow"&&typeof e=="string"){let[n,o]=(e||"row").split(" ");return(e.startsWith("x")||e==="row")&&(n="row"),(e.startsWith("y")||e==="column")&&(n="column"),{display:"flex","flex-flow":(n||"")+" "+(o||"")}}if(t==="wrap")return{display:"flex","flex-wrap":e};if((t==="align"||t==="flexAlign")&&typeof e=="string"){const[n,o]=e.split(" "),i={display:"flex","align-items":n};return o&&(i["justify-content"]=o),i}if(t==="gridAlign"&&typeof e=="string"){const[n,o]=e.split(" "),i={display:"grid","align-items":n};return o&&(i["justify-content"]=o),i}if(t==="flexFlow"&&typeof e=="string"){let[n,o]=(e||"row").split(" ");return(e.startsWith("x")||e==="row")&&(n="row"),(e.startsWith("y")||e==="column")&&(n="column"),{display:"flex","flex-flow":(n||"")+" "+(o||"")}}if(t==="flexWrap")return{display:"flex","flex-wrap":e};if(t==="backgroundImage"&&typeof e=="string"&&!e.startsWith("url(")&&!e.startsWith("linear-gradient")&&!e.startsWith("radial-gradient")&&!e.startsWith("none"))return{"background-image":`url(${e})`};if(t==="round"||t==="borderRadius"&&e)return{"border-radius":typeof e=="number"?e+"px":e};if(t==="boxSize"&&typeof e=="string"){const[n,o]=e.split(" ");return{height:n,width:o||n}}if(t==="widthRange"&&typeof e=="string"){const[n,o]=e.split(" ");return{"min-width":n,"max-width":o||n}}if(t==="heightRange"&&typeof e=="string"){const[n,o]=e.split(" ");return{"min-height":n,"max-height":o||n}}return t==="column"?{"grid-column":e}:t==="columns"?{"grid-template-columns":e}:t==="templateColumns"?{"grid-template-columns":e}:t==="row"?{"grid-row":e}:t==="rows"?{"grid-template-rows":e}:t==="templateRows"?{"grid-template-rows":e}:t==="area"?{"grid-area":e}:t==="template"?{"grid-template":e}:t==="templateAreas"?{"grid-template-areas":e}:t==="autoColumns"?{"grid-auto-columns":e}:t==="autoRows"?{"grid-auto-rows":e}:t==="autoFlow"?{"grid-auto-flow":e}:t==="columnStart"?{"grid-column-start":e}:t==="rowStart"?{"grid-row-start":e}:null},Tt=(t,e)=>{const n={};for(const o in t){const i=t[o],c=Ct(o,i);if(c){for(const u in c)n[u]=Q(u,c[u],e);continue}typeof i!="string"&&typeof i!="number"||(n[tt(o)]=Q(o,i,e))}return n},fe=(t,e,n)=>{const o={},i={},c={};for(const u in t){const a=t[u];if(u.charCodeAt(0)===64&&typeof a=="object"){const s=n?.[u.slice(1)];if(s){const f=Tt(a,e);Object.keys(f).length&&(i[s]=f)}continue}if(u.charCodeAt(0)===58&&typeof a=="object"){const s=Tt(a,e);Object.keys(s).length&&(c[u]=s);continue}if(typeof a!="string"&&typeof a!="number"||u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90||$t.has(u))continue;const r=Ct(u,a);if(r){for(const s in r)o[s]=Q(s,r[s],e);continue}o[tt(u)]=Q(u,a,e)}return{base:o,mediaRules:i,pseudoRules:c}},ue=(t,{base:e,mediaRules:n,pseudoRules:o})=>{const i=[],c=Object.entries(e).map(([u,a])=>`${u}: ${a}`).join("; ");c&&i.push(`${t} { ${c}; }`);for(const[u,a]of Object.entries(o)){const r=Object.entries(a).map(([s,f])=>`${s}: ${f}`).join("; ");r&&i.push(`${t}${u} { ${r}; }`)}for(const[u,a]of Object.entries(n)){const r=Object.entries(a).map(([f,l])=>`${f}: ${l}`).join("; "),s=u.startsWith("@")?u:`@media ${u}`;r&&i.push(`${s} { ${t} { ${r}; } }`)}return i.join(`
66
+ `)},Et={Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Block:{display:"block"},Inline:{display:"inline"}},pe=t=>{const e=t.__ref?.__extends;if(!e||!Array.isArray(e))return null;for(const n of e)if(Et[n])return Et[n];return null},de=t=>{let e;for(const n in t){if(typeof t[n]!="function"||$t.has(n)||n.charCodeAt(0)>=65&&n.charCodeAt(0)<=90||n.startsWith("on")||n.startsWith("__"))continue;e||(e={});let o;try{o=t[n](t,t.state||{})}catch{try{const i={root:{},...t.state||{}};o=t[n](t,i)}catch{}}o!=null&&o!==!1&&(e[n]=o)}return e||t},He=(t,e)=>{const n=e?.media||{},o=e?.animation||{},i=[],c=new Set,u=new Set,a=s=>{if(!s||!s.__ref)return;const f=de(s);if(f&&s.node){const l=s.node.getAttribute?.("class");if(l&&!c.has(l)){c.add(l);const p=fe(f,e,n),h=pe(s);if(h)for(const[m,R]of Object.entries(h)){const E=tt(m);p.base[E]||(p.base[E]=R)}(Object.keys(p.base).length||Object.keys(p.mediaRules).length||Object.keys(p.pseudoRules).length)&&i.push(ue("."+l.split(" ")[0],p));const w=f.animation||f.animationName;if(typeof w=="string"){const m=w.split(" ")[0];o[m]&&u.add(m)}}}if(s.__ref?.__children)for(const l of s.__ref.__children)s[l]?.__ref&&a(s[l])};a(t);const r=[];for(const s of u){const f=o[s],l=Object.entries(f).map(([p,h])=>{const S=Object.entries(h).map(([w,m])=>`${tt(w)}: ${m}`).join("; ");return` ${p} { ${S}; }`}).join(`
67
+ `);r.push(`@keyframes ${s} {
68
+ ${l}
69
+ }`)}return[...r,...i].join(`
70
+ `)},Lt=t=>{if(!t)return"";const e=t.font_family||t.fontFamily||{},n=new Set;for(const i of Object.values(e)){if(typeof i!="string")continue;const c=i.match(/'([^']+)'/);c&&n.add(c[1])}return n.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...n].map(i=>`family=${i.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
71
+ `):""};export{gt as SMBLS_SSR_SPECIFIER,ct as adoptionScripts,Be as getAccumulatedEmotionCSS,wt as render,ve as renderElement,We as renderPage,Ne as renderRoute,Fe as replaceEmotionCSS,Me as resetGlobalCSSCache,De as skinRulesToCSS,ie as splitCapturedCSS};
@@ -0,0 +1,8 @@
1
+ const A=/<head(\s[^>]*)?>/i,C=/<body(\s[^>]*)?>/i,d=(e,t)=>{const s=new RegExp(`\\s${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);return s?s[2]??s[3]??s[4]??"":null},y=e=>{const t=e.slice(0,12).toLowerCase();if(t.startsWith("<title"))return"title";if(t.startsWith("<meta")){if(d(e,"charset")!==null)return"charset";for(const s of["name","property","http-equiv","itemprop"]){const r=d(e,s);if(r!==null)return`${s}:${r.toLowerCase()}`}return null}if(t.startsWith("<link")){const s=(d(e,"rel")||"").toLowerCase();return s==="canonical"?"link:canonical":s==="icon"||s==="shortcut icon"?`link:${s}:${d(e,"href")||""}`:s==="alternate"&&d(e,"hreflang")!==null?`link:alternate:${(d(e,"hreflang")||"").toLowerCase()}`:null}return null},k=/<title[^>]*>[\s\S]*?<\/title\s*>|<meta\b[^>]*>|<link\b[^>]*>/gi,L=/<(script|style|noscript|template|textarea)\b[\s\S]*?<\/\1\s*>/gi,E=e=>[...e.matchAll(L)].map(t=>[t.index,t.index+t[0].length,t[0]]),R=(e,t,s=r=>r)=>{let r="",i=0;for(const[c,n,l]of E(e))r+=t(e.slice(i,c))+s(l),i=n;return r+t(e.slice(i))},f=(e,t,s=0)=>{const r=E(e),i=new RegExp(t.source,t.flags.includes("g")?t.flags:t.flags+"g");i.lastIndex=s;let c;for(;c=i.exec(e);){const n=c.index,l=r.find(([u,h])=>n>u&&n<h);if(!l)return c;i.lastIndex=l[1]}return null},B=e=>!!e&&!/^(?:[a-z][a-z0-9+.-]*:|\/|#|\?)/i.test(e),_=(e,t)=>e.replace(/(\s(?:src|href)\s*=\s*)(?:(["'])([^"']*)\2|([^\s"'>]+))/gi,(s,r,i,c,n)=>{const l=i?c:n;if(!B(l))return s;const u=i||"";return`${r}${u}${t}${l.replace(/^\.\//,"")}${u}`}),D=(e,t)=>{if(!t)return e;const s="../".repeat(t);return R(e,r=>r.replace(/<link\b[^>]*>/gi,i=>_(i,s)),r=>/^<script\b/i.test(r)?r.replace(/^<script\b[^>]*>/i,i=>_(i,s)):r)},I=(e,{headTags:t="",headEnd:s="",body:r="",depth:i=0,bootScripts:c=""}={})=>{if(typeof e!="string"||!e.trim())throw new Error("brender: the shell document is empty");let n=D(e,i);const l=new Set;for(const o of t.matchAll(k)){const a=y(o[0]);a&&l.add(a)}const u=o=>R(o,a=>a.replace(k,O=>l.has(y(O))?"":O)),h=t?`
2
+ ${t}`:"",g=s?`
3
+ ${s}
4
+ `:"",p=f(n,A),w=p&&f(n,/<\/head\s*>/i,p.index);if(p&&w){const o=p.index+p[0].length,a=w.index;n=n.slice(0,o)+h+u(n.slice(o,a))+g+n.slice(a)}else{n=u(n);const o=f(n,/<html(\s[^>]*)?>/i)||f(n,/<!doctype[^>]*>/i),a=o?o.index+o[0].length:0;n=n.slice(0,a)+h+g+n.slice(a)}const $=`
5
+ <script>window.__BRENDER__=true<\/script>
6
+ ${c?c+`
7
+ `:""}${r}
8
+ `,x=f(n,C);if(x){const o=x.index+x[0].length;return n.slice(0,o)+$+n.slice(o)}const m=f(n,/<\/(?:body|html)\s*>/i),b=m?m.index:n.length;return n.slice(0,b)+$+n.slice(b)};export{I as composeIntoShell,y as headTagKey};
package/env.js CHANGED
@@ -1,5 +1,38 @@
1
1
  import { parseHTML } from 'linkedom'
2
2
 
3
+ // The virtual windows createEnv() made — see the `globalThis.Window` note below.
4
+ const ssrWindows = new WeakSet()
5
+ class SSRWindow {
6
+ static [Symbol.hasInstance] (obj) { return ssrWindows.has(obj) }
7
+ }
8
+
9
+ // Give a getter-only HTMLSelectElement#value its setter (see createEnv). The
10
+ // prototype is linkedom's, shared by every document it parses: patched once.
11
+ const patchSelectValue = (document) => {
12
+ let proto = Object.getPrototypeOf(document.createElement('select'))
13
+ let desc
14
+ while (proto && !(desc = Object.getOwnPropertyDescriptor(proto, 'value'))) proto = Object.getPrototypeOf(proto)
15
+ if (!proto || !desc || !desc.get || desc.set) return
16
+ Object.defineProperty(proto, 'value', {
17
+ configurable: true,
18
+ enumerable: desc.enumerable,
19
+ get: desc.get,
20
+ set (value) {
21
+ const wanted = value == null ? '' : String(value)
22
+ let matched = false
23
+ for (const option of this.querySelectorAll('option')) {
24
+ const optionValue = option.hasAttribute('value') ? option.getAttribute('value') : option.textContent
25
+ if (!matched && optionValue === wanted) {
26
+ option.setAttribute('selected', '')
27
+ matched = true
28
+ } else {
29
+ option.removeAttribute('selected')
30
+ }
31
+ }
32
+ }
33
+ })
34
+ }
35
+
3
36
  /**
4
37
  * Creates a virtual DOM environment for server-side rendering.
5
38
  * Returns window and document that DOMQL can use as context.
@@ -26,7 +59,9 @@ export const createEnv = (html = '<!DOCTYPE html><html><head></head><body></body
26
59
  }
27
60
  }
28
61
  if (!window.location) {
29
- window.location = { pathname: '/', search: '', hash: '', origin: 'http://localhost' }
62
+ // A complete Location shape (host/hostname/protocol/href too): framework
63
+ // modules read these at module load, before any route is set.
64
+ window.location = { pathname: '/', search: '', hash: '', origin: 'http://localhost', protocol: 'http:', host: 'localhost', hostname: 'localhost', port: '', href: 'http://localhost/' }
30
65
  }
31
66
  if (!window.URL) {
32
67
  window.URL = URL
@@ -52,6 +87,14 @@ export const createEnv = (html = '<!DOCTYPE html><html><head></head><body></body
52
87
  if (!globalThis.localStorage) globalThis.localStorage = window.localStorage
53
88
  if (!globalThis.sessionStorage) globalThis.sessionStorage = window.sessionStorage
54
89
 
90
+ // linkedom's HTMLSelectElement has a `value` getter and NO setter: a
91
+ // `value` prop on a <select> threw "Cannot set property value … which has
92
+ // only a getter" and dropped the parent's children from the markup
93
+ // (docs.symbols.app lost DocsNavbar and DocSidebar through its language
94
+ // select — FW-BRENDER-HYDRATION-AND-CF-DEPLOY-PROVIDER-1). The browser's
95
+ // setter: the option with that value becomes the selected one.
96
+ patchSelectValue(document)
97
+
55
98
  // Stub MutationObserver for SSR (not provided by linkedom)
56
99
  if (!window.MutationObserver) {
57
100
  window.MutationObserver = class MutationObserver {
@@ -70,7 +113,24 @@ export const createEnv = (html = '<!DOCTYPE html><html><head></head><body></body
70
113
  globalThis.Element = window.Element || globalThis.Element
71
114
  globalThis.HTMLElement = window.HTMLElement || globalThis.HTMLElement
72
115
  globalThis.MutationObserver = window.MutationObserver
73
- globalThis.Window = window.constructor
116
+ // NEVER `window.constructor`: linkedom's window is a Proxy whose
117
+ // constructor is `Object`, and it reads unknown properties through to
118
+ // globalThis — so `window.Window` became `Object`, @symbo.ls/utils
119
+ // `isDOMNode(obj)` (`obj instanceof window.Window`) answered true for EVERY
120
+ // object, and `deepClone` (which keeps DOM nodes by reference) stopped
121
+ // cloning anything nested. Every later render in the same process then
122
+ // built on the first render's in-place-processed design system: 18–42
123
+ // self-referential theme variables per page on the platform worker
124
+ // (FW-BRENDER-HYDRATION-AND-CF-DEPLOY-PROVIDER-1). A real Window class (a
125
+ // jsdom host) is kept; otherwise a class whose only instances are the
126
+ // virtual windows this module created, so the window itself stays a host
127
+ // object (kept by reference, as before) and nothing else does.
128
+ ssrWindows.add(window)
129
+ if (window.constructor && window.constructor !== Object) {
130
+ globalThis.Window = window.constructor
131
+ } else if (typeof globalThis.Window !== 'function' || globalThis.Window === Object) {
132
+ globalThis.Window = SSRWindow
133
+ }
74
134
 
75
135
  return { window, document }
76
136
  }