react-bkoi-gl 1.0.2 → 1.0.4

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 (45) hide show
  1. package/dist/components/attribution-control.d.ts +1 -1
  2. package/dist/components/fullscreen-control.d.ts +1 -1
  3. package/dist/components/geolocate-control.d.ts +1 -1
  4. package/dist/components/geolocate-control.js +5 -5
  5. package/dist/components/geolocate-control.js.map +1 -1
  6. package/dist/components/layer.d.ts +3 -3
  7. package/dist/components/layer.js +5 -3
  8. package/dist/components/layer.js.map +1 -1
  9. package/dist/components/map.d.ts +4 -4
  10. package/dist/components/map.js +8 -6
  11. package/dist/components/map.js.map +1 -1
  12. package/dist/components/marker.d.ts +1 -1
  13. package/dist/components/marker.js +9 -7
  14. package/dist/components/marker.js.map +1 -1
  15. package/dist/components/navigation-control.d.ts +1 -1
  16. package/dist/components/popup.d.ts +1 -1
  17. package/dist/components/popup.js +6 -5
  18. package/dist/components/popup.js.map +1 -1
  19. package/dist/components/scale-control.d.ts +1 -1
  20. package/dist/components/source.d.ts +1 -1
  21. package/dist/components/source.js +4 -3
  22. package/dist/components/source.js.map +1 -1
  23. package/dist/components/use-control.d.ts +1 -1
  24. package/dist/components/use-map.d.ts +2 -2
  25. package/dist/components/use-map.js +8 -9
  26. package/dist/components/use-map.js.map +1 -1
  27. package/dist/exports-bkoi-gl.d.ts +22 -22
  28. package/dist/exports-mapbox.d.ts +23 -23
  29. package/dist/mapbox/create-ref.d.ts +1 -1
  30. package/dist/mapbox/mapbox.d.ts +1 -1
  31. package/dist/mapbox/mapbox.js +70 -67
  32. package/dist/mapbox/mapbox.js.map +1 -1
  33. package/dist/styles/react-bkoi-gl.css +1 -1
  34. package/dist/types/common.d.ts +7 -7
  35. package/dist/types/events-bkoi-gl.d.ts +3 -3
  36. package/dist/types/events-mapbox.d.ts +3 -3
  37. package/dist/types/events.d.ts +9 -9
  38. package/dist/types/index.d.ts +1 -1
  39. package/dist/types/lib.d.ts +3 -3
  40. package/dist/types/style-spec-bkoi-gl.d.ts +4 -4
  41. package/dist/types/style-spec-mapbox.d.ts +2 -2
  42. package/dist/utils/set-globals.d.ts +1 -1
  43. package/dist/utils/style-utils.js +5 -3
  44. package/dist/utils/style-utils.js.map +1 -1
  45. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ControlPosition, AttributionControlInstance } from '../types';
3
- export declare type AttributionControlProps<OptionsT> = OptionsT & {
3
+ export type AttributionControlProps<OptionsT> = OptionsT & {
4
4
  /** Placement of the control relative to the map. */
5
5
  position?: ControlPosition;
6
6
  /** CSS style override, applied to the control's container */
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ControlPosition, FullscreenControlInstance } from '../types';
3
- export declare type FullscreenControlProps<OptionsT> = Omit<OptionsT, 'container'> & {
3
+ export type FullscreenControlProps<OptionsT> = Omit<OptionsT, 'container'> & {
4
4
  /** Id of the DOM element which should be made full screen. By default, the map container
5
5
  * element will be made full screen. */
6
6
  containerId?: string;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ControlPosition, GeolocateControlInstance, GeolocateEvent, GeolocateResultEvent, GeolocateErrorEvent } from '../types';
3
- export declare type GeolocateControlProps<OptionsT, ControlT extends GeolocateControlInstance> = OptionsT & {
3
+ export type GeolocateControlProps<OptionsT, ControlT extends GeolocateControlInstance> = OptionsT & {
4
4
  /** Placement of the control relative to the map. */
5
5
  position?: ControlPosition;
6
6
  /** CSS style override, applied to the control's container */
@@ -18,23 +18,23 @@ function GeolocateControl(props, ref) {
18
18
  };
19
19
  gc.on('geolocate', e => {
20
20
  var _thisRef$current$prop, _thisRef$current$prop2;
21
- (_thisRef$current$prop = (_thisRef$current$prop2 = thisRef.current.props).onGeolocate) === null || _thisRef$current$prop === void 0 ? void 0 : _thisRef$current$prop.call(_thisRef$current$prop2, e);
21
+ (_thisRef$current$prop = (_thisRef$current$prop2 = thisRef.current.props).onGeolocate) === null || _thisRef$current$prop === void 0 || _thisRef$current$prop.call(_thisRef$current$prop2, e);
22
22
  });
23
23
  gc.on('error', e => {
24
24
  var _thisRef$current$prop3, _thisRef$current$prop4;
25
- (_thisRef$current$prop3 = (_thisRef$current$prop4 = thisRef.current.props).onError) === null || _thisRef$current$prop3 === void 0 ? void 0 : _thisRef$current$prop3.call(_thisRef$current$prop4, e);
25
+ (_thisRef$current$prop3 = (_thisRef$current$prop4 = thisRef.current.props).onError) === null || _thisRef$current$prop3 === void 0 || _thisRef$current$prop3.call(_thisRef$current$prop4, e);
26
26
  });
27
27
  gc.on('outofmaxbounds', e => {
28
28
  var _thisRef$current$prop5, _thisRef$current$prop6;
29
- (_thisRef$current$prop5 = (_thisRef$current$prop6 = thisRef.current.props).onOutOfMaxBounds) === null || _thisRef$current$prop5 === void 0 ? void 0 : _thisRef$current$prop5.call(_thisRef$current$prop6, e);
29
+ (_thisRef$current$prop5 = (_thisRef$current$prop6 = thisRef.current.props).onOutOfMaxBounds) === null || _thisRef$current$prop5 === void 0 || _thisRef$current$prop5.call(_thisRef$current$prop6, e);
30
30
  });
31
31
  gc.on('trackuserlocationstart', e => {
32
32
  var _thisRef$current$prop7, _thisRef$current$prop8;
33
- (_thisRef$current$prop7 = (_thisRef$current$prop8 = thisRef.current.props).onTrackUserLocationStart) === null || _thisRef$current$prop7 === void 0 ? void 0 : _thisRef$current$prop7.call(_thisRef$current$prop8, e);
33
+ (_thisRef$current$prop7 = (_thisRef$current$prop8 = thisRef.current.props).onTrackUserLocationStart) === null || _thisRef$current$prop7 === void 0 || _thisRef$current$prop7.call(_thisRef$current$prop8, e);
34
34
  });
35
35
  gc.on('trackuserlocationend', e => {
36
36
  var _thisRef$current$prop9, _thisRef$current$prop10;
37
- (_thisRef$current$prop9 = (_thisRef$current$prop10 = thisRef.current.props).onTrackUserLocationEnd) === null || _thisRef$current$prop9 === void 0 ? void 0 : _thisRef$current$prop9.call(_thisRef$current$prop10, e);
37
+ (_thisRef$current$prop9 = (_thisRef$current$prop10 = thisRef.current.props).onTrackUserLocationEnd) === null || _thisRef$current$prop9 === void 0 || _thisRef$current$prop9.call(_thisRef$current$prop10, e);
38
38
  });
39
39
  return gc;
40
40
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"geolocate-control.js","names":["useImperativeHandle","useRef","useEffect","forwardRef","memo","applyReactStyle","useControl","GeolocateControl","props","ref","thisRef","ctrl","_ref","mapLib","gc","setupUI","_setupUI","args","_container","hasChildNodes","on","e","_thisRef$current$prop","_thisRef$current$prop2","current","onGeolocate","call","_thisRef$current$prop3","_thisRef$current$prop4","onError","_thisRef$current$prop5","_thisRef$current$prop6","onOutOfMaxBounds","_thisRef$current$prop7","_thisRef$current$prop8","onTrackUserLocationStart","_thisRef$current$prop9","_thisRef$current$prop10","onTrackUserLocationEnd","position","style"],"sources":["../../src/components/geolocate-control.ts"],"sourcesContent":["import * as React from 'react';\nimport {useImperativeHandle, useRef, useEffect, forwardRef, memo} from 'react';\nimport {applyReactStyle} from '../utils/apply-react-style';\nimport useControl from './use-control';\n\nimport type {\n ControlPosition,\n GeolocateControlInstance,\n GeolocateEvent,\n GeolocateResultEvent,\n GeolocateErrorEvent\n} from '../types';\n\nexport type GeolocateControlProps<\n OptionsT,\n ControlT extends GeolocateControlInstance\n> = OptionsT & {\n /** Placement of the control relative to the map. */\n position?: ControlPosition;\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n\n /** Called on each Geolocation API position update that returned as success. */\n onGeolocate?: (e: GeolocateResultEvent<ControlT>) => void;\n /** Called on each Geolocation API position update that returned as an error. */\n onError?: (e: GeolocateErrorEvent<ControlT>) => void;\n /** Called on each Geolocation API position update that returned as success but user position\n * is out of map `maxBounds`. */\n onOutOfMaxBounds?: (e: GeolocateResultEvent<ControlT>) => void;\n /** Called when the GeolocateControl changes to the active lock state. */\n onTrackUserLocationStart?: (e: GeolocateEvent<ControlT>) => void;\n /** Called when the GeolocateControl changes to the background state. */\n onTrackUserLocationEnd?: (e: GeolocateEvent<ControlT>) => void;\n};\n\nfunction GeolocateControl<GeolocateControlOptions, ControlT extends GeolocateControlInstance>(\n props: GeolocateControlProps<GeolocateControlOptions, ControlT>,\n ref: React.Ref<ControlT>\n) {\n const thisRef = useRef({props});\n\n const ctrl = useControl<ControlT>(\n ({mapLib}) => {\n const gc = new mapLib.GeolocateControl(props) as ControlT;\n\n // Hack: fix GeolocateControl reuse\n // When using React strict mode, the component is mounted twice.\n // GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.\n // @ts-expect-error private method\n const setupUI = gc._setupUI;\n // @ts-expect-error private method\n gc._setupUI = args => {\n if (!gc._container.hasChildNodes()) {\n setupUI(args);\n }\n };\n\n gc.on('geolocate', e => {\n thisRef.current.props.onGeolocate?.(e as GeolocateResultEvent<ControlT>);\n });\n gc.on('error', e => {\n thisRef.current.props.onError?.(e as GeolocateErrorEvent<ControlT>);\n });\n gc.on('outofmaxbounds', e => {\n thisRef.current.props.onOutOfMaxBounds?.(e as GeolocateResultEvent<ControlT>);\n });\n gc.on('trackuserlocationstart', e => {\n thisRef.current.props.onTrackUserLocationStart?.(e as GeolocateEvent<ControlT>);\n });\n gc.on('trackuserlocationend', e => {\n thisRef.current.props.onTrackUserLocationEnd?.(e as GeolocateEvent<ControlT>);\n });\n\n return gc;\n },\n {position: props.position}\n );\n\n thisRef.current.props = props;\n\n useImperativeHandle(ref, () => ctrl, []);\n\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n\n return null;\n}\n\nexport default memo(forwardRef(GeolocateControl));\n"],"mappings":"AACA,SAAQA,mBAAmB,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,IAAI,QAAO,OAAO;AAAC,SACvEC,eAAe;AAAA,OAChBC,UAAU;AAgCjB,SAASC,gBAAgBA,CACvBC,KAA+D,EAC/DC,GAAwB,EACxB;EACA,MAAMC,OAAO,GAAGT,MAAM,CAAC;IAACO;EAAK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AE,CAACM,EAAE,CAAC,wBAAwB,EAAEC,CAAC,IAAI;MAAA,IAAAY,sBAAA,EAAAC,sBAAA;MACnC,CAAAD,sBAAA,IAAAC,sBAAA,GAAAxB,OAAO,CAACc,OAAO,CAAChB,KAAK,EAAC2B,wBAAwB,cAAAF,sBAAA,uBAA9CA,sBAAA,CAAAP,IAAA,CAAAQ,sBAAA,EAAiDb,CAA6B,CAAC;IACjF,CAAC,CAAC;IACFP,EAAE,CAACM,EAAE,CAAC,sBAAsB,EAAEC,CAAC,IAAI;MAAA,IAAAe,sBAAA,EAAAC,uBAAA;MACjC,CAAAD,sBAAA,IAAAC,uBAAA,GAAA3B,OAAO,CAACc,OAAO,CAAChB,KAAK,EAAC8B,sBAAsB,cAAAF,sBAAA,uBAA5CA,sBAAA,CAAAV,IAAA,CAAAW,uBAAA,EAA+ChB,CAA6B,CAAC;IAC/E,CAAC,CAAC;IAEF,OAAOP,EAAE;EACX,CAAC,EACD;IAACyB,QAAQ,EAAE/B,KAAK,CAAC+B;EAAQ,CAC3B,CAAC;EAED7B,OAAO,CAACc,OAAO,CAAChB,KAAK,GAAGA,KAAK;EAE7BR,mBAAmB,CAACS,GAAG,EAAE,MAAME,IAAI,EAAE,EAAE,CAAC;EAExCT,SAAS,CAAC,MAAM;IACdG,eAAe,CAACM,IAAI,CAACO,UAAU,EAAEV,KAAK,CAACgC,KAAK,CAAC;EAC/C,CAAC,EAAE,CAAChC,KAAK,CAACgC,KAAK,CAAC,CAAC;EAEjB,OAAO,IAAI;AACb;AAEA,eAAepC,IAAI,CAACD,UAAU,CAACI,gBAAgB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"geolocate-control.js","names":["useImperativeHandle","useRef","useEffect","forwardRef","memo","applyReactStyle","useControl","GeolocateControl","props","ref","thisRef","ctrl","_ref","mapLib","gc","setupUI","_setupUI","args","_container","hasChildNodes","on","e","_thisRef$current$prop","_thisRef$current$prop2","current","onGeolocate","call","_thisRef$current$prop3","_thisRef$current$prop4","onError","_thisRef$current$prop5","_thisRef$current$prop6","onOutOfMaxBounds","_thisRef$current$prop7","_thisRef$current$prop8","onTrackUserLocationStart","_thisRef$current$prop9","_thisRef$current$prop10","onTrackUserLocationEnd","position","style"],"sources":["../../src/components/geolocate-control.ts"],"sourcesContent":["import * as React from 'react';\nimport {useImperativeHandle, useRef, useEffect, forwardRef, memo} from 'react';\nimport {applyReactStyle} from '../utils/apply-react-style';\nimport useControl from './use-control';\n\nimport type {\n ControlPosition,\n GeolocateControlInstance,\n GeolocateEvent,\n GeolocateResultEvent,\n GeolocateErrorEvent\n} from '../types';\n\nexport type GeolocateControlProps<\n OptionsT,\n ControlT extends GeolocateControlInstance\n> = OptionsT & {\n /** Placement of the control relative to the map. */\n position?: ControlPosition;\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n\n /** Called on each Geolocation API position update that returned as success. */\n onGeolocate?: (e: GeolocateResultEvent<ControlT>) => void;\n /** Called on each Geolocation API position update that returned as an error. */\n onError?: (e: GeolocateErrorEvent<ControlT>) => void;\n /** Called on each Geolocation API position update that returned as success but user position\n * is out of map `maxBounds`. */\n onOutOfMaxBounds?: (e: GeolocateResultEvent<ControlT>) => void;\n /** Called when the GeolocateControl changes to the active lock state. */\n onTrackUserLocationStart?: (e: GeolocateEvent<ControlT>) => void;\n /** Called when the GeolocateControl changes to the background state. */\n onTrackUserLocationEnd?: (e: GeolocateEvent<ControlT>) => void;\n};\n\nfunction GeolocateControl<GeolocateControlOptions, ControlT extends GeolocateControlInstance>(\n props: GeolocateControlProps<GeolocateControlOptions, ControlT>,\n ref: React.Ref<ControlT>\n) {\n const thisRef = useRef({props});\n\n const ctrl = useControl<ControlT>(\n ({mapLib}) => {\n const gc = new mapLib.GeolocateControl(props) as ControlT;\n\n // Hack: fix GeolocateControl reuse\n // When using React strict mode, the component is mounted twice.\n // GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.\n // @ts-expect-error private method\n const setupUI = gc._setupUI;\n // @ts-expect-error private method\n gc._setupUI = args => {\n if (!gc._container.hasChildNodes()) {\n setupUI(args);\n }\n };\n\n gc.on('geolocate', e => {\n thisRef.current.props.onGeolocate?.(e as GeolocateResultEvent<ControlT>);\n });\n gc.on('error', e => {\n thisRef.current.props.onError?.(e as GeolocateErrorEvent<ControlT>);\n });\n gc.on('outofmaxbounds', e => {\n thisRef.current.props.onOutOfMaxBounds?.(e as GeolocateResultEvent<ControlT>);\n });\n gc.on('trackuserlocationstart', e => {\n thisRef.current.props.onTrackUserLocationStart?.(e as GeolocateEvent<ControlT>);\n });\n gc.on('trackuserlocationend', e => {\n thisRef.current.props.onTrackUserLocationEnd?.(e as GeolocateEvent<ControlT>);\n });\n\n return gc;\n },\n {position: props.position}\n );\n\n thisRef.current.props = props;\n\n useImperativeHandle(ref, () => ctrl, []);\n\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n\n return null;\n}\n\nexport default memo(forwardRef(GeolocateControl));\n"],"mappings":"AACA,SAAQA,mBAAmB,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,IAAI,QAAO,OAAO;AAAC,SACvEC,eAAe;AAAA,OAChBC,UAAU;AAgCjB,SAASC,gBAAgBA,CACvBC,KAA+D,EAC/DC,GAAwB,EACxB;EACA,MAAMC,OAAO,GAAGT,MAAM,CAAC;IAACO;EAAK,CAAC,CAAC;EAE/B,MAAMG,IAAI,GAAGL,UAAU,CACrBM,IAAA,IAAc;IAAA,IAAb;MAACC;IAAM,CAAC,GAAAD,IAAA;IACP,MAAME,EAAE,GAAG,IAAID,MAAM,CAACN,gBAAgB,CAACC,KAAK,CAAa;IAMzD,MAAMO,OAAO,GAAGD,EAAE,CAACE,QAAQ;IAE3BF,EAAE,CAACE,QAAQ,GAAGC,IAAI,IAAI;MACpB,IAAI,CAACH,EAAE,CAACI,UAAU,CAACC,aAAa,CAAC,CAAC,EAAE;QAClCJ,OAAO,CAACE,IAAI,CAAC;MACf;IAC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sBAAA,IAAAC,uBAAA,GAAA3B,OAAO,CAACc,OAAO,CAAChB,KAAK,EAAC8B,sBAAsB,cAAAF,sBAAA,eAA5CA,sBAAA,CAAAV,IAAA,CAAAW,uBAAA,EAA+ChB,CAA6B,CAAC;IAC/E,CAAC,CAAC;IAEF,OAAOP,EAAE;EACX,CAAC,EACD;IAACyB,QAAQ,EAAE/B,KAAK,CAAC+B;EAAQ,CAC3B,CAAC;EAED7B,OAAO,CAACc,OAAO,CAAChB,KAAK,GAAGA,KAAK;EAE7BR,mBAAmB,CAACS,GAAG,EAAE,MAAME,IAAI,EAAE,EAAE,CAAC;EAExCT,SAAS,CAAC,MAAM;IACdG,eAAe,CAACM,IAAI,CAACO,UAAU,EAAEV,KAAK,CAACgC,KAAK,CAAC;EAC/C,CAAC,EAAE,CAAChC,KAAK,CAACgC,KAAK,CAAC,CAAC;EAEjB,OAAO,IAAI;AACb;AAEA,eAAepC,IAAI,CAACD,UAAU,CAACI,gBAAgB,CAAC,CAAC","ignoreList":[]}
@@ -1,15 +1,15 @@
1
1
  import type { CustomLayerInterface, ILayer } from '../types';
2
- declare type OptionalId<T> = T extends {
2
+ type OptionalId<T> = T extends {
3
3
  id: string;
4
4
  } ? Omit<T, 'id'> & {
5
5
  id?: string;
6
6
  } : T;
7
- declare type OptionalSource<T> = T extends {
7
+ type OptionalSource<T> = T extends {
8
8
  source: string;
9
9
  } ? Omit<T, 'source'> & {
10
10
  source?: string;
11
11
  } : T;
12
- export declare type LayerProps<LayerT> = OptionalSource<OptionalId<LayerT>> & {
12
+ export type LayerProps<LayerT> = OptionalSource<OptionalId<LayerT>> & {
13
13
  /** If set, the layer will be inserted before the specified layer */
14
14
  beforeId?: string;
15
15
  };
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import { useContext, useEffect, useMemo, useState, useRef } from 'react';
2
5
  import { MapContext } from "./map.js";
3
6
  import assert from "../utils/assert.js";
@@ -54,10 +57,9 @@ function updateLayer(map, id, props, prevProps) {
54
57
  }
55
58
  function createLayer(map, id, props) {
56
59
  if (map.style && map.style._loaded && (!('source' in props) || map.getSource(props.source))) {
57
- const options = {
58
- ...props,
60
+ const options = _objectSpread(_objectSpread({}, props), {}, {
59
61
  id
60
- };
62
+ });
61
63
  delete options.beforeId;
62
64
  map.addLayer(options, props.beforeId);
63
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"layer.js","names":["useContext","useEffect","useMemo","useState","useRef","MapContext","assert","deepEqual","updateLayer","map","id","props","prevProps","type","layout","paint","filter","minzoom","maxzoom","beforeId","moveLayer","prevLayout","key","setLayoutProperty","hasOwnProperty","undefined","prevPaint","setPaintProperty","setFilter","setLayerZoomRange","createLayer","style","_loaded","getSource","source","options","addLayer","layerCounter","Layer","getMap","propsRef","setStyleLoaded","forceUpdate","version","on","off","getLayer","removeLayer","layer","current","error","console","warn"],"sources":["../../src/components/layer.ts"],"sourcesContent":["import {useContext, useEffect, useMemo, useState, useRef} from 'react';\nimport {MapContext} from './map';\nimport assert from '../utils/assert';\nimport {deepEqual} from '../utils/deep-equal';\n\nimport type {MapInstance, CustomLayerInterface, ILayer} from '../types';\n\n// Omiting property from a union type, see\n// https://github.com/microsoft/TypeScript/issues/39556#issuecomment-656925230\ntype OptionalId<T> = T extends {id: string} ? Omit<T, 'id'> & {id?: string} : T;\ntype OptionalSource<T> = T extends {source: string} ? Omit<T, 'source'> & {source?: string} : T;\n\nexport type LayerProps<LayerT> = OptionalSource<OptionalId<LayerT>> & {\n /** If set, the layer will be inserted before the specified layer */\n beforeId?: string;\n};\n\n/* eslint-disable complexity, max-statements */\nfunction updateLayer<LayerT extends ILayer>(\n map: MapInstance,\n id: string,\n props: LayerProps<LayerT>,\n prevProps: LayerProps<LayerT>\n) {\n assert(props.id === prevProps.id, 'layer id changed');\n assert(props.type === prevProps.type, 'layer type changed');\n\n if (props.type === 'custom' || prevProps.type === 'custom') {\n return;\n }\n\n const {layout = {}, paint = {}, filter, minzoom, maxzoom, beforeId} = props;\n\n if (beforeId !== prevProps.beforeId) {\n map.moveLayer(id, beforeId);\n }\n if (layout !== prevProps.layout) {\n const prevLayout = prevProps.layout || {};\n for (const key in layout) {\n if (!deepEqual(layout[key], prevLayout[key])) {\n map.setLayoutProperty(id, key, layout[key]);\n }\n }\n for (const key in prevLayout) {\n if (!layout.hasOwnProperty(key)) {\n map.setLayoutProperty(id, key, undefined);\n }\n }\n }\n if (paint !== prevProps.paint) {\n const prevPaint = prevProps.paint || {};\n for (const key in paint) {\n if (!deepEqual(paint[key], prevPaint[key])) {\n map.setPaintProperty(id, key, paint[key]);\n }\n }\n for (const key in prevPaint) {\n if (!paint.hasOwnProperty(key)) {\n map.setPaintProperty(id, key, undefined);\n }\n }\n }\n\n if (!deepEqual(filter, prevProps.filter)) {\n map.setFilter(id, filter);\n }\n if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {\n map.setLayerZoomRange(id, minzoom, maxzoom);\n }\n}\n\nfunction createLayer<LayerT extends ILayer>(\n map: MapInstance,\n id: string,\n props: LayerProps<LayerT>\n) {\n // @ts-ignore\n if (map.style && map.style._loaded && (!('source' in props) || map.getSource(props.source))) {\n const options: LayerProps<LayerT> = {...props, id};\n delete options.beforeId;\n\n // @ts-ignore\n map.addLayer(options, props.beforeId);\n }\n}\n\n/* eslint-enable complexity, max-statements */\n\nlet layerCounter = 0;\n\nfunction Layer<LayerT extends ILayer>(props: LayerProps<LayerT | CustomLayerInterface>) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n\n const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);\n\n useEffect(() => {\n if (map) {\n const forceUpdate = () => setStyleLoaded(version => version + 1);\n map.on('styledata', forceUpdate);\n forceUpdate();\n\n return () => {\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getLayer(id)) {\n map.removeLayer(id);\n }\n };\n }\n return undefined;\n }, [map]);\n\n // @ts-ignore\n const layer = map && map.style && map.getLayer(id);\n if (layer) {\n try {\n updateLayer(map, id, props, propsRef.current);\n } catch (error) {\n console.warn(error); // eslint-disable-line\n }\n } else {\n createLayer(map, id, props);\n }\n\n // Store last rendered props\n propsRef.current = props;\n\n return null;\n}\n\nexport default Layer;\n"],"mappings":"AAAA,SAAQA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAO,OAAO;AAAC,SAC/DC,UAAU;AAAA,OACXC,MAAM;AAAA,SACLC,SAAS;AAejB,SAASC,WAAWA,CAClBC,GAAgB,EAChBC,EAAU,EACVC,KAAyB,EACzBC,SAA6B,EAC7B;EACAN,MAAM,CAACK,KAAK,CAACD,EAAE,KAAKE,SAAS,CAACF,EAAE,EAAE,kBAAkB,CAAC;EACrDJ,MAAM,CAACK,KAAK,CAACE,IAAI,KAAKD,SAAS,CAACC,IAAI,EAAE,oBAAoB,CAAC;EAE3D,IAAIF,KAAK,CAACE,IAAI,KAAK,QAAQ,IAAID,SAAS,CAACC,IAAI,KAAK,QAAQ,EAAE;IAC1D;EACF;EAEA,MAAM;IAACC,MAAM,GAAG,CAAC,CAAC;IAAEC,KAAK,GAAG,CAAC,CAAC;IAAEC,MAAM;IAAEC,OAAO;IAAEC,OA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IQ,GAAG,EAAE;MACP,MAAMiC,WAAW,GAAGA,CAAA,KAAMD,cAAc,CAACE,OAAO,IAAIA,OAAO,GAAG,CAAC,CAAC;MAChElC,GAAG,CAACmC,EAAE,CAAC,WAAW,EAAEF,WAAW,CAAC;MAChCA,WAAW,CAAC,CAAC;MAEb,OAAO,MAAM;QACXjC,GAAG,CAACoC,GAAG,CAAC,WAAW,EAAEH,WAAW,CAAC;QAEjC,IAAIjC,GAAG,CAACsB,KAAK,IAAItB,GAAG,CAACsB,KAAK,CAACC,OAAO,IAAIvB,GAAG,CAACqC,QAAQ,CAACpC,EAAE,CAAC,EAAE;UACtDD,GAAG,CAACsC,WAAW,CAACrC,EAAE,CAAC;QACrB;MACF,CAAC;IACH;IACA,OAAOe,SAAS;EAClB,CAAC,EAAE,CAAChB,GAAG,CAAC,CAAC;EAGT,MAAMuC,KAAK,GAAGvC,GAAG,IAAIA,GAAG,CAACsB,KAAK,IAAItB,GAAG,CAACqC,QAAQ,CAACpC,EAAE,CAAC;EAClD,IAAIsC,KAAK,EAAE;IACT,IAAI;MACFxC,WAAW,CAACC,GAAG,EAAEC,EAAE,EAAEC,KAAK,EAAE6B,QAAQ,CAACS,OAAO,CAAC;IAC/C,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACC,IAAI,CAACF,KAAK,CAAC;IACrB;EACF,CAAC,MAAM;IACLpB,WAAW,CAACrB,GAAG,EAAEC,EAAE,EAAEC,KAAK,CAAC;EAC7B;EAGA6B,QAAQ,CAACS,OAAO,GAAGtC,KAAK;EAExB,OAAO,IAAI;AACb;AAEA,eAAe2B,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"layer.js","names":["useContext","useEffect","useMemo","useState","useRef","MapContext","assert","deepEqual","updateLayer","map","id","props","prevProps","type","layout","paint","filter","minzoom","maxzoom","beforeId","moveLayer","prevLayout","key","setLayoutProperty","hasOwnProperty","undefined","prevPaint","setPaintProperty","setFilter","setLayerZoomRange","createLayer","style","_loaded","getSource","source","options","_objectSpread","addLayer","layerCounter","Layer","getMap","propsRef","setStyleLoaded","forceUpdate","version","on","off","getLayer","removeLayer","layer","current","error","console","warn"],"sources":["../../src/components/layer.ts"],"sourcesContent":["import {useContext, useEffect, useMemo, useState, useRef} from 'react';\nimport {MapContext} from './map';\nimport assert from '../utils/assert';\nimport {deepEqual} from '../utils/deep-equal';\n\nimport type {MapInstance, CustomLayerInterface, ILayer} from '../types';\n\n// Omiting property from a union type, see\n// https://github.com/microsoft/TypeScript/issues/39556#issuecomment-656925230\ntype OptionalId<T> = T extends {id: string} ? Omit<T, 'id'> & {id?: string} : T;\ntype OptionalSource<T> = T extends {source: string} ? Omit<T, 'source'> & {source?: string} : T;\n\nexport type LayerProps<LayerT> = OptionalSource<OptionalId<LayerT>> & {\n /** If set, the layer will be inserted before the specified layer */\n beforeId?: string;\n};\n\n/* eslint-disable complexity, max-statements */\nfunction updateLayer<LayerT extends ILayer>(\n map: MapInstance,\n id: string,\n props: LayerProps<LayerT>,\n prevProps: LayerProps<LayerT>\n) {\n assert(props.id === prevProps.id, 'layer id changed');\n assert(props.type === prevProps.type, 'layer type changed');\n\n if (props.type === 'custom' || prevProps.type === 'custom') {\n return;\n }\n\n const {layout = {}, paint = {}, filter, minzoom, maxzoom, beforeId} = props;\n\n if (beforeId !== prevProps.beforeId) {\n map.moveLayer(id, beforeId);\n }\n if (layout !== prevProps.layout) {\n const prevLayout = prevProps.layout || {};\n for (const key in layout) {\n if (!deepEqual(layout[key], prevLayout[key])) {\n map.setLayoutProperty(id, key, layout[key]);\n }\n }\n for (const key in prevLayout) {\n if (!layout.hasOwnProperty(key)) {\n map.setLayoutProperty(id, key, undefined);\n }\n }\n }\n if (paint !== prevProps.paint) {\n const prevPaint = prevProps.paint || {};\n for (const key in paint) {\n if (!deepEqual(paint[key], prevPaint[key])) {\n map.setPaintProperty(id, key, paint[key]);\n }\n }\n for (const key in prevPaint) {\n if (!paint.hasOwnProperty(key)) {\n map.setPaintProperty(id, key, undefined);\n }\n }\n }\n\n if (!deepEqual(filter, prevProps.filter)) {\n map.setFilter(id, filter);\n }\n if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {\n map.setLayerZoomRange(id, minzoom, maxzoom);\n }\n}\n\nfunction createLayer<LayerT extends ILayer>(\n map: MapInstance,\n id: string,\n props: LayerProps<LayerT>\n) {\n // @ts-ignore\n if (map.style && map.style._loaded && (!('source' in props) || map.getSource(props.source))) {\n const options: LayerProps<LayerT> = {...props, id};\n delete options.beforeId;\n\n // @ts-ignore\n map.addLayer(options, props.beforeId);\n }\n}\n\n/* eslint-enable complexity, max-statements */\n\nlet layerCounter = 0;\n\nfunction Layer<LayerT extends ILayer>(props: LayerProps<LayerT | CustomLayerInterface>) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n\n const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);\n\n useEffect(() => {\n if (map) {\n const forceUpdate = () => setStyleLoaded(version => version + 1);\n map.on('styledata', forceUpdate);\n forceUpdate();\n\n return () => {\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getLayer(id)) {\n map.removeLayer(id);\n }\n };\n }\n return undefined;\n }, [map]);\n\n // @ts-ignore\n const layer = map && map.style && map.getLayer(id);\n if (layer) {\n try {\n updateLayer(map, id, props, propsRef.current);\n } catch (error) {\n console.warn(error); // eslint-disable-line\n }\n } else {\n createLayer(map, id, props);\n }\n\n // Store last rendered props\n propsRef.current = props;\n\n return null;\n}\n\nexport default Layer;\n"],"mappings":";;;AAAA,SAAQA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAO,OAAO;AAAC,SAC/DC,UAAU;AAAA,OACXC,MAAM;AAAA,SACLC,SAAS;AAejB,SAASC,WAAWA,CAClBC,GAAgB,EAChBC,EAAU,EACVC,KAAyB,EACzBC,SAA6B,EAC7B;EACAN,MAAM,CA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ACLrB,WAAW,CAACrB,GAAG,EAAEC,EAAE,EAAEC,KAAK,CAAC;EAC7B;EAGA8B,QAAQ,CAACS,OAAO,GAAGvC,KAAK;EAExB,OAAO,IAAI;AACb;AAEA,eAAe4B,KAAK","ignoreList":[]}
@@ -4,13 +4,13 @@ import { MapRef } from '../mapbox/create-ref';
4
4
  import type { CSSProperties } from 'react';
5
5
  import { GlobalSettings } from '../utils/set-globals';
6
6
  import type { MapLib, MapInstance, MapStyle, Callbacks } from '../types';
7
- export declare type MapContextValue<MapT extends MapInstance = MapInstance> = {
7
+ export type MapContextValue<MapT extends MapInstance = MapInstance> = {
8
8
  mapLib: MapLib<MapT>;
9
9
  map: MapRef<MapT>;
10
10
  };
11
11
  export declare const MapContext: React.Context<MapContextValue<MapInstance>>;
12
- declare type MapInitOptions<MapOptions> = Omit<MapOptions, 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'>;
13
- export declare type MapProps<MapOptions, StyleT extends MapStyle, CallbacksT extends Callbacks, MapT extends MapInstance> = MapInitOptions<MapOptions> & MapboxProps<StyleT, CallbacksT> & GlobalSettings & {
12
+ type MapInitOptions<MapOptions> = Omit<MapOptions, 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'>;
13
+ export type MapProps<MapOptions, StyleT extends MapStyle, CallbacksT extends Callbacks, MapT extends MapInstance> = MapInitOptions<MapOptions> & MapboxProps<StyleT, CallbacksT> & GlobalSettings & {
14
14
  mapLib?: MapLib<MapT> | Promise<MapLib<MapT>>;
15
15
  reuseMaps?: boolean;
16
16
  /** Map container id */
@@ -19,5 +19,5 @@ export declare type MapProps<MapOptions, StyleT extends MapStyle, CallbacksT ext
19
19
  style?: CSSProperties;
20
20
  children?: any;
21
21
  };
22
- export default function Map<MapOptions, StyleT extends MapStyle, CallbacksT extends Callbacks, MapT extends MapInstance>(props: MapProps<MapOptions, StyleT, CallbacksT, MapT>, ref: React.Ref<MapRef<MapT>>, defaultLib: MapLib<MapT> | Promise<MapLib<MapT>>): JSX.Element;
22
+ export default function Map<MapOptions, StyleT extends MapStyle, CallbacksT extends Callbacks, MapT extends MapInstance>(props: MapProps<MapOptions, StyleT, CallbacksT, MapT>, ref: React.Ref<MapRef<MapT>>, defaultLib: MapLib<MapT> | Promise<MapLib<MapT>>): React.JSX.Element;
23
23
  export {};
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import * as React from 'react';
2
5
  import { useState, useRef, useEffect, useContext, useMemo, useImperativeHandle } from 'react';
3
6
  import { MountedMapsContext } from "./use-map.js";
@@ -42,7 +45,7 @@ export default function Map(props, ref, defaultLib) {
42
45
  contextValue.map = createRef(mapbox);
43
46
  contextValue.mapLib = mapboxgl;
44
47
  setMapInstance(mapbox);
45
- mountedMapsContext === null || mountedMapsContext === void 0 ? void 0 : mountedMapsContext.onMapMount(contextValue.map, props.id);
48
+ mountedMapsContext === null || mountedMapsContext === void 0 || mountedMapsContext.onMapMount(contextValue.map, props.id);
46
49
  } else {
47
50
  throw new Error('Map is not supported by this browser');
48
51
  }
@@ -64,7 +67,7 @@ export default function Map(props, ref, defaultLib) {
64
67
  return () => {
65
68
  isMounted = false;
66
69
  if (mapbox) {
67
- mountedMapsContext === null || mountedMapsContext === void 0 ? void 0 : mountedMapsContext.onMapUnmount(props.id);
70
+ mountedMapsContext === null || mountedMapsContext === void 0 || mountedMapsContext.onMapUnmount(props.id);
68
71
  if (props.reuseMaps) {
69
72
  mapbox.recycle();
70
73
  } else {
@@ -79,12 +82,11 @@ export default function Map(props, ref, defaultLib) {
79
82
  }
80
83
  });
81
84
  useImperativeHandle(ref, () => contextValue.map, [mapInstance]);
82
- const style = useMemo(() => ({
85
+ const style = useMemo(() => _objectSpread({
83
86
  position: 'relative',
84
87
  width: '100%',
85
- height: '100%',
86
- ...props.style
87
- }), [props.style]);
88
+ height: '100%'
89
+ }, props.style), [props.style]);
88
90
  const CHILD_CONTAINER_STYLE = {
89
91
  height: '100%'
90
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","names":["React","useState","useRef","useEffect","useContext","useMemo","useImperativeHandle","MountedMapsContext","Mapbox","createRef","useIsomorphicLayoutEffect","setGlobals","MapContext","createContext","Map","props","ref","defaultLib","mountedMapsContext","mapInstance","setMapInstance","containerRef","current","contextValue","mapLib","map","isMounted","mapbox","Promise","resolve","then","module","Error","mapboxgl","default","supported","reuseMaps","reuse","onMapMount","id","catch","error","onError","type","target","originalEvent","console","onMapUnmount","recycle","destroy","setProps","style","position","width","height","CHILD_CONTAINER_STYLE","createElement","Provider","value","children"],"sources":["../../src/components/map.tsx"],"sourcesContent":["import * as React from 'react';\nimport {useState, useRef, useEffect, useContext, useMemo, useImperativeHandle} from 'react';\n\nimport {MountedMapsContext} from './use-map';\nimport Mapbox, {MapboxProps} from '../mapbox/mapbox';\nimport createRef, {MapRef} from '../mapbox/create-ref';\n\nimport type {CSSProperties} from 'react';\nimport useIsomorphicLayoutEffect from '../utils/use-isomorphic-layout-effect';\nimport setGlobals, {GlobalSettings} from '../utils/set-globals';\nimport type {MapLib, MapInstance, MapStyle, Callbacks} from '../types';\n\nexport type MapContextValue<MapT extends MapInstance = MapInstance> = {\n mapLib: MapLib<MapT>;\n map: MapRef<MapT>;\n};\n\nexport const MapContext = React.createContext<MapContextValue>(null);\n\ntype MapInitOptions<MapOptions> = Omit<\n MapOptions,\n 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'\n>;\n\nexport type MapProps<\n MapOptions,\n StyleT extends MapStyle,\n CallbacksT extends Callbacks,\n MapT extends MapInstance\n> = MapInitOptions<MapOptions> &\n MapboxProps<StyleT, CallbacksT> &\n GlobalSettings & {\n mapLib?: MapLib<MapT> | Promise<MapLib<MapT>>;\n reuseMaps?: boolean;\n /** Map container id */\n id?: string;\n /** Map container CSS style */\n style?: CSSProperties;\n children?: any;\n };\n\nexport default function Map<\n MapOptions,\n StyleT extends MapStyle,\n CallbacksT extends Callbacks,\n MapT extends MapInstance\n>(\n props: MapProps<MapOptions, StyleT, CallbacksT, MapT>,\n ref: React.Ref<MapRef<MapT>>,\n defaultLib: MapLib<MapT> | Promise<MapLib<MapT>>\n) {\n const mountedMapsContext = useContext(MountedMapsContext);\n const [mapInstance, setMapInstance] = useState<Mapbox<StyleT, CallbacksT, MapT>>(null);\n const containerRef = useRef();\n\n const {current: contextValue} = useRef<MapContextValue<MapT>>({mapLib: null, map: null});\n\n useEffect(() => {\n const mapLib = props.mapLib;\n let isMounted = true;\n let mapbox: Mapbox<StyleT, CallbacksT, MapT>;\n\n Promise.resolve(mapLib || defaultLib)\n .then((module: MapLib<MapT> | {default: MapLib<MapT>}) => {\n if (!isMounted) {\n return;\n }\n if (!module) {\n throw new Error('Invalid mapLib');\n }\n const mapboxgl = 'Map' in module ? module : module.default;\n if (!mapboxgl.Map) {\n throw new Error('Invalid mapLib');\n }\n\n // workerUrl & workerClass may change the result of supported()\n // https://github.com/visgl/react-map-gl/discussions/2027\n setGlobals(mapboxgl, props);\n if (!mapboxgl.supported || mapboxgl.supported(props)) {\n if (props.reuseMaps) {\n mapbox = Mapbox.reuse(props, containerRef.current);\n }\n if (!mapbox) {\n mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);\n }\n contextValue.map = createRef(mapbox);\n contextValue.mapLib = mapboxgl;\n\n setMapInstance(mapbox);\n mountedMapsContext?.onMapMount(contextValue.map, props.id);\n } else {\n throw new Error('Map is not supported by this browser');\n }\n })\n .catch(error => {\n const {onError} = props;\n if (onError) {\n onError({\n type: 'error',\n target: null,\n originalEvent: null,\n error\n });\n } else {\n console.error(error); // eslint-disable-line\n }\n });\n\n return () => {\n isMounted = false;\n if (mapbox) {\n mountedMapsContext?.onMapUnmount(props.id);\n if (props.reuseMaps) {\n mapbox.recycle();\n } else {\n mapbox.destroy();\n }\n }\n };\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n if (mapInstance) {\n mapInstance.setProps(props);\n }\n });\n\n useImperativeHandle(ref, () => contextValue.map, [mapInstance]);\n\n const style: CSSProperties = useMemo(\n () => ({\n position: 'relative',\n width: '100%',\n height: '100%',\n ...props.style\n }),\n [props.style]\n );\n\n const CHILD_CONTAINER_STYLE = {\n height: '100%'\n };\n\n return (\n <div id={props.id} ref={containerRef} style={style}>\n {mapInstance && (\n <MapContext.Provider value={contextValue}>\n <div mapboxgl-children=\"\" style={CHILD_CONTAINER_STYLE}>\n {props.children}\n </div>\n </MapContext.Provider>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,mBAAmB,QAAO,OAAO;AAAC,SAEpFC,kBAAkB;AAAA,OACnBC,MAAM;AAAA,OACNC,SAAS;AAAA,OAGTC,yBAAyB;AAAA,OACzBC,UAAU;AAQjB,OAAO,MAAMC,UAAU,GAAGZ,KAAK,CAACa,aAAa,CAAkB,IAAI,CAAC;AAwBpE,eAAe,SAASC,GAAGA,CAMzBC,KAAqD,EACrDC,GAA4B,EAC5BC,UAAgD,EAChD;EACA,MAAMC,kBAAkB,GAAGd,UAAU,CAACG,kBAAkB,CAAC;EACzD,MAAM,CAACY,WAAW,EAAEC,cAAc,CAAC,GAAGnB,QAAQ,CA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AK,CAACoC;EACX,CAAC,CAAC,EACF,CAACpC,KAAK,CAACoC,KAAK,CACd,CAAC;EAED,MAAMI,qBAAqB,GAAG;IAC5BD,MAAM,EAAE;EACV,CAAC;EAED,OACEtD,KAAA,CAAAwD,aAAA;IAAKjB,EAAE,EAAExB,KAAK,CAACwB,EAAG;IAACvB,GAAG,EAAEK,YAAa;IAAC8B,KAAK,EAAEA;EAAM,GAChDhC,WAAW,IACVnB,KAAA,CAAAwD,aAAA,CAAC5C,UAAU,CAAC6C,QAAQ;IAACC,KAAK,EAAEnC;EAAa,GACvCvB,KAAA,CAAAwD,aAAA;IAAK,qBAAkB,EAAE;IAACL,KAAK,EAAEI;EAAsB,GACpDxC,KAAK,CAAC4C,QACJ,CACc,CAEpB,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"file":"map.js","names":["React","useState","useRef","useEffect","useContext","useMemo","useImperativeHandle","MountedMapsContext","Mapbox","createRef","useIsomorphicLayoutEffect","setGlobals","MapContext","createContext","Map","props","ref","defaultLib","mountedMapsContext","mapInstance","setMapInstance","containerRef","current","contextValue","mapLib","map","isMounted","mapbox","Promise","resolve","then","module","Error","mapboxgl","default","supported","reuseMaps","reuse","onMapMount","id","catch","error","onError","type","target","originalEvent","console","onMapUnmount","recycle","destroy","setProps","style","_objectSpread","position","width","height","CHILD_CONTAINER_STYLE","createElement","Provider","value","children"],"sources":["../../src/components/map.tsx"],"sourcesContent":["import * as React from 'react';\nimport {useState, useRef, useEffect, useContext, useMemo, useImperativeHandle} from 'react';\n\nimport {MountedMapsContext} from './use-map';\nimport Mapbox, {MapboxProps} from '../mapbox/mapbox';\nimport createRef, {MapRef} from '../mapbox/create-ref';\n\nimport type {CSSProperties} from 'react';\nimport useIsomorphicLayoutEffect from '../utils/use-isomorphic-layout-effect';\nimport setGlobals, {GlobalSettings} from '../utils/set-globals';\nimport type {MapLib, MapInstance, MapStyle, Callbacks} from '../types';\n\nexport type MapContextValue<MapT extends MapInstance = MapInstance> = {\n mapLib: MapLib<MapT>;\n map: MapRef<MapT>;\n};\n\nexport const MapContext = React.createContext<MapContextValue>(null);\n\ntype MapInitOptions<MapOptions> = Omit<\n MapOptions,\n 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'\n>;\n\nexport type MapProps<\n MapOptions,\n StyleT extends MapStyle,\n CallbacksT extends Callbacks,\n MapT extends MapInstance\n> = MapInitOptions<MapOptions> &\n MapboxProps<StyleT, CallbacksT> &\n GlobalSettings & {\n mapLib?: MapLib<MapT> | Promise<MapLib<MapT>>;\n reuseMaps?: boolean;\n /** Map container id */\n id?: string;\n /** Map container CSS style */\n style?: CSSProperties;\n children?: any;\n };\n\nexport default function Map<\n MapOptions,\n StyleT extends MapStyle,\n CallbacksT extends Callbacks,\n MapT extends MapInstance\n>(\n props: MapProps<MapOptions, StyleT, CallbacksT, MapT>,\n ref: React.Ref<MapRef<MapT>>,\n defaultLib: MapLib<MapT> | Promise<MapLib<MapT>>\n) {\n const mountedMapsContext = useContext(MountedMapsContext);\n const [mapInstance, setMapInstance] = useState<Mapbox<StyleT, CallbacksT, MapT>>(null);\n const containerRef = useRef();\n\n const {current: contextValue} = useRef<MapContextValue<MapT>>({mapLib: null, map: null});\n\n useEffect(() => {\n const mapLib = props.mapLib;\n let isMounted = true;\n let mapbox: Mapbox<StyleT, CallbacksT, MapT>;\n\n Promise.resolve(mapLib || defaultLib)\n .then((module: MapLib<MapT> | {default: MapLib<MapT>}) => {\n if (!isMounted) {\n return;\n }\n if (!module) {\n throw new Error('Invalid mapLib');\n }\n const mapboxgl = 'Map' in module ? module : module.default;\n if (!mapboxgl.Map) {\n throw new Error('Invalid mapLib');\n }\n\n // workerUrl & workerClass may change the result of supported()\n // https://github.com/visgl/react-map-gl/discussions/2027\n setGlobals(mapboxgl, props);\n if (!mapboxgl.supported || mapboxgl.supported(props)) {\n if (props.reuseMaps) {\n mapbox = Mapbox.reuse(props, containerRef.current);\n }\n if (!mapbox) {\n mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);\n }\n contextValue.map = createRef(mapbox);\n contextValue.mapLib = mapboxgl;\n\n setMapInstance(mapbox);\n mountedMapsContext?.onMapMount(contextValue.map, props.id);\n } else {\n throw new Error('Map is not supported by this browser');\n }\n })\n .catch(error => {\n const {onError} = props;\n if (onError) {\n onError({\n type: 'error',\n target: null,\n originalEvent: null,\n error\n });\n } else {\n console.error(error); // eslint-disable-line\n }\n });\n\n return () => {\n isMounted = false;\n if (mapbox) {\n mountedMapsContext?.onMapUnmount(props.id);\n if (props.reuseMaps) {\n mapbox.recycle();\n } else {\n mapbox.destroy();\n }\n }\n };\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n if (mapInstance) {\n mapInstance.setProps(props);\n }\n });\n\n useImperativeHandle(ref, () => contextValue.map, [mapInstance]);\n\n const style: CSSProperties = useMemo(\n () => ({\n position: 'relative',\n width: '100%',\n height: '100%',\n ...props.style\n }),\n [props.style]\n );\n\n const CHILD_CONTAINER_STYLE = {\n height: '100%'\n };\n\n return (\n <div id={props.id} ref={containerRef} style={style}>\n {mapInstance && (\n <MapContext.Provider value={contextValue}>\n <div mapboxgl-children=\"\" style={CHILD_CONTAINER_STYLE}>\n {props.children}\n </div>\n </MapContext.Provider>\n )}\n </div>\n );\n}\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,mBAAmB,QAAO,OAAO;AAAC,SAEpFC,kBAAkB;AAAA,OACnBC,MAAM;AAAA,OACNC,SAAS;AAAA,OAGTC,yBAAyB;AAAA,OACzBC,UAAU;AAQjB,OAAO,MAAMC,UAAU,GAAGZ,KAAK,CAACa,aAAa,CAAkB,IAAI,CAAC;AAwBpE,eAAe,SAASC,GAAGA,CAMzBC,KAAqD,EACrDC,GAA4B,EAC5BC,UAAgD,EAChD;EACA,MAAMC,kBAAkB,GAAGd,UAAU,CAACG,kBAA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AAE,UAAU;IACpBC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EAAM,GACXxC,KAAK,CAACoC,KAAK,CACd,EACF,CAACpC,KAAK,CAACoC,KAAK,CACd,CAAC;EAED,MAAMK,qBAAqB,GAAG;IAC5BD,MAAM,EAAE;EACV,CAAC;EAED,OACEvD,KAAA,CAAAyD,aAAA;IAAKlB,EAAE,EAAExB,KAAK,CAACwB,EAAG;IAACvB,GAAG,EAAEK,YAAa;IAAC8B,KAAK,EAAEA;EAAM,GAChDhC,WAAW,IACVnB,KAAA,CAAAyD,aAAA,CAAC7C,UAAU,CAAC8C,QAAQ;IAACC,KAAK,EAAEpC;EAAa,GACvCvB,KAAA,CAAAyD,aAAA;IAAK,qBAAkB,EAAE;IAACN,KAAK,EAAEK;EAAsB,GACpDzC,KAAK,CAAC6C,QACJ,CACc,CAEpB,CAAC;AAEV","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { MarkerEvent, MarkerDragEvent, PointLike, MarkerInstance } from '../types';
3
- export declare type MarkerProps<OptionsT, MarkerT extends MarkerInstance> = OptionsT & {
3
+ export type MarkerProps<OptionsT, MarkerT extends MarkerInstance> = OptionsT & {
4
4
  /** Longitude of the anchor location */
5
5
  longitude: number;
6
6
  /** Latitude of the anchor location */
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import * as React from 'react';
2
5
  import { createPortal } from 'react-dom';
3
6
  import { useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo } from 'react';
@@ -20,15 +23,14 @@ function Marker(props, ref) {
20
23
  hasChildren = true;
21
24
  }
22
25
  });
23
- const options = {
24
- ...props,
26
+ const options = _objectSpread(_objectSpread({}, props), {}, {
25
27
  element: hasChildren ? document.createElement('div') : null
26
- };
28
+ });
27
29
  const mk = new mapLib.Marker(options);
28
30
  mk.setLngLat([props.longitude, props.latitude]);
29
31
  mk.getElement().addEventListener('click', e => {
30
32
  var _thisRef$current$prop, _thisRef$current$prop2;
31
- (_thisRef$current$prop = (_thisRef$current$prop2 = thisRef.current.props).onClick) === null || _thisRef$current$prop === void 0 ? void 0 : _thisRef$current$prop.call(_thisRef$current$prop2, {
33
+ (_thisRef$current$prop = (_thisRef$current$prop2 = thisRef.current.props).onClick) === null || _thisRef$current$prop === void 0 || _thisRef$current$prop.call(_thisRef$current$prop2, {
32
34
  type: 'click',
33
35
  target: mk,
34
36
  originalEvent: e
@@ -38,19 +40,19 @@ function Marker(props, ref) {
38
40
  var _thisRef$current$prop3, _thisRef$current$prop4;
39
41
  const evt = e;
40
42
  evt.lngLat = marker.getLngLat();
41
- (_thisRef$current$prop3 = (_thisRef$current$prop4 = thisRef.current.props).onDragStart) === null || _thisRef$current$prop3 === void 0 ? void 0 : _thisRef$current$prop3.call(_thisRef$current$prop4, evt);
43
+ (_thisRef$current$prop3 = (_thisRef$current$prop4 = thisRef.current.props).onDragStart) === null || _thisRef$current$prop3 === void 0 || _thisRef$current$prop3.call(_thisRef$current$prop4, evt);
42
44
  });
43
45
  mk.on('drag', e => {
44
46
  var _thisRef$current$prop5, _thisRef$current$prop6;
45
47
  const evt = e;
46
48
  evt.lngLat = marker.getLngLat();
47
- (_thisRef$current$prop5 = (_thisRef$current$prop6 = thisRef.current.props).onDrag) === null || _thisRef$current$prop5 === void 0 ? void 0 : _thisRef$current$prop5.call(_thisRef$current$prop6, evt);
49
+ (_thisRef$current$prop5 = (_thisRef$current$prop6 = thisRef.current.props).onDrag) === null || _thisRef$current$prop5 === void 0 || _thisRef$current$prop5.call(_thisRef$current$prop6, evt);
48
50
  });
49
51
  mk.on('dragend', e => {
50
52
  var _thisRef$current$prop7, _thisRef$current$prop8;
51
53
  const evt = e;
52
54
  evt.lngLat = marker.getLngLat();
53
- (_thisRef$current$prop7 = (_thisRef$current$prop8 = thisRef.current.props).onDragEnd) === null || _thisRef$current$prop7 === void 0 ? void 0 : _thisRef$current$prop7.call(_thisRef$current$prop8, evt);
55
+ (_thisRef$current$prop7 = (_thisRef$current$prop8 = thisRef.current.props).onDragEnd) === null || _thisRef$current$prop7 === void 0 || _thisRef$current$prop7.call(_thisRef$current$prop8, evt);
54
56
  });
55
57
  return mk;
56
58
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"marker.js","names":["React","createPortal","useImperativeHandle","useEffect","useMemo","useRef","useContext","forwardRef","memo","applyReactStyle","MapContext","arePointsEqual","Marker","props","ref","map","mapLib","thisRef","current","marker","hasChildren","Children","forEach","children","el","options","element","document","createElement","mk","setLngLat","longitude","latitude","getElement","addEventListener","e","_thisRef$current$prop","_thisRef$current$prop2","onClick","call","type","target","originalEvent","on","_thisRef$current$prop3","_thisRef$current$prop4","evt","lngLat","getLngLat","onDragStart","_thisRef$current$prop5","_thisRef$current$prop6","onDrag","_thisRef$current$prop7","_thisRef$current$prop8","onDragEnd","addTo","getMap","remove","offset","style","draggable","popup","rotation","rotationAlignment","pitchAlignment","lng","lat","getOffset","setOffset","isDraggable","setDraggable","getRotation","setRotation","getRotationAlignment","setRotationAlignment","getPitchAlignment","setPitchAlignment","getPopup","setPopup"],"sources":["../../src/components/marker.ts"],"sourcesContent":["/* global document */\nimport * as React from 'react';\nimport {createPortal} from 'react-dom';\nimport {useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo} from 'react';\nimport {applyReactStyle} from '../utils/apply-react-style';\n\nimport type {MarkerEvent, MarkerDragEvent, PointLike, MarkerInstance} from '../types';\n\nimport {MapContext} from './map';\nimport {arePointsEqual} from '../utils/deep-equal';\n\nexport type MarkerProps<OptionsT, MarkerT extends MarkerInstance> = OptionsT & {\n /** Longitude of the anchor location */\n longitude: number;\n /** Latitude of the anchor location */\n latitude: number;\n\n // These types will be further constraint by OptionsT\n draggable?: boolean;\n offset?: PointLike;\n pitchAlignment?: string;\n rotation?: number;\n rotationAlignment?: string;\n popup?: any;\n\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n onClick?: (e: MarkerEvent<MarkerT, MouseEvent>) => void;\n onDragStart?: (e: MarkerDragEvent<MarkerT>) => void;\n onDrag?: (e: MarkerDragEvent<MarkerT>) => void;\n onDragEnd?: (e: MarkerDragEvent<MarkerT>) => void;\n children?: React.ReactNode;\n};\n\n/* eslint-disable complexity,max-statements */\nfunction Marker<MarkerOptions, MarkerT extends MarkerInstance>(\n props: MarkerProps<MarkerOptions, MarkerT>,\n ref: React.Ref<MarkerT>\n) {\n const {map, mapLib} = useContext(MapContext);\n const thisRef = useRef({props});\n thisRef.current.props = props;\n\n const marker: MarkerT = useMemo(() => {\n let hasChildren = false;\n React.Children.forEach(props.children, el => {\n if (el) {\n hasChildren = true;\n }\n });\n const options = {\n ...props,\n element: hasChildren ? document.createElement('div') : null\n };\n\n const mk = new mapLib.Marker(options) as MarkerT;\n mk.setLngLat([props.longitude, props.latitude]);\n\n mk.getElement().addEventListener('click', (e: MouseEvent) => {\n thisRef.current.props.onClick?.({\n type: 'click',\n target: mk,\n originalEvent: e\n });\n });\n\n mk.on('dragstart', e => {\n const evt = e as MarkerDragEvent<MarkerT>;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDragStart?.(evt);\n });\n mk.on('drag', e => {\n const evt = e as MarkerDragEvent<MarkerT>;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDrag?.(evt);\n });\n mk.on('dragend', e => {\n const evt = e as MarkerDragEvent<MarkerT>;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDragEnd?.(evt);\n });\n\n return mk;\n }, []);\n\n useEffect(() => {\n marker.addTo(map.getMap());\n\n return () => {\n marker.remove();\n };\n }, []);\n\n const {\n longitude,\n latitude,\n offset,\n style,\n draggable = false,\n popup = null,\n rotation = 0,\n rotationAlignment = 'auto',\n pitchAlignment = 'auto'\n } = props;\n\n useEffect(() => {\n applyReactStyle(marker.getElement(), style);\n }, [style]);\n\n useImperativeHandle(ref, () => marker, []);\n\n if (marker.getLngLat().lng !== longitude || marker.getLngLat().lat !== latitude) {\n marker.setLngLat([longitude, latitude]);\n }\n if (offset && !arePointsEqual(marker.getOffset(), offset)) {\n marker.setOffset(offset);\n }\n if (marker.isDraggable() !== draggable) {\n marker.setDraggable(draggable);\n }\n if (marker.getRotation() !== rotation) {\n marker.setRotation(rotation);\n }\n if (marker.getRotationAlignment() !== rotationAlignment) {\n marker.setRotationAlignment(rotationAlignment);\n }\n if (marker.getPitchAlignment() !== pitchAlignment) {\n marker.setPitchAlignment(pitchAlignment);\n }\n if (marker.getPopup() !== popup) {\n marker.setPopup(popup);\n }\n\n return createPortal(props.children, marker.getElement());\n}\n\nexport default memo(forwardRef(Marker));\n"],"mappings":"AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,YAAY,QAAO,WAAW;AACtC,SAAQC,mBAAmB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAEC,IAAI,QAAO,OAAO;AAAC,SAC5FC,eAAe;AAAA,SAIfC,UAAU;AAAA,SACVC,cAAc;AA0BtB,SAASC,MAAMA,CACbC,KAA0C,EAC1CC,GAAuB,EACvB;EACA,MAAM;IAACC,GAAG;IAAEC;EAAM,CAAC,GAAGV,UAAU,CAACI,UAAU,CAAC;EAC5C,MAAMO,OAAO,GAAGZ,MAAM,CA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AC,KAAKhB,KAAK,EAAE;IAC/B3C,MAAM,CAAC4D,QAAQ,CAACjB,KAAK,CAAC;EACxB;EAEA,OAAO7D,YAAY,CAACY,KAAK,CAACU,QAAQ,EAAEJ,MAAM,CAACc,UAAU,CAAC,CAAC,CAAC;AAC1D;AAEA,eAAezB,IAAI,CAACD,UAAU,CAACK,MAAM,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"marker.js","names":["React","createPortal","useImperativeHandle","useEffect","useMemo","useRef","useContext","forwardRef","memo","applyReactStyle","MapContext","arePointsEqual","Marker","props","ref","map","mapLib","thisRef","current","marker","hasChildren","Children","forEach","children","el","options","_objectSpread","element","document","createElement","mk","setLngLat","longitude","latitude","getElement","addEventListener","e","_thisRef$current$prop","_thisRef$current$prop2","onClick","call","type","target","originalEvent","on","_thisRef$current$prop3","_thisRef$current$prop4","evt","lngLat","getLngLat","onDragStart","_thisRef$current$prop5","_thisRef$current$prop6","onDrag","_thisRef$current$prop7","_thisRef$current$prop8","onDragEnd","addTo","getMap","remove","offset","style","draggable","popup","rotation","rotationAlignment","pitchAlignment","lng","lat","getOffset","setOffset","isDraggable","setDraggable","getRotation","setRotation","getRotationAlignment","setRotationAlignment","getPitchAlignment","setPitchAlignment","getPopup","setPopup"],"sources":["../../src/components/marker.ts"],"sourcesContent":["/* global document */\nimport * as React from 'react';\nimport {createPortal} from 'react-dom';\nimport {useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo} from 'react';\nimport {applyReactStyle} from '../utils/apply-react-style';\n\nimport type {MarkerEvent, MarkerDragEvent, PointLike, MarkerInstance} from '../types';\n\nimport {MapContext} from './map';\nimport {arePointsEqual} from '../utils/deep-equal';\n\nexport type MarkerProps<OptionsT, MarkerT extends MarkerInstance> = OptionsT & {\n /** Longitude of the anchor location */\n longitude: number;\n /** Latitude of the anchor location */\n latitude: number;\n\n // These types will be further constraint by OptionsT\n draggable?: boolean;\n offset?: PointLike;\n pitchAlignment?: string;\n rotation?: number;\n rotationAlignment?: string;\n popup?: any;\n\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n onClick?: (e: MarkerEvent<MarkerT, MouseEvent>) => void;\n onDragStart?: (e: MarkerDragEvent<MarkerT>) => void;\n onDrag?: (e: MarkerDragEvent<MarkerT>) => void;\n onDragEnd?: (e: MarkerDragEvent<MarkerT>) => void;\n children?: React.ReactNode;\n};\n\n/* eslint-disable complexity,max-statements */\nfunction Marker<MarkerOptions, MarkerT extends MarkerInstance>(\n props: MarkerProps<MarkerOptions, MarkerT>,\n ref: React.Ref<MarkerT>\n) {\n const {map, mapLib} = useContext(MapContext);\n const thisRef = useRef({props});\n thisRef.current.props = props;\n\n const marker: MarkerT = useMemo(() => {\n let hasChildren = false;\n React.Children.forEach(props.children, el => {\n if (el) {\n hasChildren = true;\n }\n });\n const options = {\n ...props,\n element: hasChildren ? document.createElement('div') : null\n };\n\n const mk = new mapLib.Marker(options) as MarkerT;\n mk.setLngLat([props.longitude, props.latitude]);\n\n mk.getElement().addEventListener('click', (e: MouseEvent) => {\n thisRef.current.props.onClick?.({\n type: 'click',\n target: mk,\n originalEvent: e\n });\n });\n\n mk.on('dragstart', e => {\n const evt = e as MarkerDragEvent<MarkerT>;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDragStart?.(evt);\n });\n mk.on('drag', e => {\n const evt = e as MarkerDragEvent<MarkerT>;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDrag?.(evt);\n });\n mk.on('dragend', e => {\n const evt = e as MarkerDragEvent<MarkerT>;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDragEnd?.(evt);\n });\n\n return mk;\n }, []);\n\n useEffect(() => {\n marker.addTo(map.getMap());\n\n return () => {\n marker.remove();\n };\n }, []);\n\n const {\n longitude,\n latitude,\n offset,\n style,\n draggable = false,\n popup = null,\n rotation = 0,\n rotationAlignment = 'auto',\n pitchAlignment = 'auto'\n } = props;\n\n useEffect(() => {\n applyReactStyle(marker.getElement(), style);\n }, [style]);\n\n useImperativeHandle(ref, () => marker, []);\n\n if (marker.getLngLat().lng !== longitude || marker.getLngLat().lat !== latitude) {\n marker.setLngLat([longitude, latitude]);\n }\n if (offset && !arePointsEqual(marker.getOffset(), offset)) {\n marker.setOffset(offset);\n }\n if (marker.isDraggable() !== draggable) {\n marker.setDraggable(draggable);\n }\n if (marker.getRotation() !== rotation) {\n marker.setRotation(rotation);\n }\n if (marker.getRotationAlignment() !== rotationAlignment) {\n marker.setRotationAlignment(rotationAlignment);\n }\n if (marker.getPitchAlignment() !== pitchAlignment) {\n marker.setPitchAlignment(pitchAlignment);\n }\n if (marker.getPopup() !== popup) {\n marker.setPopup(popup);\n }\n\n return createPortal(props.children, marker.getElement());\n}\n\nexport default memo(forwardRef(Marker));\n"],"mappings":";;;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,YAAY,QAAO,WAAW;AACtC,SAAQC,mBAAmB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAEC,IAAI,QAAO,OAAO;AAAC,SAC5FC,eAAe;AAAA,SAIfC,UAAU;AAAA,SACVC,cAAc;AA0BtB,SAASC,MAAMA,CACbC,KAA0C,EAC1CC,GAAuB,EACvB;EACA,MAAM;IAACC,GAAG;IAAEC;EAAM,CAAC,GAAGV,UAAU,CAACI,UAAU,CAAC;EAC5C,MAAMO,OAAO,GAAGZ,MAAM,CAAC;IAACQ;EAAK,CAAC,CAAC;EAC/BI,OAAO,CAACC,OAAO,CAACL,KAAK,GAAGA,KAAK;EAE7B,MAAMM,MAAe,GAAGf,OAAO,CAAC,MAAM;IACpC,IAAIgB,WAAW,GAAG,KAAK;IACvBpB,KAAK,CAACqB,QAAQ,CAACC,OAAO,CAACT,KAAK,CAACU,QAAQ,EAAEC,EAAE,IAAI;MAC3C,IAAIA,EAAE,EAAE;QACNJ,WAAW,GAAG,IAAI;MACpB;IACF,CAAC,CAAC;IACF,MAAMK,O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AAC;EAE1C,IAAIA,MAAM,CAAC8B,SAAS,CAAC,CAAC,CAACkB,GAAG,KAAKnC,SAAS,IAAIb,MAAM,CAAC8B,SAAS,CAAC,CAAC,CAACmB,GAAG,KAAKnC,QAAQ,EAAE;IAC/Ed,MAAM,CAACY,SAAS,CAAC,CAACC,SAAS,EAAEC,QAAQ,CAAC,CAAC;EACzC;EACA,IAAI2B,MAAM,IAAI,CAACjD,cAAc,CAACQ,MAAM,CAACkD,SAAS,CAAC,CAAC,EAAET,MAAM,CAAC,EAAE;IACzDzC,MAAM,CAACmD,SAAS,CAACV,MAAM,CAAC;EAC1B;EACA,IAAIzC,MAAM,CAACoD,WAAW,CAAC,CAAC,KAAKT,SAAS,EAAE;IACtC3C,MAAM,CAACqD,YAAY,CAACV,SAAS,CAAC;EAChC;EACA,IAAI3C,MAAM,CAACsD,WAAW,CAAC,CAAC,KAAKT,QAAQ,EAAE;IACrC7C,MAAM,CAACuD,WAAW,CAACV,QAAQ,CAAC;EAC9B;EACA,IAAI7C,MAAM,CAACwD,oBAAoB,CAAC,CAAC,KAAKV,iBAAiB,EAAE;IACvD9C,MAAM,CAACyD,oBAAoB,CAACX,iBAAiB,CAAC;EAChD;EACA,IAAI9C,MAAM,CAAC0D,iBAAiB,CAAC,CAAC,KAAKX,cAAc,EAAE;IACjD/C,MAAM,CAAC2D,iBAAiB,CAACZ,cAAc,CAAC;EAC1C;EACA,IAAI/C,MAAM,CAAC4D,QAAQ,CAAC,CAAC,KAAKhB,KAAK,EAAE;IAC/B5C,MAAM,CAAC6D,QAAQ,CAACjB,KAAK,CAAC;EACxB;EAEA,OAAO9D,YAAY,CAACY,KAAK,CAACU,QAAQ,EAAEJ,MAAM,CAACe,UAAU,CAAC,CAAC,CAAC;AAC1D;AAEA,eAAe1B,IAAI,CAACD,UAAU,CAACK,MAAM,CAAC,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ControlPosition, NavigationControlInstance } from '../types';
3
- export declare type NavigationControlProps<OptionsT> = OptionsT & {
3
+ export type NavigationControlProps<OptionsT> = OptionsT & {
4
4
  /** Placement of the control relative to the map. */
5
5
  position?: ControlPosition;
6
6
  /** CSS style override, applied to the control's container */
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { PopupEvent, PopupInstance } from '../types';
3
- export declare type PopupProps<OptionsT, PopupT extends PopupInstance> = OptionsT & {
3
+ export type PopupProps<OptionsT, PopupT extends PopupInstance> = OptionsT & {
4
4
  /** Longitude of the anchor location */
5
5
  longitude: number;
6
6
  /** Latitude of the anchor location */
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import { createPortal } from 'react-dom';
2
5
  import { useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo } from 'react';
3
6
  import { applyReactStyle } from "../utils/apply-react-style.js";
@@ -19,21 +22,19 @@ function Popup(props, ref) {
19
22
  });
20
23
  thisRef.current.props = props;
21
24
  const popup = useMemo(() => {
22
- const options = {
23
- ...props
24
- };
25
+ const options = _objectSpread({}, props);
25
26
  const pp = new mapLib.Popup(options);
26
27
  pp.setLngLat([props.longitude, props.latitude]);
27
28
  pp.once('open', e => {
28
29
  var _thisRef$current$prop, _thisRef$current$prop2;
29
- (_thisRef$current$prop = (_thisRef$current$prop2 = thisRef.current.props).onOpen) === null || _thisRef$current$prop === void 0 ? void 0 : _thisRef$current$prop.call(_thisRef$current$prop2, e);
30
+ (_thisRef$current$prop = (_thisRef$current$prop2 = thisRef.current.props).onOpen) === null || _thisRef$current$prop === void 0 || _thisRef$current$prop.call(_thisRef$current$prop2, e);
30
31
  });
31
32
  return pp;
32
33
  }, []);
33
34
  useEffect(() => {
34
35
  const onClose = e => {
35
36
  var _thisRef$current$prop3, _thisRef$current$prop4;
36
- (_thisRef$current$prop3 = (_thisRef$current$prop4 = thisRef.current.props).onClose) === null || _thisRef$current$prop3 === void 0 ? void 0 : _thisRef$current$prop3.call(_thisRef$current$prop4, e);
37
+ (_thisRef$current$prop3 = (_thisRef$current$prop4 = thisRef.current.props).onClose) === null || _thisRef$current$prop3 === void 0 || _thisRef$current$prop3.call(_thisRef$current$prop4, e);
37
38
  };
38
39
  popup.on('close', onClose);
39
40
  popup.setDOMContent(container).addTo(map.getMap());
@@ -1 +1 @@
1
- {"version":3,"file":"popup.js","names":["createPortal","useImperativeHandle","useEffect","useMemo","useRef","useContext","forwardRef","memo","applyReactStyle","MapContext","deepEqual","getClassList","className","Set","trim","split","Popup","props","ref","map","mapLib","container","document","createElement","thisRef","current","popup","options","pp","setLngLat","longitude","latitude","once","e","_thisRef$current$prop","_thisRef$current$prop2","onOpen","call","onClose","_thisRef$current$prop3","_thisRef$current$prop4","on","setDOMContent","addTo","getMap","off","isOpen","remove","getElement","style","getLngLat","lng","lat","offset","setOffset","anchor","maxWidth","setMaxWidth","prevClassList","nextClassList","c","has","removeClassName","addClassName","children"],"sources":["../../src/components/popup.ts"],"sourcesContent":["/* global document */\nimport * as React from 'react';\nimport {createPortal} from 'react-dom';\nimport {useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo} from 'react';\nimport {applyReactStyle} from '../utils/apply-react-style';\n\nimport type {PopupEvent, PopupInstance} from '../types';\n\nimport {MapContext} from './map';\nimport {deepEqual} from '../utils/deep-equal';\n\nexport type PopupProps<OptionsT, PopupT extends PopupInstance> = OptionsT & {\n /** Longitude of the anchor location */\n longitude: number;\n /** Latitude of the anchor location */\n latitude: number;\n\n // These types will be further constraint by OptionsT\n anchor?: string;\n offset?: any;\n className?: string;\n maxWidth?: string;\n\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n\n onOpen?: (e: PopupEvent<PopupT>) => void;\n onClose?: (e: PopupEvent<PopupT>) => void;\n children?: React.ReactNode;\n};\n\n// Adapted from https://github.com/mapbox/mapbox-gl-js/blob/v1.13.0/src/ui/popup.js\nfunction getClassList(className: string) {\n return new Set(className ? className.trim().split(/\\s+/) : []);\n}\n\n/* eslint-disable complexity,max-statements */\nfunction Popup<PopupOptions, PopupT extends PopupInstance>(\n props: PopupProps<PopupOptions, PopupT>,\n ref: React.Ref<PopupT>\n) {\n const {map, mapLib} = useContext(MapContext);\n const container = useMemo(() => {\n return document.createElement('div');\n }, []);\n const thisRef = useRef({props});\n thisRef.current.props = props;\n\n const popup: PopupT = useMemo(() => {\n const options = {...props};\n const pp = new mapLib.Popup(options) as PopupT;\n pp.setLngLat([props.longitude, props.latitude]);\n pp.once('open', e => {\n thisRef.current.props.onOpen?.(e as PopupEvent<PopupT>);\n });\n return pp;\n }, []);\n\n useEffect(() => {\n const onClose = e => {\n thisRef.current.props.onClose?.(e as PopupEvent<PopupT>);\n };\n popup.on('close', onClose);\n popup.setDOMContent(container).addTo(map.getMap());\n\n return () => {\n // https://github.com/visgl/react-map-gl/issues/1825\n // onClose should not be fired if the popup is removed by unmounting\n // When using React strict mode, the component is mounted twice.\n // Firing the onClose callback here would be a false signal to remove the component.\n popup.off('close', onClose);\n if (popup.isOpen()) {\n popup.remove();\n }\n };\n }, []);\n\n useEffect(() => {\n applyReactStyle(popup.getElement(), props.style);\n }, [props.style]);\n\n useImperativeHandle(ref, () => popup, []);\n\n if (popup.isOpen()) {\n if (popup.getLngLat().lng !== props.longitude || popup.getLngLat().lat !== props.latitude) {\n popup.setLngLat([props.longitude, props.latitude]);\n }\n if (props.offset && !deepEqual(popup.options.offset, props.offset)) {\n popup.setOffset(props.offset);\n }\n if (popup.options.anchor !== props.anchor || popup.options.maxWidth !== props.maxWidth) {\n popup.options.anchor = props.anchor;\n popup.setMaxWidth(props.maxWidth);\n }\n if (popup.options.className !== props.className) {\n const prevClassList = getClassList(popup.options.className);\n const nextClassList = getClassList(props.className);\n\n for (const c of prevClassList) {\n if (!nextClassList.has(c)) {\n popup.removeClassName(c);\n }\n }\n for (const c of nextClassList) {\n if (!prevClassList.has(c)) {\n popup.addClassName(c);\n }\n }\n popup.options.className = props.className;\n }\n }\n\n return createPortal(props.children, container);\n}\n\nexport default memo(forwardRef(Popup));\n"],"mappings":"AAEA,SAAQA,YAAY,QAAO,WAAW;AACtC,SAAQC,mBAAmB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAEC,IAAI,QAAO,OAAO;AAAC,SAC5FC,eAAe;AAAA,SAIfC,UAAU;AAAA,SACVC,SAAS;AAuBjB,SAASC,YAAYA,CAACC,SAAiB,EAAE;EACvC,OAAO,IAAIC,GAAG,CAACD,SAAS,GAAGA,SAAS,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChE;AAGA,SAASC,KAAKA,CACZC,KAAuC,EACvCC,GAAsB,EACtB;EACA,MAAM;IAACC,GAAG;IAAEC;EAAM,CAAC,GAAGf,UAAU,CAACI,UAAU,CAAC;EAC5C,MAAMY,SAAS,GAAGlB,OAAO,CAAC,MAAM;IAC9B,OAAOmB,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EACtC,CAAC,EAAE,EAAE,CAAC;EACN,MAAMC,OAAO,GAAGpB,MAAM,CAAC;IAACa;EAAK,CAAC,CAAC;EAC/BO,OAAO,CAACC,OAAO,CAACR,KAAK,GAAGA,KAAK;EAE7B,MAAMS,KAAa,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M,KAAK,CAACL,SAAS,CAAC;MAEnD,KAAK,MAAMgD,CAAC,IAAIF,aAAa,EAAE;QAC7B,IAAI,CAACC,aAAa,CAACE,GAAG,CAACD,CAAC,CAAC,EAAE;UACzBlC,KAAK,CAACoC,eAAe,CAACF,CAAC,CAAC;QAC1B;MACF;MACA,KAAK,MAAMA,CAAC,IAAID,aAAa,EAAE;QAC7B,IAAI,CAACD,aAAa,CAACG,GAAG,CAACD,CAAC,CAAC,EAAE;UACzBlC,KAAK,CAACqC,YAAY,CAACH,CAAC,CAAC;QACvB;MACF;MACAlC,KAAK,CAACC,OAAO,CAACf,SAAS,GAAGK,KAAK,CAACL,SAAS;IAC3C;EACF;EAEA,OAAOZ,YAAY,CAACiB,KAAK,CAAC+C,QAAQ,EAAE3C,SAAS,CAAC;AAChD;AAEA,eAAed,IAAI,CAACD,UAAU,CAACU,KAAK,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"popup.js","names":["createPortal","useImperativeHandle","useEffect","useMemo","useRef","useContext","forwardRef","memo","applyReactStyle","MapContext","deepEqual","getClassList","className","Set","trim","split","Popup","props","ref","map","mapLib","container","document","createElement","thisRef","current","popup","options","_objectSpread","pp","setLngLat","longitude","latitude","once","e","_thisRef$current$prop","_thisRef$current$prop2","onOpen","call","onClose","_thisRef$current$prop3","_thisRef$current$prop4","on","setDOMContent","addTo","getMap","off","isOpen","remove","getElement","style","getLngLat","lng","lat","offset","setOffset","anchor","maxWidth","setMaxWidth","prevClassList","nextClassList","c","has","removeClassName","addClassName","children"],"sources":["../../src/components/popup.ts"],"sourcesContent":["/* global document */\nimport * as React from 'react';\nimport {createPortal} from 'react-dom';\nimport {useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo} from 'react';\nimport {applyReactStyle} from '../utils/apply-react-style';\n\nimport type {PopupEvent, PopupInstance} from '../types';\n\nimport {MapContext} from './map';\nimport {deepEqual} from '../utils/deep-equal';\n\nexport type PopupProps<OptionsT, PopupT extends PopupInstance> = OptionsT & {\n /** Longitude of the anchor location */\n longitude: number;\n /** Latitude of the anchor location */\n latitude: number;\n\n // These types will be further constraint by OptionsT\n anchor?: string;\n offset?: any;\n className?: string;\n maxWidth?: string;\n\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n\n onOpen?: (e: PopupEvent<PopupT>) => void;\n onClose?: (e: PopupEvent<PopupT>) => void;\n children?: React.ReactNode;\n};\n\n// Adapted from https://github.com/mapbox/mapbox-gl-js/blob/v1.13.0/src/ui/popup.js\nfunction getClassList(className: string) {\n return new Set(className ? className.trim().split(/\\s+/) : []);\n}\n\n/* eslint-disable complexity,max-statements */\nfunction Popup<PopupOptions, PopupT extends PopupInstance>(\n props: PopupProps<PopupOptions, PopupT>,\n ref: React.Ref<PopupT>\n) {\n const {map, mapLib} = useContext(MapContext);\n const container = useMemo(() => {\n return document.createElement('div');\n }, []);\n const thisRef = useRef({props});\n thisRef.current.props = props;\n\n const popup: PopupT = useMemo(() => {\n const options = {...props};\n const pp = new mapLib.Popup(options) as PopupT;\n pp.setLngLat([props.longitude, props.latitude]);\n pp.once('open', e => {\n thisRef.current.props.onOpen?.(e as PopupEvent<PopupT>);\n });\n return pp;\n }, []);\n\n useEffect(() => {\n const onClose = e => {\n thisRef.current.props.onClose?.(e as PopupEvent<PopupT>);\n };\n popup.on('close', onClose);\n popup.setDOMContent(container).addTo(map.getMap());\n\n return () => {\n // https://github.com/visgl/react-map-gl/issues/1825\n // onClose should not be fired if the popup is removed by unmounting\n // When using React strict mode, the component is mounted twice.\n // Firing the onClose callback here would be a false signal to remove the component.\n popup.off('close', onClose);\n if (popup.isOpen()) {\n popup.remove();\n }\n };\n }, []);\n\n useEffect(() => {\n applyReactStyle(popup.getElement(), props.style);\n }, [props.style]);\n\n useImperativeHandle(ref, () => popup, []);\n\n if (popup.isOpen()) {\n if (popup.getLngLat().lng !== props.longitude || popup.getLngLat().lat !== props.latitude) {\n popup.setLngLat([props.longitude, props.latitude]);\n }\n if (props.offset && !deepEqual(popup.options.offset, props.offset)) {\n popup.setOffset(props.offset);\n }\n if (popup.options.anchor !== props.anchor || popup.options.maxWidth !== props.maxWidth) {\n popup.options.anchor = props.anchor;\n popup.setMaxWidth(props.maxWidth);\n }\n if (popup.options.className !== props.className) {\n const prevClassList = getClassList(popup.options.className);\n const nextClassList = getClassList(props.className);\n\n for (const c of prevClassList) {\n if (!nextClassList.has(c)) {\n popup.removeClassName(c);\n }\n }\n for (const c of nextClassList) {\n if (!prevClassList.has(c)) {\n popup.addClassName(c);\n }\n }\n popup.options.className = props.className;\n }\n }\n\n return createPortal(props.children, container);\n}\n\nexport default memo(forwardRef(Popup));\n"],"mappings":";;;AAEA,SAAQA,YAAY,QAAO,WAAW;AACtC,SAAQC,mBAAmB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAEC,IAAI,QAAO,OAAO;AAAC,SAC5FC,eAAe;AAAA,SAIfC,UAAU;AAAA,SACVC,SAAS;AAuBjB,SAASC,YAAYA,CAACC,SAAiB,EAAE;EACvC,OAAO,IAAIC,GAAG,CAACD,SAAS,GAAGA,SAAS,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChE;AAGA,SAASC,KAAKA,CACZC,KAAuC,EACvCC,GAAsB,EACtB;EACA,MAAM;IAACC,GAAG;IAAEC;EAAM,CAAC,GAAGf,UAAU,CAACI,UAAU,CAAC;EAC5C,MAAMY,SAAS,GAAGlB,OAAO,CAAC,MAAM;IAC9B,OAAOmB,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EACtC,CAAC,EAAE,EAAE,CAAC;EACN,MAAMC,OAAO,GAAGpB,MAAM,CAAC;IAACa;EAAK,CAAC,CAAC;EAC/BO,OAAO,CAACC,OAAO,CAACR,KAAK,GAAGA,KAAK;EAE7B,MAAMS,KAAa,GAAGvB,OAAO,CAAC,MAAM;IAClC,MAAMwB,OAAO,GAA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IAAIF,aAAa,EAAE;QAC7B,IAAI,CAACC,aAAa,CAACE,GAAG,CAACD,CAAC,CAAC,EAAE;UACzBnC,KAAK,CAACqC,eAAe,CAACF,CAAC,CAAC;QAC1B;MACF;MACA,KAAK,MAAMA,CAAC,IAAID,aAAa,EAAE;QAC7B,IAAI,CAACD,aAAa,CAACG,GAAG,CAACD,CAAC,CAAC,EAAE;UACzBnC,KAAK,CAACsC,YAAY,CAACH,CAAC,CAAC;QACvB;MACF;MACAnC,KAAK,CAACC,OAAO,CAACf,SAAS,GAAGK,KAAK,CAACL,SAAS;IAC3C;EACF;EAEA,OAAOZ,YAAY,CAACiB,KAAK,CAACgD,QAAQ,EAAE5C,SAAS,CAAC;AAChD;AAEA,eAAed,IAAI,CAACD,UAAU,CAACU,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ControlPosition, ScaleControlInstance } from '../types';
3
- export declare type ScaleControlProps<OptionsT> = OptionsT & {
3
+ export type ScaleControlProps<OptionsT> = OptionsT & {
4
4
  unit?: string;
5
5
  maxWidth?: number;
6
6
  /** Placement of the control relative to the map. */
@@ -1,5 +1,5 @@
1
1
  import type { ISource, CustomSource } from '../types';
2
- export declare type SourceProps<SourceT> = (SourceT | CustomSource) & {
2
+ export type SourceProps<SourceT> = (SourceT | CustomSource) & {
3
3
  id?: string;
4
4
  children?: any;
5
5
  };
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import * as React from 'react';
2
5
  import { useContext, useEffect, useMemo, useState, useRef } from 'react';
3
6
  import { cloneElement } from 'react';
@@ -7,9 +10,7 @@ import { deepEqual } from "../utils/deep-equal.js";
7
10
  let sourceCounter = 0;
8
11
  function createSource(map, id, props) {
9
12
  if (map.style && map.style._loaded) {
10
- const options = {
11
- ...props
12
- };
13
+ const options = _objectSpread({}, props);
13
14
  delete options.id;
14
15
  delete options.children;
15
16
  map.addSource(id, options);
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","names":["React","useContext","useEffect","useMemo","useState","useRef","cloneElement","MapContext","assert","deepEqual","sourceCounter","createSource","map","id","props","style","_loaded","options","children","addSource","getSource","updateSource","source","prevProps","type","changedKey","changedKeyCount","key","setData","data","updateImage","url","coordinates","setCoordinates","setUrl","setTiles","tiles","console","warn","Source","getMap","propsRef","setStyleLoaded","forceUpdate","setTimeout","version","on","off","_map$getStyle","allLayers","getStyle","layers","layer","removeLayer","removeSource","undefined","current","Children","child"],"sources":["../../src/components/source.ts"],"sourcesContent":["import * as React from 'react';\nimport {useContext, useEffect, useMemo, useState, useRef} from 'react';\nimport {cloneElement} from 'react';\nimport {MapContext} from './map';\nimport assert from '../utils/assert';\nimport {deepEqual} from '../utils/deep-equal';\n\nimport type {\n MapInstance,\n ISource,\n CustomSource,\n GeoJSONSourceImplementation,\n ImageSourceImplemtation,\n AnySourceImplementation\n} from '../types';\nimport type {GeoJSONSourceRaw, ImageSourceRaw, VectorSourceRaw} from '../types/style-spec-bkoi-gl';\n\nexport type SourceProps<SourceT> = (SourceT | CustomSource) & {\n id?: string;\n children?: any;\n};\n\nlet sourceCounter = 0;\n\nfunction createSource<SourceT extends ISource>(\n map: MapInstance,\n id: string,\n props: SourceProps<SourceT>\n) {\n // @ts-ignore\n if (map.style && map.style._loaded) {\n const options = {...props};\n delete options.id;\n delete options.children;\n // @ts-ignore\n map.addSource(id, options);\n return map.getSource(id);\n }\n return null;\n}\n\n/* eslint-disable complexity */\nfunction updateSource<SourceT extends ISource>(\n source: AnySourceImplementation,\n props: SourceProps<SourceT>,\n prevProps: SourceProps<SourceT>\n) {\n assert(props.id === prevProps.id, 'source id changed');\n assert(props.type === prevProps.type, 'source type changed');\n\n let changedKey = '';\n let changedKeyCount = 0;\n\n for (const key in props) {\n if (key !== 'children' && key !== 'id' && !deepEqual(prevProps[key], props[key])) {\n changedKey = key;\n changedKeyCount++;\n }\n }\n\n if (!changedKeyCount) {\n return;\n }\n\n const type = props.type;\n\n if (type === 'geojson') {\n (source as GeoJSONSourceImplementation).setData(\n (props as unknown as GeoJSONSourceRaw).data as any\n );\n } else if (type === 'image') {\n (source as ImageSourceImplemtation).updateImage({\n url: (props as unknown as ImageSourceRaw).url,\n coordinates: (props as unknown as ImageSourceRaw).coordinates\n });\n } else if ('setCoordinates' in source && changedKeyCount === 1 && changedKey === 'coordinates') {\n source.setCoordinates((props as ImageSourceRaw).coordinates);\n } else if ('setUrl' in source) {\n // Added in 1.12.0:\n // vectorTileSource.setTiles\n // vectorTileSource.setUrl\n switch (changedKey) {\n case 'url':\n source.setUrl((props as VectorSourceRaw).url);\n break;\n case 'tiles':\n source.setTiles((props as VectorSourceRaw).tiles);\n break;\n default:\n }\n } else {\n // eslint-disable-next-line\n console.warn(`Unable to update <Source> prop: ${changedKey}`);\n }\n}\n/* eslint-enable complexity */\n\nfunction Source<SourceT extends ISource>(props: SourceProps<SourceT>) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n\n const id = useMemo(() => props.id || `jsx-source-${sourceCounter++}`, []);\n\n useEffect(() => {\n if (map) {\n /* global setTimeout */\n const forceUpdate = () => setTimeout(() => setStyleLoaded(version => version + 1), 0);\n map.on('styledata', forceUpdate);\n forceUpdate();\n\n return () => {\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getSource(id)) {\n // Parent effects are destroyed before child ones, see\n // https://github.com/facebook/react/issues/16728\n // Source can only be removed after all child layers are removed\n const allLayers = map.getStyle()?.layers;\n if (allLayers) {\n for (const layer of allLayers) {\n // @ts-ignore (2339) source does not exist on all layer types\n if (layer.source === id) {\n map.removeLayer(layer.id);\n }\n }\n }\n map.removeSource(id);\n }\n };\n }\n return undefined;\n }, [map]);\n\n // @ts-ignore\n let source = map && map.style && map.getSource(id);\n if (source) {\n updateSource(source, props, propsRef.current);\n } else {\n source = createSource(map, id, props);\n }\n propsRef.current = props;\n\n return (\n (source &&\n React.Children.map(\n props.children,\n child =>\n child &&\n cloneElement(child, {\n source: id\n })\n )) ||\n null\n );\n}\n\nexport default Source;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAO,OAAO;AACtE,SAAQC,YAAY,QAAO,OAAO;AAAC,SAC3BC,UAAU;AAAA,OACXC,MAAM;AAAA,SACLC,SAAS;AAiBjB,IAAIC,aAAa,GAAG,CAAC;AAErB,SAASC,YAAYA,CACnBC,GAAgB,EAChBC,EAAU,EACVC,KAA2B,EAC3B;EAEA,IAAIF,GAAG,CAACG,KAAK,IAAIH,GAAG,CAACG,KAAK,CAACC,OAAO,EAAE;IAClC,MAAMC,OAAO,GAAG;MAAC,GAAGH;IAAK,CAAC;IAC1B,OAAOG,OAAO,CAACJ,EAAE;IACjB,OAAOI,OAAO,CAACC,QAAQ;IAEvBN,GAAG,CAACO,SAAS,CAACN,EAAE,EAAEI,OAAO,CAAC;IAC1B,OAAOL,GAAG,CAACQ,SAAS,CAACP,EAAE,CAAC;EAC1B;EACA,OAAO,IAAI;AACb;AAGA,SAASQ,YAAYA,CACnBC,MAA+B,EAC/BR,KAA2B,EAC3BS,SAA+B,E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yC,WAAW,CAACD,KAAK,CAACvC,EAAE,CAAC;cAC3B;YACF;UACF;UACAD,GAAG,CAAC0C,YAAY,CAACzC,EAAE,CAAC;QACtB;MACF,CAAC;IACH;IACA,OAAO0C,SAAS;EAClB,CAAC,EAAE,CAAC3C,GAAG,CAAC,CAAC;EAGT,IAAIU,MAAM,GAAGV,GAAG,IAAIA,GAAG,CAACG,KAAK,IAAIH,GAAG,CAACQ,SAAS,CAACP,EAAE,CAAC;EAClD,IAAIS,MAAM,EAAE;IACVD,YAAY,CAACC,MAAM,EAAER,KAAK,EAAE2B,QAAQ,CAACe,OAAO,CAAC;EAC/C,CAAC,MAAM;IACLlC,MAAM,GAAGX,YAAY,CAACC,GAAG,EAAEC,EAAE,EAAEC,KAAK,CAAC;EACvC;EACA2B,QAAQ,CAACe,OAAO,GAAG1C,KAAK;EAExB,OACGQ,MAAM,IACLtB,KAAK,CAACyD,QAAQ,CAAC7C,GAAG,CAChBE,KAAK,CAACI,QAAQ,EACdwC,KAAK,IACHA,KAAK,IACLpD,YAAY,CAACoD,KAAK,EAAE;IAClBpC,MAAM,EAAET;EACV,CAAC,CACL,CAAC,IACH,IAAI;AAER;AAEA,eAAe0B,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"source.js","names":["React","useContext","useEffect","useMemo","useState","useRef","cloneElement","MapContext","assert","deepEqual","sourceCounter","createSource","map","id","props","style","_loaded","options","_objectSpread","children","addSource","getSource","updateSource","source","prevProps","type","changedKey","changedKeyCount","key","setData","data","updateImage","url","coordinates","setCoordinates","setUrl","setTiles","tiles","console","warn","Source","getMap","propsRef","setStyleLoaded","forceUpdate","setTimeout","version","on","off","_map$getStyle","allLayers","getStyle","layers","layer","removeLayer","removeSource","undefined","current","Children","child"],"sources":["../../src/components/source.ts"],"sourcesContent":["import * as React from 'react';\nimport {useContext, useEffect, useMemo, useState, useRef} from 'react';\nimport {cloneElement} from 'react';\nimport {MapContext} from './map';\nimport assert from '../utils/assert';\nimport {deepEqual} from '../utils/deep-equal';\n\nimport type {\n MapInstance,\n ISource,\n CustomSource,\n GeoJSONSourceImplementation,\n ImageSourceImplemtation,\n AnySourceImplementation\n} from '../types';\nimport type {GeoJSONSourceRaw, ImageSourceRaw, VectorSourceRaw} from '../types/style-spec-bkoi-gl';\n\nexport type SourceProps<SourceT> = (SourceT | CustomSource) & {\n id?: string;\n children?: any;\n};\n\nlet sourceCounter = 0;\n\nfunction createSource<SourceT extends ISource>(\n map: MapInstance,\n id: string,\n props: SourceProps<SourceT>\n) {\n // @ts-ignore\n if (map.style && map.style._loaded) {\n const options = {...props};\n delete options.id;\n delete options.children;\n // @ts-ignore\n map.addSource(id, options);\n return map.getSource(id);\n }\n return null;\n}\n\n/* eslint-disable complexity */\nfunction updateSource<SourceT extends ISource>(\n source: AnySourceImplementation,\n props: SourceProps<SourceT>,\n prevProps: SourceProps<SourceT>\n) {\n assert(props.id === prevProps.id, 'source id changed');\n assert(props.type === prevProps.type, 'source type changed');\n\n let changedKey = '';\n let changedKeyCount = 0;\n\n for (const key in props) {\n if (key !== 'children' && key !== 'id' && !deepEqual(prevProps[key], props[key])) {\n changedKey = key;\n changedKeyCount++;\n }\n }\n\n if (!changedKeyCount) {\n return;\n }\n\n const type = props.type;\n\n if (type === 'geojson') {\n (source as GeoJSONSourceImplementation).setData(\n (props as unknown as GeoJSONSourceRaw).data as any\n );\n } else if (type === 'image') {\n (source as ImageSourceImplemtation).updateImage({\n url: (props as unknown as ImageSourceRaw).url,\n coordinates: (props as unknown as ImageSourceRaw).coordinates\n });\n } else if ('setCoordinates' in source && changedKeyCount === 1 && changedKey === 'coordinates') {\n source.setCoordinates((props as ImageSourceRaw).coordinates);\n } else if ('setUrl' in source) {\n // Added in 1.12.0:\n // vectorTileSource.setTiles\n // vectorTileSource.setUrl\n switch (changedKey) {\n case 'url':\n source.setUrl((props as VectorSourceRaw).url);\n break;\n case 'tiles':\n source.setTiles((props as VectorSourceRaw).tiles);\n break;\n default:\n }\n } else {\n // eslint-disable-next-line\n console.warn(`Unable to update <Source> prop: ${changedKey}`);\n }\n}\n/* eslint-enable complexity */\n\nfunction Source<SourceT extends ISource>(props: SourceProps<SourceT>) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n\n const id = useMemo(() => props.id || `jsx-source-${sourceCounter++}`, []);\n\n useEffect(() => {\n if (map) {\n /* global setTimeout */\n const forceUpdate = () => setTimeout(() => setStyleLoaded(version => version + 1), 0);\n map.on('styledata', forceUpdate);\n forceUpdate();\n\n return () => {\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getSource(id)) {\n // Parent effects are destroyed before child ones, see\n // https://github.com/facebook/react/issues/16728\n // Source can only be removed after all child layers are removed\n const allLayers = map.getStyle()?.layers;\n if (allLayers) {\n for (const layer of allLayers) {\n // @ts-ignore (2339) source does not exist on all layer types\n if (layer.source === id) {\n map.removeLayer(layer.id);\n }\n }\n }\n map.removeSource(id);\n }\n };\n }\n return undefined;\n }, [map]);\n\n // @ts-ignore\n let source = map && map.style && map.getSource(id);\n if (source) {\n updateSource(source, props, propsRef.current);\n } else {\n source = createSource(map, id, props);\n }\n propsRef.current = props;\n\n return (\n (source &&\n React.Children.map(\n props.children,\n child =>\n child &&\n cloneElement(child, {\n source: id\n })\n )) ||\n null\n );\n}\n\nexport default Source;\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAO,OAAO;AACtE,SAAQC,YAAY,QAAO,OAAO;AAAC,SAC3BC,UAAU;AAAA,OACXC,MAAM;AAAA,SACLC,SAAS;AAiBjB,IAAIC,aAAa,GAAG,CAAC;AAErB,SAASC,YAAYA,CACnBC,GAAgB,EAChBC,EAAU,EACVC,KAA2B,EAC3B;EAEA,IAAIF,GAAG,CAACG,KAAK,IAAIH,GAAG,CAACG,KAAK,CAACC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