@nuxt/scripts 1.0.0-rc.1 → 1.0.0-rc.11

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 (164) 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/{ajngqPCs.js → BgPDxVUn.js} +1 -1
  8. package/dist/devtools-client/_nuxt/{DKL6PHO3.js → BmlapxLP.js} +1 -1
  9. package/dist/devtools-client/_nuxt/CM2vefXI.js +188 -0
  10. package/dist/devtools-client/_nuxt/{CfOsp0mU.js → DAF5Qk9P.js} +1 -1
  11. package/dist/devtools-client/_nuxt/{B3kN3DAy.js → Dx6HhVmj.js} +1 -1
  12. package/dist/devtools-client/_nuxt/{dlaR8P-P.js → S8LiR9M1.js} +1 -1
  13. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  14. package/dist/devtools-client/_nuxt/builds/meta/d788053e-f511-4867-b557-1952fcbcae82.json +1 -0
  15. package/dist/devtools-client/_nuxt/{entry.BwpOBArY.css → entry.BKkVrcJj.css} +1 -1
  16. package/dist/devtools-client/_nuxt/error-404.d44aGwWI.css +1 -0
  17. package/dist/devtools-client/_nuxt/error-500.NthMfIEt.css +1 -0
  18. package/dist/devtools-client/_nuxt/index.DZD1lwyI.css +1 -0
  19. package/dist/devtools-client/_nuxt/vBkR1GJq.js +1 -0
  20. package/dist/devtools-client/docs/index.html +1 -1
  21. package/dist/devtools-client/first-party/index.html +1 -1
  22. package/dist/devtools-client/index.html +1 -1
  23. package/dist/devtools-client/registry/index.html +1 -1
  24. package/dist/module.d.mts +66 -2
  25. package/dist/module.d.ts +66 -2
  26. package/dist/module.json +1 -1
  27. package/dist/module.mjs +151 -30
  28. package/dist/registry.d.mts +1 -0
  29. package/dist/registry.d.ts +1 -0
  30. package/dist/registry.mjs +14 -14
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +73 -97
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +81 -58
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +73 -97
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +2 -3
  35. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +1 -0
  36. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +2 -3
  37. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +2 -3
  38. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +2 -1
  39. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +2 -3
  40. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +10 -43
  41. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +3 -1
  42. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +10 -43
  43. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +50 -30
  44. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +145 -104
  45. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +50 -30
  46. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue +7 -2
  47. package/dist/runtime/components/GoogleMaps/types.d.ts +42 -0
  48. package/dist/runtime/components/GoogleMaps/types.js +1 -0
  49. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +50 -0
  50. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +76 -1
  51. package/dist/runtime/components/ScriptBlueskyEmbed.d.vue.ts +10 -12
  52. package/dist/runtime/components/ScriptBlueskyEmbed.vue +13 -10
  53. package/dist/runtime/components/ScriptBlueskyEmbed.vue.d.ts +10 -12
  54. package/dist/runtime/components/ScriptCarbonAds.d.vue.ts +4 -7
  55. package/dist/runtime/components/ScriptCarbonAds.vue +1 -0
  56. package/dist/runtime/components/ScriptCarbonAds.vue.d.ts +4 -7
  57. package/dist/runtime/components/ScriptCrisp.d.vue.ts +7 -11
  58. package/dist/runtime/components/ScriptCrisp.vue +1 -0
  59. package/dist/runtime/components/ScriptCrisp.vue.d.ts +7 -11
  60. package/dist/runtime/components/ScriptGoogleAdsense.d.vue.ts +4 -7
  61. package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -0
  62. package/dist/runtime/components/ScriptGoogleAdsense.vue.d.ts +4 -7
  63. package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +11 -13
  64. package/dist/runtime/components/ScriptInstagramEmbed.vue +4 -1
  65. package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +11 -13
  66. package/dist/runtime/components/ScriptIntercom.d.vue.ts +7 -11
  67. package/dist/runtime/components/ScriptIntercom.vue +1 -0
  68. package/dist/runtime/components/ScriptIntercom.vue.d.ts +7 -11
  69. package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +2 -3
  70. package/dist/runtime/components/ScriptLemonSqueezy.vue +1 -0
  71. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +2 -3
  72. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +8 -13
  73. package/dist/runtime/components/ScriptPayPalButtons.vue +1 -0
  74. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +8 -13
  75. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +8 -13
  76. package/dist/runtime/components/ScriptPayPalMessages.vue +1 -0
  77. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +8 -13
  78. package/dist/runtime/components/ScriptStripePricingTable.d.vue.ts +5 -9
  79. package/dist/runtime/components/ScriptStripePricingTable.vue +1 -0
  80. package/dist/runtime/components/ScriptStripePricingTable.vue.d.ts +5 -9
  81. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +8 -11
  82. package/dist/runtime/components/ScriptVimeoPlayer.vue +1 -0
  83. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +8 -11
  84. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +10 -12
  85. package/dist/runtime/components/ScriptXEmbed.vue +12 -9
  86. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +10 -12
  87. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +8 -13
  88. package/dist/runtime/components/ScriptYouTubePlayer.vue +1 -0
  89. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +8 -13
  90. package/dist/runtime/composables/useScript.js +17 -6
  91. package/dist/runtime/composables/useScriptProxyToken.d.ts +12 -0
  92. package/dist/runtime/composables/useScriptProxyToken.js +4 -0
  93. package/dist/runtime/composables/useScriptProxyUrl.d.ts +12 -0
  94. package/dist/runtime/composables/useScriptProxyUrl.js +27 -0
  95. package/dist/runtime/plugins/proxy-token.server.d.ts +10 -0
  96. package/dist/runtime/plugins/proxy-token.server.js +17 -0
  97. package/dist/runtime/registry/bing-uet.d.ts +189 -11
  98. package/dist/runtime/registry/bing-uet.js +16 -2
  99. package/dist/runtime/registry/bluesky-embed.d.ts +0 -4
  100. package/dist/runtime/registry/bluesky-embed.js +0 -4
  101. package/dist/runtime/registry/clarity.d.ts +6 -2
  102. package/dist/runtime/registry/clarity.js +12 -1
  103. package/dist/runtime/registry/google-analytics.d.ts +6 -2
  104. package/dist/runtime/registry/google-analytics.js +12 -1
  105. package/dist/runtime/registry/google-tag-manager.d.ts +6 -2
  106. package/dist/runtime/registry/google-tag-manager.js +10 -1
  107. package/dist/runtime/registry/gravatar.js +10 -13
  108. package/dist/runtime/registry/matomo-analytics.d.ts +9 -3
  109. package/dist/runtime/registry/matomo-analytics.js +28 -1
  110. package/dist/runtime/registry/meta-pixel.d.ts +8 -2
  111. package/dist/runtime/registry/meta-pixel.js +10 -1
  112. package/dist/runtime/registry/mixpanel-analytics.d.ts +12 -2
  113. package/dist/runtime/registry/mixpanel-analytics.js +16 -4
  114. package/dist/runtime/registry/posthog.d.ts +8 -2
  115. package/dist/runtime/registry/posthog.js +15 -4
  116. package/dist/runtime/registry/schemas.d.ts +65 -0
  117. package/dist/runtime/registry/schemas.js +75 -8
  118. package/dist/runtime/registry/tiktok-pixel.d.ts +16 -2
  119. package/dist/runtime/registry/tiktok-pixel.js +22 -1
  120. package/dist/runtime/registry/x-embed.d.ts +0 -4
  121. package/dist/runtime/registry/x-embed.js +0 -4
  122. package/dist/runtime/server/bluesky-embed-image.d.ts +1 -1
  123. package/dist/runtime/server/bluesky-embed.d.ts +1 -15
  124. package/dist/runtime/server/bluesky-embed.js +25 -6
  125. package/dist/runtime/server/google-maps-geocode-proxy.js +12 -8
  126. package/dist/runtime/server/google-static-maps-proxy.d.ts +1 -1
  127. package/dist/runtime/server/google-static-maps-proxy.js +17 -11
  128. package/dist/runtime/server/gravatar-proxy.d.ts +1 -1
  129. package/dist/runtime/server/gravatar-proxy.js +10 -10
  130. package/dist/runtime/server/instagram-embed-asset.d.ts +1 -1
  131. package/dist/runtime/server/instagram-embed-image.d.ts +1 -1
  132. package/dist/runtime/server/instagram-embed.d.ts +1 -16
  133. package/dist/runtime/server/instagram-embed.js +26 -125
  134. package/dist/runtime/server/proxy-handler.js +1 -2
  135. package/dist/runtime/server/utils/cached-upstream.d.ts +55 -0
  136. package/dist/runtime/server/utils/cached-upstream.js +65 -0
  137. package/dist/runtime/server/utils/embed-rewriters.d.ts +19 -0
  138. package/dist/runtime/server/utils/embed-rewriters.js +41 -0
  139. package/dist/runtime/server/utils/image-proxy.d.ts +3 -1
  140. package/dist/runtime/server/utils/image-proxy.js +11 -8
  141. package/dist/runtime/server/utils/instagram-embed.d.ts +16 -0
  142. package/dist/runtime/server/utils/instagram-embed.js +153 -0
  143. package/dist/runtime/server/utils/proxy-url.d.ts +9 -0
  144. package/dist/runtime/server/utils/proxy-url.js +21 -0
  145. package/dist/runtime/server/utils/sign-constants.d.ts +16 -0
  146. package/dist/runtime/server/utils/sign-constants.js +5 -0
  147. package/dist/runtime/server/utils/sign.d.ts +101 -0
  148. package/dist/runtime/server/utils/sign.js +91 -0
  149. package/dist/runtime/server/utils/withSigning.d.ts +23 -0
  150. package/dist/runtime/server/utils/withSigning.js +19 -0
  151. package/dist/runtime/server/x-embed-image.d.ts +1 -1
  152. package/dist/runtime/server/x-embed.js +23 -4
  153. package/dist/runtime/types.d.ts +41 -6
  154. package/dist/runtime/types.js +1 -0
  155. package/dist/stats.mjs +298 -338
  156. package/dist/types-source.mjs +537 -164
  157. package/dist/types.d.mts +2 -2
  158. package/package.json +10 -6
  159. package/dist/devtools-client/_nuxt/C8jhSQ8l.js +0 -1
  160. package/dist/devtools-client/_nuxt/CJD6wrkT.js +0 -188
  161. package/dist/devtools-client/_nuxt/builds/meta/b800a0be-5cab-4ea6-89e3-dd3a85690a73.json +0 -1
  162. package/dist/devtools-client/_nuxt/error-404.CvOVjXeC.css +0 -1
  163. package/dist/devtools-client/_nuxt/error-500.BIm53nmx.css +0 -1
  164. package/dist/devtools-client/_nuxt/index.CA-OpSj0.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,126 +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
- placeholder?: (props: {}) => any;
174
- } & {
175
- loading?: (props: {}) => any;
176
- } & {
177
- awaitingLoad?: (props: {}) => any;
178
- } & {
179
- error?: (props: {}) => any;
180
- } & {
181
- default?: (props: {}) => any;
182
- }>;
158
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScriptGoogleMapsSlots>;
183
159
  type __VLS_WithSlots<T, S> = T & {
184
160
  new (): {
185
161
  $slots: S;
@@ -1,18 +1,16 @@
1
1
  <script>
2
+ export { MAP_INJECTION_KEY } from "./useGoogleMapsResource";
3
+ </script>
4
+
5
+ <script setup>
2
6
  import { useScriptTriggerElement } from "#nuxt-scripts/composables/useScriptTriggerElement";
3
7
  import { useScriptGoogleMaps } from "#nuxt-scripts/registry/google-maps";
4
8
  import { scriptRuntimeConfig, scriptsPrefix } from "#nuxt-scripts/utils";
5
9
  import { defu } from "defu";
6
10
  import { tryUseNuxtApp, useHead, useRuntimeConfig } from "nuxt/app";
7
- import { computed, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, useAttrs, watch } from "vue";
11
+ import { computed, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, useAttrs, useTemplateRef, watch } from "vue";
8
12
  import ScriptAriaLoadingIndicator from "../ScriptAriaLoadingIndicator.vue";
9
- import { MAP_INJECTION_KEY } from "./useGoogleMapsResource";
10
- const DIGITS_ONLY_RE = /^\d+$/;
11
- const DIGITS_PX_RE = /^\d+px$/i;
12
- export { MAP_INJECTION_KEY } from "./useGoogleMapsResource";
13
- </script>
14
-
15
- <script setup>
13
+ import { defineDeprecatedAlias, MAP_INJECTION_KEY, waitForMapsReady, warnDeprecatedTopLevelMapProps } from "./useGoogleMapsResource";
16
14
  const props = defineProps({
17
15
  trigger: { type: [String, Array, Boolean], required: false, default: ["mouseenter", "mouseover", "mousedown"] },
18
16
  apiKey: { type: String, required: false },
@@ -29,23 +27,22 @@ const props = defineProps({
29
27
  colorMode: { type: String, required: false }
30
28
  });
31
29
  const emits = defineEmits(["ready", "error"]);
30
+ defineSlots();
31
+ const DIGITS_ONLY_RE = /^\d+$/;
32
+ const DIGITS_PX_RE = /^\d+px$/i;
32
33
  const apiKey = props.apiKey || scriptRuntimeConfig("googleMaps")?.apiKey;
33
34
  const runtimeConfig = useRuntimeConfig();
34
- const nuxtApp = tryUseNuxtApp();
35
- const nuxtColorMode = nuxtApp?.$colorMode;
36
- const currentColorMode = computed(() => {
37
- if (props.colorMode)
38
- return props.colorMode;
39
- if (nuxtColorMode?.value)
40
- return nuxtColorMode.value === "dark" ? "dark" : "light";
41
- return "light";
35
+ const nuxtColorMode = computed(() => {
36
+ const value = tryUseNuxtApp()?.$colorMode?.value;
37
+ return value === "dark" || value === "light" ? value : void 0;
42
38
  });
39
+ const currentColorMode = computed(() => props.colorMode || nuxtColorMode.value || "light");
43
40
  const currentMapId = computed(() => {
44
41
  if (!props.mapIds)
45
42
  return props.mapOptions?.mapId;
46
43
  return props.mapIds[currentColorMode.value] || props.mapIds.light || props.mapOptions?.mapId;
47
44
  });
48
- const mapsApi = ref();
45
+ const mapsApi = shallowRef();
49
46
  if (import.meta.dev) {
50
47
  if (!apiKey)
51
48
  throw new Error("GoogleMaps requires an API key. Enable it in your nuxt.config:\n\n scripts: {\n registry: {\n googleMaps: true\n }\n }\n\nThen set NUXT_PUBLIC_SCRIPTS_GOOGLE_MAPS_API_KEY in your .env file.\n\nAlternatively, pass `api-key` directly on the <ScriptGoogleMaps> component (note: this exposes the key client-side).");
@@ -61,9 +58,10 @@ if (import.meta.dev) {
61
58
  if (prop in attrs)
62
59
  console.warn(`[nuxt-scripts] <ScriptGoogleMaps> prop "${prop}" was removed in v1. ${message} See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1`);
63
60
  }
61
+ warnDeprecatedTopLevelMapProps({ center: props.center, zoom: props.zoom });
64
62
  }
65
- const rootEl = ref();
66
- const mapEl = ref();
63
+ const rootEl = useTemplateRef("rootEl");
64
+ const mapEl = useTemplateRef("mapEl");
67
65
  const centerOverride = ref();
68
66
  const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
69
67
  const { load, status, onLoaded } = useScriptGoogleMaps({
@@ -77,12 +75,14 @@ const { load, status, onLoaded } = useScriptGoogleMaps({
77
75
  });
78
76
  const options = computed(() => {
79
77
  const mapId = props.mapOptions?.styles ? void 0 : currentMapId.value || "map";
80
- return defu({ center: centerOverride.value, mapId, zoom: props.zoom }, props.mapOptions, {
81
- center: props.center,
82
- zoom: 15
83
- });
78
+ return defu(
79
+ { center: centerOverride.value, mapId },
80
+ props.mapOptions,
81
+ { center: props.center, zoom: props.zoom },
82
+ { zoom: 15 }
83
+ );
84
84
  });
85
- const ready = ref(false);
85
+ const isMapReady = ref(false);
86
86
  const map = shallowRef();
87
87
  function isLocationQuery(s) {
88
88
  return typeof s === "string" && (s.split(",").length > 2 || s.includes("+"));
@@ -107,29 +107,25 @@ async function resolveQueryToLatLng(query) {
107
107
  }
108
108
  throw new Error(`No location found for ${query}`);
109
109
  }
110
- return new Promise(async (resolve, reject) => {
111
- if (!mapsApi.value) {
112
- await load();
113
- await new Promise((resolve2) => {
114
- const _ = watch(mapsApi, () => {
115
- _();
116
- resolve2();
117
- });
118
- });
119
- }
120
- const placesService = new mapsApi.value.places.PlacesService(map.value);
121
- placesService.findPlaceFromQuery({
122
- query,
123
- fields: ["name", "geometry"]
124
- }, (results, status2) => {
125
- if (status2 === "OK" && results?.[0]?.geometry?.location)
126
- return resolve(results[0].geometry.location);
127
- return reject(new Error(`No location found for ${query}`));
128
- });
129
- }).then((res) => {
130
- queryToLatLngCache.set(query, res);
131
- return res;
110
+ await waitForMapsReady({ mapsApi, map, status, load });
111
+ const placesService = new mapsApi.value.places.PlacesService(map.value);
112
+ const result = await new Promise((resolve, reject) => {
113
+ placesService.findPlaceFromQuery(
114
+ {
115
+ query,
116
+ fields: ["name", "geometry"]
117
+ },
118
+ (results, status2) => {
119
+ if (status2 === "OK" && results?.[0]?.geometry?.location) {
120
+ resolve(results[0].geometry.location);
121
+ } else {
122
+ reject(new Error(`No location found for ${query}`));
123
+ }
124
+ }
125
+ );
132
126
  });
127
+ queryToLatLngCache.set(query, result);
128
+ return result;
133
129
  }
134
130
  const libraries = /* @__PURE__ */ new Map();
135
131
  function importLibrary(key) {
@@ -151,13 +147,25 @@ function importLibrary(key) {
151
147
  libraries.set(key, cached);
152
148
  return cached;
153
149
  }
154
- const googleMaps = {
150
+ const exposed = {
151
+ mapsApi,
152
+ // Plain alias for production. In dev, replaced below with a getter that
153
+ // emits a one-shot deprecation warning. Both forms return the same
154
+ // shallow ref as `mapsApi`.
155
155
  googleMaps: mapsApi,
156
156
  map,
157
157
  resolveQueryToLatLng,
158
158
  importLibrary
159
159
  };
160
- defineExpose(googleMaps);
160
+ if (import.meta.dev) {
161
+ defineDeprecatedAlias(
162
+ exposed,
163
+ "googleMaps",
164
+ "mapsApi",
165
+ '[nuxt-scripts] <ScriptGoogleMaps> expose key "googleMaps" is deprecated; use "mapsApi" instead. See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1'
166
+ );
167
+ }
168
+ defineExpose(exposed);
161
169
  let activeInfoWindow;
162
170
  provide(MAP_INJECTION_KEY, {
163
171
  map,
@@ -170,9 +178,9 @@ provide(MAP_INJECTION_KEY, {
170
178
  }
171
179
  });
172
180
  onMounted(() => {
173
- watch(ready, (v) => {
181
+ watch(isMapReady, (v) => {
174
182
  if (v) {
175
- emits("ready", googleMaps);
183
+ emits("ready", exposed);
176
184
  }
177
185
  });
178
186
  watch(status, (v) => {
@@ -181,17 +189,31 @@ onMounted(() => {
181
189
  }
182
190
  });
183
191
  watch(options, () => {
184
- map.value?.setOptions(options.value);
192
+ if (!map.value)
193
+ return;
194
+ const { center: _, zoom: __, ...rest } = options.value;
195
+ map.value.setOptions(rest);
185
196
  });
186
- watch([() => options.value.center, ready, map], async (next) => {
197
+ watch(() => options.value.zoom, (zoom) => {
198
+ if (map.value && zoom != null)
199
+ map.value.setZoom(zoom);
200
+ });
201
+ watch([() => options.value.center, isMapReady, map], async (next) => {
187
202
  if (!map.value) {
188
203
  return;
189
204
  }
190
205
  let center = toRaw(next[0]);
191
206
  if (center) {
192
- if (isLocationQuery(center) && ready.value) {
207
+ if (isLocationQuery(center) && isMapReady.value) {
193
208
  center = await resolveQueryToLatLng(center);
194
209
  }
210
+ const current = map.value.getCenter();
211
+ if (current) {
212
+ const newLat = typeof center.lat === "function" ? center.lat() : center.lat;
213
+ const newLng = typeof center.lng === "function" ? center.lng() : center.lng;
214
+ if (current.lat() === newLat && current.lng() === newLng)
215
+ return;
216
+ }
195
217
  map.value.setCenter(center);
196
218
  }
197
219
  }, {
@@ -208,9 +230,10 @@ onMounted(() => {
208
230
  map.value = new mapsApi.value.Map(mapEl.value, _options);
209
231
  if (center && isLocationQuery(center)) {
210
232
  centerOverride.value = await resolveQueryToLatLng(center);
211
- map.value?.setCenter(centerOverride.value);
233
+ if (centerOverride.value)
234
+ map.value?.setCenter(centerOverride.value);
212
235
  }
213
- ready.value = true;
236
+ isMapReady.value = true;
214
237
  });
215
238
  });
216
239
  if (import.meta.server) {
@@ -265,9 +288,9 @@ onBeforeUnmount(() => {
265
288
 
266
289
  <template>
267
290
  <div ref="rootEl" v-bind="rootAttrs">
268
- <div v-show="ready" ref="mapEl" :style="{ width: '100%', height: '100%', maxWidth: '100%' }" />
269
- <slot v-if="!ready" name="placeholder" />
270
- <slot v-if="status !== 'awaitingLoad' && !ready" name="loading">
291
+ <div v-show="isMapReady" ref="mapEl" :style="{ width: '100%', height: '100%', maxWidth: '100%' }" />
292
+ <slot v-if="!isMapReady" name="placeholder" />
293
+ <slot v-if="status !== 'awaitingLoad' && !isMapReady" name="loading">
271
294
  <ScriptAriaLoadingIndicator />
272
295
  </slot>
273
296
  <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />