@tileflow/react 0.1.0-alpha.36 → 0.1.0-alpha.37
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 +6 -0
- package/dist/index.js +26 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,6 +19,12 @@ npm install --save-dev --save-exact tileflow@alpha
|
|
|
19
19
|
The supported peer ranges are React/React DOM 18–19 and MapLibre GL JS `>=6.4.1 <7`. The worker
|
|
20
20
|
must come from the same MapLibre installation as the main module.
|
|
21
21
|
|
|
22
|
+
Prepared styles may retain relative asset URLs. The component loads them through Core's shared
|
|
23
|
+
resource loader before creating the map and before changing or blending themes. Sprites, fonts,
|
|
24
|
+
data and model resources resolve against their declaring documents. Pending document loads are
|
|
25
|
+
cancelled when the map is replaced or unmounted; `mapOptions.transformRequest` also applies to
|
|
26
|
+
style and HTTP TileJSON requests.
|
|
27
|
+
|
|
22
28
|
## Prepare a map
|
|
23
29
|
|
|
24
30
|
Create `tileflow.config.ts` at the application root:
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
createTileflowThemeController,
|
|
52
52
|
createTileflowTransformRequest,
|
|
53
53
|
getTileflowSystemColorScheme,
|
|
54
|
+
loadTileflowRuntimeStyle,
|
|
54
55
|
loadTileflowStyleFonts,
|
|
55
56
|
registerTileflowContourProtocol,
|
|
56
57
|
registerTileflowPathGroundProtocol,
|
|
@@ -748,12 +749,28 @@ function Map2(props) {
|
|
|
748
749
|
const container = containerRef.current;
|
|
749
750
|
let cancelled = false;
|
|
750
751
|
let disposeMap;
|
|
752
|
+
const resourceLifetime = new AbortController();
|
|
753
|
+
const session = createTileflowSessionController({ source: "react" });
|
|
754
|
+
const resourceTransform = createTileflowTransformRequest({
|
|
755
|
+
getAnalytics: () => resolvedAnalyticsRef.current,
|
|
756
|
+
sessionController: session,
|
|
757
|
+
sessionId: session.sessionId,
|
|
758
|
+
transformRequest: stableMapOptions?.transformRequest ?? void 0
|
|
759
|
+
});
|
|
760
|
+
const styleLoadOptions = {
|
|
761
|
+
signal: resourceLifetime.signal,
|
|
762
|
+
transformRequest: (url, type) => resourceTransform(
|
|
763
|
+
url,
|
|
764
|
+
type
|
|
765
|
+
)
|
|
766
|
+
};
|
|
751
767
|
void Promise.all([
|
|
752
768
|
loadTileflowMapLibre(),
|
|
753
|
-
|
|
754
|
-
fontFaces:
|
|
769
|
+
loadTileflowRuntimeStyle(initialRuntimeStyle, styleLoadOptions).then(async (prepared) => {
|
|
770
|
+
await loadTileflowStyleFonts(prepared.style, { fontFaces: prepared.fontFaces });
|
|
771
|
+
return prepared;
|
|
755
772
|
})
|
|
756
|
-
]).then(([maplibregl]) => {
|
|
773
|
+
]).then(([maplibregl, prepared]) => {
|
|
757
774
|
if (cancelled || containerRef.current !== container) {
|
|
758
775
|
return;
|
|
759
776
|
}
|
|
@@ -787,7 +804,6 @@ function Map2(props) {
|
|
|
787
804
|
setRendererBridgeDiagnostic(void 0);
|
|
788
805
|
}
|
|
789
806
|
};
|
|
790
|
-
const session = createTileflowSessionController({ source: "react" });
|
|
791
807
|
const sessionStarter = createTileflowSessionStarter({
|
|
792
808
|
getSessionId: () => session.sessionId,
|
|
793
809
|
sessionId: session.sessionId,
|
|
@@ -816,7 +832,7 @@ function Map2(props) {
|
|
|
816
832
|
stableMapOptions?.canvasContextAttributes
|
|
817
833
|
),
|
|
818
834
|
container,
|
|
819
|
-
style:
|
|
835
|
+
style: prepared.style,
|
|
820
836
|
bearing: bearingRef.current,
|
|
821
837
|
center: centerRef.current,
|
|
822
838
|
pitch: pitchRef.current,
|
|
@@ -839,7 +855,9 @@ function Map2(props) {
|
|
|
839
855
|
registerCleanup(attachTileflowLabelPlacement(map));
|
|
840
856
|
registerCleanup(attachTileflowHorizonQueries(map));
|
|
841
857
|
const themeController = initialRuntimeStyle.theme === void 0 ? void 0 : createTileflowThemeController({
|
|
842
|
-
initial: initialRuntimeStyle,
|
|
858
|
+
initial: prepared.family ? prepared : initialRuntimeStyle,
|
|
859
|
+
initialStyle: prepared.style,
|
|
860
|
+
styleLoadOptions,
|
|
843
861
|
map,
|
|
844
862
|
onTransition(transition) {
|
|
845
863
|
onThemeChangeRef.current?.(transition);
|
|
@@ -1070,6 +1088,7 @@ function Map2(props) {
|
|
|
1070
1088
|
});
|
|
1071
1089
|
}
|
|
1072
1090
|
}).catch((error) => {
|
|
1091
|
+
resourceLifetime.abort();
|
|
1073
1092
|
try {
|
|
1074
1093
|
disposeMap?.();
|
|
1075
1094
|
} catch (cleanupError) {
|
|
@@ -1082,6 +1101,7 @@ function Map2(props) {
|
|
|
1082
1101
|
});
|
|
1083
1102
|
return () => {
|
|
1084
1103
|
cancelled = true;
|
|
1104
|
+
resourceLifetime.abort();
|
|
1085
1105
|
readinessRunRef.current += 1;
|
|
1086
1106
|
disposeMap?.();
|
|
1087
1107
|
};
|
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.37",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "React components for rendering Tileflow maps with MapLibre.",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@tileflow/core": ">=0.1.0-alpha.
|
|
46
|
+
"@tileflow/core": ">=0.1.0-alpha.45 <0.1.0-beta.0",
|
|
47
47
|
"@tileflow/interactions": ">=0.1.0-alpha.7 <0.1.0-beta.0",
|
|
48
48
|
"@tileflow/static": ">=0.1.0-alpha.29 <0.1.0-beta.0"
|
|
49
49
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.3.0",
|
|
57
57
|
"@types/react-dom": "^19.3.0",
|
|
58
|
-
"maplibre-gl": "6.
|
|
58
|
+
"maplibre-gl": "6.16.0",
|
|
59
59
|
"react": "^19.3.0",
|
|
60
60
|
"react-dom": "^19.3.0"
|
|
61
61
|
},
|