@nuxt/scripts 1.0.0-beta.1 → 1.0.0-beta.13

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 (139) hide show
  1. package/README.md +6 -0
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/48AF9EJD.js +1 -0
  5. package/dist/client/_nuxt/Bk6ed9rg.js +1 -0
  6. package/dist/client/_nuxt/C4Cj8gBr.js +162 -0
  7. package/dist/client/_nuxt/{DTDyDxvR.js → DP0kj6Xn.js} +1 -1
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/0e95b1cc-8751-4000-8cb4-a6ef270b636f.json +1 -0
  10. package/dist/client/_nuxt/entry.D45OuV0w.css +1 -0
  11. package/dist/client/_nuxt/error-404.B57D-jUQ.css +1 -0
  12. package/dist/client/_nuxt/error-500.DTHUW7BI.css +1 -0
  13. package/dist/client/index.html +1 -1
  14. package/dist/module.d.mts +87 -2
  15. package/dist/module.d.ts +176 -0
  16. package/dist/module.json +1 -1
  17. package/dist/module.mjs +710 -273
  18. package/dist/registry.d.ts +6 -0
  19. package/dist/registry.mjs +42 -19
  20. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +1 -1
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +6 -6
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +1 -1
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +6 -6
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +7 -7
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +6 -6
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +12 -12
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +6 -6
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +1 -1
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +6 -6
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +1 -1
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +5 -5
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +7 -7
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +7 -7
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +7 -7
  35. package/dist/runtime/components/ScriptCrisp.vue +1 -1
  36. package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
  37. package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +53 -0
  38. package/dist/runtime/components/ScriptInstagramEmbed.vue +38 -0
  39. package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +53 -0
  40. package/dist/runtime/components/ScriptIntercom.vue +4 -3
  41. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +1 -1
  42. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
  43. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +2 -2
  44. package/dist/runtime/components/ScriptPayPalButtons.vue +13 -11
  45. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +2 -2
  46. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +2 -2
  47. package/dist/runtime/components/ScriptPayPalMarks.vue +10 -8
  48. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +2 -2
  49. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +2 -2
  50. package/dist/runtime/components/ScriptPayPalMessages.vue +11 -9
  51. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +2 -2
  52. package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
  53. package/dist/runtime/components/ScriptVimeoPlayer.vue +1 -1
  54. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +82 -0
  55. package/dist/runtime/components/ScriptXEmbed.vue +76 -0
  56. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +82 -0
  57. package/dist/runtime/components/ScriptYouTubePlayer.vue +7 -4
  58. package/dist/runtime/composables/useScript.js +32 -6
  59. package/dist/runtime/composables/useScriptEventPage.js +2 -2
  60. package/dist/runtime/composables/useScriptTriggerConsent.js +1 -1
  61. package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
  62. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
  63. package/dist/runtime/composables/useScriptTriggerServiceWorker.d.ts +7 -0
  64. package/dist/runtime/composables/useScriptTriggerServiceWorker.js +39 -0
  65. package/dist/runtime/registry/clarity.js +21 -25
  66. package/dist/runtime/registry/cloudflare-web-analytics.js +1 -1
  67. package/dist/runtime/registry/crisp.js +1 -1
  68. package/dist/runtime/registry/databuddy-analytics.js +1 -1
  69. package/dist/runtime/registry/fathom-analytics.js +1 -1
  70. package/dist/runtime/registry/google-adsense.js +1 -1
  71. package/dist/runtime/registry/google-analytics.js +2 -2
  72. package/dist/runtime/registry/google-maps.d.ts +1 -1
  73. package/dist/runtime/registry/google-maps.js +1 -1
  74. package/dist/runtime/registry/google-recaptcha.js +2 -2
  75. package/dist/runtime/registry/google-sign-in.js +1 -1
  76. package/dist/runtime/registry/google-tag-manager.d.ts +1 -1
  77. package/dist/runtime/registry/google-tag-manager.js +2 -2
  78. package/dist/runtime/registry/hotjar.js +1 -1
  79. package/dist/runtime/registry/instagram-embed.d.ts +23 -0
  80. package/dist/runtime/registry/instagram-embed.js +22 -0
  81. package/dist/runtime/registry/intercom.js +1 -1
  82. package/dist/runtime/registry/lemon-squeezy.d.ts +0 -1
  83. package/dist/runtime/registry/matomo-analytics.js +2 -2
  84. package/dist/runtime/registry/meta-pixel.js +1 -1
  85. package/dist/runtime/registry/npm.js +1 -1
  86. package/dist/runtime/registry/paypal.d.ts +1 -1
  87. package/dist/runtime/registry/paypal.js +2 -2
  88. package/dist/runtime/registry/plausible-analytics.js +15 -9
  89. package/dist/runtime/registry/posthog.d.ts +3 -2
  90. package/dist/runtime/registry/posthog.js +8 -12
  91. package/dist/runtime/registry/reddit-pixel.js +1 -1
  92. package/dist/runtime/registry/rybbit-analytics.js +5 -3
  93. package/dist/runtime/registry/segment.js +1 -1
  94. package/dist/runtime/registry/snapchat-pixel.js +1 -1
  95. package/dist/runtime/registry/stripe.d.ts +1 -1
  96. package/dist/runtime/registry/stripe.js +1 -1
  97. package/dist/runtime/registry/tiktok-pixel.d.ts +1 -0
  98. package/dist/runtime/registry/tiktok-pixel.js +2 -1
  99. package/dist/runtime/registry/umami-analytics.js +1 -1
  100. package/dist/runtime/registry/vimeo-player.d.ts +2 -2
  101. package/dist/runtime/registry/vimeo-player.js +1 -1
  102. package/dist/runtime/registry/x-embed.d.ts +77 -0
  103. package/dist/runtime/registry/x-embed.js +41 -0
  104. package/dist/runtime/registry/x-pixel.js +1 -1
  105. package/dist/runtime/registry/youtube-player.d.ts +7 -7
  106. package/dist/runtime/registry/youtube-player.js +1 -1
  107. package/dist/runtime/server/google-static-maps-proxy.js +1 -1
  108. package/dist/runtime/server/instagram-embed-asset.d.ts +2 -0
  109. package/dist/runtime/server/instagram-embed-asset.js +42 -0
  110. package/dist/runtime/server/instagram-embed-image.d.ts +2 -0
  111. package/dist/runtime/server/instagram-embed-image.js +54 -0
  112. package/dist/runtime/server/instagram-embed.d.ts +2 -0
  113. package/dist/runtime/server/instagram-embed.js +91 -0
  114. package/dist/runtime/server/proxy-handler.d.ts +6 -0
  115. package/dist/runtime/server/proxy-handler.js +264 -0
  116. package/dist/runtime/server/utils/privacy.d.ts +141 -0
  117. package/dist/runtime/server/utils/privacy.js +324 -0
  118. package/dist/runtime/server/x-embed-image.d.ts +2 -0
  119. package/dist/runtime/server/x-embed-image.js +53 -0
  120. package/dist/runtime/server/x-embed.d.ts +49 -0
  121. package/dist/runtime/server/x-embed.js +31 -0
  122. package/dist/runtime/types.d.ts +51 -22
  123. package/dist/runtime/utils/pure.d.ts +9 -0
  124. package/dist/runtime/utils/pure.js +0 -0
  125. package/dist/runtime/utils.d.ts +3 -3
  126. package/dist/runtime/utils.js +3 -2
  127. package/dist/shared/scripts.DLRgvHQg.mjs +288 -0
  128. package/dist/stats.d.mts +39 -0
  129. package/dist/stats.d.ts +39 -0
  130. package/dist/stats.mjs +711 -0
  131. package/dist/types.d.mts +1 -1
  132. package/package.json +48 -41
  133. package/dist/client/_nuxt/Bdf7Qtwg.js +0 -1
  134. package/dist/client/_nuxt/CoyZWCgl.js +0 -162
  135. package/dist/client/_nuxt/Ds1k3yKJ.js +0 -1
  136. package/dist/client/_nuxt/builds/meta/62574f80-71d4-4f9e-8b96-145c85230d99.json +0 -1
  137. package/dist/client/_nuxt/entry.BjfcJo5q.css +0 -1
  138. package/dist/client/_nuxt/error-404.D45Vtjcx.css +0 -1
  139. package/dist/client/_nuxt/error-500.BOm1rWQf.css +0 -1
@@ -0,0 +1,324 @@
1
+ const FULL_PRIVACY = { ip: true, userAgent: true, language: true, screen: true, timezone: true, hardware: true };
2
+ const NO_PRIVACY = { ip: false, userAgent: false, language: false, screen: false, timezone: false, hardware: false };
3
+ export function resolvePrivacy(input) {
4
+ if (input === true)
5
+ return { ...FULL_PRIVACY };
6
+ if (input === false || input === void 0 || input === null)
7
+ return { ...NO_PRIVACY };
8
+ return {
9
+ ip: input.ip ?? false,
10
+ userAgent: input.userAgent ?? false,
11
+ language: input.language ?? false,
12
+ screen: input.screen ?? false,
13
+ timezone: input.timezone ?? false,
14
+ hardware: input.hardware ?? false
15
+ };
16
+ }
17
+ export function mergePrivacy(base, override) {
18
+ if (override === void 0 || override === null)
19
+ return base;
20
+ if (typeof override === "boolean")
21
+ return resolvePrivacy(override);
22
+ return {
23
+ ip: override.ip !== void 0 ? override.ip : base.ip,
24
+ userAgent: override.userAgent !== void 0 ? override.userAgent : base.userAgent,
25
+ language: override.language !== void 0 ? override.language : base.language,
26
+ screen: override.screen !== void 0 ? override.screen : base.screen,
27
+ timezone: override.timezone !== void 0 ? override.timezone : base.timezone,
28
+ hardware: override.hardware !== void 0 ? override.hardware : base.hardware
29
+ };
30
+ }
31
+ export const IP_HEADERS = [
32
+ "x-forwarded-for",
33
+ "x-real-ip",
34
+ "forwarded",
35
+ "cf-connecting-ip",
36
+ "true-client-ip",
37
+ "x-client-ip",
38
+ "x-cluster-client-ip"
39
+ ];
40
+ export const FINGERPRINT_HEADERS = [
41
+ "user-agent",
42
+ "accept-language",
43
+ "accept-encoding",
44
+ "sec-ch-ua",
45
+ "sec-ch-ua-platform",
46
+ "sec-ch-ua-mobile",
47
+ "sec-ch-ua-full-version-list"
48
+ ];
49
+ export const SENSITIVE_HEADERS = [
50
+ "cookie",
51
+ "authorization",
52
+ "proxy-authorization",
53
+ "x-csrf-token",
54
+ "www-authenticate"
55
+ ];
56
+ export const STRIP_PARAMS = {
57
+ // IP addresses — anonymized to subnet
58
+ ip: ["uip", "ip", "client_ip_address", "ip_address", "user_ip", "ipaddress", "context.ip"],
59
+ // User identifiers — intentionally preserved for analytics functionality
60
+ userId: ["uid", "user_id", "userid", "external_id", "cid", "_gid", "fbp", "fbc", "sid", "session_id", "sessionid", "pl_id", "p_user_id", "uuid", "anonymousid", "twclid", "u_c1", "u_sclid", "u_scsid"],
61
+ // User data (PII) — intentionally preserved; hashed by analytics SDKs before sending
62
+ userData: ["ud", "user_data", "userdata", "email", "phone", "traits.email", "traits.phone"],
63
+ // Screen/Hardware — generalized to common buckets
64
+ screen: ["sr", "vp", "sd", "screen", "viewport", "colordepth", "pixelratio", "sh", "sw"],
65
+ // Hardware capabilities — generalized to common buckets
66
+ hardware: ["hardwareconcurrency", "devicememory", "cpu", "mem"],
67
+ // Platform identifiers — low entropy, kept as-is (e.g. "Linux", "x86")
68
+ platform: ["plat", "platform", "d_a", "d_ot"],
69
+ // Version strings — generalized to major version only (d_os = Snapchat OS version, uapv = GA platform version)
70
+ version: ["d_os", "uapv"],
71
+ // Browser version lists — generalized to major versions (d_bvs = Snapchat, uafvl = GA Client Hints)
72
+ browserVersion: ["d_bvs", "uafvl"],
73
+ // Browser data lists — replaced with empty value
74
+ browserData: ["plugins", "fonts"],
75
+ // Location/Timezone — generalized
76
+ location: ["tz", "timezone", "timezoneoffset"],
77
+ // Canvas/WebGL/Audio fingerprints — replaced with empty value (pure fingerprints, no analytics value)
78
+ canvas: ["canvas", "webgl", "audiofingerprint"],
79
+ // Combined device fingerprinting (X/Twitter dv param contains: timezone, locale, vendor, platform, screen, etc.)
80
+ deviceInfo: ["dv", "device_info", "deviceinfo"]
81
+ };
82
+ export const NORMALIZE_PARAMS = {
83
+ language: ["ul", "lang", "language", "languages"],
84
+ userAgent: ["ua", "useragent", "user_agent", "client_user_agent", "context.useragent"]
85
+ };
86
+ export function anonymizeIP(ip) {
87
+ if (ip.includes(":")) {
88
+ return `${ip.split(":").slice(0, 3).join(":")}::`;
89
+ }
90
+ const parts = ip.split(".");
91
+ if (parts.length === 4) {
92
+ parts[3] = "0";
93
+ return parts.join(".");
94
+ }
95
+ return ip;
96
+ }
97
+ export function normalizeUserAgent(ua) {
98
+ const tokens = [
99
+ ["Edg/", "Edge"],
100
+ ["OPR/", "Opera"],
101
+ ["Opera/", "Opera"],
102
+ ["Firefox/", "Firefox"],
103
+ ["Chrome/", "Chrome"],
104
+ ["Safari/", "Safari"]
105
+ ];
106
+ for (const [pattern, family] of tokens) {
107
+ const idx = ua.indexOf(pattern);
108
+ if (idx !== -1) {
109
+ const versionStart = idx + pattern.length;
110
+ const majorVersion = ua.slice(versionStart).match(/^(\d+)/)?.[1];
111
+ if (majorVersion)
112
+ return `Mozilla/5.0 (compatible; ${family}/${majorVersion}.0)`;
113
+ }
114
+ }
115
+ return "Mozilla/5.0 (compatible)";
116
+ }
117
+ export function normalizeLanguage(lang) {
118
+ return lang.split(",")[0]?.split(";")[0]?.trim() || "en";
119
+ }
120
+ const SCREEN_BUCKETS = {
121
+ desktop: { w: 1920, h: 1080 },
122
+ tablet: { w: 768, h: 1024 },
123
+ mobile: { w: 360, h: 640 }
124
+ };
125
+ function getDeviceClass(width) {
126
+ if (width >= 1200)
127
+ return "desktop";
128
+ if (width >= 700)
129
+ return "tablet";
130
+ return "mobile";
131
+ }
132
+ export function generalizeScreen(value, dimension) {
133
+ if (typeof value === "string" && value.includes("x")) {
134
+ const width = Number.parseInt(value.split("x")[0] || "0");
135
+ const cls = getDeviceClass(width);
136
+ return `${SCREEN_BUCKETS[cls].w}x${SCREEN_BUCKETS[cls].h}`;
137
+ }
138
+ const num = typeof value === "number" ? value : Number(value);
139
+ if (!Number.isNaN(num)) {
140
+ const cls = getDeviceClass(num);
141
+ const bucketed = dimension === "height" ? SCREEN_BUCKETS[cls].h : SCREEN_BUCKETS[cls].w;
142
+ return typeof value === "number" ? bucketed : String(bucketed);
143
+ }
144
+ return "1920x1080";
145
+ }
146
+ export function generalizeHardware(value) {
147
+ const num = typeof value === "number" ? value : Number(value);
148
+ if (Number.isNaN(num))
149
+ return 4;
150
+ if (num >= 16)
151
+ return 16;
152
+ if (num >= 8)
153
+ return 8;
154
+ if (num >= 4)
155
+ return 4;
156
+ return 2;
157
+ }
158
+ export function generalizeVersion(value) {
159
+ if (typeof value !== "string")
160
+ return String(value);
161
+ const match = value.match(/^(\d+)(([.\-_])\d+)*/);
162
+ if (!match)
163
+ return String(value);
164
+ const major = match[1];
165
+ const sep = match[3] || ".";
166
+ const segmentCount = value.split(/[.\-_]/).length;
167
+ return major + `${sep}0`.repeat(segmentCount - 1);
168
+ }
169
+ export function generalizeBrowserVersions(value) {
170
+ if (typeof value !== "string")
171
+ return String(value);
172
+ const zeroSegments = (ver) => {
173
+ const parts = ver.split(".");
174
+ return parts[0] + parts.slice(1).map(() => ".0").join("");
175
+ };
176
+ if (value.includes('"version"'))
177
+ return value.replace(/("version"\s*:\s*")(\d+(?:\.\d+)*)/g, (_, prefix, ver) => prefix + zeroSegments(ver));
178
+ if (value.includes(";"))
179
+ return value.replace(/;(\d+(?:\.\d+)*)/g, (_, ver) => `;${zeroSegments(ver)}`);
180
+ return value;
181
+ }
182
+ export function generalizeTimezone(value) {
183
+ if (typeof value === "number") {
184
+ return Math.round(value / 180) * 180;
185
+ }
186
+ if (typeof value === "string") {
187
+ return "UTC";
188
+ }
189
+ return 0;
190
+ }
191
+ export function anonymizeDeviceInfo(value) {
192
+ const sep = value.includes("|") ? "|" : "&";
193
+ const parts = value.split(sep);
194
+ if (parts.length < 4)
195
+ return value;
196
+ const result = [...parts];
197
+ for (let i = 0; i < parts.length; i++) {
198
+ const part = parts[i];
199
+ if (part.includes("/") && /^[A-Z]/.test(part)) {
200
+ result[i] = String(generalizeTimezone(part));
201
+ continue;
202
+ }
203
+ if (/^[a-z]{2}(?:-[a-z]{2,})?$/i.test(part)) {
204
+ result[i] = normalizeLanguage(part);
205
+ continue;
206
+ }
207
+ const num = Number(part);
208
+ if (!Number.isNaN(num) && num >= 300 && num <= 1e4) {
209
+ const nextNum = Number(parts[i + 1]);
210
+ if (!Number.isNaN(nextNum) && nextNum >= 300 && nextNum <= 1e4) {
211
+ const cls = getDeviceClass(num);
212
+ result[i] = String(SCREEN_BUCKETS[cls].w);
213
+ result[i + 1] = String(SCREEN_BUCKETS[cls].h);
214
+ i++;
215
+ continue;
216
+ }
217
+ result[i] = String(generalizeScreen(num));
218
+ continue;
219
+ }
220
+ if (!Number.isNaN(num) && num < -60) {
221
+ result[i] = String(generalizeTimezone(num));
222
+ }
223
+ }
224
+ return result.join(sep);
225
+ }
226
+ export function stripPayloadFingerprinting(payload, privacy) {
227
+ const p = privacy || FULL_PRIVACY;
228
+ const result = {};
229
+ let deviceClass;
230
+ for (const [key, value] of Object.entries(payload)) {
231
+ if (key.toLowerCase() === "sw") {
232
+ const num = typeof value === "number" ? value : Number(value);
233
+ if (!Number.isNaN(num))
234
+ deviceClass = getDeviceClass(num);
235
+ }
236
+ }
237
+ for (const [key, value] of Object.entries(payload)) {
238
+ const lowerKey = key.toLowerCase();
239
+ const matchesParam = (key2, params) => {
240
+ const lk = key2.toLowerCase();
241
+ return params.some((pm) => {
242
+ const lp = pm.toLowerCase();
243
+ return lk === lp || lk.startsWith(`${lp}[`);
244
+ });
245
+ };
246
+ const isLanguageParam = NORMALIZE_PARAMS.language.some((pm) => lowerKey === pm.toLowerCase());
247
+ if (isLanguageParam) {
248
+ if (Array.isArray(value)) {
249
+ result[key] = p.language ? value.map((v) => typeof v === "string" ? normalizeLanguage(v) : v) : value;
250
+ } else if (typeof value === "string") {
251
+ result[key] = p.language ? normalizeLanguage(value) : value;
252
+ } else {
253
+ result[key] = value;
254
+ }
255
+ continue;
256
+ }
257
+ const isUserAgentParam = NORMALIZE_PARAMS.userAgent.some((pm) => lowerKey === pm.toLowerCase());
258
+ if (isUserAgentParam && typeof value === "string") {
259
+ result[key] = p.userAgent ? normalizeUserAgent(value) : value;
260
+ continue;
261
+ }
262
+ if (matchesParam(key, STRIP_PARAMS.ip) && typeof value === "string") {
263
+ result[key] = p.ip ? anonymizeIP(value) : value;
264
+ continue;
265
+ }
266
+ if (matchesParam(key, STRIP_PARAMS.screen)) {
267
+ if (!p.screen) {
268
+ result[key] = value;
269
+ continue;
270
+ }
271
+ if (["sd", "colordepth", "pixelratio"].includes(lowerKey)) {
272
+ result[key] = value;
273
+ } else if (lowerKey === "sh" && deviceClass) {
274
+ const paired = SCREEN_BUCKETS[deviceClass].h;
275
+ result[key] = typeof value === "number" ? paired : String(paired);
276
+ } else {
277
+ result[key] = generalizeScreen(value, lowerKey === "sw" ? "width" : lowerKey === "sh" ? "height" : void 0);
278
+ }
279
+ continue;
280
+ }
281
+ if (matchesParam(key, STRIP_PARAMS.hardware)) {
282
+ result[key] = p.screen ? generalizeHardware(value) : value;
283
+ continue;
284
+ }
285
+ if (matchesParam(key, STRIP_PARAMS.version)) {
286
+ result[key] = p.hardware ? generalizeVersion(value) : value;
287
+ continue;
288
+ }
289
+ if (matchesParam(key, STRIP_PARAMS.browserVersion)) {
290
+ result[key] = p.hardware ? generalizeBrowserVersions(value) : value;
291
+ continue;
292
+ }
293
+ if (matchesParam(key, STRIP_PARAMS.location)) {
294
+ result[key] = p.timezone ? generalizeTimezone(value) : value;
295
+ continue;
296
+ }
297
+ if (matchesParam(key, STRIP_PARAMS.browserData)) {
298
+ result[key] = p.hardware ? Array.isArray(value) ? [] : "" : value;
299
+ continue;
300
+ }
301
+ if (matchesParam(key, STRIP_PARAMS.canvas)) {
302
+ result[key] = p.hardware ? typeof value === "number" ? 0 : typeof value === "object" ? {} : "" : value;
303
+ continue;
304
+ }
305
+ if (matchesParam(key, STRIP_PARAMS.deviceInfo)) {
306
+ result[key] = p.hardware ? typeof value === "string" ? anonymizeDeviceInfo(value) : "" : value;
307
+ continue;
308
+ }
309
+ if (matchesParam(key, STRIP_PARAMS.platform)) {
310
+ result[key] = value;
311
+ continue;
312
+ }
313
+ if (Array.isArray(value)) {
314
+ result[key] = value.map(
315
+ (item) => typeof item === "object" && item !== null ? stripPayloadFingerprinting(item, privacy) : item
316
+ );
317
+ } else if (typeof value === "object" && value !== null) {
318
+ result[key] = stripPayloadFingerprinting(value, privacy);
319
+ } else {
320
+ result[key] = value;
321
+ }
322
+ }
323
+ return result;
324
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
2
+ export default _default;
@@ -0,0 +1,53 @@
1
+ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ export default defineEventHandler(async (event) => {
4
+ const query = getQuery(event);
5
+ const url = query.url;
6
+ if (!url) {
7
+ throw createError({
8
+ statusCode: 400,
9
+ statusMessage: "Image URL is required"
10
+ });
11
+ }
12
+ let parsedUrl;
13
+ try {
14
+ parsedUrl = new URL(url);
15
+ } catch {
16
+ throw createError({
17
+ statusCode: 400,
18
+ statusMessage: "Invalid image URL"
19
+ });
20
+ }
21
+ if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
22
+ throw createError({
23
+ statusCode: 400,
24
+ statusMessage: "Invalid URL scheme"
25
+ });
26
+ }
27
+ const allowedDomains = [
28
+ "pbs.twimg.com",
29
+ "abs.twimg.com",
30
+ "video.twimg.com"
31
+ ];
32
+ if (!allowedDomains.includes(parsedUrl.hostname)) {
33
+ throw createError({
34
+ statusCode: 403,
35
+ statusMessage: "Domain not allowed"
36
+ });
37
+ }
38
+ const response = await $fetch.raw(url, {
39
+ timeout: 5e3,
40
+ headers: {
41
+ "Accept": "image/webp,image/jpeg,image/png,image/*,*/*;q=0.8",
42
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
43
+ }
44
+ }).catch((error) => {
45
+ throw createError({
46
+ statusCode: error.statusCode || 500,
47
+ statusMessage: error.statusMessage || "Failed to fetch image"
48
+ });
49
+ });
50
+ setHeader(event, "Content-Type", response.headers.get("content-type") || "image/jpeg");
51
+ setHeader(event, "Cache-Control", "public, max-age=3600, s-maxage=3600");
52
+ return response._data;
53
+ });
@@ -0,0 +1,49 @@
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>>;
49
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ export default defineEventHandler(async (event) => {
4
+ const query = getQuery(event);
5
+ const tweetId = query.id;
6
+ if (!tweetId || !/^\d+$/.test(tweetId)) {
7
+ throw createError({
8
+ statusCode: 400,
9
+ statusMessage: "Valid Tweet ID is required"
10
+ });
11
+ }
12
+ const randomToken = [...Array.from({ length: 11 })].map(() => (Math.random() * 36).toString(36)[2]).join("");
13
+ const params = new URLSearchParams({ id: tweetId, token: randomToken });
14
+ const tweetData = await $fetch(
15
+ `https://cdn.syndication.twimg.com/tweet-result?${params.toString()}`,
16
+ {
17
+ headers: {
18
+ "Accept": "application/json",
19
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
20
+ }
21
+ }
22
+ ).catch((error) => {
23
+ throw createError({
24
+ statusCode: error.statusCode || 500,
25
+ statusMessage: error.statusMessage || "Failed to fetch tweet"
26
+ });
27
+ });
28
+ setHeader(event, "Content-Type", "application/json");
29
+ setHeader(event, "Cache-Control", "public, max-age=600, s-maxage=600");
30
+ return tweetData;
31
+ });
@@ -1,37 +1,37 @@
1
+ import type { UseScriptInput, UseScriptOptions, VueScriptInstance } from '@unhead/vue';
1
2
  import type { Script } from '@unhead/vue/types';
2
- import type { UseScriptInput, VueScriptInstance, UseScriptOptions } from '@unhead/vue';
3
- import type { ComputedRef, Ref } from 'vue';
4
- import type { InferInput, ObjectSchema, ValiError } from 'valibot';
5
3
  import type { Import } from 'unimport';
6
- import type { SegmentInput } from './registry/segment.js';
4
+ import type { InferInput, ObjectSchema, ValiError } from 'valibot';
5
+ import type { ComputedRef, Ref } from 'vue';
6
+ import type { ClarityInput } from './registry/clarity.js';
7
7
  import type { CloudflareWebAnalyticsInput } from './registry/cloudflare-web-analytics.js';
8
+ import type { CrispInput } from './registry/crisp.js';
8
9
  import type { DatabuddyAnalyticsInput } from './registry/databuddy-analytics.js';
9
- import type { MetaPixelInput } from './registry/meta-pixel.js';
10
10
  import type { FathomAnalyticsInput } from './registry/fathom-analytics.js';
11
+ import type { GoogleAdsenseInput } from './registry/google-adsense.js';
12
+ import type { GoogleAnalyticsInput } from './registry/google-analytics.js';
13
+ import type { GoogleMapsInput } from './registry/google-maps.js';
14
+ import type { GoogleRecaptchaInput } from './registry/google-recaptcha.js';
15
+ import type { GoogleTagManagerInput } from './registry/google-tag-manager.js';
11
16
  import type { HotjarInput } from './registry/hotjar.js';
12
17
  import type { IntercomInput } from './registry/intercom.js';
13
- import type { GoogleMapsInput } from './registry/google-maps.js';
18
+ import type { LemonSqueezyInput } from './registry/lemon-squeezy.js';
14
19
  import type { MatomoAnalyticsInput } from './registry/matomo-analytics.js';
15
- import type { StripeInput } from './registry/stripe.js';
16
- import type { VimeoPlayerInput } from './registry/vimeo-player.js';
17
- import type { XPixelInput } from './registry/x-pixel.js';
18
- import type { SnapTrPixelInput } from './registry/snapchat-pixel.js';
19
- import type { YouTubePlayerInput } from './registry/youtube-player.js';
20
- import type { PlausibleAnalyticsInput } from './registry/plausible-analytics.js';
20
+ import type { MetaPixelInput } from './registry/meta-pixel.js';
21
21
  import type { NpmInput } from './registry/npm.js';
22
- import type { LemonSqueezyInput } from './registry/lemon-squeezy.js';
23
- import type { GoogleAdsenseInput } from './registry/google-adsense.js';
24
- import type { ClarityInput } from './registry/clarity.js';
25
- import type { CrispInput } from './registry/crisp.js';
26
- import type { GoogleAnalyticsInput } from './registry/google-analytics.js';
27
- import type { GoogleTagManagerInput } from './registry/google-tag-manager.js';
28
- import type { UmamiAnalyticsInput } from './registry/umami-analytics.js';
29
- import type { RybbitAnalyticsInput } from './registry/rybbit-analytics.js';
30
- import type { RedditPixelInput } from './registry/reddit-pixel.js';
31
22
  import type { PayPalInput } from './registry/paypal.js';
23
+ import type { PlausibleAnalyticsInput } from './registry/plausible-analytics.js';
32
24
  import type { PostHogInput } from './registry/posthog.js';
33
- import type { GoogleRecaptchaInput } from './registry/google-recaptcha.js';
25
+ import type { RedditPixelInput } from './registry/reddit-pixel.js';
26
+ import type { RybbitAnalyticsInput } from './registry/rybbit-analytics.js';
27
+ import type { SegmentInput } from './registry/segment.js';
28
+ import type { SnapTrPixelInput } from './registry/snapchat-pixel.js';
29
+ import type { StripeInput } from './registry/stripe.js';
34
30
  import type { TikTokPixelInput } from './registry/tiktok-pixel.js';
31
+ import type { UmamiAnalyticsInput } from './registry/umami-analytics.js';
32
+ import type { VimeoPlayerInput } from './registry/vimeo-player.js';
33
+ import type { XPixelInput } from './registry/x-pixel.js';
34
+ import type { YouTubePlayerInput } from './registry/youtube-player.js';
35
35
  export type WarmupStrategy = false | 'preload' | 'preconnect' | 'dns-prefetch';
36
36
  export type UseScriptContext<T extends Record<symbol | string, any>> = VueScriptInstance<T> & {
37
37
  /**
@@ -57,8 +57,24 @@ export type NuxtUseScriptOptions<T extends Record<symbol | string, any> = {}> =
57
57
  * - `false` - Do not bundle the script. (default)
58
58
  *
59
59
  * Note: Using 'force' may significantly increase build time as scripts will be re-downloaded on every build.
60
+ *
61
+ * @deprecated Use `scripts.firstParty: true` in nuxt.config instead for bundling and routing scripts through your domain.
60
62
  */
61
63
  bundle?: boolean | 'force';
64
+ /**
65
+ * Opt-out of first-party routing for this specific script when global `scripts.firstParty` is enabled.
66
+ * Set to `false` to load this script directly from its original source instead of through your domain.
67
+ *
68
+ * Note: This option only works as an opt-out. To enable first-party routing, use the global `scripts.firstParty` option in nuxt.config.
69
+ */
70
+ firstParty?: false;
71
+ /**
72
+ * Load the script in a web worker using Partytown.
73
+ * When enabled, adds `type="text/partytown"` to the script tag.
74
+ * Requires @nuxtjs/partytown to be installed and configured separately.
75
+ * @see https://partytown.qwik.dev/
76
+ */
77
+ partytown?: boolean;
62
78
  /**
63
79
  * Skip any schema validation for the script input. This is useful for loading the script stubs for development without
64
80
  * loading the actual script and not getting warnings.
@@ -99,6 +115,8 @@ export type NuxtUseScriptOptionsSerializable = Omit<NuxtUseScriptOptions, 'use'
99
115
  idleTimeout: number;
100
116
  } | {
101
117
  interaction: string[];
118
+ } | {
119
+ serviceWorker: true;
102
120
  };
103
121
  };
104
122
  export type NuxtUseScriptInput = UseScriptInput;
@@ -193,6 +211,17 @@ export type RegistryScriptInput<T = EmptyOptionsSchema, Bundelable extends boole
193
211
  export interface RegistryScript {
194
212
  import?: Import;
195
213
  scriptBundling?: false | ((options?: any) => string | false);
214
+ /**
215
+ * First-party routing configuration for this script.
216
+ * - `string` - The proxy config key to use (e.g., 'googleAnalytics', 'metaPixel')
217
+ * - `false` - Explicitly disable first-party routing for this script
218
+ * - `undefined` - Use the default key derived from the function name
219
+ *
220
+ * When set to a string, the script's URLs will be rewritten and collection
221
+ * endpoints will be routed through your server when `scripts.firstParty` is enabled.
222
+ * @internal
223
+ */
224
+ proxy?: string | false;
196
225
  label?: string;
197
226
  src?: string | false;
198
227
  category?: string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Proxy configuration for third-party scripts.
3
+ */
4
+ export interface ProxyRewrite {
5
+ /** Domain and path to match (e.g., 'www.google-analytics.com/g/collect') */
6
+ from: string;
7
+ /** Local path to rewrite to (e.g., '/_scripts/c/ga/g/collect') */
8
+ to: string;
9
+ }
File without changes
@@ -1,6 +1,6 @@
1
- import type { ObjectSchema } from 'valibot';
1
+ import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry, UseFunctionType, UseScriptContext } from '#nuxt-scripts/types';
2
2
  import type { UseScriptInput } from '@unhead/vue';
3
- import type { EmptyOptionsSchema, InferIfSchema, NuxtUseScriptOptions, RegistryScriptInput, UseFunctionType, ScriptRegistry, UseScriptContext } from '#nuxt-scripts/types';
3
+ import type { ObjectSchema } from 'valibot';
4
4
  export type MaybePromise<T> = Promise<T> | T;
5
5
  type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
6
6
  scriptInput?: UseScriptInput & {
@@ -15,4 +15,4 @@ type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
15
15
  });
16
16
  export declare function scriptRuntimeConfig<T extends keyof ScriptRegistry>(key: T): ScriptRegistry[T];
17
17
  export declare function useRegistryScript<T extends Record<string | symbol, any>, O = EmptyOptionsSchema>(registryKey: keyof ScriptRegistry | string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>): UseScriptContext<UseFunctionType<NuxtUseScriptOptions<T>, T>>;
18
- export {};
18
+ export * from './utils/pure.js';
@@ -1,9 +1,9 @@
1
+ import { parse } from "#nuxt-scripts-validator";
1
2
  import { defu } from "defu";
2
3
  import { useRuntimeConfig } from "nuxt/app";
4
+ import { parseQuery, parseURL, withQuery } from "ufo";
3
5
  import { useScript } from "./composables/useScript.js";
4
6
  import { createNpmScriptStub } from "./npm-script-stub.js";
5
- import { parse } from "#nuxt-scripts-validator";
6
- import { parseURL, withQuery, parseQuery } from "ufo";
7
7
  function validateScriptInputSchema(key, schema, options) {
8
8
  if (import.meta.dev) {
9
9
  try {
@@ -95,3 +95,4 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
95
95
  };
96
96
  return useScript(scriptInput, scriptOptions);
97
97
  }
98
+ export * from "./utils/pure.js";