tempo-sdk 0.0.22 → 0.0.23
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/canvas/editor.d.ts +8 -9
- package/dist/canvas/editor.js +36 -7
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +5 -2
- package/dist/canvas/index.js +18 -7
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +23 -4
- package/dist/canvas/interact-projection.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +221 -8
- package/dist/index.js.map +1 -1
- package/dist/{page-BUbHO0BI.d.ts → page-xi1aI5a7.d.ts} +0 -2
- package/package.json +1 -1
package/dist/canvas/editor.d.ts
CHANGED
|
@@ -40,8 +40,7 @@ type AddCanvasStoryboardInput = {
|
|
|
40
40
|
route: string;
|
|
41
41
|
layout: CanvasEditorLayout;
|
|
42
42
|
name?: string;
|
|
43
|
-
}
|
|
44
|
-
type LegacyHtmlStoryboardInput = {
|
|
43
|
+
} | {
|
|
45
44
|
kind: "html";
|
|
46
45
|
id: string;
|
|
47
46
|
layout: CanvasEditorLayout;
|
|
@@ -106,17 +105,17 @@ declare function updateRouteStoryboardRoute(options: {
|
|
|
106
105
|
storyboardId: string;
|
|
107
106
|
route: string;
|
|
108
107
|
}): CanvasEditResult;
|
|
109
|
-
declare function
|
|
108
|
+
declare function updateHtmlStoryboardSource(options: {
|
|
110
109
|
filePath: string;
|
|
111
110
|
source: string;
|
|
112
|
-
|
|
111
|
+
storyboardId: string;
|
|
112
|
+
filepath?: string;
|
|
113
|
+
src?: string;
|
|
113
114
|
}): CanvasEditResult;
|
|
114
|
-
|
|
115
|
-
* never call this legacy HTML writer. */
|
|
116
|
-
declare function addLegacyHtmlStoryboardDuringMigration(options: {
|
|
115
|
+
declare function addCanvasStoryboard(options: {
|
|
117
116
|
filePath: string;
|
|
118
117
|
source: string;
|
|
119
|
-
storyboard:
|
|
118
|
+
storyboard: AddCanvasStoryboardInput;
|
|
120
119
|
}): CanvasEditResult;
|
|
121
120
|
declare function removeCanvasStoryboard(options: {
|
|
122
121
|
filePath: string;
|
|
@@ -162,4 +161,4 @@ declare function sourceContainsIdentifierNode(filePath: string, source: string,
|
|
|
162
161
|
*/
|
|
163
162
|
declare function walkWithParent(node: any, visit: (node: any, parent: any, key: string | null) => void, parent?: any, key?: string | null, seen?: Set<any>): void;
|
|
164
163
|
|
|
165
|
-
export { type AddCanvasStoryboardInput, type CanvasEditResult, type CanvasEditorLayout, type CanvasSourceEdit, addCanvasStoryboard,
|
|
164
|
+
export { type AddCanvasStoryboardInput, type CanvasEditResult, type CanvasEditorLayout, type CanvasSourceEdit, addCanvasStoryboard, applyCanvasSourceEdits, collapseBlankLines, detectNewline, expandStatementForward, expandToFullLines, formatJsxStringAttribute, hasIdentifier, removeCanvasStoryboard, sourceContainsIdentifierNode, topLevelInsertionOffset, updateCanvasBackgroundColor, updateCanvasName, updateCanvasPath, updateHtmlStoryboardSource, updateRouteStoryboardRoute, updateStoryboardComponent, updateStoryboardId, updateStoryboardLayout, updateStoryboardName, updateStoryboardProps, walkWithParent };
|
package/dist/canvas/editor.js
CHANGED
|
@@ -238,13 +238,42 @@ function updateRouteStoryboardRoute(options) {
|
|
|
238
238
|
});
|
|
239
239
|
return applyResult(options.source, parsed, [edit]);
|
|
240
240
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
241
|
+
function updateHtmlStoryboardSource(options) {
|
|
242
|
+
const parsed = parseCanvasFile(options.filePath, options.source);
|
|
243
|
+
const storyboard = findStoryboard(parsed, options.storyboardId);
|
|
244
|
+
if (storyboard.kind !== "html") {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`Storyboard "${options.storyboardId}" is not an html storyboard`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
const filepath = options.filepath && options.filepath.trim() !== "" ? options.filepath.trim() : void 0;
|
|
250
|
+
const src = options.src && options.src.trim() !== "" ? options.src : void 0;
|
|
251
|
+
if (!filepath && !src) {
|
|
252
|
+
throw new Error("HTML storyboard source requires filepath or src");
|
|
253
|
+
}
|
|
254
|
+
const openingElementSpan = requireStoryboardOpeningSpan(
|
|
255
|
+
storyboard,
|
|
256
|
+
options.storyboardId
|
|
257
|
+
);
|
|
258
|
+
const filepathEdit = upsertJsxStringAttribute({
|
|
259
|
+
source: options.source,
|
|
260
|
+
openingElementSpan,
|
|
261
|
+
valueSpan: storyboard.filepathSpan,
|
|
262
|
+
attributeSpan: storyboard.filepathAttributeSpan,
|
|
263
|
+
name: "filepath",
|
|
264
|
+
value: filepath
|
|
265
|
+
});
|
|
266
|
+
const srcEdit = upsertJsxStringAttribute({
|
|
267
|
+
source: options.source,
|
|
268
|
+
openingElementSpan,
|
|
269
|
+
valueSpan: storyboard.srcSpan,
|
|
270
|
+
attributeSpan: storyboard.srcAttributeSpan,
|
|
271
|
+
name: "src",
|
|
272
|
+
value: src
|
|
273
|
+
});
|
|
274
|
+
return applyResult(options.source, parsed, [filepathEdit, srcEdit]);
|
|
246
275
|
}
|
|
247
|
-
function
|
|
276
|
+
function addCanvasStoryboard(options) {
|
|
248
277
|
const parsed = parseCanvasFile(options.filePath, options.source);
|
|
249
278
|
if (parsed.storyboards.some(
|
|
250
279
|
(item) => item.storyboardKey === options.storyboard.id
|
|
@@ -844,7 +873,6 @@ function requiredSpan(value, message) {
|
|
|
844
873
|
}
|
|
845
874
|
export {
|
|
846
875
|
addCanvasStoryboard,
|
|
847
|
-
addLegacyHtmlStoryboardDuringMigration,
|
|
848
876
|
applyCanvasSourceEdits,
|
|
849
877
|
collapseBlankLines,
|
|
850
878
|
detectNewline,
|
|
@@ -858,6 +886,7 @@ export {
|
|
|
858
886
|
updateCanvasBackgroundColor,
|
|
859
887
|
updateCanvasName,
|
|
860
888
|
updateCanvasPath,
|
|
889
|
+
updateHtmlStoryboardSource,
|
|
861
890
|
updateRouteStoryboardRoute,
|
|
862
891
|
updateStoryboardComponent,
|
|
863
892
|
updateStoryboardId,
|
|
@@ -1 +1 @@
|
|
|
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\ntype LegacyHtmlStoryboardInput = {\n kind: \"html\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n filepath?: string;\n src?: string;\n};\n\ntype CanvasStoryboardWriteInput =\n | AddCanvasStoryboardInput\n | LegacyHtmlStoryboardInput;\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 addCanvasStoryboard(options: {\n filePath: string;\n source: string;\n storyboard: AddCanvasStoryboardInput;\n}): CanvasEditResult {\n return addCanvasStoryboardInternal(options);\n}\n\n/** @internal Parser migration compatibility only. Product creation paths must\n * never call this legacy HTML writer. */\nexport function addLegacyHtmlStoryboardDuringMigration(options: {\n filePath: string;\n source: string;\n storyboard: LegacyHtmlStoryboardInput;\n}): CanvasEditResult {\n return addCanvasStoryboardInternal(options);\n}\n\nfunction addCanvasStoryboardInternal(options: {\n filePath: string;\n source: string;\n storyboard: CanvasStoryboardWriteInput;\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: CanvasStoryboardWriteInput;\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: CanvasStoryboardWriteInput;\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: CanvasStoryboardWriteInput,\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<CanvasStoryboardWriteInput, { 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: CanvasStoryboardWriteInput[\"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;AAoFnB,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;AACA,iBACE,WAAW,MAAM,GAAG,KAAK,KAAK,IAAI,KAAK,QAAQ,WAAW,MAAM,KAAK,GAAG;AAC1E,oBAAgB,KAAK;AAAA,EACvB;AAEA,SAAO;AACT;AAEO,SAAS,iBAAiB,SAIZ;AACnB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,gBAAgB,QAAQ,MAAM,aAAa;AAAA,IAC3C,CAAC,YAAY;AAAA,MACX,WAAW,OAAO;AAAA,MAClB,eAAe,OAAO;AAAA,IACxB;AAAA,EACF;A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,KAAK;AACzB;AAEA,SAAS,gBAAgB,OAAe,OAAuB;AAC7D,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,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"]}
|
|
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,KA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AAQ,uBAAuB,MAAM;AACpD;AAEA,SAAS,kBAAkB,OAAuB;AAChD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,GAAG;AACxD,UAAM,IAAI,MAAM,sCAAsC;AAAA,EACxD;AACA,SAAO,KAAK,MAAM,KAAK;AACzB;AAEA,SAAS,gBAAgB,OAAe,OAAuB;AAC7D,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { d as TempoStoryboard } from '../page-
|
|
3
|
+
import { d as TempoStoryboard } from '../page-xi1aI5a7.js';
|
|
4
4
|
|
|
5
5
|
declare function getCanvasStoryboardRenderId(canvasPath: string, storyboardId: string): string;
|
|
6
6
|
declare function Canvas({ children, name, path, backgroundColor, defaultViewport, ...sourceAnnotations }: {
|
|
@@ -54,6 +54,10 @@ type CanvasHostCaptureResult = {
|
|
|
54
54
|
src: string;
|
|
55
55
|
width: number;
|
|
56
56
|
height: number;
|
|
57
|
+
/** The capture is fully transparent — the storyboard rendered nothing
|
|
58
|
+
* visible. Reported by hosts that scan the decoded bitmap; absent means
|
|
59
|
+
* the host did not answer, never that content was found. */
|
|
60
|
+
contentEmpty?: boolean;
|
|
57
61
|
};
|
|
58
62
|
timing?: Record<string, number>;
|
|
59
63
|
};
|
|
@@ -249,7 +253,6 @@ declare function RouteStoryboard({ id, name, route, layout, }: {
|
|
|
249
253
|
layout: StoryboardLayout;
|
|
250
254
|
name?: string;
|
|
251
255
|
}): react_jsx_runtime.JSX.Element;
|
|
252
|
-
/** @deprecated Legacy HTML storyboards are render-only. */
|
|
253
256
|
declare function HtmlStoryboard({ id, name, filepath, src, layout, }: {
|
|
254
257
|
id: string;
|
|
255
258
|
layout: StoryboardLayout;
|
package/dist/canvas/index.js
CHANGED
|
@@ -2844,12 +2844,23 @@ function beginAdmissionWindow() {
|
|
|
2844
2844
|
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
2845
2845
|
var renderErrorRetryBaseDelayMs = 1e3;
|
|
2846
2846
|
var renderErrorRetryMaxDelayMs = 8e3;
|
|
2847
|
-
var
|
|
2848
|
-
function
|
|
2849
|
-
|
|
2847
|
+
var BEAT_BUS_KEY = "__tempoRenderErrorRecoveryBeatBus";
|
|
2848
|
+
function createBeatBus() {
|
|
2849
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2850
|
+
return {
|
|
2851
|
+
emit() {
|
|
2852
|
+
for (const listener of [...listeners]) listener();
|
|
2853
|
+
},
|
|
2854
|
+
subscribe(listener) {
|
|
2855
|
+
listeners.add(listener);
|
|
2856
|
+
return () => listeners.delete(listener);
|
|
2857
|
+
}
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
function getRenderErrorRecoveryBeatBus() {
|
|
2861
|
+
const globals = globalThis;
|
|
2862
|
+
return globals[BEAT_BUS_KEY] ?? (globals[BEAT_BUS_KEY] = createBeatBus());
|
|
2850
2863
|
}
|
|
2851
|
-
var hot = import.meta.hot;
|
|
2852
|
-
hot?.on?.("vite:afterUpdate", emitRenderErrorRecoveryBeat);
|
|
2853
2864
|
function useRenderErrorRecovery(retryNow) {
|
|
2854
2865
|
const retryNowRef = useRef3(retryNow);
|
|
2855
2866
|
retryNowRef.current = retryNow;
|
|
@@ -2883,9 +2894,9 @@ function useRenderErrorRecovery(retryNow) {
|
|
|
2883
2894
|
clearTimer();
|
|
2884
2895
|
retryNowRef.current();
|
|
2885
2896
|
};
|
|
2886
|
-
|
|
2897
|
+
const unsubscribe = getRenderErrorRecoveryBeatBus().subscribe(onBeat);
|
|
2887
2898
|
return () => {
|
|
2888
|
-
|
|
2899
|
+
unsubscribe();
|
|
2889
2900
|
clearTimer();
|
|
2890
2901
|
};
|
|
2891
2902
|
}, [clearTimer]);
|