@symbo.ls/brender 3.14.662 → 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/CHANGELOG.md +31 -0
- package/dist/esm/env.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/render.js +46 -109
- package/dist/esm/shell.js +6 -5
- package/env.js +59 -1
- package/index.js +5 -3
- package/package.json +5 -5
- package/render.js +291 -304
- package/shell.js +5 -2
package/shell.js
CHANGED
|
@@ -129,9 +129,12 @@ const rebaseAssets = (html, depth) => {
|
|
|
129
129
|
* @param {string} [parts.headEnd] - font links + <style> blocks for </head>
|
|
130
130
|
* @param {string} [parts.body] - rendered body markup
|
|
131
131
|
* @param {number} [parts.depth=0] - directory depth of the output file
|
|
132
|
+
* @param {string} [parts.bootScripts] - inline scripts placed right after the
|
|
133
|
+
* `__BRENDER__` flag, before the markup (the opt-in hydration registry and
|
|
134
|
+
* fetch seed — renderPage `adoptDom`)
|
|
132
135
|
* @returns {string}
|
|
133
136
|
*/
|
|
134
|
-
export const composeIntoShell = (shell, { headTags = '', headEnd = '', body = '', depth = 0 } = {}) => {
|
|
137
|
+
export const composeIntoShell = (shell, { headTags = '', headEnd = '', body = '', depth = 0, bootScripts = '' } = {}) => {
|
|
135
138
|
if (typeof shell !== 'string' || !shell.trim()) {
|
|
136
139
|
throw new Error('brender: the shell document is empty')
|
|
137
140
|
}
|
|
@@ -167,7 +170,7 @@ export const composeIntoShell = (shell, { headTags = '', headEnd = '', body = ''
|
|
|
167
170
|
html = html.slice(0, at) + headIn + headOut + html.slice(at)
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
const flagged = `\n<script>window.__BRENDER__=true</script>\n${body}\n`
|
|
173
|
+
const flagged = `\n<script>window.__BRENDER__=true</script>\n${bootScripts ? bootScripts + '\n' : ''}${body}\n`
|
|
171
174
|
const bodyOpen = findOutside(html, BODY_OPEN)
|
|
172
175
|
if (bodyOpen) {
|
|
173
176
|
// Right after <body>: before every shell script, so a classic inline
|