Skip to content

Commit e893c58

Browse files
authored
Merge pull request #130 from manGitAcc/1.6
Add patch to support custom extensions marketplace
2 parents c17a34c + 60ea254 commit e893c58

File tree

6 files changed

+174
-22
lines changed

6 files changed

+174
-22
lines changed

patched-vscode/product.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@
3333
"webviewContentExternalBaseUrlTemplate": "https://{{uuid}}.vscode-cdn.net/insider/ef65ac1ba57f57f2a3961bfe94aa20481caca4c6/out/vs/workbench/contrib/webview/browser/pre/",
3434
"builtInExtensions": [
3535
],
36-
"extensionsGallery": {
37-
"serviceUrl": "https://open-vsx.org/vscode/gallery",
38-
"itemUrl": "https://open-vsx.org/vscode/item",
39-
"resourceUrlTemplate": "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}",
40-
"controlUrl": "",
41-
"recommendationsUrl": "",
42-
"nlsBaseUrl": "",
43-
"publisherUrl": ""
44-
},
4536
"linkProtectionTrustedDomains": [
4637
"https://open-vsx.org"
4738
]

patched-vscode/src/vs/platform/product/common/product.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ else if (globalThis._VSCODE_PRODUCT_JSON && globalThis._VSCODE_PACKAGE_JSON) {
4747
version: pkg.version
4848
});
4949
}
50+
51+
if (env['EXTENSIONS_GALLERY']) {
52+
console.log(`Custom extensions gallery detected. Parsing...`);
53+
Object.assign(product, {
54+
extensionsGallery: JSON.parse(env['EXTENSIONS_GALLERY'])
55+
});
56+
} else {
57+
console.log(`Using default extensions gallery.`);
58+
Object.assign(product, {
59+
extensionsGallery: (product.extensionsGallery || {
60+
serviceUrl: "https://open-vsx.org/vscode/gallery",
61+
itemUrl: "https://open-vsx.org/vscode/item",
62+
resourceUrlTemplate: "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}",
63+
controlUrl: "",
64+
recommendationsUrl: "",
65+
nlsBaseUrl: "",
66+
publisherUrl: ""
67+
})
68+
});
69+
}
70+
console.log(JSON.stringify(product.extensionsGallery, null, 2));
5071
}
5172

5273
// Web environment or unknown

patched-vscode/src/vs/server/node/webClientServer.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,7 @@ export class WebClientServer {
331331
const productConfiguration = {
332332
rootEndpoint: base,
333333
embedderIdentifier: 'server-distro',
334-
extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
335-
...this._productService.extensionsGallery,
336-
resourceUrlTemplate: this._webExtensionResourceUrlTemplate.with({
337-
scheme: 'http',
338-
authority: remoteAuthority,
339-
path: `${this._webExtensionRoute}/${this._webExtensionResourceUrlTemplate.authority}${this._webExtensionResourceUrlTemplate.path}`
340-
}).toString(true)
341-
} : undefined
334+
extensionsGallery: this._productService.extensionsGallery,
342335
} satisfies Partial<IProductConfiguration>;
343336

344337
if (!this._environmentService.isBuilt) {

patched-vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ import { ILocalizedString } from 'vs/platform/action/common/action';
6464
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
6565
import { MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
6666
import { createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
67+
import { IProductService } from 'vs/platform/product/common/productService';
68+
import { memoize } from 'vs/base/common/decorators';
6769

6870
export const DefaultViewsContext = new RawContextKey<boolean>('defaultExtensionViews', true);
6971
export const ExtensionsSortByContext = new RawContextKey<string>('extensionsSortByValue', '');
@@ -87,7 +89,6 @@ const SortByUpdateDateContext = new RawContextKey<boolean>('sortByUpdateDate', f
8789
const REMOTE_CATEGORY: ILocalizedString = localize2({ key: 'remote', comment: ['Remote as in remote machine'] }, "Remote");
8890

8991
export class ExtensionsViewletViewsContribution extends Disposable implements IWorkbenchContribution {
90-
9192
private readonly container: ViewContainer;
9293

9394
constructor(
@@ -516,7 +517,8 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
516517
@IExtensionService extensionService: IExtensionService,
517518
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
518519
@IPreferencesService private readonly preferencesService: IPreferencesService,
519-
@ICommandService private readonly commandService: ICommandService
520+
@ICommandService private readonly commandService: ICommandService,
521+
@IProductService private readonly productService: IProductService,
520522
) {
521523
super(VIEWLET_ID, { mergeViewWithContainerWhenSingleView: true }, instantiationService, configurationService, layoutService, contextMenuService, telemetryService, extensionService, themeService, storageService, contextService, viewDescriptorService);
522524

@@ -544,6 +546,15 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
544546
this.searchViewletState = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
545547
}
546548

549+
@memoize
550+
get extensionsGalleryHostname(): string {
551+
if (this.productService.extensionsGallery?.serviceUrl) {
552+
return new URL(this.productService.extensionsGallery?.serviceUrl).hostname;
553+
}
554+
555+
return 'Marketplace';
556+
}
557+
547558
get searchValue(): string | undefined {
548559
return this.searchBox?.getValue();
549560
}
@@ -558,8 +569,7 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
558569
hide(overlay);
559570

560571
const header = append(this.root, $('.header'));
561-
const placeholder = localize('searchExtensions', "Search Extensions in Marketplace");
562-
572+
const placeholder = localize('searchExtensions', 'Search extensions in {0}', this.extensionsGalleryHostname);
563573
const searchValue = this.searchViewletState['query.value'] ? this.searchViewletState['query.value'] : '';
564574

565575
const searchContainer = append(header, $('.extensions-search-container'));
@@ -924,4 +934,4 @@ export class MaliciousExtensionChecker implements IWorkbenchContribution {
924934
}).then(() => undefined);
925935
}, err => this.logService.error(err));
926936
}
927-
}
937+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
Index: sagemaker-code-editor/vscode/src/vs/platform/product/common/product.ts
2+
===================================================================
3+
--- sagemaker-code-editor.orig/vscode/src/vs/platform/product/common/product.ts
4+
+++ sagemaker-code-editor/vscode/src/vs/platform/product/common/product.ts
5+
@@ -47,6 +47,27 @@ else if (globalThis._VSCODE_PRODUCT_JSON
6+
version: pkg.version
7+
});
8+
}
9+
+
10+
+ if (env['EXTENSIONS_GALLERY']) {
11+
+ console.log(`Custom extensions gallery detected. Parsing...`);
12+
+ Object.assign(product, {
13+
+ extensionsGallery: JSON.parse(env['EXTENSIONS_GALLERY'])
14+
+ });
15+
+ } else {
16+
+ console.log(`Using default extensions gallery.`);
17+
+ Object.assign(product, {
18+
+ extensionsGallery: (product.extensionsGallery || {
19+
+ serviceUrl: "https://open-vsx.org/vscode/gallery",
20+
+ itemUrl: "https://open-vsx.org/vscode/item",
21+
+ resourceUrlTemplate: "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}",
22+
+ controlUrl: "",
23+
+ recommendationsUrl: "",
24+
+ nlsBaseUrl: "",
25+
+ publisherUrl: ""
26+
+ })
27+
+ });
28+
+ }
29+
+ console.log(JSON.stringify(product.extensionsGallery, null, 2));
30+
}
31+
32+
// Web environment or unknown
33+
Index: sagemaker-code-editor/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts
34+
===================================================================
35+
--- sagemaker-code-editor.orig/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts
36+
+++ sagemaker-code-editor/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts
37+
@@ -64,6 +64,8 @@ import { ILocalizedString } from 'vs/pla
38+
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
39+
import { MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
40+
import { createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
41+
+import { IProductService } from 'vs/platform/product/common/productService';
42+
+import { memoize } from 'vs/base/common/decorators';
43+
44+
export const DefaultViewsContext = new RawContextKey<boolean>('defaultExtensionViews', true);
45+
export const ExtensionsSortByContext = new RawContextKey<string>('extensionsSortByValue', '');
46+
@@ -87,7 +89,6 @@ const SortByUpdateDateContext = new RawC
47+
const REMOTE_CATEGORY: ILocalizedString = localize2({ key: 'remote', comment: ['Remote as in remote machine'] }, "Remote");
48+
49+
export class ExtensionsViewletViewsContribution extends Disposable implements IWorkbenchContribution {
50+
-
51+
private readonly container: ViewContainer;
52+
53+
constructor(
54+
@@ -516,7 +517,8 @@ export class ExtensionsViewPaneContainer
55+
@IExtensionService extensionService: IExtensionService,
56+
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
57+
@IPreferencesService private readonly preferencesService: IPreferencesService,
58+
- @ICommandService private readonly commandService: ICommandService
59+
+ @ICommandService private readonly commandService: ICommandService,
60+
+ @IProductService private readonly productService: IProductService,
61+
) {
62+
super(VIEWLET_ID, { mergeViewWithContainerWhenSingleView: true }, instantiationService, configurationService, layoutService, contextMenuService, telemetryService, extensionService, themeService, storageService, contextService, viewDescriptorService);
63+
64+
@@ -544,6 +546,15 @@ export class ExtensionsViewPaneContainer
65+
this.searchViewletState = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
66+
}
67+
68+
+ @memoize
69+
+ get extensionsGalleryHostname(): string {
70+
+ if (this.productService.extensionsGallery?.serviceUrl) {
71+
+ return new URL(this.productService.extensionsGallery?.serviceUrl).hostname;
72+
+ }
73+
+
74+
+ return 'Marketplace';
75+
+ }
76+
+
77+
get searchValue(): string | undefined {
78+
return this.searchBox?.getValue();
79+
}
80+
@@ -558,8 +569,7 @@ export class ExtensionsViewPaneContainer
81+
hide(overlay);
82+
83+
const header = append(this.root, $('.header'));
84+
- const placeholder = localize('searchExtensions', "Search Extensions in Marketplace");
85+
-
86+
+ const placeholder = localize('searchExtensions', 'Search extensions in {0}', this.extensionsGalleryHostname);
87+
const searchValue = this.searchViewletState['query.value'] ? this.searchViewletState['query.value'] : '';
88+
89+
const searchContainer = append(header, $('.extensions-search-container'));
90+
@@ -924,4 +934,4 @@ export class MaliciousExtensionChecker i
91+
}).then(() => undefined);
92+
}, err => this.logService.error(err));
93+
}
94+
-}
95+
+}
96+
\ No newline at end of file
97+
Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
98+
===================================================================
99+
--- sagemaker-code-editor.orig/vscode/src/vs/server/node/webClientServer.ts
100+
+++ sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
101+
@@ -320,14 +320,7 @@ export class WebClientServer {
102+
const productConfiguration = {
103+
rootEndpoint: base,
104+
embedderIdentifier: 'server-distro',
105+
- extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
106+
- ...this._productService.extensionsGallery,
107+
- resourceUrlTemplate: this._webExtensionResourceUrlTemplate.with({
108+
- scheme: 'http',
109+
- authority: remoteAuthority,
110+
- path: `${this._webExtensionRoute}/${this._webExtensionResourceUrlTemplate.authority}${this._webExtensionResourceUrlTemplate.path}`
111+
- }).toString(true)
112+
- } : undefined
113+
+ extensionsGallery: this._productService.extensionsGallery,
114+
} satisfies Partial<IProductConfiguration>;
115+
116+
if (!this._environmentService.isBuilt) {
117+
Index: sagemaker-code-editor/vscode/product.json
118+
===================================================================
119+
--- sagemaker-code-editor.orig/vscode/product.json
120+
+++ sagemaker-code-editor/vscode/product.json
121+
@@ -33,15 +33,6 @@
122+
"webviewContentExternalBaseUrlTemplate": "https://{{uuid}}.vscode-cdn.net/insider/ef65ac1ba57f57f2a3961bfe94aa20481caca4c6/out/vs/workbench/contrib/webview/browser/pre/",
123+
"builtInExtensions": [
124+
],
125+
- "extensionsGallery": {
126+
- "serviceUrl": "https://open-vsx.org/vscode/gallery",
127+
- "itemUrl": "https://open-vsx.org/vscode/item",
128+
- "resourceUrlTemplate": "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}",
129+
- "controlUrl": "",
130+
- "recommendationsUrl": "",
131+
- "nlsBaseUrl": "",
132+
- "publisherUrl": ""
133+
- },
134+
"linkProtectionTrustedDomains": [
135+
"https://open-vsx.org"
136+
]

patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ sagemaker-extension-smus-support.patch
1818
post-startup-notifications.patch
1919
sagemaker-extensions-sync.patch
2020
display-language.patch
21+
custom-extensions-marketplace.diff

0 commit comments

Comments
 (0)