@nuxt/scripts 1.0.0-beta.15 → 1.0.0-beta.18

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 (110) hide show
  1. package/README.md +3 -3
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/{C4oLgKn5.js → BW6d1nfL.js} +1 -1
  5. package/dist/client/_nuxt/{C4LyqEA2.js → C8R4dwAP.js} +1 -1
  6. package/dist/client/_nuxt/{CSWa0Nc-.js → DI7VRsfF.js} +1 -1
  7. package/dist/client/_nuxt/{CAywURt7.js → NbccNBFl.js} +13 -13
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/e9af4ec4-4502-4171-9264-54123d0ae2ea.json +1 -0
  10. package/dist/client/_nuxt/error-404.Cqp3ffuH.css +1 -0
  11. package/dist/client/_nuxt/error-500.B9hH8BAi.css +1 -0
  12. package/dist/client/index.html +1 -1
  13. package/dist/module.json +1 -1
  14. package/dist/module.mjs +75 -8
  15. package/dist/registry.mjs +22 -0
  16. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +1 -1
  17. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +1 -1
  18. package/dist/runtime/components/ScriptGravatar.d.vue.ts +22 -0
  19. package/dist/runtime/components/ScriptGravatar.vue +46 -0
  20. package/dist/runtime/components/ScriptGravatar.vue.d.ts +22 -0
  21. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +1 -1
  22. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
  23. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +42 -31
  24. package/dist/runtime/components/ScriptPayPalButtons.vue +43 -76
  25. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +42 -31
  26. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +36 -22
  27. package/dist/runtime/components/ScriptPayPalMessages.vue +41 -47
  28. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +36 -22
  29. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +1 -1
  30. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +1 -1
  31. package/dist/runtime/registry/clarity.d.ts +2 -7
  32. package/dist/runtime/registry/clarity.js +2 -7
  33. package/dist/runtime/registry/cloudflare-web-analytics.d.ts +2 -13
  34. package/dist/runtime/registry/cloudflare-web-analytics.js +2 -14
  35. package/dist/runtime/registry/crisp.d.ts +2 -32
  36. package/dist/runtime/registry/crisp.js +2 -33
  37. package/dist/runtime/registry/databuddy-analytics.d.ts +2 -35
  38. package/dist/runtime/registry/databuddy-analytics.js +2 -45
  39. package/dist/runtime/registry/fathom-analytics.d.ts +2 -22
  40. package/dist/runtime/registry/fathom-analytics.js +2 -23
  41. package/dist/runtime/registry/google-adsense.d.ts +2 -10
  42. package/dist/runtime/registry/google-adsense.js +2 -11
  43. package/dist/runtime/registry/google-analytics.d.ts +2 -4
  44. package/dist/runtime/registry/google-analytics.js +2 -7
  45. package/dist/runtime/registry/google-maps.d.ts +2 -8
  46. package/dist/runtime/registry/google-maps.js +2 -8
  47. package/dist/runtime/registry/google-recaptcha.d.ts +2 -6
  48. package/dist/runtime/registry/google-recaptcha.js +2 -10
  49. package/dist/runtime/registry/google-sign-in.d.ts +2 -13
  50. package/dist/runtime/registry/google-sign-in.js +2 -22
  51. package/dist/runtime/registry/google-tag-manager.d.ts +2 -27
  52. package/dist/runtime/registry/google-tag-manager.js +2 -25
  53. package/dist/runtime/registry/gravatar.d.ts +25 -0
  54. package/dist/runtime/registry/gravatar.js +32 -0
  55. package/dist/runtime/registry/hotjar.d.ts +2 -4
  56. package/dist/runtime/registry/hotjar.js +2 -5
  57. package/dist/runtime/registry/instagram-embed.d.ts +2 -17
  58. package/dist/runtime/registry/instagram-embed.js +2 -18
  59. package/dist/runtime/registry/intercom.d.ts +2 -10
  60. package/dist/runtime/registry/intercom.js +2 -12
  61. package/dist/runtime/registry/matomo-analytics.d.ts +2 -11
  62. package/dist/runtime/registry/matomo-analytics.js +2 -11
  63. package/dist/runtime/registry/meta-pixel.d.ts +2 -4
  64. package/dist/runtime/registry/meta-pixel.js +2 -4
  65. package/dist/runtime/registry/npm.d.ts +2 -6
  66. package/dist/runtime/registry/npm.js +2 -7
  67. package/dist/runtime/registry/paypal.d.ts +4 -25
  68. package/dist/runtime/registry/paypal.js +3 -66
  69. package/dist/runtime/registry/plausible-analytics.js +5 -6
  70. package/dist/runtime/registry/posthog.d.ts +10 -12
  71. package/dist/runtime/registry/posthog.js +2 -11
  72. package/dist/runtime/registry/reddit-pixel.d.ts +2 -4
  73. package/dist/runtime/registry/reddit-pixel.js +2 -4
  74. package/dist/runtime/registry/rybbit-analytics.d.ts +2 -14
  75. package/dist/runtime/registry/rybbit-analytics.js +2 -16
  76. package/dist/runtime/registry/schemas.d.ts +940 -0
  77. package/dist/runtime/registry/schemas.js +895 -0
  78. package/dist/runtime/registry/segment.d.ts +2 -5
  79. package/dist/runtime/registry/segment.js +2 -5
  80. package/dist/runtime/registry/snapchat-pixel.d.ts +2 -31
  81. package/dist/runtime/registry/snapchat-pixel.js +2 -20
  82. package/dist/runtime/registry/stripe.d.ts +2 -3
  83. package/dist/runtime/registry/stripe.js +2 -4
  84. package/dist/runtime/registry/tiktok-pixel.d.ts +2 -5
  85. package/dist/runtime/registry/tiktok-pixel.js +2 -6
  86. package/dist/runtime/registry/umami-analytics.d.ts +2 -31
  87. package/dist/runtime/registry/umami-analytics.js +2 -36
  88. package/dist/runtime/registry/vercel-analytics.d.ts +29 -0
  89. package/dist/runtime/registry/vercel-analytics.js +84 -0
  90. package/dist/runtime/registry/x-embed.d.ts +2 -16
  91. package/dist/runtime/registry/x-embed.js +2 -17
  92. package/dist/runtime/registry/x-pixel.d.ts +2 -5
  93. package/dist/runtime/registry/x-pixel.js +2 -5
  94. package/dist/runtime/server/gravatar-proxy.d.ts +2 -0
  95. package/dist/runtime/server/gravatar-proxy.js +62 -0
  96. package/dist/runtime/types.d.ts +9 -3
  97. package/dist/runtime/utils.d.ts +2 -2
  98. package/dist/runtime/utils.js +3 -2
  99. package/dist/shared/{scripts.DLRgvHQg.mjs → scripts.Bg4pl9Yo.mjs} +22 -0
  100. package/dist/stats.mjs +152 -94
  101. package/dist/types-source.d.mts +11 -367
  102. package/dist/types-source.d.ts +11 -367
  103. package/dist/types-source.mjs +225 -460
  104. package/package.json +4 -4
  105. package/dist/client/_nuxt/builds/meta/0f5f1d62-f186-4aef-a618-dcef5ec637c1.json +0 -1
  106. package/dist/client/_nuxt/error-404.B57D-jUQ.css +0 -1
  107. package/dist/client/_nuxt/error-500.DTHUW7BI.css +0 -1
  108. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +0 -52
  109. package/dist/runtime/components/ScriptPayPalMarks.vue +0 -71
  110. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +0 -52
@@ -1 +1 @@
1
- {"id":"0f5f1d62-f186-4aef-a618-dcef5ec637c1","timestamp":1772688986035}
1
+ {"id":"e9af4ec4-4502-4171-9264-54123d0ae2ea","timestamp":1772773565943}
@@ -0,0 +1 @@
1
+ {"id":"e9af4ec4-4502-4171-9264-54123d0ae2ea","timestamp":1772773565943,"prerendered":[]}
@@ -0,0 +1 @@
1
+ .grid[data-v-47fa61ef]{display:grid}.mb-2[data-v-47fa61ef]{margin-bottom:.5rem}.mb-4[data-v-47fa61ef]{margin-bottom:1rem}.max-w-520px[data-v-47fa61ef]{max-width:520px}.min-h-screen[data-v-47fa61ef]{min-height:100vh}.w-full[data-v-47fa61ef]{width:100%}.flex[data-v-47fa61ef]{display:flex}.place-content-center[data-v-47fa61ef]{place-content:center}.items-center[data-v-47fa61ef]{align-items:center}.justify-center[data-v-47fa61ef]{justify-content:center}.overflow-hidden[data-v-47fa61ef]{overflow:hidden}.bg-white[data-v-47fa61ef]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2[data-v-47fa61ef]{padding-left:.5rem;padding-right:.5rem}.text-center[data-v-47fa61ef]{text-align:center}.text-\[80px\][data-v-47fa61ef]{font-size:80px}.text-2xl[data-v-47fa61ef]{font-size:1.5rem;line-height:2rem}.text-sm[data-v-47fa61ef]{font-size:.875rem;line-height:1.25rem}.text-\[\#020420\][data-v-47fa61ef]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\[\#64748B\][data-v-47fa61ef]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.hover\:text-\[\#00DC82\][data-v-47fa61ef]:hover{--un-text-opacity:1;color:rgb(0 220 130/var(--un-text-opacity))}.font-medium[data-v-47fa61ef]{font-weight:500}.font-semibold[data-v-47fa61ef]{font-weight:600}.leading-none[data-v-47fa61ef]{line-height:1}.tracking-wide[data-v-47fa61ef]{letter-spacing:.025em}.font-sans[data-v-47fa61ef]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums[data-v-47fa61ef]{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.underline[data-v-47fa61ef]{text-decoration-line:underline}.underline-offset-3[data-v-47fa61ef]{text-underline-offset:3px}.antialiased[data-v-47fa61ef]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\:bg-\[\#020420\][data-v-47fa61ef]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\:text-white[data-v-47fa61ef]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\:text-\[110px\][data-v-47fa61ef]{font-size:110px}.sm\:text-3xl[data-v-47fa61ef]{font-size:1.875rem;line-height:2.25rem}}
@@ -0,0 +1 @@
1
+ .grid[data-v-c0d7df54]{display:grid}.mb-2[data-v-c0d7df54]{margin-bottom:.5rem}.mb-4[data-v-c0d7df54]{margin-bottom:1rem}.max-w-520px[data-v-c0d7df54]{max-width:520px}.min-h-screen[data-v-c0d7df54]{min-height:100vh}.place-content-center[data-v-c0d7df54]{place-content:center}.overflow-hidden[data-v-c0d7df54]{overflow:hidden}.bg-white[data-v-c0d7df54]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2[data-v-c0d7df54]{padding-left:.5rem;padding-right:.5rem}.text-center[data-v-c0d7df54]{text-align:center}.text-\[80px\][data-v-c0d7df54]{font-size:80px}.text-2xl[data-v-c0d7df54]{font-size:1.5rem;line-height:2rem}.text-\[\#020420\][data-v-c0d7df54]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\[\#64748B\][data-v-c0d7df54]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.font-semibold[data-v-c0d7df54]{font-weight:600}.leading-none[data-v-c0d7df54]{line-height:1}.tracking-wide[data-v-c0d7df54]{letter-spacing:.025em}.font-sans[data-v-c0d7df54]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums[data-v-c0d7df54]{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.antialiased[data-v-c0d7df54]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\:bg-\[\#020420\][data-v-c0d7df54]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\:text-white[data-v-c0d7df54]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\:text-\[110px\][data-v-c0d7df54]{font-size:110px}.sm\:text-3xl[data-v-c0d7df54]{font-size:1.875rem;line-height:2.25rem}}
@@ -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.D45OuV0w.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/CAywURt7.js"><script type="module" src="/__nuxt-scripts/_nuxt/CAywURt7.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{"nuxt-scripts":{version:"",defaultScriptOptions:{trigger:"onNuxtReady"},googleStaticMapsProxy:""}},app:{baseURL:"/__nuxt-scripts",buildId:"0f5f1d62-f186-4aef-a618-dcef5ec637c1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772688990394,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.D45OuV0w.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/NbccNBFl.js"><script type="module" src="/__nuxt-scripts/_nuxt/NbccNBFl.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{"nuxt-scripts":{version:"",defaultScriptOptions:{trigger:"onNuxtReady"},googleStaticMapsProxy:""}},app:{baseURL:"/__nuxt-scripts",buildId:"e9af4ec4-4502-4171-9264-54123d0ae2ea",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1772773570480,false]</script></body></html>
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16"
6
6
  },
7
- "version": "1.0.0-beta.15",
7
+ "version": "1.0.0-beta.18",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -18,7 +18,7 @@ import fsp from 'node:fs/promises';
18
18
  import { colors } from 'consola/utils';
19
19
  import MagicString from 'magic-string';
20
20
  import { hash } from 'ohash';
21
- import { a as getProxyConfig, g as getAllProxyConfigs, r as routesToInterceptRules } from './shared/scripts.DLRgvHQg.mjs';
21
+ import { a as getProxyConfig, g as getAllProxyConfigs, r as routesToInterceptRules } from './shared/scripts.Bg4pl9Yo.mjs';
22
22
  import { registry } from './registry.mjs';
23
23
 
24
24
  const renderedScript = /* @__PURE__ */ new Map();
@@ -300,6 +300,10 @@ function matchAndRewrite(value, rewrites) {
300
300
  }
301
301
  function rewriteScriptUrlsAST(content, filename, rewrites) {
302
302
  const s = new MagicString(content);
303
+ function needsLeadingSpace(start) {
304
+ const prev = content[start - 1];
305
+ return prev && /[\w$]/.test(prev) ? " " : "";
306
+ }
303
307
  parseAndWalk(content, filename, (node, parent, ctx) => {
304
308
  if (node.type === "Literal" && typeof node.value === "string") {
305
309
  const value = node.value;
@@ -310,7 +314,7 @@ function rewriteScriptUrlsAST(content, filename, rewrites) {
310
314
  if (isPropertyKeyAST(parent, ctx)) {
311
315
  s.overwrite(node.start, node.end, quote + rewritten + quote);
312
316
  } else {
313
- s.overwrite(node.start, node.end, `self.location.origin+${quote}${rewritten}${quote}`);
317
+ s.overwrite(node.start, node.end, `${needsLeadingSpace(node.start)}self.location.origin+${quote}${rewritten}${quote}`);
314
318
  }
315
319
  }
316
320
  if (node.type === "TemplateLiteral" && node.expressions?.length === 0) {
@@ -325,7 +329,7 @@ function rewriteScriptUrlsAST(content, filename, rewrites) {
325
329
  if (isPropertyKeyAST(parent, ctx)) {
326
330
  s.overwrite(node.start, node.end, `\`${rewritten}\``);
327
331
  } else {
328
- s.overwrite(node.start, node.end, `self.location.origin+\`${rewritten}\``);
332
+ s.overwrite(node.start, node.end, `${needsLeadingSpace(node.start)}self.location.origin+\`${rewritten}\``);
329
333
  }
330
334
  }
331
335
  }
@@ -346,12 +350,12 @@ function rewriteScriptUrlsAST(content, filename, rewrites) {
346
350
  const gaRewrite = rewrites.find((r) => r.from.includes("google-analytics.com/g/collect"));
347
351
  if (gaRewrite) {
348
352
  output = output.replace(
349
- /"https:\/\/"\+\(.*?\)\+"\.google-analytics\.com\/g\/collect"/g,
350
- `self.location.origin+"${gaRewrite.to}"`
353
+ /([\w$])?"https:\/\/"\+\(.*?\)\+"\.google-analytics\.com\/g\/collect"/g,
354
+ (_, prevChar) => `${prevChar ? `${prevChar} ` : ""}self.location.origin+"${gaRewrite.to}"`
351
355
  );
352
356
  output = output.replace(
353
- /"https:\/\/"\+\(.*?\)\+"\.analytics\.google\.com\/g\/collect"/g,
354
- `self.location.origin+"${gaRewrite.to}"`
357
+ /([\w$])?"https:\/\/"\+\(.*?\)\+"\.analytics\.google\.com\/g\/collect"/g,
358
+ (_, prevChar) => `${prevChar ? `${prevChar} ` : ""}self.location.origin+"${gaRewrite.to}"`
355
359
  );
356
360
  }
357
361
  return output;
@@ -942,6 +946,35 @@ function fixSelfClosingScriptComponents(nuxt) {
942
946
  });
943
947
  }
944
948
  }
949
+ const REGISTRY_ENV_DEFAULTS = {
950
+ clarity: { id: "" },
951
+ cloudflareWebAnalytics: { token: "" },
952
+ crisp: { id: "" },
953
+ databuddyAnalytics: { clientId: "" },
954
+ fathomAnalytics: { site: "" },
955
+ googleAdsense: { client: "" },
956
+ googleAnalytics: { id: "" },
957
+ googleMaps: { apiKey: "" },
958
+ googleRecaptcha: { siteKey: "" },
959
+ googleSignIn: { clientId: "" },
960
+ googleTagManager: { id: "" },
961
+ hotjar: { id: "" },
962
+ intercom: { app_id: "" },
963
+ matomoAnalytics: { matomoUrl: "" },
964
+ metaPixel: { id: "" },
965
+ paypal: { clientId: "" },
966
+ plausibleAnalytics: { domain: "" },
967
+ posthog: { apiKey: "" },
968
+ redditPixel: { id: "" },
969
+ rybbitAnalytics: { siteId: "" },
970
+ segment: { writeKey: "" },
971
+ snapchatPixel: { id: "" },
972
+ stripe: {},
973
+ tiktokPixel: { id: "" },
974
+ umamiAnalytics: { websiteId: "" },
975
+ vercelAnalytics: {},
976
+ xPixel: { id: "" }
977
+ };
945
978
  const PARTYTOWN_FORWARDS = {
946
979
  googleAnalytics: ["dataLayer.push", "gtag"],
947
980
  plausible: ["plausible"],
@@ -1016,9 +1049,26 @@ const module$1 = defineNuxtModule({
1016
1049
  };
1017
1050
  if (config.registry) {
1018
1051
  nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
1052
+ const registryWithDefaults = {};
1053
+ for (const [key, value] of Object.entries(config.registry)) {
1054
+ if (value && REGISTRY_ENV_DEFAULTS[key]) {
1055
+ const envDefaults = REGISTRY_ENV_DEFAULTS[key];
1056
+ if (value === true || value === "mock") {
1057
+ registryWithDefaults[key] = { ...envDefaults };
1058
+ } else if (typeof value === "object" && !Array.isArray(value)) {
1059
+ registryWithDefaults[key] = defu(value, envDefaults);
1060
+ } else if (Array.isArray(value)) {
1061
+ registryWithDefaults[key] = defu(value[0] || {}, envDefaults);
1062
+ } else {
1063
+ registryWithDefaults[key] = value;
1064
+ }
1065
+ } else {
1066
+ registryWithDefaults[key] = value;
1067
+ }
1068
+ }
1019
1069
  nuxt.options.runtimeConfig.public.scripts = defu(
1020
1070
  nuxt.options.runtimeConfig.public.scripts || {},
1021
- config.registry
1071
+ registryWithDefaults
1022
1072
  );
1023
1073
  }
1024
1074
  if (config.defaultScriptOptions?.bundle !== void 0) {
@@ -1194,6 +1244,12 @@ const module$1 = defineNuxtModule({
1194
1244
  phConfig.apiHost = region === "eu" ? `${firstPartyCollectPrefix}/ph-eu` : `${firstPartyCollectPrefix}/ph`;
1195
1245
  }
1196
1246
  }
1247
+ if (config.registry?.plausibleAnalytics && typeof config.registry.plausibleAnalytics === "object") {
1248
+ const paConfig = Array.isArray(config.registry.plausibleAnalytics) ? config.registry.plausibleAnalytics[0] : config.registry.plausibleAnalytics;
1249
+ if (paConfig && !paConfig.endpoint) {
1250
+ paConfig.endpoint = `${firstPartyCollectPrefix}/plausible/api/event`;
1251
+ }
1252
+ }
1197
1253
  if (unsupportedScripts.length && nuxt.options.dev) {
1198
1254
  logger.warn(
1199
1255
  `First-party mode is enabled but these scripts don't support it yet: ${unsupportedScripts.join(", ")}.
@@ -1272,6 +1328,17 @@ See: https://scripts.nuxt.com/docs/guides/first-party#static-hosting`
1272
1328
  handler: await resolvePath("./runtime/server/google-static-maps-proxy")
1273
1329
  });
1274
1330
  }
1331
+ if (config.registry?.gravatar) {
1332
+ const gravatarConfig = typeof config.registry.gravatar === "object" && !Array.isArray(config.registry.gravatar) ? config.registry.gravatar : {};
1333
+ nuxt.options.runtimeConfig.public["nuxt-scripts"] = defu(
1334
+ { gravatarProxy: { cacheMaxAge: gravatarConfig.cacheMaxAge ?? 3600 } },
1335
+ nuxt.options.runtimeConfig.public["nuxt-scripts"]
1336
+ );
1337
+ addServerHandler({
1338
+ route: "/_scripts/gravatar-proxy",
1339
+ handler: await resolvePath("./runtime/server/gravatar-proxy")
1340
+ });
1341
+ }
1275
1342
  addServerHandler({
1276
1343
  route: "/api/_scripts/x-embed",
1277
1344
  handler: await resolvePath("./runtime/server/x-embed")
package/dist/registry.mjs CHANGED
@@ -28,6 +28,17 @@ async function registry(resolve) {
28
28
  from: await resolve("./runtime/registry/cloudflare-web-analytics")
29
29
  }
30
30
  },
31
+ {
32
+ label: "Vercel Analytics",
33
+ src: "https://va.vercel-scripts.com/v1/script.js",
34
+ proxy: "vercelAnalytics",
35
+ category: "analytics",
36
+ logo: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 512 512"><path d="M256 48L496 464H16z" fill="currentColor"/></svg>`,
37
+ import: {
38
+ name: "useScriptVercelAnalytics",
39
+ from: await resolve("./runtime/registry/vercel-analytics")
40
+ }
41
+ },
31
42
  {
32
43
  label: "PostHog",
33
44
  src: false,
@@ -419,6 +430,17 @@ async function registry(resolve) {
419
430
  name: "useScriptUmamiAnalytics",
420
431
  from: await resolve("./runtime/registry/umami-analytics")
421
432
  }
433
+ },
434
+ {
435
+ label: "Gravatar",
436
+ proxy: "gravatar",
437
+ src: "https://secure.gravatar.com/js/gprofiles.js",
438
+ category: "utility",
439
+ logo: `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><circle cx="128" cy="128" r="128" fill="#1d4fc4"/><path d="M128 28c-55.2 0-100 44.8-100 100s44.8 100 100 100 100-44.8 100-100S183.2 28 128 28zm0 180c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z" fill="#fff"/></svg>`,
440
+ import: {
441
+ name: "useScriptGravatar",
442
+ from: await resolve("./runtime/registry/gravatar")
443
+ }
422
444
  }
423
445
  ];
424
446
  }
@@ -228,9 +228,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
228
228
  }) => any) | undefined;
229
229
  }>, {
230
230
  trigger: ElementScriptTrigger;
231
- centerMarker: boolean;
232
231
  width: number | string;
233
232
  height: number | string;
233
+ centerMarker: boolean;
234
234
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
235
235
  placeholder?: (props: {
236
236
  placeholder: string;
@@ -228,9 +228,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
228
228
  }) => any) | undefined;
229
229
  }>, {
230
230
  trigger: ElementScriptTrigger;
231
- centerMarker: boolean;
232
231
  width: number | string;
233
232
  height: number | string;
233
+ centerMarker: boolean;
234
234
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
235
235
  placeholder?: (props: {
236
236
  placeholder: string;
@@ -0,0 +1,22 @@
1
+ type __VLS_Props = {
2
+ /** Email address — sent to your server proxy for hashing, not sent to Gravatar */
3
+ email?: string;
4
+ /** Pre-computed SHA256 hash of the email */
5
+ hash?: string;
6
+ /** Avatar size in pixels */
7
+ size?: number;
8
+ /** Default avatar style when no Gravatar exists */
9
+ default?: string;
10
+ /** Content rating filter */
11
+ rating?: string;
12
+ /** Enable hovercards on hover */
13
+ hovercards?: boolean;
14
+ };
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
+ default: string;
17
+ size: number;
18
+ rating: string;
19
+ hovercards: boolean;
20
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
@@ -0,0 +1,46 @@
1
+ <script setup>
2
+ import { computed, onMounted, ref, useAttrs } from "vue";
3
+ import { useScriptGravatar } from "../registry/gravatar";
4
+ const props = defineProps({
5
+ email: { type: String, required: false },
6
+ hash: { type: String, required: false },
7
+ size: { type: Number, required: false, default: 80 },
8
+ default: { type: String, required: false, default: "mp" },
9
+ rating: { type: String, required: false, default: "g" },
10
+ hovercards: { type: Boolean, required: false, default: false }
11
+ });
12
+ const attrs = useAttrs();
13
+ const imgSrc = ref("");
14
+ const { onLoaded } = useScriptGravatar();
15
+ const queryOverrides = computed(() => ({
16
+ size: props.size,
17
+ default: props.default,
18
+ rating: props.rating
19
+ }));
20
+ onMounted(() => {
21
+ onLoaded((api) => {
22
+ if (props.email) {
23
+ imgSrc.value = api.getAvatarUrlFromEmail(props.email, queryOverrides.value);
24
+ } else if (props.hash) {
25
+ imgSrc.value = api.getAvatarUrl(props.hash, queryOverrides.value);
26
+ }
27
+ });
28
+ });
29
+ </script>
30
+
31
+ <template>
32
+ <img
33
+ v-if="imgSrc"
34
+ :src="imgSrc"
35
+ :width="size"
36
+ :height="size"
37
+ :class="{ hovercard: hovercards }"
38
+ v-bind="attrs"
39
+ :alt="attrs.alt || 'Gravatar avatar'"
40
+ loading="lazy"
41
+ >
42
+ <span
43
+ v-else
44
+ :style="{ display: 'inline-block', width: `${size}px`, height: `${size}px`, borderRadius: '50%', background: '#e0e0e0' }"
45
+ />
46
+ </template>
@@ -0,0 +1,22 @@
1
+ type __VLS_Props = {
2
+ /** Email address — sent to your server proxy for hashing, not sent to Gravatar */
3
+ email?: string;
4
+ /** Pre-computed SHA256 hash of the email */
5
+ hash?: string;
6
+ /** Avatar size in pixels */
7
+ size?: number;
8
+ /** Default avatar style when no Gravatar exists */
9
+ default?: string;
10
+ /** Content rating filter */
11
+ rating?: string;
12
+ /** Enable hovercards on hover */
13
+ hovercards?: boolean;
14
+ };
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
+ default: string;
17
+ size: number;
18
+ rating: string;
19
+ hovercards: boolean;
20
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
@@ -3,8 +3,8 @@ type __VLS_Props = {
3
3
  size?: number;
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- color: string;
7
6
  size: number;
7
+ color: string;
8
8
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
9
  declare const _default: typeof __VLS_export;
10
10
  export default _default;
@@ -3,8 +3,8 @@ type __VLS_Props = {
3
3
  size?: number;
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- color: string;
7
6
  size: number;
7
+ color: string;
8
8
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
9
  declare const _default: typeof __VLS_export;
10
10
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
- import type { OnApproveActions, OnApproveData, OnCancelledActions, OnClickActions, OnInitActions, OnShippingAddressChangeActions, OnShippingAddressChangeData, OnShippingOptionsChangeActions, OnShippingOptionsChangeData, PayPalButtonsComponentOptions } from '@paypal/paypal-js';
2
+ import type { Components, PageTypes, SdkInstance } from '@paypal/paypal-js/sdk-v6';
3
3
  import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
@@ -12,55 +12,66 @@ type __VLS_Props = {
12
12
  */
13
13
  trigger?: ElementScriptTrigger;
14
14
  /**
15
- * The client id for the paypal script.
15
+ * Client ID or client token for PayPal SDK v6 authentication.
16
16
  */
17
17
  clientId?: string;
18
18
  /**
19
- * The options for the paypal buttons.
19
+ * Server-generated client token for SDK v6.
20
20
  */
21
- buttonOptions?: PayPalButtonsComponentOptions;
21
+ clientToken?: string;
22
22
  /**
23
- * The paypal script options.
23
+ * The v6 SDK components to load.
24
+ * @default ['paypal-payments']
24
25
  */
25
- paypalScriptOptions?: Partial<PayPalInput>;
26
+ components?: Components[];
27
+ /**
28
+ * The page type context hint.
29
+ */
30
+ pageType?: PageTypes;
31
+ /**
32
+ * The locale for the SDK (BCP-47 code).
33
+ */
34
+ locale?: string;
26
35
  /**
27
- * Disables the paypal buttons.
36
+ * The merchant ID(s).
28
37
  */
29
- disabled?: boolean;
38
+ merchantId?: string | string[];
39
+ /**
40
+ * Partner attribution ID for revenue sharing.
41
+ */
42
+ partnerAttributionId?: string;
43
+ /**
44
+ * The paypal script options.
45
+ */
46
+ paypalScriptOptions?: Partial<PayPalInput>;
30
47
  };
31
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
48
+ declare var __VLS_1: {
49
+ sdkInstance: SdkInstance<Components[]> | undefined;
50
+ }, __VLS_3: {}, __VLS_5: {}, __VLS_12: {}, __VLS_14: {};
32
51
  type __VLS_Slots = {} & {
33
- placeholder?: (props: typeof __VLS_1) => any;
52
+ default?: (props: typeof __VLS_1) => any;
34
53
  } & {
35
- loading?: (props: typeof __VLS_3) => any;
54
+ placeholder?: (props: typeof __VLS_3) => any;
36
55
  } & {
37
- awaitingLoad?: (props: typeof __VLS_10) => any;
56
+ loading?: (props: typeof __VLS_5) => any;
38
57
  } & {
39
- error?: (props: typeof __VLS_12) => any;
58
+ awaitingLoad?: (props: typeof __VLS_12) => any;
40
59
  } & {
41
- default?: (props: typeof __VLS_14) => any;
60
+ error?: (props: typeof __VLS_14) => any;
42
61
  };
43
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
44
- error: (error: Record<string, unknown>) => any;
45
- init: (data: Record<string, unknown>, actions: OnInitActions) => any;
46
- cancel: (data: Record<string, unknown>, actions: OnCancelledActions) => any;
47
- approve: (data: OnApproveData, actions: OnApproveActions) => any;
48
- clickButtons: (data: Record<string, unknown>, actions: OnClickActions) => any;
49
- shippingOptionsChange: (data: OnShippingOptionsChangeData, actions: OnShippingOptionsChangeActions) => any;
50
- shippingAddressChange: (data: OnShippingAddressChangeData, actions: OnShippingAddressChangeActions) => any;
62
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
63
+ /** The PayPal SDK v6 instance for creating payment sessions, checking eligibility, etc. */
64
+ sdkInstance: import("vue").ShallowRef<SdkInstance<Components[]> | undefined, SdkInstance<Components[]> | undefined>;
65
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
66
+ error: (error: unknown) => any;
67
+ ready: (instance: SdkInstance<Components[]>) => any;
51
68
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
52
- onError?: ((error: Record<string, unknown>) => any) | undefined;
53
- onInit?: ((data: Record<string, unknown>, actions: OnInitActions) => any) | undefined;
54
- onCancel?: ((data: Record<string, unknown>, actions: OnCancelledActions) => any) | undefined;
55
- onApprove?: ((data: OnApproveData, actions: OnApproveActions) => any) | undefined;
56
- onClickButtons?: ((data: Record<string, unknown>, actions: OnClickActions) => any) | undefined;
57
- onShippingOptionsChange?: ((data: OnShippingOptionsChangeData, actions: OnShippingOptionsChangeActions) => any) | undefined;
58
- onShippingAddressChange?: ((data: OnShippingAddressChangeData, actions: OnShippingAddressChangeActions) => any) | undefined;
69
+ onError?: ((error: unknown) => any) | undefined;
70
+ onReady?: ((instance: SdkInstance<Components[]>) => any) | undefined;
59
71
  }>, {
60
72
  trigger: ElementScriptTrigger;
61
- disabled: boolean;
62
73
  clientId: string;
63
- buttonOptions: PayPalButtonsComponentOptions;
74
+ components: Components[];
64
75
  paypalScriptOptions: Partial<PayPalInput>;
65
76
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
66
77
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,100 +1,66 @@
1
1
  <script setup>
2
2
  import { defu } from "defu";
3
- import { computed, onBeforeUnmount, onMounted, ref, resolveComponent, shallowRef, watch } from "vue";
3
+ import { computed, onBeforeUnmount, onMounted, ref, resolveComponent, shallowRef } from "vue";
4
4
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
5
5
  import { useScriptPayPal } from "../registry/paypal";
6
6
  const props = defineProps({
7
7
  rootAttrs: { type: Object, required: false },
8
8
  trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
9
9
  clientId: { type: String, required: false, default: "test" },
10
- buttonOptions: { type: Object, required: false, default: () => ({}) },
11
- paypalScriptOptions: { type: Object, required: false, default: () => ({}) },
12
- disabled: { type: Boolean, required: false, default: false }
10
+ clientToken: { type: String, required: false },
11
+ components: { type: Array, required: false, default: () => ["paypal-payments"] },
12
+ pageType: { type: String, required: false },
13
+ locale: { type: String, required: false },
14
+ merchantId: { type: [String, Array], required: false },
15
+ partnerAttributionId: { type: String, required: false },
16
+ paypalScriptOptions: { type: Object, required: false, default: () => ({}) }
13
17
  });
14
- const emit = defineEmits(["approve", "error", "cancel", "clickButtons", "shippingOptionsChange", "shippingAddressChange", "init"]);
18
+ const emit = defineEmits(["ready", "error"]);
15
19
  const el = ref(null);
16
20
  const rootEl = ref(null);
17
21
  const ready = ref(false);
22
+ const failed = ref(false);
23
+ const sdkInstance = shallowRef();
18
24
  const { onLoaded, status } = useScriptPayPal({
19
- clientId: props.clientId,
25
+ ...props.clientToken ? { clientToken: props.clientToken } : { clientId: props.clientId },
20
26
  ...props.paypalScriptOptions
21
27
  });
22
- const initActions = shallowRef(null);
23
- function handleDisabled() {
24
- if (!initActions.value)
25
- return;
26
- if (props.disabled) {
27
- initActions.value.disable();
28
- } else {
29
- initActions.value.enable();
30
- }
31
- }
32
- const options = computed(() => {
33
- const _options = {
34
- onApprove: async (data, actions) => {
35
- emit("approve", data, actions);
36
- return props.buttonOptions?.onApprove?.(data, actions);
37
- },
38
- onError: (err) => {
39
- emit("error", err);
40
- return props.buttonOptions?.onError?.(err);
41
- },
42
- onCancel: (data, actions) => {
43
- emit("cancel", data, actions);
44
- return props.buttonOptions?.onCancel?.(data, actions);
45
- },
46
- onClick: (data, actions) => {
47
- emit("clickButtons", data, actions);
48
- return props.buttonOptions?.onClick?.(data, actions);
49
- },
50
- onShippingOptionsChange: async (data, actions) => {
51
- emit("shippingOptionsChange", data, actions);
52
- return props.buttonOptions?.onShippingOptionsChange?.(data, actions);
53
- },
54
- onShippingAddressChange: async (data, actions) => {
55
- emit("shippingAddressChange", data, actions);
56
- return props.buttonOptions?.onShippingAddressChange?.(data, actions);
57
- },
58
- onInit: (data, actions) => {
59
- initActions.value = actions;
60
- actions.disable();
61
- handleDisabled();
62
- emit("init", data, actions);
63
- return props.buttonOptions?.onInit?.(data, actions);
64
- }
65
- };
66
- return defu(_options, props.buttonOptions);
67
- });
68
- watch(() => props.disabled, handleDisabled);
69
- const buttonInst = shallowRef();
70
28
  onMounted(() => {
71
29
  onLoaded(async ({ paypal }) => {
72
30
  if (!el.value)
73
31
  return;
74
- buttonInst.value = paypal?.Buttons?.(options.value);
75
- await buttonInst.value?.render(el.value);
76
- ready.value = true;
77
- watch(() => options.value, async (_options) => {
78
- if (!el.value)
79
- return;
80
- await buttonInst.value?.updateProps(_options);
81
- });
32
+ const instanceOptions = {
33
+ ...props.clientToken ? { clientToken: props.clientToken } : { clientId: props.clientId },
34
+ components: props.components,
35
+ ...props.pageType && { pageType: props.pageType },
36
+ ...props.locale && { locale: props.locale },
37
+ ...props.merchantId && { merchantId: props.merchantId },
38
+ ...props.partnerAttributionId && { partnerAttributionId: props.partnerAttributionId }
39
+ };
40
+ try {
41
+ sdkInstance.value = await paypal.createInstance(instanceOptions);
42
+ ready.value = true;
43
+ emit("ready", sdkInstance.value);
44
+ } catch (err) {
45
+ sdkInstance.value = void 0;
46
+ failed.value = true;
47
+ emit("error", err);
48
+ }
82
49
  });
83
50
  });
84
- async function destroy() {
85
- if (buttonInst.value) {
86
- await buttonInst.value?.close();
87
- }
88
- }
89
- onBeforeUnmount(async () => {
90
- await destroy();
51
+ onBeforeUnmount(() => {
52
+ sdkInstance.value = void 0;
53
+ });
54
+ defineExpose({
55
+ /** The PayPal SDK v6 instance for creating payment sessions, checking eligibility, etc. */
56
+ sdkInstance
91
57
  });
92
58
  const ScriptLoadingIndicator = resolveComponent("ScriptLoadingIndicator");
93
59
  const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
94
60
  const rootAttrs = computed(() => {
95
61
  return defu(props.rootAttrs, {
96
62
  "aria-busy": status.value === "loading",
97
- "aria-label": status.value === "awaitingLoad" ? "PayPal Script Placeholder" : status.value === "loading" ? "PayPal Buttons Loading" : "PayPal Buttons",
63
+ "aria-label": status.value === "awaitingLoad" ? "PayPal Script Placeholder" : status.value === "loading" ? "PayPal Loading" : "PayPal",
98
64
  "aria-live": "polite",
99
65
  "role": "application",
100
66
  ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
@@ -103,16 +69,17 @@ const rootAttrs = computed(() => {
103
69
  </script>
104
70
 
105
71
  <template>
106
- <div v-bind="rootAttrs" id="test">
107
- <div v-show="ready" ref="el" />
108
- <slot v-if="!ready" name="placeholder">
72
+ <div ref="rootEl" v-bind="rootAttrs">
73
+ <div ref="el">
74
+ <slot v-if="ready" name="default" :sdk-instance="sdkInstance" />
75
+ </div>
76
+ <slot v-if="status !== 'error' && !ready && !failed" name="placeholder">
109
77
  placeholder
110
78
  </slot>
111
- <slot v-if="status !== 'awaitingLoad' && !ready" name="loading">
79
+ <slot v-if="status !== 'awaitingLoad' && status !== 'error' && !ready && !failed" name="loading">
112
80
  <ScriptLoadingIndicator color="black" />
113
81
  </slot>
114
82
  <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
115
- <slot v-else-if="status === 'error'" name="error" />
116
- <slot />
83
+ <slot v-else-if="status === 'error' || failed" name="error" />
117
84
  </div>
118
85
  </template>