@symbo.ls/brender 3.14.661 → 3.14.663

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/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { createEnv } from './env.js'
2
2
  import { resetKeys, assignKeys, mapKeysToElements } from './keys.js'
3
3
  import { loadProject, loadAndRenderAll } from './load.js'
4
- import { render, renderElement, renderRoute, renderPage, resetGlobalCSSCache, getAccumulatedEmotionCSS, replaceEmotionCSS } from './render.js'
4
+ import { render, renderElement, renderRoute, renderPage, resetGlobalCSSCache, getAccumulatedEmotionCSS, replaceEmotionCSS, adoptionScripts } from './render.js'
5
5
  import { extractMetadata, generateHeadHtml } from './metadata.js'
6
6
  import { collectBrNodes, hydrate } from './hydrate.js'
7
7
  import { generateSitemap } from './sitemap.js'
8
8
  import { prefetchPageData, injectPrefetchedState } from './prefetch.js'
9
+ import { composeIntoShell } from './shell.js'
9
10
 
10
11
  export {
11
12
  createEnv,
@@ -27,7 +28,9 @@ export {
27
28
  hydrate,
28
29
  generateSitemap,
29
30
  prefetchPageData,
30
- injectPrefetchedState
31
+ injectPrefetchedState,
32
+ composeIntoShell,
33
+ adoptionScripts
31
34
  }
32
35
 
33
36
  export default {
@@ -50,5 +53,7 @@ export default {
50
53
  hydrate,
51
54
  generateSitemap,
52
55
  prefetchPageData,
53
- injectPrefetchedState
56
+ injectPrefetchedState,
57
+ composeIntoShell,
58
+ adoptionScripts
54
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/brender",
3
- "version": "3.14.661",
3
+ "version": "3.14.663",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -46,15 +46,19 @@
46
46
  "prepublishOnly": "npm run build"
47
47
  },
48
48
  "dependencies": {
49
- "@symbo.ls/css": "^3.14.599",
50
- "@symbo.ls/default-config": "^3.14.0",
51
- "@symbo.ls/element": "^3.14.5",
52
- "@symbo.ls/helmet": "^3.14.599",
53
- "@symbo.ls/scratch": "^3.14.775",
54
- "@symbo.ls/utils": "^3.14.772",
49
+ "@symbo.ls/css": "^3.14.775",
50
+ "@symbo.ls/default-config": "^3.14.785",
51
+ "@symbo.ls/element": "^3.14.800",
52
+ "@symbo.ls/fetch": "^3.14.663",
53
+ "@symbo.ls/helmet": "^3.14.669",
54
+ "@symbo.ls/scratch": "^3.14.786",
55
+ "@symbo.ls/utils": "^3.14.784",
55
56
  "esbuild": "^0.28.1",
56
57
  "linkedom": "^0.16.8"
57
58
  },
59
+ "peerDependencies": {
60
+ "smbls": "^3.14.828"
61
+ },
58
62
  "optionalDependencies": {
59
63
  "@symbo.ls/funcql": "^3.14.0"
60
64
  },
package/prefetch.js CHANGED
@@ -106,32 +106,71 @@ const collectFetchDeclarations = (def, path = '') => {
106
106
  }
107
107
 
108
108
  /**
109
- * Create an SSR adapter from project config.
109
+ * Create an SSR adapter from project config — the SAME adapter the client's
110
+ * declarative `fetch` uses, resolved through @symbo.ls/fetch's public
111
+ * `resolveDb` (config.fetch / config.db: `{ adapter: 'rest', url, headers }`,
112
+ * or an adapter object with its own select/rpc).
110
113
  *
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.
114
+ * This used to be a stub that always returned null (xma.info report
115
+ * sub-problem 2): the Supabase SSR path had been removed, nothing replaced it,
116
+ * so server renders never had data or fetched translations.
117
+ *
118
+ * Not every adapter can run on the server: the platform's 'sdk' adapter is
119
+ * registered by the page runtime, which a server render does not have. For a
120
+ * name @symbo.ls/fetch cannot resolve right now (`hasAdapter`), this returns
121
+ * null at once — the page renders without prefetched data and the client's
122
+ * fetch loads it — instead of letting resolveDb wait for a registration that
123
+ * never comes.
116
124
  */
125
+ const BUILTIN_ADAPTER_NAMES = ['rest', 'local'] // @symbo.ls/fetch without hasAdapter()
126
+ const _adapterCache = new WeakMap()
127
+
117
128
  const createSSRAdapter = async (dbConfig) => {
118
129
  if (!dbConfig) return null
119
- return null
130
+ if (isObject(dbConfig) && (isFunction(dbConfig.select) || isFunction(dbConfig.rpc))) return dbConfig
131
+ const config = typeof dbConfig === 'string' ? { adapter: dbConfig } : dbConfig
132
+ if (!isObject(config) || typeof config.adapter !== 'string') return null
133
+ if (_adapterCache.has(config)) return _adapterCache.get(config)
134
+
135
+ const pending = (async () => {
136
+ let fetchPkg
137
+ try {
138
+ fetchPkg = await import('@symbo.ls/fetch')
139
+ } catch {
140
+ return null
141
+ }
142
+ const known = isFunction(fetchPkg.hasAdapter)
143
+ ? fetchPkg.hasAdapter(config.adapter)
144
+ : BUILTIN_ADAPTER_NAMES.includes(config.adapter)
145
+ if (!known) return null
146
+ try {
147
+ return await fetchPkg.resolveDb(config)
148
+ } catch (e) {
149
+ console.warn(`[brender] SSR adapter "${config.adapter}" unavailable: ${e.message}`)
150
+ return null
151
+ }
152
+ })()
153
+ _adapterCache.set(config, pending)
154
+ return pending
120
155
  }
121
156
 
157
+ export { createSSRAdapter }
158
+
122
159
  /**
123
160
  * Execute a single fetch config against the adapter.
124
161
  * Returns the fetched data, or null on error.
125
162
  */
126
163
  const executeSingle = async (adapter, config) => {
127
164
  try {
128
- const { method, from, params, transform, limit, offset, order, single } = config
165
+ const { method, from, params, transform, limit, offset, order, single, headers, baseUrl } = config
129
166
  let result
130
167
 
131
168
  if (method === 'rpc') {
132
- result = await adapter.rpc({ from, params })
169
+ if (!isFunction(adapter.rpc)) return null
170
+ result = await adapter.rpc({ from, params, headers, baseUrl })
133
171
  } else {
134
- result = await adapter.select({ from, select: config.select, params, limit, offset, order, single })
172
+ if (!isFunction(adapter.select)) return null
173
+ result = await adapter.select({ from, select: config.select, params, limit, offset, order, single, headers, baseUrl })
135
174
  }
136
175
 
137
176
  let data = result?.data ?? null
@@ -232,6 +271,7 @@ export const fetchSSRTranslations = async (data) => {
232
271
  const results = await Promise.allSettled(
233
272
  languages.map(async (lang) => {
234
273
  try {
274
+ if (!isFunction(adapter.rpc)) return
235
275
  const res = await adapter.rpc({
236
276
  from: rpcName,
237
277
  params: { p_lang: lang, p_cached_version: 0 }