@nuxt/scripts 1.0.0-rc.4 → 1.0.0-rc.6
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/dist/devtools-client/200.html +1 -1
- package/dist/devtools-client/404.html +1 -1
- package/dist/devtools-client/_nuxt/{DKL6PHO3.js → B7jHEBMT.js} +1 -1
- package/dist/devtools-client/_nuxt/{B3kN3DAy.js → BaiqmiV1.js} +1 -1
- package/dist/devtools-client/_nuxt/{CfOsp0mU.js → BjmZlwuw.js} +1 -1
- package/dist/devtools-client/_nuxt/{ajngqPCs.js → CLjOeO0G.js} +1 -1
- package/dist/devtools-client/_nuxt/{dlaR8P-P.js → Chi3DhDl.js} +1 -1
- package/dist/devtools-client/_nuxt/HLYrIHDq.js +188 -0
- package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
- package/dist/devtools-client/_nuxt/builds/meta/640f0a39-e659-4a31-8b8d-adbd9af52f1e.json +1 -0
- package/dist/devtools-client/_nuxt/error-404.Dwj0Wlzm.css +1 -0
- package/dist/devtools-client/_nuxt/error-500.B4wHUYBa.css +1 -0
- package/dist/devtools-client/_nuxt/{C8jhSQ8l.js → qfgRjj7S.js} +1 -1
- package/dist/devtools-client/docs/index.html +1 -1
- package/dist/devtools-client/first-party/index.html +1 -1
- package/dist/devtools-client/index.html +1 -1
- package/dist/devtools-client/registry/index.html +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +23 -8
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +73 -93
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +65 -57
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +73 -93
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +49 -28
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +143 -103
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +49 -28
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +50 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +76 -1
- package/dist/types-source.mjs +2 -198
- package/package.json +5 -5
- package/dist/devtools-client/_nuxt/CJD6wrkT.js +0 -188
- package/dist/devtools-client/_nuxt/builds/meta/65cf7087-ee3d-4fb9-8658-92e02491d502.json +0 -1
- package/dist/devtools-client/_nuxt/error-404.CvOVjXeC.css +0 -1
- package/dist/devtools-client/_nuxt/error-500.BIm53nmx.css +0 -1
|
@@ -1,35 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<script setup>
|
|
2
|
-
import { computed, inject,
|
|
6
|
+
import { computed, inject, shallowRef, useTemplateRef, watch } from "vue";
|
|
3
7
|
import { MARKER_CLUSTERER_INJECTION_KEY } from "./types";
|
|
4
|
-
import { MARKER_INJECTION_KEY, useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
8
|
+
import { defineDeprecatedAlias, MARKER_INJECTION_KEY, normalizeLatLng, useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
5
9
|
defineOptions({
|
|
6
10
|
inheritAttrs: false
|
|
7
11
|
});
|
|
8
|
-
const
|
|
12
|
+
const {
|
|
13
|
+
position,
|
|
14
|
+
defaultOpen = true,
|
|
15
|
+
anchor = "bottom-center",
|
|
16
|
+
offset,
|
|
17
|
+
pane = "floatPane",
|
|
18
|
+
zIndex,
|
|
19
|
+
blockMapInteraction = true,
|
|
20
|
+
panOnOpen = true,
|
|
21
|
+
hideWhenClustered = true
|
|
22
|
+
} = defineProps({
|
|
9
23
|
position: { type: null, required: false },
|
|
10
|
-
|
|
24
|
+
defaultOpen: { type: Boolean, required: false },
|
|
25
|
+
anchor: { type: String, required: false },
|
|
11
26
|
offset: { type: Object, required: false },
|
|
12
|
-
pane: { type: String, required: false
|
|
27
|
+
pane: { type: String, required: false },
|
|
13
28
|
zIndex: { type: Number, required: false },
|
|
14
|
-
blockMapInteraction: { type: Boolean, required: false
|
|
15
|
-
panOnOpen: { type: [Boolean, Number], required: false
|
|
16
|
-
hideWhenClustered: { type: Boolean, required: false
|
|
29
|
+
blockMapInteraction: { type: Boolean, required: false },
|
|
30
|
+
panOnOpen: { type: [Boolean, Number], required: false },
|
|
31
|
+
hideWhenClustered: { type: Boolean, required: false }
|
|
17
32
|
});
|
|
18
33
|
defineSlots();
|
|
19
34
|
const open = defineModel("open", { type: Boolean, ...{ default: void 0 } });
|
|
35
|
+
if (open.value === void 0)
|
|
36
|
+
open.value = defaultOpen ?? true;
|
|
20
37
|
const markerContext = inject(MARKER_INJECTION_KEY, void 0);
|
|
21
38
|
const markerClustererContext = inject(MARKER_CLUSTERER_INJECTION_KEY, void 0);
|
|
22
39
|
function getResolvedPosition() {
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if ("lat" in pos && typeof pos.lat === "function")
|
|
29
|
-
return { lat: pos.lat(), lng: pos.lng() };
|
|
30
|
-
return pos;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
40
|
+
if (position)
|
|
41
|
+
return normalizeLatLng(position);
|
|
42
|
+
const markerPosition = markerContext?.advancedMarkerElement.value?.position;
|
|
43
|
+
if (markerPosition)
|
|
44
|
+
return normalizeLatLng(markerPosition);
|
|
33
45
|
return void 0;
|
|
34
46
|
}
|
|
35
47
|
const ANCHOR_TRANSFORMS = {
|
|
@@ -43,21 +55,32 @@ const ANCHOR_TRANSFORMS = {
|
|
|
43
55
|
"left-center": "translate(0, -50%)",
|
|
44
56
|
"right-center": "translate(-100%, -50%)"
|
|
45
57
|
};
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const dataState = computed(
|
|
58
|
+
const overlayAnchor = useTemplateRef("overlay-anchor");
|
|
59
|
+
const overlayPosition = shallowRef(void 0);
|
|
60
|
+
const dataState = computed(
|
|
61
|
+
() => open.value !== false && overlayPosition.value !== void 0 ? "open" : "closed"
|
|
62
|
+
);
|
|
63
|
+
const overlayStyle = computed(() => {
|
|
64
|
+
const visible = open.value !== false && overlayPosition.value !== void 0;
|
|
65
|
+
if (!visible) {
|
|
66
|
+
return {
|
|
67
|
+
position: "absolute",
|
|
68
|
+
visibility: "hidden",
|
|
69
|
+
pointerEvents: "none"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const { x, y } = overlayPosition.value;
|
|
73
|
+
return {
|
|
74
|
+
position: "absolute",
|
|
75
|
+
left: `${x + (offset?.x ?? 0)}px`,
|
|
76
|
+
top: `${y + (offset?.y ?? 0)}px`,
|
|
77
|
+
transform: ANCHOR_TRANSFORMS[anchor],
|
|
78
|
+
zIndex: zIndex !== void 0 ? String(zIndex) : void 0,
|
|
79
|
+
visibility: "visible",
|
|
80
|
+
pointerEvents: "auto"
|
|
81
|
+
};
|
|
82
|
+
});
|
|
49
83
|
const listeners = [];
|
|
50
|
-
function setDataState(el, state) {
|
|
51
|
-
el.dataset.state = state;
|
|
52
|
-
const child = el.firstElementChild;
|
|
53
|
-
if (child)
|
|
54
|
-
child.dataset.state = state;
|
|
55
|
-
}
|
|
56
|
-
function hideElement(el) {
|
|
57
|
-
el.style.visibility = "hidden";
|
|
58
|
-
el.style.pointerEvents = "none";
|
|
59
|
-
setDataState(el, "closed");
|
|
60
|
-
}
|
|
61
84
|
function panMapToFitOverlay(el, map, padding) {
|
|
62
85
|
const child = el.firstElementChild;
|
|
63
86
|
if (!child)
|
|
@@ -77,69 +100,59 @@ function panMapToFitOverlay(el, map, padding) {
|
|
|
77
100
|
if (panX !== 0 || panY !== 0)
|
|
78
101
|
map.panBy(panX, panY);
|
|
79
102
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
panes[props.pane].appendChild(el);
|
|
90
|
-
if (props.blockMapInteraction)
|
|
91
|
-
mapsApi.OverlayView.preventMapHitsAndGesturesFrom(el);
|
|
92
|
-
}
|
|
93
|
-
if (props.panOnOpen) {
|
|
94
|
-
const padding = typeof props.panOnOpen === "number" ? props.panOnOpen : 40;
|
|
95
|
-
requestAnimationFrame(() => {
|
|
96
|
-
panMapToFitOverlay(el, map, padding);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
103
|
+
function makeOverlayClass(mapsApi, map) {
|
|
104
|
+
return class CustomOverlay extends mapsApi.OverlayView {
|
|
105
|
+
onAdd() {
|
|
106
|
+
const panes = this.getPanes();
|
|
107
|
+
const el = overlayAnchor.value;
|
|
108
|
+
if (panes && el) {
|
|
109
|
+
panes[pane].appendChild(el);
|
|
110
|
+
if (blockMapInteraction)
|
|
111
|
+
mapsApi.OverlayView.preventMapHitsAndGesturesFrom(el);
|
|
99
112
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
const position = getResolvedPosition();
|
|
107
|
-
if (!position) {
|
|
108
|
-
isPositioned.value = false;
|
|
109
|
-
hideElement(el);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const projection = this.getProjection();
|
|
113
|
-
if (!projection) {
|
|
114
|
-
isPositioned.value = false;
|
|
115
|
-
hideElement(el);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const pos = projection.fromLatLngToDivPixel(
|
|
119
|
-
new mapsApi.LatLng(position.lat, position.lng)
|
|
120
|
-
);
|
|
121
|
-
if (!pos) {
|
|
122
|
-
isPositioned.value = false;
|
|
123
|
-
hideElement(el);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
el.style.position = "absolute";
|
|
127
|
-
el.style.left = `${pos.x + (props.offset?.x ?? 0)}px`;
|
|
128
|
-
el.style.top = `${pos.y + (props.offset?.y ?? 0)}px`;
|
|
129
|
-
el.style.transform = ANCHOR_TRANSFORMS[props.anchor];
|
|
130
|
-
if (props.zIndex !== void 0)
|
|
131
|
-
el.style.zIndex = String(props.zIndex);
|
|
132
|
-
el.style.visibility = "visible";
|
|
133
|
-
el.style.pointerEvents = "auto";
|
|
134
|
-
setDataState(el, "open");
|
|
135
|
-
isPositioned.value = true;
|
|
113
|
+
if (panOnOpen && open.value !== false) {
|
|
114
|
+
const padding = typeof panOnOpen === "number" ? panOnOpen : 40;
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
if (open.value !== false && overlayAnchor.value && overlayPosition.value)
|
|
117
|
+
panMapToFitOverlay(overlayAnchor.value, map, padding);
|
|
118
|
+
});
|
|
136
119
|
}
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
}
|
|
121
|
+
draw() {
|
|
122
|
+
if (open.value === false) {
|
|
123
|
+
overlayPosition.value = void 0;
|
|
124
|
+
return;
|
|
139
125
|
}
|
|
126
|
+
const resolvedPosition = getResolvedPosition();
|
|
127
|
+
if (!resolvedPosition) {
|
|
128
|
+
overlayPosition.value = void 0;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const projection = this.getProjection();
|
|
132
|
+
if (!projection) {
|
|
133
|
+
overlayPosition.value = void 0;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const pos = projection.fromLatLngToDivPixel(
|
|
137
|
+
new mapsApi.LatLng(resolvedPosition.lat, resolvedPosition.lng)
|
|
138
|
+
);
|
|
139
|
+
if (!pos) {
|
|
140
|
+
overlayPosition.value = void 0;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
overlayPosition.value = { x: pos.x, y: pos.y };
|
|
140
144
|
}
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
onRemove() {
|
|
146
|
+
const el = overlayAnchor.value;
|
|
147
|
+
el?.parentNode?.removeChild(el);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const overlay = useGoogleMapsResource({
|
|
152
|
+
// ready condition accesses .value on ShallowRefs — tracked by whenever() in useGoogleMapsResource
|
|
153
|
+
ready: () => !!overlayAnchor.value && !!(position || markerContext?.advancedMarkerElement.value),
|
|
154
|
+
create({ mapsApi, map }) {
|
|
155
|
+
const CustomOverlay = makeOverlayClass(mapsApi, map);
|
|
143
156
|
const ov = new CustomOverlay();
|
|
144
157
|
ov.setMap(map);
|
|
145
158
|
if (markerContext?.advancedMarkerElement.value) {
|
|
@@ -160,12 +173,8 @@ const overlay = useGoogleMapsResource({
|
|
|
160
173
|
if (markerContext) {
|
|
161
174
|
watch(
|
|
162
175
|
() => {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
return void 0;
|
|
166
|
-
if ("lat" in pos && typeof pos.lat === "function")
|
|
167
|
-
return { lat: pos.lat(), lng: pos.lng() };
|
|
168
|
-
return pos;
|
|
176
|
+
const markerPosition = markerContext.advancedMarkerElement.value?.position;
|
|
177
|
+
return markerPosition ? normalizeLatLng(markerPosition) : void 0;
|
|
169
178
|
},
|
|
170
179
|
() => {
|
|
171
180
|
overlay.value?.draw();
|
|
@@ -173,7 +182,10 @@ if (markerContext) {
|
|
|
173
182
|
);
|
|
174
183
|
}
|
|
175
184
|
watch(
|
|
176
|
-
() =>
|
|
185
|
+
() => {
|
|
186
|
+
const p = position ? normalizeLatLng(position) : void 0;
|
|
187
|
+
return [p?.lat, p?.lng, offset?.x, offset?.y, zIndex, anchor];
|
|
188
|
+
},
|
|
177
189
|
() => {
|
|
178
190
|
overlay.value?.draw();
|
|
179
191
|
}
|
|
@@ -183,7 +195,7 @@ watch(() => open.value, () => {
|
|
|
183
195
|
return;
|
|
184
196
|
overlay.value.draw();
|
|
185
197
|
});
|
|
186
|
-
watch([() =>
|
|
198
|
+
watch([() => pane, () => blockMapInteraction], () => {
|
|
187
199
|
if (overlay.value) {
|
|
188
200
|
const map = overlay.value.getMap();
|
|
189
201
|
overlay.value.setMap(null);
|
|
@@ -195,7 +207,7 @@ if (markerClustererContext && markerContext) {
|
|
|
195
207
|
watch(
|
|
196
208
|
() => markerClustererContext.clusteringVersion.value,
|
|
197
209
|
() => {
|
|
198
|
-
if (!
|
|
210
|
+
if (!hideWhenClustered || open.value === false)
|
|
199
211
|
return;
|
|
200
212
|
const clusterer = markerClustererContext.markerClusterer.value;
|
|
201
213
|
if (!clusterer?.clusters)
|
|
@@ -211,13 +223,41 @@ if (markerClustererContext && markerContext) {
|
|
|
211
223
|
}
|
|
212
224
|
);
|
|
213
225
|
}
|
|
214
|
-
|
|
226
|
+
const exposed = {
|
|
227
|
+
overlayView: overlay,
|
|
228
|
+
// Plain alias for production. In dev, replaced below with a getter that
|
|
229
|
+
// emits a one-shot deprecation warning. Both forms return the same
|
|
230
|
+
// shallow ref as `overlayView`.
|
|
231
|
+
overlay,
|
|
232
|
+
dataState
|
|
233
|
+
};
|
|
234
|
+
if (import.meta.dev) {
|
|
235
|
+
defineDeprecatedAlias(
|
|
236
|
+
exposed,
|
|
237
|
+
"overlay",
|
|
238
|
+
"overlayView",
|
|
239
|
+
'[nuxt-scripts] <ScriptGoogleMapsOverlayView> expose key "overlay" is deprecated; use "overlayView" instead. See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1'
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
defineExpose(exposed);
|
|
215
243
|
</script>
|
|
216
244
|
|
|
217
245
|
<template>
|
|
218
246
|
<div style="display: none;">
|
|
219
|
-
|
|
220
|
-
|
|
247
|
+
<!--
|
|
248
|
+
Two-element structure:
|
|
249
|
+
- `overlay-anchor` is moved into a Google Maps pane on `onAdd()`. Its
|
|
250
|
+
inline style is reactively bound to `overlayStyle`, so position
|
|
251
|
+
updates from `draw()` flow through Vue's patcher even after the node
|
|
252
|
+
has been reparented out of the component tree.
|
|
253
|
+
- `overlay-content` carries `data-state`, attribute-based animations,
|
|
254
|
+
and forwards parent attrs (e.g. `class`) so consumers can target it
|
|
255
|
+
directly with `[data-state]` selectors.
|
|
256
|
+
-->
|
|
257
|
+
<div ref="overlay-anchor" :style="overlayStyle">
|
|
258
|
+
<div :data-state="dataState" v-bind="$attrs">
|
|
259
|
+
<slot />
|
|
260
|
+
</div>
|
|
221
261
|
</div>
|
|
222
262
|
</div>
|
|
223
263
|
</template>
|
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
type
|
|
2
|
-
type
|
|
3
|
-
type
|
|
1
|
+
import type { ShallowRef } from 'vue';
|
|
2
|
+
export type ScriptGoogleMapsOverlayAnchor = 'center' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left-center' | 'right-center';
|
|
3
|
+
export type ScriptGoogleMapsOverlayPane = 'mapPane' | 'overlayLayer' | 'markerLayer' | 'overlayMouseTarget' | 'floatPane';
|
|
4
|
+
export interface ScriptGoogleMapsOverlayViewProps {
|
|
4
5
|
/**
|
|
5
6
|
* Geographic position for the overlay. Falls back to parent marker position if omitted.
|
|
7
|
+
*
|
|
8
|
+
* Accepts either a plain `LatLngLiteral` (`{ lat, lng }`) or a
|
|
9
|
+
* `google.maps.LatLng` instance.
|
|
6
10
|
* @see https://developers.google.com/maps/documentation/javascript/reference/overlay-view#OverlayView
|
|
7
11
|
*/
|
|
8
|
-
position?: google.maps.LatLngLiteral;
|
|
12
|
+
position?: google.maps.LatLng | google.maps.LatLngLiteral;
|
|
13
|
+
/**
|
|
14
|
+
* Initial open state for the uncontrolled mode (when `v-model:open` is not
|
|
15
|
+
* bound). When omitted, the overlay opens on mount, matching v0 behaviour.
|
|
16
|
+
*
|
|
17
|
+
* Has no effect when `v-model:open` is used; pass an initial value to the
|
|
18
|
+
* bound ref instead.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
defaultOpen?: boolean;
|
|
9
22
|
/**
|
|
10
23
|
* Anchor point of the overlay relative to its position.
|
|
11
24
|
* @default 'bottom-center'
|
|
12
25
|
*/
|
|
13
|
-
anchor?:
|
|
26
|
+
anchor?: ScriptGoogleMapsOverlayAnchor;
|
|
14
27
|
/**
|
|
15
28
|
* Pixel offset from the anchor position.
|
|
16
29
|
*/
|
|
@@ -23,7 +36,7 @@ type __VLS_Props = {
|
|
|
23
36
|
* @default 'floatPane'
|
|
24
37
|
* @see https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes
|
|
25
38
|
*/
|
|
26
|
-
pane?:
|
|
39
|
+
pane?: ScriptGoogleMapsOverlayPane;
|
|
27
40
|
/**
|
|
28
41
|
* CSS z-index for the overlay element.
|
|
29
42
|
*/
|
|
@@ -45,31 +58,39 @@ type __VLS_Props = {
|
|
|
45
58
|
* @default true
|
|
46
59
|
*/
|
|
47
60
|
hideWhenClustered?: boolean;
|
|
48
|
-
}
|
|
49
|
-
|
|
61
|
+
}
|
|
62
|
+
export interface ScriptGoogleMapsOverlayViewEmits {
|
|
63
|
+
/** Event handler called when the open state of the overlay view changes. */
|
|
64
|
+
'update:open': [value: boolean];
|
|
65
|
+
}
|
|
66
|
+
export interface ScriptGoogleMapsOverlayViewSlots {
|
|
50
67
|
default?: () => any;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
blockMapInteraction: boolean;
|
|
67
|
-
panOnOpen: boolean | number;
|
|
68
|
-
hideWhenClustered: boolean;
|
|
69
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
70
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
68
|
+
}
|
|
69
|
+
export interface ScriptGoogleMapsOverlayViewExpose {
|
|
70
|
+
/** The underlying `OverlayView` instance. */
|
|
71
|
+
overlayView: ShallowRef<google.maps.OverlayView | undefined>;
|
|
72
|
+
/**
|
|
73
|
+
* The underlying `OverlayView` instance.
|
|
74
|
+
*
|
|
75
|
+
* @deprecated Use `overlayView` instead. The `overlay` alias will be
|
|
76
|
+
* removed in a future major version.
|
|
77
|
+
* @see https://scripts.nuxt.com/docs/migration-guide/v0-to-v1
|
|
78
|
+
*/
|
|
79
|
+
overlay: ShallowRef<google.maps.OverlayView | undefined>;
|
|
80
|
+
/** The current data-state of the overlay, either 'open' or 'closed'. */
|
|
81
|
+
dataState: Readonly<ShallowRef<'open' | 'closed'>>;
|
|
82
|
+
}
|
|
71
83
|
declare const _default: typeof __VLS_export;
|
|
72
84
|
export default _default;
|
|
85
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScriptGoogleMapsOverlayViewProps & {
|
|
86
|
+
open?: boolean;
|
|
87
|
+
}, ScriptGoogleMapsOverlayViewExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
88
|
+
"update:open": (value: boolean) => any;
|
|
89
|
+
}, string, import("vue").PublicProps, Readonly<ScriptGoogleMapsOverlayViewProps & {
|
|
90
|
+
open?: boolean;
|
|
91
|
+
}> & Readonly<{
|
|
92
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
93
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScriptGoogleMapsOverlayViewSlots>;
|
|
73
94
|
type __VLS_WithSlots<T, S> = T & {
|
|
74
95
|
new (): {
|
|
75
96
|
$slots: S;
|
|
@@ -25,6 +25,56 @@ export interface GoogleMapsResourceContext {
|
|
|
25
25
|
map: google.maps.Map;
|
|
26
26
|
mapsApi: typeof google.maps;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes a `LatLng | LatLngLiteral` value into a plain `LatLngLiteral`.
|
|
30
|
+
*
|
|
31
|
+
* Google's `LatLng` exposes coordinates via `.lat()`/`.lng()` methods, while
|
|
32
|
+
* `LatLngLiteral` exposes them as plain `lat`/`lng` numeric properties. The
|
|
33
|
+
* runtime distinguishes them by checking whether `.lat` is callable; this is
|
|
34
|
+
* preferred over `instanceof google.maps.LatLng` because mocked APIs in tests
|
|
35
|
+
* return plain objects rather than real `LatLng` instances.
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeLatLng(p: google.maps.LatLng | google.maps.LatLngLiteral): google.maps.LatLngLiteral;
|
|
38
|
+
/**
|
|
39
|
+
* Defines a deprecated property alias on an exposed object. Reading the alias
|
|
40
|
+
* returns the value of the canonical key and emits a one-shot
|
|
41
|
+
* `console.warn` (so repeated reads don't spam the console).
|
|
42
|
+
*
|
|
43
|
+
* Used to provide backward-compatible renames on `defineExpose` payloads
|
|
44
|
+
* without breaking existing template-ref consumers. Call sites should wrap
|
|
45
|
+
* this in `if (import.meta.dev)` so production builds skip the getter
|
|
46
|
+
* entirely and the alias stays a plain data property.
|
|
47
|
+
*/
|
|
48
|
+
export declare function defineDeprecatedAlias<T extends object, K extends keyof T>(target: T, alias: string, canonicalKey: K, message: string): T;
|
|
49
|
+
/**
|
|
50
|
+
* Emits dev-mode deprecation warnings for the legacy top-level `center` and
|
|
51
|
+
* `zoom` props on `<ScriptGoogleMaps>`. Both props still work, but new code
|
|
52
|
+
* should pass them via `mapOptions` instead.
|
|
53
|
+
*
|
|
54
|
+
* Returns the number of warnings emitted (useful for tests).
|
|
55
|
+
*/
|
|
56
|
+
export declare function warnDeprecatedTopLevelMapProps(props: {
|
|
57
|
+
center?: unknown;
|
|
58
|
+
zoom?: unknown;
|
|
59
|
+
}): number;
|
|
60
|
+
/**
|
|
61
|
+
* Wait until the Google Maps API and a Map instance are both available.
|
|
62
|
+
*
|
|
63
|
+
* Triggers script loading via `load()` if not already loaded. Uses an
|
|
64
|
+
* immediate watcher (matching `importLibrary`'s pattern) to avoid the race
|
|
65
|
+
* where `load()` resolves synchronously: a non-immediate watcher would miss
|
|
66
|
+
* the change and the promise would hang forever.
|
|
67
|
+
*
|
|
68
|
+
* Rejects if `status` enters an `'error'` state before both refs are populated.
|
|
69
|
+
* Runs the watcher inside a detached effect scope so it is safe to call from
|
|
70
|
+
* any context (component setup, exposed methods, tests).
|
|
71
|
+
*/
|
|
72
|
+
export declare function waitForMapsReady({ mapsApi, map, status, load, }: {
|
|
73
|
+
mapsApi: ShallowRef<typeof google.maps | undefined>;
|
|
74
|
+
map: ShallowRef<google.maps.Map | undefined>;
|
|
75
|
+
status: Ref<string>;
|
|
76
|
+
load: () => Promise<unknown> | unknown;
|
|
77
|
+
}): Promise<void>;
|
|
28
78
|
/**
|
|
29
79
|
* Composable for safely managing Google Maps resource lifecycle.
|
|
30
80
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { whenever } from "@vueuse/core";
|
|
2
|
-
import { inject, onUnmounted, ref, shallowRef } from "vue";
|
|
2
|
+
import { effectScope, inject, onUnmounted, ref, shallowRef, watch } from "vue";
|
|
3
3
|
export const MAP_INJECTION_KEY = Symbol("map");
|
|
4
4
|
export const MARKER_INJECTION_KEY = Symbol("marker");
|
|
5
5
|
export function bindGoogleMapsEvents(instance, emit, config) {
|
|
@@ -10,6 +10,81 @@ export function bindGoogleMapsEvents(instance, emit, config) {
|
|
|
10
10
|
instance.addListener(event, (payload) => emit(event, payload));
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
+
export function normalizeLatLng(p) {
|
|
14
|
+
if (typeof p.lat === "function") {
|
|
15
|
+
const ll = p;
|
|
16
|
+
return { lat: ll.lat(), lng: ll.lng() };
|
|
17
|
+
}
|
|
18
|
+
return { lat: p.lat, lng: p.lng };
|
|
19
|
+
}
|
|
20
|
+
export function defineDeprecatedAlias(target, alias, canonicalKey, message) {
|
|
21
|
+
let warned = false;
|
|
22
|
+
Object.defineProperty(target, alias, {
|
|
23
|
+
get() {
|
|
24
|
+
if (!warned) {
|
|
25
|
+
warned = true;
|
|
26
|
+
console.warn(message);
|
|
27
|
+
}
|
|
28
|
+
return target[canonicalKey];
|
|
29
|
+
},
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
export function warnDeprecatedTopLevelMapProps(props) {
|
|
36
|
+
let warned = 0;
|
|
37
|
+
if (props.center !== void 0) {
|
|
38
|
+
warned++;
|
|
39
|
+
console.warn(
|
|
40
|
+
'[nuxt-scripts] <ScriptGoogleMaps> prop "center" is deprecated; use `:map-options="{ center: ... }"` instead. See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (props.zoom !== void 0) {
|
|
44
|
+
warned++;
|
|
45
|
+
console.warn(
|
|
46
|
+
'[nuxt-scripts] <ScriptGoogleMaps> prop "zoom" is deprecated; use `:map-options="{ zoom: ... }"` instead. See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1'
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return warned;
|
|
50
|
+
}
|
|
51
|
+
export async function waitForMapsReady({
|
|
52
|
+
mapsApi,
|
|
53
|
+
map,
|
|
54
|
+
status,
|
|
55
|
+
load
|
|
56
|
+
}) {
|
|
57
|
+
if (mapsApi.value && map.value)
|
|
58
|
+
return;
|
|
59
|
+
if (status.value === "error")
|
|
60
|
+
throw new Error("Google Maps script failed to load");
|
|
61
|
+
await load();
|
|
62
|
+
if (mapsApi.value && map.value)
|
|
63
|
+
return;
|
|
64
|
+
if (status.value === "error")
|
|
65
|
+
throw new Error("Google Maps script failed to load");
|
|
66
|
+
const scope = effectScope(true);
|
|
67
|
+
try {
|
|
68
|
+
await new Promise((resolve, reject) => {
|
|
69
|
+
scope.run(() => {
|
|
70
|
+
watch(
|
|
71
|
+
[mapsApi, map, status],
|
|
72
|
+
([api, m, s]) => {
|
|
73
|
+
if (api && m) {
|
|
74
|
+
resolve();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (s === "error")
|
|
78
|
+
reject(new Error("Google Maps script failed to load"));
|
|
79
|
+
},
|
|
80
|
+
{ immediate: true }
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
} finally {
|
|
85
|
+
scope.stop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
13
88
|
export function useGoogleMapsResource({
|
|
14
89
|
ready,
|
|
15
90
|
create,
|