@volter/editor-react 0.5.67 → 0.5.68

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.
@@ -1114,6 +1114,16 @@ ${child}${parentIndent}${code.slice(closingTagStart)}`, changed: true };
1114
1114
  function insertSiblingElement(code, elementStart, snippet) {
1115
1115
  const trimmed = snippet.trim();
1116
1116
  if (!trimmed.startsWith("<")) return { code, changed: false };
1117
+ let before = elementStart - 1;
1118
+ while (before >= 0 && /\s/.test(code[before])) before--;
1119
+ const arrowBody = code[before] === ">" && code[before - 1] === "=";
1120
+ if (before < 0 || arrowBody || code[before] !== ">" && code[before] !== "}") {
1121
+ return {
1122
+ code,
1123
+ changed: false,
1124
+ error: "this element is not a JSX child (a lone returned element), so it can have no sibling."
1125
+ };
1126
+ }
1117
1127
  const r = lineBlockRange(code, elementStart);
1118
1128
  if (!r) return { code, changed: false };
1119
1129
  const indent = code.slice(r.lineStart, elementStart).match(/^(\s*)/)?.[1] ?? "";
@@ -5006,7 +5016,10 @@ function planSourceEdit(request, sources, resolveOid, utilityClasses = UTILITY_C
5006
5016
  request.ensureImport.module,
5007
5017
  request.ensureImport.kind
5008
5018
  ).code : result.code;
5009
- return planned(entry.file, src, code, { changed: result.changed });
5019
+ return planned(entry.file, src, code, {
5020
+ changed: result.changed,
5021
+ ...result.error ? { error: result.error } : {}
5022
+ });
5010
5023
  }
5011
5024
 
5012
5025
  // src/source/r3f-diagnostic-index.ts
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@volter/editor-react",
3
3
  "author": "Volter AI, Inc.",
4
4
  "license": "AGPL-3.0-only",
5
- "version": "0.5.67",
5
+ "version": "0.5.68",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -38,8 +38,8 @@
38
38
  "serving": "./dist-node/serving.mjs"
39
39
  },
40
40
  "dependencies": {
41
- "@volter/editor-sdk": "0.5.67",
42
- "@volter/editor-project": "0.5.67",
41
+ "@volter/editor-sdk": "0.5.68",
42
+ "@volter/editor-project": "0.5.68",
43
43
  "typescript": "5.9.3"
44
44
  },
45
45
  "peerDependencies": {
@@ -349,5 +349,8 @@ export function planSourceEdit(
349
349
  request.ensureImport.kind,
350
350
  ).code
351
351
  : result.code;
352
- return planned(entry.file, src, code, { changed: result.changed });
352
+ return planned(entry.file, src, code, {
353
+ changed: result.changed,
354
+ ...(result.error ? { error: result.error } : {}),
355
+ });
353
356
  }
@@ -1565,6 +1565,8 @@ export function removePropAttribute(
1565
1565
  export interface StructEditResult {
1566
1566
  code: string;
1567
1567
  changed: boolean;
1568
+ /** Why an op that could not apply refused, when it can say. */
1569
+ error?: string;
1568
1570
  }
1569
1571
 
1570
1572
  /** Expand a JSX element at `elementStart` to its full LINE block (leading whitespace on the
@@ -1809,6 +1811,19 @@ export function insertSiblingElement(
1809
1811
  ): StructEditResult {
1810
1812
  const trimmed = snippet.trim();
1811
1813
  if (!trimmed.startsWith('<')) return { code, changed: false };
1814
+ // A sibling is legal only beside a JSX CHILD: an element whose text is preceded by a tag's `>`
1815
+ // (not an arrow's `=>`) or an expression child's `}`. The lone element a component returns has no JSX parent, and a
1816
+ // second element beside it is a syntax error, never an insert.
1817
+ let before = elementStart - 1;
1818
+ while (before >= 0 && /\s/.test(code[before]!)) before--;
1819
+ const arrowBody = code[before] === '>' && code[before - 1] === '=';
1820
+ if (before < 0 || arrowBody || (code[before] !== '>' && code[before] !== '}')) {
1821
+ return {
1822
+ code,
1823
+ changed: false,
1824
+ error: 'this element is not a JSX child (a lone returned element), so it can have no sibling.',
1825
+ };
1826
+ }
1812
1827
  const r = lineBlockRange(code, elementStart);
1813
1828
  if (!r) return { code, changed: false };
1814
1829
  const indent = code.slice(r.lineStart, elementStart).match(/^(\s*)/)?.[1] ?? '';