From bd82d921cdb8285fd5dc74311675ce5964ca54f1 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Sat, 21 Nov 2026 15:29:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?perf(playground):=20inject=20a=20build-time?= =?UTF-8?q?=20trimmed=20system=20list=20=E2=80=94=20the=20full=20616=20KB?= =?UTF-8?q?=20catalogue=20no=20longer=20ships=20in=20the=20client=20bundle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The client script imported maps-catalogue.json only to build a {code, name} list for the system select, bundling every entry's tests, invertibility and descriptions into the page (~503 KB of JS). The list is now trimmed in the frontmatter and injected as a data attribute (same pattern as /api), dropping the page's JS to ~76 KB. Prose and the filter placeholder read the count from the same source, so the hardcoded 289 (stale since the 450/457 waves) cannot drift again; this also clears the unused-import eslint error. --- src/pages/playground.astro | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/pages/playground.astro b/src/pages/playground.astro index 7ad9bb5..2fd18b1 100644 --- a/src/pages/playground.astro +++ b/src/pages/playground.astro @@ -1,18 +1,30 @@ --- -// Playground: the full two-layer stack in the browser — pick any of the -// 289 authority systems, optionally vocalize Arabic through the neural +// Playground: the full two-layer stack in the browser — pick any +// authority system, optionally vocalize Arabic through the neural // layer first, transliterate off-main-thread, share the state by URL, // and copy the exact TS that does the same thing. import Base from "../layouts/Base.astro" -import catalogue from "../data/maps-catalogue.json" - +import catalogue from "../data/maps-catalogue.json" with { type: "json" } + +// Importing the whole catalogue from the client script used to bundle +// ~450 KB of map metadata the page never renders. The playground only +// needs {code, name}, so trim it at build time and inject it as +// data; counts read the same source, so prose and placeholder cannot +// drift stale. +interface CatalogueEntry { + data: { name: string } +} +const systems = Object.entries(catalogue as Record).map( + ([code, m]) => ({ code, name: m.data.name }), +) +const systemCount = systems.length --- -
+

Playground

- Runs entirely in your browser: {289} authority systems and the neural + Runs entirely in your browser: {systemCount} authority systems and the neural models for text that has no published system. No text is sent to a server.

@@ -30,7 +42,11 @@ import catalogue from "../data/maps-catalogue.json" - + @@ -109,16 +125,17 @@ import catalogue from "../data/maps-catalogue.json"