Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/patches/service-worker.diff
Asher 43ef50b404
Update to 1.78.2 (#6201)
* Update to 1.78.1

No changes needed in the patches other than moving some lines around and
updating the CSP hash as usual.

The flake had to be updated as it was using Node 16.16 and 16.17 is
required at minimum now.  Also python seems to install python2 which is
marked as deprecated so explicitly install python3.

* Update to 1.78.2

Patches applied without any conflicts.

* Update commit environment variable

This was causing the commit not to be set.  It broke display languages
since that has a hard dependency on the commit for directory names.
Possibly broke other things.
2023-05-15 15:44:03 -08:00

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
@@ -60,6 +60,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/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
@@ -89,6 +89,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) {
@@ -161,4 +165,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);
+ }
+ }
+ }
}
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
@@ -306,6 +306,10 @@ export class WebClientServer {
updateEndpoint: !this._environmentService.args['disable-update-check'] ? base + '/update/check' : undefined,
logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? base + '/logout' : undefined,
proxyEndpointTemplate: process.env.VSCODE_PROXY_URI ?? base + '/proxy/{{port}}/',
+ serviceWorker: {
+ scope: vscodeBase + '/',
+ path: base + '/_static/out/browser/serviceWorker.js',
+ },
embedderIdentifier: 'server-distro',
extensionsGallery: this._productService.extensionsGallery,
};