From 2384f7928299235cd9ad7015b49b58de216bd0e7 Mon Sep 17 00:00:00 2001 From: explodi Date: Wed, 2 Dec 2026 22:39:37 +0100 Subject: [PATCH 1/2] A hold key's fill grows from nothing to full while the key is held bureau-hold-fill had only its 100% frame, and a missing 0% frame starts at the property's resting value, which for scaleX is 1: the fill stood full from the first frame of the hold. It now starts at 0. Claude-Session: https://claude.ai/code/session_015YsDT1mrrucxxz116AeCoP --- kit/tokens.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kit/tokens.ts b/kit/tokens.ts index 6cea34f..f758c4d 100644 --- a/kit/tokens.ts +++ b/kit/tokens.ts @@ -3831,7 +3831,7 @@ export const ANIMATIONS = { tempo: "fill", easing: "linear", fill: "forwards", - frames: [{ at: [100], scaleX: 1 }], + frames: [{ at: [0], scaleX: 0 }, { at: [100], scaleX: 1 }], }, "bureau-keycap-blink": { cycleMs: 480, From daacb24c8fd8a8413ea07e2f430b8852e464fb18 Mon Sep 17 00:00:00 2001 From: explodi Date: Wed, 2 Dec 2026 22:44:56 +0100 Subject: [PATCH 2/2] A website: the kit as Bureau draws it, a library of every component, its foundations and the guide Every picture on the site is drawn by Bureau. `deno task site:pictures` bundles the specimens in site/specimens/, runs each in a Ui of its own on a frozen clock, draws its display list through the Metal backend into a texture no window shows, and writes the PNG (site/specimens/render.mm, the bureau_specimens target). An animation is written as an animated PNG with its frames beside it, and the hero also as its quads alone, the x-ray its slider wipes across. The library's code samples are the source of the functions that drew its pictures. `deno task site` builds the pages into site/dist/: the home page, the library of 104 components in six sections, the foundations read from kit/tokens.ts, and docs/ as the guide. They are static HTML and CSS, and the hero's slider is the one script. The Website workflow draws the pictures on macOS, builds the pages on Ubuntu and publishes main to GitHub Pages; a pull request that touches the site, the kit or the engine builds both and publishes nothing. Claude-Session: https://claude.ai/code/session_015YsDT1mrrucxxz116AeCoP --- .github/workflows/site.yml | 124 ++++ .gitignore | 1 + CMakeLists.txt | 12 + deno.json | 4 +- deno.lock | 6 + docs/integrating.md | 10 + package.json | 1 + site/art/world.png | Bin 0 -> 22231 bytes site/art/world.ts | 382 +++++++++++ site/build.ts | 113 ++++ site/components.ts | 27 + site/favicon.svg | 7 + site/highlight.ts | 171 +++++ site/html.ts | 57 ++ site/layout.ts | 131 ++++ site/pages/docs.ts | 83 +++ site/pages/foundations.ts | 232 +++++++ site/pages/home.ts | 486 ++++++++++++++ site/pages/library.ts | 127 ++++ site/picture.ts | 87 +++ site/pictures.ts | 144 +++++ site/specimens/catalog.ts | 64 ++ site/specimens/controls.tsx | 981 +++++++++++++++++++++++++++++ site/specimens/data.tsx | 896 ++++++++++++++++++++++++++ site/specimens/groups.ts | 26 + site/specimens/hints.tsx | 34 + site/specimens/input.tsx | 448 +++++++++++++ site/specimens/instruments.tsx | 744 ++++++++++++++++++++++ site/specimens/main.tsx | 5 + site/specimens/meters.tsx | 694 ++++++++++++++++++++ site/specimens/mount.tsx | 43 ++ site/specimens/plate.tsx | 44 ++ site/specimens/render.mm | 469 ++++++++++++++ site/specimens/showcase.tsx | 504 +++++++++++++++ site/specimens/specimen.ts | 71 +++ site/specimens/windows.tsx | 747 ++++++++++++++++++++++ site/style.css | 1079 ++++++++++++++++++++++++++++++++ site/xray.js | 25 + 38 files changed, 9078 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/site.yml create mode 100644 site/art/world.png create mode 100644 site/art/world.ts create mode 100644 site/build.ts create mode 100644 site/components.ts create mode 100644 site/favicon.svg create mode 100644 site/highlight.ts create mode 100644 site/html.ts create mode 100644 site/layout.ts create mode 100644 site/pages/docs.ts create mode 100644 site/pages/foundations.ts create mode 100644 site/pages/home.ts create mode 100644 site/pages/library.ts create mode 100644 site/picture.ts create mode 100644 site/pictures.ts create mode 100644 site/specimens/catalog.ts create mode 100644 site/specimens/controls.tsx create mode 100644 site/specimens/data.tsx create mode 100644 site/specimens/groups.ts create mode 100644 site/specimens/hints.tsx create mode 100644 site/specimens/input.tsx create mode 100644 site/specimens/instruments.tsx create mode 100644 site/specimens/main.tsx create mode 100644 site/specimens/meters.tsx create mode 100644 site/specimens/mount.tsx create mode 100644 site/specimens/plate.tsx create mode 100644 site/specimens/render.mm create mode 100644 site/specimens/showcase.tsx create mode 100644 site/specimens/specimen.ts create mode 100644 site/specimens/windows.tsx create mode 100644 site/style.css create mode 100644 site/xray.js diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml new file mode 100644 index 0000000..d50b892 --- /dev/null +++ b/.github/workflows/site.yml @@ -0,0 +1,124 @@ +# The website: Bureau draws the pictures of its own kit on a Mac (Metal), then +# the pages are built around them and published to GitHub Pages. The +# repository's Pages settings must use "GitHub Actions" as the source. +# +# A pull request that touches the site, the kit or the docs builds it all and +# publishes nothing, so a change that would break a picture shows before it is +# merged. Only main is published, whatever starts the run. +name: Website + +on: + push: + branches: [main] + pull_request: + paths: + - "site/**" + - "kit/**" + - "docs/**" + - "src/**" + - "include/**" + - "assets/**" + - "tools/**" + - "CMakeLists.txt" + - "deno.json" + - "deno.lock" + - "package.json" + - ".github/workflows/site.yml" + workflow_dispatch: + +permissions: + contents: read + +# One deployment at a time; a newer push waits instead of cancelling one in progress. +concurrency: + group: pages-${{ github.ref }} + cancel-in-progress: false + +jobs: + pictures: + name: Draw the pictures + runs-on: macos-26 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.9.6 + + - name: Dependencies + run: | + brew install ninja + deno install --frozen + + - name: Keep the pinned Hermes between runs + uses: actions/cache@v4 + with: + path: third_party/hermes + key: hermes-${{ runner.os }}-${{ hashFiles('third_party/hermes.pin.json') }} + + - name: Hermes + run: deno task hermes + + - name: Pictures + run: deno task site:pictures + + - uses: actions/upload-artifact@v4 + with: + name: pictures + path: build/site/pictures + if-no-files-found: error + + build: + name: Build the website + needs: pictures + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.9.6 + + - run: deno install --frozen + + - uses: actions/download-artifact@v4 + with: + name: pictures + path: pictures + + - id: pages + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + uses: actions/configure-pages@v5 + + - name: Pages + run: deno task site + env: + SITE_PICTURES: pictures + # The path the site is served under, such as /bureau, for 404.html. + BASE_PATH: ${{ steps.pages.outputs.base_path }} + + - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + uses: actions/upload-pages-artifact@v3 + with: + path: site/dist + + deploy: + name: Publish to GitHub Pages + needs: build + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index bfa95e9..ec87e0f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /compile_commands.json node_modules .DS_Store +/site/dist/ diff --git a/CMakeLists.txt b/CMakeLists.txt index d92f6cf..4830732 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,4 +214,16 @@ if(BUREAU_BUILD_TESTS) "${bureau_hermes_framework_dir}") add_test(NAME bureau_ui_tests COMMAND bureau_ui_tests) endif() + + # The website's pictures: Bureau draws its own kit through the Metal backend + # (site/specimens/render.mm, run by `deno task site:pictures`). + if(TARGET bureau_js AND TARGET bureau_metal) + add_executable(bureau_specimens site/specimens/render.mm) + target_compile_options(bureau_specimens PRIVATE -fobjc-arc) + target_link_libraries(bureau_specimens PRIVATE bureau_js bureau_metal + "-framework Foundation" "-framework CoreGraphics" "-framework ImageIO" + "-framework UniformTypeIdentifiers") + set_target_properties(bureau_specimens PROPERTIES BUILD_RPATH + "${bureau_hermes_framework_dir}") + endif() endif() diff --git a/deno.json b/deno.json index dfe557f..1056c7d 100644 --- a/deno.json +++ b/deno.json @@ -32,7 +32,9 @@ "bundle": "deno run -A tools/bundle.ts", "bundle:tests": "deno task bundle tests/bundles/literal_entry.tsx bundles/literal && deno task bundle tests/bundles/closure_entry.tsx bundles/closure && deno task bundle tests/bundles/unicode_entry.tsx bundles/unicode && deno task bundle tests/bundles/hello_entry.tsx bundles/hello", "tokens": "deno run --allow-read --allow-write tools/tokens.ts", - "check": "deno check kit tools tests/bundles", + "check": "deno check kit tools tests/bundles site", + "site:pictures": "deno run -A site/pictures.ts", + "site": "deno run --allow-read --allow-write --allow-env site/build.ts", "test": "deno test --allow-all --no-check --sanitize-ops --sanitize-resources kit tools" }, "lint": { diff --git a/deno.lock b/deno.lock index 51c574f..8e35aa7 100644 --- a/deno.lock +++ b/deno.lock @@ -29,6 +29,7 @@ "npm:@vitejs/plugin-react@^6.1.1": "6.2.1_@rolldown+plugin-babel@0.2.4_babel-plugin-react-compiler@1.0.0_vite@8.3.5_@babel+core@7.29.7_rolldown@1.2.16", "npm:@webgpu/glslang@0.0.15": "0.0.15", "npm:babel-plugin-react-compiler@1": "1.0.0", + "npm:marked@17.0.1": "17.0.1", "npm:react-reconciler@0.34.0": "0.34.0_react@19.3.0", "npm:react@19.3.0": "19.3.0", "npm:vite@8": "8.3.5", @@ -642,6 +643,10 @@ "yallist" ] }, + "marked@17.0.1": { + "integrity": "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg==", + "bin": true + }, "ms@2.1.3": { "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, @@ -815,6 +820,7 @@ "npm:@types/react@^19.3.0", "npm:@vitejs/plugin-react@^6.1.1", "npm:babel-plugin-react-compiler@1", + "npm:marked@17.0.1", "npm:react-reconciler@0.34.0", "npm:react@19.3.0", "npm:vite@^8.3.3" diff --git a/docs/integrating.md b/docs/integrating.md index 7828fdd..a040207 100644 --- a/docs/integrating.md +++ b/docs/integrating.md @@ -217,3 +217,13 @@ deno task test The first configure fetches the pinned commits in `third_party/dependencies.cmake`. + +The website in `site/` shows every component as a picture Bureau draws of +itself. Each picture is a specimen in `site/specimens/`: a function that +renders the component, and the words the library sets beside it. + +```sh +deno task site:pictures # every picture, through the Metal backend (a Mac) +deno task site:pictures button # one, by its id +deno task site # the pages, into site/dist/ +``` diff --git a/package.json b/package.json index 228c0c1..21e2abe 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/react-reconciler": "^0.34.0", "@vitejs/plugin-react": "^6.1.1", "babel-plugin-react-compiler": "^1.0.0", + "marked": "17.0.1", "vite": "^8.3.3" } } diff --git a/site/art/world.png b/site/art/world.png new file mode 100644 index 0000000000000000000000000000000000000000..b3a25fff99a25421b49d009f852c639980036706 GIT binary patch literal 22231 zcmW(+XCRyJ*EWNQQG^&ZTD3>iDq@BjwIyb?2`#Ett2VWxwX3vN5n3X4YxZX(Xj7}S z_NKPlTdg<$_e(zH!^yetJm;M2I@k5QHaFF00`dSUC@7c=4RkFjD5&TuC@8h)smR}0 zhq2?xpLvG5+K9m1jSp%GiVnfEe~akRF}Le@h%N&J%1AaFClQDcUo93rhY%EEHKJiQ zjz*^$f?PsG|4}^mFfZtwpR;W?76kbRYY+);`BwXtb}e~5!CrqYLu~d-)@J^5AO5P* zc3AEpJ*nBY@%8fRDm7i>e%nRSL4&^ATurxt1+wVQ3u}+~;N=XJv5?rQTPfid`LW2a zuE^7q{wu|<+va|8nx-^tbSkQGT@RW37e$MKd7{j3GXz1NYPLgelj5u+~&av#eHup+>=x~c6BjMzbK@F6@~~I7r{=`u7Q@H z(eesgH~~KAh~%>=xJMSaOHhL|KVr9{J~HpvOz?czd?!wzDC${3rE7E5+aldAeLM{3 z_LWAW9?}+_vJ|jF=}C1B{U}sn`lSri2VJ86Yap=9Q*z);x=A@gqaB`bw=P+y{c>Af zNRQaXeLtpaG)7(JG$wQpC!FM!A>Ez&Xs?+cP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+ t = Math.imul(t ^ (t >>> 15), t | 1); + t ^= t + Math.imul(t ^ (t >>> 7), t | 61); + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +} +const rand = random(1979); + +/** Smooth value noise over a lattice, for the coast and the woods. */ +function noiseField( + cell: number, + seed: number, +): (x: number, y: number) => number { + const r = random(seed); + const columns = Math.ceil(WIDTH / cell) + 2; + const rows = Math.ceil(HEIGHT / cell) + 2; + const lattice = Array.from({ length: columns * rows }, () => r()); + const at = (i: number, j: number) => lattice[j * columns + i]!; + const fade = (t: number) => t * t * (3 - 2 * t); + return (x, y) => { + const fx = x / cell; + const fy = y / cell; + const i = Math.floor(fx); + const j = Math.floor(fy); + const u = fade(fx - i); + const v = fade(fy - j); + const top = at(i, j) * (1 - u) + at(i + 1, j) * u; + const bottom = at(i, j + 1) * (1 - u) + at(i + 1, j + 1) * u; + return top * (1 - v) + bottom * v; + }; +} + +const coarse = noiseField(70, 11); +const fine = noiseField(18, 23); +const grain = noiseField(5, 37); + +const pixels: Ink[] = new Array(WIDTH * HEIGHT).fill("blueSlate"); +const set = (x: number, y: number, ink: Ink) => { + if (x >= 0 && y >= 0 && x < WIDTH && y < HEIGHT) pixels[y * WIDTH + x] = ink; +}; +const get = (x: number, y: number): Ink => + pixels[ + Math.max(0, Math.min(HEIGHT - 1, y)) * WIDTH + + Math.max(0, Math.min(WIDTH - 1, x)) + ]!; + +/** Land rises to the north and west; the sea opens to the south-east. The + * town's ground stands above it, so its harbour is its southern edge. */ +function height(x: number, y: number): number { + const slope = 1.34 - (y / HEIGHT) * 0.9 - (x / WIDTH) * 0.45; + const h = slope + (coarse(x, y) - 0.5) * 0.32 + (fine(x, y) - 0.5) * 0.12; + return inTown(x, y) && y < TOWN.y1 - 6 ? Math.max(h, SEA + 0.08) : h; +} + +const SEA = 0.5; +const TOWN = { x0: 248, y0: 34, x1: 378, y1: 190, block: 26, street: 4 }; +function inTown(x: number, y: number): boolean { + return x >= TOWN.x0 && x < TOWN.x1 && y >= TOWN.y0 && y < TOWN.y1; +} +const kind: ("sea" | "shore" | "sand" | "land")[] = []; +for (let y = 0; y < HEIGHT; y += 1) { + for (let x = 0; x < WIDTH; x += 1) { + const h = height(x, y); + kind.push( + h < SEA - 0.06 + ? "sea" + : h < SEA + ? "shore" + : h < SEA + 0.025 + ? "sand" + : "land", + ); + } +} +const kindAt = (x: number, y: number) => + kind[ + Math.max(0, Math.min(HEIGHT - 1, y)) * WIDTH + + Math.max(0, Math.min(WIDTH - 1, x)) + ]!; + +// Water, shallows, sand and grass, with a grain of lighter and darker pixels. +for (let y = 0; y < HEIGHT; y += 1) { + for (let x = 0; x < WIDTH; x += 1) { + const g = grain(x, y); + const here = kindAt(x, y); + if (here === "sea") { + set(x, y, height(x, y) < SEA - 0.2 ? "navy" : "blueSlate"); + if (g > 0.86 && (x + y * 3) % 7 === 0) set(x, y, "sky"); + } else if (here === "shore") { + set(x, y, "cyan"); + if (g < 0.3) set(x, y, "sky"); + } else if (here === "sand") { + set(x, y, g > 0.6 ? "skin" : "tan"); + } else { + set(x, y, g > 0.8 ? "lime" : g < 0.1 ? "olive" : "green"); + } + } +} + +// Woods on the high ground: round crowns, lit from the top left. +const woods = noiseField(40, 51); +for (let i = 0; i < 1400; i += 1) { + const x = Math.floor(rand() * WIDTH); + const y = Math.floor(rand() * HEIGHT); + if (kindAt(x, y) !== "land" || woods(x, y) < 0.55) continue; + if (inTown(x - 6, y - 6) || inTown(x + 6, y + 6)) continue; + const r = 3 + Math.floor(rand() * 2); + for (let dy = -r; dy <= r; dy += 1) { + for (let dx = -r; dx <= r; dx += 1) { + if (dx * dx + dy * dy > r * r) continue; + if (kindAt(x + dx, y + dy) !== "land") continue; + const lit = dx + dy < -r / 2; + const shaded = dx + dy > r / 2; + set(x + dx, y + dy, lit ? "green" : shaded ? "olive" : "teal"); + } + } + set(x + r, y + r, "slate"); +} + +// Fields to the north-west, ploughed in stripes. +for (let field = 0; field < 9; field += 1) { + const fx = 10 + Math.floor(rand() * 140); + const fy = 8 + Math.floor(rand() * 120); + const w = 26 + Math.floor(rand() * 20); + const h = 18 + Math.floor(rand() * 14); + const ink: Ink = rand() < 0.5 ? "moss" : "gold"; + for (let y = fy; y < fy + h; y += 1) { + for (let x = fx; x < fx + w; x += 1) { + if (kindAt(x, y) !== "land") continue; + set(x, y, (y - fy) % 4 === 0 ? "grayOlive" : ink); + } + } +} + +// The town: a grid of streets above the harbour, blocks of houses between. +const onStreet = (x: number, y: number) => + (x - TOWN.x0) % TOWN.block < TOWN.street || + (y - TOWN.y0) % TOWN.block < TOWN.street; + +for (let y = TOWN.y0; y < TOWN.y1; y += 1) { + for (let x = TOWN.x0; x < TOWN.x1; x += 1) { + if (kindAt(x, y) !== "land" && kindAt(x, y) !== "sand") continue; + if (onStreet(x, y)) { + set(x, y, "grayMedium"); + if ((x + y) % 2 === 0 && grain(x, y) > 0.55) set(x, y, "gray"); + } else { + set(x, y, "grayLight"); + } + } +} + +const ROOFS: [Ink, Ink, Ink][] = [ + ["red", "redPink", "chocolate"], + ["brown", "tan", "chocolate"], + ["orange", "skin", "brown"], + ["navy", "violet", "valhalla"], + ["grayDark", "grayMedium", "slate"], + ["purple", "pink", "purpleDark"], +]; + +function house(x: number, y: number, w: number, h: number) { + for (let dy = 0; dy < h; dy += 1) { + for (let dx = 0; dx < w; dx += 1) { + const k = kindAt(x + dx, y + dy); + if (k !== "land" && k !== "sand") return; + } + } + const [roof, light, dark] = ROOFS[Math.floor(rand() * ROOFS.length)]!; + // A shadow falls to the south-east. + for (let dy = 1; dy <= h; dy += 1) set(x + w, y + dy, "slate"); + for (let dx = 1; dx <= w; dx += 1) set(x + dx, y + h, "slate"); + for (let dy = 0; dy < h; dy += 1) { + for (let dx = 0; dx < w; dx += 1) { + const edge = dx === 0 || dy === 0 || dx === w - 1 || dy === h - 1; + const ridge = w >= h + ? dy === Math.floor(h / 2) + : dx === Math.floor(w / 2); + const lit = w >= h ? dy < h / 2 : dx < w / 2; + set(x + dx, y + dy, edge ? "black" : ridge ? dark : lit ? light : roof); + } + } +} + +for (let by = TOWN.y0; by < TOWN.y1; by += TOWN.block) { + for (let bx = TOWN.x0; bx < TOWN.x1; bx += TOWN.block) { + const x0 = bx + TOWN.street + 1; + const y0 = by + TOWN.street + 1; + const span = TOWN.block - TOWN.street - 2; + if (rand() < 0.12) { + // A square with a fountain. + for (let y = y0; y < y0 + span; y += 1) { + for (let x = x0; x < x0 + span; x += 1) { + if (kindAt(x, y) === "land") { + set(x, y, (x + y) % 2 ? "green" : "lime"); + } + } + } + const c = Math.floor(span / 2); + for (let dy = -2; dy <= 2; dy += 1) { + for (let dx = -2; dx <= 2; dx += 1) { + if (Math.abs(dx) + Math.abs(dy) <= 3) { + set(x0 + c + dx, y0 + c + dy, "ice"); + } + } + } + set(x0 + c, y0 + c, "sky"); + continue; + } + let y = y0; + while (y < y0 + span - 5) { + const h = 6 + Math.floor(rand() * 5); + let x = x0; + while (x < x0 + span - 5) { + const w = 6 + Math.floor(rand() * 6); + if (x + w <= x0 + span && y + h <= y0 + span) house(x, y, w, h); + x += w + 1; + } + y += h + 1; + } + } +} + +// Piers into the harbour, plank by plank, with boats tied up. +for (let pier = 0; pier < 5; pier += 1) { + const x = TOWN.x0 + 20 + pier * 26; + let y = TOWN.y1 - 20; + while (y < HEIGHT && kindAt(x, y) !== "shore" && kindAt(x, y) !== "sea") { + y += 1; + } + const length = 26 + Math.floor(rand() * 16); + for (let dy = 0; dy < length; dy += 1) { + for (let dx = 0; dx < 3; dx += 1) { + set(x + dx, y + dy, dy % 3 === 0 ? "chocolate" : "brown"); + } + } + for (let boat = 0; boat < 2; boat += 1) { + const by = y + 6 + boat * 12; + const side = boat % 2 === 0 ? 4 : -9; + for (let dy = 0; dy < 5; dy += 1) { + for (let dx = 0; dx < 6; dx += 1) { + const hull = dy === 0 || dy === 4 || dx === 0 || dx === 5; + set(x + side + dx, by + dy, hull ? "chocolate" : "white"); + } + } + } +} + +// Wakes behind boats out at sea. +for (let i = 0; i < 7; i += 1) { + const x = 300 + Math.floor(rand() * 170); + const y = 200 + Math.floor(rand() * 90); + if (kindAt(x, y) !== "sea") continue; + for (let dx = 0; dx < 7; dx += 1) { + for (let dy = 0; dy < 4; dy += 1) { + const hull = dy === 0 || dy === 3 || dx === 0 || dx === 6; + set(x + dx, y + dy, hull ? "black" : dx < 3 ? "red" : "white"); + } + } + for (let t = 1; t < 16; t += 1) { + set(x - t, y + 1 + (t % 3 === 0 ? 0 : 1), t % 2 ? "ice" : "cyan"); + } +} + +// A road out of town to the fields. +for (let y = 0; y < TOWN.y0; y += 1) { + for (let w = 0; w < 4; w += 1) { + const x = TOWN.x0 + 52 + w + Math.round(Math.sin(y / 14) * 6); + if (kindAt(x, y) === "land") set(x, y, "grayMedium"); + } +} + +// The PNG: one row of RGB per line of pixels, each art pixel SCALE times over. +const outWidth = WIDTH * SCALE; +const outHeight = HEIGHT * SCALE; +const raw = new Uint8Array((outWidth * 3 + 1) * outHeight); +for (let y = 0; y < outHeight; y += 1) { + const row = y * (outWidth * 3 + 1); + raw[row] = 0; + for (let x = 0; x < outWidth; x += 1) { + const [r, g, b] = DB32[get(Math.floor(x / SCALE), Math.floor(y / SCALE))]; + raw.set([r, g, b], row + 1 + x * 3); + } +} + +const CRC_TABLE = Array.from({ length: 256 }, (_, n) => { + let c = n; + for (let k = 0; k < 8; k += 1) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; + return c >>> 0; +}); +function crc32(bytes: Uint8Array): number { + let c = 0xffffffff; + for (const byte of bytes) c = CRC_TABLE[(c ^ byte) & 0xff]! ^ (c >>> 8); + return (c ^ 0xffffffff) >>> 0; +} +function chunk(type: string, data: Uint8Array): Uint8Array { + const out = new Uint8Array(12 + data.length); + const view = new DataView(out.buffer); + view.setUint32(0, data.length); + out.set(new TextEncoder().encode(type), 4); + out.set(data, 8); + view.setUint32(8 + data.length, crc32(out.subarray(4, 8 + data.length))); + return out; +} + +const header = new Uint8Array(13); +const headerView = new DataView(header.buffer); +headerView.setUint32(0, outWidth); +headerView.setUint32(4, outHeight); +header.set([8, 2, 0, 0, 0], 8); +const compressed = new Uint8Array( + await new Response( + new Blob([raw]).stream().pipeThrough(new CompressionStream("deflate")), + ).arrayBuffer(), +); +const parts = [ + new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), + chunk("IHDR", header), + chunk("IDAT", compressed), + chunk("IEND", new Uint8Array()), +]; +const png = new Uint8Array(parts.reduce((sum, part) => sum + part.length, 0)); +parts.reduce((at, part) => (png.set(part, at), at + part.length), 0); +const out = new URL("./world.png", import.meta.url); +await Deno.writeFile(out, png); +console.log(out.pathname); diff --git a/site/build.ts b/site/build.ts new file mode 100644 index 0000000..b1430e8 --- /dev/null +++ b/site/build.ts @@ -0,0 +1,113 @@ +/** + * Builds the website into site/dist/ (`deno task site`): static pages that + * need no JavaScript, but for the hero's slider. + * + * - index.html, the home page (pages/home.ts); + * - library.html, every section of the kit with its pictures (pages/library.ts); + * - foundations.html, the token table (pages/foundations.ts); + * - docs/.html for each Markdown file in docs/ (pages/docs.ts); + * - 404.html, which GitHub Pages serves at any missing address. + * + * The pictures come from `deno task site:pictures`, which draws them with + * Bureau into build/site/pictures/ (or the folder SITE_PICTURES names). A + * picture a page shows that is not there fails the build; `--draft` builds + * anyway, with the missing ones named in its place. + * + * Links between pages are relative, so the site works at any address. Only + * 404.html carries a ``: BASE_PATH, such as `/bureau/`, the path the + * site is served under, which the workflow takes from actions/configure-pages. + */ +import { join } from "@std/path"; +import { html } from "./html.ts"; +import { documentOf, href, type Page } from "./layout.ts"; +import { Pictures } from "./picture.ts"; +import { GROUPS, SHOWCASE } from "./specimens/groups.ts"; +import { homePage } from "./pages/home.ts"; +import { libraryPage } from "./pages/library.ts"; +import { foundationsPage, iconFiles } from "./pages/foundations.ts"; +import { docPages } from "./pages/docs.ts"; +import { componentsOf } from "./components.ts"; + +const ROOT = new URL("..", import.meta.url).pathname; +const SITE = join(ROOT, "site"); +const OUT = join(SITE, "dist"); +const draft = Deno.args.includes("--draft"); +const pictures = new Pictures( + Deno.env.get("SITE_PICTURES") ?? join(ROOT, "build/site/pictures"), +); +const base = (Deno.env.get("BASE_PATH") ?? "/").replace(/\/?$/, "/"); + +function notFound(): Page { + return { + path: "404.html", + base, + title: "No such page: Bureau", + description: "There is no page at this address.", + section: "none", + body: html`
+

No such page

+

Nothing on the site lives at this address. The + library lists every + component, and the guide says how to put Bureau in a game.

+
`, + }; +} + +const components = await componentsOf(GROUPS); +const pages: Page[] = [ + homePage(GROUPS, pictures, components), + libraryPage(GROUPS, pictures, components), + foundationsPage(SHOWCASE, pictures), + ...docPages(), + notFound(), +]; + +if (pictures.missing.length > 0) { + const message = `pictures missing from ${pictures.folder}: ${ + [...new Set(pictures.missing)].join(", ") + }. Draw them with \`deno task site:pictures\`.`; + if (!draft) throw new Error(message); + console.warn(message); +} + +await Deno.remove(OUT, { recursive: true }).catch(() => {}); +await Deno.mkdir(join(OUT, "pictures"), { recursive: true }); +await Deno.mkdir(join(OUT, "fonts"), { recursive: true }); +await Deno.mkdir(join(OUT, "icons"), { recursive: true }); +await Deno.mkdir(join(OUT, "docs"), { recursive: true }); + +for (const page of pages) { + await Deno.writeTextFile(join(OUT, page.path), documentOf(page)); +} +for (const file of pictures.used) { + await Deno.copyFile(join(pictures.folder, file), join(OUT, "pictures", file)); +} +for (const icon of iconFiles()) { + await Deno.copyFile( + join(ROOT, "assets/icons", icon), + join(OUT, "icons", icon), + ); +} +const FONTS = [ + "Jersey25-Regular.ttf", + "BoldPixels.otf", + "IBMPlexSerif-Regular.ttf", + "IBMPlexSerif-SemiBold.ttf", + "IBMPlexSerif-Bold.ttf", + "diffusion-regular.ttf", +]; +for (const font of FONTS) { + await Deno.copyFile( + join(ROOT, "assets/fonts", font), + join(OUT, "fonts", font), + ); +} +for (const file of ["style.css", "xray.js", "favicon.svg"]) { + await Deno.copyFile(join(SITE, file), join(OUT, file)); +} + +console.log( + `${pages.length} pages and ${pictures.used.size} pictures in ${OUT}`, +); diff --git a/site/components.ts b/site/components.ts new file mode 100644 index 0000000..09f47a4 --- /dev/null +++ b/site/components.ts @@ -0,0 +1,27 @@ +/** + * The components the library shows: of the names its specimens import, those + * that are components when the kit runs (functions, or React's forwardRef and + * memo wrappers), not the types, contexts and helpers imported beside them. + */ +import type { SpecimenGroup } from "./specimens/specimen.ts"; + +const WRAPPERS = [Symbol.for("react.forward_ref"), Symbol.for("react.memo")]; + +export async function componentsOf( + groups: SpecimenGroup[], +): Promise> { + const components = new Set(); + for (const specimen of groups.flatMap((group) => group.specimens)) { + const module = await import( + new URL(`../${specimen.source}`, import.meta.url).href + ) as Record; + for (const name of specimen.names) { + const value = module[name] as { $$typeof?: symbol } | undefined; + if (typeof value === "function") components.add(name); + else if (value?.$$typeof && WRAPPERS.includes(value.$$typeof)) { + components.add(name); + } + } + } + return components; +} diff --git a/site/favicon.svg b/site/favicon.svg new file mode 100644 index 0000000..d765307 --- /dev/null +++ b/site/favicon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/site/highlight.ts b/site/highlight.ts new file mode 100644 index 0000000..0cf2d3e --- /dev/null +++ b/site/highlight.ts @@ -0,0 +1,171 @@ +/** + * Colours for the code on the website: TSX, C++, CMake and shell, each read + * by one regular expression whose named groups say what a run is. A run the + * expression does not name stays plain. + */ +import { escape, type Html, raw } from "./html.ts"; + +const TS_KEYWORDS = [ + "as", + "async", + "await", + "break", + "case", + "catch", + "const", + "continue", + "default", + "else", + "export", + "extends", + "false", + "for", + "from", + "function", + "if", + "import", + "in", + "interface", + "let", + "new", + "null", + "of", + "return", + "satisfies", + "switch", + "this", + "throw", + "true", + "try", + "type", + "typeof", + "undefined", + "while", +]; + +const CPP_KEYWORDS = [ + "auto", + "bool", + "break", + "case", + "class", + "const", + "constexpr", + "continue", + "double", + "else", + "false", + "float", + "for", + "if", + "int", + "namespace", + "nullptr", + "return", + "size_t", + "static", + "struct", + "switch", + "true", + "using", + "void", + "while", +]; + +const SHELL_KEYWORDS = ["cd", "curl", "tar", "deno", "cmake", "git"]; + +const CMAKE_KEYWORDS = [ + "add_subdirectory", + "target_link_libraries", + "set_target_properties", + "set", + "set_property", + "bureau_hermes_by_sdk", +]; + +function words(list: string[]): string { + return `\\b(?:${list.join("|")})\\b`; +} + +const STRING = String + .raw`"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|\x60(?:[^\x60\\]|\\.)*\x60`; + +const GRAMMARS: Record = { + tsx: new RegExp( + [ + String.raw`(?\/\/[^\n]*|\/\*[\s\S]*?\*\/)`, + `(?${STRING})`, + String.raw`(?(?<=<\/?)[A-Za-z][\w.]*)`, + String.raw`(?\b[a-zA-Z][\w-]*(?==[{"]))`, + `(?${words(TS_KEYWORDS)})`, + String.raw`(?\b\d[\d_.]*\b)`, + String.raw`(?\b[A-Z][A-Za-z0-9]*\b)`, + ].join("|"), + "g", + ), + cpp: new RegExp( + [ + String.raw`(?\/\/[^\n]*|\/\*[\s\S]*?\*\/)`, + String.raw`(?^[ \t]*#\w+[^\n]*)`, + `(?${STRING})`, + `(?${words(CPP_KEYWORDS)})`, + String.raw`(?\b\d[\d_.]*f?\b)`, + String + .raw`(?\b(?:bureau|std|facebook|jsi)\b|\b[A-Z][A-Za-z0-9]*\b)`, + ].join("|"), + "gm", + ), + sh: new RegExp( + [ + String.raw`(?#[^\n]*)`, + `(?${STRING})`, + String.raw`(?(?<=^|\|\s*|&&\s*)(?:${ + SHELL_KEYWORDS.join("|") + })\b)`, + String.raw`(?(?<=\s)--?[a-zA-Z][\w-]*)`, + ].join("|"), + "gm", + ), + cmake: new RegExp( + [ + String.raw`(?#[^\n]*)`, + `(?${STRING})`, + `(?${words(CMAKE_KEYWORDS)})`, + String.raw`(?\b[A-Z][A-Z_]{2,}\b|\$\{[^}]*\})`, + ].join("|"), + "g", + ), +}; + +const ALIASES: Record = { + ts: "tsx", + typescript: "tsx", + jsx: "tsx", + js: "tsx", + "c++": "cpp", + cc: "cpp", + h: "cpp", + objcpp: "cpp", + shell: "sh", + bash: "sh", + zsh: "sh", +}; + +/** The code's runs, each in a span named for what it is. */ +export function highlight(code: string, language: string): Html { + const grammar = GRAMMARS[ALIASES[language] ?? language]; + if (!grammar) return raw(escape(code)); + let out = ""; + let at = 0; + for (const match of code.matchAll(grammar)) { + const kind = Object.entries(match.groups ?? {}).find(([, value]) => + value !== undefined + )?.[0]; + if (!kind || match[0] === "") continue; + out += escape(code.slice(at, match.index)); + out += `${escape(match[0])}`; + at = match.index! + match[0].length; + } + out += escape(code.slice(at)); + return raw(out); +} diff --git a/site/html.ts b/site/html.ts new file mode 100644 index 0000000..76d6b5b --- /dev/null +++ b/site/html.ts @@ -0,0 +1,57 @@ +/** + * HTML as tagged templates: `html\`

${text}

\`` escapes what it is given, + * unless it is HTML already (a nested template, or `raw`). + */ + +export class Html { + constructor(readonly value: string) {} + toString(): string { + return this.value; + } +} + +export type Part = Html | string | number | boolean | null | undefined | Part[]; + +const ESCAPES: Record = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", +}; + +export function escape(text: string): string { + return text.replace(/[&<>"']/g, (character) => ESCAPES[character]!); +} + +/** Markup that is trusted as it is: the builder's own, never a reader's. */ +export function raw(value: string): Html { + return new Html(value); +} + +function partText(part: Part): string { + if (part instanceof Html) return part.value; + if (Array.isArray(part)) return part.map(partText).join(""); + if (part === null || part === undefined || part === false) return ""; + if (part === true) return ""; + return escape(String(part)); +} + +export function html(strings: TemplateStringsArray, ...parts: Part[]): Html { + let value = strings[0]!; + parts.forEach((part, index) => { + value += partText(part) + strings[index + 1]!; + }); + return new Html(value); +} + +/** Text with `code` spans, as the specimens' words carry them. */ +export function inline(text: string): Html { + return raw( + text.split(/(`[^`]+`)/).map((piece) => + piece.startsWith("`") && piece.endsWith("`") && piece.length > 1 + ? `${escape(piece.slice(1, -1))}` + : escape(piece) + ).join(""), + ); +} diff --git a/site/layout.ts b/site/layout.ts new file mode 100644 index 0000000..50ed1bf --- /dev/null +++ b/site/layout.ts @@ -0,0 +1,131 @@ +/** + * The frame around every page of the website: the document, the menu bar + * along its top and the footer. Links are relative, so the site works at any + * address; only 404.html, served at any address, carries a ``. + */ +import * as posix from "@std/path/posix"; +import { type Html, html, type Part } from "./html.ts"; + +export const REPOSITORY = Deno.env.get("SITE_REPOSITORY_URL") ?? + "https://github.com/explodi/bureau"; + +export type Section = "home" | "library" | "foundations" | "docs" | "none"; + +export interface Page { + /** Its path in the built site, such as `docs/integrating.html`. */ + path: string; + title: string; + description: string; + section: Section; + body: Html; + /** Scripts the page runs, as paths in the built site. */ + scripts?: string[]; + /** A ``, for a page served at any address. */ + base?: string; +} + +/** `to`, a path in the built site, as seen from the page at `from`. */ +export function href(from: string, to: string): string { + const [path, fragment] = to.split("#") as [string, string | undefined]; + let relative = path === "" + ? "" + : posix.relative(posix.dirname(from), path) || posix.basename(path); + if (relative.endsWith("index.html") && relative !== "index.html") { + relative = relative.slice(0, -"index.html".length); + } + return fragment === undefined ? relative : `${relative}#${fragment}`; +} + +const NAVIGATION: { section: Section; label: string; path: string }[] = [ + { section: "library", label: "Library", path: "library.html" }, + { section: "foundations", label: "Foundations", path: "foundations.html" }, + { section: "docs", label: "Guide", path: "docs/integrating.html" }, +]; + +function menuBar(page: Page): Html { + return html` + + `; +} + +function footer(page: Page): Html { + return html`
+ +
`; +} + +export function documentOf(page: Page): string { + const scripts: Part = (page.scripts ?? []).map((script) => + html`` + ); + return `\n` + html` + + + + + ${page.base ? html`` : ""} + ${page.title} + + + + + + ${scripts} + + + + ${menuBar(page)} +
+ ${page.body} +
+ ${footer(page)} + + + `.value; +} diff --git a/site/pages/docs.ts b/site/pages/docs.ts new file mode 100644 index 0000000..8553cbc --- /dev/null +++ b/site/pages/docs.ts @@ -0,0 +1,83 @@ +/** + * The guide: each Markdown file in docs/ as a page, its code coloured, its + * links to other guides kept on the site and its links into the repository + * sent to GitHub. + */ +import { basename } from "@std/path"; +import * as posix from "@std/path/posix"; +import { marked, type Tokens } from "marked"; +import { escape, html, raw } from "../html.ts"; +import { highlight } from "../highlight.ts"; +import { href, type Page, REPOSITORY } from "../layout.ts"; + +const DOCS = new URL("../../docs/", import.meta.url); + +function slug(text: string): string { + return text.toLowerCase().replace(/<[^>]+>/g, "").replace(/[^\w\s-]/g, "") + .trim().replace(/\s+/g, "-"); +} + +/** Where a link in docs/ leads on the site. */ +export function rewriteLink(link: string, page: string): string { + if (/^[a-z][\w+.-]*:|^#|^\/\//i.test(link)) return link; + const [path, fragment] = link.split("#") as [string, string | undefined]; + const target = posix.normalize(posix.join("docs", path)); + const suffix = fragment === undefined ? "" : `#${fragment}`; + if (target.startsWith("docs/") && target.endsWith(".md")) { + return href(page, target.replace(/\.md$/, ".html")) + suffix; + } + if (target === "README.md") return href(page, "index.html"); + const kind = target.endsWith("/") || !posix.extname(target) ? "tree" : "blob"; + return `${REPOSITORY}/${kind}/main/${target}${suffix}`; +} + +export function docPages(): Page[] { + const pages: Page[] = []; + for (const entry of Deno.readDirSync(DOCS)) { + if (!entry.isFile || !entry.name.endsWith(".md")) continue; + const source = Deno.readTextFileSync(new URL(entry.name, DOCS)); + const path = `docs/${basename(entry.name, ".md")}.html`; + const headings: { depth: number; text: string; id: string }[] = []; + const renderer = new marked.Renderer(); + renderer.code = ({ text, lang }: Tokens.Code) => + html`
${
+        highlight(text, lang ?? "")
+      }
`.value; + renderer.heading = function ({ tokens, depth, text }: Tokens.Heading) { + const id = slug(text); + headings.push({ depth, text, id }); + const inner = this.parser.parseInline(tokens); + return `${inner}\n`; + }; + renderer.link = function ({ href: link, title, tokens }: Tokens.Link) { + const inner = this.parser.parseInline(tokens); + const titled = title ? ` title="${escape(title)}"` : ""; + return `${inner}`; + }; + const body = marked.parse(source, { async: false, renderer, gfm: true }); + const title = headings.find((heading) => heading.depth === 1)?.text ?? + entry.name; + const sections = headings.filter((heading) => heading.depth === 2); + pages.push({ + path, + title: `${title}: Bureau`, + description: source.split("\n\n")[1]?.replace(/\s+/g, " ").trim() ?? + title, + section: "docs", + body: html`
+ +
${raw(body)}
+
`, + }); + } + return pages; +} diff --git a/site/pages/foundations.ts b/site/pages/foundations.ts new file mode 100644 index 0000000..b4ca5f2 --- /dev/null +++ b/site/pages/foundations.ts @@ -0,0 +1,232 @@ +/** + * The foundations: the token table every component is drawn from, read from + * kit/tokens.ts as the native view reads it, beside Bureau's pictures of it. + */ +import { + ANIMATIONS, + CHROMES, + DB32, + LAYERS, + type PaletteName, + TEMPOS, + TYPE_METRICS, +} from "../../kit/tokens.ts"; +import { type Html, html, inline } from "../html.ts"; +import { href, type Page, REPOSITORY } from "../layout.ts"; +import type { Pictures } from "../picture.ts"; +import type { SpecimenGroup } from "../specimens/specimen.ts"; + +const ICONS = new URL("../../assets/icons/", import.meta.url); + +/** A PNG's size, from its header. */ +function pngSize(file: URL): { width: number; height: number } { + const header = Deno.readFileSync(file).subarray(0, 24); + const view = new DataView(header.buffer, header.byteOffset, 24); + return { width: view.getUint32(16), height: view.getUint32(20) }; +} + +/** The role inks the table shows, in the order a reader meets them. */ +const ROLES = [ + "face", + "paper", + "ink", + "titlebar", + "highlight", + "shadow", + "ring", + "row-selected", + "ink-good", + "ink-warn", + "ink-bad", + "fill-alert", + "fill-notice", + "meter-ink", + "goal", +] as const; + +type Chrome = keyof typeof CHROMES; + +/** A role ink's colour in a chrome, following references down to a hex. */ +function resolve(chrome: Chrome, name: string): string | undefined { + const table = CHROMES[chrome]; + const inks = table.inks as Record; + const bevels = table.bevelInks as Record; + let value: string | undefined = inks[name] ?? bevels[name]; + for (let depth = 0; value && depth < 4; depth += 1) { + if (value.startsWith("#")) return value; + if (value.startsWith("db32-")) { + return DB32[value.slice(5) as PaletteName]; + } + value = inks[value] ?? bevels[value]; + } + return undefined; +} + +function nameOf(hex: string): string { + const found = Object.entries(DB32).find(([, value]) => value === hex); + return found ? found[0] : hex; +} + +function swatch(hex: string | undefined): Html { + if (!hex) return html``; + return html``; +} + +function figure( + path: string, + pictures: Pictures, + showcase: SpecimenGroup, + id: string, + headingId: string, +): Html { + const specimen = showcase.specimens.find((each) => each.id === id); + if (!specimen) throw new Error(`no showcase specimen ${id}`); + return html`
+

${specimen.title}

+

${inline(specimen.about)}

+
${ + pictures.tag(path, id, `${specimen.title}, drawn by Bureau`) + }
+
`; +} + +export function foundationsPage( + showcase: SpecimenGroup, + pictures: Pictures, +): Page { + const path = "foundations.html"; + const icons = [...Deno.readDirSync(ICONS)] + .filter((entry) => entry.isFile && entry.name.endsWith(".png")) + .map((entry) => entry.name) + .sort(); + const animations = Object.keys(ANIMATIONS); + const typeStyles = Object.keys(TYPE_METRICS).length; + return { + path, + title: "Foundations: Bureau's looks, as data", + description: + "The palette, role inks, type styles, bevel recipes, patterns, glyphs and motion every Bureau component is drawn from.", + section: "foundations", + body: html`
+
+

Foundations

+

+ Every look in the kit is named data in + kit/tokens.ts: + inks, bevel recipes, a box's states, ${typeStyles} type styles, patterns + and animations. deno task tokens writes it out as the JSON the + native view reads, so a game changes its looks without touching a + component, and nothing generates CSS. +

+
+ +
+

Palette

+

+ DawnBringer's 32 colours, which the chrome and the art share. A component + names a role, such as face or ink-bad, and each + chrome says which of these it is. +

+
    + ${ + Object.entries(DB32).map(([name, hex]) => + html`
  • ${ + swatch(hex) + }${name}${hex}
  • ` + ) + } +
+
+ +
+

Role inks, in both chromes

+

+ The light chrome is for windows a player opens, titles and closes; the dark + one is for instruments kept over the game and read at a glance. A box with + chrome="dark" restates every role below it, so no component is + told which chrome it sits on. +

+ + + + ${ + ROLES.map((role) => { + const light = resolve("light", role); + const dark = resolve("dark", role); + return html` + + + + + + `; + }) + } + +
RoleLightDark
${role}${swatch(light)} ${light ? nameOf(light) : ""}${swatch(dark)} ${dark ? nameOf(dark) : ""}
+
+ +${figure(path, pictures, showcase, "chromes", "chromes-title")} +${figure(path, pictures, showcase, "type-styles", "type-title")} +${figure(path, pictures, showcase, "bevels", "bevels-title")} +${figure(path, pictures, showcase, "patterns", "patterns-title")} + +
+

Controller glyphs

+

+ ${icons.length} pictures of buttons, sticks, pads and trackpads, which the + kit's prompts choose by the pad in the player's hands. Ninety are from + 1-bit Pixel Icons by + Nikoichu (CC0); the rest were drawn for Bureau. Shown here at three times + their pixels. +

+
    + ${ + icons.map((icon) => { + const { width, height } = pngSize(new URL(icon, ICONS)); + return html`
  • ${
+          icon.replace(/\.png$/,
  • `; + }) + } +
+
+ +
+

Motion

+

+ Two tempos time the kit: snap, ${TEMPOS.snap} ms, for a key + latching or a box appearing, and fill, ${TEMPOS.fill} ms, for + a meter reaching its figure. ${animations.length} named animations are + keyframes and held moments in the same table, which the view plays on the + UI's thread and stills under reduced motion. +

+
    ${ + animations.map((name) => html`
  • ${name}
  • `) + }
+
+ +
+

Layers

+

+ A Layer lifts what it holds out of its box's place in the + stacking order, to one of these levels. A later one paints over an earlier + one and takes the pointer first. +

+
    + ${ + [...LAYERS].reverse().map((layer) => html`
  1. ${layer}
  2. `) + } +
+
+
`, + }; +} + +export function iconFiles(): string[] { + return [...Deno.readDirSync(ICONS)] + .filter((entry) => entry.isFile && entry.name.endsWith(".png")) + .map((entry) => entry.name); +} diff --git a/site/pages/home.ts b/site/pages/home.ts new file mode 100644 index 0000000..6dd4805 --- /dev/null +++ b/site/pages/home.ts @@ -0,0 +1,486 @@ +/** + * The home page: what Bureau is, for a developer deciding whether their game's + * interface should be written in it. Its words follow the README's. + */ +import { type Html, html } from "../html.ts"; +import { highlight } from "../highlight.ts"; +import { href, type Page, REPOSITORY } from "../layout.ts"; +import type { Pictures } from "../picture.ts"; +import type { SpecimenGroup } from "../specimens/specimen.ts"; + +const TSX = `import { useState } from "react"; +import { Box, Text } from "bureau/primitives"; +import { Button } from "bureau/kit/Bureau.tsx"; +import { render } from "bureau/kit/render.ts"; + +function Menu() { + const [presses, setPresses] = useState(0); + return ( + + {\`Pressed \${presses} times\`} + + + ); +} + +render();`; + +const CPP = `auto frame = ui.takeFrame(); +backend.upload(frame.uploads); +if (frame.list) list = std::move(frame.list); + +// ...draw your game, then, in the same pass: +if (list) backend.draw(*list, encoder, width, height); + +ui.refresh(nowMs);`; + +const GET = + `curl -L https://github.com/explodi/bureau/releases/latest/download/bureau.tar.gz | + tar -xz -C third_party`; + +const TASKS = `cd third_party/bureau +deno task hermes # the pinned Hermes, once +deno task tokens ../../ui/tokens.json # the looks, as JSON +deno task bundle ../../ui/main.tsx ../../build/ui # your TSX, as bytecode`; + +const CMAKE = `add_subdirectory(third_party/bureau) +target_link_libraries(game PRIVATE bureau_js bureau_metal)`; + +const BACKENDS: [string, string, string, "tested" | "partly" | "written"][] = [ + ["Metal", "bureau_metal", "Tested", "tested"], + [ + "OpenGL 3.3", + "bureau_opengl", + "Tested on macOS; the ES 3.0 path has not been run", + "partly", + ], + [ + "Vulkan", + "bureau_vulkan", + "Written and compiled, not yet run on a driver", + "written", + ], + [ + "Direct3D 11", + "bureau_d3d11", + "Written, not yet compiled by MSVC or run", + "written", + ], + [ + "Direct3D 12", + "bureau_d3d12", + "Written, not yet compiled by MSVC or run", + "written", + ], +]; + +const IS: [string, string][] = [ + [ + "Bureau is React, for real.", + "It runs the actual react package on a custom reconciler, so hooks, context and the React Compiler all work, and you write strictly typed TSX. You get the programming model and the type checker without learning a new UI language.", + ], + [ + "Bureau is a native UI engine.", + 'Layout comes from Yoga, text from HarfBuzz and FreeType with proper line breaking, and input, focus and scrolling are handled in C++. It handles Latin, Cyrillic and CJK text, and formats numbers, dates and plurals itself, because a game should not need a browser to say "3 coins" in Polish.', + ], + [ + "Bureau is a component kit.", + "Windows, dialogs, buttons, fields, selects, tabs, lists, sheets, charts and meters, all driven by keyboard, mouse, touch and controller, with on-screen glyphs that follow the pad in the player's hands. They share a distinctive bevelled, pixel-font look, defined as data you can change.", + ], + [ + "Bureau is a small seam in your code.", + "You hold one C++ object, feed it input, and draw what it gives you. TypeScript calls your C++ through functions you register.", + ], +]; + +const ISNT: [string, string][] = [ + [ + "It isn't a browser or a web view.", + "There is no HTML, CSS or DOM, and npm packages that touch them will not run. Those are precisely the costs Bureau exists to avoid, and the type checker rejects them, so you find out while writing the code.", + ], + [ + "It isn't React Native.", + "It shares a JavaScript engine with it, Hermes, but draws no platform widgets. Every pixel goes through your renderer, so your UI looks the same on every machine and sits correctly over your game.", + ], + [ + "It isn't a renderer or an engine.", + "It owns no window, no GPU device and no main loop, because your game already has those. It hands you textured quads and you decide when they are drawn.", + ], + [ + "It isn't Dear ImGui.", + "If you want a debug panel in five lines of C++, use an immediate-mode library. Bureau needs a JavaScript engine in your game and a TypeScript toolchain in your build, which is only worth it for an interface your players will spend time in.", + ], +]; + +/** The pictures the kit's section lays out, by specimen id, if drawn. */ +const MOSAIC = [ + "program-window", + "chart-stacked", + "settings", + "sheet", + "prompt-styles", + "menu-bar", + "gamepad-keyboard-ja", + "card-hint", +]; + +const LANGUAGES: [string, string][] = [ + ["en", "English"], + ["pl", "Polish"], + ["ru", "Russian"], + ["ja", "Japanese"], + ["zh", "Chinese"], +]; + +function code(text: string, language: string, label: string): Html { + return html`
+
${label}
+
${highlight(text, language)}
+
`; +} + +function hero(path: string, pictures: Pictures): Html { + const quads = pictures.has("hero-quads"); + // How many quads the renderer was handed for the frame, written beside it. + const counted = pictures.read("hero-quads.json") as + | { quads: number; clips: number } + | undefined; + const handed = counted + ? `${ + counted.quads.toLocaleString("en") + } textured quads in order, each with one of ${counted.clips} clips` + : "textured quads, in order, each with its clip"; + return html` +
+
+

Write your C++ game's UI in React

+
+

+ Bureau draws it in your own render pass, on Metal, Vulkan, Direct3D or + OpenGL, with no browser in the way. +

+

+ Read the guide + Browse the kit +

+

+ MIT licensed, and the interface of + Microlandia. +

+
+
+
+
+ ${pictures.tag( + path, + "hero", + "A game's screen drawn by Bureau: a budget window, a district instrument and controller prompts over a city map.", + { eager: true, className: "xray-ui" }, + )} + ${quads + ? html` + + + ` + : ""} +
+
+ A screen drawn by Bureau through its Metal backend.${quads + ? ` Drag across it to see what your renderer is handed for the frame: ${handed}.` + : ""} +
+
+
+ `; +} + +export function homePage( + groups: SpecimenGroup[], + pictures: Pictures, + components: Set, +): Page { + const path = "index.html"; + const specimens = groups.flatMap((group) => group.specimens); + const titled = new Map(specimens.map((each) => [each.id, each])); + const mosaic = MOSAIC.filter((id) => titled.has(id) && pictures.has(id)); + return { + path, + title: "Bureau: write your C++ game's UI in React", + description: + "Write your C++ game's UI in React and TypeScript, and draw it in your own render pass on Metal, Vulkan, Direct3D or OpenGL, with no browser in the way.", + section: "home", + scripts: ["xray.js"], + body: html` + ${hero(path, pictures)} + +
+
+
+

The interface is where a game loses its time

+

+ Player-facing UI is where a C++ game loses the most time for the least + reward. A real interface needs layout, text shaping in several scripts, + translated strings and plurals, focus, scrolling, animation, and + navigation by mouse, touch, keyboard and controller. Its state changes + constantly and has to stay in step with the game. +

+
+
    +
  • +

    Immediate-mode libraries

    +

    are wonderful for debug tools and quick to start, but they leave + layout, localised text and controller navigation of a shipping + interface to you.

    +
  • +
  • +

    A retained toolkit of your own

    +

    can do all of it, after you have spent years writing it, and every + change to a menu still means recompiling your game.

    +
  • +
  • +

    An embedded browser

    +

    gives you the web's tools, and with them a browser to ship, its + memory and processes, and the work of compositing its output with your + renderer and keeping its frames in step with yours.

    +
  • +
+

+ React already solved the part that makes UI code hard: describe the + screen as a function of state, and let the library work out what + changed. Bureau gives C++ games that model, and nothing else from the web. +

+
+
+ +
+
+
+

Both sides of it

+

+ The interface is TSX, compiled ahead of time to Hermes bytecode: the + game ships bytecode, not source. The game holds one C++ object, feeds + it input, and each frame takes the newest display list and draws it in + the pass it already has. +

+
+
+ ${code(TSX, "tsx", "ui/main.tsx")} + ${code(CPP, "cpp", "A frame of your game")} +
+
+
+ +
+
+
+

Two threads that meet over immutable data

+

+ At run time the UI lives on a thread of its own, so a slow screen + never holds up your frame. React commits into the view as a stream of + integers; the view lays out with Yoga, sets text with HarfBuzz and + paints into quads. Your render thread takes the newest list when it + draws. +

+
+
    +
  1. +

    UI thread, in Hermes

    +
      +
    1. React renders your components
    2. +
    3. Commits, as a stream of integers, into the view
    4. +
    5. Layout (Yoga), text (HarfBuzz) and painting into quads
    6. +
    7. Events reach your handlers
    8. +
    +
  2. +
  3. +

    Your render thread

    +
      +
    1. ui.pointer(), ui.key(): input goes in
    2. +
    3. ui.takeFrame(): the newest display list and atlas pixels
    4. +
    5. backend.draw() in your own pass
    6. +
    7. ui.refresh(nowMs): the UI's animation frames
    8. +
    +
  4. +
+
+
+ +
+
+

What Bureau is, and what it isn't

+
+
    + ${IS.map(([lead, text]) => + html` +
  • +

    ${lead}

    +

    ${text}

    +
  • + ` + )} +
+
    + ${ISNT.map(([lead, text]) => + html` +
  • +

    ${lead}

    +

    ${text}

    +
  • + ` + )} +
+
+
+
+ +
+
+
+

A kit with a look of its own

+

+ ${components + .size} components share a bevelled, pixel-font look, and + the look is data: inks, bevel recipes, type styles and animations in + one token table you can change. Two chromes come with it, light for the + windows a player opens and dark for the instruments kept over the game. +

+

See the whole kit

+
+ +
+
+ +
+
+
+

“3 coins” in Polish, without a browser

+

+ Bureau handles Latin, Cyrillic and CJK text, and formats numbers, dates + and plurals itself. Each language maps the kit's type roles to fonts + that carry its script, and breaks its lines by its own rules. This is + one component in five languages. +

+
+
    + ${LANGUAGES.map(([language, name]) => + html`
  • ${ + pictures.tag( + path, + `treasury-${language}`, + `The treasury window in ${name}`, + ) + }${name}
  • ` + )} +
+
+
+ +
+
+
+

Drawn by the renderer you already have

+

+ A display list is a plain array of textured quads with their clips, so + there is one simple pipeline to draw it: premultiplied blending, one + scissor per run. A backend does that on your device, inside your pass. + With a renderer of your own, bureau::backends::batchesOf + gives you the vertices and the runs to draw yourself. +

+

+ Each backend draws the same scene in tests/backends/, + checked pixel by pixel against values worked out by hand, so a backend + that is new to your platform has a test waiting for it. +

+
+ + + + + + + + + + ${BACKENDS.map(([renderer, target, state, kind]) => + html` + + + + + + ` + )} + +
Your rendererTargetState
${renderer}${target}${state}
+
+
+ +
+
+
+

Put it in your game

+

+ You need CMake, Ninja, a C++20 compiler and + Deno, which runs the TypeScript + toolchain. Each commit of main that passes its tests is + published as a package. +

+
+
    +
  1. +

    Copy the newest package into your repository

    + ${code(GET, "sh", "Shell")} +
  2. +
  3. +

    Fetch Hermes, write out the looks, compile your TSX

    + ${code(TASKS, "sh", "Shell")} +
  4. +
  5. +

    Link Bureau and the backend you draw with

    + ${code(CMAKE, "cmake", "CMakeLists.txt")} +
  6. +
+

+ Read the guide + Bureau on GitHub +

+
+
+ `, + }; +} diff --git a/site/pages/library.ts b/site/pages/library.ts new file mode 100644 index 0000000..f9e97f1 --- /dev/null +++ b/site/pages/library.ts @@ -0,0 +1,127 @@ +/** + * The library: every section of the kit, each specimen with its picture, + * what it is for, the line that imports it and the code that drew it. + */ +import { html, inline } from "../html.ts"; +import { highlight } from "../highlight.ts"; +import type { Page } from "../layout.ts"; +import type { Pictures } from "../picture.ts"; +import type { Specimen, SpecimenGroup } from "../specimens/specimen.ts"; + +const SPECIMENS = new URL("../specimens/", import.meta.url); + +/** The sources of the specimens' files, read once. */ +const sources = new Map(); +for (const entry of Deno.readDirSync(SPECIMENS)) { + if (entry.isFile && entry.name.endsWith(".tsx")) { + sources.set( + entry.name, + Deno.readTextFileSync(new URL(entry.name, SPECIMENS)), + ); + } +} + +/** A specimen's code: its render function, as its file has it. */ +export function specimenCode(specimen: Specimen): string { + const name = specimen.render.name; + for (const [file, source] of sources) { + const start = source.indexOf(`\nfunction ${name}(`); + if (start < 0) continue; + const end = source.indexOf("\n}\n", start); + if (end < 0) throw new Error(`${file}: ${name} has no end`); + return source.slice(start + 1, end + 2); + } + throw new Error( + `${specimen.id}: no top-level "function ${name}(" in site/specimens`, + ); +} + +export function importLine(specimen: Specimen): string { + const names = specimen.names.join(", "); + const from = specimen.source.replace(/^kit\//, "bureau/kit/"); + return `import { ${names} } from "${from}";`; +} + +function specimenEntry(page: string, specimen: Specimen, pictures: Pictures) { + return html`
+
+

${specimen.title}

+

${inline(specimen.about)}

+
+
+ ${pictures.tag(page, specimen.id, `${specimen.title}, drawn by Bureau`)} +
+
${
+    highlight(importLine(specimen), "tsx")
+  }
+
+ The code that drew it +
${highlight(specimenCode(specimen), "tsx")}
+
+
`; +} + +export function libraryPage( + groups: SpecimenGroup[], + pictures: Pictures, + components: Set, +): Page { + const path = "library.html"; + const count = groups.reduce((sum, group) => sum + group.specimens.length, 0); + return { + path, + title: "The kit: Bureau's components", + description: + `Windows, dialogs, keys, fields, sheets, meters, charts and controller prompts: ${components.size} components of Bureau's kit, each drawn by Bureau.`, + section: "library", + body: html`
+ +
+
+

The kit

+

+ ${components.size} components a game imports from + bureau/kit/, in ${count} pictures. Each picture was drawn + by Bureau through its Metal backend, at twice its size, from the code + beside it. +

+

+ Every control answers the mouse, a finger, the keyboard and a + controller. Its looks are token data in + the foundations, so a game can change + them without touching the components. +

+
+ ${ + groups.map((group) => + html` +
+

${group.title}

+ ${group.about + ? html`

${inline(group.about)}

` + : ""} + ${group.specimens.map((specimen) => + specimenEntry(path, specimen, pictures) + )} +
+ ` + ) + } +
+
`, + }; +} diff --git a/site/picture.ts b/site/picture.ts new file mode 100644 index 0000000..d5e7619 --- /dev/null +++ b/site/picture.ts @@ -0,0 +1,87 @@ +/** + * The pictures Bureau drew (`deno task site:pictures`), as the pages show + * them: at their size in UI pixels, which is half their pixels, since they + * are drawn at twice it. An animation is `.png`, an animated PNG, with + * its frames beside it as `..png`: the middle one is the still a + * reader who asks for less motion sees, a hold half held, a fade half done. + */ +import { join } from "@std/path"; +import { type Html, html } from "./html.ts"; +import { href } from "./layout.ts"; + +export class Pictures { + /** The pictures the pages used, by file name, to copy into the site. */ + readonly used = new Set(); + readonly missing: string[] = []; + + constructor(readonly folder: string) {} + + /** A JSON file the renderer wrote beside the pictures, if it is there. */ + read(file: string): unknown { + try { + return JSON.parse(Deno.readTextFileSync(join(this.folder, file))); + } catch { + return undefined; + } + } + + size(file: string): { width: number; height: number } | undefined { + let bytes: Uint8Array; + try { + const handle = Deno.openSync(join(this.folder, file)); + bytes = new Uint8Array(24); + handle.readSync(bytes); + handle.close(); + } catch { + return undefined; + } + const view = new DataView(bytes.buffer); + return { width: view.getUint32(16), height: view.getUint32(20) }; + } + + has(id: string): boolean { + return this.size(`${id}.png`) !== undefined || + this.size(`${id}.0.png`) !== undefined; + } + + /** The `` for a picture, from the page at `page`. */ + tag( + page: string, + id: string, + alt: string, + options: { eager?: boolean; className?: string } = {}, + ): Html { + const file = `${id}.png`; + let frames = 0; + while (this.size(`${id}.${frames}.png`) !== undefined) frames += 1; + const animated = frames > 0; + const held = `${id}.${Math.floor(frames / 2)}.png`; + const size = this.size(file) ?? this.size(held); + if (!size) { + this.missing.push(id); + return html`${id}`; + } + const shown = this.size(file) ? file : held; + this.used.add(shown); + const width = Math.round(size.width / 2); + const height = Math.round(size.height / 2); + const img = html` + ${alt} + `; + if (!animated || shown === held) return img; + this.used.add(held); + return html`${img}`; + } +} diff --git a/site/pictures.ts b/site/pictures.ts new file mode 100644 index 0000000..abd4a05 --- /dev/null +++ b/site/pictures.ts @@ -0,0 +1,144 @@ +/** + * Draws the website's pictures with Bureau itself (`deno task site:pictures`): + * bundles the gallery's TSX, builds the renderer (site/specimens/render.mm) + * and runs every specimen through it into build/site/pictures/. + * + * deno task site:pictures every specimen + * deno task site:pictures --group controls one section's, from its file alone + * deno task site:pictures button select these, by id + * + * The renderer draws through Metal, so this runs on a Mac. A section's file + * bundles on its own with --group, so one that does not compile yet holds up + * only its own pictures. + */ +import { dirname, fromFileUrl, join, relative } from "@std/path"; +import { + manifestOf, + type Specimen, + type SpecimenGroup, +} from "./specimens/specimen.ts"; + +const ROOT = fromFileUrl(new URL("..", import.meta.url)); +const BUILD = join(ROOT, "build"); +const OUT = join(BUILD, "site"); + +async function run(command: string, args: string[], cwd = ROOT) { + const { success } = await new Deno.Command(command, { + args, + cwd, + stdout: "inherit", + stderr: "inherit", + }).spawn().status; + if (!success) throw new Error(`${command} ${args.join(" ")} failed`); +} + +async function modified(path: string): Promise { + try { + return (await Deno.stat(path)).mtime?.getTime(); + } catch { + return undefined; + } +} + +/** The renderer and the tokens, built unless they are newer than their sources. */ +/** Builds the renderer and the token table; ninja does only what changed. */ +async function buildRenderer() { + if (await modified(join(BUILD, "build.ninja")) === undefined) { + await run("cmake", ["-S", ".", "-B", "build", "-G", "Ninja"]); + } + await run("cmake", [ + "--build", + "build", + "--target", + "bureau_specimens", + "bureau_tokens", + ]); +} + +function isGroup(value: unknown): value is SpecimenGroup { + return typeof value === "object" && value !== null && + Array.isArray((value as SpecimenGroup).specimens); +} + +const args = [...Deno.args]; +const groupAt = args.indexOf("--group"); +const groupName = groupAt >= 0 ? args.splice(groupAt, 2)[1] : undefined; +const ids = new Set(args); + +let specimens: Specimen[]; +let entry: string; +if (groupName) { + const file = join(ROOT, "site/specimens", `${groupName}.tsx`); + const module = await import(`file://${file}`) as Record; + const [name, group] = Object.entries(module).find(([, value]) => + isGroup(value) + ) ?? []; + if (!name || !isGroup(group)) throw new Error(`${file} exports no section`); + specimens = group.specimens; + entry = join(OUT, "entries", `${groupName}.tsx`); + await Deno.mkdir(dirname(entry), { recursive: true }); + const from = (path: string) => relative(dirname(entry), path); + await Deno.writeTextFile( + entry, + `import { mount } from "${ + from(join(ROOT, "site/specimens/mount.tsx")) + }";\n` + + `import { ${name} } from "${from(file)}";\n\n` + + `mount(${name}.specimens);\n`, + ); +} else { + const { EVERY_SPECIMEN } = await import("./specimens/groups.ts"); + specimens = EVERY_SPECIMEN; + entry = join(ROOT, "site/specimens/main.tsx"); +} +if (ids.size > 0) { + specimens = specimens.filter((specimen) => ids.has(specimen.id)); + const missing = [...ids].filter((id) => + !specimens.some((specimen) => specimen.id === id) + ); + if (missing.length > 0) throw new Error(`no specimen ${missing.join(", ")}`); +} + +const seen = new Set(); +for (const specimen of specimens) { + if (seen.has(specimen.id)) { + throw new Error(`two specimens are ${specimen.id}`); + } + seen.add(specimen.id); +} + +const bundle = join(OUT, "bundles", groupName ?? "all"); +await run(Deno.execPath(), ["run", "-A", "tools/bundle.ts", entry, bundle]); +await buildRenderer(); + +const pictures = join(OUT, "pictures"); +await Deno.mkdir(pictures, { recursive: true }); +const manifest = join(OUT, `specimens-${groupName ?? "all"}.json`); +await Deno.writeTextFile( + manifest, + JSON.stringify(specimens.map(manifestOf), null, 2), +); +// What the specimens read: Bureau's own assets, and the site's art beside them. +const assets = join(OUT, "assets"); +await Deno.mkdir(assets, { recursive: true }); +for ( + const [name, target] of [ + ...[...Deno.readDirSync(join(ROOT, "assets"))].map((entry) => + [entry.name, join(ROOT, "assets", entry.name)] as const + ), + ["art", join(ROOT, "site/art")] as const, + ] +) { + const link = join(assets, name); + await Deno.remove(link).catch(() => {}); + await Deno.symlink(target, link); +} + +await run(join(BUILD, "bureau_specimens"), [ + join(bundle, "bundle.hbc"), + join(BUILD, "tokens.json"), + assets, + manifest, + pictures, +]); +console.log(`${specimens.length} pictures in ${pictures}`); diff --git a/site/specimens/catalog.ts b/site/specimens/catalog.ts new file mode 100644 index 0000000..e1ea112 --- /dev/null +++ b/site/specimens/catalog.ts @@ -0,0 +1,64 @@ +/** + * The words a game's own catalog adds to the kit's: here, what the on-screen + * keyboard says, which kit/i18n/kit_strings.ts does not carry yet. The mount + * loads it in the language each picture is drawn in. + */ +export const CATALOG = { + en: { + controller: { + textEntry: "Enter text", + select: "Select", + keyboardLanguage: "Language", + keyboardLatin: "ABC", + keyboardKana: "Hiragana", + keyboardKatakana: "Katakana", + keyboardPinyin: "Pinyin", + keyboardHangul: "Hangul", + keyboardShift: "Shift", + keyboardSymbols: "Symbols", + keyboardAccents: "Accents", + keyboardReading: "Reading", + keyboardCommit: "Insert", + keyboardComposeHint: "Enter one reading, then choose a character.", + keyboardNoCandidates: "No characters for this reading", + keyboardLoading: "Loading character readings…", + keyboardUnavailable: "Character readings unavailable", + keyboardPrevious: "Previous", + keyboardNext: "Next", + }, + }, + ja: { + common: { cancel: "キャンセル" }, + controller: { + disconnected: "コントローラーが切断されました", + reconnect: + "コントローラーを再接続して決定するか、キーを押すかクリックして続けてください。", + resume: "続ける", + unbound: "未割り当て", + textEntry: "テキストを入力", + select: "選択", + keyboardLanguage: "言語", + keyboardLatin: "英字", + keyboardKana: "ひらがな", + keyboardKatakana: "カタカナ", + keyboardShift: "シフト", + keyboardSymbols: "記号", + keyboardReading: "読み", + keyboardCommit: "確定", + keyboardComposeHint: "1文字分の読みを入力して、文字を選んでください。", + keyboardNoCandidates: "この読みに対応する文字がありません", + keyboardLoading: "文字の読みを読み込み中…", + keyboardUnavailable: "文字の読みを利用できません", + keyboardPrevious: "前へ", + keyboardNext: "次へ", + }, + titlescreen: { + keyboard: { + charactersHint: "{count} / {max} 文字", + backspace: "削除", + enter: "決定", + space: "スペース", + }, + }, + }, +}; diff --git a/site/specimens/controls.tsx b/site/specimens/controls.tsx new file mode 100644 index 0000000..ab84dc4 --- /dev/null +++ b/site/specimens/controls.tsx @@ -0,0 +1,981 @@ +/** Keys, checks, fields and pickers: what a player presses and types into. */ +import { useEffect, useState } from "react"; +import { Box, Field, Text } from "bureau/primitives"; +import { host } from "bureau/host"; +import { + Button, + CloseButton, + GroupBox, + HoldButton, + Icon, + KeyRow, + Toolbar, + ToolbarSeparator, +} from "bureau/kit/Bureau.tsx"; +import { + Caption, + Checkbox, + CheckboxGroup, + Radio, + RadioGroup, +} from "bureau/kit/Check.tsx"; +import { Segmented } from "bureau/kit/Segmented.tsx"; +import { Select } from "bureau/kit/Select.tsx"; +import { TextField } from "bureau/kit/TextField.tsx"; +import { Notebook, Tabs } from "bureau/kit/Tabs.tsx"; +import { Keycap } from "bureau/kit/Keycap.tsx"; +import { Badge } from "bureau/kit/Badge.tsx"; +import { Tile } from "bureau/kit/Tile.tsx"; +import { Mark, type MarkName } from "bureau/kit/Mark.tsx"; +import { ToolboxIcon } from "bureau/kit/ToolboxIcon.tsx"; +import type { SpecimenGroup } from "./specimen.ts"; +import { Plate, Row } from "./plate.tsx"; + +/** + * A cottage in 16 pixels, standing in for a game's own toolbox art: a + * `/toolbox/pixel/.png` the game ships. + */ +const HOUSE = + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAwElEQVR42mNgoBAwkqD2PzZ9TKTY1lLXjiHGQqSNOAEuA/7fDE9GEVBfOZfoMMDQjMUQRlwGwDVfvn0eRUJX1RDZEKyBiFMzshhUzX90F/wnNxkge+H/u8OzCOp4ffcMg3rCLLjlGLEgZJsGZ8MMRBa7uSCNcDQmz/7PcPZoM4pYf5g1VhdhTYnomvEBrAZcWFDHcGFBHYZ4zpzf2A3I2mfwH9nfMIwOpqSwwtkwPYzemfpwzVunXyTK2d6Z+nA2AGOASO40PoLaAAAAAElFTkSuQmCC"; + +function SettingsSpecimen() { + const [windowMode, setWindowMode] = useState< + "windowed" | "borderless" | "fullscreen" + >("borderless"); + const [resolution, setResolution] = useState("2560x1440"); + const [frameLimit, setFrameLimit] = useState("144"); + const [vsync, setVsync] = useState(true); + const [textSize, setTextSize] = useState<"small" | "medium" | "large">( + "medium", + ); + const [subtitles, setSubtitles] = useState(true); + const [screenShake, setScreenShake] = useState(false); + return ( + + + + + + + Resolution + + + Sort by +