@netlify/plugin-nextjs 4.41.3 → 5.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 (241) hide show
  1. package/README.md +61 -17
  2. package/dist/build/cache.js +15 -0
  3. package/dist/build/content/prerendered.js +16 -0
  4. package/dist/build/content/server.js +18 -0
  5. package/dist/build/content/static.js +20 -0
  6. package/dist/build/functions/edge.js +14 -0
  7. package/dist/build/functions/server.js +16 -0
  8. package/dist/build/plugin-context.js +17 -0
  9. package/dist/esm-chunks/chunk-4AJYXTWN.js +17 -0
  10. package/dist/esm-chunks/chunk-5N2CWXSJ.js +564 -0
  11. package/dist/esm-chunks/chunk-A22224GM.js +113 -0
  12. package/dist/esm-chunks/chunk-AVWFCGVE.js +5536 -0
  13. package/dist/esm-chunks/chunk-B6QMRLBH.js +255 -0
  14. package/dist/esm-chunks/chunk-G3GM7JNF.js +92 -0
  15. package/dist/esm-chunks/chunk-GGHAQM5D.js +28 -0
  16. package/dist/esm-chunks/chunk-NOX2JUQZ.js +89 -0
  17. package/dist/esm-chunks/chunk-R4NHZWGU.js +32 -0
  18. package/dist/esm-chunks/chunk-RSKIKBZH.js +44 -0
  19. package/dist/esm-chunks/chunk-UXLNY5XK.js +86 -0
  20. package/dist/esm-chunks/chunk-VP3PT3VV.js +119 -0
  21. package/dist/esm-chunks/chunk-YZXA5QBC.js +60 -0
  22. package/dist/esm-chunks/chunk-Z7ZMLVTM.js +78 -0
  23. package/dist/index.js +66 -0
  24. package/dist/run/config.js +18 -0
  25. package/dist/run/constants.js +15 -0
  26. package/dist/run/handlers/cache.cjs +852 -0
  27. package/dist/run/handlers/server.js +3297 -0
  28. package/dist/run/headers.js +19 -0
  29. package/dist/run/next.cjs +1058 -0
  30. package/dist/run/revalidate.js +13 -0
  31. package/dist/run/systemlog.js +15 -0
  32. package/edge-runtime/README.md +29 -0
  33. package/edge-runtime/lib/headers.ts +26 -0
  34. package/edge-runtime/lib/middleware.ts +60 -0
  35. package/edge-runtime/lib/next-request.ts +59 -0
  36. package/edge-runtime/lib/response.ts +145 -0
  37. package/{src/templates/edge-shared/next-utils.ts → edge-runtime/lib/routing.ts} +64 -20
  38. package/edge-runtime/lib/util.ts +26 -0
  39. package/edge-runtime/middleware.ts +53 -0
  40. package/edge-runtime/shim/index.js +11 -0
  41. package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +1 -1
  42. package/edge-runtime/vendor/import_map.json +13 -0
  43. package/edge-runtime/vendor.ts +18 -0
  44. package/manifest.yml +1 -1
  45. package/package.json +23 -60
  46. package/index.js +0 -1
  47. package/lib/constants.js +0 -56
  48. package/lib/helpers/analysis.js +0 -115
  49. package/lib/helpers/cache.js +0 -46
  50. package/lib/helpers/compiler.js +0 -119
  51. package/lib/helpers/config.js +0 -192
  52. package/lib/helpers/dev.js +0 -20
  53. package/lib/helpers/edge.js +0 -328
  54. package/lib/helpers/files.js +0 -335
  55. package/lib/helpers/flags.js +0 -46
  56. package/lib/helpers/functions.js +0 -437
  57. package/lib/helpers/functionsMetaData.js +0 -46
  58. package/lib/helpers/matchers.js +0 -41
  59. package/lib/helpers/middlewareWatcher.js +0 -12
  60. package/lib/helpers/pack.js +0 -41
  61. package/lib/helpers/redirects.js +0 -246
  62. package/lib/helpers/types.js +0 -2
  63. package/lib/helpers/utils.js +0 -226
  64. package/lib/helpers/verification.js +0 -182
  65. package/lib/index.js +0 -194
  66. package/lib/templates/blobStorage.js +0 -30
  67. package/lib/templates/getApiHandler.js +0 -120
  68. package/lib/templates/getHandler.js +0 -201
  69. package/lib/templates/getPageResolver.js +0 -54
  70. package/lib/templates/handlerUtils.js +0 -268
  71. package/lib/templates/ipx.js +0 -13
  72. package/lib/templates/requireHooks.js +0 -105
  73. package/lib/templates/server.js +0 -159
  74. package/lib/templates/vendor.js +0 -20
  75. package/src/templates/edge/bundle.js +0 -8
  76. package/src/templates/edge/function-runtime.ts +0 -24
  77. package/src/templates/edge/imageconfig.json +0 -3
  78. package/src/templates/edge/ipx.ts +0 -5
  79. package/src/templates/edge/middleware-runtime.ts +0 -62
  80. package/src/templates/edge/next-dev.js +0 -104
  81. package/src/templates/edge/rsc-data.ts +0 -5
  82. package/src/templates/edge/shims.js +0 -77
  83. package/src/templates/edge-shared/nextConfig.json +0 -3
  84. package/src/templates/edge-shared/prerender-manifest.json +0 -7
  85. package/src/templates/edge-shared/rsc-data.ts +0 -78
  86. package/src/templates/edge-shared/utils.test.ts +0 -114
  87. package/src/templates/edge-shared/utils.ts +0 -315
  88. package/src/templates/vendor/import_map.json +0 -13
  89. /package/{src/templates/edge → edge-runtime}/matchers.json +0 -0
  90. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/fmt/colors.ts +0 -0
  91. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/_diff.ts +0 -0
  92. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/asserts.ts +0 -0
  93. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/asserts.ts +0 -0
  94. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/os.ts +0 -0
  95. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/abortable.ts +0 -0
  96. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deadline.ts +0 -0
  97. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/debounce.ts +0 -0
  98. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deferred.ts +0 -0
  99. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/delay.ts +0 -0
  100. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mod.ts +0 -0
  101. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +0 -0
  102. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/pool.ts +0 -0
  103. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/retry.ts +0 -0
  104. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/tee.ts +0 -0
  105. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +0 -0
  106. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +0 -0
  107. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +0 -0
  108. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64.ts +0 -0
  109. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64url.ts +0 -0
  110. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/flags/mod.ts +0 -0
  111. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/colors.ts +0 -0
  112. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/printf.ts +0 -0
  113. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/http/cookie.ts +0 -0
  114. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_core.ts +0 -0
  115. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.d.ts +0 -0
  116. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.mjs +0 -0
  117. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_global.d.ts +0 -0
  118. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_next_tick.ts +0 -0
  119. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +0 -0
  120. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/process.ts +0 -0
  121. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +0 -0
  122. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +0 -0
  123. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.d.ts +0 -0
  124. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.mjs +0 -0
  125. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +0 -0
  126. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_utils.ts +0 -0
  127. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assert.ts +0 -0
  128. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assertion_error.ts +0 -0
  129. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/async_hooks.ts +0 -0
  130. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/buffer.ts +0 -0
  131. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/events.ts +0 -0
  132. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +0 -0
  133. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +0 -0
  134. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +0 -0
  135. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +0 -0
  136. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +0 -0
  137. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/errors.ts +0 -0
  138. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +0 -0
  139. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +0 -0
  140. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/net.ts +0 -0
  141. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +0 -0
  142. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/options.ts +0 -0
  143. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +0 -0
  144. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +0 -0
  145. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +0 -0
  146. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +0 -0
  147. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +0 -0
  148. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +0 -0
  149. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +0 -0
  150. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +0 -0
  151. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +0 -0
  152. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +0 -0
  153. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +0 -0
  154. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util.mjs +0 -0
  155. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +0 -0
  156. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +0 -0
  157. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +0 -0
  158. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +0 -0
  159. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +0 -0
  160. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +0 -0
  161. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +0 -0
  162. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +0 -0
  163. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +0 -0
  164. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +0 -0
  165. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +0 -0
  166. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +0 -0
  167. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +0 -0
  168. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +0 -0
  169. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +0 -0
  170. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +0 -0
  171. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +0 -0
  172. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +0 -0
  173. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +0 -0
  174. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +0 -0
  175. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +0 -0
  176. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +0 -0
  177. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +0 -0
  178. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +0 -0
  179. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +0 -0
  180. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +0 -0
  181. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +0 -0
  182. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +0 -0
  183. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +0 -0
  184. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +0 -0
  185. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +0 -0
  186. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +0 -0
  187. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +0 -0
  188. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +0 -0
  189. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +0 -0
  190. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +0 -0
  191. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +0 -0
  192. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +0 -0
  193. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +0 -0
  194. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +0 -0
  195. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +0 -0
  196. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +0 -0
  197. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +0 -0
  198. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +0 -0
  199. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +0 -0
  200. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +0 -0
  201. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +0 -0
  202. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +0 -0
  203. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +0 -0
  204. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +0 -0
  205. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +0 -0
  206. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +0 -0
  207. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +0 -0
  208. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +0 -0
  209. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +0 -0
  210. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +0 -0
  211. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +0 -0
  212. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +0 -0
  213. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +0 -0
  214. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +0 -0
  215. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/process.ts +0 -0
  216. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/stream.ts +0 -0
  217. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/string_decoder.ts +0 -0
  218. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util/types.ts +0 -0
  219. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util.ts +0 -0
  220. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_constants.ts +0 -0
  221. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_interface.ts +0 -0
  222. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_util.ts +0 -0
  223. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/common.ts +0 -0
  224. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/glob.ts +0 -0
  225. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/mod.ts +0 -0
  226. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/posix.ts +0 -0
  227. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/separator.ts +0 -0
  228. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/win32.ts +0 -0
  229. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/streams/write_all.ts +0 -0
  230. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_diff.ts +0 -0
  231. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_format.ts +0 -0
  232. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/asserts.ts +0 -0
  233. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/types.d.ts +0 -0
  234. /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +0 -0
  235. /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +0 -0
  236. /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +0 -0
  237. /package/{src/templates → edge-runtime}/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +0 -0
  238. /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +0 -0
  239. /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +0 -0
  240. /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +0 -0
  241. /package/{src/templates → edge-runtime}/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +0 -0
@@ -0,0 +1,564 @@
1
+
2
+ const require = await (async () => {
3
+ const { createRequire } = await import("node:module");
4
+ return createRequire(import.meta.url);
5
+ })();
6
+
7
+
8
+ // src/run/headers.ts
9
+ import { Buffer as Buffer4 } from "node:buffer";
10
+
11
+ // node_modules/@netlify/blobs/dist/main.js
12
+ import { Buffer } from "buffer";
13
+ import { env } from "process";
14
+ import { Buffer as Buffer2 } from "buffer";
15
+ import { Buffer as Buffer3 } from "buffer";
16
+ var getEnvironmentContext = () => {
17
+ const context = globalThis.netlifyBlobsContext || env.NETLIFY_BLOBS_CONTEXT;
18
+ if (typeof context !== "string" || !context) {
19
+ return {};
20
+ }
21
+ const data = Buffer.from(context, "base64").toString();
22
+ try {
23
+ return JSON.parse(data);
24
+ } catch {
25
+ }
26
+ return {};
27
+ };
28
+ var MissingBlobsEnvironmentError = class extends Error {
29
+ constructor(requiredProperties) {
30
+ super(
31
+ `The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: ${requiredProperties.join(
32
+ ", "
33
+ )}`
34
+ );
35
+ this.name = "MissingBlobsEnvironmentError";
36
+ }
37
+ };
38
+ var BASE64_PREFIX = "b64;";
39
+ var METADATA_HEADER_INTERNAL = "x-amz-meta-user";
40
+ var METADATA_HEADER_EXTERNAL = "netlify-blobs-metadata";
41
+ var METADATA_MAX_SIZE = 2 * 1024;
42
+ var encodeMetadata = (metadata) => {
43
+ if (!metadata) {
44
+ return null;
45
+ }
46
+ const encodedObject = Buffer2.from(JSON.stringify(metadata)).toString("base64");
47
+ const payload = `b64;${encodedObject}`;
48
+ if (METADATA_HEADER_EXTERNAL.length + payload.length > METADATA_MAX_SIZE) {
49
+ throw new Error("Metadata object exceeds the maximum size");
50
+ }
51
+ return payload;
52
+ };
53
+ var decodeMetadata = (header) => {
54
+ if (!header || !header.startsWith(BASE64_PREFIX)) {
55
+ return {};
56
+ }
57
+ const encodedData = header.slice(BASE64_PREFIX.length);
58
+ const decodedData = Buffer2.from(encodedData, "base64").toString();
59
+ const metadata = JSON.parse(decodedData);
60
+ return metadata;
61
+ };
62
+ var getMetadataFromResponse = (response) => {
63
+ if (!response.headers) {
64
+ return {};
65
+ }
66
+ const value = response.headers.get(METADATA_HEADER_EXTERNAL) || response.headers.get(METADATA_HEADER_INTERNAL);
67
+ try {
68
+ return decodeMetadata(value);
69
+ } catch {
70
+ throw new Error(
71
+ "An internal error occurred while trying to retrieve the metadata for an entry. Please try updating to the latest version of the Netlify Blobs client."
72
+ );
73
+ }
74
+ };
75
+ var DEFAULT_RETRY_DELAY = 5e3;
76
+ var MIN_RETRY_DELAY = 1e3;
77
+ var MAX_RETRY = 5;
78
+ var RATE_LIMIT_HEADER = "X-RateLimit-Reset";
79
+ var fetchAndRetry = async (fetch, url, options, attemptsLeft = MAX_RETRY) => {
80
+ try {
81
+ const res = await fetch(url, options);
82
+ if (attemptsLeft > 0 && (res.status === 429 || res.status >= 500)) {
83
+ const delay = getDelay(res.headers.get(RATE_LIMIT_HEADER));
84
+ await sleep(delay);
85
+ return fetchAndRetry(fetch, url, options, attemptsLeft - 1);
86
+ }
87
+ return res;
88
+ } catch (error) {
89
+ if (attemptsLeft === 0) {
90
+ throw error;
91
+ }
92
+ const delay = getDelay();
93
+ await sleep(delay);
94
+ return fetchAndRetry(fetch, url, options, attemptsLeft - 1);
95
+ }
96
+ };
97
+ var getDelay = (rateLimitReset) => {
98
+ if (!rateLimitReset) {
99
+ return DEFAULT_RETRY_DELAY;
100
+ }
101
+ return Math.max(Number(rateLimitReset) * 1e3 - Date.now(), MIN_RETRY_DELAY);
102
+ };
103
+ var sleep = (ms) => new Promise((resolve2) => {
104
+ setTimeout(resolve2, ms);
105
+ });
106
+ var Client = class {
107
+ constructor({ apiURL, edgeURL, fetch, siteID, token }) {
108
+ this.apiURL = apiURL;
109
+ this.edgeURL = edgeURL;
110
+ this.fetch = fetch ?? globalThis.fetch;
111
+ this.siteID = siteID;
112
+ this.token = token;
113
+ if (!this.fetch) {
114
+ throw new Error(
115
+ "Netlify Blobs could not find a `fetch` client in the global scope. You can either update your runtime to a version that includes `fetch` (like Node.js 18.0.0 or above), or you can supply your own implementation using the `fetch` property."
116
+ );
117
+ }
118
+ }
119
+ async getFinalRequest({ key, metadata, method, parameters = {}, storeName }) {
120
+ const encodedMetadata = encodeMetadata(metadata);
121
+ if (this.edgeURL) {
122
+ const headers = {
123
+ authorization: `Bearer ${this.token}`
124
+ };
125
+ if (encodedMetadata) {
126
+ headers[METADATA_HEADER_INTERNAL] = encodedMetadata;
127
+ }
128
+ const path = key ? `/${this.siteID}/${storeName}/${key}` : `/${this.siteID}/${storeName}`;
129
+ const url2 = new URL(path, this.edgeURL);
130
+ for (const key2 in parameters) {
131
+ url2.searchParams.set(key2, parameters[key2]);
132
+ }
133
+ return {
134
+ headers,
135
+ url: url2.toString()
136
+ };
137
+ }
138
+ const apiHeaders = { authorization: `Bearer ${this.token}` };
139
+ const url = new URL(`/api/v1/sites/${this.siteID}/blobs`, this.apiURL ?? "https://api.netlify.com");
140
+ for (const key2 in parameters) {
141
+ url.searchParams.set(key2, parameters[key2]);
142
+ }
143
+ url.searchParams.set("context", storeName);
144
+ if (key === void 0) {
145
+ return {
146
+ headers: apiHeaders,
147
+ url: url.toString()
148
+ };
149
+ }
150
+ url.pathname += `/${key}`;
151
+ if (encodedMetadata) {
152
+ apiHeaders[METADATA_HEADER_EXTERNAL] = encodedMetadata;
153
+ }
154
+ if (method === "head") {
155
+ return {
156
+ headers: apiHeaders,
157
+ url: url.toString()
158
+ };
159
+ }
160
+ const res = await this.fetch(url.toString(), { headers: apiHeaders, method });
161
+ if (res.status !== 200) {
162
+ throw new Error(`Netlify Blobs has generated an internal error: ${res.status} response`);
163
+ }
164
+ const { url: signedURL } = await res.json();
165
+ const userHeaders = encodedMetadata ? { [METADATA_HEADER_INTERNAL]: encodedMetadata } : void 0;
166
+ return {
167
+ headers: userHeaders,
168
+ url: signedURL
169
+ };
170
+ }
171
+ async makeRequest({
172
+ body,
173
+ headers: extraHeaders,
174
+ key,
175
+ metadata,
176
+ method,
177
+ parameters,
178
+ storeName
179
+ }) {
180
+ const { headers: baseHeaders = {}, url } = await this.getFinalRequest({
181
+ key,
182
+ metadata,
183
+ method,
184
+ parameters,
185
+ storeName
186
+ });
187
+ const headers = {
188
+ ...baseHeaders,
189
+ ...extraHeaders
190
+ };
191
+ if (method === "put") {
192
+ headers["cache-control"] = "max-age=0, stale-while-revalidate=60";
193
+ }
194
+ const options = {
195
+ body,
196
+ headers,
197
+ method
198
+ };
199
+ if (body instanceof ReadableStream) {
200
+ options.duplex = "half";
201
+ }
202
+ return fetchAndRetry(this.fetch, url, options);
203
+ }
204
+ };
205
+ var getClientOptions = (options, contextOverride) => {
206
+ const context = contextOverride ?? getEnvironmentContext();
207
+ const siteID = context.siteID ?? options.siteID;
208
+ const token = context.token ?? options.token;
209
+ if (!siteID || !token) {
210
+ throw new MissingBlobsEnvironmentError(["siteID", "token"]);
211
+ }
212
+ const clientOptions = {
213
+ apiURL: context.apiURL ?? options.apiURL,
214
+ edgeURL: context.edgeURL ?? options.edgeURL,
215
+ fetch: options.fetch,
216
+ siteID,
217
+ token
218
+ };
219
+ return clientOptions;
220
+ };
221
+ var BlobsInternalError = class extends Error {
222
+ constructor(statusCode) {
223
+ super(`Netlify Blobs has generated an internal error: ${statusCode} response`);
224
+ this.name = "BlobsInternalError";
225
+ }
226
+ };
227
+ var collectIterator = async (iterator) => {
228
+ const result = [];
229
+ for await (const item of iterator) {
230
+ result.push(item);
231
+ }
232
+ return result;
233
+ };
234
+ var Store = class _Store {
235
+ constructor(options) {
236
+ this.client = options.client;
237
+ if ("deployID" in options) {
238
+ _Store.validateDeployID(options.deployID);
239
+ this.name = `deploy:${options.deployID}`;
240
+ } else {
241
+ _Store.validateStoreName(options.name);
242
+ this.name = options.name;
243
+ }
244
+ }
245
+ async delete(key) {
246
+ const res = await this.client.makeRequest({ key, method: "delete", storeName: this.name });
247
+ if (![200, 204, 404].includes(res.status)) {
248
+ throw new BlobsInternalError(res.status);
249
+ }
250
+ }
251
+ async get(key, options) {
252
+ const { type } = options ?? {};
253
+ const res = await this.client.makeRequest({ key, method: "get", storeName: this.name });
254
+ if (res.status === 404) {
255
+ return null;
256
+ }
257
+ if (res.status !== 200) {
258
+ throw new BlobsInternalError(res.status);
259
+ }
260
+ if (type === void 0 || type === "text") {
261
+ return res.text();
262
+ }
263
+ if (type === "arrayBuffer") {
264
+ return res.arrayBuffer();
265
+ }
266
+ if (type === "blob") {
267
+ return res.blob();
268
+ }
269
+ if (type === "json") {
270
+ return res.json();
271
+ }
272
+ if (type === "stream") {
273
+ return res.body;
274
+ }
275
+ throw new BlobsInternalError(res.status);
276
+ }
277
+ async getMetadata(key) {
278
+ const res = await this.client.makeRequest({ key, method: "head", storeName: this.name });
279
+ if (res.status === 404) {
280
+ return null;
281
+ }
282
+ if (res.status !== 200 && res.status !== 304) {
283
+ throw new BlobsInternalError(res.status);
284
+ }
285
+ const etag = res?.headers.get("etag") ?? void 0;
286
+ const metadata = getMetadataFromResponse(res);
287
+ const result = {
288
+ etag,
289
+ metadata
290
+ };
291
+ return result;
292
+ }
293
+ async getWithMetadata(key, options) {
294
+ const { etag: requestETag, type } = options ?? {};
295
+ const headers = requestETag ? { "if-none-match": requestETag } : void 0;
296
+ const res = await this.client.makeRequest({ headers, key, method: "get", storeName: this.name });
297
+ if (res.status === 404) {
298
+ return null;
299
+ }
300
+ if (res.status !== 200 && res.status !== 304) {
301
+ throw new BlobsInternalError(res.status);
302
+ }
303
+ const responseETag = res?.headers.get("etag") ?? void 0;
304
+ const metadata = getMetadataFromResponse(res);
305
+ const result = {
306
+ etag: responseETag,
307
+ metadata
308
+ };
309
+ if (res.status === 304 && requestETag) {
310
+ return { data: null, ...result };
311
+ }
312
+ if (type === void 0 || type === "text") {
313
+ return { data: await res.text(), ...result };
314
+ }
315
+ if (type === "arrayBuffer") {
316
+ return { data: await res.arrayBuffer(), ...result };
317
+ }
318
+ if (type === "blob") {
319
+ return { data: await res.blob(), ...result };
320
+ }
321
+ if (type === "json") {
322
+ return { data: await res.json(), ...result };
323
+ }
324
+ if (type === "stream") {
325
+ return { data: res.body, ...result };
326
+ }
327
+ throw new Error(`Invalid 'type' property: ${type}. Expected: arrayBuffer, blob, json, stream, or text.`);
328
+ }
329
+ list(options = {}) {
330
+ const iterator = this.getListIterator(options);
331
+ if (options.paginate) {
332
+ return iterator;
333
+ }
334
+ return collectIterator(iterator).then(
335
+ (items) => items.reduce(
336
+ (acc, item) => ({
337
+ blobs: [...acc.blobs, ...item.blobs],
338
+ directories: [...acc.directories, ...item.directories]
339
+ }),
340
+ { blobs: [], directories: [] }
341
+ )
342
+ );
343
+ }
344
+ async set(key, data, { metadata } = {}) {
345
+ _Store.validateKey(key);
346
+ const res = await this.client.makeRequest({
347
+ body: data,
348
+ key,
349
+ metadata,
350
+ method: "put",
351
+ storeName: this.name
352
+ });
353
+ if (res.status !== 200) {
354
+ throw new BlobsInternalError(res.status);
355
+ }
356
+ }
357
+ async setJSON(key, data, { metadata } = {}) {
358
+ _Store.validateKey(key);
359
+ const payload = JSON.stringify(data);
360
+ const headers = {
361
+ "content-type": "application/json"
362
+ };
363
+ const res = await this.client.makeRequest({
364
+ body: payload,
365
+ headers,
366
+ key,
367
+ metadata,
368
+ method: "put",
369
+ storeName: this.name
370
+ });
371
+ if (res.status !== 200) {
372
+ throw new BlobsInternalError(res.status);
373
+ }
374
+ }
375
+ static formatListResultBlob(result) {
376
+ if (!result.key) {
377
+ return null;
378
+ }
379
+ return {
380
+ etag: result.etag,
381
+ key: result.key
382
+ };
383
+ }
384
+ static validateKey(key) {
385
+ if (key === "") {
386
+ throw new Error("Blob key must not be empty.");
387
+ }
388
+ if (key.startsWith("/") || key.startsWith("%2F")) {
389
+ throw new Error("Blob key must not start with forward slash (/).");
390
+ }
391
+ if (Buffer3.byteLength(key, "utf8") > 600) {
392
+ throw new Error(
393
+ "Blob key must be a sequence of Unicode characters whose UTF-8 encoding is at most 600 bytes long."
394
+ );
395
+ }
396
+ }
397
+ static validateDeployID(deployID) {
398
+ if (!/^\w{1,24}$/.test(deployID)) {
399
+ throw new Error(`'${deployID}' is not a valid Netlify deploy ID.`);
400
+ }
401
+ }
402
+ static validateStoreName(name) {
403
+ if (name.startsWith("deploy:") || name.startsWith("deploy%3A1")) {
404
+ throw new Error("Store name must not start with the `deploy:` reserved keyword.");
405
+ }
406
+ if (name.includes("/") || name.includes("%2F")) {
407
+ throw new Error("Store name must not contain forward slashes (/).");
408
+ }
409
+ if (Buffer3.byteLength(name, "utf8") > 64) {
410
+ throw new Error(
411
+ "Store name must be a sequence of Unicode characters whose UTF-8 encoding is at most 64 bytes long."
412
+ );
413
+ }
414
+ }
415
+ getListIterator(options) {
416
+ const { client, name: storeName } = this;
417
+ const parameters = {};
418
+ if (options?.prefix) {
419
+ parameters.prefix = options.prefix;
420
+ }
421
+ if (options?.directories) {
422
+ parameters.directories = "true";
423
+ }
424
+ return {
425
+ [Symbol.asyncIterator]() {
426
+ let currentCursor = null;
427
+ let done = false;
428
+ return {
429
+ async next() {
430
+ if (done) {
431
+ return { done: true, value: void 0 };
432
+ }
433
+ const nextParameters = { ...parameters };
434
+ if (currentCursor !== null) {
435
+ nextParameters.cursor = currentCursor;
436
+ }
437
+ const res = await client.makeRequest({
438
+ method: "get",
439
+ parameters: nextParameters,
440
+ storeName
441
+ });
442
+ const page = await res.json();
443
+ if (page.next_cursor) {
444
+ currentCursor = page.next_cursor;
445
+ } else {
446
+ done = true;
447
+ }
448
+ const blobs = (page.blobs ?? []).map(_Store.formatListResultBlob).filter(Boolean);
449
+ return {
450
+ done: false,
451
+ value: {
452
+ blobs,
453
+ directories: page.directories ?? []
454
+ }
455
+ };
456
+ }
457
+ };
458
+ }
459
+ };
460
+ }
461
+ };
462
+ var getDeployStore = (options = {}) => {
463
+ const context = getEnvironmentContext();
464
+ const deployID = options.deployID ?? context.deployID;
465
+ if (!deployID) {
466
+ throw new MissingBlobsEnvironmentError(["deployID"]);
467
+ }
468
+ const clientOptions = getClientOptions(options, context);
469
+ const client = new Client(clientOptions);
470
+ return new Store({ client, deployID });
471
+ };
472
+
473
+ // src/run/headers.ts
474
+ var generateNetlifyVaryValues = ({ headers, languages, cookies }) => {
475
+ const values = [];
476
+ if (headers.length !== 0) {
477
+ values.push(`header=${headers.join(`|`)}`);
478
+ }
479
+ if (languages.length !== 0) {
480
+ values.push(`language=${languages.join(`|`)}`);
481
+ }
482
+ if (cookies.length !== 0) {
483
+ values.push(`cookie=${cookies.join(`|`)}`);
484
+ }
485
+ return values.join(",");
486
+ };
487
+ var getHeaderValueArray = (header) => {
488
+ return header.split(",").map((value) => value.trim());
489
+ };
490
+ var omitHeaderValues = (header, values) => {
491
+ const headerValues = getHeaderValueArray(header);
492
+ const filteredValues = headerValues.filter(
493
+ (value) => !values.some((val) => value.startsWith(val))
494
+ );
495
+ return filteredValues.join(", ");
496
+ };
497
+ var mapHeaderValues = (header, callback) => {
498
+ const headerValues = getHeaderValueArray(header);
499
+ const mappedValues = headerValues.map(callback);
500
+ return mappedValues.join(", ");
501
+ };
502
+ var setVaryHeaders = (headers, request, { basePath, i18n }) => {
503
+ const netlifyVaryValues = {
504
+ headers: [],
505
+ languages: [],
506
+ cookies: ["__prerender_bypass", "__next_preview_data"]
507
+ };
508
+ const vary = headers.get("vary");
509
+ if (vary !== null) {
510
+ netlifyVaryValues.headers.push(...getHeaderValueArray(vary));
511
+ }
512
+ const path = new URL(request.url).pathname;
513
+ const locales = i18n && i18n.localeDetection !== false ? i18n.locales : [];
514
+ if (locales.length > 1 && (path === "/" || path === basePath)) {
515
+ netlifyVaryValues.languages.push(...locales);
516
+ netlifyVaryValues.cookies.push(`NEXT_LOCALE`);
517
+ }
518
+ headers.set(`netlify-vary`, generateNetlifyVaryValues(netlifyVaryValues));
519
+ };
520
+ function encodeBlobKey(key) {
521
+ return Buffer4.from(key.replace(/^\//, "")).toString("base64");
522
+ }
523
+ var adjustDateHeader = async (headers, request) => {
524
+ if (headers.get("x-nextjs-cache") !== "HIT") {
525
+ return;
526
+ }
527
+ const path = new URL(request.url).pathname;
528
+ const key = encodeBlobKey(path);
529
+ const blobStore = getDeployStore();
530
+ const { lastModified } = await blobStore.get(key, { type: "json" }) ?? {};
531
+ if (!lastModified) {
532
+ return;
533
+ }
534
+ const lastModifiedDate = new Date(lastModified);
535
+ headers.set("x-nextjs-date", headers.get("date") ?? lastModifiedDate.toUTCString());
536
+ headers.set("date", lastModifiedDate.toUTCString());
537
+ };
538
+ var setCacheControlHeaders = (headers, request) => {
539
+ const cacheControl = headers.get("cache-control");
540
+ if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
541
+ const privateCacheControl = omitHeaderValues(cacheControl, [
542
+ "s-maxage",
543
+ "stale-while-revalidate"
544
+ ]);
545
+ const sharedCacheControl = mapHeaderValues(
546
+ cacheControl,
547
+ (value) => value === "stale-while-revalidate" ? "stale-while-revalidate=31536000" : value
548
+ );
549
+ headers.set("cache-control", privateCacheControl || "public, max-age=0, must-revalidate");
550
+ headers.set("netlify-cdn-cache-control", sharedCacheControl);
551
+ }
552
+ };
553
+ var setCacheTagsHeaders = (headers, request, manifest) => {
554
+ const path = new URL(request.url).pathname;
555
+ const tags = manifest[path];
556
+ headers.set("cache-tag", tags);
557
+ };
558
+
559
+ export {
560
+ setVaryHeaders,
561
+ adjustDateHeader,
562
+ setCacheControlHeaders,
563
+ setCacheTagsHeaders
564
+ };
@@ -0,0 +1,113 @@
1
+
2
+ const require = await (async () => {
3
+ const { createRequire } = await import("node:module");
4
+ return createRequire(import.meta.url);
5
+ })();
6
+
7
+ import {
8
+ require_out
9
+ } from "./chunk-AVWFCGVE.js";
10
+ import {
11
+ __toESM
12
+ } from "./chunk-RSKIKBZH.js";
13
+
14
+ // src/build/content/server.ts
15
+ var import_fast_glob = __toESM(require_out(), 1);
16
+ import { existsSync } from "node:fs";
17
+ import { cp, mkdir, readFile, readdir, readlink, symlink, writeFile } from "node:fs/promises";
18
+ import { dirname, join } from "node:path";
19
+ var copyNextServerCode = async (ctx) => {
20
+ const srcDir = join(ctx.publishDir, "standalone/.next");
21
+ const destDir = join(ctx.serverHandlerDir, ".next");
22
+ const paths = await (0, import_fast_glob.default)([`*`, `server/*`, `server/chunks/*`, `server/+(app|pages)/**/*.js`], {
23
+ cwd: srcDir,
24
+ extglob: true
25
+ });
26
+ await Promise.all(
27
+ paths.map(async (path) => {
28
+ const srcPath = join(srcDir, path);
29
+ const destPath = join(destDir, path);
30
+ if (path === "server/middleware-manifest.json") {
31
+ try {
32
+ await replaceMiddlewareManifest(srcPath, destPath);
33
+ } catch (error) {
34
+ throw new Error("Could not patch middleware manifest file", { cause: error });
35
+ }
36
+ return;
37
+ }
38
+ await cp(srcPath, destPath, { recursive: true });
39
+ })
40
+ );
41
+ };
42
+ async function recreateNodeModuleSymlinks(src, dest, org) {
43
+ const dirents = await readdir(join(src, org || ""), { withFileTypes: true });
44
+ await Promise.all(
45
+ dirents.map(async (dirent) => {
46
+ if (dirent.name.startsWith("@")) {
47
+ return recreateNodeModuleSymlinks(src, dest, dirent.name);
48
+ }
49
+ if (dirent.isSymbolicLink()) {
50
+ const symlinkSrc = join(dest, org || "", dirent.name);
51
+ const symlinkTarget = await readlink(join(src, org || "", dirent.name));
52
+ const symlinkDest = join(dest, org || "", symlinkTarget);
53
+ if (existsSync(symlinkDest) && !existsSync(symlinkSrc)) {
54
+ if (org) {
55
+ await mkdir(join(dest, org), { recursive: true });
56
+ }
57
+ await symlink(symlinkDest, symlinkSrc);
58
+ }
59
+ }
60
+ })
61
+ );
62
+ }
63
+ var copyNextDependencies = async (ctx) => {
64
+ const srcDir = join(ctx.publishDir, "standalone/node_modules");
65
+ const destDir = join(ctx.serverHandlerDir, "node_modules");
66
+ await cp(srcDir, destDir, { recursive: true });
67
+ await recreateNodeModuleSymlinks(ctx.resolve("node_modules"), destDir);
68
+ };
69
+ var writeTagsManifest = async (ctx) => {
70
+ const manifest = await ctx.getPrerenderManifest();
71
+ const routes = Object.entries(manifest.routes).map(async ([route, definition]) => {
72
+ let tags;
73
+ if (definition.dataRoute?.endsWith(".rsc")) {
74
+ const path = join(ctx.publishDir, `server/app/${route === "/" ? "/index" : route}.meta`);
75
+ try {
76
+ const file = await readFile(path, "utf-8");
77
+ const meta = JSON.parse(file);
78
+ tags = meta.headers["x-next-cache-tags"];
79
+ } catch {
80
+ console.log(`Unable to read cache tags for: ${path}`);
81
+ }
82
+ }
83
+ if (definition.dataRoute?.endsWith(".json")) {
84
+ tags = `_N_T_${route}`;
85
+ }
86
+ if (definition.dataRoute === null) {
87
+ tags = definition.initialHeaders?.["x-next-cache-tags"];
88
+ }
89
+ return [route, tags];
90
+ });
91
+ await writeFile(
92
+ join(ctx.serverHandlerDir, ".netlify/tags-manifest.json"),
93
+ JSON.stringify(Object.fromEntries(await Promise.all(routes))),
94
+ "utf-8"
95
+ );
96
+ };
97
+ var replaceMiddlewareManifest = async (sourcePath, destPath) => {
98
+ await mkdir(dirname(destPath), { recursive: true });
99
+ const data = await readFile(sourcePath, "utf8");
100
+ const manifest = JSON.parse(data);
101
+ const newManifest = {
102
+ ...manifest,
103
+ middleware: {}
104
+ };
105
+ const newData = JSON.stringify(newManifest);
106
+ await writeFile(destPath, newData);
107
+ };
108
+
109
+ export {
110
+ copyNextServerCode,
111
+ copyNextDependencies,
112
+ writeTagsManifest
113
+ };