@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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isIndex"],"sources":["../src/components/GlobeSkeleton.ts","../src/utils/camera.ts","../src/utils/handover.ts","../src/utils/palette.ts","../src/composables/use-globe-map.ts","../src/components/GlobeCanvas.ts","../src/components/GlobeLock.ts","../src/components/GlobeReadout.ts","../src/components/GlobeTimeSlider.ts","../src/composables/use-globe-state.ts","../src/composables/use-globe-fields.ts","../src/composables/use-globe-particles.ts","../src/composables/use-globe-districts.ts"],"sourcesContent":["import { defineComponent, h } from 'vue';\nimport type { Component } from 'vue';\n\n/**\n * What the globe shows before a frame is ready: the planet's silhouette, not a\n * black rectangle. `data-globe-skeleton` is what the canvas test and the UI\n * sweep assert on.\n */\nconst GlobeSkeletonComponent = defineComponent({\n name: 'GlobeSkeleton',\n setup() {\n return () =>\n h('div', { 'data-globe-skeleton': '', class: 'globe-skeleton' }, [\n h('span', { class: 'globe-skeleton-ring', 'aria-hidden': 'true' }),\n h('span', { class: 'globe-skeleton-label' }, 'Loading the globe'),\n ]);\n },\n});\n\nexport const GlobeSkeleton: Component = GlobeSkeletonComponent;\n","/**\n * The globe opens at a fixed zoom and pitch, over one place: the visitor's\n * country when the caller resolved it, the world otherwise.\n */\nexport const OPEN_ZOOM = 1.8;\n\n/** The globe is never tilted on open: a tilted planet hides half the field. */\nexport const OPEN_PITCH = 0;\n\n/**\n * Slow rotation so a still visitor sees a planet, not a poster. One full turn\n * takes five minutes; faster reads as a loading spinner.\n */\nexport const ROTATE_DEGREES_PER_SECOND = 1.2;\n\n/** The world view: equirectangular centre of the planet, 20° north. */\nexport const WORLD_CENTRE: readonly [number, number] = [0, 20];\n\n/** Where the globe opens. */\nexport interface OpeningCamera {\n readonly center: [number, number];\n readonly zoom: number;\n readonly pitch: number;\n}\n\n/**\n * The opening camera: the visitor's country's centroid when it is known, the\n * world otherwise.\n *\n * @param centroid - `[lon, lat]` of the visitor's country, or null when unknown.\n */\nexport function openingCamera(\n centroid: readonly [number, number] | null,\n): OpeningCamera {\n const centre: [number, number] = centroid\n ? [centroid[0], centroid[1]]\n : [WORLD_CENTRE[0], WORLD_CENTRE[1]];\n return { center: centre, zoom: OPEN_ZOOM, pitch: OPEN_PITCH };\n}\n\n/**\n * Whether the globe should rotate right now. Reduced motion is honoured, and the\n * first interaction hands control to the visitor for good.\n */\nexport function shouldRotate(\n reducedMotion: boolean,\n interacted: boolean,\n): boolean {\n return !reducedMotion && !interacted;\n}\n","/**\n * Zoom range over which the field fades out and the districts fade in. They are\n * the same two numbers on purpose: the globe is always showing one of them, and\n * a seam between the ramps would show as a flash of bare basemap.\n */\nexport const FIELD_FADE: readonly [number, number] = [6.5, 8];\n\n/** The districts' half of the same handover. */\nexport const DISTRICT_FADE: readonly [number, number] = [6.5, 8];\n\n/** The desktop particle count the spike measured as free on a desktop GPU. */\nexport const PARTICLE_CAP = 42_000;\n\nconst RAMP: readonly [number, number] = FIELD_FADE;\n\n/**\n * Opacity of the global field at a zoom: 1 below the ramp, 0 above it, linear\n * between.\n */\nexport function fieldOpacity(zoom: number): number {\n const [from, to] = RAMP;\n if (zoom <= from) return 1;\n if (zoom >= to) return 0;\n return (to - zoom) / (to - from);\n}\n\n/** Opacity of the district fill at a zoom; the field's complement. */\nexport function districtOpacity(zoom: number): number {\n return 1 - fieldOpacity(zoom);\n}\n\n/**\n * How many particles to draw. A phone is given fewer because the fragment cost\n * is per device pixel, and a visitor who prefers reduced motion gets none.\n *\n * @param width - The map's width in CSS pixels.\n * @param dpr - The device pixel ratio the map draws at.\n */\nexport function particleCount(\n width: number,\n dpr: number,\n reducedMotion: boolean,\n): number {\n if (reducedMotion) return 0;\n const density = width < 600 ? (dpr >= 2 ? 18 : 26) : 30;\n return Math.min(PARTICLE_CAP, Math.round(width * density));\n}\n","/**\n * The field ramps. They are data ramps, not brand colours: a shader needs plain\n * RGB stops, and these are perceptually spaced so a 1 mm cell never looks like a\n * 40 mm cell. A caller may pass its own stops to `WeatherFieldLayer`.\n */\nexport const RAIN_RAMP: readonly string[] = [\n '#f7fbff',\n '#deebf7',\n '#9ecae1',\n '#4292c6',\n '#2171b5',\n '#08519c',\n '#5e3c99',\n];\n\n/** Cold to hot, through a neutral middle so 0 °C is not tinted. */\nexport const TEMPERATURE_RAMP: readonly string[] = [\n '#2166ac',\n '#67a9cf',\n '#d1e5f0',\n '#f7f7f7',\n '#fddbc7',\n '#f4a582',\n '#d6604d',\n '#b2182b',\n];\n\n/** Calm to strong, the magma ramp. */\nexport const WIND_RAMP: readonly string[] = [\n '#3b0f70',\n '#8c2981',\n '#de4968',\n '#fe9f6d',\n '#fcfdbf',\n];\n\n/** Every ramp the globe ships, keyed by the field family it draws. */\nexport const FIELD_PALETTES: Readonly<\n Record<'rain' | 'temperature' | 'wind', readonly string[]>\n> = {\n rain: RAIN_RAMP,\n temperature: TEMPERATURE_RAMP,\n wind: WIND_RAMP,\n};\n\n/**\n * The ramp for a field name: rain grids take the rain ramp, both temperature\n * fields the temperature ramp, both wind components the wind ramp.\n */\nexport function paletteFor(field: string): readonly string[] {\n if (field === 'rain') return RAIN_RAMP;\n if (field === 'tmax' || field === 'tmin') return TEMPERATURE_RAMP;\n return WIND_RAMP;\n}\n","import { shallowRef, watch } from 'vue';\nimport type { Ref } from 'vue';\nimport type { Map as MapLibreMap, StyleSpecification } from 'maplibre-gl';\nimport {\n WeatherFieldLayer,\n WindParticleLayer,\n} from '@geoql/maplibre-gl-weather';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport type { GlobeDataSource } from '../types';\nimport {\n ROTATE_DEGREES_PER_SECOND,\n openingCamera,\n shouldRotate,\n} from '../utils/camera';\nimport { fieldOpacity, particleCount } from '../utils/handover';\nimport type { WindPair } from './use-globe-particles';\nimport { paletteFor } from '../utils/palette';\n\n/** A district source the map may draw. */\nexport interface DistrictSource {\n readonly country: string;\n readonly url: string;\n}\n\n/** Everything the map needs from the component. */\nexport interface UseGlobeMapInput {\n readonly host: Ref<HTMLElement | null>;\n readonly style: StyleSpecification;\n readonly centroid: readonly [number, number] | null;\n readonly reducedMotion: boolean;\n readonly source: GlobeDataSource;\n readonly frames: Ref<readonly Grid[]>;\n readonly mix: Ref<number>;\n readonly palette: readonly string[] | null;\n readonly wind: Ref<WindPair | null>;\n readonly district: Ref<DistrictSource | null>;\n /** True once the caller's data is ready; the map mounts then. */\n readonly mountWhen: Ref<boolean>;\n readonly onIdle: () => void;\n}\n\n/** The map handle and its lifecycle. */\nexport interface GlobeMap {\n readonly map: Ref<MapLibreMap | null>;\n mount(): Promise<void>;\n dispose(): void;\n}\n\nconst DEFAULT_FIELD_OPACITY = 0.85;\n\n/**\n * The map's lifecycle and its layers. Mounts only when its host measures non\n * zero in both axes, so a hidden page (or a test with no layout) mounts\n * nothing and logs nothing.\n */\nexport function useGlobeMap(input: UseGlobeMapInput): GlobeMap {\n const map = shallowRef<MapLibreMap | null>(null);\n let field: WeatherFieldLayer | null = null;\n let particles: WindParticleLayer | null = null;\n let frame = 0;\n let interacted = false;\n let wired = false;\n\n const stopRotation = (): void => {\n if (frame !== 0) cancelAnimationFrame(frame);\n frame = 0;\n };\n\n const rotate = (): void => {\n const instance = map.value;\n if (!instance || !shouldRotate(input.reducedMotion, interacted)) return;\n const centre = instance.getCenter();\n const lng = centre.lng + ROTATE_DEGREES_PER_SECOND / 60;\n instance.setCenter([lng > 180 ? lng - 360 : lng, centre.lat]);\n frame = requestAnimationFrame(rotate);\n };\n\n const addField = (instance: MapLibreMap): void => {\n const frames = input.frames.value;\n if (frames.length === 0 || field) return;\n const first = frames[0];\n const palette = input.palette ?? paletteFor(first?.meta.field ?? 'rain');\n field = new WeatherFieldLayer({\n frames,\n mix: input.mix.value,\n palette,\n opacity: DEFAULT_FIELD_OPACITY,\n });\n instance.addLayer(field);\n instance.on('zoom', () => {\n field?.setOpacity(\n DEFAULT_FIELD_OPACITY * fieldOpacity(instance.getZoom()),\n );\n });\n };\n\n const addParticles = (instance: MapLibreMap): void => {\n const wind = input.wind.value;\n if (!wind || particles) return;\n const width = input.host.value?.clientWidth ?? 0;\n const dpr = globalThis.devicePixelRatio ?? 1;\n particles = new WindParticleLayer({\n u: wind.u,\n v: wind.v,\n count: particleCount(width, dpr, input.reducedMotion),\n animated: !input.reducedMotion,\n });\n instance.addLayer(particles);\n };\n\n const addDistricts = (instance: MapLibreMap): void => {\n const district = input.district.value;\n if (!district) return;\n const sourceId = `globe-districts-${district.country}`;\n if (instance.getSource(sourceId)) return;\n instance.addSource(sourceId, { type: 'vector', tiles: [district.url] });\n instance.addLayer({\n id: `${sourceId}-fill`,\n type: 'fill',\n source: sourceId,\n paint: {\n 'fill-color': paletteFor('rain')[3] ?? '#4292c6',\n // The handover ramp, read by MapLibre at paint time.\n 'fill-opacity': ['interpolate', ['linear'], ['zoom'], 6.5, 0, 8, 1],\n },\n });\n };\n\n const wire = (): void => {\n const instance = map.value;\n if (!instance || !wired) return;\n addField(instance);\n addParticles(instance);\n addDistricts(instance);\n };\n\n const mount = async (): Promise<void> => {\n if (map.value) return;\n const host = input.host.value;\n if (!host || typeof window === 'undefined') return;\n const rect = host.getBoundingClientRect();\n if (rect.width === 0 || rect.height === 0) return;\n\n const { Map } = await import('maplibre-gl');\n const camera = openingCamera(input.centroid);\n const created = new Map({\n container: host,\n style: input.style,\n center: camera.center,\n zoom: camera.zoom,\n pitch: camera.pitch,\n attributionControl: false,\n });\n // MapLibre 6 sets the projection on the map, not in its options: a globe\n // draws with projectTile(), the mercator prelude never runs.\n created.setProjection({ type: 'globe' });\n map.value = created;\n created.once('idle', () => {\n wired = true;\n wire();\n input.onIdle();\n });\n const stop = (): void => {\n interacted = true;\n stopRotation();\n };\n const canvas = created.getCanvas();\n canvas.addEventListener('pointerdown', stop, { once: true });\n canvas.addEventListener('wheel', stop, { once: true });\n canvas.addEventListener('touchstart', stop, { once: true });\n if (shouldRotate(input.reducedMotion, interacted)) {\n frame = requestAnimationFrame(rotate);\n }\n };\n\n watch(input.frames, () => {\n if (field) field.setFrames(input.frames.value, input.mix.value);\n else wire();\n });\n watch(input.mix, (value) => field?.setMix(value));\n watch(input.wind, () => wire());\n watch(input.district, () => wire());\n watch(input.mountWhen, (ready) => {\n if (ready) void mount();\n });\n\n const dispose = (): void => {\n stopRotation();\n field = null;\n particles = null;\n wired = false;\n map.value?.remove();\n map.value = null;\n };\n\n return { map, mount, dispose };\n}\n","import {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n} from 'vue';\nimport type { Component, PropType } from 'vue';\nimport type { StyleSpecification } from 'maplibre-gl';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport type { GlobeDataSource, GlobeLayer } from '../types';\nimport { GlobeSkeleton } from './GlobeSkeleton';\nimport { useGlobeMap } from '../composables/use-globe-map';\nimport type { DistrictSource } from '../composables/use-globe-map';\nimport type { WindPair } from '../composables/use-globe-particles';\n\n/** Everything the globe draws; the page supplies all of it. */\nexport interface GlobeCanvasProps {\n readonly layers: readonly GlobeLayer[];\n readonly dataSource: GlobeDataSource;\n readonly style: StyleSpecification;\n readonly status: 'loading' | 'ready' | 'empty' | 'error';\n readonly centroid?: readonly [number, number] | null;\n readonly reducedMotion?: boolean;\n readonly frames?: readonly Grid[];\n readonly mix?: number;\n readonly palette?: readonly string[] | null;\n readonly wind?: WindPair | null;\n readonly district?: DistrictSource | null;\n}\n\n/**\n * The globe itself. It draws the skeleton until the caller's data is ready,\n * mounts a WebGL map only where its host has a size, and rotates slowly until\n * the visitor touches it. `data-globe` carries the caller's status: it is what\n * the 2.5 s budget waits for.\n */\nconst GlobeCanvasComponent = defineComponent({\n name: 'GlobeCanvas',\n props: {\n layers: { type: Array as PropType<readonly GlobeLayer[]>, required: true },\n dataSource: { type: Object as PropType<GlobeDataSource>, required: true },\n style: { type: Object as PropType<StyleSpecification>, required: true },\n status: { type: String, required: true },\n centroid: {\n type: Array as unknown as PropType<readonly [number, number] | null>,\n default: null,\n },\n reducedMotion: { type: Boolean, default: false },\n frames: { type: Array as PropType<readonly Grid[]>, default: () => [] },\n mix: { type: Number, default: 0 },\n palette: {\n type: Array as PropType<readonly string[] | null>,\n default: null,\n },\n wind: { type: Object as PropType<WindPair | null>, default: null },\n district: {\n type: Object as PropType<DistrictSource | null>,\n default: null,\n },\n },\n emits: ['idle'],\n setup(props, { emit }) {\n const host = ref<HTMLElement | null>(null);\n const frames = ref<readonly Grid[]>(props.frames);\n const mix = ref<number>(props.mix);\n const wind = ref<WindPair | null>(props.wind);\n const district = ref<DistrictSource | null>(props.district);\n const mountWhen = ref(props.status === 'ready');\n\n const globe = useGlobeMap({\n host,\n style: props.style,\n centroid: props.centroid,\n reducedMotion: props.reducedMotion,\n source: props.dataSource,\n frames,\n mix,\n palette: props.palette,\n wind,\n district,\n mountWhen,\n onIdle: () => emit('idle'),\n });\n\n watch(\n () => props.frames,\n (value) => {\n frames.value = value;\n },\n );\n watch(\n () => props.mix,\n (value) => {\n mix.value = value;\n },\n );\n watch(\n () => props.wind,\n (value) => {\n wind.value = value;\n },\n );\n watch(\n () => props.district,\n (value) => {\n district.value = value;\n },\n );\n watch(\n () => props.status,\n (value) => {\n mountWhen.value = value === 'ready';\n },\n );\n\n onMounted(() => {\n if (props.status === 'ready') void globe.mount();\n });\n onBeforeUnmount(() => globe.dispose());\n\n return () =>\n h(\n 'div',\n {\n ref: host,\n class: 'globe-canvas',\n 'data-globe': props.status,\n 'data-globe-host': '',\n },\n props.status === 'loading' ? [h(GlobeSkeleton)] : [],\n );\n },\n});\n\nexport const GlobeCanvas: Component = GlobeCanvasComponent;\n","import { defineComponent, h } from 'vue';\nimport type { Component } from 'vue';\n\n/** The locked country and the hook a page uses to open its own ask. */\nexport interface GlobeLockProps {\n readonly country: string;\n}\n\n/**\n * The locked state for a country whose district numbers the caller may not\n * show: one sentence in the catalogue's words, and a button the page answers\n * with its own unlock flow.\n */\nconst GlobeLockComponent = defineComponent({\n name: 'GlobeLock',\n props: {\n country: { type: String, required: true },\n },\n emits: ['unlock-request'],\n setup(props, { emit }) {\n return () =>\n h('div', { class: 'globe-lock', 'data-globe-lock': props.country }, [\n h(\n 'p',\n { class: 'globe-lock-copy' },\n 'District data is not open for this country yet.',\n ),\n h(\n 'button',\n {\n type: 'button',\n class: 'globe-lock-action',\n onClick: () => emit('unlock-request', { country: props.country }),\n },\n 'Unlock district data for 230 countries',\n ),\n ]);\n },\n});\n\nexport const GlobeLock: Component = GlobeLockComponent;\n","import { defineComponent, h } from 'vue';\nimport type { Component } from 'vue';\n\n/** The pointer readout: a value and its unit, or nothing at all. */\nexport interface GlobeReadoutProps {\n readonly value: number | null;\n readonly unit: string;\n}\n\n/**\n * Shows the field's value under the pointer. A cell with no data prints\n * nothing — never `NaN`, never `0`, which a reader would take for a measurement.\n */\nconst GlobeReadoutComponent = defineComponent({\n name: 'GlobeReadout',\n props: {\n value: { type: Number, default: null },\n unit: { type: String, required: true },\n },\n setup(props) {\n return () => {\n const value: number | null = props.value;\n if (value === null) return h('span', { class: 'globe-readout' });\n const shown = Math.round(value * 10) / 10;\n return h(\n 'span',\n { class: 'globe-readout', 'data-globe-readout': '' },\n `${shown} ${props.unit}`,\n );\n };\n },\n});\n\nexport const GlobeReadout: Component = GlobeReadoutComponent;\n","import { defineComponent, h } from 'vue';\nimport type { Component, PropType } from 'vue';\nimport { SliderRange, SliderRoot, SliderThumb, SliderTrack } from 'reka-ui';\n\n/** The 7-day slider: the run's own day labels, a play toggle, and a thumb. */\nexport interface GlobeTimeSliderProps {\n /** Day labels from the field index, in the run's order. */\n readonly labels: readonly string[];\n readonly modelValue: number;\n readonly playing: boolean;\n}\n\n/**\n * The time axis of the globe. The label is the index's label (a UTC day), never\n * a date computed here, and it is the slider's `aria-valuetext`, so a screen\n * reader and the visible caption read the same value.\n */\nconst GlobeTimeSliderComponent = defineComponent({\n name: 'GlobeTimeSlider',\n props: {\n labels: { type: Array as PropType<readonly string[]>, required: true },\n modelValue: { type: Number, required: true },\n playing: { type: Boolean, default: false },\n },\n emits: ['update:modelValue', 'toggle'],\n setup(props, { emit }) {\n const label = (): string => props.labels[props.modelValue] ?? '';\n\n const update = (value: number[] | undefined): void => {\n const next = value?.[0];\n if (typeof next === 'number') emit('update:modelValue', next);\n };\n\n return () =>\n h('div', { class: 'globe-slider', 'data-globe-slider': '' }, [\n h(\n 'button',\n {\n type: 'button',\n class: 'globe-slider-play',\n 'aria-label': props.playing ? 'Pause' : 'Play',\n 'aria-pressed': props.playing ? 'true' : 'false',\n onClick: () => emit('toggle'),\n },\n props.playing ? 'Pause' : 'Play',\n ),\n h(\n SliderRoot,\n {\n class: 'globe-slider-root',\n modelValue: [props.modelValue],\n max: Math.max(props.labels.length - 1, 0),\n step: 1,\n 'onUpdate:modelValue': update,\n },\n () => [\n h(SliderTrack, { class: 'globe-slider-track' }, () => [\n h(SliderRange, { class: 'globe-slider-range' }),\n ]),\n h(SliderThumb, {\n class: 'globe-slider-thumb',\n 'aria-valuetext': label(),\n 'aria-label': 'Forecast day',\n }),\n ],\n ),\n h('span', { class: 'globe-slider-label' }, label()),\n ]);\n },\n});\n\nexport const GlobeTimeSlider: Component = GlobeTimeSliderComponent;\n","import { computed, ref } from 'vue';\nimport type { ComputedRef, Ref } from 'vue';\nimport type { GlobeLayer, GlobeModel, GlobeSelection } from '../types';\n\n/** What the visitor has explored: which layers, and since when (epoch ms). */\nexport interface Explored {\n readonly layers: ReadonlySet<string>;\n readonly startedAt: number;\n}\n\n/** Everything a globe page drives from one place. */\nexport interface GlobeState {\n readonly selection: Ref<GlobeSelection>;\n readonly playing: Ref<boolean>;\n readonly explored: Ref<Explored>;\n /** The layer the selection names, or null when the catalogue has no match. */\n readonly layer: ComputedRef<GlobeLayer | null>;\n /** The last frame index the caller's run published. */\n readonly lastDay: ComputedRef<number>;\n select(layerId: string): void;\n setModel(model: GlobeModel): void;\n setDay(index: number): void;\n togglePlaying(value?: boolean): void;\n /** False when `country` may show district numbers. */\n lockFor(country: string): boolean;\n}\n\nconst clamp = (value: number, max: number): number => {\n if (!Number.isFinite(value)) return 0;\n const whole = Math.trunc(value);\n if (whole < 0) return 0;\n return whole > max ? max : whole;\n};\n\n/**\n * The globe's state machine: which layer, model and day are showing, whether it\n * plays, and which countries may show district numbers.\n *\n * Pure Vue reactivity — no browser API and no HTTP — so a page and a test share\n * one behaviour. `now` is injected so a test can advance the exploration clock\n * without sleeping.\n */\nexport function useGlobeState(initial: {\n readonly layers: readonly GlobeLayer[];\n readonly days: number;\n readonly unlocked: boolean;\n readonly unlockedCountries: readonly string[];\n readonly now?: () => number;\n}): GlobeState {\n const { layers, unlocked, unlockedCountries } = initial;\n const now = initial.now ?? (() => Date.now());\n const dayCount = clamp(initial.days, Number.MAX_SAFE_INTEGER);\n const opening = layers[0];\n\n const selection = ref<GlobeSelection>({\n layerId: opening?.id ?? '',\n // A field layer opens on its first published model; a district layer has\n // none, and the model of the opening layer stays for the readout.\n model: opening?.models[0] ?? 'ecmwf-ifs',\n dayIndex: 0,\n });\n\n const playing = ref(false);\n\n // The opening layer counts as explored: the visitor is looking at it.\n const explored = ref<Explored>({\n layers: new Set(opening ? [opening.id] : []),\n startedAt: now(),\n });\n const lastDay = computed(() => clamp(dayCount, Number.MAX_SAFE_INTEGER) - 1);\n\n const layer = computed<GlobeLayer | null>(\n () => layers.find((entry) => entry.id === selection.value.layerId) ?? null,\n );\n\n const remember = (layerId: string): void => {\n if (explored.value.layers.has(layerId)) return;\n explored.value = {\n layers: new Set([...explored.value.layers, layerId]),\n startedAt: explored.value.startedAt,\n };\n };\n\n const select = (layerId: string): void => {\n const next = layers.find((entry) => entry.id === layerId);\n if (!next) return;\n const model = next.models.includes(selection.value.model)\n ? selection.value.model\n : (next.models[0] ?? selection.value.model);\n selection.value = { ...selection.value, layerId, model };\n remember(layerId);\n };\n\n const setModel = (model: GlobeModel): void => {\n if (!layer.value?.models.includes(model)) return;\n selection.value = { ...selection.value, model };\n };\n\n const setDay = (index: number): void => {\n selection.value = {\n ...selection.value,\n dayIndex: clamp(index, lastDay.value),\n };\n };\n\n const togglePlaying = (value?: boolean): void => {\n playing.value = value ?? !playing.value;\n };\n\n const lockFor = (country: string): boolean => {\n if (unlocked) return false;\n const key = country.trim().toLowerCase();\n return !unlockedCountries.some((entry) => entry.toLowerCase() === key);\n };\n\n return {\n selection,\n playing,\n explored,\n layer,\n lastDay,\n select,\n setModel,\n setDay,\n togglePlaying,\n lockFor,\n };\n}\n","import { ref } from 'vue';\nimport type { Ref } from 'vue';\nimport { decodeGrid } from '@geoql/maplibre-gl-weather';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport type {\n FieldIndexDto,\n GlobeDataSource,\n GlobeField,\n GlobeSelection,\n} from '../types';\n\n/** What the field layer is doing, as the page reports it. */\nexport type GlobeStatus = 'idle' | 'loading' | 'ready' | 'empty' | 'error';\n\n/** Everything `useGlobeFields` reads. */\nexport interface GlobeFieldsInput {\n readonly source: GlobeDataSource;\n readonly selection: Ref<GlobeSelection>;\n /** The catalogue layer's fields; the first one is drawn and blended. */\n readonly fields?: readonly GlobeField[];\n readonly fetchJson: (url: string) => Promise<unknown>;\n /** The grid's decoded bytes: the transport un-gzips, never the shader. */\n readonly fetchBytes: (url: string) => Promise<Uint8Array>;\n}\n\n/** The field frames and their state. */\nexport interface GlobeFields {\n readonly index: Ref<FieldIndexDto | null>;\n readonly frames: Ref<readonly Grid[]>;\n /** `0` shows `frames[0]`, `1` shows `frames[1]`. */\n readonly mix: Ref<number>;\n readonly status: Ref<GlobeStatus>;\n /** The index's own day labels, in order. */\n readonly labels: Ref<readonly string[]>;\n load(): Promise<void>;\n}\n\nconst isIndex = (value: unknown): value is FieldIndexDto => {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Partial<FieldIndexDto>;\n return (\n typeof candidate.run === 'string' &&\n Array.isArray(candidate.days) &&\n typeof candidate.width === 'number' &&\n typeof candidate.height === 'number' &&\n typeof candidate.step === 'number'\n );\n};\n\n/** A 404 is a country or run with no data, not a broken globe. */\nconst isMissing = (error: unknown): boolean => {\n const status = (error as { status?: unknown } | null)?.status;\n if (status === 404) return true;\n return /404|not found/i.test(String(error));\n};\n\n/** `'forecast-rain'` → `'rain'`, for a caller that passes no field list. */\nconst fieldFromLayer = (layerId: string): GlobeField => {\n const tail = layerId.split('-').pop() ?? '';\n if (tail === 'rain') return 'rain';\n if (tail === 'temperature' || tail === 'tmax' || tail === 'tmin')\n return 'tmax';\n return 'wind-u';\n};\n\n/**\n * Loads one field's index, then the selected day and the day after it, so the\n * shader can blend. The composable never invents a zero field: no data is\n * `'empty'` and a failed grid after a good index keeps the frames it had.\n */\nexport function useGlobeFields(input: GlobeFieldsInput): GlobeFields {\n const index = ref<FieldIndexDto | null>(null);\n const frames = ref<readonly Grid[]>([]);\n const mix = ref(0);\n const status = ref<GlobeStatus>('idle');\n const labels = ref<readonly string[]>([]);\n\n let run = 0;\n\n const meta = (dto: FieldIndexDto, day: string) => ({\n field: dto.field,\n run: dto.run,\n day,\n width: dto.width,\n height: dto.height,\n lonMin: dto.lonMin,\n latMax: dto.latMax,\n step: dto.step,\n scale: dto.scale,\n offset: dto.offset,\n unit: dto.unit,\n });\n\n const load = async (): Promise<void> => {\n const ticket = ++run;\n const { source, selection } = input;\n const field = input.fields?.[0] ?? fieldFromLayer(selection.value.layerId);\n const model = selection.value.model;\n status.value = 'loading';\n\n let dto: FieldIndexDto;\n try {\n const raw = await input.fetchJson(source.indexUrl(model, field));\n if (!isIndex(raw)) throw new Error('field index is not an index');\n dto = raw;\n } catch (error) {\n if (ticket !== run) return;\n frames.value = [];\n index.value = null;\n labels.value = [];\n mix.value = 0;\n status.value = isMissing(error) ? 'empty' : 'error';\n return;\n }\n\n if (ticket !== run) return;\n index.value = dto;\n labels.value = dto.days;\n\n const at = Math.min(\n Math.max(selection.value.dayIndex, 0),\n dto.days.length - 1,\n );\n const day = dto.days[at];\n if (day === undefined) {\n frames.value = [];\n status.value = 'empty';\n return;\n }\n const nextDay = dto.days[at + 1] ?? day;\n\n try {\n const first = await input.fetchBytes(\n source.gridUrl(model, field, dto.run, day),\n );\n const second =\n nextDay === day\n ? first\n : await input.fetchBytes(\n source.gridUrl(model, field, dto.run, nextDay),\n );\n if (ticket !== run) return;\n frames.value = [\n decodeGrid(first, meta(dto, day)),\n decodeGrid(second, meta(dto, nextDay)),\n ];\n mix.value = 0;\n status.value = 'ready';\n } catch (error) {\n if (ticket !== run) return;\n status.value = isMissing(error) ? 'empty' : 'error';\n }\n };\n\n return { index, frames, mix, status, labels, load };\n}\n","import { ref } from 'vue';\nimport type { Ref } from 'vue';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport { decodeGrid } from '@geoql/maplibre-gl-weather';\nimport type { FieldIndexDto, GlobeDataSource, GlobeSelection } from '../types';\nimport type { GlobeStatus } from './use-globe-fields';\n\n/** The wind pair the particle layer advects through. */\nexport interface WindPair {\n readonly u: Grid;\n readonly v: Grid;\n}\n\n/** Everything `useGlobeParticles` reads. */\nexport interface GlobeParticlesInput {\n readonly source: GlobeDataSource;\n readonly selection: Ref<GlobeSelection>;\n readonly fetchJson: (url: string) => Promise<unknown>;\n readonly fetchBytes: (url: string) => Promise<Uint8Array>;\n}\n\n/** The wind grids and their state. */\nexport interface GlobeParticles {\n readonly wind: Ref<WindPair | null>;\n readonly status: Ref<GlobeStatus>;\n load(): Promise<void>;\n}\n\nconst isIndex = (value: unknown): value is FieldIndexDto => {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Partial<FieldIndexDto>;\n return (\n typeof candidate.run === 'string' &&\n Array.isArray(candidate.days) &&\n typeof candidate.width === 'number' &&\n typeof candidate.height === 'number'\n );\n};\n\nconst dayOf = (dto: FieldIndexDto, index: number): string | null => {\n const at = Math.min(Math.max(index, 0), dto.days.length - 1);\n return dto.days[at] ?? null;\n};\n\n/**\n * Loads the 10 m wind pair (`u` east, `v` north) for the selected day. A layer\n * with no wind fields, or a run that published none, is `'empty'` — the globe\n * then draws the field alone, never particles advected by zero wind.\n */\nexport function useGlobeParticles(input: GlobeParticlesInput): GlobeParticles {\n const wind = ref<WindPair | null>(null);\n const status = ref<GlobeStatus>('idle');\n\n let run = 0;\n\n const one = async (\n model: GlobeSelection['model'],\n field: 'wind-u' | 'wind-v',\n dayIndex: number,\n ): Promise<Grid | null> => {\n const raw = await input.fetchJson(input.source.indexUrl(model, field));\n if (!isIndex(raw)) throw new Error('wind index is not an index');\n const day = dayOf(raw, dayIndex);\n if (day === null) return null;\n const bytes = await input.fetchBytes(\n input.source.gridUrl(model, field, raw.run, day),\n );\n return decodeGrid(bytes, {\n field,\n run: raw.run,\n day,\n width: raw.width,\n height: raw.height,\n lonMin: raw.lonMin,\n latMax: raw.latMax,\n step: raw.step,\n scale: raw.scale,\n offset: raw.offset,\n unit: raw.unit,\n });\n };\n\n const load = async (): Promise<void> => {\n const ticket = ++run;\n status.value = 'loading';\n const { model, dayIndex } = input.selection.value;\n try {\n const [u, v] = await Promise.all([\n one(model, 'wind-u', dayIndex),\n one(model, 'wind-v', dayIndex),\n ]);\n if (ticket !== run) return;\n if (!u || !v) {\n wind.value = null;\n status.value = 'empty';\n return;\n }\n wind.value = { u, v };\n status.value = 'ready';\n } catch (error) {\n if (ticket !== run) return;\n const missing = (error as { status?: unknown } | null)?.status === 404;\n status.value = missing ? 'empty' : 'error';\n if (missing) wind.value = null;\n }\n };\n\n return { wind, status, load };\n}\n","/** A district source the globe may draw, or nothing for a locked country. */\nexport interface DistrictLayer {\n readonly id: string;\n readonly source: string;\n}\n\n/** What a caller must tell the districts composable. */\nexport interface GlobeDistrictsInput {\n /** True when the account may see district numbers everywhere. */\n readonly unlocked: boolean;\n /** The caller's own MVT template; a locked country is never asked for one. */\n readonly districtUrl: (dataset: string, country: string) => string;\n /** The dataset segment of `districtUrl`; defaults to `'boundaries'`. */\n readonly dataset?: string;\n}\n\n/** The districts' half of the globe. */\nexport interface GlobeDistricts {\n /** The layer for a country, or null when the caller may not show it. */\n layerFor(country: string): DistrictLayer | null;\n}\n\n/**\n * Decides whether a country's districts may be drawn at all. A locked country\n * gets `null`, so the component never mounts a source it may not show: no\n * district geometry reaches a browser that may not read it.\n */\nexport function useGlobeDistricts(input: GlobeDistrictsInput): GlobeDistricts {\n const dataset = input.dataset ?? 'boundaries';\n\n const layerFor = (country: string): DistrictLayer | null => {\n if (!input.unlocked) return null;\n const key = country.trim().toLowerCase();\n if (key === '') return null;\n return {\n id: `globe-districts-${key}`,\n source: input.districtUrl(dataset, key),\n };\n };\n\n return { layerFor };\n}\n"],"mappings":";;;AAmBA,MAAa,gBAXkB,gBAAgB;CAC7C,MAAM;CACN,QAAQ;EACN,aACE,EAAE,OAAO;GAAE,uBAAuB;GAAI,OAAO;EAAiB,GAAG,CAC/D,EAAE,QAAQ;GAAE,OAAO;GAAuB,eAAe;EAAO,CAAC,GACjE,EAAE,QAAQ,EAAE,OAAO,uBAAuB,GAAG,mBAAmB,CAClE,CAAC;CACL;AACF,CAEwC;;;;;;ACfxC,MAAa,YAAY;;AAGzB,MAAa,aAAa;;;;;AAM1B,MAAa,4BAA4B;;AAGzC,MAAa,eAA0C,CAAC,GAAG,EAAE;;;;;;;AAe7D,SAAgB,cACd,UACe;CAIf,OAAO;EAAE,QAHwB,WAC7B,CAAC,SAAS,IAAI,SAAS,EAAE,IACzB,CAAC,aAAa,IAAI,aAAa,EAAE;EACZ,MAAM;EAAW,OAAA;CAAkB;AAC9D;;;;;AAMA,SAAgB,aACd,eACA,YACS;CACT,OAAO,CAAC,iBAAiB,CAAC;AAC5B;;;;;;;AC5CA,MAAa,aAAwC,CAAC,KAAK,CAAC;;AAG5D,MAAa,gBAA2C,CAAC,KAAK,CAAC;;AAG/D,MAAa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vB,QAAQ,MAAM,YAAY,SAAS,GAAG;EACxC;CACF;CAEA,OAAO,EAAE,SAAS;AACpB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_hoisted_1","_openBlock","_createElementBlock","_createElementVNode","_openBlock","_createElementBlock","_createBlock","GlobeSkeleton","_openBlock","_createElementBlock","_createElementVNode","_hoisted_1","_openBlock","_createElementBlock","_toDisplayString","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_withCtx","isIndex"],"sources":["../src/components/GlobeSkeleton.vue","../src/utils/camera.ts","../src/utils/handover.ts","../src/utils/palette.ts","../src/utils/field-frames.ts","../src/utils/particles.ts","../src/utils/districts.ts","../src/composables/use-globe-map.ts","../src/components/GlobeCanvas.vue","../src/components/GlobeLock.vue","../src/components/GlobeReadout.vue","../src/components/GlobeTimeSlider.vue","../src/composables/use-globe-state.ts","../src/composables/use-globe-fields.ts","../src/composables/use-globe-particles.ts","../src/composables/use-globe-districts.ts"],"sourcesContent":["<script setup lang=\"ts\">\n // No props: the skeleton is the same everywhere the globe has not drawn yet.\n</script>\n\n<template>\n <div data-globe-skeleton class=\"globe-skeleton\">\n <span class=\"globe-skeleton-ring\" aria-hidden=\"true\" />\n <span class=\"globe-skeleton-label\">Loading the globe</span>\n </div>\n</template>\n","/**\n * The globe opens at a fixed zoom and pitch, over one place: the visitor's\n * country when the caller resolved it, the world otherwise.\n */\nexport const OPEN_ZOOM = 1.8;\n\n/** The globe is never tilted on open: a tilted planet hides half the field. */\nexport const OPEN_PITCH = 0;\n\n/**\n * Slow rotation so a still visitor sees a planet, not a poster. One full turn\n * takes five minutes; faster reads as a loading spinner.\n */\nexport const ROTATE_DEGREES_PER_SECOND = 1.2;\n\n/** The world view: equirectangular centre of the planet, 20° north. */\nexport const WORLD_CENTRE: readonly [number, number] = [0, 20];\n\n/** Where the globe opens. */\nexport interface OpeningCamera {\n readonly center: [number, number];\n readonly zoom: number;\n readonly pitch: number;\n}\n\n/**\n * The opening camera: the visitor's country's centroid when it is known, the\n * world otherwise.\n *\n * @param centroid - `[lon, lat]` of the visitor's country, or null when unknown.\n */\nexport function openingCamera(\n centroid: readonly [number, number] | null,\n): OpeningCamera {\n const centre: [number, number] = centroid\n ? [centroid[0], centroid[1]]\n : [WORLD_CENTRE[0], WORLD_CENTRE[1]];\n return { center: centre, zoom: OPEN_ZOOM, pitch: OPEN_PITCH };\n}\n\n/**\n * Whether the globe should rotate right now. Reduced motion is honoured, and the\n * first interaction hands control to the visitor for good.\n */\nexport function shouldRotate(\n reducedMotion: boolean,\n interacted: boolean,\n): boolean {\n return !reducedMotion && !interacted;\n}\n","/**\n * Zoom range over which the field fades out and the districts fade in. They are\n * the same two numbers on purpose: the globe is always showing one of them, and\n * a seam between the ramps would show as a flash of bare basemap.\n */\nexport const FIELD_FADE: readonly [number, number] = [6.5, 8];\n\n/** The districts' half of the same handover. */\nexport const DISTRICT_FADE: readonly [number, number] = [6.5, 8];\n\n/** The desktop particle count the spike measured as free on a desktop GPU. */\nexport const PARTICLE_CAP = 42_000;\n\nconst RAMP: readonly [number, number] = FIELD_FADE;\n\n/**\n * Opacity of the global field at a zoom: 1 below the ramp, 0 above it, linear\n * between.\n */\nexport function fieldOpacity(zoom: number): number {\n const [from, to] = RAMP;\n if (zoom <= from) return 1;\n if (zoom >= to) return 0;\n return (to - zoom) / (to - from);\n}\n\n/** Opacity of the district fill at a zoom; the field's complement. */\nexport function districtOpacity(zoom: number): number {\n return 1 - fieldOpacity(zoom);\n}\n\n/**\n * How many particles to draw. A phone is given fewer because the fragment cost\n * is per device pixel, and a visitor who prefers reduced motion gets none.\n *\n * @param width - The map's width in CSS pixels.\n * @param dpr - The device pixel ratio the map draws at.\n */\nexport function particleCount(\n width: number,\n dpr: number,\n reducedMotion: boolean,\n): number {\n if (reducedMotion) return 0;\n const density = width < 600 ? (dpr >= 2 ? 18 : 26) : 30;\n return Math.min(PARTICLE_CAP, Math.round(width * density));\n}\n","/**\n * The field ramps. They are data ramps, not brand colours: a shader needs plain\n * RGB stops, and these are perceptually spaced so a 1 mm cell never looks like a\n * 40 mm cell. A caller may pass its own stops to `WeatherFieldLayer`.\n */\nexport const RAIN_RAMP: readonly string[] = [\n '#f7fbff',\n '#deebf7',\n '#9ecae1',\n '#4292c6',\n '#2171b5',\n '#08519c',\n '#5e3c99',\n];\n\n/** Cold to hot, through a neutral middle so 0 °C is not tinted. */\nexport const TEMPERATURE_RAMP: readonly string[] = [\n '#2166ac',\n '#67a9cf',\n '#d1e5f0',\n '#f7f7f7',\n '#fddbc7',\n '#f4a582',\n '#d6604d',\n '#b2182b',\n];\n\n/** Calm to strong, the magma ramp. */\nexport const WIND_RAMP: readonly string[] = [\n '#3b0f70',\n '#8c2981',\n '#de4968',\n '#fe9f6d',\n '#fcfdbf',\n];\n\n/** Every ramp the globe ships, keyed by the field family it draws. */\nexport const FIELD_PALETTES: Readonly<\n Record<'rain' | 'temperature' | 'wind', readonly string[]>\n> = {\n rain: RAIN_RAMP,\n temperature: TEMPERATURE_RAMP,\n wind: WIND_RAMP,\n};\n\n/**\n * The ramp for a field name: rain grids take the rain ramp, both temperature\n * fields the temperature ramp, both wind components the wind ramp.\n */\nexport function paletteFor(field: string): readonly string[] {\n if (field === 'rain') return RAIN_RAMP;\n if (field === 'tmax' || field === 'tmin') return TEMPERATURE_RAMP;\n return WIND_RAMP;\n}\n","import { decodeGrid } from '@geoql/maplibre-gl-weather';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\n\n/** The quantised cell that means \"no data\" in every grid. */\nconst NO_DATA = 255;\n\n/**\n * Rain as a field is mostly dry: the ramp's lowest stop is near-white, so a dry\n * cell would paint the planet white. Cells under `minValue` (millimetres) are\n * set to the no-data byte, so rain shows where rain is and nothing elsewhere.\n *\n * Only a rain grid is masked: a temperature cell is never \"dry\", and a wind\n * component of zero is calm air, not an absence.\n */\nexport function maskDryRain(\n frames: readonly Grid[],\n minValue: number,\n): readonly Grid[] {\n return frames.map((grid) => {\n const { meta } = grid;\n if (meta.field !== 'rain' || !(meta.scale > 0)) return grid;\n const cut = Math.ceil((minValue - meta.offset) / meta.scale);\n if (cut <= 0) return grid;\n const bytes = new Uint8Array(grid.bytes);\n let changed = false;\n for (let index = 0; index < bytes.length; index += 1) {\n if ((bytes[index] ?? NO_DATA) < cut) {\n bytes[index] = NO_DATA;\n changed = true;\n }\n }\n return changed ? decodeGrid(bytes, meta) : grid;\n });\n}\n","import { particleCount } from './handover';\n\n/**\n * How much of the particle budget the field may carry.\n *\n * Measured on this Mac (Chromium, SwiftShader, 1440×900, globe at z1.5, the\n * field hidden so only the wind shows): the share of canvas pixels carrying a\n * stroke is 1.1 % at 200 particles, 8.2 % at 4 200, 8.9 % at 8 000, 9.3 % at\n * 14 700 and 9.9 % at 42 000. The curve is flat above ~4 000: 42 000 buys\n * 1.7 points of coverage for ten times the work. `0.15` spends 6 300 at a\n * desktop width and ~1 100 on a phone, just above the knee; the console's own\n * report (a full budget became a white sheet on a phone) is the same finding\n * from the other side. A host that wants more can pass its own count.\n */\nexport const PARTICLE_DENSITY = 0.15;\n\n/**\n * Particles for a viewport: the handover budget scaled by the measured density,\n * and none at all for a visitor who prefers reduced motion.\n */\nexport function particleDensity(\n width: number,\n dpr: number,\n reducedMotion: boolean,\n): number {\n if (reducedMotion) return 0;\n return Math.max(\n 1,\n Math.round(particleCount(width, dpr, false) * PARTICLE_DENSITY),\n );\n}\n","import type { Map as MapLibreMap } from 'maplibre-gl';\nimport { paletteFor } from './palette';\n\n/** The source layer the area tiles carry. */\nexport const AREA_SOURCE_LAYER = 'areas';\n\nconst AREA_ID =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * A district feature's own id.\n *\n * The MVT feature id is a tile-local integer; the area's UUID is the `id`\n * property. Reading the integer asks the API for \"area=192\", which is not an\n * area at all.\n */\nexport function areaIdOf(\n properties: Readonly<Record<string, unknown>> | null | undefined,\n): string | null {\n const id = properties?.['id'];\n return typeof id === 'string' && AREA_ID.test(id) ? id : null;\n}\n\n/** The two layers a district source needs: a fill that fades in, and its line. */\nexport interface DistrictLayerIds {\n readonly sourceId: string;\n readonly fill: string;\n readonly line: string;\n}\n\n/**\n * Adds a country's area source and its two layers, once per style. The fill\n * fades in on the same ramp the field fades out on; the line keeps a coastline\n * readable over the weather.\n */\nexport function addDistrictLayers(\n map: MapLibreMap,\n country: string,\n url: string,\n): DistrictLayerIds {\n const sourceId = `globe-districts-${country}`;\n const fill = `${sourceId}-fill`;\n const line = `${sourceId}-line`;\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, {\n type: 'vector',\n tiles: [url],\n minzoom: 0,\n maxzoom: 9,\n });\n }\n if (!map.getLayer(fill)) {\n map.addLayer({\n id: fill,\n type: 'fill',\n source: sourceId,\n 'source-layer': AREA_SOURCE_LAYER,\n paint: {\n 'fill-color': paletteFor('rain')[4] ?? '#7fb2c9',\n 'fill-opacity': ['interpolate', ['linear'], ['zoom'], 6, 0, 7.5, 0.45],\n },\n });\n }\n if (!map.getLayer(line)) {\n map.addLayer({\n id: line,\n type: 'line',\n source: sourceId,\n 'source-layer': AREA_SOURCE_LAYER,\n paint: {\n 'line-color': paletteFor('rain')[6] ?? '#2b5d74',\n 'line-width': 0.6,\n 'line-opacity': 0.7,\n },\n });\n }\n return { sourceId, fill, line };\n}\n\n/** Reports a district click by the area's own UUID, and the pointer shape. */\nexport function bindDistrictClicks(\n map: MapLibreMap,\n fill: string,\n onSelect: (areaId: string) => void,\n): void {\n map.on('click', fill, (event) => {\n const id = areaIdOf(event.features?.[0]?.properties ?? null);\n if (id !== null) onSelect(id);\n });\n map.on('mousemove', fill, () => {\n map.getCanvas().style.cursor = 'pointer';\n });\n map.on('mouseleave', fill, () => {\n map.getCanvas().style.cursor = '';\n });\n}\n","import { shallowRef, watch } from 'vue';\nimport type { Ref } from 'vue';\nimport type { Map as MapLibreMap, StyleSpecification } from 'maplibre-gl';\nimport {\n WeatherFieldLayer,\n WindParticleLayer,\n} from '@geoql/maplibre-gl-weather';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport type { DistrictSource, GlobeDataSource, WindPair } from '../types';\nimport {\n ROTATE_DEGREES_PER_SECOND,\n openingCamera,\n shouldRotate,\n} from '../utils/camera';\nimport { fieldOpacity } from '../utils/handover';\nimport { paletteFor } from '../utils/palette';\nimport { maskDryRain } from '../utils/field-frames';\nimport { particleDensity } from '../utils/particles';\nimport { addDistrictLayers, bindDistrictClicks } from '../utils/districts';\n\nexport type { DistrictSource } from '../types';\n\n/** Everything the map needs from the component. */\nexport interface UseGlobeMapInput {\n readonly host: Ref<HTMLElement | null>;\n readonly style: StyleSpecification;\n readonly centroid: readonly [number, number] | null;\n readonly reducedMotion: boolean;\n readonly source: GlobeDataSource;\n readonly frames: Ref<readonly Grid[]>;\n readonly mix: Ref<number>;\n readonly palette: readonly string[] | null;\n readonly wind: Ref<WindPair | null>;\n readonly district: Ref<DistrictSource | null>;\n /** True once the caller's data is ready; the map mounts then. */\n readonly mountWhen: Ref<boolean>;\n readonly onIdle: () => void;\n /** A district click, by the area's own UUID. */\n readonly onSelect?: (areaId: string) => void;\n}\n\n/** The map handle and its lifecycle. */\nexport interface GlobeMap {\n readonly map: Ref<MapLibreMap | null>;\n mount(): Promise<void>;\n dispose(): void;\n}\n\nconst FIELD_ID = 'globe-field';\nconst FIELD_OPACITY = 0.85;\nconst PARTICLES_ID = 'globe-particles';\n/** Rain under this many millimetres is dry: no-data, not a white wash. */\nconst DRY_RAIN_MM = 1;\n\n/**\n * The map's lifecycle and its layers.\n *\n * MapLibre 6 refuses `setProjection` until a style is loaded, so the globe is\n * converted on `load` and again on `style.load` (a new style drops both the\n * projection and every custom layer). A mount can never run twice, and every\n * add is guarded by the layer's existence, so N mounts and any number of prop\n * changes leave exactly one map and one canvas.\n */\nexport function useGlobeMap(input: UseGlobeMapInput): GlobeMap {\n const map = shallowRef<MapLibreMap | null>(null);\n let field: WeatherFieldLayer | null = null;\n let particles: WindParticleLayer | null = null;\n let frame = 0;\n let interacted = false;\n let mounting = false;\n let districtBound = false;\n\n const stopRotation = (): void => {\n if (frame !== 0) cancelAnimationFrame(frame);\n frame = 0;\n };\n\n const rotate = (): void => {\n const instance = map.value;\n if (!instance || !shouldRotate(input.reducedMotion, interacted)) return;\n const centre = instance.getCenter();\n const lng = centre.lng + ROTATE_DEGREES_PER_SECOND / 60;\n instance.setCenter([lng > 180 ? lng - 360 : lng, centre.lat]);\n frame = requestAnimationFrame(rotate);\n };\n\n /** The projection, once the style can take it. */\n const project = (instance: MapLibreMap): void => {\n if (!instance.isStyleLoaded()) return;\n instance.setProjection({ type: 'globe' });\n };\n\n const addField = (instance: MapLibreMap): void => {\n const frames = input.frames.value;\n if (frames.length === 0) return;\n if (field && instance.getLayer(FIELD_ID)) {\n field.setFrames(maskDryRain(frames, DRY_RAIN_MM), input.mix.value);\n return;\n }\n const first = frames[0];\n const palette = input.palette ?? paletteFor(first?.meta.field ?? 'rain');\n field = new WeatherFieldLayer({\n id: FIELD_ID,\n frames: maskDryRain(frames, DRY_RAIN_MM),\n mix: input.mix.value,\n palette,\n opacity: FIELD_OPACITY,\n });\n if (!instance.getLayer(FIELD_ID)) instance.addLayer(field);\n };\n\n const addParticles = (instance: MapLibreMap): void => {\n const wind = input.wind.value;\n if (!wind || particles) return;\n const width = input.host.value?.clientWidth ?? 0;\n const dpr = globalThis.devicePixelRatio ?? 1;\n particles = new WindParticleLayer({\n id: PARTICLES_ID,\n u: wind.u,\n v: wind.v,\n count: particleDensity(width, dpr, input.reducedMotion),\n animated: !input.reducedMotion,\n });\n if (!instance.getLayer(PARTICLES_ID)) instance.addLayer(particles);\n };\n\n const addDistricts = (instance: MapLibreMap): void => {\n const district = input.district.value;\n if (!district) return;\n const ids = addDistrictLayers(instance, district.country, district.url);\n if (districtBound || !input.onSelect) return;\n districtBound = true;\n bindDistrictClicks(instance, ids.fill, input.onSelect);\n };\n\n const wire = (): void => {\n const instance = map.value;\n if (!instance || !instance.isStyleLoaded()) return;\n addField(instance);\n addParticles(instance);\n addDistricts(instance);\n };\n\n const mount = async (): Promise<void> => {\n if (map.value || mounting) return;\n const host = input.host.value;\n if (!host || typeof window === 'undefined') return;\n const rect = host.getBoundingClientRect();\n if (rect.width === 0 || rect.height === 0) return;\n mounting = true;\n try {\n const { Map } = await import('maplibre-gl');\n if (map.value) return;\n const camera = openingCamera(input.centroid);\n const created = new Map({\n container: host,\n style: input.style,\n center: camera.center,\n zoom: camera.zoom,\n // Below 0 a globe collapses to a point and MapLibre asks for a tile at\n // y = Infinity; the world view is zoom 0 and the floor.\n minZoom: 0,\n pitch: camera.pitch,\n attributionControl: false,\n });\n map.value = created;\n created.on('load', () => {\n project(created);\n wire();\n input.onIdle();\n });\n created.on('style.load', () => {\n // A new style drops every custom layer and the click bindings that\n // name them; wire them again, once.\n districtBound = false;\n project(created);\n wire();\n });\n created.on('zoom', () => {\n if (!field) return;\n field.setOpacity(FIELD_OPACITY * fieldOpacity(created.getZoom()));\n });\n const stop = (): void => {\n interacted = true;\n stopRotation();\n };\n const canvas = created.getCanvas();\n canvas.addEventListener('pointerdown', stop, { once: true });\n canvas.addEventListener('wheel', stop, { once: true });\n canvas.addEventListener('touchstart', stop, { once: true });\n if (shouldRotate(input.reducedMotion, interacted)) {\n frame = requestAnimationFrame(rotate);\n }\n } finally {\n mounting = false;\n }\n };\n\n watch(input.frames, () => wire());\n watch(input.mix, (value) => field?.setMix(value));\n watch(input.wind, () => wire());\n watch(input.district, () => wire());\n\n const dispose = (): void => {\n stopRotation();\n field = null;\n particles = null;\n districtBound = false;\n map.value?.remove();\n map.value = null;\n };\n\n return { map, mount, dispose };\n}\n","<script setup lang=\"ts\">\n import { onBeforeUnmount, onMounted, ref, watch } from 'vue';\n import type { Grid } from '@geoql/maplibre-gl-weather';\n import type { DistrictSource, GlobeCanvasProps, WindPair } from '../types';\n import GlobeSkeleton from './GlobeSkeleton.vue';\n import { useGlobeMap } from '../composables/use-globe-map';\n\n /**\n * The globe itself. It draws the skeleton until the caller's data is ready,\n * mounts a WebGL map only where its host has a size, and rotates slowly until\n * the visitor touches it. `data-globe` carries the caller's status: it is what\n * the 2.5 s budget waits for.\n */\n const props = withDefaults(defineProps<GlobeCanvasProps>(), {\n centroid: null,\n reducedMotion: false,\n frames: () => [],\n mix: 0,\n palette: null,\n wind: null,\n district: null,\n });\n\n const emit = defineEmits<{\n idle: [];\n select: [areaId: string];\n }>();\n\n const host = ref<HTMLElement | null>(null);\n const frames = ref<readonly Grid[]>(props.frames);\n const mix = ref<number>(props.mix);\n const wind = ref<WindPair | null>(props.wind);\n const district = ref<DistrictSource | null>(props.district);\n const mountWhen = ref(props.status === 'ready');\n\n const globe = useGlobeMap({\n host,\n style: props.style,\n centroid: props.centroid,\n reducedMotion: props.reducedMotion,\n source: props.dataSource,\n frames,\n mix,\n palette: props.palette,\n wind,\n district,\n mountWhen,\n onIdle: () => emit('idle'),\n onSelect: (areaId: string) => emit('select', areaId),\n });\n\n watch(\n () => props.frames,\n (value) => {\n frames.value = value;\n },\n );\n watch(\n () => props.mix,\n (value) => {\n mix.value = value;\n },\n );\n watch(\n () => props.wind,\n (value) => {\n wind.value = value;\n },\n );\n watch(\n () => props.district,\n (value) => {\n district.value = value;\n },\n );\n watch(\n () => props.status,\n (value) => {\n mountWhen.value = value === 'ready';\n },\n );\n\n onMounted(() => {\n if (props.status === 'ready') void globe.mount();\n });\n onBeforeUnmount(() => globe.dispose());\n</script>\n\n<template>\n <div ref=\"host\" class=\"globe-canvas\" :data-globe=\"status\" data-globe-host>\n <GlobeSkeleton v-if=\"status === 'loading'\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\n import type { GlobeLockProps } from '../types';\n\n /**\n * The locked state for a country whose district numbers the caller may not\n * show: one sentence in the catalogue's words, and a button the page answers\n * with its own unlock flow.\n */\n defineProps<GlobeLockProps>();\n\n const emit = defineEmits<{\n unlockRequest: [{ country: string }];\n }>();\n</script>\n\n<template>\n <div class=\"globe-lock\" :data-globe-lock=\"country\">\n <p class=\"globe-lock-copy\">\n District data is not open for this country yet.\n </p>\n <button\n type=\"button\"\n class=\"globe-lock-action\"\n @click=\"emit('unlockRequest', { country })\"\n >\n Unlock district data for 230 countries\n </button>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue';\n import type { GlobeReadoutProps } from '../types';\n\n /**\n * Shows the field's value under the pointer. A cell with no data prints\n * nothing — never `NaN`, never `0`, which a reader would take for a\n * measurement.\n */\n const props = withDefaults(defineProps<GlobeReadoutProps>(), { value: null });\n\n const shown = computed((): string => {\n const value = props.value;\n if (value === null) return '';\n return `${Math.round(value * 10) / 10} ${props.unit}`;\n });\n</script>\n\n<template>\n <span\n class=\"globe-readout\"\n :data-globe-readout=\"shown === '' ? undefined : ''\"\n >{{ shown }}</span\n >\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue';\n import { SliderRange, SliderRoot, SliderThumb, SliderTrack } from 'reka-ui';\n import type { GlobeTimeSliderProps } from '../types';\n\n /**\n * The time axis of the globe. The label is the index's label (a UTC day),\n * never a date computed here, and it is the slider's `aria-valuetext`, so a\n * screen reader and the visible caption read the same value.\n */\n const props = withDefaults(defineProps<GlobeTimeSliderProps>(), {\n playing: false,\n });\n\n const emit = defineEmits<{\n 'update:modelValue': [value: number];\n toggle: [];\n }>();\n\n const label = computed((): string => props.labels[props.modelValue] ?? '');\n\n const onUpdate = (value: number[] | undefined): void => {\n const next = value?.[0];\n if (typeof next === 'number') emit('update:modelValue', next);\n };\n</script>\n\n<template>\n <div class=\"globe-slider\" data-globe-slider>\n <button\n type=\"button\"\n class=\"globe-slider-play\"\n :aria-label=\"playing ? 'Pause' : 'Play'\"\n :aria-pressed=\"playing\"\n @click=\"emit('toggle')\"\n >\n {{ playing ? 'Pause' : 'Play' }}\n </button>\n <SliderRoot\n class=\"globe-slider-root\"\n :model-value=\"[modelValue]\"\n :max=\"Math.max(labels.length - 1, 0)\"\n :step=\"1\"\n @update:model-value=\"onUpdate\"\n >\n <SliderTrack class=\"globe-slider-track\">\n <SliderRange class=\"globe-slider-range\" />\n </SliderTrack>\n <SliderThumb\n class=\"globe-slider-thumb\"\n aria-label=\"Forecast day\"\n :aria-valuetext=\"label\"\n />\n </SliderRoot>\n <span class=\"globe-slider-label\">{{ label }}</span>\n </div>\n</template>\n","import { computed, ref } from 'vue';\nimport type { ComputedRef, Ref } from 'vue';\nimport type { GlobeLayer, GlobeModel, GlobeSelection } from '../types';\n\n/** What the visitor has explored: which layers, and since when (epoch ms). */\nexport interface Explored {\n readonly layers: ReadonlySet<string>;\n readonly startedAt: number;\n}\n\n/** Everything a globe page drives from one place. */\nexport interface GlobeState {\n readonly selection: Ref<GlobeSelection>;\n readonly playing: Ref<boolean>;\n readonly explored: Ref<Explored>;\n /** The layer the selection names, or null when the catalogue has no match. */\n readonly layer: ComputedRef<GlobeLayer | null>;\n /** The last frame index the caller's run published. */\n readonly lastDay: ComputedRef<number>;\n select(layerId: string): void;\n setModel(model: GlobeModel): void;\n setDay(index: number): void;\n togglePlaying(value?: boolean): void;\n /** False when `country` may show district numbers. */\n lockFor(country: string): boolean;\n}\n\nconst clamp = (value: number, max: number): number => {\n if (!Number.isFinite(value)) return 0;\n const whole = Math.trunc(value);\n if (whole < 0) return 0;\n return whole > max ? max : whole;\n};\n\n/**\n * The globe's state machine: which layer, model and day are showing, whether it\n * plays, and which countries may show district numbers.\n *\n * Pure Vue reactivity — no browser API and no HTTP — so a page and a test share\n * one behaviour. `now` is injected so a test can advance the exploration clock\n * without sleeping.\n */\nexport function useGlobeState(initial: {\n readonly layers: readonly GlobeLayer[];\n readonly days: number;\n readonly unlocked: boolean;\n readonly unlockedCountries: readonly string[];\n readonly now?: () => number;\n}): GlobeState {\n const { layers, unlocked, unlockedCountries } = initial;\n const now = initial.now ?? (() => Date.now());\n const dayCount = clamp(initial.days, Number.MAX_SAFE_INTEGER);\n const opening = layers[0];\n\n const selection = ref<GlobeSelection>({\n layerId: opening?.id ?? '',\n // A field layer opens on its first published model; a district layer has\n // none, and the model of the opening layer stays for the readout.\n model: opening?.models[0] ?? 'ecmwf-ifs',\n dayIndex: 0,\n });\n\n const playing = ref(false);\n\n // The opening layer counts as explored: the visitor is looking at it.\n const explored = ref<Explored>({\n layers: new Set(opening ? [opening.id] : []),\n startedAt: now(),\n });\n const lastDay = computed(() => clamp(dayCount, Number.MAX_SAFE_INTEGER) - 1);\n\n const layer = computed<GlobeLayer | null>(\n () => layers.find((entry) => entry.id === selection.value.layerId) ?? null,\n );\n\n const remember = (layerId: string): void => {\n if (explored.value.layers.has(layerId)) return;\n explored.value = {\n layers: new Set([...explored.value.layers, layerId]),\n startedAt: explored.value.startedAt,\n };\n };\n\n const select = (layerId: string): void => {\n const next = layers.find((entry) => entry.id === layerId);\n if (!next) return;\n const model = next.models.includes(selection.value.model)\n ? selection.value.model\n : (next.models[0] ?? selection.value.model);\n selection.value = { ...selection.value, layerId, model };\n remember(layerId);\n };\n\n const setModel = (model: GlobeModel): void => {\n if (!layer.value?.models.includes(model)) return;\n selection.value = { ...selection.value, model };\n };\n\n const setDay = (index: number): void => {\n selection.value = {\n ...selection.value,\n dayIndex: clamp(index, lastDay.value),\n };\n };\n\n const togglePlaying = (value?: boolean): void => {\n playing.value = value ?? !playing.value;\n };\n\n const lockFor = (country: string): boolean => {\n if (unlocked) return false;\n const key = country.trim().toLowerCase();\n return !unlockedCountries.some((entry) => entry.toLowerCase() === key);\n };\n\n return {\n selection,\n playing,\n explored,\n layer,\n lastDay,\n select,\n setModel,\n setDay,\n togglePlaying,\n lockFor,\n };\n}\n","import { ref } from 'vue';\nimport type { Ref } from 'vue';\nimport { decodeGrid } from '@geoql/maplibre-gl-weather';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport type {\n FieldIndexDto,\n GlobeDataSource,\n GlobeField,\n GlobeSelection,\n} from '../types';\n\n/** What the field layer is doing, as the page reports it. */\nexport type GlobeStatus = 'idle' | 'loading' | 'ready' | 'empty' | 'error';\n\n/** Everything `useGlobeFields` reads. */\nexport interface GlobeFieldsInput {\n readonly source: GlobeDataSource;\n readonly selection: Ref<GlobeSelection>;\n /** The catalogue layer's fields; the first one is drawn and blended. */\n readonly fields?: readonly GlobeField[];\n readonly fetchJson: (url: string) => Promise<unknown>;\n /** The grid's decoded bytes: the transport un-gzips, never the shader. */\n readonly fetchBytes: (url: string) => Promise<Uint8Array>;\n}\n\n/** The field frames and their state. */\nexport interface GlobeFields {\n readonly index: Ref<FieldIndexDto | null>;\n readonly frames: Ref<readonly Grid[]>;\n /** `0` shows `frames[0]`, `1` shows `frames[1]`. */\n readonly mix: Ref<number>;\n readonly status: Ref<GlobeStatus>;\n /** The index's own day labels, in order. */\n readonly labels: Ref<readonly string[]>;\n load(): Promise<void>;\n}\n\nconst isIndex = (value: unknown): value is FieldIndexDto => {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Partial<FieldIndexDto>;\n return (\n typeof candidate.run === 'string' &&\n Array.isArray(candidate.days) &&\n typeof candidate.width === 'number' &&\n typeof candidate.height === 'number' &&\n typeof candidate.step === 'number'\n );\n};\n\n/** A 404 is a country or run with no data, not a broken globe. */\nconst isMissing = (error: unknown): boolean => {\n const status = (error as { status?: unknown } | null)?.status;\n if (status === 404) return true;\n return /404|not found/i.test(String(error));\n};\n\n/** `'forecast-rain'` → `'rain'`, for a caller that passes no field list. */\nconst fieldFromLayer = (layerId: string): GlobeField => {\n const tail = layerId.split('-').pop() ?? '';\n if (tail === 'rain') return 'rain';\n if (tail === 'temperature' || tail === 'tmax' || tail === 'tmin')\n return 'tmax';\n return 'wind-u';\n};\n\n/**\n * Loads one field's index, then the selected day and the day after it, so the\n * shader can blend. The composable never invents a zero field: no data is\n * `'empty'` and a failed grid after a good index keeps the frames it had.\n */\nexport function useGlobeFields(input: GlobeFieldsInput): GlobeFields {\n const index = ref<FieldIndexDto | null>(null);\n const frames = ref<readonly Grid[]>([]);\n const mix = ref(0);\n const status = ref<GlobeStatus>('idle');\n const labels = ref<readonly string[]>([]);\n\n let run = 0;\n\n const meta = (dto: FieldIndexDto, day: string) => ({\n field: dto.field,\n run: dto.run,\n day,\n width: dto.width,\n height: dto.height,\n lonMin: dto.lonMin,\n latMax: dto.latMax,\n step: dto.step,\n scale: dto.scale,\n offset: dto.offset,\n unit: dto.unit,\n });\n\n const load = async (): Promise<void> => {\n const ticket = ++run;\n const { source, selection } = input;\n const field = input.fields?.[0] ?? fieldFromLayer(selection.value.layerId);\n const model = selection.value.model;\n status.value = 'loading';\n\n let dto: FieldIndexDto;\n try {\n const raw = await input.fetchJson(source.indexUrl(model, field));\n if (!isIndex(raw)) throw new Error('field index is not an index');\n dto = raw;\n } catch (error) {\n if (ticket !== run) return;\n frames.value = [];\n index.value = null;\n labels.value = [];\n mix.value = 0;\n status.value = isMissing(error) ? 'empty' : 'error';\n return;\n }\n\n if (ticket !== run) return;\n index.value = dto;\n labels.value = dto.days;\n\n const at = Math.min(\n Math.max(selection.value.dayIndex, 0),\n dto.days.length - 1,\n );\n const day = dto.days[at];\n if (day === undefined) {\n frames.value = [];\n status.value = 'empty';\n return;\n }\n const nextDay = dto.days[at + 1] ?? day;\n\n try {\n const first = await input.fetchBytes(\n source.gridUrl(model, field, dto.run, day),\n );\n const second =\n nextDay === day\n ? first\n : await input.fetchBytes(\n source.gridUrl(model, field, dto.run, nextDay),\n );\n if (ticket !== run) return;\n frames.value = [\n decodeGrid(first, meta(dto, day)),\n decodeGrid(second, meta(dto, nextDay)),\n ];\n mix.value = 0;\n status.value = 'ready';\n } catch (error) {\n if (ticket !== run) return;\n status.value = isMissing(error) ? 'empty' : 'error';\n }\n };\n\n return { index, frames, mix, status, labels, load };\n}\n","import { ref } from 'vue';\nimport type { Ref } from 'vue';\nimport type { Grid } from '@geoql/maplibre-gl-weather';\nimport { decodeGrid } from '@geoql/maplibre-gl-weather';\nimport type {\n FieldIndexDto,\n GlobeDataSource,\n GlobeSelection,\n WindPair,\n} from '../types';\n\nexport type { WindPair } from '../types';\nimport type { GlobeStatus } from './use-globe-fields';\n\n/** Everything `useGlobeParticles` reads. */\nexport interface GlobeParticlesInput {\n readonly source: GlobeDataSource;\n readonly selection: Ref<GlobeSelection>;\n readonly fetchJson: (url: string) => Promise<unknown>;\n readonly fetchBytes: (url: string) => Promise<Uint8Array>;\n}\n\n/** The wind grids and their state. */\nexport interface GlobeParticles {\n readonly wind: Ref<WindPair | null>;\n readonly status: Ref<GlobeStatus>;\n load(): Promise<void>;\n}\n\nconst isIndex = (value: unknown): value is FieldIndexDto => {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Partial<FieldIndexDto>;\n return (\n typeof candidate.run === 'string' &&\n Array.isArray(candidate.days) &&\n typeof candidate.width === 'number' &&\n typeof candidate.height === 'number'\n );\n};\n\nconst dayOf = (dto: FieldIndexDto, index: number): string | null => {\n const at = Math.min(Math.max(index, 0), dto.days.length - 1);\n return dto.days[at] ?? null;\n};\n\n/**\n * Loads the 10 m wind pair (`u` east, `v` north) for the selected day. A layer\n * with no wind fields, or a run that published none, is `'empty'` — the globe\n * then draws the field alone, never particles advected by zero wind.\n */\nexport function useGlobeParticles(input: GlobeParticlesInput): GlobeParticles {\n const wind = ref<WindPair | null>(null);\n const status = ref<GlobeStatus>('idle');\n\n let run = 0;\n\n const one = async (\n model: GlobeSelection['model'],\n field: 'wind-u' | 'wind-v',\n dayIndex: number,\n ): Promise<Grid | null> => {\n const raw = await input.fetchJson(input.source.indexUrl(model, field));\n if (!isIndex(raw)) throw new Error('wind index is not an index');\n const day = dayOf(raw, dayIndex);\n if (day === null) return null;\n const bytes = await input.fetchBytes(\n input.source.gridUrl(model, field, raw.run, day),\n );\n return decodeGrid(bytes, {\n field,\n run: raw.run,\n day,\n width: raw.width,\n height: raw.height,\n lonMin: raw.lonMin,\n latMax: raw.latMax,\n step: raw.step,\n scale: raw.scale,\n offset: raw.offset,\n unit: raw.unit,\n });\n };\n\n const load = async (): Promise<void> => {\n const ticket = ++run;\n status.value = 'loading';\n const { model, dayIndex } = input.selection.value;\n try {\n const [u, v] = await Promise.all([\n one(model, 'wind-u', dayIndex),\n one(model, 'wind-v', dayIndex),\n ]);\n if (ticket !== run) return;\n if (!u || !v) {\n wind.value = null;\n status.value = 'empty';\n return;\n }\n wind.value = { u, v };\n status.value = 'ready';\n } catch (error) {\n if (ticket !== run) return;\n const missing = (error as { status?: unknown } | null)?.status === 404;\n status.value = missing ? 'empty' : 'error';\n if (missing) wind.value = null;\n }\n };\n\n return { wind, status, load };\n}\n","/** A district source the globe may draw, or nothing for a locked country. */\nexport interface DistrictLayer {\n readonly id: string;\n readonly source: string;\n}\n\n/** What a caller must tell the districts composable. */\nexport interface GlobeDistrictsInput {\n /** True when the account may see district numbers everywhere. */\n readonly unlocked: boolean;\n /** The caller's own MVT template; a locked country is never asked for one. */\n readonly districtUrl: (dataset: string, country: string) => string;\n /** The dataset segment of `districtUrl`; defaults to `'boundaries'`. */\n readonly dataset?: string;\n}\n\n/** The districts' half of the globe. */\nexport interface GlobeDistricts {\n /** The layer for a country, or null when the caller may not show it. */\n layerFor(country: string): DistrictLayer | null;\n}\n\n/**\n * Decides whether a country's districts may be drawn at all. A locked country\n * gets `null`, so the component never mounts a source it may not show: no\n * district geometry reaches a browser that may not read it.\n */\nexport function useGlobeDistricts(input: GlobeDistrictsInput): GlobeDistricts {\n const dataset = input.dataset ?? 'boundaries';\n\n const layerFor = (country: string): DistrictLayer | null => {\n if (!input.unlocked) return null;\n const key = country.trim().toLowerCase();\n if (key === '') return null;\n return {\n id: `globe-districts-${key}`,\n source: input.districtUrl(dataset, key),\n };\n };\n\n return { layerFor };\n}\n"],"mappings":";;;;;;;;;;;;GAKE,OAAAC,UAAA,GAAAC,mBAGM,OAHNF,cAGM,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAFJG,mBAAuD,QAAA;IAAjD,OAAM;IAAsB,eAAY;G,cAC9CA,mBAA2D,QAAA,EAArD,OAAM,uBAAsB,GAAC,qBAAiB,E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AAO,QAAQ;EACf,MAAM,EAAE,OAAO,aAAa,MAAM,UAAU;EAC5C,IAAI;GACF,MAAM,CAAC,GAAG,KAAK,MAAM,QAAQ,IAAI,CAC/B,IAAI,OAAO,UAAU,QAAQ,GAC7B,IAAI,OAAO,UAAU,QAAQ,CAC/B,CAAC;GACD,IAAI,WAAW,KAAK;GACpB,IAAI,CAAC,KAAK,CAAC,GAAG;IACZ,KAAK,QAAQ;IACb,OAAO,QAAQ;IACf;GACF;GACA,KAAK,QAAQ;IAAE;IAAG;GAAE;GACpB,OAAO,QAAQ;EACjB,SAAS,OAAO;GACd,IAAI,WAAW,KAAK;GACpB,MAAM,UAAW,OAAuC,WAAW;GACnE,OAAO,QAAQ,UAAU,UAAU;GACnC,IAAI,SAAS,KAAK,QAAQ;EAC5B;CACF;CAEA,OAAO;EAAE;EAAM;EAAQ;CAAK;AAC9B;;;;;;;AClFA,SAAgB,kBAAkB,OAA4C;CAC5E,MAAM,UAAU,MAAM,WAAW;CAEjC,MAAM,YAAY,YAA0C;EAC1D,IAAI,CAAC,MAAM,UAAU,OAAO;EAC5B,MAAM,MAAM,QAAQ,KAAK,CAAC,CAAC,YAAY;EACvC,IAAI,QAAQ,IAAI,OAAO;EACvB,OAAO;GACL,IAAI,mBAAmB;GACvB,QAAQ,MAAM,YAAY,SAAS,GAAG;EACxC;CACF;CAEA,OAAO,EAAE,SAAS;AACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geolith/globe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "One MapLibre globe component: weather fields, wind particles and districts",
|
|
6
6
|
"keywords": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lint": "vp lint",
|
|
49
49
|
"format": "vp fmt --check",
|
|
50
50
|
"format:fix": "vp fmt --write",
|
|
51
|
-
"typecheck": "
|
|
51
|
+
"typecheck": "vue-tsc --noEmit -p tsconfig.json"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"reka-ui": "^2.12.0"
|
|
@@ -56,20 +56,23 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@commitlint/cli": "^21.3.0",
|
|
58
58
|
"@commitlint/config-conventional": "^21.3.0",
|
|
59
|
-
"@geoql/maplibre-gl-weather": "^0.2.
|
|
59
|
+
"@geoql/maplibre-gl-weather": "^0.2.1",
|
|
60
60
|
"@types/node": "^26.6.11",
|
|
61
|
+
"@vitejs/plugin-vue": "^6.0.11",
|
|
61
62
|
"@vue/test-utils": "^2.6.0",
|
|
62
63
|
"happy-dom": "^21.0.4",
|
|
63
64
|
"husky": "^9.1.7",
|
|
64
65
|
"is-ci": "^4.1.0",
|
|
65
66
|
"lint-staged": "^17.6.3",
|
|
66
67
|
"maplibre-gl": "^6.21.0",
|
|
67
|
-
"typescript": "^
|
|
68
|
+
"typescript": "^6.0.3",
|
|
69
|
+
"unplugin-vue": "^8.0.1",
|
|
68
70
|
"vite-plus": "catalog:",
|
|
69
|
-
"vue": "^3.5.47"
|
|
71
|
+
"vue": "^3.5.47",
|
|
72
|
+
"vue-tsc": "^3.3.14"
|
|
70
73
|
},
|
|
71
74
|
"peerDependencies": {
|
|
72
|
-
"@geoql/maplibre-gl-weather": "^0.2.
|
|
75
|
+
"@geoql/maplibre-gl-weather": "^0.2.1",
|
|
73
76
|
"maplibre-gl": ">=6.21.0",
|
|
74
77
|
"vue": "^3.5.0"
|
|
75
78
|
},
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["MapLibreMap"],"sources":["../src/types.ts","../src/composables/use-globe-fields.ts","../src/composables/use-globe-particles.ts","../src/composables/use-globe-map.ts","../src/components/GlobeCanvas.ts","../src/components/GlobeLock.ts","../src/components/GlobeReadout.ts","../src/components/GlobeSkeleton.ts","../src/components/GlobeTimeSlider.ts","../src/composables/use-globe-state.ts","../src/composables/use-globe-districts.ts","../src/utils/camera.ts","../src/utils/handover.ts","../src/utils/palette.ts"],"mappings":";;;;;;;KAIY;;KAGA;;UAGK;;WAEN;;WAEA;;WAEA;;WAEA,iBAAiB;;WAEjB,iBAAiB;;;;;;UAOX;;EAEf,SAAS,OAAO,YAAY;;EAE5B,QAAQ,OAAO,YAAY,eAAe,aAAa;;EAEvD,aAAa,iBAAiB;;;UAIf;WACN;WACA,OAAO;WACP;;;;;;UAOM;WACN,OAAO;WACP,OAAO;WACP;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;UAIM;WACN;;;UAIM;WACN;;;KClEC;;UAGK;WACN,QAAQ;WACR,WAAW,IAAI;;WAEf,kBAAkB;WAClB,YAAY,gBAAgB;;WAE5B,aAAa,gBAAgB,QAAQ;;;UAI/B;WACN,OAAO,IAAI;WACX,QAAQ,aAAa;;WAErB,KAAK;WACL,QAAQ,IAAI;;WAEZ,QAAQ;EACjB,QAAQ;;;;;;;wBAoCM,eAAe,OAAO,mBAAmB;;UC9DxC;WACN,GAAG;WACH,GAAG;;;UAIG;WACN,QAAQ;WACR,WAAW,IAAI;WACf,YAAY,gBAAgB;WAC5B,aAAa,gBAAgB,QAAQ;;;UAI/B;WACN,MAAM,IAAI;WACV,QAAQ,IAAI;EACrB,QAAQ;;;;;;;wBAwBM,kBAAkB,OAAO,sBAAsB;;UC9B9C;WACN;WACA;;;UAIM;WACN,MAAM,IAAI;WACV,OAAO;WACP;WACA;WACA,QAAQ;WACR,QAAQ,aAAa;WACrB,KAAK;WACL;WACA,MAAM,IAAI;WACV,UAAU,IAAI;;WAEd,WAAW;WACX;;;UAIM;WACN,KAAK,IAAIA;EAClB,SAAS;EACT;;;;;;;wBAUc,YAAY,OAAO,mBAAmB;;UCrCrC;WACN,iBAAiB;WACjB,YAAY;WACZ,OAAO;WACP;WACA;WACA;WACA,kBAAkB;WACl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