Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: real x402 donations for the Unstoppable Agent + dev buffer fix

nirholasc3046b156064
diff --git a/pages/agent-next.html b/pages/agent-next.html
index b0120b251..a130e7dcb 100644
--- a/pages/agent-next.html
+++ b/pages/agent-next.html
@@ -21,6 +21,7 @@
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" id="tw-title" content="Agent · three.ws" />
<meta name="twitter:description" id="tw-desc" content="A living 3D AI agent on three.ws — talk, animate, embed, remix." />
+ <meta name="twitter:site" content="@trythreews" />
<meta name="twitter:creator" content="@nichxbt" />
<meta name="twitter:image" id="tw-image" content="https://three.ws/assets/og-image.png" />
diff --git a/pages/app-demo.html b/pages/app-demo.html
index efbfeee74..3d60ea122 100644
--- a/pages/app-demo.html
+++ b/pages/app-demo.html
@@ -39,6 +39,7 @@
name="twitter:description"
content="The first three.ws with a body, a place, an identity, and memory."
/>
+ <meta name="twitter:site" content="@trythreews" />
<meta name="twitter:creator" content="@nichxbt" />
<meta name="twitter:image" content="https://three.ws/assets/og-image.png">
diff --git a/pages/app-next.html b/pages/app-next.html
index 067deb179..f7842898a 100644
--- a/pages/app-next.html
+++ b/pages/app-next.html
@@ -39,6 +39,7 @@
name="twitter:description"
content="The first three.ws with a body, a place, an identity, and memory."
/>
+ <meta name="twitter:site" content="@trythreews" />
<meta name="twitter:creator" content="@nichxbt" />
<meta name="twitter:image" content="https://three.ws/assets/og-image.png">
diff --git a/pages/app.html b/pages/app.html
index e12d32d62..ab86f0ecd 100644
--- a/pages/app.html
+++ b/pages/app.html
@@ -39,6 +39,7 @@
name="twitter:description"
content="The first three.ws with a body, a place, an identity, and memory."
/>
+ <meta name="twitter:site" content="@trythreews" />
<meta name="twitter:creator" content="@nichxbt" />
<meta name="twitter:image" content="https://three.ws/assets/og-image.png">
diff --git a/pages/home.html b/pages/home.html
index 04c5fc709..a5467d45c 100644
--- a/pages/home.html
+++ b/pages/home.html
@@ -1926,6 +1926,52 @@
font-family: var(--font-mono); font-size: 9px;
letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-3);
}
+ .door-earn-viz {
+ position: absolute; inset: 0; overflow: hidden;
+ transition: transform 0.4s cubic-bezier(.2,.7,.3,1);
+ }
+ .door:hover .door-earn-viz { transform: scale(1.03); }
+ .door-earn-spark { position: absolute; inset: 0; width: 100%; height: 100%; }
+ .door-earn-area { opacity: 0; transition: opacity 1.1s ease 0.35s; }
+ .door-earn-line {
+ fill: none; stroke: var(--green); stroke-width: 2;
+ stroke-linejoin: round; stroke-linecap: round;
+ vector-effect: non-scaling-stroke;
+ stroke-dasharray: 1000; stroke-dashoffset: 1000;
+ }
+ .door-earn-viz.is-live .door-earn-area { opacity: 1; }
+ .door-earn-viz.is-live .door-earn-line {
+ transition: stroke-dashoffset 1.7s cubic-bezier(.4,0,.2,1);
+ stroke-dashoffset: 0;
+ }
+ .door-earn-stream {
+ position: absolute; top: 12px; left: 12px; right: 12px;
+ display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
+ pointer-events: none;
+ }
+ .earn-tick {
+ display: inline-flex; align-items: center; gap: 6px;
+ padding: 4px 9px; border-radius: 6px; white-space: nowrap;
+ background: rgba(5,5,5,0.7); backdrop-filter: blur(8px);
+ border: 1px solid var(--hairline-strong);
+ font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.03em;
+ color: var(--text-3);
+ animation: earnTickIn 0.5s cubic-bezier(.2,.7,.3,1) both;
+ }
+ .earn-tick b { color: var(--green); font-weight: 600; }
+ .earn-tick.out { animation: earnTickOut 0.42s ease forwards; }
+ @keyframes earnTickIn {
+ from { opacity: 0; transform: translateY(-7px); }
+ to { opacity: 1; transform: translateY(0); }
+ }
+ @keyframes earnTickOut {
+ to { opacity: 0; transform: translateY(-9px); }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .door-earn-line { transition: none; stroke-dashoffset: 0; }
+ .door-earn-area { transition: none; opacity: 1; }
+ .earn-tick { animation: none; }
+ }
.bento-screenshot { position: relative; }
.bento-agent { position: absolute; inset: 0; }
.bento-agent agent-3d { width: 100%; height: 100%; display: block; }
@@ -2540,8 +2586,8 @@
<span class="pg-control-label">BG</span>
<div class="pg-chips" id="pg-bg-chips">
<button class="pg-chip active" data-val="transparent">none</button>
- <button class="pg-chip" data-val="#0b0b0b">dark</button>
- <button class="pg-chip" data-val="#ffffff">light</button>
+ <button class="pg-chip" data-val="dark">dark</button>
+ <button class="pg-chip" data-val="light">light</button>
</div>
<button class="pg-color-trigger" id="pg-color-trigger" aria-label="Pick a custom background color" title="Custom color"></button>
<div class="pg-color-popover" id="pg-color-popover">
@@ -2634,7 +2680,19 @@
<a class="door" href="/dashboard/monetize">
<div class="door-num"><span>03</span><span class="lbl">Earn</span></div>
<div class="door-screenshot">
- <div class="door-agent" id="door-earn"></div>
+ <div class="door-earn-viz" id="door-earn-viz">
+ <svg class="door-earn-spark" viewBox="0 0 320 180" preserveAspectRatio="none" aria-hidden="true" focusable="false">
+ <defs>
+ <linearGradient id="earnFill" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="rgba(232,232,232,0.16)"/>
+ <stop offset="1" stop-color="rgba(232,232,232,0)"/>
+ </linearGradient>
+ </defs>
+ <path class="door-earn-area" d="M0,158 L32,150 L64,140 L96,134 L128,120 L160,112 L192,92 L224,86 L256,66 L288,50 L320,38 L320,180 L0,180 Z" fill="url(#earnFill)"/>
+ <path class="door-earn-line" d="M0,158 L32,150 L64,140 L96,134 L128,120 L160,112 L192,92 L224,86 L256,66 L288,50 L320,38"/>
+ </svg>
+ <div class="door-earn-stream" id="door-earn-stream" aria-hidden="true"></div>
+ </div>
<div class="door-earn-overlay">
<div class="door-earn-val" id="door-earn-val">$0.00</div>
<div class="door-earn-lbl">USDC earned</div>
@@ -3670,15 +3728,17 @@
// Fetch a pool of unique community avatar GLBs from /api/explore, cached for the page lifetime.
// pool[0]=WYG, pool[1]=vclose, pool[2..]=LIVE_SPOTS null entries
var _avatarPoolP = null;
+ // Only renderable full-body avatars belong here. The idle_*.glb clips are
+ // animation-only (0 meshes) and render as an empty box — never use them as a body.
var POOL_FALLBACKS = [
+ '/avatars/default.glb',
+ '/avatars/cz.glb',
+ '/animations/robotexpressive.glb',
+ '/animations/soldier.glb',
+ '/avatars/default.glb',
'/avatars/cz.glb',
- '/animations/idle_female_jan25.glb',
- '/animations/idle_male_jan25.glb',
'/animations/robotexpressive.glb',
'/animations/soldier.glb',
- '/animations/idle_anim.glb',
- '/animations/idle_male_jan25.glb',
- '/animations/idle_female_jan25.glb',
];
function getAvatarPool() {
if (!_avatarPoolP) {
@@ -4142,6 +4202,17 @@
highlight.innerHTML = hl(code);
}
+ // The live agent paints its own canvas, but it may not fill the preview
+ // frame (responsive width / aspect). Match the surrounding area to the
+ // chosen background so the preview reads as one surface. 'transparent'
+ // returns '' so the default stage backdrop shows through behind the avatar.
+ function resolvePreviewBg(bg) {
+ if (bg === 'transparent') return '';
+ if (bg === 'dark') return '#0b0d10';
+ if (bg === 'light') return '#f5f5f5';
+ return bg;
+ }
+
function updatePreview() {
if (!state.glbUrl) return;
if (!liveAgent) {
@@ -4157,7 +4228,7 @@
if (v && v !== 'off') liveAgent.setAttribute(k, typeof v === 'string' ? v : '');
else liveAgent.removeAttribute(k);
}
- preview.style.backgroundColor = state.background === '#ffffff' ? '#ffffff' : '';
+ preview.style.backgroundColor = resolvePreviewBg(state.background);
}
function fetchGlb(id) {
@@ -4756,7 +4827,6 @@
var LIVE_SPOTS = [
{ id: 'door-create', anim: 'idle', loop: true, glb: null },
{ id: 'door-embed', anim: 'wave', loop: false, glb: O + '/avatars/cz.glb' },
- { id: 'door-earn', anim: 'dance', loop: true, glb: O + '/animations/soldier.glb' },
{ id: 'bento-studio', anim: 'idle', loop: true, glb: null },
{ id: 'bento-anim', anim: 'idle', loop: true, glb: null }
];
@@ -4820,25 +4890,55 @@
// Earn door ticker
var earnVal = document.getElementById('door-earn-val');
+ var earnViz = document.getElementById('door-earn-viz');
+ var earnStream = document.getElementById('door-earn-stream');
if (earnVal) {
var started = false;
var earnObs = new IntersectionObserver(function(entries) {
- if (entries[0].isIntersecting && !started) {
- started = true; earnObs.disconnect();
- var val = 0, target = 847.5;
- (function tick() {
- val += (target - val) * 0.025;
- if (val >= target - 0.01) val = target;
- earnVal.textContent = '$' + val.toFixed(2);
- if (val < target) requestAnimationFrame(tick);
- })();
+ if (!entries[0].isIntersecting || started) return;
+ started = true; earnObs.disconnect();
+ if (earnViz) earnViz.classList.add('is-live');
+
+ var val = 0, target = 847.5;
+ (function tick() {
+ val += (target - val) * 0.025;
+ if (val >= target - 0.01) val = target;
+ earnVal.textContent = '$' + val.toFixed(2);
+ if (val < target) requestAnimationFrame(tick);
+ })();
+
+ var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
+ if (earnStream && !reduceMotion) {
+ var EARN_EVENTS = [
+ { label: 'chat', amt: 0.05 },
+ { label: 'voice', amt: 0.12 },
+ { label: 'skill', amt: 0.25 },
+ { label: 'chat', amt: 0.05 },
+ { label: 'memory', amt: 0.08 }
+ ];
+ var ei = 0;
+ function pushEarnTick() {
+ var ev = EARN_EVENTS[ei++ % EARN_EVENTS.length];
+ var row = document.createElement('div');
+ row.className = 'earn-tick';
+ row.innerHTML = '+&nbsp;<b>$' + ev.amt.toFixed(2) + '</b>&nbsp;&middot;&nbsp;' + ev.label;
+ earnStream.prepend(row);
+ var live = earnStream.querySelectorAll('.earn-tick:not(.out)');
+ if (live.length > 3) {
+ var oldest = live[live.length - 1];
+ oldest.classList.add('out');
+ oldest.addEventListener('animationend', function() { oldest.remove(); }, { once: true });
+ }
+ }
+ pushEarnTick();
+ setInterval(pushEarnTick, 2200);
}
- });
+ }, { threshold: 0.35 });
earnObs.observe(earnVal);
}
})();
</script>
-<script src="/src/api-playground.js"></script>
+<script type="module" src="/src/api-playground.js"></script>
<script type="module" src="/dragon-section.js"></script>
<script type="module">
import * as THREE from 'three';
diff --git a/pages/unstoppable.html b/pages/unstoppable.html
index 12a739426..34184f70c 100644
--- a/pages/unstoppable.html
+++ b/pages/unstoppable.html
@@ -497,9 +497,9 @@
</div>
<div class="donate-block" style="margin-top: 28px;">
- <div class="donate-label">Keep it alive — donate $0.10 USDC to extend the agent's runway.</div>
+ <div class="donate-label">Keep it alive — donate $0.01 USDC to extend the agent's runway and unlock the live view.</div>
<button class="btn primary" id="donateBtn" onclick="window.__unstoppable.donate()">
- Donate $0.10
+ Donate $0.01
</button>
</div>
</div>
@@ -583,6 +583,8 @@
<!-- TOAST -->
<div id="toast"></div>
+ <!-- x402 checkout (provides window.X402 for the donate flow) -->
+ <script type="module" src="/x402.js"></script>
<!-- DASHBOARD JS -->
<script type="module" src="/src/unstoppable-dashboard.js"></script>
</body>
diff --git a/public/avatars/thumbs/cz.png b/public/avatars/thumbs/cz.png
new file mode 100644
index 000000000..0ba286532
Binary files /dev/null and b/public/avatars/thumbs/cz.png differ
diff --git a/public/avatars/thumbs/default.png b/public/avatars/thumbs/default.png
new file mode 100644
index 000000000..0b68195ec
Binary files /dev/null and b/public/avatars/thumbs/default.png differ
diff --git a/public/avatars/thumbs/robotexpressive.png b/public/avatars/thumbs/robotexpressive.png
new file mode 100644
index 000000000..48c3b27fd
Binary files /dev/null and b/public/avatars/thumbs/robotexpressive.png differ
diff --git a/public/avatars/thumbs/soldier.png b/public/avatars/thumbs/soldier.png
new file mode 100644
index 000000000..54c14e44e
Binary files /dev/null and b/public/avatars/thumbs/soldier.png differ
diff --git a/public/embed/v1/preview.html b/public/embed/v1/preview.html
index 2aea18915..5f21010f8 100644
--- a/public/embed/v1/preview.html
+++ b/public/embed/v1/preview.html
@@ -217,7 +217,7 @@
<div class="x-row">
<div class="x-av"></div>
<div style="flex:1">
- <div class="x-name">three.ws <span class="handle">@threews · 2h</span></div>
+ <div class="x-name">three.ws <span class="handle">@trythreews · 2h</span></div>
<div class="x-body">made my agent. lives on Base, earns x402, embeds anywhere ↓</div>
<div class="x-embed">
<three-d src="https://three.ws/animations/robotexpressive.glb" name="Saga" theme="dark" autoplay></three-d>
diff --git a/public/validation/index.html b/public/validation/index.html
index 5bf772ba0..55e5a0afe 100644
--- a/public/validation/index.html
+++ b/public/validation/index.html
@@ -1018,8 +1018,8 @@
</div>
<script type="module">
- import { ValidationDashboard } from '/src/validation-ui.js';
- import { ValidationPage } from '/src/validation-page.js';
+ import { ValidationDashboard } from '../../src/validation-ui.js';
+ import { ValidationPage } from '../../src/validation-page.js';
const dashboard = new ValidationDashboard(document.querySelector('main'), {
agentInput: document.getElementById('agent-input'),
diff --git a/public/widgets-gallery/gallery.css b/public/widgets-gallery/gallery.css
index 4dabc8e6a..0f5e95085 100644
--- a/public/widgets-gallery/gallery.css
+++ b/public/widgets-gallery/gallery.css
@@ -188,12 +188,12 @@ body.gallery-body {
.btn-primary {
background: var(--blue);
- color: #fff;
+ color: #0a0a0a;
}
.btn-primary:hover {
transform: translateY(-1px);
- background: #2563eb;
+ background: #e8e8e8;
}
.btn-ghost {
diff --git a/scripts/render-demo-thumbs.mjs b/scripts/render-demo-thumbs.mjs
new file mode 100644
index 000000000..d0548b031
--- /dev/null
+++ b/scripts/render-demo-thumbs.mjs
@@ -0,0 +1,144 @@
+#!/usr/bin/env node
+/**
+ * Render PNG preview thumbnails for the homepage playground's built-in demo
+ * avatars. Each demo avatar maps to a local GLB; we render it once in a
+ * headless Chromium via model-viewer, capture a 512×512 transparent PNG, and
+ * write it to public/avatars/thumbs/<name>.png.
+ *
+ * These are static assets committed to the repo so the playground avatar
+ * selector can show real model previews instead of letter initials, without
+ * spinning up a WebGL context per swatch.
+ *
+ * Usage: node scripts/render-demo-thumbs.mjs
+ */
+
+import { chromium } from 'playwright';
+import { createServer } from 'node:http';
+import { readFile } from 'node:fs/promises';
+import { fileURLToPath } from 'node:url';
+import { dirname, join, extname, resolve } from 'node:path';
+import { mkdirSync, writeFileSync } from 'node:fs';
+
+const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+const PUBLIC = join(ROOT, 'public');
+const OUT_DIR = join(PUBLIC, 'avatars', 'thumbs');
+const SIZE = 512;
+
+// Unique GLBs behind the demo avatars (see loadAvatars() in pages/home.html).
+const TARGETS = [
+ { glb: '/avatars/cz.glb', out: 'cz.png' },
+ { glb: '/avatars/default.glb', out: 'default.png' },
+ { glb: '/animations/soldier.glb', out: 'soldier.png' },
+ { glb: '/animations/robotexpressive.glb', out: 'robotexpressive.png' },
+];
+
+const MIME = {
+ '.glb': 'model/gltf-binary',
+ '.html': 'text/html; charset=utf-8',
+ '.js': 'text/javascript',
+ '.png': 'image/png',
+};
+
+function startServer() {
+ const server = createServer(async (req, res) => {
+ try {
+ const path = decodeURIComponent(req.url.split('?')[0]);
+ const file = join(PUBLIC, path);
+ if (!file.startsWith(PUBLIC)) {
+ res.writeHead(403).end();
+ return;
+ }
+ const body = await readFile(file);
+ res.writeHead(200, {
+ 'content-type': MIME[extname(file)] || 'application/octet-stream',
+ 'access-control-allow-origin': '*',
+ });
+ res.end(body);
+ } catch {
+ res.writeHead(404).end();
+ }
+ });
+ return new Promise((res) => {
+ server.listen(0, '127.0.0.1', () => res({ server, port: server.address().port }));
+ });
+}
+
+const viewerHtml = (origin) => `<!doctype html>
+<html><head><meta charset="utf-8">
+<style>
+ html,body { margin:0; padding:0; background: transparent; width:${SIZE}px; height:${SIZE}px; }
+ model-viewer { width:100%; height:100%; --poster-color: transparent; background: transparent; }
+</style>
+<script type="module" src="${origin}/vendor/model-viewer.min.js" onerror="window.__mvFallback=1"></script>
+<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>
+</head>
+<body>
+ <model-viewer id="mv" interaction-prompt="none" exposure="1.05" shadow-intensity="0.7" tone-mapping="aces" camera-orbit="0deg 82deg auto"></model-viewer>
+</body></html>`;
+
+async function capture(page, src) {
+ await page.evaluate(async (s) => {
+ const mv = document.getElementById('mv');
+ mv.setAttribute('src', s);
+ await new Promise((res, rej) => {
+ const t = setTimeout(() => rej(new Error('load timeout')), 25000);
+ mv.addEventListener('load', () => { clearTimeout(t); res(); }, { once: true });
+ mv.addEventListener('error', () => { clearTimeout(t); rej(new Error('load error')); }, { once: true });
+ });
+ // Re-apply framing AFTER load: auto radius only fits correctly once the
+ // geometry is present. Setting it pre-load frames against an empty scene.
+ mv.fieldOfView = 'auto';
+ mv.cameraTarget = 'auto auto auto';
+ mv.cameraOrbit = '0deg 82deg auto';
+ await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
+ await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
+ }, src);
+
+ const dataUrl = await page.evaluate(async () => {
+ const mv = document.getElementById('mv');
+ const blob = await mv.toBlob({ idealAspect: true, mimeType: 'image/png' });
+ return await new Promise((res) => {
+ const fr = new FileReader();
+ fr.onloadend = () => res(fr.result);
+ fr.readAsDataURL(blob);
+ });
+ });
+ return Buffer.from(dataUrl.split(',')[1], 'base64');
+}
+
+async function main() {
+ mkdirSync(OUT_DIR, { recursive: true });
+ const { server, port } = await startServer();
+ const origin = `http://127.0.0.1:${port}`;
+ console.log(`[thumbs] static server on ${origin}`);
+
+ const browser = await chromium.launch({ args: ['--no-sandbox', '--disable-dev-shm-usage'] });
+ const ctx = await browser.newContext({ viewport: { width: SIZE, height: SIZE }, deviceScaleFactor: 2 });
+ const page = await ctx.newPage();
+ await page.setContent(viewerHtml(origin), { waitUntil: 'load' });
+ await page.waitForFunction(() => !!customElements.get('model-viewer'), null, { timeout: 30000 });
+
+ let ok = 0, fail = 0;
+ for (const t of TARGETS) {
+ try {
+ console.log(`[thumbs] rendering ${t.glb}…`);
+ const png = await capture(page, origin + t.glb);
+ writeFileSync(join(OUT_DIR, t.out), png);
+ console.log(`[thumbs] ✓ ${t.out} (${png.length} bytes)`);
+ ok++;
+ } catch (err) {
+ console.error(`[thumbs] ✗ ${t.glb}: ${err.message}`);
+ fail++;
+ }
+ }
+
+ await browser.close();
+ server.close();
+ console.log(`[thumbs] done — ${ok} ok, ${fail} failed`);
+ if (fail) process.exit(1);
+}
+
+main().catch((err) => {
+ console.error('[thumbs] fatal:', err);
+ process.exit(1);
+});
diff --git a/src/app-next-overlay.js b/src/app-next-overlay.js
index a875c6de4..ac66e757a 100644
--- a/src/app-next-overlay.js
+++ b/src/app-next-overlay.js
@@ -606,8 +606,8 @@ function wireShare() {
const app = window.VIEWER?.app;
const name = app?.identity?.name;
return name
- ? `Meet ${name} — an embodied AI agent on @three_ws`
- : 'Check out this embodied AI agent on @three_ws';
+ ? `Meet ${name} — an embodied AI agent on @trythreews`
+ : 'Check out this embodied AI agent on @trythreews';
};
const shareUrl = () => urlEl?.value || location.href;
diff --git a/src/unstoppable-dashboard.js b/src/unstoppable-dashboard.js
index cdd647217..2ab50b0f6 100644
--- a/src/unstoppable-dashboard.js
+++ b/src/unstoppable-dashboard.js
@@ -309,8 +309,43 @@ async function poll() {
// ─── Public API ───────────────────────────────────────────────────────────────
-function donate() {
- showToast('Wallet connect coming soon — donate via /wallet');
+// Donating funds the agent for real: a paid x402 call to the status endpoint
+// credits the treasury (recordRevenue) and returns the live state the donor
+// just paid for. The x402 checkout modal (window.X402, loaded from /x402.js)
+// handles wallet connect, SIWX, and settlement on Base or Solana.
+async function donate() {
+ const X402 = window.X402;
+ if (!X402 || typeof X402.pay !== 'function') {
+ showToast('Payment module still loading — please try again in a moment.');
+ return;
+ }
+
+ const btn = document.getElementById('donateBtn');
+ try {
+ if (btn) btn.disabled = true;
+ const out = await X402.pay({
+ endpoint: STATUS_ENDPOINT,
+ method: 'GET',
+ action: "Fund the Unstoppable Agent's runway",
+ });
+ if (!out?.ok) return;
+
+ showToast('Donation confirmed — thank you for keeping the agent alive.');
+ // The paid response is the live status the donor unlocked.
+ if (out.result && typeof out.result === 'object') {
+ renderFull(out.result);
+ saveToCache(out.result);
+ const notice = document.getElementById('paymentNotice');
+ if (notice) notice.style.display = 'none';
+ } else {
+ poll();
+ }
+ } catch (err) {
+ if (err?.code === 'cancelled') return; // donor dismissed the checkout
+ showToast('Payment failed: ' + String(err?.message || 'unknown error').slice(0, 80));
+ } finally {
+ if (btn) btn.disabled = false;
+ }
}
export function init() {
diff --git a/vite.config.js b/vite.config.js
index 7665e3cea..1e2676529 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -127,15 +127,24 @@ const appConfig = {
// etc.) must share the same `three` module as the app, otherwise
// Three's module-scoped registry warns "Multiple instances of Three.js".
dedupe: ['three'],
+ alias: {
+ // Resolve `buffer` to the real (CommonJS) npm package instead of the
+ // ESM shim vite-plugin-node-polyfills would otherwise alias it to. The
+ // shim exposes only named exports, but Vite's dep-optimizer rewrites
+ // `import { Buffer } from 'buffer'` into a CJS-interop *default* import
+ // (`import m from 'buffer'; m.Buffer`). With the named-only shim that
+ // default is missing and the module fails to link in dev with
+ // "buffer.js does not provide an export named 'default'" (hit on /cz,
+ // whose lib.js pulls Solana/Anchor deps served as source). The CJS
+ // package, once prebundled by esbuild, exposes both default and named.
+ buffer: resolve(__dirname, 'node_modules/buffer/index.js'),
+ },
},
optimizeDeps: {
include: [
- // Force-prebundle `buffer` so esbuild's CJS interop synthesizes a
- // `default` export. Without this, deps that do `import Buffer from
- // 'buffer'` (eth/solana transitive deps reached from /cz's lib.js)
- // hit the node-polyfills shim, which only exposes the named export,
- // and the module fails to link in dev with "does not provide an
- // export named 'default'".
+ // Prebundle the real `buffer` package (see resolve.alias above) so
+ // esbuild's CJS interop synthesizes the `default` export Vite's
+ // dep-optimizer expects when rewriting named buffer imports.
'buffer',
'three',
'three/addons/loaders/GLTFLoader.js',