@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.
Files changed (172) hide show
  1. package/LICENSE +105 -0
  2. package/PLUGIN.mdl +55 -0
  3. package/dist/lib/IllustratorPlugin.mjs +18 -0
  4. package/dist/lib/IllustratorPlugin.mjs.map +1 -0
  5. package/dist/lib/IllustratorPlugin.node.mjs +18 -0
  6. package/dist/lib/IllustratorPlugin.node.mjs.map +1 -0
  7. package/dist/lib/IllustratorPlugin.workerd.mjs +10 -0
  8. package/dist/lib/IllustratorPlugin.workerd.mjs.map +1 -0
  9. package/dist/lib/capabilities.mjs +11 -0
  10. package/dist/lib/capabilities.mjs.map +1 -0
  11. package/dist/lib/chunk-IllustratorCapabilities.mjs +16 -0
  12. package/dist/lib/chunk-IllustratorCapabilities.mjs.map +1 -0
  13. package/dist/lib/chunk-comment-config.mjs +16 -0
  14. package/dist/lib/chunk-comment-config.mjs.map +1 -0
  15. package/dist/lib/chunk-create-object.mjs +46 -0
  16. package/dist/lib/chunk-create-object.mjs.map +1 -0
  17. package/dist/lib/chunk-create.mjs +20 -0
  18. package/dist/lib/chunk-create.mjs.map +1 -0
  19. package/dist/lib/chunk-edit.mjs +20 -0
  20. package/dist/lib/chunk-edit.mjs.map +1 -0
  21. package/dist/lib/chunk-load-sketch.mjs +64 -0
  22. package/dist/lib/chunk-load-sketch.mjs.map +1 -0
  23. package/dist/lib/chunk-meta.mjs +40 -0
  24. package/dist/lib/chunk-meta.mjs.map +1 -0
  25. package/dist/lib/chunk-model.mjs +202 -0
  26. package/dist/lib/chunk-model.mjs.map +1 -0
  27. package/dist/lib/chunk-operation-handler.mjs +11 -0
  28. package/dist/lib/chunk-operation-handler.mjs.map +1 -0
  29. package/dist/lib/chunk-react-surface.mjs +31 -0
  30. package/dist/lib/chunk-react-surface.mjs.map +1 -0
  31. package/dist/lib/chunk-read.mjs +13 -0
  32. package/dist/lib/chunk-read.mjs.map +1 -0
  33. package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
  34. package/dist/lib/chunk-skill-definition.mjs +10 -0
  35. package/dist/lib/chunk-skill-definition.mjs.map +1 -0
  36. package/dist/lib/chunk-skills.mjs +65 -0
  37. package/dist/lib/chunk-skills.mjs.map +1 -0
  38. package/dist/lib/chunk-types.mjs +108 -0
  39. package/dist/lib/chunk-types.mjs.map +1 -0
  40. package/dist/lib/components.mjs +45 -0
  41. package/dist/lib/components.mjs.map +1 -0
  42. package/dist/lib/containers.mjs +58 -0
  43. package/dist/lib/containers.mjs.map +1 -0
  44. package/dist/lib/index.mjs +9 -0
  45. package/dist/lib/meta.mjs +2 -0
  46. package/dist/lib/model.mjs +2 -0
  47. package/dist/lib/operations.mjs +7 -0
  48. package/dist/lib/operations.mjs.map +1 -0
  49. package/dist/lib/plugin.mjs +9 -0
  50. package/dist/lib/plugin.mjs.map +1 -0
  51. package/dist/lib/skills.mjs +2 -0
  52. package/dist/lib/translations.mjs +27 -0
  53. package/dist/lib/translations.mjs.map +1 -0
  54. package/dist/lib/types.mjs +3 -0
  55. package/dist/lib/util.mjs +2 -0
  56. package/dist/types/dx.config.d.ts +28 -0
  57. package/dist/types/dx.config.d.ts.map +1 -0
  58. package/dist/types/src/IllustratorPlugin.d.ts +4 -0
  59. package/dist/types/src/IllustratorPlugin.d.ts.map +1 -0
  60. package/dist/types/src/IllustratorPlugin.node.d.ts +10 -0
  61. package/dist/types/src/IllustratorPlugin.node.d.ts.map +1 -0
  62. package/dist/types/src/IllustratorPlugin.workerd.d.ts +4 -0
  63. package/dist/types/src/IllustratorPlugin.workerd.d.ts.map +1 -0
  64. package/dist/types/src/capabilities/comment-config.d.ts +5 -0
  65. package/dist/types/src/capabilities/comment-config.d.ts.map +1 -0
  66. package/dist/types/src/capabilities/create-object.d.ts +5 -0
  67. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  68. package/dist/types/src/capabilities/index.d.ts +8 -0
  69. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  70. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  71. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  72. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  73. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  74. package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
  75. package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
  76. package/dist/types/src/components/CreateSketchPanel.d.ts +15 -0
  77. package/dist/types/src/components/CreateSketchPanel.d.ts.map +1 -0
  78. package/dist/types/src/components/index.d.ts +2 -0
  79. package/dist/types/src/components/index.d.ts.map +1 -0
  80. package/dist/types/src/containers/SketchArticle/SketchArticle.d.ts +11 -0
  81. package/dist/types/src/containers/SketchArticle/SketchArticle.d.ts.map +1 -0
  82. package/dist/types/src/containers/SketchArticle/index.d.ts +2 -0
  83. package/dist/types/src/containers/SketchArticle/index.d.ts.map +1 -0
  84. package/dist/types/src/containers/SketchCard/SketchCard.d.ts +10 -0
  85. package/dist/types/src/containers/SketchCard/SketchCard.d.ts.map +1 -0
  86. package/dist/types/src/containers/SketchCard/index.d.ts +2 -0
  87. package/dist/types/src/containers/SketchCard/index.d.ts.map +1 -0
  88. package/dist/types/src/containers/index.d.ts +3 -0
  89. package/dist/types/src/containers/index.d.ts.map +1 -0
  90. package/dist/types/src/index.d.ts +7 -0
  91. package/dist/types/src/index.d.ts.map +1 -0
  92. package/dist/types/src/meta.d.ts +33 -0
  93. package/dist/types/src/meta.d.ts.map +1 -0
  94. package/dist/types/src/model/builder.d.ts +32 -0
  95. package/dist/types/src/model/builder.d.ts.map +1 -0
  96. package/dist/types/src/model/dialect.d.ts +19 -0
  97. package/dist/types/src/model/dialect.d.ts.map +1 -0
  98. package/dist/types/src/model/index.d.ts +4 -0
  99. package/dist/types/src/model/index.d.ts.map +1 -0
  100. package/dist/types/src/model/scene.d.ts +843 -0
  101. package/dist/types/src/model/scene.d.ts.map +1 -0
  102. package/dist/types/src/operations/create.d.ts +5 -0
  103. package/dist/types/src/operations/create.d.ts.map +1 -0
  104. package/dist/types/src/operations/edit.d.ts +5 -0
  105. package/dist/types/src/operations/edit.d.ts.map +1 -0
  106. package/dist/types/src/operations/index.d.ts +3 -0
  107. package/dist/types/src/operations/index.d.ts.map +1 -0
  108. package/dist/types/src/operations/read.d.ts +5 -0
  109. package/dist/types/src/operations/read.d.ts.map +1 -0
  110. package/dist/types/src/plugin.d.ts +4 -0
  111. package/dist/types/src/plugin.d.ts.map +1 -0
  112. package/dist/types/src/skills/index.d.ts +2 -0
  113. package/dist/types/src/skills/index.d.ts.map +1 -0
  114. package/dist/types/src/skills/sketch-skill.d.ts +4 -0
  115. package/dist/types/src/skills/sketch-skill.d.ts.map +1 -0
  116. package/dist/types/src/translations.d.ts +34 -0
  117. package/dist/types/src/translations.d.ts.map +1 -0
  118. package/dist/types/src/types/IllustratorCapabilities.d.ts +10 -0
  119. package/dist/types/src/types/IllustratorCapabilities.d.ts.map +1 -0
  120. package/dist/types/src/types/Sketch.d.ts +50 -0
  121. package/dist/types/src/types/Sketch.d.ts.map +1 -0
  122. package/dist/types/src/types/SketchOperation.d.ts +427 -0
  123. package/dist/types/src/types/SketchOperation.d.ts.map +1 -0
  124. package/dist/types/src/types/index.d.ts +5 -0
  125. package/dist/types/src/types/index.d.ts.map +1 -0
  126. package/dist/types/src/types/types.d.ts +45 -0
  127. package/dist/types/src/types/types.d.ts.map +1 -0
  128. package/dist/types/src/util/index.d.ts +2 -0
  129. package/dist/types/src/util/index.d.ts.map +1 -0
  130. package/dist/types/src/util/load-sketch.d.ts +37 -0
  131. package/dist/types/src/util/load-sketch.d.ts.map +1 -0
  132. package/dist/types/tsconfig.tsbuildinfo +1 -0
  133. package/dx.config.ts +35 -0
  134. package/package.json +144 -0
  135. package/src/IllustratorPlugin.node.tsx +27 -0
  136. package/src/IllustratorPlugin.tsx +30 -0
  137. package/src/IllustratorPlugin.workerd.tsx +16 -0
  138. package/src/capabilities/comment-config.ts +20 -0
  139. package/src/capabilities/create-object.ts +66 -0
  140. package/src/capabilities/index.ts +15 -0
  141. package/src/capabilities/operation-handler.ts +16 -0
  142. package/src/capabilities/react-surface.tsx +37 -0
  143. package/src/capabilities/skill-definition.ts +14 -0
  144. package/src/components/CreateSketchPanel.tsx +68 -0
  145. package/src/components/index.ts +5 -0
  146. package/src/containers/SketchArticle/SketchArticle.tsx +48 -0
  147. package/src/containers/SketchArticle/index.ts +5 -0
  148. package/src/containers/SketchCard/SketchCard.tsx +41 -0
  149. package/src/containers/SketchCard/index.ts +5 -0
  150. package/src/containers/index.ts +6 -0
  151. package/src/index.ts +10 -0
  152. package/src/meta.ts +9 -0
  153. package/src/model/builder.ts +41 -0
  154. package/src/model/dialect.ts +53 -0
  155. package/src/model/index.ts +7 -0
  156. package/src/model/scene.ts +208 -0
  157. package/src/operations/create.ts +27 -0
  158. package/src/operations/edit.ts +23 -0
  159. package/src/operations/index.ts +11 -0
  160. package/src/operations/read.ts +21 -0
  161. package/src/plugin.ts +11 -0
  162. package/src/skills/index.ts +5 -0
  163. package/src/skills/sketch-skill.ts +70 -0
  164. package/src/translations.ts +33 -0
  165. package/src/types/IllustratorCapabilities.ts +19 -0
  166. package/src/types/Sketch.ts +69 -0
  167. package/src/types/SketchOperation.ts +76 -0
  168. package/src/types/index.ts +9 -0
  169. package/src/types/types.ts +53 -0
  170. package/src/util/index.ts +5 -0
  171. package/src/util/load-sketch.ts +74 -0
  172. package/src/vite-env.d.ts +10 -0
@@ -0,0 +1,76 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ // @import-as-namespace
6
+
7
+ import * as Schema from 'effect/Schema';
8
+
9
+ import { Capability } from '@dxos/app-framework';
10
+ import { Operation } from '@dxos/compute';
11
+ import { Database, Ref, Type } from '@dxos/echo';
12
+ import { DXN } from '@dxos/keys';
13
+
14
+ import { meta } from '#meta';
15
+ import { Scene } from '#model';
16
+
17
+ import * as Sketch from './Sketch';
18
+
19
+ const makeKey = (name: string) => DXN.make(`${meta.profile.key}.operation.${name}`);
20
+
21
+ export const Create = Operation.make({
22
+ meta: { key: makeKey('create'), name: 'Create Sketch', icon: 'ph--pencil-simple--regular' },
23
+ input: Schema.Struct({
24
+ name: Schema.optional(Schema.String),
25
+ variant: Schema.optional(Schema.String).annotations({
26
+ description: 'Variant id (canvas typename); defaults to the first registered variant.',
27
+ }),
28
+ }),
29
+ output: Schema.Struct({
30
+ object: Type.getSchema(Sketch.Sketch),
31
+ }),
32
+ services: [Capability.Service, Database.Service],
33
+ });
34
+
35
+ /** The scene as derived from the live canvas. */
36
+ const SceneOutput = {
37
+ scene: Scene.Scene.annotations({ description: 'The diagram as world objects with object-local coordinates.' }),
38
+ unmanaged: Schema.Number.annotations({
39
+ description: 'Number of shapes on the canvas not managed by the DSL (drawn by users).',
40
+ }),
41
+ };
42
+
43
+ export const Read = Operation.make({
44
+ meta: {
45
+ key: makeKey('read'),
46
+ name: 'Read Sketch',
47
+ description:
48
+ 'Returns the current scene of a sketch: world objects (by id) with their elements in object-local units. Call before editing an existing sketch.',
49
+ icon: 'ph--eye--regular',
50
+ },
51
+ input: Schema.Struct({
52
+ sketch: Ref.Ref(Sketch.Sketch).annotations({ description: 'The sketch to read.' }),
53
+ }),
54
+ output: Schema.Struct(SceneOutput),
55
+ services: [Capability.Service, Database.Service],
56
+ });
57
+
58
+ export const Edit = Operation.make({
59
+ meta: {
60
+ key: makeKey('edit'),
61
+ name: 'Edit Sketch',
62
+ description:
63
+ 'Applies scene commands to a sketch: upsert/move/remove world objects or individual elements by id. Returns the resulting scene.',
64
+ icon: 'ph--pencil-simple-line--regular',
65
+ },
66
+ input: Schema.Struct({
67
+ sketch: Ref.Ref(Sketch.Sketch).annotations({ description: 'The sketch to edit.' }),
68
+ commands: Schema.Array(Scene.Command).annotations({ description: 'Commands applied in order, atomically.' }),
69
+ }),
70
+ output: Schema.Struct({
71
+ ...SceneOutput,
72
+ upserted: Schema.Array(Schema.String).annotations({ description: 'Object ids created or modified.' }),
73
+ removed: Schema.Number.annotations({ description: 'Number of shapes removed.' }),
74
+ }),
75
+ services: [Capability.Service, Database.Service],
76
+ });
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ export * from './types';
6
+
7
+ export * as IllustratorCapabilities from './IllustratorCapabilities';
8
+ export * as Sketch from './Sketch';
9
+ export * as SketchOperation from './SketchOperation';
@@ -0,0 +1,53 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import type * as Effect from 'effect/Effect';
6
+ import type { ComponentType } from 'react';
7
+
8
+ import type { Database, Obj, Type } from '@dxos/echo';
9
+
10
+ import { type SketchBuilder } from '#model';
11
+
12
+ import type * as Sketch from './Sketch';
13
+
14
+ /**
15
+ * Contribution from a canvas renderer plugin (e.g. plugin-tldraw, plugin-excalidraw).
16
+ * Defines how a sketch variant is created, rendered, and how the scene DSL maps onto it.
17
+ */
18
+ export type SketchVariant = {
19
+ /** Stable id, typically the canvas typename (e.g. 'org.dxos.type.canvas'). */
20
+ id: string;
21
+ /** Human-readable variant name (e.g. 'tldraw'). */
22
+ label: string;
23
+ /** Optional Phosphor icon name (e.g. 'ph--compass-tool--regular'). */
24
+ icon?: string;
25
+ /** ECHO Type entity of the canvas object referenced by `Sketch.canvas`. */
26
+ canvasType: Type.AnyObj;
27
+ /**
28
+ * Build an empty canvas object. May allocate ECHO objects, run effects, etc.
29
+ * Returned object is added to the database alongside the Sketch.
30
+ */
31
+ createCanvas: (input?: Record<string, any>) => Effect.Effect<Obj.Any, Error, Database.Service>;
32
+ /** Maps the scene DSL onto this variant's canvas records. */
33
+ builder: SketchBuilder;
34
+ /** Optional Card surface component for this variant. */
35
+ card?: ComponentType<SketchVariantSurfaceProps>;
36
+ /** Optional Article/Section/Slide surface component for this variant. */
37
+ article?: ComponentType<SketchVariantSurfaceProps>;
38
+ };
39
+
40
+ export type SketchVariantSurfaceProps = {
41
+ /** The base Sketch object (may be a snapshot from useObject/Surface). */
42
+ sketch: Obj.Snapshot<Sketch.Sketch> | Sketch.Sketch;
43
+ /** The resolved LIVE canvas object — variant store adapters need `Doc.createAccessor`. */
44
+ canvas: Obj.Unknown;
45
+ /** Surface role passed through from the host. */
46
+ role?: string;
47
+ /** Attendable id passed through from the host. */
48
+ attendableId?: string;
49
+ /** Card surfaces: whether the card is editable. */
50
+ editable?: boolean;
51
+ /** Section surfaces: whether the embed is extrinsically sized. */
52
+ extrinsic?: boolean;
53
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ export * from './load-sketch';
@@ -0,0 +1,74 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { Database, Obj, type Ref, Type } from '@dxos/echo';
9
+
10
+ import * as IllustratorCapabilities from '../types/IllustratorCapabilities';
11
+ import * as Sketch from '../types/Sketch';
12
+ import { type SketchVariant } from '../types/types';
13
+
14
+ export class SketchVariantMismatchError extends Error {
15
+ readonly _tag = 'SketchVariantMismatchError';
16
+ constructor(
17
+ readonly sketchId: string,
18
+ readonly expectedTypename: string,
19
+ readonly actualTypename: string,
20
+ ) {
21
+ super(`Sketch ${sketchId} canvas typename mismatch: expected ${expectedTypename}, got ${actualTypename}.`);
22
+ }
23
+ }
24
+
25
+ export class UnknownSketchVariantError extends Error {
26
+ readonly _tag = 'UnknownSketchVariantError';
27
+ constructor(readonly typename: string) {
28
+ super(`No sketch variant registered for canvas type: ${typename}.`);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Loads a Sketch from a Ref and resolves its canvas, asserting the canvas matches
34
+ * the expected type. Returns the typed pair.
35
+ *
36
+ * Use in operation handlers that declare `input.sketch: SketchRef<MyCanvas>`.
37
+ */
38
+ export const loadSketch = <S extends Type.AnyObj>(
39
+ ref: Ref.Ref<Sketch.Sketch>,
40
+ canvasType: S,
41
+ ): Effect.Effect<{ sketch: Sketch.Sketch; canvas: Type.InstanceType<S> }, Error, Database.Service> =>
42
+ Effect.gen(function* () {
43
+ const sketch = yield* Database.load(ref);
44
+ const canvas = yield* Database.load(sketch.canvas);
45
+ if (!Obj.instanceOf(canvasType, canvas)) {
46
+ const expected = Type.getTypename(canvasType) ?? 'unknown';
47
+ const actual = Obj.getTypename(canvas as Obj.Any) ?? 'unknown';
48
+ return yield* Effect.fail(new SketchVariantMismatchError(sketch.id, expected, actual));
49
+ }
50
+ return { sketch, canvas: canvas as Type.InstanceType<S> };
51
+ });
52
+
53
+ /**
54
+ * Loads a Sketch and resolves the variant provider matching its canvas typename.
55
+ * Used by the renderer-agnostic read/edit operations.
56
+ */
57
+ export const resolveVariant = (
58
+ ref: Ref.Ref<Sketch.Sketch>,
59
+ ): Effect.Effect<
60
+ { sketch: Sketch.Sketch; canvas: Obj.Any; variant: SketchVariant },
61
+ Error,
62
+ Database.Service | Capability.Service
63
+ > =>
64
+ Effect.gen(function* () {
65
+ const sketch = yield* Database.load(ref);
66
+ const canvas = (yield* Database.load(sketch.canvas)) as Obj.Any;
67
+ const typename = Obj.getTypename(canvas) ?? 'unknown';
68
+ const variants = yield* Capability.getAll(IllustratorCapabilities.VariantProvider);
69
+ const variant = variants.find((entry) => entry.id === typename);
70
+ if (!variant) {
71
+ return yield* Effect.fail(new UnknownSketchVariantError(typename));
72
+ }
73
+ return { sketch, canvas, variant };
74
+ });
@@ -0,0 +1,10 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ //
4
+ // Copyright 2026 DXOS.org
5
+ //
6
+
7
+ declare module '*.mdl?raw' {
8
+ const content: string;
9
+ export default content;
10
+ }