@symbo.ls/brender 3.14.680 → 3.14.681
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 +13 -0
- package/dist/esm/prefetch.js +1 -1
- package/dist/esm/render.js +37 -37
- package/package.json +4 -4
- package/prefetch.js +7 -4
- package/render.js +21 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @symbo.ls/brender
|
|
2
2
|
|
|
3
|
+
## 3.14.681
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 849f8c1: frank writes an app's lang map once. An app whose polyglot reads its design system's lang map (`polyglot: { translations: lang }`, `lang` imported from `designSystem/lang.js` — the workspace apps' pattern) shipped the map twice: frank keeps the shared reference, and JSON writes a shared object at each place it occurs (a commerce app's payload: +102,603 bytes, +17.6 %). `frank.toJSON` now keeps the map in `designSystem.lang` (where the workspace shell reads a module's copy) and writes the polyglot config with `translationsFrom: 'designSystem.lang'` in the place of `translations` — only when the translations ARE that map (the same object, or a copy with the same content). Every reader puts the map back before it reads the config: `@symbo.ls/utils` adds `polyglotTranslations(project, polyglot)` (a read), `resolvePolyglotTranslations(project)` (in place — `smbls` `prepareContext` resolves the runtime's context before the shared libraries merge in) and `withPolyglotTranslations(project)` (a view — `@symbo.ls/brender` `render`/`renderPage`, `@symbo.ls/mermaid` `renderProjectHtml`'s start-up script and language, each shared library merge; the payload a server also serves is never written, so it keeps the map once); utils `getPageMetadata` resolves head labels from the pointer; `@symbo.ls/sync` resolves a livesync snapshot before it applies it (`resolveSnapshotTranslations`), so an edited copy reaches the page with the snapshot. A config with `translations` as well gets the named map with its own labels over it, per language. `@symbo.ls/polyglot`: the README documents `translationsFrom`. A runtime older than this release reads such a payload as a polyglot without static strings (the keys show): release the runtime packages and the mermaid-server pin before apps push with this frank.
|
|
8
|
+
- 71f56ce: `@symbo.ls/fetch` ships a built-in `symbols` adapter (`adapters/symbols.js`, also `@symbo.ls/fetch/symbols`): a published site reads and writes through the platform SDK, signed out, with `fetch: { adapter: 'symbols', load: () => import('@symbo.ls/sdk') }` in its config. The adapter loads the SDK on the first query only (frank publishes the literal import() as the lazy host-package marker, so the page declares the SDK file instead of inlining it), builds ONE SDK per page (memory tokens, the SDK's own telemetry off, the API base from `window.__SYMBOLS_ENV__`), and maps every op the way the hosts' 'sdk' adapter does (`select → list`, `insert → create`, …; every answer `{ data, error }`). It has no session surface. It is built in under its own name: a built-in 'sdk' would answer a host's first elements before the host's own late `registerAdapter('sdk')` (measured; `sdkAdapterShellRace.test.js`), so 'sdk' stays the hosts'. `resolveDb(config, env)` hands `env` (`{ serverRender }`, set from a context's `isolateFetchCache`) to `setup(options, env)`; the `symbols` adapter answers `null` in a server render, so the query is skipped there and the server never loads the SDK or calls the API. `@symbo.ls/brender` `createSSRAdapter` passes `{ serverRender: true }`. `smbls`: the full esm build keeps the new adapter import static (no `__esm` initializer), the core build gates it as kit `symbols` (`build.treeShakeFeatures`), and the bundles carry the new adapter.
|
|
9
|
+
- Updated dependencies [ed88d4e]
|
|
10
|
+
- Updated dependencies [849f8c1]
|
|
11
|
+
- Updated dependencies [71f56ce]
|
|
12
|
+
- @symbo.ls/fetch@3.14.679
|
|
13
|
+
- smbls@3.14.872
|
|
14
|
+
- @symbo.ls/utils@3.14.860
|
|
15
|
+
|
|
3
16
|
## 3.14.680
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/esm/prefetch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const l=t=>typeof t=="function",A=t=>Array.isArray(t),y=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),_=(t,n)=>{if(t){if(l(t))try{return t({state:n||{},call:()=>{},__ref:{}},n||{})}catch{return}return t}},j=t=>A(t)?t.length===0||t.includes("create")||!t.some(n=>typeof n=="string"&&n):!t||t==="create",k=(t,n)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const r=l(t)?null:{...t};return!r||(r.method||(r.method="select"),l(r.params)&&(r.params=_(r.params,n)),r.method==="insert"||r.method==="update"||r.method==="upsert"||r.method==="delete")||!j(r.on)?null:r},S=(t,n="")=>{if(!t||typeof t!="object")return[];if(l(t))return[];const r=[],s=t.state||{};if(t.fetch){const e=A(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=k(c,s);o&&r.push({config:o,stateKey:o.as,path:n,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])&&r.push(...S(t[e],n?`${n}.${e}`:e));return r},M=["rest","local"],w=new WeakMap,b=async t=>{if(!t)return null;if(y(t)&&(l(t.select)||l(t.rpc)))return t;const n=typeof t=="string"?{adapter:t}:t;if(!y(n)||typeof n.adapter!="string")return null;if(w.has(n))return w.get(n);const r=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(l(s.hasAdapter)?s.hasAdapter(n.adapter):M.includes(n.adapter)))return null;try{return await s.resolveDb(n)}catch(c){return console.warn(`[brender] SSR adapter "${n.adapter}" unavailable: ${c.message}`),null}})();return w.set(n,r),r},P=async(t,n)=>{try{const{method:r,from:s,params:e,transform:c,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g}=n;let i;if(r==="rpc"){if(!l(t.rpc))return null;i=await t.rpc({from:s,params:e,headers:h,baseUrl:g})}else{if(!l(t.select))return null;i=await t.select({from:s,select:n.select,params:e,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g})}let a=i?.data??null;if(i?.error)return null;if(a&&c&&l(c))try{a=c(a)}catch{}return a}catch{return null}},x=async(t,n="/",r={})=>{const e=(t.pages||{})[n];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 f=await b(o);if(!f)return new Map;const u=S(e);if(!u.length)return new Map;const p=new Map,h=await Promise.allSettled(u.map(async({config:g,stateKey:i,path:a})=>{const d=await P(f,g);if(d!==null){const m=p.get(a)||{};i?m[i]=d:y(d)&&Object.assign(m,d),p.set(a,m)}}));return p},D=async t=>{const n=t.config||{},r=n.polyglot||t.polyglot;if(!r?.fetch||typeof r.fetch=="function")return null;const s=n.fetch||t.fetch||n.db||t.db;if(!s)return null;const e=await b(s);if(!e)return null;const c=r.fetch,o=c.rpc||c.from||"get_translations_if_changed",f=await import("@symbo.ls/utils"),u=f.polyglotLanguages(r,!1),p=u.length?u:[f.polyglotFallbackLang(void 0,r)],h={},g=await Promise.allSettled(p.map(async i=>{try{if(!l(e.rpc))return;const a=await e.rpc({from:o,params:{p_lang:i,p_cached_version:0}});if(a.error||!a.data)return;const d=a.data;d.translations&&(h[i]=d.translations)}catch(a){console.warn("[brender] SSR translation fetch failed:",a.message)}}));return Object.keys(h).length?h:null},
|
|
1
|
+
const l=t=>typeof t=="function",A=t=>Array.isArray(t),y=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),_=(t,n)=>{if(t){if(l(t))try{return t({state:n||{},call:()=>{},__ref:{}},n||{})}catch{return}return t}},j=t=>A(t)?t.length===0||t.includes("create")||!t.some(n=>typeof n=="string"&&n):!t||t==="create",k=(t,n)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const r=l(t)?null:{...t};return!r||(r.method||(r.method="select"),l(r.params)&&(r.params=_(r.params,n)),r.method==="insert"||r.method==="update"||r.method==="upsert"||r.method==="delete")||!j(r.on)?null:r},S=(t,n="")=>{if(!t||typeof t!="object")return[];if(l(t))return[];const r=[],s=t.state||{};if(t.fetch){const e=A(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=k(c,s);o&&r.push({config:o,stateKey:o.as,path:n,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])&&r.push(...S(t[e],n?`${n}.${e}`:e));return r},M=["rest","local"],w=new WeakMap,b=async t=>{if(!t)return null;if(y(t)&&(l(t.select)||l(t.rpc)))return t;const n=typeof t=="string"?{adapter:t}:t;if(!y(n)||typeof n.adapter!="string")return null;if(w.has(n))return w.get(n);const r=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(l(s.hasAdapter)?s.hasAdapter(n.adapter):M.includes(n.adapter)))return null;try{return await s.resolveDb(n,{serverRender:!0})}catch(c){return console.warn(`[brender] SSR adapter "${n.adapter}" unavailable: ${c.message}`),null}})();return w.set(n,r),r},P=async(t,n)=>{try{const{method:r,from:s,params:e,transform:c,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g}=n;let i;if(r==="rpc"){if(!l(t.rpc))return null;i=await t.rpc({from:s,params:e,headers:h,baseUrl:g})}else{if(!l(t.select))return null;i=await t.select({from:s,select:n.select,params:e,limit:o,offset:f,order:u,single:p,headers:h,baseUrl:g})}let a=i?.data??null;if(i?.error)return null;if(a&&c&&l(c))try{a=c(a)}catch{}return a}catch{return null}},x=async(t,n="/",r={})=>{const e=(t.pages||{})[n];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 f=await b(o);if(!f)return new Map;const u=S(e);if(!u.length)return new Map;const p=new Map,h=await Promise.allSettled(u.map(async({config:g,stateKey:i,path:a})=>{const d=await P(f,g);if(d!==null){const m=p.get(a)||{};i?m[i]=d:y(d)&&Object.assign(m,d),p.set(a,m)}}));return p},D=async t=>{const n=t.config||{},r=n.polyglot||t.polyglot;if(!r?.fetch||typeof r.fetch=="function")return null;const s=n.fetch||t.fetch||n.db||t.db;if(!s)return null;const e=await b(s);if(!e)return null;const c=r.fetch,o=c.rpc||c.from||"get_translations_if_changed",f=await import("@symbo.ls/utils"),u=f.polyglotLanguages(r,!1),p=u.length?u:[f.polyglotFallbackLang(void 0,r)],h={},g=await Promise.allSettled(p.map(async i=>{try{if(!l(e.rpc))return;const a=await e.rpc({from:o,params:{p_lang:i,p_cached_version:0}});if(a.error||!a.data)return;const d=a.data;d.translations&&(h[i]=d.translations)}catch(a){console.warn("[brender] SSR translation fetch failed:",a.message)}}));return Object.keys(h).length?h:null},R=(t,n)=>{if(!(!n||!n.size))for(const[r,s]of n){let e=t;if(r){const c=r.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))}};export{b as createSSRAdapter,D as fetchSSRTranslations,R as injectPrefetchedState,x as prefetchPageData};
|
package/dist/esm/render.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import{resolve as d,join as nt,dirname as j}from"path";import{existsSync as S,unlinkSync as st,readFileSync as Y,realpathSync as rt}from"fs";import{resolvePackageEntry as ct}from"./packageEntry.js";import{tmpdir as it}from"os";import{randomBytes as lt}from"crypto";import{createRequire as he}from"module";import{pathToFileURL as at}from"url";import{createEnv as Te}from"./env.js";import{resetKeys as ve,assignKeys as Le,mapKeysToElements as Ae}from"./keys.js";import{extractMetadata as ye,generateHeadHtml as ft}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as pt}from"./shell.js";import{trimSpriteToPage as ut,classRulesForPage as mt,markupClasses as dt,trimVariablesToPage as gt}from"./pageWeight.js";import{facesSheetTag as ht}from"./faces.js";import{fetchSSRTranslations as yt}from"./prefetch.js";import{createEarlySeedScript as bt}from"@symbo.ls/fetch";import{headerEntries as St}from"@symbo.ls/fetch/rest";import{brenderStampMeta as Rt,brenderLazyMeta as $e,escapeRegExp as wt,jsonForScript as kt,libraryPackageSpecs as xt,polyglotFallbackLang as be,polyglotLangStorageKey as _t,polyglotAddressLang as Et,polyglotStartupScript as jt}from"@symbo.ls/utils";import{brenderRegistryBlock as Tt,brenderRegistryTreeBlock as vt}from"@symbo.ls/utils/server";import*as Lt from"@symbo.ls/utils/server";let ie=null;const At=async()=>{if(ie)return ie;try{return ie=(await import("@symbo.ls/funcql")).funcqlPlugin,ie}catch{return null}};import"linkedom";import{createEarlySeedBlock as $t,fetchRunsOf as Dt}from"@symbo.ls/fetch";import{reset as Ct}from"@symbo.ls/css";const le=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let n=e;for(const s of o){if(n==null||typeof n!="object")return;n=n[s]}return n},ae=(e,t)=>be(e?.lang,t),Ot=e=>{const t=Lt.revivePolyglotDefaultLang;if(typeof t!="function"||!e||typeof e!="object")return e;const o=e.polyglot?t(e.polyglot):e.polyglot,n=e.config&&e.config.polyglot,s=n&&t(n);if(o===e.polyglot&&s===n)return e;const r={...e};return o!==e.polyglot&&(r.polyglot=o),s!==n&&(r.config={...e.config,polyglot:s}),r},De=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const l=le(r,e);if(l!==void 0)return l}}if(n?.translations){const r=n.translations[t];if(r){const l=le(r,e);if(l!==void 0)return l}}const s=be(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const l=le(r,e);if(l!==void 0)return l}}},Mt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=De(e,t||ae(s,n),n,s);if(r!==void 0)return r;const l=ke(we);return n&&l&&l.labelKeys.add(e),e},Ce=function(){return ae(this?.state?.root,this?.context?.polyglot)},L=(e,t=new WeakMap)=>{if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(const s of e)n.push(typeof s=="object"&&s!==null?L(s,t):s);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const s=e[n];o[n]=typeof s=="object"&&s!==null?L(s,t):s}return o};let q=null;try{import.meta.url&&(q=he(import.meta.url))}catch{}const qt=()=>{if(!import.meta.url||!q)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:p=>p};const e=rt(new URL(".",import.meta.url).pathname),t=d(e,"../..");if(S(d(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const p=q.resolve("smbls/package.json");n=j(p)}catch{let p=e;for(;p!==j(p);){const h=d(p,"node_modules","smbls");if(S(d(h,"package.json"))){n=h;break}p=j(p)}}let s=q;if(n)try{s=he(d(n,"package.json"))}catch{}let r,l=process.cwd();for(;l!==j(l);){if(S(d(l,"package.json"))){r=l;break}l=j(l)}let f=s;if(r)try{f=he(d(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:f}},z=(e,t)=>{const o=e.isMonorepo?[q]:[e._smblsRequire,e._projectRequire,q].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},sn=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages",t,...o);const n=z(e,`${t}/package.json`);return n?d(j(n),...o):null},rn=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"plugins",t,...o);const n=z(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},Se=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=d(e.monorepoRoot,s,t,...o);if(S(r))return r}return null}const n=z(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},Oe=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages","domql","packages",t,...o);const n=z(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null};let fe=null;const Me="smbls/ssr",Pt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},qe=()=>(fe||(fe=It().catch(e=>{throw fe=null,e})),fe),It=async()=>{const e=qt();let t;if(q&&e.isMonorepo)t=d(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let a;try{return await Pt()}catch(c){a=c}if(!q)throw new Error(`brender: ${Me} is not available in this bundled runtime (${a.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const i=e.smblsRoot&&d(e.smblsRoot,"src","createDomql.js");if(i&&S(i))t=i;else throw new Error(`brender: cannot load ${Me} (${a.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(e.smblsRoot?` (found smbls at ${e.smblsRoot}).`:" (no smbls package found)."))}const o=await import("esbuild"),n=nt(it(),`br_createDomql_${lt(6).toString("hex")}.mjs`),s=ct,r=e.isMonorepo?await import(at(d(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,l=r?new Set(r.workspacePackageRoots().map(a=>r.workspacePackageAt(a).name)):null,f=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,p={name:"workspace-resolve",setup(a){r&&(a.onResolve({filter:/^[^./]/},i=>{if(f.test(i.path))return;const c=i.path.split("/"),u=i.path.startsWith("@")?c.slice(0,2).join("/"):c[0];if(!l.has(u))return;const g=r.resolveWorkspaceSource(i.path,i.importer||t);return g?{path:g}:{errors:[{text:`"${i.path}" names no source file in the workspace`}]}}),a.onLoad({filter:/[\\/]dist[\\/]/},i=>r.isWorkspaceDist(i.path)?{errors:[{text:`${i.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),a.onResolve({filter:/^smbls/},i=>{const c=i.path.replace(/^smbls\/?/,""),u=e.isMonorepo?d(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!u)return;if(!c){const E=s(u);return E?{path:E}:void 0}const g=d(u,c);if(S(g))return{path:g};if(S(g+".js"))return{path:g+".js"};const R=d(g,"index.js");if(S(R))return{path:R}}),a.onResolve({filter:/^domql$/},i=>{if(e.isMonorepo){const c=d(e.monorepoRoot,"packages","domql","src","index.js");if(S(c))return{path:c};const u=d(e.monorepoRoot,"packages","domql","index.js");if(S(u))return{path:u}}else try{const c=_require.resolve("domql/package.json"),u=s(j(c));if(u)return{path:u}}catch{}}),a.onResolve({filter:/^@symbo\.ls\//},i=>{const c=i.path.replace("@symbo.ls/","");if(c==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const g of["packages","plugins"]){const R=d(e.monorepoRoot,g,c,"src","index.js");if(S(R))return{path:R};const E=d(e.monorepoRoot,g,c,"index.js");if(S(E))return{path:E}}const u=d(e.monorepoRoot,"packages","default-config","blank","index.js");if(c==="default-config"&&S(u))return{path:u}}else{const u=Se(e,c,"src","index.js");if(u&&S(u))return{path:u};const g=Se(e,c,"index.js");if(g&&S(g))return{path:g};if(c==="default-config"){const R=Se(e,"default-config","blank","index.js");if(R&&S(R))return{path:R}}}}),a.onResolve({filter:/^@domql\//},i=>{const c=i.path.replace("@symbo.ls/","");if(e.isMonorepo){const u=d(e.monorepoRoot,"packages","domql","packages",c,"src","index.js");if(S(u))return{path:u};const g=d(e.monorepoRoot,"packages","domql","packages",c,"index.js");if(S(g))return{path:g}}else{const u=Oe(e,c,"src","index.js");if(u&&S(u))return{path:u};const g=Oe(e,c,"index.js");if(g&&S(g))return{path:g}}}),a.onResolve({filter:/^css-in-props/},i=>{let c;if(e.isMonorepo)c=d(e.monorepoRoot,"packages","css-in-props");else{const R=z(e,"css-in-props/package.json");R&&(c=j(R))}if(!c)return;const u=i.path.replace(/^css-in-props\/?/,"");if(u){const R=d(c,u),E=d(R,"index.js");if(S(E))return{path:E};if(S(R+".js"))return{path:R+".js"};if(S(R))return{path:R}}const g=s(c);if(g)return{path:g}}),a.onResolve({filter:/^@emotion\//},i=>{let c;if(e.isMonorepo)c=d(e.monorepoRoot,"node_modules",i.path);else{const u=z(e,`${i.path}/package.json`);if(!u)return;c=j(u)}if(S(c)){const u=d(c,"package.json");if(S(u))try{const g=JSON.parse(Y(u,"utf8")),R=g.module||g.main||"dist/emotion-css.esm.js";return{path:d(c,R)}}catch{}return{path:c}}}),a.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const c=d(i.resolveDir,i.path);if(S(c))return{path:c}}}),a.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),a.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,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 i=>{let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:c,loader:"js"}}),a.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let c=Y(i.path,"utf8");return c=c.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:c,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[p],nodePaths:e.isMonorepo?[d(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[d(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[d(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[d(e.smblsRoot,"..","..","node_modules")]:[]].filter(a=>S(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 h=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{st(n)}catch{}return h},Ft={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:e=>e.href,target:e=>e.target,rel:e=>e.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:e=>{let t=e.src;return typeof t=="string"&&t.includes("{{")&&(t=e.call("replaceLiteralsWithObjectFields",t,e.state)),t},alt:e=>e.alt,loading:e=>e.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"}},Gt=(e,t)=>{const o={};return Pe(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},Pe=(e,t)=>{const o=n=>{const s=n&&n.__ref;if(s&&(t(n,s),s.__children))for(const r of s.__children)o(n[r])};o(e)},Bt=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let W=0;const Ie=Symbol.for("brender.fetchTracked"),Re=()=>W,Kt=256*1024,Nt=1024*1024,Ht=new Set(["accept-language","accept"]),Fe={renders:0,record:null},zt=50,we={renders:0,record:null},Ge=(e,t)=>{e.renders++,e.renders===1?e.record=t():e.record&&(e.record.tainted=!0);const o=e.record;return{record:o,close:()=>{e.renders--,e.record===o&&(e.record=null)}}},ke=e=>e.record&&!e.record.tainted?e.record:null,Wt=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},xe=(e,t,o)=>{!e||e.tainted||e.failures.length>=zt||e.failures.push({url:Wt(t),reason:o})},Be=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),Ut=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Be(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),l={},f=p=>{if(!p)return;const h=!Array.isArray(p)&&typeof p.entries!="function";for(const[a,i]of St(p))h&&i==null||(l[String(a).toLowerCase()]=String(i))};return n&&f(t.headers),o&&f(o.headers),{url:s,method:r,headers:l}},Vt=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const s=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(s))return;let r;try{r=o.clone()}catch{return}n(r.text().then(l=>{e.tainted||l.length>Kt||e.bytes+l.length>Nt||(e.bytes+=l.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:l}))},()=>{}))},Jt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Ie])return;const t=function(...o){W++;let n=!1;const s=()=>{n||(n=!0,W--)},r=i=>{W++,i.then(()=>{W--},()=>{W--})},l=ke(Fe),f=ke(we);let p=null;if(l)try{p=Ut(o),(p.method!=="GET"||!/^https?:/i.test(p.url)||Object.keys(p.headers).some(i=>!Ht.has(i)))&&(p=null)}catch{p=null}const h=()=>Be(o[0]);let a;try{a=e.apply(this,o)}catch(i){throw xe(f,h(),i&&i.message||"failed"),s(),i}return a&&typeof a.then=="function"?a.then(i=>{p&&Vt(l,p,i,r),f&&i&&i.ok===!1&&xe(f,h(),"HTTP "+i.status),s()},i=>{xe(f,h(),i&&i.message||"network error"),s()}):s(),a};t[Ie]=!0,globalThis.fetch=t},cn=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=kt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
|
|
2
|
-
`+
|
|
1
|
+
import{resolve as g,join as rt,dirname as j}from"path";import{existsSync as b,unlinkSync as ct,readFileSync as Y,realpathSync as it}from"fs";import{resolvePackageEntry as at}from"./packageEntry.js";import{tmpdir as lt}from"os";import{randomBytes as ft}from"crypto";import{createRequire as ye}from"module";import{pathToFileURL as pt}from"url";import{createEnv as je}from"./env.js";import{resetKeys as ve,assignKeys as Le,mapKeysToElements as Ae}from"./keys.js";import{extractMetadata as be,generateHeadHtml as ut}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as dt}from"./shell.js";import{trimSpriteToPage as mt,classRulesForPage as gt,markupClasses as ht,trimVariablesToPage as yt}from"./pageWeight.js";import{facesSheetTag as bt}from"./faces.js";import{fetchSSRTranslations as St}from"./prefetch.js";import{createEarlySeedScript as Rt}from"@symbo.ls/fetch";import{headerEntries as wt}from"@symbo.ls/fetch/rest";import{brenderStampMeta as kt,brenderLazyMeta as $e,escapeRegExp as xt,jsonForScript as _t,libraryPackageSpecs as Et,polyglotFallbackLang as Se,polyglotLangStorageKey as Tt,polyglotAddressLang as jt,polyglotStartupScript as vt}from"@symbo.ls/utils";import{brenderRegistryBlock as Lt,brenderRegistryTreeBlock as At}from"@symbo.ls/utils/server";import*as $t from"@symbo.ls/utils/server";import*as Dt from"@symbo.ls/utils";let le=null;const Ct=async()=>{if(le)return le;try{return le=(await import("@symbo.ls/funcql")).funcqlPlugin,le}catch{return null}};import"linkedom";import{createEarlySeedBlock as Ot,fetchRunsOf as Mt}from"@symbo.ls/fetch";import{reset as qt}from"@symbo.ls/css";const fe=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let n=e;for(const s of o){if(n==null||typeof n!="object")return;n=n[s]}return n},pe=(e,t)=>Se(e?.lang,t),Pt=e=>{const t=$t.revivePolyglotDefaultLang;if(typeof t!="function"||!e||typeof e!="object")return e;const o=e.polyglot?t(e.polyglot):e.polyglot,n=e.config&&e.config.polyglot,s=n&&t(n);if(o===e.polyglot&&s===n)return e;const r={...e};return o!==e.polyglot&&(r.polyglot=o),s!==n&&(r.config={...e.config,polyglot:s}),r},De=e=>{const t=Dt.withPolyglotTranslations;return typeof t=="function"?t(e):e},Ce=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const a=fe(r,e);if(a!==void 0)return a}}if(n?.translations){const r=n.translations[t];if(r){const a=fe(r,e);if(a!==void 0)return a}}const s=Se(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const a=fe(r,e);if(a!==void 0)return a}}},It=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=Ce(e,t||pe(s,n),n,s);if(r!==void 0)return r;const a=xe(ke);return n&&a&&a.labelKeys.add(e),e},Oe=function(){return pe(this?.state?.root,this?.context?.polyglot)},L=(e,t=new WeakMap)=>{if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(const s of e)n.push(typeof s=="object"&&s!==null?L(s,t):s);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const s=e[n];o[n]=typeof s=="object"&&s!==null?L(s,t):s}return o};let O=null;try{import.meta.url&&(O=ye(import.meta.url))}catch{}const Ft=()=>{if(!import.meta.url||!O)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:p=>p};const e=it(new URL(".",import.meta.url).pathname),t=g(e,"../..");if(b(g(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const p=O.resolve("smbls/package.json");n=j(p)}catch{let p=e;for(;p!==j(p);){const m=g(p,"node_modules","smbls");if(b(g(m,"package.json"))){n=m;break}p=j(p)}}let s=O;if(n)try{s=ye(g(n,"package.json"))}catch{}let r,a=process.cwd();for(;a!==j(a);){if(b(g(a,"package.json"))){r=a;break}a=j(a)}let f=s;if(r)try{f=ye(g(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:f}},z=(e,t)=>{const o=e.isMonorepo?[O]:[e._smblsRequire,e._projectRequire,O].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},an=(e,t,...o)=>{if(e.isMonorepo)return g(e.monorepoRoot,"packages",t,...o);const n=z(e,`${t}/package.json`);return n?g(j(n),...o):null},ln=(e,t,...o)=>{if(e.isMonorepo)return g(e.monorepoRoot,"plugins",t,...o);const n=z(e,`@symbo.ls/${t}/package.json`);return n?g(j(n),...o):null},Re=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=g(e.monorepoRoot,s,t,...o);if(b(r))return r}return null}const n=z(e,`@symbo.ls/${t}/package.json`);return n?g(j(n),...o):null},Me=(e,t,...o)=>{if(e.isMonorepo)return g(e.monorepoRoot,"packages","domql","packages",t,...o);const n=z(e,`@symbo.ls/${t}/package.json`);return n?g(j(n),...o):null};let ue=null;const qe="smbls/ssr",Gt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Pe=()=>(ue||(ue=Bt().catch(e=>{throw ue=null,e})),ue),Bt=async()=>{const e=Ft();let t;if(O&&e.isMonorepo)t=g(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let l;try{return await Gt()}catch(c){l=c}if(!O)throw new Error(`brender: ${qe} is not available in this bundled runtime (${l.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const i=e.smblsRoot&&g(e.smblsRoot,"src","createDomql.js");if(i&&b(i))t=i;else throw new Error(`brender: cannot load ${qe} (${l.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(e.smblsRoot?` (found smbls at ${e.smblsRoot}).`:" (no smbls package found)."))}const o=await import("esbuild"),n=rt(lt(),`br_createDomql_${ft(6).toString("hex")}.mjs`),s=at,r=e.isMonorepo?await import(pt(g(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=r?new Set(r.workspacePackageRoots().map(l=>r.workspacePackageAt(l).name)):null,f=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,p={name:"workspace-resolve",setup(l){r&&(l.onResolve({filter:/^[^./]/},i=>{if(f.test(i.path))return;const c=i.path.split("/"),u=i.path.startsWith("@")?c.slice(0,2).join("/"):c[0];if(!a.has(u))return;const y=r.resolveWorkspaceSource(i.path,i.importer||t);return y?{path:y}:{errors:[{text:`"${i.path}" names no source file in the workspace`}]}}),l.onLoad({filter:/[\\/]dist[\\/]/},i=>r.isWorkspaceDist(i.path)?{errors:[{text:`${i.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),l.onResolve({filter:/^smbls/},i=>{const c=i.path.replace(/^smbls\/?/,""),u=e.isMonorepo?g(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!u)return;if(!c){const _=s(u);return _?{path:_}:void 0}const y=g(u,c);if(b(y))return{path:y};if(b(y+".js"))return{path:y+".js"};const S=g(y,"index.js");if(b(S))return{path:S}}),l.onResolve({filter:/^domql$/},i=>{if(e.isMonorepo){const c=g(e.monorepoRoot,"packages","domql","src","index.js");if(b(c))return{path:c};const u=g(e.monorepoRoot,"packages","domql","index.js");if(b(u))return{path:u}}else try{const c=_require.resolve("domql/package.json"),u=s(j(c));if(u)return{path:u}}catch{}}),l.onResolve({filter:/^@symbo\.ls\//},i=>{const c=i.path.replace("@symbo.ls/","");if(c==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const y of["packages","plugins"]){const S=g(e.monorepoRoot,y,c,"src","index.js");if(b(S))return{path:S};const _=g(e.monorepoRoot,y,c,"index.js");if(b(_))return{path:_}}const u=g(e.monorepoRoot,"packages","default-config","blank","index.js");if(c==="default-config"&&b(u))return{path:u}}else{const u=Re(e,c,"src","index.js");if(u&&b(u))return{path:u};const y=Re(e,c,"index.js");if(y&&b(y))return{path:y};if(c==="default-config"){const S=Re(e,"default-config","blank","index.js");if(S&&b(S))return{path:S}}}}),l.onResolve({filter:/^@domql\//},i=>{const c=i.path.replace("@symbo.ls/","");if(e.isMonorepo){const u=g(e.monorepoRoot,"packages","domql","packages",c,"src","index.js");if(b(u))return{path:u};const y=g(e.monorepoRoot,"packages","domql","packages",c,"index.js");if(b(y))return{path:y}}else{const u=Me(e,c,"src","index.js");if(u&&b(u))return{path:u};const y=Me(e,c,"index.js");if(y&&b(y))return{path:y}}}),l.onResolve({filter:/^css-in-props/},i=>{let c;if(e.isMonorepo)c=g(e.monorepoRoot,"packages","css-in-props");else{const S=z(e,"css-in-props/package.json");S&&(c=j(S))}if(!c)return;const u=i.path.replace(/^css-in-props\/?/,"");if(u){const S=g(c,u),_=g(S,"index.js");if(b(_))return{path:_};if(b(S+".js"))return{path:S+".js"};if(b(S))return{path:S}}const y=s(c);if(y)return{path:y}}),l.onResolve({filter:/^@emotion\//},i=>{let c;if(e.isMonorepo)c=g(e.monorepoRoot,"node_modules",i.path);else{const u=z(e,`${i.path}/package.json`);if(!u)return;c=j(u)}if(b(c)){const u=g(c,"package.json");if(b(u))try{const y=JSON.parse(Y(u,"utf8")),S=y.module||y.main||"dist/emotion-css.esm.js";return{path:g(c,S)}}catch{}return{path:c}}}),l.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const c=g(i.resolveDir,i.path);if(b(c))return{path:c}}}),l.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),l.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),l.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"})),l.onLoad({filter:/smbls\/src\/router\.js$/},async i=>{let c=Y(i.path,"utf8");return c=c.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:c,loader:"js"}}),l.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let c=Y(i.path,"utf8");return c=c.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:c,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[p],nodePaths:e.isMonorepo?[g(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[g(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[g(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[g(e.smblsRoot,"..","..","node_modules")]:[]].filter(l=>b(l)),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 m=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{ct(n)}catch{}return m},Kt={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:e=>e.href,target:e=>e.target,rel:e=>e.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:e=>{let t=e.src;return typeof t=="string"&&t.includes("{{")&&(t=e.call("replaceLiteralsWithObjectFields",t,e.state)),t},alt:e=>e.alt,loading:e=>e.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"}},Nt=(e,t)=>{const o={};return Ie(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},Ie=(e,t)=>{const o=n=>{const s=n&&n.__ref;if(s&&(t(n,s),s.__children))for(const r of s.__children)o(n[r])};o(e)},Ht=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let W=0;const Fe=Symbol.for("brender.fetchTracked"),we=()=>W,zt=256*1024,Wt=1024*1024,Ut=new Set(["accept-language","accept"]),Ge={renders:0,record:null},Vt=50,ke={renders:0,record:null},Be=(e,t)=>{e.renders++,e.renders===1?e.record=t():e.record&&(e.record.tainted=!0);const o=e.record;return{record:o,close:()=>{e.renders--,e.record===o&&(e.record=null)}}},xe=e=>e.record&&!e.record.tainted?e.record:null,Jt=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},_e=(e,t,o)=>{!e||e.tainted||e.failures.length>=Vt||e.failures.push({url:Jt(t),reason:o})},Ke=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),Yt=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Ke(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),a={},f=p=>{if(!p)return;const m=!Array.isArray(p)&&typeof p.entries!="function";for(const[l,i]of wt(p))m&&i==null||(a[String(l).toLowerCase()]=String(i))};return n&&f(t.headers),o&&f(o.headers),{url:s,method:r,headers:a}},Xt=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const s=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(s))return;let r;try{r=o.clone()}catch{return}n(r.text().then(a=>{e.tainted||a.length>zt||e.bytes+a.length>Wt||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:a}))},()=>{}))},Qt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Fe])return;const t=function(...o){W++;let n=!1;const s=()=>{n||(n=!0,W--)},r=i=>{W++,i.then(()=>{W--},()=>{W--})},a=xe(Ge),f=xe(ke);let p=null;if(a)try{p=Yt(o),(p.method!=="GET"||!/^https?:/i.test(p.url)||Object.keys(p.headers).some(i=>!Ut.has(i)))&&(p=null)}catch{p=null}const m=()=>Ke(o[0]);let l;try{l=e.apply(this,o)}catch(i){throw _e(f,m(),i&&i.message||"failed"),s(),i}return l&&typeof l.then=="function"?l.then(i=>{p&&Xt(a,p,i,r),f&&i&&i.ok===!1&&_e(f,m(),"HTTP "+i.status),s()},i=>{_e(f,m(),i&&i.message||"network error"),s()}):s(),l};t[Fe]=!0,globalThis.fetch=t},fn=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=_t(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
|
|
2
|
+
`+Rt(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Zt=e=>{const t=globalThis.__SMBLS_PKGS__,o=new Set(t&&typeof t=="object"?Object.getOwnPropertyNames(t):[]);return()=>{const n=globalThis.__SMBLS_PKGS__;if(!n||typeof n!="object")return;let s;try{s=Et(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},eo=3e4,to=2147483647;let Ne=Promise.resolve();const He=()=>{},oo=e=>{const t=Ne.then(e);return Ne=t.then(He,He),t},no=e=>{if(e===void 0)return eo;if(e===0||e===!1||e===1/0)return 0;if(typeof e!="number"||!(e>0))throw new TypeError(`brender: options.timeout is a number of milliseconds, or 0 / false for no limit \u2014 not ${JSON.stringify(e)}`);return Math.min(e,to)},ze=e=>{if(e==null||e===""||e==="?")return"";if(typeof e!="string"||e.includes("#"))throw new TypeError(`brender: options.search is a query string ('?view=agent'), without a hash \u2014 not ${JSON.stringify(e)}`);return e.charAt(0)==="?"?e:"?"+e},so=(e,t)=>{const o=e.route||"/",n=e.pathname||o,s=n===o?o:`${n} (route ${o})`,r=new Error(`brender: the render of ${s} did not finish within ${t} ms and was abandoned, so the renders after it can run (options.timeout)`);return r.code="BRENDER_RENDER_TIMEOUT",r.route=o,r.pathname=n,r.timeout=t,r},ro=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},co=e=>{let t=!1;return()=>{t||(t=!0,e())}},We=(e,t={})=>{let o;try{o=no(t.timeout),ze(t.search)}catch(n){return Promise.reject(n)}return oo(()=>io(De(e),t,o))},io=async(e,t,o)=>{await Pe();const n={closed:!1,undo:[]},s=ao(e,t,n);if(!o)return s;let r;const a=new Promise((f,p)=>{r=setTimeout(()=>{ro(n),p(so(t,o))},o)});try{return await Promise.race([s,a])}finally{clearTimeout(r)}},ao=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:a,prefetch:f=!1,lazyGroups:p}=t,m=s||n,l=ze(t.search);Qt();const i=Be(ke,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await lo(Pt(e),{route:n,locationPath:m,locationSearch:l,stateOverrides:r,contextOverrides:a,prefetch:f,lazyGroups:p},i.record,o)}finally{i.close()}},lo=async(e,{route:t,locationPath:o,locationSearch:n,stateOverrides:s,contextOverrides:r,prefetch:a,lazyGroups:f},p,m)=>{const l=()=>{if(m.closed)throw new Error("brender: this render was abandoned at its timeout")};let i;if(a){try{i=await St(e)}catch(M){m.closed||console.warn("[brender] SSR translation fetch failed:",M.message)}l()}const{window:c,document:u}=je(),y=u.body;c.location.pathname=o,n&&(c.location.search=n,c.location.href=c.location.origin+o+n);let S=null;const _=[de("document",u),de("location",c.location),de("localStorage",c.localStorage),de("sessionStorage",c.sessionStorage),Zt(()=>S&&S.sharedLibraries)].map(co);m.undo.push(..._);try{const{createDomqlElement:M,PRERENDER_REGISTRY_FORMATS:X}=await Pe();l();const he=L(e.app||{}),x={...e.config||{}};e.polyglot&&!x.polyglot&&(x.polyglot=e.polyglot),e.fetch&&!x.fetch&&(x.fetch=e.fetch),e.router&&!x.router&&(x.router=e.router);for(const R of yo)e[R]!=null&&x[R]==null&&(x[R]=e[R]);const E=x.polyglot?{...x.polyglot,prefetch:!1}:void 0,U=jt(o,E);U&&c.localStorage.setItem(Tt(E),U),i&&E&&(E.translations={...E.translations||{},...i});const Q=L(e.state||{});qt();const Z={};for(const R in e){if(Ht.has(R))continue;const h=e[R];Z[R]=h&&typeof h=="object"?L(h):h}const w={...Z,state:Q,...s?{state:{...Q,...s}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(e.pages||{}),functions:{...e.functions||{},polyglot:It,getActiveLang:Oe,getLang:Oe},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...x,...E?{polyglot:E}:{},document:u,window:c,parent:{node:y},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,afterFirstView:null,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...fo(f),...r||{},ssr:!0};S=w;const q=await Ct();l(),q&&(w.plugins=w.plugins||[],w.plugins.some(R=>R.name==="funcql")||w.plugins.push(q)),ve();const ee=Be(Ge,()=>({entries:[],bytes:0,tainted:!1})),P=ee.record;let d;try{if(d=await M(he,w),l(),w.lazyFirstView){const T=(d&&d.context||w).__firstNavigation;if(T&&typeof T.then=="function"){try{await T}catch{}l()}}const R=Date.now(),h=a?2e3:50,k=T=>new Promise(ae=>setTimeout(ae,T));for(await k(Math.min(50,h));a&&!m.closed&&we()>0&&Date.now()-R<h;)await k(10),we()===0&&await k(Math.max(0,Math.min(50,h-(Date.now()-R))));if(l(),a&&await po(d,E)){l();const T=Date.now();for(await k(Math.min(50,h));!m.closed&&we()>0&&Date.now()-T<h;)await k(10);l()}}finally{ee.close()}const I=P&&!P.tainted&&!(x.fetch&&x.fetch.seed===!1)?P.entries.slice():[];Le(y);const te=Ae(d),{elementPath:v}=await import("@symbo.ls/element");l();const V=Nt(d,v),oe=I.length?Mt(d&&d.context||w,v):{},ne=d?.context?.routerOptions?.contentElementKey||"content",$=d&&d[ne],se=$&&typeof $=="object"&&$.__ref?$:void 0,D=be(e,t,d,d?.state,se),K=[],J=u.head||u.querySelector("head");if(J)for(const R of J.querySelectorAll("style")){if(R.sheet&&R.sheet.cssRules)for(const h of R.sheet.cssRules)h.cssText&&K.push(h);if(!K.length){const h=R.textContent||"";h&&K.push({cssText:h})}}const re=K.map(R=>R.cssText),{globalCSS:ce,classRules:ie}=xo(K);let N=Je(y.innerHTML);const A=d?.state?.root,F=pe(A,E),G=uo(i,A);G&&(N=Ve(N,Ue(G,F,E)));const H=p&&!p.tainted?{failedRequests:p.failures.slice(),rawLabelKeys:ho(p.labelKeys,N,F,E,A)}:null,C=(d&&d.context||w).__lazyFirstViews,B=C&&typeof C.forEach=="function"?[...C]:[];return{html:N,metadata:D,registry:te,brRegistry:V,element:d,emotionCSS:re,lazyGroups:B,globalCSS:ce,classRules:ie,fetchSeed:I,fetchRuns:oe,document:u,window:c,ssrTranslations:G||void 0,activeLang:F,diagnostics:H,preparedDesignSystem:w.preparedDesignSystem||null,registryFormats:Array.isArray(X)?X.slice():["paths"]}}finally{for(const M of _)M()}},fo=e=>{if(e==="load"||e===!0)return{lazyFirstView:!0};if(Array.isArray(e)){const t=e.filter(o=>typeof o=="string"&&o);return t.length?{lazyFirstView:t}:{}}return{}},de=(e,t)=>{const o=Object.getOwnPropertyDescriptor(globalThis,e);return o&&!o.configurable?!o.writable&&!o.set?()=>{}:(globalThis[e]=t,()=>{}):(Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0,enumerable:!0}),()=>{o?Object.defineProperty(globalThis,e,o):delete globalThis[e]})},po=async(e,t)=>{if(!t||!t.fetch||!e||typeof e.call!="function")return!1;const o=e.state&&e.state.root;if(!o)return!1;const n=pe(o,t),s=o.translations&&o.translations[n];if(s&&typeof s=="object"&&Object.keys(s).length||t.translations&&t.translations[n])return!1;try{await e.call("loadTranslations",n,{inFlight:!0})}catch{}return!0},Ee=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,Te=e=>e&&typeof e.parse=="function"?e.parse():e,uo=(e,t)=>{const o=Te(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const a=Te(s[r]);a&&typeof a=="object"&&(n[r]={...n[r]||{},...a})}return Object.keys(n).length?n:null},Ue=(e,t,o)=>e[t]||e[Se(void 0,o)]||Object.values(e)[0]||{},Ve=(e,t)=>e.replace(Ee,(o,n)=>fe(t,n.trim())??o),mo=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,go=(e,t)=>new RegExp(`(?:^|[^\\w.-])${xt(t)}(?![\\w-]|\\.\\w)`).test(e),ho=(e,t,o,n,s)=>{const r=new Set,a=t.replace(mo,"");for(const f of e)/\s/.test(f)||Ce(f,o,n,s)===void 0&&go(a,f)&&r.add(f);for(const f of a.matchAll(Ee))r.add(f[1].trim());return[...r]},pn=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=je(),r=s.body,{create:a}=await import("@symbo.ls/element"),f=await import("@symbo.ls/utils"),p={...Kt,...o.components||{}},m={...f,...o.utils||{},...o.functions||{}};ve();let l;try{l=a(e,{node:r},"root",{context:{document:s,window:n,...o,components:p,utils:m,ssr:!0}})}catch{}Le(r);const i=l?Ae(l):{};return{html:Je(r.innerHTML),registry:i,element:l}},Je=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,n,s)=>{if(n.includes("<")){const r=n.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'");return o+r+s}return t}),yo=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],bo=new Set(["auto","system"]),Ye=e=>{if(!e||typeof e!="object")return null;const t=e.config&&typeof e.config=="object"?e.config:{};if((t.themeRoot!=null?t.themeRoot:e.themeRoot)!=null)return null;const n=t.globalTheme!=null?t.globalTheme:e.globalTheme;if(typeof n!="string")return null;const s=n.trim();return!s||bo.has(s)?null:s},So=e=>String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),Ro=/\.[A-Za-z_\\-]/,wo=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!Ro.test(t)},ko=/^\s*(:root|\[data-theme|\[data-skin)/,Xe=e=>{const t=e&&e.cssText;if(typeof t!="string")return null;if(/^@(-webkit-)?keyframes\b/.test(t))return"keyframes";if(t.startsWith("@font-face"))return null;if(typeof e.selectorText=="string")return wo(e.selectorText)?ko.test(e.selectorText)?"root":"reset":null;const o=e.cssRules&&Array.from(e.cssRules);if(o&&o.length&&/^@(media|supports|container)\b/.test(t)){const n=new Set(o.map(Xe));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Qe=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),xo=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Xe(n);s?t[s].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
|
|
3
3
|
`),resetRules:t.reset.join(`
|
|
4
4
|
`),keyframeRules:t.keyframes.join(`
|
|
5
|
-
`),fontFaceCSS:""},classRules:o}};let
|
|
6
|
-
`),
|
|
5
|
+
`),fontFaceCSS:""},classRules:o}};let me=new Set;const un=()=>{me=new Set},dn=()=>Array.from(me).join(`
|
|
6
|
+
`),mn=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
|
|
7
7
|
${t}
|
|
8
|
-
</style>`:""),
|
|
9
|
-
`),classRules:f.classRules.slice(),globalCSS:
|
|
10
|
-
`):
|
|
11
|
-
`),
|
|
12
|
-
${(
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
</style>`,
|
|
16
|
-
${
|
|
17
|
-
</style>`:"",
|
|
18
|
-
`:"",
|
|
19
|
-
`:"";
|
|
8
|
+
</style>`:""),gn=async(e,t={})=>{const{route:o="/",pathname:n,search:s,prefetch:r=!0,timeout:a}=t,f=await We(e,{route:o,pathname:n,search:s,prefetch:r,timeout:a});if(!f)return null;const p=e.designSystem||{},m=f.globalCSS;let l=null;try{const c=_o(f.element);Object.keys(c).length&&(l=c)}catch{}const i=f.activeLang;return{html:f.html,css:f.classRules.join(`
|
|
9
|
+
`),classRules:f.classRules.slice(),globalCSS:m,resetCss:m.resetRules,fontLinks:nt(p),metadata:f.metadata||be(e,o),brKeyCount:f.registry?Object.keys(f.registry).length:0,brRegistry:f.brRegistry||{},fetchSeed:f.fetchSeed||[],fetchRuns:f.fetchRuns||{},ssrTranslations:f.ssrTranslations,prefetchedState:l,activeLang:i,theme:Ye(e),diagnostics:f.diagnostics,preparedDesignSystem:f.preparedDesignSystem||null}},_o=e=>{const t={};return Ie(e,o=>{const n=o.fetch;if(!(!n||typeof n!="object"||!o.state))for(const s of Array.isArray(n)?n:[n]){const r=s&&typeof s=="object"&&typeof s.as=="string"?s.as:null;if(!r)continue;const a=r.startsWith("~/"),f=a?r.slice(2):r,p=a?o.state.root:o.state,m=Te(p&&p[f]);f&&m!=null&&typeof m!="function"&&(t[f]=m)}}),t},hn=async(e,t="/",o={})=>{const n=De(e),{lang:s,themeColor:r,isr:a,hydrate:f=!0,prefetch:p=!0,shell:m,adoptDom:l=!1,pathname:i,search:c,eagerImages:u=ot,preloadScripts:y=!0,nonce:S,timeout:_,stamp:M,time:X,spriteIcons:he="all",cssClasses:x="all",cssVariables:E="all",registryFormat:U="paths",lazyGroups:Q,paint:Z}=o,w=Eo(Z),q=Co(S),ee=s||n.state?.lang||n.app?.metadata?.lang||"en",P=Ye(n),d=await We(n,{route:t,pathname:i,search:c,prefetch:p,timeout:_,lazyGroups:Q});if(!d)return null;const I={...d.metadata};if(r&&(I["theme-color"]=r),typeof m=="string"&&!n.name){const h="\0brender-undeclared-title\0";if(be({...n,name:h},t,d.element,d.element?.state).title===h)for(const T of["title","og:title","twitter:title"])I[T]===d.metadata.title&&delete I[T]}const te=ut(I);for(const h of d.classRules)h&&me.add(h);let v=Ao(d.html,u);he==="page"&&(v=mt(v,typeof m=="string"?m:"").html);const V=Array.from(me),oe=V.filter(Qe),ne=oe.length?V.filter(h=>!Qe(h)):V,$=x==="page"?gt(ne,ht(v,typeof m=="string"?m:"")).join(`
|
|
10
|
+
`):ne.join(`
|
|
11
|
+
`),se=bt(oe),D=d.globalCSS,J=`<style data-brender>
|
|
12
|
+
${(E==="page"?yt(D.rootRule||"",D.resetRules,D.keyframeRules,$,v,typeof m=="string"?m:"").css:D.rootRule)||""}
|
|
13
|
+
${D.resetRules||""}
|
|
14
|
+
${D.keyframeRules||""}
|
|
15
|
+
</style>`,re=$?`<style data-emotion="smbls">
|
|
16
|
+
${$}
|
|
17
|
+
</style>`:"",ce=nt(n.designSystem||{}),ie=Object.keys(d.registry).length,N=U==="tree"||U==="auto"&&(d.registryFormats||[]).includes("tree"),A=$o({brRegistry:d.brRegistry,fetchSeed:d.fetchSeed,fetchRuns:d.fetchRuns,adoptDom:l,stamp:M,time:X,registryFormat:N?"tree":"paths",lazyGroups:d.lazyGroups});let F="";if(a&&a.clientScript){const h=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,k=h>0?"../".repeat(h):"./";if(f){const T=vt({polyglot:n.polyglot||n.config?.polyglot,translations:d.ssrTranslations,lang:d.activeLang,pathname:i||t,attrs:q}),ae=T?T+`
|
|
18
|
+
`:"",st=A.blocks?A.blocks+`
|
|
19
|
+
`:"";F=`${ae}${st}<script type="module" src="${k}${a.clientScript}"${q}><\/script>`}else F=`<script type="module"${q}>
|
|
20
20
|
{
|
|
21
21
|
const brEls = document.querySelectorAll('body > :not(script):not(style)')
|
|
22
22
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -33,29 +33,29 @@ ${V}
|
|
|
33
33
|
observer.observe(document.body, { childList: true })
|
|
34
34
|
}
|
|
35
35
|
<\/script>
|
|
36
|
-
<script type="module" src="${
|
|
37
|
-
${
|
|
38
|
-
`),body:
|
|
39
|
-
`+
|
|
40
|
-
<html lang="${ee}"${
|
|
36
|
+
<script type="module" src="${k}${a.clientScript}"${q}><\/script>`}const G={...n.config||{}};n.polyglot&&!G.polyglot&&(G.polyglot=n.polyglot);const H=G.polyglot;let C=te;if(H){const h={...H.translations||{}};for(const k in d.ssrTranslations||{})h[k]={...h[k]||{},...d.ssrTranslations[k]};C=Ve(te,Ue(h,d.activeLang,H))}const B=d.diagnostics;if(B)for(const h of C.matchAll(Ee)){const k=h[1].trim();B.rawLabelKeys.includes(k)||B.rawLabelKeys.push(k)}if(typeof m=="string"){const h=dt(m,{headTags:`${C}
|
|
37
|
+
${A.meta}`,headEnd:[ce,se,J,re].filter(Boolean).join(`
|
|
38
|
+
`),body:w?v+`
|
|
39
|
+
`+et:v,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:A.blocks,lang:s||(H?d.activeLang:void 0),theme:P,preloadScripts:y});return{html:w?tt(h):h,route:t,brKeyCount:ie,shell:!0,diagnostics:B,preparedDesignSystem:d.preparedDesignSystem||null,lazyGroups:d.lazyGroups||[]}}const R=`<!DOCTYPE html>
|
|
40
|
+
<html lang="${ee}"${P?` data-theme="${So(P)}"`:""}>
|
|
41
41
|
<head>
|
|
42
|
-
${
|
|
43
|
-
${
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${O}
|
|
42
|
+
${C}${a&&a.clientScript&&f?`
|
|
43
|
+
${A.meta}`:""}
|
|
44
|
+
${ce}
|
|
45
|
+
${se}
|
|
47
46
|
${J}
|
|
47
|
+
${re}
|
|
48
48
|
</head>
|
|
49
49
|
<body>
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
50
|
+
${v}${w?`
|
|
51
|
+
${et}`:""}
|
|
52
|
+
${F}
|
|
53
53
|
</body>
|
|
54
|
-
</html>`;return{html:
|
|
55
|
-
`+
|
|
56
|
-
`+
|
|
57
|
-
`+e},
|
|
58
|
-
`):""}
|
|
59
|
-
`+
|
|
60
|
-
`+$e(f):""),blocks:[
|
|
61
|
-
`)}},
|
|
54
|
+
</html>`;return{html:w?tt(R):R,route:t,brKeyCount:ie,diagnostics:B,preparedDesignSystem:d.preparedDesignSystem||null,lazyGroups:d.lazyGroups||[]}},Ze="smbls-whole",et=`<template id="${Ze}"></template>`,ge=`<link rel="expect" href="#${Ze}" blocking="render">`,Eo=e=>!!(e&&typeof e=="object"&&e.whole===!0),To=/<meta\b[^>]*\bcharset\s*=[^>]*>/i,jo=[/<head\b[^>]*>/i,/<html\b[^>]*>/i,/^\s*<!doctype\b[^>]*>/i],tt=e=>{if(typeof e!="string"||e.includes(ge))return e;const t=To.exec(e.slice(0,1024));if(t){const o=t.index+t[0].length;return e.slice(0,o)+`
|
|
55
|
+
`+ge+e.slice(o)}for(const o of jo){const n=o.exec(e);if(n)return e.slice(0,n.index+n[0].length)+`
|
|
56
|
+
`+ge+e.slice(n.index+n[0].length)}return ge+`
|
|
57
|
+
`+e},ot=2,vo=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,Lo=/\sloading\s*=/i,Ao=(e,t=ot)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(vo,s=>n++<o||Lo.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},nt=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const s of Object.values(t)){if(typeof s!="string")continue;const r=s.match(/'([^']+)'/);r&&o.add(r[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(s=>`family=${s.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
|
|
58
|
+
`):""},$o=({brRegistry:e,fetchSeed:t,fetchRuns:o,adoptDom:n=!1,stamp:s,time:r,registryFormat:a="paths",lazyGroups:f}={})=>{const m=n&&e&&Object.keys(e).length?a==="tree"&&At(e)||Lt(e):"",l=Ot(t,o);return{meta:`<meta name="brender" content="${m?"hydrate":"replace"}">
|
|
59
|
+
`+kt(Do(s,r))+($e(f)?`
|
|
60
|
+
`+$e(f):""),blocks:[m,l].filter(Boolean).join(`
|
|
61
|
+
`)}},Do=(e,t)=>{const o=typeof t=="number"&&isFinite(t)?Math.round(t):Date.now();return{stamp:e!=null&&e!==""?String(e):new Date(o).toISOString(),time:o}},Co=e=>{if(e==null||e==="")return"";const t=String(e);if(!/^[A-Za-z0-9+/=_-]+$/.test(t))throw new Error("brender: a nonce is base64 or base64url text");return` nonce="${t}"`};export{ot as EAGER_IMAGES_DEFAULT,qe as SMBLS_SSR_SPECIFIER,Ze as WHOLE_MARKER_ID,fn as adoptionScripts,Do as buildStamp,Ye as fixedThemeOf,dn as getAccumulatedEmotionCSS,Ao as markLazyImages,Eo as paintsWhole,$o as prerenderParts,We as render,pn as renderElement,hn as renderPage,gn as renderRoute,mn as replaceEmotionCSS,un as resetGlobalCSSCache,xo as splitCapturedCSS,tt as withWholePaint};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/brender",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.681",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -59,15 +59,15 @@
|
|
|
59
59
|
"@symbo.ls/css": "^3.14.782",
|
|
60
60
|
"@symbo.ls/default-config": "^3.14.794",
|
|
61
61
|
"@symbo.ls/element": "^3.14.823",
|
|
62
|
-
"@symbo.ls/fetch": "^3.14.
|
|
62
|
+
"@symbo.ls/fetch": "^3.14.679",
|
|
63
63
|
"@symbo.ls/helmet": "^3.14.674",
|
|
64
64
|
"@symbo.ls/scratch": "^3.14.799",
|
|
65
|
-
"@symbo.ls/utils": "^3.14.
|
|
65
|
+
"@symbo.ls/utils": "^3.14.860",
|
|
66
66
|
"esbuild": "^0.28.1",
|
|
67
67
|
"linkedom": "^0.16.8"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"smbls": "^3.14.
|
|
70
|
+
"smbls": "^3.14.872"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
73
|
"@symbo.ls/funcql": "^3.14.0"
|
package/prefetch.js
CHANGED
|
@@ -124,12 +124,15 @@ const collectFetchDeclarations = (def, path = '') => {
|
|
|
124
124
|
* sub-problem 2): the Supabase SSR path had been removed, nothing replaced it,
|
|
125
125
|
* so server renders never had data or fetched translations.
|
|
126
126
|
*
|
|
127
|
-
* Not every adapter can run on the server:
|
|
128
|
-
* registered by the page
|
|
127
|
+
* Not every adapter can run on the server: a host's 'sdk' adapter is
|
|
128
|
+
* registered by the host page, which a server render does not have. For a
|
|
129
129
|
* name @symbo.ls/fetch cannot resolve right now (`hasAdapter`), this returns
|
|
130
130
|
* null at once — the page renders without prefetched data and the client's
|
|
131
131
|
* fetch loads it — instead of letting resolveDb wait for a registration that
|
|
132
|
-
* never comes.
|
|
132
|
+
* never comes. A built-in that must not run here (`symbols`, the platform
|
|
133
|
+
* SDK of a published site) is told so — resolveDb's `{ serverRender: true }`
|
|
134
|
+
* — and answers null at once: the server never loads the SDK and never calls
|
|
135
|
+
* the API.
|
|
133
136
|
*/
|
|
134
137
|
const BUILTIN_ADAPTER_NAMES = ['rest', 'local'] // @symbo.ls/fetch without hasAdapter()
|
|
135
138
|
const _adapterCache = new WeakMap()
|
|
@@ -153,7 +156,7 @@ const createSSRAdapter = async (dbConfig) => {
|
|
|
153
156
|
: BUILTIN_ADAPTER_NAMES.includes(config.adapter)
|
|
154
157
|
if (!known) return null
|
|
155
158
|
try {
|
|
156
|
-
return await fetchPkg.resolveDb(config)
|
|
159
|
+
return await fetchPkg.resolveDb(config, { serverRender: true })
|
|
157
160
|
} catch (e) {
|
|
158
161
|
console.warn(`[brender] SSR adapter "${config.adapter}" unavailable: ${e.message}`)
|
|
159
162
|
return null
|
package/render.js
CHANGED
|
@@ -21,6 +21,8 @@ import { brenderRegistryBlock, brenderRegistryTreeBlock } from '@symbo.ls/utils/
|
|
|
21
21
|
// than this package's utils floor (a named import of a missing export fails
|
|
22
22
|
// the module at link time).
|
|
23
23
|
import * as utilsServer from '@symbo.ls/utils/server'
|
|
24
|
+
// The same, for withPolyglotTranslations (withTranslations below).
|
|
25
|
+
import * as utilsIndex from '@symbo.ls/utils'
|
|
24
26
|
|
|
25
27
|
// funcql plugin — enables evaluation of funcql schemas as property values
|
|
26
28
|
// during SSR. Async-imported to avoid polluting non-funcql codepaths.
|
|
@@ -82,6 +84,20 @@ const withRevivedDefaultLang = (data) => {
|
|
|
82
84
|
return out
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
// The payload as frank writes an app whose polyglot reads its design
|
|
88
|
+
// system's lang map: `polyglot.translationsFrom: 'designSystem.lang'` and no
|
|
89
|
+
// `translations` — the map once (FW-FRANK-LANG-MAP-ONCE, @symbo.ls/utils
|
|
90
|
+
// polyglotLang.js). A render reads a VIEW whose polyglot holds that map as
|
|
91
|
+
// its `translations` — for the languages (the address's language), the
|
|
92
|
+
// labels, the fetched labels merged over them, the head — and never writes
|
|
93
|
+
// the caller's payload: mermaid also serves it, and a resolved payload would
|
|
94
|
+
// carry the map twice again. Older utils (below this package's floor): the
|
|
95
|
+
// payload as it is.
|
|
96
|
+
const withTranslations = (data) => {
|
|
97
|
+
const view = utilsIndex.withPolyglotTranslations
|
|
98
|
+
return typeof view === 'function' ? view(data) : data
|
|
99
|
+
}
|
|
100
|
+
|
|
85
101
|
// One label lookup, the order the client's translate() reads: static
|
|
86
102
|
// translations, then the labels loaded into the root state, then the
|
|
87
103
|
// default language's static ones. `undefined` when no table has the key.
|
|
@@ -1135,7 +1151,7 @@ export const render = (data, options = {}) => {
|
|
|
1135
1151
|
} catch (err) {
|
|
1136
1152
|
return Promise.reject(err)
|
|
1137
1153
|
}
|
|
1138
|
-
return inRenderQueue(() => renderInTurn(data, options, timeout))
|
|
1154
|
+
return inRenderQueue(() => renderInTurn(withTranslations(data), options, timeout))
|
|
1139
1155
|
}
|
|
1140
1156
|
|
|
1141
1157
|
const renderInTurn = async (data, options, timeout) => {
|
|
@@ -2011,7 +2027,7 @@ const collectFetchedState = (element) => {
|
|
|
2011
2027
|
*
|
|
2012
2028
|
* Includes head, metadata, fonts, reset CSS, component CSS, and body.
|
|
2013
2029
|
*
|
|
2014
|
-
* @param {object}
|
|
2030
|
+
* @param {object} payload - Full project data (from loadProject); not written to
|
|
2015
2031
|
* @param {string} route - Route to render (e.g. '/', '/about')
|
|
2016
2032
|
* @param {object} [options]
|
|
2017
2033
|
* @param {string} [options.lang='en'] - HTML lang attribute
|
|
@@ -2066,7 +2082,9 @@ const collectFetchedState = (element) => {
|
|
|
2066
2082
|
* paint waits until the page's markup is in (see withWholePaint)
|
|
2067
2083
|
* @returns {Promise<{ html: string, route: string, brKeyCount: number, shell?: true }>}
|
|
2068
2084
|
*/
|
|
2069
|
-
export const renderPage = async (
|
|
2085
|
+
export const renderPage = async (payload, route = '/', options = {}) => {
|
|
2086
|
+
// the strings of a polyglot that names them by pointer (withTranslations)
|
|
2087
|
+
const data = withTranslations(payload)
|
|
2070
2088
|
const { lang, themeColor, isr, hydrate = true, prefetch = true, shell, adoptDom = false, pathname, search, eagerImages = EAGER_IMAGES_DEFAULT, preloadScripts = true, nonce, timeout, stamp, time, spriteIcons = 'all', cssClasses = 'all', cssVariables = 'all', registryFormat = 'paths', lazyGroups, paint } = options
|
|
2071
2089
|
const whole = paintsWhole(paint)
|
|
2072
2090
|
const nonceAttr = nonceAttribute(nonce)
|