@octanejs/react-map-gl 0.0.33 → 0.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/react-map-gl",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "mapbox-gl": ">=3.5.0",
39
- "octane": "^0.10.0"
39
+ "octane": "^0.11.0"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "mapbox-gl": {
@@ -45,13 +45,13 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@mapbox/point-geometry": "1.1.0",
48
- "@tsrx/react": "^0.3.7",
48
+ "@tsrx/react": "^0.4.5",
49
49
  "@types/react": "^19.2.17",
50
50
  "@types/react-dom": "^19.2.3",
51
51
  "@vis.gl/react-mapbox": "8.1.2",
52
52
  "esbuild": "^0.28.1",
53
53
  "mapbox-gl": "3.9.0",
54
- "octane": "0.10.2",
54
+ "octane": "0.11.0",
55
55
  "react": "19.2.7",
56
56
  "react-dom": "19.2.7",
57
57
  "vitest": "^4.1.10"
@@ -26,11 +26,14 @@ export type MapContextValue = {
26
26
 
27
27
  export const MapContext = createContext<MapContextValue>(null as unknown as MapContextValue);
28
28
 
29
- type MapInitOptions =
30
- Omit<MapOptions, 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'>;
31
-
32
- export type MapProps =
33
- MapInitOptions & MapboxProps & GlobalSettings & {
29
+ type MapInitOptions = Omit<
30
+ MapOptions,
31
+ 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'
32
+ >;
33
+
34
+ export type MapProps = MapInitOptions &
35
+ MapboxProps &
36
+ GlobalSettings & {
34
37
  mapLib?: MapLib | Promise<MapLib>;
35
38
  reuseMaps?: boolean;
36
39
  /** Map container id */
@@ -58,60 +61,61 @@ export function Map(props: MapProps) @{
58
61
  let isMounted = true;
59
62
  let mapbox: Mapbox;
60
63
 
61
- Promise.resolve(mapLib || import('mapbox-gl')).then((module: MapLib | { default: MapLib }) => {
62
- if (!isMounted) {
63
- return;
64
- }
65
- if (!module) {
66
- throw new Error('Invalid mapLib');
67
- }
68
- const mapboxgl =
69
- 'Map' in module ? module : module.default;
70
- if (!mapboxgl.Map) {
71
- throw new Error('Invalid mapLib');
72
- }
64
+ Promise.resolve(mapLib || import('mapbox-gl'))
65
+ .then((module: MapLib | { default: MapLib }) => {
66
+ if (!isMounted) {
67
+ return;
68
+ }
69
+ if (!module) {
70
+ throw new Error('Invalid mapLib');
71
+ }
72
+ const mapboxgl = 'Map' in module ? module : module.default;
73
+ if (!mapboxgl.Map) {
74
+ throw new Error('Invalid mapLib');
75
+ }
73
76
 
74
- setGlobals(mapboxgl, props);
75
- if (props.reuseMaps) {
76
- mapbox = Mapbox.reuse(props, containerRef.current!)!;
77
- }
78
- if (!mapbox) {
79
- mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current!);
80
- }
81
- contextValue.map = createRef(mapbox)!;
82
- contextValue.mapLib = mapboxgl;
83
-
84
- // The children container is created and APPENDED here rather than
85
- // rendered into the template, so it lands after the DOM mapbox-gl has
86
- // just built — which is where React puts it, and the only arrangement
87
- // that reproduces upstream's behavior.
88
- //
89
- // Rendered in the template, Octane's conditional block anchors it at its
90
- // authored position, ahead of the library's nodes. In flow it then
91
- // displaces `.mapboxgl-canvas-container`, the element mapbox-gl measures
92
- // pointer coordinates against; taken out of flow it instead paints
93
- // before the canvas, so a consumer's positioned overlay ends up hidden
94
- // and unclickable beneath an opaque map. Appending sidesteps both: same
95
- // `height: 100%` container as upstream, in the same place.
96
- const childContainer = document.createElement('div');
97
- childContainer.setAttribute('mapboxgl-children', '');
98
- childContainer.style.height = '100%';
99
- containerRef.current!.appendChild(childContainer);
100
- childContainerRef.current = childContainer;
101
-
102
- setMapInstance(mapbox);
103
- }).catch((error) => {
104
- const { onError } = props;
105
- if (onError) {
106
- onError({
107
- type: 'error',
108
- target: null,
109
- error,
110
- });
111
- } else {
112
- console.error(error); // eslint-disable-line
113
- }
114
- });
77
+ setGlobals(mapboxgl, props);
78
+ if (props.reuseMaps) {
79
+ mapbox = Mapbox.reuse(props, containerRef.current!)!;
80
+ }
81
+ if (!mapbox) {
82
+ mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current!);
83
+ }
84
+ contextValue.map = createRef(mapbox)!;
85
+ contextValue.mapLib = mapboxgl;
86
+
87
+ // The children container is created and APPENDED here rather than
88
+ // rendered into the template, so it lands after the DOM mapbox-gl has
89
+ // just built — which is where React puts it, and the only arrangement
90
+ // that reproduces upstream's behavior.
91
+ //
92
+ // Rendered in the template, Octane's conditional block anchors it at its
93
+ // authored position, ahead of the library's nodes. In flow it then
94
+ // displaces `.mapboxgl-canvas-container`, the element mapbox-gl measures
95
+ // pointer coordinates against; taken out of flow it instead paints
96
+ // before the canvas, so a consumer's positioned overlay ends up hidden
97
+ // and unclickable beneath an opaque map. Appending sidesteps both: same
98
+ // `height: 100%` container as upstream, in the same place.
99
+ const childContainer = document.createElement('div');
100
+ childContainer.setAttribute('mapboxgl-children', '');
101
+ childContainer.style.height = '100%';
102
+ containerRef.current!.appendChild(childContainer);
103
+ childContainerRef.current = childContainer;
104
+
105
+ setMapInstance(mapbox);
106
+ })
107
+ .catch((error) => {
108
+ const { onError } = props;
109
+ if (onError) {
110
+ onError({
111
+ type: 'error',
112
+ target: null,
113
+ error,
114
+ });
115
+ } else {
116
+ console.error(error); // eslint-disable-line
117
+ }
118
+ });
115
119
 
116
120
  return () => {
117
121
  isMounted = false;
@@ -164,10 +168,9 @@ export function Map(props: MapProps) @{
164
168
  // `Marker` and `Popup` already reach their library-owned elements this way.
165
169
  <div id={props.id} ref={containerRef} style={style}>
166
170
  @if (mapInstance) {
167
- <MapContext value={contextValue}>{createPortal(
168
- props.children,
169
- childContainerRef.current!,
170
- )}</MapContext>
171
+ <MapContext value={contextValue}>
172
+ {createPortal(props.children, childContainerRef.current!)}
173
+ </MapContext>
171
174
  }
172
175
  </div>
173
176
  }
@@ -17,11 +17,10 @@ import type {
17
17
  } from '../types/internal';
18
18
  import type { MapChildren } from '../types/octane';
19
19
 
20
- export type SourceProps =
21
- (SourceSpecification | CanvasSourceSpecification) & {
22
- id?: string;
23
- children?: MapChildren;
24
- };
20
+ export type SourceProps = (SourceSpecification | CanvasSourceSpecification) & {
21
+ id?: string;
22
+ children?: MapChildren;
23
+ };
25
24
 
26
25
  /**
27
26
  * OCTANE DIVERGENCE[react-map-gl-source-id-by-context][ported:source-layer:3]: upstream delivers this source's id to child layers with
@@ -18,7 +18,7 @@ export function MapProvider(props: { children?: MapChildren }) @{
18
18
  const onMapMount = useCallback((map: MapRef, id: string = 'default') => {
19
19
  setMaps((currMaps) => {
20
20
  if (id === 'current') {
21
- throw new Error('\'current\' cannot be used as map id');
21
+ throw new Error("'current' cannot be used as map id");
22
22
  }
23
23
  if (currMaps[id]) {
24
24
  throw new Error(`Multiple maps with the same id: ${id}`);
@@ -44,7 +44,9 @@ export function MapProvider(props: { children?: MapChildren }) @{
44
44
  onMapMount,
45
45
  onMapUnmount,
46
46
  }}
47
- >{props.children}</MountedMapsContext>
47
+ >
48
+ {props.children}
49
+ </MountedMapsContext>
48
50
  }
49
51
 
50
52
  export type MapCollection = {