@dxos/plugin-illustrator 0.10.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.
- package/LICENSE +105 -0
- package/PLUGIN.mdl +55 -0
- package/dist/lib/IllustratorPlugin.mjs +18 -0
- package/dist/lib/IllustratorPlugin.mjs.map +1 -0
- package/dist/lib/IllustratorPlugin.node.mjs +18 -0
- package/dist/lib/IllustratorPlugin.node.mjs.map +1 -0
- package/dist/lib/IllustratorPlugin.workerd.mjs +10 -0
- package/dist/lib/IllustratorPlugin.workerd.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +11 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/chunk-IllustratorCapabilities.mjs +16 -0
- package/dist/lib/chunk-IllustratorCapabilities.mjs.map +1 -0
- package/dist/lib/chunk-comment-config.mjs +16 -0
- package/dist/lib/chunk-comment-config.mjs.map +1 -0
- package/dist/lib/chunk-create-object.mjs +46 -0
- package/dist/lib/chunk-create-object.mjs.map +1 -0
- package/dist/lib/chunk-create.mjs +20 -0
- package/dist/lib/chunk-create.mjs.map +1 -0
- package/dist/lib/chunk-edit.mjs +20 -0
- package/dist/lib/chunk-edit.mjs.map +1 -0
- package/dist/lib/chunk-load-sketch.mjs +64 -0
- package/dist/lib/chunk-load-sketch.mjs.map +1 -0
- package/dist/lib/chunk-meta.mjs +40 -0
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/chunk-model.mjs +202 -0
- package/dist/lib/chunk-model.mjs.map +1 -0
- package/dist/lib/chunk-operation-handler.mjs +11 -0
- package/dist/lib/chunk-operation-handler.mjs.map +1 -0
- package/dist/lib/chunk-react-surface.mjs +31 -0
- package/dist/lib/chunk-react-surface.mjs.map +1 -0
- package/dist/lib/chunk-read.mjs +13 -0
- package/dist/lib/chunk-read.mjs.map +1 -0
- package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
- package/dist/lib/chunk-skill-definition.mjs +10 -0
- package/dist/lib/chunk-skill-definition.mjs.map +1 -0
- package/dist/lib/chunk-skills.mjs +65 -0
- package/dist/lib/chunk-skills.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +108 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/components.mjs +45 -0
- package/dist/lib/components.mjs.map +1 -0
- package/dist/lib/containers.mjs +58 -0
- package/dist/lib/containers.mjs.map +1 -0
- package/dist/lib/index.mjs +9 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/model.mjs +2 -0
- package/dist/lib/operations.mjs +7 -0
- package/dist/lib/operations.mjs.map +1 -0
- package/dist/lib/plugin.mjs +9 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/skills.mjs +2 -0
- package/dist/lib/translations.mjs +27 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +3 -0
- package/dist/lib/util.mjs +2 -0
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/IllustratorPlugin.d.ts +4 -0
- package/dist/types/src/IllustratorPlugin.d.ts.map +1 -0
- package/dist/types/src/IllustratorPlugin.node.d.ts +10 -0
- package/dist/types/src/IllustratorPlugin.node.d.ts.map +1 -0
- package/dist/types/src/IllustratorPlugin.workerd.d.ts +4 -0
- package/dist/types/src/IllustratorPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/comment-config.d.ts +5 -0
- package/dist/types/src/capabilities/comment-config.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +5 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
- package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
- package/dist/types/src/components/CreateSketchPanel.d.ts +15 -0
- package/dist/types/src/components/CreateSketchPanel.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/containers/SketchArticle/SketchArticle.d.ts +11 -0
- package/dist/types/src/containers/SketchArticle/SketchArticle.d.ts.map +1 -0
- package/dist/types/src/containers/SketchArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SketchArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/SketchCard/SketchCard.d.ts +10 -0
- package/dist/types/src/containers/SketchCard/SketchCard.d.ts.map +1 -0
- package/dist/types/src/containers/SketchCard/index.d.ts +2 -0
- package/dist/types/src/containers/SketchCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +7 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +33 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/model/builder.d.ts +32 -0
- package/dist/types/src/model/builder.d.ts.map +1 -0
- package/dist/types/src/model/dialect.d.ts +19 -0
- package/dist/types/src/model/dialect.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +4 -0
- package/dist/types/src/model/index.d.ts.map +1 -0
- package/dist/types/src/model/scene.d.ts +843 -0
- package/dist/types/src/model/scene.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/edit.d.ts +5 -0
- package/dist/types/src/operations/edit.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/read.d.ts +5 -0
- package/dist/types/src/operations/read.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/skills/index.d.ts +2 -0
- package/dist/types/src/skills/index.d.ts.map +1 -0
- package/dist/types/src/skills/sketch-skill.d.ts +4 -0
- package/dist/types/src/skills/sketch-skill.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +34 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/IllustratorCapabilities.d.ts +10 -0
- package/dist/types/src/types/IllustratorCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/Sketch.d.ts +50 -0
- package/dist/types/src/types/Sketch.d.ts.map +1 -0
- package/dist/types/src/types/SketchOperation.d.ts +427 -0
- package/dist/types/src/types/SketchOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +45 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/load-sketch.d.ts +37 -0
- package/dist/types/src/util/load-sketch.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dx.config.ts +35 -0
- package/package.json +144 -0
- package/src/IllustratorPlugin.node.tsx +27 -0
- package/src/IllustratorPlugin.tsx +30 -0
- package/src/IllustratorPlugin.workerd.tsx +16 -0
- package/src/capabilities/comment-config.ts +20 -0
- package/src/capabilities/create-object.ts +66 -0
- package/src/capabilities/index.ts +15 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +37 -0
- package/src/capabilities/skill-definition.ts +14 -0
- package/src/components/CreateSketchPanel.tsx +68 -0
- package/src/components/index.ts +5 -0
- package/src/containers/SketchArticle/SketchArticle.tsx +48 -0
- package/src/containers/SketchArticle/index.ts +5 -0
- package/src/containers/SketchCard/SketchCard.tsx +41 -0
- package/src/containers/SketchCard/index.ts +5 -0
- package/src/containers/index.ts +6 -0
- package/src/index.ts +10 -0
- package/src/meta.ts +9 -0
- package/src/model/builder.ts +41 -0
- package/src/model/dialect.ts +53 -0
- package/src/model/index.ts +7 -0
- package/src/model/scene.ts +208 -0
- package/src/operations/create.ts +27 -0
- package/src/operations/edit.ts +23 -0
- package/src/operations/index.ts +11 -0
- package/src/operations/read.ts +21 -0
- package/src/plugin.ts +11 -0
- package/src/skills/index.ts +5 -0
- package/src/skills/sketch-skill.ts +70 -0
- package/src/translations.ts +33 -0
- package/src/types/IllustratorCapabilities.ts +19 -0
- package/src/types/Sketch.ts +69 -0
- package/src/types/SketchOperation.ts +76 -0
- package/src/types/index.ts +9 -0
- package/src/types/types.ts +53 -0
- package/src/util/index.ts +5 -0
- package/src/util/load-sketch.ts +74 -0
- package/src/vite-env.d.ts +10 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { invariant } from "@dxos/invariant";
|
|
5
|
+
//#region src/model/scene.ts
|
|
6
|
+
var scene_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
Arc: () => Arc,
|
|
8
|
+
Arrow: () => Arrow,
|
|
9
|
+
Box: () => Box,
|
|
10
|
+
Circle: () => Circle,
|
|
11
|
+
Color: () => Color,
|
|
12
|
+
Command: () => Command,
|
|
13
|
+
Curve: () => Curve,
|
|
14
|
+
Element: () => Element,
|
|
15
|
+
Fill: () => Fill,
|
|
16
|
+
MoveObject: () => MoveObject,
|
|
17
|
+
Point: () => Point,
|
|
18
|
+
Polyline: () => Polyline,
|
|
19
|
+
RemoveElements: () => RemoveElements,
|
|
20
|
+
RemoveObject: () => RemoveObject,
|
|
21
|
+
Scene: () => Scene,
|
|
22
|
+
Stroke: () => Stroke,
|
|
23
|
+
Text: () => Text,
|
|
24
|
+
UpsertElements: () => UpsertElements,
|
|
25
|
+
UpsertObject: () => UpsertObject,
|
|
26
|
+
Weight: () => Weight,
|
|
27
|
+
WorldObject: () => WorldObject
|
|
28
|
+
});
|
|
29
|
+
var Color = Schema.Literal("black", "grey", "light-violet", "violet", "blue", "light-blue", "yellow", "orange", "green", "light-green", "light-red", "red", "white");
|
|
30
|
+
var Fill = Schema.Literal("none", "solid", "pattern");
|
|
31
|
+
var Stroke = Schema.Literal("sketchy", "solid", "dashed", "dotted");
|
|
32
|
+
var Weight = Schema.Literal("s", "m", "l", "xl");
|
|
33
|
+
var Point = Schema.Struct({
|
|
34
|
+
x: Schema.Number,
|
|
35
|
+
y: Schema.Number
|
|
36
|
+
});
|
|
37
|
+
/** Style props shared by all elements; every field is optional with sensible defaults. */
|
|
38
|
+
var styleFields = {
|
|
39
|
+
color: Schema.optional(Color).annotations({ description: "Stroke/text color." }),
|
|
40
|
+
fill: Schema.optional(Fill).annotations({ description: "Interior fill of closed shapes." }),
|
|
41
|
+
stroke: Schema.optional(Stroke).annotations({ description: "Stroke rendering; sketchy is hand-drawn." }),
|
|
42
|
+
weight: Schema.optional(Weight).annotations({ description: "Stroke weight / text size." })
|
|
43
|
+
};
|
|
44
|
+
var id = Schema.String.annotations({ description: "Stable element id, unique within the object (e.g. \"left-eye\"). Used to edit or delete the element." });
|
|
45
|
+
/** Closed shape drawn inside a local bounding box. */
|
|
46
|
+
var Box = Schema.Struct({
|
|
47
|
+
kind: Schema.Literal("rect", "ellipse", "diamond", "triangle"),
|
|
48
|
+
id,
|
|
49
|
+
x: Schema.Number.annotations({ description: "Left edge (object-local units)." }),
|
|
50
|
+
y: Schema.Number.annotations({ description: "Top edge (object-local units)." }),
|
|
51
|
+
w: Schema.Number,
|
|
52
|
+
h: Schema.Number,
|
|
53
|
+
rotation: Schema.optional(Schema.Number).annotations({ description: "Clockwise rotation in degrees." }),
|
|
54
|
+
text: Schema.optional(Schema.String).annotations({ description: "Centered label." }),
|
|
55
|
+
...styleFields
|
|
56
|
+
});
|
|
57
|
+
/** Circle sugar; reads back as an ellipse. */
|
|
58
|
+
var Circle = Schema.Struct({
|
|
59
|
+
kind: Schema.Literal("circle"),
|
|
60
|
+
id,
|
|
61
|
+
cx: Schema.Number.annotations({ description: "Center x (object-local units)." }),
|
|
62
|
+
cy: Schema.Number.annotations({ description: "Center y (object-local units)." }),
|
|
63
|
+
r: Schema.Number,
|
|
64
|
+
text: Schema.optional(Schema.String),
|
|
65
|
+
...styleFields
|
|
66
|
+
});
|
|
67
|
+
/** Straight segment or open polyline through the given points. */
|
|
68
|
+
var Polyline = Schema.Struct({
|
|
69
|
+
kind: Schema.Literal("line"),
|
|
70
|
+
id,
|
|
71
|
+
points: Schema.Array(Point).annotations({ description: "Two or more points (object-local units)." }),
|
|
72
|
+
closed: Schema.optional(Schema.Boolean).annotations({ description: "Close the path back to the first point." }),
|
|
73
|
+
...styleFields
|
|
74
|
+
});
|
|
75
|
+
/** Smooth curve through the given points (spline). */
|
|
76
|
+
var Curve = Schema.Struct({
|
|
77
|
+
kind: Schema.Literal("curve"),
|
|
78
|
+
id,
|
|
79
|
+
points: Schema.Array(Point).annotations({ description: "Control points the curve passes through." }),
|
|
80
|
+
...styleFields
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Circular arc sugar; reads back as a curve. Angles are degrees, measured clockwise from
|
|
84
|
+
* the positive x-axis in screen coordinates (y grows downward): 0–180 is the lower half
|
|
85
|
+
* (a smile), 180–360 the upper half (a frown).
|
|
86
|
+
*/
|
|
87
|
+
var Arc = Schema.Struct({
|
|
88
|
+
kind: Schema.Literal("arc"),
|
|
89
|
+
id,
|
|
90
|
+
cx: Schema.Number,
|
|
91
|
+
cy: Schema.Number,
|
|
92
|
+
r: Schema.Number,
|
|
93
|
+
startAngle: Schema.Number,
|
|
94
|
+
endAngle: Schema.Number,
|
|
95
|
+
...styleFields
|
|
96
|
+
});
|
|
97
|
+
/** Free-standing text. */
|
|
98
|
+
var Text = Schema.Struct({
|
|
99
|
+
kind: Schema.Literal("text"),
|
|
100
|
+
id,
|
|
101
|
+
x: Schema.Number,
|
|
102
|
+
y: Schema.Number,
|
|
103
|
+
w: Schema.optional(Schema.Number).annotations({ description: "Wrap width; omit for auto-size." }),
|
|
104
|
+
text: Schema.String,
|
|
105
|
+
...styleFields
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Connector. Endpoints are element refs — `"<elementId>"` within the same object or
|
|
109
|
+
* `"<objectId>/<elementId>"` across objects — or explicit local points. Bound endpoints
|
|
110
|
+
* track their target when it moves.
|
|
111
|
+
*/
|
|
112
|
+
var Arrow = Schema.Struct({
|
|
113
|
+
kind: Schema.Literal("arrow"),
|
|
114
|
+
id,
|
|
115
|
+
from: Schema.optional(Schema.String).annotations({ description: "Source element ref." }),
|
|
116
|
+
to: Schema.optional(Schema.String).annotations({ description: "Target element ref." }),
|
|
117
|
+
start: Schema.optional(Point).annotations({ description: "Explicit start (used when `from` is omitted)." }),
|
|
118
|
+
end: Schema.optional(Point).annotations({ description: "Explicit end (used when `to` is omitted)." }),
|
|
119
|
+
text: Schema.optional(Schema.String).annotations({ description: "Label at the arrow midpoint." }),
|
|
120
|
+
...styleFields
|
|
121
|
+
});
|
|
122
|
+
var Element = Schema.Union(Box, Circle, Polyline, Curve, Arc, Text, Arrow);
|
|
123
|
+
/**
|
|
124
|
+
* A semantic group of elements ("face", "hat") authored in its own local unit space.
|
|
125
|
+
* `origin` (canvas px) and `scale` (px per unit) place it on the canvas:
|
|
126
|
+
* `canvas = origin + local * scale`. On read, `origin` is derived as the top-left of the
|
|
127
|
+
* object's bounding box, so the model survives users dragging shapes around.
|
|
128
|
+
*/
|
|
129
|
+
var WorldObject = Schema.Struct({
|
|
130
|
+
id: Schema.String.annotations({ description: "Stable object id naming the thing depicted (e.g. \"face\", \"hat\")." }),
|
|
131
|
+
origin: Schema.optional(Point).annotations({ description: "Canvas position (px). Omit on upsert to keep the current position." }),
|
|
132
|
+
scale: Schema.optional(Schema.Number).annotations({ description: "Canvas px per local unit (default 1)." }),
|
|
133
|
+
elements: Schema.Array(Element)
|
|
134
|
+
});
|
|
135
|
+
var Scene = Schema.Struct({ objects: Schema.Array(WorldObject) });
|
|
136
|
+
var UpsertObject = Schema.Struct({
|
|
137
|
+
op: Schema.Literal("upsert-object"),
|
|
138
|
+
object: WorldObject
|
|
139
|
+
}).annotations({ description: "Create an object, or replace an existing one wholesale (same id)." });
|
|
140
|
+
var UpsertElements = Schema.Struct({
|
|
141
|
+
op: Schema.Literal("upsert-elements"),
|
|
142
|
+
objectId: Schema.String,
|
|
143
|
+
elements: Schema.Array(Element)
|
|
144
|
+
}).annotations({ description: "Add elements to an existing object, replacing any with matching ids." });
|
|
145
|
+
var RemoveElements = Schema.Struct({
|
|
146
|
+
op: Schema.Literal("remove-elements"),
|
|
147
|
+
objectId: Schema.String,
|
|
148
|
+
elementIds: Schema.Array(Schema.String)
|
|
149
|
+
});
|
|
150
|
+
var RemoveObject = Schema.Struct({
|
|
151
|
+
op: Schema.Literal("remove-object"),
|
|
152
|
+
objectId: Schema.String
|
|
153
|
+
});
|
|
154
|
+
var MoveObject = Schema.Struct({
|
|
155
|
+
op: Schema.Literal("move-object"),
|
|
156
|
+
objectId: Schema.String,
|
|
157
|
+
origin: Point.annotations({ description: "New canvas position (px) for the object top-left." })
|
|
158
|
+
});
|
|
159
|
+
var Command = Schema.Union(UpsertObject, UpsertElements, RemoveElements, RemoveObject, MoveObject);
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/model/dialect.ts
|
|
162
|
+
var __dxlog_file = "/Users/burdon/Code/dxos/dxos/.claude/worktrees/peaceful-allen-9b542f/packages/plugins/plugin-illustrator/src/model/dialect.ts";
|
|
163
|
+
/** The core dialect: input is already scene edit commands (identity compile). */
|
|
164
|
+
var sceneDialect = {
|
|
165
|
+
id: "scene",
|
|
166
|
+
description: "Positioned world objects and elements; the agent does the layout.",
|
|
167
|
+
input: Schema.Array(Command),
|
|
168
|
+
compile: Effect.succeed
|
|
169
|
+
};
|
|
170
|
+
var DialectRegistry = class {
|
|
171
|
+
#dialects = /* @__PURE__ */ new Map();
|
|
172
|
+
constructor(dialects = [sceneDialect]) {
|
|
173
|
+
dialects.forEach((dialect) => this.register(dialect));
|
|
174
|
+
}
|
|
175
|
+
register(dialect) {
|
|
176
|
+
invariant(!this.#dialects.has(dialect.id), `duplicate dialect: ${dialect.id}`, {
|
|
177
|
+
"~LogMeta": "~LogMeta",
|
|
178
|
+
F: __dxlog_file,
|
|
179
|
+
L: 42,
|
|
180
|
+
S: this,
|
|
181
|
+
A: ["!this.#dialects.has(dialect.id)", "`duplicate dialect: ${dialect.id}`"]
|
|
182
|
+
});
|
|
183
|
+
this.#dialects.set(dialect.id, dialect);
|
|
184
|
+
}
|
|
185
|
+
get(id) {
|
|
186
|
+
return this.#dialects.get(id);
|
|
187
|
+
}
|
|
188
|
+
list() {
|
|
189
|
+
return [...this.#dialects.values()];
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/model/index.ts
|
|
194
|
+
var model_exports = /* @__PURE__ */ __exportAll({
|
|
195
|
+
DialectRegistry: () => DialectRegistry,
|
|
196
|
+
Scene: () => scene_exports,
|
|
197
|
+
sceneDialect: () => sceneDialect
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { scene_exports as i, DialectRegistry as n, sceneDialect as r, model_exports as t };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=chunk-model.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-model.mjs","names":[],"sources":["../../src/model/scene.ts","../../src/model/dialect.ts","../../src/model/index.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n//\n// Backend-neutral scene DSL: a diagram is a set of named world objects (\"face\", \"hat\"),\n// each composed of graphical elements (rect, ellipse, line, curve, text, arrow) authored\n// in object-local units. A backend compiler (tldraw today) maps the scene onto the\n// concrete canvas; see `render.ts` / `read.ts`.\n//\n\nimport * as Schema from 'effect/Schema';\n\nexport const Color = Schema.Literal(\n 'black',\n 'grey',\n 'light-violet',\n 'violet',\n 'blue',\n 'light-blue',\n 'yellow',\n 'orange',\n 'green',\n 'light-green',\n 'light-red',\n 'red',\n 'white',\n);\nexport type Color = Schema.Schema.Type<typeof Color>;\n\nexport const Fill = Schema.Literal('none', 'solid', 'pattern');\nexport type Fill = Schema.Schema.Type<typeof Fill>;\n\nexport const Stroke = Schema.Literal('sketchy', 'solid', 'dashed', 'dotted');\nexport type Stroke = Schema.Schema.Type<typeof Stroke>;\n\nexport const Weight = Schema.Literal('s', 'm', 'l', 'xl');\nexport type Weight = Schema.Schema.Type<typeof Weight>;\n\nexport const Point = Schema.Struct({\n x: Schema.Number,\n y: Schema.Number,\n});\nexport type Point = Schema.Schema.Type<typeof Point>;\n\n/** Style props shared by all elements; every field is optional with sensible defaults. */\nconst styleFields = {\n color: Schema.optional(Color).annotations({ description: 'Stroke/text color.' }),\n fill: Schema.optional(Fill).annotations({ description: 'Interior fill of closed shapes.' }),\n stroke: Schema.optional(Stroke).annotations({ description: 'Stroke rendering; sketchy is hand-drawn.' }),\n weight: Schema.optional(Weight).annotations({ description: 'Stroke weight / text size.' }),\n};\n\nconst id = Schema.String.annotations({\n description: 'Stable element id, unique within the object (e.g. \"left-eye\"). Used to edit or delete the element.',\n});\n\n/** Closed shape drawn inside a local bounding box. */\nexport const Box = Schema.Struct({\n kind: Schema.Literal('rect', 'ellipse', 'diamond', 'triangle'),\n id,\n x: Schema.Number.annotations({ description: 'Left edge (object-local units).' }),\n y: Schema.Number.annotations({ description: 'Top edge (object-local units).' }),\n w: Schema.Number,\n h: Schema.Number,\n rotation: Schema.optional(Schema.Number).annotations({ description: 'Clockwise rotation in degrees.' }),\n text: Schema.optional(Schema.String).annotations({ description: 'Centered label.' }),\n ...styleFields,\n});\nexport type Box = Schema.Schema.Type<typeof Box>;\n\n/** Circle sugar; reads back as an ellipse. */\nexport const Circle = Schema.Struct({\n kind: Schema.Literal('circle'),\n id,\n cx: Schema.Number.annotations({ description: 'Center x (object-local units).' }),\n cy: Schema.Number.annotations({ description: 'Center y (object-local units).' }),\n r: Schema.Number,\n text: Schema.optional(Schema.String),\n ...styleFields,\n});\nexport type Circle = Schema.Schema.Type<typeof Circle>;\n\n/** Straight segment or open polyline through the given points. */\nexport const Polyline = Schema.Struct({\n kind: Schema.Literal('line'),\n id,\n points: Schema.Array(Point).annotations({ description: 'Two or more points (object-local units).' }),\n closed: Schema.optional(Schema.Boolean).annotations({ description: 'Close the path back to the first point.' }),\n ...styleFields,\n});\nexport type Polyline = Schema.Schema.Type<typeof Polyline>;\n\n/** Smooth curve through the given points (spline). */\nexport const Curve = Schema.Struct({\n kind: Schema.Literal('curve'),\n id,\n points: Schema.Array(Point).annotations({ description: 'Control points the curve passes through.' }),\n ...styleFields,\n});\nexport type Curve = Schema.Schema.Type<typeof Curve>;\n\n/**\n * Circular arc sugar; reads back as a curve. Angles are degrees, measured clockwise from\n * the positive x-axis in screen coordinates (y grows downward): 0–180 is the lower half\n * (a smile), 180–360 the upper half (a frown).\n */\nexport const Arc = Schema.Struct({\n kind: Schema.Literal('arc'),\n id,\n cx: Schema.Number,\n cy: Schema.Number,\n r: Schema.Number,\n startAngle: Schema.Number,\n endAngle: Schema.Number,\n ...styleFields,\n});\nexport type Arc = Schema.Schema.Type<typeof Arc>;\n\n/** Free-standing text. */\nexport const Text = Schema.Struct({\n kind: Schema.Literal('text'),\n id,\n x: Schema.Number,\n y: Schema.Number,\n w: Schema.optional(Schema.Number).annotations({ description: 'Wrap width; omit for auto-size.' }),\n text: Schema.String,\n ...styleFields,\n});\nexport type Text = Schema.Schema.Type<typeof Text>;\n\n/**\n * Connector. Endpoints are element refs — `\"<elementId>\"` within the same object or\n * `\"<objectId>/<elementId>\"` across objects — or explicit local points. Bound endpoints\n * track their target when it moves.\n */\nexport const Arrow = Schema.Struct({\n kind: Schema.Literal('arrow'),\n id,\n from: Schema.optional(Schema.String).annotations({ description: 'Source element ref.' }),\n to: Schema.optional(Schema.String).annotations({ description: 'Target element ref.' }),\n start: Schema.optional(Point).annotations({ description: 'Explicit start (used when `from` is omitted).' }),\n end: Schema.optional(Point).annotations({ description: 'Explicit end (used when `to` is omitted).' }),\n text: Schema.optional(Schema.String).annotations({ description: 'Label at the arrow midpoint.' }),\n ...styleFields,\n});\nexport type Arrow = Schema.Schema.Type<typeof Arrow>;\n\nexport const Element = Schema.Union(Box, Circle, Polyline, Curve, Arc, Text, Arrow);\nexport type Element = Schema.Schema.Type<typeof Element>;\n\n/**\n * A semantic group of elements (\"face\", \"hat\") authored in its own local unit space.\n * `origin` (canvas px) and `scale` (px per unit) place it on the canvas:\n * `canvas = origin + local * scale`. On read, `origin` is derived as the top-left of the\n * object's bounding box, so the model survives users dragging shapes around.\n */\nexport const WorldObject = Schema.Struct({\n id: Schema.String.annotations({\n description: 'Stable object id naming the thing depicted (e.g. \"face\", \"hat\").',\n }),\n origin: Schema.optional(Point).annotations({\n description: 'Canvas position (px). Omit on upsert to keep the current position.',\n }),\n scale: Schema.optional(Schema.Number).annotations({ description: 'Canvas px per local unit (default 1).' }),\n elements: Schema.Array(Element),\n});\nexport type WorldObject = Schema.Schema.Type<typeof WorldObject>;\n\nexport const Scene = Schema.Struct({\n objects: Schema.Array(WorldObject),\n});\nexport type Scene = Schema.Schema.Type<typeof Scene>;\n\n//\n// Edit commands.\n//\n\nexport const UpsertObject = Schema.Struct({\n op: Schema.Literal('upsert-object'),\n object: WorldObject,\n}).annotations({ description: 'Create an object, or replace an existing one wholesale (same id).' });\n\nexport const UpsertElements = Schema.Struct({\n op: Schema.Literal('upsert-elements'),\n objectId: Schema.String,\n elements: Schema.Array(Element),\n}).annotations({ description: 'Add elements to an existing object, replacing any with matching ids.' });\n\nexport const RemoveElements = Schema.Struct({\n op: Schema.Literal('remove-elements'),\n objectId: Schema.String,\n elementIds: Schema.Array(Schema.String),\n});\n\nexport const RemoveObject = Schema.Struct({\n op: Schema.Literal('remove-object'),\n objectId: Schema.String,\n});\n\nexport const MoveObject = Schema.Struct({\n op: Schema.Literal('move-object'),\n objectId: Schema.String,\n origin: Point.annotations({ description: 'New canvas position (px) for the object top-left.' }),\n});\n\nexport const Command = Schema.Union(UpsertObject, UpsertElements, RemoveElements, RemoveObject, MoveObject);\nexport type Command = Schema.Schema.Type<typeof Command>;\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// Extension point for higher-level diagram languages (mermaid, d2, sequence, uml-class, …).\n// A dialect compiles its input into scene edit commands — owning any layout it needs — so its\n// output lands as ordinary world objects and stays editable by id. Mirrors the architecture\n// shared by Mermaid/D2/Kroki: dialect → intermediate positioned model → renderer.\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\nimport * as Scene from './scene';\n\nexport type Dialect<Input = any> = {\n id: string;\n description: string;\n input: Schema.Schema<Input, any>;\n compile: (input: Input) => Effect.Effect<readonly Scene.Command[]>;\n};\n\n/** The core dialect: input is already scene edit commands (identity compile). */\nexport const sceneDialect: Dialect<readonly Scene.Command[]> = {\n id: 'scene',\n description: 'Positioned world objects and elements; the agent does the layout.',\n input: Schema.Array(Scene.Command),\n compile: Effect.succeed,\n};\n\nexport class DialectRegistry {\n readonly #dialects = new Map<string, Dialect>();\n\n constructor(dialects: Dialect[] = [sceneDialect]) {\n dialects.forEach((dialect) => this.register(dialect));\n }\n\n register(dialect: Dialect): void {\n invariant(!this.#dialects.has(dialect.id), `duplicate dialect: ${dialect.id}`);\n this.#dialects.set(dialect.id, dialect);\n }\n\n get(id: string): Dialect | undefined {\n return this.#dialects.get(id);\n }\n\n list(): Dialect[] {\n return [...this.#dialects.values()];\n }\n}\n","//\n// Copyright 2026 DXOS.org\n//\n\nexport * from './builder';\nexport * from './dialect';\nexport * as Scene from './scene';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,QAAQ,OAAO,QAC1B,SAC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,QAAQ,aAAa;CAChC,UAAU,OAAO;CACjB,QAAQ,MAAM,YAAY,EAAE,aAAa,oDAAoD,CAAC;AAChG,CAAC;AAED,IAAa,UAAU,OAAO,MAAM,cAAc,gBAAgB,gBAAgB,cAAc,UAAU;;;;;ACpL1G,IAAa,eAAkD;CAC7D,IAAI;CACJ,aAAa;CACb,OAAO,OAAO,MAAM,OAAa;CACjC,SAAS,OAAO;AAClB;AAEA,IAAa,kBAAb,MAA6B;CAC3B,4BAAqB,IAAI,IAAqB;CAE9C,YAAY,WAAsB,CAAC,YAAY,GAAG;EAChD,SAAS,SAAS,YAAY,KAAK,SAAS,OAAO,CAAC;CACtD;CAEA,SAAS,SAAwB;EAC/B,UAAU,CAAC,KAAK,UAAU,IAAI,QAAQ,EAAE,GAAG,sBAAsB,QAAQ,MAAG;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,CAAA,mCAAA,oCAAA;EAAA,CAAC;EAC7E,KAAK,UAAU,IAAI,QAAQ,IAAI,OAAO;CACxC;CAEA,IAAI,IAAiC;EACnC,OAAO,KAAK,UAAU,IAAI,EAAE;CAC9B;CAEA,OAAkB;EAChB,OAAO,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC;CACpC;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { IllustratorOperationHandlerSet } from "#operations";
|
|
4
|
+
//#region src/capabilities/operation-handler.ts
|
|
5
|
+
var operation_handler_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
6
|
+
return Capability.contributes(Capabilities.OperationHandler, IllustratorOperationHandlerSet);
|
|
7
|
+
}));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { operation_handler_default as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=chunk-operation-handler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-operation-handler.mjs","names":[],"sources":["../../src/capabilities/operation-handler.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport type { OperationHandlerSet } from '@dxos/compute';\n\nimport { IllustratorOperationHandlerSet } from '#operations';\n\nexport default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(\n Effect.fnUntraced(function* () {\n return Capability.contributes(Capabilities.OperationHandler, IllustratorOperationHandlerSet);\n }),\n);\n"],"mappings":";;;;AAWA,IAAA,4BAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,OAAO,WAAW,YAAY,aAAa,kBAAkB,8BAA8B;AAC7F,CAAC,CACH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { a as Sketch } from "./chunk-types.mjs";
|
|
2
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import "react";
|
|
5
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
8
|
+
import { SketchArticle, SketchCard } from "#containers";
|
|
9
|
+
//#region src/capabilities/react-surface.tsx
|
|
10
|
+
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Capabilities.ReactSurface, [Surface.create({
|
|
11
|
+
id: "sketch",
|
|
12
|
+
filter: AppSurface.oneOf(AppSurface.object(AppSurface.Article, Sketch), AppSurface.object(AppSurface.Section, Sketch), AppSurface.object(AppSurface.Slide, Sketch)),
|
|
13
|
+
component: ({ data: { subject, attendableId, extrinsic }, role }) => /* @__PURE__ */ jsx(SketchArticle, {
|
|
14
|
+
role,
|
|
15
|
+
subject,
|
|
16
|
+
attendableId,
|
|
17
|
+
extrinsic
|
|
18
|
+
})
|
|
19
|
+
}), Surface.create({
|
|
20
|
+
id: "sketchCard",
|
|
21
|
+
filter: AppSurface.object(AppSurface.CardContent, Sketch),
|
|
22
|
+
component: ({ data, role }) => /* @__PURE__ */ jsx(SketchCard, {
|
|
23
|
+
role,
|
|
24
|
+
subject: data.subject,
|
|
25
|
+
editable: data.editable
|
|
26
|
+
})
|
|
27
|
+
})])));
|
|
28
|
+
//#endregion
|
|
29
|
+
export { react_surface_default as default };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=chunk-react-surface.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-react-surface.mjs","names":[],"sources":["../../src/capabilities/react-surface.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { Surface } from '@dxos/app-framework/ui';\nimport { AppSurface } from '@dxos/app-toolkit/ui';\n\nimport { SketchArticle, SketchCard } from '#containers';\n\nimport { Sketch } from '../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Capabilities.ReactSurface, [\n Surface.create({\n id: 'sketch',\n filter: AppSurface.oneOf(\n AppSurface.object(AppSurface.Article, Sketch.Sketch),\n AppSurface.object(AppSurface.Section, Sketch.Sketch),\n AppSurface.object(AppSurface.Slide, Sketch.Sketch),\n ),\n component: ({ data: { subject, attendableId, extrinsic }, role }) => (\n <SketchArticle role={role} subject={subject} attendableId={attendableId} extrinsic={extrinsic} />\n ),\n }),\n Surface.create({\n id: 'sketchCard',\n filter: AppSurface.object(AppSurface.CardContent, Sketch.Sketch),\n component: ({ data, role }) => <SketchCard role={role} subject={data.subject} editable={data.editable} />,\n }),\n ]),\n ),\n);\n"],"mappings":";;;;;;;;;AAeA,IAAA,wBAAe,WAAW,iBACxB,OAAO,QACL,WAAW,YAAY,aAAa,cAAc,CAChD,QAAQ,OAAO;CACb,IAAI;CACJ,QAAQ,WAAW,MACjB,WAAW,OAAO,WAAW,SAAS,MAAa,GACnD,WAAW,OAAO,WAAW,SAAS,MAAa,GACnD,WAAW,OAAO,WAAW,OAAO,MAAa,CACnD;CACA,YAAY,EAAE,MAAM,EAAE,SAAS,cAAc,aAAa,WACxD,oBAAC,eAAD;EAAqB;EAAe;EAAuB;EAAyB;CAAY,CAAA;AAEpG,CAAC,GACD,QAAQ,OAAO;CACb,IAAI;CACJ,QAAQ,WAAW,OAAO,WAAW,aAAa,MAAa;CAC/D,YAAY,EAAE,MAAM,WAAW,oBAAC,YAAD;EAAkB;EAAM,SAAS,KAAK;EAAS,UAAU,KAAK;CAAW,CAAA;AAC1G,CAAC,CACH,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { r as Read } from "./chunk-types.mjs";
|
|
2
|
+
import { i as resolveVariant } from "./chunk-load-sketch.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { Operation } from "@dxos/compute";
|
|
5
|
+
//#region src/operations/read.ts
|
|
6
|
+
var handler = Read.pipe(Operation.withHandler(Effect.fn(function* ({ sketch }) {
|
|
7
|
+
const { canvas, variant } = yield* resolveVariant(sketch);
|
|
8
|
+
return variant.builder.read(canvas);
|
|
9
|
+
})));
|
|
10
|
+
//#endregion
|
|
11
|
+
export { handler as default };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=chunk-read.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-read.mjs","names":[],"sources":["../../src/operations/read.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Operation } from '@dxos/compute';\n\nimport { SketchOperation } from '../types';\nimport { resolveVariant } from '../util/load-sketch';\n\nconst handler: Operation.WithHandler<typeof SketchOperation.Read> = SketchOperation.Read.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ sketch }) {\n const { canvas, variant } = yield* resolveVariant(sketch);\n return variant.builder.read(canvas);\n }),\n ),\n);\n\nexport default handler;\n"],"mappings":";;;;;AAWA,IAAM,UAAA,KAAmF,KACvF,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,UAAU;CAC/B,MAAM,EAAE,QAAQ,YAAY,OAAO,eAAe,MAAM;CACxD,OAAO,QAAQ,QAAQ,KAAK,MAAM;AACpC,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Capability } from "@dxos/app-framework";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
4
|
+
import { SketchSkill } from "#skills";
|
|
5
|
+
//#region src/capabilities/skill-definition.ts
|
|
6
|
+
var skillDefinition = () => Effect.succeed([Capability.contributes(AppCapabilities.SkillDefinition, SketchSkill)]);
|
|
7
|
+
//#endregion
|
|
8
|
+
export { skillDefinition as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=chunk-skill-definition.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-skill-definition.mjs","names":[],"sources":["../../src/capabilities/skill-definition.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\n\nimport { SketchSkill } from '#skills';\n\nconst skillDefinition = () => Effect.succeed([Capability.contributes(AppCapabilities.SkillDefinition, SketchSkill)]);\n\nexport default skillDefinition;\n"],"mappings":";;;;;AAWA,IAAM,wBAAwB,OAAO,QAAQ,CAAC,WAAW,YAAY,gBAAgB,iBAAiB,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { trim } from "@dxos/util";
|
|
2
|
+
import { Skill, Template } from "@dxos/compute";
|
|
3
|
+
import { SketchOperation } from "#types";
|
|
4
|
+
//#region src/skills/sketch-skill.ts
|
|
5
|
+
var SKILL_KEY = "org.dxos.skill.sketch";
|
|
6
|
+
var operations = [
|
|
7
|
+
SketchOperation.Create,
|
|
8
|
+
SketchOperation.Read,
|
|
9
|
+
SketchOperation.Edit
|
|
10
|
+
];
|
|
11
|
+
var make = () => Skill.make({
|
|
12
|
+
key: SKILL_KEY,
|
|
13
|
+
name: "Sketch",
|
|
14
|
+
tools: Skill.toolDefinitions({ operations }),
|
|
15
|
+
instructions: Template.make({ source: trim`
|
|
16
|
+
{{! Sketch }}
|
|
17
|
+
|
|
18
|
+
You can draw and edit diagrams on a shared canvas using a scene DSL.
|
|
19
|
+
|
|
20
|
+
## Model
|
|
21
|
+
|
|
22
|
+
A drawing is a set of WORLD OBJECTS — semantic things like "face", "hat", "server" —
|
|
23
|
+
each composed of graphical ELEMENTS (rect, ellipse, circle, diamond, triangle, line,
|
|
24
|
+
curve, arc, text, arrow). You do the layout; there is no auto-layout.
|
|
25
|
+
|
|
26
|
+
- Give objects and elements short, semantic ids ("face", "left-eye"). Ids are how you
|
|
27
|
+
edit or delete things later — choose them as carefully as variable names.
|
|
28
|
+
- Element coordinates are OBJECT-LOCAL units. Design each object in roughly a 100-unit
|
|
29
|
+
box. The object's "origin" (canvas px) and "scale" (px per unit) place it on the
|
|
30
|
+
canvas: canvas = origin + local * scale. Prefer scale 2-3 for a primary subject.
|
|
31
|
+
- Screen coordinates: x grows right, y grows DOWN. Arc angles are degrees clockwise
|
|
32
|
+
from the +x axis: startAngle 30, endAngle 150 bulges downward (a smile);
|
|
33
|
+
210 to 330 bulges upward (a frown).
|
|
34
|
+
- Circle is sugar for ellipse (reads back as ellipse); arc is sugar for curve.
|
|
35
|
+
- Arrows can bind to elements: from/to is an element id in the same object, or
|
|
36
|
+
"objectId/elementId" across objects. Bound arrows track their targets.
|
|
37
|
+
- Styles: color (named palette), fill (none | solid | pattern),
|
|
38
|
+
stroke (sketchy | solid | dashed | dotted), weight (s | m | l | xl).
|
|
39
|
+
|
|
40
|
+
## Workflow
|
|
41
|
+
|
|
42
|
+
1. If no sketch exists in context, create one first.
|
|
43
|
+
2. ALWAYS call read before editing an existing sketch — it returns the scene as you
|
|
44
|
+
(or the user) last left it, with origins derived from the live canvas, so it stays
|
|
45
|
+
correct even after the user drags shapes around. Note "unmanaged" counts shapes the
|
|
46
|
+
user drew by hand that are not part of the scene.
|
|
47
|
+
3. Edit with commands, in one batch where possible:
|
|
48
|
+
- upsert-object: create a new object, or redraw one wholesale.
|
|
49
|
+
- upsert-elements: add or replace specific elements of an object — prefer this for
|
|
50
|
+
incremental changes ("make the smile bigger" replaces only "smile").
|
|
51
|
+
- remove-elements / remove-object: delete by id.
|
|
52
|
+
- move-object: reposition an object (canvas px) without resending its elements.
|
|
53
|
+
4. Compose scenes from multiple objects: "add a hat" means a NEW "hat" object placed
|
|
54
|
+
relative to the existing object's origin and size (from read) — do not redraw the
|
|
55
|
+
existing object.
|
|
56
|
+
` })
|
|
57
|
+
});
|
|
58
|
+
var skill = {
|
|
59
|
+
key: SKILL_KEY,
|
|
60
|
+
make
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { skill as t };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=chunk-skills.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-skills.mjs","names":[],"sources":["../../src/skills/sketch-skill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Skill, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { SketchOperation } from '#types';\n\nconst SKILL_KEY = 'org.dxos.skill.sketch';\n\nconst operations = [SketchOperation.Create, SketchOperation.Read, SketchOperation.Edit];\n\nconst make = () =>\n Skill.make({\n key: SKILL_KEY,\n name: 'Sketch',\n tools: Skill.toolDefinitions({ operations }),\n instructions: Template.make({\n source: trim`\n {{! Sketch }}\n\n You can draw and edit diagrams on a shared canvas using a scene DSL.\n\n ## Model\n\n A drawing is a set of WORLD OBJECTS — semantic things like \"face\", \"hat\", \"server\" —\n each composed of graphical ELEMENTS (rect, ellipse, circle, diamond, triangle, line,\n curve, arc, text, arrow). You do the layout; there is no auto-layout.\n\n - Give objects and elements short, semantic ids (\"face\", \"left-eye\"). Ids are how you\n edit or delete things later — choose them as carefully as variable names.\n - Element coordinates are OBJECT-LOCAL units. Design each object in roughly a 100-unit\n box. The object's \"origin\" (canvas px) and \"scale\" (px per unit) place it on the\n canvas: canvas = origin + local * scale. Prefer scale 2-3 for a primary subject.\n - Screen coordinates: x grows right, y grows DOWN. Arc angles are degrees clockwise\n from the +x axis: startAngle 30, endAngle 150 bulges downward (a smile);\n 210 to 330 bulges upward (a frown).\n - Circle is sugar for ellipse (reads back as ellipse); arc is sugar for curve.\n - Arrows can bind to elements: from/to is an element id in the same object, or\n \"objectId/elementId\" across objects. Bound arrows track their targets.\n - Styles: color (named palette), fill (none | solid | pattern),\n stroke (sketchy | solid | dashed | dotted), weight (s | m | l | xl).\n\n ## Workflow\n\n 1. If no sketch exists in context, create one first.\n 2. ALWAYS call read before editing an existing sketch — it returns the scene as you\n (or the user) last left it, with origins derived from the live canvas, so it stays\n correct even after the user drags shapes around. Note \"unmanaged\" counts shapes the\n user drew by hand that are not part of the scene.\n 3. Edit with commands, in one batch where possible:\n - upsert-object: create a new object, or redraw one wholesale.\n - upsert-elements: add or replace specific elements of an object — prefer this for\n incremental changes (\"make the smile bigger\" replaces only \"smile\").\n - remove-elements / remove-object: delete by id.\n - move-object: reposition an object (canvas px) without resending its elements.\n 4. Compose scenes from multiple objects: \"add a hat\" means a NEW \"hat\" object placed\n relative to the existing object's origin and size (from read) — do not redraw the\n existing object.\n `,\n }),\n });\n\nconst skill: Skill.Definition = {\n key: SKILL_KEY,\n make,\n};\n\nexport default skill;\n"],"mappings":";;;;AASA,IAAM,YAAY;AAElB,IAAM,aAAa;CAAC,gBAAgB;CAAQ,gBAAgB;CAAM,gBAAgB;AAAI;AAEtF,IAAM,aACJ,MAAM,KAAK;CACT,KAAK;CACL,MAAM;CACN,OAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC;CAC3C,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0Cd,CAAC;AACH,CAAC;AAEH,IAAM,QAA0B;CAC9B,KAAK;CACL;AACF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import "./chunk-IllustratorCapabilities.mjs";
|
|
3
|
+
import { Capability } from "@dxos/app-framework";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { Operation } from "@dxos/compute";
|
|
6
|
+
import { meta } from "#meta";
|
|
7
|
+
import { Annotation, DXN, Database, Obj, Ref, Type } from "@dxos/echo";
|
|
8
|
+
import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/Annotation";
|
|
9
|
+
import { CardAnnotation, CollectionItemAnnotation } from "@dxos/schema";
|
|
10
|
+
import { DXN as DXN$1 } from "@dxos/keys";
|
|
11
|
+
import { Scene } from "#model";
|
|
12
|
+
//#region src/types/Sketch.ts
|
|
13
|
+
var Sketch_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
Sketch: () => Sketch,
|
|
15
|
+
SketchRef: () => SketchRef,
|
|
16
|
+
isSketch: () => isSketch,
|
|
17
|
+
make: () => make
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Base Sketch object. Renderer-specific canvas data lives in a separate referenced object.
|
|
21
|
+
* Unifies all canvas renderers (tldraw, excalidraw, ...) under one typename so they share
|
|
22
|
+
* graph node, create flow, and shared surface scaffolding.
|
|
23
|
+
*/
|
|
24
|
+
var Sketch = class extends Type.makeObject(DXN.make("org.dxos.type.sketch", "0.1.0"))(Schema.Struct({
|
|
25
|
+
name: Schema.optional(Schema.String),
|
|
26
|
+
canvas: Ref.Ref(Obj.Unknown).annotations({ description: "Reference to the renderer-specific canvas object." }).pipe(FormInputAnnotation.set(false))
|
|
27
|
+
}).pipe(LabelAnnotation.set(["name"]), Annotation.IconAnnotation.set({
|
|
28
|
+
icon: "ph--compass-tool--regular",
|
|
29
|
+
hue: "indigo"
|
|
30
|
+
}), CardAnnotation.set(true), CollectionItemAnnotation.set(true))) {};
|
|
31
|
+
var SketchRef = (_canvasType) => Ref.Ref(Sketch);
|
|
32
|
+
/**
|
|
33
|
+
* Build a base `Sketch` object referencing the given canvas ECHO object.
|
|
34
|
+
*
|
|
35
|
+
* The canvas is stored as a `Ref` so the renderer-specific data (e.g. `Tldraw.Canvas`,
|
|
36
|
+
* `Excalidraw.Canvas`) lives as its own ECHO object alongside the Sketch.
|
|
37
|
+
*
|
|
38
|
+
* @param name Optional display name shown in the graph node and Properties form.
|
|
39
|
+
* @param canvas Renderer-specific canvas object.
|
|
40
|
+
* @returns A new `Sketch` object with `canvas` stored as a Ref.
|
|
41
|
+
*/
|
|
42
|
+
var make = ({ name, canvas }) => {
|
|
43
|
+
return Obj.make(Sketch, {
|
|
44
|
+
name,
|
|
45
|
+
canvas: Ref.make(canvas)
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/** Type guard for {@link Sketch} objects. */
|
|
49
|
+
var isSketch = (object) => Obj.instanceOf(Sketch, object);
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/types/SketchOperation.ts
|
|
52
|
+
var SketchOperation_exports = /* @__PURE__ */ __exportAll({
|
|
53
|
+
Create: () => Create,
|
|
54
|
+
Edit: () => Edit,
|
|
55
|
+
Read: () => Read
|
|
56
|
+
});
|
|
57
|
+
var makeKey = (name) => DXN$1.make(`${meta.profile.key}.operation.${name}`);
|
|
58
|
+
var Create = Operation.make({
|
|
59
|
+
meta: {
|
|
60
|
+
key: makeKey("create"),
|
|
61
|
+
name: "Create Sketch",
|
|
62
|
+
icon: "ph--pencil-simple--regular"
|
|
63
|
+
},
|
|
64
|
+
input: Schema.Struct({
|
|
65
|
+
name: Schema.optional(Schema.String),
|
|
66
|
+
variant: Schema.optional(Schema.String).annotations({ description: "Variant id (canvas typename); defaults to the first registered variant." })
|
|
67
|
+
}),
|
|
68
|
+
output: Schema.Struct({ object: Type.getSchema(Sketch) }),
|
|
69
|
+
services: [Capability.Service, Database.Service]
|
|
70
|
+
});
|
|
71
|
+
/** The scene as derived from the live canvas. */
|
|
72
|
+
var SceneOutput = {
|
|
73
|
+
scene: Scene.Scene.annotations({ description: "The diagram as world objects with object-local coordinates." }),
|
|
74
|
+
unmanaged: Schema.Number.annotations({ description: "Number of shapes on the canvas not managed by the DSL (drawn by users)." })
|
|
75
|
+
};
|
|
76
|
+
var Read = Operation.make({
|
|
77
|
+
meta: {
|
|
78
|
+
key: makeKey("read"),
|
|
79
|
+
name: "Read Sketch",
|
|
80
|
+
description: "Returns the current scene of a sketch: world objects (by id) with their elements in object-local units. Call before editing an existing sketch.",
|
|
81
|
+
icon: "ph--eye--regular"
|
|
82
|
+
},
|
|
83
|
+
input: Schema.Struct({ sketch: Ref.Ref(Sketch).annotations({ description: "The sketch to read." }) }),
|
|
84
|
+
output: Schema.Struct(SceneOutput),
|
|
85
|
+
services: [Capability.Service, Database.Service]
|
|
86
|
+
});
|
|
87
|
+
var Edit = Operation.make({
|
|
88
|
+
meta: {
|
|
89
|
+
key: makeKey("edit"),
|
|
90
|
+
name: "Edit Sketch",
|
|
91
|
+
description: "Applies scene commands to a sketch: upsert/move/remove world objects or individual elements by id. Returns the resulting scene.",
|
|
92
|
+
icon: "ph--pencil-simple-line--regular"
|
|
93
|
+
},
|
|
94
|
+
input: Schema.Struct({
|
|
95
|
+
sketch: Ref.Ref(Sketch).annotations({ description: "The sketch to edit." }),
|
|
96
|
+
commands: Schema.Array(Scene.Command).annotations({ description: "Commands applied in order, atomically." })
|
|
97
|
+
}),
|
|
98
|
+
output: Schema.Struct({
|
|
99
|
+
...SceneOutput,
|
|
100
|
+
upserted: Schema.Array(Schema.String).annotations({ description: "Object ids created or modified." }),
|
|
101
|
+
removed: Schema.Number.annotations({ description: "Number of shapes removed." })
|
|
102
|
+
}),
|
|
103
|
+
services: [Capability.Service, Database.Service]
|
|
104
|
+
});
|
|
105
|
+
//#endregion
|
|
106
|
+
export { Sketch as a, SketchOperation_exports as i, Edit as n, Sketch_exports as o, Read as r, make as s, Create as t };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=chunk-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-types.mjs","names":[],"sources":["../../src/types/Sketch.ts","../../src/types/SketchOperation.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, DXN, Obj, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/Annotation';\nimport { CardAnnotation, CollectionItemAnnotation } from '@dxos/schema';\n\n/**\n * Base Sketch object. Renderer-specific canvas data lives in a separate referenced object.\n * Unifies all canvas renderers (tldraw, excalidraw, ...) under one typename so they share\n * graph node, create flow, and shared surface scaffolding.\n */\nexport class Sketch extends Type.makeObject<Sketch>(DXN.make('org.dxos.type.sketch', '0.1.0'))(\n Schema.Struct({\n name: Schema.optional(Schema.String),\n canvas: Ref.Ref(Obj.Unknown)\n .annotations({ description: 'Reference to the renderer-specific canvas object.' })\n .pipe(FormInputAnnotation.set(false)),\n }).pipe(\n LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--compass-tool--regular', hue: 'indigo' }),\n CardAnnotation.set(true),\n CollectionItemAnnotation.set(true),\n ),\n) {}\n\n/**\n * Variant-narrowed reference to a Sketch.\n *\n * Encodes — at the type level — that the canvas ref points to a specific canvas type.\n * Runtime narrowing is performed by `loadSketch(ref, canvasType)` which validates and\n * returns the resolved Sketch together with its typed canvas.\n *\n * @example\n * ```ts\n * input: Schema.Struct({\n * sketch: SketchRef(Tldraw.Canvas),\n * }),\n * // handler:\n * const { sketch, canvas } = yield* loadSketch(input.sketch, Tldraw.Canvas);\n * // `canvas` is typed as Tldraw.Canvas.\n * ```\n */\nexport type SketchRef<_V> = Ref.Ref<Sketch>;\n\nexport const SketchRef = <S extends Type.AnyObj>(_canvasType: S) =>\n Ref.Ref(Sketch) as Schema.Schema<SketchRef<Type.InstanceType<S>>, any, never>;\n\n/**\n * Build a base `Sketch` object referencing the given canvas ECHO object.\n *\n * The canvas is stored as a `Ref` so the renderer-specific data (e.g. `Tldraw.Canvas`,\n * `Excalidraw.Canvas`) lives as its own ECHO object alongside the Sketch.\n *\n * @param name Optional display name shown in the graph node and Properties form.\n * @param canvas Renderer-specific canvas object.\n * @returns A new `Sketch` object with `canvas` stored as a Ref.\n */\nexport const make = ({ name, canvas }: { name?: string; canvas: Obj.Unknown }): Sketch => {\n return Obj.make(Sketch, { name, canvas: Ref.make(canvas) });\n};\n\n/** Type guard for {@link Sketch} objects. */\nexport const isSketch = (object: unknown): object is Sketch => Obj.instanceOf(Sketch, object);\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport { Operation } from '@dxos/compute';\nimport { Database, Ref, Type } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\n\nimport { meta } from '#meta';\nimport { Scene } from '#model';\n\nimport * as Sketch from './Sketch';\n\nconst makeKey = (name: string) => DXN.make(`${meta.profile.key}.operation.${name}`);\n\nexport const Create = Operation.make({\n meta: { key: makeKey('create'), name: 'Create Sketch', icon: 'ph--pencil-simple--regular' },\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n variant: Schema.optional(Schema.String).annotations({\n description: 'Variant id (canvas typename); defaults to the first registered variant.',\n }),\n }),\n output: Schema.Struct({\n object: Type.getSchema(Sketch.Sketch),\n }),\n services: [Capability.Service, Database.Service],\n});\n\n/** The scene as derived from the live canvas. */\nconst SceneOutput = {\n scene: Scene.Scene.annotations({ description: 'The diagram as world objects with object-local coordinates.' }),\n unmanaged: Schema.Number.annotations({\n description: 'Number of shapes on the canvas not managed by the DSL (drawn by users).',\n }),\n};\n\nexport const Read = Operation.make({\n meta: {\n key: makeKey('read'),\n name: 'Read Sketch',\n description:\n 'Returns the current scene of a sketch: world objects (by id) with their elements in object-local units. Call before editing an existing sketch.',\n icon: 'ph--eye--regular',\n },\n input: Schema.Struct({\n sketch: Ref.Ref(Sketch.Sketch).annotations({ description: 'The sketch to read.' }),\n }),\n output: Schema.Struct(SceneOutput),\n services: [Capability.Service, Database.Service],\n});\n\nexport const Edit = Operation.make({\n meta: {\n key: makeKey('edit'),\n name: 'Edit Sketch',\n description:\n 'Applies scene commands to a sketch: upsert/move/remove world objects or individual elements by id. Returns the resulting scene.',\n icon: 'ph--pencil-simple-line--regular',\n },\n input: Schema.Struct({\n sketch: Ref.Ref(Sketch.Sketch).annotations({ description: 'The sketch to edit.' }),\n commands: Schema.Array(Scene.Command).annotations({ description: 'Commands applied in order, atomically.' }),\n }),\n output: Schema.Struct({\n ...SceneOutput,\n upserted: Schema.Array(Schema.String).annotations({ description: 'Object ids created or modified.' }),\n removed: Schema.Number.annotations({ description: 'Number of shapes removed.' }),\n }),\n services: [Capability.Service, Database.Service],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAa,SAAb,cAA4B,KAAK,WAAmB,IAAI,KAAK,wBAAwB,OAAO,CAAC,CAAC,CAC5F,OAAO,OAAO;CACZ,MAAM,O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AAK,QAAQ,MAAM;EACnB,MAAM;EACN,aACE;EACF,MAAM;CACR;CACA,OAAO,OAAO,OAAO,EACnB,QAAQ,IAAI,IAAI,MAAa,CAAC,CAAC,YAAY,EAAE,aAAa,sBAAsB,CAAC,EACnF,CAAC;CACD,QAAQ,OAAO,OAAO,WAAW;CACjC,UAAU,CAAC,WAAW,SAAS,SAAS,OAAO;AACjD,CAAC;AAED,IAAa,OAAO,UAAU,KAAK;CACjC,MAAM;EACJ,KAAK,QAAQ,MAAM;EACnB,MAAM;EACN,aACE;EACF,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,QAAQ,IAAI,IAAI,MAAa,CAAC,CAAC,YAAY,EAAE,aAAa,sBAAsB,CAAC;EACjF,UAAU,OAAO,MAAM,MAAM,OAAO,CAAC,CAAC,YAAY,EAAE,aAAa,yCAAyC,CAAC;CAC7G,CAAC;CACD,QAAQ,OAAO,OAAO;EACpB,GAAG;EACH,UAAU,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,EAAE,aAAa,kCAAkC,CAAC;EACpG,SAAS,OAAO,OAAO,YAAY,EAAE,aAAa,4BAA4B,CAAC;CACjF,CAAC;CACD,UAAU,CAAC,WAAW,SAAS,SAAS,OAAO;AACjD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IllustratorCapabilities } from "#types";
|
|
2
|
+
import { meta } from "#meta";
|
|
3
|
+
import { useCallback, useMemo } from "react";
|
|
4
|
+
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
5
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
6
|
+
import { SearchList, useSearchListResults } from "@dxos/react-ui-search";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/CreateSketchPanel.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Variant picker for sketches (SearchList over contributed `SketchVariant[]`).
|
|
11
|
+
* On select, calls `onCreateObject({ variantId })`; plugin-illustrator's
|
|
12
|
+
* CreateObjectEntry.createObject resolves the variantId, builds the canvas via
|
|
13
|
+
* variant.createCanvas, then wraps it in a Sketch.
|
|
14
|
+
*/
|
|
15
|
+
var CreateSketchPanel = ({ onCreateObject, variants: variantsProp }) => {
|
|
16
|
+
const { t } = useTranslation(meta.profile.key);
|
|
17
|
+
const capabilityVariants = useCapabilities(IllustratorCapabilities.VariantProvider);
|
|
18
|
+
const variants = variantsProp ?? capabilityVariants;
|
|
19
|
+
const { results, handleSearch } = useSearchListResults({
|
|
20
|
+
items: useMemo(() => [...variants].sort((a, b) => a.label.localeCompare(b.label)), [variants]),
|
|
21
|
+
extract: (variant) => variant.label
|
|
22
|
+
});
|
|
23
|
+
const handleSelect = useCallback((id) => {
|
|
24
|
+
if (!variants.find((entry) => entry.id === id)) return;
|
|
25
|
+
onCreateObject({ variantId: id });
|
|
26
|
+
}, [variants, onCreateObject]);
|
|
27
|
+
return /* @__PURE__ */ jsxs(SearchList.Root, {
|
|
28
|
+
onSearch: handleSearch,
|
|
29
|
+
children: [/* @__PURE__ */ jsx(SearchList.Input, {
|
|
30
|
+
classNames: "mb-form-gap",
|
|
31
|
+
autoFocus: true,
|
|
32
|
+
"data-testid": "create-sketch-panel.variant-input",
|
|
33
|
+
placeholder: t("create-panel.variant.placeholder")
|
|
34
|
+
}), /* @__PURE__ */ jsx(SearchList.Viewport, { children: results.map((variant) => /* @__PURE__ */ jsx(SearchList.Item, {
|
|
35
|
+
value: variant.id,
|
|
36
|
+
label: variant.label,
|
|
37
|
+
icon: variant.icon ?? "ph--compass-tool--regular",
|
|
38
|
+
onSelect: () => handleSelect(variant.id)
|
|
39
|
+
}, variant.id)) })]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { CreateSketchPanel };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.mjs","names":[],"sources":["../../src/components/CreateSketchPanel.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { useCapabilities } from '@dxos/app-framework/ui';\nimport { type SpaceCapabilities } from '@dxos/plugin-space';\nimport { useTranslation } from '@dxos/react-ui';\nimport { SearchList, useSearchListResults } from '@dxos/react-ui-search';\n\nimport { meta } from '#meta';\nimport { IllustratorCapabilities, type SketchVariant } from '#types';\n\nexport type CreateSketchPanelProps = SpaceCapabilities.CreateObjectCustomPanelProps & {\n /** Optional override (primarily for stories/tests). Defaults to IllustratorCapabilities.VariantProvider. */\n variants?: SketchVariant[];\n};\n\n/**\n * Variant picker for sketches (SearchList over contributed `SketchVariant[]`).\n * On select, calls `onCreateObject({ variantId })`; plugin-illustrator's\n * CreateObjectEntry.createObject resolves the variantId, builds the canvas via\n * variant.createCanvas, then wraps it in a Sketch.\n */\nexport const CreateSketchPanel = ({ onCreateObject, variants: variantsProp }: CreateSketchPanelProps) => {\n const { t } = useTranslation(meta.profile.key);\n const capabilityVariants = useCapabilities(IllustratorCapabilities.VariantProvider);\n const variants = variantsProp ?? capabilityVariants;\n const sorted = useMemo(() => [...variants].sort((a, b) => a.label.localeCompare(b.label)), [variants]);\n const { results, handleSearch } = useSearchListResults({\n items: sorted,\n extract: (variant) => variant.label,\n });\n\n const handleSelect = useCallback(\n (id: string) => {\n const variant = variants.find((entry) => entry.id === id);\n if (!variant) {\n return;\n }\n void onCreateObject({ variantId: id });\n },\n [variants, onCreateObject],\n );\n\n return (\n <SearchList.Root onSearch={handleSearch}>\n <SearchList.Input\n classNames='mb-form-gap'\n autoFocus\n data-testid='create-sketch-panel.variant-input'\n placeholder={t('create-panel.variant.placeholder')}\n />\n <SearchList.Viewport>\n {results.map((variant) => (\n <SearchList.Item\n key={variant.id}\n value={variant.id}\n label={variant.label}\n icon={variant.icon ?? 'ph--compass-tool--regular'}\n onSelect={() => handleSelect(variant.id)}\n />\n ))}\n </SearchList.Viewport>\n </SearchList.Root>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAyBA,IAAa,qBAAqB,EAAE,gBAAgB,UAAU,mBAA2C;CACvG,MAAM,EAAE,MAAM,eAAe,KAAK,QAAQ,GAAG;CAC7C,MAAM,qBAAqB,gBAAgB,wBAAwB,eAAe;CAClF,MAAM,WAAW,gBAAgB;CAEjC,MAAM,EAAE,SAAS,iBAAiB,qBAAqB;EACrD,OAFa,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAE3F;EACP,UAAU,YAAY,QAAQ;CAChC,CAAC;CAED,MAAM,eAAe,aAClB,OAAe;EAEd,IAAI,CADY,SAAS,MAAM,UAAU,MAAM,OAAO,EACjD,GACH;EAEF,eAAoB,EAAE,WAAW,GAAG,CAAC;CACvC,GACA,CAAC,UAAU,cAAc,CAC3B;CAEA,OACE,qBAAC,WAAW,MAAZ;EAAiB,UAAU;YAA3B,CACE,oBAAC,WAAW,OAAZ;GACE,YAAW;GACX,WAAA;GACA,eAAY;GACZ,aAAa,EAAE,kCAAkC;EAClD,CAAA,GACD,oBAAC,WAAW,UAAZ,EAAA,UACG,QAAQ,KAAK,YACZ,oBAAC,WAAW,MAAZ;GAEE,OAAO,QAAQ;GACf,OAAO,QAAQ;GACf,MAAM,QAAQ,QAAQ;GACtB,gBAAgB,aAAa,QAAQ,EAAE;EACxC,GALM,QAAQ,EAKd,CACF,EACkB,CAAA,CACN;;AAErB"}
|