@nuxt/scripts 1.3.6 → 2.0.0-beta.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 (207) hide show
  1. package/THIRD_PARTY_LICENSES.md +124 -0
  2. package/dist/devtools-client/200.html +1 -1
  3. package/dist/devtools-client/404.html +1 -1
  4. package/dist/devtools-client/_nuxt/{B551Pnuh.js → 2p1_IuX2.js} +1 -1
  5. package/dist/devtools-client/_nuxt/{KxC4Q3ev.js → 9elIQxwW.js} +1 -1
  6. package/dist/devtools-client/_nuxt/{DTP8MRtW.js → BNPn63Jz.js} +1 -1
  7. package/dist/devtools-client/_nuxt/BjRLaDIG.js +152 -0
  8. package/dist/devtools-client/_nuxt/BtNUYBXT.js +8 -0
  9. package/dist/devtools-client/_nuxt/CDDBpkXG.js +3 -0
  10. package/dist/devtools-client/_nuxt/Cpb0XAYP.js +1 -0
  11. package/dist/devtools-client/_nuxt/DAsiyhPm.js +6 -0
  12. package/dist/devtools-client/_nuxt/{VICyrUSM.js → DabLKy7M.js} +1 -1
  13. package/dist/devtools-client/_nuxt/Dat651Oh.js +1 -0
  14. package/dist/devtools-client/_nuxt/DcG2ZXvY.js +1 -0
  15. package/dist/devtools-client/_nuxt/DmlGWZ2X.js +1 -0
  16. package/dist/devtools-client/_nuxt/KsX6Az5B.js +1 -0
  17. package/dist/devtools-client/_nuxt/RL1np866.js +28 -0
  18. package/dist/devtools-client/_nuxt/UmWNrBO5.js +2 -0
  19. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  20. package/dist/devtools-client/_nuxt/builds/meta/e28b96f1-78e8-41a4-ad6f-904cd078f85e.json +1 -0
  21. package/dist/devtools-client/_nuxt/{entry.CYUdJFoE.css → entry.9HJPJ6Hp.css} +1 -1
  22. package/dist/devtools-client/_nuxt/error-404.DnwL1N6v.css +1 -0
  23. package/dist/devtools-client/_nuxt/error-500.DEbXRLdm.css +1 -0
  24. package/dist/devtools-client/docs/index.html +1 -1
  25. package/dist/devtools-client/first-party/index.html +1 -1
  26. package/dist/devtools-client/index.html +1 -1
  27. package/dist/devtools-client/registry/index.html +1 -1
  28. package/dist/module.d.mts +2 -86
  29. package/dist/module.d.ts +2 -86
  30. package/dist/module.json +3 -3
  31. package/dist/module.mjs +71 -328
  32. package/dist/registry.mjs +54 -22
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +1 -28
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +7 -50
  35. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +1 -28
  36. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +0 -8
  37. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +1 -13
  38. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +0 -8
  39. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.d.vue.ts +4 -4
  40. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue +9 -15
  41. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue.d.ts +4 -4
  42. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +0 -22
  43. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +0 -31
  44. package/dist/runtime/components/Leaflet/ScriptLeafletGeoJson.d.vue.ts +31 -0
  45. package/dist/runtime/components/Leaflet/ScriptLeafletGeoJson.vue +43 -0
  46. package/dist/runtime/components/Leaflet/ScriptLeafletGeoJson.vue.d.ts +31 -0
  47. package/dist/runtime/components/Leaflet/ScriptLeafletMap.d.vue.ts +90 -0
  48. package/dist/runtime/components/Leaflet/ScriptLeafletMap.vue +171 -0
  49. package/dist/runtime/components/Leaflet/ScriptLeafletMap.vue.d.ts +90 -0
  50. package/dist/runtime/components/Leaflet/ScriptLeafletMarker.d.vue.ts +47 -0
  51. package/dist/runtime/components/Leaflet/ScriptLeafletMarker.vue +70 -0
  52. package/dist/runtime/components/Leaflet/ScriptLeafletMarker.vue.d.ts +47 -0
  53. package/dist/runtime/components/Leaflet/ScriptLeafletPopup.d.vue.ts +31 -0
  54. package/dist/runtime/components/Leaflet/ScriptLeafletPopup.vue +81 -0
  55. package/dist/runtime/components/Leaflet/ScriptLeafletPopup.vue.d.ts +31 -0
  56. package/dist/runtime/components/Leaflet/ScriptLeafletTileLayer.d.vue.ts +26 -0
  57. package/dist/runtime/components/Leaflet/ScriptLeafletTileLayer.vue +38 -0
  58. package/dist/runtime/components/Leaflet/ScriptLeafletTileLayer.vue.d.ts +26 -0
  59. package/dist/runtime/components/Leaflet/useLeafletResource.d.ts +30 -0
  60. package/dist/runtime/components/Leaflet/useLeafletResource.js +46 -0
  61. package/dist/runtime/components/MapLibre/ScriptMapLibreGeoJson.d.vue.ts +39 -0
  62. package/dist/runtime/components/MapLibre/ScriptMapLibreGeoJson.vue +84 -0
  63. package/dist/runtime/components/MapLibre/ScriptMapLibreGeoJson.vue.d.ts +39 -0
  64. package/dist/runtime/components/MapLibre/ScriptMapLibreMap.d.vue.ts +122 -0
  65. package/dist/runtime/components/MapLibre/ScriptMapLibreMap.vue +214 -0
  66. package/dist/runtime/components/MapLibre/ScriptMapLibreMap.vue.d.ts +122 -0
  67. package/dist/runtime/components/MapLibre/ScriptMapLibreMarker.d.vue.ts +35 -0
  68. package/dist/runtime/components/MapLibre/ScriptMapLibreMarker.vue +98 -0
  69. package/dist/runtime/components/MapLibre/ScriptMapLibreMarker.vue.d.ts +35 -0
  70. package/dist/runtime/components/MapLibre/ScriptMapLibreNavigationControl.d.vue.ts +12 -0
  71. package/dist/runtime/components/MapLibre/ScriptMapLibreNavigationControl.vue +23 -0
  72. package/dist/runtime/components/MapLibre/ScriptMapLibreNavigationControl.vue.d.ts +12 -0
  73. package/dist/runtime/components/MapLibre/ScriptMapLibrePopup.d.vue.ts +31 -0
  74. package/dist/runtime/components/MapLibre/ScriptMapLibrePopup.vue +99 -0
  75. package/dist/runtime/components/MapLibre/ScriptMapLibrePopup.vue.d.ts +31 -0
  76. package/dist/runtime/components/MapLibre/useMapLibreResource.d.ts +23 -0
  77. package/dist/runtime/components/MapLibre/useMapLibreResource.js +41 -0
  78. package/dist/runtime/components/ScriptCrisp.vue +20 -18
  79. package/dist/runtime/components/ScriptDeskCrew.d.vue.ts +40 -0
  80. package/dist/runtime/components/ScriptDeskCrew.vue +82 -0
  81. package/dist/runtime/components/ScriptDeskCrew.vue.d.ts +40 -0
  82. package/dist/runtime/components/ScriptIntercom.vue +21 -19
  83. package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +1 -1
  84. package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
  85. package/dist/runtime/components/ScriptPayPalButtons.vue +7 -3
  86. package/dist/runtime/components/ScriptPayPalMessages.vue +8 -4
  87. package/dist/runtime/composables/useScript.js +96 -49
  88. package/dist/runtime/composables/useScriptProxyUrl.d.ts +4 -8
  89. package/dist/runtime/composables/useScriptProxyUrl.js +0 -7
  90. package/dist/runtime/composables/useScriptTriggerIdleTimeout.d.ts +2 -1
  91. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +3 -34
  92. package/dist/runtime/composables/useScriptTriggerInteraction.d.ts +2 -1
  93. package/dist/runtime/composables/useScriptTriggerInteraction.js +13 -46
  94. package/dist/runtime/composables/useScriptTriggerServiceWorker.d.ts +2 -1
  95. package/dist/runtime/composables/useScriptTriggerServiceWorker.js +5 -38
  96. package/dist/runtime/leaflet-styles.d.ts +13 -0
  97. package/dist/runtime/leaflet-styles.js +684 -0
  98. package/dist/runtime/maplibre-styles.d.ts +7 -0
  99. package/dist/runtime/maplibre-styles.js +25 -0
  100. package/dist/runtime/npm-script-api-state.d.ts +4 -0
  101. package/dist/runtime/npm-script-api-state.js +13 -0
  102. package/dist/runtime/registry/crisp.d.ts +1 -1
  103. package/dist/runtime/registry/crisp.js +30 -18
  104. package/dist/runtime/registry/deskcrew.d.ts +52 -0
  105. package/dist/runtime/registry/deskcrew.js +31 -0
  106. package/dist/runtime/registry/google-analytics.d.ts +0 -2
  107. package/dist/runtime/registry/google-maps.d.ts +2 -11
  108. package/dist/runtime/registry/google-maps.js +31 -10
  109. package/dist/runtime/registry/google-tag-manager.d.ts +0 -2
  110. package/dist/runtime/registry/leaflet.d.ts +13 -0
  111. package/dist/runtime/registry/leaflet.js +29 -0
  112. package/dist/runtime/registry/maplibre.d.ts +13 -0
  113. package/dist/runtime/registry/maplibre.js +29 -0
  114. package/dist/runtime/registry/matomo-analytics.js +1 -8
  115. package/dist/runtime/registry/plausible-analytics.d.ts +4 -16
  116. package/dist/runtime/registry/plausible-analytics.js +15 -58
  117. package/dist/runtime/registry/rybbit-analytics.d.ts +0 -4
  118. package/dist/runtime/registry/rybbit-analytics.js +1 -4
  119. package/dist/runtime/registry/schemas.d.ts +61 -5
  120. package/dist/runtime/registry/schemas.js +64 -5
  121. package/dist/runtime/registry/tiktok-pixel.d.ts +2 -12
  122. package/dist/runtime/registry/tiktok-pixel.js +1 -1
  123. package/dist/runtime/registry/usercentrics.js +46 -6
  124. package/dist/runtime/registry/youtube-player.d.ts +3 -4
  125. package/dist/runtime/registry/youtube-player.js +30 -23
  126. package/dist/runtime/server/bluesky-embed-image.d.ts +1 -1
  127. package/dist/runtime/server/bluesky-embed.d.ts +1 -1
  128. package/dist/runtime/server/bluesky-embed.js +3 -6
  129. package/dist/runtime/server/gravatar-proxy.d.ts +1 -1
  130. package/dist/runtime/server/gravatar-proxy.js +2 -3
  131. package/dist/runtime/server/instagram-embed-asset.d.ts +1 -1
  132. package/dist/runtime/server/instagram-embed-image.d.ts +1 -1
  133. package/dist/runtime/server/instagram-embed.d.ts +1 -1
  134. package/dist/runtime/server/instagram-embed.js +4 -7
  135. package/dist/runtime/server/utils/cached-upstream.d.ts +4 -11
  136. package/dist/runtime/server/utils/embed-rewriters.d.ts +3 -5
  137. package/dist/runtime/server/utils/embed-rewriters.js +8 -8
  138. package/dist/runtime/server/utils/image-proxy.d.ts +1 -1
  139. package/dist/runtime/server/utils/image-proxy.js +2 -3
  140. package/dist/runtime/server/utils/instagram-embed.d.ts +6 -6
  141. package/dist/runtime/server/utils/instagram-embed.js +18 -19
  142. package/dist/runtime/server/utils/proxy-url.d.ts +5 -6
  143. package/dist/runtime/server/utils/proxy-url.js +1 -4
  144. package/dist/runtime/server/x-embed-image.d.ts +1 -1
  145. package/dist/runtime/server/x-embed.d.ts +48 -1
  146. package/dist/runtime/server/x-embed.js +3 -6
  147. package/dist/runtime/types.d.ts +13 -13
  148. package/dist/runtime/utils/abortable-promise.js +26 -5
  149. package/dist/runtime/utils/nuxt-ready-script-trigger.d.ts +3 -0
  150. package/dist/runtime/utils/nuxt-ready-script-trigger.js +16 -0
  151. package/dist/runtime/utils.js +21 -32
  152. package/dist/stats.mjs +13 -0
  153. package/dist/types-source.mjs +1173 -100
  154. package/dist/types.d.mts +2 -2
  155. package/package.json +34 -21
  156. package/LICENSE.md +0 -9
  157. package/bin/cli.mjs +0 -2
  158. package/dist/cli.d.mts +0 -2
  159. package/dist/cli.d.ts +0 -2
  160. package/dist/cli.mjs +0 -50
  161. package/dist/devtools-client/_nuxt/8ltZ0o6d.js +0 -1
  162. package/dist/devtools-client/_nuxt/B8_EBdhg.js +0 -152
  163. package/dist/devtools-client/_nuxt/BKdLzFmX.js +0 -3
  164. package/dist/devtools-client/_nuxt/Bf2Kt1P0.js +0 -28
  165. package/dist/devtools-client/_nuxt/CC0GKROJ.js +0 -1
  166. package/dist/devtools-client/_nuxt/CH5oUfNi.js +0 -1
  167. package/dist/devtools-client/_nuxt/CMXzQxJZ.js +0 -1
  168. package/dist/devtools-client/_nuxt/CP7c-Js6.js +0 -8
  169. package/dist/devtools-client/_nuxt/C_v3_O0R.js +0 -6
  170. package/dist/devtools-client/_nuxt/CxN78VhB.js +0 -1
  171. package/dist/devtools-client/_nuxt/Dkc7iTdR.js +0 -1
  172. package/dist/devtools-client/_nuxt/builds/meta/35e54cbc-079c-4313-8838-34632d9dac97.json +0 -1
  173. package/dist/devtools-client/_nuxt/error-404.Bq2JQbJs.css +0 -1
  174. package/dist/devtools-client/_nuxt/error-500.5E_FOzlc.css +0 -1
  175. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +0 -13
  176. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +0 -15
  177. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +0 -13
  178. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +0 -27
  179. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +0 -34
  180. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +0 -27
  181. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +0 -13
  182. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +0 -11
  183. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +0 -13
  184. package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.d.ts +0 -13
  185. package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.js +0 -8
  186. package/dist/runtime/components/GoogleMaps/injectionKeys.d.ts +0 -10
  187. package/dist/runtime/components/GoogleMaps/injectionKeys.js +0 -2
  188. package/dist/runtime/composables/useScriptProxyToken.d.ts +0 -12
  189. package/dist/runtime/composables/useScriptProxyToken.js +0 -4
  190. package/dist/runtime/npm-script-stub.d.ts +0 -20
  191. package/dist/runtime/npm-script-stub.js +0 -72
  192. package/dist/runtime/plugins/proxy-token.server.d.ts +0 -10
  193. package/dist/runtime/plugins/proxy-token.server.js +0 -17
  194. package/dist/runtime/server/google-maps-geocode-proxy.d.ts +0 -2
  195. package/dist/runtime/server/google-maps-geocode-proxy.js +0 -43
  196. package/dist/runtime/server/google-static-maps-proxy.d.ts +0 -2
  197. package/dist/runtime/server/google-static-maps-proxy.js +0 -56
  198. package/dist/runtime/server/utils/proxy-query.d.ts +0 -2
  199. package/dist/runtime/server/utils/proxy-query.js +0 -10
  200. package/dist/runtime/server/utils/sign-constants.d.ts +0 -16
  201. package/dist/runtime/server/utils/sign-constants.js +0 -5
  202. package/dist/runtime/server/utils/sign.d.ts +0 -101
  203. package/dist/runtime/server/utils/sign.js +0 -91
  204. package/dist/runtime/server/utils/withSigning.d.ts +0 -23
  205. package/dist/runtime/server/utils/withSigning.js +0 -19
  206. package/dist/runtime/unhead-features.d.ts +0 -1
  207. package/dist/runtime/unhead-features.js +0 -3
package/dist/module.mjs CHANGED
@@ -1,21 +1,20 @@
1
- import { createHash, randomBytes } from 'node:crypto';
2
- import { existsSync, readFileSync, writeFileSync, appendFileSync, readdirSync } from 'node:fs';
3
- import fsp, { open, stat, unlink } from 'node:fs/promises';
4
- import { setTimeout } from 'node:timers/promises';
5
- import { useNuxt, addDevServerHandler, extendRouteRules, tryUseNuxt, createResolver, extendViteConfig, logger as logger$1, useLogger, getNuxtVersion, addTypeTemplate, resolvePath, defineNuxtModule, addPluginTemplate, addServerHandler, addImports, addComponentsDir, addTemplate, hasNuxtModule, addBuildPlugin, addPlugin } from '@nuxt/kit';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { findPackageJSON } from 'node:module';
3
+ import { useNuxt, addDevServerHandler, extendRouteRules, tryUseNuxt, createResolver, extendViteConfig, logger as logger$1, useLogger, getNuxtVersion, addTypeTemplate, resolvePath, defineNuxtModule, addPluginTemplate, addServerHandler, addImports, addComponentsDir, addTemplate, hasNuxtModule, addBuildPlugin } from '@nuxt/kit';
6
4
  import { defu } from 'defu';
7
- import { join, resolve, dirname } from 'pathe';
8
- import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
5
+ import { satisfies } from 'semver';
9
6
  import { lazyEventHandler, eventHandler, createError, setHeader } from 'h3';
10
7
  import { fetch, $fetch } from 'ofetch';
8
+ import { join, resolve, dirname } from 'pathe';
11
9
  import { joinURL, parseURL, parseQuery, hasProtocol } from 'ufo';
12
10
  import { createStorage } from 'unstorage';
13
11
  import fsDriver from 'unstorage/drivers/fs-lite';
14
- import { Buffer as Buffer$1 } from 'node:buffer';
15
- import { isCI, provider } from 'std-env';
16
12
  import { pathToFileURL } from 'node:url';
13
+ import { isCI, provider } from 'std-env';
17
14
  import { parseAndWalk, ScopeTracker, walk, ScopeTrackerFunction, ScopeTrackerIdentifier, ScopeTrackerFunctionParam, ScopeTrackerVariable } from 'oxc-walker';
18
15
  import { createUnplugin } from 'unplugin';
16
+ import { createHash } from 'node:crypto';
17
+ import fsp from 'node:fs/promises';
19
18
  import { colors } from 'consola/utils';
20
19
  import MagicString from 'magic-string';
21
20
  import { hash } from 'ohash';
@@ -151,7 +150,7 @@ function setupStandaloneApi(nuxt) {
151
150
  req.off("error", onAborted);
152
151
  }, onAborted = function() {
153
152
  finished = true;
154
- chunks = [];
153
+ chunks.length = 0;
155
154
  cleanup();
156
155
  }, onData = function(chunk) {
157
156
  if (finished)
@@ -159,7 +158,7 @@ function setupStandaloneApi(nuxt) {
159
158
  size += chunk.byteLength;
160
159
  if (size > DEVTOOLS_API_MAX_BODY_SIZE) {
161
160
  finished = true;
162
- chunks = [];
161
+ chunks.length = 0;
163
162
  cleanup();
164
163
  req.once("error", () => {
165
164
  });
@@ -175,7 +174,7 @@ function setupStandaloneApi(nuxt) {
175
174
  finished = true;
176
175
  cleanup();
177
176
  try {
178
- const data = JSON.parse(Buffer$1.concat(chunks, size).toString("utf8"));
177
+ const data = JSON.parse(Buffer.concat(chunks).toString("utf8"));
179
178
  scriptsState = { ...data, updatedAt: Date.now() };
180
179
  res.statusCode = 200;
181
180
  res.end("ok");
@@ -183,9 +182,9 @@ function setupStandaloneApi(nuxt) {
183
182
  res.statusCode = 400;
184
183
  res.end("invalid json");
185
184
  }
186
- chunks = [];
185
+ chunks.length = 0;
187
186
  };
188
- let chunks = [];
187
+ const chunks = [];
189
188
  let size = 0;
190
189
  let finished = false;
191
190
  req.on("data", onData);
@@ -252,9 +251,16 @@ function buildDevtoolsData(proxyPrefix, privacyLabel, scripts, aliasToDomain) {
252
251
 
253
252
  const isStackblitz = provider === "stackblitz";
254
253
  async function promptToInstall(name, installCommand, options) {
255
- if (await resolvePackageJSON(name).catch(() => {
256
- return null;
257
- })) {
254
+ const installed = [options.rootDir, ...options.searchPaths || []].some((searchPath) => {
255
+ try {
256
+ return !!findPackageJSON(name, pathToFileURL(`${searchPath.replace(/\/$/, "")}/`));
257
+ } catch (error) {
258
+ if (error.code === "ERR_MODULE_NOT_FOUND")
259
+ return false;
260
+ throw error;
261
+ }
262
+ });
263
+ if (installed) {
258
264
  return true;
259
265
  }
260
266
  logger$1.info(`Package ${name} is missing`);
@@ -384,81 +390,34 @@ function extractRequiredFields(schema) {
384
390
  return [];
385
391
  return Object.entries(schema.entries).filter(([, field]) => field?.type !== "optional").map(([key]) => key);
386
392
  }
387
- function migrateDeprecatedRegistryKeys(registry, warn) {
393
+ function normalizeRegistryConfig(registry) {
388
394
  for (const key of Object.keys(registry)) {
389
395
  const entry = registry[key];
390
- if (!entry || typeof entry !== "object")
391
- continue;
392
- if (Array.isArray(entry)) {
393
- const opts = entry[1];
394
- if (opts && typeof opts === "object" && "reverseProxyIntercept" in opts) {
395
- warn(`[nuxt-scripts] registry.${key}: \`reverseProxyIntercept\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`);
396
- const o = opts;
397
- o.proxy ??= o.reverseProxyIntercept;
398
- delete o.reverseProxyIntercept;
399
- }
400
- } else {
401
- const obj = entry;
402
- if ("reverseProxyIntercept" in obj) {
403
- warn(`[nuxt-scripts] registry.${key}: \`reverseProxyIntercept\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`);
404
- obj.proxy ??= obj.reverseProxyIntercept;
405
- delete obj.reverseProxyIntercept;
406
- }
407
- const so = obj.scriptOptions;
408
- if (so && typeof so === "object" && "reverseProxyIntercept" in so) {
409
- warn(`[nuxt-scripts] registry.${key}: \`scriptOptions.reverseProxyIntercept\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`);
410
- const s = so;
411
- s.proxy ??= s.reverseProxyIntercept;
412
- delete s.reverseProxyIntercept;
413
- }
414
- }
415
- }
416
- }
417
- function normalizeRegistryConfig(registry, warn, componentOnlyKeys) {
418
- for (const key of Object.keys(registry)) {
419
- const entry = registry[key];
420
- if (!entry) {
396
+ if (entry === false || entry === null || entry === void 0) {
421
397
  delete registry[key];
422
398
  continue;
423
399
  }
424
- if (entry === true) {
425
- if (componentOnlyKeys?.has(key)) {
426
- registry[key] = [{}];
427
- continue;
428
- }
429
- warn?.(`[nuxt-scripts] registry.${key}: \`true\` shorthand is deprecated. Use \`{ trigger: 'onNuxtReady' }\` instead.`);
430
- registry[key] = [{}, { trigger: "onNuxtReady" }];
431
- continue;
432
- }
433
- if (entry === "proxy-only") {
434
- throw new Error(
435
- `[nuxt-scripts] registry.${key}: \`'proxy-only'\` is no longer supported. Use \`{}\` instead (infrastructure only is now the default behavior).`
436
- );
437
- }
438
400
  if (entry === "mock") {
439
401
  registry[key] = [{}, { trigger: "manual", skipValidation: true }];
440
- } else if (Array.isArray(entry)) {
441
- if (!entry[0] && !entry[1]) {
442
- delete registry[key];
443
- continue;
444
- }
445
- if (!entry[0])
446
- entry[0] = {};
447
- } else if (typeof entry === "object") {
448
- const { scriptOptions, ...rest } = entry;
402
+ } else if (typeof entry === "object" && !Array.isArray(entry)) {
449
403
  const input = {};
450
- const mergedScriptOptions = {};
451
- if (scriptOptions && typeof scriptOptions === "object")
452
- Object.assign(mergedScriptOptions, scriptOptions);
453
- for (const [k, v] of Object.entries(rest)) {
404
+ const scriptOptions = {};
405
+ for (const [k, v] of Object.entries(entry)) {
406
+ if (k === "scriptOptions" || k === "reverseProxyIntercept") {
407
+ throw new TypeError(
408
+ `[nuxt-scripts] registry.${key}.${k} is no longer supported.`
409
+ );
410
+ }
454
411
  if (SCRIPT_OPTION_KEYS.includes(k))
455
- mergedScriptOptions[k] = v;
412
+ scriptOptions[k] = v;
456
413
  else
457
414
  input[k] = v;
458
415
  }
459
- registry[key] = Object.keys(mergedScriptOptions).length > 0 ? [input, mergedScriptOptions] : [input];
416
+ registry[key] = Object.keys(scriptOptions).length > 0 ? [input, scriptOptions] : [input];
460
417
  } else {
461
- delete registry[key];
418
+ throw new TypeError(
419
+ `[nuxt-scripts] registry.${key}: invalid entry. Use a flat config object, 'mock', or false.`
420
+ );
462
421
  }
463
422
  }
464
423
  }
@@ -1586,10 +1545,6 @@ function resolveTriggerForTemplate(trigger) {
1586
1545
  return null;
1587
1546
  }
1588
1547
  function templatePlugin(config, registry) {
1589
- if (Array.isArray(config.globals)) {
1590
- config.globals = Object.fromEntries(config.globals.map((i) => [hash(i), i]));
1591
- logger.warn("The `globals` array option is deprecated. Convert to an object: `globals: { myScript: 'https://example.com/script.js' }`");
1592
- }
1593
1548
  const imports = [];
1594
1549
  const inits = [];
1595
1550
  const globalMapEntries = [];
@@ -1718,20 +1673,6 @@ function templatePlugin(config, registry) {
1718
1673
  ].join("\n");
1719
1674
  }
1720
1675
 
1721
- const SOURCE_LESS_SCRIPT_LOADER_TYPE = /\bUseScriptLoaderInput\b/;
1722
- function hasUnheadSourceLessScriptLoader(typesSource) {
1723
- return SOURCE_LESS_SCRIPT_LOADER_TYPE.test(typesSource);
1724
- }
1725
- function hasUnheadSourceLessScriptLoaderFile(typesPath) {
1726
- if (!typesPath || !existsSync(typesPath))
1727
- return false;
1728
- try {
1729
- return hasUnheadSourceLessScriptLoader(readFileSync(typesPath, "utf8"));
1730
- } catch {
1731
- return false;
1732
- }
1733
- }
1734
-
1735
1676
  const UPPER_RE$1 = /([A-Z])/g;
1736
1677
  const toScreamingSnake$1 = (s) => s.replace(UPPER_RE$1, "_$1").toUpperCase();
1737
1678
  const ENV_PREFIX = "NUXT_PUBLIC_SCRIPTS_";
@@ -1884,148 +1825,22 @@ function validateScriptsEnvVars(scripts, enabledRegistryKeys, logger, globalsKey
1884
1825
  }
1885
1826
  }
1886
1827
 
1887
- const SELF_CLOSING_SCRIPT_RE = /<((?:Script[A-Z]|script-)\w[\w-]*)\b([^>]*?)\/\s*>/g;
1888
- function fixSelfClosingScriptComponents(nuxt) {
1889
- function expandTags(content) {
1890
- SELF_CLOSING_SCRIPT_RE.lastIndex = 0;
1891
- if (!SELF_CLOSING_SCRIPT_RE.test(content))
1892
- return null;
1893
- SELF_CLOSING_SCRIPT_RE.lastIndex = 0;
1894
- return content.replace(SELF_CLOSING_SCRIPT_RE, (_, tag, attrs) => `<${tag}${attrs.trimEnd()}></${tag}>`);
1895
- }
1896
- function fixFile(filePath) {
1897
- if (!existsSync(filePath))
1898
- return;
1899
- const content = readFileSync(filePath, "utf-8");
1900
- const fixed = expandTags(content);
1901
- if (fixed)
1902
- nuxt.vfs[filePath] = fixed;
1903
- }
1904
- function scanDir(dir) {
1905
- if (!existsSync(dir))
1906
- return;
1907
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
1908
- const fullPath = resolve(dir, entry.name);
1909
- if (entry.isDirectory())
1910
- scanDir(fullPath);
1911
- else if (entry.name.endsWith(".vue"))
1912
- fixFile(fullPath);
1913
- }
1914
- }
1915
- const pagesDirs = /* @__PURE__ */ new Set();
1916
- for (const layer of nuxt.options._layers) {
1917
- pagesDirs.add(resolve(
1918
- layer.config.srcDir,
1919
- layer.config.dir?.pages || "pages"
1920
- ));
1921
- }
1922
- for (const dir of pagesDirs) scanDir(dir);
1923
- if (nuxt.options.dev) {
1924
- nuxt.hook("builder:watch", (_event, relativePath) => {
1925
- if (!relativePath.endsWith(".vue"))
1926
- return;
1927
- for (const layer of nuxt.options._layers) {
1928
- const fullPath = resolve(layer.config.srcDir, relativePath);
1929
- for (const dir of pagesDirs) {
1930
- if (fullPath.startsWith(`${dir}/`)) {
1931
- fixFile(fullPath);
1932
- return;
1933
- }
1934
- }
1935
- }
1936
- });
1937
- }
1938
- }
1939
1828
  const UPPER_RE = /([A-Z])/g;
1940
1829
  const toScreamingSnake = (s) => s.replace(UPPER_RE, "_$1").toUpperCase();
1941
- const PROXY_SECRET_ENV_KEY = "NUXT_SCRIPTS_PROXY_SECRET";
1942
- const PROXY_SECRET_ENV_LINE_RE = /^NUXT_SCRIPTS_PROXY_SECRET=.*$/m;
1943
- const PROXY_SECRET_ENV_VALUE_RE = /^NUXT_SCRIPTS_PROXY_SECRET=(.+)$/m;
1944
- const PROXY_SECRET_LOCK_RETRY_MS = 10;
1945
- const PROXY_SECRET_LOCK_TIMEOUT_MS = 2e3;
1946
- async function withProxySecretFileLock(envPath, effect) {
1947
- const lockPath = `${envPath}.nuxt-scripts.lock`;
1948
- const deadline = Date.now() + PROXY_SECRET_LOCK_TIMEOUT_MS;
1949
- let lockHandle;
1950
- while (!lockHandle) {
1951
- const acquisition = await open(lockPath, "wx").then((handle) => ({ _tag: "Acquired", handle })).catch((error) => {
1952
- if (error.code === "EEXIST")
1953
- return { _tag: "Busy" };
1954
- throw error;
1955
- });
1956
- if (acquisition._tag === "Acquired") {
1957
- lockHandle = acquisition.handle;
1958
- break;
1959
- }
1960
- const existingLock = await stat(lockPath).then((lockStat) => ({ _tag: "Found", mtimeMs: lockStat.mtimeMs })).catch((error) => {
1961
- if (error.code === "ENOENT")
1962
- return { _tag: "Missing" };
1963
- throw error;
1964
- });
1965
- if (existingLock._tag === "Found" && Date.now() - existingLock.mtimeMs >= PROXY_SECRET_LOCK_TIMEOUT_MS) {
1966
- await unlink(lockPath).catch((error) => {
1967
- if (error.code !== "ENOENT")
1968
- throw error;
1969
- });
1970
- continue;
1971
- }
1972
- if (Date.now() >= deadline)
1973
- throw Object.assign(new Error("Timed out waiting for proxy secret file lock"), { code: "ETIMEDOUT" });
1974
- await setTimeout(PROXY_SECRET_LOCK_RETRY_MS);
1975
- }
1976
- let effectResult;
1830
+ const UNHEAD_VERSION_RANGE = ">=3.3.1 <4";
1831
+ function readInstalledPackageVersion(name) {
1832
+ let packagePath;
1977
1833
  try {
1978
- effectResult = { _tag: "Success", value: effect() };
1834
+ packagePath = findPackageJSON(name, import.meta.url);
1979
1835
  } catch (error) {
1980
- effectResult = { _tag: "Failure", error };
1981
- }
1982
- const closeResult = await lockHandle.close().then(() => ({ _tag: "Success" })).catch((error) => ({ _tag: "Failure", error }));
1983
- const unlinkResult = await unlink(lockPath).then(() => ({ _tag: "Success" })).catch((error) => error.code === "ENOENT" ? { _tag: "Success" } : { _tag: "Failure", error });
1984
- if (closeResult._tag === "Failure")
1985
- logger.warn(`[security] Failed to close the proxy secret lock: ${closeResult.error.message}`);
1986
- if (unlinkResult._tag === "Failure")
1987
- logger.warn(`[security] Failed to remove the proxy secret lock: ${unlinkResult.error.message}`);
1988
- if (effectResult._tag === "Failure")
1989
- throw effectResult.error;
1990
- return effectResult.value;
1991
- }
1992
- async function resolveProxySecret(rootDir, isDev, configSecret, autoGenerate = true) {
1993
- if (configSecret)
1994
- return { secret: configSecret, ephemeral: false, source: "config" };
1995
- const envSecret = process.env[PROXY_SECRET_ENV_KEY];
1996
- if (envSecret)
1997
- return { secret: envSecret, ephemeral: false, source: "env" };
1998
- if (!isDev || !autoGenerate)
1999
- return void 0;
2000
- const secret = randomBytes(32).toString("hex");
2001
- const envPath = resolve(rootDir, ".env");
2002
- const line = `${PROXY_SECRET_ENV_KEY}=${secret}
2003
- `;
2004
- try {
2005
- const persistedSecret = await withProxySecretFileLock(envPath, () => {
2006
- if (existsSync(envPath)) {
2007
- const contents = readFileSync(envPath, "utf-8");
2008
- const existingSecret = contents.match(PROXY_SECRET_ENV_VALUE_RE)?.[1]?.trim();
2009
- if (existingSecret)
2010
- return existingSecret;
2011
- if (PROXY_SECRET_ENV_LINE_RE.test(contents)) {
2012
- writeFileSync(envPath, contents.replace(PROXY_SECRET_ENV_LINE_RE, `${PROXY_SECRET_ENV_KEY}=${secret}`));
2013
- } else {
2014
- appendFileSync(envPath, contents.endsWith("\n") ? line : `
2015
- ${line}`);
2016
- }
2017
- } else {
2018
- writeFileSync(envPath, `# Generated by @nuxt/scripts
2019
- ${line}`);
2020
- }
2021
- return secret;
2022
- });
2023
- process.env[PROXY_SECRET_ENV_KEY] = persistedSecret;
2024
- return { secret: persistedSecret, ephemeral: false, source: "dotenv-generated" };
2025
- } catch {
2026
- process.env[PROXY_SECRET_ENV_KEY] = secret;
2027
- return { secret, ephemeral: true, source: "memory-generated" };
1836
+ if (error.code === "ERR_MODULE_NOT_FOUND")
1837
+ return;
1838
+ throw error;
2028
1839
  }
1840
+ if (!packagePath)
1841
+ return;
1842
+ const parsed = JSON.parse(readFileSync(packagePath, "utf8"));
1843
+ return typeof parsed.version === "string" ? parsed.version : void 0;
2029
1844
  }
2030
1845
  function isProxyDisabled(registryKey, registry2, runtimeConfig) {
2031
1846
  const entry = registry2?.[registryKey];
@@ -2099,7 +1914,7 @@ const module$1 = defineNuxtModule({
2099
1914
  name: "@nuxt/scripts",
2100
1915
  configKey: "scripts",
2101
1916
  compatibility: {
2102
- nuxt: ">=3.16"
1917
+ nuxt: ">=4.5.1"
2103
1918
  }
2104
1919
  },
2105
1920
  defaults: {
@@ -2116,16 +1931,12 @@ const module$1 = defineNuxtModule({
2116
1931
  // Configures the maximum time (in milliseconds) allowed for each fetch attempt.
2117
1932
  }
2118
1933
  },
2119
- googleStaticMapsProxy: {
2120
- enabled: false,
2121
- cacheMaxAge: 3600
2122
- },
2123
1934
  enabled: true,
2124
1935
  debug: false
2125
1936
  },
2126
1937
  async setup(config, nuxt) {
2127
1938
  const { resolve: resolveModule, resolvePath } = createResolver(import.meta.url);
2128
- const { version, name } = await readPackageJSON(await resolvePath("../package.json"));
1939
+ const { version, name } = JSON.parse(readFileSync(await resolvePath("../package.json"), "utf8"));
2129
1940
  nuxt.options.alias["#nuxt-scripts"] = await resolvePath("./runtime");
2130
1941
  logger.level = config.debug || nuxt.options.debug ? 4 : 3;
2131
1942
  if (!config.enabled) {
@@ -2152,29 +1963,22 @@ const module$1 = defineNuxtModule({
2152
1963
  });
2153
1964
  }
2154
1965
  }
2155
- const unheadScriptsAlias = nuxt.options.alias["@unhead/vue/scripts"];
2156
- const unheadPackagePath = await (typeof unheadScriptsAlias === "string" ? resolvePackageJSON(unheadScriptsAlias) : Promise.reject(new Error("No Unhead scripts alias"))).catch(() => resolvePackageJSON("@unhead/vue", {
2157
- // Match the package instance imported by the built runtime. An app can
2158
- // contain another Unhead version with different loader capabilities.
2159
- from: [resolveModule("./runtime")]
2160
- })).catch(() => {
2161
- return null;
2162
- });
2163
- const unheadPackage = unheadPackagePath ? await readPackageJSON(unheadPackagePath).catch(() => {
2164
- return null;
2165
- }) : null;
2166
- const unheadVersion = unheadPackage?.version;
2167
- const scriptsTypesExport = unheadPackage?.exports?.["./scripts"]?.types;
2168
- const scriptsTypesPath = unheadPackagePath && typeof scriptsTypesExport === "string" ? resolve(dirname(unheadPackagePath), scriptsTypesExport) : null;
2169
- const unheadSourceLessScriptLoader = hasUnheadSourceLessScriptLoaderFile(scriptsTypesPath);
2170
- if (unheadVersion?.startsWith("1")) {
2171
- logger.error(`Nuxt Scripts requires Unhead >= 2, you are using v${unheadVersion}. Please run \`nuxi upgrade --clean\` to upgrade...`);
1966
+ const unheadVersions = [
1967
+ ["@unhead/vue", readInstalledPackageVersion("@unhead/vue")],
1968
+ ["unhead", readInstalledPackageVersion("unhead")]
1969
+ ];
1970
+ const incompatibleUnheadPackages = unheadVersions.filter(
1971
+ ([, dependencyVersion]) => !dependencyVersion || !satisfies(dependencyVersion, UNHEAD_VERSION_RANGE)
1972
+ );
1973
+ if (incompatibleUnheadPackages.length) {
1974
+ const resolvedVersions = incompatibleUnheadPackages.map(([dependency, dependencyVersion]) => `${dependency}=${dependencyVersion ? `v${dependencyVersion}` : "missing"}`).join(", ");
1975
+ throw new Error(
1976
+ `[nuxt-scripts] Nuxt Scripts 2 requires @unhead/vue and unhead ${UNHEAD_VERSION_RANGE}; resolved ${resolvedVersions}. Run \`npx nuxi@latest upgrade --force\` to upgrade Nuxt and refresh its dependencies.`
1977
+ );
2172
1978
  }
2173
1979
  const scripts = await registry(resolvePath);
2174
1980
  if (config.registry) {
2175
- const componentOnlyKeys = new Set(scripts.filter((s) => !s.import).map((s) => s.registryKey));
2176
- migrateDeprecatedRegistryKeys(config.registry, (msg) => logger.warn(msg));
2177
- normalizeRegistryConfig(config.registry, (msg) => logger.warn(msg), componentOnlyKeys);
1981
+ normalizeRegistryConfig(config.registry);
2178
1982
  nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
2179
1983
  const registryWithDefaults = {};
2180
1984
  for (const [key, entry] of Object.entries(config.registry)) {
@@ -2210,33 +2014,25 @@ const module$1 = defineNuxtModule({
2210
2014
  logger,
2211
2015
  Object.keys(config.globals || {})
2212
2016
  );
2213
- const googleMapsEnabled = config.googleStaticMapsProxy?.enabled || !!config.registry?.googleMaps;
2214
2017
  nuxt.options.runtimeConfig["nuxt-scripts"] = {
2215
- version,
2216
- // Private proxy config with API key (server-side only)
2217
- googleStaticMapsProxy: googleMapsEnabled ? { apiKey: nuxt.options.runtimeConfig.public.scripts?.googleMaps?.apiKey } : void 0
2018
+ version
2218
2019
  };
2219
2020
  nuxt.options.runtimeConfig.public["nuxt-scripts"] = {
2220
2021
  // expose for devtools
2221
2022
  version: nuxt.options.dev ? version : void 0,
2222
2023
  prefix: config.prefix || "/_scripts",
2223
- defaultScriptOptions: config.defaultScriptOptions,
2224
- // Only expose enabled and cacheMaxAge to client, not apiKey
2225
- googleStaticMapsProxy: googleMapsEnabled ? { enabled: true, cacheMaxAge: config.googleStaticMapsProxy?.cacheMaxAge ?? 3600 } : void 0
2024
+ defaultScriptOptions: config.defaultScriptOptions
2226
2025
  };
2227
2026
  const debugConst = JSON.stringify(!!config.debug);
2228
- const unheadSourceLessConst = JSON.stringify(unheadSourceLessScriptLoader);
2229
2027
  nuxt.options.vite ||= {};
2230
2028
  nuxt.options.vite.define = {
2231
2029
  ...nuxt.options.vite.define,
2232
- __NUXT_SCRIPTS_DEBUG__: debugConst,
2233
- __NUXT_SCRIPTS_UNHEAD_SOURCELESS__: unheadSourceLessConst
2030
+ __NUXT_SCRIPTS_DEBUG__: debugConst
2234
2031
  };
2235
2032
  nuxt.options.nitro ||= {};
2236
2033
  nuxt.options.nitro.replace = {
2237
2034
  ...nuxt.options.nitro.replace,
2238
- __NUXT_SCRIPTS_DEBUG__: debugConst,
2239
- __NUXT_SCRIPTS_UNHEAD_SOURCELESS__: unheadSourceLessConst
2035
+ __NUXT_SCRIPTS_DEBUG__: debugConst
2240
2036
  };
2241
2037
  const scriptsBase = config.prefix || "/_scripts";
2242
2038
  const proxyPrefix = `${scriptsBase}/p`;
@@ -2253,7 +2049,6 @@ const module$1 = defineNuxtModule({
2253
2049
  const composables = [
2254
2050
  "useScript",
2255
2051
  "useScriptEventPage",
2256
- "useScriptProxyToken",
2257
2052
  "useScriptProxyUrl",
2258
2053
  "useScriptTriggerConsent",
2259
2054
  "useScriptTriggerElement",
@@ -2273,7 +2068,6 @@ const module$1 = defineNuxtModule({
2273
2068
  path: await resolvePath("./runtime/components"),
2274
2069
  pathPrefix: false
2275
2070
  });
2276
- fixSelfClosingScriptComponents(nuxt);
2277
2071
  addTemplate({
2278
2072
  filename: "nuxt-scripts-trigger-resolver.mjs",
2279
2073
  getContents() {
@@ -2510,7 +2304,7 @@ They will load directly from third-party servers.`
2510
2304
  if (proxyStaticPresets.includes(proxyPreset)) {
2511
2305
  logger.warn(
2512
2306
  `Proxy collection endpoints require a server runtime (detected: ${proxyPreset || "static"}).
2513
- Scripts will be bundled, but collection requests will not be proxied and URL signing will be unavailable.
2307
+ Scripts will be bundled, but collection requests will not be proxied.
2514
2308
  Options: configure platform rewrites, switch to server-rendered mode, or disable with proxy: false.`
2515
2309
  );
2516
2310
  }
@@ -2559,11 +2353,10 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
2559
2353
  });
2560
2354
  const scriptsPrefix = config.prefix || "/_scripts";
2561
2355
  const enabledEndpoints = {};
2562
- let anyHandlerRequiresSigning = false;
2563
2356
  for (const script of scripts) {
2564
2357
  if (!script.serverHandlers?.length || !script.registryKey)
2565
2358
  continue;
2566
- const isEnabled = script.registryKey === "googleMaps" ? config.googleStaticMapsProxy?.enabled || config.registry?.googleMaps : config.registry?.[script.registryKey];
2359
+ const isEnabled = config.registry?.[script.registryKey];
2567
2360
  if (!isEnabled)
2568
2361
  continue;
2569
2362
  enabledEndpoints[script.registryKey] = true;
@@ -2574,8 +2367,6 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
2574
2367
  handler: handler.handler,
2575
2368
  middleware: handler.middleware
2576
2369
  });
2577
- if (handler.requiresSigning)
2578
- anyHandlerRequiresSigning = true;
2579
2370
  }
2580
2371
  if (script.registryKey === "gravatar") {
2581
2372
  const gravatarConfig = config.registry?.gravatar?.[0] || {};
@@ -2584,61 +2375,13 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
2584
2375
  nuxt.options.runtimeConfig.public["nuxt-scripts"]
2585
2376
  );
2586
2377
  }
2587
- if (script.registryKey === "googleMaps") {
2588
- nuxt.options.runtimeConfig["nuxt-scripts"] = defu(
2589
- { googleMapsGeocodeProxy: { apiKey: nuxt.options.runtimeConfig.public.scripts?.googleMaps?.apiKey } },
2590
- nuxt.options.runtimeConfig["nuxt-scripts"]
2591
- );
2592
- }
2593
2378
  }
2594
2379
  ensureNuxtScriptsCacheStorage(nuxt.options.nitro);
2595
2380
  nuxt.options.runtimeConfig.public["nuxt-scripts"] = defu(
2596
2381
  { endpoints: enabledEndpoints },
2597
2382
  nuxt.options.runtimeConfig.public["nuxt-scripts"]
2598
2383
  );
2599
- const staticPresets = ["static", "github-pages", "cloudflare-pages-static", "netlify-static", "azure-static", "firebase-static"];
2600
- const nitroPreset = process.env.NITRO_PRESET || "";
2601
- const isStaticTarget = staticPresets.includes(nitroPreset);
2602
- const isSpa = nuxt.options.ssr === false;
2603
- if (config.security === false) {
2604
- if (anyHandlerRequiresSigning && !nuxt.options.dev) {
2605
- logger.info("[security] Proxy security disabled via `security: false`. Proxy endpoints will pass requests through without signature verification.");
2606
- }
2607
- } else if (anyHandlerRequiresSigning && (isSpa || isStaticTarget)) {
2608
- logger.warn(
2609
- `[security] URL signing requires a server runtime${isStaticTarget ? ` (detected preset: ${nitroPreset})` : " (ssr: false)"}.
2610
- Proxy endpoints will work without signature verification.
2611
- To enable signing, deploy with a server-rendered target or configure platform-level rewrites.`
2612
- );
2613
- } else if (anyHandlerRequiresSigning) {
2614
- const proxySecretResolved = await resolveProxySecret(
2615
- nuxt.options.rootDir,
2616
- !!nuxt.options.dev,
2617
- config.security?.secret,
2618
- config.security?.autoGenerateSecret !== false
2619
- );
2620
- if (proxySecretResolved?.source === "dotenv-generated")
2621
- logger.info(`[security] Generated ${PROXY_SECRET_ENV_KEY} in .env for signed proxy URLs.`);
2622
- else if (proxySecretResolved?.source === "memory-generated")
2623
- logger.warn(`[security] Generated an in-memory ${PROXY_SECRET_ENV_KEY} (could not write .env). Signed URLs will break across restarts.`);
2624
- if (proxySecretResolved?.secret) {
2625
- const scriptsRuntime = nuxt.options.runtimeConfig["nuxt-scripts"];
2626
- scriptsRuntime.proxySecret = proxySecretResolved.secret;
2627
- if (config.security?.pageTokenMaxAge !== void 0)
2628
- scriptsRuntime.pageTokenMaxAge = config.security.pageTokenMaxAge;
2629
- addPlugin({
2630
- src: await resolvePath("./runtime/plugins/proxy-token.server"),
2631
- mode: "server"
2632
- });
2633
- } else if (!nuxt.options.dev) {
2634
- logger.warn(
2635
- `[security] ${PROXY_SECRET_ENV_KEY} is not set. Proxy endpoints will pass requests through without signature verification.
2636
- Generate one with: npx @nuxt/scripts generate-secret
2637
- Then set the env var: ${PROXY_SECRET_ENV_KEY}=<secret>`
2638
- );
2639
- }
2640
- }
2641
2384
  }
2642
2385
  });
2643
2386
 
2644
- export { applyAutoInject, module$1 as default, findMissingRequiredFields, isProxyDisabled, resolveConfiguredProxyDomains, resolveProxySecret };
2387
+ export { applyAutoInject, module$1 as default, findMissingRequiredFields, isProxyDisabled, resolveConfiguredProxyDomains };