@eclipse-docks/extension-canvas 0.8.4 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/active-canvas.d.ts +2 -0
  2. package/dist/active-canvas.d.ts.map +1 -1
  3. package/dist/active-canvas.js +7 -3
  4. package/dist/active-canvas.js.map +1 -1
  5. package/dist/canvas-editor.d.ts +5 -18
  6. package/dist/canvas-editor.d.ts.map +1 -1
  7. package/dist/canvas-editor.js +23 -117
  8. package/dist/canvas-editor.js.map +1 -1
  9. package/dist/canvas-extension.d.ts.map +1 -1
  10. package/dist/canvas-extension.js +12 -4
  11. package/dist/canvas-extension.js.map +1 -1
  12. package/dist/canvas-part.d.ts +36 -0
  13. package/dist/canvas-part.d.ts.map +1 -0
  14. package/dist/canvas-part.js +153 -0
  15. package/dist/canvas-part.js.map +1 -0
  16. package/dist/canvas-readonly.d.ts +20 -0
  17. package/dist/canvas-readonly.d.ts.map +1 -0
  18. package/dist/canvas-readonly.js +49 -0
  19. package/dist/canvas-readonly.js.map +1 -0
  20. package/dist/canvas-switcher.js +3 -3
  21. package/dist/canvas-switcher.js.map +1 -1
  22. package/dist/canvases/tasks.canvas.js +6 -0
  23. package/dist/canvases/tasks.canvas.js.map +1 -0
  24. package/dist/commands.d.ts.map +1 -1
  25. package/dist/commands.js +22 -18
  26. package/dist/commands.js.map +1 -1
  27. package/dist/contribution.d.ts +5 -3
  28. package/dist/contribution.d.ts.map +1 -1
  29. package/dist/contribution.js +2 -1
  30. package/dist/contribution.js.map +1 -1
  31. package/dist/host.js +1 -1
  32. package/dist/host.js.map +1 -1
  33. package/dist/skills/eclipse-docks-canvas/SKILL.js +6 -0
  34. package/dist/skills/eclipse-docks-canvas/SKILL.js.map +1 -0
  35. package/dist/skills/eclipse-docks-core/SKILL.js +6 -0
  36. package/dist/skills/eclipse-docks-core/SKILL.js.map +1 -0
  37. package/dist/skills/eclipse-docks-lit/SKILL.js +6 -0
  38. package/dist/skills/eclipse-docks-lit/SKILL.js.map +1 -0
  39. package/dist/skills/eclipse-docks-webawesome/SKILL.js +6 -0
  40. package/dist/skills/eclipse-docks-webawesome/SKILL.js.map +1 -0
  41. package/package.json +2 -3
  42. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js +0 -9
  43. package/skills/eclipse-docks-canvas/SKILL.md +0 -127
  44. package/skills/eclipse-docks-core/SKILL.md +0 -132
  45. package/skills/eclipse-docks-lit/SKILL.md +0 -67
  46. package/skills/eclipse-docks-webawesome/SKILL.md +0 -39
@@ -0,0 +1,153 @@
1
+ import { rasterizeElement } from "./preview-image.js";
2
+ import { readWorkspaceFile } from "./workspace-file.js";
3
+ import { compileCanvas } from "./compile.js";
4
+ import { canvasBridges } from "./bridges/urls.js";
5
+ import { elementFromConstructor, mountCompiled } from "./mount.js";
6
+ import { DocksPart } from "@eclipse-docks/core";
7
+ import { css, html, nothing, property, state } from "@eclipse-docks/core/externals/lit";
8
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
9
+ //#region src/canvas-part.ts
10
+ /** Shared preview host for the canvas editor and the read-only contribution canvas. */
11
+ var DocksCanvasPart = class extends DocksPart {
12
+ constructor(..._args) {
13
+ super(..._args);
14
+ this.source = "";
15
+ this.scrollMode = "none";
16
+ this.host = {
17
+ getState: (_key, fallback) => fallback,
18
+ setState: () => void 0,
19
+ openFile: () => void 0
20
+ };
21
+ this.ready = false;
22
+ this.reloadGeneration = 0;
23
+ }
24
+ doClose() {
25
+ this.reloadGeneration++;
26
+ this.previewDispose?.();
27
+ this.previewDispose = void 0;
28
+ }
29
+ async capturePreview() {
30
+ return this.rasterizePreview();
31
+ }
32
+ /** Compile workspace or contribution source and mount the exported element. */
33
+ async mountCompiledSource(source, entryPath) {
34
+ const generation = ++this.reloadGeneration;
35
+ const compiled = await compileCanvas({
36
+ entryPath,
37
+ entrySource: source,
38
+ read: readWorkspaceFile,
39
+ bridges: canvasBridges()
40
+ });
41
+ if (generation !== this.reloadGeneration) return "";
42
+ if (!compiled.ok) {
43
+ this.previewError = compiled.error;
44
+ this.requestUpdate();
45
+ return compiled.error;
46
+ }
47
+ const mounted = await mountCompiled(compiled.code);
48
+ if (generation !== this.reloadGeneration) {
49
+ if (mounted.ok) mounted.dispose();
50
+ return "";
51
+ }
52
+ if (!mounted.ok) {
53
+ this.previewError = mounted.error;
54
+ this.requestUpdate();
55
+ return mounted.error;
56
+ }
57
+ mounted.element.canvasHost = this.host;
58
+ this.replacePreview(mounted.element, source, mounted.dispose);
59
+ return "ready";
60
+ }
61
+ /** Mount a contribution that already provides its element constructor. */
62
+ async mountLoadedConstructor(load, source) {
63
+ const generation = ++this.reloadGeneration;
64
+ try {
65
+ const mod = await load();
66
+ if (generation !== this.reloadGeneration) return "";
67
+ const Ctor = mod.default;
68
+ if (typeof Ctor !== "function" || !(Ctor.prototype instanceof HTMLElement)) {
69
+ this.previewError = "Canvas default export must be an HTMLElement subclass";
70
+ this.requestUpdate();
71
+ return this.previewError;
72
+ }
73
+ const element = elementFromConstructor(Ctor);
74
+ element.canvasHost = this.host;
75
+ this.replacePreview(element, source);
76
+ return "ready";
77
+ } catch (err) {
78
+ if (generation !== this.reloadGeneration) return "";
79
+ this.previewError = err instanceof Error ? err.message : String(err);
80
+ this.requestUpdate();
81
+ return this.previewError;
82
+ }
83
+ }
84
+ /** Called when a preview element is installed. `source` is the text that produced it. */
85
+ adoptPreview(_source) {}
86
+ replacePreview(element, source, dispose) {
87
+ const previous = this.previewDispose;
88
+ this.previewDispose = dispose ?? (() => element.remove());
89
+ this.previewElement = element;
90
+ this.previewError = void 0;
91
+ this.adoptPreview(source);
92
+ this.placePreview();
93
+ this.requestUpdate();
94
+ previous?.();
95
+ }
96
+ /** The mount has no Lit child part, so replacing its children leaves part markers intact. */
97
+ placePreview() {
98
+ const mount = this.renderRoot.querySelector(".canvas-mount");
99
+ const element = this.previewElement;
100
+ if (!mount || !element) return;
101
+ if (mount.childElementCount === 1 && mount.firstElementChild === element) return;
102
+ mount.replaceChildren(element);
103
+ }
104
+ updated(changed) {
105
+ super.updated(changed);
106
+ this.placePreview();
107
+ }
108
+ renderPreview(hidden = false) {
109
+ return html`
110
+ <div class="canvas-preview ${hidden ? "canvas-hidden" : ""}">
111
+ ${this.previewError ? html`<pre class="canvas-error">${this.previewError}</pre>` : nothing}
112
+ <wa-scroller class="canvas-scroll" orientation="vertical">
113
+ <div class="canvas-mount"></div>
114
+ </wa-scroller>
115
+ </div>
116
+ `;
117
+ }
118
+ renderContent() {
119
+ if (!this.ready) return html``;
120
+ return this.renderPreview();
121
+ }
122
+ async rasterizePreview() {
123
+ await this.updateComplete;
124
+ const preview = this.renderRoot.querySelector(".canvas-preview");
125
+ if (!preview) throw new Error("Canvas preview is not rendered");
126
+ const view = this.previewElement;
127
+ if (view?.updateComplete) await view.updateComplete;
128
+ return rasterizeElement(preview);
129
+ }
130
+ static {
131
+ this.styles = css`
132
+ :host { display: flex; flex-direction: column; height: 100%; min-height: 0; }
133
+ .canvas-preview { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
134
+ wa-scroller.canvas-scroll { flex: 1 1 0; min-height: 0; height: 100%; }
135
+ .canvas-mount > * { display: block; }
136
+ .canvas-error {
137
+ margin: 0;
138
+ padding: var(--wa-space-s, 8px);
139
+ white-space: pre-wrap;
140
+ color: var(--wa-color-danger-on-quiet, #b42318);
141
+ }
142
+ `;
143
+ }
144
+ };
145
+ _decorate([property({ attribute: false })], DocksCanvasPart.prototype, "input", void 0);
146
+ _decorate([property()], DocksCanvasPart.prototype, "canvasName", void 0);
147
+ _decorate([property()], DocksCanvasPart.prototype, "source", void 0);
148
+ _decorate([state()], DocksCanvasPart.prototype, "previewError", void 0);
149
+ _decorate([state()], DocksCanvasPart.prototype, "previewElement", void 0);
150
+ //#endregion
151
+ export { DocksCanvasPart };
152
+
153
+ //# sourceMappingURL=canvas-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-part.js","names":[],"sources":["../src/canvas-part.ts"],"sourcesContent":["import { DocksPart, type EditorInput } from '@eclipse-docks/core';\nimport { css, html, nothing, type PropertyValues } from '@eclipse-docks/core/externals/lit';\nimport { property, state } from '@eclipse-docks/core/externals/lit';\nimport type { CanvasContribution } from './contribution';\nimport { compileCanvas } from './compile';\nimport { canvasBridges } from './bridges/urls';\nimport type { CanvasHost } from './host';\nimport { elementFromConstructor, mountCompiled, type CanvasViewElement } from './mount';\nimport { rasterizeElement, type PreviewShot } from './preview-image';\nimport { readWorkspaceFile } from './workspace-file';\n\n/** Shared preview host for the canvas editor and the read-only contribution canvas. */\nexport abstract class DocksCanvasPart extends DocksPart {\n @property({ attribute: false }) input?: EditorInput;\n @property() canvasName?: string;\n @property() source = '';\n\n @state() protected previewError?: string;\n @state() protected previewElement?: CanvasViewElement;\n\n protected scrollMode: 'scroller' | 'native' | 'none' = 'none';\n protected host: CanvasHost = { getState: (_key, fallback) => fallback, setState: () => undefined, openFile: () => undefined };\n protected ready = false;\n protected reloadGeneration = 0;\n\n private previewDispose?: () => void;\n\n protected doClose() {\n this.reloadGeneration++;\n this.previewDispose?.();\n this.previewDispose = undefined;\n }\n\n async capturePreview(): Promise<PreviewShot> {\n return this.rasterizePreview();\n }\n\n /** Compile workspace or contribution source and mount the exported element. */\n protected async mountCompiledSource(source: string, entryPath: string): Promise<string> {\n const generation = ++this.reloadGeneration;\n const compiled = await compileCanvas({\n entryPath,\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 /** Mount a contribution that already provides its element constructor. */\n protected async mountLoadedConstructor(load: NonNullable<CanvasContribution['load']>, source: string): Promise<string> {\n const generation = ++this.reloadGeneration;\n try {\n const mod = await 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\n /** Called when a preview element is installed. `source` is the text that produced it. */\n protected adoptPreview(_source: string): void {}\n\n protected 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.adoptPreview(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 protected 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 protected updated(changed: PropertyValues) {\n super.updated(changed);\n this.placePreview();\n }\n\n protected renderPreview(hidden = false) {\n return html`\n <div class=\"canvas-preview ${hidden ? '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 `;\n }\n\n protected renderContent() {\n if (!this.ready) return html``;\n return this.renderPreview();\n }\n\n protected async rasterizePreview(): Promise<PreviewShot> {\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 view = this.previewElement as { updateComplete?: Promise<unknown> } | undefined;\n if (view?.updateComplete) await view.updateComplete;\n return rasterizeElement(preview);\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 wa-scroller.canvas-scroll { flex: 1 1 0; min-height: 0; height: 100%; }\n .canvas-mount > * { display: block; }\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"],"mappings":";;;;;;;;;;AAYA,IAAsB,kBAAtB,cAA8C,UAAU;;;EAG/B,KAAA,SAAA;EAKkC,KAAA,aAAA;EAC1B,KAAA,OAAA;GAAE,WAAW,MAAM,aAAa;GAAU,gBAAgB,KAAA;GAAW,gBAAgB,KAAA;EAAU;EAC1G,KAAA,QAAA;EACW,KAAA,mBAAA;;CAI7B,UAAoB;EAChB,KAAK;EACL,KAAK,iBAAiB;EACtB,KAAK,iBAAiB,KAAA;CAC1B;CAEA,MAAM,iBAAuC;EACzC,OAAO,KAAK,iBAAiB;CACjC;;CAGA,MAAgB,oBAAoB,QAAgB,WAAoC;EACpF,MAAM,aAAa,EAAE,KAAK;EAC1B,MAAM,WAAW,MAAM,cAAc;GACjC;GACA,aAAa;GACb,MAAM;GACN,SAAS,cAAc;EAC3B,CAAC;EACD,IAAI,eAAe,KAAK,kBAAkB,OAAO;EACjD,IAAI,CAAC,SAAS,IAAI;GACd,KAAK,eAAe,SAAS;GAC7B,KAAK,cAAc;GACnB,OAAO,SAAS;EACpB;EACA,MAAM,UAAU,MAAM,cAAc,SAAS,IAAI;EACjD,IAAI,eAAe,KAAK,kBAAkB;GACtC,IAAI,QAAQ,IAAI,QAAQ,QAAQ;GAChC,OAAO;EACX;EACA,IAAI,CAAC,QAAQ,IAAI;GACb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a;CACtB;CAEA,cAAwB,SAAS,OAAO;EACpC,OAAO,IAAI;yCACsB,SAAS,kBAAkB,GAAG;kBACrD,KAAK,eAAe,IAAI,6BAA6B,KAAK,aAAa,UAAU,QAAQ;;;;;;CAMvG;CAEA,gBAA0B;EACtB,IAAI,CAAC,KAAK,OAAO,OAAO,IAAI;EAC5B,OAAO,KAAK,cAAc;CAC9B;CAEA,MAAgB,mBAAyC;EACrD,MAAM,KAAK;EACX,MAAM,UAAU,KAAK,WAAW,cAAc,iBAAiB;EAC/D,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,gCAAgC;EAC9D,MAAM,OAAO,KAAK;EAClB,IAAI,MAAM,gBAAgB,MAAM,KAAK;EACrC,OAAO,iBAAiB,OAAO;CACnC;;EAEgB,KAAA,SAAA,GAAG;;;;;;;;;;;;;AAYvB;AA/IK,UAAA,CAAA,SAAS,EAAE,WAAW,MAAM,CAAC,CAAA,GAAA,gBAAA,WAAA,SAAA,KAAA,CAAA;AAC7B,UAAA,CAAA,SAAS,CAAA,GAAA,gBAAA,WAAA,cAAA,KAAA,CAAA;AACT,UAAA,CAAA,SAAS,CAAA,GAAA,gBAAA,WAAA,UAAA,KAAA,CAAA;AAET,UAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,gBAAA,KAAA,CAAA;AACN,UAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,kBAAA,KAAA,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { DocksCanvasPart } from './canvas-part';
2
+ /** Read-only preview for a canvas opened from the canvases dropdown. */
3
+ export declare class DocksCanvasReadonly extends DocksCanvasPart {
4
+ readonly kind: "registered";
5
+ private contribution?;
6
+ /**
7
+ * A part is the active editor only when `save` is overridden.
8
+ * This one writes nothing.
9
+ */
10
+ save(): Promise<void>;
11
+ protected doInitUI(): Promise<void>;
12
+ private mount;
13
+ private contributedSource;
14
+ }
15
+ declare global {
16
+ interface HTMLElementTagNameMap {
17
+ 'docks-canvas-readonly': DocksCanvasReadonly;
18
+ }
19
+ }
20
+ //# sourceMappingURL=canvas-readonly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-readonly.d.ts","sourceRoot":"","sources":["../src/canvas-readonly.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,wEAAwE;AACxE,qBACa,mBAAoB,SAAQ,eAAe;IACpD,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAU;IAEtC,OAAO,CAAC,YAAY,CAAC,CAAqB;IAE1C;;;OAGG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;cAEpB,QAAQ;YAeV,KAAK;YAWL,iBAAiB;CAKlC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,uBAAuB,EAAE,mBAAmB,CAAC;KAChD;CACJ"}
@@ -0,0 +1,49 @@
1
+ import { DocksCanvasPart } from "./canvas-part.js";
2
+ import { createContributionHost } from "./host.js";
3
+ import { customElement } from "@eclipse-docks/core/externals/lit";
4
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
5
+ //#region src/canvas-readonly.ts
6
+ var DocksCanvasReadonly = class DocksCanvasReadonly extends DocksCanvasPart {
7
+ constructor(..._args) {
8
+ super(..._args);
9
+ this.kind = "registered";
10
+ }
11
+ /**
12
+ * A part is the active editor only when `save` is overridden.
13
+ * This one writes nothing.
14
+ */
15
+ async save() {}
16
+ async doInitUI() {
17
+ const contribution = (this.input?.data)?.contribution;
18
+ if (!contribution) {
19
+ this.previewError = "No canvas contribution";
20
+ this.ready = true;
21
+ return;
22
+ }
23
+ this.contribution = contribution;
24
+ this.canvasName = contribution.name;
25
+ this.host = await createContributionHost(contribution);
26
+ this.ready = true;
27
+ await this.mount();
28
+ }
29
+ async mount() {
30
+ const contribution = this.contribution;
31
+ if (!contribution) return;
32
+ if (contribution.load) {
33
+ await this.mountLoadedConstructor(contribution.load, this.source);
34
+ return;
35
+ }
36
+ const source = await this.contributedSource(contribution);
37
+ await this.mountCompiledSource(source, `${contribution.name}.canvas.js`);
38
+ }
39
+ async contributedSource(contribution) {
40
+ if (this.source) return this.source;
41
+ if (typeof contribution.source === "function") return contribution.source();
42
+ return contribution.source ?? "";
43
+ }
44
+ };
45
+ DocksCanvasReadonly = _decorate([customElement("docks-canvas-readonly")], DocksCanvasReadonly);
46
+ //#endregion
47
+ export { DocksCanvasReadonly };
48
+
49
+ //# sourceMappingURL=canvas-readonly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-readonly.js","names":[],"sources":["../src/canvas-readonly.ts"],"sourcesContent":["import { customElement } from '@eclipse-docks/core/externals/lit';\nimport type { CanvasContribution } from './contribution';\nimport { DocksCanvasPart } from './canvas-part';\nimport { createContributionHost } from './host';\n\n/** Read-only preview for a canvas opened from the canvases dropdown. */\n@customElement('docks-canvas-readonly')\nexport class DocksCanvasReadonly extends DocksCanvasPart {\n readonly kind = 'registered' as const;\n\n private contribution?: CanvasContribution;\n\n /**\n * A part is the active editor only when `save` is overridden.\n * This one writes nothing.\n */\n override async save(): Promise<void> {}\n\n protected async doInitUI() {\n const data = this.input?.data as { contribution?: CanvasContribution } | undefined;\n const contribution = data?.contribution;\n if (!contribution) {\n this.previewError = 'No canvas contribution';\n this.ready = true;\n return;\n }\n this.contribution = contribution;\n this.canvasName = contribution.name;\n this.host = await createContributionHost(contribution);\n this.ready = true;\n await this.mount();\n }\n\n private async mount() {\n const contribution = this.contribution;\n if (!contribution) return;\n if (contribution.load) {\n await this.mountLoadedConstructor(contribution.load, this.source);\n return;\n }\n const source = await this.contributedSource(contribution);\n await this.mountCompiledSource(source, `${contribution.name}.canvas.js`);\n }\n\n private async contributedSource(contribution: CanvasContribution): Promise<string> {\n if (this.source) return this.source;\n if (typeof contribution.source === 'function') return contribution.source();\n return contribution.source ?? '';\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'docks-canvas-readonly': DocksCanvasReadonly;\n }\n}\n"],"mappings":";;;;;AAOO,IAAM,sBAAN,MAAM,4BAA4B,gBAAgB;;;EACrC,KAAA,OAAA;;;;;;CAQhB,MAAe,OAAsB,CAAC;CAEtC,MAAgB,WAAW;EAEvB,MAAM,gBADO,KAAK,OAAO,KAAA,EACE;EAC3B,IAAI,CAAC,cAAc;GACf,KAAK,eAAe;GACpB,KAAK,QAAQ;GACb;EACJ;EACA,KAAK,eAAe;EACpB,KAAK,aAAa,aAAa;EAC/B,KAAK,OAAO,MAAM,uBAAuB,YAAY;EACrD,KAAK,QAAQ;EACb,MAAM,KAAK,MAAM;CACrB;CAEA,MAAc,QAAQ;EAClB,MAAM,eAAe,KAAK;EAC1B,IAAI,CAAC,cAAc;EACnB,IAAI,aAAa,MAAM;GACnB,MAAM,KAAK,uBAAuB,aAAa,MAAM,KAAK,MAAM;GAChE;EACJ;EACA,MAAM,SAAS,MAAM,KAAK,kBAAkB,YAAY;EACxD,MAAM,KAAK,oBAAoB,QAAQ,GAAG,aAAa,KAAK,WAAW;CAC3E;CAEA,MAAc,kBAAkB,cAAmD;EAC/E,IAAI,KAAK,QAAQ,OAAO,KAAK;EAC7B,IAAI,OAAO,aAAa,WAAW,YAAY,OAAO,aAAa,OAAO;EAC1E,OAAO,aAAa,UAAU;CAClC;AACJ;AA3CC,sBAAA,UAAA,CAAA,cAAc,uBAAuB,CAAA,GAAA,mBAAA"}
@@ -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/canvases/tasks.canvas.js?raw
2
+ var tasks_canvas_default = "import { LitElement, html, css } from \"docks/lit\";\nimport \"docks/webawesome\";\n\nexport default class extends LitElement {\n static properties = {\n tasks: { state: true },\n query: { state: true },\n grouping: { state: true },\n editingId: { state: true },\n };\n\n static styles = css`\n :host { display:block; min-height:100%; box-sizing:border-box; padding:clamp(18px,4vw,48px); color:var(--wa-color-text-normal); background:var(--wa-color-surface-default); font-family:var(--wa-font-family-body,system-ui,sans-serif); }\n * { box-sizing:border-box; }\n .app { max-width:920px; margin:0 auto; }\n header { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; margin-bottom:30px; }\n .eyebrow { color:var(--wa-color-brand-600); text-transform:uppercase; letter-spacing:.12em; font-size:11px; font-weight:750; margin:0 0 8px; }\n h1 { font-size:clamp(30px,5vw,44px); line-height:1.05; letter-spacing:-.04em; margin:0; }\n .sub { color:var(--wa-color-text-quiet); margin:9px 0 0; }\n .date { color:var(--wa-color-text-quiet); font-size:13px; white-space:nowrap; padding-top:8px; }\n .summary { display:grid; grid-template-columns:1.3fr 1fr; gap:16px; margin-bottom:22px; }\n .panel { border:1px solid var(--wa-color-neutral-200); border-radius:16px; background:var(--wa-color-surface-raised); padding:20px; }\n .progress-top { display:flex; justify-content:space-between; gap:12px; align-items:center; }\n .label { font-size:13px; font-weight:700; }\n .muted { color:var(--wa-color-text-quiet); font-size:13px; }\n .percent { font-weight:750; font-size:22px; letter-spacing:-.03em; }\n .track { height:8px; border-radius:99px; background:var(--wa-color-neutral-100); overflow:hidden; margin-top:15px; }\n .fill { height:100%; border-radius:inherit; background:var(--wa-color-success-600); transition:width .25s ease; }\n .stats { display:grid; grid-template-columns:1fr 1fr; gap:12px; }\n .stat { border-left:2px solid var(--wa-color-neutral-200); padding-left:13px; }\n .stat strong { display:block; font-size:22px; letter-spacing:-.03em; }\n .stat span { color:var(--wa-color-text-quiet); font-size:12px; }\n .composer { display:flex; gap:10px; margin-bottom:14px; }\n wa-input { flex:1; }\n wa-input::part(base) { border-radius:11px; }\n wa-button::part(button) { border-radius:10px; font-weight:650; }\n .toolbar { display:flex; gap:12px; align-items:center; margin:18px 0 12px; }\n .search { flex:1; }\n .filters { display:flex; gap:6px; padding:4px; background:var(--wa-color-neutral-100); border-radius:11px; }\n .filters wa-button::part(button) { border:0; }\n .filters wa-button.active::part(button) { background:var(--wa-color-surface-raised); box-shadow:0 1px 4px #0001; }\n .group-title { display:flex; align-items:center; gap:9px; margin:22px 0 9px; font-size:13px; text-transform:uppercase; letter-spacing:.08em; font-weight:750; color:var(--wa-color-text-quiet); }\n .count { font-size:11px; background:var(--wa-color-neutral-100); padding:3px 7px; border-radius:20px; }\n .list { display:grid; gap:8px; }\n .task { display:flex; align-items:center; gap:12px; padding:13px 14px; border:1px solid var(--wa-color-neutral-200); background:var(--wa-color-surface-raised); border-radius:13px; min-width:0; }\n .check { width:21px; height:21px; flex:none; border-radius:7px; border:1.5px solid var(--wa-color-neutral-400); display:grid; place-items:center; cursor:pointer; color:white; background:transparent; font-size:14px; }\n .check.done { background:var(--wa-color-success-600); border-color:var(--wa-color-success-600); }\n .task-copy { flex:1; min-width:0; }\n .task-name { font-size:14px; font-weight:650; overflow-wrap:anywhere; }\n .task.done .task-name { color:var(--wa-color-text-quiet); text-decoration:line-through; }\n .task-date { color:var(--wa-color-text-quiet); font-size:11px; margin-top:4px; }\n .actions { display:flex; gap:3px; }\n .actions wa-button::part(button) { padding-inline:9px; }\n .empty { padding:30px 15px; text-align:center; color:var(--wa-color-text-quiet); border:1px dashed var(--wa-color-neutral-300); border-radius:13px; }\n .empty b { color:var(--wa-color-text-normal); display:block; margin-bottom:5px; }\n @media(max-width:620px) { .summary { grid-template-columns:1fr; } header { display:block; } .date { padding-top:12px; } .toolbar { flex-wrap:wrap; } .search { flex-basis:100%; } .filters { width:100%; justify-content:space-around; } .composer { align-items:stretch; } .task { padding:11px; } }\n `;\n\n constructor() {\n super();\n this.tasks = [];\n this.query = \"\";\n this.grouping = \"all\";\n this.editingId = null;\n }\n\n connectedCallback() {\n super.connectedCallback();\n const saved = this.canvasHost?.getState(\"tasks\", null);\n if (Array.isArray(saved)) this.tasks = saved;\n }\n\n persist() { this.canvasHost?.setState(\"tasks\", this.tasks); }\n\n addTask() {\n const input = this.renderRoot.querySelector(\"#new-task\");\n const title = String(input?.value ?? \"\").trim();\n if (!title) return;\n this.tasks = [{ id: crypto.randomUUID(), title, done: false, created: Date.now() }, ...this.tasks];\n this.persist();\n input.value = \"\";\n input.focus();\n }\n\n toggle(id) {\n this.tasks = this.tasks.map(t => t.id === id ? { ...t, done: !t.done } : t);\n this.persist();\n }\n\n remove(id) { this.tasks = this.tasks.filter(t => t.id !== id); this.persist(); }\n\n edit(id) {\n const task = this.tasks.find(t => t.id === id);\n if (!task) return;\n const title = window.prompt(\"Edit task\", task.title);\n if (title === null) return;\n if (!title.trim()) return;\n this.tasks = this.tasks.map(t => t.id === id ? { ...t, title: title.trim() } : t);\n this.persist();\n }\n\n filtered() {\n const q = this.query.trim().toLowerCase();\n return this.tasks.filter(t => (!q || t.title.toLowerCase().includes(q)) &&\n (this.grouping === \"all\" || (this.grouping === \"done\" ? t.done : !t.done)));\n }\n\n renderTask(task) {\n return html`<article class=\"task ${task.done ? \"done\" : \"\"}\">\n <button class=\"check ${task.done ? \"done\" : \"\"}\" aria-label=${task.done ? \"Mark incomplete\" : \"Mark complete\"} @click=${() => this.toggle(task.id)}>${task.done ? \"✓\" : \"\"}</button>\n <div class=\"task-copy\"><div class=\"task-name\">${task.title}</div><div class=\"task-date\">Added ${new Date(task.created).toLocaleDateString(undefined,{month:\"short\",day:\"numeric\"})}</div></div>\n <div class=\"actions\"><wa-button appearance=\"plain\" size=\"small\" aria-label=\"Edit task\" @click=${() => this.edit(task.id)}>Edit</wa-button><wa-button appearance=\"plain\" variant=\"danger\" size=\"small\" aria-label=\"Delete task\" @click=${() => this.remove(task.id)}>Delete</wa-button></div>\n </article>`;\n }\n\n render() {\n const done = this.tasks.filter(t => t.done).length;\n const total = this.tasks.length;\n const percent = total ? Math.round(done / total * 100) : 0;\n const visible = this.filtered();\n const activeTasks = visible.filter(t => !t.done);\n const doneTasks = visible.filter(t => t.done);\n const date = new Intl.DateTimeFormat(undefined, { weekday:\"long\", month:\"long\", day:\"numeric\" }).format(new Date());\n return html`<main class=\"app\">\n <header><div><p class=\"eyebrow\">Daily planner</p><h1>Today, with intention.</h1><p class=\"sub\">A little progress adds up. Keep your focus on what matters.</p></div><div class=\"date\">${date}</div></header>\n <section class=\"summary\"><div class=\"panel\"><div class=\"progress-top\"><div><div class=\"label\">Today's progress</div><div class=\"muted\">${done} of ${total} tasks completed</div></div><div class=\"percent\">${percent}%</div></div><div class=\"track\"><div class=\"fill\" style=\"width:${percent}%\"></div></div></div><div class=\"panel stats\"><div class=\"stat\"><strong>${total - done}</strong><span>Still to do</span></div><div class=\"stat\"><strong>${done}</strong><span>Completed</span></div></div></section>\n <section class=\"composer\"><wa-input id=\"new-task\" placeholder=\"What needs your attention today?\" aria-label=\"New task\" @keydown=${e => { if (e.key === \"Enter\") this.addTask(); }}></wa-input><wa-button variant=\"brand\" @click=${() => this.addTask()}>Add task</wa-button></section>\n <div class=\"toolbar\"><wa-input class=\"search\" placeholder=\"Search your tasks…\" aria-label=\"Search tasks\" @keyup=${e => { this.query = e.target.value; }}></wa-input><div class=\"filters\" aria-label=\"Filter tasks\"><wa-button class=${this.grouping === \"all\" ? \"active\" : \"\"} size=\"small\" appearance=\"plain\" @click=${() => this.grouping = \"all\"}>All</wa-button><wa-button class=${this.grouping === \"active\" ? \"active\" : \"\"} size=\"small\" appearance=\"plain\" @click=${() => this.grouping = \"active\"}>To do</wa-button><wa-button class=${this.grouping === \"done\" ? \"active\" : \"\"} size=\"small\" appearance=\"plain\" @click=${() => this.grouping = \"done\"}>Done</wa-button></div></div>\n ${visible.length ? html`${this.grouping === \"all\" || this.grouping === \"active\" ? html`<section><h2 class=\"group-title\">To do <span class=\"count\">${activeTasks.length}</span></h2><div class=\"list\">${activeTasks.length ? activeTasks.map(t => this.renderTask(t)) : html`<div class=\"empty\"><b>Nothing left on your list.</b>Enjoy the breathing room.</div>`}</div></section>` : \"\"}${this.grouping === \"all\" || this.grouping === \"done\" ? html`<section><h2 class=\"group-title\">Completed <span class=\"count\">${doneTasks.length}</span></h2><div class=\"list\">${doneTasks.length ? doneTasks.map(t => this.renderTask(t)) : html`<div class=\"empty\">Completed tasks will show up here.</div>`}</div></section>` : \"\"}` : html`<div class=\"empty\"><b>${this.query ? \"No tasks match your search.\" : \"Your list is clear.\"}</b>${this.query ? \"Try another search or change the filter.\" : \"Add a task above to get started.\"}</div>`}\n </main>`;\n }\n}\n";
3
+ //#endregion
4
+ export { tasks_canvas_default as default };
5
+
6
+ //# sourceMappingURL=tasks.canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.canvas.js","names":[],"sources":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,KAAK,WAAW,EACnB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,OAAO,iBAAiB,CAAC;AAIzB,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,kBAAkB,EAAE,UAAU,SAAK,GAAG,WAAW,CAehG;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMpE;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpE;AAMD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAYjF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjE;AAiBD,wBAAgB,sBAAsB,IAAI,IAAI,CAyK7C"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,KAAK,WAAW,EACnB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,OAAO,iBAAiB,CAAC;AACzB,OAAO,mBAAmB,CAAC;AAI3B,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,kBAAkB,EAAE,UAAU,SAAK,GAAG,WAAW,CAahG;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMpE;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpE;AAMD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAYjF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjE;AAiBD,wBAAgB,sBAAsB,IAAI,IAAI,CA0K7C"}
package/dist/commands.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { listRegisteredCanvases } from "./canvases.js";
2
- import { connectedWorkspaceEditors, findOpenCanvas, readActiveCanvas } from "./active-canvas.js";
2
+ import { connectedWorkspaceEditors, findOpenCanvas, isCanvasViewer, readActiveCanvas } from "./active-canvas.js";
3
3
  import { attachPreviewShot } from "./preview-image.js";
4
4
  import { writeWorkspaceFile } from "./workspace-file.js";
5
5
  import "./canvas-editor.js";
6
+ import "./canvas-readonly.js";
6
7
  import { File, PANEL_BOTTOM, SIDEBAR_AUXILIARY, SIDEBAR_MAIN, contributionRegistry, editorRegistry, registerAll, workspaceService } from "@eclipse-docks/core";
7
8
  import { html } from "@eclipse-docks/core/externals/lit";
8
9
  //#region src/commands.ts
@@ -12,17 +13,17 @@ var VIEW_SLOTS = /* @__PURE__ */ new Set([
12
13
  PANEL_BOTTOM
13
14
  ]);
14
15
  function canvasEditorInput(contribution, sourceText = "") {
15
- const hasSource = contribution.source !== void 0;
16
16
  const input = {
17
17
  key: `canvas:${contribution.name}`,
18
18
  title: contribution.label,
19
19
  icon: contribution.icon ?? "table-columns",
20
20
  data: { contribution },
21
21
  state: { mode: "preview" },
22
+ toolbar: false,
22
23
  component: () => html``
23
24
  };
24
- input.component = (id) => hasSource ? html`<docks-canvas-editor id="${id}" .input=${input} .source=${sourceText}></docks-canvas-editor>` : html`<docks-canvas-surface id="${id}" .input=${input}></docks-canvas-surface>`;
25
- input.editorId = "system.canvas-editor";
25
+ input.component = (id) => html`<docks-canvas-readonly id="${id}" .input=${input} .source=${sourceText}></docks-canvas-readonly>`;
26
+ input.editorId = "system.canvas-readonly";
26
27
  return input;
27
28
  }
28
29
  async function openCanvasByName(name) {
@@ -126,22 +127,25 @@ function registerCanvasCommands() {
126
127
  required: false
127
128
  }]
128
129
  },
129
- handler: { execute: async ({ params }) => {
130
- const source = String(params?.source ?? "");
131
- const path = (typeof params?.path === "string" ? params.path : void 0) ?? workspaceCanvas()?.getFilePath?.() ?? void 0;
132
- const targets = path ? connectedWorkspaceEditors(path) : [];
133
- if (targets.length) {
134
- let compiled = "ready";
135
- for (const editor of targets) {
136
- if (!editor.setSource || !editor.reload) continue;
137
- editor.setSource(source);
138
- compiled = await editor.reload();
130
+ handler: {
131
+ canExecute: () => !isCanvasViewer(),
132
+ execute: async ({ params }) => {
133
+ const source = String(params?.source ?? "");
134
+ const path = (typeof params?.path === "string" ? params.path : void 0) ?? workspaceCanvas()?.getFilePath?.() ?? void 0;
135
+ const targets = path ? connectedWorkspaceEditors(path) : [];
136
+ if (targets.length) {
137
+ let compiled = "ready";
138
+ for (const editor of targets) {
139
+ if (!editor.setSource || !editor.reload) continue;
140
+ editor.setSource(source);
141
+ compiled = await editor.reload();
142
+ }
143
+ return compiled;
139
144
  }
140
- return compiled;
145
+ if (!path) return "Provide a workspace path";
146
+ return writeWorkspaceFile(path, source);
141
147
  }
142
- if (!path) return "Provide a workspace path";
143
- return writeWorkspaceFile(path, source);
144
- } }
148
+ }
145
149
  });
146
150
  registerAll({
147
151
  command: {
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","names":[],"sources":["../src/commands.ts"],"sourcesContent":["import {\n contributionRegistry,\n editorRegistry,\n File,\n registerAll,\n SIDEBAR_AUXILIARY,\n SIDEBAR_MAIN,\n PANEL_BOTTOM,\n workspaceService,\n type EditorInput,\n} from '@eclipse-docks/core';\nimport { html } from '@eclipse-docks/core/externals/lit';\nimport { connectedWorkspaceEditors, findOpenCanvas, readActiveCanvas } from './active-canvas';\nimport { listRegisteredCanvases } from './canvases';\nimport type { CanvasContribution } from './contribution';\nimport { attachPreviewShot } from './preview-image';\nimport { writeWorkspaceFile } from './workspace-file';\nimport './canvas-editor';\n\nconst VIEW_SLOTS = new Set([SIDEBAR_MAIN, SIDEBAR_AUXILIARY, PANEL_BOTTOM]);\n\nexport function canvasEditorInput(contribution: CanvasContribution, sourceText = ''): EditorInput {\n const hasSource = contribution.source !== undefined;\n const input = {\n key: `canvas:${contribution.name}`,\n title: contribution.label,\n icon: contribution.icon ?? 'table-columns',\n data: { contribution },\n state: { mode: 'preview' },\n component: () => html``,\n } as EditorInput;\n input.component = (id: string) => hasSource\n ? html`<docks-canvas-editor id=\"${id}\" .input=${input} .source=${sourceText}></docks-canvas-editor>`\n : html`<docks-canvas-surface id=\"${id}\" .input=${input}></docks-canvas-surface>`;\n (input as unknown as { editorId: string }).editorId = 'system.canvas-editor';\n return input;\n}\n\nexport async function openCanvasByName(name: string): Promise<string> {\n const contribution = listRegisteredCanvases().find(item => item.name === name);\n if (!contribution) return `No canvas named ${name}`;\n const sourceText = typeof contribution.source === 'function' ? await contribution.source() : (contribution.source ?? '');\n await editorRegistry.loadEditor(canvasEditorInput(contribution, sourceText));\n return 'ready';\n}\n\nexport async function openCanvasByPath(path: string): Promise<string> {\n const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\n if (!workspace) return 'No workspace is open';\n const resource = await workspace.getResource(path.replace(/^\\/+/, ''));\n if (!(resource instanceof File)) return `Cannot find workspace file \"${path}\"`;\n await editorRegistry.loadEditor(resource, 'system.canvas-editor');\n return 'ready';\n}\n\nfunction viewName(path: string): string {\n return `canvas-view:${path}`;\n}\n\nexport function showCanvasView(slot: string, path: string, source: string): string {\n if (!VIEW_SLOTS.has(slot)) return `Unsupported view slot ${slot}`;\n const name = viewName(path);\n contributionRegistry.unregisterContribution(slot, name);\n contributionRegistry.registerContribution(slot, {\n name,\n label: path.split('/').pop() || path,\n icon: 'table-columns',\n closable: true,\n component: (id: string) => html`<docks-canvas-surface id=\"${id}\" .entryPath=${path} .source=${source}></docks-canvas-surface>`,\n });\n return 'ready';\n}\n\nexport function hideCanvasView(slot: string, path: string): string {\n if (!VIEW_SLOTS.has(slot)) return `Unsupported view slot ${slot}`;\n contributionRegistry.unregisterContribution(slot, viewName(path));\n return 'ready';\n}\n\nfunction workspaceCanvas() {\n const active = readActiveCanvas();\n if (!active?.editor || active.kind !== 'workspace') return null;\n return active;\n}\n\nasync function waitForCanvas(match: (active: NonNullable<ReturnType<typeof readActiveCanvas>>) => boolean) {\n for (let attempt = 0; attempt < 30; attempt++) {\n const active = readActiveCanvas();\n if (active?.reload && match(active)) return active;\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n return null;\n}\n\nexport function registerCanvasCommands(): void {\n registerAll({\n command: {\n id: 'canvas.open',\n name: 'Open canvas',\n description: 'Opens a workspace .canvas.js path or a canvas registered on system.canvases and returns ready or a compile error',\n parameters: [\n { name: 'path', description: 'Workspace path of a .canvas.js file', required: false },\n { name: 'name', description: 'Name of a canvas registered on system.canvases', required: false },\n ],\n },\n handler: {\n execute: async ({ params }) => {\n const name = params?.name as string | undefined;\n const path = params?.path as string | undefined;\n if (name) {\n const opened = await openCanvasByName(name);\n if (opened !== 'ready') return opened;\n const active = await waitForCanvas(item => item.canvasName === name);\n return active?.reload ? active.reload() : opened;\n }\n if (path) {\n const opened = await openCanvasByPath(path);\n if (opened !== 'ready') return opened;\n const normalized = path.replace(/^\\/+/, '');\n const active = await waitForCanvas(item => item.getFilePath?.()?.replace(/^\\/+/, '') === normalized);\n if (!active?.reload) return opened;\n await active.syncFromFile?.();\n return active.reload();\n }\n return 'Provide a workspace path or a registered canvas name';\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.apply_source',\n name: 'Apply canvas source',\n description: 'Updates an open canvas editor and recompiles its preview without saving. When that canvas is not open in an editor, writes the file instead.',\n parameters: [\n { name: 'source', description: 'Full canvas module source', required: true },\n { name: 'path', description: 'Workspace path of the canvas file. Required when that canvas is not open in an editor.', required: false },\n ],\n },\n handler: {\n execute: async ({ params }) => {\n const source = String(params?.source ?? '');\n const requested = typeof params?.path === 'string' ? params.path : undefined;\n const path = requested ?? workspaceCanvas()?.getFilePath?.() ?? undefined;\n const targets = path ? connectedWorkspaceEditors(path) : [];\n if (targets.length) {\n let compiled = 'ready';\n for (const editor of targets) {\n if (!editor.setSource || !editor.reload) continue;\n editor.setSource(source);\n compiled = await editor.reload();\n }\n return compiled;\n }\n if (!path) return 'Provide a workspace path';\n return writeWorkspaceFile(path, source);\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.get_source',\n name: 'Get canvas source',\n description: 'Returns the current source buffer of the active workspace canvas',\n parameters: [],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async () => workspaceCanvas()?.getContent?.() ?? '',\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.get_state',\n name: 'Get canvas state',\n description: 'Reads one persisted state value from the active workspace canvas',\n parameters: [{ name: 'key', description: 'State key', required: true }],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => workspaceCanvas()?.getState?.(String(params?.key ?? '')),\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.set_state',\n name: 'Set canvas state',\n description: 'Writes one persisted state value on the active workspace canvas',\n parameters: [\n { name: 'key', description: 'State key', required: true },\n { name: 'value', description: 'JSON value', required: true },\n ],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => {\n const active = workspaceCanvas();\n if (!active?.setState) return 'No workspace canvas is active';\n active.setState(String(params?.key ?? ''), params?.value);\n return 'ready';\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.capture_preview',\n name: 'Capture canvas preview',\n description: 'Renders the open canvas preview to an image, attaches it to the session, and returns it for visual inspection. Content inside an iframe may be blank.',\n parameters: [],\n },\n handler: {\n canExecute: () => !!findOpenCanvas()?.capturePreview,\n execute: async () => {\n const active = findOpenCanvas();\n if (!active) return 'No canvas is open';\n return attachPreviewShot(active);\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.show_as_view',\n name: 'Show canvas as view',\n description: 'Pins the active workspace canvas preview into a sidebar or the bottom panel',\n parameters: [\n { name: 'slot', description: 'sidebar-main, sidebar-auxiliary, or panel-bottom', required: true },\n ],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => {\n const active = workspaceCanvas();\n const path = active?.getFilePath?.();\n if (!active || !path) return 'No workspace canvas is active';\n return showCanvasView(String(params?.slot ?? ''), path, active.getContent?.() ?? '');\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.hide_view',\n name: 'Hide canvas view',\n description: 'Removes a pinned canvas preview from a sidebar or the bottom panel',\n parameters: [\n { name: 'slot', description: 'sidebar-main, sidebar-auxiliary, or panel-bottom', required: true },\n { name: 'path', description: 'Workspace path of the canvas file', required: false },\n ],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => {\n const path = (params?.path as string | undefined) ?? workspaceCanvas()?.getFilePath?.() ?? '';\n if (!path) return 'No canvas path';\n return hideCanvasView(String(params?.slot ?? ''), path);\n },\n },\n });\n}\n"],"mappings":";;;;;;;;AAmBA,IAAM,6BAAa,IAAI,IAAI;CAAC;CAAc;CAAmB;AAAY,CAAC;AAE1E,SAAgB,kBAAkB,cAAkC,aAAa,IAAiB;CAC9F,MAAM,YAAY,aAAa,WAAW,KAAA;CAC1C,MAAM,QAAQ;EACV,KAAK,UAAU,aAAa;EAC5B,OAAO,aAAa;EACpB,MAAM,aAAa,QAAQ;EAC3B,MAAM,EAAE,aAAa;EACrB,OAAO,EAAE,MAAM,UAAU;EACzB,iBAAiB,IAAI;CACzB;CACA,MAAM,aAAa,OAAe,YAC5B,IAAI,4BAA4B,GAAG,WAAW,MAAM,W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AS,OAAO,EAAE,aAAa;IAC3B,MAAM,OAAQ,QAAQ,QAA+B,gBAAgB,CAAC,EAAE,cAAc,KAAK;IAC3F,IAAI,CAAC,MAAM,OAAO;IAClB,OAAO,eAAe,OAAO,QAAQ,QAAQ,EAAE,GAAG,IAAI;GAC1D;EACJ;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"commands.js","names":[],"sources":["../src/commands.ts"],"sourcesContent":["import {\n contributionRegistry,\n editorRegistry,\n File,\n registerAll,\n SIDEBAR_AUXILIARY,\n SIDEBAR_MAIN,\n PANEL_BOTTOM,\n workspaceService,\n type EditorInput,\n} from '@eclipse-docks/core';\nimport { html } from '@eclipse-docks/core/externals/lit';\nimport { connectedWorkspaceEditors, findOpenCanvas, isCanvasViewer, readActiveCanvas } from './active-canvas';\nimport { listRegisteredCanvases } from './canvases';\nimport type { CanvasContribution } from './contribution';\nimport { attachPreviewShot } from './preview-image';\nimport { writeWorkspaceFile } from './workspace-file';\nimport './canvas-editor';\nimport './canvas-readonly';\n\nconst VIEW_SLOTS = new Set([SIDEBAR_MAIN, SIDEBAR_AUXILIARY, PANEL_BOTTOM]);\n\nexport function canvasEditorInput(contribution: CanvasContribution, sourceText = ''): EditorInput {\n const input = {\n key: `canvas:${contribution.name}`,\n title: contribution.label,\n icon: contribution.icon ?? 'table-columns',\n data: { contribution },\n state: { mode: 'preview' },\n toolbar: false,\n component: () => html``,\n } as EditorInput;\n input.component = (id: string) => html`<docks-canvas-readonly id=\"${id}\" .input=${input} .source=${sourceText}></docks-canvas-readonly>`;\n (input as unknown as { editorId: string }).editorId = 'system.canvas-readonly';\n return input;\n}\n\nexport async function openCanvasByName(name: string): Promise<string> {\n const contribution = listRegisteredCanvases().find(item => item.name === name);\n if (!contribution) return `No canvas named ${name}`;\n const sourceText = typeof contribution.source === 'function' ? await contribution.source() : (contribution.source ?? '');\n await editorRegistry.loadEditor(canvasEditorInput(contribution, sourceText));\n return 'ready';\n}\n\nexport async function openCanvasByPath(path: string): Promise<string> {\n const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\n if (!workspace) return 'No workspace is open';\n const resource = await workspace.getResource(path.replace(/^\\/+/, ''));\n if (!(resource instanceof File)) return `Cannot find workspace file \"${path}\"`;\n await editorRegistry.loadEditor(resource, 'system.canvas-editor');\n return 'ready';\n}\n\nfunction viewName(path: string): string {\n return `canvas-view:${path}`;\n}\n\nexport function showCanvasView(slot: string, path: string, source: string): string {\n if (!VIEW_SLOTS.has(slot)) return `Unsupported view slot ${slot}`;\n const name = viewName(path);\n contributionRegistry.unregisterContribution(slot, name);\n contributionRegistry.registerContribution(slot, {\n name,\n label: path.split('/').pop() || path,\n icon: 'table-columns',\n closable: true,\n component: (id: string) => html`<docks-canvas-surface id=\"${id}\" .entryPath=${path} .source=${source}></docks-canvas-surface>`,\n });\n return 'ready';\n}\n\nexport function hideCanvasView(slot: string, path: string): string {\n if (!VIEW_SLOTS.has(slot)) return `Unsupported view slot ${slot}`;\n contributionRegistry.unregisterContribution(slot, viewName(path));\n return 'ready';\n}\n\nfunction workspaceCanvas() {\n const active = readActiveCanvas();\n if (!active?.editor || active.kind !== 'workspace') return null;\n return active;\n}\n\nasync function waitForCanvas(match: (active: NonNullable<ReturnType<typeof readActiveCanvas>>) => boolean) {\n for (let attempt = 0; attempt < 30; attempt++) {\n const active = readActiveCanvas();\n if (active?.reload && match(active)) return active;\n await new Promise(resolve => setTimeout(resolve, 50));\n }\n return null;\n}\n\nexport function registerCanvasCommands(): void {\n registerAll({\n command: {\n id: 'canvas.open',\n name: 'Open canvas',\n description: 'Opens a workspace .canvas.js path or a canvas registered on system.canvases and returns ready or a compile error',\n parameters: [\n { name: 'path', description: 'Workspace path of a .canvas.js file', required: false },\n { name: 'name', description: 'Name of a canvas registered on system.canvases', required: false },\n ],\n },\n handler: {\n execute: async ({ params }) => {\n const name = params?.name as string | undefined;\n const path = params?.path as string | undefined;\n if (name) {\n const opened = await openCanvasByName(name);\n if (opened !== 'ready') return opened;\n const active = await waitForCanvas(item => item.canvasName === name);\n return active?.reload ? active.reload() : opened;\n }\n if (path) {\n const opened = await openCanvasByPath(path);\n if (opened !== 'ready') return opened;\n const normalized = path.replace(/^\\/+/, '');\n const active = await waitForCanvas(item => item.getFilePath?.()?.replace(/^\\/+/, '') === normalized);\n if (!active?.reload) return opened;\n await active.syncFromFile?.();\n return active.reload();\n }\n return 'Provide a workspace path or a registered canvas name';\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.apply_source',\n name: 'Apply canvas source',\n description: 'Updates an open canvas editor and recompiles its preview without saving. When that canvas is not open in an editor, writes the file instead.',\n parameters: [\n { name: 'source', description: 'Full canvas module source', required: true },\n { name: 'path', description: 'Workspace path of the canvas file. Required when that canvas is not open in an editor.', required: false },\n ],\n },\n handler: {\n canExecute: () => !isCanvasViewer(),\n execute: async ({ params }) => {\n const source = String(params?.source ?? '');\n const requested = typeof params?.path === 'string' ? params.path : undefined;\n const path = requested ?? workspaceCanvas()?.getFilePath?.() ?? undefined;\n const targets = path ? connectedWorkspaceEditors(path) : [];\n if (targets.length) {\n let compiled = 'ready';\n for (const editor of targets) {\n if (!editor.setSource || !editor.reload) continue;\n editor.setSource(source);\n compiled = await editor.reload();\n }\n return compiled;\n }\n if (!path) return 'Provide a workspace path';\n return writeWorkspaceFile(path, source);\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.get_source',\n name: 'Get canvas source',\n description: 'Returns the current source buffer of the active workspace canvas',\n parameters: [],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async () => workspaceCanvas()?.getContent?.() ?? '',\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.get_state',\n name: 'Get canvas state',\n description: 'Reads one persisted state value from the active workspace canvas',\n parameters: [{ name: 'key', description: 'State key', required: true }],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => workspaceCanvas()?.getState?.(String(params?.key ?? '')),\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.set_state',\n name: 'Set canvas state',\n description: 'Writes one persisted state value on the active workspace canvas',\n parameters: [\n { name: 'key', description: 'State key', required: true },\n { name: 'value', description: 'JSON value', required: true },\n ],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => {\n const active = workspaceCanvas();\n if (!active?.setState) return 'No workspace canvas is active';\n active.setState(String(params?.key ?? ''), params?.value);\n return 'ready';\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.capture_preview',\n name: 'Capture canvas preview',\n description: 'Renders the open canvas preview to an image, attaches it to the session, and returns it for visual inspection. Content inside an iframe may be blank.',\n parameters: [],\n },\n handler: {\n canExecute: () => !!findOpenCanvas()?.capturePreview,\n execute: async () => {\n const active = findOpenCanvas();\n if (!active) return 'No canvas is open';\n return attachPreviewShot(active);\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.show_as_view',\n name: 'Show canvas as view',\n description: 'Pins the active workspace canvas preview into a sidebar or the bottom panel',\n parameters: [\n { name: 'slot', description: 'sidebar-main, sidebar-auxiliary, or panel-bottom', required: true },\n ],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => {\n const active = workspaceCanvas();\n const path = active?.getFilePath?.();\n if (!active || !path) return 'No workspace canvas is active';\n return showCanvasView(String(params?.slot ?? ''), path, active.getContent?.() ?? '');\n },\n },\n });\n\n registerAll({\n command: {\n id: 'canvas.hide_view',\n name: 'Hide canvas view',\n description: 'Removes a pinned canvas preview from a sidebar or the bottom panel',\n parameters: [\n { name: 'slot', description: 'sidebar-main, sidebar-auxiliary, or panel-bottom', required: true },\n { name: 'path', description: 'Workspace path of the canvas file', required: false },\n ],\n },\n handler: {\n canExecute: () => !!workspaceCanvas(),\n execute: async ({ params }) => {\n const path = (params?.path as string | undefined) ?? workspaceCanvas()?.getFilePath?.() ?? '';\n if (!path) return 'No canvas path';\n return hideCanvasView(String(params?.slot ?? ''), path);\n },\n },\n });\n}\n"],"mappings":";;;;;;;;;AA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AO,eAAe,OAAO,QAAQ,QAAQ,EAAE,GAAG,MAAM,OAAO,aAAa,KAAK,EAAE;GACvF;EACJ;CACJ,CAAC;CAED,YAAY;EACR,SAAS;GACL,IAAI;GACJ,MAAM;GACN,aAAa;GACb,YAAY,CACR;IAAE,MAAM;IAAQ,aAAa;IAAoD,UAAU;GAAK,GAChG;IAAE,MAAM;IAAQ,aAAa;IAAqC,UAAU;GAAM,CACtF;EACJ;EACA,SAAS;GACL,kBAAkB,CAAC,CAAC,gBAAgB;GACpC,SAAS,OAAO,EAAE,aAAa;IAC3B,MAAM,OAAQ,QAAQ,QAA+B,gBAAgB,CAAC,EAAE,cAAc,KAAK;IAC3F,IAAI,CAAC,MAAM,OAAO;IAClB,OAAO,eAAe,OAAO,QAAQ,QAAQ,EAAE,GAAG,IAAI;GAC1D;EACJ;CACJ,CAAC;AACL"}
@@ -18,11 +18,13 @@ export interface CanvasToolContribution {
18
18
  }
19
19
  /** A canvas module registered on {@link SYSTEM_CANVASES} and opened from the toolbar dropdown. */
20
20
  export interface CanvasContribution extends TabContribution {
21
- /** Module whose default export is an HTMLElement subclass. */
22
- load: () => Promise<{
21
+ /** Unique app-settings key for this canvas's `canvasHost` state. */
22
+ settingsKey: string;
23
+ /** Constructor module. Omit when `source` is canvas text; the editor compiles that. */
24
+ load?: () => Promise<{
23
25
  default: CustomElementConstructor;
24
26
  }>;
25
- /** When set, the editor can toggle between preview and source and counts as an editor. */
27
+ /** Canvas module source. Compiled for the preview; the contribution is not editable. */
26
28
  source?: string | (() => Promise<string>);
27
29
  tools?: CanvasToolContribution[];
28
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../src/contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEzE,wGAAwG;AACxG,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACnC,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,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,OAAO,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC5B,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1F;AAED,kGAAkG;AAClG,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACvD,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,wBAAwB,CAAA;KAAE,CAAC,CAAC;IAC5D,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACpC;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,IAAI,kBAAkB,CAInG"}
@@ -2,7 +2,8 @@
2
2
  /** Slot for canvases an extension contributes. The toolbar dropdown lists it; it is not a tab group. */
3
3
  var SYSTEM_CANVASES = "system.canvases";
4
4
  function isCanvasContribution(contribution) {
5
- return typeof contribution.load === "function";
5
+ const canvas = contribution;
6
+ return typeof canvas.settingsKey === "string" && canvas.settingsKey.length > 0 && (typeof canvas.load === "function" || canvas.source !== void 0);
6
7
  }
7
8
  //#endregion
8
9
  export { SYSTEM_CANVASES, isCanvasContribution };
@@ -1 +1 @@
1
- {"version":3,"file":"contribution.js","names":[],"sources":["../src/contribution.ts"],"sourcesContent":["import type { Contribution, TabContribution } from '@eclipse-docks/core';\n\n/** Slot for canvases an extension contributes. The toolbar dropdown lists it; it is not a tab group. */\nexport const SYSTEM_CANVASES = 'system.canvases';\n\nexport interface CanvasToolContribution {\n id: string;\n name: string;\n description: string;\n parameters?: Array<{\n name: string;\n description: string;\n type?: string;\n required: boolean;\n allowedValues?: string[];\n }>;\n execute: (context: { params?: Record<string, unknown> }) => unknown | Promise<unknown>;\n}\n\n/** A canvas module registered on {@link SYSTEM_CANVASES} and opened from the toolbar dropdown. */\nexport interface CanvasContribution extends TabContribution {\n /** Module whose default export is an HTMLElement subclass. */\n load: () => Promise<{ default: CustomElementConstructor }>;\n /** When set, the editor can toggle between preview and source and counts as an editor. */\n source?: string | (() => Promise<string>);\n tools?: CanvasToolContribution[];\n}\n\nexport function isCanvasContribution(contribution: Contribution): contribution is CanvasContribution {\n return typeof (contribution as CanvasContribution).load === 'function';\n}\n"],"mappings":";;AAGA,IAAa,kBAAkB;AAyB/B,SAAgB,qBAAqB,cAAgE;CACjG,OAAO,OAAQ,aAAoC,SAAS;AAChE"}
1
+ {"version":3,"file":"contribution.js","names":[],"sources":["../src/contribution.ts"],"sourcesContent":["import type { Contribution, TabContribution } from '@eclipse-docks/core';\n\n/** Slot for canvases an extension contributes. The toolbar dropdown lists it; it is not a tab group. */\nexport const SYSTEM_CANVASES = 'system.canvases';\n\nexport interface CanvasToolContribution {\n id: string;\n name: string;\n description: string;\n parameters?: Array<{\n name: string;\n description: string;\n type?: string;\n required: boolean;\n allowedValues?: string[];\n }>;\n execute: (context: { params?: Record<string, unknown> }) => unknown | Promise<unknown>;\n}\n\n/** A canvas module registered on {@link SYSTEM_CANVASES} and opened from the toolbar dropdown. */\nexport interface CanvasContribution extends TabContribution {\n /** Unique app-settings key for this canvas's `canvasHost` state. */\n settingsKey: string;\n /** Constructor module. Omit when `source` is canvas text; the editor compiles that. */\n load?: () => Promise<{ default: CustomElementConstructor }>;\n /** Canvas module source. Compiled for the preview; the contribution is not editable. */\n source?: string | (() => Promise<string>);\n tools?: CanvasToolContribution[];\n}\n\nexport function isCanvasContribution(contribution: Contribution): contribution is CanvasContribution {\n const canvas = contribution as CanvasContribution;\n return typeof canvas.settingsKey === 'string' && canvas.settingsKey.length > 0\n && (typeof canvas.load === 'function' || canvas.source !== undefined);\n}\n"],"mappings":";;AAGA,IAAa,kBAAkB;AA2B/B,SAAgB,qBAAqB,cAAgE;CACjG,MAAM,SAAS;CACf,OAAO,OAAO,OAAO,gBAAgB,YAAY,OAAO,YAAY,SAAS,MACrE,OAAO,OAAO,SAAS,cAAc,OAAO,WAAW,KAAA;AACnE"}
package/dist/host.js CHANGED
@@ -21,7 +21,7 @@ async function createFileHost(file) {
21
21
  });
22
22
  }
23
23
  async function createContributionHost(contribution) {
24
- const key = `canvas.${contribution.name}`;
24
+ const key = contribution.settingsKey;
25
25
  const stored = await appSettings.get(key);
26
26
  return createMemoryHost(stored && typeof stored === "object" ? stored : {}, (state) => {
27
27
  appSettings.set(key, state);
package/dist/host.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","names":[],"sources":["../src/host.ts"],"sourcesContent":["import { appSettings, editorRegistry, File, workspaceService } from '@eclipse-docks/core';\nimport type { CanvasContribution } from './contribution';\n\nexport interface CanvasHost {\n getState(key: string, fallback?: unknown): unknown;\n setState(key: string, value: unknown): void;\n openFile(path: string): void;\n}\n\nexport function createMemoryHost(initial: Record<string, unknown>, persist: (state: Record<string, unknown>) => void): CanvasHost {\n const state = { ...initial };\n return {\n getState(key, fallback) {\n return state[key] === undefined ? fallback : state[key];\n },\n setState(key, value) {\n state[key] = value;\n persist(state);\n },\n openFile(path) {\n void openWorkspaceFile(path);\n },\n };\n}\n\nexport async function createFileHost(file: File): Promise<CanvasHost> {\n const initial = await readSidecar(file);\n return createMemoryHost(initial, state => {\n void writeSidecar(file, state);\n });\n}\n\nexport async function createContributionHost(contribution: CanvasContribution): Promise<CanvasHost> {\n const key = `canvas.${contribution.name}`;\n const stored = await appSettings.get(key);\n const initial = stored && typeof stored === 'object' ? stored as Record<string, unknown> : {};\n return createMemoryHost(initial, state => {\n void appSettings.set(key, state);\n });\n}\n\nfunction sidecarName(fileName: string): string {\n return fileName.replace(/\\.canvas\\.js$/i, '.canvas.data.json');\n}\n\nasync function readSidecar(file: File): Promise<Record<string, unknown>> {\n const parent = file.getParent();\n if (!parent) return {};\n const resource = await parent.getResource(sidecarName(file.getName()));\n if (!(resource instanceof File)) return {};\n try {\n const parsed = JSON.parse(await resource.getContents());\n return parsed && typeof parsed === 'object' ? parsed as Record<string, unknown> : {};\n } catch {\n return {};\n }\n}\n\nasync function writeSidecar(file: File, state: Record<string, unknown>): Promise<void> {\n const parent = file.getParent();\n if (!parent) return;\n const name = sidecarName(file.getName());\n let resource = await parent.getResource(name);\n if (!(resource instanceof File)) {\n resource = await parent.getResource(name, { create: true }) as File | null;\n }\n if (!(resource instanceof File)) return;\n await resource.saveContents(JSON.stringify(state));\n}\n\nasync function openWorkspaceFile(path: string): Promise<void> {\n const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\n if (!workspace) return;\n const resource = await workspace.getResource(path.replace(/^\\/+/, ''));\n if (resource instanceof File) await editorRegistry.loadEditor(resource);\n}\n"],"mappings":";;AASA,SAAgB,iBAAiB,SAAkC,SAA+D;CAC9H,MAAM,QAAQ,EAAE,GAAG,QAAQ;CAC3B,OAAO;EACH,SAAS,KAAK,UAAU;GACpB,OAAO,MAAM,SAAS,KAAA,IAAY,WAAW,MAAM;EACvD;EACA,SAAS,KAAK,OAAO;GACjB,MAAM,OAAO;GACb,QAAQ,KAAK;EACjB;EACA,SAAS,MAAM;GACX,kBAAuB,IAAI;EAC/B;CACJ;AACJ;AAEA,eAAsB,eAAe,MAAiC;CAElE,OAAO,iBAAiB,MADF,YAAY,IAAI,IACL,UAAS;EACtC,aAAkB,MAAM,KAAK;CACjC,CAAC;AACL;AAEA,eAAsB,uBAAuB,cAAuD;CAChG,MAAM,MAAM,UAAU,aAAa;CACnC,MAAM,SAAS,MAAM,YAAY,IAAI,GAAG;CAExC,OAAO,iBADS,UAAU,OAAO,WAAW,WAAW,SAAoC,CAAC,IAC3D,UAAS;EACtC,YAAiB,IAAI,KAAK,KAAK;CACnC,CAAC;AACL;AAEA,SAAS,YAAY,UAA0B;CAC3C,OAAO,SAAS,QAAQ,kBAAkB,mBAAmB;AACjE;AAEA,eAAe,YAAY,MAA8C;CACrE,MAAM,SAAS,KAAK,UAAU;CAC9B,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,MAAM,WAAW,MAAM,OAAO,YAAY,YAAY,KAAK,QAAQ,CAAC,CAAC;CACrE,IAAI,EAAE,oBAAoB,OAAO,OAAO,CAAC;CACzC,IAAI;EACA,MAAM,SAAS,KAAK,MAAM,MAAM,SAAS,YAAY,CAAC;EACtD,OAAO,UAAU,OAAO,WAAW,WAAW,SAAoC,CAAC;CACvF,QAAQ;EACJ,OAAO,CAAC;CACZ;AACJ;AAEA,eAAe,aAAa,MAAY,OAA+C;CACnF,MAAM,SAAS,KAAK,UAAU;CAC9B,IAAI,CAAC,QAAQ;CACb,MAAM,OAAO,YAAY,KAAK,QAAQ,CAAC;CACvC,IAAI,WAAW,MAAM,OAAO,YAAY,IAAI;CAC5C,IAAI,EAAE,oBAAoB,OACtB,WAAW,MAAM,OAAO,YAAY,MAAM,EAAE,QAAQ,KAAK,CAAC;CAE9D,IAAI,EAAE,oBAAoB,OAAO;CACjC,MAAM,SAAS,aAAa,KAAK,UAAU,KAAK,CAAC;AACrD;AAEA,eAAe,kBAAkB,MAA6B;CAC1D,MAAM,YAAY,iBAAiB,iBAAiB,KAAK,MAAM,iBAAiB,aAAa;CAC7F,IAAI,CAAC,WAAW;CAChB,MAAM,WAAW,MAAM,UAAU,YAAY,KAAK,QAAQ,QAAQ,EAAE,CAAC;CACrE,IAAI,oBAAoB,MAAM,MAAM,eAAe,WAAW,QAAQ;AAC1E"}
1
+ {"version":3,"file":"host.js","names":[],"sources":["../src/host.ts"],"sourcesContent":["import { appSettings, editorRegistry, File, workspaceService } from '@eclipse-docks/core';\nimport type { CanvasContribution } from './contribution';\n\nexport interface CanvasHost {\n getState(key: string, fallback?: unknown): unknown;\n setState(key: string, value: unknown): void;\n openFile(path: string): void;\n}\n\nexport function createMemoryHost(initial: Record<string, unknown>, persist: (state: Record<string, unknown>) => void): CanvasHost {\n const state = { ...initial };\n return {\n getState(key, fallback) {\n return state[key] === undefined ? fallback : state[key];\n },\n setState(key, value) {\n state[key] = value;\n persist(state);\n },\n openFile(path) {\n void openWorkspaceFile(path);\n },\n };\n}\n\nexport async function createFileHost(file: File): Promise<CanvasHost> {\n const initial = await readSidecar(file);\n return createMemoryHost(initial, state => {\n void writeSidecar(file, state);\n });\n}\n\nexport async function createContributionHost(contribution: CanvasContribution): Promise<CanvasHost> {\n const key = contribution.settingsKey;\n const stored = await appSettings.get(key);\n const initial = stored && typeof stored === 'object' ? stored as Record<string, unknown> : {};\n return createMemoryHost(initial, state => {\n void appSettings.set(key, state);\n });\n}\n\nfunction sidecarName(fileName: string): string {\n return fileName.replace(/\\.canvas\\.js$/i, '.canvas.data.json');\n}\n\nasync function readSidecar(file: File): Promise<Record<string, unknown>> {\n const parent = file.getParent();\n if (!parent) return {};\n const resource = await parent.getResource(sidecarName(file.getName()));\n if (!(resource instanceof File)) return {};\n try {\n const parsed = JSON.parse(await resource.getContents());\n return parsed && typeof parsed === 'object' ? parsed as Record<string, unknown> : {};\n } catch {\n return {};\n }\n}\n\nasync function writeSidecar(file: File, state: Record<string, unknown>): Promise<void> {\n const parent = file.getParent();\n if (!parent) return;\n const name = sidecarName(file.getName());\n let resource = await parent.getResource(name);\n if (!(resource instanceof File)) {\n resource = await parent.getResource(name, { create: true }) as File | null;\n }\n if (!(resource instanceof File)) return;\n await resource.saveContents(JSON.stringify(state));\n}\n\nasync function openWorkspaceFile(path: string): Promise<void> {\n const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\n if (!workspace) return;\n const resource = await workspace.getResource(path.replace(/^\\/+/, ''));\n if (resource instanceof File) await editorRegistry.loadEditor(resource);\n}\n"],"mappings":";;AASA,SAA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E,oBAAoB,OACtB,WAAW,MAAM,OAAO,YAAY,MAAM,EAAE,QAAQ,KAAK,CAAC;CAE9D,IAAI,EAAE,oBAAoB,OAAO;CACjC,MAAM,SAAS,aAAa,KAAK,UAAU,KAAK,CAAC;AACrD;AAEA,eAAe,kBAAkB,MAA6B;CAC1D,MAAM,YAAY,iBAAiB,iBAAiB,KAAK,MAAM,iBAAiB,aAAa;CAC7F,IAAI,CAAC,WAAW;CAChB,MAAM,WAAW,MAAM,UAAU,YAAY,KAAK,QAAQ,QAAQ,EAAE,CAAC;CACrE,IAAI,oBAAoB,MAAM,MAAM,eAAe,WAAW,QAAQ;AAC1E"}
@@ -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`. That opens a read-only viewer. Do not edit it: `canvas.apply_source`, `canvas.get_source`, `canvas.set_state`, and any tools declared by that canvas are not available while it is active.\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":""}