celestial-chart 0.8.0 → 0.8.1

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.
@@ -7122,7 +7122,7 @@ function geoZoom() {
7122
7122
  // src/core.js
7123
7123
  var Celestial = {
7124
7124
  // Must match the package version — guarded by test/package.test.mjs.
7125
- version: "0.8.0",
7125
+ version: "0.8.1",
7126
7126
  container: null,
7127
7127
  data: []
7128
7128
  };
@@ -14464,6 +14464,7 @@ var SkyMap = class {
14464
14464
  var cfg, mapProjection, parentElement, zoom, map2, circle, daylight, starnames = {}, dsonames = {};
14465
14465
  var base = options && options.standalone ? settings : void 0;
14466
14466
  var instance = this;
14467
+ var layersEnabled = false;
14467
14468
  function $(id2) {
14468
14469
  return document.querySelector(parentElement + " #" + id2);
14469
14470
  }
@@ -14951,7 +14952,7 @@ var SkyMap = class {
14951
14952
  }
14952
14953
  });
14953
14954
  }
14954
- if (Celestial.data.length > 0) {
14955
+ if (layersEnabled && Celestial.data.length > 0) {
14955
14956
  Celestial.data.forEach(function(d) {
14956
14957
  d.redraw();
14957
14958
  });
@@ -15299,6 +15300,7 @@ var SkyMap = class {
15299
15300
  animate();
15300
15301
  };
15301
15302
  load();
15303
+ layersEnabled = true;
15302
15304
  }
15303
15305
  };
15304
15306
  ["constellations", "constellation"].forEach(function(name_) {
@@ -15321,6 +15323,7 @@ Celestial.display = function(config) {
15321
15323
  if (key_ === "constructor" || key_ === "constellations" || key_ === "constellation") continue;
15322
15324
  Object.defineProperty(Celestial, key_, descriptors[key_]);
15323
15325
  }
15326
+ instance.redraw();
15324
15327
  return instance;
15325
15328
  };
15326
15329
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "celestial-chart",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Interactive celestial map for the browser — a modernised fork of d3-celestial (D3 v7, ES modules, TypeScript types, multiple maps per page)",
5
5
  "keywords": [
6
6
  "astronomy",
package/src/celestial.js CHANGED
@@ -61,6 +61,19 @@ export class SkyMap {
61
61
  // change. A getter always exposes the current internal state.
62
62
  var instance = this;
63
63
 
64
+ // Layers added with Celestial.add() draw through the GLOBAL Celestial object
65
+ // (Celestial.container, .context, .mapProjection …) — that is how upstream's
66
+ // examples are written, and the interface upstream had from the start, because
67
+ // there `this` inside display() WAS the global object.
68
+ //
69
+ // Here the global only receives that interface once display() has copied it
70
+ // off the finished instance. A redraw that runs while this constructor is
71
+ // still executing — the zoom behaviour triggers one — would therefore call
72
+ // user layers against a global whose container is still null. So they stay
73
+ // switched off until the constructor is done; display() draws them right
74
+ // after it has published the interface.
75
+ var layersEnabled = false;
76
+
64
77
  // Element lookup inside this map's own parent element. This used to live in
65
78
  // util.js, reached through a shared "current map" pointer — so two maps would
66
79
  // have found each other's elements.
@@ -724,7 +737,7 @@ export class SkyMap {
724
737
  });
725
738
  }
726
739
 
727
- if (Celestial.data.length > 0) {
740
+ if (layersEnabled && Celestial.data.length > 0) {
728
741
  Celestial.data.forEach( function(d) {
729
742
  d.redraw();
730
743
  });
@@ -1134,6 +1147,7 @@ export class SkyMap {
1134
1147
  this.date = function() { console.log("Celestial.date() needs config.location = true to work." ); };
1135
1148
  */
1136
1149
  load();
1150
+ layersEnabled = true;
1137
1151
  }
1138
1152
  }
1139
1153
 
@@ -1168,6 +1182,8 @@ Celestial.display = function (config) {
1168
1182
  if (key_ === "constructor" || key_ === "constellations" || key_ === "constellation") continue;
1169
1183
  Object.defineProperty(Celestial, key_, descriptors[key_]);
1170
1184
  }
1185
+ // Now that the global interface exists, the layers can be drawn.
1186
+ instance.redraw();
1171
1187
  return instance;
1172
1188
  };
1173
1189
 
package/src/core.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // first, and by the time anyone touches the object it already exists.
9
9
  export var Celestial = {
10
10
  // Must match the package version — guarded by test/package.test.mjs.
11
- version: '0.8.0',
11
+ version: '0.8.1',
12
12
  container: null,
13
13
  data: []
14
14
  };