From 77f2e9ae56c1279b7df55d338f4e8e3317a4ffbb Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Fri, 20 Mar 2026 22:20:08 -0700 Subject: [PATCH] fix(rpubs): allow public PDF generation + fix zine auto-spawn - Add publicWrite to rpubs module (PDF gen is computational, not a write) - Fix zine auto-spawn: wait for community-sync-ready event instead of fragile 800ms timeout Co-Authored-By: Claude Opus 4.6 --- modules/rpubs/mod.ts | 1 + website/canvas.html | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/rpubs/mod.ts b/modules/rpubs/mod.ts index b1907e7..ff78a84 100644 --- a/modules/rpubs/mod.ts +++ b/modules/rpubs/mod.ts @@ -350,6 +350,7 @@ export const pubsModule: RSpaceModule = { description: "Drop in a document, get a pocket book", scoping: { defaultScope: 'global', userConfigurable: true }, routes, + publicWrite: true, standaloneDomain: "rpubs.online", landingPage: renderLanding, feeds: [ diff --git a/website/canvas.html b/website/canvas.html index 424e186..66e730b 100644 --- a/website/canvas.html +++ b/website/canvas.html @@ -4425,14 +4425,21 @@ // Auto-spawn shape from ?tool= URL param (e.g. ?tool=folk-zine-gen) const toolParam = urlParams.get("tool"); if (toolParam && shapeRegistry.has(toolParam)) { - // Wait for sync to initialize, then auto-place the shape - setTimeout(() => { + const spawnToolShape = () => { newShape(toolParam); - // Clean up URL param without reload const cleanUrl = new URL(window.location.href); cleanUrl.searchParams.delete("tool"); history.replaceState(null, "", cleanUrl.pathname + cleanUrl.search); - }, 800); + }; + // Wait for sync to be ready, or fallback after 2s + if (sync._connected) { + setTimeout(spawnToolShape, 100); + } else { + let spawned = false; + const onReady = () => { if (!spawned) { spawned = true; setTimeout(spawnToolShape, 100); } }; + document.addEventListener("community-sync-ready", onReady, { once: true }); + setTimeout(onReady, 2000); // fallback if sync never fires + } } // Feed shape — pull live data from another layer/module