@jbpark/live-editor 1.11.0 → 1.13.0

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,8 +1,8 @@
1
- import { d as require_lib, f as require_lib$2, g as DATA_ATTR, h as CONFIG, l as createBoundedCache, m as BINDING_PROP, p as require_lib$1, u as require_lib$3, x as __toESM, y as REGEX } from "./document-CBw2uF_P.mjs";
1
+ import { d as require_lib, f as require_lib$2, g as DATA_ATTR, h as CONFIG, l as traverse, m as BINDING_PROP, p as require_lib$1, u as createBoundedCache, x as __toESM, y as REGEX } from "./document-CSIscFpL.js";
2
2
  import { z } from "zod";
3
- import crypto from "crypto";
4
-
5
3
  //#region src/utils/ast/types.ts
4
+ var import_lib$1 = require_lib$1();
5
+ var import_lib$2 = /* @__PURE__ */ __toESM(require_lib$2(), 1);
6
6
  const BINDING_TYPES = [
7
7
  "array",
8
8
  "object",
@@ -17,12 +17,10 @@ const BINDING_TYPES = [
17
17
  "icon-picker",
18
18
  "asset-picker"
19
19
  ];
20
-
21
20
  //#endregion
22
21
  //#region src/utils/ast/helpers.ts
23
- var import_lib$1 = /* @__PURE__ */ __toESM(require_lib(), 1);
24
- var import_lib$2 = require_lib$1();
25
- var import_lib$3 = /* @__PURE__ */ __toESM(require_lib$2(), 1);
22
+ var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
23
+ const generate = typeof import_lib.default === "function" ? import_lib.default : import_lib.default.default;
26
24
  const wrap = (code) => {
27
25
  return `<>${code}</>`;
28
26
  };
@@ -31,24 +29,23 @@ const unwrap = (generated) => {
31
29
  };
32
30
  const attrValue = ({ value, isStringLiteral }) => {
33
31
  if (value === null) return null;
34
- if (isStringLiteral) return import_lib$3.stringLiteral(value);
32
+ if (isStringLiteral) return import_lib$2.stringLiteral(value);
35
33
  const trimmed = value.trim();
36
- if (REGEX.NUMBER.test(trimmed)) return import_lib$3.jsxExpressionContainer(import_lib$3.numericLiteral(parseFloat(trimmed)));
34
+ if (REGEX.NUMBER.test(trimmed)) return import_lib$2.jsxExpressionContainer(import_lib$2.numericLiteral(parseFloat(trimmed)));
37
35
  if (REGEX.BOOLEAN_OR_NULL.test(trimmed)) {
38
- const expr = (0, import_lib$2.parseExpression)(trimmed, { plugins: ["jsx", "typescript"] });
39
- return import_lib$3.jsxExpressionContainer(expr);
36
+ const expr = (0, import_lib$1.parseExpression)(trimmed, { plugins: ["jsx", "typescript"] });
37
+ return import_lib$2.jsxExpressionContainer(expr);
40
38
  }
41
39
  try {
42
- const expr = (0, import_lib$2.parseExpression)(trimmed, { plugins: ["jsx", "typescript"] });
43
- return import_lib$3.jsxExpressionContainer(expr);
40
+ const expr = (0, import_lib$1.parseExpression)(trimmed, { plugins: ["jsx", "typescript"] });
41
+ return import_lib$2.jsxExpressionContainer(expr);
44
42
  } catch {
45
- return import_lib$3.stringLiteral(trimmed);
43
+ return import_lib$2.stringLiteral(trimmed);
46
44
  }
47
45
  };
48
46
  const generateCode = (node) => {
49
- return (0, import_lib$1.default)(node, { jsescOption: { minimal: true } }).code;
47
+ return generate(node, { jsescOption: { minimal: true } }).code;
50
48
  };
51
-
52
49
  //#endregion
53
50
  //#region src/utils/ast/value.ts
54
51
  const dedent = (str) => {
@@ -61,23 +58,23 @@ const dedent = (str) => {
61
58
  return indent === Infinity ? str.trim() : lines.map((line) => line.slice(indent)).join("\n");
62
59
  };
63
60
  const evaluateLiteral = (node) => {
64
- if (import_lib$3.isStringLiteral(node)) return node.value;
65
- if (import_lib$3.isNumericLiteral(node)) return node.value;
66
- if (import_lib$3.isBooleanLiteral(node)) return node.value;
67
- if (import_lib$3.isNullLiteral(node)) return null;
68
- if (import_lib$3.isIdentifier(node) && node.name === "undefined") return;
69
- if (import_lib$3.isUnaryExpression(node) && node.operator === "-" && import_lib$3.isNumericLiteral(node.argument)) return -node.argument.value;
70
- if (import_lib$3.isTemplateLiteral(node) && node.expressions.length === 0) return node.quasis[0]?.value.cooked ?? node.quasis[0]?.value.raw ?? "";
71
- if (import_lib$3.isJSXElement(node) || import_lib$3.isJSXFragment(node)) return generateCode(node);
72
- if (import_lib$3.isArrayExpression(node)) return node.elements.map((element) => element ? evaluateLiteral(element) : null);
73
- if (import_lib$3.isObjectExpression(node)) {
61
+ if (import_lib$2.isStringLiteral(node)) return node.value;
62
+ if (import_lib$2.isNumericLiteral(node)) return node.value;
63
+ if (import_lib$2.isBooleanLiteral(node)) return node.value;
64
+ if (import_lib$2.isNullLiteral(node)) return null;
65
+ if (import_lib$2.isIdentifier(node) && node.name === "undefined") return;
66
+ if (import_lib$2.isUnaryExpression(node) && node.operator === "-" && import_lib$2.isNumericLiteral(node.argument)) return -node.argument.value;
67
+ if (import_lib$2.isTemplateLiteral(node) && node.expressions.length === 0) return node.quasis[0]?.value.cooked ?? node.quasis[0]?.value.raw ?? "";
68
+ if (import_lib$2.isJSXElement(node) || import_lib$2.isJSXFragment(node)) return generateCode(node);
69
+ if (import_lib$2.isArrayExpression(node)) return node.elements.map((element) => element ? evaluateLiteral(element) : null);
70
+ if (import_lib$2.isObjectExpression(node)) {
74
71
  const result = {};
75
72
  for (const prop of node.properties) {
76
- if (!import_lib$3.isObjectProperty(prop)) continue;
73
+ if (!import_lib$2.isObjectProperty(prop)) continue;
77
74
  let key = null;
78
- if (import_lib$3.isIdentifier(prop.key)) key = prop.key.name;
79
- else if (import_lib$3.isStringLiteral(prop.key)) key = prop.key.value;
80
- else if (import_lib$3.isNumericLiteral(prop.key)) key = String(prop.key.value);
75
+ if (import_lib$2.isIdentifier(prop.key)) key = prop.key.name;
76
+ else if (import_lib$2.isStringLiteral(prop.key)) key = prop.key.value;
77
+ else if (import_lib$2.isNumericLiteral(prop.key)) key = String(prop.key.value);
81
78
  if (key === null) continue;
82
79
  result[key] = evaluateLiteral(prop.value);
83
80
  }
@@ -97,31 +94,31 @@ const parseValue = (value) => {
97
94
  }
98
95
  if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
99
96
  try {
100
- const ast = (0, import_lib$2.parseExpression)(trimmed, { plugins: ["jsx", "typescript"] });
101
- if (import_lib$3.isObjectExpression(ast) || import_lib$3.isArrayExpression(ast)) return evaluateLiteral(ast);
97
+ const ast = (0, import_lib$1.parseExpression)(trimmed, { plugins: ["jsx", "typescript"] });
98
+ if (import_lib$2.isObjectExpression(ast) || import_lib$2.isArrayExpression(ast)) return evaluateLiteral(ast);
102
99
  } catch {}
103
100
  return value;
104
101
  }
105
102
  return value;
106
103
  };
107
104
  const extractNodeValue = (node) => {
108
- if (import_lib$3.isBooleanLiteral(node)) return {
105
+ if (import_lib$2.isBooleanLiteral(node)) return {
109
106
  type: "boolean",
110
107
  value: node.value
111
108
  };
112
- if (import_lib$3.isNumericLiteral(node)) return {
109
+ if (import_lib$2.isNumericLiteral(node)) return {
113
110
  type: "number",
114
111
  value: node.value
115
112
  };
116
- if (import_lib$3.isUnaryExpression(node) && node.operator === "-" && import_lib$3.isNumericLiteral(node.argument)) return {
113
+ if (import_lib$2.isUnaryExpression(node) && node.operator === "-" && import_lib$2.isNumericLiteral(node.argument)) return {
117
114
  type: "number",
118
115
  value: -node.argument.value
119
116
  };
120
- if (import_lib$3.isStringLiteral(node)) return {
117
+ if (import_lib$2.isStringLiteral(node)) return {
121
118
  type: "string",
122
119
  value: node.value
123
120
  };
124
- if (import_lib$3.isTemplateLiteral(node)) {
121
+ if (import_lib$2.isTemplateLiteral(node)) {
125
122
  if (node.expressions.length === 0 && node.quasis.length === 1) return {
126
123
  type: "string",
127
124
  value: dedent(node.quasis[0].value.cooked ?? node.quasis[0].value.raw)
@@ -131,19 +128,19 @@ const extractNodeValue = (node) => {
131
128
  value: generateCode(node)
132
129
  };
133
130
  }
134
- if (import_lib$3.isNullLiteral(node)) return {
131
+ if (import_lib$2.isNullLiteral(node)) return {
135
132
  type: "null",
136
133
  value: null
137
134
  };
138
- if (import_lib$3.isArrayExpression(node)) return {
135
+ if (import_lib$2.isArrayExpression(node)) return {
139
136
  type: "array",
140
137
  value: generateCode(node)
141
138
  };
142
- if (import_lib$3.isObjectExpression(node)) return {
139
+ if (import_lib$2.isObjectExpression(node)) return {
143
140
  type: "object",
144
141
  value: generateCode(node)
145
142
  };
146
- if (import_lib$3.isJSXElement(node) || import_lib$3.isJSXFragment(node)) return {
143
+ if (import_lib$2.isJSXElement(node) || import_lib$2.isJSXFragment(node)) return {
147
144
  type: "string",
148
145
  value: generateCode(node)
149
146
  };
@@ -154,10 +151,10 @@ const extractNodeValue = (node) => {
154
151
  };
155
152
  const createNodeFromValue = (type, value) => {
156
153
  switch (type) {
157
- case "boolean": return import_lib$3.booleanLiteral(value === true);
158
- case "number": return import_lib$3.numericLiteral(Number(value));
159
- case "string": return import_lib$3.stringLiteral(String(value));
160
- case "null": return import_lib$3.nullLiteral();
154
+ case "boolean": return import_lib$2.booleanLiteral(value === true);
155
+ case "number": return import_lib$2.numericLiteral(Number(value));
156
+ case "string": return import_lib$2.stringLiteral(String(value));
157
+ case "null": return import_lib$2.nullLiteral();
161
158
  case "array":
162
159
  case "object":
163
160
  case "unknown": return null;
@@ -166,8 +163,8 @@ const createNodeFromValue = (type, value) => {
166
163
  };
167
164
  const parseArrayExpression = (value) => {
168
165
  try {
169
- const ast = (0, import_lib$2.parseExpression)(value, { plugins: ["jsx", "typescript"] });
170
- if (!import_lib$3.isArrayExpression(ast)) return null;
166
+ const ast = (0, import_lib$1.parseExpression)(value, { plugins: ["jsx", "typescript"] });
167
+ if (!import_lib$2.isArrayExpression(ast)) return null;
171
168
  return ast;
172
169
  } catch (error) {
173
170
  console.error("❌ Array parsing error:", error);
@@ -177,11 +174,12 @@ const parseArrayExpression = (value) => {
177
174
  const extractObjectProperties = (element) => {
178
175
  const properties = {};
179
176
  element.properties.forEach((prop) => {
180
- if (import_lib$3.isObjectProperty(prop) && import_lib$3.isIdentifier(prop.key)) {
177
+ if (import_lib$2.isObjectProperty(prop) && import_lib$2.isIdentifier(prop.key)) {
181
178
  const key = prop.key.name;
182
179
  if (key === "children") return;
180
+ const extracted = extractNodeValue(prop.value);
183
181
  properties[key] = {
184
- ...extractNodeValue(prop.value),
182
+ ...extracted,
185
183
  astNode: prop.value
186
184
  };
187
185
  }
@@ -189,9 +187,9 @@ const extractObjectProperties = (element) => {
189
187
  return properties;
190
188
  };
191
189
  const arrayExpressionToCode = (elements) => {
192
- return generateCode(import_lib$3.arrayExpression(elements));
190
+ const nextAst = import_lib$2.arrayExpression(elements);
191
+ return generateCode(nextAst);
193
192
  };
194
-
195
193
  //#endregion
196
194
  //#region src/utils/ast/binding.ts
197
195
  const bindingTypeSchema = z.enum(BINDING_TYPES);
@@ -280,12 +278,12 @@ const getCurrentValue = (node, property) => {
280
278
  case BINDING_PROP.INNER_HTML: {
281
279
  const dsiAttr = node.attributes.find((a) => a.name === "dangerouslySetInnerHTML");
282
280
  if (dsiAttr?.value) try {
283
- const expr = (0, import_lib$2.parseExpression)(dsiAttr.value, { plugins: ["jsx", "typescript"] });
284
- if (import_lib$3.isObjectExpression(expr)) {
285
- const htmlProp = expr.properties.find((p) => import_lib$3.isObjectProperty(p) && import_lib$3.isIdentifier(p.key) && p.key.name === "__html");
281
+ const expr = (0, import_lib$1.parseExpression)(dsiAttr.value, { plugins: ["jsx", "typescript"] });
282
+ if (import_lib$2.isObjectExpression(expr)) {
283
+ const htmlProp = expr.properties.find((p) => import_lib$2.isObjectProperty(p) && import_lib$2.isIdentifier(p.key) && p.key.name === "__html");
286
284
  if (htmlProp) {
287
- if (import_lib$3.isStringLiteral(htmlProp.value)) return htmlProp.value.value;
288
- if (import_lib$3.isTemplateLiteral(htmlProp.value) && htmlProp.value.expressions.length === 0) return htmlProp.value.quasis[0]?.value.cooked ?? htmlProp.value.quasis[0]?.value.raw ?? "";
285
+ if (import_lib$2.isStringLiteral(htmlProp.value)) return htmlProp.value.value;
286
+ if (import_lib$2.isTemplateLiteral(htmlProp.value) && htmlProp.value.expressions.length === 0) return htmlProp.value.quasis[0]?.value.cooked ?? htmlProp.value.quasis[0]?.value.raw ?? "";
289
287
  }
290
288
  }
291
289
  } catch {}
@@ -312,62 +310,44 @@ const findEditableChildren = (node) => {
312
310
  traverse(node.children);
313
311
  return editableChildren;
314
312
  };
315
-
316
313
  //#endregion
317
- //#region node_modules/.pnpm/nanoid@3.3.11/node_modules/nanoid/url-alphabet/index.js
318
- let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
319
-
320
- //#endregion
321
- //#region node_modules/.pnpm/nanoid@3.3.11/node_modules/nanoid/index.js
322
- const POOL_SIZE_MULTIPLIER = 128;
323
- let pool, poolOffset;
324
- let fillPool = (bytes) => {
325
- if (!pool || pool.length < bytes) {
326
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
327
- crypto.randomFillSync(pool);
328
- poolOffset = 0;
329
- } else if (poolOffset + bytes > pool.length) {
330
- crypto.randomFillSync(pool);
331
- poolOffset = 0;
332
- }
333
- poolOffset += bytes;
334
- };
335
- let nanoid = (size = 21) => {
336
- fillPool(size |= 0);
337
- let id = "";
338
- for (let i = poolOffset - size; i < poolOffset; i++) id += urlAlphabet[pool[i] & 63];
314
+ //#region node_modules/.pnpm/nanoid@3.3.18/node_modules/nanoid/index.browser.js
315
+ let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
316
+ byte &= 63;
317
+ if (byte < 36) id += byte.toString(36);
318
+ else if (byte < 62) id += (byte - 26).toString(36).toUpperCase();
319
+ else if (byte > 62) id += "-";
320
+ else id += "_";
339
321
  return id;
340
- };
341
-
322
+ }, "");
342
323
  //#endregion
343
324
  //#region src/utils/ast/extract.ts
344
- var import_lib = /* @__PURE__ */ __toESM(require_lib$3(), 1);
345
325
  const collectText = (children) => {
346
- return children.filter((c) => import_lib$3.isJSXText(c)).map((c) => c.value.trim()).filter((v) => v.length).join(" ");
326
+ return children.filter((c) => import_lib$2.isJSXText(c)).map((c) => c.value.trim()).filter((v) => v.length).join(" ");
347
327
  };
348
328
  const getTagName = (opening) => {
349
- if (import_lib$3.isJSXIdentifier(opening.name)) return opening.name.name;
350
- if (import_lib$3.isJSXMemberExpression(opening.name)) return resolveMemberName(opening.name);
329
+ if (import_lib$2.isJSXIdentifier(opening.name)) return opening.name.name;
330
+ if (import_lib$2.isJSXMemberExpression(opening.name)) return resolveMemberName(opening.name);
351
331
  return "";
352
332
  };
353
333
  const resolveMemberName = (expr) => {
354
334
  const parts = [];
355
335
  const collectMemberParts = (node) => {
356
- if (import_lib$3.isJSXIdentifier(node)) parts.push(node.name);
357
- else if (import_lib$3.isJSXMemberExpression(node)) {
336
+ if (import_lib$2.isJSXIdentifier(node)) parts.push(node.name);
337
+ else if (import_lib$2.isJSXMemberExpression(node)) {
358
338
  collectMemberParts(node.object);
359
- if (import_lib$3.isJSXIdentifier(node.property)) parts.push(node.property.name);
339
+ if (import_lib$2.isJSXIdentifier(node.property)) parts.push(node.property.name);
360
340
  }
361
341
  };
362
342
  collectMemberParts(expr.object);
363
- if (import_lib$3.isJSXIdentifier(expr.property)) parts.push(expr.property.name);
343
+ if (import_lib$2.isJSXIdentifier(expr.property)) parts.push(expr.property.name);
364
344
  return parts.join(".");
365
345
  };
366
346
  const parseJSXName = (tagName) => {
367
347
  const parts = tagName.split(".");
368
- if (parts.length === 1) return import_lib$3.jsxIdentifier(parts[0]);
369
- let expr = import_lib$3.jsxIdentifier(parts[0]);
370
- for (let i = 1; i < parts.length; i++) expr = import_lib$3.jsxMemberExpression(expr, import_lib$3.jsxIdentifier(parts[i]));
348
+ if (parts.length === 1) return import_lib$2.jsxIdentifier(parts[0]);
349
+ let expr = import_lib$2.jsxIdentifier(parts[0]);
350
+ for (let i = 1; i < parts.length; i++) expr = import_lib$2.jsxMemberExpression(expr, import_lib$2.jsxIdentifier(parts[i]));
371
351
  return expr;
372
352
  };
373
353
  const extractCache = createBoundedCache(CONFIG.CACHE_LIMIT);
@@ -375,15 +355,15 @@ const extractAttributes = (attributes) => {
375
355
  const allAttrs = [];
376
356
  const dataAttrs = [];
377
357
  for (const attr of attributes) {
378
- if (!import_lib$3.isJSXAttribute(attr) || !import_lib$3.isJSXIdentifier(attr.name)) continue;
358
+ if (!import_lib$2.isJSXAttribute(attr) || !import_lib$2.isJSXIdentifier(attr.name)) continue;
379
359
  const name = attr.name.name;
380
360
  let value = null;
381
361
  let isStringLiteral = false;
382
362
  if (attr.value) {
383
- if (import_lib$3.isStringLiteral(attr.value)) {
363
+ if (import_lib$2.isStringLiteral(attr.value)) {
384
364
  value = attr.value.value;
385
365
  isStringLiteral = true;
386
- } else if (import_lib$3.isJSXExpressionContainer(attr.value)) try {
366
+ } else if (import_lib$2.isJSXExpressionContainer(attr.value)) try {
387
367
  value = generateCode(attr.value.expression);
388
368
  isStringLiteral = false;
389
369
  } catch {
@@ -405,7 +385,7 @@ const extractAttributes = (attributes) => {
405
385
  };
406
386
  const buildChildElements = (node) => {
407
387
  const childElements = [];
408
- if (node.textContent) childElements.push(import_lib$3.jsxText(node.textContent));
388
+ if (node.textContent) childElements.push(import_lib$2.jsxText(node.textContent));
409
389
  node.children?.forEach((child) => {
410
390
  const childJSX = nodeToJSX(child);
411
391
  if (childJSX) childElements.push(childJSX);
@@ -416,22 +396,22 @@ const nodeToJSX = (node) => {
416
396
  try {
417
397
  if (node.isFragment) {
418
398
  const childElements = buildChildElements(node);
419
- return import_lib$3.jsxFragment(import_lib$3.jsxOpeningFragment(), import_lib$3.jsxClosingFragment(), childElements);
399
+ return import_lib$2.jsxFragment(import_lib$2.jsxOpeningFragment(), import_lib$2.jsxClosingFragment(), childElements);
420
400
  }
421
401
  if (node.tagName === "div" && node.dataAttributes.some((attr) => attr.name === "data-item")) {
422
402
  if (node.children) return nodeToJSX(node.children[0]);
423
403
  return null;
424
404
  }
425
405
  const attributes = node.attributes.map((attr) => {
426
- const attrName = import_lib$3.jsxIdentifier(attr.name);
427
- if (!attr.value) return import_lib$3.jsxAttribute(attrName, null);
428
- return import_lib$3.jsxAttribute(attrName, attrValue(attr));
406
+ const attrName = import_lib$2.jsxIdentifier(attr.name);
407
+ if (!attr.value) return import_lib$2.jsxAttribute(attrName, null);
408
+ return import_lib$2.jsxAttribute(attrName, attrValue(attr));
429
409
  });
430
410
  const elementName = parseJSXName(node.tagName);
431
- const openingElement = import_lib$3.jsxOpeningElement(elementName, attributes);
432
- const closingElement = import_lib$3.jsxClosingElement(elementName);
411
+ const openingElement = import_lib$2.jsxOpeningElement(elementName, attributes);
412
+ const closingElement = import_lib$2.jsxClosingElement(elementName);
433
413
  const children = buildChildElements(node);
434
- return import_lib$3.jsxElement(openingElement, closingElement, children, false);
414
+ return import_lib$2.jsxElement(openingElement, closingElement, children, false);
435
415
  } catch (error) {
436
416
  console.error("❌ DataAttrNode to JSX conversion error:", error);
437
417
  return null;
@@ -461,21 +441,21 @@ const createFragmentNode = (textContent, children) => ({
461
441
  isFragment: true
462
442
  });
463
443
  const processChildrenBinding = (jsxElement, processedNodes, shouldWrap = true) => {
464
- const jsxChildren = jsxElement.children.filter((child) => import_lib$3.isJSXElement(child) || import_lib$3.isJSXFragment(child));
444
+ const jsxChildren = jsxElement.children.filter((child) => import_lib$2.isJSXElement(child) || import_lib$2.isJSXFragment(child));
465
445
  if (!jsxChildren.length) return;
466
446
  const childrenNodes = [];
467
447
  jsxChildren.forEach((child) => {
468
- if (import_lib$3.isJSXElement(child)) {
448
+ if (import_lib$2.isJSXElement(child)) {
469
449
  const childResults = extractFromNode(child, processedNodes);
470
450
  if (shouldWrap) {
471
451
  const wrapperNode = createWrapperNode(collectText(child.children), childResults);
472
452
  childrenNodes.push(wrapperNode);
473
453
  } else childrenNodes.push(...childResults);
474
- } else if (import_lib$3.isJSXFragment(child)) {
454
+ } else if (import_lib$2.isJSXFragment(child)) {
475
455
  processedNodes?.add(child);
476
456
  const fragmentChildren = [];
477
457
  child.children.forEach((fragmentChild) => {
478
- if (import_lib$3.isJSXElement(fragmentChild)) {
458
+ if (import_lib$2.isJSXElement(fragmentChild)) {
479
459
  const childResults = extractFromNode(fragmentChild, processedNodes);
480
460
  fragmentChildren.push(...childResults);
481
461
  }
@@ -489,21 +469,21 @@ const processChildrenBinding = (jsxElement, processedNodes, shouldWrap = true) =
489
469
  return childrenNodes.length ? childrenNodes : void 0;
490
470
  };
491
471
  const skipItemsChildren = (jsxElement, processedNodes, propertyName = "items") => {
492
- const itemsAttr = jsxElement.openingElement.attributes.find((attr) => import_lib$3.isJSXAttribute(attr) && import_lib$3.isJSXIdentifier(attr.name) && attr.name.name === propertyName);
493
- if (!itemsAttr || !import_lib$3.isJSXAttribute(itemsAttr)) return;
494
- if (itemsAttr.value && import_lib$3.isJSXExpressionContainer(itemsAttr.value) && import_lib$3.isArrayExpression(itemsAttr.value.expression)) itemsAttr.value.expression.elements.forEach((element) => {
495
- if (import_lib$3.isObjectExpression(element)) element.properties.forEach((prop) => {
496
- if (import_lib$3.isObjectProperty(prop) && import_lib$3.isIdentifier(prop.key) && import_lib$3.isJSXElement(prop.value)) markProcessedJSX(prop.value, processedNodes);
472
+ const itemsAttr = jsxElement.openingElement.attributes.find((attr) => import_lib$2.isJSXAttribute(attr) && import_lib$2.isJSXIdentifier(attr.name) && attr.name.name === propertyName);
473
+ if (!itemsAttr || !import_lib$2.isJSXAttribute(itemsAttr)) return;
474
+ if (itemsAttr.value && import_lib$2.isJSXExpressionContainer(itemsAttr.value) && import_lib$2.isArrayExpression(itemsAttr.value.expression)) itemsAttr.value.expression.elements.forEach((element) => {
475
+ if (import_lib$2.isObjectExpression(element)) element.properties.forEach((prop) => {
476
+ if (import_lib$2.isObjectProperty(prop) && import_lib$2.isIdentifier(prop.key) && import_lib$2.isJSXElement(prop.value)) markProcessedJSX(prop.value, processedNodes);
497
477
  });
498
478
  });
499
479
  };
500
480
  const markProcessedJSX = (node, processedNodes) => {
501
- if (import_lib$3.isJSXElement(node) || import_lib$3.isJSXFragment(node)) {
481
+ if (import_lib$2.isJSXElement(node) || import_lib$2.isJSXFragment(node)) {
502
482
  processedNodes.add(node);
503
483
  node.children.forEach((child) => markProcessedJSX(child, processedNodes));
504
484
  return;
505
485
  }
506
- if (import_lib$3.isJSXExpressionContainer(node) || import_lib$3.isParenthesizedExpression(node)) markProcessedJSX(node.expression, processedNodes);
486
+ if (import_lib$2.isJSXExpressionContainer(node) || import_lib$2.isParenthesizedExpression(node)) markProcessedJSX(node.expression, processedNodes);
507
487
  };
508
488
  const readNodeBindingInfo = (node) => {
509
489
  const opening = node.openingElement;
@@ -527,14 +507,15 @@ const readNodeBindingInfo = (node) => {
527
507
  };
528
508
  };
529
509
  const parseToNodes = (raw) => {
530
- const ast = (0, import_lib$2.parse)(wrap(raw), {
510
+ const wrapped = wrap(raw);
511
+ const ast = (0, import_lib$1.parse)(wrapped, {
531
512
  sourceType: "module",
532
513
  plugins: ["jsx", "typescript"],
533
514
  errorRecovery: true
534
515
  });
535
516
  const results = [];
536
517
  const processedNodes = /* @__PURE__ */ new WeakSet();
537
- (0, import_lib.default)(ast, { JSXElement(path) {
518
+ traverse(ast, { JSXElement(path) {
538
519
  if (processedNodes.has(path.node)) return;
539
520
  const { tagName, allAttrs, dataAttrs, bindings, childrenBinding, arrayBindings, rawChildren } = readNodeBindingInfo(path.node);
540
521
  if (!tagName || !dataAttrs.length) return;
@@ -588,18 +569,17 @@ function extractFromNode(node, processedNodes) {
588
569
  function clearExtractCache() {
589
570
  extractCache.clear();
590
571
  }
591
-
592
572
  //#endregion
593
573
  //#region src/utils/ast/update.ts
594
574
  const updateInnerText = (path, value) => {
595
575
  const jsxChildren = path.node.children;
596
- for (let i = jsxChildren.length - 1; i >= 0; i--) if (import_lib$3.isJSXText(jsxChildren[i])) jsxChildren.splice(i, 1);
597
- jsxChildren.push(import_lib$3.jsxText(value));
576
+ for (let i = jsxChildren.length - 1; i >= 0; i--) if (import_lib$2.isJSXText(jsxChildren[i])) jsxChildren.splice(i, 1);
577
+ jsxChildren.push(import_lib$2.jsxText(value));
598
578
  return true;
599
579
  };
600
580
  const injectPlaceholder = (prefix, value, placeholders, { asRawContent = false } = {}) => {
601
581
  const name = `__${prefix}_${nanoid(6)}__`;
602
- const container = import_lib$3.jsxExpressionContainer(import_lib$3.identifier(name));
582
+ const container = import_lib$2.jsxExpressionContainer(import_lib$2.identifier(name));
603
583
  placeholders.set(asRawContent ? `{${name}}` : name, value);
604
584
  return container;
605
585
  };
@@ -624,20 +604,21 @@ const updateChildren = (path, value) => {
624
604
  const updateRichtext = (path, value) => {
625
605
  path.node.children = [];
626
606
  const opening = path.node.openingElement;
627
- const htmlObject = import_lib$3.objectExpression([import_lib$3.objectProperty(import_lib$3.identifier("__html"), import_lib$3.stringLiteral(value))]);
628
- const existingAttr = opening.attributes.find((a) => import_lib$3.isJSXAttribute(a) && import_lib$3.isJSXIdentifier(a.name) && a.name.name === "dangerouslySetInnerHTML");
629
- if (existingAttr && import_lib$3.isJSXAttribute(existingAttr)) existingAttr.value = import_lib$3.jsxExpressionContainer(htmlObject);
630
- else opening.attributes.push(import_lib$3.jsxAttribute(import_lib$3.jsxIdentifier("dangerouslySetInnerHTML"), import_lib$3.jsxExpressionContainer(htmlObject)));
607
+ const htmlObject = import_lib$2.objectExpression([import_lib$2.objectProperty(import_lib$2.identifier("__html"), import_lib$2.stringLiteral(value))]);
608
+ const existingAttr = opening.attributes.find((a) => import_lib$2.isJSXAttribute(a) && import_lib$2.isJSXIdentifier(a.name) && a.name.name === "dangerouslySetInnerHTML");
609
+ if (existingAttr && import_lib$2.isJSXAttribute(existingAttr)) existingAttr.value = import_lib$2.jsxExpressionContainer(htmlObject);
610
+ else opening.attributes.push(import_lib$2.jsxAttribute(import_lib$2.jsxIdentifier("dangerouslySetInnerHTML"), import_lib$2.jsxExpressionContainer(htmlObject)));
631
611
  return true;
632
612
  };
633
613
  const updateAttribute = (opening, propertyName, value) => {
634
- const customAttr = opening.attributes.find((attr) => import_lib$3.isJSXAttribute(attr) && import_lib$3.isJSXIdentifier(attr.name) && attr.name.name === propertyName);
635
- if (customAttr && import_lib$3.isJSXAttribute(customAttr)) {
614
+ const customAttr = opening.attributes.find((attr) => import_lib$2.isJSXAttribute(attr) && import_lib$2.isJSXIdentifier(attr.name) && attr.name.name === propertyName);
615
+ if (customAttr && import_lib$2.isJSXAttribute(customAttr)) {
636
616
  const trimmed = value.trim();
617
+ const isExpression = trimmed.startsWith("[") || trimmed.startsWith("{") || REGEX.NUMBER.test(trimmed) || REGEX.BOOLEAN_OR_NULL.test(trimmed);
637
618
  customAttr.value = attrValue({
638
619
  name: propertyName,
639
620
  value,
640
- isStringLiteral: !(trimmed.startsWith("[") || trimmed.startsWith("{") || REGEX.NUMBER.test(trimmed) || REGEX.BOOLEAN_OR_NULL.test(trimmed))
621
+ isStringLiteral: !isExpression
641
622
  });
642
623
  return true;
643
624
  }
@@ -645,22 +626,23 @@ const updateAttribute = (opening, propertyName, value) => {
645
626
  };
646
627
  const update = (code, dataId, label, value) => {
647
628
  try {
648
- const ast = (0, import_lib$2.parse)(wrap(code), {
629
+ const wrapped = wrap(code);
630
+ const ast = (0, import_lib$1.parse)(wrapped, {
649
631
  sourceType: "module",
650
632
  plugins: ["jsx", "typescript"]
651
633
  });
652
634
  let changed = false;
653
635
  const jsxPlaceholders = /* @__PURE__ */ new Map();
654
- (0, import_lib.default)(ast, { JSXElement(path) {
636
+ traverse(ast, { JSXElement(path) {
655
637
  const opening = path.node.openingElement;
656
638
  if (!opening.attributes.find((attr) => {
657
- return import_lib$3.isJSXAttribute(attr) && import_lib$3.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.ID && attr.value && import_lib$3.isStringLiteral(attr.value) && attr.value.value === dataId;
639
+ return import_lib$2.isJSXAttribute(attr) && import_lib$2.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.ID && attr.value && import_lib$2.isStringLiteral(attr.value) && attr.value.value === dataId;
658
640
  })) return;
659
- const bindingAttr = opening.attributes.find((attr) => import_lib$3.isJSXAttribute(attr) && import_lib$3.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.BINDING);
641
+ const bindingAttr = opening.attributes.find((attr) => import_lib$2.isJSXAttribute(attr) && import_lib$2.isJSXIdentifier(attr.name) && attr.name.name === DATA_ATTR.BINDING);
660
642
  if (!bindingAttr?.value) return;
661
643
  let bindingValue = "";
662
- if (import_lib$3.isStringLiteral(bindingAttr.value)) bindingValue = bindingAttr.value.value;
663
- else if (import_lib$3.isJSXExpressionContainer(bindingAttr.value)) try {
644
+ if (import_lib$2.isStringLiteral(bindingAttr.value)) bindingValue = bindingAttr.value.value;
645
+ else if (import_lib$2.isJSXExpressionContainer(bindingAttr.value)) try {
664
646
  bindingValue = generateCode(bindingAttr.value.expression);
665
647
  } catch {
666
648
  return;
@@ -678,15 +660,13 @@ const update = (code, dataId, label, value) => {
678
660
  case BINDING_PROP.CHILDREN:
679
661
  changed = updateChildren(path, value);
680
662
  break;
681
- default:
682
- if (propertyBinding.type === "jsx") {
683
- const attr = opening.attributes.find((a) => import_lib$3.isJSXAttribute(a) && import_lib$3.isJSXIdentifier(a.name) && a.name.name === propertyBinding.property);
684
- if (attr && import_lib$3.isJSXAttribute(attr)) {
685
- attr.value = injectPlaceholder("JSX", value.trim(), jsxPlaceholders);
686
- changed = true;
687
- }
688
- } else changed = updateAttribute(opening, propertyBinding.property, value);
689
- break;
663
+ default: if (propertyBinding.type === "jsx") {
664
+ const attr = opening.attributes.find((a) => import_lib$2.isJSXAttribute(a) && import_lib$2.isJSXIdentifier(a.name) && a.name.name === propertyBinding.property);
665
+ if (attr && import_lib$2.isJSXAttribute(attr)) {
666
+ attr.value = injectPlaceholder("JSX", value.trim(), jsxPlaceholders);
667
+ changed = true;
668
+ }
669
+ } else changed = updateAttribute(opening, propertyBinding.property, value);
690
670
  }
691
671
  } });
692
672
  if (!changed) return {
@@ -720,7 +700,6 @@ const bulkUpdate = (raw, entries) => {
720
700
  success: allSucceeded
721
701
  };
722
702
  };
723
-
724
703
  //#endregion
725
704
  //#region src/utils/ast/tree.ts
726
705
  const replaceIds = (code, generateId = () => nanoid(6)) => {
@@ -734,9 +713,11 @@ const fillIds = (code, generateId = () => nanoid(6)) => {
734
713
  });
735
714
  };
736
715
  const clone = (element, generateId = () => nanoid(6)) => {
737
- return (0, import_lib$2.parseExpression)(replaceIds(generateCode(import_lib$3.cloneNode(element, true)), generateId), { plugins: ["jsx", "typescript"] });
716
+ const cloned = import_lib$2.cloneNode(element, true);
717
+ const generatedCode = generateCode(cloned);
718
+ const code = replaceIds(generatedCode, generateId);
719
+ return (0, import_lib$1.parseExpression)(code, { plugins: ["jsx", "typescript"] });
738
720
  };
739
-
740
721
  //#endregion
741
722
  //#region src/utils/ast/validate.ts
742
723
  const VALID = { valid: true };
@@ -786,7 +767,7 @@ const validateBindingValue = (binding, value) => {
786
767
  }
787
768
  return VALID;
788
769
  };
789
-
790
770
  //#endregion
791
771
  export { parseArrayExpression as _, bulkUpdate as a, extract as c, getCurrentValue as d, parseBinding as f, extractObjectProperties as g, extractNodeValue as h, replaceIds as i, nanoid as l, createNodeFromValue as m, clone as n, update as o, arrayExpressionToCode as p, fillIds as r, clearExtractCache as s, validateBindingValue as t, findEditableChildren as u, parseValue as v, generateCode as y };
792
- //# sourceMappingURL=ast-C0FNDLFQ.mjs.map
772
+
773
+ //# sourceMappingURL=ast-Dq1EfxA5.js.map