@m4l/gclick 0.34.0 → 0.34.1-beta-pkg-802-ajustes-mf-53.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.
- package/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/TileLayerGoogle.d.ts.map +1 -1
- package/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/TileLayerGoogle.js +62 -55
- package/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/googleMapsLoader.d.ts +5 -0
- package/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/googleMapsLoader.d.ts.map +1 -1
- package/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/googleMapsLoader.js +60 -27
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayerGoogle.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/TileLayerGoogle.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwClD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"TileLayerGoogle.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/TileLayerGoogle.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwClD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,QAgPrE"}
|
|
@@ -1,74 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useMap as
|
|
3
|
-
import { ensureGoogleMutantRegistered as
|
|
4
|
-
import
|
|
5
|
-
import { useMapStore as
|
|
6
|
-
import { deepShallow as
|
|
7
|
-
import { DARK_STYLES as
|
|
8
|
-
import { loadGoogleMapsLibrary as
|
|
9
|
-
import { createReservedTileLayer as
|
|
10
|
-
import { DEFAULT_TILE_RESERVE_FACTOR as
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const { sourceId: c, layer:
|
|
1
|
+
import t, { useEffect as S } from "react";
|
|
2
|
+
import { useMap as K } from "react-leaflet";
|
|
3
|
+
import { ensureGoogleMutantRegistered as V } from "../../../../external/googleMutant/index.js";
|
|
4
|
+
import _ from "leaflet";
|
|
5
|
+
import { useMapStore as Z } from "../../../../hooks/useMapStore/index.js";
|
|
6
|
+
import { deepShallow as k } from "@m4l/components";
|
|
7
|
+
import { DARK_STYLES as C } from "./darkStyles.js";
|
|
8
|
+
import { subscribeGoogleMapsFailure as D, loadGoogleMapsLibrary as j } from "./googleMapsLoader.js";
|
|
9
|
+
import { createReservedTileLayer as Y } from "../../../../external/tileReserve/ReservedTileLayer.js";
|
|
10
|
+
import { DEFAULT_TILE_RESERVE_FACTOR as J } from "../../../../external/tileReserve/constants.js";
|
|
11
|
+
const P = [], h = (M) => M === "dark" ? C : P;
|
|
12
|
+
function te(M) {
|
|
13
|
+
const s = K(), { mode: g, tileReserveFactor: p = J } = M, [I, U] = t.useState(!1), [w, v] = t.useState(!1), A = t.useRef(null), r = t.useRef(null), b = t.useRef(p);
|
|
14
|
+
b.current = p;
|
|
15
|
+
const G = t.useRef(null), L = t.useRef(h(g));
|
|
16
|
+
L.current = h(g);
|
|
17
|
+
const { sourceId: c, layer: o, trafficLayer: n, transitLayer: l, bicyclingLayer: i, googleApiKey: R, googleMapVersion: E } = Z(
|
|
18
18
|
(e) => {
|
|
19
|
-
const
|
|
19
|
+
const a = e.mapSources.find((y) => y.id === e.currentMapSourceLayer.mapSourceId) || e.mapSources[0], u = a.layers.find((y) => y.id === e.currentMapSourceLayer.mapSourceLayerId) || a.layers[0];
|
|
20
20
|
return {
|
|
21
|
-
sourceId:
|
|
22
|
-
layer:
|
|
23
|
-
trafficLayer:
|
|
24
|
-
transitLayer:
|
|
25
|
-
bicyclingLayer:
|
|
21
|
+
sourceId: a.id,
|
|
22
|
+
layer: u,
|
|
23
|
+
trafficLayer: u?.roadSelectedOptions?.trafficLayer || !1,
|
|
24
|
+
transitLayer: u?.roadSelectedOptions?.transitLayer || !1,
|
|
25
|
+
bicyclingLayer: u?.roadSelectedOptions?.bicyclingLayer || !1,
|
|
26
26
|
googleApiKey: e.googleMapsApiKey,
|
|
27
27
|
googleMapVersion: e.googleMapVersion
|
|
28
28
|
};
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
),
|
|
32
|
-
return f.current = { trafficLayer:
|
|
30
|
+
k
|
|
31
|
+
), d = (n || l || i || g === "dark") && !!R && !I, F = !d || g === "light" && !w, m = t.useRef({ trafficLayer: n, transitLayer: l, bicyclingLayer: i }), f = t.useRef({ trafficLayer: n, transitLayer: l, bicyclingLayer: i });
|
|
32
|
+
return f.current = { trafficLayer: n, transitLayer: l, bicyclingLayer: i }, S(() => {
|
|
33
33
|
let e;
|
|
34
34
|
if (c === "google")
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
),
|
|
40
|
-
e && (
|
|
35
|
+
return F && (e = Y(
|
|
36
|
+
o.urlTemplate,
|
|
37
|
+
o.options,
|
|
38
|
+
b.current
|
|
39
|
+
), o.getTileUrl && (e.getTileUrl = o.getTileUrl), s.addLayer(e), A.current = e, o.options && o.options.maxZoom && s.setMaxZoom(o.options.maxZoom)), () => {
|
|
40
|
+
e && (s.removeLayer(e), A.current = null);
|
|
41
41
|
};
|
|
42
|
-
}, [c,
|
|
43
|
-
if (c !== "google" || !
|
|
42
|
+
}, [c, o.urlTemplate, o.options, o.getTileUrl, s, F]), S(() => {
|
|
43
|
+
if (c !== "google" || !d || !R)
|
|
44
44
|
return;
|
|
45
|
-
let e = null,
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
let e = null, a = !1;
|
|
46
|
+
const u = () => {
|
|
47
|
+
e && (s.removeLayer(e), e = null, r.current = null), G.current = null;
|
|
48
|
+
}, y = (T) => {
|
|
49
|
+
a || (a = !0, u(), v(!1), U(!0), console.error("[GpsMap] Google Maps JavaScript API unavailable; using base tiles.", T));
|
|
50
|
+
}, x = D(y);
|
|
51
|
+
return V().then(() => j({
|
|
52
|
+
apiKey: R,
|
|
48
53
|
version: E
|
|
49
54
|
})).then(() => {
|
|
50
|
-
if (
|
|
55
|
+
if (a)
|
|
51
56
|
return;
|
|
52
|
-
const
|
|
53
|
-
typeof
|
|
57
|
+
const T = _.gridLayer.googleMutant, B = _.GridLayer.GoogleMutant;
|
|
58
|
+
if (typeof T != "function" || typeof B != "function")
|
|
59
|
+
throw new Error("GoogleMutant runtime registration is incomplete.");
|
|
60
|
+
e = T({
|
|
54
61
|
maxZoom: 22,
|
|
55
|
-
type:
|
|
56
|
-
styles:
|
|
62
|
+
type: o.type,
|
|
63
|
+
styles: L.current
|
|
57
64
|
// ...layer.options,
|
|
58
|
-
}), e.setTileReserveFactor(
|
|
59
|
-
|
|
60
|
-
}), r.current = e, f.current.trafficLayer && e.addGoogleLayer("TrafficLayer"), f.current.transitLayer && e.addGoogleLayer("TransitLayer"), f.current.bicyclingLayer && e.addGoogleLayer("BicyclingLayer"),
|
|
61
|
-
}), () => {
|
|
62
|
-
|
|
65
|
+
}), e.setTileReserveFactor(b.current), e.on("spawned", (O) => {
|
|
66
|
+
a || (G.current = O.mapObject, O.mapObject.setOptions({ styles: L.current }), v(!0));
|
|
67
|
+
}), r.current = e, f.current.trafficLayer && e.addGoogleLayer("TrafficLayer"), f.current.transitLayer && e.addGoogleLayer("TransitLayer"), f.current.bicyclingLayer && e.addGoogleLayer("BicyclingLayer"), m.current = { ...f.current }, s.addLayer(e);
|
|
68
|
+
}).catch(y), () => {
|
|
69
|
+
a = !0, x(), u(), v(!1);
|
|
63
70
|
};
|
|
64
|
-
}, [
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
c !== "google" || !
|
|
68
|
-
}, [c,
|
|
69
|
-
c === "google" && r.current && (
|
|
70
|
-
}, [
|
|
71
|
+
}, [s, o.type, c, R, E, d]), S(() => {
|
|
72
|
+
A.current?.setTileReserveFactor(p), r.current?.setTileReserveFactor(p);
|
|
73
|
+
}, [p]), S(() => {
|
|
74
|
+
c !== "google" || !d || !G.current || (G.current.setOptions({ styles: L.current }), r.current && (r.current.options.styles = L.current));
|
|
75
|
+
}, [c, d, g]), t.useEffect(() => {
|
|
76
|
+
c === "google" && r.current && (n !== m.current.trafficLayer && (n ? r.current.addGoogleLayer("TrafficLayer") : n === !1 && r.current.removeGoogleLayer("TrafficLayer")), l !== m.current.transitLayer && (l ? r.current.addGoogleLayer("TransitLayer") : l === !1 && r.current.removeGoogleLayer("TransitLayer")), i !== m.current.bicyclingLayer && (i ? r.current.addGoogleLayer("BicyclingLayer") : i === !1 && r.current.removeGoogleLayer("BicyclingLayer")), m.current = { ...f.current });
|
|
77
|
+
}, [n, l, i]), null;
|
|
71
78
|
}
|
|
72
79
|
export {
|
|
73
|
-
|
|
80
|
+
te as TileLayerGoogle
|
|
74
81
|
};
|
|
@@ -5,6 +5,9 @@ type GoogleMapsLoaderOptions = {
|
|
|
5
5
|
type GoogleMapsLoaderState = {
|
|
6
6
|
pendingPromise: Promise<void> | null;
|
|
7
7
|
pendingOptions: GoogleMapsLoaderOptions | null;
|
|
8
|
+
authenticationError?: Error;
|
|
9
|
+
failureListeners?: Set<(error: Error) => void>;
|
|
10
|
+
authenticationHandlerInstalled?: boolean;
|
|
8
11
|
};
|
|
9
12
|
declare const GCLICK_GOOGLE_MAPS_LOADER_STATE_PROPERTY: "__m4lGoogleMapsLoaderState__";
|
|
10
13
|
declare global {
|
|
@@ -12,6 +15,8 @@ declare global {
|
|
|
12
15
|
[GCLICK_GOOGLE_MAPS_LOADER_STATE_PROPERTY]?: GoogleMapsLoaderState;
|
|
13
16
|
}
|
|
14
17
|
}
|
|
18
|
+
/** Subscribe maps in every bundle to Google's documented page-wide authentication failure. */
|
|
19
|
+
export declare function subscribeGoogleMapsFailure(listener: (error: Error) => void): () => void;
|
|
15
20
|
/**
|
|
16
21
|
* Return whether the Google Maps JavaScript runtime is already available on the page.
|
|
17
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googleMapsLoader.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/googleMapsLoader.ts"],"names":[],"mappings":"AAEA,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"googleMapsLoader.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMap/subcomponents/TileLayers/subcomponents/TileLayerGoogle/googleMapsLoader.ts"],"names":[],"mappings":"AAEA,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC/C,mBAAmB,CAAC,EAAE,KAAK,CAAC;IAC5B,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;IAC/C,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C,CAAC;AAEF,QAAA,MAAM,wCAAwC,EAAG,8BAAuC,CAAC;AAEzF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,CAAC,wCAAwC,CAAC,CAAC,EACzC,qBAAqB,CAAC;KACzB;CACF;AAoED,8FAA8F;AAC9F,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,cAO1E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,YAQzC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,iBAsCrE"}
|
|
@@ -1,38 +1,71 @@
|
|
|
1
|
-
import { Loader as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { Loader as d } from "@googlemaps/js-api-loader";
|
|
2
|
+
const s = "__m4lGoogleMapsLoaderState__";
|
|
3
|
+
function l() {
|
|
4
4
|
return typeof window > "u" ? null : window;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function u(r, e) {
|
|
7
|
+
try {
|
|
8
|
+
r(e);
|
|
9
|
+
} catch (n) {
|
|
10
|
+
console.error("[GpsMap] Google Maps failure listener failed.", n);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function i() {
|
|
14
|
+
const r = l();
|
|
15
|
+
if (!r)
|
|
16
|
+
return null;
|
|
17
|
+
r[s] ??= {
|
|
9
18
|
pendingPromise: null,
|
|
10
19
|
pendingOptions: null
|
|
11
|
-
}
|
|
20
|
+
};
|
|
21
|
+
const e = r[s];
|
|
22
|
+
if (e.failureListeners ??= /* @__PURE__ */ new Set(), !e.authenticationHandlerInstalled) {
|
|
23
|
+
const n = r.gm_authFailure;
|
|
24
|
+
r.gm_authFailure = () => {
|
|
25
|
+
if (!e.authenticationError) {
|
|
26
|
+
const o = new Error(
|
|
27
|
+
"Google Maps authentication failed. Reload the page before retrying the JavaScript API."
|
|
28
|
+
);
|
|
29
|
+
e.authenticationError = o, e.failureListeners?.forEach((t) => u(t, o));
|
|
30
|
+
}
|
|
31
|
+
n?.call(r);
|
|
32
|
+
}, e.authenticationHandlerInstalled = !0;
|
|
33
|
+
}
|
|
34
|
+
return e;
|
|
12
35
|
}
|
|
13
|
-
function p() {
|
|
14
|
-
const e =
|
|
15
|
-
return e
|
|
36
|
+
function p(r) {
|
|
37
|
+
const e = i();
|
|
38
|
+
return e?.failureListeners?.add(r), e?.authenticationError && u(r, e.authenticationError), () => {
|
|
39
|
+
e?.failureListeners?.delete(r);
|
|
40
|
+
};
|
|
16
41
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
function c() {
|
|
43
|
+
const r = l();
|
|
44
|
+
return r ? !i()?.authenticationError && typeof r.google?.maps?.Map == "function" : !1;
|
|
45
|
+
}
|
|
46
|
+
function h(r) {
|
|
47
|
+
const e = i();
|
|
48
|
+
if (!e)
|
|
22
49
|
return Promise.reject(new Error("Google Maps can only load in a browser window."));
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
50
|
+
if (e.authenticationError)
|
|
51
|
+
return Promise.reject(e.authenticationError);
|
|
52
|
+
if (c())
|
|
53
|
+
return Promise.resolve();
|
|
54
|
+
if (e.pendingPromise)
|
|
55
|
+
return e.pendingPromise;
|
|
56
|
+
const n = e.pendingOptions ??= r;
|
|
57
|
+
let o;
|
|
58
|
+
return e.pendingPromise = new Promise((t, a) => {
|
|
59
|
+
o = p(a), new d({
|
|
60
|
+
apiKey: n.apiKey,
|
|
61
|
+
version: n.version
|
|
62
|
+
}).importLibrary("maps").then(() => t(), a);
|
|
31
63
|
}).catch((t) => {
|
|
32
|
-
throw
|
|
33
|
-
}),
|
|
64
|
+
throw e.pendingPromise = null, e.pendingOptions = null, t;
|
|
65
|
+
}).finally(() => o?.()), e.pendingPromise;
|
|
34
66
|
}
|
|
35
67
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
68
|
+
c as hasLoadedGoogleMapsRuntime,
|
|
69
|
+
h as loadGoogleMapsLibrary,
|
|
70
|
+
p as subscribeGoogleMapsFailure
|
|
38
71
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/gclick",
|
|
3
|
-
"version": "0.34.0",
|
|
3
|
+
"version": "0.34.1-beta-pkg-802-ajustes-mf-53.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@mui/material": "5.16.7",
|
|
60
60
|
"immer": "9.0.21",
|
|
61
61
|
"react-hook-form": "7.71.1",
|
|
62
|
-
"leaflet.markercluster": "1.5.3",
|
|
63
62
|
"@googlemaps/js-api-loader": "1.16.10",
|
|
63
|
+
"leaflet.markercluster": "1.5.3",
|
|
64
64
|
"yup": "0.32.11"
|
|
65
65
|
}
|
|
66
66
|
}
|