@symbo.ls/brender 3.4.11 → 3.5.1

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.
@@ -39,6 +39,61 @@ var import_metadata = require("./metadata.js");
39
39
  var import_hydrate = require("./hydrate.js");
40
40
  var import_linkedom = require("linkedom");
41
41
  const import_meta = {};
42
+ const UIKIT_STUBS = {
43
+ Box: {},
44
+ Focusable: {},
45
+ Block: { display: "block" },
46
+ Inline: { display: "inline" },
47
+ Flex: { display: "flex" },
48
+ InlineFlex: { display: "inline-flex" },
49
+ Grid: { display: "grid" },
50
+ InlineGrid: { display: "inline-grid" },
51
+ Link: {
52
+ tag: "a",
53
+ attr: {
54
+ href: (el) => el.props?.href,
55
+ target: (el) => el.props?.target,
56
+ rel: (el) => el.props?.rel
57
+ }
58
+ },
59
+ A: { extends: "Link" },
60
+ RouteLink: { extends: "Link" },
61
+ Img: {
62
+ tag: "img",
63
+ attr: {
64
+ src: (el) => {
65
+ let src = el.props?.src;
66
+ if (typeof src === "string" && src.includes("{{")) {
67
+ src = el.call("replaceLiteralsWithObjectFields", src, el.state);
68
+ }
69
+ return src;
70
+ },
71
+ alt: (el) => el.props?.alt,
72
+ loading: (el) => el.props?.loading
73
+ }
74
+ },
75
+ Image: { extends: "Img" },
76
+ Button: { tag: "button" },
77
+ FocusableComponent: { tag: "button" },
78
+ Form: { tag: "form" },
79
+ Input: { tag: "input" },
80
+ TextArea: { tag: "textarea" },
81
+ Textarea: { tag: "textarea" },
82
+ Select: { tag: "select" },
83
+ Label: { tag: "label" },
84
+ Iframe: { tag: "iframe" },
85
+ Video: { tag: "video" },
86
+ Audio: { tag: "audio" },
87
+ Canvas: { tag: "canvas" },
88
+ Span: { tag: "span" },
89
+ P: { tag: "p" },
90
+ H1: { tag: "h1" },
91
+ H2: { tag: "h2" },
92
+ H3: { tag: "h3" },
93
+ H4: { tag: "h4" },
94
+ H5: { tag: "h5" },
95
+ H6: { tag: "h6" }
96
+ };
42
97
  const render = async (data, options = {}) => {
43
98
  const { route = "/", state: stateOverrides, context: contextOverrides } = options;
44
99
  const { window, document } = (0, import_env.createEnv)();
@@ -78,12 +133,23 @@ const renderElement = async (elementDef, options = {}) => {
78
133
  const { window, document } = (0, import_env.createEnv)();
79
134
  const body = document.body;
80
135
  const { create } = await import("@domql/element");
136
+ const domqlUtils = await import("@domql/utils");
137
+ const components = { ...UIKIT_STUBS, ...context.components || {} };
138
+ const utils = {
139
+ ...domqlUtils,
140
+ ...context.utils || {},
141
+ ...context.functions || {}
142
+ };
81
143
  (0, import_keys.resetKeys)();
82
- const element = create(elementDef, { node: body }, "root", {
83
- context: { document, window, ...context }
84
- });
144
+ let element;
145
+ try {
146
+ element = create(elementDef, { node: body }, "root", {
147
+ context: { document, window, ...context, components, utils }
148
+ });
149
+ } catch (err) {
150
+ }
85
151
  (0, import_keys.assignKeys)(body);
86
- const registry = (0, import_keys.mapKeysToElements)(element);
152
+ const registry = element ? (0, import_keys.mapKeysToElements)(element) : {};
87
153
  const html = body.innerHTML;
88
154
  return { html, registry, element };
89
155
  };
@@ -148,6 +214,138 @@ ${result.html}
148
214
  </html>`;
149
215
  return { html, route, brKeyCount: result.brKeyCount };
150
216
  };
217
+ const LETTER_TO_INDEX = {
218
+ U: -6,
219
+ V: -5,
220
+ W: -4,
221
+ X: -3,
222
+ Y: -2,
223
+ Z: -1,
224
+ A: 0,
225
+ B: 1,
226
+ C: 2,
227
+ D: 3,
228
+ E: 4,
229
+ F: 5,
230
+ G: 6,
231
+ H: 7,
232
+ I: 8,
233
+ J: 9,
234
+ K: 10,
235
+ L: 11,
236
+ M: 12,
237
+ N: 13,
238
+ O: 14,
239
+ P: 15
240
+ };
241
+ const SPACING_PROPS = /* @__PURE__ */ new Set([
242
+ "padding",
243
+ "paddingTop",
244
+ "paddingRight",
245
+ "paddingBottom",
246
+ "paddingLeft",
247
+ "paddingBlock",
248
+ "paddingInline",
249
+ "paddingBlockStart",
250
+ "paddingBlockEnd",
251
+ "paddingInlineStart",
252
+ "paddingInlineEnd",
253
+ "margin",
254
+ "marginTop",
255
+ "marginRight",
256
+ "marginBottom",
257
+ "marginLeft",
258
+ "marginBlock",
259
+ "marginInline",
260
+ "marginBlockStart",
261
+ "marginBlockEnd",
262
+ "marginInlineStart",
263
+ "marginInlineEnd",
264
+ "gap",
265
+ "rowGap",
266
+ "columnGap",
267
+ "top",
268
+ "right",
269
+ "bottom",
270
+ "left",
271
+ "width",
272
+ "height",
273
+ "minWidth",
274
+ "maxWidth",
275
+ "minHeight",
276
+ "maxHeight",
277
+ "flexBasis",
278
+ "fontSize",
279
+ "lineHeight",
280
+ "letterSpacing",
281
+ "borderWidth",
282
+ "borderRadius",
283
+ "outlineWidth",
284
+ "outlineOffset",
285
+ "inset",
286
+ "insetBlock",
287
+ "insetInline",
288
+ "boxSize",
289
+ "round"
290
+ ]);
291
+ const resolveSpacingToken = (token, spacingConfig) => {
292
+ if (!token || typeof token !== "string") return null;
293
+ if (!spacingConfig) return null;
294
+ const base = spacingConfig.base || 16;
295
+ const ratio = spacingConfig.ratio || 1.618;
296
+ const unit = spacingConfig.unit || "px";
297
+ const hasSubSequence = spacingConfig.subSequence !== false;
298
+ if (token.includes(" ")) {
299
+ const parts = token.split(" ").map((part) => {
300
+ if (part === "-" || part === "") return part;
301
+ return resolveSpacingToken(part, spacingConfig) || part;
302
+ });
303
+ return parts.join(" ");
304
+ }
305
+ if (/^(none|auto|inherit|initial|unset|0)$/i.test(token)) return null;
306
+ if (/\d+(px|em|rem|%|vh|vw|vmin|vmax|ch|ex|cm|mm|in|pt|pc|fr|s|ms)$/i.test(token)) return null;
307
+ if (/^(#|rgb|hsl|var\()/i.test(token)) return null;
308
+ const isNegative = token.startsWith("-");
309
+ const abs = isNegative ? token.slice(1) : token;
310
+ const m = abs.match(/^([A-Z])(\d)?$/i);
311
+ if (!m) return null;
312
+ const letter = m[1].toUpperCase();
313
+ const subStep = m[2] ? parseInt(m[2]) : 0;
314
+ const idx = LETTER_TO_INDEX[letter];
315
+ if (idx === void 0) return null;
316
+ let value = base * Math.pow(ratio, idx);
317
+ if (subStep > 0 && hasSubSequence) {
318
+ const next = base * Math.pow(ratio, idx + 1);
319
+ const diff = next - value;
320
+ const subRatio = diff / ratio;
321
+ const first = next - subRatio;
322
+ const second = value + subRatio;
323
+ const middle = (first + second) / 2;
324
+ const subs = ~~next - ~~value > 16 ? [first, middle, second] : [first, second];
325
+ if (subStep <= subs.length) {
326
+ value = subs[subStep - 1];
327
+ }
328
+ }
329
+ const rounded = Math.round(value * 100) / 100;
330
+ const sign = isNegative ? "-" : "";
331
+ return `${sign}${rounded}${unit}`;
332
+ };
333
+ const SPACING_PROPS_KEBAB = new Set(
334
+ [...SPACING_PROPS].map((k) => k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()))
335
+ );
336
+ const resolveDSValue = (key, val, ds) => {
337
+ if (typeof val !== "string") return val;
338
+ if (CSS_COLOR_PROPS.has(key)) {
339
+ const colorMap = ds?.color || {};
340
+ if (colorMap[val]) return colorMap[val];
341
+ }
342
+ if (SPACING_PROPS.has(key) || SPACING_PROPS_KEBAB.has(key)) {
343
+ const spacing = ds?.spacing || {};
344
+ const resolved = resolveSpacingToken(val, spacing);
345
+ if (resolved) return resolved;
346
+ }
347
+ return val;
348
+ };
151
349
  const CSS_COLOR_PROPS = /* @__PURE__ */ new Set([
152
350
  "color",
153
351
  "background",
@@ -187,41 +385,96 @@ const NON_CSS_PROPS = /* @__PURE__ */ new Set([
187
385
  "autofocus",
188
386
  "theme",
189
387
  "__element",
190
- "update"
388
+ "update",
389
+ "childrenAs",
390
+ "childExtends",
391
+ "childProps",
392
+ "children"
191
393
  ]);
192
394
  const camelToKebab = (str) => str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
193
395
  const resolveShorthand = (key, val) => {
194
- if (key === "flexAlign" && typeof val === "string") {
396
+ if (typeof val === "undefined" || val === null) return null;
397
+ if (key === "flow" && typeof val === "string") {
398
+ let [direction, wrap] = (val || "row").split(" ");
399
+ if (val.startsWith("x") || val === "row") direction = "row";
400
+ if (val.startsWith("y") || val === "column") direction = "column";
401
+ return { display: "flex", "flex-flow": (direction || "") + " " + (wrap || "") };
402
+ }
403
+ if (key === "wrap") {
404
+ return { display: "flex", "flex-wrap": val };
405
+ }
406
+ if ((key === "align" || key === "flexAlign") && typeof val === "string") {
195
407
  const [alignItems, justifyContent] = val.split(" ");
196
- return { display: "flex", "align-items": alignItems, "justify-content": justifyContent };
408
+ const result = { display: "flex", "align-items": alignItems };
409
+ if (justifyContent) result["justify-content"] = justifyContent;
410
+ return result;
197
411
  }
198
412
  if (key === "gridAlign" && typeof val === "string") {
199
413
  const [alignItems, justifyContent] = val.split(" ");
200
- return { display: "grid", "align-items": alignItems, "justify-content": justifyContent };
414
+ const result = { display: "grid", "align-items": alignItems };
415
+ if (justifyContent) result["justify-content"] = justifyContent;
416
+ return result;
201
417
  }
202
- if (key === "round" && val) {
418
+ if (key === "flexFlow" && typeof val === "string") {
419
+ let [direction, wrap] = (val || "row").split(" ");
420
+ if (val.startsWith("x") || val === "row") direction = "row";
421
+ if (val.startsWith("y") || val === "column") direction = "column";
422
+ return { display: "flex", "flex-flow": (direction || "") + " " + (wrap || "") };
423
+ }
424
+ if (key === "flexWrap") {
425
+ return { display: "flex", "flex-wrap": val };
426
+ }
427
+ if (key === "backgroundImage" && typeof val === "string" && !val.startsWith("url(") && !val.startsWith("linear-gradient") && !val.startsWith("radial-gradient") && !val.startsWith("none")) {
428
+ return { "background-image": `url(${val})` };
429
+ }
430
+ if (key === "round" || key === "borderRadius" && val) {
203
431
  return { "border-radius": typeof val === "number" ? val + "px" : val };
204
432
  }
205
- if (key === "boxSize" && val) {
206
- return { width: val, height: val };
433
+ if (key === "boxSize" && typeof val === "string") {
434
+ const [height, width] = val.split(" ");
435
+ return { height, width: width || height };
436
+ }
437
+ if (key === "widthRange" && typeof val === "string") {
438
+ const [minWidth, maxWidth] = val.split(" ");
439
+ return { "min-width": minWidth, "max-width": maxWidth || minWidth };
207
440
  }
441
+ if (key === "heightRange" && typeof val === "string") {
442
+ const [minHeight, maxHeight] = val.split(" ");
443
+ return { "min-height": minHeight, "max-height": maxHeight || minHeight };
444
+ }
445
+ if (key === "column") return { "grid-column": val };
446
+ if (key === "columns") return { "grid-template-columns": val };
447
+ if (key === "templateColumns") return { "grid-template-columns": val };
448
+ if (key === "row") return { "grid-row": val };
449
+ if (key === "rows") return { "grid-template-rows": val };
450
+ if (key === "templateRows") return { "grid-template-rows": val };
451
+ if (key === "area") return { "grid-area": val };
452
+ if (key === "template") return { "grid-template": val };
453
+ if (key === "templateAreas") return { "grid-template-areas": val };
454
+ if (key === "autoColumns") return { "grid-auto-columns": val };
455
+ if (key === "autoRows") return { "grid-auto-rows": val };
456
+ if (key === "autoFlow") return { "grid-auto-flow": val };
457
+ if (key === "columnStart") return { "grid-column-start": val };
458
+ if (key === "rowStart") return { "grid-row-start": val };
208
459
  return null;
209
460
  };
210
- const resolveInnerProps = (obj, colorMap) => {
461
+ const resolveInnerProps = (obj, ds) => {
211
462
  const result = {};
212
463
  for (const k in obj) {
213
464
  const v = obj[k];
214
465
  const expanded = resolveShorthand(k, v);
215
466
  if (expanded) {
216
- Object.assign(result, expanded);
467
+ for (const ek in expanded) {
468
+ result[ek] = resolveDSValue(ek, expanded[ek], ds);
469
+ }
217
470
  continue;
218
471
  }
219
472
  if (typeof v !== "string" && typeof v !== "number") continue;
220
- result[camelToKebab(k)] = CSS_COLOR_PROPS.has(k) && colorMap[v] ? colorMap[v] : v;
473
+ result[camelToKebab(k)] = resolveDSValue(k, v, ds);
221
474
  }
222
475
  return result;
223
476
  };
224
- const buildCSSFromProps = (props, colorMap, mediaMap) => {
477
+ const buildCSSFromProps = (props, ds, mediaMap) => {
225
478
  const base = {};
226
479
  const mediaRules = {};
227
480
  const pseudoRules = {};
@@ -230,13 +483,13 @@ const buildCSSFromProps = (props, colorMap, mediaMap) => {
230
483
  if (key.charCodeAt(0) === 64 && typeof val === "object") {
231
484
  const bp = mediaMap?.[key.slice(1)];
232
485
  if (bp) {
233
- const inner = resolveInnerProps(val, colorMap);
486
+ const inner = resolveInnerProps(val, ds);
234
487
  if (Object.keys(inner).length) mediaRules[bp] = inner;
235
488
  }
236
489
  continue;
237
490
  }
238
491
  if (key.charCodeAt(0) === 58 && typeof val === "object") {
239
- const inner = resolveInnerProps(val, colorMap);
492
+ const inner = resolveInnerProps(val, ds);
240
493
  if (Object.keys(inner).length) pseudoRules[key] = inner;
241
494
  continue;
242
495
  }
@@ -245,10 +498,12 @@ const buildCSSFromProps = (props, colorMap, mediaMap) => {
245
498
  if (NON_CSS_PROPS.has(key)) continue;
246
499
  const expanded = resolveShorthand(key, val);
247
500
  if (expanded) {
248
- Object.assign(base, expanded);
501
+ for (const ek in expanded) {
502
+ base[ek] = resolveDSValue(ek, expanded[ek], ds);
503
+ }
249
504
  continue;
250
505
  }
251
- base[camelToKebab(key)] = CSS_COLOR_PROPS.has(key) && colorMap[val] ? colorMap[val] : val;
506
+ base[camelToKebab(key)] = resolveDSValue(key, val, ds);
252
507
  }
253
508
  return { base, mediaRules, pseudoRules };
254
509
  };
@@ -267,8 +522,23 @@ const renderCSSRule = (selector, { base, mediaRules, pseudoRules }) => {
267
522
  }
268
523
  return lines.join("\n");
269
524
  };
525
+ const EXTENDS_CSS = {
526
+ Flex: { display: "flex" },
527
+ InlineFlex: { display: "inline-flex" },
528
+ Grid: { display: "grid" },
529
+ InlineGrid: { display: "inline-grid" },
530
+ Block: { display: "block" },
531
+ Inline: { display: "inline" }
532
+ };
533
+ const getExtendsCSS = (el) => {
534
+ const exts = el.__ref?.__extends;
535
+ if (!exts || !Array.isArray(exts)) return null;
536
+ for (const ext of exts) {
537
+ if (EXTENDS_CSS[ext]) return EXTENDS_CSS[ext];
538
+ }
539
+ return null;
540
+ };
270
541
  const extractCSS = (element, ds) => {
271
- const colorMap = ds?.color || {};
272
542
  const mediaMap = ds?.media || {};
273
543
  const animations = ds?.animation || {};
274
544
  const rules = [];
@@ -281,7 +551,14 @@ const extractCSS = (element, ds) => {
281
551
  const cls = el.node.getAttribute?.("class");
282
552
  if (cls && !seen.has(cls)) {
283
553
  seen.add(cls);
284
- const cssResult = buildCSSFromProps(props, colorMap, mediaMap);
554
+ const cssResult = buildCSSFromProps(props, ds, mediaMap);
555
+ const extsCss = getExtendsCSS(el);
556
+ if (extsCss) {
557
+ for (const [k, v] of Object.entries(extsCss)) {
558
+ const kebab = camelToKebab(k);
559
+ if (!cssResult.base[kebab]) cssResult.base[kebab] = v;
560
+ }
561
+ }
285
562
  const has = Object.keys(cssResult.base).length || Object.keys(cssResult.mediaRules).length || Object.keys(cssResult.pseudoRules).length;
286
563
  if (has) rules.push(renderCSSRule("." + cls.split(" ")[0], cssResult));
287
564
  const anim = props.animation || props.animationName;
@@ -315,6 +592,7 @@ const generateResetCSS = (reset) => {
315
592
  if (!reset) return "";
316
593
  const rules = [];
317
594
  for (const [selector, props] of Object.entries(reset)) {
595
+ if (!props || typeof props !== "object") continue;
318
596
  const decls = Object.entries(props).map(([k, v]) => `${camelToKebab(k)}: ${v}`).join("; ");
319
597
  if (decls) rules.push(`${selector} { ${decls}; }`);
320
598
  }
@@ -325,6 +603,7 @@ const generateFontLinks = (ds) => {
325
603
  const families = ds.font_family || ds.fontFamily || {};
326
604
  const fontNames = /* @__PURE__ */ new Set();
327
605
  for (const val of Object.values(families)) {
606
+ if (typeof val !== "string") continue;
328
607
  const match = val.match(/'([^']+)'/);
329
608
  if (match) fontNames.add(match[1]);
330
609
  }
package/dist/esm/env.js CHANGED
@@ -26,6 +26,29 @@ const createEnv = (html = "<!DOCTYPE html><html><head></head><body></body></html
26
26
  window.scrollTo = () => {
27
27
  };
28
28
  }
29
+ const createStorage = () => {
30
+ const store = {};
31
+ return {
32
+ getItem: (k) => store[k] ?? null,
33
+ setItem: (k, v) => {
34
+ store[k] = String(v);
35
+ },
36
+ removeItem: (k) => {
37
+ delete store[k];
38
+ },
39
+ clear: () => {
40
+ for (const k in store) delete store[k];
41
+ },
42
+ get length() {
43
+ return Object.keys(store).length;
44
+ },
45
+ key: (i) => Object.keys(store)[i] ?? null
46
+ };
47
+ };
48
+ if (!window.localStorage) window.localStorage = createStorage();
49
+ if (!window.sessionStorage) window.sessionStorage = createStorage();
50
+ if (!globalThis.localStorage) globalThis.localStorage = window.localStorage;
51
+ if (!globalThis.sessionStorage) globalThis.sessionStorage = window.sessionStorage;
29
52
  globalThis.window = window;
30
53
  globalThis.document = document;
31
54
  globalThis.Node = window.Node || globalThis.Node;
@@ -92,6 +92,15 @@ const renderCSS = (el, emotion, colorMap, mediaMap) => {
92
92
  css[key] = resolveValue(key, val, colorMap);
93
93
  hasCss = true;
94
94
  }
95
+ const extsCss = getExtendsCSS(el);
96
+ if (extsCss) {
97
+ for (const [k, v] of Object.entries(extsCss)) {
98
+ if (!css[k]) {
99
+ css[k] = v;
100
+ hasCss = true;
101
+ }
102
+ }
103
+ }
95
104
  if (el.style && typeof el.style === "object") {
96
105
  Object.assign(css, el.style);
97
106
  hasCss = true;
@@ -190,8 +199,34 @@ const NON_CSS_PROPS = /* @__PURE__ */ new Set([
190
199
  "__element",
191
200
  "update"
192
201
  ]);
202
+ const EXTENDS_CSS = {
203
+ Flex: { display: "flex" },
204
+ InlineFlex: { display: "inline-flex" },
205
+ Grid: { display: "grid" },
206
+ InlineGrid: { display: "inline-grid" },
207
+ Block: { display: "block" },
208
+ Inline: { display: "inline" }
209
+ };
210
+ const getExtendsCSS = (el) => {
211
+ const exts = el.__ref?.__extends;
212
+ if (!exts || !Array.isArray(exts)) return null;
213
+ for (const ext of exts) {
214
+ if (EXTENDS_CSS[ext]) return EXTENDS_CSS[ext];
215
+ }
216
+ return null;
217
+ };
193
218
  const resolveShorthand = (key, val) => {
194
- if (key === "flexAlign" && typeof val === "string") {
219
+ if (typeof val === "undefined" || val === null) return null;
220
+ if (key === "flow" && typeof val === "string") {
221
+ let [direction, wrap] = (val || "row").split(" ");
222
+ if (val.startsWith("x") || val === "row") direction = "row";
223
+ if (val.startsWith("y") || val === "column") direction = "column";
224
+ return { display: "flex", flexFlow: (direction || "") + " " + (wrap || "") };
225
+ }
226
+ if (key === "wrap") {
227
+ return { display: "flex", flexWrap: val };
228
+ }
229
+ if ((key === "align" || key === "flexAlign") && typeof val === "string") {
195
230
  const [alignItems, justifyContent] = val.split(" ");
196
231
  return { display: "flex", alignItems, justifyContent };
197
232
  }
@@ -199,12 +234,44 @@ const resolveShorthand = (key, val) => {
199
234
  const [alignItems, justifyContent] = val.split(" ");
200
235
  return { display: "grid", alignItems, justifyContent };
201
236
  }
202
- if (key === "round" && val) {
237
+ if (key === "flexFlow" && typeof val === "string") {
238
+ let [direction, wrap] = (val || "row").split(" ");
239
+ if (val.startsWith("x") || val === "row") direction = "row";
240
+ if (val.startsWith("y") || val === "column") direction = "column";
241
+ return { display: "flex", flexFlow: (direction || "") + " " + (wrap || "") };
242
+ }
243
+ if (key === "flexWrap") {
244
+ return { display: "flex", flexWrap: val };
245
+ }
246
+ if (key === "round" || key === "borderRadius" && val) {
203
247
  return { borderRadius: typeof val === "number" ? val + "px" : val };
204
248
  }
205
- if (key === "boxSize" && val) {
206
- return { width: val, height: val };
249
+ if (key === "boxSize" && typeof val === "string") {
250
+ const [height, width] = val.split(" ");
251
+ return { height, width: width || height };
252
+ }
253
+ if (key === "widthRange" && typeof val === "string") {
254
+ const [minWidth, maxWidth] = val.split(" ");
255
+ return { minWidth, maxWidth: maxWidth || minWidth };
256
+ }
257
+ if (key === "heightRange" && typeof val === "string") {
258
+ const [minHeight, maxHeight] = val.split(" ");
259
+ return { minHeight, maxHeight: maxHeight || minHeight };
207
260
  }
261
+ if (key === "column") return { gridColumn: val };
262
+ if (key === "columns") return { gridTemplateColumns: val };
263
+ if (key === "templateColumns") return { gridTemplateColumns: val };
264
+ if (key === "row") return { gridRow: val };
265
+ if (key === "rows") return { gridTemplateRows: val };
266
+ if (key === "templateRows") return { gridTemplateRows: val };
267
+ if (key === "area") return { gridArea: val };
268
+ if (key === "template") return { gridTemplate: val };
269
+ if (key === "templateAreas") return { gridTemplateAreas: val };
270
+ if (key === "autoColumns") return { gridAutoColumns: val };
271
+ if (key === "autoRows") return { gridAutoRows: val };
272
+ if (key === "autoFlow") return { gridAutoFlow: val };
273
+ if (key === "columnStart") return { gridColumnStart: val };
274
+ if (key === "rowStart") return { gridRowStart: val };
208
275
  return null;
209
276
  };
210
277
  const isCSS = (key) => {
@@ -318,11 +385,37 @@ const CSS_PROPERTIES = /* @__PURE__ */ new Set([
318
385
  "gridAutoFlow",
319
386
  "gridAutoColumns",
320
387
  "gridAutoRows",
388
+ "inset",
389
+ "inlineSize",
390
+ "blockSize",
391
+ "minInlineSize",
392
+ "maxInlineSize",
393
+ "minBlockSize",
394
+ "maxBlockSize",
395
+ "paddingBlockStart",
396
+ "paddingBlockEnd",
397
+ "paddingInlineStart",
398
+ "paddingInlineEnd",
399
+ "marginBlockStart",
400
+ "marginBlockEnd",
401
+ "marginInlineStart",
402
+ "marginInlineEnd",
321
403
  "transform",
322
404
  "transformOrigin",
323
405
  "transition",
324
406
  "animation",
407
+ "animationName",
408
+ "animationDuration",
325
409
  "animationDelay",
410
+ "animationTimingFunction",
411
+ "animationFillMode",
412
+ "animationIterationCount",
413
+ "animationPlayState",
414
+ "animationDirection",
415
+ "gridTemplate",
416
+ "gridTemplateAreas",
417
+ "gridColumnStart",
418
+ "gridRowStart",
326
419
  "boxShadow",
327
420
  "outline",
328
421
  "outlineColor",
package/dist/esm/load.js CHANGED
@@ -1,13 +1,49 @@
1
1
  import { resolve, join } from "path";
2
- const loadProject = async (projectPath) => {
3
- const symbolsDir = resolve(projectPath, "symbols");
4
- const tryImport = async (modulePath) => {
2
+ import { existsSync, mkdirSync, writeFileSync, unlinkSync } from "fs";
3
+ import { tmpdir } from "os";
4
+ import { randomBytes } from "crypto";
5
+ const bundleAndImport = async (entryPath) => {
6
+ if (!existsSync(entryPath)) return null;
7
+ let esbuild;
8
+ try {
9
+ esbuild = await import("esbuild");
10
+ } catch {
5
11
  try {
6
- return await import(modulePath);
12
+ return await import(entryPath);
7
13
  } catch {
8
14
  return null;
9
15
  }
10
- };
16
+ }
17
+ const outFile = join(tmpdir(), `brender_${randomBytes(8).toString("hex")}.mjs`);
18
+ try {
19
+ await esbuild.build({
20
+ entryPoints: [entryPath],
21
+ bundle: true,
22
+ format: "esm",
23
+ platform: "node",
24
+ outfile: outFile,
25
+ write: true,
26
+ logLevel: "silent",
27
+ // Mark node builtins as external
28
+ 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"]
29
+ });
30
+ const mod = await import(`file://${outFile}`);
31
+ return mod;
32
+ } catch {
33
+ try {
34
+ return await import(entryPath);
35
+ } catch {
36
+ return null;
37
+ }
38
+ } finally {
39
+ try {
40
+ unlinkSync(outFile);
41
+ } catch {
42
+ }
43
+ }
44
+ };
45
+ const loadProject = async (projectPath) => {
46
+ const symbolsDir = resolve(projectPath, "symbols");
11
47
  const [
12
48
  appModule,
13
49
  stateModule,
@@ -21,17 +57,17 @@ const loadProject = async (projectPath) => {
21
57
  designSystemModule,
22
58
  filesModule
23
59
  ] = await Promise.all([
24
- tryImport(join(symbolsDir, "app.js")),
25
- tryImport(join(symbolsDir, "state.js")),
26
- tryImport(join(symbolsDir, "config.js")),
27
- tryImport(join(symbolsDir, "dependencies.js")),
28
- tryImport(join(symbolsDir, "components", "index.js")),
29
- tryImport(join(symbolsDir, "snippets", "index.js")),
30
- tryImport(join(symbolsDir, "pages", "index.js")),
31
- tryImport(join(symbolsDir, "functions", "index.js")),
32
- tryImport(join(symbolsDir, "methods", "index.js")),
33
- tryImport(join(symbolsDir, "designSystem", "index.js")),
34
- tryImport(join(symbolsDir, "files", "index.js"))
60
+ bundleAndImport(join(symbolsDir, "app.js")),
61
+ bundleAndImport(join(symbolsDir, "state.js")),
62
+ bundleAndImport(join(symbolsDir, "config.js")),
63
+ bundleAndImport(join(symbolsDir, "dependencies.js")),
64
+ bundleAndImport(join(symbolsDir, "components", "index.js")),
65
+ bundleAndImport(join(symbolsDir, "snippets", "index.js")),
66
+ bundleAndImport(join(symbolsDir, "pages", "index.js")),
67
+ bundleAndImport(join(symbolsDir, "functions", "index.js")),
68
+ bundleAndImport(join(symbolsDir, "methods", "index.js")),
69
+ bundleAndImport(join(symbolsDir, "designSystem", "index.js")),
70
+ bundleAndImport(join(symbolsDir, "files", "index.js"))
35
71
  ]);
36
72
  return {
37
73
  app: appModule?.default || {},