react-bkoi-gl 2.0.0 → 2.1.0

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 (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1429 -176
  3. package/dist/index.cjs +1299 -266
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +870 -0
  6. package/dist/index.d.ts +870 -2
  7. package/dist/index.js +2420 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/styles/react-bkoi-gl.css +95 -1
  10. package/package.json +83 -31
  11. package/dist/components/attribution-control.d.ts +0 -9
  12. package/dist/components/attribution-control.js +0 -20
  13. package/dist/components/attribution-control.js.map +0 -1
  14. package/dist/components/fullscreen-control.d.ts +0 -12
  15. package/dist/components/fullscreen-control.js +0 -21
  16. package/dist/components/fullscreen-control.js.map +0 -1
  17. package/dist/components/geolocate-control.d.ts +0 -21
  18. package/dist/components/geolocate-control.js +0 -46
  19. package/dist/components/geolocate-control.js.map +0 -1
  20. package/dist/components/layer.d.ts +0 -18
  21. package/dist/components/layer.js +0 -98
  22. package/dist/components/layer.js.map +0 -1
  23. package/dist/components/logo-control.d.ts +0 -9
  24. package/dist/components/logo-control.js +0 -28
  25. package/dist/components/logo-control.js.map +0 -1
  26. package/dist/components/map.d.ts +0 -27
  27. package/dist/components/map.js +0 -108
  28. package/dist/components/map.js.map +0 -1
  29. package/dist/components/marker.d.ts +0 -18
  30. package/dist/components/marker.js +0 -105
  31. package/dist/components/marker.js.map +0 -1
  32. package/dist/components/navigation-control.d.ts +0 -9
  33. package/dist/components/navigation-control.js +0 -19
  34. package/dist/components/navigation-control.js.map +0 -1
  35. package/dist/components/popup.d.ts +0 -15
  36. package/dist/components/popup.js +0 -68
  37. package/dist/components/popup.js.map +0 -1
  38. package/dist/components/scale-control.d.ts +0 -11
  39. package/dist/components/scale-control.js +0 -31
  40. package/dist/components/scale-control.js.map +0 -1
  41. package/dist/components/source.d.ts +0 -6
  42. package/dist/components/source.js +0 -95
  43. package/dist/components/source.js.map +0 -1
  44. package/dist/components/terrain-control.d.ts +0 -10
  45. package/dist/components/terrain-control.js +0 -19
  46. package/dist/components/terrain-control.js.map +0 -1
  47. package/dist/components/use-control.d.ts +0 -9
  48. package/dist/components/use-control.js +0 -30
  49. package/dist/components/use-control.js.map +0 -1
  50. package/dist/components/use-map.d.ts +0 -19
  51. package/dist/components/use-map.js +0 -54
  52. package/dist/components/use-map.js.map +0 -1
  53. package/dist/exports-maplibre-gl.d.ts +0 -33
  54. package/dist/exports-maplibre-gl.js +0 -21
  55. package/dist/exports-maplibre-gl.js.map +0 -1
  56. package/dist/maplibre/create-ref.d.ts +0 -9
  57. package/dist/maplibre/create-ref.js +0 -30
  58. package/dist/maplibre/create-ref.js.map +0 -1
  59. package/dist/maplibre/maplibre.d.ts +0 -81
  60. package/dist/maplibre/maplibre.js +0 -387
  61. package/dist/maplibre/maplibre.js.map +0 -1
  62. package/dist/styles.d.js +0 -2
  63. package/dist/styles.d.js.map +0 -1
  64. package/dist/tsconfig.build.tsbuildinfo +0 -1
  65. package/dist/types/common.d.ts +0 -20
  66. package/dist/types/common.js +0 -2
  67. package/dist/types/common.js.map +0 -1
  68. package/dist/types/events.d.ts +0 -80
  69. package/dist/types/events.js +0 -2
  70. package/dist/types/events.js.map +0 -1
  71. package/dist/types/internal.d.ts +0 -14
  72. package/dist/types/internal.js +0 -2
  73. package/dist/types/internal.js.map +0 -1
  74. package/dist/types/lib.d.ts +0 -40
  75. package/dist/types/lib.js +0 -2
  76. package/dist/types/lib.js.map +0 -1
  77. package/dist/types/style-spec.d.ts +0 -1
  78. package/dist/types/style-spec.js +0 -2
  79. package/dist/types/style-spec.js.map +0 -1
  80. package/dist/utils/apply-react-style.d.ts +0 -2
  81. package/dist/utils/apply-react-style.js +0 -16
  82. package/dist/utils/apply-react-style.js.map +0 -1
  83. package/dist/utils/assert.d.ts +0 -1
  84. package/dist/utils/assert.js +0 -6
  85. package/dist/utils/assert.js.map +0 -1
  86. package/dist/utils/compare-class-names.d.ts +0 -2
  87. package/dist/utils/compare-class-names.js +0 -23
  88. package/dist/utils/compare-class-names.js.map +0 -1
  89. package/dist/utils/deep-equal.d.ts +0 -15
  90. package/dist/utils/deep-equal.js +0 -46
  91. package/dist/utils/deep-equal.js.map +0 -1
  92. package/dist/utils/set-globals.d.ts +0 -20
  93. package/dist/utils/set-globals.js +0 -31
  94. package/dist/utils/set-globals.js.map +0 -1
  95. package/dist/utils/style-utils.d.ts +0 -3
  96. package/dist/utils/style-utils.js +0 -42
  97. package/dist/utils/style-utils.js.map +0 -1
  98. package/dist/utils/transform.d.ts +0 -18
  99. package/dist/utils/transform.js +0 -33
  100. package/dist/utils/transform.js.map +0 -1
  101. package/dist/utils/use-isomorphic-layout-effect.d.ts +0 -3
  102. package/dist/utils/use-isomorphic-layout-effect.js +0 -4
  103. package/dist/utils/use-isomorphic-layout-effect.js.map +0 -1
  104. package/src/components/attribution-control.ts +0 -56
  105. package/src/components/fullscreen-control.ts +0 -40
  106. package/src/components/geolocate-control.ts +0 -96
  107. package/src/components/layer.ts +0 -141
  108. package/src/components/logo-control.ts +0 -44
  109. package/src/components/map.tsx +0 -166
  110. package/src/components/marker.ts +0 -155
  111. package/src/components/navigation-control.ts +0 -28
  112. package/src/components/popup.ts +0 -113
  113. package/src/components/scale-control.ts +0 -44
  114. package/src/components/source.ts +0 -159
  115. package/src/components/terrain-control.ts +0 -29
  116. package/src/components/use-control.ts +0 -68
  117. package/src/components/use-map.tsx +0 -71
  118. package/src/exports-maplibre-gl.ts +0 -37
  119. package/src/index.ts +0 -3
  120. package/src/maplibre/create-ref.ts +0 -70
  121. package/src/maplibre/maplibre.ts +0 -624
  122. package/src/styles.d.ts +0 -4
  123. package/src/types/common.ts +0 -34
  124. package/src/types/events.ts +0 -133
  125. package/src/types/internal.ts +0 -26
  126. package/src/types/lib.ts +0 -84
  127. package/src/types/style-spec.ts +0 -34
  128. package/src/utils/apply-react-style.ts +0 -24
  129. package/src/utils/assert.ts +0 -5
  130. package/src/utils/compare-class-names.ts +0 -29
  131. package/src/utils/deep-equal.ts +0 -61
  132. package/src/utils/set-globals.ts +0 -51
  133. package/src/utils/style-utils.ts +0 -68
  134. package/src/utils/transform.ts +0 -58
  135. package/src/utils/use-isomorphic-layout-effect.ts +0 -8
@@ -1,30 +0,0 @@
1
- import { useContext, useMemo, useEffect } from "react";
2
- import { MapContext } from "./map.js";
3
- export function useControl(onCreate, arg1, arg2, arg3) {
4
- const context = useContext(MapContext);
5
- const ctrl = useMemo(() => onCreate(context), []);
6
- useEffect(() => {
7
- const opts = arg3 || arg2 || arg1;
8
- const onAdd = typeof arg1 === "function" && typeof arg2 === "function" ? arg1 : null;
9
- const onRemove = typeof arg2 === "function" ? arg2 : typeof arg1 === "function" ? arg1 : null;
10
- const {
11
- map
12
- } = context;
13
- if (!map.hasControl(ctrl)) {
14
- map.addControl(ctrl, opts?.position);
15
- if (onAdd) {
16
- onAdd(context);
17
- }
18
- }
19
- return () => {
20
- if (onRemove) {
21
- onRemove(context);
22
- }
23
- if (map.hasControl(ctrl)) {
24
- map.removeControl(ctrl);
25
- }
26
- };
27
- }, []);
28
- return ctrl;
29
- }
30
- //# sourceMappingURL=use-control.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-control.js","names":["useContext","useMemo","useEffect","MapContext","useControl","onCreate","arg1","arg2","arg3","context","ctrl","opts","onAdd","onRemove","map","hasControl","addControl","position","removeControl"],"sources":["../../src/components/use-control.ts"],"sourcesContent":["import { useContext, useMemo, useEffect } from \"react\";\nimport type { IControl, ControlPosition } from \"../types/lib\";\nimport { MapContext } from \"./map\";\nimport type { MapContextValue } from \"./map\";\n\ntype ControlOptions = {\n position?: ControlPosition;\n};\n\nexport function useControl<T extends IControl>(\n onCreate: (context: MapContextValue) => T,\n opts?: ControlOptions,\n): T;\n\nexport function useControl<T extends IControl>(\n onCreate: (context: MapContextValue) => T,\n onRemove: (context: MapContextValue) => void,\n opts?: ControlOptions,\n): T;\n\nexport function useControl<T extends IControl>(\n onCreate: (context: MapContextValue) => T,\n onAdd: (context: MapContextValue) => void,\n onRemove: (context: MapContextValue) => void,\n opts?: ControlOptions,\n): T;\n\nexport function useControl<T extends IControl>(\n onCreate: (context: MapContextValue) => T,\n arg1?: ((context: MapContextValue) => void) | ControlOptions,\n arg2?: ((context: MapContextValue) => void) | ControlOptions,\n arg3?: ControlOptions,\n): T {\n const context = useContext(MapContext);\n const ctrl = useMemo(() => onCreate(context), []);\n\n useEffect(() => {\n const opts = (arg3 || arg2 || arg1) as ControlOptions;\n const onAdd =\n typeof arg1 === \"function\" && typeof arg2 === \"function\" ? arg1 : null;\n const onRemove =\n typeof arg2 === \"function\"\n ? arg2\n : typeof arg1 === \"function\"\n ? arg1\n : null;\n\n const { map } = context;\n if (!map.hasControl(ctrl)) {\n map.addControl(ctrl, opts?.position);\n if (onAdd) {\n onAdd(context);\n }\n }\n\n return () => {\n if (onRemove) {\n onRemove(context);\n }\n // Map might have been removed (parent effects are destroyed before child ones)\n if (map.hasControl(ctrl)) {\n map.removeControl(ctrl);\n }\n };\n }, []);\n\n return ctrl;\n}\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,EAAEC,SAAS,QAAQ,OAAO;AAAC,SAE9CC,UAAU;AAyBnB,OAAO,SAASC,UAAUA,CACxBC,QAAyC,EACzCC,IAA4D,EAC5DC,IAA4D,EAC5DC,IAAqB,EAClB;EACH,MAAMC,OAAO,GAAGT,UAAU,CAACG,UAAU,CAAC;EACtC,MAAMO,IAAI,GAAGT,OAAO,CAAC,MAAMI,QAAQ,CAACI,OAAO,CAAC,EAAE,EAAE,CAAC;EAEjDP,SAAS,CAAC,MAAM;IACd,MAAMS,IAAI,GAAIH,IAAI,IAAID,IAAI,IAAID,IAAuB;IACrD,MAAMM,KAAK,GACT,OAAON,IAAI,KAAK,UAAU,IAAI,OAAOC,IAAI,KAAK,UAAU,GAAGD,IAAI,GAAG,IAAI;IACxE,MAAMO,QAAQ,GACZ,OAAON,IAAI,KAAK,UAAU,GACtBA,IAAI,GACJ,OAAOD,IAAI,KAAK,UAAU,GAC1BA,IAAI,GACJ,IAAI;IAEV,MAAM;MAAEQ;IAAI,CAAC,GAAGL,OAAO;IACvB,IAAI,CAACK,GAAG,CAACC,UAAU,CAACL,IAAI,CAAC,EAAE;MACzBI,GAAG,CAACE,UAAU,CAACN,IAAI,EAAEC,IAAI,EAAEM,QAAQ,CAAC;MACpC,IAAIL,KAAK,EAAE;QACTA,KAAK,CAACH,OAAO,CAAC;MAChB;IACF;IAEA,OAAO,MAAM;MACX,IAAII,QAAQ,EAAE;QACZA,QAAQ,CAACJ,OAAO,CAAC;MACnB;MAEA,IAAIK,GAAG,CAACC,UAAU,CAACL,IAAI,CAAC,EAAE;QACxBI,GAAG,CAACI,aAAa,CAACR,IAAI,CAAC;MACzB;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOA,IAAI;AACb","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
- import { MapRef } from "../maplibre/create-ref";
3
- type MountedMapsContextValue = {
4
- maps: {
5
- [id: string]: MapRef;
6
- };
7
- onMapMount: (map: MapRef, id: string) => void;
8
- onMapUnmount: (id: string) => void;
9
- };
10
- export declare const MountedMapsContext: React.Context<MountedMapsContextValue>;
11
- export declare const MapProvider: React.FC<{
12
- children?: React.ReactNode;
13
- }>;
14
- export type MapCollection = {
15
- [id: string]: MapRef | undefined;
16
- current?: MapRef;
17
- };
18
- export declare function useMap(): MapCollection;
19
- export {};
@@ -1,54 +0,0 @@
1
- import * as React from "react";
2
- import { useState, useCallback, useMemo, useContext } from "react";
3
- import { MapContext } from "./map.js";
4
- export const MountedMapsContext = React.createContext(null);
5
- export const MapProvider = props => {
6
- const [maps, setMaps] = useState({});
7
- const onMapMount = useCallback(function (map) {
8
- let id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "default";
9
- setMaps(currMaps => {
10
- if (id === "current") {
11
- throw new Error("'current' cannot be used as map id");
12
- }
13
- if (currMaps[id]) {
14
- throw new Error(`Multiple maps with the same id: ${id}`);
15
- }
16
- return {
17
- ...currMaps,
18
- [id]: map
19
- };
20
- });
21
- }, []);
22
- const onMapUnmount = useCallback(function () {
23
- let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
24
- setMaps(currMaps => {
25
- if (currMaps[id]) {
26
- const nextMaps = {
27
- ...currMaps
28
- };
29
- delete nextMaps[id];
30
- return nextMaps;
31
- }
32
- return currMaps;
33
- });
34
- }, []);
35
- return React.createElement(MountedMapsContext.Provider, {
36
- value: {
37
- maps,
38
- onMapMount,
39
- onMapUnmount
40
- }
41
- }, props.children);
42
- };
43
- export function useMap() {
44
- const maps = useContext(MountedMapsContext)?.maps;
45
- const currentMap = useContext(MapContext);
46
- const mapsWithCurrent = useMemo(() => {
47
- return {
48
- ...maps,
49
- current: currentMap?.map
50
- };
51
- }, [maps, currentMap]);
52
- return mapsWithCurrent;
53
- }
54
- //# sourceMappingURL=use-map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-map.js","names":["React","useState","useCallback","useMemo","useContext","MapContext","MountedMapsContext","createContext","MapProvider","props","maps","setMaps","onMapMount","map","id","arguments","length","undefined","currMaps","Error","onMapUnmount","nextMaps","createElement","Provider","value","children","useMap","currentMap","mapsWithCurrent","current"],"sources":["../../src/components/use-map.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useState, useCallback, useMemo, useContext } from \"react\";\n\nimport { MapRef } from \"../maplibre/create-ref\";\nimport { MapContext } from \"./map\";\n\ntype MountedMapsContextValue = {\n maps: { [id: string]: MapRef };\n onMapMount: (map: MapRef, id: string) => void;\n onMapUnmount: (id: string) => void;\n};\n\nexport const MountedMapsContext =\n React.createContext<MountedMapsContextValue>(null);\n\nexport const MapProvider: React.FC<{ children?: React.ReactNode }> = (\n props,\n) => {\n const [maps, setMaps] = useState<{ [id: string]: MapRef }>({});\n\n const onMapMount = useCallback((map: MapRef, id: string = \"default\") => {\n setMaps((currMaps) => {\n if (id === \"current\") {\n throw new Error(\"'current' cannot be used as map id\");\n }\n if (currMaps[id]) {\n throw new Error(`Multiple maps with the same id: ${id}`);\n }\n return { ...currMaps, [id]: map };\n });\n }, []);\n\n const onMapUnmount = useCallback((id: string = \"default\") => {\n setMaps((currMaps) => {\n if (currMaps[id]) {\n const nextMaps = { ...currMaps };\n delete nextMaps[id];\n return nextMaps;\n }\n return currMaps;\n });\n }, []);\n\n return (\n <MountedMapsContext.Provider\n value={{\n maps,\n onMapMount,\n onMapUnmount,\n }}\n >\n {props.children}\n </MountedMapsContext.Provider>\n );\n};\n\nexport type MapCollection = {\n [id: string]: MapRef | undefined;\n current?: MapRef;\n};\n\nexport function useMap(): MapCollection {\n const maps = useContext(MountedMapsContext)?.maps;\n const currentMap = useContext(MapContext);\n\n const mapsWithCurrent = useMemo(() => {\n return { ...maps, current: currentMap?.map };\n }, [maps, currentMap]);\n\n return mapsWithCurrent as MapCollection;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,EAAEC,UAAU,QAAQ,OAAO;AAAC,SAG1DC,UAAU;AAQnB,OAAO,MAAMC,kBAAkB,GAC7BN,KAAK,CAACO,aAAa,CAA0B,IAAI,CAAC;AAEpD,OAAO,MAAMC,WAAqD,GAChEC,KAAK,IACF;EACH,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,QAAQ,CAA2B,CAAC,CAAC,CAAC;EAE9D,MAAMW,UAAU,GAAGV,WAAW,CAAC,UAACW,GAAW,EAA6B;IAAA,IAA3BC,EAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;IACjEJ,OAAO,CAAEO,QAAQ,IAAK;MACpB,IAAIJ,EAAE,KAAK,SAAS,EAAE;QACpB,MAAM,IAAIK,KA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0 @@
1
- import { Map } from "./components/map";
2
- export { Map };
3
- export default Map;
4
- export { Marker } from "./components/marker";
5
- export { Popup } from "./components/popup";
6
- export { AttributionControl } from "./components/attribution-control";
7
- export { FullscreenControl } from "./components/fullscreen-control";
8
- export { GeolocateControl } from "./components/geolocate-control";
9
- export { NavigationControl } from "./components/navigation-control";
10
- export { ScaleControl } from "./components/scale-control";
11
- export { TerrainControl } from "./components/terrain-control";
12
- export { LogoControl } from "./components/logo-control";
13
- export { Source } from "./components/source";
14
- export { Layer } from "./components/layer";
15
- export { useControl } from "./components/use-control";
16
- export { MapProvider, useMap } from "./components/use-map";
17
- export type { MapProps } from "./components/map";
18
- export type { MapRef } from "./maplibre/create-ref";
19
- export type { MarkerProps } from "./components/marker";
20
- export type { PopupProps } from "./components/popup";
21
- export type { AttributionControlProps } from "./components/attribution-control";
22
- export type { FullscreenControlProps } from "./components/fullscreen-control";
23
- export type { GeolocateControlProps } from "./components/geolocate-control";
24
- export type { NavigationControlProps } from "./components/navigation-control";
25
- export type { ScaleControlProps } from "./components/scale-control";
26
- export type { TerrainControlProps } from "./components/terrain-control";
27
- export type { LogoControlProps } from "./components/logo-control";
28
- export type { SourceProps } from "./components/source";
29
- export type { LayerProps } from "./components/layer";
30
- export * from "./types/common";
31
- export * from "./types/events";
32
- export * from "./types/lib";
33
- export * from "./types/style-spec";
@@ -1,21 +0,0 @@
1
- import { Map } from "./components/map.js";
2
- export { Map };
3
- export default Map;
4
- export { Marker } from "./components/marker.js";
5
- export { Popup } from "./components/popup.js";
6
- export { AttributionControl } from "./components/attribution-control.js";
7
- export { FullscreenControl } from "./components/fullscreen-control.js";
8
- export { GeolocateControl } from "./components/geolocate-control.js";
9
- export { NavigationControl } from "./components/navigation-control.js";
10
- export { ScaleControl } from "./components/scale-control.js";
11
- export { TerrainControl } from "./components/terrain-control.js";
12
- export { LogoControl } from "./components/logo-control.js";
13
- export { Source } from "./components/source.js";
14
- export { Layer } from "./components/layer.js";
15
- export { useControl } from "./components/use-control.js";
16
- export { MapProvider, useMap } from "./components/use-map.js";
17
- export * from "./types/common.js";
18
- export * from "./types/events.js";
19
- export * from "./types/lib.js";
20
- export * from "./types/style-spec.js";
21
- //# sourceMappingURL=exports-maplibre-gl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports-maplibre-gl.js","names":["Map","Marker","Popup","AttributionControl","FullscreenControl","GeolocateControl","NavigationControl","ScaleControl","TerrainControl","LogoControl","Source","Layer","useControl","MapProvider","useMap"],"sources":["../src/exports-maplibre-gl.ts"],"sourcesContent":["import { Map } from \"./components/map\";\nexport { Map };\nexport default Map;\n\nexport { Marker } from \"./components/marker\";\nexport { Popup } from \"./components/popup\";\nexport { AttributionControl } from \"./components/attribution-control\";\nexport { FullscreenControl } from \"./components/fullscreen-control\";\nexport { GeolocateControl } from \"./components/geolocate-control\";\nexport { NavigationControl } from \"./components/navigation-control\";\nexport { ScaleControl } from \"./components/scale-control\";\nexport { TerrainControl } from \"./components/terrain-control\";\nexport { LogoControl } from \"./components/logo-control\";\nexport { Source } from \"./components/source\";\nexport { Layer } from \"./components/layer\";\nexport { useControl } from \"./components/use-control\";\nexport { MapProvider, useMap } from \"./components/use-map\";\n\nexport type { MapProps } from \"./components/map\";\nexport type { MapRef } from \"./maplibre/create-ref\";\nexport type { MarkerProps } from \"./components/marker\";\nexport type { PopupProps } from \"./components/popup\";\nexport type { AttributionControlProps } from \"./components/attribution-control\";\nexport type { FullscreenControlProps } from \"./components/fullscreen-control\";\nexport type { GeolocateControlProps } from \"./components/geolocate-control\";\nexport type { NavigationControlProps } from \"./components/navigation-control\";\nexport type { ScaleControlProps } from \"./components/scale-control\";\nexport type { TerrainControlProps } from \"./components/terrain-control\";\nexport type { LogoControlProps } from \"./components/logo-control\";\nexport type { SourceProps } from \"./components/source\";\nexport type { LayerProps } from \"./components/layer\";\n\n// Types\nexport * from \"./types/common\";\nexport * from \"./types/events\";\nexport * from \"./types/lib\";\nexport * from \"./types/style-spec\";\n"],"mappings":"SAASA,GAAG;AACZ,SAASA,GAAG;AACZ,eAAeA,GAAG;AAAC,SAEVC,MAAM;AAAA,SACNC,KAAK;AAAA,SACLC,kBAAkB;AAAA,SAClBC,iBAAiB;AAAA,SACjBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SACjBC,YAAY;AAAA,SACZC,cAAc;AAAA,SACdC,WAAW;AAAA,SACXC,MAAM;AAAA,SACNC,KAAK;AAAA,SACLC,UAAU;AAAA,SACVC,WAAW,EAAEC,MAAM;AAAA;AAAA;AAAA;AAAA","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- import type { Map as MapInstance } from "../types/lib";
2
- import type Maplibre from "./maplibre";
3
- /** These methods may break the react binding if called directly */
4
- declare const skipMethods: readonly ["setMaxBounds", "setMinZoom", "setMaxZoom", "setMinPitch", "setMaxPitch", "setRenderWorldCopies", "setProjection", "setStyle", "addSource", "removeSource", "addLayer", "removeLayer", "setLayerZoomRange", "setFilter", "setPaintProperty", "setLayoutProperty", "setLight", "setTerrain", "setFog", "remove"];
5
- export type MapRef = {
6
- getMap(): MapInstance;
7
- } & Omit<MapInstance, (typeof skipMethods)[number]>;
8
- export default function createRef(mapInstance: Maplibre): MapRef | null;
9
- export {};
@@ -1,30 +0,0 @@
1
- const skipMethods = ["setMaxBounds", "setMinZoom", "setMaxZoom", "setMinPitch", "setMaxPitch", "setRenderWorldCopies", "setProjection", "setStyle", "addSource", "removeSource", "addLayer", "removeLayer", "setLayerZoomRange", "setFilter", "setPaintProperty", "setLayoutProperty", "setLight", "setTerrain", "setFog", "remove"];
2
- export default function createRef(mapInstance) {
3
- if (!mapInstance) {
4
- return null;
5
- }
6
- const map = mapInstance.map;
7
- const result = {
8
- getMap: () => map
9
- };
10
- for (const key of getMethodNames(map)) {
11
- if (!(key in result) && !skipMethods.includes(key)) {
12
- result[key] = map[key].bind(map);
13
- }
14
- }
15
- return result;
16
- }
17
- function getMethodNames(obj) {
18
- const result = new Set();
19
- let proto = obj;
20
- while (proto) {
21
- for (const key of Object.getOwnPropertyNames(proto)) {
22
- if (key[0] !== "_" && typeof obj[key] === "function" && key !== "fire" && key !== "setEventedParent") {
23
- result.add(key);
24
- }
25
- }
26
- proto = Object.getPrototypeOf(proto);
27
- }
28
- return Array.from(result);
29
- }
30
- //# sourceMappingURL=create-ref.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-ref.js","names":["skipMethods","createRef","mapInstance","map","result","getMap","key","getMethodNames","includes","bind","obj","Set","proto","Object","getOwnPropertyNames","add","getPrototypeOf","Array","from"],"sources":["../../src/maplibre/create-ref.ts"],"sourcesContent":["import type { Map as MapInstance } from \"../types/lib\";\nimport type Maplibre from \"./maplibre\";\n\n/** These methods may break the react binding if called directly */\nconst skipMethods = [\n \"setMaxBounds\",\n \"setMinZoom\",\n \"setMaxZoom\",\n \"setMinPitch\",\n \"setMaxPitch\",\n \"setRenderWorldCopies\",\n \"setProjection\",\n \"setStyle\",\n \"addSource\",\n \"removeSource\",\n \"addLayer\",\n \"removeLayer\",\n \"setLayerZoomRange\",\n \"setFilter\",\n \"setPaintProperty\",\n \"setLayoutProperty\",\n \"setLight\",\n \"setTerrain\",\n \"setFog\",\n \"remove\",\n] as const;\n\nexport type MapRef = {\n getMap(): MapInstance;\n} & Omit<MapInstance, (typeof skipMethods)[number]>;\n\nexport default function createRef(mapInstance: Maplibre): MapRef | null {\n if (!mapInstance) {\n return null;\n }\n\n const map = mapInstance.map;\n const result: any = {\n getMap: () => map,\n };\n\n for (const key of getMethodNames(map)) {\n // @ts-expect-error\n if (!(key in result) && !skipMethods.includes(key)) {\n result[key] = map[key].bind(map);\n }\n }\n\n return result;\n}\n\nfunction getMethodNames(obj: Object) {\n const result = new Set<string>();\n\n let proto = obj;\n while (proto) {\n for (const key of Object.getOwnPropertyNames(proto)) {\n if (\n key[0] !== \"_\" &&\n typeof obj[key] === \"function\" &&\n key !== \"fire\" &&\n key !== \"setEventedParent\"\n ) {\n result.add(key);\n }\n }\n proto = Object.get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AG,CAAC;MACjB;IACF;IACAM,KAAK,GAAGC,MAAM,CAACG,cAAc,CAACJ,KAAK,CAAC;EACtC;EACA,OAAOK,KAAK,CAACC,IAAI,CAACd,MAAM,CAAC;AAC3B","ignoreList":[]}
@@ -1,81 +0,0 @@
1
- import type { ViewState, PointLike, PaddingOptions, ImmutableLike, LngLatBoundsLike } from "../types/common";
2
- import type { StyleSpecification, SkySpecification, LightSpecification, TerrainSpecification, ProjectionSpecification } from "../types/style-spec";
3
- import type { Map as MapInstance } from "../types/lib";
4
- import type { MapCallbacks } from "../types/events";
5
- export type MaplibreProps = Partial<ViewState> & MapCallbacks & {
6
- /** Camera options used when constructing the Map instance */
7
- initialViewState?: Partial<ViewState> & {
8
- /** The initial bounds of the map. If bounds is specified, it overrides longitude, latitude and zoom options. */
9
- bounds?: LngLatBoundsLike;
10
- /** A fitBounds options object to use only when setting the bounds option. */
11
- fitBoundsOptions?: {
12
- offset?: PointLike;
13
- minZoom?: number;
14
- maxZoom?: number;
15
- padding?: number | PaddingOptions;
16
- };
17
- };
18
- /** If provided, render into an external WebGL context */
19
- gl?: WebGLRenderingContext;
20
- /** For external controller to override the camera state */
21
- viewState?: ViewState & {
22
- width: number;
23
- height: number;
24
- };
25
- /** Mapbox style */
26
- mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;
27
- /** Enable diffing when the map style changes
28
- * @default true
29
- */
30
- styleDiffing?: boolean;
31
- /** The projection property of the style. Must conform to the Projection Style Specification.
32
- * @default 'mercator'
33
- */
34
- projection?: ProjectionSpecification | "mercator" | "globe";
35
- /** Light properties of the map. */
36
- light?: LightSpecification;
37
- /** Terrain property of the style. Must conform to the Terrain Style Specification.
38
- * If `undefined` is provided, removes terrain from the map. */
39
- terrain?: TerrainSpecification;
40
- /** Sky properties of the map. Must conform to the Sky Style Specification. */
41
- sky?: SkySpecification;
42
- /** Default layers to query on pointer events */
43
- interactiveLayerIds?: string[];
44
- /** CSS cursor */
45
- cursor?: string;
46
- };
47
- /**
48
- * A wrapper for mapbox-gl's Map class
49
- */
50
- export default class Maplibre {
51
- private _MapClass;
52
- private _map;
53
- props: MaplibreProps;
54
- private _internalUpdate;
55
- private _hoveredFeatures;
56
- private _propsedCameraUpdate;
57
- private _styleComponents;
58
- static savedMaps: Maplibre[];
59
- constructor(MapClass: {
60
- new (options: any): MapInstance;
61
- }, props: MaplibreProps, container: HTMLDivElement);
62
- get map(): MapInstance;
63
- setProps(props: MaplibreProps): void;
64
- static reuse(props: MaplibreProps, container: HTMLDivElement): Maplibre;
65
- private _initialize;
66
- recycle(): void;
67
- destroy(): void;
68
- redraw(): void;
69
- private _updateSize;
70
- private _updateViewState;
71
- private _updateSettings;
72
- private _updateStyle;
73
- private _updateStyleComponents;
74
- private _updateHandlers;
75
- private _onEvent;
76
- private _onCameraEvent;
77
- private _onCameraUpdate;
78
- private _queryRenderedFeatures;
79
- private _updateHover;
80
- private _onPointerEvent;
81
- }