@geolith/globe 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +80 -2
- package/dist/index.d.ts +375 -0
- package/dist/index.js +885 -0
- package/dist/index.js.map +1 -0
- package/package.json +87 -4
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
|
-
#
|
|
1
|
+
# @geolith/globe
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
CI (`.github/workflows/ci.yml`) is the gate; run the same commands locally
|
|
81
|
+
before a PR.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { Grid } from "@geoql/maplibre-gl-weather";
|
|
2
|
+
import { Map, StyleSpecification } from "maplibre-gl";
|
|
3
|
+
import { ComputedRef, Ref } from "vue";
|
|
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
|
+
/** The wind pair the particle layer advects through. */
|
|
77
|
+
interface WindPair {
|
|
78
|
+
readonly u: Grid;
|
|
79
|
+
readonly v: Grid;
|
|
80
|
+
}
|
|
81
|
+
/** A district source the map may draw. */
|
|
82
|
+
interface DistrictSource {
|
|
83
|
+
readonly country: string;
|
|
84
|
+
readonly url: string;
|
|
85
|
+
}
|
|
86
|
+
/** Everything the globe draws; the page supplies all of it. */
|
|
87
|
+
interface GlobeCanvasProps {
|
|
88
|
+
readonly layers: readonly GlobeLayer[];
|
|
89
|
+
readonly dataSource: GlobeDataSource;
|
|
90
|
+
readonly style: StyleSpecification;
|
|
91
|
+
readonly status: 'loading' | 'ready' | 'empty' | 'error';
|
|
92
|
+
readonly centroid?: readonly [number, number] | null;
|
|
93
|
+
readonly reducedMotion?: boolean;
|
|
94
|
+
readonly frames?: readonly Grid[];
|
|
95
|
+
readonly mix?: number;
|
|
96
|
+
readonly palette?: readonly string[] | null;
|
|
97
|
+
readonly wind?: WindPair | null;
|
|
98
|
+
readonly district?: DistrictSource | null;
|
|
99
|
+
}
|
|
100
|
+
/** The 7-day slider: the run's own day labels, a play toggle, and a thumb. */
|
|
101
|
+
interface GlobeTimeSliderProps {
|
|
102
|
+
/** Day labels from the field index, in the run's order. */
|
|
103
|
+
readonly labels: readonly string[];
|
|
104
|
+
readonly modelValue: number;
|
|
105
|
+
readonly playing?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/** The pointer readout: a value and its unit, or nothing at all. */
|
|
108
|
+
interface GlobeReadoutProps {
|
|
109
|
+
readonly value?: number | null;
|
|
110
|
+
readonly unit: string;
|
|
111
|
+
}
|
|
112
|
+
/** The locked country and the hook a page uses to open its own ask. */
|
|
113
|
+
interface GlobeLockProps {
|
|
114
|
+
readonly country: string;
|
|
115
|
+
}
|
|
116
|
+
declare const __VLS_export$4: import("vue").DefineComponent<GlobeCanvasProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
117
|
+
idle: () => any;
|
|
118
|
+
select: (areaId: string) => any;
|
|
119
|
+
}, string, import("vue").PublicProps, Readonly<GlobeCanvasProps> & Readonly<{
|
|
120
|
+
onIdle?: (() => any) | undefined;
|
|
121
|
+
onSelect?: ((areaId: string) => any) | undefined;
|
|
122
|
+
}>, {
|
|
123
|
+
centroid: readonly [number, number] | null;
|
|
124
|
+
reducedMotion: boolean;
|
|
125
|
+
frames: readonly Grid[];
|
|
126
|
+
mix: number;
|
|
127
|
+
palette: readonly string[] | null;
|
|
128
|
+
wind: WindPair | null;
|
|
129
|
+
district: DistrictSource | null;
|
|
130
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
131
|
+
declare const _default: typeof __VLS_export$4;
|
|
132
|
+
declare const __VLS_export$3: import("vue").DefineComponent<GlobeLockProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
133
|
+
unlockRequest: (args_0: {
|
|
134
|
+
country: string;
|
|
135
|
+
}) => any;
|
|
136
|
+
}, string, import("vue").PublicProps, Readonly<GlobeLockProps> & Readonly<{
|
|
137
|
+
onUnlockRequest?: ((args_0: {
|
|
138
|
+
country: string;
|
|
139
|
+
}) => any) | undefined;
|
|
140
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
141
|
+
declare const _default$1: typeof __VLS_export$3;
|
|
142
|
+
declare const __VLS_export$2: import("vue").DefineComponent<GlobeReadoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<GlobeReadoutProps> & Readonly<{}>, {
|
|
143
|
+
value: number | null;
|
|
144
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
145
|
+
declare const _default$2: typeof __VLS_export$2;
|
|
146
|
+
declare const __VLS_export$1: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
147
|
+
declare const _default$3: typeof __VLS_export$1;
|
|
148
|
+
declare const __VLS_export: import("vue").DefineComponent<GlobeTimeSliderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
149
|
+
"update:modelValue": (value: number) => any;
|
|
150
|
+
toggle: () => any;
|
|
151
|
+
}, string, import("vue").PublicProps, Readonly<GlobeTimeSliderProps> & Readonly<{
|
|
152
|
+
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
153
|
+
onToggle?: (() => any) | undefined;
|
|
154
|
+
}>, {
|
|
155
|
+
playing: boolean;
|
|
156
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
157
|
+
declare const _default$4: typeof __VLS_export;
|
|
158
|
+
/** What the visitor has explored: which layers, and since when (epoch ms). */
|
|
159
|
+
interface Explored {
|
|
160
|
+
readonly layers: ReadonlySet<string>;
|
|
161
|
+
readonly startedAt: number;
|
|
162
|
+
}
|
|
163
|
+
/** Everything a globe page drives from one place. */
|
|
164
|
+
interface GlobeState {
|
|
165
|
+
readonly selection: Ref<GlobeSelection>;
|
|
166
|
+
readonly playing: Ref<boolean>;
|
|
167
|
+
readonly explored: Ref<Explored>;
|
|
168
|
+
/** The layer the selection names, or null when the catalogue has no match. */
|
|
169
|
+
readonly layer: ComputedRef<GlobeLayer | null>;
|
|
170
|
+
/** The last frame index the caller's run published. */
|
|
171
|
+
readonly lastDay: ComputedRef<number>;
|
|
172
|
+
select(layerId: string): void;
|
|
173
|
+
setModel(model: GlobeModel): void;
|
|
174
|
+
setDay(index: number): void;
|
|
175
|
+
togglePlaying(value?: boolean): void;
|
|
176
|
+
/** False when `country` may show district numbers. */
|
|
177
|
+
lockFor(country: string): boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The globe's state machine: which layer, model and day are showing, whether it
|
|
181
|
+
* plays, and which countries may show district numbers.
|
|
182
|
+
*
|
|
183
|
+
* Pure Vue reactivity — no browser API and no HTTP — so a page and a test share
|
|
184
|
+
* one behaviour. `now` is injected so a test can advance the exploration clock
|
|
185
|
+
* without sleeping.
|
|
186
|
+
*/
|
|
187
|
+
export declare function useGlobeState(initial: {
|
|
188
|
+
readonly layers: readonly GlobeLayer[];
|
|
189
|
+
readonly days: number;
|
|
190
|
+
readonly unlocked: boolean;
|
|
191
|
+
readonly unlockedCountries: readonly string[];
|
|
192
|
+
readonly now?: () => number;
|
|
193
|
+
}): GlobeState;
|
|
194
|
+
/** What the field layer is doing, as the page reports it. */
|
|
195
|
+
type GlobeStatus = 'idle' | 'loading' | 'ready' | 'empty' | 'error';
|
|
196
|
+
/** Everything `useGlobeFields` reads. */
|
|
197
|
+
interface GlobeFieldsInput {
|
|
198
|
+
readonly source: GlobeDataSource;
|
|
199
|
+
readonly selection: Ref<GlobeSelection>;
|
|
200
|
+
/** The catalogue layer's fields; the first one is drawn and blended. */
|
|
201
|
+
readonly fields?: readonly GlobeField[];
|
|
202
|
+
readonly fetchJson: (url: string) => Promise<unknown>;
|
|
203
|
+
/** The grid's decoded bytes: the transport un-gzips, never the shader. */
|
|
204
|
+
readonly fetchBytes: (url: string) => Promise<Uint8Array>;
|
|
205
|
+
}
|
|
206
|
+
/** The field frames and their state. */
|
|
207
|
+
interface GlobeFields {
|
|
208
|
+
readonly index: Ref<FieldIndexDto | null>;
|
|
209
|
+
readonly frames: Ref<readonly Grid[]>;
|
|
210
|
+
/** `0` shows `frames[0]`, `1` shows `frames[1]`. */
|
|
211
|
+
readonly mix: Ref<number>;
|
|
212
|
+
readonly status: Ref<GlobeStatus>;
|
|
213
|
+
/** The index's own day labels, in order. */
|
|
214
|
+
readonly labels: Ref<readonly string[]>;
|
|
215
|
+
load(): Promise<void>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Loads one field's index, then the selected day and the day after it, so the
|
|
219
|
+
* shader can blend. The composable never invents a zero field: no data is
|
|
220
|
+
* `'empty'` and a failed grid after a good index keeps the frames it had.
|
|
221
|
+
*/
|
|
222
|
+
export declare function useGlobeFields(input: GlobeFieldsInput): GlobeFields;
|
|
223
|
+
/** Everything `useGlobeParticles` reads. */
|
|
224
|
+
interface GlobeParticlesInput {
|
|
225
|
+
readonly source: GlobeDataSource;
|
|
226
|
+
readonly selection: Ref<GlobeSelection>;
|
|
227
|
+
readonly fetchJson: (url: string) => Promise<unknown>;
|
|
228
|
+
readonly fetchBytes: (url: string) => Promise<Uint8Array>;
|
|
229
|
+
}
|
|
230
|
+
/** The wind grids and their state. */
|
|
231
|
+
interface GlobeParticles {
|
|
232
|
+
readonly wind: Ref<WindPair | null>;
|
|
233
|
+
readonly status: Ref<GlobeStatus>;
|
|
234
|
+
load(): Promise<void>;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Loads the 10 m wind pair (`u` east, `v` north) for the selected day. A layer
|
|
238
|
+
* with no wind fields, or a run that published none, is `'empty'` — the globe
|
|
239
|
+
* then draws the field alone, never particles advected by zero wind.
|
|
240
|
+
*/
|
|
241
|
+
export declare function useGlobeParticles(input: GlobeParticlesInput): GlobeParticles;
|
|
242
|
+
/** A district source the globe may draw, or nothing for a locked country. */
|
|
243
|
+
interface DistrictLayer {
|
|
244
|
+
readonly id: string;
|
|
245
|
+
readonly source: string;
|
|
246
|
+
}
|
|
247
|
+
/** What a caller must tell the districts composable. */
|
|
248
|
+
interface GlobeDistrictsInput {
|
|
249
|
+
/** True when the account may see district numbers everywhere. */
|
|
250
|
+
readonly unlocked: boolean;
|
|
251
|
+
/** The caller's own MVT template; a locked country is never asked for one. */
|
|
252
|
+
readonly districtUrl: (dataset: string, country: string) => string;
|
|
253
|
+
/** The dataset segment of `districtUrl`; defaults to `'boundaries'`. */
|
|
254
|
+
readonly dataset?: string;
|
|
255
|
+
}
|
|
256
|
+
/** The districts' half of the globe. */
|
|
257
|
+
interface GlobeDistricts {
|
|
258
|
+
/** The layer for a country, or null when the caller may not show it. */
|
|
259
|
+
layerFor(country: string): DistrictLayer | null;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Decides whether a country's districts may be drawn at all. A locked country
|
|
263
|
+
* gets `null`, so the component never mounts a source it may not show: no
|
|
264
|
+
* district geometry reaches a browser that may not read it.
|
|
265
|
+
*/
|
|
266
|
+
export declare function useGlobeDistricts(input: GlobeDistrictsInput): GlobeDistricts;
|
|
267
|
+
/** Everything the map needs from the component. */
|
|
268
|
+
interface UseGlobeMapInput {
|
|
269
|
+
readonly host: Ref<HTMLElement | null>;
|
|
270
|
+
readonly style: StyleSpecification;
|
|
271
|
+
readonly centroid: readonly [number, number] | null;
|
|
272
|
+
readonly reducedMotion: boolean;
|
|
273
|
+
readonly source: GlobeDataSource;
|
|
274
|
+
readonly frames: Ref<readonly Grid[]>;
|
|
275
|
+
readonly mix: Ref<number>;
|
|
276
|
+
readonly palette: readonly string[] | null;
|
|
277
|
+
readonly wind: Ref<WindPair | null>;
|
|
278
|
+
readonly district: Ref<DistrictSource | null>;
|
|
279
|
+
/** True once the caller's data is ready; the map mounts then. */
|
|
280
|
+
readonly mountWhen: Ref<boolean>;
|
|
281
|
+
readonly onIdle: () => void;
|
|
282
|
+
/** A district click, by the area's own UUID. */
|
|
283
|
+
readonly onSelect?: (areaId: string) => void;
|
|
284
|
+
}
|
|
285
|
+
/** The map handle and its lifecycle. */
|
|
286
|
+
interface GlobeMap {
|
|
287
|
+
readonly map: Ref<Map | null>;
|
|
288
|
+
mount(): Promise<void>;
|
|
289
|
+
dispose(): void;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The map's lifecycle and its layers.
|
|
293
|
+
*
|
|
294
|
+
* MapLibre 6 refuses `setProjection` until a style is loaded, so the globe is
|
|
295
|
+
* converted on `load` and again on `style.load` (a new style drops both the
|
|
296
|
+
* projection and every custom layer). A mount can never run twice, and every
|
|
297
|
+
* add is guarded by the layer's existence, so N mounts and any number of prop
|
|
298
|
+
* changes leave exactly one map and one canvas.
|
|
299
|
+
*/
|
|
300
|
+
export declare function useGlobeMap(input: UseGlobeMapInput): GlobeMap;
|
|
301
|
+
/**
|
|
302
|
+
* The globe opens at a fixed zoom and pitch, over one place: the visitor's
|
|
303
|
+
* country when the caller resolved it, the world otherwise.
|
|
304
|
+
*/
|
|
305
|
+
export declare const OPEN_ZOOM = 1.8;
|
|
306
|
+
/** The globe is never tilted on open: a tilted planet hides half the field. */
|
|
307
|
+
export declare const OPEN_PITCH = 0;
|
|
308
|
+
/**
|
|
309
|
+
* Slow rotation so a still visitor sees a planet, not a poster. One full turn
|
|
310
|
+
* takes five minutes; faster reads as a loading spinner.
|
|
311
|
+
*/
|
|
312
|
+
export declare const ROTATE_DEGREES_PER_SECOND = 1.2;
|
|
313
|
+
/** The world view: equirectangular centre of the planet, 20° north. */
|
|
314
|
+
export declare const WORLD_CENTRE: readonly [number, number];
|
|
315
|
+
/** Where the globe opens. */
|
|
316
|
+
interface OpeningCamera {
|
|
317
|
+
readonly center: [number, number];
|
|
318
|
+
readonly zoom: number;
|
|
319
|
+
readonly pitch: number;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The opening camera: the visitor's country's centroid when it is known, the
|
|
323
|
+
* world otherwise.
|
|
324
|
+
*
|
|
325
|
+
* @param centroid - `[lon, lat]` of the visitor's country, or null when unknown.
|
|
326
|
+
*/
|
|
327
|
+
export declare function openingCamera(centroid: readonly [number, number] | null): OpeningCamera;
|
|
328
|
+
/**
|
|
329
|
+
* Whether the globe should rotate right now. Reduced motion is honoured, and the
|
|
330
|
+
* first interaction hands control to the visitor for good.
|
|
331
|
+
*/
|
|
332
|
+
export declare function shouldRotate(reducedMotion: boolean, interacted: boolean): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Zoom range over which the field fades out and the districts fade in. They are
|
|
335
|
+
* the same two numbers on purpose: the globe is always showing one of them, and
|
|
336
|
+
* a seam between the ramps would show as a flash of bare basemap.
|
|
337
|
+
*/
|
|
338
|
+
export declare const FIELD_FADE: readonly [number, number];
|
|
339
|
+
/** The districts' half of the same handover. */
|
|
340
|
+
export declare const DISTRICT_FADE: readonly [number, number];
|
|
341
|
+
/** The desktop particle count the spike measured as free on a desktop GPU. */
|
|
342
|
+
export declare const PARTICLE_CAP = 42000;
|
|
343
|
+
/**
|
|
344
|
+
* Opacity of the global field at a zoom: 1 below the ramp, 0 above it, linear
|
|
345
|
+
* between.
|
|
346
|
+
*/
|
|
347
|
+
export declare function fieldOpacity(zoom: number): number;
|
|
348
|
+
/** Opacity of the district fill at a zoom; the field's complement. */
|
|
349
|
+
export declare function districtOpacity(zoom: number): number;
|
|
350
|
+
/**
|
|
351
|
+
* How many particles to draw. A phone is given fewer because the fragment cost
|
|
352
|
+
* is per device pixel, and a visitor who prefers reduced motion gets none.
|
|
353
|
+
*
|
|
354
|
+
* @param width - The map's width in CSS pixels.
|
|
355
|
+
* @param dpr - The device pixel ratio the map draws at.
|
|
356
|
+
*/
|
|
357
|
+
export declare function particleCount(width: number, dpr: number, reducedMotion: boolean): number;
|
|
358
|
+
/**
|
|
359
|
+
* The field ramps. They are data ramps, not brand colours: a shader needs plain
|
|
360
|
+
* RGB stops, and these are perceptually spaced so a 1 mm cell never looks like a
|
|
361
|
+
* 40 mm cell. A caller may pass its own stops to `WeatherFieldLayer`.
|
|
362
|
+
*/
|
|
363
|
+
export declare const RAIN_RAMP: readonly string[];
|
|
364
|
+
/** Cold to hot, through a neutral middle so 0 °C is not tinted. */
|
|
365
|
+
export declare const TEMPERATURE_RAMP: readonly string[];
|
|
366
|
+
/** Calm to strong, the magma ramp. */
|
|
367
|
+
export declare const WIND_RAMP: readonly string[];
|
|
368
|
+
/** Every ramp the globe ships, keyed by the field family it draws. */
|
|
369
|
+
export declare const FIELD_PALETTES: Readonly<Record<'rain' | 'temperature' | 'wind', readonly string[]>>;
|
|
370
|
+
/**
|
|
371
|
+
* The ramp for a field name: rain grids take the rain ramp, both temperature
|
|
372
|
+
* fields the temperature ramp, both wind components the wind ramp.
|
|
373
|
+
*/
|
|
374
|
+
export declare function paletteFor(field: string): readonly string[];
|
|
375
|
+
export { type DistrictLayer, type DistrictSource, type Explored, type FieldIndexDto, _default as GlobeCanvas, type GlobeCanvasProps, type GlobeDataSource, type GlobeDistricts, type GlobeDistrictsInput, type GlobeField, type GlobeFields, type GlobeFieldsInput, type GlobeHover, type GlobeLayer, _default$1 as GlobeLock, type GlobeLockProps, type GlobeLockedClick, type GlobeMap, type GlobeModel, type GlobeParticles, type GlobeParticlesInput, _default$2 as GlobeReadout, type GlobeReadoutProps, type GlobeSelect, type GlobeSelection, _default$3 as GlobeSkeleton, type GlobeState, type GlobeStatus, _default$4 as GlobeTimeSlider, type GlobeTimeSliderProps, type OpeningCamera, type UseGlobeMapInput, type WindPair };
|