diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-22 11:02:15 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-22 11:02:15 +0200 |
| commit | 3b677af830672759198a0bb8167b4929a9afd997 (patch) | |
| tree | fa8bcde38b2c3ce72a41c8edca385ce81456dc1b /packages/meshbay-client/scripts | |
| parent | 4335a515c67477a6ac33356361b4f43a5df5e642 (diff) | |
| download | meshbay-3b677af830672759198a0bb8167b4929a9afd997.tar.gz | |
fix: move meshbay-client build scripts out of gitignored build/ dir
The root .gitignore ignores build/ (Python convention), which silently
prevented sync-ui.js and its companion index.html from being committed.
Rename to scripts/ so the files are tracked normally.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-client/scripts')
| -rw-r--r-- | packages/meshbay-client/scripts/index.html | 27 | ||||
| -rw-r--r-- | packages/meshbay-client/scripts/sync-ui.js | 46 |
2 files changed, 73 insertions, 0 deletions
diff --git a/packages/meshbay-client/scripts/index.html b/packages/meshbay-client/scripts/index.html new file mode 100644 index 0000000..337e180 --- /dev/null +++ b/packages/meshbay-client/scripts/index.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>MeshBay</title> + <!-- + The interface is loaded from this package, never from the hub. That is the + whole point of the application existing (T3): a hub that ships the code can + lift keys from the page whatever the protocol does. + + The Content-Security-Policy is NOT here. It is sent as a header by the + protocol handler in src/main.js, because `frame-ancestors` is ignored in a + <meta> element — a policy with a directive that silently does nothing is + worse than one without it. One source, and every directive effective. + --> + <link rel="stylesheet" href="./style.css"> +</head> +<body> + <div id="app"></div> + <script src="./vendor/argon2.min.js"></script> + <script src="./keyderive.js"></script> + <script src="./crypto.js"></script> + <script src="./transport.js"></script> + <script type="module" src="./app.js"></script> +</body> +</html> diff --git a/packages/meshbay-client/scripts/sync-ui.js b/packages/meshbay-client/scripts/sync-ui.js new file mode 100644 index 0000000..d0b6eee --- /dev/null +++ b/packages/meshbay-client/scripts/sync-ui.js @@ -0,0 +1,46 @@ +/** + * Copy the interface into this package. + * + * `packages/meshbay-hub/src/meshbay_hub/static/` is the single source of the + * interface, and it is *copied* here at build time rather than forked. A silent + * fork is the only real way to end up maintaining the UI twice, so this script + * refuses to leave a stale copy behind: it wipes the destination first, and CI + * fails if running it changes anything that was committed. + */ + +'use strict'; + +const fs = require('node:fs'); +const path = require('node:path'); + +const SRC = path.resolve(__dirname, '..', '..', 'meshbay-hub', 'src', + 'meshbay_hub', 'static'); +const DEST = path.resolve(__dirname, '..', 'ui'); + +// index.html is ours: the hub builds its own with a /a/<hash>/ prefix for cache +// busting, which an application loading from disk does not need and must not +// have — the prefix would point at the hub. +const OURS = ['index.html']; + +// sw.js has to sit at the root of the scope it serves, which it already does. +const SKIP = new Set(['webrtc-test.html']); + +function copyTree(from, to) { + fs.mkdirSync(to, { recursive: true }); + for (const entry of fs.readdirSync(from, { withFileTypes: true })) { + if (SKIP.has(entry.name)) continue; + const src = path.join(from, entry.name); + const dst = path.join(to, entry.name); + if (entry.isDirectory()) copyTree(src, dst); + else fs.copyFileSync(src, dst); + } +} + +fs.rmSync(DEST, { recursive: true, force: true }); +copyTree(SRC, DEST); +for (const name of OURS) { + fs.copyFileSync(path.join(__dirname, name), path.join(DEST, name)); +} + +const count = fs.readdirSync(DEST).length; +console.log(`ui/ rebuilt from ${path.relative(process.cwd(), SRC)} (${count} entries)`); |