@symbo.ls/brender 3.6.7 → 3.6.8
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/env.js +2 -2
- package/hydrate.js +8 -8
- package/keys.js +3 -3
- package/package.json +2 -2
- package/render.js +5 -5
package/env.js
CHANGED
|
@@ -2,12 +2,12 @@ import { parseHTML } from 'linkedom'
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a virtual DOM environment for server-side rendering.
|
|
5
|
-
* Returns window and document that
|
|
5
|
+
* Returns window and document that DOMQL can use as context.
|
|
6
6
|
*/
|
|
7
7
|
export const createEnv = (html = '<!DOCTYPE html><html><head></head><body></body></html>') => {
|
|
8
8
|
const { window, document } = parseHTML(html)
|
|
9
9
|
|
|
10
|
-
// Stub APIs that
|
|
10
|
+
// Stub APIs that DOMQL/smbls may call during rendering
|
|
11
11
|
if (!window.requestAnimationFrame) {
|
|
12
12
|
window.requestAnimationFrame = (fn) => setTimeout(fn, 0)
|
|
13
13
|
}
|
package/hydrate.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Client-side hydration — reconnects pre-rendered HTML (with data-br keys)
|
|
3
|
-
* to a live
|
|
3
|
+
* to a live DOMQL element tree, attaches events, and fires lifecycle hooks.
|
|
4
4
|
*
|
|
5
|
-
* After hydration the
|
|
5
|
+
* After hydration the DOMQL tree owns every DOM node:
|
|
6
6
|
* - el.node points to the real DOM element
|
|
7
|
-
* - node.ref points back to the
|
|
7
|
+
* - node.ref points back to the DOMQL element
|
|
8
8
|
* - CSS classes are generated via emotion and applied
|
|
9
9
|
* - DOM events (click, input, etc.) are bound
|
|
10
10
|
* - on.render / on.renderRouter callbacks fire
|
|
@@ -25,11 +25,11 @@ export const collectBrNodes = (root) => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Walks a
|
|
28
|
+
* Walks a DOMQL element tree that was created with onlyResolveExtends.
|
|
29
29
|
* For each element with a __brKey, attaches the matching real DOM node,
|
|
30
30
|
* renders CSS via emotion, binds DOM events, and fires lifecycle hooks.
|
|
31
31
|
*
|
|
32
|
-
* @param {object} element - Root
|
|
32
|
+
* @param {object} element - Root DOMQL element (from create with onlyResolveExtends)
|
|
33
33
|
* @param {object} [options]
|
|
34
34
|
* @param {Element} [options.root] - Root DOM element to scan for data-br nodes
|
|
35
35
|
* @param {boolean} [options.events=true] - Attach DOM events (click, input, etc.)
|
|
@@ -134,7 +134,7 @@ const renderCSS = (el, emotion, colorMap, mediaMap) => {
|
|
|
134
134
|
continue
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
// Resolve
|
|
137
|
+
// Resolve DOMQL shorthands (flexAlign, round, boxSize, etc.)
|
|
138
138
|
const expanded = resolveShorthand(key, val)
|
|
139
139
|
if (expanded) {
|
|
140
140
|
for (const ek in expanded) {
|
|
@@ -263,7 +263,7 @@ const getExtendsCSS = (el) => {
|
|
|
263
263
|
return null
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
//
|
|
266
|
+
// DOMQL shorthand props that expand to multiple CSS properties
|
|
267
267
|
const resolveShorthand = (key, val) => {
|
|
268
268
|
if (typeof val === 'undefined' || val === null) return null
|
|
269
269
|
|
|
@@ -438,7 +438,7 @@ const addListener = (node, eventName, handler, el) => {
|
|
|
438
438
|
|
|
439
439
|
/**
|
|
440
440
|
* Walks the tree and fires on.render, on.renderRouter, on.done, on.create
|
|
441
|
-
* lifecycle events — the same ones that fire during normal
|
|
441
|
+
* lifecycle events — the same ones that fire during normal DOMQL create.
|
|
442
442
|
*/
|
|
443
443
|
const fireLifecycle = (el) => {
|
|
444
444
|
if (!el || !el.__ref || !el.node) return
|
package/keys.js
CHANGED
|
@@ -6,7 +6,7 @@ export const resetKeys = () => {
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Recursively assigns `data-br` attributes to all element nodes.
|
|
9
|
-
* These keys allow qsql to remap static HTML back onto
|
|
9
|
+
* These keys allow qsql to remap static HTML back onto DOMQL elements.
|
|
10
10
|
*/
|
|
11
11
|
export const assignKeys = (node) => {
|
|
12
12
|
if (!node) return
|
|
@@ -25,8 +25,8 @@ export const assignKeys = (node) => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Walks a
|
|
29
|
-
* mapping data-br keys to
|
|
28
|
+
* Walks a DOMQL element tree and builds a registry
|
|
29
|
+
* mapping data-br keys to DOMQL elements.
|
|
30
30
|
*/
|
|
31
31
|
export const mapKeysToElements = (element, registry = {}) => {
|
|
32
32
|
if (!element) return registry
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/brender",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.8",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dev:rita": "node examples/serve-rita.js"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@symbo.ls/helmet": "^3.6.
|
|
39
|
+
"@symbo.ls/helmet": "^3.6.8",
|
|
40
40
|
"linkedom": "^0.16.8"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
package/render.js
CHANGED
|
@@ -291,10 +291,10 @@ const UIKIT_STUBS = {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
/**
|
|
294
|
-
* Renders a Symbols/
|
|
294
|
+
* Renders a Symbols/DOMQL project to HTML on the server.
|
|
295
295
|
*
|
|
296
296
|
* Accepts project data as a plain object (matching what ProjectDataService provides)
|
|
297
|
-
* or as a pre-loaded smbls context. Runs
|
|
297
|
+
* or as a pre-loaded smbls context. Runs DOMQL in a linkedom virtual DOM,
|
|
298
298
|
* assigns data-br keys for hydration, and extracts page metadata for SEO.
|
|
299
299
|
*
|
|
300
300
|
* @param {object} data - Project data object with: pages, components, designSystem,
|
|
@@ -456,12 +456,12 @@ export const render = async (data, options = {}) => {
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
/**
|
|
459
|
-
* Renders a single
|
|
459
|
+
* Renders a single DOMQL element definition to HTML.
|
|
460
460
|
* Useful for rendering individual components without a full project.
|
|
461
461
|
*
|
|
462
|
-
* @param {object} elementDef -
|
|
462
|
+
* @param {object} elementDef - DOMQL element definition
|
|
463
463
|
* @param {object} [options]
|
|
464
|
-
* @param {object} [options.context] -
|
|
464
|
+
* @param {object} [options.context] - DOMQL context (components, designSystem, etc.)
|
|
465
465
|
* @returns {Promise<{ html: string, registry: object, element: object }>}
|
|
466
466
|
*/
|
|
467
467
|
export const renderElement = async (elementDef, options = {}) => {
|