@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.
Files changed (52) hide show
  1. package/bin/cli.mjs +2 -0
  2. package/dist/cli.d.mts +2 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.mjs +50 -0
  5. package/dist/devtools-client/200.html +1 -1
  6. package/dist/devtools-client/404.html +1 -1
  7. package/dist/devtools-client/_nuxt/{CL6TeQIJ.js → 5D-5agUu.js} +31 -31
  8. package/dist/devtools-client/_nuxt/{DoF6byDH.js → BDlZgWHO.js} +1 -1
  9. package/dist/devtools-client/_nuxt/{D838xXrH.js → BntLcF3H.js} +1 -1
  10. package/dist/devtools-client/_nuxt/{BFtOB2Ap.js → CC9d18RE.js} +1 -1
  11. package/dist/devtools-client/_nuxt/{BfQVeAez.js → CaQ1scfO.js} +1 -1
  12. package/dist/devtools-client/_nuxt/{C7-YRs3P.js → DJ5bfe9v.js} +1 -1
  13. package/dist/devtools-client/_nuxt/{Duf9abe1.js → YKhzFESo.js} +1 -1
  14. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  15. package/dist/devtools-client/_nuxt/builds/meta/7a96fd5e-d239-4ba5-816b-05034a861ba0.json +1 -0
  16. package/dist/devtools-client/_nuxt/error-404.Dwj0Wlzm.css +1 -0
  17. package/dist/devtools-client/_nuxt/error-500.B4wHUYBa.css +1 -0
  18. package/dist/devtools-client/docs/index.html +1 -1
  19. package/dist/devtools-client/first-party/index.html +1 -1
  20. package/dist/devtools-client/index.html +1 -1
  21. package/dist/devtools-client/registry/index.html +1 -1
  22. package/dist/module.d.mts +51 -2
  23. package/dist/module.d.ts +51 -2
  24. package/dist/module.json +1 -1
  25. package/dist/module.mjs +80 -9
  26. package/dist/registry.mjs +10 -10
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +73 -93
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +65 -57
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +73 -93
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +49 -28
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +143 -103
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +49 -28
  33. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +50 -0
  34. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +76 -1
  35. package/dist/runtime/server/bluesky-embed.js +3 -2
  36. package/dist/runtime/server/google-maps-geocode-proxy.js +3 -2
  37. package/dist/runtime/server/google-static-maps-proxy.js +3 -2
  38. package/dist/runtime/server/gravatar-proxy.js +3 -2
  39. package/dist/runtime/server/instagram-embed.js +3 -2
  40. package/dist/runtime/server/utils/image-proxy.js +3 -2
  41. package/dist/runtime/server/utils/sign.d.ts +109 -0
  42. package/dist/runtime/server/utils/sign.js +88 -0
  43. package/dist/runtime/server/utils/withSigning.d.ts +23 -0
  44. package/dist/runtime/server/utils/withSigning.js +18 -0
  45. package/dist/runtime/server/x-embed.js +3 -2
  46. package/dist/runtime/types.d.ts +9 -1
  47. package/dist/types-source.mjs +2 -198
  48. package/dist/types.d.mts +2 -2
  49. package/package.json +6 -2
  50. package/dist/devtools-client/_nuxt/builds/meta/03a9e297-6209-4281-8c3d-4265bdd5d038.json +0 -1
  51. package/dist/devtools-client/_nuxt/error-404.BGYgyi5Q.css +0 -1
  52. 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
- declare const _default: typeof __VLS_export;
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
- * Takes precedence over mapOptions.zoom when provided.
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', 'dark', or a reactive ref.
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
- trigger?: ElementScriptTrigger;
75
+ colorMode?: 'light' | 'dark';
76
+ }
77
+ export interface ScriptGoogleMapsExpose {
98
78
  /**
99
- * Defines the Google Maps API key. Must have access to the Static Maps API as well.
79
+ * A reference to the loaded Google Maps API namespace (`google.maps`), or
80
+ * `undefined` if not yet loaded.
100
81
  */
101
- apiKey?: string;
82
+ mapsApi: ShallowRef<typeof google.maps | undefined>;
102
83
  /**
103
- * A latitude / longitude of where to focus the map.
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
- center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
91
+ googleMaps: ShallowRef<typeof google.maps | undefined>;
106
92
  /**
107
- * Zoom level for the map (0-21). Reactive: changing this will update the map.
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
- zoom?: number;
95
+ map: ShallowRef<google.maps.Map | undefined>;
111
96
  /**
112
- * Options for the map.
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
- mapOptions?: google.maps.MapOptions;
100
+ resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
115
101
  /**
116
- * Defines the region of the map.
102
+ * Utility function to dynamically import additional Google Maps libraries (e.g. "marker", "places").
103
+ * Caches imported libraries for efficient reuse.
117
104
  */
118
- region?: string;
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
- * Defines the language of the map
116
+ * Fired when the Google Maps instance is fully loaded and ready to use. Provides access to the maps API.
121
117
  */
122
- language?: string;
118
+ ready: [payload: ScriptGoogleMapsExpose];
123
119
  /**
124
- * Defines the version of google maps js API
120
+ * Fired when the Google Maps script fails to load.
125
121
  */
126
- version?: string;
122
+ error: [];
123
+ }
124
+ export interface ScriptGoogleMapsSlots {
127
125
  /**
128
- * Defines the width of the map.
126
+ * Default slot for rendering child components (e.g. markers, info windows) that depend on the map being ready.
129
127
  */
130
- width?: number | string;
128
+ default?: () => any;
131
129
  /**
132
- * Defines the height of the map
130
+ * Slot displayed while the map is loading. Can be used to show a custom loading indicator.
133
131
  */
134
- height?: number | string;
132
+ loading?: () => any;
135
133
  /**
136
- * Customize the root element attributes.
134
+ * Slot displayed when the script is awaiting user interaction to load (based on the `trigger` prop).
137
135
  */
138
- rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>;
136
+ awaitingLoad?: () => any;
139
137
  /**
140
- * Map IDs for light and dark color modes.
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
- mapIds?: {
145
- light?: string;
146
- dark?: string;
147
- };
140
+ error?: () => any;
148
141
  /**
149
- * Manual color mode control. When provided, overrides auto-detection from @nuxtjs/color-mode.
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
- colorMode?: "light" | "dark";
153
- }> & Readonly<{
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?: ((e: {
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 OverlayAnchor = 'center' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left-center' | 'right-center';
2
- type OverlayPane = 'mapPane' | 'overlayLayer' | 'markerLayer' | 'overlayMouseTarget' | 'floatPane';
3
- type __VLS_Props = {
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?: OverlayAnchor;
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?: OverlayPane;
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
- type __VLS_Slots = {
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
- type __VLS_ModelProps = {
53
- 'open'?: boolean;
54
- };
55
- type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
56
- declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
57
- overlay: import("vue").ShallowRef<google.maps.OverlayView | undefined>;
58
- dataState: import("vue").ComputedRef<"open" | "closed">;
59
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
60
- "update:open": (value: boolean) => any;
61
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
62
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
63
- }>, {
64
- anchor: OverlayAnchor;
65
- pane: OverlayPane;
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, ref, useTemplateRef, watch } from "vue";
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 props = defineProps({
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
- anchor: { type: String, required: false, default: "bottom-center" },
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, default: "floatPane" },
27
+ pane: { type: String, required: false },
13
28
  zIndex: { type: Number, required: false },
14
- blockMapInteraction: { type: Boolean, required: false, default: true },
15
- panOnOpen: { type: [Boolean, Number], required: false, default: true },
16
- hideWhenClustered: { type: Boolean, required: false, default: true }
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 (props.position)
24
- return props.position;
25
- if (markerContext?.advancedMarkerElement.value) {
26
- const pos = markerContext.advancedMarkerElement.value.position;
27
- if (pos) {
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 overlayContent = useTemplateRef("overlay-content");
47
- const isPositioned = ref(false);
48
- const dataState = computed(() => isPositioned.value ? "open" : "closed");
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
- const overlay = useGoogleMapsResource({
81
- // ready condition accesses .value on ShallowRefs — tracked by whenever() in useGoogleMapsResource
82
- ready: () => !!overlayContent.value && !!(props.position || markerContext?.advancedMarkerElement.value),
83
- create({ mapsApi, map }) {
84
- const el = overlayContent.value;
85
- class CustomOverlay extends mapsApi.OverlayView {
86
- onAdd() {
87
- const panes = this.getPanes();
88
- if (panes) {
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
- draw() {
101
- if (open.value === false) {
102
- isPositioned.value = false;
103
- hideElement(el);
104
- return;
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
- onRemove() {
138
- el.parentNode?.removeChild(el);
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
- el.style.visibility = "hidden";
142
- el.style.pointerEvents = "none";
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 pos = markerContext.advancedMarkerElement.value?.position;
164
- if (!pos)
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
- () => [props.position?.lat, props.position?.lng, props.offset?.x, props.offset?.y, props.zIndex, props.anchor],
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([() => props.pane, () => props.blockMapInteraction], () => {
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 (!props.hideWhenClustered || open.value === false)
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
- defineExpose({ overlay, dataState });
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
- <div ref="overlay-content" :data-state="dataState" v-bind="$attrs">
220
- <slot />
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>