a1af9e2a56
* Move integration types into code-server This will be easier to maintain than to have it as a patch. * Disable connection token Using a flag means we will not need to patch it out. I think this is new from 1.64? * Add product.json to build process This way we do not have to patch it. * Ship with remote agent package.json Instead of the root one. This contains fewer dependencies. * Let Code handle errors This way we will not have to patch Code to make this work and I think it makes sense to let Code handle the request. If we do want to handle errors we can do it cleanly by patching their error handler to throw instead. * Move manifest override into code-server This way we will not have to patch it. * Move to patches - Switch submodule to track upstream - Add quilt to the process - Add patches The node-* ignore was ignoring one of the diffs so I removed it. This was added when we were curling Node as node-v{version}-darwin-x64 for the macOS build but this no longer happens (we use the Node action to install a specific version now so we just use the system-wide Node). * Use pre-packaged Code
68 lines
2.6 KiB
Diff
68 lines
2.6 KiB
Diff
Add a service worker
|
|
|
|
To test try installing code-server as a PWA.
|
|
|
|
Index: code-server/lib/vscode/src/vs/base/common/product.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/base/common/product.ts
|
|
+++ code-server/lib/vscode/src/vs/base/common/product.ts
|
|
@@ -36,6 +36,10 @@ export interface IProductConfiguration {
|
|
readonly updateEndpoint?: string
|
|
readonly logoutEndpoint?: string
|
|
readonly proxyEndpointTemplate?: string
|
|
+ readonly serviceWorker?: {
|
|
+ readonly path: string;
|
|
+ readonly scope: string;
|
|
+ }
|
|
|
|
readonly version: string;
|
|
readonly date?: string;
|
|
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
@@ -296,6 +296,10 @@ export class WebClientServer {
|
|
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
|
|
logoutEndpoint: this._environmentService.args['auth'] ? base + '/logout' : undefined,
|
|
proxyEndpointTemplate: base + '/proxy/{{port}}',
|
|
+ serviceWorker: {
|
|
+ scope: vscodeBase + '/',
|
|
+ path: base + '/_static/out/browser/serviceWorker.js',
|
|
+ },
|
|
extensionsGallery: {
|
|
...this._productService.extensionsGallery,
|
|
'resourceUrlTemplate': this._webExtensionResourceUrlTemplate ? this._webExtensionResourceUrlTemplate.with({
|
|
Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
|
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
@@ -90,6 +90,10 @@ export class CodeServerClient extends Di
|
|
if (this.productService.logoutEndpoint) {
|
|
this.addLogoutCommand(this.productService.logoutEndpoint);
|
|
}
|
|
+
|
|
+ if (this.productService.serviceWorker) {
|
|
+ await this.registerServiceWorker(this.productService.serviceWorker);
|
|
+ }
|
|
}
|
|
|
|
private checkUpdates(updateEndpoint: string) {
|
|
@@ -162,4 +166,17 @@ export class CodeServerClient extends Di
|
|
});
|
|
}
|
|
}
|
|
+
|
|
+ private async registerServiceWorker(serviceWorker: { path: string; scope: string }) {
|
|
+ if (typeof navigator !== 'undefined' && 'serviceWorker' in navigator) {
|
|
+ try {
|
|
+ await navigator.serviceWorker.register(serviceWorker.path, {
|
|
+ scope: serviceWorker.scope,
|
|
+ });
|
|
+ this.logService.info('[Service Worker] registered');
|
|
+ } catch (error: any) {
|
|
+ this.logService.error('[Service Worker] registration', error as Error);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
}
|