@symbo.ls/brender 3.14.659 → 3.14.661
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/dist/esm/render.js +57 -38
- package/dist/esm/sitemap.js +4 -4
- package/package.json +14 -1
- package/render.js +37 -0
- package/sitemap.js +10 -1
package/dist/esm/render.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import{resolve as d,join as tt,dirname as q}from"path";import{existsSync as b,unlinkSync as _t,readFileSync as K,realpathSync as kt}from"fs";import{resolvePackageEntry as $t}from"./packageEntry.js";import{tmpdir as Ct}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 Ot}from"./metadata.js";import"./hydrate.js";import{prefetchPageData as Lt,injectPrefetchedState as At,fetchSSRTranslations as Pt}from"./prefetch.js";let z=null;const It=async()=>{if(z)return z;try{return z=(await import("@symbo.ls/funcql")).funcqlPlugin,z}catch{return null}};import"linkedom";import{reset as qt}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 s=t;for(const r of o){if(s==null||typeof s!="object")return;s=s[r]}return s},vt=function(t,e){if(!t)return"";const o=this?.context,s=o?.polyglot,r=e||s?.defaultLang||"en";if(s?.translations){const c=s.translations[r];if(c){const i=ot(c,t);if(i!==void 0)return i}}const p=this?.state?.root||o?.state?.root;if(p?.translations){const c=p.translations[r];if(c){const i=ot(c,t);if(i!==void 0)return i}}const f=s?.defaultLang||"en";if(f!==r&&s?.translations){const c=s.translations[f];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"},M=(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 s=[];e.set(t,s);for(const r of t)s.push(typeof r=="object"&&r!==null?M(r,e):r);return s}const o={};e.set(t,o);for(const s of Object.keys(t)){const r=t[s];o[s]=typeof r=="object"&&r!==null?M(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 N=null;try{import.meta.url&&(N=et(import.meta.url))}catch{}const ft=()=>{if(!import.meta.url||!N)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:i=>i};const t=kt(new URL(".",import.meta.url).pathname),e=d(t,"../..");if(b(d(e,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:e};let s;try{const i=N.resolve("smbls/package.json");s=q(i)}catch{let i=t;for(;i!==q(i);){const n=d(i,"node_modules","smbls");if(b(d(n,"package.json"))){s=n;break}i=q(i)}}let r=N;if(s)try{r=et(d(s,"package.json"))}catch{}let p,f=process.cwd();for(;f!==q(f);){if(b(d(f,"package.json"))){p=f;break}f=q(f)}let c=r;if(p)try{c=et(d(p,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:s,brenderDir:t,projectRoot:p,_smblsRequire:r,_projectRequire:c}},G=(t,e)=>{const o=t.isMonorepo?[N]:[t._smblsRequire,t._projectRequire,N].filter(Boolean);for(const s of o)try{return s.resolve(e)}catch{}return null},fe=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages",e,...o);const s=G(t,`${e}/package.json`);return s?d(q(s),...o):null},ue=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"plugins",e,...o);const s=G(t,`@symbo.ls/${e}/package.json`);return s?d(q(s),...o):null},H=(t,e,...o)=>{if(t.isMonorepo){for(const r of["packages","plugins"]){const p=d(t.monorepoRoot,r,e,...o);if(b(p))return p}return null}const s=G(t,`@symbo.ls/${e}/package.json`);return s?d(q(s),...o):null},Y=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages","domql","packages",e,...o);const s=G(t,`@symbo.ls/${e}/package.json`);return s?d(q(s),...o):null};let Z=null;const Et=async()=>{if(Z)return Z;const t=ft();if(!N)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"),s=tt(Ct(),`br_createDomql_${Tt(6).toString("hex")}.mjs`),r=$t,p={name:"workspace-resolve",setup(c){c.onResolve({filter:/^smbls/},i=>{const n=i.path.replace(/^smbls\/?/,""),l=t.isMonorepo?d(t.monorepoRoot,"packages","smbls"):t.smblsRoot;if(!l)return;if(!n){const m=r(l);return m?{path:m}:void 0}const u=d(l,n);if(b(u))return{path:u};if(b(u+".js"))return{path:u+".js"};const a=d(u,"index.js");if(b(a))return{path:a}}),c.onResolve({filter:/^domql$/},i=>{if(t.isMonorepo){const n=d(t.monorepoRoot,"packages","domql","src","index.js");if(b(n))return{path:n};const l=d(t.monorepoRoot,"packages","domql","index.js");if(b(l))return{path:l}}else try{const n=_require.resolve("domql/package.json"),l=r(q(n));if(l)return{path:l}}catch{}}),c.onResolve({filter:/^@symbo\.ls\//},i=>{const n=i.path.replace("@symbo.ls/","");if(n==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(t.isMonorepo){for(const u of["packages","plugins"]){const a=d(t.monorepoRoot,u,n,"src","index.js");if(b(a))return{path:a};const m=d(t.monorepoRoot,u,n,"index.js");if(b(m))return{path:m}}const l=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(n==="default-config"&&b(l))return{path:l}}else{const l=H(t,n,"src","index.js");if(l&&b(l))return{path:l};const u=H(t,n,"index.js");if(u&&b(u))return{path:u};if(n==="default-config"){const a=H(t,"default-config","blank","index.js");if(a&&b(a))return{path:a}}}}),c.onResolve({filter:/^@domql\//},i=>{const n=i.path.replace("@symbo.ls/","");if(t.isMonorepo){const l=d(t.monorepoRoot,"packages","domql","packages",n,"src","index.js");if(b(l))return{path:l};const u=d(t.monorepoRoot,"packages","domql","packages",n,"index.js");if(b(u))return{path:u}}else{const l=Y(t,n,"src","index.js");if(l&&b(l))return{path:l};const u=Y(t,n,"index.js");if(u&&b(u))return{path:u}}}),c.onResolve({filter:/^css-in-props/},i=>{let n;if(t.isMonorepo)n=d(t.monorepoRoot,"packages","css-in-props");else{const a=G(t,"css-in-props/package.json");a&&(n=q(a))}if(!n)return;const l=i.path.replace(/^css-in-props\/?/,"");if(l){const a=d(n,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 u=r(n);if(u)return{path:u}}),c.onResolve({filter:/^@emotion\//},i=>{let n;if(t.isMonorepo)n=d(t.monorepoRoot,"node_modules",i.path);else{const l=G(t,`${i.path}/package.json`);if(!l)return;n=q(l)}if(b(n)){const l=d(n,"package.json");if(b(l))try{const u=JSON.parse(K(l,"utf8")),a=u.module||u.main||"dist/emotion-css.esm.js";return{path:d(n,a)}}catch{}return{path:n}}}),c.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const n=d(i.resolveDir,i.path);if(b(n))return{path:n}}}),c.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let n=K(i.path,"utf8");return n=n.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),n=n.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:n,loader:"js"}}),c.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let n=K(i.path,"utf8");return n=n.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:n,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 n=K(i.path,"utf8");return n=n.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:n,loader:"js"}}),c.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let n=K(i.path,"utf8");return n=n.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:n,loader:"js"}})}};await o.build({entryPoints:[e],bundle:!0,format:"esm",platform:"node",outfile:s,write:!0,logLevel:"warning",plugins:[p],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 f=await import(`file://${s}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",s);else try{_t(s)}catch{}return Z=f,f},Dt={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={},s=t.__ref.__brKey;if(s&&(o[e===""?"__root":e]=s),t.__ref.__children)for(const r of t.__ref.__children){const p=t[r];if(p&&p.__ref){const f=e===""?r:`${e}.${r}`;Object.assign(o,ut(p,f))}}return o},pt=async(t,e={})=>{const{route:o="/",pathname:s,state:r,context:p,prefetch:f=!1}=e,c=s||o,i=globalThis.location,n=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(f)try{const y=t.pages||{};l={...y};const E=await Lt(t,o);if(E.size){const V=JSON.parse(JSON.stringify(y[o],(v,B)=>{if(typeof B!="function")return B})),U=(v,B)=>{if(!(!v||!B))for(const D in v)typeof v[D]=="function"?B[D]=v[D]:typeof v[D]=="object"&&v[D]!==null&&!Array.isArray(v[D])&&typeof B[D]=="object"&&B[D]!==null&&U(v[D],B[D])};U(y[o],V),At(V,E),l[o]=V}}catch(y){console.error("[brender] Prefetch error:",y),l=t.pages}let u;if(f)try{u=await Pt(t)}catch(y){console.warn("[brender] SSR translation fetch failed:",y.message)}i!==void 0?globalThis.location=i:delete globalThis.location,n!==void 0?globalThis.window=n:delete globalThis.window;const{window:a,document:m}=nt(),_=m.body;a.location.pathname=c;const h=globalThis.document,g=globalThis.location;globalThis.document=m,globalThis.location=a.location;const{createDomqlElement:I}=await Et(),L=M(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 y of["useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDefaultConfig","useDocumentTheme"])t[y]!=null&&R[y]==null&&(R[y]=t[y]);const k=R.polyglot?{...R.polyglot}:void 0;u&&k&&(k.translations={...k.translations||{},...u});const O=M(t.state||{});(u||k)&&(O.root||(O.root={}),k&&(O.root.lang=O.root.lang||k.defaultLang||"en"),u&&(O.root.translations={...O.root.translations||{},...u})),qt();const C={state:O,...r?{state:{...O,...r}}:{},dependencies:M(t.dependencies||{}),components:M(t.components||{}),snippets:M(t.snippets||{}),pages:M(l||t.pages||{}),functions:{...t.functions||{},polyglot:vt,getActiveLang:lt,getLang:lt},methods:t.methods||{},designSystem:M(t.designSystem||{}),files:t.files||{},sharedLibraries:t.sharedLibraries||[],...R,...k?{polyglot:k}:{},document:m,window:a,parent:{node:_},initOptions:{},domqlOptions:{sourcemap:!1},...p||{}},F=await It();F&&(C.plugins=C.plugins||[],C.plugins.some(y=>y.name==="funcql")||C.plugins.push(F)),st();const A=await I(L,C),x=f?2e3:50;await new Promise(y=>setTimeout(y,x)),rt(_);const $=it(A),S=ut(A),w=ct(t,o,A,A?.state),j=[],T=m.head||m.querySelector("head");if(T)for(const y of T.querySelectorAll("style")){if(y.sheet&&y.sheet.cssRules)for(const E of y.sheet.cssRules)E.cssText&&j.push(E.cssText);if(!j.length){const E=y.textContent||"";E&&j.push(E)}}let P=dt(_.innerHTML);if(u){const y=k?.defaultLang||"en",E=u[y]||Object.values(u)[0]||{};P=P.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(V,U)=>{const v=U.trim();return E[v]??V})}return h!==void 0?globalThis.document=h:delete globalThis.document,g!==void 0?globalThis.location=g:delete globalThis.location,{html:P,metadata:w,registry:$,brRegistry:S,element:A,emotionCSS:j,document:m,window:a,ssrTranslations:u,prefetchedPages:l}},pe=async(t,e={})=>{const{context:o={}}=e,{window:s,document:r}=nt(),p=r.body,{create:f}=await import("@symbo.ls/element"),c=await import("@symbo.ls/utils"),i={...Dt,...o.components||{}},n={...c,...o.utils||{},...o.functions||{}};st();let l;try{l=f(t,{node:p},"root",{context:{document:r,window:s,...o,components:i,utils:n}})}catch{}rt(p);const u=l?it(l):{};return{html:dt(p.innerHTML),registry:u,element:l}},dt=t=>t.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(e,o,s,r)=>{if(s.includes("<")){const p=s.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'");return o+p+r}return e});let W=null;const Mt=["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 s of Mt)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s],o=!0);return o?e:t.settings||null},gt=async(t,e)=>{if(W)return W;try{const{existsSync:o,writeFileSync:s,unlinkSync:r}=await import("fs"),{tmpdir:p}=await import("os"),{randomBytes:f}=await import("crypto");try{p()}catch{return{}}const c=await import("esbuild"),i=JSON.stringify(t||{},at()),n=JSON.stringify(e||{},at()),l=tt(p(),`br_global_${f(6).toString("hex")}.mjs`),u=tt(p(),`br_global_${f(6).toString("hex")}_out.mjs`);s(l,`
|
|
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("<")){const f=n.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/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}
|
|
7
|
+
}`:""}).filter(Boolean).join(`
|
|
8
|
+
|
|
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,`
|
|
2
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'
|
|
3
15
|
import { DEFAULT_CONFIG } from '@symbo.ls/default-config'
|
|
4
16
|
|
|
5
17
|
const ds = ${i}
|
|
6
|
-
const cfg = ${
|
|
18
|
+
const cfg = ${s}
|
|
7
19
|
|
|
8
20
|
// Merge with defaults (same as initEmotion)
|
|
9
21
|
const merged = {}
|
|
@@ -30,39 +42,46 @@ import{resolve as d,join as tt,dirname as q}from"path";import{existsSync as b,un
|
|
|
30
42
|
const result = {
|
|
31
43
|
CSS_VARS: conf.CSS_VARS || {},
|
|
32
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
|
+
: {},
|
|
33
50
|
reset: conf.reset || {},
|
|
34
51
|
animation: conf.animation || {}
|
|
35
52
|
}
|
|
36
53
|
// Export as globalThis so we can read it
|
|
37
54
|
globalThis.__BR_GLOBAL_CSS__ = result
|
|
38
55
|
export default result
|
|
39
|
-
`);const a=ft(),m={name:"workspace-resolve",setup(
|
|
40
|
-
`);let
|
|
41
|
-
${
|
|
42
|
-
}`:"";const
|
|
43
|
-
`);return
|
|
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")?`${_} {
|
|
44
61
|
:root:not([data-theme]) {
|
|
45
|
-
${
|
|
62
|
+
${w};
|
|
46
63
|
}
|
|
47
|
-
}`:`${
|
|
48
|
-
${
|
|
64
|
+
}`:`${_} {
|
|
65
|
+
${w};
|
|
49
66
|
}`:""}).filter(Boolean).join(`
|
|
50
67
|
|
|
51
|
-
`);
|
|
68
|
+
`);T&&(C+=`
|
|
69
|
+
|
|
70
|
+
`+T);const D=Ft(h.CSS_SKIN_RULES);D&&(C+=(C?`
|
|
52
71
|
|
|
53
|
-
|
|
54
|
-
`);
|
|
55
|
-
${
|
|
56
|
-
}`)}return W={rootRule:
|
|
57
|
-
`)},W}catch(o){return console.warn("generateGlobalCSS failed:",o.message,o.stack),W={rootRule:"",resetRules:"",fontFaceCSS:"",keyframeRules:""},W}};let X=new Set;const
|
|
58
|
-
`),
|
|
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">
|
|
59
78
|
${e}
|
|
60
|
-
</style>`:""),
|
|
61
|
-
`):"",globalCSS:
|
|
62
|
-
`),m=t.designSystem||{},
|
|
63
|
-
`)}const
|
|
64
|
-
`:"";
|
|
65
|
-
<script type="module" src="${
|
|
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">
|
|
66
85
|
{
|
|
67
86
|
const brEls = document.querySelectorAll('body > :not(script):not(style)')
|
|
68
87
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -79,30 +98,30 @@ ${e}
|
|
|
79
98
|
observer.observe(document.body, { childList: true })
|
|
80
99
|
}
|
|
81
100
|
<\/script>
|
|
82
|
-
<script type="module" src="${
|
|
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>
|
|
83
102
|
<html lang="${i}">
|
|
84
103
|
<head>
|
|
85
|
-
${
|
|
104
|
+
${$}
|
|
86
105
|
${h}
|
|
87
|
-
${
|
|
106
|
+
${x.fontFaceCSS?`<style>${x.fontFaceCSS}</style>`:""}
|
|
88
107
|
<style>
|
|
89
|
-
${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
108
|
+
${x.rootRule||""}
|
|
109
|
+
${x.resetRules||""}
|
|
110
|
+
${x.keyframeRules||""}
|
|
92
111
|
</style>
|
|
93
112
|
${a?`<style data-emotion="smbls">
|
|
94
113
|
${a}
|
|
95
114
|
</style>`:""}
|
|
96
115
|
</head>
|
|
97
116
|
<body>
|
|
98
|
-
${
|
|
99
|
-
${
|
|
117
|
+
${s.html}
|
|
118
|
+
${A}
|
|
100
119
|
</body>
|
|
101
|
-
</html>`,route:e,brKeyCount:
|
|
102
|
-
`)},
|
|
103
|
-
`);i.push(`@keyframes ${
|
|
104
|
-
${
|
|
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}
|
|
105
124
|
}`)}return[...i,...r].join(`
|
|
106
|
-
`)},
|
|
107
|
-
`)},
|
|
108
|
-
`):""};export{
|
|
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};
|
package/dist/esm/sitemap.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(n,a){const r=([t,e])=>!t.includes(":")&&!t.endsWith("/*")&&!(e&&typeof e=="object"&&(e.notFound===!0||e.metadata?.notFound===!0));return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<urlset
|
|
3
3
|
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
4
4
|
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
5
|
-
${Object.entries(
|
|
5
|
+
${Object.entries(a).filter(r).map(([t,e])=>`
|
|
6
6
|
<url>
|
|
7
|
-
<loc>${(
|
|
7
|
+
<loc>${(e.metadata||{}).canonical||`${n}${t==="/"?"":t}`}</loc>
|
|
8
8
|
<lastmod>${new Date().toISOString()}</lastmod>
|
|
9
9
|
<changefreq>weekly</changefreq>
|
|
10
10
|
<priority>${t==="/"?"1.0":"0.8"}</priority>
|
|
11
11
|
</url>`).join(`
|
|
12
12
|
`)}
|
|
13
|
-
</urlset>`}export{
|
|
13
|
+
</urlset>`}export{c as generateSitemap};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/brender",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.661",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"default": "./dist/esm/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./package.json": "./package.json",
|
|
14
|
+
"./sitemap": {
|
|
15
|
+
"development": "./sitemap.js",
|
|
16
|
+
"import": "./dist/esm/sitemap.js",
|
|
17
|
+
"default": "./dist/esm/sitemap.js"
|
|
18
|
+
},
|
|
14
19
|
"./hydrate": {
|
|
15
20
|
"development": "./hydrate.js",
|
|
16
21
|
"import": "./dist/esm/hydrate.js",
|
|
@@ -42,9 +47,17 @@
|
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
44
49
|
"@symbo.ls/css": "^3.14.599",
|
|
50
|
+
"@symbo.ls/default-config": "^3.14.0",
|
|
51
|
+
"@symbo.ls/element": "^3.14.5",
|
|
45
52
|
"@symbo.ls/helmet": "^3.14.599",
|
|
53
|
+
"@symbo.ls/scratch": "^3.14.775",
|
|
54
|
+
"@symbo.ls/utils": "^3.14.772",
|
|
55
|
+
"esbuild": "^0.28.1",
|
|
46
56
|
"linkedom": "^0.16.8"
|
|
47
57
|
},
|
|
58
|
+
"optionalDependencies": {
|
|
59
|
+
"@symbo.ls/funcql": "^3.14.0"
|
|
60
|
+
},
|
|
48
61
|
"devDependencies": {
|
|
49
62
|
"@babel/core": "^7.29.7"
|
|
50
63
|
},
|
package/render.js
CHANGED
|
@@ -980,6 +980,28 @@ const pickProjectConfig = (data) => {
|
|
|
980
980
|
return data.settings || null
|
|
981
981
|
}
|
|
982
982
|
|
|
983
|
+
// Serialise scratch `buildSkinVarStyles` output — `{ selector: { var: value },
|
|
984
|
+
// '@media …': { selector: { var: value } } }` — as CSS text
|
|
985
|
+
// (FW-SCRATCH-SKINS-DIMENSION-1).
|
|
986
|
+
const declarationBlock = (selector, vars, indent) => {
|
|
987
|
+
const decls = Object.entries(vars || {})
|
|
988
|
+
.map(([k, v]) => `${indent} ${k}: ${v}`)
|
|
989
|
+
.join(';\n')
|
|
990
|
+
return decls ? `${indent}${selector} {\n${decls};\n${indent}}` : ''
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
export const skinRulesToCSS = (rules) => Object.entries(rules || {})
|
|
994
|
+
.map(([key, body]) => {
|
|
995
|
+
if (!key.startsWith('@')) return declarationBlock(key, body, '')
|
|
996
|
+
const inner = Object.entries(body || {})
|
|
997
|
+
.map(([selector, vars]) => declarationBlock(selector, vars, ' '))
|
|
998
|
+
.filter(Boolean)
|
|
999
|
+
.join('\n')
|
|
1000
|
+
return inner ? `${key} {\n${inner}\n}` : ''
|
|
1001
|
+
})
|
|
1002
|
+
.filter(Boolean)
|
|
1003
|
+
.join('\n\n')
|
|
1004
|
+
|
|
983
1005
|
const generateGlobalCSS = async (ds, config) => {
|
|
984
1006
|
if (_cachedGlobalCSS) return _cachedGlobalCSS
|
|
985
1007
|
|
|
@@ -1004,6 +1026,10 @@ const generateGlobalCSS = async (ds, config) => {
|
|
|
1004
1026
|
|
|
1005
1027
|
writeFileSync(tmpEntry, `
|
|
1006
1028
|
import { set, getActiveConfig, getFontFaceString } from '@symbo.ls/scratch'
|
|
1029
|
+
// Namespace access for the skin builder: a scratch without it (version
|
|
1030
|
+
// skew) gives an empty skin block instead of failing this whole bundle
|
|
1031
|
+
// and, with it, every global rule.
|
|
1032
|
+
import * as scratchNs from '@symbo.ls/scratch'
|
|
1007
1033
|
import { DEFAULT_CONFIG } from '@symbo.ls/default-config'
|
|
1008
1034
|
|
|
1009
1035
|
const ds = ${dsJson}
|
|
@@ -1034,6 +1060,11 @@ const generateGlobalCSS = async (ds, config) => {
|
|
|
1034
1060
|
const result = {
|
|
1035
1061
|
CSS_VARS: conf.CSS_VARS || {},
|
|
1036
1062
|
CSS_MEDIA_VARS: conf.CSS_MEDIA_VARS || {},
|
|
1063
|
+
// Skin rules — the same builder smbls init() injects on the client
|
|
1064
|
+
// (FW-SCRATCH-SKINS-DIMENSION-1).
|
|
1065
|
+
CSS_SKIN_RULES: typeof scratchNs.buildSkinVarStyles === 'function'
|
|
1066
|
+
? scratchNs.buildSkinVarStyles(conf.cssSkinVars, conf.cssSkinFallback, ':root')
|
|
1067
|
+
: {},
|
|
1037
1068
|
reset: conf.reset || {},
|
|
1038
1069
|
animation: conf.animation || {}
|
|
1039
1070
|
}
|
|
@@ -1139,6 +1170,12 @@ const generateGlobalCSS = async (ds, config) => {
|
|
|
1139
1170
|
.join('\n\n')
|
|
1140
1171
|
if (themeVarRules) rootRule += '\n\n' + themeVarRules
|
|
1141
1172
|
|
|
1173
|
+
// ── Skin rules ([data-skin] selectors + the reduced-transparency block) ──
|
|
1174
|
+
// After the scheme blocks: on an equal specificity the skin wins, as it
|
|
1175
|
+
// does in the hydrated page (smbls init injects them in the same order).
|
|
1176
|
+
const skinRules = skinRulesToCSS(data.CSS_SKIN_RULES)
|
|
1177
|
+
if (skinRules) rootRule += (rootRule ? '\n\n' : '') + skinRules
|
|
1178
|
+
|
|
1142
1179
|
// ── Reset styles ──
|
|
1143
1180
|
const resetRules = generateResetCSS(reset)
|
|
1144
1181
|
|
package/sitemap.js
CHANGED
|
@@ -6,7 +6,16 @@
|
|
|
6
6
|
* @returns {string} Sitemap XML
|
|
7
7
|
*/
|
|
8
8
|
export function generateSitemap (baseUrl, routes) {
|
|
9
|
-
|
|
9
|
+
// Skip routes that are not real crawlable addresses: dynamic ':param'
|
|
10
|
+
// patterns, '/*' wildcards, and the project's not-found page
|
|
11
|
+
// (notFound: true at the page top level or in its metadata).
|
|
12
|
+
const indexable = ([path, config]) =>
|
|
13
|
+
!path.includes(':') &&
|
|
14
|
+
!path.endsWith('/*') &&
|
|
15
|
+
!(config && typeof config === 'object' &&
|
|
16
|
+
(config.notFound === true || config.metadata?.notFound === true))
|
|
17
|
+
|
|
18
|
+
const urls = Object.entries(routes).filter(indexable).map(([path, config]) => {
|
|
10
19
|
const metadata = config.metadata || {}
|
|
11
20
|
const canonical = metadata.canonical || `${baseUrl}${path === '/' ? '' : path}`
|
|
12
21
|
|