google-maps-js-api-loader
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,2 +0,2 @@ | ||
import t from"fast-deep-equal";import{stringifyUrl as e}from"query-string";function a(){return a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])}return t},a.apply(this,arguments)}const o=function(){};var s;!function(t){t[t.NONE=0]="NONE",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t[t.ERROR=3]="ERROR"}(s||(s={}));class r{static get status(){return this._status}static async load(r,n){if(this._options){if(!t(this._options,r))throw new Error("Loader must not be called again with different options")}else{if(window.google&&window.google.maps)throw new Error("Google Maps already loaded");let t;this._options=r,this._status=s.LOADING,(n||o)(),this._promise=new Promise((e,a)=>{window.__googleMapsCallback=()=>{this._status=s.LOADED,e(),delete window.__googleMapsCallback},t=t=>{this._status=s.ERROR,a(t)}}),((t,o)=>{const{params:s,url:r,nonce:n}=(t=>({params:{key:t.apiKey,channel:t.channel,client:t.client,v:t.version,language:t.language,region:t.region,map_ids:t.mapIds,libraries:t.libraries},url:t.url||"https://maps.googleapis.com/maps/api/js",nonce:t.nonce}))(t),i=document.createElement("script");i.src=e({url:r,query:a({},s,{callback:"__googleMapsCallback"})},{skipEmptyString:!0}),i.type="text/javascript",i.defer=!0,i.async=!0,i.addEventListener("error",o),n&&(i.nonce=n),document.head.appendChild(i)})(r,t)}return this._promise}}r._status=s.NONE,r._options=void 0,r._promise=void 0;export{s as LoaderStatus,r as default}; | ||
import t from"fast-deep-equal";import{stringifyUrl as e}from"query-string";function s(){return s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(t[o]=s[o])}return t},s.apply(this,arguments)}const o=function(){};var a;!function(t){t[t.NONE=0]="NONE",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t[t.ERROR=3]="ERROR"}(a||(a={}));class i{static get status(){return this._status}static get completion(){return this._promise}static get libraries(){return this._options.libraries||[]}static async load(i,r){if(this._options){if(!t(this._options,i))throw new Error("Loader must not be called again with different options")}else{if(window.google&&window.google.maps)throw new Error("Google Maps already loaded");let t;this._options=i,this._status=a.LOADING,(r||o)(),this._promise=new Promise((e,s)=>{window.__googleMapsCallback=()=>{this._status=a.LOADED,e(),delete window.__googleMapsCallback},t=t=>{this._status=a.ERROR,s(t)}}),((t,o)=>{const{params:a,url:i,nonce:r}=(t=>({params:{key:t.apiKey,channel:t.channel,client:t.client,v:t.version,language:t.language,region:t.region,map_ids:t.mapIds,libraries:t.libraries},url:t.url||"https://maps.googleapis.com/maps/api/js",nonce:t.nonce}))(t),n=document.createElement("script");n.src=e({url:i,query:s({},a,{callback:"__googleMapsCallback"})},{skipEmptyString:!0}),n.type="text/javascript",n.defer=!0,n.async=!0,n.addEventListener("error",o),r&&(n.nonce=r),document.head.appendChild(n)})(i,t)}return this._promise}}i._status=a.NONE,i._options=void 0,i._promise=void 0;export{a as LoaderStatus,i as default}; | ||
//# sourceMappingURL=google-maps-loader.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import e from"fast-deep-equal";import{stringifyUrl as r}from"query-string";function t(){return t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},t.apply(this,arguments)}var n,o=function(){};!function(e){e[e.NONE=0]="NONE",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e[e.ERROR=3]="ERROR"}(n||(n={}));var a=/*#__PURE__*/function(){function a(){}var i,s;return a.load=function(a,i){try{var s=this;if(s._options){if(!e(s._options,a))throw new Error("Loader must not be called again with different options")}else{if(window.google&&window.google.maps)throw new Error("Google Maps already loaded");var l;s._options=a,s._status=n.LOADING,(i||o)(),s._promise=new Promise(function(e,r){window.__googleMapsCallback=function(){s._status=n.LOADED,e(),delete window.__googleMapsCallback},l=function(e){s._status=n.ERROR,r(e)}}),function(e,n){var o=function(e){return{params:{key:e.apiKey,channel:e.channel,client:e.client,v:e.version,language:e.language,region:e.region,map_ids:e.mapIds,libraries:e.libraries},url:e.url||"https://maps.googleapis.com/maps/api/js",nonce:e.nonce}}(e),a=o.params,i=o.url,s=o.nonce,l=document.createElement("script");l.src=r({url:i,query:t({},a,{callback:"__googleMapsCallback"})},{skipEmptyString:!0}),l.type="text/javascript",l.defer=!0,l.async=!0,l.addEventListener("error",n),s&&(l.nonce=s),document.head.appendChild(l)}(a,l)}return Promise.resolve(s._promise)}catch(e){return Promise.reject(e)}},i=a,(s=[{key:"status",get:function(){return this._status}}])&&function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i,s),Object.defineProperty(i,"prototype",{writable:!1}),a}();a._status=n.NONE,a._options=void 0,a._promise=void 0;export{n as LoaderStatus,a as default}; | ||
import e from"fast-deep-equal";import{stringifyUrl as r}from"query-string";function t(){return t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},t.apply(this,arguments)}var n,o=function(){};!function(e){e[e.NONE=0]="NONE",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e[e.ERROR=3]="ERROR"}(n||(n={}));var a=/*#__PURE__*/function(){function a(){}var i,s;return a.load=function(a,i){try{var s=this;if(s._options){if(!e(s._options,a))throw new Error("Loader must not be called again with different options")}else{if(window.google&&window.google.maps)throw new Error("Google Maps already loaded");var l;s._options=a,s._status=n.LOADING,(i||o)(),s._promise=new Promise(function(e,r){window.__googleMapsCallback=function(){s._status=n.LOADED,e(),delete window.__googleMapsCallback},l=function(e){s._status=n.ERROR,r(e)}}),function(e,n){var o=function(e){return{params:{key:e.apiKey,channel:e.channel,client:e.client,v:e.version,language:e.language,region:e.region,map_ids:e.mapIds,libraries:e.libraries},url:e.url||"https://maps.googleapis.com/maps/api/js",nonce:e.nonce}}(e),a=o.params,i=o.url,s=o.nonce,l=document.createElement("script");l.src=r({url:i,query:t({},a,{callback:"__googleMapsCallback"})},{skipEmptyString:!0}),l.type="text/javascript",l.defer=!0,l.async=!0,l.addEventListener("error",n),s&&(l.nonce=s),document.head.appendChild(l)}(a,l)}return Promise.resolve(s._promise)}catch(e){return Promise.reject(e)}},i=a,(s=[{key:"status",get:function(){return this._status}},{key:"completion",get:function(){return this._promise}},{key:"libraries",get:function(){return this._options.libraries||[]}}])&&function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i,s),Object.defineProperty(i,"prototype",{writable:!1}),a}();a._status=n.NONE,a._options=void 0,a._promise=void 0;export{n as LoaderStatus,a as default}; | ||
//# sourceMappingURL=google-maps-loader.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fast-deep-equal"),require("query-string")):"function"==typeof define&&define.amd?define(["exports","fast-deep-equal","query-string"],t):t((e||self).googleMapsJsApiLoader={},e.fastDeepEqual,e.queryString)}(this,function(e,t,r){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/n(t);function a(){return a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(this,arguments)}var i,s="__googleMapsCallback",u=function(){};e.LoaderStatus=void 0,(i=e.LoaderStatus||(e.LoaderStatus={}))[i.NONE=0]="NONE",i[i.LOADING=1]="LOADING",i[i.LOADED=2]="LOADED",i[i.ERROR=3]="ERROR";var l=/*#__PURE__*/function(){function t(){}var n,i;return t.load=function(t,n){try{var i=this;if(i._options){if(!o.default(i._options,t))throw new Error("Loader must not be called again with different options")}else{if(window.google&&window.google.maps)throw new Error("Google Maps already loaded");var l;i._options=t,i._status=e.LoaderStatus.LOADING,(n||u)(),i._promise=new Promise(function(t,r){window[s]=function(){i._status=e.LoaderStatus.LOADED,t(),delete window[s]},l=function(t){i._status=e.LoaderStatus.ERROR,r(t)}}),function(e,t){var n=function(e){return{params:{key:e.apiKey,channel:e.channel,client:e.client,v:e.version,language:e.language,region:e.region,map_ids:e.mapIds,libraries:e.libraries},url:e.url||"https://maps.googleapis.com/maps/api/js",nonce:e.nonce}}(e),o=n.params,i=n.url,u=n.nonce,l=document.createElement("script");l.src=r.stringifyUrl({url:i,query:a({},o,{callback:s})},{skipEmptyString:!0}),l.type="text/javascript",l.defer=!0,l.async=!0,l.addEventListener("error",t),u&&(l.nonce=u),document.head.appendChild(l)}(t,l)}return Promise.resolve(i._promise)}catch(e){return Promise.reject(e)}},n=t,(i=[{key:"status",get:function(){return this._status}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n,i),Object.defineProperty(n,"prototype",{writable:!1}),t}();l._status=e.LoaderStatus.NONE,l._options=void 0,l._promise=void 0,e.default=l}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fast-deep-equal"),require("query-string")):"function"==typeof define&&define.amd?define(["exports","fast-deep-equal","query-string"],t):t((e||self).googleMapsJsApiLoader={},e.fastDeepEqual,e.queryString)}(this,function(e,t,r){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=/*#__PURE__*/n(t);function a(){return a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(this,arguments)}var i,s="__googleMapsCallback",u=function(){};e.LoaderStatus=void 0,(i=e.LoaderStatus||(e.LoaderStatus={}))[i.NONE=0]="NONE",i[i.LOADING=1]="LOADING",i[i.LOADED=2]="LOADED",i[i.ERROR=3]="ERROR";var l=/*#__PURE__*/function(){function t(){}var n,i;return t.load=function(t,n){try{var i=this;if(i._options){if(!o.default(i._options,t))throw new Error("Loader must not be called again with different options")}else{if(window.google&&window.google.maps)throw new Error("Google Maps already loaded");var l;i._options=t,i._status=e.LoaderStatus.LOADING,(n||u)(),i._promise=new Promise(function(t,r){window[s]=function(){i._status=e.LoaderStatus.LOADED,t(),delete window[s]},l=function(t){i._status=e.LoaderStatus.ERROR,r(t)}}),function(e,t){var n=function(e){return{params:{key:e.apiKey,channel:e.channel,client:e.client,v:e.version,language:e.language,region:e.region,map_ids:e.mapIds,libraries:e.libraries},url:e.url||"https://maps.googleapis.com/maps/api/js",nonce:e.nonce}}(e),o=n.params,i=n.url,u=n.nonce,l=document.createElement("script");l.src=r.stringifyUrl({url:i,query:a({},o,{callback:s})},{skipEmptyString:!0}),l.type="text/javascript",l.defer=!0,l.async=!0,l.addEventListener("error",t),u&&(l.nonce=u),document.head.appendChild(l)}(t,l)}return Promise.resolve(i._promise)}catch(e){return Promise.reject(e)}},n=t,(i=[{key:"status",get:function(){return this._status}},{key:"completion",get:function(){return this._promise}},{key:"libraries",get:function(){return this._options.libraries||[]}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n,i),Object.defineProperty(n,"prototype",{writable:!1}),t}();l._status=e.LoaderStatus.NONE,l._options=void 0,l._promise=void 0,e.default=l}); | ||
//# sourceMappingURL=google-maps-loader.umd.js.map |
@@ -13,5 +13,15 @@ import { LoaderOptions } from "./types"; | ||
private static _promise; | ||
/** Current status of {@link Loader Loader} */ | ||
static get status(): LoaderStatus; | ||
/** Promise from {@link Loader.load load} first call */ | ||
static get completion(): Promise<void>; | ||
/** List of [libraries](https://developers.google.com/maps/documentation/javascript/libraries) from {@link Loader.load load} options */ | ||
static get libraries(): import("@googlemaps/js-api-loader").Libraries; | ||
/** | ||
* Asynchronously loads Google Maps JavaScript API with given options, can be called multiple times | ||
* @returns promise from the first call | ||
* @throws error if google.maps already exists on the first call or if the options are different from the first call | ||
*/ | ||
static load(options: LoaderOptions, onLoadingStart?: () => void): Promise<void>; | ||
} | ||
export default Loader; |
{ | ||
"name": "google-maps-js-api-loader", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Wrapper for the loading of Google Maps JavaScript API script in the browser", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -16,2 +16,13 @@ # google-maps-js-api-loader | ||
}); | ||
// or | ||
// start load in root file | ||
Loader.load({ | ||
apiKey: API_KEY, | ||
// ...some other options | ||
}); | ||
// and then await it in nested files | ||
await Loader.completion; | ||
``` | ||
@@ -36,2 +47,9 @@ | ||
```ts | ||
enum LoaderStatus { | ||
NONE, // default value | ||
LOADING, | ||
LOADED, | ||
ERROR, | ||
} | ||
static status: LoaderStatus | ||
@@ -44,18 +62,25 @@ ``` | ||
### LoaderStatus | ||
### completion | ||
```ts | ||
enum LoaderStatus { | ||
NONE, | ||
LOADING, | ||
LOADED, | ||
ERROR, | ||
} | ||
static completion: Promise<void> | ||
``` | ||
Promise from [load](#load) first call | ||
--- | ||
### libraries | ||
```ts | ||
static libraries: Libraries | ||
``` | ||
List of [libraries](https://developers.google.com/maps/documentation/javascript/libraries) from [options](#loaderoptions) | ||
--- | ||
### LoaderOptions | ||
Options structure is same to [@googlemaps/js-api-loader](https://github.com/googlemaps/js-api-loader) | ||
Options structure is similar to [@googlemaps/js-api-loader](https://github.com/googlemaps/js-api-loader) | ||
@@ -62,0 +87,0 @@ --- |
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
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
35876
70
89
0