@tileflow/static 0.1.0-alpha.3 → 0.1.0-alpha.30

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,20 +1,299 @@
1
1
  # @tileflow/static
2
2
 
3
- Static map schemas, overlay helpers, and request utilities for Tileflow static map rendering.
3
+ Validate static map scenes, author overlays, and request hosted image renders. The client follows
4
+ an asynchronous operation until an immutable image is ready. It does not display the image or
5
+ provide an interactive map.
6
+
7
+ > Related packages and guides: [documentation index](https://raw.githubusercontent.com/tileflow/tileflow-sdk/main/llms.txt).
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install @tileflow/static@alpha
13
+ ```
14
+
15
+ Validation and overlay authoring work without a hosted account. Creating a render needs a deployed
16
+ Tileflow map, an enabled Static Maps service, and an authorized credential. Run authenticated
17
+ requests on a trusted server with `fetch` available, such as Node.js 22 or newer. Keep credentials
18
+ out of browser bundles. A React application can use
19
+ [`@tileflow/react/static`](https://github.com/tileflow/tileflow-sdk/blob/main/packages/react/README.md)
20
+ through its own authorized server endpoint.
21
+
22
+ ## Create a render
23
+
24
+ Every scene names one concrete `theme`. The browser-only `"system"` selector is rejected so hashes,
25
+ cache keys, receipts, and regenerated images remain reproducible.
26
+
27
+ Scene, size, camera, attribution, padding, and overlay objects are strict. Unknown fields are
28
+ rejected instead of being removed during normalization, so misspelled or unsupported options cannot
29
+ silently share another scene's identity.
30
+
31
+ <!-- docs:check -->
4
32
 
5
33
  ```ts
6
- import {marker, precacheStaticMap, validateStaticScene} from '@tileflow/static';
34
+ import {createStaticMap, createStaticMapIdempotencyKey} from '@tileflow/static/client';
35
+ import {marker} from '@tileflow/static/overlays';
36
+ import {validateStaticScene} from '@tileflow/static/scene';
37
+
38
+ const apiKey = process.env.TILEFLOW_API_KEY;
39
+ if (!apiKey) throw new Error('Set TILEFLOW_API_KEY on the server.');
7
40
 
8
41
  const scene = validateStaticScene({
9
42
  map: 'madrid',
10
- camera: {type: 'center', center: [-3.7038, 40.4168], zoom: 12},
11
- size: {width: 1200, height: 800},
43
+ theme: 'dark',
44
+ format: 'webp',
45
+ camera: {type: 'auto', padding: 24},
46
+ size: {width: 600, height: 400, dpr: 2},
12
47
  overlays: [marker({coordinate: [-3.7038, 40.4168]})],
13
48
  });
14
49
 
15
- await precacheStaticMap(scene.scene, {
16
- apiKey: process.env.TILEFLOW_API_KEY,
50
+ if (!scene.ok) throw new Error(scene.error);
51
+
52
+ const idempotencyKey = createStaticMapIdempotencyKey();
53
+ const result = await createStaticMap(scene.scene, {
54
+ apiKey,
55
+ idempotencyKey,
56
+ });
57
+
58
+ console.log(result.imageUrl, result.attribution.entries);
59
+ ```
60
+
61
+ `map: 'madrid'` is the deployed portable map name; replace it with yours. For a Team credential,
62
+ pass the destination's public `mapId` separately in the request options, as described below.
63
+ `createStaticMap` and `precacheStaticMap` both return a hosted result with `resultVersion: 1`, an
64
+ operation ID, image URL, and attribution. Use precache for cache warming, not as a free validation
65
+ operation. Neither helper is the same as `<Map mode="image">`, which only displays an existing image.
66
+
67
+ Create one idempotency key per intentional action and retain it across retries. Do not put the key
68
+ factory inside a retry callback. The helper handles polling; cancellation or a timeout does not
69
+ prove that the server did no work.
70
+
71
+ ## Image size and format
72
+
73
+ `width` and `height` are logical CSS pixels. `dpr` accepts 1 or 2 and defaults to 1, so a 600 by
74
+ 400 scene at DPR 2 produces a 1200 by 800 image without changing camera, padding, or overlay paint
75
+ sizes. Logical dimensions may reach 2048 per axis; the physical budget permits 4096 by 4096 output,
76
+ or 16,777,216 total pixels.
77
+
78
+ `format` accepts `png`, `jpeg`, or `webp` and defaults to PNG. PNG's canonical default stays omitted,
79
+ so explicit and omitted PNG requests share identity. JPEG and WebP use a fixed encoder quality;
80
+ there is no public quality option.
81
+
82
+ ## Semantic overlays
83
+
84
+ Every overlay accepts a semantic `placement`:
85
+
86
+ - `above-water`
87
+ - `below-roads`
88
+ - `above-roads`
89
+ - `above-buildings`
90
+ - `below-labels`
91
+ - `above-labels` (default)
92
+
93
+ These values are stable across themes. They never expose a physical Style layer ID. Array order is
94
+ preserved within each placement; later overlays paint above earlier overlays in the same group.
95
+
96
+ Use `symbol` for a deployed sprite icon, renderer-owned text, or both:
97
+
98
+ ```ts
99
+ import {symbol} from '@tileflow/static/overlays';
100
+
101
+ symbol({
102
+ coordinate: [-3.7038, 40.4168],
103
+ icon: 'store',
104
+ label: {appearance: 'badge', text: '23'},
105
+ placement: 'above-labels',
106
+ anchor: 'bottom',
107
+ offset: [0, -4],
108
+ scale: 1,
17
109
  });
18
110
  ```
19
111
 
20
- Docs: https://tileflow.dev/docs
112
+ `icon` is an ID in the exact managed sprite deployed with the selected Map, never a URL. Hosted
113
+ resolves and binds its dimensions before rendering; an unmanaged sprite or absent ID returns a
114
+ non-retryable structured error. `scale` changes the icon while `label.fontSize` controls text.
115
+ `offset` uses logical CSS pixels and moves the complete symbol after anchoring.
116
+
117
+ A string label is shorthand for `{appearance: 'plain', text}`. `plain` renders text with a halo;
118
+ `badge` renders text in a rounded container. Both use renderer-owned Noto faces independent of theme
119
+ typography. The accepted baseline is generated from the shipped WOFF2 `cmap` tables and covers
120
+ Latin/Extended, Vietnamese, Greek, Cyrillic, Arabic, Hebrew, Devanagari, Thai, Japanese, Simplified
121
+ and Traditional Chinese, and Korean. Symbols and embedded attribution use exactly that coverage.
122
+ Unsupported glyphs fail with `STATIC_MAP_LABEL_UNSUPPORTED`; Chromium must load the matching bundled
123
+ face. The renderer audits the face Chromium actually used for every run; any system-font glyph fails
124
+ the render.
125
+
126
+ Appearance objects accept `language: 'ja' | 'zh-Hans' | 'zh-Hant' | 'ko'`. It chooses the preferred
127
+ regional Noto CJK face; glyphs absent there fall through only to other bundled regional faces. It
128
+ does not translate text or select map data. Omission and string shorthand normalize to `zh-Hans`.
129
+ That fallback is deterministic but makes no regional-form promise for Han text whose language was
130
+ omitted. Font family and weight are not public controls. Label position can be `center`, any cardinal
131
+ side, or any diagonal side. With an icon, plain defaults above it and badge defaults above-right;
132
+ label-only symbols default to center.
133
+
134
+ `anchor` accepts the same nine center/cardinal/diagonal positions. `collision: 'always-visible'` is
135
+ the default: the symbol is never hidden and does not reserve collision space. `avoid-overlap`
136
+ participates in MapLibre's shared symbol collision index, including ordinary Style labels and other
137
+ request symbols. The visually higher layer wins: an `above-labels` request symbol can hide a
138
+ colliding Style label, while a `below-labels` symbol yields to it. Higher semantic placement wins
139
+ across placements; later request order wins within one placement. Style-owned overlap properties
140
+ remain authoritative.
141
+
142
+ ## Attribution
143
+
144
+ New renders default to `attribution: {mode: 'embedded', position: 'auto'}` without adding that
145
+ omitted default to the normalized scene. Hosted derives notices from the sources referenced by the
146
+ exact selected Style and embeds a safe, compact block. Automatic placement prefers an unobstructed
147
+ corner, then the least interfering corner among declared request overlays. Explicit center and
148
+ bounds cameras never move.
149
+
150
+ Choose a corner when composition requires it:
151
+
152
+ <!-- docs:check -->
153
+
154
+ ```ts
155
+ import type {StaticAttributionRequest} from '@tileflow/static/scene';
156
+
157
+ const attribution = {
158
+ mode: 'embedded',
159
+ position: 'bottom-left',
160
+ } satisfies StaticAttributionRequest;
161
+ ```
162
+
163
+ Or request structured external attribution:
164
+
165
+ <!-- docs:check -->
166
+
167
+ ```ts
168
+ import {createStaticMap, createStaticMapIdempotencyKey} from '@tileflow/static/client';
169
+
170
+ const apiKey = process.env.TILEFLOW_API_KEY;
171
+ if (!apiKey) throw new Error('Set TILEFLOW_API_KEY on the server.');
172
+
173
+ const result = await createStaticMap(
174
+ {
175
+ map: 'madrid',
176
+ theme: 'dark',
177
+ camera: {type: 'center', center: [-3.7038, 40.4168], zoom: 12},
178
+ size: {width: 600, height: 400},
179
+ attribution: {mode: 'external'},
180
+ },
181
+ {apiKey, idempotencyKey: createStaticMapIdempotencyKey()},
182
+ );
183
+
184
+ console.log(JSON.stringify({imageUrl: result.imageUrl, entries: result.attribution.entries}));
185
+ ```
186
+
187
+ External mode leaves the image unchanged and returns `position: null`. The caller must retain and
188
+ display every returned entry beside the image. Entries contain bounded plain text, safe HTTP(S)
189
+ links, and `platform-notice` or `team-declared` authority; they never contain source HTML or private
190
+ resource IDs. Embedded results return the resolved corner. Changing mode or requested position
191
+ changes scene and artifact identity.
192
+
193
+ Embedded attribution uses the same generated multilingual coverage as symbol labels and the fixed
194
+ `zh-Hans` CJK fallback. External attribution contains structured text only and is rendered by the
195
+ caller.
196
+
197
+ ## Automatic framing
198
+
199
+ `camera.type: 'auto'` fits the complete painted footprint of every declared marker, circle, line,
200
+ polygon, and symbol. Symbol sizing uses the exact deployed icon dimensions plus deterministic label
201
+ measurement, anchor, scale, and offset. It works with Mercator and Globe styles when the geometry
202
+ can be shown. It never clips silently.
203
+
204
+ ```ts
205
+ const camera = {
206
+ type: 'auto',
207
+ padding: {top: 24, right: 240, bottom: 24, left: 24},
208
+ maxZoom: 16,
209
+ bearing: 0,
210
+ } as const;
211
+ ```
212
+
213
+ Padding uses logical CSS pixels. A number applies to every side; omitted sides in an object are
214
+ zero. Without `padding`, Tileflow uses `min(32, ceil(5% * min(width, height)))`. `maxZoom` defaults
215
+ to 16 and `bearing` to 0. A single position still honors asymmetric padding, so its apparent center
216
+ can move away from the viewport center.
217
+
218
+ Point-like overlays around ±180° use the shortest longitude interval. Tileflow never reinterprets
219
+ vertices inside a line or polygon: an ambiguous crossing returns an error. Represent a correctly
220
+ cut `MultiLineString` or `MultiPolygon` as several `line` or `polygon` overlays with identical
221
+ styles; auto-fit may move each complete component to an adjacent world copy.
222
+
223
+ Current overlay primitives use MapLibre's GeoJSON pipeline and require
224
+ `abs(latitude) <= MAX_OVERLAY_LATITUDE` (`85.051129`). Tileflow rejects larger latitudes instead of
225
+ clamping them. A Globe basemap may display polar regions even though these overlay primitives cannot
226
+ yet be drawn there.
227
+
228
+ ## Handle failures
229
+
230
+ Deterministic request failures return `422`, set `retryable: false`, and preserve a stable code,
231
+ reason, and bounded details. `validateStaticScene` returns that document; request helpers throw
232
+ `StaticMapRequestError` either locally or from the Hosted response. The reasons distinguish an empty
233
+ scene, an ambiguous antimeridian path, an out-of-range overlay latitude, an unsupported label glyph,
234
+ an unavailable managed icon or semantic placement, an oversized composed symbol, an insufficient
235
+ viewport, a Globe visibility conflict, an unresolvable camera, and failed post-fit containment.
236
+ Correct the scene or redeploy the Map as directed; do not retry it unchanged. Unsupported
237
+ attribution grammar or glyphs, excessive attribution, and a block that cannot fit use the same
238
+ non-retryable `422` boundary.
239
+
240
+ Other bounded Hosted JSON failures throw `StaticMapError`. It preserves HTTP `status` and any safe
241
+ `code`, `requiredPlan`, `retryable`, `requestId`, or `remainingUnits` fields the server supplied;
242
+ absent fields are `null`. `StaticMapRequestError` extends the same class. Malformed, oversized, or
243
+ unsafe remote documents remain generic errors and are never reflected to the caller.
244
+
245
+ `STATIC_MAPS_PLAN_UNAVAILABLE` is a non-retryable Pro requirement. Its `requiredPlan` is
246
+ `starter-v1`; select a Pro Team or use a non-static fallback. It occurs before a Static Maps
247
+ operation or API-unit charge. A different `403` is a credential or Map-coverage failure.
248
+
249
+ ## API entry points
250
+
251
+ The package has four deliberately separate entry points:
252
+
253
+ - `@tileflow/static/scene`, scene validation and normalization: `staticSceneSchema`,
254
+ `validateStaticScene`, and `normalizeStaticScene`;
255
+ - `@tileflow/static/overlays`, overlay authoring and MapLibre compilation: `line`, `circle`,
256
+ `marker`, `polygon`, `symbol`, and `compileStaticOverlays`;
257
+ - `@tileflow/static/manifest`, renderer identity: `createRenderManifest`,
258
+ `validateStaticRenderManifest`, `hashRenderManifest`, and `hashStaticSceneRequest`;
259
+ - `@tileflow/static/client`, bounded Hosted transport: `prepareStaticMapRequest`,
260
+ `createStaticMap`, `precacheStaticMap`, and `requestStaticMapUntilReady`.
261
+
262
+ The package has no root entry point.
263
+
264
+ `StaticRenderManifest` is the single strict immutable input contract between a resolved Hosted style
265
+ and a Static Maps renderer. It binds safe attribution, exact source identity, semantic placement
266
+ anchors, and resolved sprite dimensions. Its top-level `mapId` identifies the resolved destination
267
+ while `scene.map` retains the portable map name supplied by the application. It is unrelated to the
268
+ runtime delivery manifest generated by application build or deploy workflows.
269
+
270
+ ## Operation identity and usage
271
+
272
+ Create one idempotency key per intentional create/precache action and retain it across network
273
+ retries. Reusing the key with the same normalized scene returns the stored result; reusing it with a
274
+ different scene returns 409. A successful paid operation reports `unitCost: 15`, shared
275
+ `remainingUnits`, its durable `operationId`, cache reuse, hash, and immutable image URL. An
276
+ unbounded Pro service reports `remainingUnits: null`. Creation helpers require the single strict
277
+ result contract, including `resultVersion: 1` and attribution. A live
278
+ equal-hash render may return `202`; the helper polls with the same body/key within its bounded wait.
279
+ `maxWaitMs` is the total client completion budget, including network, response parsing, and polling
280
+ delays; `signal` cancels the same complete operation. The helper aborts in-flight work when either
281
+ boundary is reached. It rejects malformed responses, non-HTTP(S) image URLs, and any change of
282
+ durable operation ID while polling.
283
+
284
+ Framework adapters can call `prepareStaticMapRequest(scene)` once and pass its result to
285
+ `requestStaticMapUntilReady(request, {createUrl, idempotencyKey, ...})`. The prepared request uses
286
+ the same normalized scene for its `sceneKey` and HTTP body, so equivalent omitted/explicit defaults
287
+ deduplicate consistently without duplicating the polling implementation.
288
+
289
+ Free cannot initiate Static Maps work. Pro consumes 15 shared API units for each successful
290
+ logical operation, including a distinct-key cache reuse. Downloading an immutable PNG, JPEG, or WebP
291
+ consumes zero units.
292
+
293
+ ## Team credentials
294
+
295
+ A Team credential can serve multiple Maps. Pass `mapId` in the options to `createStaticMap` or
296
+ `precacheStaticMap`; it must be a Managed Map ID such as `map_1234567890abcdef`. The client sends
297
+ `X-Tileflow-Map-Id` separately from the portable scene. `scene.map` remains the deployed environment
298
+ name. The Hosted API must support unified Team credentials and authorize the selected Map.
299
+ Existing Map-scoped keys remain usable without this option. Keep either key on a trusted server.