@nuxt/scripts 1.0.0-rc.5 → 1.0.0-rc.7
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/bin/cli.mjs +2 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +50 -0
- package/dist/devtools-client/200.html +1 -1
- package/dist/devtools-client/404.html +1 -1
- package/dist/devtools-client/_nuxt/{CL6TeQIJ.js → 5D-5agUu.js} +31 -31
- package/dist/devtools-client/_nuxt/{DoF6byDH.js → BDlZgWHO.js} +1 -1
- package/dist/devtools-client/_nuxt/{D838xXrH.js → BntLcF3H.js} +1 -1
- package/dist/devtools-client/_nuxt/{BFtOB2Ap.js → CC9d18RE.js} +1 -1
- package/dist/devtools-client/_nuxt/{BfQVeAez.js → CaQ1scfO.js} +1 -1
- package/dist/devtools-client/_nuxt/{C7-YRs3P.js → DJ5bfe9v.js} +1 -1
- package/dist/devtools-client/_nuxt/{Duf9abe1.js → YKhzFESo.js} +1 -1
- package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
- package/dist/devtools-client/_nuxt/builds/meta/7a96fd5e-d239-4ba5-816b-05034a861ba0.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/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.d.mts +51 -2
- package/dist/module.d.ts +51 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +80 -9
- package/dist/registry.mjs +10 -10
- 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/runtime/server/bluesky-embed.js +3 -2
- package/dist/runtime/server/google-maps-geocode-proxy.js +3 -2
- package/dist/runtime/server/google-static-maps-proxy.js +3 -2
- package/dist/runtime/server/gravatar-proxy.js +3 -2
- package/dist/runtime/server/instagram-embed.js +3 -2
- package/dist/runtime/server/utils/image-proxy.js +3 -2
- package/dist/runtime/server/utils/sign.d.ts +109 -0
- package/dist/runtime/server/utils/sign.js +88 -0
- package/dist/runtime/server/utils/withSigning.d.ts +23 -0
- package/dist/runtime/server/utils/withSigning.js +18 -0
- package/dist/runtime/server/x-embed.js +3 -2
- package/dist/runtime/types.d.ts +9 -1
- package/dist/types-source.mjs +2 -198
- package/dist/types.d.mts +2 -2
- package/package.json +6 -2
- package/dist/devtools-client/_nuxt/builds/meta/03a9e297-6209-4281-8c3d-4265bdd5d038.json +0 -1
- package/dist/devtools-client/_nuxt/error-404.BGYgyi5Q.css +0 -1
- package/dist/devtools-client/_nuxt/error-500.7RpV0mcx.css +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
2
2
|
import type { HTMLAttributes, ReservedProps, ShallowRef } from 'vue';
|
|
3
3
|
export { MAP_INJECTION_KEY } from './useGoogleMapsResource.js';
|
|
4
|
-
|
|
5
|
-
export default _default;
|
|
6
|
-
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
4
|
+
export interface ScriptGoogleMapsProps {
|
|
7
5
|
/**
|
|
8
6
|
* Defines the trigger event to load the script.
|
|
7
|
+
* @default ['mouseenter', 'mouseover', 'mousedown']
|
|
9
8
|
*/
|
|
10
9
|
trigger?: ElementScriptTrigger;
|
|
11
10
|
/**
|
|
@@ -14,11 +13,20 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
14
13
|
apiKey?: string;
|
|
15
14
|
/**
|
|
16
15
|
* A latitude / longitude of where to focus the map.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated Pass `center` via `mapOptions` instead. The top-level `center`
|
|
18
|
+
* prop will be removed in a future major version. When both are set,
|
|
19
|
+
* `mapOptions.center` wins.
|
|
20
|
+
* @see https://scripts.nuxt.com/docs/migration-guide/v0-to-v1
|
|
17
21
|
*/
|
|
18
22
|
center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
|
|
19
23
|
/**
|
|
20
24
|
* Zoom level for the map (0-21). Reactive: changing this will update the map.
|
|
21
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Pass `zoom` via `mapOptions` instead. The top-level `zoom`
|
|
27
|
+
* prop will be removed in a future major version. When both are set,
|
|
28
|
+
* `mapOptions.zoom` wins.
|
|
29
|
+
* @see https://scripts.nuxt.com/docs/migration-guide/v0-to-v1
|
|
22
30
|
*/
|
|
23
31
|
zoom?: number;
|
|
24
32
|
/**
|
|
@@ -30,19 +38,21 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
30
38
|
*/
|
|
31
39
|
region?: string;
|
|
32
40
|
/**
|
|
33
|
-
* Defines the language of the map
|
|
41
|
+
* Defines the language of the map.
|
|
34
42
|
*/
|
|
35
43
|
language?: string;
|
|
36
44
|
/**
|
|
37
|
-
* Defines the version of google maps js API
|
|
45
|
+
* Defines the version of google maps js API.
|
|
38
46
|
*/
|
|
39
47
|
version?: string;
|
|
40
48
|
/**
|
|
41
49
|
* Defines the width of the map.
|
|
50
|
+
* @default 640
|
|
42
51
|
*/
|
|
43
52
|
width?: number | string;
|
|
44
53
|
/**
|
|
45
|
-
* Defines the height of the map
|
|
54
|
+
* Defines the height of the map.
|
|
55
|
+
* @default 400
|
|
46
56
|
*/
|
|
47
57
|
height?: number | string;
|
|
48
58
|
/**
|
|
@@ -60,122 +70,92 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
60
70
|
};
|
|
61
71
|
/**
|
|
62
72
|
* Manual color mode control. When provided, overrides auto-detection from @nuxtjs/color-mode.
|
|
63
|
-
* Accepts 'light'
|
|
64
|
-
*/
|
|
65
|
-
colorMode?: "light" | "dark";
|
|
66
|
-
}, {
|
|
67
|
-
readonly googleMaps: import("vue").Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
68
|
-
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
69
|
-
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
70
|
-
readonly importLibrary: {
|
|
71
|
-
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
72
|
-
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
73
|
-
(key: "geometry"): Promise<google.maps.GeometryLibrary>;
|
|
74
|
-
(key: "drawing"): Promise<google.maps.DrawingLibrary>;
|
|
75
|
-
(key: "visualization"): Promise<google.maps.VisualizationLibrary>;
|
|
76
|
-
(key: string): Promise<any>;
|
|
77
|
-
};
|
|
78
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
79
|
-
error: () => any;
|
|
80
|
-
ready: (e: {
|
|
81
|
-
readonly googleMaps: import("vue").Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
82
|
-
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
83
|
-
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
84
|
-
readonly importLibrary: {
|
|
85
|
-
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
86
|
-
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
87
|
-
(key: "geometry"): Promise<google.maps.GeometryLibrary>;
|
|
88
|
-
(key: "drawing"): Promise<google.maps.DrawingLibrary>;
|
|
89
|
-
(key: "visualization"): Promise<google.maps.VisualizationLibrary>;
|
|
90
|
-
(key: string): Promise<any>;
|
|
91
|
-
};
|
|
92
|
-
}) => any;
|
|
93
|
-
}, string, import("vue").PublicProps, Readonly<{
|
|
94
|
-
/**
|
|
95
|
-
* Defines the trigger event to load the script.
|
|
73
|
+
* Accepts 'light' or 'dark'.
|
|
96
74
|
*/
|
|
97
|
-
|
|
75
|
+
colorMode?: 'light' | 'dark';
|
|
76
|
+
}
|
|
77
|
+
export interface ScriptGoogleMapsExpose {
|
|
98
78
|
/**
|
|
99
|
-
*
|
|
79
|
+
* A reference to the loaded Google Maps API namespace (`google.maps`), or
|
|
80
|
+
* `undefined` if not yet loaded.
|
|
100
81
|
*/
|
|
101
|
-
|
|
82
|
+
mapsApi: ShallowRef<typeof google.maps | undefined>;
|
|
102
83
|
/**
|
|
103
|
-
* A
|
|
84
|
+
* A reference to the loaded Google Maps API namespace, or `undefined` if not
|
|
85
|
+
* yet loaded.
|
|
86
|
+
*
|
|
87
|
+
* @deprecated Use `mapsApi` instead. The `googleMaps` alias will be removed
|
|
88
|
+
* in a future major version.
|
|
89
|
+
* @see https://scripts.nuxt.com/docs/migration-guide/v0-to-v1
|
|
104
90
|
*/
|
|
105
|
-
|
|
91
|
+
googleMaps: ShallowRef<typeof google.maps | undefined>;
|
|
106
92
|
/**
|
|
107
|
-
*
|
|
108
|
-
* Takes precedence over mapOptions.zoom when provided.
|
|
93
|
+
* A reference to the Google Map instance, or `undefined` if not yet initialized.
|
|
109
94
|
*/
|
|
110
|
-
|
|
95
|
+
map: ShallowRef<google.maps.Map | undefined>;
|
|
111
96
|
/**
|
|
112
|
-
*
|
|
97
|
+
* Utility function to resolve a location query (e.g. "New York, NY") to latitude/longitude coordinates.
|
|
98
|
+
* Uses a caching mechanism and a server-side proxy to avoid unnecessary client-side API calls.
|
|
113
99
|
*/
|
|
114
|
-
|
|
100
|
+
resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
115
101
|
/**
|
|
116
|
-
*
|
|
102
|
+
* Utility function to dynamically import additional Google Maps libraries (e.g. "marker", "places").
|
|
103
|
+
* Caches imported libraries for efficient reuse.
|
|
117
104
|
*/
|
|
118
|
-
|
|
105
|
+
importLibrary: {
|
|
106
|
+
(key: 'marker'): Promise<google.maps.MarkerLibrary>;
|
|
107
|
+
(key: 'places'): Promise<google.maps.PlacesLibrary>;
|
|
108
|
+
(key: 'geometry'): Promise<google.maps.GeometryLibrary>;
|
|
109
|
+
(key: 'drawing'): Promise<google.maps.DrawingLibrary>;
|
|
110
|
+
(key: 'visualization'): Promise<google.maps.VisualizationLibrary>;
|
|
111
|
+
(key: string): Promise<any>;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface ScriptGoogleMapsEmits {
|
|
119
115
|
/**
|
|
120
|
-
*
|
|
116
|
+
* Fired when the Google Maps instance is fully loaded and ready to use. Provides access to the maps API.
|
|
121
117
|
*/
|
|
122
|
-
|
|
118
|
+
ready: [payload: ScriptGoogleMapsExpose];
|
|
123
119
|
/**
|
|
124
|
-
*
|
|
120
|
+
* Fired when the Google Maps script fails to load.
|
|
125
121
|
*/
|
|
126
|
-
|
|
122
|
+
error: [];
|
|
123
|
+
}
|
|
124
|
+
export interface ScriptGoogleMapsSlots {
|
|
127
125
|
/**
|
|
128
|
-
*
|
|
126
|
+
* Default slot for rendering child components (e.g. markers, info windows) that depend on the map being ready.
|
|
129
127
|
*/
|
|
130
|
-
|
|
128
|
+
default?: () => any;
|
|
131
129
|
/**
|
|
132
|
-
*
|
|
130
|
+
* Slot displayed while the map is loading. Can be used to show a custom loading indicator.
|
|
133
131
|
*/
|
|
134
|
-
|
|
132
|
+
loading?: () => any;
|
|
135
133
|
/**
|
|
136
|
-
*
|
|
134
|
+
* Slot displayed when the script is awaiting user interaction to load (based on the `trigger` prop).
|
|
137
135
|
*/
|
|
138
|
-
|
|
136
|
+
awaitingLoad?: () => any;
|
|
139
137
|
/**
|
|
140
|
-
*
|
|
141
|
-
* When provided, the map will automatically switch styles based on color mode.
|
|
142
|
-
* Requires @nuxtjs/color-mode or manual colorMode prop.
|
|
138
|
+
* Slot displayed if the script fails to load.
|
|
143
139
|
*/
|
|
144
|
-
|
|
145
|
-
light?: string;
|
|
146
|
-
dark?: string;
|
|
147
|
-
};
|
|
140
|
+
error?: () => any;
|
|
148
141
|
/**
|
|
149
|
-
*
|
|
150
|
-
* Accepts 'light', 'dark', or a reactive ref.
|
|
142
|
+
* Slot displayed as a placeholder before the map is ready. Useful for showing a static map or skeleton.
|
|
151
143
|
*/
|
|
152
|
-
|
|
153
|
-
}
|
|
144
|
+
placeholder?: () => any;
|
|
145
|
+
}
|
|
146
|
+
declare const _default: typeof __VLS_export;
|
|
147
|
+
export default _default;
|
|
148
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScriptGoogleMapsProps, ScriptGoogleMapsExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
149
|
+
error: () => any;
|
|
150
|
+
ready: (payload: ScriptGoogleMapsExpose) => any;
|
|
151
|
+
}, string, import("vue").PublicProps, Readonly<ScriptGoogleMapsProps> & Readonly<{
|
|
154
152
|
onError?: (() => any) | undefined;
|
|
155
|
-
onReady?: ((
|
|
156
|
-
readonly googleMaps: import("vue").Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
157
|
-
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
158
|
-
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
159
|
-
readonly importLibrary: {
|
|
160
|
-
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
161
|
-
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
162
|
-
(key: "geometry"): Promise<google.maps.GeometryLibrary>;
|
|
163
|
-
(key: "drawing"): Promise<google.maps.DrawingLibrary>;
|
|
164
|
-
(key: "visualization"): Promise<google.maps.VisualizationLibrary>;
|
|
165
|
-
(key: string): Promise<any>;
|
|
166
|
-
};
|
|
167
|
-
}) => any) | undefined;
|
|
153
|
+
onReady?: ((payload: ScriptGoogleMapsExpose) => any) | undefined;
|
|
168
154
|
}>, {
|
|
169
155
|
trigger: ElementScriptTrigger;
|
|
170
156
|
width: number | string;
|
|
171
157
|
height: number | string;
|
|
172
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>,
|
|
173
|
-
default?: () => any;
|
|
174
|
-
placeholder?: () => any;
|
|
175
|
-
loading?: () => any;
|
|
176
|
-
awaitingLoad?: () => any;
|
|
177
|
-
error?: () => any;
|
|
178
|
-
}>;
|
|
158
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScriptGoogleMapsSlots>;
|
|
179
159
|
type __VLS_WithSlots<T, S> = T & {
|
|
180
160
|
new (): {
|
|
181
161
|
$slots: S;
|
|
@@ -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;
|
|
@@ -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>
|