@remotion/maptiler 4.0.533 → 4.0.535

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 (2) hide show
  1. package/dist/esm/index.mjs +88 -44
  2. package/package.json +3 -3
@@ -1590,7 +1590,13 @@ var MapPolygon = (props) => {
1590
1590
  };
1591
1591
  // src/MapRegion.tsx
1592
1592
  import { length as getLineLength2, lineSliceAlong as lineSliceAlong2, lineString as lineString2 } from "@turf/turf";
1593
- import { useContext as useContext9, useEffect as useEffect7, useMemo as useMemo3, useState as useState2 } from "react";
1593
+ import {
1594
+ useContext as useContext9,
1595
+ useEffect as useEffect7,
1596
+ useLayoutEffect,
1597
+ useMemo as useMemo3,
1598
+ useState as useState2
1599
+ } from "react";
1594
1600
  import {
1595
1601
  Interactive as Interactive2,
1596
1602
  Freeze as Freeze7,
@@ -1667,7 +1673,13 @@ var MapRegionDrawing = ({
1667
1673
  const { map } = useContext9(MapTilerContext);
1668
1674
  const { continueRender, delayRender } = useDelayRender6();
1669
1675
  const [isReady, setIsReady] = useState2(false);
1670
- const [loadingHandle] = useState2(() => delayRender(`Loading ${feature.properties.name} geometry`));
1676
+ useLayoutEffect(() => {
1677
+ if (isReady) {
1678
+ return;
1679
+ }
1680
+ const handle = delayRender(`Loading ${feature.properties.name} geometry`);
1681
+ return () => continueRender(handle);
1682
+ }, [continueRender, delayRender, feature.properties.name, isReady]);
1671
1683
  const outline = useMemo3(() => lineString2(feature.geometry.coordinates[0]), [feature]);
1672
1684
  const outlineLength = useMemo3(() => getLineLength2(outline), [outline]);
1673
1685
  const fillSourceId = `${id}-fill`;
@@ -1678,7 +1690,7 @@ var MapRegionDrawing = ({
1678
1690
  outlineSourceId,
1679
1691
  outlineGlowLayerId
1680
1692
  ]);
1681
- useEffect7(() => {
1693
+ useLayoutEffect(() => {
1682
1694
  if (!map) {
1683
1695
  return;
1684
1696
  }
@@ -1742,11 +1754,12 @@ var MapRegionDrawing = ({
1742
1754
  map.setPaintProperty(outlineSourceId, "line-color", strokeColor);
1743
1755
  map.setPaintProperty(outlineSourceId, "line-width", strokeWidth);
1744
1756
  applyPremountVisibility();
1745
- map.once("idle", () => {
1746
- setIsReady(true);
1747
- continueRender(loadingHandle);
1748
- });
1757
+ const onIdle = () => setIsReady(true);
1758
+ map.once("idle", onIdle);
1749
1759
  map.triggerRepaint();
1760
+ return () => {
1761
+ map.off("idle", onIdle);
1762
+ };
1750
1763
  }, [
1751
1764
  applyPremountVisibility,
1752
1765
  continueRender,
@@ -1754,7 +1767,6 @@ var MapRegionDrawing = ({
1754
1767
  fillColor,
1755
1768
  fillSourceId,
1756
1769
  glow,
1757
- loadingHandle,
1758
1770
  map,
1759
1771
  outline,
1760
1772
  outlineGlowLayerId,
@@ -1762,15 +1774,20 @@ var MapRegionDrawing = ({
1762
1774
  strokeColor,
1763
1775
  strokeWidth
1764
1776
  ]);
1765
- useEffect7(() => {
1777
+ useLayoutEffect(() => {
1766
1778
  if (!isReady || !map) {
1767
1779
  return;
1768
1780
  }
1769
1781
  const frameHandle = delayRender(`Drawing ${feature.properties.name}`);
1770
1782
  map.getSource(outlineSourceId).setData(lineSliceAlong2(outline, 0, Math.max(0.001, outlineLength * Math.min(1, Math.max(0, progress)))));
1771
1783
  map.setPaintProperty(fillSourceId, "fill-opacity", Math.min(1, Math.max(0, fill)));
1772
- map.once("idle", () => continueRender(frameHandle));
1784
+ const onIdle = () => continueRender(frameHandle);
1785
+ map.once("idle", onIdle);
1773
1786
  map.triggerRepaint();
1787
+ return () => {
1788
+ map.off("idle", onIdle);
1789
+ continueRender(frameHandle);
1790
+ };
1774
1791
  }, [
1775
1792
  continueRender,
1776
1793
  delayRender,
@@ -1924,7 +1941,13 @@ var MapRegion = Interactive2.withSchema({
1924
1941
  });
1925
1942
  // src/MapRoute.tsx
1926
1943
  import { length as getLineLength3, lineSliceAlong as lineSliceAlong3, lineString as lineString3 } from "@turf/turf";
1927
- import { useContext as useContext10, useEffect as useEffect8, useMemo as useMemo4, useState as useState3 } from "react";
1944
+ import {
1945
+ useContext as useContext10,
1946
+ useEffect as useEffect8,
1947
+ useLayoutEffect as useLayoutEffect2,
1948
+ useMemo as useMemo4,
1949
+ useState as useState3
1950
+ } from "react";
1928
1951
  import {
1929
1952
  Interactive as Interactive3,
1930
1953
  Freeze as Freeze8,
@@ -1984,7 +2007,13 @@ var MapRouteDrawing = ({
1984
2007
  const { map } = useContext10(MapTilerContext);
1985
2008
  const { continueRender, delayRender } = useDelayRender7();
1986
2009
  const [isReady, setIsReady] = useState3(false);
1987
- const [loadingHandle] = useState3(() => delayRender(`Loading ${feature.properties.name} route`));
2010
+ useLayoutEffect2(() => {
2011
+ if (isReady) {
2012
+ return;
2013
+ }
2014
+ const handle = delayRender(`Loading ${feature.properties.name} route`);
2015
+ return () => continueRender(handle);
2016
+ }, [continueRender, delayRender, feature.properties.name, isReady]);
1988
2017
  const route = useMemo4(() => lineString3(feature.geometry.coordinates), [feature]);
1989
2018
  const routeLength = useMemo4(() => getLineLength3(route), [route]);
1990
2019
  const sourceId = `${id}-route`;
@@ -1993,7 +2022,7 @@ var MapRouteDrawing = ({
1993
2022
  sourceId,
1994
2023
  glowLayerId
1995
2024
  ]);
1996
- useEffect8(() => {
2025
+ useLayoutEffect2(() => {
1997
2026
  if (!map) {
1998
2027
  return;
1999
2028
  }
@@ -2037,31 +2066,36 @@ var MapRouteDrawing = ({
2037
2066
  map.setPaintProperty(sourceId, "line-color", strokeColor);
2038
2067
  map.setPaintProperty(sourceId, "line-width", strokeWidth);
2039
2068
  applyPremountVisibility();
2040
- map.once("idle", () => {
2041
- setIsReady(true);
2042
- continueRender(loadingHandle);
2043
- });
2069
+ const onIdle = () => setIsReady(true);
2070
+ map.once("idle", onIdle);
2044
2071
  map.triggerRepaint();
2072
+ return () => {
2073
+ map.off("idle", onIdle);
2074
+ };
2045
2075
  }, [
2046
2076
  applyPremountVisibility,
2047
2077
  continueRender,
2048
2078
  glow,
2049
2079
  glowLayerId,
2050
- loadingHandle,
2051
2080
  map,
2052
2081
  route,
2053
2082
  sourceId,
2054
2083
  strokeColor,
2055
2084
  strokeWidth
2056
2085
  ]);
2057
- useEffect8(() => {
2086
+ useLayoutEffect2(() => {
2058
2087
  if (!isReady || !map) {
2059
2088
  return;
2060
2089
  }
2061
2090
  const frameHandle = delayRender(`Drawing ${feature.properties.name} route`);
2062
2091
  map.getSource(sourceId).setData(lineSliceAlong3(route, 0, Math.max(0.001, routeLength * Math.min(1, Math.max(0, progress)))));
2063
- map.once("idle", () => continueRender(frameHandle));
2092
+ const onIdle = () => continueRender(frameHandle);
2093
+ map.once("idle", onIdle);
2064
2094
  map.triggerRepaint();
2095
+ return () => {
2096
+ map.off("idle", onIdle);
2097
+ continueRender(frameHandle);
2098
+ };
2065
2099
  }, [
2066
2100
  continueRender,
2067
2101
  delayRender,
@@ -2325,7 +2359,7 @@ var MapSource = ({
2325
2359
  // src/MapViewport.tsx
2326
2360
  import { MapStyle, Map as MapTilerMap } from "@maptiler/sdk";
2327
2361
  import"@maptiler/sdk/style.css";
2328
- import { useEffect as useEffect10, useMemo as useMemo5, useRef as useRef8, useState as useState4 } from "react";
2362
+ import { useLayoutEffect as useLayoutEffect3, useMemo as useMemo5, useRef as useRef8, useState as useState4 } from "react";
2329
2363
  import {
2330
2364
  Interactive as Interactive4,
2331
2365
  useDelayRender as useDelayRender9
@@ -2524,19 +2558,20 @@ var MapViewportContent = ({
2524
2558
  const onMapReadyRef = useRef8(onMapReady);
2525
2559
  onMapReadyRef.current = onMapReady;
2526
2560
  const { continueRender, delayRender } = useDelayRender9();
2527
- const [map, setMap] = useState4(null);
2561
+ const [loadedMap, setLoadedMap] = useState4(null);
2562
+ const map = loadedMap?.map ?? null;
2528
2563
  const [cameraRevision, setCameraRevision] = useState4(0);
2529
2564
  const [styleRevision, setStyleRevision] = useState4(0);
2530
- const [loadingHandle] = useState4(() => delayRender("Loading MapTiler map"));
2531
2565
  const contextValue = useMemo5(() => ({ cameraRevision, map, styleRevision }), [cameraRevision, map, styleRevision]);
2532
- useEffect10(() => {
2566
+ useLayoutEffect3(() => {
2533
2567
  if (!apiKey) {
2534
- continueRender(loadingHandle);
2535
2568
  return;
2536
2569
  }
2537
2570
  if (!mapContainerRef.current || mapRef.current) {
2538
2571
  return;
2539
2572
  }
2573
+ const loadingHandle = delayRender("Loading MapTiler map");
2574
+ let cancelled = false;
2540
2575
  const initialCamera = initialCameraRef.current;
2541
2576
  const initialOptions = initialMapOptionsRef.current;
2542
2577
  const mapInstance = new MapTilerMap({
@@ -2578,18 +2613,27 @@ var MapViewportContent = ({
2578
2613
  showLabels: initialOptions.showLabels
2579
2614
  });
2580
2615
  mapInstance.once("idle", () => {
2581
- setMap(mapInstance);
2616
+ if (cancelled) {
2617
+ return;
2618
+ }
2619
+ setLoadedMap({ map: mapInstance, handle: loadingHandle });
2582
2620
  onMapReadyRef.current?.(mapInstance);
2583
- continueRender(loadingHandle);
2584
2621
  });
2585
2622
  mapInstance.triggerRepaint();
2586
2623
  });
2587
2624
  return () => {
2625
+ cancelled = true;
2588
2626
  mapInstance.remove();
2589
2627
  mapRef.current = null;
2628
+ continueRender(loadingHandle);
2590
2629
  };
2591
- }, [apiKey, continueRender, loadingHandle]);
2592
- useEffect10(() => {
2630
+ }, [apiKey, continueRender, delayRender]);
2631
+ useLayoutEffect3(() => {
2632
+ if (loadedMap) {
2633
+ continueRender(loadedMap.handle);
2634
+ }
2635
+ }, [continueRender, loadedMap]);
2636
+ useLayoutEffect3(() => {
2593
2637
  if (!map) {
2594
2638
  return;
2595
2639
  }
@@ -2642,7 +2686,7 @@ var MapViewportContent = ({
2642
2686
  pitch,
2643
2687
  zoom
2644
2688
  ]);
2645
- useEffect10(() => {
2689
+ useLayoutEffect3(() => {
2646
2690
  if (!map || lastMapStyleRef.current === mapStyle && lastLayerVisibilityRef.current.showLabels === showLabels && lastLayerVisibilityRef.current.administrativeBorders === administrativeBorders) {
2647
2691
  return;
2648
2692
  }
@@ -2682,13 +2726,13 @@ var MapViewportContent = ({
2682
2726
  mapStyle,
2683
2727
  showLabels
2684
2728
  ]);
2685
- useEffect10(() => {
2729
+ useLayoutEffect3(() => {
2686
2730
  if (map && language) {
2687
2731
  map.setLanguage(language);
2688
2732
  map.triggerRepaint();
2689
2733
  }
2690
2734
  }, [language, map]);
2691
- useEffect10(() => {
2735
+ useLayoutEffect3(() => {
2692
2736
  if (!map) {
2693
2737
  return;
2694
2738
  }
@@ -2699,7 +2743,7 @@ var MapViewportContent = ({
2699
2743
  }
2700
2744
  map.triggerRepaint();
2701
2745
  }, [map, terrain, terrainExaggeration]);
2702
- useEffect10(() => {
2746
+ useLayoutEffect3(() => {
2703
2747
  if (map && projection) {
2704
2748
  map.setProjection(projection, { persist: true });
2705
2749
  map.triggerRepaint();
@@ -2737,16 +2781,16 @@ var MapViewport = Interactive4.withSchema({
2737
2781
  wrapInSequence: true
2738
2782
  });
2739
2783
  export {
2740
- useMapTiler,
2741
- MapViewport,
2742
- MapSource,
2743
- MapRoute,
2744
- MapRegion,
2745
- MapPolyline,
2746
- MapPolygon,
2747
- MapPoint,
2748
- MapOverlay,
2749
- MapMarker,
2784
+ MapHeatmap,
2750
2785
  MapLayer,
2751
- MapHeatmap
2786
+ MapMarker,
2787
+ MapOverlay,
2788
+ MapPoint,
2789
+ MapPolygon,
2790
+ MapPolyline,
2791
+ MapRegion,
2792
+ MapRoute,
2793
+ MapSource,
2794
+ MapViewport,
2795
+ useMapTiler
2752
2796
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/maptiler",
3
- "version": "4.0.533",
3
+ "version": "4.0.535",
4
4
  "description": "MapTiler components for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@maptiler/sdk": "4.0.2",
27
27
  "@turf/turf": "7.3.2",
28
- "remotion": "4.0.533"
28
+ "remotion": "4.0.535"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "react": ">=16.8.0",
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "react": "19.2.3",
44
44
  "react-dom": "19.2.3",
45
- "@remotion/eslint-config-internal": "4.0.533",
45
+ "@remotion/eslint-config-internal": "4.0.535",
46
46
  "eslint": "9.19.0",
47
47
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
48
48
  },