@jbpark/live-editor 4.5.0 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +4 -1
- package/README.md +5 -1
- package/dist/{boundary-DnjGgsK6.js → boundary-BLB80tyw.js} +2 -2
- package/dist/boundary-BLB80tyw.js.map +1 -0
- package/dist/cache-B0-XcIxJ.js.map +1 -1
- package/dist/{compile-DDfk5P25.js → compile-Dxas-D05.js} +3 -3
- package/dist/compile-Dxas-D05.js.map +1 -0
- package/dist/{constants-h1JAgOeW.js → constants-DU17Tdwo.js} +3 -3
- package/dist/constants-DU17Tdwo.js.map +1 -0
- package/dist/{context-DsEXJl4h.js → context-B8MzP7_p.js} +3 -3
- package/dist/context-B8MzP7_p.js.map +1 -0
- package/dist/{core-CRsAGpei.js → core-Bgfek364.js} +2 -2
- package/dist/core-Bgfek364.js.map +1 -0
- package/dist/{detect-typescript-CCj9ALXc.js → detect-typescript-Dr_oLniM.js} +2 -2
- package/dist/detect-typescript-Dr_oLniM.js.map +1 -0
- package/dist/dnd/index.d.ts +1 -1
- package/dist/dnd/index.js +1 -1
- package/dist/{dnd-DGNp20Nk.js → dnd-V8NAxd_R.js} +435 -413
- package/dist/dnd-V8NAxd_R.js.map +1 -0
- package/dist/document-CHO215iP.js +33992 -0
- package/dist/document-CHO215iP.js.map +1 -0
- package/dist/{document-Ct4jW78J.d.ts → document-DqRSCtsx.d.ts} +496 -435
- package/dist/editor/index.js +2 -2
- package/dist/{editor-DQ8Q--qR.js → editor-CMElfHer.js} +2 -2
- package/dist/editor-CMElfHer.js.map +1 -0
- package/dist/editor-caches-ClMvdcQF.js.map +1 -1
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +2 -2
- package/dist/{error-DwqwjJ2C.js → error-CN_GCnXB.js} +3 -3
- package/dist/{error-DwqwjJ2C.js.map → error-CN_GCnXB.js.map} +1 -1
- package/dist/{index-vtyggWy0.d.ts → index-CRwEhJ7w.d.ts} +2 -2
- package/dist/index-C_PfR4X9.d.ts +734 -0
- package/dist/{index-P9Aifaui.d.ts → index-CiWB0zFb.d.ts} +72 -70
- package/dist/{index-WQgFy510.d.ts → index-DrWtSKXu.d.ts} +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -6
- package/dist/{items-DdrwGxJw.js → items-BXXtMUNI.js} +307 -390
- package/dist/items-BXXtMUNI.js.map +1 -0
- package/dist/{messages-CzUPVnzH.js → messages-CSrMI4Rm.js} +2 -1
- package/dist/messages-CSrMI4Rm.js.map +1 -0
- package/dist/{messages-Cp3g1mn1.d.ts → messages-IBPs4TkZ.d.ts} +2 -1
- package/dist/preview/index.js +2 -2
- package/dist/{preview-BKFgq_5u.js → preview-CtyG5UbH.js} +4 -4
- package/dist/{preview-BKFgq_5u.js.map → preview-CtyG5UbH.js.map} +1 -1
- package/dist/provider/index.d.ts +2 -2
- package/dist/provider/index.js +2 -2
- package/dist/{sections-BRH3KHYc.js → sections-jYuqS4KB.js} +3 -3
- package/dist/sections-jYuqS4KB.js.map +1 -0
- package/dist/states-Ci1AvoQ9.js.map +1 -1
- package/dist/{use-dynamic-tailwind-T9r9ExbR.js → use-dynamic-tailwind-BP1toJkW.js} +59 -39
- package/dist/use-dynamic-tailwind-BP1toJkW.js.map +1 -0
- package/dist/utils/ast/index.d.ts +2 -2
- package/dist/utils/ast/index.js +84 -2
- package/dist/utils/ast/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/tailwind/index.js.map +1 -1
- package/dist/validate-iLo8IONY.js.map +1 -1
- package/package.json +5 -7
- package/dist/boundary-DnjGgsK6.js.map +0 -1
- package/dist/compile-DDfk5P25.js.map +0 -1
- package/dist/constants-h1JAgOeW.js.map +0 -1
- package/dist/context-DsEXJl4h.js.map +0 -1
- package/dist/core-CRsAGpei.js.map +0 -1
- package/dist/detect-typescript-CCj9ALXc.js.map +0 -1
- package/dist/dnd-DGNp20Nk.js.map +0 -1
- package/dist/document-DGHTfrda.js +0 -38667
- package/dist/document-DGHTfrda.js.map +0 -1
- package/dist/editor-DQ8Q--qR.js.map +0 -1
- package/dist/index-CHknA6k1.d.ts +0 -221
- package/dist/items-DdrwGxJw.js.map +0 -1
- package/dist/messages-CzUPVnzH.js.map +0 -1
- package/dist/sections-BRH3KHYc.js.map +0 -1
- package/dist/use-dynamic-tailwind-T9r9ExbR.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"items-BXXtMUNI.js","names":["t.isTSAsExpression","t.isTSSatisfiesExpression","t.isTSNonNullExpression","t.isTSTypeAssertion","t.isParenthesizedExpression","t.isStringLiteral","t.isNumericLiteral","t.isBooleanLiteral","t.isNullLiteral","t.isUnaryExpression","t.isTemplateLiteral","t.isArrayExpression","t.isObjectExpression","t.isObjectProperty","t.isIdentifier","t.isJSXElement","t.isJSXFragment","t.isObjectExpression","t.isObjectProperty","t.isIdentifier","t.isStringLiteral","t.isTemplateLiteral","t.isJSXText","t.jsxIdentifier","t.jsxMemberExpression","t.isJSXAttribute","t.isJSXIdentifier","isStringLiteral","t.isStringLiteral","t.isJSXExpressionContainer","t.isArrayExpression","t.isObjectExpression","t.jsxText","t.jsxFragment","t.jsxOpeningFragment","t.jsxClosingFragment","t.jsxAttribute","t.jsxOpeningElement","t.jsxClosingElement","t.jsxElement","t.isJSXElement","t.isJSXFragment","t.isObjectProperty","t.isIdentifier","t.isParenthesizedExpression","t.isJSXOpeningElement","t.isJSXAttribute","t.isJSXIdentifier","t.isJSXSpreadAttribute","t.isStringLiteral","t.isJSXElement","t.isJSXFragment","t.booleanLiteral","t.numericLiteral","t.stringLiteral","t.nullLiteral","t.unaryExpression","t.arrayExpression","t.objectProperty","t.objectExpression","t.isJSXAttribute","t.isJSXIdentifier","t.isJSXText","t.jsxAttribute","t.jsxIdentifier","t.jsxExpressionContainer","t.objectExpression","t.objectProperty","t.identifier","t.stringLiteral","t.isJSXExpressionContainer","t.isArrayExpression","t.isObjectExpression","t.isJSXEmptyExpression","t.isJSXAttribute","t.isJSXIdentifier","t.isStringLiteral","t.isJSXExpressionContainer","t.isExpression","t.isObjectExpression","t.isExpression","t.templateLiteral","t.templateElement","t.isJSXElement","t.isJSXFragment","t.stringLiteral","t.isObjectProperty","t.isIdentifier","t.isJSXOpeningElement","t.isJSXAttribute","t.isJSXIdentifier","t.isStringLiteral","t.isJSXSpreadAttribute","t.isSpreadElement"],"sources":["../src/utils/ast/types.ts","../src/utils/ast/value.ts","../src/utils/ast/binding.ts","../src/utils/ast/extract.ts","../src/utils/selection.ts","../src/utils/ast/patch.ts","../src/utils/ast/children.ts","../src/utils/ast/value-expression.ts","../src/utils/ast/edit-source.ts","../src/utils/ast/update.ts","../src/utils/ast/array-source.ts","../src/utils/ast/items.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 // Exact structural child source, used to validate source-preserving edits.\n source?: 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// The kinds of data a binding can hold: what a value is, not how to draw\n// it. How to draw it is `widget`, which the library passes through without\n// reading; the built-in panel renders the default control for each kind.\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] as const;\n\nexport type BindingType = (typeof BINDING_TYPES)[number];\n\n// How to draw one field, as opposed to `type`, which is what its data is.\n// Written as a control name (`widget: 'slider'`) or as this object; parsing\n// turns the string into `{ type }`, so consumers see one shape.\n//\n// Constraints (`min`, `max`, `pattern`, `required`) stay on the binding, not\n// here, so `validateBindingValue` checks them with or without a widget.\nexport interface BindingWidget {\n // The control name, any string (such as `'slider'`). A custom panel\n // switches on it; the built-in panel ignores it.\n type: string;\n // Common presentation hints, typed.\n step?: number;\n unit?: string;\n // Any other config for the control, kept as written (#234).\n [key: string]: unknown;\n}\n\n// The fields a binding declares about itself. Shared by `BindingItem` and\n// render-map leaves, so a nested field can say everything a top-level one\n// can (#383).\nexport interface BindingFieldSpec {\n // What the value is. A closed set, because validation and parsing switch\n // on it.\n type?: BindingType;\n // How to draw it, always in object form. See `BindingWidget`.\n widget?: BindingWidget;\n options?: BindingOption[];\n render?: BindingRenderMap;\n min?: number;\n max?: number;\n pattern?: string;\n required?: boolean;\n // The app's own keys, anything not listed above, such as `group` or `tab`.\n // Kept apart so they can't collide with a field added later. Config for\n // the control goes in `widget` instead. `undefined` when there are none\n // (#234).\n meta?: Record<string, unknown>;\n}\n\n// A render-map entry is a leaf when it declares `type`, even an unknown\n// one, which then shows as an untyped field (#234). `label` and `property`\n// default to the entry's key.\nexport interface BindingRenderLeaf extends BindingFieldSpec {\n label?: string;\n property?: string;\n}\n\nexport interface BindingRenderMap {\n [key: string]: BindingRenderLeaf | BindingRenderMap;\n}\n\nexport interface BindingItem extends BindingFieldSpec {\n label: string;\n property: string;\n}\n\n// A component's tag name as written in the source: a member path\n// (`ui.Button`) or an identifier that doesn't start with a lowercase letter\n// (`Button`). Lowercase names are HTML elements.\nexport type BindingComponentName = `${string}.${string}` | Capitalize<string>;\n\n// One entry of `bindings` or `bindingKeys`, as written: a `BindingItem` plus\n// any key of the app's own (`group`, `tab`, `description`, ...), which\n// arrives in `binding.meta` just as it does from an inline `data-binding`.\n// `meta` itself isn't one of them: it's where those keys end up, so writing\n// it here would nest it under `meta.meta`.\nexport interface BindingSchema extends Omit<BindingItem, 'meta'> {\n [key: string]: unknown;\n}\n\n// Bindings for every element of a component, keyed by its tag name as\n// written, so markup doesn't have to repeat the same `data-binding` on each\n// one (#509). Components only: an entry for an HTML element such as `p` or\n// `h2` would make every one of them in every section editable, so those keys\n// are rejected by the type and ignored at runtime. An element's own\n// `data-binding`, even an empty one, takes precedence over its component's\n// entry. Matched elements still need a `data-id` to be edited.\nexport type BindingRegistry = Partial<\n Record<BindingComponentName, BindingSchema[]>\n>;\n\n// Bindings an element asks for by name, with `data-binding-key=\"hero-title\"`\n// in its markup, on an HTML element or a component alike (#513). Plain data,\n// so a host can load it from JSON or a CMS.\nexport type BindingKeyMap = Record<string, BindingSchema[]>;\n\n// Where bindings come from besides an element's own `data-binding`, in\n// order of precedence: the key its `data-binding-key` names in\n// `bindingKeys`, then its component's entry in `bindings`.\nexport interface BindingOptions {\n bindings?: BindingRegistry;\n bindingKeys?: BindingKeyMap;\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 { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport { REGEX } from '../../constants';\nimport { generateCode } from './helpers';\nimport type { ExtractedNodeValue } from './types';\n\n// Reads values out of the AST without running code: literals, binding values\n// and array or object expressions.\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// Removes type-only wrappers (`satisfies`, `as const`, type assertions) and\n// parentheses, so the literal underneath can be read. Without this, a\n// `data-binding={[...] satisfies BindingItem[]}` would read as no bindings.\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// Whether `evaluateLiteral()` and `valueToExpression()` can round-trip the\n// value without losing calls, references, spreads, holes or computed keys.\n// The panel uses it to disable editors, and edits use it as the last check,\n// so both agree on what is editable.\nexport const isLosslesslyEvaluable = (node: t.Node): boolean => {\n const value = unwrapExpression(node);\n\n if (\n t.isStringLiteral(value) ||\n t.isNumericLiteral(value) ||\n t.isBooleanLiteral(value) ||\n t.isNullLiteral(value)\n ) {\n return true;\n }\n\n if (\n t.isUnaryExpression(value) &&\n value.operator === '-' &&\n t.isNumericLiteral(value.argument)\n ) {\n return true;\n }\n\n if (t.isTemplateLiteral(value)) {\n return value.expressions.length === 0;\n }\n\n if (t.isArrayExpression(value)) {\n return value.elements.every(\n element => element !== null && isLosslesslyEvaluable(element),\n );\n }\n\n if (t.isObjectExpression(value)) {\n return value.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\nexport const canLosslesslyEvaluateSource = (source: string): boolean => {\n try {\n return isLosslesslyEvaluable(\n parseExpression(source, { plugins: ['jsx', 'typescript'] }),\n );\n } catch {\n return false;\n }\n};\n\n// Reads a literal's value from its AST without running any code. Calls,\n// references and other non-literal expressions give `undefined`, so reading\n// a field never executes the document's code.\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 /* Not an object or array literal: keep the string. */\n }\n\n return value;\n }\n\n return value;\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 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 // `children` and other JSX-valued properties (such as `label`) are\n // edited through `useDndItems`'s nested elements instead (#298).\n if (\n key === 'children' ||\n t.isJSXElement(prop.value) ||\n t.isJSXFragment(prop.value)\n ) {\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","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 BindingKeyMap,\n type BindingOption,\n type BindingOptions,\n type BindingRegistry,\n type BindingRenderLeaf,\n type BindingRenderMap,\n type BindingType,\n type BindingWidget,\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// `widget.type` is any string, not an enum: the library implements no\n// widgets, so every value belongs to a custom panel (#236). `.passthrough()`\n// keeps that control's own config, such as `{ type: 'slider', snapTo: [...] }`.\nconst bindingWidgetSchema = z\n .object({\n type: z.string().min(1),\n step: z.number().optional(),\n unit: z.string().optional(),\n })\n .passthrough();\n\n// Parses one key on its own. A malformed value becomes absent instead of\n// failing the whole binding, so a typo in `min` loses only `min` (#234).\nconst pick = <T>(schema: z.ZodType<T>, value: unknown): T | undefined => {\n const parsed = schema.safeParse(value);\n\n return parsed.success ? parsed.data : undefined;\n};\n\n// Turns the string form (`widget: 'slider'`) into `{ type }`, so consumers\n// see one shape.\nconst sanitizeWidget = (value: unknown): BindingWidget | undefined => {\n if (typeof value === 'string') {\n return value ? { type: value } : undefined;\n }\n\n return pick(bindingWidgetSchema, value);\n};\n\n// Drops only the malformed options and keeps the valid ones.\nconst sanitizeOptions = (value: unknown): BindingOption[] | undefined => {\n if (!Array.isArray(value)) {\n return undefined;\n }\n\n const options = value.flatMap(option => {\n const parsed = pick(bindingOptionSchema, option);\n\n return parsed ? [parsed] : [];\n });\n\n return options.length > 0 ? options : undefined;\n};\n\n// Every key the library reads from a binding. Any other key is the app's\n// own and goes into `meta`.\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\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n// Sanitizes the fields a binding declares. Shared by top-level bindings and\n// render-map leaves, so a new field reaches both. Absent fields are left\n// off, not set to `undefined`.\nconst sanitizeField = (raw: Record<string, unknown>): BindingRenderLeaf => {\n const metaEntries = Object.entries(raw).filter(\n ([key]) => !KNOWN_BINDING_KEYS.has(key),\n );\n const field: BindingRenderLeaf = {\n label: pick(z.string(), raw.label),\n property: pick(z.string(), raw.property),\n type: pick(bindingTypeSchema, raw.type),\n widget: sanitizeWidget(raw.widget),\n options: sanitizeOptions(raw.options),\n render: sanitizeRenderMap(raw.render),\n min: pick(z.number(), raw.min),\n max: pick(z.number(), raw.max),\n pattern: pick(z.string(), raw.pattern),\n required: pick(z.boolean(), raw.required),\n meta: metaEntries.length > 0 ? Object.fromEntries(metaEntries) : undefined,\n };\n\n return Object.fromEntries(\n Object.entries(field).filter(([, value]) => value !== undefined),\n );\n};\n\n// A render map entry is a leaf (it has `type`) or a nested map. Anything\n// else is dropped, without failing the whole map.\nfunction 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 // Keep the `type` key even when its value was dropped, so\n // `'type' in leaf` still marks it as a leaf: an unknown type shows as a\n // plain field instead of disappearing (#234).\n map[key] = { type: undefined, ...sanitizeField(raw) };\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// Validates an evaluated `data-binding` array into `BindingItem[]`. Used by\n// `parseBinding` (from a string) and `parseBindingExpression` (from an AST).\nconst buildBindingItems = (raw: unknown): BindingItem[] => {\n if (!Array.isArray(raw)) {\n return [];\n }\n\n return raw.flatMap(rawItem => {\n if (!isPlainObject(rawItem)) {\n return [];\n }\n\n const { label, property, ...field } = sanitizeField(rawItem);\n\n if (label === undefined) {\n return [];\n }\n\n if (property === undefined && field.type !== 'richtext') {\n return [];\n }\n\n return [{ label, property: property ?? BINDING_PROP.INNER_HTML, ...field }];\n });\n};\n\n// Registry entries are validated like an inline `data-binding`. Cached per\n// registry object, which a host defines once rather than every render.\nconst registryEntries = new WeakMap<\n BindingRegistry,\n Map<string, BindingItem[]>\n>();\n\n// Whether a tag name is a component rather than an HTML element, by JSX's\n// own rule: a member path, or an identifier that doesn't start with a\n// lowercase letter. A namespaced name (`svg:rect`) resolves to `''` and is\n// neither.\nexport const isComponentTagName = (tagName: string): boolean =>\n tagName !== '' && (tagName.includes('.') || !/^[a-z]/.test(tagName));\n\n// The bindings `registry` gives an element of `tagName`, or `undefined` when\n// it has no entry for that component. HTML elements never match, even when\n// the registry has a key for them.\nexport const getRegistryBindings = (\n registry: BindingRegistry | undefined,\n tagName: string,\n): BindingItem[] | undefined => {\n if (!registry) {\n return undefined;\n }\n\n let entries = registryEntries.get(registry);\n\n if (!entries) {\n entries = new Map();\n registryEntries.set(registry, entries);\n\n // Once per registry, so a key the type would have rejected doesn't go\n // unnoticed in plain JavaScript or behind a cast.\n const ignored = Object.keys(registry).filter(\n key => !isComponentTagName(key),\n );\n\n if (ignored.length > 0) {\n console.warn(\n `Live.Dnd \\`bindings\\` only applies to components. Ignored: ${ignored.join(', ')}. Bind an HTML element with its own data-binding.`,\n );\n }\n }\n\n if (!isComponentTagName(tagName) || !Object.hasOwn(registry, tagName)) {\n return undefined;\n }\n\n let bindings = entries.get(tagName);\n\n if (!bindings) {\n bindings = buildBindingItems(\n (registry as Record<string, BindingItem[] | undefined>)[tagName],\n );\n entries.set(tagName, bindings);\n }\n\n return bindings;\n};\n\n// Key map entries are validated like inline ones and cached per map, as\n// registry entries are.\nconst keyEntries = new WeakMap<BindingKeyMap, Map<string, BindingItem[]>>();\n\n// Each problem is reported once per key, not on every read of a section.\nconst warnedKeys = new Set<string>();\n\nconst warnOnce = (id: string, message: string) => {\n if (!warnedKeys.has(id)) {\n warnedKeys.add(id);\n console.warn(message);\n }\n};\n\n// The bindings `bindingKeys` has under `key`, or `undefined` when it has no\n// such entry.\nexport const getKeyBindings = (\n bindingKeys: BindingKeyMap | undefined,\n key: string,\n): BindingItem[] | undefined => {\n if (!bindingKeys || !Object.hasOwn(bindingKeys, key)) {\n return undefined;\n }\n\n let entries = keyEntries.get(bindingKeys);\n\n if (!entries) {\n entries = new Map();\n keyEntries.set(bindingKeys, entries);\n }\n\n let bindings = entries.get(key);\n\n if (!bindings) {\n bindings = buildBindingItems(bindingKeys[key]);\n entries.set(key, bindings);\n }\n\n return bindings;\n};\n\n// One element's bindings, from the most specific source it has (#513):\n//\n// 1. `own`, its `data-binding`, parsed. `undefined` when it has none; an\n// empty array is still its own, which is how an element opts out.\n// 2. `key`, the string its `data-binding-key` names in `bindingKeys`.\n// `undefined` without the attribute, `null` when the attribute isn't a\n// plain string. A key with no entry gives no fields rather than falling\n// through to the registry.\n// 3. Its component's entry in `bindings`.\nexport const resolveBindings = (\n own: BindingItem[] | undefined,\n key: string | null | undefined,\n tagName: string,\n options: BindingOptions = {},\n): BindingItem[] => {\n if (own) {\n if (key !== undefined) {\n warnOnce(\n `both:${key}`,\n `Live.Dnd: an element has both data-binding and data-binding-key=\"${key ?? ''}\". Its data-binding is used; remove one of them.`,\n );\n }\n\n return own;\n }\n\n if (key === null) {\n warnOnce(\n 'not-a-string',\n 'Live.Dnd: data-binding-key must be a plain string, such as data-binding-key=\"hero-title\". The element has no fields.',\n );\n\n return [];\n }\n\n if (key !== undefined) {\n const bindings = getKeyBindings(options.bindingKeys, key);\n\n if (!bindings) {\n warnOnce(\n `missing:${key}`,\n `Live.Dnd: data-binding-key=\"${key}\" isn't in bindingKeys. The element has no fields.`,\n );\n }\n\n return bindings ?? [];\n }\n\n return getRegistryBindings(options.bindings, tagName) ?? [];\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// `parseBinding` for an array expression that is already parsed, as\n// `extract` has it. Saves printing it and parsing it again (#241).\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 // A `richtext` value lives in `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 // Not a readable object: fall back to the children below.\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// Types whose value stays a string, even when the text looks like a number\n// or an object. `jsx` and `richtext` hold source code, which `update` writes\n// back as an expression.\nexport const STRING_VALUED_TYPES: ReadonlySet<BindingType> = new Set([\n 'string',\n 'url',\n 'date',\n 'color',\n 'jsx',\n 'richtext',\n]);\n\n// The value as its JS type (number, boolean, object, array or string), for\n// `PanelBinding.value`. `getCurrentValue` gives the source text, for\n// `PanelBinding.rawValue` (#238). A string literal in the source stays a\n// string whatever it contains; only expressions such as `count={3}` or\n// `data={[...]}` are read 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\n// The node's bindings. `extract()` resolves them from all three sources\n// (#509, #513); a node built some other way may only have its\n// `data-binding` attribute, which is parsed here.\nexport const readNodeBindings = (node: DataAttrNode): BindingItem[] => {\n if (node.bindings) {\n return node.bindings;\n }\n\n const bindingAttr = node.dataAttributes.find(\n attr => attr.name === DATA_ATTR.BINDING,\n );\n\n return bindingAttr?.value ? parseBinding(bindingAttr.value) : [];\n};\n\nconst hasEditableBindings = (node: DataAttrNode): boolean =>\n readNodeBindings(node).length > 0;\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","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 { type BoundedCache, createBoundedCache } from '../cache';\nimport { registerEditorCache } from '../editor-caches';\nimport {\n parseBinding,\n parseBindingExpression,\n resolveBindings,\n} from './binding';\nimport { traverse } from './document';\nimport { attrValue, generateCode, wrap } from './helpers';\nimport { getJSXTagName } from './jsx-name';\nimport type {\n Attribute,\n BindingItem,\n BindingOptions,\n DataAttrNode,\n} 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 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\n// One cache per combination of `bindings` and `bindingKeys`, since they\n// change what the same source extracts to (#509, #513). An absent map is\n// keyed by `NO_MAP`.\nconst NO_MAP = {};\nlet optionExtractCaches = new WeakMap<\n object,\n WeakMap<object, BoundedCache<string, DataAttrNode[]>>\n>();\n\nconst cacheFor = ({ bindings, bindingKeys }: BindingOptions) => {\n if (!bindings && !bindingKeys) {\n return extractCache;\n }\n\n let byKeys = optionExtractCaches.get(bindings ?? NO_MAP);\n\n if (!byKeys) {\n byKeys = new WeakMap();\n optionExtractCaches.set(bindings ?? NO_MAP, byKeys);\n }\n\n let cache = byKeys.get(bindingKeys ?? NO_MAP);\n\n if (!cache) {\n cache = createBoundedCache<string, DataAttrNode[]>(CONFIG.CACHE_LIMIT);\n byKeys.set(bindingKeys ?? NO_MAP, cache);\n }\n\n return cache;\n};\n\nconst extractAttributes = (\n attributes: (t.JSXAttribute | t.JSXSpreadAttribute)[],\n source?: string,\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 const expression = attr.value.expression;\n const structural =\n t.isArrayExpression(unwrapExpression(expression)) ||\n t.isObjectExpression(unwrapExpression(expression));\n value =\n source &&\n structural &&\n expression.start != null &&\n expression.end != null\n ? source.slice(expression.start, expression.end)\n : generateCode(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);\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 source?: string,\n options?: BindingOptions,\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(\n child,\n processedNodes,\n source,\n options,\n );\n\n if (shouldWrap) {\n const wrapperNode = createWrapperNode(\n collectText(child.children),\n childResults,\n );\n wrapperNode.source = source?.slice(child.start!, child.end!);\n const dataId = childResults[0]?.dataAttributes.find(\n attr => attr.name === DATA_ATTR.ID,\n )?.value;\n\n if (dataId) {\n wrapperNode.id = `child:${dataId}`;\n }\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(\n fragmentChild,\n processedNodes,\n source,\n options,\n );\n fragmentChildren.push(...childResults);\n }\n });\n\n if (fragmentChildren.length) {\n const fragmentNode = createFragmentNode(\n collectText(child.children),\n fragmentChildren,\n );\n fragmentNode.source = source?.slice(child.start!, child.end!);\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// The `data-binding` array expression, so bindings can be read from the AST\n// without printing and parsing it again. `null` when the attribute is\n// missing or a plain string, which goes through `parseBinding` instead.\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` and parentheses.\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\n// Reads one element's tag name, attributes and bindings. Shared by the\n// top-level visitor in `parseToNodes` and by `extractFromNode`.\nconst readNodeBindingInfo = (\n node: t.JSXElement,\n source?: string,\n options?: BindingOptions,\n): NodeBindingInfo => {\n const opening = node.openingElement;\n const tagName = getJSXTagName(opening);\n const { allAttrs, dataAttrs } = extractAttributes(opening.attributes, source);\n\n const bindingAttr = dataAttrs.find(attr => attr.name === DATA_ATTR.BINDING);\n const bindingExpr = getBindingExpression(opening);\n const keyAttr = dataAttrs.find(attr => attr.name === DATA_ATTR.BINDING_KEY);\n // Its own `data-binding` first, even an empty one (how an element opts\n // out), then its `data-binding-key`, then its component's entry\n // (#509, #513).\n const bindings = resolveBindings(\n bindingExpr\n ? parseBindingExpression(bindingExpr)\n : bindingAttr\n ? parseBinding(bindingAttr.value)\n : undefined,\n keyAttr && (keyAttr.isStringLiteral ? keyAttr.value : null),\n tagName,\n options,\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 = (\n raw: string,\n options?: BindingOptions,\n): 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 // Elements already recorded as another result's children, or skipped\n // inside an `items` array. `traverse()` visits every element, so the\n // visitor skips these to avoid recording them twice.\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, wrapped, options);\n\n if (!tagName || !dataAttrs.length) {\n return;\n }\n\n let childrenNodes: DataAttrNode[] | undefined;\n\n if (childrenBinding) {\n childrenNodes = processChildrenBinding(\n path.node,\n processedNodes,\n true,\n wrapped,\n options,\n );\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\n// The elements of `raw` that carry `data-*` attributes, with their\n// bindings, as `DataAttrNode`s. Cached. `options` supplies bindings for\n// elements without their own `data-binding` (#509, #513).\nexport function extract(\n raw: string,\n options: BindingOptions = {},\n): DataAttrNode[] {\n const cache = cacheFor(options);\n\n if (cache.has(raw)) {\n return cache.get(raw)!;\n }\n\n const results = parseToNodes(raw, options);\n\n cache.set(raw, results);\n\n return results;\n}\n\nfunction extractFromNode(\n node: t.JSXElement,\n processedNodes?: WeakSet<t.JSXElement | t.JSXFragment>,\n source?: string,\n options?: BindingOptions,\n): DataAttrNode[] {\n processedNodes?.add(node);\n\n const {\n tagName,\n allAttrs,\n dataAttrs,\n bindings,\n childrenBinding,\n rawChildren,\n } = readNodeBindingInfo(node, source, options);\n\n let childrenNodes: DataAttrNode[] | undefined;\n\n if (childrenBinding) {\n childrenNodes = processChildrenBinding(\n node,\n processedNodes,\n true,\n source,\n options,\n );\n }\n\n if (!childrenNodes) {\n childrenNodes = processChildrenBinding(\n node,\n processedNodes,\n false,\n source,\n options,\n );\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 optionExtractCaches = new WeakMap();\n}\n\nregisterEditorCache(clearExtractCache);\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","// Applies source edits by position: the spans `update` records are\n// replaced, and everything else is copied as is, so an edit never reformats\n// code it didn't touch (#239). Not `magic-string`, which would become a\n// runtime dependency for features (source maps, moves) this doesn't need.\nexport interface SourceEdit {\n start: number;\n end: number;\n content: string;\n // Indent `content`'s later lines to match the line it lands on. Only for\n // generated code, which is printed from column zero; a value the author\n // wrote must go in exactly as written. Applied only when every newline is\n // layout (`hasOnlyLayoutNewlines`).\n indent?: boolean;\n}\n\n// Whether every newline in generated code is layout, not part of a value.\n// Babel escapes newlines in ordinary strings, so a meaningful newline can\n// only come from a template literal or JSX text, which start with a\n// backtick or `<`. Indenting such a newline would change the value, again\n// on every edit.\n//\n// Anything ambiguous returns false: a missed indent is harmless, a changed\n// value is not.\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// The index just past the closing quote, or -1 when the literal doesn't end\n// on its line. Generated JS never has a bare newline in a string, so one\n// means the scan is lost.\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 before a newline is a line continuation, so the newline\n // is part of the string's source. Indenting it would change the\n // string: give up.\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// The file's own line ending, so generated code (always LF from Babel)\n// doesn't mix endings in a CRLF file. Used only with re-indentation.\nconst lineTerminatorOf = (source: string): string => {\n return source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n};\n\n// Applies non-overlapping edits to `source` in one pass. An edit with\n// `start === end` inserts. Throws on overlapping or out-of-range edits,\n// which mean the caller's offsets are wrong, instead of returning broken\n// source.\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 { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { nanoid } from 'nanoid';\n\nimport { moveSelectedIndices } from '../selection';\nimport { extract, nodeToJSX } from './extract';\nimport { generateCode } from './helpers';\nimport { type SourceEdit, applyEdits } from './patch';\nimport type { BindingOptions, DataAttrNode } from './types';\n\nexport type ChildrenAction =\n | { type: 'move'; from: number; to: number }\n | { type: 'move-selected'; indices: number[]; direction: 'up' | 'down' }\n | { type: 'remove' | 'duplicate'; indices: number[] }\n | { type: 'append' };\n\nexport interface ChildrenEdit {\n kind: 'children-edit';\n expected: string[];\n action: ChildrenAction;\n}\n\n// Signatures address the extracted list, not synthetic wrapper IDs. The\n// source editor checks them against the latest parent before using indices.\nconst modeledSignatures = (nodes: DataAttrNode[]): string[] =>\n nodes.map(node => {\n const jsx = nodeToJSX(node);\n\n if (!jsx) {\n throw new Error('Invalid child node');\n }\n\n return generateCode(jsx);\n });\n\nexport const getChildrenSignatures = (nodes: DataAttrNode[]): string[] => {\n const modeled = modeledSignatures(nodes);\n\n return nodes.map((node, index) =>\n JSON.stringify([node.source ?? null, modeled[index]]),\n );\n};\n\nconst indicesAreValid = (\n indices: unknown,\n count: number,\n): indices is number[] =>\n Array.isArray(indices) &&\n new Set(indices).size === indices.length &&\n indices.every(\n index => Number.isInteger(index) && index >= 0 && index < count,\n );\n\n// Only ID attributes are replaced: expressions, spreads, comments and text\n// in a copied subtree retain their exact source. Dynamic IDs are ambiguous.\nconst copySource = (source: string, usedIds: Set<string>): string => {\n const node = parseExpression(source, { plugins: ['jsx', 'typescript'] });\n const edits: SourceEdit[] = [];\n const newId = () => {\n let id = nanoid(12);\n\n while (usedIds.has(id)) {\n id = nanoid(12);\n }\n\n usedIds.add(id);\n\n return id;\n };\n\n t.traverseFast(node, child => {\n if (!t.isJSXOpeningElement(child)) {\n return;\n }\n\n const ids = child.attributes.filter(\n (attr): attr is t.JSXAttribute =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name, { name: 'data-id' }),\n );\n\n if (ids.length > 1) {\n throw new Error('Duplicate data-id attributes');\n }\n\n const attr = ids[0];\n\n if (\n attr &&\n child.attributes\n .slice(child.attributes.indexOf(attr) + 1)\n .some(attribute => t.isJSXSpreadAttribute(attribute))\n ) {\n throw new Error('A spread may override the copied data-id');\n }\n\n if (attr) {\n const value = attr.value;\n\n if (\n !t.isStringLiteral(value) ||\n value.start == null ||\n value.end == null\n ) {\n throw new Error('Cannot copy a dynamic data-id');\n }\n\n edits.push({\n start: value.start,\n end: value.end,\n content: JSON.stringify(newId()),\n });\n } else {\n const at = child.attributes.at(-1)?.end ?? child.name.end;\n\n if (at == null) {\n throw new Error('Missing opening element span');\n }\n\n edits.push({\n start: at,\n end: at,\n content: ` data-id=\"${newId()}\"`,\n });\n }\n });\n\n return applyEdits(source, edits);\n};\n\n// Coordinates refer to the caller's wrapped source, just like other update\n// editors. Non-element gaps stay at their original positions; moving a JSX\n// child moves its entire subtree but never regenerates intervening content.\nexport const editChildrenSource = (\n source: string,\n parent: t.JSXElement,\n input: unknown,\n // The binding sources the caller extracted the children with, so they're\n // modeled the same way here (#509, #513).\n options?: BindingOptions,\n): SourceEdit[] | null => {\n try {\n if (!parent.closingElement || parent.start == null || parent.end == null) {\n return null;\n }\n\n const value = typeof input === 'string' ? JSON.parse(input) : input;\n const children = parent.children.filter(\n (child): child is t.JSXElement | t.JSXFragment =>\n t.isJSXElement(child) || t.isJSXFragment(child),\n );\n const raw = children.map(child => source.slice(child.start!, child.end!));\n const models =\n extract(source.slice(parent.start, parent.end), options)[0]?.children ??\n [];\n\n // The extractor currently omits some empty/expression-only fragments.\n // Never interpret its visible indices as different source children.\n if (models.length !== children.length) {\n return null;\n }\n\n const signatures = modeledSignatures(models);\n const replaceSlots = (next: string[]): SourceEdit[] => {\n const edits = children.map((child, index) => ({\n start: child.start!,\n end: child.end!,\n content: next[index] ?? '',\n }));\n\n if (next.length > children.length) {\n const at = parent.closingElement!.start!;\n edits.push({\n start: at,\n end: at,\n content: next.slice(children.length).join(''),\n });\n }\n\n return edits;\n };\n\n if (Array.isArray(value)) {\n // A full list of children (the JSON form). Unchanged children keep\n // their original source; other replacements are allowed only when\n // every original child can be represented without loss.\n const desired = modeledSignatures(value);\n const lossless = raw.every(\n (text, index) =>\n generateCode(\n parseExpression(text, { plugins: ['jsx', 'typescript'] }),\n ) === signatures[index],\n );\n const consumed = new Set<number>();\n const next = desired.map((signature, position) => {\n const index = signatures.findIndex(\n (candidate, i) =>\n candidate === signature &&\n !consumed.has(i) &&\n (value[position].source === undefined ||\n value[position].source === raw[i]),\n );\n\n if (index >= 0) {\n consumed.add(index);\n\n return raw[index]!;\n }\n\n if (\n !lossless ||\n (value[position].source !== undefined &&\n !raw.includes(value[position].source))\n ) {\n throw new Error(\n 'Use children commands to copy or edit unsupported source',\n );\n }\n\n return signature;\n });\n\n // The list may contain new children. Refuse a repeated `data-id`,\n // which would make later edits ambiguous.\n const countIds = (text: string) => {\n const counts = new Map<string, number>();\n t.traverseFast(\n parseExpression(text, { plugins: ['jsx', 'typescript'] }),\n node => {\n if (\n t.isJSXAttribute(node) &&\n t.isJSXIdentifier(node.name, { name: 'data-id' }) &&\n t.isStringLiteral(node.value)\n ) {\n counts.set(\n node.value.value,\n (counts.get(node.value.value) ?? 0) + 1,\n );\n }\n },\n );\n\n return counts;\n };\n const previousIds = countIds(source);\n const updatedParent = applyEdits(source, replaceSlots(next));\n const nextIds = countIds(updatedParent);\n\n if (\n [...nextIds].some(\n ([id, count]) => count > 1 && count > (previousIds.get(id) ?? 0),\n )\n ) {\n return null;\n }\n\n return replaceSlots(next);\n }\n\n const request = value as ChildrenEdit | null;\n\n if (\n request?.kind !== 'children-edit' ||\n !Array.isArray(request.expected) ||\n request.expected.length !== signatures.length ||\n !getChildrenSignatures(models).every(\n (signature, index) => signature === request.expected[index],\n ) ||\n !request.action\n ) {\n return null;\n }\n\n const { action } = request;\n const usedIds = new Set<string>();\n\n t.traverseFast(parent, node => {\n if (\n t.isJSXAttribute(node) &&\n t.isJSXIdentifier(node.name, { name: 'data-id' }) &&\n t.isStringLiteral(node.value)\n ) {\n usedIds.add(node.value.value);\n }\n });\n\n switch (action.type) {\n case 'move': {\n if (\n !indicesAreValid([action.from], raw.length) ||\n !indicesAreValid([action.to], raw.length)\n ) {\n return null;\n }\n\n const next = [...raw];\n const [moved] = next.splice(action.from, 1);\n next.splice(action.to, 0, moved!);\n\n return replaceSlots(next);\n }\n case 'move-selected': {\n if (\n !indicesAreValid(action.indices, raw.length) ||\n !['up', 'down'].includes(action.direction)\n ) {\n return null;\n }\n\n return replaceSlots(\n moveSelectedIndices(raw, new Set(action.indices), action.direction)\n .items,\n );\n }\n case 'remove': {\n if (!indicesAreValid(action.indices, raw.length)) {\n return null;\n }\n\n return action.indices.map(index => ({\n start: children[index]!.start!,\n end: children[index]!.end!,\n content: '',\n }));\n }\n case 'duplicate': {\n if (!indicesAreValid(action.indices, raw.length)) {\n return null;\n }\n\n const content = [...action.indices]\n .sort((a, b) => a - b)\n .map(index => copySource(raw[index]!, usedIds))\n .join('');\n const at = parent.closingElement.start!;\n\n return [{ start: at, end: at, content }];\n }\n case 'append': {\n const content = copySource(raw[0] ?? '<div></div>', usedIds);\n const at = parent.closingElement.start!;\n\n return [{ start: at, end: at, content }];\n }\n default:\n return null;\n }\n } catch {\n return null;\n }\n};\n","import * as t from '@babel/types';\n\nimport { generateCode } from './helpers';\nimport type { NodeValueType } from './types';\n\n// Builds AST expressions and source text from JS values: the inverse of\n// reading them in `value.ts`.\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// Builds an expression for a JS value: the inverse of `evaluateLiteral`\n// (#238). Each JS type maps to one kind of literal. Values with no literal\n// form (`undefined`, functions, symbols) give `null`. Inside an object the\n// property is left out; inside an array the item becomes `null`.\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 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';\n\nimport { STRING_VALUED_TYPES } from './binding';\nimport { generateCode } from './helpers';\nimport type { SourceEdit } from './patch';\nimport type { BindingType } from './types';\nimport { isLosslesslyEvaluable, unwrapExpression } from './value';\nimport { valueToExpression } from './value-expression';\n\n// The source editors behind `update`: each turns one property edit on one\n// element into source spans, and never touches the tree.\n\n// What each editor below returns: the source spans to change, never a\n// changed tree, so everything else stays byte-identical (#239). An empty\n// array means \"handled, nothing to write\"; `null` means the edit failed.\nexport type 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.\nexport const 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\nexport const 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 new attribute goes: after the last attribute, or after the\n// 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// Replaces the element's text. With a single text child, only the trimmed\n// text is replaced, so the line breaks and indentation around it stay\n// (#239). Otherwise every text child is removed and `value` is written just\n// before the closing tag; nested elements stay.\n//\n// A self-closing element has nowhere to put text: this returns no edits,\n// and `update` reports success without changing anything.\nexport const 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 // Measure the raw source, not `only.value`: Babel decodes entities and\n // CRLF in `value`, so its lengths don't match the source offsets.\n // ` Old ` would otherwise become `&New;`.\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// Replaces the element's children with the raw HTML, as written.\nexport const editInnerHTML = (\n element: t.JSXElement,\n value: string,\n): 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\nexport const editRichtext = (\n element: t.JSXElement,\n value: string,\n): 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.\nexport const 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// Whether the attribute holds an array or object literal, such as\n// `items={[...]}`. Other expressions (`className={cn(...)}`,\n// `items={rows}`) don't count: the panel doesn't edit their source, so a\n// string committed to them stays a string.\nconst holdsStructuralExpression = (value?: t.JSXAttribute['value']): boolean =>\n t.isJSXExpressionContainer(value) &&\n (t.isArrayExpression(unwrapExpression(value.expression)) ||\n t.isObjectExpression(unwrapExpression(value.expression)));\n\n// Parses committed text as an array or object literal, or `null`. Only\n// those shapes are accepted: `hello` also parses, as an identifier, and\n// writing `items={hello}` would turn a value into a variable reference.\nconst structuralSource = (value: string): t.Expression | null => {\n try {\n const expression = parseExpression(value.trim(), {\n plugins: ['jsx', 'typescript'],\n });\n\n return t.isArrayExpression(unwrapExpression(expression)) ||\n t.isObjectExpression(unwrapExpression(expression))\n ? expression\n : null;\n } catch {\n return null;\n }\n};\n\n// Builds the JSX attribute value for a value and its declared `type`\n// (#238). `current` is the value being replaced. Without a declared type,\n// as in most `items` bindings, `current` decides whether the value is\n// source code or a string, the same way `getStructuredValue` reads it.\nconst buildAttributeValue = (\n value: unknown,\n type?: BindingType,\n current?: t.JSXAttribute['value'],\n): t.JSXAttribute['value'] => {\n // Declared object or array: an expression. A string here is source text\n // from the Items or object editor, so parse it instead of quoting it.\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 // Otherwise each JS type maps to one kind of literal. A string stays a\n // string literal whatever it contains.\n if (typeof value === 'string') {\n // Except when the attribute holds an array or object literal: then the\n // string is its source text from the array editor. Quoting it would turn\n // `items={[...]}` into a string and break the document.\n if (\n holdsStructuralExpression(current) &&\n !(type && STRING_VALUED_TYPES.has(type))\n ) {\n const structural = structuralSource(value);\n\n if (structural) {\n return t.jsxExpressionContainer(structural);\n }\n }\n\n return t.stringLiteral(value);\n }\n\n const expr = valueToExpression(value);\n return expr ? t.jsxExpressionContainer(expr) : t.stringLiteral(String(value));\n};\n\nexport const 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 // Array or object source from the editors: check its shape, then replace\n // only the expression, so the unchanged items keep their formatting.\n if (\n typeof value === 'string' &&\n (type === 'array' ||\n type === 'object' ||\n (holdsStructuralExpression(attribute.value) &&\n !(type && STRING_VALUED_TYPES.has(type))))\n ) {\n const expression = structuralSource(value);\n\n if (expression && t.isJSXExpressionContainer(attribute.value)) {\n const text = value.trim();\n const lineComment = expression.trailingComments?.some(\n comment => comment.type === 'CommentLine',\n );\n\n return [\n {\n start: attribute.value.expression.start!,\n end: attribute.value.expression.end!,\n content: `${text}${lineComment ? '\\n' : ''}`,\n },\n ];\n }\n }\n\n // Print the whole attribute, so Babel decides the quoting and escaping.\n // The parsed name node is reused, so namespaced and dashed names stay as\n // written.\n const content = generateCode(\n t.jsxAttribute(\n attribute.name,\n buildAttributeValue(value, type, attribute.value),\n ),\n );\n\n return [\n { start: attribute.start, end: attribute.end, content, indent: true },\n ];\n};\n\n// Removes an attribute and the whitespace before it, leaving no gap. A\n// caller asks for this with `undefined`, since React treats an `undefined`\n// prop like a missing one (#426).\nexport const removeAttribute = (\n source: string,\n attribute: t.JSXAttribute,\n): EditResult => {\n if (attribute.start == null || attribute.end == null) {\n return null;\n }\n\n let start = attribute.start;\n\n while (start > 0 && /\\s/.test(source[start - 1]!)) {\n start -= 1;\n }\n\n return [{ start, end: attribute.end, content: '' }];\n};\n\n// Adds a missing attribute after the last one. Only for a real value:\n// clearing a field never creates the attribute (#426). When the last\n// attribute is on its own line, the new one goes on the next line with the\n// same indentation.\nexport const addAttribute = (\n source: string,\n opening: t.JSXOpeningElement,\n propertyName: string,\n value: unknown,\n type?: BindingType,\n): EditResult => {\n const insertAt = attributeInsertPoint(opening);\n\n if (insertAt == null) {\n return null;\n }\n\n // With `indent: true`, a newline is enough to line the new attribute up\n // under the last one.\n const lastStart = opening.attributes[opening.attributes.length - 1]?.start;\n const lineStart =\n lastStart == null ? -1 : source.lastIndexOf('\\n', lastStart - 1) + 1;\n const ownLine =\n lastStart != null &&\n lineStart > 0 &&\n /^\\s*$/.test(source.slice(lineStart, lastStart));\n const separator = ownLine ? '\\n' : ' ';\n\n const content =\n type === 'jsx'\n ? `${propertyName}={${String(value).trim()}}`\n : generateCode(\n t.jsxAttribute(\n t.jsxIdentifier(propertyName),\n buildAttributeValue(value, type),\n ),\n );\n\n return [\n {\n start: insertAt,\n end: insertAt,\n content: `${separator}${content}`,\n indent: true,\n },\n ];\n};\n\nexport const canEditAttributeValue = (\n attribute: t.JSXAttribute,\n value: unknown,\n type?: BindingType,\n) => {\n if (\n !t.isJSXExpressionContainer(attribute.value) ||\n t.isJSXEmptyExpression(attribute.value.expression) ||\n isLosslesslyEvaluable(attribute.value.expression)\n ) {\n return true;\n }\n\n // The array and object editors commit checked source text, which keeps\n // every expression, so accept it.\n return (\n typeof value === 'string' &&\n holdsStructuralExpression(attribute.value) &&\n !(type && STRING_VALUED_TYPES.has(type)) &&\n structuralSource(value) !== null\n );\n};\n","import { parse } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport {\n BINDING_PROP,\n DATA_ATTR,\n RESERVED_BINDING_PROPERTIES,\n} from '../../constants';\nimport { parseBinding, resolveBindings } from './binding';\nimport { editChildrenSource } from './children';\nimport { traverse } from './document';\nimport {\n type EditResult,\n addAttribute,\n canEditAttributeValue,\n childrenRange,\n editAttribute,\n editInnerHTML,\n editInnerText,\n editJsxAttribute,\n editRichtext,\n findAttribute,\n removeAttribute,\n} from './edit-source';\nimport { generateCode, unwrap, wrap } from './helpers';\nimport { getJSXTagName } from './jsx-name';\nimport { type SourceEdit, applyEdits } from './patch';\nimport type { BindingItem, BindingOptions } from './types';\n\n// Why an edit failed, with what a caller needs to name the cause (#270).\n// The cause is usually a wrong `property` or `label` in the element's\n// `data-binding`, not the value just typed.\nexport type UpdateFailure =\n | { reason: 'element-not-found'; dataId: string }\n | { reason: 'no-binding'; dataId: string }\n // The binding targets an attribute the editor owns (`data-id`,\n // `data-name`, `data-binding`), which a panel edit must not rewrite.\n | { reason: 'reserved-property'; dataId: string; property: string }\n // Asked to remove (`undefined`) a property whose binding is `required`.\n | { reason: 'required-property'; dataId: string; property: string }\n | {\n reason: 'binding-not-declared';\n dataId: string;\n label: string;\n property?: string;\n }\n | {\n reason: 'duplicate-binding';\n dataId: string;\n label: string;\n property?: string;\n count: number;\n }\n | { reason: 'attribute-not-found'; dataId: string; property: string }\n // `innerText` or `innerHTML` written to a self-closing element, which has\n // nowhere between its tags to put them (#552).\n | { reason: 'self-closing'; dataId: string; property: string }\n | { reason: 'unsupported-syntax'; dataId: string; property: string }\n | { reason: 'parse-error'; error: unknown };\n\nexport interface UpdateResult {\n code: string;\n success: boolean;\n // Set when `success` is false. The deprecated `bulkUpdate` reports\n // per-entry failures in `failures` instead.\n failure?: UpdateFailure;\n failures?: UpdateFailure[];\n}\n\n// What one `update` call asks for.\ninterface UpdateRequest {\n dataId: string;\n label: string;\n value: unknown;\n property?: string;\n options: BindingOptions;\n}\n\n// One element's outcome: the spans to write (possibly none, which still\n// counts as handled), or why it was refused.\ntype ElementEdit = { edits: SourceEdit[] } | { failure: UpdateFailure };\n\nconst hasDataId = (opening: t.JSXOpeningElement, dataId: string) =>\n opening.attributes.some(\n attr =>\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\nconst findJSXAttribute = (opening: t.JSXOpeningElement, name: string) =>\n opening.attributes.find(\n (attr): attr is t.JSXAttribute =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === name,\n );\n\n// Step 1: the element's binding for the request, from the same sources\n// `extract` reads (#509, #513). Found by `property` when given, otherwise by\n// `label`. More than one match is an authoring mistake, reported rather than\n// resolved by picking one (#240).\nconst findBinding = (\n opening: t.JSXOpeningElement,\n { dataId, label, property, options }: UpdateRequest,\n): { binding: BindingItem } | { failure: UpdateFailure } => {\n const bindingAttr = findJSXAttribute(opening, DATA_ATTR.BINDING);\n\n // An attribute with no value declares nothing to check against.\n if (bindingAttr && !bindingAttr.value) {\n return { failure: { reason: 'no-binding', dataId } };\n }\n\n let own: BindingItem[] | undefined;\n\n if (bindingAttr?.value) {\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 (error) {\n return { failure: { reason: 'parse-error', error } };\n }\n }\n\n own = parseBinding(bindingValue);\n }\n\n const keyAttr = findJSXAttribute(opening, DATA_ATTR.BINDING_KEY);\n const bindings = resolveBindings(\n own,\n keyAttr &&\n (keyAttr.value && t.isStringLiteral(keyAttr.value)\n ? keyAttr.value.value\n : null),\n getJSXTagName(opening),\n options,\n );\n\n if (!own && bindings.length === 0) {\n return { failure: { reason: 'no-binding', dataId } };\n }\n\n const matches = bindings.filter(binding =>\n property !== undefined\n ? binding.property === property\n : binding.label === label,\n );\n\n if (matches.length === 0) {\n return {\n failure: { reason: 'binding-not-declared', dataId, label, property },\n };\n }\n\n if (matches.length > 1) {\n return {\n failure: {\n reason: 'duplicate-binding',\n dataId,\n label,\n property,\n count: matches.length,\n },\n };\n }\n\n return { binding: matches[0]! };\n};\n\n// Step 2: what no edit may do, whatever the property: rewrite an attribute\n// the editor owns, or remove a `required` one (#426).\nconst checkEdit = (\n binding: BindingItem,\n { dataId, value }: UpdateRequest,\n): UpdateFailure | undefined => {\n const property = binding.property;\n\n if (RESERVED_BINDING_PROPERTIES.includes(property)) {\n return { reason: 'reserved-property', dataId, property };\n }\n\n if (value === undefined && binding.required) {\n return { reason: 'required-property', dataId, property };\n }\n\n return undefined;\n};\n\n// An editor's result as an `ElementEdit`: `null` becomes `onNull`'s failure.\nconst toElementEdit = (\n result: EditResult,\n onNull: () => UpdateFailure,\n): ElementEdit => (result ? { edits: result } : { failure: onNull() });\n\n// Step 3: the spans that set `binding`'s property on `element`. `undefined`\n// asks for the property to go: an attribute is removed, content is emptied.\nconst editProperty = (\n source: string,\n element: t.JSXElement,\n binding: BindingItem,\n { dataId, value, options }: UpdateRequest,\n): ElementEdit => {\n const opening = element.openingElement;\n const prop = binding.property;\n const unset = value === undefined;\n const couldNotUpdate = (): UpdateFailure => ({\n reason: 'parse-error',\n error: new Error(`could not update \"${prop}\"`),\n });\n\n // Text and HTML go between the tags, so a self-closing element can't take\n // them. Clearing them is fine: there's nothing to clear (#552).\n const contentWithoutSlot =\n !unset && String(value) !== '' && !childrenRange(element);\n\n switch (prop) {\n case BINDING_PROP.INNER_TEXT: {\n if (contentWithoutSlot) {\n return { failure: { reason: 'self-closing', dataId, property: prop } };\n }\n\n return toElementEdit(\n editInnerText(source, element, unset ? '' : String(value)),\n couldNotUpdate,\n );\n }\n\n case BINDING_PROP.INNER_HTML: {\n // `richtext` is written to an attribute, so it doesn't need one.\n if (contentWithoutSlot && binding.type !== 'richtext') {\n return { failure: { reason: 'self-closing', dataId, property: prop } };\n }\n\n return toElementEdit(\n binding.type === 'richtext'\n ? editRichtext(element, unset ? '' : String(value))\n : editInnerHTML(element, unset ? '' : String(value)),\n couldNotUpdate,\n );\n }\n\n case BINDING_PROP.CHILDREN: {\n // Children are edited one at a time (move, add, remove), so they can't\n // be removed as a whole.\n if (unset) {\n return {\n failure: { reason: 'unsupported-syntax', dataId, property: prop },\n };\n }\n\n return toElementEdit(\n editChildrenSource(source, element, value, options),\n () => ({\n reason: 'parse-error',\n error: new Error(\n 'Unsupported or stale children edit; source was preserved',\n ),\n }),\n );\n }\n\n default: {\n const attribute = findAttribute(opening, prop);\n\n if (unset) {\n // Already absent: nothing to remove, and nothing went wrong.\n return toElementEdit(\n attribute ? removeAttribute(source, attribute) : [],\n () => ({\n reason: 'parse-error',\n error: new Error(`could not remove \"${prop}\"`),\n }),\n );\n }\n\n // A declared property the element doesn't have yet is added when it's\n // given a real value, so a field that was switched off can be switched\n // on again. An empty string leaves it absent (#426).\n if (!attribute) {\n return toElementEdit(\n value === ''\n ? []\n : addAttribute(source, opening, prop, value, binding.type),\n () => ({ reason: 'attribute-not-found', dataId, property: prop }),\n );\n }\n\n if (\n binding.type !== 'jsx' &&\n !canEditAttributeValue(attribute, value, binding.type)\n ) {\n return {\n failure: { reason: 'unsupported-syntax', dataId, property: prop },\n };\n }\n\n return toElementEdit(\n binding.type === 'jsx'\n ? editJsxAttribute(opening, prop, value)\n : editAttribute(opening, prop, value, binding.type),\n () => ({ reason: 'attribute-not-found', dataId, property: prop }),\n );\n }\n }\n};\n\n// The three steps for one element.\nconst editElement = (\n source: string,\n element: t.JSXElement,\n request: UpdateRequest,\n): ElementEdit => {\n const found = findBinding(element.openingElement, request);\n\n if ('failure' in found) {\n return found;\n }\n\n const refused = checkEdit(found.binding, request);\n\n if (refused) {\n return { failure: refused };\n }\n\n return editProperty(source, element, found.binding, request);\n};\n\n// Sets one bound property of the element with `dataId` to `value`, and\n// returns the new source or why it couldn't.\n//\n// The binding is found by `property` when given, otherwise by `label`.\n// Pass `property` when you have it: a label is display text and can repeat\n// (#240). `options` are the binding sources the bindings were read with\n// (#509, #513).\nexport const update = (\n code: string,\n dataId: string,\n label: string,\n value: unknown,\n property?: string,\n options: BindingOptions = {},\n): UpdateResult => {\n const request: UpdateRequest = { dataId, label, value, property, options };\n\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 let failure: UpdateFailure | undefined;\n const edits: SourceEdit[] = [];\n\n // Every element carrying `dataId` is edited, so a duplicated id edits\n // each copy; the last refusal is the one reported.\n traverse(ast, {\n JSXElement(path) {\n if (!hasDataId(path.node.openingElement, dataId)) {\n return;\n }\n\n const result = editElement(wrapped, path.node, request);\n\n if ('failure' in result) {\n failure = result.failure;\n\n return;\n }\n\n edits.push(...result.edits);\n changed = true;\n },\n });\n\n if (!changed) {\n return {\n code,\n success: false,\n // No specific reason recorded means the traversal never reached the\n // target element at all.\n failure: failure ?? { reason: 'element-not-found', dataId },\n };\n }\n\n // Patch the original source: everything outside the recorded spans is\n // copied unchanged (#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, failure: { reason: 'parse-error', error } };\n }\n};\n\nexport interface UpdateEntry {\n dataId: string;\n label: string;\n value: unknown;\n property?: string;\n}\n\n// The result of `updateAll`: every entry applied, or none. On failure `code`\n// is the source as it came in, `index` says which entry was refused, and\n// `failure` says why.\nexport type UpdateAllResult =\n | { success: true; code: string }\n | { success: false; code: string; failure: UpdateFailure; index: number };\n\n// Applies several edits as one: all of them, in array order, or none. The\n// first entry that fails stops the run and the source comes back untouched,\n// so a caller can commit the result as a single change (#425). An entry sees\n// the source the earlier ones left, and a later entry for the same\n// `dataId`/`property` wins.\n//\n// Each entry re-parses the source the one before it produced, so every offset\n// is fresh, and the outcome matches applying the entries one at a time (#239).\nexport const updateAll = (\n raw: string,\n entries: UpdateEntry[],\n options: BindingOptions = {},\n): UpdateAllResult => {\n let current = raw;\n\n for (const [index, entry] of entries.entries()) {\n const result = update(\n current,\n entry.dataId,\n entry.label,\n entry.value,\n entry.property,\n options,\n );\n\n if (!result.success) {\n return {\n success: false,\n code: raw,\n failure: result.failure ?? {\n reason: 'element-not-found',\n dataId: entry.dataId,\n },\n index,\n };\n }\n\n current = result.code;\n }\n\n return { success: true, code: current };\n};\n\n/**\n * @deprecated Not atomic: when an entry fails, the ones before and after it\n * are still applied, and the returned `code` carries them. Use `updateAll`,\n * which applies every entry or none. Will be removed in the next major.\n */\nexport const bulkUpdate = (\n raw: string,\n entries: UpdateEntry[],\n): UpdateResult => {\n let current = raw;\n const failures: UpdateFailure[] = [];\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 if (!result.success && result.failure) {\n failures.push(result.failure);\n }\n }\n\n return failures.length > 0\n ? { code: current, success: false, failures }\n : { code: current, success: true };\n};\n","import * as t from '@babel/types';\n\nimport { type SourceEdit, applyEdits } from './patch';\nimport { parseArrayExpression } from './value';\n\n// Gaps between dense elements contain only whitespace, comments and one\n// comma. Scan those gaps, never the expressions (which can contain JSX,\n// regexes, templates and nested commas).\nconst commaIn = (source: string, start: number, end: number): number | null => {\n let comma: number | null = null;\n\n for (let at = start; at < end; at++) {\n if (/\\s/.test(source[at]!)) {\n continue;\n }\n\n if (source.startsWith('/*', at)) {\n const close = source.indexOf('*/', at + 2);\n\n if (close < 0 || close + 2 > end) {\n return null;\n }\n\n at = close + 1;\n } else if (source.startsWith('//', at)) {\n const newline = source.indexOf('\\n', at + 2);\n at = newline < 0 ? end : newline;\n } else if (source[at] === ',' && comma === null) {\n comma = at;\n } else {\n return null;\n }\n }\n\n return comma;\n};\n\nexport const denseArraySource = (source: string) => {\n const array = parseArrayExpression(source);\n\n // Holes/spreads have source positions but no stable visible item count.\n // Value edits can preserve them; structural edits deliberately refuse.\n if (\n !array ||\n array.elements.some(\n node => !t.isExpression(node) || node.extra?.parenthesized,\n )\n ) {\n return null;\n }\n\n const elements = array.elements as t.Expression[];\n const commas = elements\n .slice(0, -1)\n .map((node, index) =>\n commaIn(source, node.end!, elements[index + 1]!.start!),\n );\n\n if (commas.some(comma => comma === null)) {\n return null;\n }\n\n const last = elements.at(-1);\n const trailing = last ? commaIn(source, last.end!, array.end! - 1) : null;\n\n return { array, elements, commas: commas as number[], trailing };\n};\n\n// Keep presentation and mutation on the same syntax boundary. Consumers can\n// use this before offering structural controls, while every write still calls\n// denseArraySource() again so stale source is refused at commit time.\nexport const canStructurallyEditArray = (source: string) =>\n denseArraySource(source) !== null;\n\nexport const validArrayIndices = (indices: Iterable<number>, length: number) =>\n [...indices].every(\n index => Number.isInteger(index) && index >= 0 && index < length,\n );\n\nexport const reorderArraySource = (\n source: string,\n elements: t.Expression[],\n next: t.Expression[],\n): string =>\n applyEdits(\n source,\n elements.map((node, index) => ({\n start: node.start!,\n end: node.end!,\n content: source.slice(next[index]!.start!, next[index]!.end!),\n })),\n );\n\nexport const removeArraySource = (\n source: string,\n data: NonNullable<ReturnType<typeof denseArraySource>>,\n indices: Set<number>,\n): string => {\n const edits: SourceEdit[] = [];\n const removedCommas = new Set<number>();\n const { elements, commas, trailing } = data;\n\n // Each consecutive removed run consumes its following commas. A run\n // ending at the last element consumes the preceding separator instead;\n // a trailing comma, when present, stays a trailing comma.\n for (let index = 0; index < elements.length; index++) {\n if (!indices.has(index)) {\n continue;\n }\n\n const start = index;\n\n while (index + 1 < elements.length && indices.has(index + 1)) {\n index++;\n }\n\n for (let current = start; current <= index; current++) {\n const node = elements[current]!;\n edits.push({ start: node.start!, end: node.end!, content: '' });\n\n if (current < elements.length - 1) {\n removedCommas.add(commas[current]!);\n }\n }\n\n if (index === elements.length - 1) {\n if (trailing !== null) {\n removedCommas.add(trailing);\n } else if (start > 0) {\n removedCommas.add(commas[start - 1]!);\n }\n }\n }\n\n for (const comma of removedCommas) {\n edits.push({ start: comma, end: comma + 1, content: '' });\n }\n\n return applyEdits(source, edits);\n};\n\nexport const appendArraySource = (\n source: string,\n data: NonNullable<ReturnType<typeof denseArraySource>>,\n copies: string[],\n): string => {\n const last = data.elements.at(-1);\n\n if (!last || copies.length === 0) {\n return source;\n }\n\n // Insert before the old trailing gap so line comments cannot swallow a\n // new item, and keep an existing trailing comma in its original role.\n return applyEdits(source, [\n {\n start: last.end!,\n end: last.end!,\n content: `, ${copies.join(', ')}`,\n },\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 {\n appendArraySource,\n denseArraySource,\n removeArraySource,\n reorderArraySource,\n validArrayIndices,\n} from './array-source';\nimport { generateCode } from './helpers';\nimport { type SourceEdit, applyEdits } from './patch';\nimport type {\n BindingRenderLeaf,\n BindingRenderMap,\n NodeValueType,\n} from './types';\nimport {\n extractNodeValue,\n extractObjectProperties,\n isLosslesslyEvaluable,\n parseArrayExpression,\n parseValue,\n} from './value';\nimport { createNodeFromValue, valueToExpression } from './value-expression';\n\n// Array edits are source patches. Parsing locates the requested value or\n// element; unrelated expressions, comments and formatting are not printed\n// again. Structural edits require dense arrays; value edits preserve holes\n// and spreads at their existing source positions. `null` means refusal.\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) =>\n parseArrayExpression(code)?.elements ?? null;\n\nconst kindOf = (element: t.Expression): ItemKind =>\n t.isObjectExpression(element) ? 'object' : 'primitive';\n\n// Omit holes and spreads from the visible list without renumbering source\n// positions. A spread is not one runtime value that the panel can edit.\nexport const parseItems = (code: string): ArrayItem[] | null => {\n const elements = elementsOf(code);\n\n return (\n elements?.flatMap((node, index) =>\n t.isExpression(node) ? [{ index, kind: kindOf(node), node }] : [],\n ) ?? null\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// Escapes text for a template literal's raw source: backticks, `${`,\n// backslashes and carriage returns. Without this, pasted markup can throw\n// in `@babel/types`, and CRLF doesn't 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 is raw markup: a template literal keeps it as written.\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 // JSX when the render map declares `jsx`, or when the current value is\n // already JSX without a declaration, so it stays JSX (#298).\n if (\n renderLeaf?.type === 'jsx' ||\n t.isJSXElement(current) ||\n t.isJSXFragment(current)\n ) {\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 source text; parse it as is. The\n // object editor and the fallback text area commit a JS value instead.\n if (typeof value === 'string') {\n try {\n return parseExpression(value, { plugins: ['jsx', 'typescript'] });\n } catch {\n return undefined;\n }\n }\n\n // A JS value can be rebuilt exactly only when the property held nothing\n // but literals. Otherwise the edit is refused and the source stays.\n if (!isLosslesslyEvaluable(current)) {\n return undefined;\n }\n\n return valueToExpression(value) ?? undefined;\n }\n\n // Scalars arrive as typed text, so convert first: the string `'true'`\n // would otherwise become `false` for a boolean.\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 let serialized =\n typeof value === 'string' &&\n (declaredType === 'array' ||\n declaredType === 'object' ||\n t.isJSXElement(nextValue) ||\n t.isJSXFragment(nextValue))\n ? value.trim()\n : generateCode(nextValue);\n\n if (\n nextValue.trailingComments?.some(comment => comment.type === 'CommentLine')\n ) {\n serialized += '\\n';\n }\n\n // A shorthand property shares the key/value span: expand it explicitly.\n const content = target.shorthand ? `${key}: ${serialized}` : serialized;\n\n return applyEdits(code, [\n { start: target.value.start!, end: target.value.end!, content },\n ]);\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 || !t.isExpression(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 return applyEdits(code, [\n {\n start: element.start!,\n end: element.end!,\n content: generateCode(nextValue),\n },\n ]);\n};\n\nexport const moveArrayItem = (\n code: string,\n from: number,\n to: number,\n): string | null => {\n const data = denseArraySource(code);\n\n if (\n !data ||\n !validArrayIndices([from], data.elements.length) ||\n !Number.isInteger(to)\n ) {\n return null;\n }\n\n // Preserve the existing splice destination semantics (including append).\n const next = [...data.elements];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved!);\n\n return reorderArraySource(code, data.elements, next);\n};\n\nexport const moveArrayItems = (\n code: string,\n indices: Set<number>,\n direction: 'up' | 'down',\n): { code: string; indices: Set<number> } | null => {\n const data = denseArraySource(code);\n\n if (\n !data ||\n !validArrayIndices(indices, data.elements.length) ||\n !['up', 'down'].includes(direction)\n ) {\n return null;\n }\n\n const next = moveSelectedIndices(data.elements, indices, direction);\n\n return {\n code: reorderArraySource(code, data.elements, next.items),\n indices: next.indices,\n };\n};\n\n// Keep the last-item guard until the empty-array creation contract (#316)\n// is implemented. It must count the visible kind in a mixed array.\nexport const removeArrayItems = (\n code: string,\n indices: Set<number>,\n kind?: ItemKind,\n): string | null => {\n const data = denseArraySource(code);\n\n if (!data || !validArrayIndices(indices, data.elements.length)) {\n return null;\n }\n\n const remaining = removeIndices(data.elements, indices);\n const survivors =\n kind === undefined\n ? remaining\n : remaining.filter(node => kindOf(node) === kind);\n\n if (!survivors.length) {\n return null;\n }\n\n return removeArraySource(code, data, indices);\n};\n\n// Copy exact source; only static object keys / JSX identities get changed.\n// Re-evaluating modeled property values here would erase expressions.\nconst copyItem = (\n code: string,\n element: t.Expression,\n generateId: () => string,\n usedIds: Set<string>,\n): string | null => {\n const edits: SourceEdit[] = [];\n let unsupported = false;\n const reserveId = (id: string) => {\n if (usedIds.has(id)) {\n unsupported = true;\n }\n\n usedIds.add(id);\n\n return JSON.stringify(id);\n };\n\n t.traverseFast(element, node => {\n if (!t.isJSXOpeningElement(node)) {\n return;\n }\n\n const ids = node.attributes.filter(\n (attr): attr is t.JSXAttribute =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name, { name: 'data-id' }),\n );\n const attr = ids[0];\n\n if (\n ids.length > 1 ||\n (attr &&\n (!t.isStringLiteral(attr.value) ||\n node.attributes\n .slice(node.attributes.indexOf(attr) + 1)\n .some(a => t.isJSXSpreadAttribute(a))))\n ) {\n unsupported = true;\n return;\n }\n\n if (attr && t.isStringLiteral(attr.value)) {\n edits.push({\n start: attr.value.start!,\n end: attr.value.end!,\n content: reserveId(generateId()),\n });\n }\n });\n\n if (t.isObjectExpression(element)) {\n const keys = element.properties.filter(\n (prop): prop is t.ObjectProperty =>\n t.isObjectProperty(prop) &&\n !prop.computed &&\n (t.isIdentifier(prop.key, { name: 'key' }) ||\n t.isStringLiteral(prop.key, { value: 'key' })),\n );\n const key = keys[0];\n\n if (\n keys.length > 1 ||\n (key &&\n (!t.isStringLiteral(key.value) ||\n element.properties\n .slice(element.properties.indexOf(key) + 1)\n .some(\n prop =>\n t.isSpreadElement(prop) ||\n ('computed' in prop && prop.computed),\n )))\n ) {\n return null;\n }\n\n if (key && t.isStringLiteral(key.value)) {\n edits.push({\n start: key.value.start!,\n end: key.value.end!,\n content: reserveId(`${key.value.value}-${generateId()}`),\n });\n }\n }\n\n if (unsupported) {\n return null;\n }\n\n return applyEdits(\n code.slice(element.start!, element.end!),\n edits.map(edit => ({\n ...edit,\n start: edit.start - element.start!,\n end: edit.end - element.start!,\n })),\n );\n};\n\nexport const duplicateArrayItems = (\n code: string,\n indices: Set<number>,\n generateId: () => string = () => nanoid(6),\n): string | null => {\n const data = denseArraySource(code);\n\n if (\n !data ||\n !indices.size ||\n !validArrayIndices(indices, data.elements.length)\n ) {\n return null;\n }\n\n const usedIds = new Set<string>();\n\n t.traverseFast(data.array, node => {\n if (\n t.isJSXAttribute(node) &&\n t.isJSXIdentifier(node.name, { name: 'data-id' }) &&\n t.isStringLiteral(node.value)\n ) {\n usedIds.add(node.value.value);\n } else if (\n t.isObjectProperty(node) &&\n !node.computed &&\n (t.isIdentifier(node.key, { name: 'key' }) ||\n t.isStringLiteral(node.key, { value: 'key' })) &&\n t.isStringLiteral(node.value)\n ) {\n usedIds.add(node.value.value);\n }\n });\n\n const copies = [...indices]\n .sort((a, b) => a - b)\n .map(index => copyItem(code, data.elements[index]!, generateId, usedIds));\n\n return copies.every((copy): copy is string => copy !== null)\n ? appendArraySource(code, data, copies)\n : null;\n};\n\n// Appends a copy of the first item of `kind`. Items are never created from\n// scratch, because their shape comes from their siblings. So an array\n// needs at least one item to be editable, and `removeArrayItems` never\n// empties it. `null` means there is no item of `kind` to copy; the first\n// one has to be written in the source (#316).\nexport const appendArrayItem = (\n code: string,\n kind: ItemKind,\n generateId: () => string = () => nanoid(6),\n): string | null => {\n const data = denseArraySource(code);\n const index = data?.elements.findIndex(node => kindOf(node) === kind) ?? -1;\n\n return index < 0\n ? null\n : duplicateArrayItems(code, new Set([index]), generateId);\n};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,gBAAkB,KAAK,KAAK,GAE5B,QAAQ,IAAI,KAAK,MAAM,KAAK;CAEhC,CAAC;CAED,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CACxB,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC,CACrB,KAAI,UAAS,SAAS,MAAM,KAAK,SAAS,QAAS,YAAY,OAAO,CAAC;CAE1E,OAAO,OAAO,OAAO,SAAyB,SAAS,IAAI,IACvD,kBAAkB,MAAM,MAAM,MAAM,IACpC;AACN;AAOA,MAAa,mBACX,MACA,MACA,mBAAiC,OAAO,CAAC,MACvB;CAElB,MAAM,QADO,iBAAiB,IACb,CAAC,EAAE,SAAS,WAAU,SAAQ,OAAO,IAAI,MAAM,IAAI,KAAK;CAEzE,OAAO,QAAQ,IACX,OACA,oBAAoB,sBAAM,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,UAAU;AAC5D"}
|
|
@@ -80,6 +80,7 @@ const defaultMessages = {
|
|
|
80
80
|
noBinding: "This element has no data-binding declaration.",
|
|
81
81
|
elementNotFound: "The target element could not be found in this section.",
|
|
82
82
|
unsupportedSyntax: (property) => `The "${property}" expression was preserved. Change it in the code editor instead.`,
|
|
83
|
+
selfClosing: (property) => `This element is self-closing, so it has no content for "${property}". Give it a closing tag in the code editor.`,
|
|
83
84
|
checkConsole: "Check the console for details.",
|
|
84
85
|
syntaxError: "The document has a syntax error",
|
|
85
86
|
syntaxErrorDetail: "The canvas shows the last version that parsed. Fix the error in the code, then edit here again.",
|
|
@@ -129,4 +130,4 @@ const useLiveMessages = () => useContext(MessagesContext);
|
|
|
129
130
|
//#endregion
|
|
130
131
|
export { useLiveMessages as i, defaultMessages as n, mergeMessages as r, MessagesContext as t };
|
|
131
132
|
|
|
132
|
-
//# sourceMappingURL=messages-
|
|
133
|
+
//# sourceMappingURL=messages-CSrMI4Rm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages-CSrMI4Rm.js","names":[],"sources":["../src/components/context/messages.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport {\n type ValidationMessages,\n defaultValidationMessages,\n} from '~/utils/ast/validate';\n\n// Every piece of text the editor shows or announces, grouped by where it\n// appears (#524). Text with values in it is a function, so a translation\n// can put them where its grammar needs them. Pass a partial set to `Live`'s\n// `messages` prop to replace any of it; the rest stays English.\nexport interface LiveMessages {\n // The section toolbar on the canvas and the panel header.\n section: {\n moveUp: string;\n moveDown: string;\n duplicate: string;\n delete: string;\n };\n canvas: {\n // The mobile palette button and Drawer title.\n palette: string;\n // The mobile panel Drawer title.\n properties: string;\n pickElement: string;\n pickElementActive: string;\n dropHere: string;\n dropAtBottom: string;\n empty: string;\n emptyHintTouch: string;\n emptyHintDrag: string;\n syntaxError: string;\n syntaxErrorDetail: string;\n missingContainer: (containerId: string) => string;\n missingContainerDetail: (containerId: string) => string;\n stale: string;\n };\n panel: {\n selectSection: string;\n noEditableElements: string;\n readOnly: string;\n expressionPreserved: string;\n useCodeEditor: string;\n invalidValue: string;\n urlPlaceholder: string;\n numberPlaceholder: string;\n textPlaceholder: string;\n };\n // The built-in editor for an array value.\n items: {\n heading: (count: number) => string;\n add: string;\n item: (position: number) => string;\n reorder: (item: string) => string;\n moveUp: string;\n moveDown: string;\n delete: string;\n collapseAll: string;\n expandAll: string;\n unreadable: string;\n empty: string;\n structureLocked: string;\n noNestedBindings: string;\n };\n // The built-in editor for child elements.\n children: {\n heading: (count: number) => string;\n add: string;\n child: (position: number, tagName: string) => string;\n moveUp: string;\n moveDown: string;\n delete: string;\n editableBindings: string;\n childNodes: string;\n };\n // The bar shown while items or children are selected.\n selection: {\n count: (count: number) => string;\n duplicate: string;\n moveUp: string;\n moveDown: string;\n delete: string;\n clear: string;\n };\n // The `title` and `description` of a `DndEditError`, which the default\n // toast shows.\n editErrors: {\n updateFailed: (label: string) => string;\n cannotEdit: (label: string) => string;\n cannotRemove: (label: string) => string;\n attributeNotFound: (property: string) => string;\n // `property` is set when the binding names one, otherwise `label` is the\n // one to show.\n bindingNotDeclared: (target: {\n label: string;\n property?: string;\n }) => string;\n duplicateBinding: (target: {\n count: number;\n label: string;\n property?: string;\n }) => string;\n reservedProperty: (property: string) => string;\n requiredProperty: (property: string) => string;\n noBinding: string;\n elementNotFound: string;\n unsupportedSyntax: (property: string) => string;\n selfClosing: (property: string) => string;\n checkConsole: string;\n syntaxError: string;\n syntaxErrorDetail: string;\n missingContainer: (containerId: string) => string;\n missingContainerDetail: (containerId: string) => string;\n sectionParseFailed: string;\n itemsParseFailed: string;\n itemUpdateFailed: string;\n itemUpdateFailedDetail: string;\n };\n // What a screen reader hears during a drag.\n announcements: {\n instructions: string;\n // Stands in for a section without a name.\n section: string;\n pickedUp: (name: string) => string;\n movedTo: (name: string, position: number, total: number) => string;\n notOver: (name: string) => string;\n droppedAt: (name: string, position: number, total: number) => string;\n dropped: (name: string) => string;\n cancelled: (name: string) => string;\n itemOver: (name: string, over: string) => string;\n itemMoved: (name: string, over: string) => string;\n };\n // The error boxes of `Live.Preview`, `Live.Error` and canvas sections.\n errors: {\n default: string;\n compile: string;\n runtime: string;\n rendering: string;\n sectionUnavailable: string;\n sectionNotRendered: string;\n tryAgain: string;\n // The message of a page error that carries none.\n unknown: string;\n // The message of an unhandled promise rejection that carries none.\n unhandledRejection: string;\n };\n validation: ValidationMessages;\n}\n\n// Every group of `LiveMessages`, each with any of its keys.\nexport type LiveMessagesInput = {\n [Group in keyof LiveMessages]?: Partial<LiveMessages[Group]>;\n};\n\nexport const defaultMessages: LiveMessages = {\n section: {\n moveUp: 'Move section up',\n moveDown: 'Move section down',\n duplicate: 'Duplicate section',\n delete: 'Delete section',\n },\n canvas: {\n palette: 'Components',\n properties: 'Properties',\n pickElement: 'Pick an element',\n pickElementActive: 'Click an element to edit it. Esc to cancel.',\n dropHere: 'Drop here',\n dropAtBottom: 'Drag here to add at bottom',\n empty: 'No sections available',\n emptyHintTouch: 'Tap a component to add it',\n emptyHintDrag: 'Drag a component from the left to add it',\n syntaxError: 'The document has a syntax error',\n syntaxErrorDetail: 'Fix it in the code to see its sections',\n missingContainer: containerId =>\n `No #${containerId} element in the document`,\n missingContainerDetail: containerId =>\n `Sections go inside the element with id=\"${containerId}\"`,\n stale:\n 'Showing the last version that parsed. Fix the syntax error in the code to edit here again.',\n },\n panel: {\n selectSection: 'Please select a section.',\n noEditableElements: 'No editable elements.',\n readOnly:\n \"The document has a syntax error. These fields are from the last version that parsed, and can't be edited until it parses again.\",\n expressionPreserved:\n 'This expression is preserved but is not editable here.',\n useCodeEditor: 'Use the code editor to change it.',\n invalidValue: 'Invalid value.',\n urlPlaceholder: 'https://example.com',\n numberPlaceholder: 'Enter a numeric value',\n textPlaceholder: 'Enter a value',\n },\n items: {\n heading: count => `Items (${count})`,\n add: 'Add Item',\n item: position => `Item ${position}`,\n reorder: item => `Reorder ${item}`,\n moveUp: 'Move item up',\n moveDown: 'Move item down',\n delete: 'Delete item',\n collapseAll: 'Collapse all',\n expandAll: 'Expand all',\n unreadable:\n 'This value could not be read as a list. Edit it in the code editor.',\n empty:\n 'No editable items. The panel copies an existing item rather than guessing the shape of a new one — add the first item in the code editor.',\n structureLocked:\n 'Values remain editable, but moving, copying, adding, and deleting require a dense array without spreads or parenthesized top-level items. Use the code editor for those structural changes.',\n noNestedBindings: 'No JSX bindings found',\n },\n children: {\n heading: count => `Children Items (${count})`,\n add: 'Add Child',\n child: (position, tagName) => `Child ${position} (${tagName})`,\n moveUp: 'Move child up',\n moveDown: 'Move child down',\n delete: 'Delete child',\n editableBindings: 'Editable Bindings:',\n childNodes: 'Child Nodes:',\n },\n selection: {\n count: count => `${count} selected`,\n duplicate: 'Duplicate selected',\n moveUp: 'Move selected up',\n moveDown: 'Move selected down',\n delete: 'Delete selected',\n clear: 'Clear',\n },\n editErrors: {\n updateFailed: label => `Failed to update \"${label}\"`,\n cannotEdit: label => `Cannot edit \"${label}\" in the panel`,\n cannotRemove: label => `Cannot remove \"${label}\"`,\n attributeNotFound: property =>\n `This element has no \"${property}\" attribute — check the property in its data-binding.`,\n bindingNotDeclared: ({ label, property }) =>\n `No binding for ${\n property ? `property \"${property}\"` : `label \"${label}\"`\n } is declared on this element's data-binding.`,\n duplicateBinding: ({ count, label, property }) =>\n `${count} bindings share ${\n property ? `property \"${property}\"` : `label \"${label}\"`\n } on this element — remove the duplicate in its data-binding.`,\n reservedProperty: property =>\n `\"${property}\" is managed by the editor, so a binding can't change it.`,\n requiredProperty: property =>\n `\"${property}\" is marked required in its data-binding, so it can't be removed.`,\n noBinding: 'This element has no data-binding declaration.',\n elementNotFound: 'The target element could not be found in this section.',\n unsupportedSyntax: property =>\n `The \"${property}\" expression was preserved. Change it in the code editor instead.`,\n selfClosing: property =>\n `This element is self-closing, so it has no content for \"${property}\". Give it a closing tag in the code editor.`,\n checkConsole: 'Check the console for details.',\n syntaxError: 'The document has a syntax error',\n syntaxErrorDetail:\n 'The canvas shows the last version that parsed. Fix the error in the code, then edit here again.',\n missingContainer: containerId =>\n `No #${containerId} element in the document`,\n missingContainerDetail: containerId =>\n `Sections are the <section> elements inside the element with id=\"${containerId}\". Start from createDocument(), or set containerId to match your document.`,\n sectionParseFailed: 'Failed to parse this section',\n itemsParseFailed: 'Failed to parse items',\n itemUpdateFailed: 'Failed to update this item',\n itemUpdateFailedDetail:\n 'The source was preserved. Structural edits require a dense array without spreads; use the code editor for unsupported syntax.',\n },\n announcements: {\n instructions:\n 'On a palette item, press Enter to add it to the canvas. On a canvas section, press Enter to select it, the up and down arrow keys to go to the previous or next section, and Delete to remove it. Press Space to pick a section up, the arrow keys to move it, and Space or Enter to drop it. Press Escape to cancel.',\n section: 'section',\n pickedUp: name => `Picked up ${name}.`,\n movedTo: (name, position, total) =>\n `${name} moved to position ${position} of ${total}.`,\n notOver: name => `${name} is no longer over a position.`,\n droppedAt: (name, position, total) =>\n `${name} dropped at position ${position} of ${total}.`,\n dropped: name => `${name} dropped.`,\n cancelled: name => `Moving ${name} was cancelled.`,\n itemOver: (name, over) => `${name} is over ${over}.`,\n itemMoved: (name, over) => `${name} was moved to the place of ${over}.`,\n },\n errors: {\n default: 'An error occurred',\n compile: 'Compile Error',\n runtime: 'Runtime Error',\n rendering: 'Rendering Error',\n sectionUnavailable: 'Section Unavailable',\n sectionNotRendered: 'This section is not rendered in this editor.',\n tryAgain: 'Try Again',\n unknown: 'Unknown error',\n unhandledRejection: 'Unhandled promise rejection',\n },\n validation: defaultValidationMessages,\n};\n\n// `base` (the defaults, unless given) with each group's given keys on top.\nexport const mergeMessages = (\n input?: LiveMessagesInput,\n base: LiveMessages = defaultMessages,\n): LiveMessages => {\n if (!input) {\n return base;\n }\n\n const merged = { ...base };\n\n for (const group of Object.keys(base) as (keyof LiveMessages)[]) {\n if (input[group]) {\n merged[group] = { ...base[group], ...input[group] } as never;\n }\n }\n\n return merged;\n};\n\n// The English defaults outside a provider, so an error box rendered on its\n// own still has text.\nexport const MessagesContext = createContext<LiveMessages>(defaultMessages);\n\n// The messages in effect: the provider's, merged over the defaults. A custom\n// palette or panel can use it to show the same text as the built-in ones.\nexport const useLiveMessages = () => useContext(MessagesContext);\n"],"mappings":";;;AA0JA,MAAa,kBAAgC;CAC3C,SAAS;EACP,QAAQ;EACR,UAAU;EACV,WAAW;EACX,QAAQ;CACV;CACA,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,aAAa;EACb,mBAAmB;EACnB,UAAU;EACV,cAAc;EACd,OAAO;EACP,gBAAgB;EAChB,eAAe;EACf,aAAa;EACb,mBAAmB;EACnB,mBAAkB,gBAChB,OAAO,YAAY;EACrB,yBAAwB,gBACtB,2CAA2C,YAAY;EACzD,OACE;CACJ;CACA,OAAO;EACL,eAAe;EACf,oBAAoB;EACpB,UACE;EACF,qBACE;EACF,eAAe;EACf,cAAc;EACd,gBAAgB;EAChB,mBAAmB;EACnB,iBAAiB;CACnB;CACA,OAAO;EACL,UAAS,UAAS,UAAU,MAAM;EAClC,KAAK;EACL,OAAM,aAAY,QAAQ;EAC1B,UAAS,SAAQ,WAAW;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B,SAAS,MAAM,MAAM;EACtD,UAAS,SAAQ,GAAG,KAAK;EACzB,YAAW,SAAQ,UAAU,KAAK;EAClC,WAAW,MAAM,SAAS,GAAG,KAAK,WAAW,KAAK;EAClD,YAAY,MAAM,SAAS,GAAG,KAAK,6BAA6B,KAAK;CACvE;CACA,QAAQ;EACN,SAAS;EACT,SAAS;EACT,SAAS;EACT,WAAW;EACX,oBAAoB;EACpB,oBAAoB;EACpB,UAAU;EACV,SAAS;EACT,oBAAoB;CACtB;CACA,YAAY;AACd;AAGA,MAAa,iBACX,OACA,OAAqB,oBACJ;CACjB,IAAI,CAAC,OACH,OAAO;CAGT,MAAM,SAAS,EAAE,GAAG,KAAK;CAEzB,KAAK,MAAM,SAAS,OAAO,KAAK,IAAI,GAClC,IAAI,MAAM,QACR,OAAO,SAAS;EAAE,GAAG,KAAK;EAAQ,GAAG,MAAM;CAAO;CAItD,OAAO;AACT;AAIA,MAAa,kBAAkB,cAA4B,eAAe;AAI1E,MAAa,wBAAwB,WAAW,eAAe"}
|
|
@@ -86,6 +86,7 @@ interface LiveMessages {
|
|
|
86
86
|
noBinding: string;
|
|
87
87
|
elementNotFound: string;
|
|
88
88
|
unsupportedSyntax: (property: string) => string;
|
|
89
|
+
selfClosing: (property: string) => string;
|
|
89
90
|
checkConsole: string;
|
|
90
91
|
syntaxError: string;
|
|
91
92
|
syntaxErrorDetail: string;
|
|
@@ -126,4 +127,4 @@ declare const defaultMessages: LiveMessages;
|
|
|
126
127
|
declare const useLiveMessages: () => LiveMessages;
|
|
127
128
|
//#endregion
|
|
128
129
|
export { useLiveMessages as i, LiveMessagesInput as n, defaultMessages as r, LiveMessages as t };
|
|
129
|
-
//# sourceMappingURL=messages-
|
|
130
|
+
//# sourceMappingURL=messages-IBPs4TkZ.d.ts.map
|
package/dist/preview/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as baseModules } from "../use-dynamic-tailwind-
|
|
2
|
-
import { t as Preview } from "../preview-
|
|
1
|
+
import { r as baseModules } from "../use-dynamic-tailwind-BP1toJkW.js";
|
|
2
|
+
import { t as Preview } from "../preview-CtyG5UbH.js";
|
|
3
3
|
export { baseModules, Preview as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as useLiveMessages } from "./messages-
|
|
1
|
+
import { i as useLiveMessages } from "./messages-CSrMI4Rm.js";
|
|
2
2
|
import { i as usePreview, r as useError } from "./states-Ci1AvoQ9.js";
|
|
3
3
|
import { t as cn } from "./cn-CAnad2vL.js";
|
|
4
|
-
import {
|
|
5
|
-
import { t as Error } from "./error-
|
|
4
|
+
import { i as Frame, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-BP1toJkW.js";
|
|
5
|
+
import { t as Error } from "./error-CN_GCnXB.js";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/preview/defaults.ts
|
|
@@ -85,4 +85,4 @@ const Preview = ({ code, props = NO_PROPS, modules = NO_MODULES, dynamicTailwind
|
|
|
85
85
|
//#endregion
|
|
86
86
|
export { Preview as t };
|
|
87
87
|
|
|
88
|
-
//# sourceMappingURL=preview-
|
|
88
|
+
//# sourceMappingURL=preview-CtyG5UbH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-
|
|
1
|
+
{"version":3,"file":"preview-CtyG5UbH.js","names":["LiveError"],"sources":["../src/components/preview/defaults.ts","../src/components/preview/client.tsx","../src/components/preview/preview.tsx"],"sourcesContent":["// Stable defaults for optional object props. A `= {}` default is a new\n// object on every render, which re-runs every memo keyed on it — the merged\n// module map, and so `compile()` — even when the caller passed nothing (#348).\nexport const NO_PROPS: Record<string, unknown> = {};\nexport const NO_MODULES: Record<string, unknown> = {};\n","'use client';\n\nimport { useMemo } from 'react';\n\nimport { useLiveMessages } from '~/components/context/messages';\nimport { useError, usePreview } from '~/components/context/states';\nimport LiveError from '~/components/error';\nimport Frame, { type FrameProps } from '~/components/frame';\nimport { cn } from '~/utils/cn';\n\nimport { NO_MODULES, NO_PROPS } from './defaults';\nimport { type Props } from './preview';\nimport { useCompiledModule } from './use-compiled-module';\nimport { useDynamicTailwind } from './use-dynamic-tailwind';\n\nconst Client = ({\n code: _code,\n className,\n showError,\n props = NO_PROPS,\n modules = NO_MODULES,\n frame,\n dynamicTailwind = false,\n provider,\n}: Props) => {\n const { code } = usePreview();\n const { error, setError } = useError();\n const messages = useLiveMessages();\n const isError = !!showError && !!error;\n\n const classNames = cn(isError && 'hidden', className);\n\n const effectiveCode = _code === undefined ? code : _code;\n\n const module = useCompiledModule(effectiveCode, modules);\n\n // Attached to the wrapper below; scans the rendered DOM so classes coming\n // from an imported component are picked up too. See the hook for details.\n const { ref: contentRef, css: dynamicCSS } = useDynamicTailwind(\n effectiveCode,\n dynamicTailwind,\n );\n\n const componentProps = useMemo(\n () => ({\n ...props,\n }),\n [props],\n );\n\n const renderProvider = (component: React.ReactNode) => {\n return provider ? provider(component) : component;\n };\n\n if (module && module.error) {\n return (\n <>\n <div className={cn('relative h-full w-full', classNames)}>\n <LiveError message={module.error} title={messages.errors.compile} />\n </div>\n <LiveError.Runtime open={isError} />\n </>\n );\n }\n\n const Component = module?.exports?.default;\n\n if (!Component) {\n return null;\n }\n\n return (\n <>\n {frame ? (\n <div className={cn('h-full w-full', classNames)}>\n <Frame {...(frame as FrameProps)}>\n {container => (\n <div ref={contentRef} style={{ display: 'contents' }}>\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={(e: Error) => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} container={container} />\n {dynamicTailwind && dynamicCSS && (\n <style>{dynamicCSS}</style>\n )}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n </Frame>\n </div>\n ) : (\n <div\n ref={contentRef}\n className={cn(\n 'relative h-full w-full overflow-x-hidden overflow-y-auto',\n classNames,\n )}\n style={{\n isolation: 'isolate',\n transform: 'translateZ(0)',\n containerType: 'inline-size',\n }}\n >\n <LiveError.Boundary\n resetKeys={[effectiveCode]}\n onError={e => setError(e.message)}\n >\n {renderProvider(\n <LiveError.Guard onError={e => setError(e.message)}>\n <Component {...componentProps} />\n {dynamicTailwind && dynamicCSS && <style>{dynamicCSS}</style>}\n </LiveError.Guard>,\n )}\n </LiveError.Boundary>\n </div>\n )}\n <LiveError.Runtime open={isError} />\n </>\n );\n};\n\nexport default Client;\n","import type React from 'react';\n\nimport type { FrameProps } from '../frame';\nimport Client from './client';\nimport { NO_MODULES, NO_PROPS } from './defaults';\n\nexport interface Props extends React.ComponentPropsWithRef<'div'> {\n code?: string;\n showError?: boolean;\n props?: Record<string, unknown>;\n container?: HTMLElement | null;\n frame?: boolean | FrameProps;\n modules?: Record<string, unknown>;\n dynamicTailwind?: boolean;\n provider?: (children: React.ReactNode) => React.ReactNode;\n}\n\n// `Live.Preview`: a thin wrapper around `Client`, which compiles, handles\n// errors and wraps the frame. One render path for both `code` and the\n// provider's code (#187).\nconst Preview = ({\n code,\n props = NO_PROPS,\n modules = NO_MODULES,\n dynamicTailwind = false,\n provider,\n ...restProps\n}: Props) => {\n return (\n <Client\n code={code}\n props={props}\n modules={modules}\n dynamicTailwind={dynamicTailwind}\n provider={provider}\n {...restProps}\n />\n );\n};\n\nexport default Preview;\n"],"mappings":";;;;;;;;AAGA,MAAa,WAAoC,CAAC;AAClD,MAAa,aAAsC,CAAC;;;ACWpD,MAAM,UAAU,EACd,MAAM,OACN,WACA,WACA,QAAQ,UACR,UAAU,YACV,OACA,kBAAkB,OAClB,eACW;CACX,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,EAAE,OAAO,aAAa,SAAS;CACrC,MAAM,WAAW,gBAAgB;CACjC,MAAM,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC;CAEjC,MAAM,aAAa,GAAG,WAAW,UAAU,SAAS;CAEpD,MAAM,gBAAgB,U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AAW;GACX,eAAe;EACjB;EAEA,UAAA,oBAACA,MAAU,UAAX;GACE,WAAW,CAAC,aAAa;GACzB,UAAS,MAAK,SAAS,EAAE,OAAO;GAE/B,UAAA,eACC,qBAACA,MAAU,OAAX;IAAiB,UAAS,MAAK,SAAS,EAAE,OAAO;IAAjD,UAAA,CACE,oBAAC,WAAD,EAAW,GAAI,eAAiB,CAAA,GAC/B,mBAAmB,cAAc,oBAAC,SAAD,EAAA,UAAQ,WAAkB,CAAA,CAC7C;GACnB,CAAA,CAAA;EACkB,CAAA;CACjB,CAAA,GAEP,oBAACA,MAAU,SAAX,EAAmB,MAAM,QAAU,CAAA,CACnC,EAAA,CAAA;AAEN;;;ACxGA,MAAM,WAAW,EACf,MACA,QAAQ,UACR,UAAU,YACV,kBAAkB,OAClB,UACA,GAAG,gBACQ;CACX,OACE,oBAAC,QAAD;EACQ;EACC;EACE;EACQ;EACP;EACV,GAAI;CACL,CAAA;AAEL"}
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as useLiveMessages, n as LiveMessagesInput, r as defaultMessages, t as LiveMessages } from "../messages-
|
|
2
|
-
import { n as Props, t as ContextProvider } from "../index-
|
|
1
|
+
import { i as useLiveMessages, n as LiveMessagesInput, r as defaultMessages, t as LiveMessages } from "../messages-IBPs4TkZ.js";
|
|
2
|
+
import { n as Props, t as ContextProvider } from "../index-DrWtSKXu.js";
|
|
3
3
|
export { type LiveMessages, type LiveMessagesInput, type Props, ContextProvider as default, defaultMessages, useLiveMessages };
|
package/dist/provider/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as useLiveMessages, n as defaultMessages } from "../messages-
|
|
2
|
-
import { t as ContextProvider } from "../context-
|
|
1
|
+
import { i as useLiveMessages, n as defaultMessages } from "../messages-CSrMI4Rm.js";
|
|
2
|
+
import { t as ContextProvider } from "../context-B8MzP7_p.js";
|
|
3
3
|
export { ContextProvider as default, defaultMessages, useLiveMessages };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as generateSectionPreview, c as inspectDocument, l as parseDocument, o as generateSectionPreviews, s as getSections, u as replaceDocumentSections } from "./document-
|
|
2
|
-
import { i as DEFAULT_CONTAINER_ID, u as documentTemplate } from "./constants-
|
|
1
|
+
import { a as generateSectionPreview, c as inspectDocument, l as parseDocument, o as generateSectionPreviews, s as getSections, u as replaceDocumentSections } from "./document-CHO215iP.js";
|
|
2
|
+
import { i as DEFAULT_CONTAINER_ID, u as documentTemplate } from "./constants-DU17Tdwo.js";
|
|
3
3
|
//#region src/utils/sections.ts
|
|
4
4
|
const extractSections = (code, options) => {
|
|
5
5
|
const doc = parseDocument(code, options);
|
|
@@ -26,4 +26,4 @@ const checkDocument = (code, options) => {
|
|
|
26
26
|
//#endregion
|
|
27
27
|
export { generateSections as a, generateSection as i, createDocument as n, replaceSections as o, extractSections as r, checkDocument as t };
|
|
28
28
|
|
|
29
|
-
//# sourceMappingURL=sections-
|
|
29
|
+
//# sourceMappingURL=sections-jYuqS4KB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections-jYuqS4KB.js","names":[],"sources":["../src/utils/sections.ts"],"sourcesContent":["import { DEFAULT_CONTAINER_ID, documentTemplate } from '~/constants';\nimport type { Section } from '~/types';\n\nimport {\n type DocumentOptions,\n type DocumentProblem,\n type SectionOptions,\n createSectionPreviewCache,\n generateSectionPreview,\n generateSectionPreviews,\n getSections,\n inspectDocument,\n parseDocument,\n replaceDocumentSections,\n} from './ast/document';\n\nexport const extractSections = (\n code: string,\n options?: SectionOptions,\n): Section[] => {\n const doc = parseDocument(code, options);\n\n return doc ? getSections(doc, options) : [];\n};\n\nexport const replaceSections = (\n code: string,\n sections: string[],\n options?: DocumentOptions,\n): string => {\n return replaceDocumentSections(code, sections, options);\n};\n\nexport const generateSection = (\n code: string,\n fullCode: string,\n options?: DocumentOptions,\n) => {\n return generateSectionPreview(fullCode, code, options);\n};\n\n// `generateSection()` for every section, from one parse of `fullCode`. An\n// unchanged section gets the same string as before, so `React.memo` can skip\n// it.\nexport const generateSections = (\n codes: string[],\n fullCode: string,\n options?: DocumentOptions,\n): string[] => {\n return generateSectionPreviews(fullCode, codes, options);\n};\n\n// A new, empty document `Live.Dnd` can add sections to: an `App` component\n// rendering the container element and nothing else. Start a controlled\n// `Live.Dnd` from this rather than an empty string, which has no container,\n// so nothing dropped on the canvas would land anywhere (#449). Pass the same\n// `containerId` you give `Live.Dnd`.\nexport const createDocument = ({\n containerId = DEFAULT_CONTAINER_ID,\n}: DocumentOptions = {}): string => {\n // The id is written into a JSX attribute as-is, so anything that could end\n // the attribute or the tag is refused rather than producing broken source.\n if (!/^[^\\s\"'<>{}]+$/.test(containerId)) {\n throw new Error(\n `createDocument: containerId must be a plain element id, got ${JSON.stringify(containerId)}`,\n );\n }\n\n return documentTemplate(containerId);\n};\n\n// Whether `Live.Dnd` can edit a document: it parses, and it has the\n// container. A host can check one before saving or loading it, and gets the\n// same reasons `Live.Dnd` reports through `onEditError` (#522).\nexport type DocumentCheck = { ok: true } | ({ ok: false } & DocumentProblem);\n\nexport const checkDocument = (\n code: string,\n options?: DocumentOptions,\n): DocumentCheck => {\n const inspection = inspectDocument(code, options);\n\n if (inspection.ok) {\n return { ok: true };\n }\n\n // A copy: the inspection is cached and shared with `Live.Dnd`.\n return { ...inspection };\n};\n\n// `generateSections()` that reuses unchanged previews between calls (#131).\n// Keep one instance per editor, as `Live.Dnd` does.\nexport { createSectionPreviewCache };\nexport type {\n DocumentOptions,\n DocumentProblem,\n SectionOptions,\n SectionPreviewCache,\n} from './ast/document';\n"],"mappings":";;;AAgBA,MAAa,mBACX,MACA,YACc;CACd,MAAM,MAAM,cAAc,MAAM,OAAO;CAEvC,OAAO,MAAM,YAAY,KAAK,OAAO,IAAI,CAAC;AAC5C;AAEA,MAAa,mBACX,MACA,UACA,YACW;CACX,OAAO,wBAAwB,MAAM,UAAU,OAAO;AACxD;AAEA,MAAa,mBACX,MACA,UACA,YACG;CACH,OAAO,uBAAuB,UAAU,MAAM,OAAO;AACvD;AAKA,MAAa,oBACX,OACA,UACA,YACa;CACb,OAAO,wBAAwB,UAAU,OAAO,OAAO;AACzD;AAOA,MAAa,kBAAkB,EAC7B,cAAc,yBACK,CAAC,MAAc;CAGlC,IAAI,CAAC,iBAAiB,KAAK,WAAW,GACpC,MAAM,IAAI,MACR,+DAA+D,KAAK,UAAU,WAAW,GAC3F;CAGF,OAAO,iBAAiB,WAAW;AACrC;AAOA,MAAa,iBACX,MACA,YACkB;CAClB,MAAM,aAAa,gBAAgB,MAAM,OAAO;CAEhD,IAAI,WAAW,IACb,OAAO,EAAE,IAAI,KAAK;CAIpB,OAAO,EAAE,GAAG,WAAW;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"states-Ci1AvoQ9.js","names":[],"sources":["../src/components/context/states.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\nimport type { Dispatch, SetStateAction } from 'react';\n\nexport interface PreviewContextType {\n code: string;\n setCode: Dispatch<SetStateAction<string>>;\n}\n\nexport interface ErrorContextType {\n error: string | null;\n setError: Dispatch<SetStateAction<string | null>>;\n}\n\n// `undefined`
|
|
1
|
+
{"version":3,"file":"states-Ci1AvoQ9.js","names":[],"sources":["../src/components/context/states.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\nimport type { Dispatch, SetStateAction } from 'react';\n\nexport interface PreviewContextType {\n code: string;\n setCode: Dispatch<SetStateAction<string>>;\n}\n\nexport interface ErrorContextType {\n error: string | null;\n setError: Dispatch<SetStateAction<string | null>>;\n}\n\n// `undefined` outside a provider, so `usePreview` and `useError` can throw\n// there instead of silently doing nothing.\nexport const PreviewContext = createContext<PreviewContextType | undefined>(\n undefined,\n);\n\nexport const ErrorContext = createContext<ErrorContextType | undefined>(\n undefined,\n);\n\nexport const usePreview = () => {\n const context = useContext(PreviewContext);\n\n if (context === undefined) {\n throw new Error('usePreview must be used within <Live> (ContextProvider)');\n }\n\n return context;\n};\n\nexport const useError = () => {\n const context = useContext(ErrorContext);\n\n if (context === undefined) {\n throw new Error('useError must be used within <Live> (ContextProvider)');\n }\n\n return context;\n};\n"],"mappings":";;AAiBA,MAAa,iBAAiB,cAC5B,KAAA,CACF;AAEA,MAAa,eAAe,cAC1B,KAAA,CACF;AAEA,MAAa,mBAAmB;CAC9B,MAAM,UAAU,WAAW,cAAc;CAEzC,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,yDAAyD;CAG3E,OAAO;AACT;AAEA,MAAa,iBAAiB;CAC5B,MAAM,UAAU,WAAW,YAAY;CAEvC,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,uDAAuD;CAGzE,OAAO;AACT"}
|