@symbo.ls/brender 3.14.599 → 3.14.656
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 +6 -0
- package/README.md +2 -2
- package/dist/esm/prefetch.js +1 -1
- package/dist/esm/render.js +1 -3
- package/package.json +1 -1
- package/prefetch.js +9 -45
- package/render.js +1 -10
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Browser DOM (static) DOMQL Tree (no nodes) After hydrate()
|
|
|
64
64
|
| `env.js` | `createEnv()` — linkedom virtual DOM with browser API stubs (requestAnimationFrame, history, location, etc.) |
|
|
65
65
|
| `keys.js` | `resetKeys()`, `assignKeys()` — stamps data-br on DOM nodes; `mapKeysToElements()` — builds registry |
|
|
66
66
|
| `metadata.js` | Re-exports from [`@symbo.ls/helmet`](../helmet/) — `extractMetadata()`, `generateHeadHtml()`, `resolveMetadata()`, `applyMetadata()` |
|
|
67
|
-
| `prefetch.js` | `prefetchPageData()` — SSR data prefetching via DB adapter
|
|
67
|
+
| `prefetch.js` | `prefetchPageData()` — SSR data prefetching via DB adapter; `injectPrefetchedState()` — injects fetched data into page definitions |
|
|
68
68
|
| `load.js` | `loadProject()` — imports a symbols/ directory; `loadAndRenderAll()` — renders every route |
|
|
69
69
|
| `sitemap.js` | `generateSitemap()` — generates sitemap.xml from routes |
|
|
70
70
|
| `index.js` | Re-exports everything |
|
|
@@ -138,7 +138,7 @@ const result = await renderPage(data, '/about', {
|
|
|
138
138
|
|
|
139
139
|
### `prefetchPageData(data, route, options?)`
|
|
140
140
|
|
|
141
|
-
Fetches data for a page's declarative `fetch` definitions during SSR, using the project's DB adapter (
|
|
141
|
+
Fetches data for a page's declarative `fetch` definitions during SSR, using the project's DB adapter. (No built-in SSR adapter currently resolves — the Supabase SSR path was removed; client-side fetch owns data loading.)
|
|
142
142
|
|
|
143
143
|
```js
|
|
144
144
|
import { prefetchPageData } from '@symbo.ls/brender'
|
package/dist/esm/prefetch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const h=t=>typeof t=="function",b=t=>Array.isArray(t),y=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),S=(t,r)=>{if(t){if(h(t))try{return t({state:r||{},call:()=>{},__ref:{}},r||{})}catch{return}return t}},_=(t,r)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const n=h(t)?null:{...t};return!n||(n.method||(n.method="select"),h(n.params)&&(n.params=S(n.params,r)),n.method==="insert"||n.method==="update"||n.method==="upsert"||n.method==="delete")||n.on&&n.on!=="create"?null:n},A=(t,r="")=>{if(!t||typeof t!="object")return[];if(h(t))return[];const n=[],s=t.state||{};if(t.fetch){const e=b(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=_(c,s);o&&n.push({config:o,stateKey:o.as,path:r,elementState:s})}}for(const e in t)e==="fetch"||e==="state"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs"||e.charAt(0)>="A"&&e.charAt(0)<="Z"&&y(t[e])&&n.push(...A(t[e],r?`${r}.${e}`:e));return n},w=async t=>null,k=async(t,r)=>{try{const{method:n,from:s,params:e,transform:c,limit:o,offset:i,order:l,single:u}=r;let f;n==="rpc"?f=await t.rpc({from:s,params:e}):f=await t.select({from:s,select:r.select,params:e,limit:o,offset:i,order:l,single:u});let a=f?.data??null;if(f?.error)return null;if(a&&c&&h(c))try{a=c(a)}catch{}return a}catch{return null}},x=async(t,r="/",n={})=>{const e=(t.pages||{})[r];if(!e)return new Map;const c=t.config||t.settings||{},o=c.fetch||t.fetch||c.db||t.db;if(!o)return new Map;const i=await w(o);if(!i)return new Map;const l=A(e);if(!l.length)return new Map;const u=new Map,f=await Promise.allSettled(l.map(async({config:a,stateKey:p,path:m})=>{const g=await k(i,a);if(g!==null){const d=u.get(m)||{};p?d[p]=g:y(g)&&Object.assign(d,g),u.set(m,d)}}));return u},M=async t=>{const r=t.config||{},n=r.polyglot||t.polyglot;if(!n?.fetch)return null;const s=r.fetch||t.fetch||r.db||t.db;if(!s)return null;const e=await w(s);if(!e)return null;const c=n.fetch,o=c.rpc||c.from||"get_translations_if_changed",i=n.languages||[n.defaultLang||"en"],l={},u=await Promise.allSettled(i.map(async f=>{try{const a=await e.rpc({from:o,params:{p_lang:f,p_cached_version:0}});if(a.error||!a.data)return;const p=a.data;p.translations&&(l[f]=p.translations)}catch(a){console.warn("[brender] SSR translation fetch failed:",a.message)}}));return Object.keys(l).length?l:null},j=(t,r)=>{if(!(!t||typeof t!="object")){for(const n in t)if(!(n==="state"||n==="fetch"||n==="props"||n==="attr"||n==="on"||n==="define"||n==="childExtends"||n==="childProps"||n==="childrenAs")&&n.charAt(0)>="A"&&n.charAt(0)<="Z"&&y(t[n])){const s=t[n],e=s.state&&typeof s.state=="object"?{...r,...s.state}:r;if(h(s.children))try{const c={state:e,call:i=>{if(i==="getActiveLang"||i==="getLang")return e?.lang||"ka";if(i==="polyglot")return arguments[1]||""},__ref:{}},o=s.children(c,e);b(o)&&o.length>0&&(s.children=o)}catch{}j(s,e)}}},P=(t,r)=>{if(!(!r||!r.size))for(const[n,s]of r){let e=t;if(n){const c=n.split(".");for(const o of c){if(!e||typeof e!="object")break;e=e[o]}}e&&typeof e=="object"&&((!e.state||typeof e.state!="object")&&(e.state={}),Object.assign(e.state,s),j(e,e.state))}};export{M as fetchSSRTranslations,P as injectPrefetchedState,x as prefetchPageData};
|
package/dist/esm/render.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import{resolve as d,join as tt,dirname as q}from"path";import{existsSync as h,unlinkSync as _t,readFileSync as K,realpathSync as kt}from"fs";import{tmpdir as $t}from"os";import{randomBytes as Ct}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 Tt}from"./metadata.js";import"./hydrate.js";import{prefetchPageData as Ot,injectPrefetchedState as Lt,fetchSSRTranslations as At}from"./prefetch.js";let z=null;const Pt=async()=>{if(z)return z;try{return z=(await import("@symbo.ls/funcql")).funcqlPlugin,z}catch{return null}};import"linkedom";import{reset as It}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},qt=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"},D=(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?D(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?D(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(h(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(h(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(h(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},le=(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},ae=(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(h(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 vt=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=h(c)?c:i}if(!e||!h(e))throw new Error(`brender: cannot find createDomql.js (isMonorepo=${t.isMonorepo}, entry=${e})`);const o=await import("esbuild"),s=tt($t(),`br_createDomql_${Ct(6).toString("hex")}.mjs`),r=c=>{if(!c)return null;const i=d(c,"src","index.js");if(h(i))return i;const n=d(c,"index.js");return h(n)?n:null},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(h(u))return{path:u};if(h(u+".js"))return{path:u+".js"};const a=d(u,"index.js");if(h(a))return{path:a}}),c.onResolve({filter:/^domql$/},i=>{if(t.isMonorepo){const n=d(t.monorepoRoot,"packages","domql","src","index.js");if(h(n))return{path:n};const l=d(t.monorepoRoot,"packages","domql","index.js");if(h(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(h(a))return{path:a};const m=d(t.monorepoRoot,u,n,"index.js");if(h(m))return{path:m}}const l=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(n==="default-config"&&h(l))return{path:l}}else{const l=H(t,n,"src","index.js");if(l&&h(l))return{path:l};const u=H(t,n,"index.js");if(u&&h(u))return{path:u};if(n==="default-config"){const a=H(t,"default-config","blank","index.js");if(a&&h(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(h(l))return{path:l};const u=d(t.monorepoRoot,"packages","domql","packages",n,"index.js");if(h(u))return{path:u}}else{const l=Y(t,n,"src","index.js");if(l&&h(l))return{path:l};const u=Y(t,n,"index.js");if(u&&h(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(h(m))return{path:m};if(h(a+".js"))return{path:a+".js"};if(h(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(h(n)){const l=d(n,"package.json");if(h(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(h(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:/fetch\/adapters\/supabase\.js$/},()=>({contents:`export const setup = async () => null;
|
|
2
|
-
export const supabaseAdapter = () => ({name:'supabase'});
|
|
3
|
-
`,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 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=>h(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},Et={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 b=t.pages||{};l={...b};const E=await Ot(t,o);if(E.size){const V=JSON.parse(JSON.stringify(b[o],(v,B)=>{if(typeof B!="function")return B})),U=(v,B)=>{if(!(!v||!B))for(const M in v)typeof v[M]=="function"?B[M]=v[M]:typeof v[M]=="object"&&v[M]!==null&&!Array.isArray(v[M])&&typeof B[M]=="object"&&B[M]!==null&&U(v[M],B[M])};U(b[o],V),Lt(V,E),l[o]=V}}catch(b){console.error("[brender] Prefetch error:",b),l=t.pages}let u;if(f)try{u=await At(t)}catch(b){console.warn("[brender] SSR translation fetch failed:",b.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 y=globalThis.document,g=globalThis.location;globalThis.document=m,globalThis.location=a.location;const{createDomqlElement:I}=await vt(),L=D(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 b of["useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDefaultConfig","useDocumentTheme"])t[b]!=null&&R[b]==null&&(R[b]=t[b]);const k=R.polyglot?{...R.polyglot}:void 0;u&&k&&(k.translations={...k.translations||{},...u});const O=D(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})),It();const C={state:O,...r?{state:{...O,...r}}:{},dependencies:D(t.dependencies||{}),components:D(t.components||{}),snippets:D(t.snippets||{}),pages:D(l||t.pages||{}),functions:{...t.functions||{},polyglot:qt,getActiveLang:lt,getLang:lt},methods:t.methods||{},designSystem:D(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 Pt();F&&(C.plugins=C.plugins||[],C.plugins.some(b=>b.name==="funcql")||C.plugins.push(F)),st();const A=await I(L,C),w=f?2e3:50;await new Promise(b=>setTimeout(b,w)),rt(_);const $=it(A),S=ut(A),x=ct(t,o,A,A?.state),j=[],T=m.head||m.querySelector("head");if(T)for(const b of T.querySelectorAll("style")){if(b.sheet&&b.sheet.cssRules)for(const E of b.sheet.cssRules)E.cssText&&j.push(E.cssText);if(!j.length){const E=b.textContent||"";E&&j.push(E)}}let P=dt(_.innerHTML);if(u){const b=k?.defaultLang||"en",E=u[b]||Object.values(u)[0]||{};P=P.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(V,U)=>{const v=U.trim();return E[v]??V})}return y!==void 0?globalThis.document=y:delete globalThis.document,g!==void 0?globalThis.location=g:delete globalThis.location,{html:P,metadata:x,registry:$,brRegistry:S,element:A,emotionCSS:j,document:m,window:a,ssrTranslations:u,prefetchedPages:l}},fe=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={...Et,...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 h,unlinkSync as _t,readFileSync as K,realpathSync as kt}from"fs";import{tmpdir as $t}from"os";import{randomBytes as Ct}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 Tt}from"./metadata.js";import"./hydrate.js";import{prefetchPageData as Ot,injectPrefetchedState as Lt,fetchSSRTranslations as At}from"./prefetch.js";let z=null;const Pt=async()=>{if(z)return z;try{return z=(await import("@symbo.ls/funcql")).funcqlPlugin,z}catch{return null}};import"linkedom";import{reset as It}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},qt=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"},D=(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?D(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?D(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(h(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(h(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(h(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},le=(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},ae=(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(h(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 vt=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=h(c)?c:i}if(!e||!h(e))throw new Error(`brender: cannot find createDomql.js (isMonorepo=${t.isMonorepo}, entry=${e})`);const o=await import("esbuild"),s=tt($t(),`br_createDomql_${Ct(6).toString("hex")}.mjs`),r=c=>{if(!c)return null;const i=d(c,"src","index.js");if(h(i))return i;const n=d(c,"index.js");return h(n)?n:null},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(h(u))return{path:u};if(h(u+".js"))return{path:u+".js"};const a=d(u,"index.js");if(h(a))return{path:a}}),c.onResolve({filter:/^domql$/},i=>{if(t.isMonorepo){const n=d(t.monorepoRoot,"packages","domql","src","index.js");if(h(n))return{path:n};const l=d(t.monorepoRoot,"packages","domql","index.js");if(h(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(h(a))return{path:a};const m=d(t.monorepoRoot,u,n,"index.js");if(h(m))return{path:m}}const l=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(n==="default-config"&&h(l))return{path:l}}else{const l=H(t,n,"src","index.js");if(l&&h(l))return{path:l};const u=H(t,n,"index.js");if(u&&h(u))return{path:u};if(n==="default-config"){const a=H(t,"default-config","blank","index.js");if(a&&h(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(h(l))return{path:l};const u=d(t.monorepoRoot,"packages","domql","packages",n,"index.js");if(h(u))return{path:u}}else{const l=Y(t,n,"src","index.js");if(l&&h(l))return{path:l};const u=Y(t,n,"index.js");if(u&&h(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(h(m))return{path:m};if(h(a+".js"))return{path:a+".js"};if(h(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(h(n)){const l=d(n,"package.json");if(h(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(h(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 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=>h(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},Et={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 b=t.pages||{};l={...b};const E=await Ot(t,o);if(E.size){const V=JSON.parse(JSON.stringify(b[o],(v,B)=>{if(typeof B!="function")return B})),U=(v,B)=>{if(!(!v||!B))for(const M in v)typeof v[M]=="function"?B[M]=v[M]:typeof v[M]=="object"&&v[M]!==null&&!Array.isArray(v[M])&&typeof B[M]=="object"&&B[M]!==null&&U(v[M],B[M])};U(b[o],V),Lt(V,E),l[o]=V}}catch(b){console.error("[brender] Prefetch error:",b),l=t.pages}let u;if(f)try{u=await At(t)}catch(b){console.warn("[brender] SSR translation fetch failed:",b.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 y=globalThis.document,g=globalThis.location;globalThis.document=m,globalThis.location=a.location;const{createDomqlElement:I}=await vt(),L=D(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 b of["useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDefaultConfig","useDocumentTheme"])t[b]!=null&&R[b]==null&&(R[b]=t[b]);const k=R.polyglot?{...R.polyglot}:void 0;u&&k&&(k.translations={...k.translations||{},...u});const O=D(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})),It();const C={state:O,...r?{state:{...O,...r}}:{},dependencies:D(t.dependencies||{}),components:D(t.components||{}),snippets:D(t.snippets||{}),pages:D(l||t.pages||{}),functions:{...t.functions||{},polyglot:qt,getActiveLang:lt,getLang:lt},methods:t.methods||{},designSystem:D(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 Pt();F&&(C.plugins=C.plugins||[],C.plugins.some(b=>b.name==="funcql")||C.plugins.push(F)),st();const A=await I(L,C),w=f?2e3:50;await new Promise(b=>setTimeout(b,w)),rt(_);const $=it(A),S=ut(A),x=ct(t,o,A,A?.state),j=[],T=m.head||m.querySelector("head");if(T)for(const b of T.querySelectorAll("style")){if(b.sheet&&b.sheet.cssRules)for(const E of b.sheet.cssRules)E.cssText&&j.push(E.cssText);if(!j.length){const E=b.textContent||"";E&&j.push(E)}}let P=dt(_.innerHTML);if(u){const b=k?.defaultLang||"en",E=u[b]||Object.values(u)[0]||{};P=P.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(V,U)=>{const v=U.trim();return E[v]??V})}return y!==void 0?globalThis.document=y:delete globalThis.document,g!==void 0?globalThis.location=g:delete globalThis.location,{html:P,metadata:x,registry:$,brRegistry:S,element:A,emotionCSS:j,document:m,window:a,ssrTranslations:u,prefetchedPages:l}},fe=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={...Et,...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,`
|
|
4
2
|
import { set, getActiveConfig, getFontFaceString } from '@symbo.ls/scratch'
|
|
5
3
|
import { DEFAULT_CONFIG } from '@symbo.ls/default-config'
|
|
6
4
|
|
package/package.json
CHANGED
package/prefetch.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* SSR data prefetching for brender.
|
|
3
3
|
*
|
|
4
4
|
* Walks a page definition tree, collects `fetch` declarations,
|
|
5
|
-
* executes them against the configured DB adapter
|
|
5
|
+
* executes them against the configured DB adapter,
|
|
6
6
|
* and returns the fetched data keyed by element path + `as` field.
|
|
7
7
|
*
|
|
8
8
|
* This allows brender to inject fetched data into element state
|
|
@@ -106,53 +106,17 @@ const collectFetchDeclarations = (def, path = '') => {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* Create
|
|
109
|
+
* Create an SSR adapter from project config.
|
|
110
|
+
*
|
|
111
|
+
* The Supabase SSR code path was removed — the SDK adapter is the only
|
|
112
|
+
* backend transport now, and it has no server-side client here yet. Until
|
|
113
|
+
* an SDK-backed SSR adapter exists, no built-in adapter resolves: callers
|
|
114
|
+
* get null, skip prefetch, and the client-side fetch plugin owns data
|
|
115
|
+
* loading after hydration.
|
|
110
116
|
*/
|
|
111
117
|
const createSSRAdapter = async (dbConfig) => {
|
|
112
118
|
if (!dbConfig) return null
|
|
113
|
-
|
|
114
|
-
const { adapter, createClient, url, key, projectId } = dbConfig
|
|
115
|
-
if (adapter !== 'supabase') return null
|
|
116
|
-
|
|
117
|
-
const supabaseUrl = url || (projectId && `https://${projectId}.supabase.co`)
|
|
118
|
-
if (!supabaseUrl || !key) return null
|
|
119
|
-
|
|
120
|
-
// Always import @supabase/supabase-js for SSR — the serialized createClient
|
|
121
|
-
// from project data is a no-op placeholder that won't produce a real client.
|
|
122
|
-
let clientFactory
|
|
123
|
-
try {
|
|
124
|
-
const mod = await import('@supabase/supabase-js')
|
|
125
|
-
clientFactory = mod.createClient
|
|
126
|
-
} catch {
|
|
127
|
-
// Fall back to provided createClient only if import fails
|
|
128
|
-
clientFactory = createClient
|
|
129
|
-
}
|
|
130
|
-
if (!clientFactory) return null
|
|
131
|
-
|
|
132
|
-
const client = clientFactory(supabaseUrl, key)
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
rpc: ({ from, params }) => client.rpc(from, params),
|
|
136
|
-
select: async ({ from, select: sel, params, limit, offset, order, single }) => {
|
|
137
|
-
let q = client.from(from).select(sel || '*')
|
|
138
|
-
if (params) {
|
|
139
|
-
for (const k in params) {
|
|
140
|
-
const v = params[k]
|
|
141
|
-
if (v === null) q = q.is(k, null)
|
|
142
|
-
else if (Array.isArray(v)) q = q.in(k, v)
|
|
143
|
-
else q = q.eq(k, v)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (order) {
|
|
147
|
-
const orderBy = typeof order === 'string' ? order : order.by
|
|
148
|
-
q = q.order(orderBy, { ascending: order.asc !== false })
|
|
149
|
-
}
|
|
150
|
-
if (limit) q = q.limit(limit)
|
|
151
|
-
if (offset) q = q.range(offset, offset + (limit || 20) - 1)
|
|
152
|
-
if (single) q = q.single()
|
|
153
|
-
return q
|
|
154
|
-
}
|
|
155
|
-
}
|
|
119
|
+
return null
|
|
156
120
|
}
|
|
157
121
|
|
|
158
122
|
/**
|
package/render.js
CHANGED
|
@@ -459,15 +459,6 @@ const bundleCreateDomql = async () => {
|
|
|
459
459
|
)
|
|
460
460
|
return { contents, loader: 'js' }
|
|
461
461
|
})
|
|
462
|
-
// Stub the Supabase adapter during brender — the prefetch system handles
|
|
463
|
-
// data fetching separately via its own Supabase client. The DOMQL fetch
|
|
464
|
-
// plugin's on.create handler shouldn't fire during SSR.
|
|
465
|
-
build.onLoad({ filter: /fetch\/adapters\/supabase\.js$/ }, () => {
|
|
466
|
-
return {
|
|
467
|
-
contents: `export const setup = async () => null;\nexport const supabaseAdapter = () => ({name:'supabase'});\n`,
|
|
468
|
-
loader: 'js'
|
|
469
|
-
}
|
|
470
|
-
})
|
|
471
462
|
// No-op: globals.js keeps window = globalThis
|
|
472
463
|
// We set globalThis.document/location before import to make it SSR-safe
|
|
473
464
|
// Stub loader for brender-stub namespace (used for @symbo.ls/sync etc.)
|
|
@@ -1012,7 +1003,7 @@ const generateGlobalCSS = async (ds, config) => {
|
|
|
1012
1003
|
// Write a temporary script that imports scratch, runs set(), and
|
|
1013
1004
|
// serialises the CSS_VARS + RESET objects as JSON.
|
|
1014
1005
|
const dsJson = JSON.stringify(ds || {}, safeJsonReplacer())
|
|
1015
|
-
// Config may contain non-serializable values (e.g.
|
|
1006
|
+
// Config may contain non-serializable values (e.g. a DB client with
|
|
1016
1007
|
// circular refs, functions). Strip those for the CSS generation script.
|
|
1017
1008
|
const cfgJson = JSON.stringify(config || {}, safeJsonReplacer())
|
|
1018
1009
|
const tmpEntry = join(tmpdir(), `br_global_${randomBytes(6).toString('hex')}.mjs`)
|