Skip to content

Commit 8ba160a

Browse files
committed
The TinyGo build, and stop advertising a demo that is not in it
docs/tinygo/desktop.wasm carries the twelve new animations: 8.11 MB to 10.17 MB, two megabytes for the lot, against 20.6 MB for the standard Go build of the same thing. /tinygo/?demo=parrot works now. The build overlapped a go mod vendor of its own dependency tree, so it was verified rather than trusted: every new demo name is in the binary and the parrot renders in a browser. docs/desktop.wasm is rebuilt too and differs from the committed copy by 115 bytes, all of them in the build-ID region at the head of the file; the payload is byte-identical. And a bug this turned up. cmd/gendemos imported demos/markdown unconditionally while cmd/desktop imports it only under -tags tuimarkdown, so the generated table listed a demo the shipped binary does not contain and ?demo=markdown has been answering "no demo called markdown". pterm never had the problem because its build tag is on the demo package itself, which makes it unimportable rather than merely unimported. The fix puts gendemos behind the same tag: the default run now writes 42 demos and -tags tuimarkdown writes 43. A table generated from a different build than the one that ships is a table that lies, and this one had been lying since the demo was tagged out.
1 parent 67efdb1 commit 8ba160a

6 files changed

Lines changed: 98 additions & 89 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ at startup — so a link to one costs nothing to serve and there is no per-demo
9696
build. The full-page view has no chrome at all: it should look like the terminal
9797
it would run in, and the browser already has a back button.
9898

99-
`pterm` is not listed: it needs `-tags pterm`, see `shims/`.
99+
`pterm` is not listed: it needs `-tags pterm`, see `shims/`. Neither is
100+
`markdown`, which needs `-tags tuimarkdown` — glamour and chroma are a couple
101+
of megabytes for one demo. Build gendemos with the same tags as the binary and
102+
both appear; the table describes the build it was generated from, never a
103+
build nobody ships.
100104

101105
<!-- BEGIN DEMOS -->
102106
| demo | shape | what it is |
@@ -121,7 +125,6 @@ it would run in, and the browser already has a back button.
121125
| [`lavalamp`](https://tuiwasm.magnetosphere.net/?demo=lavalamp) | screen | wax that heats, rises, cools and sinks |
122126
| [`life`](https://tuiwasm.magnetosphere.net/?demo=life) | screen | Conway's life, colored by how long a cell has lived |
123127
| [`lightning`](https://tuiwasm.magnetosphere.net/?demo=lightning) | screen | a branching discharge: leader, return stroke, afterglow |
124-
| [`markdown`](https://tuiwasm.magnetosphere.net/?demo=markdown) | text | glamour + chroma — rendered markdown, highlighted code |
125128
| [`matrix`](https://tuiwasm.magnetosphere.net/?demo=matrix) | screen | falling columns of glyphs |
126129
| [`maze`](https://tuiwasm.magnetosphere.net/?demo=maze) | screen | a maze carved by backtracking, then solved |
127130
| [`metaballs`](https://tuiwasm.magnetosphere.net/?demo=metaballs) | screen | blobs that bulge and merge as they approach |

cmd/gendemos/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
// eventually draw into is js/wasm.
3535
_ "github.com/0magnet/tuiwasm/demos/anim"
3636
_ "github.com/0magnet/tuiwasm/demos/charts"
37-
_ "github.com/0magnet/tuiwasm/demos/markdown"
3837
_ "github.com/0magnet/tuiwasm/demos/proxima"
3938
_ "github.com/0magnet/tuiwasm/demos/proxima2"
4039
_ "github.com/0magnet/tuiwasm/demos/styles"

cmd/gendemos/markdown.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//go:build tuimarkdown
2+
3+
// Package main cmd/gendemos/markdown.go
4+
//
5+
// The markdown demo's registration, behind the same tag cmd/desktop puts it
6+
// behind.
7+
//
8+
// Without this the table listed a demo the shipped binary does not contain:
9+
// gendemos imported demos/markdown unconditionally and saw it register, while
10+
// cmd/desktop imports it only under -tags tuimarkdown, so every published
11+
// ?demo=markdown link answered "no demo called markdown". pterm never had the
12+
// problem because its build tag is on the demo package itself, which makes it
13+
// unimportable rather than merely unimported.
14+
//
15+
// The rule this restores: gendemos must be built the same way as the thing it
16+
// documents, so the table cannot describe a build nobody ships.
17+
package main
18+
19+
import _ "github.com/0magnet/tuiwasm/demos/markdown"

docs/desktop.wasm

0 Bytes
Binary file not shown.

docs/tinygo/desktop.wasm

1.96 MB
Binary file not shown.

0 commit comments

Comments
 (0)