@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,34 +1,47 @@
1
+ <script>
2
+
3
+ </script>
4
+
1
5
  <script setup>
2
- import { computed, inject, ref, useTemplateRef, watch } from "vue";
3
- import { MARKER_CLUSTERER_INJECTION_KEY } from "./ScriptGoogleMapsMarkerClusterer.vue";
4
- import { MARKER_INJECTION_KEY, useGoogleMapsResource } from "./useGoogleMapsResource";
6
+ import { computed, inject, shallowRef, useTemplateRef, watch } from "vue";
7
+ import { MARKER_CLUSTERER_INJECTION_KEY } from "./types";
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
  });
33
+ defineSlots();
18
34
  const open = defineModel("open", { type: Boolean, ...{ default: void 0 } });
35
+ if (open.value === void 0)
36
+ open.value = defaultOpen ?? true;
19
37
  const markerContext = inject(MARKER_INJECTION_KEY, void 0);
20
38
  const markerClustererContext = inject(MARKER_CLUSTERER_INJECTION_KEY, void 0);
21
39
  function getResolvedPosition() {
22
- if (props.position)
23
- return props.position;
24
- if (markerContext?.advancedMarkerElement.value) {
25
- const pos = markerContext.advancedMarkerElement.value.position;
26
- if (pos) {
27
- if ("lat" in pos && typeof pos.lat === "function")
28
- return { lat: pos.lat(), lng: pos.lng() };
29
- return pos;
30
- }
31
- }
40
+ if (position)
41
+ return normalizeLatLng(position);
42
+ const markerPosition = markerContext?.advancedMarkerElement.value?.position;
43
+ if (markerPosition)
44
+ return normalizeLatLng(markerPosition);
32
45
  return void 0;
33
46
  }
34
47
  const ANCHOR_TRANSFORMS = {
@@ -42,21 +55,32 @@ const ANCHOR_TRANSFORMS = {
42
55
  "left-center": "translate(0, -50%)",
43
56
  "right-center": "translate(-100%, -50%)"
44
57
  };
45
- const overlayContent = useTemplateRef("overlay-content");
46
- const isPositioned = ref(false);
47
- 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
+ });
48
83
  const listeners = [];
49
- function setDataState(el, state) {
50
- el.dataset.state = state;
51
- const child = el.firstElementChild;
52
- if (child)
53
- child.dataset.state = state;
54
- }
55
- function hideElement(el) {
56
- el.style.visibility = "hidden";
57
- el.style.pointerEvents = "none";
58
- setDataState(el, "closed");
59
- }
60
84
  function panMapToFitOverlay(el, map, padding) {
61
85
  const child = el.firstElementChild;
62
86
  if (!child)
@@ -76,69 +100,59 @@ function panMapToFitOverlay(el, map, padding) {
76
100
  if (panX !== 0 || panY !== 0)
77
101
  map.panBy(panX, panY);
78
102
  }
79
- const overlay = useGoogleMapsResource({
80
- // ready condition accesses .value on ShallowRefs — tracked by whenever() in useGoogleMapsResource
81
- ready: () => !!overlayContent.value && !!(props.position || markerContext?.advancedMarkerElement.value),
82
- create({ mapsApi, map }) {
83
- const el = overlayContent.value;
84
- class CustomOverlay extends mapsApi.OverlayView {
85
- onAdd() {
86
- const panes = this.getPanes();
87
- if (panes) {
88
- panes[props.pane].appendChild(el);
89
- if (props.blockMapInteraction)
90
- mapsApi.OverlayView.preventMapHitsAndGesturesFrom(el);
91
- }
92
- if (props.panOnOpen) {
93
- const padding = typeof props.panOnOpen === "number" ? props.panOnOpen : 40;
94
- requestAnimationFrame(() => {
95
- panMapToFitOverlay(el, map, padding);
96
- });
97
- }
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);
98
112
  }
99
- draw() {
100
- if (open.value === false) {
101
- isPositioned.value = false;
102
- hideElement(el);
103
- return;
104
- }
105
- const position = getResolvedPosition();
106
- if (!position) {
107
- isPositioned.value = false;
108
- hideElement(el);
109
- return;
110
- }
111
- const projection = this.getProjection();
112
- if (!projection) {
113
- isPositioned.value = false;
114
- hideElement(el);
115
- return;
116
- }
117
- const pos = projection.fromLatLngToDivPixel(
118
- new mapsApi.LatLng(position.lat, position.lng)
119
- );
120
- if (!pos) {
121
- isPositioned.value = false;
122
- hideElement(el);
123
- return;
124
- }
125
- el.style.position = "absolute";
126
- el.style.left = `${pos.x + (props.offset?.x ?? 0)}px`;
127
- el.style.top = `${pos.y + (props.offset?.y ?? 0)}px`;
128
- el.style.transform = ANCHOR_TRANSFORMS[props.anchor];
129
- if (props.zIndex !== void 0)
130
- el.style.zIndex = String(props.zIndex);
131
- el.style.visibility = "visible";
132
- el.style.pointerEvents = "auto";
133
- setDataState(el, "open");
134
- 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
+ });
135
119
  }
136
- onRemove() {
137
- el.parentNode?.removeChild(el);
120
+ }
121
+ draw() {
122
+ if (open.value === false) {
123
+ overlayPosition.value = void 0;
124
+ return;
138
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 };
139
144
  }
140
- el.style.visibility = "hidden";
141
- 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);
142
156
  const ov = new CustomOverlay();
143
157
  ov.setMap(map);
144
158
  if (markerContext?.advancedMarkerElement.value) {
@@ -159,12 +173,8 @@ const overlay = useGoogleMapsResource({
159
173
  if (markerContext) {
160
174
  watch(
161
175
  () => {
162
- const pos = markerContext.advancedMarkerElement.value?.position;
163
- if (!pos)
164
- return void 0;
165
- if ("lat" in pos && typeof pos.lat === "function")
166
- return { lat: pos.lat(), lng: pos.lng() };
167
- return pos;
176
+ const markerPosition = markerContext.advancedMarkerElement.value?.position;
177
+ return markerPosition ? normalizeLatLng(markerPosition) : void 0;
168
178
  },
169
179
  () => {
170
180
  overlay.value?.draw();
@@ -172,7 +182,10 @@ if (markerContext) {
172
182
  );
173
183
  }
174
184
  watch(
175
- () => [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
+ },
176
189
  () => {
177
190
  overlay.value?.draw();
178
191
  }
@@ -182,7 +195,7 @@ watch(() => open.value, () => {
182
195
  return;
183
196
  overlay.value.draw();
184
197
  });
185
- watch([() => props.pane, () => props.blockMapInteraction], () => {
198
+ watch([() => pane, () => blockMapInteraction], () => {
186
199
  if (overlay.value) {
187
200
  const map = overlay.value.getMap();
188
201
  overlay.value.setMap(null);
@@ -194,7 +207,7 @@ if (markerClustererContext && markerContext) {
194
207
  watch(
195
208
  () => markerClustererContext.clusteringVersion.value,
196
209
  () => {
197
- if (!props.hideWhenClustered || open.value === false)
210
+ if (!hideWhenClustered || open.value === false)
198
211
  return;
199
212
  const clusterer = markerClustererContext.markerClusterer.value;
200
213
  if (!clusterer?.clusters)
@@ -210,13 +223,41 @@ if (markerClustererContext && markerContext) {
210
223
  }
211
224
  );
212
225
  }
213
- 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);
214
243
  </script>
215
244
 
216
245
  <template>
217
246
  <div style="display: none;">
218
- <div ref="overlay-content" :data-state="dataState" v-bind="$attrs">
219
- <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>
220
261
  </div>
221
262
  </div>
222
263
  </template>
@@ -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,32 +58,39 @@ type __VLS_Props = {
45
58
  * @default true
46
59
  */
47
60
  hideWhenClustered?: boolean;
48
- };
49
- type __VLS_ModelProps = {
50
- 'open'?: boolean;
51
- };
52
- type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
53
- declare var __VLS_1: {};
54
- type __VLS_Slots = {} & {
55
- default?: (props: typeof __VLS_1) => any;
56
- };
57
- declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
58
- overlay: import("vue").ShallowRef<google.maps.OverlayView | undefined>;
59
- dataState: import("vue").ComputedRef<"open" | "closed">;
60
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
61
- "update:open": (value: boolean) => any;
62
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
63
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
64
- }>, {
65
- anchor: OverlayAnchor;
66
- pane: OverlayPane;
67
- blockMapInteraction: boolean;
68
- panOnOpen: boolean | number;
69
- hideWhenClustered: boolean;
70
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
71
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __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 {
67
+ default?: () => any;
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
+ }
72
83
  declare const _default: typeof __VLS_export;
73
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>;
74
94
  type __VLS_WithSlots<T, S> = T & {
75
95
  new (): {
76
96
  $slots: S;
@@ -4,6 +4,7 @@ import { defu } from "defu";
4
4
  import { useHead, useRuntimeConfig } from "nuxt/app";
5
5
  import { withQuery } from "ufo";
6
6
  import { computed, onMounted, ref } from "vue";
7
+ import { useScriptProxyUrl } from "../../composables/useScriptProxyUrl";
7
8
  </script>
8
9
 
9
10
  <script setup>
@@ -29,10 +30,12 @@ const props = defineProps({
29
30
  objectFit: { type: String, required: false, default: "cover" },
30
31
  imgAttrs: { type: Object, required: false }
31
32
  });
33
+ defineSlots();
32
34
  const runtimeConfig = useRuntimeConfig();
33
35
  const proxyConfig = runtimeConfig.public["nuxt-scripts"]?.googleStaticMapsProxy;
34
36
  const apiKey = props.apiKey || scriptRuntimeConfig("googleMaps")?.apiKey;
35
37
  const useProxy = !props.apiKey && proxyConfig?.enabled;
38
+ const proxyUrl = useScriptProxyUrl();
36
39
  if (import.meta.dev) {
37
40
  if (!apiKey && !useProxy)
38
41
  console.warn("[nuxt-scripts] ScriptGoogleMapsStaticMap requires a Google Maps API key with Static Maps API access. Set NUXT_PUBLIC_SCRIPTS_GOOGLE_MAPS_API_KEY in your .env, or enable the proxy via `scripts.registry.googleMaps`.");
@@ -121,8 +124,10 @@ const src = computed(() => {
121
124
  if (query[key] === void 0)
122
125
  delete query[key];
123
126
  }
124
- const baseUrl = useProxy ? "/_scripts/proxy/google-static-maps" : "https://maps.googleapis.com/maps/api/staticmap";
125
- return withQuery(baseUrl, query);
127
+ if (useProxy) {
128
+ return proxyUrl("/_scripts/proxy/google-static-maps", query);
129
+ }
130
+ return withQuery("https://maps.googleapis.com/maps/api/staticmap", query);
126
131
  });
127
132
  const imgAttributes = computed(() => {
128
133
  return defu(props.imgAttrs, {
@@ -0,0 +1,42 @@
1
+ import type { InjectionKey, ShallowRef } from 'vue';
2
+ export interface MarkerClustererInstance {
3
+ render: () => void;
4
+ setMap: (map: google.maps.Map | null) => void;
5
+ addListener: (event: string, handler: () => void) => void;
6
+ addMarker: (marker: google.maps.marker.AdvancedMarkerElement | google.maps.Marker, noDraw?: boolean) => void;
7
+ removeMarker: (marker: google.maps.marker.AdvancedMarkerElement | google.maps.Marker, noDraw?: boolean) => boolean;
8
+ }
9
+ export interface MarkerClustererOptions {
10
+ markers?: google.maps.marker.AdvancedMarkerElement[];
11
+ algorithm?: unknown;
12
+ renderer?: unknown;
13
+ onClusterClick?: unknown;
14
+ }
15
+ export interface Cluster {
16
+ marker: google.maps.marker.AdvancedMarkerElement;
17
+ markers?: google.maps.marker.AdvancedMarkerElement[];
18
+ position: google.maps.LatLng;
19
+ bounds: google.maps.LatLngBounds | undefined;
20
+ count: number;
21
+ }
22
+ export interface ClusterStats {
23
+ markers: {
24
+ sum: number;
25
+ };
26
+ clusters: {
27
+ count: number;
28
+ markers: {
29
+ min: number;
30
+ max: number;
31
+ mean: number;
32
+ sum: number;
33
+ };
34
+ };
35
+ }
36
+ export interface MarkerClustererContext {
37
+ markerClusterer: ShallowRef<MarkerClustererInstance | undefined>;
38
+ requestRerender: () => void;
39
+ /** Increments after each clustering cycle; watch to detect cluster membership changes */
40
+ clusteringVersion: ShallowRef<number>;
41
+ }
42
+ export declare const MARKER_CLUSTERER_INJECTION_KEY: InjectionKey<MarkerClustererContext>;
@@ -0,0 +1 @@
1
+ export const MARKER_CLUSTERER_INJECTION_KEY = Symbol("marker-clusterer");
@@ -25,6 +25,56 @@ export interface GoogleMapsResourceContext {
25
25
  map: google.maps.Map;
26
26
  mapsApi: typeof google.maps;
27
27
  }
28
+ /**
29
+ * Normalizes a `LatLng | LatLngLiteral` value into a plain `LatLngLiteral`.
30
+ *
31
+ * Google's `LatLng` exposes coordinates via `.lat()`/`.lng()` methods, while
32
+ * `LatLngLiteral` exposes them as plain `lat`/`lng` numeric properties. The
33
+ * runtime distinguishes them by checking whether `.lat` is callable; this is
34
+ * preferred over `instanceof google.maps.LatLng` because mocked APIs in tests
35
+ * return plain objects rather than real `LatLng` instances.
36
+ */
37
+ export declare function normalizeLatLng(p: google.maps.LatLng | google.maps.LatLngLiteral): google.maps.LatLngLiteral;
38
+ /**
39
+ * Defines a deprecated property alias on an exposed object. Reading the alias
40
+ * returns the value of the canonical key and emits a one-shot
41
+ * `console.warn` (so repeated reads don't spam the console).
42
+ *
43
+ * Used to provide backward-compatible renames on `defineExpose` payloads
44
+ * without breaking existing template-ref consumers. Call sites should wrap
45
+ * this in `if (import.meta.dev)` so production builds skip the getter
46
+ * entirely and the alias stays a plain data property.
47
+ */
48
+ export declare function defineDeprecatedAlias<T extends object, K extends keyof T>(target: T, alias: string, canonicalKey: K, message: string): T;
49
+ /**
50
+ * Emits dev-mode deprecation warnings for the legacy top-level `center` and
51
+ * `zoom` props on `<ScriptGoogleMaps>`. Both props still work, but new code
52
+ * should pass them via `mapOptions` instead.
53
+ *
54
+ * Returns the number of warnings emitted (useful for tests).
55
+ */
56
+ export declare function warnDeprecatedTopLevelMapProps(props: {
57
+ center?: unknown;
58
+ zoom?: unknown;
59
+ }): number;
60
+ /**
61
+ * Wait until the Google Maps API and a Map instance are both available.
62
+ *
63
+ * Triggers script loading via `load()` if not already loaded. Uses an
64
+ * immediate watcher (matching `importLibrary`'s pattern) to avoid the race
65
+ * where `load()` resolves synchronously: a non-immediate watcher would miss
66
+ * the change and the promise would hang forever.
67
+ *
68
+ * Rejects if `status` enters an `'error'` state before both refs are populated.
69
+ * Runs the watcher inside a detached effect scope so it is safe to call from
70
+ * any context (component setup, exposed methods, tests).
71
+ */
72
+ export declare function waitForMapsReady({ mapsApi, map, status, load, }: {
73
+ mapsApi: ShallowRef<typeof google.maps | undefined>;
74
+ map: ShallowRef<google.maps.Map | undefined>;
75
+ status: Ref<string>;
76
+ load: () => Promise<unknown> | unknown;
77
+ }): Promise<void>;
28
78
  /**
29
79
  * Composable for safely managing Google Maps resource lifecycle.
30
80
  *
@@ -1,5 +1,5 @@
1
1
  import { whenever } from "@vueuse/core";
2
- import { inject, onUnmounted, ref, shallowRef } from "vue";
2
+ import { effectScope, inject, onUnmounted, ref, shallowRef, watch } from "vue";
3
3
  export const MAP_INJECTION_KEY = Symbol("map");
4
4
  export const MARKER_INJECTION_KEY = Symbol("marker");
5
5
  export function bindGoogleMapsEvents(instance, emit, config) {
@@ -10,6 +10,81 @@ export function bindGoogleMapsEvents(instance, emit, config) {
10
10
  instance.addListener(event, (payload) => emit(event, payload));
11
11
  });
12
12
  }
13
+ export function normalizeLatLng(p) {
14
+ if (typeof p.lat === "function") {
15
+ const ll = p;
16
+ return { lat: ll.lat(), lng: ll.lng() };
17
+ }
18
+ return { lat: p.lat, lng: p.lng };
19
+ }
20
+ export function defineDeprecatedAlias(target, alias, canonicalKey, message) {
21
+ let warned = false;
22
+ Object.defineProperty(target, alias, {
23
+ get() {
24
+ if (!warned) {
25
+ warned = true;
26
+ console.warn(message);
27
+ }
28
+ return target[canonicalKey];
29
+ },
30
+ enumerable: true,
31
+ configurable: true
32
+ });
33
+ return target;
34
+ }
35
+ export function warnDeprecatedTopLevelMapProps(props) {
36
+ let warned = 0;
37
+ if (props.center !== void 0) {
38
+ warned++;
39
+ console.warn(
40
+ '[nuxt-scripts] <ScriptGoogleMaps> prop "center" is deprecated; use `:map-options="{ center: ... }"` instead. See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1'
41
+ );
42
+ }
43
+ if (props.zoom !== void 0) {
44
+ warned++;
45
+ console.warn(
46
+ '[nuxt-scripts] <ScriptGoogleMaps> prop "zoom" is deprecated; use `:map-options="{ zoom: ... }"` instead. See https://scripts.nuxt.com/docs/migration-guide/v0-to-v1'
47
+ );
48
+ }
49
+ return warned;
50
+ }
51
+ export async function waitForMapsReady({
52
+ mapsApi,
53
+ map,
54
+ status,
55
+ load
56
+ }) {
57
+ if (mapsApi.value && map.value)
58
+ return;
59
+ if (status.value === "error")
60
+ throw new Error("Google Maps script failed to load");
61
+ await load();
62
+ if (mapsApi.value && map.value)
63
+ return;
64
+ if (status.value === "error")
65
+ throw new Error("Google Maps script failed to load");
66
+ const scope = effectScope(true);
67
+ try {
68
+ await new Promise((resolve, reject) => {
69
+ scope.run(() => {
70
+ watch(
71
+ [mapsApi, map, status],
72
+ ([api, m, s]) => {
73
+ if (api && m) {
74
+ resolve();
75
+ return;
76
+ }
77
+ if (s === "error")
78
+ reject(new Error("Google Maps script failed to load"));
79
+ },
80
+ { immediate: true }
81
+ );
82
+ });
83
+ });
84
+ } finally {
85
+ scope.stop();
86
+ }
87
+ }
13
88
  export function useGoogleMapsResource({
14
89
  ready,
15
90
  create,