@eclipse-docks/extension-canvas 0.8.4 → 0.8.5

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.
@@ -4,10 +4,10 @@ import { compileCanvas } from "./compile.js";
4
4
  import { createContributionHost, createFileHost } from "./host.js";
5
5
  import { elementFromConstructor, mountCompiled } from "./mount.js";
6
6
  import { canvasBridges } from "./bridges/urls.js";
7
- import __decorate from "./_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
8
7
  import { DocksPart, File, TOPIC_WORKSPACE_CHANGED, icon } from "@eclipse-docks/core";
9
8
  import { css, customElement, html, nothing, property, query, state } from "@eclipse-docks/core/externals/lit";
10
9
  import "@eclipse-docks/extension-monaco-editor/widget";
10
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
11
11
  //#region src/canvas-editor.ts
12
12
  var DocksCanvasSurface = class DocksCanvasSurface extends DocksPart {
13
13
  constructor(..._args) {
@@ -359,19 +359,19 @@ var DocksCanvasSurface = class DocksCanvasSurface extends DocksPart {
359
359
  `;
360
360
  }
361
361
  };
362
- __decorate([property({ attribute: false })], DocksCanvasSurface.prototype, "input", void 0);
363
- __decorate([property()], DocksCanvasSurface.prototype, "kind", void 0);
364
- __decorate([property()], DocksCanvasSurface.prototype, "canvasName", void 0);
365
- __decorate([property()], DocksCanvasSurface.prototype, "entryPath", void 0);
366
- __decorate([property()], DocksCanvasSurface.prototype, "source", void 0);
367
- __decorate([property({ type: Boolean })], DocksCanvasSurface.prototype, "showSource", void 0);
368
- __decorate([state()], DocksCanvasSurface.prototype, "sourceText", void 0);
369
- __decorate([state()], DocksCanvasSurface.prototype, "mode", void 0);
370
- __decorate([state()], DocksCanvasSurface.prototype, "previewError", void 0);
371
- __decorate([state()], DocksCanvasSurface.prototype, "attachingPreview", void 0);
372
- __decorate([state()], DocksCanvasSurface.prototype, "previewElement", void 0);
373
- __decorate([query("docks-monaco-widget")], DocksCanvasSurface.prototype, "widget", void 0);
374
- DocksCanvasSurface = __decorate([customElement("docks-canvas-surface")], DocksCanvasSurface);
362
+ _decorate([property({ attribute: false })], DocksCanvasSurface.prototype, "input", void 0);
363
+ _decorate([property()], DocksCanvasSurface.prototype, "kind", void 0);
364
+ _decorate([property()], DocksCanvasSurface.prototype, "canvasName", void 0);
365
+ _decorate([property()], DocksCanvasSurface.prototype, "entryPath", void 0);
366
+ _decorate([property()], DocksCanvasSurface.prototype, "source", void 0);
367
+ _decorate([property({ type: Boolean })], DocksCanvasSurface.prototype, "showSource", void 0);
368
+ _decorate([state()], DocksCanvasSurface.prototype, "sourceText", void 0);
369
+ _decorate([state()], DocksCanvasSurface.prototype, "mode", void 0);
370
+ _decorate([state()], DocksCanvasSurface.prototype, "previewError", void 0);
371
+ _decorate([state()], DocksCanvasSurface.prototype, "attachingPreview", void 0);
372
+ _decorate([state()], DocksCanvasSurface.prototype, "previewElement", void 0);
373
+ _decorate([query("docks-monaco-widget")], DocksCanvasSurface.prototype, "widget", void 0);
374
+ DocksCanvasSurface = _decorate([customElement("docks-canvas-surface")], DocksCanvasSurface);
375
375
  var DocksCanvasEditor = class DocksCanvasEditor extends DocksCanvasSurface {
376
376
  async save() {
377
377
  const value = this.getContent() ?? "";
@@ -381,7 +381,7 @@ var DocksCanvasEditor = class DocksCanvasEditor extends DocksCanvasSurface {
381
381
  this.markDirty(false);
382
382
  }
383
383
  };
384
- DocksCanvasEditor = __decorate([customElement("docks-canvas-editor")], DocksCanvasEditor);
384
+ DocksCanvasEditor = _decorate([customElement("docks-canvas-editor")], DocksCanvasEditor);
385
385
  function nextFrame() {
386
386
  return new Promise((resolve) => requestAnimationFrame(() => resolve()));
387
387
  }
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-editor.js","names":["_decorate"],"sources":["../src/canvas-editor.ts"],"sourcesContent":["import {\n DocksPart,\n File,\n icon,\n TOPIC_WORKSPACE_CHANGED,\n type EditorContentProvider,\n type EditorInput,\n} from '@eclipse-docks/core';\nimport { css, html, nothing, type PropertyValues } from '@eclipse-docks/core/externals/lit';\nimport { customElement, property, query, state } from '@eclipse-docks/core/externals/lit';\nimport '@eclipse-docks/extension-monaco-editor/widget';\nimport type { DocksMonacoWidget } from '@eclipse-docks/extension-monaco-editor/widget';\nimport type { CanvasContribution } from './contribution';\nimport { compileCanvas } from './compile';\nimport { createContributionHost, createFileHost, type CanvasHost } from './host';\nimport { elementFromConstructor, mountCompiled, type CanvasViewElement } from './mount';\nimport { canvasBridges } from './bridges/urls';\nimport { attachPreviewShot, rasterizeElement, type PreviewShot } from './preview-image';\nimport { readWorkspaceFile } from './workspace-file';\n\n@customElement('docks-canvas-surface')\nexport class DocksCanvasSurface extends DocksPart implements EditorContentProvider {\n @property({ attribute: false }) input?: EditorInput;\n @property() kind: 'workspace' | 'registered' = 'workspace';\n @property() canvasName?: string;\n @property() entryPath = '';\n @property() source = '';\n @property({ type: Boolean }) showSource = false;\n\n @state() protected sourceText = '';\n @state() protected mode: 'preview' | 'source' = 'preview';\n @state() protected previewError?: string;\n @state() private attachingPreview = false;\n @state() protected previewElement?: CanvasViewElement;\n @query('docks-monaco-widget') protected widget?: DocksMonacoWidget;\n\n protected scrollMode: 'scroller' | 'native' | 'none' = 'none';\n protected host: CanvasHost = { getState: (_key, fallback) => fallback, setState: () => undefined, openFile: () => undefined };\n private previewDispose?: () => void;\n private contribution?: CanvasContribution;\n private ready = false;\n private reloadGeneration = 0;\n private reloadTail: Promise<void> = Promise.resolve();\n private syncToken = 0;\n private compiledSource = '';\n protected previewStale = false;\n\n override connectedCallback() {\n super.connectedCallback();\n this.addEventListener('dirty', this.onDirty);\n this.subscribe(TOPIC_WORKSPACE_CHANGED, this.onWorkspaceChanged);\n }\n\n override disconnectedCallback() {\n this.removeEventListener('dirty', this.onDirty);\n this.reloadGeneration++;\n super.disconnectedCallback();\n }\n\n protected async doInitUI() {\n const data = this.input?.data;\n if (data instanceof File) {\n this.kind = 'workspace';\n this.entryPath = data.getWorkspacePath();\n this.showSource = true;\n this.sourceText = String(await data.getContents() ?? '');\n this.host = await createFileHost(data);\n } else if (data && typeof data === 'object' && 'contribution' in data) {\n this.contribution = (data as { contribution: CanvasContribution }).contribution;\n this.kind = 'registered';\n this.canvasName = this.contribution.name;\n this.showSource = this.contribution.source !== undefined;\n if (typeof this.contribution.source === 'function') this.sourceText = await this.contribution.source();\n else this.sourceText = this.contribution.source ?? '';\n this.host = await createContributionHost(this.contribution);\n } else if (this.entryPath || this.source) {\n this.kind = 'workspace';\n this.showSource = false;\n this.sourceText = this.source;\n const workspaceFile = await readWorkspaceFile(this.entryPath);\n if (workspaceFile?.text !== undefined && !this.sourceText) this.sourceText = workspaceFile.text;\n this.host = { getState: (_key, fallback) => fallback, setState: () => undefined, openFile: () => undefined };\n }\n this.mode = this.input?.state?.mode === 'source' ? 'source' : 'preview';\n this.ready = true;\n await this.syncFromFile();\n this.requestUpdate();\n if (this.mode === 'preview' || !this.showSource) await this.reload();\n }\n\n protected doClose() {\n this.reloadGeneration++;\n this.previewDispose?.();\n this.previewDispose = undefined;\n this.widget?.dispose();\n }\n\n getContent(): string | null {\n return this.widget?.getContent() ?? this.sourceText;\n }\n\n getSelection(): string | null {\n return this.widget?.getSelection() ?? null;\n }\n\n getSnippet(lines = 5): { snippet: string; cursorLine: number } | null {\n return this.widget?.getSnippet(lines) ?? null;\n }\n\n getLanguage(): string | null {\n return 'javascript';\n }\n\n isLanguage(lang: string): boolean {\n return lang.toLowerCase() === 'javascript';\n }\n\n getFilePath(): string | null {\n const data = this.input?.data;\n if (data instanceof File) return data.getWorkspacePath();\n return this.entryPath || null;\n }\n\n getState(key: string): unknown {\n return this.host.getState(key);\n }\n\n setState(key: string, value: unknown): void {\n this.host.setState(key, value);\n }\n\n setSource(source: string): void {\n const current = this.getContent() ?? '';\n this.sourceText = source;\n const model = this.widget?.getModel();\n if (model && model.getValue() !== source) model.setValue(source);\n const next = this.getContent() ?? source;\n this.previewStale = next !== this.compiledSource || !this.previewElement;\n if (next !== current || this.previewStale) this.markDirty(true);\n this.requestUpdate();\n }\n\n async syncFromFile(): Promise<boolean> {\n for (let attempt = 0; attempt < 30 && !this.ready; attempt++) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n if (!this.ready || this.kind !== 'workspace' || !this.entryPath) return false;\n const token = ++this.syncToken;\n const before = this.getContent() ?? '';\n const file = await readWorkspaceFile(this.entryPath);\n if (token !== this.syncToken) return false;\n if (file?.text === undefined) return false;\n const current = this.getContent() ?? '';\n if (current !== before || file.text === current) return false;\n this.setSource(file.text);\n return true;\n }\n\n async capturePreview(): Promise<PreviewShot> {\n for (let attempt = 0; attempt < 30 && !this.ready; attempt++) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n if (!this.ready) throw new Error('Canvas is still opening');\n await this.reload();\n await this.updateComplete;\n const preview = this.renderRoot.querySelector('.canvas-preview') as HTMLElement | null;\n if (!preview) throw new Error('Canvas preview is not rendered');\n const hidden = preview.classList.contains('canvas-hidden') || preview.getBoundingClientRect().width < 2;\n if (hidden) {\n preview.classList.add('canvas-capture');\n preview.style.width = `${this.clientWidth || 960}px`;\n preview.style.height = `${this.clientHeight || 640}px`;\n }\n try {\n await nextFrame();\n await nextFrame();\n const view = this.previewElement as { updateComplete?: Promise<unknown> } | undefined;\n if (view?.updateComplete) await view.updateComplete;\n return await rasterizeElement(preview);\n } finally {\n preview.classList.remove('canvas-capture');\n preview.style.width = '';\n preview.style.height = '';\n }\n }\n\n reload(): Promise<string> {\n const run = this.reloadTail.then(() => this.reloadLatest());\n this.reloadTail = run.then(() => undefined, () => undefined);\n return run;\n }\n\n private async reloadLatest(): Promise<string> {\n let result = 'ready';\n for (let pass = 0; pass < 4; pass++) {\n const source = this.getContent() ?? '';\n if (this.previewElement && !this.previewStale && source === this.compiledSource && !this.previewError) return result;\n result = await this.mountSource(source);\n if (!result) continue;\n if ((this.getContent() ?? '') === source) return result;\n this.previewStale = true;\n }\n return result;\n }\n\n private async mountSource(source: string): Promise<string> {\n const generation = ++this.reloadGeneration;\n if (this.kind === 'registered' && this.contribution) {\n try {\n const mod = await this.contribution.load();\n if (generation !== this.reloadGeneration) return '';\n const Ctor = mod.default;\n if (typeof Ctor !== 'function' || !(Ctor.prototype instanceof HTMLElement)) {\n this.previewError = 'Canvas default export must be an HTMLElement subclass';\n this.requestUpdate();\n return this.previewError;\n }\n const element = elementFromConstructor(Ctor);\n element.canvasHost = this.host;\n this.replacePreview(element, source);\n return 'ready';\n } catch (err) {\n if (generation !== this.reloadGeneration) return '';\n this.previewError = err instanceof Error ? err.message : String(err);\n this.requestUpdate();\n return this.previewError;\n }\n }\n const compiled = await compileCanvas({\n entryPath: this.entryPath || 'canvas.js',\n entrySource: source,\n read: readWorkspaceFile,\n bridges: canvasBridges(),\n });\n if (generation !== this.reloadGeneration) return '';\n if (!compiled.ok) {\n this.previewError = compiled.error;\n this.requestUpdate();\n return compiled.error;\n }\n const mounted = await mountCompiled(compiled.code);\n if (generation !== this.reloadGeneration) {\n if (mounted.ok) mounted.dispose();\n return '';\n }\n if (!mounted.ok) {\n this.previewError = mounted.error;\n this.requestUpdate();\n return mounted.error;\n }\n mounted.element.canvasHost = this.host;\n this.replacePreview(mounted.element, source, mounted.dispose);\n return 'ready';\n }\n\n private replacePreview(element: CanvasViewElement, source: string, dispose?: () => void) {\n const previous = this.previewDispose;\n this.previewDispose = dispose ?? (() => element.remove());\n this.previewElement = element;\n this.previewError = undefined;\n this.compiledSource = source;\n this.previewStale = (this.getContent() ?? '') !== source;\n this.placePreview();\n this.requestUpdate();\n previous?.();\n }\n\n /** The mount has no Lit child part, so replacing its children leaves part markers intact. */\n private placePreview() {\n const mount = this.renderRoot.querySelector('.canvas-mount');\n const element = this.previewElement;\n if (!mount || !element) return;\n if (mount.childElementCount === 1 && mount.firstElementChild === element) return;\n mount.replaceChildren(element);\n }\n\n private onWorkspaceChanged = () => {\n void this.refreshFromFile();\n };\n\n private async refreshFromFile() {\n const changed = await this.syncFromFile();\n if (!changed) return;\n if (this.mode === 'preview' || !this.showSource) await this.reload();\n }\n\n private onDirty = (event: Event) => {\n if (!this.ready || (event as CustomEvent<boolean>).detail !== true) return;\n const source = this.getContent() ?? '';\n if (source === this.compiledSource && this.previewElement) return;\n this.previewStale = true;\n if (this.mode === 'preview' || !this.showSource) void this.reload();\n };\n\n protected updated(changed: PropertyValues) {\n super.updated(changed);\n this.placePreview();\n if (this.mode === 'source') this.widget?.layout();\n }\n\n private onContentChange = () => {\n const next = this.widget?.getContent() ?? this.sourceText;\n this.previewStale = next !== this.compiledSource;\n this.sourceText = next;\n this.markDirty(true);\n };\n\n private toggleMode() {\n if (this.widget) this.sourceText = this.widget.getContent() ?? this.sourceText;\n const next = this.mode === 'preview' ? 'source' : 'preview';\n this.mode = next;\n if (this.input) this.input.state.mode = next;\n if (next === 'preview' && (this.previewStale || !this.previewElement)) void this.reload();\n }\n\n private attachPreview = async () => {\n if (this.attachingPreview) return;\n this.attachingPreview = true;\n try {\n const result = await attachPreviewShot(this);\n if (typeof result === 'string') {\n this.showError(result);\n return;\n }\n if (result.stored === false) {\n this.showError(String(result.note ?? 'Could not attach the preview'));\n return;\n }\n this.showInfo('Attached preview');\n } catch (err) {\n this.showError(err instanceof Error ? err.message : String(err));\n } finally {\n this.attachingPreview = false;\n }\n };\n\n protected renderToolbar() {\n if (!this.ready) return nothing;\n const toSource = this.mode === 'preview';\n const label = toSource ? 'Source' : 'Preview';\n return html`\n ${this.showSource ? html`\n <wa-button appearance=\"plain\" size=\"s\" title=${label} @click=${() => this.toggleMode()}>\n ${icon(toSource ? 'code' : 'eye', { slot: 'start' })}\n ${label}\n </wa-button>\n ` : nothing}\n <wa-button\n appearance=\"plain\"\n size=\"s\"\n title=\"Attach a screenshot of the preview\"\n ?loading=${this.attachingPreview}\n ?disabled=${this.attachingPreview}\n @click=${() => this.attachPreview()}>\n ${icon('camera', { slot: 'start' })}\n Screenshot\n </wa-button>\n `;\n }\n\n protected renderContent() {\n if (!this.ready) return html``;\n const showPreview = !this.showSource || this.mode === 'preview';\n return html`\n <div class=\"canvas-preview ${showPreview ? '' : 'canvas-hidden'}\">\n ${this.previewError ? html`<pre class=\"canvas-error\">${this.previewError}</pre>` : nothing}\n <wa-scroller class=\"canvas-scroll\" orientation=\"vertical\">\n <div class=\"canvas-mount\"></div>\n </wa-scroller>\n </div>\n ${this.showSource ? html`\n <docks-monaco-widget\n class=${this.mode === 'source' ? '' : 'canvas-hidden'}\n .value=${this.sourceText}\n .language=${'javascript'}\n .uri=${this.entryPath || this.canvasName || 'canvas.js'}\n @content-change=${this.onContentChange}>\n </docks-monaco-widget>\n ` : nothing}\n `;\n }\n\n static styles = css`\n :host { display: flex; flex-direction: column; height: 100%; min-height: 0; }\n .canvas-preview { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }\n .canvas-preview.canvas-hidden, docks-monaco-widget.canvas-hidden { display: none; }\n .canvas-preview.canvas-capture {\n display: flex !important;\n position: fixed;\n left: 0;\n top: 0;\n z-index: 2147483000;\n overflow: hidden;\n background: var(--wa-color-surface-default, #fff);\n }\n wa-scroller.canvas-scroll { flex: 1 1 0; min-height: 0; height: 100%; }\n .canvas-mount > * { display: block; }\n docks-monaco-widget { display: block; height: 100%; min-height: 0; }\n .canvas-error {\n margin: 0;\n padding: var(--wa-space-s, 8px);\n white-space: pre-wrap;\n color: var(--wa-color-danger-on-quiet, #b42318);\n }\n `;\n}\n\n@customElement('docks-canvas-editor')\nexport class DocksCanvasEditor extends DocksCanvasSurface {\n override async save(): Promise<void> {\n const value = this.getContent() ?? '';\n const data = this.input?.data;\n if (data instanceof File) await data.saveContents(value);\n if ((this.mode === 'preview' || !this.showSource) && this.previewStale) await this.reload();\n this.markDirty(false);\n }\n}\n\nfunction nextFrame(): Promise<void> {\n return new Promise(resolve => requestAnimationFrame(() => resolve()));\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'docks-canvas-surface': DocksCanvasSurface;\n 'docks-canvas-editor': DocksCanvasEditor;\n }\n}\n"],"mappings":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vas-editor.ts"],"sourcesContent":["import {\n DocksPart,\n File,\n icon,\n TOPIC_WORKSPACE_CHANGED,\n type EditorContentProvider,\n type EditorInput,\n} from '@eclipse-docks/core';\nimport { css, html, nothing, type PropertyValues } from '@eclipse-docks/core/externals/lit';\nimport { customElement, property, query, state } from '@eclipse-docks/core/externals/lit';\nimport '@eclipse-docks/extension-monaco-editor/widget';\nimport type { DocksMonacoWidget } from '@eclipse-docks/extension-monaco-editor/widget';\nimport type { CanvasContribution } from './contribution';\nimport { compileCanvas } from './compile';\nimport { createContributionHost, createFileHost, type CanvasHost } from './host';\nimport { elementFromConstructor, mountCompiled, type CanvasViewElement } from './mount';\nimport { canvasBridges } from './bridges/urls';\nimport { attachPreviewShot, rasterizeElement, type PreviewShot } from './preview-image';\nimport { readWorkspaceFile } from './workspace-file';\n\n@customElement('docks-canvas-surface')\nexport class DocksCanvasSurface extends DocksPart implements EditorContentProvider {\n @property({ attribute: false }) input?: EditorInput;\n @property() kind: 'workspace' | 'registered' = 'workspace';\n @property() canvasName?: string;\n @property() entryPath = '';\n @property() source = '';\n @property({ type: Boolean }) showSource = false;\n\n @state() protected sourceText = '';\n @state() protected mode: 'preview' | 'source' = 'preview';\n @state() protected previewError?: string;\n @state() private attachingPreview = false;\n @state() protected previewElement?: CanvasViewElement;\n @query('docks-monaco-widget') protected widget?: DocksMonacoWidget;\n\n protected scrollMode: 'scroller' | 'native' | 'none' = 'none';\n protected host: CanvasHost = { getState: (_key, fallback) => fallback, setState: () => undefined, openFile: () => undefined };\n private previewDispose?: () => void;\n private contribution?: CanvasContribution;\n private ready = false;\n private reloadGeneration = 0;\n private reloadTail: Promise<void> = Promise.resolve();\n private syncToken = 0;\n private compiledSource = '';\n protected previewStale = false;\n\n override connectedCallback() {\n super.connectedCallback();\n this.addEventListener('dirty', this.onDirty);\n this.subscribe(TOPIC_WORKSPACE_CHANGED, this.onWorkspaceChanged);\n }\n\n override disconnectedCallback() {\n this.removeEventListener('dirty', this.onDirty);\n this.reloadGeneration++;\n super.disconnectedCallback();\n }\n\n protected async doInitUI() {\n const data = this.input?.data;\n if (data instanceof File) {\n this.kind = 'workspace';\n this.entryPath = data.getWorkspacePath();\n this.showSource = true;\n this.sourceText = String(await data.getContents() ?? '');\n this.host = await createFileHost(data);\n } else if (data && typeof data === 'object' && 'contribution' in data) {\n this.contribution = (data as { contribution: CanvasContribution }).contribution;\n this.kind = 'registered';\n this.canvasName = this.contribution.name;\n this.showSource = this.contribution.source !== undefined;\n if (typeof this.contribution.source === 'function') this.sourceText = await this.contribution.source();\n else this.sourceText = this.contribution.source ?? '';\n this.host = await createContributionHost(this.contribution);\n } else if (this.entryPath || this.source) {\n this.kind = 'workspace';\n this.showSource = false;\n this.sourceText = this.source;\n const workspaceFile = await readWorkspaceFile(this.entryPath);\n if (workspaceFile?.text !== undefined && !this.sourceText) this.sourceText = workspaceFile.text;\n this.host = { getState: (_key, fallback) => fallback, setState: () => undefined, openFile: () => undefined };\n }\n this.mode = this.input?.state?.mode === 'source' ? 'source' : 'preview';\n this.ready = true;\n await this.syncFromFile();\n this.requestUpdate();\n if (this.mode === 'preview' || !this.showSource) await this.reload();\n }\n\n protected doClose() {\n this.reloadGeneration++;\n this.previewDispose?.();\n this.previewDispose = undefined;\n this.widget?.dispose();\n }\n\n getContent(): string | null {\n return this.widget?.getContent() ?? this.sourceText;\n }\n\n getSelection(): string | null {\n return this.widget?.getSelection() ?? null;\n }\n\n getSnippet(lines = 5): { snippet: string; cursorLine: number } | null {\n return this.widget?.getSnippet(lines) ?? null;\n }\n\n getLanguage(): string | null {\n return 'javascript';\n }\n\n isLanguage(lang: string): boolean {\n return lang.toLowerCase() === 'javascript';\n }\n\n getFilePath(): string | null {\n const data = this.input?.data;\n if (data instanceof File) return data.getWorkspacePath();\n return this.entryPath || null;\n }\n\n getState(key: string): unknown {\n return this.host.getState(key);\n }\n\n setState(key: string, value: unknown): void {\n this.host.setState(key, value);\n }\n\n setSource(source: string): void {\n const current = this.getContent() ?? '';\n this.sourceText = source;\n const model = this.widget?.getModel();\n if (model && model.getValue() !== source) model.setValue(source);\n const next = this.getContent() ?? source;\n this.previewStale = next !== this.compiledSource || !this.previewElement;\n if (next !== current || this.previewStale) this.markDirty(true);\n this.requestUpdate();\n }\n\n async syncFromFile(): Promise<boolean> {\n for (let attempt = 0; attempt < 30 && !this.ready; attempt++) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n if (!this.ready || this.kind !== 'workspace' || !this.entryPath) return false;\n const token = ++this.syncToken;\n const before = this.getContent() ?? '';\n const file = await readWorkspaceFile(this.entryPath);\n if (token !== this.syncToken) return false;\n if (file?.text === undefined) return false;\n const current = this.getContent() ?? '';\n if (current !== before || file.text === current) return false;\n this.setSource(file.text);\n return true;\n }\n\n async capturePreview(): Promise<PreviewShot> {\n for (let attempt = 0; attempt < 30 && !this.ready; attempt++) {\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n if (!this.ready) throw new Error('Canvas is still opening');\n await this.reload();\n await this.updateComplete;\n const preview = this.renderRoot.querySelector('.canvas-preview') as HTMLElement | null;\n if (!preview) throw new Error('Canvas preview is not rendered');\n const hidden = preview.classList.contains('canvas-hidden') || preview.getBoundingClientRect().width < 2;\n if (hidden) {\n preview.classList.add('canvas-capture');\n preview.style.width = `${this.clientWidth || 960}px`;\n preview.style.height = `${this.clientHeight || 640}px`;\n }\n try {\n await nextFrame();\n await nextFrame();\n const view = this.previewElement as { updateComplete?: Promise<unknown> } | undefined;\n if (view?.updateComplete) await view.updateComplete;\n return await rasterizeElement(preview);\n } finally {\n preview.classList.remove('canvas-capture');\n preview.style.width = '';\n preview.style.height = '';\n }\n }\n\n reload(): Promise<string> {\n const run = this.reloadTail.then(() => this.reloadLatest());\n this.reloadTail = run.then(() => undefined, () => undefined);\n return run;\n }\n\n private async reloadLatest(): Promise<string> {\n let result = 'ready';\n for (let pass = 0; pass < 4; pass++) {\n const source = this.getContent() ?? '';\n if (this.previewElement && !this.previewStale && source === this.compiledSource && !this.previewError) return result;\n result = await this.mountSource(source);\n if (!result) continue;\n if ((this.getContent() ?? '') === source) return result;\n this.previewStale = true;\n }\n return result;\n }\n\n private async mountSource(source: string): Promise<string> {\n const generation = ++this.reloadGeneration;\n if (this.kind === 'registered' && this.contribution) {\n try {\n const mod = await this.contribution.load();\n if (generation !== this.reloadGeneration) return '';\n const Ctor = mod.default;\n if (typeof Ctor !== 'function' || !(Ctor.prototype instanceof HTMLElement)) {\n this.previewError = 'Canvas default export must be an HTMLElement subclass';\n this.requestUpdate();\n return this.previewError;\n }\n const element = elementFromConstructor(Ctor);\n element.canvasHost = this.host;\n this.replacePreview(element, source);\n return 'ready';\n } catch (err) {\n if (generation !== this.reloadGeneration) return '';\n this.previewError = err instanceof Error ? err.message : String(err);\n this.requestUpdate();\n return this.previewError;\n }\n }\n const compiled = await compileCanvas({\n entryPath: this.entryPath || 'canvas.js',\n entrySource: source,\n read: readWorkspaceFile,\n bridges: canvasBridges(),\n });\n if (generation !== this.reloadGeneration) return '';\n if (!compiled.ok) {\n this.previewError = compiled.error;\n this.requestUpdate();\n return compiled.error;\n }\n const mounted = await mountCompiled(compiled.code);\n if (generation !== this.reloadGeneration) {\n if (mounted.ok) mounted.dispose();\n return '';\n }\n if (!mounted.ok) {\n this.previewError = mounted.error;\n this.requestUpdate();\n return mounted.error;\n }\n mounted.element.canvasHost = this.host;\n this.replacePreview(mounted.element, source, mounted.dispose);\n return 'ready';\n }\n\n private replacePreview(element: CanvasViewElement, source: string, dispose?: () => void) {\n const previous = this.previewDispose;\n this.previewDispose = dispose ?? (() => element.remove());\n this.previewElement = element;\n this.previewError = undefined;\n this.compiledSource = source;\n this.previewStale = (this.getContent() ?? '') !== source;\n this.placePreview();\n this.requestUpdate();\n previous?.();\n }\n\n /** The mount has no Lit child part, so replacing its children leaves part markers intact. */\n private placePreview() {\n const mount = this.renderRoot.querySelector('.canvas-mount');\n const element = this.previewElement;\n if (!mount || !element) return;\n if (mount.childElementCount === 1 && mount.firstElementChild === element) return;\n mount.replaceChildren(element);\n }\n\n private onWorkspaceChanged = () => {\n void this.refreshFromFile();\n };\n\n private async refreshFromFile() {\n const changed = await this.syncFromFile();\n if (!changed) return;\n if (this.mode === 'preview' || !this.showSource) await this.reload();\n }\n\n private onDirty = (event: Event) => {\n if (!this.ready || (event as CustomEvent<boolean>).detail !== true) return;\n const source = this.getContent() ?? '';\n if (source === this.compiledSource && this.previewElement) return;\n this.previewStale = true;\n if (this.mode === 'preview' || !this.showSource) void this.reload();\n };\n\n protected updated(changed: PropertyValues) {\n super.updated(changed);\n this.placePreview();\n if (this.mode === 'source') this.widget?.layout();\n }\n\n private onContentChange = () => {\n const next = this.widget?.getContent() ?? this.sourceText;\n this.previewStale = next !== this.compiledSource;\n this.sourceText = next;\n this.markDirty(true);\n };\n\n private toggleMode() {\n if (this.widget) this.sourceText = this.widget.getContent() ?? this.sourceText;\n const next = this.mode === 'preview' ? 'source' : 'preview';\n this.mode = next;\n if (this.input) this.input.state.mode = next;\n if (next === 'preview' && (this.previewStale || !this.previewElement)) void this.reload();\n }\n\n private attachPreview = async () => {\n if (this.attachingPreview) return;\n this.attachingPreview = true;\n try {\n const result = await attachPreviewShot(this);\n if (typeof result === 'string') {\n this.showError(result);\n return;\n }\n if (result.stored === false) {\n this.showError(String(result.note ?? 'Could not attach the preview'));\n return;\n }\n this.showInfo('Attached preview');\n } catch (err) {\n this.showError(err instanceof Error ? err.message : String(err));\n } finally {\n this.attachingPreview = false;\n }\n };\n\n protected renderToolbar() {\n if (!this.ready) return nothing;\n const toSource = this.mode === 'preview';\n const label = toSource ? 'Source' : 'Preview';\n return html`\n ${this.showSource ? html`\n <wa-button appearance=\"plain\" size=\"s\" title=${label} @click=${() => this.toggleMode()}>\n ${icon(toSource ? 'code' : 'eye', { slot: 'start' })}\n ${label}\n </wa-button>\n ` : nothing}\n <wa-button\n appearance=\"plain\"\n size=\"s\"\n title=\"Attach a screenshot of the preview\"\n ?loading=${this.attachingPreview}\n ?disabled=${this.attachingPreview}\n @click=${() => this.attachPreview()}>\n ${icon('camera', { slot: 'start' })}\n Screenshot\n </wa-button>\n `;\n }\n\n protected renderContent() {\n if (!this.ready) return html``;\n const showPreview = !this.showSource || this.mode === 'preview';\n return html`\n <div class=\"canvas-preview ${showPreview ? '' : 'canvas-hidden'}\">\n ${this.previewError ? html`<pre class=\"canvas-error\">${this.previewError}</pre>` : nothing}\n <wa-scroller class=\"canvas-scroll\" orientation=\"vertical\">\n <div class=\"canvas-mount\"></div>\n </wa-scroller>\n </div>\n ${this.showSource ? html`\n <docks-monaco-widget\n class=${this.mode === 'source' ? '' : 'canvas-hidden'}\n .value=${this.sourceText}\n .language=${'javascript'}\n .uri=${this.entryPath || this.canvasName || 'canvas.js'}\n @content-change=${this.onContentChange}>\n </docks-monaco-widget>\n ` : nothing}\n `;\n }\n\n static styles = css`\n :host { display: flex; flex-direction: column; height: 100%; min-height: 0; }\n .canvas-preview { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }\n .canvas-preview.canvas-hidden, docks-monaco-widget.canvas-hidden { display: none; }\n .canvas-preview.canvas-capture {\n display: flex !important;\n position: fixed;\n left: 0;\n top: 0;\n z-index: 2147483000;\n overflow: hidden;\n background: var(--wa-color-surface-default, #fff);\n }\n wa-scroller.canvas-scroll { flex: 1 1 0; min-height: 0; height: 100%; }\n .canvas-mount > * { display: block; }\n docks-monaco-widget { display: block; height: 100%; min-height: 0; }\n .canvas-error {\n margin: 0;\n padding: var(--wa-space-s, 8px);\n white-space: pre-wrap;\n color: var(--wa-color-danger-on-quiet, #b42318);\n }\n `;\n}\n\n@customElement('docks-canvas-editor')\nexport class DocksCanvasEditor extends DocksCanvasSurface {\n override async save(): Promise<void> {\n const value = this.getContent() ?? '';\n const data = this.input?.data;\n if (data instanceof File) await data.saveContents(value);\n if ((this.mode === 'preview' || !this.showSource) && this.previewStale) await this.reload();\n this.markDirty(false);\n }\n}\n\nfunction nextFrame(): Promise<void> {\n return new Promise(resolve => requestAnimationFrame(() => resolve()));\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'docks-canvas-surface': DocksCanvasSurface;\n 'docks-canvas-editor': DocksCanvasEditor;\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBO,IAAM,qBAAN,MAAM,2BAA2B,UAA2C;;;EAEhC,KAAA,OAAA;EAEvB,KAAA,YAAA;EACH,KAAA,SAAA;EACqB,KAAA,aAAA;EAEV,KAAA,aAAA;EACgB,KAAA,OAAA;EAEZ,KAAA,mBAAA;EAImB,KAAA,aAAA;EAC1B,KAAA,OAAA;GAAE,WAAW,MAAM,aAAa;GAAU,gBAAgB,KAAA;GAAW,gBAAgB,KAAA;EAAU;EAG5G,KAAA,QAAA;EACW,KAAA,mBAAA;EACS,KAAA,aAAA,QAAQ,QAAQ;EAChC,KAAA,YAAA;EACK,KAAA,iBAAA;EACA,KAAA,eAAA;EAuOU,KAAA,2BAAA;GAC/B,KAAU,gBAAgB;EAC9B;EAQmB,KAAA,WAAA,UAAiB;GAChC,IAAI,CAAC,KAAK,SAAU,MAA+B,WAAW,MAAM;GAEpE,KADe,KAAK,WAAW,KAAK,QACrB,KAAK,kBAAkB,KAAK,gBAAgB;GAC3D,KAAK,eAAe;GACpB,IAAI,KAAK,SAAS,aAAa,CAAC,KAAK,YAAY,KAAU,OAAO;EACtE;EAQgC,KAAA,wBAAA;GAC5B,MAAM,OAAO,KAAK,QAAQ,WAAW,KAAK,KAAK;GAC/C,KAAK,eAAe,SAAS,KAAK;GAClC,KAAK,aAAa;GAClB,KAAK,UAAU,IAAI;EACvB;EAUwB,KAAA,gBAAA,YAAY;GAChC,IAAI,KAAK,kBAAkB;GAC3B,KAAK,mBAAmB;GACxB,IAAI;IACA,MAAM,SAAS,MAAM,kBAAkB,IAAI;IAC3C,IAAI,OAAO,WAAW,UAAU;KAC5B,KAAK,UAAU,MAAM;KACrB;IACJ;IACA,IAAI,OAAO,WAAW,OAAO;KACzB,KAAK,UAAU,OAAO,OAAO,QAAQ,8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;CAChC,OAAO,IAAI,SAAQ,YAAW,4BAA4B,QAAQ,CAAC,CAAC;AACxE"}
@@ -35,25 +35,25 @@ var canvasSkills = [
35
35
  {
36
36
  name: "eclipse-docks-canvas",
37
37
  label: "Eclipse Docks canvas",
38
- load: () => import("../skills/eclipse-docks-canvas/SKILL.md?raw"),
38
+ load: () => import("./skills/eclipse-docks-canvas/SKILL.js"),
39
39
  ranking: 100
40
40
  },
41
41
  {
42
42
  name: "eclipse-docks-lit",
43
43
  label: "Eclipse Docks Lit",
44
- load: () => import("../skills/eclipse-docks-lit/SKILL.md?raw"),
44
+ load: () => import("./skills/eclipse-docks-lit/SKILL.js"),
45
45
  ranking: 90
46
46
  },
47
47
  {
48
48
  name: "eclipse-docks-webawesome",
49
49
  label: "Eclipse Docks Web Awesome",
50
- load: () => import("../skills/eclipse-docks-webawesome/SKILL.md?raw"),
50
+ load: () => import("./skills/eclipse-docks-webawesome/SKILL.js"),
51
51
  ranking: 90
52
52
  },
53
53
  {
54
54
  name: "eclipse-docks-core",
55
55
  label: "Eclipse Docks core",
56
- load: () => import("../skills/eclipse-docks-core/SKILL.md?raw"),
56
+ load: () => import("./skills/eclipse-docks-core/SKILL.js"),
57
57
  ranking: 90
58
58
  }
59
59
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-extension.js","names":[],"sources":["../src/canvas-extension.ts"],"sourcesContent":["import {\n contributionRegistry,\n editorRegistry,\n File,\n subscribe,\n TOOLBAR_MAIN_RIGHT,\n TOPIC_CONTRIBUTEIONS_CHANGED,\n type EditorInput,\n type HTMLContribution,\n} from '@eclipse-docks/core';\nimport { html } from '@eclipse-docks/core/externals/lit';\nimport { SYSTEM_SKILLS, type SkillContribution } from '@eclipse-docks/extension-ai-system/api';\nimport { isCanvasContribution, SYSTEM_CANVASES } from './contribution';\nimport { listRegisteredCanvases } from './canvases';\nimport { registerCanvasTools } from './canvas-tools';\nimport { registerCanvasCommands } from './commands';\nimport './canvas-switcher';\n\neditorRegistry.registerEditorInputHandler({\n editorId: 'system.canvas-editor',\n label: 'Canvas',\n icon: 'table-columns',\n ranking: 1100,\n canHandle: (input: unknown) => input instanceof File && input.getName().toLowerCase().endsWith('.canvas.js'),\n handle: async (input: File) => {\n const editorInput = {\n title: input.getName(),\n data: input,\n key: input.getWorkspacePath(),\n icon: 'table-columns',\n state: { mode: 'preview' },\n component: () => html``,\n } as EditorInput;\n editorInput.component = (id: string) => html`<docks-canvas-editor id=\"${id}\" .input=${editorInput}></docks-canvas-editor>`;\n return editorInput;\n },\n});\n\ncontributionRegistry.registerContribution(TOOLBAR_MAIN_RIGHT, {\n name: 'canvas.switcher',\n label: 'Canvases',\n component: () => html`<docks-canvas-switcher></docks-canvas-switcher>`,\n} as HTMLContribution);\n\nconst canvasSkills = [\n {\n name: 'eclipse-docks-canvas',\n label: 'Eclipse Docks canvas',\n load: () => import('../skills/eclipse-docks-canvas/SKILL.md?raw'),\n ranking: 100,\n },\n {\n name: 'eclipse-docks-lit',\n label: 'Eclipse Docks Lit',\n load: () => import('../skills/eclipse-docks-lit/SKILL.md?raw'),\n ranking: 90,\n },\n {\n name: 'eclipse-docks-webawesome',\n label: 'Eclipse Docks Web Awesome',\n load: () => import('../skills/eclipse-docks-webawesome/SKILL.md?raw'),\n ranking: 90,\n },\n {\n name: 'eclipse-docks-core',\n label: 'Eclipse Docks core',\n load: () => import('../skills/eclipse-docks-core/SKILL.md?raw'),\n ranking: 90,\n },\n] as const satisfies ReadonlyArray<SkillContribution>;\n\nfor (const skill of canvasSkills) {\n contributionRegistry.registerContribution(SYSTEM_SKILLS, skill);\n}\n\nfunction registerListedCanvasTools(): void {\n for (const canvas of listRegisteredCanvases()) registerCanvasTools(canvas);\n}\n\nregisterCanvasCommands();\nregisterListedCanvasTools();\nsubscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: { target?: string }) => {\n if (event?.target !== SYSTEM_CANVASES) return;\n for (const contribution of contributionRegistry.getContributions(SYSTEM_CANVASES)) {\n if (isCanvasContribution(contribution)) registerCanvasTools(contribution);\n }\n});\n"],"mappings":";;;;;;;;;AAkBA,eAAe,2BAA2B;CACtC,UAAU;CACV,OAAO;CACP,MAAM;CACN,SAAS;CACT,YAAY,UAAmB,iBAAiB,QAAQ,MAAM,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,YAAY;CAC3G,QAAQ,OAAO,UAAgB;EAC3B,MAAM,cAAc;GAChB,OAAO,MAAM,QAAQ;GACrB,MAAM;GACN,KAAK,MAAM,iBAAiB;GAC5B,MAAM;GACN,OAAO,EAAE,MAAM,UAAU;GACzB,iBAAiB,IAAI;EACzB;EACA,YAAY,aAAa,OAAe,IAAI,4BAA4B,GAAG,WAAW,YAAY;EAClG,OAAO;CACX;AACJ,CAAC;AAED,qBAAqB,qBAAqB,oBAAoB;CAC1D,MAAM;CACN,OAAO;CACP,iBAAiB,IAAI;AACzB,CAAqB;AAErB,IAAM,eAAe;CACjB;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;CACA;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;CACA;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;CACA;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;AACJ;AAEA,KAAK,MAAM,SAAS,cAChB,qBAAqB,qBAAqB,eAAe,KAAK;AAGlE,SAAS,4BAAkC;CACvC,KAAK,MAAM,UAAU,uBAAuB,GAAG,oBAAoB,MAAM;AAC7E;AAEA,uBAAuB;AACvB,0BAA0B;AAC1B,UAAU,+BAA+B,UAA+B;CACpE,IAAI,OAAO,WAAA,mBAA4B;CACvC,KAAK,MAAM,gBAAgB,qBAAqB,iBAAiB,eAAe,GAC5E,IAAI,qBAAqB,YAAY,GAAG,oBAAoB,YAAY;AAEhF,CAAC"}
1
+ {"version":3,"file":"canvas-extension.js","names":[],"sources":["../src/canvas-extension.ts"],"sourcesContent":["import {\n contributionRegistry,\n editorRegistry,\n File,\n subscribe,\n TOOLBAR_MAIN_RIGHT,\n TOPIC_CONTRIBUTEIONS_CHANGED,\n type EditorInput,\n type HTMLContribution,\n} from '@eclipse-docks/core';\nimport { html } from '@eclipse-docks/core/externals/lit';\nimport { SYSTEM_SKILLS, type SkillContribution } from '@eclipse-docks/extension-ai-system/api';\nimport { isCanvasContribution, SYSTEM_CANVASES } from './contribution';\nimport { listRegisteredCanvases } from './canvases';\nimport { registerCanvasTools } from './canvas-tools';\nimport { registerCanvasCommands } from './commands';\nimport './canvas-switcher';\n\neditorRegistry.registerEditorInputHandler({\n editorId: 'system.canvas-editor',\n label: 'Canvas',\n icon: 'table-columns',\n ranking: 1100,\n canHandle: (input: unknown) => input instanceof File && input.getName().toLowerCase().endsWith('.canvas.js'),\n handle: async (input: File) => {\n const editorInput = {\n title: input.getName(),\n data: input,\n key: input.getWorkspacePath(),\n icon: 'table-columns',\n state: { mode: 'preview' },\n component: () => html``,\n } as EditorInput;\n editorInput.component = (id: string) => html`<docks-canvas-editor id=\"${id}\" .input=${editorInput}></docks-canvas-editor>`;\n return editorInput;\n },\n});\n\ncontributionRegistry.registerContribution(TOOLBAR_MAIN_RIGHT, {\n name: 'canvas.switcher',\n label: 'Canvases',\n component: () => html`<docks-canvas-switcher></docks-canvas-switcher>`,\n} as HTMLContribution);\n\nconst canvasSkills = [\n {\n name: 'eclipse-docks-canvas',\n label: 'Eclipse Docks canvas',\n load: () => import('./skills/eclipse-docks-canvas/SKILL.md?raw'),\n ranking: 100,\n },\n {\n name: 'eclipse-docks-lit',\n label: 'Eclipse Docks Lit',\n load: () => import('./skills/eclipse-docks-lit/SKILL.md?raw'),\n ranking: 90,\n },\n {\n name: 'eclipse-docks-webawesome',\n label: 'Eclipse Docks Web Awesome',\n load: () => import('./skills/eclipse-docks-webawesome/SKILL.md?raw'),\n ranking: 90,\n },\n {\n name: 'eclipse-docks-core',\n label: 'Eclipse Docks core',\n load: () => import('./skills/eclipse-docks-core/SKILL.md?raw'),\n ranking: 90,\n },\n] as const satisfies ReadonlyArray<SkillContribution>;\n\nfor (const skill of canvasSkills) {\n contributionRegistry.registerContribution(SYSTEM_SKILLS, skill);\n}\n\nfunction registerListedCanvasTools(): void {\n for (const canvas of listRegisteredCanvases()) registerCanvasTools(canvas);\n}\n\nregisterCanvasCommands();\nregisterListedCanvasTools();\nsubscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: { target?: string }) => {\n if (event?.target !== SYSTEM_CANVASES) return;\n for (const contribution of contributionRegistry.getContributions(SYSTEM_CANVASES)) {\n if (isCanvasContribution(contribution)) registerCanvasTools(contribution);\n }\n});\n"],"mappings":";;;;;;;;;AAkBA,eAAe,2BAA2B;CACtC,UAAU;CACV,OAAO;CACP,MAAM;CACN,SAAS;CACT,YAAY,UAAmB,iBAAiB,QAAQ,MAAM,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,YAAY;CAC3G,QAAQ,OAAO,UAAgB;EAC3B,MAAM,cAAc;GAChB,OAAO,MAAM,QAAQ;GACrB,MAAM;GACN,KAAK,MAAM,iBAAiB;GAC5B,MAAM;GACN,OAAO,EAAE,MAAM,UAAU;GACzB,iBAAiB,IAAI;EACzB;EACA,YAAY,aAAa,OAAe,IAAI,4BAA4B,GAAG,WAAW,YAAY;EAClG,OAAO;CACX;AACJ,CAAC;AAED,qBAAqB,qBAAqB,oBAAoB;CAC1D,MAAM;CACN,OAAO;CACP,iBAAiB,IAAI;AACzB,CAAqB;AAErB,IAAM,eAAe;CACjB;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;CACA;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;CACA;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;CACA;EACI,MAAM;EACN,OAAO;EACP,YAAY,OAAO;EACnB,SAAS;CACb;AACJ;AAEA,KAAK,MAAM,SAAS,cAChB,qBAAqB,qBAAqB,eAAe,KAAK;AAGlE,SAAS,4BAAkC;CACvC,KAAK,MAAM,UAAU,uBAAuB,GAAG,oBAAoB,MAAM;AAC7E;AAEA,uBAAuB;AACvB,0BAA0B;AAC1B,UAAU,+BAA+B,UAA+B;CACpE,IAAI,OAAO,WAAA,mBAA4B;CACvC,KAAK,MAAM,gBAAgB,qBAAqB,iBAAiB,eAAe,GAC5E,IAAI,qBAAqB,YAAY,GAAG,oBAAoB,YAAY;AAEhF,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import "./contribution.js";
2
2
  import { listRegisteredCanvases } from "./canvases.js";
3
- import __decorate from "./_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
3
  import { openCanvasByName } from "./commands.js";
5
4
  import { DocksElement, TOPIC_CONTRIBUTEIONS_CHANGED, icon, subscribe, unsubscribe } from "@eclipse-docks/core";
6
5
  import { css, customElement, html, state } from "@eclipse-docks/core/externals/lit";
6
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
7
7
  //#region src/canvas-switcher.ts
8
8
  var DocksCanvasSwitcher = class DocksCanvasSwitcher extends DocksElement {
9
9
  constructor(..._args) {
@@ -51,8 +51,8 @@ var DocksCanvasSwitcher = class DocksCanvasSwitcher extends DocksElement {
51
51
  `;
52
52
  }
53
53
  };
54
- __decorate([state()], DocksCanvasSwitcher.prototype, "canvases", void 0);
55
- DocksCanvasSwitcher = __decorate([customElement("docks-canvas-switcher")], DocksCanvasSwitcher);
54
+ _decorate([state()], DocksCanvasSwitcher.prototype, "canvases", void 0);
55
+ DocksCanvasSwitcher = _decorate([customElement("docks-canvas-switcher")], DocksCanvasSwitcher);
56
56
  //#endregion
57
57
  export { DocksCanvasSwitcher };
58
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-switcher.js","names":["_decorate"],"sources":["../src/canvas-switcher.ts"],"sourcesContent":["import { DocksElement, icon, subscribe, TOPIC_CONTRIBUTEIONS_CHANGED, unsubscribe } from '@eclipse-docks/core';\nimport { css, html } from '@eclipse-docks/core/externals/lit';\nimport { customElement, state } from '@eclipse-docks/core/externals/lit';\nimport { listRegisteredCanvases } from './canvases';\nimport { SYSTEM_CANVASES } from './contribution';\nimport { openCanvasByName } from './commands';\n\n@customElement('docks-canvas-switcher')\nexport class DocksCanvasSwitcher extends DocksElement {\n @state() private canvases = listRegisteredCanvases();\n private topic?: string;\n\n protected doBeforeUI() {\n this.topic = subscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: { target?: string }) => {\n if (event?.target !== SYSTEM_CANVASES) return;\n this.canvases = listRegisteredCanvases();\n });\n }\n\n disconnectedCallback() {\n if (this.topic) unsubscribe(this.topic);\n super.disconnectedCallback();\n }\n\n private onSelect = (event: CustomEvent) => {\n const item = event.detail?.item as HTMLElement & { value?: string } | undefined;\n const name = item?.value || item?.getAttribute('value');\n if (!name) return;\n void openCanvasByName(name);\n };\n\n protected render() {\n if (this.canvases.length === 0) return html``;\n return html`\n <wa-dropdown placement=\"bottom-end\" distance=\"4\" size=\"s\" @wa-select=${this.onSelect}>\n <wa-button slot=\"trigger\" appearance=\"plain\" size=\"s\" with-caret title=\"Canvases\">\n ${icon('table-columns', { label: 'Canvases' })}\n </wa-button>\n ${this.canvases.map(canvas => html`\n <wa-dropdown-item value=\"${canvas.name ?? ''}\">\n ${icon(canvas.icon, { label: canvas.label, slot: 'icon' })}\n ${canvas.label}\n </wa-dropdown-item>\n `)}\n </wa-dropdown>\n `;\n }\n\n static styles = css`\n :host { display: inline-block; }\n `;\n}\n"],"mappings":";;;;;;;AAQO,IAAM,sBAAN,MAAM,4BAA4B,aAAa;;;EACtB,KAAA,WAAA,uBAAuB;EAe/B,KAAA,YAAA,UAAuB;GACvC,MAAM,OAAO,MAAM,QAAQ;GAC3B,MAAM,OAAO,MAAM,SAAS,MAAM,aAAa,OAAO;GACtD,IAAI,CAAC,MAAM;GACX,iBAAsB,IAAI;EAC9B;;CAjBA,aAAuB;EACnB,KAAK,QAAQ,UAAU,+BAA+B,UAA+B;GACjF,IAAI,OAAO,WAAA,mBAA4B;GACvC,KAAK,WAAW,uBAAuB;EAC3C,CAAC;CACL;CAEA,uBAAuB;EACnB,IAAI,KAAK,OAAO,YAAY,KAAK,KAAK;EACtC,MAAM,qBAAqB;CAC/B;CASA,SAAmB;EACf,IAAI,KAAK,SAAS,WAAW,GAAG,OAAO,IAAI;EAC3C,OAAO,IAAI;mFACgE,KAAK,SAAS;;sBAE3E,KAAK,iBAAiB,EAAE,OAAO,WAAW,CAAC,EAAE;;kBAEjD,KAAK,SAAS,KAAI,WAAU,IAAI;+CACH,OAAO,QAAQ,GAAG;0BACvC,KAAK,OAAO,MAAM;GAAE,OAAO,OAAO;GAAO,MAAM;EAAO,CAAC,EAAE;0BACzD,OAAO,MAAM;;iBAEtB,EAAE;;;CAGf;;EAEgB,KAAA,SAAA,GAAG;;;;AAGvB;AA1CKA,WAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,YAAA,KAAA,CAAA;AAFV,sBAAAA,WAAA,CAAA,cAAc,uBAAuB,CAAA,GAAA,mBAAA"}
1
+ {"version":3,"file":"canvas-switcher.js","names":[],"sources":["../src/canvas-switcher.ts"],"sourcesContent":["import { DocksElement, icon, subscribe, TOPIC_CONTRIBUTEIONS_CHANGED, unsubscribe } from '@eclipse-docks/core';\nimport { css, html } from '@eclipse-docks/core/externals/lit';\nimport { customElement, state } from '@eclipse-docks/core/externals/lit';\nimport { listRegisteredCanvases } from './canvases';\nimport { SYSTEM_CANVASES } from './contribution';\nimport { openCanvasByName } from './commands';\n\n@customElement('docks-canvas-switcher')\nexport class DocksCanvasSwitcher extends DocksElement {\n @state() private canvases = listRegisteredCanvases();\n private topic?: string;\n\n protected doBeforeUI() {\n this.topic = subscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: { target?: string }) => {\n if (event?.target !== SYSTEM_CANVASES) return;\n this.canvases = listRegisteredCanvases();\n });\n }\n\n disconnectedCallback() {\n if (this.topic) unsubscribe(this.topic);\n super.disconnectedCallback();\n }\n\n private onSelect = (event: CustomEvent) => {\n const item = event.detail?.item as HTMLElement & { value?: string } | undefined;\n const name = item?.value || item?.getAttribute('value');\n if (!name) return;\n void openCanvasByName(name);\n };\n\n protected render() {\n if (this.canvases.length === 0) return html``;\n return html`\n <wa-dropdown placement=\"bottom-end\" distance=\"4\" size=\"s\" @wa-select=${this.onSelect}>\n <wa-button slot=\"trigger\" appearance=\"plain\" size=\"s\" with-caret title=\"Canvases\">\n ${icon('table-columns', { label: 'Canvases' })}\n </wa-button>\n ${this.canvases.map(canvas => html`\n <wa-dropdown-item value=\"${canvas.name ?? ''}\">\n ${icon(canvas.icon, { label: canvas.label, slot: 'icon' })}\n ${canvas.label}\n </wa-dropdown-item>\n `)}\n </wa-dropdown>\n `;\n }\n\n static styles = css`\n :host { display: inline-block; }\n `;\n}\n"],"mappings":";;;;;;;AAQO,IAAM,sBAAN,MAAM,4BAA4B,aAAa;;;EACtB,KAAA,WAAA,uBAAuB;EAe/B,KAAA,YAAA,UAAuB;GACvC,MAAM,OAAO,MAAM,QAAQ;GAC3B,MAAM,OAAO,MAAM,SAAS,MAAM,aAAa,OAAO;GACtD,IAAI,CAAC,MAAM;GACX,iBAAsB,IAAI;EAC9B;;CAjBA,aAAuB;EACnB,KAAK,QAAQ,UAAU,+BAA+B,UAA+B;GACjF,IAAI,OAAO,WAAA,mBAA4B;GACvC,KAAK,WAAW,uBAAuB;EAC3C,CAAC;CACL;CAEA,uBAAuB;EACnB,IAAI,KAAK,OAAO,YAAY,KAAK,KAAK;EACtC,MAAM,qBAAqB;CAC/B;CASA,SAAmB;EACf,IAAI,KAAK,SAAS,WAAW,GAAG,OAAO,IAAI;EAC3C,OAAO,IAAI;mFACgE,KAAK,SAAS;;sBAE3E,KAAK,iBAAiB,EAAE,OAAO,WAAW,CAAC,EAAE;;kBAEjD,KAAK,SAAS,KAAI,WAAU,IAAI;+CACH,OAAO,QAAQ,GAAG;0BACvC,KAAK,OAAO,MAAM;GAAE,OAAO,OAAO;GAAO,MAAM;EAAO,CAAC,EAAE;0BACzD,OAAO,MAAM;;iBAEtB,EAAE;;;CAGf;;EAEgB,KAAA,SAAA,GAAG;;;;AAGvB;AA1CK,UAAA,CAAA,MAAM,CAAA,GAAA,oBAAA,WAAA,YAAA,KAAA,CAAA;AAFV,sBAAA,UAAA,CAAA,cAAc,uBAAuB,CAAA,GAAA,mBAAA"}
@@ -0,0 +1,6 @@
1
+ //#region src/skills/eclipse-docks-canvas/SKILL.md?raw
2
+ var SKILL_default = "---\nname: eclipse-docks-canvas\ndescription: >-\n Create or edit interactive Eclipse Docks canvases (.canvas.js): LitElement UIs,\n dashboards, todo apps, widgets, maps, and previewable tools. Use when the user\n wants an interactive view, canvas, widget, or .canvas.js file — even if they do\n not say \"canvas\".\n---\n\n# Eclipse Docks canvas\n\nWrite a workspace file ending in `.canvas.js`. Default-export a `LitElement` subclass from `docks/lit`. Do **not** extend `HTMLElement`. Do **not** call `customElements.define` — the host registers the tag.\n\n## Hard rules\n\n1. **`canvasHost` is unavailable in `constructor`.** The host sets `this.canvasHost` after construction. Read/write persisted state in `connectedCallback` (after `super`) or later. Always guard: `this.canvasHost?.getState` / `setState`.\n2. Pure JavaScript only — no TypeScript, no decorators. Declare reactive fields with `static properties = { … }`. Initialize plain defaults in `constructor`; hydrate from `canvasHost` only after connect.\n3. Build controls and chrome with Web Awesome (`wa-button`, `wa-input`, `wa-checkbox`, `wa-card`, `wa-callout`, `wa-spinner`). `import \"docks/webawesome\"` only registers the elements; a raw `<button>` or `<input>` is not a substitute. Load `eclipse-docks-webawesome` before a non-trivial UI, and use `--wa-color-*` tokens instead of hardcoded colors.\n4. Emit complete, valid JavaScript — no truncated objects or unfinished strings.\n5. The page uses `Cross-Origin-Embedder-Policy: require-corp`. A cross-origin response loads only when the request is CORS and the server sends `Access-Control-Allow-Origin`, or when the server sends `Cross-Origin-Resource-Policy: cross-origin`. An `<iframe srcdoc>` inherits this policy; `sandbox=\"allow-same-origin\"` does not exempt it. Keep `docks/lit`, `docks/webawesome`, and `canvasHost` on the LitElement.\n\n## Minimal pattern\n\n```js\nimport { LitElement, html, css } from \"docks/lit\";\nimport \"docks/webawesome\";\n\nexport default class extends LitElement {\n static properties = {\n items: { state: true },\n draft: { state: true },\n };\n\n static styles = css`\n :host { display: block; padding: 1rem; box-sizing: border-box; }\n `;\n\n constructor() {\n super();\n this.items = [];\n this.draft = \"\";\n }\n\n connectedCallback() {\n super.connectedCallback();\n const saved = this.canvasHost?.getState(\"items\", null);\n if (Array.isArray(saved)) this.items = saved;\n }\n\n persist() {\n this.canvasHost?.setState(\"items\", this.items);\n }\n\n addItem() {\n const input = this.renderRoot.querySelector(\"wa-input\");\n const text = String(input?.value ?? \"\").trim();\n if (!text) return;\n this.items = [...this.items, { id: crypto.randomUUID(), text, done: false }];\n this.draft = \"\";\n this.persist();\n }\n\n render() {\n return html`\n <wa-input\n placeholder=\"New item\"\n .value=${this.draft}\n @keydown=${(e) => { if (e.key === \"Enter\") this.addItem(); }}\n ></wa-input>\n <wa-button @click=${() => this.addItem()}>Add</wa-button>\n <ul>\n ${this.items.map((item) => html`<li>${item.text}</li>`)}\n </ul>\n `;\n }\n}\n```\n\nAPIs: `this.canvasHost.getState(key, fallback)`, `this.canvasHost.setState(key, value)`, `this.canvasHost.openFile(path)`.\n\n## Cross-origin resources\n\n`<img>`, `<link>`, and `<script>` tags without `crossorigin` are no-cors. A no-cors response that omits `Cross-Origin-Resource-Policy` fails with `not-set cross-origin-resource-policy`, even when it sends `Access-Control-Allow-Origin: *`. Moving that URL into an `<iframe srcdoc>` does not change the check. Subresources inside the frame follow the same rule.\n\nWhen the server only sends `Access-Control-Allow-Origin`, request the resource as CORS. `fetch()` already does. For an element, set `crossorigin=\"anonymous\"`. When a library creates the element, set its equivalent option (often `crossOrigin: \"anonymous\"`). A missing `Access-Control-Allow-Origin` header on that request is a CORS error, not the CORP error.\n\n```html\n<img crossorigin=\"anonymous\" src=\"https://cdn.example/asset.png\" />\n<script crossorigin=\"anonymous\" src=\"https://cdn.example/lib.js\"><\/script>\n```\n\nA host that sends neither header cannot be embedded in this page. Pass the string `\"anonymous\"` to a library option (`crossOrigin: \"anonymous\"`). A boolean `true` is not that option.\n\n## Styles inside the shadow root\n\nThe canvas renders in a shadow root. A `<link>` or `<style>` added to `document.head` does not apply to nodes inside that root. A widget that positions its own DOM with classes will load its images and still draw them in the wrong place until its stylesheet is on the shadow root.\n\nFetch the stylesheet as CORS and adopt it before constructing the widget:\n\n```js\nconst cssText = await (await fetch(stylesheetUrl, { mode: \"cors\" })).text();\nconst sheet = new CSSStyleSheet();\nsheet.replaceSync(cssText);\nthis.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, sheet];\n```\n\n`static styles` is for the host. Do not rely on a document-level stylesheet for DOM the library creates inside the shadow root.\n\n## Imports\n\n- `docks/lit`, `docks/webawesome`, `docks/core` → running app\n- Relative imports → workspace files (compiler inlines them: JSON → value, text/CSS → string, binaries → data URL)\n\nBefore non-trivial UI or shell integration, load companion skills as needed:\n\n- `skills.load` `eclipse-docks-lit` — reactive properties, templates, directives (pure JS)\n- `skills.load` `eclipse-docks-webawesome` — `wa-*` components and layout utilities\n- `skills.load` `eclipse-docks-core` — workspace, editors, commands, dialogs, events\n\n## Workflow\n\n1. `workspace_write` a durable `<root>/….canvas.js` (qualify with a root from `workspace_list`).\n2. `canvas.open` with that path — returns `ready` or the compile/runtime error.\n3. Change a canvas with `canvas.apply_source`. If that canvas is open in an editor, the editor marks itself dirty and recompiles the preview and does not save. If it is not open in an editor, the tool writes the file. Do not `workspace_write` a canvas that is already open.\n4. Optional: `canvas.capture_preview` to attach a screenshot (iframe contents may be blank).\n\nExtension-registered canvases live on `system.canvases` and open by name via `canvas.open`.\n";
3
+ //#endregion
4
+ export { SKILL_default as default };
5
+
6
+ //# sourceMappingURL=SKILL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SKILL.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ //#region 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`. Subpaths map to the same bridges, e.g. `docks/core/parts`, `docks/core/widgets`, `docks/core/externals/lit`.\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- Canvases can also open a path via `this.canvasHost.openFile(path)` without importing core.\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`) with a `load()` that returns `{ default: CustomElementConstructor }`.\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- Host persistence for a workspace `.canvas.js` is `canvasHost.getState` / `setState`, not `appSettings`, unless you intentionally share app-wide settings.\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- Keep UI building blocks on `docks/lit` + `docks/webawesome`; use `docks/core` for shell integration.\n\n## Anti-patterns\n\n- Bare filenames at the composite workspace root when a durable root prefix is required\n- Assuming `canvasHost` APIs exist on arbitrary LitElements outside a canvas mount\n- Re-implementing toast/dialog with `alert` when core helpers are available\n";
3
+ //#endregion
4
+ export { SKILL_default as default };
5
+
6
+ //# sourceMappingURL=SKILL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SKILL.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ //#region src/skills/eclipse-docks-lit/SKILL.md?raw
2
+ var SKILL_default = "---\nname: eclipse-docks-lit\ndescription: >-\n LitElement patterns for Eclipse Docks canvases and UI code via docks/lit.\n Use when writing or fixing .canvas.js, Lit templates, reactive properties,\n directives, or styles — pure JavaScript only (no TypeScript decorators).\n---\n\n# Eclipse Docks Lit (`docks/lit`)\n\nImport from `docks/lit` (same module as `@eclipse-docks/core/externals/lit`). In `.canvas.js` files use **pure JavaScript only** — no TypeScript, no decorators (`@property`, `@state`, `@customElement` are unavailable).\n\n## Essentials\n\n```js\nimport { LitElement, html, css, nothing } from \"docks/lit\";\n```\n\n- Default-export a `LitElement` subclass for canvases. Do **not** call `customElements.define` in a canvas — the host registers the tag.\n- Reactive fields: `static properties = { count: { state: true }, label: { type: String } }`.\n- Initialize defaults in `constructor` after `super()`.\n- Styles: `static styles = css\\`:host { display: block; }\\`;` (or an array of `css` results).\n- Templates: `render() { return html\\`...\\`; }` — use `nothing` for empty branches.\n\n## Property options (common)\n\n| Option | Meaning |\n| --- | --- |\n| `state: true` | Internal reactive state (not an attribute) |\n| `type: String` / `Number` / `Boolean` / `Object` / `Array` | Attribute reflection helpers |\n| `attribute: false` | Do not mirror to an attribute |\n| `reflect: true` | Reflect property → attribute |\n\nAssign **new** values for objects/arrays (`this.items = [...this.items, next]`), do not mutate in place if you need an update.\n\n## Directives\n\nNamed exports from `docks/lit` (also available as in Lit docs):\n\n```js\nimport { repeat, when, classMap, styleMap, ifDefined, live, ref, keyed } from \"docks/lit\";\n```\n\n- `repeat(items, (i) => i.id, (i) => html\\`...\\`)` for keyed lists\n- `when(cond, () => html\\`...\\`)` / `nothing` for conditionals\n- `classMap({ active: isOn })`, `styleMap({ width: \"1rem\" })`\n- `live(value)` when binding to form controls that can diverge from the property\n- Prefer `.value=${x}` (property) over `value=${x}` (attribute) for form controls\n\n## Events in templates\n\n```js\nhtml`<wa-button @click=${this.onSave}>Save</wa-button>`\n```\n\nUse arrow functions or bound methods so `this` stays the element. For `wa-*` props and events, follow `eclipse-docks-webawesome`.\n\n## Signals (optional)\n\n`docks/lit` also re-exports `@lit-labs/signals` helpers: `signal`, `computed`, `watch`, `SignalWatcher`, `withWatch`. Prefer `static properties` for simple canvas state unless you already use signals.\n\n## Anti-patterns\n\n- Decorators or `.ts` syntax in `.canvas.js`\n- Mutating arrays/objects in place without reassignment\n- Relying on `this` inside a non-arrow inline handler incorrectly\n- Calling `customElements.define` from a workspace canvas module\n";
3
+ //#endregion
4
+ export { SKILL_default as default };
5
+
6
+ //# sourceMappingURL=SKILL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SKILL.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ //#region src/skills/eclipse-docks-webawesome/SKILL.md?raw
2
+ var SKILL_default = "---\nname: eclipse-docks-webawesome\ndescription: >-\n Web Awesome UI in Eclipse Docks via docks/webawesome. Use when building\n buttons, inputs, selects, checkboxes, dialogs, forms, icons, or layout\n utilities in canvases or Docks UI. Fetch the official component page before\n writing wa-* markup.\n---\n\n# Eclipse Docks Web Awesome (`docks/webawesome`)\n\n```js\nimport \"docks/webawesome\";\n```\n\nThat import registers the components, the theme, and the `docks` icon library. Canvas files use this import. Custom elements take a closing tag: `<wa-input></wa-input>`.\n\n## Look up the component, then write it\n\nFetch the official page for each tag before using its props, slots, or events. Use that page's events table. Ignore the overview line that says to listen for `wa-input` or `wa-change`.\n\n- Index: https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome/SKILL.md\n- One component: `https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome/references/components/<name>.md` (`button`, `input`, `checkbox`, `select`, …)\n- Which component: https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome/references/choosing-components.md\n- Layout, tokens, theming: https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome-design/SKILL.md\n\nBind properties (`.value`, `.checked`). Listen for the events that page lists.\n\n## `wa-input` and `wa-number-input`\n\nTheir pages list an `input` event. This build copies keystrokes onto `.value` and does not re-dispatch `input`, so a host `@input` listener never runs. `change` fires on blur, after a click handler.\n\nRead `.value` in the click or Enter handler. For live text, use `@keyup` and assign `e.target.value`. `wa-textarea` does re-dispatch `input`.\n\n## Docks\n\n- Shell icons: `<wa-icon library=\"docks\" name=\"…\"></wa-icon>`. Other icons use the names on the icon page.\n- Color comes from `--wa-color-*` tokens so the loaded theme covers light and dark.\n- Shell toasts: `toastInfo` / `toastError` from `docks/core` when that module is already loaded.\n";
3
+ //#endregion
4
+ export { SKILL_default as default };
5
+
6
+ //# sourceMappingURL=SKILL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SKILL.js","names":[],"sources":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-docks/extension-canvas",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -16,8 +16,7 @@
16
16
  }
17
17
  },
18
18
  "files": [
19
- "dist",
20
- "skills"
19
+ "dist"
21
20
  ],
22
21
  "scripts": {
23
22
  "build": "vite build",
@@ -1,9 +0,0 @@
1
- //#region \0@oxc-project+runtime@0.152.0/helpers/esm/decorate.js
2
- function __decorate(decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- }
8
- //#endregion
9
- export { __decorate as default };
@@ -1,127 +0,0 @@
1
- ---
2
- name: eclipse-docks-canvas
3
- description: >-
4
- Create or edit interactive Eclipse Docks canvases (.canvas.js): LitElement UIs,
5
- dashboards, todo apps, widgets, maps, and previewable tools. Use when the user
6
- wants an interactive view, canvas, widget, or .canvas.js file — even if they do
7
- not say "canvas".
8
- ---
9
-
10
- # Eclipse Docks canvas
11
-
12
- Write a workspace file ending in `.canvas.js`. Default-export a `LitElement` subclass from `docks/lit`. Do **not** extend `HTMLElement`. Do **not** call `customElements.define` — the host registers the tag.
13
-
14
- ## Hard rules
15
-
16
- 1. **`canvasHost` is unavailable in `constructor`.** The host sets `this.canvasHost` after construction. Read/write persisted state in `connectedCallback` (after `super`) or later. Always guard: `this.canvasHost?.getState` / `setState`.
17
- 2. Pure JavaScript only — no TypeScript, no decorators. Declare reactive fields with `static properties = { … }`. Initialize plain defaults in `constructor`; hydrate from `canvasHost` only after connect.
18
- 3. Build controls and chrome with Web Awesome (`wa-button`, `wa-input`, `wa-checkbox`, `wa-card`, `wa-callout`, `wa-spinner`). `import "docks/webawesome"` only registers the elements; a raw `<button>` or `<input>` is not a substitute. Load `eclipse-docks-webawesome` before a non-trivial UI, and use `--wa-color-*` tokens instead of hardcoded colors.
19
- 4. Emit complete, valid JavaScript — no truncated objects or unfinished strings.
20
- 5. The page uses `Cross-Origin-Embedder-Policy: require-corp`. A cross-origin response loads only when the request is CORS and the server sends `Access-Control-Allow-Origin`, or when the server sends `Cross-Origin-Resource-Policy: cross-origin`. An `<iframe srcdoc>` inherits this policy; `sandbox="allow-same-origin"` does not exempt it. Keep `docks/lit`, `docks/webawesome`, and `canvasHost` on the LitElement.
21
-
22
- ## Minimal pattern
23
-
24
- ```js
25
- import { LitElement, html, css } from "docks/lit";
26
- import "docks/webawesome";
27
-
28
- export default class extends LitElement {
29
- static properties = {
30
- items: { state: true },
31
- draft: { state: true },
32
- };
33
-
34
- static styles = css`
35
- :host { display: block; padding: 1rem; box-sizing: border-box; }
36
- `;
37
-
38
- constructor() {
39
- super();
40
- this.items = [];
41
- this.draft = "";
42
- }
43
-
44
- connectedCallback() {
45
- super.connectedCallback();
46
- const saved = this.canvasHost?.getState("items", null);
47
- if (Array.isArray(saved)) this.items = saved;
48
- }
49
-
50
- persist() {
51
- this.canvasHost?.setState("items", this.items);
52
- }
53
-
54
- addItem() {
55
- const input = this.renderRoot.querySelector("wa-input");
56
- const text = String(input?.value ?? "").trim();
57
- if (!text) return;
58
- this.items = [...this.items, { id: crypto.randomUUID(), text, done: false }];
59
- this.draft = "";
60
- this.persist();
61
- }
62
-
63
- render() {
64
- return html`
65
- <wa-input
66
- placeholder="New item"
67
- .value=${this.draft}
68
- @keydown=${(e) => { if (e.key === "Enter") this.addItem(); }}
69
- ></wa-input>
70
- <wa-button @click=${() => this.addItem()}>Add</wa-button>
71
- <ul>
72
- ${this.items.map((item) => html`<li>${item.text}</li>`)}
73
- </ul>
74
- `;
75
- }
76
- }
77
- ```
78
-
79
- APIs: `this.canvasHost.getState(key, fallback)`, `this.canvasHost.setState(key, value)`, `this.canvasHost.openFile(path)`.
80
-
81
- ## Cross-origin resources
82
-
83
- `<img>`, `<link>`, and `<script>` tags without `crossorigin` are no-cors. A no-cors response that omits `Cross-Origin-Resource-Policy` fails with `not-set cross-origin-resource-policy`, even when it sends `Access-Control-Allow-Origin: *`. Moving that URL into an `<iframe srcdoc>` does not change the check. Subresources inside the frame follow the same rule.
84
-
85
- When the server only sends `Access-Control-Allow-Origin`, request the resource as CORS. `fetch()` already does. For an element, set `crossorigin="anonymous"`. When a library creates the element, set its equivalent option (often `crossOrigin: "anonymous"`). A missing `Access-Control-Allow-Origin` header on that request is a CORS error, not the CORP error.
86
-
87
- ```html
88
- <img crossorigin="anonymous" src="https://cdn.example/asset.png" />
89
- <script crossorigin="anonymous" src="https://cdn.example/lib.js"></script>
90
- ```
91
-
92
- A host that sends neither header cannot be embedded in this page. Pass the string `"anonymous"` to a library option (`crossOrigin: "anonymous"`). A boolean `true` is not that option.
93
-
94
- ## Styles inside the shadow root
95
-
96
- The canvas renders in a shadow root. A `<link>` or `<style>` added to `document.head` does not apply to nodes inside that root. A widget that positions its own DOM with classes will load its images and still draw them in the wrong place until its stylesheet is on the shadow root.
97
-
98
- Fetch the stylesheet as CORS and adopt it before constructing the widget:
99
-
100
- ```js
101
- const cssText = await (await fetch(stylesheetUrl, { mode: "cors" })).text();
102
- const sheet = new CSSStyleSheet();
103
- sheet.replaceSync(cssText);
104
- this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, sheet];
105
- ```
106
-
107
- `static styles` is for the host. Do not rely on a document-level stylesheet for DOM the library creates inside the shadow root.
108
-
109
- ## Imports
110
-
111
- - `docks/lit`, `docks/webawesome`, `docks/core` → running app
112
- - Relative imports → workspace files (compiler inlines them: JSON → value, text/CSS → string, binaries → data URL)
113
-
114
- Before non-trivial UI or shell integration, load companion skills as needed:
115
-
116
- - `skills.load` `eclipse-docks-lit` — reactive properties, templates, directives (pure JS)
117
- - `skills.load` `eclipse-docks-webawesome` — `wa-*` components and layout utilities
118
- - `skills.load` `eclipse-docks-core` — workspace, editors, commands, dialogs, events
119
-
120
- ## Workflow
121
-
122
- 1. `workspace_write` a durable `<root>/….canvas.js` (qualify with a root from `workspace_list`).
123
- 2. `canvas.open` with that path — returns `ready` or the compile/runtime error.
124
- 3. Change a canvas with `canvas.apply_source`. If that canvas is open in an editor, the editor marks itself dirty and recompiles the preview and does not save. If it is not open in an editor, the tool writes the file. Do not `workspace_write` a canvas that is already open.
125
- 4. Optional: `canvas.capture_preview` to attach a screenshot (iframe contents may be blank).
126
-
127
- Extension-registered canvases live on `system.canvases` and open by name via `canvas.open`.
@@ -1,132 +0,0 @@
1
- ---
2
- name: eclipse-docks-core
3
- description: >-
4
- Eclipse Docks core runtime from docks/core: workspace files, editors, commands,
5
- contributions, dialogs, toasts, settings, and events. Use when a canvas or
6
- extension needs to open files, register UI, run commands, or talk to the shell.
7
- ---
8
-
9
- # Eclipse Docks core (`docks/core`)
10
-
11
- ```js
12
- import {
13
- workspaceService,
14
- File,
15
- editorRegistry,
16
- commandRegistry,
17
- registerAll,
18
- contributionRegistry,
19
- publish,
20
- subscribe,
21
- unsubscribe,
22
- appSettings,
23
- toastInfo,
24
- toastError,
25
- confirmDialog,
26
- promptDialog,
27
- filebrowserDialog,
28
- } from "docks/core";
29
- ```
30
-
31
- Alias: `@eclipse-docks/core`. Subpaths map to the same bridges, e.g. `docks/core/parts`, `docks/core/widgets`, `docks/core/externals/lit`.
32
-
33
- ## Workspace
34
-
35
- ```js
36
- const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();
37
- const resource = await workspace.getResource("folder/note.md");
38
- if (resource instanceof File) {
39
- const text = await resource.getContents();
40
- await resource.saveContents(text);
41
- }
42
- ```
43
-
44
- - Paths are workspace-relative (root-prefixed in the composite workspace).
45
- - Create with `getResource(path, { create: true })` when the API allows.
46
- - Canvases can also open a path via `this.canvasHost.openFile(path)` without importing core.
47
-
48
- ## Editors
49
-
50
- ```js
51
- await editorRegistry.loadEditor(file); // default handler
52
- await editorRegistry.loadEditor(file, "system.canvas-editor");
53
- ```
54
-
55
- `EditorInput` objects carry `title`, `key`, `data`, `component`, optional `state`. Prefer opening a `File` when one exists.
56
-
57
- ## Commands
58
-
59
- ```js
60
- registerAll({
61
- command: {
62
- id: "demo.ping",
63
- name: "Ping",
64
- description: "Demo command",
65
- parameters: [],
66
- },
67
- handler: {
68
- execute: async () => "pong",
69
- },
70
- });
71
-
72
- await commandRegistry.execute("demo.ping", {});
73
- ```
74
-
75
- Commands registered this way can surface as AI tools when the cognitive runtime refreshes command tools.
76
-
77
- ## Contributions
78
-
79
- ```js
80
- import { SIDEBAR_MAIN, TOOLBAR_MAIN_RIGHT } from "docks/core";
81
-
82
- contributionRegistry.registerContribution(SIDEBAR_MAIN, {
83
- name: "demo.view",
84
- label: "Demo",
85
- icon: "star",
86
- component: (id) => /* Lit html template for the view */ null,
87
- });
88
- ```
89
-
90
- Common slots: sidebars, panel bottom, toolbars, settings. Canvas modules contributed by extensions use `system.canvases` (`SYSTEM_CANVASES` from `@eclipse-docks/extension-canvas/contribution`) with a `load()` that returns `{ default: CustomElementConstructor }`.
91
-
92
- ## Dialogs & toasts
93
-
94
- ```js
95
- const ok = await confirmDialog("Replace file?");
96
- const name = await promptDialog("Name?");
97
- toastInfo("Saved");
98
- toastError("Failed");
99
- ```
100
-
101
- `filebrowserDialog` for folder/file picks; `formDialog` for multi-field forms. Prefer these over ad-hoc `window.prompt` in shell-integrated code.
102
-
103
- ## Settings & events
104
-
105
- ```js
106
- await appSettings.set("demo.flag", true);
107
- const flag = await appSettings.get("demo.flag");
108
-
109
- const id = subscribe("topic.name", (event) => { /* … */ });
110
- publish("topic.name", { detail: 1 });
111
- unsubscribe(id);
112
- ```
113
-
114
- ## Logging
115
-
116
- ```js
117
- import { createLogger } from "docks/core";
118
- const log = createLogger("demo");
119
- log.info("ready");
120
- ```
121
-
122
- ## Canvas notes
123
-
124
- - Host persistence for a workspace `.canvas.js` is `canvasHost.getState` / `setState`, not `appSettings`, unless you intentionally share app-wide settings.
125
- - 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.
126
- - Keep UI building blocks on `docks/lit` + `docks/webawesome`; use `docks/core` for shell integration.
127
-
128
- ## Anti-patterns
129
-
130
- - Bare filenames at the composite workspace root when a durable root prefix is required
131
- - Assuming `canvasHost` APIs exist on arbitrary LitElements outside a canvas mount
132
- - Re-implementing toast/dialog with `alert` when core helpers are available
@@ -1,67 +0,0 @@
1
- ---
2
- name: eclipse-docks-lit
3
- description: >-
4
- LitElement patterns for Eclipse Docks canvases and UI code via docks/lit.
5
- Use when writing or fixing .canvas.js, Lit templates, reactive properties,
6
- directives, or styles — pure JavaScript only (no TypeScript decorators).
7
- ---
8
-
9
- # Eclipse Docks Lit (`docks/lit`)
10
-
11
- Import from `docks/lit` (same module as `@eclipse-docks/core/externals/lit`). In `.canvas.js` files use **pure JavaScript only** — no TypeScript, no decorators (`@property`, `@state`, `@customElement` are unavailable).
12
-
13
- ## Essentials
14
-
15
- ```js
16
- import { LitElement, html, css, nothing } from "docks/lit";
17
- ```
18
-
19
- - Default-export a `LitElement` subclass for canvases. Do **not** call `customElements.define` in a canvas — the host registers the tag.
20
- - Reactive fields: `static properties = { count: { state: true }, label: { type: String } }`.
21
- - Initialize defaults in `constructor` after `super()`.
22
- - Styles: `static styles = css\`:host { display: block; }\`;` (or an array of `css` results).
23
- - Templates: `render() { return html\`...\`; }` — use `nothing` for empty branches.
24
-
25
- ## Property options (common)
26
-
27
- | Option | Meaning |
28
- | --- | --- |
29
- | `state: true` | Internal reactive state (not an attribute) |
30
- | `type: String` / `Number` / `Boolean` / `Object` / `Array` | Attribute reflection helpers |
31
- | `attribute: false` | Do not mirror to an attribute |
32
- | `reflect: true` | Reflect property → attribute |
33
-
34
- Assign **new** values for objects/arrays (`this.items = [...this.items, next]`), do not mutate in place if you need an update.
35
-
36
- ## Directives
37
-
38
- Named exports from `docks/lit` (also available as in Lit docs):
39
-
40
- ```js
41
- import { repeat, when, classMap, styleMap, ifDefined, live, ref, keyed } from "docks/lit";
42
- ```
43
-
44
- - `repeat(items, (i) => i.id, (i) => html\`...\`)` for keyed lists
45
- - `when(cond, () => html\`...\`)` / `nothing` for conditionals
46
- - `classMap({ active: isOn })`, `styleMap({ width: "1rem" })`
47
- - `live(value)` when binding to form controls that can diverge from the property
48
- - Prefer `.value=${x}` (property) over `value=${x}` (attribute) for form controls
49
-
50
- ## Events in templates
51
-
52
- ```js
53
- html`<wa-button @click=${this.onSave}>Save</wa-button>`
54
- ```
55
-
56
- Use arrow functions or bound methods so `this` stays the element. For `wa-*` props and events, follow `eclipse-docks-webawesome`.
57
-
58
- ## Signals (optional)
59
-
60
- `docks/lit` also re-exports `@lit-labs/signals` helpers: `signal`, `computed`, `watch`, `SignalWatcher`, `withWatch`. Prefer `static properties` for simple canvas state unless you already use signals.
61
-
62
- ## Anti-patterns
63
-
64
- - Decorators or `.ts` syntax in `.canvas.js`
65
- - Mutating arrays/objects in place without reassignment
66
- - Relying on `this` inside a non-arrow inline handler incorrectly
67
- - Calling `customElements.define` from a workspace canvas module
@@ -1,39 +0,0 @@
1
- ---
2
- name: eclipse-docks-webawesome
3
- description: >-
4
- Web Awesome UI in Eclipse Docks via docks/webawesome. Use when building
5
- buttons, inputs, selects, checkboxes, dialogs, forms, icons, or layout
6
- utilities in canvases or Docks UI. Fetch the official component page before
7
- writing wa-* markup.
8
- ---
9
-
10
- # Eclipse Docks Web Awesome (`docks/webawesome`)
11
-
12
- ```js
13
- import "docks/webawesome";
14
- ```
15
-
16
- That import registers the components, the theme, and the `docks` icon library. Canvas files use this import. Custom elements take a closing tag: `<wa-input></wa-input>`.
17
-
18
- ## Look up the component, then write it
19
-
20
- Fetch the official page for each tag before using its props, slots, or events. Use that page's events table. Ignore the overview line that says to listen for `wa-input` or `wa-change`.
21
-
22
- - Index: https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome/SKILL.md
23
- - One component: `https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome/references/components/<name>.md` (`button`, `input`, `checkbox`, `select`, …)
24
- - Which component: https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome/references/choosing-components.md
25
- - Layout, tokens, theming: https://cdn.jsdelivr.net/npm/@awesome.me/webawesome@3/dist/skills/webawesome-design/SKILL.md
26
-
27
- Bind properties (`.value`, `.checked`). Listen for the events that page lists.
28
-
29
- ## `wa-input` and `wa-number-input`
30
-
31
- Their pages list an `input` event. This build copies keystrokes onto `.value` and does not re-dispatch `input`, so a host `@input` listener never runs. `change` fires on blur, after a click handler.
32
-
33
- Read `.value` in the click or Enter handler. For live text, use `@keyup` and assign `e.target.value`. `wa-textarea` does re-dispatch `input`.
34
-
35
- ## Docks
36
-
37
- - Shell icons: `<wa-icon library="docks" name="…"></wa-icon>`. Other icons use the names on the icon page.
38
- - Color comes from `--wa-color-*` tokens so the loaded theme covers light and dark.
39
- - Shell toasts: `toastInfo` / `toastError` from `docks/core` when that module is already loaded.