@symbo.ls/brender 3.14.663 → 3.14.665
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 +46 -0
- package/README.md +106 -23
- package/dist/esm/env.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/load.js +2 -1
- package/dist/esm/prefetch.js +1 -1
- package/dist/esm/render.js +33 -51
- package/dist/esm/shell.js +9 -8
- package/env.js +8 -2
- package/index.js +5 -3
- package/load.js +111 -22
- package/package.json +9 -9
- package/prefetch.js +30 -62
- package/render.js +533 -658
- package/shell.js +74 -12
package/dist/esm/render.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import{resolve as d,join as At,dirname as T}from"path";import{existsSync as y,unlinkSync as Pt,readFileSync as V,realpathSync as qt}from"fs";import{resolvePackageEntry as It}from"./packageEntry.js";import{tmpdir as vt}from"os";import{randomBytes as Dt}from"crypto";import{createRequire as ot}from"module";import{createEnv as at}from"./env.js";import{resetKeys as ft,assignKeys as ut,mapKeysToElements as pt}from"./keys.js";import{extractMetadata as st,generateHeadHtml as Mt}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as Bt}from"./shell.js";import{prefetchPageData as Ft,injectPrefetchedState as Nt,fetchSSRTranslations as Wt}from"./prefetch.js";import{createEarlySeedScript as Ht}from"@symbo.ls/fetch";let X=null;const Gt=async()=>{if(X)return X;try{return X=(await import("@symbo.ls/funcql")).funcqlPlugin,X}catch{return null}};import"linkedom";import{reset as Jt}from"@symbo.ls/css";const rt=(t,e)=>{if(!t||!e)return;if(t[e]!==void 0)return t[e];const n=e.split(".");let o=t;for(const i of n){if(o==null||typeof o!="object")return;o=o[i]}return o},Kt=function(t,e){if(!t)return"";const n=this?.context,o=n?.polyglot,i=e||o?.defaultLang||"en";if(o?.translations){const a=o.translations[i];if(a){const r=rt(a,t);if(r!==void 0)return r}}const c=this?.state?.root||n?.state?.root;if(c?.translations){const a=c.translations[i];if(a){const r=rt(a,t);if(r!==void 0)return r}}const u=o?.defaultLang||"en";if(u!==i&&o?.translations){const a=o.translations[u];if(a){const r=rt(a,t);if(r!==void 0)return r}}return t},dt=function(){const t=this?.context;return this?.state?.root?.lang||t?.polyglot?.defaultLang||"en"},A=(t,e=new WeakMap)=>{if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(Array.isArray(t)){const o=[];e.set(t,o);for(const i of t)o.push(typeof i=="object"&&i!==null?A(i,e):i);return o}const n={};e.set(t,n);for(const o of Object.keys(t)){const i=t[o];n[o]=typeof i=="object"&&i!==null?A(i,e):i}return n};let F=null;try{import.meta.url&&(F=ot(import.meta.url))}catch{}const zt=()=>{if(!import.meta.url||!F)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:r=>r};const t=qt(new URL(".",import.meta.url).pathname),e=d(t,"../..");if(y(d(e,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:e};let o;try{const r=F.resolve("smbls/package.json");o=T(r)}catch{let r=t;for(;r!==T(r);){const s=d(r,"node_modules","smbls");if(y(d(s,"package.json"))){o=s;break}r=T(r)}}let i=F;if(o)try{i=ot(d(o,"package.json"))}catch{}let c,u=process.cwd();for(;u!==T(u);){if(y(d(u,"package.json"))){c=u;break}u=T(u)}let a=i;if(c)try{a=ot(d(c,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:o,brenderDir:t,projectRoot:c,_smblsRequire:i,_projectRequire:a}},K=(t,e)=>{const n=t.isMonorepo?[F]:[t._smblsRequire,t._projectRequire,F].filter(Boolean);for(const o of n)try{return o.resolve(e)}catch{}return null},qe=(t,e,...n)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages",e,...n);const o=K(t,`${e}/package.json`);return o?d(T(o),...n):null},Ie=(t,e,...n)=>{if(t.isMonorepo)return d(t.monorepoRoot,"plugins",e,...n);const o=K(t,`@symbo.ls/${e}/package.json`);return o?d(T(o),...n):null},it=(t,e,...n)=>{if(t.isMonorepo){for(const i of["packages","plugins"]){const c=d(t.monorepoRoot,i,e,...n);if(y(c))return c}return null}const o=K(t,`@symbo.ls/${e}/package.json`);return o?d(T(o),...n):null},mt=(t,e,...n)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages","domql","packages",e,...n);const o=K(t,`@symbo.ls/${e}/package.json`);return o?d(T(o),...n):null};let N=null;const gt="smbls/ssr",ht=async()=>{const t=await import("smbls/ssr");if(typeof t?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return t},Ut=async()=>{if(N)return N;const t=zt();if(!F)try{return N=await ht(),N}catch(a){throw new Error(`brender: ${gt} is not available in this bundled runtime (${a.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`)}let e;if(t.isMonorepo)e=d(t.monorepoRoot,"packages","smbls","src","createDomql.js");else{let a;try{return N=await ht(),N}catch(s){a=s}const r=t.smblsRoot&&d(t.smblsRoot,"src","createDomql.js");if(r&&y(r))e=r;else throw new Error(`brender: cannot load ${gt} (${a.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(t.smblsRoot?` (found smbls at ${t.smblsRoot}).`:" (no smbls package found)."))}const n=await import("esbuild"),o=At(vt(),`br_createDomql_${Dt(6).toString("hex")}.mjs`),i=It,c={name:"workspace-resolve",setup(a){a.onResolve({filter:/^smbls/},r=>{const s=r.path.replace(/^smbls\/?/,""),f=t.isMonorepo?d(t.monorepoRoot,"packages","smbls"):t.smblsRoot;if(!f)return;if(!s){const h=i(f);return h?{path:h}:void 0}const l=d(f,s);if(y(l))return{path:l};if(y(l+".js"))return{path:l+".js"};const p=d(l,"index.js");if(y(p))return{path:p}}),a.onResolve({filter:/^domql$/},r=>{if(t.isMonorepo){const s=d(t.monorepoRoot,"packages","domql","src","index.js");if(y(s))return{path:s};const f=d(t.monorepoRoot,"packages","domql","index.js");if(y(f))return{path:f}}else try{const s=_require.resolve("domql/package.json"),f=i(T(s));if(f)return{path:f}}catch{}}),a.onResolve({filter:/^@symbo\.ls\//},r=>{const s=r.path.replace("@symbo.ls/","");if(s==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(t.isMonorepo){for(const l of["packages","plugins"]){const p=d(t.monorepoRoot,l,s,"src","index.js");if(y(p))return{path:p};const h=d(t.monorepoRoot,l,s,"index.js");if(y(h))return{path:h}}const f=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(s==="default-config"&&y(f))return{path:f}}else{const f=it(t,s,"src","index.js");if(f&&y(f))return{path:f};const l=it(t,s,"index.js");if(l&&y(l))return{path:l};if(s==="default-config"){const p=it(t,"default-config","blank","index.js");if(p&&y(p))return{path:p}}}}),a.onResolve({filter:/^@domql\//},r=>{const s=r.path.replace("@symbo.ls/","");if(t.isMonorepo){const f=d(t.monorepoRoot,"packages","domql","packages",s,"src","index.js");if(y(f))return{path:f};const l=d(t.monorepoRoot,"packages","domql","packages",s,"index.js");if(y(l))return{path:l}}else{const f=mt(t,s,"src","index.js");if(f&&y(f))return{path:f};const l=mt(t,s,"index.js");if(l&&y(l))return{path:l}}}),a.onResolve({filter:/^css-in-props/},r=>{let s;if(t.isMonorepo)s=d(t.monorepoRoot,"packages","css-in-props");else{const p=K(t,"css-in-props/package.json");p&&(s=T(p))}if(!s)return;const f=r.path.replace(/^css-in-props\/?/,"");if(f){const p=d(s,f),h=d(p,"index.js");if(y(h))return{path:h};if(y(p+".js"))return{path:p+".js"};if(y(p))return{path:p}}const l=i(s);if(l)return{path:l}}),a.onResolve({filter:/^@emotion\//},r=>{let s;if(t.isMonorepo)s=d(t.monorepoRoot,"node_modules",r.path);else{const f=K(t,`${r.path}/package.json`);if(!f)return;s=T(f)}if(y(s)){const f=d(s,"package.json");if(y(f))try{const l=JSON.parse(V(f,"utf8")),p=l.module||l.main||"dist/emotion-css.esm.js";return{path:d(s,p)}}catch{}return{path:s}}}),a.onResolve({filter:/\.json$/},r=>{if(r.resolveDir){const s=d(r.resolveDir,r.path);if(y(s))return{path:s}}}),a.onLoad({filter:/smbls\/.*options\.js$/},async r=>{if(!r.path.includes("smbls/")||!r.path.endsWith("options.js"))return;let s=V(r.path,"utf8");return s=s.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),a.onLoad({filter:/smbls\/.*init\.js$/},async r=>{if(!r.path.includes("smbls/")||!r.path.endsWith("init.js"))return;let s=V(r.path,"utf8");return s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),a.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),a.onLoad({filter:/smbls\/src\/router\.js$/},async r=>{let s=V(r.path,"utf8");return s=s.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:s,loader:"js"}}),a.onLoad({filter:/fetchOnCreate\.js$/},async r=>{if(!r.path.includes("smbls/"))return;let s=V(r.path,"utf8");return s=s.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:s,loader:"js"}})}};await n.build({entryPoints:[e],bundle:!0,format:"esm",platform:"node",outfile:o,write:!0,logLevel:"warning",plugins:[c],nodePaths:t.isMonorepo?[d(t.monorepoRoot,"node_modules")]:[...t.smblsRoot?[d(t.smblsRoot,"node_modules")]:[],...t.projectRoot?[d(t.projectRoot,"node_modules")]:[],...t.smblsRoot?[d(t.smblsRoot,"..","..","node_modules")]:[]].filter(a=>y(a)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const u=await import(`file://${o}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",o);else try{Pt(o)}catch{}return N=u,u},Yt={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:t=>t.href,target:t=>t.target,rel:t=>t.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:t=>{let e=t.src;return typeof e=="string"&&e.includes("{{")&&(e=t.call("replaceLiteralsWithObjectFields",e,t.state)),e},alt:t=>t.alt,loading:t=>t.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},yt=(t,e="")=>{if(!t||!t.__ref)return{};const n={},o=t.__ref.__brKey;if(o&&(n[e===""?"__root":e]=o),t.__ref.__children)for(const i of t.__ref.__children){const c=t[i];if(c&&c.__ref){const u=e===""?i:`${e}.${i}`;Object.assign(n,yt(c,u))}}return n};let z=0;const bt=Symbol.for("brender.fetchTracked"),St=()=>z,Vt=256*1024,Xt=1024*1024,Zt=new Set(["accept-language","accept"]);let lt=0,q=null;const Qt=t=>{const[e,n]=t,o=e&&typeof e=="object"&&typeof e.url=="string",i=o?e.url:String(e),c=String(n&&n.method||o&&e.method||"GET").toUpperCase(),u={},a=r=>{if(r)if(typeof r.forEach=="function"&&!Array.isArray(r))r.forEach((s,f)=>{u[String(f).toLowerCase()]=String(s)});else if(Array.isArray(r))for(const[s,f]of r)u[String(s).toLowerCase()]=String(f);else for(const s in r)r[s]!=null&&(u[s.toLowerCase()]=String(r[s]))};return o&&a(e.headers),n&&a(n.headers),{url:i,method:c,headers:u}},te=(t,e,n,o)=>{if(!n||!n.ok||typeof n.clone!="function")return;const i=n.headers&&n.headers.get&&n.headers.get("content-type")||"";if(!/json|^text\//i.test(i))return;let c;try{c=n.clone()}catch{return}o(c.text().then(u=>{t.tainted||u.length>Vt||t.bytes+u.length>Xt||(t.bytes+=u.length,t.entries.push({url:e.url,lang:e.headers["accept-language"]||"",status:n.status,type:i,body:u}))},()=>{}))},ee=()=>{const t=globalThis.fetch;if(typeof t!="function"||t[bt])return;const e=function(...n){z++;let o=!1;const i=()=>{o||(o=!0,z--)},c=s=>{z++,s.then(()=>{z--},()=>{z--})},u=q&&!q.tainted?q:null;let a=null;if(u)try{a=Qt(n),(a.method!=="GET"||!/^https?:/i.test(a.url)||Object.keys(a.headers).some(s=>!Zt.has(s)))&&(a=null)}catch{a=null}let r;try{r=t.apply(this,n)}catch(s){throw i(),s}return r&&typeof r.then=="function"?r.then(s=>{a&&te(u,a,s,c),i()},i):i(),r};e[bt]=!0,globalThis.fetch=e},ct=({brRegistry:t,fetchSeed:e}={})=>!t||!Object.keys(t).length?"":`<script>window.__BR_REGISTRY__=${JSON.stringify(t).replace(/</g,"\\u003c")};window.__BRENDER_HYDRATE__=true<\/script>`+(e&&e.length?`
|
|
2
|
-
`+
|
|
3
|
-
`)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`)
|
|
7
|
-
${
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
`),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
${
|
|
16
|
-
</style>`:""
|
|
17
|
-
`)
|
|
18
|
-
|
|
19
|
-
`)}const G=l.brRegistry&&Object.keys(l.brRegistry).length?JSON.stringify(l.brRegistry):null,U=s?ct(l)?ct(l)+`
|
|
20
|
-
`:"":G?`<script>window.__BR_REGISTRY__=${G}<\/script>
|
|
21
|
-
`:"";x=`${$}${U}<script>window.__BRENDER__=true<\/script>
|
|
22
|
-
<script type="module" src="${L}${c.clientScript}"><\/script>`}else x=`<script type="module">
|
|
1
|
+
import{resolve as m,join as Ce,dirname as x}from"path";import{existsSync as b,unlinkSync as De,readFileSync as W,realpathSync as Ie}from"fs";import{resolvePackageEntry as Oe}from"./packageEntry.js";import{tmpdir as Me}from"os";import{randomBytes as Pe}from"crypto";import{createRequire as oe}from"module";import{pathToFileURL as Fe}from"url";import{createEnv as ue}from"./env.js";import{resetKeys as de,assignKeys as me,mapKeysToElements as ge}from"./keys.js";import{extractMetadata as se,generateHeadHtml as Be}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as Ke}from"./shell.js";import{fetchSSRTranslations as Ne}from"./prefetch.js";import{createEarlySeedScript as Ge}from"@symbo.ls/fetch";import{headerEntries as He}from"@symbo.ls/fetch/rest";import{brenderRegistryBlock as Je,escapeRegExp as We,jsonForScript as Ue,polyglotFallbackLang as U}from"@symbo.ls/utils";let Z=null;const ze=async()=>{if(Z)return Z;try{return Z=(await import("@symbo.ls/funcql")).funcqlPlugin,Z}catch{return null}};import"linkedom";import{createEarlySeedBlock as Ye}from"@symbo.ls/fetch";import{reset as Ve}from"@symbo.ls/css";const Q=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let s=e;for(const r of o){if(s==null||typeof s!="object")return;s=s[r]}return s},ne=(e,t)=>U(e?.lang,t),he=(e,t,o,s)=>{if(o?.translations){const n=o.translations[t];if(n){const a=Q(n,e);if(a!==void 0)return a}}if(s?.translations){const n=s.translations[t];if(n){const a=Q(n,e);if(a!==void 0)return a}}const r=U(void 0,o);if(r!==t&&o?.translations){const n=o.translations[r];if(n){const a=Q(n,e);if(a!==void 0)return a}}},Xe=function(e,t){if(!e)return"";const o=this?.context,s=o?.polyglot,r=this?.state?.root||o?.state?.root,n=he(e,t||ne(r,s),s,r);if(n!==void 0)return n;const a=ie(ce);return s&&a&&a.labelKeys.add(e),e},ye=function(){return ne(this?.state?.root,this?.context?.polyglot)},_=(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 s=[];t.set(e,s);for(const r of e)s.push(typeof r=="object"&&r!==null?_(r,t):r);return s}const o={};t.set(e,o);for(const s of Object.keys(e)){const r=e[s];o[s]=typeof r=="object"&&r!==null?_(r,t):r}return o};let $=null;try{import.meta.url&&($=oe(import.meta.url))}catch{}const Ze=()=>{if(!import.meta.url||!$)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:l=>l};const e=Ie(new URL(".",import.meta.url).pathname),t=m(e,"../..");if(b(m(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let s;try{const l=$.resolve("smbls/package.json");s=x(l)}catch{let l=e;for(;l!==x(l);){const y=m(l,"node_modules","smbls");if(b(m(y,"package.json"))){s=y;break}l=x(l)}}let r=$;if(s)try{r=oe(m(s,"package.json"))}catch{}let n,a=process.cwd();for(;a!==x(a);){if(b(m(a,"package.json"))){n=a;break}a=x(a)}let u=r;if(n)try{u=oe(m(n,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:s,brenderDir:e,projectRoot:n,_smblsRequire:r,_projectRequire:u}},P=(e,t)=>{const o=e.isMonorepo?[$]:[e._smblsRequire,e._projectRequire,$].filter(Boolean);for(const s of o)try{return s.resolve(t)}catch{}return null},Zt=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages",t,...o);const s=P(e,`${t}/package.json`);return s?m(x(s),...o):null},Qt=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"plugins",t,...o);const s=P(e,`@symbo.ls/${t}/package.json`);return s?m(x(s),...o):null},re=(e,t,...o)=>{if(e.isMonorepo){for(const r of["packages","plugins"]){const n=m(e.monorepoRoot,r,t,...o);if(b(n))return n}return null}const s=P(e,`@symbo.ls/${t}/package.json`);return s?m(x(s),...o):null},be=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages","domql","packages",t,...o);const s=P(e,`@symbo.ls/${t}/package.json`);return s?m(x(s),...o):null};let z=null;const Se="smbls/ssr",Qe=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},et=async()=>{if(z)return z;const e=Ze();let t;if($&&e.isMonorepo)t=m(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return z=await Qe(),z}catch(c){f=c}if(!$)throw new Error(`brender: ${Se} is not available in this bundled runtime (${f.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const i=e.smblsRoot&&m(e.smblsRoot,"src","createDomql.js");if(i&&b(i))t=i;else throw new Error(`brender: cannot load ${Se} (${f.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"),s=Ce(Me(),`br_createDomql_${Pe(6).toString("hex")}.mjs`),r=Oe,n=e.isMonorepo?await import(Fe(m(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=n?new Set(n.workspacePackageRoots().map(f=>n.workspacePackageAt(f).name)):null,u=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,l={name:"workspace-resolve",setup(f){n&&(f.onResolve({filter:/^[^./]/},i=>{if(u.test(i.path))return;const c=i.path.split("/"),d=i.path.startsWith("@")?c.slice(0,2).join("/"):c[0];if(!a.has(d))return;const p=n.resolveWorkspaceSource(i.path,i.importer||t);return p?{path:p}:{errors:[{text:`"${i.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},i=>n.isWorkspaceDist(i.path)?{errors:[{text:`${i.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},i=>{const c=i.path.replace(/^smbls\/?/,""),d=e.isMonorepo?m(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!d)return;if(!c){const g=r(d);return g?{path:g}:void 0}const p=m(d,c);if(b(p))return{path:p};if(b(p+".js"))return{path:p+".js"};const h=m(p,"index.js");if(b(h))return{path:h}}),f.onResolve({filter:/^domql$/},i=>{if(e.isMonorepo){const c=m(e.monorepoRoot,"packages","domql","src","index.js");if(b(c))return{path:c};const d=m(e.monorepoRoot,"packages","domql","index.js");if(b(d))return{path:d}}else try{const c=_require.resolve("domql/package.json"),d=r(x(c));if(d)return{path:d}}catch{}}),f.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 p of["packages","plugins"]){const h=m(e.monorepoRoot,p,c,"src","index.js");if(b(h))return{path:h};const g=m(e.monorepoRoot,p,c,"index.js");if(b(g))return{path:g}}const d=m(e.monorepoRoot,"packages","default-config","blank","index.js");if(c==="default-config"&&b(d))return{path:d}}else{const d=re(e,c,"src","index.js");if(d&&b(d))return{path:d};const p=re(e,c,"index.js");if(p&&b(p))return{path:p};if(c==="default-config"){const h=re(e,"default-config","blank","index.js");if(h&&b(h))return{path:h}}}}),f.onResolve({filter:/^@domql\//},i=>{const c=i.path.replace("@symbo.ls/","");if(e.isMonorepo){const d=m(e.monorepoRoot,"packages","domql","packages",c,"src","index.js");if(b(d))return{path:d};const p=m(e.monorepoRoot,"packages","domql","packages",c,"index.js");if(b(p))return{path:p}}else{const d=be(e,c,"src","index.js");if(d&&b(d))return{path:d};const p=be(e,c,"index.js");if(p&&b(p))return{path:p}}}),f.onResolve({filter:/^css-in-props/},i=>{let c;if(e.isMonorepo)c=m(e.monorepoRoot,"packages","css-in-props");else{const h=P(e,"css-in-props/package.json");h&&(c=x(h))}if(!c)return;const d=i.path.replace(/^css-in-props\/?/,"");if(d){const h=m(c,d),g=m(h,"index.js");if(b(g))return{path:g};if(b(h+".js"))return{path:h+".js"};if(b(h))return{path:h}}const p=r(c);if(p)return{path:p}}),f.onResolve({filter:/^@emotion\//},i=>{let c;if(e.isMonorepo)c=m(e.monorepoRoot,"node_modules",i.path);else{const d=P(e,`${i.path}/package.json`);if(!d)return;c=x(d)}if(b(c)){const d=m(c,"package.json");if(b(d))try{const p=JSON.parse(W(d,"utf8")),h=p.module||p.main||"dist/emotion-css.esm.js";return{path:m(c,h)}}catch{}return{path:c}}}),f.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const c=m(i.resolveDir,i.path);if(b(c))return{path:c}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let c=W(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"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let c=W(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"}}),f.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"})),f.onLoad({filter:/smbls\/src\/router\.js$/},async i=>{let c=W(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"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let c=W(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:s,write:!0,logLevel:"warning",plugins:[l],nodePaths:e.isMonorepo?[m(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[m(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[m(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[m(e.smblsRoot,"..","..","node_modules")]:[]].filter(f=>b(f)),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 y=await import(`file://${s}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",s);else try{De(s)}catch{}return z=y,y},tt={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"}},ot=(e,t)=>{const o={};return ke(e,(s,r)=>{if(!r.__brKey)return;const n=t(s);o[n===""?"__root":n]=r.__brKey}),o},ke=(e,t)=>{const o=s=>{const r=s&&s.__ref;if(r&&(t(s,r),r.__children))for(const n of r.__children)o(s[n])};o(e)},st=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let F=0;const Re=Symbol.for("brender.fetchTracked"),we=()=>F,nt=256*1024,rt=1024*1024,ct=new Set(["accept-language","accept"]),xe={renders:0,record:null},it=50,ce={renders:0,record:null},je=(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)}}},ie=e=>e.record&&!e.record.tainted?e.record:null,at=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},ae=(e,t,o)=>{!e||e.tainted||e.failures.length>=it||e.failures.push({url:at(t),reason:o})},ve=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),lt=e=>{const[t,o]=e,s=t&&typeof t=="object"&&typeof t.url=="string",r=ve(t),n=String(o&&o.method||s&&t.method||"GET").toUpperCase(),a={},u=l=>{if(!l)return;const y=!Array.isArray(l)&&typeof l.entries!="function";for(const[f,i]of He(l))y&&i==null||(a[String(f).toLowerCase()]=String(i))};return s&&u(t.headers),o&&u(o.headers),{url:r,method:n,headers:a}},ft=(e,t,o,s)=>{if(!o||!o.ok||typeof o.clone!="function")return;const r=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(r))return;let n;try{n=o.clone()}catch{return}s(n.text().then(a=>{e.tainted||a.length>nt||e.bytes+a.length>rt||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:r,body:a}))},()=>{}))},pt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Re])return;const t=function(...o){F++;let s=!1;const r=()=>{s||(s=!0,F--)},n=i=>{F++,i.then(()=>{F--},()=>{F--})},a=ie(xe),u=ie(ce);let l=null;if(a)try{l=lt(o),(l.method!=="GET"||!/^https?:/i.test(l.url)||Object.keys(l.headers).some(i=>!ct.has(i)))&&(l=null)}catch{l=null}const y=()=>ve(o[0]);let f;try{f=e.apply(this,o)}catch(i){throw ae(u,y(),i&&i.message||"failed"),r(),i}return f&&typeof f.then=="function"?f.then(i=>{l&&ft(a,l,i,n),u&&i&&i.ok===!1&&ae(u,y(),"HTTP "+i.status),r()},i=>{ae(u,y(),i&&i.message||"network error"),r()}):r(),f};t[Re]=!0,globalThis.fetch=t},eo=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const s=Ue(e);return o?`<script>window.__BR_REGISTRY__=${s};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
|
|
2
|
+
`+Ge(t):""):`<script>window.__BR_REGISTRY__=${s}<\/script>`},_e=async(e,t={})=>{const{route:o="/",pathname:s,state:r,context:n,prefetch:a=!1}=t,u=s||o;pt();const l=je(ce,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await ut(e,{route:o,locationPath:u,stateOverrides:r,contextOverrides:n,prefetch:a},l.record)}finally{l.close()}},ut=async(e,{route:t,locationPath:o,stateOverrides:s,contextOverrides:r,prefetch:n},a)=>{let u;if(n)try{u=await Ne(e)}catch(c){console.warn("[brender] SSR translation fetch failed:",c.message)}const{window:l,document:y}=ue(),f=y.body;l.location.pathname=o;const i=[ee("document",y),ee("location",l.location),ee("localStorage",l.localStorage),ee("sessionStorage",l.sessionStorage)];try{const{createDomqlElement:c}=await et(),d=_(e.app||{}),p={...e.config||{}};e.polyglot&&!p.polyglot&&(p.polyglot=e.polyglot),e.fetch&&!p.fetch&&(p.fetch=e.fetch),e.router&&!p.router&&(p.router=e.router);for(const S of yt)e[S]!=null&&p[S]==null&&(p[S]=e[S]);const h=p.polyglot?{...p.polyglot}:void 0;u&&h&&(h.translations={...h.translations||{},...u});const g=_(e.state||{});(u||h)&&(g.root||(g.root={}),h&&(g.root.lang=U(g.root.lang,h)),u&&(g.root.translations={...g.root.translations||{},...u})),Ve();const A={};for(const S in e){if(st.has(S))continue;const R=e[S];A[S]=R&&typeof R=="object"?_(R):R}const T={...A,state:g,...s?{state:{...g,...s}}:{},dependencies:_(e.dependencies||{}),components:_(e.components||{}),snippets:_(e.snippets||{}),pages:_(e.pages||{}),functions:{...e.functions||{},polyglot:Xe,getActiveLang:ye,getLang:ye},methods:e.methods||{},designSystem:_(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...p,...h?{polyglot:h}:{},document:y,window:l,parent:{node:f},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,isolateDesignSystem:!0,isolateFetchCache:!0,...r||{}},B=await ze();B&&(T.plugins=T.plugins||[],T.plugins.some(S=>S.name==="funcql")||T.plugins.push(B)),de();const I=je(xe,()=>({entries:[],bytes:0,tainted:!1})),O=I.record;let j;try{j=await c(d,T);const S=Date.now(),R=n?2e3:50,L=M=>new Promise(J=>setTimeout(J,M));for(await L(Math.min(50,R));n&&we()>0&&Date.now()-S<R;)await L(10),we()===0&&await L(Math.max(0,Math.min(50,R-(Date.now()-S))))}finally{I.close()}const Y=O&&!O.tainted?O.entries.slice():[];me(f);const V=ge(j),{elementPath:q}=await import("@symbo.ls/element"),K=ot(j,q),N=se(e,t,j,j?.state),v=[],C=y.head||y.querySelector("head");if(C)for(const S of C.querySelectorAll("style")){if(S.sheet&&S.sheet.cssRules)for(const R of S.sheet.cssRules)R.cssText&&v.push(R);if(!v.length){const R=S.textContent||"";R&&v.push({cssText:R})}}const D=v.map(S=>S.cssText),{globalCSS:X,classRules:pe}=Rt(v);let k=Le(f.innerHTML);const w=j?.state?.root,E=ne(w,h),G=dt(u,w);G&&(k=Te(k,Ee(G,E,h)));const H=a&&!a.tainted?{failedRequests:a.failures.slice(),rawLabelKeys:ht(a.labelKeys,k,E,h,w)}:null;return{html:k,metadata:N,registry:V,brRegistry:K,element:j,emotionCSS:D,globalCSS:X,classRules:pe,fetchSeed:Y,document:y,window:l,ssrTranslations:G||void 0,activeLang:E,diagnostics:H}}finally{for(const c of i)c()}},ee=(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]})},le=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,fe=e=>e&&typeof e.parse=="function"?e.parse():e,dt=(e,t)=>{const o=fe(t?.translations),s={};for(const r of[e,o])if(!(!r||typeof r!="object"))for(const n in r){const a=fe(r[n]);a&&typeof a=="object"&&(s[n]={...s[n]||{},...a})}return Object.keys(s).length?s:null},Ee=(e,t,o)=>e[t]||e[U(void 0,o)]||Object.values(e)[0]||{},Te=(e,t)=>e.replace(le,(o,s)=>Q(t,s.trim())??o),mt=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,gt=(e,t)=>new RegExp(`(?:^|[^\\w.-])${We(t)}(?![\\w-]|\\.\\w)`).test(e),ht=(e,t,o,s,r)=>{const n=new Set,a=t.replace(mt,"");for(const u of e)/\s/.test(u)||he(u,o,s,r)===void 0&>(a,u)&&n.add(u);for(const u of a.matchAll(le))n.add(u[1].trim());return[...n]},to=async(e,t={})=>{const{context:o={}}=t,{window:s,document:r}=ue(),n=r.body,{create:a}=await import("@symbo.ls/element"),u=await import("@symbo.ls/utils"),l={...tt,...o.components||{}},y={...u,...o.utils||{},...o.functions||{}};de();let f;try{f=a(e,{node:n},"root",{context:{document:r,window:s,...o,components:l,utils:y}})}catch{}me(n);const i=f?ge(f):{};return{html:Le(n.innerHTML),registry:i,element:f}},Le=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,s,r)=>{if(s.includes("<")){const n=s.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'");return o+n+r}return t}),yt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],bt=/\.[A-Za-z_\\-]/,St=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!bt.test(t)},kt=/^\s*(:root|\[data-theme|\[data-skin)/,$e=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 St(e.selectorText)?kt.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 s=new Set(o.map($e));return s.has(null)||s.size!==1?s.has(null)?null:"reset":[...s][0]}return null},Rt=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const s of e||[]){const r=$e(s);r?t[r].push(s.cssText):s&&s.cssText&&o.push(s.cssText)}return{globalCSS:{rootRule:t.root.join(`
|
|
3
|
+
`),resetRules:t.reset.join(`
|
|
4
|
+
`),keyframeRules:t.keyframes.join(`
|
|
5
|
+
`),fontFaceCSS:""},classRules:o}};let te=new Set;const oo=()=>{te=new Set},so=()=>Array.from(te).join(`
|
|
6
|
+
`),no=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
|
|
7
|
+
${t}
|
|
8
|
+
</style>`:""),ro=async(e,t={})=>{const{route:o="/",pathname:s,prefetch:r=!0}=t,n=await _e(e,{route:o,pathname:s,prefetch:r});if(!n)return null;const a=e.designSystem||{},u=n.globalCSS;let l=null;try{const f=wt(n.element);Object.keys(f).length&&(l=f)}catch{}const y=n.activeLang;return{html:n.html,css:n.classRules.join(`
|
|
9
|
+
`),classRules:n.classRules.slice(),globalCSS:u,resetCss:u.resetRules,fontLinks:qe(a),metadata:n.metadata||se(e,o),brKeyCount:n.registry?Object.keys(n.registry).length:0,brRegistry:n.brRegistry||{},fetchSeed:n.fetchSeed||[],ssrTranslations:n.ssrTranslations,prefetchedState:l,activeLang:y,diagnostics:n.diagnostics}},wt=e=>{const t={};return ke(e,o=>{const s=o.fetch;if(!(!s||typeof s!="object"||!o.state))for(const r of Array.isArray(s)?s:[s]){const n=r&&typeof r=="object"&&typeof r.as=="string"?r.as:null;if(!n)continue;const a=n.startsWith("~/"),u=a?n.slice(2):n,l=a?o.state.root:o.state,y=fe(l&&l[u]);u&&y!=null&&typeof y!="function"&&(t[u]=y)}}),t},co=async(e,t="/",o={})=>{const{lang:s,themeColor:r,isr:n,hydrate:a=!0,prefetch:u=!0,shell:l,adoptDom:y=!1,pathname:f,eagerImages:i=Ae,preloadScripts:c=!0,nonce:d}=o,p=Et(d),h=s||e.state?.lang||e.app?.metadata?.lang||"en",g=await _e(e,{route:t,pathname:f,prefetch:u});if(!g)return null;const A={...g.metadata};if(r&&(A["theme-color"]=r),typeof l=="string"&&!e.name){const k="\0brender-undeclared-title\0";if(se({...e,name:k},t,g.element,g.element?.state).title===k)for(const E of["title","og:title","twitter:title"])A[E]===g.metadata.title&&delete A[E]}const T=Be(A);for(const k of g.classRules)k&&te.add(k);const B=Array.from(te).join(`
|
|
10
|
+
`),I=g.globalCSS,O=`<style data-brender>
|
|
11
|
+
${I.rootRule||""}
|
|
12
|
+
${I.resetRules||""}
|
|
13
|
+
${I.keyframeRules||""}
|
|
14
|
+
</style>`,j=B?`<style data-emotion="smbls">
|
|
15
|
+
${B}
|
|
16
|
+
</style>`:"",Y=qe(e.designSystem||{}),V=Object.keys(g.registry).length,q=_t({brRegistry:g.brRegistry,fetchSeed:g.fetchSeed,adoptDom:y});let K="";if(n&&n.clientScript){const k=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,w=k>0?"../".repeat(k):"./";if(a){let E="";if(g.ssrTranslations){const H=e.polyglot||e.config?.polyglot,S=H?.storagePrefix||"",R=H?.storageLangKey||"",L=[];for(const M in g.ssrTranslations){const J=g.ssrTranslations[M];J&&typeof J=="object"&&L.push(`localStorage.setItem(${JSON.stringify(S+M)},${JSON.stringify(JSON.stringify(J))})`)}if(R){const M=U(void 0,H);L.push(`if(!localStorage.getItem(${JSON.stringify(R)}))localStorage.setItem(${JSON.stringify(R)},${JSON.stringify(M)})`)}L.length&&(E=`<script${p}>try{${L.join(";")}}catch(e){}<\/script>
|
|
17
|
+
`)}const G=q.blocks?q.blocks+`
|
|
18
|
+
`:"";K=`${E}${G}<script type="module" src="${w}${n.clientScript}"${p}><\/script>`}else K=`<script type="module"${p}>
|
|
23
19
|
{
|
|
24
20
|
const brEls = document.querySelectorAll('body > :not(script):not(style)')
|
|
25
21
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -36,36 +32,22 @@ ${e}
|
|
|
36
32
|
observer.observe(document.body, { childList: true })
|
|
37
33
|
}
|
|
38
34
|
<\/script>
|
|
39
|
-
<script type="module" src="${
|
|
40
|
-
${
|
|
41
|
-
|
|
42
|
-
${
|
|
43
|
-
</style>`,S?`<style data-emotion="smbls">
|
|
44
|
-
${S}
|
|
45
|
-
</style>`:""];return{html:Bt(r,{headTags:W,headEnd:[R,...k].filter(Boolean).join(`
|
|
46
|
-
`),body:l.html,depth:Number.isInteger(n.depth)?n.depth:0,bootScripts:s?ct(l):""}),route:e,brKeyCount:E,shell:!0}}return{html:`<!DOCTYPE html>
|
|
47
|
-
<html lang="${f}">
|
|
35
|
+
<script type="module" src="${w}${n.clientScript}"${p}><\/script>`}const N={...e.config||{}};e.polyglot&&!N.polyglot&&(N.polyglot=e.polyglot);const v=N.polyglot;let C=T;if(v){const k={...v.translations||{}};for(const w in g.ssrTranslations||{})k[w]={...k[w]||{},...g.ssrTranslations[w]};C=Te(T,Ee(k,g.activeLang,v))}const D=g.diagnostics;if(D)for(const k of C.matchAll(le)){const w=k[1].trim();D.rawLabelKeys.includes(w)||D.rawLabelKeys.push(w)}const X=vt(g.html,i);return typeof l=="string"?{html:Ke(l,{headTags:`${C}
|
|
36
|
+
${q.meta}`,headEnd:[Y,O,j].filter(Boolean).join(`
|
|
37
|
+
`),body:X,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:q.blocks,lang:s||(v?g.activeLang:void 0),preloadScripts:c}),route:t,brKeyCount:V,shell:!0,diagnostics:D}:{html:`<!DOCTYPE html>
|
|
38
|
+
<html lang="${h}">
|
|
48
39
|
<head>
|
|
49
|
-
${
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
|
|
53
|
-
${
|
|
54
|
-
${
|
|
55
|
-
${m.keyframeRules||""}
|
|
56
|
-
</style>
|
|
57
|
-
${S?`<style data-emotion="smbls">
|
|
58
|
-
${S}
|
|
59
|
-
</style>`:""}
|
|
40
|
+
${C}${n&&n.clientScript&&a?`
|
|
41
|
+
${q.meta}`:""}
|
|
42
|
+
${Y}
|
|
43
|
+
|
|
44
|
+
${O}
|
|
45
|
+
${j}
|
|
60
46
|
</head>
|
|
61
47
|
<body>
|
|
62
|
-
${
|
|
63
|
-
${
|
|
48
|
+
${X}
|
|
49
|
+
${K}
|
|
64
50
|
</body>
|
|
65
|
-
</html>`,route:
|
|
66
|
-
`)
|
|
67
|
-
`);
|
|
68
|
-
${l}
|
|
69
|
-
}`)}return[...r,...i].join(`
|
|
70
|
-
`)},Lt=t=>{if(!t)return"";const e=t.font_family||t.fontFamily||{},n=new Set;for(const i of Object.values(e)){if(typeof i!="string")continue;const c=i.match(/'([^']+)'/);c&&n.add(c[1])}return n.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...n].map(i=>`family=${i.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
|
|
71
|
-
`):""};export{gt as SMBLS_SSR_SPECIFIER,ct as adoptionScripts,Be as getAccumulatedEmotionCSS,wt as render,ve as renderElement,We as renderPage,Ne as renderRoute,Fe as replaceEmotionCSS,Me as resetGlobalCSSCache,De as skinRulesToCSS,ie as splitCapturedCSS};
|
|
51
|
+
</html>`,route:t,brKeyCount:V,diagnostics:D}},Ae=2,xt=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,jt=/\sloading\s*=/i,vt=(e,t=Ae)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let s=0;return e.replace(xt,r=>s++<o||jt.test(r)?r:r.replace(/^<img\b/i,'<img loading="lazy"'))},qe=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const r of Object.values(t)){if(typeof r!="string")continue;const n=r.match(/'([^']+)'/);n&&o.add(n[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(`
|
|
52
|
+
`):""},_t=({brRegistry:e,fetchSeed:t,adoptDom:o=!1}={})=>{const s=o&&e&&Object.keys(e).length?Je(e):"",r=Ye(t);return{meta:`<meta name="brender" content="${s?"hydrate":"replace"}">`,blocks:[s,r].filter(Boolean).join(`
|
|
53
|
+
`)}},Et=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{Ae as EAGER_IMAGES_DEFAULT,Se as SMBLS_SSR_SPECIFIER,eo as adoptionScripts,so as getAccumulatedEmotionCSS,vt as markLazyImages,_t as prerenderParts,_e as render,to as renderElement,co as renderPage,ro as renderRoute,no as replaceEmotionCSS,oo as resetGlobalCSSCache,Rt as splitCapturedCSS};
|
package/dist/esm/shell.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
${t}
|
|
3
|
-
${
|
|
4
|
-
`:"",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const I=/<head(\s[^>]*)?>/i,P=/<body(\s[^>]*)?>/i,f=(e,n)=>{const t=new RegExp(`\\s${n}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);return t?t[2]??t[3]??t[4]??"":null},S=e=>{const n=e.slice(0,12).toLowerCase();if(n.startsWith("<title"))return"title";if(n.startsWith("<meta")){if(f(e,"charset")!==null)return"charset";for(const t of["name","property","http-equiv","itemprop"]){const r=f(e,t);if(r!==null)return`${t}:${r.toLowerCase()}`}return null}if(n.startsWith("<link")){const t=(f(e,"rel")||"").toLowerCase();return t==="canonical"?"link:canonical":t==="icon"||t==="shortcut icon"?`link:${t}:${f(e,"href")||""}`:t==="alternate"&&f(e,"hreflang")!==null?`link:alternate:${(f(e,"hreflang")||"").toLowerCase()}`:null}return null},v=/<title[^>]*>[\s\S]*?<\/title\s*>|<meta\b[^>]*>|<link\b[^>]*>/gi,_=/<(script|style|noscript|template|textarea)\b[\s\S]*?<\/\1\s*>/gi,x=e=>[...e.matchAll(_)].map(n=>[n.index,n.index+n[0].length,n[0]]),L=(e,n,t=r=>r)=>{let r="",i=0;for(const[o,l,a]of x(e))r+=n(e.slice(i,o))+t(a),i=l;return r+n(e.slice(i))},d=(e,n,t=0)=>{const r=x(e),i=new RegExp(n.source,n.flags.includes("g")?n.flags:n.flags+"g");i.lastIndex=t;let o;for(;o=i.exec(e);){const l=o.index,a=r.find(([s,u])=>l>s&&l<u);if(!a)return o;i.lastIndex=a[1]}return null},j=e=>!!e&&!/^(?:[a-z][a-z0-9+.-]*:|\/|#|\?)/i.test(e),E=(e,n)=>e.replace(/(\s(?:src|href)\s*=\s*)(?:(["'])([^"']*)\2|([^\s"'>]+))/gi,(t,r,i,o,l)=>{const a=i?o:l;if(!j(a))return t;const s=i||"";return`${r}${s}${n}${a.replace(/^\.\//,"")}${s}`}),q=(e,n)=>{if(!n)return e;const t="../".repeat(n);return L(e,r=>r.replace(/<link\b[^>]*>/gi,i=>E(i,t)),r=>/^<script\b/i.test(r)?r.replace(/^<script\b[^>]*>/i,i=>E(i,t)):r)},W=new Set(["","module","text/javascript","application/javascript"]),m=(e,n)=>new RegExp(`\\s${n}(?:\\s*=|\\s|>|/)`,"i").test(e),B=e=>{const n=[],t=new Set;for(const[,,r]of x(e)){if(!/^<script\b/i.test(r))continue;const i=r.slice(0,r.indexOf(">")+1),o=f(i,"src");if(!o||t.has(o))continue;const l=(f(i,"type")||"").trim().toLowerCase();if(!W.has(l)||m(i,"async")||m(i,"nomodule"))continue;t.add(o);const a=["crossorigin","integrity","referrerpolicy"].map(u=>{const h=f(i,u);return h===null?m(i,u)?` ${u}`:"":` ${u}="${h.replace(/"/g,""")}"`}).join(""),s=o.replace(/"/g,""");n.push(l==="module"?`<link rel="modulepreload" href="${s}" fetchpriority="high"${a}>`:`<link rel="preload" as="script" href="${s}" fetchpriority="high"${a}>`)}return n.join(`
|
|
2
|
+
`)},D=(e,n)=>{const t=d(e,/<html(\s[^>]*)?>/i);if(!t)return e;const r=t[0],i=String(n).replace(/"/g,"""),o=f(r,"lang")!==null?r.replace(/(\slang\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s>]+)/i,`$1"${i}"`):r.replace(/^<html/i,`<html lang="${i}"`);return e.slice(0,t.index)+o+e.slice(t.index+r.length)},H=(e,{headTags:n="",headEnd:t="",body:r="",depth:i=0,bootScripts:o="",lang:l,preloadScripts:a=!1}={})=>{if(typeof e!="string"||!e.trim())throw new Error("brender: the shell document is empty");let s=q(e,i);l&&(s=D(s,l));const u=a?B(s):"";u&&(t=t?`${u}
|
|
3
|
+
${t}`:u);const h=new Set;for(const c of n.matchAll(v)){const p=S(c[0]);p&&h.add(p)}const w=c=>L(c,p=>p.replace(v,R=>h.has(S(R))?"":R)),y=n?`
|
|
4
|
+
${n}`:"",O=t?`
|
|
5
|
+
${t}
|
|
6
|
+
`:"",g=d(s,I),b=g&&d(s,/<\/head\s*>/i,g.index);if(g&&b){const c=g.index+g[0].length,p=b.index;s=s.slice(0,c)+y+w(s.slice(c,p))+O+s.slice(p)}else{s=w(s);const c=d(s,/<html(\s[^>]*)?>/i)||d(s,/<!doctype[^>]*>/i),p=c?c.index+c[0].length:0;s=s.slice(0,p)+y+O+s.slice(p)}const k=`
|
|
7
|
+
${r}
|
|
8
|
+
${o?o+`
|
|
9
|
+
`:""}`,$=d(s,P);if($){const c=$.index+$[0].length;return s.slice(0,c)+k+s.slice(c)}const C=d(s,/<\/(?:body|html)\s*>/i),A=C?C.index:s.length;return s.slice(0,A)+k+s.slice(A)};export{H as composeIntoShell,S as headTagKey,B as scriptPreloads};
|
package/env.js
CHANGED
|
@@ -82,8 +82,14 @@ export const createEnv = (html = '<!DOCTYPE html><html><head></head><body></body
|
|
|
82
82
|
key: (i) => Object.keys(store)[i] ?? null
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
// Every environment gets its own, empty storage. linkedom's window reads an
|
|
86
|
+
// unknown property through to globalThis, so `window.localStorage` found the
|
|
87
|
+
// FIRST environment's store (published on globalThis below) and every later
|
|
88
|
+
// render shared it: polyglot keeps the language a page switched to and the
|
|
89
|
+
// labels it loaded there, and the next page of a build booted with them
|
|
90
|
+
// (xma.info report, brender build item 7 — reset state between renders).
|
|
91
|
+
window.localStorage = createStorage()
|
|
92
|
+
window.sessionStorage = createStorage()
|
|
87
93
|
if (!globalThis.localStorage) globalThis.localStorage = window.localStorage
|
|
88
94
|
if (!globalThis.sessionStorage) globalThis.sessionStorage = window.sessionStorage
|
|
89
95
|
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createEnv } from './env.js'
|
|
2
2
|
import { resetKeys, assignKeys, mapKeysToElements } from './keys.js'
|
|
3
3
|
import { loadProject, loadAndRenderAll } from './load.js'
|
|
4
|
-
import { render, renderElement, renderRoute, renderPage, resetGlobalCSSCache, getAccumulatedEmotionCSS, replaceEmotionCSS, adoptionScripts } from './render.js'
|
|
4
|
+
import { render, renderElement, renderRoute, renderPage, resetGlobalCSSCache, getAccumulatedEmotionCSS, replaceEmotionCSS, adoptionScripts, prerenderParts } from './render.js'
|
|
5
5
|
import { extractMetadata, generateHeadHtml } from './metadata.js'
|
|
6
6
|
import { collectBrNodes, hydrate } from './hydrate.js'
|
|
7
7
|
import { generateSitemap } from './sitemap.js'
|
|
@@ -30,7 +30,8 @@ export {
|
|
|
30
30
|
prefetchPageData,
|
|
31
31
|
injectPrefetchedState,
|
|
32
32
|
composeIntoShell,
|
|
33
|
-
adoptionScripts
|
|
33
|
+
adoptionScripts,
|
|
34
|
+
prerenderParts
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export default {
|
|
@@ -55,5 +56,6 @@ export default {
|
|
|
55
56
|
prefetchPageData,
|
|
56
57
|
injectPrefetchedState,
|
|
57
58
|
composeIntoShell,
|
|
58
|
-
adoptionScripts
|
|
59
|
+
adoptionScripts,
|
|
60
|
+
prerenderParts
|
|
59
61
|
}
|
package/load.js
CHANGED
|
@@ -1,15 +1,51 @@
|
|
|
1
|
-
import { resolve, join } from 'path'
|
|
2
|
-
import { existsSync,
|
|
1
|
+
import { resolve, join, extname, sep } from 'path'
|
|
2
|
+
import { existsSync, readFileSync, unlinkSync } from 'fs'
|
|
3
3
|
import { tmpdir } from 'os'
|
|
4
4
|
import { randomBytes } from 'crypto'
|
|
5
|
+
import { pathToFileURL } from 'url'
|
|
6
|
+
|
|
7
|
+
// ── import.meta.url in project code ─────────────────────────────────────────
|
|
8
|
+
// `new URL('../../assets/fonts/x.woff2', import.meta.url)` is how a project
|
|
9
|
+
// names a file next to its source; the bundler turns it into the built
|
|
10
|
+
// asset's address. Bundled into ONE temp module here, every project file's
|
|
11
|
+
// `import.meta.url` became that temp file's, so the URL pointed into the
|
|
12
|
+
// build machine's temp folder — every pre-rendered @font-face read
|
|
13
|
+
// `file:///var/folders/…`, the page drew a fallback font, then shifted (CLS
|
|
14
|
+
// 0.40; xma.info report, brender build item 6). Each project file (anything
|
|
15
|
+
// outside node_modules) gets its OWN source address instead: the URL then
|
|
16
|
+
// names the real source file, which a build maps to its output (the CLI's
|
|
17
|
+
// brenderAssets) and refuses to ship as a file: URL.
|
|
18
|
+
const IMPORT_META_URL = /\bimport\.meta\.url\b/g
|
|
19
|
+
const HAS_IMPORT_META_URL = /\bimport\.meta\.url\b/
|
|
20
|
+
const LOADERS = { '.js': 'js', '.mjs': 'js', '.cjs': 'js', '.jsx': 'jsx', '.ts': 'ts', '.mts': 'ts', '.tsx': 'tsx' }
|
|
21
|
+
|
|
22
|
+
export const sourceUrlPlugin = {
|
|
23
|
+
name: 'brender-source-import-meta-url',
|
|
24
|
+
setup (build) {
|
|
25
|
+
build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, (args) => {
|
|
26
|
+
if (args.path.includes(`${sep}node_modules${sep}`)) return
|
|
27
|
+
const contents = readFileSync(args.path, 'utf8')
|
|
28
|
+
if (!HAS_IMPORT_META_URL.test(contents)) return
|
|
29
|
+
const url = JSON.stringify(pathToFileURL(args.path).href)
|
|
30
|
+
return {
|
|
31
|
+
contents: `const __brenderImportMetaUrl = ${url};\n` + contents.replace(IMPORT_META_URL, '__brenderImportMetaUrl'),
|
|
32
|
+
loader: LOADERS[extname(args.path)] || 'js'
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
5
37
|
|
|
6
38
|
/**
|
|
7
39
|
* Bundles a module entry point with esbuild so that extensionless imports,
|
|
8
40
|
* bare specifiers, and other bundler conventions resolve correctly.
|
|
9
|
-
* Returns the default + named exports of the bundled module, or null on failure
|
|
41
|
+
* Returns the default + named exports of the bundled module, or null on failure
|
|
42
|
+
* (or, with `strict`, throws what went wrong).
|
|
10
43
|
*/
|
|
11
|
-
const bundleAndImport = async (entryPath) => {
|
|
12
|
-
if (!existsSync(entryPath))
|
|
44
|
+
const bundleAndImport = async (entryPath, { strict = false } = {}) => {
|
|
45
|
+
if (!existsSync(entryPath)) {
|
|
46
|
+
if (strict) throw new Error(`${entryPath} does not exist`)
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
13
49
|
|
|
14
50
|
let esbuild
|
|
15
51
|
try {
|
|
@@ -30,20 +66,69 @@ const bundleAndImport = async (entryPath) => {
|
|
|
30
66
|
outfile: outFile,
|
|
31
67
|
write: true,
|
|
32
68
|
logLevel: 'silent',
|
|
69
|
+
plugins: [sourceUrlPlugin],
|
|
33
70
|
// Mark node builtins as external
|
|
34
71
|
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'],
|
|
35
72
|
})
|
|
36
73
|
|
|
37
74
|
const mod = await import(`file://${outFile}`)
|
|
38
75
|
return mod
|
|
39
|
-
} catch {
|
|
76
|
+
} catch (err) {
|
|
40
77
|
// Fallback: try raw import
|
|
41
|
-
try { return await import(entryPath) } catch {
|
|
78
|
+
try { return await import(entryPath) } catch (rawErr) { // fallback: module not found via this resolver, trying next
|
|
79
|
+
if (strict) throw err
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
42
82
|
} finally {
|
|
43
83
|
try { unlinkSync(outFile) } catch {} // cleanup: ignore if temp file already removed
|
|
44
84
|
}
|
|
45
85
|
}
|
|
46
86
|
|
|
87
|
+
// A project's own context module (`context`): the object its entry hands to
|
|
88
|
+
// `create(app, context)` — `{ state, components, pages, functions,
|
|
89
|
+
// designSystem, files, sharedLibraries, ...config }`. The build's entry is
|
|
90
|
+
// what decides which pages a site has; a project whose public entry boots a
|
|
91
|
+
// smaller context than symbols/pages/index.js (xma.info: `siteContext.js`,
|
|
92
|
+
// no admin pages) got every page pre-rendered, admin ones included (xma.info
|
|
93
|
+
// report, brender build item 10). Its keys are spread into plain objects (a
|
|
94
|
+
// module namespace is not extensible); config keys stay at the top level,
|
|
95
|
+
// where render() reads them, as in a frank payload.
|
|
96
|
+
const CONTEXT_OBJECT_KEYS = ['state', 'dependencies', 'components', 'snippets', 'pages', 'functions', 'methods', 'designSystem', 'files', 'assets']
|
|
97
|
+
|
|
98
|
+
const loadContextModule = async (projectPath, contextPath) => {
|
|
99
|
+
const entry = resolve(projectPath, contextPath)
|
|
100
|
+
let mod
|
|
101
|
+
try {
|
|
102
|
+
mod = await bundleAndImport(entry, { strict: true })
|
|
103
|
+
} catch (err) {
|
|
104
|
+
throw new Error(`brender: cannot load the context module ${contextPath} (${err.message})`)
|
|
105
|
+
}
|
|
106
|
+
const context = mod && (mod.default || mod)
|
|
107
|
+
if (!context || typeof context !== 'object') {
|
|
108
|
+
throw new Error(`brender: the context module ${contextPath} has no default export object`)
|
|
109
|
+
}
|
|
110
|
+
const out = { ...context }
|
|
111
|
+
for (const key of CONTEXT_OBJECT_KEYS) {
|
|
112
|
+
if (context[key] && typeof context[key] === 'object') out[key] = { ...context[key] }
|
|
113
|
+
}
|
|
114
|
+
out.sharedLibraries = Array.isArray(context.sharedLibraries) ? context.sharedLibraries : []
|
|
115
|
+
return out
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const mergeLibraries = async (result) => {
|
|
119
|
+
// Pre-resolve string library references and merge into context
|
|
120
|
+
// so production builds have zero runtime overhead
|
|
121
|
+
if (result.sharedLibraries.length) {
|
|
122
|
+
const { resolveSharedLibraries, mergeSharedLibraries } = await import('@symbo.ls/utils')
|
|
123
|
+
const hasStrings = result.sharedLibraries.some(lib => typeof lib === 'string')
|
|
124
|
+
if (hasStrings) {
|
|
125
|
+
result.sharedLibraries = await resolveSharedLibraries(result.sharedLibraries)
|
|
126
|
+
}
|
|
127
|
+
mergeSharedLibraries(result, result.sharedLibraries)
|
|
128
|
+
}
|
|
129
|
+
return result
|
|
130
|
+
}
|
|
131
|
+
|
|
47
132
|
/**
|
|
48
133
|
* Loads a Symbols project from a filesystem path.
|
|
49
134
|
* Expects the standard symbols/ directory structure.
|
|
@@ -52,13 +137,28 @@ const bundleAndImport = async (entryPath) => {
|
|
|
52
137
|
* and other bundler conventions work in Node.js.
|
|
53
138
|
*
|
|
54
139
|
* Used for prebuild scenarios where brender runs locally
|
|
55
|
-
* against a project directory (e.g. `smbls build
|
|
140
|
+
* against a project directory (e.g. `smbls build`).
|
|
56
141
|
*
|
|
57
142
|
* For server runtime rendering, pass the project data
|
|
58
143
|
* directly to render() instead.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} projectPath
|
|
146
|
+
* @param {object} [options]
|
|
147
|
+
* @param {string} [options.dir='symbols'] - the symbols directory (symbols.json `dir`)
|
|
148
|
+
* @param {string} [options.context] - a module, relative to `projectPath`,
|
|
149
|
+
* whose default export is the context the build's entry boots with
|
|
150
|
+
* (symbols.json `brender.context`). Everything but `app` comes from it.
|
|
59
151
|
*/
|
|
60
|
-
export const loadProject = async (projectPath) => {
|
|
61
|
-
const symbolsDir = resolve(projectPath, 'symbols')
|
|
152
|
+
export const loadProject = async (projectPath, options = {}) => {
|
|
153
|
+
const symbolsDir = resolve(projectPath, options.dir || 'symbols')
|
|
154
|
+
|
|
155
|
+
if (options.context) {
|
|
156
|
+
const [appModule, context] = await Promise.all([
|
|
157
|
+
bundleAndImport(join(symbolsDir, 'app.js')),
|
|
158
|
+
loadContextModule(projectPath, options.context)
|
|
159
|
+
])
|
|
160
|
+
return mergeLibraries({ app: { ...(appModule?.default || {}) }, ...context })
|
|
161
|
+
}
|
|
62
162
|
|
|
63
163
|
const [
|
|
64
164
|
appModule,
|
|
@@ -108,18 +208,7 @@ export const loadProject = async (projectPath) => {
|
|
|
108
208
|
sharedLibraries: sharedLibsModule?.default || []
|
|
109
209
|
}
|
|
110
210
|
|
|
111
|
-
|
|
112
|
-
// so production builds have zero runtime overhead
|
|
113
|
-
if (result.sharedLibraries.length) {
|
|
114
|
-
const { resolveSharedLibraries, mergeSharedLibraries } = await import('@symbo.ls/utils')
|
|
115
|
-
const hasStrings = result.sharedLibraries.some(lib => typeof lib === 'string')
|
|
116
|
-
if (hasStrings) {
|
|
117
|
-
result.sharedLibraries = await resolveSharedLibraries(result.sharedLibraries)
|
|
118
|
-
}
|
|
119
|
-
mergeSharedLibraries(result, result.sharedLibraries)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return result
|
|
211
|
+
return mergeLibraries(result)
|
|
123
212
|
}
|
|
124
213
|
|
|
125
214
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/brender",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.665",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"prepublishOnly": "npm run build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@symbo.ls/css": "^3.14.
|
|
50
|
-
"@symbo.ls/default-config": "^3.14.
|
|
51
|
-
"@symbo.ls/element": "^3.14.
|
|
52
|
-
"@symbo.ls/fetch": "^3.14.
|
|
53
|
-
"@symbo.ls/helmet": "^3.14.
|
|
54
|
-
"@symbo.ls/scratch": "^3.14.
|
|
55
|
-
"@symbo.ls/utils": "^3.14.
|
|
49
|
+
"@symbo.ls/css": "^3.14.779",
|
|
50
|
+
"@symbo.ls/default-config": "^3.14.787",
|
|
51
|
+
"@symbo.ls/element": "^3.14.805",
|
|
52
|
+
"@symbo.ls/fetch": "^3.14.665",
|
|
53
|
+
"@symbo.ls/helmet": "^3.14.670",
|
|
54
|
+
"@symbo.ls/scratch": "^3.14.789",
|
|
55
|
+
"@symbo.ls/utils": "^3.14.787",
|
|
56
56
|
"esbuild": "^0.28.1",
|
|
57
57
|
"linkedom": "^0.16.8"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"smbls": "^3.14.
|
|
60
|
+
"smbls": "^3.14.838"
|
|
61
61
|
},
|
|
62
62
|
"optionalDependencies": {
|
|
63
63
|
"@symbo.ls/funcql": "^3.14.0"
|