@tileflow/react 0.1.0-alpha.35 → 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.
Files changed (3) hide show
  1. package/README.md +10 -4
  2. package/dist/index.js +30 -6
  3. package/package.json +5 -5
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:
@@ -110,7 +116,7 @@ Theme and `timeOfDay` changes cross-fade over 450 ms by default, respecting redu
110
116
  `themeBlend={{themes: ['night', 'dusk', 'day'], position}}` shows a continuous blend of the map's
111
117
  themes instead of `theme`: position 0 is the first theme and 1.5 is halfway from the second to the
112
118
  third. Moving the position updates the map at once. See
113
- [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/theme-transitions-and-blends.md).
119
+ [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md).
114
120
 
115
121
  Interactive maps show the 3D scene their style declares by default: buildings with Tileflow
116
122
  landmarks and the map's Team building models, 3D trees, and street lights where the map enables
@@ -120,8 +126,8 @@ draws vegetation as the map's policy sets for the 2D view (Streets keeps its mod
120
126
  view). `vegetation` overrides vegetation visibility (omitting it uses the map default); `vegetation={false}`
121
127
  hides models and flat artwork alike. Changing either prop updates the existing map immediately.
122
128
  They do not change camera pitch and do not apply in image mode. See
123
- [the map's 3D scene](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/buildings-3d.md#the-maps-3d-scene)
124
- and [vegetation controls](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/trees-3d.md#visibility-and-representation).
129
+ [the map's 3D scene](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md)
130
+ and [vegetation controls](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md).
125
131
 
126
132
  `mapOptions` accepts native MapLibre options except `container` and `style`. Direct camera props
127
133
  take priority over `mapOptions`, then the manifest view, then shared defaults. `Map` always selects
@@ -163,7 +169,7 @@ export function Unemployment({rates}: {rates: {ine: string; rate: number}[]}) {
163
169
 
164
170
  Rows join by `ref` here, so this map declares `boundaryAreas: {family: 'boundaries', promoteId:
165
171
  'ref'}`. Without `promoteId`, rows join by registry `id`. See
166
- [boundary areas and choropleths](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/boundary-areas-and-choropleths.md)
172
+ [boundary areas and choropleths](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md)
167
173
  for scales, joins and the lookup table.
168
174
 
169
175
  ## Add annotations and popups
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ import { createPortal } from "react-dom";
41
41
  import {
42
42
  attachTileflowAtmosphere,
43
43
  attachTileflowFairUseNotice,
44
+ attachTileflowHorizonQueries,
44
45
  attachTileflowLabelPlacement,
45
46
  attachTileflowMap3D,
46
47
  attachTileflowMapLifecycle,
@@ -50,8 +51,10 @@ import {
50
51
  createTileflowThemeController,
51
52
  createTileflowTransformRequest,
52
53
  getTileflowSystemColorScheme,
54
+ loadTileflowRuntimeStyle,
53
55
  loadTileflowStyleFonts,
54
56
  registerTileflowContourProtocol,
57
+ registerTileflowPathGroundProtocol,
55
58
  registerTileflowPmtilesProtocol,
56
59
  registerTileflowWorldRequestBridge,
57
60
  subscribeTileflowSystemColorScheme,
@@ -746,12 +749,28 @@ function Map2(props) {
746
749
  const container = containerRef.current;
747
750
  let cancelled = false;
748
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
+ };
749
767
  void Promise.all([
750
768
  loadTileflowMapLibre(),
751
- loadTileflowStyleFonts(initialRuntimeStyle.style, {
752
- fontFaces: initialRuntimeStyle.fontFaces
769
+ loadTileflowRuntimeStyle(initialRuntimeStyle, styleLoadOptions).then(async (prepared) => {
770
+ await loadTileflowStyleFonts(prepared.style, { fontFaces: prepared.fontFaces });
771
+ return prepared;
753
772
  })
754
- ]).then(([maplibregl]) => {
773
+ ]).then(([maplibregl, prepared]) => {
755
774
  if (cancelled || containerRef.current !== container) {
756
775
  return;
757
776
  }
@@ -785,7 +804,6 @@ function Map2(props) {
785
804
  setRendererBridgeDiagnostic(void 0);
786
805
  }
787
806
  };
788
- const session = createTileflowSessionController({ source: "react" });
789
807
  const sessionStarter = createTileflowSessionStarter({
790
808
  getSessionId: () => session.sessionId,
791
809
  sessionId: session.sessionId,
@@ -794,6 +812,7 @@ function Map2(props) {
794
812
  const fairUseNotice = attachTileflowFairUseNotice(container);
795
813
  registerCleanup(() => fairUseNotice.dispose());
796
814
  registerTileflowContourProtocol({ addProtocol: maplibregl.addProtocol });
815
+ registerTileflowPathGroundProtocol({ addProtocol: maplibregl.addProtocol });
797
816
  registerTileflowPmtilesProtocol({ addProtocol: maplibregl.addProtocol });
798
817
  const worldRequestBridge = registerTileflowWorldRequestBridge({
799
818
  addProtocol: maplibregl.addProtocol,
@@ -813,7 +832,7 @@ function Map2(props) {
813
832
  stableMapOptions?.canvasContextAttributes
814
833
  ),
815
834
  container,
816
- style: initialRuntimeStyle.style,
835
+ style: prepared.style,
817
836
  bearing: bearingRef.current,
818
837
  center: centerRef.current,
819
838
  pitch: pitchRef.current,
@@ -834,8 +853,11 @@ function Map2(props) {
834
853
  registerCleanup(attachTileflowNotices(map));
835
854
  registerCleanup(attachTileflowNauticalLights(map));
836
855
  registerCleanup(attachTileflowLabelPlacement(map));
856
+ registerCleanup(attachTileflowHorizonQueries(map));
837
857
  const themeController = initialRuntimeStyle.theme === void 0 ? void 0 : createTileflowThemeController({
838
- initial: initialRuntimeStyle,
858
+ initial: prepared.family ? prepared : initialRuntimeStyle,
859
+ initialStyle: prepared.style,
860
+ styleLoadOptions,
839
861
  map,
840
862
  onTransition(transition) {
841
863
  onThemeChangeRef.current?.(transition);
@@ -1066,6 +1088,7 @@ function Map2(props) {
1066
1088
  });
1067
1089
  }
1068
1090
  }).catch((error) => {
1091
+ resourceLifetime.abort();
1069
1092
  try {
1070
1093
  disposeMap?.();
1071
1094
  } catch (cleanupError) {
@@ -1078,6 +1101,7 @@ function Map2(props) {
1078
1101
  });
1079
1102
  return () => {
1080
1103
  cancelled = true;
1104
+ resourceLifetime.abort();
1081
1105
  readinessRunRef.current += 1;
1082
1106
  disposeMap?.();
1083
1107
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/react",
3
- "version": "0.1.0-alpha.35",
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,9 +43,9 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@tileflow/core": ">=0.1.0-alpha.40 <0.1.0-beta.0",
47
- "@tileflow/interactions": ">=0.1.0-alpha.6 <0.1.0-beta.0",
48
- "@tileflow/static": ">=0.1.0-alpha.28 <0.1.0-beta.0"
46
+ "@tileflow/core": ">=0.1.0-alpha.45 <0.1.0-beta.0",
47
+ "@tileflow/interactions": ">=0.1.0-alpha.7 <0.1.0-beta.0",
48
+ "@tileflow/static": ">=0.1.0-alpha.29 <0.1.0-beta.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "maplibre-gl": ">=6.4.1 <7",
@@ -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.13.0",
58
+ "maplibre-gl": "6.16.0",
59
59
  "react": "^19.3.0",
60
60
  "react-dom": "^19.3.0"
61
61
  },