@pixerate/editor-svelte 0.190.0 → 0.191.0
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.
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
type PaintEditorController,
|
|
12
12
|
type PaintPresence,
|
|
13
13
|
type PaintProposals,
|
|
14
|
+
type PaintAgentStrokes,
|
|
15
|
+
type PaintAgentStrokesState,
|
|
14
16
|
type PaintTool,
|
|
17
|
+
paintAgentStrokePoints,
|
|
15
18
|
} from '@pixerate/editor/paint-editor';
|
|
16
19
|
import { untrack } from 'svelte';
|
|
17
20
|
import { paintEditorState } from './paintEditorRune.svelte.js';
|
|
@@ -33,9 +36,23 @@
|
|
|
33
36
|
presence?: PaintPresence;
|
|
34
37
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `createPaintProposalState`). */
|
|
35
38
|
proposals?: PaintProposals;
|
|
39
|
+
/** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
|
|
40
|
+
agentStrokes?: PaintAgentStrokes;
|
|
36
41
|
class?: string;
|
|
37
42
|
}
|
|
38
|
-
let { controller, tool = 'brush', showGuides = true, fitOnMount = true, onerror, presence, proposals, class: className = '' }: Props = $props();
|
|
43
|
+
let { controller, tool = 'brush', showGuides = true, fitOnMount = true, onerror, presence, proposals, agentStrokes, class: className = '' }: Props = $props();
|
|
44
|
+
let agentLines = $state.raw<PaintAgentStrokesState>({ strokes: [] });
|
|
45
|
+
$effect(() => {
|
|
46
|
+
const store = agentStrokes;
|
|
47
|
+
if (!store) {
|
|
48
|
+
agentLines = { strokes: [] };
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
agentLines = store.getState();
|
|
52
|
+
return store.subscribe((next) => {
|
|
53
|
+
agentLines = next;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
39
56
|
|
|
40
57
|
const editor = paintEditorState(() => controller);
|
|
41
58
|
const snap = $derived(editor.current);
|
|
@@ -198,6 +215,9 @@
|
|
|
198
215
|
stroke-dasharray={l.kind === 'symmetry' ? `${6 / snap.view.zoom} ${4 / snap.view.zoom}` : undefined}
|
|
199
216
|
/>
|
|
200
217
|
{/each}
|
|
218
|
+
{#each agentLines.strokes as s (s.id)}
|
|
219
|
+
<polyline data-agent-stroke={s.id} points={paintAgentStrokePoints(s)} fill="none" stroke={s.color} stroke-opacity={s.opacity ?? 0.6} stroke-width={s.size} stroke-linecap="round" stroke-linejoin="round" />
|
|
220
|
+
{/each}
|
|
201
221
|
{#if predicted.length > 0}
|
|
202
222
|
<polyline points={predicted.map((p) => `${p.x},${p.y}`).join(' ')} fill="none" stroke={snap.color} stroke-opacity="0.5" stroke-width={Math.max(1, snap.brush.tip.size / 2)} stroke-linecap="round" />
|
|
203
223
|
{/if}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PaintEditorController, type PaintPresence, type PaintProposals, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
1
|
+
import { type PaintEditorController, type PaintPresence, type PaintProposals, type PaintAgentStrokes, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
2
2
|
interface Props {
|
|
3
3
|
controller: PaintEditorController;
|
|
4
4
|
/** The active tool (default brush). */
|
|
@@ -13,6 +13,8 @@ interface Props {
|
|
|
13
13
|
presence?: PaintPresence;
|
|
14
14
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `createPaintProposalState`). */
|
|
15
15
|
proposals?: PaintProposals;
|
|
16
|
+
/** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
|
|
17
|
+
agentStrokes?: PaintAgentStrokes;
|
|
16
18
|
class?: string;
|
|
17
19
|
}
|
|
18
20
|
declare const PaintCanvas: import("svelte").Component<Props, {}, "">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { PaintPresence, documentToScreen, screenToDocument, type PaintEditorController, type PaintProposals, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
2
|
+
import { PaintPresence, documentToScreen, screenToDocument, type PaintEditorController, type PaintProposals, type PaintAgentStrokes, type PaintTool } from '@pixerate/editor/paint-editor';
|
|
3
3
|
import type { AgentPlayback, PlaybackPoint, PlaybackRect, PlaybackRef } from '@pixerate/editor/tools';
|
|
4
4
|
import { createPlaybackSurface, getAgentPlayback } from '../playback/playback.svelte.js';
|
|
5
5
|
import PresenceLayer from '../playback/PresenceLayer.svelte';
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
presence?: PaintPresence;
|
|
26
26
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `createPaintProposalState`). */
|
|
27
27
|
proposals?: PaintProposals;
|
|
28
|
+
/** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
|
|
29
|
+
agentStrokes?: PaintAgentStrokes;
|
|
28
30
|
class?: string;
|
|
29
31
|
/**
|
|
30
32
|
* Agent playback: act out the paint tools' calls here with the agent's cursor, opening the
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
/** Bring the editor on screen (switch to its tab) before the agent acts. */
|
|
38
40
|
onplaybackreveal?: () => void | Promise<void>;
|
|
39
41
|
}
|
|
40
|
-
let { controller, fileName, height = 720, presence, proposals, class: className = '', playback, playbackId = 'paint', onplaybackreveal }: Props = $props();
|
|
42
|
+
let { controller, fileName, height = 720, presence, proposals, agentStrokes, class: className = '', playback, playbackId = 'paint', onplaybackreveal }: Props = $props();
|
|
41
43
|
|
|
42
44
|
/** Controls a paint plan can point at, by `{ kind: 'control', id }`. */
|
|
43
45
|
const PAINT_CONTROLS: Record<string, string> = {
|
|
@@ -118,7 +120,7 @@
|
|
|
118
120
|
<BrushPanel {controller} class="w-60 shrink-0 overflow-y-auto pr-1" />
|
|
119
121
|
<div class="flex min-w-0 flex-1 flex-col">
|
|
120
122
|
<!-- With playback the editor draws the cursor (over the panels too), so the canvas doesn't. -->
|
|
121
|
-
<PaintCanvas {controller} {tool} presence={playing ? undefined : presence} {proposals} onerror={(e) => (error = e)} class="flex-1 rounded-lg" />
|
|
123
|
+
<PaintCanvas {controller} {tool} presence={playing ? undefined : presence} {proposals} {agentStrokes} onerror={(e) => (error = e)} class="flex-1 rounded-lg" />
|
|
122
124
|
{#if error}<p role="alert" class="mt-1 text-[11px] text-rose-400">{error}</p>{/if}
|
|
123
125
|
</div>
|
|
124
126
|
<div class="flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaintPresence, type PaintEditorController, type PaintProposals } from '@pixerate/editor/paint-editor';
|
|
1
|
+
import { PaintPresence, type PaintEditorController, type PaintProposals, type PaintAgentStrokes } from '@pixerate/editor/paint-editor';
|
|
2
2
|
import type { AgentPlayback } from '@pixerate/editor/tools';
|
|
3
3
|
interface Props {
|
|
4
4
|
controller: PaintEditorController;
|
|
@@ -10,6 +10,8 @@ interface Props {
|
|
|
10
10
|
presence?: PaintPresence;
|
|
11
11
|
/** Paint an agent suggests, drawn over the canvas as ghosts (see `createPaintProposalState`). */
|
|
12
12
|
proposals?: PaintProposals;
|
|
13
|
+
/** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
|
|
14
|
+
agentStrokes?: PaintAgentStrokes;
|
|
13
15
|
class?: string;
|
|
14
16
|
/**
|
|
15
17
|
* Agent playback: act out the paint tools' calls here with the agent's cursor, opening the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.191.0",
|
|
4
4
|
"description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
"**/*.css"
|
|
176
176
|
],
|
|
177
177
|
"dependencies": {
|
|
178
|
-
"@pixerate/editor": "0.
|
|
178
|
+
"@pixerate/editor": "0.258.0"
|
|
179
179
|
},
|
|
180
180
|
"peerDependencies": {
|
|
181
181
|
"@dagrejs/dagre": "^1.1.4",
|