@symbo.ls/brender 3.14.0 → 3.14.2

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.
@@ -1,554 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var hydrate_exports = {};
19
- __export(hydrate_exports, {
20
- collectBrNodes: () => collectBrNodes,
21
- hydrate: () => hydrate
22
- });
23
- module.exports = __toCommonJS(hydrate_exports);
24
- const collectBrNodes = (root) => {
25
- const container = root || document;
26
- const nodes = container.querySelectorAll("[data-br]");
27
- const map = {};
28
- nodes.forEach((node) => {
29
- map[node.getAttribute("data-br")] = node;
30
- });
31
- return map;
32
- };
33
- const hydrate = (element, options = {}) => {
34
- const {
35
- root,
36
- events: attachEvents = true,
37
- renderEvents: fireRenderEvents = true,
38
- emotion,
39
- designSystem
40
- } = options;
41
- const brNodes = collectBrNodes(root);
42
- const colorMap = designSystem?.color || {};
43
- const mediaMap = designSystem?.media || {};
44
- let linked = 0;
45
- let unlinked = 0;
46
- const walk = (el) => {
47
- if (!el || !el.__ref) return;
48
- const brKey = el.__ref.__brKey;
49
- if (brKey) {
50
- const node = brNodes[brKey];
51
- if (node) {
52
- el.node = node;
53
- node.ref = el;
54
- if (emotion) {
55
- renderCSS(el, emotion, colorMap, mediaMap);
56
- }
57
- if (attachEvents) {
58
- bindEvents(el);
59
- }
60
- linked++;
61
- } else {
62
- unlinked++;
63
- }
64
- }
65
- if (el.__ref.__children) {
66
- for (const childKey of el.__ref.__children) {
67
- const child = el[childKey];
68
- if (child && child.__ref) walk(child);
69
- }
70
- }
71
- };
72
- walk(element);
73
- if (fireRenderEvents) {
74
- fireLifecycle(element);
75
- }
76
- return { element, linked, unlinked };
77
- };
78
- const renderCSS = (el, emotion, colorMap, mediaMap) => {
79
- const { node } = el;
80
- if (!node) return;
81
- const css = {};
82
- let hasCss = false;
83
- for (const key in el) {
84
- const val = el[key];
85
- if (key.charCodeAt(0) === 64) {
86
- const breakpoint = mediaMap[key.slice(1)];
87
- if (breakpoint && typeof val === "object") {
88
- const mediaCss = resolvePropsToCSS(val, colorMap);
89
- if (Object.keys(mediaCss).length) {
90
- css[breakpoint] = mediaCss;
91
- hasCss = true;
92
- }
93
- }
94
- continue;
95
- }
96
- if (key.charCodeAt(0) === 58) {
97
- if (typeof val === "object") {
98
- const pseudoCss = resolvePropsToCSS(val, colorMap);
99
- if (Object.keys(pseudoCss).length) {
100
- css["&" + key] = pseudoCss;
101
- hasCss = true;
102
- }
103
- }
104
- continue;
105
- }
106
- const expanded = resolveShorthand(key, val);
107
- if (expanded) {
108
- for (const ek in expanded) {
109
- css[ek] = resolveValue(ek, expanded[ek], colorMap);
110
- }
111
- hasCss = true;
112
- continue;
113
- }
114
- if (!isCSS(key)) continue;
115
- css[key] = resolveValue(key, val, colorMap);
116
- hasCss = true;
117
- }
118
- const extsCss = getExtendsCSS(el);
119
- if (extsCss) {
120
- for (const [k, v] of Object.entries(extsCss)) {
121
- if (!css[k]) {
122
- css[k] = v;
123
- hasCss = true;
124
- }
125
- }
126
- }
127
- if (el.style && typeof el.style === "object") {
128
- Object.assign(css, el.style);
129
- hasCss = true;
130
- }
131
- if (!hasCss) return;
132
- const emotionClass = emotion.css(css);
133
- const classes = [];
134
- if (emotionClass) classes.push(emotionClass);
135
- if (typeof el.key === "string" && el.key.charCodeAt(0) === 95 && el.key.charCodeAt(1) !== 95) {
136
- classes.push(el.key.slice(1));
137
- }
138
- if (el.class) classes.push(el.class);
139
- if (el.attr?.class) classes.push(el.attr.class);
140
- const classlist = el.classlist;
141
- if (classlist) {
142
- if (typeof classlist === "string") classes.push(classlist);
143
- else if (typeof classlist === "object") {
144
- for (const k in classlist) {
145
- const v = classlist[k];
146
- if (typeof v === "boolean" && v) classes.push(k);
147
- else if (typeof v === "string") classes.push(v);
148
- else if (typeof v === "object" && v) classes.push(emotion.css(v));
149
- }
150
- }
151
- }
152
- if (classes.length) {
153
- node.setAttribute("class", classes.join(" "));
154
- }
155
- for (const key in el) {
156
- if (isCSS(key) && node.hasAttribute(key)) {
157
- node.removeAttribute(key);
158
- }
159
- }
160
- };
161
- const resolvePropsToCSS = (propsObj, colorMap) => {
162
- const css = {};
163
- for (const key in propsObj) {
164
- const expanded = resolveShorthand(key, propsObj[key]);
165
- if (expanded) {
166
- for (const ek in expanded) css[ek] = resolveValue(ek, expanded[ek], colorMap);
167
- continue;
168
- }
169
- if (!isCSS(key)) continue;
170
- css[key] = resolveValue(key, propsObj[key], colorMap);
171
- }
172
- return css;
173
- };
174
- const COLOR_PROPS = /* @__PURE__ */ new Set([
175
- "color",
176
- "background",
177
- "backgroundColor",
178
- "borderColor",
179
- "borderTopColor",
180
- "borderRightColor",
181
- "borderBottomColor",
182
- "borderLeftColor",
183
- "outlineColor",
184
- "fill",
185
- "stroke",
186
- "caretColor",
187
- "columnRuleColor",
188
- "textDecorationColor",
189
- "boxShadow",
190
- "textShadow"
191
- ]);
192
- const resolveValue = (key, val, colorMap) => {
193
- if (typeof val !== "string") return val;
194
- if (COLOR_PROPS.has(key) && colorMap[val]) return colorMap[val];
195
- return val;
196
- };
197
- const NON_CSS_PROPS = /* @__PURE__ */ new Set([
198
- "href",
199
- "src",
200
- "alt",
201
- "title",
202
- "id",
203
- "name",
204
- "type",
205
- "value",
206
- "placeholder",
207
- "target",
208
- "rel",
209
- "loading",
210
- "srcset",
211
- "sizes",
212
- "media",
213
- "role",
214
- "tabindex",
215
- "for",
216
- "action",
217
- "method",
218
- "enctype",
219
- "autocomplete",
220
- "autofocus",
221
- "theme",
222
- "__element",
223
- "update"
224
- ]);
225
- const EXTENDS_CSS = {
226
- Flex: { display: "flex" },
227
- InlineFlex: { display: "inline-flex" },
228
- Grid: { display: "grid" },
229
- InlineGrid: { display: "inline-grid" },
230
- Block: { display: "block" },
231
- Inline: { display: "inline" }
232
- };
233
- const getExtendsCSS = (el) => {
234
- const exts = el.__ref?.__extends;
235
- if (!exts || !Array.isArray(exts)) return null;
236
- for (const ext of exts) {
237
- if (EXTENDS_CSS[ext]) return EXTENDS_CSS[ext];
238
- }
239
- return null;
240
- };
241
- const resolveShorthand = (key, val) => {
242
- if (typeof val === "undefined" || val === null) return null;
243
- if (key === "flow" && typeof val === "string") {
244
- let [direction, wrap] = (val || "row").split(" ");
245
- if (val.startsWith("x") || val === "row") direction = "row";
246
- if (val.startsWith("y") || val === "column") direction = "column";
247
- return { display: "flex", flexFlow: (direction || "") + " " + (wrap || "") };
248
- }
249
- if (key === "wrap") {
250
- return { display: "flex", flexWrap: val };
251
- }
252
- if ((key === "align" || key === "flexAlign") && typeof val === "string") {
253
- const [alignItems, justifyContent] = val.split(" ");
254
- return { display: "flex", alignItems, justifyContent };
255
- }
256
- if (key === "gridAlign" && typeof val === "string") {
257
- const [alignItems, justifyContent] = val.split(" ");
258
- return { display: "grid", alignItems, justifyContent };
259
- }
260
- if (key === "flexFlow" && typeof val === "string") {
261
- let [direction, wrap] = (val || "row").split(" ");
262
- if (val.startsWith("x") || val === "row") direction = "row";
263
- if (val.startsWith("y") || val === "column") direction = "column";
264
- return { display: "flex", flexFlow: (direction || "") + " " + (wrap || "") };
265
- }
266
- if (key === "flexWrap") {
267
- return { display: "flex", flexWrap: val };
268
- }
269
- if (key === "round" || key === "borderRadius" && val) {
270
- return { borderRadius: typeof val === "number" ? val + "px" : val };
271
- }
272
- if (key === "boxSize" && typeof val === "string") {
273
- const [height, width] = val.split(" ");
274
- return { height, width: width || height };
275
- }
276
- if (key === "widthRange" && typeof val === "string") {
277
- const [minWidth, maxWidth] = val.split(" ");
278
- return { minWidth, maxWidth: maxWidth || minWidth };
279
- }
280
- if (key === "heightRange" && typeof val === "string") {
281
- const [minHeight, maxHeight] = val.split(" ");
282
- return { minHeight, maxHeight: maxHeight || minHeight };
283
- }
284
- if (key === "column") return { gridColumn: val };
285
- if (key === "columns") return { gridTemplateColumns: val };
286
- if (key === "templateColumns") return { gridTemplateColumns: val };
287
- if (key === "row") return { gridRow: val };
288
- if (key === "rows") return { gridTemplateRows: val };
289
- if (key === "templateRows") return { gridTemplateRows: val };
290
- if (key === "area") return { gridArea: val };
291
- if (key === "template") return { gridTemplate: val };
292
- if (key === "templateAreas") return { gridTemplateAreas: val };
293
- if (key === "autoColumns") return { gridAutoColumns: val };
294
- if (key === "autoRows") return { gridAutoRows: val };
295
- if (key === "autoFlow") return { gridAutoFlow: val };
296
- if (key === "columnStart") return { gridColumnStart: val };
297
- if (key === "rowStart") return { gridRowStart: val };
298
- return null;
299
- };
300
- const isCSS = (key) => {
301
- const ch = key.charCodeAt(0);
302
- if (ch === 95 || ch === 64 || ch === 58) return false;
303
- if (ch >= 65 && ch <= 90) return false;
304
- if (NON_CSS_PROPS.has(key)) return false;
305
- return CSS_PROPERTIES.has(key);
306
- };
307
- const CSS_PROPERTIES = /* @__PURE__ */ new Set([
308
- "display",
309
- "position",
310
- "top",
311
- "right",
312
- "bottom",
313
- "left",
314
- "width",
315
- "height",
316
- "minWidth",
317
- "maxWidth",
318
- "minHeight",
319
- "maxHeight",
320
- "margin",
321
- "marginTop",
322
- "marginRight",
323
- "marginBottom",
324
- "marginLeft",
325
- "marginBlock",
326
- "marginInline",
327
- "padding",
328
- "paddingTop",
329
- "paddingRight",
330
- "paddingBottom",
331
- "paddingLeft",
332
- "paddingBlock",
333
- "paddingInline",
334
- "border",
335
- "borderTop",
336
- "borderRight",
337
- "borderBottom",
338
- "borderLeft",
339
- "borderRadius",
340
- "borderColor",
341
- "borderWidth",
342
- "borderStyle",
343
- "borderTopWidth",
344
- "borderRightWidth",
345
- "borderBottomWidth",
346
- "borderLeftWidth",
347
- "borderTopStyle",
348
- "borderRightStyle",
349
- "borderBottomStyle",
350
- "borderLeftStyle",
351
- "borderTopColor",
352
- "borderRightColor",
353
- "borderBottomColor",
354
- "borderLeftColor",
355
- "borderTopLeftRadius",
356
- "borderTopRightRadius",
357
- "borderBottomLeftRadius",
358
- "borderBottomRightRadius",
359
- "background",
360
- "backgroundColor",
361
- "backgroundImage",
362
- "backgroundSize",
363
- "backgroundPosition",
364
- "backgroundRepeat",
365
- "backgroundAttachment",
366
- "color",
367
- "fontSize",
368
- "fontWeight",
369
- "fontFamily",
370
- "fontStyle",
371
- "lineHeight",
372
- "letterSpacing",
373
- "textAlign",
374
- "textDecoration",
375
- "textTransform",
376
- "textIndent",
377
- "textOverflow",
378
- "textShadow",
379
- "opacity",
380
- "overflow",
381
- "overflowX",
382
- "overflowY",
383
- "zIndex",
384
- "cursor",
385
- "pointerEvents",
386
- "userSelect",
387
- "flex",
388
- "flexDirection",
389
- "flexWrap",
390
- "flexFlow",
391
- "flexGrow",
392
- "flexShrink",
393
- "flexBasis",
394
- "alignItems",
395
- "alignContent",
396
- "alignSelf",
397
- "justifyContent",
398
- "justifyItems",
399
- "justifySelf",
400
- "gap",
401
- "rowGap",
402
- "columnGap",
403
- "gridTemplateColumns",
404
- "gridTemplateRows",
405
- "gridColumn",
406
- "gridRow",
407
- "gridArea",
408
- "gridAutoFlow",
409
- "gridAutoColumns",
410
- "gridAutoRows",
411
- "inset",
412
- "inlineSize",
413
- "blockSize",
414
- "minInlineSize",
415
- "maxInlineSize",
416
- "minBlockSize",
417
- "maxBlockSize",
418
- "paddingBlockStart",
419
- "paddingBlockEnd",
420
- "paddingInlineStart",
421
- "paddingInlineEnd",
422
- "marginBlockStart",
423
- "marginBlockEnd",
424
- "marginInlineStart",
425
- "marginInlineEnd",
426
- "transform",
427
- "transformOrigin",
428
- "transition",
429
- "animation",
430
- "animationName",
431
- "animationDuration",
432
- "animationDelay",
433
- "animationTimingFunction",
434
- "animationFillMode",
435
- "animationIterationCount",
436
- "animationPlayState",
437
- "animationDirection",
438
- "gridTemplate",
439
- "gridTemplateAreas",
440
- "gridColumnStart",
441
- "gridRowStart",
442
- "boxShadow",
443
- "outline",
444
- "outlineColor",
445
- "outlineWidth",
446
- "outlineStyle",
447
- "outlineOffset",
448
- "whiteSpace",
449
- "wordBreak",
450
- "wordWrap",
451
- "overflowWrap",
452
- "visibility",
453
- "boxSizing",
454
- "objectFit",
455
- "objectPosition",
456
- "filter",
457
- "backdropFilter",
458
- "mixBlendMode",
459
- "fill",
460
- "stroke",
461
- "strokeWidth",
462
- "listStyle",
463
- "listStyleType",
464
- "listStylePosition",
465
- "counterReset",
466
- "counterIncrement",
467
- "content",
468
- "aspectRatio",
469
- "resize",
470
- "appearance",
471
- "scrollBehavior",
472
- "scrollMargin",
473
- "scrollPadding",
474
- "willChange",
475
- "contain",
476
- "isolation",
477
- "caretColor",
478
- "accentColor",
479
- "columnCount",
480
- "columnGap",
481
- "columnRuleColor",
482
- "columnRuleStyle",
483
- "columnRuleWidth",
484
- "textDecorationColor",
485
- "textDecorationStyle",
486
- "textDecorationThickness",
487
- "clipPath",
488
- "shapeOutside"
489
- ]);
490
- const DOMQL_LIFECYCLE = /* @__PURE__ */ new Set([
491
- "render",
492
- "create",
493
- "init",
494
- "start",
495
- "complete",
496
- "done",
497
- "beforeClassAssign",
498
- "attachNode",
499
- "stateInit",
500
- "stateCreated",
501
- "renderRouter",
502
- "lazyLoad",
503
- "error"
504
- ]);
505
- const bindEvents = (el) => {
506
- const { node } = el;
507
- if (!node) return;
508
- if (!el.__ref.__eventCleanup) el.__ref.__eventCleanup = [];
509
- for (const key in el) {
510
- if (key.length <= 2 || key[0] !== "o" || key[1] !== "n") continue;
511
- if (typeof el[key] !== "function") continue;
512
- const third = key[2];
513
- if (third !== third.toUpperCase()) continue;
514
- const eventName = third.toLowerCase() + key.slice(3);
515
- if (DOMQL_LIFECYCLE.has(eventName)) continue;
516
- addListener(node, eventName, el[key], el);
517
- }
518
- };
519
- const addListener = (node, eventName, handler, el) => {
520
- const listener = (event) => {
521
- try {
522
- handler.call(el, event, el, el.state, el.context);
523
- } catch (e) {
524
- console.warn("[brender hydrate]", eventName, e.message);
525
- }
526
- };
527
- node.addEventListener(eventName, listener);
528
- el.__ref.__eventCleanup.push(() => node.removeEventListener(eventName, listener));
529
- };
530
- const fireLifecycle = (el) => {
531
- if (!el || !el.__ref || !el.node) return;
532
- fireEvent(el.onRender, el);
533
- fireEvent(el.onRenderRouter, el);
534
- fireEvent(el.onDone, el);
535
- fireEvent(el.onCreate, el);
536
- if (el.__ref.__children) {
537
- for (const childKey of el.__ref.__children) {
538
- const child = el[childKey];
539
- if (child && child.__ref) fireLifecycle(child);
540
- }
541
- }
542
- };
543
- const fireEvent = (fn, el) => {
544
- if (typeof fn !== "function") return;
545
- try {
546
- const result = fn.call(el, el, el.state, el.context);
547
- if (result && typeof result.then === "function") {
548
- result.catch(() => {
549
- });
550
- }
551
- } catch (e) {
552
- console.warn("[brender hydrate]", el.key, e.message);
553
- }
554
- };
package/dist/cjs/index.js DELETED
@@ -1,72 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var index_exports = {};
19
- __export(index_exports, {
20
- assignKeys: () => import_keys.assignKeys,
21
- collectBrNodes: () => import_hydrate.collectBrNodes,
22
- createEnv: () => import_env.createEnv,
23
- default: () => index_default,
24
- extractMetadata: () => import_metadata.extractMetadata,
25
- generateHeadHtml: () => import_metadata.generateHeadHtml,
26
- generateSitemap: () => import_sitemap.generateSitemap,
27
- getAccumulatedEmotionCSS: () => import_render.getAccumulatedEmotionCSS,
28
- hydrate: () => import_hydrate.hydrate,
29
- injectPrefetchedState: () => import_prefetch.injectPrefetchedState,
30
- loadAndRenderAll: () => import_load.loadAndRenderAll,
31
- loadProject: () => import_load.loadProject,
32
- mapKeysToElements: () => import_keys.mapKeysToElements,
33
- prefetchPageData: () => import_prefetch.prefetchPageData,
34
- render: () => import_render.render,
35
- renderElement: () => import_render.renderElement,
36
- renderPage: () => import_render.renderPage,
37
- renderRoute: () => import_render.renderRoute,
38
- replaceEmotionCSS: () => import_render.replaceEmotionCSS,
39
- resetGlobalCSSCache: () => import_render.resetGlobalCSSCache,
40
- resetKeys: () => import_keys.resetKeys
41
- });
42
- module.exports = __toCommonJS(index_exports);
43
- var import_env = require("./env.js");
44
- var import_keys = require("./keys.js");
45
- var import_load = require("./load.js");
46
- var import_render = require("./render.js");
47
- var import_metadata = require("./metadata.js");
48
- var import_hydrate = require("./hydrate.js");
49
- var import_sitemap = require("./sitemap.js");
50
- var import_prefetch = require("./prefetch.js");
51
- var index_default = {
52
- createEnv: import_env.createEnv,
53
- resetKeys: import_keys.resetKeys,
54
- assignKeys: import_keys.assignKeys,
55
- mapKeysToElements: import_keys.mapKeysToElements,
56
- loadProject: import_load.loadProject,
57
- loadAndRenderAll: import_load.loadAndRenderAll,
58
- render: import_render.render,
59
- renderElement: import_render.renderElement,
60
- renderRoute: import_render.renderRoute,
61
- renderPage: import_render.renderPage,
62
- resetGlobalCSSCache: import_render.resetGlobalCSSCache,
63
- getAccumulatedEmotionCSS: import_render.getAccumulatedEmotionCSS,
64
- replaceEmotionCSS: import_render.replaceEmotionCSS,
65
- extractMetadata: import_metadata.extractMetadata,
66
- generateHeadHtml: import_metadata.generateHeadHtml,
67
- collectBrNodes: import_hydrate.collectBrNodes,
68
- hydrate: import_hydrate.hydrate,
69
- generateSitemap: import_sitemap.generateSitemap,
70
- prefetchPageData: import_prefetch.prefetchPageData,
71
- injectPrefetchedState: import_prefetch.injectPrefetchedState
72
- };
package/dist/cjs/keys.js DELETED
@@ -1,62 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var keys_exports = {};
19
- __export(keys_exports, {
20
- assignKeys: () => assignKeys,
21
- mapKeysToElements: () => mapKeysToElements,
22
- resetKeys: () => resetKeys
23
- });
24
- module.exports = __toCommonJS(keys_exports);
25
- let _keyCounter = 0;
26
- const resetKeys = () => {
27
- _keyCounter = 0;
28
- };
29
- const assignKeys = (node) => {
30
- if (!node) return;
31
- if (node.nodeType === 1) {
32
- const key = `br-${_keyCounter++}`;
33
- node.setAttribute("data-br", key);
34
- }
35
- const children = node.childNodes;
36
- if (children) {
37
- for (let i = 0; i < children.length; i++) {
38
- assignKeys(children[i]);
39
- }
40
- }
41
- };
42
- const mapKeysToElements = (element, registry = {}) => {
43
- if (!element) return registry;
44
- const node = element.node;
45
- if (node && node.getAttribute) {
46
- const brKey = node.getAttribute("data-br");
47
- if (brKey) {
48
- if (!element.__ref) element.__ref = {};
49
- element.__ref.__brKey = brKey;
50
- registry[brKey] = element;
51
- }
52
- }
53
- if (element.__ref && element.__ref.__children) {
54
- for (const childKey of element.__ref.__children) {
55
- const child = element[childKey];
56
- if (child && child.__ref) {
57
- mapKeysToElements(child, registry);
58
- }
59
- }
60
- }
61
- return registry;
62
- };