@geolith/globe 0.1.0 → 0.2.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/README.md +2 -2
- package/dist/index.d.ts +143 -101
- package/dist/index.js +351 -206
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
- package/dist/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { computed,
|
|
1
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, onBeforeUnmount, onMounted, openBlock, ref, shallowRef, toDisplayString, unref, watch, withCtx } from "vue";
|
|
2
2
|
import { WeatherFieldLayer, WindParticleLayer, decodeGrid } from "@geoql/maplibre-gl-weather";
|
|
3
3
|
import { SliderRange, SliderRoot, SliderThumb, SliderTrack } from "reka-ui";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
// src/components/GlobeSkeleton.vue
|
|
5
|
+
const _hoisted_1$4 = {
|
|
6
|
+
"data-globe-skeleton": "",
|
|
7
|
+
class: "globe-skeleton"
|
|
8
|
+
};
|
|
9
|
+
const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
10
|
+
__name: "GlobeSkeleton",
|
|
11
|
+
setup(__props) {
|
|
12
|
+
return (_ctx, _cache) => {
|
|
13
|
+
return openBlock(), createElementBlock("div", _hoisted_1$4, [..._cache[0] || (_cache[0] = [createElementVNode("span", {
|
|
14
|
+
class: "globe-skeleton-ring",
|
|
15
|
+
"aria-hidden": "true"
|
|
16
|
+
}, null, -1), createElementVNode("span", { class: "globe-skeleton-label" }, "Loading the globe", -1)])]);
|
|
17
|
+
};
|
|
14
18
|
}
|
|
15
19
|
});
|
|
16
20
|
// src/utils/camera.ts
|
|
@@ -134,12 +138,146 @@ function paletteFor(field) {
|
|
|
134
138
|
if (field === "tmax" || field === "tmin") return TEMPERATURE_RAMP;
|
|
135
139
|
return WIND_RAMP;
|
|
136
140
|
}
|
|
141
|
+
// src/utils/field-frames.ts
|
|
142
|
+
/** The quantised cell that means "no data" in every grid. */
|
|
143
|
+
const NO_DATA = 255;
|
|
144
|
+
/**
|
|
145
|
+
* Rain as a field is mostly dry: the ramp's lowest stop is near-white, so a dry
|
|
146
|
+
* cell would paint the planet white. Cells under `minValue` (millimetres) are
|
|
147
|
+
* set to the no-data byte, so rain shows where rain is and nothing elsewhere.
|
|
148
|
+
*
|
|
149
|
+
* Only a rain grid is masked: a temperature cell is never "dry", and a wind
|
|
150
|
+
* component of zero is calm air, not an absence.
|
|
151
|
+
*/
|
|
152
|
+
function maskDryRain(frames, minValue) {
|
|
153
|
+
return frames.map((grid) => {
|
|
154
|
+
const { meta } = grid;
|
|
155
|
+
if (meta.field !== "rain" || !(meta.scale > 0)) return grid;
|
|
156
|
+
const cut = Math.ceil((minValue - meta.offset) / meta.scale);
|
|
157
|
+
if (cut <= 0) return grid;
|
|
158
|
+
const bytes = new Uint8Array(grid.bytes);
|
|
159
|
+
let changed = false;
|
|
160
|
+
for (let index = 0; index < bytes.length; index += 1) if ((bytes[index] ?? NO_DATA) < cut) {
|
|
161
|
+
bytes[index] = NO_DATA;
|
|
162
|
+
changed = true;
|
|
163
|
+
}
|
|
164
|
+
return changed ? decodeGrid(bytes, meta) : grid;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// src/utils/particles.ts
|
|
168
|
+
/**
|
|
169
|
+
* How much of the particle budget the field may carry.
|
|
170
|
+
*
|
|
171
|
+
* Measured on this Mac (Chromium, SwiftShader, 1440×900, globe at z1.5, the
|
|
172
|
+
* field hidden so only the wind shows): the share of canvas pixels carrying a
|
|
173
|
+
* stroke is 1.1 % at 200 particles, 8.2 % at 4 200, 8.9 % at 8 000, 9.3 % at
|
|
174
|
+
* 14 700 and 9.9 % at 42 000. The curve is flat above ~4 000: 42 000 buys
|
|
175
|
+
* 1.7 points of coverage for ten times the work. `0.15` spends 6 300 at a
|
|
176
|
+
* desktop width and ~1 100 on a phone, just above the knee; the console's own
|
|
177
|
+
* report (a full budget became a white sheet on a phone) is the same finding
|
|
178
|
+
* from the other side. A host that wants more can pass its own count.
|
|
179
|
+
*/
|
|
180
|
+
const PARTICLE_DENSITY = .15;
|
|
181
|
+
/**
|
|
182
|
+
* Particles for a viewport: the handover budget scaled by the measured density,
|
|
183
|
+
* and none at all for a visitor who prefers reduced motion.
|
|
184
|
+
*/
|
|
185
|
+
function particleDensity(width, dpr, reducedMotion) {
|
|
186
|
+
if (reducedMotion) return 0;
|
|
187
|
+
return Math.max(1, Math.round(particleCount(width, dpr, false) * PARTICLE_DENSITY));
|
|
188
|
+
}
|
|
189
|
+
// src/utils/districts.ts
|
|
190
|
+
/** The source layer the area tiles carry. */
|
|
191
|
+
const AREA_SOURCE_LAYER = "areas";
|
|
192
|
+
const AREA_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
193
|
+
/**
|
|
194
|
+
* A district feature's own id.
|
|
195
|
+
*
|
|
196
|
+
* The MVT feature id is a tile-local integer; the area's UUID is the `id`
|
|
197
|
+
* property. Reading the integer asks the API for "area=192", which is not an
|
|
198
|
+
* area at all.
|
|
199
|
+
*/
|
|
200
|
+
function areaIdOf(properties) {
|
|
201
|
+
const id = properties?.["id"];
|
|
202
|
+
return typeof id === "string" && AREA_ID.test(id) ? id : null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Adds a country's area source and its two layers, once per style. The fill
|
|
206
|
+
* fades in on the same ramp the field fades out on; the line keeps a coastline
|
|
207
|
+
* readable over the weather.
|
|
208
|
+
*/
|
|
209
|
+
function addDistrictLayers(map, country, url) {
|
|
210
|
+
const sourceId = `globe-districts-${country}`;
|
|
211
|
+
const fill = `${sourceId}-fill`;
|
|
212
|
+
const line = `${sourceId}-line`;
|
|
213
|
+
if (!map.getSource(sourceId)) map.addSource(sourceId, {
|
|
214
|
+
type: "vector",
|
|
215
|
+
tiles: [url],
|
|
216
|
+
minzoom: 0,
|
|
217
|
+
maxzoom: 9
|
|
218
|
+
});
|
|
219
|
+
if (!map.getLayer(fill)) map.addLayer({
|
|
220
|
+
id: fill,
|
|
221
|
+
type: "fill",
|
|
222
|
+
source: sourceId,
|
|
223
|
+
"source-layer": AREA_SOURCE_LAYER,
|
|
224
|
+
paint: {
|
|
225
|
+
"fill-color": paletteFor("rain")[4] ?? "#7fb2c9",
|
|
226
|
+
"fill-opacity": [
|
|
227
|
+
"interpolate",
|
|
228
|
+
["linear"],
|
|
229
|
+
["zoom"],
|
|
230
|
+
6,
|
|
231
|
+
0,
|
|
232
|
+
7.5,
|
|
233
|
+
.45
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
if (!map.getLayer(line)) map.addLayer({
|
|
238
|
+
id: line,
|
|
239
|
+
type: "line",
|
|
240
|
+
source: sourceId,
|
|
241
|
+
"source-layer": AREA_SOURCE_LAYER,
|
|
242
|
+
paint: {
|
|
243
|
+
"line-color": paletteFor("rain")[6] ?? "#2b5d74",
|
|
244
|
+
"line-width": .6,
|
|
245
|
+
"line-opacity": .7
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
sourceId,
|
|
250
|
+
fill,
|
|
251
|
+
line
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/** Reports a district click by the area's own UUID, and the pointer shape. */
|
|
255
|
+
function bindDistrictClicks(map, fill, onSelect) {
|
|
256
|
+
map.on("click", fill, (event) => {
|
|
257
|
+
const id = areaIdOf(event.features?.[0]?.properties ?? null);
|
|
258
|
+
if (id !== null) onSelect(id);
|
|
259
|
+
});
|
|
260
|
+
map.on("mousemove", fill, () => {
|
|
261
|
+
map.getCanvas().style.cursor = "pointer";
|
|
262
|
+
});
|
|
263
|
+
map.on("mouseleave", fill, () => {
|
|
264
|
+
map.getCanvas().style.cursor = "";
|
|
265
|
+
});
|
|
266
|
+
}
|
|
137
267
|
// src/composables/use-globe-map.ts
|
|
138
|
-
const
|
|
268
|
+
const FIELD_ID = "globe-field";
|
|
269
|
+
const FIELD_OPACITY = .85;
|
|
270
|
+
const PARTICLES_ID = "globe-particles";
|
|
271
|
+
/** Rain under this many millimetres is dry: no-data, not a white wash. */
|
|
272
|
+
const DRY_RAIN_MM = 1;
|
|
139
273
|
/**
|
|
140
|
-
* The map's lifecycle and its layers.
|
|
141
|
-
*
|
|
142
|
-
*
|
|
274
|
+
* The map's lifecycle and its layers.
|
|
275
|
+
*
|
|
276
|
+
* MapLibre 6 refuses `setProjection` until a style is loaded, so the globe is
|
|
277
|
+
* converted on `load` and again on `style.load` (a new style drops both the
|
|
278
|
+
* projection and every custom layer). A mount can never run twice, and every
|
|
279
|
+
* add is guarded by the layer's existence, so N mounts and any number of prop
|
|
280
|
+
* changes leave exactly one map and one canvas.
|
|
143
281
|
*/
|
|
144
282
|
function useGlobeMap(input) {
|
|
145
283
|
const map = shallowRef(null);
|
|
@@ -147,7 +285,8 @@ function useGlobeMap(input) {
|
|
|
147
285
|
let particles = null;
|
|
148
286
|
let frame = 0;
|
|
149
287
|
let interacted = false;
|
|
150
|
-
let
|
|
288
|
+
let mounting = false;
|
|
289
|
+
let districtBound = false;
|
|
151
290
|
const stopRotation = () => {
|
|
152
291
|
if (frame !== 0) cancelAnimationFrame(frame);
|
|
153
292
|
frame = 0;
|
|
@@ -160,21 +299,28 @@ function useGlobeMap(input) {
|
|
|
160
299
|
instance.setCenter([lng > 180 ? lng - 360 : lng, centre.lat]);
|
|
161
300
|
frame = requestAnimationFrame(rotate);
|
|
162
301
|
};
|
|
302
|
+
/** The projection, once the style can take it. */
|
|
303
|
+
const project = (instance) => {
|
|
304
|
+
if (!instance.isStyleLoaded()) return;
|
|
305
|
+
instance.setProjection({ type: "globe" });
|
|
306
|
+
};
|
|
163
307
|
const addField = (instance) => {
|
|
164
308
|
const frames = input.frames.value;
|
|
165
|
-
if (frames.length === 0
|
|
309
|
+
if (frames.length === 0) return;
|
|
310
|
+
if (field && instance.getLayer(FIELD_ID)) {
|
|
311
|
+
field.setFrames(maskDryRain(frames, DRY_RAIN_MM), input.mix.value);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
166
314
|
const first = frames[0];
|
|
167
315
|
const palette = input.palette ?? paletteFor(first?.meta.field ?? "rain");
|
|
168
316
|
field = new WeatherFieldLayer({
|
|
169
|
-
|
|
317
|
+
id: FIELD_ID,
|
|
318
|
+
frames: maskDryRain(frames, DRY_RAIN_MM),
|
|
170
319
|
mix: input.mix.value,
|
|
171
320
|
palette,
|
|
172
|
-
opacity:
|
|
173
|
-
});
|
|
174
|
-
instance.addLayer(field);
|
|
175
|
-
instance.on("zoom", () => {
|
|
176
|
-
field?.setOpacity(DEFAULT_FIELD_OPACITY * fieldOpacity(instance.getZoom()));
|
|
321
|
+
opacity: FIELD_OPACITY
|
|
177
322
|
});
|
|
323
|
+
if (!instance.getLayer(FIELD_ID)) instance.addLayer(field);
|
|
178
324
|
};
|
|
179
325
|
const addParticles = (instance) => {
|
|
180
326
|
const wind = input.wind.value;
|
|
@@ -182,95 +328,86 @@ function useGlobeMap(input) {
|
|
|
182
328
|
const width = input.host.value?.clientWidth ?? 0;
|
|
183
329
|
const dpr = globalThis.devicePixelRatio ?? 1;
|
|
184
330
|
particles = new WindParticleLayer({
|
|
331
|
+
id: PARTICLES_ID,
|
|
185
332
|
u: wind.u,
|
|
186
333
|
v: wind.v,
|
|
187
|
-
count:
|
|
334
|
+
count: particleDensity(width, dpr, input.reducedMotion),
|
|
188
335
|
animated: !input.reducedMotion
|
|
189
336
|
});
|
|
190
|
-
instance.addLayer(particles);
|
|
337
|
+
if (!instance.getLayer(PARTICLES_ID)) instance.addLayer(particles);
|
|
191
338
|
};
|
|
192
339
|
const addDistricts = (instance) => {
|
|
193
340
|
const district = input.district.value;
|
|
194
341
|
if (!district) return;
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
tiles: [district.url]
|
|
200
|
-
});
|
|
201
|
-
instance.addLayer({
|
|
202
|
-
id: `${sourceId}-fill`,
|
|
203
|
-
type: "fill",
|
|
204
|
-
source: sourceId,
|
|
205
|
-
paint: {
|
|
206
|
-
"fill-color": paletteFor("rain")[3] ?? "#4292c6",
|
|
207
|
-
"fill-opacity": [
|
|
208
|
-
"interpolate",
|
|
209
|
-
["linear"],
|
|
210
|
-
["zoom"],
|
|
211
|
-
6.5,
|
|
212
|
-
0,
|
|
213
|
-
8,
|
|
214
|
-
1
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
});
|
|
342
|
+
const ids = addDistrictLayers(instance, district.country, district.url);
|
|
343
|
+
if (districtBound || !input.onSelect) return;
|
|
344
|
+
districtBound = true;
|
|
345
|
+
bindDistrictClicks(instance, ids.fill, input.onSelect);
|
|
218
346
|
};
|
|
219
347
|
const wire = () => {
|
|
220
348
|
const instance = map.value;
|
|
221
|
-
if (!instance || !
|
|
349
|
+
if (!instance || !instance.isStyleLoaded()) return;
|
|
222
350
|
addField(instance);
|
|
223
351
|
addParticles(instance);
|
|
224
352
|
addDistricts(instance);
|
|
225
353
|
};
|
|
226
354
|
const mount = async () => {
|
|
227
|
-
if (map.value) return;
|
|
355
|
+
if (map.value || mounting) return;
|
|
228
356
|
const host = input.host.value;
|
|
229
357
|
if (!host || typeof window === "undefined") return;
|
|
230
358
|
const rect = host.getBoundingClientRect();
|
|
231
359
|
if (rect.width === 0 || rect.height === 0) return;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
360
|
+
mounting = true;
|
|
361
|
+
try {
|
|
362
|
+
const { Map } = await import("maplibre-gl");
|
|
363
|
+
if (map.value) return;
|
|
364
|
+
const camera = openingCamera(input.centroid);
|
|
365
|
+
const created = new Map({
|
|
366
|
+
container: host,
|
|
367
|
+
style: input.style,
|
|
368
|
+
center: camera.center,
|
|
369
|
+
zoom: camera.zoom,
|
|
370
|
+
minZoom: 0,
|
|
371
|
+
pitch: camera.pitch,
|
|
372
|
+
attributionControl: false
|
|
373
|
+
});
|
|
374
|
+
map.value = created;
|
|
375
|
+
created.on("load", () => {
|
|
376
|
+
project(created);
|
|
377
|
+
wire();
|
|
378
|
+
input.onIdle();
|
|
379
|
+
});
|
|
380
|
+
created.on("style.load", () => {
|
|
381
|
+
districtBound = false;
|
|
382
|
+
project(created);
|
|
383
|
+
wire();
|
|
384
|
+
});
|
|
385
|
+
created.on("zoom", () => {
|
|
386
|
+
if (!field) return;
|
|
387
|
+
field.setOpacity(FIELD_OPACITY * fieldOpacity(created.getZoom()));
|
|
388
|
+
});
|
|
389
|
+
const stop = () => {
|
|
390
|
+
interacted = true;
|
|
391
|
+
stopRotation();
|
|
392
|
+
};
|
|
393
|
+
const canvas = created.getCanvas();
|
|
394
|
+
canvas.addEventListener("pointerdown", stop, { once: true });
|
|
395
|
+
canvas.addEventListener("wheel", stop, { once: true });
|
|
396
|
+
canvas.addEventListener("touchstart", stop, { once: true });
|
|
397
|
+
if (shouldRotate(input.reducedMotion, interacted)) frame = requestAnimationFrame(rotate);
|
|
398
|
+
} finally {
|
|
399
|
+
mounting = false;
|
|
400
|
+
}
|
|
258
401
|
};
|
|
259
|
-
watch(input.frames, () =>
|
|
260
|
-
if (field) field.setFrames(input.frames.value, input.mix.value);
|
|
261
|
-
else wire();
|
|
262
|
-
});
|
|
402
|
+
watch(input.frames, () => wire());
|
|
263
403
|
watch(input.mix, (value) => field?.setMix(value));
|
|
264
404
|
watch(input.wind, () => wire());
|
|
265
405
|
watch(input.district, () => wire());
|
|
266
|
-
watch(input.mountWhen, (ready) => {
|
|
267
|
-
if (ready) mount();
|
|
268
|
-
});
|
|
269
406
|
const dispose = () => {
|
|
270
407
|
stopRotation();
|
|
271
408
|
field = null;
|
|
272
409
|
particles = null;
|
|
273
|
-
|
|
410
|
+
districtBound = false;
|
|
274
411
|
map.value?.remove();
|
|
275
412
|
map.value = null;
|
|
276
413
|
};
|
|
@@ -280,56 +417,36 @@ function useGlobeMap(input) {
|
|
|
280
417
|
dispose
|
|
281
418
|
};
|
|
282
419
|
}
|
|
283
|
-
|
|
284
|
-
|
|
420
|
+
// src/components/GlobeCanvas.vue
|
|
421
|
+
const _hoisted_1$3 = ["data-globe"];
|
|
422
|
+
/**
|
|
423
|
+
* The globe itself. It draws the skeleton until the caller's data is ready,
|
|
424
|
+
* mounts a WebGL map only where its host has a size, and rotates slowly until
|
|
425
|
+
* the visitor touches it. `data-globe` carries the caller's status: it is what
|
|
426
|
+
* the 2.5 s budget waits for.
|
|
427
|
+
*/
|
|
428
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
429
|
+
__name: "GlobeCanvas",
|
|
285
430
|
props: {
|
|
286
|
-
layers: {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
type: Object,
|
|
292
|
-
required: true
|
|
293
|
-
},
|
|
294
|
-
style: {
|
|
295
|
-
type: Object,
|
|
296
|
-
required: true
|
|
297
|
-
},
|
|
298
|
-
status: {
|
|
299
|
-
type: String,
|
|
300
|
-
required: true
|
|
301
|
-
},
|
|
302
|
-
centroid: {
|
|
303
|
-
type: Array,
|
|
304
|
-
default: null
|
|
305
|
-
},
|
|
431
|
+
layers: {},
|
|
432
|
+
dataSource: {},
|
|
433
|
+
style: {},
|
|
434
|
+
status: {},
|
|
435
|
+
centroid: { default: null },
|
|
306
436
|
reducedMotion: {
|
|
307
437
|
type: Boolean,
|
|
308
438
|
default: false
|
|
309
439
|
},
|
|
310
|
-
frames: {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
type: Number,
|
|
316
|
-
default: 0
|
|
317
|
-
},
|
|
318
|
-
palette: {
|
|
319
|
-
type: Array,
|
|
320
|
-
default: null
|
|
321
|
-
},
|
|
322
|
-
wind: {
|
|
323
|
-
type: Object,
|
|
324
|
-
default: null
|
|
325
|
-
},
|
|
326
|
-
district: {
|
|
327
|
-
type: Object,
|
|
328
|
-
default: null
|
|
329
|
-
}
|
|
440
|
+
frames: { default: () => [] },
|
|
441
|
+
mix: { default: 0 },
|
|
442
|
+
palette: { default: null },
|
|
443
|
+
wind: { default: null },
|
|
444
|
+
district: { default: null }
|
|
330
445
|
},
|
|
331
|
-
emits: ["idle"],
|
|
332
|
-
setup(
|
|
446
|
+
emits: ["idle", "select"],
|
|
447
|
+
setup(__props, { emit: __emit }) {
|
|
448
|
+
const props = __props;
|
|
449
|
+
const emit = __emit;
|
|
333
450
|
const host = ref(null);
|
|
334
451
|
const frames = ref(props.frames);
|
|
335
452
|
const mix = ref(props.mix);
|
|
@@ -348,7 +465,8 @@ const GlobeCanvas = defineComponent({
|
|
|
348
465
|
wind,
|
|
349
466
|
district,
|
|
350
467
|
mountWhen,
|
|
351
|
-
onIdle: () => emit("idle")
|
|
468
|
+
onIdle: () => emit("idle"),
|
|
469
|
+
onSelect: (areaId) => emit("select", areaId)
|
|
352
470
|
});
|
|
353
471
|
watch(() => props.frames, (value) => {
|
|
354
472
|
frames.value = value;
|
|
@@ -369,103 +487,130 @@ const GlobeCanvas = defineComponent({
|
|
|
369
487
|
if (props.status === "ready") globe.mount();
|
|
370
488
|
});
|
|
371
489
|
onBeforeUnmount(() => globe.dispose());
|
|
372
|
-
return () =>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
490
|
+
return (_ctx, _cache) => {
|
|
491
|
+
return openBlock(), createElementBlock("div", {
|
|
492
|
+
ref_key: "host",
|
|
493
|
+
ref: host,
|
|
494
|
+
class: "globe-canvas",
|
|
495
|
+
"data-globe": __props.status,
|
|
496
|
+
"data-globe-host": ""
|
|
497
|
+
}, [__props.status === "loading" ? (openBlock(), createBlock(_sfc_main$3, { key: 0 })) : createCommentVNode("v-if", true)], 8, _hoisted_1$3);
|
|
498
|
+
};
|
|
378
499
|
}
|
|
379
500
|
});
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
501
|
+
// src/components/GlobeLock.vue
|
|
502
|
+
const _hoisted_1$2 = ["data-globe-lock"];
|
|
503
|
+
/**
|
|
504
|
+
* The locked state for a country whose district numbers the caller may not
|
|
505
|
+
* show: one sentence in the catalogue's words, and a button the page answers
|
|
506
|
+
* with its own unlock flow.
|
|
507
|
+
*/
|
|
508
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
509
|
+
__name: "GlobeLock",
|
|
510
|
+
props: { country: {} },
|
|
511
|
+
emits: ["unlockRequest"],
|
|
512
|
+
setup(__props, { emit: __emit }) {
|
|
513
|
+
const emit = __emit;
|
|
514
|
+
return (_ctx, _cache) => {
|
|
515
|
+
return openBlock(), createElementBlock("div", {
|
|
516
|
+
class: "globe-lock",
|
|
517
|
+
"data-globe-lock": __props.country
|
|
518
|
+
}, [_cache[1] || (_cache[1] = createElementVNode("p", { class: "globe-lock-copy" }, " District data is not open for this country yet. ", -1)), createElementVNode("button", {
|
|
519
|
+
type: "button",
|
|
520
|
+
class: "globe-lock-action",
|
|
521
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("unlockRequest", { country: __props.country }))
|
|
522
|
+
}, " Unlock district data for 230 countries ")], 8, _hoisted_1$2);
|
|
523
|
+
};
|
|
396
524
|
}
|
|
397
525
|
});
|
|
398
|
-
|
|
399
|
-
|
|
526
|
+
// src/components/GlobeReadout.vue
|
|
527
|
+
const _hoisted_1$1 = ["data-globe-readout"];
|
|
528
|
+
/**
|
|
529
|
+
* Shows the field's value under the pointer. A cell with no data prints
|
|
530
|
+
* nothing — never `NaN`, never `0`, which a reader would take for a
|
|
531
|
+
* measurement.
|
|
532
|
+
*/
|
|
533
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
534
|
+
__name: "GlobeReadout",
|
|
400
535
|
props: {
|
|
401
|
-
value: {
|
|
402
|
-
|
|
403
|
-
default: null
|
|
404
|
-
},
|
|
405
|
-
unit: {
|
|
406
|
-
type: String,
|
|
407
|
-
required: true
|
|
408
|
-
}
|
|
536
|
+
value: { default: null },
|
|
537
|
+
unit: {}
|
|
409
538
|
},
|
|
410
|
-
setup(
|
|
411
|
-
|
|
539
|
+
setup(__props) {
|
|
540
|
+
const props = __props;
|
|
541
|
+
const shown = computed(() => {
|
|
412
542
|
const value = props.value;
|
|
413
|
-
if (value === null) return
|
|
414
|
-
|
|
415
|
-
|
|
543
|
+
if (value === null) return "";
|
|
544
|
+
return `${Math.round(value * 10) / 10} ${props.unit}`;
|
|
545
|
+
});
|
|
546
|
+
return (_ctx, _cache) => {
|
|
547
|
+
return openBlock(), createElementBlock("span", {
|
|
416
548
|
class: "globe-readout",
|
|
417
|
-
"data-globe-readout": ""
|
|
418
|
-
},
|
|
549
|
+
"data-globe-readout": shown.value === "" ? void 0 : ""
|
|
550
|
+
}, toDisplayString(shown.value), 9, _hoisted_1$1);
|
|
419
551
|
};
|
|
420
552
|
}
|
|
421
553
|
});
|
|
422
|
-
|
|
423
|
-
|
|
554
|
+
// src/components/GlobeTimeSlider.vue
|
|
555
|
+
const _hoisted_1 = {
|
|
556
|
+
class: "globe-slider",
|
|
557
|
+
"data-globe-slider": ""
|
|
558
|
+
};
|
|
559
|
+
const _hoisted_2 = ["aria-label", "aria-pressed"];
|
|
560
|
+
const _hoisted_3 = { class: "globe-slider-label" };
|
|
561
|
+
/**
|
|
562
|
+
* The time axis of the globe. The label is the index's label (a UTC day),
|
|
563
|
+
* never a date computed here, and it is the slider's `aria-valuetext`, so a
|
|
564
|
+
* screen reader and the visible caption read the same value.
|
|
565
|
+
*/
|
|
566
|
+
const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
567
|
+
__name: "GlobeTimeSlider",
|
|
424
568
|
props: {
|
|
425
|
-
labels: {
|
|
426
|
-
|
|
427
|
-
required: true
|
|
428
|
-
},
|
|
429
|
-
modelValue: {
|
|
430
|
-
type: Number,
|
|
431
|
-
required: true
|
|
432
|
-
},
|
|
569
|
+
labels: {},
|
|
570
|
+
modelValue: {},
|
|
433
571
|
playing: {
|
|
434
572
|
type: Boolean,
|
|
435
573
|
default: false
|
|
436
574
|
}
|
|
437
575
|
},
|
|
438
576
|
emits: ["update:modelValue", "toggle"],
|
|
439
|
-
setup(
|
|
440
|
-
const
|
|
441
|
-
const
|
|
577
|
+
setup(__props, { emit: __emit }) {
|
|
578
|
+
const props = __props;
|
|
579
|
+
const emit = __emit;
|
|
580
|
+
const label = computed(() => props.labels[props.modelValue] ?? "");
|
|
581
|
+
const onUpdate = (value) => {
|
|
442
582
|
const next = value?.[0];
|
|
443
583
|
if (typeof next === "number") emit("update:modelValue", next);
|
|
444
584
|
};
|
|
445
|
-
return () =>
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
585
|
+
return (_ctx, _cache) => {
|
|
586
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
587
|
+
createElementVNode("button", {
|
|
588
|
+
type: "button",
|
|
589
|
+
class: "globe-slider-play",
|
|
590
|
+
"aria-label": __props.playing ? "Pause" : "Play",
|
|
591
|
+
"aria-pressed": __props.playing,
|
|
592
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("toggle"))
|
|
593
|
+
}, toDisplayString(__props.playing ? "Pause" : "Play"), 9, _hoisted_2),
|
|
594
|
+
createVNode(unref(SliderRoot), {
|
|
595
|
+
class: "globe-slider-root",
|
|
596
|
+
"model-value": [__props.modelValue],
|
|
597
|
+
max: Math.max(__props.labels.length - 1, 0),
|
|
598
|
+
step: 1,
|
|
599
|
+
"onUpdate:modelValue": onUpdate
|
|
600
|
+
}, {
|
|
601
|
+
default: withCtx(() => [createVNode(unref(SliderTrack), { class: "globe-slider-track" }, {
|
|
602
|
+
default: withCtx(() => [createVNode(unref(SliderRange), { class: "globe-slider-range" })]),
|
|
603
|
+
_: 1
|
|
604
|
+
}), createVNode(unref(SliderThumb), {
|
|
605
|
+
class: "globe-slider-thumb",
|
|
606
|
+
"aria-label": "Forecast day",
|
|
607
|
+
"aria-valuetext": label.value
|
|
608
|
+
}, null, 8, ["aria-valuetext"])]),
|
|
609
|
+
_: 1
|
|
610
|
+
}, 8, ["model-value", "max"]),
|
|
611
|
+
createElementVNode("span", _hoisted_3, toDisplayString(label.value), 1)
|
|
612
|
+
]);
|
|
613
|
+
};
|
|
469
614
|
}
|
|
470
615
|
});
|
|
471
616
|
// src/composables/use-globe-state.ts
|
|
@@ -735,6 +880,6 @@ function useGlobeDistricts(input) {
|
|
|
735
880
|
};
|
|
736
881
|
return { layerFor };
|
|
737
882
|
}
|
|
738
|
-
export { DISTRICT_FADE, FIELD_FADE, FIELD_PALETTES, GlobeCanvas, GlobeLock, GlobeReadout, GlobeSkeleton, GlobeTimeSlider, OPEN_PITCH, OPEN_ZOOM, PARTICLE_CAP, RAIN_RAMP, ROTATE_DEGREES_PER_SECOND, TEMPERATURE_RAMP, WIND_RAMP, WORLD_CENTRE, districtOpacity, fieldOpacity, openingCamera, paletteFor, particleCount, shouldRotate, useGlobeDistricts, useGlobeFields, useGlobeMap, useGlobeParticles, useGlobeState };
|
|
883
|
+
export { DISTRICT_FADE, FIELD_FADE, FIELD_PALETTES, _sfc_main as GlobeCanvas, _sfc_main$1 as GlobeLock, _sfc_main$2 as GlobeReadout, _sfc_main$3 as GlobeSkeleton, _sfc_main$4 as GlobeTimeSlider, OPEN_PITCH, OPEN_ZOOM, PARTICLE_CAP, RAIN_RAMP, ROTATE_DEGREES_PER_SECOND, TEMPERATURE_RAMP, WIND_RAMP, WORLD_CENTRE, districtOpacity, fieldOpacity, openingCamera, paletteFor, particleCount, shouldRotate, useGlobeDistricts, useGlobeFields, useGlobeMap, useGlobeParticles, useGlobeState };
|
|
739
884
|
|
|
740
885
|
//# sourceMappingURL=index.js.map
|