Files
infiplot-web/wrangler.jsonc
Kai ki 610dba78b7 feat(persistence): local-first story persistence (IndexedDB + Supabase skeleton)
Remove Cloudflare D1 entirely (4 API routes, lib/db/, Drizzle config/migrations,
drizzle-orm/drizzle-kit deps, wrangler D1/R2/KV bindings) and replace with
browser-local-first architecture:

Open-source build (IndexedDB, no auth):
- lib/persistence/ 5-file module: types, idb adapter (zero-dep, fault-tolerant,
  post-open invalidation retry), localStore (CRUD + sync-reserved metadata +
  slim/rebuild + retention-cap eviction with tombstone reap + sync-state
  protection + last-resort bounded fallback), sessionSlim (voice strip +
  styleRef absent-delete), cloudStore (Supabase skeleton, server-only)
- Autosave: persistence fingerprint (history.length:lastBeatCount:playerName),
  serial saveChain, failure rollback retry, replaySourceRef guard (prevents
  replayed shared stories from clobbering user saves)
- clientStoryPersistence.ts: thin facade (SaveResult discriminated union)
- Stories page: /[locale]/stories with 3-language i18n (zh-CN/en/ja)
- Homepage: book icon entry point in header

Commercial build (Supabase, skeleton only):
- Single table public.stories (JSONB + RLS 4 policies on auth.uid()=user_id)
- supabase/migrations/ DDL (idempotent)
- cloudStore.ts server-only repository, AUTH_ENABLED short-circuit
- Not wired to client this phase

Featured stories: pure fallback (buildFallbackCards + localizeCards), no D1

Includes fixes from 3 rounds of subagent code-review (tasks 16-30):
- CR1: autosave restructure, coerceOrientation, D1 comment cleanup
- CR2: fingerprint+serial+rollback+replay guard, idb post-open retry,
  enforceRetentionCap latent defense, sessionSlim absent invariant
- CR3: single-scene share guard (replaySourceRef), insert-beat fingerprint
  (beats.length), pass3 overflow double-count fix, detach gate unification
2026-06-25 18:19:08 +08:00

67 lines
3.3 KiB
JSON

{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "infiplot",
"main": ".open-next/worker.js",
"compatibility_date": "2025-03-25",
"compatibility_flags": ["nodejs_compat"],
"assets": {
"binding": "ASSETS",
"directory": ".open-next/assets"
},
"observability": {
"enabled": true
},
// Preserve Dashboard-set variables across deployments (Vercel-like behavior).
// Only vars explicitly listed in "vars" below are overwritten; all others
// (set via Dashboard or `wrangler secret put`) survive redeployments.
"keep_vars": true,
// Placement Hint: uncomment to pin Worker execution to a specific region.
// Example: "azure:eastasia" for lowest latency to mainland China.
// Static assets always serve from the edge nearest the user regardless.
// "placement": {
// "region": "azure:eastasia"
// },
// CPU time limit: Workers Paid plan default is 30s, which is sufficient.
// InfiPlot scene pipeline is I/O-bound (5-6 LLM API calls with 3-15s each),
// actual CPU work (JSON parse, string ops) ~200ms. No cpu_ms override needed.
// "limits": {
// "cpu_ms": 30000
// },
// ── Runtime variables ───────────────────────────────────────────────
// Structural vars with safe defaults are listed here. All provider-specific
// vars (TEXT_BASE_URL, TEXT_MODEL, IMAGE_*, VISION_*, TTS_*, etc.) should be
// set via Cloudflare Dashboard (Settings → Variables) or .dev.vars for local
// dev. With "keep_vars": true above, Dashboard values survive redeployments.
"vars": {
"NEXT_PRIVATE_MINIMAL_MODE": "1",
"MOCK_IMAGE": "false"
},
// ── Secrets (set via Dashboard or `wrangler secret put`) ─────────────
// Required (3): TEXT_API_KEY, IMAGE_API_KEY, VISION_API_KEY
// Optional (1): TTS_API_KEY (voice synthesis)
//
// ── Runtime variables (set via Dashboard) ────────────────────────────
// Required (6): TEXT_BASE_URL, TEXT_MODEL, IMAGE_BASE_URL, IMAGE_MODEL,
// VISION_BASE_URL, VISION_MODEL
// Optional (4): TTS_BASE_URL, TTS_SPEECH_MODEL (voice synthesis),
// IMAGE_TIMEOUT_MS, IMAGE_HEDGE_MS (image generation tuning)
//
// ── Build-time variables (set as Build Variables in Workers Builds) ──
// These are inlined at build time, NOT runtime. Set them in Dashboard under
// Settings → Build → Build variables, or as env vars during `pnpm build:cf`.
// All are optional — the app degrades gracefully without them:
// NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY (auth)
// NEXT_PUBLIC_IMAGE_PROXY_URL (browser image proxying)
// NEXT_PUBLIC_UMAMI_SRC, NEXT_PUBLIC_UMAMI_WEBSITE_ID,
// NEXT_PUBLIC_UMAMI_DOMAINS (analytics)
//
// See .dev.vars.example for a full reference of all variables.
// ────────────────────────────────────────────────────────────────────
//
// Story persistence is browser-local (IndexedDB) in the open-source build and
// Supabase (Postgres) in the commercial build — no Cloudflare D1/R2/KV
// bindings are used.
}