@eclipse-docks/extension-canvas 0.8.15 → 0.8.17

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.
@@ -42,8 +42,8 @@ async function attachPreviewShot(active) {
42
42
  if (!active.capturePreview) return "No canvas is open";
43
43
  const shot = await active.capturePreview();
44
44
  const name = previewFileName(active.getFilePath?.() ?? active.canvasName, shot.mime);
45
- const { cognitiveRuntime } = await import("@eclipse-docks/extension-ai-system/api");
46
- return previewToolOutput(shot, name, (await cognitiveRuntime.addAttachments(void 0, [{
45
+ const { aiRuntime } = await import("@eclipse-docks/extension-ai-system/api");
46
+ return previewToolOutput(shot, name, (await aiRuntime.addAttachments(void 0, [{
47
47
  name,
48
48
  mime: shot.mime,
49
49
  kind: "image",
@@ -1 +1 @@
1
- {"version":3,"file":"preview-image.js","names":[],"sources":["../src/preview-image.ts"],"sourcesContent":["import { domToBlob } from 'modern-screenshot';\n\n/** Same field the specialist loop reads to schedule a follow-up vision message. */\nexport const PREVIEW_IMAGE_KEY = '_presentImage';\n\nconst MAX_BYTES = 3_500_000;\nconst MAX_EDGE = 1600;\n\nexport interface PreviewShot {\n dataUrl: string;\n byteLength: number;\n mime: string;\n}\n\nexport interface StoredPreview {\n id: string;\n name: string;\n path?: string;\n}\n\nexport async function rasterizeElement(element: HTMLElement): Promise<PreviewShot> {\n const rect = element.getBoundingClientRect();\n if (rect.width < 2 || rect.height < 2) throw new Error('Canvas preview has no visible size');\n const width = Math.round(rect.width);\n const height = Math.round(rect.height);\n const options = {\n width,\n height,\n scale: Math.min(2, MAX_EDGE / Math.max(width, height)),\n backgroundColor: opaqueBackground(element),\n font: false as const,\n features: { restoreScrollPosition: true },\n };\n let mime = 'image/png';\n let blob = await domToBlob(element, options);\n if (blob.size > MAX_BYTES) {\n mime = 'image/jpeg';\n blob = await domToBlob(element, { ...options, type: 'image/jpeg', quality: 0.8 });\n }\n if (blob.size > MAX_BYTES) throw new Error('Canvas preview image is too large to attach');\n const bytes = new Uint8Array(await blob.arrayBuffer());\n return { mime, byteLength: bytes.byteLength, dataUrl: `data:${mime};base64,${bytesToBase64(bytes)}` };\n}\n\nexport function previewFileName(sourceName: string | null | undefined, mime: string): string {\n const base = (sourceName?.split('/').pop() || 'canvas').replace(/\\.canvas\\.js$/i, '').replace(/[^\\w.-]+/g, '_') || 'canvas';\n const ext = mime === 'image/jpeg' ? 'jpg' : 'png';\n return `${base}.preview.${ext}`;\n}\n\nexport async function attachPreviewShot(active: {\n capturePreview?: () => Promise<PreviewShot>;\n getFilePath?: () => string | null;\n canvasName?: string;\n}): Promise<Record<string, unknown> | string> {\n if (!active.capturePreview) return 'No canvas is open';\n const shot = await active.capturePreview();\n const name = previewFileName(active.getFilePath?.() ?? active.canvasName, shot.mime);\n const { cognitiveRuntime } = await import('@eclipse-docks/extension-ai-system/api');\n const stored = await cognitiveRuntime.addAttachments(undefined, [{\n name,\n mime: shot.mime,\n kind: 'image',\n dataUrl: shot.dataUrl,\n byteLength: shot.byteLength,\n }]);\n return previewToolOutput(shot, name, stored[0]);\n}\n\nexport function previewToolOutput(\n shot: PreviewShot,\n name: string,\n stored?: StoredPreview | null,\n presentKey = PREVIEW_IMAGE_KEY,\n): Record<string, unknown> {\n return {\n id: stored?.id ?? '',\n name: stored?.name ?? name,\n path: stored?.path,\n mime: shot.mime,\n kind: 'image',\n byteLength: shot.byteLength,\n stored: Boolean(stored),\n [presentKey]: true,\n dataUrl: shot.dataUrl,\n note: stored\n ? 'Image bytes will be provided to the model in the next message for vision inspection.'\n : 'Image bytes follow for inspection. The preview was not stored because the session attachment limit is full.',\n };\n}\n\nfunction opaqueBackground(start: Element): string {\n let current: Element | null = start;\n while (current) {\n const color = getComputedStyle(current).backgroundColor;\n if (color && color !== 'transparent' && color !== 'rgba(0, 0, 0, 0)') return color;\n const root = current.getRootNode();\n current = current.parentElement ?? (root instanceof ShadowRoot ? root.host : null);\n }\n return '#ffffff';\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n const chunk = 0x8000;\n let binary = '';\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n return btoa(binary);\n}\n"],"mappings":";;;AAGA,IAAa,oBAAoB;AAEjC,IAAM,YAAY;AAClB,IAAM,WAAW;AAcjB,eAAsB,iBAAiB,SAA4C;CAC/E,MAAM,OAAO,QAAQ,sBAAsB;CAC3C,IAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,GAAG,MAAM,IAAI,MAAM,oCAAoC;CAC3F,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK;CACnC,MAAM,SAAS,KAAK,MAAM,KAAK,MAAM;CACrC,MAAM,UAAU;EACZ;EACA;EACA,OAAO,KAAK,IAAI,GAAG,WAAW,KAAK,IAAI,OAAO,MAAM,CAAC;EACrD,iBAAiB,iBAAiB,OAAO;EACzC,MAAM;EACN,UAAU,EAAE,uBAAuB,KAAK;CAC5C;CACA,IAAI,OAAO;CACX,IAAI,OAAO,MAAM,UAAU,SAAS,OAAO;CAC3C,IAAI,KAAK,OAAO,WAAW;EACvB,OAAO;EACP,OAAO,MAAM,UAAU,SAAS;GAAE,GAAG;GAAS,MAAM;GAAc,SAAS;EAAI,CAAC;CACpF;CACA,IAAI,KAAK,OAAO,WAAW,MAAM,IAAI,MAAM,6CAA6C;CACxF,MAAM,QAAQ,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;CACrD,OAAO;EAAE;EAAM,YAAY,MAAM;EAAY,SAAS,QAAQ,KAAK,UAAU,cAAc,KAAK;CAAI;AACxG;AAEA,SAAgB,gBAAgB,YAAuC,MAAsB;CAGzF,OAAO,IAFO,YAAY,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,SAAA,CAAU,QAAQ,kBAAkB,EAAE,CAAC,CAAC,QAAQ,aAAa,GAAG,KAAK,SAEpG,WADH,SAAS,eAAe,QAAQ;AAEhD;AAEA,eAAsB,kBAAkB,QAIM;CAC1C,IAAI,CAAC,OAAO,gBAAgB,OAAO;CACnC,MAAM,OAAO,MAAM,OAAO,eAAe;CACzC,MAAM,OAAO,gBAAgB,OAAO,cAAc,KAAK,OAAO,YAAY,KAAK,IAAI;CACnF,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAQ1C,OAAO,kBAAkB,MAAM,OAAM,MAPhB,iBAAiB,eAAe,KAAA,GAAW,CAAC;EAC7D;EACA,MAAM,KAAK;EACX,MAAM;EACN,SAAS,KAAK;EACd,YAAY,KAAK;CACrB,CAAC,CAAC,EAAA,CAC0C,EAAE;AAClD;AAEA,SAAgB,kBACZ,MACA,MACA,QACA,aAAa,mBACU;CACvB,OAAO;EACH,IAAI,QAAQ,MAAM;EAClB,MAAM,QAAQ,QAAQ;EACtB,MAAM,QAAQ;EACd,MAAM,KAAK;EACX,MAAM;EACN,YAAY,KAAK;EACjB,QAAQ,QAAQ,MAAM;GACrB,aAAa;EACd,SAAS,KAAK;EACd,MAAM,SACA,yFACA;CACV;AACJ;AAEA,SAAS,iBAAiB,OAAwB;CAC9C,IAAI,UAA0B;CAC9B,OAAO,SAAS;EACZ,MAAM,QAAQ,iBAAiB,OAAO,CAAC,CAAC;EACxC,IAAI,SAAS,UAAU,iBAAiB,UAAU,oBAAoB,OAAO;EAC7E,MAAM,OAAO,QAAQ,YAAY;EACjC,UAAU,QAAQ,kBAAkB,gBAAgB,aAAa,KAAK,OAAO;CACjF;CACA,OAAO;AACX;AAEA,SAAS,cAAc,OAA2B;CAC9C,MAAM,QAAQ;CACd,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,OACnC,UAAU,OAAO,aAAa,GAAG,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC;CAEjE,OAAO,KAAK,MAAM;AACtB"}
1
+ {"version":3,"file":"preview-image.js","names":[],"sources":["../src/preview-image.ts"],"sourcesContent":["import { domToBlob } from 'modern-screenshot';\n\n/** Same field the specialist loop reads to schedule a follow-up vision message. */\nexport const PREVIEW_IMAGE_KEY = '_presentImage';\n\nconst MAX_BYTES = 3_500_000;\nconst MAX_EDGE = 1600;\n\nexport interface PreviewShot {\n dataUrl: string;\n byteLength: number;\n mime: string;\n}\n\nexport interface StoredPreview {\n id: string;\n name: string;\n path?: string;\n}\n\nexport async function rasterizeElement(element: HTMLElement): Promise<PreviewShot> {\n const rect = element.getBoundingClientRect();\n if (rect.width < 2 || rect.height < 2) throw new Error('Canvas preview has no visible size');\n const width = Math.round(rect.width);\n const height = Math.round(rect.height);\n const options = {\n width,\n height,\n scale: Math.min(2, MAX_EDGE / Math.max(width, height)),\n backgroundColor: opaqueBackground(element),\n font: false as const,\n features: { restoreScrollPosition: true },\n };\n let mime = 'image/png';\n let blob = await domToBlob(element, options);\n if (blob.size > MAX_BYTES) {\n mime = 'image/jpeg';\n blob = await domToBlob(element, { ...options, type: 'image/jpeg', quality: 0.8 });\n }\n if (blob.size > MAX_BYTES) throw new Error('Canvas preview image is too large to attach');\n const bytes = new Uint8Array(await blob.arrayBuffer());\n return { mime, byteLength: bytes.byteLength, dataUrl: `data:${mime};base64,${bytesToBase64(bytes)}` };\n}\n\nexport function previewFileName(sourceName: string | null | undefined, mime: string): string {\n const base = (sourceName?.split('/').pop() || 'canvas').replace(/\\.canvas\\.js$/i, '').replace(/[^\\w.-]+/g, '_') || 'canvas';\n const ext = mime === 'image/jpeg' ? 'jpg' : 'png';\n return `${base}.preview.${ext}`;\n}\n\nexport async function attachPreviewShot(active: {\n capturePreview?: () => Promise<PreviewShot>;\n getFilePath?: () => string | null;\n canvasName?: string;\n}): Promise<Record<string, unknown> | string> {\n if (!active.capturePreview) return 'No canvas is open';\n const shot = await active.capturePreview();\n const name = previewFileName(active.getFilePath?.() ?? active.canvasName, shot.mime);\n const { aiRuntime } = await import('@eclipse-docks/extension-ai-system/api');\n const stored = await aiRuntime.addAttachments(undefined, [{\n name,\n mime: shot.mime,\n kind: 'image',\n dataUrl: shot.dataUrl,\n byteLength: shot.byteLength,\n }]);\n return previewToolOutput(shot, name, stored[0]);\n}\n\nexport function previewToolOutput(\n shot: PreviewShot,\n name: string,\n stored?: StoredPreview | null,\n presentKey = PREVIEW_IMAGE_KEY,\n): Record<string, unknown> {\n return {\n id: stored?.id ?? '',\n name: stored?.name ?? name,\n path: stored?.path,\n mime: shot.mime,\n kind: 'image',\n byteLength: shot.byteLength,\n stored: Boolean(stored),\n [presentKey]: true,\n dataUrl: shot.dataUrl,\n note: stored\n ? 'Image bytes will be provided to the model in the next message for vision inspection.'\n : 'Image bytes follow for inspection. The preview was not stored because the session attachment limit is full.',\n };\n}\n\nfunction opaqueBackground(start: Element): string {\n let current: Element | null = start;\n while (current) {\n const color = getComputedStyle(current).backgroundColor;\n if (color && color !== 'transparent' && color !== 'rgba(0, 0, 0, 0)') return color;\n const root = current.getRootNode();\n current = current.parentElement ?? (root instanceof ShadowRoot ? root.host : null);\n }\n return '#ffffff';\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n const chunk = 0x8000;\n let binary = '';\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n return btoa(binary);\n}\n"],"mappings":";;;AAGA,IAAa,oBAAoB;AAEjC,IAAM,YAAY;AAClB,IAAM,WAAW;AAcjB,eAAsB,iBAAiB,SAA4C;CAC/E,MAAM,OAAO,QAAQ,sBAAsB;CAC3C,IAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,GAAG,MAAM,IAAI,MAAM,oCAAoC;CAC3F,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK;CACnC,MAAM,SAAS,KAAK,MAAM,KAAK,MAAM;CACrC,MAAM,UAAU;EACZ;EACA;EACA,OAAO,KAAK,IAAI,GAAG,WAAW,KAAK,IAAI,OAAO,MAAM,CAAC;EACrD,iBAAiB,iBAAiB,OAAO;EACzC,MAAM;EACN,UAAU,EAAE,uBAAuB,KAAK;CAC5C;CACA,IAAI,OAAO;CACX,IAAI,OAAO,MAAM,UAAU,SAAS,OAAO;CAC3C,IAAI,KAAK,OAAO,WAAW;EACvB,OAAO;EACP,OAAO,MAAM,UAAU,SAAS;GAAE,GAAG;GAAS,MAAM;GAAc,SAAS;EAAI,CAAC;CACpF;CACA,IAAI,KAAK,OAAO,WAAW,MAAM,IAAI,MAAM,6CAA6C;CACxF,MAAM,QAAQ,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;CACrD,OAAO;EAAE;EAAM,YAAY,MAAM;EAAY,SAAS,QAAQ,KAAK,UAAU,cAAc,KAAK;CAAI;AACxG;AAEA,SAAgB,gBAAgB,YAAuC,MAAsB;CAGzF,OAAO,IAFO,YAAY,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,SAAA,CAAU,QAAQ,kBAAkB,EAAE,CAAC,CAAC,QAAQ,aAAa,GAAG,KAAK,SAEpG,WADH,SAAS,eAAe,QAAQ;AAEhD;AAEA,eAAsB,kBAAkB,QAIM;CAC1C,IAAI,CAAC,OAAO,gBAAgB,OAAO;CACnC,MAAM,OAAO,MAAM,OAAO,eAAe;CACzC,MAAM,OAAO,gBAAgB,OAAO,cAAc,KAAK,OAAO,YAAY,KAAK,IAAI;CACnF,MAAM,EAAE,cAAc,MAAM,OAAO;CAQnC,OAAO,kBAAkB,MAAM,OAAM,MAPhB,UAAU,eAAe,KAAA,GAAW,CAAC;EACtD;EACA,MAAM,KAAK;EACX,MAAM;EACN,SAAS,KAAK;EACd,YAAY,KAAK;CACrB,CAAC,CAAC,EAAA,CAC0C,EAAE;AAClD;AAEA,SAAgB,kBACZ,MACA,MACA,QACA,aAAa,mBACU;CACvB,OAAO;EACH,IAAI,QAAQ,MAAM;EAClB,MAAM,QAAQ,QAAQ;EACtB,MAAM,QAAQ;EACd,MAAM,KAAK;EACX,MAAM;EACN,YAAY,KAAK;EACjB,QAAQ,QAAQ,MAAM;GACrB,aAAa;EACd,SAAS,KAAK;EACd,MAAM,SACA,yFACA;CACV;AACJ;AAEA,SAAS,iBAAiB,OAAwB;CAC9C,IAAI,UAA0B;CAC9B,OAAO,SAAS;EACZ,MAAM,QAAQ,iBAAiB,OAAO,CAAC,CAAC;EACxC,IAAI,SAAS,UAAU,iBAAiB,UAAU,oBAAoB,OAAO;EAC7E,MAAM,OAAO,QAAQ,YAAY;EACjC,UAAU,QAAQ,kBAAkB,gBAAgB,aAAa,KAAK,OAAO;CACjF;CACA,OAAO;AACX;AAEA,SAAS,cAAc,OAA2B;CAC9C,MAAM,QAAQ;CACd,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,OACnC,UAAU,OAAO,aAAa,GAAG,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC;CAEjE,OAAO,KAAK,MAAM;AACtB"}
@@ -1,5 +1,5 @@
1
1
  // src/skills/eclipse-docks-core/SKILL.md?raw
2
- var SKILL_default = "---\nname: eclipse-docks-core\ndescription: >-\n Eclipse Docks core runtime from docks/core: workspace files, editors, commands,\n contributions, dialogs, toasts, settings, and events. Use when a canvas or\n extension needs to open files, register UI, run commands, or talk to the shell.\n---\n\n# Eclipse Docks core (`docks/core`)\n\n```js\nimport {\n workspaceService,\n File,\n editorRegistry,\n commandRegistry,\n registerAll,\n contributionRegistry,\n publish,\n subscribe,\n unsubscribe,\n appSettings,\n toastInfo,\n toastError,\n confirmDialog,\n promptDialog,\n filebrowserDialog,\n} from \"docks/core\";\n```\n\nAlias: `@eclipse-docks/core`. `publish`, `subscribe`, and `unsubscribe` come from this module.\n\n## Workspace\n\n```js\nconst workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\nconst resource = await workspace.getResource(\"folder/note.md\");\nif (resource instanceof File) {\n const text = await resource.getContents();\n await resource.saveContents(text);\n}\n```\n\n- Paths are workspace-relative (root-prefixed in the composite workspace).\n- Create with `getResource(path, { create: true })` when the API allows.\n- A canvas opens a path in the editor with `this.openFile(path)` and does not import core for that call. Reading or writing file bytes still uses `workspaceService` and `File`.\n\n## Editors\n\n```js\nawait editorRegistry.loadEditor(file); // default handler\nawait editorRegistry.loadEditor(file, \"system.canvas-editor\");\n```\n\n`EditorInput` objects carry `title`, `key`, `data`, `component`, optional `state`. Prefer opening a `File` when one exists.\n\n## Commands\n\n```js\nregisterAll({\n command: {\n id: \"demo.ping\",\n name: \"Ping\",\n description: \"Demo command\",\n parameters: [],\n },\n handler: {\n execute: async () => \"pong\",\n },\n});\n\nawait commandRegistry.execute(\"demo.ping\", {});\n```\n\nCommands registered this way can surface as AI tools when the cognitive runtime refreshes command tools.\n\n## Contributions\n\n```js\nimport { SIDEBAR_MAIN, TOOLBAR_MAIN_RIGHT } from \"docks/core\";\n\ncontributionRegistry.registerContribution(SIDEBAR_MAIN, {\n name: \"demo.view\",\n label: \"Demo\",\n icon: \"star\",\n component: (id) => /* Lit html template for the view */ null,\n});\n```\n\nCommon slots: sidebars, panel bottom, toolbars, settings. Canvas modules contributed by extensions use `system.canvases` (`SYSTEM_CANVASES` from `@eclipse-docks/extension-canvas/contribution`). Each contribution sets a unique `settingsKey` for the state behind `getState` / `setState`. `load()` returns `{ default: CustomElementConstructor }`, or `source` is the canvas module text and the preview compiles it. A contributed canvas is not editable and opens without a toolbar.\n\n## Dialogs & toasts\n\n```js\nconst ok = await confirmDialog(\"Replace file?\");\nconst name = await promptDialog(\"Name?\");\ntoastInfo(\"Saved\");\ntoastError(\"Failed\");\n```\n\n`filebrowserDialog` for folder/file picks; `formDialog` for multi-field forms. Prefer these over ad-hoc `window.prompt` in shell-integrated code.\n\n## Settings & events\n\n```js\nawait appSettings.set(\"demo.flag\", true);\nconst flag = await appSettings.get(\"demo.flag\");\n\nconst id = subscribe(\"topic.name\", (event) => { /* … */ });\npublish(\"topic.name\", { detail: 1 });\nunsubscribe(id);\n```\n\n## Logging\n\n```js\nimport { createLogger } from \"docks/core\";\nconst log = createLogger(\"demo\");\nlog.info(\"ready\");\n```\n\n## Canvas notes\n\n- A canvas app consists of `….canvas.js` and `….canvas.json`. Its behavior contract is a `plan-….plan.md` file, the same plan document used for every other task. Plan mode writes the plan; Build generates the `….canvas.js` from it. A later change revises that same plan, then the module. Persist with `this.getState` / `this.setState` inside `onConnect` and later. `setState` creates the `….canvas.json`. Use `appSettings` only to share app-wide settings. A contributed canvas stores that state under its `settingsKey` and has no plan file.\n- `this.openFile(path)` opens a workspace path. Dialogs, toasts, and file contents stay on `docks/core`.\n- A canvas listens and publishes with `this.subscribe`, `this.unsubscribe`, and `this.publish`. It does not import those functions.\n- Cross-origin loads follow the canvas skill: CORS plus `Access-Control-Allow-Origin`, or `Cross-Origin-Resource-Policy: cross-origin`. An iframe `srcdoc` does not opt out.\n\n## Anti-patterns\n\n- Bare filenames at the composite workspace root when a durable root prefix is required\n- Calling `getState`, `setState`, or `openFile` before `onConnect`\n- Re-implementing toast/dialog with `alert` when core helpers are available\n";
2
+ var SKILL_default = "---\nname: eclipse-docks-core\ndescription: >-\n Eclipse Docks core runtime from docks/core: workspace files, editors, commands,\n contributions, dialogs, toasts, settings, and events. Use when a canvas or\n extension needs to open files, register UI, run commands, or talk to the shell.\n---\n\n# Eclipse Docks core (`docks/core`)\n\n```js\nimport {\n workspaceService,\n File,\n editorRegistry,\n commandRegistry,\n registerAll,\n contributionRegistry,\n publish,\n subscribe,\n unsubscribe,\n appSettings,\n toastInfo,\n toastError,\n confirmDialog,\n promptDialog,\n filebrowserDialog,\n} from \"docks/core\";\n```\n\nAlias: `@eclipse-docks/core`. `publish`, `subscribe`, and `unsubscribe` come from this module.\n\n## Workspace\n\n```js\nconst workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\nconst resource = await workspace.getResource(\"folder/note.md\");\nif (resource instanceof File) {\n const text = await resource.getContents();\n await resource.saveContents(text);\n}\n```\n\n- Paths are workspace-relative (root-prefixed in the composite workspace).\n- Create with `getResource(path, { create: true })` when the API allows.\n- A canvas opens a path in the editor with `this.openFile(path)` and does not import core for that call. Reading or writing file bytes still uses `workspaceService` and `File`.\n\n## Editors\n\n```js\nawait editorRegistry.loadEditor(file); // default handler\nawait editorRegistry.loadEditor(file, \"system.canvas-editor\");\n```\n\n`EditorInput` objects carry `title`, `key`, `data`, `component`, optional `state`. Prefer opening a `File` when one exists.\n\n## Commands\n\n```js\nregisterAll({\n command: {\n id: \"demo.ping\",\n name: \"Ping\",\n description: \"Demo command\",\n parameters: [],\n },\n handler: {\n execute: async () => \"pong\",\n },\n});\n\nawait commandRegistry.execute(\"demo.ping\", {});\n```\n\nCommands registered this way can surface as AI tools when the AI runtime refreshes command tools.\n\n## Contributions\n\n```js\nimport { SIDEBAR_MAIN, TOOLBAR_MAIN_RIGHT } from \"docks/core\";\n\ncontributionRegistry.registerContribution(SIDEBAR_MAIN, {\n name: \"demo.view\",\n label: \"Demo\",\n icon: \"star\",\n component: (id) => /* Lit html template for the view */ null,\n});\n```\n\nCommon slots: sidebars, panel bottom, toolbars, settings. Canvas modules contributed by extensions use `system.canvases` (`SYSTEM_CANVASES` from `@eclipse-docks/extension-canvas/contribution`). Each contribution sets a unique `settingsKey` for the state behind `getState` / `setState`. `load()` returns `{ default: CustomElementConstructor }`, or `source` is the canvas module text and the preview compiles it. A contributed canvas is not editable and opens without a toolbar.\n\n## Dialogs & toasts\n\n```js\nconst ok = await confirmDialog(\"Replace file?\");\nconst name = await promptDialog(\"Name?\");\ntoastInfo(\"Saved\");\ntoastError(\"Failed\");\n```\n\n`filebrowserDialog` for folder/file picks; `formDialog` for multi-field forms. Prefer these over ad-hoc `window.prompt` in shell-integrated code.\n\n## Settings & events\n\n```js\nawait appSettings.set(\"demo.flag\", true);\nconst flag = await appSettings.get(\"demo.flag\");\n\nconst id = subscribe(\"topic.name\", (event) => { /* … */ });\npublish(\"topic.name\", { detail: 1 });\nunsubscribe(id);\n```\n\n## Logging\n\n```js\nimport { createLogger } from \"docks/core\";\nconst log = createLogger(\"demo\");\nlog.info(\"ready\");\n```\n\n## Canvas notes\n\n- A canvas app consists of `….canvas.js` and `….canvas.json`. Its behavior contract is a `plan-….plan.md` file, the same plan document used for every other task. Plan mode writes the plan; Build generates the `….canvas.js` from it. A later change revises that same plan, then the module. Persist with `this.getState` / `this.setState` inside `onConnect` and later. `setState` creates the `….canvas.json`. Use `appSettings` only to share app-wide settings. A contributed canvas stores that state under its `settingsKey` and has no plan file.\n- `this.openFile(path)` opens a workspace path. Dialogs, toasts, and file contents stay on `docks/core`.\n- A canvas listens and publishes with `this.subscribe`, `this.unsubscribe`, and `this.publish`. It does not import those functions.\n- Cross-origin loads follow the canvas skill: CORS plus `Access-Control-Allow-Origin`, or `Cross-Origin-Resource-Policy: cross-origin`. An iframe `srcdoc` does not opt out.\n\n## Anti-patterns\n\n- Bare filenames at the composite workspace root when a durable root prefix is required\n- Calling `getState`, `setState`, or `openFile` before `onConnect`\n- Re-implementing toast/dialog with `alert` when core helpers are available\n";
3
3
  export { SKILL_default as default };
4
4
 
5
5
  //# sourceMappingURL=SKILL.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-docks/extension-canvas",
3
- "version": "0.8.15",
3
+ "version": "0.8.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",