@geolith/globe 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,81 @@
1
- # Temporary Holding Version
1
+ # @geolith/globe
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ One MapLibre globe component for geolith.app and the console: a smooth weather
4
+ field, animated wind particles and district layers, handing over from one to the
5
+ other as you zoom.
6
+
7
+ Public API: <https://www.npmjs.com/package/@geolith/globe> · Licence: Apache-2.0.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @geolith/globe maplibre-gl vue
13
+ ```
14
+
15
+ `maplibre-gl`, `vue` and `@geoql/maplibre-gl-weather` are peers: the app owns one
16
+ copy of each, so the globe never forks the map or the shader runtime.
17
+
18
+ ## Use
19
+
20
+ ```ts
21
+ import { GlobeCanvas, useGlobeState } from '@geolith/globe';
22
+ ```
23
+
24
+ ```vue
25
+ <GlobeCanvas
26
+ :layers="catalogue.layers"
27
+ :data-source="source"
28
+ :style="basemap"
29
+ :status="status"
30
+ :frames="frames"
31
+ :mix="mix"
32
+ :wind="wind"
33
+ :district="district"
34
+ :centroid="[78.9, 22.6]"
35
+ @idle="status = 'ready'"
36
+ />
37
+ ```
38
+
39
+ The component names no host and reads no key: the caller supplies a
40
+ `GlobeDataSource` whose `indexUrl` and `gridUrl` point at its own field grids,
41
+ and whose `districtUrl` is absent when the caller may show no districts.
42
+
43
+ ## What is in the box
44
+
45
+ | Export | What it does |
46
+ | -------------------------------------------------- | ----------------------------------------------------------------------- |
47
+ | `GlobeCanvas` | The map: globe projection, rotation until first touch, the three layers |
48
+ | `GlobeTimeSlider` | The run's own day labels, play/pause, `aria-valuetext` |
49
+ | `GlobeReadout` | The field value under the pointer, or nothing |
50
+ | `GlobeLock` | The locked-country state and its ask |
51
+ | `useGlobeState` | Layer, model, day, play, explored layers and the country lock |
52
+ | `useGlobeFields` | The index, then the chosen day and the next, for the blend |
53
+ | `useGlobeParticles` | The 10 m wind pair for the selected day |
54
+ | `useGlobeDistricts` | A district layer, or `null` for a locked country |
55
+ | `fieldOpacity`, `districtOpacity`, `particleCount` | The handover ramp and the particle budget |
56
+
57
+ ## Rules the code keeps
58
+
59
+ - **No data is a state, not a zero.** A missing run is `'empty'`; a failed grid
60
+ after a good index is `'error'` and keeps the frames it had.
61
+ - **A locked country is never drawn.** `useGlobeDistricts.layerFor` answers
62
+ `null`, so no district source is mounted for it.
63
+ - **A component carries no catalogue.** Labels, days and models come from the
64
+ caller and the run index.
65
+ - **Reduced motion is honoured**: no rotation, no particles.
66
+ - **The map mounts only where it has a size**, so a hidden page never opens a
67
+ WebGL context.
68
+
69
+ ## Development
70
+
71
+ ```bash
72
+ pnpm install
73
+ pnpm test # unit tests
74
+ pnpm build # dist/index.js + dist/index.d.ts
75
+ pnpm lint
76
+ pnpm format
77
+ pnpm typecheck
78
+ ```
79
+
80
+ The local gates are the gate (Actions billing is off for the org); paste their
81
+ exit codes in a PR.
@@ -0,0 +1,333 @@
1
+ import { Component, ComputedRef, Ref } from "vue";
2
+ import { Map, StyleSpecification } from "maplibre-gl";
3
+ import { Grid } from "@geoql/maplibre-gl-weather";
4
+ /**
5
+ * The forecast models the catalogue can publish a field for. The strings are the
6
+ * dataset's own model keys, so a URL is never assembled from a display name.
7
+ */
8
+ type GlobeModel = "gfs" | "ecmwf-ifs";
9
+ /** A quantised field the weather layers know how to draw. */
10
+ type GlobeField = "rain" | "tmax" | "tmin" | "wind-u" | "wind-v";
11
+ /** One catalogue layer, as the caller's catalogue defines it. */
12
+ interface GlobeLayer {
13
+ /** Catalogue id: `'forecast-rain'`, `'wind'`, `'flood-risk'`. */
14
+ readonly id: string;
15
+ /** The catalogue's own label; never typed by the app. */
16
+ readonly label: string;
17
+ /** A global field, or a district dataset drawn when zoomed in. */
18
+ readonly kind: "field" | "district";
19
+ /** Models that publish this layer; empty for a district layer. */
20
+ readonly models: readonly GlobeModel[];
21
+ /** Fields this layer draws; empty for a district layer. */
22
+ readonly fields: readonly GlobeField[];
23
+ }
24
+ /**
25
+ * Where a globe reads its data. The component names no host, bucket or key: the
26
+ * caller supplies every URL, and a locked country has no district URL at all.
27
+ */
28
+ interface GlobeDataSource {
29
+ /** The run/day index for one model and field. */
30
+ indexUrl(model: GlobeModel, field: string): string;
31
+ /** The quantised grid for one run and day. */
32
+ gridUrl(model: GlobeModel, field: string, run: string, day: string): string;
33
+ /** A district MVT template; absent when the caller may show no districts. */
34
+ districtUrl?(dataset: string, country: string): string;
35
+ }
36
+ /** What the globe is showing right now. */
37
+ interface GlobeSelection {
38
+ readonly layerId: string;
39
+ readonly model: GlobeModel;
40
+ readonly dayIndex: number;
41
+ }
42
+ /**
43
+ * The index a builder writes beside a field's grids. Mirrors the API contract;
44
+ * every number a shader needs to place a cell is here.
45
+ */
46
+ interface FieldIndexDto {
47
+ readonly model: GlobeModel;
48
+ readonly field: GlobeField;
49
+ readonly run: string;
50
+ readonly days: readonly string[];
51
+ readonly width: number;
52
+ readonly height: number;
53
+ readonly lonMin: number;
54
+ readonly latMax: number;
55
+ readonly step: number;
56
+ readonly scale: number;
57
+ readonly offset: number;
58
+ readonly unit: string;
59
+ readonly builtAt: string;
60
+ }
61
+ /** A pointer value read from the field, or null where the grid has no data. */
62
+ interface GlobeHover {
63
+ readonly lon: number;
64
+ readonly lat: number;
65
+ readonly value: number | null;
66
+ readonly unit: string;
67
+ }
68
+ /** A district the visitor clicked. */
69
+ interface GlobeSelect {
70
+ readonly areaId: string;
71
+ }
72
+ /** A click on a country whose numbers the caller may not show. */
73
+ interface GlobeLockedClick {
74
+ readonly country: string;
75
+ }
76
+ /** What the field layer is doing, as the page reports it. */
77
+ type GlobeStatus = "idle" | "loading" | "ready" | "empty" | "error";
78
+ /** Everything `useGlobeFields` reads. */
79
+ interface GlobeFieldsInput {
80
+ readonly source: GlobeDataSource;
81
+ readonly selection: Ref<GlobeSelection>;
82
+ /** The catalogue layer's fields; the first one is drawn and blended. */
83
+ readonly fields?: readonly GlobeField[];
84
+ readonly fetchJson: (url: string) => Promise<unknown>;
85
+ /** The grid's decoded bytes: the transport un-gzips, never the shader. */
86
+ readonly fetchBytes: (url: string) => Promise<Uint8Array>;
87
+ }
88
+ /** The field frames and their state. */
89
+ interface GlobeFields {
90
+ readonly index: Ref<FieldIndexDto | null>;
91
+ readonly frames: Ref<readonly Grid[]>;
92
+ /** `0` shows `frames[0]`, `1` shows `frames[1]`. */
93
+ readonly mix: Ref<number>;
94
+ readonly status: Ref<GlobeStatus>;
95
+ /** The index's own day labels, in order. */
96
+ readonly labels: Ref<readonly string[]>;
97
+ load(): Promise<void>;
98
+ }
99
+ /**
100
+ * Loads one field's index, then the selected day and the day after it, so the
101
+ * shader can blend. The composable never invents a zero field: no data is
102
+ * `'empty'` and a failed grid after a good index keeps the frames it had.
103
+ */
104
+ export declare function useGlobeFields(input: GlobeFieldsInput): GlobeFields;
105
+ /** The wind pair the particle layer advects through. */
106
+ interface WindPair {
107
+ readonly u: Grid;
108
+ readonly v: Grid;
109
+ }
110
+ /** Everything `useGlobeParticles` reads. */
111
+ interface GlobeParticlesInput {
112
+ readonly source: GlobeDataSource;
113
+ readonly selection: Ref<GlobeSelection>;
114
+ readonly fetchJson: (url: string) => Promise<unknown>;
115
+ readonly fetchBytes: (url: string) => Promise<Uint8Array>;
116
+ }
117
+ /** The wind grids and their state. */
118
+ interface GlobeParticles {
119
+ readonly wind: Ref<WindPair | null>;
120
+ readonly status: Ref<GlobeStatus>;
121
+ load(): Promise<void>;
122
+ }
123
+ /**
124
+ * Loads the 10 m wind pair (`u` east, `v` north) for the selected day. A layer
125
+ * with no wind fields, or a run that published none, is `'empty'` — the globe
126
+ * then draws the field alone, never particles advected by zero wind.
127
+ */
128
+ export declare function useGlobeParticles(input: GlobeParticlesInput): GlobeParticles;
129
+ /** A district source the map may draw. */
130
+ interface DistrictSource {
131
+ readonly country: string;
132
+ readonly url: string;
133
+ }
134
+ /** Everything the map needs from the component. */
135
+ interface UseGlobeMapInput {
136
+ readonly host: Ref<HTMLElement | null>;
137
+ readonly style: StyleSpecification;
138
+ readonly centroid: readonly [number, number] | null;
139
+ readonly reducedMotion: boolean;
140
+ readonly source: GlobeDataSource;
141
+ readonly frames: Ref<readonly Grid[]>;
142
+ readonly mix: Ref<number>;
143
+ readonly palette: readonly string[] | null;
144
+ readonly wind: Ref<WindPair | null>;
145
+ readonly district: Ref<DistrictSource | null>;
146
+ /** True once the caller's data is ready; the map mounts then. */
147
+ readonly mountWhen: Ref<boolean>;
148
+ readonly onIdle: () => void;
149
+ }
150
+ /** The map handle and its lifecycle. */
151
+ interface GlobeMap {
152
+ readonly map: Ref<Map | null>;
153
+ mount(): Promise<void>;
154
+ dispose(): void;
155
+ }
156
+ /**
157
+ * The map's lifecycle and its layers. Mounts only when its host measures non
158
+ * zero in both axes, so a hidden page (or a test with no layout) mounts
159
+ * nothing and logs nothing.
160
+ */
161
+ export declare function useGlobeMap(input: UseGlobeMapInput): GlobeMap;
162
+ /** Everything the globe draws; the page supplies all of it. */
163
+ interface GlobeCanvasProps {
164
+ readonly layers: readonly GlobeLayer[];
165
+ readonly dataSource: GlobeDataSource;
166
+ readonly style: StyleSpecification;
167
+ readonly status: "loading" | "ready" | "empty" | "error";
168
+ readonly centroid?: readonly [number, number] | null;
169
+ readonly reducedMotion?: boolean;
170
+ readonly frames?: readonly Grid[];
171
+ readonly mix?: number;
172
+ readonly palette?: readonly string[] | null;
173
+ readonly wind?: WindPair | null;
174
+ readonly district?: DistrictSource | null;
175
+ }
176
+ export declare const GlobeCanvas: Component;
177
+ /** The locked country and the hook a page uses to open its own ask. */
178
+ interface GlobeLockProps {
179
+ readonly country: string;
180
+ }
181
+ export declare const GlobeLock: Component;
182
+ /** The pointer readout: a value and its unit, or nothing at all. */
183
+ interface GlobeReadoutProps {
184
+ readonly value: number | null;
185
+ readonly unit: string;
186
+ }
187
+ export declare const GlobeReadout: Component;
188
+ export declare const GlobeSkeleton: Component;
189
+ /** The 7-day slider: the run's own day labels, a play toggle, and a thumb. */
190
+ interface GlobeTimeSliderProps {
191
+ /** Day labels from the field index, in the run's order. */
192
+ readonly labels: readonly string[];
193
+ readonly modelValue: number;
194
+ readonly playing: boolean;
195
+ }
196
+ export declare const GlobeTimeSlider: Component;
197
+ /** What the visitor has explored: which layers, and since when (epoch ms). */
198
+ interface Explored {
199
+ readonly layers: ReadonlySet<string>;
200
+ readonly startedAt: number;
201
+ }
202
+ /** Everything a globe page drives from one place. */
203
+ interface GlobeState {
204
+ readonly selection: Ref<GlobeSelection>;
205
+ readonly playing: Ref<boolean>;
206
+ readonly explored: Ref<Explored>;
207
+ /** The layer the selection names, or null when the catalogue has no match. */
208
+ readonly layer: ComputedRef<GlobeLayer | null>;
209
+ /** The last frame index the caller's run published. */
210
+ readonly lastDay: ComputedRef<number>;
211
+ select(layerId: string): void;
212
+ setModel(model: GlobeModel): void;
213
+ setDay(index: number): void;
214
+ togglePlaying(value?: boolean): void;
215
+ /** False when `country` may show district numbers. */
216
+ lockFor(country: string): boolean;
217
+ }
218
+ /**
219
+ * The globe's state machine: which layer, model and day are showing, whether it
220
+ * plays, and which countries may show district numbers.
221
+ *
222
+ * Pure Vue reactivity — no browser API and no HTTP — so a page and a test share
223
+ * one behaviour. `now` is injected so a test can advance the exploration clock
224
+ * without sleeping.
225
+ */
226
+ export declare function useGlobeState(initial: {
227
+ readonly layers: readonly GlobeLayer[];
228
+ readonly days: number;
229
+ readonly unlocked: boolean;
230
+ readonly unlockedCountries: readonly string[];
231
+ readonly now?: () => number;
232
+ }): GlobeState;
233
+ /** A district source the globe may draw, or nothing for a locked country. */
234
+ interface DistrictLayer {
235
+ readonly id: string;
236
+ readonly source: string;
237
+ }
238
+ /** What a caller must tell the districts composable. */
239
+ interface GlobeDistrictsInput {
240
+ /** True when the account may see district numbers everywhere. */
241
+ readonly unlocked: boolean;
242
+ /** The caller's own MVT template; a locked country is never asked for one. */
243
+ readonly districtUrl: (dataset: string, country: string) => string;
244
+ /** The dataset segment of `districtUrl`; defaults to `'boundaries'`. */
245
+ readonly dataset?: string;
246
+ }
247
+ /** The districts' half of the globe. */
248
+ interface GlobeDistricts {
249
+ /** The layer for a country, or null when the caller may not show it. */
250
+ layerFor(country: string): DistrictLayer | null;
251
+ }
252
+ /**
253
+ * Decides whether a country's districts may be drawn at all. A locked country
254
+ * gets `null`, so the component never mounts a source it may not show: no
255
+ * district geometry reaches a browser that may not read it.
256
+ */
257
+ export declare function useGlobeDistricts(input: GlobeDistrictsInput): GlobeDistricts;
258
+ /**
259
+ * The globe opens at a fixed zoom and pitch, over one place: the visitor's
260
+ * country when the caller resolved it, the world otherwise.
261
+ */
262
+ export declare const OPEN_ZOOM = 1.8;
263
+ /** The globe is never tilted on open: a tilted planet hides half the field. */
264
+ export declare const OPEN_PITCH = 0;
265
+ /**
266
+ * Slow rotation so a still visitor sees a planet, not a poster. One full turn
267
+ * takes five minutes; faster reads as a loading spinner.
268
+ */
269
+ export declare const ROTATE_DEGREES_PER_SECOND = 1.2;
270
+ /** The world view: equirectangular centre of the planet, 20° north. */
271
+ export declare const WORLD_CENTRE: readonly [number, number];
272
+ /** Where the globe opens. */
273
+ interface OpeningCamera {
274
+ readonly center: [number, number];
275
+ readonly zoom: number;
276
+ readonly pitch: number;
277
+ }
278
+ /**
279
+ * The opening camera: the visitor's country's centroid when it is known, the
280
+ * world otherwise.
281
+ *
282
+ * @param centroid - `[lon, lat]` of the visitor's country, or null when unknown.
283
+ */
284
+ export declare function openingCamera(centroid: readonly [number, number] | null): OpeningCamera;
285
+ /**
286
+ * Whether the globe should rotate right now. Reduced motion is honoured, and the
287
+ * first interaction hands control to the visitor for good.
288
+ */
289
+ export declare function shouldRotate(reducedMotion: boolean, interacted: boolean): boolean;
290
+ /**
291
+ * Zoom range over which the field fades out and the districts fade in. They are
292
+ * the same two numbers on purpose: the globe is always showing one of them, and
293
+ * a seam between the ramps would show as a flash of bare basemap.
294
+ */
295
+ export declare const FIELD_FADE: readonly [number, number];
296
+ /** The districts' half of the same handover. */
297
+ export declare const DISTRICT_FADE: readonly [number, number];
298
+ /** The desktop particle count the spike measured as free on a desktop GPU. */
299
+ export declare const PARTICLE_CAP = 42e3;
300
+ /**
301
+ * Opacity of the global field at a zoom: 1 below the ramp, 0 above it, linear
302
+ * between.
303
+ */
304
+ export declare function fieldOpacity(zoom: number): number;
305
+ /** Opacity of the district fill at a zoom; the field's complement. */
306
+ export declare function districtOpacity(zoom: number): number;
307
+ /**
308
+ * How many particles to draw. A phone is given fewer because the fragment cost
309
+ * is per device pixel, and a visitor who prefers reduced motion gets none.
310
+ *
311
+ * @param width - The map's width in CSS pixels.
312
+ * @param dpr - The device pixel ratio the map draws at.
313
+ */
314
+ export declare function particleCount(width: number, dpr: number, reducedMotion: boolean): number;
315
+ /**
316
+ * The field ramps. They are data ramps, not brand colours: a shader needs plain
317
+ * RGB stops, and these are perceptually spaced so a 1 mm cell never looks like a
318
+ * 40 mm cell. A caller may pass its own stops to `WeatherFieldLayer`.
319
+ */
320
+ export declare const RAIN_RAMP: readonly string[];
321
+ /** Cold to hot, through a neutral middle so 0 °C is not tinted. */
322
+ export declare const TEMPERATURE_RAMP: readonly string[];
323
+ /** Calm to strong, the magma ramp. */
324
+ export declare const WIND_RAMP: readonly string[];
325
+ /** Every ramp the globe ships, keyed by the field family it draws. */
326
+ export declare const FIELD_PALETTES: Readonly<Record<"rain" | "temperature" | "wind", readonly string[]>>;
327
+ /**
328
+ * The ramp for a field name: rain grids take the rain ramp, both temperature
329
+ * fields the temperature ramp, both wind components the wind ramp.
330
+ */
331
+ export declare function paletteFor(field: string): readonly string[];
332
+ export type { DistrictLayer, DistrictSource, Explored, FieldIndexDto, GlobeCanvasProps, GlobeDataSource, GlobeDistricts, GlobeDistrictsInput, GlobeField, GlobeFields, GlobeFieldsInput, GlobeHover, GlobeLayer, GlobeLockProps, GlobeLockedClick, GlobeMap, GlobeModel, GlobeParticles, GlobeParticlesInput, GlobeReadoutProps, GlobeSelect, GlobeSelection, GlobeState, GlobeStatus, GlobeTimeSliderProps, OpeningCamera, UseGlobeMapInput, WindPair };
333
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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;WAClB;WACA;WACA,OAAO;WACP,WAAW;;qBA2GT,aAAa;;UCpIT;WACN;;qBAmCE,WAAW;;UCpCP;WACN;WACA;;qBA2BE,cAAc;qBCdd,eAAe;;UCdX;;WAEN;WACA;WACA;;qBA8DE,iBAAiB;;UClEb;WACN,QAAQ;WACR;;;UAIM;WACN,WAAW,IAAI;WACf,SAAS;WACT,UAAU,IAAI;;WAEd,OAAO,YAAY;;WAEnB,SAAS;EAClB,OAAO;EACP,SAAS,OAAO;EAChB,OAAO;EACP,cAAc;;EAEd,QAAQ;;;;;;;;;;wBAkBM,cAAc;WACnB,iBAAiB;WACjB;WACA;WACA;WACA;IACP;;UC/Ca;WACN;WACA;;;UAIM;;WAEN;;WAEA,cAAc,iBAAiB;;WAE/B;;;UAIM;;EAEf,SAAS,kBAAkB;;;;;;;wBAQb,kBAAkB,OAAO,sBAAsB;;;;;qBCvBlD;;qBAGA;;;;;qBAMA;;qBAGA;;UAGI;WACN;WACA;WACA;;;;;;;;wBASK,cACd,6CACC;;;;;wBAWa,aACd,wBACA;;;;;;qBCzCW;;qBAGA;;qBAGA;;;;;wBAQG,aAAa;;wBAQb,gBAAgB;;;;;;;;wBAWhB,cACd,eACA,aACA;;;;;;qBCpCW;;qBAWA;;qBAYA;;qBASA,gBAAgB,SAC3B;;;;;wBAWc,WAAW"}