AI-native design editor. Open-source Figma alternative.
Format codebase with oxfmt
Danila Poyarkov046f23b138c8
diff --git a/components.d.ts b/components.d.tsindex e174cd2a5..c0c74e250 100644--- a/components.d.ts+++ b/components.d.ts@@ -44,6 +44,7 @@ declare module 'vue' {IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw')['default']IconLucideRotateCw: typeof import('~icons/lucide/rotate-cw')['default']IconLucideSearch: typeof import('~icons/lucide/search')['default']+ IconLucideX: typeof import('~icons/lucide/x')['default']LayersPanel: typeof import('./src/components/LayersPanel.vue')['default']LayoutSection: typeof import('./src/components/properties/LayoutSection.vue')['default']PageSection: typeof import('./src/components/properties/PageSection.vue')['default']diff --git a/src/App.vue b/src/App.vueindex 4d97ab4bc..a3ee30e63 100644--- a/src/App.vue+++ b/src/App.vue@@ -15,12 +15,16 @@ import Toolbar from './components/Toolbar.vue'const store = provideEditorStore()useKeyboard(store)useMenu(store)-;(window as any).__OPEN_PENCIL_STORE__ = store-useEventListener(document, 'wheel', (e: WheelEvent) => {- if (e.ctrlKey || e.metaKey) e.preventDefault()-}, { passive: false })+useEventListener(+ document,+ 'wheel',+ (e: WheelEvent) => {+ if (e.ctrlKey || e.metaKey) e.preventDefault()+ },+ { passive: false }+)const params = useUrlSearchParams('history')const showChrome = !('no-chrome' in params)@@ -31,7 +35,12 @@ if (!('test' in params)) {<template><div class="flex h-screen w-screen flex-col">- <SplitterGroup v-if="showChrome" direction="horizontal" class="flex-1 overflow-hidden" auto-save-id="editor-layout">+ <SplitterGroup+ v-if="showChrome"+ direction="horizontal"+ class="flex-1 overflow-hidden"+ auto-save-id="editor-layout"+ ><SplitterPanel :default-size="15" :min-size="10" :max-size="30" class="flex"><LayersPanel /></SplitterPanel>diff --git a/src/app.css b/src/app.cssindex 13aa6bfd6..09571ec2b 100644--- a/src/app.css+++ b/src/app.css@@ -1,5 +1,4 @@-@import "tailwindcss";-+@import 'tailwindcss';@theme {--color-panel: #2a2a2a;@@ -21,7 +20,11 @@ body,}body {- font-family: Inter, system-ui, -apple-system, sans-serif;+ font-family:+ Inter,+ system-ui,+ -apple-system,+ sans-serif;font-size: 13px;color: var(--color-surface);background: var(--color-canvas);@@ -29,12 +32,12 @@ body {-webkit-user-select: none;}-input[type="number"] {+input[type='number'] {appearance: textfield;-moz-appearance: textfield;}-input[type="number"]::-webkit-inner-spin-button,-input[type="number"]::-webkit-outer-spin-button {+input[type='number']::-webkit-inner-spin-button,+input[type='number']::-webkit-outer-spin-button {display: none;}diff --git a/src/components/CanvasContextMenu.vue b/src/components/CanvasContextMenu.vueindex 2bc6a0c2d..64445b2b2 100644--- a/src/components/CanvasContextMenu.vue+++ b/src/components/CanvasContextMenu.vue@@ -82,9 +82,12 @@ function onRightClick(e: MouseEvent) {}}-const itemClass = 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-surface outline-none data-[highlighted]:bg-hover data-[disabled]:cursor-default data-[disabled]:text-muted'-const componentItemClass = 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-[#9747ff] outline-none data-[highlighted]:bg-[#9747ff]/12 data-[disabled]:cursor-default data-[disabled]:text-[#9747ff]/40'-const menuClass = 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 shadow-[0_8px_30px_rgb(0_0_0/0.4)] animate-in fade-in zoom-in-95'+const itemClass =+ 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-surface outline-none data-[highlighted]:bg-hover data-[disabled]:cursor-default data-[disabled]:text-muted'+const componentItemClass =+ 'flex w-full cursor-pointer select-none items-center justify-between gap-6 rounded px-2 py-1.5 text-xs text-[#9747ff] outline-none data-[highlighted]:bg-[#9747ff]/12 data-[disabled]:cursor-default data-[disabled]:text-[#9747ff]/40'+const menuClass =+ 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 shadow-[0_8px_30px_rgb(0_0_0/0.4)] animate-in fade-in zoom-in-95'</script><template>@@ -96,11 +99,19 @@ const menuClass = 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 sh<ContextMenuPortal><ContextMenuContent :class="menuClass" :side-offset="2" align="start"><!-- Clipboard -->- <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="document.execCommand('copy')">+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="document.execCommand('copy')"+ ><span>Copy</span><span class="text-[11px] text-muted">⌘C</span></ContextMenuItem>- <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="document.execCommand('cut')">+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="document.execCommand('cut')"+ ><span>Cut</span><span class="text-[11px] text-muted">⌘X</span></ContextMenuItem>@@ -108,11 +119,19 @@ const menuClass = 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 sh<span>Paste here</span><span class="text-[11px] text-muted">⌘V</span></ContextMenuItem>- <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.duplicateSelected()">+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="store.duplicateSelected()"+ ><span>Duplicate</span><span class="text-[11px] text-muted">⌘D</span></ContextMenuItem>- <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.deleteSelected()">+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="store.deleteSelected()"+ ><span>Delete</span><span class="text-[11px] text-muted">⌫</span></ContextMenuItem>@@ -140,7 +159,11 @@ const menuClass = 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 sh</ContextMenuSub><!-- Z-order -->- <ContextMenuItem :class="itemClass" :disabled="!hasSelection" @select="store.bringToFront()">+ <ContextMenuItem+ :class="itemClass"+ :disabled="!hasSelection"+ @select="store.bringToFront()"+ ><span>Bring to front</span><span class="text-[11px] text-muted">]</span></ContextMenuItem>@@ -152,7 +175,11 @@ const menuClass = 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 sh<ContextMenuSeparator class="my-1 h-px bg-border" /><!-- Grouping -->- <ContextMenuItem :class="itemClass" :disabled="multiCount < 2" @select="store.groupSelected()">+ <ContextMenuItem+ :class="itemClass"+ :disabled="multiCount < 2"+ @select="store.groupSelected()"+ ><span>Group</span><span class="text-[11px] text-muted">⌘G</span></ContextMenuItem>@@ -168,18 +195,34 @@ const menuClass = 'z-50 min-w-56 rounded-lg border border-border bg-panel p-1 sh<ContextMenuSeparator class="my-1 h-px bg-border" /><!-- Components -->- <ContextMenuItem :class="componentItemClass" :disabled="!hasSelection" @select="store.createComponentFromSelection()">+ <ContextMenuItem+ :class="componentItemClass"+ :disabled="!hasSelection"+ @select="store.createComponentFromSelection()"+ ><span>Create component</span><span class="text-[11px] text-[#9747ff]/60">⌥⌘K</span></ContextMenuItem>- <ContextMenuItem v-if="canCreateComponentSet" :class="componentItemClass" @select="store.createComponentSetFromComponents()">+ <ContextMenuItem+ v-if="canCreateComponentSet"+ :class="componentItemClass"+ @select="store.createComponentSetFromComponents()"+ ><span>Create component set</span><span class="text-[11px] text-[#9747ff]/60">⇧⌘K</span></ContextMenuItem>- <ContextMenuItem v-if="isComponent" :class="componentItemClass" @select="store.createInstanceFromComponent(singleNode!.id)">+ <ContextMenuItem+ v-if="isComponent"+ :class="componentItemClass"+ @select="store.createInstanceFromComponent(singleNode!.id)"+ ><span>Create instance</span></ContextMenuItem>- <ContextMenuItem v-if="isInstance" :class="componentItemClass" @select="store.goToMainComponent()">+ <ContextMenuItem+ v-if="isInstance"+ :class="componentItemClass"+ @select="store.goToMainComponent()"+ ><span>Go to main component</span></ContextMenuItem><ContextMenuItem v-if="isInstance" :class="itemClass" @select="store.detachInstance()">diff --git a/src/components/ColorPicker.vue b/src/components/ColorPicker.vueindex f478d53c5..d4815694c 100644--- a/src/components/ColorPicker.vue+++ b/src/components/ColorPicker.vue@@ -137,11 +137,18 @@ const swatchColor = computed(() => {<template><PopoverRoot><PopoverTrigger as-child>- <button class="size-5 shrink-0 cursor-pointer rounded border border-border p-0" :style="{ background: swatchColor }" />+ <button+ class="size-5 shrink-0 cursor-pointer rounded border border-border p-0"+ :style="{ background: swatchColor }"+ /></PopoverTrigger><PopoverPortal>- <PopoverContent class="z-[100] w-56 rounded-lg border border-border bg-panel p-2 shadow-xl" :side-offset="4" side="left">+ <PopoverContent+ class="z-[100] w-56 rounded-lg border border-border bg-panel p-2 shadow-xl"+ :side-offset="4"+ side="left"+ ><!-- SV area --><divref="svAreaRef"@@ -160,12 +167,26 @@ const swatchColor = computed(() => {<!-- Hue slider --><div class="mt-2">- <input type="range" class="hue-slider" :value="hue" min="0" max="360" @input="onHueInput" />+ <input+ type="range"+ class="hue-slider"+ :value="hue"+ min="0"+ max="360"+ @input="onHueInput"+ /></div><!-- Alpha slider --><div class="mt-2">- <input type="range" class="alpha-slider" :value="alpha * 100" min="0" max="100" @input="onAlphaSliderInput" />+ <input+ type="range"+ class="alpha-slider"+ :value="alpha * 100"+ min="0"+ max="100"+ @input="onAlphaSliderInput"+ /></div><!-- Hex input -->@@ -205,7 +226,16 @@ const swatchColor = computed(() => {}.hue-slider {- background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);+ background: linear-gradient(+ to right,+ #f00 0%,+ #ff0 17%,+ #0f0 33%,+ #0ff 50%,+ #00f 67%,+ #f0f 83%,+ #f00 100%+ );}.alpha-slider {diff --git a/src/components/EditorCanvas.vue b/src/components/EditorCanvas.vueindex a25624d1a..516be29f7 100644--- a/src/components/EditorCanvas.vue+++ b/src/components/EditorCanvas.vue@@ -10,7 +10,12 @@ const store = useEditorStore()const canvasRef = ref<HTMLCanvasElement | null>(null)const { hitTestSectionTitle, hitTestComponentLabel } = useCanvas(canvasRef, store)-const { cursorOverride } = useCanvasInput(canvasRef, store, hitTestSectionTitle, hitTestComponentLabel)+const { cursorOverride } = useCanvasInput(+ canvasRef,+ store,+ hitTestSectionTitle,+ hitTestComponentLabel+)const cursor = computed(() => {if (cursorOverride.value) return cursorOverride.valuediff --git a/src/components/FillPicker.vue b/src/components/FillPicker.vueindex 7d3a04024..ecec72a80 100644--- a/src/components/FillPicker.vue+++ b/src/components/FillPicker.vue@@ -1,8 +1,19 @@<script setup lang="ts">import { ref, computed, watch } from 'vue'import {- PopoverRoot, PopoverTrigger, PopoverPortal, PopoverContent,- SelectRoot, SelectTrigger, SelectValue, SelectPortal, SelectContent, SelectItem, SelectItemText, SelectItemIndicator, SelectViewport,+ PopoverRoot,+ PopoverTrigger,+ PopoverPortal,+ PopoverContent,+ SelectRoot,+ SelectTrigger,+ SelectValue,+ SelectPortal,+ SelectContent,+ SelectItem,+ SelectItemText,+ SelectItemIndicator,+ SelectViewport} from 'reka-ui'import ScrubInput from './ScrubInput.vue'@@ -12,20 +23,24 @@ import type { Color } from '../types'import type { Fill, FillType, GradientStop, GradientTransform } from '../engine/scene-graph'type FillCategory = 'SOLID' | 'GRADIENT' | 'IMAGE'-type GradientSubtype = 'GRADIENT_LINEAR' | 'GRADIENT_RADIAL' | 'GRADIENT_ANGULAR' | 'GRADIENT_DIAMOND'+type GradientSubtype =+ | 'GRADIENT_LINEAR'+ | 'GRADIENT_RADIAL'+ | 'GRADIENT_ANGULAR'+ | 'GRADIENT_DIAMOND'const GRADIENT_SUBTYPES: { type: GradientSubtype; label: string }[] = [{ type: 'GRADIENT_LINEAR', label: 'Linear' },{ type: 'GRADIENT_RADIAL', label: 'Radial' },{ type: 'GRADIENT_ANGULAR', label: 'Angular' },- { type: 'GRADIENT_DIAMOND', label: 'Diamond' },+ { type: 'GRADIENT_DIAMOND', label: 'Diamond' }]const DEFAULT_GRADIENT_TRANSFORMS: Record<GradientSubtype, GradientTransform> = {- GRADIENT_LINEAR: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 0, m12: 0.5 },- GRADIENT_RADIAL: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 },- GRADIENT_ANGULAR: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 },- GRADIENT_DIAMOND: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 },+ GRADIENT_LINEAR: { m00: 1, m01: 0, m02: 0, m10: 0, m11: 0, m12: 0.5 },+ GRADIENT_RADIAL: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 },+ GRADIENT_ANGULAR: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 },+ GRADIENT_DIAMOND: { m00: 0.5, m01: 0, m02: 0.5, m10: 0, m11: 0.5, m12: 0.5 }}const props = defineProps<{@@ -47,7 +62,7 @@ const fillCategory = computed<FillCategory>(() => {const isGradient = computed(() => fillCategory.value === 'GRADIENT')const gradientSubtype = computed(() =>- isGradient.value ? props.fill.type as GradientSubtype : 'GRADIENT_LINEAR'+ isGradient.value ? (props.fill.type as GradientSubtype) : 'GRADIENT_LINEAR')const activeColor = computed(() => {@@ -140,13 +155,13 @@ function setCategory(cat: FillCategory) {? props.fill.gradientStops: [{ color: { ...props.fill.color }, position: 0 },- { color: { r: 1, g: 1, b: 1, a: 1 }, position: 1 },+ { color: { r: 1, g: 1, b: 1, a: 1 }, position: 1 }]emit('update', {...props.fill,type,gradientStops: stops,- gradientTransform: DEFAULT_GRADIENT_TRANSFORMS[type],+ gradientTransform: DEFAULT_GRADIENT_TRANSFORMS[type]})activeStopIndex.value = 0} else {@@ -160,7 +175,7 @@ function setGradientSubtype(type: string) {emit('update', {...props.fill,type: subtype,- gradientTransform: DEFAULT_GRADIENT_TRANSFORMS[subtype],+ gradientTransform: DEFAULT_GRADIENT_TRANSFORMS[subtype]})}@@ -174,13 +189,14 @@ function selectStop(index: number) {function addStop() {if (!props.fill.gradientStops) returnconst stops = [...props.fill.gradientStops]- const newPos = stops.length >= 2- ? (stops[stops.length - 2].position + stops[stops.length - 1].position) / 2- : 0.5+ const newPos =+ stops.length >= 2+ ? (stops[stops.length - 2].position + stops[stops.length - 1].position) / 2+ : 0.5const color = currentRgb()stops.push({ color, position: newPos })stops.sort((a, b) => a.position - b.position)- const newIndex = stops.findIndex(s => s.position === newPos)+ const newIndex = stops.findIndex((s) => s.position === newPos)activeStopIndex.value = newIndexemit('update', { ...props.fill, gradientStops: stops })}@@ -283,7 +299,7 @@ const hueColor = computed(() => {const swatchBackground = computed(() => {if (isGradient.value && props.fill.gradientStops?.length) {const stops = props.fill.gradientStops- .map(s => {+ .map((s) => {const rgba = colorToRgba255(s.color)return `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${s.color.a}) ${s.position * 100}%`})@@ -297,7 +313,7 @@ const swatchBackground = computed(() => {const gradientBarBackground = computed(() => {if (!props.fill.gradientStops?.length) return ''const stops = props.fill.gradientStops- .map(s => {+ .map((s) => {const rgba = colorToRgba255(s.color)return `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${s.color.a}) ${s.position * 100}%`})@@ -358,7 +374,9 @@ function stopSwatchColor(stop: GradientStop) {title="Solid"@click="setCategory('SOLID')">- <svg class="size-3.5" viewBox="0 0 16 16"><rect x="2" y="2" width="12" height="12" rx="2" fill="currentColor" /></svg>+ <svg class="size-3.5" viewBox="0 0 16 16">+ <rect x="2" y="2" width="12" height="12" rx="2" fill="currentColor" />+ </svg></button><buttonclass="flex size-6 cursor-pointer items-center justify-center rounded border-none p-0 text-muted transition-colors hover:bg-hover hover:text-surface"@@ -366,7 +384,15 @@ function stopSwatchColor(stop: GradientStop) {title="Gradient"@click="setCategory('GRADIENT')">- <svg class="size-3.5" viewBox="0 0 16 16"><defs><linearGradient id="gl"><stop offset="0" stop-color="currentColor" /><stop offset="1" stop-color="currentColor" stop-opacity="0" /></linearGradient></defs><rect x="2" y="2" width="12" height="12" rx="2" fill="url(#gl)" /></svg>+ <svg class="size-3.5" viewBox="0 0 16 16">+ <defs>+ <linearGradient id="gl">+ <stop offset="0" stop-color="currentColor" />+ <stop offset="1" stop-color="currentColor" stop-opacity="0" />+ </linearGradient>+ </defs>+ <rect x="2" y="2" width="12" height="12" rx="2" fill="url(#gl)" />+ </svg></button><buttonclass="flex size-6 cursor-pointer items-center justify-center rounded border-none p-0 text-muted transition-colors hover:bg-hover hover:text-surface"@@ -381,12 +407,20 @@ function stopSwatchColor(stop: GradientStop) {<!-- Gradient subtype dropdown --><div v-if="isGradient" class="mb-2"><SelectRoot :model-value="gradientSubtype" @update:model-value="setGradientSubtype">- <SelectTrigger class="flex h-7 w-28 cursor-pointer items-center justify-between rounded border border-border bg-input px-2 text-xs text-surface">+ <SelectTrigger+ class="flex h-7 w-28 cursor-pointer items-center justify-between rounded border border-border bg-input px-2 text-xs text-surface"+ ><SelectValue /><icon-lucide-chevron-down class="size-3 text-muted" /></SelectTrigger><SelectPortal>- <SelectContent class="z-[200] min-w-[112px] rounded-md border border-border bg-panel py-1 shadow-xl" position="popper" side="bottom" :side-offset="4" :align="'start'">+ <SelectContent+ class="z-[200] min-w-[112px] rounded-md border border-border bg-panel py-1 shadow-xl"+ position="popper"+ side="bottom"+ :side-offset="4"+ :align="'start'"+ ><SelectViewport><SelectItemv-for="sub in GRADIENT_SUBTYPES"@@ -421,7 +455,7 @@ function stopSwatchColor(stop: GradientStop) {:class="idx === activeStopIndex ? 'border-white' : 'border-white/60'":style="{left: `${stop.position * 100}%`,- background: stopSwatchColor(stop),+ background: stopSwatchColor(stop)}"@pointerdown.stop="onStopPointerDown(idx, $event)"/>@@ -480,7 +514,9 @@ function stopSwatchColor(stop: GradientStop) {v-if="(fill.gradientStops?.length ?? 0) > 2"class="flex size-4 cursor-pointer items-center justify-center rounded border-none bg-transparent p-0 text-muted hover:text-surface"@click.stop="removeStop(idx)"- >−</button>+ >+ −+ </button></div></div>@@ -511,13 +547,30 @@ function stopSwatchColor(stop: GradientStop) {<!-- Hue slider --><div class="mt-2">- <input type="range" class="hue-slider" :value="hue" min="0" max="360" @input="onHueInput" />+ <input+ type="range"+ class="hue-slider"+ :value="hue"+ min="0"+ max="360"+ @input="onHueInput"+ /></div><!-- Alpha slider --><div class="alpha-wrap mt-2">- <div class="alpha-gradient" :style="{ background: `linear-gradient(to right, transparent, ${hueColor})` }" />- <input type="range" class="alpha-slider" :value="alpha * 100" min="0" max="100" @input="onAlphaSliderInput" />+ <div+ class="alpha-gradient"+ :style="{ background: `linear-gradient(to right, transparent, ${hueColor})` }"+ />+ <input+ type="range"+ class="alpha-slider"+ :value="alpha * 100"+ min="0"+ max="100"+ @input="onAlphaSliderInput"+ /></div><!-- Hex input -->@@ -558,7 +611,16 @@ function stopSwatchColor(stop: GradientStop) {}.hue-slider {- background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);+ background: linear-gradient(+ to right,+ #f00 0%,+ #ff0 17%,+ #0f0 33%,+ #0ff 50%,+ #00f 67%,+ #f0f 83%,+ #f00 100%+ );}.alpha-wrap {@@ -571,7 +633,11 @@ function stopSwatchColor(stop: GradientStop) {linear-gradient(45deg, transparent 75%, #444 75%),linear-gradient(-45deg, transparent 75%, #444 75%);background-size: 8px 8px;- background-position: 0 0, 0 4px, 4px -4px, -4px 0;+ background-position:+ 0 0,+ 0 4px,+ 4px -4px,+ -4px 0;background-color: #333;}diff --git a/src/components/LayersPanel.vue b/src/components/LayersPanel.vueindex d490c8b2a..2f6eef87b 100644--- a/src/components/LayersPanel.vue+++ b/src/components/LayersPanel.vue@@ -55,20 +55,17 @@ function buildTree(parentId: string): LayerNode[] {name: node.name,type: node.type,visible: node.visible,- children: node.childIds.length > 0 ? buildTree(node.id) : undefined,+ children: node.childIds.length > 0 ? buildTree(node.id) : undefined}))}const items = ref(buildTree(store.state.currentPageId))const treeKey = ref(0)-watch(- [() => store.state.renderVersion, () => store.state.currentPageId],- () => {- items.value = buildTree(store.state.currentPageId)- treeKey.value++- }-)+watch([() => store.state.renderVersion, () => store.state.currentPageId], () => {+ items.value = buildTree(store.state.currentPageId)+ treeKey.value+++})const expanded = ref<string[]>([])@@ -85,7 +82,7 @@ function onSelect(ev: CustomEvent) {function toggleExpand(id: string) {const idx = expanded.value.indexOf(id)if (idx >= 0) {- expanded.value = expanded.value.filter(e => e !== id)+ expanded.value = expanded.value.filter((e) => e !== id)} else {expanded.value = [...expanded.value, id]}@@ -176,7 +173,12 @@ function updateDropTarget(ev: PointerEvent) {if (parent) {const idx = parent.childIds.indexOf(rowId)const level = parseInt(row.dataset.level ?? '0')- bestInsertBefore = { parentId, index: Math.max(0, idx), y: rect.top - listRect.top + list.scrollTop, depth: level }+ bestInsertBefore = {+ parentId,+ index: Math.max(0, idx),+ y: rect.top - listRect.top + list.scrollTop,+ depth: level+ }}break}@@ -187,7 +189,12 @@ function updateDropTarget(ev: PointerEvent) {if (parent) {const idx = parent.childIds.indexOf(rowId)const level = parseInt(row.dataset.level ?? '0')- bestInsertBefore = { parentId, index: idx + 1, y: rect.bottom - listRect.top + list.scrollTop, depth: level }+ bestInsertBefore = {+ parentId,+ index: idx + 1,+ y: rect.bottom - listRect.top + list.scrollTop,+ depth: level+ }}}}@@ -196,7 +203,9 @@ function updateDropTarget(ev: PointerEvent) {dropIntoId.value = bestInto.nodeIdindicatorY.value = -1const container = store.graph.getNode(bestInto.nodeId)- dropTarget.value = container ? { parentId: bestInto.nodeId, index: container.childIds.length } : null+ dropTarget.value = container+ ? { parentId: bestInto.nodeId, index: container.childIds.length }+ : null} else if (bestInsertBefore) {dropIntoId.value = nullindicatorY.value = bestInsertBefore.y@@ -213,7 +222,9 @@ function updateDropTarget(ev: PointerEvent) {<template><aside class="flex min-w-0 flex-1 flex-col overflow-y-auto border-r border-border bg-panel"><PagesPanel />- <header class="shrink-0 px-3 py-2 text-[11px] uppercase tracking-wider text-muted">Layers</header>+ <header class="shrink-0 px-3 py-2 text-[11px] uppercase tracking-wider text-muted">+ Layers+ </header><div ref="listRef" class="relative flex-1 overflow-y-auto px-1"><TreeRoot:key="treeKey"@@ -229,12 +240,7 @@ function updateDropTarget(ev: PointerEvent) {:data-node-id="item.value.id":data-level="item.level">- <TreeItem- v-slot="{ isExpanded }"- v-bind="item.bind"- as-child- @select="onSelect"- >+ <TreeItem v-slot="{ isExpanded }" v-bind="item.bind" as-child @select="onSelect"><buttonclass="group/row flex w-full cursor-pointer items-center gap-1 rounded border-none py-1 text-left text-xs":class="[@@ -260,9 +266,9 @@ function updateDropTarget(ev: PointerEvent) {<component:is="nodeIcons[item.value.type] ?? IconSquare"class="size-3 shrink-0"- :class="COMPONENT_TYPES.has(item.value.type)- ? 'text-[#9747ff] opacity-100'- : 'opacity-70'"+ :class="+ COMPONENT_TYPES.has(item.value.type) ? 'text-[#9747ff] opacity-100' : 'opacity-70'+ "/><span class="min-w-0 flex-1 truncate">{{ item.value.name }}</span><icon-lucide-eye-offdiff --git a/src/components/PagesPanel.vue b/src/components/PagesPanel.vueindex c5baa60e3..ca7543925 100644--- a/src/components/PagesPanel.vue+++ b/src/components/PagesPanel.vue@@ -45,7 +45,9 @@ function onKeydown(e: KeyboardEvent, pageId: string) {class="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface"title="Add page"@click="store.addPage()"- >+</button>+ >+ ++ </button></div><div class="px-1 pb-1"><div v-for="pg in pages" :key="pg.id">@@ -60,7 +62,11 @@ function onKeydown(e: KeyboardEvent, pageId: string) {<buttonv-elseclass="flex w-full cursor-pointer items-center gap-1.5 rounded border-none px-2 py-1 text-left text-xs"- :class="pg.id === store.state.currentPageId ? 'bg-hover text-surface' : 'bg-transparent text-muted hover:bg-hover hover:text-surface'"+ :class="+ pg.id === store.state.currentPageId+ ? 'bg-hover text-surface'+ : 'bg-transparent text-muted hover:bg-hover hover:text-surface'+ "@click="store.switchPage(pg.id)"@dblclick="startRename(pg.id)">diff --git a/src/components/PropertiesPanel.vue b/src/components/PropertiesPanel.vueindex 52bd8333e..c2abcf28b 100644--- a/src/components/PropertiesPanel.vue+++ b/src/components/PropertiesPanel.vue@@ -28,7 +28,9 @@ const isComponentType = computed(() => {<div class="flex h-10 shrink-0 items-center gap-1 border-b border-border px-2"><button class="rounded px-2.5 py-1 text-xs font-semibold text-surface">Design</button><button class="rounded px-2.5 py-1 text-xs text-muted">Prototype</button>- <span class="ml-auto cursor-pointer rounded px-1.5 py-0.5 text-[11px] text-muted hover:bg-hover">+ <span+ class="ml-auto cursor-pointer rounded px-1.5 py-0.5 text-[11px] text-muted hover:bg-hover"+ >{{ Math.round(store.state.zoom * 100) }}%</span></div>@@ -46,15 +48,17 @@ const isComponentType = computed(() => {<div v-else-if="node" class="flex-1 overflow-y-auto pb-4"><!-- Node header --><div class="flex items-center gap-1.5 border-b border-border px-3 py-2">- <span- class="text-[11px]"- :class="isComponentType ? 'text-[#9747ff]' : 'text-muted'"- >{{ node.type }}</span>+ <span class="text-[11px]" :class="isComponentType ? 'text-[#9747ff]' : 'text-muted'">{{+ node.type+ }}</span><span class="text-xs font-semibold">{{ node.name }}</span></div><!-- Component actions -->- <div v-if="node.type === 'INSTANCE'" class="flex flex-col gap-1 border-b border-border px-3 py-2">+ <div+ v-if="node.type === 'INSTANCE'"+ class="flex flex-col gap-1 border-b border-border px-3 py-2"+ ><buttonclass="rounded bg-[#9747ff]/10 px-2 py-1 text-left text-[11px] text-[#9747ff] hover:bg-[#9747ff]/20"@click="store.goToMainComponent()"diff --git a/src/components/ScrubInput.vue b/src/components/ScrubInput.vueindex d1196652f..c893903dd 100644--- a/src/components/ScrubInput.vue+++ b/src/components/ScrubInput.vue@@ -2,25 +2,28 @@import { ref, computed } from 'vue'import { useEventListener } from '@vueuse/core'-const props = withDefaults(defineProps<{- modelValue: number- min?: number- max?: number- step?: number- icon?: string- label?: string- suffix?: string- sensitivity?: number-}>(), {- min: -Infinity,- max: Infinity,- step: 1,- sensitivity: 1,-})+const props = withDefaults(+ defineProps<{+ modelValue: number+ min?: number+ max?: number+ step?: number+ icon?: string+ label?: string+ suffix?: string+ sensitivity?: number+ }>(),+ {+ min: -Infinity,+ max: Infinity,+ step: 1,+ sensitivity: 1+ }+)const emit = defineEmits<{'update:modelValue': [value: number]- 'commit': [value: number, previous: number]+ commit: [value: number, previous: number]}>()const editing = ref(false)diff --git a/src/components/Toolbar.vue b/src/components/Toolbar.vueindex a5816369c..6da1970fc 100644--- a/src/components/Toolbar.vue+++ b/src/components/Toolbar.vue@@ -1,5 +1,11 @@<script setup lang="ts">-import { DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuPortal } from 'reka-ui'+import {+ DropdownMenuRoot,+ DropdownMenuTrigger,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuPortal+} from 'reka-ui'import IconMousePointer from '~icons/lucide/mouse-pointer'import IconFrame from '~icons/lucide/frame'@@ -62,12 +68,12 @@ const toolShortcuts: Record<Tool, string> = {HAND: 'H'}-function isActive(tool: typeof TOOLS[number]): boolean {+function isActive(tool: (typeof TOOLS)[number]): boolean {if (tool.key === store.state.activeTool) return truereturn tool.flyout?.includes(store.state.activeTool) ?? false}-function activeKeyForTool(tool: typeof TOOLS[number]): Tool {+function activeKeyForTool(tool: (typeof TOOLS)[number]): Tool {if (tool.flyout?.includes(store.state.activeTool)) return store.state.activeToolreturn tool.key}@@ -81,9 +87,11 @@ function activeKeyForTool(tool: typeof TOOLS[number]): Tool {<div v-if="tool.flyout && tool.flyout.length > 1" class="flex items-center"><buttonclass="flex size-8 cursor-pointer items-center justify-center rounded-lg border-none transition-colors"- :class="isActive(tool)- ? 'bg-accent text-white'- : 'bg-transparent text-muted hover:bg-hover hover:text-surface'"+ :class="+ isActive(tool)+ ? 'bg-accent text-white'+ : 'bg-transparent text-muted hover:bg-hover hover:text-surface'+ ":title="`${toolLabels[activeKeyForTool(tool)]} (${tool.shortcut})`"@click="store.setTool(activeKeyForTool(tool))">@@ -94,9 +102,11 @@ function activeKeyForTool(tool: typeof TOOLS[number]): Tool {<DropdownMenuTrigger as-child><buttonclass="flex h-8 w-3 cursor-pointer items-center justify-center rounded-lg border-none transition-colors"- :class="isActive(tool)- ? 'bg-accent text-white'- : 'bg-transparent text-muted hover:bg-hover hover:text-surface'"+ :class="+ isActive(tool)+ ? 'bg-accent text-white'+ : 'bg-transparent text-muted hover:bg-hover hover:text-surface'+ "><IconChevronDown class="size-2.5" /></button>@@ -113,14 +123,18 @@ function activeKeyForTool(tool: typeof TOOLS[number]): Tool {v-for="sub in tool.flyout":key="sub"class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none transition-colors"- :class="store.state.activeTool === sub- ? 'bg-accent text-white'- : 'text-surface hover:bg-hover'"+ :class="+ store.state.activeTool === sub+ ? 'bg-accent text-white'+ : 'text-surface hover:bg-hover'+ "@select="store.setTool(sub)"><component :is="toolIcons[sub]" class="size-3.5" /><span class="flex-1">{{ toolLabels[sub] }}</span>- <span v-if="toolShortcuts[sub]" class="text-[11px] text-muted">{{ toolShortcuts[sub] }}</span>+ <span v-if="toolShortcuts[sub]" class="text-[11px] text-muted">{{+ toolShortcuts[sub]+ }}</span></DropdownMenuItem></DropdownMenuContent></DropdownMenuPortal>@@ -131,9 +145,11 @@ function activeKeyForTool(tool: typeof TOOLS[number]): Tool {<buttonv-elseclass="flex size-8 cursor-pointer items-center justify-center rounded-lg border-none transition-colors"- :class="isActive(tool)- ? 'bg-accent text-white'- : 'bg-transparent text-muted hover:bg-hover hover:text-surface'"+ :class="+ isActive(tool)+ ? 'bg-accent text-white'+ : 'bg-transparent text-muted hover:bg-hover hover:text-surface'+ ":title="`${toolLabels[tool.key]} (${tool.shortcut})`"@click="store.setTool(tool.key)">diff --git a/src/components/properties/AppearanceSection.vue b/src/components/properties/AppearanceSection.vueindex 208143f4d..c8f7ac26d 100644--- a/src/components/properties/AppearanceSection.vue+++ b/src/components/properties/AppearanceSection.vue@@ -8,7 +8,13 @@ import type { SceneNode } from '../../engine/scene-graph'const { store, node, updateProp, commitProp } = useNodeProps()-const CORNER_RADIUS_TYPES = new Set(['RECTANGLE', 'ROUNDED_RECTANGLE', 'FRAME', 'COMPONENT', 'INSTANCE'])+const CORNER_RADIUS_TYPES = new Set([+ 'RECTANGLE',+ 'ROUNDED_RECTANGLE',+ 'FRAME',+ 'COMPONENT',+ 'INSTANCE'+])const hasCornerRadius = computed(() => node.value && CORNER_RADIUS_TYPES.has(node.value.type))@@ -31,9 +37,9 @@ function toggleIndependentCorners() {topLeftRadius: uniform,topRightRadius: uniform,bottomRightRadius: uniform,- bottomLeftRadius: uniform,+ bottomLeftRadius: uniform} as Partial<SceneNode>,- 'Uniform corner radius',+ 'Uniform corner radius')} else {store.updateNodeWithUndo(@@ -43,9 +49,9 @@ function toggleIndependentCorners() {topLeftRadius: n.cornerRadius,topRightRadius: n.cornerRadius,bottomRightRadius: n.cornerRadius,- bottomLeftRadius: n.cornerRadius,+ bottomLeftRadius: n.cornerRadius} as Partial<SceneNode>,- 'Independent corner radii',+ 'Independent corner radii')}}@@ -104,7 +110,13 @@ function commitCornerProp(key: string, value: number, previous: number) {title="Independent corner radii"@click="toggleIndependentCorners">- <svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5">+ <svg+ class="size-3"+ viewBox="0 0 12 12"+ fill="none"+ stroke="currentColor"+ stroke-width="1.5"+ ><path d="M1 4V2.5A1.5 1.5 0 0 1 2.5 1H4" /><path d="M8 1h1.5A2.5 2.5 0 0 1 11 3.5V5" /><path d="M11 8v1a2 2 0 0 1-2 2H8" />@@ -122,7 +134,13 @@ function commitCornerProp(key: string, value: number, previous: number) {@commit="(v: number, p: number) => commitCornerProp('topLeftRadius', v, p)"><template #icon>- <svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5">+ <svg+ class="size-3"+ viewBox="0 0 12 12"+ fill="none"+ stroke="currentColor"+ stroke-width="1.5"+ ><path d="M1 11V4a3 3 0 0 1 3-3h7" /></svg></template>@@ -134,7 +152,13 @@ function commitCornerProp(key: string, value: number, previous: number) {@commit="(v: number, p: number) => commitCornerProp('topRightRadius', v, p)"><template #icon>- <svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5">+ <svg+ class="size-3"+ viewBox="0 0 12 12"+ fill="none"+ stroke="currentColor"+ stroke-width="1.5"+ ><path d="M11 11V4a3 3 0 0 0-3-3H1" /></svg></template>@@ -146,7 +170,13 @@ function commitCornerProp(key: string, value: number, previous: number) {@commit="(v: number, p: number) => commitCornerProp('bottomLeftRadius', v, p)"><template #icon>- <svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5">+ <svg+ class="size-3"+ viewBox="0 0 12 12"+ fill="none"+ stroke="currentColor"+ stroke-width="1.5"+ ><path d="M1 1v7a3 3 0 0 0 3 3h7" /></svg></template>@@ -158,7 +188,13 @@ function commitCornerProp(key: string, value: number, previous: number) {@commit="(v: number, p: number) => commitCornerProp('bottomRightRadius', v, p)"><template #icon>- <svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5">+ <svg+ class="size-3"+ viewBox="0 0 12 12"+ fill="none"+ stroke="currentColor"+ stroke-width="1.5"+ ><path d="M11 1v7a3 3 0 0 1-3 3H1" /></svg></template>diff --git a/src/components/properties/EffectsSection.vue b/src/components/properties/EffectsSection.vueindex d5760e8bf..bd182da3a 100644--- a/src/components/properties/EffectsSection.vue+++ b/src/components/properties/EffectsSection.vue@@ -18,7 +18,7 @@ const EFFECT_LABELS: Record<string, string> = {INNER_SHADOW: 'Inner shadow',LAYER_BLUR: 'Layer blur',BACKGROUND_BLUR: 'Background blur',- FOREGROUND_BLUR: 'Foreground blur',+ FOREGROUND_BLUR: 'Foreground blur'}const EFFECT_TYPES = Object.keys(EFFECT_LABELS) as EffectType[]@@ -34,7 +34,7 @@ function defaultEffect(): Effect {offset: { x: 0, y: 4 },radius: 4,spread: 0,- visible: true,+ visible: true}}@@ -85,7 +85,7 @@ function remove(index: number) {store.updateNodeWithUndo(node.value!.id,{ effects: node.value!.effects.filter((_, i) => i !== index) },- 'Remove effect',+ 'Remove effect')if (expandedIndex.value === index) expandedIndex.value = nullelse if (expandedIndex.value !== null && expandedIndex.value > index) expandedIndex.value--@@ -103,7 +103,9 @@ function toggleExpand(index: number) {<buttonclass="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"@click="add"- >+</button>+ >+ ++ </button></div><div v-for="(effect, i) in node.effects" :key="i">@@ -112,7 +114,9 @@ function toggleExpand(index: number) {<buttonv-if="isShadow(effect.type)"class="size-5 shrink-0 cursor-pointer rounded border border-border"- :style="{ background: `rgba(${Math.round(effect.color.r * 255)}, ${Math.round(effect.color.g * 255)}, ${Math.round(effect.color.b * 255)}, ${effect.color.a})` }"+ :style="{+ background: `rgba(${Math.round(effect.color.r * 255)}, ${Math.round(effect.color.g * 255)}, ${Math.round(effect.color.b * 255)}, ${effect.color.a})`+ }"@click="toggleExpand(i)"/><button@@ -128,7 +132,9 @@ function toggleExpand(index: number) {:value="effect.type"@change="updateType(i, ($event.target as HTMLSelectElement).value as EffectType)">- <option v-for="t in EFFECT_TYPES" :key="t" :value="t" class="bg-panel text-surface">{{ EFFECT_LABELS[t] }}</option>+ <option v-for="t in EFFECT_TYPES" :key="t" :value="t" class="bg-panel text-surface">+ {{ EFFECT_LABELS[t] }}+ </option></select><button@@ -141,7 +147,9 @@ function toggleExpand(index: number) {<buttonclass="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"@click="remove(i)"- >−</button>+ >+ −+ </button></div><!-- Expanded controls inline -->diff --git a/src/components/properties/FillSection.vue b/src/components/properties/FillSection.vueindex 10d46cc08..cf584e353 100644--- a/src/components/properties/FillSection.vue+++ b/src/components/properties/FillSection.vue@@ -28,11 +28,19 @@ function toggleVisibility(index: number) {}function add() {- store.updateNodeWithUndo(node.value.id, { fills: [...node.value.fills, { ...DEFAULT_SHAPE_FILL }] }, 'Add fill')+ store.updateNodeWithUndo(+ node.value.id,+ { fills: [...node.value.fills, { ...DEFAULT_SHAPE_FILL }] },+ 'Add fill'+ )}function remove(index: number) {- store.updateNodeWithUndo(node.value.id, { fills: node.value.fills.filter((_, i) => i !== index) }, 'Remove fill')+ store.updateNodeWithUndo(+ node.value.id,+ { fills: node.value.fills.filter((_, i) => i !== index) },+ 'Remove fill'+ )}</script>@@ -40,13 +48,20 @@ function remove(index: number) {<div v-if="node" class="border-b border-border px-3 py-2"><div class="flex items-center justify-between"><label class="mb-1 block text-[11px] text-muted">Fill</label>- <button class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface" @click="add">+</button>+ <button+ class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"+ @click="add"+ >+ ++ </button></div><div v-for="(fill, i) in node.fills" :key="i" class="group flex items-center gap-1.5 py-0.5"><FillPicker :fill="fill" @update="updateFill(i, $event)" /><span class="min-w-0 flex-1 font-mono text-xs text-surface"><template v-if="fill.type === 'SOLID'">{{ colorToHexRaw(fill.color) }}</template>- <template v-else-if="fill.type.startsWith('GRADIENT')">{{ fill.type.replace('GRADIENT_', '') }}</template>+ <template v-else-if="fill.type.startsWith('GRADIENT')">{{+ fill.type.replace('GRADIENT_', '')+ }}</template><template v-else>{{ fill.type }}</template></span><ScrubInput@@ -64,7 +79,12 @@ function remove(index: number) {<icon-lucide-eye v-if="fill.visible" class="size-3.5" /><icon-lucide-eye-off v-else class="size-3.5" /></button>- <button class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface" @click="remove(i)">−</button>+ <button+ class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"+ @click="remove(i)"+ >+ −+ </button></div></div></template>diff --git a/src/components/properties/LayoutSection.vue b/src/components/properties/LayoutSection.vueindex 282f4e321..738baf230 100644--- a/src/components/properties/LayoutSection.vue+++ b/src/components/properties/LayoutSection.vue@@ -5,7 +5,12 @@ import { onClickOutside } from '@vueuse/core'import ScrubInput from '../ScrubInput.vue'import { useNodeProps } from '../../composables/use-node-props'-import type { SceneNode, LayoutSizing, LayoutAlign, LayoutCounterAlign } from '../../engine/scene-graph'+import type {+ SceneNode,+ LayoutSizing,+ LayoutAlign,+ LayoutCounterAlign+} from '../../engine/scene-graph'const { store, node, updateProp, commitProp } = useNodeProps()@@ -15,8 +20,12 @@ const heightSizingOpen = ref(false)const widthDimRef = ref<HTMLElement | null>(null)const heightDimRef = ref<HTMLElement | null>(null)-onClickOutside(widthDimRef, () => { widthSizingOpen.value = false })-onClickOutside(heightDimRef, () => { heightSizingOpen.value = false })+onClickOutside(widthDimRef, () => {+ widthSizingOpen.value = false+})+onClickOutside(heightDimRef, () => {+ heightSizingOpen.value = false+})const isInAutoLayout = computed(() => {if (!node.value.parentId) return false@@ -26,7 +35,9 @@ const isInAutoLayout = computed(() => {const widthSizing = computed(() => {if (node.value.layoutMode !== 'NONE') {- return node.value.layoutMode === 'HORIZONTAL' ? node.value.primaryAxisSizing : node.value.counterAxisSizing+ return node.value.layoutMode === 'HORIZONTAL'+ ? node.value.primaryAxisSizing+ : node.value.counterAxisSizing}if (isInAutoLayout.value && node.value.layoutGrow > 0) return 'FILL'return 'FIXED'@@ -34,7 +45,9 @@ const widthSizing = computed(() => {const heightSizing = computed(() => {if (node.value.layoutMode !== 'NONE') {- return node.value.layoutMode === 'VERTICAL' ? node.value.primaryAxisSizing : node.value.counterAxisSizing+ return node.value.layoutMode === 'VERTICAL'+ ? node.value.primaryAxisSizing+ : node.value.counterAxisSizing}if (isInAutoLayout.value && node.value.layoutAlignSelf === 'STRETCH') return 'FILL'return 'FIXED'@@ -67,19 +80,33 @@ function sizingLabel(s: string) {}function hasUniformPadding() {- return node.value.paddingTop === node.value.paddingRight &&+ return (+ node.value.paddingTop === node.value.paddingRight &&node.value.paddingRight === node.value.paddingBottom &&node.value.paddingBottom === node.value.paddingLeft+ )}function setUniformPadding(v: number) {- store.updateNode(node.value.id, { paddingTop: v, paddingRight: v, paddingBottom: v, paddingLeft: v })+ store.updateNode(node.value.id, {+ paddingTop: v,+ paddingRight: v,+ paddingBottom: v,+ paddingLeft: v+ })}function commitUniformPadding(_value: number, previous: number) {- store.commitNodeUpdate(node.value.id, {- paddingTop: previous, paddingRight: previous, paddingBottom: previous, paddingLeft: previous- } as unknown as Partial<SceneNode>, 'Change padding')+ store.commitNodeUpdate(+ node.value.id,+ {+ paddingTop: previous,+ paddingRight: previous,+ paddingBottom: previous,+ paddingLeft: previous+ } as unknown as Partial<SceneNode>,+ 'Change padding'+ )}const ALIGN_GRID: Array<{ primary: LayoutAlign; counter: LayoutCounterAlign }> = [@@ -95,7 +122,11 @@ const ALIGN_GRID: Array<{ primary: LayoutAlign; counter: LayoutCounterAlign }> =]function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {- store.updateNodeWithUndo(node.value.id, { primaryAxisAlign: primary, counterAxisAlign: counter }, 'Change alignment')+ store.updateNodeWithUndo(+ node.value.id,+ { primaryAxisAlign: primary, counterAxisAlign: counter },+ 'Change alignment'+ )}</script>@@ -105,40 +136,94 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {<div class="flex gap-1.5"><!-- Width --><div ref="widthDimRef" class="relative flex min-w-0 flex-1 items-center gap-1">- <ScrubInput icon="W" :model-value="Math.round(node.width)" :min="0" @update:model-value="updateProp('width', $event)" @commit="(v: number, p: number) => commitProp('width', v, p)" />+ <ScrubInput+ icon="W"+ :model-value="Math.round(node.width)"+ :min="0"+ @update:model-value="updateProp('width', $event)"+ @commit="(v: number, p: number) => commitProp('width', v, p)"+ /><buttonv-if="node.layoutMode !== 'NONE' || isInAutoLayout"class="cursor-pointer whitespace-nowrap rounded border-none bg-transparent px-1 py-px text-[10px] text-muted hover:bg-hover hover:text-surface"@click="widthSizingOpen = !widthSizingOpen"- >{{ sizingLabel(widthSizing) }}</button>- <div v-if="widthSizingOpen" class="absolute top-full left-0 right-0 z-10 min-w-40 rounded-md border border-border bg-panel p-1 shadow-lg">- <button class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover" :class="widthSizing === 'FIXED' ? 'text-accent' : 'text-surface'" @click="setWidthSizing('FIXED')">- <span class="w-4 text-center text-[11px] opacity-70">↔</span>Fixed width ({{ Math.round(node.width) }})+ >+ {{ sizingLabel(widthSizing) }}+ </button>+ <div+ v-if="widthSizingOpen"+ class="absolute top-full left-0 right-0 z-10 min-w-40 rounded-md border border-border bg-panel p-1 shadow-lg"+ >+ <button+ class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover"+ :class="widthSizing === 'FIXED' ? 'text-accent' : 'text-surface'"+ @click="setWidthSizing('FIXED')"+ >+ <span class="w-4 text-center text-[11px] opacity-70">↔</span>Fixed width ({{+ Math.round(node.width)+ }})</button>- <button v-if="node.layoutMode !== 'NONE'" class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover" :class="widthSizing === 'HUG' ? 'text-accent' : 'text-surface'" @click="setWidthSizing('HUG')">+ <button+ v-if="node.layoutMode !== 'NONE'"+ class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover"+ :class="widthSizing === 'HUG' ? 'text-accent' : 'text-surface'"+ @click="setWidthSizing('HUG')"+ ><span class="w-4 text-center text-[11px] opacity-70">↤↦</span>Hug contents</button>- <button v-if="isInAutoLayout" class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover" :class="widthSizing === 'FILL' ? 'text-accent' : 'text-surface'" @click="setWidthSizing('FILL')">+ <button+ v-if="isInAutoLayout"+ class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover"+ :class="widthSizing === 'FILL' ? 'text-accent' : 'text-surface'"+ @click="setWidthSizing('FILL')"+ ><span class="w-4 text-center text-[11px] opacity-70">⟷</span>Fill container</button></div></div><!-- Height --><div ref="heightDimRef" class="relative flex min-w-0 flex-1 items-center gap-1">- <ScrubInput icon="H" :model-value="Math.round(node.height)" :min="0" @update:model-value="updateProp('height', $event)" @commit="(v: number, p: number) => commitProp('height', v, p)" />+ <ScrubInput+ icon="H"+ :model-value="Math.round(node.height)"+ :min="0"+ @update:model-value="updateProp('height', $event)"+ @commit="(v: number, p: number) => commitProp('height', v, p)"+ /><buttonv-if="node.layoutMode !== 'NONE' || isInAutoLayout"class="cursor-pointer whitespace-nowrap rounded border-none bg-transparent px-1 py-px text-[10px] text-muted hover:bg-hover hover:text-surface"@click="heightSizingOpen = !heightSizingOpen"- >{{ sizingLabel(heightSizing) }}</button>- <div v-if="heightSizingOpen" class="absolute top-full left-0 right-0 z-10 min-w-40 rounded-md border border-border bg-panel p-1 shadow-lg">- <button class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover" :class="heightSizing === 'FIXED' ? 'text-accent' : 'text-surface'" @click="setHeightSizing('FIXED')">- <span class="w-4 text-center text-[11px] opacity-70">↕</span>Fixed height ({{ Math.round(node.height) }})+ >+ {{ sizingLabel(heightSizing) }}+ </button>+ <div+ v-if="heightSizingOpen"+ class="absolute top-full left-0 right-0 z-10 min-w-40 rounded-md border border-border bg-panel p-1 shadow-lg"+ >+ <button+ class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover"+ :class="heightSizing === 'FIXED' ? 'text-accent' : 'text-surface'"+ @click="setHeightSizing('FIXED')"+ >+ <span class="w-4 text-center text-[11px] opacity-70">↕</span>Fixed height ({{+ Math.round(node.height)+ }})</button>- <button v-if="node.layoutMode !== 'NONE'" class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover" :class="heightSizing === 'HUG' ? 'text-accent' : 'text-surface'" @click="setHeightSizing('HUG')">+ <button+ v-if="node.layoutMode !== 'NONE'"+ class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover"+ :class="heightSizing === 'HUG' ? 'text-accent' : 'text-surface'"+ @click="setHeightSizing('HUG')"+ ><span class="w-4 text-center text-[11px] opacity-70">↤↦</span>Hug contents</button>- <button v-if="isInAutoLayout" class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover" :class="heightSizing === 'FILL' ? 'text-accent' : 'text-surface'" @click="setHeightSizing('FILL')">+ <button+ v-if="isInAutoLayout"+ class="flex w-full cursor-pointer items-center gap-2 rounded border-none bg-transparent px-2 py-1.5 text-left text-xs hover:bg-hover"+ :class="heightSizing === 'FILL' ? 'text-accent' : 'text-surface'"+ @click="setHeightSizing('FILL')"+ ><span class="w-4 text-center text-[11px] opacity-70">⟷</span>Fill container</button></div>@@ -155,13 +240,17 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {class="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface"title="Add auto layout (Shift+A)"@click="store.setLayoutMode(node.id, 'VERTICAL')"- >+</button>+ >+ ++ </button><buttonv-elseclass="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface"title="Remove auto layout"@click="store.setLayoutMode(node.id, 'NONE')"- >−</button>+ >+ −+ </button></div><template v-if="node.layoutMode !== 'NONE'">@@ -169,27 +258,51 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {<div class="mt-1.5 flex gap-0.5"><buttonclass="flex cursor-pointer items-center justify-center rounded border px-2 py-1"- :class="node.layoutMode === 'VERTICAL' ? 'border-accent bg-accent text-white' : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'"+ :class="+ node.layoutMode === 'VERTICAL'+ ? 'border-accent bg-accent text-white'+ : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'+ "title="Vertical layout"@click="store.setLayoutMode(node.id, 'VERTICAL')">- <svg width="16" height="16" viewBox="0 0 16 16"><rect x="3" y="2" width="10" height="3" rx="0.5" fill="currentColor" /><rect x="3" y="6.5" width="10" height="3" rx="0.5" fill="currentColor" /><rect x="3" y="11" width="10" height="3" rx="0.5" fill="currentColor" /></svg>+ <svg width="16" height="16" viewBox="0 0 16 16">+ <rect x="3" y="2" width="10" height="3" rx="0.5" fill="currentColor" />+ <rect x="3" y="6.5" width="10" height="3" rx="0.5" fill="currentColor" />+ <rect x="3" y="11" width="10" height="3" rx="0.5" fill="currentColor" />+ </svg></button><buttonclass="flex cursor-pointer items-center justify-center rounded border px-2 py-1"- :class="node.layoutMode === 'HORIZONTAL' ? 'border-accent bg-accent text-white' : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'"+ :class="+ node.layoutMode === 'HORIZONTAL'+ ? 'border-accent bg-accent text-white'+ : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'+ "title="Horizontal layout"@click="store.setLayoutMode(node.id, 'HORIZONTAL')">- <svg width="16" height="16" viewBox="0 0 16 16"><rect x="2" y="3" width="3" height="10" rx="0.5" fill="currentColor" /><rect x="6.5" y="3" width="3" height="10" rx="0.5" fill="currentColor" /><rect x="11" y="3" width="3" height="10" rx="0.5" fill="currentColor" /></svg>+ <svg width="16" height="16" viewBox="0 0 16 16">+ <rect x="2" y="3" width="3" height="10" rx="0.5" fill="currentColor" />+ <rect x="6.5" y="3" width="3" height="10" rx="0.5" fill="currentColor" />+ <rect x="11" y="3" width="3" height="10" rx="0.5" fill="currentColor" />+ </svg></button><buttonclass="flex cursor-pointer items-center justify-center rounded border px-2 py-1"- :class="node.layoutWrap === 'WRAP' ? 'border-accent bg-accent text-white' : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'"+ :class="+ node.layoutWrap === 'WRAP'+ ? 'border-accent bg-accent text-white'+ : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'+ "title="Wrap"@click="updateProp('layoutWrap', node.layoutWrap === 'WRAP' ? 'NO_WRAP' : 'WRAP')">- <svg width="16" height="16" viewBox="0 0 16 16"><rect x="2" y="2" width="5" height="5" rx="0.5" fill="currentColor" /><rect x="9" y="2" width="5" height="5" rx="0.5" fill="currentColor" /><rect x="2" y="9" width="5" height="5" rx="0.5" fill="currentColor" /></svg>+ <svg width="16" height="16" viewBox="0 0 16 16">+ <rect x="2" y="2" width="5" height="5" rx="0.5" fill="currentColor" />+ <rect x="9" y="2" width="5" height="5" rx="0.5" fill="currentColor" />+ <rect x="2" y="9" width="5" height="5" rx="0.5" fill="currentColor" />+ </svg></button></div>@@ -204,13 +317,26 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {><spanclass="rounded-full"- :class="node.primaryAxisAlign === a.primary && node.counterAxisAlign === a.counter ? 'size-1.5 bg-accent' : 'size-1 bg-muted opacity-40'"+ :class="+ node.primaryAxisAlign === a.primary && node.counterAxisAlign === a.counter+ ? 'size-1.5 bg-accent'+ : 'size-1 bg-muted opacity-40'+ "/></button></div>- <ScrubInput :model-value="node.itemSpacing" :min="0" @update:model-value="updateProp('itemSpacing', $event)" @commit="(v: number, p: number) => commitProp('itemSpacing', v, p)">+ <ScrubInput+ :model-value="node.itemSpacing"+ :min="0"+ @update:model-value="updateProp('itemSpacing', $event)"+ @commit="(v: number, p: number) => commitProp('itemSpacing', v, p)"+ ><template #icon>- <svg width="14" height="14" viewBox="0 0 14 14"><rect x="0" y="1" width="4" height="12" rx="0.5" fill="currentColor" opacity="0.4" /><rect x="5" y="5" width="4" height="4" rx="0.5" fill="currentColor" /><rect x="10" y="1" width="4" height="12" rx="0.5" fill="currentColor" opacity="0.4" /></svg>+ <svg width="14" height="14" viewBox="0 0 14 14">+ <rect x="0" y="1" width="4" height="12" rx="0.5" fill="currentColor" opacity="0.4" />+ <rect x="5" y="5" width="4" height="4" rx="0.5" fill="currentColor" />+ <rect x="10" y="1" width="4" height="12" rx="0.5" fill="currentColor" opacity="0.4" />+ </svg></template></ScrubInput></div>@@ -219,7 +345,15 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {<div class="mt-1.5 flex items-start gap-1"><template v-if="showIndividualPadding || !hasUniformPadding()"><div class="grid flex-1 grid-cols-2 gap-0.5">- <div v-for="side in ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'] as const" :key="side">+ <div+ v-for="side in [+ 'paddingTop',+ 'paddingRight',+ 'paddingBottom',+ 'paddingLeft'+ ] as const"+ :key="side"+ ><inputtype="number"class="w-full rounded border border-border bg-input px-1 py-0.5 text-center text-[11px] text-surface"@@ -231,19 +365,45 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {</div></template><template v-else>- <ScrubInput :model-value="node.paddingTop" :min="0" @update:model-value="setUniformPadding($event)" @commit="commitUniformPadding">+ <ScrubInput+ :model-value="node.paddingTop"+ :min="0"+ @update:model-value="setUniformPadding($event)"+ @commit="commitUniformPadding"+ ><template #icon>- <svg width="14" height="14" viewBox="0 0 14 14"><rect x="0" y="0" width="14" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="1" /><rect x="3" y="3" width="8" height="8" rx="1" fill="currentColor" opacity="0.3" /></svg>+ <svg width="14" height="14" viewBox="0 0 14 14">+ <rect+ x="0"+ y="0"+ width="14"+ height="14"+ rx="2"+ fill="none"+ stroke="currentColor"+ stroke-width="1"+ />+ <rect x="3" y="3" width="8" height="8" rx="1" fill="currentColor" opacity="0.3" />+ </svg></template></ScrubInput></template><buttonclass="flex shrink-0 cursor-pointer items-center justify-center rounded border p-1"- :class="showIndividualPadding || !hasUniformPadding() ? 'border-accent bg-accent text-white' : 'border-border text-muted hover:bg-hover hover:text-surface'"+ :class="+ showIndividualPadding || !hasUniformPadding()+ ? 'border-accent bg-accent text-white'+ : 'border-border text-muted hover:bg-hover hover:text-surface'+ "title="Individual padding"@click="showIndividualPadding = !showIndividualPadding">- <svg width="14" height="14" viewBox="0 0 14 14"><rect x="0" y="0" width="14" height="4" rx="1" fill="currentColor" opacity="0.6" /><rect x="10" y="0" width="4" height="14" rx="1" fill="currentColor" opacity="0.6" /><rect x="0" y="10" width="14" height="4" rx="1" fill="currentColor" opacity="0.6" /><rect x="0" y="0" width="4" height="14" rx="1" fill="currentColor" opacity="0.6" /></svg>+ <svg width="14" height="14" viewBox="0 0 14 14">+ <rect x="0" y="0" width="14" height="4" rx="1" fill="currentColor" opacity="0.6" />+ <rect x="10" y="0" width="4" height="14" rx="1" fill="currentColor" opacity="0.6" />+ <rect x="0" y="10" width="14" height="4" rx="1" fill="currentColor" opacity="0.6" />+ <rect x="0" y="0" width="4" height="14" rx="1" fill="currentColor" opacity="0.6" />+ </svg></button></div></template>@@ -256,7 +416,13 @@ function setAlignment(primary: LayoutAlign, counter: LayoutCounterAlign) {type="checkbox"class="accent-accent":checked="node.clipsContent"- @change="store.updateNodeWithUndo(node.id, { clipsContent: !node.clipsContent }, 'Toggle clip content')"+ @change="+ store.updateNodeWithUndo(+ node.id,+ { clipsContent: !node.clipsContent },+ 'Toggle clip content'+ )+ "/>Clip content</label>diff --git a/src/components/properties/PositionSection.vue b/src/components/properties/PositionSection.vueindex 63673ccc4..759ea9b16 100644--- a/src/components/properties/PositionSection.vue+++ b/src/components/properties/PositionSection.vue@@ -11,7 +11,8 @@ function alignHorizontal(align: HAlign) {const selected = nodes.valueif (selected.length < 2) return- let minX = Infinity, maxX = -Infinity+ let minX = Infinity,+ maxX = -Infinityfor (const n of selected) {const abs = store.graph.getAbsolutePosition(n.id)minX = Math.min(minX, abs.x)@@ -35,7 +36,8 @@ function alignVertical(align: VAlign) {const selected = nodes.valueif (selected.length < 2) return- let minY = Infinity, maxY = -Infinity+ let minY = Infinity,+ maxY = -Infinityfor (const n of selected) {const abs = store.graph.getAbsolutePosition(n.id)minY = Math.min(minY, abs.y)@@ -130,13 +132,31 @@ function rotate90() {<!-- X / Y --><div class="flex gap-1.5">- <ScrubInput icon="X" :model-value="Math.round(node.x)" @update:model-value="updateProp('x', $event)" @commit="(v: number, p: number) => commitProp('x', v, p)" />- <ScrubInput icon="Y" :model-value="Math.round(node.y)" @update:model-value="updateProp('y', $event)" @commit="(v: number, p: number) => commitProp('y', v, p)" />+ <ScrubInput+ icon="X"+ :model-value="Math.round(node.x)"+ @update:model-value="updateProp('x', $event)"+ @commit="(v: number, p: number) => commitProp('x', v, p)"+ />+ <ScrubInput+ icon="Y"+ :model-value="Math.round(node.y)"+ @update:model-value="updateProp('y', $event)"+ @commit="(v: number, p: number) => commitProp('y', v, p)"+ /></div><!-- Rotation + flip --><div class="mt-1.5 flex items-center gap-1.5">- <ScrubInput class="flex-1" suffix="°" :model-value="Math.round(node.rotation)" :min="-360" :max="360" @update:model-value="updateProp('rotation', $event)" @commit="(v: number, p: number) => commitProp('rotation', v, p)">+ <ScrubInput+ class="flex-1"+ suffix="°"+ :model-value="Math.round(node.rotation)"+ :min="-360"+ :max="360"+ @update:model-value="updateProp('rotation', $event)"+ @commit="(v: number, p: number) => commitProp('rotation', v, p)"+ ><template #icon><icon-lucide-rotate-ccw class="size-3" /></template>diff --git a/src/components/properties/StrokeSection.vue b/src/components/properties/StrokeSection.vueindex dcb099b23..6a0a21956 100644--- a/src/components/properties/StrokeSection.vue+++ b/src/components/properties/StrokeSection.vue@@ -39,12 +39,26 @@ function toggleVisibility(index: number) {}function add() {- const stroke: Stroke = { color: { r: 0, g: 0, b: 0, a: 1 }, weight: 1, opacity: 1, visible: true, align: 'CENTER' }- store.updateNodeWithUndo(node.value.id, { strokes: [...node.value.strokes, stroke] }, 'Add stroke')+ const stroke: Stroke = {+ color: { r: 0, g: 0, b: 0, a: 1 },+ weight: 1,+ opacity: 1,+ visible: true,+ align: 'CENTER'+ }+ store.updateNodeWithUndo(+ node.value.id,+ { strokes: [...node.value.strokes, stroke] },+ 'Add stroke'+ )}function remove(index: number) {- store.updateNodeWithUndo(node.value.id, { strokes: node.value.strokes.filter((_, i) => i !== index) }, 'Remove stroke')+ store.updateNodeWithUndo(+ node.value.id,+ { strokes: node.value.strokes.filter((_, i) => i !== index) },+ 'Remove stroke'+ )}</script>@@ -52,9 +66,18 @@ function remove(index: number) {<div v-if="node" class="border-b border-border px-3 py-2"><div class="flex items-center justify-between"><label class="mb-1 block text-[11px] text-muted">Stroke</label>- <button class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface" @click="add">+</button>+ <button+ class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"+ @click="add"+ >+ ++ </button></div>- <div v-for="(stroke, i) in node.strokes" :key="i" class="group flex items-center gap-1.5 py-0.5">+ <div+ v-for="(stroke, i) in node.strokes"+ :key="i"+ class="group flex items-center gap-1.5 py-0.5"+ ><ColorPicker :color="stroke.color" @update="updateColor(i, $event)" /><inputclass="min-w-0 flex-1 border-none bg-transparent font-mono text-xs text-surface outline-none"@@ -76,7 +99,12 @@ function remove(index: number) {<icon-lucide-eye v-if="stroke.visible" class="size-3.5" /><icon-lucide-eye-off v-else class="size-3.5" /></button>- <button class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface" @click="remove(i)">−</button>+ <button+ class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"+ @click="remove(i)"+ >+ −+ </button></div><div v-if="node.strokes.length > 0" class="mt-1 flex items-center gap-1.5"><ScrubInputdiff --git a/src/components/properties/TypographySection.vue b/src/components/properties/TypographySection.vueindex 4da44d600..53b8b02f1 100644--- a/src/components/properties/TypographySection.vue+++ b/src/components/properties/TypographySection.vue@@ -14,7 +14,9 @@ const fontFamilies = ref<string[]>([])const fontPickerRef = ref<HTMLElement | null>(null)const searchInputRef = ref<HTMLInputElement | null>(null)-onClickOutside(fontPickerRef, () => { fontPickerOpen.value = false })+onClickOutside(fontPickerRef, () => {+ fontPickerOpen.value = false+})const filteredFamilies = computed(() => {const q = fontSearch.value.toLowerCase()@@ -34,8 +36,8 @@ const WEIGHTS = [{ value: 900, label: 'Black' }]-const currentWeightLabel = computed(() =>- WEIGHTS.find((w) => w.value === node.value.fontWeight)?.label ?? 'Regular'+const currentWeightLabel = computed(+ () => WEIGHTS.find((w) => w.value === node.value.fontWeight)?.label ?? 'Regular')type TextAlign = 'LEFT' | 'CENTER' | 'RIGHT'@@ -119,7 +121,10 @@ onMounted(async () => {<span v-else class="size-3 shrink-0" /><span class="truncate">{{ family }}</span></button>- <div v-if="filteredFamilies.length === 0" class="px-2 py-3 text-center text-xs text-muted">+ <div+ v-if="filteredFamilies.length === 0"+ class="px-2 py-3 text-center text-xs text-muted"+ >No fonts found</div></div>@@ -174,12 +179,14 @@ onMounted(async () => {<!-- Text alignment --><div class="flex gap-0.5"><button- v-for="align in (['LEFT', 'CENTER', 'RIGHT'] as TextAlign[])"+ v-for="align in ['LEFT', 'CENTER', 'RIGHT'] as TextAlign[]":key="align"class="flex cursor-pointer items-center justify-center rounded border px-2 py-1"- :class="node.textAlignHorizontal === align- ? 'border-accent bg-accent text-white'- : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'"+ :class="+ node.textAlignHorizontal === align+ ? 'border-accent bg-accent text-white'+ : 'border-border bg-input text-muted hover:bg-hover hover:text-surface'+ "@click="setAlign(align)"><icon-lucide-align-left v-if="align === 'LEFT'" class="size-3.5" />diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.tsindex 703358a49..0978d215e 100644--- a/src/composables/use-canvas-input.ts+++ b/src/composables/use-canvas-input.ts@@ -1,12 +1,17 @@import { useEventListener } from '@vueuse/core'import { ref, type Ref } from 'vue'-import { computeSelectionBounds, computeSnap } from '../engine/snap'import {- AUTO_LAYOUT_BREAK_THRESHOLD, HANDLE_HIT_RADIUS, ROTATION_HIT_RADIUS,- PEN_CLOSE_THRESHOLD, ROTATION_SNAP_DEGREES, ROTATION_HIT_OFFSET,- DEFAULT_TEXT_WIDTH, DEFAULT_TEXT_HEIGHT+ AUTO_LAYOUT_BREAK_THRESHOLD,+ HANDLE_HIT_RADIUS,+ ROTATION_HIT_RADIUS,+ PEN_CLOSE_THRESHOLD,+ ROTATION_SNAP_DEGREES,+ ROTATION_HIT_OFFSET,+ DEFAULT_TEXT_WIDTH,+ DEFAULT_TEXT_HEIGHT} from '../constants'+import { computeSelectionBounds, computeSnap } from '../engine/snap'import type { NodeType, SceneNode } from '../engine/scene-graph'import type { EditorStore, Tool } from '../stores/editor'@@ -81,8 +86,6 @@ const TOOL_TO_NODE: Partial<Record<Tool, NodeType>> = {TEXT: 'TEXT'}--const HANDLE_CURSORS: Record<HandlePosition, string> = {nw: 'nwse-resize',n: 'ns-resize',@@ -207,7 +210,10 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>,store: EditorStore,hitTestSectionTitle: (cx: number, cy: number) => import('../engine/scene-graph').SceneNode | null,- hitTestComponentLabel: (cx: number, cy: number) => import('../engine/scene-graph').SceneNode | null+ hitTestComponentLabel: (+ cx: number,+ cy: number+ ) => import('../engine/scene-graph').SceneNode | null) {const drag = ref<DragState | null>(null)const cursorOverride = ref<string | null>(null)@@ -317,7 +323,10 @@ export function useCanvasInput(}// Hit test nodes (labels first, then body)- const hit = hitTestSectionTitle(cx, cy) ?? hitTestComponentLabel(cx, cy) ?? store.graph.hitTest(cx, cy, store.state.currentPageId)+ const hit =+ hitTestSectionTitle(cx, cy) ??+ hitTestComponentLabel(cx, cy) ??+ store.graph.hitTest(cx, cy, store.state.currentPageId)if (hit) {if (!store.state.selectedIds.has(hit.id) && !e.shiftKey) {store.select([hit.id])@@ -487,7 +496,8 @@ export function useCanvasInput(}cursorOverride.value = cursor- const hit = hitTestSectionTitle(cx, cy) ?? hitTestComponentLabel(cx, cy) ?? store.graph.hitTest(cx, cy)+ const hit =+ hitTestSectionTitle(cx, cy) ?? hitTestComponentLabel(cx, cy) ?? store.graph.hitTest(cx, cy)store.setHoveredNode(hit && !store.state.selectedIds.has(hit.id) ? hit.id : null)}@@ -538,10 +548,22 @@ export function useCanvasInput(}// Check if we're hovering over an auto-layout frame- let dropTarget = store.graph.hitTestFrame(cx, cy, store.state.selectedIds, store.state.currentPageId)+ let dropTarget = store.graph.hitTestFrame(+ cx,+ cy,+ store.state.selectedIds,+ store.state.currentPageId+ )// Sections can't be dropped into frames or groups- const movingSection = [...store.state.selectedIds].some(id => store.graph.getNode(id)?.type === 'SECTION')- if (movingSection && dropTarget && dropTarget.type !== 'SECTION' && dropTarget.type !== 'CANVAS') {+ const movingSection = [...store.state.selectedIds].some(+ (id) => store.graph.getNode(id)?.type === 'SECTION'+ )+ if (+ movingSection &&+ dropTarget &&+ dropTarget.type !== 'SECTION' &&+ dropTarget.type !== 'CANVAS'+ ) {dropTarget = null}const dropParent = dropTarget ? store.graph.getNode(dropTarget.id) : null@@ -832,7 +854,10 @@ export function useCanvasInput(function onDblClick(e: MouseEvent) {const { cx, cy } = getCoords(e)- const hit = hitTestSectionTitle(cx, cy) ?? hitTestComponentLabel(cx, cy) ?? store.graph.hitTestDeep(cx, cy, store.state.currentPageId)+ const hit =+ hitTestSectionTitle(cx, cy) ??+ hitTestComponentLabel(cx, cy) ??+ store.graph.hitTestDeep(cx, cy, store.state.currentPageId)if (!hit) returnif (hit.type === 'TEXT') {@@ -853,9 +878,9 @@ export function useCanvasInput(}function computeAutoLayoutIndicatorForFrame(parent: SceneNode, cx: number, cy: number) {- const children = store.graph.getChildren(parent.id).filter(- (c) => c.layoutPositioning !== 'ABSOLUTE' && !store.state.selectedIds.has(c.id)- )+ const children = store.graph+ .getChildren(parent.id)+ .filter((c) => c.layoutPositioning !== 'ABSOLUTE' && !store.state.selectedIds.has(c.id))const parentAbs = store.graph.getAbsolutePosition(parent.id)const isRow = parent.layoutMode === 'HORIZONTAL'@@ -865,9 +890,7 @@ export function useCanvasInput(for (let i = 0; i < children.length; i++) {const child = children[i]const childAbs = store.graph.getAbsolutePosition(child.id)- const mid = isRow- ? childAbs.x + child.width / 2- : childAbs.y + child.height / 2+ const mid = isRow ? childAbs.x + child.width / 2 : childAbs.y + child.height / 2const cursor = isRow ? cx : cyif (cursor < mid) {@@ -884,9 +907,7 @@ export function useCanvasInput(: parent.width - parent.paddingLeft - parent.paddingRightif (children.length === 0) {- indicatorPos = isRow- ? parentAbs.x + parent.paddingLeft- : parentAbs.y + parent.paddingTop+ indicatorPos = isRow ? parentAbs.x + parent.paddingLeft : parentAbs.y + parent.paddingTop} else if (insertIndex === 0) {const first = children[0]const firstAbs = store.graph.getAbsolutePosition(first.id)diff --git a/src/composables/use-canvas.ts b/src/composables/use-canvas.tsindex a4c056d66..adc262389 100644--- a/src/composables/use-canvas.ts+++ b/src/composables/use-canvas.ts@@ -69,11 +69,13 @@ export function useCanvas(canvasRef: Ref<HTMLCanvasElement | null>, store: EditorotationPreview: store.state.rotationPreview,dropTargetId: store.state.dropTargetId,layoutInsertIndicator: store.state.layoutInsertIndicator,- penState: store.state.penState ? {- ...store.state.penState,- cursorX: store.state.penCursorX ?? undefined,- cursorY: store.state.penCursorY ?? undefined- } : null+ penState: store.state.penState+ ? {+ ...store.state.penState,+ cursorX: store.state.penCursorX ?? undefined,+ cursorY: store.state.penCursorY ?? undefined+ }+ : null})}diff --git a/src/composables/use-menu.ts b/src/composables/use-menu.tsindex b77ca148c..7d898ab38 100644--- a/src/composables/use-menu.ts+++ b/src/composables/use-menu.ts@@ -1,6 +1,7 @@import { onUnmounted } from 'vue'import { IS_TAURI } from '../constants'+import type { EditorStore } from '../stores/editor'export async function openFileDialog(store: EditorStore) {@@ -21,10 +22,12 @@ export async function openFileDialog(store: EditorStore) {if ('showOpenFilePicker' in window) {try {const [handle] = await (window as any).showOpenFilePicker({- types: [{- description: 'Figma file',- accept: { 'application/octet-stream': ['.fig'] }- }]+ types: [+ {+ description: 'Figma file',+ accept: { 'application/octet-stream': ['.fig'] }+ }+ ]})const file = await handle.getFile()await store.openFigFile(file, handle)@@ -55,7 +58,7 @@ const MENU_ACTIONS: Record<string, (store: EditorStore) => void> = {'create-component': (store) => store.createComponentFromSelection(),'create-component-set': (store) => store.createComponentSetFromComponents(),'detach-instance': (store) => store.detachInstance(),- 'zoom-fit': (store) => store.zoomToFit(),+ 'zoom-fit': (store) => store.zoomToFit()}export function useMenu(store: EditorStore) {diff --git a/src/constants.ts b/src/constants.tsindex d16333c9a..ceafc460a 100644--- a/src/constants.ts+++ b/src/constants.ts@@ -1,5 +1,5 @@-import type { Color } from './types'import type { Fill, Stroke } from './engine/scene-graph'+import type { Color } from './types'export const IS_TAURI = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in windowdiff --git a/src/demo.ts b/src/demo.tsindex b5aa98801..8e68c4b3b 100644--- a/src/demo.ts+++ b/src/demo.ts@@ -1,7 +1,8 @@-import type { EditorStore } from './stores/editor'-import type { Color, Fill, GradientStop } from './engine/scene-graph'import { computeAllLayouts } from './engine/layout'+import type { Color, Fill, GradientStop } from './engine/scene-graph'+import type { EditorStore } from './stores/editor'+const WHITE: Color = { r: 1, g: 1, b: 1, a: 1 }const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }const GRAY_50: Color = { r: 0.98, g: 0.98, b: 0.98, a: 1 }@@ -59,7 +60,10 @@ export function createDemoShapes(store: EditorStore) {counterAxisSizing: 'HUG',primaryAxisAlign: 'CENTER',counterAxisAlign: 'CENTER',- paddingTop: 10, paddingBottom: 10, paddingLeft: 20, paddingRight: 20+ paddingTop: 10,+ paddingBottom: 10,+ paddingLeft: 20,+ paddingRight: 20})const btnTextId = store.createShape('TEXT', 0, 0, 80, 20, btnId)graph.updateNode(btnTextId, {@@ -83,7 +87,10 @@ export function createDemoShapes(store: EditorStore) {counterAxisSizing: 'HUG',primaryAxisAlign: 'CENTER',counterAxisAlign: 'CENTER',- paddingTop: 10, paddingBottom: 10, paddingLeft: 20, paddingRight: 20+ paddingTop: 10,+ paddingBottom: 10,+ paddingLeft: 20,+ paddingRight: 20})const btn2TextId = store.createShape('TEXT', 0, 0, 60, 20, btn2Id)graph.updateNode(btn2TextId, {@@ -106,7 +113,10 @@ export function createDemoShapes(store: EditorStore) {counterAxisSizing: 'HUG',primaryAxisAlign: 'CENTER',counterAxisAlign: 'CENTER',- paddingTop: 4, paddingBottom: 4, paddingLeft: 12, paddingRight: 12+ paddingTop: 4,+ paddingBottom: 4,+ paddingLeft: 12,+ paddingRight: 12})const chipTextId = store.createShape('TEXT', 0, 0, 56, 16, chipId)graph.updateNode(chipTextId, {@@ -122,10 +132,12 @@ export function createDemoShapes(store: EditorStore) {const avatarId = store.createShape('ELLIPSE', 416, 48, 40, 40, compSectionId)graph.updateNode(avatarId, {name: 'Avatar',- fills: [gradient([- { color: PURPLE, position: 0 },- { color: BLUE, position: 1 }- ])]+ fills: [+ gradient([+ { color: PURPLE, position: 0 },+ { color: BLUE, position: 1 }+ ])+ ]})makeComponent(store, [avatarId])@@ -140,7 +152,10 @@ export function createDemoShapes(store: EditorStore) {primaryAxisSizing: 'FIXED',counterAxisSizing: 'FIXED',itemSpacing: 8,- paddingTop: 20, paddingBottom: 20, paddingLeft: 20, paddingRight: 20+ paddingTop: 20,+ paddingBottom: 20,+ paddingLeft: 20,+ paddingRight: 20})const cardTitleId = store.createShape('TEXT', 0, 0, 240, 22, cardId)graph.updateNode(cardTitleId, {@@ -168,10 +183,12 @@ export function createDemoShapes(store: EditorStore) {graph.updateNode(cardBar, {name: 'Progress',cornerRadius: 4,- fills: [gradient([- { color: BLUE, position: 0 },- { color: TEAL, position: 1 }- ])]+ fills: [+ gradient([+ { color: BLUE, position: 0 },+ { color: TEAL, position: 1 }+ ])+ ]})const cardCompId = makeComponent(store, [cardId])@@ -187,7 +204,10 @@ export function createDemoShapes(store: EditorStore) {counterAxisSizing: 'HUG',primaryAxisAlign: 'MIN',counterAxisAlign: 'CENTER',- paddingTop: 10, paddingBottom: 10, paddingLeft: 12, paddingRight: 12+ paddingTop: 10,+ paddingBottom: 10,+ paddingLeft: 12,+ paddingRight: 12})const inputPlaceholder = store.createShape('TEXT', 0, 0, 200, 18, inputId)graph.updateNode(inputPlaceholder, {@@ -210,7 +230,10 @@ export function createDemoShapes(store: EditorStore) {counterAxisSizing: 'HUG',primaryAxisAlign: 'CENTER',counterAxisAlign: 'CENTER',- paddingTop: 4, paddingBottom: 4, paddingLeft: 8, paddingRight: 8+ paddingTop: 4,+ paddingBottom: 4,+ paddingLeft: 8,+ paddingRight: 8})const badgeDot = store.createShape('ELLIPSE', 0, 0, 6, 6, badgeId)graph.updateNode(badgeDot, {@@ -316,7 +339,10 @@ export function createDemoShapes(store: EditorStore) {primaryAxisSizing: 'FIXED',counterAxisSizing: 'FIXED',itemSpacing: 4,- paddingTop: 14, paddingBottom: 14, paddingLeft: 16, paddingRight: 16+ paddingTop: 14,+ paddingBottom: 14,+ paddingLeft: 16,+ paddingRight: 16})const labelId = store.createShape('TEXT', 0, 0, 108, 14, cId)graph.updateNode(labelId, {@@ -376,10 +402,12 @@ export function createDemoShapes(store: EditorStore) {graph.updateNode(barId, {name: `Bar ${i + 1}`,cornerRadius: 4,- fills: [gradient([- { color: BLUE, position: 0 },- { color: INDIGO, position: 1 }- ])]+ fills: [+ gradient([+ { color: BLUE, position: 0 },+ { color: INDIGO, position: 1 }+ ])+ ]})}@@ -394,7 +422,10 @@ export function createDemoShapes(store: EditorStore) {counterAxisSizing: 'HUG',primaryAxisAlign: 'SPACE_BETWEEN',counterAxisAlign: 'CENTER',- paddingTop: 10, paddingBottom: 10, paddingLeft: 16, paddingRight: 16,+ paddingTop: 10,+ paddingBottom: 10,+ paddingLeft: 16,+ paddingRight: 16,itemSpacing: 16})const cols = ['Name', 'Status', 'Amount', 'Date']@@ -415,11 +446,13 @@ export function createDemoShapes(store: EditorStore) {graph.updateNode(grad1, {name: 'Gradient Card',cornerRadius: 16,- fills: [gradient([- { color: { r: 0.99, g: 0.37, b: 0.33, a: 1 }, position: 0 },- { color: { r: 0.93, g: 0.18, b: 0.65, a: 1 }, position: 0.5 },- { color: { r: 0.55, g: 0.28, b: 0.96, a: 1 }, position: 1 }- ])]+ fills: [+ gradient([+ { color: { r: 0.99, g: 0.37, b: 0.33, a: 1 }, position: 0 },+ { color: { r: 0.93, g: 0.18, b: 0.65, a: 1 }, position: 0.5 },+ { color: { r: 0.55, g: 0.28, b: 0.96, a: 1 }, position: 1 }+ ])+ ]})const gradText = store.createShape('TEXT', 20, 80, 140, 20, grad1)graph.updateNode(gradText, {@@ -434,10 +467,12 @@ export function createDemoShapes(store: EditorStore) {graph.updateNode(grad2, {name: 'Ocean',cornerRadius: 16,- fills: [gradient([- { color: { r: 0.04, g: 0.82, b: 0.67, a: 1 }, position: 0 },- { color: { r: 0.13, g: 0.45, b: 0.96, a: 1 }, position: 1 }- ])]+ fills: [+ gradient([+ { color: { r: 0.04, g: 0.82, b: 0.67, a: 1 }, position: 0 },+ { color: { r: 0.13, g: 0.45, b: 0.96, a: 1 }, position: 1 }+ ])+ ]})const grad2Text = store.createShape('TEXT', 20, 80, 140, 20, grad2)graph.updateNode(grad2Text, {@@ -452,10 +487,12 @@ export function createDemoShapes(store: EditorStore) {graph.updateNode(grad3, {name: 'Sunset',cornerRadius: 16,- fills: [gradient([- { color: { r: 1, g: 0.6, b: 0.2, a: 1 }, position: 0 },- { color: { r: 0.96, g: 0.26, b: 0.21, a: 1 }, position: 1 }- ])]+ fills: [+ gradient([+ { color: { r: 1, g: 0.6, b: 0.2, a: 1 }, position: 0 },+ { color: { r: 0.96, g: 0.26, b: 0.21, a: 1 }, position: 1 }+ ])+ ]})const grad3Text = store.createShape('TEXT', 20, 80, 140, 20, grad3)graph.updateNode(grad3Text, {@@ -477,7 +514,10 @@ export function createDemoShapes(store: EditorStore) {primaryAxisSizing: 'FIXED',counterAxisSizing: 'FIXED',itemSpacing: 6,- paddingTop: 16, paddingBottom: 16, paddingLeft: 20, paddingRight: 20+ paddingTop: 16,+ paddingBottom: 16,+ paddingLeft: 20,+ paddingRight: 20})const typoItems = [{ text: 'Heading', size: 24, weight: 700 },@@ -498,9 +538,30 @@ export function createDemoShapes(store: EditorStore) {// Mixed shapes rowconst shapes = [- { type: 'ELLIPSE' as const, x: 1060, fill: gradient([{ color: PURPLE, position: 0 }, { color: BLUE, position: 1 }]) },- { type: 'RECTANGLE' as const, x: 1160, fill: gradient([{ color: GREEN, position: 0 }, { color: TEAL, position: 1 }]) },- { type: 'ELLIPSE' as const, x: 1260, fill: gradient([{ color: ORANGE, position: 0 }, { color: RED, position: 1 }]) }+ {+ type: 'ELLIPSE' as const,+ x: 1060,+ fill: gradient([+ { color: PURPLE, position: 0 },+ { color: BLUE, position: 1 }+ ])+ },+ {+ type: 'RECTANGLE' as const,+ x: 1160,+ fill: gradient([+ { color: GREEN, position: 0 },+ { color: TEAL, position: 1 }+ ])+ },+ {+ type: 'ELLIPSE' as const,+ x: 1260,+ fill: gradient([+ { color: ORANGE, position: 0 },+ { color: RED, position: 1 }+ ])+ }]for (const s of shapes) {const id = store.createShape(s.type, s.x, 680, 80, 80)diff --git a/src/engine/clipboard.ts b/src/engine/clipboard.tsindex 3d639d12b..bbaef2346 100644--- a/src/engine/clipboard.ts+++ b/src/engine/clipboard.ts@@ -1,10 +1,22 @@import { inflateSync, deflateSync } from 'fflate'-import { decodeBinarySchema, compileSchema, ByteBuffer } from '../kiwi/kiwi-schema'-import { initCodec, getCompiledSchema, getSchemaBytes } from '../kiwi/codec'-import type { SceneGraph, SceneNode, Fill, Stroke, Color, LayoutMode, LayoutSizing, LayoutAlign, LayoutCounterAlign, VectorNetwork } from './scene-graph'+import { initCodec, getCompiledSchema, getSchemaBytes } from '../kiwi/codec'+import { decodeBinarySchema, compileSchema, ByteBuffer } from '../kiwi/kiwi-schema'import { decodeVectorNetworkBlob, encodeVectorNetworkBlob } from './vector'+import type {+ SceneGraph,+ SceneNode,+ Fill,+ Stroke,+ Color,+ LayoutMode,+ LayoutSizing,+ LayoutAlign,+ LayoutCounterAlign,+ VectorNetwork+} from './scene-graph'+interface FigmaClipboardMeta {fileKey: stringpasteID: number@@ -55,7 +67,9 @@ export async function prefetchFigmaSchema(): Promise<void> {await initCodec()}-function parseFigKiwi(binary: Uint8Array): { schemaDeflated: Uint8Array; dataRaw: Uint8Array } | null {+function parseFigKiwi(+ binary: Uint8Array+): { schemaDeflated: Uint8Array; dataRaw: Uint8Array } | null {const header = new TextDecoder().decode(binary.slice(0, 8))if (header !== 'fig-kiwi') return null@@ -178,20 +192,20 @@ export async function parseFigmaClipboard(}const blobs: Uint8Array[] = (msg.blobs ?? []).map((b) =>- b.bytes instanceof Uint8Array- ? b.bytes- : new Uint8Array(Object.values(b.bytes) as number[])+ b.bytes instanceof Uint8Array ? b.bytes : new Uint8Array(Object.values(b.bytes) as number[]))return { nodes: msg.nodeChanges ?? [], meta, blobs }}function decodeVectorData(nc: KiwiNodeChange, blobs: Uint8Array[]): VectorNetwork | null {- const vectorData = nc.vectorData as {- vectorNetworkBlob?: number- normalizedSize?: { x: number; y: number }- styleOverrideTable?: Array<{ styleID: number; handleMirroring?: string }>- } | undefined+ const vectorData = nc.vectorData as+ | {+ vectorNetworkBlob?: number+ normalizedSize?: { x: number; y: number }+ styleOverrideTable?: Array<{ styleID: number; handleMirroring?: string }>+ }+ | undefinedif (!vectorData || vectorData.vectorNetworkBlob === undefined) return null@@ -295,16 +309,29 @@ export function importClipboardNodes(layoutMode: mapLayoutMode(nc.stackMode as string),itemSpacing: (nc.stackSpacing as number) ?? 0,paddingTop: (nc.stackVerticalPadding as number) ?? (nc.stackPadding as number) ?? 0,- paddingBottom: (nc.stackPaddingBottom as number) ?? (nc.stackVerticalPadding as number) ?? (nc.stackPadding as number) ?? 0,+ paddingBottom:+ (nc.stackPaddingBottom as number) ??+ (nc.stackVerticalPadding as number) ??+ (nc.stackPadding as number) ??+ 0,paddingLeft: (nc.stackHorizontalPadding as number) ?? (nc.stackPadding as number) ?? 0,- paddingRight: (nc.stackPaddingRight as number) ?? (nc.stackHorizontalPadding as number) ?? (nc.stackPadding as number) ?? 0,+ paddingRight:+ (nc.stackPaddingRight as number) ??+ (nc.stackHorizontalPadding as number) ??+ (nc.stackPadding as number) ??+ 0,primaryAxisSizing: mapSizing(nc.stackPrimarySizing as string),counterAxisSizing: mapSizing(nc.stackCounterSizing as string),- primaryAxisAlign: mapPrimaryAlign(nc.stackPrimaryAlignItems as string ?? nc.stackJustify as string),- counterAxisAlign: mapCounterAlign(nc.stackCounterAlignItems as string ?? nc.stackCounterAlign as string),- layoutWrap: (nc.stackWrap as string) === 'WRAP' ? 'WRAP' as const : 'NO_WRAP' as const,+ primaryAxisAlign: mapPrimaryAlign(+ (nc.stackPrimaryAlignItems as string) ?? (nc.stackJustify as string)+ ),+ counterAxisAlign: mapCounterAlign(+ (nc.stackCounterAlignItems as string) ?? (nc.stackCounterAlign as string)+ ),+ layoutWrap: (nc.stackWrap as string) === 'WRAP' ? ('WRAP' as const) : ('NO_WRAP' as const),counterAxisSpacing: (nc.stackCounterSpacing as number) ?? 0,- layoutPositioning: (nc.stackPositioning as string) === 'ABSOLUTE' ? 'ABSOLUTE' as const : 'AUTO' as const,+ layoutPositioning:+ (nc.stackPositioning as string) === 'ABSOLUTE' ? ('ABSOLUTE' as const) : ('AUTO' as const),layoutGrow: (nc.stackChildPrimaryGrow as number) ?? 0,vectorNetwork: decodeVectorData(nc, blobs)})@@ -529,7 +556,8 @@ function sceneNodeToKiwi(nc.stackPaddingBottom = node.paddingBottomnc.stackPaddingRight = node.paddingRightnc.stackPrimarySizing = node.primaryAxisSizing === 'HUG' ? 'RESIZE_TO_FIT' : 'FIXED'- nc.stackCounterSizing = node.counterAxisSizing === 'HUG' ? 'RESIZE_TO_FIT_WITH_IMPLICIT_SIZE' : undefined+ nc.stackCounterSizing =+ node.counterAxisSizing === 'HUG' ? 'RESIZE_TO_FIT_WITH_IMPLICIT_SIZE' : undefined}if (node.layoutPositioning === 'ABSOLUTE') {@@ -557,10 +585,7 @@ function sceneNodeToKiwi(return result}-export function buildFigmaClipboardHTML(- nodes: SceneNode[],- graph: SceneGraph-): string | null {+export function buildFigmaClipboardHTML(nodes: SceneNode[], graph: SceneGraph): string | null {const compiled = getCompiledSchema()const schemaDeflated = deflateSync(getSchemaBytes())diff --git a/src/engine/fig-export.ts b/src/engine/fig-export.tsindex 3ac643a4f..99ffbd1b8 100644--- a/src/engine/fig-export.ts+++ b/src/engine/fig-export.ts@@ -1,15 +1,19 @@import { zipSync, deflateSync } from 'fflate'-import { encodeVectorNetworkBlob } from './vector'+import { IS_TAURI } from '../constants'import { initCodec, getCompiledSchema, getSchemaBytes } from '../kiwi/codec'+import { encodeVectorNetworkBlob } from './vector'-import type { CanvasKit } from 'canvaskit-wasm'-import type { SceneGraph, SceneNode, Color } from './scene-graph'import type { SkiaRenderer } from './renderer'+import type { SceneGraph, SceneNode, Color } from './scene-graph'+import type { CanvasKit } from 'canvaskit-wasm'-const THUMBNAIL_1X1 = Uint8Array.from(atob(- 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='-), (c) => c.charCodeAt(0))+const THUMBNAIL_1X1 = Uint8Array.from(+ atob(+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='+ ),+ (c) => c.charCodeAt(0)+)interface KiwiNodeChange {guid: { sessionID: number; localID: number }@@ -51,27 +55,42 @@ interface KiwiNodeChange {[key: string]: unknown}--function mapToFigmaType(type: SceneNode['type']): string {switch (type) {- case 'FRAME': return 'FRAME'- case 'RECTANGLE': return 'RECTANGLE'- case 'ROUNDED_RECTANGLE': return 'ROUNDED_RECTANGLE'- case 'ELLIPSE': return 'ELLIPSE'- case 'TEXT': return 'TEXT'- case 'LINE': return 'LINE'- case 'STAR': return 'STAR'- case 'POLYGON': return 'REGULAR_POLYGON'- case 'VECTOR': return 'VECTOR'- case 'GROUP': return 'FRAME'- case 'SECTION': return 'SECTION'- case 'COMPONENT': return 'COMPONENT'- case 'COMPONENT_SET': return 'COMPONENT_SET'- case 'INSTANCE': return 'INSTANCE'- case 'CONNECTOR': return 'CONNECTOR'- case 'SHAPE_WITH_TEXT': return 'SHAPE_WITH_TEXT'- default: return 'RECTANGLE'+ case 'FRAME':+ return 'FRAME'+ case 'RECTANGLE':+ return 'RECTANGLE'+ case 'ROUNDED_RECTANGLE':+ return 'ROUNDED_RECTANGLE'+ case 'ELLIPSE':+ return 'ELLIPSE'+ case 'TEXT':+ return 'TEXT'+ case 'LINE':+ return 'LINE'+ case 'STAR':+ return 'STAR'+ case 'POLYGON':+ return 'REGULAR_POLYGON'+ case 'VECTOR':+ return 'VECTOR'+ case 'GROUP':+ return 'FRAME'+ case 'SECTION':+ return 'SECTION'+ case 'COMPONENT':+ return 'COMPONENT'+ case 'COMPONENT_SET':+ return 'COMPONENT_SET'+ case 'INSTANCE':+ return 'INSTANCE'+ case 'CONNECTOR':+ return 'CONNECTOR'+ case 'SHAPE_WITH_TEXT':+ return 'SHAPE_WITH_TEXT'+ default:+ return 'RECTANGLE'}}@@ -138,10 +157,18 @@ function sceneNodeToKiwi(if (node.cornerRadius > 0 || node.independentCorners) {nc.cornerRadius = node.cornerRadiusnc.rectangleCornerRadiiIndependent = node.independentCorners- nc.rectangleTopLeftCornerRadius = node.independentCorners ? node.topLeftRadius : node.cornerRadius- nc.rectangleTopRightCornerRadius = node.independentCorners ? node.topRightRadius : node.cornerRadius- nc.rectangleBottomLeftCornerRadius = node.independentCorners ? node.bottomLeftRadius : node.cornerRadius- nc.rectangleBottomRightCornerRadius = node.independentCorners ? node.bottomRightRadius : node.cornerRadius+ nc.rectangleTopLeftCornerRadius = node.independentCorners+ ? node.topLeftRadius+ : node.cornerRadius+ nc.rectangleTopRightCornerRadius = node.independentCorners+ ? node.topRightRadius+ : node.cornerRadius+ nc.rectangleBottomLeftCornerRadius = node.independentCorners+ ? node.bottomLeftRadius+ : node.cornerRadius+ nc.rectangleBottomRightCornerRadius = node.independentCorners+ ? node.bottomRightRadius+ : node.cornerRadius}if (node.cornerSmoothing > 0) {@@ -161,7 +188,11 @@ function sceneNodeToKiwi(if (node.type === 'TEXT') {nc.fontSize = node.fontSize- nc.fontName = { family: node.fontFamily, style: node.fontWeight >= 700 ? 'Bold' : 'Regular', postscript: '' }+ nc.fontName = {+ family: node.fontFamily,+ style: node.fontWeight >= 700 ? 'Bold' : 'Regular',+ postscript: ''+ }nc.textData = { characters: node.text }nc.textAutoResize = 'WIDTH_AND_HEIGHT'nc.textAlignHorizontal = node.textAlignHorizontal@@ -244,7 +275,10 @@ function generateThumbnail(const page = graph.getNode(pageId)if (!page || page.childIds.length === 0) return null- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity+ let minX = Infinity,+ minY = Infinity,+ maxX = -Infinity,+ maxY = -Infinityfor (const childId of page.childIds) {const node = graph.getNode(childId)if (!node || !node.visible) continue@@ -359,9 +393,10 @@ export async function exportFigFile(const kiwiData = compiled.encodeMessage(msg)const currentPageId = pageId ?? pages[0]?.id- const thumbnailPng = (ck && renderer && currentPageId- ? generateThumbnail(ck, renderer, graph, currentPageId)- : null) ?? THUMBNAIL_1X1+ const thumbnailPng =+ (ck && renderer && currentPageId+ ? generateThumbnail(ck, renderer, graph, currentPageId)+ : null) ?? THUMBNAIL_1X1const metaJson = JSON.stringify({version: 1,@@ -371,12 +406,14 @@ export async function exportFigFile(if (IS_TAURI) {const { invoke } = await import('@tauri-apps/api/core')- return new Uint8Array(await invoke<number[]>('build_fig_file', {- schemaDeflated: Array.from(schemaDeflated),- kiwiData: Array.from(kiwiData),- thumbnailPng: Array.from(thumbnailPng),- metaJson- }))+ return new Uint8Array(+ await invoke<number[]>('build_fig_file', {+ schemaDeflated: Array.from(schemaDeflated),+ kiwiData: Array.from(kiwiData),+ thumbnailPng: Array.from(thumbnailPng),+ metaJson+ })+ )}const canvasData = buildFigKiwi(schemaDeflated, deflateSync(kiwiData))diff --git a/src/engine/fonts.ts b/src/engine/fonts.tsindex a7863907e..2f5177ccf 100644--- a/src/engine/fonts.ts+++ b/src/engine/fonts.ts@@ -62,11 +62,9 @@ export async function loadFont(family: string, style = 'Regular'): Promise<Arrayif ('queryLocalFonts' in window) {try {const fonts = await (window as any).queryLocalFonts()- const match = fonts.find(- (f: FontInfo) => f.family === family && f.style === style- ) ?? fonts.find(- (f: FontInfo) => f.family === family- )+ const match =+ fonts.find((f: FontInfo) => f.family === family && f.style === style) ??+ fonts.find((f: FontInfo) => f.family === family)if (match) {const blob: Blob = await match.blob()const buffer = await blob.arrayBuffer()@@ -76,7 +74,9 @@ export async function loadFont(family: string, style = 'Regular'): Promise<ArrayregisterFontInBrowser(family, style, buffer)return buffer}- } catch { /* fall through to bundled */ }+ } catch {+ /* fall through to bundled */+ }}// Fall back to bundled font@@ -90,7 +90,9 @@ export async function loadFont(family: string, style = 'Regular'): Promise<ArrayregisterFontInCanvasKit(family, buffer)registerFontInBrowser(family, style, buffer)return buffer- } catch { /* no bundled font available */ }+ } catch {+ /* no bundled font available */+ }}return nulldiff --git a/src/engine/layout.ts b/src/engine/layout.tsindex 38de74bac..5f2216488 100644--- a/src/engine/layout.ts+++ b/src/engine/layout.ts@@ -64,8 +64,14 @@ function buildYogaTree(graph: SceneGraph, frame: SceneNode): YogaNode {root.setPadding(Edge.Bottom, frame.paddingBottom)root.setPadding(Edge.Left, frame.paddingLeft)- root.setGap(Gutter.Column, frame.layoutMode === 'HORIZONTAL' ? frame.itemSpacing : frame.counterAxisSpacing)- root.setGap(Gutter.Row, frame.layoutMode === 'HORIZONTAL' ? frame.counterAxisSpacing : frame.itemSpacing)+ root.setGap(+ Gutter.Column,+ frame.layoutMode === 'HORIZONTAL' ? frame.itemSpacing : frame.counterAxisSpacing+ )+ root.setGap(+ Gutter.Row,+ frame.layoutMode === 'HORIZONTAL' ? frame.counterAxisSpacing : frame.itemSpacing+ )const children = graph.getChildren(frame.id)for (let i = 0; i < children.length; i++) {@@ -123,8 +129,14 @@ function configureChildAsAutoLayout(yogaChild.setPadding(Edge.Bottom, child.paddingBottom)yogaChild.setPadding(Edge.Left, child.paddingLeft)- yogaChild.setGap(Gutter.Column, child.layoutMode === 'HORIZONTAL' ? child.itemSpacing : child.counterAxisSpacing)- yogaChild.setGap(Gutter.Row, child.layoutMode === 'HORIZONTAL' ? child.counterAxisSpacing : child.itemSpacing)+ yogaChild.setGap(+ Gutter.Column,+ child.layoutMode === 'HORIZONTAL' ? child.itemSpacing : child.counterAxisSpacing+ )+ yogaChild.setGap(+ Gutter.Row,+ child.layoutMode === 'HORIZONTAL' ? child.counterAxisSpacing : child.itemSpacing+ )const grandchildren = graph.getChildren(child.id)for (const gc of grandchildren) {@@ -139,14 +151,9 @@ function configureChildAsAutoLayout(}}-function configureChildAsLeaf(- yogaChild: YogaNode,- child: SceneNode,- parent: SceneNode-): void {+function configureChildAsLeaf(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {const isRow = parent.layoutMode === 'HORIZONTAL'- const stretchCross =- child.layoutAlignSelf === 'STRETCH' || parent.counterAxisAlign === 'STRETCH'+ const stretchCross = child.layoutAlignSelf === 'STRETCH' || parent.counterAxisAlign === 'STRETCH'if (child.layoutGrow > 0) {yogaChild.setFlexGrow(child.layoutGrow)@@ -235,11 +242,7 @@ function applyYogaLayout(graph: SceneGraph, frame: SceneNode, yogaRoot: YogaNode}}-function applyYogaLayoutNested(- graph: SceneGraph,- frame: SceneNode,- yogaNode: YogaNode-): void {+function applyYogaLayoutNested(graph: SceneGraph, frame: SceneNode, yogaNode: YogaNode): void {if (frame.primaryAxisSizing === 'HUG' || frame.counterAxisSizing === 'HUG') {const computedW = yogaNode.getComputedWidth()const computedH = yogaNode.getComputedHeight()diff --git a/src/engine/renderer.ts b/src/engine/renderer.tsindex 978973920..9e1117cff 100644--- a/src/engine/renderer.ts+++ b/src/engine/renderer.ts@@ -1,26 +1,71 @@import {- SELECTION_COLOR, COMPONENT_COLOR, SNAP_COLOR, CANVAS_BG_COLOR, ROTATION_HANDLE_OFFSET,- RULER_SIZE, RULER_BG_COLOR, RULER_TICK_COLOR, RULER_TEXT_COLOR,- RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BADGE_EXCLUSION,- RULER_TEXT_BASELINE, RULER_MAJOR_TICK, RULER_MINOR_TICK, RULER_HIGHLIGHT_ALPHA,- PEN_HANDLE_RADIUS, PEN_VERTEX_RADIUS, PEN_CLOSE_RADIUS_BOOST, PEN_PATH_STROKE_WIDTH,- PARENT_OUTLINE_ALPHA, PARENT_OUTLINE_DASH,- DEFAULT_FONT_SIZE, LABEL_FONT_SIZE, SIZE_FONT_SIZE,- ROTATION_HANDLE_RADIUS, HANDLE_HALF_SIZE,- LABEL_OFFSET_Y, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_HEIGHT,- SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y,- MARQUEE_FILL_ALPHA, SELECTION_DASH_ALPHA, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE,+ SELECTION_COLOR,+ COMPONENT_COLOR,+ SNAP_COLOR,+ CANVAS_BG_COLOR,+ ROTATION_HANDLE_OFFSET,+ RULER_SIZE,+ RULER_BG_COLOR,+ RULER_TICK_COLOR,+ RULER_TEXT_COLOR,+ RULER_BADGE_HEIGHT,+ RULER_BADGE_PADDING,+ RULER_BADGE_RADIUS,+ RULER_BADGE_EXCLUSION,+ RULER_TEXT_BASELINE,+ RULER_MAJOR_TICK,+ RULER_MINOR_TICK,+ RULER_HIGHLIGHT_ALPHA,+ PEN_HANDLE_RADIUS,+ PEN_VERTEX_RADIUS,+ PEN_CLOSE_RADIUS_BOOST,+ PEN_PATH_STROKE_WIDTH,+ PARENT_OUTLINE_ALPHA,+ PARENT_OUTLINE_DASH,+ DEFAULT_FONT_SIZE,+ LABEL_FONT_SIZE,+ SIZE_FONT_SIZE,+ ROTATION_HANDLE_RADIUS,+ HANDLE_HALF_SIZE,+ LABEL_OFFSET_Y,+ SIZE_PILL_PADDING_X,+ SIZE_PILL_PADDING_Y,+ SIZE_PILL_HEIGHT,+ SIZE_PILL_RADIUS,+ SIZE_PILL_TEXT_OFFSET_Y,+ MARQUEE_FILL_ALPHA,+ SELECTION_DASH_ALPHA,+ DROP_HIGHLIGHT_ALPHA,+ DROP_HIGHLIGHT_STROKE,LAYOUT_INDICATOR_STROKE,- SECTION_CORNER_RADIUS, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X,- SECTION_TITLE_RADIUS, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_GAP,- COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_BORDER_WIDTH,- COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_LABEL_ICON_GAP,- RULER_TARGET_PIXEL_SPACING, RULER_MAJOR_TOLERANCE+ SECTION_CORNER_RADIUS,+ SECTION_TITLE_HEIGHT,+ SECTION_TITLE_PADDING_X,+ SECTION_TITLE_RADIUS,+ SECTION_TITLE_FONT_SIZE,+ SECTION_TITLE_GAP,+ COMPONENT_SET_DASH,+ COMPONENT_SET_DASH_GAP,+ COMPONENT_SET_BORDER_WIDTH,+ COMPONENT_LABEL_FONT_SIZE,+ COMPONENT_LABEL_GAP,+ COMPONENT_LABEL_ICON_SIZE,+ COMPONENT_LABEL_ICON_GAP,+ RULER_TARGET_PIXEL_SPACING,+ RULER_MAJOR_TOLERANCE} from '../constants'-import type { SceneNode, SceneGraph, Fill, GradientStop, GradientTransform, ArcData } from './scene-graph'-import type { Image as CKImage } from 'canvaskit-wasm'-import type { SnapGuide } from './snap'import { vectorNetworkToPath } from './vector'++import type {+ SceneNode,+ SceneGraph,+ Fill,+ GradientStop,+ GradientTransform,+ ArcData+} from './scene-graph'+import type { SnapGuide } from './snap'+import type { Image as CKImage } from 'canvaskit-wasm'import type {CanvasKit,Surface,@@ -47,7 +92,12 @@ export interface RenderOverlays {} | nullpenState?: {vertices: Array<{ x: number; y: number }>- segments: Array<{ start: number; end: number; tangentStart: { x: number; y: number }; tangentEnd: { x: number; y: number } }>+ segments: Array<{+ start: number+ end: number+ tangentStart: { x: number; y: number }+ tangentEnd: { x: number; y: number }+ }>dragTangent: { x: number; y: number } | nullclosingToFirst: booleancursorX?: number@@ -123,7 +173,9 @@ export class SkiaRenderer {this.parentOutlinePaint.setStrokeWidth(1)this.parentOutlinePaint.setColor(this.selColor(PARENT_OUTLINE_ALPHA))this.parentOutlinePaint.setAntiAlias(true)- this.parentOutlinePaint.setPathEffect(ck.PathEffect.MakeDash([PARENT_OUTLINE_DASH, PARENT_OUTLINE_DASH], 0))+ this.parentOutlinePaint.setPathEffect(+ ck.PathEffect.MakeDash([PARENT_OUTLINE_DASH, PARENT_OUTLINE_DASH], 0)+ )this.snapPaint = new ck.Paint()this.snapPaint.setStyle(ck.PaintStyle.Stroke)@@ -196,7 +248,8 @@ export class SkiaRenderer {const widths = font.getGlyphWidths(glyphIds)let textW = 0for (const w of widths) textW += w- const pillW = Math.min(textW + SECTION_TITLE_PADDING_X * 2, child.width * this.zoom) / this.zoom+ const pillW =+ Math.min(textW + SECTION_TITLE_PADDING_X * 2, child.width * this.zoom) / this.zoomconst pillH = SECTION_TITLE_HEIGHT / this.zoomconst gap = SECTION_TITLE_GAP / this.zoom@@ -208,8 +261,12 @@ export class SkiaRenderer {pillY = ay - pillH - gap}- if (canvasX >= pillX && canvasX <= pillX + pillW &&- canvasY >= pillY && canvasY <= pillY + pillH) {+ if (+ canvasX >= pillX &&+ canvasX <= pillX + pillW &&+ canvasY >= pillY &&+ canvasY <= pillY + pillH+ ) {result = childreturn}@@ -263,8 +320,12 @@ export class SkiaRenderer {labelY = ay - labelH - gap}- if (canvasX >= labelX && canvasX <= labelX + labelW &&- canvasY >= labelY && canvasY <= labelY + labelH) {+ if (+ canvasX >= labelX &&+ canvasX <= labelX + labelW &&+ canvasY >= labelY &&+ canvasY <= labelY + labelH+ ) {result = childreturn}@@ -447,11 +508,7 @@ export class SkiaRenderer {canvas.restore()}- private drawSelectionLabels(- canvas: Canvas,- graph: SceneGraph,- selectedIds: Set<string>- ): void {+ private drawSelectionLabels(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {if (!this.labelFont || !this.sizeFont) return// Compute bounding box of all selected nodes@@ -483,7 +540,8 @@ export class SkiaRenderer {if (nodes.length === 1) {const node = nodes[0]const parentNode = node.parentId ? graph.getNode(node.parentId) : null- const isTopLevel = !parentNode || parentNode.type === 'CANVAS' || parentNode.type === 'SECTION'+ const isTopLevel =+ !parentNode || parentNode.type === 'CANVAS' || parentNode.type === 'SECTION'if (node.type === 'FRAME' && isTopLevel) {this.auxFill.setColor(this.selColor())canvas.drawText(node.name, sx1, sy1 - LABEL_OFFSET_Y, this.auxFill, this.labelFont)@@ -507,11 +565,21 @@ export class SkiaRenderer {const pillColor = allComponents ? this.compColor() : this.selColor()this.auxFill.setColor(pillColor)- const rrect = this.ck.RRectXY(this.ck.LTRBRect(pillX, pillY, pillX + pillW, pillY + pillH), SIZE_PILL_RADIUS, SIZE_PILL_RADIUS)+ const rrect = this.ck.RRectXY(+ this.ck.LTRBRect(pillX, pillY, pillX + pillW, pillY + pillH),+ SIZE_PILL_RADIUS,+ SIZE_PILL_RADIUS+ )canvas.drawRRect(rrect, this.auxFill)this.auxFill.setColor(this.ck.WHITE)- canvas.drawText(sizeText, pillX + SIZE_PILL_PADDING_X, pillY + SIZE_PILL_TEXT_OFFSET_Y, this.auxFill, this.sizeFont)+ canvas.drawText(+ sizeText,+ pillX + SIZE_PILL_PADDING_X,+ pillY + SIZE_PILL_TEXT_OFFSET_Y,+ this.auxFill,+ this.sizeFont+ )}private drawParentFrameOutlines(@@ -638,7 +706,12 @@ export class SkiaRenderer {private drawHandle(canvas: Canvas, x: number, y: number): void {this.auxFill.setColor(this.ck.WHITE)- const rect = this.ck.LTRBRect(x - HANDLE_HALF_SIZE, y - HANDLE_HALF_SIZE, x + HANDLE_HALF_SIZE, y + HANDLE_HALF_SIZE)+ const rect = this.ck.LTRBRect(+ x - HANDLE_HALF_SIZE,+ y - HANDLE_HALF_SIZE,+ x + HANDLE_HALF_SIZE,+ y + HANDLE_HALF_SIZE+ )canvas.drawRect(rect, this.auxFill)canvas.drawRect(rect, this.selectionPaint)}@@ -726,8 +799,10 @@ export class SkiaRenderer {// Viewport culling: skip nodes entirely outside the visible area.// Only cull leaf nodes and clipped containers — unclipped containers// may have children that extend beyond the parent's bounds.- const canCull = node.childIds.length === 0 ||- ((node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE') && node.clipsContent)+ const canCull =+ node.childIds.length === 0 ||+ ((node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE') &&+ node.clipsContent)if (canCull) {const vp = this.worldViewport// Expand bounds for rotation (diagonal is the max extent)@@ -745,12 +820,7 @@ export class SkiaRenderer {) {return}- } else if (- absX > vp.x + vp.w ||- absY > vp.y + vp.h ||- absX + bw < vp.x ||- absY + bh < vp.y- ) {+ } else if (absX > vp.x + vp.w || absY > vp.y + vp.h || absX + bw < vp.x || absY + bh < vp.y) {return}}@@ -794,7 +864,8 @@ export class SkiaRenderer {}// Clip + render children for containers- const isClippableContainer = node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE'+ const isClippableContainer =+ node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE'if (isClippableContainer && node.clipsContent && node.childIds.length > 0) {canvas.save()canvas.clipRect(@@ -855,11 +926,18 @@ export class SkiaRenderer {if (hasRadius) {if (node.independentCorners) {const rrect = new Float32Array([- 0, 0, node.width, node.height,- node.topLeftRadius, node.topLeftRadius,- node.topRightRadius, node.topRightRadius,- node.bottomRightRadius, node.bottomRightRadius,- node.bottomLeftRadius, node.bottomLeftRadius+ 0,+ 0,+ node.width,+ node.height,+ node.topLeftRadius,+ node.topLeftRadius,+ node.topRightRadius,+ node.topRightRadius,+ node.bottomRightRadius,+ node.bottomRightRadius,+ node.bottomLeftRadius,+ node.bottomLeftRadius])canvas.drawRRect(rrect, paint)} else {@@ -893,7 +971,6 @@ export class SkiaRenderer {this.strokePaint.setAlphaf(stroke.opacity)canvas.drawRRect(rrect, this.strokePaint)}-}private drawSectionTitles(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {@@ -913,7 +990,12 @@ export class SkiaRenderer {const ay = oy + child.yif (child.type === 'SECTION') {const vp = this.worldViewport- if (ax + child.width >= vp.x && ay + child.height >= vp.y && ax <= vp.x + vp.w && ay <= vp.y + vp.h) {+ if (+ ax + child.width >= vp.x &&+ ay + child.height >= vp.y &&+ ax <= vp.x + vp.w &&+ ay <= vp.y + vp.h+ ) {sections.push({ node: child, absX: ax, absY: ay, nested: insideSection })}collectSections(childId, ax, ay, true)@@ -930,8 +1012,8 @@ export class SkiaRenderer {const ellipsisWidth = font.getGlyphWidths(ellipsisGlyphs)[0]for (const { node, absX, absY, nested } of sections) {- const screenX = (absX * this.zoom + this.panX)- const screenY = (absY * this.zoom + this.panY)+ const screenX = absX * this.zoom + this.panX+ const screenY = absY * this.zoom + this.panYconst screenW = node.width * this.zoomconst maxPillW = Math.max(screenW, 0)@@ -963,9 +1045,7 @@ export class SkiaRenderer {const pillW = Math.min(textWidth + SECTION_TITLE_PADDING_X * 2, maxPillW)const pillH = SECTION_TITLE_HEIGHTconst pillX = screenX- const pillY = nested- ? screenY + SECTION_TITLE_GAP- : screenY - pillH - SECTION_TITLE_GAP+ const pillY = nested ? screenY + SECTION_TITLE_GAP : screenY - pillH - SECTION_TITLE_GAPif (node.fills.length > 0 && node.fills[0].visible) {const c = node.fills[0].color@@ -979,9 +1059,10 @@ export class SkiaRenderer {this.auxFill)- const pillColor = node.fills.length > 0 && node.fills[0].visible- ? node.fills[0].color- : { r: 0.37, g: 0.37, b: 0.37 }+ const pillColor =+ node.fills.length > 0 && node.fills[0].visible+ ? node.fills[0].color+ : { r: 0.37, g: 0.37, b: 0.37 }const lum = 0.299 * pillColor.r + 0.587 * pillColor.g + 0.114 * pillColor.bthis.auxFill.setColor(lum > 0.5 ? this.ck.BLACK : this.ck.WHITE)const textY = pillY + pillH * 0.7@@ -1009,7 +1090,12 @@ export class SkiaRenderer {const ay = oy + child.yif (LABEL_TYPES.has(child.type)) {const vp = this.worldViewport- if (ax + child.width >= vp.x && ay + child.height >= vp.y && ax <= vp.x + vp.w && ay <= vp.y + vp.h) {+ if (+ ax + child.width >= vp.x &&+ ay + child.height >= vp.y &&+ ax <= vp.x + vp.w &&+ ay <= vp.y + vp.h+ ) {const isInsideSet = parent.type === 'COMPONENT_SET'nodes.push({ node: child, absX: ax, absY: ay, inside: isInsideSet })}@@ -1058,7 +1144,12 @@ export class SkiaRenderer {const s = iconR * 0.45const gap = iconR * 0.2const path = new this.ck.Path()- for (const [dx, dy] of [[-1, -1], [1, -1], [-1, 1], [1, 1]]) {+ for (const [dx, dy] of [+ [-1, -1],+ [1, -1],+ [-1, 1],+ [1, 1]+ ]) {const cx = iconCx + dx * (s + gap)const cy = iconCy + dy * (s + gap)path.moveTo(cx, cy - s)@@ -1080,7 +1171,13 @@ export class SkiaRenderer {path.delete()}- canvas.drawText(node.name, labelX + iconS + COMPONENT_LABEL_ICON_GAP, labelY, this.auxFill, font)+ canvas.drawText(+ node.name,+ labelX + iconS + COMPONENT_LABEL_ICON_GAP,+ labelY,+ this.auxFill,+ font+ )}}@@ -1143,13 +1240,17 @@ export class SkiaRenderer {if (stroke.cap) {const capMap: Record<string, number> = {- NONE: 0, ROUND: 1, SQUARE: 2+ NONE: 0,+ ROUND: 1,+ SQUARE: 2}this.strokePaint.setStrokeCap(capMap[stroke.cap] ?? 0)}if (stroke.join) {const joinMap: Record<string, number> = {- MITER: 0, ROUND: 1, BEVEL: 2+ MITER: 0,+ ROUND: 1,+ BEVEL: 2}this.strokePaint.setStrokeJoin(joinMap[stroke.join] ?? 0)}@@ -1166,7 +1267,12 @@ export class SkiaRenderer {this.renderEffects(canvas, node, rect, hasRadius, 'front')}- private drawNodeFill(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {+ private drawNodeFill(+ canvas: Canvas,+ node: SceneNode,+ rect: Float32Array,+ hasRadius: boolean+ ): void {switch (node.type) {case 'VECTOR':if (node.vectorNetwork) {@@ -1204,7 +1310,12 @@ export class SkiaRenderer {}}- private drawNodeStroke(canvas: Canvas, node: SceneNode, rect: Float32Array, hasRadius: boolean): void {+ private drawNodeStroke(+ canvas: Canvas,+ node: SceneNode,+ rect: Float32Array,+ hasRadius: boolean+ ): void {switch (node.type) {case 'VECTOR':if (node.vectorNetwork) {@@ -1264,16 +1375,24 @@ export class SkiaRenderer {private makeRRect(node: SceneNode): Float32Array {if (node.independentCorners) {return new Float32Array([- 0, 0, node.width, node.height,- node.topLeftRadius, node.topLeftRadius,- node.topRightRadius, node.topRightRadius,- node.bottomRightRadius, node.bottomRightRadius,- node.bottomLeftRadius, node.bottomLeftRadius,+ 0,+ 0,+ node.width,+ node.height,+ node.topLeftRadius,+ node.topLeftRadius,+ node.topRightRadius,+ node.topRightRadius,+ node.bottomRightRadius,+ node.bottomRightRadius,+ node.bottomLeftRadius,+ node.bottomLeftRadius])}return this.ck.RRectXY(this.ck.LTRBRect(0, 0, node.width, node.height),- node.cornerRadius, node.cornerRadius+ node.cornerRadius,+ node.cornerRadius)}@@ -1296,9 +1415,7 @@ export class SkiaRenderer {if (arc.innerRadius > 0) {// Donut shapepath.addArc(oval, startDeg, sweepDeg)- const innerOval = this.ck.LTRBRect(- cx - innerRx, cy - innerRy, cx + innerRx, cy + innerRy- )+ const innerOval = this.ck.LTRBRect(cx - innerRx, cy - innerRy, cx + innerRx, cy + innerRy)const innerPath = new this.ck.Path()innerPath.addArc(innerOval, startDeg + sweepDeg, -sweepDeg)path.addPath(innerPath)@@ -1320,16 +1437,19 @@ export class SkiaRenderer {}private renderEffects(- canvas: Canvas, node: SceneNode, rect: Float32Array,- hasRadius: boolean, pass: 'behind' | 'front'+ canvas: Canvas,+ node: SceneNode,+ rect: Float32Array,+ hasRadius: boolean,+ pass: 'behind' | 'front'): void {for (const effect of node.effects) {if (!effect.visible) continueif (pass === 'behind' && effect.type === 'DROP_SHADOW') {- this.auxFill.setColor(this.ck.Color4f(- effect.color.r, effect.color.g, effect.color.b, effect.color.a- ))+ this.auxFill.setColor(+ this.ck.Color4f(effect.color.r, effect.color.g, effect.color.b, effect.color.a)+ )this.auxFill.setImageFilter(this.ck.ImageFilter.MakeBlur(effect.radius, effect.radius, this.ck.TileMode.Decal, null))@@ -1353,9 +1473,9 @@ export class SkiaRenderer {if (pass === 'front' && effect.type === 'INNER_SHADOW') {// Inner shadow: draw a shadow clipped to the node shape- this.auxFill.setColor(this.ck.Color4f(- effect.color.r, effect.color.g, effect.color.b, effect.color.a- ))+ this.auxFill.setColor(+ this.ck.Color4f(effect.color.r, effect.color.g, effect.color.b, effect.color.a)+ )this.auxFill.setImageFilter(this.ck.ImageFilter.MakeBlur(effect.radius, effect.radius, this.ck.TileMode.Decal, null))@@ -1384,18 +1504,24 @@ export class SkiaRenderer {if (node.type === 'ELLIPSE') {const innerPath = new this.ck.Path()const offsetRect = this.ck.LTRBRect(- effect.offset.x, effect.offset.y,- node.width + effect.offset.x, node.height + effect.offset.y+ effect.offset.x,+ effect.offset.y,+ node.width + effect.offset.x,+ node.height + effect.offset.y)innerPath.addOval(offsetRect)bigPath.op(innerPath, this.ck.PathOp.Difference)innerPath.delete()} else {const innerPath = new this.ck.Path()- innerPath.addRect(this.ck.LTRBRect(- effect.offset.x, effect.offset.y,- node.width + effect.offset.x, node.height + effect.offset.y- ))+ innerPath.addRect(+ this.ck.LTRBRect(+ effect.offset.x,+ effect.offset.y,+ node.width + effect.offset.x,+ node.height + effect.offset.y+ )+ )bigPath.op(innerPath, this.ck.PathOp.Difference)innerPath.delete()}@@ -1420,7 +1546,9 @@ export class SkiaRenderer {fontSize: node.fontSize || DEFAULT_FONT_SIZE,fontStyle: { weight: { value: node.fontWeight || 400 } as FontWeight },letterSpacing: node.letterSpacing || 0,- heightMultiplier: node.lineHeight ? node.lineHeight / (node.fontSize || DEFAULT_FONT_SIZE) : undefined+ heightMultiplier: node.lineHeight+ ? node.lineHeight / (node.fontSize || DEFAULT_FONT_SIZE)+ : undefined}})const builder = this.ck.ParagraphBuilder.MakeFromFontProvider(paraStyle, this.fontProvider)@@ -1472,9 +1600,7 @@ export class SkiaRenderer {private applyGradientFill(fill: Fill, node: SceneNode): void {const stops = fill.gradientStops!const t = fill.gradientTransform!- const colors = stops.map((s) =>- this.ck.Color4f(s.color.r, s.color.g, s.color.b, s.color.a)- )+ const colors = stops.map((s) => this.ck.Color4f(s.color.r, s.color.g, s.color.b, s.color.a))const positions = stops.map((s) => s.position)// Figma gradient transform maps unit square to node bounds@@ -1489,8 +1615,10 @@ export class SkiaRenderer {const endX = (t.m00 + t.m02) * wconst endY = (t.m10 + t.m12) * hconst shader = this.ck.Shader.MakeLinearGradient(- [startX, startY], [endX, endY],- colors, positions,+ [startX, startY],+ [endX, endY],+ colors,+ positions,this.ck.TileMode.Clamp)this.fillPaint.setShader(shader)@@ -1499,8 +1627,10 @@ export class SkiaRenderer {const cy = t.m12 * hconst radius = Math.sqrt(t.m00 * t.m00 + t.m10 * t.m10) * Math.max(w, h)const shader = this.ck.Shader.MakeRadialGradient(- [cx, cy], radius,- colors, positions,+ [cx, cy],+ radius,+ colors,+ positions,this.ck.TileMode.Clamp)this.fillPaint.setShader(shader)@@ -1508,8 +1638,10 @@ export class SkiaRenderer {const cx = t.m02 * wconst cy = t.m12 * hconst shader = this.ck.Shader.MakeSweepGradient(- cx, cy,- colors, positions,+ cx,+ cy,+ colors,+ positions,this.ck.TileMode.Clamp,// Figma angular gradients start from right (0°), CanvasKit sweep from right tooundefined@@ -1521,8 +1653,10 @@ export class SkiaRenderer {const cy = t.m12 * hconst radius = Math.sqrt(t.m00 * t.m00 + t.m10 * t.m10) * Math.max(w, h)const shader = this.ck.Shader.MakeRadialGradient(- [cx, cy], radius,- colors, positions,+ [cx, cy],+ radius,+ colors,+ positions,this.ck.TileMode.Clamp)this.fillPaint.setShader(shader)@@ -1558,12 +1692,17 @@ export class SkiaRenderer {sy = 0// FIT: image centered within bounds — handled by shader matrix} else {- sx = 0; sy = 0; sw = imgW; sh = imgH+ sx = 0+ sy = 0+ sw = imgW+ sh = imgH}const shader = img.makeShaderCubic(- this.ck.TileMode.Clamp, this.ck.TileMode.Clamp,- 1 / 3, 1 / 3,+ this.ck.TileMode.Clamp,+ this.ck.TileMode.Clamp,+ 1 / 3,+ 1 / 3,this.ck.Matrix.multiply(this.ck.Matrix.scaled(node.width / sw, node.height / sh),this.ck.Matrix.translated(-sx, -sy)@@ -1619,8 +1758,10 @@ export class SkiaRenderer {path.moveTo(s.x, s.y)const isLine =- seg.tangentStart.x === 0 && seg.tangentStart.y === 0 &&- seg.tangentEnd.x === 0 && seg.tangentEnd.y === 0+ seg.tangentStart.x === 0 &&+ seg.tangentStart.y === 0 &&+ seg.tangentEnd.x === 0 &&+ seg.tangentEnd.y === 0if (isLine) {path.lineTo(e.x, e.y)} else {@@ -1690,7 +1831,10 @@ export class SkiaRenderer {// Draw verticesfor (let i = 0; i < vertices.length; i++) {const v = toScreen(vertices[i].x, vertices[i].y)- const radius = i === 0 && penState.closingToFirst ? PEN_VERTEX_RADIUS + PEN_CLOSE_RADIUS_BOOST : PEN_VERTEX_RADIUS+ const radius =+ i === 0 && penState.closingToFirst+ ? PEN_VERTEX_RADIUS + PEN_CLOSE_RADIUS_BOOST+ : PEN_VERTEX_RADIUScanvas.drawCircle(v.x, v.y, radius, vertexFill)canvas.drawCircle(v.x, v.y, radius, vertexStroke)}@@ -1703,8 +1847,6 @@ export class SkiaRenderer {// --- Rulers -----private drawRulers(canvas: Canvas, graph: SceneGraph, selectedIds: Set<string>): void {const R = RULER_SIZEconst vw = this.viewportWidth@@ -1722,7 +1864,9 @@ export class SkiaRenderer {canvas.drawRect(this.ck.LTRBRect(0, 0, R, R), bgPaint)const tickPaint = new this.ck.Paint()- tickPaint.setColor(this.ck.Color4f(RULER_TICK_COLOR.r, RULER_TICK_COLOR.g, RULER_TICK_COLOR.b, 1))+ tickPaint.setColor(+ this.ck.Color4f(RULER_TICK_COLOR.r, RULER_TICK_COLOR.g, RULER_TICK_COLOR.b, 1)+ )tickPaint.setStrokeWidth(1)tickPaint.setAntiAlias(true)@@ -1732,18 +1876,29 @@ export class SkiaRenderer {textPaint.setAntiAlias(true)const font = this.sizeFont ?? this.textFont- if (!font) { bgPaint.delete(); tickPaint.delete(); textPaint.delete(); return }+ if (!font) {+ bgPaint.delete()+ tickPaint.delete()+ textPaint.delete()+ return+ }const step = this.rulerStep()const minorStep = step / 5// Compute selection bounds for badge exclusion zones- let sx1 = -Infinity, sx2 = -Infinity, sy1 = -Infinity, sy2 = -Infinity+ let sx1 = -Infinity,+ sx2 = -Infinity,+ sy1 = -Infinity,+ sy2 = -Infinityconst selNodes = [...selectedIds].map((id) => graph.getNode(id)).filter((n): n is SceneNode => n !== undefined)if (selNodes.length > 0) {- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity+ let minX = Infinity,+ minY = Infinity,+ maxX = -Infinity,+ maxY = -Infinityfor (const n of selNodes) {const abs = graph.getAbsolutePosition(n.id)minX = Math.min(minX, abs.x)@@ -1825,10 +1980,38 @@ export class SkiaRenderer {canvas.drawRect(this.ck.LTRBRect(Math.max(R, sx1), 0, sx2, R), hlPaint)canvas.drawRect(this.ck.LTRBRect(0, Math.max(R, sy1), R, sy2), hlPaint)- this.drawRulerBadge(canvas, font, Math.round((sx1 - this.panX) / this.zoom).toString(), Math.max(R, sx1), 0, 'horizontal')- this.drawRulerBadge(canvas, font, Math.round((sx2 - this.panX) / this.zoom).toString(), sx2, 0, 'horizontal')- this.drawRulerBadge(canvas, font, Math.round((sy1 - this.panY) / this.zoom).toString(), 0, Math.max(R, sy1), 'vertical')- this.drawRulerBadge(canvas, font, Math.round((sy2 - this.panY) / this.zoom).toString(), 0, sy2, 'vertical')+ this.drawRulerBadge(+ canvas,+ font,+ Math.round((sx1 - this.panX) / this.zoom).toString(),+ Math.max(R, sx1),+ 0,+ 'horizontal'+ )+ this.drawRulerBadge(+ canvas,+ font,+ Math.round((sx2 - this.panX) / this.zoom).toString(),+ sx2,+ 0,+ 'horizontal'+ )+ this.drawRulerBadge(+ canvas,+ font,+ Math.round((sy1 - this.panY) / this.zoom).toString(),+ 0,+ Math.max(R, sy1),+ 'vertical'+ )+ this.drawRulerBadge(+ canvas,+ font,+ Math.round((sy2 - this.panY) / this.zoom).toString(),+ 0,+ sy2,+ 'vertical'+ )hlPaint.delete()}@@ -1838,7 +2021,14 @@ export class SkiaRenderer {textPaint.delete()}- private drawRulerBadge(canvas: Canvas, font: InstanceType<CanvasKit['Font']>, label: string, x: number, y: number, axis: 'horizontal' | 'vertical'): void {+ private drawRulerBadge(+ canvas: Canvas,+ font: InstanceType<CanvasKit['Font']>,+ label: string,+ x: number,+ y: number,+ axis: 'horizontal' | 'vertical'+ ): void {const R = RULER_SIZEconst glyphIds = font.getGlyphIDs(label)const widths = font.getGlyphWidths(glyphIds)@@ -1855,16 +2045,30 @@ export class SkiaRenderer {if (axis === 'horizontal') {const bx = x - (textW + pad * 2) / 2const by = (R - h) / 2- canvas.drawRRect(this.ck.RRectXY(this.ck.LTRBRect(bx, by, bx + textW + pad * 2, by + h), RULER_BADGE_RADIUS, RULER_BADGE_RADIUS), badgePaint)+ canvas.drawRRect(+ this.ck.RRectXY(+ this.ck.LTRBRect(bx, by, bx + textW + pad * 2, by + h),+ RULER_BADGE_RADIUS,+ RULER_BADGE_RADIUS+ ),+ badgePaint+ )canvas.drawText(label, bx + pad, R * RULER_TEXT_BASELINE, labelPaint, font)} else {const bw = textW + pad * 2const bx = (R - h) / 2- const by = y - (bw) / 2+ const by = y - bw / 2canvas.save()canvas.translate(bx + h / 2, by + bw / 2)canvas.rotate(-90, 0, 0)- canvas.drawRRect(this.ck.RRectXY(this.ck.LTRBRect(-bw / 2, -h / 2, bw / 2, h / 2), RULER_BADGE_RADIUS, RULER_BADGE_RADIUS), badgePaint)+ canvas.drawRRect(+ this.ck.RRectXY(+ this.ck.LTRBRect(-bw / 2, -h / 2, bw / 2, h / 2),+ RULER_BADGE_RADIUS,+ RULER_BADGE_RADIUS+ ),+ badgePaint+ )canvas.drawText(label, -bw / 2 + pad, h / 2 - 3, labelPaint, font)canvas.restore()}diff --git a/src/engine/scene-graph.ts b/src/engine/scene-graph.tsindex 829b46295..6d6d9005b 100644--- a/src/engine/scene-graph.ts+++ b/src/engine/scene-graph.ts@@ -51,8 +51,31 @@ export type NodeType =import type { Color } from '../types'-export type FillType = 'SOLID' | 'GRADIENT_LINEAR' | 'GRADIENT_RADIAL' | 'GRADIENT_ANGULAR' | 'GRADIENT_DIAMOND' | 'IMAGE'-export type BlendMode = 'NORMAL' | 'DARKEN' | 'MULTIPLY' | 'COLOR_BURN' | 'LIGHTEN' | 'SCREEN' | 'COLOR_DODGE' | 'OVERLAY' | 'SOFT_LIGHT' | 'HARD_LIGHT' | 'DIFFERENCE' | 'EXCLUSION' | 'HUE' | 'SATURATION' | 'COLOR' | 'LUMINOSITY' | 'PASS_THROUGH'+export type FillType =+ | 'SOLID'+ | 'GRADIENT_LINEAR'+ | 'GRADIENT_RADIAL'+ | 'GRADIENT_ANGULAR'+ | 'GRADIENT_DIAMOND'+ | 'IMAGE'+export type BlendMode =+ | 'NORMAL'+ | 'DARKEN'+ | 'MULTIPLY'+ | 'COLOR_BURN'+ | 'LIGHTEN'+ | 'SCREEN'+ | 'COLOR_DODGE'+ | 'OVERLAY'+ | 'SOFT_LIGHT'+ | 'HARD_LIGHT'+ | 'DIFFERENCE'+ | 'EXCLUSION'+ | 'HUE'+ | 'SATURATION'+ | 'COLOR'+ | 'LUMINOSITY'+ | 'PASS_THROUGH'export type ImageScaleMode = 'FILL' | 'FIT' | 'CROP' | 'TILE'export interface GradientStop {@@ -290,7 +313,15 @@ function createDefaultNode(type: NodeType, overrides: Partial<SceneNode> = {}):}}-const CONTAINER_TYPES = new Set<NodeType>(['CANVAS', 'FRAME', 'GROUP', 'SECTION', 'COMPONENT', 'COMPONENT_SET', 'INSTANCE'])+const CONTAINER_TYPES = new Set<NodeType>([+ 'CANVAS',+ 'FRAME',+ 'GROUP',+ 'SECTION',+ 'COMPONENT',+ 'COMPONENT_SET',+ 'INSTANCE'+])export class SceneGraph {nodes = new Map<string, SceneNode>()@@ -432,7 +463,10 @@ export class SceneGraph {// If same parent, adjust index since we removed the itemlet idx = insertIndex- if (oldParent === newParent && idx > (oldParent.childIds.indexOf(nodeId) === -1 ? idx : oldParent.childIds.length)) {+ if (+ oldParent === newParent &&+ idx > (oldParent.childIds.indexOf(nodeId) === -1 ? idx : oldParent.childIds.length)+ ) {// Already removed above, no adjustment needed}@@ -512,7 +546,12 @@ export class SceneGraph {return null}- hitTestFrame(px: number, py: number, excludeIds: Set<string>, scopeId?: string): SceneNode | null {+ hitTestFrame(+ px: number,+ py: number,+ excludeIds: Set<string>,+ scopeId?: string+ ): SceneNode | null {return this.hitTestFrameChildren(px, py, scopeId ?? this.rootId, 0, 0, excludeIds)}@@ -550,7 +589,11 @@ export class SceneGraph {return best}- cloneTree(sourceId: string, parentId: string, overrides: Partial<SceneNode> = {}): SceneNode | null {+ cloneTree(+ sourceId: string,+ parentId: string,+ overrides: Partial<SceneNode> = {}+ ): SceneNode | null {const src = this.nodes.get(sourceId)if (!src) return null@@ -565,14 +608,38 @@ export class SceneGraph {}private static readonly INSTANCE_SYNC_PROPS: (keyof SceneNode)[] = [- 'width', 'height', 'fills', 'strokes', 'effects', 'opacity',- 'cornerRadius', 'topLeftRadius', 'topRightRadius', 'bottomRightRadius', 'bottomLeftRadius',- 'independentCorners', 'layoutMode', 'layoutWrap', 'primaryAxisAlign', 'counterAxisAlign',- 'primaryAxisSizing', 'counterAxisSizing', 'itemSpacing', 'counterAxisSpacing',- 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'clipsContent'+ 'width',+ 'height',+ 'fills',+ 'strokes',+ 'effects',+ 'opacity',+ 'cornerRadius',+ 'topLeftRadius',+ 'topRightRadius',+ 'bottomRightRadius',+ 'bottomLeftRadius',+ 'independentCorners',+ 'layoutMode',+ 'layoutWrap',+ 'primaryAxisAlign',+ 'counterAxisAlign',+ 'primaryAxisSizing',+ 'counterAxisSizing',+ 'itemSpacing',+ 'counterAxisSpacing',+ 'paddingTop',+ 'paddingRight',+ 'paddingBottom',+ 'paddingLeft',+ 'clipsContent']- createInstance(componentId: string, parentId: string, overrides: Partial<SceneNode> = {}): SceneNode | null {+ createInstance(+ componentId: string,+ parentId: string,+ overrides: Partial<SceneNode> = {}+ ): SceneNode | null {const component = this.nodes.get(componentId)if (!component || component.type !== 'COMPONENT') return nulldiff --git a/src/engine/snap.ts b/src/engine/snap.tsindex b42a254b3..50f3541e2 100644--- a/src/engine/snap.ts+++ b/src/engine/snap.ts@@ -36,13 +36,16 @@ function getEdges(node: SceneNode) {const hh = node.height / 2const corners = [- { x: cx + (-hw) * cos - (-hh) * sin, y: cy + (-hw) * sin + (-hh) * cos },- { x: cx + hw * cos - (-hh) * sin, y: cy + hw * sin + (-hh) * cos },+ { x: cx + -hw * cos - -hh * sin, y: cy + -hw * sin + -hh * cos },+ { x: cx + hw * cos - -hh * sin, y: cy + hw * sin + -hh * cos },{ x: cx + hw * cos - hh * sin, y: cy + hw * sin + hh * cos },- { x: cx + (-hw) * cos - hh * sin, y: cy + (-hw) * sin + hh * cos },+ { x: cx + -hw * cos - hh * sin, y: cy + -hw * sin + hh * cos }]- let left = Infinity, right = -Infinity, top = Infinity, bottom = -Infinity+ let left = Infinity,+ right = -Infinity,+ top = Infinity,+ bottom = -Infinityfor (const c of corners) {left = Math.min(left, c.x)right = Math.max(right, c.x)diff --git a/src/engine/vector.ts b/src/engine/vector.tsindex c75cd79e8..bb17d9d12 100644--- a/src/engine/vector.ts+++ b/src/engine/vector.ts@@ -1,7 +1,13 @@+import type {+ HandleMirroring,+ VectorNetwork,+ VectorRegion,+ VectorSegment,+ VectorVertex,+ WindingRule+} from './scene-graph'import type { CanvasKit, Path } from 'canvaskit-wasm'-import type { HandleMirroring, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule } from './scene-graph'-// --- vectorNetworkBlob binary format ---// Header: [numVertices:u32, numSegments:u32, numRegions:u32] (12 bytes)// Vertex: [styleOverrideIdx:u32, x:f32, y:f32] (12 bytes)@@ -20,9 +26,12 @@ export function decodeVectorNetworkBlob(const view = new DataView(data.buffer, data.byteOffset, data.byteLength)let o = 0- const nV = view.getUint32(o, true); o += 4- const nS = view.getUint32(o, true); o += 4- const nR = view.getUint32(o, true); o += 4+ const nV = view.getUint32(o, true)+ o += 4+ const nS = view.getUint32(o, true)+ o += 4+ const nR = view.getUint32(o, true)+ o += 4const styleMap = new Map<number, StyleOverride>()if (styleOverrideTable) {@@ -33,9 +42,12 @@ export function decodeVectorNetworkBlob(const vertices: VectorVertex[] = []for (let i = 0; i < nV; i++) {- const styleIdx = view.getUint32(o, true); o += 4- const x = view.getFloat32(o, true); o += 4- const y = view.getFloat32(o, true); o += 4+ const styleIdx = view.getUint32(o, true)+ o += 4+ const x = view.getFloat32(o, true)+ o += 4+ const y = view.getFloat32(o, true)+ o += 4const override = styleMap.get(styleIdx)vertices.push({@@ -48,12 +60,18 @@ export function decodeVectorNetworkBlob(const segments: VectorSegment[] = []for (let i = 0; i < nS; i++) {o += 4 // styleOverrideIdx (unused for segments currently)- const start = view.getUint32(o, true); o += 4- const tsX = view.getFloat32(o, true); o += 4- const tsY = view.getFloat32(o, true); o += 4- const end = view.getUint32(o, true); o += 4- const teX = view.getFloat32(o, true); o += 4- const teY = view.getFloat32(o, true); o += 4+ const start = view.getUint32(o, true)+ o += 4+ const tsX = view.getFloat32(o, true)+ o += 4+ const tsY = view.getFloat32(o, true)+ o += 4+ const end = view.getUint32(o, true)+ o += 4+ const teX = view.getFloat32(o, true)+ o += 4+ const teY = view.getFloat32(o, true)+ o += 4segments.push({start,@@ -65,15 +83,19 @@ export function decodeVectorNetworkBlob(const regions: VectorRegion[] = []for (let i = 0; i < nR; i++) {- const windingRuleU32 = view.getUint32(o, true); o += 4+ const windingRuleU32 = view.getUint32(o, true)+ o += 4const windingRule: WindingRule = windingRuleU32 === 0 ? 'EVENODD' : 'NONZERO'- const numLoops = view.getUint32(o, true); o += 4+ const numLoops = view.getUint32(o, true)+ o += 4const loops: number[][] = []for (let j = 0; j < numLoops; j++) {- const numSegs = view.getUint32(o, true); o += 4+ const numSegs = view.getUint32(o, true)+ o += 4const loop: number[] = []for (let k = 0; k < numSegs; k++) {- loop.push(view.getUint32(o, true)); o += 4+ loop.push(view.getUint32(o, true))+ o += 4}loops.push(loop)}@@ -99,33 +121,50 @@ export function encodeVectorNetworkBlob(network: VectorNetwork): Uint8Array {const view = new DataView(buf)let o = 0- view.setUint32(o, vertices.length, true); o += 4- view.setUint32(o, segments.length, true); o += 4- view.setUint32(o, regions.length, true); o += 4+ view.setUint32(o, vertices.length, true)+ o += 4+ view.setUint32(o, segments.length, true)+ o += 4+ view.setUint32(o, regions.length, true)+ o += 4for (const v of vertices) {- view.setUint32(o, 0, true); o += 4 // styleOverrideIdx (TODO: encode handleMirroring)- view.setFloat32(o, v.x, true); o += 4- view.setFloat32(o, v.y, true); o += 4+ view.setUint32(o, 0, true)+ o += 4 // styleOverrideIdx (TODO: encode handleMirroring)+ view.setFloat32(o, v.x, true)+ o += 4+ view.setFloat32(o, v.y, true)+ o += 4}for (const seg of segments) {- view.setUint32(o, 0, true); o += 4 // styleOverrideIdx- view.setUint32(o, seg.start, true); o += 4- view.setFloat32(o, seg.tangentStart.x, true); o += 4- view.setFloat32(o, seg.tangentStart.y, true); o += 4- view.setUint32(o, seg.end, true); o += 4- view.setFloat32(o, seg.tangentEnd.x, true); o += 4- view.setFloat32(o, seg.tangentEnd.y, true); o += 4+ view.setUint32(o, 0, true)+ o += 4 // styleOverrideIdx+ view.setUint32(o, seg.start, true)+ o += 4+ view.setFloat32(o, seg.tangentStart.x, true)+ o += 4+ view.setFloat32(o, seg.tangentStart.y, true)+ o += 4+ view.setUint32(o, seg.end, true)+ o += 4+ view.setFloat32(o, seg.tangentEnd.x, true)+ o += 4+ view.setFloat32(o, seg.tangentEnd.y, true)+ o += 4}for (const region of regions) {- view.setUint32(o, region.windingRule === 'EVENODD' ? 0 : 1, true); o += 4- view.setUint32(o, region.loops.length, true); o += 4+ view.setUint32(o, region.windingRule === 'EVENODD' ? 0 : 1, true)+ o += 4+ view.setUint32(o, region.loops.length, true)+ o += 4for (const loop of region.loops) {- view.setUint32(o, loop.length, true); o += 4+ view.setUint32(o, loop.length, true)+ o += 4for (const segIdx of loop) {- view.setUint32(o, segIdx, true); o += 4+ view.setUint32(o, segIdx, true)+ o += 4}}}@@ -142,9 +181,7 @@ export function vectorNetworkToPath(ck: CanvasKit, network: VectorNetwork): Pathfor (const loop of region.loops) {addLoopToPath(path, loop, segments, vertices)}- path.setFillType(- region.windingRule === 'EVENODD' ? ck.FillType.EvenOdd : ck.FillType.Winding- )+ path.setFillType(region.windingRule === 'EVENODD' ? ck.FillType.EvenOdd : ck.FillType.Winding)}} else {// No regions — draw all segments as open paths@@ -195,11 +232,7 @@ function addLoopToPath(}}-function addSegmentToPath(- path: Path,- seg: VectorSegment,- vertices: VectorVertex[]-): void {+function addSegmentToPath(path: Path, seg: VectorSegment, vertices: VectorVertex[]): void {const start = vertices[seg.start]const end = vertices[seg.end]const ts = seg.tangentStart@@ -210,14 +243,7 @@ function addSegmentToPath(path.lineTo(end.x, end.y)} else {// Cubic bezier: control points are tangent offsets from start/end- path.cubicTo(- start.x + ts.x,- start.y + ts.y,- end.x + te.x,- end.y + te.y,- end.x,- end.y- )+ path.cubicTo(start.x + ts.x, start.y + ts.y, end.x + te.x, end.y + te.y, end.x, end.y)}}@@ -238,13 +264,9 @@ function buildChains(segments: VectorSegment[], _vertexCount: number): number[][const chains: number[][] = []// Start from degree-1 vertices (endpoints) or any unvisited- const degree1 = [...adj.entries()]- .filter(([, segs]) => segs.length === 1)- .map(([v]) => v)+ const degree1 = [...adj.entries()].filter(([, segs]) => segs.length === 1).map(([v]) => v)- const startVertices = degree1.length > 0- ? degree1- : [segments[0].start]+ const startVertices = degree1.length > 0 ? degree1 : [segments[0].start]for (const startVertex of startVertices) {let current = startVertex@@ -270,9 +292,12 @@ function buildChains(segments: VectorSegment[], _vertexCount: number): number[][return chains}-export function computeVectorBounds(- network: VectorNetwork-): { x: number; y: number; width: number; height: number } {+export function computeVectorBounds(network: VectorNetwork): {+ x: number+ y: number+ width: number+ height: number+} {if (network.vertices.length === 0) {return { x: 0, y: 0, width: 0, height: 0 }}diff --git a/src/kiwi/codec.ts b/src/kiwi/codec.tsindex dceb9bd0a..f0afea4d0 100644--- a/src/kiwi/codec.ts+++ b/src/kiwi/codec.ts@@ -7,14 +7,14 @@*/import { decompress as zstdDecompress } from 'fzstd'-import { compileSchema, encodeBinarySchema } from './kiwi-schema'--import type { Schema } from './kiwi-schema'import { parseColor } from '../engine/color'+import { compileSchema, encodeBinarySchema } from './kiwi-schema'import { isZstdCompressed, getKiwiMessageType } from './protocol.ts'import figmaSchema from './schema.ts'+import type { Schema } from './kiwi-schema'+interface CompiledSchema {encodeMessage(message: unknown): Uint8ArraydecodeMessage(data: Uint8Array): unknowndiff --git a/src/kiwi/fig-file.ts b/src/kiwi/fig-file.tsindex e0e3c4c14..4dc730bff 100644--- a/src/kiwi/fig-file.ts+++ b/src/kiwi/fig-file.ts@@ -1,8 +1,8 @@import { unzipSync, inflateSync } from 'fflate'import { decompress as zstdDecompress } from 'fzstd'-import { decodeBinarySchema, compileSchema, ByteBuffer } from './kiwi-schema'import { importNodeChanges } from './fig-import'+import { decodeBinarySchema, compileSchema, ByteBuffer } from './kiwi-schema'import { isZstdCompressed } from './protocol'import type { SceneGraph } from '../engine/scene-graph'@@ -34,7 +34,11 @@ function parseFigKiwiContainer(data: Uint8Array): FigKiwiPayload | null {if (isZstdCompressed(compressed)) {dataRaw = zstdDecompress(compressed)} else {- try { dataRaw = inflateSync(compressed) } catch { dataRaw = compressed }+ try {+ dataRaw = inflateSync(compressed)+ } catch {+ dataRaw = compressed+ }}return { schemaDeflated: chunks[0], dataRaw }@@ -80,8 +84,11 @@ export async function parseFigFile(buffer: ArrayBuffer): Promise<SceneGraph> {throw new Error('No nodes found in .fig file')}- const blobs: Uint8Array[] = ((message as unknown as Record<string, unknown>).blobs as Array<{ bytes: Uint8Array }> ?? [])- .map((b) => b.bytes instanceof Uint8Array ? b.bytes : new Uint8Array(Object.values(b.bytes) as number[]))+ const blobs: Uint8Array[] = (+ ((message as unknown as Record<string, unknown>).blobs as Array<{ bytes: Uint8Array }>) ?? []+ ).map((b) =>+ b.bytes instanceof Uint8Array ? b.bytes : new Uint8Array(Object.values(b.bytes) as number[])+ )const images = new Map<string, Uint8Array>()for (const name of entries) {diff --git a/src/kiwi/fig-import.ts b/src/kiwi/fig-import.tsindex f8b8196fb..2f3eccace 100644--- a/src/kiwi/fig-import.ts+++ b/src/kiwi/fig-import.ts@@ -1,14 +1,32 @@import { SceneGraph } from '../engine/scene-graph'import { decodeVectorNetworkBlob } from '../engine/vector'-import type { NodeChange, Paint, Effect as KiwiEffect, GUID } from './codec'import type {- NodeType, Fill, FillType, Stroke, Effect, Color, BlendMode, ImageScaleMode,- GradientStop, GradientTransform, StrokeCap, StrokeJoin,- LayoutMode, LayoutSizing, LayoutAlign, LayoutCounterAlign,- ConstraintType, TextAutoResize, TextAlignVertical, TextCase, TextDecoration,- ArcData, VectorNetwork+ NodeType,+ Fill,+ FillType,+ Stroke,+ Effect,+ Color,+ BlendMode,+ ImageScaleMode,+ GradientStop,+ GradientTransform,+ StrokeCap,+ StrokeJoin,+ LayoutMode,+ LayoutSizing,+ LayoutAlign,+ LayoutCounterAlign,+ ConstraintType,+ TextAutoResize,+ TextAlignVertical,+ TextCase,+ TextDecoration,+ ArcData,+ VectorNetwork} from '../engine/scene-graph'+import type { NodeChange, Paint, Effect as KiwiEffect, GUID } from './codec'function ext(nc: NodeChange): Record<string, unknown> {return nc as unknown as Record<string, unknown>@@ -24,7 +42,9 @@ function convertColor(color?: { r: number; g: number; b: number; a: number }): C}function imageHashToString(hash: Record<string, number>): string {- const bytes = Object.keys(hash).sort((a, b) => Number(a) - Number(b)).map((k) => hash[Number(k)])+ const bytes = Object.keys(hash)+ .sort((a, b) => Number(a) - Number(b))+ .map((k) => hash[Number(k)])return bytes.map((b) => b.toString(16).padStart(2, '0')).join('')}@@ -41,14 +61,16 @@ function convertFills(paints?: Paint[]): Fill[] {color: convertColor(p.color),opacity: p.opacity ?? 1,visible: p.visible ?? true,- blendMode: (p.blendMode ?? 'NORMAL') as BlendMode,+ blendMode: (p.blendMode ?? 'NORMAL') as BlendMode}if (p.type?.startsWith('GRADIENT') && p.stops) {- base.gradientStops = p.stops.map((s: { color: Record<string, number>; position: number }) => ({- color: convertColor(s.color as Color),- position: s.position- }))+ base.gradientStops = p.stops.map(+ (s: { color: Record<string, number>; position: number }) => ({+ color: convertColor(s.color as Color),+ position: s.position+ })+ )base.gradientTransform = convertGradientTransform(p.transform as Record<string, number>)}@@ -68,14 +90,25 @@ function convertFills(paints?: Paint[]): Fill[] {})}-function convertStrokes(paints?: Paint[], weight?: number, align?: string, cap?: string, join?: string, dashPattern?: number[]): Stroke[] {+function convertStrokes(+ paints?: Paint[],+ weight?: number,+ align?: string,+ cap?: string,+ join?: string,+ dashPattern?: number[]+): Stroke[] {if (!paints) return []return paints.map((p) => ({color: convertColor(p.color),weight: weight ?? 1,opacity: p.opacity ?? 1,visible: p.visible ?? true,- align: (align === 'INSIDE' ? 'INSIDE' : align === 'OUTSIDE' ? 'OUTSIDE' : 'CENTER') as Stroke['align'],+ align: (align === 'INSIDE'+ ? 'INSIDE'+ : align === 'OUTSIDE'+ ? 'OUTSIDE'+ : 'CENTER') as Stroke['align'],cap: (cap ?? 'NONE') as StrokeCap,join: (join ?? 'MITER') as StrokeJoin,dashPattern: dashPattern ?? []@@ -97,34 +130,57 @@ function convertEffects(effects?: KiwiEffect[]): Effect[] {function mapNodeType(type?: string): NodeType | 'DOCUMENT' {switch (type) {- case 'DOCUMENT': return 'DOCUMENT'- case 'CANVAS': return 'CANVAS'- case 'FRAME': return 'FRAME'- case 'RECTANGLE': return 'RECTANGLE'- case 'ROUNDED_RECTANGLE': return 'ROUNDED_RECTANGLE'- case 'ELLIPSE': return 'ELLIPSE'- case 'TEXT': return 'TEXT'- case 'LINE': return 'LINE'- case 'STAR': return 'STAR'- case 'REGULAR_POLYGON': return 'POLYGON'- case 'VECTOR': return 'VECTOR'- case 'GROUP': return 'GROUP'- case 'SECTION': return 'SECTION'- case 'COMPONENT': return 'COMPONENT'- case 'COMPONENT_SET': return 'COMPONENT_SET'- case 'INSTANCE': return 'INSTANCE'- case 'SYMBOL': return 'COMPONENT'- case 'CONNECTOR': return 'CONNECTOR'- case 'SHAPE_WITH_TEXT': return 'SHAPE_WITH_TEXT'- default: return 'RECTANGLE'+ case 'DOCUMENT':+ return 'DOCUMENT'+ case 'CANVAS':+ return 'CANVAS'+ case 'FRAME':+ return 'FRAME'+ case 'RECTANGLE':+ return 'RECTANGLE'+ case 'ROUNDED_RECTANGLE':+ return 'ROUNDED_RECTANGLE'+ case 'ELLIPSE':+ return 'ELLIPSE'+ case 'TEXT':+ return 'TEXT'+ case 'LINE':+ return 'LINE'+ case 'STAR':+ return 'STAR'+ case 'REGULAR_POLYGON':+ return 'POLYGON'+ case 'VECTOR':+ return 'VECTOR'+ case 'GROUP':+ return 'GROUP'+ case 'SECTION':+ return 'SECTION'+ case 'COMPONENT':+ return 'COMPONENT'+ case 'COMPONENT_SET':+ return 'COMPONENT_SET'+ case 'INSTANCE':+ return 'INSTANCE'+ case 'SYMBOL':+ return 'COMPONENT'+ case 'CONNECTOR':+ return 'CONNECTOR'+ case 'SHAPE_WITH_TEXT':+ return 'SHAPE_WITH_TEXT'+ default:+ return 'RECTANGLE'}}function mapStackMode(mode?: string): LayoutMode {switch (mode) {- case 'HORIZONTAL': return 'HORIZONTAL'- case 'VERTICAL': return 'VERTICAL'- default: return 'NONE'+ case 'HORIZONTAL':+ return 'HORIZONTAL'+ case 'VERTICAL':+ return 'VERTICAL'+ default:+ return 'NONE'}}@@ -142,21 +198,30 @@ function mapStackSizing(sizing?: string): LayoutSizing {function mapStackJustify(justify?: string): LayoutAlign {switch (justify) {- case 'CENTER': return 'CENTER'- case 'MAX': return 'MAX'+ case 'CENTER':+ return 'CENTER'+ case 'MAX':+ return 'MAX'case 'SPACE_BETWEEN':- case 'SPACE_EVENLY': return 'SPACE_BETWEEN'- default: return 'MIN'+ case 'SPACE_EVENLY':+ return 'SPACE_BETWEEN'+ default:+ return 'MIN'}}function mapStackCounterAlign(align?: string): LayoutCounterAlign {switch (align) {- case 'CENTER': return 'CENTER'- case 'MAX': return 'MAX'- case 'STRETCH': return 'STRETCH'- case 'BASELINE': return 'BASELINE'- default: return 'MIN'+ case 'CENTER':+ return 'CENTER'+ case 'MAX':+ return 'MAX'+ case 'STRETCH':+ return 'STRETCH'+ case 'BASELINE':+ return 'BASELINE'+ default:+ return 'MIN'}}@@ -176,19 +241,27 @@ function mapFontWeight(style?: string): number {function mapConstraint(c?: string): ConstraintType {switch (c) {- case 'CENTER': return 'CENTER'- case 'MAX': return 'MAX'- case 'STRETCH': return 'STRETCH'- case 'SCALE': return 'SCALE'- default: return 'MIN'+ case 'CENTER':+ return 'CENTER'+ case 'MAX':+ return 'MAX'+ case 'STRETCH':+ return 'STRETCH'+ case 'SCALE':+ return 'SCALE'+ default:+ return 'MIN'}}function mapTextDecoration(d?: string): TextDecoration {switch (d) {- case 'UNDERLINE': return 'UNDERLINE'- case 'STRIKETHROUGH': return 'STRIKETHROUGH'- default: return 'NONE'+ case 'UNDERLINE':+ return 'UNDERLINE'+ case 'STRIKETHROUGH':+ return 'STRIKETHROUGH'+ default:+ return 'NONE'}}@@ -202,10 +275,12 @@ function mapArcData(data?: Record<string, number>): ArcData | null {}function resolveVectorNetwork(nc: NodeChange, blobs: Uint8Array[]): VectorNetwork | null {- const vectorData = (nc as unknown as Record<string, unknown>).vectorData as {- vectorNetworkBlob?: number- styleOverrideTable?: Array<{ styleID: number; handleMirroring?: string }>- } | undefined+ const vectorData = (nc as unknown as Record<string, unknown>).vectorData as+ | {+ vectorNetworkBlob?: number+ styleOverrideTable?: Array<{ styleID: number; handleMirroring?: string }>+ }+ | undefinedif (!vectorData || vectorData.vectorNetworkBlob === undefined) return nullconst idx = vectorData.vectorNetworkBlob@@ -299,7 +374,14 @@ export function importNodeChanges(locked: nc.locked ?? false,blendMode: (ext(nc).blendMode as Fill['blendMode']) ?? 'PASS_THROUGH',fills: convertFills(nc.fillPaints),- strokes: convertStrokes(nc.strokePaints, nc.strokeWeight, nc.strokeAlign, nc.strokeCap, nc.strokeJoin, dashPattern),+ strokes: convertStrokes(+ nc.strokePaints,+ nc.strokeWeight,+ nc.strokeAlign,+ nc.strokeCap,+ nc.strokeJoin,+ dashPattern+ ),effects: convertEffects(nc.effects),cornerRadius: nc.cornerRadius ?? 0,topLeftRadius: nc.rectangleTopLeftCornerRadius ?? nc.cornerRadius ?? 0,@@ -346,7 +428,7 @@ export function importNodeChanges(borderRightWeight: (ext(nc).borderRightWeight as number) ?? 0,borderBottomWeight: (ext(nc).borderBottomWeight as number) ?? 0,borderLeftWeight: (ext(nc).borderLeftWeight as number) ?? 0,- independentStrokeWeights: (ext(nc).borderStrokeWeightsIndependent as boolean) ?? false,+ independentStrokeWeights: (ext(nc).borderStrokeWeightsIndependent as boolean) ?? false})for (const childId of getChildren(ncId)) {diff --git a/src/kiwi/kiwi-schema/bb.ts b/src/kiwi/kiwi-schema/bb.tsindex a65f2613d..84f703c84 100644--- a/src/kiwi/kiwi-schema/bb.ts+++ b/src/kiwi/kiwi-schema/bb.ts@@ -1,274 +1,281 @@-let int32 = new Int32Array(1);-let float32 = new Float32Array(int32.buffer);+let int32 = new Int32Array(1)+let float32 = new Float32Array(int32.buffer)export class ByteBuffer {- private _data: Uint8Array;- private _index: number;- length: number;+ private _data: Uint8Array+ private _index: number+ length: numberconstructor(data?: Uint8Array) {if (data && !(data instanceof Uint8Array)) {- throw new Error('Must initialize a ByteBuffer with a Uint8Array');+ throw new Error('Must initialize a ByteBuffer with a Uint8Array')}- this._data = data || new Uint8Array(256);- this._index = 0;- this.length = data ? data.length : 0;+ this._data = data || new Uint8Array(256)+ this._index = 0+ this.length = data ? data.length : 0}toUint8Array(): Uint8Array {- return this._data.subarray(0, this.length);+ return this._data.subarray(0, this.length)}readByte(): number {if (this._index + 1 > this._data.length) {- throw new Error('Index out of bounds');+ throw new Error('Index out of bounds')}- return this._data[this._index++];+ return this._data[this._index++]}readByteArray(): Uint8Array {- let length = this.readVarUint();- let start = this._index;- let end = start + length;+ let length = this.readVarUint()+ let start = this._index+ let end = start + lengthif (end > this._data.length) {- throw new Error('Read array out of bounds');+ throw new Error('Read array out of bounds')}- this._index = end;+ this._index = end// Copy into a new array instead of just creating another view.- let result = new Uint8Array(length);- result.set(this._data.subarray(start, end));- return result;+ let result = new Uint8Array(length)+ result.set(this._data.subarray(start, end))+ return result}readVarFloat(): number {- let index = this._index;- let data = this._data;- let length = data.length;+ let index = this._index+ let data = this._data+ let length = data.length// Optimization: use a single byte to store zeroif (index + 1 > length) {- throw new Error('Index out of bounds');+ throw new Error('Index out of bounds')}- let first = data[index];+ let first = data[index]if (first === 0) {- this._index = index + 1;- return 0;+ this._index = index + 1+ return 0}// Endian-independent 32-bit readif (index + 4 > length) {- throw new Error('Index out of bounds');+ throw new Error('Index out of bounds')}- let bits = first | (data[index + 1] << 8) | (data[index + 2] << 16) | (data[index + 3] << 24);- this._index = index + 4;+ let bits = first | (data[index + 1] << 8) | (data[index + 2] << 16) | (data[index + 3] << 24)+ this._index = index + 4// Move the exponent back into place- bits = (bits << 23) | (bits >>> 9);+ bits = (bits << 23) | (bits >>> 9)// Reinterpret as a floating-point number- int32[0] = bits;- return float32[0];+ int32[0] = bits+ return float32[0]}readVarUint(): number {- let value = 0;- let shift = 0;+ let value = 0+ let shift = 0do {- var byte = this.readByte();- value |= (byte & 127) << shift;- shift += 7;- } while (byte & 128 && shift < 35);- return value >>> 0;+ var byte = this.readByte()+ value |= (byte & 127) << shift+ shift += 7+ } while (byte & 128 && shift < 35)+ return value >>> 0}readVarInt(): number {- let value = this.readVarUint() | 0;- return value & 1 ? ~(value >>> 1) : value >>> 1;+ let value = this.readVarUint() | 0+ return value & 1 ? ~(value >>> 1) : value >>> 1}readVarUint64(): bigint {- let value = BigInt(0);- let shift = BigInt(0);- let seven = BigInt(7);- let byte: number;+ let value = BigInt(0)+ let shift = BigInt(0)+ let seven = BigInt(7)+ let byte: numberwhile ((byte = this.readByte()) & 128 && shift < 56) {- value |= BigInt(byte & 127) << shift;- shift += seven;+ value |= BigInt(byte & 127) << shift+ shift += seven}- value |= BigInt(byte) << shift;- return value;+ value |= BigInt(byte) << shift+ return value}readVarInt64(): bigint {- let value = this.readVarUint64();- let one = BigInt(1);- let sign = value & one;- value >>= one;- return sign ? ~value : value;+ let value = this.readVarUint64()+ let one = BigInt(1)+ let sign = value & one+ value >>= one+ return sign ? ~value : value}readString(): string {- let result = '';+ let result = ''while (true) {- let codePoint;+ let codePoint// Decode UTF-8- let a = this.readByte();- if (a < 0xC0) {- codePoint = a;+ let a = this.readByte()+ if (a < 0xc0) {+ codePoint = a} else {- let b = this.readByte();- if (a < 0xE0) {- codePoint = ((a & 0x1F) << 6) | (b & 0x3F);+ let b = this.readByte()+ if (a < 0xe0) {+ codePoint = ((a & 0x1f) << 6) | (b & 0x3f)} else {- let c = this.readByte();- if (a < 0xF0) {- codePoint = ((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F);+ let c = this.readByte()+ if (a < 0xf0) {+ codePoint = ((a & 0x0f) << 12) | ((b & 0x3f) << 6) | (c & 0x3f)} else {- let d = this.readByte();- codePoint = ((a & 0x07) << 18) | ((b & 0x3F) << 12) | ((c & 0x3F) << 6) | (d & 0x3F);+ let d = this.readByte()+ codePoint = ((a & 0x07) << 18) | ((b & 0x3f) << 12) | ((c & 0x3f) << 6) | (d & 0x3f)}}}// Strings are null-terminatedif (codePoint === 0) {- break;+ break}// Encode UTF-16if (codePoint < 0x10000) {- result += String.fromCharCode(codePoint);+ result += String.fromCharCode(codePoint)} else {- codePoint -= 0x10000;- result += String.fromCharCode((codePoint >> 10) + 0xD800, (codePoint & ((1 << 10) - 1)) + 0xDC00);+ codePoint -= 0x10000+ result += String.fromCharCode(+ (codePoint >> 10) + 0xd800,+ (codePoint & ((1 << 10) - 1)) + 0xdc00+ )}}- return result;+ return result}private _growBy(amount: number): void {if (this.length + amount > this._data.length) {- let data = new Uint8Array(this.length + amount << 1);- data.set(this._data);- this._data = data;+ let data = new Uint8Array((this.length + amount) << 1)+ data.set(this._data)+ this._data = data}- this.length += amount;+ this.length += amount}writeByte(value: number): void {- let index = this.length;- this._growBy(1);- this._data[index] = value;+ let index = this.length+ this._growBy(1)+ this._data[index] = value}writeByteArray(value: Uint8Array): void {- this.writeVarUint(value.length);- let index = this.length;- this._growBy(value.length);- this._data.set(value, index);+ this.writeVarUint(value.length)+ let index = this.length+ this._growBy(value.length)+ this._data.set(value, index)}writeVarFloat(value: number): void {- let index = this.length;+ let index = this.length// Reinterpret as an integer- float32[0] = value;- let bits = int32[0];+ float32[0] = value+ let bits = int32[0]// Move the exponent to the first 8 bits- bits = (bits >>> 23) | (bits << 9);+ bits = (bits >>> 23) | (bits << 9)// Optimization: use a single byte to store zero and denormals (check for an exponent of 0)if ((bits & 255) === 0) {- this.writeByte(0);- return;+ this.writeByte(0)+ return}// Endian-independent 32-bit write- this._growBy(4);- let data = this._data;- data[index] = bits;- data[index + 1] = bits >> 8;- data[index + 2] = bits >> 16;- data[index + 3] = bits >> 24;+ this._growBy(4)+ let data = this._data+ data[index] = bits+ data[index + 1] = bits >> 8+ data[index + 2] = bits >> 16+ data[index + 3] = bits >> 24}writeVarUint(value: number): void {- if (value < 0 || value > 0xFFFF_FFFF) throw new Error('Outside uint range: ' + value);+ if (value < 0 || value > 0xffff_ffff) throw new Error('Outside uint range: ' + value)do {- let byte = value & 127;- value >>>= 7;- this.writeByte(value ? byte | 128 : byte);- } while (value);+ let byte = value & 127+ value >>>= 7+ this.writeByte(value ? byte | 128 : byte)+ } while (value)}writeVarInt(value: number): void {- if (value < -0x8000_0000 || value > 0x7FFF_FFFF) throw new Error('Outside int range: ' + value);- this.writeVarUint(((value << 1) ^ (value >> 31)) >>> 0);+ if (value < -0x8000_0000 || value > 0x7fff_ffff) throw new Error('Outside int range: ' + value)+ this.writeVarUint(((value << 1) ^ (value >> 31)) >>> 0)}writeVarUint64(value: bigint | string): void {- if (typeof value === 'string') value = BigInt(value);- else if (typeof value !== 'bigint') throw new Error('Expected bigint but got ' + typeof value + ': ' + value);- if (value < 0 || value > BigInt('0xFFFFFFFFFFFFFFFF')) throw new Error('Outside uint64 range: ' + value);- let mask = BigInt(127);- let seven = BigInt(7);+ if (typeof value === 'string') value = BigInt(value)+ else if (typeof value !== 'bigint')+ throw new Error('Expected bigint but got ' + typeof value + ': ' + value)+ if (value < 0 || value > BigInt('0xFFFFFFFFFFFFFFFF'))+ throw new Error('Outside uint64 range: ' + value)+ let mask = BigInt(127)+ let seven = BigInt(7)for (let i = 0; value > mask && i < 8; i++) {- this.writeByte(Number(value & mask) | 128);- value >>= seven;+ this.writeByte(Number(value & mask) | 128)+ value >>= seven}- this.writeByte(Number(value));+ this.writeByte(Number(value))}writeVarInt64(value: bigint | string): void {- if (typeof value === 'string') value = BigInt(value);- else if (typeof value !== 'bigint') throw new Error('Expected bigint but got ' + typeof value + ': ' + value);- if (value < -BigInt('0x8000000000000000') || value > BigInt('0x7FFFFFFFFFFFFFFF')) throw new Error('Outside int64 range: ' + value);- let one = BigInt(1);- this.writeVarUint64(value < 0 ? ~(value << one) : value << one);+ if (typeof value === 'string') value = BigInt(value)+ else if (typeof value !== 'bigint')+ throw new Error('Expected bigint but got ' + typeof value + ': ' + value)+ if (value < -BigInt('0x8000000000000000') || value > BigInt('0x7FFFFFFFFFFFFFFF'))+ throw new Error('Outside int64 range: ' + value)+ let one = BigInt(1)+ this.writeVarUint64(value < 0 ? ~(value << one) : value << one)}writeString(value: string): void {- let codePoint;+ let codePointfor (let i = 0; i < value.length; i++) {// Decode UTF-16- let a = value.charCodeAt(i);- if (i + 1 === value.length || a < 0xD800 || a >= 0xDC00) {- codePoint = a;+ let a = value.charCodeAt(i)+ if (i + 1 === value.length || a < 0xd800 || a >= 0xdc00) {+ codePoint = a} else {- let b = value.charCodeAt(++i);- codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00);+ let b = value.charCodeAt(++i)+ codePoint = (a << 10) + b + (0x10000 - (0xd800 << 10) - 0xdc00)}// Strings are null-terminatedif (codePoint === 0) {- throw new Error('Cannot encode a string containing the null character');+ throw new Error('Cannot encode a string containing the null character')}// Encode UTF-8if (codePoint < 0x80) {- this.writeByte(codePoint);+ this.writeByte(codePoint)} else {if (codePoint < 0x800) {- this.writeByte(((codePoint >> 6) & 0x1F) | 0xC0);+ this.writeByte(((codePoint >> 6) & 0x1f) | 0xc0)} else {if (codePoint < 0x10000) {- this.writeByte(((codePoint >> 12) & 0x0F) | 0xE0);+ this.writeByte(((codePoint >> 12) & 0x0f) | 0xe0)} else {- this.writeByte(((codePoint >> 18) & 0x07) | 0xF0);- this.writeByte(((codePoint >> 12) & 0x3F) | 0x80);+ this.writeByte(((codePoint >> 18) & 0x07) | 0xf0)+ this.writeByte(((codePoint >> 12) & 0x3f) | 0x80)}- this.writeByte(((codePoint >> 6) & 0x3F) | 0x80);+ this.writeByte(((codePoint >> 6) & 0x3f) | 0x80)}- this.writeByte((codePoint & 0x3F) | 0x80);+ this.writeByte((codePoint & 0x3f) | 0x80)}}// Strings are null-terminated- this.writeByte(0);+ this.writeByte(0)}}diff --git a/src/kiwi/kiwi-schema/binary.ts b/src/kiwi/kiwi-schema/binary.tsindex 8260c7707..9e6af4691 100644--- a/src/kiwi/kiwi-schema/binary.ts+++ b/src/kiwi/kiwi-schema/binary.ts@@ -1,36 +1,36 @@-import { ByteBuffer } from "./bb";-import { Schema, Field, Definition, DefinitionKind } from "./schema";+import { ByteBuffer } from './bb'+import { Schema, Field, Definition, DefinitionKind } from './schema'-let types: (string | null)[] = ['bool', 'byte', 'int', 'uint', 'float', 'string', 'int64', 'uint64'];-let kinds: DefinitionKind[] = ['ENUM', 'STRUCT', 'MESSAGE'];+let types: (string | null)[] = ['bool', 'byte', 'int', 'uint', 'float', 'string', 'int64', 'uint64']+let kinds: DefinitionKind[] = ['ENUM', 'STRUCT', 'MESSAGE']export function decodeBinarySchema(buffer: Uint8Array | ByteBuffer): Schema {- let bb = buffer instanceof ByteBuffer ? buffer : new ByteBuffer(buffer);- let definitionCount = bb.readVarUint();- let definitions: Definition[] = [];+ let bb = buffer instanceof ByteBuffer ? buffer : new ByteBuffer(buffer)+ let definitionCount = bb.readVarUint()+ let definitions: Definition[] = []// Read in the schemafor (let i = 0; i < definitionCount; i++) {- let definitionName = bb.readString();- let kind = bb.readByte();- let fieldCount = bb.readVarUint();- let fields: Field[] = [];+ let definitionName = bb.readString()+ let kind = bb.readByte()+ let fieldCount = bb.readVarUint()+ let fields: Field[] = []for (let j = 0; j < fieldCount; j++) {- let fieldName = bb.readString();- let type = bb.readVarInt();- let isArray = !!(bb.readByte() & 1);- let value = bb.readVarUint();+ let fieldName = bb.readString()+ let type = bb.readVarInt()+ let isArray = !!(bb.readByte() & 1)+ let value = bb.readVarUint()fields.push({name: fieldName,line: 0,column: 0,- type: kinds[kind] === 'ENUM' ? null : type as any,+ type: kinds[kind] === 'ENUM' ? null : (type as any),isArray: isArray,isDeprecated: false,- value: value,- });+ value: value+ })}definitions.push({@@ -38,67 +38,65 @@ export function decodeBinarySchema(buffer: Uint8Array | ByteBuffer): Schema {line: 0,column: 0,kind: kinds[kind],- fields: fields,- });+ fields: fields+ })}// Bind type names afterwardsfor (let i = 0; i < definitionCount; i++) {- let fields = definitions[i].fields;+ let fields = definitions[i].fieldsfor (let j = 0; j < fields.length; j++) {- let field = fields[j];- let type = field.type as any as number | null;+ let field = fields[j]+ let type = field.type as any as number | nullif (type !== null && type < 0) {if (~type >= types.length) {- throw new Error('Invalid type ' + type);+ throw new Error('Invalid type ' + type)}- field.type = types[~type];- }-- else {+ field.type = types[~type]+ } else {if (type !== null && type >= definitions.length) {- throw new Error('Invalid type ' + type);+ throw new Error('Invalid type ' + type)}- field.type = type === null ? null : definitions[type].name;+ field.type = type === null ? null : definitions[type].name}}}return {package: null,- definitions: definitions,- };+ definitions: definitions+ }}export function encodeBinarySchema(schema: Schema): Uint8Array {- let bb = new ByteBuffer();- let definitions = schema.definitions;- let definitionIndex: { [name: string]: number } = {};+ let bb = new ByteBuffer()+ let definitions = schema.definitions+ let definitionIndex: { [name: string]: number } = {}- bb.writeVarUint(definitions.length);+ bb.writeVarUint(definitions.length)for (let i = 0; i < definitions.length; i++) {- definitionIndex[definitions[i].name] = i;+ definitionIndex[definitions[i].name] = i}for (let i = 0; i < definitions.length; i++) {- let definition = definitions[i];+ let definition = definitions[i]- bb.writeString(definition.name);- bb.writeByte(kinds.indexOf(definition.kind));- bb.writeVarUint(definition.fields.length);+ bb.writeString(definition.name)+ bb.writeByte(kinds.indexOf(definition.kind))+ bb.writeVarUint(definition.fields.length)for (let j = 0; j < definition.fields.length; j++) {- let field = definition.fields[j];- let type = types.indexOf(field.type);+ let field = definition.fields[j]+ let type = types.indexOf(field.type)- bb.writeString(field.name);- bb.writeVarInt(type === -1 ? definitionIndex[field.type!] : ~type);- bb.writeByte(field.isArray ? 1 : 0);- bb.writeVarUint(field.value);+ bb.writeString(field.name)+ bb.writeVarInt(type === -1 ? definitionIndex[field.type!] : ~type)+ bb.writeByte(field.isArray ? 1 : 0)+ bb.writeVarUint(field.value)}}- return bb.toUint8Array();+ return bb.toUint8Array()}diff --git a/src/kiwi/kiwi-schema/js.ts b/src/kiwi/kiwi-schema/js.tsindex 5d30de6cd..63649e7e8 100644--- a/src/kiwi/kiwi-schema/js.ts+++ b/src/kiwi/kiwi-schema/js.ts@@ -1,311 +1,339 @@-import { Schema, Definition } from "./schema";-import { ByteBuffer } from "./bb";-import { error, quote } from "./util";--function compileDecode(definition: Definition, definitions: { [name: string]: Definition }): string {- let lines: string[] = [];- let indent = ' ';-- lines.push('function (bb) {');- lines.push(' var result = {};');- lines.push(' if (!(bb instanceof this.ByteBuffer)) {');- lines.push(' bb = new this.ByteBuffer(bb);');- lines.push(' }');- lines.push('');+import { ByteBuffer } from './bb'+import { Schema, Definition } from './schema'+import { error, quote } from './util'++function compileDecode(+ definition: Definition,+ definitions: { [name: string]: Definition }+): string {+ let lines: string[] = []+ let indent = ' '++ lines.push('function (bb) {')+ lines.push(' var result = {};')+ lines.push(' if (!(bb instanceof this.ByteBuffer)) {')+ lines.push(' bb = new this.ByteBuffer(bb);')+ lines.push(' }')+ lines.push('')if (definition.kind === 'MESSAGE') {- lines.push(' while (true) {');- lines.push(' switch (bb.readVarUint()) {');- lines.push(' case 0:');- lines.push(' return result;');- lines.push('');- indent = ' ';+ lines.push(' while (true) {')+ lines.push(' switch (bb.readVarUint()) {')+ lines.push(' case 0:')+ lines.push(' return result;')+ lines.push('')+ indent = ' '}for (let i = 0; i < definition.fields.length; i++) {- let field = definition.fields[i];- let code: string;+ let field = definition.fields[i]+ let code: stringswitch (field.type) {case 'bool': {- code = '!!bb.readByte()';- break;+ code = '!!bb.readByte()'+ break}case 'byte': {- code = 'bb.readByte()'; // only used if not array- break;+ code = 'bb.readByte()' // only used if not array+ break}case 'int': {- code = 'bb.readVarInt()';- break;+ code = 'bb.readVarInt()'+ break}case 'uint': {- code = 'bb.readVarUint()';- break;+ code = 'bb.readVarUint()'+ break}case 'float': {- code = 'bb.readVarFloat()';- break;+ code = 'bb.readVarFloat()'+ break}case 'string': {- code = 'bb.readString()';- break;+ code = 'bb.readString()'+ break}case 'int64': {- code = 'bb.readVarInt64()';- break;+ code = 'bb.readVarInt64()'+ break}case 'uint64': {- code = 'bb.readVarUint64()';- break;+ code = 'bb.readVarUint64()'+ break}default: {- let type = definitions[field.type!];+ let type = definitions[field.type!]if (!type) {- error('Invalid type ' + quote(field.type!) + ' for field ' + quote(field.name), field.line, field.column);+ error(+ 'Invalid type ' + quote(field.type!) + ' for field ' + quote(field.name),+ field.line,+ field.column+ )} else if (type.kind === 'ENUM') {- code = 'this[' + quote(type.name) + '][bb.readVarUint()]';+ code = 'this[' + quote(type.name) + '][bb.readVarUint()]'} else {- code = 'this[' + quote('decode' + type.name) + '](bb)';+ code = 'this[' + quote('decode' + type.name) + '](bb)'}}}if (definition.kind === 'MESSAGE') {- lines.push(' case ' + field.value + ':');+ lines.push(' case ' + field.value + ':')}if (field.isArray) {if (field.isDeprecated) {if (field.type === 'byte') {- lines.push(indent + 'bb.readByteArray();');+ lines.push(indent + 'bb.readByteArray();')} else {- lines.push(indent + 'var length = bb.readVarUint();');- lines.push(indent + 'while (length-- > 0) ' + code + ';');+ lines.push(indent + 'var length = bb.readVarUint();')+ lines.push(indent + 'while (length-- > 0) ' + code + ';')}} else {if (field.type === 'byte') {- lines.push(indent + 'result[' + quote(field.name) + '] = bb.readByteArray();');+ lines.push(indent + 'result[' + quote(field.name) + '] = bb.readByteArray();')} else {- lines.push(indent + 'var length = bb.readVarUint();');- lines.push(indent + 'var values = result[' + quote(field.name) + '] = Array(length);');- lines.push(indent + 'for (var i = 0; i < length; i++) values[i] = ' + code + ';');+ lines.push(indent + 'var length = bb.readVarUint();')+ lines.push(indent + 'var values = result[' + quote(field.name) + '] = Array(length);')+ lines.push(indent + 'for (var i = 0; i < length; i++) values[i] = ' + code + ';')}}- }-- else {+ } else {if (field.isDeprecated) {- lines.push(indent + code + ';');+ lines.push(indent + code + ';')} else {- lines.push(indent + 'result[' + quote(field.name) + '] = ' + code + ';');+ lines.push(indent + 'result[' + quote(field.name) + '] = ' + code + ';')}}if (definition.kind === 'MESSAGE') {- lines.push(' break;');- lines.push('');+ lines.push(' break;')+ lines.push('')}}if (definition.kind === 'MESSAGE') {- lines.push(' default:');- lines.push(' throw new Error("Attempted to parse invalid message");');- lines.push(' }');- lines.push(' }');- }-- else {- lines.push(' return result;');+ lines.push(' default:')+ lines.push(' throw new Error("Attempted to parse invalid message");')+ lines.push(' }')+ lines.push(' }')+ } else {+ lines.push(' return result;')}- lines.push('}');+ lines.push('}')- return lines.join('\n');+ return lines.join('\n')}-function compileEncode(definition: Definition, definitions: { [name: string]: Definition }): string {- let lines: string[] = [];+function compileEncode(+ definition: Definition,+ definitions: { [name: string]: Definition }+): string {+ let lines: string[] = []- lines.push('function (message, bb) {');- lines.push(' var isTopLevel = !bb;');- lines.push(' if (isTopLevel) bb = new this.ByteBuffer();');+ lines.push('function (message, bb) {')+ lines.push(' var isTopLevel = !bb;')+ lines.push(' if (isTopLevel) bb = new this.ByteBuffer();')for (let j = 0; j < definition.fields.length; j++) {- let field = definition.fields[j];- let code: string;+ let field = definition.fields[j]+ let code: stringif (field.isDeprecated) {- continue;+ continue}switch (field.type) {case 'bool': {- code = 'bb.writeByte(value);';- break;+ code = 'bb.writeByte(value);'+ break}case 'byte': {- code = 'bb.writeByte(value);'; // only used if not array- break;+ code = 'bb.writeByte(value);' // only used if not array+ break}case 'int': {- code = 'bb.writeVarInt(value);';- break;+ code = 'bb.writeVarInt(value);'+ break}case 'uint': {- code = 'bb.writeVarUint(value);';- break;+ code = 'bb.writeVarUint(value);'+ break}case 'float': {- code = 'bb.writeVarFloat(value);';- break;+ code = 'bb.writeVarFloat(value);'+ break}case 'string': {- code = 'bb.writeString(value);';- break;+ code = 'bb.writeString(value);'+ break}case 'int64': {- code = 'bb.writeVarInt64(value);';- break;+ code = 'bb.writeVarInt64(value);'+ break}case 'uint64': {- code = 'bb.writeVarUint64(value);';- break;+ code = 'bb.writeVarUint64(value);'+ break}default: {- let type = definitions[field.type!];+ let type = definitions[field.type!]if (!type) {- throw new Error('Invalid type ' + quote(field.type!) + ' for field ' + quote(field.name));+ throw new Error('Invalid type ' + quote(field.type!) + ' for field ' + quote(field.name))} else if (type.kind === 'ENUM') {code =- 'var encoded = this[' + quote(type.name) + '][value]; ' +- 'if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' + quote(' for enum ' + quote(type.name)) + '); ' +- 'bb.writeVarUint(encoded);';+ 'var encoded = this[' ++ quote(type.name) ++ '][value]; ' ++ 'if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' ++ quote(' for enum ' + quote(type.name)) ++ '); ' ++ 'bb.writeVarUint(encoded);'} else {- code = 'this[' + quote('encode' + type.name) + '](value, bb);';+ code = 'this[' + quote('encode' + type.name) + '](value, bb);'}}}- lines.push('');- lines.push(' var value = message[' + quote(field.name) + '];');- lines.push(' if (value != null) {'); // Comparing with null using "!=" also checks for undefined+ lines.push('')+ lines.push(' var value = message[' + quote(field.name) + '];')+ lines.push(' if (value != null) {') // Comparing with null using "!=" also checks for undefinedif (definition.kind === 'MESSAGE') {- lines.push(' bb.writeVarUint(' + field.value + ');');+ lines.push(' bb.writeVarUint(' + field.value + ');')}if (field.isArray) {if (field.type === 'byte') {- lines.push(' bb.writeByteArray(value);');+ lines.push(' bb.writeByteArray(value);')} else {- lines.push(' var values = value, n = values.length;');- lines.push(' bb.writeVarUint(n);');- lines.push(' for (var i = 0; i < n; i++) {');- lines.push(' value = values[i];');- lines.push(' ' + code);- lines.push(' }');+ lines.push(' var values = value, n = values.length;')+ lines.push(' bb.writeVarUint(n);')+ lines.push(' for (var i = 0; i < n; i++) {')+ lines.push(' value = values[i];')+ lines.push(' ' + code)+ lines.push(' }')}- }-- else {- lines.push(' ' + code);+ } else {+ lines.push(' ' + code)}if (definition.kind === 'STRUCT') {- lines.push(' } else {');- lines.push(' throw new Error(' + quote('Missing required field ' + quote(field.name)) + ');');+ lines.push(' } else {')+ lines.push(+ ' throw new Error(' + quote('Missing required field ' + quote(field.name)) + ');'+ )}- lines.push(' }');+ lines.push(' }')}// A field id of zero is reserved to indicate the end of the messageif (definition.kind === 'MESSAGE') {- lines.push(' bb.writeVarUint(0);');+ lines.push(' bb.writeVarUint(0);')}- lines.push('');- lines.push(' if (isTopLevel) return bb.toUint8Array();');- lines.push('}');+ lines.push('')+ lines.push(' if (isTopLevel) return bb.toUint8Array();')+ lines.push('}')- return lines.join('\n');+ return lines.join('\n')}export function compileSchemaJS(schema: Schema): string {- let definitions: { [name: string]: Definition } = {};- let name = schema.package;- let js: string[] = [];+ let definitions: { [name: string]: Definition } = {}+ let name = schema.package+ let js: string[] = []if (name !== null) {- js.push('var ' + name + ' = exports || ' + name + ' || {}, exports;');+ js.push('var ' + name + ' = exports || ' + name + ' || {}, exports;')} else {- js.push('var exports = exports || {};');- name = 'exports';+ js.push('var exports = exports || {};')+ name = 'exports'}- js.push(name + '.ByteBuffer = ' + name + '.ByteBuffer || require("kiwi-schema").ByteBuffer;');+ js.push(name + '.ByteBuffer = ' + name + '.ByteBuffer || require("kiwi-schema").ByteBuffer;')for (let i = 0; i < schema.definitions.length; i++) {- let definition = schema.definitions[i];- definitions[definition.name] = definition;+ let definition = schema.definitions[i]+ definitions[definition.name] = definition}for (let i = 0; i < schema.definitions.length; i++) {- let definition = schema.definitions[i];+ let definition = schema.definitions[i]switch (definition.kind) {case 'ENUM': {- let value: any = {};+ let value: any = {}for (let j = 0; j < definition.fields.length; j++) {- let field = definition.fields[j];- value[field.name] = field.value;- value[field.value] = field.name;+ let field = definition.fields[j]+ value[field.name] = field.value+ value[field.value] = field.name}- js.push(name + '[' + quote(definition.name) + '] = ' + JSON.stringify(value, null, 2) + ';');- break;+ js.push(name + '[' + quote(definition.name) + '] = ' + JSON.stringify(value, null, 2) + ';')+ break}case 'STRUCT':case 'MESSAGE': {- js.push('');- js.push(name + '[' + quote('decode' + definition.name) + '] = ' + compileDecode(definition, definitions) + ';');- js.push('');- js.push(name + '[' + quote('encode' + definition.name) + '] = ' + compileEncode(definition, definitions) + ';');- break;+ js.push('')+ js.push(+ name ++ '[' ++ quote('decode' + definition.name) ++ '] = ' ++ compileDecode(definition, definitions) ++ ';'+ )+ js.push('')+ js.push(+ name ++ '[' ++ quote('encode' + definition.name) ++ '] = ' ++ compileEncode(definition, definitions) ++ ';'+ )+ break}default: {- error('Invalid definition kind ' + quote(definition.kind), definition.line, definition.column);- break;+ error(+ 'Invalid definition kind ' + quote(definition.kind),+ definition.line,+ definition.column+ )+ break}}}- js.push('');- return js.join('\n');+ js.push('')+ return js.join('\n')}export function compileSchema(schema: Schema): any {let result = {- ByteBuffer: ByteBuffer,- };- new Function('exports', compileSchemaJS(schema))(result);- return result;+ ByteBuffer: ByteBuffer+ }+ new Function('exports', compileSchemaJS(schema))(result)+ return result}diff --git a/src/kiwi/kiwi-schema/parser.ts b/src/kiwi/kiwi-schema/parser.tsindex 498a79814..c2a0a80ff 100644--- a/src/kiwi/kiwi-schema/parser.ts+++ b/src/kiwi/kiwi-schema/parser.ts@@ -1,38 +1,26 @@-import { Schema, Definition, Field, DefinitionKind } from "./schema";-import { error, quote } from "./util";--export let nativeTypes = [- 'bool',- 'byte',- 'float',- 'int',- 'int64',- 'string',- 'uint',- 'uint64',-];+import { Schema, Definition, Field, DefinitionKind } from './schema'+import { error, quote } from './util'++export let nativeTypes = ['bool', 'byte', 'float', 'int', 'int64', 'string', 'uint', 'uint64']// These are special names on the object returned by compileSchema()-export let reservedNames = [- 'ByteBuffer',- 'package',-];--let regex = /((?:-|\b)\d+\b|[=;{}]|\[\]|\[deprecated\]|\b[A-Za-z_][A-Za-z0-9_]*\b|\/\/.*|\s+)/g;-let identifier = /^[A-Za-z_][A-Za-z0-9_]*$/;-let whitespace = /^\/\/.*|\s+$/;-let equals = /^=$/;-let endOfFile = /^$/;-let semicolon = /^;$/;-let integer = /^-?\d+$/;-let leftBrace = /^\{$/;-let rightBrace = /^\}$/;-let arrayToken = /^\[\]$/;-let enumKeyword = /^enum$/;-let structKeyword = /^struct$/;-let messageKeyword = /^message$/;-let packageKeyword = /^package$/;-let deprecatedToken = /^\[deprecated\]$/;+export let reservedNames = ['ByteBuffer', 'package']++let regex = /((?:-|\b)\d+\b|[=;{}]|\[\]|\[deprecated\]|\b[A-Za-z_][A-Za-z0-9_]*\b|\/\/.*|\s+)/g+let identifier = /^[A-Za-z_][A-Za-z0-9_]*$/+let whitespace = /^\/\/.*|\s+$/+let equals = /^=$/+let endOfFile = /^$/+let semicolon = /^;$/+let integer = /^-?\d+$/+let leftBrace = /^\{$/+let rightBrace = /^\}$/+let arrayToken = /^\[\]$/+let enumKeyword = /^enum$/+let structKeyword = /^struct$/+let messageKeyword = /^message$/+let packageKeyword = /^package$/+let deprecatedToken = /^\[deprecated\]$/interface Token {text: string@@ -41,13 +29,13 @@ interface Token {}function tokenize(text: string): Token[] {- let parts = text.split(regex);- let tokens = [];- let column = 0;- let line = 0;+ let parts = text.split(regex)+ let tokens = []+ let column = 0+ let line = 0for (let i = 0; i < parts.length; i++) {- let part = parts[i];+ let part = parts[i]// Keep non-whitespace tokensif (i & 1) {@@ -55,120 +43,120 @@ function tokenize(text: string): Token[] {tokens.push({text: part,line: line + 1,- column: column + 1,- });+ column: column + 1+ })}}// Detect syntax errorselse if (part !== '') {- error('Syntax error ' + quote(part), line + 1, column + 1);+ error('Syntax error ' + quote(part), line + 1, column + 1)}// Keep track of the line and column counts- let lines = part.split('\n');- if (lines.length > 1) column = 0;- line += lines.length - 1;- column += lines[lines.length - 1].length;+ let lines = part.split('\n')+ if (lines.length > 1) column = 0+ line += lines.length - 1+ column += lines[lines.length - 1].length}// End-of-file tokentokens.push({text: '',line: line,- column: column,- });+ column: column+ })- return tokens;+ return tokens}function parse(tokens: Token[]): Schema {function current(): Token {- return tokens[index];+ return tokens[index]}function eat(test: RegExp): boolean {if (test.test(current().text)) {- index++;- return true;+ index+++ return true}- return false;+ return false}function expect(test: RegExp, expected: string): void {if (!eat(test)) {- let token = current();- error('Expected ' + expected + ' but found ' + quote(token.text), token.line, token.column);+ let token = current()+ error('Expected ' + expected + ' but found ' + quote(token.text), token.line, token.column)}}function unexpectedToken(): never {- let token = current();- error('Unexpected token ' + quote(token.text), token.line, token.column);+ let token = current()+ error('Unexpected token ' + quote(token.text), token.line, token.column)}- let definitions: Definition[] = [];- let packageText = null;- let index = 0;+ let definitions: Definition[] = []+ let packageText = null+ let index = 0if (eat(packageKeyword)) {- packageText = current().text;- expect(identifier, 'identifier');- expect(semicolon, '";"');+ packageText = current().text+ expect(identifier, 'identifier')+ expect(semicolon, '";"')}while (index < tokens.length && !eat(endOfFile)) {- let fields: Field[] = [];- let kind: DefinitionKind;+ let fields: Field[] = []+ let kind: DefinitionKind- if (eat(enumKeyword)) kind = 'ENUM';- else if (eat(structKeyword)) kind = 'STRUCT';- else if (eat(messageKeyword)) kind = 'MESSAGE';- else unexpectedToken();+ if (eat(enumKeyword)) kind = 'ENUM'+ else if (eat(structKeyword)) kind = 'STRUCT'+ else if (eat(messageKeyword)) kind = 'MESSAGE'+ else unexpectedToken()// All definitions start off the same- let name = current();- expect(identifier, 'identifier');- expect(leftBrace, '"{"');+ let name = current()+ expect(identifier, 'identifier')+ expect(leftBrace, '"{"')// Parse fieldswhile (!eat(rightBrace)) {- let type: string | null = null;- let isArray = false;- let isDeprecated = false;+ let type: string | null = null+ let isArray = false+ let isDeprecated = false// Enums don't have typesif (kind !== 'ENUM') {- type = current().text;- expect(identifier, 'identifier');- isArray = eat(arrayToken);+ type = current().text+ expect(identifier, 'identifier')+ isArray = eat(arrayToken)}- let field = current();- expect(identifier, 'identifier');+ let field = current()+ expect(identifier, 'identifier')// Structs don't have explicit values- let value: Token | null = null;+ let value: Token | null = nullif (kind !== 'STRUCT') {- expect(equals, '"="');- value = current();- expect(integer, 'integer');+ expect(equals, '"="')+ value = current()+ expect(integer, 'integer')if ((+value.text | 0) + '' !== value.text) {- error('Invalid integer ' + quote(value.text), value.line, value.column);+ error('Invalid integer ' + quote(value.text), value.line, value.column)}}- let deprecated = current();+ let deprecated = current()if (eat(deprecatedToken)) {if (kind !== 'MESSAGE') {- error('Cannot deprecate this field', deprecated.line, deprecated.column);+ error('Cannot deprecate this field', deprecated.line, deprecated.column)}- isDeprecated = true;+ isDeprecated = true}- expect(semicolon, '";"');+ expect(semicolon, '";"')fields.push({name: field.text,@@ -177,8 +165,8 @@ function parse(tokens: Token[]): Schema {type: type,isArray: isArray,isDeprecated: isDeprecated,- value: value !== null ? +value.text | 0 : fields.length + 1,- });+ value: value !== null ? +value.text | 0 : fields.length + 1+ })}definitions.push({@@ -186,94 +174,114 @@ function parse(tokens: Token[]): Schema {line: name.line,column: name.column,kind: kind,- fields: fields,- });+ fields: fields+ })}return {package: packageText,- definitions: definitions,- };+ definitions: definitions+ }}function verify(root: Schema): void {- let definedTypes = nativeTypes.slice();- let definitions: { [name: string]: Definition } = {};+ let definedTypes = nativeTypes.slice()+ let definitions: { [name: string]: Definition } = {}// Define definitionsfor (let i = 0; i < root.definitions.length; i++) {- let definition = root.definitions[i];+ let definition = root.definitions[i]if (definedTypes.indexOf(definition.name) !== -1) {- error('The type ' + quote(definition.name) + ' is defined twice', definition.line, definition.column);+ error(+ 'The type ' + quote(definition.name) + ' is defined twice',+ definition.line,+ definition.column+ )}if (reservedNames.indexOf(definition.name) !== -1) {- error('The type name ' + quote(definition.name) + ' is reserved', definition.line, definition.column);+ error(+ 'The type name ' + quote(definition.name) + ' is reserved',+ definition.line,+ definition.column+ )}- definedTypes.push(definition.name);- definitions[definition.name] = definition;+ definedTypes.push(definition.name)+ definitions[definition.name] = definition}// Check fieldsfor (let i = 0; i < root.definitions.length; i++) {- let definition = root.definitions[i];- let fields = definition.fields;+ let definition = root.definitions[i]+ let fields = definition.fieldsif (definition.kind === 'ENUM' || fields.length === 0) {- continue;+ continue}// Check typesfor (let j = 0; j < fields.length; j++) {- let field = fields[j];+ let field = fields[j]if (definedTypes.indexOf(field.type!) === -1) {- error('The type ' + quote(field.type!) + ' is not defined for field ' + quote(field.name), field.line, field.column);+ error(+ 'The type ' + quote(field.type!) + ' is not defined for field ' + quote(field.name),+ field.line,+ field.column+ )}}// Check values- let values: number[] = [];+ let values: number[] = []for (let j = 0; j < fields.length; j++) {- let field = fields[j];+ let field = fields[j]if (values.indexOf(field.value) !== -1) {- error('The id for field ' + quote(field.name) + ' is used twice', field.line, field.column);+ error('The id for field ' + quote(field.name) + ' is used twice', field.line, field.column)}if (field.value <= 0) {- error('The id for field ' + quote(field.name) + ' must be positive', field.line, field.column);+ error(+ 'The id for field ' + quote(field.name) + ' must be positive',+ field.line,+ field.column+ )}// Figma schema uses sparse field IDs (up to 435), so skip sequential check- values.push(field.value);+ values.push(field.value)}}// Check that structs don't contain themselves- let state: { [name: string]: number } = {};+ let state: { [name: string]: number } = {}let check = (name: string): boolean => {- let definition = definitions[name];+ let definition = definitions[name]if (definition && definition.kind === 'STRUCT') {if (state[name] === 1) {- error('Recursive nesting of ' + quote(name) + ' is not allowed', definition.line, definition.column);+ error(+ 'Recursive nesting of ' + quote(name) + ' is not allowed',+ definition.line,+ definition.column+ )}if (state[name] !== 2 && definition) {- state[name] = 1;- let fields = definition.fields;+ state[name] = 1+ let fields = definition.fieldsfor (let i = 0; i < fields.length; i++) {- let field = fields[i];+ let field = fields[i]if (!field.isArray) {- check(field.type!);+ check(field.type!)}}- state[name] = 2;+ state[name] = 2}}- return true;- };+ return true+ }for (let i = 0; i < root.definitions.length; i++) {- check(root.definitions[i].name);+ check(root.definitions[i].name)}}export function parseSchema(text: string): Schema {- let schema = parse(tokenize(text));- verify(schema);- return schema;+ let schema = parse(tokenize(text))+ verify(schema)+ return schema}diff --git a/src/kiwi/kiwi-schema/schema.ts b/src/kiwi/kiwi-schema/schema.tsindex 87c65a311..82786ef59 100644--- a/src/kiwi/kiwi-schema/schema.ts+++ b/src/kiwi/kiwi-schema/schema.ts@@ -1,24 +1,24 @@export interface Schema {- package: string | null;- definitions: Definition[];+ package: string | null+ definitions: Definition[]}-export type DefinitionKind = 'ENUM' | 'STRUCT' | 'MESSAGE';+export type DefinitionKind = 'ENUM' | 'STRUCT' | 'MESSAGE'export interface Definition {- name: string;- line: number;- column: number;- kind: DefinitionKind;- fields: Field[];+ name: string+ line: number+ column: number+ kind: DefinitionKind+ fields: Field[]}export interface Field {- name: string;- line: number;- column: number;- type: string | null;- isArray: boolean;- isDeprecated: boolean;- value: number;+ name: string+ line: number+ column: number+ type: string | null+ isArray: boolean+ isDeprecated: boolean+ value: number}diff --git a/src/kiwi/kiwi-schema/util.ts b/src/kiwi/kiwi-schema/util.tsindex 3f40e4ab9..2925ed6dd 100644--- a/src/kiwi/kiwi-schema/util.ts+++ b/src/kiwi/kiwi-schema/util.ts@@ -1,10 +1,10 @@export function quote(text: string): string {- return JSON.stringify(text);+ return JSON.stringify(text)}export function error(text: string, line: number, column: number): never {- var error = new Error(text);- (error as any).line = line;- (error as any).column = column;- throw error;+ var error = new Error(text)+ ;(error as any).line = line+ ;(error as any).column = column+ throw error}diff --git a/src/stores/editor.ts b/src/stores/editor.tsindex c120a4cb6..db86db275 100644--- a/src/stores/editor.ts+++ b/src/stores/editor.ts@@ -1,7 +1,14 @@import { reactive, shallowRef, computed } from 'vue'-import { IS_TAURI, DEFAULT_SHAPE_FILL, DEFAULT_FRAME_FILL, SECTION_DEFAULT_FILL, SECTION_DEFAULT_STROKE, CANVAS_BG_COLOR, ZOOM_SENSITIVITY } from '../constants'-import type { Color } from '../types'+import {+ IS_TAURI,+ DEFAULT_SHAPE_FILL,+ DEFAULT_FRAME_FILL,+ SECTION_DEFAULT_FILL,+ SECTION_DEFAULT_STROKE,+ CANVAS_BG_COLOR,+ ZOOM_SENSITIVITY+} from '../constants'import {parseFigmaClipboard,importClipboardNodes,@@ -10,17 +17,38 @@ import {buildOpenPencilClipboardHTML,prefetchFigmaSchema} from '../engine/clipboard'-import { readFigFile } from '../kiwi/fig-file'import { exportFigFile } from '../engine/fig-export'import { computeLayout, computeAllLayouts } from '../engine/layout'import { SceneGraph } from '../engine/scene-graph'import { UndoManager } from '../engine/undo'import { computeVectorBounds } from '../engine/vector'+import { readFigFile } from '../kiwi/fig-file'-import type { SceneNode, NodeType, Fill, LayoutMode, VectorVertex, VectorSegment, VectorRegion, VectorNetwork } from '../engine/scene-graph'+import type {+ SceneNode,+ NodeType,+ Fill,+ LayoutMode,+ VectorVertex,+ VectorSegment,+ VectorRegion,+ VectorNetwork+} from '../engine/scene-graph'import type { SnapGuide } from '../engine/snap'+import type { Color } from '../types'-export type Tool = 'SELECT' | 'FRAME' | 'SECTION' | 'RECTANGLE' | 'ELLIPSE' | 'LINE' | 'POLYGON' | 'STAR' | 'TEXT' | 'PEN' | 'HAND'+export type Tool =+ | 'SELECT'+ | 'FRAME'+ | 'SECTION'+ | 'RECTANGLE'+ | 'ELLIPSE'+ | 'LINE'+ | 'POLYGON'+ | 'STAR'+ | 'TEXT'+ | 'PEN'+ | 'HAND'export interface ToolDef {key: Tool@@ -32,7 +60,12 @@ export interface ToolDef {export const TOOLS: ToolDef[] = [{ key: 'SELECT', label: 'Move', shortcut: 'V' },{ key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },- { key: 'RECTANGLE', label: 'Rectangle', shortcut: 'R', flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR'] },+ {+ key: 'RECTANGLE',+ label: 'Rectangle',+ shortcut: 'R',+ flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']+ },{ key: 'PEN', label: 'Pen', shortcut: 'P' },{ key: 'TEXT', label: 'Text', shortcut: 'T' },{ key: 'HAND', label: 'Hand', shortcut: 'H' }@@ -50,7 +83,12 @@ export const TOOL_SHORTCUTS: Record<string, Tool> = {h: 'HAND'}-const BLACK_FILL: Fill = { type: 'SOLID', color: { r: 0, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }+const BLACK_FILL: Fill = {+ type: 'SOLID',+ color: { r: 0, g: 0, b: 0, a: 1 },+ opacity: 1,+ visible: true+}const DEFAULT_FILLS: Record<string, Fill> = {FRAME: DEFAULT_FRAME_FILL,@@ -248,9 +286,7 @@ export function createEditorStore() {requestRender()}- function setLayoutInsertIndicator(- indicator: typeof state.layoutInsertIndicator- ) {+ function setLayoutInsertIndicator(indicator: typeof state.layoutInsertIndicator) {state.layoutInsertIndicator = indicatorrequestRender()}@@ -280,7 +316,13 @@ export function createEditorStore() {for (const id of nodeIds) {const node = graph.getNode(id)// Sections can only live in pages (CANVAS) or other sections- if (node?.type === 'SECTION' && parent && parent.type !== 'CANVAS' && parent.type !== 'SECTION') continue+ if (+ node?.type === 'SECTION' &&+ parent &&+ parent.type !== 'CANVAS' &&+ parent.type !== 'SECTION'+ )+ continuegraph.reparentNode(id, newParentId)}requestRender()@@ -386,12 +428,18 @@ export function createEditorStore() {updateNode(nodeId, {vectorNetwork: normalizedNetwork,name: 'Vector',- fills: closed- ? [{ ...DEFAULT_SHAPE_FILL }]- : [],+ fills: closed ? [{ ...DEFAULT_SHAPE_FILL }] : [],strokes: closed? []- : [{ color: { r: 0, g: 0, b: 0, a: 1 }, weight: 2, opacity: 1, visible: true, align: 'CENTER' as const }]+ : [+ {+ color: { r: 0, g: 0, b: 0, a: 1 },+ weight: 2,+ opacity: 1,+ visible: true,+ align: 'CENTER' as const+ }+ ]})select([nodeId])@@ -455,7 +503,10 @@ export function createEditorStore() {}}- function setCanvasKit(ck: import('canvaskit-wasm').CanvasKit, renderer: import('../engine/renderer').SkiaRenderer) {+ function setCanvasKit(+ ck: import('canvaskit-wasm').CanvasKit,+ renderer: import('../engine/renderer').SkiaRenderer+ ) {_ck = ck_renderer = renderer}@@ -492,10 +543,12 @@ export function createEditorStore() {try {const handle = await (window as any).showSaveFilePicker({suggestedName: 'Untitled.fig',- types: [{- description: 'Figma file',- accept: { 'application/octet-stream': ['.fig'] }- }]+ types: [+ {+ description: 'Figma file',+ accept: { 'application/octet-stream': ['.fig'] }+ }+ ]})fileHandle = handlefilePath = null@@ -673,8 +726,7 @@ export function createEditorStore() {maxY = Math.max(maxY, abs.y + n.height)}- const parentAbs =- isTopLevel(parentId) ? { x: 0, y: 0 } : graph.getAbsolutePosition(parentId)+ const parentAbs = isTopLevel(parentId) ? { x: 0, y: 0 } : graph.getAbsolutePosition(parentId)const frame = graph.createNode('FRAME', parentId, {name: 'Frame',@@ -757,8 +809,7 @@ export function createEditorStore() {maxY = Math.max(maxY, abs.y + n.height)}- const parentAbs =- isTopLevel(parentId) ? { x: 0, y: 0 } : graph.getAbsolutePosition(parentId)+ const parentAbs = isTopLevel(parentId) ? { x: 0, y: 0 } : graph.getAbsolutePosition(parentId)// Insert group at the position of the topmost selected nodeconst firstIndex = Math.min(...nodeIds.map((id) => parent.childIds.indexOf(id)))@@ -769,7 +820,7 @@ export function createEditorStore() {y: minY - parentAbs.y,width: maxX - minX,height: maxY - minY,- fills: [],+ fills: []})const groupId = group.id@@ -944,7 +995,9 @@ export function createEditorStore() {y: minY - parentAbs.y - padding,width: maxX - minX + padding * 2,height: maxY - minY + padding * 2,- fills: [{ type: 'SOLID', color: { r: 0.96, g: 0.96, b: 0.96, a: 1 }, opacity: 1, visible: true }]+ fills: [+ { type: 'SOLID', color: { r: 0.96, g: 0.96, b: 0.96, a: 1 }, opacity: 1, visible: true }+ ]})const setId = componentSet.id@@ -1249,7 +1302,14 @@ export function createEditorStore() {if (toAdopt.length === 0) return- const undoOps: Array<{ id: string; oldParent: string; oldX: number; oldY: number; newX: number; newY: number }> = []+ const undoOps: Array<{+ id: string+ oldParent: string+ oldX: number+ oldY: number+ newX: number+ newY: number+ }> = []for (const id of toAdopt) {const node = graph.getNode(id)if (!node) continue@@ -1348,7 +1408,14 @@ export function createEditorStore() {parseFigmaClipboard(html).then((figma) => {if (figma) {- const created = importClipboardNodes(figma.nodes, graph, state.currentPageId, 20, 20, figma.blobs)+ const created = importClipboardNodes(+ figma.nodes,+ graph,+ state.currentPageId,+ 20,+ 20,+ figma.blobs+ )if (created.length > 0) {state.selectedIds = new Set(created)requestRender()