Skip to content

Commit 029ccce

Browse files
author
winjo
committed
feat: 增加 extension-manager 模块, 可展示已内置的扩展
1 parent 11f15dc commit 029ccce

22 files changed

Lines changed: 1093 additions & 12 deletions

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@
9393
{
9494
"publisher": "alex",
9595
"name": "css-language-features-worker",
96-
"version": "1.0.0-beta.1"
96+
"version": "1.53.0-patch.1"
9797
},
9898
{
9999
"publisher": "alex",
100100
"name": "markdown-language-features-worker",
101-
"version": "1.0.0-beta.2"
101+
"version": "1.53.0-patch.1"
102102
},
103103
{
104104
"publisher": "alex",
105105
"name": "html-language-features-worker",
106-
"version": "1.0.0-beta.1"
106+
"version": "1.53.0-patch.1"
107107
},
108108
{
109109
"publisher": "alex",
110110
"name": "json-language-features-worker",
111-
"version": "1.0.0-beta.1"
111+
"version": "1.53.0-patch.1"
112112
},
113113
{
114114
"publisher": "alex",
115115
"name": "typescript-language-features-worker",
116-
"version": "1.53.0-patch.1"
116+
"version": "1.53.0-patch.2"
117117
},
118118
{
119119
"publisher": "cloud-ide",

packages/alex/src/core/extension/metadata.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ export const IconSlim: IExtensionBasicMetadata = {
1212
version: '1.0.5',
1313
},
1414
packageJSON: {
15+
publisher: 'kaitian',
1516
name: 'vsicons-slim',
17+
version: '1.0.5',
18+
displayName: 'vsicons-slim',
19+
description: 'Icons for Visual Studio Code',
1620
activationEvents: ['*'],
1721
contributes: {
1822
iconThemes: [
@@ -27,6 +31,7 @@ export const IconSlim: IExtensionBasicMetadata = {
2731
pkgNlsJSON: {},
2832
nlsList: [],
2933
extendConfig: {},
34+
webAssets: [],
3035
};
3136

3237
export const IDETheme: IExtensionBasicMetadata = {
@@ -36,7 +41,11 @@ export const IDETheme: IExtensionBasicMetadata = {
3641
version: '2.4.0',
3742
},
3843
packageJSON: {
44+
publisher: 'kaitian',
3945
name: 'ide-dark-theme',
46+
version: '2.4.0',
47+
displayName: 'IDE UI Theme',
48+
description: 'IDE UI Theme',
4049
contributes: {
4150
themes: [
4251
{
@@ -57,6 +66,7 @@ export const IDETheme: IExtensionBasicMetadata = {
5766
pkgNlsJSON: {},
5867
nlsList: [],
5968
extendConfig: {},
69+
webAssets: [],
6070
};
6171

6272
export const GeekTheme: IExtensionBasicMetadata = {
@@ -66,7 +76,11 @@ export const GeekTheme: IExtensionBasicMetadata = {
6676
version: '1.8.0',
6777
},
6878
packageJSON: {
79+
publisher: 'cloudide',
6980
name: '@alipay/geek-theme',
81+
version: '1.8.0',
82+
displayName: 'Geek IDE UI Theme',
83+
description: 'Geek IDE UI Theme',
7084
contributes: {
7185
themes: [
7286
{
@@ -87,4 +101,5 @@ export const GeekTheme: IExtensionBasicMetadata = {
87101
pkgNlsJSON: {},
88102
nlsList: [],
89103
extendConfig: {},
104+
webAssets: [],
90105
};

packages/alex/src/core/modules.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ import { WorkspaceEditModule } from '@ali/ide-workspace-edit/lib/browser';
4444
* alex
4545
*/
4646

47-
import { ClientModule, ServerModuleCollection } from '@alipay/alex-core';
47+
import {
48+
ClientModule,
49+
ServerModuleCollection,
50+
ExtensionClientManagerModule,
51+
} from '@alipay/alex-core';
4852
import { PluginModule } from '@alipay/alex-plugin';
4953
import { AlexModule } from './alex.module';
5054

@@ -89,7 +93,7 @@ export const modules: ModuleConstructor[] = [
8993
// Extension Modules
9094
KaitianExtensionModule,
9195
// FeatureExtensionModule,
92-
// ExtensionManagerModule,
96+
ExtensionClientManagerModule,
9397
MonacoEnhanceModule,
9498

9599
// addons

packages/cli/src/extension/scanner.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ export async function getExtension(
9494

9595
const nlsList = await getAllLocalized(extensionPath, 'package.nls', '.json');
9696

97+
const metaPath = path.join(extensionPath, 'kaitian-meta.json');
98+
let webAssets: string[] = [];
99+
if (await fse.pathExists(metaPath)) {
100+
try {
101+
const meta = await fse.readJSON(metaPath);
102+
webAssets = meta?.['web-assets'] || [];
103+
} catch (e) {
104+
console.error(e);
105+
webAssets = [];
106+
}
107+
}
108+
97109
// merge for `kaitianContributes` and `contributes`
98110
packageJSON.contributes = mergeContributes(
99111
packageJSON.kaitianContributes,
@@ -118,6 +130,12 @@ export async function getExtension(
118130
},
119131
packageJSON: pick(packageJSON, [
120132
'name',
133+
'publisher',
134+
'version',
135+
'repository',
136+
'displayName',
137+
'description',
138+
'icon',
121139
'activationEvents',
122140
'kaitianContributes',
123141
'contributes',
@@ -126,6 +144,7 @@ export async function getExtension(
126144
pkgNlsJSON,
127145
nlsList,
128146
extendConfig,
147+
webAssets,
129148
mode,
130149
uri,
131150
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { IExtensionProps } from '@ali/ide-core-common';
2+
3+
export const EXTENSION_SCHEME = 'extension';
4+
export const enableExtensionsContainerId = 'extensions';
5+
export const enableExtensionsTarbarHandlerId = 'extensions.enable';
6+
7+
export const IExtensionManagerService = Symbol('IExtensionManagerService');
8+
9+
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
10+
11+
// IExtensionProps 属性为 readonly,改为 writeable
12+
export type IExtension = Writeable<IExtensionProps> & {
13+
installed: boolean;
14+
};
15+
16+
export const DEFAULT_ICON_URL =
17+
'https://gw.alipayobjects.com/mdn/rms_d8fa74/afts/img/A*upJXQo96It8AAAAAAAAAAABkARQnAQ';
18+
19+
export interface BaseExtension {
20+
extensionId: string; // 插件市场 extensionId
21+
name: string;
22+
version: string;
23+
path: string;
24+
publisher: string;
25+
isBuiltin?: boolean;
26+
}
27+
28+
export interface RawExtension extends BaseExtension {
29+
id: string; // publisher.name
30+
displayName: string;
31+
description: string;
32+
installed: boolean;
33+
icon: string;
34+
enable: boolean;
35+
isBuiltin: boolean;
36+
isDevelopment?: boolean;
37+
// 启用范围
38+
engines: {
39+
vscode: string;
40+
kaitian: string;
41+
};
42+
}
43+
44+
// 插件详情页显示
45+
export interface ExtensionDetail extends RawExtension {
46+
readme: string;
47+
changelog: string;
48+
license: string;
49+
categories: string;
50+
packageJSON: any;
51+
// 代码仓库
52+
repository: string;
53+
contributes: {
54+
[name: string]: any;
55+
};
56+
}
57+
58+
export interface OpenExtensionOptions {
59+
publisher: string;
60+
name: string;
61+
preview: boolean;
62+
displayName?: string;
63+
version?: string;
64+
icon?: string;
65+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.icon {
2+
vertical-align: middle;
3+
font-size: 14px !important;
4+
}
5+
6+
.tab_icon {
7+
width: 14px;
8+
height: 14px;
9+
}
10+
11+
.tag {
12+
margin-right: 4px;
13+
background-color: var(--list-inactiveSelectionBackground);
14+
border: 1px solid var(--sideBarSectionHeader-background);
15+
color: var(--descriptionForeground);
16+
padding: 0 4px;
17+
border-radius: 4px;
18+
user-select: text;
19+
white-space: nowrap;
20+
font-size: 12px;
21+
height: 20px;
22+
line-height: 18px;
23+
box-sizing: border-box;
24+
&.green {
25+
background-color: rgba(#73D13D, 0.15);
26+
border-color: rgba(#73D13D, 0.25);
27+
}
28+
29+
&.developmentMode {
30+
background-color: var(--statusBar-debuggingBackground);
31+
color: var(--foreground);
32+
}
33+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
.wrap {
2+
height: 100%;
3+
}
4+
5+
.tabs {
6+
line-height: 20px;
7+
padding-left: 24px;
8+
:global(.kt-tab) {
9+
font-weight: 500;
10+
}
11+
}
12+
13+
.content {
14+
height: calc(100% - 40px);
15+
}
16+
17+
.header {
18+
display: flex;
19+
padding: 32px 32px 14px;
20+
font-size: 14px;
21+
}
22+
23+
.title {
24+
display: flex;
25+
align-items: center;
26+
overflow: hidden;
27+
margin-bottom: 4px;
28+
}
29+
30+
.details {
31+
margin-left: 20px;
32+
}
33+
34+
.name {
35+
font-size: 24px;
36+
line-height: 32px;
37+
font-weight: bold;
38+
white-space: nowrap;
39+
margin-right: 11px;
40+
}
41+
42+
.action {
43+
margin-right: 8px;
44+
}
45+
46+
47+
.subtitle {
48+
white-space: nowrap;
49+
height: 20px;
50+
line-height: 20px;
51+
margin-bottom: 4px;
52+
}
53+
54+
.description {
55+
font-size: 12px;
56+
line-height: 20px;
57+
color: var(--description-foreground);
58+
white-space: nowrap;
59+
text-overflow: ellipsis;
60+
overflow: hidden;
61+
}
62+
63+
.subtitle_item:first-child {
64+
padding-left: 0;
65+
border: none;
66+
}
67+
68+
.subtitle_item {
69+
font-size: 12px;
70+
line-height: 12px;
71+
margin-right: 12px;
72+
color: var(--description-foreground);
73+
}
74+
75+
.subtitle_item a {
76+
font-size: 12px;
77+
}
78+
79+
.icon {
80+
width: 72px;
81+
height: 72px;
82+
object-fit: contain;
83+
}
84+
85+
.actions {
86+
margin-top: 12px;
87+
display: flex;
88+
align-items: center;
89+
}
90+
91+
.body {
92+
height: calc(100% - 165px);
93+
overflow: hidden;
94+
}
95+
96+
.navbar {
97+
height: 36px;
98+
font-weight: 700;
99+
font-size: 14px;
100+
line-height: 36px;
101+
padding-left: 20px;
102+
border-bottom: 1px solid hsla(0,0%,53%,.45);
103+
box-sizing: border-box;
104+
}
105+
106+
.actions_container {
107+
display: flex;
108+
margin:0;
109+
padding:0;
110+
}
111+
112+
.action_item {
113+
margin:0;
114+
padding:0;
115+
list-style-type:none;
116+
}
117+
118+
.action_label {
119+
cursor: pointer;
120+
margin-right: 16px;
121+
color: inherit;
122+
&:hover {
123+
color: inherit;
124+
text-decoration: underline;
125+
}
126+
}
127+
128+
.action_label_show {
129+
text-decoration: underline;
130+
}

0 commit comments

Comments
 (0)