@pairdraw/core 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ai/providers.d.ts +6 -1
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js +9 -0
- package/dist/ai/providers.js.map +1 -1
- package/dist/canvas/highlight-rect.d.ts +10 -1
- package/dist/canvas/highlight-rect.d.ts.map +1 -1
- package/dist/canvas/highlight-rect.js +16 -8
- package/dist/canvas/highlight-rect.js.map +1 -1
- package/dist/canvas/index.d.ts +2 -3
- package/dist/canvas/index.js +1 -2
- package/dist/canvas/issues/draw.d.ts +2 -6
- package/dist/canvas/issues/draw.d.ts.map +1 -1
- package/dist/canvas/issues/draw.js +2 -99
- package/dist/canvas/issues/draw.js.map +1 -1
- package/dist/canvas/issues/types.d.ts +2 -33
- package/dist/canvas/issues/types.d.ts.map +1 -1
- package/dist/canvas/overlays/{ai.d.ts → ai/draw.d.ts} +3 -3
- package/dist/canvas/overlays/ai/draw.d.ts.map +1 -0
- package/dist/canvas/overlays/ai/draw.js +102 -0
- package/dist/canvas/overlays/ai/draw.js.map +1 -0
- package/dist/canvas/overlays/ai/motion.d.ts +23 -0
- package/dist/canvas/overlays/ai/motion.d.ts.map +1 -0
- package/dist/canvas/overlays/ai/motion.js +32 -0
- package/dist/canvas/overlays/ai/motion.js.map +1 -0
- package/dist/canvas/renderer/methods.js +1 -1
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +2 -47
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.js +1 -1
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/state.d.ts +5 -3
- package/dist/canvas/renderer/state.d.ts.map +1 -1
- package/dist/canvas/renderer/state.js +18 -6
- package/dist/canvas/renderer/state.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +2 -2
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +12 -8
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +9 -9
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/text/preparation/cache.d.ts +5 -0
- package/dist/canvas/text/preparation/cache.d.ts.map +1 -1
- package/dist/canvas/text/preparation/cache.js +8 -1
- package/dist/canvas/text/preparation/cache.js.map +1 -1
- package/dist/constants.d.ts +13 -18
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +16 -21
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/preview/picture.d.ts +12 -5
- package/dist/design-jsx/preview/picture.d.ts.map +1 -1
- package/dist/design-jsx/preview/picture.js +40 -15
- package/dist/design-jsx/preview/picture.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/create.d.ts +3 -6
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +11 -8
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/document-change.d.ts +9 -1
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +100 -2
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/snapshot/graph.d.ts +15 -3
- package/dist/editor/history/snapshot/graph.d.ts.map +1 -1
- package/dist/editor/history/snapshot/graph.js +29 -8
- package/dist/editor/history/snapshot/graph.js.map +1 -1
- package/dist/editor/index.d.ts +3 -3
- package/dist/editor/index.js +3 -3
- package/dist/editor/issues.d.ts +1 -4
- package/dist/editor/issues.d.ts.map +1 -1
- package/dist/editor/issues.js +5 -44
- package/dist/editor/issues.js.map +1 -1
- package/dist/editor/nudge.js +3 -2
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/read-only/actions.js +0 -3
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/state/shared.js +1 -1
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/types.d.ts +7 -4
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/io/formats/design-tokens/apply.d.ts +1 -1
- package/dist/io/subgraph.d.ts +5 -2
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +6 -2
- package/dist/io/subgraph.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -1
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +1 -1
- package/dist/layout/mutations.js.map +1 -1
- package/dist/text/font/faces.js +1 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/web-font/providers.d.ts +2 -11
- package/dist/text/web-font/providers.d.ts.map +1 -1
- package/dist/text/web-font/providers.js +8 -7
- package/dist/text/web-font/providers.js.map +1 -1
- package/dist/tools/analyze/diff/jsx.d.ts +2 -1
- package/dist/tools/analyze/diff/jsx.d.ts.map +1 -1
- package/dist/tools/analyze/diff/jsx.js +4 -2
- package/dist/tools/analyze/diff/jsx.js.map +1 -1
- package/package.json +24 -9
- package/src/ai/providers.ts +15 -1
- package/src/canvas/highlight-rect.ts +30 -9
- package/src/canvas/index.ts +1 -15
- package/src/canvas/issues/draw.ts +2 -165
- package/src/canvas/issues/types.ts +1 -36
- package/src/canvas/overlays/ai/draw.ts +129 -0
- package/src/canvas/overlays/ai/motion.ts +46 -0
- package/src/canvas/renderer/methods.ts +1 -1
- package/src/canvas/renderer/overlay-pass.ts +2 -49
- package/src/canvas/renderer/pipeline.ts +1 -1
- package/src/canvas/renderer/state.ts +20 -5
- package/src/canvas/renderer/types.ts +2 -2
- package/src/canvas/renderer.ts +9 -10
- package/src/canvas/text/preparation/cache.ts +9 -1
- package/src/constants.ts +12 -17
- package/src/design-jsx/index.ts +1 -1
- package/src/design-jsx/preview/picture.ts +55 -18
- package/src/editor/history/atomic-tool.ts +15 -8
- package/src/editor/history/document-change.ts +117 -1
- package/src/editor/history/snapshot/graph.ts +48 -8
- package/src/editor/index.ts +10 -2
- package/src/editor/issues.ts +6 -36
- package/src/editor/nudge.ts +4 -2
- package/src/editor/read-only/actions.ts +0 -3
- package/src/editor/state/shared.ts +1 -1
- package/src/editor/types.ts +6 -4
- package/src/io/subgraph.ts +10 -5
- package/src/layout/mutations.ts +2 -2
- package/src/text/font/faces.ts +1 -1
- package/src/text/web-font/providers.ts +19 -13
- package/src/tools/analyze/diff/jsx.ts +10 -5
- package/dist/canvas/issues/layout.d.ts +0 -37
- package/dist/canvas/issues/layout.d.ts.map +0 -1
- package/dist/canvas/issues/layout.js +0 -303
- package/dist/canvas/issues/layout.js.map +0 -1
- package/dist/canvas/overlays/ai.d.ts.map +0 -1
- package/dist/canvas/overlays/ai.js +0 -26
- package/dist/canvas/overlays/ai.js.map +0 -1
- package/src/canvas/issues/layout.ts +0 -376
- package/src/canvas/overlays/ai.ts +0 -34
package/src/ai/providers.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { OPENAI_COMPATIBLE_PRESETS } from './presets'
|
|
4
4
|
|
|
5
|
-
export type ACPAgentID = 'claude-code' | 'codex' | 'gemini-cli'
|
|
5
|
+
export type ACPAgentID = 'claude-code' | 'codex' | 'gemini-cli' | 'omp'
|
|
6
6
|
|
|
7
7
|
export interface ACPAgentDef {
|
|
8
8
|
id: ACPAgentID
|
|
@@ -22,6 +22,11 @@ export interface ACPAgentDef {
|
|
|
22
22
|
* which the desktop shell scope pins under `<command>-sign-in`.
|
|
23
23
|
*/
|
|
24
24
|
signIn?: { via: 'acp'; method: string } | { via: 'terminal'; method: string; args: string[] }
|
|
25
|
+
/**
|
|
26
|
+
* The agent runs on the providers and keys already set up in its own configuration and has no
|
|
27
|
+
* account to sign in to, so setup shows no sign-in step.
|
|
28
|
+
*/
|
|
29
|
+
ownCredentials?: boolean
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export const ACP_AGENTS: ACPAgentDef[] = [
|
|
@@ -58,6 +63,15 @@ export const ACP_AGENTS: ACPAgentDef[] = [
|
|
|
58
63
|
args: ['--acp'],
|
|
59
64
|
setupURL: 'https://geminicli.com/docs/get-started/installation/',
|
|
60
65
|
installCommand: 'npm i -g @google/gemini-cli'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'omp',
|
|
69
|
+
name: 'omp',
|
|
70
|
+
command: 'omp',
|
|
71
|
+
args: ['acp'],
|
|
72
|
+
setupURL: 'https://omp.sh',
|
|
73
|
+
installCommand: 'bun i -g @oh-my-pi/pi-coding-agent',
|
|
74
|
+
ownCredentials: true
|
|
61
75
|
}
|
|
62
76
|
]
|
|
63
77
|
|
|
@@ -15,6 +15,32 @@ export function ensureFlashPaint(r: SkiaRenderer): Paint {
|
|
|
15
15
|
return r._flashPaint
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** A node's box on screen: its centre, half its size, and its rotation in degrees. */
|
|
19
|
+
export interface ScreenBox {
|
|
20
|
+
cx: number
|
|
21
|
+
cy: number
|
|
22
|
+
hw: number
|
|
23
|
+
hh: number
|
|
24
|
+
rotation: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function nodeScreenBox(
|
|
28
|
+
r: SkiaRenderer,
|
|
29
|
+
graph: SceneGraph,
|
|
30
|
+
nodeId: string
|
|
31
|
+
): ScreenBox | null {
|
|
32
|
+
const node = graph.getNode(nodeId)
|
|
33
|
+
if (!node) return null
|
|
34
|
+
const abs = graph.getAbsolutePosition(nodeId)
|
|
35
|
+
return {
|
|
36
|
+
cx: (abs.x + node.width / 2) * r.zoom + r.panX,
|
|
37
|
+
cy: (abs.y + node.height / 2) * r.zoom + r.panY,
|
|
38
|
+
hw: (node.width / 2) * r.zoom,
|
|
39
|
+
hh: (node.height / 2) * r.zoom,
|
|
40
|
+
rotation: node.rotation
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
18
44
|
export function drawNodeHighlightRect(
|
|
19
45
|
r: SkiaRenderer,
|
|
20
46
|
canvas: Canvas,
|
|
@@ -24,14 +50,9 @@ export function drawNodeHighlightRect(
|
|
|
24
50
|
opacity: number,
|
|
25
51
|
extraPad = 0
|
|
26
52
|
): boolean {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
|
|
30
|
-
const abs = graph.getAbsolutePosition(nodeId)
|
|
31
|
-
const cx = (abs.x + node.width / 2) * r.zoom + r.panX
|
|
32
|
-
const cy = (abs.y + node.height / 2) * r.zoom + r.panY
|
|
33
|
-
const hw = (node.width / 2) * r.zoom
|
|
34
|
-
const hh = (node.height / 2) * r.zoom
|
|
53
|
+
const box = nodeScreenBox(r, graph, nodeId)
|
|
54
|
+
if (!box) return false
|
|
55
|
+
const { cx, cy, hw, hh } = box
|
|
35
56
|
const pad = FLASH_PADDING + extraPad
|
|
36
57
|
|
|
37
58
|
const paint = ensureFlashPaint(r)
|
|
@@ -39,7 +60,7 @@ export function drawNodeHighlightRect(
|
|
|
39
60
|
paint.setStrokeWidth(FLASH_STROKE_WIDTH)
|
|
40
61
|
|
|
41
62
|
canvas.save()
|
|
42
|
-
if (
|
|
63
|
+
if (box.rotation !== 0) canvas.rotate(box.rotation, cx, cy)
|
|
43
64
|
const rect = r.ck.RRectXY(
|
|
44
65
|
r.ck.LTRBRect(cx - hw - pad, cy - hh - pad, cx + hw + pad, cy + hh + pad),
|
|
45
66
|
FLASH_RADIUS,
|
package/src/canvas/index.ts
CHANGED
|
@@ -25,21 +25,7 @@ export {
|
|
|
25
25
|
type RulerTheme,
|
|
26
26
|
type SelectionTheme
|
|
27
27
|
} from './renderer'
|
|
28
|
-
export {
|
|
29
|
-
hitTestIssueMarkers,
|
|
30
|
-
issueMarkerLabel,
|
|
31
|
-
issueSeverityRank,
|
|
32
|
-
layoutIssueMarkers,
|
|
33
|
-
type IssueMarkerLayoutOptions,
|
|
34
|
-
type IssueMarkerView
|
|
35
|
-
} from './issues/layout'
|
|
36
|
-
export type {
|
|
37
|
-
DesignIssueHighlight,
|
|
38
|
-
DesignIssueMarker,
|
|
39
|
-
DesignIssueOverlay,
|
|
40
|
-
DesignIssueSeverity,
|
|
41
|
-
PlacedIssueMarker
|
|
42
|
-
} from './issues/types'
|
|
28
|
+
export type { DesignIssueHighlight, DesignIssueSeverity } from './issues/types'
|
|
43
29
|
export { hitTestStatusLabels, type PlacedStatusLabel } from './labels/status'
|
|
44
30
|
export { LabelCache, type CachedComponent, type CachedSection } from './labels/cache'
|
|
45
31
|
export { withFigExportRuntime } from './text/shape'
|
|
@@ -6,41 +6,24 @@ import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
|
6
6
|
import { inNodeSpace, withScreenStroke } from '#core/canvas/overlays/outline'
|
|
7
7
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
8
8
|
import {
|
|
9
|
-
ISSUE_EDGE_ARROW,
|
|
10
9
|
ISSUE_ERROR_COLOR,
|
|
11
10
|
ISSUE_HIGHLIGHT_FILL_ALPHA,
|
|
12
11
|
ISSUE_HIGHLIGHT_STROKE_WIDTH,
|
|
13
12
|
ISSUE_INFO_COLOR,
|
|
14
|
-
ISSUE_MARKER_RING_WIDTH,
|
|
15
13
|
ISSUE_WARNING_COLOR
|
|
16
14
|
} from '#core/constants'
|
|
17
15
|
import { createSceneGeometry, type RotationPreview } from '#core/geometry'
|
|
18
16
|
|
|
19
|
-
import {
|
|
20
|
-
import type { DesignIssueHighlight, DesignIssueSeverity, PlacedIssueMarker } from './types'
|
|
17
|
+
import type { DesignIssueHighlight, DesignIssueSeverity } from './types'
|
|
21
18
|
|
|
22
|
-
const MARKER_SHADOW_SIGMA = 1.5
|
|
23
|
-
/** Half the base of an edge pin's chevron. */
|
|
24
|
-
const EDGE_ARROW_HALF_WIDTH = 4
|
|
25
|
-
const MARKER_SHADOW_OFFSET_Y = 1
|
|
26
|
-
const MARKER_SHADOW_ALPHA = 0.3
|
|
27
|
-
const MARKER_HOVER_HALO = 3
|
|
28
|
-
const MARKER_HOVER_HALO_ALPHA = 0.28
|
|
29
|
-
/** Baseline below the vertical center for 10px Inter digits and the exclamation mark. */
|
|
30
|
-
const MARKER_TEXT_BASELINE = 3.5
|
|
31
19
|
const TARGET_DASH = 3
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
function issueSeverityColor(severity: DesignIssueSeverity): Color {
|
|
34
22
|
if (severity === 'error') return ISSUE_ERROR_COLOR
|
|
35
23
|
if (severity === 'warning') return ISSUE_WARNING_COLOR
|
|
36
24
|
return ISSUE_INFO_COLOR
|
|
37
25
|
}
|
|
38
26
|
|
|
39
|
-
/** Amber needs dark text; red and gray read best with white. */
|
|
40
|
-
function issueSeverityForeground(severity: DesignIssueSeverity): Color {
|
|
41
|
-
return severity === 'warning' ? { r: 0, g: 0, b: 0, a: 0.85 } : { r: 1, g: 1, b: 1, a: 1 }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
27
|
function color4f(r: SkiaRenderer, color: Color, alpha = color.a) {
|
|
45
28
|
return r.ck.Color4f(color.r, color.g, color.b, alpha)
|
|
46
29
|
}
|
|
@@ -75,149 +58,3 @@ export function drawIssueHighlight(
|
|
|
75
58
|
}
|
|
76
59
|
})
|
|
77
60
|
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* The chevron an edge pin points with: a triangle from the pill's border toward the issues,
|
|
81
|
-
* outlined in white like the pill so it reads on any canvas.
|
|
82
|
-
*/
|
|
83
|
-
function drawEdgeArrow(
|
|
84
|
-
r: SkiaRenderer,
|
|
85
|
-
canvas: Canvas,
|
|
86
|
-
marker: PlacedIssueMarker,
|
|
87
|
-
color: Color,
|
|
88
|
-
ring: number
|
|
89
|
-
): void {
|
|
90
|
-
const { rect, direction } = marker
|
|
91
|
-
if (!direction) return
|
|
92
|
-
const center = { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 }
|
|
93
|
-
const tx = direction.x === 0 ? Infinity : rect.width / 2 / Math.abs(direction.x)
|
|
94
|
-
const ty = direction.y === 0 ? Infinity : rect.height / 2 / Math.abs(direction.y)
|
|
95
|
-
const border = Math.min(tx, ty)
|
|
96
|
-
const normal = { x: -direction.y, y: direction.x }
|
|
97
|
-
const triangle = (reach: number, half: number) => {
|
|
98
|
-
const path = new r.ck.PathBuilder()
|
|
99
|
-
const base = border - 1
|
|
100
|
-
path.moveTo(
|
|
101
|
-
center.x + direction.x * (border + reach),
|
|
102
|
-
center.y + direction.y * (border + reach)
|
|
103
|
-
)
|
|
104
|
-
path.lineTo(
|
|
105
|
-
center.x + direction.x * base + normal.x * half,
|
|
106
|
-
center.y + direction.y * base + normal.y * half
|
|
107
|
-
)
|
|
108
|
-
path.lineTo(
|
|
109
|
-
center.x + direction.x * base - normal.x * half,
|
|
110
|
-
center.y + direction.y * base - normal.y * half
|
|
111
|
-
)
|
|
112
|
-
path.close()
|
|
113
|
-
return path.detachAndDelete()
|
|
114
|
-
}
|
|
115
|
-
const outline = triangle(ISSUE_EDGE_ARROW + ring * 2, EDGE_ARROW_HALF_WIDTH + ring)
|
|
116
|
-
const fill = triangle(ISSUE_EDGE_ARROW, EDGE_ARROW_HALF_WIDTH)
|
|
117
|
-
r.auxFill.setColor(r.ck.WHITE)
|
|
118
|
-
canvas.drawPath(outline, r.auxFill)
|
|
119
|
-
r.auxFill.setColor(color4f(r, color))
|
|
120
|
-
canvas.drawPath(fill, r.auxFill)
|
|
121
|
-
outline.delete()
|
|
122
|
-
fill.delete()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function drawMarker(
|
|
126
|
-
r: SkiaRenderer,
|
|
127
|
-
canvas: Canvas,
|
|
128
|
-
marker: PlacedIssueMarker,
|
|
129
|
-
hovered: boolean
|
|
130
|
-
): void {
|
|
131
|
-
const { rect } = marker
|
|
132
|
-
const radius = rect.height / 2
|
|
133
|
-
const color = issueSeverityColor(marker.severity)
|
|
134
|
-
const ring = ISSUE_MARKER_RING_WIDTH
|
|
135
|
-
|
|
136
|
-
const shadow = r.ck.RRectXY(
|
|
137
|
-
r.ck.LTRBRect(
|
|
138
|
-
rect.x - ring,
|
|
139
|
-
rect.y - ring + MARKER_SHADOW_OFFSET_Y,
|
|
140
|
-
rect.x + rect.width + ring,
|
|
141
|
-
rect.y + rect.height + ring + MARKER_SHADOW_OFFSET_Y
|
|
142
|
-
),
|
|
143
|
-
radius + ring,
|
|
144
|
-
radius + ring
|
|
145
|
-
)
|
|
146
|
-
r.auxFill.setColor(r.ck.Color4f(0, 0, 0, MARKER_SHADOW_ALPHA))
|
|
147
|
-
r.auxFill.setMaskFilter(r.getCachedMaskBlur(MARKER_SHADOW_SIGMA))
|
|
148
|
-
canvas.drawRRect(shadow, r.auxFill)
|
|
149
|
-
r.auxFill.setMaskFilter(null)
|
|
150
|
-
|
|
151
|
-
if (hovered) {
|
|
152
|
-
const halo = ring + MARKER_HOVER_HALO
|
|
153
|
-
r.auxFill.setColor(color4f(r, color, MARKER_HOVER_HALO_ALPHA))
|
|
154
|
-
canvas.drawRRect(
|
|
155
|
-
r.ck.RRectXY(
|
|
156
|
-
r.ck.LTRBRect(
|
|
157
|
-
rect.x - halo,
|
|
158
|
-
rect.y - halo,
|
|
159
|
-
rect.x + rect.width + halo,
|
|
160
|
-
rect.y + rect.height + halo
|
|
161
|
-
),
|
|
162
|
-
radius + halo,
|
|
163
|
-
radius + halo
|
|
164
|
-
),
|
|
165
|
-
r.auxFill
|
|
166
|
-
)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (marker.direction) drawEdgeArrow(r, canvas, marker, color, ring)
|
|
170
|
-
|
|
171
|
-
r.auxFill.setColor(r.ck.WHITE)
|
|
172
|
-
canvas.drawRRect(
|
|
173
|
-
r.ck.RRectXY(
|
|
174
|
-
r.ck.LTRBRect(
|
|
175
|
-
rect.x - ring,
|
|
176
|
-
rect.y - ring,
|
|
177
|
-
rect.x + rect.width + ring,
|
|
178
|
-
rect.y + rect.height + ring
|
|
179
|
-
),
|
|
180
|
-
radius + ring,
|
|
181
|
-
radius + ring
|
|
182
|
-
),
|
|
183
|
-
r.auxFill
|
|
184
|
-
)
|
|
185
|
-
r.auxFill.setColor(color4f(r, color))
|
|
186
|
-
canvas.drawRRect(
|
|
187
|
-
r.ck.RRectXY(
|
|
188
|
-
r.ck.LTRBRect(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height),
|
|
189
|
-
radius,
|
|
190
|
-
radius
|
|
191
|
-
),
|
|
192
|
-
r.auxFill
|
|
193
|
-
)
|
|
194
|
-
|
|
195
|
-
const font = r.sizeFont
|
|
196
|
-
if (!font) return
|
|
197
|
-
const label = issueMarkerLabel(marker.count)
|
|
198
|
-
let textWidth = 0
|
|
199
|
-
for (const width of font.getGlyphWidths(font.getGlyphIDs(label))) textWidth += width
|
|
200
|
-
font.setEmbolden(true)
|
|
201
|
-
r.auxFill.setColor(color4f(r, issueSeverityForeground(marker.severity)))
|
|
202
|
-
canvas.drawText(
|
|
203
|
-
label,
|
|
204
|
-
rect.x + (rect.width - textWidth) / 2,
|
|
205
|
-
rect.y + rect.height / 2 + MARKER_TEXT_BASELINE,
|
|
206
|
-
r.auxFill,
|
|
207
|
-
font
|
|
208
|
-
)
|
|
209
|
-
font.setEmbolden(false)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** Draws placed markers so the first placed, most severe marker ends up on top. */
|
|
213
|
-
export function drawIssueMarkers(
|
|
214
|
-
r: SkiaRenderer,
|
|
215
|
-
canvas: Canvas,
|
|
216
|
-
placed: readonly PlacedIssueMarker[],
|
|
217
|
-
hoveredKey: string | null | undefined
|
|
218
|
-
): void {
|
|
219
|
-
for (let index = placed.length - 1; index >= 0; index--) {
|
|
220
|
-
const marker = placed[index]
|
|
221
|
-
drawMarker(r, canvas, marker, marker.key === hoveredKey)
|
|
222
|
-
}
|
|
223
|
-
}
|
|
@@ -1,44 +1,9 @@
|
|
|
1
|
-
import type { Rect, Vector } from '@pairdraw/scene-graph/primitives'
|
|
2
|
-
|
|
3
1
|
export type DesignIssueSeverity = 'error' | 'warning' | 'info'
|
|
4
2
|
|
|
5
|
-
/**
|
|
6
|
-
export interface DesignIssueMarker {
|
|
7
|
-
nodeId: string
|
|
8
|
-
severity: DesignIssueSeverity
|
|
9
|
-
count: number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** A layer the user is inspecting through a marker or an issue row. */
|
|
3
|
+
/** A layer the user is inspecting through an issue row. */
|
|
13
4
|
export interface DesignIssueHighlight {
|
|
14
5
|
nodeId: string
|
|
15
6
|
severity: DesignIssueSeverity
|
|
16
7
|
/** Minimum size the layer should reach, drawn as a ghost target around it. */
|
|
17
8
|
minSize?: { width: number; height: number }
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
export interface DesignIssueOverlay {
|
|
21
|
-
/** Layers to mark on the canvas; empty while markers are turned off. */
|
|
22
|
-
markers: readonly DesignIssueMarker[]
|
|
23
|
-
highlight: DesignIssueHighlight | null
|
|
24
|
-
/** `key` of the placed marker under the pointer. */
|
|
25
|
-
hoveredMarkerKey: string | null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** A marker placed in screen space; nearby layers share one marker. */
|
|
29
|
-
export interface PlacedIssueMarker {
|
|
30
|
-
/** Stable while the leading layer stays the same, for hover state. */
|
|
31
|
-
key: string
|
|
32
|
-
nodeIds: string[]
|
|
33
|
-
severity: DesignIssueSeverity
|
|
34
|
-
count: number
|
|
35
|
-
/** Screen-space rectangle in CSS pixels. */
|
|
36
|
-
rect: Rect
|
|
37
|
-
/** Screen-space corner of the layer the marker is attached to. */
|
|
38
|
-
anchor: Vector
|
|
39
|
-
/**
|
|
40
|
-
* Set for an edge pin: issues outside the viewport, pinned to its edge. A unit vector from the
|
|
41
|
-
* viewport center toward them; `nodeIds` are ordered most severe first, then nearest.
|
|
42
|
-
*/
|
|
43
|
-
direction?: Vector
|
|
44
|
-
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { Canvas } from 'canvaskit-wasm'
|
|
2
|
+
|
|
3
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
drawNodeHighlightRect,
|
|
7
|
+
ensureFlashPaint,
|
|
8
|
+
nodeScreenBox,
|
|
9
|
+
type ScreenBox
|
|
10
|
+
} from '#core/canvas/highlight-rect'
|
|
11
|
+
import { entranceFrame, shimmerPosition, type EntranceFrame } from '#core/canvas/overlays/ai/motion'
|
|
12
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
13
|
+
import {
|
|
14
|
+
AI_AGENT_COLOR,
|
|
15
|
+
AI_DONE_COLOR,
|
|
16
|
+
AI_DONE_DURATION_MS,
|
|
17
|
+
AI_ENTER_DURATION_MS,
|
|
18
|
+
AI_SHIMMER_BAND
|
|
19
|
+
} from '#core/constants'
|
|
20
|
+
|
|
21
|
+
const AI_LINE_WIDTH = 1.5
|
|
22
|
+
const WORK_AREA_OUTLINE_ALPHA = 0.55
|
|
23
|
+
const WORK_AREA_FILL_ALPHA = 0.04
|
|
24
|
+
const SHIMMER_ALPHA = 0.16
|
|
25
|
+
|
|
26
|
+
function agentColor(r: SkiaRenderer, alpha: number) {
|
|
27
|
+
return r.ck.Color4f(AI_AGENT_COLOR.r, AI_AGENT_COLOR.g, AI_AGENT_COLOR.b, alpha)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Runs `draw` in the box's frame on screen, turned with its layer, and with its rect. */
|
|
31
|
+
function inScreenBox(
|
|
32
|
+
r: SkiaRenderer,
|
|
33
|
+
canvas: Canvas,
|
|
34
|
+
box: ScreenBox,
|
|
35
|
+
draw: (rect: Float32Array) => void
|
|
36
|
+
): void {
|
|
37
|
+
const { cx, cy, hw, hh } = box
|
|
38
|
+
canvas.save()
|
|
39
|
+
if (box.rotation !== 0) canvas.rotate(box.rotation, cx, cy)
|
|
40
|
+
draw(r.ck.LTRBRect(cx - hw, cy - hh, cx + hw, cy + hh))
|
|
41
|
+
canvas.restore()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A layer an agent added: a violet wash that fades while its outline traces round it. */
|
|
45
|
+
function drawEntrance(r: SkiaRenderer, canvas: Canvas, box: ScreenBox, frame: EntranceFrame) {
|
|
46
|
+
inScreenBox(r, canvas, box, (rect) => {
|
|
47
|
+
if (frame.wash > 0) {
|
|
48
|
+
r.auxFill.setColor(agentColor(r, frame.wash))
|
|
49
|
+
canvas.drawRect(rect, r.auxFill)
|
|
50
|
+
}
|
|
51
|
+
const perimeter = 4 * (box.hw + box.hh)
|
|
52
|
+
const drawn = perimeter * frame.trace
|
|
53
|
+
if (frame.outline <= 0 || drawn < 1) return
|
|
54
|
+
const paint = ensureFlashPaint(r)
|
|
55
|
+
paint.setColor(agentColor(r, frame.outline))
|
|
56
|
+
paint.setStrokeWidth(AI_LINE_WIDTH)
|
|
57
|
+
// A rect's outline starts at its top-left corner and runs clockwise, so one dash traces it.
|
|
58
|
+
const dash = frame.trace < 1 ? r.ck.PathEffect.MakeDash([drawn, perimeter], 0) : null
|
|
59
|
+
paint.setPathEffect(dash)
|
|
60
|
+
canvas.drawRect(rect, paint)
|
|
61
|
+
paint.setPathEffect(null)
|
|
62
|
+
dash?.delete()
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** An area an agent is working in: a light sweeping across it inside a violet outline. */
|
|
67
|
+
function drawWorkArea(r: SkiaRenderer, canvas: Canvas, box: ScreenBox, now: number) {
|
|
68
|
+
inScreenBox(r, canvas, box, (rect) => {
|
|
69
|
+
const left = box.cx - box.hw
|
|
70
|
+
const top = box.cy - box.hh
|
|
71
|
+
// The light runs along the diagonal, measured from the top-left corner.
|
|
72
|
+
const span = (2 * box.hw + 2 * box.hh) / Math.SQRT2
|
|
73
|
+
const at = shimmerPosition(now, span) / Math.SQRT2
|
|
74
|
+
const half = AI_SHIMMER_BAND / 2 / Math.SQRT2
|
|
75
|
+
const shader = r.ck.Shader.MakeLinearGradient(
|
|
76
|
+
[left + at - half, top + at - half],
|
|
77
|
+
[left + at + half, top + at + half],
|
|
78
|
+
[agentColor(r, 0), agentColor(r, SHIMMER_ALPHA), agentColor(r, 0)],
|
|
79
|
+
[0, 0.5, 1],
|
|
80
|
+
r.ck.TileMode.Clamp
|
|
81
|
+
)
|
|
82
|
+
r.auxFill.setColor(agentColor(r, WORK_AREA_FILL_ALPHA))
|
|
83
|
+
canvas.drawRect(rect, r.auxFill)
|
|
84
|
+
r.auxFill.setColor(agentColor(r, 1))
|
|
85
|
+
r.auxFill.setShader(shader)
|
|
86
|
+
canvas.drawRect(rect, r.auxFill)
|
|
87
|
+
r.auxFill.setShader(null)
|
|
88
|
+
shader.delete()
|
|
89
|
+
|
|
90
|
+
const paint = ensureFlashPaint(r)
|
|
91
|
+
paint.setColor(agentColor(r, WORK_AREA_OUTLINE_ALPHA))
|
|
92
|
+
paint.setStrokeWidth(AI_LINE_WIDTH)
|
|
93
|
+
canvas.drawRect(rect, paint)
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function drawAIOverlays(r: SkiaRenderer, canvas: Canvas, graph: SceneGraph): void {
|
|
98
|
+
const now = performance.now()
|
|
99
|
+
|
|
100
|
+
for (const nodeId of r._aiActiveNodes) {
|
|
101
|
+
const box = nodeScreenBox(r, graph, nodeId)
|
|
102
|
+
if (box) drawWorkArea(r, canvas, box, now)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
for (let i = r._aiEntrances.length - 1; i >= 0; i--) {
|
|
106
|
+
const entrance = r._aiEntrances[i]
|
|
107
|
+
const elapsed = now - entrance.startTime
|
|
108
|
+
// Still waiting for its turn: the layer shows as it is until then.
|
|
109
|
+
if (elapsed < 0) continue
|
|
110
|
+
const box = elapsed > AI_ENTER_DURATION_MS ? null : nodeScreenBox(r, graph, entrance.nodeId)
|
|
111
|
+
if (!box) {
|
|
112
|
+
r._aiEntrances.splice(i, 1)
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
drawEntrance(r, canvas, box, entranceFrame(elapsed / AI_ENTER_DURATION_MS))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for (let i = r._aiDoneFlashes.length - 1; i >= 0; i--) {
|
|
119
|
+
const flash = r._aiDoneFlashes[i]
|
|
120
|
+
const elapsed = now - flash.startTime
|
|
121
|
+
if (elapsed > AI_DONE_DURATION_MS) {
|
|
122
|
+
r._aiDoneFlashes.splice(i, 1)
|
|
123
|
+
continue
|
|
124
|
+
}
|
|
125
|
+
const t = elapsed / AI_DONE_DURATION_MS
|
|
126
|
+
const opacity = t < 0.3 ? t / 0.3 : 1 - (t - 0.3) / 0.7
|
|
127
|
+
drawNodeHighlightRect(r, canvas, graph, flash.nodeId, AI_DONE_COLOR, opacity)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AI_ENTER_MAX_DELAY_MS,
|
|
3
|
+
AI_ENTER_STAGGER_MS,
|
|
4
|
+
AI_SHIMMER_BAND,
|
|
5
|
+
AI_SHIMMER_PERIOD_MS
|
|
6
|
+
} from '#core/constants'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* When each of `count` layers starts tracing in, after the first: one stagger apart, closer
|
|
10
|
+
* together once the edit adds so many that the last would start after the cap.
|
|
11
|
+
*/
|
|
12
|
+
export function entranceDelays(count: number): number[] {
|
|
13
|
+
if (count <= 1) return count === 1 ? [0] : []
|
|
14
|
+
const step = Math.min(AI_ENTER_STAGGER_MS, AI_ENTER_MAX_DELAY_MS / (count - 1))
|
|
15
|
+
return Array.from({ length: count }, (_, index) => index * step)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** How far a layer's entrance has come: its outline traced, the outline's and the wash's alpha. */
|
|
19
|
+
export interface EntranceFrame {
|
|
20
|
+
/** Share of the outline drawn, from its top-left corner round. */
|
|
21
|
+
trace: number
|
|
22
|
+
outline: number
|
|
23
|
+
wash: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const easeOutCubic = (t: number) => 1 - (1 - t) ** 3
|
|
27
|
+
|
|
28
|
+
/** The entrance at `t`, from 0 when the layer's turn comes to 1 when it is done. */
|
|
29
|
+
export function entranceFrame(t: number): EntranceFrame {
|
|
30
|
+
const clamped = Math.min(1, Math.max(0, t))
|
|
31
|
+
return {
|
|
32
|
+
trace: easeOutCubic(Math.min(1, clamped / 0.6)),
|
|
33
|
+
// The outline holds while it traces, then fades as the layer settles.
|
|
34
|
+
outline: clamped < 0.7 ? 0.9 : 0.9 * (1 - (clamped - 0.7) / 0.3),
|
|
35
|
+
wash: 0.2 * (1 - easeOutCubic(clamped))
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Where the light's centre is along an area's diagonal of `span` pixels at `now`: it enters
|
|
41
|
+
* before the area's top-left corner and leaves past its bottom-right one each period.
|
|
42
|
+
*/
|
|
43
|
+
export function shimmerPosition(now: number, span: number): number {
|
|
44
|
+
const phase = (now % AI_SHIMMER_PERIOD_MS) / AI_SHIMMER_PERIOD_MS
|
|
45
|
+
return phase * (span + AI_SHIMMER_BAND * 2) - AI_SHIMMER_BAND
|
|
46
|
+
}
|
|
@@ -9,7 +9,7 @@ import * as Fills from '#core/canvas/fills'
|
|
|
9
9
|
import * as Labels from '#core/canvas/labels/draw'
|
|
10
10
|
import * as NodeEditOverlay from '#core/canvas/node-edit-overlay'
|
|
11
11
|
import * as Overlays from '#core/canvas/overlays'
|
|
12
|
-
import * as AIOverlays from '#core/canvas/overlays/ai'
|
|
12
|
+
import * as AIOverlays from '#core/canvas/overlays/ai/draw'
|
|
13
13
|
import * as PenOverlay from '#core/canvas/pen-overlay'
|
|
14
14
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
15
15
|
import type { PresenceCursor, RenderOverlays } from '#core/canvas/renderer/types'
|
|
@@ -3,8 +3,7 @@ import type { Canvas } from 'canvaskit-wasm'
|
|
|
3
3
|
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
4
4
|
|
|
5
5
|
import { drawGuides } from '#core/canvas/guides/draw'
|
|
6
|
-
import { drawIssueHighlight
|
|
7
|
-
import { layoutIssueMarkers } from '#core/canvas/issues/layout'
|
|
6
|
+
import { drawIssueHighlight } from '#core/canvas/issues/draw'
|
|
8
7
|
import { drawComponentSetBorders } from '#core/canvas/overlays/component-sets'
|
|
9
8
|
import { drawConnectorTarget } from '#core/canvas/overlays/connectors'
|
|
10
9
|
import { drawDropTarget, drawEditingText } from '#core/canvas/overlays/feedback'
|
|
@@ -18,7 +17,6 @@ import { drawCodeFocus } from '#core/canvas/overlays/selection'
|
|
|
18
17
|
import { drawShapeHandles } from '#core/canvas/overlays/shape-handles'
|
|
19
18
|
import { drawSlotOutlines } from '#core/canvas/overlays/slots'
|
|
20
19
|
import type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'
|
|
21
|
-
import { RULER_SIZE } from '#core/constants'
|
|
22
20
|
import { editedGradient } from '#core/editor/gradient-edit'
|
|
23
21
|
import { editedImage } from '#core/editor/image-edit'
|
|
24
22
|
|
|
@@ -51,49 +49,6 @@ export function drawLabelPass(
|
|
|
51
49
|
profiler.endPhase('render:componentLabels')
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
function suppressedIssueIds(overlays: RenderOverlays): Set<string> {
|
|
55
|
-
const ids = new Set<string>()
|
|
56
|
-
if (overlays.editingTextId) ids.add(overlays.editingTextId)
|
|
57
|
-
if (overlays.nodeEditState) ids.add(overlays.nodeEditState.nodeId)
|
|
58
|
-
return ids
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Lays out markers for this frame and keeps them for hit testing, so the pointer always targets
|
|
63
|
-
* what is drawn. Markers stay attached to their layers through edits and hide while drawing a path.
|
|
64
|
-
*/
|
|
65
|
-
function updateIssueMarkers(r: SkiaRenderer, graph: SceneGraph, overlays: RenderOverlays): void {
|
|
66
|
-
const markers = overlays.designIssues?.markers
|
|
67
|
-
if (!markers || markers.length === 0 || overlays.penState) {
|
|
68
|
-
r.issueMarkers = []
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
const measureText = (text: string) => {
|
|
72
|
-
const font = r.sizeFont
|
|
73
|
-
if (!font) return 0
|
|
74
|
-
let width = 0
|
|
75
|
-
for (const glyph of font.getGlyphWidths(font.getGlyphIDs(text))) width += glyph
|
|
76
|
-
return width
|
|
77
|
-
}
|
|
78
|
-
const inset = r.showRulers ? RULER_SIZE : 0
|
|
79
|
-
r.issueMarkers = layoutIssueMarkers(graph, markers, {
|
|
80
|
-
pageId: r.pageId ?? '',
|
|
81
|
-
view: {
|
|
82
|
-
panX: r.panX,
|
|
83
|
-
panY: r.panY,
|
|
84
|
-
zoom: r.zoom,
|
|
85
|
-
width: r.viewportWidth,
|
|
86
|
-
height: r.viewportHeight,
|
|
87
|
-
insetTop: inset,
|
|
88
|
-
insetLeft: inset
|
|
89
|
-
},
|
|
90
|
-
suppressedIds: suppressedIssueIds(overlays),
|
|
91
|
-
preview: overlays.rotationPreview,
|
|
92
|
-
measureText,
|
|
93
|
-
obstacles: r.overlayObstacles
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
52
|
/**
|
|
98
53
|
* While a gradient is edited, Figma shows its handles instead of the layer's selection, and an
|
|
99
54
|
* image being cropped shows itself whole with its crop handles; a previewing canvas shows neither.
|
|
@@ -137,7 +92,7 @@ export function drawOverlayPass(
|
|
|
137
92
|
if (!measuring) drawLayoutOutlines(r, canvas, graph, selectedIds, hoveredNodeId, overlays)
|
|
138
93
|
if (!measuring) drawPrototypeConnections(r, canvas, graph, selectedIds, overlays.rotationPreview)
|
|
139
94
|
r.drawHoverHighlight(canvas, graph, hoveredNodeId, overlays.rotationPreview)
|
|
140
|
-
drawIssueHighlight(r, canvas, graph, overlays.
|
|
95
|
+
drawIssueHighlight(r, canvas, graph, overlays.designIssueHighlight, overlays.rotationPreview)
|
|
141
96
|
r.drawEnteredContainer(canvas, graph, overlays.enteredContainerId, overlays.rotationPreview)
|
|
142
97
|
drawDropTarget(r, canvas, graph, overlays.dropTargetId, overlays.rotationPreview)
|
|
143
98
|
drawConnectorTarget(r, canvas, graph, overlays.connectorTarget, overlays.rotationPreview)
|
|
@@ -171,8 +126,6 @@ export function drawOverlayPass(
|
|
|
171
126
|
r.drawPenOverlay(canvas, overlays.penState)
|
|
172
127
|
r.drawPencilOverlay(canvas, overlays.pencilState)
|
|
173
128
|
r.drawSnapMarks(canvas, overlays.snapGuides)
|
|
174
|
-
updateIssueMarkers(r, graph, overlays)
|
|
175
|
-
drawIssueMarkers(r, canvas, r.issueMarkers, overlays.designIssues?.hoveredMarkerKey)
|
|
176
129
|
r.drawPresenceCursors(canvas, graph, overlays.presenceCursors)
|
|
177
130
|
}
|
|
178
131
|
|
|
@@ -122,7 +122,7 @@ export function renderFromEditorState(
|
|
|
122
122
|
? { ...state.nodeEditState, pointsTransformable: state.activeTool === 'SELECT' }
|
|
123
123
|
: null,
|
|
124
124
|
presenceCursors: state.presenceCursors,
|
|
125
|
-
|
|
125
|
+
designIssueHighlight: state.designIssueHighlight,
|
|
126
126
|
codeFocusNodeId: state.codeFocusNodeId,
|
|
127
127
|
autoLayoutHover: state.autoLayoutHover,
|
|
128
128
|
shapeHandleHover: state.shapeHandleHover,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
2
2
|
|
|
3
|
+
import { entranceDelays } from '#core/canvas/overlays/ai/motion'
|
|
3
4
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
4
5
|
import { changesShaping } from '#core/canvas/text/paragraph/inputs'
|
|
5
6
|
|
|
@@ -23,8 +24,9 @@ export function clearSubtreePictureCache(r: SkiaRenderer): void {
|
|
|
23
24
|
r.subtreePictureCacheFontGeneration = -1
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export function invalidateAllPictures(r: SkiaRenderer): void {
|
|
27
|
-
r.textPreparationCache.
|
|
27
|
+
export function invalidateAllPictures(r: SkiaRenderer, { keepShapedText = false } = {}): void {
|
|
28
|
+
if (keepShapedText) r.textPreparationCache.releaseLayers()
|
|
29
|
+
else r.textPreparationCache.clear()
|
|
28
30
|
invalidateScenePicture(r)
|
|
29
31
|
r.tiledScene.invalidateStructure()
|
|
30
32
|
for (const pic of r.nodePictureCache.values()) pic?.delete()
|
|
@@ -80,15 +82,28 @@ export function aiFlashDone(r: SkiaRenderer, nodeIds: string[]): void {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
export function
|
|
84
|
-
|
|
85
|
+
export function aiEnter(r: SkiaRenderer, nodeIds: string[]): void {
|
|
86
|
+
const now = performance.now()
|
|
87
|
+
const entering = new Set(nodeIds)
|
|
88
|
+
// A layer added again before it finished tracing starts over rather than tracing twice.
|
|
89
|
+
r._aiEntrances = r._aiEntrances.filter((entrance) => !entering.has(entrance.nodeId))
|
|
90
|
+
const delays = entranceDelays(nodeIds.length)
|
|
91
|
+
nodeIds.forEach((nodeId, index) => {
|
|
92
|
+
r._aiEntrances.push({ nodeId, startTime: now + (delays[index] ?? 0) })
|
|
93
|
+
})
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
export function aiClearAll(r: SkiaRenderer): void {
|
|
88
97
|
r._aiActiveNodes.clear()
|
|
89
98
|
r._aiDoneFlashes = []
|
|
99
|
+
r._aiEntrances = []
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
export function hasActiveFlashes(r: SkiaRenderer): boolean {
|
|
93
|
-
return
|
|
103
|
+
return (
|
|
104
|
+
r._flashes.length > 0 ||
|
|
105
|
+
r._aiActiveNodes.size > 0 ||
|
|
106
|
+
r._aiDoneFlashes.length > 0 ||
|
|
107
|
+
r._aiEntrances.length > 0
|
|
108
|
+
)
|
|
94
109
|
}
|