From 4380b074504a0b9570495f14d159f4e70ed7df88 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Thu, 9 Apr 2026 22:21:04 +1000 Subject: [PATCH 1/3] refactor(google-maps): export typed interfaces, internal cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Splits the safe, additive changes out of #689 so they can land independently of the larger breaking refactor. - Export `ScriptGoogleMapsProps`/`Emits`/`Slots`/`Expose` and the matching `ScriptGoogleMapsOverlayView*` interfaces so consumers can type their template refs and event handlers. - Modernise internal vars: `useTemplateRef` for `rootEl`/`mapEl`, `mapsApi` switched to `shallowRef`, internal `ready` ref renamed to `isMapReady` for clearer intent. - Tidy `resolveQueryToLatLng` so the cache always returns a consistent `LatLngLiteral` shape. - Collapse the color-mode logic into a single computed. - Use `instanceof google.maps.LatLng` to normalise marker positions in the overlay component. - Drop the `styled.vue` playground page; it relied on the deprecated `styles` map option which conflicts with `mapId`. No public API changes — `center`/`zoom` props, `googleMaps` expose, `ready` event payload, location-query auto-resolution, and the `setCenter` skip-if-equal optimisation are all preserved. --- .../GoogleMaps/ScriptGoogleMaps.vue | 218 +++++++++++------- .../ScriptGoogleMapsOverlayView.vue | 81 ++++--- playground/pages/index.vue | 6 - .../third-parties/google-maps/styled.vue | 19 -- 4 files changed, 186 insertions(+), 138 deletions(-) delete mode 100644 playground/pages/third-parties/google-maps/styled.vue diff --git a/packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue b/packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue index 5ae811fb..5a509d0f 100644 --- a/packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +++ b/packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue @@ -2,26 +2,13 @@ /// import type { ElementScriptTrigger } from '#nuxt-scripts/types' import type { HTMLAttributes, ReservedProps, ShallowRef } from 'vue' -import { useScriptTriggerElement } from '#nuxt-scripts/composables/useScriptTriggerElement' -import { useScriptGoogleMaps } from '#nuxt-scripts/registry/google-maps' -import { scriptRuntimeConfig, scriptsPrefix } from '#nuxt-scripts/utils' -import { defu } from 'defu' -import { tryUseNuxtApp, useHead, useRuntimeConfig } from 'nuxt/app' -import { computed, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, useAttrs, watch } from 'vue' -import ScriptAriaLoadingIndicator from '../ScriptAriaLoadingIndicator.vue' - -import { MAP_INJECTION_KEY } from './useGoogleMapsResource' - -const DIGITS_ONLY_RE = /^\d+$/ -const DIGITS_PX_RE = /^\d+px$/i export { MAP_INJECTION_KEY } from './useGoogleMapsResource' - - + + + +