@@ -7,7 +7,7 @@ import { WebsocketRequest } from "../../../typings/pluginapi"
7
7
import { logError } from "../../common/util"
8
8
import { CodeArgs , toCodeArgs } from "../cli"
9
9
import { isDevMode } from "../constants"
10
- import { authenticated , ensureAuthenticated , redirect , self } from "../http"
10
+ import { authenticated , ensureAuthenticated , redirect , replaceTemplates , self } from "../http"
11
11
import { SocketProxyProvider } from "../socket"
12
12
import { isFile , loadAMDModule } from "../util"
13
13
import { Router as WsRouter } from "../wsRouter"
@@ -34,6 +34,32 @@ export class CodeServerRouteWrapper {
34
34
35
35
//#region Route Handlers
36
36
37
+ private manifest : express . Handler = async ( req , res , next ) => {
38
+ res . writeHead ( 200 , { "Content-Type" : "application/manifest+json" } )
39
+
40
+ return res . end (
41
+ replaceTemplates (
42
+ req ,
43
+ JSON . stringify (
44
+ {
45
+ name : "code-server" ,
46
+ short_name : "code-server" ,
47
+ start_url : "." ,
48
+ display : "fullscreen" ,
49
+ description : "Run Code on a remote server." ,
50
+ icons : [ 192 , 512 ] . map ( ( size ) => ( {
51
+ src : `{{BASE}}/_static/src/browser/media/pwa-icon-${ size } .png` ,
52
+ type : "image/png" ,
53
+ sizes : `${ size } x${ size } ` ,
54
+ } ) ) ,
55
+ } ,
56
+ null ,
57
+ 2 ,
58
+ ) ,
59
+ ) ,
60
+ )
61
+ }
62
+
37
63
private $root : express . Handler = async ( req , res , next ) => {
38
64
const isAuthenticated = await authenticated ( req )
39
65
const NO_FOLDER_OR_WORKSPACE_QUERY = ! req . query . folder && ! req . query . workspace
@@ -141,6 +167,7 @@ export class CodeServerRouteWrapper {
141
167
142
168
constructor ( ) {
143
169
this . router . get ( "/" , this . ensureCodeServerLoaded , this . $root )
170
+ this . router . get ( / m a n i f e s t .j s o n $ / , this . manifest )
144
171
this . router . all ( "*" , ensureAuthenticated , this . ensureCodeServerLoaded , this . $proxyRequest )
145
172
this . _wsRouterWrapper . ws ( "/" , ensureAuthenticated , this . ensureCodeServerLoaded , this . $proxyWebsocket )
146
173
}
0 commit comments