@eclipse-docks/extension-catalog 0.7.68
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/api.d.ts +3 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +42 -0
- package/dist/api.js.map +1 -0
- package/dist/docks-catalog.d.ts +29 -0
- package/dist/docks-catalog.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +1 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +153 -0
- package/dist/loader.js.map +1 -0
- package/dist/register-catalog.d.ts +12 -0
- package/dist/register-catalog.d.ts.map +1 -0
- package/package.json +40 -0
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,eAAe,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { contributionRegistry } from "@eclipse-docks/core";
|
|
2
|
+
//#region src/register-catalog.ts
|
|
3
|
+
function getCatalogBaseUrl() {
|
|
4
|
+
if (typeof globalThis === "undefined") return "";
|
|
5
|
+
const loc = globalThis.location;
|
|
6
|
+
const base = "/";
|
|
7
|
+
if (!loc?.origin) return "";
|
|
8
|
+
return (loc.origin + base).replace(/\/?$/, "/");
|
|
9
|
+
}
|
|
10
|
+
function registerCatalog(catalog, baseUrl) {
|
|
11
|
+
const base = baseUrl ?? getCatalogBaseUrl();
|
|
12
|
+
contributionRegistry.registerContribution("catalog.root", {
|
|
13
|
+
label: catalog.label,
|
|
14
|
+
icon: catalog.icon,
|
|
15
|
+
contributionId: catalog.contributionId
|
|
16
|
+
});
|
|
17
|
+
const contributionId = catalog.contributionId ?? catalog.label;
|
|
18
|
+
catalog.items?.forEach((item) => {
|
|
19
|
+
contributionRegistry.registerContribution(contributionId, {
|
|
20
|
+
label: item.label,
|
|
21
|
+
icon: item.icon,
|
|
22
|
+
contributionId: item.contributionId
|
|
23
|
+
});
|
|
24
|
+
item.items?.forEach((child) => {
|
|
25
|
+
const contribution = {
|
|
26
|
+
label: child.label,
|
|
27
|
+
icon: child.icon,
|
|
28
|
+
state: { ...child.state }
|
|
29
|
+
};
|
|
30
|
+
const url = contribution.state?.url;
|
|
31
|
+
if (url && typeof url === "string" && url.includes("${baseURL}/")) contribution.state = {
|
|
32
|
+
...contribution.state,
|
|
33
|
+
url: url.replace("${baseURL}/", base)
|
|
34
|
+
};
|
|
35
|
+
contributionRegistry.registerContribution(item.contributionId, contribution);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { getCatalogBaseUrl, registerCatalog };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../src/register-catalog.ts"],"sourcesContent":["import {\n contributionRegistry,\n type TreeContribution,\n} from \"@eclipse-docks/core\";\n\n/** Leaf item state: optional filename when URL is not path-shaped (e.g. data: in production bundles). */\nexport type CatalogResourceState = {\n url: string;\n filename?: string;\n};\n\nexport interface CatalogContribution extends TreeContribution {\n items?: CatalogContribution[];\n}\n\nexport function getCatalogBaseUrl(): string {\n if (typeof globalThis === 'undefined') return '';\n const loc = (globalThis as unknown as { location?: { origin: string } }).location;\n const base = (import.meta as unknown as { env?: { BASE_URL?: string } }).env?.BASE_URL ?? '';\n if (!loc?.origin) return '';\n return (loc.origin + base).replace(/\\/?$/, '/');\n}\n\nexport function registerCatalog(catalog: CatalogContribution, baseUrl?: string): void {\n const base = baseUrl ?? getCatalogBaseUrl();\n contributionRegistry.registerContribution(\"catalog.root\", {\n label: catalog.label,\n icon: catalog.icon,\n contributionId: catalog.contributionId,\n } as TreeContribution);\n\n const contributionId = catalog.contributionId ?? catalog.label;\n catalog.items?.forEach((item: CatalogContribution) => {\n contributionRegistry.registerContribution(contributionId, {\n label: item.label,\n icon: item.icon,\n contributionId: item.contributionId,\n } as TreeContribution);\n\n item.items?.forEach((child: any) => {\n const contribution = {\n label: child.label,\n icon: child.icon,\n state: { ...child.state },\n } as TreeContribution;\n const url = contribution.state?.url as string | undefined;\n if (url && typeof url === \"string\" && url.includes(\"${baseURL}/\")) {\n contribution.state = { ...contribution.state, url: url.replace(\"${baseURL}/\", base) };\n }\n contributionRegistry.registerContribution(\n item.contributionId!,\n contribution\n );\n });\n });\n}\n"],"mappings":";;AAeA,SAAgB,oBAA4B;AACxC,KAAI,OAAO,eAAe,YAAa,QAAO;CAC9C,MAAM,MAAO,WAA4D;CACzE,MAAM,OAAA;AACN,KAAI,CAAC,KAAK,OAAQ,QAAO;AACzB,SAAQ,IAAI,SAAS,MAAM,QAAQ,QAAQ,IAAI;;AAGnD,SAAgB,gBAAgB,SAA8B,SAAwB;CAClF,MAAM,OAAO,WAAW,mBAAmB;AAC3C,sBAAqB,qBAAqB,gBAAgB;EACtD,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,gBAAgB,QAAQ;EAC3B,CAAqB;CAEtB,MAAM,iBAAiB,QAAQ,kBAAkB,QAAQ;AACzD,SAAQ,OAAO,SAAS,SAA8B;AAClD,uBAAqB,qBAAqB,gBAAgB;GACtD,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,gBAAgB,KAAK;GACxB,CAAqB;AAEtB,OAAK,OAAO,SAAS,UAAe;GAChC,MAAM,eAAe;IACjB,OAAO,MAAM;IACb,MAAM,MAAM;IACZ,OAAO,EAAE,GAAG,MAAM,OAAO;IAC5B;GACD,MAAM,MAAM,aAAa,OAAO;AAChC,OAAI,OAAO,OAAO,QAAQ,YAAY,IAAI,SAAS,cAAc,CAC7D,cAAa,QAAQ;IAAE,GAAG,aAAa;IAAO,KAAK,IAAI,QAAQ,eAAe,KAAK;IAAE;AAEzF,wBAAqB,qBACjB,KAAK,gBACL,aACH;IACH;GACJ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TemplateResult } from '@eclipse-docks/core/externals/lit';
|
|
2
|
+
import { DocksPart, TreeNode } from '@eclipse-docks/core';
|
|
3
|
+
export declare const CID_CATALOG_ROOT = "catalog.root";
|
|
4
|
+
export declare class DocksCatalog extends DocksPart {
|
|
5
|
+
private rootNodes?;
|
|
6
|
+
private treeRef;
|
|
7
|
+
private contributionsSubscriptionToken?;
|
|
8
|
+
protected doBeforeUI(): void;
|
|
9
|
+
protected doClose(): void;
|
|
10
|
+
private rebuildTree;
|
|
11
|
+
protected renderToolbar(): TemplateResult<1>;
|
|
12
|
+
private toTreeNodes;
|
|
13
|
+
private wgetParamsFromCatalogData;
|
|
14
|
+
onItemDblClicked(event: Event): void;
|
|
15
|
+
private runWgetForSelection;
|
|
16
|
+
onSelectionChanged(event: Event): void;
|
|
17
|
+
protected renderContextMenu(): TemplateResult<1>;
|
|
18
|
+
setAllExpanded(expanded: boolean): void;
|
|
19
|
+
refresh(): void;
|
|
20
|
+
createTreeItems(node: TreeNode, expanded?: boolean): TemplateResult;
|
|
21
|
+
protected renderContent(): TemplateResult<1>;
|
|
22
|
+
static styles: import('lit').CSSResult;
|
|
23
|
+
}
|
|
24
|
+
declare global {
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
"docks-catalog": DocksCatalog;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=docks-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docks-catalog.d.ts","sourceRoot":"","sources":["../src/docks-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,cAAc,EAKjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,SAAS,EAET,QAAQ,EASX,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,qBACa,YAAa,SAAQ,SAAS;IAEvC,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,8BAA8B,CAAC,CAAS;IAEhD,SAAS,CAAC,UAAU;IASpB,SAAS,CAAC,OAAO;IAQjB,OAAO,CAAC,WAAW;IAQnB,SAAS,CAAC,aAAa;IAkBvB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,yBAAyB;IASjC,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAc7B,OAAO,CAAC,mBAAmB;IAQ3B,kBAAkB,CAAC,KAAK,EAAE,KAAK;IAM/B,SAAS,CAAC,iBAAiB;IAapB,cAAc,CAAC,QAAQ,EAAE,OAAO;IAShC,OAAO;IAId,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,UAAQ,GAAG,cAAc;IAgBjE,SAAS,CAAC,aAAa;IAcvB,MAAM,CAAC,MAAM,0BAKX;CACL;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,eAAe,EAAE,YAAY,CAAC;KACjC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { extensionRegistry } from "@eclipse-docks/core";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
extensionRegistry.registerExtension({
|
|
4
|
+
id: "@eclipse-docks/extension-catalog",
|
|
5
|
+
name: "Catalog",
|
|
6
|
+
description: "Browse and checkout resources from a catalog",
|
|
7
|
+
loader: () => import("./loader.js"),
|
|
8
|
+
icon: "book"
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { extensionRegistry } from \"@eclipse-docks/core\";\n\nextensionRegistry.registerExtension({\n id: \"@eclipse-docks/extension-catalog\",\n name: \"Catalog\",\n description: \"Browse and checkout resources from a catalog\",\n loader: () => import(\"./loader\"),\n icon: \"book\",\n});\n"],"mappings":";;AAEA,kBAAkB,kBAAkB;CAChC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc,OAAO;CACrB,MAAM;CACT,CAAC"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAC"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { DocksPart, SIDEBAR_MAIN, TOPIC_CONTRIBUTEIONS_CHANGED, activePartSignal, activeSelectionSignal, contributionRegistry, icon, subscribe, unsubscribe } from "@eclipse-docks/core";
|
|
2
|
+
import { createRef, css, customElement, html, ref, state } from "@eclipse-docks/core/externals/lit";
|
|
3
|
+
import _decorate from "@oxc-project/runtime/helpers/decorate";
|
|
4
|
+
//#region src/docks-catalog.ts
|
|
5
|
+
var _DocksCatalog;
|
|
6
|
+
var CID_CATALOG_ROOT = "catalog.root";
|
|
7
|
+
var DocksCatalog = class DocksCatalog extends DocksPart {
|
|
8
|
+
static {
|
|
9
|
+
_DocksCatalog = this;
|
|
10
|
+
}
|
|
11
|
+
constructor(..._args) {
|
|
12
|
+
super(..._args);
|
|
13
|
+
this.treeRef = createRef();
|
|
14
|
+
}
|
|
15
|
+
doBeforeUI() {
|
|
16
|
+
this.rebuildTree();
|
|
17
|
+
this.contributionsSubscriptionToken = subscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event) => {
|
|
18
|
+
if (event.target === "catalog.root" || event.target?.startsWith("catalog.")) this.rebuildTree();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
doClose() {
|
|
22
|
+
if (this.contributionsSubscriptionToken) {
|
|
23
|
+
unsubscribe(this.contributionsSubscriptionToken);
|
|
24
|
+
this.contributionsSubscriptionToken = void 0;
|
|
25
|
+
}
|
|
26
|
+
super.doClose();
|
|
27
|
+
}
|
|
28
|
+
rebuildTree() {
|
|
29
|
+
const contributions = contributionRegistry.getContributions(CID_CATALOG_ROOT);
|
|
30
|
+
this.rootNodes = this.toTreeNodes(contributions);
|
|
31
|
+
this.requestUpdate();
|
|
32
|
+
}
|
|
33
|
+
renderToolbar() {
|
|
34
|
+
return html`
|
|
35
|
+
<docks-command
|
|
36
|
+
icon="file-arrow-down"
|
|
37
|
+
title="Checkout"
|
|
38
|
+
?disabled=${!(activePartSignal.get() instanceof _DocksCatalog && activeSelectionSignal.get() !== void 0)}
|
|
39
|
+
.action=${() => this.runWgetForSelection()}
|
|
40
|
+
></docks-command>
|
|
41
|
+
<docks-command icon="arrows-rotate" title="Refresh Catalog" .action=${() => this.refresh()}></docks-command>
|
|
42
|
+
<docks-command icon="angles-down" slot="end" title="Expand All" .action=${() => this.setAllExpanded(true)}></docks-command>
|
|
43
|
+
<docks-command icon="angles-up" slot="end" title="Collapse All" .action=${() => this.setAllExpanded(false)}></docks-command>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
toTreeNodes(contributions) {
|
|
47
|
+
return contributions.map((c) => {
|
|
48
|
+
const node = {
|
|
49
|
+
data: c.state,
|
|
50
|
+
icon: c.icon,
|
|
51
|
+
label: c.label,
|
|
52
|
+
leaf: false
|
|
53
|
+
};
|
|
54
|
+
if (c.contributionId) {
|
|
55
|
+
const children = contributionRegistry.getContributions(c.contributionId);
|
|
56
|
+
node.leaf = children.length === 0;
|
|
57
|
+
node.children = this.toTreeNodes(children);
|
|
58
|
+
}
|
|
59
|
+
return node;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
wgetParamsFromCatalogData(data) {
|
|
63
|
+
if (!data?.url) return null;
|
|
64
|
+
const params = { url: data.url };
|
|
65
|
+
if (typeof data.filename === "string" && data.filename.trim()) params.filename = data.filename.trim();
|
|
66
|
+
return params;
|
|
67
|
+
}
|
|
68
|
+
onItemDblClicked(event) {
|
|
69
|
+
const item = event.currentTarget;
|
|
70
|
+
const node = item?.model;
|
|
71
|
+
if (!node) return;
|
|
72
|
+
const wgetParams = this.wgetParamsFromCatalogData(node.data);
|
|
73
|
+
if (wgetParams) {
|
|
74
|
+
this.executeCommand("wget", wgetParams);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!node.leaf && "expanded" in item) item.expanded = !item.expanded;
|
|
78
|
+
}
|
|
79
|
+
runWgetForSelection() {
|
|
80
|
+
const item = activeSelectionSignal.get();
|
|
81
|
+
const wgetParams = item && this.wgetParamsFromCatalogData(item);
|
|
82
|
+
if (wgetParams) this.executeCommand("wget", wgetParams);
|
|
83
|
+
}
|
|
84
|
+
onSelectionChanged(event) {
|
|
85
|
+
const node = event.detail.selection[0].model;
|
|
86
|
+
activeSelectionSignal.set(node.data);
|
|
87
|
+
}
|
|
88
|
+
renderContextMenu() {
|
|
89
|
+
const item = activePartSignal.get() instanceof _DocksCatalog ? activeSelectionSignal.get() : void 0;
|
|
90
|
+
return html`
|
|
91
|
+
<docks-command
|
|
92
|
+
icon="file-arrow-down"
|
|
93
|
+
title="Checkout"
|
|
94
|
+
?disabled=${!(item && "url" in item && item.url)}
|
|
95
|
+
.action=${() => this.runWgetForSelection()}
|
|
96
|
+
>Checkout</docks-command>
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
setAllExpanded(expanded) {
|
|
100
|
+
const tree = this.treeRef.value;
|
|
101
|
+
if (tree) tree.querySelectorAll("wa-tree-item").forEach((item) => {
|
|
102
|
+
item.expanded = expanded;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
refresh() {
|
|
106
|
+
this.rebuildTree();
|
|
107
|
+
}
|
|
108
|
+
createTreeItems(node, expanded = false) {
|
|
109
|
+
if (!node) return html``;
|
|
110
|
+
return html`
|
|
111
|
+
<wa-tree-item
|
|
112
|
+
@dblclick=${this.nobubble(this.onItemDblClicked)}
|
|
113
|
+
.model=${node}
|
|
114
|
+
?expanded=${expanded}
|
|
115
|
+
>
|
|
116
|
+
<span>${icon(node.icon)} ${node.label}</span>
|
|
117
|
+
${node.children?.map((child) => this.createTreeItems(child))}
|
|
118
|
+
</wa-tree-item>
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
renderContent() {
|
|
122
|
+
return html`
|
|
123
|
+
<wa-tree
|
|
124
|
+
${ref(this.treeRef)}
|
|
125
|
+
@wa-selection-change=${this.nobubble(this.onSelectionChanged)}
|
|
126
|
+
style="--indent-guide-width: 1px;"
|
|
127
|
+
>
|
|
128
|
+
${this.rootNodes?.map((node) => this.createTreeItems(node, true))}
|
|
129
|
+
</wa-tree>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
static {
|
|
133
|
+
this.styles = css`
|
|
134
|
+
:host {
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-direction: column;
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
_decorate([state()], DocksCatalog.prototype, "rootNodes", void 0);
|
|
142
|
+
DocksCatalog = _DocksCatalog = _decorate([customElement("docks-catalog")], DocksCatalog);
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/loader.ts
|
|
145
|
+
contributionRegistry.registerContribution(SIDEBAR_MAIN, {
|
|
146
|
+
name: "catalog",
|
|
147
|
+
label: "Catalog",
|
|
148
|
+
icon: "book",
|
|
149
|
+
component: (id) => html`<docks-catalog id="${id}"></docks-catalog>`
|
|
150
|
+
});
|
|
151
|
+
//#endregion
|
|
152
|
+
|
|
153
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","names":[],"sources":["../src/docks-catalog.ts","../src/loader.ts"],"sourcesContent":["import {\n css,\n html,\n TemplateResult,\n customElement,\n state,\n createRef,\n ref,\n} from \"@eclipse-docks/core/externals/lit\";\nimport {\n DocksPart,\n TreeContribution,\n TreeNode,\n contributionRegistry,\n activePartSignal,\n activeSelectionSignal,\n subscribe,\n unsubscribe,\n TOPIC_CONTRIBUTEIONS_CHANGED,\n type ContributionChangeEvent,\n icon,\n} from \"@eclipse-docks/core\";\n\nexport const CID_CATALOG_ROOT = \"catalog.root\";\n\n@customElement(\"docks-catalog\")\nexport class DocksCatalog extends DocksPart {\n @state()\n private rootNodes?: TreeNode[];\n\n private treeRef = createRef<HTMLElement>();\n private contributionsSubscriptionToken?: string;\n\n protected doBeforeUI() {\n this.rebuildTree();\n this.contributionsSubscriptionToken = subscribe(TOPIC_CONTRIBUTEIONS_CHANGED, (event: ContributionChangeEvent) => {\n if (event.target === CID_CATALOG_ROOT || event.target?.startsWith(\"catalog.\")) {\n this.rebuildTree();\n }\n });\n }\n\n protected doClose() {\n if (this.contributionsSubscriptionToken) {\n unsubscribe(this.contributionsSubscriptionToken);\n this.contributionsSubscriptionToken = undefined;\n }\n super.doClose();\n }\n\n private rebuildTree() {\n const contributions = contributionRegistry.getContributions(\n CID_CATALOG_ROOT\n ) as TreeContribution[];\n this.rootNodes = this.toTreeNodes(contributions);\n this.requestUpdate();\n }\n\n protected renderToolbar() {\n const isActiveAndHasSelection =\n activePartSignal.get() instanceof DocksCatalog &&\n activeSelectionSignal.get() !== undefined;\n\n return html`\n <docks-command\n icon=\"file-arrow-down\"\n title=\"Checkout\"\n ?disabled=${!isActiveAndHasSelection}\n .action=${() => this.runWgetForSelection()}\n ></docks-command>\n <docks-command icon=\"arrows-rotate\" title=\"Refresh Catalog\" .action=${() => this.refresh()}></docks-command>\n <docks-command icon=\"angles-down\" slot=\"end\" title=\"Expand All\" .action=${() => this.setAllExpanded(true)}></docks-command>\n <docks-command icon=\"angles-up\" slot=\"end\" title=\"Collapse All\" .action=${() => this.setAllExpanded(false)}></docks-command>\n `;\n }\n\n private toTreeNodes(contributions: TreeContribution[]) {\n return contributions.map((c) => {\n const node = {\n data: c.state,\n icon: c.icon,\n label: c.label,\n leaf: false,\n } as TreeNode;\n if (c.contributionId) {\n const children = contributionRegistry.getContributions(\n c.contributionId\n ) as TreeContribution[];\n node.leaf = children.length === 0;\n node.children = this.toTreeNodes(children);\n }\n return node;\n });\n }\n\n private wgetParamsFromCatalogData(data: { url?: string; filename?: string }) {\n if (!data?.url) return null;\n const params: { url: string; filename?: string } = { url: data.url };\n if (typeof data.filename === \"string\" && data.filename.trim()) {\n params.filename = data.filename.trim();\n }\n return params;\n }\n\n onItemDblClicked(event: Event) {\n const item = event.currentTarget as HTMLElement & { model?: TreeNode; expanded?: boolean };\n const node = item?.model;\n if (!node) return;\n const wgetParams = this.wgetParamsFromCatalogData(node.data);\n if (wgetParams) {\n this.executeCommand(\"wget\", wgetParams);\n return;\n }\n if (!node.leaf && \"expanded\" in item) {\n item.expanded = !item.expanded;\n }\n }\n\n private runWgetForSelection() {\n const item = activeSelectionSignal.get();\n const wgetParams = item && this.wgetParamsFromCatalogData(item as { url?: string; filename?: string });\n if (wgetParams) {\n this.executeCommand(\"wget\", wgetParams);\n }\n }\n\n onSelectionChanged(event: Event) {\n const node: TreeNode = (event as CustomEvent).detail.selection[0]\n .model;\n activeSelectionSignal.set(node.data);\n }\n\n protected renderContextMenu() {\n const item = activePartSignal.get() instanceof DocksCatalog ? activeSelectionSignal.get() : undefined;\n const hasUrl = item && \"url\" in item && item.url;\n return html`\n <docks-command\n icon=\"file-arrow-down\"\n title=\"Checkout\"\n ?disabled=${!hasUrl}\n .action=${() => this.runWgetForSelection()}\n >Checkout</docks-command>\n `;\n }\n\n public setAllExpanded(expanded: boolean) {\n const tree = this.treeRef.value;\n if (tree) {\n tree.querySelectorAll(\"wa-tree-item\").forEach((item: any) => {\n item.expanded = expanded;\n });\n }\n }\n\n public refresh() {\n this.rebuildTree();\n }\n\n createTreeItems(node: TreeNode, expanded = false): TemplateResult {\n if (!node) {\n return html``;\n }\n return html`\n <wa-tree-item\n @dblclick=${this.nobubble(this.onItemDblClicked)}\n .model=${node}\n ?expanded=${expanded}\n >\n <span>${icon(node.icon)} ${node.label}</span>\n ${node.children?.map((child) => this.createTreeItems(child))}\n </wa-tree-item>\n `;\n }\n\n protected renderContent() {\n return html`\n <wa-tree\n ${ref(this.treeRef)}\n @wa-selection-change=${this.nobubble(this.onSelectionChanged)}\n style=\"--indent-guide-width: 1px;\"\n >\n ${this.rootNodes?.map((node) =>\n this.createTreeItems(node, true)\n )}\n </wa-tree>\n `;\n }\n\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n }\n `;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"docks-catalog\": DocksCatalog;\n }\n}\n","import { html } from \"@eclipse-docks/core/externals/lit\";\nimport { contributionRegistry, SIDEBAR_MAIN } from \"@eclipse-docks/core\";\nimport \"./docks-catalog\";\n\ncontributionRegistry.registerContribution(SIDEBAR_MAIN, {\n name: \"catalog\",\n label: \"Catalog\",\n icon: \"book\",\n component: (id: string) => html`<docks-catalog id=\"${id}\"></docks-catalog>`,\n} as any);\n"],"mappings":";;;;;AAuBA,IAAa,mBAAmB;AAGzB,IAAA,eAAA,MAAM,qBAAqB,UAAU;;;;;;iBAItB,WAAwB;;CAG1C,aAAuB;AACnB,OAAK,aAAa;AAClB,OAAK,iCAAiC,UAAU,+BAA+B,UAAmC;AAC9G,OAAI,MAAM,WAAA,kBAA+B,MAAM,QAAQ,WAAW,WAAW,CACzE,MAAK,aAAa;IAExB;;CAGN,UAAoB;AAChB,MAAI,KAAK,gCAAgC;AACrC,eAAY,KAAK,+BAA+B;AAChD,Q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|
|
|
1
|
+
import { TreeContribution } from '@eclipse-docks/core';
|
|
2
|
+
/** Leaf item state: optional filename when URL is not path-shaped (e.g. data: in production bundles). */
|
|
3
|
+
export type CatalogResourceState = {
|
|
4
|
+
url: string;
|
|
5
|
+
filename?: string;
|
|
6
|
+
};
|
|
7
|
+
export interface CatalogContribution extends TreeContribution {
|
|
8
|
+
items?: CatalogContribution[];
|
|
9
|
+
}
|
|
10
|
+
export declare function getCatalogBaseUrl(): string;
|
|
11
|
+
export declare function registerCatalog(catalog: CatalogContribution, baseUrl?: string): void;
|
|
12
|
+
//# sourceMappingURL=register-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-catalog.d.ts","sourceRoot":"","sources":["../src/register-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,gBAAgB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,yGAAyG;AACzG,MAAM,MAAM,oBAAoB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IACzD,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACjC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAgCpF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eclipse-docks/extension-catalog",
|
|
3
|
+
"version": "0.7.68",
|
|
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
|
+
"./api": {
|
|
14
|
+
"types": "./dist/api.d.ts",
|
|
15
|
+
"import": "./dist/api.js"
|
|
16
|
+
},
|
|
17
|
+
"./loader": {
|
|
18
|
+
"types": "./dist/loader.d.ts",
|
|
19
|
+
"import": "./dist/loader.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "vite build"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@eclipse-docks/core": "*"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "^6.0.0",
|
|
33
|
+
"vite": "^8.0.0",
|
|
34
|
+
"vite-plugin-dts": "^4.5.4"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/eclipse-docks/core"
|
|
39
|
+
}
|
|
40
|
+
}
|