tempo-sdk 0.0.16 → 0.0.19
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/dist/assets/editor.d.ts +79 -0
- package/dist/assets/editor.js +571 -0
- package/dist/assets/editor.js.map +1 -0
- package/dist/assets/index.d.ts +83 -0
- package/dist/assets/index.js +26 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/assets/parser.d.ts +78 -0
- package/dist/assets/parser.js +29 -0
- package/dist/assets/parser.js.map +1 -0
- package/dist/canvas/editor.d.ts +44 -9
- package/dist/canvas/editor.js +116 -416
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +237 -56
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/parser.d.ts +25 -2
- package/dist/canvas/parser.js +3 -3
- package/dist/{chunk-77BNMPBS.js → chunk-CB5NJJJT.js} +31 -5
- package/dist/chunk-CB5NJJJT.js.map +1 -0
- package/dist/chunk-IWULHYPW.js +650 -0
- package/dist/chunk-IWULHYPW.js.map +1 -0
- package/dist/{chunk-ICP7LCPJ.js → chunk-P277UVZE.js} +279 -40
- package/dist/chunk-P277UVZE.js.map +1 -0
- package/dist/expo/plugin.cjs +30 -4
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +30 -4
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +1 -1
- package/dist/expo-babel-plugin.d.ts +1 -1
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/nextjs-loader.cjs +29 -4
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/types-B-dRoF2T.d.ts +102 -0
- package/package.json +16 -3
- package/dist/annotation-strategy-DCJHc--2.d.cts +0 -13
- package/dist/annotation-strategy-DCJHc--2.d.ts +0 -13
- package/dist/chunk-2LP5G6CD.js +0 -748
- package/dist/chunk-2LP5G6CD.js.map +0 -1
- package/dist/chunk-77BNMPBS.js.map +0 -1
- package/dist/chunk-B3PHU7XX.js +0 -571
- package/dist/chunk-B3PHU7XX.js.map +0 -1
- package/dist/chunk-EJBWZCEE.js +0 -434
- package/dist/chunk-EJBWZCEE.js.map +0 -1
- package/dist/chunk-F64WRL4H.js +0 -884
- package/dist/chunk-F64WRL4H.js.map +0 -1
- package/dist/chunk-G7M57ARC.js +0 -902
- package/dist/chunk-G7M57ARC.js.map +0 -1
- package/dist/chunk-GHPL4LGE.js +0 -205
- package/dist/chunk-GHPL4LGE.js.map +0 -1
- package/dist/chunk-ICP7LCPJ.js.map +0 -1
- package/dist/chunk-IG3JZVZI.js +0 -846
- package/dist/chunk-IG3JZVZI.js.map +0 -1
- package/dist/chunk-MBTLXFNP.js +0 -605
- package/dist/chunk-MBTLXFNP.js.map +0 -1
- package/dist/chunk-MD3HJ7L3.js +0 -457
- package/dist/chunk-MD3HJ7L3.js.map +0 -1
- package/dist/chunk-O3HYJ6BU.js +0 -433
- package/dist/chunk-O3HYJ6BU.js.map +0 -1
- package/dist/chunk-WGGLHHC5.js +0 -337
- package/dist/chunk-WGGLHHC5.js.map +0 -1
- package/dist/chunk-X3K7Z2BH.js +0 -900
- package/dist/chunk-X3K7Z2BH.js.map +0 -1
- package/dist/chunk-ZHORRCQG.js +0 -756
- package/dist/chunk-ZHORRCQG.js.map +0 -1
- package/dist/index.cjs +0 -1170
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -99
- package/dist/page-BokkL6FZ.d.ts +0 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../canvas/editor.ts"],"sourcesContent":["import {\n fallbackPageName,\n parseCanvasFile,\n unwrapTsExpression,\n type CanvasSourceSpan,\n type ParsedCanvasFile,\n type ParsedCanvasImport,\n type ParsedCanvasStoryboard,\n} from \"./parser\";\nimport { parseSync } from \"oxc-parser\";\n\nexport type CanvasSourceEdit = {\n start: number;\n end: number;\n value: string;\n};\n\nexport type CanvasEditResult = {\n source: string;\n edits: CanvasSourceEdit[];\n parsed: ParsedCanvasFile;\n};\n\nexport type LegacyCanvasMigrationResult = CanvasEditResult & {\n migrated: boolean;\n};\n\nexport type CanvasEditorLayout = {\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex?: number;\n intrinsicSizing?: \"root-element\";\n};\n\nexport type AddCanvasStoryboardInput =\n | {\n kind: \"component\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n componentExpression?: string;\n componentImport?: {\n localName: string;\n source: string;\n importedName?: string;\n };\n }\n | {\n kind: \"route\";\n id: string;\n route: string;\n layout: CanvasEditorLayout;\n name?: string;\n }\n | {\n kind: \"html\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n filepath?: string;\n src?: string;\n };\n\ntype SdkComponent = \"Storyboard\" | \"RouteStoryboard\" | \"HtmlStoryboard\";\n\nexport function applyCanvasSourceEdits(\n source: string,\n edits: readonly CanvasSourceEdit[],\n): string {\n const sorted = [...edits].sort((left, right) => right.start - left.start);\n let previousStart = source.length + 1;\n let nextSource = source;\n\n for (const edit of sorted) {\n if (\n edit.start < 0 ||\n edit.end < edit.start ||\n edit.end > source.length ||\n edit.end > previousStart\n ) {\n throw new Error(`Invalid overlapping canvas source edit ${edit.start}:${edit.end}`);\n }\n nextSource =\n nextSource.slice(0, edit.start) + edit.value + nextSource.slice(edit.end);\n previousStart = edit.start;\n }\n\n return nextSource;\n}\n\nexport function migrateLegacyCanvasToReact(options: {\n filePath: string;\n source: string;\n}): LegacyCanvasMigrationResult {\n const existing = parseCanvasFile(options.filePath, options.source);\n if (existing.canvasElementSpan) {\n return {\n source: options.source,\n edits: [],\n parsed: existing,\n migrated: false,\n };\n }\n\n const legacy = readLegacyCanvasMigration(options.filePath, options.source);\n if (legacy.unsupported.length > 0) {\n throw new Error(legacy.unsupported.join(\"\\n\"));\n }\n\n const newline = detectNewline(options.source);\n const edits: CanvasSourceEdit[] = [...legacy.exportEdits];\n const importPrefix = legacy.importInsertionOffset === 0 ||\n options.source.slice(0, legacy.importInsertionOffset).endsWith(newline)\n ? \"\"\n : newline;\n edits.push({\n start: legacy.importInsertionOffset,\n end: legacy.importInsertionOffset,\n value: `${importPrefix}${legacy.importSource}${newline}`,\n });\n edits.push({\n start: options.source.length,\n end: options.source.length,\n value: `${newline}${buildMigratedCanvasComponent(legacy, newline)}`,\n });\n\n const source = collapseBlankLines(\n applyCanvasSourceEdits(options.source, edits),\n newline,\n );\n\n return {\n source,\n edits,\n parsed: parseCanvasFile(options.filePath, source),\n migrated: true,\n };\n}\n\nexport function updateCanvasName(options: {\n filePath: string;\n source: string;\n name: string;\n}): CanvasEditResult {\n return editCanvasStringAttribute(\n options,\n \"name\",\n requireNonEmpty(options.name, \"Canvas name\"),\n (parsed) => ({\n valueSpan: parsed.nameSpan,\n attributeSpan: parsed.nameAttributeSpan,\n }),\n );\n}\n\nexport function updateCanvasPath(options: {\n filePath: string;\n source: string;\n path: string;\n}): CanvasEditResult {\n return editCanvasStringAttribute(\n options,\n \"path\",\n requireNonEmpty(options.path, \"Canvas path\"),\n (parsed) => ({\n valueSpan: parsed.pathSpan,\n attributeSpan: parsed.pathAttributeSpan,\n }),\n );\n}\n\nexport function updateCanvasBackgroundColor(options: {\n filePath: string;\n source: string;\n backgroundColor?: string;\n}): CanvasEditResult {\n return editCanvasStringAttribute(\n options,\n \"backgroundColor\",\n options.backgroundColor && options.backgroundColor.trim() !== \"\"\n ? options.backgroundColor\n : undefined,\n (parsed) => ({\n valueSpan: parsed.backgroundColorSpan,\n attributeSpan: parsed.backgroundColorAttributeSpan,\n }),\n );\n}\n\nfunction editCanvasStringAttribute(\n options: { filePath: string; source: string },\n attributeName: string,\n value: string | undefined,\n selectSpans: (parsed: ParsedCanvasFile) => {\n valueSpan?: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n },\n): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const spans = selectSpans(parsed);\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requiredSpan(\n parsed.canvasOpeningElementSpan,\n \"Canvas opening element not found\",\n ),\n valueSpan: spans.valueSpan,\n attributeSpan: spans.attributeSpan,\n name: attributeName,\n value,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n}\n\nexport function updateStoryboardName(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n name?: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.legacyV1) {\n const edit = upsertObjectStringProperty({\n source: options.source,\n objectClose: storyboard.legacyV1.objectClose,\n valueSpan: storyboard.nameSpan,\n propertySpan: storyboard.legacyV1.namePropertySpan,\n name: \"name\",\n value:\n options.name && options.name.trim() !== \"\" ? options.name : undefined,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n }\n\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n valueSpan: storyboard.nameSpan,\n attributeSpan: storyboard.nameAttributeSpan,\n name: \"name\",\n value:\n options.name && options.name.trim() !== \"\" ? options.name : undefined,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n}\n\nexport function updateStoryboardId(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n nextId: string;\n}): CanvasEditResult {\n const nextId = requireNonEmpty(options.nextId, \"Storyboard id\");\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const duplicate = parsed.storyboards.find(\n (item) =>\n item.storyboardKey === nextId && item.storyboardKey !== storyboard.storyboardKey,\n );\n if (duplicate) {\n throw new Error(`Storyboard id \"${nextId}\" already exists`);\n }\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n valueSpan: storyboard.idSpan,\n attributeSpan: storyboard.idAttributeSpan,\n name: \"id\",\n value: nextId,\n });\n return applyResult(options.source, parsed, [edit]);\n}\n\nexport function updateStoryboardLayout(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n layout: Partial<CanvasEditorLayout>;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const spans = storyboard.layoutSpans;\n if (!spans) {\n throw new Error(`Storyboard \"${options.storyboardId}\" has no editable layout`);\n }\n\n const edits: CanvasSourceEdit[] = [];\n for (const key of [\"x\", \"y\", \"width\", \"height\"] as const) {\n if (options.layout[key] === undefined) continue;\n const span = spans[key];\n if (!span) {\n throw new Error(\n `Storyboard \"${options.storyboardId}\" layout.${key} is not editable`,\n );\n }\n edits.push({\n start: span.start,\n end: span.end,\n value: String(roundLayoutNumber(options.layout[key])),\n });\n }\n\n if (options.layout.zIndex !== undefined) {\n const value = String(roundLayoutNumber(options.layout.zIndex));\n edits.push(\n spans.zIndex\n ? { start: spans.zIndex.start, end: spans.zIndex.end, value }\n : insertLayoutProperty(options.source, spans, `zIndex: ${value}`),\n );\n }\n\n if (options.layout.intrinsicSizing !== undefined) {\n const value = JSON.stringify(options.layout.intrinsicSizing);\n edits.push(\n spans.intrinsicSizing\n ? {\n start: spans.intrinsicSizing.start,\n end: spans.intrinsicSizing.end,\n value,\n }\n : insertLayoutProperty(\n options.source,\n spans,\n `intrinsicSizing: ${value}`,\n ),\n );\n }\n\n return applyResult(options.source, parsed, edits);\n}\n\nexport function updateStoryboardComponent(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n componentExpression: string;\n componentImport?: {\n localName: string;\n source: string;\n importedName?: string;\n };\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.kind !== \"component\") {\n throw new Error(`Storyboard \"${options.storyboardId}\" is not a component storyboard`);\n }\n\n const imports: string[] = [];\n if (options.componentImport) {\n const importLine = buildMissingComponentImportLine(\n parsed,\n options.source,\n options.componentImport,\n );\n if (importLine) imports.push(importLine);\n }\n\n const importEdit = buildImportInsertionEdit(options.source, parsed, imports);\n const componentEdit = upsertJsxExpressionAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n expressionSpan: storyboard.component?.span,\n attributeSpan: storyboard.component?.attributeSpan,\n name: \"component\",\n value: requireNonEmpty(\n options.componentExpression,\n \"Storyboard component expression\",\n ),\n });\n\n return applyResult(options.source, parsed, [\n ...(importEdit ? [importEdit] : []),\n componentEdit,\n ]);\n}\n\nexport function updateStoryboardProps(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n propsExpression?: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const edit = upsertJsxExpressionAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n expressionSpan: storyboard.props?.span,\n attributeSpan: storyboard.props?.attributeSpan,\n name: \"props\",\n value:\n options.propsExpression && options.propsExpression.trim() !== \"\"\n ? options.propsExpression.trim()\n : undefined,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n}\n\nexport function updateRouteStoryboardRoute(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n route: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.kind !== \"route\") {\n throw new Error(`Storyboard \"${options.storyboardId}\" is not a route storyboard`);\n }\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n valueSpan: storyboard.routeSpan,\n attributeSpan: storyboard.routeAttributeSpan,\n name: \"route\",\n value: requireNonEmpty(options.route, \"Route storyboard route\"),\n });\n return applyResult(options.source, parsed, [edit]);\n}\n\nexport function updateHtmlStoryboardSource(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n filepath?: string;\n src?: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.kind !== \"html\") {\n throw new Error(`Storyboard \"${options.storyboardId}\" is not an html storyboard`);\n }\n const filepath =\n options.filepath && options.filepath.trim() !== \"\"\n ? options.filepath.trim()\n : undefined;\n const src =\n options.src && options.src.trim() !== \"\" ? options.src : undefined;\n if (!filepath && !src) {\n throw new Error(\"HTML storyboard source requires filepath or src\");\n }\n\n const openingElementSpan = requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n );\n const filepathEdit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan,\n valueSpan: storyboard.filepathSpan,\n attributeSpan: storyboard.filepathAttributeSpan,\n name: \"filepath\",\n value: filepath,\n });\n const srcEdit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan,\n valueSpan: storyboard.srcSpan,\n attributeSpan: storyboard.srcAttributeSpan,\n name: \"src\",\n value: src,\n });\n\n return applyResult(options.source, parsed, [filepathEdit, srcEdit]);\n}\n\nexport function addCanvasStoryboard(options: {\n filePath: string;\n source: string;\n storyboard: AddCanvasStoryboardInput;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n if (parsed.storyboards.some((item) => item.storyboardKey === options.storyboard.id)) {\n throw new Error(`Storyboard id \"${options.storyboard.id}\" already exists`);\n }\n\n const imports: string[] = [];\n const sdkComponent = sdkComponentForStoryboard(options.storyboard.kind);\n const sdkTag = resolveSdkTag(parsed, sdkComponent);\n let storyboardTag = sdkTag.tag;\n if (sdkTag.importLine) {\n imports.push(sdkTag.importLine);\n storyboardTag = sdkTag.tag;\n }\n\n let componentExpression: string | undefined;\n if (options.storyboard.kind === \"component\") {\n componentExpression =\n options.storyboard.componentExpression ??\n options.storyboard.componentImport?.localName;\n if (!componentExpression) {\n throw new Error(\"Component storyboard requires componentExpression or componentImport\");\n }\n if (options.storyboard.componentImport) {\n const importLine = buildMissingComponentImportLine(\n parsed,\n options.source,\n options.storyboard.componentImport,\n );\n if (importLine) imports.push(importLine);\n }\n }\n\n const importEdit = buildImportInsertionEdit(options.source, parsed, imports);\n const insertionEdit = buildCanvasChildInsertionEdit({\n source: options.source,\n parsed,\n tag: storyboardTag,\n storyboard: options.storyboard,\n componentExpression,\n });\n\n const edits = [\n ...(importEdit ? [importEdit] : []),\n insertionEdit,\n ];\n return applyResult(options.source, parsed, edits);\n}\n\nexport function removeCanvasStoryboard(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n removeUnusedComponentImport?: boolean;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const edits: CanvasSourceEdit[] = [\n {\n ...expandToFullLines(options.source, storyboard.jsxElementSpan),\n value: \"\",\n },\n ];\n\n if (options.removeUnusedComponentImport ?? true) {\n const importEdit = buildUnusedComponentImportRemoval({\n source: options.source,\n parsed,\n deletedStoryboard: storyboard,\n deletionEdit: edits[0],\n });\n if (importEdit) edits.push(importEdit);\n }\n\n const result = applyResult(options.source, parsed, edits);\n return {\n ...result,\n source: collapseBlankLines(result.source, detectNewline(options.source)),\n };\n}\n\nfunction applyResult(\n source: string,\n parsed: ParsedCanvasFile,\n edits: readonly (CanvasSourceEdit | null | undefined)[],\n): CanvasEditResult {\n const compactEdits = edits.filter((edit): edit is CanvasSourceEdit => {\n if (!edit) return false;\n return source.slice(edit.start, edit.end) !== edit.value;\n });\n return {\n source: applyCanvasSourceEdits(source, compactEdits),\n edits: compactEdits,\n parsed,\n };\n}\n\nfunction findStoryboard(\n parsed: ParsedCanvasFile,\n storyboardId: string,\n): ParsedCanvasStoryboard {\n const storyboard = parsed.storyboards.find(\n (item) => item.storyboardKey === storyboardId,\n );\n if (!storyboard) {\n throw new Error(`Storyboard \"${storyboardId}\" not found`);\n }\n return storyboard;\n}\n\nfunction requireStoryboardOpeningSpan(\n storyboard: ParsedCanvasStoryboard,\n storyboardId: string,\n): CanvasSourceSpan {\n return requiredSpan(\n storyboard.openingElementSpan,\n `Storyboard \"${storyboardId}\" opening element not found`,\n );\n}\n\nfunction upsertJsxStringAttribute(options: {\n source: string;\n openingElementSpan: CanvasSourceSpan;\n valueSpan?: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n name: string;\n value?: string;\n}): CanvasSourceEdit | null {\n if (options.value === undefined) {\n if (!options.attributeSpan) return null;\n return {\n ...expandJsxAttributeRemoval(options.source, options.attributeSpan),\n value: \"\",\n };\n }\n\n const value = JSON.stringify(options.value);\n if (options.valueSpan) {\n return { start: options.valueSpan.start, end: options.valueSpan.end, value };\n }\n\n const offset = findOpeningElementAttributeInsertionOffset(\n options.source,\n options.openingElementSpan,\n );\n return {\n start: offset,\n end: offset,\n value: ` ${options.name}={${value}}`,\n };\n}\n\nfunction upsertObjectStringProperty(options: {\n source: string;\n objectClose?: number;\n valueSpan?: CanvasSourceSpan;\n propertySpan?: CanvasSourceSpan;\n name: string;\n value?: string;\n}): CanvasSourceEdit | null {\n if (options.value === undefined) {\n if (!options.propertySpan) return null;\n return {\n ...expandObjectPropertyRemoval(options.source, options.propertySpan),\n value: \"\",\n };\n }\n\n const value = JSON.stringify(options.value);\n if (options.valueSpan) {\n return { start: options.valueSpan.start, end: options.valueSpan.end, value };\n }\n\n if (typeof options.objectClose !== \"number\") {\n throw new Error(`Object close not found for \"${options.name}\" property`);\n }\n\n return insertObjectProperty(\n options.source,\n options.objectClose,\n `${options.name}: ${value}`,\n );\n}\n\nfunction upsertJsxExpressionAttribute(options: {\n source: string;\n openingElementSpan: CanvasSourceSpan;\n expressionSpan?: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n name: string;\n value?: string;\n}): CanvasSourceEdit | null {\n if (options.value === undefined) {\n if (!options.attributeSpan) return null;\n return {\n ...expandJsxAttributeRemoval(options.source, options.attributeSpan),\n value: \"\",\n };\n }\n\n if (options.expressionSpan) {\n return {\n start: options.expressionSpan.start,\n end: options.expressionSpan.end,\n value: options.value,\n };\n }\n\n const offset = findOpeningElementAttributeInsertionOffset(\n options.source,\n options.openingElementSpan,\n );\n return {\n start: offset,\n end: offset,\n value: ` ${options.name}={${options.value}}`,\n };\n}\n\nfunction insertLayoutProperty(\n source: string,\n spans: NonNullable<ParsedCanvasStoryboard[\"layoutSpans\"]>,\n propertySource: string,\n): CanvasSourceEdit {\n if (typeof spans.layoutClose !== \"number\") {\n throw new Error(\"Layout object close span not found\");\n }\n return insertObjectProperty(source, spans.layoutClose, propertySource);\n}\n\nfunction insertObjectProperty(\n source: string,\n objectClose: number,\n propertySource: string,\n): CanvasSourceEdit {\n const offset = trimWhitespaceBeforeOffset(source, objectClose);\n const previous = previousMeaningfulCharacter(source, offset);\n return {\n start: offset,\n end: offset,\n value: `${previous === \"{\" || previous === \",\" ? \" \" : \", \"}${propertySource}`,\n };\n}\n\nfunction formatStoryboardElement(options: {\n source: string;\n insertionOffset: number;\n tag: string;\n storyboard: AddCanvasStoryboardInput;\n componentExpression?: string;\n}): string {\n const newline = detectNewline(options.source);\n const closingIndent = lineIndentAt(options.source, options.insertionOffset);\n const indent = `${closingIndent} `;\n const firstLineIndent = \" \";\n const propIndent = `${indent} `;\n const props = storyboardElementProps(\n options.storyboard,\n options.componentExpression,\n );\n\n return `${firstLineIndent}<${options.tag}${newline}${props\n .map((prop) => `${propIndent}${prop}`)\n .join(newline)}${newline}${indent}/>${newline}${closingIndent}`;\n}\n\nfunction buildCanvasChildInsertionEdit(options: {\n source: string;\n parsed: ParsedCanvasFile;\n tag: string;\n storyboard: AddCanvasStoryboardInput;\n componentExpression?: string;\n}): CanvasSourceEdit {\n const insertionOffset = options.parsed.canvasChildrenInsertionOffset;\n if (typeof insertionOffset === \"number\") {\n return {\n start: insertionOffset,\n end: insertionOffset,\n value: formatStoryboardElement({\n source: options.source,\n insertionOffset,\n tag: options.tag,\n storyboard: options.storyboard,\n componentExpression: options.componentExpression,\n }),\n };\n }\n\n const openingSpan = options.parsed.canvasOpeningElementSpan;\n if (!openingSpan) {\n throw new Error(\"Canvas closing element not found\");\n }\n\n const openingSource = options.source.slice(openingSpan.start, openingSpan.end);\n const selfClosingMatch = openingSource.match(/\\s*\\/\\s*>$/);\n const canvasName = openingSource.match(/^<\\s*([A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*)/)?.[1];\n if (!selfClosingMatch || !canvasName) {\n throw new Error(\"Canvas closing element not found\");\n }\n\n const newline = detectNewline(options.source);\n const replacementStart = openingSpan.end - selfClosingMatch[0].length;\n const closingIndent = lineIndentAt(options.source, openingSpan.start);\n const childIndent = `${closingIndent} `;\n const propIndent = `${childIndent} `;\n const props = storyboardElementProps(\n options.storyboard,\n options.componentExpression,\n );\n\n return {\n start: replacementStart,\n end: openingSpan.end,\n value: `>${newline}${childIndent}<${options.tag}${newline}${props\n .map((prop) => `${propIndent}${prop}`)\n .join(newline)}${newline}${childIndent}/>${newline}${closingIndent}</${canvasName}>`,\n };\n}\n\nfunction storyboardElementProps(\n storyboard: AddCanvasStoryboardInput,\n componentExpression?: string,\n): string[] {\n return [\n `id={${JSON.stringify(requireNonEmpty(storyboard.id, \"Storyboard id\"))}}`,\n ...(storyboard.name && storyboard.name.trim() !== \"\"\n ? [`name={${JSON.stringify(storyboard.name)}}`]\n : []),\n ...storyboardKindProps(storyboard, componentExpression),\n `layout={{ ${formatLayout(storyboard.layout)} }}`,\n ];\n}\n\nfunction storyboardKindProps(\n storyboard: AddCanvasStoryboardInput,\n componentExpression?: string,\n): string[] {\n if (storyboard.kind === \"component\") {\n return [`component={${componentExpression}}`];\n }\n if (storyboard.kind === \"route\") {\n return [`route={${JSON.stringify(storyboard.route)}}`];\n }\n return [\n ...(storyboard.filepath ? [`filepath={${JSON.stringify(storyboard.filepath)}}`] : []),\n ...(storyboard.src ? [`src={${JSON.stringify(storyboard.src)}}`] : []),\n ];\n}\n\nfunction formatLayout(layout: CanvasEditorLayout): string {\n return [\n `x: ${roundLayoutNumber(layout.x)}`,\n `y: ${roundLayoutNumber(layout.y)}`,\n `width: ${roundLayoutNumber(layout.width)}`,\n `height: ${roundLayoutNumber(layout.height)}`,\n ...(layout.zIndex === undefined\n ? []\n : [`zIndex: ${roundLayoutNumber(layout.zIndex)}`]),\n ...(layout.intrinsicSizing\n ? [`intrinsicSizing: ${JSON.stringify(layout.intrinsicSizing)}`]\n : []),\n ].join(\", \");\n}\n\nfunction sdkComponentForStoryboard(kind: AddCanvasStoryboardInput[\"kind\"]): SdkComponent {\n if (kind === \"route\") return \"RouteStoryboard\";\n if (kind === \"html\") return \"HtmlStoryboard\";\n return \"Storyboard\";\n}\n\nfunction resolveSdkTag(\n parsed: ParsedCanvasFile,\n component: SdkComponent,\n): { tag: string; importLine?: string } {\n for (const item of parsed.imports) {\n if (item.source !== \"tempo-sdk/canvas\") continue;\n if (item.kind === \"namespace\") return { tag: `${item.localName}.${component}` };\n if (item.importedName === component) return { tag: item.localName };\n }\n\n const localName = pickAvailableIdentifier(\n parsed,\n `TempoCanvas${component}`,\n );\n return {\n tag: localName,\n importLine: `import { ${component} as ${localName} } from \"tempo-sdk/canvas\";`,\n };\n}\n\nfunction buildMissingComponentImportLine(\n parsed: ParsedCanvasFile,\n source: string,\n componentImport: {\n localName: string;\n source: string;\n importedName?: string;\n },\n): string | null {\n const existing = parsed.imports.find(\n (item) => item.localName === componentImport.localName,\n );\n if (existing) {\n if (existing.source !== componentImport.source) {\n throw new Error(`Import binding \"${componentImport.localName}\" already exists`);\n }\n return null;\n }\n if (hasIdentifier(source, componentImport.localName)) {\n throw new Error(`Identifier \"${componentImport.localName}\" already exists`);\n }\n\n if (\n !componentImport.importedName ||\n componentImport.importedName === \"default\"\n ) {\n return `import ${componentImport.localName} from ${JSON.stringify(\n componentImport.source,\n )};`;\n }\n\n const specifier =\n componentImport.importedName === componentImport.localName\n ? componentImport.localName\n : `${componentImport.importedName} as ${componentImport.localName}`;\n return `import { ${specifier} } from ${JSON.stringify(componentImport.source)};`;\n}\n\nfunction buildImportInsertionEdit(\n source: string,\n parsed: ParsedCanvasFile,\n importLines: readonly string[],\n): CanvasSourceEdit | null {\n if (importLines.length === 0) return null;\n const newline = detectNewline(source);\n const uniqueLines = Array.from(new Set(importLines));\n const lastImport = parsed.imports.reduce<ParsedCanvasImport | null>(\n (latest, item) =>\n !latest || item.declarationSpan.end > latest.declarationSpan.end\n ? item\n : latest,\n null,\n );\n\n if (lastImport) {\n return {\n start: lastImport.declarationSpan.end,\n end: lastImport.declarationSpan.end,\n value: `${newline}${uniqueLines.join(newline)}`,\n };\n }\n\n const offset = topLevelInsertionOffset(source);\n return {\n start: offset,\n end: offset,\n value: `${uniqueLines.join(newline)}${newline}`,\n };\n}\n\nfunction buildUnusedComponentImportRemoval(options: {\n source: string;\n parsed: ParsedCanvasFile;\n deletedStoryboard: ParsedCanvasStoryboard;\n deletionEdit: CanvasSourceEdit;\n}): CanvasSourceEdit | null {\n const componentImport = options.deletedStoryboard.component?.import;\n if (!componentImport || componentImport.importKind === \"type\") return null;\n\n const usedByRemainingStoryboard = options.parsed.storyboards.some(\n (storyboard) =>\n storyboard.storyboardKey !== options.deletedStoryboard.storyboardKey &&\n storyboard.component?.import?.localName === componentImport.localName,\n );\n if (usedByRemainingStoryboard) return null;\n\n const sourceAfterStoryboardDelete = applyCanvasSourceEdits(options.source, [\n options.deletionEdit,\n ]);\n\n if (componentImport.specifierCount === 1) {\n const sourceWithoutImport = removeSpanText(\n sourceAfterStoryboardDelete,\n componentImport.declarationSpan,\n );\n if (hasIdentifier(sourceWithoutImport, componentImport.localName)) return null;\n\n return {\n ...expandToFullLines(options.source, componentImport.declarationSpan),\n value: \"\",\n };\n }\n\n if (\n componentImport.kind !== \"named\" ||\n componentImport.hasDefaultSpecifier ||\n componentImport.hasNamespaceSpecifier ||\n componentImport.namedSpecifierCount <= 1\n ) {\n return null;\n }\n\n const specifierRange = expandImportSpecifierRemovalRange(\n options.source,\n componentImport.span,\n );\n const sourceWithoutImport = removeSpanText(\n sourceAfterStoryboardDelete,\n specifierRange,\n );\n if (hasIdentifier(sourceWithoutImport, componentImport.localName)) return null;\n\n return {\n ...specifierRange,\n value: \"\",\n };\n}\n\nfunction expandImportSpecifierRemovalRange(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n const lineStart = Math.max(source.lastIndexOf(\"\\n\", span.start - 1) + 1, 0);\n const nextNewline = source.indexOf(\"\\n\", span.end);\n const lineEnd = nextNewline >= 0 ? nextNewline + 1 : source.length;\n const before = source.slice(lineStart, span.start);\n const after = source.slice(span.end, lineEnd);\n if (/^[ \\t]*$/.test(before) && /^[ \\t]*(,)?[ \\t]*(\\r?\\n)?$/.test(after)) {\n return { start: lineStart, end: lineEnd };\n }\n\n let start = span.start;\n let end = span.end;\n while (end < source.length && /\\s/.test(source[end] ?? \"\")) end++;\n if (source[end] === \",\") {\n end++;\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n return { start, end };\n }\n\n while (start > 0 && (source[start - 1] === \" \" || source[start - 1] === \"\\t\")) {\n start--;\n }\n if (source[start - 1] === \",\") {\n start--;\n while (start > 0 && (source[start - 1] === \" \" || source[start - 1] === \"\\t\")) {\n start--;\n }\n }\n return { start, end };\n}\n\nfunction removeSpanText(source: string, span: CanvasSourceSpan): string {\n return source.slice(0, span.start) + source.slice(span.end);\n}\n\nfunction findOpeningElementAttributeInsertionOffset(\n source: string,\n span: CanvasSourceSpan,\n): number {\n const close = source.lastIndexOf(\">\", span.end - 1);\n if (close < span.start) {\n throw new Error(\"JSX opening element close not found\");\n }\n return source[close - 1] === \"/\" ? close - 1 : close;\n}\n\nfunction expandJsxAttributeRemoval(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let start = span.start;\n let end = span.end;\n\n while (start > 0 && (source[start - 1] === \" \" || source[start - 1] === \"\\t\")) {\n start--;\n }\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n return { start, end };\n}\n\nfunction expandObjectPropertyRemoval(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let start = span.start;\n let end = span.end;\n\n while (start > 0 && /\\s/.test(source[start - 1] ?? \"\")) start--;\n while (end < source.length && /\\s/.test(source[end] ?? \"\")) end++;\n\n if (source[end] === \",\") {\n end++;\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n return { start, end };\n }\n\n let comma = start - 1;\n while (comma >= 0 && /\\s/.test(source[comma] ?? \"\")) comma--;\n if (source[comma] === \",\") {\n start = comma;\n }\n return { start, end };\n}\n\nfunction expandToFullLines(source: string, span: CanvasSourceSpan): CanvasSourceSpan {\n let start = span.start;\n let end = span.end;\n while (start > 0 && source[start - 1] !== \"\\n\" && source[start - 1] !== \"\\r\") {\n start--;\n }\n if (start > 0) {\n if (source[start - 1] === \"\\n\") start--;\n if (start > 0 && source[start - 1] === \"\\r\") start--;\n }\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n if (source.slice(end, end + 2) === \"\\r\\n\") {\n end += 2;\n } else if (source[end] === \"\\n\" || source[end] === \"\\r\") {\n end++;\n }\n return { start, end };\n}\n\nfunction expandStatementForward(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let end = span.end;\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n if (source.slice(end, end + 2) === \"\\r\\n\") {\n end += 2;\n } else if (source[end] === \"\\n\" || source[end] === \"\\r\") {\n end++;\n }\n return { start: span.start, end };\n}\n\ntype LegacyMigratedStoryboard =\n | { kind: \"component\"; id: string; localName: string }\n | {\n kind: \"route\";\n id: string;\n route: string;\n name?: string;\n layout: CanvasEditorLayout;\n }\n | {\n kind: \"html\";\n id: string;\n filepath: string;\n name?: string;\n layout: CanvasEditorLayout;\n };\n\ntype LegacyMigration = {\n storyboards: LegacyMigratedStoryboard[];\n exportEdits: CanvasSourceEdit[];\n unsupported: string[];\n importInsertionOffset: number;\n importSource: string;\n componentName: string;\n canvasTag: string;\n legacyTag: string;\n routeTag: string;\n htmlTag: string;\n pageExpression?: string;\n canvasName: string;\n hasPageBackgroundColor: boolean;\n};\n\ntype LegacyBinding = {\n typeName: string | null;\n init: any;\n};\n\nfunction readLegacyCanvasMigration(\n filePath: string,\n source: string,\n): LegacyMigration {\n const result = parseSync(filePath, source) as any;\n const program = result.program;\n const programBody = Array.isArray(program?.body) ? program.body : [];\n const bindings = collectLegacyBindings(programBody);\n const usedIdentifiers = collectSourceIdentifiers(source);\n const canvasTag = pickAvailableSourceIdentifier(usedIdentifiers, \"TempoCanvas\");\n const legacyTag = pickAvailableSourceIdentifier(\n usedIdentifiers,\n \"TempoLegacyStoryboardV1\",\n );\n const routeTag = pickAvailableSourceIdentifier(\n usedIdentifiers,\n \"TempoRouteStoryboard\",\n );\n const htmlTag = pickAvailableSourceIdentifier(\n usedIdentifiers,\n \"TempoHtmlStoryboard\",\n );\n usedIdentifiers.add(canvasTag);\n usedIdentifiers.add(legacyTag);\n usedIdentifiers.add(routeTag);\n usedIdentifiers.add(htmlTag);\n\n const componentName = pickAvailableSourceIdentifier(\n usedIdentifiers,\n `${toPascalIdentifier(fallbackPageName(filePath))}Canvas`,\n );\n const pageBindingName = pickAvailableSourceIdentifier(usedIdentifiers, \"page\");\n\n const migration: LegacyMigration = {\n storyboards: [],\n exportEdits: [],\n unsupported: [],\n importInsertionOffset: lastImportEnd(programBody) ?? topLevelInsertionOffset(source),\n importSource: `import { Canvas as ${canvasTag}, LegacyStoryboardV1 as ${legacyTag}, RouteStoryboard as ${routeTag}, HtmlStoryboard as ${htmlTag} } from \"tempo-sdk/canvas\";`,\n componentName,\n canvasTag,\n legacyTag,\n routeTag,\n htmlTag,\n canvasName: fallbackPageName(filePath),\n hasPageBackgroundColor: false,\n };\n\n let defaultExportCount = 0;\n const seenStoryboardIds = new Set<string>();\n\n const addStoryboard = (\n id: string,\n localName: string,\n typeName: string | null,\n ): void => {\n if (seenStoryboardIds.has(id)) return;\n if (\n typeName !== \"TempoStoryboard\" &&\n typeName !== \"TempoRouteStoryboard\" &&\n typeName !== \"TempoHtmlStoryboard\"\n ) {\n return;\n }\n\n seenStoryboardIds.add(id);\n\n const binding = bindings.get(localName);\n const pageName = readObjectStringProperty(binding?.init, \"name\");\n if (!migration.pageExpression && pageName) {\n migration.canvasName = pageName;\n }\n\n if (typeName === \"TempoStoryboard\") {\n migration.storyboards.push({ kind: \"component\", id, localName });\n return;\n }\n\n const layout = readObjectLayoutProperty(binding?.init);\n if (!layout) {\n migration.unsupported.push(\n `Legacy ${typeName} export \"${id}\" requires a literal layout object`,\n );\n return;\n }\n\n if (typeName === \"TempoRouteStoryboard\") {\n const route = readObjectStringProperty(binding?.init, \"route\");\n if (!route) {\n migration.unsupported.push(\n `Legacy TempoRouteStoryboard export \"${id}\" requires a literal route string`,\n );\n return;\n }\n migration.storyboards.push({\n kind: \"route\",\n id,\n route,\n ...(pageName ? { name: pageName } : {}),\n layout,\n });\n return;\n }\n\n const filepath = readObjectStringProperty(binding?.init, \"filepath\");\n if (!filepath) {\n migration.unsupported.push(\n `Legacy TempoHtmlStoryboard export \"${id}\" requires a literal filepath string`,\n );\n return;\n }\n migration.storyboards.push({\n kind: \"html\",\n id,\n filepath,\n ...(pageName ? { name: pageName } : {}),\n layout,\n });\n };\n\n for (const statement of programBody) {\n const span = nodeSpan(statement);\n if (!span) continue;\n\n if (statement?.type === \"ExportAllDeclaration\") {\n migration.unsupported.push(\"export * declarations require manual migration\");\n continue;\n }\n\n if (statement?.type === \"ExportDefaultDeclaration\") {\n defaultExportCount += 1;\n if (defaultExportCount > 1) {\n migration.unsupported.push(\"Multiple default exports require manual migration\");\n continue;\n }\n\n const declaration = unwrapTsExpression(statement.declaration);\n if (declaration?.type === \"Identifier\") {\n migration.pageExpression = declaration.name;\n const binding = bindings.get(declaration.name);\n const pageName = readObjectStringProperty(binding?.init, \"name\");\n if (pageName) migration.canvasName = pageName;\n migration.hasPageBackgroundColor = hasObjectProperty(\n binding?.init,\n \"backgroundColor\",\n );\n migration.exportEdits.push({\n ...expandStatementForward(source, span),\n value: \"\",\n });\n continue;\n }\n\n if (declaration?.type === \"ObjectExpression\") {\n migration.pageExpression = pageBindingName;\n const pageName = readObjectStringProperty(declaration, \"name\");\n if (pageName) migration.canvasName = pageName;\n migration.hasPageBackgroundColor = hasObjectProperty(\n declaration,\n \"backgroundColor\",\n );\n migration.exportEdits.push({\n start: statement.start,\n end: declaration.start,\n value: `const ${pageBindingName} = `,\n });\n continue;\n }\n\n migration.unsupported.push(\"Default export must be a page object or identifier\");\n continue;\n }\n\n if (statement?.type !== \"ExportNamedDeclaration\") {\n continue;\n }\n\n if (statement.source) {\n migration.unsupported.push(\n \"Re-export declarations with a source require manual migration\",\n );\n continue;\n }\n\n if (statement.declaration) {\n const declarationSpan = nodeSpan(statement.declaration);\n if (declarationSpan) {\n migration.exportEdits.push({\n start: statement.start,\n end: declarationSpan.start,\n value: \"\",\n });\n }\n\n if (statement.declaration.type === \"VariableDeclaration\") {\n for (const declaration of statement.declaration.declarations ?? []) {\n if (declaration?.id?.type !== \"Identifier\") continue;\n const localName = declaration.id.name;\n const typeName = legacyTypeName(\n declaration.id.typeAnnotation?.typeAnnotation,\n );\n addStoryboard(localName, localName, typeName);\n }\n }\n continue;\n }\n\n migration.exportEdits.push({\n ...expandStatementForward(source, span),\n value: \"\",\n });\n for (const specifier of statement.specifiers ?? []) {\n const localName = legacyIdentifierName(specifier.local);\n const exportedName = legacyIdentifierName(\n specifier.exported ?? specifier.local,\n );\n if (!localName || !exportedName) continue;\n addStoryboard(\n exportedName,\n localName,\n bindings.get(localName)?.typeName ?? null,\n );\n }\n }\n\n return migration;\n}\n\nfunction buildMigratedCanvasComponent(\n migration: LegacyMigration,\n newline: string,\n): string {\n const canvasProps = [\n migration.pageExpression\n ? `name={${migration.pageExpression}.name}`\n : `name={${JSON.stringify(migration.canvasName)}}`,\n ...(migration.pageExpression && migration.hasPageBackgroundColor\n ? [`backgroundColor={${migration.pageExpression}.backgroundColor}`]\n : []),\n ].join(\" \");\n if (migration.storyboards.length === 0) {\n return `export default function ${migration.componentName}() {\n return <${migration.canvasTag} ${canvasProps} />;\n}\n`;\n }\n\n const storyboards = migration.storyboards\n .map((storyboard) => ` ${formatMigratedStoryboard(migration, storyboard)}`)\n .join(newline);\n\n return `export default function ${migration.componentName}() {\n return (\n <${migration.canvasTag} ${canvasProps}>\n${storyboards}\n </${migration.canvasTag}>\n );\n}\n`;\n}\n\nfunction formatMigratedStoryboard(\n migration: LegacyMigration,\n storyboard: LegacyMigratedStoryboard,\n): string {\n if (storyboard.kind === \"component\") {\n return `<${migration.legacyTag} id=${JSON.stringify(storyboard.id)} storyboard={${storyboard.localName}} />`;\n }\n\n if (storyboard.kind === \"route\") {\n return `<${migration.routeTag} id=${JSON.stringify(storyboard.id)}${formatOptionalJsxStringAttribute(\"name\", storyboard.name)} route=${JSON.stringify(storyboard.route)} layout={{ ${formatLayout(storyboard.layout)} }} />`;\n }\n\n return `<${migration.htmlTag} id=${JSON.stringify(storyboard.id)}${formatOptionalJsxStringAttribute(\"name\", storyboard.name)} filepath=${JSON.stringify(storyboard.filepath)} layout={{ ${formatLayout(storyboard.layout)} }} />`;\n}\n\nfunction formatOptionalJsxStringAttribute(\n name: string,\n value: string | undefined,\n): string {\n return value ? ` ${name}=${JSON.stringify(value)}` : \"\";\n}\n\nfunction collectLegacyBindings(programBody: any[]): Map<string, LegacyBinding> {\n const bindings = new Map<string, LegacyBinding>();\n\n const collect = (node: any): void => {\n if (node?.type !== \"VariableDeclaration\") return;\n for (const declaration of node.declarations ?? []) {\n if (declaration?.id?.type !== \"Identifier\") continue;\n bindings.set(declaration.id.name, {\n typeName: legacyTypeName(declaration.id.typeAnnotation?.typeAnnotation),\n init: declaration.init,\n });\n }\n };\n\n for (const statement of programBody) {\n collect(statement);\n if (statement?.type === \"ExportNamedDeclaration\") {\n collect(statement.declaration);\n }\n }\n return bindings;\n}\n\nfunction legacyTypeName(typeAnnotation: any): string | null {\n if (!typeAnnotation || typeAnnotation.type !== \"TSTypeReference\") return null;\n const typeName = typeAnnotation.typeName;\n if (typeName?.type === \"Identifier\") return typeName.name;\n if (\n typeName?.type === \"TSQualifiedName\" &&\n typeName.right?.type === \"Identifier\"\n ) {\n return typeName.right.name;\n }\n return null;\n}\n\nfunction legacyIdentifierName(node: any): string | null {\n if (node?.type === \"Identifier\") return node.name;\n if (node?.type === \"Literal\" && typeof node.value === \"string\") {\n return node.value;\n }\n return null;\n}\n\nfunction readObjectStringProperty(node: any, propertyName: string): string | null {\n const property = getObjectPropertyFromNode(node, propertyName);\n return property?.value?.type === \"Literal\" &&\n typeof property.value.value === \"string\"\n ? property.value.value\n : null;\n}\n\nfunction hasObjectProperty(node: any, propertyName: string): boolean {\n return getObjectPropertyFromNode(node, propertyName) !== null;\n}\n\nfunction readObjectLayoutProperty(node: any): CanvasEditorLayout | null {\n const property = getObjectPropertyFromNode(node, \"layout\");\n const layout = unwrapTsExpression(property?.value);\n if (!layout || layout.type !== \"ObjectExpression\") return null;\n\n const x = readObjectNumberProperty(layout, \"x\");\n const y = readObjectNumberProperty(layout, \"y\");\n const width = readObjectNumberProperty(layout, \"width\");\n const height = readObjectNumberProperty(layout, \"height\");\n if (x == null || y == null || width == null || height == null) {\n return null;\n }\n\n const zIndex = readObjectNumberProperty(layout, \"zIndex\");\n return {\n x,\n y,\n width,\n height,\n ...(zIndex == null ? {} : { zIndex }),\n };\n}\n\nfunction readObjectNumberProperty(node: any, propertyName: string): number | null {\n const property = getObjectPropertyFromNode(node, propertyName);\n const value = unwrapTsExpression(property?.value);\n if (value?.type === \"Literal\" && typeof value.value === \"number\") {\n return value.value;\n }\n if (\n value?.type === \"UnaryExpression\" &&\n value.operator === \"-\" &&\n value.argument?.type === \"Literal\" &&\n typeof value.argument.value === \"number\"\n ) {\n return -value.argument.value;\n }\n return null;\n}\n\nfunction getObjectPropertyFromNode(node: any, propertyName: string): any | null {\n const objectNode = unwrapTsExpression(node);\n if (!objectNode || objectNode.type !== \"ObjectExpression\") return null;\n for (const property of objectNode.properties ?? []) {\n if (property?.type !== \"Property\" || property.computed) continue;\n const key =\n property.key?.type === \"Identifier\"\n ? property.key.name\n : property.key?.type === \"Literal\" &&\n typeof property.key.value === \"string\"\n ? property.key.value\n : null;\n if (key === propertyName) return property;\n }\n return null;\n}\n\nfunction lastImportEnd(programBody: any[]): number | null {\n let end: number | null = null;\n for (const statement of programBody) {\n if (statement?.type !== \"ImportDeclaration\") continue;\n const span = nodeSpan(statement);\n if (span) end = Math.max(end ?? 0, span.end);\n }\n return end;\n}\n\nfunction nodeSpan(node: any): CanvasSourceSpan | null {\n return typeof node?.start === \"number\" &&\n typeof node?.end === \"number\" &&\n Number.isFinite(node.start) &&\n Number.isFinite(node.end)\n ? { start: node.start, end: node.end }\n : null;\n}\n\nfunction collectSourceIdentifiers(source: string): Set<string> {\n return new Set(\n Array.from(source.matchAll(/\\b[A-Za-z_$][\\w$]*\\b/g), (match) => match[0]),\n );\n}\n\nfunction pickAvailableSourceIdentifier(used: Set<string>, base: string): string {\n const normalizedBase = /^[A-Za-z_$]/.test(base) ? base : `Canvas${base}`;\n if (!used.has(normalizedBase)) return normalizedBase;\n for (let index = 2; index < 10_000; index += 1) {\n const candidate = `${normalizedBase}${index}`;\n if (!used.has(candidate)) return candidate;\n }\n throw new Error(`Unable to find available identifier for ${base}`);\n}\n\nfunction toPascalIdentifier(value: string): string {\n const identifier = value\n .split(/[^A-Za-z0-9_$]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n return identifier || \"Canvas\";\n}\n\nfunction lineIndentAt(source: string, offset: number): string {\n const lineStart = Math.max(source.lastIndexOf(\"\\n\", offset - 1) + 1, 0);\n const linePrefix = source.slice(lineStart, offset);\n const match = linePrefix.match(/^[ \\t]*/);\n return match?.[0] ?? \"\";\n}\n\nfunction previousMeaningfulCharacter(source: string, offset: number): string {\n for (let index = offset - 1; index >= 0; index -= 1) {\n const character = source[index] ?? \"\";\n if (!/\\s/.test(character)) return character;\n }\n return \"\";\n}\n\nfunction trimWhitespaceBeforeOffset(source: string, offset: number): number {\n let nextOffset = offset;\n while (nextOffset > 0 && /\\s/.test(source[nextOffset - 1] ?? \"\")) {\n nextOffset--;\n }\n return nextOffset;\n}\n\nfunction collapseBlankLines(source: string, newline: string): string {\n return newline === \"\\r\\n\"\n ? source.replace(/(\\r\\n){3,}/g, \"\\r\\n\\r\\n\")\n : source.replace(/\\n{3,}/g, \"\\n\\n\");\n}\n\nfunction detectNewline(source: string): \"\\n\" | \"\\r\\n\" {\n return source.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n}\n\nfunction topLevelInsertionOffset(source: string): number {\n let offset = 0;\n if (source.startsWith(\"#!\")) {\n const newline = source.indexOf(\"\\n\");\n offset = newline >= 0 ? newline + 1 : source.length;\n }\n\n while (true) {\n const nextLineEnd = source.indexOf(\"\\n\", offset);\n const end = nextLineEnd >= 0 ? nextLineEnd + 1 : source.length;\n const line = source.slice(offset, end).trim();\n if (!/^[\"']use [^\"']+[\"'];?$/.test(line)) break;\n offset = end;\n }\n\n return offset;\n}\n\nfunction pickAvailableIdentifier(parsed: ParsedCanvasFile, base: string): string {\n const usedImports = new Set(parsed.imports.map((item) => item.localName));\n if (!usedImports.has(base)) return base;\n for (let index = 2; index < 10_000; index += 1) {\n const candidate = `${base}${index}`;\n if (!usedImports.has(candidate)) return candidate;\n }\n throw new Error(`Unable to find available identifier for ${base}`);\n}\n\nfunction hasIdentifier(source: string, identifier: string): boolean {\n return new RegExp(`\\\\b${escapeRegExp(identifier)}\\\\b`).test(source);\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction roundLayoutNumber(value: number): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new Error(\"Layout values must be finite numbers\");\n }\n return Math.round(value);\n}\n\nfunction requireNonEmpty(value: string, label: string): string {\n const trimmed = value.trim();\n if (!trimmed) {\n throw new Error(`${label} must be non-empty`);\n }\n return trimmed;\n}\n\nfunction requiredSpan<T>(value: T | undefined, message: string): T {\n if (value === undefined) {\n throw new Error(message);\n }\n return value;\n}\n"],"mappings":";;;;;;;AASA,SAAS,iBAAiB;AA0DnB,SAAS,uBACd,QACA,OACQ;AACR,QAAM,SAAS,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,UAAU,MAAM,QAAQ,KAAK,KAAK;AACxE,MAAI,gBAAgB,OAAO,SAAS;AACpC,MAAI,aAAa;AAEjB,aAAW,QAAQ,QAAQ;AACzB,QACE,KAAK,QAAQ,KACb,KAAK,MAAM,KAAK,SAChB,KAAK,MAAM,OAAO,UAClB,KAAK,MAAM,eACX;AACA,YAAM,IAAI,MAAM,0CAA0C,KAAK,KAAK,IAAI,KAAK,GAAG,EAAE;AAAA,IACpF;AACA,iBACE,WAAW,MAAM,GAAG,KAAK,KAAK,IAAI,KAAK,QAAQ,WAAW,MAAM,KAAK,GAAG;AAC1E,oBAAgB,KAAK;AAAA,EACvB;AAEA,SAAO;AACT;AAEO,SAAS,2BAA2B,SAGX;AAC9B,QAAM,WAAW,gBAAgB,QAAQ,UAAU,QAAQ,MAAM;AACjE,MAAI,SAAS,mBAAmB;AAC9B,WAAO;AAAA,MACL,QAAQ,QAAQ;AAAA,MAChB,OAAO,CAAC;AAAA,MACR,QAAQ;AAAA,MACR,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,SAAS,0BAA0B,QAAQ,UAAU,QAAQ,MAAM;AACzE,MAAI,OAAO,YAAY,SAAS,GAAG;AACjC,UAAM,IAAI,MAAM,OAAO,YAAY,KAAK,IAAI,CAAC;AAAA,EAC/C;AAEA,QAAM,UAAU,cAAc,QAAQ,MAAM;AAC5C,QAAM,QAA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ACzB;AACA,SAAO;AACT;","names":["edit","sourceWithoutImport"]}
|
|
1
|
+
{"version":3,"sources":["../../canvas/editor.ts"],"sourcesContent":["import { parseSync } from \"oxc-parser\";\n\nimport {\n parseCanvasFile,\n type CanvasSourceSpan,\n type ParsedCanvasFile,\n type ParsedCanvasImport,\n type ParsedCanvasStoryboard,\n} from \"./parser\";\n\nexport type CanvasSourceEdit = {\n start: number;\n end: number;\n value: string;\n};\n\nexport type CanvasEditResult = {\n source: string;\n edits: CanvasSourceEdit[];\n parsed: ParsedCanvasFile;\n};\n\nexport type CanvasEditorLayout = {\n x: number;\n y: number;\n width: number;\n height: number;\n zIndex?: number;\n intrinsicSizing?: \"root-element\";\n};\n\nexport type AddCanvasStoryboardInput =\n | {\n kind: \"component\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n componentExpression?: string;\n // Pre-formatted object-literal expression (e.g. `{ a: \"s\", b: expr }`)\n // emitted as `props={<value>}` after `component=`. Used by migration to\n // render `render: () => <C a={b} />` as `component={C} props={{ a: b }}`.\n props?: string;\n componentImport?: {\n localName: string;\n source: string;\n importedName?: string;\n };\n }\n | {\n // Per-storyboard fallback for legacy object shapes migration cannot\n // convert natively: emits `<LegacyStoryboardV1 id storyboard={Expr} />`.\n // The wrapper reads name/layout off the referenced object, so no\n // name/layout attributes are emitted here.\n kind: \"legacy-v1\";\n id: string;\n storyboardExpression: string;\n }\n | {\n kind: \"route\";\n id: string;\n route: string;\n layout: CanvasEditorLayout;\n name?: string;\n }\n | {\n kind: \"html\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n filepath?: string;\n src?: string;\n };\n\ntype SdkComponent =\n | \"Storyboard\"\n | \"LegacyStoryboardV1\"\n | \"RouteStoryboard\"\n | \"HtmlStoryboard\";\n\nexport function applyCanvasSourceEdits(\n source: string,\n edits: readonly CanvasSourceEdit[],\n): string {\n const sorted = [...edits].sort((left, right) => right.start - left.start);\n let previousStart = source.length + 1;\n let nextSource = source;\n\n for (const edit of sorted) {\n if (\n edit.start < 0 ||\n edit.end < edit.start ||\n edit.end > source.length ||\n edit.end > previousStart\n ) {\n throw new Error(\n `Invalid overlapping canvas source edit ${edit.start}:${edit.end}`,\n );\n }\n nextSource =\n nextSource.slice(0, edit.start) + edit.value + nextSource.slice(edit.end);\n previousStart = edit.start;\n }\n\n return nextSource;\n}\n\nexport function updateCanvasName(options: {\n filePath: string;\n source: string;\n name: string;\n}): CanvasEditResult {\n return editCanvasStringAttribute(\n options,\n \"name\",\n requireNonEmpty(options.name, \"Canvas name\"),\n (parsed) => ({\n valueSpan: parsed.nameSpan,\n attributeSpan: parsed.nameAttributeSpan,\n }),\n );\n}\n\nexport function updateCanvasPath(options: {\n filePath: string;\n source: string;\n path: string;\n}): CanvasEditResult {\n return editCanvasStringAttribute(\n options,\n \"path\",\n requireNonEmpty(options.path, \"Canvas path\"),\n (parsed) => ({\n valueSpan: parsed.pathSpan,\n attributeSpan: parsed.pathAttributeSpan,\n }),\n );\n}\n\nexport function updateCanvasBackgroundColor(options: {\n filePath: string;\n source: string;\n backgroundColor?: string;\n}): CanvasEditResult {\n return editCanvasStringAttribute(\n options,\n \"backgroundColor\",\n options.backgroundColor && options.backgroundColor.trim() !== \"\"\n ? options.backgroundColor\n : undefined,\n (parsed) => ({\n valueSpan: parsed.backgroundColorSpan,\n attributeSpan: parsed.backgroundColorAttributeSpan,\n }),\n );\n}\n\nfunction editCanvasStringAttribute(\n options: { filePath: string; source: string },\n attributeName: string,\n value: string | undefined,\n selectSpans: (parsed: ParsedCanvasFile) => {\n valueSpan?: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n },\n): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const spans = selectSpans(parsed);\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requiredSpan(\n parsed.canvasOpeningElementSpan,\n \"Canvas opening element not found\",\n ),\n valueSpan: spans.valueSpan,\n attributeSpan: spans.attributeSpan,\n name: attributeName,\n value,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n}\n\nexport function updateStoryboardName(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n name?: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.legacyV1) {\n const edit = upsertObjectStringProperty({\n source: options.source,\n objectClose: storyboard.legacyV1.objectClose,\n valueSpan: storyboard.nameSpan,\n propertySpan: storyboard.legacyV1.namePropertySpan,\n name: \"name\",\n value:\n options.name && options.name.trim() !== \"\" ? options.name : undefined,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n }\n\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n valueSpan: storyboard.nameSpan,\n attributeSpan: storyboard.nameAttributeSpan,\n name: \"name\",\n value:\n options.name && options.name.trim() !== \"\" ? options.name : undefined,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n}\n\nexport function updateStoryboardId(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n nextId: string;\n}): CanvasEditResult {\n const nextId = requireNonEmpty(options.nextId, \"Storyboard id\");\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const duplicate = parsed.storyboards.find(\n (item) =>\n item.storyboardKey === nextId &&\n item.storyboardKey !== storyboard.storyboardKey,\n );\n if (duplicate) {\n throw new Error(`Storyboard id \"${nextId}\" already exists`);\n }\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n valueSpan: storyboard.idSpan,\n attributeSpan: storyboard.idAttributeSpan,\n name: \"id\",\n value: nextId,\n });\n return applyResult(options.source, parsed, [edit]);\n}\n\nexport function updateStoryboardLayout(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n layout: Partial<CanvasEditorLayout>;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const spans = storyboard.layoutSpans;\n if (!spans) {\n throw new Error(\n `Storyboard \"${options.storyboardId}\" has no editable layout`,\n );\n }\n\n const edits: CanvasSourceEdit[] = [];\n for (const key of [\"x\", \"y\", \"width\", \"height\"] as const) {\n if (options.layout[key] === undefined) continue;\n const span = spans[key];\n if (!span) {\n throw new Error(\n `Storyboard \"${options.storyboardId}\" layout.${key} is not editable`,\n );\n }\n edits.push({\n start: span.start,\n end: span.end,\n value: String(roundLayoutNumber(options.layout[key])),\n });\n }\n\n if (options.layout.zIndex !== undefined) {\n const value = String(roundLayoutNumber(options.layout.zIndex));\n edits.push(\n spans.zIndex\n ? { start: spans.zIndex.start, end: spans.zIndex.end, value }\n : insertLayoutProperty(options.source, spans, `zIndex: ${value}`),\n );\n }\n\n if (options.layout.intrinsicSizing !== undefined) {\n const value = JSON.stringify(options.layout.intrinsicSizing);\n edits.push(\n spans.intrinsicSizing\n ? {\n start: spans.intrinsicSizing.start,\n end: spans.intrinsicSizing.end,\n value,\n }\n : insertLayoutProperty(\n options.source,\n spans,\n `intrinsicSizing: ${value}`,\n ),\n );\n }\n\n return applyResult(options.source, parsed, edits);\n}\n\nexport function updateStoryboardComponent(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n componentExpression: string;\n componentImport?: {\n localName: string;\n source: string;\n importedName?: string;\n };\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.kind !== \"component\") {\n throw new Error(\n `Storyboard \"${options.storyboardId}\" is not a component storyboard`,\n );\n }\n\n const imports: string[] = [];\n if (options.componentImport) {\n const importLine = buildMissingComponentImportLine(\n parsed,\n options.source,\n options.componentImport,\n );\n if (importLine) imports.push(importLine);\n }\n\n const importEdit = buildImportInsertionEdit(options.source, parsed, imports);\n const componentEdit = upsertJsxExpressionAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n expressionSpan: storyboard.component?.span,\n attributeSpan: storyboard.component?.attributeSpan,\n name: \"component\",\n value: requireNonEmpty(\n options.componentExpression,\n \"Storyboard component expression\",\n ),\n });\n\n return applyResult(options.source, parsed, [\n ...(importEdit ? [importEdit] : []),\n componentEdit,\n ]);\n}\n\nexport function updateStoryboardProps(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n propsExpression?: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const edit = upsertJsxExpressionAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n expressionSpan: storyboard.props?.span,\n attributeSpan: storyboard.props?.attributeSpan,\n name: \"props\",\n value:\n options.propsExpression && options.propsExpression.trim() !== \"\"\n ? options.propsExpression.trim()\n : undefined,\n });\n return applyResult(options.source, parsed, edit ? [edit] : []);\n}\n\nexport function updateRouteStoryboardRoute(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n route: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.kind !== \"route\") {\n throw new Error(\n `Storyboard \"${options.storyboardId}\" is not a route storyboard`,\n );\n }\n const edit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan: requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n ),\n valueSpan: storyboard.routeSpan,\n attributeSpan: storyboard.routeAttributeSpan,\n name: \"route\",\n value: requireNonEmpty(options.route, \"Route storyboard route\"),\n });\n return applyResult(options.source, parsed, [edit]);\n}\n\nexport function updateHtmlStoryboardSource(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n filepath?: string;\n src?: string;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n if (storyboard.kind !== \"html\") {\n throw new Error(\n `Storyboard \"${options.storyboardId}\" is not an html storyboard`,\n );\n }\n const filepath =\n options.filepath && options.filepath.trim() !== \"\"\n ? options.filepath.trim()\n : undefined;\n const src =\n options.src && options.src.trim() !== \"\" ? options.src : undefined;\n if (!filepath && !src) {\n throw new Error(\"HTML storyboard source requires filepath or src\");\n }\n\n const openingElementSpan = requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n );\n const filepathEdit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan,\n valueSpan: storyboard.filepathSpan,\n attributeSpan: storyboard.filepathAttributeSpan,\n name: \"filepath\",\n value: filepath,\n });\n const srcEdit = upsertJsxStringAttribute({\n source: options.source,\n openingElementSpan,\n valueSpan: storyboard.srcSpan,\n attributeSpan: storyboard.srcAttributeSpan,\n name: \"src\",\n value: src,\n });\n\n return applyResult(options.source, parsed, [filepathEdit, srcEdit]);\n}\n\nexport function addCanvasStoryboard(options: {\n filePath: string;\n source: string;\n storyboard: AddCanvasStoryboardInput;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n if (\n parsed.storyboards.some(\n (item) => item.storyboardKey === options.storyboard.id,\n )\n ) {\n throw new Error(`Storyboard id \"${options.storyboard.id}\" already exists`);\n }\n\n const imports: string[] = [];\n const sdkComponent = sdkComponentForStoryboard(options.storyboard.kind);\n const sdkTag = resolveSdkTag(parsed, sdkComponent);\n let storyboardTag = sdkTag.tag;\n if (sdkTag.importLine) {\n imports.push(sdkTag.importLine);\n storyboardTag = sdkTag.tag;\n }\n\n let componentExpression: string | undefined;\n if (options.storyboard.kind === \"component\") {\n componentExpression =\n options.storyboard.componentExpression ??\n options.storyboard.componentImport?.localName;\n if (!componentExpression) {\n throw new Error(\n \"Component storyboard requires componentExpression or componentImport\",\n );\n }\n if (options.storyboard.componentImport) {\n const importLine = buildMissingComponentImportLine(\n parsed,\n options.source,\n options.storyboard.componentImport,\n );\n if (importLine) imports.push(importLine);\n }\n }\n\n const importEdit = buildImportInsertionEdit(options.source, parsed, imports);\n const insertionEdit = buildCanvasChildInsertionEdit({\n source: options.source,\n parsed,\n tag: storyboardTag,\n storyboard: options.storyboard,\n componentExpression,\n });\n\n const edits = [...(importEdit ? [importEdit] : []), insertionEdit];\n return applyResult(options.source, parsed, edits);\n}\n\nexport function removeCanvasStoryboard(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n removeUnusedComponentImport?: boolean;\n}): CanvasEditResult {\n const parsed = parseCanvasFile(options.filePath, options.source);\n const storyboard = findStoryboard(parsed, options.storyboardId);\n const edits: CanvasSourceEdit[] = [\n {\n ...expandToFullLines(options.source, storyboard.jsxElementSpan),\n value: \"\",\n },\n ];\n\n if (options.removeUnusedComponentImport ?? true) {\n const importEdit = buildUnusedComponentImportRemoval({\n source: options.source,\n parsed,\n deletedStoryboard: storyboard,\n deletionEdit: edits[0],\n });\n if (importEdit) edits.push(importEdit);\n }\n\n const result = applyResult(options.source, parsed, edits);\n return {\n ...result,\n source: collapseBlankLines(result.source, detectNewline(options.source)),\n };\n}\n\nfunction applyResult(\n source: string,\n parsed: ParsedCanvasFile,\n edits: readonly (CanvasSourceEdit | null | undefined)[],\n): CanvasEditResult {\n const compactEdits = edits.filter((edit): edit is CanvasSourceEdit => {\n if (!edit) return false;\n return source.slice(edit.start, edit.end) !== edit.value;\n });\n return {\n source: applyCanvasSourceEdits(source, compactEdits),\n edits: compactEdits,\n parsed,\n };\n}\n\nfunction findStoryboard(\n parsed: ParsedCanvasFile,\n storyboardId: string,\n): ParsedCanvasStoryboard {\n const storyboard = parsed.storyboards.find(\n (item) => item.storyboardKey === storyboardId,\n );\n if (!storyboard) {\n throw new Error(`Storyboard \"${storyboardId}\" not found`);\n }\n return storyboard;\n}\n\nfunction requireStoryboardOpeningSpan(\n storyboard: ParsedCanvasStoryboard,\n storyboardId: string,\n): CanvasSourceSpan {\n return requiredSpan(\n storyboard.openingElementSpan,\n `Storyboard \"${storyboardId}\" opening element not found`,\n );\n}\n\nfunction upsertJsxStringAttribute(options: {\n source: string;\n openingElementSpan: CanvasSourceSpan;\n valueSpan?: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n name: string;\n value?: string;\n}): CanvasSourceEdit | null {\n if (options.value === undefined) {\n if (!options.attributeSpan) return null;\n return {\n ...expandJsxAttributeRemoval(options.source, options.attributeSpan),\n value: \"\",\n };\n }\n\n const value = JSON.stringify(options.value);\n if (options.valueSpan) {\n return {\n start: options.valueSpan.start,\n end: options.valueSpan.end,\n value,\n };\n }\n\n const offset = findOpeningElementAttributeInsertionOffset(\n options.source,\n options.openingElementSpan,\n );\n return {\n start: offset,\n end: offset,\n value: ` ${options.name}={${value}}`,\n };\n}\n\nfunction upsertObjectStringProperty(options: {\n source: string;\n objectClose?: number;\n valueSpan?: CanvasSourceSpan;\n propertySpan?: CanvasSourceSpan;\n name: string;\n value?: string;\n}): CanvasSourceEdit | null {\n if (options.value === undefined) {\n if (!options.propertySpan) return null;\n return {\n ...expandObjectPropertyRemoval(options.source, options.propertySpan),\n value: \"\",\n };\n }\n\n const value = JSON.stringify(options.value);\n if (options.valueSpan) {\n return {\n start: options.valueSpan.start,\n end: options.valueSpan.end,\n value,\n };\n }\n\n if (typeof options.objectClose !== \"number\") {\n throw new Error(`Object close not found for \"${options.name}\" property`);\n }\n\n return insertObjectProperty(\n options.source,\n options.objectClose,\n `${options.name}: ${value}`,\n );\n}\n\nfunction upsertJsxExpressionAttribute(options: {\n source: string;\n openingElementSpan: CanvasSourceSpan;\n expressionSpan?: CanvasSourceSpan;\n attributeSpan?: CanvasSourceSpan;\n name: string;\n value?: string;\n}): CanvasSourceEdit | null {\n if (options.value === undefined) {\n if (!options.attributeSpan) return null;\n return {\n ...expandJsxAttributeRemoval(options.source, options.attributeSpan),\n value: \"\",\n };\n }\n\n if (options.expressionSpan) {\n return {\n start: options.expressionSpan.start,\n end: options.expressionSpan.end,\n value: options.value,\n };\n }\n\n const offset = findOpeningElementAttributeInsertionOffset(\n options.source,\n options.openingElementSpan,\n );\n return {\n start: offset,\n end: offset,\n value: ` ${options.name}={${options.value}}`,\n };\n}\n\nfunction insertLayoutProperty(\n source: string,\n spans: NonNullable<ParsedCanvasStoryboard[\"layoutSpans\"]>,\n propertySource: string,\n): CanvasSourceEdit {\n if (typeof spans.layoutClose !== \"number\") {\n throw new Error(\"Layout object close span not found\");\n }\n return insertObjectProperty(source, spans.layoutClose, propertySource);\n}\n\nfunction insertObjectProperty(\n source: string,\n objectClose: number,\n propertySource: string,\n): CanvasSourceEdit {\n const offset = trimWhitespaceBeforeOffset(source, objectClose);\n const previous = previousMeaningfulCharacter(source, offset);\n return {\n start: offset,\n end: offset,\n value: `${previous === \"{\" || previous === \",\" ? \" \" : \", \"}${propertySource}`,\n };\n}\n\nfunction formatStoryboardElement(options: {\n source: string;\n insertionOffset: number;\n tag: string;\n storyboard: AddCanvasStoryboardInput;\n componentExpression?: string;\n}): string {\n const newline = detectNewline(options.source);\n const closingIndent = lineIndentAt(options.source, options.insertionOffset);\n const indent = `${closingIndent} `;\n const firstLineIndent = \" \";\n const propIndent = `${indent} `;\n const props = storyboardElementProps(\n options.storyboard,\n options.componentExpression,\n );\n\n return `${firstLineIndent}<${options.tag}${newline}${props\n .map((prop) => `${propIndent}${prop}`)\n .join(newline)}${newline}${indent}/>${newline}${closingIndent}`;\n}\n\nfunction buildCanvasChildInsertionEdit(options: {\n source: string;\n parsed: ParsedCanvasFile;\n tag: string;\n storyboard: AddCanvasStoryboardInput;\n componentExpression?: string;\n}): CanvasSourceEdit {\n const insertionOffset = options.parsed.canvasChildrenInsertionOffset;\n if (typeof insertionOffset === \"number\") {\n return {\n start: insertionOffset,\n end: insertionOffset,\n value: formatStoryboardElement({\n source: options.source,\n insertionOffset,\n tag: options.tag,\n storyboard: options.storyboard,\n componentExpression: options.componentExpression,\n }),\n };\n }\n\n const openingSpan = options.parsed.canvasOpeningElementSpan;\n if (!openingSpan) {\n throw new Error(\"Canvas closing element not found\");\n }\n\n const openingSource = options.source.slice(\n openingSpan.start,\n openingSpan.end,\n );\n const selfClosingMatch = openingSource.match(/\\s*\\/\\s*>$/);\n const canvasName = openingSource.match(\n /^<\\s*([A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*)/,\n )?.[1];\n if (!selfClosingMatch || !canvasName) {\n throw new Error(\"Canvas closing element not found\");\n }\n\n const newline = detectNewline(options.source);\n const replacementStart = openingSpan.end - selfClosingMatch[0].length;\n const closingIndent = lineIndentAt(options.source, openingSpan.start);\n const childIndent = `${closingIndent} `;\n const propIndent = `${childIndent} `;\n const props = storyboardElementProps(\n options.storyboard,\n options.componentExpression,\n );\n\n return {\n start: replacementStart,\n end: openingSpan.end,\n value: `>${newline}${childIndent}<${options.tag}${newline}${props\n .map((prop) => `${propIndent}${prop}`)\n .join(\n newline,\n )}${newline}${childIndent}/>${newline}${closingIndent}</${canvasName}>`,\n };\n}\n\nfunction storyboardElementProps(\n storyboard: AddCanvasStoryboardInput,\n componentExpression?: string,\n): string[] {\n const idProp = formatJsxStringAttribute(\n \"id\",\n requireNonEmpty(storyboard.id, \"Storyboard id\"),\n );\n\n // LegacyStoryboardV1 carries only `id` + `storyboard={Expr}`; name and\n // layout live on the referenced object, so they are never emitted here.\n if (storyboard.kind === \"legacy-v1\") {\n return [idProp, `storyboard={${storyboard.storyboardExpression}}`];\n }\n\n return [\n idProp,\n ...(storyboard.name && storyboard.name.trim() !== \"\"\n ? [formatJsxStringAttribute(\"name\", storyboard.name)]\n : []),\n ...storyboardKindProps(storyboard, componentExpression),\n `layout={{ ${formatLayout(storyboard.layout)} }}`,\n ];\n}\n\n/**\n * Format a JSX string attribute. Prefers the idiomatic plain form\n * (`name=\"value\"`) and falls back to the expression form (`name={\"value\"}`)\n * when the plain form can't represent the value faithfully: JSX string\n * attributes don't process backslash escapes but DO decode HTML entities, so\n * any value that JSON-escapes (quotes, backslashes, control characters) or\n * contains `&` must go through a braced string literal.\n */\nexport function formatJsxStringAttribute(name: string, value: string): string {\n const encoded = JSON.stringify(value);\n const plainSafe = encoded === `\"${value}\"` && !value.includes(\"&\");\n return plainSafe ? `${name}=${encoded}` : `${name}={${encoded}}`;\n}\n\nfunction storyboardKindProps(\n // legacy-v1 never reaches here: `storyboardElementProps` emits its\n // `storyboard={…}` prop directly (it has no name/layout attributes).\n storyboard: Exclude<AddCanvasStoryboardInput, { kind: \"legacy-v1\" }>,\n componentExpression?: string,\n): string[] {\n if (storyboard.kind === \"component\") {\n return [\n `component={${componentExpression}}`,\n ...(storyboard.props && storyboard.props.trim() !== \"\"\n ? [`props={${storyboard.props.trim()}}`]\n : []),\n ];\n }\n if (storyboard.kind === \"route\") {\n return [formatJsxStringAttribute(\"route\", storyboard.route)];\n }\n return [\n ...(storyboard.filepath\n ? [formatJsxStringAttribute(\"filepath\", storyboard.filepath)]\n : []),\n ...(storyboard.src\n ? [formatJsxStringAttribute(\"src\", storyboard.src)]\n : []),\n ];\n}\n\nfunction formatLayout(layout: CanvasEditorLayout): string {\n return [\n `x: ${roundLayoutNumber(layout.x)}`,\n `y: ${roundLayoutNumber(layout.y)}`,\n `width: ${roundLayoutNumber(layout.width)}`,\n `height: ${roundLayoutNumber(layout.height)}`,\n ...(layout.zIndex === undefined\n ? []\n : [`zIndex: ${roundLayoutNumber(layout.zIndex)}`]),\n ...(layout.intrinsicSizing\n ? [`intrinsicSizing: ${JSON.stringify(layout.intrinsicSizing)}`]\n : []),\n ].join(\", \");\n}\n\nfunction sdkComponentForStoryboard(\n kind: AddCanvasStoryboardInput[\"kind\"],\n): SdkComponent {\n if (kind === \"route\") return \"RouteStoryboard\";\n if (kind === \"html\") return \"HtmlStoryboard\";\n if (kind === \"legacy-v1\") return \"LegacyStoryboardV1\";\n return \"Storyboard\";\n}\n\nfunction resolveSdkTag(\n parsed: ParsedCanvasFile,\n component: SdkComponent,\n): { tag: string; importLine?: string } {\n for (const item of parsed.imports) {\n if (item.source !== \"tempo-sdk/canvas\") continue;\n if (item.kind === \"namespace\")\n return { tag: `${item.localName}.${component}` };\n if (item.importedName === component) return { tag: item.localName };\n }\n\n const localName = pickAvailableIdentifier(parsed, `TempoCanvas${component}`);\n return {\n tag: localName,\n importLine: `import { ${component} as ${localName} } from \"tempo-sdk/canvas\";`,\n };\n}\n\nfunction buildMissingComponentImportLine(\n parsed: ParsedCanvasFile,\n source: string,\n componentImport: {\n localName: string;\n source: string;\n importedName?: string;\n },\n): string | null {\n const existing = parsed.imports.find(\n (item) => item.localName === componentImport.localName,\n );\n if (existing) {\n if (existing.source !== componentImport.source) {\n throw new Error(\n `Import binding \"${componentImport.localName}\" already exists`,\n );\n }\n return null;\n }\n // Collision check that THROWS — must not fire on the name merely appearing\n // inside a string literal (e.g. `<Canvas name=\"Card Demo\">` blocking a `Card`\n // import), so use the AST-based node scan, never the textual `hasIdentifier`.\n if (\n sourceContainsIdentifierNode(\n parsed.filePath,\n source,\n componentImport.localName,\n )\n ) {\n throw new Error(`Identifier \"${componentImport.localName}\" already exists`);\n }\n\n if (\n !componentImport.importedName ||\n componentImport.importedName === \"default\"\n ) {\n return `import ${componentImport.localName} from ${JSON.stringify(\n componentImport.source,\n )};`;\n }\n\n const specifier =\n componentImport.importedName === componentImport.localName\n ? componentImport.localName\n : `${componentImport.importedName} as ${componentImport.localName}`;\n return `import { ${specifier} } from ${JSON.stringify(componentImport.source)};`;\n}\n\nfunction buildImportInsertionEdit(\n source: string,\n parsed: ParsedCanvasFile,\n importLines: readonly string[],\n): CanvasSourceEdit | null {\n if (importLines.length === 0) return null;\n const newline = detectNewline(source);\n const uniqueLines = Array.from(new Set(importLines));\n const lastImport = parsed.imports.reduce<ParsedCanvasImport | null>(\n (latest, item) =>\n !latest || item.declarationSpan.end > latest.declarationSpan.end\n ? item\n : latest,\n null,\n );\n\n if (lastImport) {\n return {\n start: lastImport.declarationSpan.end,\n end: lastImport.declarationSpan.end,\n value: `${newline}${uniqueLines.join(newline)}`,\n };\n }\n\n const offset = topLevelInsertionOffset(source);\n return {\n start: offset,\n end: offset,\n value: `${uniqueLines.join(newline)}${newline}`,\n };\n}\n\nfunction buildUnusedComponentImportRemoval(options: {\n source: string;\n parsed: ParsedCanvasFile;\n deletedStoryboard: ParsedCanvasStoryboard;\n deletionEdit: CanvasSourceEdit;\n}): CanvasSourceEdit | null {\n const componentImport = options.deletedStoryboard.component?.import;\n if (!componentImport || componentImport.importKind === \"type\") return null;\n\n const usedByRemainingStoryboard = options.parsed.storyboards.some(\n (storyboard) =>\n storyboard.storyboardKey !== options.deletedStoryboard.storyboardKey &&\n storyboard.component?.import?.localName === componentImport.localName,\n );\n if (usedByRemainingStoryboard) return null;\n\n const sourceAfterStoryboardDelete = applyCanvasSourceEdits(options.source, [\n options.deletionEdit,\n ]);\n\n if (componentImport.specifierCount === 1) {\n const sourceWithoutImport = removeSpanText(\n sourceAfterStoryboardDelete,\n componentImport.declarationSpan,\n );\n if (hasIdentifier(sourceWithoutImport, componentImport.localName))\n return null;\n\n return {\n ...expandToFullLines(options.source, componentImport.declarationSpan),\n value: \"\",\n };\n }\n\n if (\n componentImport.kind !== \"named\" ||\n componentImport.hasDefaultSpecifier ||\n componentImport.hasNamespaceSpecifier ||\n componentImport.namedSpecifierCount <= 1\n ) {\n return null;\n }\n\n const specifierRange = expandImportSpecifierRemovalRange(\n options.source,\n componentImport.span,\n );\n const sourceWithoutImport = removeSpanText(\n sourceAfterStoryboardDelete,\n specifierRange,\n );\n if (hasIdentifier(sourceWithoutImport, componentImport.localName))\n return null;\n\n return {\n ...specifierRange,\n value: \"\",\n };\n}\n\nfunction expandImportSpecifierRemovalRange(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n const lineStart = Math.max(source.lastIndexOf(\"\\n\", span.start - 1) + 1, 0);\n const nextNewline = source.indexOf(\"\\n\", span.end);\n const lineEnd = nextNewline >= 0 ? nextNewline + 1 : source.length;\n const before = source.slice(lineStart, span.start);\n const after = source.slice(span.end, lineEnd);\n if (/^[ \\t]*$/.test(before) && /^[ \\t]*(,)?[ \\t]*(\\r?\\n)?$/.test(after)) {\n return { start: lineStart, end: lineEnd };\n }\n\n let start = span.start;\n let end = span.end;\n while (end < source.length && /\\s/.test(source[end] ?? \"\")) end++;\n if (source[end] === \",\") {\n end++;\n while (\n end < source.length &&\n (source[end] === \" \" || source[end] === \"\\t\")\n ) {\n end++;\n }\n return { start, end };\n }\n\n while (\n start > 0 &&\n (source[start - 1] === \" \" || source[start - 1] === \"\\t\")\n ) {\n start--;\n }\n if (source[start - 1] === \",\") {\n start--;\n while (\n start > 0 &&\n (source[start - 1] === \" \" || source[start - 1] === \"\\t\")\n ) {\n start--;\n }\n }\n return { start, end };\n}\n\nfunction removeSpanText(source: string, span: CanvasSourceSpan): string {\n return source.slice(0, span.start) + source.slice(span.end);\n}\n\nfunction findOpeningElementAttributeInsertionOffset(\n source: string,\n span: CanvasSourceSpan,\n): number {\n const close = source.lastIndexOf(\">\", span.end - 1);\n if (close < span.start) {\n throw new Error(\"JSX opening element close not found\");\n }\n return source[close - 1] === \"/\" ? close - 1 : close;\n}\n\nfunction expandJsxAttributeRemoval(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let start = span.start;\n let end = span.end;\n\n while (\n start > 0 &&\n (source[start - 1] === \" \" || source[start - 1] === \"\\t\")\n ) {\n start--;\n }\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n return { start, end };\n}\n\nfunction expandObjectPropertyRemoval(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let start = span.start;\n let end = span.end;\n\n while (start > 0 && /\\s/.test(source[start - 1] ?? \"\")) start--;\n while (end < source.length && /\\s/.test(source[end] ?? \"\")) end++;\n\n if (source[end] === \",\") {\n end++;\n while (\n end < source.length &&\n (source[end] === \" \" || source[end] === \"\\t\")\n ) {\n end++;\n }\n return { start, end };\n }\n\n let comma = start - 1;\n while (comma >= 0 && /\\s/.test(source[comma] ?? \"\")) comma--;\n if (source[comma] === \",\") {\n start = comma;\n }\n return { start, end };\n}\n\nexport function expandToFullLines(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let start = span.start;\n let end = span.end;\n while (\n start > 0 &&\n source[start - 1] !== \"\\n\" &&\n source[start - 1] !== \"\\r\"\n ) {\n start--;\n }\n if (start > 0) {\n if (source[start - 1] === \"\\n\") start--;\n if (start > 0 && source[start - 1] === \"\\r\") start--;\n }\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n if (source.slice(end, end + 2) === \"\\r\\n\") {\n end += 2;\n } else if (source[end] === \"\\n\" || source[end] === \"\\r\") {\n end++;\n }\n return { start, end };\n}\n\nexport function expandStatementForward(\n source: string,\n span: CanvasSourceSpan,\n): CanvasSourceSpan {\n let end = span.end;\n while (end < source.length && (source[end] === \" \" || source[end] === \"\\t\")) {\n end++;\n }\n if (source.slice(end, end + 2) === \"\\r\\n\") {\n end += 2;\n } else if (source[end] === \"\\n\" || source[end] === \"\\r\") {\n end++;\n }\n return { start: span.start, end };\n}\n\nfunction lineIndentAt(source: string, offset: number): string {\n const lineStart = Math.max(source.lastIndexOf(\"\\n\", offset - 1) + 1, 0);\n const linePrefix = source.slice(lineStart, offset);\n const match = linePrefix.match(/^[ \\t]*/);\n return match?.[0] ?? \"\";\n}\n\nfunction previousMeaningfulCharacter(source: string, offset: number): string {\n for (let index = offset - 1; index >= 0; index -= 1) {\n const character = source[index] ?? \"\";\n if (!/\\s/.test(character)) return character;\n }\n return \"\";\n}\n\nfunction trimWhitespaceBeforeOffset(source: string, offset: number): number {\n let nextOffset = offset;\n while (nextOffset > 0 && /\\s/.test(source[nextOffset - 1] ?? \"\")) {\n nextOffset--;\n }\n return nextOffset;\n}\n\nexport function collapseBlankLines(source: string, newline: string): string {\n return newline === \"\\r\\n\"\n ? source.replace(/(\\r\\n){3,}/g, \"\\r\\n\\r\\n\")\n : source.replace(/\\n{3,}/g, \"\\n\\n\");\n}\n\nexport function detectNewline(source: string): \"\\n\" | \"\\r\\n\" {\n return source.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n}\n\nexport function topLevelInsertionOffset(source: string): number {\n let offset = 0;\n if (source.startsWith(\"#!\")) {\n const newline = source.indexOf(\"\\n\");\n offset = newline >= 0 ? newline + 1 : source.length;\n }\n\n while (true) {\n const nextLineEnd = source.indexOf(\"\\n\", offset);\n const end = nextLineEnd >= 0 ? nextLineEnd + 1 : source.length;\n const line = source.slice(offset, end).trim();\n if (!/^[\"']use [^\"']+[\"'];?$/.test(line)) break;\n offset = end;\n }\n\n return offset;\n}\n\nfunction pickAvailableIdentifier(\n parsed: ParsedCanvasFile,\n base: string,\n): string {\n const usedImports = new Set(parsed.imports.map((item) => item.localName));\n if (!usedImports.has(base)) return base;\n for (let index = 2; index < 10_000; index += 1) {\n const candidate = `${base}${index}`;\n if (!usedImports.has(candidate)) return candidate;\n }\n throw new Error(`Unable to find available identifier for ${base}`);\n}\n\n/**\n * Cheap word-boundary text scan. It matches occurrences inside string literals\n * and comments too, so it is SAFE-DIRECTION ONLY: use it where a false positive\n * is harmless (conservatively keeping an import that might still be used), NEVER\n * for a collision check that throws or blocks an edit — those must use\n * {@link sourceContainsIdentifierNode}, which counts real identifier nodes only.\n */\nexport function hasIdentifier(source: string, identifier: string): boolean {\n return new RegExp(`\\\\b${escapeRegExp(identifier)}\\\\b`).test(source);\n}\n\n/**\n * True when `name` appears as a real identifier node (`Identifier` /\n * `JSXIdentifier`) anywhere in `source` — a binding or reference, never a\n * string-literal or comment occurrence. Use this for collision checks that\n * throw or block an edit, so a name appearing only inside a string (e.g.\n * `<Canvas name=\"Card Demo\">` vs a `Card` import) can't masquerade as a\n * declared identifier.\n */\nexport function sourceContainsIdentifierNode(\n filePath: string,\n source: string,\n name: string,\n): boolean {\n const program = (parseSync(filePath, source) as any).program;\n let found = false;\n walkWithParent(program, (node) => {\n if (found) return;\n if (\n (node.type === \"Identifier\" || node.type === \"JSXIdentifier\") &&\n node.name === name\n ) {\n found = true;\n }\n });\n return found;\n}\n\n/**\n * Depth-first walk that hands each AST node to `visit` along with its parent and\n * the parent field it was reached through — the context callers need to tell a\n * value reference from a property key or member access.\n */\nexport function walkWithParent(\n node: any,\n visit: (node: any, parent: any, key: string | null) => void,\n parent: any = null,\n key: string | null = null,\n seen = new Set<any>(),\n): void {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n if (typeof node.type === \"string\") visit(node, parent, key);\n for (const [childKey, value] of Object.entries(node)) {\n if (!value || typeof value !== \"object\") continue;\n if (Array.isArray(value)) {\n for (const item of value)\n walkWithParent(item, visit, node, childKey, seen);\n } else {\n walkWithParent(value, visit, node, childKey, seen);\n }\n }\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction roundLayoutNumber(value: number): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new Error(\"Layout values must be finite numbers\");\n }\n return Math.round(value);\n}\n\nfunction requireNonEmpty(value: string, label: string): string {\n const trimmed = value.trim();\n if (!trimmed) {\n throw new Error(`${label} must be non-empty`);\n }\n return trimmed;\n}\n\nfunction requiredSpan<T>(value: T | undefined, message: string): T {\n if (value === undefined) {\n throw new Error(message);\n }\n return value;\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AA+EnB,SAAS,uBACd,QACA,OACQ;AACR,QAAM,SAAS,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,UAAU,MAAM,QAAQ,KAAK,KAAK;AACxE,MAAI,gBAAgB,OAAO,SAAS;AACpC,MAAI,aAAa;AAEjB,aAAW,QAAQ,QAAQ;AACzB,QACE,KAAK,QAAQ,KACb,KAAK,MAAM,KAAK,SAChB,KAAK,MAAM,OAAO,UAClB,KAAK,MAAM,eACX;AACA,YAAM,IAAI;AAAA,QACR,0CAA0C,KAAK,KAAK,IAAI,KAAK,GAAG;AAAA,MAClE;AAAA,IACF;A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CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,GAAG,KAAK,oBAAoB;AAAA,EAC9C;AACA,SAAO;AACT;AAEA,SAAS,aAAgB,OAAsB,SAAoB;AACjE,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AACA,SAAO;AACT;","names":["edit","sourceWithoutImport"]}
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ interface StoryboardLayout {
|
|
|
134
134
|
width: number;
|
|
135
135
|
height: number;
|
|
136
136
|
zIndex?: number;
|
|
137
|
+
intrinsicSizing?: "root-element";
|
|
137
138
|
}
|
|
138
139
|
declare function Storyboard<Props extends object = object>({ id, name, component, layout, props, }: {
|
|
139
140
|
id: string;
|