@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.
package/dist/cjs/env.js CHANGED
@@ -48,6 +48,29 @@ const createEnv = (html = "<!DOCTYPE html><html><head></head><body></body></html
48
48
  window.scrollTo = () => {
49
49
  };
50
50
  }
51
+ const createStorage = () => {
52
+ const store = {};
53
+ return {
54
+ getItem: (k) => store[k] ?? null,
55
+ setItem: (k, v) => {
56
+ store[k] = String(v);
57
+ },
58
+ removeItem: (k) => {
59
+ delete store[k];
60
+ },
61
+ clear: () => {
62
+ for (const k in store) delete store[k];
63
+ },
64
+ get length() {
65
+ return Object.keys(store).length;
66
+ },
67
+ key: (i) => Object.keys(store)[i] ?? null
68
+ };
69
+ };
70
+ if (!window.localStorage) window.localStorage = createStorage();
71
+ if (!window.sessionStorage) window.sessionStorage = createStorage();
72
+ if (!globalThis.localStorage) globalThis.localStorage = window.localStorage;
73
+ if (!globalThis.sessionStorage) globalThis.sessionStorage = window.sessionStorage;
51
74
  globalThis.window = window;
52
75
  globalThis.document = document;
53
76
  globalThis.Node = window.Node || globalThis.Node;
@@ -115,6 +115,15 @@ const renderCSS = (el, emotion, colorMap, mediaMap) => {
115
115
  css[key] = resolveValue(key, val, colorMap);
116
116
  hasCss = true;
117
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
+ }
118
127
  if (el.style && typeof el.style === "object") {
119
128
  Object.assign(css, el.style);
120
129
  hasCss = true;
@@ -213,8 +222,34 @@ const NON_CSS_PROPS = /* @__PURE__ */ new Set([
213
222
  "__element",
214
223
  "update"
215
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
+ };
216
241
  const resolveShorthand = (key, val) => {
217
- if (key === "flexAlign" && typeof val === "string") {
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") {
218
253
  const [alignItems, justifyContent] = val.split(" ");
219
254
  return { display: "flex", alignItems, justifyContent };
220
255
  }
@@ -222,12 +257,44 @@ const resolveShorthand = (key, val) => {
222
257
  const [alignItems, justifyContent] = val.split(" ");
223
258
  return { display: "grid", alignItems, justifyContent };
224
259
  }
225
- if (key === "round" && val) {
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) {
226
270
  return { borderRadius: typeof val === "number" ? val + "px" : val };
227
271
  }
228
- if (key === "boxSize" && val) {
229
- return { width: val, height: val };
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 };
230
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 };
231
298
  return null;
232
299
  };
233
300
  const isCSS = (key) => {
@@ -341,11 +408,37 @@ const CSS_PROPERTIES = /* @__PURE__ */ new Set([
341
408
  "gridAutoFlow",
342
409
  "gridAutoColumns",
343
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",
344
426
  "transform",
345
427
  "transformOrigin",
346
428
  "transition",
347
429
  "animation",
430
+ "animationName",
431
+ "animationDuration",
348
432
  "animationDelay",
433
+ "animationTimingFunction",
434
+ "animationFillMode",
435
+ "animationIterationCount",
436
+ "animationPlayState",
437
+ "animationDirection",
438
+ "gridTemplate",
439
+ "gridTemplateAreas",
440
+ "gridColumnStart",
441
+ "gridRowStart",
349
442
  "boxShadow",
350
443
  "outline",
351
444
  "outlineColor",
package/dist/cjs/load.js CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
  var load_exports = {};
19
29
  __export(load_exports, {
@@ -22,15 +32,51 @@ __export(load_exports, {
22
32
  });
23
33
  module.exports = __toCommonJS(load_exports);
24
34
  var import_path = require("path");
25
- const loadProject = async (projectPath) => {
26
- const symbolsDir = (0, import_path.resolve)(projectPath, "symbols");
27
- const tryImport = async (modulePath) => {
35
+ var import_fs = require("fs");
36
+ var import_os = require("os");
37
+ var import_crypto = require("crypto");
38
+ const bundleAndImport = async (entryPath) => {
39
+ if (!(0, import_fs.existsSync)(entryPath)) return null;
40
+ let esbuild;
41
+ try {
42
+ esbuild = await import("esbuild");
43
+ } catch {
28
44
  try {
29
- return await import(modulePath);
45
+ return await import(entryPath);
30
46
  } catch {
31
47
  return null;
32
48
  }
33
- };
49
+ }
50
+ const outFile = (0, import_path.join)((0, import_os.tmpdir)(), `brender_${(0, import_crypto.randomBytes)(8).toString("hex")}.mjs`);
51
+ try {
52
+ await esbuild.build({
53
+ entryPoints: [entryPath],
54
+ bundle: true,
55
+ format: "esm",
56
+ platform: "node",
57
+ outfile: outFile,
58
+ write: true,
59
+ logLevel: "silent",
60
+ // Mark node builtins as external
61
+ 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"]
62
+ });
63
+ const mod = await import(`file://${outFile}`);
64
+ return mod;
65
+ } catch {
66
+ try {
67
+ return await import(entryPath);
68
+ } catch {
69
+ return null;
70
+ }
71
+ } finally {
72
+ try {
73
+ (0, import_fs.unlinkSync)(outFile);
74
+ } catch {
75
+ }
76
+ }
77
+ };
78
+ const loadProject = async (projectPath) => {
79
+ const symbolsDir = (0, import_path.resolve)(projectPath, "symbols");
34
80
  const [
35
81
  appModule,
36
82
  stateModule,
@@ -44,17 +90,17 @@ const loadProject = async (projectPath) => {
44
90
  designSystemModule,
45
91
  filesModule
46
92
  ] = await Promise.all([
47
- tryImport((0, import_path.join)(symbolsDir, "app.js")),
48
- tryImport((0, import_path.join)(symbolsDir, "state.js")),
49
- tryImport((0, import_path.join)(symbolsDir, "config.js")),
50
- tryImport((0, import_path.join)(symbolsDir, "dependencies.js")),
51
- tryImport((0, import_path.join)(symbolsDir, "components", "index.js")),
52
- tryImport((0, import_path.join)(symbolsDir, "snippets", "index.js")),
53
- tryImport((0, import_path.join)(symbolsDir, "pages", "index.js")),
54
- tryImport((0, import_path.join)(symbolsDir, "functions", "index.js")),
55
- tryImport((0, import_path.join)(symbolsDir, "methods", "index.js")),
56
- tryImport((0, import_path.join)(symbolsDir, "designSystem", "index.js")),
57
- tryImport((0, import_path.join)(symbolsDir, "files", "index.js"))
93
+ bundleAndImport((0, import_path.join)(symbolsDir, "app.js")),
94
+ bundleAndImport((0, import_path.join)(symbolsDir, "state.js")),
95
+ bundleAndImport((0, import_path.join)(symbolsDir, "config.js")),
96
+ bundleAndImport((0, import_path.join)(symbolsDir, "dependencies.js")),
97
+ bundleAndImport((0, import_path.join)(symbolsDir, "components", "index.js")),
98
+ bundleAndImport((0, import_path.join)(symbolsDir, "snippets", "index.js")),
99
+ bundleAndImport((0, import_path.join)(symbolsDir, "pages", "index.js")),
100
+ bundleAndImport((0, import_path.join)(symbolsDir, "functions", "index.js")),
101
+ bundleAndImport((0, import_path.join)(symbolsDir, "methods", "index.js")),
102
+ bundleAndImport((0, import_path.join)(symbolsDir, "designSystem", "index.js")),
103
+ bundleAndImport((0, import_path.join)(symbolsDir, "files", "index.js"))
58
104
  ]);
59
105
  return {
60
106
  app: appModule?.default || {},