@tileflow/static 0.1.0-alpha.22 → 0.1.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -17
- package/dist/chunk-6DWVCK64.js +406 -0
- package/dist/chunk-HVVIAOBE.js +175 -0
- package/dist/{chunk-MSQ4OLKA.js → chunk-N63IFMFM.js} +22 -22
- package/dist/{chunk-EMCKSFZV.js → chunk-TBI5AED6.js} +172 -52
- package/dist/{chunk-TQMKOTBE.js → chunk-XMT7VJL5.js} +70 -60
- package/dist/client.d.ts +19 -25
- package/dist/client.js +10 -7
- package/dist/errors-B9rwehK0.d.ts +21 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +35 -23
- package/dist/manifest.d.ts +234 -373
- package/dist/manifest.js +9 -15
- package/dist/overlays.d.ts +9 -3
- package/dist/overlays.js +6 -4
- package/dist/scene-contract-Cr6BNLz0.d.ts +734 -0
- package/dist/scene.d.ts +91 -10
- package/dist/scene.js +17 -3
- package/package.json +4 -7
- package/GENERATED_OUTPUT_LICENSE.md +0 -21
- package/NOTICE +0 -9
- package/TRADEMARKS.md +0 -10
- package/dist/chunk-EPOYQNNT.js +0 -122
- package/dist/chunk-NM2JSFUF.js +0 -252
- package/dist/scene-contract-OMIOisSB.d.ts +0 -204
package/dist/scene.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { S as StaticMapError } from './errors-B9rwehK0.js';
|
|
3
|
+
import { j as StaticSceneInput, i as StaticScene } from './scene-contract-Cr6BNLz0.js';
|
|
4
|
+
export { M as MAX_OVERLAY_LATITUDE, S as StaticAttributionMode, a as StaticAttributionPosition, b as StaticAttributionRequest, c as StaticCoordinate, d as StaticMapFormat, g as StaticOverlayPlacement, h as StaticPadding, k as StaticSymbolAnchor, l as StaticSymbolCollision, m as StaticSymbolLabelAppearance, n as StaticSymbolLabelPosition, o as StaticSymbolLanguage, p as isSupportedStaticSymbolCodePoint, s as staticAttributionPositionSchema, q as staticAttributionRequestSchema, r as staticOverlayPlacements, u as staticSceneLimits, v as staticSceneSchema, w as staticSceneSchemaVersion, x as staticSymbolAnchors, y as staticSymbolCollisions, z as staticSymbolLabelAppearances, A as staticSymbolLabelPositions, B as staticSymbolLanguages } from './scene-contract-Cr6BNLz0.js';
|
|
4
5
|
|
|
5
6
|
declare const autoFitDetailsSchema: z.ZodObject<{
|
|
6
7
|
overlay: z.ZodOptional<z.ZodObject<{
|
|
7
8
|
id: z.ZodString;
|
|
8
9
|
index: z.ZodNumber;
|
|
9
10
|
type: z.ZodEnum<{
|
|
10
|
-
line: "line";
|
|
11
11
|
circle: "circle";
|
|
12
|
+
line: "line";
|
|
12
13
|
marker: "marker";
|
|
13
14
|
polygon: "polygon";
|
|
15
|
+
symbol: "symbol";
|
|
14
16
|
}>;
|
|
15
17
|
}, z.core.$strict>>;
|
|
16
18
|
padding: z.ZodOptional<z.ZodObject<{
|
|
@@ -44,14 +46,41 @@ declare const staticOverlayInvalidDetailsSchema: z.ZodObject<{
|
|
|
44
46
|
id: z.ZodString;
|
|
45
47
|
index: z.ZodNumber;
|
|
46
48
|
type: z.ZodEnum<{
|
|
47
|
-
line: "line";
|
|
48
49
|
circle: "circle";
|
|
50
|
+
line: "line";
|
|
49
51
|
marker: "marker";
|
|
50
52
|
polygon: "polygon";
|
|
53
|
+
symbol: "symbol";
|
|
51
54
|
}>;
|
|
52
55
|
}, z.core.$strict>;
|
|
53
56
|
}, z.core.$strict>;
|
|
54
|
-
|
|
57
|
+
declare const staticLabelUnsupportedDetailsSchema: z.ZodObject<{
|
|
58
|
+
codePoint: z.ZodNumber;
|
|
59
|
+
overlay: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
index: z.ZodNumber;
|
|
62
|
+
type: z.ZodLiteral<"symbol">;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
declare const staticIconUnavailableDetailsSchema: z.ZodObject<{
|
|
66
|
+
icon: z.ZodString;
|
|
67
|
+
overlay: z.ZodObject<{
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
index: z.ZodNumber;
|
|
70
|
+
type: z.ZodLiteral<"symbol">;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
declare const staticSymbolTooLargeDetailsSchema: z.ZodObject<{
|
|
74
|
+
height: z.ZodNumber;
|
|
75
|
+
limit: z.ZodLiteral<2048>;
|
|
76
|
+
overlay: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
index: z.ZodNumber;
|
|
79
|
+
type: z.ZodLiteral<"symbol">;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
width: z.ZodNumber;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
type StaticMapRequestErrorDetails = StaticAutoFitDetails | z.infer<typeof staticIconUnavailableDetailsSchema> | z.infer<typeof staticOverlayInvalidDetailsSchema> | z.infer<typeof staticLabelUnsupportedDetailsSchema> | z.infer<typeof staticSymbolTooLargeDetailsSchema>;
|
|
55
84
|
declare const staticMapRequestErrorResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
56
85
|
code: z.ZodLiteral<"AUTO_FIT_EMPTY">;
|
|
57
86
|
reason: z.ZodLiteral<"NO_FITTABLE_OVERLAYS">;
|
|
@@ -64,10 +93,11 @@ declare const staticMapRequestErrorResponseSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
64
93
|
id: z.ZodString;
|
|
65
94
|
index: z.ZodNumber;
|
|
66
95
|
type: z.ZodEnum<{
|
|
67
|
-
line: "line";
|
|
68
96
|
circle: "circle";
|
|
97
|
+
line: "line";
|
|
69
98
|
marker: "marker";
|
|
70
99
|
polygon: "polygon";
|
|
100
|
+
symbol: "symbol";
|
|
71
101
|
}>;
|
|
72
102
|
}, z.core.$strict>>;
|
|
73
103
|
padding: z.ZodOptional<z.ZodObject<{
|
|
@@ -103,10 +133,11 @@ declare const staticMapRequestErrorResponseSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
103
133
|
id: z.ZodString;
|
|
104
134
|
index: z.ZodNumber;
|
|
105
135
|
type: z.ZodEnum<{
|
|
106
|
-
line: "line";
|
|
107
136
|
circle: "circle";
|
|
137
|
+
line: "line";
|
|
108
138
|
marker: "marker";
|
|
109
139
|
polygon: "polygon";
|
|
140
|
+
symbol: "symbol";
|
|
110
141
|
}>;
|
|
111
142
|
}, z.core.$strict>>;
|
|
112
143
|
padding: z.ZodOptional<z.ZodObject<{
|
|
@@ -133,9 +164,9 @@ declare const staticMapRequestErrorResponseSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
133
164
|
}, z.core.$strict>>;
|
|
134
165
|
}, z.core.$strict>>;
|
|
135
166
|
reason: z.ZodEnum<{
|
|
167
|
+
CAMERA_UNRESOLVABLE: "CAMERA_UNRESOLVABLE";
|
|
136
168
|
GLOBE_NOT_SIMULTANEOUSLY_VISIBLE: "GLOBE_NOT_SIMULTANEOUSLY_VISIBLE";
|
|
137
169
|
INSUFFICIENT_VIEWPORT: "INSUFFICIENT_VIEWPORT";
|
|
138
|
-
CAMERA_UNRESOLVABLE: "CAMERA_UNRESOLVABLE";
|
|
139
170
|
PROJECTED_FOOTPRINT_OUTSIDE_VIEWPORT: "PROJECTED_FOOTPRINT_OUTSIDE_VIEWPORT";
|
|
140
171
|
}>;
|
|
141
172
|
error: z.ZodString;
|
|
@@ -149,16 +180,66 @@ declare const staticMapRequestErrorResponseSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
149
180
|
id: z.ZodString;
|
|
150
181
|
index: z.ZodNumber;
|
|
151
182
|
type: z.ZodEnum<{
|
|
152
|
-
line: "line";
|
|
153
183
|
circle: "circle";
|
|
184
|
+
line: "line";
|
|
154
185
|
marker: "marker";
|
|
155
186
|
polygon: "polygon";
|
|
187
|
+
symbol: "symbol";
|
|
156
188
|
}>;
|
|
157
189
|
}, z.core.$strict>;
|
|
158
190
|
}, z.core.$strict>;
|
|
159
191
|
reason: z.ZodLiteral<"OVERLAY_LATITUDE_OUT_OF_RANGE">;
|
|
160
192
|
error: z.ZodString;
|
|
161
193
|
retryable: z.ZodLiteral<false>;
|
|
194
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
195
|
+
code: z.ZodLiteral<"STATIC_MAP_LABEL_UNSUPPORTED">;
|
|
196
|
+
details: z.ZodObject<{
|
|
197
|
+
codePoint: z.ZodNumber;
|
|
198
|
+
overlay: z.ZodObject<{
|
|
199
|
+
id: z.ZodString;
|
|
200
|
+
index: z.ZodNumber;
|
|
201
|
+
type: z.ZodLiteral<"symbol">;
|
|
202
|
+
}, z.core.$strict>;
|
|
203
|
+
}, z.core.$strict>;
|
|
204
|
+
reason: z.ZodLiteral<"UNSUPPORTED_GLYPH">;
|
|
205
|
+
error: z.ZodString;
|
|
206
|
+
retryable: z.ZodLiteral<false>;
|
|
207
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
208
|
+
code: z.ZodLiteral<"STATIC_MAP_ICON_UNAVAILABLE">;
|
|
209
|
+
details: z.ZodObject<{
|
|
210
|
+
icon: z.ZodString;
|
|
211
|
+
overlay: z.ZodObject<{
|
|
212
|
+
id: z.ZodString;
|
|
213
|
+
index: z.ZodNumber;
|
|
214
|
+
type: z.ZodLiteral<"symbol">;
|
|
215
|
+
}, z.core.$strict>;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
reason: z.ZodEnum<{
|
|
218
|
+
ICON_NOT_FOUND: "ICON_NOT_FOUND";
|
|
219
|
+
MANAGED_SPRITE_REQUIRED: "MANAGED_SPRITE_REQUIRED";
|
|
220
|
+
}>;
|
|
221
|
+
error: z.ZodString;
|
|
222
|
+
retryable: z.ZodLiteral<false>;
|
|
223
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
224
|
+
code: z.ZodLiteral<"STATIC_MAP_PLACEMENT_UNAVAILABLE">;
|
|
225
|
+
reason: z.ZodLiteral<"MAP_REDEPLOY_REQUIRED">;
|
|
226
|
+
error: z.ZodString;
|
|
227
|
+
retryable: z.ZodLiteral<false>;
|
|
228
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
+
code: z.ZodLiteral<"STATIC_MAP_SYMBOL_TOO_LARGE">;
|
|
230
|
+
details: z.ZodObject<{
|
|
231
|
+
height: z.ZodNumber;
|
|
232
|
+
limit: z.ZodLiteral<2048>;
|
|
233
|
+
overlay: z.ZodObject<{
|
|
234
|
+
id: z.ZodString;
|
|
235
|
+
index: z.ZodNumber;
|
|
236
|
+
type: z.ZodLiteral<"symbol">;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
width: z.ZodNumber;
|
|
239
|
+
}, z.core.$strict>;
|
|
240
|
+
reason: z.ZodLiteral<"COMPOSED_IMAGE_TOO_LARGE">;
|
|
241
|
+
error: z.ZodString;
|
|
242
|
+
retryable: z.ZodLiteral<false>;
|
|
162
243
|
}, z.core.$strict>, z.ZodObject<{
|
|
163
244
|
code: z.ZodLiteral<"STATIC_MAP_ATTRIBUTION_UNSUPPORTED">;
|
|
164
245
|
reason: z.ZodEnum<{
|
|
@@ -182,7 +263,7 @@ type StaticMapRequestErrorResponse = z.infer<typeof staticMapRequestErrorRespons
|
|
|
182
263
|
type StaticAutoFitErrorResponse = Extract<StaticMapRequestErrorResponse, {
|
|
183
264
|
code: `AUTO_FIT_${string}`;
|
|
184
265
|
}>;
|
|
185
|
-
declare class StaticMapRequestError extends
|
|
266
|
+
declare class StaticMapRequestError extends StaticMapError {
|
|
186
267
|
readonly code: StaticMapRequestErrorResponse['code'];
|
|
187
268
|
readonly details?: StaticMapRequestErrorDetails;
|
|
188
269
|
readonly reason: StaticMapRequestErrorResponse['reason'];
|
package/dist/scene.js
CHANGED
|
@@ -3,24 +3,38 @@ import {
|
|
|
3
3
|
normalizeStaticScene,
|
|
4
4
|
staticMapRequestErrorResponseSchema,
|
|
5
5
|
validateStaticScene
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TBI5AED6.js";
|
|
7
7
|
import {
|
|
8
8
|
MAX_OVERLAY_LATITUDE,
|
|
9
|
+
isSupportedStaticSymbolCodePoint,
|
|
9
10
|
staticAttributionPositionSchema,
|
|
10
11
|
staticAttributionRequestSchema,
|
|
12
|
+
staticOverlayPlacements,
|
|
11
13
|
staticSceneLimits,
|
|
12
14
|
staticSceneSchema,
|
|
13
|
-
staticSceneSchemaVersion
|
|
14
|
-
|
|
15
|
+
staticSceneSchemaVersion,
|
|
16
|
+
staticSymbolAnchors,
|
|
17
|
+
staticSymbolCollisions,
|
|
18
|
+
staticSymbolLabelAppearances,
|
|
19
|
+
staticSymbolLabelPositions,
|
|
20
|
+
staticSymbolLanguages
|
|
21
|
+
} from "./chunk-6DWVCK64.js";
|
|
15
22
|
export {
|
|
16
23
|
MAX_OVERLAY_LATITUDE,
|
|
17
24
|
StaticMapRequestError,
|
|
25
|
+
isSupportedStaticSymbolCodePoint,
|
|
18
26
|
normalizeStaticScene,
|
|
19
27
|
staticAttributionPositionSchema,
|
|
20
28
|
staticAttributionRequestSchema,
|
|
21
29
|
staticMapRequestErrorResponseSchema,
|
|
30
|
+
staticOverlayPlacements,
|
|
22
31
|
staticSceneLimits,
|
|
23
32
|
staticSceneSchema,
|
|
24
33
|
staticSceneSchemaVersion,
|
|
34
|
+
staticSymbolAnchors,
|
|
35
|
+
staticSymbolCollisions,
|
|
36
|
+
staticSymbolLabelAppearances,
|
|
37
|
+
staticSymbolLabelPositions,
|
|
38
|
+
staticSymbolLanguages,
|
|
25
39
|
validateStaticScene
|
|
26
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tileflow/static",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.24",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Static map request schemas and helpers for Tileflow.",
|
|
6
6
|
"type": "module",
|
|
@@ -25,10 +25,7 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
|
-
"LICENSE"
|
|
29
|
-
"NOTICE",
|
|
30
|
-
"GENERATED_OUTPUT_LICENSE.md",
|
|
31
|
-
"TRADEMARKS.md"
|
|
28
|
+
"LICENSE"
|
|
32
29
|
],
|
|
33
30
|
"exports": {
|
|
34
31
|
".": {
|
|
@@ -64,8 +61,8 @@
|
|
|
64
61
|
"zod": "^4.4.3"
|
|
65
62
|
},
|
|
66
63
|
"scripts": {
|
|
67
|
-
"build": "tsup src/index.ts src/scene.ts src/overlays.ts src/manifest.ts src/client.ts --format esm --dts --clean --splitting",
|
|
68
|
-
"verify": "tsx --test test/*.test.ts",
|
|
64
|
+
"build": "tsup src/index.ts src/scene.ts src/overlays.ts src/manifest.ts src/client.ts --format esm --dts --clean --splitting && node ../../scripts/canonicalize-zod-enums.mjs dist",
|
|
65
|
+
"verify": "pnpm --silent --dir ../.. static-text:check && tsx --test test/*.test.ts",
|
|
69
66
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
70
67
|
"lint": "tsc -p tsconfig.json --noEmit"
|
|
71
68
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Tileflow generated-output grant
|
|
2
|
-
|
|
3
|
-
In addition to the rights granted by the Apache License, Version 2.0, Tileflow.dev contributors
|
|
4
|
-
grant recipients a perpetual, worldwide, non-exclusive, no-charge, royalty-free right to use,
|
|
5
|
-
reproduce, modify, display, perform, distribute, sublicense, and commercialize the Tileflow-owned
|
|
6
|
-
parts of output generated by this SDK.
|
|
7
|
-
|
|
8
|
-
Covered output includes compiled map styles, manifests, receipts, sprites, glyph artifacts, static
|
|
9
|
-
render descriptions, and other build artifacts produced from Tileflow maps or application maps.
|
|
10
|
-
Original Tileflow map definitions, icons, and patterns distributed by `@tileflow/maps` may likewise
|
|
11
|
-
be used, modified, embedded, deployed, and redistributed as part of personal or commercial maps and
|
|
12
|
-
applications.
|
|
13
|
-
|
|
14
|
-
This grant does not relicense third-party software, fonts, icons, map data, datasets, imagery, or
|
|
15
|
-
other input material. Their licenses, attribution requirements, notices, and use restrictions
|
|
16
|
-
continue to apply to the relevant source and generated output. You are responsible for having the
|
|
17
|
-
rights necessary to process and distribute your own inputs.
|
|
18
|
-
|
|
19
|
-
This grant does not provide access to Tileflow hosted services or grant rights in Tileflow names,
|
|
20
|
-
logos, or marks. The SDK and generated output are provided without warranties or conditions beyond
|
|
21
|
-
those required by applicable law.
|
package/NOTICE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
Tileflow SDK
|
|
2
|
-
Copyright 2026 Tileflow.dev contributors
|
|
3
|
-
|
|
4
|
-
This product includes software and original map artwork developed by Tileflow.dev contributors.
|
|
5
|
-
|
|
6
|
-
Third-party materials distributed with a package remain subject to their own license and notice
|
|
7
|
-
files. See THIRD_PARTY_NOTICES.md and asset-adjacent license files where present.
|
|
8
|
-
|
|
9
|
-
The Tileflow names and marks are not licensed under the Apache License 2.0. See TRADEMARKS.md.
|
package/TRADEMARKS.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Tileflow trademarks
|
|
2
|
-
|
|
3
|
-
The Apache License, Version 2.0, and the Tileflow generated-output grant do not grant permission to
|
|
4
|
-
use the Tileflow name, `tileflow.dev`, logos, service marks, product names, or other Tileflow brand
|
|
5
|
-
features except for reasonable and customary use that truthfully describes the origin of the SDK or
|
|
6
|
-
compatibility with Tileflow, and for reproducing required notices.
|
|
7
|
-
|
|
8
|
-
You may not use Tileflow brand features in a way that suggests sponsorship, endorsement, or an
|
|
9
|
-
official Tileflow product when none exists. Third-party names and marks remain the property of their
|
|
10
|
-
respective owners.
|
package/dist/chunk-EPOYQNNT.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeStaticOverlay,
|
|
3
|
-
roundNumber
|
|
4
|
-
} from "./chunk-NM2JSFUF.js";
|
|
5
|
-
|
|
6
|
-
// src/overlays.ts
|
|
7
|
-
function line(input) {
|
|
8
|
-
return normalizeStaticOverlay({ ...input, type: "line" });
|
|
9
|
-
}
|
|
10
|
-
function circle(input) {
|
|
11
|
-
return normalizeStaticOverlay({ ...input, type: "circle" });
|
|
12
|
-
}
|
|
13
|
-
function marker(input) {
|
|
14
|
-
return normalizeStaticOverlay({ ...input, type: "marker" });
|
|
15
|
-
}
|
|
16
|
-
function polygon(input) {
|
|
17
|
-
return normalizeStaticOverlay({ ...input, type: "polygon" });
|
|
18
|
-
}
|
|
19
|
-
function compileStaticOverlays(overlays, options = {}) {
|
|
20
|
-
if (options.longitudeOffsets !== void 0 && (options.longitudeOffsets.length !== overlays.length || options.longitudeOffsets.some(
|
|
21
|
-
(offset) => !Number.isInteger(offset) || Math.abs(offset) > 360 || offset % 360 !== 0
|
|
22
|
-
))) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
"Static overlay longitude offsets must contain one -360, 0, or 360 per overlay"
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
const sources = {};
|
|
28
|
-
const layers = [];
|
|
29
|
-
for (const [index, overlay] of overlays.entries()) {
|
|
30
|
-
const longitudeOffset = options.longitudeOffsets?.[index] ?? 0;
|
|
31
|
-
const id = safeLayerId(`overlay-${index + 1}-${overlay.id ?? overlay.type}`);
|
|
32
|
-
const sourceId = `${id}-source`;
|
|
33
|
-
if (overlay.type === "line") {
|
|
34
|
-
sources[sourceId] = {
|
|
35
|
-
data: feature("LineString", shiftLongitudes(overlay.coordinates, longitudeOffset)),
|
|
36
|
-
type: "geojson"
|
|
37
|
-
};
|
|
38
|
-
layers.push({
|
|
39
|
-
id,
|
|
40
|
-
layout: { "line-cap": "round", "line-join": "round" },
|
|
41
|
-
paint: {
|
|
42
|
-
"line-color": overlay.color,
|
|
43
|
-
"line-opacity": overlay.opacity,
|
|
44
|
-
"line-width": overlay.width
|
|
45
|
-
},
|
|
46
|
-
source: sourceId,
|
|
47
|
-
type: "line"
|
|
48
|
-
});
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (overlay.type === "polygon") {
|
|
52
|
-
sources[sourceId] = {
|
|
53
|
-
data: feature("Polygon", shiftLongitudes(overlay.coordinates, longitudeOffset)),
|
|
54
|
-
type: "geojson"
|
|
55
|
-
};
|
|
56
|
-
layers.push({
|
|
57
|
-
id,
|
|
58
|
-
paint: {
|
|
59
|
-
"fill-color": overlay.fill,
|
|
60
|
-
"fill-opacity": overlay.opacity
|
|
61
|
-
},
|
|
62
|
-
source: sourceId,
|
|
63
|
-
type: "fill"
|
|
64
|
-
});
|
|
65
|
-
if (overlay.stroke && overlay.strokeWidth > 0) {
|
|
66
|
-
layers.push({
|
|
67
|
-
id: `${id}-stroke`,
|
|
68
|
-
layout: { "line-cap": "round", "line-join": "round" },
|
|
69
|
-
paint: {
|
|
70
|
-
"line-color": overlay.stroke,
|
|
71
|
-
"line-width": overlay.strokeWidth
|
|
72
|
-
},
|
|
73
|
-
source: sourceId,
|
|
74
|
-
type: "line"
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
sources[sourceId] = {
|
|
80
|
-
data: feature("Point", shiftLongitudes(overlay.coordinate, longitudeOffset)),
|
|
81
|
-
type: "geojson"
|
|
82
|
-
};
|
|
83
|
-
layers.push({
|
|
84
|
-
id,
|
|
85
|
-
paint: {
|
|
86
|
-
"circle-color": overlay.color,
|
|
87
|
-
"circle-opacity": overlay.type === "circle" ? overlay.opacity : 1,
|
|
88
|
-
"circle-radius": overlay.radius,
|
|
89
|
-
"circle-stroke-color": overlay.strokeColor ?? overlay.color,
|
|
90
|
-
"circle-stroke-width": overlay.strokeWidth
|
|
91
|
-
},
|
|
92
|
-
source: sourceId,
|
|
93
|
-
type: "circle"
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return { layers, sources };
|
|
97
|
-
}
|
|
98
|
-
function shiftLongitudes(value, offset) {
|
|
99
|
-
if (!Array.isArray(value)) return value;
|
|
100
|
-
if (value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number") {
|
|
101
|
-
return [roundNumber(value[0] + offset), value[1]];
|
|
102
|
-
}
|
|
103
|
-
return value.map((entry) => shiftLongitudes(entry, offset));
|
|
104
|
-
}
|
|
105
|
-
function feature(type, coordinates) {
|
|
106
|
-
return {
|
|
107
|
-
geometry: { coordinates, type },
|
|
108
|
-
properties: {},
|
|
109
|
-
type: "Feature"
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function safeLayerId(value) {
|
|
113
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-").slice(0, 80);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export {
|
|
117
|
-
line,
|
|
118
|
-
circle,
|
|
119
|
-
marker,
|
|
120
|
-
polygon,
|
|
121
|
-
compileStaticOverlays
|
|
122
|
-
};
|
package/dist/chunk-NM2JSFUF.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
// src/canonical.ts
|
|
2
|
-
function stableStringify(value) {
|
|
3
|
-
return JSON.stringify(sortJson(value));
|
|
4
|
-
}
|
|
5
|
-
function roundNumber(value) {
|
|
6
|
-
return Number(value.toFixed(6));
|
|
7
|
-
}
|
|
8
|
-
function stripUndefined(value) {
|
|
9
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
13
|
-
}
|
|
14
|
-
function jsonByteLength(value) {
|
|
15
|
-
return new TextEncoder().encode(JSON.stringify(value)).length;
|
|
16
|
-
}
|
|
17
|
-
async function hashStableValue(value) {
|
|
18
|
-
const bytes = new TextEncoder().encode(stableStringify(value));
|
|
19
|
-
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
20
|
-
return base64Url(new Uint8Array(digest));
|
|
21
|
-
}
|
|
22
|
-
function isSafeHttpUrl(value) {
|
|
23
|
-
try {
|
|
24
|
-
const url = new URL(value);
|
|
25
|
-
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && !url.hash;
|
|
26
|
-
} catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function sortJson(value) {
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
return value.map(sortJson);
|
|
33
|
-
}
|
|
34
|
-
if (value && typeof value === "object") {
|
|
35
|
-
return Object.fromEntries(
|
|
36
|
-
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, sortJson(entry)])
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
function base64Url(bytes) {
|
|
42
|
-
let binary = "";
|
|
43
|
-
for (const byte of bytes) {
|
|
44
|
-
binary += String.fromCharCode(byte);
|
|
45
|
-
}
|
|
46
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/scene-contract.ts
|
|
50
|
-
import { z } from "zod";
|
|
51
|
-
var staticSceneSchemaVersion = 1;
|
|
52
|
-
var MAX_OVERLAY_LATITUDE = 85.051129;
|
|
53
|
-
var staticSceneLimits = {
|
|
54
|
-
maxDimension: 2048,
|
|
55
|
-
maxGeoJsonBytes: 96e3,
|
|
56
|
-
maxOverlays: 24,
|
|
57
|
-
maxPathCoordinates: 2e3,
|
|
58
|
-
maxPhysicalPixels: 2048 * 2048 * 4,
|
|
59
|
-
minDimension: 64
|
|
60
|
-
};
|
|
61
|
-
var coordinateSchema = z.tuple([z.number().finite(), z.number().finite()]).refine(([lng, lat]) => lng >= -180 && lng <= 180 && lat >= -90 && lat <= 90, {
|
|
62
|
-
message: "Expected [lng, lat] within world bounds"
|
|
63
|
-
});
|
|
64
|
-
var overlayCoordinateSchema = coordinateSchema.refine(
|
|
65
|
-
([, latitude]) => Math.abs(latitude) <= MAX_OVERLAY_LATITUDE,
|
|
66
|
-
{
|
|
67
|
-
message: `Static overlay latitude must be within \xB1${MAX_OVERLAY_LATITUDE}\xB0`
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
var colorSchema = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, {
|
|
71
|
-
message: "Expected a hex color like #C6A15B"
|
|
72
|
-
});
|
|
73
|
-
var portableIdSchema = z.string().min(1).max(64).regex(/^[a-z][a-z0-9-]{0,63}$/u, {
|
|
74
|
-
message: "Expected lowercase kebab-case beginning with a letter"
|
|
75
|
-
}).refine(
|
|
76
|
-
(name) => !["constructor", "prototype"].includes(name) && !/^(?:AUX|CON|NUL|PRN|COM[1-9]|LPT[1-9])$/i.test(name),
|
|
77
|
-
"Expected a portable identifier that is not a reserved filename or prototype key"
|
|
78
|
-
);
|
|
79
|
-
var concreteThemeSchema = portableIdSchema.refine((value) => value !== "system", {
|
|
80
|
-
message: 'Static maps require a concrete theme; "system" is browser-only'
|
|
81
|
-
});
|
|
82
|
-
var staticMapFormatSchema = z.enum(["png", "jpeg", "webp"]);
|
|
83
|
-
var staticAttributionPositionSchema = z.enum([
|
|
84
|
-
"auto",
|
|
85
|
-
"top-left",
|
|
86
|
-
"top-right",
|
|
87
|
-
"bottom-left",
|
|
88
|
-
"bottom-right"
|
|
89
|
-
]);
|
|
90
|
-
var staticAttributionRequestSchema = z.union([
|
|
91
|
-
z.object({
|
|
92
|
-
mode: z.literal("embedded").optional(),
|
|
93
|
-
position: staticAttributionPositionSchema.optional()
|
|
94
|
-
}).strict(),
|
|
95
|
-
z.object({
|
|
96
|
-
mode: z.literal("external")
|
|
97
|
-
}).strict()
|
|
98
|
-
]);
|
|
99
|
-
var sizeSchema = z.object({
|
|
100
|
-
dpr: z.union([z.literal(1), z.literal(2)]).optional(),
|
|
101
|
-
height: z.number().int().min(staticSceneLimits.minDimension).max(staticSceneLimits.maxDimension),
|
|
102
|
-
width: z.number().int().min(staticSceneLimits.minDimension).max(staticSceneLimits.maxDimension)
|
|
103
|
-
}).refine(
|
|
104
|
-
(size) => {
|
|
105
|
-
const dpr = size.dpr ?? 1;
|
|
106
|
-
return size.width * size.height * dpr * dpr <= staticSceneLimits.maxPhysicalPixels;
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
message: "Static map exceeds the maximum render pixel budget"
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
var centerCameraSchema = z.object({
|
|
113
|
-
bearing: z.number().finite().min(-180).max(180).optional(),
|
|
114
|
-
center: coordinateSchema,
|
|
115
|
-
type: z.literal("center"),
|
|
116
|
-
zoom: z.number().finite().min(0).max(22)
|
|
117
|
-
});
|
|
118
|
-
var boundsCameraSchema = z.object({
|
|
119
|
-
bearing: z.number().finite().min(-180).max(180).optional(),
|
|
120
|
-
bounds: z.tuple([z.number().finite(), z.number().finite(), z.number().finite(), z.number().finite()]).refine(
|
|
121
|
-
([west, south, east, north]) => west >= -180 && west <= 180 && east >= -180 && east <= 180 && south >= -90 && south <= 90 && north >= -90 && north <= 90 && west !== east && south !== north,
|
|
122
|
-
{ message: "Expected bounds as [west, south, east, north]" }
|
|
123
|
-
),
|
|
124
|
-
padding: z.number().int().min(0).max(256).optional(),
|
|
125
|
-
type: z.literal("bounds")
|
|
126
|
-
}).refine((camera) => camera.bounds[3] > camera.bounds[1], {
|
|
127
|
-
message: "Bounds north must be greater than south"
|
|
128
|
-
});
|
|
129
|
-
var staticPaddingSchema = z.object({
|
|
130
|
-
bottom: z.number().int().nonnegative(),
|
|
131
|
-
left: z.number().int().nonnegative(),
|
|
132
|
-
right: z.number().int().nonnegative(),
|
|
133
|
-
top: z.number().int().nonnegative()
|
|
134
|
-
}).strict();
|
|
135
|
-
var autoPaddingInputSchema = z.union([
|
|
136
|
-
z.number().int().nonnegative(),
|
|
137
|
-
z.object({
|
|
138
|
-
bottom: z.number().int().nonnegative().optional(),
|
|
139
|
-
left: z.number().int().nonnegative().optional(),
|
|
140
|
-
right: z.number().int().nonnegative().optional(),
|
|
141
|
-
top: z.number().int().nonnegative().optional()
|
|
142
|
-
}).strict()
|
|
143
|
-
]);
|
|
144
|
-
var autoCameraSchema = z.object({
|
|
145
|
-
bearing: z.number().finite().min(-180).max(180).optional(),
|
|
146
|
-
maxZoom: z.number().finite().min(0).max(22).optional(),
|
|
147
|
-
padding: autoPaddingInputSchema.optional(),
|
|
148
|
-
type: z.literal("auto")
|
|
149
|
-
});
|
|
150
|
-
var lineOverlaySchema = z.object({
|
|
151
|
-
color: colorSchema.default("#C6A15B"),
|
|
152
|
-
coordinates: z.array(overlayCoordinateSchema).min(2).max(staticSceneLimits.maxPathCoordinates),
|
|
153
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
154
|
-
opacity: z.number().finite().min(0).max(1).default(1),
|
|
155
|
-
type: z.literal("line"),
|
|
156
|
-
width: z.number().finite().min(0.5).max(32).default(4)
|
|
157
|
-
});
|
|
158
|
-
var circleOverlaySchema = z.object({
|
|
159
|
-
color: colorSchema.default("#C6A15B"),
|
|
160
|
-
coordinate: overlayCoordinateSchema,
|
|
161
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
162
|
-
opacity: z.number().finite().min(0).max(1).default(1),
|
|
163
|
-
radius: z.number().finite().min(1).max(64).default(6),
|
|
164
|
-
strokeColor: colorSchema.optional(),
|
|
165
|
-
strokeWidth: z.number().finite().min(0).max(16).default(0),
|
|
166
|
-
type: z.literal("circle")
|
|
167
|
-
});
|
|
168
|
-
var markerOverlaySchema = z.object({
|
|
169
|
-
color: colorSchema.default("#C6A15B"),
|
|
170
|
-
coordinate: overlayCoordinateSchema,
|
|
171
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
172
|
-
radius: z.number().finite().min(2).max(64).default(8),
|
|
173
|
-
strokeColor: colorSchema.default("#ffffff"),
|
|
174
|
-
strokeWidth: z.number().finite().min(0).max(16).default(2),
|
|
175
|
-
type: z.literal("marker")
|
|
176
|
-
});
|
|
177
|
-
var polygonRingSchema = z.array(overlayCoordinateSchema).min(4).max(staticSceneLimits.maxPathCoordinates).refine(
|
|
178
|
-
(ring) => {
|
|
179
|
-
const first = ring[0];
|
|
180
|
-
const last = ring[ring.length - 1];
|
|
181
|
-
return Boolean(first && last && first[0] === last[0] && first[1] === last[1]);
|
|
182
|
-
},
|
|
183
|
-
{ message: "Polygon rings must end at their starting coordinate" }
|
|
184
|
-
);
|
|
185
|
-
var polygonOverlaySchema = z.object({
|
|
186
|
-
coordinates: z.array(polygonRingSchema).min(1).max(16),
|
|
187
|
-
fill: colorSchema.default("#C6A15B"),
|
|
188
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
189
|
-
opacity: z.number().finite().min(0).max(1).default(0.28),
|
|
190
|
-
stroke: colorSchema.optional(),
|
|
191
|
-
strokeWidth: z.number().finite().min(0).max(16).default(0),
|
|
192
|
-
type: z.literal("polygon")
|
|
193
|
-
});
|
|
194
|
-
var staticOverlaySchema = z.discriminatedUnion("type", [
|
|
195
|
-
lineOverlaySchema,
|
|
196
|
-
circleOverlaySchema,
|
|
197
|
-
markerOverlaySchema,
|
|
198
|
-
polygonOverlaySchema
|
|
199
|
-
]);
|
|
200
|
-
var staticSceneSchema = z.object({
|
|
201
|
-
attribution: staticAttributionRequestSchema.optional(),
|
|
202
|
-
camera: z.discriminatedUnion("type", [centerCameraSchema, boundsCameraSchema, autoCameraSchema]),
|
|
203
|
-
format: staticMapFormatSchema.optional(),
|
|
204
|
-
map: portableIdSchema,
|
|
205
|
-
overlays: z.array(staticOverlaySchema).max(staticSceneLimits.maxOverlays).default([]),
|
|
206
|
-
size: sizeSchema,
|
|
207
|
-
theme: concreteThemeSchema
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// src/overlay-normalization.ts
|
|
211
|
-
function normalizeStaticOverlay(overlay) {
|
|
212
|
-
const parsed = staticOverlaySchema.parse(overlay);
|
|
213
|
-
const normalized = stripUndefined({ ...parsed });
|
|
214
|
-
if ("coordinate" in normalized) {
|
|
215
|
-
normalized.coordinate = normalizeStaticCoordinate(normalized.coordinate);
|
|
216
|
-
}
|
|
217
|
-
if ("coordinates" in normalized) {
|
|
218
|
-
normalized.coordinates = normalizeStaticCoordinates(normalized.coordinates);
|
|
219
|
-
}
|
|
220
|
-
return normalized;
|
|
221
|
-
}
|
|
222
|
-
function normalizeStaticCoordinate(coordinate) {
|
|
223
|
-
return [roundNumber(coordinate[0]), roundNumber(coordinate[1])];
|
|
224
|
-
}
|
|
225
|
-
function normalizeStaticCoordinates(value) {
|
|
226
|
-
if (!Array.isArray(value)) {
|
|
227
|
-
return value;
|
|
228
|
-
}
|
|
229
|
-
if (value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number") {
|
|
230
|
-
return normalizeStaticCoordinate(value);
|
|
231
|
-
}
|
|
232
|
-
return value.map(normalizeStaticCoordinates);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export {
|
|
236
|
-
stableStringify,
|
|
237
|
-
roundNumber,
|
|
238
|
-
stripUndefined,
|
|
239
|
-
jsonByteLength,
|
|
240
|
-
hashStableValue,
|
|
241
|
-
isSafeHttpUrl,
|
|
242
|
-
staticSceneSchemaVersion,
|
|
243
|
-
MAX_OVERLAY_LATITUDE,
|
|
244
|
-
staticSceneLimits,
|
|
245
|
-
staticAttributionPositionSchema,
|
|
246
|
-
staticAttributionRequestSchema,
|
|
247
|
-
staticPaddingSchema,
|
|
248
|
-
staticOverlaySchema,
|
|
249
|
-
staticSceneSchema,
|
|
250
|
-
normalizeStaticOverlay,
|
|
251
|
-
normalizeStaticCoordinate
|
|
252
|
-
};
|