@eclipse-docks/extension-canvas 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js +9 -0
- package/dist/active-canvas.d.ts +13 -0
- package/dist/active-canvas.d.ts.map +1 -0
- package/dist/active-canvas.js +23 -0
- package/dist/active-canvas.js.map +1 -0
- package/dist/bridges/core.d.ts +2 -0
- package/dist/bridges/core.d.ts.map +1 -0
- package/dist/bridges/core.js +9 -0
- package/dist/bridges/core.js.map +1 -0
- package/dist/bridges/events.d.ts +2 -0
- package/dist/bridges/events.d.ts.map +1 -0
- package/dist/bridges/events.js +9 -0
- package/dist/bridges/events.js.map +1 -0
- package/dist/bridges/lit.d.ts +2 -0
- package/dist/bridges/lit.d.ts.map +1 -0
- package/dist/bridges/lit.js +9 -0
- package/dist/bridges/lit.js.map +1 -0
- package/dist/bridges/parts.d.ts +2 -0
- package/dist/bridges/parts.d.ts.map +1 -0
- package/dist/bridges/parts.js +9 -0
- package/dist/bridges/parts.js.map +1 -0
- package/dist/bridges/register.d.ts +9 -0
- package/dist/bridges/register.d.ts.map +1 -0
- package/dist/bridges/register.js +13 -0
- package/dist/bridges/register.js.map +1 -0
- package/dist/bridges/third-party.d.ts +2 -0
- package/dist/bridges/third-party.d.ts.map +1 -0
- package/dist/bridges/third-party.js +9 -0
- package/dist/bridges/third-party.js.map +1 -0
- package/dist/bridges/urls.d.ts +3 -0
- package/dist/bridges/urls.d.ts.map +1 -0
- package/dist/bridges/urls.js +27 -0
- package/dist/bridges/urls.js.map +1 -0
- package/dist/bridges/webawesome.d.ts +2 -0
- package/dist/bridges/webawesome.d.ts.map +1 -0
- package/dist/bridges/webawesome.js +9 -0
- package/dist/bridges/webawesome.js.map +1 -0
- package/dist/bridges/widgets.d.ts +2 -0
- package/dist/bridges/widgets.d.ts.map +1 -0
- package/dist/bridges/widgets.js +9 -0
- package/dist/bridges/widgets.js.map +1 -0
- package/dist/canvas-editor.d.ts +61 -0
- package/dist/canvas-editor.d.ts.map +1 -0
- package/dist/canvas-editor.js +276 -0
- package/dist/canvas-editor.js.map +1 -0
- package/dist/canvas-extension.d.ts +1 -0
- package/dist/canvas-extension.d.ts.map +1 -0
- package/dist/canvas-extension.js +48 -0
- package/dist/canvas-extension.js.map +1 -0
- package/dist/canvas-switcher.d.ts +11 -0
- package/dist/canvas-switcher.d.ts.map +1 -0
- package/dist/canvas-switcher.js +59 -0
- package/dist/canvas-switcher.js.map +1 -0
- package/dist/canvas-tools.d.ts +4 -0
- package/dist/canvas-tools.d.ts.map +1 -0
- package/dist/canvas-tools.js +30 -0
- package/dist/canvas-tools.js.map +1 -0
- package/dist/canvases.d.ts +3 -0
- package/dist/canvases.d.ts.map +1 -0
- package/dist/canvases.js +10 -0
- package/dist/canvases.js.map +1 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +255 -0
- package/dist/commands.js.map +1 -0
- package/dist/compile.d.ts +31 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +398 -0
- package/dist/compile.js.map +1 -0
- package/dist/contribution.d.ts +30 -0
- package/dist/contribution.d.ts.map +1 -0
- package/dist/contribution.js +10 -0
- package/dist/contribution.js.map +1 -0
- package/dist/help.d.ts +3 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +19 -0
- package/dist/help.js.map +1 -0
- package/dist/host.d.ts +11 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +63 -0
- package/dist/host.js.map +1 -0
- package/dist/i18n.de.js +11 -0
- package/dist/i18n.de.js.map +1 -0
- package/dist/i18n.en.js +11 -0
- package/dist/i18n.en.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/mount.d.ts +15 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +81 -0
- package/dist/mount.js.map +1 -0
- package/dist/workspace-file.d.ts +5 -0
- package/dist/workspace-file.d.ts.map +1 -0
- package/dist/workspace-file.js +41 -0
- package/dist/workspace-file.js.map +1 -0
- package/package.json +41 -4
- package/README.md +0 -3
package/dist/i18n.de.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/i18n.de.json
|
|
2
|
+
var EXT_CANVAS_NAME = "Canvas";
|
|
3
|
+
var EXT_CANVAS_DESC = ".canvas.js-Dateien und von Erweiterungen registrierte Canvases öffnen";
|
|
4
|
+
var i18n_de_default = {
|
|
5
|
+
EXT_CANVAS_NAME,
|
|
6
|
+
EXT_CANVAS_DESC
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { EXT_CANVAS_DESC, EXT_CANVAS_NAME, i18n_de_default as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=i18n.de.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.de.js","names":[],"sources":["../src/i18n.de.json"],"sourcesContent":["{\n \"EXT_CANVAS_NAME\": \"Canvas\",\n \"EXT_CANVAS_DESC\": \".canvas.js-Dateien und von Erweiterungen registrierte Canvases öffnen\"\n}\n"],"mappings":""}
|
package/dist/i18n.en.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/i18n.en.json
|
|
2
|
+
var EXT_CANVAS_NAME = "Canvas";
|
|
3
|
+
var EXT_CANVAS_DESC = "Open .canvas.js files and canvases registered by extensions";
|
|
4
|
+
var i18n_en_default = {
|
|
5
|
+
EXT_CANVAS_NAME,
|
|
6
|
+
EXT_CANVAS_DESC
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { EXT_CANVAS_DESC, EXT_CANVAS_NAME, i18n_en_default as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=i18n.en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.en.js","names":[],"sources":["../src/i18n.en.json"],"sourcesContent":["{\n \"EXT_CANVAS_NAME\": \"Canvas\",\n \"EXT_CANVAS_DESC\": \"Open .canvas.js files and canvases registered by extensions\"\n}\n"],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SYSTEM_CANVASES, isCanvasContribution } from "./contribution.js";
|
|
2
|
+
import { extensionRegistry, i18n } from "@eclipse-docks/core";
|
|
3
|
+
import pkg from "../package.json";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
var t = await i18n(/* #__PURE__ */ Object.assign({
|
|
6
|
+
"./i18n.de.json": () => import("./i18n.de.js"),
|
|
7
|
+
"./i18n.en.json": () => import("./i18n.en.js")
|
|
8
|
+
}), true);
|
|
9
|
+
extensionRegistry.registerExtension({
|
|
10
|
+
id: pkg.name,
|
|
11
|
+
name: t.EXT_CANVAS_NAME,
|
|
12
|
+
description: t.EXT_CANVAS_DESC,
|
|
13
|
+
loader: () => import("./canvas-extension.js"),
|
|
14
|
+
icon: "table-columns",
|
|
15
|
+
dependencies: ["@eclipse-docks/extension-monaco-editor"]
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { SYSTEM_CANVASES, isCanvasContribution };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { extensionRegistry, i18n } from '@eclipse-docks/core';\nimport pkg from '../package.json';\n\nexport { SYSTEM_CANVASES, isCanvasContribution, type CanvasContribution, type CanvasToolContribution } from './contribution';\n\nconst t = await i18n(import.meta.glob('./i18n*.json'), true);\n\nextensionRegistry.registerExtension({\n id: pkg.name,\n name: t.EXT_CANVAS_NAME,\n description: t.EXT_CANVAS_DESC,\n loader: () => import('./canvas-extension'),\n icon: 'table-columns',\n dependencies: ['@eclipse-docks/extension-monaco-editor'],\n});\n"],"mappings":";;;;AAKA,IAAM,IAAI,MAAM,KAAK,uBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,wBAAA,OAAA;AAAA,CAAA,GAAkC,IAAI;AAE3D,kBAAkB,kBAAkB;CAChC,IAAI,IAAI;CACR,MAAM,EAAE;CACR,aAAa,EAAE;CACf,cAAc,OAAO;CACrB,MAAM;CACN,cAAc,CAAC,wCAAwC;AAC3D,CAAC"}
|
package/dist/mount.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CanvasHost } from './host';
|
|
2
|
+
export interface CanvasViewElement extends HTMLElement {
|
|
3
|
+
canvasHost?: CanvasHost;
|
|
4
|
+
}
|
|
5
|
+
export type MountResult = {
|
|
6
|
+
ok: true;
|
|
7
|
+
element: CanvasViewElement;
|
|
8
|
+
dispose: () => void;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
error: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function elementFromConstructor(Ctor: CustomElementConstructor): CanvasViewElement;
|
|
14
|
+
export declare function mountCompiled(code: string): Promise<MountResult>;
|
|
15
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IAClD,UAAU,CAAC,EAAE,UAAU,CAAC;CAC3B;AAED,MAAM,MAAM,WAAW,GACjB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,GAC7D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAkCnC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CAQxF;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAqBtE"}
|
package/dist/mount.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region src/mount.ts
|
|
2
|
+
var tagSequence = 0;
|
|
3
|
+
var constructorTags = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function constructElement(Ctor) {
|
|
5
|
+
let tag = constructorTags.get(Ctor);
|
|
6
|
+
if (!tag) {
|
|
7
|
+
tag = `docks-canvas-compiled-${++tagSequence}`;
|
|
8
|
+
customElements.define(tag, Ctor);
|
|
9
|
+
constructorTags.set(Ctor, tag);
|
|
10
|
+
}
|
|
11
|
+
const caught = [];
|
|
12
|
+
const onError = (event) => {
|
|
13
|
+
caught.push(event.error ?? event.message);
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
};
|
|
16
|
+
window.addEventListener("error", onError);
|
|
17
|
+
let element;
|
|
18
|
+
try {
|
|
19
|
+
element = document.createElement(tag);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: err instanceof Error ? err.message : String(err)
|
|
24
|
+
};
|
|
25
|
+
} finally {
|
|
26
|
+
window.removeEventListener("error", onError);
|
|
27
|
+
}
|
|
28
|
+
if (!(element instanceof Ctor)) {
|
|
29
|
+
const reason = caught[0];
|
|
30
|
+
return {
|
|
31
|
+
ok: false,
|
|
32
|
+
error: reason instanceof Error ? reason.message : String(reason ?? "Canvas element failed to construct")
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
ok: true,
|
|
37
|
+
element,
|
|
38
|
+
dispose: () => element.remove()
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function elementFromConstructor(Ctor) {
|
|
42
|
+
let tag = constructorTags.get(Ctor);
|
|
43
|
+
if (!tag) {
|
|
44
|
+
tag = `docks-canvas-live-${++tagSequence}`;
|
|
45
|
+
customElements.define(tag, Ctor);
|
|
46
|
+
constructorTags.set(Ctor, tag);
|
|
47
|
+
}
|
|
48
|
+
return document.createElement(tag);
|
|
49
|
+
}
|
|
50
|
+
async function mountCompiled(code) {
|
|
51
|
+
const url = `data:text/javascript;charset=utf-8,${encodeURIComponent(code)}`;
|
|
52
|
+
try {
|
|
53
|
+
const Ctor = (await import(
|
|
54
|
+
/* @vite-ignore */
|
|
55
|
+
url
|
|
56
|
+
)).default;
|
|
57
|
+
if (typeof Ctor !== "function" || !(Ctor.prototype instanceof HTMLElement)) return {
|
|
58
|
+
ok: false,
|
|
59
|
+
error: "Canvas default export must be an HTMLElement subclass"
|
|
60
|
+
};
|
|
61
|
+
const constructed = constructElement(Ctor);
|
|
62
|
+
if (!constructed.ok) return constructed;
|
|
63
|
+
const element = constructed.element;
|
|
64
|
+
return {
|
|
65
|
+
ok: true,
|
|
66
|
+
element,
|
|
67
|
+
dispose: () => {
|
|
68
|
+
element.remove();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
} catch (err) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: err instanceof Error ? err.message : String(err)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { elementFromConstructor, mountCompiled };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.js","names":[],"sources":["../src/mount.ts"],"sourcesContent":["import type { CanvasHost } from './host';\n\nexport interface CanvasViewElement extends HTMLElement {\n canvasHost?: CanvasHost;\n}\n\nexport type MountResult =\n | { ok: true; element: CanvasViewElement; dispose: () => void }\n | { ok: false; error: string };\n\nlet tagSequence = 0;\nconst constructorTags = new WeakMap<CustomElementConstructor, string>();\n\nfunction constructElement(Ctor: CustomElementConstructor): MountResult {\n let tag = constructorTags.get(Ctor);\n if (!tag) {\n tag = `docks-canvas-compiled-${++tagSequence}`;\n customElements.define(tag, Ctor);\n constructorTags.set(Ctor, tag);\n }\n const caught: unknown[] = [];\n const onError = (event: ErrorEvent) => {\n caught.push(event.error ?? event.message);\n event.preventDefault();\n };\n window.addEventListener('error', onError);\n let element: CanvasViewElement;\n try {\n element = document.createElement(tag) as CanvasViewElement;\n } catch (err) {\n return { ok: false, error: err instanceof Error ? err.message : String(err) };\n } finally {\n window.removeEventListener('error', onError);\n }\n if (!(element instanceof Ctor)) {\n const reason = caught[0];\n const message = reason instanceof Error ? reason.message : String(reason ?? 'Canvas element failed to construct');\n return { ok: false, error: message };\n }\n return { ok: true, element, dispose: () => element.remove() };\n}\n\nexport function elementFromConstructor(Ctor: CustomElementConstructor): CanvasViewElement {\n let tag = constructorTags.get(Ctor);\n if (!tag) {\n tag = `docks-canvas-live-${++tagSequence}`;\n customElements.define(tag, Ctor);\n constructorTags.set(Ctor, tag);\n }\n return document.createElement(tag) as CanvasViewElement;\n}\n\nexport async function mountCompiled(code: string): Promise<MountResult> {\n const url = `data:text/javascript;charset=utf-8,${encodeURIComponent(code)}`;\n try {\n const mod = await import(/* @vite-ignore */ url);\n const Ctor = mod.default;\n if (typeof Ctor !== 'function' || !(Ctor.prototype instanceof HTMLElement)) {\n return { ok: false, error: 'Canvas default export must be an HTMLElement subclass' };\n }\n const constructed = constructElement(Ctor);\n if (!constructed.ok) return constructed;\n const element = constructed.element;\n return {\n ok: true,\n element,\n dispose: () => {\n element.remove();\n },\n };\n } catch (err) {\n return { ok: false, error: err instanceof Error ? err.message : String(err) };\n }\n}\n"],"mappings":";AAUA,IAAI,cAAc;AAClB,IAAM,kCAAkB,IAAI,QAA0C;AAEtE,SAAS,iBAAiB,MAA6C;CACnE,IAAI,MAAM,gBAAgB,IAAI,IAAI;CAClC,IAAI,CAAC,KAAK;EACN,MAAM,yBAAyB,EAAE;EACjC,eAAe,OAAO,KAAK,IAAI;EAC/B,gBAAgB,IAAI,MAAM,GAAG;CACjC;CACA,MAAM,SAAoB,CAAC;CAC3B,MAAM,WAAW,UAAsB;EACnC,OAAO,KAAK,MAAM,SAAS,MAAM,OAAO;EACxC,MAAM,eAAe;CACzB;CACA,OAAO,iBAAiB,SAAS,OAAO;CACxC,IAAI;CACJ,IAAI;EACA,UAAU,SAAS,cAAc,GAAG;CACxC,SAAS,KAAK;EACV,OAAO;GAAE,IAAI;GAAO,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EAAE;CAChF,UAAU;EACN,OAAO,oBAAoB,SAAS,OAAO;CAC/C;CACA,IAAI,EAAE,mBAAmB,OAAO;EAC5B,MAAM,SAAS,OAAO;EAEtB,OAAO;GAAE,IAAI;GAAO,OADJ,kBAAkB,QAAQ,OAAO,UAAU,OAAO,UAAU,oCAAoC;EAC7E;CACvC;CACA,OAAO;EAAE,IAAI;EAAM;EAAS,eAAe,QAAQ,OAAO;CAAE;AAChE;AAEA,SAAgB,uBAAuB,MAAmD;CACtF,IAAI,MAAM,gBAAgB,IAAI,IAAI;CAClC,IAAI,CAAC,KAAK;EACN,MAAM,qBAAqB,EAAE;EAC7B,eAAe,OAAO,KAAK,IAAI;EAC/B,gBAAgB,IAAI,MAAM,GAAG;CACjC;CACA,OAAO,SAAS,cAAc,GAAG;AACrC;AAEA,eAAsB,cAAc,MAAoC;CACpE,MAAM,MAAM,sCAAsC,mBAAmB,IAAI;CACzE,IAAI;EAEA,MAAM,QAAO,MADK;;GAA0B;EAC/B,CAAI;EACjB,IAAI,OAAO,SAAS,cAAc,EAAE,KAAK,qBAAqB,cAC1D,OAAO;GAAE,IAAI;GAAO,OAAO;EAAwD;EAEvF,MAAM,cAAc,iBAAiB,IAAI;EACzC,IAAI,CAAC,YAAY,IAAI,OAAO;EAC5B,MAAM,UAAU,YAAY;EAC5B,OAAO;GACH,IAAI;GACJ;GACA,eAAe;IACX,QAAQ,OAAO;GACnB;EACJ;CACJ,SAAS,KAAK;EACV,OAAO;GAAE,IAAI;GAAO,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EAAE;CAChF;AACJ"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { File } from '@eclipse-docks/core';
|
|
2
|
+
import { CanvasFileBytes } from './compile';
|
|
3
|
+
export declare function readWorkspaceFile(path: string): Promise<CanvasFileBytes | null>;
|
|
4
|
+
export declare function writeWorkspaceFile(path: string, contents: string): Promise<File | null>;
|
|
5
|
+
//# sourceMappingURL=workspace-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-file.d.ts","sourceRoot":"","sources":["../src/workspace-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAerF;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAO7F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { File, workspaceService } from "@eclipse-docks/core";
|
|
2
|
+
//#region src/workspace-file.ts
|
|
3
|
+
var TEXT_EXT = /* @__PURE__ */ new Set([
|
|
4
|
+
"js",
|
|
5
|
+
"mjs",
|
|
6
|
+
"css",
|
|
7
|
+
"json",
|
|
8
|
+
"svg",
|
|
9
|
+
"txt",
|
|
10
|
+
"md",
|
|
11
|
+
"html",
|
|
12
|
+
"csv"
|
|
13
|
+
]);
|
|
14
|
+
async function readWorkspaceFile(path) {
|
|
15
|
+
const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();
|
|
16
|
+
if (!workspace) return null;
|
|
17
|
+
const resource = await workspace.getResource(path.replace(/^\/+/, ""));
|
|
18
|
+
if (!(resource instanceof File)) return null;
|
|
19
|
+
const ext = path.split(".").pop()?.toLowerCase() ?? "";
|
|
20
|
+
if (TEXT_EXT.has(ext) || path.endsWith(".canvas.js")) {
|
|
21
|
+
const text = await resource.getContents();
|
|
22
|
+
return { text: typeof text === "string" ? text : String(text ?? "") };
|
|
23
|
+
}
|
|
24
|
+
const blob = await resource.getContents({ blob: true });
|
|
25
|
+
if (blob instanceof Blob) return { bytes: new Uint8Array(await blob.arrayBuffer()) };
|
|
26
|
+
if (blob instanceof Uint8Array) return { bytes: blob };
|
|
27
|
+
if (typeof blob === "string") return { text: blob };
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
async function writeWorkspaceFile(path, contents) {
|
|
31
|
+
const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();
|
|
32
|
+
if (!workspace) return null;
|
|
33
|
+
const resource = await workspace.getResource(path.replace(/^\/+/, ""), { create: true });
|
|
34
|
+
if (!(resource instanceof File)) return null;
|
|
35
|
+
await resource.saveContents(contents);
|
|
36
|
+
return resource;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { readWorkspaceFile, writeWorkspaceFile };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=workspace-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-file.js","names":[],"sources":["../src/workspace-file.ts"],"sourcesContent":["import { File, workspaceService } from '@eclipse-docks/core';\nimport type { CanvasFileBytes } from './compile';\n\nconst TEXT_EXT = new Set(['js', 'mjs', 'css', 'json', 'svg', 'txt', 'md', 'html', 'csv']);\n\nexport async function readWorkspaceFile(path: string): Promise<CanvasFileBytes | null> {\n const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\n if (!workspace) return null;\n const resource = await workspace.getResource(path.replace(/^\\/+/, ''));\n if (!(resource instanceof File)) return null;\n const ext = path.split('.').pop()?.toLowerCase() ?? '';\n if (TEXT_EXT.has(ext) || path.endsWith('.canvas.js')) {\n const text = await resource.getContents();\n return { text: typeof text === 'string' ? text : String(text ?? '') };\n }\n const blob = await resource.getContents({ blob: true });\n if (blob instanceof Blob) return { bytes: new Uint8Array(await blob.arrayBuffer()) };\n if (blob instanceof Uint8Array) return { bytes: blob };\n if (typeof blob === 'string') return { text: blob };\n return null;\n}\n\nexport async function writeWorkspaceFile(path: string, contents: string): Promise<File | null> {\n const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();\n if (!workspace) return null;\n const resource = await workspace.getResource(path.replace(/^\\/+/, ''), { create: true });\n if (!(resource instanceof File)) return null;\n await resource.saveContents(contents);\n return resource;\n}\n"],"mappings":";;AAGA,IAAM,2BAAW,IAAI,IAAI;CAAC;CAAM;CAAO;CAAO;CAAQ;CAAO;CAAO;CAAM;CAAQ;AAAK,CAAC;AAExF,eAAsB,kBAAkB,MAA+C;CACnF,MAAM,YAAY,iBAAiB,iBAAiB,KAAK,MAAM,iBAAiB,aAAa;CAC7F,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,WAAW,MAAM,UAAU,YAAY,KAAK,QAAQ,QAAQ,EAAE,CAAC;CACrE,IAAI,EAAE,oBAAoB,OAAO,OAAO;CACxC,MAAM,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,YAAY,KAAK;CACpD,IAAI,SAAS,IAAI,GAAG,KAAK,KAAK,SAAS,YAAY,GAAG;EAClD,MAAM,OAAO,MAAM,SAAS,YAAY;EACxC,OAAO,EAAE,MAAM,OAAO,SAAS,WAAW,OAAO,OAAO,QAAQ,EAAE,EAAE;CACxE;CACA,MAAM,OAAO,MAAM,SAAS,YAAY,EAAE,MAAM,KAAK,CAAC;CACtD,IAAI,gBAAgB,MAAM,OAAO,EAAE,OAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC,EAAE;CACnF,IAAI,gBAAgB,YAAY,OAAO,EAAE,OAAO,KAAK;CACrD,IAAI,OAAO,SAAS,UAAU,OAAO,EAAE,MAAM,KAAK;CAClD,OAAO;AACX;AAEA,eAAsB,mBAAmB,MAAc,UAAwC;CAC3F,MAAM,YAAY,iBAAiB,iBAAiB,KAAK,MAAM,iBAAiB,aAAa;CAC7F,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,WAAW,MAAM,UAAU,YAAY,KAAK,QAAQ,QAAQ,EAAE,GAAG,EAAE,QAAQ,KAAK,CAAC;CACvF,IAAI,EAAE,oBAAoB,OAAO,OAAO;CACxC,MAAM,SAAS,aAAa,QAAQ;CACpC,OAAO;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-docks/extension-canvas",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./contribution": {
|
|
14
|
+
"types": "./dist/contribution.d.ts",
|
|
15
|
+
"import": "./dist/contribution.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "vite build",
|
|
23
|
+
"test": "vitest run"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@eclipse-docks/core": "*",
|
|
27
|
+
"@eclipse-docks/extension-ai-system": "*",
|
|
28
|
+
"@eclipse-docks/extension-monaco-editor": "*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"jsdom": "^25.0.0",
|
|
32
|
+
"typescript": "^6.0.0",
|
|
33
|
+
"vite": "^8.0.0",
|
|
34
|
+
"vite-plugin-dts": "^4.5.4",
|
|
35
|
+
"vitest": "^4.1.4"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/eclipse-docks/core"
|
|
40
|
+
},
|
|
41
|
+
"license": "EPL-2.0",
|
|
42
|
+
"description": "Compile and open workspace canvas.js views, and list canvases registered by extensions"
|
|
43
|
+
}
|
package/README.md
DELETED