Skip to content

Commit

Permalink
cf works, remove sw.js
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Jan 30, 2024
1 parent 9de0f6c commit ac19e12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 174 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ This repo contains a build script for clangd on WebAssembly (TBD), and an exampl

I'm working on the build instruction, but you can take a look at `build.sh`.

## About the example page

I've publish a [GitHub Page](https://clangd.guyutongxue.site/) for demonstrating how clangd works in your browser.

Notice that clangd is a multi-thread program, so we need `SharedArrayBuffer` -- and more over, a strict context called `crossOriginIsolated`. GitHub Pages do not send COOP/COEP headers for us to enabling that context, so I served this site through CloudFlare with a custom rule adding those headers. If you want to deploy this project by yourself, make sure correct COOP/COEP header is set on the server side, or you can use [`coi-serviceworker`](https://github.com/gzuidhof/coi-serviceworker).

<!--By the way, you should be able to embed this page into your website as a `<iframe>`. I've enabled [iframe-resizer](https://github.com/davidjbradshaw/iframe-resizer) on this page for your convenience.-->

## Acknowledgement

- [soedirgo/llvm-wasm](https://github.com/soedirgo/llvm-wasm) provides a very detailed guide on how to build LLVM to wasm. Better then famous works like [binji/wasm-clang](https://github.com/binji/wasm-clang) or [tbfleming/cib](https://github.com/tbfleming/cib) (but also thank you guys :P);
- [nokotan/vscode-clangd](https://github.com/nokotan/vscode-clangd) patch vscode's clangd extension with WASM binary to make it work on vscode-web. Some bugs but useful; no build scripts or further documentation;
- [ConorBobbleHat/clangd-wasm](https://github.com/ConorBobbleHat/clangd-wasm) and [ConorBobbleHat/clangd-wasm-core](https://github.com/ConorBobbleHat/clangd-wasm-core); build scripts provided but lack examples on how to use them.

## About the demo

I've publish a [GitHub Page](https://clangd.guyutongxue.site/) for demonstrating how clangd works in the browser. Notice that clangd is a multi-thread program, so we need `SharedArrayBuffer` -- and more over, a strict context called `crossOriginIsolated`. GitHub Pages do not send COOP/COEP headers for us to enabling that context, so a Service Worker [`coi-serviceworker`](https://github.com/gzuidhof/coi-serviceworker) is used here. If you want to deploy this project, it's encourage to set correct COOP/COEP header on the server side (then you can remove those coi stuff on the `<head>` part of `index.html`).

<!--By the way, you should be able to embed this page into your website as a `<iframe>`. I've enabled [iframe-resizer](https://github.com/davidjbradshaw/iframe-resizer) on this page for your convenience.-->
2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<link rel="icon" type="image/svg+xml" href="/clangd.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clangd Web</title>
<script>window.coi = { quiet: false };</script>
<script src="/sw.js" ></script>
</head>
<body>
<div id="app">
Expand Down
166 changes: 0 additions & 166 deletions public/sw.js

This file was deleted.

0 comments on commit ac19e12

Please sign in to comment.