From 2dbf57071e022a1df429ebdecb04f3c56a6f7a2c Mon Sep 17 00:00:00 2001 From: Steven Clontz Date: Thu, 25 Jun 2026 08:08:03 -0500 Subject: [PATCH 01/13] stub out customization --- packages/viewer/src/constants.ts | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/packages/viewer/src/constants.ts b/packages/viewer/src/constants.ts index c1d07495..8b199832 100644 --- a/packages/viewer/src/constants.ts +++ b/packages/viewer/src/constants.ts @@ -4,8 +4,60 @@ const { VITE_BRANCH = 'unknown', VITE_MAIN_BRANCH = 'main', VITE_VERSION = 'unknown', + VITE_CATEGORY = 'topology' } = import.meta.env +interface CategoryConfig { + category: string + objects: string + dataHost: string + contributingUrl: string + helpUrl: string + calloutFeatures: string[] + homeContent: string + showQuestions: boolean + acknowledgement?: { + quote: string + footer: string + dedication: string + } +} + +const topologyConfig:CategoryConfig = { + category: "topology", + objects: "Spaces", + dataHost: "https://pub-65041ca69d744da88ade13abd31ad834.r2.dev", + contributingUrl: "https://code4math.zulipchat.com/#narrow/channel/416467-pi-base/topic/Welcome.20new.20and.20potential.20contributors!.20.F0.9F.91.8B/with/544214230", + helpUrl: "https://github.com/pi-base/data/wiki/", + calloutFeatures: [ + "Search spaces by name/description: [compactifications](https://topology.pi-base.org/spaces?text=compactification)", + "Search spaces by properties: [non-metric continua](https://topology.pi-base.org/spaces?q=compact%20%2B%20connected%20%2B%20t_2%20%2B%20~metrizable)", + "Find counterexamples: [connected spaces need not be path connected](https://topology.pi-base.org/theorems/T000040)", + ], + homeContent: "# Contributing ...", + showQuestions: true, + acknowledgement: { + quote: "Topology is a dense forest of counterexamples. A usable map of the forest is a fine thing.", + footer: "Paraphrased from Mary Ellen Rudin's review of *Counterexamples in Topology*", + dedication: "Dedicated to the memory of our friend and mentor Gary Gruenhage (1947-2023)." + }, +} + +const graphConfig:CategoryConfig = { + category: "graph", + objects: "Graphs", + dataHost: "TODO", + contributingUrl: "TODO", + helpUrl: "https://github.com/pi-base/data-graph/wiki/", + calloutFeatures: [ + "graphs are neat" + ], + homeContent: "# Contributing ...", + showQuestions: false, +} + +export const categoryConfig = VITE_CATEGORY === "graph" ? graphConfig : topologyConfig + export const mainBranch = VITE_MAIN_BRANCH export const defaultHost = VITE_BUNDLE_HOST From 1c9d2d6c4b31dcf3b5089cc71340634ec81e04e4 Mon Sep 17 00:00:00 2001 From: Steven Clontz Date: Thu, 25 Jun 2026 15:34:14 +0000 Subject: [PATCH 02/13] configurable constants for given category --- packages/viewer/package.json | 2 + packages/viewer/src/components/Footer.svelte | 20 +- packages/viewer/src/components/Home.svelte | 146 +++-------- packages/viewer/src/components/Nav.svelte | 16 +- .../components/Search/Results/NotFound.svelte | 4 +- .../viewer/src/components/Shared/Cite.svelte | 9 +- .../src/components/Shared/References.svelte | 4 +- .../src/components/Theorems/Converse.svelte | 4 +- .../viewer/src/components/Traits/Show.svelte | 6 +- packages/viewer/src/constants.ts | 115 ++++++--- packages/viewer/src/errors.ts | 4 +- pnpm-lock.yaml | 233 ++++++++++++------ 12 files changed, 310 insertions(+), 253 deletions(-) diff --git a/packages/viewer/package.json b/packages/viewer/package.json index 4fcda5bb..3d44afa8 100644 --- a/packages/viewer/package.json +++ b/packages/viewer/package.json @@ -32,6 +32,7 @@ "hast-to-hyperscript": "^10.0.3", "hyperscript": "^2.0.2", "jquery": "^3.7.1", + "markdown-it": "^14.2.0", "rehype-katex": "^6.0.3", "remark-rehype": "^10.1.0", "unified": "^10.1.2", @@ -46,6 +47,7 @@ "@types/debug": "^4.1.12", "@types/hyperscript": "0.0.7", "@types/katex": "^0.16.7", + "@types/markdown-it": "^14.1.2", "@types/page": "^1.11.9", "@types/unist": "^2.0.10", "cypress": "^14.3.2", diff --git a/packages/viewer/src/components/Footer.svelte b/packages/viewer/src/components/Footer.svelte index 63f84523..d6eeaf41 100644 --- a/packages/viewer/src/components/Footer.svelte +++ b/packages/viewer/src/components/Footer.svelte @@ -1,20 +1,24 @@
- Data © {new Date().getFullYear()} Steven Clontz and James Dabbs (CC-BY) | Software © {new Date().getFullYear()} James Dabbs (MIT License) | - GitHub + {@html md.renderInline( + categoryConfig.footer(new Date().getFullYear().toString()), + )}
Data last synchonized:
+ + diff --git a/packages/viewer/src/components/Home.svelte b/packages/viewer/src/components/Home.svelte index 74560233..ee4e75f7 100644 --- a/packages/viewer/src/components/Home.svelte +++ b/packages/viewer/src/components/Home.svelte @@ -1,126 +1,48 @@
-

π-Base

-

a community database of topological counterexamples

-
-

- ➜ Search spaces by name/description: - compactifications -

-

- ➜ Search spaces by properties: - non-metric continua -

-

- ➜ Find counterexamples: - connected spaces need not be path connected -

+

π-Base: {categoryConfig.subject}

+

{categoryConfig.slogan}

+
+ {#each categoryConfig.calloutFeatures as feature} +

+ ➜ {@html md.renderInline(feature)} +

+ {/each}
-
-

- Topology is a dense forest of counterexamples. A usable map of the forest - is a fine thing. -

-
- Paraphrased from Mary Ellen Rudin's review of - Counterexamples in Topology -
-

- - Dedicated to the memory of our friend and mentor Gary Gruenhage - (1947-2023). - -

-
-
-

Contributing

-

- π-Base's data and software are open-sourced on GitHub. We rely on - volunteers like yourself - to contribute new spaces, properties, and theorems. -

-

About Us

-

- The π-Base was founded in 2014 by its lead maintainer - James Dabbs. π-Base's lead - mathematical editor and contributing research software engineer - Steven Clontz - joined the project in 2017. -

-

Community

-

- The π-Base is part of the - code4math - community. Join the conversation on either the - code4math Zulip - or the - - π-Base GitHub Discussion board. -

-

- More databases may be discovered at the - Index of Mathematical DataBases. -

-

Special Acknowledgements

-

- Many people have contributed to this project, but a few individuals and - organizations deserve particular recognition: -

- + {#if categoryConfig.acknowledgement} +
+

+ {categoryConfig.acknowledgement.quote} +

+
+ {categoryConfig.acknowledgement.footer} +
+

+ + {categoryConfig.acknowledgement.dedication} + +

+
+
+ {/if} + {@html md.render(categoryConfig.homeContent)}
+ + diff --git a/packages/viewer/src/components/Nav.svelte b/packages/viewer/src/components/Nav.svelte index 7ab55cba..627c336d 100644 --- a/packages/viewer/src/components/Nav.svelte +++ b/packages/viewer/src/components/Nav.svelte @@ -1,7 +1,7 @@
Cite as: - The pi-Base Community. - {title}. + The π-Base Community. + {categoryConfig.citeTitle}. Available at: {$page.url} (Accessed: {new Date().toISOString().split('T')[0]}). diff --git a/packages/viewer/src/components/Shared/References.svelte b/packages/viewer/src/components/Shared/References.svelte index 91318f16..da01cd96 100644 --- a/packages/viewer/src/components/Shared/References.svelte +++ b/packages/viewer/src/components/Shared/References.svelte @@ -1,7 +1,7 @@ @@ -14,7 +14,7 @@ {:else}
  • No references available. If appropriate, please consider contributingcontributing a reference.
  • {/each} diff --git a/packages/viewer/src/components/Theorems/Converse.svelte b/packages/viewer/src/components/Theorems/Converse.svelte index 8f346d39..1ec33aa2 100644 --- a/packages/viewer/src/components/Theorems/Converse.svelte +++ b/packages/viewer/src/components/Theorems/Converse.svelte @@ -1,6 +1,6 @@ -

    Space

    +

    {categoryConfig.object}

    diff --git a/packages/viewer/src/components/Traits/Redundancy.svelte b/packages/viewer/src/components/Traits/Redundancy.svelte index 5c5545af..17ca9d95 100644 --- a/packages/viewer/src/components/Traits/Redundancy.svelte +++ b/packages/viewer/src/components/Traits/Redundancy.svelte @@ -19,7 +19,7 @@
    Notice: This asserted property can be deduced from the other asserted traits for this - space, due to the following theorems. + object, due to the following theorems.
    {/if} diff --git a/packages/viewer/src/components/Traits/Show.svelte b/packages/viewer/src/components/Traits/Show.svelte index 73bf271c..5a85457a 100644 --- a/packages/viewer/src/components/Traits/Show.svelte +++ b/packages/viewer/src/components/Traits/Show.svelte @@ -40,7 +40,7 @@ | undefined -

    Space S{space.id} | Property P{property.id}

    +

    {categoryConfig.object} S{space.id} | Property P{property.id}

    {#if proof} diff --git a/packages/viewer/src/constants.ts b/packages/viewer/src/constants.ts index 4144bf7b..1853b124 100644 --- a/packages/viewer/src/constants.ts +++ b/packages/viewer/src/constants.ts @@ -9,6 +9,7 @@ const { interface CategoryConfig { category: string + object: string objects: string subject: string slogan: string @@ -29,6 +30,7 @@ interface CategoryConfig { const topologyConfig: CategoryConfig = { category: 'topology', + object: 'Space', objects: 'Spaces', subject: 'Topology', slogan: 'a community database of topological counterexamples', @@ -100,6 +102,7 @@ Software © ${currentYear} James Dabbs ([MIT License](https://github.com/pi-base const graphConfig: CategoryConfig = { category: 'graph', + object: 'Graph', objects: 'Graphs', subject: 'Graph Theory', slogan: 'a community database of graph classes', From 801883cb554d5a4f7a4f8203cb86126ab5145abe Mon Sep 17 00:00:00 2001 From: James Dabbs Date: Mon, 6 Jul 2026 09:48:37 -0700 Subject: [PATCH 06/13] chore: standardize on VITE_CATEGORY the VITE_SITE name was just incidental --- bin/build | 6 +++--- doc/deployment.md | 8 ++++---- packages/viewer/src/components/Search/Search.svelte | 2 +- packages/viewer/src/site.ts | 6 +++--- packages/viewer/wrangler.jsonc | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/build b/bin/build index 8ee6a57b..319a97c6 100755 --- a/bin/build +++ b/bin/build @@ -9,10 +9,10 @@ export VITE_BRANCH="${WORKERS_CI_BRANCH:-${CF_PAGES_BRANCH:-$(git rev-parse --abbrev-ref HEAD 2>/dev/null)}}" export VITE_VERSION="${WORKERS_CI_COMMIT_SHA:-${CF_PAGES_COMMIT_SHA:-$(git rev-parse HEAD 2>/dev/null)}}" -# VITE_SITE selects the build flavor (branding/data). It is set per-Worker in +# VITE_CATEGORY selects the build flavor (branding/data). It is set per-Worker in # the Workers Builds environment variables; default to topology if unset. -export VITE_SITE="${VITE_SITE:-topology}" -echo "Building site '${VITE_SITE}' (branch=${VITE_BRANCH}, version=${VITE_VERSION})" +export VITE_CATEGORY="${VITE_CATEGORY:-topology}" +echo "Building site '${VITE_CATEGORY}' (branch=${VITE_BRANCH}, version=${VITE_VERSION})" # Workers Builds (and the GitHub workflows) run `pnpm install` before invoking # this script, so only install when dependencies are actually missing — e.g. diff --git a/doc/deployment.md b/doc/deployment.md index 4b96d85e..186194c0 100644 --- a/doc/deployment.md +++ b/doc/deployment.md @@ -4,9 +4,9 @@ The viewer is migrating from Cloudflare Pages to **Cloudflare Workers** (Static Assets). Two Workers are produced from this single repo, selected at build time -by the `VITE_SITE` flavor flag (see `packages/viewer/src/site.ts`): +by the `VITE_CATEGORY` flavor flag (see `packages/viewer/src/site.ts`): -| Worker | `VITE_SITE` | wrangler env | Site | +| Worker | `VITE_CATEGORY` | wrangler env | Site | | ------------------ | ----------- | ------------ | -------------------------- | | `pi-base-topology` | `topology` | `topology` | `topology.pi-base.org` | | `pi-base-graphs` | `graphs` | `graphs` | `graphs.pi-base.org` (TBD) | @@ -19,7 +19,7 @@ variables Workers Builds injects for branch/commit metadata. ```bash pnpm --filter core build -VITE_SITE=topology pnpm --filter viewer build +VITE_CATEGORY=topology pnpm --filter viewer build pnpm --filter viewer run cf:deploy:topology # or cf:deploy:graphs ``` @@ -30,7 +30,7 @@ Each Worker is connected to this repo through Cloudflare Workers Builds - **Root directory:** repo root - **Build command:** `bin/build` -- **Build environment variable:** `VITE_SITE=topology` (or `graphs`) +- **Build environment variable:** `VITE_CATEGORY=topology` (or `graphs`) - **Deploy command:** `pnpm --filter viewer run cf:deploy:topology` (or `:graphs`) - **Non-production (preview) deploy command:** `pnpm --filter viewer run cf:preview:topology` (or `:graphs`) diff --git a/packages/viewer/src/components/Search/Search.svelte b/packages/viewer/src/components/Search/Search.svelte index 3b395691..a1667d59 100644 --- a/packages/viewer/src/components/Search/Search.svelte +++ b/packages/viewer/src/components/Search/Search.svelte @@ -80,5 +80,5 @@
    - +
    diff --git a/packages/viewer/src/site.ts b/packages/viewer/src/site.ts index 046b29f2..2f59b1cf 100644 --- a/packages/viewer/src/site.ts +++ b/packages/viewer/src/site.ts @@ -1,6 +1,6 @@ -// Per-deployment ("site") configuration, selected at build time via VITE_SITE. +// Per-deployment ("site") configuration, selected at build time via VITE_CATEGORY. // -// The viewer is built once per site (e.g. `VITE_SITE=graphs pnpm build`) and +// The viewer is built once per site (e.g. `VITE_CATEGORY=graphs pnpm build`) and // each build is deployed to its own Cloudflare Worker. For now the only // difference is a branding label; this is the seam where data-bundle host, // tagline, theme, etc. will diverge later. @@ -17,6 +17,6 @@ const sites: Record = { graphs: { key: 'graphs', label: 'π-Base (graphs)' }, } -const key = (import.meta.env.VITE_SITE ?? 'topology') as SiteKey +const key = (import.meta.env.VITE_CATEGORY ?? 'topology') as SiteKey export const site = sites[key] ?? sites.topology diff --git a/packages/viewer/wrangler.jsonc b/packages/viewer/wrangler.jsonc index 6215fbed..ab514358 100644 --- a/packages/viewer/wrangler.jsonc +++ b/packages/viewer/wrangler.jsonc @@ -7,7 +7,7 @@ // // Deploy: wrangler deploy --env topology (or --env graphs) // The per-site differences (branding, bundle host) are baked in at build time - // via the VITE_SITE env var, not configured here. + // via the VITE_CATEGORY env var, not configured here. "$schema": "./node_modules/wrangler/config-schema.json", "name": "pi-base", "main": ".svelte-kit/cloudflare/_worker.js", From f1d0ed00d03c97ef53efd7ce6ed0564218fbf407 Mon Sep 17 00:00:00 2001 From: Steven Clontz Date: Mon, 6 Jul 2026 16:51:00 +0000 Subject: [PATCH 07/13] more spaces->objects --- packages/viewer/src/routes/(app)/spaces/all/+page.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/viewer/src/routes/(app)/spaces/all/+page.svelte b/packages/viewer/src/routes/(app)/spaces/all/+page.svelte index 9135d9f8..f041adbf 100644 --- a/packages/viewer/src/routes/(app)/spaces/all/+page.svelte +++ b/packages/viewer/src/routes/(app)/spaces/all/+page.svelte @@ -1,13 +1,14 @@ - +<Title title={categoryConfig.objects} /> -<h1>Spaces</h1> +<h1>{categoryConfig.objects}</h1> <List spaces={data.spaces} /> From f16521f80a43f29419fb60e42210563a4e2933b2 Mon Sep 17 00:00:00 2001 From: James Dabbs <james.dabbs@gmail.com> Date: Mon, 6 Jul 2026 09:59:21 -0700 Subject: [PATCH 08/13] fix: singularize graph --- doc/deployment.md | 2 +- packages/viewer/src/site.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/deployment.md b/doc/deployment.md index 186194c0..47e95919 100644 --- a/doc/deployment.md +++ b/doc/deployment.md @@ -9,7 +9,7 @@ by the `VITE_CATEGORY` flavor flag (see `packages/viewer/src/site.ts`): | Worker | `VITE_CATEGORY` | wrangler env | Site | | ------------------ | ----------- | ------------ | -------------------------- | | `pi-base-topology` | `topology` | `topology` | `topology.pi-base.org` | -| `pi-base-graphs` | `graphs` | `graphs` | `graphs.pi-base.org` (TBD) | +| `pi-base-graphs` | `graph` | `graphs` | `graphs.pi-base.org` (TBD) | Worker config lives in `packages/viewer/wrangler.jsonc` (Static Assets + named environments). Builds run through `bin/build`, which reads the `WORKERS_CI_*` diff --git a/packages/viewer/src/site.ts b/packages/viewer/src/site.ts index 2f59b1cf..b6462d78 100644 --- a/packages/viewer/src/site.ts +++ b/packages/viewer/src/site.ts @@ -5,7 +5,7 @@ // difference is a branding label; this is the seam where data-bundle host, // tagline, theme, etc. will diverge later. -type SiteKey = 'topology' | 'graphs' +type SiteKey = 'topology' | 'graph' type Site = { key: SiteKey @@ -14,7 +14,7 @@ type Site = { const sites: Record<SiteKey, Site> = { topology: { key: 'topology', label: 'π-Base' }, - graphs: { key: 'graphs', label: 'π-Base (graphs)' }, + graph: { key: 'graph', label: 'π-Base (graphs)' }, } const key = (import.meta.env.VITE_CATEGORY ?? 'topology') as SiteKey From d206a7780f5d4a2d5e9fbac599d52d8d851ee286 Mon Sep 17 00:00:00 2001 From: James Dabbs <james.dabbs@gmail.com> Date: Mon, 6 Jul 2026 10:07:17 -0700 Subject: [PATCH 09/13] fix: buildable graph config --- packages/viewer/src/constants.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/viewer/src/constants.ts b/packages/viewer/src/constants.ts index 1853b124..737c4111 100644 --- a/packages/viewer/src/constants.ts +++ b/packages/viewer/src/constants.ts @@ -107,9 +107,13 @@ const graphConfig: CategoryConfig = { subject: 'Graph Theory', slogan: 'a community database of graph classes', citeTitle: 'π-Base Graph Theory', - contributingUrl: 'TODO', + // TODO: graph-specific contributing docs; must be an absolute URL or the + // prerenderer will crawl it as an internal link and 404 the build + contributingUrl: + 'https://code4math.zulipchat.com/#narrow/channel/416467-pi-base', helpUrl: 'https://github.com/pi-base/data-graph/wiki/', - sentryUrl: 'TODO', + // Empty DSN disables Sentry until a graph-specific project exists + sentryUrl: '', calloutFeatures: ['graphs are neat'], homeContent: '# Contributing ...', showQuestions: false, From c26ca611ac50e664bfce348d904aac8fb74daae4 Mon Sep 17 00:00:00 2001 From: James Dabbs <james.dabbs@gmail.com> Date: Mon, 6 Jul 2026 14:10:26 -0700 Subject: [PATCH 10/13] fix: Questions page looped forever when a dataset has no open questions rollOpenQuestion re-rolled random spaces until it found an undecided (space, property) pair; in a fully-decided dataset (like the nascent graphs one) that never happens, which hung SSR/prerendering. Collect the open questions once and render an empty state when there are none. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --- .../src/components/Questions/Questions.svelte | 71 +++++++++---------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/packages/viewer/src/components/Questions/Questions.svelte b/packages/viewer/src/components/Questions/Questions.svelte index 533c8faa..5c0ff1bf 100644 --- a/packages/viewer/src/components/Questions/Questions.svelte +++ b/packages/viewer/src/components/Questions/Questions.svelte @@ -7,28 +7,17 @@ let openQuestion: | { space: Space; property: Property; trait: Trait | undefined } | undefined = undefined + // Datasets with no undecided (space, property) pairs have no questions to + // roll; openQuestion stays undefined and we render the empty state instead const rollOpenQuestion = () => { - openQuestion = undefined - const ss = $spaces.all - while (openQuestion == undefined) { - const randomSpace = ss[Math.floor(Math.random() * ss.length)] - const openQuestions = $traits - .forSpaceAll(randomSpace) - .map(([p, t]) => { - return { - space: randomSpace, - property: p, - trait: t, - } - }) - .filter(question => question.trait === undefined) - if (openQuestions.length === 0) { - openQuestion = undefined - } else { - openQuestion = - openQuestions[Math.floor(Math.random() * openQuestions.length)] - } - } + const openQuestions = $spaces.all.flatMap(space => + $traits + .forSpaceAll(space) + .filter(([, trait]) => trait === undefined) + .map(([property, trait]) => ({ space, property, trait })), + ) + openQuestion = + openQuestions[Math.floor(Math.random() * openQuestions.length)] } rollOpenQuestion() $: bodyMain = `Does {S${openQuestion?.space.id}} satisfy {P${openQuestion?.property.id}}?` @@ -36,22 +25,26 @@ </script> <div class="text-center my-3"> - <div class="mb-3"> - <button - type="button" - class="btn btn-outline-secondary" - on:click={() => rollOpenQuestion()} - > - <Dice /> Reroll question - </button> - </div> - <div class="lead mb-3" style="font-size:2em"> - <Typeset body={bodyMain} /> - </div> - <div class="mb-3"> - <Typeset body={bodySecondary} /> - </div> - <p> - <small> Disclaimer: some questions cannot be answered in ZFC! </small> - </p> + {#if openQuestion} + <div class="mb-3"> + <button + type="button" + class="btn btn-outline-secondary" + on:click={() => rollOpenQuestion()} + > + <Dice /> Reroll question + </button> + </div> + <div class="lead mb-3" style="font-size:2em"> + <Typeset body={bodyMain} /> + </div> + <div class="mb-3"> + <Typeset body={bodySecondary} /> + </div> + <p> + <small> Disclaimer: some questions cannot be answered in ZFC! </small> + </p> + {:else} + <p class="lead">There are no open questions in this database.</p> + {/if} </div> From e48d847d72f176d02b1f86e16e247da43a7f19d4 Mon Sep 17 00:00:00 2001 From: James Dabbs <james.dabbs@gmail.com> Date: Mon, 6 Jul 2026 14:10:28 -0700 Subject: [PATCH 11/13] Standardize on VITE_CATEGORY=graphs, with per-category bundle hosts - Settle the graph/graphs naming on 'graphs' everywhere; unsupported values now fail the build instead of silently rendering topology - Each category defaults to its own R2 bundle host (data-graphs now publishes to the pi-base-graphs bucket); VITE_BUNDLE_HOST still overrides - Drop site.ts, which nothing imports since categoryConfig took over Requires flipping VITE_CATEGORY from 'graph' to 'graphs' in the pi-base-graphs Worker's build variables. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --- doc/deployment.md | 14 ++++++++++---- packages/viewer/src/constants.ts | 33 +++++++++++++++++++++++++++----- packages/viewer/src/site.ts | 22 --------------------- 3 files changed, 38 insertions(+), 31 deletions(-) delete mode 100644 packages/viewer/src/site.ts diff --git a/doc/deployment.md b/doc/deployment.md index 47e95919..413f02b6 100644 --- a/doc/deployment.md +++ b/doc/deployment.md @@ -4,12 +4,14 @@ The viewer is migrating from Cloudflare Pages to **Cloudflare Workers** (Static Assets). Two Workers are produced from this single repo, selected at build time -by the `VITE_CATEGORY` flavor flag (see `packages/viewer/src/site.ts`): +by the `VITE_CATEGORY` flavor flag (see `categoryConfig` in +`packages/viewer/src/constants.ts`; unset defaults to `topology`, unsupported +values fail the build): | Worker | `VITE_CATEGORY` | wrangler env | Site | | ------------------ | ----------- | ------------ | -------------------------- | | `pi-base-topology` | `topology` | `topology` | `topology.pi-base.org` | -| `pi-base-graphs` | `graph` | `graphs` | `graphs.pi-base.org` (TBD) | +| `pi-base-graphs` | `graphs` | `graphs` | `graphs.pi-base.org` (TBD) | Worker config lives in `packages/viewer/wrangler.jsonc` (Static Assets + named environments). Builds run through `bin/build`, which reads the `WORKERS_CI_*` @@ -69,5 +71,9 @@ Add a semver tag to trigger the [Publish Images CI step](https://github.com/pi-b ## Data -Changes to the data repo invoke the released [compile action](https://github.com/pi-base/data/blob/6cc73f720751910ad4ede8a320c1eeff975ee5c3/.github/workflows/compile.yml#L12), -and upload the compiled bundles to the `pi-base-bundles` S3 bucket. +Changes to a data repo ([pi-base/data](https://github.com/pi-base/data), +[pi-base/data-graphs](https://github.com/pi-base/data-graphs)) invoke that +repo's compile workflow, which uploads the compiled bundle to the +corresponding category's public R2 bucket — the `bundleHost` values in +`packages/viewer/src/constants.ts`. (`pi-base/data` also uploads to the legacy +`pi-base-bundles` S3 bucket.) diff --git a/packages/viewer/src/constants.ts b/packages/viewer/src/constants.ts index 737c4111..03e712be 100644 --- a/packages/viewer/src/constants.ts +++ b/packages/viewer/src/constants.ts @@ -1,5 +1,5 @@ const { - VITE_BUNDLE_HOST = 'https://pub-65041ca69d744da88ade13abd31ad834.r2.dev', // TODO: push down to @pi-base/core? + VITE_BUNDLE_HOST, VITE_BUNDLE_SSE = 'false', VITE_BRANCH = 'unknown', VITE_MAIN_BRANCH = 'main', @@ -9,6 +9,9 @@ const { interface CategoryConfig { category: string + // Public host serving this category's compiled data bundles (each data repo's + // compile workflow publishes to its own R2 bucket) + bundleHost: string object: string objects: string subject: string @@ -30,6 +33,7 @@ interface CategoryConfig { const topologyConfig: CategoryConfig = { category: 'topology', + bundleHost: 'https://pub-65041ca69d744da88ade13abd31ad834.r2.dev', object: 'Space', objects: 'Spaces', subject: 'Topology', @@ -101,7 +105,8 @@ Software © ${currentYear} James Dabbs ([MIT License](https://github.com/pi-base } const graphConfig: CategoryConfig = { - category: 'graph', + category: 'graphs', + bundleHost: 'https://pub-f9343081ef2f4afba3e09cc65216223c.r2.dev', object: 'Graph', objects: 'Graphs', subject: 'Graph Theory', @@ -120,11 +125,29 @@ const graphConfig: CategoryConfig = { footer: () => '', } -export const categoryConfig = - VITE_CATEGORY === 'graph' ? graphConfig : topologyConfig +const configs: Record<string, CategoryConfig> = { + topology: topologyConfig, + graphs: graphConfig, +} + +// Fails the build (during prerendering) rather than silently falling back to +// topology when VITE_CATEGORY is set but unsupported. Unset defaults above. +function selectConfig(category: string): CategoryConfig { + const config = configs[category] + if (!config) { + throw new Error( + `Unsupported VITE_CATEGORY '${category}'; expected one of: ${Object.keys( + configs, + ).join(', ')}`, + ) + } + return config +} + +export const categoryConfig = selectConfig(VITE_CATEGORY) export const mainBranch = VITE_MAIN_BRANCH -export const defaultHost = VITE_BUNDLE_HOST +export const defaultHost = VITE_BUNDLE_HOST ?? categoryConfig.bundleHost export const build = { branch: VITE_BRANCH, diff --git a/packages/viewer/src/site.ts b/packages/viewer/src/site.ts deleted file mode 100644 index b6462d78..00000000 --- a/packages/viewer/src/site.ts +++ /dev/null @@ -1,22 +0,0 @@ -// Per-deployment ("site") configuration, selected at build time via VITE_CATEGORY. -// -// The viewer is built once per site (e.g. `VITE_CATEGORY=graphs pnpm build`) and -// each build is deployed to its own Cloudflare Worker. For now the only -// difference is a branding label; this is the seam where data-bundle host, -// tagline, theme, etc. will diverge later. - -type SiteKey = 'topology' | 'graph' - -type Site = { - key: SiteKey - label: string -} - -const sites: Record<SiteKey, Site> = { - topology: { key: 'topology', label: 'π-Base' }, - graph: { key: 'graph', label: 'π-Base (graphs)' }, -} - -const key = (import.meta.env.VITE_CATEGORY ?? 'topology') as SiteKey - -export const site = sites[key] ?? sites.topology From ac276569ab0d858d543caac3c8df2e3eefd9c154 Mon Sep 17 00:00:00 2001 From: James Dabbs <james.dabbs@gmail.com> Date: Mon, 6 Jul 2026 14:14:44 -0700 Subject: [PATCH 12/13] chore: update worker subdomain names --- bin/e2e | 4 ++-- packages/viewer/cypress.config.ts | 2 +- packages/viewer/wrangler.jsonc | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/e2e b/bin/e2e index de93ae41..4274d409 100755 --- a/bin/e2e +++ b/bin/e2e @@ -24,8 +24,8 @@ fi function baseUrl() { case "$1" in pages | production) echo "https://topology.pi-base.org" ;; - workers) echo "https://pi-base-topology.fragrant-boat-7068.workers.dev" ;; - graphs) echo "https://pi-base-graphs.fragrant-boat-7068.workers.dev" ;; + workers) echo "https://topology.pi-base.workers.dev" ;; + graphs) echo "https://graphs.pi-base.workers.dev" ;; preview) echo "${PREVIEW_URL:-}" ;; *) echo "" ;; esac diff --git a/packages/viewer/cypress.config.ts b/packages/viewer/cypress.config.ts index 378def5d..2dd18a0b 100644 --- a/packages/viewer/cypress.config.ts +++ b/packages/viewer/cypress.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'cypress' // The account's workers.dev subdomain for the viewer Workers (see // doc/deployment.md). Used to address the deployed Workers directly. -const WORKERS_SUBDOMAIN = 'fragrant-boat-7068.workers.dev' +const WORKERS_SUBDOMAIN = 'pi-base.workers.dev' type Mode = 'fixture' | 'live' type Target = { baseUrl: string; mode: Mode } diff --git a/packages/viewer/wrangler.jsonc b/packages/viewer/wrangler.jsonc index ab514358..dc8478a6 100644 --- a/packages/viewer/wrangler.jsonc +++ b/packages/viewer/wrangler.jsonc @@ -22,6 +22,7 @@ // and via the observability API). invocation_logs gives per-request // cpuTimeMs/wallTimeMs; traces give the auto I/O waterfall (bundle fetch). "topology": { + "name": "topology", "observability": { "enabled": true, "logs": { @@ -32,6 +33,7 @@ } }, "graphs": { + "name": "graphs", "observability": { "enabled": true, "logs": { From 12e2c8752da1f9d0167d15c56d57b32c9f66d3d3 Mon Sep 17 00:00:00 2001 From: James Dabbs <james.dabbs@gmail.com> Date: Mon, 6 Jul 2026 14:47:15 -0700 Subject: [PATCH 13/13] chore: finish worker rename in cypress targets and docs The cypress workers/graphs targets still pointed at the old pi-base-<env> hostnames, which no longer resolve on the renamed pi-base.workers.dev subdomain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --- doc/deployment.md | 8 ++++---- doc/testing.md | 8 ++++---- packages/viewer/cypress.config.ts | 4 ++-- packages/viewer/src/components/Footer.svelte | 2 ++ packages/viewer/wrangler.jsonc | 5 +++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/doc/deployment.md b/doc/deployment.md index 413f02b6..b856c7ae 100644 --- a/doc/deployment.md +++ b/doc/deployment.md @@ -8,10 +8,10 @@ by the `VITE_CATEGORY` flavor flag (see `categoryConfig` in `packages/viewer/src/constants.ts`; unset defaults to `topology`, unsupported values fail the build): -| Worker | `VITE_CATEGORY` | wrangler env | Site | -| ------------------ | ----------- | ------------ | -------------------------- | -| `pi-base-topology` | `topology` | `topology` | `topology.pi-base.org` | -| `pi-base-graphs` | `graphs` | `graphs` | `graphs.pi-base.org` (TBD) | +| Worker | `VITE_CATEGORY` | wrangler env | Site | +| ---------- | --------------- | ------------ | ----------------------------------------------------------- | +| `topology` | `topology` | `topology` | `topology.pi-base.org` | +| `graphs` | `graphs` | `graphs` | `graphs.pi-base.workers.dev` (`graphs.pi-base.org` TBD) | Worker config lives in `packages/viewer/wrangler.jsonc` (Static Assets + named environments). Builds run through `bin/build`, which reads the `WORKERS_CI_*` diff --git a/doc/testing.md b/doc/testing.md index e939ec7f..a02bff9f 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -74,8 +74,8 @@ against: | -------------------- | ------------------------------------ | ------- | | `local` (default) | `http://localhost:5173` | fixture | | `pages` | `https://topology.pi-base.org` | live | -| `workers` | `pi-base-topology.…workers.dev` | live | -| `graphs` | `pi-base-graphs.…workers.dev` | live | +| `workers` | `topology.pi-base.workers.dev` | live | +| `graphs` | `graphs.pi-base.workers.dev` | live | | `preview` | `$PREVIEW_URL` | live | The whole suite runs in both modes; assertions are written to hold against the @@ -104,8 +104,8 @@ health-checking each first: <root> $ ./bin/e2e graphs # A Workers preview ("wrangler versions upload" prints a per-version URL) -<root> $ PREVIEW_URL=https://<version>-pi-base-topology.<subdomain>.workers.dev ./bin/e2e preview -<root> $ ./bin/e2e https://<version>-pi-base-topology.<subdomain>.workers.dev +<root> $ PREVIEW_URL=https://<version>-topology.pi-base.workers.dev ./bin/e2e preview +<root> $ ./bin/e2e https://<version>-topology.pi-base.workers.dev ``` Equivalently, per-target package scripts: `pnpm --filter viewer run diff --git a/packages/viewer/cypress.config.ts b/packages/viewer/cypress.config.ts index 2dd18a0b..0defd548 100644 --- a/packages/viewer/cypress.config.ts +++ b/packages/viewer/cypress.config.ts @@ -26,12 +26,12 @@ function targetFor(name: string): Target { return { baseUrl: 'https://topology.pi-base.org', mode: 'live' } case 'workers': return { - baseUrl: `https://pi-base-topology.${WORKERS_SUBDOMAIN}`, + baseUrl: `https://topology.${WORKERS_SUBDOMAIN}`, mode: 'live', } case 'graphs': return { - baseUrl: `https://pi-base-graphs.${WORKERS_SUBDOMAIN}`, + baseUrl: `https://graphs.${WORKERS_SUBDOMAIN}`, mode: 'live', } case 'preview': { diff --git a/packages/viewer/src/components/Footer.svelte b/packages/viewer/src/components/Footer.svelte index d6eeaf41..52777495 100644 --- a/packages/viewer/src/components/Footer.svelte +++ b/packages/viewer/src/components/Footer.svelte @@ -1,6 +1,8 @@ <script lang="ts"> import { categoryConfig } from '@/constants' import markdownit from 'markdown-it' + + // TODO: standardize on one markdown library. const md = markdownit() import Sync from './Dev/Sync.svelte' </script> diff --git a/packages/viewer/wrangler.jsonc b/packages/viewer/wrangler.jsonc index dc8478a6..3bc27dd6 100644 --- a/packages/viewer/wrangler.jsonc +++ b/packages/viewer/wrangler.jsonc @@ -2,8 +2,9 @@ // Cloudflare Workers (Static Assets) configuration for the viewer. // // The same SvelteKit build (`.svelte-kit/cloudflare`) is deployed to two - // Workers via named environments. Cloudflare names an environment's Worker - // `<name>-<env>`, so these deploy as `pi-base-topology` and `pi-base-graphs`. + // Workers via named environments. Each environment sets an explicit `name`, + // so these deploy as `topology` and `graphs`, served at + // `(topology|graphs).pi-base.workers.dev`. // // Deploy: wrangler deploy --env topology (or --env graphs) // The per-site differences (branding, bundle host) are baked in at build time