@tileflow/react-native 0.1.0-alpha.6 → 0.1.0-alpha.8

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
@@ -1,6 +1,6 @@
1
1
  # @tileflow/react-native
2
2
 
3
- `@tileflow/react-native` provides a Tileflow `Map` backed by MapLibre Native on iOS and Android. It is pre-release. The first alpha release requires the bootstrap and Trusted Publisher checks in the [publishing guide](https://github.com/tileflow/tileflow-sdk/blob/main/PUBLISHING.md).
3
+ `@tileflow/react-native` provides a Tileflow `Map` backed by MapLibre Native on iOS and Android. It is pre-release. Publication requires the repository’s protected release workflow.
4
4
 
5
5
  The package targets exactly React 19.2.0, React Native 0.83.10 and `@maplibre/maplibre-react-native` 11.5.0, with MapLibre Native Android 13.6.1 and iOS 6.31.0 through the pinned integration below. Expo consumers use Expo 55.0.31 with a native development build; Expo Go does not contain the required native modules.
6
6
 
@@ -99,7 +99,40 @@ Theme and `timeOfDay` changes cross-fade over 450 ms by default: a snapshot of t
99
99
  <Map source={source} themeBlend={{themes: ['night', 'dusk', 'day'], position}} style={{flex: 1}} />
100
100
  ```
101
101
 
102
- The first blend of a set of themes prepares every theme's style and replaces the native style once; moving `position` later changes the map without loading. Removing `themeBlend` returns to `theme`. Both keep the same native Map, context and session, and `ready` events wait for the fade. The device's reduce-motion setting changes at once. See [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/theme-transitions-and-blends.md#react-native) for what follows the position on native maps.
102
+ The first blend of a set of themes prepares every theme's style and replaces the native style once; moving `position` later changes the map without loading. Removing `themeBlend` returns to `theme`. Both keep the same native Map, context and session, and `ready` events wait for the fade. The device's reduce-motion setting changes at once. See [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for what follows the position on native maps.
103
+
104
+ ## Boundary choropleths
105
+
106
+ A map that declares `boundaryAreas` and a `boundaryChoropleth()` without compiled `values` reads
107
+ its colors from feature-state. `boundaryFeatureState` sets that state from the application, with
108
+ the same rows and options as `useBoundaryFeatureState` on the web: rows keyed by the source's
109
+ feature ID (`id`, or `ref` when the map promotes it), `labels` and `state`:
110
+
111
+ <!-- docs:check -->
112
+
113
+ ```tsx
114
+ import {Map, type MapSource} from '@tileflow/react-native';
115
+ import {useMemo} from 'react';
116
+
117
+ export function UnemploymentMap({
118
+ source,
119
+ rates,
120
+ }: {
121
+ source: MapSource;
122
+ rates: ReadonlyMap<number, number>;
123
+ }) {
124
+ // Memoize the values: each new object replaces the previous ones.
125
+ const values = useMemo(
126
+ () => ({joinBy: 'id' as const, rows: [...rates].map(([key, value]) => ({key, value}))}),
127
+ [rates],
128
+ );
129
+ return <Map source={source} boundaryFeatureState={{values}} style={{flex: 1}} />;
130
+ }
131
+ ```
132
+
133
+ Values survive theme changes: they are set again once the new style has loaded. `values: null`
134
+ removes them. Rows keyed by codes the polygons do not carry are joined before they reach the app,
135
+ on a server or at build time.
103
136
 
104
137
  ## Camera
105
138
 
@@ -144,16 +177,12 @@ Relative URLs are resolved with Core's native URL policy. Protected resources ar
144
177
 
145
178
  Glyph templates use a finite set of exact font-stack expansions. A later theme may extend that same template only through an acknowledged append-only finite union; it cannot change the resource scope, origin or identity.
146
179
 
147
- See [Private native resource admission](./docs/native-admission.md) for the transport and security boundaries.
148
-
149
180
  ## Hosted mobile application configuration
150
181
 
151
182
  Hosted native session delivery uses a scoped, revocable, publishable **mobile application credential** configured once in the native application. It authenticates the distributed application, not its end user. The manifest supplies `mapId`, `apiUrl` and `usageMode`; Tileflow requires the manifest API origin to exactly match the configured canonical HTTPS origin before bootstrap.
152
183
 
153
184
  There is intentionally no credential prop, JS setter, Provider, client object, package-name/bundle-ID authentication or attestation path in this version.
154
185
 
155
- See [Native application configuration](./docs/native-configuration.md) for the exact Android resource and iOS Info.plist keys, credential grammar, origin normalization, rotation/revocation guidance and threat model.
156
-
157
186
  ## Map options and presentation
158
187
 
159
188
  The public `mapOptions` object remains a positive allowlist. It includes the currently supported gesture/control options only. Style inputs, request transformation, headers and upstream lifecycle callbacks remain owned by Tileflow. Runtime validation rejects forged extra keys without reflecting their values.
@@ -169,10 +198,44 @@ The public lifecycle surface remains:
169
198
  - `onReadinessChange`;
170
199
  - `onThemeChange`;
171
200
  - controlled `onViewChange`;
172
- - `ref.getSourceState()`.
201
+ - `ref.getSourceState()`;
202
+ - `ref.retry()`.
173
203
 
174
204
  `getSourceState()` returns only the last safe projected source snapshot. Errors use existing bounded codes/fields/kinds. No URL, response body, native event, credential, grant, session object, native handle or raw cause enters public callbacks, refs or serializable state.
175
205
 
206
+ `onError` reports `source-error`, `renderer-error` and, for Hosted session delivery, `session-error`. A `session-error` means Tileflow refused the session: the mobile credential was rejected (`NATIVE_SESSION_CREDENTIAL_REJECTED`), it does not authorize the Map (`NATIVE_SESSION_MAP_MISMATCH`), the Map was not found (`NATIVE_SESSION_MAP_NOT_FOUND`), its view or spending limit was reached (`NATIVE_SESSION_QUOTA_EXCEEDED`), or the service refused the session for another reason that trying again cannot change (`NATIVE_SESSION_REJECTED`), such as a Map that does not use session delivery. For `NATIVE_SESSION_REJECTED`, `event.error.reason` is the service's code when it sent one, for example `MOBILE_SESSION_MODE_REQUIRED`; it is a bounded identifier, never a message or response body. A `session-error` can arrive after the first load, when a renewal is refused. The map keeps what it has drawn but loads nothing new until you call `ref.retry()` or change the source:
207
+
208
+ ```tsx
209
+ import {Map, type MapRef} from '@tileflow/react-native';
210
+ import {useRef} from 'react';
211
+
212
+ export function StoreMap() {
213
+ const map = useRef<MapRef>(null);
214
+ return (
215
+ <Map
216
+ ref={map}
217
+ source={{map: 'stores', manifestUrl: 'https://maps.example.com/tileflow/manifest.json'}}
218
+ onError={(event) => {
219
+ if (
220
+ event.type === 'session-error' &&
221
+ event.error.code === 'NATIVE_SESSION_QUOTA_EXCEEDED'
222
+ ) {
223
+ // Show your own notice; call map.current?.retry() once the limit is raised.
224
+ } else if (
225
+ event.type === 'session-error' &&
226
+ event.error.code === 'NATIVE_SESSION_REJECTED'
227
+ ) {
228
+ // event.error.reason, such as 'MOBILE_SESSION_MODE_REQUIRED', names the cause.
229
+ }
230
+ }}
231
+ style={{flex: 1}}
232
+ />
233
+ );
234
+ }
235
+ ```
236
+
237
+ Service outages, timeouts and rate limiting are not session errors. The map keeps using its current grant while it is valid and requests another after an increasing delay, from one second up to one minute, or after the `Retry-After` the service sends. A first load that failed this way prepares again on its own. `ref.retry()` also loads again after a source or renderer error, and changes nothing while the map is shown.
238
+
176
239
  ## Native integration
177
240
 
178
241
  Autolinking registers the private Android/iOS modules used by the mounted lifecycle. Android depends on the exact MapLibre React Native project and MapLibre Native 13.6.1. iOS uses the existing MapLibre React Native CocoaPod plus the exact MapLibre Native 6.31.0 Swift Package Manager product.
@@ -184,7 +247,7 @@ $MLRN.post_install(installer)
184
247
  tileflow_native_admission_post_install(installer)
185
248
  ```
186
249
 
187
- Do not add a second MapLibre Native CocoaPod. See [Private native resource admission](./docs/native-admission.md) for installation-order and teardown details.
250
+ Do not add a second MapLibre Native CocoaPod.
188
251
 
189
252
  ## Source-checkout harness
190
253
 
@@ -213,8 +276,7 @@ remain in native vector or GeoJSON layers and are selected through semantic rend
213
276
  queries rather than thousands of React marker views.
214
277
 
215
278
  The application owns persistent selection and its presentation. The SDK emits normalized
216
- annotation or POI targets but no popup, callout, tooltip, sheet, panel or modal renderer. See
217
- [Native interaction contract](./docs/native-interactions.md).
279
+ annotation or POI targets but no popup, callout, tooltip, sheet, panel or modal renderer.
218
280
 
219
281
  ## Current boundary
220
282
 
@@ -234,7 +296,3 @@ Source and tests describe contracts; they do not establish that a native build,
234
296
  fix arrives. Applications can compose a validated foreground fix through the existing accessible
235
297
  annotation and controlled-camera contracts while keeping permission, provider lifetime, privacy
236
298
  policy, status UI and recenter controls outside Tileflow.
237
-
238
- See [Application-owned foreground location](./docs/native-location.md) for the package-owned
239
- source-checkout recipe. The recipe is excluded from package exports and packed runtime files and
240
- imports no concrete location provider.
@@ -6,7 +6,10 @@ internal object AdmissionBootstrapLimits {
6
6
  const val QUEUE = 32
7
7
  const val REQUEST_BYTES = 2048
8
8
  const val RESPONSE_BYTES = 65536
9
- const val TIMEOUT_MS = 30000L
9
+ const val RETRY_AFTER_CHARACTERS = 64
10
+ // Well inside the 30 s ticket and batch deadlines, so a stalled renewal fails its batch
11
+ // instead of letting the context retire under it.
12
+ const val TIMEOUT_MS = 10000L
10
13
  }
11
14
 
12
15
  internal class AdmissionBootstrapRequest(
@@ -18,7 +21,7 @@ internal class AdmissionBootstrapRequest(
18
21
  override fun toString() = "AdmissionBootstrapRequest(redacted)"
19
22
  }
20
23
 
21
- internal class AdmissionBootstrapReply(val status: Int, val cacheControl: String, val body: ByteArray) {
24
+ internal class AdmissionBootstrapReply(val status: Int, val cacheControl: String, val body: ByteArray, val retryAfter: String = "") {
22
25
  override fun toString() = "AdmissionBootstrapReply(redacted)"
23
26
  }
24
27
 
@@ -86,7 +89,8 @@ internal class AdmissionBootstrap(
86
89
  work.network = network.start(AdmissionBootstrapRequest(url, credential, body) { mayStart(work) }) { reply ->
87
90
  scheduler.dispatch {
88
91
  val valid = mayStart(work) && reply != null && reply.status in 100..599 &&
89
- reply.cacheControl.length <= 1024 && reply.body.size <= AdmissionBootstrapLimits.RESPONSE_BYTES
92
+ reply.cacheControl.length <= 1024 && reply.retryAfter.length <= AdmissionBootstrapLimits.RETRY_AFTER_CHARACTERS &&
93
+ reply.body.size <= AdmissionBootstrapLimits.RESPONSE_BYTES
90
94
  finish(work, if (valid) reply else null)
91
95
  }
92
96
  }
@@ -55,6 +55,8 @@ internal class AdmissionBootstrapOkHttpNetwork : AdmissionBootstrapNetwork {
55
55
  val reply = try {
56
56
  response.use {
57
57
  val cacheControl = it.header("cache-control") ?: ""
58
+ // An oversized Retry-After is ignored rather than failing the reply.
59
+ val retryAfter = (it.header("retry-after") ?: "").takeIf { value -> value.length <= AdmissionBootstrapLimits.RETRY_AFTER_CHARACTERS } ?: ""
58
60
  val body = it.body
59
61
  if (cacheControl.length > 1024 || body == null || body.contentLength() > AdmissionBootstrapLimits.RESPONSE_BYTES) throw IOException("Invalid bootstrap response")
60
62
  val bytes = ByteArrayOutputStream()
@@ -67,7 +69,7 @@ internal class AdmissionBootstrapOkHttpNetwork : AdmissionBootstrapNetwork {
67
69
  bytes.write(buffer, 0, count)
68
70
  }
69
71
  }
70
- AdmissionBootstrapReply(it.code, cacheControl, bytes.toByteArray())
72
+ AdmissionBootstrapReply(it.code, cacheControl, bytes.toByteArray(), retryAfter)
71
73
  }
72
74
  } catch (_: Exception) { null }
73
75
  complete(reply)
@@ -155,8 +155,10 @@ internal class AdmissionEngine(
155
155
  work = item
156
156
  context.work[item.id] = item
157
157
  item.timer = scheduler.after(AdmissionLimits.WAIT_MS) {
158
- if (context.batch?.tickets?.contains(item.id) == true) retire(context.id)
159
- else fail(item)
158
+ // A slow renewal fails only this request. JavaScript still answers its batch, and the
159
+ // batch deadline alone retires a context whose JavaScript stopped answering.
160
+ if (context.batch?.tickets?.contains(item.id) == true) event(context, "cancel", mapOf("tickets" to listOf(item.id)))
161
+ fail(item)
160
162
  }
161
163
  scheduler.dispatch { drain(context) }
162
164
  }
@@ -125,7 +125,7 @@ class TileflowNativeAdmissionModule(context: ReactApplicationContext) : ReactCon
125
125
  (bootstrapRequests ?: invalid()).start(context, request, url, credential, body) { reply ->
126
126
  if (reply == null) reject(promise)
127
127
  else promise.resolve(Arguments.makeNativeMap(mapOf(
128
- "status" to reply.status, "cacheControl" to reply.cacheControl,
128
+ "status" to reply.status, "cacheControl" to reply.cacheControl, "retryAfter" to reply.retryAfter,
129
129
  "bodyBase64" to Base64.encodeToString(reply.body, Base64.NO_WRAP))))
130
130
  }
131
131
  } catch (_: Exception) { reject(promise) }
@@ -1,7 +1,7 @@
1
1
  import { MapProps as MapProps$1 } from '@maplibre/maplibre-react-native';
2
2
  import { ReactElement, ReactNode, Ref } from 'react';
3
3
  import { ViewProps } from 'react-native';
4
- import { TileflowNativeInitialView, TileflowNativeInitialViewOptions, TileflowNativeSource, TileflowNativeSourceOptions, TileflowNativeSourceState, TileflowNativeSourceError } from '@tileflow/core/native';
4
+ import { TileflowNativeInitialView, TileflowNativeInitialViewOptions, TileflowNativeSource, TileflowNativeSourceOptions, TileflowBoundaryValues, TileflowBoundaryFamily, TileflowNativeSourceState, TileflowNativeSourceError } from '@tileflow/core/native';
5
5
  import { TileflowAnnotation, TileflowInteractionBinding, TileflowInteractionEvent, TileflowResolvedAnnotationTarget, TileflowResolvedPoiFeatureTarget, TileflowInteractionDiagnostic, TileflowAnnotationViewContext } from '@tileflow/interactions';
6
6
 
7
7
  /** Marker composition only. Selection presentation and native handles are not part of this context. */
@@ -58,6 +58,22 @@ type MapSourceProps = Readonly<{
58
58
  */
59
59
  themeBlend?: MapThemeBlend;
60
60
  }>;
61
+ /**
62
+ * Application values on the map's Boundaries areas, for a choropleth that reads them with
63
+ * `feature-state`. The same rows and options as `useBoundaryFeatureState` on the web: rows keyed by
64
+ * the source's feature ID (`id`, or `ref` when the map promotes it), joined with
65
+ * `joinBoundaryRows` when the data carries other codes. Values survive theme changes; `null`
66
+ * removes them.
67
+ */
68
+ type MapBoundaryFeatureState = Readonly<{
69
+ values: TileflowBoundaryValues | null;
70
+ /** Defaults to `boundaries`. */
71
+ family?: TileflowBoundaryFamily;
72
+ /** Also set the values on `boundary_label` points, for labels styled by value. */
73
+ labels?: boolean;
74
+ /** Feature-state key; it must match the choropleth's `state`. Defaults to `value`. */
75
+ state?: string;
76
+ }>;
61
77
  type AllowedMapOptions = 'dragPan' | 'touchZoom' | 'doubleTapZoom' | 'doubleTapHoldZoom' | 'touchRotate' | 'touchPitch' | 'compass' | 'compassHiddenFacingNorth' | 'scaleBar';
62
78
  type OwnedMapOptions = Exclude<keyof MapProps$1, AllowedMapOptions> | 'container' | 'styleURL' | 'styleUrl' | 'transformRequest' | 'requestTransform' | 'requestHeaders';
63
79
  /** A positive allowlist. Style, interception, view and lifecycle remain adapter-owned. */
@@ -69,6 +85,7 @@ type MapPresentationProps = Readonly<{
69
85
  style?: ViewProps['style'];
70
86
  testID?: ViewProps['testID'];
71
87
  mapOptions?: MapOptions;
88
+ boundaryFeatureState?: MapBoundaryFeatureState;
72
89
  }>;
73
90
  type TileflowReady = Extract<TileflowNativeSourceState, {
74
91
  status: 'ready';
@@ -92,9 +109,29 @@ type MapSourceState = Readonly<{
92
109
  generation: number;
93
110
  error: MapSourceError;
94
111
  }>;
95
- /** A synchronous read of the last source snapshot. Does not trigger loading or native commands. */
112
+ /**
113
+ * The Hosted session stopped: its credential, Map or quota was rejected, or Tileflow refused the
114
+ * session for another reason that trying again will not change (`NATIVE_SESSION_REJECTED`). The map
115
+ * keeps what it has drawn and loads nothing new until `ref.retry()` or another source. Service
116
+ * outages and rate limits retry on their own and are not reported.
117
+ */
118
+ type MapSessionError = Readonly<{
119
+ code: 'NATIVE_SESSION_CREDENTIAL_REJECTED' | 'NATIVE_SESSION_MAP_MISMATCH' | 'NATIVE_SESSION_MAP_NOT_FOUND' | 'NATIVE_SESSION_QUOTA_EXCEEDED' | 'NATIVE_SESSION_REJECTED' | 'NATIVE_SESSION_INPUT_INVALID';
120
+ kind: 'terminal';
121
+ /**
122
+ * For `NATIVE_SESSION_REJECTED`, the service's code when its answer carried one, such as
123
+ * `MOBILE_SESSION_MODE_REQUIRED`. A bounded identifier, never a message or response body.
124
+ */
125
+ reason?: string;
126
+ }>;
96
127
  type MapRef = Readonly<{
128
+ /** A synchronous read of the last source snapshot. Does not trigger loading or native commands. */
97
129
  getSourceState(): MapSourceState | undefined;
130
+ /**
131
+ * Loads again a map that stopped: after a `session-error` once its cause is resolved, for
132
+ * example a raised quota, or after a source or renderer error. A shown map is unaffected.
133
+ */
134
+ retry(): void;
98
135
  }>;
99
136
  /** The current style was accepted by the renderer; this alone does not establish a rendered frame. */
100
137
  type MapLoadEvent = Readonly<{
@@ -110,6 +147,10 @@ type MapErrorEvent = Readonly<{
110
147
  }> | Readonly<{
111
148
  type: 'renderer-error';
112
149
  generation: number;
150
+ }> | Readonly<{
151
+ type: 'session-error';
152
+ generation: number;
153
+ error: MapSessionError;
113
154
  }>;
114
155
  /** The renderer owner must confirm readiness; a ready manifest alone is insufficient. */
115
156
  type MapReadinessChangeEvent = Readonly<{
@@ -168,4 +209,4 @@ type MapCameraProps = Readonly<{
168
209
  /** Complete Tileflow source, presentation, mount-stable camera and portable interaction inputs. */
169
210
  type MapProps<TAnnotation extends TileflowAnnotation = TileflowAnnotation> = MapBaseProps & MapCameraProps & MapInteractionProps<TAnnotation>;
170
211
 
171
- export type { MapThemeTransition as A, MapView as M, MapViewChangeEvent as a, MapInitialViewInputs as b, MapCameraProps as c, MapProps as d, MapBaseProps as e, MapColorScheme as f, MapErrorEvent as g, MapEventHandlers as h, MapInteractionEvent as i, MapInteractionProps as j, MapLoadEvent as k, MapMarkerRenderContext as l, MapMarkerRenderer as m, MapOptions as n, MapPresentationProps as o, MapReadinessChangeEvent as p, MapRef as q, MapSelection as r, MapSource as s, MapSourceError as t, MapSourceProps as u, MapSourceState as v, MapTheme as w, MapThemeBlend as x, MapThemeChangeEvent as y, MapThemeSelection as z };
212
+ export type { MapThemeChangeEvent as A, MapThemeSelection as B, MapThemeTransition as C, MapView as M, MapViewChangeEvent as a, MapInitialViewInputs as b, MapCameraProps as c, MapProps as d, MapBaseProps as e, MapBoundaryFeatureState as f, MapColorScheme as g, MapErrorEvent as h, MapEventHandlers as i, MapInteractionEvent as j, MapInteractionProps as k, MapLoadEvent as l, MapMarkerRenderContext as m, MapMarkerRenderer as n, MapOptions as o, MapPresentationProps as p, MapReadinessChangeEvent as q, MapRef as r, MapSelection as s, MapSessionError as t, MapSource as u, MapSourceError as v, MapSourceProps as w, MapSourceState as x, MapTheme as y, MapThemeBlend as z };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { TileflowAnnotation } from '@tileflow/interactions';
3
3
  export { TileflowAnnotation, TileflowInteractionBinding, TileflowInteractionCoordinate, TileflowInteractionDiagnostic, TileflowPoiCategory, TileflowResolvedAnnotationTarget, TileflowResolvedPoiFeatureTarget } from '@tileflow/interactions';
4
- import { d as MapProps } from './contract-By3URNxS.js';
5
- export { e as MapBaseProps, c as MapCameraProps, f as MapColorScheme, g as MapErrorEvent, h as MapEventHandlers, b as MapInitialViewInputs, i as MapInteractionEvent, j as MapInteractionProps, k as MapLoadEvent, l as MapMarkerRenderContext, m as MapMarkerRenderer, n as MapOptions, o as MapPresentationProps, p as MapReadinessChangeEvent, q as MapRef, r as MapSelection, s as MapSource, t as MapSourceError, u as MapSourceProps, v as MapSourceState, w as MapTheme, x as MapThemeBlend, y as MapThemeChangeEvent, z as MapThemeSelection, A as MapThemeTransition, M as MapView, a as MapViewChangeEvent } from './contract-By3URNxS.js';
4
+ import { d as MapProps } from './contract-BWT1jxqg.js';
5
+ export { e as MapBaseProps, f as MapBoundaryFeatureState, c as MapCameraProps, g as MapColorScheme, h as MapErrorEvent, i as MapEventHandlers, b as MapInitialViewInputs, j as MapInteractionEvent, k as MapInteractionProps, l as MapLoadEvent, m as MapMarkerRenderContext, n as MapMarkerRenderer, o as MapOptions, p as MapPresentationProps, q as MapReadinessChangeEvent, r as MapRef, s as MapSelection, t as MapSessionError, u as MapSource, v as MapSourceError, w as MapSourceProps, x as MapSourceState, y as MapTheme, z as MapThemeBlend, A as MapThemeChangeEvent, B as MapThemeSelection, C as MapThemeTransition, M as MapView, a as MapViewChangeEvent } from './contract-BWT1jxqg.js';
6
6
  import '@maplibre/maplibre-react-native';
7
7
  import 'react-native';
8
8
  import '@tileflow/core/native';