@@ -126,11 +126,19 @@ WB_HTML="$SERVDIR/out/vs/code/browser/workbench/workbench.html"
126126python3 -c "
127127html = open('$WB_HTML ').read()
128128
129- # Replace web CSS with desktop CSS
129+ # Add desktop CSS (contains Tailwind v4 runtime + Cursor-specific styles)
130+ # The HTML has workbench.css (not workbench.web.main.css), so replace doesn't work.
131+ # Instead, add a second <link> for the desktop CSS.
130132html = html.replace(
131133 'workbench/workbench.web.main.css',
132134 'workbench/workbench.desktop.main.css'
133135)
136+ desktop_css_link = '<link rel=\" stylesheet\" href=\" {{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.desktop.main.css\" >'
137+ if 'workbench.desktop.main.css' not in html:
138+ html = html.replace(
139+ '</head>',
140+ '\t' + desktop_css_link + '\n\t</head>'
141+ )
134142
135143# Replace web workbench loader with desktop shim
136144html = html.replace(
@@ -462,6 +470,9 @@ if old in js and 'style="display:none' not in js[js.find(old):js.find(old)+200]
462470 changed = True
463471 print(' update notification suppressed')
464472
473+ # 7t. Keep default Editor layout
474+ # (no change needed — M0.Editor is already the default)
475+
465476if changed:
466477 open(f, 'w').write(js)
467478PATCH_DESKTOP_EOF
@@ -495,14 +506,12 @@ import sys
495506f = sys.argv[1]
496507js = open(f).read()
497508
498- # 8a. CSP connect-src: add CORS proxy origin
509+ # 8a. CSP connect-src: same-origin proxy, no external origin needed
499510old = "connect-src 'self' ws: wss: https:;"
500- new = "connect-src 'self' ws: wss: https: http://127.0.0.1:9080;"
501511if old in js:
502- js = js.replace(old, new, 1)
503- print(' connect-src: added CORS proxy origin')
504- elif new in js:
505- print(' connect-src: already patched')
512+ print(' connect-src: already allows https: (no change needed)')
513+ elif 'connect-src' in js:
514+ print(' connect-src: non-standard, skipping')
506515
507516# 8b. CSP font-src: add vscode-remote-resource
508517old = "font-src 'self' blob:;"
@@ -532,14 +541,31 @@ if old in js:
532541elif 'o="1.105.1";let r=ZS' in js:
533542 print(' U0() already patched')
534543
535- # 8e. MIME type : add .wasm for WebAssembly
544+ # 8e. MIME types : add .wasm, .ttf, .woff2
536545old = '".woff":"application/font-woff"'
537- new = '".wasm":"application/wasm",".woff":"application/font-woff"'
546+ new = '".wasm":"application/wasm",".ttf":"font/ttf",". woff":"application/font-woff",".woff2":"font/woff2 "'
538547if old in js and '".wasm"' not in js:
539548 js = js.replace(old, new, 1)
540- print(' MIME: added .wasm')
541- elif '".wasm"' in js:
542- print(' MIME: .wasm already present')
549+ print(' MIME: added .wasm, .ttf, .woff2')
550+ elif '".wasm"' in js and '".ttf"' not in js:
551+ old2 = '".wasm":"application/wasm",".woff":"application/font-woff"'
552+ new2 = '".wasm":"application/wasm",".ttf":"font/ttf",".woff":"application/font-woff",".woff2":"font/woff2"'
553+ if old2 in js:
554+ js = js.replace(old2, new2, 1)
555+ print(' MIME: added .ttf, .woff2')
556+ elif '".ttf"' in js:
557+ print(' MIME: .ttf/.woff2 already present')
558+
559+ # 8f0. Inject /cors-proxy/ route into server request handler (same-origin, no allowlist)
560+ # URL format: /cors-proxy/<target-host>/path → https://<target-host>/path
561+ # Must go BEFORE the GET-only method check since API calls use POST.
562+ old = 'handleRequest(e,n){if(e.method!=="GET")'
563+ cors_route = r'''handleRequest(e,n){let _u=new URL(e.url||"/",`http://${e.headers.host}`),_p=_u.pathname;if(this._serverBasePath!==void 0&&_p.startsWith(this._serverBasePath)){_p=_p.substring(this._serverBasePath.length);if(_p[0]!=="/")_p="/"+_p}if(_p.startsWith("/cors-proxy/")){const _cp=_p.substring(12),_si=_cp.indexOf("/"),_host=_si>0?_cp.substring(0,_si):_cp,_path=_si>0?_cp.substring(_si):"/";if(e.method==="OPTIONS"){n.writeHead(200,{"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"*","access-control-max-age":"86400"});n.end();return}const _https=yH("https"),_chunks=[];e.on("data",_c=>_chunks.push(_c));e.on("end",()=>{const _body=Buffer.concat(_chunks),_fh={...e.headers};delete _fh["host"];delete _fh["origin"];delete _fh["referer"];delete _fh["connection"];delete _fh["accept-encoding"];_fh["host"]=_host;const _opts={hostname:_host,port:443,path:_path+(_u.search||""),method:e.method,headers:_fh},_pr=_https.request(_opts,_res=>{const _rh={..._res.headers};_rh["access-control-allow-origin"]="*";_rh["access-control-expose-headers"]="*";delete _rh["access-control-allow-credentials"];n.writeHead(_res.statusCode,_rh);_res.pipe(n)});_pr.on("error",_e=>{n.writeHead(502,{"Content-Type":"text/plain"});n.end("Proxy error: "+_e.message)});if(_body.length>0)_pr.write(_body);_pr.end()});return}if(e.method!=="GET")'''
564+ if old in js and '/cors-proxy/' not in js:
565+ js = js.replace(old, cors_route, 1)
566+ print(' CORS proxy route injected at /cors-proxy/')
567+ elif '/cors-proxy/' in js:
568+ print(' CORS proxy route already present')
543569
544570open(f, 'w').write(js)
545571PATCH_SERVER_EOF
0 commit comments