@nuxt/scripts 1.0.2 → 1.0.4

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 (44) hide show
  1. package/dist/devtools-client/200.html +1 -1
  2. package/dist/devtools-client/404.html +1 -1
  3. package/dist/devtools-client/_nuxt/{DBnmHlYd.js → 13TuIchK.js} +1 -1
  4. package/dist/devtools-client/_nuxt/{BBkg4uxE.js → 32RpwIYg.js} +1 -1
  5. package/dist/devtools-client/_nuxt/BQOW0dqa.js +188 -0
  6. package/dist/devtools-client/_nuxt/{348WW8S2.js → C0p4l2Wy.js} +1 -1
  7. package/dist/devtools-client/_nuxt/{B6vzhpP9.js → CWELSfs5.js} +1 -1
  8. package/dist/devtools-client/_nuxt/DxyiGojb.js +1 -0
  9. package/dist/devtools-client/_nuxt/{Bo8cAJTo.js → NMrm-PBR.js} +1 -1
  10. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  11. package/dist/devtools-client/_nuxt/builds/meta/41edb1f4-fb21-4848-be40-543a397dc212.json +1 -0
  12. package/dist/devtools-client/_nuxt/entry.XOvcedFq.css +1 -0
  13. package/dist/devtools-client/_nuxt/error-404.CmHnDJ22.css +1 -0
  14. package/dist/devtools-client/_nuxt/error-500.C0mC5XzU.css +1 -0
  15. package/dist/devtools-client/docs/index.html +1 -1
  16. package/dist/devtools-client/first-party/index.html +1 -1
  17. package/dist/devtools-client/index.html +1 -1
  18. package/dist/devtools-client/registry/index.html +1 -1
  19. package/dist/module.json +1 -1
  20. package/dist/module.mjs +1 -1
  21. package/dist/registry.mjs +16 -3
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +39 -4
  23. package/dist/runtime/server/bluesky-embed-image.d.ts +1 -1
  24. package/dist/runtime/server/bluesky-embed.d.ts +1 -1
  25. package/dist/runtime/server/google-maps-geocode-proxy.d.ts +1 -1
  26. package/dist/runtime/server/google-static-maps-proxy.d.ts +1 -1
  27. package/dist/runtime/server/gravatar-proxy.d.ts +1 -1
  28. package/dist/runtime/server/instagram-embed-asset.d.ts +1 -1
  29. package/dist/runtime/server/instagram-embed-image.d.ts +1 -1
  30. package/dist/runtime/server/instagram-embed.d.ts +1 -1
  31. package/dist/runtime/server/proxy-handler.js +4 -4
  32. package/dist/runtime/server/utils/image-proxy.d.ts +1 -1
  33. package/dist/runtime/server/utils/match-domain.d.ts +1 -0
  34. package/dist/runtime/server/utils/match-domain.js +20 -0
  35. package/dist/runtime/server/utils/withSigning.d.ts +1 -1
  36. package/dist/runtime/server/x-embed-image.d.ts +1 -1
  37. package/dist/runtime/server/x-embed.d.ts +1 -48
  38. package/package.json +3 -3
  39. package/dist/devtools-client/_nuxt/builds/meta/831017e7-487a-40a4-83f3-dd537354844c.json +0 -1
  40. package/dist/devtools-client/_nuxt/entry.BKkVrcJj.css +0 -1
  41. package/dist/devtools-client/_nuxt/error-404.B3yGjJCG.css +0 -1
  42. package/dist/devtools-client/_nuxt/error-500.njrud7Pk.css +0 -1
  43. package/dist/devtools-client/_nuxt/fSf6EEYR.js +0 -188
  44. package/dist/devtools-client/_nuxt/r9yOu_bc.js +0 -1
package/dist/module.mjs CHANGED
@@ -1060,7 +1060,7 @@ function NuxtScriptBundleTransformer(options = {
1060
1060
  const hasReverseProxy = !!script?.proxy;
1061
1061
  const proxyConfigKey = hasReverseProxy ? typeof script?.proxy === "string" ? script.proxy : registryKey : void 0;
1062
1062
  const proxyConfig = !firstPartyOptOut && proxyConfigKey ? options.proxyConfigs?.[proxyConfigKey] : void 0;
1063
- const proxyRewrites = proxyConfig?.domains?.map((domain) => ({
1063
+ const proxyRewrites = proxyConfig?.domains?.filter((domain) => !domain.includes("*")).map((domain) => ({
1064
1064
  from: domain,
1065
1065
  to: `${options.proxyPrefix}/${domain}`
1066
1066
  }));
package/dist/registry.mjs CHANGED
@@ -266,7 +266,11 @@ async function registry(resolve) {
266
266
  const host = region === "eu" ? "eu.i.posthog.com" : "us.i.posthog.com";
267
267
  return `${proxyPrefix}/${host}`;
268
268
  }
269
- }
269
+ },
270
+ // PostHog supports `apiHost` for self-hosted instances and custom
271
+ // reverse proxies. Without this, custom-host users are 403'd through
272
+ // the proxy because only the SaaS US/EU hosts are allowlisted.
273
+ configDomainFields: ["apiHost"]
270
274
  }
271
275
  }),
272
276
  def("fathomAnalytics", {
@@ -508,7 +512,13 @@ async function registry(resolve) {
508
512
  }
509
513
  },
510
514
  proxy: {
511
- domains: ["www.clarity.ms", "scripts.clarity.ms", "d.clarity.ms", "e.clarity.ms", "k.clarity.ms", "c.clarity.ms", "a.clarity.ms", "b.clarity.ms"],
515
+ // Clarity buckets visitors across letter/hash-prefixed shards (a/b/c/d/e/k/...).
516
+ // Microsoft adds shards over time, so an enumerated list silently 403s
517
+ // through the proxy when an unlisted letter is rolled out (#728-class bug).
518
+ // `*.clarity.ms` covers the full surface at runtime; `www.clarity.ms` is
519
+ // kept literal so the build-time URL rewrite (which filters wildcards)
520
+ // can still rewrite `https://www.clarity.ms/tag/<id>` in bundled SDKs.
521
+ domains: ["www.clarity.ms", "*.clarity.ms"],
512
522
  privacy: PRIVACY_HEATMAP
513
523
  },
514
524
  partytown: { forwards: ["clarity"] }
@@ -667,7 +677,10 @@ async function registry(resolve) {
667
677
  }
668
678
  },
669
679
  proxy: {
670
- domains: ["www.google-analytics.com", "analytics.google.com", "stats.g.doubleclick.net", "pagead2.googlesyndication.com", "www.googleadservices.com", "googleads.g.doubleclick.net", "www.google.com", "www.googletagmanager.com"],
680
+ // `www.google.com` covers static URLs (www.google.com/g/collect) rewritten at build time;
681
+ // `www.google.*` covers the geo-localized ga-audiences beacon, which gtag.js dynamically
682
+ // fires to the visitor's local Google cctld (www.google.com.tw, www.google.co.jp, ...).
683
+ domains: ["www.google-analytics.com", "analytics.google.com", "stats.g.doubleclick.net", "pagead2.googlesyndication.com", "www.googleadservices.com", "googleads.g.doubleclick.net", "www.google.com", "www.google.*", "www.googletagmanager.com"],
671
684
  privacy: PRIVACY_HEATMAP
672
685
  },
673
686
  partytown: { forwards: ["dataLayer.push", "gtag"] }
@@ -8,7 +8,7 @@ import { useScriptGoogleMaps } from "#nuxt-scripts/registry/google-maps";
8
8
  import { scriptRuntimeConfig, scriptsPrefix } from "#nuxt-scripts/utils";
9
9
  import { defu } from "defu";
10
10
  import { tryUseNuxtApp, useHead, useRuntimeConfig } from "nuxt/app";
11
- import { computed, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, useAttrs, useTemplateRef, watch } from "vue";
11
+ import { computed, nextTick, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, useAttrs, useTemplateRef, watch } from "vue";
12
12
  import ScriptAriaLoadingIndicator from "../ScriptAriaLoadingIndicator.vue";
13
13
  import { defineDeprecatedAlias, MAP_INJECTION_KEY, waitForMapsReady, warnDeprecatedTopLevelMapProps } from "./useGoogleMapsResource";
14
14
  const props = defineProps({
@@ -42,6 +42,11 @@ const currentMapId = computed(() => {
42
42
  return props.mapOptions?.mapId;
43
43
  return props.mapIds[currentColorMode.value] || props.mapIds.light || props.mapOptions?.mapId;
44
44
  });
45
+ const currentColorScheme = computed(() => {
46
+ if (!props.mapIds && !props.colorMode && !nuxtColorMode.value)
47
+ return void 0;
48
+ return currentColorMode.value === "dark" ? "DARK" : "LIGHT";
49
+ });
45
50
  const mapsApi = shallowRef();
46
51
  if (import.meta.dev) {
47
52
  if (!apiKey)
@@ -76,13 +81,14 @@ const { load, status, onLoaded } = useScriptGoogleMaps({
76
81
  const options = computed(() => {
77
82
  const mapId = props.mapOptions?.styles ? void 0 : currentMapId.value || "DEMO_MAP_ID";
78
83
  return defu(
79
- { center: centerOverride.value, mapId },
84
+ { center: centerOverride.value, mapId, colorScheme: currentColorScheme.value },
80
85
  props.mapOptions,
81
86
  { center: props.center, zoom: props.zoom },
82
87
  { zoom: 15 }
83
88
  );
84
89
  });
85
90
  const isMapReady = ref(false);
91
+ const slotMounted = ref(true);
86
92
  const map = shallowRef();
87
93
  function isLocationQuery(s) {
88
94
  return typeof s === "string" && (s.split(",").length > 2 || s.includes("+"));
@@ -191,13 +197,42 @@ onMounted(() => {
191
197
  watch(options, () => {
192
198
  if (!map.value)
193
199
  return;
194
- const { center: _, zoom: __, ...rest } = options.value;
200
+ const { center: _, zoom: __, mapId: ___, colorScheme: ____, ...rest } = options.value;
195
201
  map.value.setOptions(rest);
196
202
  });
203
+ watch([currentMapId, currentColorScheme], async ([newMapId, newScheme], [oldMapId, oldScheme]) => {
204
+ if (!map.value || !mapsApi.value || !mapEl.value)
205
+ return;
206
+ if (newMapId === oldMapId && newScheme === oldScheme)
207
+ return;
208
+ const center = map.value.getCenter();
209
+ const zoom = map.value.getZoom();
210
+ if (center)
211
+ centerOverride.value = { lat: center.lat(), lng: center.lng() };
212
+ map.value.unbindAll();
213
+ map.value = void 0;
214
+ slotMounted.value = false;
215
+ if (mapEl.value)
216
+ mapEl.value.innerHTML = "";
217
+ await nextTick();
218
+ if (!mapEl.value || !mapsApi.value)
219
+ return;
220
+ const _options = {
221
+ ...options.value,
222
+ center: center ? { lat: center.lat(), lng: center.lng() } : options.value.center,
223
+ zoom: zoom ?? options.value.zoom
224
+ };
225
+ map.value = new mapsApi.value.Map(mapEl.value, _options);
226
+ slotMounted.value = true;
227
+ emits("ready", exposed);
228
+ });
197
229
  watch(() => options.value.zoom, (zoom) => {
198
230
  if (map.value && zoom != null)
199
231
  map.value.setZoom(zoom);
200
232
  });
233
+ watch([() => props.center, () => props.mapOptions?.center], () => {
234
+ centerOverride.value = void 0;
235
+ });
201
236
  watch([() => options.value.center, isMapReady, map], async (next) => {
202
237
  if (!map.value) {
203
238
  return;
@@ -294,6 +329,6 @@ onBeforeUnmount(() => {
294
329
  </slot>
295
330
  <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
296
331
  <slot v-else-if="status === 'error'" name="error" />
297
- <slot />
332
+ <slot v-if="slotMounted" />
298
333
  </div>
299
334
  </template>
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Record<string, any>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  export { proxyAssetUrl, proxyImageUrl, rewriteUrl, rewriteUrlsInText, scopeCss } from './utils/instagram-embed.js';
2
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string>>;
2
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
3
3
  export default _default;
@@ -1,5 +1,6 @@
1
- import { createError, defineEventHandler, getHeaders, getQuery, getRequestIP, getRequestWebStream, readBody, setResponseHeader } from "h3";
1
+ import { createError, defineEventHandler, getHeaders, getQuery, getRequestIP, getRequestWebStream, readBody, setResponseHeader, setResponseStatus } from "h3";
2
2
  import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
3
+ import { matchDomain } from "./utils/match-domain.js";
3
4
  import {
4
5
  anonymizeIP,
5
6
  mergePrivacy,
@@ -51,7 +52,7 @@ export default defineEventHandler(async (event) => {
51
52
  }
52
53
  let perScriptInput;
53
54
  for (const [configDomain, privacyInput] of Object.entries(domainPrivacy)) {
54
- if (domain === configDomain || domain.endsWith(`.${configDomain}`)) {
55
+ if (matchDomain(domain, configDomain)) {
55
56
  perScriptInput = privacyInput;
56
57
  break;
57
58
  }
@@ -264,8 +265,7 @@ export default defineEventHandler(async (event) => {
264
265
  setResponseHeader(event, key, value);
265
266
  }
266
267
  });
267
- event.node.res.statusCode = response.status;
268
- event.node.res.statusMessage = response.statusText;
268
+ setResponseStatus(event, response.status, response.statusText);
269
269
  const responseContentType = response.headers.get("content-type") || "";
270
270
  const isTextContent = responseContentType.includes("text") || responseContentType.includes("javascript") || responseContentType.includes("json");
271
271
  if (isTextContent) {
@@ -11,4 +11,4 @@ export interface ImageProxyConfig {
11
11
  /** Unique name for the nitro cache group (defaults to derived from allowedDomains). */
12
12
  cacheName?: string;
13
13
  }
14
- export declare function createImageProxyHandler(config: ImageProxyConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
14
+ export declare function createImageProxyHandler(config: ImageProxyConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
@@ -0,0 +1 @@
1
+ export declare function matchDomain(domain: string, pattern: string): boolean;
@@ -0,0 +1,20 @@
1
+ const TLD_WILDCARD_RE = /^(?:com|[a-z]{2}|(?:com|co)\.[a-z]{2})$/i;
2
+ const SUBDOMAIN_LABEL_RE = /^[^.]+$/;
3
+ export function matchDomain(domain, pattern) {
4
+ if (!pattern.includes("*"))
5
+ return domain === pattern || domain.endsWith(`.${pattern}`);
6
+ if (pattern.startsWith("*.") && pattern.indexOf("*") === 0) {
7
+ const suffix = pattern.slice(2);
8
+ if (!domain.endsWith(`.${suffix}`))
9
+ return false;
10
+ const label = domain.slice(0, -(suffix.length + 1));
11
+ return SUBDOMAIN_LABEL_RE.test(label);
12
+ }
13
+ if (!pattern.endsWith("*") || pattern.indexOf("*") !== pattern.length - 1)
14
+ return false;
15
+ const prefix = pattern.slice(0, -1);
16
+ if (!domain.startsWith(prefix))
17
+ return false;
18
+ const tld = domain.slice(prefix.length);
19
+ return TLD_WILDCARD_RE.test(tld);
20
+ }
@@ -20,4 +20,4 @@
20
20
  * never reach the upstream fetch and cannot consume API quota.
21
21
  */
22
22
  import type { EventHandler, EventHandlerRequest, EventHandlerResponse } from 'h3';
23
- export declare function withSigning<Req extends EventHandlerRequest = EventHandlerRequest, Res extends EventHandlerResponse = EventHandlerResponse>(handler: EventHandler<Req, Res>): EventHandler<Req, Res>;
23
+ export declare function withSigning<Req extends EventHandlerRequest = EventHandlerRequest, Res extends EventHandlerResponse = EventHandlerResponse>(handler: EventHandler<Req, Res>): EventHandler<Req, any>;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Buffer<ArrayBufferLike>>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
2
2
  export default _default;
@@ -1,49 +1,2 @@
1
- interface TweetData {
2
- id_str: string;
3
- text: string;
4
- created_at: string;
5
- favorite_count: number;
6
- conversation_count: number;
7
- user: {
8
- name: string;
9
- screen_name: string;
10
- profile_image_url_https: string;
11
- verified?: boolean;
12
- is_blue_verified?: boolean;
13
- };
14
- entities?: {
15
- media?: Array<{
16
- media_url_https: string;
17
- type: string;
18
- sizes: Record<string, {
19
- w: number;
20
- h: number;
21
- }>;
22
- }>;
23
- urls?: Array<{
24
- url: string;
25
- expanded_url: string;
26
- display_url: string;
27
- }>;
28
- };
29
- photos?: Array<{
30
- url: string;
31
- width: number;
32
- height: number;
33
- }>;
34
- video?: {
35
- poster: string;
36
- variants: Array<{
37
- type: string;
38
- src: string;
39
- }>;
40
- };
41
- quoted_tweet?: TweetData;
42
- parent?: {
43
- user: {
44
- screen_name: string;
45
- };
46
- };
47
- }
48
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<TweetData>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, any>;
49
2
  export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/scripts",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "description": "Load third-party scripts with better performance, privacy and DX in Nuxt Apps.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -112,10 +112,10 @@
112
112
  "magic-string": "^0.30.21",
113
113
  "ofetch": "^1.5.1",
114
114
  "ohash": "^2.0.11",
115
- "oxc-parser": "^0.127.0",
115
+ "oxc-parser": "^0.128.0",
116
116
  "oxc-walker": "^0.7.0",
117
117
  "pathe": "^2.0.3",
118
- "pkg-types": "^2.3.0",
118
+ "pkg-types": "^2.3.1",
119
119
  "sirv": "^3.0.2",
120
120
  "std-env": "^4.1.0",
121
121
  "ufo": "^1.6.3",
@@ -1 +0,0 @@
1
- {"id":"831017e7-487a-40a4-83f3-dd537354844c","timestamp":1776929246336,"prerendered":[]}