@johnmorrisdotca/chikyu-earth 0.40.0 → 0.41.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.41.0 - 2026-11-12
6
+
7
+ - **The credit under the space view follows the painter's credit** (MODULES-1158). wakusei-planets' painter (0.39 and later) carries `credit: { en, ja }` for the pictures of the bodies the view holds, and the view makes the Sun, the Moon and every planet in each view, so the line names all their pictures in an Earth view as in a Jupiter view (more than is big on the screen is safe, less would be the fault); so `<chikyu-space>` reads it again whenever a body drawing asks for a redraw (a picture arrived, a window of tiles changed, a body was made) and writes the line only when its text changed, never at every frame; no credit, no line. Pass the painter as it is: `{ ...painter }` reads `credit` once. A page that writes the credit itself (`bodies-credit="off"`) is sent `chikyu-bodies-credit` when it changed, with `detail` `{ en, ja }` or `null`. The demo drops its own `PLANET_CREDIT` and uses the painter's; its full-screen page follows the event. Tests: `e2e/space-credit.gl.ts` (a painter of the test's own; and wakusei-planets' own, wrapped to log the bodies made and the reads of its credit after they are made: every body is made, the Sun's and Jupiter's CC BY 4.0 credits are in the line, and it is the painter's credit as it is now). Lazy making of the bodies out of view, which would narrow the credit, is a separate ticket. The credit line is at most four lines high and scrolls: with every body made, wakusei-planets' credit is some twenty lines and covered the whole view (it hid the ground from the drag, air and follow tests in CI).
8
+
5
9
  ## 0.40.0 - 2026-11-12
6
10
 
7
11
  - **Names of different layers never overlap** (MODULES-1072). On `<chikyu-space>` and `<chikyu-earth-realistic>` each layer placed its names alone: city names ignored the places, the markers' labels ignored the places' names, and star names ignored every layer's names and rings, so a name could sit over another layer's. The layers now lay out in a fixed order, each keeping clear of the boxes of those before it: the places' names, rings and marks with the ringed satellites, then the markers' labels, then the cities' names, then the stars' and constellations' names (the countries' names, which already kept clear of the others, come after the cities'). A star whose name box or ring touches an earlier box is left out and the next star is named. The order is the draw's: the realistic Earth's places are laid out before its markers and the sky after the cities, as the space view's sky is after its cities. `OverlayHost` has an optional `taken()` (the places' boxes, which `attachMarkers` reads), `CityLayoutOptions` has `taken`, and a satellite's ring is among the boxes the places take. Boxes are handed over when names are laid out, which is when the view changes; nothing is laid out or drawn at rest. Tests: `test/label-overlap.test.ts` and `e2e/label-overlap.gl.ts`.
package/README.md CHANGED
@@ -609,7 +609,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
609
609
 
610
610
  ## How to cite
611
611
 
612
- > Morris, J. (2026). *Chikyu Earth* (version 0.40.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
612
+ > Morris, J. (2026). *Chikyu Earth* (version 0.41.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
613
613
 
614
614
  GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
615
615
 
@@ -12,7 +12,7 @@ export declare const AIR_NOTE: {
12
12
  readonly ja: "大気は、見やすいように実際の厚さの{n}倍で描いています。";
13
13
  };
14
14
  /** The styles of the lines under the picture (`#notes`, with the air's `#air-note` and the meteors' `#meteor-note` in it, one above the other) in an element's shadow root. */
15
- export declare const NOTES_STYLE = "#notes{position:absolute;left:8px;right:8px;bottom:6px;display:flex;flex-direction:column;align-items:flex-start;gap:4px;pointer-events:none}#notes>p{position:static;margin:0;max-width:100%;font:11px/1.3 system-ui,sans-serif;color:#dfe6f2;background:#0b0e14b3;padding:2px 6px;border-radius:4px}#notes>p[hidden]{display:none}";
15
+ export declare const NOTES_STYLE = "#notes{position:absolute;left:8px;right:8px;bottom:6px;display:flex;flex-direction:column;align-items:flex-start;gap:4px;pointer-events:none}#notes>p{position:static;margin:0;max-width:100%;font:11px/1.3 system-ui,sans-serif;color:#dfe6f2;background:#0b0e14b3;padding:2px 6px;border-radius:4px}#notes>p[hidden]{display:none}#notes>#bodies-note{max-height:4.6em;overflow-y:auto;pointer-events:auto;overscroll-behavior:contain}";
16
16
  /** The words of the line for a thickness: a whole number is written plainly, any other with up to one decimal. */
17
17
  export declare function airNoteText(lang: "en" | "ja", thickness: number): string;
18
18
  /** Put the line right: its words in the language of the element or the page, shown only while the air is thicker than it is (`air-thickness` above 1) and `air-label` is not `off`. */
@@ -13,7 +13,7 @@ export const AIR_NOTE = {
13
13
  ja: "大気は、見やすいように実際の厚さの{n}倍で描いています。",
14
14
  };
15
15
  /** The styles of the lines under the picture (`#notes`, with the air's `#air-note` and the meteors' `#meteor-note` in it, one above the other) in an element's shadow root. */
16
- export const NOTES_STYLE = "#notes{position:absolute;left:8px;right:8px;bottom:6px;display:flex;flex-direction:column;align-items:flex-start;gap:4px;pointer-events:none}#notes>p{position:static;margin:0;max-width:100%;font:11px/1.3 system-ui,sans-serif;color:#dfe6f2;background:#0b0e14b3;padding:2px 6px;border-radius:4px}#notes>p[hidden]{display:none}";
16
+ export const NOTES_STYLE = "#notes{position:absolute;left:8px;right:8px;bottom:6px;display:flex;flex-direction:column;align-items:flex-start;gap:4px;pointer-events:none}#notes>p{position:static;margin:0;max-width:100%;font:11px/1.3 system-ui,sans-serif;color:#dfe6f2;background:#0b0e14b3;padding:2px 6px;border-radius:4px}#notes>p[hidden]{display:none}#notes>#bodies-note{max-height:4.6em;overflow-y:auto;pointer-events:auto;overscroll-behavior:contain}";
17
17
  /** The words of the line for a thickness: a whole number is written plainly, any other with up to one decimal. */
18
18
  export function airNoteText(lang, thickness) {
19
19
  return AIR_NOTE[lang].replace("{n}", String(Math.round(thickness * 10) / 10));
@@ -299,6 +299,7 @@ export class ChikyuSpace extends HTMLElement {
299
299
  cap: () => this.#textureCap(),
300
300
  air: () => airFor(this.getAttribute("air")),
301
301
  invalidate: () => this.#gate?.request(),
302
+ onBodies: () => this.#showBodiesCredit(),
302
303
  onError: (error) => this.#fail(error instanceof Error ? error.message : String(error)),
303
304
  onTier: (layer, width) => {
304
305
  this.#tiers[layer] = width;
@@ -487,15 +488,29 @@ export class ChikyuSpace extends HTMLElement {
487
488
  this.setAttribute("tiles", value);
488
489
  }
489
490
  /** The body painter's credit under the picture, in the element's or the page's language: shown while the painter draws the bodies (not `plain`), unless `bodies-credit` is `off`. */
491
+ /** The painter's credit as last told to the page (`chikyu-bodies-credit`): both languages, or empty for none. */
492
+ #creditKey = "";
490
493
  #showBodiesCredit() {
491
494
  const note = this.#bodiesNote;
492
495
  if (!note)
493
496
  return;
494
497
  const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
495
- const credit = painter?.credit?.[lang] ?? "";
496
- note.textContent = credit;
497
- note.lang = lang;
498
- note.hidden = credit === "" || this.bodies === "plain" || this.getAttribute("bodies-credit") === "off";
498
+ // read again at each redraw a body asks for (a picture arrived, a window of tiles changed): a painter's credit names the pictures on the screen now. Written only when the text changed, never at every frame.
499
+ const given = painter?.credit;
500
+ // a page that writes the credit itself (`bodies-credit="off"`) hears when the painter's credit changed
501
+ const key = given ? `${given.en}\n${given.ja}` : "";
502
+ if (key !== this.#creditKey) {
503
+ this.#creditKey = key;
504
+ this.dispatchEvent(new CustomEvent("chikyu-bodies-credit", { detail: given ? { en: given.en, ja: given.ja } : null }));
505
+ }
506
+ const credit = given?.[lang] ?? "";
507
+ if (note.textContent !== credit)
508
+ note.textContent = credit;
509
+ if (note.lang !== lang)
510
+ note.lang = lang;
511
+ const hidden = credit === "" || this.bodies === "plain" || this.getAttribute("bodies-credit") === "off";
512
+ if (note.hidden !== hidden)
513
+ note.hidden = hidden;
499
514
  }
500
515
  /**
501
516
  * True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape (the Earth fits the shorter side with its glow inside it, `earth-size`), a plain wheel zooms instead of scrolling
@@ -413,6 +413,8 @@ export interface SpaceDeps {
413
413
  satellitePainter?: () => SatellitePainter | undefined;
414
414
  /** The painter could not make a body (the three.js parts handed over lack something it needs); the body is drawn plain instead. */
415
415
  onPainterError?: (error: unknown) => void;
416
+ /** A body the painter drew changed (a picture arrived, a window of its tiles changed, a body was made): the painter's credit, which names the pictures on the screen now, may have changed. Told before the redraw is asked for. */
417
+ onBodies?: () => void;
416
418
  /** The map source of each layer now (the folder of the `tiles` attribute), or none: the Earth then keeps the package's own pictures. Read at every draw. */
417
419
  sources?: () => TileSources;
418
420
  /** Told once when the tile set has been read: the width in pixels of the finest level of each of its layers. */
@@ -250,6 +250,7 @@ export function createSpaceItem(model, deps) {
250
250
  }
251
251
  slot.drawing = made;
252
252
  scene.add(made.object);
253
+ deps.onBodies?.();
253
254
  deps.invalidate();
254
255
  };
255
256
  const fail = (error) => {
@@ -263,7 +264,7 @@ export function createSpaceItem(model, deps) {
263
264
  }
264
265
  };
265
266
  try {
266
- const made = (slot.plain || look === "plain" ? plainPainter : painter).make(three, slot.name, { look, invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap(), mapped: true });
267
+ const made = (slot.plain || look === "plain" ? plainPainter : painter).make(three, slot.name, { look, invalidate: () => (deps.onBodies?.(), deps.invalidate()), ratio: model.ratio(), maxTexture: deps.cap(), mapped: true });
267
268
  if (typeof made.then === "function")
268
269
  made.then(arrive, fail);
269
270
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on the place you give it, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
5
5
  "keywords": [
6
6
  "earth",
@@ -255,7 +255,7 @@
255
255
  "@johnmorrisdotca/hata": "^1.8.0",
256
256
  "@johnmorrisdotca/hoshi-stars": "^0.30.0",
257
257
  "@johnmorrisdotca/kuni": "^1.6.1",
258
- "@johnmorrisdotca/wakusei-planets": "^0.38.0",
258
+ "@johnmorrisdotca/wakusei-planets": "^0.39.0",
259
259
  "@playwright/test": "1.64.0",
260
260
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
261
261
  "@types/d3-geo": "^3.1.0",