@pencil-lang/figure 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,6 +30,20 @@ It owns the canvas, the labels over it, the GPU and the clock. It starts the GPU
30
30
  under `prefers-reduced-motion`, and every handle and beat can be worked from the keyboard. Its attributes, methods and
31
31
  events are described at the top of [`src/element.js`](src/element.js).
32
32
 
33
+ A figure's shaders are compiled after its sources, while the figure before it, or its poster, stays on screen and draws
34
+ on. Its pipelines are made with wgpu's `create_render_pipeline_async`, which on WebGPU is `createRenderPipelineAsync`,
35
+ so the browser compiles them off the thread that composites the page. Chrome compiles a pipeline made with
36
+ `createRenderPipeline` on that thread, and a page of figures stopped for 150 to 800 ms as each one started. `load` and
37
+ `loadCompiled` throw a compile error at once, and resolve with `true` once the figure is shown, however long the GPU
38
+ takes to start, or with `false`: one asked for while another is compiling takes its place, one the GPU can't make is
39
+ an `error`, and one whose GPU can't start, or whose figure leaves the page, isn't shown, though it's still what the
40
+ figure starts from if it does. The `error` has `detail.kept`: `true` when the figure before stays on screen, and
41
+ `false` when there was none on the player, as for a first figure, or after the GPU started again, which then shows the
42
+ figure that drew before. A figure far off screen has no GPU yet, so its `load` resolves only once it comes near, and a
43
+ page that awaits several figures' loads in turn waits at the first one off screen. A figure's handles and keys wait for
44
+ it too. WebGL2 compiles a pipeline where it's made, as before. A page that drives a `Player` itself does
45
+ `player.install(await player.prepare(doc, sheets, names, files))` ([`src/host.js`](src/host.js)).
46
+
33
47
  A param with a binding goes back to it when a reader sets a param that binding reads, as θ in Bounds does when `q` or
34
48
  the case is set after a drag: the core says which params each binding reads (`info.params[].reads`), and the element
35
49
  hands them back, so a page needs no `release` of its own for it. Params held together, by the `params` attribute or
@@ -80,14 +94,22 @@ or fewer, a `<select>` for more, and a checkbox for a choice of off and on (`doc
80
94
  words, and a readout's box is as big as the most it says over the moments a reader can reach, from the one the figure
81
95
  starts at, which the core tries (`readout_room`). Each sits in a contained box. Every slider is in one grid, so each
82
96
  starts and ends where the others do, and a long caption wraps rather than squeezing its slider.
83
- - **On a phone,** or a screen with little height, one row stays, on one line, in a bar of fixed height, and the rest open
84
- from a `⋯` button as a menu over the page, from the bottom. The figure keeps the height. Which row is `BAR` in
85
- [`src/controls.js`](src/controls.js): `'first'`, the first row, or `'readouts'`. A row that doesn't fit the bar's line,
86
- as radios with long words, goes behind the menu too, and the button says "Controls", so nothing in the bar is cut off.
87
- A row that comes to fit again, as when a phone turns, comes back to the bar. The beats' caption is a line of its own
88
- under the bar, wherever the stepper is, as tall as the longest caption at that width, so stepping moves nothing.
89
- Escape closes the menu and gives the focus back to `⋯`, and controls written again, as for another look, keep an
90
- open menu open and the focus where it was.
97
+ - **On a phone,** or a screen with little height, one row stays, on one line, in a bar of fixed height, and the rest drop
98
+ down from a `⋯` button in a menu over the page below, as wide as the controls. The figure keeps the height. The bar
99
+ keeps the playback, which is the time or else the beats, or else the readouts, or else a figure's one param. It never
100
+ splits a figure's params: one with more than one and nothing else has a bar of only the button, `Controls ⋯`, and its
101
+ params together in the menu. A row that doesn't fit the bar's line, as radios with long words, goes behind the menu
102
+ too, and the button says "Controls", so nothing in the bar is cut off. A row that comes to fit again, as when a phone
103
+ turns, comes back to the bar. The beats' caption is a line of its own under the bar, wherever the stepper is, as tall
104
+ as the longest caption at that width, so stepping moves nothing, and the menu drops from under it.
105
+ - **The menu scrolls with the page,** under its bar, and follows the bar wherever else it goes: when something above it
106
+ grows, or a sticky or fixed box carries it, and a frame behind when a scrolling box it's in scrolls. It closes when
107
+ its controls leave the screen, so it never stays over another figure. Opening one low on the screen scrolls the page
108
+ just enough to show it, never so far that the bar leaves the top, and opening another figure's closes it. It's at most
109
+ 60% of the screen's height, and scrolls within that. Escape closes it and gives the focus back to `⋯`, and controls
110
+ written again, as for another look, keep an open menu open where it was, and the focus where it was, without
111
+ scrolling. The button is called "More controls" beside the bar's row and "Controls" alone, and a build writes it
112
+ disabled, as it does the rest, until the figure loads.
91
113
  - **A new beat is said,** in a polite live region: which beat it is and its caption, `2 / 3: Then as many…`, whether
92
114
  a reader stepped to it or time brought it.
93
115
  - **Anything a page puts in `<pencil-controls>`,** as a choice of looks, is shown after the defaults, and on a phone in
@@ -102,7 +124,7 @@ set on the figure or anything around it:
102
124
  | `--pencil-ink` | Values, a param's name and readouts. |
103
125
  | `--pencil-muted` | What a control says it is, and captions. |
104
126
  | `--pencil-accent` | Sliders, radios and checkboxes. |
105
- | `--pencil-rule`, `--pencil-surface` | A button's border and background. |
127
+ | `--pencil-rule`, `--pencil-surface` | A button's border and background, and the rule is the menu's border on a phone. |
106
128
  | `--pencil-surface-menu` | The menu's background on a phone. |
107
129
  | `--pencil-math-font` | A param's name, as the `font` shorthand. |
108
130
  | `--pencil-focus` | The focus ring, as on the figure's handles. |
@@ -110,7 +132,7 @@ set on the figure or anything around it:
110
132
 
111
133
  | Part | What it is |
112
134
  |---|---|
113
- | `controls`, `bar`, `rest` | All of them, the first row, and the rest, which on a phone is the menu. |
135
+ | `controls`, `bar`, `rest` | All of them, the row a phone's bar keeps with the menu's button, and the rest, which on a phone is the menu. |
114
136
  | `row` | Each row, with `time`, `beats`, `param`, `choice` or `readouts` as well. |
115
137
  | `label` | What a control says it is: a `<label>`, or a group's `<legend>`. |
116
138
  | `slider`, `select`, `radio`, `checkbox`, `option` | Each control, and a radio's label. |
@@ -257,7 +279,7 @@ pnpm test
257
279
 
258
280
  Playwright's, in [`tests/`](tests), against the corpus in this repo, headless, on its own Chromium and WebKit: each at
259
281
  a desktop size and as a phone (a Pixel 7 and an iPhone 15, emulated). They cover drawing, every key on a handle and on
260
- beats, the default controls and a page's own, readouts, and that no control moves as the figure loads, plays or is
282
+ beats, the default controls and a page's own, a phone's bar and where its menu opens as the page scrolls, readouts, and that no control moves as the figure loads, plays or is
261
283
  dragged, a mouse drag and a touch drag, a swipe that scrolls past a figure, a drag that selects no text, a range that follows another param, reduced motion, sheets picked by theme, the
262
284
  poster's swap, and a compiled figure. `PENCIL_GL=1 pnpm test` runs them all on WebGL2 in place of WebGPU, and `PENCIL_MIN=1 pnpm test` on the minified bundle. They serve the repo on
263
285
  port 8743, and reuse a server already there, so a second checkout runs them on its own with `PENCIL_PORT=8751 pnpm test`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pencil-lang/figure",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Pencil figures on a page: the <pencil-figure> element, the WASM host it runs on, and an Astro component that builds a figure and its poster.",
5
5
  "license": "MIT",
6
6
  "repository": {