@tileflow/react 0.1.0-alpha.25 → 0.1.0-alpha.26
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 +16 -13
- package/dist/index.js +15 -35
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ import {Map} from '@tileflow/react';
|
|
|
79
79
|
export function App() {
|
|
80
80
|
return (
|
|
81
81
|
<Map
|
|
82
|
-
source={{
|
|
82
|
+
source={{map: 'madrid'}}
|
|
83
83
|
theme="system"
|
|
84
84
|
center={[-3.7038, 40.4168]}
|
|
85
85
|
zoom={12}
|
|
@@ -89,19 +89,21 @@ export function App() {
|
|
|
89
89
|
}
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
Coordinates are `[longitude, latitude]`. `source
|
|
93
|
-
not a hosted `map_...` identifier.
|
|
94
|
-
For a subpath or external host,
|
|
95
|
-
bundler configuration or search
|
|
92
|
+
Coordinates are `[longitude, latitude]`. `source` is one object, `{map, manifestUrl?}`.
|
|
93
|
+
`source.map` must match the config's portable map ID, not a hosted `map_...` identifier.
|
|
94
|
+
The default manifest URL is exactly `/tileflow/manifest.json`. For a subpath or external host,
|
|
95
|
+
provide `manifestUrl` in the source; the component does not infer bundler configuration or search
|
|
96
|
+
for assets.
|
|
96
97
|
|
|
97
98
|
`theme` selects a published concrete theme. Omission uses `defaultTheme`; `system` requires an
|
|
98
99
|
explicit light/dark mapping, which Streets supplies. Theme changes preserve the MapLibre instance,
|
|
99
100
|
camera, and interactions, and roll back on failure. `onThemeChange` reports transitions.
|
|
100
101
|
|
|
101
102
|
`mapOptions` accepts native MapLibre options except `container` and `style`. Direct camera props
|
|
102
|
-
take priority over `mapOptions`, then the manifest view, then shared defaults.
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
take priority over `mapOptions`, then the manifest view, then shared defaults. `Map` always selects
|
|
104
|
+
a Tileflow map through its manifest; it has no renderer discriminator or direct-style mode.
|
|
105
|
+
The obsolete source fields `kind` and `style` are rejected. For a completely unmanaged map, use
|
|
106
|
+
`maplibre-gl` directly rather than a Tileflow component.
|
|
105
107
|
|
|
106
108
|
## Add annotations and popups
|
|
107
109
|
|
|
@@ -141,7 +143,7 @@ export function PropertyMap() {
|
|
|
141
143
|
|
|
142
144
|
return (
|
|
143
145
|
<Map
|
|
144
|
-
source={{
|
|
146
|
+
source={{map: 'madrid'}}
|
|
145
147
|
annotations={annotations}
|
|
146
148
|
interactionState={state}
|
|
147
149
|
onInteractionStateChange={setState}
|
|
@@ -178,10 +180,11 @@ Keep tooltips non-interactive; put buttons, links, and forms in popups.
|
|
|
178
180
|
|
|
179
181
|
## Display an image or create a render
|
|
180
182
|
|
|
181
|
-
`<Map mode="image">` displays an
|
|
182
|
-
manifest
|
|
183
|
-
|
|
184
|
-
not
|
|
183
|
+
`<Map mode="image">` displays an explicit `imageUrl` or derives an image URL from the selected
|
|
184
|
+
manifest map's `mapId`, `apiUrl`, concrete theme and view. It still requires a valid Tileflow source.
|
|
185
|
+
It does not create a static render, poll an operation, or load MapLibre. A local style build alone
|
|
186
|
+
does not create that image. Annotations, semantic bindings, and interaction state are not supported
|
|
187
|
+
in image mode.
|
|
185
188
|
|
|
186
189
|
To request a new static render, use `StaticMap` from `@tileflow/react/static`. First install the
|
|
187
190
|
shared client/types used by this example:
|
package/dist/index.js
CHANGED
|
@@ -37,8 +37,7 @@ import {
|
|
|
37
37
|
resolveTileflowRuntimeStyle,
|
|
38
38
|
resolveTileflowRuntimeTheme,
|
|
39
39
|
resolveTileflowRuntimeView,
|
|
40
|
-
resolveTileflowStaticImageUrl
|
|
41
|
-
shouldLoadTileflowManifest
|
|
40
|
+
resolveTileflowStaticImageUrl
|
|
42
41
|
} from "@tileflow/core/runtime";
|
|
43
42
|
import {
|
|
44
43
|
createTileflowMapLibreDomRuntime,
|
|
@@ -175,9 +174,6 @@ function validateTileflowMapStyleInputs(input) {
|
|
|
175
174
|
if (input.theme !== void 0 && !validateTileflowThemeSelection(input.theme)) {
|
|
176
175
|
return { error: 'theme must be a concrete portable theme name or "system"', ok: false };
|
|
177
176
|
}
|
|
178
|
-
if (input.theme !== void 0 && input.source.kind !== "tileflow") {
|
|
179
|
-
return { error: "theme is only valid with a tileflow source", ok: false };
|
|
180
|
-
}
|
|
181
177
|
return { ok: true };
|
|
182
178
|
}
|
|
183
179
|
function assertTileflowMapStyleInputs(input) {
|
|
@@ -253,16 +249,14 @@ function Map2(props) {
|
|
|
253
249
|
} = props;
|
|
254
250
|
const generalRenderPopup = renderPopup;
|
|
255
251
|
const generalRenderTooltip = renderTooltip;
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const sourceManifestUrl = source.kind === "tileflow" ? source.manifestUrl : void 0;
|
|
259
|
-
const sourceStyle = source.kind === "maplibre" ? source.style : void 0;
|
|
252
|
+
const sourceMap = source.map;
|
|
253
|
+
const sourceManifestUrl = source.manifestUrl;
|
|
260
254
|
const runtimeSource = useMemo(
|
|
261
|
-
() =>
|
|
262
|
-
[
|
|
255
|
+
() => ({ manifestUrl: sourceManifestUrl, map: sourceMap }),
|
|
256
|
+
[sourceManifestUrl, sourceMap]
|
|
263
257
|
);
|
|
264
|
-
const mapName = runtimeSource.
|
|
265
|
-
const manifestUrl = runtimeSource.
|
|
258
|
+
const mapName = runtimeSource.map;
|
|
259
|
+
const manifestUrl = runtimeSource.manifestUrl ?? defaultTileflowManifestUrl;
|
|
266
260
|
const preparedAnnotations = useMemo(
|
|
267
261
|
() => prepareTileflowReactAnnotations(annotations),
|
|
268
262
|
[annotations]
|
|
@@ -328,22 +322,12 @@ function Map2(props) {
|
|
|
328
322
|
const resolvedCaptureId = normalizeTileflowCaptureId(captureId);
|
|
329
323
|
const resolvedMode = resolveTileflowMapMode({ mode });
|
|
330
324
|
const isImageMode = resolvedMode === "image";
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
});
|
|
334
|
-
const manifestRequestKey = shouldLoadManifest ? JSON.stringify([manifestUrl, mapName]) : "not-needed";
|
|
335
|
-
const currentManifestResolution = manifestResolution.key === manifestRequestKey ? manifestResolution : {
|
|
336
|
-
key: manifestRequestKey,
|
|
337
|
-
map: null,
|
|
338
|
-
state: shouldLoadManifest ? "loading" : "not-needed"
|
|
339
|
-
};
|
|
325
|
+
const manifestRequestKey = JSON.stringify([manifestUrl, mapName]);
|
|
326
|
+
const currentManifestResolution = manifestResolution.key === manifestRequestKey ? manifestResolution : { key: manifestRequestKey, map: null, state: "loading" };
|
|
340
327
|
const manifestMap = currentManifestResolution.state === "ready" ? currentManifestResolution.map : null;
|
|
341
328
|
const themeResolution = useMemo(() => {
|
|
342
|
-
if (!manifestMap
|
|
343
|
-
return {
|
|
344
|
-
error: false,
|
|
345
|
-
name: runtimeSource.kind === "tileflow" && theme && theme !== "system" ? theme : void 0
|
|
346
|
-
};
|
|
329
|
+
if (!manifestMap) {
|
|
330
|
+
return { error: false, name: theme && theme !== "system" ? theme : void 0 };
|
|
347
331
|
}
|
|
348
332
|
try {
|
|
349
333
|
return {
|
|
@@ -353,7 +337,7 @@ function Map2(props) {
|
|
|
353
337
|
} catch {
|
|
354
338
|
return { error: true, name: void 0 };
|
|
355
339
|
}
|
|
356
|
-
}, [manifestMap,
|
|
340
|
+
}, [manifestMap, systemColorScheme, theme]);
|
|
357
341
|
const resolvedThemeName = themeResolution.name;
|
|
358
342
|
const manifestView = resolveTileflowRuntimeView({ manifestMap });
|
|
359
343
|
const manifestCenter = useStableMapOptionValue(
|
|
@@ -458,10 +442,6 @@ function Map2(props) {
|
|
|
458
442
|
reportedDeclarativeDiagnosticKeysRef.current = nextKeys;
|
|
459
443
|
}, [declarativeInteractionDiagnostics]);
|
|
460
444
|
useEffect(() => {
|
|
461
|
-
if (!shouldLoadManifest) {
|
|
462
|
-
setManifestResolution({ key: manifestRequestKey, map: null, state: "not-needed" });
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
445
|
let cancelled = false;
|
|
466
446
|
setManifestResolution({ key: manifestRequestKey, map: null, state: "loading" });
|
|
467
447
|
loadTileflowManifest(manifestUrl).then((manifest) => {
|
|
@@ -483,7 +463,7 @@ function Map2(props) {
|
|
|
483
463
|
return () => {
|
|
484
464
|
cancelled = true;
|
|
485
465
|
};
|
|
486
|
-
}, [manifestRequestKey, manifestUrl, mapName
|
|
466
|
+
}, [manifestRequestKey, manifestUrl, mapName]);
|
|
487
467
|
const runtimeStyle = useMemo(() => {
|
|
488
468
|
if (isImageMode || themeResolution.error) {
|
|
489
469
|
return null;
|
|
@@ -496,7 +476,7 @@ function Map2(props) {
|
|
|
496
476
|
});
|
|
497
477
|
}, [isImageMode, manifestMap, runtimeSource, systemColorScheme, themeResolution]);
|
|
498
478
|
runtimeStyleRef.current = runtimeStyle;
|
|
499
|
-
const runtimeMapIdentity =
|
|
479
|
+
const runtimeMapIdentity = `${manifestUrl}\0${runtimeSource.map}`;
|
|
500
480
|
const runtimeStyleReady = runtimeStyle !== null || themeResolution.error && mapRef.current !== null;
|
|
501
481
|
const resolvedAnalytics = useMemo(
|
|
502
482
|
() => mergeTileflowAnalytics(analytics, runtimeStyle?.analytics),
|
|
@@ -544,7 +524,7 @@ function Map2(props) {
|
|
|
544
524
|
]
|
|
545
525
|
);
|
|
546
526
|
const runtimeResolutionState = (() => {
|
|
547
|
-
if (
|
|
527
|
+
if (currentManifestResolution.state !== "ready") {
|
|
548
528
|
return currentManifestResolution.state === "error" ? "error" : "loading";
|
|
549
529
|
}
|
|
550
530
|
if (themeResolution.error) return "error";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tileflow/react",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.26",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "React components for rendering Tileflow maps with MapLibre.",
|
|
6
6
|
"type": "module",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@tileflow/core": ">=0.1.0-alpha.
|
|
46
|
+
"@tileflow/core": ">=0.1.0-alpha.27 <0.1.0-beta.0",
|
|
47
47
|
"@tileflow/interactions": ">=0.1.0-alpha.4 <0.1.0-beta.0",
|
|
48
|
-
"@tileflow/static": ">=0.1.0-alpha.
|
|
48
|
+
"@tileflow/static": ">=0.1.0-alpha.27 <0.1.0-beta.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"maplibre-gl": ">=6.4.1 <7",
|