@johnmorrisdotca/wakusei-planets 0.30.0 → 0.32.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/NOTICE.md +5 -0
  3. package/README.md +98 -12
  4. package/dist/data-door.d.ts +357 -0
  5. package/dist/data-door.js +393 -0
  6. package/dist/door/book.d.ts +133 -0
  7. package/dist/door/book.js +256 -0
  8. package/dist/door/host.d.ts +30 -0
  9. package/dist/door/host.js +44 -0
  10. package/dist/door/index.d.ts +6 -0
  11. package/dist/door/index.js +10 -0
  12. package/dist/door/map.d.ts +152 -0
  13. package/dist/door/map.js +162 -0
  14. package/dist/door/own.d.ts +36 -0
  15. package/dist/door/own.js +86 -0
  16. package/dist/door/points.d.ts +61 -0
  17. package/dist/door/points.js +175 -0
  18. package/dist/door/small-bodies.d.ts +157 -0
  19. package/dist/door/small-bodies.js +148 -0
  20. package/dist/element.d.ts +21 -0
  21. package/dist/element.js +74 -4
  22. package/dist/scene/body.d.ts +5 -2
  23. package/dist/scene/body.js +2 -1
  24. package/dist/scene/detail.d.ts +29 -12
  25. package/dist/scene/detail.js +217 -135
  26. package/dist/scene/painter.d.ts +5 -0
  27. package/dist/scene/painter.js +8 -5
  28. package/dist/scene/textures.d.ts +9 -2
  29. package/dist/scene/textures.js +17 -0
  30. package/dist/space/arrows.d.ts +87 -0
  31. package/dist/space/arrows.js +117 -0
  32. package/dist/space/beside.d.ts +74 -0
  33. package/dist/space/beside.js +76 -0
  34. package/dist/space/bodies.d.ts +83 -0
  35. package/dist/space/bodies.js +93 -0
  36. package/dist/space/element.d.ts +114 -14
  37. package/dist/space/element.js +344 -28
  38. package/dist/space/frame.d.ts +45 -2
  39. package/dist/space/frame.js +56 -4
  40. package/dist/space/index.d.ts +6 -1
  41. package/dist/space/index.js +6 -1
  42. package/dist/space/labels.d.ts +52 -0
  43. package/dist/space/labels.js +40 -0
  44. package/dist/space/scale.d.ts +5 -5
  45. package/dist/space/scale.js +10 -4
  46. package/dist/space/scene.d.ts +49 -9
  47. package/dist/space/scene.js +325 -34
  48. package/dist/space/spin.d.ts +37 -0
  49. package/dist/space/spin.js +29 -0
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/package.json +6 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.32.0] - 2026-11-10
6
+
7
+ - **The data door: `@johnmorrisdotca/wakusei-planets/door`** (MODULES-831, step 2; the shapes are kazoku-ui's `templates/data-door.ts`, copied unchanged to `src/data-door.ts`). One way to hand the package outside data and to say whose data is on the screen. `BodyMapSource` is a `TileSource` for the colour or the height of a body's map (the family's `MapPlace` and `ImageTile`; the keys end in `level/column/row` on the package's 512 pixel pyramid, and `mapKeys` names them), and `tilesSource(base)` is the package's own folder of tiles as a source, which is what the `tiles` attribute means; the attribute stays. `SmallBody` (name, `a`, `e`, `i`, `node`, `peri`, `M0`, `epoch`, `H`) and `SmallBodySource` are a record source of small bodies, read once, at most 200,000, with the records that cannot be drawn left out and counted; `smallBodyAt` says where one is on a date. `<wakusei-body>` and `<wakusei-space>` take `sources`, `addSource` (checked at once, returns its `remove()`), `removeSource`, `enableSource` and `data="own"`, and have `credits()` and the event `wakusei-creditschange`; `creditLine` writes the credit line with the licence beside each source, "non-commercial" or "share-alike" included, in English and Japanese. Off aborts a source's loads, frees its tiles and records, and drops its credit. The tiles of every body in a view share one 48 MB budget (`TILE_BUDGET_BYTES`), six loads at a time per source, and nothing is sent at rest. `OWN_SOURCES` (the pictures, the tiles and the orbit series) and `ownCredit` write the package's own credits from `NOTICE.md`, and a test holds that none is non-commercial or share-alike. A window of tiles that could not be made is no longer tried again after 30 seconds: it is tried again when the view changes. Every attribute and function is as it was; `createPainter` takes an optional `book`.
8
+ ## [0.31.0] - 2026-11-10
9
+
10
+ - **The body looked at is shown whole with a margin, no orbit line crosses it, and the demo opens moving** (machine1's review of the first hand-in). Zoom 1 now frames the body about 80% of the view's shorter side across (`FIT_DISTANCE` 4.1, it was 3.4 and the disc nearly touched the edges; Saturn is framed with its rings at 2.3 radii), so the zoom ceiling is 3.6 (the camera is as near as before). Close to a body (its disc 30 CSS pixels or more across its radius) only the orbit lines of its own system are drawn and the part of them within about twelve radii fades out, so no line is ever seen across the disc (`stats.orbits.hidden`). The demo's space page opens playing, from now, an hour a second, when its address names no date, speed or play and the reader has not asked for reduced motion; with reduced motion it opens still with Play ready. On the full-screen page the scale line sits at the bottom right and overlaps nothing. Browser tests: the disc is 72% to 88% of the shorter side, centred, at 1440x900, 390x844 and 2400x700 in the panel and full screen; the picture of the disc is the same with the lines on and off; the picture changes within two seconds with nothing touched.
11
+ - **Arrows on an orbit show which way the body goes, and the help mode shows its spin** (MODULES-857). With `orbits` on, six arrowheads about nine CSS pixels long sit along each orbit line (the Moon's too), pointing the way the body goes round; they keep their pixel size at every zoom, stay clear of the body, and show the real direction of travel, so they do not turn round when the clock runs backwards. `help` (new attribute and property, off by default) draws, on the body looked at, the line of its axis and a curved arrow round it for the way it spins, by the right-hand rule about the axis it really turns about (`spinAxis(id, ms)`, from its prime meridian's motion): the north pole for the Earth, the opposite way about the pole for Venus and Uranus, the way it goes round for a moon that keeps one face to its planet. `arrowSites`, `chevron`, `spinArrow`, `spinAxis` and `ARROWS_PER_ORBIT` are new in `/space`; `stats.arrows`, `stats.arrowPx` and `stats.help` read what was drawn. The three.js parts the view needs now include `LineSegments` (a page's own `setThreeLoader` subset adds it; the demo's does). The demo's Help switch turns the help mode on.
12
+ - **The space view offers every body the package knows: the dwarf planets are placed, and every moon can be gone to and ridden** (MODULES-741). `SPACE_BODIES` is now the nineteen bodies the view places (it was eleven): the Earth, the Sun, the Moon, the seven other planets, Pluto and the eight other dwarf planets, which `frameAt` gives in `frame.dwarfs` (new) from their osculating elements; `placeBodies`, `radiusIn` (a dwarf planet is its real size, or 0.3 Earth radii when compressed, whichever is larger), `moonDistance` and `planetOrbit` take them, `SPACE_DWARFS` and `SpaceDwarf` are new in `/space`, and `orbits` draws their lines, each body on its own. The moons of Orcus, Haumea and Eris are placed and drawn like those of the planets, `zoomFor` has `orcus-moons`, `haumea-moons` and `eris-moons` beside the planets', and every body of the 47 can be at the middle, gone to, hopped to and ridden. A dwarf planet under half a pixel across its radius is named and ringed but not drawn or made. The demo's picker is a kind, for a moon its planet, then the body, with a search by name and a "With its moons" button. `stats.bodies.painted` counts the dwarf planets made, so it can be above eleven.
13
+ - **Every planet and moon of the space view shows its real picture in every look** (MODULES-850, MODULES-809). The painter's context takes `mapped: true`: every body that has a surface map is drawn from it, whatever the look. `<wakusei-space>` passes it, so the realistic look, its default, draws Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto, the Moon and the moons that have maps from their pictures (it was the Earth alone) and the finer map tiles reach Mars and the Moon in it as they do in the painted look (MODULES-809); a body with no picture (Phobos, Deimos, Uranus's moons) is still shaded. The portrait and the single body are unchanged.
14
+ - **A view from beside the Moon with the Earth still in view** (MODULES-854). `space.ride("moon", { view: "beside" })`, and the same for any moon of a planet (`"io"`), puts the camera beyond the moon and off the line to its planet: the moon large in the foreground (about 20 degrees across its radius), the planet in view behind it at its real angular size (the Earth about two degrees from the Moon in the true scale) and never hidden by the moon, with a glide there and back. The camera opens off the line until the two discs clear each other, sits on the Sun's side where it can, turns the picture so the planet is beside the moon, and widens the field of view to fit the narrower side of the view; yaw swings it round the line, tilt opens the angle and zoom goes closer. `besideMoon(input)` and `BESIDE_RADII` (new, `/space`) are the pure maths. A planet or a point of your own with `view: "beside"` is refused. The demo's Ride along row has it as "Beside the Moon".
15
+ - **Any body can be at the middle of the space view, a press selects and a second press goes there, and a hopper goes through the bodies** (MODULES-858). `space.body` takes any body of the view by name in any case, in English or Japanese, including the moons of the planets (`titan`); `space.goTo(name, { smooth, zoom })` glides there and brings it whole into view. A first press selects (`wakusei-body-select`, `space.selected`) and a second goes there; a press never sends the view back to the Earth. `space.next()`, `previous()`, `hopper`, `bodyList()` and the `wakusei-hop` event give the order Sun, Mercury, Venus, Earth, Moon, Mars, Phobos, Deimos, Jupiter and its moons, and on; `HOP_ORDER`, `findBody`, `hopFrom`, `hostOf` and `bodyKindOf` are new in `/space`; `BodyInfo` gains `kind` and `host`. The names of a planet's moons are shown and placed (`placeOf`) once they are drawn. A test checks that `body = "Saturn"`, in any case, puts Saturn at the middle; `zoomFor` takes a preset in any case, and gives 1 for a name that is no preset (it gave NaN, or threw, for a capital: very likely why the prototype's `body = "Saturn"` with `zoomFor("Saturn-moons")` left the view on the Earth, since `body` itself always took the name in any case).
16
+ - **`<wakusei-space>` works full screen** (MODULES-848). `immersive` (new attribute and property) makes the element fill its box in any shape, a plain wheel zoom and a drag anywhere (a touch drag too) turn it, as the home page prototype needed; without it kazoku-ui's rules stand (Ctrl, Command or Alt with the wheel zooms, the plain wheel scrolls the page). At zoom 1 the body looked at is framed by the shorter side of the view in any shape, so it is never cut off, and Saturn is framed with its rings (2.4 radii across). A browser test (`fill-frame.demo.ts`) holds the space view, the portrait and the line-up of the demo to fill their frame edge to edge, canvas included, to within a pixel, at 1440, 390 and a wide short window. The demo has the page `space-full.html`, and `checkGestures` passes on it (the plain wheel's pan is named as the one gesture it lacks, because there the plain wheel zooms).
17
+ - **The Moon's orbit round the Earth is drawn, and every body is checked to sit on its own line** (MODULES-852). With `orbits` on, the view draws the Moon's path round the Earth (`moonOrbit(ms)`, new in `/space`: one sidereal month from the Moon's own place, closed, worked out again every five days of the clock) beside the Earth's and the planets' round the Sun, through the same mapping as the bodies in both scales. `stats.orbits` (new) lists the lines drawn and how far each body is from its own, as a fraction of the line's radius.
18
+ - **No two names of the space view overlap** (MODULES-855). The names of the bodies are chosen by rank (the body looked at, the Sun, the planets, the Moon) and one that would cover a surer one is left out, with its ring: a moon gives way to its planet and a planet to the Sun, and zooming in brings the names back. `chooseLabels(boxes)` and `LABEL_GAP` (new, `/space`) are the rule on plain boxes.
19
+ - **The space view opens at true distances, and says so** (MODULES-856). `scale` is `true` by default (it was `compressed`); the scale in use is named on the view itself ("True distances" or "Distances squeezed to fit", in the element's `lang`, with `scaleNames` for a page's own words and `::part(scale)` to style the line); a body whose disc is under 4 CSS pixels across its radius is marked with a ring as well as its name; and in the compressed scale the Moon is drawn at its true 0.273 of the Earth (it was 0.9, nearly as big as the Earth). A page that relied on the old default writes `scale="compressed"`. `space.placeOf(id)` (new) says where a body is on the screen.
20
+
5
21
  ## [0.30.0] - 2026-11-10
6
22
 
7
23
  - **The portrait and the space view zoom to their bodies' detail, with the finer map tiles** (MODULES-773). The painter, which draws every body of `<wakusei-portrait>` and `<wakusei-space>`, now takes the tiles, the window and the zoom table that `<wakusei-body>` got in 0.27.0. `PaintInfo.view` (new, optional: the camera and the size of its view in CSS pixels) lets a body work out which part of its surface the camera sees (`seenRegion`: rays through a grid of the view and round the edge of the near side, met with the body in its own frame, for an orthographic camera and a perspective one alike); a body whose disc is 150 device pixels across its radius or more, once the 2048 pixel map is not sharp enough, reads the tile set and lays the window over its map. `createPainter({ tiles })` says where the tiles are (`off` for none; the demo site's by default unless `textureBase` is given), `PaintContext.onLevels` is told what levels a body has, and `Painting.tiles` says what the window is doing. A caller that gives no `view` (chikyu-earth's space view) draws as it always did. Bodies that are not glowing take the generic detail in the painter's shader too, as in `<wakusei-body>`.
package/NOTICE.md CHANGED
@@ -132,6 +132,11 @@ Not tiled, because no finer public-domain map was found that this package can us
132
132
 
133
133
  The generic detail of a close zoom (docs/guides/close-zoom.md) is noise made in the shader. It is no data and takes nothing from any source.
134
134
 
135
+ ## The data door
136
+
137
+ - **The package's own credits (`OWN_SOURCES` in `@johnmorrisdotca/wakusei-planets/door`, MODULES-831, written 2026-11-10)**: three rows, written from the entries of this file and read nowhere else. `wakusei-pictures` is the surface pictures (Surface pictures above: NASA, USGS and JPL maps that are public domain, and Solar System Scope's and Nestaeric's maps, CC BY 4.0; its licence name is the stricter, "CC BY 4.0", read 2026-11-02). `wakusei-tiles` is the finer map tiles (Finer map tiles above: public domain, read 2026-11-09). `wakusei-orbits` is the series and tables the positions come from (The numbers above: IMCCE's VSOP87B and ELP2000-82B, which "carry no licence text" and are published for use with the credit, and JPL Horizons, NASA/JPL-Caltech, read 2026-11-07; its licence name says "Published for use with credit"). A test holds that none of the three is marked non-commercial or share-alike.
138
+ - **Data a caller hands in is not part of this package.** A source passed to `addSource` or `sources` carries its own credit and licence, and the credit line prints them (with "non-commercial" or "share-alike" where the source says so). This package bundles no such data and takes none as a dependency. The small-body source is a list of orbital elements a caller supplies; this package holds no catalogue of them.
139
+
135
140
  ## Orbiter's MIT notice
136
141
 
137
142
  The TASS1.7 table above was read from Orbiter (https://github.com/orbitersim/orbiter), whose licence is:
package/README.md CHANGED
@@ -15,9 +15,33 @@ A clean line drawing, a shaded realistic drawing, or a painted surface map, with
15
15
 
16
16
  <p align="center"><a href="https://johnmorrisdotca.github.io/wakusei-planets/"><strong>Open the demo →</strong></a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/embed.html">Embed page</a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/docs/">Docs</a></p>
17
17
 
18
- <p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.30.0/docs/images/hero-desk.png" width="640"></p>
18
+ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing to install, no account, and it is free.
19
19
 
20
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.30.0/docs/images/lineup-desk.png" width="640"></p>
20
+ <p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
21
+
22
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.32.0/docs/images/lineup-desk.png" width="640"></p>
23
+
24
+ ## Who it is for
25
+
26
+ - **Teachers and students:** [the size line-up](https://johnmorrisdotca.github.io/wakusei-planets/lineup.html) puts the Sun and the largest stars side by side at true relative size, each with its radius, its error and its paper, and [colouring sheets](https://johnmorrisdotca.github.io/wakusei-planets/kids.html) of the Sun, the planets and the big moons print on A4 or US Letter in English and Japanese, with the real colours and three facts each.
27
+ - **Space enthusiasts:** [the space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html) puts the Earth, the Moon, the Sun and the planets where they are now, or on any date you set, and zooms out to the whole solar system; [Jupiter and its moons as the Earth sees them now](https://johnmorrisdotca.github.io/wakusei-planets/?body=jupiter&sky=real&moons=1) is one click. The ten famous spacecraft (Voyager 1 and 2, New Horizons, Cassini, Juno, the Webb telescope and the rest) and where each is on any date are in [the spacecraft guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/spacecraft.html): that is code and a table, and there is no demo page for it yet.
28
+ - **Researchers and outreach staff:** every planet and the Moon is held within 6 arc-seconds of NASA's JPL Horizons on 60 dates from 1800 to 2200, and Jupiter's four big moons within 0.15 degree; [the accuracy guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/accuracy.html) gives each body's number and [NOTICE.md](NOTICE.md) names every source. The tables download as CSV and Parquet ([data files](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/data-files.html)). Read [Limits](#limits) first, and see [How to cite](#how-to-cite).
29
+ - **Writers, museums and site owners:** [the code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html) and [the portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) write the code that puts a body, or a picture of several, in your page as an `<iframe>` or a tag, with no build step.
30
+ - **Developers:** one `<wakusei-body>` tag, an SVG string with no browser at all, and typed data for the sizes, tilts, poles and places, and the bodies as objects for a three.js scene of your own; [One minute](#one-minute) and the [API](#api) are below.
31
+
32
+ ## Try it now, nothing to install
33
+
34
+ **Learn:** **[Colouring sheets to print](https://johnmorrisdotca.github.io/wakusei-planets/kids.html)** · **[Saturn's sheet](https://johnmorrisdotca.github.io/wakusei-planets/kids.html?sheet=saturn)** · **[The size line-up, the Sun to the largest stars](https://johnmorrisdotca.github.io/wakusei-planets/lineup.html)**
35
+
36
+ **Look:** **[Saturn, painted](https://johnmorrisdotca.github.io/wakusei-planets/?body=saturn&look=painted)** · **[Jupiter and its moons now](https://johnmorrisdotca.github.io/wakusei-planets/?body=jupiter&sky=real&moons=1)** · **[The space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html)** · **[A star from its numbers: Vega](https://johnmorrisdotca.github.io/wakusei-planets/star.html?star=vega)**
37
+
38
+ **Make:** **[The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html)** · **[The code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html)**
39
+
40
+ **Language:** **[日本語](https://johnmorrisdotca.github.io/wakusei-planets/?lang=ja)** · **[English](https://johnmorrisdotca.github.io/wakusei-planets/?lang=en)**
41
+
42
+ ## For teachers and families
43
+
44
+ Wakusei Planets works on a phone or a tablet as well as on a computer, in the browser, and it is free: the code is MIT-licensed, and nothing is installed or signed up for. [The colouring-sheets guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/kids-sheets.html) says what each sheet is and how to print it, and [the size line-up guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/size-lineup.html) says where each star's radius comes from. Every source is credited in [NOTICE.md](NOTICE.md) and at the foot of each demo page.
21
45
 
22
46
  ## One minute
23
47
 
@@ -70,13 +94,6 @@ Every view already turns, zooms and pans with a drag, a pinch, Ctrl and the whee
70
94
 
71
95
  A bundled app imports it: `import "@johnmorrisdotca/wakusei-planets/element"` (and `import { lineSvg } from "@johnmorrisdotca/wakusei-planets"` for the SVG string, which needs no browser). For the shaded look add the body's own entry point, `import "@johnmorrisdotca/wakusei-planets/jupiter"`, and `three` (an optional peer).
72
96
 
73
- ## Who it is for
74
-
75
- - **A developer who wants a planet on a page** with one tag, no build step, and a drawing that is an SVG before any 3D has loaded.
76
- - **A teacher, writer or museum** who needs the Sun, the planets and their moons at their real sizes and tilts, with every number traceable to the IAU, NASA or JPL.
77
- - **A maker of sky tools** who wants a planet's pole, phase, ring opening and its moons' places for any date and time as plain data, on a server or in a browser.
78
- - **A three.js developer** who wants the bodies as objects for a scene of their own.
79
-
80
97
  ## Features
81
98
 
82
99
  - The Sun, the eight planets, Pluto, eight more dwarf planets and 29 moons, each with its real size, flattening, axial tilt, pole and rotation as data.
@@ -296,13 +313,66 @@ A body that turns by itself and a moving sky, in HTML:
296
313
  <wakusei-body body="venus" look="realistic" time="2026-11-02T12:00:00Z" turn="12" live="hover"></wakusei-body>
297
314
  ```
298
315
 
316
+ ## Outside data
317
+
318
+ The package draws; you bring the data. `@johnmorrisdotca/wakusei-planets/door` takes a finer map of a body, or a list of small bodies, as a **source**: a small object that carries its own licence and credit, so the page can always say whose data is on the screen. Without a source the package draws exactly what it did before, from its own pictures, tiles and series. A source of yours may be non-commercial or share-alike; the credit line says so beside the licence, and the package never bundles one.
319
+
320
+ ```js
321
+ import { createSourceBook, creditLine, smallBodyAt } from "@johnmorrisdotca/wakusei-planets/door";
322
+
323
+ // A source of your own: here two small bodies held in memory (the second has a number that is not one, so it is left out). A real one would read a catalogue, and says whose it is and under what licence.
324
+ const mine = {
325
+ kind: "records",
326
+ info: {
327
+ id: "my-rocks",
328
+ name: { en: "My rocks", ja: "私の小天体" },
329
+ credit: { en: "My rocks, A. Person (2026)", ja: "私の小天体(A. Person、2026年)" },
330
+ licence: { name: "CC BY-NC 4.0", url: "https://creativecommons.org/licenses/by-nc/4.0/", nonCommercial: true },
331
+ url: "https://example.org/my-rocks",
332
+ retrieved: "2026-11-10",
333
+ },
334
+ records: () => [
335
+ { name: "Ceres", a: 2.7656, e: 0.0795, i: 10.588, node: 80.25, peri: 73.3, M0: 291.4, epoch: 2461000.5, H: 3.34 },
336
+ { name: "Broken", a: Number.NaN, e: 0.1, i: 5, node: 0, peri: 0, M0: 0, epoch: 2461000.5, H: 12 },
337
+ ],
338
+ };
339
+
340
+ // An element keeps a book like this one: `space.addSource(mine)` is `book.addSource(mine)`.
341
+ const book = createSourceBook();
342
+ book.addSource(mine);
343
+ await book.ready();
344
+ const [ceres] = book.smallBodies();
345
+ const [x, y, z] = smallBodyAt(ceres, 2461000.5);
346
+ console.log(`${book.smallBodies().length} small body, ${book.stats().records["my-rocks"].skipped} left out: ${ceres.name} is ${Math.hypot(x, y, z).toFixed(2)} au from the Sun`);
347
+ const credits = [{ source: mine.info, own: false, used: book.smallBodies().length }];
348
+ console.log(creditLine(credits, "en"));
349
+ console.log(creditLine(credits, "ja"));
350
+
351
+ book.enableSource("my-rocks", false);
352
+ console.log(`${book.smallBodies().length} small bodies with the source off`);
353
+ ```
354
+
355
+ `<wakusei-space>` draws small bodies as points in one instanced draw, and `<wakusei-body>` and `<wakusei-space>` both take a map of a body to lay over its own picture. Both have `sources` and `addSource(source)`, which checks the source at once and returns the way to remove it, `removeSource(id)`, `enableSource(id, false)` and the attribute `data="own"` to switch outside sources off (their loads abort and their tiles are freed), and `credits()` with the event `wakusei-creditschange` for the credit line.
356
+
357
+ ```js no-run
358
+ import { creditLine, tilesSource } from "@johnmorrisdotca/wakusei-planets/door";
359
+ import "@johnmorrisdotca/wakusei-planets/space/element";
360
+
361
+ const space = document.querySelector("wakusei-space");
362
+ space.addSource(mine); // the source above: its points are in the next frame
363
+ space.addSource(tilesSource("/my-tiles/")); // what tiles="/my-tiles/" means
364
+ space.addEventListener("wakusei-creditschange", () => console.log(creditLine(space.credits(), "en")));
365
+ ```
366
+
367
+ The tiles of every body share one 48 MB budget, six loads at a time for a source, and nothing is sent at rest. `OWN_SOURCES` and `ownCredit` give the package's own credits, `mapKeys` helps a source of your own name the tiles of a place, and `readSmallBodies` and `smallBodyAt` read a list of small bodies and say where one is on a date. The [guide](docs/guides/data-door.md) has the shapes and the rules.
368
+
299
369
  ## The code builder
300
370
 
301
371
  [The code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html) is one screen: choose which planet's system, the body, the look, the size, the sky and the turning, then pick how your page is made and copy the code. It is the family's embed panel with those choices inside it, built from `embedCode`, so it writes what the package writes. [Put it in your page](docs/guides/put-it-in-your-page.md) is its guide.
302
372
 
303
373
  ## The portrait builder
304
374
 
305
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.30.0/docs/images/portrait-family.png" width="640"></p>
375
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.32.0/docs/images/portrait-family.png" width="640"></p>
306
376
 
307
377
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
308
378
 
@@ -392,6 +462,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
392
462
  | [The size line-up](docs/guides/size-lineup.md) | The Sun and the largest stars at true relative size, with each radius, its error and its paper, where the papers disagree, every way to put it in a page |
393
463
  | [Zoom and pan](docs/guides/zoom-and-pan.md) | Every view zooms and moves by itself: the range of each and why it ends there, the bar, the embed page |
394
464
  | [Close zoom and map tiles](docs/guides/close-zoom.md) | How far each body zooms and why, the finer map tiles for a close zoom (made from public-domain maps, served beside the demo, never in the package), the generic detail, what it costs |
465
+ | [Outside data, the data door](docs/guides/data-door.md) | Hand the package your own maps of a body or small bodies with their licence and credit, switch them off, and show whose data is on the screen |
395
466
  | [Riding along](docs/guides/ride-along.md) | The camera on a moon, a planet or any moving point, looking at what it goes round |
396
467
  | [Accuracy](docs/guides/accuracy.md) | How far each body is from JPL Horizons |
397
468
  | [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
@@ -418,13 +489,28 @@ import { BODIES } from "@johnmorrisdotca/wakusei-planets";
418
489
  BODIES.pluto.kind; // "dwarf-planet"
419
490
  ```
420
491
 
421
- - A fact with no source is left out, never guessed. The Moon is within 2 arc-seconds of JPL Horizons, and the planets within a few arc-seconds on 60 dates from 1800 to 2200; the moons are within a degree or two on the orbit for almost every moon, about the size of the moon on screen, and Jupiter's four within a few hundredths of a degree; [accuracy](docs/guides/accuracy.md) has each body's number.
492
+ - **What it is for.** Pictures, charts, teaching and stories about the sky. It is not an ephemeris for pointing a telescope or planning a flight: for that use [JPL Horizons](https://ssd.jpl.nasa.gov/horizons/) itself, which every position here is checked against.
493
+ - **The planets** (Mercury to Neptune, VSOP87B cut to 995 of its 35,080 terms) are within 5 arc-seconds of Horizons on 60 dates from 1800 to 2200, Mars the worst at 4.8, and the tests hold each to 6 or less; the series is good for the years 1750 to 2250 and slowly worse beyond. Pluto's table is within 0.2.
494
+ - **The Moon** (ELP2000-82B cut to its 540 largest terms) is within 4.7 arc-seconds on the same 60 dates, held to 5.8.
495
+ - **The moons** are less exact: Jupiter's four big moons are within 0.15 degree and Saturn's seven inner ones within 2.1, Uranus's Miranda within 3 and Neptune's Nereid within 6.3; one degree on a moon's orbit is about the width of the moon on a screen. [Accuracy](docs/guides/accuracy.md) has each moon's number.
496
+ - **The dwarf planets** are within 0.2 arc-seconds of Horizons in the years their tables cover (1800 to 2200, Ceres 1900 to 2100); outside them the positions are plain ellipses, good for a few years either side of June 2026. Their moons other than Pluto's are not checked against Horizons, and a dwarf planet's pole is estimated where it is not measured (NOTICE.md says which).
497
+ - **The spacecraft** follow Horizons' own record, within 1,000 km near a planet and elsewhere a millionth of the distance from the Sun; a path after today is Horizons' prediction, not a fact.
498
+ - **Star sizes** in the line-up are each from a refereed paper, with the paper's error; WOH G64's and Stephenson 2-18's are estimated (from the spectrum and the brightness, and from a dust-shell fit) and not measured, and UY Scuti's distance is not a parallax. A star's surface (cells, spots, glow) is drawn for looks and says so.
499
+ - **Nothing is guessed.** A fact with no source is left out. [Accuracy](docs/guides/accuracy.md) has each body's number and how to run the check yourself.
422
500
  - `realistic` and `painted` are the photo maps (`painted` is the same maps, so an older page still works). `illustrated` is the shaded drawing from the numbers, and it is not a default. Venus, Saturn, Neptune and the Sun use Solar System Scope's maps (CC BY 4.0). Mercury uses the natural grey 8K map (Shady Tex and Solar System Scope, CC BY 4.0). Mars stays on the Viking mosaic, graded toward a butterscotch ochre, with the frost in Hellas toned to the basin and the polar ice left. Jupiter and Uranus use Nestaeric's maps (CC BY 4.0), and Saturn's poles use Nestaeric's caps (CC BY 4.0). The Earth and the Moon stay on their NASA maps until those have been compared. The rest are the public-domain maps in `NOTICE.md`.
423
501
  - A shaded look needs WebGL. Without it the line drawing is drawn.
424
502
  - Jupiter, Saturn, Uranus and Neptune have their rings drawn.
425
503
  - A portrait with no `turn` turns at 12 degrees a second, backwards when the body turns backwards. A picture with a date keeps that orientation and adds the same turn. `turn="0"` stays still.
426
504
  - Pictures for the painted look are 1.31 MB in the package at 512 and 1024 pixels; a sharper picture is fetched when you zoom in.
427
505
 
506
+ ## How to cite
507
+
508
+ If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
509
+
510
+ > Morris, J. (2026). *Wakusei Planets* (version 0.32.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
511
+
512
+ Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
513
+
428
514
  ## Accessibility
429
515
 
430
516
  - Every `<wakusei-body>` is an image with an accessible name from its body and look, such as "Saturn, line drawing", or the Japanese name with `lang="ja"`.
@@ -474,7 +560,7 @@ pnpm test:readme # every ts block of the README, type-checked and run against
474
560
  pnpm test:usage # every way of using it in the README and the guides, built and opened
475
561
  pnpm docs:check # the reference site's checks
476
562
  pnpm test:demo # the demo and the docs site in a real browser
477
- pnpm dev # the demo on http://127.0.0.1:8225/wakusei-planets/
563
+ pnpm dev # the demo on http://127.0.0.1:8300/wakusei-planets/
478
564
  ```
479
565
 
480
566
  The pictures in `docs/images` are made by the package's own script:
@@ -0,0 +1,357 @@
1
+ /**
2
+ * A licence: its name and a link are always shown beside the credit. *
3
+ * @example
4
+ * ```ts no-check
5
+ * import type { Licence } from "./data-door.ts";
6
+ *
7
+ * const licence: Licence = { name: "CC BY 4.0", url: "https://creativecommons.org/licenses/by/4.0/", spdx: "CC-BY-4.0" };
8
+ * ```
9
+ */
10
+ export interface Licence {
11
+ name: string;
12
+ url: string;
13
+ /** An SPDX identifier, when there is one. */
14
+ spdx?: string;
15
+ nonCommercial?: boolean;
16
+ shareAlike?: boolean;
17
+ }
18
+ /**
19
+ * What a source says about itself. *
20
+ * @example
21
+ * ```ts no-check
22
+ * import type { SourceInfo } from "./data-door.ts";
23
+ *
24
+ * const info: SourceInfo = {
25
+ * id: "my-catalogue",
26
+ * name: { en: "My catalogue", ja: "私のカタログ" },
27
+ * credit: { en: "My catalogue, A. Person (2026)", ja: "私のカタログ(A. Person、2026年)" },
28
+ * licence: { name: "CC BY 4.0", url: "https://creativecommons.org/licenses/by/4.0/" },
29
+ * url: "https://example.org/my-catalogue",
30
+ * retrieved: "2026-11-10",
31
+ * };
32
+ * ```
33
+ */
34
+ export interface SourceInfo {
35
+ /** Unique in a view: lower-case letters, digits and hyphens ("ucac4", "my-catalogue"). */
36
+ id: string;
37
+ name: {
38
+ en: string;
39
+ ja: string;
40
+ };
41
+ /** The line shown on screen. Never empty, in both languages. */
42
+ credit: {
43
+ en: string;
44
+ ja: string;
45
+ };
46
+ /** The licence: its name and link are always shown with the credit. */
47
+ licence: Licence;
48
+ /** The source's own page. */
49
+ url: string;
50
+ /** The day it was retrieved, yyyy-mm-dd, as NOTICE.md writes it. */
51
+ retrieved: string;
52
+ }
53
+ /**
54
+ * The most records a record source may hold. Bigger data must be tiles. *
55
+ * @example
56
+ * ```ts no-check
57
+ * import { MAX_RECORDS } from "./data-door.ts";
58
+ *
59
+ * console.log(MAX_RECORDS); // 200000
60
+ * ```
61
+ */
62
+ export declare const MAX_RECORDS = 200000;
63
+ /**
64
+ * The default budget for decoded tiles in a view, all sources together: 48 MB (a picture counts with its mipmaps, 4/3 of its bytes). *
65
+ * @example
66
+ * ```ts no-check
67
+ * import { TILE_BUDGET_BYTES } from "./data-door.ts";
68
+ *
69
+ * console.log(TILE_BUDGET_BYTES / 1024 / 1024); // 48
70
+ * ```
71
+ */
72
+ export declare const TILE_BUDGET_BYTES: number;
73
+ /**
74
+ * The most loads in flight at once for one source. *
75
+ * @example
76
+ * ```ts no-check
77
+ * import { MAX_IN_FLIGHT } from "./data-door.ts";
78
+ *
79
+ * console.log(MAX_IN_FLIGHT); // 6
80
+ * ```
81
+ */
82
+ export declare const MAX_IN_FLIGHT = 6;
83
+ /**
84
+ * A list that fits in memory (at most `MAX_RECORDS` records; bigger data must be tiles). It is read once, when the source is added. *
85
+ * @example
86
+ * ```ts no-check
87
+ * import type { RecordSource } from "./data-door.ts";
88
+ *
89
+ * declare const info: import("./data-door.ts").SourceInfo;
90
+ * const source: RecordSource<{ id: string }> = { kind: "records", info, records: () => [{ id: "a" }] };
91
+ * ```
92
+ */
93
+ export interface RecordSource<R> {
94
+ kind: "records";
95
+ info: SourceInfo;
96
+ records(signal: AbortSignal): R[] | Promise<R[]>;
97
+ }
98
+ /**
99
+ * Data cut by place and by detail. `Place` and `Detail` are the package's own types. *
100
+ * @example
101
+ * ```ts no-check
102
+ * import type { TileSource } from "./data-door.ts";
103
+ *
104
+ * declare const info: import("./data-door.ts").SourceInfo;
105
+ * const source: TileSource<string, number, Uint8Array> = {
106
+ * kind: "tiles",
107
+ * info,
108
+ * need: (place, detail) => [`${place}/${detail}`],
109
+ * load: async () => new Uint8Array(16),
110
+ * bytes: (tile) => tile.byteLength,
111
+ * };
112
+ * ```
113
+ */
114
+ export interface TileSource<Place, Detail, Tile> {
115
+ kind: "tiles";
116
+ info: SourceInfo;
117
+ /** The keys of the tiles a place needs at a detail. Pure: no fetching. */
118
+ need(place: Place, detail: Detail): readonly string[];
119
+ /** Loads one tile. The source may use the network or not; it must stop when the signal aborts. */
120
+ load(key: string, signal: AbortSignal): Promise<Tile>;
121
+ /** The tile's size in memory, in bytes, for the budget. */
122
+ bytes(tile: Tile): number;
123
+ }
124
+ /**
125
+ * Either kind of source. *
126
+ * @example
127
+ * ```ts no-check
128
+ * import type { DataSource } from "./data-door.ts";
129
+ *
130
+ * const kinds = (sources: DataSource[]): string[] => sources.map((source) => source.kind);
131
+ * ```
132
+ */
133
+ export type DataSource = RecordSource<unknown> | TileSource<unknown, unknown, unknown>;
134
+ /**
135
+ * A piece of a map, in degrees: longitude and latitude (right ascension and declination for the sky). One shape in every package. *
136
+ * @example
137
+ * ```ts no-check
138
+ * import type { MapPlace } from "./data-door.ts";
139
+ *
140
+ * const wholeSky: MapPlace = { lonMin: 0, lonMax: 360, latMin: -90, latMax: 90 };
141
+ * ```
142
+ */
143
+ export interface MapPlace {
144
+ lonMin: number;
145
+ lonMax: number;
146
+ latMin: number;
147
+ latMax: number;
148
+ }
149
+ /**
150
+ * What a picture needs of its bitmap: an `ImageBitmap` fits. *
151
+ * @example
152
+ * ```ts no-check
153
+ * import type { BitmapLike } from "./data-door.ts";
154
+ *
155
+ * const size = (bitmap: BitmapLike): number => bitmap.width * bitmap.height;
156
+ * ```
157
+ */
158
+ export interface BitmapLike {
159
+ readonly width: number;
160
+ readonly height: number;
161
+ close?(): void;
162
+ }
163
+ /**
164
+ * A map tile: its size in pixels and its picture. A map source's detail is the pixels across the whole circumference (not a level number, because the packages number their pyramids differently),
165
+ * and each source maps a width to its own nearest level.
166
+ *
167
+ * @example
168
+ * ```ts no-check
169
+ * import type { ImageTile } from "./data-door.ts";
170
+ *
171
+ * const tile: ImageTile = { width: 512, height: 256, image: await createImageBitmap(blob) };
172
+ * ```
173
+ */
174
+ export interface ImageTile {
175
+ width: number;
176
+ height: number;
177
+ image: BitmapLike;
178
+ }
179
+ /**
180
+ * One source's part in the last drawn frame. *
181
+ * @example
182
+ * ```ts no-check
183
+ * import type { Credit } from "./data-door.ts";
184
+ *
185
+ * declare const info: import("./data-door.ts").SourceInfo;
186
+ * const credit: Credit = { source: info, own: false, used: 12 };
187
+ * ```
188
+ */
189
+ export interface Credit {
190
+ source: SourceInfo;
191
+ /** True for the package's own (bundled) data. */
192
+ own: boolean;
193
+ /** The marks or tiles drawn from it. */
194
+ used: number;
195
+ }
196
+ /**
197
+ * Refuses a source that cannot be shown honestly: it throws a `TypeError` at once, when a source is added, not at the first draw. An empty credit (either language), a licence with no name or no
198
+ * link, a bad or already used id, a missing name, page or day, or a missing function is refused.
199
+ * @param source What the caller handed in.
200
+ * @param taken The ids already in the view, so that a clash is refused.
201
+ * @example
202
+ * ```ts no-check
203
+ * import { validateSource } from "./data-door.ts";
204
+ *
205
+ * validateSource(mySource, view.sources.map((one) => one.info.id)); // throws TypeError: source "mine": the credit is empty (en)
206
+ * ```
207
+ */
208
+ export declare function validateSource(source: unknown, taken?: Iterable<string>): asserts source is DataSource;
209
+ /**
210
+ * The credit line for what a view drew: each source's credit with its licence name, and "non-commercial" or "share-alike" whenever the source says so, so a page cannot hide the terms of the data it
211
+ * uses. The package's own sources come first, then the rest, each group in the order given; a source listed twice is written once. English: joined with semicolons, ending in a full stop. Japanese: the
212
+ * licence in full-width parentheses, joined with /, no full stop. An empty list is an empty string.
213
+ * @param credits What the view drew, from its `credits()`.
214
+ * @param language `"en"` or `"ja"`.
215
+ * @returns The line, or an empty string for no credits.
216
+ * @example
217
+ * ```ts no-check
218
+ * import { creditLine } from "./data-door.ts";
219
+ *
220
+ * creditLine(view.credits(), "en"); // "Yale Bright Star Catalogue (Public domain); UCAC4 (CC0 1.0)."
221
+ * creditLine(view.credits(), "ja"); // "イェール輝星カタログ(パブリックドメイン)/UCAC4(CC0 1.0)"
222
+ * ```
223
+ */
224
+ export declare function creditLine(credits: readonly Credit[], language: "en" | "ja"): string;
225
+ /**
226
+ * What `loadRecords` found. `skipped` counts the records dropped for a non-finite number; a failed read has no records and says why.
227
+ *
228
+ * @example
229
+ * ```ts no-check
230
+ * import type { RecordsRead } from "./data-door.ts";
231
+ *
232
+ * const say = (read: RecordsRead<unknown>): string => `${read.status}: ${read.records.length} kept, ${read.skipped} skipped`;
233
+ * ```
234
+ */
235
+ export interface RecordsRead<R> {
236
+ status: "ok" | "failed" | "aborted";
237
+ /** Frozen. Empty unless the read succeeded. */
238
+ records: readonly R[];
239
+ skipped: number;
240
+ /** Why a read failed. */
241
+ reason?: string;
242
+ }
243
+ /**
244
+ * Reads a record source once, when it is added: the list is frozen, a record with a non-finite number (a `NaN` or an infinity in any number `finite` names) is skipped and counted, and a list over
245
+ * `MAX_RECORDS` is refused whole (bigger data must be tiles). It never throws: a source that throws or rejects is a failed read, and a read the signal aborted is `aborted`.
246
+ * @param source The record source.
247
+ * @param signal Aborts the read (the source is removed or switched off).
248
+ * @param finite The numbers of one record that must be finite, if any: `(star) => [star.ra, star.dec, star.mag]`.
249
+ * @returns What was found: the status, the frozen records, how many were skipped and, for a failed read, why.
250
+ * @example
251
+ * ```ts no-check
252
+ * import { loadRecords } from "./data-door.ts";
253
+ *
254
+ * const read = await loadRecords(source, controller.signal, (star) => [star.ra, star.dec]); // read.records is frozen; read.skipped counts the NaNs
255
+ * ```
256
+ */
257
+ export declare function loadRecords<R>(source: RecordSource<R>, signal: AbortSignal, finite?: (record: R) => readonly number[]): Promise<RecordsRead<R>>;
258
+ /**
259
+ * The part of a tile source the store uses.
260
+ *
261
+ * @example
262
+ * ```ts no-check
263
+ * import type { TileLoader } from "./data-door.ts";
264
+ *
265
+ * const loader: TileLoader<Uint8Array> = { info, load: async () => new Uint8Array(8), bytes: (tile) => tile.byteLength };
266
+ * ```
267
+ */
268
+ export type TileLoader<Tile> = Pick<TileSource<unknown, unknown, Tile>, "info" | "load" | "bytes">;
269
+ /**
270
+ * Options for `createTileStore`.
271
+ *
272
+ * @example
273
+ * ```ts no-check
274
+ * import type { TileStoreOptions } from "./data-door.ts";
275
+ *
276
+ * const options: TileStoreOptions = { budgetBytes: 24 * 1024 * 1024, maxTiles: 256, onChange: () => draw() };
277
+ * ```
278
+ */
279
+ export interface TileStoreOptions {
280
+ /** The bytes of decoded tiles held, all sources together. Default `TILE_BUDGET_BYTES`. */
281
+ budgetBytes?: number;
282
+ /** The most loads in flight for one source. Default `MAX_IN_FLIGHT`. */
283
+ maxInFlight?: number;
284
+ /** The most tiles held, all sources together, as well as the byte budget. Default: no limit. */
285
+ maxTiles?: number;
286
+ /** Called when a tile has arrived, failed or been refused, so the view can redraw. */
287
+ onChange?: () => void;
288
+ }
289
+ /**
290
+ * What a tile store has done.
291
+ *
292
+ * @example
293
+ * ```ts no-check
294
+ * import type { TileStats } from "./data-door.ts";
295
+ *
296
+ * const full = (stats: TileStats): boolean => stats.refused > 0;
297
+ * ```
298
+ */
299
+ export interface TileStats {
300
+ /** Tiles held, and their bytes: `heldBytes` is never over the budget. */
301
+ held: number;
302
+ heldBytes: number;
303
+ /** Loads running now, and loads waiting for a free place. */
304
+ inFlight: number;
305
+ queued: number;
306
+ /** Loads started since the store was made: the number a test reads to prove nothing is sent at rest. */
307
+ requested: number;
308
+ /** Tiles that failed to load, came back empty, or reported a size that is not a number. They are never held or drawn. */
309
+ failed: number;
310
+ /** Tiles that arrived and did not fit, because every tile held was needed by the view. They are not held; the view draws what it holds. */
311
+ refused: number;
312
+ /** Tiles let go to make room. */
313
+ evicted: number;
314
+ }
315
+ /**
316
+ * A tile store: tiles by source and key, under one byte budget.
317
+ *
318
+ * @example
319
+ * ```ts no-check
320
+ * import type { TileStore } from "./data-door.ts";
321
+ *
322
+ * const held = (store: TileStore<Uint8Array>): number => store.stats().held;
323
+ * ```
324
+ */
325
+ export interface TileStore<Tile> {
326
+ /**
327
+ * Tells the store which tiles `source` needs now, and returns the ones it holds. When the keys are the same as the last call it does nothing, so a view that asks again at rest sends nothing;
328
+ * when they changed, the missing ones load (a tile that failed is tried again only now), the loads of tiles no longer needed are aborted, and the held ones are marked used.
329
+ * `again: true` is for a caller that means "try what is missing once more" with the same keys: it starts the missing tiles that are not already loading or waiting, and nothing else changes.
330
+ */
331
+ want(source: TileLoader<Tile>, keys: readonly string[], again?: boolean): ReadonlyMap<string, Tile>;
332
+ /** One held tile, or `undefined`. */
333
+ get(sourceId: string, key: string): Tile | undefined;
334
+ /** Forgets a source: aborts its loads, frees its tiles. The source is switched off. */
335
+ drop(sourceId: string): void;
336
+ stats(): TileStats;
337
+ /** Resolves when no load is running or waiting. */
338
+ idle(): Promise<void>;
339
+ }
340
+ /**
341
+ * A tile store for a view: loads the tiles of every source by key and keeps them under one budget of bytes (default 48 MB, all sources together).
342
+ * - At most `maxInFlight` loads (6) run at once for a source, and a load starts only because the keys changed: at rest the store sends nothing, and a tile that failed waits for the next change.
343
+ * - The least recently used tile goes first when room is needed, and never a tile the view needs now. If a new tile does not fit even so, it is refused and counted: the held bytes never pass the budget (nor the count, if `maxTiles` is set).
344
+ * - A tile that throws, comes back empty or reports a size that is not a finite number is counted in `failed` and never held, so it is never drawn.
345
+ * - `drop(sourceId)` aborts the source's loads and frees its tiles.
346
+ * @param options Budget, loads in flight, and a callback for a redraw.
347
+ * @returns The store.
348
+ * @example
349
+ * ```ts no-check
350
+ * import { createTileStore } from "./data-door.ts";
351
+ *
352
+ * const store = createTileStore<Tile>({ onChange: draw });
353
+ * const held = store.want(source, source.need(place, detail)); // draws what is held now; the rest arrives through onChange
354
+ * store.drop(source.info.id); // the layer is switched off
355
+ * ```
356
+ */
357
+ export declare function createTileStore<Tile>(options?: TileStoreOptions): TileStore<Tile>;