@ttoss/google-maps 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -3,26 +3,21 @@ import * as React from "react";
3
3
 
4
4
  // src/GoogleMapsProvider.tsx
5
5
  import { useScript } from "@ttoss/hooks";
6
- import {
7
- createContext,
8
- createElement,
9
- useContext,
10
- useMemo
11
- } from "react";
12
- var GoogleMapsContext = createContext({
6
+ import * as React2 from "react";
7
+ var GoogleMapsContext = React2.createContext({
13
8
  status: "idle",
14
9
  googleMaps: null
15
10
  });
16
11
  var GoogleMapsProvider = ({ children, apiKey, libraries }) => {
17
12
  const src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries == null ? void 0 : libraries.join(",")}`;
18
13
  const { status } = useScript(src);
19
- const googleMaps = useMemo(() => {
14
+ const googleMaps = React2.useMemo(() => {
20
15
  if (status === "ready" && window.google.maps) {
21
16
  return window.google.maps;
22
17
  }
23
18
  return null;
24
19
  }, [status]);
25
- const value = useMemo(() => {
20
+ const value = React2.useMemo(() => {
26
21
  if (status === "ready" && googleMaps) {
27
22
  return {
28
23
  status,
@@ -34,21 +29,18 @@ var GoogleMapsProvider = ({ children, apiKey, libraries }) => {
34
29
  googleMaps: null
35
30
  };
36
31
  }, [googleMaps, status]);
37
- return /* @__PURE__ */ createElement(GoogleMapsContext.Provider, {
32
+ return /* @__PURE__ */ React2.createElement(GoogleMapsContext.Provider, {
38
33
  value
39
34
  }, children);
40
35
  };
41
- var useGoogleMaps = () => useContext(GoogleMapsContext);
36
+ var useGoogleMaps = () => React2.useContext(GoogleMapsContext);
42
37
 
43
38
  // src/useGeocoder.ts
44
- import {
45
- useMemo as useMemo2,
46
- useState
47
- } from "react";
39
+ import * as React3 from "react";
48
40
  var useGeocoder = () => {
49
41
  const { googleMaps } = useGoogleMaps();
50
- const [isGeocoderInitialized, setIsGeocoderInitialized] = useState(false);
51
- const geocoder = useMemo2(() => {
42
+ const [isGeocoderInitialized, setIsGeocoderInitialized] = React3.useState(false);
43
+ const geocoder = React3.useMemo(() => {
52
44
  if (googleMaps) {
53
45
  const googleMapsGeocoder = new googleMaps.Geocoder();
54
46
  setIsGeocoderInitialized(true);
@@ -60,17 +52,13 @@ var useGeocoder = () => {
60
52
  };
61
53
 
62
54
  // src/useMap.ts
63
- import {
64
- useMemo as useMemo3,
65
- useRef,
66
- useState as useState2
67
- } from "react";
55
+ import * as React4 from "react";
68
56
  var useMap = (options) => {
69
- const ref = useRef(null);
57
+ const ref = React4.useRef(null);
70
58
  const { googleMaps } = useGoogleMaps();
71
- const [isMapInitialized, setIsMapInitialized] = useState2(false);
59
+ const [isMapInitialized, setIsMapInitialized] = React4.useState(false);
72
60
  const optionsStringify = JSON.stringify(options);
73
- const map = useMemo3(() => {
61
+ const map = React4.useMemo(() => {
74
62
  if (googleMaps && ref.current) {
75
63
  const parsedOptions = JSON.parse(optionsStringify);
76
64
  const googleMapsMap = new googleMaps.Map(ref.current, parsedOptions);
package/dist/index.js CHANGED
@@ -1,28 +1,60 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// tsup.inject.js
2
- var _react = require('react'); var React = _interopRequireWildcard(_react);
3
-
4
- // src/GoogleMapsProvider.tsx
5
- var _hooks = require('@ttoss/hooks');
6
-
7
-
8
-
9
-
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+
29
+ // src/index.ts
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ GoogleMapsProvider: () => GoogleMapsProvider,
33
+ useGeocoder: () => useGeocoder,
34
+ useGoogleMaps: () => useGoogleMaps,
35
+ useMap: () => useMap
36
+ });
10
37
 
38
+ // tsup.inject.js
39
+ var React = __toESM(require("react"));
11
40
 
12
- var GoogleMapsContext = _react.createContext.call(void 0, {
41
+ // src/GoogleMapsProvider.tsx
42
+ var import_hooks = require("@ttoss/hooks");
43
+ var React2 = __toESM(require("react"));
44
+ var GoogleMapsContext = React2.createContext({
13
45
  status: "idle",
14
46
  googleMaps: null
15
47
  });
16
48
  var GoogleMapsProvider = ({ children, apiKey, libraries }) => {
17
49
  const src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries == null ? void 0 : libraries.join(",")}`;
18
- const { status } = _hooks.useScript.call(void 0, src);
19
- const googleMaps = _react.useMemo.call(void 0, () => {
50
+ const { status } = (0, import_hooks.useScript)(src);
51
+ const googleMaps = React2.useMemo(() => {
20
52
  if (status === "ready" && window.google.maps) {
21
53
  return window.google.maps;
22
54
  }
23
55
  return null;
24
56
  }, [status]);
25
- const value = _react.useMemo.call(void 0, () => {
57
+ const value = React2.useMemo(() => {
26
58
  if (status === "ready" && googleMaps) {
27
59
  return {
28
60
  status,
@@ -34,21 +66,18 @@ var GoogleMapsProvider = ({ children, apiKey, libraries }) => {
34
66
  googleMaps: null
35
67
  };
36
68
  }, [googleMaps, status]);
37
- return /* @__PURE__ */ _react.createElement.call(void 0, GoogleMapsContext.Provider, {
69
+ return /* @__PURE__ */ React2.createElement(GoogleMapsContext.Provider, {
38
70
  value
39
71
  }, children);
40
72
  };
41
- var useGoogleMaps = () => _react.useContext.call(void 0, GoogleMapsContext);
73
+ var useGoogleMaps = () => React2.useContext(GoogleMapsContext);
42
74
 
43
75
  // src/useGeocoder.ts
44
-
45
-
46
-
47
-
76
+ var React3 = __toESM(require("react"));
48
77
  var useGeocoder = () => {
49
78
  const { googleMaps } = useGoogleMaps();
50
- const [isGeocoderInitialized, setIsGeocoderInitialized] = _react.useState.call(void 0, false);
51
- const geocoder = _react.useMemo.call(void 0, () => {
79
+ const [isGeocoderInitialized, setIsGeocoderInitialized] = React3.useState(false);
80
+ const geocoder = React3.useMemo(() => {
52
81
  if (googleMaps) {
53
82
  const googleMapsGeocoder = new googleMaps.Geocoder();
54
83
  setIsGeocoderInitialized(true);
@@ -60,17 +89,13 @@ var useGeocoder = () => {
60
89
  };
61
90
 
62
91
  // src/useMap.ts
63
-
64
-
65
-
66
-
67
-
92
+ var React4 = __toESM(require("react"));
68
93
  var useMap = (options) => {
69
- const ref = _react.useRef.call(void 0, null);
94
+ const ref = React4.useRef(null);
70
95
  const { googleMaps } = useGoogleMaps();
71
- const [isMapInitialized, setIsMapInitialized] = _react.useState.call(void 0, false);
96
+ const [isMapInitialized, setIsMapInitialized] = React4.useState(false);
72
97
  const optionsStringify = JSON.stringify(options);
73
- const map = _react.useMemo.call(void 0, () => {
98
+ const map = React4.useMemo(() => {
74
99
  if (googleMaps && ref.current) {
75
100
  const parsedOptions = JSON.parse(optionsStringify);
76
101
  const googleMapsMap = new googleMaps.Map(ref.current, parsedOptions);
@@ -81,9 +106,11 @@ var useMap = (options) => {
81
106
  }, [googleMaps, optionsStringify]);
82
107
  return { map, ref, isMapInitialized };
83
108
  };
84
-
85
-
86
-
87
-
88
-
89
- exports.GoogleMapsProvider = GoogleMapsProvider; exports.useGeocoder = useGeocoder; exports.useGoogleMaps = useGoogleMaps; exports.useMap = useMap;
109
+ module.exports = __toCommonJS(src_exports);
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ GoogleMapsProvider,
113
+ useGeocoder,
114
+ useGoogleMaps,
115
+ useMap
116
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/google-maps",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "author": "ttoss",
5
5
  "contributors": [
6
6
  {
@@ -31,12 +31,12 @@
31
31
  "build": "tsup"
32
32
  },
33
33
  "dependencies": {
34
- "@ttoss/hooks": "^0.8.4",
34
+ "@ttoss/hooks": "^0.8.5",
35
35
  "@types/google.maps": "^3.45.6"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=16.8.0",
39
39
  "react-dom": ">=16.8.0"
40
40
  },
41
- "gitHead": "9d8124a3110e71122dbdeebc791bac649e43791c"
41
+ "gitHead": "41243699cc8ed5eba265e6434ebefbb9d6d91d52"
42
42
  }