@jbpark/live-editor 4.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["t","parseExpression","_appendArrayItem","_duplicateArrayItems","_moveArrayItem","_moveArrayItems","_parseItems","_removeArrayItems","_updateArrayItemProperty","_updateArrayItemValue","_parseArrayExpression","_arrayExpressionToCode","_canStructurallyEditArray","_extractNodeValue","_extractObjectProperties","_createNodeFromValue","_canLosslesslyEvaluateSource","_getCurrentValue","_getStructuredValue","_parseBinding","_parseBindingExpression","_readNodeBindings","_resolveBindings","_getKeyBindings","_getRegistryBindings","_isComponentTagName","_fillIds","_replaceIds","_clone","_generateCode","_clearExtractCache"],"sources":["../../../src/utils/ast/editable-value.ts","../../../src/utils/ast/index.ts"],"sourcesContent":["import { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport { parseValue, unwrapExpression } from './value';\n\n// The editable leaves of an object or array value: listing them with their\n// paths, and replacing one while keeping the rest of the source as written.\n\nexport type EditablePathSegment = string | number;\n\nexport type EditablePrimitive = string | number | boolean;\n\nexport interface EditableValueEntry {\n path: EditablePathSegment[];\n value: EditablePrimitive;\n}\n\nconst MAX_FLATTEN_DEPTH = 20;\n\nconst isEditablePrimitive = (value: unknown): value is EditablePrimitive =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean';\n\n// Lists the editable leaves of an object or array value, with their paths.\n// It follows the value's own shape, so it works without a `render` map\n// (#225), as for `style` or an `items` array of `{ key, children }`. Strings,\n// numbers and booleans are leaves, whatever a string contains. Deeply nested\n// values stop at a fixed depth, and anything deeper is left out.\nexport const flattenEditableValue = (\n value: string,\n): EditableValueEntry[] | null => {\n const parsed = parseValue(value);\n\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n Object.keys(parsed).length === 0\n ) {\n return null;\n }\n\n const entries: EditableValueEntry[] = [];\n\n const walk = (node: unknown, path: EditablePathSegment[], depth: number) => {\n if (depth > MAX_FLATTEN_DEPTH) {\n return;\n }\n\n if (isEditablePrimitive(node)) {\n entries.push({ path, value: node });\n return;\n }\n\n if (Array.isArray(node)) {\n node.forEach((item, index) => walk(item, [...path, index], depth + 1));\n return;\n }\n\n if (typeof node === 'object' && node !== null) {\n Object.entries(node).forEach(([key, item]) =>\n walk(item, [...path, key], depth + 1),\n );\n }\n\n // `null`, `undefined`, functions and symbols have no editable form and\n // are left out.\n };\n\n walk(parsed, [], 0);\n\n return entries.length ? entries : null;\n};\n\n// Finds the node `flattenEditableValue` reported at `path`, walking the\n// same literal structure `evaluateLiteral` reads. Returns null for anything\n// it can't point at with certainty: a missing key or index, a step through\n// something that isn't an object or array, or a spread that could replace\n// the entry at runtime.\nconst findEditableLeaf = (\n root: t.Node,\n path: EditablePathSegment[],\n): t.Node | null => {\n let node = unwrapExpression(root);\n\n for (const segment of path) {\n if (t.isArrayExpression(node)) {\n if (typeof segment !== 'number') {\n return null;\n }\n\n const elements = node.elements.slice(0, segment + 1);\n const element = node.elements[segment];\n\n if (!element || elements.some(item => t.isSpreadElement(item))) {\n return null;\n }\n\n node = unwrapExpression(element);\n continue;\n }\n\n if (t.isObjectExpression(node)) {\n const key = String(segment);\n const matches = (property: t.ObjectExpression['properties'][number]) =>\n t.isObjectProperty(property) &&\n !property.computed &&\n ((t.isIdentifier(property.key) && property.key.name === key) ||\n (t.isStringLiteral(property.key) && property.key.value === key) ||\n (t.isNumericLiteral(property.key) &&\n String(property.key.value) === key));\n // The last match is the one a duplicate key leaves in effect, and the\n // one `evaluateLiteral` reports.\n let index = node.properties.length - 1;\n\n while (index >= 0 && !matches(node.properties[index]!)) {\n index--;\n }\n\n const property = node.properties[index];\n\n if (\n !property ||\n !t.isObjectProperty(property) ||\n node.properties.slice(index + 1).some(item => t.isSpreadElement(item))\n ) {\n return null;\n }\n\n node = unwrapExpression(property.value);\n continue;\n }\n\n return null;\n }\n\n return node;\n};\n\nconst isEditableLeaf = (node: t.Node): boolean =>\n t.isStringLiteral(node) ||\n t.isNumericLiteral(node) ||\n t.isBooleanLiteral(node) ||\n (t.isUnaryExpression(node) &&\n node.operator === '-' &&\n t.isNumericLiteral(node.argument)) ||\n (t.isTemplateLiteral(node) && node.expressions.length === 0) ||\n t.isJSXElement(node) ||\n t.isJSXFragment(node);\n\nconst quoteString = (text: string, quote: string): string => {\n if (quote === '`') {\n return `\\`${text.replace(/[\\\\`]|\\$\\{/g, match => `\\\\${match}`)}\\``;\n }\n\n const escaped = JSON.stringify(text).slice(1, -1);\n\n return quote === '\"'\n ? `\"${escaped}\"`\n : `'${escaped.replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\")}'`;\n};\n\nconst isJSXSource = (text: string): boolean => {\n try {\n const expression = parseExpression(text, { plugins: ['jsx'] });\n\n return t.isJSXElement(expression) || t.isJSXFragment(expression);\n } catch {\n return false;\n }\n};\n\n// Source text for `next` in place of `leaf`, keeping the leaf's own form\n// where it has one: a string keeps its quotes, and a JSX leaf, which\n// `flattenEditableValue` reports as its source text, stays JSX when the\n// edited text still is.\nconst leafSource = (\n value: string,\n leaf: t.Node,\n next: EditablePrimitive,\n): string => {\n if (typeof next !== 'string') {\n return String(next);\n }\n\n if ((t.isJSXElement(leaf) || t.isJSXFragment(leaf)) && isJSXSource(next)) {\n return next.trim();\n }\n\n const quote =\n t.isStringLiteral(leaf) || t.isTemplateLiteral(leaf)\n ? value[leaf.start!]!\n : \"'\";\n\n return quoteString(next, quote);\n};\n\n// Replaces the leaf at `path` (as `flattenEditableValue` reports it) and\n// returns `value` with only that leaf's source changed, so formatting,\n// comments, JSX, functions and references stay (#427). The result is a\n// string for `PanelBinding.onChange`. A path it can't find, or a `value`\n// that doesn't parse, returns `value` unchanged. It never adds a key or\n// grows an array.\nexport const setEditableValue = (\n value: string,\n path: EditablePathSegment[],\n next: EditablePrimitive,\n): string => {\n if (!path.length) {\n return value;\n }\n\n let leaf: t.Node | null;\n\n try {\n leaf = findEditableLeaf(\n parseExpression(value, { plugins: ['jsx', 'typescript'] }),\n path,\n );\n } catch {\n return value;\n }\n\n if (\n !leaf ||\n !isEditableLeaf(leaf) ||\n leaf.start == null ||\n leaf.end == null\n ) {\n return value;\n }\n\n return `${value.slice(0, leaf.start)}${leafSource(value, leaf, next)}${value.slice(leaf.end)}`;\n};\n","// The public `./utils/ast` entry: reading a section's bindings (`extract`),\n// committing edits (`update`, `updateAll`), validating and flattening\n// values, and the types those take and return. Library code imports from\n// the module files, not from here, so the deprecated names below can leave\n// this barrel without touching their callers (#522).\nimport { canStructurallyEditArray as _canStructurallyEditArray } from './array-source';\nimport { getCurrentValue as _getCurrentValue } from './binding';\nimport { getStructuredValue as _getStructuredValue } from './binding';\nimport { parseBinding as _parseBinding } from './binding';\nimport { parseBindingExpression as _parseBindingExpression } from './binding';\nimport { readNodeBindings as _readNodeBindings } from './binding';\nimport { resolveBindings as _resolveBindings } from './binding';\nimport { getKeyBindings as _getKeyBindings } from './binding';\nimport { getRegistryBindings as _getRegistryBindings } from './binding';\nimport { isComponentTagName as _isComponentTagName } from './binding';\nimport { clearExtractCache as _clearExtractCache } from './extract';\nimport { generateCode as _generateCode } from './helpers';\nimport { appendArrayItem as _appendArrayItem } from './items';\nimport { duplicateArrayItems as _duplicateArrayItems } from './items';\nimport { moveArrayItem as _moveArrayItem } from './items';\nimport { moveArrayItems as _moveArrayItems } from './items';\nimport { parseItems as _parseItems } from './items';\nimport { removeArrayItems as _removeArrayItems } from './items';\nimport { updateArrayItemProperty as _updateArrayItemProperty } from './items';\nimport { updateArrayItemValue as _updateArrayItemValue } from './items';\nimport type { ArrayItem as _ArrayItem } from './items';\nimport type { ItemKind as _ItemKind } from './items';\nimport { fillIds as _fillIds } from './tree';\nimport { replaceIds as _replaceIds } from './tree';\nimport { clone as _clone } from './tree';\nimport type { ExtractedNodeValue as _ExtractedNodeValue } from './types';\nimport type { NodeValueType as _NodeValueType } from './types';\nimport type { EditableNodeValueType as _EditableNodeValueType } from './types';\nimport { parseArrayExpression as _parseArrayExpression } from './value';\nimport { extractNodeValue as _extractNodeValue } from './value';\nimport { extractObjectProperties as _extractObjectProperties } from './value';\nimport { canLosslesslyEvaluateSource as _canLosslesslyEvaluateSource } from './value';\nimport { arrayExpressionToCode as _arrayExpressionToCode } from './value-expression';\nimport { createNodeFromValue as _createNodeFromValue } from './value-expression';\n\nexport type {\n BindingFieldSpec,\n BindingItem,\n BindingOption,\n BindingRenderLeaf,\n BindingComponentName,\n BindingKeyMap,\n BindingOptions,\n BindingRegistry,\n BindingRenderMap,\n BindingSchema,\n BindingType,\n BindingWidget,\n DataAttrNode,\n} from './types';\nexport { findEditableChildren } from './binding';\nexport type {\n EditablePathSegment,\n EditablePrimitive,\n EditableValueEntry,\n} from './editable-value';\nexport { parseValue } from './value';\nexport { flattenEditableValue, setEditableValue } from './editable-value';\nexport { extract } from './extract';\nexport type {\n DocumentOptions,\n DocumentProblem,\n SectionOptions,\n} from './document';\nexport { bulkUpdate, update, updateAll } from './update';\nexport type {\n UpdateAllResult,\n UpdateEntry,\n UpdateFailure,\n UpdateResult,\n} from './update';\nexport { getChildrenSignatures } from './children';\nexport type { ChildrenAction, ChildrenEdit } from './children';\nexport type {\n ValidationMessages,\n ValidationOptions,\n ValidationResult,\n} from './validate';\nexport { defaultValidationMessages, validateBindingValue } from './validate';\n\n// Internal helpers, deprecated. Each still works, and leaves this entry in\n// the next major (#522). Most are `const` aliases, so their\n// `@deprecated` reaches the built declarations. The document layer stays a\n// plain re-export: as an alias here, its Babel AST types move this entry's\n// declarations into the chunk that also pulls in React, and\n// `check-package-types.mjs` fails. A re-export's JSDoc doesn't survive the\n// declaration bundle, so those are announced in the docs and changeset only.\n\n// Array-literal editing: the engine behind `useDndItems`.\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const appendArrayItem = _appendArrayItem;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const duplicateArrayItems = _duplicateArrayItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const moveArrayItem = _moveArrayItem;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const moveArrayItems = _moveArrayItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const parseItems = _parseItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const removeArrayItems = _removeArrayItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const updateArrayItemProperty = _updateArrayItemProperty;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const updateArrayItemValue = _updateArrayItemValue;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const parseArrayExpression = _parseArrayExpression;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const arrayExpressionToCode = _arrayExpressionToCode;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const canStructurallyEditArray = _canStructurallyEditArray;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport type ArrayItem = _ArrayItem;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport type ItemKind = _ItemKind;\n\n// Value plumbing behind `extract`, `update` and `PanelBinding.value`.\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const extractNodeValue = _extractNodeValue;\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const extractObjectProperties = _extractObjectProperties;\n/** @deprecated Internal. Write values through `update` or `PanelBinding.onChange`. Removed in the next major. */\nexport const createNodeFromValue = _createNodeFromValue;\n/** @deprecated Internal. Check `PanelBinding.canEditValue` instead. Removed in the next major. */\nexport const canLosslesslyEvaluateSource = _canLosslesslyEvaluateSource;\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const getCurrentValue = _getCurrentValue;\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const getStructuredValue = _getStructuredValue;\n/** @deprecated Internal. Removed in the next major. */\nexport type ExtractedNodeValue = _ExtractedNodeValue;\n/** @deprecated Internal. Removed in the next major. */\nexport type NodeValueType = _NodeValueType;\n/** @deprecated Internal. Removed in the next major. */\nexport type EditableNodeValueType = _EditableNodeValueType;\n\n// Binding resolution behind `extract(source, { bindings, bindingKeys })`.\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const parseBinding = _parseBinding;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const parseBindingExpression = _parseBindingExpression;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const readNodeBindings = _readNodeBindings;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const resolveBindings = _resolveBindings;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const getKeyBindings = _getKeyBindings;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const getRegistryBindings = _getRegistryBindings;\n/** @deprecated Internal. Removed in the next major. */\nexport const isComponentTagName = _isComponentTagName;\n\n// The document layer under `./utils` and `Live.Dnd`.\nexport {\n /** @deprecated Internal. Use `extractSections` from `./utils`. Removed in the next major. */\n parseDocument,\n /** @deprecated Internal. Use `extractSections` from `./utils`. Removed in the next major. */\n getSections,\n /** @deprecated Internal. Use `replaceSections` from `./utils`. Removed in the next major. */\n replaceDocumentSections,\n /** @deprecated Internal. Use `checkDocument` from `./utils`. Removed in the next major. */\n inspectDocument,\n /** @deprecated Internal. Removed in the next major. */\n generateDocumentCode,\n /** @deprecated Internal. Removed in the next major. */\n fillSectionIds,\n /** @deprecated Internal. Removed in the next major. */\n generateSectionPreview,\n /** @deprecated Internal. Removed in the next major. */\n generateSectionPreviews,\n /** @deprecated Internal. Removed in the next major. */\n createSectionPreviewCache,\n} from './document';\nexport type {\n /** @deprecated Internal. Use `checkDocument` from `./utils`. Removed in the next major. */\n DocumentInspection,\n /** @deprecated Internal. Removed in the next major. */\n DocumentTree,\n /** @deprecated Internal. Removed in the next major. */\n SectionPreviewCache,\n} from './document';\n\n// Ids, code generation and caches.\n/** @deprecated Internal. Removed in the next major. */\nexport const fillIds = _fillIds;\n/** @deprecated Internal. Removed in the next major. */\nexport const replaceIds = _replaceIds;\n/** @deprecated Internal. Removed in the next major. */\nexport const clone = _clone;\n/** @deprecated Internal. Removed in the next major. */\nexport const generateCode = _generateCode;\n/** @deprecated Internal. Use `clearEditorCaches` from `./utils`. Removed in the next major. */\nexport const clearExtractCache = _clearExtractCache;\nexport {\n /** @deprecated Internal. Use `clearEditorCaches` from `./utils`. Removed in the next major. */\n clearDocumentParseCache,\n} from './document';\n"],"mappings":";;;;;;AAiBA,MAAM,oBAAoB;AAE1B,MAAM,uBAAuB,UAC3B,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAOnB,MAAa,wBACX,UACgC;CAChC,MAAM,SAAS,WAAW,KAAK;CAE/B,IACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GAE/B,OAAO;CAGT,MAAM,UAAgC,CAAC;CAEvC,MAAM,QAAQ,MAAe,MAA6B,UAAkB;EAC1E,IAAI,QAAQ,mBACV;EAGF,IAAI,oBAAoB,IAAI,GAAG;GAC7B,QAAQ,KAAK;IAAE;IAAM,OAAO;GAAK,CAAC;GAClC;EACF;EAEA,IAAI,MAAM,QAAQ,IAAI,GAAG;GACvB,KAAK,SAAS,MAAM,UAAU,KAAK,MAAM,CAAC,GAAG,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC;GACrE;EACF;EAEA,IAAI,OAAO,SAAS,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,IAAI;CAEJ,IAAI;EACF,OAAO,kBAAA,GACLC,WAAAA,gBAAAA,CAAgB,OAAO,EAAE,SAAS,CAAC,OAAO,YAAY,EAAE,CAAC,GACzD,IACF;CACF,QAAQ;EACN,OAAO;CACT;CAEA,IACE,CAAC,QACD,CAAC,eAAe,IAAI,KACpB,KAAK,SAAS,QACd,KAAK,OAAO,MAEZ,OAAO;CAGT,OAAO,GAAG,MAAM,MAAM,GAAG,KAAK,KAAK,IAAI,WAAW,OAAO,MAAM,IAAI,IAAI,MAAM,MAAM,KAAK,GAAG;AAC7F;;;;AC1IA,MAAa,kBAAkBC;;AAE/B,MAAa,sBAAsBC;;AAEnC,MAAa,gBAAgBC;;AAE7B,MAAa,iBAAiBC;;AAE9B,MAAa,aAAaC;;AAE1B,MAAa,mBAAmBC;;AAEhC,MAAa,0BAA0BC;;AAEvC,MAAa,uBAAuBC;;AAEpC,MAAa,uBAAuBC;;AAEpC,MAAa,wBAAwBC;;AAErC,MAAa,2BAA2BC;;AAQxC,MAAa,mBAAmBC;;AAEhC,MAAa,0BAA0BC;;AAEvC,MAAa,sBAAsBC;;AAEnC,MAAa,8BAA8BC;;AAE3C,MAAa,kBAAkBC;;AAE/B,MAAa,qBAAqBC;;AAUlC,MAAa,eAAeC;;AAE5B,MAAa,yBAAyBC;;AAEtC,MAAa,mBAAmBC;;AAEhC,MAAa,kBAAkBC;;AAE/B,MAAa,iBAAiBC;;AAE9B,MAAa,sBAAsBC;;AAEnC,MAAa,qBAAqBC;;AAkClC,MAAa,UAAUC;;AAEvB,MAAa,aAAaC;;AAE1B,MAAa,QAAQC;;AAErB,MAAa,eAAeC;;AAE5B,MAAa,oBAAoBC"}
1
+ {"version":3,"file":"index.js","names":["t.isArrayExpression","t.isSpreadElement","t.isObjectExpression","t.isObjectProperty","t.isIdentifier","t.isStringLiteral","t.isNumericLiteral","t.isBooleanLiteral","t.isUnaryExpression","t.isTemplateLiteral","t.isJSXElement","t.isJSXFragment","_appendArrayItem","_duplicateArrayItems","_moveArrayItem","_moveArrayItems","_parseItems","_removeArrayItems","_updateArrayItemProperty","_updateArrayItemValue","_parseArrayExpression","_arrayExpressionToCode","_canStructurallyEditArray","_extractNodeValue","_extractObjectProperties","_createNodeFromValue","_canLosslesslyEvaluateSource","_getCurrentValue","_getStructuredValue","_parseBinding","_parseBindingExpression","_readNodeBindings","_resolveBindings","_getKeyBindings","_getRegistryBindings","_isComponentTagName","_fillIds","_replaceIds","_clone","_generateCode","_clearExtractCache"],"sources":["../../../src/utils/ast/editable-value.ts","../../../src/utils/ast/index.ts"],"sourcesContent":["import { parseExpression } from '@babel/parser';\nimport * as t from '@babel/types';\n\nimport { parseValue, unwrapExpression } from './value';\n\n// The editable leaves of an object or array value: listing them with their\n// paths, and replacing one while keeping the rest of the source as written.\n\nexport type EditablePathSegment = string | number;\n\nexport type EditablePrimitive = string | number | boolean;\n\nexport interface EditableValueEntry {\n path: EditablePathSegment[];\n value: EditablePrimitive;\n}\n\nconst MAX_FLATTEN_DEPTH = 20;\n\nconst isEditablePrimitive = (value: unknown): value is EditablePrimitive =>\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean';\n\n// Lists the editable leaves of an object or array value, with their paths.\n// It follows the value's own shape, so it works without a `render` map\n// (#225), as for `style` or an `items` array of `{ key, children }`. Strings,\n// numbers and booleans are leaves, whatever a string contains. Deeply nested\n// values stop at a fixed depth, and anything deeper is left out.\nexport const flattenEditableValue = (\n value: string,\n): EditableValueEntry[] | null => {\n const parsed = parseValue(value);\n\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n Object.keys(parsed).length === 0\n ) {\n return null;\n }\n\n const entries: EditableValueEntry[] = [];\n\n const walk = (node: unknown, path: EditablePathSegment[], depth: number) => {\n if (depth > MAX_FLATTEN_DEPTH) {\n return;\n }\n\n if (isEditablePrimitive(node)) {\n entries.push({ path, value: node });\n return;\n }\n\n if (Array.isArray(node)) {\n node.forEach((item, index) => walk(item, [...path, index], depth + 1));\n return;\n }\n\n if (typeof node === 'object' && node !== null) {\n Object.entries(node).forEach(([key, item]) =>\n walk(item, [...path, key], depth + 1),\n );\n }\n\n // `null`, `undefined`, functions and symbols have no editable form and\n // are left out.\n };\n\n walk(parsed, [], 0);\n\n return entries.length ? entries : null;\n};\n\n// Finds the node `flattenEditableValue` reported at `path`, walking the\n// same literal structure `evaluateLiteral` reads. Returns null for anything\n// it can't point at with certainty: a missing key or index, a step through\n// something that isn't an object or array, or a spread that could replace\n// the entry at runtime.\nconst findEditableLeaf = (\n root: t.Node,\n path: EditablePathSegment[],\n): t.Node | null => {\n let node = unwrapExpression(root);\n\n for (const segment of path) {\n if (t.isArrayExpression(node)) {\n if (typeof segment !== 'number') {\n return null;\n }\n\n const elements = node.elements.slice(0, segment + 1);\n const element = node.elements[segment];\n\n if (!element || elements.some(item => t.isSpreadElement(item))) {\n return null;\n }\n\n node = unwrapExpression(element);\n continue;\n }\n\n if (t.isObjectExpression(node)) {\n const key = String(segment);\n const matches = (property: t.ObjectExpression['properties'][number]) =>\n t.isObjectProperty(property) &&\n !property.computed &&\n ((t.isIdentifier(property.key) && property.key.name === key) ||\n (t.isStringLiteral(property.key) && property.key.value === key) ||\n (t.isNumericLiteral(property.key) &&\n String(property.key.value) === key));\n // The last match is the one a duplicate key leaves in effect, and the\n // one `evaluateLiteral` reports.\n let index = node.properties.length - 1;\n\n while (index >= 0 && !matches(node.properties[index]!)) {\n index--;\n }\n\n const property = node.properties[index];\n\n if (\n !property ||\n !t.isObjectProperty(property) ||\n node.properties.slice(index + 1).some(item => t.isSpreadElement(item))\n ) {\n return null;\n }\n\n node = unwrapExpression(property.value);\n continue;\n }\n\n return null;\n }\n\n return node;\n};\n\nconst isEditableLeaf = (node: t.Node): boolean =>\n t.isStringLiteral(node) ||\n t.isNumericLiteral(node) ||\n t.isBooleanLiteral(node) ||\n (t.isUnaryExpression(node) &&\n node.operator === '-' &&\n t.isNumericLiteral(node.argument)) ||\n (t.isTemplateLiteral(node) && node.expressions.length === 0) ||\n t.isJSXElement(node) ||\n t.isJSXFragment(node);\n\nconst quoteString = (text: string, quote: string): string => {\n if (quote === '`') {\n return `\\`${text.replace(/[\\\\`]|\\$\\{/g, match => `\\\\${match}`)}\\``;\n }\n\n const escaped = JSON.stringify(text).slice(1, -1);\n\n return quote === '\"'\n ? `\"${escaped}\"`\n : `'${escaped.replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\")}'`;\n};\n\nconst isJSXSource = (text: string): boolean => {\n try {\n const expression = parseExpression(text, { plugins: ['jsx'] });\n\n return t.isJSXElement(expression) || t.isJSXFragment(expression);\n } catch {\n return false;\n }\n};\n\n// Source text for `next` in place of `leaf`, keeping the leaf's own form\n// where it has one: a string keeps its quotes, and a JSX leaf, which\n// `flattenEditableValue` reports as its source text, stays JSX when the\n// edited text still is.\nconst leafSource = (\n value: string,\n leaf: t.Node,\n next: EditablePrimitive,\n): string => {\n if (typeof next !== 'string') {\n return String(next);\n }\n\n if ((t.isJSXElement(leaf) || t.isJSXFragment(leaf)) && isJSXSource(next)) {\n return next.trim();\n }\n\n const quote =\n t.isStringLiteral(leaf) || t.isTemplateLiteral(leaf)\n ? value[leaf.start!]!\n : \"'\";\n\n return quoteString(next, quote);\n};\n\n// Replaces the leaf at `path` (as `flattenEditableValue` reports it) and\n// returns `value` with only that leaf's source changed, so formatting,\n// comments, JSX, functions and references stay (#427). The result is a\n// string for `PanelBinding.onChange`. A path it can't find, or a `value`\n// that doesn't parse, returns `value` unchanged. It never adds a key or\n// grows an array.\nexport const setEditableValue = (\n value: string,\n path: EditablePathSegment[],\n next: EditablePrimitive,\n): string => {\n if (!path.length) {\n return value;\n }\n\n let leaf: t.Node | null;\n\n try {\n leaf = findEditableLeaf(\n parseExpression(value, { plugins: ['jsx', 'typescript'] }),\n path,\n );\n } catch {\n return value;\n }\n\n if (\n !leaf ||\n !isEditableLeaf(leaf) ||\n leaf.start == null ||\n leaf.end == null\n ) {\n return value;\n }\n\n return `${value.slice(0, leaf.start)}${leafSource(value, leaf, next)}${value.slice(leaf.end)}`;\n};\n","// The public `./utils/ast` entry: reading a section's bindings (`extract`),\n// committing edits (`update`, `updateAll`), validating and flattening\n// values, and the types those take and return. Library code imports from\n// the module files, not from here, so the deprecated names below can leave\n// this barrel without touching their callers (#522).\nimport { canStructurallyEditArray as _canStructurallyEditArray } from './array-source';\nimport { getCurrentValue as _getCurrentValue } from './binding';\nimport { getStructuredValue as _getStructuredValue } from './binding';\nimport { parseBinding as _parseBinding } from './binding';\nimport { parseBindingExpression as _parseBindingExpression } from './binding';\nimport { readNodeBindings as _readNodeBindings } from './binding';\nimport { resolveBindings as _resolveBindings } from './binding';\nimport { getKeyBindings as _getKeyBindings } from './binding';\nimport { getRegistryBindings as _getRegistryBindings } from './binding';\nimport { isComponentTagName as _isComponentTagName } from './binding';\nimport { clearExtractCache as _clearExtractCache } from './extract';\nimport { generateCode as _generateCode } from './helpers';\nimport { appendArrayItem as _appendArrayItem } from './items';\nimport { duplicateArrayItems as _duplicateArrayItems } from './items';\nimport { moveArrayItem as _moveArrayItem } from './items';\nimport { moveArrayItems as _moveArrayItems } from './items';\nimport { parseItems as _parseItems } from './items';\nimport { removeArrayItems as _removeArrayItems } from './items';\nimport { updateArrayItemProperty as _updateArrayItemProperty } from './items';\nimport { updateArrayItemValue as _updateArrayItemValue } from './items';\nimport type { ArrayItem as _ArrayItem } from './items';\nimport type { ItemKind as _ItemKind } from './items';\nimport { fillIds as _fillIds } from './tree';\nimport { replaceIds as _replaceIds } from './tree';\nimport { clone as _clone } from './tree';\nimport type { ExtractedNodeValue as _ExtractedNodeValue } from './types';\nimport type { NodeValueType as _NodeValueType } from './types';\nimport type { EditableNodeValueType as _EditableNodeValueType } from './types';\nimport { parseArrayExpression as _parseArrayExpression } from './value';\nimport { extractNodeValue as _extractNodeValue } from './value';\nimport { extractObjectProperties as _extractObjectProperties } from './value';\nimport { canLosslesslyEvaluateSource as _canLosslesslyEvaluateSource } from './value';\nimport { arrayExpressionToCode as _arrayExpressionToCode } from './value-expression';\nimport { createNodeFromValue as _createNodeFromValue } from './value-expression';\n\nexport type {\n BindingFieldSpec,\n BindingItem,\n BindingOption,\n BindingRenderLeaf,\n BindingComponentName,\n BindingKeyMap,\n BindingOptions,\n BindingRegistry,\n BindingRenderMap,\n BindingSchema,\n BindingType,\n BindingWidget,\n DataAttrNode,\n} from './types';\nexport { findEditableChildren } from './binding';\nexport type {\n EditablePathSegment,\n EditablePrimitive,\n EditableValueEntry,\n} from './editable-value';\nexport { parseValue } from './value';\nexport { flattenEditableValue, setEditableValue } from './editable-value';\nexport { extract } from './extract';\nexport type {\n DocumentOptions,\n DocumentProblem,\n SectionOptions,\n} from './document';\nexport { bulkUpdate, update, updateAll } from './update';\nexport type {\n UpdateAllResult,\n UpdateEntry,\n UpdateFailure,\n UpdateResult,\n} from './update';\nexport { getChildrenSignatures } from './children';\nexport type { ChildrenAction, ChildrenEdit } from './children';\nexport type {\n ValidationMessages,\n ValidationOptions,\n ValidationResult,\n} from './validate';\nexport { defaultValidationMessages, validateBindingValue } from './validate';\n\n// Internal helpers, deprecated. Each still works, and leaves this entry in\n// the next major (#522). Most are `const` aliases, so their\n// `@deprecated` reaches the built declarations. The document layer stays a\n// plain re-export: as an alias here, its Babel AST types move this entry's\n// declarations into the chunk that also pulls in React, and\n// `check-package-types.mjs` fails. A re-export's JSDoc doesn't survive the\n// declaration bundle, so those are announced in the docs and changeset only.\n\n// Array-literal editing: the engine behind `useDndItems`.\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const appendArrayItem = _appendArrayItem;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const duplicateArrayItems = _duplicateArrayItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const moveArrayItem = _moveArrayItem;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const moveArrayItems = _moveArrayItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const parseItems = _parseItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const removeArrayItems = _removeArrayItems;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const updateArrayItemProperty = _updateArrayItemProperty;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const updateArrayItemValue = _updateArrayItemValue;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const parseArrayExpression = _parseArrayExpression;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const arrayExpressionToCode = _arrayExpressionToCode;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport const canStructurallyEditArray = _canStructurallyEditArray;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport type ArrayItem = _ArrayItem;\n/** @deprecated Internal. Use `useDndItems` from `./dnd`. Removed in the next major. */\nexport type ItemKind = _ItemKind;\n\n// Value plumbing behind `extract`, `update` and `PanelBinding.value`.\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const extractNodeValue = _extractNodeValue;\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const extractObjectProperties = _extractObjectProperties;\n/** @deprecated Internal. Write values through `update` or `PanelBinding.onChange`. Removed in the next major. */\nexport const createNodeFromValue = _createNodeFromValue;\n/** @deprecated Internal. Check `PanelBinding.canEditValue` instead. Removed in the next major. */\nexport const canLosslesslyEvaluateSource = _canLosslesslyEvaluateSource;\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const getCurrentValue = _getCurrentValue;\n/** @deprecated Internal. Read values through `extract` or `PanelBinding.value`. Removed in the next major. */\nexport const getStructuredValue = _getStructuredValue;\n/** @deprecated Internal. Removed in the next major. */\nexport type ExtractedNodeValue = _ExtractedNodeValue;\n/** @deprecated Internal. Removed in the next major. */\nexport type NodeValueType = _NodeValueType;\n/** @deprecated Internal. Removed in the next major. */\nexport type EditableNodeValueType = _EditableNodeValueType;\n\n// Binding resolution behind `extract(source, { bindings, bindingKeys })`.\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const parseBinding = _parseBinding;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const parseBindingExpression = _parseBindingExpression;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const readNodeBindings = _readNodeBindings;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const resolveBindings = _resolveBindings;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const getKeyBindings = _getKeyBindings;\n/** @deprecated Internal. Read bindings through `extract` or `useDndPanel().bindings`. Removed in the next major. */\nexport const getRegistryBindings = _getRegistryBindings;\n/** @deprecated Internal. Removed in the next major. */\nexport const isComponentTagName = _isComponentTagName;\n\n// The document layer under `./utils` and `Live.Dnd`.\nexport {\n /** @deprecated Internal. Use `extractSections` from `./utils`. Removed in the next major. */\n parseDocument,\n /** @deprecated Internal. Use `extractSections` from `./utils`. Removed in the next major. */\n getSections,\n /** @deprecated Internal. Use `replaceSections` from `./utils`. Removed in the next major. */\n replaceDocumentSections,\n /** @deprecated Internal. Use `checkDocument` from `./utils`. Removed in the next major. */\n inspectDocument,\n /** @deprecated Internal. Removed in the next major. */\n generateDocumentCode,\n /** @deprecated Internal. Removed in the next major. */\n fillSectionIds,\n /** @deprecated Internal. Removed in the next major. */\n generateSectionPreview,\n /** @deprecated Internal. Removed in the next major. */\n generateSectionPreviews,\n /** @deprecated Internal. Removed in the next major. */\n createSectionPreviewCache,\n} from './document';\nexport type {\n /** @deprecated Internal. Use `checkDocument` from `./utils`. Removed in the next major. */\n DocumentInspection,\n /** @deprecated Internal. Removed in the next major. */\n DocumentTree,\n /** @deprecated Internal. Removed in the next major. */\n SectionPreviewCache,\n} from './document';\n\n// Ids, code generation and caches.\n/** @deprecated Internal. Removed in the next major. */\nexport const fillIds = _fillIds;\n/** @deprecated Internal. Removed in the next major. */\nexport const replaceIds = _replaceIds;\n/** @deprecated Internal. Removed in the next major. */\nexport const clone = _clone;\n/** @deprecated Internal. Removed in the next major. */\nexport const generateCode = _generateCode;\n/** @deprecated Internal. Use `clearEditorCaches` from `./utils`. Removed in the next major. */\nexport const clearExtractCache = _clearExtractCache;\nexport {\n /** @deprecated Internal. Use `clearEditorCaches` from `./utils`. Removed in the next major. */\n clearDocumentParseCache,\n} from './document';\n"],"mappings":";;;;AAiBA,MAAM,oBAAoB;AAE1B,MAAM,uBAAuB,UAC3B,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAOnB,MAAa,wBACX,UACgC;CAChC,MAAM,SAAS,WAAW,KAAK;CAE/B,IACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GAE/B,OAAO;CAGT,MAAM,UAAgC,CAAC;CAEvC,MAAM,QAAQ,MAAe,MAA6B,UAAkB;EAC1E,IAAI,QAAQ,mBACV;EAGF,IAAI,oBAAoB,IAAI,GAAG;GAC7B,QAAQ,KAAK;IAAE;IAAM,OAAO;GAAK,CAAC;GAClC;EACF;EAEA,IAAI,MAAM,QAAQ,IAAI,GAAG;GACvB,KAAK,SAAS,MAAM,UAAU,KAAK,MAAM,CAAC,GAAG,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC;GACrE;EACF;EAEA,IAAI,OAAO,SAAS,YAAY,SAAS,MACvC,OAAO,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,UAClC,KAAK,MAAM,CAAC,GAAG,MAAM,GAAG,GAAG,QAAQ,CAAC,CACtC;CAKJ;CAEA,KAAK,QAAQ,CAAC,GAAG,CAAC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;;;;AC1IA,MAAa,kBAAkBG;;AAE/B,MAAa,sBAAsBC;;AAEnC,MAAa,gBAAgBC;;AAE7B,MAAa,iBAAiBC;;AAE9B,MAAa,aAAaC;;AAE1B,MAAa,mBAAmBC;;AAEhC,MAAa,0BAA0BC;;AAEvC,MAAa,uBAAuBC;;AAEpC,MAAa,uBAAuBC;;AAEpC,MAAa,wBAAwBC;;AAErC,MAAa,2BAA2BC;;AAQxC,MAAa,mBAAmBC;;AAEhC,MAAa,0BAA0BC;;AAEvC,MAAa,sBAAsBC;;AAEnC,MAAa,8BAA8BC;;AAE3C,MAAa,kBAAkBC;;AAE/B,MAAa,qBAAqBC;;AAUlC,MAAa,eAAeC;;AAE5B,MAAa,yBAAyBC;;AAEtC,MAAa,mBAAmBC;;AAEhC,MAAa,kBAAkBC;;AAE/B,MAAa,iBAAiBC;;AAE9B,MAAa,sBAAsBC;;AAEnC,MAAa,qBAAqBC;;AAkClC,MAAa,UAAUC;;AAEvB,MAAa,aAAaC;;AAE1B,MAAa,QAAQC;;AAErB,MAAa,eAAeC;;AAE5B,MAAa,oBAAoBC"}
@@ -1,4 +1,4 @@
1
- import { _ as Module, a as SectionOptions, n as DocumentOptions, o as SectionPreviewCache$1, r as DocumentProblem, v as Section } from "../document-Ct4jW78J.js";
1
+ import { _ as Module, a as SectionOptions, n as DocumentOptions, o as SectionPreviewCache$1, r as DocumentProblem, v as Section } from "../document-DqRSCtsx.js";
2
2
  //#region src/utils/sections.d.ts
3
3
  declare const extractSections: (code: string, options?: SectionOptions) => Section[];
4
4
  declare const replaceSections: (code: string, sections: string[], options?: DocumentOptions) => string;
@@ -1,8 +1,8 @@
1
- import { n as createSectionPreviewCache$1 } from "../document-CGbe6bSV.js";
1
+ import { n as createSectionPreviewCache$1 } from "../document-CHO215iP.js";
2
2
  import { r as registerEditorSession$1, t as clearEditorCaches } from "../editor-caches-ClMvdcQF.js";
3
3
  import { t as cn } from "../cn-CAnad2vL.js";
4
4
  import { a as getCachedScriptBlob$1, i as clearScriptCache$1, n as compile, o as preloadScripts, r as transformCode$1, t as clearCompilationCache } from "../compile-Dxas-D05.js";
5
- import { a as generateSections$1, i as generateSection$1, n as createDocument, o as replaceSections, r as extractSections, t as checkDocument } from "../sections-BYWOBISr.js";
5
+ import { a as generateSections$1, i as generateSection$1, n as createDocument, o as replaceSections, r as extractSections, t as checkDocument } from "../sections-jYuqS4KB.js";
6
6
  import { t as detectTypeScript$1 } from "../detect-typescript-Dr_oLniM.js";
7
7
  //#region src/utils/index.ts
8
8
  /** @deprecated Internal. Use `compile`. Removed in the next major. */
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "4.6.0",
7
+ "version": "4.6.1",
8
8
  "type": "module",
9
9
  "module": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -129,10 +129,10 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@babel/generator": "^7.29.8",
133
- "@babel/parser": "^7.29.8",
134
- "@babel/traverse": "^7.29.8",
135
- "@babel/types": "^7.29.8",
132
+ "@babel/generator": "^8.0.6",
133
+ "@babel/parser": "^8.0.6",
134
+ "@babel/traverse": "^8.0.6",
135
+ "@babel/types": "^8.0.6",
136
136
  "@changesets/cli": "^3.0.0",
137
137
  "@eslint/js": "^10.0.0",
138
138
  "@playwright/test": "^1.63.0",
@@ -141,9 +141,7 @@
141
141
  "@testing-library/react": "^16.3.3",
142
142
  "@trivago/prettier-plugin-sort-imports": "^6.0.2",
143
143
  "@tsdown/css": "^0.22.14",
144
- "@types/babel__generator": "^7.27.0",
145
144
  "@types/babel__standalone": "^7.1.9",
146
- "@types/babel__traverse": "^7.28.0",
147
145
  "@types/node": "^26.2.0",
148
146
  "@types/react": "^19.2.18",
149
147
  "@types/react-dom": "^19.2.4",