@nuxt/scripts 1.2.1 → 1.3.1

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 (46) 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/-l_Ea-OJ.js +1 -0
  4. package/dist/devtools-client/_nuxt/3x0vfy9V.js +1 -0
  5. package/dist/devtools-client/_nuxt/BXHESzkh.js +1 -0
  6. package/dist/devtools-client/_nuxt/Bc00m62Q.js +1 -0
  7. package/dist/devtools-client/_nuxt/CuXL8tZi.js +1 -0
  8. package/dist/devtools-client/_nuxt/D5fxpUga.js +1 -0
  9. package/dist/devtools-client/_nuxt/DLLLjYUR.js +195 -0
  10. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  11. package/dist/devtools-client/_nuxt/builds/meta/a20c007a-cd1e-42bf-8c21-eebe97e5bdd1.json +1 -0
  12. package/dist/devtools-client/_nuxt/entry.DehJww9T.css +1 -0
  13. package/dist/devtools-client/_nuxt/error-404.BmTWJpVN.css +1 -0
  14. package/dist/devtools-client/_nuxt/error-500.DxASQRq7.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.d.mts +29 -1
  20. package/dist/module.d.ts +29 -1
  21. package/dist/module.json +1 -1
  22. package/dist/module.mjs +234 -11
  23. package/dist/registry.d.mts +5 -2
  24. package/dist/registry.d.ts +5 -2
  25. package/dist/registry.mjs +12 -4
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +2 -0
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +2 -0
  28. package/dist/runtime/composables/useScript.js +7 -2
  29. package/dist/runtime/registry/vimeo-player.d.ts +1 -2
  30. package/dist/runtime/registry/youtube-player.d.ts +1 -2
  31. package/dist/runtime/server/proxy-handler.js +3 -2
  32. package/dist/runtime/server/utils/match-domain.js +1 -1
  33. package/dist/runtime/types.d.ts +31 -1
  34. package/dist/runtime/utils.js +10 -1
  35. package/package.json +11 -8
  36. package/dist/devtools-client/_nuxt/BTXw0v4h.js +0 -1
  37. package/dist/devtools-client/_nuxt/Bf6N2ObH.js +0 -1
  38. package/dist/devtools-client/_nuxt/C5Bq9Qgz.js +0 -1
  39. package/dist/devtools-client/_nuxt/CSw0kWhI.js +0 -1
  40. package/dist/devtools-client/_nuxt/DWvCkA0U.js +0 -195
  41. package/dist/devtools-client/_nuxt/TPgAGQc8.js +0 -1
  42. package/dist/devtools-client/_nuxt/builds/meta/32b705e4-fcb6-4eea-92d5-dbdced5169df.json +0 -1
  43. package/dist/devtools-client/_nuxt/dvDf1_6X.js +0 -1
  44. package/dist/devtools-client/_nuxt/entry.VwiedW44.css +0 -1
  45. package/dist/devtools-client/_nuxt/error-404.DBJH6QEN.css +0 -1
  46. package/dist/devtools-client/_nuxt/error-500.BIIPjeaA.css +0 -1
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.VwiedW44.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DWvCkA0U.js"><script type="module" src="/__nuxt-scripts/_nuxt/DWvCkA0U.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"32b705e4-fcb6-4eea-92d5-dbdced5169df",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1780417333058,false]</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.DehJww9T.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DLLLjYUR.js"><script type="module" src="/__nuxt-scripts/_nuxt/DLLLjYUR.js" crossorigin></script><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/B8PEiB0p.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/Cp-IABpG.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/wDzz0qaB.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CVO1_9PV.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/D0r3Knsf.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-scripts/_nuxt/error-500.DxASQRq7.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/D5fxpUga.js"><script>"use strict";(()=>{const o=window,e=document.documentElement,c=["dark","light"],s=getStorageValue("localStorage","nuxt-color-mode")||"system";let r=s==="system"?f():s;const l=e.getAttribute("data-color-mode-forced");l&&(r=l),i(r),o["__NUXT_COLOR_MODE__"]={preference:s,value:r,getColorScheme:f,addColorScheme:i,removeColorScheme:d};function i(t){const a=""+t+"",n="";e.classList?e.classList.add(a):e.className+=" "+a,n&&e.setAttribute("data-"+n,t)}function d(t){const a=""+t+"",n="";e.classList?e.classList.remove(a):e.className=e.className.replace(new RegExp(a,"g"),""),n&&e.removeAttribute("data-"+n)}function u(t){return o.matchMedia("(prefers-color-scheme"+t+")")}function f(){if(o.matchMedia&&u("").media!=="not all"){for(const t of c)if(u(":"+t).matches)return t}return"light"}})();function getStorageValue(o,e){switch(o){case"localStorage":try{return window.localStorage.getItem(e)}catch{return null}case"sessionStorage":try{return window.sessionStorage.getItem(e)}catch{return null}case"cookie":try{return getCookie(e)}catch{return null}default:return null}}function getCookie(o){const c=("; "+window.document.cookie).split("; "+o+"=");if(c.length===2){const s=c.pop();return s?s.split(";").shift():null}}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"a20c007a-cd1e-42bf-8c21-eebe97e5bdd1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1784001639492,false]</script></body></html>
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.VwiedW44.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DWvCkA0U.js"><script type="module" src="/__nuxt-scripts/_nuxt/DWvCkA0U.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"32b705e4-fcb6-4eea-92d5-dbdced5169df",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1780417333058,false]</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.DehJww9T.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DLLLjYUR.js"><script type="module" src="/__nuxt-scripts/_nuxt/DLLLjYUR.js" crossorigin></script><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/B8PEiB0p.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/Cp-IABpG.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/wDzz0qaB.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CVO1_9PV.js"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/D0r3Knsf.js"><link rel="prefetch" as="style" crossorigin href="/__nuxt-scripts/_nuxt/error-500.DxASQRq7.css"><link rel="prefetch" as="script" crossorigin href="/__nuxt-scripts/_nuxt/D5fxpUga.js"><script>"use strict";(()=>{const o=window,e=document.documentElement,c=["dark","light"],s=getStorageValue("localStorage","nuxt-color-mode")||"system";let r=s==="system"?f():s;const l=e.getAttribute("data-color-mode-forced");l&&(r=l),i(r),o["__NUXT_COLOR_MODE__"]={preference:s,value:r,getColorScheme:f,addColorScheme:i,removeColorScheme:d};function i(t){const a=""+t+"",n="";e.classList?e.classList.add(a):e.className+=" "+a,n&&e.setAttribute("data-"+n,t)}function d(t){const a=""+t+"",n="";e.classList?e.classList.remove(a):e.className=e.className.replace(new RegExp(a,"g"),""),n&&e.removeAttribute("data-"+n)}function u(t){return o.matchMedia("(prefers-color-scheme"+t+")")}function f(){if(o.matchMedia&&u("").media!=="not all"){for(const t of c)if(u(":"+t).matches)return t}return"light"}})();function getStorageValue(o,e){switch(o){case"localStorage":try{return window.localStorage.getItem(e)}catch{return null}case"sessionStorage":try{return window.sessionStorage.getItem(e)}catch{return null}case"cookie":try{return getCookie(e)}catch{return null}default:return null}}function getCookie(o){const c=("; "+window.document.cookie).split("; "+o+"=");if(c.length===2){const s=c.pop();return s?s.split(";").shift():null}}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"a20c007a-cd1e-42bf-8c21-eebe97e5bdd1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1784001639492,false]</script></body></html>
package/dist/module.d.mts CHANGED
@@ -3,6 +3,17 @@ import { FetchOptions } from 'ofetch';
3
3
  import { RegistryScripts, FirstPartyPrivacy, NuxtConfigScriptRegistry, NuxtUseScriptOptionsSerializable, NuxtUseScriptInput, ResolvedProxyAutoInject, ProxyConfig } from '../dist/runtime/types.js';
4
4
  export { FirstPartyPrivacy } from '../dist/runtime/types.js';
5
5
 
6
+ /**
7
+ * Proxy path alias configuration.
8
+ * - `false` / `undefined`: proxy paths use the verbatim third-party hostname
9
+ * (`/_scripts/p/us.i.posthog.com/...`).
10
+ * - `true`: every proxied domain gets a short deterministic opaque alias
11
+ * (`/_scripts/p/a1b2c3d4/...`), so the real hostname never appears in client URLs.
12
+ * - `Record<domain, alias>`: explicit aliases (domain → alias). Domains not listed
13
+ * keep their verbatim hostname.
14
+ */
15
+ type ProxyAliasConfig = boolean | Record<string, string> | undefined;
16
+
6
17
  interface ResolvedProxySecret {
7
18
  secret: string;
8
19
  /** True when the secret exists only in memory (dev-only fallback; won't survive restarts). */
@@ -21,7 +32,7 @@ interface ResolvedProxySecret {
21
32
  */
22
33
  declare function resolveProxySecret(rootDir: string, isDev: boolean, configSecret?: string, autoGenerate?: boolean): ResolvedProxySecret | undefined;
23
34
  declare function isProxyDisabled(registryKey: string, registry?: NuxtConfigScriptRegistry, runtimeConfig?: Record<string, any>): boolean;
24
- declare function applyAutoInject(registry: NuxtConfigScriptRegistry, runtimeConfig: Record<string, any>, proxyPrefix: string, registryKey: string, autoInject: ResolvedProxyAutoInject): void;
35
+ declare function applyAutoInject(registry: NuxtConfigScriptRegistry, runtimeConfig: Record<string, any>, proxyPrefix: string, registryKey: string, autoInject: ResolvedProxyAutoInject, alias?: ProxyAliasConfig): void;
25
36
  declare function resolveConfiguredProxyDomains(config: Record<string, any> | undefined, proxyConfig?: Pick<ProxyConfig, 'autoInject' | 'configDomainFields'>): string[];
26
37
  /**
27
38
  * Compute missing required fields for a registry entry, using the merged
@@ -50,6 +61,23 @@ interface ModuleOptions {
50
61
  * @default undefined (per-script defaults)
51
62
  */
52
63
  privacy?: FirstPartyPrivacy;
64
+ /**
65
+ * First-party proxy behaviour.
66
+ */
67
+ proxy?: {
68
+ /**
69
+ * Replace third-party hostnames in proxy paths with aliases, so the real domain
70
+ * (e.g. a self-hosted analytics host) never appears in client-facing URLs.
71
+ *
72
+ * - `false` (default): paths embed the verbatim hostname (`/_scripts/p/us.i.posthog.com/...`)
73
+ * - `true`: auto-generate a short opaque alias per domain (`/_scripts/p/a1b2c3d4/...`)
74
+ * - `Record<domain, alias>`: explicit aliases (domain → alias); unlisted domains stay verbatim
75
+ *
76
+ * @default false
77
+ * @example { 'us.i.posthog.com': 'ph', 'analytics.internal.example.com': 'a' }
78
+ */
79
+ alias?: ProxyAliasConfig;
80
+ };
53
81
  /**
54
82
  * The registry of supported third-party scripts. Presence enables infrastructure (proxy routes, types, bundling, composable auto-imports).
55
83
  * Scripts only auto-load globally when `trigger` is explicitly set in the config object.
package/dist/module.d.ts CHANGED
@@ -3,6 +3,17 @@ import { FetchOptions } from 'ofetch';
3
3
  import { RegistryScripts, FirstPartyPrivacy, NuxtConfigScriptRegistry, NuxtUseScriptOptionsSerializable, NuxtUseScriptInput, ResolvedProxyAutoInject, ProxyConfig } from '../dist/runtime/types.js';
4
4
  export { FirstPartyPrivacy } from '../dist/runtime/types.js';
5
5
 
6
+ /**
7
+ * Proxy path alias configuration.
8
+ * - `false` / `undefined`: proxy paths use the verbatim third-party hostname
9
+ * (`/_scripts/p/us.i.posthog.com/...`).
10
+ * - `true`: every proxied domain gets a short deterministic opaque alias
11
+ * (`/_scripts/p/a1b2c3d4/...`), so the real hostname never appears in client URLs.
12
+ * - `Record<domain, alias>`: explicit aliases (domain → alias). Domains not listed
13
+ * keep their verbatim hostname.
14
+ */
15
+ type ProxyAliasConfig = boolean | Record<string, string> | undefined;
16
+
6
17
  interface ResolvedProxySecret {
7
18
  secret: string;
8
19
  /** True when the secret exists only in memory (dev-only fallback; won't survive restarts). */
@@ -21,7 +32,7 @@ interface ResolvedProxySecret {
21
32
  */
22
33
  declare function resolveProxySecret(rootDir: string, isDev: boolean, configSecret?: string, autoGenerate?: boolean): ResolvedProxySecret | undefined;
23
34
  declare function isProxyDisabled(registryKey: string, registry?: NuxtConfigScriptRegistry, runtimeConfig?: Record<string, any>): boolean;
24
- declare function applyAutoInject(registry: NuxtConfigScriptRegistry, runtimeConfig: Record<string, any>, proxyPrefix: string, registryKey: string, autoInject: ResolvedProxyAutoInject): void;
35
+ declare function applyAutoInject(registry: NuxtConfigScriptRegistry, runtimeConfig: Record<string, any>, proxyPrefix: string, registryKey: string, autoInject: ResolvedProxyAutoInject, alias?: ProxyAliasConfig): void;
25
36
  declare function resolveConfiguredProxyDomains(config: Record<string, any> | undefined, proxyConfig?: Pick<ProxyConfig, 'autoInject' | 'configDomainFields'>): string[];
26
37
  /**
27
38
  * Compute missing required fields for a registry entry, using the merged
@@ -50,6 +61,23 @@ interface ModuleOptions {
50
61
  * @default undefined (per-script defaults)
51
62
  */
52
63
  privacy?: FirstPartyPrivacy;
64
+ /**
65
+ * First-party proxy behaviour.
66
+ */
67
+ proxy?: {
68
+ /**
69
+ * Replace third-party hostnames in proxy paths with aliases, so the real domain
70
+ * (e.g. a self-hosted analytics host) never appears in client-facing URLs.
71
+ *
72
+ * - `false` (default): paths embed the verbatim hostname (`/_scripts/p/us.i.posthog.com/...`)
73
+ * - `true`: auto-generate a short opaque alias per domain (`/_scripts/p/a1b2c3d4/...`)
74
+ * - `Record<domain, alias>`: explicit aliases (domain → alias); unlisted domains stay verbatim
75
+ *
76
+ * @default false
77
+ * @example { 'us.i.posthog.com': 'ph', 'analytics.internal.example.com': 'a' }
78
+ */
79
+ alias?: ProxyAliasConfig;
80
+ };
53
81
  /**
54
82
  * The registry of supported third-party scripts. Presence enables infrastructure (proxy routes, types, bundling, composable auto-imports).
55
83
  * Scripts only auto-load globally when `trigger` is explicitly set in the config object.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16"
6
6
  },
7
- "version": "1.2.1",
7
+ "version": "1.3.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -196,7 +196,7 @@ function buildDevtoolsEntry(key, script, configKey, proxyConfig) {
196
196
  domains: [...proxyConfig.domains]
197
197
  };
198
198
  }
199
- function buildDevtoolsData(proxyPrefix, privacyLabel, scripts) {
199
+ function buildDevtoolsData(proxyPrefix, privacyLabel, scripts, aliasToDomain) {
200
200
  const allDomains = /* @__PURE__ */ new Set();
201
201
  for (const s of scripts) {
202
202
  for (const d of s.domains)
@@ -207,7 +207,8 @@ function buildDevtoolsData(proxyPrefix, privacyLabel, scripts) {
207
207
  proxyPrefix,
208
208
  privacyMode: privacyLabel,
209
209
  scripts,
210
- totalDomains: allDomains.size
210
+ totalDomains: allDomains.size,
211
+ aliasToDomain
211
212
  };
212
213
  }
213
214
 
@@ -428,6 +429,7 @@ function generateInterceptPluginContents(proxyPrefix, options) {
428
429
  enforce: 'pre',
429
430
  setup() {
430
431
  const proxyPrefix = ${JSON.stringify(proxyPrefix)};
432
+ const domainAliases = ${JSON.stringify(options?.domainAliases ?? {})};
431
433
  const origBeacon = typeof navigator !== 'undefined' && navigator.sendBeacon
432
434
  ? navigator.sendBeacon.bind(navigator)
433
435
  : () => false;
@@ -436,8 +438,10 @@ function generateInterceptPluginContents(proxyPrefix, options) {
436
438
  function proxyUrl(url) {
437
439
  try {
438
440
  const parsed = new URL(url, location.origin);
439
- if (parsed.origin !== location.origin)
440
- return location.origin + proxyPrefix + '/' + parsed.host + parsed.pathname + parsed.search;
441
+ if (parsed.origin !== location.origin) {
442
+ const seg = domainAliases[parsed.host] || parsed.host;
443
+ return location.origin + proxyPrefix + '/' + seg + parsed.pathname + parsed.search;
444
+ }
441
445
  } catch {}
442
446
  return url;
443
447
  }
@@ -613,9 +617,146 @@ function rewriteScriptUrlsAST(content, filename, rewrites, sdkPatches, options)
613
617
  const prev = content[start - 1];
614
618
  return prev && WORD_OR_DOLLAR_RE.test(prev) ? " " : "";
615
619
  }
620
+ function sourceOf(node) {
621
+ return content.slice(node.start, node.end);
622
+ }
616
623
  const scopeTracker = new ScopeTracker({ preserveExitedScopes: true });
617
624
  const { program } = parseAndWalk(content, filename, { scopeTracker });
618
625
  scopeTracker.freeze();
626
+ const scriptLoaderUrlPatches = sdkPatches?.filter((p) => p.type === "replace-script-loader-url") ?? [];
627
+ const scriptLoaderFunctionKeys = /* @__PURE__ */ new Set();
628
+ function isIdentifier(node, name) {
629
+ return node?.type === "Identifier" && (!name || node.name === name);
630
+ }
631
+ function propertyName(node) {
632
+ if (!node)
633
+ return null;
634
+ if (node.type === "Identifier")
635
+ return node.name;
636
+ if (node.type === "Literal" && typeof node.value === "string")
637
+ return node.value;
638
+ return null;
639
+ }
640
+ function firstParamName(node) {
641
+ const param = node?.params?.[0];
642
+ return param?.type === "Identifier" ? param.name : null;
643
+ }
644
+ function functionName(node, parent) {
645
+ if (node.type === "FunctionDeclaration" && node.id?.type === "Identifier")
646
+ return node.id.name;
647
+ if ((node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && parent?.type === "VariableDeclarator" && parent.id?.type === "Identifier") {
648
+ return parent.id.name;
649
+ }
650
+ if ((node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && parent?.type === "AssignmentExpression" && parent.left?.type === "Identifier") {
651
+ return parent.left.name;
652
+ }
653
+ return null;
654
+ }
655
+ function declarationKey(name) {
656
+ const decl = scopeTracker.getDeclaration(name);
657
+ if (decl) {
658
+ const node = decl.node;
659
+ return `${decl.type}:${decl.scope}:${node?.start ?? decl.start}:${node?.end ?? decl.end}`;
660
+ }
661
+ return `global:${name}`;
662
+ }
663
+ function isScriptLoaderPathLiteral(value, pathPrefix) {
664
+ return value === pathPrefix || value.startsWith(`${pathPrefix}/`);
665
+ }
666
+ function getIdentifierInit(name) {
667
+ const decl = scopeTracker.getDeclaration(name);
668
+ if (!(decl instanceof ScopeTrackerVariable))
669
+ return null;
670
+ const declarators = decl.variableNode.declarations;
671
+ if (!declarators)
672
+ return null;
673
+ for (const declarator of declarators) {
674
+ if (declarator.id?.type === "Identifier" && declarator.id.name === name)
675
+ return declarator.init ?? null;
676
+ }
677
+ return null;
678
+ }
679
+ function findScriptLoaderPathExpression(node, pathPrefix, seenIdentifiers = /* @__PURE__ */ new Set()) {
680
+ if (!node)
681
+ return null;
682
+ if (node.type === "Identifier") {
683
+ if (seenIdentifiers.has(node.name))
684
+ return null;
685
+ const init = getIdentifierInit(node.name);
686
+ if (!init)
687
+ return null;
688
+ seenIdentifiers.add(node.name);
689
+ return findScriptLoaderPathExpression(init, pathPrefix, seenIdentifiers) ? node : null;
690
+ }
691
+ if (node.type === "Literal" && typeof node.value === "string" && isScriptLoaderPathLiteral(node.value, pathPrefix))
692
+ return node;
693
+ if (node.type === "TemplateLiteral") {
694
+ const hasConfigPrefix = node.quasis?.some((q) => {
695
+ const value = q.value?.cooked ?? q.value?.raw;
696
+ return typeof value === "string" && isScriptLoaderPathLiteral(value, pathPrefix);
697
+ });
698
+ return hasConfigPrefix ? node : null;
699
+ }
700
+ if (node.type === "CallExpression") {
701
+ for (const arg of node.arguments ?? []) {
702
+ const found = findScriptLoaderPathExpression(arg, pathPrefix, seenIdentifiers);
703
+ if (found)
704
+ return found;
705
+ }
706
+ return null;
707
+ }
708
+ if (node.type === "BinaryExpression" || node.type === "LogicalExpression")
709
+ return findScriptLoaderPathExpression(node.right, pathPrefix, seenIdentifiers) || findScriptLoaderPathExpression(node.left, pathPrefix, seenIdentifiers);
710
+ if (node.type === "ConditionalExpression")
711
+ return findScriptLoaderPathExpression(node.consequent, pathPrefix, seenIdentifiers) || findScriptLoaderPathExpression(node.alternate, pathPrefix, seenIdentifiers);
712
+ if (node.type === "SequenceExpression") {
713
+ for (let i = node.expressions.length - 1; i >= 0; i--) {
714
+ const found = findScriptLoaderPathExpression(node.expressions[i], pathPrefix, seenIdentifiers);
715
+ if (found)
716
+ return found;
717
+ }
718
+ }
719
+ return null;
720
+ }
721
+ function isScriptLoaderFunction(node, urlParam) {
722
+ let matches = false;
723
+ walk(node.body, {
724
+ enter(child) {
725
+ if (child !== node.body && (child.type === "FunctionDeclaration" || child.type === "FunctionExpression" || child.type === "ArrowFunctionExpression")) {
726
+ this.skip();
727
+ return;
728
+ }
729
+ if (child.type === "CallExpression" && child.callee?.type === "Identifier" && child.callee.name === "importScripts" && isIdentifier(child.arguments?.[0], urlParam)) {
730
+ matches = true;
731
+ }
732
+ if (child.type === "CallExpression" && child.callee?.type === "MemberExpression" && propertyName(child.callee.property) === "setAttribute" && child.arguments?.[0]?.type === "Literal" && child.arguments[0].value === "src" && isIdentifier(child.arguments?.[1], urlParam)) {
733
+ matches = true;
734
+ }
735
+ if (child.type === "Property" && propertyName(child.key) === "src" && isIdentifier(child.value, urlParam)) {
736
+ matches = true;
737
+ }
738
+ if (child.type === "AssignmentExpression" && child.left?.type === "MemberExpression" && propertyName(child.left.property) === "src" && isIdentifier(child.right, urlParam)) {
739
+ matches = true;
740
+ }
741
+ }
742
+ });
743
+ return matches;
744
+ }
745
+ if (scriptLoaderUrlPatches.length) {
746
+ walk(program, {
747
+ scopeTracker,
748
+ enter(node, parent) {
749
+ if (node.type !== "FunctionDeclaration" && node.type !== "FunctionExpression" && node.type !== "ArrowFunctionExpression")
750
+ return;
751
+ const name = functionName(node, parent);
752
+ const param = firstParamName(node);
753
+ if (!name || !param)
754
+ return;
755
+ if (isScriptLoaderFunction(node, param))
756
+ scriptLoaderFunctionKeys.add(declarationKey(name));
757
+ }
758
+ });
759
+ }
619
760
  walk(program, {
620
761
  scopeTracker,
621
762
  enter(node, parent, ctx) {
@@ -755,6 +896,31 @@ function rewriteScriptUrlsAST(content, filename, rewrites, sdkPatches, options)
755
896
  }
756
897
  }
757
898
  }
899
+ if (sdkPatches?.some((p) => p.type === "replace-new-url-host") && node.type === "MemberExpression" && !node.computed) {
900
+ const obj = node.object;
901
+ const prop = node.property;
902
+ if (prop?.type === "Identifier" && (prop.name === "host" || prop.name === "hostname") && obj?.type === "NewExpression" && obj.callee?.type === "Identifier" && obj.callee.name === "URL" && obj.arguments?.length >= 1) {
903
+ const patch = sdkPatches.find((p) => p.type === "replace-new-url-host");
904
+ if (patch)
905
+ s.overwrite(node.start, node.end, `${needsLeadingSpace(node.start)}${JSON.stringify(patch.host)}`);
906
+ }
907
+ }
908
+ if (scriptLoaderUrlPatches.length && node.type === "CallExpression" && node.callee?.type === "Identifier" && scriptLoaderFunctionKeys.has(declarationKey(node.callee.name))) {
909
+ const urlArg = node.arguments?.[0];
910
+ if (urlArg) {
911
+ for (const patch of scriptLoaderUrlPatches) {
912
+ const rewrite = rewrites.find((r) => r.from === patch.fromDomain);
913
+ if (!rewrite)
914
+ continue;
915
+ const pathNode = findScriptLoaderPathExpression(urlArg, patch.pathPrefix);
916
+ if (!pathNode)
917
+ continue;
918
+ s.overwrite(urlArg.start, urlArg.end, `${needsLeadingSpace(urlArg.start)}self.location.origin+"${rewrite.to}"+${sourceOf(pathNode)}`);
919
+ this.skip();
920
+ break;
921
+ }
922
+ }
923
+ }
758
924
  if (node.type === "NewExpression" && !options?.skipApiRewrites) {
759
925
  const callee = node.callee;
760
926
  if (callee?.type === "Identifier" && callee.name === "XMLHttpRequest") {
@@ -1078,7 +1244,7 @@ function NuxtScriptBundleTransformer(options = {
1078
1244
  const proxyConfig = !firstPartyOptOut && proxyConfigKey ? options.proxyConfigs?.[proxyConfigKey] : void 0;
1079
1245
  const proxyRewrites = proxyConfig?.domains?.filter((domain) => !domain.includes("*")).map((domain) => ({
1080
1246
  from: domain,
1081
- to: `${options.proxyPrefix}/${domain}`
1247
+ to: `${options.proxyPrefix}/${options.domainAliases?.[domain] ?? domain}`
1082
1248
  }));
1083
1249
  const bundleConfig = typeof script?.bundle === "object" ? script.bundle : void 0;
1084
1250
  const sdkPatches = proxyConfig?.sdkPatches ?? bundleConfig?.sdkPatches;
@@ -1170,6 +1336,45 @@ function NuxtScriptBundleTransformer(options = {
1170
1336
  });
1171
1337
  }
1172
1338
 
1339
+ const WILDCARD_RE = /\*/;
1340
+ const SAFE_ALIAS_SEGMENT_RE = /^[\w.-]+$/;
1341
+ function isSafeAliasSegment(alias) {
1342
+ return SAFE_ALIAS_SEGMENT_RE.test(alias);
1343
+ }
1344
+ function aliasForDomain(domain, alias) {
1345
+ if (!alias || WILDCARD_RE.test(domain))
1346
+ return void 0;
1347
+ if (alias === true)
1348
+ return createHash("sha256").update(domain).digest("hex").slice(0, 12);
1349
+ return Object.hasOwn(alias, domain) ? alias[domain] || void 0 : void 0;
1350
+ }
1351
+ function buildDomainAliasMap(domains, alias) {
1352
+ const map = {};
1353
+ for (const domain of domains) {
1354
+ const value = aliasForDomain(domain, alias);
1355
+ if (value)
1356
+ map[domain] = value;
1357
+ }
1358
+ return map;
1359
+ }
1360
+ function invertAliasMap(map) {
1361
+ const out = {};
1362
+ for (const [domain, alias] of Object.entries(map))
1363
+ out[alias] = domain;
1364
+ return out;
1365
+ }
1366
+ function aliasProxyValue(value, proxyPrefix, alias) {
1367
+ const prefix = `${proxyPrefix}/`;
1368
+ if (!alias || !value.startsWith(prefix))
1369
+ return value;
1370
+ const rest = value.slice(prefix.length);
1371
+ const host = rest.match(/^[^/?#]+/)?.[0];
1372
+ if (!host)
1373
+ return value;
1374
+ const aliased = aliasForDomain(host, alias);
1375
+ return aliased ? `${prefix}${aliased}${rest.slice(host.length)}` : value;
1376
+ }
1377
+
1173
1378
  const TRIGGER_PLACEHOLDER_RE = /"__TRIGGER_PLACEHOLDER__"/g;
1174
1379
  function registerTypeTemplates({ config, newScripts }) {
1175
1380
  addTypeTemplate({
@@ -1646,7 +1851,7 @@ function isProxyDisabled(registryKey, registry2, runtimeConfig) {
1646
1851
  }
1647
1852
  return false;
1648
1853
  }
1649
- function applyAutoInject(registry2, runtimeConfig, proxyPrefix, registryKey, autoInject) {
1854
+ function applyAutoInject(registry2, runtimeConfig, proxyPrefix, registryKey, autoInject, alias) {
1650
1855
  if (isProxyDisabled(registryKey, registry2, runtimeConfig))
1651
1856
  return;
1652
1857
  const entry = registry2[registryKey];
@@ -1656,7 +1861,7 @@ function applyAutoInject(registry2, runtimeConfig, proxyPrefix, registryKey, aut
1656
1861
  const config = rtEntry && typeof rtEntry === "object" ? rtEntry : input;
1657
1862
  if (!config || config[autoInject.configField])
1658
1863
  return;
1659
- const value = autoInject.computeValue(proxyPrefix, config);
1864
+ const value = aliasProxyValue(autoInject.computeValue(proxyPrefix, config), proxyPrefix, alias);
1660
1865
  input[autoInject.configField] = value;
1661
1866
  if (rtEntry && typeof rtEntry === "object" && rtEntry !== input)
1662
1867
  rtEntry[autoInject.configField] = value;
@@ -1991,6 +2196,8 @@ const module$1 = defineNuxtModule({
1991
2196
  }
1992
2197
  }
1993
2198
  }
2199
+ const proxyAlias = config.proxy?.alias;
2200
+ let domainAliases = {};
1994
2201
  if (anyNeedsProxy) {
1995
2202
  const builtConfigs = buildProxyConfigsFromRegistry(registryScripts, scriptByKey);
1996
2203
  Object.assign(proxyConfigs, builtConfigs);
@@ -2030,7 +2237,7 @@ const module$1 = defineNuxtModule({
2030
2237
  }
2031
2238
  }
2032
2239
  if (proxyConfig.autoInject && config.registry)
2033
- applyAutoInject(config.registry, nuxt.options.runtimeConfig, proxyPrefix, key, proxyConfig.autoInject);
2240
+ applyAutoInject(config.registry, nuxt.options.runtimeConfig, proxyPrefix, key, proxyConfig.autoInject, proxyAlias);
2034
2241
  if (nuxt.options.dev)
2035
2242
  devtoolsScripts.push(buildDevtoolsEntry(key, script, configKey, proxyConfig));
2036
2243
  }
@@ -2046,15 +2253,30 @@ These scripts will not have proxy routes registered.`
2046
2253
  They will load directly from third-party servers.`
2047
2254
  );
2048
2255
  }
2256
+ domainAliases = buildDomainAliasMap(Object.keys(domainPrivacy), proxyAlias);
2257
+ const realDomains = new Set(Object.keys(domainPrivacy));
2258
+ const aliasOwner = /* @__PURE__ */ new Map();
2259
+ for (const [domain, alias] of Object.entries(domainAliases)) {
2260
+ if (!isSafeAliasSegment(alias))
2261
+ throw new Error(`[nuxt-scripts] Invalid proxy alias "${alias}" for "${domain}": use a single URL-safe path segment (letters, digits, '-', '_', '.').`);
2262
+ if (realDomains.has(alias))
2263
+ throw new Error(`[nuxt-scripts] Proxy alias "${alias}" for "${domain}" collides with proxied domain "${alias}". Pick an alias that is not also a proxied hostname.`);
2264
+ const prev = aliasOwner.get(alias);
2265
+ if (prev)
2266
+ throw new Error(`[nuxt-scripts] Proxy alias collision: "${prev}" and "${domain}" both map to "${alias}". Give each domain a unique alias.`);
2267
+ aliasOwner.set(alias, domain);
2268
+ }
2269
+ const aliasToDomain = invertAliasMap(domainAliases);
2049
2270
  addPluginTemplate({
2050
2271
  filename: "nuxt-scripts-intercept.client.mjs",
2051
2272
  getContents() {
2052
- return generateInterceptPluginContents(proxyPrefix, { testMode: !!nuxt.options.test });
2273
+ return generateInterceptPluginContents(proxyPrefix, { testMode: !!nuxt.options.test, domainAliases });
2053
2274
  }
2054
2275
  });
2055
2276
  nuxt.options.runtimeConfig["nuxt-scripts-proxy"] = {
2056
2277
  proxyPrefix,
2057
2278
  domainPrivacy,
2279
+ aliasToDomain,
2058
2280
  privacy: config.privacy
2059
2281
  };
2060
2282
  const privacyLabel = config.privacy === void 0 ? "per-script" : typeof config.privacy === "boolean" ? config.privacy ? "anonymize" : "passthrough" : "custom";
@@ -2071,12 +2293,12 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
2071
2293
  );
2072
2294
  }
2073
2295
  if (nuxt.options.dev) {
2074
- nuxt.options.runtimeConfig.public["nuxt-scripts-devtools"] = buildDevtoolsData(proxyPrefix, privacyLabel, devtoolsScripts);
2296
+ nuxt.options.runtimeConfig.public["nuxt-scripts-devtools"] = buildDevtoolsData(proxyPrefix, privacyLabel, devtoolsScripts, aliasToDomain);
2075
2297
  }
2076
2298
  if (partytownScripts.size && hasNuxtModule("@nuxtjs/partytown")) {
2077
2299
  const partytownConfig = nuxt.options.partytown || {};
2078
2300
  if (!partytownConfig.resolveUrl) {
2079
- partytownConfig.resolveUrl = generatePartytownResolveUrl(proxyPrefix);
2301
+ partytownConfig.resolveUrl = generatePartytownResolveUrl(proxyPrefix, domainAliases);
2080
2302
  nuxt.options.partytown = partytownConfig;
2081
2303
  logger.info("[partytown] Auto-configured resolveUrl for proxy");
2082
2304
  } else {
@@ -2093,6 +2315,7 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
2093
2315
  registryConfig: nuxt.options.runtimeConfig.public.scripts,
2094
2316
  proxyConfigs,
2095
2317
  proxyPrefix,
2318
+ domainAliases,
2096
2319
  partytownScripts,
2097
2320
  moduleDetected(module) {
2098
2321
  if (nuxt.options.dev && module !== "@nuxt/scripts" && !moduleInstallPromises.has(module) && !hasNuxtModule(module))
@@ -71,9 +71,12 @@ declare function registry(resolve?: (path: string) => Promise<string>): Promise<
71
71
  /**
72
72
  * Generate a Partytown `resolveUrl` function string for proxy routing.
73
73
  * Partytown calls this for every network request made by worker-executed scripts.
74
- * Any non-same-origin URL is proxied through `proxyPrefix/<host><path>`.
74
+ * Any non-same-origin URL is proxied through `proxyPrefix/<host-or-alias><path>`.
75
+ *
76
+ * `domainAliases` (real domain → path alias) is embedded so worker requests use the
77
+ * same opaque path segment as build-time rewrites, keeping hostnames out of URLs.
75
78
  */
76
- declare function generatePartytownResolveUrl(proxyPrefix: string): string;
79
+ declare function generatePartytownResolveUrl(proxyPrefix: string, domainAliases?: Record<string, string>): string;
77
80
  /**
78
81
  * Resolve the effective capabilities for a script by merging:
79
82
  * 1. Derive ceiling from script's bundle/proxy/partytown keys
@@ -71,9 +71,12 @@ declare function registry(resolve?: (path: string) => Promise<string>): Promise<
71
71
  /**
72
72
  * Generate a Partytown `resolveUrl` function string for proxy routing.
73
73
  * Partytown calls this for every network request made by worker-executed scripts.
74
- * Any non-same-origin URL is proxied through `proxyPrefix/<host><path>`.
74
+ * Any non-same-origin URL is proxied through `proxyPrefix/<host-or-alias><path>`.
75
+ *
76
+ * `domainAliases` (real domain → path alias) is embedded so worker requests use the
77
+ * same opaque path segment as build-time rewrites, keeping hostnames out of URLs.
75
78
  */
76
- declare function generatePartytownResolveUrl(proxyPrefix: string): string;
79
+ declare function generatePartytownResolveUrl(proxyPrefix: string, domainAliases?: Record<string, string>): string;
77
80
  /**
78
81
  * Resolve the effective capabilities for a script by merging:
79
82
  * 1. Derive ceiling from script's bundle/proxy/partytown keys
package/dist/registry.mjs CHANGED
@@ -456,10 +456,16 @@ async function registry(resolve) {
456
456
  src: "https://sc-static.net/scevent.min.js",
457
457
  category: "ad",
458
458
  envDefaults: { id: "" },
459
- bundle: true,
459
+ bundle: {
460
+ sdkPatches: [{ type: "replace-new-url-host", host: "sc-static.net" }]
461
+ },
460
462
  proxy: {
461
463
  domains: ["sc-static.net", "tr.snapchat.com", "pixel.tapad.com"],
462
- privacy: PRIVACY_FULL
464
+ privacy: PRIVACY_FULL,
465
+ sdkPatches: [
466
+ { type: "replace-new-url-host", host: "sc-static.net" },
467
+ { type: "replace-script-loader-url", fromDomain: "tr.snapchat.com", pathPrefix: "/config" }
468
+ ]
463
469
  },
464
470
  partytown: { forwards: ["snaptr"] }
465
471
  }),
@@ -800,10 +806,12 @@ async function registry(resolve) {
800
806
  })
801
807
  ]);
802
808
  }
803
- function generatePartytownResolveUrl(proxyPrefix) {
809
+ function generatePartytownResolveUrl(proxyPrefix, domainAliases = {}) {
804
810
  return `function(url, location, type) {
805
811
  if (url.origin !== location.origin) {
806
- return new URL(${JSON.stringify(proxyPrefix)} + '/' + url.host + url.pathname + url.search, location.origin);
812
+ var aliases = ${JSON.stringify(domainAliases)};
813
+ var seg = aliases[url.host] || url.host;
814
+ return new URL(${JSON.stringify(proxyPrefix)} + '/' + seg + url.pathname + url.search, location.origin);
807
815
  }
808
816
  }`;
809
817
  }
@@ -84,10 +84,12 @@ declare const _default: typeof __VLS_export;
84
84
  export default _default;
85
85
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScriptGoogleMapsOverlayViewProps & {
86
86
  open?: boolean;
87
+ openModifiers?: Partial<Record<"open", true>>;
87
88
  }, ScriptGoogleMapsOverlayViewExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
88
89
  "update:open": (value: boolean) => any;
89
90
  }, string, import("vue").PublicProps, Readonly<ScriptGoogleMapsOverlayViewProps & {
90
91
  open?: boolean;
92
+ openModifiers?: Partial<Record<"open", true>>;
91
93
  }> & Readonly<{
92
94
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
93
95
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScriptGoogleMapsOverlayViewSlots>;
@@ -84,10 +84,12 @@ declare const _default: typeof __VLS_export;
84
84
  export default _default;
85
85
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScriptGoogleMapsOverlayViewProps & {
86
86
  open?: boolean;
87
+ openModifiers?: Partial<Record<"open", true>>;
87
88
  }, ScriptGoogleMapsOverlayViewExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
88
89
  "update:open": (value: boolean) => any;
89
90
  }, string, import("vue").PublicProps, Readonly<ScriptGoogleMapsOverlayViewProps & {
90
91
  open?: boolean;
92
+ openModifiers?: Partial<Record<"open", true>>;
91
93
  }> & Readonly<{
92
94
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
93
95
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScriptGoogleMapsOverlayViewSlots>;
@@ -29,6 +29,7 @@ function toNetworkRequest(entry, proxyPrefix) {
29
29
  }
30
30
  function createDomainMatcher(domains, proxyPrefix, scriptSrc) {
31
31
  const localHostname = window.location.hostname;
32
+ const aliasToDomain = useRuntimeConfig().public["nuxt-scripts-devtools"]?.aliasToDomain || {};
32
33
  const scriptUrl = (() => {
33
34
  if (!scriptSrc)
34
35
  return "";
@@ -49,7 +50,8 @@ function createDomainMatcher(domains, proxyPrefix, scriptSrc) {
49
50
  const proxyIdx = entryUrl.pathname.indexOf(proxyPath);
50
51
  if (proxyIdx !== -1) {
51
52
  const afterPrefix = entryUrl.pathname.slice(proxyIdx + proxyPath.length);
52
- const proxyDomain = afterPrefix.split("/")[0];
53
+ const proxySegment = afterPrefix.split("/")[0];
54
+ const proxyDomain = proxySegment ? aliasToDomain[proxySegment] || proxySegment : void 0;
53
55
  if (proxyDomain && domains.has(proxyDomain))
54
56
  return true;
55
57
  }
@@ -116,6 +118,9 @@ export function resolveScriptKey(input) {
116
118
  export function useScript(input, options) {
117
119
  input = typeof input === "string" ? { src: input } : input;
118
120
  options = defu(options, useNuxtScriptRuntimeConfig()?.defaultScriptOptions);
121
+ if (!import.meta.client && options.use) {
122
+ options.use = (() => void 0);
123
+ }
119
124
  if (options.partytown) {
120
125
  const src = input.src;
121
126
  if (!src) {
@@ -198,7 +203,7 @@ export function useScript(input, options) {
198
203
  logger.info(out);
199
204
  }
200
205
  } else if (options.trigger === "onNuxtReady" || options.trigger === "client") {
201
- if (!options.warmupStrategy) {
206
+ if (options.warmupStrategy === void 0) {
202
207
  options.warmupStrategy = "preload";
203
208
  }
204
209
  if (options.trigger === "onNuxtReady") {
@@ -1,6 +1,5 @@
1
- import type { UseScriptContext } from '@unhead/vue';
2
1
  import type Vimeo from '@vimeo/player';
3
- import type { RegistryScriptInput } from '#nuxt-scripts/types';
2
+ import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types';
4
3
  type Constructor<T extends new (...args: any) => any> = T extends new (...args: infer A) => infer R ? new (...args: A) => R : never;
5
4
  export interface VimeoPlayerApi {
6
5
  Vimeo: {