@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.
- package/README.md +145 -18
- package/dist/chunk-6DWVCK64.js +406 -0
- package/dist/chunk-HVVIAOBE.js +175 -0
- package/dist/{chunk-A23RC4BE.js → chunk-N63IFMFM.js} +64 -18
- package/dist/{chunk-NHQK5UZ2.js → chunk-TBI5AED6.js} +185 -43
- package/dist/chunk-XMT7VJL5.js +297 -0
- package/dist/client.d.ts +93 -10
- package/dist/client.js +16 -5
- package/dist/errors-B9rwehK0.d.ts +21 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +55 -9
- package/dist/manifest.d.ts +419 -13
- package/dist/manifest.js +19 -3
- 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 +103 -4
- package/dist/scene.js +21 -3
- package/package.json +3 -6
- package/GENERATED_OUTPUT_LICENSE.md +0 -21
- package/NOTICE +0 -9
- package/TRADEMARKS.md +0 -10
- package/dist/chunk-KPT7PASB.js +0 -122
- package/dist/chunk-MGQCHCU3.js +0 -228
- package/dist/chunk-S3WXE5P4.js +0 -99
- package/dist/scene-contract-DZMhLDnf.d.ts +0 -159
package/README.md
CHANGED
|
@@ -9,6 +9,10 @@ existing hosted image and does not create or poll a Static Maps operation.
|
|
|
9
9
|
Every scene names one concrete `theme`. The browser-only `"system"` selector is rejected so hashes,
|
|
10
10
|
cache keys, receipts, and regenerated images remain reproducible.
|
|
11
11
|
|
|
12
|
+
Scene, size, camera, attribution, padding, and overlay objects are strict. Unknown fields are
|
|
13
|
+
rejected instead of being removed during normalization, so misspelled or unsupported options cannot
|
|
14
|
+
silently share another scene's identity.
|
|
15
|
+
|
|
12
16
|
```ts
|
|
13
17
|
import {
|
|
14
18
|
createStaticMapIdempotencyKey,
|
|
@@ -20,24 +24,137 @@ import {
|
|
|
20
24
|
const scene = validateStaticScene({
|
|
21
25
|
map: 'madrid',
|
|
22
26
|
theme: 'dark',
|
|
27
|
+
format: 'webp',
|
|
23
28
|
camera: {type: 'auto', padding: 24},
|
|
24
|
-
size: {width:
|
|
29
|
+
size: {width: 600, height: 400, dpr: 2},
|
|
25
30
|
overlays: [marker({coordinate: [-3.7038, 40.4168]})],
|
|
26
31
|
});
|
|
27
32
|
|
|
28
33
|
if (!scene.ok) throw new Error(scene.error);
|
|
29
34
|
|
|
30
|
-
await precacheStaticMap(scene.scene, {
|
|
35
|
+
const result = await precacheStaticMap(scene.scene, {
|
|
31
36
|
apiKey: process.env.TILEFLOW_API_KEY,
|
|
32
37
|
idempotencyKey: createStaticMapIdempotencyKey(),
|
|
33
38
|
});
|
|
39
|
+
|
|
40
|
+
console.log(result.attribution.entries);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`width` and `height` are logical CSS pixels. `dpr` accepts 1 or 2 and defaults to 1, so a 600 by
|
|
44
|
+
400 scene at DPR 2 produces a 1200 by 800 image without changing camera, padding, or overlay paint
|
|
45
|
+
sizes. Logical dimensions may reach 2048 per axis; the physical budget permits 4096 by 4096 output,
|
|
46
|
+
or 16,777,216 total pixels.
|
|
47
|
+
|
|
48
|
+
`format` accepts `png`, `jpeg`, or `webp` and defaults to PNG. PNG's canonical default stays omitted,
|
|
49
|
+
so explicit and omitted PNG requests share identity. JPEG and WebP use a fixed encoder quality;
|
|
50
|
+
there is no public quality option.
|
|
51
|
+
|
|
52
|
+
## Semantic overlays
|
|
53
|
+
|
|
54
|
+
Every overlay accepts a semantic `placement`:
|
|
55
|
+
|
|
56
|
+
- `above-water`
|
|
57
|
+
- `below-roads`
|
|
58
|
+
- `above-roads`
|
|
59
|
+
- `above-buildings`
|
|
60
|
+
- `below-labels`
|
|
61
|
+
- `above-labels` (default)
|
|
62
|
+
|
|
63
|
+
These values are stable across themes. They never expose a physical Style layer ID. Array order is
|
|
64
|
+
preserved within each placement; later overlays paint above earlier overlays in the same group.
|
|
65
|
+
|
|
66
|
+
Use `symbol` for a deployed sprite icon, renderer-owned text, or both:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import {symbol} from '@tileflow/static';
|
|
70
|
+
|
|
71
|
+
symbol({
|
|
72
|
+
coordinate: [-3.7038, 40.4168],
|
|
73
|
+
icon: 'store',
|
|
74
|
+
label: {appearance: 'badge', text: '23'},
|
|
75
|
+
placement: 'above-labels',
|
|
76
|
+
anchor: 'bottom',
|
|
77
|
+
offset: [0, -4],
|
|
78
|
+
scale: 1,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`icon` is an ID in the exact managed sprite deployed with the selected Map, never a URL. Hosted
|
|
83
|
+
resolves and binds its dimensions before rendering; an unmanaged sprite or absent ID returns a
|
|
84
|
+
non-retryable structured error. `scale` changes the icon while `label.fontSize` controls text.
|
|
85
|
+
`offset` uses logical CSS pixels and moves the complete symbol after anchoring.
|
|
86
|
+
|
|
87
|
+
A string label is shorthand for `{appearance: 'plain', text}`. `plain` renders text with a halo;
|
|
88
|
+
`badge` renders text in a rounded container. Both use renderer-owned Noto faces independent of theme
|
|
89
|
+
typography. The accepted baseline is generated from the shipped WOFF2 `cmap` tables and covers
|
|
90
|
+
Latin/Extended, Vietnamese, Greek, Cyrillic, Arabic, Hebrew, Devanagari, Thai, Japanese, Simplified
|
|
91
|
+
and Traditional Chinese, and Korean. Symbols and embedded attribution use exactly that coverage.
|
|
92
|
+
Unsupported glyphs fail with `STATIC_MAP_LABEL_UNSUPPORTED`; Chromium must load the matching bundled
|
|
93
|
+
face. The renderer audits the face Chromium actually used for every run; any system-font glyph fails
|
|
94
|
+
the render.
|
|
95
|
+
|
|
96
|
+
Appearance objects accept `language: 'ja' | 'zh-Hans' | 'zh-Hant' | 'ko'`. It chooses the preferred
|
|
97
|
+
regional Noto CJK face; glyphs absent there fall through only to other bundled regional faces. It
|
|
98
|
+
does not translate text or select map data. Omission and string shorthand normalize to `zh-Hans`.
|
|
99
|
+
That fallback is deterministic but makes no regional-form promise for Han text whose language was
|
|
100
|
+
omitted. Font family and weight are not public controls. Label position can be `center`, any cardinal
|
|
101
|
+
side, or any diagonal side. With an icon, plain defaults above it and badge defaults above-right;
|
|
102
|
+
label-only symbols default to center.
|
|
103
|
+
|
|
104
|
+
`anchor` accepts the same nine center/cardinal/diagonal positions. `collision: 'always-visible'` is
|
|
105
|
+
the default: the symbol is never hidden and does not reserve collision space. `avoid-overlap`
|
|
106
|
+
participates in MapLibre's shared symbol collision index, including ordinary Style labels and other
|
|
107
|
+
request symbols. The visually higher layer wins: an `above-labels` request symbol can hide a
|
|
108
|
+
colliding Style label, while a `below-labels` symbol yields to it. Higher semantic placement wins
|
|
109
|
+
across placements; later request order wins within one placement. Style-owned overlap properties
|
|
110
|
+
remain authoritative.
|
|
111
|
+
|
|
112
|
+
## Attribution
|
|
113
|
+
|
|
114
|
+
New renders default to `attribution: {mode: 'embedded', position: 'auto'}` without adding that
|
|
115
|
+
omitted default to the normalized scene. Hosted derives notices from the sources referenced by the
|
|
116
|
+
exact selected Style and embeds a safe, compact block. Automatic placement prefers an unobstructed
|
|
117
|
+
corner, then the least interfering corner among declared request overlays. Explicit center and
|
|
118
|
+
bounds cameras never move.
|
|
119
|
+
|
|
120
|
+
Choose a corner when composition requires it:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
attribution: {mode: 'embedded', position: 'bottom-left'}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Or request structured external attribution:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const result = await createStaticMap(
|
|
130
|
+
{...scene.scene, attribution: {mode: 'external'}},
|
|
131
|
+
{
|
|
132
|
+
apiKey: process.env.TILEFLOW_API_KEY,
|
|
133
|
+
idempotencyKey: createStaticMapIdempotencyKey(),
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
for (const entry of result.attribution.entries) {
|
|
138
|
+
renderAttributionText(entry.text, entry.links);
|
|
139
|
+
}
|
|
34
140
|
```
|
|
35
141
|
|
|
142
|
+
External mode leaves the image unchanged and returns `position: null`. The caller must retain and
|
|
143
|
+
display every returned entry beside the image. Entries contain bounded plain text, safe HTTP(S)
|
|
144
|
+
links, and `platform-notice` or `team-declared` authority; they never contain source HTML or private
|
|
145
|
+
resource IDs. Embedded results return the resolved corner. Changing mode or requested position
|
|
146
|
+
changes scene and artifact identity.
|
|
147
|
+
|
|
148
|
+
Embedded attribution uses the same generated multilingual coverage as symbol labels and the fixed
|
|
149
|
+
`zh-Hans` CJK fallback. External attribution contains structured text only and is rendered by the
|
|
150
|
+
caller.
|
|
151
|
+
|
|
36
152
|
## Automatic framing
|
|
37
153
|
|
|
38
|
-
`camera.type: 'auto'` fits the complete
|
|
39
|
-
and
|
|
40
|
-
|
|
154
|
+
`camera.type: 'auto'` fits the complete painted footprint of every declared marker, circle, line,
|
|
155
|
+
polygon, and symbol. Symbol sizing uses the exact deployed icon dimensions plus deterministic label
|
|
156
|
+
measurement, anchor, scale, and offset. It works with Mercator and Globe styles when the geometry
|
|
157
|
+
can be shown. It never clips silently.
|
|
41
158
|
|
|
42
159
|
```ts
|
|
43
160
|
camera: {
|
|
@@ -66,34 +183,44 @@ yet be drawn there.
|
|
|
66
183
|
Deterministic request failures return `422`, set `retryable: false`, and preserve a stable code,
|
|
67
184
|
reason, and bounded details. `validateStaticScene` returns that document; request helpers throw
|
|
68
185
|
`StaticMapRequestError` either locally or from the Hosted response. The reasons distinguish an empty
|
|
69
|
-
scene, an ambiguous antimeridian path, an out-of-range overlay latitude, an
|
|
70
|
-
|
|
71
|
-
|
|
186
|
+
scene, an ambiguous antimeridian path, an out-of-range overlay latitude, an unsupported label glyph,
|
|
187
|
+
an unavailable managed icon or semantic placement, an oversized composed symbol, an insufficient
|
|
188
|
+
viewport, a Globe visibility conflict, an unresolvable camera, and failed post-fit containment.
|
|
189
|
+
Correct the scene or redeploy the Map as directed; do not retry it unchanged. Unsupported
|
|
190
|
+
attribution grammar or glyphs, excessive attribution, and a block that cannot fit use the same
|
|
191
|
+
non-retryable `422` boundary.
|
|
192
|
+
|
|
193
|
+
Other bounded Hosted JSON failures throw `StaticMapError`. It preserves HTTP `status` and any safe
|
|
194
|
+
`code`, `retryable`, `requestId`, or `remainingUnits` fields the server supplied; absent fields are
|
|
195
|
+
`null`. `StaticMapRequestError` extends the same class. Malformed, oversized, or unsafe remote
|
|
196
|
+
documents remain generic errors and are never reflected to the caller.
|
|
72
197
|
|
|
73
198
|
The package has four deliberately separate surfaces, all available from the root for compatibility:
|
|
74
199
|
|
|
75
200
|
- scene validation and normalization: `staticSceneSchema`, `validateStaticScene`, and
|
|
76
201
|
`normalizeStaticScene`;
|
|
77
|
-
- overlay authoring and MapLibre compilation: `line`, `circle`, `marker`, `polygon`, and
|
|
202
|
+
- overlay authoring and MapLibre compilation: `line`, `circle`, `marker`, `polygon`, `symbol`, and
|
|
78
203
|
`compileStaticOverlays`;
|
|
79
|
-
- renderer identity: `createRenderManifest`,
|
|
80
|
-
`hashRenderManifest`, and `hashStaticSceneRequest`;
|
|
204
|
+
- renderer identity: `createRenderManifest`,
|
|
205
|
+
`validateStaticRenderManifest`, `hashRenderManifest`, and `hashStaticSceneRequest`;
|
|
81
206
|
- bounded Hosted transport: `prepareStaticMapRequest`, `createStaticMap`, `precacheStaticMap`, and
|
|
82
207
|
`requestStaticMapUntilReady`.
|
|
83
208
|
|
|
84
209
|
Applications that need only one surface can use `@tileflow/static/scene`, `/overlays`, `/manifest`,
|
|
85
210
|
or `/client`. The root remains a compatibility entry point.
|
|
86
211
|
|
|
87
|
-
`StaticRenderManifest` is the immutable input contract between a resolved Hosted style
|
|
88
|
-
Maps renderer.
|
|
89
|
-
|
|
90
|
-
|
|
212
|
+
`StaticRenderManifest` is the single strict immutable input contract between a resolved Hosted style
|
|
213
|
+
and a Static Maps renderer. It binds safe attribution, exact source identity, semantic placement
|
|
214
|
+
anchors, and resolved sprite dimensions. Its top-level `mapId` identifies the resolved destination
|
|
215
|
+
while `scene.map` retains the portable map name supplied by the application. It is unrelated to the
|
|
216
|
+
runtime delivery manifest generated by application build or deploy workflows.
|
|
91
217
|
|
|
92
218
|
Create one idempotency key per intentional create/precache action and retain it across network
|
|
93
219
|
retries. Reusing the key with the same normalized scene returns the stored result; reusing it with a
|
|
94
220
|
different scene returns 409. A successful paid operation reports `unitCost: 15`, shared
|
|
95
221
|
`remainingUnits`, its durable `operationId`, cache reuse, hash, and immutable image URL. An
|
|
96
|
-
unbounded Starter service reports `remainingUnits: null`.
|
|
222
|
+
unbounded Starter service reports `remainingUnits: null`. Creation helpers require the single strict
|
|
223
|
+
result contract, including `resultVersion: 1` and attribution. A live
|
|
97
224
|
equal-hash render may return `202`; the helper polls with the same body/key within its bounded wait.
|
|
98
225
|
`maxWaitMs` is the total client completion budget, including network, response parsing, and polling
|
|
99
226
|
delays; `signal` cancels the same complete operation. The helper aborts in-flight work when either
|
|
@@ -106,7 +233,7 @@ the same normalized scene for its `sceneKey` and HTTP body, so equivalent omitte
|
|
|
106
233
|
deduplicate consistently without duplicating the polling implementation.
|
|
107
234
|
|
|
108
235
|
Free cannot initiate Static Maps work. Starter consumes 15 shared API units for each successful
|
|
109
|
-
logical operation, including a distinct-key cache reuse. Downloading
|
|
110
|
-
zero units.
|
|
236
|
+
logical operation, including a distinct-key cache reuse. Downloading an immutable PNG, JPEG, or WebP
|
|
237
|
+
consumes zero units.
|
|
111
238
|
|
|
112
239
|
Docs: https://tileflow.dev/docs
|