@jbpark/live-editor 2.0.0 → 2.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-BKQmEBj9.js","names":["_generate","t","parseExpression","t","parseExpression","parseExpression","t","t","parseExpression","t","parseExpression","t","parse","t","parseExpression","parse"],"sources":["../src/utils/ast/types.ts","../src/utils/ast/helpers.ts","../src/utils/ast/value.ts","../src/utils/ast/binding.ts","../src/utils/selection.ts","../src/utils/ast/tree.ts","../src/utils/ast/items.ts","../src/utils/ast/extract.ts","../src/utils/ast/patch.ts","../src/utils/ast/update.ts","../src/utils/ast/validate.ts"],"sourcesContent":["export interface Attribute {\n name: string;\n value: string | null;\n isStringLiteral?: boolean;\n}\n\nexport interface DataAttrNode {\n id?: string;\n tagName: string;\n attributes: Attribute[];\n dataAttributes: Attribute[];\n textContent: string;\n rawChildren?: string;\n loc?: {\n start: { line: number; column: number };\n end: { line: number; column: number };\n };\n children?: DataAttrNode[];\n isFragment?: boolean;\n bindings?: BindingItem[];\n}\n\nexport interface BindingOption {\n label: string;\n value: string;\n}\n\n// `icon-picker`/`asset-picker` are kept here as deprecated aliases, not\n// removed — see #236. They describe a *control*, not a data kind, and\n// conflating that with the rest of this list (which does describe what a\n// value actually is) left a consumer with nowhere to express their own\n// widget choice. `parseBinding` normalizes an authored `type: 'icon-picker'`\n// into `{ type: 'string', widget: 'icon-picker' }` rather than passing it\n// through as-is, so existing authored content keeps working unchanged while\n// `BindingItem.widget` becomes the real, open-ended home for this axis.\nexport const BINDING_TYPES = [\n 'array',\n 'object',\n 'string',\n 'number',\n 'boolean',\n 'color',\n 'jsx',\n 'richtext',\n 'date',\n 'url',\n 'icon-picker',\n 'asset-picker',\n] as const;\n\nexport type BindingType = (typeof BINDING_TYPES)[number];\n\nexport interface BindingRenderLeaf {\n // Optional, matching the top-level BindingItem.type — an unrecognized\n // leaf type degrades to untyped instead of dropping the entry (see\n // sanitizeRenderMap in binding.ts and #234).\n type?: BindingType;\n property?: string;\n render?: BindingRenderMap;\n}\n\nexport interface BindingRenderMap {\n [key: string]: BindingRenderLeaf | BindingRenderMap;\n}\n\nexport interface BindingItem {\n label: string;\n property: string;\n // Data kind — what the value *is*. Closed, since the library's own\n // validation/coercion (validateBindingValue, parseValue) has to be able\n // to switch on it exhaustively.\n type?: BindingType;\n // Presentation — how to *render* it. Deliberately an open string, not a\n // closed enum: the library cannot enumerate controls it doesn't\n // implement, and a renderPanel consumer owns presentation once they use\n // it (see #234/#236). `'icon-picker'`/`'asset-picker'` are the built-in\n // panel's own two widgets; anything else (e.g. `'slider'`) is free for a\n // custom renderPanel to switch on.\n widget?: string;\n options?: BindingOption[];\n render?: BindingRenderMap;\n min?: number;\n max?: number;\n pattern?: string;\n required?: boolean;\n // Consumer-defined keys that aren't one of the fields above (`step`,\n // `unit`, a widget hint, ...) — namespaced here rather than spread onto\n // the item itself so they can't collide with a future first-class field.\n // Undefined when nothing extra was authored, not an empty object. See\n // #234: `parseBinding` used to silently strip these.\n meta?: Record<string, unknown>;\n}\n\nexport type NodeValueType =\n 'boolean' | 'number' | 'string' | 'null' | 'array' | 'object' | 'unknown';\n\nexport type EditableNodeValueType = 'boolean' | 'number' | 'string' | 'null';\n\nexport interface ExtractedNodeValue {\n type: NodeValueType;\n value: string | number | boolean | null;\n}\n","import _generate from '@babel/generator';\nimport { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport { REGEX } from '../../constants';\nimport type { Attribute } from './types';\n\n// Same @babel/* CJS/ESM interop issue as document.ts's traverse import:\n// @babel/generator's CJS build re-exports itself as `{ default: generate,\n// generate, CodeGenerator }`, and Vite's browser dependency pre-bundling\n// doesn't unwrap that inner `.default` again — `generate` resolved to the\n// whole exports object, not the function. Every generateCode() call threw,\n// which extract.ts's extractAttributes() silently swallows into a `null`\n// attribute value, and update.ts's callers surface as \"Failed to parse/\n// update this section\" toasts.\nconst generate =\n typeof _generate === 'function'\n ? _generate\n : (_generate as unknown as { default: typeof _generate }).default;\n\nexport const wrap = (code: string) => {\n return `<>${code}</>`;\n};\n\nexport const unwrap = (generated: string) => {\n return generated\n .replace(/^<>\\s*/g, '')\n .replace(/\\s*<\\/>\\s*;?\\s*$/g, '')\n .trim();\n};\n\nexport const attrValue = ({\n value,\n isStringLiteral,\n}: Attribute): t.JSXAttribute['value'] => {\n if (value === null) {\n return null;\n }\n\n if (isStringLiteral) {\n return t.stringLiteral(value);\n }\n\n const trimmed = value.trim();\n\n if (REGEX.NUMBER.test(trimmed)) {\n return t.jsxExpressionContainer(t.numericLiteral(parseFloat(trimmed)));\n }\n\n if (REGEX.BOOLEAN_OR_NULL.test(trimmed)) {\n const expr = parseExpression(trimmed, {\n plugins: ['jsx', 'typescript'],\n });\n return t.jsxExpressionContainer(expr);\n }\n\n try {\n const expr = parseExpression(trimmed, {\n plugins: ['jsx', 'typescript'],\n });\n return t.jsxExpressionContainer(expr);\n } catch {\n return t.stringLiteral(trimmed);\n }\n};\n\nexport const generateCode = (node: t.Node): string => {\n return generate(node, { jsescOption: { minimal: true } }).code;\n};\n","import { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport { REGEX } from '../../constants';\nimport { generateCode } from './helpers';\nimport type { ExtractedNodeValue, NodeValueType } from './types';\n\nconst dedent = (str: string): string => {\n const lines = str\n .replace(/^\\n/, '')\n .replace(/\\n\\s*$/, '')\n .split('\\n');\n\n const indent = lines.reduce((min, line) => {\n if (!line.trim()) {\n return min;\n }\n const match = line.match(/^(\\s*)/);\n return Math.min(min, match?.[1]?.length ?? 0);\n }, Infinity);\n\n return indent === Infinity\n ? str.trim()\n : lines.map(line => line.slice(indent)).join('\\n');\n};\n\n// Peel type-only wrappers and parentheses off an expression so the literal\n// underneath can be read. Authored bindings may carry `satisfies BindingItem[]`\n// (or `as const`, a type assertion, ...) for editor type-safety; those are\n// erased at build time and mean nothing to this literal evaluator, so without\n// unwrapping them the value — or the whole binding array — would be silently\n// dropped as \"not a literal\".\nexport const unwrapExpression = (node: t.Node): t.Node => {\n let current = node;\n\n while (\n t.isTSAsExpression(current) ||\n t.isTSSatisfiesExpression(current) ||\n t.isTSNonNullExpression(current) ||\n t.isTSTypeAssertion(current) ||\n t.isParenthesizedExpression(current)\n ) {\n current = current.expression;\n }\n\n return current;\n};\n\n// AST 노드를 코드 실행(new Function/eval) 없이 순수 리터럴 구조만 재귀적으로\n// 실제 JS 값으로 변환한다. 함수 호출, 변수 참조 등 리터럴이 아닌 표현식은\n// 평가하지 않고 undefined를 반환한다 — 사용자 코드는 iframe 안에서만 실행한다는\n// 이 저장소의 원칙(AGENTS.md)을 이 패널 UI(메인 문서에서 렌더링됨)에서도 지키기 위함.\nexport const evaluateLiteral = (rawNode: t.Node): unknown => {\n const node = unwrapExpression(rawNode);\n\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n\n if (t.isNumericLiteral(node)) {\n return node.value;\n }\n\n if (t.isBooleanLiteral(node)) {\n return node.value;\n }\n\n if (t.isNullLiteral(node)) {\n return null;\n }\n\n if (t.isIdentifier(node) && node.name === 'undefined') {\n return undefined;\n }\n\n if (\n t.isUnaryExpression(node) &&\n node.operator === '-' &&\n t.isNumericLiteral(node.argument)\n ) {\n return -node.argument.value;\n }\n\n if (t.isTemplateLiteral(node) && node.expressions.length === 0) {\n return node.quasis[0]?.value.cooked ?? node.quasis[0]?.value.raw ?? '';\n }\n\n if (t.isJSXElement(node) || t.isJSXFragment(node)) {\n return generateCode(node);\n }\n\n if (t.isArrayExpression(node)) {\n return node.elements.map(element =>\n element ? evaluateLiteral(element) : null,\n );\n }\n\n if (t.isObjectExpression(node)) {\n const result: Record<string, unknown> = {};\n\n for (const prop of node.properties) {\n if (!t.isObjectProperty(prop)) {\n continue;\n }\n\n let key: string | null = null;\n\n if (t.isIdentifier(prop.key)) {\n key = prop.key.name;\n } else if (t.isStringLiteral(prop.key)) {\n key = prop.key.value;\n } else if (t.isNumericLiteral(prop.key)) {\n key = String(prop.key.value);\n }\n\n if (key === null) {\n continue;\n }\n\n result[key] = evaluateLiteral(prop.value);\n }\n\n return result;\n }\n\n return undefined;\n};\n\nexport const parseValue = (value: unknown): unknown => {\n if (typeof value !== 'string') {\n return value;\n }\n\n const trimmed = value.trim();\n\n if (!trimmed) {\n return value;\n }\n\n if (REGEX.NUMBER.test(trimmed)) {\n return parseFloat(trimmed);\n }\n\n if (REGEX.BOOLEAN_OR_NULL.test(trimmed)) {\n if (trimmed === 'true') {\n return true;\n }\n if (trimmed === 'false') {\n return false;\n }\n if (trimmed === 'null') {\n return null;\n }\n if (trimmed === 'undefined') {\n return undefined;\n }\n }\n\n if (\n (trimmed.startsWith('{') && trimmed.endsWith('}')) ||\n (trimmed.startsWith('[') && trimmed.endsWith(']'))\n ) {\n try {\n const ast = parseExpression(trimmed, {\n plugins: ['jsx', 'typescript'],\n });\n\n if (t.isObjectExpression(ast) || t.isArrayExpression(ast)) {\n return evaluateLiteral(ast);\n }\n } catch {\n /* ignore */\n }\n\n return value;\n }\n\n return value;\n};\n\nexport type EditablePathSegment = string | number;\nexport type EditablePrimitive = string | number | boolean;\n\nexport interface EditableValueEntry {\n path: EditablePathSegment[];\n value: EditablePrimitive;\n}\n\nconst MAX_FLATTEN_DEPTH = 20;\n\nconst isEditablePrimitive = (value: unknown): value is EditablePrimitive =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean';\n\n// A binding's data-binding declaration is one way to know a value is\n// structured (`type: 'object'` + a `render` map — see #225), but most\n// existing content declares neither; it's just an object/array-shaped\n// string because that's what the bound prop actually is (e.g. `style`).\n// This recovers editable leaves from the *parsed value's own shape*\n// instead, so it works on content authored without a renderPanel in mind\n// — including an array of objects whose own members embed further JSX\n// (Live Editor's shipped Stats/FAQ sections both look like this: an\n// `items` array of `{ key, children }`, where `children` is itself a\n// nested, separately data-bound element). A JSX-bearing string is never\n// parsed further here — `parseValue` already reduced it to plain text\n// (see `evaluateLiteral`'s JSXElement case), and this function only ever\n// recurses into genuine object/array structure, treating every string,\n// number, and boolean as a leaf regardless of what the string contains.\n// Depth is capped defensively (pathological/deeply-recursive input\n// shouldn't be able to blow the stack); anything past that depth is\n// treated as a leaf-less dead end and simply omitted, not thrown.\nexport const flattenEditableValue = (\n value: string,\n): EditableValueEntry[] | null => {\n const parsed = parseValue(value);\n\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n Object.keys(parsed).length === 0\n ) {\n return null;\n }\n\n const entries: EditableValueEntry[] = [];\n\n const walk = (node: unknown, path: EditablePathSegment[], depth: number) => {\n if (depth > MAX_FLATTEN_DEPTH) {\n return;\n }\n\n if (isEditablePrimitive(node)) {\n entries.push({ path, value: node });\n return;\n }\n\n if (Array.isArray(node)) {\n node.forEach((item, index) => walk(item, [...path, index], depth + 1));\n return;\n }\n\n if (typeof node === 'object' && node !== null) {\n Object.entries(node).forEach(([key, item]) =>\n walk(item, [...path, key], depth + 1),\n );\n }\n\n // null/undefined/function/symbol values have no editable leaf form —\n // silently omitted rather than represented as, say, an empty string,\n // which would misrepresent what's actually stored there.\n };\n\n walk(parsed, [], 0);\n\n return entries.length ? entries : null;\n};\n\n// Companion to `flattenEditableValue`: replaces the single leaf at `path`\n// and re-serializes the whole structure — the result is a plain string\n// suitable for `PanelBinding.onChange`/`Dnd`'s AST-update pipeline, same\n// as any other committed value. Fails safe: an out-of-range index, a\n// missing key, or a `value` that didn't parse to an object/array in the\n// first place returns `value` unchanged rather than throwing or silently\n// writing to the wrong place.\nexport const setEditableValue = (\n value: string,\n path: EditablePathSegment[],\n next: EditablePrimitive,\n): string => {\n if (!path.length) {\n return value;\n }\n\n const parsed = parseValue(value);\n\n if (typeof parsed !== 'object' || parsed === null) {\n return value;\n }\n\n const root: unknown = Array.isArray(parsed) ? [...parsed] : { ...parsed };\n let cursor: Record<EditablePathSegment, unknown> | unknown[] = root as\n Record<EditablePathSegment, unknown> | unknown[];\n\n for (let i = 0; i < path.length - 1; i++) {\n const key = path[i]!;\n const child = (cursor as Record<EditablePathSegment, unknown>)[key];\n\n if (typeof child !== 'object' || child === null) {\n return value;\n }\n\n const clonedChild = Array.isArray(child) ? [...child] : { ...child };\n (cursor as Record<EditablePathSegment, unknown>)[key] = clonedChild;\n cursor = clonedChild as Record<EditablePathSegment, unknown> | unknown[];\n }\n\n const lastKey = path[path.length - 1]!;\n\n if (!(lastKey in (cursor as object))) {\n return value;\n }\n\n (cursor as Record<EditablePathSegment, unknown>)[lastKey] = next;\n\n return JSON.stringify(root);\n};\n\nexport const extractNodeValue = (node: t.Node): ExtractedNodeValue => {\n if (t.isBooleanLiteral(node)) {\n return { type: 'boolean', value: node.value };\n }\n\n if (t.isNumericLiteral(node)) {\n return { type: 'number', value: node.value };\n }\n\n if (\n t.isUnaryExpression(node) &&\n node.operator === '-' &&\n t.isNumericLiteral(node.argument)\n ) {\n return { type: 'number', value: -node.argument.value };\n }\n\n if (t.isStringLiteral(node)) {\n return { type: 'string', value: node.value };\n }\n\n if (t.isTemplateLiteral(node)) {\n if (node.expressions.length === 0 && node.quasis.length === 1) {\n return {\n type: 'string',\n value: dedent(\n node.quasis[0]!.value.cooked ?? node.quasis[0]!.value.raw,\n ),\n };\n }\n return { type: 'string', value: generateCode(node) };\n }\n\n if (t.isNullLiteral(node)) {\n return { type: 'null', value: null };\n }\n\n if (t.isArrayExpression(node)) {\n return { type: 'array', value: generateCode(node) };\n }\n\n if (t.isObjectExpression(node)) {\n return { type: 'object', value: generateCode(node) };\n }\n\n if (t.isJSXElement(node) || t.isJSXFragment(node)) {\n return { type: 'string', value: generateCode(node) };\n }\n\n return { type: 'unknown', value: null };\n};\n\nexport const createNodeFromValue = (\n type: NodeValueType,\n value: unknown,\n): t.Expression | null => {\n switch (type) {\n case 'boolean': {\n return t.booleanLiteral(value === true);\n }\n case 'number': {\n return t.numericLiteral(Number(value));\n }\n case 'string': {\n return t.stringLiteral(String(value));\n }\n case 'null': {\n return t.nullLiteral();\n }\n case 'array':\n case 'object':\n case 'unknown': {\n return null;\n }\n default: {\n return null;\n }\n }\n};\n\n// Faithfully rebuilds a JS value into an AST expression node — the inverse\n// of `evaluateLiteral`, and the single serialization point #238 moves the\n// panel's value contract onto. Because the caller already knows what the\n// value *is* (a real number/boolean/object/array, not a string that has to\n// be re-guessed), there is no string-vs-expression heuristic here: each JS\n// type maps to exactly one literal kind. Values with no literal form\n// (`undefined`, functions, symbols) are dropped — an object property whose\n// value is `undefined` is omitted rather than emitted as `undefined`,\n// mirroring `flattenEditableValue`, which also treats them as absent.\nexport const valueToExpression = (value: unknown): t.Expression | null => {\n if (typeof value === 'string') {\n return t.stringLiteral(value);\n }\n\n if (typeof value === 'number') {\n return value < 0\n ? t.unaryExpression('-', t.numericLiteral(-value))\n : t.numericLiteral(value);\n }\n\n if (typeof value === 'boolean') {\n return t.booleanLiteral(value);\n }\n\n if (value === null) {\n return t.nullLiteral();\n }\n\n if (Array.isArray(value)) {\n return t.arrayExpression(\n value.map(item => valueToExpression(item) ?? t.nullLiteral()),\n );\n }\n\n if (typeof value === 'object') {\n const properties: t.ObjectProperty[] = [];\n\n for (const [key, item] of Object.entries(value)) {\n const expr = valueToExpression(item);\n if (expr === null) {\n continue;\n }\n properties.push(t.objectProperty(t.stringLiteral(key), expr));\n }\n\n return t.objectExpression(properties);\n }\n\n return null;\n};\n\nexport const parseArrayExpression = (value: string) => {\n try {\n const ast = unwrapExpression(\n parseExpression(value, {\n plugins: ['jsx', 'typescript'],\n }),\n );\n\n if (!t.isArrayExpression(ast)) {\n return null;\n }\n\n return ast;\n } catch (error) {\n console.error('❌ Array parsing error:', error);\n return null;\n }\n};\n\nexport const extractObjectProperties = (\n element: t.ObjectExpression,\n): Record<string, ExtractedNodeValue & { astNode: t.Node }> => {\n const properties: Record<string, ExtractedNodeValue & { astNode: t.Node }> =\n {};\n\n element.properties.forEach(prop => {\n if (t.isObjectProperty(prop) && t.isIdentifier(prop.key)) {\n const key = prop.key.name;\n\n if (key === 'children') {\n return;\n }\n\n const extracted = extractNodeValue(prop.value);\n\n properties[key] = {\n ...extracted,\n astNode: prop.value,\n };\n }\n });\n\n return properties;\n};\n\nexport const arrayExpressionToCode = (\n elements: t.ObjectExpression[],\n): string => {\n const nextAst = t.arrayExpression(elements);\n return generateCode(nextAst);\n};\n","import { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { z } from 'zod';\n\nimport { BINDING_PROP, DATA_ATTR } from '../../constants';\nimport {\n BINDING_TYPES,\n type BindingItem,\n type BindingOption,\n type BindingRenderMap,\n type BindingType,\n type DataAttrNode,\n} from './types';\nimport { evaluateLiteral, parseArrayExpression, parseValue } from './value';\n\nconst bindingTypeSchema = z.enum(BINDING_TYPES);\n\nconst bindingOptionSchema = z.object({\n label: z.string(),\n value: z.string(),\n});\n\n// `type` is validated separately in sanitizeRenderMap (like the top-level\n// item's own type) so an unrecognized value degrades the leaf to untyped\n// instead of failing this whole schema — see #234.\nconst bindingRenderLeafSchema = z.object({\n property: z.string().optional(),\n});\n\n// `widget` is deliberately just `z.string()`, not an enum — see #236. An\n// unrecognized widget is expected (a renderPanel consumer's own value, not\n// this library's), so unlike `type` there is no \"drop it\" failure mode to\n// design for.\n//\n// `.passthrough()` (rather than the default `.strip()`) keeps any key this\n// schema doesn't know about instead of silently discarding it — see #234.\n// A consumer's own metadata (`step`, `unit`, a widget hint, ...) survives\n// parsing and is surfaced separately as `meta` below, namespaced instead of\n// spread onto the item, so it can't collide with a future first-class field.\nconst rawBindingItemSchema = z\n .object({\n label: z.string(),\n property: z.string().optional(),\n type: bindingTypeSchema.optional(),\n widget: z.string().optional(),\n options: z.array(bindingOptionSchema).optional(),\n min: z.number().optional(),\n max: z.number().optional(),\n pattern: z.string().optional(),\n required: z.boolean().optional(),\n })\n .passthrough();\n\n// Every key `rawBindingItemSchema` declares, plus `render` (handled by\n// `sanitizeRenderMap` separately, never through this schema) — anything\n// else surviving `.passthrough()` is consumer-defined and belongs in `meta`,\n// not treated as one of this library's own fields.\nconst KNOWN_BINDING_KEYS = new Set([\n 'label',\n 'property',\n 'type',\n 'widget',\n 'options',\n 'render',\n 'min',\n 'max',\n 'pattern',\n 'required',\n]);\n\n// The two BINDING_TYPES entries that describe a control, not a data kind —\n// see the type/widget split in #236. Normalized below into `widget` instead\n// of being passed through as `type` directly.\nconst WIDGET_TYPE_ALIASES = new Set(['icon-picker', 'asset-picker']);\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n// A render map entry is either a \"leaf\" (has its own `type`) or a nested\n// map of further entries — recurse into whichever it looks like, and drop\n// anything that matches neither instead of failing the whole map.\nconst sanitizeRenderMap = (value: unknown): BindingRenderMap | undefined => {\n if (!isPlainObject(value)) {\n return undefined;\n }\n\n const map: BindingRenderMap = {};\n\n for (const [key, raw] of Object.entries(value)) {\n if (!isPlainObject(raw)) {\n continue;\n }\n\n if ('type' in raw) {\n // Drop an unrecognized `type` down to untyped instead of dropping the\n // whole entry — matches the top-level item's own behavior at\n // `bindingTypeSchema.safeParse(rawItem.type)` above. Keeping the\n // entry (rather than deleting the key) is what #234 asked for: a\n // typo'd/future leaf type still shows up as a plain field instead of\n // vanishing, and `'type' in leaf` stays true either way since `type`\n // is always set below, even to `undefined`.\n const sanitizedType = bindingTypeSchema.safeParse(raw.type);\n const leaf = bindingRenderLeafSchema.safeParse(raw);\n\n if (leaf.success) {\n const render = sanitizeRenderMap(raw.render);\n const typedLeaf = {\n ...leaf.data,\n type: sanitizedType.success ? sanitizedType.data : undefined,\n };\n\n map[key] = render ? { ...typedLeaf, render } : typedLeaf;\n }\n continue;\n }\n\n const nested = sanitizeRenderMap(raw);\n\n if (nested) {\n map[key] = nested;\n }\n }\n\n return Object.keys(map).length > 0 ? map : undefined;\n};\n\n// Shared tail of `parseBinding`/`parseBindingExpression`: turn the raw,\n// already-evaluated array literal into validated `BindingItem[]`. The two\n// callers differ only in how they reach this array — from a source string\n// (public API) or straight off an expression AST (extract's hot path).\nconst buildBindingItems = (raw: unknown): BindingItem[] => {\n if (!Array.isArray(raw)) {\n return [];\n }\n\n const items: BindingItem[] = [];\n\n for (const rawItem of raw) {\n if (!isPlainObject(rawItem)) {\n continue;\n }\n\n // Drop an unrecognized `type` instead of rejecting the whole item — an\n // authored binding with a typo'd/future type string still works as an\n // untyped field rather than disappearing entirely.\n const sanitizedType = bindingTypeSchema.safeParse(rawItem.type);\n\n // `icon-picker`/`asset-picker` describe a widget, not a data kind\n // (#236) — normalize them into `widget` instead of passing them\n // through as `type`. An explicitly authored `widget` (checked below,\n // once the schema has validated it) wins if both are somehow present.\n const isWidgetAlias =\n sanitizedType.success && WIDGET_TYPE_ALIASES.has(sanitizedType.data);\n const normalizedType = isWidgetAlias\n ? 'string'\n : sanitizedType.success\n ? sanitizedType.data\n : undefined;\n const derivedWidget = isWidgetAlias ? sanitizedType.data : undefined;\n\n // Drop individually malformed options instead of rejecting the whole\n // item — a select field with 3 valid options and 1 malformed one should\n // still work with the 3 valid ones.\n const sanitizedOptions = Array.isArray(rawItem.options)\n ? rawItem.options\n .map(option => {\n const parsed = bindingOptionSchema.safeParse(option);\n return parsed.success ? parsed.data : null;\n })\n .filter((option): option is BindingOption => option !== null)\n : undefined;\n\n const parsed = rawBindingItemSchema.safeParse({\n ...rawItem,\n type: normalizedType,\n options: sanitizedOptions?.length ? sanitizedOptions : undefined,\n });\n\n if (!parsed.success) {\n continue;\n }\n\n const {\n label,\n property,\n type,\n widget: explicitWidget,\n options,\n min,\n max,\n pattern,\n required,\n } = parsed.data;\n const widget = explicitWidget ?? derivedWidget;\n\n if (property === undefined && type !== 'richtext') {\n continue;\n }\n\n const render = sanitizeRenderMap(rawItem.render);\n\n const metaEntries = Object.entries(parsed.data).filter(\n ([key]) => !KNOWN_BINDING_KEYS.has(key),\n );\n const meta =\n metaEntries.length > 0 ? Object.fromEntries(metaEntries) : undefined;\n\n items.push({\n label,\n property: property ?? BINDING_PROP.INNER_HTML,\n ...(type !== undefined && { type }),\n ...(widget !== undefined && { widget }),\n ...(options?.length && { options }),\n ...(render && { render }),\n ...(min !== undefined && { min }),\n ...(max !== undefined && { max }),\n ...(pattern !== undefined && { pattern }),\n ...(required !== undefined && { required }),\n ...(meta && { meta }),\n });\n }\n\n return items;\n};\n\nexport const parseBinding = (bindingValue: string | null): BindingItem[] => {\n if (!bindingValue) {\n return [];\n }\n\n const ast = parseArrayExpression(bindingValue);\n\n if (!ast) {\n return [];\n }\n\n return buildBindingItems(evaluateLiteral(ast));\n};\n\n// Same result as `parseBinding`, but fed the array-literal expression the\n// parser already produced instead of a source string. `extract` authors\n// `data-binding` as a real JSX object-array expression, so re-serializing it\n// to a string only to `parseExpression` it straight back was a wasted Babel\n// round-trip (#241's \"two parsers\"); evaluate that AST in place.\nexport const parseBindingExpression = (\n expression: t.ArrayExpression,\n): BindingItem[] => buildBindingItems(evaluateLiteral(expression));\n\nexport const getCurrentValue = (\n node: DataAttrNode,\n property: string,\n): string => {\n switch (property) {\n case BINDING_PROP.INNER_TEXT: {\n return node.textContent || '';\n }\n\n case BINDING_PROP.INNER_HTML: {\n // richtext 타입: dangerouslySetInnerHTML={{ __html }} 에서 읽기\n const dsiAttr = node.attributes.find(\n a => a.name === 'dangerouslySetInnerHTML',\n );\n if (dsiAttr?.value) {\n try {\n const expr = parseExpression(dsiAttr.value, {\n plugins: ['jsx', 'typescript'],\n });\n if (t.isObjectExpression(expr)) {\n const htmlProp = expr.properties.find(\n p =>\n t.isObjectProperty(p) &&\n t.isIdentifier(p.key) &&\n p.key.name === '__html',\n ) as t.ObjectProperty | undefined;\n if (htmlProp) {\n if (t.isStringLiteral(htmlProp.value)) {\n return htmlProp.value.value;\n }\n if (\n t.isTemplateLiteral(htmlProp.value) &&\n htmlProp.value.expressions.length === 0\n ) {\n return (\n htmlProp.value.quasis[0]?.value.cooked ??\n htmlProp.value.quasis[0]?.value.raw ??\n ''\n );\n }\n }\n }\n } catch {\n // ignore\n }\n }\n return node.rawChildren || node.textContent || '';\n }\n\n case BINDING_PROP.CHILDREN: {\n return JSON.stringify(node?.children || []);\n }\n\n default: {\n const customAttr = node.attributes.find(attr => attr.name === property);\n const value = customAttr?.value || '';\n\n return value;\n }\n }\n};\n\n// Declared types whose value is genuinely text — never re-parsed into a\n// number/object/array even when the text happens to look like one. `jsx`\n// and `richtext` carry source that is an expression, not a literal, so they\n// stay as their exact source string too (the update pipeline re-inserts\n// them as expressions, not string literals).\nconst STRING_VALUED_TYPES: ReadonlySet<BindingType> = new Set([\n 'string',\n 'url',\n 'date',\n 'color',\n 'jsx',\n 'richtext',\n 'icon-picker',\n 'asset-picker',\n]);\n\n// Structured counterpart to `getCurrentValue`: returns the value as its real\n// JS type (number/boolean/object/array/string) rather than always as a\n// string, so both the built-in panel and a custom `renderPanel` receive\n// `PanelBinding.value` already typed. `getCurrentValue` still supplies the\n// exact source text (`PanelBinding.rawValue`). See #238.\n//\n// The string-vs-structure decision is made *here*, from information the AST\n// still has — an attribute that was a string literal in source is a genuine\n// string whatever its contents, so `\"{not an expression}\"` stays a string\n// instead of being re-parsed into an object. Only genuine expressions\n// (`count={3}`, `data={[...]}`) are recovered into their real shape.\nexport const getStructuredValue = (\n node: DataAttrNode,\n property: string,\n type?: BindingType,\n): unknown => {\n switch (property) {\n case BINDING_PROP.INNER_TEXT:\n case BINDING_PROP.INNER_HTML: {\n return getCurrentValue(node, property);\n }\n\n case BINDING_PROP.CHILDREN: {\n return node.children ?? [];\n }\n\n default: {\n const raw = getCurrentValue(node, property);\n const attr = node.attributes.find(a => a.name === property);\n\n if (attr?.isStringLiteral || (type && STRING_VALUED_TYPES.has(type))) {\n return raw;\n }\n\n return parseValue(raw);\n }\n }\n};\n\nconst hasEditableBindings = (node: DataAttrNode): boolean => {\n const bindingAttr = node.dataAttributes.find(\n attr => attr.name === DATA_ATTR.BINDING,\n );\n\n if (!bindingAttr?.value) {\n return false;\n }\n\n const bindings = node.bindings || parseBinding(bindingAttr.value);\n\n return bindings.length > 0;\n};\n\nexport const findEditableChildren = (node: DataAttrNode): DataAttrNode[] => {\n const editableChildren: DataAttrNode[] = [];\n\n const traverse = (children: DataAttrNode[] | undefined) => {\n if (!children) {\n return;\n }\n\n for (const child of children) {\n if (hasEditableBindings(child)) {\n editableChildren.push(child);\n }\n traverse(child.children);\n }\n };\n\n traverse(node.children);\n\n return editableChildren;\n};\n","export const removeIndices = <T>(items: T[], indices: Set<number>): T[] => {\n return items.filter((_, index) => !indices.has(index));\n};\n\n/**\n * Shifts every selected index up/down by one step as a block, preserving\n * relative order — scattered selections stop moving individually once they\n * hit an unselected neighbor, so the whole group slides together instead of\n * items passing through each other.\n */\nexport const moveSelectedIndices = <T>(\n items: T[],\n indices: Set<number>,\n direction: 'up' | 'down',\n): { items: T[]; indices: Set<number> } => {\n const next = [...items];\n const nextIndices = new Set(indices);\n\n const ordered = [...indices].sort((a, b) =>\n direction === 'up' ? a - b : b - a,\n );\n\n for (const index of ordered) {\n const target = direction === 'up' ? index - 1 : index + 1;\n\n if (target < 0 || target >= next.length || nextIndices.has(target)) {\n continue;\n }\n\n [next[index], next[target]] = [next[target]!, next[index]!];\n nextIndices.delete(index);\n nextIndices.add(target);\n }\n\n return { items: next, indices: nextIndices };\n};\n","import { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { nanoid } from 'nanoid';\n\nimport { DATA_ATTR } from '../../constants';\nimport { generateCode } from './helpers';\n\nexport const replaceIds = (\n code: string,\n generateId: () => string = () => nanoid(6),\n): string => {\n return code.replace(new RegExp(`${DATA_ATTR.ID}=\"[^\"]*\"`, 'g'), () => {\n return `${DATA_ATTR.ID}=\"${generateId()}\"`;\n });\n};\n\nexport const fillIds = (\n code: string,\n generateId: () => string = () => nanoid(6),\n): string => {\n return code.replace(new RegExp(`${DATA_ATTR.ID}=\"\"`, 'g'), () => {\n return `${DATA_ATTR.ID}=\"${generateId()}\"`;\n });\n};\n\nexport const clone = (\n element: t.Node,\n generateId: () => string = () => nanoid(6),\n) => {\n const cloned = t.cloneNode(element, true);\n const generatedCode = generateCode(cloned);\n const code = replaceIds(generatedCode, generateId);\n\n return parseExpression(code, {\n plugins: ['jsx', 'typescript'],\n });\n};\n","import { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { nanoid } from 'nanoid';\n\nimport { BINDING_PROP } from '../../constants';\nimport { moveSelectedIndices, removeIndices } from '../selection';\nimport { generateCode } from './helpers';\nimport { clone } from './tree';\nimport type {\n BindingRenderLeaf,\n BindingRenderMap,\n NodeValueType,\n} from './types';\nimport {\n createNodeFromValue,\n extractNodeValue,\n extractObjectProperties,\n parseArrayExpression,\n parseValue,\n valueToExpression,\n} from './value';\n\n// The editing engine behind the built-in array-item panel. Every function\n// here is string in, string out: the array source is re-parsed on each call\n// and the resulting tree is thrown away, so nothing is shared with a\n// caller's memoized state and there is no live AST to keep in sync.\n//\n// This used to live in `panel/items.tsx`, where it mutated the nodes held\n// by a `useMemo` and restored JSX by substituting `__JSX_<id>__` strings\n// into the generated output. Neither is needed: Babel prints JSX inside an\n// object literal correctly, and a raw JSX value parses straight into a\n// node. See #247.\n//\n// `null` means the edit could not be applied and the caller should keep the\n// value it already has.\n\nexport type ItemKind = 'object' | 'primitive';\n\nexport interface ArrayItem {\n // Position in the array's elements, which is what every function here\n // indexes by. Items of one kind are not renumbered, so a mixed array\n // stays addressable.\n index: number;\n kind: ItemKind;\n node: t.Expression;\n}\n\nconst elementsOf = (code: string): t.Expression[] | null => {\n const ast = parseArrayExpression(code);\n\n if (!ast) {\n return null;\n }\n\n return ast.elements.filter((element): element is t.Expression =>\n Boolean(element),\n );\n};\n\nconst kindOf = (element: t.Expression): ItemKind =>\n t.isObjectExpression(element) ? 'object' : 'primitive';\n\nconst toCode = (elements: t.Expression[]): string => {\n return generateCode(t.arrayExpression(elements));\n};\n\n// Reads the array's elements without touching them. The caller renders from\n// this; every edit goes back through the source string, never through these\n// nodes.\nexport const parseItems = (code: string): ArrayItem[] | null => {\n const elements = elementsOf(code);\n\n if (!elements) {\n return null;\n }\n\n return elements.map((node, index) => ({\n index,\n kind: kindOf(node),\n node,\n }));\n};\n\nconst resolveRenderLeaf = (\n render: BindingRenderMap | undefined,\n key: string,\n): BindingRenderLeaf | null => {\n const leaf = render?.[key];\n\n return leaf && 'type' in leaf ? (leaf as BindingRenderLeaf) : null;\n};\n\n// Whether a node's value survives `evaluateLiteral` intact. It returns\n// `undefined` for anything that isn't a literal and skips spread properties\n// outright, so rebuilding from its output would quietly drop an identifier,\n// a call, or a spread — `{ c: theme.red }` would be written back as `{}`.\n// Rebuilding is only safe when the node holds nothing but literals.\n//\n// The accepted set mirrors the branches `evaluateLiteral` and\n// `valueToExpression` both handle, so a shape that round-trips faithfully\n// isn't refused: a negative number is a `UnaryExpression`, not a literal\n// node, and an expression-free template literal is just a string.\nconst isLosslesslyEvaluable = (node: t.Node): boolean => {\n if (\n t.isStringLiteral(node) ||\n t.isNumericLiteral(node) ||\n t.isBooleanLiteral(node) ||\n t.isNullLiteral(node)\n ) {\n return true;\n }\n\n if (\n t.isUnaryExpression(node) &&\n node.operator === '-' &&\n t.isNumericLiteral(node.argument)\n ) {\n return true;\n }\n\n if (t.isTemplateLiteral(node)) {\n return node.expressions.length === 0;\n }\n\n if (t.isArrayExpression(node)) {\n return node.elements.every(\n element => element !== null && isLosslesslyEvaluable(element),\n );\n }\n\n if (t.isObjectExpression(node)) {\n return node.properties.every(\n property =>\n t.isObjectProperty(property) &&\n !property.computed &&\n (t.isIdentifier(property.key) ||\n t.isStringLiteral(property.key) ||\n t.isNumericLiteral(property.key)) &&\n isLosslesslyEvaluable(property.value),\n );\n }\n\n return false;\n};\n\n// Escapes text for a template literal's raw slot. `@babel/types` rejects a\n// raw containing an unescaped backtick or `${`, a lone backslash would\n// otherwise be read back as an escape sequence, and a carriage return is\n// normalized to a newline by the spec's raw-value rules — so raw markup\n// pasted into an innerHTML field used to throw straight out of the edit\n// handler, and CRLF would not survive a round trip.\nconst toTemplateRaw = (value: string): string => {\n return value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/`/g, '\\\\`')\n .replace(/\\$\\{/g, '\\\\${')\n .replace(/\\r/g, '\\\\r');\n};\n\n// Builds the node a property should hold, from the value the panel produced.\n// Returns `undefined` when the value can't be represented, which callers\n// treat as \"leave the source alone\".\nconst buildPropertyValue = (\n value: unknown,\n declaredType: NodeValueType,\n renderLeaf: BindingRenderLeaf | null,\n current: t.Expression,\n): t.Expression | undefined => {\n // innerHTML carries raw markup, which has to survive as written — a\n // template literal keeps it verbatim without escaping.\n if (renderLeaf?.property === BINDING_PROP.INNER_HTML) {\n const raw = String(value);\n\n return t.templateLiteral(\n [t.templateElement({ raw: toTemplateRaw(raw), cooked: raw }, true)],\n [],\n );\n }\n\n if (renderLeaf?.type === 'jsx') {\n const trimmed = String(value).trim();\n\n // Anything that isn't markup is a plain string for this property.\n if (!trimmed.startsWith('<')) {\n return t.stringLiteral(trimmed);\n }\n\n try {\n return parseExpression(trimmed, { plugins: ['jsx', 'typescript'] });\n } catch {\n return undefined;\n }\n }\n\n if (declaredType === 'array' || declaredType === 'object') {\n // The nested Items editor commits serialized source text, while the\n // object editor and the fallback TextArea commit a real JS value.\n // Parsing the former directly avoids evaluating it and `String()`-ing\n // it back to `1,2` (a sequence expression).\n if (typeof value === 'string') {\n try {\n return parseExpression(value, { plugins: ['jsx', 'typescript'] });\n } catch {\n return undefined;\n }\n }\n\n // The latter has already been through `evaluateLiteral`, so it can only\n // be rebuilt faithfully when the property held nothing but literals to\n // begin with. Otherwise the edit is refused and the source is left\n // alone, which is the safe half of what this path used to do.\n if (!isLosslesslyEvaluable(current)) {\n return undefined;\n }\n\n return valueToExpression(value) ?? undefined;\n }\n\n // Scalars arrive as the text typed into the field, so coerce before\n // building the literal — `createNodeFromValue('boolean', 'true')` would\n // otherwise compare the string against `true` and yield `false`.\n return createNodeFromValue(declaredType, parseValue(value)) ?? undefined;\n};\n\nexport const updateArrayItemProperty = (\n code: string,\n index: number,\n key: string,\n value: unknown,\n render?: BindingRenderMap,\n): string | null => {\n const elements = elementsOf(code);\n const element = elements?.[index];\n\n if (!elements || !t.isObjectExpression(element)) {\n return null;\n }\n\n const target = element.properties.find(\n (property): property is t.ObjectProperty =>\n t.isObjectProperty(property) &&\n t.isIdentifier(property.key) &&\n property.key.name === key,\n );\n\n if (!target) {\n return null;\n }\n\n const declaredType = extractObjectProperties(element)[key]?.type ?? 'string';\n const nextValue = buildPropertyValue(\n value,\n declaredType,\n resolveRenderLeaf(render, key),\n target.value as t.Expression,\n );\n\n if (!nextValue) {\n return null;\n }\n\n target.value = nextValue;\n\n return toCode(elements);\n};\n\nexport const updateArrayItemValue = (\n code: string,\n index: number,\n value: unknown,\n): string | null => {\n const elements = elementsOf(code);\n const element = elements?.[index];\n\n if (!elements || !element) {\n return null;\n }\n\n const nextValue = createNodeFromValue(\n extractNodeValue(element).type,\n parseValue(value),\n );\n\n if (!nextValue) {\n return null;\n }\n\n elements[index] = nextValue;\n\n return toCode(elements);\n};\n\nexport const moveArrayItem = (\n code: string,\n from: number,\n to: number,\n): string | null => {\n const elements = elementsOf(code);\n\n if (!elements?.[from]) {\n return null;\n }\n\n // `to` is left unchecked so the splice pair keeps its usual semantics: a\n // destination past the end appends, and a single-item move that goes\n // nowhere is a no-op rather than a reported failure.\n const next = [...elements];\n const [moved] = next.splice(from, 1);\n\n next.splice(to, 0, moved!);\n\n return toCode(next);\n};\n\n// Shifts the selection as a block and reports where it ended up, so the\n// caller can keep its selection state in step without redoing the maths.\nexport const moveArrayItems = (\n code: string,\n indices: Set<number>,\n direction: 'up' | 'down',\n): { code: string; indices: Set<number> } | null => {\n const elements = elementsOf(code);\n\n if (!elements) {\n return null;\n }\n\n const { items, indices: nextIndices } = moveSelectedIndices(\n elements,\n indices,\n direction,\n );\n\n return { code: toCode(items), indices: nextIndices };\n};\n\n// Refuses to remove the last item of its kind: the panel shows one kind at\n// a time and every \"add\" clones an existing item of that kind, so emptying\n// it leaves no way back. Counting the whole array instead would let the\n// object panel delete its last object while a primitive kept the total\n// above zero.\nexport const removeArrayItems = (\n code: string,\n indices: Set<number>,\n kind?: ItemKind,\n): string | null => {\n const elements = elementsOf(code);\n\n if (!elements) {\n return null;\n }\n\n const remaining = removeIndices(elements, indices);\n const survivors =\n kind === undefined\n ? remaining\n : remaining.filter(element => kindOf(element) === kind);\n\n if (survivors.length < 1) {\n return null;\n }\n\n return toCode(remaining);\n};\n\n// Gives a cloned item a fresh `key`, so React can still tell the copy from\n// its original, and normalizes its editable properties back to literals.\nconst cloneItem = (\n element: t.Expression,\n generateId: () => string,\n): t.Expression => {\n const cloned = clone(element) as t.Expression;\n\n if (!t.isObjectExpression(cloned)) {\n return cloned;\n }\n\n const editable = extractObjectProperties(cloned);\n\n cloned.properties.forEach(property => {\n if (!t.isObjectProperty(property) || !t.isIdentifier(property.key)) {\n return;\n }\n\n const key = property.key.name;\n\n if (key === 'key' && t.isStringLiteral(property.value)) {\n property.value = t.stringLiteral(\n `${property.value.value}-${generateId()}`,\n );\n return;\n }\n\n const source = editable[key];\n\n if (source) {\n const next = createNodeFromValue(source.type, source.value);\n\n if (next) {\n property.value = next;\n }\n }\n });\n\n return cloned;\n};\n\nexport const duplicateArrayItems = (\n code: string,\n indices: Set<number>,\n generateId: () => string = () => nanoid(6),\n): string | null => {\n const elements = elementsOf(code);\n\n if (!elements) {\n return null;\n }\n\n const clones = [...indices]\n .sort((a, b) => a - b)\n .map(index => elements[index])\n .filter((element): element is t.Expression => Boolean(element))\n .map(element => cloneItem(element, generateId));\n\n if (clones.length === 0) {\n return null;\n }\n\n return toCode([...elements, ...clones]);\n};\n\n// Appends a copy of the first item of `kind`. There is no schema to build a\n// blank item from, so an existing one is the only available template.\nexport const appendArrayItem = (\n code: string,\n kind: ItemKind,\n generateId: () => string = () => nanoid(6),\n): string | null => {\n const elements = elementsOf(code);\n\n if (!elements) {\n return null;\n }\n\n const template = elements.find(element => kindOf(element) === kind);\n\n if (!template) {\n return null;\n }\n\n if (kind === 'primitive') {\n const { type, value } = extractNodeValue(template);\n const next = createNodeFromValue(type, value);\n\n return next ? toCode([...elements, next]) : null;\n }\n\n return toCode([...elements, cloneItem(template, generateId)]);\n};\n","import { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { nanoid } from 'nanoid';\n\nimport { BINDING_PROP, CONFIG, DATA_ATTR } from '../../constants';\nimport { createBoundedCache } from '../cache';\nimport { parseBinding, parseBindingExpression } from './binding';\nimport { traverse } from './document';\nimport { attrValue, generateCode, wrap } from './helpers';\nimport type { Attribute, BindingItem, DataAttrNode } from './types';\nimport { unwrapExpression } from './value';\n\nconst collectText = (\n children: (\n | t.JSXText\n | t.JSXExpressionContainer\n | t.JSXElement\n | t.JSXFragment\n | t.JSXSpreadChild\n )[],\n) => {\n return children\n .filter(c => t.isJSXText(c))\n .map(c => (c as t.JSXText).value.trim())\n .filter(v => v.length)\n .join(' ');\n};\n\nconst getTagName = (opening: t.JSXOpeningElement): string => {\n if (t.isJSXIdentifier(opening.name)) {\n return opening.name.name;\n }\n\n if (t.isJSXMemberExpression(opening.name)) {\n return resolveMemberName(opening.name);\n }\n\n return '';\n};\n\nconst resolveMemberName = (expr: t.JSXMemberExpression): string => {\n const parts: string[] = [];\n\n const collectMemberParts = (\n node: t.JSXMemberExpression['object'] | t.JSXMemberExpression['property'],\n ): void => {\n if (t.isJSXIdentifier(node)) {\n parts.push(node.name);\n } else if (t.isJSXMemberExpression(node)) {\n collectMemberParts(node.object);\n\n if (t.isJSXIdentifier(node.property)) {\n parts.push(node.property.name);\n }\n }\n };\n\n collectMemberParts(expr.object);\n\n if (t.isJSXIdentifier(expr.property)) {\n parts.push(expr.property.name);\n }\n\n return parts.join('.');\n};\n\nconst parseJSXName = (\n tagName: string,\n): t.JSXIdentifier | t.JSXMemberExpression => {\n const parts = tagName.split('.');\n\n if (parts.length === 1) {\n return t.jsxIdentifier(parts[0]!);\n }\n\n let expr: t.JSXIdentifier | t.JSXMemberExpression = t.jsxIdentifier(\n parts[0]!,\n );\n\n for (let i = 1; i < parts.length; i++) {\n expr = t.jsxMemberExpression(expr, t.jsxIdentifier(parts[i]!));\n }\n\n return expr;\n};\n\nconst extractCache = createBoundedCache<string, DataAttrNode[]>(\n CONFIG.CACHE_LIMIT,\n);\n\nconst extractAttributes = (\n attributes: (t.JSXAttribute | t.JSXSpreadAttribute)[],\n): { allAttrs: Attribute[]; dataAttrs: Attribute[] } => {\n const allAttrs: Attribute[] = [];\n const dataAttrs: Attribute[] = [];\n\n for (const attr of attributes) {\n if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name)) {\n continue;\n }\n\n const name = attr.name.name;\n let value: string | null = null;\n let isStringLiteral = false;\n\n if (attr.value) {\n if (t.isStringLiteral(attr.value)) {\n value = attr.value.value;\n isStringLiteral = true;\n } else if (t.isJSXExpressionContainer(attr.value)) {\n try {\n value = generateCode(attr.value.expression);\n isStringLiteral = false;\n } catch {\n value = null;\n }\n }\n }\n\n const entry = { name, value, isStringLiteral };\n\n allAttrs.push(entry);\n\n if (name.startsWith('data-')) {\n dataAttrs.push(entry);\n }\n }\n\n return { allAttrs, dataAttrs };\n};\n\nconst buildChildElements = (\n node: DataAttrNode,\n): (t.JSXText | t.JSXElement | t.JSXFragment)[] => {\n const childElements: (t.JSXText | t.JSXElement | t.JSXFragment)[] = [];\n\n if (node.textContent) {\n childElements.push(t.jsxText(node.textContent));\n }\n\n node.children?.forEach(child => {\n const childJSX = nodeToJSX(child);\n if (childJSX) {\n childElements.push(childJSX);\n }\n });\n\n return childElements;\n};\n\nexport const nodeToJSX = (\n node: DataAttrNode,\n): t.JSXElement | t.JSXFragment | null => {\n try {\n if (node.isFragment) {\n const childElements = buildChildElements(node);\n\n return t.jsxFragment(\n t.jsxOpeningFragment(),\n t.jsxClosingFragment(),\n childElements,\n );\n }\n\n if (\n node.tagName === 'div' &&\n node.dataAttributes.some(attr => attr.name === 'data-item')\n ) {\n if (node.children) {\n return nodeToJSX(node.children[0]!);\n }\n return null;\n }\n\n const attributes = node.attributes.map(attr => {\n const attrName = t.jsxIdentifier(attr.name);\n\n if (!attr.value) {\n return t.jsxAttribute(attrName, null);\n }\n\n return t.jsxAttribute(attrName, attrValue(attr));\n });\n\n const elementName = parseJSXName(node.tagName);\n\n const openingElement = t.jsxOpeningElement(elementName, attributes);\n\n const closingElement = t.jsxClosingElement(elementName);\n const children = buildChildElements(node);\n\n return t.jsxElement(openingElement, closingElement, children, false);\n } catch (error) {\n console.error('❌ DataAttrNode to JSX conversion error:', error);\n return null;\n }\n};\n\nconst createWrapperNode = (\n textContent: string,\n children: DataAttrNode[],\n): DataAttrNode => ({\n tagName: 'div',\n id: nanoid(6),\n attributes: [{ name: DATA_ATTR.ITEM, value: 'true' }],\n dataAttributes: [{ name: DATA_ATTR.ITEM, value: 'true' }],\n textContent,\n children,\n});\n\nconst createFragmentNode = (\n textContent: string,\n children: DataAttrNode[],\n): DataAttrNode => ({\n tagName: '',\n id: nanoid(6),\n attributes: [],\n dataAttributes: [],\n textContent,\n children,\n isFragment: true,\n});\n\nconst processChildrenBinding = (\n jsxElement: t.JSXElement,\n processedNodes?: WeakSet<t.JSXElement | t.JSXFragment>,\n shouldWrap: boolean = true,\n): DataAttrNode[] | undefined => {\n const jsxChildren = jsxElement.children.filter(\n child => t.isJSXElement(child) || t.isJSXFragment(child),\n );\n\n if (!jsxChildren.length) {\n return undefined;\n }\n\n const childrenNodes: DataAttrNode[] = [];\n\n jsxChildren.forEach(child => {\n if (t.isJSXElement(child)) {\n const childResults = extractFromNode(child, processedNodes);\n\n if (shouldWrap) {\n const wrapperNode = createWrapperNode(\n collectText(child.children),\n childResults,\n );\n childrenNodes.push(wrapperNode);\n } else {\n childrenNodes.push(...childResults);\n }\n } else if (t.isJSXFragment(child)) {\n processedNodes?.add(child);\n\n const fragmentChildren: DataAttrNode[] = [];\n\n child.children.forEach(fragmentChild => {\n if (t.isJSXElement(fragmentChild)) {\n const childResults = extractFromNode(fragmentChild, processedNodes);\n fragmentChildren.push(...childResults);\n }\n });\n\n if (fragmentChildren.length) {\n const fragmentNode = createFragmentNode(\n collectText(child.children),\n fragmentChildren,\n );\n childrenNodes.push(fragmentNode);\n }\n }\n });\n\n return childrenNodes.length ? childrenNodes : undefined;\n};\n\nconst skipItemsChildren = (\n jsxElement: t.JSXElement,\n processedNodes: WeakSet<t.JSXElement | t.JSXFragment>,\n propertyName: string = 'items',\n): void => {\n const opening = jsxElement.openingElement;\n\n const itemsAttr = opening.attributes.find(\n attr =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === propertyName,\n );\n\n if (!itemsAttr || !t.isJSXAttribute(itemsAttr)) {\n return;\n }\n\n if (\n itemsAttr.value &&\n t.isJSXExpressionContainer(itemsAttr.value) &&\n t.isArrayExpression(itemsAttr.value.expression)\n ) {\n const arrayExpr = itemsAttr.value.expression;\n\n arrayExpr.elements.forEach(element => {\n if (t.isObjectExpression(element)) {\n element.properties.forEach(prop => {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key) &&\n t.isJSXElement(prop.value)\n ) {\n markProcessedJSX(prop.value, processedNodes);\n }\n });\n }\n });\n }\n};\n\nconst markProcessedJSX = (\n node: t.Node,\n processedNodes: WeakSet<t.JSXElement | t.JSXFragment>,\n): void => {\n if (t.isJSXElement(node) || t.isJSXFragment(node)) {\n processedNodes.add(node as t.JSXElement | t.JSXFragment);\n node.children.forEach(child => markProcessedJSX(child, processedNodes));\n return;\n }\n\n const expression =\n t.isJSXExpressionContainer(node) || t.isParenthesizedExpression(node);\n\n if (expression) {\n markProcessedJSX(node.expression, processedNodes);\n }\n};\n\ninterface NodeBindingInfo {\n tagName: string;\n allAttrs: Attribute[];\n dataAttrs: Attribute[];\n bindings: BindingItem[];\n childrenBinding: BindingItem | undefined;\n arrayBindings: BindingItem[];\n rawChildren: string | undefined;\n}\n\n// Shared prefix for the top-level traverse() visitor below and the manual\n// recursive descent in extractFromNode: read the tag name, attributes, and\n// parsed bindings off one JSXElement. What differs between the two callers\n// is how childrenNodes gets computed and whether the result is pushed at\n// all — traverse() only records elements with data-* attributes, while\n// extractFromNode always records the children it's asked to (see each call\n// site for details).\n// `data-binding` is authored as a JSX object-array expression, so the\n// original `ArrayExpression` node is still on hand here. Return it so\n// `readNodeBindingInfo` can evaluate bindings straight off the AST instead\n// of re-parsing the stringified form. Null when the attribute is absent or\n// written as a plain string literal (bench/tests) — those still go through\n// `parseBinding(string)`.\nconst getBindingExpression = (\n opening: t.JSXOpeningElement,\n): t.ArrayExpression | null => {\n for (const attr of opening.attributes) {\n if (\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === DATA_ATTR.BINDING &&\n attr.value &&\n t.isJSXExpressionContainer(attr.value)\n ) {\n // Unwrap `satisfies BindingItem[]`/`as const`/parentheses so the array\n // is still recognized when authored with an editor type annotation.\n const expression = unwrapExpression(attr.value.expression);\n\n if (t.isArrayExpression(expression)) {\n return expression;\n }\n }\n }\n\n return null;\n};\n\nconst readNodeBindingInfo = (node: t.JSXElement): NodeBindingInfo => {\n const opening = node.openingElement;\n const tagName = getTagName(opening);\n const { allAttrs, dataAttrs } = extractAttributes(opening.attributes);\n\n const bindingAttr = dataAttrs.find(attr => attr.name === DATA_ATTR.BINDING);\n const bindingExpr = getBindingExpression(opening);\n const bindings = bindingExpr\n ? parseBindingExpression(bindingExpr)\n : bindingAttr?.value\n ? parseBinding(bindingAttr.value)\n : [];\n\n const childrenBinding = bindings.find(\n b => b.property === BINDING_PROP.CHILDREN,\n );\n const arrayBindings = bindings.filter(\n b => b.property === BINDING_PROP.ITEMS || b.type === 'array',\n );\n\n const innerHtmlBinding = bindings.find(\n b => b.property === BINDING_PROP.INNER_HTML,\n );\n\n let rawChildren: string | undefined;\n if (innerHtmlBinding && node.children.length > 0) {\n rawChildren = node.children\n .map(child => generateCode(child))\n .join('')\n .trim();\n }\n\n return {\n tagName,\n allAttrs,\n dataAttrs,\n bindings,\n childrenBinding,\n arrayBindings,\n rawChildren,\n };\n};\n\nconst parseToNodes = (raw: string): DataAttrNode[] => {\n const wrapped = wrap(raw);\n const ast = parse(wrapped, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n errorRecovery: true,\n });\n\n const results: DataAttrNode[] = [];\n\n // babel's traverse() below visits every JSXElement in the tree, top to\n // bottom, regardless of structure. But some elements are meant to be\n // recorded as *structural* children of another result — e.g. a node\n // wrapped by processChildrenBinding()/extractFromNode() into a parent's\n // `children` array, or an element sitting inside an `items` binding's\n // array literal (skipped via skipItemsChildren()/markProcessedJSX()) —\n // not as their own top-level entry in `results`. Without this WeakSet,\n // traverse() would independently re-visit those same elements once it\n // reaches them in the tree and add a second, duplicate entry for them.\n // Each helper below adds a node here the moment it pulls that node out\n // of the normal top-level flow, and the JSXElement() visitor skips\n // anything already marked.\n const processedNodes = new WeakSet<t.JSXElement | t.JSXFragment>();\n\n traverse(ast, {\n JSXElement(path) {\n if (processedNodes.has(path.node)) {\n return;\n }\n\n const {\n tagName,\n allAttrs,\n dataAttrs,\n bindings,\n childrenBinding,\n arrayBindings,\n rawChildren,\n } = readNodeBindingInfo(path.node);\n\n if (!tagName || !dataAttrs.length) {\n return;\n }\n\n let childrenNodes: DataAttrNode[] | undefined;\n\n if (childrenBinding) {\n childrenNodes = processChildrenBinding(path.node, processedNodes);\n }\n\n for (const arrayBinding of arrayBindings) {\n skipItemsChildren(path.node, processedNodes, arrayBinding.property);\n }\n\n results.push({\n tagName,\n attributes: allAttrs,\n dataAttributes: dataAttrs,\n textContent: collectText(path.node.children),\n rawChildren,\n children: childrenNodes,\n bindings,\n loc: path.node.loc\n ? {\n start: {\n line: path.node.loc.start.line,\n column: path.node.loc.start.column,\n },\n end: {\n line: path.node.loc.end.line,\n column: path.node.loc.end.column,\n },\n }\n : undefined,\n });\n },\n });\n\n return results;\n};\n\nexport function extract(raw: string): DataAttrNode[] {\n if (extractCache.has(raw)) {\n return extractCache.get(raw)!;\n }\n\n const results = parseToNodes(raw);\n\n extractCache.set(raw, results);\n\n return results;\n}\n\nfunction extractFromNode(\n node: t.JSXElement,\n processedNodes?: WeakSet<t.JSXElement | t.JSXFragment>,\n): DataAttrNode[] {\n processedNodes?.add(node);\n\n const {\n tagName,\n allAttrs,\n dataAttrs,\n bindings,\n childrenBinding,\n rawChildren,\n } = readNodeBindingInfo(node);\n\n let childrenNodes: DataAttrNode[] | undefined;\n\n if (childrenBinding) {\n childrenNodes = processChildrenBinding(node, processedNodes);\n }\n\n if (!childrenNodes) {\n childrenNodes = processChildrenBinding(node, processedNodes, false);\n }\n\n return [\n {\n tagName,\n attributes: allAttrs,\n dataAttributes: dataAttrs,\n textContent: collectText(node.children),\n rawChildren,\n children: childrenNodes,\n bindings,\n },\n ];\n}\n\nexport function clearExtractCache() {\n extractCache.clear();\n}\n","// Positional source patching: the write-side counterpart to `extract`'s\n// read-side `loc`. `update` records the exact byte spans it wants to change\n// and everything else is copied through verbatim, so an edit can no longer\n// reformat code it didn't touch. See #239.\n//\n// Deliberately not `magic-string`: it is the usual tool for this, but it is\n// only available here transitively (via Vite) and would have to become a\n// real runtime dependency shipped to consumers' browsers. Its value is\n// source maps and interleaved insert/move semantics — neither of which this\n// needs. Edits here are non-overlapping span replacements applied in one\n// forward pass, which is the whole implementation below.\nexport interface SourceEdit {\n start: number;\n end: number;\n content: string;\n // Re-indent `content`'s continuation lines to the indentation of the line\n // it lands on. Opt-in because it must apply to *generated* fragments only:\n // a generated fragment is printed from column zero and would otherwise\n // land ragged inside indented markup, whereas a raw user-authored value\n // (an innerHTML string, a hand-written JSX attribute) has to go in byte\n // for byte — re-indenting it would silently rewrite the value itself.\n //\n // Even within a generated fragment this is applied only when every\n // newline is provably layout; see `hasOnlyLayoutNewlines`.\n indent?: boolean;\n}\n\n// Whether every newline in generated code is layout rather than part of a\n// value. Babel escapes newlines inside ordinary string literals, so the only\n// newlines that carry meaning come from a template literal or from JSX text\n// — and both announce themselves with a backtick or a `<`.\n//\n// This matters because indenting a value-newline silently rewrites the\n// value, and the damage compounds: the built-in array editor re-serializes\n// its own output and feeds it back through `update`, so an `innerHTML` leaf\n// stored as a template literal would gain a level of indentation on every\n// single edit.\n//\n// The scan is deliberately conservative. Quotes, comments and regex\n// literals can all hide a backtick, and telling a regex from a division\n// needs real parsing — so anything ambiguous returns false. A false\n// \"unsafe\" only costs a fragment that isn't re-indented; a false \"safe\"\n// corrupts the value.\nconst hasOnlyLayoutNewlines = (content: string): boolean => {\n let index = 0;\n\n while (index < content.length) {\n const char = content[index];\n\n // `<` also matches comparison operators and TS generics. Refusing those\n // is harmless.\n if (char === '`' || char === '<') {\n return false;\n }\n\n if (char === '\"' || char === \"'\") {\n const next = skipStringLiteral(content, index);\n\n if (next === -1) {\n return false;\n }\n\n index = next;\n continue;\n }\n\n if (char === '/') {\n const following = content[index + 1];\n\n if (following === '/') {\n const lineEnd = content.indexOf('\\n', index + 2);\n index = lineEnd === -1 ? content.length : lineEnd;\n continue;\n }\n\n if (following === '*') {\n const commentEnd = content.indexOf('*/', index + 2);\n\n if (commentEnd === -1) {\n return false;\n }\n\n index = commentEnd + 2;\n continue;\n }\n\n // Division or a regex literal — indistinguishable without parsing.\n return false;\n }\n\n index++;\n }\n\n return true;\n};\n\n// Index just past the closing quote, or -1 if the literal doesn't terminate\n// before the end of its line. Valid generated JS never contains a bare\n// newline inside a string literal, so hitting one means the scan has lost\n// track of where it is and the caller should stop trusting it.\nconst skipStringLiteral = (content: string, start: number): number => {\n const quote = content[start];\n\n for (let index = start + 1; index < content.length; index++) {\n const char = content[index];\n\n if (char === '\\\\') {\n // A backslash immediately before a newline is a line continuation:\n // legal JS, and Babel re-emits it verbatim because it contributes\n // nothing to the value. The newline is then part of the literal's raw\n // text, so indenting it would rewrite the string — bail out instead\n // of treating the continuation as an ordinary escape.\n const escaped = content[index + 1];\n\n if (escaped === '\\n' || escaped === '\\r') {\n return -1;\n }\n\n index++;\n continue;\n }\n\n if (char === quote) {\n return index + 1;\n }\n\n if (char === '\\n') {\n return -1;\n }\n }\n\n return -1;\n};\n\n// Indentation of the line that `offset` falls on.\nconst lineIndentAt = (source: string, offset: number): string => {\n const lineStart = source.lastIndexOf('\\n', offset - 1) + 1;\n const match = /^[ \\t]*/.exec(source.slice(lineStart, offset));\n\n return match?.[0] ?? '';\n};\n\n// Babel always emits LF. Inserting that straight into a CRLF file leaves it\n// with mixed endings, so a generated fragment adopts whichever the file\n// already uses. Only ever applied alongside re-indentation, where the\n// newlines are known to be layout rather than part of a value.\nconst lineTerminatorOf = (source: string): string => {\n return source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n};\n\n// Applies non-overlapping edits to `source` in a single forward pass.\n// An edit with `start === end` is an insertion at that offset.\n//\n// Throws on overlapping or out-of-bounds edits rather than silently\n// producing corrupt output: callers build spans from parsed node offsets,\n// so an overlap means the caller's model of the tree is wrong, and a\n// half-applied patch would be far harder to diagnose than a failure.\nexport const applyEdits = (source: string, edits: SourceEdit[]): string => {\n if (edits.length === 0) {\n return source;\n }\n\n const ordered = [...edits].sort((a, b) => a.start - b.start || a.end - b.end);\n\n for (const edit of ordered) {\n if (\n !Number.isInteger(edit.start) ||\n !Number.isInteger(edit.end) ||\n edit.start < 0 ||\n edit.end > source.length ||\n edit.start > edit.end\n ) {\n throw new Error(\n `Invalid source edit [${edit.start}, ${edit.end}) for a source of length ${source.length}`,\n );\n }\n }\n\n for (let i = 1; i < ordered.length; i++) {\n const previous = ordered[i - 1]!;\n const current = ordered[i]!;\n\n if (current.start < previous.end) {\n throw new Error(\n `Overlapping source edits: [${previous.start}, ${previous.end}) and [${current.start}, ${current.end})`,\n );\n }\n }\n\n let result = '';\n let cursor = 0;\n const terminator = lineTerminatorOf(source);\n\n for (const edit of ordered) {\n const content =\n edit.indent &&\n edit.content.includes('\\n') &&\n hasOnlyLayoutNewlines(edit.content)\n ? edit.content.replace(\n /\\n/g,\n `${terminator}${lineIndentAt(source, edit.start)}`,\n )\n : edit.content;\n\n result += source.slice(cursor, edit.start) + content;\n cursor = edit.end;\n }\n\n return result + source.slice(cursor);\n};\n","import { parse, parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport { BINDING_PROP, DATA_ATTR } from '../../constants';\nimport { parseBinding } from './binding';\nimport { traverse } from './document';\nimport { nodeToJSX } from './extract';\nimport { generateCode, unwrap, wrap } from './helpers';\nimport { type SourceEdit, applyEdits } from './patch';\nimport type { BindingType, DataAttrNode } from './types';\nimport { valueToExpression } from './value';\n\n// Every editor below returns the source spans it wants to change rather\n// than mutating the tree, so `update` can patch the original text and leave\n// untouched bytes byte-identical. An empty array means \"nothing to write,\n// but this counts as handled\"; `null` means the edit failed. See #239.\ntype EditResult = SourceEdit[] | null;\n\n// The span between `>` and `</`, i.e. everything the element encloses.\n// `null` for a self-closing element, which has nowhere to put children.\nconst childrenRange = (\n element: t.JSXElement,\n): { start: number; end: number } | null => {\n const { openingElement, closingElement } = element;\n\n if (\n !closingElement ||\n openingElement.end == null ||\n closingElement.start == null\n ) {\n return null;\n }\n\n return { start: openingElement.end, end: closingElement.start };\n};\n\nconst findAttribute = (\n opening: t.JSXOpeningElement,\n propertyName: string,\n): t.JSXAttribute | undefined => {\n return opening.attributes.find(\n (attr): attr is t.JSXAttribute =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === propertyName,\n );\n};\n\n// Where a brand-new attribute should be inserted: after the last existing\n// attribute, or straight after the element name when there are none.\nconst attributeInsertPoint = (opening: t.JSXOpeningElement): number | null => {\n const last = opening.attributes[opening.attributes.length - 1];\n\n return last?.end ?? opening.name.end ?? null;\n};\n\n// Drops the element's JSXText children and writes `value` just before the\n// closing tag — the positional equivalent of the previous \"splice out every\n// JSXText, then push a new one\" mutation, including its handling of mixed\n// children (a nested element stays, the text around it doesn't).\n//\n// The common case — a single text child — is narrowed further: only the\n// text's *trimmed* span is replaced, so the author's line breaks and\n// indentation around it survive. Rewriting the whole children region would\n// collapse\n//\n// >\n// Old Title\n// </h1>\n//\n// down to `>New Title</h1>`, which is exactly the formatting loss #239 is\n// about, just at a smaller scale.\n//\n// A self-closing element yields no edits: there is no children region to\n// write into. That matches the old behaviour, which pushed onto a `children`\n// array the generator then ignored — a silent no-op still reported as\n// success. Left as-is here deliberately; it is a reporting bug, tracked\n// with the rest of that class in #270.\nconst editInnerText = (\n source: string,\n element: t.JSXElement,\n value: string,\n): EditResult => {\n const range = childrenRange(element);\n\n if (!range) {\n return [];\n }\n\n const [only] = element.children;\n\n if (\n element.children.length === 1 &&\n t.isJSXText(only) &&\n only.start != null &&\n only.end != null\n ) {\n // Measured on the raw source slice, never on `only.value`: the latter is\n // Babel's *cooked* text, with HTML entities decoded and CRLF collapsed\n // to LF, so its character counts don't line up with the raw offsets the\n // span is built from. `&nbsp;Old&nbsp;` would put the span six bytes\n // inside the entity (yielding `&New;`), and a CRLF file would lose a\n // byte off each end of every innerText edit.\n const raw = source.slice(only.start, only.end);\n\n if (raw.trim() !== '') {\n const leading = raw.length - raw.trimStart().length;\n const trailing = raw.length - raw.trimEnd().length;\n\n return [\n {\n start: only.start + leading,\n end: only.end - trailing,\n content: value,\n },\n ];\n }\n }\n\n const edits: SourceEdit[] = [];\n\n for (const child of element.children) {\n if (t.isJSXText(child) && child.start != null && child.end != null) {\n edits.push({ start: child.start, end: child.end, content: '' });\n }\n }\n\n edits.push({ start: range.end, end: range.end, content: value });\n\n return edits;\n};\n\n// Raw HTML replaces the children region verbatim. This is what the old\n// `__HTML_<id>__` placeholder existed to achieve: the value can't be\n// represented as an AST literal, so it had to be smuggled past the\n// generator and string-substituted back in afterwards. Writing directly\n// into the source removes that round-trip — and with it the `$&`/`$$`\n// substitution hazard that the replacement step had to guard against.\nconst editInnerHTML = (element: t.JSXElement, value: string): EditResult => {\n const range = childrenRange(element);\n\n if (!range) {\n return [];\n }\n\n return [{ start: range.start, end: range.end, content: value }];\n};\n\nconst editChildren = (element: t.JSXElement, value: unknown): EditResult => {\n try {\n const childrenData = (\n typeof value === 'string' ? JSON.parse(value) : value\n ) as DataAttrNode[];\n\n const range = childrenRange(element);\n\n if (!range) {\n return [];\n }\n\n // These children are new, so there is no source text to preserve —\n // generating the fragment is correct here. The point of #239 is to\n // generate *only* the fragment, never the enclosing tree.\n const content = childrenData\n .map(childData => nodeToJSX(childData))\n .filter((node): node is t.JSXElement | t.JSXFragment => node !== null)\n .map(node => generateCode(node))\n .join('');\n\n return [{ start: range.start, end: range.end, content, indent: true }];\n } catch (error) {\n console.error('❌ Children update error:', error);\n return null;\n }\n};\n\nconst editRichtext = (element: t.JSXElement, value: string): EditResult => {\n const edits: SourceEdit[] = [];\n const range = childrenRange(element);\n\n // richtext owns the element's content, so any prior markup goes.\n if (range && range.start !== range.end) {\n edits.push({ start: range.start, end: range.end, content: '' });\n }\n\n const opening = element.openingElement;\n const attribute = t.jsxAttribute(\n t.jsxIdentifier('dangerouslySetInnerHTML'),\n t.jsxExpressionContainer(\n t.objectExpression([\n t.objectProperty(t.identifier('__html'), t.stringLiteral(value)),\n ]),\n ),\n );\n const content = generateCode(attribute);\n const existing = findAttribute(opening, 'dangerouslySetInnerHTML');\n\n if (existing && existing.start != null && existing.end != null) {\n edits.push({\n start: existing.start,\n end: existing.end,\n content,\n indent: true,\n });\n\n return edits;\n }\n\n const insertAt = attributeInsertPoint(opening);\n\n if (insertAt == null) {\n return null;\n }\n\n edits.push({\n start: insertAt,\n end: insertAt,\n content: ` ${content}`,\n indent: true,\n });\n\n return edits;\n};\n\n// A `type: 'jsx'` value is arbitrary user-authored JSX, so it goes in as\n// written rather than being parsed into nodes and printed back out.\nconst editJsxAttribute = (\n opening: t.JSXOpeningElement,\n propertyName: string,\n value: unknown,\n): EditResult => {\n const attribute = findAttribute(opening, propertyName);\n\n if (!attribute) {\n return null;\n }\n\n const content = `{${String(value).trim()}}`;\n\n if (attribute.value?.start != null && attribute.value.end != null) {\n return [\n {\n start: attribute.value.start,\n end: attribute.value.end,\n content,\n },\n ];\n }\n\n // Valueless shorthand (`<Icon icon />`): there is no value span to\n // overwrite, so append one after the attribute name.\n const insertAt = attribute.name.end;\n\n if (insertAt == null) {\n return null;\n }\n\n return [{ start: insertAt, end: insertAt, content: `=${content}` }];\n};\n\n// Serialize a structured value into a JSX attribute value, once, at the AST\n// boundary — the single point where the declared `type` is known. Replaces\n// the old first-character heuristic (`startsWith('{')` ...) that guessed\n// string-vs-expression and then let `attrValue` guess again. See #238.\nconst buildAttributeValue = (\n value: unknown,\n type?: BindingType,\n): t.JSXAttribute['value'] => {\n // Declared object/array bindings: an expression container. A string here\n // is already-serialized source text (from the built-in Items/flatten\n // editor, which re-emits the whole array/object as code) — parse it back\n // to an expression rather than quoting it as a literal.\n if (type === 'array' || type === 'object') {\n if (typeof value === 'string') {\n try {\n return t.jsxExpressionContainer(\n parseExpression(value.trim(), { plugins: ['jsx', 'typescript'] }),\n );\n } catch {\n return t.stringLiteral(value);\n }\n }\n\n const expr = valueToExpression(value);\n return expr ? t.jsxExpressionContainer(expr) : t.stringLiteral('');\n }\n\n // Everything else maps one JS type to one literal kind — no guessing. A\n // string stays a string literal whatever it contains, so a genuine\n // `\"{not an expression}\"` no longer becomes a JSX expression container.\n if (typeof value === 'string') {\n return t.stringLiteral(value);\n }\n\n const expr = valueToExpression(value);\n return expr ? t.jsxExpressionContainer(expr) : t.stringLiteral(String(value));\n};\n\nconst editAttribute = (\n opening: t.JSXOpeningElement,\n propertyName: string,\n value: unknown,\n type?: BindingType,\n): EditResult => {\n const attribute = findAttribute(opening, propertyName);\n\n if (!attribute || attribute.start == null || attribute.end == null) {\n return null;\n }\n\n // Generate the whole attribute rather than just its value, so Babel's\n // JSX-attribute printing path decides the quoting and escaping — the same\n // path that produced this text before, when the enclosing tree was\n // regenerated. Reuses the parsed name node instead of building a fresh\n // identifier so namespaced/dashed names survive untouched.\n const content = generateCode(\n t.jsxAttribute(attribute.name, buildAttributeValue(value, type)),\n );\n\n return [\n { start: attribute.start, end: attribute.end, content, indent: true },\n ];\n};\n\nexport interface UpdateResult {\n code: string;\n success: boolean;\n}\n\n// `label` is a display string — reworded, duplicated, or translated at\n// authors' whim — so it identifies a binding only as a fallback. `property`\n// (an actual key, unique per element) is the real identity; pass it\n// whenever the caller has it (every internal caller does, via\n// PanelBinding.property). See #240: two bindings sharing a label used to\n// resolve to whichever `.find()` hit first, silently dropping the other's\n// edit while still reporting success.\nexport const update = (\n code: string,\n dataId: string,\n label: string,\n value: unknown,\n property?: string,\n): UpdateResult => {\n try {\n const wrapped = wrap(code);\n const ast = parse(wrapped, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n });\n\n let changed = false;\n const edits: SourceEdit[] = [];\n\n // Records an editor's outcome. `null` is a failure (leave `changed`\n // alone so the caller sees success: false); anything else counts as\n // handled, even when it produces no edits.\n const collect = (result: EditResult) => {\n if (!result) {\n return;\n }\n\n edits.push(...result);\n changed = true;\n };\n\n traverse(ast, {\n JSXElement(path) {\n const opening = path.node.openingElement;\n\n const idAttr = opening.attributes.find(attr => {\n return (\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === DATA_ATTR.ID &&\n attr.value &&\n t.isStringLiteral(attr.value) &&\n attr.value.value === dataId\n );\n });\n\n if (!idAttr) {\n return;\n }\n\n const bindingAttr = opening.attributes.find(\n (attr): attr is t.JSXAttribute =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === DATA_ATTR.BINDING,\n );\n\n if (!bindingAttr?.value) {\n return;\n }\n\n let bindingValue = '';\n\n if (t.isStringLiteral(bindingAttr.value)) {\n bindingValue = bindingAttr.value.value;\n } else if (t.isJSXExpressionContainer(bindingAttr.value)) {\n try {\n bindingValue = generateCode(bindingAttr.value.expression);\n } catch {\n return;\n }\n }\n\n const bindings = parseBinding(bindingValue);\n\n // Prefer `property` (an actual key) over `label` (a display\n // string) — see the module-level comment on `update`. Either way,\n // more than one match on this element is an authoring ambiguity\n // (duplicate labels, or a genuine property collision), not a case\n // to silently resolve by picking the first — see #240.\n const matches = bindings.filter(binding =>\n property !== undefined\n ? binding.property === property\n : binding.label === label,\n );\n\n if (matches.length !== 1) {\n return;\n }\n\n const propertyBinding = matches[0]!;\n\n switch (propertyBinding.property) {\n case BINDING_PROP.INNER_TEXT: {\n collect(editInnerText(wrapped, path.node, String(value)));\n break;\n }\n\n case BINDING_PROP.INNER_HTML: {\n collect(\n propertyBinding.type === 'richtext'\n ? editRichtext(path.node, String(value))\n : editInnerHTML(path.node, String(value)),\n );\n break;\n }\n\n case BINDING_PROP.CHILDREN: {\n collect(editChildren(path.node, value));\n break;\n }\n\n default: {\n collect(\n propertyBinding.type === 'jsx'\n ? editJsxAttribute(opening, propertyBinding.property, value)\n : editAttribute(\n opening,\n propertyBinding.property,\n value,\n propertyBinding.type,\n ),\n );\n break;\n }\n }\n },\n });\n\n if (!changed) {\n return { code, success: false };\n }\n\n // Patch the original source instead of re-emitting the tree: every byte\n // outside a recorded span is copied through unchanged, so an edit to\n // one field can no longer reflow the author's formatting elsewhere in\n // the section — including the `data-binding` array itself, which is now\n // authored as a JSX expression. See #239.\n return { code: unwrap(applyEdits(wrapped, edits)), success: true };\n } catch (error) {\n console.error('❌ Code update error:', error);\n return { code, success: false };\n }\n};\n\nexport const bulkUpdate = (\n raw: string,\n entries: {\n dataId: string;\n label: string;\n value: unknown;\n property?: string;\n }[],\n): UpdateResult => {\n let current = raw;\n let allSucceeded = true;\n\n for (const entry of entries) {\n const result = update(\n current,\n entry.dataId,\n entry.label,\n entry.value,\n entry.property,\n );\n current = result.code;\n allSucceeded = allSucceeded && result.success;\n }\n\n return { code: current, success: allSucceeded };\n};\n","import type { BindingItem } from './types';\n\nexport interface ValidationResult {\n valid: boolean;\n message?: string;\n}\n\nconst VALID: ValidationResult = { valid: true };\n\nexport const validateBindingValue = (\n binding: BindingItem,\n value: unknown,\n): ValidationResult => {\n const isEmpty = value === '' || value === null || value === undefined;\n\n if (isEmpty) {\n if (binding.required) {\n return { valid: false, message: 'This field is required.' };\n }\n return VALID;\n }\n\n // `min`/`max` compare against a real number. Since #238, a `type:\n // 'number'` binding delivers an actual number across the panel boundary,\n // so callers pass one here directly — no string coercion to re-derive the\n // type. A non-number value simply isn't range-checked.\n if (typeof value === 'number') {\n if (binding.min !== undefined && value < binding.min) {\n return { valid: false, message: `Must be at least ${binding.min}.` };\n }\n if (binding.max !== undefined && value > binding.max) {\n return { valid: false, message: `Must be at most ${binding.max}.` };\n }\n }\n\n if (typeof value === 'string' && binding.pattern) {\n let regex: RegExp;\n\n try {\n regex = new RegExp(binding.pattern);\n } catch {\n // Malformed pattern authored on the binding itself — don't block the\n // user's input for an authoring mistake that isn't theirs to fix.\n return VALID;\n }\n\n if (!regex.test(value)) {\n return {\n valid: false,\n message: 'Value does not match the required format.',\n };\n }\n }\n\n if (typeof value === 'string' && binding.type === 'url') {\n try {\n new URL(value);\n } catch {\n return { valid: false, message: 'Must be a valid URL.' };\n }\n }\n\n if (typeof value === 'string' && binding.type === 'date') {\n if (Number.isNaN(Date.parse(value))) {\n return { valid: false, message: 'Must be a valid date.' };\n }\n }\n\n return VALID;\n};\n"],"mappings":";;;;;AAmCA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;ACjCA,MAAM,WACJ,OAAOA,WAAAA,YAAc,aACjBA,WAAAA,UACCA,WAAAA,QAAuD;AAE9D,MAAa,QAAQ,SAAiB;CACpC,OAAO,KAAK,KAAK;AACnB;AAEA,MAAa,UAAU,cAAsB;CAC3C,OAAO,UACJ,QAAQ,WAAW,EAAE,CAAC,CACtB,QAAQ,qBAAqB,EAAE,CAAC,CAChC,KAAK;AACV;AAEA,MAAa,aAAa,EACxB,OACA,sBACwC;CACxC,IAAI,UAAU,MACZ,OAAO;CAGT,IAAI,iBACF,OAAOC,aAAE,cAAc,KAAK;CAG9B,MAAM,UAAU,MAAM,KAAK;CAE3B,IAAI,MAAM,OAAO,KAAK,OAAO,GAC3B,OAAOA,aAAE,uBAA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I;EAAG;EAErE,IAAI,QAAQ,QAAQ,KAAA,KAAa,QAAQ,QAAQ,KAC/C,OAAO;GAAE,OAAO;GAAO,SAAS,mBAAmB,QAAQ,IAAI;EAAG;CAEtE;CAEA,IAAI,OAAO,UAAU,YAAY,QAAQ,SAAS;EAChD,IAAI;EAEJ,IAAI;GACF,QAAQ,IAAI,OAAO,QAAQ,OAAO;EACpC,QAAQ;GAGN,OAAO;EACT;EAEA,IAAI,CAAC,MAAM,KAAK,KAAK,GACnB,OAAO;GACL,OAAO;GACP,SAAS;EACX;CAEJ;CAEA,IAAI,OAAO,UAAU,YAAY,QAAQ,SAAS,OAChD,IAAI;EACF,IAAI,IAAI,KAAK;CACf,QAAQ;EACN,OAAO;GAAE,OAAO;GAAO,SAAS;EAAuB;CACzD;CAGF,IAAI,OAAO,UAAU,YAAY,QAAQ,SAAS,QAC5C;MAAA,OAAO,MAAM,KAAK,MAAM,KAAK,CAAC,GAChC,OAAO;GAAE,OAAO;GAAO,SAAS;EAAwB;CAAA;CAI5D,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { a as ICON_OPTIONS, c as PanelRenderData, d as DraggableItemDragState, f as DraggableItemProps, i as ICON_MAP, l as Props, n as Panel, o as PaletteRenderData, r as PanelProps, s as PanelBinding, t as Dnd, u as DraggableItem } from "../index-7J3AYBNK.js";
1
+ import { a as ICON_OPTIONS, c as PanelRenderData, d as DraggableItemDragState, f as DraggableItemProps, i as ICON_MAP, l as Props, n as Panel, o as PaletteRenderData, r as PanelProps, s as PanelBinding, t as Dnd, u as DraggableItem } from "../index-2CUWhF-T.js";
2
2
  export { Panel as DefaultPanel, DraggableItem, type DraggableItemDragState, type DraggableItemProps, ICON_MAP, ICON_OPTIONS, type PaletteRenderData, type PanelBinding, type PanelProps, type PanelRenderData, type Props, Dnd as default };
package/dist/dnd/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as DraggableItem, i as ICON_OPTIONS, n as Panel, r as ICON_MAP, t as Dnd } from "../dnd-DMh9mSaU.js";
1
+ import { a as DraggableItem, i as ICON_OPTIONS, n as Panel, r as ICON_MAP, t as Dnd } from "../dnd-Cyuif73L.js";
2
2
  export { Panel as DefaultPanel, DraggableItem, ICON_MAP, ICON_OPTIONS, Dnd as default };