Socket
Socket
Sign inDemoInstall

@react-google-maps/api

Package Overview
Dependencies
16
Maintainers
2
Versions
135
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.7.0 to 2.8.0

src/components/addons/MarkerClusterer.stories.tsx

87

package.json
{
"name": "@react-google-maps/api",
"sideEffects": false,
"version": "2.7.0",
"version": "2.8.0",
"description": "React.js Google Maps API integration",

@@ -88,14 +88,11 @@ "license": "MIT",

"resolutions": {
"@types/react": "17.0.22",
"@types/react-dom": "17.0.9",
"**/typescript": "4.4.3",
"**/@typescript-eslint/eslint-plugin": "4.31.2",
"**/@typescript-eslint/parser": "4.31.2"
"@types/react": "17.0.43",
"@types/react-dom": "17.0.14"
},
"dependencies": {
"@googlemaps/js-api-loader": "1.12.8",
"@googlemaps/markerclusterer": "1.0.12",
"@react-google-maps/infobox": "2.6.0",
"@react-google-maps/marker-clusterer": "2.6.0",
"@types/google.maps": "3.46.1",
"@googlemaps/js-api-loader": "1.13.10",
"@googlemaps/markerclusterer": "2.0.2",
"@react-google-maps/infobox": "2.8.0",
"@react-google-maps/marker-clusterer": "2.9.0",
"@types/google.maps": "3.48.3",
"invariant": "2.2.4"

@@ -108,53 +105,59 @@ },

"devDependencies": {
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-node-resolve": "13.0.6",
"@rollup/plugin-typescript": "8.3.0",
"@testing-library/react": "12.1.2",
"@rollup/plugin-commonjs": "21.0.3",
"@rollup/plugin-node-resolve": "13.1.3",
"@rollup/plugin-typescript": "8.3.1",
"@testing-library/react": "13.0.0",
"@types/invariant": "2.2.35",
"@types/jest": "27.0.2",
"@types/react": "17.0.34",
"@types/react-dom": "17.0.11",
"@typescript-eslint/eslint-plugin": "5.3.1",
"@typescript-eslint/parser": "5.3.1",
"acorn": "8.5.0",
"@types/jest": "27.4.1",
"@types/react": "17.0.43",
"@types/react-dom": "17.0.14",
"@types/supercluster": "^7.1.0",
"@typescript-eslint/eslint-plugin": "5.17.0",
"@typescript-eslint/parser": "5.17.0",
"@typescript/lib-dom": "npm:@types/web",
"acorn": "8.7.0",
"acorn-jsx": "5.3.2",
"awesome-typescript-loader": "5.2.1",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-config-standard-react": "11.0.1",
"eslint-import-resolver-typescript": "2.5.0",
"eslint": "8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "17.0.0-0",
"eslint-import-resolver-typescript": "2.7.1",
"eslint-plugin-ascii": "1.0.0",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-compat": "3.13.0",
"eslint-plugin-compat": "4.0.2",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-html": "6.2.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jest": "^26.1.3",
"eslint-plugin-jest-dom": "^4.0.1",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-n": "^15.1.0",
"eslint-plugin-no-inferred-method-name": "2.0.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-optimize-regex": "1.2.1",
"eslint-plugin-promise": "5.1.1",
"eslint-plugin-react": "7.26.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "6.0.0",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-react-functional-set-state": "1.2.1",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-react-perf": "3.3.0",
"eslint-plugin-security-node": "1.0.14",
"eslint-plugin-standard": "5.0.0",
"eslint-plugin-react-hooks": "4.4.0",
"eslint-plugin-react-perf": "3.3.1",
"eslint-plugin-security-node": "1.1.1",
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
"jest": "27.3.1",
"jest-cli": "27.3.1",
"jest": "27.5.1",
"jest-cli": "27.5.1",
"prettier": "^2.6.2",
"react": "17.0.2",
"react-docgen": "5.4.0",
"react-docgen-typescript": "2.1.1",
"react-docgen-typescript": "2.2.2",
"react-dom": "17.0.2",
"react-styleguidist": "11.1.7",
"react-styleguidist": "11.2.0",
"rimraf": "3.0.2",
"rollup": "2.59.0",
"rollup-plugin-dts": "4.0.1",
"rollup": "2.70.1",
"rollup-plugin-dts": "4.2.0",
"rollup-plugin-terser": "7.0.2",
"ts-jest": "27.0.7",
"typescript": "4.4.4"
"ts-jest": "27.1.4",
"typescript": "4.6.3"
},
"gitHead": "80167ddcc3d8e356dbf0b0c3a6292c6a3a989f83"
}

@@ -0,1 +1,5 @@

/**
* @jest-environment jsdom
*/
import { applyUpdaterToNextProps } from './../../utils/helper'

@@ -2,0 +6,0 @@

@@ -0,1 +1,5 @@

/**
* @jest-environment jsdom
*/
import { injectScript } from '../../utils/injectscript'

@@ -107,2 +111,2 @@

})
})
})
import { PositionDrawProps } from "../../types"
/* eslint-disable filenames/match-regex */
export function getOffsetOverride(
containerElement: HTMLElement,
getPixelPositionOffset?: (offsetWidth: number, offsetHeight: number) => { x: number; y: number }
getPixelPositionOffset?:( (offsetWidth: number, offsetHeight: number) => { x: number; y: number }) | undefined
): { x: number; y: number } | {} {

@@ -14,21 +13,34 @@ return typeof getPixelPositionOffset === 'function'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const createLatLng = (inst: any, Type: any): any => new Type(inst.lat, inst.lng)
function createLatLng(inst: any, Type: any): any { return new Type(inst.lat, inst.lng) }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const createLatLngBounds = (inst: any, Type: any): any =>
new Type(
function createLatLngBounds(inst: any, Type: any): any {
return new Type(
new google.maps.LatLng(inst.ne.lat, inst.ne.lng),
new google.maps.LatLng(inst.sw.lat, inst.sw.lng)
)
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const ensureOfType = (inst: any, type: any, factory: any): any => {
function ensureOfType(
inst: google.maps.LatLng | google.maps.LatLngLiteral | undefined,
type: any,
factory: any
): any {
return inst instanceof type ? inst : factory(inst, type)
}
const getLayoutStylesByBounds = (
function ensureOfTypeBounds(
inst: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral,
type: any,
factory: (inst: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral, type: any) => any
): any {
return inst instanceof type ? inst : factory(inst, type)
}
function getLayoutStylesByBounds(
mapCanvasProjection: google.maps.MapCanvasProjection,
offset: { x: number; y: number },
bounds: google.maps.LatLngBounds
): { left: string; top: string; width?: string; height?: string } => {
): { left: string; top: string; width?: string | undefined; height?: string | undefined } {
const ne = mapCanvasProjection && mapCanvasProjection.fromLatLngToDivPixel(bounds.getNorthEast())

@@ -53,7 +65,7 @@

const getLayoutStylesByPosition = (
function getLayoutStylesByPosition (
mapCanvasProjection: google.maps.MapCanvasProjection,
offset: { x: number; y: number },
position: google.maps.LatLng
): { left: string; top: string } => {
): { left: string; top: string } {
const point = mapCanvasProjection && mapCanvasProjection.fromLatLngToDivPixel(position)

@@ -76,8 +88,8 @@

export const getLayoutStyles = (
export function getLayoutStyles (
mapCanvasProjection: google.maps.MapCanvasProjection,
offset: { x: number; y: number },
bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral,
position?: google.maps.LatLng | google.maps.LatLngLiteral
): PositionDrawProps => {
bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral | undefined,
position?: google.maps.LatLng | google.maps.LatLngLiteral | undefined
): PositionDrawProps {
return bounds !== undefined

@@ -87,3 +99,3 @@ ? getLayoutStylesByBounds(

offset,
ensureOfType(bounds, google.maps.LatLngBounds, createLatLngBounds)
ensureOfTypeBounds(bounds, google.maps.LatLngBounds, createLatLngBounds)
)

@@ -97,6 +109,6 @@ : getLayoutStylesByPosition(

export const arePositionsEqual = (
export function arePositionsEqual (
currentPosition: PositionDrawProps,
previousPosition: PositionDrawProps
): boolean => {
): boolean {
return currentPosition.left === previousPosition.left

@@ -106,2 +118,2 @@ && currentPosition.top === previousPosition.top

&& currentPosition.height === previousPosition.height;
}
}
# Access google map instance
```js static
import React from 'react'
import { useEffect } from 'react'
import { GoogleMap, useGoogleMap } from '@react-google-maps/api'

@@ -10,3 +10,3 @@

React.useEffect(() => {
useEffect(() => {
map.panTo(...)

@@ -13,0 +13,0 @@ }, [map])

@@ -8,3 +8,3 @@ # Requires React 16.8+

```js static
import React from 'react'
import { useCallback } from 'react'
import { GoogleMap, useJsApiLoader } from '@react-google-maps/api'

@@ -29,3 +29,3 @@

// feel free to render directly if you don't need that
const onLoad = React.useCallback(
const onLoad = useCallback(
function onLoad (mapInstance) {

@@ -32,0 +32,0 @@ // do something with map Instance

@@ -8,3 +8,3 @@ # Requires React 16.8+

```js static
import React from 'react'
import { useCallback } from 'react'
import { GoogleMap, useLoadScript } from '@react-google-maps/api'

@@ -29,3 +29,3 @@

// feel free to render directly if you don't need that
const onLoad = React.useCallback(
const onLoad = useCallback(
function onLoad (mapInstance) {

@@ -32,0 +32,0 @@ // do something with map Instance

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function forEach(obj: any, fn: any): any {
Object.keys(obj).forEach(function iterator(key) {
Object.keys(obj).forEach((key) => {
return fn(obj[key], key)
})
}

@@ -6,3 +6,3 @@ /* global google */

export const applyUpdaterToNextProps = (
export function applyUpdaterToNextProps (
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -17,3 +17,3 @@ updaterMap: any,

// eslint-disable-next-line @typescript-eslint/no-explicit-any
): any => {
): any {
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -63,2 +63,3 @@ const map: any = {}

}
function unregisterEvent(registered: google.maps.MapsEventListener): void {

@@ -90,4 +91,6 @@ google.maps.event.removeListener(registered)

const registeredEvents = registerEvents(nextProps, instance, eventMap)
applyUpdaterToNextProps(updaterMap, prevProps, nextProps, instance)
return registeredEvents
}
import { isBrowser } from './isbrowser'
interface WindowWithGoogleMap extends Window {
initMap?: () => void
initMap?: (() => void) | undefined
}

@@ -10,6 +10,6 @@

id: string
nonce?: string
nonce?: string | undefined
}
export const injectScript = ({ url, id, nonce }: InjectScriptArg): Promise<any> => {
export function injectScript({ url, id, nonce }: InjectScriptArg): Promise<any> {
if (!isBrowser) {

@@ -21,6 +21,9 @@ return Promise.reject(new Error('document is undefined'))

const existingScript = document.getElementById(id) as HTMLScriptElement | undefined
const windowWithGoogleMap: WindowWithGoogleMap = window
if (existingScript) {
// Same script id/url: keep same script
const dataStateAttribute = existingScript.getAttribute('data-state')
if (existingScript.src === url && dataStateAttribute !== 'error') {

@@ -31,2 +34,3 @@ if (dataStateAttribute === 'ready') {

const originalInitMap = windowWithGoogleMap.initMap
const originalErrorCallback = existingScript.onerror

@@ -68,2 +72,3 @@

script.setAttribute('data-state', 'error')
reject(err)

@@ -74,2 +79,3 @@ }

script.setAttribute('data-state', 'ready')
resolve(id)

@@ -81,4 +87,5 @@ }

console.error('injectScript error: ', err)
throw err
})
}

@@ -7,9 +7,9 @@ import invariant from 'invariant'

googleMapsApiKey: string | ""
googleMapsClientId?: string
version?: string
language?: string
region?: string
libraries?: Libraries
channel?: string
mapIds?: string[]
googleMapsClientId?: string | undefined
version?: string | undefined
language?: string | undefined
region?: string | undefined
libraries?: Libraries | undefined
channel?: string | undefined
mapIds?: string[] | undefined
}

@@ -16,0 +16,0 @@

@@ -1,1 +0,1 @@

export function noop(): void {}
export function noop(): void { return }

@@ -1,2 +0,2 @@

const isRobotoStyle = (element: HTMLElement): boolean => {
function isRobotoStyle(element: HTMLElement): boolean {
// roboto font download

@@ -13,13 +13,9 @@ if (

element.tagName.toLowerCase() === 'style' &&
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
element.styleSheet &&
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
element.styleSheet.cssText &&
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
element.styleSheet.cssText.replace('\r\n', '').indexOf('.gm-style') === 0
) {
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore

@@ -41,3 +37,2 @@ element.styleSheet.cssText = ''

element.tagName.toLowerCase() === 'style' &&
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore

@@ -54,3 +49,3 @@ !element.styleSheet &&

// Preventing the Google Maps library from downloading an extra font
export const preventGoogleFonts = (): void => {
export function preventGoogleFonts (): void {
// we override these methods only for one particular head element

@@ -63,3 +58,2 @@ // default methods for other elements are not affected

// TODO: adding return before reflect solves the TS issue
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore

@@ -78,3 +72,2 @@ head.insertBefore = function insertBefore(

// TODO: adding return before reflect solves the TS issue
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore

@@ -81,0 +74,0 @@ head.appendChild = function appendChild(textNode: HTMLElement): void {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const reduce = (obj: any, fn: any, acc: any): any => {
export function reduce(obj: any, fn: any, acc: any): any {
return Object.keys(obj).reduce(function reducer(newAcc, key) {

@@ -4,0 +4,0 @@ return fn(newAcc, obj[key], key)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc