| … | … | @@ -0,0 +1,48 @@ |
| 1 | // Verify the BUILT worklet bundle carries every browser file favela-surface serves. |
| 2 | // |
| 3 | // ⛔ WHY THIS EXISTS. favela-surface used to fill its /static/ map by reading its own static/ directory |
| 4 | // at boot. On a desktop that directory is on disk. In this app the surface runs from worklet.bundle, |
| 5 | // and bare-pack packs only what the module graph IMPORTS — a directory read at runtime is invisible to |
| 6 | // it. So readdirSync failed inside the bundle, the try/catch turned that into an empty list, and every |
| 7 | // /static/*.js on the phone was a 404: |
| 8 | // |
| 9 | // composer.js never ran, so a photo posted from the phone was ONE level with no pyramid. A 2,645,504 |
| 10 | // byte photo then had no level under bsky's 2,000,000 ceiling and the bridge withheld |
| 11 | // it — the post reached bsky with no image while Mastodon (no ceiling) showed it. |
| 12 | // the @-picker, explore's three.js, the anproto client — all silently absent the same way. |
| 13 | // |
| 14 | // Nothing reported it: a module script that 404s is a page that quietly does nothing. favela-surface now |
| 15 | // imports static/ as text modules so bare-pack sees them; this reads the ARTIFACT so a regression fails |
| 16 | // the build instead of a handset. |
| 17 | // |
| 18 | // Usage: bare scripts/verify-bundle-static.mjs [path/to/worklet.bundle] |
| 19 | import fs from 'bare-fs' |
| 20 | import path from 'bare-path' |
| 21 | import process from 'bare-process' |
| 22 | import b4a from 'b4a' |
| 23 | import Bundle from 'bare-bundle' |
| 24 | |
| 25 | const bundlePath = process.argv[2] || 'android/app/src/main/assets/worklet.bundle' |
| 26 | const staticDir = path.resolve('node_modules/favela-surface/static') |
| 27 | |
| 28 | const bundle = Bundle.from(fs.readFileSync(bundlePath)) |
| 29 | const files = fs.readdirSync(staticDir).filter((f) => f.endsWith('.js')).sort() |
| 30 | if (!files.length) { |
| 31 | console.error('verify-bundle-static: no .js files in ' + staticDir + ' — wrong directory, not a pass') |
| 32 | process.exit(1) |
| 33 | } |
| 34 | |
| 35 | const missing = [] |
| 36 | const differ = [] |
| 37 | for (const f of files) { |
| 38 | const key = '/node_modules/favela-surface/static/' + f |
| 39 | if (!bundle.exists(key)) { missing.push(f); continue } |
| 40 | if (!b4a.equals(bundle.read(key), fs.readFileSync(path.join(staticDir, f)))) differ.push(f) |
| 41 | } |
| 42 | |
| 43 | if (missing.length || differ.length) { |
| 44 | if (missing.length) console.error('verify-bundle-static: NOT in ' + bundlePath + ': ' + missing.join(', ')) |
| 45 | if (differ.length) console.error('verify-bundle-static: bytes DIFFER from static/: ' + differ.join(', ')) |
| 46 | process.exit(1) |
| 47 | } |
| 48 | console.log('verify-bundle-static: all ' + files.length + ' favela-surface static files are in ' + bundlePath) |