@eclipse-docks/extension-canvas 0.0.0-stage → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js +9 -0
  2. package/dist/active-canvas.d.ts +13 -0
  3. package/dist/active-canvas.d.ts.map +1 -0
  4. package/dist/active-canvas.js +23 -0
  5. package/dist/active-canvas.js.map +1 -0
  6. package/dist/bridges/core.d.ts +2 -0
  7. package/dist/bridges/core.d.ts.map +1 -0
  8. package/dist/bridges/core.js +9 -0
  9. package/dist/bridges/core.js.map +1 -0
  10. package/dist/bridges/events.d.ts +2 -0
  11. package/dist/bridges/events.d.ts.map +1 -0
  12. package/dist/bridges/events.js +9 -0
  13. package/dist/bridges/events.js.map +1 -0
  14. package/dist/bridges/lit.d.ts +2 -0
  15. package/dist/bridges/lit.d.ts.map +1 -0
  16. package/dist/bridges/lit.js +9 -0
  17. package/dist/bridges/lit.js.map +1 -0
  18. package/dist/bridges/parts.d.ts +2 -0
  19. package/dist/bridges/parts.d.ts.map +1 -0
  20. package/dist/bridges/parts.js +9 -0
  21. package/dist/bridges/parts.js.map +1 -0
  22. package/dist/bridges/register.d.ts +9 -0
  23. package/dist/bridges/register.d.ts.map +1 -0
  24. package/dist/bridges/register.js +13 -0
  25. package/dist/bridges/register.js.map +1 -0
  26. package/dist/bridges/third-party.d.ts +2 -0
  27. package/dist/bridges/third-party.d.ts.map +1 -0
  28. package/dist/bridges/third-party.js +9 -0
  29. package/dist/bridges/third-party.js.map +1 -0
  30. package/dist/bridges/urls.d.ts +3 -0
  31. package/dist/bridges/urls.d.ts.map +1 -0
  32. package/dist/bridges/urls.js +27 -0
  33. package/dist/bridges/urls.js.map +1 -0
  34. package/dist/bridges/webawesome.d.ts +2 -0
  35. package/dist/bridges/webawesome.d.ts.map +1 -0
  36. package/dist/bridges/webawesome.js +9 -0
  37. package/dist/bridges/webawesome.js.map +1 -0
  38. package/dist/bridges/widgets.d.ts +2 -0
  39. package/dist/bridges/widgets.d.ts.map +1 -0
  40. package/dist/bridges/widgets.js +9 -0
  41. package/dist/bridges/widgets.js.map +1 -0
  42. package/dist/canvas-editor.d.ts +61 -0
  43. package/dist/canvas-editor.d.ts.map +1 -0
  44. package/dist/canvas-editor.js +276 -0
  45. package/dist/canvas-editor.js.map +1 -0
  46. package/dist/canvas-extension.d.ts +1 -0
  47. package/dist/canvas-extension.d.ts.map +1 -0
  48. package/dist/canvas-extension.js +48 -0
  49. package/dist/canvas-extension.js.map +1 -0
  50. package/dist/canvas-switcher.d.ts +11 -0
  51. package/dist/canvas-switcher.d.ts.map +1 -0
  52. package/dist/canvas-switcher.js +59 -0
  53. package/dist/canvas-switcher.js.map +1 -0
  54. package/dist/canvas-tools.d.ts +4 -0
  55. package/dist/canvas-tools.d.ts.map +1 -0
  56. package/dist/canvas-tools.js +30 -0
  57. package/dist/canvas-tools.js.map +1 -0
  58. package/dist/canvases.d.ts +3 -0
  59. package/dist/canvases.d.ts.map +1 -0
  60. package/dist/canvases.js +10 -0
  61. package/dist/canvases.js.map +1 -0
  62. package/dist/commands.d.ts +9 -0
  63. package/dist/commands.d.ts.map +1 -0
  64. package/dist/commands.js +255 -0
  65. package/dist/commands.js.map +1 -0
  66. package/dist/compile.d.ts +31 -0
  67. package/dist/compile.d.ts.map +1 -0
  68. package/dist/compile.js +398 -0
  69. package/dist/compile.js.map +1 -0
  70. package/dist/contribution.d.ts +30 -0
  71. package/dist/contribution.d.ts.map +1 -0
  72. package/dist/contribution.js +10 -0
  73. package/dist/contribution.js.map +1 -0
  74. package/dist/help.d.ts +3 -0
  75. package/dist/help.d.ts.map +1 -0
  76. package/dist/help.js +19 -0
  77. package/dist/help.js.map +1 -0
  78. package/dist/host.d.ts +11 -0
  79. package/dist/host.d.ts.map +1 -0
  80. package/dist/host.js +63 -0
  81. package/dist/host.js.map +1 -0
  82. package/dist/i18n.de.js +11 -0
  83. package/dist/i18n.de.js.map +1 -0
  84. package/dist/i18n.en.js +11 -0
  85. package/dist/i18n.en.js.map +1 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +20 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/mount.d.ts +15 -0
  91. package/dist/mount.d.ts.map +1 -0
  92. package/dist/mount.js +81 -0
  93. package/dist/mount.js.map +1 -0
  94. package/dist/workspace-file.d.ts +5 -0
  95. package/dist/workspace-file.d.ts.map +1 -0
  96. package/dist/workspace-file.js +41 -0
  97. package/dist/workspace-file.js.map +1 -0
  98. package/package.json +41 -4
  99. package/README.md +0 -3
@@ -0,0 +1,398 @@
1
+ //#region src/compile.ts
2
+ var TEXT_EXT = /* @__PURE__ */ new Set([
3
+ "js",
4
+ "mjs",
5
+ "css",
6
+ "json",
7
+ "svg",
8
+ "txt",
9
+ "md",
10
+ "html",
11
+ "csv"
12
+ ]);
13
+ var MIME = {
14
+ png: "image/png",
15
+ jpg: "image/jpeg",
16
+ jpeg: "image/jpeg",
17
+ gif: "image/gif",
18
+ webp: "image/webp",
19
+ ico: "image/x-icon",
20
+ woff: "font/woff",
21
+ woff2: "font/woff2",
22
+ pdf: "application/pdf",
23
+ wasm: "application/wasm",
24
+ svg: "image/svg+xml"
25
+ };
26
+ function resolveWorkspacePath(fromFile, spec) {
27
+ const base = fromFile.split("/").filter(Boolean);
28
+ base.pop();
29
+ for (const part of spec.split("/")) {
30
+ if (part === "" || part === ".") continue;
31
+ if (part === "..") base.pop();
32
+ else base.push(part);
33
+ }
34
+ return base.join("/");
35
+ }
36
+ function isRelativeSpecifier(spec) {
37
+ return spec.startsWith("./") || spec.startsWith("../");
38
+ }
39
+ function bridgeRuntime(spec, bridges) {
40
+ if (spec === "docks/lit" || spec === "@eclipse-docks/core/externals/lit") return "__docksCanvas.lit";
41
+ if (spec === "docks/webawesome" || spec === "@eclipse-docks/core/externals/webawesome") return "__docksCanvas.webawesome";
42
+ if (spec === "docks/core" || spec === "@eclipse-docks/core") return "__docksCanvas.core";
43
+ const sub = coreSubpath(spec);
44
+ if (!sub || !bridges.coreSubpaths[sub]) return null;
45
+ return `__docksCanvas.subpaths[${JSON.stringify(sub)}]`;
46
+ }
47
+ function rewriteBridgeSpecifier(spec, bridges) {
48
+ if (spec === "docks/lit" || spec === "@eclipse-docks/core/externals/lit") return bridges.lit;
49
+ if (spec === "docks/webawesome" || spec === "@eclipse-docks/core/externals/webawesome") return bridges.webawesome;
50
+ if (spec === "docks/core" || spec === "@eclipse-docks/core") return bridges.core;
51
+ const sub = coreSubpath(spec);
52
+ if (!sub) return spec;
53
+ return bridges.coreSubpaths[sub] ?? spec;
54
+ }
55
+ function coreSubpath(spec) {
56
+ if (spec.startsWith("@eclipse-docks/core/")) return `./${spec.slice(20)}`;
57
+ if (spec.startsWith("docks/core/")) return `./${spec.slice(11)}`;
58
+ return null;
59
+ }
60
+ function extensionOf(path) {
61
+ const base = path.split("/").pop() ?? path;
62
+ const dot = base.lastIndexOf(".");
63
+ return dot >= 0 ? base.slice(dot + 1).toLowerCase() : "";
64
+ }
65
+ function isJavaScript(path) {
66
+ const ext = extensionOf(path);
67
+ return ext === "js" || ext === "mjs" || path.endsWith(".canvas.js");
68
+ }
69
+ function toBase64(bytes) {
70
+ const bufferCtor = globalThis.Buffer;
71
+ if (bufferCtor) return bufferCtor.from(bytes).toString("base64");
72
+ let binary = "";
73
+ for (const byte of bytes) binary += String.fromCharCode(byte);
74
+ return btoa(binary);
75
+ }
76
+ function findRefs(code) {
77
+ const patterns = [
78
+ {
79
+ form: "asset-url",
80
+ re: /new\s+URL\(\s*(['"])([^'"]+)\1\s*,\s*import\.meta\.url\s*\)/g
81
+ },
82
+ {
83
+ form: "dynamic",
84
+ re: /\bimport\(\s*(['"])([^'"]+)\1\s*\)/g
85
+ },
86
+ {
87
+ form: "export-from",
88
+ re: /\bexport\s+(?:type\s+)?(?:\*\s+as\s+\w+|\*|\{[^}]*\})\s+from\s*(['"])([^'"]+)\1/g
89
+ },
90
+ {
91
+ form: "import",
92
+ re: /\bimport\s+(?:type\s+)?(?:[^'";]*?\s+from\s+)?(['"])([^'"]+)\1/g
93
+ }
94
+ ];
95
+ const refs = [];
96
+ for (const { form, re } of patterns) for (const match of code.matchAll(re)) {
97
+ const spec = match[2];
98
+ if (!spec || match.index === void 0) continue;
99
+ refs.push({
100
+ spec,
101
+ start: match.index,
102
+ end: match.index + match[0].length,
103
+ raw: match[0],
104
+ form
105
+ });
106
+ }
107
+ refs.sort((a, b) => a.start - b.start || b.end - a.end);
108
+ const kept = [];
109
+ let cursor = -1;
110
+ for (const ref of refs) {
111
+ if (ref.start < cursor) continue;
112
+ kept.push(ref);
113
+ cursor = ref.end;
114
+ }
115
+ return kept;
116
+ }
117
+ function rewriteLocalExports(code) {
118
+ let out = code.replace(/export\s+default\s+/g, "__exports.default = ");
119
+ out = out.replace(/export\s+(async\s+)?function\s+(\w+)/g, (_all, asyncKw, name) => {
120
+ return `__exports.${name} = ${asyncKw ?? ""}function ${name}`;
121
+ });
122
+ out = out.replace(/export\s+class\s+(\w+)/g, "__exports.$1 = class $1");
123
+ out = out.replace(/export\s+(const|let|var)\s+(\w+)\s*=/g, "$1 $2 = __exports.$2 =");
124
+ out = out.replace(/export\s*\{([^}]+)\}\s*;?/g, (_all, inner) => {
125
+ return inner.split(",").map((part) => {
126
+ const [from, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
127
+ if (!from) return "";
128
+ return `__exports.${alias || from} = ${from};`;
129
+ }).join("\n");
130
+ });
131
+ return out;
132
+ }
133
+ function externalBinding(specUrl, imported, externals, seq) {
134
+ const existing = externals.find((item) => item.line.includes(JSON.stringify(specUrl)) && item.imported === imported);
135
+ if (existing) return existing.local;
136
+ const local = `__ext_${seq.n++}`;
137
+ if (imported === "*") externals.push({
138
+ local,
139
+ imported,
140
+ line: `import * as ${local} from ${JSON.stringify(specUrl)};`
141
+ });
142
+ else if (imported === "side") externals.push({
143
+ local,
144
+ imported,
145
+ line: `import ${JSON.stringify(specUrl)};`
146
+ });
147
+ else externals.push({
148
+ local,
149
+ imported,
150
+ line: `import { ${imported} as ${local} } from ${JSON.stringify(specUrl)};`
151
+ });
152
+ return local;
153
+ }
154
+ function importPrelude(raw, load) {
155
+ const clause = raw.replace(/\s+/g, " ").trim();
156
+ if (/^import\s+['"]/.test(clause)) return `await ${load};`;
157
+ const named = clause.match(/\{([^}]*)\}/);
158
+ const namespace = clause.match(/\*\s+as\s+(\w+)/);
159
+ const defaultName = clause.match(/^import\s+(?!type\b)(\w+)\s*(?:,|from)/);
160
+ const lines = [];
161
+ if (defaultName) lines.push(`const ${defaultName[1]} = (await ${load}).default;`);
162
+ if (namespace) lines.push(`const ${namespace[1]} = await ${load};`);
163
+ if (named) {
164
+ const pairs = named[1].split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
165
+ const [imported, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
166
+ return alias ? `${imported}: ${alias}` : imported;
167
+ });
168
+ if (pairs.length) lines.push(`const { ${pairs.join(", ")} } = await ${load};`);
169
+ }
170
+ return lines.join("\n");
171
+ }
172
+ function exportFromPrelude(raw, load) {
173
+ if (/\*\s+as\s+(\w+)/.test(raw)) {
174
+ const name = raw.match(/\*\s+as\s+(\w+)/)?.[1] ?? "ns";
175
+ return `const ${name} = await ${load};\nObject.assign(__exports, { ${name} });`;
176
+ }
177
+ if (raw.includes("*")) return `Object.assign(__exports, await ${load});\ndelete __exports.default;`;
178
+ return (raw.match(/\{([^}]*)\}/)?.[1] ?? "").split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
179
+ const [imported, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
180
+ return `__exports.${alias || imported} = (await ${load}).${imported};`;
181
+ }).join("\n");
182
+ }
183
+ async function compileCanvas(input) {
184
+ const modules = [];
185
+ const indexByPath = /* @__PURE__ */ new Map();
186
+ const stack = [];
187
+ const addModule = async (path, source) => {
188
+ const known = indexByPath.get(path);
189
+ if (known !== void 0) return known;
190
+ if (stack.includes(path)) return `Circular workspace import: ${[...stack, path].join(" -> ")}`;
191
+ stack.push(path);
192
+ const ext = extensionOf(path);
193
+ let mod;
194
+ if (source !== void 0) mod = {
195
+ path,
196
+ kind: "js",
197
+ text: source
198
+ };
199
+ else if (isJavaScript(path)) {
200
+ const file = await input.read(path);
201
+ if (!file?.text && file?.text !== "") return missing(path);
202
+ mod = {
203
+ path,
204
+ kind: "js",
205
+ text: file?.text ?? ""
206
+ };
207
+ } else if (ext === "json" || TEXT_EXT.has(ext)) {
208
+ const file = await input.read(path);
209
+ if (file?.text === void 0) return missing(path);
210
+ mod = {
211
+ path,
212
+ kind: ext === "json" ? "json" : "text",
213
+ text: file.text
214
+ };
215
+ } else {
216
+ const file = await input.read(path);
217
+ const bytes = file?.bytes ?? (file?.text !== void 0 ? new TextEncoder().encode(file.text) : void 0);
218
+ if (!bytes) return missing(path);
219
+ mod = {
220
+ path,
221
+ kind: "binary",
222
+ bytes,
223
+ mime: MIME[ext] ?? "application/octet-stream"
224
+ };
225
+ }
226
+ const id = modules.length;
227
+ modules.push(mod);
228
+ indexByPath.set(path, id);
229
+ if (mod.kind === "js" && mod.text !== void 0) for (const ref of findRefs(mod.text)) {
230
+ if (!isRelativeSpecifier(ref.spec)) continue;
231
+ const resolved = resolveWorkspacePath(path, ref.spec);
232
+ const child = await addModule(resolved);
233
+ if (typeof child === "string") return child;
234
+ }
235
+ stack.pop();
236
+ return id;
237
+ };
238
+ const missing = (path) => `Cannot find workspace file "${path}"`;
239
+ const entryId = await addModule(input.entryPath, input.entrySource);
240
+ if (typeof entryId === "string") return {
241
+ ok: false,
242
+ error: entryId
243
+ };
244
+ const externals = [];
245
+ const seq = { n: 0 };
246
+ const factories = [];
247
+ for (const mod of modules) {
248
+ if (mod.kind === "json") {
249
+ try {
250
+ const value = JSON.parse(mod.text ?? "");
251
+ factories.push(`async () => ({ default: ${JSON.stringify(value)} })`);
252
+ } catch (err) {
253
+ return {
254
+ ok: false,
255
+ error: `Invalid JSON in ${mod.path}: ${err instanceof Error ? err.message : String(err)}`
256
+ };
257
+ }
258
+ continue;
259
+ }
260
+ if (mod.kind === "text") {
261
+ const cssInject = extensionOf(mod.path) === "css" ? `const __css = ${JSON.stringify(mod.text ?? "")};
262
+ const __cssId = ${JSON.stringify(`docks-canvas-css-${mod.path}`)};
263
+ if (typeof document !== "undefined" && !document.getElementById(__cssId)) {
264
+ const __style = document.createElement("style");
265
+ __style.id = __cssId;
266
+ __style.textContent = __css;
267
+ document.head.append(__style);
268
+ }
269
+ return { default: __css };` : `return { default: ${JSON.stringify(mod.text ?? "")} };`;
270
+ factories.push(`async () => { ${cssInject} }`);
271
+ continue;
272
+ }
273
+ if (mod.kind === "binary") {
274
+ const href = `data:${mod.mime};base64,${toBase64(mod.bytes ?? /* @__PURE__ */ new Uint8Array())}`;
275
+ factories.push(`async () => ({ default: ${JSON.stringify(href)} })`);
276
+ continue;
277
+ }
278
+ const refs = findRefs(mod.text ?? "").sort((a, b) => b.start - a.start);
279
+ let body = mod.text ?? "";
280
+ const preludes = [];
281
+ for (const ref of refs) {
282
+ const resolvedUrl = rewriteBridgeSpecifier(ref.spec, input.bridges);
283
+ let replacement = "";
284
+ if (ref.form === "asset-url") {
285
+ if (!isRelativeSpecifier(ref.spec)) replacement = ref.raw;
286
+ else {
287
+ const assetPath = resolveWorkspacePath(mod.path, ref.spec);
288
+ const assetId = indexByPath.get(assetPath);
289
+ if (assetId === void 0) return {
290
+ ok: false,
291
+ error: missing(assetPath)
292
+ };
293
+ replacement = `(await __req(${assetId})).default`;
294
+ }
295
+ } else if (isRelativeSpecifier(ref.spec)) {
296
+ const depPath = resolveWorkspacePath(mod.path, ref.spec);
297
+ const depId = indexByPath.get(depPath);
298
+ if (depId === void 0) return {
299
+ ok: false,
300
+ error: missing(depPath)
301
+ };
302
+ const load = `__req(${depId})`;
303
+ if (ref.form === "dynamic") replacement = load;
304
+ else if (ref.form === "export-from") preludes.push(exportFromPrelude(ref.raw, load));
305
+ else preludes.push(importPrelude(ref.raw, load));
306
+ } else if (ref.form === "dynamic") {
307
+ const runtime = bridgeRuntime(ref.spec, input.bridges);
308
+ replacement = runtime ? `Promise.resolve(${runtime})` : `import(${JSON.stringify(resolvedUrl)})`;
309
+ if (runtime) externalBinding(resolvedUrl, "side", externals, seq);
310
+ } else {
311
+ const runtime = bridgeRuntime(ref.spec, input.bridges);
312
+ if (runtime) {
313
+ externalBinding(resolvedUrl, "side", externals, seq);
314
+ if (ref.form === "import" && !/^import\s+['"]/.test(ref.raw.trim())) preludes.push(runtimeImportPrelude(ref.raw, runtime));
315
+ else if (ref.form === "export-from") preludes.push(runtimeExportFromPrelude(ref.raw, runtime));
316
+ else if (ref.form === "import") preludes.push(`void ${runtime};`);
317
+ } else {
318
+ const localFor = (imported) => externalBinding(resolvedUrl, imported, externals, seq);
319
+ if (ref.form === "import" && /^import\s+['"]/.test(ref.raw.trim())) externalBinding(resolvedUrl, "side", externals, seq);
320
+ else if (ref.form === "import") preludes.push(externalImportPrelude(ref.raw, localFor));
321
+ else if (ref.form === "export-from") preludes.push(externalExportFromPrelude(ref.raw, localFor));
322
+ }
323
+ }
324
+ if (ref.form === "import" || ref.form === "export-from") replacement = "";
325
+ body = body.slice(0, ref.start) + replacement + body.slice(ref.end);
326
+ }
327
+ body = rewriteLocalExports(body);
328
+ factories.push(`async () => {
329
+ const __exports = {};
330
+ ${preludes.join("\n")}
331
+ ${body}
332
+ return __exports;
333
+ }`);
334
+ }
335
+ return {
336
+ ok: true,
337
+ code: `${[...new Set(externals.map((item) => item.line))].join("\n")}
338
+ const __factories = [
339
+ ${factories.join(",\n")}
340
+ ];
341
+ const __cache = new Map();
342
+ async function __req(id) {
343
+ if (__cache.has(id)) return __cache.get(id);
344
+ const pending = __factories[id]();
345
+ __cache.set(id, pending);
346
+ return pending;
347
+ }
348
+ const __entry = await __req(${entryId});
349
+ export default __entry.default;
350
+ `
351
+ };
352
+ }
353
+ function runtimeImportPrelude(raw, runtime) {
354
+ const clause = raw.replace(/\s+/g, " ").trim();
355
+ const lines = [];
356
+ const defaultName = clause.match(/^import\s+(?!type\b)(\w+)\s*(?:,|from)/);
357
+ const namespace = clause.match(/\*\s+as\s+(\w+)/);
358
+ const named = clause.match(/\{([^}]*)\}/);
359
+ if (defaultName) lines.push(`const ${defaultName[1]} = ${runtime}.default;`);
360
+ if (namespace) lines.push(`const ${namespace[1]} = ${runtime};`);
361
+ if (named) for (const part of named[1].split(",").map((piece) => piece.trim()).filter(Boolean)) {
362
+ const [imported, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
363
+ lines.push(`const ${alias || imported} = ${runtime}.${imported};`);
364
+ }
365
+ return lines.join("\n");
366
+ }
367
+ function runtimeExportFromPrelude(raw, runtime) {
368
+ if (raw.includes("*") && !raw.includes("{")) return `Object.assign(__exports, ${runtime});\ndelete __exports.default;`;
369
+ return (raw.match(/\{([^}]*)\}/)?.[1] ?? "").split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
370
+ const [imported, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
371
+ return `__exports.${alias || imported} = ${runtime}.${imported};`;
372
+ }).join("\n");
373
+ }
374
+ function externalImportPrelude(raw, localFor) {
375
+ const clause = raw.replace(/\s+/g, " ").trim();
376
+ const lines = [];
377
+ const defaultName = clause.match(/^import\s+(?!type\b)(\w+)\s*(?:,|from)/);
378
+ const namespace = clause.match(/\*\s+as\s+(\w+)/);
379
+ const named = clause.match(/\{([^}]*)\}/);
380
+ if (defaultName) lines.push(`const ${defaultName[1]} = ${localFor("default")};`);
381
+ if (namespace) lines.push(`const ${namespace[1]} = ${localFor("*")};`);
382
+ if (named) for (const part of named[1].split(",").map((piece) => piece.trim()).filter(Boolean)) {
383
+ const [imported, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
384
+ lines.push(`const ${alias || imported} = ${localFor(imported)};`);
385
+ }
386
+ return lines.join("\n");
387
+ }
388
+ function externalExportFromPrelude(raw, localFor) {
389
+ if (raw.includes("*") && !raw.includes("{")) return `Object.assign(__exports, ${localFor("*")});\ndelete __exports.default;`;
390
+ return (raw.match(/\{([^}]*)\}/)?.[1] ?? "").split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
391
+ const [imported, alias] = part.split(/\s+as\s+/).map((piece) => piece.trim());
392
+ return `__exports.${alias || imported} = ${localFor(imported)};`;
393
+ }).join("\n");
394
+ }
395
+ //#endregion
396
+ export { bridgeRuntime, compileCanvas, isRelativeSpecifier, resolveWorkspacePath, rewriteBridgeSpecifier };
397
+
398
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","names":[],"sources":["../src/compile.ts"],"sourcesContent":["export interface CanvasFileBytes {\n text?: string;\n bytes?: Uint8Array;\n}\n\nexport type CanvasFileReader = (path: string) => Promise<CanvasFileBytes | null>;\n\nexport interface CanvasBridges {\n lit: string;\n webawesome: string;\n core: string;\n /** Package export subpath (`./parts`) to a module URL. */\n coreSubpaths: Record<string, string>;\n}\n\nexport interface CompileCanvasInput {\n entryPath: string;\n entrySource: string;\n read: CanvasFileReader;\n bridges: CanvasBridges;\n}\n\nexport type CompileCanvasResult = { ok: true; code: string } | { ok: false; error: string };\n\ninterface GraphModule {\n path: string;\n kind: \"js\" | \"json\" | \"text\" | \"binary\";\n text?: string;\n bytes?: Uint8Array;\n mime?: string;\n}\n\ninterface SpecRef {\n spec: string;\n start: number;\n end: number;\n raw: string;\n form: \"import\" | \"export-from\" | \"dynamic\" | \"asset-url\";\n}\n\nconst TEXT_EXT = new Set([\"js\", \"mjs\", \"css\", \"json\", \"svg\", \"txt\", \"md\", \"html\", \"csv\"]);\nconst MIME: Record<string, string> = {\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n gif: \"image/gif\",\n webp: \"image/webp\",\n ico: \"image/x-icon\",\n woff: \"font/woff\",\n woff2: \"font/woff2\",\n pdf: \"application/pdf\",\n wasm: \"application/wasm\",\n svg: \"image/svg+xml\",\n};\n\nexport function resolveWorkspacePath(fromFile: string, spec: string): string {\n const base = fromFile.split(\"/\").filter(Boolean);\n base.pop();\n for (const part of spec.split(\"/\")) {\n if (part === \"\" || part === \".\") continue;\n if (part === \"..\") base.pop();\n else base.push(part);\n }\n return base.join(\"/\");\n}\n\nexport function isRelativeSpecifier(spec: string): boolean {\n return spec.startsWith(\"./\") || spec.startsWith(\"../\");\n}\n\nexport function bridgeRuntime(spec: string, bridges: CanvasBridges): string | null {\n if (spec === \"docks/lit\" || spec === \"@eclipse-docks/core/externals/lit\") return \"__docksCanvas.lit\";\n if (spec === \"docks/webawesome\" || spec === \"@eclipse-docks/core/externals/webawesome\") return \"__docksCanvas.webawesome\";\n if (spec === \"docks/core\" || spec === \"@eclipse-docks/core\") return \"__docksCanvas.core\";\n const sub = coreSubpath(spec);\n if (!sub || !bridges.coreSubpaths[sub]) return null;\n return `__docksCanvas.subpaths[${JSON.stringify(sub)}]`;\n}\n\nexport function rewriteBridgeSpecifier(spec: string, bridges: CanvasBridges): string {\n if (spec === \"docks/lit\" || spec === \"@eclipse-docks/core/externals/lit\") return bridges.lit;\n if (spec === \"docks/webawesome\" || spec === \"@eclipse-docks/core/externals/webawesome\") return bridges.webawesome;\n if (spec === \"docks/core\" || spec === \"@eclipse-docks/core\") return bridges.core;\n const sub = coreSubpath(spec);\n if (!sub) return spec;\n return bridges.coreSubpaths[sub] ?? spec;\n}\n\nfunction coreSubpath(spec: string): string | null {\n if (spec.startsWith(\"@eclipse-docks/core/\")) return `./${spec.slice(\"@eclipse-docks/core/\".length)}`;\n if (spec.startsWith(\"docks/core/\")) return `./${spec.slice(\"docks/core/\".length)}`;\n return null;\n}\n\nfunction extensionOf(path: string): string {\n const base = path.split(\"/\").pop() ?? path;\n const dot = base.lastIndexOf(\".\");\n return dot >= 0 ? base.slice(dot + 1).toLowerCase() : \"\";\n}\n\nfunction isJavaScript(path: string): boolean {\n const ext = extensionOf(path);\n return ext === \"js\" || ext === \"mjs\" || path.endsWith(\".canvas.js\");\n}\n\nfunction toBase64(bytes: Uint8Array): string {\n const bufferCtor = (globalThis as { Buffer?: { from(data: Uint8Array): { toString(encoding: string): string } } }).Buffer;\n if (bufferCtor) return bufferCtor.from(bytes).toString(\"base64\");\n let binary = \"\";\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary);\n}\n\nfunction findRefs(code: string): SpecRef[] {\n const patterns: Array<{ form: SpecRef[\"form\"]; re: RegExp }> = [\n { form: \"asset-url\", re: /new\\s+URL\\(\\s*(['\"])([^'\"]+)\\1\\s*,\\s*import\\.meta\\.url\\s*\\)/g },\n { form: \"dynamic\", re: /\\bimport\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g },\n { form: \"export-from\", re: /\\bexport\\s+(?:type\\s+)?(?:\\*\\s+as\\s+\\w+|\\*|\\{[^}]*\\})\\s+from\\s*(['\"])([^'\"]+)\\1/g },\n { form: \"import\", re: /\\bimport\\s+(?:type\\s+)?(?:[^'\";]*?\\s+from\\s+)?(['\"])([^'\"]+)\\1/g },\n ];\n const refs: SpecRef[] = [];\n for (const { form, re } of patterns) {\n for (const match of code.matchAll(re)) {\n const spec = match[2];\n if (!spec || match.index === undefined) continue;\n refs.push({\n spec,\n start: match.index,\n end: match.index + match[0].length,\n raw: match[0],\n form,\n });\n }\n }\n refs.sort((a, b) => a.start - b.start || b.end - a.end);\n const kept: SpecRef[] = [];\n let cursor = -1;\n for (const ref of refs) {\n if (ref.start < cursor) continue;\n kept.push(ref);\n cursor = ref.end;\n }\n return kept;\n}\n\nfunction rewriteLocalExports(code: string): string {\n let out = code.replace(/export\\s+default\\s+/g, \"__exports.default = \");\n out = out.replace(/export\\s+(async\\s+)?function\\s+(\\w+)/g, (_all, asyncKw: string | undefined, name: string) => {\n return `__exports.${name} = ${asyncKw ?? \"\"}function ${name}`;\n });\n out = out.replace(/export\\s+class\\s+(\\w+)/g, \"__exports.$1 = class $1\");\n out = out.replace(/export\\s+(const|let|var)\\s+(\\w+)\\s*=/g, \"$1 $2 = __exports.$2 =\");\n out = out.replace(/export\\s*\\{([^}]+)\\}\\s*;?/g, (_all, inner: string) => {\n return inner.split(\",\").map(part => {\n const [from, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n if (!from) return \"\";\n return `__exports.${alias || from} = ${from};`;\n }).join(\"\\n\");\n });\n return out;\n}\n\ninterface ExternalImport {\n line: string;\n local: string;\n imported: string;\n}\n\nfunction externalBinding(specUrl: string, imported: string, externals: ExternalImport[], seq: { n: number }): string {\n const existing = externals.find(item => item.line.includes(JSON.stringify(specUrl)) && item.imported === imported);\n if (existing) return existing.local;\n const local = `__ext_${seq.n++}`;\n if (imported === \"*\") {\n externals.push({ local, imported, line: `import * as ${local} from ${JSON.stringify(specUrl)};` });\n } else if (imported === \"side\") {\n externals.push({ local, imported, line: `import ${JSON.stringify(specUrl)};` });\n } else {\n externals.push({\n local,\n imported,\n line: `import { ${imported} as ${local} } from ${JSON.stringify(specUrl)};`,\n });\n }\n return local;\n}\n\nfunction importPrelude(raw: string, load: string): string {\n const clause = raw.replace(/\\s+/g, \" \").trim();\n if (/^import\\s+['\"]/.test(clause)) return `await ${load};`;\n const named = clause.match(/\\{([^}]*)\\}/);\n const namespace = clause.match(/\\*\\s+as\\s+(\\w+)/);\n const defaultName = clause.match(/^import\\s+(?!type\\b)(\\w+)\\s*(?:,|from)/);\n const lines: string[] = [];\n if (defaultName) lines.push(`const ${defaultName[1]} = (await ${load}).default;`);\n if (namespace) lines.push(`const ${namespace[1]} = await ${load};`);\n if (named) {\n const pairs = named[1].split(\",\").map(part => part.trim()).filter(Boolean).map(part => {\n const [imported, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n return alias ? `${imported}: ${alias}` : imported;\n });\n if (pairs.length) lines.push(`const { ${pairs.join(\", \")} } = await ${load};`);\n }\n return lines.join(\"\\n\");\n}\n\nfunction exportFromPrelude(raw: string, load: string): string {\n if (/\\*\\s+as\\s+(\\w+)/.test(raw)) {\n const name = raw.match(/\\*\\s+as\\s+(\\w+)/)?.[1] ?? \"ns\";\n return `const ${name} = await ${load};\\nObject.assign(__exports, { ${name} });`;\n }\n if (raw.includes(\"*\")) {\n return `Object.assign(__exports, await ${load});\\ndelete __exports.default;`;\n }\n const inner = raw.match(/\\{([^}]*)\\}/)?.[1] ?? \"\";\n const lines = inner.split(\",\").map(part => part.trim()).filter(Boolean).map(part => {\n const [imported, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n return `__exports.${alias || imported} = (await ${load}).${imported};`;\n });\n return lines.join(\"\\n\");\n}\n\nexport async function compileCanvas(input: CompileCanvasInput): Promise<CompileCanvasResult> {\n const modules: GraphModule[] = [];\n const indexByPath = new Map<string, number>();\n const stack: string[] = [];\n\n const addModule = async (path: string, source?: string): Promise<number | string> => {\n const known = indexByPath.get(path);\n if (known !== undefined) return known;\n if (stack.includes(path)) return `Circular workspace import: ${[...stack, path].join(\" -> \")}`;\n stack.push(path);\n const ext = extensionOf(path);\n let mod: GraphModule;\n if (source !== undefined) {\n mod = { path, kind: \"js\", text: source };\n } else if (isJavaScript(path)) {\n const file = await input.read(path);\n if (!file?.text && file?.text !== \"\") return missing(path);\n mod = { path, kind: \"js\", text: file?.text ?? \"\" };\n } else if (ext === \"json\" || TEXT_EXT.has(ext)) {\n const file = await input.read(path);\n if (file?.text === undefined) return missing(path);\n mod = { path, kind: ext === \"json\" ? \"json\" : \"text\", text: file.text };\n } else {\n const file = await input.read(path);\n const bytes = file?.bytes ?? (file?.text !== undefined ? new TextEncoder().encode(file.text) : undefined);\n if (!bytes) return missing(path);\n mod = { path, kind: \"binary\", bytes, mime: MIME[ext] ?? \"application/octet-stream\" };\n }\n const id = modules.length;\n modules.push(mod);\n indexByPath.set(path, id);\n if (mod.kind === \"js\" && mod.text !== undefined) {\n for (const ref of findRefs(mod.text)) {\n if (!isRelativeSpecifier(ref.spec)) continue;\n const resolved = resolveWorkspacePath(path, ref.spec);\n const child = await addModule(resolved);\n if (typeof child === \"string\") return child;\n }\n }\n stack.pop();\n return id;\n };\n\n const missing = (path: string) => `Cannot find workspace file \"${path}\"`;\n\n const entryId = await addModule(input.entryPath, input.entrySource);\n if (typeof entryId === \"string\") return { ok: false, error: entryId };\n\n const externals: ExternalImport[] = [];\n const seq = { n: 0 };\n const factories: string[] = [];\n\n for (const mod of modules) {\n if (mod.kind === \"json\") {\n try {\n const value = JSON.parse(mod.text ?? \"\");\n factories.push(`async () => ({ default: ${JSON.stringify(value)} })`);\n } catch (err) {\n return { ok: false, error: `Invalid JSON in ${mod.path}: ${err instanceof Error ? err.message : String(err)}` };\n }\n continue;\n }\n if (mod.kind === \"text\") {\n const cssInject = extensionOf(mod.path) === \"css\"\n ? `const __css = ${JSON.stringify(mod.text ?? \"\")};\nconst __cssId = ${JSON.stringify(`docks-canvas-css-${mod.path}`)};\nif (typeof document !== \"undefined\" && !document.getElementById(__cssId)) {\n const __style = document.createElement(\"style\");\n __style.id = __cssId;\n __style.textContent = __css;\n document.head.append(__style);\n}\nreturn { default: __css };`\n : `return { default: ${JSON.stringify(mod.text ?? \"\")} };`;\n factories.push(`async () => { ${cssInject} }`);\n continue;\n }\n if (mod.kind === \"binary\") {\n const href = `data:${mod.mime};base64,${toBase64(mod.bytes ?? new Uint8Array())}`;\n factories.push(`async () => ({ default: ${JSON.stringify(href)} })`);\n continue;\n }\n\n const refs = findRefs(mod.text ?? \"\").sort((a, b) => b.start - a.start);\n let body = mod.text ?? \"\";\n const preludes: string[] = [];\n for (const ref of refs) {\n const resolvedUrl = rewriteBridgeSpecifier(ref.spec, input.bridges);\n let replacement = \"\";\n if (ref.form === \"asset-url\") {\n if (!isRelativeSpecifier(ref.spec)) {\n replacement = ref.raw;\n } else {\n const assetPath = resolveWorkspacePath(mod.path, ref.spec);\n const assetId = indexByPath.get(assetPath);\n if (assetId === undefined) return { ok: false, error: missing(assetPath) };\n replacement = `(await __req(${assetId})).default`;\n }\n } else if (isRelativeSpecifier(ref.spec)) {\n const depPath = resolveWorkspacePath(mod.path, ref.spec);\n const depId = indexByPath.get(depPath);\n if (depId === undefined) return { ok: false, error: missing(depPath) };\n const load = `__req(${depId})`;\n if (ref.form === \"dynamic\") replacement = load;\n else if (ref.form === \"export-from\") preludes.push(exportFromPrelude(ref.raw, load));\n else preludes.push(importPrelude(ref.raw, load));\n } else if (ref.form === \"dynamic\") {\n const runtime = bridgeRuntime(ref.spec, input.bridges);\n replacement = runtime ? `Promise.resolve(${runtime})` : `import(${JSON.stringify(resolvedUrl)})`;\n if (runtime) externalBinding(resolvedUrl, \"side\", externals, seq);\n } else {\n const runtime = bridgeRuntime(ref.spec, input.bridges);\n if (runtime) {\n externalBinding(resolvedUrl, \"side\", externals, seq);\n if (ref.form === \"import\" && !/^import\\s+['\"]/.test(ref.raw.trim())) {\n preludes.push(runtimeImportPrelude(ref.raw, runtime));\n } else if (ref.form === \"export-from\") {\n preludes.push(runtimeExportFromPrelude(ref.raw, runtime));\n } else if (ref.form === \"import\") {\n preludes.push(`void ${runtime};`);\n }\n } else {\n const localFor = (imported: string) => externalBinding(resolvedUrl, imported, externals, seq);\n if (ref.form === \"import\" && /^import\\s+['\"]/.test(ref.raw.trim())) {\n externalBinding(resolvedUrl, \"side\", externals, seq);\n } else if (ref.form === \"import\") {\n preludes.push(externalImportPrelude(ref.raw, localFor));\n } else if (ref.form === \"export-from\") {\n preludes.push(externalExportFromPrelude(ref.raw, localFor));\n }\n }\n }\n if (ref.form === \"import\" || ref.form === \"export-from\") replacement = \"\";\n body = body.slice(0, ref.start) + replacement + body.slice(ref.end);\n }\n body = rewriteLocalExports(body);\n factories.push(`async () => {\n const __exports = {};\n ${preludes.join(\"\\n\")}\n ${body}\n return __exports;\n}`);\n }\n\n const uniqueLines = [...new Set(externals.map(item => item.line))];\n const code = `${uniqueLines.join(\"\\n\")}\nconst __factories = [\n${factories.join(\",\\n\")}\n];\nconst __cache = new Map();\nasync function __req(id) {\n if (__cache.has(id)) return __cache.get(id);\n const pending = __factories[id]();\n __cache.set(id, pending);\n return pending;\n}\nconst __entry = await __req(${entryId});\nexport default __entry.default;\n`;\n return { ok: true, code };\n}\n\nfunction runtimeImportPrelude(raw: string, runtime: string): string {\n const clause = raw.replace(/\\s+/g, \" \").trim();\n const lines: string[] = [];\n const defaultName = clause.match(/^import\\s+(?!type\\b)(\\w+)\\s*(?:,|from)/);\n const namespace = clause.match(/\\*\\s+as\\s+(\\w+)/);\n const named = clause.match(/\\{([^}]*)\\}/);\n if (defaultName) lines.push(`const ${defaultName[1]} = ${runtime}.default;`);\n if (namespace) lines.push(`const ${namespace[1]} = ${runtime};`);\n if (named) {\n for (const part of named[1].split(\",\").map(piece => piece.trim()).filter(Boolean)) {\n const [imported, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n lines.push(`const ${alias || imported} = ${runtime}.${imported};`);\n }\n }\n return lines.join(\"\\n\");\n}\n\nfunction runtimeExportFromPrelude(raw: string, runtime: string): string {\n if (raw.includes(\"*\") && !raw.includes(\"{\")) {\n return `Object.assign(__exports, ${runtime});\\ndelete __exports.default;`;\n }\n const inner = raw.match(/\\{([^}]*)\\}/)?.[1] ?? \"\";\n return inner.split(\",\").map(part => part.trim()).filter(Boolean).map(part => {\n const [imported, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n return `__exports.${alias || imported} = ${runtime}.${imported};`;\n }).join(\"\\n\");\n}\n\nfunction externalImportPrelude(raw: string, localFor: (imported: string) => string): string {\n const clause = raw.replace(/\\s+/g, \" \").trim();\n const lines: string[] = [];\n const defaultName = clause.match(/^import\\s+(?!type\\b)(\\w+)\\s*(?:,|from)/);\n const namespace = clause.match(/\\*\\s+as\\s+(\\w+)/);\n const named = clause.match(/\\{([^}]*)\\}/);\n if (defaultName) lines.push(`const ${defaultName[1]} = ${localFor(\"default\")};`);\n if (namespace) lines.push(`const ${namespace[1]} = ${localFor(\"*\")};`);\n if (named) {\n for (const part of named[1].split(\",\").map(piece => piece.trim()).filter(Boolean)) {\n const [imported, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n lines.push(`const ${alias || imported} = ${localFor(imported)};`);\n }\n }\n return lines.join(\"\\n\");\n}\n\nfunction externalExportFromPrelude(raw: string, localFor: (imported: string) => string): string {\n if (raw.includes(\"*\") && !raw.includes(\"{\")) {\n return `Object.assign(__exports, ${localFor(\"*\")});\\ndelete __exports.default;`;\n }\n const inner = raw.match(/\\{([^}]*)\\}/)?.[1] ?? \"\";\n return inner.split(\",\").map(part => part.trim()).filter(Boolean).map(part => {\n const [imported, alias] = part.split(/\\s+as\\s+/).map(piece => piece.trim());\n return `__exports.${alias || imported} = ${localFor(imported)};`;\n }).join(\"\\n\");\n}\n"],"mappings":";AAwCA,IAAM,2BAAW,IAAI,IAAI;CAAC;CAAM;CAAO;CAAO;CAAQ;CAAO;CAAO;CAAM;CAAQ;AAAK,CAAC;AACxF,IAAM,OAA+B;CACjC,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,OAAO;CACP,KAAK;CACL,MAAM;CACN,KAAK;AACT;AAEA,SAAgB,qBAAqB,UAAkB,MAAsB;CACzE,MAAM,OAAO,SAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC/C,KAAK,IAAI;CACT,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;EAChC,IAAI,SAAS,MAAM,SAAS,KAAK;EACjC,IAAI,SAAS,MAAM,KAAK,IAAI;OACvB,KAAK,KAAK,IAAI;CACvB;CACA,OAAO,KAAK,KAAK,GAAG;AACxB;AAEA,SAAgB,oBAAoB,MAAuB;CACvD,OAAO,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;AACzD;AAEA,SAAgB,cAAc,MAAc,SAAuC;CAC/E,IAAI,SAAS,eAAe,SAAS,qCAAqC,OAAO;CACjF,IAAI,SAAS,sBAAsB,SAAS,4CAA4C,OAAO;CAC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AE;CACrE,IAAI,OACA,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,KAAI,UAAS,MAAM,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,GAAG;EAC/E,MAAM,CAAC,UAAU,SAAS,KAAK,MAAM,UAAU,CAAC,CAAC,KAAI,UAAS,MAAM,KAAK,CAAC;EAC1E,MAAM,KAAK,SAAS,SAAS,SAAS,KAAK,SAAS,QAAQ,EAAE,EAAE;CACpE;CAEJ,OAAO,MAAM,KAAK,IAAI;AAC1B;AAEA,SAAS,0BAA0B,KAAa,UAAgD;CAC5F,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC,IAAI,SAAS,GAAG,GACtC,OAAO,4BAA4B,SAAS,GAAG,EAAE;CAGrD,QADc,IAAI,MAAM,aAAa,CAAC,GAAG,MAAM,GAAA,CAClC,MAAM,GAAG,CAAC,CAAC,KAAI,SAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAI,SAAQ;EACzE,MAAM,CAAC,UAAU,SAAS,KAAK,MAAM,UAAU,CAAC,CAAC,KAAI,UAAS,MAAM,KAAK,CAAC;EAC1E,OAAO,aAAa,SAAS,SAAS,KAAK,SAAS,QAAQ,EAAE;CAClE,CAAC,CAAC,CAAC,KAAK,IAAI;AAChB"}
@@ -0,0 +1,30 @@
1
+ import { Contribution, TabContribution } from '@eclipse-docks/core';
2
+ /** Slot for canvases an extension contributes. The toolbar dropdown lists it; it is not a tab group. */
3
+ export declare const SYSTEM_CANVASES = "system.canvases";
4
+ export interface CanvasToolContribution {
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ parameters?: Array<{
9
+ name: string;
10
+ description: string;
11
+ type?: string;
12
+ required: boolean;
13
+ allowedValues?: string[];
14
+ }>;
15
+ execute: (context: {
16
+ params?: Record<string, unknown>;
17
+ }) => unknown | Promise<unknown>;
18
+ }
19
+ /** A canvas module registered on {@link SYSTEM_CANVASES} and opened from the toolbar dropdown. */
20
+ export interface CanvasContribution extends TabContribution {
21
+ /** Module whose default export is an HTMLElement subclass. */
22
+ load: () => Promise<{
23
+ default: CustomElementConstructor;
24
+ }>;
25
+ /** When set, the editor can toggle between preview and source and counts as an editor. */
26
+ source?: string | (() => Promise<string>);
27
+ tools?: CanvasToolContribution[];
28
+ }
29
+ export declare function isCanvasContribution(contribution: Contribution): contribution is CanvasContribution;
30
+ //# sourceMappingURL=contribution.d.ts.map
@@ -0,0 +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,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,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,8DAA8D;IAC9D,IAAI,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,wBAAwB,CAAA;KAAE,CAAC,CAAC;IAC3D,0FAA0F;IAC1F,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,CAEnG"}
@@ -0,0 +1,10 @@
1
+ //#region src/contribution.ts
2
+ /** Slot for canvases an extension contributes. The toolbar dropdown lists it; it is not a tab group. */
3
+ var SYSTEM_CANVASES = "system.canvases";
4
+ function isCanvasContribution(contribution) {
5
+ return typeof contribution.load === "function";
6
+ }
7
+ //#endregion
8
+ export { SYSTEM_CANVASES, isCanvasContribution };
9
+
10
+ //# sourceMappingURL=contribution.js.map
@@ -0,0 +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"}
package/dist/help.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const CANVAS_HELP = "A canvas is a workspace file ending in .canvas.js. Extend LitElement, not HTMLElement:\n\nimport { LitElement, html } from \"docks/lit\";\nimport \"docks/webawesome\";\nexport default class extends LitElement {\n render() { return html`<wa-button>Ready</wa-button>`; }\n}\n\nThe host defines the custom element. Do not call customElements.define. Set state with this.canvasHost.getState(key, fallback) and this.canvasHost.setState(key, value). Open a workspace file with this.canvasHost.openFile(path).\n\nImports are not filtered. docks/lit, docks/webawesome, and docks/core are the running app (Lit, Web Awesome, and @eclipse-docks/core). Relative imports are workspace files. Compiling inlines those files: JSON becomes its value, text and CSS become strings, and other binaries become data URLs.\n\nWrite the file with the workspace tools, then call canvas.open with its path. canvas.apply_source updates the open canvas and returns ready or the compile error. Extension canvases are registered with contributionRegistry.registerContribution(SYSTEM_CANVASES, contribution). Import SYSTEM_CANVASES and CanvasContribution from @eclipse-docks/extension-canvas/contribution. They are opened by name from canvas.open or the toolbar dropdown.";
2
+ export declare const CANVAS_SKILL = "For a durable interactive view, write a workspace file ending in .canvas.js whose default export extends LitElement from \"docks/lit\". Do not extend HTMLElement. Call canvas.open, and call canvas.help for the module contract. Extension canvases registered on system.canvases open by name.";
3
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,8tCAY8Z,CAAC;AAEvb,eAAO,MAAM,YAAY,sSAAoS,CAAC"}
package/dist/help.js ADDED
@@ -0,0 +1,19 @@
1
+ //#region src/help.ts
2
+ var CANVAS_HELP = `A canvas is a workspace file ending in .canvas.js. Extend LitElement, not HTMLElement:
3
+
4
+ import { LitElement, html } from "docks/lit";
5
+ import "docks/webawesome";
6
+ export default class extends LitElement {
7
+ render() { return html\`<wa-button>Ready</wa-button>\`; }
8
+ }
9
+
10
+ The host defines the custom element. Do not call customElements.define. Set state with this.canvasHost.getState(key, fallback) and this.canvasHost.setState(key, value). Open a workspace file with this.canvasHost.openFile(path).
11
+
12
+ Imports are not filtered. docks/lit, docks/webawesome, and docks/core are the running app (Lit, Web Awesome, and @eclipse-docks/core). Relative imports are workspace files. Compiling inlines those files: JSON becomes its value, text and CSS become strings, and other binaries become data URLs.
13
+
14
+ Write the file with the workspace tools, then call canvas.open with its path. canvas.apply_source updates the open canvas and returns ready or the compile error. Extension canvases are registered with contributionRegistry.registerContribution(SYSTEM_CANVASES, contribution). Import SYSTEM_CANVASES and CanvasContribution from @eclipse-docks/extension-canvas/contribution. They are opened by name from canvas.open or the toolbar dropdown.`;
15
+ var CANVAS_SKILL = `For a durable interactive view, write a workspace file ending in .canvas.js whose default export extends LitElement from "docks/lit". Do not extend HTMLElement. Call canvas.open, and call canvas.help for the module contract. Extension canvases registered on system.canvases open by name.`;
16
+ //#endregion
17
+ export { CANVAS_HELP, CANVAS_SKILL };
18
+
19
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","names":[],"sources":["../src/help.ts"],"sourcesContent":["export const CANVAS_HELP = `A canvas is a workspace file ending in .canvas.js. Extend LitElement, not HTMLElement:\n\nimport { LitElement, html } from \"docks/lit\";\nimport \"docks/webawesome\";\nexport default class extends LitElement {\n render() { return html\\`<wa-button>Ready</wa-button>\\`; }\n}\n\nThe host defines the custom element. Do not call customElements.define. Set state with this.canvasHost.getState(key, fallback) and this.canvasHost.setState(key, value). Open a workspace file with this.canvasHost.openFile(path).\n\nImports are not filtered. docks/lit, docks/webawesome, and docks/core are the running app (Lit, Web Awesome, and @eclipse-docks/core). Relative imports are workspace files. Compiling inlines those files: JSON becomes its value, text and CSS become strings, and other binaries become data URLs.\n\nWrite the file with the workspace tools, then call canvas.open with its path. canvas.apply_source updates the open canvas and returns ready or the compile error. Extension canvases are registered with contributionRegistry.registerContribution(SYSTEM_CANVASES, contribution). Import SYSTEM_CANVASES and CanvasContribution from @eclipse-docks/extension-canvas/contribution. They are opened by name from canvas.open or the toolbar dropdown.`;\n\nexport const CANVAS_SKILL = `For a durable interactive view, write a workspace file ending in .canvas.js whose default export extends LitElement from \"docks/lit\". Do not extend HTMLElement. Call canvas.open, and call canvas.help for the module contract. Extension canvases registered on system.canvases open by name.`;\n"],"mappings":";AAAA,IAAa,cAAc;;;;;;;;;;;;;AAc3B,IAAa,eAAe"}
package/dist/host.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { File } from '@eclipse-docks/core';
2
+ import { CanvasContribution } from './contribution';
3
+ export interface CanvasHost {
4
+ getState(key: string, fallback?: unknown): unknown;
5
+ setState(key: string, value: unknown): void;
6
+ openFile(path: string): void;
7
+ }
8
+ export declare function createMemoryHost(initial: Record<string, unknown>, persist: (state: Record<string, unknown>) => void): CanvasHost;
9
+ export declare function createFileHost(file: File): Promise<CanvasHost>;
10
+ export declare function createContributionHost(contribution: CanvasContribution): Promise<CanvasHost>;
11
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,IAAI,EAAoB,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,UAAU,CAchI;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAKpE;AAED,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAOlG"}
package/dist/host.js ADDED
@@ -0,0 +1,63 @@
1
+ import { File, appSettings, editorRegistry, workspaceService } from "@eclipse-docks/core";
2
+ //#region src/host.ts
3
+ function createMemoryHost(initial, persist) {
4
+ const state = { ...initial };
5
+ return {
6
+ getState(key, fallback) {
7
+ return state[key] === void 0 ? fallback : state[key];
8
+ },
9
+ setState(key, value) {
10
+ state[key] = value;
11
+ persist(state);
12
+ },
13
+ openFile(path) {
14
+ openWorkspaceFile(path);
15
+ }
16
+ };
17
+ }
18
+ async function createFileHost(file) {
19
+ return createMemoryHost(await readSidecar(file), (state) => {
20
+ writeSidecar(file, state);
21
+ });
22
+ }
23
+ async function createContributionHost(contribution) {
24
+ const key = `canvas.${contribution.name}`;
25
+ const stored = await appSettings.get(key);
26
+ return createMemoryHost(stored && typeof stored === "object" ? stored : {}, (state) => {
27
+ appSettings.set(key, state);
28
+ });
29
+ }
30
+ function sidecarName(fileName) {
31
+ return fileName.replace(/\.canvas\.js$/i, ".canvas.data.json");
32
+ }
33
+ async function readSidecar(file) {
34
+ const parent = file.getParent();
35
+ if (!parent) return {};
36
+ const resource = await parent.getResource(sidecarName(file.getName()));
37
+ if (!(resource instanceof File)) return {};
38
+ try {
39
+ const parsed = JSON.parse(await resource.getContents());
40
+ return parsed && typeof parsed === "object" ? parsed : {};
41
+ } catch {
42
+ return {};
43
+ }
44
+ }
45
+ async function writeSidecar(file, state) {
46
+ const parent = file.getParent();
47
+ if (!parent) return;
48
+ const name = sidecarName(file.getName());
49
+ let resource = await parent.getResource(name);
50
+ if (!(resource instanceof File)) resource = await parent.getResource(name, { create: true });
51
+ if (!(resource instanceof File)) return;
52
+ await resource.saveContents(JSON.stringify(state));
53
+ }
54
+ async function openWorkspaceFile(path) {
55
+ const workspace = workspaceService.getWorkspaceSync() ?? await workspaceService.getWorkspace();
56
+ if (!workspace) return;
57
+ const resource = await workspace.getResource(path.replace(/^\/+/, ""));
58
+ if (resource instanceof File) await editorRegistry.loadEditor(resource);
59
+ }
60
+ //#endregion
61
+ export { createContributionHost, createFileHost, createMemoryHost };
62
+
63
+ //# sourceMappingURL=host.js.map
@@ -0,0 +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;CACz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