@openuiai/next 16.2.0 → 16.2.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 (197) hide show
  1. package/dist/bin/next +2 -2
  2. package/dist/build/index.js +3 -3
  3. package/dist/build/webpack-config.js +2 -2
  4. package/dist/cache/cache-control.js +22 -0
  5. package/dist/cache/cache-control.js.map +1 -0
  6. package/dist/cache/clone-response.js +77 -0
  7. package/dist/cache/clone-response.js.map +1 -0
  8. package/dist/cache/dedupe-fetch.js +123 -0
  9. package/dist/cache/dedupe-fetch.js.map +1 -0
  10. package/dist/cache/lazy-result.js +46 -0
  11. package/dist/cache/lazy-result.js.map +1 -0
  12. package/dist/cache/lru-cache.js +177 -0
  13. package/dist/cache/lru-cache.js.map +1 -0
  14. package/dist/client/app-bootstrap.js +1 -1
  15. package/dist/client/index.js +1 -1
  16. package/dist/concurrency/batcher.js +65 -0
  17. package/dist/concurrency/batcher.js.map +1 -0
  18. package/dist/concurrency/coalesced-function.js +39 -0
  19. package/dist/concurrency/coalesced-function.js.map +1 -0
  20. package/dist/concurrency/scheduler.js +64 -0
  21. package/dist/concurrency/scheduler.js.map +1 -0
  22. package/dist/concurrency/wait.js +19 -0
  23. package/dist/concurrency/wait.js.map +1 -0
  24. package/dist/concurrency/with-promise-cache.js +24 -0
  25. package/dist/concurrency/with-promise-cache.js.map +1 -0
  26. package/dist/config/detect-typo.js +51 -0
  27. package/dist/config/detect-typo.js.map +1 -0
  28. package/dist/config/find-config.js +102 -0
  29. package/dist/config/find-config.js.map +1 -0
  30. package/dist/config/get-package-version.js +118 -0
  31. package/dist/config/get-package-version.js.map +1 -0
  32. package/dist/config/get-project-dir.js +51 -0
  33. package/dist/config/get-project-dir.js.map +1 -0
  34. package/dist/config/install-dependencies.js +40 -0
  35. package/dist/config/install-dependencies.js.map +1 -0
  36. package/dist/config/needs-experimental-react.js +16 -0
  37. package/dist/config/needs-experimental-react.js.map +1 -0
  38. package/dist/config/static-env.js +92 -0
  39. package/dist/config/static-env.js.map +1 -0
  40. package/dist/constants/constants.js +397 -0
  41. package/dist/constants/constants.js.map +1 -0
  42. package/dist/errors/compile-error.js +14 -0
  43. package/dist/errors/compile-error.js.map +1 -0
  44. package/dist/errors/error-source.js +36 -0
  45. package/dist/errors/error-source.js.map +1 -0
  46. package/dist/errors/error-telemetry-utils.js +42 -0
  47. package/dist/errors/error-telemetry-utils.js.map +1 -0
  48. package/dist/errors/fatal-error.js +14 -0
  49. package/dist/errors/fatal-error.js.map +1 -0
  50. package/dist/errors/format-server-error.js +74 -0
  51. package/dist/errors/format-server-error.js.map +1 -0
  52. package/dist/errors/invariant-error.js +18 -0
  53. package/dist/errors/invariant-error.js.map +1 -0
  54. package/dist/errors/is-error.js +65 -0
  55. package/dist/errors/is-error.js.map +1 -0
  56. package/dist/errors/no-fallback-error.js +18 -0
  57. package/dist/errors/no-fallback-error.js.map +1 -0
  58. package/dist/esm/build/index.js +3 -3
  59. package/dist/esm/build/webpack-config.js +2 -2
  60. package/dist/esm/client/app-bootstrap.js +1 -1
  61. package/dist/esm/client/index.js +1 -1
  62. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  63. package/dist/esm/server/lib/app-info-log.js +1 -1
  64. package/dist/esm/server/lib/start-server.js +1 -1
  65. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  66. package/dist/filesystem/file-exists.js +53 -0
  67. package/dist/filesystem/file-exists.js.map +1 -0
  68. package/dist/filesystem/find-pages-dir.js +65 -0
  69. package/dist/filesystem/find-pages-dir.js.map +1 -0
  70. package/dist/filesystem/find-root.js +118 -0
  71. package/dist/filesystem/find-root.js.map +1 -0
  72. package/dist/filesystem/get-files-in-dir.js +33 -0
  73. package/dist/filesystem/get-files-in-dir.js.map +1 -0
  74. package/dist/filesystem/multi-file-writer.js +75 -0
  75. package/dist/filesystem/multi-file-writer.js.map +1 -0
  76. package/dist/filesystem/realpath.js +20 -0
  77. package/dist/filesystem/realpath.js.map +1 -0
  78. package/dist/filesystem/recursive-copy.js +76 -0
  79. package/dist/filesystem/recursive-copy.js.map +1 -0
  80. package/dist/filesystem/recursive-delete.js +137 -0
  81. package/dist/filesystem/recursive-delete.js.map +1 -0
  82. package/dist/filesystem/recursive-readdir.js +124 -0
  83. package/dist/filesystem/recursive-readdir.js.map +1 -0
  84. package/dist/filesystem/rename.js +87 -0
  85. package/dist/filesystem/rename.js.map +1 -0
  86. package/dist/filesystem/write-atomic.js +28 -0
  87. package/dist/filesystem/write-atomic.js.map +1 -0
  88. package/dist/fonts/font-utils.js +43 -0
  89. package/dist/fonts/font-utils.js.map +1 -0
  90. package/dist/fonts/get-preloadable-fonts.js +39 -0
  91. package/dist/fonts/get-preloadable-fonts.js.map +1 -0
  92. package/dist/hash/bloom-filter.js +85 -0
  93. package/dist/hash/bloom-filter.js.map +1 -0
  94. package/dist/hash/etag.js +56 -0
  95. package/dist/hash/etag.js.map +1 -0
  96. package/dist/hash/fnv1a.js +56 -0
  97. package/dist/hash/fnv1a.js.map +1 -0
  98. package/dist/hash/hash.js +39 -0
  99. package/dist/hash/hash.js.map +1 -0
  100. package/dist/hostname/format-hostname.js +16 -0
  101. package/dist/hostname/format-hostname.js.map +1 -0
  102. package/dist/hostname/get-hostname.js +23 -0
  103. package/dist/hostname/get-hostname.js.map +1 -0
  104. package/dist/hostname/get-network-host.js +44 -0
  105. package/dist/hostname/get-network-host.js.map +1 -0
  106. package/dist/hostname/is-ipv6.js +41 -0
  107. package/dist/hostname/is-ipv6.js.map +1 -0
  108. package/dist/image/find-closest-quality.js +19 -0
  109. package/dist/image/find-closest-quality.js.map +1 -0
  110. package/dist/image/get-img-props.js +573 -0
  111. package/dist/image/get-img-props.js.map +1 -0
  112. package/dist/image/image-blur-svg.js +22 -0
  113. package/dist/image/image-blur-svg.js.map +1 -0
  114. package/dist/image/image-config-context.shared-runtime.js +19 -0
  115. package/dist/image/image-config-context.shared-runtime.js.map +1 -0
  116. package/dist/image/image-config.js +74 -0
  117. package/dist/image/image-config.js.map +1 -0
  118. package/dist/image/image-loader.js +91 -0
  119. package/dist/image/image-loader.js.map +1 -0
  120. package/dist/image/image-optimizer.js +1019 -0
  121. package/dist/image/image-optimizer.js.map +1 -0
  122. package/dist/image/match-local-pattern.js +46 -0
  123. package/dist/image/match-local-pattern.js.map +1 -0
  124. package/dist/image/match-remote-pattern.js +63 -0
  125. package/dist/image/match-remote-pattern.js.map +1 -0
  126. package/dist/image/mime-type.js +20 -0
  127. package/dist/image/mime-type.js.map +1 -0
  128. package/dist/memory/gc-observer.js +53 -0
  129. package/dist/memory/gc-observer.js.map +1 -0
  130. package/dist/memory/shutdown.js +29 -0
  131. package/dist/memory/shutdown.js.map +1 -0
  132. package/dist/memory/startup.js +47 -0
  133. package/dist/memory/startup.js.map +1 -0
  134. package/dist/memory/trace.js +109 -0
  135. package/dist/memory/trace.js.map +1 -0
  136. package/dist/module/client-and-server-references.js +54 -0
  137. package/dist/module/client-and-server-references.js.map +1 -0
  138. package/dist/module/format-dynamic-import-path.js +24 -0
  139. package/dist/module/format-dynamic-import-path.js.map +1 -0
  140. package/dist/module/interop-default.js +15 -0
  141. package/dist/module/interop-default.js.map +1 -0
  142. package/dist/module/resolve-from.js +79 -0
  143. package/dist/module/resolve-from.js.map +1 -0
  144. package/dist/module/semver-noop.js +18 -0
  145. package/dist/module/semver-noop.js.map +1 -0
  146. package/dist/object/deep-freeze.js +30 -0
  147. package/dist/object/deep-freeze.js.map +1 -0
  148. package/dist/object/deep-readonly.js +10 -0
  149. package/dist/object/deep-readonly.js.map +1 -0
  150. package/dist/object/is-plain-object.js +42 -0
  151. package/dist/object/is-plain-object.js.map +1 -0
  152. package/dist/object/non-nullable.js +15 -0
  153. package/dist/object/non-nullable.js.map +1 -0
  154. package/dist/object/pick.js +19 -0
  155. package/dist/object/pick.js.map +1 -0
  156. package/dist/process/setup-exception-listeners.js +11 -0
  157. package/dist/process/setup-exception-listeners.js.map +1 -0
  158. package/dist/promise/detached-promise.js +32 -0
  159. package/dist/promise/detached-promise.js.map +1 -0
  160. package/dist/promise/is-thenable.js +20 -0
  161. package/dist/promise/is-thenable.js.map +1 -0
  162. package/dist/promise/promise-with-resolvers.js +26 -0
  163. package/dist/promise/promise-with-resolvers.js.map +1 -0
  164. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  165. package/dist/server/lib/app-info-log.js +1 -1
  166. package/dist/server/lib/start-server.js +1 -1
  167. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  168. package/dist/string/encode-uri-path.js +15 -0
  169. package/dist/string/encode-uri-path.js.map +1 -0
  170. package/dist/string/escape-regexp.js +22 -0
  171. package/dist/string/escape-regexp.js.map +1 -0
  172. package/dist/string/normalize-path.js +21 -0
  173. package/dist/string/normalize-path.js.map +1 -0
  174. package/dist/string/oxford-comma-list.js +15 -0
  175. package/dist/string/oxford-comma-list.js.map +1 -0
  176. package/dist/string/pretty-bytes.js +74 -0
  177. package/dist/string/pretty-bytes.js.map +1 -0
  178. package/dist/telemetry/anonymous-meta.js +1 -1
  179. package/dist/telemetry/events/session-stopped.js +2 -2
  180. package/dist/telemetry/events/version.js +2 -2
  181. package/dist/typescript/diagnosticFormatter.js +240 -0
  182. package/dist/typescript/diagnosticFormatter.js.map +1 -0
  183. package/dist/typescript/getTypeScriptConfiguration.js +73 -0
  184. package/dist/typescript/getTypeScriptConfiguration.js.map +1 -0
  185. package/dist/typescript/getTypeScriptIntent.js +52 -0
  186. package/dist/typescript/getTypeScriptIntent.js.map +1 -0
  187. package/dist/typescript/missingDependencyError.js +27 -0
  188. package/dist/typescript/missingDependencyError.js.map +1 -0
  189. package/dist/typescript/runTypeCheck.js +95 -0
  190. package/dist/typescript/runTypeCheck.js.map +1 -0
  191. package/dist/typescript/writeAppTypeDeclarations.js +65 -0
  192. package/dist/typescript/writeAppTypeDeclarations.js.map +1 -0
  193. package/dist/typescript/writeConfigurationDefaults.js +403 -0
  194. package/dist/typescript/writeConfigurationDefaults.js.map +1 -0
  195. package/dist/validation/is-serializable-props.js +106 -0
  196. package/dist/validation/is-serializable-props.js.map +1 -0
  197. package/package.json +1 -1
package/dist/bin/next CHANGED
@@ -89,7 +89,7 @@ const program = new NextRootCommand();
89
89
  program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
90
90
  formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
91
91
  subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
92
- }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"16.2.0"}`, '-v, --version', 'Outputs the Next.js version.');
92
+ }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"16.2.1"}`, '-v, --version', 'Outputs the Next.js version.');
93
93
  program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('-d, --debug', 'Enables a more verbose build output.').option('--debug-prerender', 'Enables debug mode for prerendering. Not for production use!').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').option('--webpack', 'Builds using webpack.').addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
94
94
  'compile',
95
95
  'generate',
@@ -133,7 +133,7 @@ program.command('telemetry').description(`Allows you to enable or disable Next.j
133
133
  program.command('typegen').description('Generate TypeScript definitions for routes, pages, and layouts without running a full build.').argument('[directory]', `A directory on which to generate types. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).action((directory, options)=>// ensure process exits after typegen completes so open handles/connections
134
134
  // don't cause process to hang
135
135
  import('../cli/next-typegen.js').then((mod)=>mod.nextTypegen(options, directory).then(()=>process.exit(0)))).usage('[directory] [options]');
136
- const nextVersion = "16.2.0" || 'unknown';
136
+ const nextVersion = "16.2.1" || 'unknown';
137
137
  program.command('upgrade').description('Upgrade Next.js apps to desired versions with a single command.').argument('[directory]', `A Next.js project directory to upgrade. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).usage('[directory] [options]').option('--revision <revision>', 'Specify the target Next.js version using an NPM dist tag (e.g. "latest", "canary", "rc", "beta") or an exact version number (e.g. "15.0.0").', nextVersion.includes('-canary.') ? 'canary' : nextVersion.includes('-rc.') ? 'rc' : nextVersion.includes('-beta.') ? 'beta' : 'latest').option('--verbose', 'Verbose output', false).action(async (directory, options)=>{
138
138
  const mod = await import('../cli/next-upgrade.js');
139
139
  mod.spawnNextUpgrade(directory, options);
@@ -376,7 +376,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
376
376
  try {
377
377
  const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
378
378
  buildMode: experimentalBuildMode,
379
- version: "16.2.0"
379
+ version: "16.2.1"
380
380
  });
381
381
  _buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
382
382
  _buildcontext.NextBuildContext.dir = dir;
@@ -889,7 +889,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
889
889
  // Files outside of the distDir can be "type": "module"
890
890
  await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
891
891
  // These are written to distDir, so they need to come after creating and cleaning distDr.
892
- await (0, _builddiagnostics.recordFrameworkVersion)("16.2.0");
892
+ await (0, _builddiagnostics.recordFrameworkVersion)("16.2.1");
893
893
  await (0, _builddiagnostics.updateBuildDiagnostics)({
894
894
  buildStage: 'start'
895
895
  });
@@ -2540,7 +2540,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
2540
2540
  configOutDir: _path.default.join(dir, configOutDir),
2541
2541
  staticPages,
2542
2542
  serverPropsPages,
2543
- nextVersion: "16.2.0",
2543
+ nextVersion: "16.2.1",
2544
2544
  tracingRoot: outputFileTracingRoot,
2545
2545
  hasNodeMiddleware,
2546
2546
  hasInstrumentationHook,
@@ -1616,7 +1616,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1616
1616
  isClient && new _copyfileplugin.CopyFilePlugin({
1617
1617
  // file path to build output of `@next/polyfill-nomodule`
1618
1618
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1619
- cacheKey: "16.2.0",
1619
+ cacheKey: "16.2.1",
1620
1620
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1621
1621
  minimize: false,
1622
1622
  info: {
@@ -1788,7 +1788,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1788
1788
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1789
1789
  // - Next.js version
1790
1790
  // - next.config.js keys that affect compilation
1791
- version: `${__dirname}|${"16.2.0"}|${configVars}`,
1791
+ version: `${__dirname}|${"16.2.1"}|${configVars}`,
1792
1792
  cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
1793
1793
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1794
1794
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getCacheControlHeader", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getCacheControlHeader;
9
+ }
10
+ });
11
+ const _constants = require("../lib/constants");
12
+ function getCacheControlHeader({ revalidate, expire }) {
13
+ const swrHeader = typeof revalidate === 'number' && expire !== undefined && revalidate < expire ? `, stale-while-revalidate=${expire - revalidate}` : '';
14
+ if (revalidate === 0) {
15
+ return 'private, no-cache, no-store, max-age=0, must-revalidate';
16
+ } else if (typeof revalidate === 'number') {
17
+ return `s-maxage=${revalidate}${swrHeader}`;
18
+ }
19
+ return `s-maxage=${_constants.CACHE_ONE_YEAR}${swrHeader}`;
20
+ }
21
+
22
+ //# sourceMappingURL=cache-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../cache/cache-control.ts"],"sourcesContent":["import { CACHE_ONE_YEAR } from '../lib/constants'\n\n/**\n * The revalidate option used internally for pages. A value of `false` means\n * that the page should not be revalidated. A number means that the page\n * should be revalidated after the given number of seconds (this also includes\n * `1` which means to revalidate after 1 second). A value of `0` is not a valid\n * value for this option.\n */\nexport type Revalidate = number | false\n\nexport interface CacheControl {\n revalidate: Revalidate\n expire: number | undefined\n}\n\nexport function getCacheControlHeader({\n revalidate,\n expire,\n}: CacheControl): string {\n const swrHeader =\n typeof revalidate === 'number' &&\n expire !== undefined &&\n revalidate < expire\n ? `, stale-while-revalidate=${expire - revalidate}`\n : ''\n\n if (revalidate === 0) {\n return 'private, no-cache, no-store, max-age=0, must-revalidate'\n } else if (typeof revalidate === 'number') {\n return `s-maxage=${revalidate}${swrHeader}`\n }\n\n return `s-maxage=${CACHE_ONE_YEAR}${swrHeader}`\n}\n"],"names":["getCacheControlHeader","revalidate","expire","swrHeader","undefined","CACHE_ONE_YEAR"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;2BAhBe;AAgBxB,SAASA,sBAAsB,EACpCC,UAAU,EACVC,MAAM,EACO;IACb,MAAMC,YACJ,OAAOF,eAAe,YACtBC,WAAWE,aACXH,aAAaC,SACT,CAAC,yBAAyB,EAAEA,SAASD,YAAY,GACjD;IAEN,IAAIA,eAAe,GAAG;QACpB,OAAO;IACT,OAAO,IAAI,OAAOA,eAAe,UAAU;QACzC,OAAO,CAAC,SAAS,EAAEA,aAAaE,WAAW;IAC7C;IAEA,OAAO,CAAC,SAAS,EAAEE,yBAAc,GAAGF,WAAW;AACjD","ignoreList":[0]}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "cloneResponse", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return cloneResponse;
9
+ }
10
+ });
11
+ const noop = ()=>{};
12
+ let registry;
13
+ if (globalThis.FinalizationRegistry) {
14
+ registry = new FinalizationRegistry((weakRef)=>{
15
+ const stream = weakRef.deref();
16
+ if (stream && !stream.locked) {
17
+ stream.cancel('Response object has been garbage collected').then(noop);
18
+ }
19
+ });
20
+ }
21
+ function cloneResponse(original) {
22
+ // If the response has no body, then we can just return the original response
23
+ // twice because it's immutable.
24
+ if (!original.body) {
25
+ return [
26
+ original,
27
+ original
28
+ ];
29
+ }
30
+ const [body1, body2] = original.body.tee();
31
+ const cloned1 = new Response(body1, {
32
+ status: original.status,
33
+ statusText: original.statusText,
34
+ headers: original.headers
35
+ });
36
+ Object.defineProperty(cloned1, 'url', {
37
+ value: original.url,
38
+ // How the original response.url behaves
39
+ configurable: true,
40
+ enumerable: true,
41
+ writable: false
42
+ });
43
+ // The Fetch Standard allows users to skip consuming the response body by
44
+ // relying on garbage collection to release connection resources.
45
+ // https://github.com/nodejs/undici?tab=readme-ov-file#garbage-collection
46
+ //
47
+ // To cancel the stream you then need to cancel both resulting branches.
48
+ // Teeing a stream will generally lock it for the duration, preventing other
49
+ // readers from locking it.
50
+ // https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/tee
51
+ // cloned2 is stored in a react cache and cloned for subsequent requests.
52
+ // It is the original request, and is is garbage collected by a
53
+ // FinalizationRegistry in Undici, but since we're tee-ing the stream
54
+ // ourselves, we need to cancel clone1's stream (the response returned from
55
+ // our dedupe fetch) when clone1 is reclaimed, otherwise we leak memory.
56
+ if (registry && cloned1.body) {
57
+ registry.register(cloned1, new WeakRef(cloned1.body));
58
+ }
59
+ const cloned2 = new Response(body2, {
60
+ status: original.status,
61
+ statusText: original.statusText,
62
+ headers: original.headers
63
+ });
64
+ Object.defineProperty(cloned2, 'url', {
65
+ value: original.url,
66
+ // How the original response.url behaves
67
+ configurable: true,
68
+ enumerable: true,
69
+ writable: false
70
+ });
71
+ return [
72
+ cloned1,
73
+ cloned2
74
+ ];
75
+ }
76
+
77
+ //# sourceMappingURL=clone-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../cache/clone-response.ts"],"sourcesContent":["const noop = () => {}\n\nlet registry: FinalizationRegistry<WeakRef<ReadableStream>> | undefined\n\nif (globalThis.FinalizationRegistry) {\n registry = new FinalizationRegistry((weakRef: WeakRef<ReadableStream>) => {\n const stream = weakRef.deref()\n if (stream && !stream.locked) {\n stream.cancel('Response object has been garbage collected').then(noop)\n }\n })\n}\n\n/**\n * Clones a response by teeing the body so we can return two independent\n * ReadableStreams from it. This avoids the bug in the undici library around\n * response cloning.\n *\n * After cloning, the original response's body will be consumed and closed.\n *\n * @see https://github.com/vercel/next.js/pull/73274\n *\n * @param original - The original response to clone.\n * @returns A tuple containing two independent clones of the original response.\n */\nexport function cloneResponse(original: Response): [Response, Response] {\n // If the response has no body, then we can just return the original response\n // twice because it's immutable.\n if (!original.body) {\n return [original, original]\n }\n\n const [body1, body2] = original.body.tee()\n\n const cloned1 = new Response(body1, {\n status: original.status,\n statusText: original.statusText,\n headers: original.headers,\n })\n\n Object.defineProperty(cloned1, 'url', {\n value: original.url,\n // How the original response.url behaves\n configurable: true,\n enumerable: true,\n writable: false,\n })\n\n // The Fetch Standard allows users to skip consuming the response body by\n // relying on garbage collection to release connection resources.\n // https://github.com/nodejs/undici?tab=readme-ov-file#garbage-collection\n //\n // To cancel the stream you then need to cancel both resulting branches.\n // Teeing a stream will generally lock it for the duration, preventing other\n // readers from locking it.\n // https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/tee\n\n // cloned2 is stored in a react cache and cloned for subsequent requests.\n // It is the original request, and is is garbage collected by a\n // FinalizationRegistry in Undici, but since we're tee-ing the stream\n // ourselves, we need to cancel clone1's stream (the response returned from\n // our dedupe fetch) when clone1 is reclaimed, otherwise we leak memory.\n if (registry && cloned1.body) {\n registry.register(cloned1, new WeakRef(cloned1.body))\n }\n\n const cloned2 = new Response(body2, {\n status: original.status,\n statusText: original.statusText,\n headers: original.headers,\n })\n\n Object.defineProperty(cloned2, 'url', {\n value: original.url,\n // How the original response.url behaves\n configurable: true,\n enumerable: true,\n writable: false,\n })\n\n return [cloned1, cloned2]\n}\n"],"names":["cloneResponse","noop","registry","globalThis","FinalizationRegistry","weakRef","stream","deref","locked","cancel","then","original","body","body1","body2","tee","cloned1","Response","status","statusText","headers","Object","defineProperty","value","url","configurable","enumerable","writable","register","WeakRef","cloned2"],"mappings":";;;;+BAyBgBA;;;eAAAA;;;AAzBhB,MAAMC,OAAO,KAAO;AAEpB,IAAIC;AAEJ,IAAIC,WAAWC,oBAAoB,EAAE;IACnCF,WAAW,IAAIE,qBAAqB,CAACC;QACnC,MAAMC,SAASD,QAAQE,KAAK;QAC5B,IAAID,UAAU,CAACA,OAAOE,MAAM,EAAE;YAC5BF,OAAOG,MAAM,CAAC,8CAA8CC,IAAI,CAACT;QACnE;IACF;AACF;AAcO,SAASD,cAAcW,QAAkB;IAC9C,6EAA6E;IAC7E,gCAAgC;IAChC,IAAI,CAACA,SAASC,IAAI,EAAE;QAClB,OAAO;YAACD;YAAUA;SAAS;IAC7B;IAEA,MAAM,CAACE,OAAOC,MAAM,GAAGH,SAASC,IAAI,CAACG,GAAG;IAExC,MAAMC,UAAU,IAAIC,SAASJ,OAAO;QAClCK,QAAQP,SAASO,MAAM;QACvBC,YAAYR,SAASQ,UAAU;QAC/BC,SAAST,SAASS,OAAO;IAC3B;IAEAC,OAAOC,cAAc,CAACN,SAAS,OAAO;QACpCO,OAAOZ,SAASa,GAAG;QACnB,wCAAwC;QACxCC,cAAc;QACdC,YAAY;QACZC,UAAU;IACZ;IAEA,yEAAyE;IACzE,iEAAiE;IACjE,yEAAyE;IACzE,EAAE;IACF,wEAAwE;IACxE,4EAA4E;IAC5E,2BAA2B;IAC3B,sEAAsE;IAEtE,yEAAyE;IACzE,+DAA+D;IAC/D,qEAAqE;IACrE,2EAA2E;IAC3E,wEAAwE;IACxE,IAAIzB,YAAYc,QAAQJ,IAAI,EAAE;QAC5BV,SAAS0B,QAAQ,CAACZ,SAAS,IAAIa,QAAQb,QAAQJ,IAAI;IACrD;IAEA,MAAMkB,UAAU,IAAIb,SAASH,OAAO;QAClCI,QAAQP,SAASO,MAAM;QACvBC,YAAYR,SAASQ,UAAU;QAC/BC,SAAST,SAASS,OAAO;IAC3B;IAEAC,OAAOC,cAAc,CAACQ,SAAS,OAAO;QACpCP,OAAOZ,SAASa,GAAG;QACnB,wCAAwC;QACxCC,cAAc;QACdC,YAAY;QACZC,UAAU;IACZ;IAEA,OAAO;QAACX;QAASc;KAAQ;AAC3B","ignoreList":[0]}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Based on https://github.com/facebook/react/blob/d4e78c42a94be027b4dc7ed2659a5fddfbf9bd4e/packages/react/src/ReactFetch.js
3
+ */ // Use bare 'react' import so webpack can alias it to the vendored RSC React
4
+ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "createDedupeFetch", {
9
+ enumerable: true,
10
+ get: function() {
11
+ return createDedupeFetch;
12
+ }
13
+ });
14
+ const _cloneresponse = require("./clone-response");
15
+ const _invarianterror = require("../shared/lib/invariant-error");
16
+ const React = require('react');
17
+ const simpleCacheKey = '["GET",[],null,"follow",null,null,null,null]' // generateCacheKey(new Request('https://blank'));
18
+ ;
19
+ // Headers that should not affect deduplication
20
+ // traceparent and tracestate are used for distributed tracing and should not affect cache keys
21
+ const headersToExcludeInCacheKey = new Set([
22
+ 'traceparent',
23
+ 'tracestate'
24
+ ]);
25
+ function generateCacheKey(request) {
26
+ // We pick the fields that goes into the key used to dedupe requests.
27
+ // We don't include the `cache` field, because we end up using whatever
28
+ // caching resulted from the first request.
29
+ // Notably we currently don't consider non-standard (or future) options.
30
+ // This might not be safe. TODO: warn for non-standard extensions differing.
31
+ // IF YOU CHANGE THIS UPDATE THE simpleCacheKey ABOVE.
32
+ const filteredHeaders = Array.from(request.headers.entries()).filter(([key])=>!headersToExcludeInCacheKey.has(key.toLowerCase()));
33
+ return JSON.stringify([
34
+ request.method,
35
+ filteredHeaders,
36
+ request.mode,
37
+ request.redirect,
38
+ request.credentials,
39
+ request.referrer,
40
+ request.referrerPolicy,
41
+ request.integrity
42
+ ]);
43
+ }
44
+ function createDedupeFetch(originalFetch) {
45
+ const getCacheEntries = React.cache(// eslint-disable-next-line @typescript-eslint/no-unused-vars -- url is the cache key
46
+ (url)=>[]);
47
+ return function dedupeFetch(resource, options) {
48
+ if (options && options.signal) {
49
+ // If we're passed a signal, then we assume that
50
+ // someone else controls the lifetime of this object and opts out of
51
+ // caching. It's effectively the opt-out mechanism.
52
+ // Ideally we should be able to check this on the Request but
53
+ // it always gets initialized with its own signal so we don't
54
+ // know if it's supposed to override - unless we also override the
55
+ // Request constructor.
56
+ return originalFetch(resource, options);
57
+ }
58
+ // Normalize the Request
59
+ let url;
60
+ let cacheKey;
61
+ if (typeof resource === 'string' && !options) {
62
+ // Fast path.
63
+ cacheKey = simpleCacheKey;
64
+ url = resource;
65
+ } else {
66
+ // Normalize the request.
67
+ // if resource is not a string or a URL (its an instance of Request)
68
+ // then do not instantiate a new Request but instead
69
+ // reuse the request as to not disturb the body in the event it's a ReadableStream.
70
+ const request = typeof resource === 'string' || resource instanceof URL ? new Request(resource, options) : resource;
71
+ if (request.method !== 'GET' && request.method !== 'HEAD' || request.keepalive) {
72
+ // We currently don't dedupe requests that might have side-effects. Those
73
+ // have to be explicitly cached. We assume that the request doesn't have a
74
+ // body if it's GET or HEAD.
75
+ // keepalive gets treated the same as if you passed a custom cache signal.
76
+ return originalFetch(resource, options);
77
+ }
78
+ cacheKey = generateCacheKey(request);
79
+ url = request.url;
80
+ }
81
+ const cacheEntries = getCacheEntries(url);
82
+ for(let i = 0, j = cacheEntries.length; i < j; i += 1){
83
+ const [key, promise] = cacheEntries[i];
84
+ if (key === cacheKey) {
85
+ return promise.then(()=>{
86
+ const response = cacheEntries[i][2];
87
+ if (!response) throw Object.defineProperty(new _invarianterror.InvariantError('No cached response'), "__NEXT_ERROR_CODE", {
88
+ value: "E579",
89
+ enumerable: false,
90
+ configurable: true
91
+ });
92
+ // We're cloning the response using this utility because there exists
93
+ // a bug in the undici library around response cloning. See the
94
+ // following pull request for more details:
95
+ // https://github.com/vercel/next.js/pull/73274
96
+ const [cloned1, cloned2] = (0, _cloneresponse.cloneResponse)(response);
97
+ cacheEntries[i][2] = cloned2;
98
+ return cloned1;
99
+ });
100
+ }
101
+ }
102
+ // We pass the original arguments here in case normalizing the Request
103
+ // doesn't include all the options in this environment.
104
+ const promise = originalFetch(resource, options);
105
+ const entry = [
106
+ cacheKey,
107
+ promise,
108
+ null
109
+ ];
110
+ cacheEntries.push(entry);
111
+ return promise.then((response)=>{
112
+ // We're cloning the response using this utility because there exists
113
+ // a bug in the undici library around response cloning. See the
114
+ // following pull request for more details:
115
+ // https://github.com/vercel/next.js/pull/73274
116
+ const [cloned1, cloned2] = (0, _cloneresponse.cloneResponse)(response);
117
+ entry[2] = cloned2;
118
+ return cloned1;
119
+ });
120
+ };
121
+ }
122
+
123
+ //# sourceMappingURL=dedupe-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../cache/dedupe-fetch.ts"],"sourcesContent":["/**\n * Based on https://github.com/facebook/react/blob/d4e78c42a94be027b4dc7ed2659a5fddfbf9bd4e/packages/react/src/ReactFetch.js\n */\n// Use bare 'react' import so webpack can alias it to the vendored RSC React\nconst React: typeof import('react') = require('react') as typeof import('react')\nimport { cloneResponse } from './clone-response'\nimport { InvariantError } from '../shared/lib/invariant-error'\n\nconst simpleCacheKey = '[\"GET\",[],null,\"follow\",null,null,null,null]' // generateCacheKey(new Request('https://blank'));\n\n// Headers that should not affect deduplication\n// traceparent and tracestate are used for distributed tracing and should not affect cache keys\nconst headersToExcludeInCacheKey = new Set(['traceparent', 'tracestate'])\n\nfunction generateCacheKey(request: Request): string {\n // We pick the fields that goes into the key used to dedupe requests.\n // We don't include the `cache` field, because we end up using whatever\n // caching resulted from the first request.\n // Notably we currently don't consider non-standard (or future) options.\n // This might not be safe. TODO: warn for non-standard extensions differing.\n // IF YOU CHANGE THIS UPDATE THE simpleCacheKey ABOVE.\n\n const filteredHeaders = Array.from(request.headers.entries()).filter(\n ([key]) => !headersToExcludeInCacheKey.has(key.toLowerCase())\n )\n\n return JSON.stringify([\n request.method,\n filteredHeaders,\n request.mode,\n request.redirect,\n request.credentials,\n request.referrer,\n request.referrerPolicy,\n request.integrity,\n ])\n}\n\ntype CacheEntry = [\n key: string,\n promise: Promise<Response>,\n response: Response | null,\n]\n\nexport function createDedupeFetch(originalFetch: typeof fetch) {\n const getCacheEntries = React.cache(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- url is the cache key\n (url: string): CacheEntry[] => []\n )\n\n return function dedupeFetch(\n resource: URL | RequestInfo,\n options?: RequestInit\n ): Promise<Response> {\n if (options && options.signal) {\n // If we're passed a signal, then we assume that\n // someone else controls the lifetime of this object and opts out of\n // caching. It's effectively the opt-out mechanism.\n // Ideally we should be able to check this on the Request but\n // it always gets initialized with its own signal so we don't\n // know if it's supposed to override - unless we also override the\n // Request constructor.\n return originalFetch(resource, options)\n }\n // Normalize the Request\n let url: string\n let cacheKey: string\n if (typeof resource === 'string' && !options) {\n // Fast path.\n cacheKey = simpleCacheKey\n url = resource\n } else {\n // Normalize the request.\n // if resource is not a string or a URL (its an instance of Request)\n // then do not instantiate a new Request but instead\n // reuse the request as to not disturb the body in the event it's a ReadableStream.\n const request =\n typeof resource === 'string' || resource instanceof URL\n ? new Request(resource, options)\n : resource\n if (\n (request.method !== 'GET' && request.method !== 'HEAD') ||\n request.keepalive\n ) {\n // We currently don't dedupe requests that might have side-effects. Those\n // have to be explicitly cached. We assume that the request doesn't have a\n // body if it's GET or HEAD.\n // keepalive gets treated the same as if you passed a custom cache signal.\n return originalFetch(resource, options)\n }\n cacheKey = generateCacheKey(request)\n url = request.url\n }\n\n const cacheEntries = getCacheEntries(url)\n for (let i = 0, j = cacheEntries.length; i < j; i += 1) {\n const [key, promise] = cacheEntries[i]\n if (key === cacheKey) {\n return promise.then(() => {\n const response = cacheEntries[i][2]\n if (!response) throw new InvariantError('No cached response')\n\n // We're cloning the response using this utility because there exists\n // a bug in the undici library around response cloning. See the\n // following pull request for more details:\n // https://github.com/vercel/next.js/pull/73274\n const [cloned1, cloned2] = cloneResponse(response)\n cacheEntries[i][2] = cloned2\n return cloned1\n })\n }\n }\n\n // We pass the original arguments here in case normalizing the Request\n // doesn't include all the options in this environment.\n const promise = originalFetch(resource, options)\n const entry: CacheEntry = [cacheKey, promise, null]\n cacheEntries.push(entry)\n\n return promise.then((response) => {\n // We're cloning the response using this utility because there exists\n // a bug in the undici library around response cloning. See the\n // following pull request for more details:\n // https://github.com/vercel/next.js/pull/73274\n const [cloned1, cloned2] = cloneResponse(response)\n entry[2] = cloned2\n return cloned1\n })\n }\n}\n"],"names":["createDedupeFetch","React","require","simpleCacheKey","headersToExcludeInCacheKey","Set","generateCacheKey","request","filteredHeaders","Array","from","headers","entries","filter","key","has","toLowerCase","JSON","stringify","method","mode","redirect","credentials","referrer","referrerPolicy","integrity","originalFetch","getCacheEntries","cache","url","dedupeFetch","resource","options","signal","cacheKey","URL","Request","keepalive","cacheEntries","i","j","length","promise","then","response","InvariantError","cloned1","cloned2","cloneResponse","entry","push"],"mappings":"AAAA;;CAEC,GACD,4EAA4E;;;;;+BAyC5DA;;;eAAAA;;;+BAvCc;gCACC;AAF/B,MAAMC,QAAgCC,QAAQ;AAI9C,MAAMC,iBAAiB,+CAA+C,kDAAkD;;AAExH,+CAA+C;AAC/C,+FAA+F;AAC/F,MAAMC,6BAA6B,IAAIC,IAAI;IAAC;IAAe;CAAa;AAExE,SAASC,iBAAiBC,OAAgB;IACxC,qEAAqE;IACrE,uEAAuE;IACvE,2CAA2C;IAC3C,wEAAwE;IACxE,4EAA4E;IAC5E,sDAAsD;IAEtD,MAAMC,kBAAkBC,MAAMC,IAAI,CAACH,QAAQI,OAAO,CAACC,OAAO,IAAIC,MAAM,CAClE,CAAC,CAACC,IAAI,GAAK,CAACV,2BAA2BW,GAAG,CAACD,IAAIE,WAAW;IAG5D,OAA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AAE;YACtC,IAAIzB,QAAQoB,UAAU;gBACpB,OAAOQ,QAAQC,IAAI,CAAC;oBAClB,MAAMC,WAAWN,YAAY,CAACC,EAAE,CAAC,EAAE;oBACnC,IAAI,CAACK,UAAU,MAAM,qBAAwC,CAAxC,IAAIC,8BAAc,CAAC,uBAAnB,qBAAA;+BAAA;oCAAA;sCAAA;oBAAuC;oBAE5D,qEAAqE;oBACrE,+DAA+D;oBAC/D,2CAA2C;oBAC3C,+CAA+C;oBAC/C,MAAM,CAACC,SAASC,QAAQ,GAAGC,IAAAA,4BAAa,EAACJ;oBACzCN,YAAY,CAACC,EAAE,CAAC,EAAE,GAAGQ;oBACrB,OAAOD;gBACT;YACF;QACF;QAEA,sEAAsE;QACtE,uDAAuD;QACvD,MAAMJ,UAAUhB,cAAcK,UAAUC;QACxC,MAAMiB,QAAoB;YAACf;YAAUQ;YAAS;SAAK;QACnDJ,aAAaY,IAAI,CAACD;QAElB,OAAOP,QAAQC,IAAI,CAAC,CAACC;YACnB,qEAAqE;YACrE,+DAA+D;YAC/D,2CAA2C;YAC3C,+CAA+C;YAC/C,MAAM,CAACE,SAASC,QAAQ,GAAGC,IAAAA,4BAAa,EAACJ;YACzCK,KAAK,CAAC,EAAE,GAAGF;YACX,OAAOD;QACT;IACF;AACF","ignoreList":[0]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ 0 && (module.exports = {
6
+ createLazyResult: null,
7
+ isResolvedLazyResult: null
8
+ });
9
+ function _export(target, all) {
10
+ for(var name in all)Object.defineProperty(target, name, {
11
+ enumerable: true,
12
+ get: all[name]
13
+ });
14
+ }
15
+ _export(exports, {
16
+ createLazyResult: function() {
17
+ return createLazyResult;
18
+ },
19
+ isResolvedLazyResult: function() {
20
+ return isResolvedLazyResult;
21
+ }
22
+ });
23
+ function createLazyResult(fn) {
24
+ let pendingResult;
25
+ const result = {
26
+ then (onfulfilled, onrejected) {
27
+ if (!pendingResult) {
28
+ pendingResult = fn();
29
+ }
30
+ pendingResult.then((value)=>{
31
+ result.value = value;
32
+ }).catch(()=>{
33
+ // The externally awaited result will be rejected via `onrejected`. We
34
+ // don't need to handle it here. But we do want to avoid an unhandled
35
+ // rejection.
36
+ });
37
+ return pendingResult.then(onfulfilled, onrejected);
38
+ }
39
+ };
40
+ return result;
41
+ }
42
+ function isResolvedLazyResult(result) {
43
+ return result.hasOwnProperty('value');
44
+ }
45
+
46
+ //# sourceMappingURL=lazy-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../cache/lazy-result.ts"],"sourcesContent":["export type LazyResult<TValue> = PromiseLike<TValue> & { value?: TValue }\nexport type ResolvedLazyResult<TValue> = PromiseLike<TValue> & { value: TValue }\n\n/**\n * Calls the given async function only when the returned promise-like object is\n * awaited. Afterwards, it provides the resolved value synchronously as `value`\n * property.\n */\nexport function createLazyResult<TValue>(\n fn: () => Promise<TValue>\n): LazyResult<TValue> {\n let pendingResult: Promise<TValue> | undefined\n\n const result: LazyResult<TValue> = {\n then(onfulfilled, onrejected) {\n if (!pendingResult) {\n pendingResult = fn()\n }\n\n pendingResult\n .then((value) => {\n result.value = value\n })\n .catch(() => {\n // The externally awaited result will be rejected via `onrejected`. We\n // don't need to handle it here. But we do want to avoid an unhandled\n // rejection.\n })\n\n return pendingResult.then(onfulfilled, onrejected)\n },\n }\n\n return result\n}\n\nexport function isResolvedLazyResult<TValue>(\n result: LazyResult<TValue>\n): result is ResolvedLazyResult<TValue> {\n return result.hasOwnProperty('value')\n}\n"],"names":["createLazyResult","isResolvedLazyResult","fn","pendingResult","result","then","onfulfilled","onrejected","value","catch","hasOwnProperty"],"mappings":";;;;;;;;;;;;;;;IAQgBA,gBAAgB;eAAhBA;;IA4BAC,oBAAoB;eAApBA;;;AA5BT,SAASD,iBACdE,EAAyB;IAEzB,IAAIC;IAEJ,MAAMC,SAA6B;QACjCC,MAAKC,WAAW,EAAEC,UAAU;YAC1B,IAAI,CAACJ,eAAe;gBAClBA,gBAAgBD;YAClB;YAEAC,cACGE,IAAI,CAAC,CAACG;gBACLJ,OAAOI,KAAK,GAAGA;YACjB,GACCC,KAAK,CAAC;YACL,sEAAsE;YACtE,qEAAqE;YACrE,aAAa;YACf;YAEF,OAAON,cAAcE,IAAI,CAACC,aAAaC;QACzC;IACF;IAEA,OAAOH;AACT;AAEO,SAASH,qBACdG,MAA0B;IAE1B,OAAOA,OAAOM,cAAc,CAAC;AAC/B","ignoreList":[0]}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Node in the doubly-linked list used for LRU tracking.
3
+ * Each node represents a cache entry with bidirectional pointers.
4
+ */ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "LRUCache", {
9
+ enumerable: true,
10
+ get: function() {
11
+ return LRUCache;
12
+ }
13
+ });
14
+ class LRUNode {
15
+ constructor(key, data, size){
16
+ this.prev = null;
17
+ this.next = null;
18
+ this.key = key;
19
+ this.data = data;
20
+ this.size = size;
21
+ }
22
+ }
23
+ /**
24
+ * Sentinel node used for head/tail boundaries.
25
+ * These nodes don't contain actual cache data but simplify list operations.
26
+ */ class SentinelNode {
27
+ constructor(){
28
+ this.prev = null;
29
+ this.next = null;
30
+ }
31
+ }
32
+ class LRUCache {
33
+ constructor(maxSize, calculateSize){
34
+ this.cache = new Map();
35
+ this.totalSize = 0;
36
+ this.maxSize = maxSize;
37
+ this.calculateSize = calculateSize;
38
+ // Create sentinel nodes to simplify doubly-linked list operations
39
+ // HEAD <-> TAIL (empty list)
40
+ this.head = new SentinelNode();
41
+ this.tail = new SentinelNode();
42
+ this.head.next = this.tail;
43
+ this.tail.prev = this.head;
44
+ }
45
+ /**
46
+ * Adds a node immediately after the head (marks as most recently used).
47
+ * Used when inserting new items or when an item is accessed.
48
+ * PRECONDITION: node must be disconnected (prev/next should be null)
49
+ */ addToHead(node) {
50
+ node.prev = this.head;
51
+ node.next = this.head.next;
52
+ // head.next is always non-null (points to tail or another node)
53
+ this.head.next.prev = node;
54
+ this.head.next = node;
55
+ }
56
+ /**
57
+ * Removes a node from its current position in the doubly-linked list.
58
+ * Updates the prev/next pointers of adjacent nodes to maintain list integrity.
59
+ * PRECONDITION: node must be connected (prev/next are non-null)
60
+ */ removeNode(node) {
61
+ // Connected nodes always have non-null prev/next
62
+ node.prev.next = node.next;
63
+ node.next.prev = node.prev;
64
+ }
65
+ /**
66
+ * Moves an existing node to the head position (marks as most recently used).
67
+ * This is the core LRU operation - accessed items become most recent.
68
+ */ moveToHead(node) {
69
+ this.removeNode(node);
70
+ this.addToHead(node);
71
+ }
72
+ /**
73
+ * Removes and returns the least recently used node (the one before tail).
74
+ * This is called during eviction when the cache exceeds capacity.
75
+ * PRECONDITION: cache is not empty (ensured by caller)
76
+ */ removeTail() {
77
+ const lastNode = this.tail.prev;
78
+ // tail.prev is always non-null and always LRUNode when cache is not empty
79
+ this.removeNode(lastNode);
80
+ return lastNode;
81
+ }
82
+ /**
83
+ * Sets a key-value pair in the cache.
84
+ * If the key exists, updates the value and moves to head.
85
+ * If new, adds at head and evicts from tail if necessary.
86
+ *
87
+ * Time Complexity:
88
+ * - O(1) for uniform item sizes
89
+ * - O(k) where k is the number of items evicted (can be O(N) for variable sizes)
90
+ */ set(key, value) {
91
+ const size = (this.calculateSize == null ? void 0 : this.calculateSize.call(this, value)) ?? 1;
92
+ if (size > this.maxSize) {
93
+ console.warn('Single item size exceeds maxSize');
94
+ return;
95
+ }
96
+ const existing = this.cache.get(key);
97
+ if (existing) {
98
+ // Update existing node: adjust size and move to head (most recent)
99
+ existing.data = value;
100
+ this.totalSize = this.totalSize - existing.size + size;
101
+ existing.size = size;
102
+ this.moveToHead(existing);
103
+ } else {
104
+ // Add new node at head (most recent position)
105
+ const newNode = new LRUNode(key, value, size);
106
+ this.cache.set(key, newNode);
107
+ this.addToHead(newNode);
108
+ this.totalSize += size;
109
+ }
110
+ // Evict least recently used items until under capacity
111
+ while(this.totalSize > this.maxSize && this.cache.size > 0){
112
+ const tail = this.removeTail();
113
+ this.cache.delete(tail.key);
114
+ this.totalSize -= tail.size;
115
+ }
116
+ }
117
+ /**
118
+ * Checks if a key exists in the cache.
119
+ * This is a pure query operation - does NOT update LRU order.
120
+ *
121
+ * Time Complexity: O(1)
122
+ */ has(key) {
123
+ return this.cache.has(key);
124
+ }
125
+ /**
126
+ * Retrieves a value by key and marks it as most recently used.
127
+ * Moving to head maintains the LRU property for future evictions.
128
+ *
129
+ * Time Complexity: O(1)
130
+ */ get(key) {
131
+ const node = this.cache.get(key);
132
+ if (!node) return undefined;
133
+ // Mark as most recently used by moving to head
134
+ this.moveToHead(node);
135
+ return node.data;
136
+ }
137
+ /**
138
+ * Returns an iterator over the cache entries. The order is outputted in the
139
+ * order of most recently used to least recently used.
140
+ */ *[Symbol.iterator]() {
141
+ let current = this.head.next;
142
+ while(current && current !== this.tail){
143
+ // Between head and tail, current is always LRUNode
144
+ const node = current;
145
+ yield [
146
+ node.key,
147
+ node.data
148
+ ];
149
+ current = current.next;
150
+ }
151
+ }
152
+ /**
153
+ * Removes a specific key from the cache.
154
+ * Updates both the hash map and doubly-linked list.
155
+ *
156
+ * Time Complexity: O(1)
157
+ */ remove(key) {
158
+ const node = this.cache.get(key);
159
+ if (!node) return;
160
+ this.removeNode(node);
161
+ this.cache.delete(key);
162
+ this.totalSize -= node.size;
163
+ }
164
+ /**
165
+ * Returns the number of items in the cache.
166
+ */ get size() {
167
+ return this.cache.size;
168
+ }
169
+ /**
170
+ * Returns the current total size of all cached items.
171
+ * This uses the custom size calculation if provided.
172
+ */ get currentSize() {
173
+ return this.totalSize;
174
+ }
175
+ }
176
+
177
+ //# sourceMappingURL=lru-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../cache/lru-cache.ts"],"sourcesContent":["/**\n * Node in the doubly-linked list used for LRU tracking.\n * Each node represents a cache entry with bidirectional pointers.\n */\nclass LRUNode<T> {\n public readonly key: string\n public data: T\n public size: number\n public prev: LRUNode<T> | SentinelNode<T> | null = null\n public next: LRUNode<T> | SentinelNode<T> | null = null\n\n constructor(key: string, data: T, size: number) {\n this.key = key\n this.data = data\n this.size = size\n }\n}\n\n/**\n * Sentinel node used for head/tail boundaries.\n * These nodes don't contain actual cache data but simplify list operations.\n */\nclass SentinelNode<T> {\n public prev: LRUNode<T> | SentinelNode<T> | null = null\n public next: LRUNode<T> | SentinelNode<T> | null = null\n}\n\n/**\n * LRU (Least Recently Used) Cache implementation using a doubly-linked list\n * and hash map for O(1) operations.\n *\n * Algorithm:\n * - Uses a doubly-linked list to maintain access order (most recent at head)\n * - Hash map provides O(1) key-to-node lookup\n * - Sentinel head/tail nodes simplify edge case handling\n * - Size-based eviction supports custom size calculation functions\n *\n * Data Structure Layout:\n * HEAD <-> [most recent] <-> ... <-> [least recent] <-> TAIL\n *\n * Operations:\n * - get(): Move accessed node to head (mark as most recent)\n * - set(): Add new node at head, evict from tail if over capacity\n * - Eviction: Remove least recent node (tail.prev) when size exceeds limit\n */\nexport class LRUCache<T> {\n private readonly cache: Map<string, LRUNode<T>> = new Map()\n private readonly head: SentinelNode<T>\n private readonly tail: SentinelNode<T>\n private totalSize: number = 0\n private readonly maxSize: number\n private readonly calculateSize: ((value: T) => number) | undefined\n\n constructor(maxSize: number, calculateSize?: (value: T) => number) {\n this.maxSize = maxSize\n this.calculateSize = calculateSize\n\n // Create sentinel nodes to simplify doubly-linked list operations\n // HEAD <-> TAIL (empty list)\n this.head = new SentinelNode<T>()\n this.tail = new SentinelNode<T>()\n this.head.next = this.tail\n this.tail.prev = this.head\n }\n\n /**\n * Adds a node immediately after the head (marks as most recently used).\n * Used when inserting new items or when an item is accessed.\n * PRECONDITION: node must be disconnected (prev/next should be null)\n */\n private addToHead(node: LRUNode<T>): void {\n node.prev = this.head\n node.next = this.head.next\n // head.next is always non-null (points to tail or another node)\n this.head.next!.prev = node\n this.head.next = node\n }\n\n /**\n * Removes a node from its current position in the doubly-linked list.\n * Updates the prev/next pointers of adjacent nodes to maintain list integrity.\n * PRECONDITION: node must be connected (prev/next are non-null)\n */\n private removeNode(node: LRUNode<T>): void {\n // Connected nodes always have non-null prev/next\n node.prev!.next = node.next\n node.next!.prev = node.prev\n }\n\n /**\n * Moves an existing node to the head position (marks as most recently used).\n * This is the core LRU operation - accessed items become most recent.\n */\n private moveToHead(node: LRUNode<T>): void {\n this.removeNode(node)\n this.addToHead(node)\n }\n\n /**\n * Removes and returns the least recently used node (the one before tail).\n * This is called during eviction when the cache exceeds capacity.\n * PRECONDITION: cache is not empty (ensured by caller)\n */\n private removeTail(): LRUNode<T> {\n const lastNode = this.tail.prev as LRUNode<T>\n // tail.prev is always non-null and always LRUNode when cache is not empty\n this.removeNode(lastNode)\n return lastNode\n }\n\n /**\n * Sets a key-value pair in the cache.\n * If the key exists, updates the value and moves to head.\n * If new, adds at head and evicts from tail if necessary.\n *\n * Time Complexity:\n * - O(1) for uniform item sizes\n * - O(k) where k is the number of items evicted (can be O(N) for variable sizes)\n */\n public set(key: string, value: T): void {\n const size = this.calculateSize?.(value) ?? 1\n if (size > this.maxSize) {\n console.warn('Single item size exceeds maxSize')\n return\n }\n\n const existing = this.cache.get(key)\n if (existing) {\n // Update existing node: adjust size and move to head (most recent)\n existing.data = value\n this.totalSize = this.totalSize - existing.size + size\n existing.size = size\n this.moveToHead(existing)\n } else {\n // Add new node at head (most recent position)\n const newNode = new LRUNode(key, value, size)\n this.cache.set(key, newNode)\n this.addToHead(newNode)\n this.totalSize += size\n }\n\n // Evict least recently used items until under capacity\n while (this.totalSize > this.maxSize && this.cache.size > 0) {\n const tail = this.removeTail()\n this.cache.delete(tail.key)\n this.totalSize -= tail.size\n }\n }\n\n /**\n * Checks if a key exists in the cache.\n * This is a pure query operation - does NOT update LRU order.\n *\n * Time Complexity: O(1)\n */\n public has(key: string): boolean {\n return this.cache.has(key)\n }\n\n /**\n * Retrieves a value by key and marks it as most recently used.\n * Moving to head maintains the LRU property for future evictions.\n *\n * Time Complexity: O(1)\n */\n public get(key: string): T | undefined {\n const node = this.cache.get(key)\n if (!node) return undefined\n\n // Mark as most recently used by moving to head\n this.moveToHead(node)\n\n return node.data\n }\n\n /**\n * Returns an iterator over the cache entries. The order is outputted in the\n * order of most recently used to least recently used.\n */\n public *[Symbol.iterator](): IterableIterator<[string, T]> {\n let current = this.head.next\n while (current && current !== this.tail) {\n // Between head and tail, current is always LRUNode\n const node = current as LRUNode<T>\n yield [node.key, node.data]\n current = current.next\n }\n }\n\n /**\n * Removes a specific key from the cache.\n * Updates both the hash map and doubly-linked list.\n *\n * Time Complexity: O(1)\n */\n public remove(key: string): void {\n const node = this.cache.get(key)\n if (!node) return\n\n this.removeNode(node)\n this.cache.delete(key)\n this.totalSize -= node.size\n }\n\n /**\n * Returns the number of items in the cache.\n */\n public get size(): number {\n return this.cache.size\n }\n\n /**\n * Returns the current total size of all cached items.\n * This uses the custom size calculation if provided.\n */\n public get currentSize(): number {\n return this.totalSize\n }\n}\n"],"names":["LRUCache","LRUNode","constructor","key","data","size","prev","next","SentinelNode","maxSize","calculateSize","cache","Map","totalSize","head","tail","addToHead","node","removeNode","moveToHead","removeTail","lastNode","set","value","console","warn","existing","get","newNode","delete","has","undefined","Symbol","iterator","current","remove","currentSize"],"mappings":"AAAA;;;CAGC;;;;+BA0CYA;;;eAAAA;;;AAzCb,MAAMC;IAOJC,YAAYC,GAAW,EAAEC,IAAO,EAAEC,IAAY,CAAE;aAHzCC,OAA4C;aAC5CC,OAA4C;QAGjD,IAAI,CAACJ,GAAG,GAAGA;QACX,IAAI,CAACC,IAAI,GAAGA;QACZ,IAAI,CAACC,IAAI,GAAGA;IACd;AACF;AAEA;;;CAGC,GACD,MAAMG;;aACGF,OAA4C;aAC5CC,OAA4C;;AACrD;AAoBO,MAAMP;IAQXE,YAAYO,OAAe,EAAEC,aAAoC,CAAE;aAPlDC,QAAiC,IAAIC;aAG9CC,YAAoB;QAK1B,IAAI,CAACJ,OAAO,GAAGA;QACf,I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D;YACnD,MAAME,OAAOiB;YACb,MAAM;gBAACjB,KAAKd,GAAG;gBAAEc,KAAKb,IAAI;aAAC;YAC3B8B,UAAUA,QAAQ3B,IAAI;QACxB;IACF;IAEA;;;;;GAKC,GACD,AAAO4B,OAAOhC,GAAW,EAAQ;QAC/B,MAAMc,OAAO,IAAI,CAACN,KAAK,CAACgB,GAAG,CAACxB;QAC5B,IAAI,CAACc,MAAM;QAEX,IAAI,CAACC,UAAU,CAACD;QAChB,IAAI,CAACN,KAAK,CAACkB,MAAM,CAAC1B;QAClB,IAAI,CAACU,SAAS,IAAII,KAAKZ,IAAI;IAC7B;IAEA;;GAEC,GACD,IAAWA,OAAe;QACxB,OAAO,IAAI,CAACM,KAAK,CAACN,IAAI;IACxB;IAEA;;;GAGC,GACD,IAAW+B,cAAsB;QAC/B,OAAO,IAAI,CAACvB,SAAS;IACvB;AACF","ignoreList":[0]}
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "appBootstrap", {
15
15
  });
16
16
  const _assetprefix = require("./asset-prefix");
17
17
  const _setattributesfromprops = require("./set-attributes-from-props");
18
- const version = "16.2.0";
18
+ const version = "16.2.1";
19
19
  window.next = {
20
20
  version,
21
21
  appDir: true
@@ -60,7 +60,7 @@ const _hooksclientcontextsharedruntime = require("../shared/lib/hooks-client-con
60
60
  const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
61
61
  const _tracer = /*#__PURE__*/ _interop_require_default._(require("./tracing/tracer"));
62
62
  const _isnextroutererror = require("./components/is-next-router-error");
63
- const version = "16.2.0";
63
+ const version = "16.2.1";
64
64
  let router;
65
65
  const emitter = (0, _mitt.default)();
66
66
  const looseToArray = (input)=>[].slice.call(input);