* feat(lint): suggest converting groups to frames and deleting hidden layers no-groups and no-hidden-layers now carry suggestions the Lint panel, the lint_fix tool and editor.applyLintFixes can apply. A group becomes a frame in place, keeping its id, children, bounds and look; a hidden layer is deleted with its children. Neither is offered for locked layers or inside components and instances, and both are checked again when applied. The editor gains convertGroupToFrame and deleteNodes, which deleteSelected now uses, and applies lint fixes through a bridge so structure changes and property updates share one undo step. lint_fix becomes a document mutation because atomic tools cannot remove layers. * fix(code): keep canvas edits made while replaced code waits to render Replacing all the code drops its layer links until the preview links it again, so a canvas edit in the preview delay could not be patched into the code and the preview drew over it. Edits made while code waits to render are now applied again once the preview has linked the code, in the same undo step, and reach the code like any other canvas change. * fix(figma-api): default paint opacity and visibility like Figma Plugin scripts may leave out a paint's opacity and visible; Figma reads them back as 1 and true. The fills and strokes setters stored the paint as given, so the Design panel received an undefined opacity. * build(dev): forward only errors from the browser console Vite forwards browser logs when an agent starts the dev server. Serializing a Vue warning's component props walks the editor state and freezes the tab, so warnings stay in the browser console. * fix(code): follow values while they are dragged or scrubbed Live previews change layers without a new scene version, so the code kept the old value until the gesture ended. The Code tab now follows preview updates once per frame, as the Design panel does, and goes back when the gesture is cancelled. * fix(code): keep canvas edits when the replaced code fails to preview A failed preview took the canvas edits waiting for it and dropped them, and stopped recording new ones, so correcting the code drew over them. The edits now wait for the next preview.
83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { createAPI } from '../helpers'
|
|
|
|
describe('property access', () => {
|
|
test('name get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.name = 'Card'
|
|
expect(frame.name).toBe('Card')
|
|
})
|
|
|
|
test('position get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.x = 50
|
|
frame.y = 100
|
|
expect(frame.x).toBe(50)
|
|
expect(frame.y).toBe(100)
|
|
})
|
|
|
|
test('resize', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.resize(300, 200)
|
|
expect(frame.width).toBe(300)
|
|
expect(frame.height).toBe(200)
|
|
})
|
|
|
|
test('fills get/set', () => {
|
|
const api = createAPI()
|
|
const rect = api.createRectangle()
|
|
rect.fills = [{ type: 'SOLID', color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }]
|
|
expect(rect.fills.length).toBe(1)
|
|
expect(rect.fills[0].color.r).toBe(1)
|
|
})
|
|
|
|
test('paints default to full opacity and visible, as in Figma', () => {
|
|
const api = createAPI()
|
|
const rect = api.createRectangle()
|
|
// Plugin scripts may leave out `opacity` and `visible`; Figma fills them in.
|
|
Reflect.set(rect, 'fills', [{ type: 'SOLID', color: { r: 1, g: 0, b: 0 } }])
|
|
Reflect.set(rect, 'strokes', [{ type: 'SOLID', color: { r: 0, g: 0, b: 1 }, opacity: 0.5 }])
|
|
expect(rect.fills[0]).toMatchObject({ opacity: 1, visible: true })
|
|
expect(rect.strokes[0]).toMatchObject({ opacity: 0.5, visible: true })
|
|
})
|
|
|
|
test('opacity get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.opacity = 0.5
|
|
expect(frame.opacity).toBe(0.5)
|
|
})
|
|
|
|
test('visible get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.visible = false
|
|
expect(frame.visible).toBe(false)
|
|
})
|
|
|
|
test('locked get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.locked = true
|
|
expect(frame.locked).toBe(true)
|
|
})
|
|
|
|
test('rotation get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.rotation = 45
|
|
expect(frame.rotation).toBe(45)
|
|
})
|
|
|
|
test('clipsContent get/set', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.clipsContent = true
|
|
expect(frame.clipsContent).toBe(true)
|
|
})
|
|
})
|