tempo-sdk 0.0.34 → 0.0.35
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.js +66 -9
- package/dist/canvas/editor.js.map +1 -1
- package/dist/{chunk-WLWCRFPM.js → chunk-MLGK7DDB.js} +2 -2
- package/dist/{chunk-WLWCRFPM.js.map → chunk-MLGK7DDB.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs.cjs +1 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +1 -1
- package/package.json +1 -1
package/dist/canvas/editor.js
CHANGED
|
@@ -242,21 +242,32 @@ function updateStoryboardVrt(options) {
|
|
|
242
242
|
if (storyboard.vrt) {
|
|
243
243
|
return applyResult(options.source, parsed, []);
|
|
244
244
|
}
|
|
245
|
+
const openingElementSpan = requireStoryboardOpeningSpan(
|
|
246
|
+
storyboard,
|
|
247
|
+
options.storyboardId
|
|
248
|
+
);
|
|
245
249
|
if (storyboard.vrtAttributeSpan) {
|
|
246
250
|
return applyResult(options.source, parsed, [
|
|
247
251
|
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
+
...expandJsxAttributeRemoval(
|
|
253
|
+
options.source,
|
|
254
|
+
storyboard.vrtAttributeSpan
|
|
255
|
+
),
|
|
256
|
+
value: ""
|
|
257
|
+
},
|
|
258
|
+
insertBareJsxAttributeLine({
|
|
259
|
+
source: options.source,
|
|
260
|
+
openingElementSpan,
|
|
261
|
+
name: "vrt"
|
|
262
|
+
})
|
|
252
263
|
]);
|
|
253
264
|
}
|
|
254
|
-
const offset = findOpeningElementAttributeInsertionOffset(
|
|
255
|
-
options.source,
|
|
256
|
-
requireStoryboardOpeningSpan(storyboard, options.storyboardId)
|
|
257
|
-
);
|
|
258
265
|
return applyResult(options.source, parsed, [
|
|
259
|
-
{
|
|
266
|
+
insertBareJsxAttributeLine({
|
|
267
|
+
source: options.source,
|
|
268
|
+
openingElementSpan,
|
|
269
|
+
name: "vrt"
|
|
270
|
+
})
|
|
260
271
|
]);
|
|
261
272
|
}
|
|
262
273
|
function updateRouteStoryboardRoute(options) {
|
|
@@ -753,7 +764,53 @@ function findOpeningElementAttributeInsertionOffset(source, span) {
|
|
|
753
764
|
}
|
|
754
765
|
return source[close - 1] === "/" ? close - 1 : close;
|
|
755
766
|
}
|
|
767
|
+
function insertBareJsxAttributeLine(options) {
|
|
768
|
+
const offset = findOpeningElementAttributeInsertionOffset(
|
|
769
|
+
options.source,
|
|
770
|
+
options.openingElementSpan
|
|
771
|
+
);
|
|
772
|
+
const newline = detectNewline(options.source);
|
|
773
|
+
const openingIndent = lineIndentAt(
|
|
774
|
+
options.source,
|
|
775
|
+
options.openingElementSpan.start
|
|
776
|
+
);
|
|
777
|
+
const openingLineEnd = options.source.indexOf(
|
|
778
|
+
"\n",
|
|
779
|
+
options.openingElementSpan.start
|
|
780
|
+
);
|
|
781
|
+
const existingAttributeIndent = openingLineEnd >= 0 && openingLineEnd < offset ? options.source.slice(openingLineEnd + 1, offset).split(/\r?\n/).find((line) => line.trim() !== "")?.match(/^[ \t]*/)?.[0] : void 0;
|
|
782
|
+
const attributeIndent = existingAttributeIndent && existingAttributeIndent.length > openingIndent.length ? existingAttributeIndent : `${openingIndent}${openingIndent.includes(" ") ? " " : " "}`;
|
|
783
|
+
const closingLineStart = Math.max(
|
|
784
|
+
options.source.lastIndexOf("\n", offset - 1) + 1,
|
|
785
|
+
0
|
|
786
|
+
);
|
|
787
|
+
if (/^[ \t]*$/.test(options.source.slice(closingLineStart, offset))) {
|
|
788
|
+
return {
|
|
789
|
+
start: closingLineStart,
|
|
790
|
+
end: closingLineStart,
|
|
791
|
+
value: `${attributeIndent}${options.name}${newline}`
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
let start = offset;
|
|
795
|
+
while (start > options.openingElementSpan.start && (options.source[start - 1] === " " || options.source[start - 1] === " ")) {
|
|
796
|
+
start--;
|
|
797
|
+
}
|
|
798
|
+
return {
|
|
799
|
+
start,
|
|
800
|
+
end: offset,
|
|
801
|
+
value: `${newline}${attributeIndent}${options.name}${newline}${openingIndent}`
|
|
802
|
+
};
|
|
803
|
+
}
|
|
756
804
|
function expandJsxAttributeRemoval(source, span) {
|
|
805
|
+
const lineStart = Math.max(source.lastIndexOf("\n", span.start - 1) + 1, 0);
|
|
806
|
+
const nextNewline = source.indexOf("\n", span.end);
|
|
807
|
+
const lineEnd = nextNewline >= 0 ? nextNewline : source.length;
|
|
808
|
+
if (/^[ \t]*$/.test(source.slice(lineStart, span.start)) && /^[ \t]*$/.test(source.slice(span.end, lineEnd))) {
|
|
809
|
+
return {
|
|
810
|
+
start: lineStart,
|
|
811
|
+
end: nextNewline >= 0 ? nextNewline + 1 : lineEnd
|
|
812
|
+
};
|
|
813
|
+
}
|
|
757
814
|
let start = span.start;
|
|
758
815
|
let end = span.end;
|
|
759
816
|
while (start > 0 && (source[start - 1] === " " || source[start - 1] === " ")) {
|
|
@@ -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 kind: \"svelte-component\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n componentExpression?: string;\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 | \"SvelteStoryboard\"\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\n/**\n * Sets or clears the opt-in visual-regression tracking mark (TEM-1775) on a\n * component storyboard. `tracked: true` writes the bare `vrt` attribute\n * (tracked with defaults), replacing an existing untracked declaration\n * (`vrt={false}`, dynamic forms) in place; an already-tracked declaration —\n * including the object form with threshold/ignore overrides — is left\n * untouched. `tracked: false` removes the whole `vrt` attribute, object\n * config included: the in-app toggle is a full untrack, not the\n * `skip: true` pause.\n */\nexport function updateStoryboardVrt(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n tracked: boolean;\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 if (!options.tracked) {\n if (!storyboard.vrtAttributeSpan) {\n return applyResult(options.source, parsed, []);\n }\n return applyResult(options.source, parsed, [\n {\n ...expandJsxAttributeRemoval(\n options.source,\n storyboard.vrtAttributeSpan,\n ),\n value: \"\",\n },\n ]);\n }\n\n if (storyboard.vrt) {\n return applyResult(options.source, parsed, []);\n }\n if (storyboard.vrtAttributeSpan) {\n return applyResult(options.source, parsed, [\n {\n start: storyboard.vrtAttributeSpan.start,\n end: storyboard.vrtAttributeSpan.end,\n value: \"vrt\",\n },\n ]);\n }\n const offset = findOpeningElementAttributeInsertionOffset(\n options.source,\n requireStoryboardOpeningSpan(storyboard, options.storyboardId),\n );\n return applyResult(options.source, parsed, [\n { start: offset, end: offset, value: \" vrt\" },\n ]);\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 (\n options.storyboard.kind === \"component\" ||\n options.storyboard.kind === \"svelte-component\"\n ) {\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 (\n storyboard.kind === \"component\" ||\n storyboard.kind === \"svelte-component\"\n ) {\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 if (kind === \"svelte-component\") return \"SvelteStoryboard\";\n return \"Storyboard\";\n}\n\nfunction resolveSdkTag(\n parsed: ParsedCanvasFile,\n component: SdkComponent,\n): { tag: string; importLine?: string } {\n const sdkSource =\n component === \"SvelteStoryboard\"\n ? \"tempo-sdk/canvas/svelte\"\n : \"tempo-sdk/canvas\";\n for (const item of parsed.imports) {\n if (item.source !== sdkSource) 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 \"${sdkSource}\";`,\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;AA6FnB,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;AACF;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;AACF;AAEO,SAAS,4BAA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U,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AACpD,QAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,iBAAW,QAAQ;AACjB,uBAAe,MAAM,OAAO,MAAM,UAAU,IAAI;AAAA,IACpD,OAAO;AACL,qBAAe,OAAO,OAAO,MAAM,UAAU,IAAI;AAAA,IACnD;AAAA,EACF;AACF;AAEA,SAAS,aAAa,OAAuB;AAC3C,SAAO,MAAM,QAAQ,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"]}
|
|
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 kind: \"svelte-component\";\n id: string;\n layout: CanvasEditorLayout;\n name?: string;\n componentExpression?: string;\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 | \"SvelteStoryboard\"\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\n/**\n * Sets or clears the opt-in visual-regression tracking mark (TEM-1775) on a\n * component storyboard. `tracked: true` writes the bare `vrt` attribute\n * (tracked with defaults), replacing an existing untracked declaration\n * (`vrt={false}`, dynamic forms) in place; an already-tracked declaration —\n * including the object form with threshold/ignore overrides — is left\n * untouched. `tracked: false` removes the whole `vrt` attribute, object\n * config included: the in-app toggle is a full untrack, not the\n * `skip: true` pause.\n */\nexport function updateStoryboardVrt(options: {\n filePath: string;\n source: string;\n storyboardId: string;\n tracked: boolean;\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 if (!options.tracked) {\n if (!storyboard.vrtAttributeSpan) {\n return applyResult(options.source, parsed, []);\n }\n return applyResult(options.source, parsed, [\n {\n ...expandJsxAttributeRemoval(\n options.source,\n storyboard.vrtAttributeSpan,\n ),\n value: \"\",\n },\n ]);\n }\n\n if (storyboard.vrt) {\n return applyResult(options.source, parsed, []);\n }\n const openingElementSpan = requireStoryboardOpeningSpan(\n storyboard,\n options.storyboardId,\n );\n if (storyboard.vrtAttributeSpan) {\n return applyResult(options.source, parsed, [\n {\n ...expandJsxAttributeRemoval(\n options.source,\n storyboard.vrtAttributeSpan,\n ),\n value: \"\",\n },\n insertBareJsxAttributeLine({\n source: options.source,\n openingElementSpan,\n name: \"vrt\",\n }),\n ]);\n }\n return applyResult(options.source, parsed, [\n insertBareJsxAttributeLine({\n source: options.source,\n openingElementSpan,\n name: \"vrt\",\n }),\n ]);\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 (\n options.storyboard.kind === \"component\" ||\n options.storyboard.kind === \"svelte-component\"\n ) {\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 (\n storyboard.kind === \"component\" ||\n storyboard.kind === \"svelte-component\"\n ) {\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 if (kind === \"svelte-component\") return \"SvelteStoryboard\";\n return \"Storyboard\";\n}\n\nfunction resolveSdkTag(\n parsed: ParsedCanvasFile,\n component: SdkComponent,\n): { tag: string; importLine?: string } {\n const sdkSource =\n component === \"SvelteStoryboard\"\n ? \"tempo-sdk/canvas/svelte\"\n : \"tempo-sdk/canvas\";\n for (const item of parsed.imports) {\n if (item.source !== sdkSource) 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 \"${sdkSource}\";`,\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 insertBareJsxAttributeLine(options: {\n source: string;\n openingElementSpan: CanvasSourceSpan;\n name: string;\n}): CanvasSourceEdit {\n const offset = findOpeningElementAttributeInsertionOffset(\n options.source,\n options.openingElementSpan,\n );\n const newline = detectNewline(options.source);\n const openingIndent = lineIndentAt(\n options.source,\n options.openingElementSpan.start,\n );\n const openingLineEnd = options.source.indexOf(\n \"\\n\",\n options.openingElementSpan.start,\n );\n const existingAttributeIndent =\n openingLineEnd >= 0 && openingLineEnd < offset\n ? options.source\n .slice(openingLineEnd + 1, offset)\n .split(/\\r?\\n/)\n .find((line) => line.trim() !== \"\")\n ?.match(/^[ \\t]*/)?.[0]\n : undefined;\n const attributeIndent =\n existingAttributeIndent &&\n existingAttributeIndent.length > openingIndent.length\n ? existingAttributeIndent\n : `${openingIndent}${openingIndent.includes(\"\\t\") ? \"\\t\" : \" \"}`;\n const closingLineStart = Math.max(\n options.source.lastIndexOf(\"\\n\", offset - 1) + 1,\n 0,\n );\n\n if (/^[ \\t]*$/.test(options.source.slice(closingLineStart, offset))) {\n return {\n start: closingLineStart,\n end: closingLineStart,\n value: `${attributeIndent}${options.name}${newline}`,\n };\n }\n\n let start = offset;\n while (\n start > options.openingElementSpan.start &&\n (options.source[start - 1] === \" \" || options.source[start - 1] === \"\\t\")\n ) {\n start--;\n }\n return {\n start,\n end: offset,\n value: `${newline}${attributeIndent}${options.name}${newline}${openingIndent}`,\n };\n}\n\nfunction expandJsxAttributeRemoval(\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 : source.length;\n if (\n /^[ \\t]*$/.test(source.slice(lineStart, span.start)) &&\n /^[ \\t]*$/.test(source.slice(span.end, lineEnd))\n ) {\n return {\n start: lineStart,\n end: nextNewline >= 0 ? nextNewline + 1 : lineEnd,\n };\n }\n\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;AA6FnB,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;AACF;AAEO,SAAS,iBAAiB,SAIZ;AACnB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,gBAAgB,QAAQ,MAAM,aAAa;AA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AAEA,SAAS,aAAgB,OAAsB,SAAoB;AACjE,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AACA,SAAO;AACT;","names":["edit","sourceWithoutImport"]}
|
|
@@ -10,7 +10,7 @@ import { resolve } from "path";
|
|
|
10
10
|
// package.json
|
|
11
11
|
var package_default = {
|
|
12
12
|
name: "tempo-sdk",
|
|
13
|
-
version: "0.0.
|
|
13
|
+
version: "0.0.35",
|
|
14
14
|
type: "module",
|
|
15
15
|
description: "Tempo SDK \u2014 Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types",
|
|
16
16
|
repository: {
|
|
@@ -354,4 +354,4 @@ export {
|
|
|
354
354
|
nextjs_default,
|
|
355
355
|
_internal
|
|
356
356
|
};
|
|
357
|
-
//# sourceMappingURL=chunk-
|
|
357
|
+
//# sourceMappingURL=chunk-MLGK7DDB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../nextjs.ts","../host-identity.ts","../package.json"],"sourcesContent":["/**\n * Next.js plugin that registers the tempo-annotate loader for Webpack and\n * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order\n * function that takes plugin options, returns a function that takes the user's\n * `next.config`, and returns a new config with the plugin's loader rules\n * merged in.\n *\n * See SPEC_NEXTJS.md (in this directory) for the full design rationale.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type { ElementInfo, PropValue } from \"@modules/annotation\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type { ElementInfo, PropValue } from \"@modules/annotation\";\n\n// Internal exports used by tests.\nexport const _internal = {\n buildTurbopackRule,\n mergeTurbopackRules,\n buildWebpackHook,\n detectNextVersion,\n useExperimentalTurbo,\n shouldOmitTurbopack,\n resolveLoaderPath,\n};\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER =\n \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\";\n\nexport interface TempoHostIdentity {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n pluginActive: boolean;\n framework: TempoHostFramework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity(\n framework: TempoHostFramework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.34\",\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"peerDependencies\": {\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog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;AAC/C,UAAM,UAAU,UAAU,kBAAkB;AAC5C,UAAM,gBAAgB,UAAU,oBAAoB,OAAO;AAC3D,UAAM,kBAAkB,UAAU,qBAAqB,OAAO;AAE9D,UAAM,UAAU,mBAAmB,YAAY,aAAa;AAE5D,UAAM,gBAAgB,kBAClB,YAAY,cAAc,QAC1B,YAAY;AAChB,UAAM,cAAc,oBAAoB,eAAe,OAAO;AAE9D,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA,YAAY,WAAW;AAAA,IACzB;AAEA,UAAM,OAAuB;AAAA,MAC3B,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AAMA,UAAM,kBAAkB,QAAQ,IAAI;AACpC,QAAI,iBAAiB;AACnB,WAAK,UAAU;AAAA,IACjB;AAEA,QAAI,CAAC,eAAe;AAClB,UAAI,iBAAiB;AACnB,aAAK,eAAe;AAAA,UAClB,GAAG,YAAY;AAAA,UACf,OAAO;AAAA,QACT;AAAA,MACF,OAAO;AACL,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAEA,IAAO,iBAAQ;AASR,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["resolve","resolve"]}
|
|
1
|
+
{"version":3,"sources":["../nextjs.ts","../host-identity.ts","../package.json"],"sourcesContent":["/**\n * Next.js plugin that registers the tempo-annotate loader for Webpack and\n * Turbopack. Mirrors the user-facing pattern of `@next/mdx`: a higher-order\n * function that takes plugin options, returns a function that takes the user's\n * `next.config`, and returns a new config with the plugin's loader rules\n * merged in.\n *\n * See SPEC_NEXTJS.md (in this directory) for the full design rationale.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type { ElementInfo, PropValue } from \"@modules/annotation\";\nimport {\n createTempoHostIdentity,\n type TempoHostIdentity,\n} from \"./host-identity.ts\";\n\n// ---------------------------------------------------------------------------\n// Types. We keep these minimal and self-contained rather than depending on\n// Next.js types — the plugin file is loaded by `next.config.js` evaluation,\n// before `next` itself is fully resolved in some environments.\n// ---------------------------------------------------------------------------\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n) => Record<string, PropValue>;\n\nexport interface TempoNextjsOptions {\n /** Path to a JS/TS module that default-exports a `ComputeAnnotatedProps`\n * function. Resolved relative to the project root (CWD where the user\n * invokes `next dev` / `next build`). Turbopack does not allow function-\n * valued loader options, so this must be a path. */\n computeAnnotatedPropsModule?: string;\n\n /** File patterns to include. Default: `[\"**\\/*.tsx\", \"**\\/*.jsx\"]`. */\n include?: string | RegExp | Array<string | RegExp>;\n\n /** File patterns to exclude. Default: `[\"**\\/node_modules\\/**\"]`. */\n exclude?: string | RegExp | Array<string | RegExp>;\n\n /** Auto-inject `<meta name=\"tempo-project-root\">` into JSX `<head>`.\n * Default: `true`. */\n autoInjectRootMeta?: boolean;\n\n /** Run the loader during production builds too. Default: `false`. */\n productionBuild?: boolean;\n}\n\ninterface TurbopackRule {\n condition?: unknown;\n loaders?: Array<{ loader: string; options?: unknown } | string>;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRule | TurbopackRule[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfigLike {\n webpack?:\n | ((\n config: unknown,\n context: { dev: boolean; [k: string]: unknown },\n ) => unknown)\n | null;\n turbopack?: TurbopackConfig;\n experimental?: { turbo?: TurbopackConfig; [k: string]: unknown };\n [key: string]: unknown;\n}\n\ntype NextConfigInput = NextConfigLike | undefined;\n\ninterface WebpackHookContext {\n dev: boolean;\n [key: string]: unknown;\n}\n\ninterface WebpackConfigLike {\n module?: { rules?: unknown[] };\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst TURBOPACK_RULE_KEY = \"*.{tsx,jsx}\";\n\nconst requireFromHere = createRequire(\n typeof import.meta.url === \"string\" && import.meta.url.length > 0\n ? import.meta.url\n : __filename,\n);\n\nfunction resolveLoaderPath(): string {\n // Production: dist/nextjs.{js,cjs} sits next to dist/nextjs-loader.cjs.\n // Development: source nextjs.ts sits at <pkg>/nextjs.ts; the built\n // loader is at <pkg>/dist/nextjs-loader.cjs. Try both so unit tests\n // running directly against the .ts source file still find the loader.\n for (const candidate of [\"./nextjs-loader.cjs\", \"./dist/nextjs-loader.cjs\"]) {\n try {\n return requireFromHere.resolve(candidate);\n } catch {\n // try next candidate\n }\n }\n throw new Error(\n \"tempo-sdk/nextjs: could not resolve nextjs-loader.cjs. \" +\n \"Run `pnpm build` in the tempo-sdk package to produce the dist/ output.\",\n );\n}\n\ninterface NextVersionInfo {\n major: number;\n minor: number;\n}\n\nfunction detectNextVersion(): NextVersionInfo | null {\n try {\n const pkg = requireFromHere(\"next/package.json\") as { version: string };\n const m = /^(\\d+)\\.(\\d+)/.exec(pkg.version);\n if (!m) return null;\n return { major: Number(m[1]), minor: Number(m[2]) };\n } catch {\n return null;\n }\n}\n\n/** Should the wrapper write to `experimental.turbo` instead of `turbopack`? */\nfunction useExperimentalTurbo(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n if (version.major < 15) return true;\n if (version.major === 15 && version.minor < 3) return true;\n return false;\n}\n\n/** Should the wrapper omit Turbopack registration entirely? Some pre-13 versions\n * error on unknown config keys. */\nfunction shouldOmitTurbopack(version: NextVersionInfo | null): boolean {\n if (!version) return false;\n return version.major < 13;\n}\n\nfunction buildTurbopackRule(\n loaderPath: string,\n options: TempoNextjsOptions,\n): TurbopackRule {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n // {all: [{not: \"foreign\"}, \"development\"]} — exclude node_modules / Next\n // internals AND only run during `next dev`. The \"development\" condition is\n // a Turbopack built-in; it matches both `next dev` and `next build` in dev\n // mode but is inert during a production `next build`.\n const condition = options.productionBuild\n ? { not: \"foreign\" }\n : { all: [{ not: \"foreign\" }, \"development\"] };\n\n return {\n condition,\n loaders: [{ loader: loaderPath, options: loaderOptions }],\n };\n}\n\nfunction mergeTurbopackRules(\n existing: TurbopackConfig | undefined,\n newRule: TurbopackRule,\n): TurbopackConfig {\n const existingRule = existing?.rules?.[TURBOPACK_RULE_KEY];\n let mergedRule: TurbopackRule | TurbopackRule[];\n if (!existingRule) {\n mergedRule = newRule;\n } else if (Array.isArray(existingRule)) {\n mergedRule = [...existingRule, newRule];\n } else {\n mergedRule = [existingRule, newRule];\n }\n return {\n ...existing,\n rules: {\n ...existing?.rules,\n [TURBOPACK_RULE_KEY]: mergedRule,\n },\n };\n}\n\nfunction buildWebpackHook(\n loaderPath: string,\n options: TempoNextjsOptions,\n userWebpack: NextConfigLike[\"webpack\"],\n): NonNullable<NextConfigLike[\"webpack\"]> {\n const loaderOptions: Record<string, unknown> = {};\n if (options.computeAnnotatedPropsModule !== undefined) {\n loaderOptions.computeAnnotatedPropsModule =\n options.computeAnnotatedPropsModule;\n }\n if (options.autoInjectRootMeta !== undefined) {\n loaderOptions.autoInjectRootMeta = options.autoInjectRootMeta;\n }\n\n const allowProduction = options.productionBuild === true;\n\n return (configIn, context) => {\n const config = configIn as WebpackConfigLike;\n const ctx = context as WebpackHookContext;\n if (ctx.dev || allowProduction) {\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: /\\.(tsx|jsx)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [{ loader: loaderPath, options: loaderOptions }],\n });\n }\n if (typeof userWebpack === \"function\") {\n return userWebpack(config, context);\n }\n return config;\n };\n}\n\n// ---------------------------------------------------------------------------\n// tempoProjectRoot — sync helper for Pages Router users (Section 6.4)\n// ---------------------------------------------------------------------------\n\nlet cachedTempoProjectRoot: string | null = null;\n\n/**\n * Returns the canonical project root that the Tempo loader uses to compute\n * `data-tempo-filepath` values. Use this in `pages/_document.tsx` to set the\n * content of `<meta name=\"tempo-project-root\">`, ensuring the manual meta tag\n * value matches what the loader produces.\n */\nexport function tempoProjectRoot(): string {\n if (cachedTempoProjectRoot !== null) return cachedTempoProjectRoot;\n\n // Walk upward from CWD looking for the nearest package.json. CWD is what\n // Next.js itself uses as the project root when the user invokes\n // `next dev` / `next build` — the loader's `rootContext` matches.\n let dir = process.cwd();\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (existsSync(resolve(dir, \"package.json\"))) break;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n let canonical = dir;\n try {\n canonical = realpathSync.native(dir);\n } catch {\n // Keep `dir` as fallback.\n }\n cachedTempoProjectRoot = canonical;\n return canonical;\n}\n\n/** Request-time identity for a Next route served by a Tempo-enabled host. */\nexport function tempoHostIdentity(): TempoHostIdentity {\n return createTempoHostIdentity(\"nextjs\");\n}\n\n/** Reset the cached project root. For tests only. */\nexport function _resetTempoProjectRoot(): void {\n cachedTempoProjectRoot = null;\n}\n\n// ---------------------------------------------------------------------------\n// tempoNextjsPlugin — the wrapper\n// ---------------------------------------------------------------------------\n\n/**\n * Higher-order function that wraps a Next.js config to register the\n * tempo-annotate loader with both Webpack and Turbopack. No-op when\n * `process.env.TEMPO` is not set.\n *\n * @example\n * ```js\n * // next.config.js\n * const tempoNextjsPlugin = require(\"tempo-sdk/nextjs\");\n * module.exports = tempoNextjsPlugin()({ reactStrictMode: true });\n * ```\n */\nexport function tempoNextjsPlugin(\n pluginOptions: TempoNextjsOptions = {},\n): (inputConfig?: NextConfigLike) => NextConfigLike {\n return (inputConfigArg?: NextConfigLike): NextConfigLike => {\n const inputConfig: NextConfigLike = inputConfigArg ?? {};\n\n if (!process.env.TEMPO) return inputConfig;\n\n // Routed through `_internal.*` so unit tests can spy on these helpers\n // without rewiring the imports.\n const loaderPath = _internal.resolveLoaderPath();\n const version = _internal.detectNextVersion();\n const omitTurbopack = _internal.shouldOmitTurbopack(version);\n const useExperimental = _internal.useExperimentalTurbo(version);\n\n const newRule = buildTurbopackRule(loaderPath, pluginOptions);\n\n const existingTurbo = useExperimental\n ? inputConfig.experimental?.turbo\n : inputConfig.turbopack;\n const mergedTurbo = mergeTurbopackRules(existingTurbo, newRule);\n\n const webpackHook = buildWebpackHook(\n loaderPath,\n pluginOptions,\n inputConfig.webpack ?? null,\n );\n\n const next: NextConfigLike = {\n ...inputConfig,\n webpack: webpackHook,\n };\n\n // Tempo-owned build cache: the supervisor always points managed Next hosts\n // at `.next/tempo`, isolating them from the user's own `next dev` cache.\n // A suffixed sibling is selected only after Next reports a lock conflict\n // for the stable directory. Runs outside Tempo never receive this variable.\n const distDirOverride = process.env.TEMPO_NEXT_DIST_DIR;\n if (distDirOverride) {\n next.distDir = distDirOverride;\n }\n\n if (!omitTurbopack) {\n if (useExperimental) {\n next.experimental = {\n ...inputConfig.experimental,\n turbo: mergedTurbo,\n };\n } else {\n next.turbopack = mergedTurbo;\n }\n }\n\n return next;\n };\n}\n\nexport default tempoNextjsPlugin;\n\n// ---------------------------------------------------------------------------\n// Type re-exports for users writing custom strategies.\n// ---------------------------------------------------------------------------\n\nexport type { ElementInfo, PropValue } from \"@modules/annotation\";\n\n// Internal exports used by tests.\nexport const _internal = {\n buildTurbopackRule,\n mergeTurbopackRules,\n buildWebpackHook,\n detectNextVersion,\n useExperimentalTurbo,\n shouldOmitTurbopack,\n resolveLoaderPath,\n};\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport sdkPackage from \"./package.json\" with { type: \"json\" };\n\nexport const TEMPO_HOST_IDENTITY_ENDPOINT = \"/__tempo/identity\";\nexport const TEMPO_HOST_IDENTITY_CAPABILITY_HEADER =\n \"x-tempo-host-identity\";\nexport const TEMPO_HOST_IDENTITY_CONTRACT_VERSION = 1;\nexport const TEMPO_WORKSPACE_NONCE_ENV = \"TEMPO_WORKSPACE_NONCE\";\nexport const TEMPO_WORKSPACE_NONCE_META_NAME = \"tempo-workspace-nonce\";\n\nconst WORKSPACE_NONCE_RELATIVE_PATH = \".tempo/workspace-nonce\";\nconst MAX_WORKSPACE_NONCE_LENGTH = 128;\n\nexport type TempoHostFramework = \"vite\" | \"nextjs\";\n\nexport interface TempoHostIdentity {\n tempoHost: true;\n contractVersion: number;\n workspaceNonce: string;\n sdkVersion: string;\n pluginActive: boolean;\n framework: TempoHostFramework;\n}\n\nfunction normalizeWorkspaceNonce(value: string | undefined): string {\n const nonce = value?.trim() ?? \"\";\n return nonce.length > 0 && nonce.length <= MAX_WORKSPACE_NONCE_LENGTH\n ? nonce\n : \"\";\n}\n\nexport function readTempoWorkspaceNonce(root = process.cwd()): string {\n const fromEnvironment = normalizeWorkspaceNonce(\n process.env[TEMPO_WORKSPACE_NONCE_ENV],\n );\n if (fromEnvironment) return fromEnvironment;\n try {\n return normalizeWorkspaceNonce(\n readFileSync(resolve(root, WORKSPACE_NONCE_RELATIVE_PATH), \"utf-8\"),\n );\n } catch {\n return \"\";\n }\n}\n\nexport function createTempoHostIdentity(\n framework: TempoHostFramework,\n options: { root?: string; pluginActive?: boolean } = {},\n): TempoHostIdentity {\n return {\n tempoHost: true,\n contractVersion: TEMPO_HOST_IDENTITY_CONTRACT_VERSION,\n workspaceNonce: readTempoWorkspaceNonce(options.root),\n sdkVersion: sdkPackage.version,\n pluginActive: options.pluginActive ?? Boolean(process.env.TEMPO),\n framework,\n };\n}\n","{\n \"name\": \"tempo-sdk\",\n \"version\": \"0.0.35\",\n \"type\": \"module\",\n \"description\": \"Tempo SDK — Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/TempoLabsAI/tempo-monorepo.git\",\n \"directory\": \"tempo-modules/tempo-sdk\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./canvas\": {\n \"types\": \"./dist/canvas/index.d.ts\",\n \"import\": \"./dist/canvas/index.js\"\n },\n \"./canvas/svelte\": {\n \"types\": \"./dist/canvas/svelte.d.ts\",\n \"import\": \"./dist/canvas/svelte.js\"\n },\n \"./canvas/interact-projection\": {\n \"types\": \"./dist/canvas/interact-projection.d.ts\",\n \"import\": \"./dist/canvas/interact-projection.js\"\n },\n \"./canvas/parser\": {\n \"types\": \"./dist/canvas/parser.d.ts\",\n \"import\": \"./dist/canvas/parser.js\"\n },\n \"./canvas/editor\": {\n \"types\": \"./dist/canvas/editor.d.ts\",\n \"import\": \"./dist/canvas/editor.js\"\n },\n \"./assets\": {\n \"types\": \"./dist/assets/index.d.ts\",\n \"import\": \"./dist/assets/index.js\"\n },\n \"./assets/parser\": {\n \"types\": \"./dist/assets/parser.d.ts\",\n \"import\": \"./dist/assets/parser.js\"\n },\n \"./assets/editor\": {\n \"types\": \"./dist/assets/editor.d.ts\",\n \"import\": \"./dist/assets/editor.js\"\n },\n \"./nextjs\": {\n \"types\": \"./dist/nextjs.d.ts\",\n \"import\": \"./dist/nextjs.js\",\n \"require\": \"./dist/nextjs.cjs\"\n },\n \"./nextjs/plugin\": {\n \"types\": \"./dist/nextjs/plugin.d.ts\",\n \"import\": \"./dist/nextjs/plugin.js\"\n },\n \"./expo\": {\n \"types\": \"./dist/expo-babel-plugin.d.ts\",\n \"import\": \"./dist/expo-babel-plugin.js\",\n \"require\": \"./dist/expo-babel-plugin.cjs\"\n },\n \"./expo/plugin\": {\n \"types\": \"./dist/expo/plugin.d.ts\",\n \"import\": \"./dist/expo/plugin.js\",\n \"require\": \"./dist/expo/plugin.cjs\"\n },\n \"./svelte\": {\n \"types\": \"./dist/svelte.d.ts\",\n \"import\": \"./dist/svelte.js\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"build\": \"pnpm run clean && tsup\",\n \"build:if-missing\": \"test -f dist/index.js || pnpm run build\",\n \"prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm build\",\n \"demo\": \"TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev\",\n \"demo:nextjs\": \"TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev\",\n \"test\": \"vitest run\",\n \"test:browser\": \"vitest run canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts\",\n \"test:watch\": \"vitest\",\n \"test:nextjs:unit\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts\",\n \"test:nextjs:integration\": \"vitest run nextjs-e2e-correctness.test.ts\",\n \"test:nextjs:production\": \"vitest run nextjs-production.test.ts\",\n \"test:nextjs\": \"vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts nextjs-e2e-correctness.test.ts nextjs-production.test.ts\"\n },\n \"dependencies\": {\n \"@rollup/pluginutils\": \"^5.1.0\",\n \"oxc-parser\": \"^0.110.0\"\n },\n \"peerDependencies\": {\n \"@babel/core\": \"^7.0.0\",\n \"next\": \"^13 || ^14 || ^15 || ^16\",\n \"react\": \"^18 || ^19\",\n \"svelte\": \"^5.0.0\",\n \"vite\": \"^5 || ^6 || ^7 || ^8\"\n },\n \"peerDependenciesMeta\": {\n \"@babel/core\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"svelte\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.29.0\",\n \"@babel/types\": \"^7.29.0\",\n \"@modules/annotation\": \"workspace:*\",\n \"@modules/file-parser\": \"workspace:*\",\n \"@modules/svelte-editor\": \"workspace:*\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/node\": \"^25.0.8\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"playwright\": \"^1.58.2\",\n \"react-dom\": \"catalog:\",\n \"svelte\": \"5.56.9\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"catalog:\",\n \"vite\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n"],"mappings":";AAiBA,SAAS,YAAY,oBAAoB;AACzC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,WAAAA,gBAAe;;;ACnBjC,SAAS,oBAAoB;AAC7B,SAAS,eAAe;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,gCAAgC;AAAA,MAC9B,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,mBAAmB;AAAA,MACjB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,QA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QAAQ;AACzC;AAGO,SAAS,yBAA+B;AAC7C,2BAAyB;AAC3B;AAkBO,SAAS,kBACd,gBAAoC,CAAC,GACa;AAClD,SAAO,CAAC,mBAAoD;AAC1D,UAAM,cAA8B,kBAAkB,CAAC;AAEvD,QAAI,CAAC,QAAQ,IAAI,MAAO,QAAO;AAI/B,UAAM,aAAa,UAAU,kBAAkB;AAC/C,UAAM,UAAU,UAAU,kBAAkB;AAC5C,UAAM,gBAAgB,UAAU,oBAAoB,OAAO;AAC3D,UAAM,kBAAkB,UAAU,qBAAqB,OAAO;AAE9D,UAAM,UAAU,mBAAmB,YAAY,aAAa;AAE5D,UAAM,gBAAgB,kBAClB,YAAY,cAAc,QAC1B,YAAY;AAChB,UAAM,cAAc,oBAAoB,eAAe,OAAO;AAE9D,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA,YAAY,WAAW;AAAA,IACzB;AAEA,UAAM,OAAuB;AAAA,MAC3B,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AAMA,UAAM,kBAAkB,QAAQ,IAAI;AACpC,QAAI,iBAAiB;AACnB,WAAK,UAAU;AAAA,IACjB;AAEA,QAAI,CAAC,eAAe;AAClB,UAAI,iBAAiB;AACnB,aAAK,eAAe;AAAA,UAClB,GAAG,YAAY;AAAA,UACf,OAAO;AAAA,QACT;AAAA,MACF,OAAO;AACL,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAEA,IAAO,iBAAQ;AASR,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["resolve","resolve"]}
|
package/dist/index.js
CHANGED
|
@@ -294,7 +294,7 @@ import { resolve } from "path";
|
|
|
294
294
|
// package.json
|
|
295
295
|
var package_default = {
|
|
296
296
|
name: "tempo-sdk",
|
|
297
|
-
version: "0.0.
|
|
297
|
+
version: "0.0.35",
|
|
298
298
|
type: "module",
|
|
299
299
|
description: "Tempo SDK \u2014 Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types",
|
|
300
300
|
repository: {
|