@symbo.ls/brender 3.14.599 → 3.14.657
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/packageEntry.js +1 -0
- package/dist/esm/prefetch.js +1 -1
- package/dist/esm/render.js +20 -22
- package/package.json +1 -1
- package/packageEntry.js +31 -0
- package/prefetch.js +9 -45
- package/render.js +3 -19
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'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"path";import{existsSync as s}from"fs";const c=r=>{if(!r)return null;const t=e(r,"index.js");if(s(t))return t;const n=e(r,"src","index.js");return s(n)?n:null};export{c as resolvePackageEntry};
|
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 b,unlinkSync as _t,readFileSync as K,realpathSync as kt}from"fs";import{resolvePackageEntry as $t}from"./packageEntry.js";import{tmpdir as Ct}from"os";import{randomBytes as Tt}from"crypto";import{createRequire as et}from"module";import{createEnv as nt}from"./env.js";import{resetKeys as st,assignKeys as rt,mapKeysToElements as it}from"./keys.js";import{extractMetadata as ct,generateHeadHtml as Ot}from"./metadata.js";import"./hydrate.js";import{prefetchPageData as Lt,injectPrefetchedState as At,fetchSSRTranslations as Pt}from"./prefetch.js";let z=null;const It=async()=>{if(z)return z;try{return z=(await import("@symbo.ls/funcql")).funcqlPlugin,z}catch{return null}};import"linkedom";import{reset as qt}from"@symbo.ls/css";const ot=(t,e)=>{if(!t||!e)return;if(t[e]!==void 0)return t[e];const o=e.split(".");let s=t;for(const r of o){if(s==null||typeof s!="object")return;s=s[r]}return s},vt=function(t,e){if(!t)return"";const o=this?.context,s=o?.polyglot,r=e||s?.defaultLang||"en";if(s?.translations){const c=s.translations[r];if(c){const i=ot(c,t);if(i!==void 0)return i}}const p=this?.state?.root||o?.state?.root;if(p?.translations){const c=p.translations[r];if(c){const i=ot(c,t);if(i!==void 0)return i}}const f=s?.defaultLang||"en";if(f!==r&&s?.translations){const c=s.translations[f];if(c){const i=ot(c,t);if(i!==void 0)return i}}return t},lt=function(){const t=this?.context;return this?.state?.root?.lang||t?.polyglot?.defaultLang||"en"},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(b(d(e,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:e};let s;try{const i=N.resolve("smbls/package.json");s=q(i)}catch{let i=t;for(;i!==q(i);){const n=d(i,"node_modules","smbls");if(b(d(n,"package.json"))){s=n;break}i=q(i)}}let r=N;if(s)try{r=et(d(s,"package.json"))}catch{}let p,f=process.cwd();for(;f!==q(f);){if(b(d(f,"package.json"))){p=f;break}f=q(f)}let c=r;if(p)try{c=et(d(p,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:s,brenderDir:t,projectRoot:p,_smblsRequire:r,_projectRequire:c}},G=(t,e)=>{const o=t.isMonorepo?[N]:[t._smblsRequire,t._projectRequire,N].filter(Boolean);for(const s of o)try{return s.resolve(e)}catch{}return null},fe=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages",e,...o);const s=G(t,`${e}/package.json`);return s?d(q(s),...o):null},ue=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"plugins",e,...o);const s=G(t,`@symbo.ls/${e}/package.json`);return s?d(q(s),...o):null},H=(t,e,...o)=>{if(t.isMonorepo){for(const r of["packages","plugins"]){const p=d(t.monorepoRoot,r,e,...o);if(b(p))return p}return null}const s=G(t,`@symbo.ls/${e}/package.json`);return s?d(q(s),...o):null},Y=(t,e,...o)=>{if(t.isMonorepo)return d(t.monorepoRoot,"packages","domql","packages",e,...o);const s=G(t,`@symbo.ls/${e}/package.json`);return s?d(q(s),...o):null};let Z=null;const Et=async()=>{if(Z)return Z;const t=ft();if(!N)try{const c=await import("./dist/createDomql.bundled.mjs");return Z=c,c}catch(c){throw new Error(`brender: pre-bundled createDomql not available in bundled runtime: ${c.message}`)}let e;if(t.isMonorepo)e=d(t.monorepoRoot,"packages","smbls","src","createDomql.js");else if(t.smblsRoot){const c=d(t.smblsRoot,"src","createDomql.js"),i=d(t.smblsRoot,"dist","esm","src","createDomql.js");e=b(c)?c:i}if(!e||!b(e))throw new Error(`brender: cannot find createDomql.js (isMonorepo=${t.isMonorepo}, entry=${e})`);const o=await import("esbuild"),s=tt(Ct(),`br_createDomql_${Tt(6).toString("hex")}.mjs`),r=$t,p={name:"workspace-resolve",setup(c){c.onResolve({filter:/^smbls/},i=>{const n=i.path.replace(/^smbls\/?/,""),l=t.isMonorepo?d(t.monorepoRoot,"packages","smbls"):t.smblsRoot;if(!l)return;if(!n){const m=r(l);return m?{path:m}:void 0}const u=d(l,n);if(b(u))return{path:u};if(b(u+".js"))return{path:u+".js"};const a=d(u,"index.js");if(b(a))return{path:a}}),c.onResolve({filter:/^domql$/},i=>{if(t.isMonorepo){const n=d(t.monorepoRoot,"packages","domql","src","index.js");if(b(n))return{path:n};const l=d(t.monorepoRoot,"packages","domql","index.js");if(b(l))return{path:l}}else try{const n=_require.resolve("domql/package.json"),l=r(q(n));if(l)return{path:l}}catch{}}),c.onResolve({filter:/^@symbo\.ls\//},i=>{const n=i.path.replace("@symbo.ls/","");if(n==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(t.isMonorepo){for(const u of["packages","plugins"]){const a=d(t.monorepoRoot,u,n,"src","index.js");if(b(a))return{path:a};const m=d(t.monorepoRoot,u,n,"index.js");if(b(m))return{path:m}}const l=d(t.monorepoRoot,"packages","default-config","blank","index.js");if(n==="default-config"&&b(l))return{path:l}}else{const l=H(t,n,"src","index.js");if(l&&b(l))return{path:l};const u=H(t,n,"index.js");if(u&&b(u))return{path:u};if(n==="default-config"){const a=H(t,"default-config","blank","index.js");if(a&&b(a))return{path:a}}}}),c.onResolve({filter:/^@domql\//},i=>{const n=i.path.replace("@symbo.ls/","");if(t.isMonorepo){const l=d(t.monorepoRoot,"packages","domql","packages",n,"src","index.js");if(b(l))return{path:l};const u=d(t.monorepoRoot,"packages","domql","packages",n,"index.js");if(b(u))return{path:u}}else{const l=Y(t,n,"src","index.js");if(l&&b(l))return{path:l};const u=Y(t,n,"index.js");if(u&&b(u))return{path:u}}}),c.onResolve({filter:/^css-in-props/},i=>{let n;if(t.isMonorepo)n=d(t.monorepoRoot,"packages","css-in-props");else{const a=G(t,"css-in-props/package.json");a&&(n=q(a))}if(!n)return;const l=i.path.replace(/^css-in-props\/?/,"");if(l){const a=d(n,l),m=d(a,"index.js");if(b(m))return{path:m};if(b(a+".js"))return{path:a+".js"};if(b(a))return{path:a}}const u=r(n);if(u)return{path:u}}),c.onResolve({filter:/^@emotion\//},i=>{let n;if(t.isMonorepo)n=d(t.monorepoRoot,"node_modules",i.path);else{const l=G(t,`${i.path}/package.json`);if(!l)return;n=q(l)}if(b(n)){const l=d(n,"package.json");if(b(l))try{const u=JSON.parse(K(l,"utf8")),a=u.module||u.main||"dist/emotion-css.esm.js";return{path:d(n,a)}}catch{}return{path:n}}}),c.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const n=d(i.resolveDir,i.path);if(b(n))return{path:n}}}),c.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let n=K(i.path,"utf8");return n=n.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),n=n.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:n,loader:"js"}}),c.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let n=K(i.path,"utf8");return n=n.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:n,loader:"js"}}),c.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const inspectPlugin = () => ({}); export default {}",loader:"js"})),c.onLoad({filter:/smbls\/src\/router\.js$/},async i=>{let n=K(i.path,"utf8");return n=n.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:n,loader:"js"}}),c.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let n=K(i.path,"utf8");return n=n.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:n,loader:"js"}})}};await o.build({entryPoints:[e],bundle:!0,format:"esm",platform:"node",outfile:s,write:!0,logLevel:"warning",plugins:[p],nodePaths:t.isMonorepo?[d(t.monorepoRoot,"node_modules")]:[...t.smblsRoot?[d(t.smblsRoot,"node_modules")]:[],...t.projectRoot?[d(t.projectRoot,"node_modules")]:[],...t.smblsRoot?[d(t.smblsRoot,"..","..","node_modules")]:[]].filter(c=>b(c)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const f=await import(`file://${s}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",s);else try{_t(s)}catch{}return Z=f,f},Mt={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:t=>t.href,target:t=>t.target,rel:t=>t.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:t=>{let e=t.src;return typeof e=="string"&&e.includes("{{")&&(e=t.call("replaceLiteralsWithObjectFields",e,t.state)),e},alt:t=>t.alt,loading:t=>t.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},ut=(t,e="")=>{if(!t||!t.__ref)return{};const o={},s=t.__ref.__brKey;if(s&&(o[e===""?"__root":e]=s),t.__ref.__children)for(const r of t.__ref.__children){const p=t[r];if(p&&p.__ref){const f=e===""?r:`${e}.${r}`;Object.assign(o,ut(p,f))}}return o},pt=async(t,e={})=>{const{route:o="/",pathname:s,state:r,context:p,prefetch:f=!1}=e,c=s||o,i=globalThis.location,n=globalThis.window;(!globalThis.location||globalThis.location.pathname!==c)&&(globalThis.location={pathname:c,href:c,search:"",hash:"",origin:""}),globalThis.window||(globalThis.window={location:globalThis.location});let l;if(f)try{const y=t.pages||{};l={...y};const E=await Lt(t,o);if(E.size){const V=JSON.parse(JSON.stringify(y[o],(v,B)=>{if(typeof B!="function")return B})),U=(v,B)=>{if(!(!v||!B))for(const 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(y[o],V),At(V,E),l[o]=V}}catch(y){console.error("[brender] Prefetch error:",y),l=t.pages}let u;if(f)try{u=await Pt(t)}catch(y){console.warn("[brender] SSR translation fetch failed:",y.message)}i!==void 0?globalThis.location=i:delete globalThis.location,n!==void 0?globalThis.window=n:delete globalThis.window;const{window:a,document:m}=nt(),_=m.body;a.location.pathname=c;const h=globalThis.document,g=globalThis.location;globalThis.document=m,globalThis.location=a.location;const{createDomqlElement:I}=await Et(),L=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 y of["useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDefaultConfig","useDocumentTheme"])t[y]!=null&&R[y]==null&&(R[y]=t[y]);const k=R.polyglot?{...R.polyglot}:void 0;u&&k&&(k.translations={...k.translations||{},...u});const O=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})),qt();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:vt,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 It();F&&(C.plugins=C.plugins||[],C.plugins.some(y=>y.name==="funcql")||C.plugins.push(F)),st();const A=await I(L,C),x=f?2e3:50;await new Promise(y=>setTimeout(y,x)),rt(_);const $=it(A),S=ut(A),w=ct(t,o,A,A?.state),j=[],T=m.head||m.querySelector("head");if(T)for(const y of T.querySelectorAll("style")){if(y.sheet&&y.sheet.cssRules)for(const E of y.sheet.cssRules)E.cssText&&j.push(E.cssText);if(!j.length){const E=y.textContent||"";E&&j.push(E)}}let P=dt(_.innerHTML);if(u){const y=k?.defaultLang||"en",E=u[y]||Object.values(u)[0]||{};P=P.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(V,U)=>{const v=U.trim();return E[v]??V})}return h!==void 0?globalThis.document=h:delete globalThis.document,g!==void 0?globalThis.location=g:delete globalThis.location,{html:P,metadata:w,registry:$,brRegistry:S,element:A,emotionCSS:j,document:m,window:a,ssrTranslations:u,prefetchedPages:l}},pe=async(t,e={})=>{const{context:o={}}=e,{window:s,document:r}=nt(),p=r.body,{create:f}=await import("@symbo.ls/element"),c=await import("@symbo.ls/utils"),i={...Mt,...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 Dt=["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 Dt)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
|
|
|
@@ -38,31 +36,31 @@ export const supabaseAdapter = () => ({name:'supabase'});
|
|
|
38
36
|
// Export as globalThis so we can read it
|
|
39
37
|
globalThis.__BR_GLOBAL_CSS__ = result
|
|
40
38
|
export default result
|
|
41
|
-
`);const a=ft(),m={name:"workspace-resolve",setup(
|
|
39
|
+
`);const a=ft(),m={name:"workspace-resolve",setup(x){x.onResolve({filter:/^@symbo\.ls\//},$=>{const S=$.path.replace("@symbo.ls/","");if(a.isMonorepo){for(const j of["packages","plugins"]){const T=d(a.monorepoRoot,j,S,"src","index.js");if(o(T))return{path:T};const P=d(a.monorepoRoot,j,S,"index.js");if(o(P))return{path:P}}const w=d(a.monorepoRoot,"packages","default-config","blank","index.js");if(S==="default-config"&&o(w))return{path:w}}else{const w=H(a,S,"src","index.js");if(w&&o(w))return{path:w};const j=H(a,S,"index.js");if(j&&o(j))return{path:j};if(S==="default-config"){const T=H(a,"default-config","blank","index.js");if(T&&o(T))return{path:T}}}}),x.onResolve({filter:/^@domql\//},$=>{const S=$.path.replace("@symbo.ls/","");if(a.isMonorepo){const w=d(a.monorepoRoot,"packages","domql","packages",S,"src","index.js");if(o(w))return{path:w}}else{const w=Y(a,S,"src","index.js");if(w&&o(w))return{path:w};const j=Y(a,S,"index.js");if(j&&o(j))return{path:j}}})}};await c.build({entryPoints:[l],bundle:!0,format:"esm",platform:"node",outfile:u,write:!0,logLevel:"silent",plugins:[m],nodePaths:a.isMonorepo?[d(a.monorepoRoot,"node_modules")]:[...a.smblsRoot?[d(a.smblsRoot,"node_modules")]:[],...a.projectRoot?[d(a.projectRoot,"node_modules")]:[],...a.smblsRoot?[d(a.smblsRoot,"..","..","node_modules")]:[]].filter(x=>o(x)),external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker"]});const h=(await import(`file://${u}`)).default||{};try{r(l)}catch{}try{r(u)}catch{}const g=h.CSS_VARS||{},I=h.CSS_MEDIA_VARS||{},L=h.RESET||{},R=h.ANIMATION||{},k=Object.entries(g).map(([x,$])=>` ${x}: ${$}`).join(`;
|
|
42
40
|
`);let O=k?`:root {
|
|
43
41
|
${k};
|
|
44
|
-
}`:"";const C=Object.entries(I).map(([
|
|
45
|
-
`);return S?
|
|
42
|
+
}`:"";const C=Object.entries(I).map(([x,$])=>{const S=Object.entries($).map(([w,j])=>` ${w}: ${j}`).join(`;
|
|
43
|
+
`);return S?x.startsWith("@media")?`${x} {
|
|
46
44
|
:root:not([data-theme]) {
|
|
47
45
|
${S};
|
|
48
46
|
}
|
|
49
|
-
}`:`${
|
|
47
|
+
}`:`${x} {
|
|
50
48
|
${S};
|
|
51
49
|
}`:""}).filter(Boolean).join(`
|
|
52
50
|
|
|
53
51
|
`);C&&(O+=`
|
|
54
52
|
|
|
55
|
-
`+C);const F=
|
|
56
|
-
`);A.push(`@keyframes ${
|
|
53
|
+
`+C);const F=wt(L),A=[];for(const x in R){const $=R[x];if(!$||typeof $!="object")continue;const S=Object.entries($).map(([w,j])=>{if(typeof j!="object")return"";const T=Object.entries(j).map(([P,y])=>`${J(P)}: ${y}`).join("; ");return` ${w} { ${T}; }`}).join(`
|
|
54
|
+
`);A.push(`@keyframes ${x} {
|
|
57
55
|
${S}
|
|
58
56
|
}`)}return W={rootRule:O,resetRules:F,fontFaceCSS:"",keyframeRules:A.join(`
|
|
59
|
-
`)},W}catch(o){return console.warn("generateGlobalCSS failed:",o.message,o.stack),W={rootRule:"",resetRules:"",fontFaceCSS:"",keyframeRules:""},W}};let X=new Set;const
|
|
60
|
-
`),
|
|
57
|
+
`)},W}catch(o){return console.warn("generateGlobalCSS failed:",o.message,o.stack),W={rootRule:"",resetRules:"",fontFaceCSS:"",keyframeRules:""},W}};let X=new Set;const de=()=>{W=null,X=new Set},me=()=>Array.from(X).join(`
|
|
58
|
+
`),ge=(t,e)=>t.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,e?`<style data-emotion="smbls">
|
|
61
59
|
${e}
|
|
62
|
-
</style>`:""),
|
|
63
|
-
`):"",globalCSS:f,resetCss:f.resetRules||
|
|
64
|
-
`),m=t.designSystem||{},_=await gt(m,mt(t)),
|
|
65
|
-
`)}const
|
|
60
|
+
</style>`:""),he=async(t,e={})=>{const{route:o="/",pathname:s}=e,r=await pt(t,{route:o,pathname:s,prefetch:!0});if(!r)return null;const p=t.designSystem||{},f=await gt(p,mt(t));let c=null,i=null;try{const n=r.element,l=n?.context?.polyglot||t.polyglot||t.config?.polyglot;if(i=n?.state?.root?.lang||l?.defaultLang||"en",r.prefetchedPages&&r.prefetchedPages[o]){const u=r.prefetchedPages[o],a=(m,_={})=>{if(!m||typeof m!="object")return _;if(m.state&&typeof m.state=="object")for(const[h,g]of Object.entries(m.state))g!=null&&typeof g!="function"&&(_[h]=g);for(const[h,g]of Object.entries(m))h==="state"||h==="props"||h==="attr"||h==="on"||h==="define"||h==="__ref"||h.startsWith("__")||g&&typeof g=="object"&&!Array.isArray(g)&&a(g,_);return _};c=a(u)}}catch{}return{html:r.html,css:r.emotionCSS?r.emotionCSS.join(`
|
|
61
|
+
`):"",globalCSS:f,resetCss:f.resetRules||wt(p.reset),fontLinks:xt(p),metadata:r.metadata||ct(t,o),brKeyCount:r.registry?Object.keys(r.registry).length:0,brRegistry:r.brRegistry||{},ssrTranslations:r.ssrTranslations,prefetchedState:c,activeLang:i}},ye=async(t,e="/",o={})=>{const{lang:s,themeColor:r,isr:p,hydrate:f=!0,prefetch:c=!0}=o,i=s||t.state?.lang||t.app?.metadata?.lang||"en",n=await pt(t,{route:e,prefetch:c});if(!n)return null;const l={...n.metadata};r&&(l["theme-color"]=r);const u=Ot(l);if(n.emotionCSS&&n.emotionCSS.length)for(const C of n.emotionCSS)C&&X.add(C);const a=Array.from(X).join(`
|
|
62
|
+
`),m=t.designSystem||{},_=await gt(m,mt(t)),h=xt(m),g=Object.keys(n.registry).length;let I="";if(p&&p.clientScript){const C=e==="/"?0:e.replace(/^\/|\/$/g,"").split("/").length,F=C>0?"../".repeat(C):"./";if(f){let A="";if(n.ssrTranslations){const S=t.polyglot||t.config?.polyglot,w=S?.storagePrefix||"",j=S?.storageLangKey||"",T=[];for(const P in n.ssrTranslations){const y=n.ssrTranslations[P];y&&typeof y=="object"&&T.push(`localStorage.setItem(${JSON.stringify(w+P)},${JSON.stringify(JSON.stringify(y))})`)}if(j){const P=S?.defaultLang||"en";T.push(`if(!localStorage.getItem(${JSON.stringify(j)}))localStorage.setItem(${JSON.stringify(j)},${JSON.stringify(P)})`)}T.length&&(A=`<script>try{${T.join(";")}}catch(e){}<\/script>
|
|
63
|
+
`)}const x=n.brRegistry&&Object.keys(n.brRegistry).length?JSON.stringify(n.brRegistry):null,$=x?`<script>window.__BR_REGISTRY__=${x}<\/script>
|
|
66
64
|
`:"";I=`${A}${$}<script>window.__BRENDER__=true<\/script>
|
|
67
65
|
<script type="module" src="${F}${p.clientScript}"><\/script>`}else I=`<script type="module">
|
|
68
66
|
{
|
|
@@ -81,11 +79,11 @@ ${e}
|
|
|
81
79
|
observer.observe(document.body, { childList: true })
|
|
82
80
|
}
|
|
83
81
|
<\/script>
|
|
84
|
-
<script type="module" src="${F}${p.clientScript}"><\/script>`}const L={...t.config||{}};t.polyglot&&!L.polyglot&&(L.polyglot=t.polyglot);const R=L.polyglot;let k=u;if(R){const C=R.defaultLang||"en",A={...R.translations||{},...n.ssrTranslations||{}}[C]||{};k=u.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(
|
|
82
|
+
<script type="module" src="${F}${p.clientScript}"><\/script>`}const L={...t.config||{}};t.polyglot&&!L.polyglot&&(L.polyglot=t.polyglot);const R=L.polyglot;let k=u;if(R){const C=R.defaultLang||"en",A={...R.translations||{},...n.ssrTranslations||{}}[C]||{};k=u.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(x,$)=>{const S=$.trim();return A[S]??x})}return{html:`<!DOCTYPE html>
|
|
85
83
|
<html lang="${i}">
|
|
86
84
|
<head>
|
|
87
85
|
${k}
|
|
88
|
-
${
|
|
86
|
+
${h}
|
|
89
87
|
${_.fontFaceCSS?`<style>${_.fontFaceCSS}</style>`:""}
|
|
90
88
|
<style>
|
|
91
89
|
${_.rootRule||""}
|
|
@@ -100,11 +98,11 @@ ${a}
|
|
|
100
98
|
${n.html}
|
|
101
99
|
${I}
|
|
102
100
|
</body>
|
|
103
|
-
</html>`,route:e,brKeyCount:g}},
|
|
104
|
-
`)},Rt={Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Block:{display:"block"},Inline:{display:"inline"}},
|
|
101
|
+
</html>`,route:e,brKeyCount:g}},Ft={U:-6,V:-5,W:-4,X:-3,Y:-2,Z:-1,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15},ht=new Set(["padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingBlock","paddingInline","paddingBlockStart","paddingBlockEnd","paddingInlineStart","paddingInlineEnd","margin","marginTop","marginRight","marginBottom","marginLeft","marginBlock","marginInline","marginBlockStart","marginBlockEnd","marginInlineStart","marginInlineEnd","gap","rowGap","columnGap","top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","fontSize","lineHeight","letterSpacing","borderWidth","borderRadius","outlineWidth","outlineOffset","inset","insetBlock","insetInline","boxSize","round"]),yt=(t,e)=>{if(!t||typeof t!="string"||!e)return null;const o=e.base||16,s=e.ratio||1.618,r=e.unit||"px",p=e.subSequence!==!1;if(t.includes(" "))return t.split(" ").map(g=>g==="-"||g===""?g:yt(g,e)||g).join(" ");if(/^(none|auto|inherit|initial|unset|0)$/i.test(t)||/\d+(px|em|rem|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc|fr|s|ms)$/i.test(t)||/^(#|rgb|hsl|var\()/i.test(t))return null;const f=t.startsWith("-"),i=(f?t.slice(1):t).match(/^([A-Z])(\d)?$/i);if(!i)return null;const n=i[1].toUpperCase(),l=i[2]?parseInt(i[2]):0,u=Ft[n];if(u===void 0)return null;let a=o*Math.pow(s,u);if(l>0&&p){const h=o*Math.pow(s,u+1),I=(h-a)/s,L=h-I,R=a+I,k=(L+R)/2,O=~~h-~~a>16?[L,k,R]:[L,R];l<=O.length&&(a=O[l-1])}const m=Math.round(a*100)/100;return`${f?"-":""}${m}${r}`},Bt=new Set([...ht].map(t=>t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()))),Q=(t,e,o)=>{if(typeof e!="string")return e;if(Nt.has(t)){const s=o?.color||{};if(s[e])return s[e]}if(ht.has(t)||Bt.has(t)){const s=o?.spacing||{},r=yt(e,s);if(r)return r}return e},Nt=new Set(["color","background","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor","fill","stroke"]),bt=new Set(["href","src","alt","title","id","name","type","value","placeholder","target","rel","loading","srcset","sizes","media","role","tabindex","for","action","method","enctype","autocomplete","autofocus","theme","__element","update","childrenAs","childExtends","childProps","children"]),J=t=>t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),St=(t,e)=>{if(typeof e>"u"||e===null)return null;if(t==="flow"&&typeof e=="string"){let[o,s]=(e||"row").split(" ");return(e.startsWith("x")||e==="row")&&(o="row"),(e.startsWith("y")||e==="column")&&(o="column"),{display:"flex","flex-flow":(o||"")+" "+(s||"")}}if(t==="wrap")return{display:"flex","flex-wrap":e};if((t==="align"||t==="flexAlign")&&typeof e=="string"){const[o,s]=e.split(" "),r={display:"flex","align-items":o};return s&&(r["justify-content"]=s),r}if(t==="gridAlign"&&typeof e=="string"){const[o,s]=e.split(" "),r={display:"grid","align-items":o};return s&&(r["justify-content"]=s),r}if(t==="flexFlow"&&typeof e=="string"){let[o,s]=(e||"row").split(" ");return(e.startsWith("x")||e==="row")&&(o="row"),(e.startsWith("y")||e==="column")&&(o="column"),{display:"flex","flex-flow":(o||"")+" "+(s||"")}}if(t==="flexWrap")return{display:"flex","flex-wrap":e};if(t==="backgroundImage"&&typeof e=="string"&&!e.startsWith("url(")&&!e.startsWith("linear-gradient")&&!e.startsWith("radial-gradient")&&!e.startsWith("none"))return{"background-image":`url(${e})`};if(t==="round"||t==="borderRadius"&&e)return{"border-radius":typeof e=="number"?e+"px":e};if(t==="boxSize"&&typeof e=="string"){const[o,s]=e.split(" ");return{height:o,width:s||o}}if(t==="widthRange"&&typeof e=="string"){const[o,s]=e.split(" ");return{"min-width":o,"max-width":s||o}}if(t==="heightRange"&&typeof e=="string"){const[o,s]=e.split(" ");return{"min-height":o,"max-height":s||o}}return t==="column"?{"grid-column":e}:t==="columns"?{"grid-template-columns":e}:t==="templateColumns"?{"grid-template-columns":e}:t==="row"?{"grid-row":e}:t==="rows"?{"grid-template-rows":e}:t==="templateRows"?{"grid-template-rows":e}:t==="area"?{"grid-area":e}:t==="template"?{"grid-template":e}:t==="templateAreas"?{"grid-template-areas":e}:t==="autoColumns"?{"grid-auto-columns":e}:t==="autoRows"?{"grid-auto-rows":e}:t==="autoFlow"?{"grid-auto-flow":e}:t==="columnStart"?{"grid-column-start":e}:t==="rowStart"?{"grid-row-start":e}:null},jt=(t,e)=>{const o={};for(const s in t){const r=t[s],p=St(s,r);if(p){for(const f in p)o[f]=Q(f,p[f],e);continue}typeof r!="string"&&typeof r!="number"||(o[J(s)]=Q(s,r,e))}return o},Wt=(t,e,o)=>{const s={},r={},p={};for(const f in t){const c=t[f];if(f.charCodeAt(0)===64&&typeof c=="object"){const n=o?.[f.slice(1)];if(n){const l=jt(c,e);Object.keys(l).length&&(r[n]=l)}continue}if(f.charCodeAt(0)===58&&typeof c=="object"){const n=jt(c,e);Object.keys(n).length&&(p[f]=n);continue}if(typeof c!="string"&&typeof c!="number"||f.charCodeAt(0)>=65&&f.charCodeAt(0)<=90||bt.has(f))continue;const i=St(f,c);if(i){for(const n in i)s[n]=Q(n,i[n],e);continue}s[J(f)]=Q(f,c,e)}return{base:s,mediaRules:r,pseudoRules:p}},Jt=(t,{base:e,mediaRules:o,pseudoRules:s})=>{const r=[],p=Object.entries(e).map(([f,c])=>`${f}: ${c}`).join("; ");p&&r.push(`${t} { ${p}; }`);for(const[f,c]of Object.entries(s)){const i=Object.entries(c).map(([n,l])=>`${n}: ${l}`).join("; ");i&&r.push(`${t}${f} { ${i}; }`)}for(const[f,c]of Object.entries(o)){const i=Object.entries(c).map(([l,u])=>`${l}: ${u}`).join("; "),n=f.startsWith("@")?f:`@media ${f}`;i&&r.push(`${n} { ${t} { ${i}; } }`)}return r.join(`
|
|
102
|
+
`)},Rt={Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Block:{display:"block"},Inline:{display:"inline"}},Gt=t=>{const e=t.__ref?.__extends;if(!e||!Array.isArray(e))return null;for(const o of e)if(Rt[o])return Rt[o];return null},Ht=t=>{let e;for(const o in t){if(typeof t[o]!="function"||bt.has(o)||o.charCodeAt(0)>=65&&o.charCodeAt(0)<=90||o.startsWith("on")||o.startsWith("__"))continue;e||(e={});let s;try{s=t[o](t,t.state||{})}catch{try{const r={root:{},...t.state||{}};s=t[o](t,r)}catch{}}s!=null&&s!==!1&&(e[o]=s)}return e||t},be=(t,e)=>{const o=e?.media||{},s=e?.animation||{},r=[],p=new Set,f=new Set,c=n=>{if(!n||!n.__ref)return;const l=Ht(n);if(l&&n.node){const u=n.node.getAttribute?.("class");if(u&&!p.has(u)){p.add(u);const a=Wt(l,e,o),m=Gt(n);if(m)for(const[g,I]of Object.entries(m)){const L=J(g);a.base[L]||(a.base[L]=I)}(Object.keys(a.base).length||Object.keys(a.mediaRules).length||Object.keys(a.pseudoRules).length)&&r.push(Jt("."+u.split(" ")[0],a));const h=l.animation||l.animationName;if(typeof h=="string"){const g=h.split(" ")[0];s[g]&&f.add(g)}}}if(n.__ref?.__children)for(const u of n.__ref.__children)n[u]?.__ref&&c(n[u])};c(t);const i=[];for(const n of f){const l=s[n],u=Object.entries(l).map(([a,m])=>{const _=Object.entries(m).map(([h,g])=>`${J(h)}: ${g}`).join("; ");return` ${a} { ${_}; }`}).join(`
|
|
105
103
|
`);i.push(`@keyframes ${n} {
|
|
106
104
|
${u}
|
|
107
105
|
}`)}return[...i,...r].join(`
|
|
108
|
-
`)},
|
|
109
|
-
`)},
|
|
110
|
-
`):""};export{
|
|
106
|
+
`)},wt=t=>{if(!t)return"";const e=[];for(const[o,s]of Object.entries(t)){if(!s||typeof s!="object")continue;const r=[],p=[];for(const[f,c]of Object.entries(s)){if(typeof c=="object"&&c!==null){if(f.startsWith("@media")||f.startsWith("@")){const i=Object.entries(c).filter(([,n])=>typeof n!="object").map(([n,l])=>`${J(n)}: ${l}`).join("; ");i&&p.push(`${f} { ${o} { ${i}; } }`)}continue}r.push(`${J(f)}: ${c}`)}r.length&&e.push(`${o} { ${r.join("; ")}; }`),e.push(...p)}return e.join(`
|
|
107
|
+
`)},xt=t=>{if(!t)return"";const e=t.font_family||t.fontFamily||{},o=new Set;for(const r of Object.values(e)){if(typeof r!="string")continue;const p=r.match(/'([^']+)'/);p&&o.add(p[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(`
|
|
108
|
+
`):""};export{me as getAccumulatedEmotionCSS,pt as render,pe as renderElement,ye as renderPage,he as renderRoute,ge as replaceEmotionCSS,de as resetGlobalCSSCache};
|
package/package.json
CHANGED
package/packageEntry.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { resolve } from 'path'
|
|
4
|
+
import { existsSync } from 'fs'
|
|
5
|
+
|
|
6
|
+
// Helper to find a package's PUBLIC entry: root `index.js`, then `src/index.js`.
|
|
7
|
+
//
|
|
8
|
+
// Root-index FIRST, and the order is load-bearing. A package's root
|
|
9
|
+
// `index.js` is its public entry; `src/index.js` is an internal module this
|
|
10
|
+
// resolver only reaches for because a monorepo `dist/` may be stale or
|
|
11
|
+
// absent. For every @symbo.ls package the root index is exactly
|
|
12
|
+
// `export * from './src/index.js'`, so either order resolves the same
|
|
13
|
+
// module — but `smbls`'s root `index.js` is the UMBRELLA, re-exporting
|
|
14
|
+
// @symbo.ls/signal, /css, /scratch, /default-config and more ON TOP of
|
|
15
|
+
// `./src/index.js`. Preferring `src/index.js` therefore dropped every
|
|
16
|
+
// umbrella re-export from the SSR bundle, and esbuild failed the whole
|
|
17
|
+
// build with `No matching export in "packages/smbls/src/index.js" for
|
|
18
|
+
// import "createEffect"` — raised by plugins/dropdown and plugins/windows,
|
|
19
|
+
// which import `createEffect` through the umbrella deliberately (a second
|
|
20
|
+
// `@symbo.ls/signal` instance silently breaks every subscription; see the
|
|
21
|
+
// comment above their imports). `src/index.js` stays the fallback for a
|
|
22
|
+
// package that ships no root index. Locked by
|
|
23
|
+
// __tests__/packageEntryResolution.test.js (+ brenderStubDistFreshness.test.js end-to-end).
|
|
24
|
+
export const resolvePackageEntry = (base) => {
|
|
25
|
+
if (!base) return null
|
|
26
|
+
const idx = resolve(base, 'index.js')
|
|
27
|
+
if (existsSync(idx)) return idx
|
|
28
|
+
const src = resolve(base, 'src', 'index.js')
|
|
29
|
+
if (existsSync(src)) return src
|
|
30
|
+
return null
|
|
31
|
+
}
|
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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve, join, dirname } from 'path'
|
|
2
2
|
import { existsSync, writeFileSync, unlinkSync, readFileSync, realpathSync } from 'fs'
|
|
3
|
+
import { resolvePackageEntry } from './packageEntry.js'
|
|
3
4
|
import { tmpdir } from 'os'
|
|
4
5
|
import { randomBytes } from 'crypto'
|
|
5
6
|
import { createRequire } from 'module'
|
|
@@ -297,15 +298,7 @@ const bundleCreateDomql = async () => {
|
|
|
297
298
|
const esbuild = await import('esbuild')
|
|
298
299
|
const outFile = join(tmpdir(), `br_createDomql_${randomBytes(6).toString('hex')}.mjs`)
|
|
299
300
|
|
|
300
|
-
|
|
301
|
-
const tryResolve = (base) => {
|
|
302
|
-
if (!base) return null
|
|
303
|
-
const src = resolve(base, 'src', 'index.js')
|
|
304
|
-
if (existsSync(src)) return src
|
|
305
|
-
const idx = resolve(base, 'index.js')
|
|
306
|
-
if (existsSync(idx)) return idx
|
|
307
|
-
return null
|
|
308
|
-
}
|
|
301
|
+
const tryResolve = resolvePackageEntry
|
|
309
302
|
|
|
310
303
|
const workspacePlugin = {
|
|
311
304
|
name: 'workspace-resolve',
|
|
@@ -459,15 +452,6 @@ const bundleCreateDomql = async () => {
|
|
|
459
452
|
)
|
|
460
453
|
return { contents, loader: 'js' }
|
|
461
454
|
})
|
|
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
455
|
// No-op: globals.js keeps window = globalThis
|
|
472
456
|
// We set globalThis.document/location before import to make it SSR-safe
|
|
473
457
|
// Stub loader for brender-stub namespace (used for @symbo.ls/sync etc.)
|
|
@@ -1012,7 +996,7 @@ const generateGlobalCSS = async (ds, config) => {
|
|
|
1012
996
|
// Write a temporary script that imports scratch, runs set(), and
|
|
1013
997
|
// serialises the CSS_VARS + RESET objects as JSON.
|
|
1014
998
|
const dsJson = JSON.stringify(ds || {}, safeJsonReplacer())
|
|
1015
|
-
// Config may contain non-serializable values (e.g.
|
|
999
|
+
// Config may contain non-serializable values (e.g. a DB client with
|
|
1016
1000
|
// circular refs, functions). Strip those for the CSS generation script.
|
|
1017
1001
|
const cfgJson = JSON.stringify(config || {}, safeJsonReplacer())
|
|
1018
1002
|
const tmpEntry = join(tmpdir(), `br_global_${randomBytes(6).toString('hex')}.mjs`)
|