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

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 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,
@@ -45,6 +49,66 @@ or 16,777,216 total pixels.
45
49
  so explicit and omitted PNG requests share identity. JPEG and WebP use a fixed encoder quality;
46
50
  there is no public quality option.
47
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
+
48
112
  ## Attribution
49
113
 
50
114
  New renders default to `attribution: {mode: 'embedded', position: 'auto'}` without adding that
@@ -81,11 +145,16 @@ links, and `platform-notice` or `team-declared` authority; they never contain so
81
145
  resource IDs. Embedded results return the resolved corner. Changing mode or requested position
82
146
  changes scene and artifact identity.
83
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
+
84
152
  ## Automatic framing
85
153
 
86
- `camera.type: 'auto'` fits the complete nominal footprint of every declared marker, circle, line,
87
- and polygon. It works with Mercator and Globe styles when the geometry can be shown. It never clips
88
- silently.
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.
89
158
 
90
159
  ```ts
91
160
  camera: {
@@ -114,18 +183,25 @@ yet be drawn there.
114
183
  Deterministic request failures return `422`, set `retryable: false`, and preserve a stable code,
115
184
  reason, and bounded details. `validateStaticScene` returns that document; request helpers throw
116
185
  `StaticMapRequestError` either locally or from the Hosted response. The reasons distinguish an empty
117
- scene, an ambiguous antimeridian path, an out-of-range overlay latitude, an insufficient viewport,
118
- a Globe visibility conflict, an unresolvable camera, and failed post-fit containment. Correct the
119
- scene; do not retry it unchanged. Unsupported attribution grammar or glyphs, excessive attribution,
120
- and a block that cannot fit use the same non-retryable `422` boundary.
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.
121
197
 
122
198
  The package has four deliberately separate surfaces, all available from the root for compatibility:
123
199
 
124
200
  - scene validation and normalization: `staticSceneSchema`, `validateStaticScene`, and
125
201
  `normalizeStaticScene`;
126
- - overlay authoring and MapLibre compilation: `line`, `circle`, `marker`, `polygon`, and
202
+ - overlay authoring and MapLibre compilation: `line`, `circle`, `marker`, `polygon`, `symbol`, and
127
203
  `compileStaticOverlays`;
128
- - renderer identity: `createRenderManifestV1`, `createRenderManifestV2`,
204
+ - renderer identity: `createRenderManifest`,
129
205
  `validateStaticRenderManifest`, `hashRenderManifest`, and `hashStaticSceneRequest`;
130
206
  - bounded Hosted transport: `prepareStaticMapRequest`, `createStaticMap`, `precacheStaticMap`, and
131
207
  `requestStaticMapUntilReady`.
@@ -133,20 +209,18 @@ The package has four deliberately separate surfaces, all available from the root
133
209
  Applications that need only one surface can use `@tileflow/static/scene`, `/overlays`, `/manifest`,
134
210
  or `/client`. The root remains a compatibility entry point.
135
211
 
136
- `StaticRenderManifest` is the versioned immutable input contract between a resolved Hosted style and
137
- a Static Maps renderer. Manifest v1 remains the exact historical no-attribution contract; new Hosted
138
- work uses strict v2 with resolved safe entries and immutable provenance. `createRenderManifest`
139
- remains the v1 compatibility alias. Its top-level `mapId` identifies the resolved destination while
140
- `scene.map` retains the portable map name supplied by the application. It is unrelated to the
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
141
216
  runtime delivery manifest generated by application build or deploy workflows.
142
217
 
143
218
  Create one idempotency key per intentional create/precache action and retain it across network
144
219
  retries. Reusing the key with the same normalized scene returns the stored result; reusing it with a
145
220
  different scene returns 409. A successful paid operation reports `unitCost: 15`, shared
146
221
  `remainingUnits`, its durable `operationId`, cache reuse, hash, and immutable image URL. An
147
- unbounded Starter service reports `remainingUnits: null`. Creation helpers request strict result v2,
148
- including `resultVersion: 2` and required attribution. They reject a legacy success rather than
149
- claiming notices that were never produced. A live
222
+ unbounded Starter service reports `remainingUnits: null`. Creation helpers require the single strict
223
+ result contract, including `resultVersion: 1` and attribution. A live
150
224
  equal-hash render may return `202`; the helper polls with the same body/key within its bounded wait.
151
225
  `maxWaitMs` is the total client completion budget, including network, response parsing, and polling
152
226
  delays; `signal` cancels the same complete operation. The helper aborts in-flight work when either