@tileflow/static 0.1.0-alpha.2 → 0.1.0-alpha.20
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/GENERATED_OUTPUT_LICENSE.md +21 -0
- package/LICENSE +201 -0
- package/NOTICE +9 -0
- package/README.md +56 -1
- package/TRADEMARKS.md +10 -0
- package/dist/chunk-HKYA7ZIU.js +79 -0
- package/dist/chunk-LGEYA6FQ.js +106 -0
- package/dist/chunk-QCR76BUO.js +304 -0
- package/dist/chunk-ROBEGDDY.js +63 -0
- package/dist/chunk-YUG3PBK2.js +198 -0
- package/dist/client.d.ts +58 -0
- package/dist/client.js +25 -0
- package/dist/index.d.ts +6 -248
- package/dist/index.js +43 -375
- package/dist/manifest.d.ts +85 -0
- package/dist/manifest.js +18 -0
- package/dist/overlays.d.ts +14 -0
- package/dist/overlays.js +18 -0
- package/dist/scene-contract-DzsUeJ_V.d.ts +141 -0
- package/dist/scene.d.ts +14 -0
- package/dist/scene.js +16 -0
- package/package.json +32 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,248 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly maxGeoJsonBytes: 96000;
|
|
8
|
-
readonly maxOverlays: 24;
|
|
9
|
-
readonly maxPathCoordinates: 2000;
|
|
10
|
-
readonly maxPhysicalPixels: number;
|
|
11
|
-
readonly minDimension: 64;
|
|
12
|
-
};
|
|
13
|
-
declare const coordinateSchema: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
14
|
-
declare const lineOverlaySchema: z.ZodObject<{
|
|
15
|
-
color: z.ZodDefault<z.ZodString>;
|
|
16
|
-
coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
17
|
-
id: z.ZodOptional<z.ZodString>;
|
|
18
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
19
|
-
type: z.ZodLiteral<"line">;
|
|
20
|
-
width: z.ZodDefault<z.ZodNumber>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
declare const circleOverlaySchema: z.ZodObject<{
|
|
23
|
-
color: z.ZodDefault<z.ZodString>;
|
|
24
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
25
|
-
id: z.ZodOptional<z.ZodString>;
|
|
26
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
27
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
28
|
-
strokeColor: z.ZodOptional<z.ZodString>;
|
|
29
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
30
|
-
type: z.ZodLiteral<"circle">;
|
|
31
|
-
}, z.core.$strip>;
|
|
32
|
-
declare const markerOverlaySchema: z.ZodObject<{
|
|
33
|
-
color: z.ZodDefault<z.ZodString>;
|
|
34
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
35
|
-
id: z.ZodOptional<z.ZodString>;
|
|
36
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
37
|
-
strokeColor: z.ZodDefault<z.ZodString>;
|
|
38
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
39
|
-
type: z.ZodLiteral<"marker">;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
declare const polygonOverlaySchema: z.ZodObject<{
|
|
42
|
-
coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
43
|
-
fill: z.ZodDefault<z.ZodString>;
|
|
44
|
-
id: z.ZodOptional<z.ZodString>;
|
|
45
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
46
|
-
stroke: z.ZodOptional<z.ZodString>;
|
|
47
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
48
|
-
type: z.ZodLiteral<"polygon">;
|
|
49
|
-
}, z.core.$strip>;
|
|
50
|
-
declare const staticOverlaySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
51
|
-
color: z.ZodDefault<z.ZodString>;
|
|
52
|
-
coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
53
|
-
id: z.ZodOptional<z.ZodString>;
|
|
54
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
55
|
-
type: z.ZodLiteral<"line">;
|
|
56
|
-
width: z.ZodDefault<z.ZodNumber>;
|
|
57
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
-
color: z.ZodDefault<z.ZodString>;
|
|
59
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
60
|
-
id: z.ZodOptional<z.ZodString>;
|
|
61
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
62
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
63
|
-
strokeColor: z.ZodOptional<z.ZodString>;
|
|
64
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
65
|
-
type: z.ZodLiteral<"circle">;
|
|
66
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
-
color: z.ZodDefault<z.ZodString>;
|
|
68
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
69
|
-
id: z.ZodOptional<z.ZodString>;
|
|
70
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
71
|
-
strokeColor: z.ZodDefault<z.ZodString>;
|
|
72
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
73
|
-
type: z.ZodLiteral<"marker">;
|
|
74
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
75
|
-
coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
76
|
-
fill: z.ZodDefault<z.ZodString>;
|
|
77
|
-
id: z.ZodOptional<z.ZodString>;
|
|
78
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
79
|
-
stroke: z.ZodOptional<z.ZodString>;
|
|
80
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
81
|
-
type: z.ZodLiteral<"polygon">;
|
|
82
|
-
}, z.core.$strip>], "type">;
|
|
83
|
-
declare const staticSceneSchema: z.ZodObject<{
|
|
84
|
-
camera: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
85
|
-
bearing: z.ZodOptional<z.ZodNumber>;
|
|
86
|
-
center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
87
|
-
type: z.ZodLiteral<"center">;
|
|
88
|
-
zoom: z.ZodNumber;
|
|
89
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
90
|
-
bearing: z.ZodOptional<z.ZodNumber>;
|
|
91
|
-
bounds: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
92
|
-
padding: z.ZodOptional<z.ZodNumber>;
|
|
93
|
-
type: z.ZodLiteral<"bounds">;
|
|
94
|
-
}, z.core.$strip>], "type">;
|
|
95
|
-
map: z.ZodString;
|
|
96
|
-
overlays: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
97
|
-
color: z.ZodDefault<z.ZodString>;
|
|
98
|
-
coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
99
|
-
id: z.ZodOptional<z.ZodString>;
|
|
100
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
101
|
-
type: z.ZodLiteral<"line">;
|
|
102
|
-
width: z.ZodDefault<z.ZodNumber>;
|
|
103
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
104
|
-
color: z.ZodDefault<z.ZodString>;
|
|
105
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
106
|
-
id: z.ZodOptional<z.ZodString>;
|
|
107
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
108
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
109
|
-
strokeColor: z.ZodOptional<z.ZodString>;
|
|
110
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
111
|
-
type: z.ZodLiteral<"circle">;
|
|
112
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
113
|
-
color: z.ZodDefault<z.ZodString>;
|
|
114
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
115
|
-
id: z.ZodOptional<z.ZodString>;
|
|
116
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
117
|
-
strokeColor: z.ZodDefault<z.ZodString>;
|
|
118
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
119
|
-
type: z.ZodLiteral<"marker">;
|
|
120
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
121
|
-
coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
122
|
-
fill: z.ZodDefault<z.ZodString>;
|
|
123
|
-
id: z.ZodOptional<z.ZodString>;
|
|
124
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
125
|
-
stroke: z.ZodOptional<z.ZodString>;
|
|
126
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
127
|
-
type: z.ZodLiteral<"polygon">;
|
|
128
|
-
}, z.core.$strip>], "type">>>;
|
|
129
|
-
size: z.ZodObject<{
|
|
130
|
-
dpr: z.ZodOptional<z.ZodLiteral<1>>;
|
|
131
|
-
height: z.ZodNumber;
|
|
132
|
-
width: z.ZodNumber;
|
|
133
|
-
}, z.core.$strip>;
|
|
134
|
-
}, z.core.$strip>;
|
|
135
|
-
declare const staticRenderManifestSchema: z.ZodObject<{
|
|
136
|
-
mapId: z.ZodString;
|
|
137
|
-
rendererVersion: z.ZodString;
|
|
138
|
-
schemaVersion: z.ZodLiteral<1>;
|
|
139
|
-
scene: z.ZodObject<{
|
|
140
|
-
camera: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
141
|
-
bearing: z.ZodOptional<z.ZodNumber>;
|
|
142
|
-
center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
143
|
-
type: z.ZodLiteral<"center">;
|
|
144
|
-
zoom: z.ZodNumber;
|
|
145
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
-
bearing: z.ZodOptional<z.ZodNumber>;
|
|
147
|
-
bounds: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
148
|
-
padding: z.ZodOptional<z.ZodNumber>;
|
|
149
|
-
type: z.ZodLiteral<"bounds">;
|
|
150
|
-
}, z.core.$strip>], "type">;
|
|
151
|
-
map: z.ZodString;
|
|
152
|
-
overlays: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
153
|
-
color: z.ZodDefault<z.ZodString>;
|
|
154
|
-
coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
155
|
-
id: z.ZodOptional<z.ZodString>;
|
|
156
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
157
|
-
type: z.ZodLiteral<"line">;
|
|
158
|
-
width: z.ZodDefault<z.ZodNumber>;
|
|
159
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
160
|
-
color: z.ZodDefault<z.ZodString>;
|
|
161
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
162
|
-
id: z.ZodOptional<z.ZodString>;
|
|
163
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
164
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
165
|
-
strokeColor: z.ZodOptional<z.ZodString>;
|
|
166
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
167
|
-
type: z.ZodLiteral<"circle">;
|
|
168
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
169
|
-
color: z.ZodDefault<z.ZodString>;
|
|
170
|
-
coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
171
|
-
id: z.ZodOptional<z.ZodString>;
|
|
172
|
-
radius: z.ZodDefault<z.ZodNumber>;
|
|
173
|
-
strokeColor: z.ZodDefault<z.ZodString>;
|
|
174
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
175
|
-
type: z.ZodLiteral<"marker">;
|
|
176
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
177
|
-
coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
178
|
-
fill: z.ZodDefault<z.ZodString>;
|
|
179
|
-
id: z.ZodOptional<z.ZodString>;
|
|
180
|
-
opacity: z.ZodDefault<z.ZodNumber>;
|
|
181
|
-
stroke: z.ZodOptional<z.ZodString>;
|
|
182
|
-
strokeWidth: z.ZodDefault<z.ZodNumber>;
|
|
183
|
-
type: z.ZodLiteral<"polygon">;
|
|
184
|
-
}, z.core.$strip>], "type">>>;
|
|
185
|
-
size: z.ZodObject<{
|
|
186
|
-
dpr: z.ZodOptional<z.ZodLiteral<1>>;
|
|
187
|
-
height: z.ZodNumber;
|
|
188
|
-
width: z.ZodNumber;
|
|
189
|
-
}, z.core.$strip>;
|
|
190
|
-
}, z.core.$strip>;
|
|
191
|
-
styleId: z.ZodOptional<z.ZodString>;
|
|
192
|
-
styleRevision: z.ZodString;
|
|
193
|
-
styleUrl: z.ZodString;
|
|
194
|
-
}, z.core.$strip>;
|
|
195
|
-
type StaticCoordinate = z.infer<typeof coordinateSchema>;
|
|
196
|
-
type StaticSceneInput = z.input<typeof staticSceneSchema>;
|
|
197
|
-
type StaticScene = z.infer<typeof staticSceneSchema>;
|
|
198
|
-
type StaticOverlayInput = z.input<typeof staticOverlaySchema>;
|
|
199
|
-
type StaticOverlay = z.infer<typeof staticOverlaySchema>;
|
|
200
|
-
type StaticRenderManifest = z.infer<typeof staticRenderManifestSchema>;
|
|
201
|
-
type StaticMapResult = {
|
|
202
|
-
cached: boolean;
|
|
203
|
-
hash: string;
|
|
204
|
-
imageUrl: string;
|
|
205
|
-
status: 'ready';
|
|
206
|
-
};
|
|
207
|
-
type StaticMapCreateOptions = {
|
|
208
|
-
apiKey?: string;
|
|
209
|
-
apiUrl?: string;
|
|
210
|
-
fetch?: typeof fetch;
|
|
211
|
-
};
|
|
212
|
-
declare function line(input: Omit<z.input<typeof lineOverlaySchema>, 'type'>): StaticOverlay;
|
|
213
|
-
declare function circle(input: Omit<z.input<typeof circleOverlaySchema>, 'type'>): StaticOverlay;
|
|
214
|
-
declare function marker(input: Omit<z.input<typeof markerOverlaySchema>, 'type'>): StaticOverlay;
|
|
215
|
-
declare function polygon(input: Omit<z.input<typeof polygonOverlaySchema>, 'type'>): StaticOverlay;
|
|
216
|
-
declare function validateStaticScene(input: unknown): {
|
|
217
|
-
ok: true;
|
|
218
|
-
scene: StaticScene;
|
|
219
|
-
} | {
|
|
220
|
-
error: string;
|
|
221
|
-
ok: false;
|
|
222
|
-
};
|
|
223
|
-
declare function validateStaticRenderManifest(input: unknown): {
|
|
224
|
-
manifest: StaticRenderManifest;
|
|
225
|
-
ok: true;
|
|
226
|
-
} | {
|
|
227
|
-
error: string;
|
|
228
|
-
ok: false;
|
|
229
|
-
};
|
|
230
|
-
declare function normalizeStaticScene(scene: StaticSceneInput): StaticScene;
|
|
231
|
-
declare function createRenderManifest(input: {
|
|
232
|
-
mapId: string;
|
|
233
|
-
rendererVersion: string;
|
|
234
|
-
scene: StaticSceneInput;
|
|
235
|
-
styleId?: string;
|
|
236
|
-
styleRevision: string;
|
|
237
|
-
styleUrl: string;
|
|
238
|
-
}): StaticRenderManifest;
|
|
239
|
-
declare function hashRenderManifest(manifest: StaticRenderManifest): Promise<string>;
|
|
240
|
-
declare function compileStaticOverlays(overlays: StaticOverlay[]): {
|
|
241
|
-
layers: Record<string, unknown>[];
|
|
242
|
-
sources: Record<string, Record<string, unknown>>;
|
|
243
|
-
};
|
|
244
|
-
declare function createStaticMap(scene: StaticSceneInput, options?: StaticMapCreateOptions): Promise<StaticMapResult>;
|
|
245
|
-
declare function precacheStaticMap(scene: StaticSceneInput, options?: StaticMapCreateOptions): Promise<StaticMapResult>;
|
|
246
|
-
declare function stableStringify(value: unknown): string;
|
|
247
|
-
|
|
248
|
-
export { type StaticCoordinate, type StaticMapCreateOptions, type StaticMapResult, type StaticOverlay, type StaticOverlayInput, type StaticRenderManifest, type StaticScene, type StaticSceneInput, circle, compileStaticOverlays, createRenderManifest, createStaticMap, hashRenderManifest, line, marker, normalizeStaticScene, polygon, precacheStaticMap, stableStringify, staticOverlaySchema, staticRenderManifestSchema, staticRendererSchemaVersion, staticSceneLimits, staticSceneSchema, staticSceneSchemaVersion, validateStaticRenderManifest, validateStaticScene };
|
|
1
|
+
export { normalizeStaticScene, validateStaticScene } from './scene.js';
|
|
2
|
+
export { circle, compileStaticOverlays, line, marker, polygon } from './overlays.js';
|
|
3
|
+
export { StaticRenderManifest, createRenderManifest, hashRenderManifest, hashStaticSceneRequest, staticRenderManifestSchema, staticRendererSchemaVersion, validateStaticRenderManifest } from './manifest.js';
|
|
4
|
+
export { PreparedStaticMapRequest, StaticMapCreateOptions, StaticMapEndpointRequestOptions, StaticMapResult, createStaticMap, createStaticMapIdempotencyKey, precacheStaticMap, prepareStaticMapRequest, requestStaticMapUntilReady, stableStringify, staticMapProcessingResultSchema, staticMapReadyResultSchema, validateStaticMapIdempotencyKey } from './client.js';
|
|
5
|
+
export { S as StaticCoordinate, a as StaticOverlay, b as StaticOverlayInput, c as StaticScene, d as StaticSceneInput, s as staticOverlaySchema, e as staticSceneLimits, f as staticSceneSchema, g as staticSceneSchemaVersion } from './scene-contract-DzsUeJ_V.js';
|
|
6
|
+
import 'zod';
|
package/dist/index.js
CHANGED
|
@@ -1,396 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
bounds: z.tuple([z.number().finite(), z.number().finite(), z.number().finite(), z.number().finite()]).refine(
|
|
38
|
-
([west, south, east, north]) => west >= -180 && west <= 180 && east >= -180 && east <= 180 && south >= -90 && south <= 90 && north >= -90 && north <= 90 && west !== east && south !== north,
|
|
39
|
-
{ message: "Expected bounds as [west, south, east, north]" }
|
|
40
|
-
),
|
|
41
|
-
padding: z.number().int().min(0).max(256).optional(),
|
|
42
|
-
type: z.literal("bounds")
|
|
43
|
-
}).refine((camera) => camera.bounds[3] > camera.bounds[1], {
|
|
44
|
-
message: "Bounds north must be greater than south"
|
|
45
|
-
});
|
|
46
|
-
var lineOverlaySchema = z.object({
|
|
47
|
-
color: colorSchema.default("#C6A15B"),
|
|
48
|
-
coordinates: z.array(coordinateSchema).min(2).max(staticSceneLimits.maxPathCoordinates),
|
|
49
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
50
|
-
opacity: z.number().finite().min(0).max(1).default(1),
|
|
51
|
-
type: z.literal("line"),
|
|
52
|
-
width: z.number().finite().min(0.5).max(32).default(4)
|
|
53
|
-
});
|
|
54
|
-
var circleOverlaySchema = z.object({
|
|
55
|
-
color: colorSchema.default("#C6A15B"),
|
|
56
|
-
coordinate: coordinateSchema,
|
|
57
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
58
|
-
opacity: z.number().finite().min(0).max(1).default(1),
|
|
59
|
-
radius: z.number().finite().min(1).max(64).default(6),
|
|
60
|
-
strokeColor: colorSchema.optional(),
|
|
61
|
-
strokeWidth: z.number().finite().min(0).max(16).default(0),
|
|
62
|
-
type: z.literal("circle")
|
|
63
|
-
});
|
|
64
|
-
var markerOverlaySchema = z.object({
|
|
65
|
-
color: colorSchema.default("#C6A15B"),
|
|
66
|
-
coordinate: coordinateSchema,
|
|
67
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
68
|
-
radius: z.number().finite().min(2).max(64).default(8),
|
|
69
|
-
strokeColor: colorSchema.default("#ffffff"),
|
|
70
|
-
strokeWidth: z.number().finite().min(0).max(16).default(2),
|
|
71
|
-
type: z.literal("marker")
|
|
72
|
-
});
|
|
73
|
-
var polygonOverlaySchema = z.object({
|
|
74
|
-
coordinates: z.array(z.array(coordinateSchema).min(4).max(staticSceneLimits.maxPathCoordinates)).min(1).max(16),
|
|
75
|
-
fill: colorSchema.default("#C6A15B"),
|
|
76
|
-
id: z.string().trim().min(1).max(64).optional(),
|
|
77
|
-
opacity: z.number().finite().min(0).max(1).default(0.28),
|
|
78
|
-
stroke: colorSchema.optional(),
|
|
79
|
-
strokeWidth: z.number().finite().min(0).max(16).default(0),
|
|
80
|
-
type: z.literal("polygon")
|
|
81
|
-
});
|
|
82
|
-
var staticOverlaySchema = z.discriminatedUnion("type", [
|
|
83
|
-
lineOverlaySchema,
|
|
84
|
-
circleOverlaySchema,
|
|
85
|
-
markerOverlaySchema,
|
|
86
|
-
polygonOverlaySchema
|
|
87
|
-
]);
|
|
88
|
-
var staticSceneSchema = z.object({
|
|
89
|
-
camera: z.discriminatedUnion("type", [centerCameraSchema, boundsCameraSchema]),
|
|
90
|
-
map: z.string().trim().min(1).max(128),
|
|
91
|
-
overlays: z.array(staticOverlaySchema).max(staticSceneLimits.maxOverlays).default([]),
|
|
92
|
-
size: sizeSchema
|
|
93
|
-
});
|
|
94
|
-
var staticRenderManifestSchema = z.object({
|
|
95
|
-
mapId: z.string().trim().min(1).max(128),
|
|
96
|
-
rendererVersion: z.string().trim().min(1).max(64),
|
|
97
|
-
schemaVersion: z.literal(staticRendererSchemaVersion),
|
|
98
|
-
scene: staticSceneSchema,
|
|
99
|
-
styleId: z.string().trim().min(1).max(128).optional(),
|
|
100
|
-
styleRevision: z.string().trim().min(1).max(128),
|
|
101
|
-
styleUrl: z.string().trim().url().max(512).refine((value) => /^https?:\/\//.test(value), {
|
|
102
|
-
message: "Expected an http(s) style URL"
|
|
103
|
-
})
|
|
104
|
-
});
|
|
105
|
-
function line(input) {
|
|
106
|
-
return normalizeOverlay({ ...input, type: "line" });
|
|
107
|
-
}
|
|
108
|
-
function circle(input) {
|
|
109
|
-
return normalizeOverlay({ ...input, type: "circle" });
|
|
110
|
-
}
|
|
111
|
-
function marker(input) {
|
|
112
|
-
return normalizeOverlay({ ...input, type: "marker" });
|
|
113
|
-
}
|
|
114
|
-
function polygon(input) {
|
|
115
|
-
return normalizeOverlay({ ...input, type: "polygon" });
|
|
116
|
-
}
|
|
117
|
-
function validateStaticScene(input) {
|
|
118
|
-
const parsed = staticSceneSchema.safeParse(input);
|
|
119
|
-
if (!parsed.success) {
|
|
120
|
-
return {
|
|
121
|
-
error: parsed.error.issues.map((issue) => `${issue.path.join(".") || "scene"}: ${issue.message}`).join("; "),
|
|
122
|
-
ok: false
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (jsonByteLength(parsed.data.overlays) > staticSceneLimits.maxGeoJsonBytes) {
|
|
126
|
-
return {
|
|
127
|
-
error: `overlays exceed ${staticSceneLimits.maxGeoJsonBytes} bytes`,
|
|
128
|
-
ok: false
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
return { ok: true, scene: normalizeStaticScene(parsed.data) };
|
|
132
|
-
}
|
|
133
|
-
function validateStaticRenderManifest(input) {
|
|
134
|
-
const parsed = staticRenderManifestSchema.safeParse(input);
|
|
135
|
-
if (!parsed.success) {
|
|
136
|
-
return {
|
|
137
|
-
error: parsed.error.issues.map((issue) => `${issue.path.join(".") || "manifest"}: ${issue.message}`).join("; "),
|
|
138
|
-
ok: false
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
const sceneValidation = validateStaticScene(parsed.data.scene);
|
|
142
|
-
if (!sceneValidation.ok) {
|
|
143
|
-
return sceneValidation;
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
manifest: {
|
|
147
|
-
...parsed.data,
|
|
148
|
-
scene: sceneValidation.scene
|
|
149
|
-
},
|
|
150
|
-
ok: true
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function normalizeStaticScene(scene) {
|
|
154
|
-
const parsed = staticSceneSchema.parse(scene);
|
|
155
|
-
return stripUndefined({
|
|
156
|
-
camera: parsed.camera.type === "center" ? {
|
|
157
|
-
bearing: roundNumber(parsed.camera.bearing ?? 0),
|
|
158
|
-
center: normalizeCoordinate(parsed.camera.center),
|
|
159
|
-
type: "center",
|
|
160
|
-
zoom: roundNumber(parsed.camera.zoom)
|
|
161
|
-
} : {
|
|
162
|
-
bearing: roundNumber(parsed.camera.bearing ?? 0),
|
|
163
|
-
bounds: parsed.camera.bounds.map(roundNumber),
|
|
164
|
-
padding: parsed.camera.padding ?? 32,
|
|
165
|
-
type: "bounds"
|
|
166
|
-
},
|
|
167
|
-
map: parsed.map,
|
|
168
|
-
overlays: parsed.overlays.map(
|
|
169
|
-
(overlay, index) => normalizeOverlay({
|
|
170
|
-
...overlay,
|
|
171
|
-
id: overlay.id ?? `overlay-${index + 1}`
|
|
172
|
-
})
|
|
173
|
-
),
|
|
174
|
-
size: {
|
|
175
|
-
dpr: parsed.size.dpr ?? 1,
|
|
176
|
-
height: parsed.size.height,
|
|
177
|
-
width: parsed.size.width
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
function createRenderManifest(input) {
|
|
182
|
-
return staticRenderManifestSchema.parse(
|
|
183
|
-
stripUndefined({
|
|
184
|
-
mapId: input.mapId,
|
|
185
|
-
rendererVersion: input.rendererVersion,
|
|
186
|
-
schemaVersion: staticRendererSchemaVersion,
|
|
187
|
-
scene: normalizeStaticScene({
|
|
188
|
-
...input.scene,
|
|
189
|
-
map: input.mapId
|
|
190
|
-
}),
|
|
191
|
-
styleId: input.styleId,
|
|
192
|
-
styleRevision: input.styleRevision,
|
|
193
|
-
styleUrl: input.styleUrl
|
|
194
|
-
})
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
async function hashRenderManifest(manifest) {
|
|
198
|
-
const normalized = staticRenderManifestSchema.parse({
|
|
199
|
-
...manifest,
|
|
200
|
-
scene: normalizeStaticScene(manifest.scene)
|
|
201
|
-
});
|
|
202
|
-
const bytes = new TextEncoder().encode(stableStringify(normalized));
|
|
203
|
-
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
204
|
-
return base64Url(new Uint8Array(digest));
|
|
205
|
-
}
|
|
206
|
-
function compileStaticOverlays(overlays) {
|
|
207
|
-
const sources = {};
|
|
208
|
-
const layers = [];
|
|
209
|
-
for (const [index, overlay] of overlays.entries()) {
|
|
210
|
-
const id = safeLayerId(`overlay-${index + 1}-${overlay.id ?? overlay.type}`);
|
|
211
|
-
const sourceId = `${id}-source`;
|
|
212
|
-
if (overlay.type === "line") {
|
|
213
|
-
sources[sourceId] = {
|
|
214
|
-
data: feature("LineString", overlay.coordinates),
|
|
215
|
-
type: "geojson"
|
|
216
|
-
};
|
|
217
|
-
layers.push({
|
|
218
|
-
id,
|
|
219
|
-
layout: { "line-cap": "round", "line-join": "round" },
|
|
220
|
-
paint: {
|
|
221
|
-
"line-color": overlay.color,
|
|
222
|
-
"line-opacity": overlay.opacity,
|
|
223
|
-
"line-width": overlay.width
|
|
224
|
-
},
|
|
225
|
-
source: sourceId,
|
|
226
|
-
type: "line"
|
|
227
|
-
});
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
if (overlay.type === "polygon") {
|
|
231
|
-
sources[sourceId] = {
|
|
232
|
-
data: feature("Polygon", overlay.coordinates),
|
|
233
|
-
type: "geojson"
|
|
234
|
-
};
|
|
235
|
-
layers.push({
|
|
236
|
-
id,
|
|
237
|
-
paint: {
|
|
238
|
-
"fill-color": overlay.fill,
|
|
239
|
-
"fill-opacity": overlay.opacity
|
|
240
|
-
},
|
|
241
|
-
source: sourceId,
|
|
242
|
-
type: "fill"
|
|
243
|
-
});
|
|
244
|
-
if (overlay.stroke && overlay.strokeWidth > 0) {
|
|
245
|
-
layers.push({
|
|
246
|
-
id: `${id}-stroke`,
|
|
247
|
-
layout: { "line-cap": "round", "line-join": "round" },
|
|
248
|
-
paint: {
|
|
249
|
-
"line-color": overlay.stroke,
|
|
250
|
-
"line-width": overlay.strokeWidth
|
|
251
|
-
},
|
|
252
|
-
source: sourceId,
|
|
253
|
-
type: "line"
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
sources[sourceId] = {
|
|
259
|
-
data: feature("Point", overlay.coordinate),
|
|
260
|
-
type: "geojson"
|
|
261
|
-
};
|
|
262
|
-
layers.push({
|
|
263
|
-
id,
|
|
264
|
-
paint: {
|
|
265
|
-
"circle-color": overlay.color,
|
|
266
|
-
"circle-opacity": overlay.type === "circle" ? overlay.opacity : 1,
|
|
267
|
-
"circle-radius": overlay.radius,
|
|
268
|
-
"circle-stroke-color": overlay.strokeColor ?? overlay.color,
|
|
269
|
-
"circle-stroke-width": overlay.strokeWidth
|
|
270
|
-
},
|
|
271
|
-
source: sourceId,
|
|
272
|
-
type: "circle"
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return { layers, sources };
|
|
276
|
-
}
|
|
277
|
-
async function createStaticMap(scene, options = {}) {
|
|
278
|
-
return requestStaticMap(scene, options, "/v1/static/maps");
|
|
279
|
-
}
|
|
280
|
-
async function precacheStaticMap(scene, options = {}) {
|
|
281
|
-
return requestStaticMap(scene, options, "/v1/static/maps/precache");
|
|
282
|
-
}
|
|
283
|
-
async function requestStaticMap(scene, options, path) {
|
|
284
|
-
const validation = validateStaticScene(scene);
|
|
285
|
-
if (!validation.ok) {
|
|
286
|
-
throw new Error(`Invalid Tileflow static scene: ${validation.error}`);
|
|
287
|
-
}
|
|
288
|
-
const fetcher = options.fetch ?? fetch;
|
|
289
|
-
const apiUrl = normalizeUrl(options.apiUrl ?? "https://api.tileflow.dev");
|
|
290
|
-
const headers = {
|
|
291
|
-
"Content-Type": "application/json"
|
|
292
|
-
};
|
|
293
|
-
if (options.apiKey) {
|
|
294
|
-
headers.Authorization = `Bearer ${options.apiKey}`;
|
|
295
|
-
}
|
|
296
|
-
const response = await fetcher(`${apiUrl}${path}`, {
|
|
297
|
-
body: JSON.stringify(validation.scene),
|
|
298
|
-
headers,
|
|
299
|
-
method: "POST"
|
|
300
|
-
});
|
|
301
|
-
if (!response.ok) {
|
|
302
|
-
const error = await response.text();
|
|
303
|
-
throw new Error(`Tileflow static map failed: ${response.status} ${error}`);
|
|
304
|
-
}
|
|
305
|
-
return await response.json();
|
|
306
|
-
}
|
|
307
|
-
function stableStringify(value) {
|
|
308
|
-
return JSON.stringify(sortJson(value));
|
|
309
|
-
}
|
|
310
|
-
function normalizeOverlay(overlay) {
|
|
311
|
-
const parsed = staticOverlaySchema.parse(overlay);
|
|
312
|
-
const normalized = stripUndefined({ ...parsed });
|
|
313
|
-
if ("coordinate" in normalized) {
|
|
314
|
-
normalized.coordinate = normalizeCoordinate(normalized.coordinate);
|
|
315
|
-
}
|
|
316
|
-
if ("coordinates" in normalized) {
|
|
317
|
-
normalized.coordinates = normalizeCoordinates(normalized.coordinates);
|
|
318
|
-
}
|
|
319
|
-
return normalized;
|
|
320
|
-
}
|
|
321
|
-
function normalizeCoordinates(value) {
|
|
322
|
-
if (!Array.isArray(value)) {
|
|
323
|
-
return value;
|
|
324
|
-
}
|
|
325
|
-
if (value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number") {
|
|
326
|
-
return normalizeCoordinate(value);
|
|
327
|
-
}
|
|
328
|
-
return value.map(normalizeCoordinates);
|
|
329
|
-
}
|
|
330
|
-
function normalizeCoordinate(coordinate) {
|
|
331
|
-
return [roundNumber(coordinate[0]), roundNumber(coordinate[1])];
|
|
332
|
-
}
|
|
333
|
-
function roundNumber(value) {
|
|
334
|
-
return Number(value.toFixed(6));
|
|
335
|
-
}
|
|
336
|
-
function stripUndefined(value) {
|
|
337
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
338
|
-
return value;
|
|
339
|
-
}
|
|
340
|
-
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
341
|
-
}
|
|
342
|
-
function sortJson(value) {
|
|
343
|
-
if (Array.isArray(value)) {
|
|
344
|
-
return value.map(sortJson);
|
|
345
|
-
}
|
|
346
|
-
if (value && typeof value === "object") {
|
|
347
|
-
return Object.fromEntries(
|
|
348
|
-
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, sortJson(entry)])
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
return value;
|
|
352
|
-
}
|
|
353
|
-
function feature(type, coordinates) {
|
|
354
|
-
return {
|
|
355
|
-
geometry: { coordinates, type },
|
|
356
|
-
properties: {},
|
|
357
|
-
type: "Feature"
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
function safeLayerId(value) {
|
|
361
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-").slice(0, 80);
|
|
362
|
-
}
|
|
363
|
-
function jsonByteLength(value) {
|
|
364
|
-
return new TextEncoder().encode(JSON.stringify(value)).length;
|
|
365
|
-
}
|
|
366
|
-
function base64Url(bytes) {
|
|
367
|
-
let binary = "";
|
|
368
|
-
for (const byte of bytes) {
|
|
369
|
-
binary += String.fromCharCode(byte);
|
|
370
|
-
}
|
|
371
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
372
|
-
}
|
|
373
|
-
function normalizeUrl(value) {
|
|
374
|
-
return value.replace(/\/+$/, "");
|
|
375
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
createStaticMap,
|
|
3
|
+
createStaticMapIdempotencyKey,
|
|
4
|
+
precacheStaticMap,
|
|
5
|
+
prepareStaticMapRequest,
|
|
6
|
+
requestStaticMapUntilReady,
|
|
7
|
+
staticMapProcessingResultSchema,
|
|
8
|
+
staticMapReadyResultSchema,
|
|
9
|
+
validateStaticMapIdempotencyKey
|
|
10
|
+
} from "./chunk-QCR76BUO.js";
|
|
11
|
+
import {
|
|
12
|
+
createRenderManifest,
|
|
13
|
+
hashRenderManifest,
|
|
14
|
+
hashStaticSceneRequest,
|
|
15
|
+
staticRenderManifestSchema,
|
|
16
|
+
staticRendererSchemaVersion,
|
|
17
|
+
validateStaticRenderManifest
|
|
18
|
+
} from "./chunk-HKYA7ZIU.js";
|
|
19
|
+
import {
|
|
20
|
+
circle,
|
|
21
|
+
compileStaticOverlays,
|
|
22
|
+
line,
|
|
23
|
+
marker,
|
|
24
|
+
polygon
|
|
25
|
+
} from "./chunk-LGEYA6FQ.js";
|
|
26
|
+
import {
|
|
27
|
+
normalizeStaticScene,
|
|
28
|
+
validateStaticScene
|
|
29
|
+
} from "./chunk-ROBEGDDY.js";
|
|
30
|
+
import {
|
|
31
|
+
stableStringify,
|
|
32
|
+
staticOverlaySchema,
|
|
33
|
+
staticSceneLimits,
|
|
34
|
+
staticSceneSchema,
|
|
35
|
+
staticSceneSchemaVersion
|
|
36
|
+
} from "./chunk-YUG3PBK2.js";
|
|
376
37
|
export {
|
|
377
38
|
circle,
|
|
378
39
|
compileStaticOverlays,
|
|
379
40
|
createRenderManifest,
|
|
380
41
|
createStaticMap,
|
|
42
|
+
createStaticMapIdempotencyKey,
|
|
381
43
|
hashRenderManifest,
|
|
44
|
+
hashStaticSceneRequest,
|
|
382
45
|
line,
|
|
383
46
|
marker,
|
|
384
47
|
normalizeStaticScene,
|
|
385
48
|
polygon,
|
|
386
49
|
precacheStaticMap,
|
|
50
|
+
prepareStaticMapRequest,
|
|
51
|
+
requestStaticMapUntilReady,
|
|
387
52
|
stableStringify,
|
|
53
|
+
staticMapProcessingResultSchema,
|
|
54
|
+
staticMapReadyResultSchema,
|
|
388
55
|
staticOverlaySchema,
|
|
389
56
|
staticRenderManifestSchema,
|
|
390
57
|
staticRendererSchemaVersion,
|
|
391
58
|
staticSceneLimits,
|
|
392
59
|
staticSceneSchema,
|
|
393
60
|
staticSceneSchemaVersion,
|
|
61
|
+
validateStaticMapIdempotencyKey,
|
|
394
62
|
validateStaticRenderManifest,
|
|
395
63
|
validateStaticScene
|
|
396
64
|
};
|