Skip to content

AI-native design editor. Open-source Figma alternative.

chore: format sources with oxfmt

Danila Poyarkovb85805e9c7cc
diff --git a/package.json b/package.json
index d13f935b9..02496aebb 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"tauri": "tauri",
"lint": "bun run lint:structure && oxlint -c oxlint.json --type-aware --type-check src/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/",
"lint:structure": "oxlint -c oxlint.structure.json vite.config.ts vite/ src/ packages/core/src/ packages/vue/src/ packages/cli/src/ packages/mcp/src/ tests/ scripts/",
- "format": "oxfmt --write src/ packages/core/src/ packages/cli/src/ packages/mcp/src/ packages/vue/src/",
+ "format": "oxfmt --write src/ packages/core/src/ packages/cli/src/ packages/mcp/src/ packages/vue/src/ tests",
"check": "bun run lint && tsgo --noEmit && bun run check:vue",
"check:vue": "vue-tsc --noEmit -p tsconfig.json && vue-tsc --noEmit -p packages/vue/tsconfig.json",
"test": "playwright test --project=openpencil",
diff --git a/packages/cli/src/commands/analyze/clusters.ts b/packages/cli/src/commands/analyze/clusters.ts
index c0238347c..3d3849908 100644
--- a/packages/cli/src/commands/analyze/clusters.ts
+++ b/packages/cli/src/commands/analyze/clusters.ts
@@ -1,10 +1,9 @@
+import { bold, fmtList, fmtSummary } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
import { defineCommand } from 'citty'
import { calcClusterConfidence } from '@open-pencil/core/tools'
-import { loadRpcData } from '#cli/rpc-data'
-import { bold, fmtList, fmtSummary } from '#cli/format'
-
import type { AnalyzeClustersResult } from '@open-pencil/core/rpc'
function formatSignature(sig: string): string {
diff --git a/packages/cli/src/commands/analyze/colors.ts b/packages/cli/src/commands/analyze/colors.ts
index a0a106298..9ff87918d 100644
--- a/packages/cli/src/commands/analyze/colors.ts
+++ b/packages/cli/src/commands/analyze/colors.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { bold, fmtHistogram, fmtList, fmtSummary } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { AnalyzeColorsResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/analyze/spacing.ts b/packages/cli/src/commands/analyze/spacing.ts
index e1a82f019..ffa8b001a 100644
--- a/packages/cli/src/commands/analyze/spacing.ts
+++ b/packages/cli/src/commands/analyze/spacing.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { bold, kv, fmtHistogram, fmtSummary } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { AnalyzeSpacingResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/analyze/typography.ts b/packages/cli/src/commands/analyze/typography.ts
index 0d856e5e6..e2babb2d2 100644
--- a/packages/cli/src/commands/analyze/typography.ts
+++ b/packages/cli/src/commands/analyze/typography.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { bold, fmtHistogram, fmtSummary } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { AnalyzeTypographyResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/convert.ts b/packages/cli/src/commands/convert.ts
index d52681e87..089cc9bf4 100644
--- a/packages/cli/src/commands/convert.ts
+++ b/packages/cli/src/commands/convert.ts
@@ -1,12 +1,11 @@
import { basename, extname, resolve } from 'node:path'
-import { defineCommand } from 'citty'
-
-import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
-
import { requireFile } from '#cli/app-client'
import { ok, printError } from '#cli/format'
import { loadDocument } from '#cli/headless'
+import { defineCommand } from 'citty'
+
+import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
const io = new IORegistry(BUILTIN_IO_FORMATS)
diff --git a/packages/cli/src/commands/eval.ts b/packages/cli/src/commands/eval.ts
index 4e6ba0b8f..c5c93dc8e 100644
--- a/packages/cli/src/commands/eval.ts
+++ b/packages/cli/src/commands/eval.ts
@@ -1,10 +1,9 @@
-import { defineCommand } from 'citty'
-
-import { FigmaAPI } from '@open-pencil/core/figma-api'
-
import { isAppMode, requireFile, rpc } from '#cli/app-client'
import { printError } from '#cli/format'
import { loadDocument } from '#cli/headless'
+import { defineCommand } from 'citty'
+
+import { FigmaAPI } from '@open-pencil/core/figma-api'
function printResult(value: unknown, json: boolean) {
if (json || !process.stdout.isTTY) {
diff --git a/packages/cli/src/commands/export.ts b/packages/cli/src/commands/export.ts
index b4a217d5c..ebfd72cfb 100644
--- a/packages/cli/src/commands/export.ts
+++ b/packages/cli/src/commands/export.ts
@@ -1,12 +1,11 @@
import { basename, extname, resolve } from 'node:path'
-import { defineCommand } from 'citty'
-
-import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
-
import { isAppMode, requireFile, rpc } from '#cli/app-client'
import { ok, printError } from '#cli/format'
import { loadDocument } from '#cli/headless'
+import { defineCommand } from 'citty'
+
+import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
import type { RasterExportFormat } from '@open-pencil/core/io'
diff --git a/packages/cli/src/commands/find.ts b/packages/cli/src/commands/find.ts
index e263957d1..776c0713c 100644
--- a/packages/cli/src/commands/find.ts
+++ b/packages/cli/src/commands/find.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { printNodeResults } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { FindNodeResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/formats.ts b/packages/cli/src/commands/formats.ts
index e0635989f..004132055 100644
--- a/packages/cli/src/commands/formats.ts
+++ b/packages/cli/src/commands/formats.ts
@@ -1,9 +1,8 @@
+import { bold, fmtList, kv } from '#cli/format'
import { defineCommand } from 'citty'
import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
-import { bold, fmtList, kv } from '#cli/format'
-
const io = new IORegistry(BUILTIN_IO_FORMATS)
function supportLabels(format: ReturnType<IORegistry['listFormats']>[number]): string[] {
diff --git a/packages/cli/src/commands/info.ts b/packages/cli/src/commands/info.ts
index fe4992a40..edef99cd0 100644
--- a/packages/cli/src/commands/info.ts
+++ b/packages/cli/src/commands/info.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { bold, fmtHistogram, fmtSummary, kv } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { InfoResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/lint.ts b/packages/cli/src/commands/lint.ts
index 48f43be58..a95fe4545 100644
--- a/packages/cli/src/commands/lint.ts
+++ b/packages/cli/src/commands/lint.ts
@@ -1,10 +1,9 @@
+import { bold, dim, fail, fmtList, ok } from '#cli/format'
+import { loadDocument } from '#cli/headless'
import { defineCommand } from 'citty'
import { allRules, createLinter, presets, type LintMessage } from '@open-pencil/core/lint'
-import { bold, dim, fail, fmtList, ok } from '#cli/format'
-import { loadDocument } from '#cli/headless'
-
function formatSeverity(severity: LintMessage['severity']) {
if (severity === 'error') return fail('error')
if (severity === 'warning') return fail('warn')
diff --git a/packages/cli/src/commands/node.ts b/packages/cli/src/commands/node.ts
index e4f171a58..5893905fa 100644
--- a/packages/cli/src/commands/node.ts
+++ b/packages/cli/src/commands/node.ts
@@ -1,8 +1,8 @@
+import { fmtNode, printError, formatType } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
import { defineCommand } from 'citty'
import { colorToHex } from '@open-pencil/core/color'
-import { loadRpcData } from '#cli/rpc-data'
-import { fmtNode, printError, formatType } from '#cli/format'
import type { NodeResult } from '@open-pencil/core/rpc'
import type { Color } from '@open-pencil/core/types'
@@ -19,7 +19,9 @@ export default defineCommand({
json: { type: 'boolean', description: 'Output as JSON' }
},
async run({ args }) {
- const data = await loadRpcData<NodeResult | { error: string }>(args.file, 'node', { id: args.id })
+ const data = await loadRpcData<NodeResult | { error: string }>(args.file, 'node', {
+ id: args.id
+ })
if ('error' in data) {
printError(data.error)
diff --git a/packages/cli/src/commands/pages.ts b/packages/cli/src/commands/pages.ts
index 57860e0c4..3f6776ea4 100644
--- a/packages/cli/src/commands/pages.ts
+++ b/packages/cli/src/commands/pages.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { bold, fmtList, entity } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { PageItem } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/query.ts b/packages/cli/src/commands/query.ts
index 3316c0036..e53fca4e4 100644
--- a/packages/cli/src/commands/query.ts
+++ b/packages/cli/src/commands/query.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { printNodeResults, printError } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { QueryNodeResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/commands/selection.ts b/packages/cli/src/commands/selection.ts
index a6c345010..fe8e9ffa2 100644
--- a/packages/cli/src/commands/selection.ts
+++ b/packages/cli/src/commands/selection.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
import { rpc } from '#cli/app-client'
import { bold, entity, fmtList, formatType, printError } from '#cli/format'
+import { defineCommand } from 'citty'
interface SelectionNode {
id: string
diff --git a/packages/cli/src/commands/tree.ts b/packages/cli/src/commands/tree.ts
index 89ee47ebc..5c90f53ce 100644
--- a/packages/cli/src/commands/tree.ts
+++ b/packages/cli/src/commands/tree.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { fmtTree, printError, entity, formatType } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { TreeNodeResult, TreeResult } from '@open-pencil/core/rpc'
import type { TreeNode } from 'agentfmt'
diff --git a/packages/cli/src/commands/variables.ts b/packages/cli/src/commands/variables.ts
index c5d564014..2a78ac7be 100644
--- a/packages/cli/src/commands/variables.ts
+++ b/packages/cli/src/commands/variables.ts
@@ -1,7 +1,6 @@
-import { defineCommand } from 'citty'
-
-import { loadRpcData } from '#cli/rpc-data'
import { bold, entity, fmtList, fmtSummary } from '#cli/format'
+import { loadRpcData } from '#cli/rpc-data'
+import { defineCommand } from 'citty'
import type { VariablesResult } from '@open-pencil/core/rpc'
diff --git a/packages/cli/src/rpc-data.ts b/packages/cli/src/rpc-data.ts
index f4dd510cd..43d46797f 100644
--- a/packages/cli/src/rpc-data.ts
+++ b/packages/cli/src/rpc-data.ts
@@ -1,8 +1,8 @@
-import { executeRpcCommand } from '@open-pencil/core/rpc'
-
import { isAppMode, requireFile, rpc } from '#cli/app-client'
import { loadDocument } from '#cli/headless'
+import { executeRpcCommand } from '@open-pencil/core/rpc'
+
export async function loadRpcData<Result>(
file: string | undefined,
command: string,
diff --git a/packages/core/src/canvas/ai-overlays.ts b/packages/core/src/canvas/ai-overlays.ts
index 29f665955..0ecf4c140 100644
--- a/packages/core/src/canvas/ai-overlays.ts
+++ b/packages/core/src/canvas/ai-overlays.ts
@@ -4,6 +4,7 @@ import {
AI_PULSE_PERIOD_MS,
AI_DONE_DURATION_MS
} from '#core/constants'
+
import { drawNodeHighlightRect } from './highlight-rect'
import type { SceneGraph } from '#core/scene-graph'
diff --git a/packages/core/src/canvas/labels/draw.ts b/packages/core/src/canvas/labels/draw.ts
index e791993a0..8ba53ee79 100644
--- a/packages/core/src/canvas/labels/draw.ts
+++ b/packages/core/src/canvas/labels/draw.ts
@@ -9,8 +9,8 @@ import {
COMPONENT_LABEL_ICON_GAP
} from '#core/constants'
-import type { SceneNode, SceneGraph } from '#core/scene-graph'
import type { SkiaRenderer } from '#core/canvas/renderer'
+import type { SceneNode, SceneGraph } from '#core/scene-graph'
import type { Canvas, Font } from 'canvaskit-wasm'
export function drawSectionTitles(r: SkiaRenderer, canvas: Canvas, graph: SceneGraph): void {
diff --git a/packages/core/src/canvas/renderer/fonts.ts b/packages/core/src/canvas/renderer/fonts.ts
index c4d1d284c..63dcf55ae 100644
--- a/packages/core/src/canvas/renderer/fonts.ts
+++ b/packages/core/src/canvas/renderer/fonts.ts
@@ -7,8 +7,8 @@ import {
SIZE_FONT_SIZE
} from '#core/constants'
-import type { SceneGraph } from '#core/scene-graph'
import type { SkiaRenderer } from '#core/canvas/renderer'
+import type { SceneGraph } from '#core/scene-graph'
export function getFontProvider(r: SkiaRenderer) {
return r.fontProvider
diff --git a/packages/core/src/canvas/renderer/methods.ts b/packages/core/src/canvas/renderer/methods.ts
index 82760f48b..bdfe03f40 100644
--- a/packages/core/src/canvas/renderer/methods.ts
+++ b/packages/core/src/canvas/renderer/methods.ts
@@ -9,281 +9,283 @@ import * as Rulers from '#core/canvas/rulers'
import * as SceneRender from '#core/canvas/scene'
import * as Shapes from '#core/canvas/shapes'
import * as Strokes from '#core/canvas/strokes'
+
+import type { NodeEditOverlayState } from '#core/canvas/node-edit-overlay'
+import type { SkiaRenderer } from '#core/canvas/renderer'
+import type { RenderOverlays } from '#core/canvas/renderer/types'
import type { Fill, SceneGraph, SceneNode, Stroke } from '#core/scene-graph'
import type { SnapGuide } from '#core/scene-graph/snap'
import type { TextEditor } from '#core/text/editor'
import type { Rect, Vector } from '#core/types'
import type { ImageFilter, MaskFilter, Canvas, Paint, Path } from 'canvaskit-wasm'
-import type { NodeEditOverlayState } from '#core/canvas/node-edit-overlay'
-import type { RenderOverlays } from '#core/canvas/renderer/types'
-import type { SkiaRenderer } from '#core/canvas/renderer'
const rendererMethods: ThisType<SkiaRenderer> = {
-drawHoverHighlight(
- canvas: Canvas,
- graph: SceneGraph,
- hoveredNodeId?: string | null
-): void {
- Overlays.drawHoverHighlight(this, canvas, graph, hoveredNodeId)
-},
-
-drawEnteredContainer(
- canvas: Canvas,
- graph: SceneGraph,
- enteredContainerId?: string | null
-): void {
- Overlays.drawEnteredContainer(this, canvas, graph, enteredContainerId)
-},
-
-drawSelection(
- canvas: Canvas,
- graph: SceneGraph,
- selectedIds: Set<string>,
- overlays: RenderOverlays
-): void {
- Overlays.drawSelection(this, canvas, graph, selectedIds, overlays)
-},
-
-drawNodeSelection(canvas: Canvas, node: SceneNode, rotation: number, graph: SceneGraph): void {
- Overlays.drawNodeSelection(this, canvas, node, rotation, graph)
-},
-
-drawSelectionLabels(
- canvas: Canvas,
- graph: SceneGraph,
- selectedIds: Set<string>,
- overlays?: RenderOverlays
-): void {
- Overlays.drawSelectionLabels(this, canvas, graph, selectedIds, overlays)
-},
-
-drawParentFrameOutlines(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {
- Overlays.drawParentFrameOutlines(this, canvas, graph, selectedIds)
-},
-
-drawNodeOutline(canvas: Canvas, node: SceneNode, rotation: number, graph: SceneGraph): void {
- Overlays.drawNodeOutline(this, canvas, node, rotation, graph)
-},
-
-drawGroupBounds(canvas: Canvas, nodes: SceneNode[], graph: SceneGraph): void {
- Overlays.drawGroupBounds(this, canvas, nodes, graph)
-},
-
-getRotatedCorners(n: SceneNode, abs: Vector): Vector[] {
- return Overlays.getRotatedCorners(this, n, abs)
-},
-
-drawHandle(canvas: Canvas, x: number, y: number): void {
- Overlays.drawHandle(this, canvas, x, y)
-},
-
-drawSnapGuides(canvas: Canvas, guides?: SnapGuide[]): void {
- Overlays.drawSnapGuides(this, canvas, guides)
-},
-
-drawMarquee(canvas: Canvas, marquee?: Rect | null): void {
- Overlays.drawMarquee(this, canvas, marquee)
-},
-
-drawFlashes(canvas: Canvas, graph: SceneGraph): void {
- Overlays.drawFlashes(this, canvas, graph)
- AiOverlays.drawAiOverlays(this, canvas, graph)
-},
-
-drawLayoutInsertIndicator(
- canvas: Canvas,
- indicator?: RenderOverlays['layoutInsertIndicator']
-): void {
- Overlays.drawLayoutInsertIndicator(this, canvas, indicator)
-},
-
-drawTextEditOverlay(canvas: Canvas, node: SceneNode, editor: TextEditor): void {
- Overlays.drawTextEditOverlay(this, canvas, node, editor)
-},
-
-drawNodeEditOverlay(
- canvas: Canvas,
- graph: SceneGraph,
- editState: RenderOverlays['nodeEditState']
-): void {
- NodeEditOverlay.drawNodeEditOverlay(this, canvas, graph, editState as NodeEditOverlayState | null)
-},
-
-drawPenOverlay(canvas: Canvas, penState: RenderOverlays['penState']): void {
- PenOverlay.drawPenOverlay(this, canvas, penState)
-},
-
-drawRemoteCursors(
- canvas: Canvas,
- graph: SceneGraph,
- cursors?: RenderOverlays['remoteCursors']
-): void {
- PenOverlay.drawRemoteCursors(this, canvas, graph, cursors)
-},
-
-drawRulers(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {
- Rulers.drawRulers(this, canvas, graph, selectedIds)
-},
-
-drawSectionTitles(canvas: Canvas, graph: SceneGraph): void {
- Labels.drawSectionTitles(this, canvas, graph)
-},
-
-drawComponentLabels(canvas: Canvas, graph: SceneGraph): void {
- Labels.drawComponentLabels(this, canvas, graph)
-},
-
-renderNode(canvas: Canvas, graph: SceneGraph, nodeId: string, overlays: RenderOverlays): void {
- SceneRender.renderNode(this, canvas, graph, nodeId, overlays)
-},
-
-renderSection(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
- SceneRender.renderSection(this, canvas, node, graph)
-},
-
-renderComponentSet(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
- SceneRender.renderComponentSet(this, canvas, node, graph)
-},
-
-renderShape(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
- SceneRender.renderShape(this, canvas, node, graph)
-},
-
-renderShapeUncached(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
- SceneRender.renderShapeUncached(this, canvas, node, graph)
-},
-
-renderEffects(
- canvas: Canvas,
- node: SceneNode,
- rect: Float32Array,
- hasRadius: boolean,
- pass: 'behind' | 'front',
- shadowShapeChild?: SceneNode | null
-): void {
- Effects.renderEffects(this, canvas, node, rect, hasRadius, pass, shadowShapeChild)
-},
-
-renderText(canvas: Canvas, node: SceneNode): void {
- SceneRender.renderText(this, canvas, node)
-},
-
-drawNodeFill(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {
- Fills.drawNodeFill(this, canvas, node, rect, hasRadius)
-},
-
-applyFill(fill: Fill, node: SceneNode, graph: SceneGraph, fillIndex = 0): boolean {
- return Fills.applyFill(this, fill, node, graph, fillIndex)
-},
-
-applyGradientFill(fill: Fill, node: SceneNode, graph: SceneGraph): void {
- Fills.applyGradientFill(this, fill, node, graph)
-},
-
-applyImageFill(fill: Fill, node: SceneNode, graph: SceneGraph): boolean {
- return Fills.applyImageFill(this, fill, node, graph)
-},
-
-drawArc(canvas: Canvas, node: SceneNode, paint: Paint): void {
- Fills.drawArc(this, canvas, node, paint)
-},
-
-drawNodeStroke(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {
- Strokes.drawNodeStroke(this, canvas, node, rect, hasRadius)
-},
-
-drawStrokeWithAlign(
- canvas: Canvas,
- node: SceneNode,
- rect: Float32Array,
- hasRadius: boolean,
- align: 'INSIDE' | 'CENTER' | 'OUTSIDE'
-): void {
- Strokes.drawStrokeWithAlign(this, canvas, node, rect, hasRadius, align)
-},
-
-drawRRectStrokeWithAlign(
- canvas: Canvas,
- rrect: Float32Array,
- node: SceneNode,
- stroke: Stroke
-): void {
- Strokes.drawRRectStrokeWithAlign(this, canvas, rrect, node, stroke)
-},
-
-drawIndividualSideStrokes(
- canvas: Canvas,
- node: SceneNode,
- align: 'INSIDE' | 'CENTER' | 'OUTSIDE'
-): void {
- Strokes.drawIndividualSideStrokes(this, canvas, node, align)
-},
-
-strokeNodeShape(canvas: Canvas, node: SceneNode, paint: Paint): void {
- Strokes.strokeNodeShape(this, canvas, node, paint)
-},
-
-makeNodeShapePath(node: SceneNode, rect: Float32Array, hasRadius: boolean): Path {
- return Shapes.makeNodeShapePath(this, node, rect, hasRadius)
-},
-
-makePolygonPath(node: SceneNode): Path {
- return Shapes.makePolygonPath(this, node)
-},
-
-makeRRect(node: SceneNode): Float32Array {
- return Shapes.makeRRect(this, node)
-},
-
-makeRRectWithSpread(node: SceneNode, spread: number): Float32Array {
- return Shapes.makeRRectWithSpread(this, node, spread)
-},
-
-makeRRectWithOffset(node: SceneNode, ox: number, oy: number, spread: number): Float32Array {
- return Shapes.makeRRectWithOffset(this, node, ox, oy, spread)
-},
-
-clipNodeShape(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {
- Shapes.clipNodeShape(this, canvas, node, rect, hasRadius)
-},
-
-getVectorPaths(node: SceneNode): Path[] | null {
- return Shapes.getVectorPaths(this, node)
-},
-
-getFillGeometry(node: SceneNode): Path[] | null {
- return Shapes.getFillGeometry(this, node)
-},
-
-getStrokeGeometry(node: SceneNode): Path[] | null {
- return Shapes.getStrokeGeometry(this, node)
-},
-
-getCachedDropShadow(dx: number, dy: number, sigma: number, color: Float32Array): ImageFilter {
- return Effects.getCachedDropShadow(this, dx, dy, sigma, color)
-},
-
-getCachedBlur(sigma: number): ImageFilter {
- return Effects.getCachedBlur(this, sigma)
-},
-
-getCachedDecalBlur(sigma: number): ImageFilter {
- return Effects.getCachedDecalBlur(this, sigma)
-},
-
-getCachedMaskBlur(sigma: number): MaskFilter {
- return Effects.getCachedMaskBlur(this, sigma)
-},
-
-applyClippedBlur(
- canvas: Canvas,
- node: SceneNode,
- rect: Float32Array,
- hasRadius: boolean,
- sigma: number
-): void {
- Effects.applyClippedBlur(this, canvas, node, rect, hasRadius, sigma)
-}
+ drawHoverHighlight(canvas: Canvas, graph: SceneGraph, hoveredNodeId?: string | null): void {
+ Overlays.drawHoverHighlight(this, canvas, graph, hoveredNodeId)
+ },
+
+ drawEnteredContainer(
+ canvas: Canvas,
+ graph: SceneGraph,
+ enteredContainerId?: string | null
+ ): void {
+ Overlays.drawEnteredContainer(this, canvas, graph, enteredContainerId)
+ },
+
+ drawSelection(
+ canvas: Canvas,
+ graph: SceneGraph,
+ selectedIds: Set<string>,
+ overlays: RenderOverlays
+ ): void {
+ Overlays.drawSelection(this, canvas, graph, selectedIds, overlays)
+ },
+
+ drawNodeSelection(canvas: Canvas, node: SceneNode, rotation: number, graph: SceneGraph): void {
+ Overlays.drawNodeSelection(this, canvas, node, rotation, graph)
+ },
+
+ drawSelectionLabels(
+ canvas: Canvas,
+ graph: SceneGraph,
+ selectedIds: Set<string>,
+ overlays?: RenderOverlays
+ ): void {
+ Overlays.drawSelectionLabels(this, canvas, graph, selectedIds, overlays)
+ },
+
+ drawParentFrameOutlines(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {
+ Overlays.drawParentFrameOutlines(this, canvas, graph, selectedIds)
+ },
+
+ drawNodeOutline(canvas: Canvas, node: SceneNode, rotation: number, graph: SceneGraph): void {
+ Overlays.drawNodeOutline(this, canvas, node, rotation, graph)
+ },
+
+ drawGroupBounds(canvas: Canvas, nodes: SceneNode[], graph: SceneGraph): void {
+ Overlays.drawGroupBounds(this, canvas, nodes, graph)
+ },
+
+ getRotatedCorners(n: SceneNode, abs: Vector): Vector[] {
+ return Overlays.getRotatedCorners(this, n, abs)
+ },
+
+ drawHandle(canvas: Canvas, x: number, y: number): void {
+ Overlays.drawHandle(this, canvas, x, y)
+ },
+
+ drawSnapGuides(canvas: Canvas, guides?: SnapGuide[]): void {
+ Overlays.drawSnapGuides(this, canvas, guides)
+ },
+
+ drawMarquee(canvas: Canvas, marquee?: Rect | null): void {
+ Overlays.drawMarquee(this, canvas, marquee)
+ },
+
+ drawFlashes(canvas: Canvas, graph: SceneGraph): void {
+ Overlays.drawFlashes(this, canvas, graph)
+ AiOverlays.drawAiOverlays(this, canvas, graph)
+ },
+
+ drawLayoutInsertIndicator(
+ canvas: Canvas,
+ indicator?: RenderOverlays['layoutInsertIndicator']
+ ): void {
+ Overlays.drawLayoutInsertIndicator(this, canvas, indicator)
+ },
+
+ drawTextEditOverlay(canvas: Canvas, node: SceneNode, editor: TextEditor): void {
+ Overlays.drawTextEditOverlay(this, canvas, node, editor)
+ },
+
+ drawNodeEditOverlay(
+ canvas: Canvas,
+ graph: SceneGraph,
+ editState: RenderOverlays['nodeEditState']
+ ): void {
+ NodeEditOverlay.drawNodeEditOverlay(
+ this,
+ canvas,
+ graph,
+ editState as NodeEditOverlayState | null
+ )
+ },
+
+ drawPenOverlay(canvas: Canvas, penState: RenderOverlays['penState']): void {
+ PenOverlay.drawPenOverlay(this, canvas, penState)
+ },
+
+ drawRemoteCursors(
+ canvas: Canvas,
+ graph: SceneGraph,
+ cursors?: RenderOverlays['remoteCursors']
+ ): void {
+ PenOverlay.drawRemoteCursors(this, canvas, graph, cursors)
+ },
+
+ drawRulers(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {
+ Rulers.drawRulers(this, canvas, graph, selectedIds)
+ },
+
+ drawSectionTitles(canvas: Canvas, graph: SceneGraph): void {
+ Labels.drawSectionTitles(this, canvas, graph)
+ },
+
+ drawComponentLabels(canvas: Canvas, graph: SceneGraph): void {
+ Labels.drawComponentLabels(this, canvas, graph)
+ },
+
+ renderNode(canvas: Canvas, graph: SceneGraph, nodeId: string, overlays: RenderOverlays): void {
+ SceneRender.renderNode(this, canvas, graph, nodeId, overlays)
+ },
+
+ renderSection(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
+ SceneRender.renderSection(this, canvas, node, graph)
+ },
+
+ renderComponentSet(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
+ SceneRender.renderComponentSet(this, canvas, node, graph)
+ },
+
+ renderShape(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
+ SceneRender.renderShape(this, canvas, node, graph)
+ },
+
+ renderShapeUncached(canvas: Canvas, node: SceneNode, graph: SceneGraph): void {
+ SceneRender.renderShapeUncached(this, canvas, node, graph)
+ },
+
+ renderEffects(
+ canvas: Canvas,
+ node: SceneNode,
+ rect: Float32Array,
+ hasRadius: boolean,
+ pass: 'behind' | 'front',
+ shadowShapeChild?: SceneNode | null
+ ): void {
+ Effects.renderEffects(this, canvas, node, rect, hasRadius, pass, shadowShapeChild)
+ },
+
+ renderText(canvas: Canvas, node: SceneNode): void {
+ SceneRender.renderText(this, canvas, node)
+ },
+
+ drawNodeFill(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {
+ Fills.drawNodeFill(this, canvas, node, rect, hasRadius)
+ },
+
+ applyFill(fill: Fill, node: SceneNode, graph: SceneGraph, fillIndex = 0): boolean {
+ return Fills.applyFill(this, fill, node, graph, fillIndex)
+ },
+
+ applyGradientFill(fill: Fill, node: SceneNode, graph: SceneGraph): void {
+ Fills.applyGradientFill(this, fill, node, graph)
+ },
+
+ applyImageFill(fill: Fill, node: SceneNode, graph: SceneGraph): boolean {
+ return Fills.applyImageFill(this, fill, node, graph)
+ },
+
+ drawArc(canvas: Canvas, node: SceneNode, paint: Paint): void {
+ Fills.drawArc(this, canvas, node, paint)
+ },
+
+ drawNodeStroke(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {
+ Strokes.drawNodeStroke(this, canvas, node, rect, hasRadius)
+ },
+
+ drawStrokeWithAlign(
+ canvas: Canvas,
+ node: SceneNode,
+ rect: Float32Array,
+ hasRadius: boolean,
+ align: 'INSIDE' | 'CENTER' | 'OUTSIDE'
+ ): void {
+ Strokes.drawStrokeWithAlign(this, canvas, node, rect, hasRadius, align)
+ },
+
+ drawRRectStrokeWithAlign(
+ canvas: Canvas,
+ rrect: Float32Array,
+ node: SceneNode,
+ stroke: Stroke
+ ): void {
+ Strokes.drawRRectStrokeWithAlign(this, canvas, rrect, node, stroke)
+ },
+
+ drawIndividualSideStrokes(
+ canvas: Canvas,
+ node: SceneNode,
+ align: 'INSIDE' | 'CENTER' | 'OUTSIDE'
+ ): void {
+ Strokes.drawIndividualSideStrokes(this, canvas, node, align)
+ },
+
+ strokeNodeShape(canvas: Canvas, node: SceneNode, paint: Paint): void {
+ Strokes.strokeNodeShape(this, canvas, node, paint)
+ },
+
+ makeNodeShapePath(node: SceneNode, rect: Float32Array, hasRadius: boolean): Path {
+ return Shapes.makeNodeShapePath(this, node, rect, hasRadius)
+ },
+
+ makePolygonPath(node: SceneNode): Path {
+ return Shapes.makePolygonPath(this, node)
+ },
+
+ makeRRect(node: SceneNode): Float32Array {
+ return Shapes.makeRRect(this, node)
+ },
+
+ makeRRectWithSpread(node: SceneNode, spread: number): Float32Array {
+ return Shapes.makeRRectWithSpread(this, node, spread)
+ },
+
+ makeRRectWithOffset(node: SceneNode, ox: number, oy: number, spread: number): Float32Array {
+ return Shapes.makeRRectWithOffset(this, node, ox, oy, spread)
+ },
+
+ clipNodeShape(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {
+ Shapes.clipNodeShape(this, canvas, node, rect, hasRadius)
+ },
+
+ getVectorPaths(node: SceneNode): Path[] | null {
+ return Shapes.getVectorPaths(this, node)
+ },
+
+ getFillGeometry(node: SceneNode): Path[] | null {
+ return Shapes.getFillGeometry(this, node)
+ },
+
+ getStrokeGeometry(node: SceneNode): Path[] | null {
+ return Shapes.getStrokeGeometry(this, node)
+ },
+
+ getCachedDropShadow(dx: number, dy: number, sigma: number, color: Float32Array): ImageFilter {
+ return Effects.getCachedDropShadow(this, dx, dy, sigma, color)
+ },
+
+ getCachedBlur(sigma: number): ImageFilter {
+ return Effects.getCachedBlur(this, sigma)
+ },
+
+ getCachedDecalBlur(sigma: number): ImageFilter {
+ return Effects.getCachedDecalBlur(this, sigma)
+ },
+
+ getCachedMaskBlur(sigma: number): MaskFilter {
+ return Effects.getCachedMaskBlur(this, sigma)
+ },
+
+ applyClippedBlur(
+ canvas: Canvas,
+ node: SceneNode,
+ rect: Float32Array,
+ hasRadius: boolean,
+ sigma: number
+ ): void {
+ Effects.applyClippedBlur(this, canvas, node, rect, hasRadius, sigma)
+ }
}
export function installRendererDomainMethods(prototype: object): void {
diff --git a/packages/core/src/canvas/renderer/paints.ts b/packages/core/src/canvas/renderer/paints.ts
index 8ad38e054..9368fded9 100644
--- a/packages/core/src/canvas/renderer/paints.ts
+++ b/packages/core/src/canvas/renderer/paints.ts
@@ -60,7 +60,9 @@ export function initializeRendererPaints(r: SkiaRenderer): void {
r.rulerBgPaint.setColor(ck.Color4f(bg.r, bg.g, bg.b, 1))
r.rulerTickPaint = new ck.Paint()
- r.rulerTickPaint.setColor(ck.Color4f(RULER_TICK_COLOR.r, RULER_TICK_COLOR.g, RULER_TICK_COLOR.b, 1))
+ r.rulerTickPaint.setColor(
+ ck.Color4f(RULER_TICK_COLOR.r, RULER_TICK_COLOR.g, RULER_TICK_COLOR.b, 1)
+ )
r.rulerTickPaint.setStrokeWidth(1)
r.rulerTickPaint.setAntiAlias(true)
diff --git a/packages/core/src/canvas/scene.ts b/packages/core/src/canvas/scene.ts
index 61902e8e7..481f98b1b 100644
--- a/packages/core/src/canvas/scene.ts
+++ b/packages/core/src/canvas/scene.ts
@@ -190,10 +190,7 @@ function forVisibleStrokes(
r: SkiaRenderer,
node: SceneNode,
graph: SceneGraph,
- draw: (
- stroke: SceneNode['strokes'][number],
- color: Color
- ) => void
+ draw: (stroke: SceneNode['strokes'][number], color: Color) => void
): void {
for (let index = 0; index < node.strokes.length; index++) {
const stroke = node.strokes[index]
diff --git a/packages/core/src/color/index.ts b/packages/core/src/color/index.ts
index f211fe973..4113b8040 100644
--- a/packages/core/src/color/index.ts
+++ b/packages/core/src/color/index.ts
@@ -2,9 +2,8 @@ export * from './management'
export { normalizeColor } from './normalize'
export * from './okhcl'
-import { parse, formatHex, formatHex8, formatRgb, converter, differenceEuclidean } from 'culori'
-
import { BLACK } from '#core/constants'
+import { parse, formatHex, formatHex8, formatRgb, converter, differenceEuclidean } from 'culori'
import type { Color } from '#core/types'
diff --git a/packages/core/src/color/okhcl.ts b/packages/core/src/color/okhcl.ts
index 27e3b06bc..6d90a6290 100644
--- a/packages/core/src/color/okhcl.ts
+++ b/packages/core/src/color/okhcl.ts
@@ -1,6 +1,6 @@
+import { copyFill, copyStroke } from '#core/scene-graph/copy'
import { converter, toGamut } from 'culori'
-import { copyFill, copyStroke } from '#core/scene-graph/copy'
import { normalizeColor } from './normalize'
import type { SceneNode } from '#core/scene-graph'
diff --git a/packages/core/src/design-jsx/renderer.ts b/packages/core/src/design-jsx/renderer.ts
index fe154584e..10c145e9f 100644
--- a/packages/core/src/design-jsx/renderer.ts
+++ b/packages/core/src/design-jsx/renderer.ts
@@ -2,8 +2,9 @@ import { parseColor } from '#core/color'
import { fetchIcons } from '#core/icons'
import { createIconFromPaths } from '#core/icons/render'
import { computeAllLayouts } from '#core/layout'
-import { isTreeNode } from './tree'
+
import { applySizeOverrides, propsToOverrides } from './props-overrides'
+import { isTreeNode } from './tree'
import type { SceneGraph, SceneNode, NodeType } from '#core/scene-graph'
import type { TreeNode } from './tree'
diff --git a/packages/core/src/editor/clipboard/images.ts b/packages/core/src/editor/clipboard/images.ts
index 10ccb6032..96acaeb6e 100644
--- a/packages/core/src/editor/clipboard/images.ts
+++ b/packages/core/src/editor/clipboard/images.ts
@@ -1,7 +1,7 @@
import { computeImageHash } from '#core/figma-api'
-import type { Fill } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { Fill } from '#core/scene-graph'
const IMAGE_MAX_DIMENSION = 4096
const IMAGE_GAP = 20
diff --git a/packages/core/src/editor/component-sync.ts b/packages/core/src/editor/component-sync.ts
index f69cb0750..93ec73096 100644
--- a/packages/core/src/editor/component-sync.ts
+++ b/packages/core/src/editor/component-sync.ts
@@ -1,6 +1,9 @@
import type { SceneGraph } from '#core/scene-graph'
-export function createComponentSyncScheduler(getGraph: () => SceneGraph, requestRender: () => void) {
+export function createComponentSyncScheduler(
+ getGraph: () => SceneGraph,
+ requestRender: () => void
+) {
let pendingComponentSync: Set<string> | null = null
function flushComponentSync() {
diff --git a/packages/core/src/editor/components/focus.ts b/packages/core/src/editor/components/focus.ts
index 024f9f9ad..8629f5e18 100644
--- a/packages/core/src/editor/components/focus.ts
+++ b/packages/core/src/editor/components/focus.ts
@@ -1,5 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { SceneNode } from '#core/scene-graph'
export function createComponentFocusActions(ctx: EditorContext) {
function goToMainComponent(
diff --git a/packages/core/src/editor/components/instances.ts b/packages/core/src/editor/components/instances.ts
index fbcb53328..332ed0801 100644
--- a/packages/core/src/editor/components/instances.ts
+++ b/packages/core/src/editor/components/instances.ts
@@ -1,5 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { SceneNode } from '#core/scene-graph'
export function createComponentInstanceActions(ctx: EditorContext) {
function createInstanceFromComponent(componentId: string, x?: number, y?: number) {
diff --git a/packages/core/src/editor/create.ts b/packages/core/src/editor/create.ts
index 7322478ca..1db9056e1 100644
--- a/packages/core/src/editor/create.ts
+++ b/packages/core/src/editor/create.ts
@@ -5,15 +5,16 @@ import { SceneGraph } from '#core/scene-graph'
import { UndoManager } from '#core/scene-graph/undo'
import { TextEditor } from '#core/text/editor'
import { loadFont as defaultLoadFont } from '#core/text/fonts'
+
+import { createAlignmentActions } from './alignment'
import { createClipboardBridge } from './bridges/clipboard'
import { createComponentBridge } from './bridges/components'
import { createStructureBridge } from './bridges/structure'
import { createUndoBridge } from './bridges/undo'
-import { createAlignmentActions } from './alignment'
import { createClipboardActions } from './clipboard'
import { createColorSpaceActions } from './color-space'
-import { createComponentActions } from './components'
import { createComponentSyncScheduler } from './component-sync'
+import { createComponentActions } from './components'
import { createGraphEventSubscription } from './graph-events'
import { createGraphReadActions } from './graph-reads'
import { createLayoutRunner } from './layout-runner'
diff --git a/packages/core/src/editor/selection.ts b/packages/core/src/editor/selection.ts
index da5339374..61332af0d 100644
--- a/packages/core/src/editor/selection.ts
+++ b/packages/core/src/editor/selection.ts
@@ -2,6 +2,7 @@ import { createSelectionContainerActions } from './selection/container'
import { createSelectionHitTestActions } from './selection/hit-test'
import { createSelectionOverlayActions } from './selection/overlays'
import { createSelectionReadActions } from './selection/read'
+
import type { EditorContext } from './types'
export function createSelectionActions(ctx: EditorContext) {
diff --git a/packages/core/src/editor/selection/hit-test.ts b/packages/core/src/editor/selection/hit-test.ts
index 5259816c5..052116fec 100644
--- a/packages/core/src/editor/selection/hit-test.ts
+++ b/packages/core/src/editor/selection/hit-test.ts
@@ -1,5 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { SceneNode } from '#core/scene-graph'
export function createSelectionHitTestActions(
ctx: EditorContext,
diff --git a/packages/core/src/editor/selection/overlays.ts b/packages/core/src/editor/selection/overlays.ts
index 52e578808..616931949 100644
--- a/packages/core/src/editor/selection/overlays.ts
+++ b/packages/core/src/editor/selection/overlays.ts
@@ -1,6 +1,6 @@
+import type { EditorContext } from '#core/editor/types'
import type { SnapGuide } from '#core/scene-graph/snap'
import type { Rect } from '#core/types'
-import type { EditorContext } from '#core/editor/types'
export function createSelectionOverlayActions(ctx: EditorContext) {
function setMarquee(rect: Rect | null) {
diff --git a/packages/core/src/editor/shapes.ts b/packages/core/src/editor/shapes.ts
index 294b70988..9cc947470 100644
--- a/packages/core/src/editor/shapes.ts
+++ b/packages/core/src/editor/shapes.ts
@@ -4,6 +4,7 @@ import {
SECTION_DEFAULT_FILL,
SECTION_DEFAULT_STROKE
} from '#core/constants'
+
import { createPenActions } from './shapes/pen'
import { adoptNodesIntoSection as adoptNodesIntoSectionImpl } from './shapes/section-adopt'
diff --git a/packages/core/src/editor/shapes/pen.ts b/packages/core/src/editor/shapes/pen.ts
index ee50816ec..d9cc2e8e9 100644
--- a/packages/core/src/editor/shapes/pen.ts
+++ b/packages/core/src/editor/shapes/pen.ts
@@ -1,8 +1,8 @@
import { computeVectorBounds } from '#core/vector'
+import type { EditorContext } from '#core/editor/types'
import type { Fill, SceneNode, VectorNetwork, VectorRegion, VectorSegment } from '#core/scene-graph'
import type { Vector } from '#core/types'
-import type { EditorContext } from '#core/editor/types'
export interface PenDragOptions {
keepOpposite?: boolean
diff --git a/packages/core/src/editor/structure/auto-layout-wrap.ts b/packages/core/src/editor/structure/auto-layout-wrap.ts
index 536eebe83..f7762b001 100644
--- a/packages/core/src/editor/structure/auto-layout-wrap.ts
+++ b/packages/core/src/editor/structure/auto-layout-wrap.ts
@@ -1,8 +1,8 @@
import { computeAbsoluteBounds } from '#core/geometry'
import { computeLayout } from '#core/layout'
-import type { LayoutMode, SceneNode } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { LayoutMode, SceneNode } from '#core/scene-graph'
export function wrapInAutoLayout(
ctx: EditorContext,
@@ -22,9 +22,7 @@ export function wrapInAutoLayout(
const bounds = computeAbsoluteBounds(selectedNodes, (id) => ctx.graph.getAbsolutePosition(id))
- const parentAbs = isTopLevel(parentId)
- ? { x: 0, y: 0 }
- : ctx.graph.getAbsolutePosition(parentId)
+ const parentAbs = isTopLevel(parentId) ? { x: 0, y: 0 } : ctx.graph.getAbsolutePosition(parentId)
const direction: LayoutMode =
selectedNodes.length <= 1 || bounds.height > bounds.width ? 'VERTICAL' : 'HORIZONTAL'
diff --git a/packages/core/src/editor/structure/container-wrap.ts b/packages/core/src/editor/structure/container-wrap.ts
index 4cfb52f1c..13cd16584 100644
--- a/packages/core/src/editor/structure/container-wrap.ts
+++ b/packages/core/src/editor/structure/container-wrap.ts
@@ -1,7 +1,7 @@
import { computeAbsoluteBounds } from '#core/geometry'
-import type { SceneNode } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { SceneNode } from '#core/scene-graph'
export function wrapSelectionInContainer(
ctx: EditorContext,
@@ -34,9 +34,7 @@ export function wrapSelectionInContainer(
const maxX = minX + bw
const maxY = minY + bh
- const parentAbs = isTopLevel(parentId)
- ? { x: 0, y: 0 }
- : ctx.graph.getAbsolutePosition(parentId)
+ const parentAbs = isTopLevel(parentId) ? { x: 0, y: 0 } : ctx.graph.getAbsolutePosition(parentId)
const firstIndex = Math.min(...nodeIds.map((id) => parent.childIds.indexOf(id)))
const padding = containerType === 'COMPONENT_SET' ? 40 : 0
diff --git a/packages/core/src/editor/structure/group.ts b/packages/core/src/editor/structure/group.ts
index f5f122b9a..b2507f105 100644
--- a/packages/core/src/editor/structure/group.ts
+++ b/packages/core/src/editor/structure/group.ts
@@ -1,5 +1,5 @@
-import type { SceneNode } from '#core/scene-graph'
import type { EditorContext } from '#core/editor/types'
+import type { SceneNode } from '#core/scene-graph'
export function ungroupSelected(ctx: EditorContext, selectedNode: SceneNode | undefined) {
if (selectedNode?.type !== 'GROUP') return
diff --git a/packages/core/src/editor/undo.ts b/packages/core/src/editor/undo.ts
index 3f4971f8e..b47b22cec 100644
--- a/packages/core/src/editor/undo.ts
+++ b/packages/core/src/editor/undo.ts
@@ -58,7 +58,12 @@ export function createUndoActions(ctx: EditorContext) {
if (ctx.graph.getNode(id)) continue
const snapshot = snapshots.get(id)
if (!snapshot) continue
- restoreSubtree(ctx.graph, snapshot, snapshot.parentId ?? ctx.state.currentPageId, snapshots)
+ restoreSubtree(
+ ctx.graph,
+ snapshot,
+ snapshot.parentId ?? ctx.state.currentPageId,
+ snapshots
+ )
ctx.runLayoutForNode(id)
}
ctx.state.selectedIds = new Set(nextSelection)
diff --git a/packages/core/src/figma-api/accessors/basic.ts b/packages/core/src/figma-api/accessors/basic.ts
index 75654df69..5fd8048a5 100644
--- a/packages/core/src/figma-api/accessors/basic.ts
+++ b/packages/core/src/figma-api/accessors/basic.ts
@@ -1,8 +1,14 @@
-import { graph, nodeId, raw, type NodeProxyInternals, type ProxyThis } from '#core/figma-api/accessor-utils'
+import {
+ graph,
+ nodeId,
+ raw,
+ type NodeProxyInternals,
+ type ProxyThis
+} from '#core/figma-api/accessor-utils'
+import type { NodeProxyHost } from '#core/figma-api/proxy'
import type { SceneNode } from '#core/scene-graph'
import type { Rect } from '#core/types'
-import type { NodeProxyHost } from '#core/figma-api/proxy'
export function installBasicNodeProxyAccessors(
prototype: object,
diff --git a/packages/core/src/figma-api/accessors/layout.ts b/packages/core/src/figma-api/accessors/layout.ts
index b7c66d65c..a48baf3a9 100644
--- a/packages/core/src/figma-api/accessors/layout.ts
+++ b/packages/core/src/figma-api/accessors/layout.ts
@@ -1,4 +1,9 @@
-import { raw, updateNode, type NodeProxyInternals, type ProxyThis } from '#core/figma-api/accessor-utils'
+import {
+ raw,
+ updateNode,
+ type NodeProxyInternals,
+ type ProxyThis
+} from '#core/figma-api/accessor-utils'
import type { LayoutMode, SceneGraph, SceneNode } from '#core/scene-graph'
@@ -6,7 +11,10 @@ function graph(target: ProxyThis, internals: NodeProxyInternals): SceneGraph {
return target[internals.graph] as SceneGraph
}
-function parentLayout(target: ProxyThis, internals: NodeProxyInternals): 'HORIZONTAL' | 'VERTICAL' | 'NONE' {
+function parentLayout(
+ target: ProxyThis,
+ internals: NodeProxyInternals
+): 'HORIZONTAL' | 'VERTICAL' | 'NONE' {
const node = raw(target, internals)
if (!node.parentId) return 'NONE'
const parent = graph(target, internals).getNode(node.parentId)
diff --git a/packages/core/src/figma-api/accessors/visual.ts b/packages/core/src/figma-api/accessors/visual.ts
index 0a664a1c3..298e4cf6e 100644
--- a/packages/core/src/figma-api/accessors/visual.ts
+++ b/packages/core/src/figma-api/accessors/visual.ts
@@ -1,8 +1,12 @@
import { normalizeColor } from '#core/color'
+import {
+ raw,
+ updateNode,
+ type NodeProxyInternals,
+ type ProxyThis
+} from '#core/figma-api/accessor-utils'
import { copyEffects, copyFills, copyStrokes } from '#core/scene-graph/copy'
-import { raw, updateNode, type NodeProxyInternals, type ProxyThis } from '#core/figma-api/accessor-utils'
-
import type { Effect, Fill, SceneNode, Stroke } from '#core/scene-graph'
export function installVisualNodeProxyAccessors(
diff --git a/packages/core/src/figma-api/index.ts b/packages/core/src/figma-api/index.ts
index 8e1d51c18..5dac45ca3 100644
--- a/packages/core/src/figma-api/index.ts
+++ b/packages/core/src/figma-api/index.ts
@@ -1,6 +1,7 @@
import { IS_BROWSER } from '#core/constants'
import { computeBounds } from '#core/geometry'
import { copyFills, copyStrokes, copyEffects } from '#core/scene-graph/copy'
+
import {
FigmaNodeProxy,
INTERNAL_ID,
diff --git a/packages/core/src/figma-api/plugin-data.ts b/packages/core/src/figma-api/plugin-data.ts
index d901f53e6..cd09dbbdc 100644
--- a/packages/core/src/figma-api/plugin-data.ts
+++ b/packages/core/src/figma-api/plugin-data.ts
@@ -10,7 +10,12 @@ export function getPluginData(node: SceneNode, key: string): string {
)
}
-export function setPluginData(graph: SceneGraph, node: SceneNode, key: string, value: string): void {
+export function setPluginData(
+ graph: SceneGraph,
+ node: SceneNode,
+ key: string,
+ value: string
+): void {
const pluginData = node.pluginData.filter(
(entry) => !(entry.pluginId === OPEN_PENCIL_PLUGIN_DATA_NAMESPACE && entry.key === key)
)
@@ -27,7 +32,10 @@ export function getPluginDataKeys(node: SceneNode): string[] {
}
export function getSharedPluginData(node: SceneNode, namespace: string, key: string): string {
- return node.sharedPluginData.find((entry) => entry.namespace === namespace && entry.key === key)?.value ?? ''
+ return (
+ node.sharedPluginData.find((entry) => entry.namespace === namespace && entry.key === key)
+ ?.value ?? ''
+ )
}
export function setSharedPluginData(
diff --git a/packages/core/src/figma-api/proxy.ts b/packages/core/src/figma-api/proxy.ts
index 26642ef2a..52dd984dc 100644
--- a/packages/core/src/figma-api/proxy.ts
+++ b/packages/core/src/figma-api/proxy.ts
@@ -1,14 +1,18 @@
-import { getFillOkHCL, getStrokeOkHCL, setNodeFillOkHCL, setNodeStrokeOkHCL } from '#core/color/okhcl'
-import type { FigmaFontName } from './fonts'
+import {
+ getFillOkHCL,
+ getStrokeOkHCL,
+ setNodeFillOkHCL,
+ setNodeStrokeOkHCL
+} from '#core/color/okhcl'
+
+import { installBasicNodeProxyAccessors } from './accessors/basic'
+import { installLayoutNodeProxyAccessors } from './accessors/layout'
+import { installVisualNodeProxyAccessors } from './accessors/visual'
+import * as PluginData from './plugin-data'
import { nodeProxyToJSON } from './serialization'
+import { setFirstStrokeAlign, setFirstStrokeWeight, setIndependentStrokeWeight } from './strokes'
import * as TextProxy from './text'
-import {
- setFirstStrokeAlign,
- setFirstStrokeWeight,
- setIndependentStrokeWeight
-} from './strokes'
import * as Traversal from './traversal'
-import * as PluginData from './plugin-data'
import type { OkHCLColor, OkHCLPayload } from '#core/color/okhcl'
/* eslint-disable max-lines -- Figma Plugin API proxy; FigmaAPI already in separate file */
@@ -21,10 +25,8 @@ import type {
Effect,
LayoutMode
} from '#core/scene-graph'
-import { installBasicNodeProxyAccessors } from './accessors/basic'
-import { installLayoutNodeProxyAccessors } from './accessors/layout'
-import { installVisualNodeProxyAccessors } from './accessors/visual'
import type { Rect } from '#core/types'
+import type { FigmaFontName } from './fonts'
const MIXED = Symbol('mixed')
@@ -41,7 +43,6 @@ export interface NodeProxyHost {
export { MIXED }
-
export class FigmaNodeProxy {
[INTERNAL_ID]: string;
[INTERNAL_GRAPH]: SceneGraph;
@@ -431,15 +432,30 @@ export class FigmaNodeProxy {
}
findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {
- return Traversal.findChild(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)
+ return Traversal.findChild(
+ this[INTERNAL_GRAPH],
+ this[INTERNAL_API],
+ this[INTERNAL_ID],
+ callback
+ )
}
findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {
- return Traversal.findChildren(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)
+ return Traversal.findChildren(
+ this[INTERNAL_GRAPH],
+ this[INTERNAL_API],
+ this[INTERNAL_ID],
+ callback
+ )
}
findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {
- return Traversal.findAllWithCriteria(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], criteria)
+ return Traversal.findAllWithCriteria(
+ this[INTERNAL_GRAPH],
+ this[INTERNAL_API],
+ this[INTERNAL_ID],
+ criteria
+ )
}
// --- Plugin data ---
@@ -490,7 +506,13 @@ export class FigmaNodeProxy {
// --- Serialization ---
toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {
- return nodeProxyToJSON(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], maxDepth, currentDepth)
+ return nodeProxyToJSON(
+ this[INTERNAL_GRAPH],
+ this[INTERNAL_API],
+ this[INTERNAL_ID],
+ maxDepth,
+ currentDepth
+ )
}
toString(): string {
diff --git a/packages/core/src/icons/api.ts b/packages/core/src/icons/api.ts
index 47df6da59..b358920af 100644
--- a/packages/core/src/icons/api.ts
+++ b/packages/core/src/icons/api.ts
@@ -36,6 +36,6 @@ export async function searchIconify(
return {
icons: icons.slice(0, limit),
total: data.total ?? 0,
- collections: data.collections ?? {},
+ collections: data.collections ?? {}
}
}
diff --git a/packages/core/src/icons/svg.ts b/packages/core/src/icons/svg.ts
index 8797d1dca..f7d2fedaf 100644
--- a/packages/core/src/icons/svg.ts
+++ b/packages/core/src/icons/svg.ts
@@ -1,8 +1,7 @@
+import { parseSVGPath } from '#core/io/formats/svg/parse-path'
import { iconToSVG } from '@iconify/utils'
import svgpath from 'svgpath'
-import { parseSVGPath } from '#core/io/formats/svg/parse-path'
-
import type { IconData, IconifyIconEntry, IconPathInfo } from './types'
function attrValue(tag: string, attr: string): string | null {
@@ -61,7 +60,10 @@ function shapeToD(tagName: string, tag: string): string | null {
case 'polyline': {
const points = attrValue(tag, 'points')
if (!points) return null
- const values = points.trim().split(/[\s,]+/).map(Number)
+ const values = points
+ .trim()
+ .split(/[\s,]+/)
+ .map(Number)
if (values.length < 4) return null
let d = `M${values[0]},${values[1]}`
for (let i = 2; i < values.length; i += 2) d += `L${values[i]},${values[i + 1]}`
@@ -89,7 +91,7 @@ function extractPaths(svgBody: string): IconPathInfo[] {
stroke: null as string | null,
strokeWidth: null as string | null,
strokeCap: null as string | null,
- strokeJoin: null as string | null,
+ strokeJoin: null as string | null
}
const groupRe = /<g\b[^>]*>/g
let groupMatch
@@ -118,7 +120,7 @@ function extractPaths(svgBody: string): IconPathInfo[] {
strokeWidth: parseFloat(attrValue(tag, 'stroke-width') ?? groupAttrs.strokeWidth ?? '1'),
strokeCap: attrValue(tag, 'stroke-linecap') ?? groupAttrs.strokeCap ?? 'butt',
strokeJoin: attrValue(tag, 'stroke-linejoin') ?? groupAttrs.strokeJoin ?? 'miter',
- fillRule: fillRuleAttr === 'evenodd' ? 'EVENODD' : 'NONZERO',
+ fillRule: fillRuleAttr === 'evenodd' ? 'EVENODD' : 'NONZERO'
})
}
return result
@@ -135,7 +137,7 @@ export function buildIconData(
const rendered = iconToSVG({
body: iconEntry.body,
width: iconEntry.width ?? defaultW,
- height: iconEntry.height ?? defaultH,
+ height: iconEntry.height ?? defaultH
})
const [, , viewBoxWidth, viewBoxHeight] = rendered.viewBox
const scaleX = size / viewBoxWidth
@@ -159,8 +161,8 @@ export function buildIconData(
stroke: path.stroke,
strokeWidth: path.strokeWidth * Math.min(scaleX, scaleY),
strokeCap: path.strokeCap,
- strokeJoin: path.strokeJoin,
+ strokeJoin: path.strokeJoin
}
- }),
+ })
}
}
diff --git a/packages/core/src/io/formats.ts b/packages/core/src/io/formats.ts
index f471859ae..50ea468b0 100644
--- a/packages/core/src/io/formats.ts
+++ b/packages/core/src/io/formats.ts
@@ -1,4 +1,5 @@
import { sceneNodeToJSX, selectionToJSX } from '#core/design-jsx'
+
import { exportFigFile, parseFigFile } from './formats/fig'
import { parsePenFile } from './formats/pen'
import { headlessRenderNodes, renderNodesToImage, type RasterExportFormat } from './formats/raster'
diff --git a/packages/core/src/io/formats/jsx/export.ts b/packages/core/src/io/formats/jsx/export.ts
index dc54ddb5e..df159aa8d 100644
--- a/packages/core/src/io/formats/jsx/export.ts
+++ b/packages/core/src/io/formats/jsx/export.ts
@@ -1,6 +1,6 @@
import { DEFAULT_FONT_FAMILY } from '#core/constants'
import { resolveNodeTextDirection } from '#core/text/direction'
-import { collectTailwindClasses } from './tailwind-classes'
+
import {
collectCornerRadii,
collectPadding,
@@ -13,6 +13,7 @@ import {
solidFillColor,
solidStroke
} from './helpers'
+import { collectTailwindClasses } from './tailwind-classes'
import type { SceneGraph, SceneNode, NodeType } from '#core/scene-graph'
diff --git a/packages/core/src/io/formats/jsx/helpers.ts b/packages/core/src/io/formats/jsx/helpers.ts
index 91688261e..bbb933b01 100644
--- a/packages/core/src/io/formats/jsx/helpers.ts
+++ b/packages/core/src/io/formats/jsx/helpers.ts
@@ -1,6 +1,14 @@
import { colorToHex8, colorToCSSCompact } from '#core/color'
-import type { SceneGraph, SceneNode, Fill, Stroke, Effect, Color, GridTrack } from '#core/scene-graph'
+import type {
+ SceneGraph,
+ SceneNode,
+ Fill,
+ Stroke,
+ Effect,
+ Color,
+ GridTrack
+} from '#core/scene-graph'
export function formatColor(color: Color, opacity = 1): string {
return colorToHex8(color, opacity)
@@ -127,4 +135,3 @@ export function formatTrack(t: GridTrack): string {
export function formatTracks(tracks: GridTrack[]): string {
return tracks.map(formatTrack).join(' ')
}
-
diff --git a/packages/core/src/io/formats/jsx/tailwind-classes.ts b/packages/core/src/io/formats/jsx/tailwind-classes.ts
index f3e658635..1c97e9c6d 100644
--- a/packages/core/src/io/formats/jsx/tailwind-classes.ts
+++ b/packages/core/src/io/formats/jsx/tailwind-classes.ts
@@ -8,6 +8,7 @@ import {
opacityToTw
} from '#core/design-jsx/tailwind'
import { resolveNodeTextDirection } from '#core/text/direction'
+
import {
collectCornerRadii,
collectPadding,
@@ -190,4 +191,3 @@ export function collectTailwindClasses(node: SceneNode, graph: SceneGraph): stri
return classes
}
-
diff --git a/packages/core/src/io/formats/pen/read.ts b/packages/core/src/io/formats/pen/read.ts
index 50e4cd3b8..9d9337838 100644
--- a/packages/core/src/io/formats/pen/read.ts
+++ b/packages/core/src/io/formats/pen/read.ts
@@ -1,7 +1,8 @@
+import { parseSVGPath } from '#core/io/formats/svg/parse-path'
import { SceneGraph } from '#core/scene-graph'
import { copyEffects, copyFills, copyStrokes } from '#core/scene-graph/copy'
import { populateInstanceChildren } from '#core/scene-graph/instances'
-import { parseSVGPath } from '#core/io/formats/svg/parse-path'
+
import {
applyCornerRadius,
applyPadding,
diff --git a/packages/core/src/io/formats/raster/headless.ts b/packages/core/src/io/formats/raster/headless.ts
index 9672ed608..e42e1fe88 100644
--- a/packages/core/src/io/formats/raster/headless.ts
+++ b/packages/core/src/io/formats/raster/headless.ts
@@ -1,4 +1,5 @@
import { SkiaRenderer } from '#core/canvas'
+
import { renderNodesToImage, renderThumbnail, type ExportFormat } from './render'
import type { SceneGraph } from '#core/scene-graph'
diff --git a/packages/core/src/io/formats/svg/defs.ts b/packages/core/src/io/formats/svg/defs.ts
index 73db8c9d8..620e957b1 100644
--- a/packages/core/src/io/formats/svg/defs.ts
+++ b/packages/core/src/io/formats/svg/defs.ts
@@ -1,5 +1,6 @@
import { colorToHex } from '#core/color'
import { colorToDisplayCss, getDefaultRenderColorSpace } from '#core/color/management'
+
import { svg, type SVGNode } from './node'
import { round } from './paths'
diff --git a/packages/core/src/io/formats/svg/export.ts b/packages/core/src/io/formats/svg/export.ts
index fd6111561..c55b6ea6c 100644
--- a/packages/core/src/io/formats/svg/export.ts
+++ b/packages/core/src/io/formats/svg/export.ts
@@ -1,5 +1,6 @@
-import { resolveNodeTextDirection } from '#core/text/direction'
import { computeContentBounds } from '#core/io/formats/raster'
+import { resolveNodeTextDirection } from '#core/text/direction'
+
import {
nextDefId,
formatColor,
@@ -23,13 +24,7 @@ export { geometryBlobToSVGPath, vectorNetworkToSVGPaths } from './paths'
import { svg, renderSVGNode } from './node'
-import type {
- SceneGraph,
- SceneNode,
- Fill,
- Stroke,
- CharacterStyleOverride
-} from '#core/scene-graph'
+import type { SceneGraph, SceneNode, Fill, Stroke, CharacterStyleOverride } from '#core/scene-graph'
import type { SVGExportContext } from './defs'
import type { SVGNode } from './node'
diff --git a/packages/core/src/kiwi/instance-overrides/symbol/overrides.ts b/packages/core/src/kiwi/instance-overrides/symbol/overrides.ts
index 34967f5d0..cd720912d 100644
--- a/packages/core/src/kiwi/instance-overrides/symbol/overrides.ts
+++ b/packages/core/src/kiwi/instance-overrides/symbol/overrides.ts
@@ -1,10 +1,10 @@
+import { resolveOverrideTarget, repopulateInstance } from '#core/kiwi/instance-overrides/resolve'
import { guidToString } from '#core/kiwi/node-change/convert'
-import { resolveOverrideTarget, repopulateInstance } from '#core/kiwi/instance-overrides/resolve'
import { convertOverrideToProps } from './props'
-import type { SceneNode } from '#core/scene-graph'
import type { OverrideContext } from '#core/kiwi/instance-overrides/types'
+import type { SceneNode } from '#core/scene-graph'
function isActiveInstance(ctx: OverrideContext, nodeId: string | undefined): nodeId is string {
return nodeId !== undefined && (!ctx.activeNodeIds || ctx.activeNodeIds.has(nodeId))
diff --git a/packages/core/src/kiwi/node-change/convert.ts b/packages/core/src/kiwi/node-change/convert.ts
index fd0f1bc46..d906e4e3d 100644
--- a/packages/core/src/kiwi/node-change/convert.ts
+++ b/packages/core/src/kiwi/node-change/convert.ts
@@ -1,6 +1,7 @@
/* eslint-disable max-lines -- kiwi↔scene conversion helpers are tightly coupled */
import { DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT } from '#core/constants'
import { styleToWeight } from '#core/text/fonts'
+
import { guidToString } from './guid'
import { convertEffects, convertFills, convertStrokes } from './paint'
import { importStyleRuns } from './style-runs'
diff --git a/packages/core/src/kiwi/node-change/plugin-data.ts b/packages/core/src/kiwi/node-change/plugin-data.ts
index a67d28b39..aa7de4528 100644
--- a/packages/core/src/kiwi/node-change/plugin-data.ts
+++ b/packages/core/src/kiwi/node-change/plugin-data.ts
@@ -1,10 +1,6 @@
import { guidToString } from './guid'
-import type {
- NodeChange,
- PluginData,
- PluginRelaunchData
-} from '#core/kiwi/binary/codec'
+import type { NodeChange, PluginData, PluginRelaunchData } from '#core/kiwi/binary/codec'
import type {
PluginDataEntry,
PluginRelaunchDataEntry,
@@ -15,7 +11,11 @@ export const OPEN_PENCIL_PLUGIN_ID = 'open-pencil'
export const TEXT_DIRECTION_PLUGIN_KEY = 'textDirection'
export const LAYOUT_DIRECTION_PLUGIN_KEY = 'layoutDirection'
-export function upsertPluginData(node: { pluginData: PluginDataEntry[] }, key: string, value: string): void {
+export function upsertPluginData(
+ node: { pluginData: PluginDataEntry[] },
+ key: string,
+ value: string
+): void {
const pluginData = node.pluginData.filter(
(entry) => !(entry.pluginId === OPEN_PENCIL_PLUGIN_ID && entry.key === key)
)
diff --git a/packages/core/src/kiwi/node-change/style-runs.ts b/packages/core/src/kiwi/node-change/style-runs.ts
index 91be2b0b0..059648e6f 100644
--- a/packages/core/src/kiwi/node-change/style-runs.ts
+++ b/packages/core/src/kiwi/node-change/style-runs.ts
@@ -1,4 +1,5 @@
import { styleToWeight } from '#core/text/fonts'
+
import { convertFills } from './paint'
import { convertLetterSpacing, convertLineHeight, mapTextDecoration } from './text-values'
diff --git a/packages/core/src/layout/grid.ts b/packages/core/src/layout/grid.ts
index dcce33b09..6b95f96f8 100644
--- a/packages/core/src/layout/grid.ts
+++ b/packages/core/src/layout/grid.ts
@@ -1,6 +1,6 @@
+import { resolveNodeLayoutDirection } from '#core/text/direction'
import { Direction, Display, Gutter, Edge, type Node as YogaNode } from 'yoga-layout'
-import { resolveNodeLayoutDirection } from '#core/text/direction'
import { configureAbsoluteChild, createYogaNode, mapGridTrack } from './yoga-helpers'
import type { SceneGraph, SceneNode } from '#core/scene-graph'
@@ -93,4 +93,3 @@ export function buildGridTree(
return root
}
-
diff --git a/packages/core/src/profiler/capture-session.ts b/packages/core/src/profiler/capture-session.ts
index 842048f78..fab7f61fe 100644
--- a/packages/core/src/profiler/capture-session.ts
+++ b/packages/core/src/profiler/capture-session.ts
@@ -1,8 +1,8 @@
import { CaptureStack } from './frame/capture'
+import type { FrameCapture } from './frame/capture'
import type { FrameStats } from './frame/stats'
import type { GPUTimer } from './gpu-timer'
-import type { FrameCapture } from './frame/capture'
export type CaptureSession = {
stack: CaptureStack
diff --git a/packages/core/src/profiler/render-profiler.ts b/packages/core/src/profiler/render-profiler.ts
index 193b44d38..955b5ecd0 100644
--- a/packages/core/src/profiler/render-profiler.ts
+++ b/packages/core/src/profiler/render-profiler.ts
@@ -27,10 +27,7 @@ export class RenderProfiler {
private lastCapture: FrameCapture | null = null
private renderStartTime = 0
- constructor(
- ck: CanvasKit,
- gl: WebGL2RenderingContext | null
- ) {
+ constructor(ck: CanvasKit, gl: WebGL2RenderingContext | null) {
this.gpuTimer = new GPUTimer(gl)
this.drawCallCounter = new DrawCallCounter(gl)
this.hud = new HudController(ck)
diff --git a/packages/core/src/rpc/analyze-commands.ts b/packages/core/src/rpc/analyze-commands.ts
index aec600cdc..f2ef39bb5 100644
--- a/packages/core/src/rpc/analyze-commands.ts
+++ b/packages/core/src/rpc/analyze-commands.ts
@@ -296,4 +296,3 @@ export const analyzeClustersCommand: RpcCommand<AnalyzeClustersArgs, AnalyzeClus
return { clusters, totalNodes }
}
}
-
diff --git a/packages/core/src/rpc/commands.ts b/packages/core/src/rpc/commands.ts
index 70ca1a90b..d79b9ce03 100644
--- a/packages/core/src/rpc/commands.ts
+++ b/packages/core/src/rpc/commands.ts
@@ -1,3 +1,9 @@
+import {
+ analyzeClustersCommand,
+ analyzeColorsCommand,
+ analyzeSpacingCommand,
+ analyzeTypographyCommand
+} from './analyze-commands'
import {
findCommand,
infoCommand,
@@ -6,12 +12,6 @@ import {
queryCommand,
treeCommand
} from './read-commands'
-import {
- analyzeClustersCommand,
- analyzeColorsCommand,
- analyzeSpacingCommand,
- analyzeTypographyCommand
-} from './analyze-commands'
import { variablesCommand } from './variables-command'
import type { SceneGraph } from '#core/scene-graph'
diff --git a/packages/core/src/rpc/read-commands.ts b/packages/core/src/rpc/read-commands.ts
index 5e8366525..3ce90b2ce 100644
--- a/packages/core/src/rpc/read-commands.ts
+++ b/packages/core/src/rpc/read-commands.ts
@@ -330,4 +330,3 @@ export const nodeCommand: RpcCommand<NodeArgs, NodeResult | { error: string }> =
}
}
}
-
diff --git a/packages/core/src/rpc/variables-command.ts b/packages/core/src/rpc/variables-command.ts
index c3cf5b299..1b886ab28 100644
--- a/packages/core/src/rpc/variables-command.ts
+++ b/packages/core/src/rpc/variables-command.ts
@@ -79,4 +79,3 @@ export const variablesCommand: RpcCommand<VariablesArgs, VariablesResult> = {
return result
}
}
-
diff --git a/packages/core/src/scene-graph/hit-test.ts b/packages/core/src/scene-graph/hit-test.ts
index 30dd46730..301ca0995 100644
--- a/packages/core/src/scene-graph/hit-test.ts
+++ b/packages/core/src/scene-graph/hit-test.ts
@@ -1,6 +1,5 @@
-import Matrix from '#core/canvas/matrix'
-
import { getWorldMatrix } from '#core/canvas/coordinate'
+import Matrix from '#core/canvas/matrix'
import type { SceneGraph, SceneNode, NodeType } from './'
diff --git a/packages/core/src/scene-graph/index.ts b/packages/core/src/scene-graph/index.ts
index 02f963fbe..b003d6ee9 100644
--- a/packages/core/src/scene-graph/index.ts
+++ b/packages/core/src/scene-graph/index.ts
@@ -6,8 +6,8 @@ import { createNanoEvents } from 'nanoevents'
import * as HitTest from './hit-test'
import * as Instances from './instances'
import { CONTAINER_TYPES, createDefaultNode } from './node-defaults'
-import { normalizeVectorNetwork } from './vector-network'
import * as Variables from './variables'
+import { normalizeVectorNetwork } from './vector-network'
export type { GUID, Color } from '#core/types'
export * from './types'
@@ -15,7 +15,6 @@ export * from './types'
import { getAbsolutePosition } from '#core/canvas/coordinate'
import type { Color, Rect, Vector } from '#core/types'
-import type { Emitter } from 'nanoevents'
import type {
DocumentColorSpace,
NodeType,
@@ -27,6 +26,7 @@ import type {
VariableType,
VariableValue
} from './types'
+import type { Emitter } from 'nanoevents'
export { cloneVectorNetwork, normalizeVectorNetwork, validateVectorNetwork } from './vector-network'
let nextLocalID = 1
diff --git a/packages/core/src/scene-graph/variables.ts b/packages/core/src/scene-graph/variables.ts
index 121b22e01..1b2f9ff2b 100644
--- a/packages/core/src/scene-graph/variables.ts
+++ b/packages/core/src/scene-graph/variables.ts
@@ -71,7 +71,11 @@ export function createVariable(
return variable
}
-export function createCollection(graph: SceneGraph, generateId: () => string, name: string): VariableCollection {
+export function createCollection(
+ graph: SceneGraph,
+ generateId: () => string,
+ name: string
+): VariableCollection {
const id = generateId()
const modeId = generateId()
const collection: VariableCollection = {
@@ -122,7 +126,11 @@ export function resolveVariable(
let value = Object.hasOwn(variable.valuesByMode, preferredModeId)
? variable.valuesByMode[preferredModeId]
: undefined
- if (value === undefined && fallbackModeId && Object.hasOwn(variable.valuesByMode, fallbackModeId)) {
+ if (
+ value === undefined &&
+ fallbackModeId &&
+ Object.hasOwn(variable.valuesByMode, fallbackModeId)
+ ) {
value = variable.valuesByMode[fallbackModeId]
}
value ??= Object.values(variable.valuesByMode)[0]
@@ -157,7 +165,12 @@ export function getVariablesByType(graph: SceneGraph, type: VariableType): Varia
return [...graph.variables.values()].filter((v) => v.type === type)
}
-export function bindVariable(graph: SceneGraph, nodeId: string, field: string, variableId: string): void {
+export function bindVariable(
+ graph: SceneGraph,
+ nodeId: string,
+ field: string,
+ variableId: string
+): void {
const node = graph.nodes.get(nodeId)
if (node) node.boundVariables[field] = variableId
}
diff --git a/packages/core/src/scene-graph/vector-network.ts b/packages/core/src/scene-graph/vector-network.ts
index 02c347f40..7cc12de2b 100644
--- a/packages/core/src/scene-graph/vector-network.ts
+++ b/packages/core/src/scene-graph/vector-network.ts
@@ -70,4 +70,4 @@ export function normalizeVectorNetwork(vn: VectorNetwork): VectorNetwork {
})),
regions: vn.regions
}
-}
\ No newline at end of file
+}
diff --git a/packages/core/src/tools/analyze/clusters.ts b/packages/core/src/tools/analyze/clusters.ts
index db1f0ec77..4957d45d0 100644
--- a/packages/core/src/tools/analyze/clusters.ts
+++ b/packages/core/src/tools/analyze/clusters.ts
@@ -28,7 +28,7 @@ export const analyzeClusters = defineTool({
params: {
min_count: { type: 'number', description: 'Min instances to form a cluster (default: 2)' },
min_size: { type: 'number', description: 'Min node size in px (default: 30)' },
- limit: { type: 'number', description: 'Max clusters to return (default: 20)' },
+ limit: { type: 'number', description: 'Max clusters to return (default: 20)' }
},
execute: (figma, args) => {
const minCount = args.min_count ?? 2
@@ -77,7 +77,7 @@ export const analyzeClusters = defineTool({
type: raw.type,
width: raw.width,
height: raw.height,
- childCount: raw.childIds.length,
+ childCount: raw.childIds.length
})
signatureMap.set(signature, list)
return false
@@ -102,12 +102,12 @@ export const analyzeClusters = defineTool({
widthRange: Math.round(widthRange),
heightRange: Math.round(heightRange),
confidence,
- examples: nodes.slice(0, 3).map((node) => ({ id: node.id, name: node.name })),
+ examples: nodes.slice(0, 3).map((node) => ({ id: node.id, name: node.name }))
}
})
.sort((a, b) => b.count - a.count)
.slice(0, limit)
return { totalNodes, clusters }
- },
+ }
})
diff --git a/packages/core/src/tools/analyze/colors.ts b/packages/core/src/tools/analyze/colors.ts
index 3b67ae17f..66f76d090 100644
--- a/packages/core/src/tools/analyze/colors.ts
+++ b/packages/core/src/tools/analyze/colors.ts
@@ -109,4 +109,3 @@ export const analyzeColors = defineTool({
return result
}
})
-
diff --git a/packages/core/src/tools/analyze/diff.ts b/packages/core/src/tools/analyze/diff.ts
index 43a3f4ec6..7caf7397a 100644
--- a/packages/core/src/tools/analyze/diff.ts
+++ b/packages/core/src/tools/analyze/diff.ts
@@ -1,7 +1,6 @@
-import { createTwoFilesPatch } from 'diff'
-
import { colorToHex, parseColor } from '#core/color'
import { defineTool } from '#core/tools/schema'
+import { createTwoFilesPatch } from 'diff'
import type { FigmaAPI } from '#core/figma-api'
import type { SceneNode } from '#core/scene-graph'
@@ -241,4 +240,3 @@ export const diffShow = defineTool({
return { diff: createUnifiedDiff(filename, filename, oldContent, newContent) }
}
})
-
diff --git a/packages/core/src/tools/analyze/spacing.ts b/packages/core/src/tools/analyze/spacing.ts
index 2ecc6fb4d..9916906d7 100644
--- a/packages/core/src/tools/analyze/spacing.ts
+++ b/packages/core/src/tools/analyze/spacing.ts
@@ -5,7 +5,7 @@ export const analyzeSpacing = defineTool({
description:
'Analyze spacing values (gap, padding) across the current page. Checks grid compliance.',
params: {
- grid: { type: 'number', description: 'Base grid size to check against (default: 8)' },
+ grid: { type: 'number', description: 'Base grid size to check against (default: 8)' }
},
execute: (figma, args) => {
const gridSize = args.grid ?? 8
@@ -23,7 +23,12 @@ export const analyzeSpacing = defineTool({
gapMap.set(raw.itemSpacing, (gapMap.get(raw.itemSpacing) ?? 0) + 1)
}
- for (const padding of [raw.paddingTop, raw.paddingRight, raw.paddingBottom, raw.paddingLeft]) {
+ for (const padding of [
+ raw.paddingTop,
+ raw.paddingRight,
+ raw.paddingBottom,
+ raw.paddingLeft
+ ]) {
if (padding > 0) {
paddingMap.set(padding, (paddingMap.get(padding) ?? 0) + 1)
}
@@ -48,7 +53,7 @@ export const analyzeSpacing = defineTool({
gaps,
paddings,
offGridGaps: offGridGaps.map((gap) => gap.value),
- offGridPaddings: offGridPaddings.map((padding) => padding.value),
+ offGridPaddings: offGridPaddings.map((padding) => padding.value)
}
- },
+ }
})
diff --git a/packages/core/src/tools/analyze/typography.ts b/packages/core/src/tools/analyze/typography.ts
index 9062ffc81..ff8c26ab3 100644
--- a/packages/core/src/tools/analyze/typography.ts
+++ b/packages/core/src/tools/analyze/typography.ts
@@ -85,4 +85,3 @@ export const analyzeTypography = defineTool({
}
}
})
-
diff --git a/packages/core/src/tools/codegen/component-map.ts b/packages/core/src/tools/codegen/component-map.ts
index b91d2ac71..cd735bc26 100644
--- a/packages/core/src/tools/codegen/component-map.ts
+++ b/packages/core/src/tools/codegen/component-map.ts
@@ -104,7 +104,7 @@ function buildScreenInfo(
width: frameNode.width,
height: frameNode.height,
componentRefs: [...refs.entries()].map(([id, { name, count }]) => ({ id, name, count })),
- topLevelSections,
+ topLevelSections
}
}
@@ -115,8 +115,8 @@ export const designToComponentMap = defineTool({
params: {
page: {
type: 'string',
- description: 'Page name to analyze (default: current page)',
- },
+ description: 'Page name to analyze (default: current page)'
+ }
},
execute: (figma, args) => {
if (args.page) {
@@ -144,7 +144,7 @@ export const designToComponentMap = defineTool({
variants: detectVariants(raw, figma.graph),
instanceCount: 0,
propCandidates: detectPropCandidates(raw, figma.graph),
- usedOnScreens: [],
+ usedOnScreens: []
})
return false
})
@@ -188,7 +188,7 @@ export const designToComponentMap = defineTool({
screenCount: screens.length,
components: components.sort((a, b) => b.instanceCount - a.instanceCount),
screens,
- sections,
+ sections
}
- },
+ }
})
diff --git a/packages/core/src/tools/codegen/tokens.ts b/packages/core/src/tools/codegen/tokens.ts
index c2f7b8982..cea0e8ae7 100644
--- a/packages/core/src/tools/codegen/tokens.ts
+++ b/packages/core/src/tools/codegen/tokens.ts
@@ -1,8 +1,8 @@
import { colorToHex } from '#core/color'
import { defineTool } from '#core/tools/schema'
-import type { Color } from '#core/types'
import type { Variable, VariableCollection, VariableValue } from '#core/scene-graph'
+import type { Color } from '#core/types'
function slugify(name: string): string {
return name
@@ -169,17 +169,17 @@ export const designToTokens = defineTool({
type: 'string',
description: 'Output format',
enum: ['css', 'tailwind', 'json'],
- default: 'css',
+ default: 'css'
},
collection: {
type: 'string',
- description: 'Filter by collection name (substring, case-insensitive)',
+ description: 'Filter by collection name (substring, case-insensitive)'
},
type: {
type: 'string',
description: 'Filter by variable type',
- enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN'],
- },
+ enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']
+ }
},
execute: (figma, args) => {
const format = args.format ?? 'css'
@@ -215,5 +215,5 @@ export const designToTokens = defineTool({
else output = renderCSS(tokens, modes)
return { output, tokenCount: tokens.length, modeCount: modes.length }
- },
+ }
})
diff --git a/packages/core/src/tools/create-icons.ts b/packages/core/src/tools/create-icons.ts
index 23a7d934f..392c969ba 100644
--- a/packages/core/src/tools/create-icons.ts
+++ b/packages/core/src/tools/create-icons.ts
@@ -1,6 +1,7 @@
import { parseColor } from '#core/color'
import { fetchIcons, searchIconsBatch } from '#core/icons'
import { createIconFromPaths } from '#core/icons/render'
+
import { defineTool } from './schema'
export const fetchIconsTool = defineTool({
@@ -11,9 +12,9 @@ export const fetchIconsTool = defineTool({
names: {
type: 'string[]',
description: 'Icon names as prefix:name (e.g. ["lucide:heart", "lucide:home", "mdi:star"])',
- required: true,
+ required: true
},
- size: { type: 'number', description: 'Icon size in pixels (default: 24)' },
+ size: { type: 'number', description: 'Icon size in pixels (default: 24)' }
},
execute: async (_figma, args) => {
const size = args.size ?? 24
@@ -27,7 +28,7 @@ export const fetchIconsTool = defineTool({
} catch (e) {
return { error: (e as Error).message }
}
- },
+ }
})
export const insertIcon = defineTool({
@@ -39,18 +40,18 @@ export const insertIcon = defineTool({
names: {
type: 'string[]',
description:
- 'Icon names as prefix:name (e.g. ["lucide:heart"] or ["lucide:heart","lucide:home","lucide:star"])',
+ 'Icon names as prefix:name (e.g. ["lucide:heart"] or ["lucide:heart","lucide:home","lucide:star"])'
},
name: {
type: 'string',
- description: 'Single icon name (shorthand for names with one icon)',
+ description: 'Single icon name (shorthand for names with one icon)'
},
size: { type: 'number', description: 'Icon size in pixels (default: 24)' },
color: {
type: 'color',
- description: 'Icon color hex (replaces currentColor). Default: #000000',
+ description: 'Icon color hex (replaces currentColor). Default: #000000'
},
- parent_id: { type: 'string', description: 'Parent node ID for all icons' },
+ parent_id: { type: 'string', description: 'Parent node ID for all icons' }
},
execute: async (figma, args) => {
const names = args.names ?? (args.name ? [args.name] : [])
@@ -88,7 +89,7 @@ export const insertIcon = defineTool({
const result: Record<string, unknown> = { inserted }
if (notFound.length > 0) result.not_found = notFound
return result
- },
+ }
})
export const searchIconsTool = defineTool({
@@ -99,16 +100,16 @@ export const searchIconsTool = defineTool({
queries: {
type: 'string[]',
description: 'Search keywords (e.g. ["heart", "arrow", "settings"])',
- required: true,
+ required: true
},
limit: { type: 'number', description: 'Max results per query (default: 5)' },
- prefix: { type: 'string', description: 'Filter by icon set prefix (e.g. "lucide", "mdi")' },
+ prefix: { type: 'string', description: 'Filter by icon set prefix (e.g. "lucide", "mdi")' }
},
execute: async (_figma, args) => {
try {
const results = await searchIconsBatch(args.queries, {
limit: args.limit ?? 5,
- prefix: args.prefix,
+ prefix: args.prefix
})
const output: Record<string, { icons: string[]; total: number }> = {}
for (const [query, result] of results) {
@@ -118,5 +119,5 @@ export const searchIconsTool = defineTool({
} catch (e) {
return { error: (e as Error).message }
}
- },
+ }
})
diff --git a/packages/core/src/tools/create/basic.ts b/packages/core/src/tools/create/basic.ts
index 211f4eff0..88c6b7439 100644
--- a/packages/core/src/tools/create/basic.ts
+++ b/packages/core/src/tools/create/basic.ts
@@ -12,14 +12,14 @@ export const createShape = defineTool({
type: 'string',
description: 'Node type',
required: true,
- enum: ['FRAME', 'RECTANGLE', 'ELLIPSE', 'TEXT', 'LINE', 'STAR', 'POLYGON', 'SECTION'],
+ enum: ['FRAME', 'RECTANGLE', 'ELLIPSE', 'TEXT', 'LINE', 'STAR', 'POLYGON', 'SECTION']
},
x: { type: 'number', description: 'X position', required: true },
y: { type: 'number', description: 'Y position', required: true },
width: { type: 'number', description: 'Width in pixels', required: true, min: 1 },
height: { type: 'number', description: 'Height in pixels', required: true, min: 1 },
name: { type: 'string', description: 'Node name shown in layers panel' },
- parent_id: { type: 'string', description: 'Parent node ID to nest inside' },
+ parent_id: { type: 'string', description: 'Parent node ID to nest inside' }
},
execute: (figma, args) => {
const parentId = args.parent_id
@@ -32,7 +32,7 @@ export const createShape = defineTool({
LINE: () => figma.createLine(),
STAR: () => figma.createStar(),
POLYGON: () => figma.createPolygon(),
- SECTION: () => figma.createSection(),
+ SECTION: () => figma.createSection()
}
const node = createMap[args.type]()
node.x = args.x
@@ -41,7 +41,7 @@ export const createShape = defineTool({
if (args.name) node.name = args.name
if (parent) parent.appendChild(node)
return nodeSummary(node)
- },
+ }
})
export const createPage = defineTool({
@@ -49,13 +49,13 @@ export const createPage = defineTool({
mutates: true,
description: 'Create a new page.',
params: {
- name: { type: 'string', description: 'Page name', required: true },
+ name: { type: 'string', description: 'Page name', required: true }
},
execute: (figma, { name }) => {
const page = figma.createPage()
page.name = name
return { id: page.id, name }
- },
+ }
})
export const createSlice = defineTool({
@@ -68,7 +68,7 @@ export const createSlice = defineTool({
width: { type: 'number', description: 'Width', required: true, min: 1 },
height: { type: 'number', description: 'Height', required: true, min: 1 },
name: { type: 'string', description: 'Slice name' },
- parent_id: { type: 'string', description: 'Parent node ID' },
+ parent_id: { type: 'string', description: 'Parent node ID' }
},
execute: (figma, args) => {
const node = figma.createFrame()
@@ -82,5 +82,5 @@ export const createSlice = defineTool({
if (parent) parent.appendChild(node)
}
return nodeSummary(node)
- },
+ }
})
diff --git a/packages/core/src/tools/create/components.ts b/packages/core/src/tools/create/components.ts
index 33658679b..30dd6eedf 100644
--- a/packages/core/src/tools/create/components.ts
+++ b/packages/core/src/tools/create/components.ts
@@ -5,14 +5,14 @@ export const createComponent = defineTool({
mutates: true,
description: 'Convert a frame/group into a component.',
params: {
- id: { type: 'string', description: 'Node ID to convert', required: true },
+ id: { type: 'string', description: 'Node ID to convert', required: true }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
const component = figma.createComponentFromNode(node)
return nodeSummary(component)
- },
+ }
})
export const createInstance = defineTool({
@@ -22,7 +22,7 @@ export const createInstance = defineTool({
params: {
component_id: { type: 'string', description: 'Component node ID', required: true },
x: { type: 'number', description: 'X position' },
- y: { type: 'number', description: 'Y position' },
+ y: { type: 'number', description: 'Y position' }
},
execute: (figma, args) => {
const component = figma.getNodeById(args.component_id)
@@ -31,5 +31,5 @@ export const createInstance = defineTool({
if (args.x !== undefined) instance.x = args.x
if (args.y !== undefined) instance.y = args.y
return nodeSummary(instance)
- },
+ }
})
diff --git a/packages/core/src/tools/create/render.ts b/packages/core/src/tools/create/render.ts
index 94f2aed6f..a3e007e1c 100644
--- a/packages/core/src/tools/create/render.ts
+++ b/packages/core/src/tools/create/render.ts
@@ -8,16 +8,16 @@ export const render = defineTool({
params: {
replace_id: {
type: 'string',
- description: 'Node ID to replace — new node takes its position in parent, old node is deleted',
+ description: 'Node ID to replace — new node takes its position in parent, old node is deleted'
},
parent_id: { type: 'string', description: 'Parent node ID to render into' },
insert_index: {
type: 'number',
- description: 'Position among siblings (0 = first child). Omit to append at end.',
+ description: 'Position among siblings (0 = first child). Omit to append at end.'
},
x: { type: 'number', description: 'X position of the root node' },
y: { type: 'number', description: 'Y position of the root node' },
- jsx: { type: 'string', description: 'JSX string to render', required: true },
+ jsx: { type: 'string', description: 'JSX string to render', required: true }
},
execute: async (figma, args) => {
const { renderJSX } = await import('#core/design-jsx/render.js')
@@ -39,7 +39,7 @@ export const render = defineTool({
const results = await renderJSX(figma.graph, args.jsx, {
parentId,
x: args.x,
- y: args.y,
+ y: args.y
})
const result = results[0]
@@ -56,8 +56,12 @@ export const render = defineTool({
type: result.type,
children: result.childIds,
...(results.length > 1
- ? { siblings: results.slice(1).map((node) => ({ id: node.id, name: node.name, type: node.type })) }
- : {}),
+ ? {
+ siblings: results
+ .slice(1)
+ .map((node) => ({ id: node.id, name: node.name, type: node.type }))
+ }
+ : {})
}
- },
+ }
})
diff --git a/packages/core/src/tools/create/vector.ts b/packages/core/src/tools/create/vector.ts
index 0b2cbcb59..a1f0a87ed 100644
--- a/packages/core/src/tools/create/vector.ts
+++ b/packages/core/src/tools/create/vector.ts
@@ -16,7 +16,7 @@ export const createVector = defineTool({
fill: { type: 'color', description: 'Fill color (hex)' },
stroke: { type: 'color', description: 'Stroke color (hex)' },
stroke_weight: { type: 'number', description: 'Stroke weight' },
- parent_id: { type: 'string', description: 'Parent node ID' },
+ parent_id: { type: 'string', description: 'Parent node ID' }
},
execute: (figma, args) => {
const node = figma.createVector()
@@ -44,8 +44,8 @@ export const createVector = defineTool({
weight: args.stroke_weight ?? 1,
opacity: 1,
visible: true,
- align: 'CENTER',
- },
+ align: 'CENTER'
+ }
]
}
if (args.parent_id) {
@@ -53,5 +53,5 @@ export const createVector = defineTool({
if (parent) parent.appendChild(node)
}
return nodeSummary(node)
- },
+ }
})
diff --git a/packages/core/src/tools/describe/index.ts b/packages/core/src/tools/describe/index.ts
index fb5760508..aae7985f8 100644
--- a/packages/core/src/tools/describe/index.ts
+++ b/packages/core/src/tools/describe/index.ts
@@ -1,6 +1,7 @@
-import { autoDepth, describeOneNode } from './tree'
import { defineTool } from '#core/tools/schema'
+import { autoDepth, describeOneNode } from './tree'
+
export const describe = defineTool({
name: 'describe',
description:
@@ -9,7 +10,7 @@ export const describe = defineTool({
id: { type: 'string', description: 'Node ID (single node)' },
ids: { type: 'string[]', description: 'Node IDs (multiple nodes in one call)' },
depth: { type: 'number', description: 'Override depth (auto if omitted, max: 5)' },
- grid: { type: 'number', description: 'Grid size for alignment checks (default: 8)' },
+ grid: { type: 'number', description: 'Grid size for alignment checks (default: 8)' }
},
execute: (figma, args) => {
const gridSize = args.grid ?? 8
@@ -19,12 +20,12 @@ export const describe = defineTool({
nodes: args.ids.map((nodeId) => {
const depth = Math.min(args.depth ?? autoDepth(figma.graph, nodeId), 5)
return describeOneNode(figma, nodeId, depth, gridSize)
- }),
+ })
}
}
if (!args.id) return { error: 'Provide id (string) or ids (string[])' }
const depth = Math.min(args.depth ?? autoDepth(figma.graph, args.id), 5)
return describeOneNode(figma, args.id, depth, gridSize)
- },
+ }
})
diff --git a/packages/core/src/tools/describe/issues.ts b/packages/core/src/tools/describe/issues.ts
index 30438c36a..766804554 100644
--- a/packages/core/src/tools/describe/issues.ts
+++ b/packages/core/src/tools/describe/issues.ts
@@ -1,4 +1,5 @@
import { colorDistance, colorToHex } from '#core/color'
+
import { detectLayoutIssues } from './layout-issues'
import { CONTAINER_TYPES, findAncestorBackground, looksLikeButton } from './shared'
diff --git a/packages/core/src/tools/describe/layout-issues.ts b/packages/core/src/tools/describe/layout-issues.ts
index 82f484295..ec4bc2dcc 100644
--- a/packages/core/src/tools/describe/layout-issues.ts
+++ b/packages/core/src/tools/describe/layout-issues.ts
@@ -1,6 +1,6 @@
+import { colorToHex } from '#core/color'
import { wcagLuminance } from 'culori'
-import { colorToHex } from '#core/color'
import { CONTAINER_TYPES, findAncestorBackground } from './shared'
import type { SceneGraph, SceneNode } from '#core/scene-graph'
diff --git a/packages/core/src/tools/describe/roles.ts b/packages/core/src/tools/describe/roles.ts
index 0a139ba3d..7e1cda824 100644
--- a/packages/core/src/tools/describe/roles.ts
+++ b/packages/core/src/tools/describe/roles.ts
@@ -42,7 +42,7 @@ const NAME_ROLE_PATTERNS: { pattern: RegExp; role: string }[] = [
{ pattern: /^progress$/i, role: 'progressbar' },
{ pattern: /^spinner$/i, role: 'progressbar' },
{ pattern: /^divider$/i, role: 'separator' },
- { pattern: /^separator$/i, role: 'separator' },
+ { pattern: /^separator$/i, role: 'separator' }
]
function detectRoleFromName(name: string): string | null {
diff --git a/packages/core/src/tools/describe/summaries.ts b/packages/core/src/tools/describe/summaries.ts
index 8e567de4e..6796f5931 100644
--- a/packages/core/src/tools/describe/summaries.ts
+++ b/packages/core/src/tools/describe/summaries.ts
@@ -13,7 +13,8 @@ export function describeVisual(node: SceneNode): string {
if (!effect.visible) continue
if (effect.type === 'DROP_SHADOW') parts.push('drop shadow')
else if (effect.type === 'INNER_SHADOW') parts.push('inner shadow')
- else if (effect.type === 'LAYER_BLUR' || effect.type === 'FOREGROUND_BLUR') parts.push('blurred')
+ else if (effect.type === 'LAYER_BLUR' || effect.type === 'FOREGROUND_BLUR')
+ parts.push('blurred')
else parts.push('backdrop blur')
}
return parts.join(', ') || 'no visual styles'
@@ -23,7 +24,7 @@ const JUSTIFY_LABELS: Record<string, string> = {
MIN: 'start',
CENTER: 'center',
MAX: 'end',
- SPACE_BETWEEN: 'between',
+ SPACE_BETWEEN: 'between'
}
const ITEMS_LABELS: Record<string, string> = {
@@ -31,7 +32,7 @@ const ITEMS_LABELS: Record<string, string> = {
CENTER: 'center',
MAX: 'end',
STRETCH: 'stretch',
- BASELINE: 'baseline',
+ BASELINE: 'baseline'
}
export function describeLayout(node: SceneNode): string | null {
diff --git a/packages/core/src/tools/describe/tree.ts b/packages/core/src/tools/describe/tree.ts
index 93a6ed8d9..8da4ef063 100644
--- a/packages/core/src/tools/describe/tree.ts
+++ b/packages/core/src/tools/describe/tree.ts
@@ -18,7 +18,7 @@ function describeChild(
node: SceneNode,
graph: SceneGraph,
depth: number,
- gridSize: number,
+ gridSize: number
): ChildDescription {
const role = detectRole(node)
const summary = node.type === 'TEXT' ? summarizeText(node) : summarizeContainer(node)
@@ -43,7 +43,7 @@ export function describeOneNode(
figma: { graph: SceneGraph },
nodeId: string,
depth: number,
- gridSize: number,
+ gridSize: number
): Record<string, unknown> {
const raw = figma.graph.getNode(nodeId)
if (!raw) return { id: nodeId, error: `Node "${nodeId}" not found` }
@@ -66,7 +66,7 @@ export function describeOneNode(
type: raw.type,
role,
size: `${raw.width}×${raw.height}`,
- visual,
+ visual
}
if (layout) result.layout = layout
if (children.length > 0) result.children = children
diff --git a/packages/core/src/tools/modify/effects.ts b/packages/core/src/tools/modify/effects.ts
index 3ea496ca1..853cc1b3f 100644
--- a/packages/core/src/tools/modify/effects.ts
+++ b/packages/core/src/tools/modify/effects.ts
@@ -44,4 +44,3 @@ export const setEffects = defineTool({
return { id: args.id, effects: node.effects.length }
}
})
-
diff --git a/packages/core/src/tools/modify/geometry.ts b/packages/core/src/tools/modify/geometry.ts
index 5d7f0753b..f559b106f 100644
--- a/packages/core/src/tools/modify/geometry.ts
+++ b/packages/core/src/tools/modify/geometry.ts
@@ -95,4 +95,3 @@ export const setMinMax = defineTool({
}
}
})
-
diff --git a/packages/core/src/tools/modify/layout.ts b/packages/core/src/tools/modify/layout.ts
index 39c5ab34b..05a23184c 100644
--- a/packages/core/src/tools/modify/layout.ts
+++ b/packages/core/src/tools/modify/layout.ts
@@ -169,4 +169,3 @@ export const setLayoutChild = defineTool({
return { id: args.id, updated }
}
})
-
diff --git a/packages/core/src/tools/modify/state.ts b/packages/core/src/tools/modify/state.ts
index 8fa709039..e7722022b 100644
--- a/packages/core/src/tools/modify/state.ts
+++ b/packages/core/src/tools/modify/state.ts
@@ -90,4 +90,3 @@ export const setStrokeAlign = defineTool({
return { id, strokeAlign: align }
}
})
-
diff --git a/packages/core/src/tools/modify/text.ts b/packages/core/src/tools/modify/text.ts
index e429e0fae..9555ff85d 100644
--- a/packages/core/src/tools/modify/text.ts
+++ b/packages/core/src/tools/modify/text.ts
@@ -163,4 +163,3 @@ export const setTextProperties = defineTool({
return { id: args.id, updated }
}
})
-
diff --git a/packages/core/src/tools/modify/update.ts b/packages/core/src/tools/modify/update.ts
index b370c342e..f9d765267 100644
--- a/packages/core/src/tools/modify/update.ts
+++ b/packages/core/src/tools/modify/update.ts
@@ -20,16 +20,16 @@ export const updateNode = defineTool({
text_direction: {
type: 'string',
description: 'Text direction for TEXT nodes',
- enum: ['AUTO', 'LTR', 'RTL'],
+ enum: ['AUTO', 'LTR', 'RTL']
},
flow_direction: {
type: 'string',
description: 'Auto-layout flow direction for FRAME nodes',
- enum: ['AUTO', 'LTR', 'RTL'],
+ enum: ['AUTO', 'LTR', 'RTL']
},
font_size: { type: 'number', description: 'Font size', min: 1 },
font_weight: { type: 'number', description: 'Font weight (100-900)' },
- name: { type: 'string', description: 'Layer name' },
+ name: { type: 'string', description: 'Layer name' }
},
execute: (figma, args) => {
const node = figma.getNodeById(args.id)
@@ -69,13 +69,13 @@ export const updateNode = defineTool({
}
if (args.text_direction !== undefined) {
figma.graph.updateNode(node.id, {
- textDirection: args.text_direction as SceneNode['textDirection'],
+ textDirection: args.text_direction as SceneNode['textDirection']
})
updated.push('textDirection')
}
if (args.flow_direction !== undefined) {
figma.graph.updateNode(node.id, {
- layoutDirection: args.flow_direction as SceneNode['layoutDirection'],
+ layoutDirection: args.flow_direction as SceneNode['layoutDirection']
})
updated.push('layoutDirection')
}
@@ -88,5 +88,5 @@ export const updateNode = defineTool({
updated.push('fontWeight')
}
return { id: args.id, updated }
- },
+ }
})
diff --git a/packages/core/src/tools/read/components.ts b/packages/core/src/tools/read/components.ts
index 7fc474039..729b9790c 100644
--- a/packages/core/src/tools/read/components.ts
+++ b/packages/core/src/tools/read/components.ts
@@ -5,7 +5,7 @@ export const getComponents = defineTool({
description: 'List all components in the document, optionally filtered by name.',
params: {
name: { type: 'string', description: 'Filter by name (case-insensitive substring)' },
- limit: { type: 'number', description: 'Max results (default: 50)' },
+ limit: { type: 'number', description: 'Max results (default: 50)' }
},
execute: (figma, args) => {
const limit = args.limit ?? 50
@@ -24,5 +24,5 @@ export const getComponents = defineTool({
}
return { count: components.length, components }
- },
+ }
})
diff --git a/packages/core/src/tools/read/fonts.ts b/packages/core/src/tools/read/fonts.ts
index 62675f00f..6837656d8 100644
--- a/packages/core/src/tools/read/fonts.ts
+++ b/packages/core/src/tools/read/fonts.ts
@@ -4,7 +4,7 @@ export const listFonts = defineTool({
name: 'list_fonts',
description: 'List fonts used in the current page.',
params: {
- family: { type: 'string', description: 'Filter by family name (substring)' },
+ family: { type: 'string', description: 'Filter by family name (substring)' }
},
execute: (figma, args) => {
const fonts = new Map<string, Set<number>>()
@@ -22,14 +22,14 @@ export const listFonts = defineTool({
})
let result = [...fonts.entries()].map(([family, weights]) => ({
family,
- weights: [...weights].sort((a, b) => a - b),
+ weights: [...weights].sort((a, b) => a - b)
}))
if (args.family) {
const q = args.family.toLowerCase()
result = result.filter((font) => font.family.toLowerCase().includes(q))
}
return { count: result.length, fonts: result }
- },
+ }
})
export const listAvailableFonts = defineTool({
@@ -39,7 +39,7 @@ export const listAvailableFonts = defineTool({
'Use this to discover what fonts are available to set on a text node — distinct from list_fonts ' +
'which only reports families currently used in the page.',
params: {
- family: { type: 'string', description: 'Filter by family name (substring, case-insensitive)' },
+ family: { type: 'string', description: 'Filter by family name (substring, case-insensitive)' }
},
execute: async (figma, args) => {
const fonts = await figma.listAvailableFontsAsync()
@@ -50,5 +50,5 @@ export const listAvailableFonts = defineTool({
}
families.sort((a, b) => a.localeCompare(b))
return { count: families.length, fonts: families }
- },
+ }
})
diff --git a/packages/core/src/tools/read/jsx.ts b/packages/core/src/tools/read/jsx.ts
index 9e7cff722..5d00ff204 100644
--- a/packages/core/src/tools/read/jsx.ts
+++ b/packages/core/src/tools/read/jsx.ts
@@ -1,7 +1,6 @@
-import { createTwoFilesPatch } from 'diff'
-
import { sceneNodeToJSX } from '#core/io/formats/jsx'
import { defineTool } from '#core/tools/schema'
+import { createTwoFilesPatch } from 'diff'
const MAX_JSX_LENGTH = 12_000
@@ -13,8 +12,8 @@ export const getJsx = defineTool({
id: { type: 'string', description: 'Node ID', required: true },
path: {
type: 'string',
- description: 'Write JSX to this path instead of returning it (requires OPENPENCIL_MCP_ROOT)',
- },
+ description: 'Write JSX to this path instead of returning it (requires OPENPENCIL_MCP_ROOT)'
+ }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
@@ -26,11 +25,11 @@ export const getJsx = defineTool({
name: node.name,
jsx: jsx.slice(0, MAX_JSX_LENGTH),
truncated: true,
- totalLength: jsx.length,
+ totalLength: jsx.length
}
}
return { id, name: node.name, jsx }
- },
+ }
})
export const diffJsx = defineTool({
@@ -39,7 +38,7 @@ export const diffJsx = defineTool({
'Structural diff between two nodes in JSX format. Shows added/removed children, changed props.',
params: {
from: { type: 'string', description: 'Source node ID', required: true },
- to: { type: 'string', description: 'Target node ID', required: true },
+ to: { type: 'string', description: 'Target node ID', required: true }
},
execute: (figma, { from, to }) => {
const fromNode = figma.getNodeById(from)
@@ -62,5 +61,5 @@ export const diffJsx = defineTool({
{ context: 3 }
)
return { diff: patch }
- },
+ }
})
diff --git a/packages/core/src/tools/read/nodes.ts b/packages/core/src/tools/read/nodes.ts
index cc545daa6..b38070a05 100644
--- a/packages/core/src/tools/read/nodes.ts
+++ b/packages/core/src/tools/read/nodes.ts
@@ -17,7 +17,7 @@ function nodeToTreeEntry(node: FigmaNodeProxy): TreeEntry {
type: node.type,
name: node.name,
w: node.width,
- h: node.height,
+ h: node.height
}
if (node.children.length > 0) {
entry.children = node.children.map(nodeToTreeEntry)
@@ -34,9 +34,9 @@ export const getPageTree = defineTool({
const page = figma.currentPage
return {
page: page.name,
- children: page.children.map(nodeToTreeEntry),
+ children: page.children.map(nodeToTreeEntry)
}
- },
+ }
})
export const getNode = defineTool({
@@ -47,14 +47,14 @@ export const getNode = defineTool({
id: { type: 'string', description: 'Node ID', required: true },
depth: {
type: 'number',
- description: 'Max depth of children to include (0 = no children). Default: unlimited',
- },
+ description: 'Max depth of children to include (0 = no children). Default: unlimited'
+ }
},
execute: (figma, { id, depth }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
return nodeToResult(node, depth)
- },
+ }
})
export const findNodes = defineTool({
@@ -77,9 +77,9 @@ export const findNodes = defineTool({
'GROUP',
'COMPONENT',
'INSTANCE',
- 'VECTOR',
- ],
- },
+ 'VECTOR'
+ ]
+ }
},
execute: (figma, args) => {
const page = figma.currentPage
@@ -89,5 +89,5 @@ export const findNodes = defineTool({
return true
})
return { count: matches.length, nodes: matches.map(nodeSummary) }
- },
+ }
})
diff --git a/packages/core/src/tools/read/pages.ts b/packages/core/src/tools/read/pages.ts
index f0f3c3960..cdd0007a5 100644
--- a/packages/core/src/tools/read/pages.ts
+++ b/packages/core/src/tools/read/pages.ts
@@ -9,9 +9,9 @@ export const listPages = defineTool({
const pages = figma.root.children
return {
current: figma.currentPage.name,
- pages: pages.map((page) => ({ id: page.id, name: page.name })),
+ pages: pages.map((page) => ({ id: page.id, name: page.name }))
}
- },
+ }
})
export const switchPage = defineTool({
@@ -19,14 +19,15 @@ export const switchPage = defineTool({
mutates: true,
description: 'Switch to a different page by name or ID.',
params: {
- page: { type: 'string', description: 'Page name or ID', required: true },
+ page: { type: 'string', description: 'Page name or ID', required: true }
},
execute: (figma, { page }) => {
- const target = figma.root.children.find((candidate) => candidate.name === page) ?? figma.getNodeById(page)
+ const target =
+ figma.root.children.find((candidate) => candidate.name === page) ?? figma.getNodeById(page)
if (!target) return { error: `Page "${page}" not found` }
figma.currentPage = target
return { page: target.name, id: target.id }
- },
+ }
})
export const getCurrentPage = defineTool({
@@ -35,7 +36,7 @@ export const getCurrentPage = defineTool({
params: {},
execute: (figma) => {
return { id: figma.currentPage.id, name: figma.currentPage.name }
- },
+ }
})
export const pageBounds = defineTool({
@@ -44,5 +45,5 @@ export const pageBounds = defineTool({
params: {},
execute: (figma) => {
return computeBounds(figma.currentPage.children.map((child) => child.absoluteBoundingBox))
- },
+ }
})
diff --git a/packages/core/src/tools/read/query.ts b/packages/core/src/tools/read/query.ts
index c283aca6c..d01ffbe90 100644
--- a/packages/core/src/tools/read/query.ts
+++ b/packages/core/src/tools/read/query.ts
@@ -1,5 +1,5 @@
-import { queryByXPath } from '#core/xpath'
import { defineTool } from '#core/tools/schema'
+import { queryByXPath } from '#core/xpath'
export const queryNodes = defineTool({
name: 'query_nodes',
@@ -16,20 +16,20 @@ Examples:
params: {
selector: { type: 'string', description: 'XPath selector', required: true },
page: { type: 'string', description: 'Page name (default: current page)' },
- limit: { type: 'number', description: 'Max results (default: 1000)' },
+ limit: { type: 'number', description: 'Max results (default: 1000)' }
},
execute: async (figma, args) => {
try {
const nodes = await queryByXPath(figma.graph, args.selector, {
page: args.page ?? figma.currentPage.name,
- limit: args.limit,
+ limit: args.limit
})
return {
count: nodes.length,
- nodes: nodes.map((node) => ({ id: node.id, name: node.name, type: node.type })),
+ nodes: nodes.map((node) => ({ id: node.id, name: node.name, type: node.type }))
}
} catch (err) {
return { error: `XPath error: ${err instanceof Error ? err.message : String(err)}` }
}
- },
+ }
})
diff --git a/packages/core/src/tools/read/selection.ts b/packages/core/src/tools/read/selection.ts
index d6c81d21c..106aa43c1 100644
--- a/packages/core/src/tools/read/selection.ts
+++ b/packages/core/src/tools/read/selection.ts
@@ -9,7 +9,7 @@ export const getSelection = defineTool({
execute: (figma) => {
const selection = figma.currentPage.selection
return { selection: selection.map(nodeToResult) }
- },
+ }
})
export const selectNodes = defineTool({
@@ -17,12 +17,12 @@ export const selectNodes = defineTool({
mutates: true,
description: 'Select one or more nodes by ID.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to select', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to select', required: true }
},
execute: (figma, { ids }) => {
figma.currentPage.selection = ids
.map((id) => figma.getNodeById(id))
.filter((node): node is FigmaNodeProxy => node !== null)
return { selected: ids }
- },
+ }
})
diff --git a/packages/core/src/tools/registry-core.ts b/packages/core/src/tools/registry-core.ts
index 4feb13880..66fa438f4 100644
--- a/packages/core/src/tools/registry-core.ts
+++ b/packages/core/src/tools/registry-core.ts
@@ -10,7 +10,7 @@ import {
setStroke,
setText,
setTextProperties,
- updateNode,
+ updateNode
} from './modify'
import { findNodes, getJsx, getNode, getSelection } from './read'
import { stockPhoto } from './stock-photo'
@@ -51,5 +51,5 @@ export const CORE_TOOLS: ToolDef[] = [
describe,
calc,
evalCode,
- viewportZoomToFit,
+ viewportZoomToFit
]
diff --git a/packages/core/src/tools/registry-extended.ts b/packages/core/src/tools/registry-extended.ts
index 4876fd13a..3ec2457bd 100644
--- a/packages/core/src/tools/registry-extended.ts
+++ b/packages/core/src/tools/registry-extended.ts
@@ -4,7 +4,7 @@ import {
analyzeSpacing,
analyzeTypography,
diffCreate,
- diffShow,
+ diffShow
} from './analyze'
import { designToComponentMap, designToTokens } from './codegen'
import {
@@ -16,7 +16,7 @@ import {
createVector,
fetchIconsTool,
insertIcon,
- searchIconsTool,
+ searchIconsTool
} from './create'
import {
setBlend,
@@ -31,7 +31,7 @@ import {
setRotation,
setStrokeAlign,
setTextResize,
- setVisible,
+ setVisible
} from './modify'
import {
diffJsx,
@@ -44,7 +44,7 @@ import {
pageBounds,
queryNodes,
selectNodes,
- switchPage,
+ switchPage
} from './read'
import {
arrangeNodes,
@@ -60,7 +60,7 @@ import {
nodeToComponent,
nodeTree,
renameNode,
- ungroupNode,
+ ungroupNode
} from './structure'
import {
bindVariable,
@@ -73,7 +73,7 @@ import {
getVariable,
listCollections,
listVariables,
- setVariable,
+ setVariable
} from './variables'
import {
booleanExclude,
@@ -88,7 +88,7 @@ import {
pathScale,
pathSet,
viewportGet,
- viewportSet,
+ viewportSet
} from './vector'
import type { ToolDef } from './schema'
@@ -184,5 +184,5 @@ export const EXTENDED_TOOLS: ToolDef[] = [
diffShow,
// Codegen
designToTokens,
- designToComponentMap,
+ designToComponentMap
]
diff --git a/packages/core/src/tools/stock-photo.ts b/packages/core/src/tools/stock-photo.ts
index 262e6ccb2..a55ccc298 100644
--- a/packages/core/src/tools/stock-photo.ts
+++ b/packages/core/src/tools/stock-photo.ts
@@ -12,7 +12,7 @@ export {
setPexelsApiKey,
setUnsplashAccessKey,
type StockPhotoProvider,
- type StockPhotoResult,
+ type StockPhotoResult
} from './stock-photo/providers'
export const stockPhoto = defineTool({
@@ -26,14 +26,14 @@ export const stockPhoto = defineTool({
type: 'string',
description:
'JSON array: [{"id":"0:5","query":"mountain sunset"},{"id":"0:8","query":"business team","orientation":"square"}]',
- required: true,
- },
+ required: true
+ }
},
execute: async (figma, { requests }) => {
const provider = getActiveProvider()
if (!provider) {
return {
- error: `No stock photo provider configured. Ask the user to add an API key in AI chat settings. Available providers: Pexels, Unsplash.`,
+ error: `No stock photo provider configured. Ask the user to add an API key in AI chat settings. Available providers: Pexels, Unsplash.`
}
}
@@ -44,5 +44,5 @@ export const stockPhoto = defineTool({
const ok = results.filter((result) => result.photo).length
return { applied: ok, failed: results.length - ok, provider: provider.name, results }
- },
+ }
})
diff --git a/packages/core/src/tools/stock-photo/apply.ts b/packages/core/src/tools/stock-photo/apply.ts
index 83181a33b..12061b685 100644
--- a/packages/core/src/tools/stock-photo/apply.ts
+++ b/packages/core/src/tools/stock-photo/apply.ts
@@ -64,8 +64,8 @@ export async function applyPhoto(
imageHash: image.hash,
imageScaleMode: 'FILL',
visible: true,
- opacity: 1,
- },
+ opacity: 1
+ }
]
return {
@@ -75,7 +75,7 @@ export async function applyPhoto(
photographer: photo.photographer,
width: photo.width,
height: photo.height,
- provider: provider.name,
- },
+ provider: provider.name
+ }
}
}
diff --git a/packages/core/src/tools/stock-photo/providers.ts b/packages/core/src/tools/stock-photo/providers.ts
index 74aedcbff..f12db2a4c 100644
--- a/packages/core/src/tools/stock-photo/providers.ts
+++ b/packages/core/src/tools/stock-photo/providers.ts
@@ -85,9 +85,9 @@ const pexelsProvider: StockPhotoProvider = {
width: photo.width,
height: photo.height,
photographer: photo.photographer,
- sourceId: String(photo.id),
+ sourceId: String(photo.id)
}))
- },
+ }
}
let unsplashAccessKey: string | null = null
@@ -124,8 +124,8 @@ const unsplashProvider: StockPhotoProvider = {
const resp = await fetch(url, {
headers: {
Authorization: `Client-ID ${unsplashAccessKey}`,
- 'Accept-Version': 'v1',
- },
+ 'Accept-Version': 'v1'
+ }
})
if (!resp.ok) throw new Error(`Unsplash ${resp.status}`)
const data = (await resp.json()) as { results: UnsplashPhoto[] }
@@ -134,7 +134,7 @@ const unsplashProvider: StockPhotoProvider = {
width: photo.width,
height: photo.height,
photographer: photo.user.name,
- sourceId: photo.id,
+ sourceId: photo.id
}))
- },
+ }
}
diff --git a/packages/core/src/tools/structure.ts b/packages/core/src/tools/structure.ts
index 574f77345..bc931791f 100644
--- a/packages/core/src/tools/structure.ts
+++ b/packages/core/src/tools/structure.ts
@@ -1,5 +1,18 @@
-export { cloneNode, deleteNode, nodeBounds, nodeMove, nodeResize, renameNode } from './structure/basic'
-export { flattenNodes, groupNodes, nodeToComponent, reparentNode, ungroupNode } from './structure/hierarchy'
+export {
+ cloneNode,
+ deleteNode,
+ nodeBounds,
+ nodeMove,
+ nodeResize,
+ renameNode
+} from './structure/basic'
+export {
+ flattenNodes,
+ groupNodes,
+ nodeToComponent,
+ reparentNode,
+ ungroupNode
+} from './structure/hierarchy'
export { nodeAncestors, nodeBindings, nodeChildren, nodeTree } from './structure/tree'
diff --git a/packages/core/src/tools/structure/arrange.ts b/packages/core/src/tools/structure/arrange.ts
index 10a075be0..9864665cf 100644
--- a/packages/core/src/tools/structure/arrange.ts
+++ b/packages/core/src/tools/structure/arrange.ts
@@ -13,10 +13,10 @@ export const arrangeNodes = defineTool({
type: 'string',
description: 'Layout mode',
enum: ['grid', 'row', 'column'],
- default: 'grid',
+ default: 'grid'
},
gap: { type: 'number', description: 'Spacing between nodes (default: 40)' },
- cols: { type: 'number', description: 'Column count for grid mode (default: auto)' },
+ cols: { type: 'number', description: 'Column count for grid mode (default: auto)' }
},
execute: (figma, args) => {
const gap = args.gap ?? 40
@@ -44,7 +44,7 @@ export const arrangeNodes = defineTool({
}
return { arranged: nodes.length, mode }
- },
+ }
})
function arrangeRow(nodes: FigmaNodeProxy[], startX: number, y: number, gap: number) {
@@ -65,7 +65,13 @@ function arrangeColumn(nodes: FigmaNodeProxy[], x: number, startY: number, gap:
}
}
-function arrangeGrid(nodes: FigmaNodeProxy[], startX: number, startY: number, cols: number, gap: number) {
+function arrangeGrid(
+ nodes: FigmaNodeProxy[],
+ startX: number,
+ startY: number,
+ cols: number,
+ gap: number
+) {
let x = startX
let y = startY
let rowHeight = 0
diff --git a/packages/core/src/tools/structure/basic.ts b/packages/core/src/tools/structure/basic.ts
index 6baec7c34..c2a40bd84 100644
--- a/packages/core/src/tools/structure/basic.ts
+++ b/packages/core/src/tools/structure/basic.ts
@@ -5,14 +5,14 @@ export const deleteNode = defineTool({
mutates: true,
description: 'Delete a node by ID.',
params: {
- id: { type: 'string', description: 'Node ID to delete', required: true },
+ id: { type: 'string', description: 'Node ID to delete', required: true }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
node.remove()
return { deleted: id }
- },
+ }
})
export const cloneNode = defineTool({
@@ -20,14 +20,14 @@ export const cloneNode = defineTool({
mutates: true,
description: 'Clone (duplicate) a node.',
params: {
- id: { type: 'string', description: 'Node ID to clone', required: true },
+ id: { type: 'string', description: 'Node ID to clone', required: true }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
const clone = node.clone()
return nodeSummary(clone)
- },
+ }
})
export const renameNode = defineTool({
@@ -36,27 +36,27 @@ export const renameNode = defineTool({
description: 'Rename a node in the layers panel.',
params: {
id: { type: 'string', description: 'Node ID', required: true },
- name: { type: 'string', description: 'New name', required: true },
+ name: { type: 'string', description: 'New name', required: true }
},
execute: (figma, { id, name }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
node.name = name
return { id, name }
- },
+ }
})
export const nodeBounds = defineTool({
name: 'node_bounds',
description: 'Get absolute bounding box of a node.',
params: {
- id: { type: 'string', description: 'Node ID', required: true },
+ id: { type: 'string', description: 'Node ID', required: true }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
return { id, bounds: node.absoluteBoundingBox }
- },
+ }
})
export const nodeMove = defineTool({
@@ -66,7 +66,7 @@ export const nodeMove = defineTool({
params: {
id: { type: 'string', description: 'Node ID', required: true },
x: { type: 'number', description: 'X position', required: true },
- y: { type: 'number', description: 'Y position', required: true },
+ y: { type: 'number', description: 'Y position', required: true }
},
execute: (figma, { id, x, y }) => {
const node = figma.getNodeById(id)
@@ -74,7 +74,7 @@ export const nodeMove = defineTool({
node.x = x
node.y = y
return { id, x, y }
- },
+ }
})
export const nodeResize = defineTool({
@@ -84,12 +84,12 @@ export const nodeResize = defineTool({
params: {
id: { type: 'string', description: 'Node ID', required: true },
width: { type: 'number', description: 'Width', required: true, min: 1 },
- height: { type: 'number', description: 'Height', required: true, min: 1 },
+ height: { type: 'number', description: 'Height', required: true, min: 1 }
},
execute: (figma, { id, width, height }) => {
const node = figma.getNodeById(id)
if (!node) return nodeNotFound(id)
node.resize(width, height)
return { id, width, height }
- },
+ }
})
diff --git a/packages/core/src/tools/structure/batch.ts b/packages/core/src/tools/structure/batch.ts
index d625dc8ae..cf28407a3 100644
--- a/packages/core/src/tools/structure/batch.ts
+++ b/packages/core/src/tools/structure/batch.ts
@@ -98,8 +98,8 @@ export const batchUpdate = defineTool({
type: 'string',
description:
'JSON array: [{"id":"0:5","props":{"spacing":8}},{"id":"0:6","props":{"sizing_horizontal":"FILL","grow":1}}]',
- required: true,
- },
+ required: true
+ }
},
execute: (figma, { operations }) => {
let ops: BatchOp[]
@@ -127,5 +127,5 @@ export const batchUpdate = defineTool({
if (results.length > 0) out.results = results
if (errors.length > 0) out.errors = errors
return out
- },
+ }
})
diff --git a/packages/core/src/tools/structure/hierarchy.ts b/packages/core/src/tools/structure/hierarchy.ts
index 45e2a4daa..302b0b666 100644
--- a/packages/core/src/tools/structure/hierarchy.ts
+++ b/packages/core/src/tools/structure/hierarchy.ts
@@ -8,7 +8,7 @@ export const reparentNode = defineTool({
description: 'Move a node into a different parent.',
params: {
id: { type: 'string', description: 'Node ID to move', required: true },
- parent_id: { type: 'string', description: 'New parent node ID', required: true },
+ parent_id: { type: 'string', description: 'New parent node ID', required: true }
},
execute: (figma, { id, parent_id }) => {
const node = figma.getNodeById(id)
@@ -17,7 +17,7 @@ export const reparentNode = defineTool({
if (!parent) return { error: `Parent "${parent_id}" not found` }
parent.appendChild(node)
return { id, parent_id }
- },
+ }
})
export const groupNodes = defineTool({
@@ -25,7 +25,7 @@ export const groupNodes = defineTool({
mutates: true,
description: 'Group selected nodes.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to group', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to group', required: true }
},
execute: (figma, { ids }) => {
const nodes = ids
@@ -35,7 +35,7 @@ export const groupNodes = defineTool({
const parent = nodes[0].parent ?? figma.currentPage
const group = figma.group(nodes, parent)
return nodeSummary(group)
- },
+ }
})
export const ungroupNode = defineTool({
@@ -43,14 +43,14 @@ export const ungroupNode = defineTool({
mutates: true,
description: 'Ungroup a group node.',
params: {
- id: { type: 'string', description: 'Group node ID', required: true },
+ id: { type: 'string', description: 'Group node ID', required: true }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
if (!node) return { error: `Node "${id}" not found` }
figma.ungroup(node)
return { ungrouped: id }
- },
+ }
})
export const flattenNodes = defineTool({
@@ -58,12 +58,12 @@ export const flattenNodes = defineTool({
mutates: true,
description: 'Flatten nodes into a single vector.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to flatten', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to flatten', required: true }
},
execute: (figma, { ids }) => {
const result = figma.flattenNode(ids)
return nodeSummary(result)
- },
+ }
})
export const nodeToComponent = defineTool({
@@ -71,7 +71,7 @@ export const nodeToComponent = defineTool({
mutates: true,
description: 'Convert one or more frames/groups into components.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to convert', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to convert', required: true }
},
execute: (figma, { ids }) => {
const results: { id: string; name: string; originalId: string }[] = []
@@ -82,5 +82,5 @@ export const nodeToComponent = defineTool({
results.push({ id: comp.id, name: comp.name, originalId: id })
}
return { converted: results }
- },
+ }
})
diff --git a/packages/core/src/tools/structure/replace.ts b/packages/core/src/tools/structure/replace.ts
index d00e4282e..71721dba7 100644
--- a/packages/core/src/tools/structure/replace.ts
+++ b/packages/core/src/tools/structure/replace.ts
@@ -6,7 +6,7 @@ export const nodeReplaceWith = defineTool({
description: 'Replace a node with JSX content.',
params: {
id: { type: 'string', description: 'Node ID to replace', required: true },
- jsx: { type: 'string', description: 'JSX string for the replacement', required: true },
+ jsx: { type: 'string', description: 'JSX string for the replacement', required: true }
},
execute: async (figma, args) => {
const node = figma.getNodeById(args.id)
@@ -22,7 +22,9 @@ export const nodeReplaceWith = defineTool({
id: result.id,
name: result.name,
type: result.type,
- children: results.slice(1).map((child) => ({ id: child.id, name: child.name, type: child.type })),
+ children: results
+ .slice(1)
+ .map((child) => ({ id: child.id, name: child.name, type: child.type }))
}
- },
+ }
})
diff --git a/packages/core/src/tools/structure/tree.ts b/packages/core/src/tools/structure/tree.ts
index 6ef9c294f..11a12d1ea 100644
--- a/packages/core/src/tools/structure/tree.ts
+++ b/packages/core/src/tools/structure/tree.ts
@@ -7,7 +7,7 @@ export const nodeAncestors = defineTool({
description: 'Get the ancestor chain from a node to the page root.',
params: {
id: { type: 'string', description: 'Node ID', required: true },
- depth: { type: 'number', description: 'Max depth to traverse' },
+ depth: { type: 'number', description: 'Max depth to traverse' }
},
execute: (figma, args) => {
const node = figma.getNodeById(args.id)
@@ -21,20 +21,20 @@ export const nodeAncestors = defineTool({
depth++
}
return { id: args.id, ancestors }
- },
+ }
})
export const nodeChildren = defineTool({
name: 'node_children',
description: 'Get direct children of a node.',
params: {
- id: { type: 'string', description: 'Node ID', required: true },
+ id: { type: 'string', description: 'Node ID', required: true }
},
execute: (figma, { id }) => {
const node = figma.getNodeById(id)
if (!node) return nodeNotFound(id)
return { id, children: node.children.map(nodeSummary) }
- },
+ }
})
export const nodeTree = defineTool({
@@ -42,7 +42,7 @@ export const nodeTree = defineTool({
description: 'Get a node tree with types and hierarchy.',
params: {
id: { type: 'string', description: 'Node ID', required: true },
- depth: { type: 'number', description: 'Max depth (default: unlimited)' },
+ depth: { type: 'number', description: 'Max depth (default: unlimited)' }
},
execute: (figma, args) => {
const node = figma.getNodeById(args.id)
@@ -51,27 +51,28 @@ export const nodeTree = defineTool({
const result: Record<string, unknown> = {
id: current.id,
name: current.name,
- type: current.type,
+ type: current.type
}
if (args.depth === undefined || depth < args.depth) {
const children = current.children
- if (children.length > 0) result.children = children.map((child) => buildTree(child, depth + 1))
+ if (children.length > 0)
+ result.children = children.map((child) => buildTree(child, depth + 1))
}
return result
}
return buildTree(node, 0)
- },
+ }
})
export const nodeBindings = defineTool({
name: 'node_bindings',
description: 'Get variable bindings for a node.',
params: {
- id: { type: 'string', description: 'Node ID', required: true },
+ id: { type: 'string', description: 'Node ID', required: true }
},
execute: (figma, { id }) => {
const result = getRawNodeOrError(figma, id)
if ('error' in result) return result
return { id, bindings: result.node.boundVariables }
- },
+ }
})
diff --git a/packages/core/src/tools/variables.ts b/packages/core/src/tools/variables.ts
index 3d0aa99f1..4226c87dc 100644
--- a/packages/core/src/tools/variables.ts
+++ b/packages/core/src/tools/variables.ts
@@ -1,4 +1,9 @@
export { bindVariable } from './variables/bindings'
-export { createCollection, deleteCollection, getCollection, listCollections } from './variables/collections'
+export {
+ createCollection,
+ deleteCollection,
+ getCollection,
+ listCollections
+} from './variables/collections'
export { findVariables, getVariable, listVariables } from './variables/read'
export { createVariable, deleteVariable, setVariable } from './variables/values'
diff --git a/packages/core/src/tools/variables/bindings.ts b/packages/core/src/tools/variables/bindings.ts
index d4c36e322..c73204452 100644
--- a/packages/core/src/tools/variables/bindings.ts
+++ b/packages/core/src/tools/variables/bindings.ts
@@ -9,9 +9,9 @@ export const bindVariable = defineTool({
field: {
type: 'string',
description: 'Property field (fills, strokes, opacity, width, height, etc.)',
- required: true,
+ required: true
},
- variable_id: { type: 'string', description: 'Variable ID', required: true },
+ variable_id: { type: 'string', description: 'Variable ID', required: true }
},
execute: (figma, args) => {
const node = figma.getNodeById(args.node_id)
@@ -20,5 +20,5 @@ export const bindVariable = defineTool({
if (!variable) return { error: `Variable "${args.variable_id}" not found` }
figma.bindVariable(args.node_id, args.field, args.variable_id)
return { node_id: args.node_id, field: args.field, variable_id: args.variable_id }
- },
+ }
})
diff --git a/packages/core/src/tools/variables/collections.ts b/packages/core/src/tools/variables/collections.ts
index f2c6e0822..3ec5660b9 100644
--- a/packages/core/src/tools/variables/collections.ts
+++ b/packages/core/src/tools/variables/collections.ts
@@ -7,20 +7,20 @@ export const listCollections = defineTool({
execute: (figma) => {
const collections = figma.getLocalVariableCollections()
return { count: collections.length, collections }
- },
+ }
})
export const getCollection = defineTool({
name: 'get_collection',
description: 'Get a variable collection by ID.',
params: {
- id: { type: 'string', description: 'Collection ID', required: true },
+ id: { type: 'string', description: 'Collection ID', required: true }
},
execute: (figma, { id }) => {
const collection = figma.getVariableCollectionById(id)
if (!collection) return { error: `Collection "${id}" not found` }
return collection
- },
+ }
})
export const createCollection = defineTool({
@@ -28,11 +28,11 @@ export const createCollection = defineTool({
mutates: true,
description: 'Create a new variable collection.',
params: {
- name: { type: 'string', description: 'Collection name', required: true },
+ name: { type: 'string', description: 'Collection name', required: true }
},
execute: (figma, { name }) => {
return figma.createVariableCollection(name)
- },
+ }
})
export const deleteCollection = defineTool({
@@ -40,10 +40,10 @@ export const deleteCollection = defineTool({
mutates: true,
description: 'Delete a variable collection and all its variables.',
params: {
- id: { type: 'string', description: 'Collection ID', required: true },
+ id: { type: 'string', description: 'Collection ID', required: true }
},
execute: (figma, { id }) => {
figma.deleteVariableCollection(id)
return { deleted: id }
- },
+ }
})
diff --git a/packages/core/src/tools/variables/read.ts b/packages/core/src/tools/variables/read.ts
index a0e674312..3c52dba80 100644
--- a/packages/core/src/tools/variables/read.ts
+++ b/packages/core/src/tools/variables/read.ts
@@ -7,26 +7,26 @@ export const listVariables = defineTool({
type: {
type: 'string',
description: 'Filter by variable type',
- enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN'],
- },
+ enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']
+ }
},
execute: (figma, args) => {
const variables = figma.getLocalVariables(args.type)
return { count: variables.length, variables }
- },
+ }
})
export const getVariable = defineTool({
name: 'get_variable',
description: 'Get a variable by ID.',
params: {
- id: { type: 'string', description: 'Variable ID', required: true },
+ id: { type: 'string', description: 'Variable ID', required: true }
},
execute: (figma, { id }) => {
const variable = figma.getVariableById(id)
if (!variable) return { error: `Variable "${id}" not found` }
return variable
- },
+ }
})
export const findVariables = defineTool({
@@ -37,8 +37,8 @@ export const findVariables = defineTool({
type: {
type: 'string',
description: 'Filter by type',
- enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN'],
- },
+ enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']
+ }
},
execute: (figma, args) => {
let variables = figma.getLocalVariables(args.type)
@@ -46,5 +46,5 @@ export const findVariables = defineTool({
variable.name.toLowerCase().includes(args.query.toLowerCase())
)
return { count: variables.length, variables }
- },
+ }
})
diff --git a/packages/core/src/tools/variables/values.ts b/packages/core/src/tools/variables/values.ts
index 988c1f6e2..502bdfff2 100644
--- a/packages/core/src/tools/variables/values.ts
+++ b/packages/core/src/tools/variables/values.ts
@@ -20,16 +20,16 @@ export const createVariable = defineTool({
type: 'string',
description: 'Variable type',
required: true,
- enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN'],
+ enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']
},
collection_id: { type: 'string', description: 'Collection ID', required: true },
- value: { type: 'string', description: 'Initial value (hex for COLOR, number for FLOAT, etc.)' },
+ value: { type: 'string', description: 'Initial value (hex for COLOR, number for FLOAT, etc.)' }
},
execute: (figma, args) => {
const type = args.type as VariableType
const parsedValue = args.value === undefined ? undefined : parseVariableValue(type, args.value)
return figma.createVariable(args.name, type, args.collection_id, parsedValue)
- },
+ }
})
export const setVariable = defineTool({
@@ -42,8 +42,8 @@ export const setVariable = defineTool({
value: {
type: 'string',
description: 'Value (hex for COLOR, number for FLOAT, etc.)',
- required: true,
- },
+ required: true
+ }
},
execute: (figma, args) => {
const variable = figma.getVariableById(args.id)
@@ -51,7 +51,7 @@ export const setVariable = defineTool({
const parsedValue = parseVariableValue(variable.type, args.value)
figma.setVariableValue(args.id, args.mode, parsedValue)
return { id: args.id, mode: args.mode, value: parsedValue }
- },
+ }
})
export const deleteVariable = defineTool({
@@ -59,10 +59,10 @@ export const deleteVariable = defineTool({
mutates: true,
description: 'Delete a variable.',
params: {
- id: { type: 'string', description: 'Variable ID', required: true },
+ id: { type: 'string', description: 'Variable ID', required: true }
},
execute: (figma, { id }) => {
figma.deleteVariable(id)
return { deleted: id }
- },
+ }
})
diff --git a/packages/core/src/tools/vector.ts b/packages/core/src/tools/vector.ts
index 43dd4299f..f851bcdb3 100644
--- a/packages/core/src/tools/vector.ts
+++ b/packages/core/src/tools/vector.ts
@@ -1,4 +1,3 @@
-
export { booleanExclude, booleanIntersect, booleanSubtract, booleanUnion } from './vector/boolean'
export { pathFlip, pathGet, pathMove, pathScale, pathSet } from './vector/path'
diff --git a/packages/core/src/tools/vector/boolean.ts b/packages/core/src/tools/vector/boolean.ts
index 7a7e43516..05d6f3520 100644
--- a/packages/core/src/tools/vector/boolean.ts
+++ b/packages/core/src/tools/vector/boolean.ts
@@ -5,12 +5,12 @@ export const booleanUnion = defineTool({
mutates: true,
description: 'Union (combine) multiple nodes.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to union', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to union', required: true }
},
execute: (figma, { ids }) => {
const result = figma.booleanOperation('UNION', ids)
return nodeSummary(result)
- },
+ }
})
export const booleanSubtract = defineTool({
@@ -18,12 +18,12 @@ export const booleanSubtract = defineTool({
mutates: true,
description: 'Subtract the second node from the first.',
params: {
- ids: { type: 'string[]', description: 'Node IDs (first minus rest)', required: true },
+ ids: { type: 'string[]', description: 'Node IDs (first minus rest)', required: true }
},
execute: (figma, { ids }) => {
const result = figma.booleanOperation('SUBTRACT', ids)
return nodeSummary(result)
- },
+ }
})
export const booleanIntersect = defineTool({
@@ -31,12 +31,12 @@ export const booleanIntersect = defineTool({
mutates: true,
description: 'Intersect multiple nodes.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to intersect', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to intersect', required: true }
},
execute: (figma, { ids }) => {
const result = figma.booleanOperation('INTERSECT', ids)
return nodeSummary(result)
- },
+ }
})
export const booleanExclude = defineTool({
@@ -44,10 +44,10 @@ export const booleanExclude = defineTool({
mutates: true,
description: 'Exclude (XOR) multiple nodes.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to exclude', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to exclude', required: true }
},
execute: (figma, { ids }) => {
const result = figma.booleanOperation('EXCLUDE', ids)
return nodeSummary(result)
- },
+ }
})
diff --git a/packages/core/src/tools/vector/export.ts b/packages/core/src/tools/vector/export.ts
index e05d89a85..9c8437964 100644
--- a/packages/core/src/tools/vector/export.ts
+++ b/packages/core/src/tools/vector/export.ts
@@ -22,12 +22,12 @@ export const exportSvg = defineTool({
params: {
ids: {
type: 'string[]',
- description: 'Node IDs to export. Omit to export all top-level nodes on the current page.',
+ description: 'Node IDs to export. Omit to export all top-level nodes on the current page.'
},
path: {
type: 'string',
- description: 'Write SVG to this path instead of returning it (requires OPENPENCIL_MCP_ROOT)',
- },
+ description: 'Write SVG to this path instead of returning it (requires OPENPENCIL_MCP_ROOT)'
+ }
},
execute: async (figma, args) => {
const { renderNodesToSVG } = await import('#core/io/formats/svg')
@@ -37,7 +37,7 @@ export const exportSvg = defineTool({
const svg = renderNodesToSVG(figma.graph, pageId, ids)
if (!svg) return { error: 'No visible nodes to export' }
return { svg }
- },
+ }
})
export const exportImage = defineTool({
@@ -47,26 +47,26 @@ export const exportImage = defineTool({
params: {
ids: {
type: 'string[]',
- description: 'Node IDs to export. Omit to export all top-level nodes on the current page.',
+ description: 'Node IDs to export. Omit to export all top-level nodes on the current page.'
},
format: {
type: 'string',
description: 'Image format',
enum: ['PNG', 'JPG', 'WEBP'],
- default: 'PNG',
+ default: 'PNG'
},
scale: {
type: 'number',
description: 'Export scale multiplier (default: 1)',
default: 1,
min: 0.1,
- max: 4,
+ max: 4
},
path: {
type: 'string',
description:
- 'Write image to this path instead of returning base64 (requires OPENPENCIL_MCP_ROOT)',
- },
+ 'Write image to this path instead of returning base64 (requires OPENPENCIL_MCP_ROOT)'
+ }
},
execute: async (figma, args) => {
if (!figma.exportImage) {
@@ -77,7 +77,7 @@ export const exportImage = defineTool({
const format = (args.format ?? 'PNG').toUpperCase() as RasterExportFormat
const data = await figma.exportImage(ids, {
scale: args.scale ?? 1,
- format,
+ format
})
if (!data || data.length === 0) return { error: 'No visible nodes to export' }
const base64 = uint8ArrayToBase64(data)
@@ -85,7 +85,7 @@ export const exportImage = defineTool({
return {
mimeType: mimeMap[format],
base64,
- byteLength: data.length,
+ byteLength: data.length
}
- },
+ }
})
diff --git a/packages/core/src/tools/vector/path.ts b/packages/core/src/tools/vector/path.ts
index 16aa95943..c750fc273 100644
--- a/packages/core/src/tools/vector/path.ts
+++ b/packages/core/src/tools/vector/path.ts
@@ -18,14 +18,14 @@ export const pathGet = defineTool({
name: 'path_get',
description: 'Get vector path data of a node.',
params: {
- id: { type: 'string', description: 'Node ID', required: true },
+ id: { type: 'string', description: 'Node ID', required: true }
},
execute: (figma, { id }) => {
const raw = figma.graph.getNode(id)
if (!raw) return { error: `Node "${id}" not found` }
const vectorNetwork = raw.vectorNetwork
return vectorNetwork ? { id, vectorNetwork } : { error: `Node "${id}" has no vector data` }
- },
+ }
})
export const pathSet = defineTool({
@@ -34,7 +34,7 @@ export const pathSet = defineTool({
description: 'Set vector path data on a node. Provide a VectorNetwork JSON.',
params: {
id: { type: 'string', description: 'Node ID', required: true },
- path: { type: 'string', description: 'VectorNetwork JSON', required: true },
+ path: { type: 'string', description: 'VectorNetwork JSON', required: true }
},
execute: (figma, args) => {
const raw = figma.graph.getNode(args.id)
@@ -42,7 +42,7 @@ export const pathSet = defineTool({
const network = JSON.parse(args.path)
figma.graph.updateNode(args.id, { vectorNetwork: network })
return { id: args.id }
- },
+ }
})
export const pathScale = defineTool({
@@ -51,7 +51,7 @@ export const pathScale = defineTool({
description: 'Scale vector path from center.',
params: {
id: { type: 'string', description: 'Node ID', required: true },
- factor: { type: 'number', description: 'Scale factor (e.g. 2 for double)', required: true },
+ factor: { type: 'number', description: 'Scale factor (e.g. 2 for double)', required: true }
},
execute: (figma, { id, factor }) => {
const result = getVectorNode(figma, id)
@@ -72,7 +72,7 @@ export const pathScale = defineTool({
figma.graph.updateNode(id, { vectorNetwork: vn })
return { id, factor }
- },
+ }
})
export const pathFlip = defineTool({
@@ -85,8 +85,8 @@ export const pathFlip = defineTool({
type: 'string',
description: 'Flip axis',
required: true,
- enum: ['horizontal', 'vertical'],
- },
+ enum: ['horizontal', 'vertical']
+ }
},
execute: (figma, { id, axis }) => {
const result = getVectorNode(figma, id)
@@ -107,7 +107,7 @@ export const pathFlip = defineTool({
figma.graph.updateNode(id, { vectorNetwork: vn })
return { id, axis }
- },
+ }
})
export const pathMove = defineTool({
@@ -117,7 +117,7 @@ export const pathMove = defineTool({
params: {
id: { type: 'string', description: 'Node ID', required: true },
dx: { type: 'number', description: 'X offset', required: true },
- dy: { type: 'number', description: 'Y offset', required: true },
+ dy: { type: 'number', description: 'Y offset', required: true }
},
execute: (figma, { id, dx, dy }) => {
const result = getVectorNode(figma, id)
@@ -130,5 +130,5 @@ export const pathMove = defineTool({
figma.graph.updateNode(id, { vectorNetwork: vn })
return { id, dx, dy }
- },
+ }
})
diff --git a/packages/core/src/tools/vector/viewport.ts b/packages/core/src/tools/vector/viewport.ts
index 316db8718..6492ecedb 100644
--- a/packages/core/src/tools/vector/viewport.ts
+++ b/packages/core/src/tools/vector/viewport.ts
@@ -6,7 +6,7 @@ export const viewportGet = defineTool({
params: {},
execute: (figma) => {
return figma.viewport
- },
+ }
})
export const viewportSet = defineTool({
@@ -16,12 +16,12 @@ export const viewportSet = defineTool({
params: {
x: { type: 'number', description: 'Center X', required: true },
y: { type: 'number', description: 'Center Y', required: true },
- zoom: { type: 'number', description: 'Zoom level', required: true, min: 0.01 },
+ zoom: { type: 'number', description: 'Zoom level', required: true, min: 0.01 }
},
execute: (figma, { x, y, zoom }) => {
figma.viewport = { center: { x, y }, zoom }
return { x, y, zoom }
- },
+ }
})
export const viewportZoomToFit = defineTool({
@@ -29,7 +29,7 @@ export const viewportZoomToFit = defineTool({
mutates: true,
description: 'Zoom viewport to fit specified nodes.',
params: {
- ids: { type: 'string[]', description: 'Node IDs to fit in view', required: true },
+ ids: { type: 'string[]', description: 'Node IDs to fit in view', required: true }
},
execute: (figma, { ids }) => {
let minX = Infinity
@@ -51,7 +51,7 @@ export const viewportZoomToFit = defineTool({
figma.viewport = { center: { x: centerX, y: centerY }, zoom: 1 }
return {
center: { x: centerX, y: centerY },
- bounds: { x: minX, y: minY, width: maxX - minX, height: maxY - minY },
+ bounds: { x: minX, y: minY, width: maxX - minX, height: maxY - minY }
}
- },
+ }
})
diff --git a/packages/core/src/vector/bezier.ts b/packages/core/src/vector/bezier.ts
index 3aa5e9745..6340f7671 100644
--- a/packages/core/src/vector/bezier.ts
+++ b/packages/core/src/vector/bezier.ts
@@ -79,7 +79,15 @@ export function splitSegmentAt(
tangentEnd: { x: 0, y: 0 }
}
- return finishSplitSegment(network, newVertices, newSegments, segmentIndex, seg1, seg2, newVertexIndex)
+ return finishSplitSegment(
+ network,
+ newVertices,
+ newSegments,
+ segmentIndex,
+ seg1,
+ seg2,
+ newVertexIndex
+ )
}
// Cubic split via De Casteljau
@@ -103,7 +111,15 @@ export function splitSegmentAt(
tangentEnd: { x: right.cp2.x - v1.x, y: right.cp2.y - v1.y }
}
- return finishSplitSegment(network, newVertices, newSegments, segmentIndex, seg1, seg2, newVertexIndex)
+ return finishSplitSegment(
+ network,
+ newVertices,
+ newSegments,
+ segmentIndex,
+ seg1,
+ seg2,
+ newVertexIndex
+ )
}
function buildMergedSegmentForRemovedVertex(
diff --git a/packages/core/src/vector/curve-math.ts b/packages/core/src/vector/curve-math.ts
index 94e6d094c..a7fdf4ff8 100644
--- a/packages/core/src/vector/curve-math.ts
+++ b/packages/core/src/vector/curve-math.ts
@@ -325,4 +325,4 @@ export function nearestPointOnNetwork(
/**
* Split a segment in a VectorNetwork at parameter t, inserting a new vertex.
* Returns a new VectorNetwork with updated vertices, segments, and regions.
- */
\ No newline at end of file
+ */
diff --git a/packages/mcp/src/auth.ts b/packages/mcp/src/auth.ts
index 79d4c100e..9b3840531 100644
--- a/packages/mcp/src/auth.ts
+++ b/packages/mcp/src/auth.ts
@@ -4,7 +4,7 @@ export function bearerToken(header: string | undefined | null): string | null {
export function mcpRequestToken(
authorization: string | undefined | null,
- headerToken: string | undefined | null,
+ headerToken: string | undefined | null
): string | null {
return bearerToken(authorization) ?? headerToken ?? null
}
diff --git a/packages/mcp/src/http-options.ts b/packages/mcp/src/http-options.ts
index aadf8cf9f..cf8191d86 100644
--- a/packages/mcp/src/http-options.ts
+++ b/packages/mcp/src/http-options.ts
@@ -6,7 +6,7 @@ export const MCP_CORS_HEADERS = [
'x-mcp-token',
'mcp-session-id',
'Last-Event-ID',
- 'mcp-protocol-version',
+ 'mcp-protocol-version'
]
export const MCP_EXPOSED_HEADERS = ['mcp-session-id', 'mcp-protocol-version']
diff --git a/packages/mcp/src/jsx-preprocess.ts b/packages/mcp/src/jsx-preprocess.ts
index 7ac1feb95..73b1681f4 100644
--- a/packages/mcp/src/jsx-preprocess.ts
+++ b/packages/mcp/src/jsx-preprocess.ts
@@ -10,7 +10,7 @@ export function preprocessRpc(body: Record<string, unknown>): Record<string, unk
const tree = resolveToTree(element)
return {
...body,
- args: { ...args, args: { ...args.args, jsx: undefined, tree } },
+ args: { ...args, args: { ...args.args, jsx: undefined, tree } }
}
} catch (e) {
console.warn('JSX preprocessing failed, passing raw:', e instanceof Error ? e.message : e)
diff --git a/packages/mcp/src/mcp-sessions.ts b/packages/mcp/src/mcp-sessions.ts
index 29267723b..f2ffb8b06 100644
--- a/packages/mcp/src/mcp-sessions.ts
+++ b/packages/mcp/src/mcp-sessions.ts
@@ -19,7 +19,10 @@ type McpSessionManagerOptions = {
const MAX_MCP_SESSIONS = 10
const MCP_SESSION_TTL_MS = 15 * 60_000
-export function createMcpSessionManager({ serverVersion, registerTools }: McpSessionManagerOptions) {
+export function createMcpSessionManager({
+ serverVersion,
+ registerTools
+}: McpSessionManagerOptions) {
const sessions = new Map<string, MCPSession>()
function notifyToolsChanged() {
@@ -46,7 +49,7 @@ export function createMcpSessionManager({ serverVersion, registerTools }: McpSes
registerTools(server)
const transport = new WebStandardStreamableHTTPServerTransport({
- sessionIdGenerator: () => id,
+ sessionIdGenerator: () => id
})
void server.connect(transport)
sessions.set(id, { transport, server, lastSeen: Date.now() })
diff --git a/packages/mcp/src/server.ts b/packages/mcp/src/server.ts
index 1d006ecee..ba2fe9f1f 100644
--- a/packages/mcp/src/server.ts
+++ b/packages/mcp/src/server.ts
@@ -1,7 +1,9 @@
import { createRequire } from 'node:module'
+
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { WebSocketServer } from 'ws'
+
import { bearerToken, isAuthorized, mcpRequestToken } from './auth'
import { createBrowserRpcBridge } from './browser-rpc'
import { MCP_CORS_HEADERS, MCP_CORS_METHODS, MCP_EXPOSED_HEADERS } from './http-options'
diff --git a/packages/mcp/src/stdio-bridge.ts b/packages/mcp/src/stdio-bridge.ts
index f564465b4..8e0aa063d 100644
--- a/packages/mcp/src/stdio-bridge.ts
+++ b/packages/mcp/src/stdio-bridge.ts
@@ -30,7 +30,7 @@ export function createStdioRpcBridge({
wsUrl,
reconnectDelayMs = 2000,
onOpen,
- onMalformedMessage,
+ onMalformedMessage
}: StdioRpcBridgeOptions) {
const pending = new Map<string, PendingRequest>()
let ws: WebSocket | null = null
diff --git a/packages/mcp/src/stdio.ts b/packages/mcp/src/stdio.ts
index 6f0351ed3..338207d3c 100644
--- a/packages/mcp/src/stdio.ts
+++ b/packages/mcp/src/stdio.ts
@@ -2,8 +2,8 @@
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
-import { createStdioRpcBridge } from './stdio-bridge.js'
import { MCP_VERSION, registerTools } from './server.js'
+import { createStdioRpcBridge } from './stdio-bridge.js'
const wsPort = parseInt(process.env.WS_PORT ?? '7601', 10)
const wsHost = process.env.HOST ?? '127.0.0.1'
@@ -18,7 +18,7 @@ const bridge = createStdioRpcBridge({
},
onMalformedMessage: () => {
process.stderr.write('Malformed WS message\n')
- },
+ }
})
bridge.connect()
diff --git a/packages/mcp/src/tool/output.ts b/packages/mcp/src/tool/output.ts
index 3199a3743..2483d72d1 100644
--- a/packages/mcp/src/tool/output.ts
+++ b/packages/mcp/src/tool/output.ts
@@ -18,7 +18,7 @@ export async function writeToolOutput(
toolName: string,
result: Record<string, unknown>,
filePath: string,
- root: string,
+ root: string
): Promise<MCPResult | null> {
const resolved = resolveSafePath(filePath, root)
await mkdir(dirname(resolved), { recursive: true })
diff --git a/packages/mcp/src/tool/registration.ts b/packages/mcp/src/tool/registration.ts
index 196ff752f..b8d851ec0 100644
--- a/packages/mcp/src/tool/registration.ts
+++ b/packages/mcp/src/tool/registration.ts
@@ -1,10 +1,10 @@
import { resolve } from 'node:path'
+import { fail, ok } from '#mcp/result'
import { z } from 'zod'
import { ALL_TOOLS, CODEGEN_PROMPT } from '@open-pencil/core/tools'
-import { fail, ok } from '#mcp/result'
import { resolveSafePath, writeToolOutput } from './output'
import { paramToZod } from './schema'
@@ -49,16 +49,16 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
{
type: 'image' as const,
data: r.base64 as string,
- mimeType: r.mimeType as string,
- },
- ],
+ mimeType: r.mimeType as string
+ }
+ ]
}
}
return ok(r)
} catch (e) {
return fail(e)
}
- },
+ }
)
}
@@ -67,7 +67,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
{
description:
'Save the current document to disk. Uses the existing file path if available, otherwise prompts for a location.',
- inputSchema: z.object({}),
+ inputSchema: z.object({})
},
async () => {
try {
@@ -78,7 +78,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
} catch (e) {
return fail(e)
}
- },
+ }
)
if (resolvedRoot) {
@@ -87,8 +87,8 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
{
description: `Open a .fig or .pen file from disk into a new tab. Path must be inside ${resolvedRoot}.`,
inputSchema: z.object({
- path: z.string().describe('Absolute path to the design file'),
- }),
+ path: z.string().describe('Absolute path to the design file')
+ })
},
async (args: { path: string }) => {
try {
@@ -100,7 +100,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
} catch (e) {
return fail(e)
}
- },
+ }
)
register(
@@ -108,8 +108,8 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
{
description: `Create a new empty document. Optionally set a save path inside ${resolvedRoot}.`,
inputSchema: z.object({
- path: z.string().describe('Optional absolute path for the new file').optional(),
- }),
+ path: z.string().describe('Optional absolute path for the new file').optional()
+ })
},
async (args: { path?: string }) => {
try {
@@ -121,16 +121,17 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
} catch (e) {
return fail(e)
}
- },
+ }
)
}
register(
'get_codegen_prompt',
{
- description: 'Get design-to-code generation guidelines. Call before generating frontend code.',
- inputSchema: z.object({}),
+ description:
+ 'Get design-to-code generation guidelines. Call before generating frontend code.',
+ inputSchema: z.object({})
},
- async () => ok({ prompt: CODEGEN_PROMPT }),
+ async () => ok({ prompt: CODEGEN_PROMPT })
)
}
diff --git a/packages/mcp/src/tool/schema.ts b/packages/mcp/src/tool/schema.ts
index 796fc6559..b99ea29fc 100644
--- a/packages/mcp/src/tool/schema.ts
+++ b/packages/mcp/src/tool/schema.ts
@@ -16,7 +16,7 @@ export function paramToZod(param: ParamDef): z.ZodType {
},
boolean: () => z.boolean().describe(param.description),
color: () => z.string().describe(param.description),
- 'string[]': () => z.array(z.string()).min(1).describe(param.description),
+ 'string[]': () => z.array(z.string()).min(1).describe(param.description)
}
const schema = typeMap[param.type]()
diff --git a/packages/vue/src/canvas/node-edit-input/bend.ts b/packages/vue/src/canvas/node-edit-input/bend.ts
index 4bef73ead..aac6daca8 100644
--- a/packages/vue/src/canvas/node-edit-input/bend.ts
+++ b/packages/vue/src/canvas/node-edit-input/bend.ts
@@ -1,7 +1,7 @@
import type { DragState } from '#vue/shared/input/types'
+import type { Editor } from '@open-pencil/core/editor'
import type { VectorSegment } from '@open-pencil/core/scene-graph'
import type { Vector } from '@open-pencil/core/types'
-import type { Editor } from '@open-pencil/core/editor'
export type CanvasNodeEditState = {
segments: VectorSegment[]
diff --git a/packages/vue/src/canvas/pen-input/drag.ts b/packages/vue/src/canvas/pen-input/drag.ts
index fa14d1559..0b84fde4c 100644
--- a/packages/vue/src/canvas/pen-input/drag.ts
+++ b/packages/vue/src/canvas/pen-input/drag.ts
@@ -1,6 +1,6 @@
import type { DragState } from '#vue/shared/input/types'
-import type { Vector } from '@open-pencil/core/types'
import type { Editor } from '@open-pencil/core/editor'
+import type { Vector } from '@open-pencil/core/types'
type PenDragState = Extract<DragState, { type: 'pen-drag' }>
type PenState = NonNullable<Editor['state']['penState']>
diff --git a/packages/vue/src/canvas/pointer/use.ts b/packages/vue/src/canvas/pointer/use.ts
index 8b95e5ed4..ae9f3d9f8 100644
--- a/packages/vue/src/canvas/pointer/use.ts
+++ b/packages/vue/src/canvas/pointer/use.ts
@@ -6,8 +6,8 @@ import {
} from '#vue/shared/input/geometry'
import type { HitTestFns } from '#vue/shared/input/select'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Ref } from 'vue'
export function createCanvasPointer(
diff --git a/packages/vue/src/canvas/surface/lifecycle.ts b/packages/vue/src/canvas/surface/lifecycle.ts
index 17caa18b1..b0a796b07 100644
--- a/packages/vue/src/canvas/surface/lifecycle.ts
+++ b/packages/vue/src/canvas/surface/lifecycle.ts
@@ -1,10 +1,10 @@
-import { onScopeDispose } from 'vue'
-
-import { SkiaRenderer } from '@open-pencil/core/canvas'
import { makeGLSurface, sizeCanvas, type CanvasGLContext } from '#vue/canvas/surface/gl-surface'
import { useCanvasKitLoader } from '#vue/canvas/surface/kit-loader'
import { createCanvasRenderLoop } from '#vue/canvas/surface/render-loop'
import { useCanvasResizeObserver } from '#vue/canvas/surface/resize-observer'
+import { onScopeDispose } from 'vue'
+
+import { SkiaRenderer } from '@open-pencil/core/canvas'
import type { UseCanvasOptions } from '#vue/canvas/surface/types'
import type { Editor } from '@open-pencil/core/editor'
diff --git a/packages/vue/src/canvas/text-edit/editing.ts b/packages/vue/src/canvas/text-edit/editing.ts
index 0cce45647..43bc13d94 100644
--- a/packages/vue/src/canvas/text-edit/editing.ts
+++ b/packages/vue/src/canvas/text-edit/editing.ts
@@ -75,7 +75,13 @@ export function createTextCompositionHandlers({
isComposing = false
}
- return { isComposing: () => isComposing, onCompositionStart, onCompositionEnd, onInput, resetComposition }
+ return {
+ isComposing: () => isComposing,
+ onCompositionStart,
+ onCompositionEnd,
+ onInput,
+ resetComposition
+ }
}
export function createTextEditActions(store: Editor) {
diff --git a/packages/vue/src/canvas/text-edit/input.ts b/packages/vue/src/canvas/text-edit/input.ts
index 30c3b2063..a8a60ee96 100644
--- a/packages/vue/src/canvas/text-edit/input.ts
+++ b/packages/vue/src/canvas/text-edit/input.ts
@@ -1,6 +1,6 @@
import type { DragState } from '#vue/shared/input/types'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
type NodeEditMethods = Partial<{ enterNodeEditMode: (nodeId: string) => void }>
type GetCoords = (e: MouseEvent) => { cx: number; cy: number }
diff --git a/packages/vue/src/canvas/text-edit/keyboard.ts b/packages/vue/src/canvas/text-edit/keyboard.ts
index 15ecc4cba..9e3eb5ee4 100644
--- a/packages/vue/src/canvas/text-edit/keyboard.ts
+++ b/packages/vue/src/canvas/text-edit/keyboard.ts
@@ -1,7 +1,7 @@
import { extendSelectionForDeletion, handleNavigationKey } from './navigation'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
type TextKeyboardOptions = {
store: Editor
diff --git a/packages/vue/src/canvas/text-edit/use.ts b/packages/vue/src/canvas/text-edit/use.ts
index bd02ca256..773f2a3cd 100644
--- a/packages/vue/src/canvas/text-edit/use.ts
+++ b/packages/vue/src/canvas/text-edit/use.ts
@@ -2,14 +2,10 @@ import { useEventListener } from '@vueuse/core'
import { shallowRef, type Ref } from 'vue'
import { createTextClipboardActions } from './clipboard'
-import {
- createCaretBlink,
- createTextCompositionHandlers,
- createTextEditActions
-} from './editing'
-import { focusTextAreaOnCanvasPointerDown, useTextEditingSession } from './textarea'
+import { createCaretBlink, createTextCompositionHandlers, createTextEditActions } from './editing'
import { createTextFormattingActions } from './formatting'
import { createTextKeyDownHandler } from './keyboard'
+import { focusTextAreaOnCanvasPointerDown, useTextEditingSession } from './textarea'
import type { Editor } from '@open-pencil/core/editor'
diff --git a/packages/vue/src/canvas/tool-input/use.ts b/packages/vue/src/canvas/tool-input/use.ts
index ca9164a9f..4a561dc85 100644
--- a/packages/vue/src/canvas/tool-input/use.ts
+++ b/packages/vue/src/canvas/tool-input/use.ts
@@ -41,16 +41,7 @@ export function handleToolMouseDown({
}
if (tool === 'SELECT') {
- handleSelectDown(
- event,
- cx,
- cy,
- editor,
- hitFns,
- tryStartRotation,
- handleTextEditClick,
- setDrag
- )
+ handleSelectDown(event, cx, cy, editor, hitFns, tryStartRotation, handleTextEditClick, setDrag)
return
}
diff --git a/packages/vue/src/canvas/useCanvasInput.ts b/packages/vue/src/canvas/useCanvasInput.ts
index 1da797681..043cc3eb6 100644
--- a/packages/vue/src/canvas/useCanvasInput.ts
+++ b/packages/vue/src/canvas/useCanvasInput.ts
@@ -6,22 +6,22 @@ import {
import { handlePenDragMove, updatePenHover } from '#vue/canvas/pen-input/use'
import { createCanvasPointer } from '#vue/canvas/pointer/use'
import { createTextEditInput } from '#vue/canvas/text-edit/input'
-import { createCanvasTransformInput } from '#vue/canvas/transform-input/use'
import { handleToolMouseDown } from '#vue/canvas/tool-input/use'
+import { createCanvasTransformInput } from '#vue/canvas/transform-input/use'
import { createClickCounter } from '#vue/shared/input/click-count'
import { handleDrawMove, handleDrawUp } from '#vue/shared/input/draw'
-import { useSpaceHeld } from '#vue/shared/input/space-key'
import { handleMoveMove, handleMoveUp } from '#vue/shared/input/move'
import { handleNodeEditMove } from '#vue/shared/input/node-edit'
import { setupPanZoom } from '#vue/shared/input/pan-zoom'
import { applyResize } from '#vue/shared/input/resize'
import { updateHoverCursor } from '#vue/shared/input/select'
+import { useSpaceHeld } from '#vue/shared/input/space-key'
import { useEventListener } from '@vueuse/core'
import { ref, type Ref } from 'vue'
import type { DragState } from '#vue/shared/input/types'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
/**
* Wires pointer and mouse interaction to an OpenPencil canvas.
diff --git a/packages/vue/src/controls/appearance/use.ts b/packages/vue/src/controls/appearance/use.ts
index 2611370a1..e85bb8e42 100644
--- a/packages/vue/src/controls/appearance/use.ts
+++ b/packages/vue/src/controls/appearance/use.ts
@@ -1,7 +1,4 @@
-import {
- createAppearanceActions,
- createAppearanceState
-} from '#vue/controls/appearance/helpers'
+import { createAppearanceActions, createAppearanceState } from '#vue/controls/appearance/helpers'
import { useNodeProps } from '#vue/controls/node-props/use'
import { useEditor } from '#vue/editor/context'
diff --git a/packages/vue/src/controls/effects/helpers.ts b/packages/vue/src/controls/effects/helpers.ts
index 094a052ff..f67584b11 100644
--- a/packages/vue/src/controls/effects/helpers.ts
+++ b/packages/vue/src/controls/effects/helpers.ts
@@ -1,6 +1,6 @@
+import type { Editor } from '@open-pencil/core/editor'
import type { Effect, SceneNode } from '@open-pencil/core/scene-graph'
import type { Color } from '@open-pencil/core/types'
-import type { Editor } from '@open-pencil/core/editor'
import type { Ref } from 'vue'
type EffectType = Effect['type']
diff --git a/packages/vue/src/controls/effects/use.ts b/packages/vue/src/controls/effects/use.ts
index 939fd27ea..ec1356b4a 100644
--- a/packages/vue/src/controls/effects/use.ts
+++ b/packages/vue/src/controls/effects/use.ts
@@ -1,6 +1,3 @@
-import { useEditor } from '#vue/editor/context'
-import { ref } from 'vue'
-
import {
EFFECT_OPTIONS,
createDefaultEffect,
@@ -8,6 +5,8 @@ import {
createEffectEditActions,
isShadow
} from '#vue/controls/effects/helpers'
+import { useEditor } from '#vue/editor/context'
+import { ref } from 'vue'
import type { Effect } from '@open-pencil/core/scene-graph'
diff --git a/packages/vue/src/controls/node-props/helpers.ts b/packages/vue/src/controls/node-props/helpers.ts
index a2d0227bc..2efb7c769 100644
--- a/packages/vue/src/controls/node-props/helpers.ts
+++ b/packages/vue/src/controls/node-props/helpers.ts
@@ -1,9 +1,9 @@
import { useSceneComputed } from '#vue/internal/scene-computed/use'
import { computed } from 'vue'
-import type { ComputedRef } from 'vue'
-import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/core/scene-graph'
+import type { ComputedRef } from 'vue'
export const MIXED = Symbol('mixed')
export type MixedValue<T> = T | typeof MIXED
diff --git a/packages/vue/src/controls/node-props/use.ts b/packages/vue/src/controls/node-props/use.ts
index 5a1037a97..b78b18e09 100644
--- a/packages/vue/src/controls/node-props/use.ts
+++ b/packages/vue/src/controls/node-props/use.ts
@@ -1,4 +1,3 @@
-import { useEditor } from '#vue/editor/context'
import {
MIXED,
createNodePropArrayActions,
@@ -6,6 +5,7 @@ import {
createNodePropSelectionState,
isNodeArrayMixed
} from '#vue/controls/node-props/helpers'
+import { useEditor } from '#vue/editor/context'
/** Sentinel value returned when a property differs across multiple selected nodes. */
export { MIXED }
diff --git a/packages/vue/src/controls/number-variable-binding/use.ts b/packages/vue/src/controls/number-variable-binding/use.ts
index 432100cc1..366caeb7b 100644
--- a/packages/vue/src/controls/number-variable-binding/use.ts
+++ b/packages/vue/src/controls/number-variable-binding/use.ts
@@ -1,4 +1,5 @@
import { useVariableBinding } from '#vue/controls/variable-binding/use'
+
import { randomHex } from '@open-pencil/core/random'
import type { VariableCollection } from '@open-pencil/core/scene-graph'
@@ -17,7 +18,9 @@ export function useNumberVariableBinding(path: NumberBindingPath) {
const existing = binding.store
.getCollections()
.find((collection) =>
- collection.variableIds.some((variableId) => binding.store.getVariable(variableId)?.type === 'FLOAT')
+ collection.variableIds.some(
+ (variableId) => binding.store.getVariable(variableId)?.type === 'FLOAT'
+ )
)
if (existing) return existing
@@ -32,7 +35,11 @@ export function useNumberVariableBinding(path: NumberBindingPath) {
return collection
}
- function createAndBindVariable(nodeId: string, value: number, name = FALLBACK_NUMBER_VARIABLE_NAME) {
+ function createAndBindVariable(
+ nodeId: string,
+ value: number,
+ name = FALLBACK_NUMBER_VARIABLE_NAME
+ ) {
const collection = numberCollection()
const id = `var:${randomHex(8)}`
binding.store.addVariable({
diff --git a/packages/vue/src/controls/okhcl/helpers.ts b/packages/vue/src/controls/okhcl/helpers.ts
index 53506612b..8a9b9c945 100644
--- a/packages/vue/src/controls/okhcl/helpers.ts
+++ b/packages/vue/src/controls/okhcl/helpers.ts
@@ -9,8 +9,8 @@ import {
import type { ColorFieldFormat } from '#vue/primitives/ColorPicker/types'
import type { OkHCLColor } from '@open-pencil/core/color'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Ref } from 'vue'
type ColorKind = 'fill' | 'stroke'
@@ -28,11 +28,17 @@ export function getStrokeOkHCLColor(node: SceneNode | null, index: number): OkHC
}
function fallbackFillOkHCL(node: SceneNode, index: number) {
- return getFillOkHCLColor(node, index) ?? rgbaToOkHCL(node.fills[index]?.color ?? { r: 0, g: 0, b: 0, a: 1 })
+ return (
+ getFillOkHCLColor(node, index) ??
+ rgbaToOkHCL(node.fills[index]?.color ?? { r: 0, g: 0, b: 0, a: 1 })
+ )
}
function fallbackStrokeOkHCL(node: SceneNode, index: number) {
- return getStrokeOkHCLColor(node, index) ?? rgbaToOkHCL(node.strokes[index]?.color ?? { r: 0, g: 0, b: 0, a: 1 })
+ return (
+ getStrokeOkHCLColor(node, index) ??
+ rgbaToOkHCL(node.strokes[index]?.color ?? { r: 0, g: 0, b: 0, a: 1 })
+ )
}
export function createOkHCLActions(editor: Editor) {
diff --git a/packages/vue/src/controls/okhcl/use.ts b/packages/vue/src/controls/okhcl/use.ts
index 8220b44ab..37eb69624 100644
--- a/packages/vue/src/controls/okhcl/use.ts
+++ b/packages/vue/src/controls/okhcl/use.ts
@@ -1,6 +1,3 @@
-import { useEditor } from '#vue/editor/context'
-import { ref } from 'vue'
-
import {
OKHCL_FIELD_OPTIONS,
createOkHCLActions,
@@ -9,6 +6,8 @@ import {
getFillOkHCLColor,
getStrokeOkHCLColor
} from '#vue/controls/okhcl/helpers'
+import { useEditor } from '#vue/editor/context'
+import { ref } from 'vue'
import type { ColorFieldFormat } from '#vue/primitives/ColorPicker/types'
diff --git a/packages/vue/src/controls/stroke/helpers.ts b/packages/vue/src/controls/stroke/helpers.ts
index 792cd8f85..a207017b3 100644
--- a/packages/vue/src/controls/stroke/helpers.ts
+++ b/packages/vue/src/controls/stroke/helpers.ts
@@ -1,5 +1,5 @@
-import type { SceneNode, Stroke } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode, Stroke } from '@open-pencil/core/scene-graph'
import type { Ref } from 'vue'
export type StrokeSides = 'ALL' | 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT' | 'CUSTOM'
@@ -34,7 +34,12 @@ export function currentAlign(activeNode: SceneNode | null): Stroke['align'] {
export function currentSides(activeNode: SceneNode | null): StrokeSides {
if (!activeNode?.independentStrokeWeights) return 'ALL'
- const { borderTopWeight: t, borderRightWeight: r, borderBottomWeight: b, borderLeftWeight: l } = activeNode
+ const {
+ borderTopWeight: t,
+ borderRightWeight: r,
+ borderBottomWeight: b,
+ borderLeftWeight: l
+ } = activeNode
const active = [t > 0, r > 0, b > 0, l > 0]
const count = active.filter(Boolean).length
if (count === 4 && t === r && r === b && b === l) return 'ALL'
@@ -98,9 +103,17 @@ export function createStrokeSideActions(editor: Editor, sideMenuOpen: Ref<boolea
sideMenuOpen.value = false
}
- function updateBorderWeight(side: (typeof BORDER_SIDES)[number], value: number, activeNode: SceneNode) {
+ function updateBorderWeight(
+ side: (typeof BORDER_SIDES)[number],
+ value: number,
+ activeNode: SceneNode
+ ) {
const key = `border${side[0].toUpperCase()}${side.slice(1)}Weight` as keyof SceneNode
- editor.updateNodeWithUndo(activeNode.id, { [key]: value } as Partial<SceneNode>, 'Change stroke weight')
+ editor.updateNodeWithUndo(
+ activeNode.id,
+ { [key]: value } as Partial<SceneNode>,
+ 'Change stroke weight'
+ )
}
return { selectSide, updateBorderWeight }
diff --git a/packages/vue/src/controls/stroke/use.ts b/packages/vue/src/controls/stroke/use.ts
index d1e7f7d28..27027b6e7 100644
--- a/packages/vue/src/controls/stroke/use.ts
+++ b/packages/vue/src/controls/stroke/use.ts
@@ -1,7 +1,3 @@
-import { useEditor } from '#vue/editor/context'
-import { useI18n } from '#vue/i18n'
-import { ref } from 'vue'
-
import {
BORDER_SIDES,
DEFAULT_STROKE,
@@ -11,6 +7,9 @@ import {
currentSides,
updateAlign
} from '#vue/controls/stroke/helpers'
+import { useEditor } from '#vue/editor/context'
+import { useI18n } from '#vue/i18n'
+import { ref } from 'vue'
/**
* Returns stroke-related helpers for property panels.
diff --git a/packages/vue/src/document/export/helpers.ts b/packages/vue/src/document/export/helpers.ts
index d09962391..31b5c3335 100644
--- a/packages/vue/src/document/export/helpers.ts
+++ b/packages/vue/src/document/export/helpers.ts
@@ -54,7 +54,14 @@ export function createExportTargetState(
activeTarget.value === 'selection' ? selectionSettings.value : pageSettings.value
)
- return { hasSelection, activeTarget, selectedNodeName, currentPageName, activeName, activeSettings }
+ return {
+ hasSelection,
+ activeTarget,
+ selectedNodeName,
+ currentPageName,
+ activeName,
+ activeSettings
+ }
}
export function createExportSettingActions(
@@ -80,7 +87,8 @@ export function createExportSettingActions(
addPageSetting: () => addSetting(pageSettings),
removeSelectionSetting: (index: number) => selectionSettings.value.splice(index, 1),
removePageSetting: (index: number) => pageSettings.value.splice(index, 1),
- updateSelectionScale: (index: number, scale: number) => updateScale(selectionSettings, index, scale),
+ updateSelectionScale: (index: number, scale: number) =>
+ updateScale(selectionSettings, index, scale),
updatePageScale: (index: number, scale: number) => updateScale(pageSettings, index, scale),
updateSelectionFormat: (index: number, format: ExportFormatId) =>
updateFormat(selectionSettings, index, format),
diff --git a/packages/vue/src/document/export/use.ts b/packages/vue/src/document/export/use.ts
index 62ce72fc9..09c4a9791 100644
--- a/packages/vue/src/document/export/use.ts
+++ b/packages/vue/src/document/export/use.ts
@@ -1,5 +1,3 @@
-import { useEditor } from '#vue/editor/context'
-import { useSceneComputed } from '#vue/internal/scene-computed/use'
import {
EXPORT_FORMATS,
EXPORT_SCALES,
@@ -8,6 +6,8 @@ import {
createExportTargetState,
formatSupportsScale
} from '#vue/document/export/helpers'
+import { useEditor } from '#vue/editor/context'
+import { useSceneComputed } from '#vue/internal/scene-computed/use'
import { ref } from 'vue'
export type ExportFormatId = 'png' | 'jpg' | 'webp' | 'svg' | 'fig'
diff --git a/packages/vue/src/editor/commands/definitions.ts b/packages/vue/src/editor/commands/definitions.ts
index 07e3a08d5..082a97454 100644
--- a/packages/vue/src/editor/commands/definitions.ts
+++ b/packages/vue/src/editor/commands/definitions.ts
@@ -2,8 +2,8 @@ import { createEditCommands } from './edit'
import { createSelectionCommands } from './selection'
import { createViewCommands } from './view'
-import type { EditorCommand, EditorCommandId } from './types'
import type { EditorCommandMapOptions } from './context'
+import type { EditorCommand, EditorCommandId } from './types'
export function createEditorCommandMap(
options: EditorCommandMapOptions
@@ -11,6 +11,6 @@ export function createEditorCommandMap(
return {
...createEditCommands(options),
...createSelectionCommands(options),
- ...createViewCommands(options),
+ ...createViewCommands(options)
}
}
diff --git a/packages/vue/src/editor/commands/edit.ts b/packages/vue/src/editor/commands/edit.ts
index 803eefc1e..00010a259 100644
--- a/packages/vue/src/editor/commands/edit.ts
+++ b/packages/vue/src/editor/commands/edit.ts
@@ -1,12 +1,12 @@
-import type { EditorCommand } from './types'
import type { EditorCommandMapOptions } from './context'
+import type { EditorCommand } from './types'
type EditCommandId = 'edit.undo' | 'edit.redo'
export function createEditCommands({
editor,
capabilities,
- messages: t,
+ messages: t
}: EditorCommandMapOptions): Record<EditCommandId, EditorCommand> {
return {
'edit.undo': {
@@ -15,7 +15,7 @@ export function createEditCommands({
return t.value.undo
},
enabled: capabilities.canUndo,
- run: () => editor.undoAction(),
+ run: () => editor.undoAction()
},
'edit.redo': {
id: 'edit.redo',
@@ -23,7 +23,7 @@ export function createEditCommands({
return t.value.redo
},
enabled: capabilities.canRedo,
- run: () => editor.redoAction(),
- },
+ run: () => editor.redoAction()
+ }
}
}
diff --git a/packages/vue/src/editor/commands/metadata.ts b/packages/vue/src/editor/commands/metadata.ts
index 6b4494fad..bea4ec1c6 100644
--- a/packages/vue/src/editor/commands/metadata.ts
+++ b/packages/vue/src/editor/commands/metadata.ts
@@ -15,5 +15,5 @@ export const EDITOR_COMMAND_SHORTCUTS: Partial<Record<EditorCommandId, string>>
'selection.bringToFront': ']',
'selection.sendToBack': '[',
'selection.toggleVisibility': '⇧⌘H',
- 'selection.toggleLock': '⇧⌘L',
+ 'selection.toggleLock': '⇧⌘L'
}
diff --git a/packages/vue/src/editor/commands/selection.ts b/packages/vue/src/editor/commands/selection.ts
index 766d1a908..1615d43c3 100644
--- a/packages/vue/src/editor/commands/selection.ts
+++ b/packages/vue/src/editor/commands/selection.ts
@@ -1,5 +1,5 @@
-import type { EditorCommand, EditorCommandId } from './types'
import type { EditorCommandMapOptions } from './context'
+import type { EditorCommand, EditorCommandId } from './types'
type SelectionCommandId = Extract<EditorCommandId, `selection.${string}`>
@@ -9,7 +9,7 @@ export function createSelectionCommands({
capabilities,
messages: t,
otherPages,
- moveSelectionToPage,
+ moveSelectionToPage
}: EditorCommandMapOptions): Record<SelectionCommandId, EditorCommand> {
return {
'selection.selectAll': {
@@ -18,7 +18,7 @@ export function createSelectionCommands({
return t.value.selectAll
},
enabled: capabilities.canSelectAll,
- run: () => editor.selectAll(),
+ run: () => editor.selectAll()
},
'selection.duplicate': {
id: 'selection.duplicate',
@@ -26,7 +26,7 @@ export function createSelectionCommands({
return t.value.duplicate
},
enabled: capabilities.canDuplicate,
- run: () => editor.duplicateSelected(),
+ run: () => editor.duplicateSelected()
},
'selection.delete': {
id: 'selection.delete',
@@ -34,7 +34,7 @@ export function createSelectionCommands({
return t.value.delete
},
enabled: capabilities.canDelete,
- run: () => editor.deleteSelected(),
+ run: () => editor.deleteSelected()
},
'selection.group': {
id: 'selection.group',
@@ -42,7 +42,7 @@ export function createSelectionCommands({
return t.value.group
},
enabled: capabilities.canGroup,
- run: () => editor.groupSelected(),
+ run: () => editor.groupSelected()
},
'selection.ungroup': {
id: 'selection.ungroup',
@@ -50,7 +50,7 @@ export function createSelectionCommands({
return t.value.ungroup
},
enabled: capabilities.canUngroup,
- run: () => editor.ungroupSelected(),
+ run: () => editor.ungroupSelected()
},
'selection.createComponent': {
id: 'selection.createComponent',
@@ -58,7 +58,7 @@ export function createSelectionCommands({
return t.value.createComponent
},
enabled: capabilities.canCreateComponent,
- run: () => editor.createComponentFromSelection(),
+ run: () => editor.createComponentFromSelection()
},
'selection.createComponentSet': {
id: 'selection.createComponentSet',
@@ -66,7 +66,7 @@ export function createSelectionCommands({
return t.value.createComponentSet
},
enabled: capabilities.canCreateComponentSet,
- run: () => editor.createComponentSetFromComponents(),
+ run: () => editor.createComponentSetFromComponents()
},
'selection.createInstance': {
id: 'selection.createInstance',
@@ -77,7 +77,7 @@ export function createSelectionCommands({
run: () => {
const node = selection.selectedNode.value
if (node?.type === 'COMPONENT') editor.createInstanceFromComponent(node.id)
- },
+ }
},
'selection.detachInstance': {
id: 'selection.detachInstance',
@@ -85,7 +85,7 @@ export function createSelectionCommands({
return t.value.detachInstance
},
enabled: capabilities.canDetachInstance,
- run: () => editor.detachInstance(),
+ run: () => editor.detachInstance()
},
'selection.goToMainComponent': {
id: 'selection.goToMainComponent',
@@ -93,7 +93,7 @@ export function createSelectionCommands({
return t.value.goToMainComponent
},
enabled: capabilities.canGoToMainComponent,
- run: () => editor.goToMainComponent(),
+ run: () => editor.goToMainComponent()
},
'selection.wrapInAutoLayout': {
id: 'selection.wrapInAutoLayout',
@@ -101,7 +101,7 @@ export function createSelectionCommands({
return t.value.addAutoLayout
},
enabled: capabilities.canWrapInAutoLayout,
- run: () => editor.wrapInAutoLayout(),
+ run: () => editor.wrapInAutoLayout()
},
'selection.bringToFront': {
id: 'selection.bringToFront',
@@ -109,7 +109,7 @@ export function createSelectionCommands({
return t.value.bringToFront
},
enabled: capabilities.canBringToFront,
- run: () => editor.bringToFront(),
+ run: () => editor.bringToFront()
},
'selection.sendToBack': {
id: 'selection.sendToBack',
@@ -117,7 +117,7 @@ export function createSelectionCommands({
return t.value.sendToBack
},
enabled: capabilities.canSendToBack,
- run: () => editor.sendToBack(),
+ run: () => editor.sendToBack()
},
'selection.toggleVisibility': {
id: 'selection.toggleVisibility',
@@ -125,7 +125,7 @@ export function createSelectionCommands({
return t.value.toggleVisibility
},
enabled: capabilities.canToggleVisibility,
- run: () => editor.toggleVisibility(),
+ run: () => editor.toggleVisibility()
},
'selection.toggleLock': {
id: 'selection.toggleLock',
@@ -133,7 +133,7 @@ export function createSelectionCommands({
return t.value.toggleLock
},
enabled: capabilities.canToggleLock,
- run: () => editor.toggleLock(),
+ run: () => editor.toggleLock()
},
'selection.moveToPage': {
id: 'selection.moveToPage',
@@ -143,7 +143,7 @@ export function createSelectionCommands({
enabled: capabilities.canMoveToPage,
run: () => {
moveSelectionToPage(otherPages.value[0].id)
- },
- },
+ }
+ }
}
}
diff --git a/packages/vue/src/editor/commands/view.ts b/packages/vue/src/editor/commands/view.ts
index 2098c6fb3..16c6a0cf9 100644
--- a/packages/vue/src/editor/commands/view.ts
+++ b/packages/vue/src/editor/commands/view.ts
@@ -1,12 +1,12 @@
import { computed } from 'vue'
-import type { EditorCommand } from './types'
import type { EditorCommandMapOptions } from './context'
+import type { EditorCommand } from './types'
export function createViewCommands({
editor,
capabilities,
- messages: t,
+ messages: t
}: EditorCommandMapOptions): Pick<
Record<'view.zoom100' | 'view.zoomFit' | 'view.zoomSelection', EditorCommand>,
'view.zoom100' | 'view.zoomFit' | 'view.zoomSelection'
@@ -18,7 +18,7 @@ export function createViewCommands({
return t.value.zoomTo100
},
enabled: computed(() => true),
- run: () => editor.zoomTo100(),
+ run: () => editor.zoomTo100()
},
'view.zoomFit': {
id: 'view.zoomFit',
@@ -26,7 +26,7 @@ export function createViewCommands({
return t.value.zoomToFit
},
enabled: computed(() => true),
- run: () => editor.zoomToFit(),
+ run: () => editor.zoomToFit()
},
'view.zoomSelection': {
id: 'view.zoomSelection',
@@ -34,7 +34,7 @@ export function createViewCommands({
return t.value.zoomToSelection
},
enabled: capabilities.canZoomToSelection,
- run: () => editor.zoomToSelection(),
- },
+ run: () => editor.zoomToSelection()
+ }
}
}
diff --git a/packages/vue/src/editor/menu-model/command-groups.ts b/packages/vue/src/editor/menu-model/command-groups.ts
index caef19746..b514990e4 100644
--- a/packages/vue/src/editor/menu-model/command-groups.ts
+++ b/packages/vue/src/editor/menu-model/command-groups.ts
@@ -3,17 +3,17 @@ import type { EditorCommandId } from '#vue/editor/commands/types'
export const EDIT_MENU_COMMAND_GROUPS = [
['edit.undo', 'edit.redo'],
['selection.duplicate', 'selection.delete'],
- ['selection.selectAll'],
+ ['selection.selectAll']
] satisfies ReadonlyArray<ReadonlyArray<EditorCommandId>>
export const VIEW_MENU_COMMANDS = [
'view.zoom100',
'view.zoomFit',
- 'view.zoomSelection',
+ 'view.zoomSelection'
] satisfies ReadonlyArray<EditorCommandId>
export const OBJECT_MENU_COMMAND_GROUPS = [
['selection.group', 'selection.ungroup'],
['selection.createComponent', 'selection.createComponentSet', 'selection.detachInstance'],
- ['selection.bringToFront', 'selection.sendToBack'],
+ ['selection.bringToFront', 'selection.sendToBack']
] satisfies ReadonlyArray<ReadonlyArray<EditorCommandId>>
diff --git a/packages/vue/src/editor/menu-model/use.ts b/packages/vue/src/editor/menu-model/use.ts
index df8397384..67bf50aa8 100644
--- a/packages/vue/src/editor/menu-model/use.ts
+++ b/packages/vue/src/editor/menu-model/use.ts
@@ -1,11 +1,11 @@
+import { useEditorCommands } from '#vue/editor/commands/use'
+import { useEditor } from '#vue/editor/context'
import {
buildCanvasMenu,
buildEditMenu,
buildObjectMenu,
buildViewMenu
} from '#vue/editor/menu-model/builders'
-import { useEditorCommands } from '#vue/editor/commands/use'
-import { useEditor } from '#vue/editor/context'
import { useSelectionState } from '#vue/editor/selection-state/use'
import { menuMessages } from '#vue/i18n'
import { useStore } from '@nanostores/vue'
diff --git a/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue b/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue
index 7303f321e..04af1db20 100644
--- a/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue
+++ b/packages/vue/src/primitives/ColorPicker/ColorInputRoot.vue
@@ -5,7 +5,11 @@ import { colorToHexRaw, parseColor } from '@open-pencil/core/color'
import type { Color } from '@open-pencil/core/types'
import type { OkHCLControls } from '#vue/primitives/ColorPicker/types'
-const { color, editable = false, okhcl = null } = defineProps<{
+const {
+ color,
+ editable = false,
+ okhcl = null
+} = defineProps<{
color: Color
editable?: boolean
okhcl?: OkHCLControls | null
diff --git a/packages/vue/src/primitives/LayoutControls/context.ts b/packages/vue/src/primitives/LayoutControls/context.ts
index dbb6f1ae2..f92dac161 100644
--- a/packages/vue/src/primitives/LayoutControls/context.ts
+++ b/packages/vue/src/primitives/LayoutControls/context.ts
@@ -1,7 +1,7 @@
import { inject, provide } from 'vue'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { useLayout } from '#vue/controls/layout/use'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { InjectionKey, ShallowUnwrapRef } from 'vue'
type RawLayoutControlsContext = ShallowUnwrapRef<ReturnType<typeof useLayout>>
diff --git a/packages/vue/src/primitives/PropertyList/context.ts b/packages/vue/src/primitives/PropertyList/context.ts
index a2bf9bfdd..54456b4ab 100644
--- a/packages/vue/src/primitives/PropertyList/context.ts
+++ b/packages/vue/src/primitives/PropertyList/context.ts
@@ -1,7 +1,7 @@
import { type ComputedRef, type InjectionKey, inject, provide } from 'vue'
-import type { SceneNode } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/core/scene-graph'
type ArrayPropKey = 'fills' | 'strokes' | 'effects'
diff --git a/packages/vue/src/shared/input/draw.ts b/packages/vue/src/shared/input/draw.ts
index 217f3916d..72a5534f3 100644
--- a/packages/vue/src/shared/input/draw.ts
+++ b/packages/vue/src/shared/input/draw.ts
@@ -1,7 +1,7 @@
-import { DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH } from '@open-pencil/core/constants'
-
import { TOOL_TO_NODE } from '#vue/shared/input/types'
+import { DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH } from '@open-pencil/core/constants'
+
import type { DragDraw, DragState } from '#vue/shared/input/types'
import type { Editor } from '@open-pencil/core/editor'
diff --git a/packages/vue/src/shared/input/gesture.ts b/packages/vue/src/shared/input/gesture.ts
index fd710e514..ccfc23d01 100644
--- a/packages/vue/src/shared/input/gesture.ts
+++ b/packages/vue/src/shared/input/gesture.ts
@@ -1,6 +1,5 @@
-import { useEventListener } from '@vueuse/core'
-
import { createRafScheduler } from '#vue/shared/input/raf-scheduler'
+import { useEventListener } from '@vueuse/core'
import type { Editor } from '@open-pencil/core/editor'
import type { Ref } from 'vue'
diff --git a/packages/vue/src/shared/input/node-edit/hit-test.ts b/packages/vue/src/shared/input/node-edit/hit-test.ts
index 26033c432..416ee9732 100644
--- a/packages/vue/src/shared/input/node-edit/hit-test.ts
+++ b/packages/vue/src/shared/input/node-edit/hit-test.ts
@@ -1,5 +1,5 @@
-import type { VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
export type NodeEditState = {
nodeId: string
diff --git a/packages/vue/src/shared/input/node-edit/index.ts b/packages/vue/src/shared/input/node-edit/index.ts
index 7c638fadc..168a37fab 100644
--- a/packages/vue/src/shared/input/node-edit/index.ts
+++ b/packages/vue/src/shared/input/node-edit/index.ts
@@ -13,8 +13,8 @@ export {
isEndpoint,
NODE_HIT_THRESHOLD
} from '#vue/shared/input/node-edit/hit-test'
-import type { Vector } from '@open-pencil/core/types'
import type { Editor } from '@open-pencil/core/editor'
+import type { Vector } from '@open-pencil/core/types'
type NodeEditEditor = Partial<{
nodeEditSelectVertex: (vertexIndex: number, addToSelection: boolean) => void
diff --git a/packages/vue/src/shared/input/resize.ts b/packages/vue/src/shared/input/resize.ts
index cc8f7da44..2dbdcf54f 100644
--- a/packages/vue/src/shared/input/resize.ts
+++ b/packages/vue/src/shared/input/resize.ts
@@ -15,13 +15,7 @@ export function applyResize(
editor: Editor
) {
const { origRect } = d
- const newRect = calculateResizeRect(
- d.handle,
- origRect,
- cx - d.startX,
- cy - d.startY,
- constrain
- )
+ const newRect = calculateResizeRect(d.handle, origRect, cx - d.startX, cy - d.startY, constrain)
const changes: Partial<SceneNode> = { ...newRect }
@@ -35,4 +29,4 @@ export function applyResize(
if (resizedVectorNetwork) changes.vectorNetwork = resizedVectorNetwork
editor.updateNode(d.nodeId, changes)
-}
\ No newline at end of file
+}
diff --git a/packages/vue/src/shared/input/select.ts b/packages/vue/src/shared/input/select.ts
index 684769342..90588cc76 100644
--- a/packages/vue/src/shared/input/select.ts
+++ b/packages/vue/src/shared/input/select.ts
@@ -2,8 +2,8 @@ import { getNodeEditState, handleNodeEditDown } from '#vue/shared/input/node-edi
export { resolveHit } from '#vue/shared/input/select/hit'
import { resolveHit } from '#vue/shared/input/select/hit'
export { updateHoverCursor } from '#vue/shared/input/select/hover'
-import { createSelectionMoveDrag, selectionIsLocked } from '#vue/shared/input/select/move'
import { tryStartResize } from '#vue/shared/input/resize'
+import { createSelectionMoveDrag, selectionIsLocked } from '#vue/shared/input/select/move'
import type { DragState } from '#vue/shared/input/types'
import type { Editor } from '@open-pencil/core/editor'
@@ -64,4 +64,3 @@ export function handleSelectDown(
setDrag(createSelectionMoveDrag(cx, cy, editor, e.altKey))
}
-
diff --git a/packages/vue/src/shared/input/select/hover.ts b/packages/vue/src/shared/input/select/hover.ts
index e3863a2c8..b414490ea 100644
--- a/packages/vue/src/shared/input/select/hover.ts
+++ b/packages/vue/src/shared/input/select/hover.ts
@@ -29,7 +29,13 @@ function getRotationCursorForSelection(cx: number, cy: number, editor: Editor):
const node = editor.graph.getNode(id)
if (!node) return null
- const corner = hitTestCornerRotationByMatrix(cx, cy, node, editor.graph, editor.renderer?.zoom ?? 1)
+ const corner = hitTestCornerRotationByMatrix(
+ cx,
+ cy,
+ node,
+ editor.graph,
+ editor.renderer?.zoom ?? 1
+ )
if (!corner) return null
const absoluteRotation = getAbsoluteRotation(node, editor.graph)
diff --git a/packages/vue/src/shared/input/select/move.ts b/packages/vue/src/shared/input/select/move.ts
index e8bae86bd..8155433d1 100644
--- a/packages/vue/src/shared/input/select/move.ts
+++ b/packages/vue/src/shared/input/select/move.ts
@@ -1,5 +1,5 @@
-import { detectAutoLayoutParent } from '#vue/shared/input/move'
import { duplicateAndDrag } from '#vue/shared/input/duplicate-drag'
+import { detectAutoLayoutParent } from '#vue/shared/input/move'
import type { DragState } from '#vue/shared/input/types'
import type { Editor } from '@open-pencil/core/editor'
diff --git a/packages/vue/src/shared/input/types.ts b/packages/vue/src/shared/input/types.ts
index b548a26dc..6f615d895 100644
--- a/packages/vue/src/shared/input/types.ts
+++ b/packages/vue/src/shared/input/types.ts
@@ -1,6 +1,6 @@
+import type { Tool } from '@open-pencil/core/editor'
import type { NodeType, VectorNetwork } from '@open-pencil/core/scene-graph'
import type { Rect, Vector } from '@open-pencil/core/types'
-import type { Tool } from '@open-pencil/core/editor'
export type HandlePosition = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
diff --git a/packages/vue/src/shared/input/wheel.ts b/packages/vue/src/shared/input/wheel.ts
index 762a4058b..be4655cc1 100644
--- a/packages/vue/src/shared/input/wheel.ts
+++ b/packages/vue/src/shared/input/wheel.ts
@@ -4,7 +4,6 @@ import { createRafScheduler } from '#vue/shared/input/raf-scheduler'
import type { Editor } from '@open-pencil/core/editor'
import type { Ref } from 'vue'
-
type WheelAccum = {
deltaX: number
deltaY: number
diff --git a/packages/vue/src/variables/helpers.ts b/packages/vue/src/variables/helpers.ts
index 1d8ccdc53..8d776c670 100644
--- a/packages/vue/src/variables/helpers.ts
+++ b/packages/vue/src/variables/helpers.ts
@@ -1,14 +1,11 @@
import { colorToHexRaw, parseColor } from '@open-pencil/core/color'
import { randomHex } from '@open-pencil/core/random'
-import type { Variable, VariableCollection, VariableValue } from '@open-pencil/core/scene-graph'
import type { Editor } from '@open-pencil/core/editor'
+import type { Variable, VariableCollection, VariableValue } from '@open-pencil/core/scene-graph'
import type { Ref } from 'vue'
-export function createVariableCollectionActions(
- editor: Editor,
- activeCollectionId: Ref<string>
-) {
+export function createVariableCollectionActions(editor: Editor, activeCollectionId: Ref<string>) {
function setActiveCollection(id: string) {
activeCollectionId.value = id
}
diff --git a/packages/vue/src/variables/use.ts b/packages/vue/src/variables/use.ts
index 36d0e26aa..c5aa81f49 100644
--- a/packages/vue/src/variables/use.ts
+++ b/packages/vue/src/variables/use.ts
@@ -1,9 +1,6 @@
import { useEditor } from '#vue/editor/context'
import { useSceneComputed } from '#vue/internal/scene-computed/use'
-import {
- createVariableCollectionActions,
- createVariableValueActions
-} from '#vue/variables/helpers'
+import { createVariableCollectionActions, createVariableValueActions } from '#vue/variables/helpers'
import { ref, computed, watch } from 'vue'
import type { Variable } from '@open-pencil/core/scene-graph'
diff --git a/src/app/ai/chat/storage.ts b/src/app/ai/chat/storage.ts
index ac2eefc12..995fa751b 100644
--- a/src/app/ai/chat/storage.ts
+++ b/src/app/ai/chat/storage.ts
@@ -6,7 +6,7 @@ import {
DEFAULT_AI_MODEL,
DEFAULT_AI_PROVIDER,
IS_BROWSER,
- IS_TAURI,
+ IS_TAURI
} from '@open-pencil/core/constants'
import { setPexelsApiKey, setUnsplashAccessKey } from '@open-pencil/core/tools'
diff --git a/src/app/ai/debug/index.ts b/src/app/ai/debug/index.ts
index 46c6e76d1..857870cec 100644
--- a/src/app/ai/debug/index.ts
+++ b/src/app/ai/debug/index.ts
@@ -4,7 +4,6 @@ import { buildDebugLog } from '@open-pencil/core/tools'
import type { ToolDebugLog, ToolLogEntry } from '@open-pencil/core/tools'
import type { UIMessage } from 'ai'
-
export function formatTokenUsage(): string {
const steps = getStepUsages()
if (steps.length === 0) return ' (no usage data — provider may not report it)'
diff --git a/src/app/automation/bridge/handlers.ts b/src/app/automation/bridge/handlers.ts
index 6f90f73c5..b08390d74 100644
--- a/src/app/automation/bridge/handlers.ts
+++ b/src/app/automation/bridge/handlers.ts
@@ -43,4 +43,3 @@ export function createAutomationCommandHandlers(makeFigma: FigmaFactory) {
return { handleRequest }
}
-
diff --git a/src/app/collab/awareness.ts b/src/app/collab/awareness.ts
index 4fafefbe6..0ec44b5e1 100644
--- a/src/app/collab/awareness.ts
+++ b/src/app/collab/awareness.ts
@@ -3,8 +3,8 @@ import { ref } from 'vue'
import { PEER_COLORS, ROOM_ID_CHARS, ROOM_ID_LENGTH } from '@/constants'
import { randomIndex } from '@open-pencil/core/random'
-import type { EditorStore } from '@/app/editor/active-store'
import type { RemotePeer } from './types'
+import type { EditorStore } from '@/app/editor/active-store'
import type { Color } from '@open-pencil/core/types'
import type * as awarenessProtocol from 'y-protocols/awareness'
diff --git a/src/app/collab/session.ts b/src/app/collab/session.ts
index 1926171ff..835799b64 100644
--- a/src/app/collab/session.ts
+++ b/src/app/collab/session.ts
@@ -10,8 +10,8 @@ import { randomIndex } from '@open-pencil/core/random'
import type { CollabState } from '@/app/collab/types'
import type { EditorStore } from '@/app/editor/active-store'
-import type { Ref } from 'vue'
import type { Room } from 'trystero'
+import type { Ref } from 'vue'
import type { Awareness } from 'y-protocols/awareness'
export type CollabRuntime = {
diff --git a/src/app/collab/use.ts b/src/app/collab/use.ts
index ce92dadc0..513268fd8 100644
--- a/src/app/collab/use.ts
+++ b/src/app/collab/use.ts
@@ -10,6 +10,7 @@ import {
} from '@/app/collab/session'
import { DEFAULT_COLLAB_STATE, type CollabState, type RemotePeer } from '@/app/collab/types'
import { createYjsGraphSync } from '@/app/collab/yjs-sync'
+
import type { EditorStore } from '@/app/editor/active-store'
export { COLLAB_KEY, useCollabInjected } from '@/app/collab/context'
diff --git a/src/app/document/export/files.ts b/src/app/document/export/files.ts
index 07dd39015..a94459e68 100644
--- a/src/app/document/export/files.ts
+++ b/src/app/document/export/files.ts
@@ -2,7 +2,12 @@ import { IS_TAURI } from '@/constants'
import { renderNodesToImage } from '@open-pencil/core/io/formats/raster'
import type { Editor, EditorState } from '@open-pencil/core/editor'
-import type { ExportRequest, IOFormatAdapter, IORegistry, RasterExportFormat } from '@open-pencil/core/io'
+import type {
+ ExportRequest,
+ IOFormatAdapter,
+ IORegistry,
+ RasterExportFormat
+} from '@open-pencil/core/io'
import type { SceneGraph } from '@open-pencil/core/scene-graph'
type ExportOptions = {
diff --git a/src/app/document/io/names.ts b/src/app/document/io/names.ts
index 364c4c11d..ba7453a8f 100644
--- a/src/app/document/io/names.ts
+++ b/src/app/document/io/names.ts
@@ -1,8 +1,10 @@
export function documentNameFromFigPath(path: string): string {
- return path
- .split(/[\\/]/)
- .pop()
- ?.replace(/\.fig$/i, '') ?? 'Untitled'
+ return (
+ path
+ .split(/[\\/]/)
+ .pop()
+ ?.replace(/\.fig$/i, '') ?? 'Untitled'
+ )
}
export function downloadNameFromPath(path: string): string {
diff --git a/src/app/document/io/read.ts b/src/app/document/io/read.ts
index c5e0d5045..6d4512c64 100644
--- a/src/app/document/io/read.ts
+++ b/src/app/document/io/read.ts
@@ -74,7 +74,11 @@ export function createReloadActions({
const filePath = getFilePath()
const fileHandle = getFileHandle()
- const imported = await readReloadSource({ documentName: state.documentName, filePath, fileHandle })
+ const imported = await readReloadSource({
+ documentName: state.documentName,
+ filePath,
+ fileHandle
+ })
if (!imported) return
editor.replaceGraph(imported)
diff --git a/src/app/document/io/reload-state.ts b/src/app/document/io/reload-state.ts
index b8101cdfe..b02b043a4 100644
--- a/src/app/document/io/reload-state.ts
+++ b/src/app/document/io/reload-state.ts
@@ -18,7 +18,11 @@ export function captureReloadState(state: EditorState): ReloadStateSnapshot {
}
}
-export function restoreReloadState(editor: Editor, state: EditorState, snapshot: ReloadStateSnapshot) {
+export function restoreReloadState(
+ editor: Editor,
+ state: EditorState,
+ snapshot: ReloadStateSnapshot
+) {
state.selectedIds = new Set()
if (editor.graph.getNode(snapshot.pageId)) {
state.currentPageId = snapshot.pageId
diff --git a/src/app/document/io/source.ts b/src/app/document/io/source.ts
index 5703babc7..a2d5282fe 100644
--- a/src/app/document/io/source.ts
+++ b/src/app/document/io/source.ts
@@ -1,6 +1,10 @@
import { createAutosave } from '@/app/document/autosave'
+import {
+ documentNameFromFigPath,
+ downloadNameFromPath,
+ figDownloadName
+} from '@/app/document/io/names'
import { createSaveActions } from '@/app/document/io/save'
-import { documentNameFromFigPath, downloadNameFromPath, figDownloadName } from '@/app/document/io/names'
import { createDocumentSourceState } from '@/app/document/io/source-state'
import { exportFigFile } from '@open-pencil/core/io/formats/fig'
diff --git a/src/app/editor/canvas/menu-actions.ts b/src/app/editor/canvas/menu-actions.ts
index 968b78db9..bca38f34a 100644
--- a/src/app/editor/canvas/menu-actions.ts
+++ b/src/app/editor/canvas/menu-actions.ts
@@ -1,7 +1,7 @@
import { useClipboard } from '@vueuse/core'
-import { nodeToXPath } from '@open-pencil/core/xpath'
import { toast } from '@/app/shell/ui'
+import { nodeToXPath } from '@open-pencil/core/xpath'
import type { EditorStore } from '@/app/editor/active-store'
import type { Ref } from 'vue'
diff --git a/src/app/editor/session/modules.ts b/src/app/editor/session/modules.ts
index a40aa00bb..fb04d7715 100644
--- a/src/app/editor/session/modules.ts
+++ b/src/app/editor/session/modules.ts
@@ -61,12 +61,7 @@ export function createEditorStoreModules(
const pen = createPenActions(editor, graph, state)
const vectorEdit = createVectorEditActions(editor, graph, state)
const documentIO = createDocumentIOActions(editor, state, viewportSize)
- const documentExport = createDocumentExportActions(
- editor,
- state,
- io,
- documentIO.downloadBlob
- )
+ const documentExport = createDocumentExportActions(editor, state, io, documentIO.downloadBlob)
const mobileClipboard = createMobileClipboardActions(editor, state)
const profiler = createProfilerActions(editor)
diff --git a/src/app/editor/session/types.ts b/src/app/editor/session/types.ts
index f22e52024..2b0ddc179 100644
--- a/src/app/editor/session/types.ts
+++ b/src/app/editor/session/types.ts
@@ -1,5 +1,6 @@
-import type { NodeEditState } from '@/app/editor/vector-edit/types'
import { createDefaultEditorState, type EditorState } from '@open-pencil/core/editor'
+
+import type { NodeEditState } from '@/app/editor/vector-edit/types'
import type { Fill, SceneNode, VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
import type { Vector } from '@open-pencil/core/types'
diff --git a/src/app/editor/vector-edit/types.ts b/src/app/editor/vector-edit/types.ts
index cd9298112..b04a6d400 100644
--- a/src/app/editor/vector-edit/types.ts
+++ b/src/app/editor/vector-edit/types.ts
@@ -1,5 +1,10 @@
import type { EditorState } from '@open-pencil/core/editor'
-import type { VectorNetwork, VectorRegion, VectorSegment, VectorVertex } from '@open-pencil/core/scene-graph'
+import type {
+ VectorNetwork,
+ VectorRegion,
+ VectorSegment,
+ VectorVertex
+} from '@open-pencil/core/scene-graph'
import type { Rect } from '@open-pencil/core/types'
export type NodeEditState = {
diff --git a/src/app/shell/keyboard/registry.ts b/src/app/shell/keyboard/registry.ts
index 864afe4d8..f0b52ff7e 100644
--- a/src/app/shell/keyboard/registry.ts
+++ b/src/app/shell/keyboard/registry.ts
@@ -1,15 +1,15 @@
-import { onScopeDispose } from 'vue'
import { tinykeys } from 'tinykeys'
+import { onScopeDispose } from 'vue'
import { TOOL_SHORTCUTS } from '@/app/editor/session'
import { isEditing } from '@/app/shell/keyboard/focus'
import { bindSpaceHandTool } from '@/app/shell/keyboard/space-tool'
-import type { KeyBindingMap } from 'tinykeys'
import type {
KeyboardShortcutOptions,
KeyboardShortcutRunOptions
} from '@/app/shell/keyboard/types'
+import type { KeyBindingMap } from 'tinykeys'
type ShortcutAction = (options: KeyboardShortcutRunOptions) => void
@@ -69,7 +69,11 @@ export function registerKeyboardShortcuts(options: KeyboardShortcutOptions) {
commandShortcut('create-component-set', '$mod+Shift+KeyK', 'selection.createComponentSet'),
commandShortcut('toggle-visibility', '$mod+Shift+KeyH', 'selection.toggleVisibility'),
commandShortcut('toggle-lock', '$mod+Shift+KeyL', 'selection.toggleLock'),
- { id: 'export-selection-png', keys: '$mod+Shift+KeyE', run: ({ actions }) => actions.exportSelectionPng() },
+ {
+ id: 'export-selection-png',
+ keys: '$mod+Shift+KeyE',
+ run: ({ actions }) => actions.exportSelectionPng()
+ },
{ id: 'save-as', keys: '$mod+Shift+KeyS', run: ({ store }) => void store.saveFigFileAs() },
commandShortcut('ungroup', '$mod+Shift+KeyG', 'selection.ungroup'),
commandShortcut('redo-shift', '$mod+Shift+KeyZ', 'edit.redo'),
@@ -89,7 +93,11 @@ export function registerKeyboardShortcuts(options: KeyboardShortcutOptions) {
commandShortcut('group', '$mod+KeyG', 'selection.group'),
commandShortcut('zoom-fit-shift', 'Shift+Digit1', 'view.zoomFit'),
commandShortcut('zoom-selection-shift', 'Shift+Digit2', 'view.zoomSelection'),
- { id: 'toggle-auto-layout', keys: 'Shift+KeyA', run: ({ actions }) => actions.toggleAutoLayout() },
+ {
+ id: 'toggle-auto-layout',
+ keys: 'Shift+KeyA',
+ run: ({ actions }) => actions.toggleAutoLayout()
+ },
commandShortcut('bring-to-front', 'BracketRight', 'selection.bringToFront'),
commandShortcut('send-to-back', 'BracketLeft', 'selection.sendToBack'),
{ id: 'delete-backspace', keys: 'Backspace', run: ({ actions }) => actions.smartDelete(false) },
@@ -109,15 +117,18 @@ export function registerKeyboardShortcuts(options: KeyboardShortcutOptions) {
})
}
- const unsubscribe = tinykeys(window, Object.fromEntries(
- Object.entries(bindings).map(([keys, handler]) => [
- keys,
- (event: KeyboardEvent) => {
- if (shouldIgnoreShortcut(event, options)) return
- handler(event)
- }
- ])
- ))
+ const unsubscribe = tinykeys(
+ window,
+ Object.fromEntries(
+ Object.entries(bindings).map(([keys, handler]) => [
+ keys,
+ (event: KeyboardEvent) => {
+ if (shouldIgnoreShortcut(event, options)) return
+ handler(event)
+ }
+ ])
+ )
+ )
onScopeDispose(unsubscribe)
}
diff --git a/src/app/shell/menu/document-name.ts b/src/app/shell/menu/document-name.ts
index a18620852..32278e316 100644
--- a/src/app/shell/menu/document-name.ts
+++ b/src/app/shell/menu/document-name.ts
@@ -1,4 +1,5 @@
import { computed } from 'vue'
+
import { useInlineRename } from '@open-pencil/vue'
import type { EditorStore } from '@/app/editor/active-store'
diff --git a/src/app/shell/ui.ts b/src/app/shell/ui.ts
index 0a8357c40..5ec374f32 100644
--- a/src/app/shell/ui.ts
+++ b/src/app/shell/ui.ts
@@ -1,5 +1,6 @@
import { useEventListener } from '@vueuse/core'
import { ref } from 'vue'
+
import { IS_TAURI } from '@open-pencil/core/constants'
export type ToastVariant = 'default' | 'warning' | 'error'
diff --git a/src/components/SafariBanner.vue b/src/components/SafariBanner.vue
index 50447acc1..49b0b587f 100644
--- a/src/components/SafariBanner.vue
+++ b/src/components/SafariBanner.vue
@@ -16,8 +16,10 @@ const show = !IS_TAURI && IS_BROWSER && !window.showSaveFilePicker
<span class="flex-1">
Your browser doesn't support the local file API. Files will be downloaded instead of saved in
place.
- <a href="https://www.google.com/chrome/" target="_blank" class="font-medium underline">Use Chrome</a> or
- Edge for full support.
+ <a href="https://www.google.com/chrome/" target="_blank" class="font-medium underline"
+ >Use Chrome</a
+ >
+ or Edge for full support.
</span>
<button
data-test-id="safari-banner-dismiss"
diff --git a/src/components/properties/fill-okhcl.ts b/src/components/properties/fill-okhcl.ts
index 7a46e1944..13a4907c1 100644
--- a/src/components/properties/fill-okhcl.ts
+++ b/src/components/properties/fill-okhcl.ts
@@ -16,7 +16,8 @@ export function createFillOkhclAdapter(
fieldOptions: okhcl.fieldOptions,
okhcl: okhcl.getFillOkHCLColor(activeNode, index),
...okhcl.getFillPreviewInfo(activeNode, index),
- setFieldFormat: (format: FillFieldFormat) => okhcl.setFillFieldFormat(activeNode, index, format),
+ setFieldFormat: (format: FillFieldFormat) =>
+ okhcl.setFillFieldFormat(activeNode, index, format),
updateOkHCL: (value: OkhclValue) => okhcl.updateFillOkHCL(activeNode, index, value)
}
}
diff --git a/src/main.ts b/src/main.ts
index 1fd918562..8bfd6d269 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,8 +2,8 @@ import { createHead } from '@unhead/vue/client'
import { createApp } from 'vue'
import './app.css'
-import { IS_TAURI } from '@/constants'
import { preloadFonts } from '@/app/editor/fonts'
+import { IS_TAURI } from '@/constants'
import App from './App.vue'
import router from './router'
diff --git a/tests/e2e/canvas-manipulation.spec.ts b/tests/e2e/canvas-manipulation.spec.ts
index 2f90c6363..6933c71a1 100644
--- a/tests/e2e/canvas-manipulation.spec.ts
+++ b/tests/e2e/canvas-manipulation.spec.ts
@@ -97,7 +97,7 @@ test('resize corner handle drag increases node dimensions', async () => {
const panY = store.state.panY
return {
handleX: (abs.x + n.width) * zoom + panX,
- handleY: (abs.y + n.height) * zoom + panY,
+ handleY: (abs.y + n.height) * zoom + panY
}
})
expect(viewport).not.toBeNull()
@@ -230,7 +230,7 @@ async function setupFrameChild(rotation: number) {
hitX: cx + dx * Math.cos(rad) - dy * Math.sin(rad),
hitY: cy + dx * Math.sin(rad) + dy * Math.cos(rad),
missX: frameX + 20,
- missY: frameY + 20,
+ missY: frameY + 20
}
})
@@ -274,7 +274,7 @@ test('rotated frame children keep correct hover and click hit area', async () =>
canvas.assertNoErrors()
})
- test('rotation drag exposes live rotation preview state', async () => {
+test('rotation drag exposes live rotation preview state', async () => {
await canvas.clearCanvas()
await canvas.drawRect(200, 200, 100, 100)
await canvas.click(250, 250)
@@ -313,7 +313,9 @@ test('rotated frame children keep correct hover and click hit area', async () =>
await page.mouse.up()
await canvas.waitForRender()
- const clearedPreview = await page.evaluate(() => window.__OPEN_PENCIL_STORE__!.state.rotationPreview)
+ const clearedPreview = await page.evaluate(
+ () => window.__OPEN_PENCIL_STORE__!.state.rotationPreview
+ )
expect(clearedPreview).toBeNull()
canvas.assertNoErrors()
})
diff --git a/tests/e2e/chat-panel.spec.ts b/tests/e2e/chat-panel.spec.ts
index 38b8013d7..84be22c31 100644
--- a/tests/e2e/chat-panel.spec.ts
+++ b/tests/e2e/chat-panel.spec.ts
@@ -34,7 +34,7 @@ async function injectMockTransport(page: Page) {
setTransport(() => ({
async sendMessages({
- messages,
+ messages
}: {
messages: Array<{ role: string; parts: Array<{ type: string; text?: string }> }>
}) {
@@ -46,7 +46,7 @@ async function injectMockTransport(page: Page) {
if (lowerText.includes('missing agent')) {
throw new Error(
- '"claude-agent-acp" is not installed. Install it with: npm i -g @agentclientprotocol/claude-agent-acp',
+ '"claude-agent-acp" is not installed. Install it with: npm i -g @agentclientprotocol/claude-agent-acp'
)
}
@@ -59,24 +59,33 @@ async function injectMockTransport(page: Page) {
controller.enqueue({
type: 'tool-input-start',
toolCallId,
- toolName: 'create_shape',
+ toolName: 'create_shape'
})
controller.enqueue({
type: 'tool-input-delta',
toolCallId,
- inputTextDelta: '{"type":"FRAME","x":100,"y":100,"width":200,"height":150,"name":"Card"}',
+ inputTextDelta:
+ '{"type":"FRAME","x":100,"y":100,"width":200,"height":150,"name":"Card"}'
})
controller.enqueue({
type: 'tool-input-available',
toolCallId,
toolName: 'create_shape',
- input: { type: 'FRAME', x: 100, y: 100, width: 200, height: 150, name: 'Card' },
+ input: { type: 'FRAME', x: 100, y: 100, width: 200, height: 150, name: 'Card' }
})
controller.enqueue({
type: 'tool-output-available',
toolCallId,
toolName: 'create_shape',
- output: { id: '0:99', type: 'FRAME', x: 100, y: 100, width: 200, height: 150, name: 'Card' },
+ output: {
+ id: '0:99',
+ type: 'FRAME',
+ x: 100,
+ y: 100,
+ width: 200,
+ height: 150,
+ name: 'Card'
+ }
})
}
@@ -91,12 +100,12 @@ async function injectMockTransport(page: Page) {
controller.enqueue({ type: 'text-end', id: 'text-1' })
controller.enqueue({ type: 'finish', finishReason: 'stop' })
controller.close()
- },
+ }
})
},
async reconnectToStream() {
return null
- },
+ }
}))
})
}
@@ -164,9 +173,9 @@ test('Enter submits message and clears input', async () => {
test('assistant responds', async () => {
if (USE_REAL_LLM) {
- await expect(
- page.locator('.chat-markdown, [class*="rounded-tl-md"]').first(),
- ).toBeVisible({ timeout: 30000 })
+ await expect(page.locator('.chat-markdown, [class*="rounded-tl-md"]').first()).toBeVisible({
+ timeout: 30000
+ })
} else {
await expect(page.getByText('mock response', { exact: false })).toBeVisible({ timeout: 5000 })
}
@@ -189,9 +198,9 @@ test('tool calls render in assistant message', async () => {
await chatInput().press('Enter')
if (USE_REAL_LLM) {
- await expect(
- page.locator('.chat-markdown, [class*="rounded-tl-md"]').first(),
- ).toBeVisible({ timeout: 30000 })
+ await expect(page.locator('.chat-markdown, [class*="rounded-tl-md"]').first()).toBeVisible({
+ timeout: 30000
+ })
} else {
await expect(page.getByText('Create Shape')).toBeVisible({ timeout: 5000 })
await expect(page.getByText('Done')).toBeVisible()
@@ -213,8 +222,8 @@ test('transport errors show an actionable toast', async () => {
await expect(
page.locator('[data-test-id="toast-item"]').filter({
- hasText: 'Install it with: npm i -g @agentclientprotocol/claude-agent-acp',
- }),
+ hasText: 'Install it with: npm i -g @agentclientprotocol/claude-agent-acp'
+ })
).toBeVisible({ timeout: 5000 })
})
diff --git a/tests/e2e/code-panel.spec.ts b/tests/e2e/code-panel.spec.ts
index cc952f13c..32dc83fb0 100644
--- a/tests/e2e/code-panel.spec.ts
+++ b/tests/e2e/code-panel.spec.ts
@@ -115,6 +115,8 @@ test('selecting a frame shows Frame in JSX', async () => {
test('switching back to Design tab works', async () => {
await designTab().click()
- const panel = page.locator('[data-test-id="design-panel-single"], [data-test-id="design-panel-empty"]')
+ const panel = page.locator(
+ '[data-test-id="design-panel-single"], [data-test-id="design-panel-empty"]'
+ )
await expect(panel.first()).toBeVisible()
})
diff --git a/tests/e2e/color-picker-demo-card.spec.ts b/tests/e2e/color-picker-demo-card.spec.ts
index 1c41b31d3..11de2ee31 100644
--- a/tests/e2e/color-picker-demo-card.spec.ts
+++ b/tests/e2e/color-picker-demo-card.spec.ts
@@ -2,7 +2,12 @@ import { expect, test } from '@playwright/test'
import { CanvasHelper } from '../helpers/canvas'
-async function dragSlider(page: Parameters<typeof test>[0]['page'], canvas: CanvasHelper, testId: string, ratio: number) {
+async function dragSlider(
+ page: Parameters<typeof test>[0]['page'],
+ canvas: CanvasHelper,
+ testId: string,
+ ratio: number
+) {
const slider = page.locator(`[data-test-id="${testId}"] input[type="range"]`)
const box = await slider.boundingBox()
if (!box) throw new Error(`Missing slider: ${testId}`)
@@ -23,9 +28,16 @@ async function selectDemoCard(page: Parameters<typeof test>[0]['page'], canvas:
await page.evaluate(() => {
const store = window.__OPEN_PENCIL_STORE__!
const nodes = Array.from(store.graph.nodes.values())
- const card = nodes.find((node) => node.name === 'Card' && node.type === 'COMPONENT')
- ?? nodes.find((node) => node.name === 'Card')
- if (!card) throw new Error(`Card not found. Available: ${nodes.slice(0, 20).map((n) => `${n.name}:${n.type}`).join(', ')}`)
+ const card =
+ nodes.find((node) => node.name === 'Card' && node.type === 'COMPONENT') ??
+ nodes.find((node) => node.name === 'Card')
+ if (!card)
+ throw new Error(
+ `Card not found. Available: ${nodes
+ .slice(0, 20)
+ .map((n) => `${n.name}:${n.type}`)
+ .join(', ')}`
+ )
store.state.selectedIds = new Set([card.id])
store.requestRender()
})
@@ -65,10 +77,13 @@ test('demo card fill changes through color picker', async ({ page }) => {
const after = await getSelectedFill(page)
expect(after).not.toBeNull()
- expect(before?.fill?.color.r !== after?.fill?.color.r || before?.fill?.color.g !== after?.fill?.color.g || before?.fill?.color.b !== after?.fill?.color.b).toBe(true)
+ expect(
+ before?.fill?.color.r !== after?.fill?.color.r ||
+ before?.fill?.color.g !== after?.fill?.color.g ||
+ before?.fill?.color.b !== after?.fill?.color.b
+ ).toBe(true)
})
-
test('demo card fill changes from hsb saturation and brightness sliders', async ({ page }) => {
const canvas = new CanvasHelper(page)
await selectDemoCard(page, canvas)
@@ -83,12 +98,20 @@ test('demo card fill changes from hsb saturation and brightness sliders', async
const afterS = await getSelectedFill(page)
expect(afterS).not.toBeNull()
- expect(beforeS?.fill?.color.r !== afterS?.fill?.color.r || beforeS?.fill?.color.g !== afterS?.fill?.color.g || beforeS?.fill?.color.b !== afterS?.fill?.color.b).toBe(true)
+ expect(
+ beforeS?.fill?.color.r !== afterS?.fill?.color.r ||
+ beforeS?.fill?.color.g !== afterS?.fill?.color.g ||
+ beforeS?.fill?.color.b !== afterS?.fill?.color.b
+ ).toBe(true)
const beforeB = await getSelectedFill(page)
await dragSlider(page, canvas, 'color-slider-hsb-b', 0.25)
const afterB = await getSelectedFill(page)
expect(afterB).not.toBeNull()
- expect(beforeB?.fill?.color.r !== afterB?.fill?.color.r || beforeB?.fill?.color.g !== afterB?.fill?.color.g || beforeB?.fill?.color.b !== afterB?.fill?.color.b).toBe(true)
+ expect(
+ beforeB?.fill?.color.r !== afterB?.fill?.color.r ||
+ beforeB?.fill?.color.g !== afterB?.fill?.color.g ||
+ beforeB?.fill?.color.b !== afterB?.fill?.color.b
+ ).toBe(true)
})
diff --git a/tests/e2e/color-picker.spec.ts b/tests/e2e/color-picker.spec.ts
index 22a3a2d44..4a09dceda 100644
--- a/tests/e2e/color-picker.spec.ts
+++ b/tests/e2e/color-picker.spec.ts
@@ -73,7 +73,11 @@ test('rgb hue slider updates selected fill color', async () => {
const after = await getSelectedFill()
expect(after).not.toBeNull()
- expect(before?.color.r !== after?.color.r || before?.color.g !== after?.color.g || before?.color.b !== after?.color.b).toBe(true)
+ expect(
+ before?.color.r !== after?.color.r ||
+ before?.color.g !== after?.color.g ||
+ before?.color.b !== after?.color.b
+ ).toBe(true)
})
test('rgb alpha slider updates fill opacity and alpha', async () => {
@@ -94,7 +98,11 @@ test('hsl saturation slider changes saturation', async () => {
const after = await getSelectedFill()
expect(after).not.toBeNull()
- expect(before?.color.r !== after?.color.r || before?.color.g !== after?.color.g || before?.color.b !== after?.color.b).toBe(true)
+ expect(
+ before?.color.r !== after?.color.r ||
+ before?.color.g !== after?.color.g ||
+ before?.color.b !== after?.color.b
+ ).toBe(true)
})
test('hsl lightness slider changes color independently', async () => {
@@ -105,7 +113,11 @@ test('hsl lightness slider changes color independently', async () => {
const after = await getSelectedFill()
expect(after).not.toBeNull()
- expect(before?.color.r !== after?.color.r || before?.color.g !== after?.color.g || before?.color.b !== after?.color.b).toBe(true)
+ expect(
+ before?.color.r !== after?.color.r ||
+ before?.color.g !== after?.color.g ||
+ before?.color.b !== after?.color.b
+ ).toBe(true)
})
test('hsb saturation and brightness sliders both affect fill color', async () => {
@@ -116,11 +128,19 @@ test('hsb saturation and brightness sliders both affect fill color', async () =>
await dragSlider('color-slider-hsb-s', 0.15)
const afterS = await getSelectedFill()
expect(afterS).not.toBeNull()
- expect(beforeS?.color.r !== afterS?.color.r || beforeS?.color.g !== afterS?.color.g || beforeS?.color.b !== afterS?.color.b).toBe(true)
+ expect(
+ beforeS?.color.r !== afterS?.color.r ||
+ beforeS?.color.g !== afterS?.color.g ||
+ beforeS?.color.b !== afterS?.color.b
+ ).toBe(true)
const beforeB = await getSelectedFill()
await dragSlider('color-slider-hsb-b', 0.9)
const afterB = await getSelectedFill()
expect(afterB).not.toBeNull()
- expect(beforeB?.color.r !== afterB?.color.r || beforeB?.color.g !== afterB?.color.g || beforeB?.color.b !== afterB?.color.b).toBe(true)
+ expect(
+ beforeB?.color.r !== afterB?.color.r ||
+ beforeB?.color.g !== afterB?.color.g ||
+ beforeB?.color.b !== afterB?.color.b
+ ).toBe(true)
})
diff --git a/tests/e2e/components.spec.ts b/tests/e2e/components.spec.ts
index 2d2b452b4..683d5e1ae 100644
--- a/tests/e2e/components.spec.ts
+++ b/tests/e2e/components.spec.ts
@@ -128,9 +128,21 @@ test('modifying component propagates to instance', async () => {
// Change component fill
await page.evaluate((id) => {
const store = window.__OPEN_PENCIL_STORE__!
- store.updateNodeWithUndo(id, {
- fills: [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' }]
- }, 'Change fill')
+ store.updateNodeWithUndo(
+ id,
+ {
+ fills: [
+ {
+ type: 'SOLID',
+ color: { r: 1, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ]
+ },
+ 'Change fill'
+ )
}, componentId)
await canvas.waitForRender()
diff --git a/tests/e2e/copy-paste.spec.ts b/tests/e2e/copy-paste.spec.ts
index b71b04e5f..5daa619d4 100644
--- a/tests/e2e/copy-paste.spec.ts
+++ b/tests/e2e/copy-paste.spec.ts
@@ -34,7 +34,16 @@ function getSelectedNodes() {
const store = window.__OPEN_PENCIL_STORE__!
return [...store.state.selectedIds].map((id) => {
const n = store.graph.getNode(id)!
- return { id: n.id, name: n.name, type: n.type, x: n.x, y: n.y, width: n.width, height: n.height, fills: n.fills }
+ return {
+ id: n.id,
+ name: n.name,
+ type: n.type,
+ x: n.x,
+ y: n.y,
+ width: n.width,
+ height: n.height,
+ fills: n.fills
+ }
})
})
}
@@ -85,9 +94,21 @@ test('duplicate preserves fills', async () => {
await page.evaluate(() => {
const store = window.__OPEN_PENCIL_STORE__!
const id = [...store.state.selectedIds][0]
- store.updateNodeWithUndo(id, {
- fills: [{ type: 'SOLID', color: { r: 0, g: 0.5, b: 1, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' }]
- }, 'Set fill')
+ store.updateNodeWithUndo(
+ id,
+ {
+ fills: [
+ {
+ type: 'SOLID',
+ color: { r: 0, g: 0.5, b: 1, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ]
+ },
+ 'Set fill'
+ )
})
await canvas.waitForRender()
diff --git a/tests/e2e/corner-stroke-toggles.spec.ts b/tests/e2e/corner-stroke-toggles.spec.ts
index a9dd5128a..6f4be97ce 100644
--- a/tests/e2e/corner-stroke-toggles.spec.ts
+++ b/tests/e2e/corner-stroke-toggles.spec.ts
@@ -76,17 +76,23 @@ test('stroke sides toggle shows per-side weight inputs', async () => {
const toggle = page.locator('[data-test-id="stroke-sides-toggle"]')
await expect(toggle).toBeVisible({ timeout: 5000 })
- const sectionInputsBefore = await page.locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]').count()
+ const sectionInputsBefore = await page
+ .locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]')
+ .count()
await toggle.click()
await canvas.waitForRender()
- const sectionInputsAfter = await page.locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]').count()
+ const sectionInputsAfter = await page
+ .locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]')
+ .count()
expect(sectionInputsAfter).toBeGreaterThan(sectionInputsBefore)
await toggle.click()
await canvas.waitForRender()
- const sectionInputsFinal = await page.locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]').count()
+ const sectionInputsFinal = await page
+ .locator('[data-test-id="stroke-section"] [data-test-id="scrub-input"]')
+ .count()
expect(sectionInputsFinal).toBe(sectionInputsBefore)
})
diff --git a/tests/e2e/design-panel.spec.ts b/tests/e2e/design-panel.spec.ts
index c460125e2..4e8c511b4 100644
--- a/tests/e2e/design-panel.spec.ts
+++ b/tests/e2e/design-panel.spec.ts
@@ -47,7 +47,18 @@ function getNode(id: string) {
const store = window.__OPEN_PENCIL_STORE__!
const n = store.graph.getNode(nodeId)
if (!n) return null
- return { fills: n.fills, strokes: n.strokes, effects: n.effects, opacity: n.opacity, visible: n.visible, x: n.x, y: n.y, width: n.width, height: n.height, rotation: n.rotation }
+ return {
+ fills: n.fills,
+ strokes: n.strokes,
+ effects: n.effects,
+ opacity: n.opacity,
+ visible: n.visible,
+ x: n.x,
+ y: n.y,
+ width: n.width,
+ height: n.height,
+ rotation: n.rotation
+ }
}, id)
}
diff --git a/tests/e2e/effects.spec.ts b/tests/e2e/effects.spec.ts
index 90931734e..bed090d88 100644
--- a/tests/e2e/effects.spec.ts
+++ b/tests/e2e/effects.spec.ts
@@ -99,7 +99,9 @@ test('inner shadow', async () => {
width: 200,
height: 120,
cornerRadius: 12,
- fills: [{ type: 'SOLID', color: { r: 0.96, g: 0.96, b: 0.97, a: 1 }, visible: true, opacity: 1 }],
+ fills: [
+ { type: 'SOLID', color: { r: 0.96, g: 0.96, b: 0.97, a: 1 }, visible: true, opacity: 1 }
+ ],
effects: [
{
type: 'INNER_SHADOW',
@@ -129,7 +131,9 @@ test('inner shadow with spread', async () => {
width: 200,
height: 120,
cornerRadius: 12,
- fills: [{ type: 'SOLID', color: { r: 0.96, g: 0.96, b: 0.97, a: 1 }, visible: true, opacity: 1 }],
+ fills: [
+ { type: 'SOLID', color: { r: 0.96, g: 0.96, b: 0.97, a: 1 }, visible: true, opacity: 1 }
+ ],
effects: [
{
type: 'INNER_SHADOW',
@@ -158,7 +162,9 @@ test('drop shadow on ellipse', async () => {
y: 80,
width: 160,
height: 160,
- fills: [{ type: 'SOLID', color: { r: 0.38, g: 0.35, b: 0.95, a: 1 }, visible: true, opacity: 1 }],
+ fills: [
+ { type: 'SOLID', color: { r: 0.38, g: 0.35, b: 0.95, a: 1 }, visible: true, opacity: 1 }
+ ],
effects: [
{
type: 'DROP_SHADOW',
@@ -261,7 +267,9 @@ test('layer blur', async () => {
width: 200,
height: 120,
cornerRadius: 12,
- fills: [{ type: 'SOLID', color: { r: 0.23, g: 0.51, b: 0.96, a: 1 }, visible: true, opacity: 1 }],
+ fills: [
+ { type: 'SOLID', color: { r: 0.23, g: 0.51, b: 0.96, a: 1 }, visible: true, opacity: 1 }
+ ],
effects: [
{
type: 'LAYER_BLUR',
diff --git a/tests/e2e/layers-panel.spec.ts b/tests/e2e/layers-panel.spec.ts
index 44b1e8d06..e88b51c1f 100644
--- a/tests/e2e/layers-panel.spec.ts
+++ b/tests/e2e/layers-panel.spec.ts
@@ -44,7 +44,7 @@ async function getSceneTree() {
return {
name: node.name,
type: node.type,
- children: node.childIds.map((cid: string) => nodeTree(cid)).filter(Boolean),
+ children: node.childIds.map((cid: string) => nodeTree(cid)).filter(Boolean)
}
}
return nodeTree(store.state.currentPageId)
diff --git a/tests/e2e/perf.spec.ts b/tests/e2e/perf.spec.ts
index 43ded5416..48effef0a 100644
--- a/tests/e2e/perf.spec.ts
+++ b/tests/e2e/perf.spec.ts
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
+
import { CanvasHelper } from '../helpers/canvas'
const NODE_COUNT = 500
@@ -22,7 +23,11 @@ test.describe('Render performance', () => {
const mod = i % 10
const isVector = mod === 0
const isEllipse = mod === 5
- const type = isVector ? ('VECTOR' as const) : isEllipse ? ('ELLIPSE' as const) : ('RECTANGLE' as const)
+ const type = isVector
+ ? ('VECTOR' as const)
+ : isEllipse
+ ? ('ELLIPSE' as const)
+ : ('RECTANGLE' as const)
const props: Record<string, unknown> = {
x: (i % cols) * 60,
y: Math.floor(i / cols) * 60,
@@ -43,7 +48,13 @@ test.describe('Render performance', () => {
}
],
strokes: [
- { type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, visible: true, opacity: 1, weight: 1 }
+ {
+ type: 'SOLID',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ visible: true,
+ opacity: 1,
+ weight: 1
+ }
]
}
if (isVector) {
@@ -133,9 +144,18 @@ test.describe('Render performance', () => {
const hoverMs = performance.now() - hoverStart
return {
- pan: { ms: Math.round(panMs * 100) / 100, avg: Math.round((panMs / iterations) * 100) / 100 },
- scene: { ms: Math.round(sceneMs * 100) / 100, avg: Math.round((sceneMs / iterations) * 100) / 100 },
- hover: { ms: Math.round(hoverMs * 100) / 100, avg: Math.round((hoverMs / iterations) * 100) / 100 }
+ pan: {
+ ms: Math.round(panMs * 100) / 100,
+ avg: Math.round((panMs / iterations) * 100) / 100
+ },
+ scene: {
+ ms: Math.round(sceneMs * 100) / 100,
+ avg: Math.round((sceneMs / iterations) * 100) / 100
+ },
+ hover: {
+ ms: Math.round(hoverMs * 100) / 100,
+ avg: Math.round((hoverMs / iterations) * 100) / 100
+ }
}
}, ITERATIONS)
@@ -169,7 +189,9 @@ test.describe('Render performance', () => {
width: 60,
height: 60,
cornerRadius: 8,
- fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, visible: true, opacity: 1 }],
+ fills: [
+ { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, visible: true, opacity: 1 }
+ ],
effects: [
{
type: 'DROP_SHADOW',
@@ -224,9 +246,7 @@ test.describe('Render performance', () => {
console.log(
`\n═══ SHADOW BENCHMARK (${SHADOW_NODES} shadow nodes, ${SHADOW_ITERS} iterations) ═══`
)
- console.log(
- ` Scene change: ${results.scene.avg}ms/frame (${results.scene.ms}ms total)`
- )
+ console.log(` Scene change: ${results.scene.avg}ms/frame (${results.scene.ms}ms total)`)
console.log(`═══════════════════════════════════════════════════════\n`)
expect(results.scene.avg).toBeLessThan(50)
diff --git a/tests/e2e/properties-panel.spec.ts b/tests/e2e/properties-panel.spec.ts
index 2910ff06c..eb1a3dbe9 100644
--- a/tests/e2e/properties-panel.spec.ts
+++ b/tests/e2e/properties-panel.spec.ts
@@ -26,7 +26,9 @@ test('ScrubInput drag changes X position', async () => {
expect(before).not.toBeNull()
const initialX = before!.x
- const xScrub = page.locator('[data-test-id="position-section"] [data-test-id="scrub-input"]').first()
+ const xScrub = page
+ .locator('[data-test-id="position-section"] [data-test-id="scrub-input"]')
+ .first()
await canvas.dragScrubInput(xScrub, 50)
const after = await getSelectedNode(page)
@@ -41,7 +43,9 @@ test('corner radius uniform sets cornerRadius', async () => {
const scrubContainer = page.locator('[data-test-id="corner-radius-input"]')
await scrubContainer.click()
await canvas.waitForRender()
- const input = page.locator('[data-test-id="corner-radius-input"] [data-test-id="scrub-input-field"]')
+ const input = page.locator(
+ '[data-test-id="corner-radius-input"] [data-test-id="scrub-input-field"]'
+ )
await input.fill('12')
await input.press('Enter')
await canvas.waitForRender()
diff --git a/tests/e2e/scene-cache.spec.ts b/tests/e2e/scene-cache.spec.ts
index 9226fc686..8aca54074 100644
--- a/tests/e2e/scene-cache.spec.ts
+++ b/tests/e2e/scene-cache.spec.ts
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
+
import { CanvasHelper } from '../helpers/canvas'
test.describe('SkPicture scene caching', () => {
@@ -20,7 +21,9 @@ test.describe('SkPicture scene caching', () => {
y: 50,
width: 300,
height: 200,
- fills: [{ type: 'SOLID', color: { r: 0.95, g: 0.95, b: 0.95, a: 1 }, visible: true, opacity: 1 }]
+ fills: [
+ { type: 'SOLID', color: { r: 0.95, g: 0.95, b: 0.95, a: 1 }, visible: true, opacity: 1 }
+ ]
})
store.graph.createNode('TEXT', pageId, {
@@ -45,7 +48,9 @@ test.describe('SkPicture scene caching', () => {
text: 'This text must survive hover transitions without disappearing.',
fontSize: 14,
fontFamily: 'Inter',
- fills: [{ type: 'SOLID', color: { r: 0.3, g: 0.3, b: 0.3, a: 1 }, visible: true, opacity: 1 }]
+ fills: [
+ { type: 'SOLID', color: { r: 0.3, g: 0.3, b: 0.3, a: 1 }, visible: true, opacity: 1 }
+ ]
})
store.requestRender()
diff --git a/tests/e2e/section-tool.spec.ts b/tests/e2e/section-tool.spec.ts
index 448efe609..e7ea76339 100644
--- a/tests/e2e/section-tool.spec.ts
+++ b/tests/e2e/section-tool.spec.ts
@@ -26,13 +26,15 @@ test('draw section in full editor without browser errors', async () => {
await canvas.drawSection(100, 100, 240, 160)
await expect(page.locator('[data-test-id="design-node-header"]')).toContainText('SECTION')
- await expect.poll(async () => {
- return page.evaluate(() => {
- const store = window.__OPEN_PENCIL_STORE__
- const selectedId = [...store.state.selectedIds][0]
- return selectedId ? store.graph.getNode(selectedId)?.type : null
+ await expect
+ .poll(async () => {
+ return page.evaluate(() => {
+ const store = window.__OPEN_PENCIL_STORE__
+ const selectedId = [...store.state.selectedIds][0]
+ return selectedId ? store.graph.getNode(selectedId)?.type : null
+ })
})
- }).toBe('SECTION')
+ .toBe('SECTION')
canvas.assertNoErrors()
})
diff --git a/tests/e2e/stroke-picker.spec.ts b/tests/e2e/stroke-picker.spec.ts
index c84ed94a2..0ad8eda4d 100644
--- a/tests/e2e/stroke-picker.spec.ts
+++ b/tests/e2e/stroke-picker.spec.ts
@@ -17,7 +17,10 @@ async function dragSlider(page: Page, canvas: CanvasHelper, testId: string, rati
}
async function openStrokePicker(page: Page) {
- await page.locator('[data-test-id="stroke-item"] [data-test-id="color-picker-popover"]').waitFor({ state: 'detached' }).catch(() => {})
+ await page
+ .locator('[data-test-id="stroke-item"] [data-test-id="color-picker-popover"]')
+ .waitFor({ state: 'detached' })
+ .catch(() => {})
await page.locator('[data-test-id="stroke-item"] button').first().click()
await expect(page.locator('[data-test-id="color-picker-popover"]')).toBeVisible()
}
@@ -51,7 +54,11 @@ test('stroke picker updates stroke color on a rectangle', async ({ page }) => {
const after = await getSelectedStroke(page)
expect(after).not.toBeNull()
- expect(before?.color.r !== after?.color.r || before?.color.g !== after?.color.g || before?.color.b !== after?.color.b).toBe(true)
+ expect(
+ before?.color.r !== after?.color.r ||
+ before?.color.g !== after?.color.g ||
+ before?.color.b !== after?.color.b
+ ).toBe(true)
})
test('stroke picker alpha slider updates stroke opacity and alpha', async ({ page }) => {
@@ -72,7 +79,9 @@ test('stroke picker alpha slider updates stroke opacity and alpha', async ({ pag
expect(after?.color.a).toBeCloseTo(after?.opacity ?? 0, 3)
})
-test('stroke picker hsb saturation and brightness sliders update stroke color on demo card', async ({ page }) => {
+test('stroke picker hsb saturation and brightness sliders update stroke color on demo card', async ({
+ page
+}) => {
const canvas = new CanvasHelper(page)
await page.goto('/demo')
await canvas.waitForInit()
@@ -80,10 +89,17 @@ test('stroke picker hsb saturation and brightness sliders update stroke color on
await page.evaluate(() => {
const store = window.__OPEN_PENCIL_STORE__!
const nodes = Array.from(store.graph.nodes.values())
- const card = nodes.find((node) => node.name === 'Card' && node.type === 'COMPONENT')
- ?? nodes.find((node) => node.name === 'Card')
+ const card =
+ nodes.find((node) => node.name === 'Card' && node.type === 'COMPONENT') ??
+ nodes.find((node) => node.name === 'Card')
if (!card) throw new Error('Card not found')
- const stroke = { color: { r: 0.9, g: 0.9, b: 0.92, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }
+ const stroke = {
+ color: { r: 0.9, g: 0.9, b: 0.92, a: 1 },
+ weight: 1,
+ opacity: 1,
+ visible: true,
+ align: 'INSIDE'
+ }
store.updateNodeWithUndo(card.id, { strokes: [stroke] }, 'Add demo card stroke')
store.state.selectedIds = new Set([card.id])
store.requestRender()
@@ -98,11 +114,19 @@ test('stroke picker hsb saturation and brightness sliders update stroke color on
await dragSlider(page, canvas, 'color-slider-hsb-s', 0.6)
const afterS = await getSelectedStroke(page)
expect(afterS).not.toBeNull()
- expect(beforeS?.color.r !== afterS?.color.r || beforeS?.color.g !== afterS?.color.g || beforeS?.color.b !== afterS?.color.b).toBe(true)
+ expect(
+ beforeS?.color.r !== afterS?.color.r ||
+ beforeS?.color.g !== afterS?.color.g ||
+ beforeS?.color.b !== afterS?.color.b
+ ).toBe(true)
const beforeB = await getSelectedStroke(page)
await dragSlider(page, canvas, 'color-slider-hsb-b', 0.2)
const afterB = await getSelectedStroke(page)
expect(afterB).not.toBeNull()
- expect(beforeB?.color.r !== afterB?.color.r || beforeB?.color.g !== afterB?.color.g || beforeB?.color.b !== afterB?.color.b).toBe(true)
+ expect(
+ beforeB?.color.r !== afterB?.color.r ||
+ beforeB?.color.g !== afterB?.color.g ||
+ beforeB?.color.b !== afterB?.color.b
+ ).toBe(true)
})
diff --git a/tests/e2e/toolbar.spec.ts b/tests/e2e/toolbar.spec.ts
index 2499ea987..346a57986 100644
--- a/tests/e2e/toolbar.spec.ts
+++ b/tests/e2e/toolbar.spec.ts
@@ -31,7 +31,7 @@ test('Polygon tool creates POLYGON node', async () => {
await canvas.waitForRender()
const children = await getPageChildren(page)
- expect(children.some(n => n.type === 'POLYGON')).toBe(true)
+ expect(children.some((n) => n.type === 'POLYGON')).toBe(true)
canvas.assertNoErrors()
})
@@ -42,7 +42,7 @@ test('Star tool creates STAR node', async () => {
await canvas.waitForRender()
const children = await getPageChildren(page)
- expect(children.some(n => n.type === 'STAR')).toBe(true)
+ expect(children.some((n) => n.type === 'STAR')).toBe(true)
canvas.assertNoErrors()
})
@@ -59,7 +59,7 @@ test('Pen creates VECTOR node with 3 vertices on Enter', async () => {
await canvas.waitForRender()
const children = await getPageChildren(page)
- const vectors = children.filter(n => n.type === 'VECTOR')
+ const vectors = children.filter((n) => n.type === 'VECTOR')
expect(vectors.length).toBeGreaterThan(0)
const last = vectors[vectors.length - 1]
expect(last.vectorNetwork.vertices.length).toBe(3)
@@ -67,7 +67,7 @@ test('Pen creates VECTOR node with 3 vertices on Enter', async () => {
})
test('Pen Escape with 2 vertices cancels path without creating node', async () => {
- const before = (await getPageChildren(page)).filter(n => n.type === 'VECTOR').length
+ const before = (await getPageChildren(page)).filter((n) => n.type === 'VECTOR').length
await canvas.pressKey('p')
await canvas.click(350, 400)
@@ -77,13 +77,13 @@ test('Pen Escape with 2 vertices cancels path without creating node', async () =
await canvas.pressKey('Escape')
await canvas.waitForRender()
- const after = (await getPageChildren(page)).filter(n => n.type === 'VECTOR').length
+ const after = (await getPageChildren(page)).filter((n) => n.type === 'VECTOR').length
expect(after).toBe(before)
canvas.assertNoErrors()
})
test('Pen close path creates VECTOR with closed region', async () => {
- const before = (await getPageChildren(page)).filter(n => n.type === 'VECTOR').length
+ const before = (await getPageChildren(page)).filter((n) => n.type === 'VECTOR').length
await canvas.pressKey('p')
await canvas.click(500, 200)
@@ -95,10 +95,10 @@ test('Pen close path creates VECTOR with closed region', async () => {
await canvas.click(500, 200)
await canvas.waitForRender()
- const after = (await getPageChildren(page)).filter(n => n.type === 'VECTOR').length
+ const after = (await getPageChildren(page)).filter((n) => n.type === 'VECTOR').length
expect(after).toBeGreaterThan(before)
- const vectors = (await getPageChildren(page)).filter(n => n.type === 'VECTOR')
+ const vectors = (await getPageChildren(page)).filter((n) => n.type === 'VECTOR')
const last = vectors[vectors.length - 1]
expect(last.vectorNetwork.regions?.length).toBeGreaterThan(0)
canvas.assertNoErrors()
diff --git a/tests/e2e/variables-dialog.spec.ts b/tests/e2e/variables-dialog.spec.ts
index 37c46b8ab..8b2ca2003 100644
--- a/tests/e2e/variables-dialog.spec.ts
+++ b/tests/e2e/variables-dialog.spec.ts
@@ -79,7 +79,10 @@ test('color swatch opens color picker', async () => {
await page.locator('[data-test-id="variables-section-open"]').click()
await expect(page.locator('[data-test-id="variables-dialog"]')).toBeVisible({ timeout: 3000 })
- const swatch = page.locator('[data-test-id="variable-row"]').first().locator('[data-test-id="color-picker-swatch"]')
+ const swatch = page
+ .locator('[data-test-id="variable-row"]')
+ .first()
+ .locator('[data-test-id="color-picker-swatch"]')
await expect(swatch).toBeVisible({ timeout: 3000 })
await swatch.click()
await expect(page.locator('[data-test-id="color-picker-popover"]')).toBeVisible({ timeout: 5000 })
diff --git a/tests/e2e/zoom-pan.spec.ts b/tests/e2e/zoom-pan.spec.ts
index a5674fb0a..00b9f372d 100644
--- a/tests/e2e/zoom-pan.spec.ts
+++ b/tests/e2e/zoom-pan.spec.ts
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
+
import { CanvasHelper } from '../helpers/canvas'
const NODE_COUNT = 200
@@ -21,7 +22,9 @@ test.describe('Zoom and pan', () => {
y: Math.floor(i / cols) * 60,
width: 50,
height: 50,
- fills: [{ type: 'SOLID', color: { r: 0.5, g: 0.5, b: 0.8, a: 1 }, visible: true, opacity: 1 }]
+ fills: [
+ { type: 'SOLID', color: { r: 0.5, g: 0.5, b: 0.8, a: 1 }, visible: true, opacity: 1 }
+ ]
})
}
store.requestRender()
@@ -181,7 +184,9 @@ test.describe('Zoom and pan', () => {
const pageNode = store.graph.getNode(store.state.currentPageId)!
const firstId = pageNode.childIds[0]
store.graph.updateNode(firstId, {
- fills: [{ type: 'SOLID', color: { r: 0.5, g: 0.5, b: 0.8, a: 1 }, visible: true, opacity: 1 }]
+ fills: [
+ { type: 'SOLID', color: { r: 0.5, g: 0.5, b: 0.8, a: 1 }, visible: true, opacity: 1 }
+ ]
})
store.requestRender()
})
@@ -263,9 +268,18 @@ test.describe('Zoom and pan', () => {
const wheelMs = performance.now() - wheelStart
return {
- zoom: { ms: Math.round(zoomMs * 100) / 100, avg: Math.round((zoomMs / iterations) * 1000) / 1000 },
- pan: { ms: Math.round(panMs * 100) / 100, avg: Math.round((panMs / iterations) * 1000) / 1000 },
- wheel: { ms: Math.round(wheelMs * 100) / 100, avg: Math.round((wheelMs / iterations) * 1000) / 1000 }
+ zoom: {
+ ms: Math.round(zoomMs * 100) / 100,
+ avg: Math.round((zoomMs / iterations) * 1000) / 1000
+ },
+ pan: {
+ ms: Math.round(panMs * 100) / 100,
+ avg: Math.round((panMs / iterations) * 1000) / 1000
+ },
+ wheel: {
+ ms: Math.round(wheelMs * 100) / 100,
+ avg: Math.round((wheelMs / iterations) * 1000) / 1000
+ }
}
}, ITERATIONS)
diff --git a/tests/engine/acp-transport.test.ts b/tests/engine/acp-transport.test.ts
index 4327dc1d2..13d91b34f 100644
--- a/tests/engine/acp-transport.test.ts
+++ b/tests/engine/acp-transport.test.ts
@@ -38,9 +38,7 @@ describe('mapUpdate', () => {
}
const result = mapUpdate(update, TEXT_ID, true)
expect(result.textStarted).toBe(true)
- expect(result.chunks).toEqual([
- { type: 'text-delta', id: TEXT_ID, delta: 'world' }
- ])
+ expect(result.chunks).toEqual([{ type: 'text-delta', id: TEXT_ID, delta: 'world' }])
})
test('agent_thought_chunk emits reasoning start/delta/end', () => {
@@ -68,13 +66,15 @@ describe('mapUpdate', () => {
status: 'pending'
}
const result = mapUpdate(update, TEXT_ID, false)
- expect(result.chunks).toEqual([{
- type: 'tool-input-start',
- toolCallId: 'tc-1',
- toolName: 'create_shape',
- providerExecuted: true,
- title: 'create_shape'
- }])
+ expect(result.chunks).toEqual([
+ {
+ type: 'tool-input-start',
+ toolCallId: 'tc-1',
+ toolName: 'create_shape',
+ providerExecuted: true,
+ title: 'create_shape'
+ }
+ ])
})
test('tool_call with rawInput emits tool-input-available', () => {
@@ -118,12 +118,14 @@ describe('mapUpdate', () => {
rawOutput: { id: '1:5', type: 'RECTANGLE' }
}
const result = mapUpdate(update, TEXT_ID, false)
- expect(result.chunks).toEqual([{
- type: 'tool-output-available',
- toolCallId: 'tc-1',
- output: { id: '1:5', type: 'RECTANGLE' },
- providerExecuted: true
- }])
+ expect(result.chunks).toEqual([
+ {
+ type: 'tool-output-available',
+ toolCallId: 'tc-1',
+ output: { id: '1:5', type: 'RECTANGLE' },
+ providerExecuted: true
+ }
+ ])
})
test('tool_call_update failed emits tool-output-error', () => {
@@ -134,12 +136,14 @@ describe('mapUpdate', () => {
content: [{ type: 'content', content: { type: 'text', text: 'Node not found' } }]
}
const result = mapUpdate(update, TEXT_ID, false)
- expect(result.chunks).toEqual([{
- type: 'tool-output-error',
- toolCallId: 'tc-1',
- errorText: 'Node not found',
- providerExecuted: true
- }])
+ expect(result.chunks).toEqual([
+ {
+ type: 'tool-output-error',
+ toolCallId: 'tc-1',
+ errorText: 'Node not found',
+ providerExecuted: true
+ }
+ ])
})
test('agent_message_chunk with non-text content produces no chunks', () => {
@@ -226,6 +230,9 @@ describe('buildCrashChunks', () => {
const result = buildCrashChunks(false, TEXT_ID, true)
expect(result.shouldNullSession).toBe(true)
expect(result.chunks[0]).toEqual({ type: 'text-end', id: TEXT_ID })
- expect(result.chunks[1]).toEqual({ type: 'error', errorText: 'Agent process exited unexpectedly.' })
+ expect(result.chunks[1]).toEqual({
+ type: 'error',
+ errorText: 'Agent process exited unexpectedly.'
+ })
})
})
diff --git a/tests/engine/clipboard.test.ts b/tests/engine/clipboard.test.ts
index bccb32a90..7a8c6c0e1 100644
--- a/tests/engine/clipboard.test.ts
+++ b/tests/engine/clipboard.test.ts
@@ -1,5 +1,5 @@
-import { readFileSync } from 'node:fs'
import { beforeAll, describe, expect, it } from 'bun:test'
+import { readFileSync } from 'node:fs'
import {
parseFigmaClipboard,
@@ -11,10 +11,13 @@ import {
readFigFile,
initCodec,
SceneGraph,
- type SceneNode,
+ type SceneNode
} from '@open-pencil/core'
-function makeClipboardHtml(nodeChanges: unknown[], meta = { fileKey: 'test', pasteID: 1, dataType: 'scene' }) {
+function makeClipboardHtml(
+ nodeChanges: unknown[],
+ meta = { fileKey: 'test', pasteID: 1, dataType: 'scene' }
+) {
// Minimal fig-kiwi clipboard: just meta + empty figma buffer
// For real parsing we'd need actual Kiwi binary — these tests use importClipboardNodes directly
const metaB64 = btoa(JSON.stringify(meta))
@@ -33,11 +36,42 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Document' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page 1' },
- { guid: { sessionID: 0, localID: 2 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'VARIABLE_SET', name: 'Primitives' },
- { guid: { sessionID: 0, localID: 3 }, parentIndex: { guid: { sessionID: 0, localID: 2 }, position: '!' }, type: 'VARIABLE', name: 'Colors/Brand/500' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'FRAME', name: 'Card', size: { x: 300, y: 200 }, transform: { m00: 1, m01: 0, m02: 50, m10: 0, m11: 1, m12: 50 } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' }, type: 'TEXT', name: 'Title', size: { x: 200, y: 30 }, transform: { m00: 1, m01: 0, m02: 10, m10: 0, m11: 1, m12: 10 }, textData: { characters: 'Hello' }, fontSize: 16 },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page 1'
+ },
+ {
+ guid: { sessionID: 0, localID: 2 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'VARIABLE_SET',
+ name: 'Primitives'
+ },
+ {
+ guid: { sessionID: 0, localID: 3 },
+ parentIndex: { guid: { sessionID: 0, localID: 2 }, position: '!' },
+ type: 'VARIABLE',
+ name: 'Colors/Brand/500'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'FRAME',
+ name: 'Card',
+ size: { x: 300, y: 200 },
+ transform: { m00: 1, m01: 0, m02: 50, m10: 0, m11: 1, m12: 50 }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
+ type: 'TEXT',
+ name: 'Title',
+ size: { x: 200, y: 30 },
+ transform: { m00: 1, m01: 0, m02: 10, m10: 0, m11: 1, m12: 10 },
+ textData: { characters: 'Hello' },
+ fontSize: 16
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -53,26 +87,49 @@ describe('importClipboardNodes', () => {
expect(children[0].name).toBe('Title')
const allNodes = [...graph.getAllNodes()]
- const variableNodes = allNodes.filter(n => n.name.includes('Primitives') || n.name.includes('Colors/'))
+ const variableNodes = allNodes.filter(
+ (n) => n.name.includes('Primitives') || n.name.includes('Colors/')
+ )
expect(variableNodes).toHaveLength(0)
})
it('skips non-visual Figma types', () => {
const { graph, pageId } = createGraphWithPage()
- const nonVisualTypes = ['WIDGET', 'STAMP', 'STICKY', 'CONNECTOR', 'CODE_BLOCK', 'SHAPE_WITH_TEXT', 'TABLE_NODE', 'TABLE_CELL']
+ const nonVisualTypes = [
+ 'WIDGET',
+ 'STAMP',
+ 'STICKY',
+ 'CONNECTOR',
+ 'CODE_BLOCK',
+ 'SHAPE_WITH_TEXT',
+ 'TABLE_NODE',
+ 'TABLE_CELL'
+ ]
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
...nonVisualTypes.map((type, i) => ({
guid: { sessionID: 0, localID: 100 + i },
parentIndex: { guid: { sessionID: 0, localID: 1 }, position: String.fromCharCode(33 + i) },
type,
name: `${type}_node`,
size: { x: 100, y: 100 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
})),
- { guid: { sessionID: 0, localID: 200 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: 'z' }, type: 'RECTANGLE', name: 'RealShape', size: { x: 50, y: 50 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
+ {
+ guid: { sessionID: 0, localID: 200 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: 'z' },
+ type: 'RECTANGLE',
+ name: 'RealShape',
+ size: { x: 50, y: 50 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -85,10 +142,38 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Outer', size: { x: 400, y: 300 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' }, type: 'FRAME', name: 'Inner', size: { x: 200, y: 100 }, transform: { m00: 1, m01: 0, m02: 20, m10: 0, m11: 1, m12: 20 } },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 11 }, position: '!' }, type: 'TEXT', name: 'Label', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 5, m10: 0, m11: 1, m12: 5 }, textData: { characters: 'Test' }, fontSize: 14 },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Outer',
+ size: { x: 400, y: 300 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
+ type: 'FRAME',
+ name: 'Inner',
+ size: { x: 200, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 20, m10: 0, m11: 1, m12: 20 }
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 11 }, position: '!' },
+ type: 'TEXT',
+ name: 'Label',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 5, m10: 0, m11: 1, m12: 5 },
+ textData: { characters: 'Test' },
+ fontSize: 14
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -112,7 +197,12 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
{
guid: { sessionID: 0, localID: 10 },
parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
@@ -120,10 +210,14 @@ describe('importClipboardNodes', () => {
name: 'Colored',
size: { x: 100, y: 100 },
transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- fillPaints: [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }],
- strokePaints: [{ type: 'SOLID', color: { r: 0, g: 0, b: 1, a: 1 }, opacity: 1, visible: true }],
- strokeWeight: 2,
- },
+ fillPaints: [
+ { type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }
+ ],
+ strokePaints: [
+ { type: 'SOLID', color: { r: 0, g: 0, b: 1, a: 1 }, opacity: 1, visible: true }
+ ],
+ strokeWeight: 2
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -140,10 +234,38 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Row', size: { x: 400, y: 100 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, stackMode: 'HORIZONTAL' },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' }, type: 'FRAME', name: 'Stretched', size: { x: 200, y: 50 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, stackChildAlignSelf: 'STRETCH' },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '"' }, type: 'FRAME', name: 'Auto', size: { x: 200, y: 50 }, transform: { m00: 1, m01: 0, m02: 200, m10: 0, m11: 1, m12: 0 } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Row',
+ size: { x: 400, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ stackMode: 'HORIZONTAL'
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
+ type: 'FRAME',
+ name: 'Stretched',
+ size: { x: 200, y: 50 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ stackChildAlignSelf: 'STRETCH'
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '"' },
+ type: 'FRAME',
+ name: 'Auto',
+ size: { x: 200, y: 50 },
+ transform: { m00: 1, m01: 0, m02: 200, m10: 0, m11: 1, m12: 0 }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -158,10 +280,38 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Clipped', size: { x: 200, y: 100 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, frameMaskDisabled: false },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'FRAME', name: 'Unclipped', size: { x: 200, y: 100 }, transform: { m00: 1, m01: 0, m02: 200, m10: 0, m11: 1, m12: 0 }, frameMaskDisabled: true },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' }, type: 'FRAME', name: 'Default', size: { x: 200, y: 100 }, transform: { m00: 1, m01: 0, m02: 400, m10: 0, m11: 1, m12: 0 } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Clipped',
+ size: { x: 200, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ frameMaskDisabled: false
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'FRAME',
+ name: 'Unclipped',
+ size: { x: 200, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 200, m10: 0, m11: 1, m12: 0 },
+ frameMaskDisabled: true
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' },
+ type: 'FRAME',
+ name: 'Default',
+ size: { x: 200, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 400, m10: 0, m11: 1, m12: 0 }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -175,10 +325,45 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'TEXT', name: 'Medium', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, textData: { characters: 'Hello' }, fontSize: 14, fontName: { family: 'PT Root UI', style: 'Medium', postscript: 'PTRootUI-Medium' } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'TEXT', name: 'Bold', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 20 }, textData: { characters: 'World' }, fontSize: 14, fontName: { family: 'Inter', style: 'Bold', postscript: 'Inter-Bold' } },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' }, type: 'TEXT', name: 'Italic', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 40 }, textData: { characters: 'Italic' }, fontSize: 14, fontName: { family: 'Inter', style: 'Bold Italic', postscript: 'Inter-BoldItalic' } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'TEXT',
+ name: 'Medium',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ textData: { characters: 'Hello' },
+ fontSize: 14,
+ fontName: { family: 'PT Root UI', style: 'Medium', postscript: 'PTRootUI-Medium' }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'TEXT',
+ name: 'Bold',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 20 },
+ textData: { characters: 'World' },
+ fontSize: 14,
+ fontName: { family: 'Inter', style: 'Bold', postscript: 'Inter-Bold' }
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' },
+ type: 'TEXT',
+ name: 'Italic',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 40 },
+ textData: { characters: 'Italic' },
+ fontSize: 14,
+ fontName: { family: 'Inter', style: 'Bold Italic', postscript: 'Inter-BoldItalic' }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -193,10 +378,44 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'TEXT', name: 'PixelSpacing', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, textData: { characters: 'A' }, fontSize: 20, letterSpacing: { value: 2, units: 'PIXELS' } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'TEXT', name: 'PercentSpacing', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 20 }, textData: { characters: 'B' }, fontSize: 20, letterSpacing: { value: 10, units: 'PERCENT' } },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' }, type: 'TEXT', name: 'NoSpacing', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 40 }, textData: { characters: 'C' }, fontSize: 20 },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'TEXT',
+ name: 'PixelSpacing',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ textData: { characters: 'A' },
+ fontSize: 20,
+ letterSpacing: { value: 2, units: 'PIXELS' }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'TEXT',
+ name: 'PercentSpacing',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 20 },
+ textData: { characters: 'B' },
+ fontSize: 20,
+ letterSpacing: { value: 10, units: 'PERCENT' }
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' },
+ type: 'TEXT',
+ name: 'NoSpacing',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 40 },
+ textData: { characters: 'C' },
+ fontSize: 20
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -210,10 +429,45 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'TEXT', name: 'RawLH', size: { x: 100, y: 36 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, textData: { characters: 'A' }, fontSize: 24, lineHeight: { value: 1.5, units: 'RAW' } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'TEXT', name: 'PixelLH', size: { x: 100, y: 20 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 40 }, textData: { characters: 'B' }, fontSize: 16, lineHeight: { value: 20, units: 'PIXELS' } },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' }, type: 'TEXT', name: 'PercentLH', size: { x: 100, y: 24 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 80 }, textData: { characters: 'C' }, fontSize: 20, lineHeight: { value: 120, units: 'PERCENT' } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'TEXT',
+ name: 'RawLH',
+ size: { x: 100, y: 36 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ textData: { characters: 'A' },
+ fontSize: 24,
+ lineHeight: { value: 1.5, units: 'RAW' }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'TEXT',
+ name: 'PixelLH',
+ size: { x: 100, y: 20 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 40 },
+ textData: { characters: 'B' },
+ fontSize: 16,
+ lineHeight: { value: 20, units: 'PIXELS' }
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' },
+ type: 'TEXT',
+ name: 'PercentLH',
+ size: { x: 100, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 80 },
+ textData: { characters: 'C' },
+ fontSize: 20,
+ lineHeight: { value: 120, units: 'PERCENT' }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -227,25 +481,34 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
{
guid: { sessionID: 0, localID: 10 },
parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
- type: 'TEXT', name: 'Styled', size: { x: 200, y: 40 },
+ type: 'TEXT',
+ name: 'Styled',
+ size: { x: 200, y: 40 },
transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
fontSize: 16,
textData: {
characters: 'Hello World',
characterStyleIDs: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
- styleOverrideTable: [{
- styleID: 1,
- fontName: { family: 'Inter', style: 'Bold' },
- fontSize: 20,
- lineHeight: { value: 1.5, units: 'RAW' },
- letterSpacing: { value: -2, units: 'PERCENT' },
- }],
- },
- },
+ styleOverrideTable: [
+ {
+ styleID: 1,
+ fontName: { family: 'Inter', style: 'Bold' },
+ fontSize: 20,
+ lineHeight: { value: 1.5, units: 'RAW' },
+ letterSpacing: { value: -2, units: 'PERCENT' }
+ }
+ ]
+ }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -260,7 +523,12 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
{
guid: { sessionID: 0, localID: 10 },
parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
@@ -273,7 +541,7 @@ describe('importClipboardNodes', () => {
stackVerticalPadding: 24,
stackHorizontalPadding: 24,
stackPrimarySizing: 'RESIZE_TO_FIT',
- stackCounterSizing: 'RESIZE_TO_FIT',
+ stackCounterSizing: 'RESIZE_TO_FIT'
},
{
guid: { sessionID: 0, localID: 11 },
@@ -284,7 +552,7 @@ describe('importClipboardNodes', () => {
transform: { m00: 1, m01: 0, m02: 24, m10: 0, m11: 1, m12: 24 },
textData: { characters: 'Hello' },
fontSize: 24,
- fontWeight: 700,
+ fontWeight: 700
},
{
guid: { sessionID: 0, localID: 12 },
@@ -292,8 +560,8 @@ describe('importClipboardNodes', () => {
type: 'RECTANGLE',
name: 'Divider',
size: { x: 404, y: 1 },
- transform: { m00: 1, m01: 0, m02: 24, m10: 0, m11: 1, m12: 72 },
- },
+ transform: { m00: 1, m01: 0, m02: 24, m10: 0, m11: 1, m12: 72 }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -317,12 +585,39 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
// Component with a child
- { guid: { sessionID: 1, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'SYMBOL', name: 'Icon/Warning', size: { x: 48, y: 48 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 1, localID: 11 }, parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' }, type: 'VECTOR', name: 'Triangle', size: { x: 48, y: 42 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 3 } },
+ {
+ guid: { sessionID: 1, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'SYMBOL',
+ name: 'Icon/Warning',
+ size: { x: 48, y: 48 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 1, localID: 11 },
+ parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' },
+ type: 'VECTOR',
+ name: 'Triangle',
+ size: { x: 48, y: 42 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 3 }
+ },
// Instance referencing the component
- { guid: { sessionID: 2, localID: 20 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'INSTANCE', name: 'Icon/Warning', size: { x: 48, y: 48 }, transform: { m00: 1, m01: 0, m02: 100, m10: 0, m11: 1, m12: 0 }, symbolData: { symbolID: { sessionID: 1, localID: 10 } } },
+ {
+ guid: { sessionID: 2, localID: 20 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'INSTANCE',
+ name: 'Icon/Warning',
+ size: { x: 48, y: 48 },
+ transform: { m00: 1, m01: 0, m02: 100, m10: 0, m11: 1, m12: 0 },
+ symbolData: { symbolID: { sessionID: 1, localID: 10 } }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -347,13 +642,46 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page 1' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page 1'
+ },
// Internal Only Canvas with component
- { guid: { sessionID: 99, localID: 2 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '"' }, type: 'CANVAS', name: 'Internal Only Canvas', internalOnly: true },
- { guid: { sessionID: 1, localID: 10 }, parentIndex: { guid: { sessionID: 99, localID: 2 }, position: '!' }, type: 'SYMBOL', name: 'Icon', size: { x: 24, y: 24 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 1, localID: 11 }, parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' }, type: 'VECTOR', name: 'Path', size: { x: 24, y: 24 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
+ {
+ guid: { sessionID: 99, localID: 2 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '"' },
+ type: 'CANVAS',
+ name: 'Internal Only Canvas',
+ internalOnly: true
+ },
+ {
+ guid: { sessionID: 1, localID: 10 },
+ parentIndex: { guid: { sessionID: 99, localID: 2 }, position: '!' },
+ type: 'SYMBOL',
+ name: 'Icon',
+ size: { x: 24, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 1, localID: 11 },
+ parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' },
+ type: 'VECTOR',
+ name: 'Path',
+ size: { x: 24, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
// Visible page with instance
- { guid: { sessionID: 2, localID: 20 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'INSTANCE', name: 'Icon', size: { x: 24, y: 24 }, transform: { m00: 1, m01: 0, m02: 50, m10: 0, m11: 1, m12: 50 }, symbolData: { symbolID: { sessionID: 1, localID: 10 } } },
+ {
+ guid: { sessionID: 2, localID: 20 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'INSTANCE',
+ name: 'Icon',
+ size: { x: 24, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 50, m10: 0, m11: 1, m12: 50 },
+ symbolData: { symbolID: { sessionID: 1, localID: 10 } }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -381,19 +709,34 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
// Frame containing an instance whose component is NOT in the clipboard
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Card', size: { x: 400, y: 200 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Card',
+ size: { x: 400, y: 200 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
{
guid: { sessionID: 0, localID: 11 },
parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
- type: 'INSTANCE', name: 'Button',
+ type: 'INSTANCE',
+ name: 'Button',
size: { x: 120, y: 40 },
transform: { m00: 1, m01: 0, m02: 20, m10: 0, m11: 1, m12: 20 },
- fillPaints: [{ type: 'SOLID', color: { r: 0.2, g: 0.4, b: 1, a: 1 }, opacity: 1, visible: true }],
+ fillPaints: [
+ { type: 'SOLID', color: { r: 0.2, g: 0.4, b: 1, a: 1 }, opacity: 1, visible: true }
+ ],
cornerRadius: 8,
- symbolData: { symbolID: { sessionID: 99, localID: 999 } },
- },
+ symbolData: { symbolID: { sessionID: 99, localID: 999 } }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -419,14 +762,56 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page 1' },
- { guid: { sessionID: 99, localID: 2 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '"' }, type: 'CANVAS', name: 'Internal Only Canvas', internalOnly: true },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page 1'
+ },
+ {
+ guid: { sessionID: 99, localID: 2 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '"' },
+ type: 'CANVAS',
+ name: 'Internal Only Canvas',
+ internalOnly: true
+ },
// Component on internal canvas
- { guid: { sessionID: 1, localID: 10 }, parentIndex: { guid: { sessionID: 99, localID: 2 }, position: '!' }, type: 'SYMBOL', name: 'Day', size: { x: 46, y: 46 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 1, localID: 11 }, parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' }, type: 'TEXT', name: 'Number', size: { x: 14, y: 17 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, textData: { characters: '1' }, overrideKey: { sessionID: 50, localID: 100 } },
+ {
+ guid: { sessionID: 1, localID: 10 },
+ parentIndex: { guid: { sessionID: 99, localID: 2 }, position: '!' },
+ type: 'SYMBOL',
+ name: 'Day',
+ size: { x: 46, y: 46 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 1, localID: 11 },
+ parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' },
+ type: 'TEXT',
+ name: 'Number',
+ size: { x: 14, y: 17 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ textData: { characters: '1' },
+ overrideKey: { sessionID: 50, localID: 100 }
+ },
// Instance on visible page with text override
- { guid: { sessionID: 2, localID: 20 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'INSTANCE', name: 'Day', size: { x: 46, y: 46 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- symbolData: { symbolID: { sessionID: 1, localID: 10 }, symbolOverrides: [{ guidPath: { guids: [{ sessionID: 50, localID: 100 }] }, textData: { characters: '25' } }] } },
+ {
+ guid: { sessionID: 2, localID: 20 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'INSTANCE',
+ name: 'Day',
+ size: { x: 46, y: 46 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ symbolData: {
+ symbolID: { sessionID: 1, localID: 10 },
+ symbolOverrides: [
+ {
+ guidPath: { guids: [{ sessionID: 50, localID: 100 }] },
+ textData: { characters: '25' }
+ }
+ ]
+ }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -444,10 +829,44 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'TEXT', name: 'AutoHeight', size: { x: 200, y: 24 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }, textData: { characters: 'Hello' }, fontSize: 16, textAutoResize: 'HEIGHT' },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'TEXT', name: 'AutoBoth', size: { x: 100, y: 24 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 30 }, textData: { characters: 'World' }, fontSize: 16, textAutoResize: 'WIDTH_AND_HEIGHT' },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' }, type: 'TEXT', name: 'Fixed', size: { x: 100, y: 24 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 60 }, textData: { characters: 'Fixed' }, fontSize: 16 },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'TEXT',
+ name: 'AutoHeight',
+ size: { x: 200, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ textData: { characters: 'Hello' },
+ fontSize: 16,
+ textAutoResize: 'HEIGHT'
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'TEXT',
+ name: 'AutoBoth',
+ size: { x: 100, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 30 },
+ textData: { characters: 'World' },
+ fontSize: 16,
+ textAutoResize: 'WIDTH_AND_HEIGHT'
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '#' },
+ type: 'TEXT',
+ name: 'Fixed',
+ size: { x: 100, y: 24 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 60 },
+ textData: { characters: 'Fixed' },
+ fontSize: 16
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -461,10 +880,38 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Parent', size: { x: 400, y: 300 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' }, type: 'RECTANGLE', name: 'Child1', size: { x: 100, y: 100 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '"' }, type: 'TEXT', name: 'Child2', size: { x: 200, y: 30 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 100 }, textData: { characters: 'Hello' }, fontSize: 14 },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Parent',
+ size: { x: 400, y: 300 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
+ type: 'RECTANGLE',
+ name: 'Child1',
+ size: { x: 100, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '"' },
+ type: 'TEXT',
+ name: 'Child2',
+ size: { x: 200, y: 30 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 100 },
+ textData: { characters: 'Hello' },
+ fontSize: 14
+ }
] as any[]
const nodesBefore = [...graph.getAllNodes()].length
@@ -482,10 +929,38 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Parent', size: { x: 400, y: 300 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' }, type: 'RECTANGLE', name: 'Child1', size: { x: 100, y: 100 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 0, localID: 12 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '"' }, type: 'TEXT', name: 'Child2', size: { x: 200, y: 30 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 100 }, textData: { characters: 'Hello' }, fontSize: 14 },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Parent',
+ size: { x: 400, y: 300 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
+ type: 'RECTANGLE',
+ name: 'Child1',
+ size: { x: 100, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 0, localID: 12 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '"' },
+ type: 'TEXT',
+ name: 'Child2',
+ size: { x: 200, y: 30 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 100 },
+ textData: { characters: 'Hello' },
+ fontSize: 14
+ }
] as any[]
const childrenBefore = graph.getChildren(pageId).length
@@ -528,9 +1003,28 @@ describe('importClipboardNodes', () => {
const nodeChanges = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'Parent', size: { x: 400, y: 300 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' }, type: 'RECTANGLE', name: 'Child', size: { x: 100, y: 100 }, transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'Parent',
+ size: { x: 400, y: 300 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 10 }, position: '!' },
+ type: 'RECTANGLE',
+ name: 'Child',
+ size: { x: 100, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
] as any[]
const created = importClipboardNodes(nodeChanges, graph, pageId)
@@ -562,9 +1056,28 @@ describe('figmaNodesBounds', () => {
it('computes bounds of top-level visual nodes', () => {
const nodes = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'FRAME', name: 'A', size: { x: 200, y: 100 }, transform: { m00: 1, m01: 0, m02: 500, m10: 0, m11: 1, m12: 300 } },
- { guid: { sessionID: 0, localID: 11 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'RECTANGLE', name: 'B', size: { x: 50, y: 50 }, transform: { m00: 1, m01: 0, m02: 800, m10: 0, m11: 1, m12: 400 } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'FRAME',
+ name: 'A',
+ size: { x: 200, y: 100 },
+ transform: { m00: 1, m01: 0, m02: 500, m10: 0, m11: 1, m12: 300 }
+ },
+ {
+ guid: { sessionID: 0, localID: 11 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'RECTANGLE',
+ name: 'B',
+ size: { x: 50, y: 50 },
+ transform: { m00: 1, m01: 0, m02: 800, m10: 0, m11: 1, m12: 400 }
+ }
] as any[]
const bounds = figmaNodesBounds(nodes)
@@ -574,9 +1087,26 @@ describe('figmaNodesBounds', () => {
it('ignores variables and non-visual types', () => {
const nodes = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
- { guid: { sessionID: 0, localID: 2 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' }, type: 'VARIABLE_SET', name: 'Vars' },
- { guid: { sessionID: 0, localID: 10 }, parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' }, type: 'FRAME', name: 'Card', size: { x: 300, y: 200 }, transform: { m00: 1, m01: 0, m02: 18000, m10: 0, m11: 1, m12: 45000 } },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ },
+ {
+ guid: { sessionID: 0, localID: 2 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '!' },
+ type: 'VARIABLE_SET',
+ name: 'Vars'
+ },
+ {
+ guid: { sessionID: 0, localID: 10 },
+ parentIndex: { guid: { sessionID: 0, localID: 1 }, position: '"' },
+ type: 'FRAME',
+ name: 'Card',
+ size: { x: 300, y: 200 },
+ transform: { m00: 1, m01: 0, m02: 18000, m10: 0, m11: 1, m12: 45000 }
+ }
] as any[]
const bounds = figmaNodesBounds(nodes)
@@ -587,7 +1117,12 @@ describe('figmaNodesBounds', () => {
expect(figmaNodesBounds([])).toBeNull()
const nodes = [
{ guid: { sessionID: 0, localID: 0 }, type: 'DOCUMENT', name: 'Doc' },
- { guid: { sessionID: 0, localID: 1 }, parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' }, type: 'CANVAS', name: 'Page' },
+ {
+ guid: { sessionID: 0, localID: 1 },
+ parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
+ type: 'CANVAS',
+ name: 'Page'
+ }
] as any[]
expect(figmaNodesBounds(nodes)).toBeNull()
})
@@ -603,8 +1138,11 @@ describe('buildFigmaClipboardHTML', () => {
const page = graph.getPages()[0]
const frame = graph.createNode('FRAME', page.id, {
name: 'Card',
- x: 0, y: 0, width: 300, height: 200,
- fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }],
+ x: 0,
+ y: 0,
+ width: 300,
+ height: 200,
+ fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }]
})
const html = await buildFigmaClipboardHTML([frame], graph)
@@ -617,15 +1155,18 @@ describe('buildFigmaClipboardHTML', () => {
const page = graph.getPages()[0]
const text = graph.createNode('TEXT', page.id, {
name: 'Styled',
- x: 0, y: 0, width: 200, height: 24,
+ x: 0,
+ y: 0,
+ width: 200,
+ height: 24,
text: 'Hello World',
fontFamily: 'Inter',
fontWeight: 400,
fontSize: 16,
styleRuns: [
{ start: 0, length: 5, style: { fontWeight: 700 } },
- { start: 6, length: 5, style: { fontWeight: 400, italic: true } },
- ],
+ { start: 6, length: 5, style: { fontWeight: 400, italic: true } }
+ ]
})
const html = await buildFigmaClipboardHTML([text], graph)
@@ -643,16 +1184,25 @@ describe('buildFigmaClipboardHTML', () => {
const page = graph.getPages()[0]
const frame = graph.createNode('FRAME', page.id, {
name: 'Row',
- x: 0, y: 0, width: 400, height: 100,
+ x: 0,
+ y: 0,
+ width: 400,
+ height: 100,
layoutMode: 'HORIZONTAL',
itemSpacing: 16,
- paddingTop: 12, paddingRight: 12, paddingBottom: 12, paddingLeft: 12,
+ paddingTop: 12,
+ paddingRight: 12,
+ paddingBottom: 12,
+ paddingLeft: 12,
primaryAxisSizing: 'HUG',
- counterAxisSizing: 'FIXED',
+ counterAxisSizing: 'FIXED'
})
graph.createNode('RECTANGLE', frame.id, {
name: 'Child',
- x: 0, y: 0, width: 50, height: 50,
+ x: 0,
+ y: 0,
+ width: 50,
+ height: 50
})
const html = await buildFigmaClipboardHTML([frame], graph)
@@ -664,28 +1214,40 @@ describe('buildFigmaClipboardHTML', () => {
const page = graph.getPages()[0]
const frame = graph.createNode('FRAME', page.id, {
name: 'Analytics Overview',
- x: 0, y: 0, width: 300, height: 200,
+ x: 0,
+ y: 0,
+ width: 300,
+ height: 200,
layoutMode: 'VERTICAL',
itemSpacing: 8,
- paddingTop: 20, paddingRight: 20, paddingBottom: 20, paddingLeft: 20,
+ paddingTop: 20,
+ paddingRight: 20,
+ paddingBottom: 20,
+ paddingLeft: 20,
fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }],
- cornerRadius: 12,
+ cornerRadius: 12
})
graph.createNode('TEXT', frame.id, {
name: 'Title',
- x: 0, y: 0, width: 260, height: 24,
+ x: 0,
+ y: 0,
+ width: 260,
+ height: 24,
text: 'Analytics Overview',
fontFamily: 'Inter',
fontWeight: 600,
- fontSize: 18,
+ fontSize: 18
})
graph.createNode('TEXT', frame.id, {
name: 'Subtitle',
- x: 0, y: 0, width: 260, height: 40,
+ x: 0,
+ y: 0,
+ width: 260,
+ height: 40,
text: 'Track your key metrics and performance indicators in real time.',
fontFamily: 'Inter',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const html = await buildFigmaClipboardHTML([frame], graph)
@@ -795,13 +1357,21 @@ describe('gold-preview.fig clipboard roundtrip', () => {
if (o.name !== p.name) continue
if (p.clipsContent !== o.clipsContent)
- errors.push(`clipsContent: ${o.type} "${o.name}" expected ${o.clipsContent}, got ${p.clipsContent}`)
+ errors.push(
+ `clipsContent: ${o.type} "${o.name}" expected ${o.clipsContent}, got ${p.clipsContent}`
+ )
if (p.horizontalConstraint !== o.horizontalConstraint)
- errors.push(`horizontalConstraint: "${o.name}" expected ${o.horizontalConstraint}, got ${p.horizontalConstraint}`)
+ errors.push(
+ `horizontalConstraint: "${o.name}" expected ${o.horizontalConstraint}, got ${p.horizontalConstraint}`
+ )
if (p.verticalConstraint !== o.verticalConstraint)
- errors.push(`verticalConstraint: "${o.name}" expected ${o.verticalConstraint}, got ${p.verticalConstraint}`)
+ errors.push(
+ `verticalConstraint: "${o.name}" expected ${o.verticalConstraint}, got ${p.verticalConstraint}`
+ )
if (p.layoutAlignSelf !== o.layoutAlignSelf)
- errors.push(`layoutAlignSelf: "${o.name}" expected ${o.layoutAlignSelf}, got ${p.layoutAlignSelf}`)
+ errors.push(
+ `layoutAlignSelf: "${o.name}" expected ${o.layoutAlignSelf}, got ${p.layoutAlignSelf}`
+ )
if ((p.arcData != null) !== (o.arcData != null))
errors.push(`arcData: "${o.name}" expected ${o.arcData != null}, got ${p.arcData != null}`)
}
diff --git a/tests/engine/color.test.ts b/tests/engine/color.test.ts
index caa3a4606..ef4b12ef7 100644
--- a/tests/engine/color.test.ts
+++ b/tests/engine/color.test.ts
@@ -221,18 +221,12 @@ describe('colorDistance', () => {
})
test('similar reds are close', () => {
- const d = colorDistance(
- { r: 1, g: 0, b: 0, a: 1 },
- { r: 0.95, g: 0.02, b: 0.02, a: 1 }
- )
+ const d = colorDistance({ r: 1, g: 0, b: 0, a: 1 }, { r: 0.95, g: 0.02, b: 0.02, a: 1 })
expect(d).toBeLessThan(15)
})
test('red to blue is far', () => {
- const d = colorDistance(
- { r: 1, g: 0, b: 0, a: 1 },
- { r: 0, g: 0, b: 1, a: 1 }
- )
+ const d = colorDistance({ r: 1, g: 0, b: 0, a: 1 }, { r: 0, g: 0, b: 1, a: 1 })
expect(d).toBeGreaterThan(300)
})
})
diff --git a/tests/engine/copy.test.ts b/tests/engine/copy.test.ts
index 62ef34d07..d7d7a2e27 100644
--- a/tests/engine/copy.test.ts
+++ b/tests/engine/copy.test.ts
@@ -1,4 +1,5 @@
import { describe, test, expect } from 'bun:test'
+
import {
copyFill,
copyFills,
@@ -7,6 +8,7 @@ import {
copyStyleRun,
copyGeometryPaths
} from '#core/scene-graph/copy'
+
import type { Fill, Stroke, Effect, StyleRun, GeometryPath } from '@open-pencil/core'
describe('copy helpers — mutation isolation', () => {
@@ -15,7 +17,7 @@ describe('copy helpers — mutation isolation', () => {
type: 'SOLID',
color: { r: 1, g: 0, b: 0, a: 1 },
opacity: 1,
- visible: true,
+ visible: true
}
const copy = copyFill(original)
copy.color.r = 0
@@ -32,9 +34,9 @@ describe('copy helpers — mutation isolation', () => {
visible: true,
gradientStops: [
{ color: { r: 1, g: 0, b: 0, a: 1 }, position: 0 },
- { color: { r: 0, g: 0, b: 1, a: 1 }, position: 1 },
+ { color: { r: 0, g: 0, b: 1, a: 1 }, position: 1 }
],
- gradientTransform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ gradientTransform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
}
const copy = copyFill(original)
copy.gradientStops![0].color.r = 0
@@ -50,7 +52,7 @@ describe('copy helpers — mutation isolation', () => {
opacity: 1,
visible: true,
align: 'CENTER',
- dashPattern: [5, 3],
+ dashPattern: [5, 3]
}
const copy = copyStroke(original)
copy.dashPattern!.push(99)
@@ -66,7 +68,7 @@ describe('copy helpers — mutation isolation', () => {
offset: { x: 4, y: 4 },
radius: 8,
spread: 0,
- visible: true,
+ visible: true
}
const copy = copyEffect(original)
copy.offset.x = 100
@@ -79,7 +81,7 @@ describe('copy helpers — mutation isolation', () => {
const original: StyleRun = {
start: 0,
length: 5,
- style: { fontWeight: 700, fontSize: 24 },
+ style: { fontWeight: 700, fontSize: 24 }
}
const copy = copyStyleRun(original)
copy.style.fontWeight = 400
@@ -88,7 +90,7 @@ describe('copy helpers — mutation isolation', () => {
test('copyGeometryPaths: Uint8Array is independent', () => {
const original: GeometryPath[] = [
- { windingRule: 'NONZERO', commandsBlob: new Uint8Array([1, 2, 3]) },
+ { windingRule: 'NONZERO', commandsBlob: new Uint8Array([1, 2, 3]) }
]
const copy = copyGeometryPaths(original)
copy[0].commandsBlob[0] = 99
@@ -98,7 +100,7 @@ describe('copy helpers — mutation isolation', () => {
test('copyFills: array independence', () => {
const originals: Fill[] = [
{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true },
- { type: 'SOLID', color: { r: 0, g: 1, b: 0, a: 1 }, opacity: 0.5, visible: true },
+ { type: 'SOLID', color: { r: 0, g: 1, b: 0, a: 1 }, opacity: 0.5, visible: true }
]
const copies = copyFills(originals)
copies.push({ type: 'SOLID', color: { r: 0, g: 0, b: 1, a: 1 }, opacity: 1, visible: true })
diff --git a/tests/engine/editor-store-path.test.ts b/tests/engine/editor-store-path.test.ts
index cd9a0a97c..2d8f8d4ad 100644
--- a/tests/engine/editor-store-path.test.ts
+++ b/tests/engine/editor-store-path.test.ts
@@ -1,4 +1,5 @@
import { describe, test, expect } from 'bun:test'
+
import { createEditorStore } from '../../src/app/editor/session'
describe('setPlannedFilePath', () => {
diff --git a/tests/engine/eval-cli.test.ts b/tests/engine/eval-cli.test.ts
index 0516d2757..35fc01c24 100644
--- a/tests/engine/eval-cli.test.ts
+++ b/tests/engine/eval-cli.test.ts
@@ -1,7 +1,8 @@
import { describe, expect, test, setDefaultTimeout } from 'bun:test'
-import { join } from 'path'
-import { tmpdir } from 'os'
import { randomUUID } from 'crypto'
+import { tmpdir } from 'os'
+import { join } from 'path'
+
import { heavy } from '../helpers/test-utils'
setDefaultTimeout(30_000)
@@ -9,15 +10,18 @@ setDefaultTimeout(30_000)
const CLI = join(import.meta.dir, '../../packages/cli/src/index.ts')
const FIXTURE = join(import.meta.dir, '../fixtures/gold-preview.fig')
-async function run(args: string[], stdin?: string): Promise<{ stdout: string; stderr: string; exitCode: number }> {
+async function run(
+ args: string[],
+ stdin?: string
+): Promise<{ stdout: string; stderr: string; exitCode: number }> {
const proc = Bun.spawn(['bun', CLI, ...args], {
stdout: 'pipe',
stderr: 'pipe',
- stdin: stdin ? Buffer.from(stdin) : undefined,
+ stdin: stdin ? Buffer.from(stdin) : undefined
})
const [stdout, stderr] = await Promise.all([
new Response(proc.stdout).text(),
- new Response(proc.stderr).text(),
+ new Response(proc.stderr).text()
])
const exitCode = await proc.exited
return { stdout: stdout.trim(), stderr: stderr.trim(), exitCode }
@@ -25,7 +29,12 @@ async function run(args: string[], stdin?: string): Promise<{ stdout: string; st
heavy('eval CLI', () => {
test('returns page name', async () => {
- const { stdout, exitCode } = await run(['eval', FIXTURE, '--code', 'return figma.currentPage.name'])
+ const { stdout, exitCode } = await run([
+ 'eval',
+ FIXTURE,
+ '--code',
+ 'return figma.currentPage.name'
+ ])
expect(exitCode).toBe(0)
expect(stdout.length).toBeGreaterThan(0)
})
@@ -38,7 +47,10 @@ heavy('eval CLI', () => {
test('returns page count', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--code', 'return figma.root.children.length',
+ 'eval',
+ FIXTURE,
+ '--code',
+ 'return figma.root.children.length'
])
expect(exitCode).toBe(0)
const count = parseInt(stdout)
@@ -47,8 +59,11 @@ heavy('eval CLI', () => {
test('findAll queries nodes', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code',
- 'return figma.currentPage.findAll(n => n.type === "TEXT").slice(0, 3).map(n => ({ name: n.name, type: n.type }))',
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
+ 'return figma.currentPage.findAll(n => n.type === "TEXT").slice(0, 3).map(n => ({ name: n.name, type: n.type }))'
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
@@ -59,8 +74,11 @@ heavy('eval CLI', () => {
test('create frame and return properties', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code',
- `const f = figma.createFrame(); f.name = "Test"; f.resize(300, 200); return f`,
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
+ `const f = figma.createFrame(); f.name = "Test"; f.resize(300, 200); return f`
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
@@ -72,12 +90,15 @@ heavy('eval CLI', () => {
test('auto-layout script', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code',
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
`const f = figma.createFrame()
f.layoutMode = "VERTICAL"
f.itemSpacing = 8
f.paddingTop = f.paddingBottom = 16
- return { layoutMode: f.layoutMode, itemSpacing: f.itemSpacing, paddingTop: f.paddingTop }`,
+ return { layoutMode: f.layoutMode, itemSpacing: f.itemSpacing, paddingTop: f.paddingTop }`
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
@@ -88,11 +109,14 @@ heavy('eval CLI', () => {
test('text node with characters', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code',
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
`const t = figma.createText()
t.characters = "Hello"
t.fontSize = 24
- return { characters: t.characters, fontSize: t.fontSize }`,
+ return { characters: t.characters, fontSize: t.fontSize }`
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
@@ -102,8 +126,10 @@ heavy('eval CLI', () => {
test('top-level await works', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--code',
- 'await figma.loadFontAsync({ family: "Inter", style: "Regular" }); return "ok"',
+ 'eval',
+ FIXTURE,
+ '--code',
+ 'await figma.loadFontAsync({ family: "Inter", style: "Regular" }); return "ok"'
])
expect(exitCode).toBe(0)
expect(stdout).toContain('ok')
@@ -113,13 +139,13 @@ heavy('eval CLI', () => {
const proc = Bun.spawn(['bun', CLI, 'eval', FIXTURE, '--stdin'], {
stdout: 'pipe',
stderr: 'pipe',
- stdin: 'pipe',
+ stdin: 'pipe'
})
proc.stdin.write('return figma.currentPage.name')
proc.stdin.end()
const [stdout, stderr] = await Promise.all([
new Response(proc.stdout).text(),
- new Response(proc.stderr).text(),
+ new Response(proc.stderr).text()
])
const exitCode = await proc.exited
if (exitCode !== 0) throw new Error(`exit ${exitCode}: ${stderr}`)
@@ -128,7 +154,11 @@ heavy('eval CLI', () => {
test('--json outputs valid JSON', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code', 'return { a: 1, b: "two" }',
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
+ 'return { a: 1, b: "two" }'
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
@@ -136,17 +166,13 @@ heavy('eval CLI', () => {
})
test('syntax error exits with error', async () => {
- const { exitCode, stderr } = await run([
- 'eval', FIXTURE, '--code', 'return {{{',
- ])
+ const { exitCode, stderr } = await run(['eval', FIXTURE, '--code', 'return {{{'])
expect(exitCode).not.toBe(0)
expect(stderr.length).toBeGreaterThan(0)
})
test('runtime error exits with error', async () => {
- const { exitCode, stderr } = await run([
- 'eval', FIXTURE, '--code', 'throw new Error("boom")',
- ])
+ const { exitCode, stderr } = await run(['eval', FIXTURE, '--code', 'throw new Error("boom")'])
expect(exitCode).not.toBe(0)
expect(stderr).toContain('boom')
})
@@ -158,9 +184,7 @@ heavy('eval CLI', () => {
})
test('undefined result produces no output', async () => {
- const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--code', 'figma.createFrame()',
- ])
+ const { stdout, exitCode } = await run(['eval', FIXTURE, '--code', 'figma.createFrame()'])
expect(exitCode).toBe(0)
expect(stdout).toBe('')
})
@@ -168,9 +192,13 @@ heavy('eval CLI', () => {
test('--output writes file', async () => {
const outFile = join(tmpdir(), `eval-test-${randomUUID()}.fig`)
const { exitCode, stderr } = await run([
- 'eval', FIXTURE, '--quiet', '--code',
+ 'eval',
+ FIXTURE,
+ '--quiet',
+ '--code',
'const f = figma.createFrame(); f.name = "Written"',
- '-o', outFile,
+ '-o',
+ outFile
])
// exportFigFile may fail on files with COMPONENT nodes (Kiwi schema limitation)
@@ -186,10 +214,13 @@ heavy('eval CLI', () => {
test('array of nodes serializes', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code',
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
`const a = figma.createFrame(); a.name = "A"
const b = figma.createRectangle(); b.name = "B"
- return [a, b]`,
+ return [a, b]`
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
@@ -200,11 +231,14 @@ heavy('eval CLI', () => {
test('getNodeById on real file', async () => {
const { stdout, exitCode } = await run([
- 'eval', FIXTURE, '--json', '--code',
+ 'eval',
+ FIXTURE,
+ '--json',
+ '--code',
`const page = figma.currentPage
const first = page.children[0]
const found = figma.getNodeById(first.id)
- return { same: found.id === first.id, name: found.name }`,
+ return { same: found.id === first.id, name: found.name }`
])
expect(exitCode).toBe(0)
const data = JSON.parse(stdout)
diff --git a/tests/engine/export-jsx.test.ts b/tests/engine/export-jsx.test.ts
index b2e456fd6..3c279b9f7 100644
--- a/tests/engine/export-jsx.test.ts
+++ b/tests/engine/export-jsx.test.ts
@@ -51,9 +51,7 @@ describe('sceneNodeToJSX', () => {
text: 'Hello World',
fontSize: 18,
fontWeight: 700,
- fills: [
- { type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }
- ]
+ fills: [{ type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
})
const jsx = sceneNodeToJSX(node.id, graph)
expect(jsx).toContain('<Text')
@@ -134,9 +132,7 @@ describe('sceneNodeToJSX', () => {
text: 'Card Title',
fontSize: 16,
fontWeight: 700,
- fills: [
- { type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }
- ]
+ fills: [{ type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
})
const jsx = sceneNodeToJSX(frame.id, graph)
@@ -209,7 +205,13 @@ describe('sceneNodeToJSX', () => {
width: 100,
height: 100,
strokes: [
- { color: { r: 1, g: 0, b: 0, a: 1 }, weight: 2, opacity: 1, visible: true, align: 'INSIDE' as const }
+ {
+ color: { r: 1, g: 0, b: 0, a: 1 },
+ weight: 2,
+ opacity: 1,
+ visible: true,
+ align: 'INSIDE' as const
+ }
]
})
const jsx = sceneNodeToJSX(node.id, graph)
diff --git a/tests/engine/fig-export-variables.test.ts b/tests/engine/fig-export-variables.test.ts
index 1d6ac178d..c84ee4477 100644
--- a/tests/engine/fig-export-variables.test.ts
+++ b/tests/engine/fig-export-variables.test.ts
@@ -1,11 +1,6 @@
import { describe, test, expect, beforeAll } from 'bun:test'
-import {
- exportFigFile,
- parseFigFile,
- initCodec,
- SceneGraph,
-} from '@open-pencil/core'
+import { exportFigFile, parseFigFile, initCodec, SceneGraph } from '@open-pencil/core'
beforeAll(async () => {
await initCodec()
@@ -24,7 +19,12 @@ describe('COLOR variable alpha handling', () => {
const vars = [...reimported.variables.values()]
const colorVar = vars.find((v) => v.name === 'brand')!
expect(colorVar.type).toBe('COLOR')
- const val = Object.values(colorVar.valuesByMode)[0] as { r: number; g: number; b: number; a: number }
+ const val = Object.values(colorVar.valuesByMode)[0] as {
+ r: number
+ g: number
+ b: number
+ a: number
+ }
expect(val.r).toBeCloseTo(0.2, 1)
expect(val.g).toBeCloseTo(0.4, 1)
expect(val.b).toBeCloseTo(0.8, 1)
@@ -41,7 +41,12 @@ describe('COLOR variable alpha handling', () => {
const vars = [...reimported.variables.values()]
const colorVar = vars.find((v) => v.name === 'overlay')!
- const val = Object.values(colorVar.valuesByMode)[0] as { r: number; g: number; b: number; a: number }
+ const val = Object.values(colorVar.valuesByMode)[0] as {
+ r: number
+ g: number
+ b: number
+ a: number
+ }
expect(val.a).toBeCloseTo(0.5, 1)
})
diff --git a/tests/engine/fig-export-worker.test.ts b/tests/engine/fig-export-worker.test.ts
index 27aee6ea4..37b42731d 100644
--- a/tests/engine/fig-export-worker.test.ts
+++ b/tests/engine/fig-export-worker.test.ts
@@ -9,6 +9,7 @@ import {
initCodec,
SceneGraph
} from '@open-pencil/core'
+
import { heavy } from '../helpers/test-utils'
setDefaultTimeout(30_000)
@@ -24,13 +25,7 @@ describe('fig export compression', () => {
const thumbnailPng = new Uint8Array([0x89, 0x50, 0x4e, 0x47])
const metaJson = JSON.stringify({ version: 1, app: 'test' })
- const result = compressFigDataSync(
- schemaDeflated,
- kiwiData,
- thumbnailPng,
- metaJson,
- []
- )
+ const result = compressFigDataSync(schemaDeflated, kiwiData, thumbnailPng, metaJson, [])
expect(result).toBeInstanceOf(Uint8Array)
expect(result.length).toBeGreaterThan(0)
@@ -45,17 +40,9 @@ describe('fig export compression', () => {
const kiwiData = new Uint8Array([10, 20, 30])
const thumbnailPng = new Uint8Array([0x89, 0x50])
const metaJson = JSON.stringify({ version: 1, app: 'test' })
- const images = [
- { name: 'images/abc123', data: new Uint8Array([0xff, 0xd8, 0xff, 0xe0]) }
- ]
-
- const result = compressFigDataSync(
- schemaDeflated,
- kiwiData,
- thumbnailPng,
- metaJson,
- images
- )
+ const images = [{ name: 'images/abc123', data: new Uint8Array([0xff, 0xd8, 0xff, 0xe0]) }]
+
+ const result = compressFigDataSync(schemaDeflated, kiwiData, thumbnailPng, metaJson, images)
expect(result).toBeInstanceOf(Uint8Array)
expect(result.length).toBeGreaterThan(0)
diff --git a/tests/engine/fig-import.test.ts b/tests/engine/fig-import.test.ts
index bc9e69655..1ec1a2fa0 100644
--- a/tests/engine/fig-import.test.ts
+++ b/tests/engine/fig-import.test.ts
@@ -10,7 +10,7 @@ function doc(): NodeChange {
visible: true,
opacity: 1,
phase: 'CREATED',
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange
}
@@ -23,14 +23,22 @@ function canvas(localID = 1): NodeChange {
visible: true,
opacity: 1,
phase: 'CREATED',
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange
}
-function node(type: string, localID: number, parentLocalID: number, overrides: Partial<NodeChange> = {}): NodeChange {
+function node(
+ type: string,
+ localID: number,
+ parentLocalID: number,
+ overrides: Partial<NodeChange> = {}
+): NodeChange {
return {
guid: { sessionID: 1, localID },
- parentIndex: { guid: { sessionID: 0, localID: parentLocalID }, position: String.fromCharCode(33 + localID) },
+ parentIndex: {
+ guid: { sessionID: 0, localID: parentLocalID },
+ position: String.fromCharCode(33 + localID)
+ },
type,
name: `${type}_${localID}`,
visible: true,
@@ -38,7 +46,7 @@ function node(type: string, localID: number, parentLocalID: number, overrides: P
phase: 'CREATED',
size: { x: 100, y: 100 },
transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- ...overrides,
+ ...overrides
} as NodeChange
}
@@ -94,19 +102,25 @@ describe('fig-import: transforms', () => {
describe('fig-import: gradient fills', () => {
test('linear gradient', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- fillPaints: [{
- type: 'GRADIENT_LINEAR',
- opacity: 1,
- visible: true,
- blendMode: 'NORMAL',
- stops: [
- { color: { r: 1, g: 0, b: 0, a: 1 }, position: 0 },
- { color: { r: 0, g: 0, b: 1, a: 1 }, position: 1 },
- ],
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- }] as unknown as NodeChange['fillPaints'],
- })])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ fillPaints: [
+ {
+ type: 'GRADIENT_LINEAR',
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL',
+ stops: [
+ { color: { r: 1, g: 0, b: 0, a: 1 }, position: 0 },
+ { color: { r: 0, g: 0, b: 1, a: 1 }, position: 1 }
+ ],
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
+ ] as unknown as NodeChange['fillPaints']
+ })
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.fills).toHaveLength(1)
expect(n.fills[0].type).toBe('GRADIENT_LINEAR')
@@ -117,19 +131,25 @@ describe('fig-import: gradient fills', () => {
})
test('radial gradient', () => {
- const graph = importNodeChanges([doc(), canvas(), node('ELLIPSE', 10, 1, {
- fillPaints: [{
- type: 'GRADIENT_RADIAL',
- opacity: 0.8,
- visible: true,
- blendMode: 'NORMAL',
- stops: [
- { color: { r: 1, g: 1, b: 1, a: 1 }, position: 0 },
- { color: { r: 0, g: 0, b: 0, a: 1 }, position: 1 },
- ],
- transform: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 },
- }] as unknown as NodeChange['fillPaints'],
- })])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('ELLIPSE', 10, 1, {
+ fillPaints: [
+ {
+ type: 'GRADIENT_RADIAL',
+ opacity: 0.8,
+ visible: true,
+ blendMode: 'NORMAL',
+ stops: [
+ { color: { r: 1, g: 1, b: 1, a: 1 }, position: 0 },
+ { color: { r: 0, g: 0, b: 0, a: 1 }, position: 1 }
+ ],
+ transform: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 }
+ }
+ ] as unknown as NodeChange['fillPaints']
+ })
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.fills[0].type).toBe('GRADIENT_RADIAL')
expect(n.fills[0].opacity).toBe(0.8)
@@ -142,17 +162,23 @@ describe('fig-import: image fills', () => {
const hash: Record<string, number> = {}
for (let i = 0; i < 20; i++) hash[String(i)] = i + 10
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- fillPaints: [{
- type: 'IMAGE',
- opacity: 1,
- visible: true,
- blendMode: 'NORMAL',
- image: { hash, name: 'test-image' },
- imageScaleMode: 'FILL',
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- }] as unknown as NodeChange['fillPaints'],
- })])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ fillPaints: [
+ {
+ type: 'IMAGE',
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL',
+ image: { hash, name: 'test-image' },
+ imageScaleMode: 'FILL',
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
+ ] as unknown as NodeChange['fillPaints']
+ })
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.fills[0].type).toBe('IMAGE')
expect(n.fills[0].imageHash).toBeDefined()
@@ -170,16 +196,22 @@ describe('fig-import: image fills', () => {
describe('fig-import: effects', () => {
test('drop shadow', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- effects: [{
- type: 'DROP_SHADOW',
- color: { r: 0, g: 0, b: 0, a: 0.25 },
- offset: { x: 4, y: 4 },
- radius: 8,
- spread: 0,
- visible: true,
- }] as unknown as NodeChange['effects'],
- })])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ effects: [
+ {
+ type: 'DROP_SHADOW',
+ color: { r: 0, g: 0, b: 0, a: 0.25 },
+ offset: { x: 4, y: 4 },
+ radius: 8,
+ spread: 0,
+ visible: true
+ }
+ ] as unknown as NodeChange['effects']
+ })
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.effects).toHaveLength(1)
expect(n.effects[0].type).toBe('DROP_SHADOW')
@@ -188,16 +220,22 @@ describe('fig-import: effects', () => {
})
test('inner shadow', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- effects: [{
- type: 'INNER_SHADOW',
- color: { r: 0, g: 0, b: 0, a: 0.5 },
- offset: { x: 0, y: 2 },
- radius: 4,
- spread: 0,
- visible: true,
- }] as unknown as NodeChange['effects'],
- })])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ effects: [
+ {
+ type: 'INNER_SHADOW',
+ color: { r: 0, g: 0, b: 0, a: 0.5 },
+ offset: { x: 0, y: 2 },
+ radius: 4,
+ spread: 0,
+ visible: true
+ }
+ ] as unknown as NodeChange['effects']
+ })
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.effects[0].type).toBe('INNER_SHADOW')
})
@@ -205,25 +243,49 @@ describe('fig-import: effects', () => {
describe('fig-import: stroke options', () => {
test('stroke cap and join', () => {
- const graph = importNodeChanges([doc(), canvas(), node('VECTOR', 10, 1, {
- strokePaints: [{ type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' }],
- strokeWeight: 3,
- strokeAlign: 'CENTER',
- strokeCap: 'ROUND',
- strokeJoin: 'BEVEL',
- } as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('VECTOR', 10, 1, {
+ strokePaints: [
+ {
+ type: 'SOLID',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ],
+ strokeWeight: 3,
+ strokeAlign: 'CENTER',
+ strokeCap: 'ROUND',
+ strokeJoin: 'BEVEL'
+ } as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.strokes[0].cap).toBe('ROUND')
expect(n.strokes[0].join).toBe('BEVEL')
})
test('dash pattern', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- strokePaints: [{ type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' }],
- strokeWeight: 2,
- strokeAlign: 'CENTER',
- dashPattern: [10, 5],
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ strokePaints: [
+ {
+ type: 'SOLID',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ],
+ strokeWeight: 2,
+ strokeAlign: 'CENTER',
+ dashPattern: [10, 5]
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.strokes[0].dashPattern).toEqual([10, 5])
})
@@ -231,12 +293,16 @@ describe('fig-import: stroke options', () => {
describe('fig-import: text properties', () => {
test('text auto resize', () => {
- const graph = importNodeChanges([doc(), canvas(), node('TEXT', 10, 1, {
- textData: { characters: 'Hello' },
- fontSize: 16,
- textAlignHorizontal: 'CENTER',
- textAutoResize: 'WIDTH_AND_HEIGHT',
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('TEXT', 10, 1, {
+ textData: { characters: 'Hello' },
+ fontSize: 16,
+ textAlignHorizontal: 'CENTER',
+ textAutoResize: 'WIDTH_AND_HEIGHT'
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.textAutoResize).toBe('WIDTH_AND_HEIGHT')
expect(n.textAlignHorizontal).toBe('CENTER')
@@ -251,14 +317,18 @@ describe('fig-import: text properties', () => {
['Black', 900],
['Thin', 100],
['Medium', 500],
- ['Regular', 400],
+ ['Regular', 400]
] as const
for (const [style, expected] of cases) {
- const graph = importNodeChanges([doc(), canvas(), node('TEXT', 10, 1, {
- textData: { characters: 'X' },
- fontName: { family: 'Inter', style },
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('TEXT', 10, 1, {
+ textData: { characters: 'X' },
+ fontName: { family: 'Inter', style }
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.fontWeight).toBe(expected)
}
@@ -267,13 +337,17 @@ describe('fig-import: text properties', () => {
describe('fig-import: arc data', () => {
test('partial ellipse', () => {
- const graph = importNodeChanges([doc(), canvas(), node('ELLIPSE', 10, 1, {
- arcData: {
- startingAngle: 0,
- endingAngle: Math.PI,
- innerRadius: 0,
- },
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('ELLIPSE', 10, 1, {
+ arcData: {
+ startingAngle: 0,
+ endingAngle: Math.PI,
+ innerRadius: 0
+ }
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.arcData).toBeDefined()
expect(n.arcData!.startingAngle).toBe(0)
@@ -282,13 +356,17 @@ describe('fig-import: arc data', () => {
})
test('donut (inner radius)', () => {
- const graph = importNodeChanges([doc(), canvas(), node('ELLIPSE', 10, 1, {
- arcData: {
- startingAngle: 0,
- endingAngle: Math.PI * 2,
- innerRadius: 0.5,
- },
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('ELLIPSE', 10, 1, {
+ arcData: {
+ startingAngle: 0,
+ endingAngle: Math.PI * 2,
+ innerRadius: 0.5
+ }
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.arcData!.innerRadius).toBe(0.5)
})
@@ -296,10 +374,14 @@ describe('fig-import: arc data', () => {
describe('fig-import: constraints', () => {
test('horizontal and vertical constraints', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- horizontalConstraint: 'STRETCH',
- verticalConstraint: 'CENTER',
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ horizontalConstraint: 'STRETCH',
+ verticalConstraint: 'CENTER'
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.horizontalConstraint).toBe('STRETCH')
expect(n.verticalConstraint).toBe('CENTER')
@@ -315,9 +397,13 @@ describe('fig-import: constraints', () => {
describe('fig-import: blend mode', () => {
test('node blend mode', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- blendMode: 'MULTIPLY',
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ blendMode: 'MULTIPLY'
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.blendMode).toBe('MULTIPLY')
})
@@ -331,13 +417,17 @@ describe('fig-import: blend mode', () => {
describe('fig-import: independent stroke weights', () => {
test('border weights imported', () => {
- const graph = importNodeChanges([doc(), canvas(), node('FRAME', 10, 1, {
- borderTopWeight: 2,
- borderRightWeight: 4,
- borderBottomWeight: 2,
- borderLeftWeight: 4,
- borderStrokeWeightsIndependent: true,
- } as unknown as Partial<NodeChange>)])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('FRAME', 10, 1, {
+ borderTopWeight: 2,
+ borderRightWeight: 4,
+ borderBottomWeight: 2,
+ borderLeftWeight: 4,
+ borderStrokeWeightsIndependent: true
+ } as unknown as Partial<NodeChange>)
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.borderTopWeight).toBe(2)
expect(n.borderRightWeight).toBe(4)
@@ -347,22 +437,32 @@ describe('fig-import: independent stroke weights', () => {
describe('fig-import: multiple fills', () => {
test('solid + gradient stacked', () => {
- const graph = importNodeChanges([doc(), canvas(), node('RECTANGLE', 10, 1, {
- fillPaints: [
- { type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' },
- {
- type: 'GRADIENT_LINEAR',
- opacity: 0.5,
- visible: true,
- blendMode: 'NORMAL',
- stops: [
- { color: { r: 1, g: 1, b: 1, a: 1 }, position: 0 },
- { color: { r: 0, g: 0, b: 0, a: 0 }, position: 1 },
- ],
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- },
- ] as unknown as NodeChange['fillPaints'],
- })])
+ const graph = importNodeChanges([
+ doc(),
+ canvas(),
+ node('RECTANGLE', 10, 1, {
+ fillPaints: [
+ {
+ type: 'SOLID',
+ color: { r: 1, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ },
+ {
+ type: 'GRADIENT_LINEAR',
+ opacity: 0.5,
+ visible: true,
+ blendMode: 'NORMAL',
+ stops: [
+ { color: { r: 1, g: 1, b: 1, a: 1 }, position: 0 },
+ { color: { r: 0, g: 0, b: 0, a: 0 }, position: 1 }
+ ],
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
+ ] as unknown as NodeChange['fillPaints']
+ })
+ ])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.fills).toHaveLength(2)
expect(n.fills[0].type).toBe('SOLID')
@@ -378,8 +478,8 @@ describe('fig-import: auto-layout alignment', () => {
canvas(),
node('FRAME', 10, 1, {
stackMode: 'HORIZONTAL',
- stackPrimaryAlignItems: 'SPACE_EVENLY',
- } as Partial<NodeChange>),
+ stackPrimaryAlignItems: 'SPACE_EVENLY'
+ } as Partial<NodeChange>)
])
const n = graph.getChildren(graph.getPages()[0].id)[0]
expect(n.primaryAxisAlign).toBe('SPACE_BETWEEN')
@@ -396,7 +496,7 @@ describe('fig-import: variable asset refs', () => {
name: 'Tokens',
key: 'collection-key',
version: '1:1',
- variableSetModes: [{ id: { sessionID: 10, localID: 1 }, name: 'Default' }],
+ variableSetModes: [{ id: { sessionID: 10, localID: 1 }, name: 'Default' }]
} as NodeChange,
{
...node('VARIABLE', 21, 1),
@@ -412,11 +512,11 @@ describe('fig-import: variable asset refs', () => {
variableData: {
dataType: 'COLOR',
resolvedDataType: 'COLOR',
- value: { colorValue: { r: 0.14, g: 0.39, b: 0.92, a: 1 } },
- },
- },
- ],
- },
+ value: { colorValue: { r: 0.14, g: 0.39, b: 0.92, a: 1 } }
+ }
+ }
+ ]
+ }
} as NodeChange,
{
...node('VARIABLE', 22, 1),
@@ -432,11 +532,11 @@ describe('fig-import: variable asset refs', () => {
variableData: {
dataType: 'ALIAS',
resolvedDataType: 'COLOR',
- value: { alias: { assetRef: { key: 'blue-key', version: '1:2' } } },
- },
- },
- ],
- },
+ value: { alias: { assetRef: { key: 'blue-key', version: '1:2' } } }
+ }
+ }
+ ]
+ }
} as NodeChange,
node('TEXT', 30, 1, {
textData: { characters: 'browse' },
@@ -447,11 +547,11 @@ describe('fig-import: variable asset refs', () => {
colorVar: {
value: { alias: { assetRef: { key: 'primary-key', version: '1:3' } } },
dataType: 'ALIAS',
- resolvedDataType: 'COLOR',
- },
- },
- ] as unknown as NodeChange['fillPaints'],
- }),
+ resolvedDataType: 'COLOR'
+ }
+ }
+ ] as unknown as NodeChange['fillPaints']
+ })
])
const primary = [...graph.variables.values()].find((v) => v.name === 'Primary')!
@@ -475,12 +575,18 @@ describe('fig-import: component set detection', () => {
{
...node('FRAME', 10, 1),
name: 'Button',
- componentPropDefs: [
- { id: { sessionID: 0, localID: 1 }, name: 'State', type: 'VARIANT' },
- ],
+ componentPropDefs: [{ id: { sessionID: 0, localID: 1 }, name: 'State', type: 'VARIANT' }]
} as unknown as NodeChange,
- { ...node('SYMBOL', 11, 1), parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' }, name: 'State=Default' } as NodeChange,
- { ...node('SYMBOL', 12, 1), parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '"' }, name: 'State=Hover' } as NodeChange,
+ {
+ ...node('SYMBOL', 11, 1),
+ parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '!' },
+ name: 'State=Default'
+ } as NodeChange,
+ {
+ ...node('SYMBOL', 12, 1),
+ parentIndex: { guid: { sessionID: 1, localID: 10 }, position: '"' },
+ name: 'State=Hover'
+ } as NodeChange
]
const graph = importNodeChanges(changes, [])
const page = graph.getPages()[0]
@@ -494,11 +600,7 @@ describe('fig-import: component set detection', () => {
})
test('FRAME without componentPropDefs stays FRAME', () => {
- const changes: NodeChange[] = [
- doc(),
- canvas(),
- node('FRAME', 10, 1, { name: 'Regular Frame' }),
- ]
+ const changes: NodeChange[] = [doc(), canvas(), node('FRAME', 10, 1, { name: 'Regular Frame' })]
const graph = importNodeChanges(changes, [])
const page = graph.getPages()[0]
const frame = graph.getChildren(page.id)[0]
@@ -509,8 +611,9 @@ describe('fig-import: component set detection', () => {
describe('fig-import: clipsContent with resizeToFit', () => {
test('regular FRAME with frameMaskDisabled=false clips content', () => {
const graph = importNodeChanges([
- doc(), canvas(),
- node('FRAME', 10, 1, { frameMaskDisabled: false }),
+ doc(),
+ canvas(),
+ node('FRAME', 10, 1, { frameMaskDisabled: false })
])
const frame = graph.getChildren(graph.getPages()[0].id)[0]
expect(frame.clipsContent).toBe(true)
@@ -518,8 +621,9 @@ describe('fig-import: clipsContent with resizeToFit', () => {
test('resizeToFit FRAME does not clip even with frameMaskDisabled=false', () => {
const graph = importNodeChanges([
- doc(), canvas(),
- node('FRAME', 10, 1, { frameMaskDisabled: false, resizeToFit: true }),
+ doc(),
+ canvas(),
+ node('FRAME', 10, 1, { frameMaskDisabled: false, resizeToFit: true })
])
const frame = graph.getChildren(graph.getPages()[0].id)[0]
expect(frame.clipsContent).toBe(false)
@@ -527,8 +631,9 @@ describe('fig-import: clipsContent with resizeToFit', () => {
test('FRAME with frameMaskDisabled=true does not clip', () => {
const graph = importNodeChanges([
- doc(), canvas(),
- node('FRAME', 10, 1, { frameMaskDisabled: true }),
+ doc(),
+ canvas(),
+ node('FRAME', 10, 1, { frameMaskDisabled: true })
])
const frame = graph.getChildren(graph.getPages()[0].id)[0]
expect(frame.clipsContent).toBe(false)
diff --git a/tests/engine/fig-roundtrip.test.ts b/tests/engine/fig-roundtrip.test.ts
index 746e09cb9..06fbad70f 100644
--- a/tests/engine/fig-roundtrip.test.ts
+++ b/tests/engine/fig-roundtrip.test.ts
@@ -12,8 +12,9 @@ import {
initCodec,
SceneGraph,
type SceneNode,
- type Fill,
+ type Fill
} from '@open-pencil/core'
+
import {
childMatching,
childNamed,
@@ -44,7 +45,7 @@ const VALID_NODE_TYPES = new Set<string>([
'COMPONENT_SET',
'INSTANCE',
'CONNECTOR',
- 'SHAPE_WITH_TEXT',
+ 'SHAPE_WITH_TEXT'
])
let parsed: SceneGraph
@@ -149,7 +150,9 @@ describe('derived instance layout regressions', () => {
const inline = childNamed(layoutGraph, list, 'Inline')
const icon = childNamed(layoutGraph, inline, 'Static Icon')
const content = childNamed(layoutGraph, inline, 'Content')
- const label = content ? layoutGraph.getChildren(content.id).find((node) => node.text) : undefined
+ const label = content
+ ? layoutGraph.getChildren(content.id).find((node) => node.text)
+ : undefined
expect(icon?.y).toBeCloseTo(0, 3)
expect(label?.y).toBeCloseTo(0, 3)
expect(icon?.height).toBeCloseTo(label?.height ?? 0, 3)
@@ -311,7 +314,6 @@ describe('property integrity', () => {
}
}
})
-
})
heavy('parse heavy .fig files', () => {
@@ -400,7 +402,7 @@ describe('roundtrip: export → re-import', () => {
graph.createNode('RECTANGLE', internalPage.id, {
name: 'Internal Rect',
width: 50,
- height: 50,
+ height: 50
})
graph.createNode('FRAME', page1.id, {
@@ -416,7 +418,15 @@ describe('roundtrip: export → re-import', () => {
paddingBottom: 24,
paddingLeft: 24,
cornerRadius: 12,
- fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' }],
+ fills: [
+ {
+ type: 'SOLID',
+ color: { r: 1, g: 1, b: 1, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ]
})
const container = graph.getChildren(page1.id)[0]
@@ -434,7 +444,13 @@ describe('roundtrip: export → re-import', () => {
bottomLeftRadius: 0,
independentCorners: true,
fills: [
- { type: 'SOLID', color: { r: 0.2, g: 0.4, b: 0.8, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' },
+ {
+ type: 'SOLID',
+ color: { r: 0.2, g: 0.4, b: 0.8, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ },
{
type: 'GRADIENT_LINEAR',
color: { r: 0, g: 0, b: 0, a: 0 },
@@ -443,14 +459,22 @@ describe('roundtrip: export → re-import', () => {
blendMode: 'NORMAL',
gradientStops: [
{ color: { r: 1, g: 1, b: 1, a: 1 }, position: 0 },
- { color: { r: 0, g: 0, b: 0, a: 0 }, position: 1 },
+ { color: { r: 0, g: 0, b: 0, a: 0 }, position: 1 }
],
- gradientTransform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- },
+ gradientTransform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
],
effects: [
- { type: 'DROP_SHADOW', color: { r: 0, g: 0, b: 0, a: 0.25 }, offset: { x: 0, y: 4 }, radius: 8, spread: 0, visible: true, blendMode: 'NORMAL' },
- ],
+ {
+ type: 'DROP_SHADOW',
+ color: { r: 0, g: 0, b: 0, a: 0.25 },
+ offset: { x: 0, y: 4 },
+ radius: 8,
+ spread: 0,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ]
})
graph.createNode('TEXT', container.id, {
@@ -463,7 +487,7 @@ describe('roundtrip: export → re-import', () => {
fontSize: 18,
fontFamily: 'Inter',
fontWeight: 700,
- textAlignHorizontal: 'CENTER',
+ textAlignHorizontal: 'CENTER'
})
graph.createNode('ELLIPSE', container.id, {
@@ -472,7 +496,15 @@ describe('roundtrip: export → re-import', () => {
y: 140,
width: 48,
height: 48,
- fills: [{ type: 'SOLID', color: { r: 0.9, g: 0.1, b: 0.3, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' }],
+ fills: [
+ {
+ type: 'SOLID',
+ color: { r: 0.9, g: 0.1, b: 0.3, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL'
+ }
+ ]
})
graph.createNode('RECTANGLE', page2.id, {
@@ -480,7 +512,7 @@ describe('roundtrip: export → re-import', () => {
x: 50,
y: 50,
width: 100,
- height: 100,
+ height: 100
})
const figBytes = await exportFigFile(graph)
@@ -618,7 +650,7 @@ describe('edge cases', () => {
visible: true,
opacity: 1,
phase: 'CREATED',
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
},
{
guid: { sessionID: 0, localID: 1 },
@@ -628,7 +660,7 @@ describe('edge cases', () => {
visible: true,
opacity: 1,
phase: 'CREATED',
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
},
{
guid: { sessionID: 1, localID: 10 },
@@ -639,7 +671,7 @@ describe('edge cases', () => {
opacity: 1,
phase: 'CREATED',
size: { x: 100, y: 100 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
},
{
guid: { sessionID: 1, localID: 11 },
@@ -650,8 +682,8 @@ describe('edge cases', () => {
opacity: 1,
phase: 'REMOVED',
size: { x: 100, y: 100 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+ }
])
const children = graph.getChildren(graph.getPages()[0].id)
expect(children).toHaveLength(1)
@@ -675,14 +707,14 @@ describe('edge cases', () => {
guid: { sessionID: 0, localID: 0 },
type: 'DOCUMENT',
name: 'Document',
- phase: 'CREATED',
+ phase: 'CREATED'
} as NodeChange,
{
guid: { sessionID: 0, localID: 1 },
parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
type: 'CANVAS',
name: 'Page',
- phase: 'CREATED',
+ phase: 'CREATED'
} as NodeChange,
// Inner component
{
@@ -692,7 +724,7 @@ describe('edge cases', () => {
name: 'Inner',
phase: 'CREATED',
size: { x: 100, y: 40 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
// TEXT child of Inner
{
@@ -704,7 +736,7 @@ describe('edge cases', () => {
textData: { characters: 'Default' },
phase: 'CREATED',
size: { x: 80, y: 20 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
// Outer component
{
@@ -714,7 +746,7 @@ describe('edge cases', () => {
name: 'Outer',
phase: 'CREATED',
size: { x: 200, y: 40 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
// INSTANCE of Inner inside Outer, with symbolOverride on Label
{
@@ -730,10 +762,10 @@ describe('edge cases', () => {
symbolOverrides: [
{
guidPath: { guids: [{ sessionID: 99, localID: 2 }] },
- textData: { characters: 'Changed' },
- },
- ],
- },
+ textData: { characters: 'Changed' }
+ }
+ ]
+ }
} as NodeChange,
// Top-level INSTANCE of Outer on the page
{
@@ -745,9 +777,9 @@ describe('edge cases', () => {
size: { x: 200, y: 40 },
transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
symbolData: {
- symbolID: { sessionID: 1, localID: 3 },
- },
- } as NodeChange,
+ symbolID: { sessionID: 1, localID: 3 }
+ }
+ } as NodeChange
])
const page = graph.getPages()[0]
@@ -780,14 +812,14 @@ describe('edge cases', () => {
guid: { sessionID: 0, localID: 0 },
type: 'DOCUMENT',
name: 'Document',
- phase: 'CREATED',
+ phase: 'CREATED'
} as NodeChange,
{
guid: { sessionID: 0, localID: 1 },
parentIndex: { guid: { sessionID: 0, localID: 0 }, position: '!' },
type: 'CANVAS',
name: 'Page',
- phase: 'CREATED',
+ phase: 'CREATED'
} as NodeChange,
// IconA component with 1 child
{
@@ -798,7 +830,7 @@ describe('edge cases', () => {
name: 'IconA',
phase: 'CREATED',
size: { x: 24, y: 24 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
{
guid: { sessionID: 1, localID: 2 },
@@ -808,7 +840,7 @@ describe('edge cases', () => {
name: 'PathA',
phase: 'CREATED',
size: { x: 24, y: 24 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
// IconB component with 2 children
{
@@ -819,7 +851,7 @@ describe('edge cases', () => {
name: 'IconB',
phase: 'CREATED',
size: { x: 24, y: 24 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
{
guid: { sessionID: 1, localID: 31 },
@@ -829,7 +861,7 @@ describe('edge cases', () => {
name: 'PathB1',
phase: 'CREATED',
size: { x: 24, y: 12 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
{
guid: { sessionID: 1, localID: 32 },
@@ -839,7 +871,7 @@ describe('edge cases', () => {
name: 'PathB2',
phase: 'CREATED',
size: { x: 24, y: 12 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
// Button component with instance of IconA
{
@@ -850,7 +882,7 @@ describe('edge cases', () => {
name: 'Button',
phase: 'CREATED',
size: { x: 40, y: 40 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
{
guid: { sessionID: 1, localID: 6 },
@@ -861,7 +893,7 @@ describe('edge cases', () => {
phase: 'CREATED',
size: { x: 24, y: 24 },
transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
- symbolData: { symbolID: { sessionID: 1, localID: 1 } },
+ symbolData: { symbolID: { sessionID: 1, localID: 1 } }
} as NodeChange,
// Toolbar component with instance of Button, swapping icon to IconB
{
@@ -872,7 +904,7 @@ describe('edge cases', () => {
name: 'Toolbar',
phase: 'CREATED',
size: { x: 200, y: 40 },
- transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
+ transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
} as NodeChange,
{
guid: { sessionID: 1, localID: 8 },
@@ -888,10 +920,10 @@ describe('edge cases', () => {
symbolOverrides: [
{
guidPath: { guids: [{ sessionID: 90, localID: 6 }] },
- overriddenSymbolID: { sessionID: 1, localID: 3 },
- },
- ],
- },
+ overriddenSymbolID: { sessionID: 1, localID: 3 }
+ }
+ ]
+ }
} as NodeChange,
// Page-level instance of Toolbar
{
@@ -903,9 +935,9 @@ describe('edge cases', () => {
size: { x: 200, y: 40 },
transform: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 },
symbolData: {
- symbolID: { sessionID: 1, localID: 7 },
- },
- } as NodeChange,
+ symbolID: { sessionID: 1, localID: 7 }
+ }
+ } as NodeChange
])
const page = graph.getPages()[0]
@@ -928,7 +960,9 @@ describe('edge cases', () => {
})
test('DSD propagates through intermediate clones that are also DSD-targeted', async () => {
- const graph = await parseFigFile(readFileSync(resolve(__dirname, '../fixtures/gold-preview.fig')).buffer)
+ const graph = await parseFigFile(
+ readFileSync(resolve(__dirname, '../fixtures/gold-preview.fig')).buffer
+ )
const thumb = [...graph.getAllNodes()].find((n) => n.name === 'Preview Thumbnail')
expect(thumb).toBeDefined()
@@ -948,7 +982,7 @@ describe('edge cases', () => {
vis = false
break
}
- cur = cur.parentId ? graph.getNode(cur.parentId) ?? null : null
+ cur = cur.parentId ? (graph.getNode(cur.parentId) ?? null) : null
}
// Check clipping
let clipped = false
@@ -958,7 +992,7 @@ describe('edge cases', () => {
clipped = true
break
}
- cur = cur.parentId ? graph.getNode(cur.parentId) ?? null : null
+ cur = cur.parentId ? (graph.getNode(cur.parentId) ?? null) : null
}
if (vis && !clipped && node.width > parent.width * 1.2) {
overflows++
@@ -1026,9 +1060,8 @@ describe('text node export', () => {
await initCodec()
const { unzipSync, inflateSync } = await import('fflate')
- const { decodeBinarySchema, compileSchema, ByteBuffer } = await import(
- '../../packages/core/src/kiwi/kiwi-schema'
- )
+ const { decodeBinarySchema, compileSchema, ByteBuffer } =
+ await import('../../packages/core/src/kiwi/kiwi-schema')
const { parseFigKiwiChunks } = await import('@open-pencil/core')
const graph = new SceneGraph()
@@ -1084,9 +1117,8 @@ describe('text node export', () => {
await initCodec()
const { unzipSync, inflateSync } = await import('fflate')
- const { decodeBinarySchema, compileSchema, ByteBuffer } = await import(
- '../../packages/core/src/kiwi/kiwi-schema'
- )
+ const { decodeBinarySchema, compileSchema, ByteBuffer } =
+ await import('../../packages/core/src/kiwi/kiwi-schema')
const { parseFigKiwiChunks } = await import('@open-pencil/core')
const graph = new SceneGraph()
@@ -1166,7 +1198,12 @@ describe('variable roundtrip', () => {
const vars = [...reimported.variables.values()]
const colorVar = vars.find((v) => v.name === 'color/primary')!
expect(colorVar.type).toBe('COLOR')
- const colorVal = Object.values(colorVar.valuesByMode)[0] as { r: number; g: number; b: number; a: number }
+ const colorVal = Object.values(colorVar.valuesByMode)[0] as {
+ r: number
+ g: number
+ b: number
+ a: number
+ }
expect(colorVal.r).toBeCloseTo(0.23, 1)
const floatVar = vars.find((v) => v.name === 'spacing/base')!
@@ -1194,7 +1231,7 @@ describe('variable roundtrip', () => {
name: 'Bound Rect',
width: 100,
height: 100,
- cornerRadius: 12,
+ cornerRadius: 12
})
graph.bindVariable(rect.id, 'cornerRadius', floatVar.id)
diff --git a/tests/engine/figma-api.test.ts b/tests/engine/figma-api.test.ts
index 263fab37b..c46ae03c4 100644
--- a/tests/engine/figma-api.test.ts
+++ b/tests/engine/figma-api.test.ts
@@ -478,7 +478,9 @@ describe('FigmaAPI', () => {
const frame = api.createFrame()
frame.name = 'Card'
frame.resize(300, 200)
- frame.fills = [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }]
+ frame.fills = [
+ { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }
+ ]
const json = frame.toJSON()
expect(json.name).toBe('Card')
expect(json.width).toBe(300)
@@ -579,7 +581,9 @@ describe('FigmaAPI', () => {
rect.fills = [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
const fills = rect.fills
expect(Object.isFrozen(fills)).toBe(true)
- expect(() => { (fills as Fill[]).push({} as Fill) }).toThrow()
+ expect(() => {
+ ;(fills as Fill[]).push({} as Fill)
+ }).toThrow()
})
test('mutating returned fills does not affect node', () => {
@@ -587,7 +591,9 @@ describe('FigmaAPI', () => {
const rect = api.createRectangle()
rect.fills = [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
const fills = rect.fills as Fill[]
- try { fills[0].color.r = 0 } catch {}
+ try {
+ fills[0].color.r = 0
+ } catch {}
expect(rect.fills[0].color.r).toBe(1)
})
})
@@ -637,7 +643,9 @@ describe('FigmaAPI', () => {
test('strokeWeight and strokeAlign', () => {
const api = createAPI()
const rect = api.createRectangle()
- rect.strokes = [{ color: { r: 0, g: 0, b: 0, a: 1 }, weight: 2, opacity: 1, visible: true, align: 'CENTER' }]
+ rect.strokes = [
+ { color: { r: 0, g: 0, b: 0, a: 1 }, weight: 2, opacity: 1, visible: true, align: 'CENTER' }
+ ]
expect(rect.strokeWeight).toBe(2)
expect(rect.strokeAlign).toBe('CENTER')
rect.strokeWeight = 4
@@ -682,7 +690,9 @@ describe('FigmaAPI', () => {
const api = createAPI()
const frame = api.createFrame()
frame.name = 'Original'
- frame.fills = [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
+ frame.fills = [
+ { type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }
+ ]
const child = api.createRectangle()
child.name = 'Child'
frame.appendChild(child)
@@ -909,7 +919,7 @@ describe('FigmaAPI', () => {
name: 'Colors',
modes: [{ modeId: 'mode1', name: 'Default' }],
defaultModeId: 'mode1',
- variableIds: [],
+ variableIds: []
})
api.graph.addVariable({
id: 'var1',
@@ -918,7 +928,7 @@ describe('FigmaAPI', () => {
collectionId: 'col1',
valuesByMode: { mode1: { r: 1, g: 0, b: 0, a: 1 } },
description: '',
- hiddenFromPublishing: false,
+ hiddenFromPublishing: false
})
expect(api.getLocalVariables().length).toBe(1)
expect(api.getLocalVariables('COLOR').length).toBe(1)
@@ -932,7 +942,7 @@ describe('FigmaAPI', () => {
name: 'Spacing',
modes: [{ modeId: 'mode1', name: 'Default' }],
defaultModeId: 'mode1',
- variableIds: [],
+ variableIds: []
})
api.graph.addVariable({
id: 'var1',
@@ -941,7 +951,7 @@ describe('FigmaAPI', () => {
collectionId: 'col1',
valuesByMode: { mode1: 8 },
description: '',
- hiddenFromPublishing: false,
+ hiddenFromPublishing: false
})
const v = api.getVariableById('var1')
expect(v).not.toBeNull()
@@ -956,7 +966,7 @@ describe('FigmaAPI', () => {
name: 'Colors',
modes: [{ modeId: 'mode1', name: 'Default' }],
defaultModeId: 'mode1',
- variableIds: [],
+ variableIds: []
})
const cols = api.getLocalVariableCollections()
expect(cols.length).toBe(1)
@@ -970,7 +980,7 @@ describe('FigmaAPI', () => {
name: 'Colors',
modes: [{ modeId: 'mode1', name: 'Default' }],
defaultModeId: 'mode1',
- variableIds: [],
+ variableIds: []
})
expect(api.getVariableCollectionById('col1')?.name).toBe('Colors')
expect(api.getVariableCollectionById('nonexistent')).toBeNull()
diff --git a/tests/engine/font-normalize-export.test.ts b/tests/engine/font-normalize-export.test.ts
index b2fc76f58..5e7901d40 100644
--- a/tests/engine/font-normalize-export.test.ts
+++ b/tests/engine/font-normalize-export.test.ts
@@ -1,11 +1,6 @@
import { describe, test, expect, beforeAll } from 'bun:test'
-import {
- exportFigFile,
- parseFigFile,
- initCodec,
- SceneGraph,
-} from '@open-pencil/core'
+import { exportFigFile, parseFigFile, initCodec, SceneGraph } from '@open-pencil/core'
beforeAll(async () => {
await initCodec()
@@ -27,7 +22,7 @@ describe('Font family normalization on .fig export', () => {
text: 'Hello',
fontFamily: 'DM Sans 9pt',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -49,7 +44,7 @@ describe('Font family normalization on .fig export', () => {
text: 'Hello',
fontFamily: 'Inter',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -71,7 +66,7 @@ describe('Font family normalization on .fig export', () => {
text: 'Hello',
fontFamily: 'Roboto Variable',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -95,7 +90,7 @@ describe('TEXT node default fill', () => {
text: 'Hello',
fontFamily: 'Inter',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -123,7 +118,7 @@ describe('TEXT node default fill', () => {
fontFamily: 'Inter',
fontWeight: 400,
fontSize: 14,
- fills: [{ type: 'SOLID', color: { r: 0.96, g: 0.72, b: 0, a: 1 }, opacity: 1, visible: true }],
+ fills: [{ type: 'SOLID', color: { r: 0.96, g: 0.72, b: 0, a: 1 }, opacity: 1, visible: true }]
})
const exported = await exportFigFile(graph)
@@ -144,7 +139,7 @@ describe('TEXT node default fill', () => {
x: 0,
y: 0,
width: 100,
- height: 100,
+ height: 100
})
expect(graph.getNode(node.id)!.fills.length).toBe(0)
})
diff --git a/tests/engine/fonts.test.ts b/tests/engine/fonts.test.ts
index 26a787f2f..37bbe0c0c 100644
--- a/tests/engine/fonts.test.ts
+++ b/tests/engine/fonts.test.ts
@@ -10,7 +10,7 @@ import {
styleToVariant,
styleToWeight,
weightToStyle,
- SceneGraph,
+ SceneGraph
} from '@open-pencil/core'
function pageId(graph: SceneGraph) {
@@ -84,7 +84,7 @@ describe('collectFontKeys', () => {
x: 0,
y: 0,
width: 100,
- height: 100,
+ height: 100
}).id
expect(collectFontKeys(graph, [id])).toEqual([])
})
@@ -99,7 +99,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'Hello',
fontFamily: 'Inter',
- fontWeight: 400,
+ fontWeight: 400
}).id
expect(collectFontKeys(graph, [id])).toEqual([['Inter', 'Regular']])
})
@@ -114,7 +114,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'Hello',
fontFamily: 'Roboto',
- fontWeight: 400,
+ fontWeight: 400
}).id
const keys = collectFontKeys(graph, [id])
expect(keys).toEqual([['Roboto', 'Regular']])
@@ -130,7 +130,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'Hello',
fontFamily: 'Roboto',
- fontWeight: 700,
+ fontWeight: 700
}).id
const keys = collectFontKeys(graph, [id])
expect(keys).toEqual([['Roboto', 'Bold']])
@@ -147,7 +147,7 @@ describe('collectFontKeys', () => {
text: 'Hello',
fontFamily: 'Roboto',
fontWeight: 400,
- italic: true,
+ italic: true
}).id
const keys = collectFontKeys(graph, [id])
expect(keys).toEqual([['Roboto', 'Regular Italic']])
@@ -164,7 +164,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'A',
fontFamily: 'Roboto',
- fontWeight: 400,
+ fontWeight: 400
})
graph.createNode('TEXT', page, {
name: 'B',
@@ -174,7 +174,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'B',
fontFamily: 'Roboto',
- fontWeight: 400,
+ fontWeight: 400
})
const ids = graph.getChildren(page).map((n) => n.id)
const keys = collectFontKeys(graph, ids)
@@ -192,7 +192,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'A',
fontFamily: 'Roboto',
- fontWeight: 400,
+ fontWeight: 400
})
graph.createNode('TEXT', page, {
name: 'B',
@@ -202,7 +202,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'B',
fontFamily: 'Open Sans',
- fontWeight: 700,
+ fontWeight: 700
})
const ids = graph.getChildren(page).map((n) => n.id)
const keys = collectFontKeys(graph, ids)
@@ -219,7 +219,7 @@ describe('collectFontKeys', () => {
x: 0,
y: 0,
width: 400,
- height: 400,
+ height: 400
}).id
graph.createNode('TEXT', frame, {
name: 'Nested',
@@ -229,7 +229,7 @@ describe('collectFontKeys', () => {
height: 20,
text: 'Hello',
fontFamily: 'Poppins',
- fontWeight: 600,
+ fontWeight: 600
})
const keys = collectFontKeys(graph, [frame])
expect(keys).toEqual([['Poppins', 'SemiBold']])
@@ -250,14 +250,14 @@ describe('collectFontKeys', () => {
{
start: 0,
end: 5,
- style: { fontFamily: 'Roboto', fontWeight: 400 },
+ style: { fontFamily: 'Roboto', fontWeight: 400 }
},
{
start: 6,
end: 11,
- style: { fontFamily: 'Montserrat', fontWeight: 700 },
- },
- ],
+ style: { fontFamily: 'Montserrat', fontWeight: 700 }
+ }
+ ]
}).id
const keys = collectFontKeys(graph, [id])
expect(keys).toHaveLength(2)
@@ -280,9 +280,9 @@ describe('collectFontKeys', () => {
{
start: 0,
end: 5,
- style: {},
- },
- ],
+ style: {}
+ }
+ ]
}).id
const keys = collectFontKeys(graph, [id])
expect(keys).toEqual([['Lato', 'Light']])
diff --git a/tests/engine/iconify.test.ts b/tests/engine/iconify.test.ts
index a8e5beb1c..47b3f945b 100644
--- a/tests/engine/iconify.test.ts
+++ b/tests/engine/iconify.test.ts
@@ -5,7 +5,9 @@ import { fetchIcon, fetchIcons, searchIcons, searchIconsBatch } from '@open-penc
let hasNetwork = true
beforeAll(async () => {
try {
- await fetch('https://api.iconify.design/mdi.json?icons=home', { signal: AbortSignal.timeout(3000) })
+ await fetch('https://api.iconify.design/mdi.json?icons=home', {
+ signal: AbortSignal.timeout(3000)
+ })
} catch {
hasNetwork = false
console.warn('⚠ Skipping iconify tests — no network')
@@ -13,7 +15,14 @@ beforeAll(async () => {
})
const networkTest: typeof test = (name, fn, timeout) =>
- test(name, async () => { if (!hasNetwork) return; await (fn as () => Promise<void>)() }, timeout)
+ test(
+ name,
+ async () => {
+ if (!hasNetwork) return
+ await (fn as () => Promise<void>)()
+ },
+ timeout
+ )
describe('fetchIcon', () => {
networkTest('fetches mdi:home', async () => {
@@ -60,7 +69,9 @@ describe('fetchIcon', () => {
})
networkTest('throws on non-existent icon', async () => {
- await expect(fetchIcon('mdi:this-icon-definitely-does-not-exist-xyz123')).rejects.toThrow('not found')
+ await expect(fetchIcon('mdi:this-icon-definitely-does-not-exist-xyz123')).rejects.toThrow(
+ 'not found'
+ )
})
networkTest('heroicons:eye — multi-path icon with group attrs', async () => {
diff --git a/tests/engine/image.test.ts b/tests/engine/image.test.ts
index 6abff3adc..fd4768de5 100644
--- a/tests/engine/image.test.ts
+++ b/tests/engine/image.test.ts
@@ -1,4 +1,5 @@
import { beforeAll, describe, expect, test } from 'bun:test'
+
import { unzipSync } from 'fflate'
import {
@@ -10,7 +11,7 @@ import {
parseOpenPencilClipboard,
parseFigFile,
SceneGraph,
- type SceneNode,
+ type SceneNode
} from '@open-pencil/core'
const PNG_MAGIC = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
@@ -64,15 +65,29 @@ describe('set_image_fill tool', () => {
test('sets an IMAGE fill with correct imageHash and scaleMode', () => {
const { figma } = setup()
const shape = ALL_TOOLS.find((t) => t.name === 'create_shape')!
- const node = shape.execute(figma, { type: 'RECTANGLE', x: 0, y: 0, width: 100, height: 100 }) as { id: string }
+ const node = shape.execute(figma, {
+ type: 'RECTANGLE',
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100
+ }) as { id: string }
const b64 = PNG_MAGIC.toBase64()
- const result = tool.execute(figma, { id: node.id, image_data: b64 }) as { id: string; imageHash: string; scaleMode: string }
+ const result = tool.execute(figma, { id: node.id, image_data: b64 }) as {
+ id: string
+ imageHash: string
+ scaleMode: string
+ }
expect(result.imageHash).toBeTruthy()
expect(result.scaleMode).toBe('FILL')
- const fills = figma.getNodeById(node.id)!.fills as Array<{ type: string; imageHash: string; imageScaleMode: string }>
+ const fills = figma.getNodeById(node.id)!.fills as Array<{
+ type: string
+ imageHash: string
+ imageScaleMode: string
+ }>
expect(fills).toHaveLength(1)
expect(fills[0].type).toBe('IMAGE')
expect(fills[0].imageHash).toBe(result.imageHash)
@@ -81,16 +96,22 @@ describe('set_image_fill tool', () => {
test('returns error for non-existent node', () => {
const { figma } = setup()
- const result = tool.execute(figma, { id: 'nonexistent', image_data: PNG_MAGIC.toBase64() }) as { error: string }
+ const result = tool.execute(figma, { id: 'nonexistent', image_data: PNG_MAGIC.toBase64() }) as {
+ error: string
+ }
expect(result.error).toContain('not found')
})
test('default scale mode is FILL', () => {
const { figma } = setup()
const shape = ALL_TOOLS.find((t) => t.name === 'create_shape')!
- const node = shape.execute(figma, { type: 'RECTANGLE', x: 0, y: 0, width: 50, height: 50 }) as { id: string }
+ const node = shape.execute(figma, { type: 'RECTANGLE', x: 0, y: 0, width: 50, height: 50 }) as {
+ id: string
+ }
- const result = tool.execute(figma, { id: node.id, image_data: PNG_MAGIC.toBase64() }) as { scaleMode: string }
+ const result = tool.execute(figma, { id: node.id, image_data: PNG_MAGIC.toBase64() }) as {
+ scaleMode: string
+ }
expect(result.scaleMode).toBe('FILL')
})
@@ -99,9 +120,19 @@ describe('set_image_fill tool', () => {
for (const mode of modes) {
const { figma } = setup()
const shape = ALL_TOOLS.find((t) => t.name === 'create_shape')!
- const node = shape.execute(figma, { type: 'RECTANGLE', x: 0, y: 0, width: 50, height: 50 }) as { id: string }
-
- const result = tool.execute(figma, { id: node.id, image_data: PNG_MAGIC.toBase64(), scale_mode: mode }) as { scaleMode: string }
+ const node = shape.execute(figma, {
+ type: 'RECTANGLE',
+ x: 0,
+ y: 0,
+ width: 50,
+ height: 50
+ }) as { id: string }
+
+ const result = tool.execute(figma, {
+ id: node.id,
+ image_data: PNG_MAGIC.toBase64(),
+ scale_mode: mode
+ }) as { scaleMode: string }
expect(result.scaleMode).toBe(mode)
const fills = figma.getNodeById(node.id)!.fills as Array<{ imageScaleMode: string }>
@@ -112,15 +143,24 @@ describe('set_image_fill tool', () => {
test('image data is stored in graph.images', () => {
const { graph, figma } = setup()
const shape = ALL_TOOLS.find((t) => t.name === 'create_shape')!
- const node = shape.execute(figma, { type: 'RECTANGLE', x: 0, y: 0, width: 50, height: 50 }) as { id: string }
+ const node = shape.execute(figma, { type: 'RECTANGLE', x: 0, y: 0, width: 50, height: 50 }) as {
+ id: string
+ }
- const result = tool.execute(figma, { id: node.id, image_data: PNG_MAGIC.toBase64() }) as { imageHash: string }
+ const result = tool.execute(figma, { id: node.id, image_data: PNG_MAGIC.toBase64() }) as {
+ imageHash: string
+ }
expect(graph.images.get(result.imageHash)).toEqual(PNG_MAGIC)
})
})
describe('clipboard roundtrip with images', () => {
- function graphWithImageNode(): { graph: SceneGraph; node: SceneNode; imageHash: string; imageBytes: Uint8Array } {
+ function graphWithImageNode(): {
+ graph: SceneGraph
+ node: SceneNode
+ imageHash: string
+ imageBytes: Uint8Array
+ } {
const graph = new SceneGraph()
const page = graph.getPages()[0]
const imageBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
@@ -131,14 +171,16 @@ describe('clipboard roundtrip with images', () => {
name: 'ImageRect',
width: 100,
height: 100,
- fills: [{
- type: 'IMAGE',
- color: { r: 0, g: 0, b: 0, a: 1 },
- opacity: 1,
- visible: true,
- imageHash: hash,
- imageScaleMode: 'FILL',
- }],
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash,
+ imageScaleMode: 'FILL'
+ }
+ ]
})
return { graph, node, imageHash: hash, imageBytes }
@@ -178,13 +220,33 @@ describe('clipboard roundtrip with images', () => {
const node1 = graph.createNode('RECTANGLE', page.id, {
name: 'Img1',
- width: 50, height: 50,
- fills: [{ type: 'IMAGE', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, imageHash: hash1, imageScaleMode: 'FILL' }],
+ width: 50,
+ height: 50,
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash1,
+ imageScaleMode: 'FILL'
+ }
+ ]
})
const node2 = graph.createNode('RECTANGLE', page.id, {
name: 'Img2',
- width: 50, height: 50,
- fills: [{ type: 'IMAGE', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, imageHash: hash2, imageScaleMode: 'FIT' }],
+ width: 50,
+ height: 50,
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash2,
+ imageScaleMode: 'FIT'
+ }
+ ]
})
const html = buildOpenPencilClipboardHTML([node1, node2], graph)
@@ -200,8 +262,9 @@ describe('clipboard roundtrip with images', () => {
const page = graph.getPages()[0]
const node = graph.createNode('RECTANGLE', page.id, {
name: 'Plain',
- width: 50, height: 50,
- fills: [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }],
+ width: 50,
+ height: 50,
+ fills: [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
})
const html = buildOpenPencilClipboardHTML([node], graph)
@@ -221,8 +284,18 @@ describe('clipboard roundtrip with images', () => {
const frame = graph.createNode('FRAME', page.id, { name: 'Parent', width: 200, height: 200 })
graph.createNode('RECTANGLE', frame.id, {
name: 'ChildImg',
- width: 50, height: 50,
- fills: [{ type: 'IMAGE', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, imageHash: hash, imageScaleMode: 'TILE' }],
+ width: 50,
+ height: 50,
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash,
+ imageScaleMode: 'TILE'
+ }
+ ]
})
const html = buildOpenPencilClipboardHTML([frame], graph)
@@ -248,8 +321,18 @@ describe('fig export/import with images', () => {
graph.createNode('RECTANGLE', page.id, {
name: 'ImageNode',
- width: 100, height: 100,
- fills: [{ type: 'IMAGE', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, imageHash: hash, imageScaleMode: 'FILL' }],
+ width: 100,
+ height: 100,
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash,
+ imageScaleMode: 'FILL'
+ }
+ ]
})
const zip = await exportFigFile(graph)
@@ -263,7 +346,8 @@ describe('fig export/import with images', () => {
const graph = new SceneGraph()
graph.createNode('RECTANGLE', graph.getPages()[0].id, {
name: 'Plain',
- width: 50, height: 50,
+ width: 50,
+ height: 50
})
const zip = await exportFigFile(graph)
@@ -284,12 +368,34 @@ describe('fig export/import with images', () => {
const { hash: hash2 } = figma.createImage(bytes2)
graph.createNode('RECTANGLE', page.id, {
- name: 'Img1', width: 100, height: 100,
- fills: [{ type: 'IMAGE', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, imageHash: hash1, imageScaleMode: 'FILL' }],
+ name: 'Img1',
+ width: 100,
+ height: 100,
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash1,
+ imageScaleMode: 'FILL'
+ }
+ ]
})
graph.createNode('ELLIPSE', page.id, {
- name: 'Img2', width: 80, height: 80,
- fills: [{ type: 'IMAGE', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, imageHash: hash2, imageScaleMode: 'FIT' }],
+ name: 'Img2',
+ width: 80,
+ height: 80,
+ fills: [
+ {
+ type: 'IMAGE',
+ color: { r: 0, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ imageHash: hash2,
+ imageScaleMode: 'FIT'
+ }
+ ]
})
const zip = await exportFigFile(graph)
diff --git a/tests/engine/individual-strokes.test.ts b/tests/engine/individual-strokes.test.ts
index 721cf5cc3..7bfd18cc8 100644
--- a/tests/engine/individual-strokes.test.ts
+++ b/tests/engine/individual-strokes.test.ts
@@ -6,11 +6,7 @@ function pageId(graph: SceneGraph) {
return graph.getPages()[0].id
}
-function rectWithStroke(
- graph: SceneGraph,
- name: string,
- strokeOverrides: Partial<Stroke> = {}
-) {
+function rectWithStroke(graph: SceneGraph, name: string, strokeOverrides: Partial<Stroke> = {}) {
const stroke: Stroke = {
color: { r: 0, g: 0, b: 0, a: 1 },
weight: 2,
diff --git a/tests/engine/instance-overrides.test.ts b/tests/engine/instance-overrides.test.ts
index a2853dec4..0ded9bff0 100644
--- a/tests/engine/instance-overrides.test.ts
+++ b/tests/engine/instance-overrides.test.ts
@@ -18,7 +18,7 @@ function nc(
guid: { sessionID, localID },
parentIndex: {
guid: { sessionID: parentSessionID, localID: parentLocalID },
- position: String.fromCharCode(33 + localID),
+ position: String.fromCharCode(33 + localID)
},
type,
name,
@@ -27,7 +27,7 @@ function nc(
phase: 'CREATED',
size: SIZE,
transform: ID,
- ...extra,
+ ...extra
} as NodeChange
}
@@ -64,7 +64,7 @@ function swapOverrideFixture(opts?: { customName?: string }): NodeChange[] {
// Button component containing an Icon instance pointing to IconA
nc(0, 30, 'COMPONENT', 0, 1, 'Button'),
nc(0, 31, 'INSTANCE', 0, 30, opts?.customName ?? 'IconA', {
- symbolData: { symbolID: guid(0, 10) },
+ symbolData: { symbolID: guid(0, 10) }
}),
// Visible-page instance of Button with a swap override: Icon→IconB
@@ -74,11 +74,11 @@ function swapOverrideFixture(opts?: { customName?: string }): NodeChange[] {
symbolOverrides: [
{
guidPath: { guids: [guid(0, 31)] },
- overriddenSymbolID: guid(0, 20),
- },
- ],
- },
- }),
+ overriddenSymbolID: guid(0, 20)
+ }
+ ]
+ }
+ })
]
}
@@ -121,7 +121,7 @@ describe('instance swap overrides', () => {
// Wrapper COMPONENT on internal page that contains a Button instance
nc(0, 50, 'COMPONENT', 0, 1, 'Wrapper'),
nc(0, 51, 'INSTANCE', 0, 50, 'ButtonInstance', {
- symbolData: { symbolID: guid(0, 30) },
+ symbolData: { symbolID: guid(0, 30) }
}),
// WrapperInstance on visible page with swap override on the button's icon
nc(0, 60, 'INSTANCE', 0, 2, 'WrapperInstance', {
@@ -130,11 +130,11 @@ describe('instance swap overrides', () => {
symbolOverrides: [
{
guidPath: { guids: [guid(0, 51), guid(0, 31)] },
- overriddenSymbolID: guid(0, 20),
- },
- ],
- },
- }),
+ overriddenSymbolID: guid(0, 20)
+ }
+ ]
+ }
+ })
]
const graph = importNodeChanges(nodes)
@@ -163,8 +163,8 @@ describe('instance swap overrides', () => {
...swapOverrideFixture(),
// Second ButtonInstance with NO swap override
nc(0, 41, 'INSTANCE', 0, 2, 'ButtonDefault', {
- symbolData: { symbolID: guid(0, 30) },
- }),
+ symbolData: { symbolID: guid(0, 30) }
+ })
]
const graph = importNodeChanges(nodes)
@@ -197,7 +197,7 @@ describe('instance swap overrides', () => {
// Button component: children = Icon INSTANCE→IconA
nc(0, 30, 'COMPONENT', 0, 1, 'Button'),
nc(0, 31, 'INSTANCE', 0, 30, 'IconA', {
- symbolData: { symbolID: guid(0, 10) },
+ symbolData: { symbolID: guid(0, 10) }
}),
// ButtonSwapped: instance of Button on internal page with swap
@@ -207,22 +207,22 @@ describe('instance swap overrides', () => {
symbolOverrides: [
{
guidPath: { guids: [guid(0, 31)] },
- overriddenSymbolID: guid(0, 20),
- },
- ],
- },
+ overriddenSymbolID: guid(0, 20)
+ }
+ ]
+ }
}),
// Container component on internal page wrapping ButtonSwapped
nc(0, 50, 'COMPONENT', 0, 1, 'Container'),
nc(0, 51, 'INSTANCE', 0, 50, 'ButtonSwapped', {
- symbolData: { symbolID: guid(0, 40) },
+ symbolData: { symbolID: guid(0, 40) }
}),
// Visible-page instance of Container
nc(0, 60, 'INSTANCE', 0, 2, 'ContainerInstance', {
- symbolData: { symbolID: guid(0, 50) },
- }),
+ symbolData: { symbolID: guid(0, 50) }
+ })
]
const graph = importNodeChanges(nodes)
diff --git a/tests/engine/kiwi-serialize-fixes.test.ts b/tests/engine/kiwi-serialize-fixes.test.ts
index ed3e6a94a..ee14454ea 100644
--- a/tests/engine/kiwi-serialize-fixes.test.ts
+++ b/tests/engine/kiwi-serialize-fixes.test.ts
@@ -5,7 +5,7 @@ import {
sceneNodeToKiwi,
exportFigFile,
parseFigFile,
- initCodec,
+ initCodec
} from '@open-pencil/core'
beforeAll(async () => {
@@ -41,7 +41,7 @@ describe('Fix 1: auto-layout child transforms', () => {
paddingTop: 16,
paddingLeft: 16,
paddingBottom: 16,
- paddingRight: 16,
+ paddingRight: 16
})
const child = graph.createNode('FRAME', parent.id, {
@@ -49,7 +49,7 @@ describe('Fix 1: auto-layout child transforms', () => {
x: 50,
y: 100,
width: 200,
- height: 60,
+ height: 60
})
const blobs: Uint8Array[] = []
@@ -79,7 +79,7 @@ describe('Fix 1: auto-layout child transforms', () => {
width: 300,
height: 400,
layoutMode: 'VERTICAL',
- itemSpacing: 8,
+ itemSpacing: 8
})
const absChild = graph.createNode('FRAME', parent.id, {
@@ -88,7 +88,7 @@ describe('Fix 1: auto-layout child transforms', () => {
y: 120,
width: 50,
height: 50,
- layoutPositioning: 'ABSOLUTE',
+ layoutPositioning: 'ABSOLUTE'
})
const blobs: Uint8Array[] = []
@@ -114,7 +114,7 @@ describe('Fix 1: auto-layout child transforms', () => {
x: 0,
y: 0,
width: 300,
- height: 400,
+ height: 400
// layoutMode defaults to 'NONE'
})
@@ -123,7 +123,7 @@ describe('Fix 1: auto-layout child transforms', () => {
x: 30,
y: 45,
width: 100,
- height: 80,
+ height: 80
})
const blobs: Uint8Array[] = []
@@ -151,7 +151,7 @@ describe('Fix 1: auto-layout child transforms', () => {
width: 600,
height: 100,
layoutMode: 'HORIZONTAL',
- itemSpacing: 12,
+ itemSpacing: 12
})
graph.createNode('RECTANGLE', parent.id, {
@@ -159,7 +159,7 @@ describe('Fix 1: auto-layout child transforms', () => {
x: 200,
y: 50,
width: 80,
- height: 80,
+ height: 80
})
const blobs: Uint8Array[] = []
@@ -190,7 +190,7 @@ describe('Fix 2: frameMaskDisabled is inverse of clipsContent', () => {
x: 0,
y: 0,
width: 100,
- height: 100,
+ height: 100
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -205,7 +205,7 @@ describe('Fix 2: frameMaskDisabled is inverse of clipsContent', () => {
y: 0,
width: 100,
height: 100,
- clipsContent: true,
+ clipsContent: true
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -220,7 +220,7 @@ describe('Fix 2: frameMaskDisabled is inverse of clipsContent', () => {
y: 0,
width: 100,
height: 100,
- clipsContent: false,
+ clipsContent: false
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -235,7 +235,7 @@ describe('Fix 2: frameMaskDisabled is inverse of clipsContent', () => {
y: 0,
width: 100,
height: 100,
- clipsContent: true,
+ clipsContent: true
})
const exported = await exportFigFile(graph)
@@ -261,7 +261,7 @@ describe('Fix 3: bordersTakeSpace serialization', () => {
height: 200,
layoutMode: 'VERTICAL',
itemSpacing: 8,
- strokesIncludedInLayout: true,
+ strokesIncludedInLayout: true
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -278,7 +278,7 @@ describe('Fix 3: bordersTakeSpace serialization', () => {
height: 200,
layoutMode: 'VERTICAL',
itemSpacing: 8,
- strokesIncludedInLayout: false,
+ strokesIncludedInLayout: false
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -293,7 +293,7 @@ describe('Fix 3: bordersTakeSpace serialization', () => {
y: 0,
width: 300,
height: 200,
- strokesIncludedInLayout: true,
+ strokesIncludedInLayout: true
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -318,7 +318,7 @@ describe('Fix 4: text lineHeight serialization', () => {
fontFamily: 'Inter',
fontWeight: 400,
fontSize: 16,
- lineHeight: 24,
+ lineHeight: 24
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -336,7 +336,7 @@ describe('Fix 4: text lineHeight serialization', () => {
text: 'Hello',
fontFamily: 'Inter',
fontWeight: 400,
- fontSize: 16,
+ fontSize: 16
// lineHeight not set — defaults to null
})
@@ -356,7 +356,7 @@ describe('Fix 4: text lineHeight serialization', () => {
text: 'Hello',
fontFamily: 'Inter',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -376,7 +376,7 @@ describe('Fix 4: text lineHeight serialization', () => {
fontFamily: 'Inter',
fontWeight: 400,
fontSize: 16,
- lineHeight: 28,
+ lineHeight: 28
})
const exported = await exportFigFile(graph)
@@ -403,7 +403,7 @@ describe('Fix 5: font family normalization in derivedTextData', () => {
text: 'Hello',
fontFamily: 'DM Sans 9pt',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -424,7 +424,7 @@ describe('Fix 5: font family normalization in derivedTextData', () => {
text: 'Hello',
fontFamily: 'Roboto Variable',
fontWeight: 700,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -445,7 +445,7 @@ describe('Fix 5: font family normalization in derivedTextData', () => {
text: 'Hello',
fontFamily: 'Inter',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const exported = await exportFigFile(graph)
@@ -466,7 +466,7 @@ describe('Fix 5: font family normalization in derivedTextData', () => {
text: 'Hello',
fontFamily: 'DM Sans 18px',
fontWeight: 400,
- fontSize: 14,
+ fontSize: 14
})
const changes = toKiwi(node, graph) as Record<string, any>[]
@@ -499,7 +499,7 @@ describe('Integration: auto-layout component with all fixes', () => {
counterAxisSizing: 'FIXED',
clipsContent: true,
strokesIncludedInLayout: true,
- fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }],
+ fills: [{ type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true }]
})
// Title text
@@ -513,7 +513,7 @@ describe('Integration: auto-layout component with all fixes', () => {
fontFamily: 'DM Sans 9pt',
fontWeight: 600,
fontSize: 14,
- lineHeight: 20,
+ lineHeight: 20
})
// Value text
@@ -527,7 +527,7 @@ describe('Integration: auto-layout component with all fixes', () => {
fontFamily: 'Inter',
fontWeight: 700,
fontSize: 32,
- lineHeight: 40,
+ lineHeight: 40
})
// Verify kiwi output directly
@@ -553,7 +553,7 @@ describe('Integration: auto-layout component with all fixes', () => {
// Fix 2: frameMaskDisabled is inverse of clipsContent
expect(cardNc.frameMaskDisabled).toBe(false) // clipsContent=true → frameMaskDisabled=false
- expect(titleNc.frameMaskDisabled).toBe(true) // text nodes don't clip
+ expect(titleNc.frameMaskDisabled).toBe(true) // text nodes don't clip
// Fix 3: bordersTakeSpace
expect(cardNc.bordersTakeSpace).toBe(true)
diff --git a/tests/engine/label-cache.test.ts b/tests/engine/label-cache.test.ts
index 4e70b0fa7..588716e60 100644
--- a/tests/engine/label-cache.test.ts
+++ b/tests/engine/label-cache.test.ts
@@ -1,4 +1,5 @@
import { describe, it, expect } from 'bun:test'
+
import { SceneGraph, LabelCache } from '@open-pencil/core'
function buildGraph() {
@@ -80,7 +81,13 @@ describe('LabelCache', () => {
cache.update(g, pageId, 1)
const before = cache.getSections(g, { x: -1000, y: -1000, w: 3000, h: 3000 })
- g.createNode('SECTION', pageId, { name: 'New Section', x: 500, y: 500, width: 100, height: 100 })
+ g.createNode('SECTION', pageId, {
+ name: 'New Section',
+ x: 500,
+ y: 500,
+ width: 100,
+ height: 100
+ })
cache.update(g, pageId, 2)
const after = cache.getSections(g, { x: -1000, y: -1000, w: 3000, h: 3000 })
diff --git a/tests/engine/layout.test.ts b/tests/engine/layout.test.ts
index beaf35635..ebd4c55e0 100644
--- a/tests/engine/layout.test.ts
+++ b/tests/engine/layout.test.ts
@@ -1,8 +1,17 @@
import { describe, test, expect } from 'bun:test'
-import { SceneGraph, type SceneNode, type GridTrack, computeLayout, computeAllLayouts, createEditor, setTextMeasurer, FigmaAPI, readFigFile } from '@open-pencil/core'
-
import { createEditorStore } from '@/app/editor/session'
+import {
+ SceneGraph,
+ type SceneNode,
+ type GridTrack,
+ computeLayout,
+ computeAllLayouts,
+ createEditor,
+ setTextMeasurer,
+ FigmaAPI,
+ readFigFile
+} from '@open-pencil/core'
function pageId(graph: SceneGraph) {
return graph.getPages()[0].id
@@ -19,7 +28,7 @@ function autoFrame(
counterAxisSizing: 'FIXED',
width: 400,
height: 200,
- ...overrides,
+ ...overrides
})
}
@@ -34,7 +43,7 @@ function rect(
name: 'Rect',
width: w,
height: h,
- ...overrides,
+ ...overrides
})
}
@@ -83,7 +92,7 @@ describe('Auto Layout', () => {
paddingTop: 10,
paddingRight: 20,
paddingBottom: 30,
- paddingLeft: 40,
+ paddingLeft: 40
})
rect(graph, frame.id, 50, 50)
@@ -99,7 +108,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
paddingLeft: 20,
paddingTop: 15,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 30)
rect(graph, frame.id, 50, 30)
@@ -215,7 +224,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
layoutMode: 'VERTICAL',
width: 200,
- height: 400,
+ height: 400
})
rect(graph, frame.id, 50, 80)
rect(graph, frame.id, 50, 60)
@@ -235,7 +244,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 200,
height: 400,
- itemSpacing: 16,
+ itemSpacing: 16
})
rect(graph, frame.id, 50, 40)
rect(graph, frame.id, 50, 40)
@@ -256,7 +265,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 100,
- primaryAxisAlign: 'CENTER',
+ primaryAxisAlign: 'CENTER'
})
rect(graph, frame.id, 100, 50)
@@ -271,7 +280,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 100,
- primaryAxisAlign: 'MAX',
+ primaryAxisAlign: 'MAX'
})
rect(graph, frame.id, 100, 50)
@@ -286,7 +295,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 100,
- primaryAxisAlign: 'SPACE_BETWEEN',
+ primaryAxisAlign: 'SPACE_BETWEEN'
})
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 50, 50)
@@ -306,7 +315,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 200,
height: 400,
- primaryAxisAlign: 'CENTER',
+ primaryAxisAlign: 'CENTER'
})
rect(graph, frame.id, 50, 100)
@@ -322,7 +331,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 200,
height: 400,
- primaryAxisAlign: 'MAX',
+ primaryAxisAlign: 'MAX'
})
rect(graph, frame.id, 50, 100)
@@ -339,7 +348,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'CENTER',
+ counterAxisAlign: 'CENTER'
})
rect(graph, frame.id, 50, 50)
@@ -354,7 +363,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'MAX',
+ counterAxisAlign: 'MAX'
})
rect(graph, frame.id, 50, 50)
@@ -370,7 +379,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 200,
height: 400,
- counterAxisAlign: 'CENTER',
+ counterAxisAlign: 'CENTER'
})
rect(graph, frame.id, 50, 50)
@@ -385,7 +394,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'STRETCH',
+ counterAxisAlign: 'STRETCH'
})
rect(graph, frame.id, 50, 50)
@@ -401,7 +410,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 200,
height: 400,
- counterAxisAlign: 'STRETCH',
+ counterAxisAlign: 'STRETCH'
})
rect(graph, frame.id, 50, 50)
@@ -420,7 +429,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'FIXED',
width: 999,
height: 100,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 70, 50)
@@ -439,7 +448,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'FIXED',
width: 200,
height: 999,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 40)
rect(graph, frame.id, 50, 60)
@@ -460,7 +469,7 @@ describe('Auto Layout', () => {
paddingTop: 10,
paddingRight: 20,
paddingBottom: 30,
- paddingLeft: 40,
+ paddingLeft: 40
})
rect(graph, frame.id, 100, 50)
@@ -475,7 +484,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 400,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 100, 50)
rect(graph, frame.id, 50, 50, { layoutGrow: 1 })
@@ -492,7 +501,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
layoutMode: 'VERTICAL',
width: 200,
- height: 400,
+ height: 400
})
rect(graph, frame.id, 50, 100)
rect(graph, frame.id, 50, 50, { layoutGrow: 1 })
@@ -508,7 +517,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 300,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 50, 50, { layoutGrow: 1 })
rect(graph, frame.id, 50, 50, { layoutGrow: 1 })
@@ -529,7 +538,7 @@ describe('Auto Layout', () => {
height: 100,
paddingLeft: 20,
paddingRight: 20,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 100, 50)
rect(graph, frame.id, 50, 50, { layoutGrow: 1 })
@@ -549,13 +558,13 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 50, 50, {
layoutPositioning: 'ABSOLUTE',
x: 200,
- y: 100,
+ y: 100
})
rect(graph, frame.id, 50, 50)
@@ -578,7 +587,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 300,
height: 100,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 50, { visible: false })
rect(graph, frame.id, 80, 40)
@@ -600,7 +609,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 100,
- itemSpacing: 20,
+ itemSpacing: 20
})
rect(graph, frame.id, 50, 50, { visible: false })
rect(graph, frame.id, 100, 50)
@@ -617,7 +626,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
primaryAxisSizing: 'HUG',
- counterAxisSizing: 'HUG',
+ counterAxisSizing: 'HUG'
})
rect(graph, frame.id, 200, 200, { visible: false })
rect(graph, frame.id, 50, 30)
@@ -634,14 +643,14 @@ describe('Auto Layout', () => {
const outer = autoFrame(graph, pageId(graph), {
width: 300,
height: 100,
- itemSpacing: 16,
+ itemSpacing: 16
})
const inner = autoFrame(graph, outer.id, {
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
width: 50,
height: 50,
- visible: false,
+ visible: false
})
rect(graph, inner.id, 30, 30)
rect(graph, outer.id, 80, 40)
@@ -662,7 +671,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'MIN',
+ counterAxisAlign: 'MIN'
})
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'STRETCH' })
rect(graph, frame.id, 50, 50)
@@ -681,14 +690,14 @@ describe('Auto Layout', () => {
const outer = autoFrame(graph, pageId(graph), {
width: 500,
height: 200,
- itemSpacing: 10,
+ itemSpacing: 10
})
const inner = autoFrame(graph, outer.id, {
primaryAxisSizing: 'HUG',
counterAxisSizing: 'FIXED',
width: 999,
height: 100,
- itemSpacing: 5,
+ itemSpacing: 5
})
rect(graph, inner.id, 40, 40)
rect(graph, inner.id, 60, 40)
@@ -709,7 +718,7 @@ describe('Auto Layout', () => {
const outer = autoFrame(graph, pageId(graph), {
width: 500,
height: 300,
- itemSpacing: 20,
+ itemSpacing: 20
})
const inner = autoFrame(graph, outer.id, {
layoutMode: 'VERTICAL',
@@ -717,7 +726,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'FIXED',
width: 100,
height: 999,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, inner.id, 80, 50)
rect(graph, inner.id, 80, 70)
@@ -740,7 +749,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 300,
height: 500,
- itemSpacing: 10,
+ itemSpacing: 10
})
const middle = autoFrame(graph, outer.id, {
layoutMode: 'HORIZONTAL',
@@ -748,7 +757,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'HUG',
width: 999,
height: 999,
- itemSpacing: 5,
+ itemSpacing: 5
})
rect(graph, middle.id, 40, 30)
rect(graph, middle.id, 60, 30)
@@ -772,7 +781,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 200,
height: 300,
- layoutWrap: 'WRAP',
+ layoutWrap: 'WRAP'
})
rect(graph, frame.id, 80, 40)
rect(graph, frame.id, 80, 40)
@@ -797,7 +806,7 @@ describe('Auto Layout', () => {
width: 200,
height: 300,
layoutWrap: 'WRAP',
- counterAxisSpacing: 10,
+ counterAxisSpacing: 10
})
rect(graph, frame.id, 120, 40)
rect(graph, frame.id, 120, 40)
@@ -815,7 +824,7 @@ describe('Auto Layout', () => {
width: 200,
height: 300,
layoutWrap: 'WRAP',
- itemSpacing: 10,
+ itemSpacing: 10
})
// 90 + 10 + 90 = 190, fits in 200
rect(graph, frame.id, 90, 40)
@@ -840,7 +849,7 @@ describe('Auto Layout', () => {
width: 300,
height: 100,
counterAxisSpacing: 50,
- layoutWrap: 'NO_WRAP',
+ layoutWrap: 'NO_WRAP'
})
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 50, 50)
@@ -861,7 +870,7 @@ describe('Auto Layout', () => {
name: 'Plain',
layoutMode: 'NONE',
width: 400,
- height: 200,
+ height: 200
})
const child = rect(graph, frame.id, 50, 50, { x: 100, y: 100 })
@@ -882,7 +891,7 @@ describe('Auto Layout', () => {
paddingTop: 10,
paddingRight: 20,
paddingBottom: 30,
- paddingLeft: 40,
+ paddingLeft: 40
})
computeLayout(graph, frame.id)
@@ -896,7 +905,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 200,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 50, 50)
@@ -917,7 +926,7 @@ describe('Auto Layout', () => {
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
- paddingLeft: 5,
+ paddingLeft: 5
})
rect(graph, frame.id, 100, 100, { layoutPositioning: 'ABSOLUTE' })
@@ -932,7 +941,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
primaryAxisSizing: 'HUG',
- counterAxisSizing: 'HUG',
+ counterAxisSizing: 'HUG'
})
rect(graph, frame.id, 0, 0)
rect(graph, frame.id, 50, 50)
@@ -955,7 +964,7 @@ describe('Auto Layout', () => {
width: 400,
height: 999,
primaryAxisSizing: 'FIXED',
- counterAxisSizing: 'HUG',
+ counterAxisSizing: 'HUG'
})
rect(graph, frame.id, 50, 80)
rect(graph, frame.id, 50, 120)
@@ -975,7 +984,7 @@ describe('Auto Layout', () => {
height: 999,
primaryAxisSizing: 'HUG',
counterAxisSizing: 'FIXED',
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 40)
rect(graph, frame.id, 80, 60)
@@ -994,7 +1003,7 @@ describe('Auto Layout', () => {
const outer = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, outer.id, 100, 50)
const inner = autoFrame(graph, outer.id, {
@@ -1002,7 +1011,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'FIXED',
width: 50,
height: 50,
- layoutGrow: 1,
+ layoutGrow: 1
})
rect(graph, inner.id, 30, 30)
@@ -1022,7 +1031,7 @@ describe('Auto Layout', () => {
height: 300,
layoutWrap: 'WRAP',
itemSpacing: 10,
- counterAxisSpacing: 20,
+ counterAxisSpacing: 20
})
// Each row: 90 + 10 + 90 = 190 <= 200
rect(graph, frame.id, 90, 40)
@@ -1050,7 +1059,7 @@ describe('Auto Layout', () => {
height: 200,
layoutWrap: 'WRAP',
itemSpacing: 10,
- counterAxisSpacing: 20,
+ counterAxisSpacing: 20
})
// Each column: 80 + 10 + 80 = 170 <= 200
rect(graph, frame.id, 40, 80)
@@ -1082,7 +1091,8 @@ describe('Auto Layout', () => {
)
const subtitle = [...store.graph.getAllNodes()].find(
(node) =>
- node.type === 'TEXT' && node.text === 'Preline UI Figma - crafted with Tailwind CSS styles'
+ node.type === 'TEXT' &&
+ node.text === 'Preline UI Figma - crafted with Tailwind CSS styles'
)
const description = [...store.graph.getAllNodes()].find(
(node) =>
@@ -1114,9 +1124,13 @@ describe('Auto Layout', () => {
test('imported nested instance layout keeps hidden sibling offsets stable', async () => {
const graph = await loadFixtureGraph('gold-preview.fig')
const previewRoot = graph.getChildren(graph.getPages()[0].id)[0]
- const wysiwygEditor = graph.getChildren(previewRoot.id).find((node) => node.name === '_WYSIWYG-editor')
+ const wysiwygEditor = graph
+ .getChildren(previewRoot.id)
+ .find((node) => node.name === '_WYSIWYG-editor')
const toolbarVariant = wysiwygEditor
- ? graph.getChildren(wysiwygEditor.id).find((node) => node.name === '_on-text-WYSIWYG-toolbar')
+ ? graph
+ .getChildren(wysiwygEditor.id)
+ .find((node) => node.name === '_on-text-WYSIWYG-toolbar')
: undefined
const toolbarRow = toolbarVariant
? graph.getChildren(toolbarVariant.id).find((node) => node.name === 'Toolbar')
@@ -1125,9 +1139,9 @@ describe('Auto Layout', () => {
? graph.getChildren(toolbarRow.id).find((node) => node.name === 'Input')
: undefined
const visibleToolbar = toolbarRow
- ? graph.getChildren(toolbarRow.id).find(
- (node) => node.name === 'Toolbar' && node.id !== toolbarRow.id
- )
+ ? graph
+ .getChildren(toolbarRow.id)
+ .find((node) => node.name === 'Toolbar' && node.id !== toolbarRow.id)
: undefined
if (!toolbarRow || !hiddenInput || !visibleToolbar) {
@@ -1156,7 +1170,7 @@ describe('Auto Layout', () => {
primaryAxisAlign: 'CENTER',
paddingLeft: 10,
paddingRight: 10,
- itemSpacing: 10,
+ itemSpacing: 10
})
const arrow1 = graph.createNode('FRAME', frame.id, { width: 20, height: 20 })
@@ -1165,7 +1179,7 @@ describe('Auto Layout', () => {
height: 20,
text: 'Test',
fontSize: 14,
- textAutoResize: 'WIDTH_AND_HEIGHT' as const,
+ textAutoResize: 'WIDTH_AND_HEIGHT' as const
})
const arrow2 = graph.createNode('FRAME', frame.id, { width: 20, height: 20 })
@@ -1203,7 +1217,7 @@ describe('Auto Layout', () => {
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
- primaryAxisAlign: 'CENTER',
+ primaryAxisAlign: 'CENTER'
})
graph.createNode('TEXT', frame.id, {
@@ -1211,7 +1225,7 @@ describe('Auto Layout', () => {
height: 20,
text: 'Test',
fontSize: 14,
- textAutoResize: 'WIDTH_AND_HEIGHT' as const,
+ textAutoResize: 'WIDTH_AND_HEIGHT' as const
})
setTextMeasurer(null)
@@ -1233,7 +1247,7 @@ describe('Auto Layout', () => {
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
- primaryAxisAlign: 'CENTER',
+ primaryAxisAlign: 'CENTER'
})
graph.createNode('TEXT', frame.id, {
@@ -1241,7 +1255,7 @@ describe('Auto Layout', () => {
height: 100,
text: 'Test',
fontSize: 14,
- textAutoResize: 'WIDTH_AND_HEIGHT' as const,
+ textAutoResize: 'WIDTH_AND_HEIGHT' as const
})
setTextMeasurer(null)
@@ -1264,7 +1278,7 @@ describe('Auto Layout', () => {
height: 400,
layoutMode: 'VERTICAL',
primaryAxisSizing: 'FIXED',
- counterAxisSizing: 'FIXED',
+ counterAxisSizing: 'FIXED'
})
graph.createNode('TEXT', frame.id, {
@@ -1273,7 +1287,7 @@ describe('Auto Layout', () => {
text: 'GDP Growth Exceeds Expectations at 3.1% in Q2 Report That Nobody Expected',
fontSize: 15,
lineHeight: 22,
- textAutoResize: 'HEIGHT' as const,
+ textAutoResize: 'HEIGHT' as const
})
setTextMeasurer(null)
@@ -1294,7 +1308,7 @@ describe('Auto Layout', () => {
height: 400,
layoutMode: 'VERTICAL',
primaryAxisSizing: 'FIXED',
- counterAxisSizing: 'FIXED',
+ counterAxisSizing: 'FIXED'
})
graph.createNode('TEXT', frame.id, {
@@ -1303,7 +1317,7 @@ describe('Auto Layout', () => {
text: 'GDP Growth Exceeds Expectations at 3.1% in Q2 Report That Nobody Expected',
fontSize: 15,
lineHeight: 22,
- textAutoResize: 'HEIGHT' as const,
+ textAutoResize: 'HEIGHT' as const
})
setTextMeasurer(null)
@@ -1325,7 +1339,7 @@ describe('Auto Layout', () => {
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
paddingLeft: 20,
- paddingRight: 20,
+ paddingRight: 20
})
const text = graph.createNode('TEXT', frame.id, {
@@ -1334,7 +1348,7 @@ describe('Auto Layout', () => {
text: 'This text should fill the parent width',
fontSize: 14,
textAutoResize: 'HEIGHT' as const,
- layoutAlignSelf: 'STRETCH' as const,
+ layoutAlignSelf: 'STRETCH' as const
})
setTextMeasurer((_node, maxWidth) => {
@@ -1359,7 +1373,7 @@ describe('Auto Layout', () => {
height: 200,
layoutMode: 'VERTICAL',
primaryAxisSizing: 'FIXED',
- counterAxisSizing: 'FIXED',
+ counterAxisSizing: 'FIXED'
})
const text = graph.createNode('TEXT', frame.id, {
@@ -1367,7 +1381,7 @@ describe('Auto Layout', () => {
height: 20,
text: 'Long text that should wrap within the available width',
fontSize: 14,
- textAutoResize: 'HEIGHT' as const,
+ textAutoResize: 'HEIGHT' as const
})
setTextMeasurer((_node, maxWidth) => {
@@ -1394,7 +1408,7 @@ describe('Auto Layout', () => {
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
counterAxisSizing: 'FIXED',
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 100, 50)
@@ -1405,7 +1419,7 @@ describe('Auto Layout', () => {
text: 'Wide text',
fontSize: 14,
textAutoResize: 'WIDTH_AND_HEIGHT' as const,
- layoutGrow: 1,
+ layoutGrow: 1
})
const receivedWidths: number[] = []
@@ -1433,7 +1447,7 @@ describe('Auto Layout', () => {
height: 100,
layoutMode: 'HORIZONTAL',
primaryAxisSizing: 'FIXED',
- counterAxisSizing: 'FIXED',
+ counterAxisSizing: 'FIXED'
})
const text = graph.createNode('TEXT', frame.id, {
@@ -1441,7 +1455,7 @@ describe('Auto Layout', () => {
height: 40,
text: 'Fixed text',
fontSize: 14,
- textAutoResize: 'NONE' as const,
+ textAutoResize: 'NONE' as const
})
let measureCalled = false
@@ -1465,7 +1479,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 400,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 50, 50, { layoutGrow: 1, maxWidth: 200 })
@@ -1479,7 +1493,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 100,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 200, 50, { minWidth: 150 })
@@ -1494,7 +1508,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
layoutMode: 'VERTICAL',
width: 200,
- height: 400,
+ height: 400
})
rect(graph, frame.id, 50, 50, { layoutGrow: 1, maxHeight: 150 })
@@ -1509,7 +1523,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
layoutMode: 'VERTICAL',
width: 200,
- height: 400,
+ height: 400
})
rect(graph, frame.id, 50, 30, { minHeight: 80 })
@@ -1523,7 +1537,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const outer = autoFrame(graph, pageId(graph), {
width: 500,
- height: 200,
+ height: 200
})
const inner = autoFrame(graph, outer.id, {
primaryAxisSizing: 'FIXED',
@@ -1531,7 +1545,7 @@ describe('Auto Layout', () => {
width: 50,
height: 50,
layoutGrow: 1,
- maxWidth: 250,
+ maxWidth: 250
})
rect(graph, inner.id, 30, 30)
@@ -1549,7 +1563,7 @@ describe('Auto Layout', () => {
width: 200,
height: 300,
layoutWrap: 'WRAP',
- counterAxisAlignContent: 'SPACE_BETWEEN' as const,
+ counterAxisAlignContent: 'SPACE_BETWEEN' as const
})
rect(graph, frame.id, 120, 40)
rect(graph, frame.id, 120, 40)
@@ -1571,7 +1585,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 200,
height: 300,
- layoutWrap: 'WRAP',
+ layoutWrap: 'WRAP'
})
rect(graph, frame.id, 120, 40)
rect(graph, frame.id, 120, 40)
@@ -1592,7 +1606,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'MIN',
+ counterAxisAlign: 'MIN'
})
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'CENTER' as const })
rect(graph, frame.id, 50, 50)
@@ -1609,7 +1623,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'MIN',
+ counterAxisAlign: 'MIN'
})
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'MAX' as const })
rect(graph, frame.id, 50, 50)
@@ -1626,7 +1640,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- counterAxisAlign: 'STRETCH',
+ counterAxisAlign: 'STRETCH'
})
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'MIN' as const })
rect(graph, frame.id, 50, 50)
@@ -1645,7 +1659,7 @@ describe('Auto Layout', () => {
layoutMode: 'VERTICAL',
width: 300,
height: 400,
- counterAxisAlign: 'MIN',
+ counterAxisAlign: 'MIN'
})
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'CENTER' as const })
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'MAX' as const })
@@ -1663,7 +1677,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 400,
- height: 100,
+ height: 100
})
const inner1 = autoFrame(graph, frame.id, {
@@ -1671,7 +1685,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'FIXED',
width: 100,
height: 50,
- layoutGrow: 1,
+ layoutGrow: 1
})
rect(graph, inner1.id, 100, 50)
@@ -1680,7 +1694,7 @@ describe('Auto Layout', () => {
counterAxisSizing: 'FIXED',
width: 200,
height: 50,
- layoutGrow: 1,
+ layoutGrow: 1
})
rect(graph, inner2.id, 200, 50)
@@ -1696,25 +1710,25 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 300,
height: 100,
- itemSpacing: 0,
+ itemSpacing: 0
})
autoFrame(graph, frame.id, {
primaryAxisSizing: 'FILL' as const,
counterAxisSizing: 'FIXED',
width: 50,
- height: 100,
+ height: 100
})
autoFrame(graph, frame.id, {
primaryAxisSizing: 'FILL' as const,
counterAxisSizing: 'FIXED',
width: 50,
- height: 100,
+ height: 100
})
autoFrame(graph, frame.id, {
primaryAxisSizing: 'FILL' as const,
counterAxisSizing: 'FIXED',
width: 50,
- height: 100,
+ height: 100
})
computeLayout(graph, frame.id)
@@ -1731,7 +1745,7 @@ describe('Auto Layout', () => {
const graph = new SceneGraph()
const frame = autoFrame(graph, pageId(graph), {
width: 300,
- height: 100,
+ height: 100
})
const child = rect(graph, frame.id, 80, 60)
@@ -1757,7 +1771,7 @@ describe('Auto Layout', () => {
width: 400,
height: 200,
primaryAxisSizing: 'HUG',
- counterAxisSizing: 'HUG',
+ counterAxisSizing: 'HUG'
})
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 100, 100, { layoutPositioning: 'ABSOLUTE', x: 300, y: 150 })
@@ -1781,7 +1795,7 @@ describe('Auto Layout', () => {
const frame = autoFrame(graph, pageId(graph), {
width: 400,
height: 200,
- itemSpacing: 10,
+ itemSpacing: 10
})
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 80, 40, { layoutPositioning: 'ABSOLUTE', x: 200, y: 100 })
@@ -1813,7 +1827,7 @@ function gridFrame(
gridTemplateRows: rows,
gridColumnGap: 0,
gridRowGap: 0,
- ...overrides,
+ ...overrides
})
}
@@ -1879,12 +1893,10 @@ describe('Grid Layout', () => {
test('unequal fr columns', () => {
const graph = new SceneGraph()
// 1fr + 2fr = 3fr total → 133.33px + 266.67px
- const frame = gridFrame(
- graph, pageId(graph),
- [fr(1), fr(2)],
- [fr()],
- { width: 300, height: 100 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr(1), fr(2)], [fr()], {
+ width: 300,
+ height: 100
+ })
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 50, 50)
@@ -1899,12 +1911,7 @@ describe('Grid Layout', () => {
describe('gaps', () => {
test('column gap', () => {
const graph = new SceneGraph()
- const frame = gridFrame(
- graph, pageId(graph),
- [fr(), fr()],
- [fr()],
- { gridColumnGap: 20 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr(), fr()], [fr()], { gridColumnGap: 20 })
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 50, 50)
@@ -1918,12 +1925,10 @@ describe('Grid Layout', () => {
test('row gap', () => {
const graph = new SceneGraph()
- const frame = gridFrame(
- graph, pageId(graph),
- [fr()],
- [fr(), fr()],
- { gridRowGap: 20, height: 200 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr()], [fr(), fr()], {
+ gridRowGap: 20,
+ height: 200
+ })
rect(graph, frame.id, 50, 50)
rect(graph, frame.id, 50, 50)
@@ -1937,12 +1942,12 @@ describe('Grid Layout', () => {
test('both column and row gaps', () => {
const graph = new SceneGraph()
- const frame = gridFrame(
- graph, pageId(graph),
- [fr(), fr()],
- [fr(), fr()],
- { gridColumnGap: 10, gridRowGap: 10, width: 210, height: 210 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr(), fr()], [fr(), fr()], {
+ gridColumnGap: 10,
+ gridRowGap: 10,
+ width: 210,
+ height: 210
+ })
for (let i = 0; i < 4; i++) rect(graph, frame.id, 30, 30)
computeLayout(graph, frame.id)
@@ -1963,12 +1968,12 @@ describe('Grid Layout', () => {
describe('padding', () => {
test('padding offsets grid content', () => {
const graph = new SceneGraph()
- const frame = gridFrame(
- graph, pageId(graph),
- [fr()],
- [fr()],
- { paddingTop: 10, paddingLeft: 20, paddingRight: 30, paddingBottom: 40 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr()], [fr()], {
+ paddingTop: 10,
+ paddingLeft: 20,
+ paddingRight: 30,
+ paddingBottom: 40
+ })
rect(graph, frame.id, 50, 50)
computeLayout(graph, frame.id)
@@ -1985,7 +1990,7 @@ describe('Grid Layout', () => {
const frame = gridFrame(graph, pageId(graph), [fr(), fr(), fr()], [fr(), fr()])
// Place in column 2, row 1 (0-indexed internally, but yoga uses 1-indexed)
rect(graph, frame.id, 50, 50, {
- gridPosition: { column: 2, row: 1, columnSpan: 1, rowSpan: 1 },
+ gridPosition: { column: 2, row: 1, columnSpan: 1, rowSpan: 1 }
})
computeLayout(graph, frame.id)
@@ -1998,14 +2003,12 @@ describe('Grid Layout', () => {
test('column span stretches across multiple columns', () => {
const graph = new SceneGraph()
- const frame = gridFrame(
- graph, pageId(graph),
- [fr(), fr(), fr()],
- [fr()],
- { width: 300, height: 100 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr(), fr(), fr()], [fr()], {
+ width: 300,
+ height: 100
+ })
rect(graph, frame.id, 50, 50, {
- gridPosition: { column: 1, row: 1, columnSpan: 2, rowSpan: 1 },
+ gridPosition: { column: 1, row: 1, columnSpan: 2, rowSpan: 1 }
})
computeLayout(graph, frame.id)
@@ -2018,14 +2021,12 @@ describe('Grid Layout', () => {
test('row span stretches across multiple rows', () => {
const graph = new SceneGraph()
- const frame = gridFrame(
- graph, pageId(graph),
- [fr()],
- [fr(), fr(), fr()],
- { width: 100, height: 300 },
- )
+ const frame = gridFrame(graph, pageId(graph), [fr()], [fr(), fr(), fr()], {
+ width: 100,
+ height: 300
+ })
rect(graph, frame.id, 50, 50, {
- gridPosition: { column: 1, row: 1, columnSpan: 1, rowSpan: 2 },
+ gridPosition: { column: 1, row: 1, columnSpan: 1, rowSpan: 2 }
})
computeLayout(graph, frame.id)
@@ -2079,7 +2080,7 @@ describe('Grid Layout', () => {
primaryAxisSizing: 'HUG',
counterAxisSizing: 'HUG',
width: 100,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 80, 80)
rect(graph, frame.id, 80, 80)
@@ -2103,10 +2104,13 @@ describe('Grid Layout', () => {
counterAxisSizing: 'FIXED',
width: maxChildW * cols,
height: maxChildH * rows,
- gridTemplateColumns: Array.from({ length: cols }, () => ({ sizing: 'FR' as const, value: 1 })),
+ gridTemplateColumns: Array.from({ length: cols }, () => ({
+ sizing: 'FR' as const,
+ value: 1
+ })),
gridTemplateRows: Array.from({ length: rows }, () => ({ sizing: 'FR' as const, value: 1 })),
gridColumnGap: 0,
- gridRowGap: 0,
+ gridRowGap: 0
})
computeLayout(graph, frame.id)
@@ -2135,11 +2139,11 @@ describe('Grid Layout', () => {
layoutMode: 'VERTICAL',
width: 400,
height: 600,
- itemSpacing: 10,
+ itemSpacing: 10
})
const inner = gridFrame(graph, outer.id, [fr(), fr()], [fr()], {
width: 380,
- height: 100,
+ height: 100
})
rect(graph, inner.id, 50, 50)
rect(graph, inner.id, 50, 50)
@@ -2162,7 +2166,7 @@ describe('Grid Layout', () => {
const graph = new SceneGraph()
const frame = gridFrame(graph, pageId(graph), [fr(), fr()], [fr()], {
width: 300,
- height: 100,
+ height: 100
})
rect(graph, frame.id, 50, 50, { layoutAlignSelf: 'STRETCH' as const })
rect(graph, frame.id, 50, 50)
@@ -2178,7 +2182,7 @@ describe('Grid Layout', () => {
const graph = new SceneGraph()
const frame = gridFrame(graph, pageId(graph), [fr(), fr()], [fr()], {
width: 400,
- height: 200,
+ height: 200
})
rect(graph, frame.id, 50, 50, { layoutGrow: 1 })
rect(graph, frame.id, 50, 50)
diff --git a/tests/engine/mcp-path-scoping.test.ts b/tests/engine/mcp-path-scoping.test.ts
index 758537384..c6b6343ea 100644
--- a/tests/engine/mcp-path-scoping.test.ts
+++ b/tests/engine/mcp-path-scoping.test.ts
@@ -43,8 +43,6 @@ describe('MCP path scoping', () => {
})
test('rejects root prefix trick (root-evil)', () => {
- expect(() => resolveSafePath(`${root}-evil/file.fig`, root)).toThrow(
- 'outside the allowed root'
- )
+ expect(() => resolveSafePath(`${root}-evil/file.fig`, root)).toThrow('outside the allowed root')
})
})
diff --git a/tests/engine/mcp-server.test.ts b/tests/engine/mcp-server.test.ts
index 3cef88d4b..e4c9d03f5 100644
--- a/tests/engine/mcp-server.test.ts
+++ b/tests/engine/mcp-server.test.ts
@@ -1,10 +1,11 @@
import { describe, expect, test, beforeEach, afterEach } from 'bun:test'
+import { startServer, paramToZod } from '#mcp/server'
+import { serve } from '@hono/node-server'
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
import WebSocket from 'ws'
-import { startServer, paramToZod } from '#mcp/server'
import {
ALL_TOOLS,
FigmaAPI,
@@ -12,7 +13,6 @@ import {
computeAllLayouts,
executeRpcCommand
} from '@open-pencil/core'
-import { serve } from '@hono/node-server'
import type { AddressInfo } from 'node:net'
@@ -57,12 +57,14 @@ function connectMockBrowser(port: number, graph: SceneGraph): Promise<MockBrowse
ws.send(JSON.stringify({ type: 'response', id: msg.id, ok: true, result }))
} catch (e) {
- ws.send(JSON.stringify({
- type: 'response',
- id: msg.id,
- ok: false,
- error: e instanceof Error ? e.message : String(e)
- }))
+ ws.send(
+ JSON.stringify({
+ type: 'response',
+ id: msg.id,
+ ok: false,
+ error: e instanceof Error ? e.message : String(e)
+ })
+ )
}
})
@@ -232,7 +234,11 @@ describe('MCP server', () => {
describe('MCP server with mcpRoot', () => {
test('registers open_file and new_document tools when mcpRoot is set', async () => {
- const { app, wss, close: closeServer } = startServer({ httpPort: 0, wsPort: 0, mcpRoot: '/tmp' })
+ const {
+ app,
+ wss,
+ close: closeServer
+ } = startServer({ httpPort: 0, wsPort: 0, mcpRoot: '/tmp' })
const httpServer = serve({ fetch: app.fetch, port: 0, hostname: '127.0.0.1' })
const actualWsPort = await waitForWsListening(wss)
@@ -296,7 +302,13 @@ describe('paramToZod coercion', () => {
})
test('number param respects min/max after coercion', () => {
- const schema = paramToZod({ type: 'number', description: 'x', required: true, min: 0, max: 100 })
+ const schema = paramToZod({
+ type: 'number',
+ description: 'x',
+ required: true,
+ min: 0,
+ max: 100
+ })
expect(schema.parse('50')).toBe(50)
expect(() => schema.parse('200')).toThrow()
expect(() => schema.parse('-1')).toThrow()
diff --git a/tests/engine/mcp.test.ts b/tests/engine/mcp.test.ts
index bd1731c63..5903a8ce0 100644
--- a/tests/engine/mcp.test.ts
+++ b/tests/engine/mcp.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, test } from 'bun:test'
+
import { ALL_TOOLS, FigmaAPI, SceneGraph, computeAllLayouts, parseFigFile } from '@open-pencil/core'
describe('MCP tool execution', () => {
@@ -37,7 +38,10 @@ describe('MCP tool execution', () => {
test('get_page_tree returns page hierarchy', () => {
const { api } = setup()
- const result = findTool('get_page_tree').execute(api, {}) as { page: string; children: unknown[] }
+ const result = findTool('get_page_tree').execute(api, {}) as {
+ page: string
+ children: unknown[]
+ }
expect(result.page).toBe('Page 1')
expect(result.children).toBeArray()
})
@@ -126,7 +130,9 @@ describe('MCP tool execution', () => {
parent_id: parent.id
}) as { id: string }
- const tree = findTool('get_page_tree').execute(api, {}) as { children: { id: string; children?: unknown[] }[] }
+ const tree = findTool('get_page_tree').execute(api, {}) as {
+ children: { id: string; children?: unknown[] }[]
+ }
const parentNode = tree.children.find((c: { id: string }) => c.id === parent.id)
expect(parentNode).toBeDefined()
expect(parentNode!.children).toBeArray()
@@ -148,9 +154,30 @@ describe('MCP tool execution', () => {
test('find_nodes filters by type', () => {
const { api } = setup()
- findTool('create_shape').execute(api, { type: 'FRAME', x: 0, y: 0, width: 100, height: 100, name: 'F1' })
- findTool('create_shape').execute(api, { type: 'RECTANGLE', x: 0, y: 0, width: 100, height: 100, name: 'R1' })
- findTool('create_shape').execute(api, { type: 'FRAME', x: 0, y: 0, width: 100, height: 100, name: 'F2' })
+ findTool('create_shape').execute(api, {
+ type: 'FRAME',
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ name: 'F1'
+ })
+ findTool('create_shape').execute(api, {
+ type: 'RECTANGLE',
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ name: 'R1'
+ })
+ findTool('create_shape').execute(api, {
+ type: 'FRAME',
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ name: 'F2'
+ })
const result = findTool('find_nodes').execute(api, { type: 'FRAME' }) as { count: number }
expect(result.count).toBe(2)
diff --git a/tests/engine/multi-selection.test.ts b/tests/engine/multi-selection.test.ts
index 597e897c7..8ef9764f7 100644
--- a/tests/engine/multi-selection.test.ts
+++ b/tests/engine/multi-selection.test.ts
@@ -247,7 +247,12 @@ describe('multi-node property merging', () => {
test('fills comparison detects same', () => {
const graph = new SceneGraph()
const page = pageId(graph)
- const fill = { type: 'SOLID' as const, color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }
+ const fill = {
+ type: 'SOLID' as const,
+ color: { r: 1, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true
+ }
const a = rect(graph, page)
const b = rect(graph, page)
diff --git a/tests/engine/mutation.test.ts b/tests/engine/mutation.test.ts
index e38bd38a5..b2baec9b0 100644
--- a/tests/engine/mutation.test.ts
+++ b/tests/engine/mutation.test.ts
@@ -6,15 +6,13 @@ import {
applyStyleToRange,
removeStyleFromRange,
getStyleAt,
- type StyleRun,
+ type StyleRun
} from '@open-pencil/core'
-
import {
encodeVectorNetworkBlob,
decodeVectorNetworkBlob,
- type VectorNetwork,
+ type VectorNetwork
} from '@open-pencil/core'
-
import { SceneGraph, UndoManager } from '@open-pencil/core'
// ---------------------------------------------------------------------------
@@ -111,12 +109,12 @@ describe('applyStyleToRange — split and merge', () => {
test('applying same style merges adjacent runs', () => {
const runs: StyleRun[] = [
{ start: 0, length: 3, style: { fontWeight: 700 } },
- { start: 5, length: 3, style: { fontWeight: 700 } },
+ { start: 5, length: 3, style: { fontWeight: 700 } }
]
// fill the gap between them
const result = applyStyleToRange(runs, 3, 5, { fontWeight: 700 }, 10)
// should compact into one run
- const bold700Count = result.filter(r => r.style.fontWeight === 700).length
+ const bold700Count = result.filter((r) => r.style.fontWeight === 700).length
expect(bold700Count).toBe(1)
expect(result[0].length).toBe(8)
})
@@ -165,12 +163,10 @@ describe('vectorNetworkBlob — precision and mirroring', () => {
const network: VectorNetwork = {
vertices: [
{ x: -123.456, y: -78.9, handleMirroring: 'NONE' },
- { x: -0.001, y: -999.999, handleMirroring: 'NONE' },
- ],
- segments: [
- { start: 0, end: 1, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } },
+ { x: -0.001, y: -999.999, handleMirroring: 'NONE' }
],
- regions: [],
+ segments: [{ start: 0, end: 1, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } }],
+ regions: []
}
const decoded = decodeVectorNetworkBlob(encodeVectorNetworkBlob(network))
expect(decoded.vertices[0].x).toBeCloseTo(-123.456, 2)
@@ -182,18 +178,24 @@ describe('vectorNetworkBlob — precision and mirroring', () => {
// ANGLE and ANGLE_AND_LENGTH are decoded as NONE — document this known limitation.
test('handleMirroring NONE round-trips; ANGLE decodes as NONE (known limitation)', () => {
const noneNetwork: VectorNetwork = {
- vertices: [{ x: 0, y: 0, handleMirroring: 'NONE' }, { x: 10, y: 0, handleMirroring: 'NONE' }],
+ vertices: [
+ { x: 0, y: 0, handleMirroring: 'NONE' },
+ { x: 10, y: 0, handleMirroring: 'NONE' }
+ ],
segments: [{ start: 0, end: 1, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } }],
- regions: [],
+ regions: []
}
const decodedNone = decodeVectorNetworkBlob(encodeVectorNetworkBlob(noneNetwork))
expect(decodedNone.vertices[0].handleMirroring).toBe('NONE')
// ANGLE is not persisted in blob — comes back as NONE
const angleNetwork: VectorNetwork = {
- vertices: [{ x: 0, y: 0, handleMirroring: 'ANGLE' }, { x: 10, y: 0, handleMirroring: 'ANGLE' }],
+ vertices: [
+ { x: 0, y: 0, handleMirroring: 'ANGLE' },
+ { x: 10, y: 0, handleMirroring: 'ANGLE' }
+ ],
segments: [{ start: 0, end: 1, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } }],
- regions: [],
+ regions: []
}
const decodedAngle = decodeVectorNetworkBlob(encodeVectorNetworkBlob(angleNetwork))
// This is a known limitation: handleMirroring is not stored in the blob format
@@ -204,12 +206,12 @@ describe('vectorNetworkBlob — precision and mirroring', () => {
const network: VectorNetwork = {
vertices: [
{ x: 0, y: 0, handleMirroring: 'ANGLE' },
- { x: 500, y: 500, handleMirroring: 'ANGLE' },
+ { x: 500, y: 500, handleMirroring: 'ANGLE' }
],
segments: [
- { start: 0, end: 1, tangentStart: { x: -200, y: 300 }, tangentEnd: { x: 150, y: -100 } },
+ { start: 0, end: 1, tangentStart: { x: -200, y: 300 }, tangentEnd: { x: 150, y: -100 } }
],
- regions: [],
+ regions: []
}
const decoded = decodeVectorNetworkBlob(encodeVectorNetworkBlob(network))
expect(decoded.segments[0].tangentStart.x).toBeCloseTo(-200, 1)
@@ -223,13 +225,13 @@ describe('vectorNetworkBlob — precision and mirroring', () => {
const vertices = Array.from({ length: n }, (_, i) => ({
x: i * 10,
y: i * 5,
- handleMirroring: 'NONE' as const,
+ handleMirroring: 'NONE' as const
}))
const segments = Array.from({ length: n - 1 }, (_, i) => ({
start: i,
end: i + 1,
tangentStart: { x: 0, y: 0 },
- tangentEnd: { x: 0, y: 0 },
+ tangentEnd: { x: 0, y: 0 }
}))
const network: VectorNetwork = { vertices, segments, regions: [] }
const decoded = decodeVectorNetworkBlob(encodeVectorNetworkBlob(network))
@@ -245,12 +247,10 @@ describe('vectorNetworkBlob — precision and mirroring', () => {
const network: VectorNetwork = {
vertices: [
{ x: 10, y: 20, handleMirroring: 'NONE' },
- { x: 30, y: 40, handleMirroring: 'ANGLE' },
- ],
- segments: [
- { start: 0, end: 1, tangentStart: { x: 5, y: 0 }, tangentEnd: { x: -5, y: 0 } },
+ { x: 30, y: 40, handleMirroring: 'ANGLE' }
],
- regions: [],
+ segments: [{ start: 0, end: 1, tangentStart: { x: 5, y: 0 }, tangentEnd: { x: -5, y: 0 } }],
+ regions: []
}
const a = encodeVectorNetworkBlob(network)
const b = encodeVectorNetworkBlob(network)
@@ -268,16 +268,20 @@ describe('SceneGraph + UndoManager — updateNode undo integration', () => {
const undo = new UndoManager()
const pageId = graph.getPages()[0].id
- function updateWithUndo(id: string, changes: Partial<Parameters<SceneGraph['updateNode']>[1]>, label: string) {
+ function updateWithUndo(
+ id: string,
+ changes: Partial<Parameters<SceneGraph['updateNode']>[1]>,
+ label: string
+ ) {
const node = graph.getNode(id)!
const previous = Object.fromEntries(
- (Object.keys(changes) as string[]).map(k => [k, (node as Record<string, unknown>)[k]])
+ (Object.keys(changes) as string[]).map((k) => [k, (node as Record<string, unknown>)[k]])
)
graph.updateNode(id, changes)
undo.push({
label,
forward: () => graph.updateNode(id, changes),
- inverse: () => graph.updateNode(id, previous as Parameters<SceneGraph['updateNode']>[1]),
+ inverse: () => graph.updateNode(id, previous as Parameters<SceneGraph['updateNode']>[1])
})
}
@@ -380,12 +384,12 @@ describe('SceneGraph + UndoManager — updateNode undo integration', () => {
undo.apply({
label: 'x',
forward: () => graph.updateNode(id, { x: 10 }),
- inverse: () => graph.updateNode(id, { x: 0 }),
+ inverse: () => graph.updateNode(id, { x: 0 })
})
undo.apply({
label: 'y',
forward: () => graph.updateNode(id, { y: 20 }),
- inverse: () => graph.updateNode(id, { y: 0 }),
+ inverse: () => graph.updateNode(id, { y: 0 })
})
undo.commitBatch()
diff --git a/tests/engine/nudge.test.ts b/tests/engine/nudge.test.ts
index dc451b12a..7440994a5 100644
--- a/tests/engine/nudge.test.ts
+++ b/tests/engine/nudge.test.ts
@@ -11,7 +11,7 @@ describe('nudgeSelected', () => {
x: 100,
y: 200,
width: 50,
- height: 50,
+ height: 50
})
editor.select([rect.id])
return { editor, rect }
@@ -86,7 +86,7 @@ describe('nudgeSelected', () => {
x: 300,
y: 400,
width: 50,
- height: 50,
+ height: 50
})
editor.select([rect.id, rect2.id])
diff --git a/tests/engine/okhcl-ui-logic.test.ts b/tests/engine/okhcl-ui-logic.test.ts
index 2b23aa2cf..d1ac610ea 100644
--- a/tests/engine/okhcl-ui-logic.test.ts
+++ b/tests/engine/okhcl-ui-logic.test.ts
@@ -1,6 +1,14 @@
import { describe, expect, test } from 'bun:test'
-import { clearNodeFillOkHCL, clearNodeStrokeOkHCL, getFillOkHCL, getStrokeOkHCL, SceneGraph, setNodeFillOkHCL, setNodeStrokeOkHCL } from '@open-pencil/core'
+import {
+ clearNodeFillOkHCL,
+ clearNodeStrokeOkHCL,
+ getFillOkHCL,
+ getStrokeOkHCL,
+ SceneGraph,
+ setNodeFillOkHCL,
+ setNodeStrokeOkHCL
+} from '@open-pencil/core'
describe('OkHCL metadata toggling', () => {
test('can disable fill OkHCL metadata', () => {
@@ -21,7 +29,9 @@ describe('OkHCL metadata toggling', () => {
const graph = new SceneGraph()
const page = graph.getPages()[0]
const node = graph.createNode('FRAME', page.id, {
- strokes: [{ color: { r: 0, g: 0, b: 1, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }]
+ strokes: [
+ { color: { r: 0, g: 0, b: 1, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }
+ ]
})
graph.updateNode(node.id, setNodeStrokeOkHCL(node, 0, { h: 200, c: 0.1, l: 0.5 }))
diff --git a/tests/engine/okhcl.test.ts b/tests/engine/okhcl.test.ts
index 8f846f5dc..54ae2e08f 100644
--- a/tests/engine/okhcl.test.ts
+++ b/tests/engine/okhcl.test.ts
@@ -35,7 +35,9 @@ describe('OkHCL metadata', () => {
const graph = new SceneGraph()
const api = new FigmaAPI(graph)
const frame = api.createFrame()
- frame.strokes = [{ color: { r: 0, g: 0, b: 0, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }]
+ frame.strokes = [
+ { color: { r: 0, g: 0, b: 0, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }
+ ]
frame.setStrokeOkHCL({ h: 20, c: 0.08, l: 0.6 })
@@ -65,12 +67,16 @@ describe('OkHCL metadata', () => {
const frame = api.createFrame()
frame.name = 'OKHCL frame'
frame.fills = [{ type: 'SOLID', visible: true, opacity: 1, color: { r: 0, g: 0, b: 0, a: 1 } }]
- frame.strokes = [{ color: { r: 0, g: 0, b: 0, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }]
+ frame.strokes = [
+ { color: { r: 0, g: 0, b: 0, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'INSIDE' }
+ ]
frame.setFillOkHCL({ h: 210, c: 0.1, l: 0.65 })
frame.setStrokeOkHCL({ h: 320, c: 0.09, l: 0.55, a: 0.9 })
const bytes = await exportFigFile(graph)
- const parsed = await parseFigFile(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength))
+ const parsed = await parseFigFile(
+ bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
+ )
const parsedFrame = [...parsed.getAllNodes()].find((node) => node.name === 'OKHCL frame')
expect(parsedFrame).toBeDefined()
diff --git a/tests/engine/pen-var-padding.test.ts b/tests/engine/pen-var-padding.test.ts
index bb7e35fa6..d94a2c0f0 100644
--- a/tests/engine/pen-var-padding.test.ts
+++ b/tests/engine/pen-var-padding.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, test } from 'bun:test'
import { applyPadding, isVarRef, type VarContext } from '@open-pencil/core/io/formats/pen'
+
import type { SceneNode } from '@open-pencil/core'
/**
@@ -18,12 +19,15 @@ function makeNode(): SceneNode {
paddingRight: 0,
paddingBottom: 0,
paddingLeft: 0,
- boundVariables: {},
+ boundVariables: {}
} as unknown as SceneNode
}
function makeVarContext(vars: Record<string, number>): VarContext {
- const byName = new Map<string, { id: string; variable: { valuesByMode: Record<string, number> } }>()
+ const byName = new Map<
+ string,
+ { id: string; variable: { valuesByMode: Record<string, number> } }
+ >()
for (const [name, value] of Object.entries(vars)) {
byName.set(name, { id: name, variable: { valuesByMode: { default: value } } })
}
@@ -40,14 +44,14 @@ function makeVarContext(vars: Record<string, number>): VarContext {
return typeof val === 'number' ? val : 0
},
resolveString: () => '',
- setActiveTheme: () => {},
+ setActiveTheme: () => {}
} as unknown as VarContext
}
const ctx = makeVarContext({
'--spacing-sm': 8,
'--spacing-md': 16,
- '--spacing-lg': 24,
+ '--spacing-lg': 24
})
describe('applyPadding — variable resolution (#201)', () => {
diff --git a/tests/engine/perf.bench.ts b/tests/engine/perf.bench.ts
index a1bbbe9c6..bd1a0948a 100644
--- a/tests/engine/perf.bench.ts
+++ b/tests/engine/perf.bench.ts
@@ -1,9 +1,10 @@
-import { bench, group, run } from 'mitata'
import { readFileSync } from 'fs'
import { resolve } from 'path'
-import { parseFigFile, exportFigFile, initCodec, SceneGraph } from '@open-pencil/core'
import { copyFills } from '#core/scene-graph/copy'
+import { bench, group, run } from 'mitata'
+
+import { parseFigFile, exportFigFile, initCodec, SceneGraph } from '@open-pencil/core'
const FIXTURES = resolve(import.meta.dir, '../fixtures')
@@ -78,8 +79,20 @@ group('SceneNode memory', () => {
group('structuredClone vs copy (fills)', () => {
const sampleFills = [
- { type: 'SOLID' as const, color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true, blendMode: 'NORMAL' as const },
- { type: 'SOLID' as const, color: { r: 0, g: 1, b: 0, a: 1 }, opacity: 0.5, visible: true, blendMode: 'NORMAL' as const }
+ {
+ type: 'SOLID' as const,
+ color: { r: 1, g: 0, b: 0, a: 1 },
+ opacity: 1,
+ visible: true,
+ blendMode: 'NORMAL' as const
+ },
+ {
+ type: 'SOLID' as const,
+ color: { r: 0, g: 1, b: 0, a: 1 },
+ opacity: 0.5,
+ visible: true,
+ blendMode: 'NORMAL' as const
+ }
]
bench('structuredClone × 10k', () => {
diff --git a/tests/engine/plugin-data.test.ts b/tests/engine/plugin-data.test.ts
index 2e303370d..ac6522c1e 100644
--- a/tests/engine/plugin-data.test.ts
+++ b/tests/engine/plugin-data.test.ts
@@ -36,7 +36,9 @@ describe('plugin data', () => {
frame.setSharedPluginData('tokens', 'accent', '{"ref":"brand/500"}')
const bytes = await exportFigFile(graph)
- const parsed = await parseFigFile(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength))
+ const parsed = await parseFigFile(
+ bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
+ )
const parsedFrame = [...parsed.getAllNodes()].find((node) => node.name === 'Plugin data frame')
expect(parsedFrame).toBeDefined()
@@ -55,8 +57,12 @@ describe('plugin data', () => {
test('preserves plugin relaunch data from imported fig files', async () => {
await initCodec()
const bytes = new Uint8Array(await Bun.file('./tests/fixtures/material3.fig').arrayBuffer())
- const graph = await parseFigFile(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength))
- const nodeWithRelaunch = [...graph.getAllNodes()].find((node) => node.pluginRelaunchData.length > 0)
+ const graph = await parseFigFile(
+ bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
+ )
+ const nodeWithRelaunch = [...graph.getAllNodes()].find(
+ (node) => node.pluginRelaunchData.length > 0
+ )
expect(nodeWithRelaunch).toBeDefined()
expect(nodeWithRelaunch?.pluginRelaunchData[0]).toMatchObject({
diff --git a/tests/engine/profiler.test.ts b/tests/engine/profiler.test.ts
index 78d2a6db3..f197a14d4 100644
--- a/tests/engine/profiler.test.ts
+++ b/tests/engine/profiler.test.ts
@@ -1,5 +1,13 @@
import { describe, it, expect } from 'bun:test'
-import { FrameStats, DrawCallCounter, PhaseTimer, GPUTimer, CaptureStack, toSpeedscopeJSON } from '@open-pencil/core'
+
+import {
+ FrameStats,
+ DrawCallCounter,
+ PhaseTimer,
+ GPUTimer,
+ CaptureStack,
+ toSpeedscopeJSON
+} from '@open-pencil/core'
describe('FrameStats', () => {
it('records frames and computes rolling averages', () => {
diff --git a/tests/engine/render-cache.test.ts b/tests/engine/render-cache.test.ts
index c4e1c7aac..21f24639a 100644
--- a/tests/engine/render-cache.test.ts
+++ b/tests/engine/render-cache.test.ts
@@ -3,6 +3,7 @@ import { readFileSync } from 'fs'
import { resolve } from 'path'
import { initCanvasKit } from '#cli/headless'
+
import {
computeAllLayouts,
initCodec,
diff --git a/tests/engine/render-text.test.ts b/tests/engine/render-text.test.ts
index 2ec43f509..46ef9e46a 100644
--- a/tests/engine/render-text.test.ts
+++ b/tests/engine/render-text.test.ts
@@ -1,17 +1,20 @@
import { describe, test, expect, mock } from 'bun:test'
-import { renderText } from '#core/canvas/scene'
-import type { SceneNode } from '#core/scene-graph'
-import type { SkiaRenderer } from '#core/canvas/renderer'
+
import { initCanvasKit } from '#cli/headless'
-import { SceneGraph, SkiaRenderer as SkiaRendererClass } from '@open-pencil/core'
+import { renderText } from '#core/canvas/scene'
import {
initFontService,
setArabicFallbackFamily,
setCJKFallbackFamily,
markFontLoaded
} from '#core/text/fonts'
+
+import { SceneGraph, SkiaRenderer as SkiaRendererClass } from '@open-pencil/core'
import { detectTextDirection, resolveTextDirection } from '@open-pencil/core'
+import type { SkiaRenderer } from '#core/canvas/renderer'
+import type { SceneNode } from '#core/scene-graph'
+
function createMockCanvas() {
return {
drawParagraph: mock(() => {}),
@@ -134,7 +137,8 @@ describe('renderText headless visual', () => {
fontProvider.registerFont(interData, 'Inter')
markFontLoaded('Inter', 'Regular', interData)
- const notoPath = new URL('../../tests/fixtures/fonts/NotoSansSC-Regular.ttf', import.meta.url).pathname
+ const notoPath = new URL('../../tests/fixtures/fonts/NotoSansSC-Regular.ttf', import.meta.url)
+ .pathname
const notoData = await Bun.file(notoPath).arrayBuffer()
fontProvider.registerFont(notoData, 'Noto Sans SC')
setCJKFallbackFamily('Noto Sans SC')
diff --git a/tests/engine/render.test.ts b/tests/engine/render.test.ts
index 0c98651b4..d7074ffc7 100644
--- a/tests/engine/render.test.ts
+++ b/tests/engine/render.test.ts
@@ -1,7 +1,5 @@
import { describe, expect, it } from 'bun:test'
-import { makeSceneGraph } from '../helpers/scene'
-
import {
renderTree,
renderJSX,
@@ -21,6 +19,8 @@ import {
node
} from '@open-pencil/core'
+import { makeSceneGraph } from '../helpers/scene'
+
describe('TreeNode builders', () => {
it('creates Frame tree node', () => {
const tree = Frame({ name: 'Card', w: 320, h: 200, bg: '#FFF' })
@@ -85,7 +85,13 @@ describe('renderTree', () => {
it('renders text node with content', async () => {
const g = makeSceneGraph()
- const tree = Text({ name: 'Heading', size: 24, weight: 'bold', color: '#111', children: 'Hello' })
+ const tree = Text({
+ name: 'Heading',
+ size: 24,
+ weight: 'bold',
+ color: '#111',
+ children: 'Hello'
+ })
const result = await renderTree(g, tree)
const node = g.nodes.get(result.id)!
@@ -371,7 +377,8 @@ describe('renderJSX (string → scene graph)', () => {
describe('grid layout rendering', () => {
it('creates grid frame with template columns', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr' },
+ const tree = Frame(
+ { name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr' },
Rectangle({ name: 'A', w: 50, h: 50 }),
Rectangle({ name: 'B', w: 50, h: 50 }),
Rectangle({ name: 'C', w: 50, h: 50 })
@@ -415,7 +422,15 @@ describe('grid layout rendering', () => {
it('sets grid gaps', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr', columnGap: 10, rowGap: 20 })
+ const tree = Frame({
+ name: 'Grid',
+ w: 300,
+ h: 200,
+ grid: true,
+ columns: '1fr 1fr',
+ columnGap: 10,
+ rowGap: 20
+ })
const result = await renderTree(g, tree)
const frame = g.nodes.get(result.id)!
@@ -447,7 +462,14 @@ describe('grid layout rendering', () => {
it('sets grid rows', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr', rows: '100 1fr' })
+ const tree = Frame({
+ name: 'Grid',
+ w: 300,
+ h: 200,
+ grid: true,
+ columns: '1fr',
+ rows: '100 1fr'
+ })
const result = await renderTree(g, tree)
const frame = g.nodes.get(result.id)!
@@ -459,7 +481,8 @@ describe('grid layout rendering', () => {
it('sets grid child position', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr', rows: '1fr 1fr' },
+ const tree = Frame(
+ { name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr', rows: '1fr 1fr' },
Rectangle({ name: 'A', w: 50, h: 50, colStart: 2, rowStart: 1 })
)
const result = await renderTree(g, tree)
@@ -470,7 +493,8 @@ describe('grid layout rendering', () => {
it('sets grid child span', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr', rows: '1fr 1fr' },
+ const tree = Frame(
+ { name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr', rows: '1fr 1fr' },
Rectangle({ name: 'A', w: 50, h: 50, colStart: 1, colSpan: 2, rowStart: 1, rowSpan: 2 })
)
const result = await renderTree(g, tree)
@@ -481,7 +505,8 @@ describe('grid layout rendering', () => {
it('grid + computeLayout positions children in cells', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr', rows: '1fr' },
+ const tree = Frame(
+ { name: 'Grid', w: 300, h: 200, grid: true, columns: '1fr 1fr 1fr', rows: '1fr' },
Rectangle({ name: 'A', w: 50, h: 50 }),
Rectangle({ name: 'B', w: 50, h: 50 }),
Rectangle({ name: 'C', w: 50, h: 50 })
@@ -497,7 +522,8 @@ describe('grid layout rendering', () => {
it('grid 2x2 with gap positions correctly', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 210, h: 210, grid: true, columns: '1fr 1fr', rows: '1fr 1fr', gap: 10 },
+ const tree = Frame(
+ { name: 'Grid', w: 210, h: 210, grid: true, columns: '1fr 1fr', rows: '1fr 1fr', gap: 10 },
Rectangle({ name: 'A', w: 30, h: 30 }),
Rectangle({ name: 'B', w: 30, h: 30 }),
Rectangle({ name: 'C', w: 30, h: 30 }),
@@ -544,7 +570,8 @@ describe('grid layout rendering', () => {
it('grid auto-height (no rows) grows to fit content', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, grid: true, columns: '1fr 1fr', gap: 10 },
+ const tree = Frame(
+ { name: 'Grid', w: 300, grid: true, columns: '1fr 1fr', gap: 10 },
Rectangle({ name: 'A', w: 50, h: 80 }),
Rectangle({ name: 'B', w: 50, h: 80 }),
Rectangle({ name: 'C', w: 50, h: 60 }),
@@ -561,13 +588,22 @@ describe('grid layout rendering', () => {
it('grid children with flex stretch to cell width', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 200, grid: true, columns: '1fr 1fr', gap: 0 },
- Frame({ name: 'A', flex: 'col', gap: 4, p: 8, children: [
- Rectangle({ name: 'R1', w: 10, h: 20 })
- ]}),
- Frame({ name: 'B', flex: 'col', gap: 4, p: 8, children: [
- Rectangle({ name: 'R2', w: 10, h: 20 })
- ]})
+ const tree = Frame(
+ { name: 'Grid', w: 200, grid: true, columns: '1fr 1fr', gap: 0 },
+ Frame({
+ name: 'A',
+ flex: 'col',
+ gap: 4,
+ p: 8,
+ children: [Rectangle({ name: 'R1', w: 10, h: 20 })]
+ }),
+ Frame({
+ name: 'B',
+ flex: 'col',
+ gap: 4,
+ p: 8,
+ children: [Rectangle({ name: 'R2', w: 10, h: 20 })]
+ })
)
const result = await renderTree(g, tree)
computeAllLayouts(g)
@@ -581,7 +617,8 @@ describe('grid layout rendering', () => {
it('grid prop takes precedence over padding-triggered auto-layout', async () => {
const g = makeSceneGraph()
- const tree = Frame({ name: 'Grid', w: 300, grid: true, columns: '1fr 1fr', p: 20 },
+ const tree = Frame(
+ { name: 'Grid', w: 300, grid: true, columns: '1fr 1fr', p: 20 },
Rectangle({ name: 'A', w: 50, h: 50 }),
Rectangle({ name: 'B', w: 50, h: 50 })
)
@@ -602,7 +639,7 @@ describe('grid layout rendering', () => {
`
const [result] = await renderJSX(g, jsx)
computeAllLayouts(g)
- const grid = g.getChildren(result.id).find(c => c.name === 'G')!
+ const grid = g.getChildren(result.id).find((c) => c.name === 'G')!
expect(grid.width).toBe(360)
expect(grid.layoutMode).toBe('GRID')
})
@@ -620,7 +657,7 @@ describe('grid layout rendering', () => {
`
const [result] = await renderJSX(g, jsx)
computeAllLayouts(g)
- const grid = g.getChildren(result.id).find(c => c.name === 'G')!
+ const grid = g.getChildren(result.id).find((c) => c.name === 'G')!
expect(grid.width).toBe(350)
})
@@ -639,8 +676,8 @@ describe('grid layout rendering', () => {
`
const [result] = await renderJSX(g, jsx)
computeAllLayouts(g)
- const content = g.getChildren(result.id).find(c => c.name === 'Content')!
- const grid = g.getChildren(content.id).find(c => c.name === 'G')!
+ const content = g.getChildren(result.id).find((c) => c.name === 'Content')!
+ const grid = g.getChildren(content.id).find((c) => c.name === 'G')!
expect(content.width).toBe(780)
expect(grid.width).toBe(724)
})
@@ -658,7 +695,7 @@ describe('grid layout rendering', () => {
`
const [result] = await renderJSX(g, jsx)
computeAllLayouts(g)
- const grid = g.getChildren(result.id).find(c => c.name === 'G')!
+ const grid = g.getChildren(result.id).find((c) => c.name === 'G')!
expect(grid.height).toBe(460)
})
})
@@ -739,11 +776,14 @@ describe('text props round-trip', () => {
it('text w="fill" in flex="col" exports as w="fill" not w={computed}', async () => {
const g = makeSceneGraph()
- const [result] = await renderJSX(g, `
+ const [result] = await renderJSX(
+ g,
+ `
<Frame name="Card" flex="col" w={300} p={20}>
<Text name="Title" size={22} weight="bold" color="#111" w="fill">Hello World</Text>
</Frame>
- `)
+ `
+ )
const card = g.getNode(result.id)!
const title = g.getNode(card.childIds[0]!)!
expect(title.layoutAlignSelf).toBe('STRETCH')
@@ -755,12 +795,15 @@ describe('text props round-trip', () => {
it('text grow={1} in flex="row" exports as grow not w={computed}', async () => {
const g = makeSceneGraph()
- const [result] = await renderJSX(g, `
+ const [result] = await renderJSX(
+ g,
+ `
<Frame name="Row" flex="row" w={300}>
<Text name="Label" color="#999" w={60}>Label</Text>
<Text name="Value" color="#111" w="fill">Some value text</Text>
</Frame>
- `)
+ `
+ )
const row = g.getNode(result.id)!
const value = g.getNode(row.childIds[1]!)!
expect(value.layoutGrow).toBe(1)
diff --git a/tests/engine/renderer-effects.test.ts b/tests/engine/renderer-effects.test.ts
index 04ff3edaa..b82a2fb5e 100644
--- a/tests/engine/renderer-effects.test.ts
+++ b/tests/engine/renderer-effects.test.ts
@@ -21,7 +21,9 @@ const rendererSource = (await readTypescriptFiles(rendererDir)).join('\n')
describe('Renderer effect ordering', () => {
test('drop shadow renders before fills', () => {
- const behindIdx = rendererSource.indexOf("renderEffects(canvas, node, rect, hasRadius, 'behind'")
+ const behindIdx = rendererSource.indexOf(
+ "renderEffects(canvas, node, rect, hasRadius, 'behind'"
+ )
const fillsIdx = rendererSource.indexOf('drawNodeFill(canvas, node, rect, hasRadius)')
expect(behindIdx).toBeGreaterThan(-1)
expect(fillsIdx).toBeGreaterThan(-1)
@@ -29,7 +31,9 @@ describe('Renderer effect ordering', () => {
})
test('inner shadow and blur render after strokes', () => {
- const strokeIdx = rendererSource.indexOf('drawStrokeWithAlign(canvas, node, rect, hasRadius, stroke.align)')
+ const strokeIdx = rendererSource.indexOf(
+ 'drawStrokeWithAlign(canvas, node, rect, hasRadius, stroke.align)'
+ )
const frontIdx = rendererSource.indexOf("renderEffects(canvas, node, rect, hasRadius, 'front')")
expect(strokeIdx).toBeGreaterThan(-1)
expect(frontIdx).toBeGreaterThan(-1)
diff --git a/tests/engine/rtl-auto-layout-input.test.ts b/tests/engine/rtl-auto-layout-input.test.ts
index 29444c2ac..a3419ef12 100644
--- a/tests/engine/rtl-auto-layout-input.test.ts
+++ b/tests/engine/rtl-auto-layout-input.test.ts
@@ -1,10 +1,11 @@
import { describe, expect, test } from 'bun:test'
+import { computeAutoLayoutIndicatorForFrame } from '#vue/shared/input/auto-layout'
+import { handleMoveUp } from '#vue/shared/input/move'
+
import { SceneGraph, computeLayout } from '@open-pencil/core'
import { createEditor } from '@open-pencil/core/editor'
-import { computeAutoLayoutIndicatorForFrame } from '#vue/shared/input/auto-layout'
-import { handleMoveUp } from '#vue/shared/input/move'
import type { DragMove } from '#vue/shared/input/types'
function pageId(graph: SceneGraph) {
diff --git a/tests/engine/snap.test.ts b/tests/engine/snap.test.ts
index 5c767e188..731b4e965 100644
--- a/tests/engine/snap.test.ts
+++ b/tests/engine/snap.test.ts
@@ -35,11 +35,9 @@ describe('computeSelectionBounds', () => {
describe('computeSnap', () => {
test('no targets returns zero', () => {
- const result = computeSnap(
- new Set(['moving']),
- { x: 50, y: 50, width: 100, height: 100 },
- [node({ id: 'moving' })]
- )
+ const result = computeSnap(new Set(['moving']), { x: 50, y: 50, width: 100, height: 100 }, [
+ node({ id: 'moving' })
+ ])
expect(result.dx).toBe(0)
expect(result.dy).toBe(0)
expect(result.guides).toHaveLength(0)
@@ -47,31 +45,28 @@ describe('computeSnap', () => {
test('snaps to aligned left edge', () => {
const target = node({ id: 'target', x: 100, y: 200, width: 50, height: 50 })
- const result = computeSnap(
- new Set(['moving']),
- { x: 102, y: 50, width: 80, height: 80 },
- [node({ id: 'moving' }), target]
- )
+ const result = computeSnap(new Set(['moving']), { x: 102, y: 50, width: 80, height: 80 }, [
+ node({ id: 'moving' }),
+ target
+ ])
expect(result.dx).toBe(-2)
})
test('snaps to aligned top edge', () => {
const target = node({ id: 'target', x: 200, y: 100, width: 50, height: 50 })
- const result = computeSnap(
- new Set(['moving']),
- { x: 50, y: 103, width: 80, height: 80 },
- [node({ id: 'moving' }), target]
- )
+ const result = computeSnap(new Set(['moving']), { x: 50, y: 103, width: 80, height: 80 }, [
+ node({ id: 'moving' }),
+ target
+ ])
expect(result.dy).toBe(-3)
})
test('no snap when far away', () => {
const target = node({ id: 'target', x: 500, y: 500, width: 50, height: 50 })
- const result = computeSnap(
- new Set(['moving']),
- { x: 0, y: 0, width: 50, height: 50 },
- [node({ id: 'moving' }), target]
- )
+ const result = computeSnap(new Set(['moving']), { x: 0, y: 0, width: 50, height: 50 }, [
+ node({ id: 'moving' }),
+ target
+ ])
expect(result.dx).toBe(0)
expect(result.dy).toBe(0)
})
@@ -79,11 +74,10 @@ describe('computeSnap', () => {
test('center-to-center snap', () => {
// target center at x=50, moving center at x=-2+50=48 → dx=+2
const target = node({ id: 'target', x: 0, y: 0, width: 100, height: 100 })
- const result = computeSnap(
- new Set(['moving']),
- { x: -2, y: 300, width: 100, height: 100 },
- [node({ id: 'moving' }), target]
- )
+ const result = computeSnap(new Set(['moving']), { x: -2, y: 300, width: 100, height: 100 }, [
+ node({ id: 'moving' }),
+ target
+ ])
expect(result.dx).toBe(2)
})
})
diff --git a/tests/engine/style-runs.test.ts b/tests/engine/style-runs.test.ts
index 4a02b8195..db17c5a73 100644
--- a/tests/engine/style-runs.test.ts
+++ b/tests/engine/style-runs.test.ts
@@ -10,7 +10,7 @@ import {
toggleBoldInRange,
toggleItalicInRange,
toggleDecorationInRange,
- type StyleRun,
+ type StyleRun
} from '@open-pencil/core'
describe('getStyleAt', () => {
diff --git a/tests/engine/svg-export.test.ts b/tests/engine/svg-export.test.ts
index 411145f96..daefb02eb 100644
--- a/tests/engine/svg-export.test.ts
+++ b/tests/engine/svg-export.test.ts
@@ -249,9 +249,7 @@ describe('renderNodesToSVG()', () => {
const node = graph.createNode('ELLIPSE', pageId(graph), {
width: 80,
height: 60,
- fills: [
- { type: 'SOLID', color: { r: 0, g: 0.5, b: 1, a: 1 }, opacity: 1, visible: true }
- ]
+ fills: [{ type: 'SOLID', color: { r: 0, g: 0.5, b: 1, a: 1 }, opacity: 1, visible: true }]
})
const result = exportSVG(graph, [node.id])!
expect(result).toContain('<ellipse')
@@ -656,9 +654,7 @@ describe('renderNodesToSVG()', () => {
const node = graph.createNode('RECTANGLE', pageId(graph), {
width: 50,
height: 50,
- fills: [
- { type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 0.5, visible: true }
- ]
+ fills: [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 0.5, visible: true }]
})
const result = exportSVG(graph, [node.id])!
expect(result).toContain('fill="#FF0000')
diff --git a/tests/engine/svg-path-parse.test.ts b/tests/engine/svg-path-parse.test.ts
index 108289777..0e5a1dae1 100644
--- a/tests/engine/svg-path-parse.test.ts
+++ b/tests/engine/svg-path-parse.test.ts
@@ -91,7 +91,8 @@ describe('parseSVGPath', () => {
})
test('real icon: lucide heart path (arcs + curves)', () => {
- const d = 'M2 9.5a5.5 5.5 0 0 1 9.591-3.676a.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5'
+ const d =
+ 'M2 9.5a5.5 5.5 0 0 1 9.591-3.676a.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5'
const vn = parseSVGPath(d)
expect(vn.vertices.length).toBeGreaterThan(5)
expect(vn.segments.length).toBeGreaterThan(5)
diff --git a/tests/engine/tailwind-jsx.test.ts b/tests/engine/tailwind-jsx.test.ts
index ec9dbcc1f..67ab8d196 100644
--- a/tests/engine/tailwind-jsx.test.ts
+++ b/tests/engine/tailwind-jsx.test.ts
@@ -404,7 +404,9 @@ describe('Tailwind JSX export', () => {
itemSpacing: 8,
primaryAxisSizing: 'HUG',
counterAxisSizing: 'FIXED',
- fills: [{ type: 'SOLID', color: { r: 0.95, g: 0.95, b: 0.95, a: 1 }, opacity: 1, visible: true }],
+ fills: [
+ { type: 'SOLID', color: { r: 0.95, g: 0.95, b: 0.95, a: 1 }, opacity: 1, visible: true }
+ ],
cornerRadius: 12
})
graph.createNode('TEXT', frame.id, {
diff --git a/tests/engine/text-edit-undo.test.ts b/tests/engine/text-edit-undo.test.ts
index 784f75ee4..eb70ba9c7 100644
--- a/tests/engine/text-edit-undo.test.ts
+++ b/tests/engine/text-edit-undo.test.ts
@@ -16,29 +16,34 @@ function setup() {
editingTextId: null,
currentPageId: pageId,
renderVersion: 0,
- sceneVersion: 0,
+ sceneVersion: 0
} as EditorState
const ctx: EditorContext = {
graph,
undo,
state,
- requestRender: () => { state.renderVersion++; state.sceneVersion++ },
- requestRepaint: () => { state.renderVersion++ },
+ requestRender: () => {
+ state.renderVersion++
+ state.sceneVersion++
+ },
+ requestRepaint: () => {
+ state.renderVersion++
+ },
getTextEditor: () => textEditor,
getRenderer: () => null,
runLayoutForNode: () => {},
getCk: () => null,
loadFont: async () => {},
getViewportSize: () => ({ width: 800, height: 600 }),
- subscribeToGraph: () => {},
+ subscribeToGraph: () => {}
}
const textNode = graph.createNode('TEXT', pageId, {
name: 'Label',
text: 'Hello',
width: 100,
- height: 20,
+ height: 20
})
const actions = createTextActions(ctx)
@@ -130,7 +135,7 @@ describe('text edit undo', () => {
textEditor.insert(' World', textNode)
const newRuns: StyleRun[] = [
{ start: 0, length: 5, style: { fontWeight: 700 } },
- { start: 5, length: 6, style: { fontWeight: 400 } },
+ { start: 5, length: 6, style: { fontWeight: 400 } }
]
graph.updateNode(textNode.id, { text: textEditor.state!.text, styleRuns: newRuns })
diff --git a/tests/engine/tools-ai-adapter.test.ts b/tests/engine/tools-ai-adapter.test.ts
index 28837c285..3a0846489 100644
--- a/tests/engine/tools-ai-adapter.test.ts
+++ b/tests/engine/tools-ai-adapter.test.ts
@@ -1,9 +1,11 @@
import { describe, expect, test } from 'bun:test'
+
import { valibotSchema } from '@ai-sdk/valibot'
-import { ALL_TOOLS, FigmaAPI, SceneGraph, toolsToAI } from '@open-pencil/core'
import { tool } from 'ai'
import * as v from 'valibot'
+import { ALL_TOOLS, FigmaAPI, SceneGraph, toolsToAI } from '@open-pencil/core'
+
function setup() {
const graph = new SceneGraph()
const figma = new FigmaAPI(graph)
diff --git a/tests/engine/tools-cli.test.ts b/tests/engine/tools-cli.test.ts
index 9f48e3e9b..946728dc8 100644
--- a/tests/engine/tools-cli.test.ts
+++ b/tests/engine/tools-cli.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, test, setDefaultTimeout } from 'bun:test'
import { join } from 'path'
+
import { heavy } from '../helpers/test-utils'
setDefaultTimeout(30_000)
diff --git a/tests/engine/tools.test.ts b/tests/engine/tools.test.ts
index 568fc72f9..d63ce3573 100644
--- a/tests/engine/tools.test.ts
+++ b/tests/engine/tools.test.ts
@@ -388,7 +388,7 @@ describe('query_nodes', () => {
figma.createRectangle()
const tool = ALL_TOOLS.find((t) => t.name === 'query_nodes')!
- const result = await tool.execute(figma, { selector: '//FRAME' }) as any
+ const result = (await tool.execute(figma, { selector: '//FRAME' })) as any
expect(result.count).toBe(2)
expect(result.nodes.every((n: any) => n.type === 'FRAME')).toBe(true)
})
@@ -403,7 +403,7 @@ describe('query_nodes', () => {
big.name = 'Big'
const tool = ALL_TOOLS.find((t) => t.name === 'query_nodes')!
- const result = await tool.execute(figma, { selector: '//RECTANGLE[@width < 200]' }) as any
+ const result = (await tool.execute(figma, { selector: '//RECTANGLE[@width < 200]' })) as any
expect(result.count).toBe(1)
expect(result.nodes[0].name).toBe('Small')
})
@@ -418,9 +418,9 @@ describe('query_nodes', () => {
t3.name = 'Label Secondary'
const tool = ALL_TOOLS.find((t) => t.name === 'query_nodes')!
- const result = await tool.execute(figma, {
+ const result = (await tool.execute(figma, {
selector: '//TEXT[contains(@name, "Label")]'
- }) as any
+ })) as any
expect(result.count).toBe(2)
expect(result.nodes.every((n: any) => n.name.includes('Label'))).toBe(true)
})
@@ -428,7 +428,7 @@ describe('query_nodes', () => {
test('returns error for invalid xpath', async () => {
const { figma } = setup()
const tool = ALL_TOOLS.find((t) => t.name === 'query_nodes')!
- const result = await tool.execute(figma, { selector: '///invalid[[[[' }) as any
+ const result = (await tool.execute(figma, { selector: '///invalid[[[[' })) as any
expect(result.error).toBeTruthy()
expect(result.error).toContain('XPath error')
})
@@ -441,7 +441,7 @@ describe('query_nodes', () => {
}
const tool = ALL_TOOLS.find((t) => t.name === 'query_nodes')!
- const result = await tool.execute(figma, { selector: '//RECTANGLE', limit: 3 }) as any
+ const result = (await tool.execute(figma, { selector: '//RECTANGLE', limit: 3 })) as any
expect(result.count).toBe(3)
})
@@ -450,7 +450,7 @@ describe('query_nodes', () => {
figma.createRectangle()
const tool = ALL_TOOLS.find((t) => t.name === 'query_nodes')!
- const result = await tool.execute(figma, { selector: '//ELLIPSE' }) as any
+ const result = (await tool.execute(figma, { selector: '//ELLIPSE' })) as any
expect(result.count).toBe(0)
expect(result.nodes).toEqual([])
})
@@ -549,9 +549,22 @@ describe('set_font_range', () => {
const setText = ALL_TOOLS.find((t) => t.name === 'set_text')!
const setFontRange = ALL_TOOLS.find((t) => t.name === 'set_font_range')!
- const created = createText.execute(figma, { type: 'TEXT', x: 0, y: 0, width: 200, height: 20 }) as any
+ const created = createText.execute(figma, {
+ type: 'TEXT',
+ x: 0,
+ y: 0,
+ width: 200,
+ height: 20
+ }) as any
setText.execute(figma, { id: created.id, text: 'Hello World' })
- setFontRange.execute(figma, { id: created.id, start: 0, end: 5, family: 'Inter', size: 18, style: 'Bold' })
+ setFontRange.execute(figma, {
+ id: created.id,
+ start: 0,
+ end: 5,
+ family: 'Inter',
+ size: 18,
+ style: 'Bold'
+ })
const node = graph.getNode(created.id)!
expect(node.styleRuns.length).toBeGreaterThan(0)
@@ -572,7 +585,13 @@ describe('set_font_range', () => {
const setText = ALL_TOOLS.find((t) => t.name === 'set_text')!
const setFontRange = ALL_TOOLS.find((t) => t.name === 'set_font_range')!
- const created = createText.execute(figma, { type: 'TEXT', x: 0, y: 0, width: 200, height: 20 }) as any
+ const created = createText.execute(figma, {
+ type: 'TEXT',
+ x: 0,
+ y: 0,
+ width: 200,
+ height: 20
+ }) as any
setText.execute(figma, { id: created.id, text: 'Red text' })
setFontRange.execute(figma, { id: created.id, start: 0, end: 3, color: '#ff0000' })
diff --git a/tests/engine/undo-batch-idle.test.ts b/tests/engine/undo-batch-idle.test.ts
index 64d11e036..d10e91702 100644
--- a/tests/engine/undo-batch-idle.test.ts
+++ b/tests/engine/undo-batch-idle.test.ts
@@ -11,7 +11,17 @@ describe('UndoManager idle-timer batching', () => {
for (let i = 1; i <= 10; i++) {
const prev = value
const next = i
- undo.push(undoEntry(`step ${i}`, () => { value = next }, () => { value = prev }))
+ undo.push(
+ undoEntry(
+ `step ${i}`,
+ () => {
+ value = next
+ },
+ () => {
+ value = prev
+ }
+ )
+ )
value = next
}
undo.commitBatch()
@@ -30,14 +40,44 @@ describe('UndoManager idle-timer batching', () => {
let b = 0
undo.beginBatch('batch A')
- undo.push(undoEntry('a1', () => { a = 1 }, () => { a = 0 }))
+ undo.push(
+ undoEntry(
+ 'a1',
+ () => {
+ a = 1
+ },
+ () => {
+ a = 0
+ }
+ )
+ )
a = 1
- undo.push(undoEntry('a2', () => { a = 2 }, () => { a = 1 }))
+ undo.push(
+ undoEntry(
+ 'a2',
+ () => {
+ a = 2
+ },
+ () => {
+ a = 1
+ }
+ )
+ )
a = 2
undo.commitBatch()
undo.beginBatch('batch B')
- undo.push(undoEntry('b1', () => { b = 10 }, () => { b = 0 }))
+ undo.push(
+ undoEntry(
+ 'b1',
+ () => {
+ b = 10
+ },
+ () => {
+ b = 0
+ }
+ )
+ )
b = 10
undo.commitBatch()
@@ -55,13 +95,43 @@ describe('UndoManager idle-timer batching', () => {
let v = 0
undo.beginBatch('drag')
- undo.push(undoEntry('d1', () => { v = 1 }, () => { v = 0 }))
+ undo.push(
+ undoEntry(
+ 'd1',
+ () => {
+ v = 1
+ },
+ () => {
+ v = 0
+ }
+ )
+ )
v = 1
- undo.push(undoEntry('d2', () => { v = 2 }, () => { v = 1 }))
+ undo.push(
+ undoEntry(
+ 'd2',
+ () => {
+ v = 2
+ },
+ () => {
+ v = 1
+ }
+ )
+ )
v = 2
undo.commitBatch()
- undo.push(undoEntry('add fill', () => { v = 100 }, () => { v = 2 }))
+ undo.push(
+ undoEntry(
+ 'add fill',
+ () => {
+ v = 100
+ },
+ () => {
+ v = 2
+ }
+ )
+ )
v = 100
undo.undo()
@@ -76,9 +146,27 @@ describe('UndoManager idle-timer batching', () => {
const log: number[] = []
undo.beginBatch('batch')
- undo.apply(undoEntry('s1', () => log.push(1), () => log.pop()))
- undo.apply(undoEntry('s2', () => log.push(2), () => log.pop()))
- undo.apply(undoEntry('s3', () => log.push(3), () => log.pop()))
+ undo.apply(
+ undoEntry(
+ 's1',
+ () => log.push(1),
+ () => log.pop()
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 's2',
+ () => log.push(2),
+ () => log.pop()
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 's3',
+ () => log.push(3),
+ () => log.pop()
+ )
+ )
undo.commitBatch()
expect(log).toEqual([1, 2, 3])
diff --git a/tests/engine/undo-redo-sequence.test.ts b/tests/engine/undo-redo-sequence.test.ts
index 0b9fa0ea4..ec6c211f8 100644
--- a/tests/engine/undo-redo-sequence.test.ts
+++ b/tests/engine/undo-redo-sequence.test.ts
@@ -15,7 +15,7 @@ describe('undo/redo multi-step sequences', () => {
const { parentId: _p, childIds: _c, ...rest } = createSnapshot
editor.graph.createNode('FRAME', pageId, rest)
},
- inverse: () => editor.graph.deleteNode(frame.id),
+ inverse: () => editor.graph.deleteNode(frame.id)
})
editor.graph.updateNode(frame.id, { x: 300, y: 50 })
@@ -78,7 +78,7 @@ describe('undo/redo multi-step sequences', () => {
x: 10,
y: 10,
width: 100,
- height: 20,
+ height: 20
})
editor.select([frame.id])
@@ -109,7 +109,7 @@ describe('undo/redo multi-step sequences', () => {
const child = editor.graph.createNode('RECTANGLE', frame.id, {
name: 'Bg',
width: 200,
- height: 150,
+ height: 150
})
const snapshot = editor.snapshotPage()
@@ -130,7 +130,7 @@ describe('undo/redo multi-step sequences', () => {
x: 0,
y: 0,
width: 200,
- height: 150,
+ height: 150
})
editor.select([frame.id])
diff --git a/tests/engine/undo.test.ts b/tests/engine/undo.test.ts
index 18d2e0cc8..28945bd8a 100644
--- a/tests/engine/undo.test.ts
+++ b/tests/engine/undo.test.ts
@@ -14,7 +14,17 @@ describe('UndoManager', () => {
test('apply executes forward and enables undo', () => {
const undo = createUndoManager()
let value = 0
- undo.apply(undoEntry('increment', () => { value = 1 }, () => { value = 0 }))
+ undo.apply(
+ undoEntry(
+ 'increment',
+ () => {
+ value = 1
+ },
+ () => {
+ value = 0
+ }
+ )
+ )
expect(value).toBe(1)
expect(undo.canUndo).toBe(true)
expect(undo.undoLabel).toBe('increment')
@@ -23,7 +33,17 @@ describe('UndoManager', () => {
test('push does not execute forward', () => {
const undo = createUndoManager()
let value = 0
- undo.push(undoEntry('set', () => { value = 1 }, () => { value = 0 }))
+ undo.push(
+ undoEntry(
+ 'set',
+ () => {
+ value = 1
+ },
+ () => {
+ value = 0
+ }
+ )
+ )
expect(value).toBe(0)
expect(undo.canUndo).toBe(true)
})
@@ -31,7 +51,17 @@ describe('UndoManager', () => {
test('undo calls inverse and returns label', () => {
const undo = createUndoManager()
let value = 0
- undo.apply(undoEntry('set', () => { value = 1 }, () => { value = 0 }))
+ undo.apply(
+ undoEntry(
+ 'set',
+ () => {
+ value = 1
+ },
+ () => {
+ value = 0
+ }
+ )
+ )
const label = undo.undo()
expect(label).toBe('set')
expect(value).toBe(0)
@@ -42,7 +72,17 @@ describe('UndoManager', () => {
test('redo calls forward and returns label', () => {
const undo = createUndoManager()
let value = 0
- undo.apply(undoEntry('set', () => { value = 1 }, () => { value = 0 }))
+ undo.apply(
+ undoEntry(
+ 'set',
+ () => {
+ value = 1
+ },
+ () => {
+ value = 0
+ }
+ )
+ )
undo.undo()
const label = undo.redo()
expect(label).toBe('set')
@@ -81,9 +121,39 @@ describe('UndoManager', () => {
test('history limit drops oldest entries', () => {
const undo = createUndoManager({ limit: 2 })
let val = 0
- undo.apply(undoEntry('to1', () => { val = 1 }, () => { val = 0 }))
- undo.apply(undoEntry('to2', () => { val = 2 }, () => { val = 1 }))
- undo.apply(undoEntry('to3', () => { val = 3 }, () => { val = 2 }))
+ undo.apply(
+ undoEntry(
+ 'to1',
+ () => {
+ val = 1
+ },
+ () => {
+ val = 0
+ }
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 'to2',
+ () => {
+ val = 2
+ },
+ () => {
+ val = 1
+ }
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 'to3',
+ () => {
+ val = 3
+ },
+ () => {
+ val = 2
+ }
+ )
+ )
expect(undo.undoLabel).toBe('to3')
undo.undo()
@@ -96,8 +166,20 @@ describe('UndoManager', () => {
const undo = createUndoManager()
const log: number[] = []
undo.beginBatch('batch')
- undo.apply(undoEntry('a', () => log.push(1), () => log.push(-1)))
- undo.apply(undoEntry('b', () => log.push(2), () => log.push(-2)))
+ undo.apply(
+ undoEntry(
+ 'a',
+ () => log.push(1),
+ () => log.push(-1)
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 'b',
+ () => log.push(2),
+ () => log.push(-2)
+ )
+ )
undo.commitBatch()
expect(log).toEqual([1, 2])
expect(undo.undoLabel).toBe('batch')
@@ -111,8 +193,20 @@ describe('UndoManager', () => {
const log: number[] = []
undo.runBatch('batch', () => {
- undo.apply(undoEntry('a', () => log.push(1), () => log.push(-1)))
- undo.apply(undoEntry('b', () => log.push(2), () => log.push(-2)))
+ undo.apply(
+ undoEntry(
+ 'a',
+ () => log.push(1),
+ () => log.push(-1)
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 'b',
+ () => log.push(2),
+ () => log.push(-2)
+ )
+ )
})
expect(log).toEqual([1, 2])
@@ -127,7 +221,13 @@ describe('UndoManager', () => {
expect(() =>
undo.runBatch('batch', () => {
- undo.apply(undoEntry('a', () => log.push(1), () => log.push(-1)))
+ undo.apply(
+ undoEntry(
+ 'a',
+ () => log.push(1),
+ () => log.push(-1)
+ )
+ )
throw new Error('boom')
})
).toThrow('boom')
@@ -141,9 +241,21 @@ describe('UndoManager', () => {
const log: number[] = []
undo.runBatch('outer', () => {
- undo.apply(undoEntry('a', () => log.push(1), () => log.push(-1)))
+ undo.apply(
+ undoEntry(
+ 'a',
+ () => log.push(1),
+ () => log.push(-1)
+ )
+ )
undo.runBatch('inner', () => {
- undo.apply(undoEntry('b', () => log.push(2), () => log.push(-2)))
+ undo.apply(
+ undoEntry(
+ 'b',
+ () => log.push(2),
+ () => log.push(-2)
+ )
+ )
})
})
@@ -162,9 +274,39 @@ describe('UndoManager', () => {
test('multiple undo/redo', () => {
const undo = createUndoManager()
let val = 0
- undo.apply(undoEntry('to1', () => { val = 1 }, () => { val = 0 }))
- undo.apply(undoEntry('to2', () => { val = 2 }, () => { val = 1 }))
- undo.apply(undoEntry('to3', () => { val = 3 }, () => { val = 2 }))
+ undo.apply(
+ undoEntry(
+ 'to1',
+ () => {
+ val = 1
+ },
+ () => {
+ val = 0
+ }
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 'to2',
+ () => {
+ val = 2
+ },
+ () => {
+ val = 1
+ }
+ )
+ )
+ undo.apply(
+ undoEntry(
+ 'to3',
+ () => {
+ val = 3
+ },
+ () => {
+ val = 2
+ }
+ )
+ )
undo.undo()
expect(val).toBe(2)
diff --git a/tests/engine/vector.test.ts b/tests/engine/vector.test.ts
index 1393bb6ce..8bf121ad4 100644
--- a/tests/engine/vector.test.ts
+++ b/tests/engine/vector.test.ts
@@ -1,22 +1,22 @@
import { describe, test, expect } from 'bun:test'
-import {
- lineNetwork,
- triangleNetwork,
- vectorNetwork,
- vectorSegment,
- vectorVertex
-} from '../helpers/vector-network'
-
import {
encodeVectorNetworkBlob,
decodeVectorNetworkBlob,
computeVectorBounds,
normalizeVectorNetwork,
validateVectorNetwork,
- type VectorNetwork,
+ type VectorNetwork
} from '@open-pencil/core'
+import {
+ lineNetwork,
+ triangleNetwork,
+ vectorNetwork,
+ vectorSegment,
+ vectorVertex
+} from '../helpers/vector-network'
+
describe('vectorNetworkBlob round-trip', () => {
test('empty network', () => {
const network: VectorNetwork = { vertices: [], segments: [], regions: [] }
@@ -77,9 +77,7 @@ describe('vectorNetworkBlob round-trip', () => {
{ start: 2, end: 3, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } },
{ start: 3, end: 0, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } }
],
- regions: [
- { windingRule: 'EVENODD', loops: [[0, 1, 2, 3]] }
- ]
+ regions: [{ windingRule: 'EVENODD', loops: [[0, 1, 2, 3]] }]
}
const blob = encodeVectorNetworkBlob(network)
const decoded = decodeVectorNetworkBlob(blob)
@@ -114,7 +112,10 @@ describe('vectorNetworkBlob round-trip', () => {
describe('normalizeVectorNetwork', () => {
test('passes through segments that already have tangents', () => {
const network: VectorNetwork = {
- vertices: [{ x: 0, y: 0 }, { x: 10, y: 10 }],
+ vertices: [
+ { x: 0, y: 0 },
+ { x: 10, y: 10 }
+ ],
segments: [{ start: 0, end: 1, tangentStart: { x: 5, y: 0 }, tangentEnd: { x: -5, y: 0 } }],
regions: []
}
@@ -125,7 +126,10 @@ describe('normalizeVectorNetwork', () => {
test('defaults missing tangentStart and tangentEnd to zero', () => {
const network = {
- vertices: [{ x: 0, y: 0 }, { x: 10, y: 10 }],
+ vertices: [
+ { x: 0, y: 0 },
+ { x: 10, y: 10 }
+ ],
segments: [{ start: 0, end: 1 }],
regions: []
} as unknown as VectorNetwork
@@ -136,7 +140,10 @@ describe('normalizeVectorNetwork', () => {
test('defaults only the missing tangent', () => {
const network = {
- vertices: [{ x: 0, y: 0 }, { x: 10, y: 10 }],
+ vertices: [
+ { x: 0, y: 0 },
+ { x: 10, y: 10 }
+ ],
segments: [{ start: 0, end: 1, tangentStart: { x: 3, y: 4 } }],
regions: []
} as unknown as VectorNetwork
@@ -177,7 +184,10 @@ describe('normalizeVectorNetwork', () => {
describe('validateVectorNetwork', () => {
test('valid network returns no errors', () => {
const network: VectorNetwork = {
- vertices: [{ x: 0, y: 0 }, { x: 10, y: 10 }],
+ vertices: [
+ { x: 0, y: 0 },
+ { x: 10, y: 10 }
+ ],
segments: [{ start: 0, end: 1, tangentStart: { x: 0, y: 0 }, tangentEnd: { x: 0, y: 0 } }],
regions: []
}
@@ -186,7 +196,10 @@ describe('validateVectorNetwork', () => {
test('segments without tangents are valid (normalize handles them)', () => {
const network = {
- vertices: [{ x: 0, y: 0 }, { x: 10, y: 10 }],
+ vertices: [
+ { x: 0, y: 0 },
+ { x: 10, y: 10 }
+ ],
segments: [{ start: 0, end: 1 }],
regions: []
} as unknown as VectorNetwork
@@ -224,7 +237,10 @@ describe('validateVectorNetwork', () => {
describe('computeVectorBounds', () => {
test('empty network', () => {
expect(computeVectorBounds({ vertices: [], segments: [], regions: [] })).toEqual({
- x: 0, y: 0, width: 0, height: 0
+ x: 0,
+ y: 0,
+ width: 0,
+ height: 0
})
})
@@ -258,9 +274,7 @@ describe('computeVectorBounds', () => {
{ x: 0, y: 0, handleMirroring: 'NONE' },
{ x: 100, y: 0, handleMirroring: 'NONE' }
],
- segments: [
- { start: 0, end: 1, tangentStart: { x: 0, y: -50 }, tangentEnd: { x: 0, y: 50 } }
- ],
+ segments: [{ start: 0, end: 1, tangentStart: { x: 0, y: -50 }, tangentEnd: { x: 0, y: 50 } }],
regions: []
})
// Curve extrema at t=(3±√3)/6, not at control points
diff --git a/tests/helpers/editor-history.ts b/tests/helpers/editor-history.ts
index c5b757ee4..0e1aab36c 100644
--- a/tests/helpers/editor-history.ts
+++ b/tests/helpers/editor-history.ts
@@ -19,6 +19,6 @@ export function createHistoryFrame(
y: 0,
width: 200,
height: 150,
- ...overrides,
+ ...overrides
})
}
diff --git a/tests/helpers/figma.ts b/tests/helpers/figma.ts
index ec8fafaca..fc17ecaf4 100644
--- a/tests/helpers/figma.ts
+++ b/tests/helpers/figma.ts
@@ -48,13 +48,7 @@ export class FigmaHelper {
await this.page.mouse.click(box.x + canvasX, box.y + canvasY)
}
- async drag(
- fromX: number,
- fromY: number,
- toX: number,
- toY: number,
- steps = 10
- ) {
+ async drag(fromX: number, fromY: number, toX: number, toY: number, steps = 10) {
const box = await this.canvasBounds()
await this.page.mouse.move(box.x + fromX, box.y + fromY)
await this.page.mouse.down()