@tileflow/static 0.1.0-alpha.21 → 0.1.0-alpha.23

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,99 +0,0 @@
1
- import {
2
- analyzeStaticAutoFit,
3
- normalizeStaticScene,
4
- staticAutoFitPlanSchema,
5
- validateStaticScene
6
- } from "./chunk-NHQK5UZ2.js";
7
- import {
8
- hashStableValue,
9
- isSafeHttpUrl,
10
- stableStringify,
11
- staticSceneSchema,
12
- stripUndefined
13
- } from "./chunk-MGQCHCU3.js";
14
-
15
- // src/manifest.ts
16
- import { z } from "zod";
17
- var staticRendererSchemaVersion = 1;
18
- var staticRenderManifestSchema = z.object({
19
- autoFit: staticAutoFitPlanSchema.optional(),
20
- mapId: z.string().trim().min(1).max(128),
21
- rendererVersion: z.string().trim().min(1).max(64),
22
- schemaVersion: z.literal(staticRendererSchemaVersion),
23
- scene: staticSceneSchema,
24
- styleId: z.string().trim().min(1).max(128).optional(),
25
- styleRevision: z.string().trim().min(1).max(128),
26
- styleUrl: z.string().trim().url().max(512).refine(isSafeHttpUrl, {
27
- message: "Expected an http(s) style URL without credentials or a fragment"
28
- })
29
- });
30
- function validateStaticRenderManifest(input) {
31
- const rawScene = input && typeof input === "object" && !Array.isArray(input) && "scene" in input ? input.scene : void 0;
32
- const sceneValidation = validateStaticScene(rawScene);
33
- if (!sceneValidation.ok) {
34
- return sceneValidation;
35
- }
36
- const parsed = staticRenderManifestSchema.safeParse({
37
- ...input,
38
- scene: sceneValidation.scene
39
- });
40
- if (!parsed.success) {
41
- return {
42
- error: parsed.error.issues.map((issue) => `${issue.path.join(".") || "manifest"}: ${issue.message}`).join("; "),
43
- ok: false
44
- };
45
- }
46
- const autoFit = expectedAutoFit(sceneValidation.scene);
47
- if (autoFit === void 0 !== (parsed.data.autoFit === void 0) || autoFit !== void 0 && stableStringify(autoFit) !== stableStringify(parsed.data.autoFit)) {
48
- return { error: "manifest.autoFit: Expected the exact plan derived from scene", ok: false };
49
- }
50
- return {
51
- manifest: {
52
- ...parsed.data,
53
- ...autoFit === void 0 ? {} : { autoFit },
54
- scene: sceneValidation.scene
55
- },
56
- ok: true
57
- };
58
- }
59
- function createRenderManifest(input) {
60
- const scene = normalizeStaticScene(input.scene);
61
- const autoFit = expectedAutoFit(scene);
62
- return staticRenderManifestSchema.parse(
63
- stripUndefined({
64
- autoFit,
65
- mapId: input.mapId,
66
- rendererVersion: input.rendererVersion,
67
- schemaVersion: staticRendererSchemaVersion,
68
- scene,
69
- styleId: input.styleId,
70
- styleRevision: input.styleRevision,
71
- styleUrl: input.styleUrl
72
- })
73
- );
74
- }
75
- async function hashRenderManifest(manifest) {
76
- const validation = validateStaticRenderManifest(manifest);
77
- if (!validation.ok) throw new Error(`Invalid Tileflow render manifest: ${validation.error}`);
78
- return hashStableValue(validation.manifest);
79
- }
80
- async function hashStaticSceneRequest(scene) {
81
- const validation = validateStaticScene(scene);
82
- if (!validation.ok) throw new Error(`Invalid Tileflow static scene: ${validation.error}`);
83
- return hashStableValue(validation.scene);
84
- }
85
- function expectedAutoFit(scene) {
86
- if (scene.camera.type !== "auto") return void 0;
87
- const analysis = analyzeStaticAutoFit(scene);
88
- if (!analysis.ok) throw new Error(`Invalid Tileflow auto-fit scene: ${analysis.error}`);
89
- return analysis.plan;
90
- }
91
-
92
- export {
93
- staticRendererSchemaVersion,
94
- staticRenderManifestSchema,
95
- validateStaticRenderManifest,
96
- createRenderManifest,
97
- hashRenderManifest,
98
- hashStaticSceneRequest
99
- };
@@ -1,159 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- declare const staticSceneSchemaVersion = 1;
4
- declare const MAX_OVERLAY_LATITUDE = 85.051129;
5
- declare const staticSceneLimits: {
6
- readonly maxDimension: 1280;
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 staticPaddingSchema: z.ZodObject<{
15
- bottom: z.ZodNumber;
16
- left: z.ZodNumber;
17
- right: z.ZodNumber;
18
- top: z.ZodNumber;
19
- }, z.core.$strict>;
20
- declare const lineOverlaySchema: z.ZodObject<{
21
- color: z.ZodDefault<z.ZodString>;
22
- coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
23
- id: z.ZodOptional<z.ZodString>;
24
- opacity: z.ZodDefault<z.ZodNumber>;
25
- type: z.ZodLiteral<"line">;
26
- width: z.ZodDefault<z.ZodNumber>;
27
- }, z.core.$strip>;
28
- declare const circleOverlaySchema: z.ZodObject<{
29
- color: z.ZodDefault<z.ZodString>;
30
- coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
31
- id: z.ZodOptional<z.ZodString>;
32
- opacity: z.ZodDefault<z.ZodNumber>;
33
- radius: z.ZodDefault<z.ZodNumber>;
34
- strokeColor: z.ZodOptional<z.ZodString>;
35
- strokeWidth: z.ZodDefault<z.ZodNumber>;
36
- type: z.ZodLiteral<"circle">;
37
- }, z.core.$strip>;
38
- declare const markerOverlaySchema: z.ZodObject<{
39
- color: z.ZodDefault<z.ZodString>;
40
- coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
41
- id: z.ZodOptional<z.ZodString>;
42
- radius: z.ZodDefault<z.ZodNumber>;
43
- strokeColor: z.ZodDefault<z.ZodString>;
44
- strokeWidth: z.ZodDefault<z.ZodNumber>;
45
- type: z.ZodLiteral<"marker">;
46
- }, z.core.$strip>;
47
- declare const polygonOverlaySchema: z.ZodObject<{
48
- coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
49
- fill: z.ZodDefault<z.ZodString>;
50
- id: z.ZodOptional<z.ZodString>;
51
- opacity: z.ZodDefault<z.ZodNumber>;
52
- stroke: z.ZodOptional<z.ZodString>;
53
- strokeWidth: z.ZodDefault<z.ZodNumber>;
54
- type: z.ZodLiteral<"polygon">;
55
- }, z.core.$strip>;
56
- declare const staticOverlaySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
- color: z.ZodDefault<z.ZodString>;
58
- coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
59
- id: z.ZodOptional<z.ZodString>;
60
- opacity: z.ZodDefault<z.ZodNumber>;
61
- type: z.ZodLiteral<"line">;
62
- width: z.ZodDefault<z.ZodNumber>;
63
- }, z.core.$strip>, z.ZodObject<{
64
- color: z.ZodDefault<z.ZodString>;
65
- coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
66
- id: z.ZodOptional<z.ZodString>;
67
- opacity: z.ZodDefault<z.ZodNumber>;
68
- radius: z.ZodDefault<z.ZodNumber>;
69
- strokeColor: z.ZodOptional<z.ZodString>;
70
- strokeWidth: z.ZodDefault<z.ZodNumber>;
71
- type: z.ZodLiteral<"circle">;
72
- }, z.core.$strip>, z.ZodObject<{
73
- color: z.ZodDefault<z.ZodString>;
74
- coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
75
- id: z.ZodOptional<z.ZodString>;
76
- radius: z.ZodDefault<z.ZodNumber>;
77
- strokeColor: z.ZodDefault<z.ZodString>;
78
- strokeWidth: z.ZodDefault<z.ZodNumber>;
79
- type: z.ZodLiteral<"marker">;
80
- }, z.core.$strip>, z.ZodObject<{
81
- coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
82
- fill: z.ZodDefault<z.ZodString>;
83
- id: z.ZodOptional<z.ZodString>;
84
- opacity: z.ZodDefault<z.ZodNumber>;
85
- stroke: z.ZodOptional<z.ZodString>;
86
- strokeWidth: z.ZodDefault<z.ZodNumber>;
87
- type: z.ZodLiteral<"polygon">;
88
- }, z.core.$strip>], "type">;
89
- declare const staticSceneSchema: z.ZodObject<{
90
- camera: z.ZodDiscriminatedUnion<[z.ZodObject<{
91
- bearing: z.ZodOptional<z.ZodNumber>;
92
- center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
93
- type: z.ZodLiteral<"center">;
94
- zoom: z.ZodNumber;
95
- }, z.core.$strip>, z.ZodObject<{
96
- bearing: z.ZodOptional<z.ZodNumber>;
97
- bounds: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
98
- padding: z.ZodOptional<z.ZodNumber>;
99
- type: z.ZodLiteral<"bounds">;
100
- }, z.core.$strip>, z.ZodObject<{
101
- bearing: z.ZodOptional<z.ZodNumber>;
102
- maxZoom: z.ZodOptional<z.ZodNumber>;
103
- padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
104
- bottom: z.ZodOptional<z.ZodNumber>;
105
- left: z.ZodOptional<z.ZodNumber>;
106
- right: z.ZodOptional<z.ZodNumber>;
107
- top: z.ZodOptional<z.ZodNumber>;
108
- }, z.core.$strict>]>>;
109
- type: z.ZodLiteral<"auto">;
110
- }, z.core.$strip>], "type">;
111
- map: z.ZodString;
112
- overlays: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
113
- color: z.ZodDefault<z.ZodString>;
114
- coordinates: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
115
- id: z.ZodOptional<z.ZodString>;
116
- opacity: z.ZodDefault<z.ZodNumber>;
117
- type: z.ZodLiteral<"line">;
118
- width: z.ZodDefault<z.ZodNumber>;
119
- }, z.core.$strip>, z.ZodObject<{
120
- color: z.ZodDefault<z.ZodString>;
121
- coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
122
- id: z.ZodOptional<z.ZodString>;
123
- opacity: z.ZodDefault<z.ZodNumber>;
124
- radius: z.ZodDefault<z.ZodNumber>;
125
- strokeColor: z.ZodOptional<z.ZodString>;
126
- strokeWidth: z.ZodDefault<z.ZodNumber>;
127
- type: z.ZodLiteral<"circle">;
128
- }, z.core.$strip>, z.ZodObject<{
129
- color: z.ZodDefault<z.ZodString>;
130
- coordinate: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
131
- id: z.ZodOptional<z.ZodString>;
132
- radius: z.ZodDefault<z.ZodNumber>;
133
- strokeColor: z.ZodDefault<z.ZodString>;
134
- strokeWidth: z.ZodDefault<z.ZodNumber>;
135
- type: z.ZodLiteral<"marker">;
136
- }, z.core.$strip>, z.ZodObject<{
137
- coordinates: z.ZodArray<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
138
- fill: z.ZodDefault<z.ZodString>;
139
- id: z.ZodOptional<z.ZodString>;
140
- opacity: z.ZodDefault<z.ZodNumber>;
141
- stroke: z.ZodOptional<z.ZodString>;
142
- strokeWidth: z.ZodDefault<z.ZodNumber>;
143
- type: z.ZodLiteral<"polygon">;
144
- }, z.core.$strip>], "type">>>;
145
- size: z.ZodObject<{
146
- dpr: z.ZodOptional<z.ZodLiteral<1>>;
147
- height: z.ZodNumber;
148
- width: z.ZodNumber;
149
- }, z.core.$strip>;
150
- theme: z.ZodString;
151
- }, z.core.$strip>;
152
- type StaticCoordinate = z.infer<typeof coordinateSchema>;
153
- type StaticPadding = z.infer<typeof staticPaddingSchema>;
154
- type StaticSceneInput = z.input<typeof staticSceneSchema>;
155
- type StaticScene = z.infer<typeof staticSceneSchema>;
156
- type StaticOverlayInput = z.input<typeof staticOverlaySchema>;
157
- type StaticOverlay = z.infer<typeof staticOverlaySchema>;
158
-
159
- export { MAX_OVERLAY_LATITUDE as M, type StaticCoordinate as S, type StaticOverlay as a, type StaticOverlayInput as b, type StaticPadding as c, type StaticScene as d, type StaticSceneInput as e, staticSceneLimits as f, staticSceneSchema as g, staticSceneSchemaVersion as h, circleOverlaySchema as i, lineOverlaySchema as l, markerOverlaySchema as m, polygonOverlaySchema as p, staticOverlaySchema as s };