Socket
Socket
Sign inDemoInstall

homebirdscomponents

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebirdscomponents - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

dist/homebirdscomponents/p-aceedeb5.entry.js

323

dist/cjs/ba-google-map.cjs.entry.js

@@ -7,63 +7,280 @@ 'use strict';

// do not edit .js files directly - edit src/index.jst
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) return false;
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
var key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const DEFAULT_ID = "__googleMapsScriptId";
/**
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
* dynamically using
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
* It works by dynamically creating and appending a script node to the the
* document head and wrapping the callback function so as to return a promise.
*
* ```
* const loader = new Loader({
* apiKey: "",
* version: "weekly",
* libraries: ["places"]
* });
*
* loader.load().then(() => {
* const map = new google.maps.Map(...)
* })
* ```
*/
class Loader {
constructor(apiKey = null, options = {}) {
/**
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
* using this library, instead the defaults are set by the Google Maps
* JavaScript API server.
*
* ```
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
* ```
*/
constructor({ apiKey, channel, client, id = DEFAULT_ID, libraries = [], language, region, version, mapIds, nonce, retries = 3, url = "https://maps.googleapis.com/maps/api/js", }) {
this.CALLBACK = "__googleMapsCallback";
this.callbacks = [];
this.done = false;
this.loading = false;
this.errors = [];
this.version = version;
this.apiKey = apiKey;
this.options = options;
if (typeof window === 'undefined') {
throw new Error('google-maps is supported only in browser environment');
this.channel = channel;
this.client = client;
this.id = id || DEFAULT_ID; // Do not allow empty string
this.libraries = libraries;
this.language = language;
this.region = region;
this.mapIds = mapIds;
this.nonce = nonce;
this.retries = retries;
this.url = url;
if (Loader.instance) {
if (!fastDeepEqual(this.options, Loader.instance.options)) {
throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(Loader.instance.options)}`);
}
return Loader.instance;
}
Loader.instance = this;
}
load() {
if (typeof this.api !== 'undefined') {
return Promise.resolve(this.api);
}
if (typeof this.loader !== 'undefined') {
return this.loader;
}
window[Loader.CALLBACK_NAME] = () => {
this.api = window['google'];
if (typeof this.resolve === 'undefined') {
throw new Error('Should not happen');
}
this.resolve(this.api);
get options() {
return {
version: this.version,
apiKey: this.apiKey,
channel: this.channel,
client: this.client,
id: this.id,
libraries: this.libraries,
language: this.language,
region: this.region,
mapIds: this.mapIds,
nonce: this.nonce,
url: this.url,
};
window['gm_authFailure'] = () => {
if (typeof this.reject === 'undefined') {
throw new Error('Should not happen');
}
this.reject(new Error('google-maps: authentication error'));
};
return this.loader = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
const script = document.createElement('script');
script.src = this.createUrl();
script.async = true;
script.onerror = (e) => reject(e);
document.head.appendChild(script);
});
}
/**
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
*
* @ignore
*/
createUrl() {
const parameters = [
`callback=${Loader.CALLBACK_NAME}`,
];
let url = this.url;
url += `?callback=${this.CALLBACK}`;
if (this.apiKey) {
parameters.push(`key=${this.apiKey}`);
url += `&key=${this.apiKey}`;
}
for (let name in this.options) {
if (this.options.hasOwnProperty(name)) {
let value = this.options[name];
if (name === 'version') {
name = 'v';
if (this.channel) {
url += `&channel=${this.channel}`;
}
if (this.client) {
url += `&client=${this.client}`;
}
if (this.libraries.length > 0) {
url += `&libraries=${this.libraries.join(",")}`;
}
if (this.language) {
url += `&language=${this.language}`;
}
if (this.region) {
url += `&region=${this.region}`;
}
if (this.version) {
url += `&v=${this.version}`;
}
if (this.mapIds) {
url += `&map_ids=${this.mapIds.join(",")}`;
}
return url;
}
/**
* Load the Google Maps JavaScript API script and return a Promise.
*/
load() {
return this.loadPromise();
}
/**
* Load the Google Maps JavaScript API script and return a Promise.
*
* @ignore
*/
loadPromise() {
return new Promise((resolve, reject) => {
this.loadCallback((err) => {
if (!err) {
resolve();
}
if (name === 'libraries') {
value = value.join(',');
else {
reject(err);
}
parameters.push(`${name}=${value}`);
});
});
}
/**
* Load the Google Maps JavaScript API script with a callback.
*/
loadCallback(fn) {
this.callbacks.push(fn);
this.execute();
}
/**
* Set the script on document.
*/
setScript() {
if (document.getElementById(this.id)) {
// TODO wrap onerror callback for cases where the script was loaded elsewhere
this.callback();
return;
}
const url = this.createUrl();
const script = document.createElement("script");
script.id = this.id;
script.type = "text/javascript";
script.src = url;
script.onerror = this.loadErrorCallback.bind(this);
script.defer = true;
script.async = true;
if (this.nonce) {
script.nonce = this.nonce;
}
document.head.appendChild(script);
}
deleteScript() {
const script = document.getElementById(this.id);
if (script) {
script.remove();
}
}
resetIfRetryingFailed() {
const possibleAttempts = this.retries + 1;
if (this.done && !this.loading && this.errors.length >= possibleAttempts) {
this.deleteScript();
this.done = false;
this.loading = false;
this.errors = [];
}
}
loadErrorCallback(e) {
this.errors.push(e);
if (this.errors.length <= this.retries) {
const delay = this.errors.length * Math.pow(2, this.errors.length);
console.log(`Failed to load Google Maps script, retrying in ${delay} ms.`);
setTimeout(() => {
this.deleteScript();
this.setScript();
}, delay);
}
else {
this.onerrorEvent = e;
this.callback();
}
}
setCallback() {
window.__googleMapsCallback = this.callback.bind(this);
}
callback() {
this.done = true;
this.loading = false;
this.callbacks.forEach((cb) => {
cb(this.onerrorEvent);
});
this.callbacks = [];
}
execute() {
if (window.google && window.google.maps && window.google.maps.version) {
console.warn("Aborted attempt to load Google Maps JS with @googlemaps/js-api-loader." +
"This may result in undesirable behavior as script parameters may not match.");
this.callback();
}
this.resetIfRetryingFailed();
if (this.done) {
this.callback();
}
else {
if (this.loading) ;
else {
this.loading = true;
this.setCallback();
this.setScript();
}
}
return `//maps.googleapis.com/maps/api/js?${parameters.join('&')}`;
}
}
Loader.CALLBACK_NAME = '_dk_google_maps_loader_cb';

@@ -87,3 +304,2 @@ const googleMapComponentCss = "#map.sc-ba-google-map{width:100%;background:#eee}";

async componentDidLoad() {
console.log('BA-GOOGLE-MAP: Hit componentDidLoad');
await this.initMap.call(this);

@@ -101,5 +317,5 @@ }

}
const marker = new this.google.maps.Marker(markerConfigOpts);
const marker = new google.maps.Marker(markerConfigOpts);
if (pin.contentString) {
const infoWin = new this.google.maps.InfoWindow({
const infoWin = new google.maps.InfoWindow({
content: pin.contentString,

@@ -124,9 +340,6 @@ });

if (!globalThis['googleMapsLoader']) {
globalThis['googleMapsLoader'] = new Loader(this.apiKey);
console.log('BA-GOOGLE-MAP: new Loader instance created!');
globalThis['googleMapsLoader'] = new Loader({ apiKey: this.apiKey });
}
console.log('globalThis: ', globalThis);
console.log('googleMapsLoader instance: ', globalThis['googleMapsLoader']);
try {
this.google = await globalThis['googleMapsLoader'].load();
await globalThis['googleMapsLoader'].load();
console.log('BA-GOOGLE-MAP: googleMapsLoader loaded!');

@@ -149,3 +362,3 @@ }

}
this.map = new this.google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.map = new google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.el.querySelector(`#map`).style.height = this.height;

@@ -152,0 +365,0 @@ this.mapPins && this.addMarkers.call(this);

2

dist/cjs/homebirdscomponents.cjs.js

@@ -18,3 +18,3 @@ 'use strict';

patchBrowser().then(options => {
return index.bootstrapLazy([["ba-google-map.cjs",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"google":[32],"map":[32],"markers":[32]}]]],["ba-search-input.cjs",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one.cjs",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
return index.bootstrapLazy([["ba-google-map.cjs",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"map":[32],"markers":[32]}]]],["ba-search-input.cjs",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one.cjs",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
});

@@ -17,3 +17,3 @@ 'use strict';

return patchEsm().then(() => {
return index.bootstrapLazy([["ba-google-map.cjs",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"google":[32],"map":[32],"markers":[32]}]]],["ba-search-input.cjs",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one.cjs",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
return index.bootstrapLazy([["ba-google-map.cjs",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"map":[32],"markers":[32]}]]],["ba-search-input.cjs",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one.cjs",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
});

@@ -20,0 +20,0 @@ };

import { Component, h, Prop, Host, Element, State, Watch, Event } from '@stencil/core';
import { Loader } from 'google-maps';
import { Loader } from '@googlemaps/js-api-loader';
export class GoogleMap {

@@ -16,3 +16,2 @@ constructor() {

async componentDidLoad() {
console.log('BA-GOOGLE-MAP: Hit componentDidLoad');
await this.initMap.call(this);

@@ -30,5 +29,5 @@ }

}
const marker = new this.google.maps.Marker(markerConfigOpts);
const marker = new google.maps.Marker(markerConfigOpts);
if (pin.contentString) {
const infoWin = new this.google.maps.InfoWindow({
const infoWin = new google.maps.InfoWindow({
content: pin.contentString,

@@ -53,9 +52,6 @@ });

if (!globalThis['googleMapsLoader']) {
globalThis['googleMapsLoader'] = new Loader(this.apiKey);
console.log('BA-GOOGLE-MAP: new Loader instance created!');
globalThis['googleMapsLoader'] = new Loader({ apiKey: this.apiKey });
}
console.log('globalThis: ', globalThis);
console.log('googleMapsLoader instance: ', globalThis['googleMapsLoader']);
try {
this.google = await globalThis['googleMapsLoader'].load();
await globalThis['googleMapsLoader'].load();
console.log('BA-GOOGLE-MAP: googleMapsLoader loaded!');

@@ -78,3 +74,3 @@ }

}
this.map = new this.google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.map = new google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.el.querySelector(`#map`).style.height = this.height;

@@ -224,3 +220,2 @@ this.mapPins && this.addMarkers.call(this);

static get states() { return {
"google": {},
"map": {},

@@ -227,0 +222,0 @@ "markers": {}

import { createEvent, h, Host, attachShadow, proxyCustomElement } from '@stencil/core/internal/client';
export { setAssetPath } from '@stencil/core/internal/client';
// do not edit .js files directly - edit src/index.jst
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) return false;
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
var key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const DEFAULT_ID = "__googleMapsScriptId";
/**
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
* dynamically using
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
* It works by dynamically creating and appending a script node to the the
* document head and wrapping the callback function so as to return a promise.
*
* ```
* const loader = new Loader({
* apiKey: "",
* version: "weekly",
* libraries: ["places"]
* });
*
* loader.load().then(() => {
* const map = new google.maps.Map(...)
* })
* ```
*/
class Loader {
constructor(apiKey = null, options = {}) {
/**
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
* using this library, instead the defaults are set by the Google Maps
* JavaScript API server.
*
* ```
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
* ```
*/
constructor({ apiKey, channel, client, id = DEFAULT_ID, libraries = [], language, region, version, mapIds, nonce, retries = 3, url = "https://maps.googleapis.com/maps/api/js", }) {
this.CALLBACK = "__googleMapsCallback";
this.callbacks = [];
this.done = false;
this.loading = false;
this.errors = [];
this.version = version;
this.apiKey = apiKey;
this.options = options;
if (typeof window === 'undefined') {
throw new Error('google-maps is supported only in browser environment');
this.channel = channel;
this.client = client;
this.id = id || DEFAULT_ID; // Do not allow empty string
this.libraries = libraries;
this.language = language;
this.region = region;
this.mapIds = mapIds;
this.nonce = nonce;
this.retries = retries;
this.url = url;
if (Loader.instance) {
if (!fastDeepEqual(this.options, Loader.instance.options)) {
throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(Loader.instance.options)}`);
}
return Loader.instance;
}
Loader.instance = this;
}
load() {
if (typeof this.api !== 'undefined') {
return Promise.resolve(this.api);
}
if (typeof this.loader !== 'undefined') {
return this.loader;
}
window[Loader.CALLBACK_NAME] = () => {
this.api = window['google'];
if (typeof this.resolve === 'undefined') {
throw new Error('Should not happen');
}
this.resolve(this.api);
get options() {
return {
version: this.version,
apiKey: this.apiKey,
channel: this.channel,
client: this.client,
id: this.id,
libraries: this.libraries,
language: this.language,
region: this.region,
mapIds: this.mapIds,
nonce: this.nonce,
url: this.url,
};
window['gm_authFailure'] = () => {
if (typeof this.reject === 'undefined') {
throw new Error('Should not happen');
}
this.reject(new Error('google-maps: authentication error'));
};
return this.loader = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
const script = document.createElement('script');
script.src = this.createUrl();
script.async = true;
script.onerror = (e) => reject(e);
document.head.appendChild(script);
});
}
/**
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
*
* @ignore
*/
createUrl() {
const parameters = [
`callback=${Loader.CALLBACK_NAME}`,
];
let url = this.url;
url += `?callback=${this.CALLBACK}`;
if (this.apiKey) {
parameters.push(`key=${this.apiKey}`);
url += `&key=${this.apiKey}`;
}
for (let name in this.options) {
if (this.options.hasOwnProperty(name)) {
let value = this.options[name];
if (name === 'version') {
name = 'v';
if (this.channel) {
url += `&channel=${this.channel}`;
}
if (this.client) {
url += `&client=${this.client}`;
}
if (this.libraries.length > 0) {
url += `&libraries=${this.libraries.join(",")}`;
}
if (this.language) {
url += `&language=${this.language}`;
}
if (this.region) {
url += `&region=${this.region}`;
}
if (this.version) {
url += `&v=${this.version}`;
}
if (this.mapIds) {
url += `&map_ids=${this.mapIds.join(",")}`;
}
return url;
}
/**
* Load the Google Maps JavaScript API script and return a Promise.
*/
load() {
return this.loadPromise();
}
/**
* Load the Google Maps JavaScript API script and return a Promise.
*
* @ignore
*/
loadPromise() {
return new Promise((resolve, reject) => {
this.loadCallback((err) => {
if (!err) {
resolve();
}
if (name === 'libraries') {
value = value.join(',');
else {
reject(err);
}
parameters.push(`${name}=${value}`);
});
});
}
/**
* Load the Google Maps JavaScript API script with a callback.
*/
loadCallback(fn) {
this.callbacks.push(fn);
this.execute();
}
/**
* Set the script on document.
*/
setScript() {
if (document.getElementById(this.id)) {
// TODO wrap onerror callback for cases where the script was loaded elsewhere
this.callback();
return;
}
const url = this.createUrl();
const script = document.createElement("script");
script.id = this.id;
script.type = "text/javascript";
script.src = url;
script.onerror = this.loadErrorCallback.bind(this);
script.defer = true;
script.async = true;
if (this.nonce) {
script.nonce = this.nonce;
}
document.head.appendChild(script);
}
deleteScript() {
const script = document.getElementById(this.id);
if (script) {
script.remove();
}
}
resetIfRetryingFailed() {
const possibleAttempts = this.retries + 1;
if (this.done && !this.loading && this.errors.length >= possibleAttempts) {
this.deleteScript();
this.done = false;
this.loading = false;
this.errors = [];
}
}
loadErrorCallback(e) {
this.errors.push(e);
if (this.errors.length <= this.retries) {
const delay = this.errors.length * Math.pow(2, this.errors.length);
console.log(`Failed to load Google Maps script, retrying in ${delay} ms.`);
setTimeout(() => {
this.deleteScript();
this.setScript();
}, delay);
}
else {
this.onerrorEvent = e;
this.callback();
}
}
setCallback() {
window.__googleMapsCallback = this.callback.bind(this);
}
callback() {
this.done = true;
this.loading = false;
this.callbacks.forEach((cb) => {
cb(this.onerrorEvent);
});
this.callbacks = [];
}
execute() {
if (window.google && window.google.maps && window.google.maps.version) {
console.warn("Aborted attempt to load Google Maps JS with @googlemaps/js-api-loader." +
"This may result in undesirable behavior as script parameters may not match.");
this.callback();
}
this.resetIfRetryingFailed();
if (this.done) {
this.callback();
}
else {
if (this.loading) ;
else {
this.loading = true;
this.setCallback();
this.setScript();
}
}
return `//maps.googleapis.com/maps/api/js?${parameters.join('&')}`;
}
}
Loader.CALLBACK_NAME = '_dk_google_maps_loader_cb';

@@ -84,3 +301,2 @@ const googleMapComponentCss = "#map.sc-ba-google-map{width:100%;background:#eee}";

async componentDidLoad() {
console.log('BA-GOOGLE-MAP: Hit componentDidLoad');
await this.initMap.call(this);

@@ -98,5 +314,5 @@ }

}
const marker = new this.google.maps.Marker(markerConfigOpts);
const marker = new google.maps.Marker(markerConfigOpts);
if (pin.contentString) {
const infoWin = new this.google.maps.InfoWindow({
const infoWin = new google.maps.InfoWindow({
content: pin.contentString,

@@ -121,9 +337,6 @@ });

if (!globalThis['googleMapsLoader']) {
globalThis['googleMapsLoader'] = new Loader(this.apiKey);
console.log('BA-GOOGLE-MAP: new Loader instance created!');
globalThis['googleMapsLoader'] = new Loader({ apiKey: this.apiKey });
}
console.log('globalThis: ', globalThis);
console.log('googleMapsLoader instance: ', globalThis['googleMapsLoader']);
try {
this.google = await globalThis['googleMapsLoader'].load();
await globalThis['googleMapsLoader'].load();
console.log('BA-GOOGLE-MAP: googleMapsLoader loaded!');

@@ -146,3 +359,3 @@ }

}
this.map = new this.google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.map = new google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.el.querySelector(`#map`).style.height = this.height;

@@ -2037,3 +2250,3 @@ this.mapPins && this.addMarkers.call(this);

const BaGoogleMap = /*@__PURE__*/proxyCustomElement(GoogleMap, [2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"google":[32],"map":[32],"markers":[32]}]);
const BaGoogleMap = /*@__PURE__*/proxyCustomElement(GoogleMap, [2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"map":[32],"markers":[32]}]);
const BaSearchInput = /*@__PURE__*/proxyCustomElement(HJBSearchInput2, [1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]);

@@ -2040,0 +2253,0 @@ const BaTextInputOne = /*@__PURE__*/proxyCustomElement(TextInputOne, [1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]);

import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-3fd7cee5.js';
// do not edit .js files directly - edit src/index.jst
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) return false;
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
var key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at.
*
* Http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const DEFAULT_ID = "__googleMapsScriptId";
/**
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
* dynamically using
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
* It works by dynamically creating and appending a script node to the the
* document head and wrapping the callback function so as to return a promise.
*
* ```
* const loader = new Loader({
* apiKey: "",
* version: "weekly",
* libraries: ["places"]
* });
*
* loader.load().then(() => {
* const map = new google.maps.Map(...)
* })
* ```
*/
class Loader {
constructor(apiKey = null, options = {}) {
/**
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
* using this library, instead the defaults are set by the Google Maps
* JavaScript API server.
*
* ```
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
* ```
*/
constructor({ apiKey, channel, client, id = DEFAULT_ID, libraries = [], language, region, version, mapIds, nonce, retries = 3, url = "https://maps.googleapis.com/maps/api/js", }) {
this.CALLBACK = "__googleMapsCallback";
this.callbacks = [];
this.done = false;
this.loading = false;
this.errors = [];
this.version = version;
this.apiKey = apiKey;
this.options = options;
if (typeof window === 'undefined') {
throw new Error('google-maps is supported only in browser environment');
this.channel = channel;
this.client = client;
this.id = id || DEFAULT_ID; // Do not allow empty string
this.libraries = libraries;
this.language = language;
this.region = region;
this.mapIds = mapIds;
this.nonce = nonce;
this.retries = retries;
this.url = url;
if (Loader.instance) {
if (!fastDeepEqual(this.options, Loader.instance.options)) {
throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(Loader.instance.options)}`);
}
return Loader.instance;
}
Loader.instance = this;
}
load() {
if (typeof this.api !== 'undefined') {
return Promise.resolve(this.api);
}
if (typeof this.loader !== 'undefined') {
return this.loader;
}
window[Loader.CALLBACK_NAME] = () => {
this.api = window['google'];
if (typeof this.resolve === 'undefined') {
throw new Error('Should not happen');
}
this.resolve(this.api);
get options() {
return {
version: this.version,
apiKey: this.apiKey,
channel: this.channel,
client: this.client,
id: this.id,
libraries: this.libraries,
language: this.language,
region: this.region,
mapIds: this.mapIds,
nonce: this.nonce,
url: this.url,
};
window['gm_authFailure'] = () => {
if (typeof this.reject === 'undefined') {
throw new Error('Should not happen');
}
this.reject(new Error('google-maps: authentication error'));
};
return this.loader = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
const script = document.createElement('script');
script.src = this.createUrl();
script.async = true;
script.onerror = (e) => reject(e);
document.head.appendChild(script);
});
}
/**
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
*
* @ignore
*/
createUrl() {
const parameters = [
`callback=${Loader.CALLBACK_NAME}`,
];
let url = this.url;
url += `?callback=${this.CALLBACK}`;
if (this.apiKey) {
parameters.push(`key=${this.apiKey}`);
url += `&key=${this.apiKey}`;
}
for (let name in this.options) {
if (this.options.hasOwnProperty(name)) {
let value = this.options[name];
if (name === 'version') {
name = 'v';
if (this.channel) {
url += `&channel=${this.channel}`;
}
if (this.client) {
url += `&client=${this.client}`;
}
if (this.libraries.length > 0) {
url += `&libraries=${this.libraries.join(",")}`;
}
if (this.language) {
url += `&language=${this.language}`;
}
if (this.region) {
url += `&region=${this.region}`;
}
if (this.version) {
url += `&v=${this.version}`;
}
if (this.mapIds) {
url += `&map_ids=${this.mapIds.join(",")}`;
}
return url;
}
/**
* Load the Google Maps JavaScript API script and return a Promise.
*/
load() {
return this.loadPromise();
}
/**
* Load the Google Maps JavaScript API script and return a Promise.
*
* @ignore
*/
loadPromise() {
return new Promise((resolve, reject) => {
this.loadCallback((err) => {
if (!err) {
resolve();
}
if (name === 'libraries') {
value = value.join(',');
else {
reject(err);
}
parameters.push(`${name}=${value}`);
});
});
}
/**
* Load the Google Maps JavaScript API script with a callback.
*/
loadCallback(fn) {
this.callbacks.push(fn);
this.execute();
}
/**
* Set the script on document.
*/
setScript() {
if (document.getElementById(this.id)) {
// TODO wrap onerror callback for cases where the script was loaded elsewhere
this.callback();
return;
}
const url = this.createUrl();
const script = document.createElement("script");
script.id = this.id;
script.type = "text/javascript";
script.src = url;
script.onerror = this.loadErrorCallback.bind(this);
script.defer = true;
script.async = true;
if (this.nonce) {
script.nonce = this.nonce;
}
document.head.appendChild(script);
}
deleteScript() {
const script = document.getElementById(this.id);
if (script) {
script.remove();
}
}
resetIfRetryingFailed() {
const possibleAttempts = this.retries + 1;
if (this.done && !this.loading && this.errors.length >= possibleAttempts) {
this.deleteScript();
this.done = false;
this.loading = false;
this.errors = [];
}
}
loadErrorCallback(e) {
this.errors.push(e);
if (this.errors.length <= this.retries) {
const delay = this.errors.length * Math.pow(2, this.errors.length);
console.log(`Failed to load Google Maps script, retrying in ${delay} ms.`);
setTimeout(() => {
this.deleteScript();
this.setScript();
}, delay);
}
else {
this.onerrorEvent = e;
this.callback();
}
}
setCallback() {
window.__googleMapsCallback = this.callback.bind(this);
}
callback() {
this.done = true;
this.loading = false;
this.callbacks.forEach((cb) => {
cb(this.onerrorEvent);
});
this.callbacks = [];
}
execute() {
if (window.google && window.google.maps && window.google.maps.version) {
console.warn("Aborted attempt to load Google Maps JS with @googlemaps/js-api-loader." +
"This may result in undesirable behavior as script parameters may not match.");
this.callback();
}
this.resetIfRetryingFailed();
if (this.done) {
this.callback();
}
else {
if (this.loading) ;
else {
this.loading = true;
this.setCallback();
this.setScript();
}
}
return `//maps.googleapis.com/maps/api/js?${parameters.join('&')}`;
}
}
Loader.CALLBACK_NAME = '_dk_google_maps_loader_cb';

@@ -82,3 +299,2 @@ const googleMapComponentCss = "#map.sc-ba-google-map{width:100%;background:#eee}";

async componentDidLoad() {
console.log('BA-GOOGLE-MAP: Hit componentDidLoad');
await this.initMap.call(this);

@@ -96,5 +312,5 @@ }

}
const marker = new this.google.maps.Marker(markerConfigOpts);
const marker = new google.maps.Marker(markerConfigOpts);
if (pin.contentString) {
const infoWin = new this.google.maps.InfoWindow({
const infoWin = new google.maps.InfoWindow({
content: pin.contentString,

@@ -119,9 +335,6 @@ });

if (!globalThis['googleMapsLoader']) {
globalThis['googleMapsLoader'] = new Loader(this.apiKey);
console.log('BA-GOOGLE-MAP: new Loader instance created!');
globalThis['googleMapsLoader'] = new Loader({ apiKey: this.apiKey });
}
console.log('globalThis: ', globalThis);
console.log('googleMapsLoader instance: ', globalThis['googleMapsLoader']);
try {
this.google = await globalThis['googleMapsLoader'].load();
await globalThis['googleMapsLoader'].load();
console.log('BA-GOOGLE-MAP: googleMapsLoader loaded!');

@@ -144,3 +357,3 @@ }

}
this.map = new this.google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.map = new google.maps.Map(this.el.querySelector('#map'), mapConfigOpts);
this.el.querySelector(`#map`).style.height = this.height;

@@ -147,0 +360,0 @@ this.mapPins && this.addMarkers.call(this);

@@ -16,3 +16,3 @@ import { p as promiseResolve, b as bootstrapLazy } from './index-3fd7cee5.js';

patchBrowser().then(options => {
return bootstrapLazy([["ba-google-map",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"google":[32],"map":[32],"markers":[32]}]]],["ba-search-input",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
return bootstrapLazy([["ba-google-map",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"map":[32],"markers":[32]}]]],["ba-search-input",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
});

@@ -13,3 +13,3 @@ import { p as promiseResolve, b as bootstrapLazy } from './index-3fd7cee5.js';

return patchEsm().then(() => {
return bootstrapLazy([["ba-google-map",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"google":[32],"map":[32],"markers":[32]}]]],["ba-search-input",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
return bootstrapLazy([["ba-google-map",[[2,"ba-google-map",{"apiKey":[1,"api-key"],"centerLat":[2,"map-center-lat"],"centerLon":[2,"map-center-lon"],"zoom":[2,"map-zoom"],"mapPins":[16],"height":[1,"map-height"],"disableControls":[4,"map-disable-controls"],"map":[32],"markers":[32]}]]],["ba-search-input",[[1,"ba-search-input",{"value":[1025],"suggestions":[16],"placeholder":[1],"maxResultsShown":[2,"max-results"],"searchTerms":[32],"fuse":[32],"results":[32],"suggestionsPaneOpen":[32]},[[0,"blur","handleElementBlur"]]]]],["ba-text-input-one",[[1,"ba-text-input-one",{"type":[513],"placeholder":[513],"value":[1537]}]]]], options);
});

@@ -16,0 +16,0 @@ };

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

import{p as e,b as a}from"./p-8c4bdf11.js";(()=>{const a=import.meta.url,s={};return""!==a&&(s.resourcesUrl=new URL(".",a).href),e(s)})().then(e=>a([["p-1e2b8975",[[2,"ba-google-map",{apiKey:[1,"api-key"],centerLat:[2,"map-center-lat"],centerLon:[2,"map-center-lon"],zoom:[2,"map-zoom"],mapPins:[16],height:[1,"map-height"],disableControls:[4,"map-disable-controls"],google:[32],map:[32],markers:[32]}]]],["p-36648ade",[[1,"ba-search-input",{value:[1025],suggestions:[16],placeholder:[1],maxResultsShown:[2,"max-results"],searchTerms:[32],fuse:[32],results:[32],suggestionsPaneOpen:[32]},[[0,"blur","handleElementBlur"]]]]],["p-9adcb50d",[[1,"ba-text-input-one",{type:[513],placeholder:[513],value:[1537]}]]]],e));
import{p as e,b as a}from"./p-8c4bdf11.js";(()=>{const a=import.meta.url,s={};return""!==a&&(s.resourcesUrl=new URL(".",a).href),e(s)})().then(e=>a([["p-aceedeb5",[[2,"ba-google-map",{apiKey:[1,"api-key"],centerLat:[2,"map-center-lat"],centerLon:[2,"map-center-lon"],zoom:[2,"map-zoom"],mapPins:[16],height:[1,"map-height"],disableControls:[4,"map-disable-controls"],map:[32],markers:[32]}]]],["p-36648ade",[[1,"ba-search-input",{value:[1025],suggestions:[16],placeholder:[1],maxResultsShown:[2,"max-results"],searchTerms:[32],fuse:[32],results:[32],suggestionsPaneOpen:[32]},[[0,"blur","handleElementBlur"]]]]],["p-9adcb50d",[[1,"ba-text-input-one",{type:[513],placeholder:[513],value:[1537]}]]]],e));

@@ -19,3 +19,2 @@ /// <reference types="googlemaps" />

disableControls: boolean;
google: any;
map: google.maps.Map;

@@ -22,0 +21,0 @@ markers: google.maps.Marker[];

{
"name": "homebirdscomponents",
"version": "0.0.23",
"version": "0.0.24",
"description": "Stencil Component Starter",

@@ -25,7 +25,7 @@ "main": "dist/index.cjs.js",

"dependencies": {
"@googlemaps/js-api-loader": "^1.11.1",
"@stencil/angular-output-target": "0.0.3",
"@stencil/core": "^2.0.3",
"fast-levenshtein": "^3.0.0",
"fuse.js": "^6.4.1",
"google-maps": "^4.3.2"
"fuse.js": "^6.4.1"
},

@@ -32,0 +32,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc