pnpm 8.6.2 → 8.6.4

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 (418) hide show
  1. package/dist/node_modules/.modules.yaml +81 -24
  2. package/dist/node_modules/.pnpm/lock.yaml +235 -91
  3. package/dist/node_modules/@isaacs/cliui/LICENSE.txt +14 -0
  4. package/dist/node_modules/@isaacs/cliui/build/index.cjs +317 -0
  5. package/dist/node_modules/@isaacs/cliui/build/index.d.cts +43 -0
  6. package/dist/node_modules/@isaacs/cliui/build/lib/index.js +302 -0
  7. package/dist/node_modules/@isaacs/cliui/index.mjs +14 -0
  8. package/dist/node_modules/@isaacs/cliui/node_modules/string-width/index.js +54 -0
  9. package/dist/node_modules/@isaacs/cliui/node_modules/string-width/license +9 -0
  10. package/dist/node_modules/@isaacs/cliui/node_modules/string-width/package.json +59 -0
  11. package/dist/node_modules/@isaacs/cliui/package.json +86 -0
  12. package/dist/node_modules/@npmcli/fs/lib/cp/index.js +1 -1
  13. package/dist/node_modules/@npmcli/fs/lib/cp/polyfill.js +2 -2
  14. package/dist/node_modules/@npmcli/fs/lib/index.js +11 -10
  15. package/dist/node_modules/@npmcli/fs/lib/move-file.js +78 -0
  16. package/dist/node_modules/@npmcli/fs/lib/readdir-scoped.js +20 -0
  17. package/dist/node_modules/@npmcli/fs/lib/with-temp-dir.js +4 -6
  18. package/dist/node_modules/@npmcli/fs/package.json +11 -9
  19. package/dist/node_modules/@pkgjs/parseargs/LICENSE +201 -0
  20. package/dist/node_modules/@pkgjs/parseargs/index.js +396 -0
  21. package/dist/node_modules/@pkgjs/parseargs/internal/errors.js +47 -0
  22. package/dist/node_modules/@pkgjs/parseargs/internal/primordials.js +393 -0
  23. package/dist/node_modules/@pkgjs/parseargs/internal/util.js +14 -0
  24. package/dist/node_modules/@pkgjs/parseargs/internal/validators.js +89 -0
  25. package/dist/node_modules/@pkgjs/parseargs/package.json +36 -0
  26. package/dist/node_modules/@pkgjs/parseargs/utils.js +198 -0
  27. package/dist/node_modules/ansi-regex/index.js +3 -5
  28. package/dist/node_modules/ansi-regex/license +1 -1
  29. package/dist/node_modules/ansi-regex/package.json +9 -6
  30. package/dist/node_modules/ansi-styles/index.js +223 -0
  31. package/dist/node_modules/ansi-styles/license +9 -0
  32. package/dist/node_modules/ansi-styles/package.json +54 -0
  33. package/dist/node_modules/cacache/lib/content/read.js +1 -76
  34. package/dist/node_modules/cacache/lib/content/rm.js +2 -4
  35. package/dist/node_modules/cacache/lib/content/write.js +40 -24
  36. package/dist/node_modules/cacache/lib/entry-index.js +25 -99
  37. package/dist/node_modules/cacache/lib/get.js +1 -56
  38. package/dist/node_modules/cacache/lib/index.js +0 -3
  39. package/dist/node_modules/cacache/lib/rm.js +5 -5
  40. package/dist/node_modules/cacache/lib/util/glob.js +7 -0
  41. package/dist/node_modules/cacache/lib/util/tmp.js +3 -10
  42. package/dist/node_modules/cacache/lib/verify.js +28 -28
  43. package/dist/node_modules/cacache/node_modules/glob/LICENSE +1 -1
  44. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/package.json +4 -0
  45. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/bin.d.ts.map +1 -0
  46. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/bin.js +270 -0
  47. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/bin.js.map +1 -0
  48. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/glob.d.ts.map +1 -0
  49. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/glob.js +234 -0
  50. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/glob.js.map +1 -0
  51. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/has-magic.d.ts.map +1 -0
  52. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/has-magic.js +27 -0
  53. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/has-magic.js.map +1 -0
  54. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/ignore.d.ts.map +1 -0
  55. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/ignore.js +103 -0
  56. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/ignore.js.map +1 -0
  57. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/index.d.ts.map +1 -0
  58. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/index.js +68 -0
  59. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/index.js.map +1 -0
  60. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/pattern.d.ts.map +1 -0
  61. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/pattern.js +219 -0
  62. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/pattern.js.map +1 -0
  63. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/processor.d.ts.map +1 -0
  64. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/processor.js +309 -0
  65. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/processor.js.map +1 -0
  66. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/walker.d.ts.map +1 -0
  67. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/walker.js +358 -0
  68. package/dist/node_modules/cacache/node_modules/glob/dist/cjs/src/walker.js.map +1 -0
  69. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/glob.d.ts.map +1 -0
  70. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/glob.js +230 -0
  71. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/glob.js.map +1 -0
  72. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/has-magic.d.ts.map +1 -0
  73. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/has-magic.js +23 -0
  74. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/has-magic.js.map +1 -0
  75. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/ignore.d.ts.map +1 -0
  76. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/ignore.js +99 -0
  77. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/ignore.js.map +1 -0
  78. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/index.d.ts.map +1 -0
  79. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/index.js +56 -0
  80. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/index.js.map +1 -0
  81. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/package.json +4 -0
  82. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/pattern.d.ts.map +1 -0
  83. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/pattern.js +215 -0
  84. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/pattern.js.map +1 -0
  85. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/processor.d.ts.map +1 -0
  86. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/processor.js +302 -0
  87. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/processor.js.map +1 -0
  88. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/walker.d.ts.map +1 -0
  89. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/walker.js +352 -0
  90. package/dist/node_modules/cacache/node_modules/glob/dist/mjs/walker.js.map +1 -0
  91. package/dist/node_modules/cacache/node_modules/glob/package.json +78 -35
  92. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/assert-valid-pattern.d.ts.map +1 -0
  93. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/assert-valid-pattern.js +14 -0
  94. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/assert-valid-pattern.js.map +1 -0
  95. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/ast.d.ts.map +1 -0
  96. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/ast.js +589 -0
  97. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/ast.js.map +1 -0
  98. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/brace-expressions.d.ts.map +1 -0
  99. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/brace-expressions.js +152 -0
  100. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/brace-expressions.js.map +1 -0
  101. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/escape.d.ts.map +1 -0
  102. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/escape.js +22 -0
  103. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/escape.js.map +1 -0
  104. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/index.d.ts.map +1 -0
  105. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/index.js +1011 -0
  106. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/index.js.map +1 -0
  107. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/package.json +3 -0
  108. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/unescape.d.ts.map +1 -0
  109. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/unescape.js +24 -0
  110. package/dist/node_modules/cacache/node_modules/minimatch/dist/cjs/unescape.js.map +1 -0
  111. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/assert-valid-pattern.d.ts.map +1 -0
  112. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/assert-valid-pattern.js +10 -0
  113. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/assert-valid-pattern.js.map +1 -0
  114. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/ast.d.ts.map +1 -0
  115. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/ast.js +585 -0
  116. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/ast.js.map +1 -0
  117. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/brace-expressions.d.ts.map +1 -0
  118. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/brace-expressions.js +148 -0
  119. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/brace-expressions.js.map +1 -0
  120. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/escape.d.ts.map +1 -0
  121. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/escape.js +18 -0
  122. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/escape.js.map +1 -0
  123. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/index.d.ts.map +1 -0
  124. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/index.js +995 -0
  125. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/index.js.map +1 -0
  126. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/package.json +3 -0
  127. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/unescape.d.ts.map +1 -0
  128. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/unescape.js +20 -0
  129. package/dist/node_modules/cacache/node_modules/minimatch/dist/mjs/unescape.js.map +1 -0
  130. package/dist/node_modules/cacache/node_modules/minimatch/package.json +66 -15
  131. package/dist/node_modules/cacache/package.json +19 -21
  132. package/dist/node_modules/color-convert/LICENSE +21 -0
  133. package/dist/node_modules/color-convert/conversions.js +839 -0
  134. package/dist/node_modules/color-convert/index.js +81 -0
  135. package/dist/node_modules/color-convert/package.json +48 -0
  136. package/dist/node_modules/color-convert/route.js +97 -0
  137. package/dist/node_modules/color-name/LICENSE +8 -0
  138. package/dist/node_modules/color-name/index.js +152 -0
  139. package/dist/node_modules/color-name/package.json +28 -0
  140. package/dist/node_modules/cross-spawn/LICENSE +21 -0
  141. package/dist/node_modules/cross-spawn/index.js +39 -0
  142. package/dist/node_modules/cross-spawn/lib/enoent.js +59 -0
  143. package/dist/node_modules/cross-spawn/lib/parse.js +91 -0
  144. package/dist/node_modules/cross-spawn/lib/util/escape.js +45 -0
  145. package/dist/node_modules/cross-spawn/lib/util/readShebang.js +23 -0
  146. package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +52 -0
  147. package/dist/node_modules/cross-spawn/package.json +73 -0
  148. package/dist/node_modules/eastasianwidth/eastasianwidth.js +311 -0
  149. package/dist/node_modules/eastasianwidth/package.json +18 -0
  150. package/dist/node_modules/emoji-regex/RGI_Emoji.js +6 -0
  151. package/dist/node_modules/emoji-regex/es2015/RGI_Emoji.js +6 -0
  152. package/dist/node_modules/emoji-regex/es2015/index.js +1 -1
  153. package/dist/node_modules/emoji-regex/es2015/text.js +1 -1
  154. package/dist/node_modules/emoji-regex/index.js +1 -1
  155. package/dist/node_modules/emoji-regex/package.json +13 -11
  156. package/dist/node_modules/emoji-regex/text.js +1 -1
  157. package/dist/node_modules/exponential-backoff/LICENSE +202 -0
  158. package/dist/node_modules/exponential-backoff/dist/backoff.js +118 -0
  159. package/dist/node_modules/exponential-backoff/dist/backoff.js.map +1 -0
  160. package/dist/node_modules/exponential-backoff/dist/delay/always/always.delay.js +25 -0
  161. package/dist/node_modules/exponential-backoff/dist/delay/always/always.delay.js.map +1 -0
  162. package/dist/node_modules/exponential-backoff/dist/delay/delay.base.js +45 -0
  163. package/dist/node_modules/exponential-backoff/dist/delay/delay.base.js.map +1 -0
  164. package/dist/node_modules/exponential-backoff/dist/delay/delay.factory.js +17 -0
  165. package/dist/node_modules/exponential-backoff/dist/delay/delay.factory.js.map +1 -0
  166. package/dist/node_modules/exponential-backoff/dist/delay/delay.interface.js +3 -0
  167. package/dist/node_modules/exponential-backoff/dist/delay/delay.interface.js.map +1 -0
  168. package/dist/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js +82 -0
  169. package/dist/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js.map +1 -0
  170. package/dist/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js +8 -0
  171. package/dist/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js.map +1 -0
  172. package/dist/node_modules/exponential-backoff/dist/jitter/jitter.factory.js +15 -0
  173. package/dist/node_modules/exponential-backoff/dist/jitter/jitter.factory.js.map +1 -0
  174. package/dist/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js +7 -0
  175. package/dist/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js.map +1 -0
  176. package/dist/node_modules/exponential-backoff/dist/options.js +31 -0
  177. package/dist/node_modules/exponential-backoff/dist/options.js.map +1 -0
  178. package/dist/node_modules/exponential-backoff/package.json +61 -0
  179. package/dist/node_modules/{promise-inflight → foreground-child}/LICENSE +5 -4
  180. package/dist/node_modules/foreground-child/dist/cjs/all-signals.d.ts.map +1 -0
  181. package/dist/node_modules/foreground-child/dist/cjs/all-signals.js +58 -0
  182. package/dist/node_modules/foreground-child/dist/cjs/all-signals.js.map +1 -0
  183. package/dist/node_modules/foreground-child/dist/cjs/index.d.ts.map +1 -0
  184. package/dist/node_modules/foreground-child/dist/cjs/index.js +154 -0
  185. package/dist/node_modules/foreground-child/dist/cjs/index.js.map +1 -0
  186. package/dist/node_modules/foreground-child/dist/cjs/package.json +3 -0
  187. package/dist/node_modules/foreground-child/dist/cjs/watchdog.d.ts.map +1 -0
  188. package/dist/node_modules/foreground-child/dist/cjs/watchdog.js +43 -0
  189. package/dist/node_modules/foreground-child/dist/cjs/watchdog.js.map +1 -0
  190. package/dist/node_modules/foreground-child/dist/mjs/all-signals.d.ts.map +1 -0
  191. package/dist/node_modules/foreground-child/dist/mjs/all-signals.js +52 -0
  192. package/dist/node_modules/foreground-child/dist/mjs/all-signals.js.map +1 -0
  193. package/dist/node_modules/foreground-child/dist/mjs/index.d.ts.map +1 -0
  194. package/dist/node_modules/foreground-child/dist/mjs/index.js +146 -0
  195. package/dist/node_modules/foreground-child/dist/mjs/index.js.map +1 -0
  196. package/dist/node_modules/foreground-child/dist/mjs/package.json +3 -0
  197. package/dist/node_modules/foreground-child/dist/mjs/watchdog.d.ts.map +1 -0
  198. package/dist/node_modules/foreground-child/dist/mjs/watchdog.js +39 -0
  199. package/dist/node_modules/foreground-child/dist/mjs/watchdog.js.map +1 -0
  200. package/dist/node_modules/foreground-child/package.json +83 -0
  201. package/dist/node_modules/fs-minipass/lib/index.js +443 -0
  202. package/dist/node_modules/fs-minipass/package.json +28 -13
  203. package/dist/node_modules/gauge/node_modules/ansi-regex/index.js +10 -0
  204. package/dist/node_modules/gauge/node_modules/ansi-regex/license +9 -0
  205. package/dist/node_modules/gauge/node_modules/ansi-regex/package.json +55 -0
  206. package/dist/node_modules/gauge/node_modules/signal-exit/LICENSE.txt +16 -0
  207. package/dist/node_modules/gauge/node_modules/signal-exit/package.json +38 -0
  208. package/dist/node_modules/gauge/node_modules/strip-ansi/index.js +4 -0
  209. package/dist/node_modules/gauge/node_modules/strip-ansi/license +9 -0
  210. package/dist/node_modules/gauge/node_modules/strip-ansi/package.json +54 -0
  211. package/dist/node_modules/jackspeak/dist/cjs/index.d.ts.map +1 -0
  212. package/dist/node_modules/jackspeak/dist/cjs/index.js +723 -0
  213. package/dist/node_modules/jackspeak/dist/cjs/index.js.map +1 -0
  214. package/dist/node_modules/jackspeak/dist/cjs/package.json +3 -0
  215. package/dist/node_modules/jackspeak/dist/cjs/parse-args-cjs.d.ts.map +1 -0
  216. package/dist/node_modules/jackspeak/dist/cjs/parse-args-cjs.js.map +1 -0
  217. package/dist/node_modules/jackspeak/dist/cjs/parse-args.js +42 -0
  218. package/dist/node_modules/jackspeak/dist/mjs/index.d.ts.map +1 -0
  219. package/dist/node_modules/jackspeak/dist/mjs/index.js +713 -0
  220. package/dist/node_modules/jackspeak/dist/mjs/index.js.map +1 -0
  221. package/dist/node_modules/jackspeak/dist/mjs/package.json +3 -0
  222. package/dist/node_modules/jackspeak/dist/mjs/parse-args-esm.d.ts.map +1 -0
  223. package/dist/node_modules/jackspeak/dist/mjs/parse-args-esm.js.map +1 -0
  224. package/dist/node_modules/jackspeak/dist/mjs/parse-args.js +19 -0
  225. package/dist/node_modules/jackspeak/package.json +98 -0
  226. package/dist/node_modules/make-fetch-happen/lib/cache/entry.js +26 -1
  227. package/dist/node_modules/make-fetch-happen/lib/options.js +2 -0
  228. package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
  229. package/dist/node_modules/make-fetch-happen/package.json +16 -17
  230. package/dist/node_modules/minipass/LICENSE +1 -1
  231. package/dist/node_modules/minipass/index.js +299 -246
  232. package/dist/node_modules/minipass/package.json +27 -7
  233. package/dist/node_modules/{tar → minipass-collect}/node_modules/minipass/LICENSE +1 -1
  234. package/dist/node_modules/minipass-collect/node_modules/minipass/index.js +649 -0
  235. package/dist/node_modules/{tar → minipass-collect}/node_modules/minipass/package.json +7 -27
  236. package/dist/node_modules/minipass-fetch/lib/blob.js +1 -1
  237. package/dist/node_modules/minipass-fetch/lib/body.js +1 -1
  238. package/dist/node_modules/minipass-fetch/lib/index.js +15 -3
  239. package/dist/node_modules/minipass-fetch/lib/request.js +2 -1
  240. package/dist/node_modules/minipass-fetch/package.json +13 -11
  241. package/dist/node_modules/minipass-flush/node_modules/minipass/LICENSE +15 -0
  242. package/dist/node_modules/minipass-flush/node_modules/minipass/index.js +649 -0
  243. package/dist/node_modules/minipass-flush/node_modules/minipass/package.json +56 -0
  244. package/dist/node_modules/minipass-pipeline/node_modules/minipass/LICENSE +15 -0
  245. package/dist/node_modules/minipass-pipeline/node_modules/minipass/index.js +649 -0
  246. package/dist/node_modules/minipass-pipeline/node_modules/minipass/package.json +56 -0
  247. package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +15 -0
  248. package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +649 -0
  249. package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +56 -0
  250. package/dist/node_modules/minizlib/node_modules/minipass/LICENSE +15 -0
  251. package/dist/node_modules/minizlib/node_modules/minipass/index.js +649 -0
  252. package/dist/node_modules/minizlib/node_modules/minipass/package.json +56 -0
  253. package/dist/node_modules/node-gyp/.github/workflows/tests.yml +9 -6
  254. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +1 -1
  255. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  256. package/dist/node_modules/node-gyp/lib/find-visualstudio.js +13 -2
  257. package/dist/node_modules/node-gyp/lib/install.js +174 -92
  258. package/dist/node_modules/node-gyp/package.json +7 -6
  259. package/dist/node_modules/node-gyp/update-gyp.py +1 -1
  260. package/dist/node_modules/path-key/index.js +16 -0
  261. package/dist/node_modules/path-key/license +9 -0
  262. package/dist/node_modules/path-key/package.json +39 -0
  263. package/dist/node_modules/path-scurry/dist/cjs/index.d.ts.map +1 -0
  264. package/dist/node_modules/path-scurry/dist/cjs/index.js +1995 -0
  265. package/dist/node_modules/path-scurry/dist/cjs/index.js.map +1 -0
  266. package/dist/node_modules/path-scurry/dist/cjs/package.json +3 -0
  267. package/dist/node_modules/path-scurry/dist/mjs/index.d.ts.map +1 -0
  268. package/dist/node_modules/path-scurry/dist/mjs/index.js +1960 -0
  269. package/dist/node_modules/path-scurry/dist/mjs/index.js.map +1 -0
  270. package/dist/node_modules/path-scurry/dist/mjs/package.json +3 -0
  271. package/dist/node_modules/path-scurry/node_modules/lru-cache/LICENSE +15 -0
  272. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/cjs/index.d.ts.map +1 -0
  273. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/cjs/index.js +1395 -0
  274. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/cjs/index.js.map +1 -0
  275. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/cjs/index.min.js +2 -0
  276. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/cjs/index.min.js.map +7 -0
  277. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/cjs/package.json +3 -0
  278. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/mjs/index.d.ts.map +1 -0
  279. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/mjs/index.js +1391 -0
  280. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/mjs/index.js.map +1 -0
  281. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/mjs/index.min.js +2 -0
  282. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/mjs/index.min.js.map +7 -0
  283. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/mjs/package.json +3 -0
  284. package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +108 -0
  285. package/dist/node_modules/path-scurry/package.json +87 -0
  286. package/dist/node_modules/semver/classes/comparator.js +2 -1
  287. package/dist/node_modules/semver/classes/range.js +40 -27
  288. package/dist/node_modules/semver/classes/semver.js +5 -3
  289. package/dist/node_modules/semver/functions/coerce.js +1 -1
  290. package/dist/node_modules/semver/functions/diff.js +31 -20
  291. package/dist/node_modules/semver/internal/constants.js +5 -0
  292. package/dist/node_modules/semver/internal/re.js +30 -4
  293. package/dist/node_modules/semver/package.json +4 -4
  294. package/dist/node_modules/shebang-command/index.js +19 -0
  295. package/dist/node_modules/shebang-command/license +9 -0
  296. package/dist/node_modules/shebang-command/package.json +34 -0
  297. package/dist/node_modules/shebang-regex/index.js +2 -0
  298. package/dist/node_modules/shebang-regex/license +9 -0
  299. package/dist/node_modules/shebang-regex/package.json +35 -0
  300. package/dist/node_modules/signal-exit/LICENSE.txt +1 -1
  301. package/dist/node_modules/signal-exit/dist/cjs/browser.d.ts.map +1 -0
  302. package/dist/node_modules/signal-exit/dist/cjs/browser.js +10 -0
  303. package/dist/node_modules/signal-exit/dist/cjs/browser.js.map +1 -0
  304. package/dist/node_modules/signal-exit/dist/cjs/index.d.ts.map +1 -0
  305. package/dist/node_modules/signal-exit/dist/cjs/index.js +272 -0
  306. package/dist/node_modules/signal-exit/dist/cjs/index.js.map +1 -0
  307. package/dist/node_modules/signal-exit/dist/cjs/package.json +3 -0
  308. package/dist/node_modules/signal-exit/dist/cjs/signals.d.ts.map +1 -0
  309. package/dist/node_modules/signal-exit/dist/cjs/signals.js +42 -0
  310. package/dist/node_modules/signal-exit/dist/cjs/signals.js.map +1 -0
  311. package/dist/node_modules/signal-exit/dist/mjs/browser.d.ts.map +1 -0
  312. package/dist/node_modules/signal-exit/dist/mjs/browser.js +4 -0
  313. package/dist/node_modules/signal-exit/dist/mjs/browser.js.map +1 -0
  314. package/dist/node_modules/signal-exit/dist/mjs/index.d.ts.map +1 -0
  315. package/dist/node_modules/signal-exit/dist/mjs/index.js +268 -0
  316. package/dist/node_modules/signal-exit/dist/mjs/index.js.map +1 -0
  317. package/dist/node_modules/signal-exit/dist/mjs/package.json +3 -0
  318. package/dist/node_modules/signal-exit/dist/mjs/signals.d.ts.map +1 -0
  319. package/dist/node_modules/signal-exit/dist/mjs/signals.js +39 -0
  320. package/dist/node_modules/signal-exit/dist/mjs/signals.js.map +1 -0
  321. package/dist/node_modules/signal-exit/package.json +87 -19
  322. package/dist/node_modules/ssri/lib/index.js +157 -101
  323. package/dist/node_modules/ssri/package.json +12 -10
  324. package/dist/node_modules/string-width/node_modules/ansi-regex/index.js +10 -0
  325. package/dist/node_modules/string-width/node_modules/ansi-regex/license +9 -0
  326. package/dist/node_modules/string-width/node_modules/ansi-regex/package.json +55 -0
  327. package/dist/node_modules/string-width/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  328. package/dist/node_modules/string-width/node_modules/emoji-regex/es2015/index.js +6 -0
  329. package/dist/node_modules/string-width/node_modules/emoji-regex/es2015/text.js +6 -0
  330. package/dist/node_modules/string-width/node_modules/emoji-regex/index.js +6 -0
  331. package/dist/node_modules/string-width/node_modules/emoji-regex/package.json +50 -0
  332. package/dist/node_modules/string-width/node_modules/emoji-regex/text.js +6 -0
  333. package/dist/node_modules/string-width/node_modules/strip-ansi/index.js +4 -0
  334. package/dist/node_modules/string-width/node_modules/strip-ansi/license +9 -0
  335. package/dist/node_modules/string-width/node_modules/strip-ansi/package.json +54 -0
  336. package/dist/node_modules/string-width-cjs/index.js +47 -0
  337. package/dist/node_modules/string-width-cjs/license +9 -0
  338. package/dist/node_modules/string-width-cjs/node_modules/ansi-regex/index.js +10 -0
  339. package/dist/node_modules/string-width-cjs/node_modules/ansi-regex/license +9 -0
  340. package/dist/node_modules/string-width-cjs/node_modules/ansi-regex/package.json +55 -0
  341. package/dist/node_modules/string-width-cjs/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  342. package/dist/node_modules/string-width-cjs/node_modules/emoji-regex/es2015/index.js +6 -0
  343. package/dist/node_modules/string-width-cjs/node_modules/emoji-regex/es2015/text.js +6 -0
  344. package/dist/node_modules/string-width-cjs/node_modules/emoji-regex/index.js +6 -0
  345. package/dist/node_modules/string-width-cjs/node_modules/emoji-regex/package.json +50 -0
  346. package/dist/node_modules/string-width-cjs/node_modules/emoji-regex/text.js +6 -0
  347. package/dist/node_modules/string-width-cjs/node_modules/strip-ansi/index.js +4 -0
  348. package/dist/node_modules/string-width-cjs/node_modules/strip-ansi/license +9 -0
  349. package/dist/node_modules/string-width-cjs/node_modules/strip-ansi/package.json +54 -0
  350. package/dist/node_modules/string-width-cjs/package.json +56 -0
  351. package/dist/node_modules/strip-ansi/index.js +13 -3
  352. package/dist/node_modules/strip-ansi/license +1 -1
  353. package/dist/node_modules/strip-ansi/package.json +10 -7
  354. package/dist/node_modules/strip-ansi-cjs/index.js +4 -0
  355. package/dist/node_modules/strip-ansi-cjs/license +9 -0
  356. package/dist/node_modules/strip-ansi-cjs/node_modules/ansi-regex/index.js +10 -0
  357. package/dist/node_modules/strip-ansi-cjs/node_modules/ansi-regex/license +9 -0
  358. package/dist/node_modules/strip-ansi-cjs/node_modules/ansi-regex/package.json +55 -0
  359. package/dist/node_modules/strip-ansi-cjs/package.json +54 -0
  360. package/dist/node_modules/{infer-owner → tar/node_modules/fs-minipass}/LICENSE +1 -1
  361. package/dist/node_modules/tar/node_modules/fs-minipass/node_modules/minipass/LICENSE +15 -0
  362. package/dist/node_modules/tar/node_modules/fs-minipass/node_modules/minipass/index.js +649 -0
  363. package/dist/node_modules/tar/node_modules/fs-minipass/node_modules/minipass/package.json +56 -0
  364. package/dist/node_modules/tar/node_modules/fs-minipass/package.json +39 -0
  365. package/dist/node_modules/unique-filename/package.json +12 -9
  366. package/dist/node_modules/unique-slug/package.json +10 -7
  367. package/dist/node_modules/wrap-ansi/index.js +214 -0
  368. package/dist/node_modules/wrap-ansi/license +9 -0
  369. package/dist/node_modules/wrap-ansi/node_modules/string-width/index.js +54 -0
  370. package/dist/node_modules/wrap-ansi/node_modules/string-width/license +9 -0
  371. package/dist/node_modules/wrap-ansi/node_modules/string-width/package.json +59 -0
  372. package/dist/node_modules/wrap-ansi/package.json +69 -0
  373. package/dist/node_modules/wrap-ansi-cjs/index.js +216 -0
  374. package/dist/node_modules/wrap-ansi-cjs/license +9 -0
  375. package/dist/node_modules/wrap-ansi-cjs/node_modules/ansi-regex/index.js +10 -0
  376. package/dist/node_modules/wrap-ansi-cjs/node_modules/ansi-regex/license +9 -0
  377. package/dist/node_modules/wrap-ansi-cjs/node_modules/ansi-regex/package.json +55 -0
  378. package/dist/node_modules/wrap-ansi-cjs/node_modules/ansi-styles/index.js +163 -0
  379. package/dist/node_modules/wrap-ansi-cjs/node_modules/ansi-styles/license +9 -0
  380. package/dist/node_modules/wrap-ansi-cjs/node_modules/ansi-styles/package.json +56 -0
  381. package/dist/node_modules/wrap-ansi-cjs/node_modules/strip-ansi/index.js +4 -0
  382. package/dist/node_modules/wrap-ansi-cjs/node_modules/strip-ansi/license +9 -0
  383. package/dist/node_modules/wrap-ansi-cjs/node_modules/strip-ansi/package.json +54 -0
  384. package/dist/node_modules/wrap-ansi-cjs/package.json +62 -0
  385. package/dist/pnpm.cjs +30877 -17543
  386. package/package.json +3 -3
  387. package/dist/node_modules/@gar/promisify/index.js +0 -36
  388. package/dist/node_modules/@gar/promisify/package.json +0 -32
  389. package/dist/node_modules/@npmcli/fs/lib/common/owner-sync.js +0 -96
  390. package/dist/node_modules/@npmcli/fs/lib/common/owner.js +0 -96
  391. package/dist/node_modules/@npmcli/fs/lib/copy-file.js +0 -16
  392. package/dist/node_modules/@npmcli/fs/lib/fs.js +0 -14
  393. package/dist/node_modules/@npmcli/fs/lib/mkdir.js +0 -19
  394. package/dist/node_modules/@npmcli/fs/lib/mkdtemp.js +0 -23
  395. package/dist/node_modules/@npmcli/fs/lib/rm/index.js +0 -22
  396. package/dist/node_modules/@npmcli/fs/lib/rm/polyfill.js +0 -239
  397. package/dist/node_modules/@npmcli/fs/lib/with-owner-sync.js +0 -21
  398. package/dist/node_modules/@npmcli/fs/lib/with-owner.js +0 -21
  399. package/dist/node_modules/@npmcli/fs/lib/write-file.js +0 -14
  400. package/dist/node_modules/@npmcli/move-file/lib/index.js +0 -185
  401. package/dist/node_modules/@npmcli/move-file/package.json +0 -47
  402. package/dist/node_modules/cacache/lib/util/fix-owner.js +0 -145
  403. package/dist/node_modules/cacache/lib/util/move-file.js +0 -56
  404. package/dist/node_modules/cacache/node_modules/glob/common.js +0 -244
  405. package/dist/node_modules/cacache/node_modules/glob/glob.js +0 -790
  406. package/dist/node_modules/cacache/node_modules/glob/sync.js +0 -486
  407. package/dist/node_modules/cacache/node_modules/minimatch/lib/path.js +0 -4
  408. package/dist/node_modules/cacache/node_modules/minimatch/minimatch.js +0 -944
  409. package/dist/node_modules/infer-owner/index.js +0 -71
  410. package/dist/node_modules/infer-owner/package.json +0 -26
  411. package/dist/node_modules/promise-inflight/inflight.js +0 -36
  412. package/dist/node_modules/promise-inflight/package.json +0 -24
  413. package/dist/node_modules/tar/node_modules/minipass/index.js +0 -702
  414. /package/dist/node_modules/@npmcli/fs/lib/{errors.js → cp/errors.js} +0 -0
  415. /package/dist/node_modules/{signal-exit → gauge/node_modules/signal-exit}/index.js +0 -0
  416. /package/dist/node_modules/{signal-exit → gauge/node_modules/signal-exit}/signals.js +0 -0
  417. /package/dist/node_modules/{tar/node_modules/minipass → minipass}/index.mjs +0 -0
  418. /package/dist/node_modules/{fs-minipass → tar/node_modules/fs-minipass}/index.js +0 -0
@@ -0,0 +1,1395 @@
1
+ "use strict";
2
+ /**
3
+ * @module LRUCache
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LRUCache = void 0;
7
+ const perf = typeof performance === 'object' &&
8
+ performance &&
9
+ typeof performance.now === 'function'
10
+ ? performance
11
+ : Date;
12
+ const warned = new Set();
13
+ /* c8 ignore start */
14
+ const PROCESS = (typeof process === 'object' && !!process ? process : {});
15
+ /* c8 ignore start */
16
+ const emitWarning = (msg, type, code, fn) => {
17
+ typeof PROCESS.emitWarning === 'function'
18
+ ? PROCESS.emitWarning(msg, type, code, fn)
19
+ : console.error(`[${code}] ${type}: ${msg}`);
20
+ };
21
+ let AC = globalThis.AbortController;
22
+ let AS = globalThis.AbortSignal;
23
+ /* c8 ignore start */
24
+ if (typeof AC === 'undefined') {
25
+ //@ts-ignore
26
+ AS = class AbortSignal {
27
+ onabort;
28
+ _onabort = [];
29
+ reason;
30
+ aborted = false;
31
+ addEventListener(_, fn) {
32
+ this._onabort.push(fn);
33
+ }
34
+ };
35
+ //@ts-ignore
36
+ AC = class AbortController {
37
+ constructor() {
38
+ warnACPolyfill();
39
+ }
40
+ signal = new AS();
41
+ abort(reason) {
42
+ if (this.signal.aborted)
43
+ return;
44
+ //@ts-ignore
45
+ this.signal.reason = reason;
46
+ //@ts-ignore
47
+ this.signal.aborted = true;
48
+ //@ts-ignore
49
+ for (const fn of this.signal._onabort) {
50
+ fn(reason);
51
+ }
52
+ this.signal.onabort?.(reason);
53
+ }
54
+ };
55
+ let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
56
+ const warnACPolyfill = () => {
57
+ if (!printACPolyfillWarning)
58
+ return;
59
+ printACPolyfillWarning = false;
60
+ emitWarning('AbortController is not defined. If using lru-cache in ' +
61
+ 'node 14, load an AbortController polyfill from the ' +
62
+ '`node-abort-controller` package. A minimal polyfill is ' +
63
+ 'provided for use by LRUCache.fetch(), but it should not be ' +
64
+ 'relied upon in other contexts (eg, passing it to other APIs that ' +
65
+ 'use AbortController/AbortSignal might have undesirable effects). ' +
66
+ 'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
67
+ };
68
+ }
69
+ /* c8 ignore stop */
70
+ const shouldWarn = (code) => !warned.has(code);
71
+ const TYPE = Symbol('type');
72
+ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
73
+ /* c8 ignore start */
74
+ // This is a little bit ridiculous, tbh.
75
+ // The maximum array length is 2^32-1 or thereabouts on most JS impls.
76
+ // And well before that point, you're caching the entire world, I mean,
77
+ // that's ~32GB of just integers for the next/prev links, plus whatever
78
+ // else to hold that many keys and values. Just filling the memory with
79
+ // zeroes at init time is brutal when you get that big.
80
+ // But why not be complete?
81
+ // Maybe in the future, these limits will have expanded.
82
+ const getUintArray = (max) => !isPosInt(max)
83
+ ? null
84
+ : max <= Math.pow(2, 8)
85
+ ? Uint8Array
86
+ : max <= Math.pow(2, 16)
87
+ ? Uint16Array
88
+ : max <= Math.pow(2, 32)
89
+ ? Uint32Array
90
+ : max <= Number.MAX_SAFE_INTEGER
91
+ ? ZeroArray
92
+ : null;
93
+ /* c8 ignore stop */
94
+ class ZeroArray extends Array {
95
+ constructor(size) {
96
+ super(size);
97
+ this.fill(0);
98
+ }
99
+ }
100
+ class Stack {
101
+ heap;
102
+ length;
103
+ // private constructor
104
+ static #constructing = false;
105
+ static create(max) {
106
+ const HeapCls = getUintArray(max);
107
+ if (!HeapCls)
108
+ return [];
109
+ Stack.#constructing = true;
110
+ const s = new Stack(max, HeapCls);
111
+ Stack.#constructing = false;
112
+ return s;
113
+ }
114
+ constructor(max, HeapCls) {
115
+ /* c8 ignore start */
116
+ if (!Stack.#constructing) {
117
+ throw new TypeError('instantiate Stack using Stack.create(n)');
118
+ }
119
+ /* c8 ignore stop */
120
+ this.heap = new HeapCls(max);
121
+ this.length = 0;
122
+ }
123
+ push(n) {
124
+ this.heap[this.length++] = n;
125
+ }
126
+ pop() {
127
+ return this.heap[--this.length];
128
+ }
129
+ }
130
+ /**
131
+ * Default export, the thing you're using this module to get.
132
+ *
133
+ * All properties from the options object (with the exception of
134
+ * {@link OptionsBase.max} and {@link OptionsBase.maxSize}) are added as
135
+ * normal public members. (`max` and `maxBase` are read-only getters.)
136
+ * Changing any of these will alter the defaults for subsequent method calls,
137
+ * but is otherwise safe.
138
+ */
139
+ class LRUCache {
140
+ // properties coming in from the options of these, only max and maxSize
141
+ // really *need* to be protected. The rest can be modified, as they just
142
+ // set defaults for various methods.
143
+ #max;
144
+ #maxSize;
145
+ #dispose;
146
+ #disposeAfter;
147
+ #fetchMethod;
148
+ /**
149
+ * {@link LRUCache.OptionsBase.ttl}
150
+ */
151
+ ttl;
152
+ /**
153
+ * {@link LRUCache.OptionsBase.ttlResolution}
154
+ */
155
+ ttlResolution;
156
+ /**
157
+ * {@link LRUCache.OptionsBase.ttlAutopurge}
158
+ */
159
+ ttlAutopurge;
160
+ /**
161
+ * {@link LRUCache.OptionsBase.updateAgeOnGet}
162
+ */
163
+ updateAgeOnGet;
164
+ /**
165
+ * {@link LRUCache.OptionsBase.updateAgeOnHas}
166
+ */
167
+ updateAgeOnHas;
168
+ /**
169
+ * {@link LRUCache.OptionsBase.allowStale}
170
+ */
171
+ allowStale;
172
+ /**
173
+ * {@link LRUCache.OptionsBase.noDisposeOnSet}
174
+ */
175
+ noDisposeOnSet;
176
+ /**
177
+ * {@link LRUCache.OptionsBase.noUpdateTTL}
178
+ */
179
+ noUpdateTTL;
180
+ /**
181
+ * {@link LRUCache.OptionsBase.maxEntrySize}
182
+ */
183
+ maxEntrySize;
184
+ /**
185
+ * {@link LRUCache.OptionsBase.sizeCalculation}
186
+ */
187
+ sizeCalculation;
188
+ /**
189
+ * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
190
+ */
191
+ noDeleteOnFetchRejection;
192
+ /**
193
+ * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
194
+ */
195
+ noDeleteOnStaleGet;
196
+ /**
197
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
198
+ */
199
+ allowStaleOnFetchAbort;
200
+ /**
201
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
202
+ */
203
+ allowStaleOnFetchRejection;
204
+ /**
205
+ * {@link LRUCache.OptionsBase.ignoreFetchAbort}
206
+ */
207
+ ignoreFetchAbort;
208
+ // computed properties
209
+ #size;
210
+ #calculatedSize;
211
+ #keyMap;
212
+ #keyList;
213
+ #valList;
214
+ #next;
215
+ #prev;
216
+ #head;
217
+ #tail;
218
+ #free;
219
+ #disposed;
220
+ #sizes;
221
+ #starts;
222
+ #ttls;
223
+ #hasDispose;
224
+ #hasFetchMethod;
225
+ #hasDisposeAfter;
226
+ /**
227
+ * Do not call this method unless you need to inspect the
228
+ * inner workings of the cache. If anything returned by this
229
+ * object is modified in any way, strange breakage may occur.
230
+ *
231
+ * These fields are private for a reason!
232
+ *
233
+ * @internal
234
+ */
235
+ static unsafeExposeInternals(c) {
236
+ return {
237
+ // properties
238
+ starts: c.#starts,
239
+ ttls: c.#ttls,
240
+ sizes: c.#sizes,
241
+ keyMap: c.#keyMap,
242
+ keyList: c.#keyList,
243
+ valList: c.#valList,
244
+ next: c.#next,
245
+ prev: c.#prev,
246
+ get head() {
247
+ return c.#head;
248
+ },
249
+ get tail() {
250
+ return c.#tail;
251
+ },
252
+ free: c.#free,
253
+ // methods
254
+ isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
255
+ backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
256
+ moveToTail: (index) => c.#moveToTail(index),
257
+ indexes: (options) => c.#indexes(options),
258
+ rindexes: (options) => c.#rindexes(options),
259
+ isStale: (index) => c.#isStale(index),
260
+ };
261
+ }
262
+ // Protected read-only members
263
+ /**
264
+ * {@link LRUCache.OptionsBase.max} (read-only)
265
+ */
266
+ get max() {
267
+ return this.#max;
268
+ }
269
+ /**
270
+ * {@link LRUCache.OptionsBase.maxSize} (read-only)
271
+ */
272
+ get maxSize() {
273
+ return this.#maxSize;
274
+ }
275
+ /**
276
+ * The total computed size of items in the cache (read-only)
277
+ */
278
+ get calculatedSize() {
279
+ return this.#calculatedSize;
280
+ }
281
+ /**
282
+ * The number of items stored in the cache (read-only)
283
+ */
284
+ get size() {
285
+ return this.#size;
286
+ }
287
+ /**
288
+ * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
289
+ */
290
+ get fetchMethod() {
291
+ return this.#fetchMethod;
292
+ }
293
+ /**
294
+ * {@link LRUCache.OptionsBase.dispose} (read-only)
295
+ */
296
+ get dispose() {
297
+ return this.#dispose;
298
+ }
299
+ /**
300
+ * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
301
+ */
302
+ get disposeAfter() {
303
+ return this.#disposeAfter;
304
+ }
305
+ constructor(options) {
306
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
307
+ if (max !== 0 && !isPosInt(max)) {
308
+ throw new TypeError('max option must be a nonnegative integer');
309
+ }
310
+ const UintArray = max ? getUintArray(max) : Array;
311
+ if (!UintArray) {
312
+ throw new Error('invalid max value: ' + max);
313
+ }
314
+ this.#max = max;
315
+ this.#maxSize = maxSize;
316
+ this.maxEntrySize = maxEntrySize || this.#maxSize;
317
+ this.sizeCalculation = sizeCalculation;
318
+ if (this.sizeCalculation) {
319
+ if (!this.#maxSize && !this.maxEntrySize) {
320
+ throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
321
+ }
322
+ if (typeof this.sizeCalculation !== 'function') {
323
+ throw new TypeError('sizeCalculation set to non-function');
324
+ }
325
+ }
326
+ if (fetchMethod !== undefined &&
327
+ typeof fetchMethod !== 'function') {
328
+ throw new TypeError('fetchMethod must be a function if specified');
329
+ }
330
+ this.#fetchMethod = fetchMethod;
331
+ this.#hasFetchMethod = !!fetchMethod;
332
+ this.#keyMap = new Map();
333
+ this.#keyList = new Array(max).fill(undefined);
334
+ this.#valList = new Array(max).fill(undefined);
335
+ this.#next = new UintArray(max);
336
+ this.#prev = new UintArray(max);
337
+ this.#head = 0;
338
+ this.#tail = 0;
339
+ this.#free = Stack.create(max);
340
+ this.#size = 0;
341
+ this.#calculatedSize = 0;
342
+ if (typeof dispose === 'function') {
343
+ this.#dispose = dispose;
344
+ }
345
+ if (typeof disposeAfter === 'function') {
346
+ this.#disposeAfter = disposeAfter;
347
+ this.#disposed = [];
348
+ }
349
+ else {
350
+ this.#disposeAfter = undefined;
351
+ this.#disposed = undefined;
352
+ }
353
+ this.#hasDispose = !!this.#dispose;
354
+ this.#hasDisposeAfter = !!this.#disposeAfter;
355
+ this.noDisposeOnSet = !!noDisposeOnSet;
356
+ this.noUpdateTTL = !!noUpdateTTL;
357
+ this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
358
+ this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
359
+ this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
360
+ this.ignoreFetchAbort = !!ignoreFetchAbort;
361
+ // NB: maxEntrySize is set to maxSize if it's set
362
+ if (this.maxEntrySize !== 0) {
363
+ if (this.#maxSize !== 0) {
364
+ if (!isPosInt(this.#maxSize)) {
365
+ throw new TypeError('maxSize must be a positive integer if specified');
366
+ }
367
+ }
368
+ if (!isPosInt(this.maxEntrySize)) {
369
+ throw new TypeError('maxEntrySize must be a positive integer if specified');
370
+ }
371
+ this.#initializeSizeTracking();
372
+ }
373
+ this.allowStale = !!allowStale;
374
+ this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
375
+ this.updateAgeOnGet = !!updateAgeOnGet;
376
+ this.updateAgeOnHas = !!updateAgeOnHas;
377
+ this.ttlResolution =
378
+ isPosInt(ttlResolution) || ttlResolution === 0
379
+ ? ttlResolution
380
+ : 1;
381
+ this.ttlAutopurge = !!ttlAutopurge;
382
+ this.ttl = ttl || 0;
383
+ if (this.ttl) {
384
+ if (!isPosInt(this.ttl)) {
385
+ throw new TypeError('ttl must be a positive integer if specified');
386
+ }
387
+ this.#initializeTTLTracking();
388
+ }
389
+ // do not allow completely unbounded caches
390
+ if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
391
+ throw new TypeError('At least one of max, maxSize, or ttl is required');
392
+ }
393
+ if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
394
+ const code = 'LRU_CACHE_UNBOUNDED';
395
+ if (shouldWarn(code)) {
396
+ warned.add(code);
397
+ const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' +
398
+ 'result in unbounded memory consumption.';
399
+ emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
400
+ }
401
+ }
402
+ }
403
+ /**
404
+ * Return the remaining TTL time for a given entry key
405
+ */
406
+ getRemainingTTL(key) {
407
+ return this.#keyMap.has(key) ? Infinity : 0;
408
+ }
409
+ #initializeTTLTracking() {
410
+ const ttls = new ZeroArray(this.#max);
411
+ const starts = new ZeroArray(this.#max);
412
+ this.#ttls = ttls;
413
+ this.#starts = starts;
414
+ this.#setItemTTL = (index, ttl, start = perf.now()) => {
415
+ starts[index] = ttl !== 0 ? start : 0;
416
+ ttls[index] = ttl;
417
+ if (ttl !== 0 && this.ttlAutopurge) {
418
+ const t = setTimeout(() => {
419
+ if (this.#isStale(index)) {
420
+ this.delete(this.#keyList[index]);
421
+ }
422
+ }, ttl + 1);
423
+ // unref() not supported on all platforms
424
+ /* c8 ignore start */
425
+ if (t.unref) {
426
+ t.unref();
427
+ }
428
+ /* c8 ignore stop */
429
+ }
430
+ };
431
+ this.#updateItemAge = index => {
432
+ starts[index] = ttls[index] !== 0 ? perf.now() : 0;
433
+ };
434
+ this.#statusTTL = (status, index) => {
435
+ if (ttls[index]) {
436
+ const ttl = ttls[index];
437
+ const start = starts[index];
438
+ status.ttl = ttl;
439
+ status.start = start;
440
+ status.now = cachedNow || getNow();
441
+ const age = status.now - start;
442
+ status.remainingTTL = ttl - age;
443
+ }
444
+ };
445
+ // debounce calls to perf.now() to 1s so we're not hitting
446
+ // that costly call repeatedly.
447
+ let cachedNow = 0;
448
+ const getNow = () => {
449
+ const n = perf.now();
450
+ if (this.ttlResolution > 0) {
451
+ cachedNow = n;
452
+ const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
453
+ // not available on all platforms
454
+ /* c8 ignore start */
455
+ if (t.unref) {
456
+ t.unref();
457
+ }
458
+ /* c8 ignore stop */
459
+ }
460
+ return n;
461
+ };
462
+ this.getRemainingTTL = key => {
463
+ const index = this.#keyMap.get(key);
464
+ if (index === undefined) {
465
+ return 0;
466
+ }
467
+ const ttl = ttls[index];
468
+ const start = starts[index];
469
+ if (ttl === 0 || start === 0) {
470
+ return Infinity;
471
+ }
472
+ const age = (cachedNow || getNow()) - start;
473
+ return ttl - age;
474
+ };
475
+ this.#isStale = index => {
476
+ return (ttls[index] !== 0 &&
477
+ starts[index] !== 0 &&
478
+ (cachedNow || getNow()) - starts[index] > ttls[index]);
479
+ };
480
+ }
481
+ // conditionally set private methods related to TTL
482
+ #updateItemAge = () => { };
483
+ #statusTTL = () => { };
484
+ #setItemTTL = () => { };
485
+ /* c8 ignore stop */
486
+ #isStale = () => false;
487
+ #initializeSizeTracking() {
488
+ const sizes = new ZeroArray(this.#max);
489
+ this.#calculatedSize = 0;
490
+ this.#sizes = sizes;
491
+ this.#removeItemSize = index => {
492
+ this.#calculatedSize -= sizes[index];
493
+ sizes[index] = 0;
494
+ };
495
+ this.#requireSize = (k, v, size, sizeCalculation) => {
496
+ // provisionally accept background fetches.
497
+ // actual value size will be checked when they return.
498
+ if (this.#isBackgroundFetch(v)) {
499
+ return 0;
500
+ }
501
+ if (!isPosInt(size)) {
502
+ if (sizeCalculation) {
503
+ if (typeof sizeCalculation !== 'function') {
504
+ throw new TypeError('sizeCalculation must be a function');
505
+ }
506
+ size = sizeCalculation(v, k);
507
+ if (!isPosInt(size)) {
508
+ throw new TypeError('sizeCalculation return invalid (expect positive integer)');
509
+ }
510
+ }
511
+ else {
512
+ throw new TypeError('invalid size value (must be positive integer). ' +
513
+ 'When maxSize or maxEntrySize is used, sizeCalculation ' +
514
+ 'or size must be set.');
515
+ }
516
+ }
517
+ return size;
518
+ };
519
+ this.#addItemSize = (index, size, status) => {
520
+ sizes[index] = size;
521
+ if (this.#maxSize) {
522
+ const maxSize = this.#maxSize - sizes[index];
523
+ while (this.#calculatedSize > maxSize) {
524
+ this.#evict(true);
525
+ }
526
+ }
527
+ this.#calculatedSize += sizes[index];
528
+ if (status) {
529
+ status.entrySize = size;
530
+ status.totalCalculatedSize = this.#calculatedSize;
531
+ }
532
+ };
533
+ }
534
+ #removeItemSize = _i => { };
535
+ #addItemSize = (_i, _s, _st) => { };
536
+ #requireSize = (_k, _v, size, sizeCalculation) => {
537
+ if (size || sizeCalculation) {
538
+ throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
539
+ }
540
+ return 0;
541
+ };
542
+ *#indexes({ allowStale = this.allowStale } = {}) {
543
+ if (this.#size) {
544
+ for (let i = this.#tail; true;) {
545
+ if (!this.#isValidIndex(i)) {
546
+ break;
547
+ }
548
+ if (allowStale || !this.#isStale(i)) {
549
+ yield i;
550
+ }
551
+ if (i === this.#head) {
552
+ break;
553
+ }
554
+ else {
555
+ i = this.#prev[i];
556
+ }
557
+ }
558
+ }
559
+ }
560
+ *#rindexes({ allowStale = this.allowStale } = {}) {
561
+ if (this.#size) {
562
+ for (let i = this.#head; true;) {
563
+ if (!this.#isValidIndex(i)) {
564
+ break;
565
+ }
566
+ if (allowStale || !this.#isStale(i)) {
567
+ yield i;
568
+ }
569
+ if (i === this.#tail) {
570
+ break;
571
+ }
572
+ else {
573
+ i = this.#next[i];
574
+ }
575
+ }
576
+ }
577
+ }
578
+ #isValidIndex(index) {
579
+ return (index !== undefined &&
580
+ this.#keyMap.get(this.#keyList[index]) === index);
581
+ }
582
+ /**
583
+ * Return a generator yielding `[key, value]` pairs,
584
+ * in order from most recently used to least recently used.
585
+ */
586
+ *entries() {
587
+ for (const i of this.#indexes()) {
588
+ if (this.#valList[i] !== undefined &&
589
+ this.#keyList[i] !== undefined &&
590
+ !this.#isBackgroundFetch(this.#valList[i])) {
591
+ yield [this.#keyList[i], this.#valList[i]];
592
+ }
593
+ }
594
+ }
595
+ /**
596
+ * Inverse order version of {@link LRUCache.entries}
597
+ *
598
+ * Return a generator yielding `[key, value]` pairs,
599
+ * in order from least recently used to most recently used.
600
+ */
601
+ *rentries() {
602
+ for (const i of this.#rindexes()) {
603
+ if (this.#valList[i] !== undefined &&
604
+ this.#keyList[i] !== undefined &&
605
+ !this.#isBackgroundFetch(this.#valList[i])) {
606
+ yield [this.#keyList[i], this.#valList[i]];
607
+ }
608
+ }
609
+ }
610
+ /**
611
+ * Return a generator yielding the keys in the cache,
612
+ * in order from most recently used to least recently used.
613
+ */
614
+ *keys() {
615
+ for (const i of this.#indexes()) {
616
+ const k = this.#keyList[i];
617
+ if (k !== undefined &&
618
+ !this.#isBackgroundFetch(this.#valList[i])) {
619
+ yield k;
620
+ }
621
+ }
622
+ }
623
+ /**
624
+ * Inverse order version of {@link LRUCache.keys}
625
+ *
626
+ * Return a generator yielding the keys in the cache,
627
+ * in order from least recently used to most recently used.
628
+ */
629
+ *rkeys() {
630
+ for (const i of this.#rindexes()) {
631
+ const k = this.#keyList[i];
632
+ if (k !== undefined &&
633
+ !this.#isBackgroundFetch(this.#valList[i])) {
634
+ yield k;
635
+ }
636
+ }
637
+ }
638
+ /**
639
+ * Return a generator yielding the values in the cache,
640
+ * in order from most recently used to least recently used.
641
+ */
642
+ *values() {
643
+ for (const i of this.#indexes()) {
644
+ const v = this.#valList[i];
645
+ if (v !== undefined &&
646
+ !this.#isBackgroundFetch(this.#valList[i])) {
647
+ yield this.#valList[i];
648
+ }
649
+ }
650
+ }
651
+ /**
652
+ * Inverse order version of {@link LRUCache.values}
653
+ *
654
+ * Return a generator yielding the values in the cache,
655
+ * in order from least recently used to most recently used.
656
+ */
657
+ *rvalues() {
658
+ for (const i of this.#rindexes()) {
659
+ const v = this.#valList[i];
660
+ if (v !== undefined &&
661
+ !this.#isBackgroundFetch(this.#valList[i])) {
662
+ yield this.#valList[i];
663
+ }
664
+ }
665
+ }
666
+ /**
667
+ * Iterating over the cache itself yields the same results as
668
+ * {@link LRUCache.entries}
669
+ */
670
+ [Symbol.iterator]() {
671
+ return this.entries();
672
+ }
673
+ /**
674
+ * Find a value for which the supplied fn method returns a truthy value,
675
+ * similar to Array.find(). fn is called as fn(value, key, cache).
676
+ */
677
+ find(fn, getOptions = {}) {
678
+ for (const i of this.#indexes()) {
679
+ const v = this.#valList[i];
680
+ const value = this.#isBackgroundFetch(v)
681
+ ? v.__staleWhileFetching
682
+ : v;
683
+ if (value === undefined)
684
+ continue;
685
+ if (fn(value, this.#keyList[i], this)) {
686
+ return this.get(this.#keyList[i], getOptions);
687
+ }
688
+ }
689
+ }
690
+ /**
691
+ * Call the supplied function on each item in the cache, in order from
692
+ * most recently used to least recently used. fn is called as
693
+ * fn(value, key, cache). Does not update age or recenty of use.
694
+ * Does not iterate over stale values.
695
+ */
696
+ forEach(fn, thisp = this) {
697
+ for (const i of this.#indexes()) {
698
+ const v = this.#valList[i];
699
+ const value = this.#isBackgroundFetch(v)
700
+ ? v.__staleWhileFetching
701
+ : v;
702
+ if (value === undefined)
703
+ continue;
704
+ fn.call(thisp, value, this.#keyList[i], this);
705
+ }
706
+ }
707
+ /**
708
+ * The same as {@link LRUCache.forEach} but items are iterated over in
709
+ * reverse order. (ie, less recently used items are iterated over first.)
710
+ */
711
+ rforEach(fn, thisp = this) {
712
+ for (const i of this.#rindexes()) {
713
+ const v = this.#valList[i];
714
+ const value = this.#isBackgroundFetch(v)
715
+ ? v.__staleWhileFetching
716
+ : v;
717
+ if (value === undefined)
718
+ continue;
719
+ fn.call(thisp, value, this.#keyList[i], this);
720
+ }
721
+ }
722
+ /**
723
+ * Delete any stale entries. Returns true if anything was removed,
724
+ * false otherwise.
725
+ */
726
+ purgeStale() {
727
+ let deleted = false;
728
+ for (const i of this.#rindexes({ allowStale: true })) {
729
+ if (this.#isStale(i)) {
730
+ this.delete(this.#keyList[i]);
731
+ deleted = true;
732
+ }
733
+ }
734
+ return deleted;
735
+ }
736
+ /**
737
+ * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
738
+ * passed to cache.load()
739
+ */
740
+ dump() {
741
+ const arr = [];
742
+ for (const i of this.#indexes({ allowStale: true })) {
743
+ const key = this.#keyList[i];
744
+ const v = this.#valList[i];
745
+ const value = this.#isBackgroundFetch(v)
746
+ ? v.__staleWhileFetching
747
+ : v;
748
+ if (value === undefined || key === undefined)
749
+ continue;
750
+ const entry = { value };
751
+ if (this.#ttls && this.#starts) {
752
+ entry.ttl = this.#ttls[i];
753
+ // always dump the start relative to a portable timestamp
754
+ // it's ok for this to be a bit slow, it's a rare operation.
755
+ const age = perf.now() - this.#starts[i];
756
+ entry.start = Math.floor(Date.now() - age);
757
+ }
758
+ if (this.#sizes) {
759
+ entry.size = this.#sizes[i];
760
+ }
761
+ arr.unshift([key, entry]);
762
+ }
763
+ return arr;
764
+ }
765
+ /**
766
+ * Reset the cache and load in the items in entries in the order listed.
767
+ * Note that the shape of the resulting cache may be different if the
768
+ * same options are not used in both caches.
769
+ */
770
+ load(arr) {
771
+ this.clear();
772
+ for (const [key, entry] of arr) {
773
+ if (entry.start) {
774
+ // entry.start is a portable timestamp, but we may be using
775
+ // node's performance.now(), so calculate the offset, so that
776
+ // we get the intended remaining TTL, no matter how long it's
777
+ // been on ice.
778
+ //
779
+ // it's ok for this to be a bit slow, it's a rare operation.
780
+ const age = Date.now() - entry.start;
781
+ entry.start = perf.now() - age;
782
+ }
783
+ this.set(key, entry.value, entry);
784
+ }
785
+ }
786
+ /**
787
+ * Add a value to the cache.
788
+ *
789
+ * Note: if `undefined` is specified as a value, this is an alias for
790
+ * {@link LRUCache#delete}
791
+ */
792
+ set(k, v, setOptions = {}) {
793
+ if (v === undefined) {
794
+ this.delete(k);
795
+ return this;
796
+ }
797
+ const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
798
+ let { noUpdateTTL = this.noUpdateTTL } = setOptions;
799
+ const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
800
+ // if the item doesn't fit, don't do anything
801
+ // NB: maxEntrySize set to maxSize by default
802
+ if (this.maxEntrySize && size > this.maxEntrySize) {
803
+ if (status) {
804
+ status.set = 'miss';
805
+ status.maxEntrySizeExceeded = true;
806
+ }
807
+ // have to delete, in case something is there already.
808
+ this.delete(k);
809
+ return this;
810
+ }
811
+ let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
812
+ if (index === undefined) {
813
+ // addition
814
+ index = (this.#size === 0
815
+ ? this.#tail
816
+ : this.#free.length !== 0
817
+ ? this.#free.pop()
818
+ : this.#size === this.#max
819
+ ? this.#evict(false)
820
+ : this.#size);
821
+ this.#keyList[index] = k;
822
+ this.#valList[index] = v;
823
+ this.#keyMap.set(k, index);
824
+ this.#next[this.#tail] = index;
825
+ this.#prev[index] = this.#tail;
826
+ this.#tail = index;
827
+ this.#size++;
828
+ this.#addItemSize(index, size, status);
829
+ if (status)
830
+ status.set = 'add';
831
+ noUpdateTTL = false;
832
+ }
833
+ else {
834
+ // update
835
+ this.#moveToTail(index);
836
+ const oldVal = this.#valList[index];
837
+ if (v !== oldVal) {
838
+ if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
839
+ oldVal.__abortController.abort(new Error('replaced'));
840
+ }
841
+ else if (!noDisposeOnSet) {
842
+ if (this.#hasDispose) {
843
+ this.#dispose?.(oldVal, k, 'set');
844
+ }
845
+ if (this.#hasDisposeAfter) {
846
+ this.#disposed?.push([oldVal, k, 'set']);
847
+ }
848
+ }
849
+ this.#removeItemSize(index);
850
+ this.#addItemSize(index, size, status);
851
+ this.#valList[index] = v;
852
+ if (status) {
853
+ status.set = 'replace';
854
+ const oldValue = oldVal && this.#isBackgroundFetch(oldVal)
855
+ ? oldVal.__staleWhileFetching
856
+ : oldVal;
857
+ if (oldValue !== undefined)
858
+ status.oldValue = oldValue;
859
+ }
860
+ }
861
+ else if (status) {
862
+ status.set = 'update';
863
+ }
864
+ }
865
+ if (ttl !== 0 && !this.#ttls) {
866
+ this.#initializeTTLTracking();
867
+ }
868
+ if (this.#ttls) {
869
+ if (!noUpdateTTL) {
870
+ this.#setItemTTL(index, ttl, start);
871
+ }
872
+ if (status)
873
+ this.#statusTTL(status, index);
874
+ }
875
+ if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
876
+ const dt = this.#disposed;
877
+ let task;
878
+ while ((task = dt?.shift())) {
879
+ this.#disposeAfter?.(...task);
880
+ }
881
+ }
882
+ return this;
883
+ }
884
+ /**
885
+ * Evict the least recently used item, returning its value or
886
+ * `undefined` if cache is empty.
887
+ */
888
+ pop() {
889
+ try {
890
+ while (this.#size) {
891
+ const val = this.#valList[this.#head];
892
+ this.#evict(true);
893
+ if (this.#isBackgroundFetch(val)) {
894
+ if (val.__staleWhileFetching) {
895
+ return val.__staleWhileFetching;
896
+ }
897
+ }
898
+ else if (val !== undefined) {
899
+ return val;
900
+ }
901
+ }
902
+ }
903
+ finally {
904
+ if (this.#hasDisposeAfter && this.#disposed) {
905
+ const dt = this.#disposed;
906
+ let task;
907
+ while ((task = dt?.shift())) {
908
+ this.#disposeAfter?.(...task);
909
+ }
910
+ }
911
+ }
912
+ }
913
+ #evict(free) {
914
+ const head = this.#head;
915
+ const k = this.#keyList[head];
916
+ const v = this.#valList[head];
917
+ if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
918
+ v.__abortController.abort(new Error('evicted'));
919
+ }
920
+ else if (this.#hasDispose || this.#hasDisposeAfter) {
921
+ if (this.#hasDispose) {
922
+ this.#dispose?.(v, k, 'evict');
923
+ }
924
+ if (this.#hasDisposeAfter) {
925
+ this.#disposed?.push([v, k, 'evict']);
926
+ }
927
+ }
928
+ this.#removeItemSize(head);
929
+ // if we aren't about to use the index, then null these out
930
+ if (free) {
931
+ this.#keyList[head] = undefined;
932
+ this.#valList[head] = undefined;
933
+ this.#free.push(head);
934
+ }
935
+ if (this.#size === 1) {
936
+ this.#head = this.#tail = 0;
937
+ this.#free.length = 0;
938
+ }
939
+ else {
940
+ this.#head = this.#next[head];
941
+ }
942
+ this.#keyMap.delete(k);
943
+ this.#size--;
944
+ return head;
945
+ }
946
+ /**
947
+ * Check if a key is in the cache, without updating the recency of use.
948
+ * Will return false if the item is stale, even though it is technically
949
+ * in the cache.
950
+ *
951
+ * Will not update item age unless
952
+ * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
953
+ */
954
+ has(k, hasOptions = {}) {
955
+ const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
956
+ const index = this.#keyMap.get(k);
957
+ if (index !== undefined) {
958
+ const v = this.#valList[index];
959
+ if (this.#isBackgroundFetch(v) &&
960
+ v.__staleWhileFetching === undefined) {
961
+ return false;
962
+ }
963
+ if (!this.#isStale(index)) {
964
+ if (updateAgeOnHas) {
965
+ this.#updateItemAge(index);
966
+ }
967
+ if (status) {
968
+ status.has = 'hit';
969
+ this.#statusTTL(status, index);
970
+ }
971
+ return true;
972
+ }
973
+ else if (status) {
974
+ status.has = 'stale';
975
+ this.#statusTTL(status, index);
976
+ }
977
+ }
978
+ else if (status) {
979
+ status.has = 'miss';
980
+ }
981
+ return false;
982
+ }
983
+ /**
984
+ * Like {@link LRUCache#get} but doesn't update recency or delete stale
985
+ * items.
986
+ *
987
+ * Returns `undefined` if the item is stale, unless
988
+ * {@link LRUCache.OptionsBase.allowStale} is set.
989
+ */
990
+ peek(k, peekOptions = {}) {
991
+ const { allowStale = this.allowStale } = peekOptions;
992
+ const index = this.#keyMap.get(k);
993
+ if (index !== undefined &&
994
+ (allowStale || !this.#isStale(index))) {
995
+ const v = this.#valList[index];
996
+ // either stale and allowed, or forcing a refresh of non-stale value
997
+ return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
998
+ }
999
+ }
1000
+ #backgroundFetch(k, index, options, context) {
1001
+ const v = index === undefined ? undefined : this.#valList[index];
1002
+ if (this.#isBackgroundFetch(v)) {
1003
+ return v;
1004
+ }
1005
+ const ac = new AC();
1006
+ const { signal } = options;
1007
+ // when/if our AC signals, then stop listening to theirs.
1008
+ signal?.addEventListener('abort', () => ac.abort(signal.reason), {
1009
+ signal: ac.signal,
1010
+ });
1011
+ const fetchOpts = {
1012
+ signal: ac.signal,
1013
+ options,
1014
+ context,
1015
+ };
1016
+ const cb = (v, updateCache = false) => {
1017
+ const { aborted } = ac.signal;
1018
+ const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
1019
+ if (options.status) {
1020
+ if (aborted && !updateCache) {
1021
+ options.status.fetchAborted = true;
1022
+ options.status.fetchError = ac.signal.reason;
1023
+ if (ignoreAbort)
1024
+ options.status.fetchAbortIgnored = true;
1025
+ }
1026
+ else {
1027
+ options.status.fetchResolved = true;
1028
+ }
1029
+ }
1030
+ if (aborted && !ignoreAbort && !updateCache) {
1031
+ return fetchFail(ac.signal.reason);
1032
+ }
1033
+ // either we didn't abort, and are still here, or we did, and ignored
1034
+ const bf = p;
1035
+ if (this.#valList[index] === p) {
1036
+ if (v === undefined) {
1037
+ if (bf.__staleWhileFetching) {
1038
+ this.#valList[index] = bf.__staleWhileFetching;
1039
+ }
1040
+ else {
1041
+ this.delete(k);
1042
+ }
1043
+ }
1044
+ else {
1045
+ if (options.status)
1046
+ options.status.fetchUpdated = true;
1047
+ this.set(k, v, fetchOpts.options);
1048
+ }
1049
+ }
1050
+ return v;
1051
+ };
1052
+ const eb = (er) => {
1053
+ if (options.status) {
1054
+ options.status.fetchRejected = true;
1055
+ options.status.fetchError = er;
1056
+ }
1057
+ return fetchFail(er);
1058
+ };
1059
+ const fetchFail = (er) => {
1060
+ const { aborted } = ac.signal;
1061
+ const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
1062
+ const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
1063
+ const noDelete = allowStale || options.noDeleteOnFetchRejection;
1064
+ const bf = p;
1065
+ if (this.#valList[index] === p) {
1066
+ // if we allow stale on fetch rejections, then we need to ensure that
1067
+ // the stale value is not removed from the cache when the fetch fails.
1068
+ const del = !noDelete || bf.__staleWhileFetching === undefined;
1069
+ if (del) {
1070
+ this.delete(k);
1071
+ }
1072
+ else if (!allowStaleAborted) {
1073
+ // still replace the *promise* with the stale value,
1074
+ // since we are done with the promise at this point.
1075
+ // leave it untouched if we're still waiting for an
1076
+ // aborted background fetch that hasn't yet returned.
1077
+ this.#valList[index] = bf.__staleWhileFetching;
1078
+ }
1079
+ }
1080
+ if (allowStale) {
1081
+ if (options.status && bf.__staleWhileFetching !== undefined) {
1082
+ options.status.returnedStale = true;
1083
+ }
1084
+ return bf.__staleWhileFetching;
1085
+ }
1086
+ else if (bf.__returned === bf) {
1087
+ throw er;
1088
+ }
1089
+ };
1090
+ const pcall = (res, rej) => {
1091
+ const fmp = this.#fetchMethod?.(k, v, fetchOpts);
1092
+ if (fmp && fmp instanceof Promise) {
1093
+ fmp.then(v => res(v), rej);
1094
+ }
1095
+ // ignored, we go until we finish, regardless.
1096
+ // defer check until we are actually aborting,
1097
+ // so fetchMethod can override.
1098
+ ac.signal.addEventListener('abort', () => {
1099
+ if (!options.ignoreFetchAbort ||
1100
+ options.allowStaleOnFetchAbort) {
1101
+ res();
1102
+ // when it eventually resolves, update the cache.
1103
+ if (options.allowStaleOnFetchAbort) {
1104
+ res = v => cb(v, true);
1105
+ }
1106
+ }
1107
+ });
1108
+ };
1109
+ if (options.status)
1110
+ options.status.fetchDispatched = true;
1111
+ const p = new Promise(pcall).then(cb, eb);
1112
+ const bf = Object.assign(p, {
1113
+ __abortController: ac,
1114
+ __staleWhileFetching: v,
1115
+ __returned: undefined,
1116
+ });
1117
+ if (index === undefined) {
1118
+ // internal, don't expose status.
1119
+ this.set(k, bf, { ...fetchOpts.options, status: undefined });
1120
+ index = this.#keyMap.get(k);
1121
+ }
1122
+ else {
1123
+ this.#valList[index] = bf;
1124
+ }
1125
+ return bf;
1126
+ }
1127
+ #isBackgroundFetch(p) {
1128
+ if (!this.#hasFetchMethod)
1129
+ return false;
1130
+ const b = p;
1131
+ return (!!b &&
1132
+ b instanceof Promise &&
1133
+ b.hasOwnProperty('__staleWhileFetching') &&
1134
+ b.__abortController instanceof AC);
1135
+ }
1136
+ async fetch(k, fetchOptions = {}) {
1137
+ const {
1138
+ // get options
1139
+ allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
1140
+ // set options
1141
+ ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
1142
+ // fetch exclusive options
1143
+ noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
1144
+ if (!this.#hasFetchMethod) {
1145
+ if (status)
1146
+ status.fetch = 'get';
1147
+ return this.get(k, {
1148
+ allowStale,
1149
+ updateAgeOnGet,
1150
+ noDeleteOnStaleGet,
1151
+ status,
1152
+ });
1153
+ }
1154
+ const options = {
1155
+ allowStale,
1156
+ updateAgeOnGet,
1157
+ noDeleteOnStaleGet,
1158
+ ttl,
1159
+ noDisposeOnSet,
1160
+ size,
1161
+ sizeCalculation,
1162
+ noUpdateTTL,
1163
+ noDeleteOnFetchRejection,
1164
+ allowStaleOnFetchRejection,
1165
+ allowStaleOnFetchAbort,
1166
+ ignoreFetchAbort,
1167
+ status,
1168
+ signal,
1169
+ };
1170
+ let index = this.#keyMap.get(k);
1171
+ if (index === undefined) {
1172
+ if (status)
1173
+ status.fetch = 'miss';
1174
+ const p = this.#backgroundFetch(k, index, options, context);
1175
+ return (p.__returned = p);
1176
+ }
1177
+ else {
1178
+ // in cache, maybe already fetching
1179
+ const v = this.#valList[index];
1180
+ if (this.#isBackgroundFetch(v)) {
1181
+ const stale = allowStale && v.__staleWhileFetching !== undefined;
1182
+ if (status) {
1183
+ status.fetch = 'inflight';
1184
+ if (stale)
1185
+ status.returnedStale = true;
1186
+ }
1187
+ return stale ? v.__staleWhileFetching : (v.__returned = v);
1188
+ }
1189
+ // if we force a refresh, that means do NOT serve the cached value,
1190
+ // unless we are already in the process of refreshing the cache.
1191
+ const isStale = this.#isStale(index);
1192
+ if (!forceRefresh && !isStale) {
1193
+ if (status)
1194
+ status.fetch = 'hit';
1195
+ this.#moveToTail(index);
1196
+ if (updateAgeOnGet) {
1197
+ this.#updateItemAge(index);
1198
+ }
1199
+ if (status)
1200
+ this.#statusTTL(status, index);
1201
+ return v;
1202
+ }
1203
+ // ok, it is stale or a forced refresh, and not already fetching.
1204
+ // refresh the cache.
1205
+ const p = this.#backgroundFetch(k, index, options, context);
1206
+ const hasStale = p.__staleWhileFetching !== undefined;
1207
+ const staleVal = hasStale && allowStale;
1208
+ if (status) {
1209
+ status.fetch = isStale ? 'stale' : 'refresh';
1210
+ if (staleVal && isStale)
1211
+ status.returnedStale = true;
1212
+ }
1213
+ return staleVal ? p.__staleWhileFetching : (p.__returned = p);
1214
+ }
1215
+ }
1216
+ /**
1217
+ * Return a value from the cache. Will update the recency of the cache
1218
+ * entry found.
1219
+ *
1220
+ * If the key is not found, get() will return `undefined`.
1221
+ */
1222
+ get(k, getOptions = {}) {
1223
+ const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
1224
+ const index = this.#keyMap.get(k);
1225
+ if (index !== undefined) {
1226
+ const value = this.#valList[index];
1227
+ const fetching = this.#isBackgroundFetch(value);
1228
+ if (status)
1229
+ this.#statusTTL(status, index);
1230
+ if (this.#isStale(index)) {
1231
+ if (status)
1232
+ status.get = 'stale';
1233
+ // delete only if not an in-flight background fetch
1234
+ if (!fetching) {
1235
+ if (!noDeleteOnStaleGet) {
1236
+ this.delete(k);
1237
+ }
1238
+ if (status && allowStale)
1239
+ status.returnedStale = true;
1240
+ return allowStale ? value : undefined;
1241
+ }
1242
+ else {
1243
+ if (status &&
1244
+ allowStale &&
1245
+ value.__staleWhileFetching !== undefined) {
1246
+ status.returnedStale = true;
1247
+ }
1248
+ return allowStale ? value.__staleWhileFetching : undefined;
1249
+ }
1250
+ }
1251
+ else {
1252
+ if (status)
1253
+ status.get = 'hit';
1254
+ // if we're currently fetching it, we don't actually have it yet
1255
+ // it's not stale, which means this isn't a staleWhileRefetching.
1256
+ // If it's not stale, and fetching, AND has a __staleWhileFetching
1257
+ // value, then that means the user fetched with {forceRefresh:true},
1258
+ // so it's safe to return that value.
1259
+ if (fetching) {
1260
+ return value.__staleWhileFetching;
1261
+ }
1262
+ this.#moveToTail(index);
1263
+ if (updateAgeOnGet) {
1264
+ this.#updateItemAge(index);
1265
+ }
1266
+ return value;
1267
+ }
1268
+ }
1269
+ else if (status) {
1270
+ status.get = 'miss';
1271
+ }
1272
+ }
1273
+ #connect(p, n) {
1274
+ this.#prev[n] = p;
1275
+ this.#next[p] = n;
1276
+ }
1277
+ #moveToTail(index) {
1278
+ // if tail already, nothing to do
1279
+ // if head, move head to next[index]
1280
+ // else
1281
+ // move next[prev[index]] to next[index] (head has no prev)
1282
+ // move prev[next[index]] to prev[index]
1283
+ // prev[index] = tail
1284
+ // next[tail] = index
1285
+ // tail = index
1286
+ if (index !== this.#tail) {
1287
+ if (index === this.#head) {
1288
+ this.#head = this.#next[index];
1289
+ }
1290
+ else {
1291
+ this.#connect(this.#prev[index], this.#next[index]);
1292
+ }
1293
+ this.#connect(this.#tail, index);
1294
+ this.#tail = index;
1295
+ }
1296
+ }
1297
+ /**
1298
+ * Deletes a key out of the cache.
1299
+ * Returns true if the key was deleted, false otherwise.
1300
+ */
1301
+ delete(k) {
1302
+ let deleted = false;
1303
+ if (this.#size !== 0) {
1304
+ const index = this.#keyMap.get(k);
1305
+ if (index !== undefined) {
1306
+ deleted = true;
1307
+ if (this.#size === 1) {
1308
+ this.clear();
1309
+ }
1310
+ else {
1311
+ this.#removeItemSize(index);
1312
+ const v = this.#valList[index];
1313
+ if (this.#isBackgroundFetch(v)) {
1314
+ v.__abortController.abort(new Error('deleted'));
1315
+ }
1316
+ else if (this.#hasDispose || this.#hasDisposeAfter) {
1317
+ if (this.#hasDispose) {
1318
+ this.#dispose?.(v, k, 'delete');
1319
+ }
1320
+ if (this.#hasDisposeAfter) {
1321
+ this.#disposed?.push([v, k, 'delete']);
1322
+ }
1323
+ }
1324
+ this.#keyMap.delete(k);
1325
+ this.#keyList[index] = undefined;
1326
+ this.#valList[index] = undefined;
1327
+ if (index === this.#tail) {
1328
+ this.#tail = this.#prev[index];
1329
+ }
1330
+ else if (index === this.#head) {
1331
+ this.#head = this.#next[index];
1332
+ }
1333
+ else {
1334
+ this.#next[this.#prev[index]] = this.#next[index];
1335
+ this.#prev[this.#next[index]] = this.#prev[index];
1336
+ }
1337
+ this.#size--;
1338
+ this.#free.push(index);
1339
+ }
1340
+ }
1341
+ }
1342
+ if (this.#hasDisposeAfter && this.#disposed?.length) {
1343
+ const dt = this.#disposed;
1344
+ let task;
1345
+ while ((task = dt?.shift())) {
1346
+ this.#disposeAfter?.(...task);
1347
+ }
1348
+ }
1349
+ return deleted;
1350
+ }
1351
+ /**
1352
+ * Clear the cache entirely, throwing away all values.
1353
+ */
1354
+ clear() {
1355
+ for (const index of this.#rindexes({ allowStale: true })) {
1356
+ const v = this.#valList[index];
1357
+ if (this.#isBackgroundFetch(v)) {
1358
+ v.__abortController.abort(new Error('deleted'));
1359
+ }
1360
+ else {
1361
+ const k = this.#keyList[index];
1362
+ if (this.#hasDispose) {
1363
+ this.#dispose?.(v, k, 'delete');
1364
+ }
1365
+ if (this.#hasDisposeAfter) {
1366
+ this.#disposed?.push([v, k, 'delete']);
1367
+ }
1368
+ }
1369
+ }
1370
+ this.#keyMap.clear();
1371
+ this.#valList.fill(undefined);
1372
+ this.#keyList.fill(undefined);
1373
+ if (this.#ttls && this.#starts) {
1374
+ this.#ttls.fill(0);
1375
+ this.#starts.fill(0);
1376
+ }
1377
+ if (this.#sizes) {
1378
+ this.#sizes.fill(0);
1379
+ }
1380
+ this.#head = 0;
1381
+ this.#tail = 0;
1382
+ this.#free.length = 0;
1383
+ this.#calculatedSize = 0;
1384
+ this.#size = 0;
1385
+ if (this.#hasDisposeAfter && this.#disposed) {
1386
+ const dt = this.#disposed;
1387
+ let task;
1388
+ while ((task = dt?.shift())) {
1389
+ this.#disposeAfter?.(...task);
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+ exports.LRUCache = LRUCache;
1395
+ //# sourceMappingURL=index.js.map