@fusion.dev/helix-map 0.0.0-dev
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 +21 -0
- package/README.md +66 -0
- package/dist/connect-map/connect-map.d.ts +317 -0
- package/dist/connect-map/connect-map.d.ts.map +1 -0
- package/dist/connect-map/connect-map.js +847 -0
- package/dist/connect-map/connect-map.js.map +1 -0
- package/dist/connect-map/index.d.ts +3 -0
- package/dist/connect-map/index.d.ts.map +1 -0
- package/dist/connect-map/index.js +2 -0
- package/dist/connect-map/index.js.map +1 -0
- package/dist/contours/contours.d.ts +71 -0
- package/dist/contours/contours.d.ts.map +1 -0
- package/dist/contours/contours.js +314 -0
- package/dist/contours/contours.js.map +1 -0
- package/dist/credit/credit.d.ts +20 -0
- package/dist/credit/credit.d.ts.map +1 -0
- package/dist/credit/credit.js +65 -0
- package/dist/credit/credit.js.map +1 -0
- package/dist/credit/index.d.ts +3 -0
- package/dist/credit/index.d.ts.map +1 -0
- package/dist/credit/index.js +2 -0
- package/dist/credit/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/leaflet/index.d.ts +3 -0
- package/dist/leaflet/index.d.ts.map +1 -0
- package/dist/leaflet/index.js +2 -0
- package/dist/leaflet/index.js.map +1 -0
- package/dist/leaflet/leaflet-driver.d.ts +126 -0
- package/dist/leaflet/leaflet-driver.d.ts.map +1 -0
- package/dist/leaflet/leaflet-driver.js +241 -0
- package/dist/leaflet/leaflet-driver.js.map +1 -0
- package/dist/maplibre/index.d.ts +5 -0
- package/dist/maplibre/index.d.ts.map +1 -0
- package/dist/maplibre/index.js +3 -0
- package/dist/maplibre/index.js.map +1 -0
- package/dist/maplibre/map-images.d.ts +17 -0
- package/dist/maplibre/map-images.d.ts.map +1 -0
- package/dist/maplibre/map-images.js +138 -0
- package/dist/maplibre/map-images.js.map +1 -0
- package/dist/maplibre/maplibre-driver.d.ts +276 -0
- package/dist/maplibre/maplibre-driver.d.ts.map +1 -0
- package/dist/maplibre/maplibre-driver.js +1114 -0
- package/dist/maplibre/maplibre-driver.js.map +1 -0
- package/dist/motion/index.d.ts +3 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +2 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/motion/motion.d.ts +41 -0
- package/dist/motion/motion.d.ts.map +1 -0
- package/dist/motion/motion.js +167 -0
- package/dist/motion/motion.js.map +1 -0
- package/dist/points/index.d.ts +3 -0
- package/dist/points/index.d.ts.map +1 -0
- package/dist/points/index.js +2 -0
- package/dist/points/index.js.map +1 -0
- package/dist/points/points.d.ts +20 -0
- package/dist/points/points.d.ts.map +1 -0
- package/dist/points/points.js +41 -0
- package/dist/points/points.js.map +1 -0
- package/dist/snapshot/camera.d.ts +44 -0
- package/dist/snapshot/camera.d.ts.map +1 -0
- package/dist/snapshot/camera.js +42 -0
- package/dist/snapshot/camera.js.map +1 -0
- package/dist/snapshot/index.d.ts +5 -0
- package/dist/snapshot/index.d.ts.map +1 -0
- package/dist/snapshot/index.js +3 -0
- package/dist/snapshot/index.js.map +1 -0
- package/dist/snapshot/snapshot.d.ts +75 -0
- package/dist/snapshot/snapshot.d.ts.map +1 -0
- package/dist/snapshot/snapshot.js +290 -0
- package/dist/snapshot/snapshot.js.map +1 -0
- package/dist/style/index.d.ts +5 -0
- package/dist/style/index.d.ts.map +1 -0
- package/dist/style/index.js +3 -0
- package/dist/style/index.js.map +1 -0
- package/dist/style/map-colors.d.ts +69 -0
- package/dist/style/map-colors.d.ts.map +1 -0
- package/dist/style/map-colors.js +82 -0
- package/dist/style/map-colors.js.map +1 -0
- package/dist/style/map-style.d.ts +99 -0
- package/dist/style/map-style.d.ts.map +1 -0
- package/dist/style/map-style.js +440 -0
- package/dist/style/map-style.js.map +1 -0
- package/dist/style/oklab.d.ts +36 -0
- package/dist/style/oklab.d.ts.map +1 -0
- package/dist/style/oklab.js +76 -0
- package/dist/style/oklab.js.map +1 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/watch-theme.d.ts +14 -0
- package/dist/theme/watch-theme.d.ts.map +1 -0
- package/dist/theme/watch-theme.js +30 -0
- package/dist/theme/watch-theme.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type MapView } from './camera.js';
|
|
2
|
+
/** The token a snapshot layer's color is the land moved toward. */
|
|
3
|
+
export type SnapshotToward = 'foreground' | 'info' | 'primary' | 'success';
|
|
4
|
+
/**
|
|
5
|
+
* One layer of a snapshot: which of the tiles' layers it draws, which of its
|
|
6
|
+
* features, and in what. **The same as `mapLibreStyle`'s layer of the same
|
|
7
|
+
* `id`**, its color the land moved toward a token by the same amount and its
|
|
8
|
+
* width the same at every zoom, which the snapshot's spec holds it to, so the
|
|
9
|
+
* picture a page paints first is the map the renderer then draws.
|
|
10
|
+
*/
|
|
11
|
+
export interface SnapshotLayer {
|
|
12
|
+
/** Only features of these classes. */
|
|
13
|
+
classes?: readonly string[];
|
|
14
|
+
/** How far the land is moved toward `toward`, from 0 to 1. */
|
|
15
|
+
amount: number;
|
|
16
|
+
/** The feature classes left out. */
|
|
17
|
+
except?: readonly string[];
|
|
18
|
+
id: string;
|
|
19
|
+
kind: 'fill' | 'line';
|
|
20
|
+
/** The zoom it starts at, as the style's layer does. */
|
|
21
|
+
minzoom?: number;
|
|
22
|
+
/** Whether a feature in a tunnel is left out, as the style leaves it. */
|
|
23
|
+
overground?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The smallest a shape is drawn, as the area of the box around it on the
|
|
26
|
+
* screen, in square pixels. A city's buildings are most of the weight of a
|
|
27
|
+
* street map and the least of what a first paint needs, and the renderer
|
|
28
|
+
* draws the small ones over it a moment later.
|
|
29
|
+
*/
|
|
30
|
+
smallest?: number;
|
|
31
|
+
/** The tiles' layer it reads, in the OpenMapTiles schema. */
|
|
32
|
+
source: string;
|
|
33
|
+
toward: SnapshotToward;
|
|
34
|
+
/** A line's width at two zooms, in pixels, widened between them as the style widens it. */
|
|
35
|
+
width?: readonly [readonly [number, number], readonly [number, number]];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* What a snapshot draws, bottom to top: the ground, the water, the buildings
|
|
39
|
+
* and the roads. The labels, the landmarks and the signs are left to the
|
|
40
|
+
* renderer, which places them where they do not collide; a picture that drew
|
|
41
|
+
* them would draw them where the renderer then would not.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SNAPSHOT_LAYERS: readonly SnapshotLayer[];
|
|
44
|
+
/** A width between two zooms as MapLibre interpolates it: exponentially, by 1.5 a zoom. */
|
|
45
|
+
export declare const widthAt: ([[z0, w0], [z1, w1]]: readonly [readonly [number, number], readonly [number, number]], zoom: number) => number;
|
|
46
|
+
/** What a snapshot is drawn from. */
|
|
47
|
+
export interface SnapshotOptions {
|
|
48
|
+
/** The fetch the tiles are asked for with, where a server has its own, such as one that caches. */
|
|
49
|
+
fetch?: typeof fetch | undefined;
|
|
50
|
+
/** A TileJSON URL for vector tiles in the OpenMapTiles schema: the one given to `mapLibreStyle`. OpenFreeMap's by default. */
|
|
51
|
+
tiles?: string | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* **A map drawn on the server, for the page's first paint**: an SVG of the
|
|
55
|
+
* view a renderer is about to draw, from the same vector tiles and in the
|
|
56
|
+
* same colors, so the map is there before the renderer has loaded. Put it in
|
|
57
|
+
* the frame after the element the renderer draws in, since the renderer
|
|
58
|
+
* paints its land before its tiles arrive; `connectMap` fades it out once
|
|
59
|
+
* the renderer has drawn them. The frame's markers stand on it meanwhile.
|
|
60
|
+
*
|
|
61
|
+
* **Seen through the renderer's camera**, tilted and turned as the view
|
|
62
|
+
* says, so the streets it draws lie under the streets the renderer draws.
|
|
63
|
+
* It is drawn as a flat map, which is what a globe is at the zooms a page
|
|
64
|
+
* opens a street map at: a view zoomed out past about 6 is a globe in the
|
|
65
|
+
* renderer, and the picture would not match it.
|
|
66
|
+
*
|
|
67
|
+
* **Colored by the page's tokens**, each color written as the land moved
|
|
68
|
+
* toward a token in OKLab, so it is drawn in whichever theme the page is in,
|
|
69
|
+
* light or dark, and changes with it.
|
|
70
|
+
*
|
|
71
|
+
* Resolves to an empty string where the tiles cannot be read, which a page
|
|
72
|
+
* renders as nothing.
|
|
73
|
+
*/
|
|
74
|
+
export declare const mapSnapshot: (view: MapView, options?: SnapshotOptions) => Promise<string>;
|
|
75
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,OAAO,EAAoB,MAAM,aAAa,CAAA;AAEtE,mEAAmE;AACnE,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAE1E;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,cAAc,CAAA;IACtB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACxE;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EA+FnD,CAAA;AAmBD,2FAA2F;AAC3F,eAAO,MAAM,OAAO,yBACI,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAC/E,MAAM,KACX,MASF,CAAA;AAoDD,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC9B,mGAAmG;IACnG,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,CAAA;IAChC,8HAA8H;IAC9H,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B;AAWD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,SAChB,OAAO,YACJ,eAAe,KACvB,OAAO,CAAC,MAAM,CAoKhB,CAAA"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { VectorTile } from '@mapbox/vector-tile';
|
|
2
|
+
import Pbf from 'pbf';
|
|
3
|
+
import { cameraOf } from './camera.js';
|
|
4
|
+
export const SNAPSHOT_LAYERS = [
|
|
5
|
+
{
|
|
6
|
+
amount: 0.096,
|
|
7
|
+
classes: ['wood', 'grass', 'wetland'],
|
|
8
|
+
id: 'landcover',
|
|
9
|
+
kind: 'fill',
|
|
10
|
+
source: 'landcover',
|
|
11
|
+
toward: 'success',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
amount: 0.16,
|
|
15
|
+
except: ['historic'],
|
|
16
|
+
id: 'park',
|
|
17
|
+
kind: 'fill',
|
|
18
|
+
source: 'park',
|
|
19
|
+
toward: 'success',
|
|
20
|
+
},
|
|
21
|
+
{ amount: 0.3, id: 'water', kind: 'fill', overground: true, source: 'water', toward: 'info' },
|
|
22
|
+
{
|
|
23
|
+
amount: 0.3,
|
|
24
|
+
id: 'waterway',
|
|
25
|
+
kind: 'line',
|
|
26
|
+
overground: true,
|
|
27
|
+
source: 'waterway',
|
|
28
|
+
toward: 'info',
|
|
29
|
+
width: [
|
|
30
|
+
[8, 0.5],
|
|
31
|
+
[18, 6],
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
amount: 0.07,
|
|
36
|
+
id: 'building',
|
|
37
|
+
kind: 'fill',
|
|
38
|
+
minzoom: 13,
|
|
39
|
+
smallest: 400,
|
|
40
|
+
source: 'building',
|
|
41
|
+
toward: 'foreground',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
amount: 0.1,
|
|
45
|
+
classes: ['minor', 'service'],
|
|
46
|
+
id: 'road-minor',
|
|
47
|
+
kind: 'line',
|
|
48
|
+
minzoom: 12,
|
|
49
|
+
overground: true,
|
|
50
|
+
source: 'transportation',
|
|
51
|
+
toward: 'foreground',
|
|
52
|
+
width: [
|
|
53
|
+
[12, 0.5],
|
|
54
|
+
[18, 10],
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
amount: 0.16,
|
|
59
|
+
classes: ['secondary', 'tertiary'],
|
|
60
|
+
id: 'road-secondary',
|
|
61
|
+
kind: 'line',
|
|
62
|
+
minzoom: 10,
|
|
63
|
+
overground: true,
|
|
64
|
+
source: 'transportation',
|
|
65
|
+
toward: 'foreground',
|
|
66
|
+
width: [
|
|
67
|
+
[10, 0.5],
|
|
68
|
+
[18, 14],
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
amount: 0.4,
|
|
73
|
+
classes: ['primary', 'trunk'],
|
|
74
|
+
id: 'road-major',
|
|
75
|
+
kind: 'line',
|
|
76
|
+
minzoom: 8,
|
|
77
|
+
overground: true,
|
|
78
|
+
source: 'transportation',
|
|
79
|
+
toward: 'primary',
|
|
80
|
+
width: [
|
|
81
|
+
[8, 0.5],
|
|
82
|
+
[18, 16],
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
amount: 0.6,
|
|
87
|
+
classes: ['motorway'],
|
|
88
|
+
id: 'road-motorway',
|
|
89
|
+
kind: 'line',
|
|
90
|
+
minzoom: 5,
|
|
91
|
+
overground: true,
|
|
92
|
+
source: 'transportation',
|
|
93
|
+
toward: 'primary',
|
|
94
|
+
width: [
|
|
95
|
+
[5, 0.5],
|
|
96
|
+
[18, 18],
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
const TOKENS = {
|
|
101
|
+
foreground: '--helix-color-foreground',
|
|
102
|
+
info: '--helix-color-info',
|
|
103
|
+
primary: '--helix-color-primary',
|
|
104
|
+
success: '--helix-color-success',
|
|
105
|
+
surface: '--helix-color-surface',
|
|
106
|
+
};
|
|
107
|
+
const colorOf = (layer) => `color-mix(in oklab, var(${TOKENS.surface}), var(${TOKENS[layer.toward]}) ${+(layer.amount * 100).toFixed(2)}%)`;
|
|
108
|
+
export const widthAt = ([[z0, w0], [z1, w1]], zoom) => {
|
|
109
|
+
if (zoom <= z0) {
|
|
110
|
+
return w0;
|
|
111
|
+
}
|
|
112
|
+
if (zoom >= z1) {
|
|
113
|
+
return w1;
|
|
114
|
+
}
|
|
115
|
+
const t = (1.5 ** (zoom - z0) - 1) / (1.5 ** (z1 - z0) - 1);
|
|
116
|
+
return w0 + t * (w1 - w0);
|
|
117
|
+
};
|
|
118
|
+
const TOLERANCE = 0.8;
|
|
119
|
+
const SHORTEST = 12;
|
|
120
|
+
const simplified = (points) => {
|
|
121
|
+
if (points.length < 3) {
|
|
122
|
+
return points;
|
|
123
|
+
}
|
|
124
|
+
const kept = new Uint8Array(points.length);
|
|
125
|
+
kept[0] = 1;
|
|
126
|
+
kept[points.length - 1] = 1;
|
|
127
|
+
const stack = [[0, points.length - 1]];
|
|
128
|
+
while (stack.length > 0) {
|
|
129
|
+
const [from, to] = stack.pop();
|
|
130
|
+
const [ax, ay] = points[from];
|
|
131
|
+
const [bx, by] = points[to];
|
|
132
|
+
const length = Math.hypot(bx - ax, by - ay);
|
|
133
|
+
let farthest = -1;
|
|
134
|
+
let at = -1;
|
|
135
|
+
for (let index = from + 1; index < to; index++) {
|
|
136
|
+
const [px, py] = points[index];
|
|
137
|
+
const away = length === 0
|
|
138
|
+
? Math.hypot(px - ax, py - ay)
|
|
139
|
+
: Math.abs((bx - ax) * (ay - py) - (ax - px) * (by - ay)) / length;
|
|
140
|
+
if (away > farthest) {
|
|
141
|
+
farthest = away;
|
|
142
|
+
at = index;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (farthest > TOLERANCE) {
|
|
146
|
+
kept[at] = 1;
|
|
147
|
+
stack.push([from, at], [at, to]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return points.filter((_, index) => kept[index] === 1);
|
|
151
|
+
};
|
|
152
|
+
const OPENFREEMAP = 'https://tiles.openfreemap.org/planet';
|
|
153
|
+
const MOST_TILES = 40;
|
|
154
|
+
const MARGIN = 16;
|
|
155
|
+
export const mapSnapshot = async (view, options = {}) => {
|
|
156
|
+
const get = options.fetch ?? fetch;
|
|
157
|
+
const tiles = await get(options.tiles ?? OPENFREEMAP)
|
|
158
|
+
.then((response) => (response.ok ? response.json() : undefined))
|
|
159
|
+
.catch(() => undefined);
|
|
160
|
+
const template = tiles?.tiles?.[0];
|
|
161
|
+
if (!template) {
|
|
162
|
+
return '';
|
|
163
|
+
}
|
|
164
|
+
const deepest = tiles.maxzoom ?? 14;
|
|
165
|
+
const camera = cameraOf(view);
|
|
166
|
+
const corners = [
|
|
167
|
+
[0, 0],
|
|
168
|
+
[view.width, 0],
|
|
169
|
+
[0, view.height],
|
|
170
|
+
[view.width, view.height],
|
|
171
|
+
];
|
|
172
|
+
const ground = corners.map((corner) => camera.toWorld(corner));
|
|
173
|
+
let depth = Math.max(0, Math.min(deepest, Math.floor(view.zoom)));
|
|
174
|
+
const covering = (at) => {
|
|
175
|
+
const span = camera.size / 2 ** at;
|
|
176
|
+
const xs = ground.map(([x]) => Math.floor(x / span));
|
|
177
|
+
const ys = ground.map(([, y]) => Math.floor(y / span));
|
|
178
|
+
const count = 2 ** at;
|
|
179
|
+
const wanted = [];
|
|
180
|
+
for (let x = Math.min(...xs); x <= Math.max(...xs); x++) {
|
|
181
|
+
for (let y = Math.max(0, Math.min(...ys)); y <= Math.min(count - 1, Math.max(...ys)); y++) {
|
|
182
|
+
wanted.push([((x % count) + count) % count, y]);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return wanted;
|
|
186
|
+
};
|
|
187
|
+
let wanted = covering(depth);
|
|
188
|
+
while (wanted.length > MOST_TILES && depth > 0) {
|
|
189
|
+
depth -= 1;
|
|
190
|
+
wanted = covering(depth);
|
|
191
|
+
}
|
|
192
|
+
const span = camera.size / 2 ** depth;
|
|
193
|
+
const drawn = new Map(SNAPSHOT_LAYERS.map((layer) => [layer.id, []]));
|
|
194
|
+
const shown = SNAPSHOT_LAYERS.filter((layer) => view.zoom >= (layer.minzoom ?? 0));
|
|
195
|
+
const pathOf = (rings, [tx, ty], extent, closed, smallest) => {
|
|
196
|
+
let path = '';
|
|
197
|
+
for (const ring of rings) {
|
|
198
|
+
const points = [];
|
|
199
|
+
for (const point of ring) {
|
|
200
|
+
const on = camera.toScreen([(tx + point.x / extent) * span, (ty + point.y / extent) * span]);
|
|
201
|
+
if (on) {
|
|
202
|
+
points.push(on);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (points.length < 2) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const xs = points.map(([x]) => x);
|
|
209
|
+
const ys = points.map(([, y]) => y);
|
|
210
|
+
if (Math.max(...xs) < -MARGIN ||
|
|
211
|
+
Math.min(...xs) > view.width + MARGIN ||
|
|
212
|
+
Math.max(...ys) < -MARGIN ||
|
|
213
|
+
Math.min(...ys) > view.height + MARGIN ||
|
|
214
|
+
(Math.max(...xs) - Math.min(...xs)) * (Math.max(...ys) - Math.min(...ys)) < smallest ||
|
|
215
|
+
(!closed &&
|
|
216
|
+
Math.hypot(Math.max(...xs) - Math.min(...xs), Math.max(...ys) - Math.min(...ys)) <
|
|
217
|
+
SHORTEST)) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
let [lastX, lastY] = [0, 0];
|
|
221
|
+
simplified(points).forEach(([x, y], index) => {
|
|
222
|
+
const [px, py] = [Math.round(x), Math.round(y)];
|
|
223
|
+
if (index === 0) {
|
|
224
|
+
path += `M${px} ${py}`;
|
|
225
|
+
}
|
|
226
|
+
else if (px !== lastX || py !== lastY) {
|
|
227
|
+
path += `l${px - lastX} ${py - lastY}`;
|
|
228
|
+
}
|
|
229
|
+
;
|
|
230
|
+
[lastX, lastY] = [px, py];
|
|
231
|
+
});
|
|
232
|
+
if (closed) {
|
|
233
|
+
path += 'z';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return path;
|
|
237
|
+
};
|
|
238
|
+
await Promise.all(wanted.map(async (at) => {
|
|
239
|
+
const url = template
|
|
240
|
+
.replace('{z}', String(depth))
|
|
241
|
+
.replace('{x}', String(at[0]))
|
|
242
|
+
.replace('{y}', String(at[1]));
|
|
243
|
+
const bytes = await get(url)
|
|
244
|
+
.then((response) => (response.ok ? response.arrayBuffer() : undefined))
|
|
245
|
+
.catch(() => undefined);
|
|
246
|
+
if (!bytes) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const tile = new VectorTile(new Pbf(new Uint8Array(bytes)));
|
|
250
|
+
for (const layer of shown) {
|
|
251
|
+
const source = tile.layers[layer.source];
|
|
252
|
+
if (!source) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
for (let index = 0; index < source.length; index++) {
|
|
256
|
+
const feature = source.feature(index);
|
|
257
|
+
const kind = String(feature.properties.class ?? '');
|
|
258
|
+
if (feature.type !== (layer.kind === 'fill' ? 3 : 2) ||
|
|
259
|
+
(layer.classes && !layer.classes.includes(kind)) ||
|
|
260
|
+
layer.except?.includes(kind) ||
|
|
261
|
+
(layer.overground && feature.properties.brunnel === 'tunnel')) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const path = pathOf(feature.loadGeometry(), at, source.extent, layer.kind === 'fill', layer.smallest ?? 0);
|
|
265
|
+
if (path) {
|
|
266
|
+
drawn.get(layer.id)?.push(path);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}));
|
|
271
|
+
const body = shown
|
|
272
|
+
.map((layer) => {
|
|
273
|
+
const paths = drawn.get(layer.id) ?? [];
|
|
274
|
+
if (paths.length === 0) {
|
|
275
|
+
return '';
|
|
276
|
+
}
|
|
277
|
+
const color = colorOf(layer);
|
|
278
|
+
return layer.kind === 'fill'
|
|
279
|
+
? `<path fill-rule="evenodd" style="fill:${color}" d="${paths.join('')}"/>`
|
|
280
|
+
: `<path style="fill:none;stroke:${color};stroke-width:${+widthAt(layer.width ?? [
|
|
281
|
+
[0, 1],
|
|
282
|
+
[1, 1],
|
|
283
|
+
], view.zoom).toFixed(2)}px;stroke-linecap:round;stroke-linejoin:round" d="${paths.join('')}"/>`;
|
|
284
|
+
})
|
|
285
|
+
.join('');
|
|
286
|
+
return (`<div aria-hidden="true" data-helix-map-snapshot style="inset:0;overflow:hidden;pointer-events:none;position:absolute">` +
|
|
287
|
+
`<svg height="${view.height}" viewBox="0 0 ${view.width} ${view.height}" width="${view.width}" xmlns="http://www.w3.org/2000/svg" style="background:var(${TOKENS.surface});left:50%;position:absolute;top:50%;translate:-50% -50%">` +
|
|
288
|
+
`${body}</svg></div>`);
|
|
289
|
+
};
|
|
290
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/snapshot/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAA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EAAE,CAAC,CAAC;aACP,EACD,IAAI,CAAC,IAAI,CACV,CAAC,OAAO,CAAC,CAAC,CAAC,qDAAqD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAA;IAC1F,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAA;IACX,OAAO,CACL,wHAAwH;QACxH,gBAAgB,IAAI,CAAC,MAAM,kBAAkB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,YAAY,IAAI,CAAC,KAAK,8DAA8D,MAAM,CAAC,OAAO,4DAA4D;QACpO,GAAG,IAAI,cAAc,CACtB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { MapColors } from './map-colors.js';
|
|
2
|
+
export { colorsNow, colorsReady, fontReady, mapColorsFrom, mapFontFrom, PATIENCE, settledColor, } from './map-colors.js';
|
|
3
|
+
export type { MapImage, MapLibreStyle, MapStyleOptions } from './map-style.js';
|
|
4
|
+
export { mapLibreStyle } from './map-style.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/style/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,QAAQ,EACR,YAAY,GACb,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/style/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,QAAQ,EACR,YAAY,GACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colors a themed map is drawn from, each a `#hex`, `rgb()` or `rgba()`.
|
|
3
|
+
*
|
|
4
|
+
* **A handful, and the rest is mixed from them.** Buildings, borders, labels
|
|
5
|
+
* and the smaller roads are the land moved toward the ink by different
|
|
6
|
+
* amounts, so a light theme draws dark lines on a light ground and a dark
|
|
7
|
+
* theme light lines on a dark one, with no second palette to keep in step.
|
|
8
|
+
* The roads a reader navigates by take the brand, which is where a map shows
|
|
9
|
+
* whose it is.
|
|
10
|
+
*/
|
|
11
|
+
export interface MapColors {
|
|
12
|
+
/** The ink, which roads, borders and labels are mixed toward: `foreground`. */
|
|
13
|
+
foreground: string;
|
|
14
|
+
/** The water's hue, mixed quietly into the land: `info`. */
|
|
15
|
+
info: string;
|
|
16
|
+
/** The brand, which the motorways and the major roads are drawn toward: `primary`. */
|
|
17
|
+
primary: string;
|
|
18
|
+
/** The parks' and woods' hue, mixed more quietly still: `success`. */
|
|
19
|
+
success: string;
|
|
20
|
+
/** The land, which everything else is drawn on: `surface`. */
|
|
21
|
+
surface: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An element's own `color`, settled the same way: what a route or an area
|
|
25
|
+
* is drawn in, which its tone decides in the page's stylesheet and which the
|
|
26
|
+
* renderer can only take as sRGB.
|
|
27
|
+
*/
|
|
28
|
+
export declare const settledColor: (element: Element, property?: 'border-top-color' | 'color' | 'outline-color') => string;
|
|
29
|
+
/**
|
|
30
|
+
* The page's own colors, read where the map is, as a map style can take them.
|
|
31
|
+
*
|
|
32
|
+
* **Resolved by the browser and then by a canvas**, because a token is not a
|
|
33
|
+
* color yet: it is `light-dark()` over a ramp, or a `color-mix()`, which only
|
|
34
|
+
* the browser can settle for the element's color scheme, and what it settles
|
|
35
|
+
* to may be `oklch()`, which a map style cannot parse. Painting it onto one
|
|
36
|
+
* pixel and reading the pixel back gives the sRGB a style can. Read inside
|
|
37
|
+
* `element`, so a frame in a dark region of a light page is themed as dark.
|
|
38
|
+
*/
|
|
39
|
+
export declare const mapColorsFrom: (element: Element) => MapColors;
|
|
40
|
+
/**
|
|
41
|
+
* The page's colors where they can be read, or `null` while they cannot.
|
|
42
|
+
*
|
|
43
|
+
* **Not yet rather than never.** A stylesheet being swapped, which
|
|
44
|
+
* development does on every edit and a page can do on its own, takes the
|
|
45
|
+
* tokens away for a moment, and a restyle that landed in that moment threw
|
|
46
|
+
* out of an animation frame with nobody to catch it. Ask again a frame later,
|
|
47
|
+
* or call `mapColorsFrom`, whose error says what is missing.
|
|
48
|
+
*/
|
|
49
|
+
export declare const colorsNow: (element: Element) => MapColors | null;
|
|
50
|
+
/**
|
|
51
|
+
* The theme's typeface where the map is, as the one family name a map's
|
|
52
|
+
* labels are drawn in: the first of `--helix-font-sans`, unquoted.
|
|
53
|
+
*/
|
|
54
|
+
export declare const mapFontFrom: (element: Element) => string;
|
|
55
|
+
/**
|
|
56
|
+
* Resolves once the typeface's weights a map draws are loaded: regular,
|
|
57
|
+
* medium, bold and italic. MapLibre draws each letter once and keeps it, so
|
|
58
|
+
* one drawn before the face arrived stays in the fallback face.
|
|
59
|
+
*/
|
|
60
|
+
export declare const fontReady: (font: string) => Promise<void>;
|
|
61
|
+
/** How many frames to wait for the tokens before saying they are missing: a few seconds. */
|
|
62
|
+
export declare const PATIENCE = 180;
|
|
63
|
+
/**
|
|
64
|
+
* The page's colors once they can be read: at once where they already can,
|
|
65
|
+
* after a frame or two where the page is still settling, and the reason they
|
|
66
|
+
* cannot be where a few seconds pass without them.
|
|
67
|
+
*/
|
|
68
|
+
export declare const colorsReady: (element: Element) => Promise<MapColors>;
|
|
69
|
+
//# sourceMappingURL=map-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-colors.d.ts","sourceRoot":"","sources":["../../src/style/map-colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAA;IACf,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAA;CAChB;AAuCD;;;;GAIG;AACH,eAAO,MAAM,YAAY,YACd,OAAO,aACN,kBAAkB,GAAG,OAAO,GAAG,eAAe,KACvD,MAAsE,CAAA;AAEzE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,YAAa,OAAO,KAAG,SAqBhD,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,YAAa,OAAO,KAAG,SAAS,GAAG,IAMxD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,MAa9C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,SAAgB,MAAM,KAAG,OAAO,CAAC,IAAI,CAS1D,CAAA;AAED,4FAA4F;AAC5F,eAAO,MAAM,QAAQ,MAAM,CAAA;AAE3B;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAmB,OAAO,KAAG,OAAO,CAAC,SAAS,CASrE,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const TOKENS = {
|
|
2
|
+
foreground: '--helix-color-foreground',
|
|
3
|
+
info: '--helix-color-info',
|
|
4
|
+
primary: '--helix-color-primary',
|
|
5
|
+
success: '--helix-color-success',
|
|
6
|
+
surface: '--helix-color-surface',
|
|
7
|
+
};
|
|
8
|
+
let pixel;
|
|
9
|
+
const toSrgb = (resolved) => {
|
|
10
|
+
if (pixel === undefined) {
|
|
11
|
+
const canvas = document.createElement('canvas');
|
|
12
|
+
canvas.width = 1;
|
|
13
|
+
canvas.height = 1;
|
|
14
|
+
pixel = canvas.getContext('2d', { willReadFrequently: true });
|
|
15
|
+
}
|
|
16
|
+
const context = pixel;
|
|
17
|
+
if (!context) {
|
|
18
|
+
return resolved;
|
|
19
|
+
}
|
|
20
|
+
context.clearRect(0, 0, 1, 1);
|
|
21
|
+
context.fillStyle = resolved;
|
|
22
|
+
context.fillRect(0, 0, 1, 1);
|
|
23
|
+
const [red = 0, green = 0, blue = 0, alpha = 255] = context.getImageData(0, 0, 1, 1).data;
|
|
24
|
+
return alpha === 255
|
|
25
|
+
? `rgb(${red}, ${green}, ${blue})`
|
|
26
|
+
: `rgba(${red}, ${green}, ${blue}, ${alpha / 255})`;
|
|
27
|
+
};
|
|
28
|
+
export const settledColor = (element, property = 'color') => toSrgb(getComputedStyle(element).getPropertyValue(property));
|
|
29
|
+
export const mapColorsFrom = (element) => {
|
|
30
|
+
const probe = document.createElement('span');
|
|
31
|
+
probe.style.display = 'none';
|
|
32
|
+
element.append(probe);
|
|
33
|
+
const read = (token) => {
|
|
34
|
+
if (getComputedStyle(probe).getPropertyValue(token).trim() === '') {
|
|
35
|
+
probe.remove();
|
|
36
|
+
throw new Error(`mapColorsFrom: \`${token}\` is not defined where the map is. Load @fusion.dev/helix-styles, whose token layer defines it.`);
|
|
37
|
+
}
|
|
38
|
+
probe.style.color = `var(${token})`;
|
|
39
|
+
return toSrgb(getComputedStyle(probe).color);
|
|
40
|
+
};
|
|
41
|
+
const colors = Object.fromEntries(Object.entries(TOKENS).map(([name, token]) => [name, read(token)]));
|
|
42
|
+
probe.remove();
|
|
43
|
+
return colors;
|
|
44
|
+
};
|
|
45
|
+
export const colorsNow = (element) => {
|
|
46
|
+
try {
|
|
47
|
+
return mapColorsFrom(element);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const mapFontFrom = (element) => {
|
|
54
|
+
const probe = document.createElement('span');
|
|
55
|
+
probe.style.display = 'none';
|
|
56
|
+
probe.style.fontFamily = 'var(--helix-font-sans)';
|
|
57
|
+
element.append(probe);
|
|
58
|
+
const stack = getComputedStyle(probe).fontFamily;
|
|
59
|
+
probe.remove();
|
|
60
|
+
return (stack
|
|
61
|
+
.split(',')[0]
|
|
62
|
+
?.trim()
|
|
63
|
+
.replace(/^["']|["']$/g, '') || 'sans-serif');
|
|
64
|
+
};
|
|
65
|
+
export const fontReady = async (font) => {
|
|
66
|
+
if (typeof document === 'undefined' || !document.fonts) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
await Promise.all(['400', '500', '700', 'italic 400'].map((face) => document.fonts.load(`${face} 24px "${font}"`).catch(() => [])));
|
|
70
|
+
};
|
|
71
|
+
export const PATIENCE = 180;
|
|
72
|
+
export const colorsReady = async (element) => {
|
|
73
|
+
for (let waited = 0; waited < PATIENCE; waited++) {
|
|
74
|
+
const colors = colorsNow(element);
|
|
75
|
+
if (colors) {
|
|
76
|
+
return colors;
|
|
77
|
+
}
|
|
78
|
+
await new Promise((next) => requestAnimationFrame(next));
|
|
79
|
+
}
|
|
80
|
+
return mapColorsFrom(element);
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=map-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-colors.js","sourceRoot":"","sources":["../../src/style/map-colors.ts"],"names":[],"mappings":"AAwBA,MAAM,MAAM,GAAoC;IAC9C,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,uBAAuB;CACjC,CAAA;AAGD,IAAI,KAAkD,CAAA;AAOtD,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC1C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CA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