diff options
Diffstat (limited to 'build.js')
| -rw-r--r-- | build.js | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -105,6 +105,8 @@ self.addEventListener('fetch', (e) => { if (u.pathname.startsWith('/live/') || u.pathname.startsWith('/vmedia/hls')) return; // The developer docs are their own page, not the app: never the offline shell. if (u.pathname === '/docs' || u.pathname.startsWith('/docs/')) return; + // Nor is a name's pay page (/<name>/receive): a visitor's page from the server. + if (/^\\/[^/]+\\/(receive|pay)\\/?$/i.test(u.pathname) || u.pathname.startsWith('/pay/')) return; if (req.mode === 'navigate') { // Opening the app (/, the installed app's and the Android app's start @@ -242,6 +244,19 @@ export async function buildJsQr({ minify = true } = {}) { return iife(await result.outputs[0].text()); } +// The public pay page (v3.coinos.io/<name>/receive): its own small +// document with the script inline, not the app. See src/pay-page.js. +export async function buildPayPage({ minify = true } = {}) { + const result = await Bun.build({ entrypoints: ['./src/pay-page.js'], target: 'browser', minify }); + if (!result.success) { + for (const log of result.logs) console.error(log); + throw new Error('pay page bundle failed'); + } + const js = iife(await result.outputs[0].text()).replace(/<\/script/gi, '<\\/script'); + const tpl = await Bun.file('./src/pay-page.html').text(); + return tpl.replace('/*PAY_PAGE_JS*/', () => js); +} + // Standalone bundle for the NIP-46 remote-signer client — loaded on demand by // nostr-login.js the first time a bunker/nostrconnect login happens. export async function buildNip46({ minify = true } = {}) { @@ -623,6 +638,8 @@ if (import.meta.main) { for (const f of readdirSync('static/' + d)) await Bun.write(`dist/${d}/${f}`, Bun.file(`static/${d}/${f}`)); // the developer docs, a plain page at /docs/ for (const f of readdirSync('static/docs')) await Bun.write(`dist/docs/${f}`, Bun.file(`static/docs/${f}`)); + // the public pay page, served by nginx for /<name>/receive and /<name>/pay + await Bun.write('dist/pay/index.html', await buildPayPage()); const kb = (Buffer.byteLength(html) / 1024).toFixed(0); const jkb = (Buffer.byteLength(rawJs) / 1024).toFixed(0); |
