@tileflow/static 0.1.0-alpha.20 → 0.1.0-alpha.22

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.
@@ -1,12 +1,14 @@
1
1
  import { z } from 'zod';
2
- import { h as circleOverlaySchema, a as StaticOverlay, l as lineOverlaySchema, m as markerOverlaySchema, p as polygonOverlaySchema } from './scene-contract-DzsUeJ_V.js';
3
- export { b as StaticOverlayInput, s as staticOverlaySchema } from './scene-contract-DzsUeJ_V.js';
2
+ import { o as circleOverlaySchema, e as StaticOverlay, p as lineOverlaySchema, q as markerOverlaySchema, r as polygonOverlaySchema } from './scene-contract-OMIOisSB.js';
3
+ export { f as StaticOverlayInput, k as staticOverlaySchema } from './scene-contract-OMIOisSB.js';
4
4
 
5
5
  declare function line(input: Omit<z.input<typeof lineOverlaySchema>, 'type'>): StaticOverlay;
6
6
  declare function circle(input: Omit<z.input<typeof circleOverlaySchema>, 'type'>): StaticOverlay;
7
7
  declare function marker(input: Omit<z.input<typeof markerOverlaySchema>, 'type'>): StaticOverlay;
8
8
  declare function polygon(input: Omit<z.input<typeof polygonOverlaySchema>, 'type'>): StaticOverlay;
9
- declare function compileStaticOverlays(overlays: StaticOverlay[]): {
9
+ declare function compileStaticOverlays(overlays: StaticOverlay[], options?: {
10
+ longitudeOffsets?: readonly number[];
11
+ }): {
10
12
  layers: Record<string, unknown>[];
11
13
  sources: Record<string, Record<string, unknown>>;
12
14
  };
package/dist/overlays.js CHANGED
@@ -4,10 +4,10 @@ import {
4
4
  line,
5
5
  marker,
6
6
  polygon
7
- } from "./chunk-LGEYA6FQ.js";
7
+ } from "./chunk-EPOYQNNT.js";
8
8
  import {
9
9
  staticOverlaySchema
10
- } from "./chunk-YUG3PBK2.js";
10
+ } from "./chunk-NM2JSFUF.js";
11
11
  export {
12
12
  circle,
13
13
  compileStaticOverlays,
@@ -1,8 +1,9 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  declare const staticSceneSchemaVersion = 1;
4
+ declare const MAX_OVERLAY_LATITUDE = 85.051129;
4
5
  declare const staticSceneLimits: {
5
- readonly maxDimension: 1280;
6
+ readonly maxDimension: 2048;
6
7
  readonly maxGeoJsonBytes: 96000;
7
8
  readonly maxOverlays: 24;
8
9
  readonly maxPathCoordinates: 2000;
@@ -10,6 +11,36 @@ declare const staticSceneLimits: {
10
11
  readonly minDimension: 64;
11
12
  };
12
13
  declare const coordinateSchema: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
14
+ declare const staticMapFormatSchema: z.ZodEnum<{
15
+ png: "png";
16
+ jpeg: "jpeg";
17
+ webp: "webp";
18
+ }>;
19
+ declare const staticAttributionPositionSchema: z.ZodEnum<{
20
+ auto: "auto";
21
+ "top-left": "top-left";
22
+ "top-right": "top-right";
23
+ "bottom-left": "bottom-left";
24
+ "bottom-right": "bottom-right";
25
+ }>;
26
+ declare const staticAttributionRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
27
+ mode: z.ZodOptional<z.ZodLiteral<"embedded">>;
28
+ position: z.ZodOptional<z.ZodEnum<{
29
+ auto: "auto";
30
+ "top-left": "top-left";
31
+ "top-right": "top-right";
32
+ "bottom-left": "bottom-left";
33
+ "bottom-right": "bottom-right";
34
+ }>>;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ mode: z.ZodLiteral<"external">;
37
+ }, z.core.$strict>]>;
38
+ declare const staticPaddingSchema: z.ZodObject<{
39
+ bottom: z.ZodNumber;
40
+ left: z.ZodNumber;
41
+ right: z.ZodNumber;
42
+ top: z.ZodNumber;
43
+ }, z.core.$strict>;
13
44
  declare const lineOverlaySchema: z.ZodObject<{
14
45
  color: z.ZodDefault<z.ZodString>;
15
46
  coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
@@ -80,6 +111,18 @@ declare const staticOverlaySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
80
111
  type: z.ZodLiteral<"polygon">;
81
112
  }, z.core.$strip>], "type">;
82
113
  declare const staticSceneSchema: z.ZodObject<{
114
+ attribution: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
115
+ mode: z.ZodOptional<z.ZodLiteral<"embedded">>;
116
+ position: z.ZodOptional<z.ZodEnum<{
117
+ auto: "auto";
118
+ "top-left": "top-left";
119
+ "top-right": "top-right";
120
+ "bottom-left": "bottom-left";
121
+ "bottom-right": "bottom-right";
122
+ }>>;
123
+ }, z.core.$strict>, z.ZodObject<{
124
+ mode: z.ZodLiteral<"external">;
125
+ }, z.core.$strict>]>>;
83
126
  camera: z.ZodDiscriminatedUnion<[z.ZodObject<{
84
127
  bearing: z.ZodOptional<z.ZodNumber>;
85
128
  center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
@@ -90,7 +133,22 @@ declare const staticSceneSchema: z.ZodObject<{
90
133
  bounds: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
91
134
  padding: z.ZodOptional<z.ZodNumber>;
92
135
  type: z.ZodLiteral<"bounds">;
136
+ }, z.core.$strip>, z.ZodObject<{
137
+ bearing: z.ZodOptional<z.ZodNumber>;
138
+ maxZoom: z.ZodOptional<z.ZodNumber>;
139
+ padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
140
+ bottom: z.ZodOptional<z.ZodNumber>;
141
+ left: z.ZodOptional<z.ZodNumber>;
142
+ right: z.ZodOptional<z.ZodNumber>;
143
+ top: z.ZodOptional<z.ZodNumber>;
144
+ }, z.core.$strict>]>>;
145
+ type: z.ZodLiteral<"auto">;
93
146
  }, z.core.$strip>], "type">;
147
+ format: z.ZodOptional<z.ZodEnum<{
148
+ png: "png";
149
+ jpeg: "jpeg";
150
+ webp: "webp";
151
+ }>>;
94
152
  map: z.ZodString;
95
153
  overlays: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
96
154
  color: z.ZodDefault<z.ZodString>;
@@ -126,16 +184,21 @@ declare const staticSceneSchema: z.ZodObject<{
126
184
  type: z.ZodLiteral<"polygon">;
127
185
  }, z.core.$strip>], "type">>>;
128
186
  size: z.ZodObject<{
129
- dpr: z.ZodOptional<z.ZodLiteral<1>>;
187
+ dpr: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>>;
130
188
  height: z.ZodNumber;
131
189
  width: z.ZodNumber;
132
190
  }, z.core.$strip>;
133
191
  theme: z.ZodString;
134
192
  }, z.core.$strip>;
135
193
  type StaticCoordinate = z.infer<typeof coordinateSchema>;
194
+ type StaticAttributionMode = 'embedded' | 'external';
195
+ type StaticAttributionPosition = z.infer<typeof staticAttributionPositionSchema>;
196
+ type StaticAttributionRequest = z.infer<typeof staticAttributionRequestSchema>;
197
+ type StaticMapFormat = z.infer<typeof staticMapFormatSchema>;
198
+ type StaticPadding = z.infer<typeof staticPaddingSchema>;
136
199
  type StaticSceneInput = z.input<typeof staticSceneSchema>;
137
200
  type StaticScene = z.infer<typeof staticSceneSchema>;
138
201
  type StaticOverlayInput = z.input<typeof staticOverlaySchema>;
139
202
  type StaticOverlay = z.infer<typeof staticOverlaySchema>;
140
203
 
141
- export { type StaticCoordinate as S, type StaticOverlay as a, type StaticOverlayInput as b, type StaticScene as c, type StaticSceneInput as d, staticSceneLimits as e, staticSceneSchema as f, staticSceneSchemaVersion as g, circleOverlaySchema as h, lineOverlaySchema as l, markerOverlaySchema as m, polygonOverlaySchema as p, staticOverlaySchema as s };
204
+ export { MAX_OVERLAY_LATITUDE as M, type StaticAttributionMode as S, type StaticAttributionPosition as a, type StaticAttributionRequest as b, type StaticCoordinate as c, type StaticMapFormat as d, type StaticOverlay as e, type StaticOverlayInput as f, type StaticPadding as g, type StaticScene as h, type StaticSceneInput as i, staticAttributionRequestSchema as j, staticOverlaySchema as k, staticSceneLimits as l, staticSceneSchema as m, staticSceneSchemaVersion as n, circleOverlaySchema as o, lineOverlaySchema as p, markerOverlaySchema as q, polygonOverlaySchema as r, staticAttributionPositionSchema as s };
package/dist/scene.d.ts CHANGED
@@ -1,6 +1,201 @@
1
- import { d as StaticSceneInput, c as StaticScene } from './scene-contract-DzsUeJ_V.js';
2
- export { S as StaticCoordinate, e as staticSceneLimits, f as staticSceneSchema, g as staticSceneSchemaVersion } from './scene-contract-DzsUeJ_V.js';
3
- import 'zod';
1
+ import { z } from 'zod';
2
+ import { i as StaticSceneInput, h as StaticScene } from './scene-contract-OMIOisSB.js';
3
+ export { M as MAX_OVERLAY_LATITUDE, S as StaticAttributionMode, a as StaticAttributionPosition, b as StaticAttributionRequest, c as StaticCoordinate, d as StaticMapFormat, g as StaticPadding, s as staticAttributionPositionSchema, j as staticAttributionRequestSchema, l as staticSceneLimits, m as staticSceneSchema, n as staticSceneSchemaVersion } from './scene-contract-OMIOisSB.js';
4
+
5
+ declare const autoFitDetailsSchema: z.ZodObject<{
6
+ overlay: z.ZodOptional<z.ZodObject<{
7
+ id: z.ZodString;
8
+ index: z.ZodNumber;
9
+ type: z.ZodEnum<{
10
+ line: "line";
11
+ circle: "circle";
12
+ marker: "marker";
13
+ polygon: "polygon";
14
+ }>;
15
+ }, z.core.$strict>>;
16
+ padding: z.ZodOptional<z.ZodObject<{
17
+ bottom: z.ZodNumber;
18
+ left: z.ZodNumber;
19
+ right: z.ZodNumber;
20
+ top: z.ZodNumber;
21
+ }, z.core.$strict>>;
22
+ projection: z.ZodOptional<z.ZodEnum<{
23
+ globe: "globe";
24
+ mercator: "mercator";
25
+ }>>;
26
+ requiredInsets: z.ZodOptional<z.ZodObject<{
27
+ bottom: z.ZodNumber;
28
+ left: z.ZodNumber;
29
+ right: z.ZodNumber;
30
+ top: z.ZodNumber;
31
+ }, z.core.$strict>>;
32
+ ringIndex: z.ZodOptional<z.ZodNumber>;
33
+ segmentIndex: z.ZodOptional<z.ZodNumber>;
34
+ viewport: z.ZodOptional<z.ZodObject<{
35
+ height: z.ZodNumber;
36
+ width: z.ZodNumber;
37
+ }, z.core.$strict>>;
38
+ }, z.core.$strict>;
39
+ type StaticAutoFitDetails = z.infer<typeof autoFitDetailsSchema>;
40
+ declare const staticOverlayInvalidDetailsSchema: z.ZodObject<{
41
+ latitude: z.ZodNumber;
42
+ limit: z.ZodLiteral<85.051129>;
43
+ overlay: z.ZodObject<{
44
+ id: z.ZodString;
45
+ index: z.ZodNumber;
46
+ type: z.ZodEnum<{
47
+ line: "line";
48
+ circle: "circle";
49
+ marker: "marker";
50
+ polygon: "polygon";
51
+ }>;
52
+ }, z.core.$strict>;
53
+ }, z.core.$strict>;
54
+ type StaticMapRequestErrorDetails = StaticAutoFitDetails | z.infer<typeof staticOverlayInvalidDetailsSchema>;
55
+ declare const staticMapRequestErrorResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
56
+ code: z.ZodLiteral<"AUTO_FIT_EMPTY">;
57
+ reason: z.ZodLiteral<"NO_FITTABLE_OVERLAYS">;
58
+ error: z.ZodString;
59
+ retryable: z.ZodLiteral<false>;
60
+ }, z.core.$strict>, z.ZodObject<{
61
+ code: z.ZodLiteral<"AUTO_FIT_AMBIGUOUS">;
62
+ details: z.ZodObject<{
63
+ overlay: z.ZodOptional<z.ZodObject<{
64
+ id: z.ZodString;
65
+ index: z.ZodNumber;
66
+ type: z.ZodEnum<{
67
+ line: "line";
68
+ circle: "circle";
69
+ marker: "marker";
70
+ polygon: "polygon";
71
+ }>;
72
+ }, z.core.$strict>>;
73
+ padding: z.ZodOptional<z.ZodObject<{
74
+ bottom: z.ZodNumber;
75
+ left: z.ZodNumber;
76
+ right: z.ZodNumber;
77
+ top: z.ZodNumber;
78
+ }, z.core.$strict>>;
79
+ projection: z.ZodOptional<z.ZodEnum<{
80
+ globe: "globe";
81
+ mercator: "mercator";
82
+ }>>;
83
+ requiredInsets: z.ZodOptional<z.ZodObject<{
84
+ bottom: z.ZodNumber;
85
+ left: z.ZodNumber;
86
+ right: z.ZodNumber;
87
+ top: z.ZodNumber;
88
+ }, z.core.$strict>>;
89
+ ringIndex: z.ZodOptional<z.ZodNumber>;
90
+ segmentIndex: z.ZodOptional<z.ZodNumber>;
91
+ viewport: z.ZodOptional<z.ZodObject<{
92
+ height: z.ZodNumber;
93
+ width: z.ZodNumber;
94
+ }, z.core.$strict>>;
95
+ }, z.core.$strict>;
96
+ reason: z.ZodLiteral<"ANTIMERIDIAN_WRAP_REQUIRED">;
97
+ error: z.ZodString;
98
+ retryable: z.ZodLiteral<false>;
99
+ }, z.core.$strict>, z.ZodObject<{
100
+ code: z.ZodLiteral<"AUTO_FIT_IMPOSSIBLE">;
101
+ details: z.ZodOptional<z.ZodObject<{
102
+ overlay: z.ZodOptional<z.ZodObject<{
103
+ id: z.ZodString;
104
+ index: z.ZodNumber;
105
+ type: z.ZodEnum<{
106
+ line: "line";
107
+ circle: "circle";
108
+ marker: "marker";
109
+ polygon: "polygon";
110
+ }>;
111
+ }, z.core.$strict>>;
112
+ padding: z.ZodOptional<z.ZodObject<{
113
+ bottom: z.ZodNumber;
114
+ left: z.ZodNumber;
115
+ right: z.ZodNumber;
116
+ top: z.ZodNumber;
117
+ }, z.core.$strict>>;
118
+ projection: z.ZodOptional<z.ZodEnum<{
119
+ globe: "globe";
120
+ mercator: "mercator";
121
+ }>>;
122
+ requiredInsets: z.ZodOptional<z.ZodObject<{
123
+ bottom: z.ZodNumber;
124
+ left: z.ZodNumber;
125
+ right: z.ZodNumber;
126
+ top: z.ZodNumber;
127
+ }, z.core.$strict>>;
128
+ ringIndex: z.ZodOptional<z.ZodNumber>;
129
+ segmentIndex: z.ZodOptional<z.ZodNumber>;
130
+ viewport: z.ZodOptional<z.ZodObject<{
131
+ height: z.ZodNumber;
132
+ width: z.ZodNumber;
133
+ }, z.core.$strict>>;
134
+ }, z.core.$strict>>;
135
+ reason: z.ZodEnum<{
136
+ GLOBE_NOT_SIMULTANEOUSLY_VISIBLE: "GLOBE_NOT_SIMULTANEOUSLY_VISIBLE";
137
+ INSUFFICIENT_VIEWPORT: "INSUFFICIENT_VIEWPORT";
138
+ CAMERA_UNRESOLVABLE: "CAMERA_UNRESOLVABLE";
139
+ PROJECTED_FOOTPRINT_OUTSIDE_VIEWPORT: "PROJECTED_FOOTPRINT_OUTSIDE_VIEWPORT";
140
+ }>;
141
+ error: z.ZodString;
142
+ retryable: z.ZodLiteral<false>;
143
+ }, z.core.$strict>, z.ZodObject<{
144
+ code: z.ZodLiteral<"STATIC_OVERLAY_INVALID">;
145
+ details: z.ZodObject<{
146
+ latitude: z.ZodNumber;
147
+ limit: z.ZodLiteral<85.051129>;
148
+ overlay: z.ZodObject<{
149
+ id: z.ZodString;
150
+ index: z.ZodNumber;
151
+ type: z.ZodEnum<{
152
+ line: "line";
153
+ circle: "circle";
154
+ marker: "marker";
155
+ polygon: "polygon";
156
+ }>;
157
+ }, z.core.$strict>;
158
+ }, z.core.$strict>;
159
+ reason: z.ZodLiteral<"OVERLAY_LATITUDE_OUT_OF_RANGE">;
160
+ error: z.ZodString;
161
+ retryable: z.ZodLiteral<false>;
162
+ }, z.core.$strict>, z.ZodObject<{
163
+ code: z.ZodLiteral<"STATIC_MAP_ATTRIBUTION_UNSUPPORTED">;
164
+ reason: z.ZodEnum<{
165
+ UNSUPPORTED_DECLARATION: "UNSUPPORTED_DECLARATION";
166
+ UNSUPPORTED_GLYPH: "UNSUPPORTED_GLYPH";
167
+ }>;
168
+ error: z.ZodString;
169
+ retryable: z.ZodLiteral<false>;
170
+ }, z.core.$strict>, z.ZodObject<{
171
+ code: z.ZodLiteral<"STATIC_MAP_ATTRIBUTION_TOO_LARGE">;
172
+ reason: z.ZodLiteral<"CONTENT_LIMIT_EXCEEDED">;
173
+ error: z.ZodString;
174
+ retryable: z.ZodLiteral<false>;
175
+ }, z.core.$strict>, z.ZodObject<{
176
+ code: z.ZodLiteral<"STATIC_MAP_ATTRIBUTION_DOES_NOT_FIT">;
177
+ reason: z.ZodLiteral<"BLOCK_DOES_NOT_FIT">;
178
+ error: z.ZodString;
179
+ retryable: z.ZodLiteral<false>;
180
+ }, z.core.$strict>], "code">;
181
+ type StaticMapRequestErrorResponse = z.infer<typeof staticMapRequestErrorResponseSchema>;
182
+ type StaticAutoFitErrorResponse = Extract<StaticMapRequestErrorResponse, {
183
+ code: `AUTO_FIT_${string}`;
184
+ }>;
185
+ declare class StaticMapRequestError extends Error {
186
+ readonly code: StaticMapRequestErrorResponse['code'];
187
+ readonly details?: StaticMapRequestErrorDetails;
188
+ readonly reason: StaticMapRequestErrorResponse['reason'];
189
+ readonly retryable = false;
190
+ readonly status: number;
191
+ constructor(response: StaticMapRequestErrorResponse, status?: number);
192
+ }
193
+ type StaticAutoFitFailure = StaticAutoFitErrorResponse & {
194
+ ok: false;
195
+ };
196
+ type StaticMapRequestFailure = StaticMapRequestErrorResponse & {
197
+ ok: false;
198
+ };
4
199
 
5
200
  declare function validateStaticScene(input: unknown): {
6
201
  ok: true;
@@ -8,7 +203,7 @@ declare function validateStaticScene(input: unknown): {
8
203
  } | {
9
204
  error: string;
10
205
  ok: false;
11
- };
206
+ } | StaticMapRequestFailure;
12
207
  declare function normalizeStaticScene(scene: StaticSceneInput): StaticScene;
13
208
 
14
- export { StaticScene, StaticSceneInput, normalizeStaticScene, validateStaticScene };
209
+ export { type StaticAutoFitErrorResponse, type StaticAutoFitFailure, StaticMapRequestError, type StaticMapRequestErrorResponse, type StaticMapRequestFailure, StaticScene, StaticSceneInput, normalizeStaticScene, staticMapRequestErrorResponseSchema, validateStaticScene };
package/dist/scene.js CHANGED
@@ -1,14 +1,24 @@
1
1
  import {
2
+ StaticMapRequestError,
2
3
  normalizeStaticScene,
4
+ staticMapRequestErrorResponseSchema,
3
5
  validateStaticScene
4
- } from "./chunk-ROBEGDDY.js";
6
+ } from "./chunk-EMCKSFZV.js";
5
7
  import {
8
+ MAX_OVERLAY_LATITUDE,
9
+ staticAttributionPositionSchema,
10
+ staticAttributionRequestSchema,
6
11
  staticSceneLimits,
7
12
  staticSceneSchema,
8
13
  staticSceneSchemaVersion
9
- } from "./chunk-YUG3PBK2.js";
14
+ } from "./chunk-NM2JSFUF.js";
10
15
  export {
16
+ MAX_OVERLAY_LATITUDE,
17
+ StaticMapRequestError,
11
18
  normalizeStaticScene,
19
+ staticAttributionPositionSchema,
20
+ staticAttributionRequestSchema,
21
+ staticMapRequestErrorResponseSchema,
12
22
  staticSceneLimits,
13
23
  staticSceneSchema,
14
24
  staticSceneSchemaVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/static",
3
- "version": "0.1.0-alpha.20",
3
+ "version": "0.1.0-alpha.22",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Static map request schemas and helpers for Tileflow.",
6
6
  "type": "module",
@@ -1,79 +0,0 @@
1
- import {
2
- normalizeStaticScene,
3
- validateStaticScene
4
- } from "./chunk-ROBEGDDY.js";
5
- import {
6
- hashStableValue,
7
- isSafeHttpUrl,
8
- staticSceneSchema,
9
- stripUndefined
10
- } from "./chunk-YUG3PBK2.js";
11
-
12
- // src/manifest.ts
13
- import { z } from "zod";
14
- var staticRendererSchemaVersion = 1;
15
- var staticRenderManifestSchema = z.object({
16
- mapId: z.string().trim().min(1).max(128),
17
- rendererVersion: z.string().trim().min(1).max(64),
18
- schemaVersion: z.literal(staticRendererSchemaVersion),
19
- scene: staticSceneSchema,
20
- styleId: z.string().trim().min(1).max(128).optional(),
21
- styleRevision: z.string().trim().min(1).max(128),
22
- styleUrl: z.string().trim().url().max(512).refine(isSafeHttpUrl, {
23
- message: "Expected an http(s) style URL without credentials or a fragment"
24
- })
25
- });
26
- function validateStaticRenderManifest(input) {
27
- const parsed = staticRenderManifestSchema.safeParse(input);
28
- if (!parsed.success) {
29
- return {
30
- error: parsed.error.issues.map((issue) => `${issue.path.join(".") || "manifest"}: ${issue.message}`).join("; "),
31
- ok: false
32
- };
33
- }
34
- const sceneValidation = validateStaticScene(parsed.data.scene);
35
- if (!sceneValidation.ok) {
36
- return sceneValidation;
37
- }
38
- return {
39
- manifest: {
40
- ...parsed.data,
41
- scene: sceneValidation.scene
42
- },
43
- ok: true
44
- };
45
- }
46
- function createRenderManifest(input) {
47
- return staticRenderManifestSchema.parse(
48
- stripUndefined({
49
- mapId: input.mapId,
50
- rendererVersion: input.rendererVersion,
51
- schemaVersion: staticRendererSchemaVersion,
52
- scene: normalizeStaticScene(input.scene),
53
- styleId: input.styleId,
54
- styleRevision: input.styleRevision,
55
- styleUrl: input.styleUrl
56
- })
57
- );
58
- }
59
- async function hashRenderManifest(manifest) {
60
- const normalized = staticRenderManifestSchema.parse({
61
- ...manifest,
62
- scene: normalizeStaticScene(manifest.scene)
63
- });
64
- return hashStableValue(normalized);
65
- }
66
- async function hashStaticSceneRequest(scene) {
67
- const validation = validateStaticScene(scene);
68
- if (!validation.ok) throw new Error(`Invalid Tileflow static scene: ${validation.error}`);
69
- return hashStableValue(validation.scene);
70
- }
71
-
72
- export {
73
- staticRendererSchemaVersion,
74
- staticRenderManifestSchema,
75
- validateStaticRenderManifest,
76
- createRenderManifest,
77
- hashRenderManifest,
78
- hashStaticSceneRequest
79
- };
@@ -1,63 +0,0 @@
1
- import {
2
- jsonByteLength,
3
- normalizeStaticCoordinate,
4
- normalizeStaticOverlay,
5
- roundNumber,
6
- staticSceneLimits,
7
- staticSceneSchema,
8
- stripUndefined
9
- } from "./chunk-YUG3PBK2.js";
10
-
11
- // src/scene.ts
12
- function validateStaticScene(input) {
13
- const parsed = staticSceneSchema.safeParse(input);
14
- if (!parsed.success) {
15
- return {
16
- error: parsed.error.issues.map((issue) => `${issue.path.join(".") || "scene"}: ${issue.message}`).join("; "),
17
- ok: false
18
- };
19
- }
20
- if (jsonByteLength(parsed.data.overlays) > staticSceneLimits.maxGeoJsonBytes) {
21
- return {
22
- error: `overlays exceed ${staticSceneLimits.maxGeoJsonBytes} bytes`,
23
- ok: false
24
- };
25
- }
26
- return { ok: true, scene: normalizeParsedStaticScene(parsed.data) };
27
- }
28
- function normalizeStaticScene(scene) {
29
- return normalizeParsedStaticScene(staticSceneSchema.parse(scene));
30
- }
31
- function normalizeParsedStaticScene(parsed) {
32
- return stripUndefined({
33
- camera: parsed.camera.type === "center" ? {
34
- bearing: roundNumber(parsed.camera.bearing ?? 0),
35
- center: normalizeStaticCoordinate(parsed.camera.center),
36
- type: "center",
37
- zoom: roundNumber(parsed.camera.zoom)
38
- } : {
39
- bearing: roundNumber(parsed.camera.bearing ?? 0),
40
- bounds: parsed.camera.bounds.map(roundNumber),
41
- padding: parsed.camera.padding ?? 32,
42
- type: "bounds"
43
- },
44
- map: parsed.map,
45
- overlays: parsed.overlays.map(
46
- (overlay, index) => normalizeStaticOverlay({
47
- ...overlay,
48
- id: overlay.id ?? `overlay-${index + 1}`
49
- })
50
- ),
51
- size: {
52
- dpr: parsed.size.dpr ?? 1,
53
- height: parsed.size.height,
54
- width: parsed.size.width
55
- },
56
- theme: parsed.theme
57
- });
58
- }
59
-
60
- export {
61
- validateStaticScene,
62
- normalizeStaticScene
63
- };