@nuxt/scripts 1.0.0-beta.3 → 1.0.0-beta.30
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/README.md +3 -3
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/{Ds2G8aQM.js → AwAKM0sG.js} +1 -1
- package/dist/client/_nuxt/Bl23o3st.js +162 -0
- package/dist/client/_nuxt/{DdVDSbUA.js → CYlYSSNW.js} +1 -1
- package/dist/client/_nuxt/{CD5B-xvT.js → D5FIkDae.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/f0b4dd20-8496-4003-b7a3-05cbae515923.json +1 -0
- package/dist/client/_nuxt/entry.C5SUNdim.css +1 -0
- package/dist/client/_nuxt/error-404.1K8v8Su2.css +1 -0
- package/dist/client/_nuxt/error-500.B9qvKpQm.css +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +7 -19
- package/dist/module.d.ts +164 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +935 -645
- package/dist/registry.d.ts +6 -0
- package/dist/registry.mjs +235 -69
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +16 -9
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +57 -30
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +16 -9
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +22 -39
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +69 -72
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +22 -39
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.d.vue.ts +5 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +25 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue.d.ts +5 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.d.vue.ts +43 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue.d.ts +43 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +22 -26
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +9 -5
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +62 -53
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +9 -5
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +26 -11
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +48 -45
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +26 -11
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +10 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +38 -37
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +10 -2
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +63 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +160 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +63 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +23 -32
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +24 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +24 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +25 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.d.ts +13 -0
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.js +8 -0
- package/dist/runtime/components/GoogleMaps/injectionKeys.d.ts +13 -0
- package/dist/runtime/components/GoogleMaps/injectionKeys.js +3 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +26 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +42 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.d.vue.ts +87 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue +85 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue.d.ts +87 -0
- package/dist/runtime/components/ScriptCrisp.vue +1 -1
- package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
- package/dist/runtime/components/ScriptGravatar.d.vue.ts +22 -0
- package/dist/runtime/components/ScriptGravatar.vue +46 -0
- package/dist/runtime/components/ScriptGravatar.vue.d.ts +22 -0
- package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptInstagramEmbed.vue +5 -2
- package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptIntercom.vue +4 -3
- package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +43 -32
- package/dist/runtime/components/ScriptPayPalButtons.vue +48 -79
- package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +43 -32
- package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +37 -23
- package/dist/runtime/components/ScriptPayPalMessages.vue +46 -50
- package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +37 -23
- package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
- package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +9 -0
- package/dist/runtime/components/ScriptVimeoPlayer.vue +13 -10
- package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +9 -0
- package/dist/runtime/components/ScriptXEmbed.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptXEmbed.vue +6 -3
- package/dist/runtime/components/ScriptXEmbed.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptYouTubePlayer.vue +11 -5
- package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +2 -2
- package/dist/runtime/composables/useScript.js +13 -6
- package/dist/runtime/composables/useScriptEventPage.js +2 -2
- package/dist/runtime/composables/useScriptTriggerConsent.d.ts +10 -0
- package/dist/runtime/composables/useScriptTriggerConsent.js +33 -20
- package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
- package/dist/runtime/registry/bing-uet.d.ts +20 -0
- package/dist/runtime/registry/bing-uet.js +29 -0
- package/dist/runtime/registry/bluesky-embed.d.ts +116 -0
- package/dist/runtime/registry/bluesky-embed.js +72 -0
- package/dist/runtime/registry/clarity.d.ts +10 -15
- package/dist/runtime/registry/clarity.js +22 -31
- package/dist/runtime/registry/cloudflare-web-analytics.d.ts +2 -13
- package/dist/runtime/registry/cloudflare-web-analytics.js +2 -14
- package/dist/runtime/registry/crisp.d.ts +10 -40
- package/dist/runtime/registry/crisp.js +2 -33
- package/dist/runtime/registry/databuddy-analytics.d.ts +2 -35
- package/dist/runtime/registry/databuddy-analytics.js +20 -45
- package/dist/runtime/registry/fathom-analytics.d.ts +7 -26
- package/dist/runtime/registry/fathom-analytics.js +2 -24
- package/dist/runtime/registry/google-adsense.d.ts +3 -11
- package/dist/runtime/registry/google-adsense.js +2 -11
- package/dist/runtime/registry/google-analytics.d.ts +3 -5
- package/dist/runtime/registry/google-analytics.js +3 -8
- package/dist/runtime/registry/google-maps.d.ts +3 -9
- package/dist/runtime/registry/google-maps.js +2 -8
- package/dist/runtime/registry/google-recaptcha.d.ts +2 -6
- package/dist/runtime/registry/google-recaptcha.js +4 -12
- package/dist/runtime/registry/google-sign-in.d.ts +2 -13
- package/dist/runtime/registry/google-sign-in.js +2 -22
- package/dist/runtime/registry/google-tag-manager.d.ts +3 -28
- package/dist/runtime/registry/google-tag-manager.js +4 -27
- package/dist/runtime/registry/gravatar.d.ts +26 -0
- package/dist/runtime/registry/gravatar.js +33 -0
- package/dist/runtime/registry/hotjar.d.ts +4 -6
- package/dist/runtime/registry/hotjar.js +2 -5
- package/dist/runtime/registry/instagram-embed.d.ts +3 -18
- package/dist/runtime/registry/instagram-embed.js +4 -19
- package/dist/runtime/registry/intercom.d.ts +4 -12
- package/dist/runtime/registry/intercom.js +2 -12
- package/dist/runtime/registry/matomo-analytics.d.ts +3 -12
- package/dist/runtime/registry/matomo-analytics.js +3 -12
- package/dist/runtime/registry/meta-pixel.d.ts +4 -6
- package/dist/runtime/registry/meta-pixel.js +2 -4
- package/dist/runtime/registry/mixpanel-analytics.d.ts +22 -0
- package/dist/runtime/registry/mixpanel-analytics.js +46 -0
- package/dist/runtime/registry/npm.d.ts +3 -7
- package/dist/runtime/registry/npm.js +2 -9
- package/dist/runtime/registry/paypal.d.ts +4 -25
- package/dist/runtime/registry/paypal.js +3 -66
- package/dist/runtime/registry/plausible-analytics.js +18 -13
- package/dist/runtime/registry/posthog.d.ts +10 -12
- package/dist/runtime/registry/posthog.js +7 -14
- package/dist/runtime/registry/reddit-pixel.d.ts +5 -6
- package/dist/runtime/registry/reddit-pixel.js +2 -4
- package/dist/runtime/registry/rybbit-analytics.d.ts +2 -14
- package/dist/runtime/registry/rybbit-analytics.js +10 -20
- package/dist/runtime/registry/schemas.d.ts +982 -0
- package/dist/runtime/registry/schemas.js +937 -0
- package/dist/runtime/registry/segment.d.ts +2 -5
- package/dist/runtime/registry/segment.js +2 -5
- package/dist/runtime/registry/snapchat-pixel.d.ts +4 -33
- package/dist/runtime/registry/snapchat-pixel.js +2 -20
- package/dist/runtime/registry/stripe.d.ts +3 -4
- package/dist/runtime/registry/stripe.js +2 -4
- package/dist/runtime/registry/tiktok-pixel.d.ts +4 -7
- package/dist/runtime/registry/tiktok-pixel.js +2 -6
- package/dist/runtime/registry/umami-analytics.d.ts +2 -31
- package/dist/runtime/registry/umami-analytics.js +2 -36
- package/dist/runtime/registry/vercel-analytics.d.ts +29 -0
- package/dist/runtime/registry/vercel-analytics.js +84 -0
- package/dist/runtime/registry/vimeo-player.d.ts +2 -2
- package/dist/runtime/registry/vimeo-player.js +1 -1
- package/dist/runtime/registry/x-embed.d.ts +3 -17
- package/dist/runtime/registry/x-embed.js +3 -18
- package/dist/runtime/registry/x-pixel.d.ts +4 -7
- package/dist/runtime/registry/x-pixel.js +2 -5
- package/dist/runtime/registry/youtube-player.d.ts +7 -7
- package/dist/runtime/registry/youtube-player.js +1 -1
- package/dist/runtime/server/{sw-handler.d.ts → bluesky-embed-image.d.ts} +1 -1
- package/dist/runtime/server/bluesky-embed-image.js +7 -0
- package/dist/runtime/server/bluesky-embed.d.ts +16 -0
- package/dist/runtime/server/bluesky-embed.js +59 -0
- package/dist/runtime/server/google-maps-geocode-proxy.d.ts +2 -0
- package/dist/runtime/server/google-maps-geocode-proxy.js +34 -0
- package/dist/runtime/server/google-static-maps-proxy.js +2 -13
- package/dist/runtime/server/gravatar-proxy.d.ts +2 -0
- package/dist/runtime/server/gravatar-proxy.js +46 -0
- package/dist/runtime/server/instagram-embed-asset.js +8 -41
- package/dist/runtime/server/instagram-embed-image.js +6 -53
- package/dist/runtime/server/instagram-embed.d.ts +16 -0
- package/dist/runtime/server/instagram-embed.js +173 -35
- package/dist/runtime/server/proxy-handler.js +134 -93
- package/dist/runtime/server/utils/image-proxy.d.ts +12 -0
- package/dist/runtime/server/utils/image-proxy.js +70 -0
- package/dist/runtime/server/utils/privacy.d.ts +1 -2
- package/dist/runtime/server/utils/privacy.js +54 -34
- package/dist/runtime/server/x-embed-image.js +5 -49
- package/dist/runtime/server/x-embed.js +3 -2
- package/dist/runtime/types.d.ts +74 -40
- package/dist/runtime/utils/pure.d.ts +1 -5
- package/dist/runtime/utils/pure.js +0 -67
- package/dist/runtime/utils.d.ts +4 -3
- package/dist/runtime/utils.js +24 -10
- package/dist/shared/scripts.ViOoYQXH.mjs +381 -0
- package/dist/stats.d.mts +202 -0
- package/dist/stats.d.ts +202 -0
- package/dist/stats.mjs +3868 -0
- package/dist/types-source.d.mts +17 -0
- package/dist/types-source.d.ts +17 -0
- package/dist/types-source.mjs +3600 -0
- package/package.json +52 -38
- package/dist/client/_nuxt/D-kOnTuH.js +0 -162
- package/dist/client/_nuxt/builds/meta/f1474569-6922-450d-bc3f-4fd5f3e1391a.json +0 -1
- package/dist/client/_nuxt/entry.D45OuV0w.css +0 -1
- package/dist/client/_nuxt/error-404.B57D-jUQ.css +0 -1
- package/dist/client/_nuxt/error-500.DTHUW7BI.css +0 -1
- package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +0 -52
- package/dist/runtime/components/ScriptPayPalMarks.vue +0 -69
- package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +0 -52
- package/dist/runtime/plugins/sw-register.client.d.ts +0 -2
- package/dist/runtime/plugins/sw-register.client.js +0 -12
- package/dist/runtime/server/sw-handler.js +0 -25
- package/dist/runtime/sw/proxy-sw.template.d.ts +0 -1
- package/dist/runtime/sw/proxy-sw.template.js +0 -54
|
@@ -1,43 +1,34 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
1
|
<script setup>
|
|
6
|
-
import { inject,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ADVANCED_MARKER_ELEMENT_INJECTION_KEY } from "./ScriptGoogleMapsAdvancedMarkerElement.vue";
|
|
2
|
+
import { inject, watch } from "vue";
|
|
3
|
+
import { ADVANCED_MARKER_ELEMENT_INJECTION_KEY } from "./injectionKeys";
|
|
4
|
+
import { useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
10
5
|
const props = defineProps({
|
|
11
6
|
options: { type: Object, required: false }
|
|
12
7
|
});
|
|
13
|
-
const mapContext = inject(MAP_INJECTION_KEY, void 0);
|
|
14
8
|
const advancedMarkerElementContext = inject(ADVANCED_MARKER_ELEMENT_INJECTION_KEY, void 0);
|
|
15
|
-
const pinElement =
|
|
16
|
-
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
pinElement.value = new mapContext.mapsApi.value.marker.PinElement(props.options);
|
|
9
|
+
const pinElement = useGoogleMapsResource({
|
|
10
|
+
ready: () => !!advancedMarkerElementContext?.advancedMarkerElement.value,
|
|
11
|
+
async create({ mapsApi }) {
|
|
12
|
+
await mapsApi.importLibrary("marker");
|
|
13
|
+
const pin = new mapsApi.marker.PinElement(props.options);
|
|
21
14
|
if (advancedMarkerElementContext?.advancedMarkerElement.value) {
|
|
22
|
-
advancedMarkerElementContext.advancedMarkerElement.value.content =
|
|
15
|
+
advancedMarkerElementContext.advancedMarkerElement.value.content = pin.element;
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
if (pinElement.value && options) {
|
|
26
|
-
Object.assign(pinElement.value, options);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
deep: true
|
|
30
|
-
});
|
|
17
|
+
return pin;
|
|
31
18
|
},
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
onUnmounted(() => {
|
|
38
|
-
if (advancedMarkerElementContext?.advancedMarkerElement.value && pinElement.value) {
|
|
39
|
-
advancedMarkerElementContext.advancedMarkerElement.value.content = null;
|
|
19
|
+
cleanup() {
|
|
20
|
+
if (advancedMarkerElementContext?.advancedMarkerElement.value) {
|
|
21
|
+
advancedMarkerElementContext.advancedMarkerElement.value.content = null;
|
|
22
|
+
}
|
|
40
23
|
}
|
|
41
|
-
pinElement.value = void 0;
|
|
42
24
|
});
|
|
25
|
+
watch(() => props.options, (options) => {
|
|
26
|
+
if (pinElement.value && options) {
|
|
27
|
+
Object.assign(pinElement.value, options);
|
|
28
|
+
}
|
|
29
|
+
}, { deep: true });
|
|
43
30
|
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
|
|
34
|
+
</template>
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the pin element that customizes the visual appearance of the marker.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#PinElementOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.marker.PinElementOptions, 'map'>;
|
|
3
7
|
};
|
|
4
8
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the polygon overlay.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/polygon#PolygonOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.PolygonOptions, 'map'>;
|
|
3
7
|
};
|
|
4
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
-
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
9
|
contextmenu: (payload: google.maps.PolyMouseEvent) => any;
|
|
10
|
+
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
7
11
|
dblclick: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
12
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
9
13
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
@@ -14,8 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
14
18
|
mouseover: (payload: google.maps.PolyMouseEvent) => any;
|
|
15
19
|
mouseup: (payload: google.maps.PolyMouseEvent) => any;
|
|
16
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
-
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
18
21
|
onContextmenu?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
22
|
+
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
19
23
|
onDblclick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
20
24
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
21
25
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
1
|
<script setup>
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { watch } from "vue";
|
|
3
|
+
import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
|
|
4
|
+
import { useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
9
5
|
const props = defineProps({
|
|
10
6
|
options: { type: Object, required: false }
|
|
11
7
|
});
|
|
8
|
+
const emit = defineEmits(["click", "contextmenu", "dblclick", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "drag", "dragend", "dragstart"]);
|
|
12
9
|
const eventsWithPolyMouseEventPayload = [
|
|
13
10
|
"click",
|
|
14
11
|
"contextmenu",
|
|
@@ -24,37 +21,26 @@ const eventsWithMapMouseEventPayload = [
|
|
|
24
21
|
"dragend",
|
|
25
22
|
"dragstart"
|
|
26
23
|
];
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, {
|
|
39
|
-
deep: true
|
|
40
|
-
});
|
|
41
|
-
}, {
|
|
42
|
-
immediate: true,
|
|
43
|
-
once: true
|
|
44
|
-
});
|
|
45
|
-
onUnmounted(() => {
|
|
46
|
-
if (!polygon || !mapContext?.mapsApi.value) {
|
|
47
|
-
return;
|
|
24
|
+
const polygon = useGoogleMapsResource({
|
|
25
|
+
create({ mapsApi, map }) {
|
|
26
|
+
const p = new mapsApi.Polygon({ map, ...props.options });
|
|
27
|
+
bindGoogleMapsEvents(p, emit, {
|
|
28
|
+
withPayload: [...eventsWithPolyMouseEventPayload, ...eventsWithMapMouseEventPayload]
|
|
29
|
+
});
|
|
30
|
+
return p;
|
|
31
|
+
},
|
|
32
|
+
cleanup(p, { mapsApi }) {
|
|
33
|
+
mapsApi.event.clearInstanceListeners(p);
|
|
34
|
+
p.setMap(null);
|
|
48
35
|
}
|
|
49
|
-
mapContext.mapsApi.value.event.clearInstanceListeners(polygon);
|
|
50
|
-
polygon.setMap(null);
|
|
51
36
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
polygon2.addListener(event, (payload) => emit(event, payload));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
37
|
+
watch(() => props.options, (options) => {
|
|
38
|
+
if (polygon.value && options) {
|
|
39
|
+
polygon.value.setOptions(options);
|
|
40
|
+
}
|
|
41
|
+
}, { deep: true });
|
|
60
42
|
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
|
|
46
|
+
</template>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the polygon overlay.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/polygon#PolygonOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.PolygonOptions, 'map'>;
|
|
3
7
|
};
|
|
4
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
-
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
9
|
contextmenu: (payload: google.maps.PolyMouseEvent) => any;
|
|
10
|
+
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
7
11
|
dblclick: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
12
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
9
13
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
@@ -14,8 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
14
18
|
mouseover: (payload: google.maps.PolyMouseEvent) => any;
|
|
15
19
|
mouseup: (payload: google.maps.PolyMouseEvent) => any;
|
|
16
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
-
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
18
21
|
onContextmenu?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
22
|
+
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
19
23
|
onDblclick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
20
24
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
21
25
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the polyline overlay.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/polygon#PolylineOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.PolylineOptions, 'map'>;
|
|
3
7
|
};
|
|
4
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
-
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
9
|
contextmenu: (payload: google.maps.PolyMouseEvent) => any;
|
|
10
|
+
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
7
11
|
dblclick: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
12
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
9
13
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
@@ -14,8 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
14
18
|
mouseover: (payload: google.maps.PolyMouseEvent) => any;
|
|
15
19
|
mouseup: (payload: google.maps.PolyMouseEvent) => any;
|
|
16
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
-
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
18
21
|
onContextmenu?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
22
|
+
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
19
23
|
onDblclick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
20
24
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
21
25
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
1
|
<script setup>
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { watch } from "vue";
|
|
3
|
+
import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
|
|
4
|
+
import { useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
9
5
|
const props = defineProps({
|
|
10
6
|
options: { type: Object, required: false }
|
|
11
7
|
});
|
|
8
|
+
const emit = defineEmits(["click", "contextmenu", "dblclick", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "drag", "dragend", "dragstart"]);
|
|
12
9
|
const eventsWithPolyMouseEventPayload = [
|
|
13
10
|
"click",
|
|
14
11
|
"contextmenu",
|
|
@@ -24,37 +21,26 @@ const eventsWithMapMouseEventPayload = [
|
|
|
24
21
|
"dragend",
|
|
25
22
|
"dragstart"
|
|
26
23
|
];
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, {
|
|
39
|
-
deep: true
|
|
40
|
-
});
|
|
41
|
-
}, {
|
|
42
|
-
immediate: true,
|
|
43
|
-
once: true
|
|
44
|
-
});
|
|
45
|
-
onUnmounted(() => {
|
|
46
|
-
if (!polyline || !mapContext?.mapsApi.value) {
|
|
47
|
-
return;
|
|
24
|
+
const polyline = useGoogleMapsResource({
|
|
25
|
+
create({ mapsApi, map }) {
|
|
26
|
+
const p = new mapsApi.Polyline({ map, ...props.options });
|
|
27
|
+
bindGoogleMapsEvents(p, emit, {
|
|
28
|
+
withPayload: [...eventsWithPolyMouseEventPayload, ...eventsWithMapMouseEventPayload]
|
|
29
|
+
});
|
|
30
|
+
return p;
|
|
31
|
+
},
|
|
32
|
+
cleanup(p, { mapsApi }) {
|
|
33
|
+
mapsApi.event.clearInstanceListeners(p);
|
|
34
|
+
p.setMap(null);
|
|
48
35
|
}
|
|
49
|
-
mapContext.mapsApi.value.event.clearInstanceListeners(polyline);
|
|
50
|
-
polyline.setMap(null);
|
|
51
36
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
polyline2.addListener(event, (payload) => emit(event, payload));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
37
|
+
watch(() => props.options, (options) => {
|
|
38
|
+
if (polyline.value && options) {
|
|
39
|
+
polyline.value.setOptions(options);
|
|
40
|
+
}
|
|
41
|
+
}, { deep: true });
|
|
60
42
|
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
|
|
46
|
+
</template>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the polyline overlay.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/polygon#PolylineOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.PolylineOptions, 'map'>;
|
|
3
7
|
};
|
|
4
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
-
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
9
|
contextmenu: (payload: google.maps.PolyMouseEvent) => any;
|
|
10
|
+
click: (payload: google.maps.PolyMouseEvent) => any;
|
|
7
11
|
dblclick: (payload: google.maps.PolyMouseEvent) => any;
|
|
8
12
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
9
13
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
@@ -14,8 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
14
18
|
mouseover: (payload: google.maps.PolyMouseEvent) => any;
|
|
15
19
|
mouseup: (payload: google.maps.PolyMouseEvent) => any;
|
|
16
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
-
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
18
21
|
onContextmenu?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
22
|
+
onClick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
19
23
|
onDblclick?: ((payload: google.maps.PolyMouseEvent) => any) | undefined;
|
|
20
24
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
21
25
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the rectangle overlay.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/polygon#RectangleOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.RectangleOptions, 'map'>;
|
|
3
7
|
};
|
|
4
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
-
click: (payload: google.maps.MapMouseEvent) => any;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
9
|
contextmenu: (payload: google.maps.MapMouseEvent) => any;
|
|
10
|
+
click: (payload: google.maps.MapMouseEvent) => any;
|
|
7
11
|
dblclick: (payload: google.maps.MapMouseEvent) => any;
|
|
8
12
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
9
13
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
@@ -15,8 +19,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
15
19
|
mouseup: (payload: google.maps.MapMouseEvent) => any;
|
|
16
20
|
bounds_changed: () => any;
|
|
17
21
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
-
onClick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
19
22
|
onContextmenu?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
23
|
+
onClick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
20
24
|
onDblclick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
21
25
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
22
26
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
1
|
<script setup>
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { watch } from "vue";
|
|
3
|
+
import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
|
|
4
|
+
import { useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
9
5
|
const props = defineProps({
|
|
10
6
|
options: { type: Object, required: false }
|
|
11
7
|
});
|
|
8
|
+
const emit = defineEmits(["bounds_changed", "click", "contextmenu", "dblclick", "drag", "dragend", "dragstart", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup"]);
|
|
12
9
|
const eventsWithoutPayload = [
|
|
13
10
|
"bounds_changed"
|
|
14
11
|
];
|
|
@@ -25,37 +22,27 @@ const eventsWithMapMouseEventPayload = [
|
|
|
25
22
|
"mouseover",
|
|
26
23
|
"mouseup"
|
|
27
24
|
];
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
deep: true
|
|
41
|
-
});
|
|
42
|
-
}, {
|
|
43
|
-
immediate: true,
|
|
44
|
-
once: true
|
|
45
|
-
});
|
|
46
|
-
onUnmounted(() => {
|
|
47
|
-
if (!rectangle || !mapContext?.mapsApi.value) {
|
|
48
|
-
return;
|
|
25
|
+
const rectangle = useGoogleMapsResource({
|
|
26
|
+
create({ mapsApi, map }) {
|
|
27
|
+
const r = new mapsApi.Rectangle({ map, ...props.options });
|
|
28
|
+
bindGoogleMapsEvents(r, emit, {
|
|
29
|
+
noPayload: eventsWithoutPayload,
|
|
30
|
+
withPayload: eventsWithMapMouseEventPayload
|
|
31
|
+
});
|
|
32
|
+
return r;
|
|
33
|
+
},
|
|
34
|
+
cleanup(r, { mapsApi }) {
|
|
35
|
+
mapsApi.event.clearInstanceListeners(r);
|
|
36
|
+
r.setMap(null);
|
|
49
37
|
}
|
|
50
|
-
mapContext.mapsApi.value.event.clearInstanceListeners(rectangle);
|
|
51
|
-
rectangle.setMap(null);
|
|
52
38
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
rectangle2.addListener(event, (payload) => emit(event, payload));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
39
|
+
watch(() => props.options, (options) => {
|
|
40
|
+
if (rectangle.value && options) {
|
|
41
|
+
rectangle.value.setOptions(options);
|
|
42
|
+
}
|
|
43
|
+
}, { deep: true });
|
|
61
44
|
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
|
|
48
|
+
</template>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the rectangle overlay.
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/polygon#RectangleOptions
|
|
5
|
+
*/
|
|
2
6
|
options?: Omit<google.maps.RectangleOptions, 'map'>;
|
|
3
7
|
};
|
|
4
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
-
click: (payload: google.maps.MapMouseEvent) => any;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
9
|
contextmenu: (payload: google.maps.MapMouseEvent) => any;
|
|
10
|
+
click: (payload: google.maps.MapMouseEvent) => any;
|
|
7
11
|
dblclick: (payload: google.maps.MapMouseEvent) => any;
|
|
8
12
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
9
13
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
@@ -15,8 +19,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
15
19
|
mouseup: (payload: google.maps.MapMouseEvent) => any;
|
|
16
20
|
bounds_changed: () => any;
|
|
17
21
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
-
onClick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
19
22
|
onContextmenu?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
23
|
+
onClick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
20
24
|
onDblclick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
21
25
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
22
26
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind Google Maps event listeners that forward to Vue emit.
|
|
3
|
+
*
|
|
4
|
+
* Two categories:
|
|
5
|
+
* - `noPayload`: emits with no arguments (state-change events like `position_changed`)
|
|
6
|
+
* - `withPayload`: forwards the first argument from the listener (mouse events, etc.)
|
|
7
|
+
*/
|
|
8
|
+
export declare function bindGoogleMapsEvents(instance: {
|
|
9
|
+
addListener: (event: string, handler: (...args: any[]) => void) => void;
|
|
10
|
+
}, emit: (...args: any[]) => void, config: {
|
|
11
|
+
noPayload?: readonly string[];
|
|
12
|
+
withPayload?: readonly string[];
|
|
13
|
+
}): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function bindGoogleMapsEvents(instance, emit, config) {
|
|
2
|
+
config.noPayload?.forEach((event) => {
|
|
3
|
+
instance.addListener(event, () => emit(event));
|
|
4
|
+
});
|
|
5
|
+
config.withPayload?.forEach((event) => {
|
|
6
|
+
instance.addListener(event, (payload) => emit(event, payload));
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InjectionKey, Ref, ShallowRef } from 'vue';
|
|
2
|
+
export declare const MAP_INJECTION_KEY: InjectionKey<{
|
|
3
|
+
map: ShallowRef<google.maps.Map | undefined>;
|
|
4
|
+
mapsApi: Ref<typeof google.maps | undefined>;
|
|
5
|
+
/** Close the previously active InfoWindow and register a new one as active */
|
|
6
|
+
activateInfoWindow: (iw: google.maps.InfoWindow) => void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const ADVANCED_MARKER_ELEMENT_INJECTION_KEY: InjectionKey<{
|
|
9
|
+
advancedMarkerElement: ShallowRef<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const MARKER_INJECTION_KEY: InjectionKey<{
|
|
12
|
+
marker: ShallowRef<google.maps.Marker | undefined>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ShallowRef } from 'vue';
|
|
2
|
+
export interface GoogleMapsResourceContext {
|
|
3
|
+
map: google.maps.Map;
|
|
4
|
+
mapsApi: typeof google.maps;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Composable for safely managing Google Maps resource lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* Handles the common pattern: wait for map readiness → async create → cleanup on unmount.
|
|
10
|
+
*
|
|
11
|
+
* Safety guarantees:
|
|
12
|
+
* - No watchers created after `await` (prevents orphaned watchers that leak memory)
|
|
13
|
+
* - Unmount guard prevents resource creation after component unmount
|
|
14
|
+
* - Resources created during the async gap are immediately cleaned up
|
|
15
|
+
* - Resource ref is always nulled on unmount to allow GC
|
|
16
|
+
*/
|
|
17
|
+
export declare function useGoogleMapsResource<T>({ ready, create, cleanup, }: {
|
|
18
|
+
/** Additional readiness condition beyond map + mapsApi being available */
|
|
19
|
+
ready?: () => boolean;
|
|
20
|
+
/** Create the Google Maps resource. Receives map context snapshot. May be async. */
|
|
21
|
+
create: (ctx: GoogleMapsResourceContext) => Promise<T> | T;
|
|
22
|
+
/** Clean up the resource. Called on unmount, or immediately if resource was created after unmount. */
|
|
23
|
+
cleanup?: (resource: T, ctx: {
|
|
24
|
+
mapsApi: typeof google.maps;
|
|
25
|
+
}) => void;
|
|
26
|
+
}): ShallowRef<T | undefined>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { whenever } from "@vueuse/core";
|
|
2
|
+
import { inject, onUnmounted, ref, shallowRef } from "vue";
|
|
3
|
+
import { MAP_INJECTION_KEY } from "./injectionKeys.js";
|
|
4
|
+
export function useGoogleMapsResource({
|
|
5
|
+
ready,
|
|
6
|
+
create,
|
|
7
|
+
cleanup
|
|
8
|
+
}) {
|
|
9
|
+
const mapContext = inject(MAP_INJECTION_KEY, void 0);
|
|
10
|
+
const resource = shallowRef(void 0);
|
|
11
|
+
const isUnmounted = ref(false);
|
|
12
|
+
whenever(
|
|
13
|
+
() => mapContext?.map.value && mapContext.mapsApi.value && (!ready || ready()),
|
|
14
|
+
() => {
|
|
15
|
+
Promise.resolve(create({
|
|
16
|
+
map: mapContext.map.value,
|
|
17
|
+
mapsApi: mapContext.mapsApi.value
|
|
18
|
+
})).then((result) => {
|
|
19
|
+
if (isUnmounted.value) {
|
|
20
|
+
if (cleanup && mapContext?.mapsApi.value) {
|
|
21
|
+
cleanup(result, { mapsApi: mapContext.mapsApi.value });
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
resource.value = result;
|
|
26
|
+
}).catch((err) => {
|
|
27
|
+
if (import.meta.dev) {
|
|
28
|
+
console.error("[nuxt-scripts] Google Maps resource creation failed:", err);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
{ immediate: true, once: true }
|
|
33
|
+
);
|
|
34
|
+
onUnmounted(() => {
|
|
35
|
+
isUnmounted.value = true;
|
|
36
|
+
if (resource.value && cleanup && mapContext?.mapsApi.value) {
|
|
37
|
+
cleanup(resource.value, { mapsApi: mapContext.mapsApi.value });
|
|
38
|
+
}
|
|
39
|
+
resource.value = void 0;
|
|
40
|
+
});
|
|
41
|
+
return resource;
|
|
42
|
+
}
|