@socketsecurity/cli-with-sentry 1.1.15 → 1.1.17

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 (103) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cli.js +14 -15
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +35 -37
  5. package/dist/constants.js.map +1 -1
  6. package/dist/shadow-npm-bin.js +6 -6
  7. package/dist/shadow-npm-bin.js.map +1 -1
  8. package/dist/shadow-pnpm-bin.js +3 -5
  9. package/dist/shadow-pnpm-bin.js.map +1 -1
  10. package/dist/shadow-yarn-bin.js +2 -2
  11. package/dist/shadow-yarn-bin.js.map +1 -1
  12. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  13. package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
  14. package/dist/types/commands/optimize/apply-optimization.d.mts.map +1 -1
  15. package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
  16. package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
  17. package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
  18. package/dist/types/commands/yarn/cmd-yarn.d.mts +1 -1
  19. package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -1
  20. package/dist/types/constants.d.mts +15 -19
  21. package/dist/types/constants.d.mts.map +1 -1
  22. package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
  23. package/dist/types/utils/agent.d.mts.map +1 -1
  24. package/dist/types/utils/dlx.d.mts.map +1 -1
  25. package/dist/types/utils/package-environment.d.mts.map +1 -1
  26. package/dist/types/utils/path-resolve.d.mts.map +1 -1
  27. package/dist/utils.js +65 -27
  28. package/dist/utils.js.map +1 -1
  29. package/dist/vendor.js +514 -517
  30. package/external/@socketsecurity/registry/external/@inquirer/confirm.js +45 -205
  31. package/external/@socketsecurity/registry/external/@inquirer/input.js +45 -205
  32. package/external/@socketsecurity/registry/external/@inquirer/password.js +181 -205
  33. package/external/@socketsecurity/registry/external/@inquirer/search.js +47 -207
  34. package/external/@socketsecurity/registry/external/@inquirer/select.js +183 -207
  35. package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +388 -2280
  36. package/external/@socketsecurity/registry/external/browserslist.js +11534 -567
  37. package/external/@socketsecurity/registry/external/cacache.js +2575 -4914
  38. package/external/@socketsecurity/registry/external/libnpmpack.js +64667 -166061
  39. package/external/@socketsecurity/registry/external/make-fetch-happen.js +384 -4044
  40. package/external/@socketsecurity/registry/external/normalize-package-data.js +30 -278
  41. package/external/@socketsecurity/registry/external/npm-package-arg.js +28 -9
  42. package/external/@socketsecurity/registry/external/pacote.js +46680 -66482
  43. package/external/@socketsecurity/registry/external/spdx-correct.js +19 -0
  44. package/external/@socketsecurity/registry/external/spdx-expression-parse.js +19 -0
  45. package/external/@socketsecurity/registry/lib/agent.js +390 -0
  46. package/external/@socketsecurity/registry/lib/arrays.js +31 -0
  47. package/external/@socketsecurity/registry/lib/bin.js +650 -0
  48. package/external/@socketsecurity/registry/lib/constants/bun-lock.js +3 -0
  49. package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +3 -0
  50. package/external/@socketsecurity/registry/lib/constants/bun.js +3 -0
  51. package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +3 -0
  52. package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +3 -0
  53. package/external/@socketsecurity/registry/lib/constants/empty-value.js +3 -0
  54. package/external/@socketsecurity/registry/lib/constants/env.js +17 -3
  55. package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +3 -0
  56. package/external/@socketsecurity/registry/lib/constants/ext-yml.js +3 -0
  57. package/external/@socketsecurity/registry/lib/constants/index.js +20 -11
  58. package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +2 -2
  59. package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +1 -1
  60. package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +3 -0
  61. package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +5 -0
  62. package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +3 -0
  63. package/external/@socketsecurity/registry/lib/constants/unknown-error.js +3 -0
  64. package/external/@socketsecurity/registry/lib/constants/unknown-value.js +3 -0
  65. package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +3 -0
  66. package/external/@socketsecurity/registry/lib/constants/vlt.js +3 -0
  67. package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +3 -0
  68. package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +3 -0
  69. package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +5 -0
  70. package/external/@socketsecurity/registry/lib/constants/yarn.js +3 -0
  71. package/external/@socketsecurity/registry/lib/debug.js +53 -0
  72. package/external/@socketsecurity/registry/lib/env.js +18 -0
  73. package/external/@socketsecurity/registry/lib/fs.js +218 -2
  74. package/external/@socketsecurity/registry/lib/functions.js +5 -0
  75. package/external/@socketsecurity/registry/lib/globs.js +22 -1
  76. package/external/@socketsecurity/registry/lib/json.js +16 -0
  77. package/external/@socketsecurity/registry/lib/logger.js +157 -0
  78. package/external/@socketsecurity/registry/lib/objects.js +103 -0
  79. package/external/@socketsecurity/registry/lib/packages.js +88 -0
  80. package/external/@socketsecurity/registry/lib/path.js +51 -1
  81. package/external/@socketsecurity/registry/lib/promises.js +55 -0
  82. package/external/@socketsecurity/registry/lib/regexps.js +5 -0
  83. package/external/@socketsecurity/registry/lib/sorts.js +17 -0
  84. package/external/@socketsecurity/registry/lib/spawn.js +105 -7
  85. package/external/@socketsecurity/registry/lib/streams.js +26 -0
  86. package/external/@socketsecurity/registry/lib/strings.js +123 -9
  87. package/external/@socketsecurity/registry/lib/url.js +21 -0
  88. package/external/@socketsecurity/registry/lib/words.js +16 -0
  89. package/external/@socketsecurity/registry/manifest.json +5 -4
  90. package/package.json +5 -4
  91. package/external/@socketsecurity/registry/external/ansi-regex.js +0 -13
  92. package/external/@socketsecurity/registry/lib/constants/node-workspaces.js +0 -3
  93. package/external/@socketsecurity/registry/lib/constants/parse-args-config.js +0 -14
  94. package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -43
  95. package/external/@socketsecurity/registry/lib/constants/template-cjs-browser.js +0 -3
  96. package/external/@socketsecurity/registry/lib/constants/template-cjs-esm.js +0 -3
  97. package/external/@socketsecurity/registry/lib/constants/template-cjs.js +0 -3
  98. package/external/@socketsecurity/registry/lib/constants/template-es-shim-constructor.js +0 -3
  99. package/external/@socketsecurity/registry/lib/constants/template-es-shim-prototype-method.js +0 -3
  100. package/external/@socketsecurity/registry/lib/constants/template-es-shim-static-method.js +0 -3
  101. package/external/@socketsecurity/registry/lib/constants/win32-ensure-tests-by-ecosystem.js +0 -3
  102. package/external/@socketsecurity/registry/lib/npm.js +0 -404
  103. /package/external/@socketsecurity/registry/lib/constants/{hidden-package-lock-json.js → dot-package-lock-json.js} +0 -0
@@ -685,12 +685,12 @@ function requireSemver() {
685
685
  }
686
686
 
687
687
  let parse_1
688
- let hasRequiredParse$2
689
- function requireParse$2() {
690
- if (hasRequiredParse$2) {
688
+ let hasRequiredParse$1
689
+ function requireParse$1() {
690
+ if (hasRequiredParse$1) {
691
691
  return parse_1
692
692
  }
693
- hasRequiredParse$2 = 1
693
+ hasRequiredParse$1 = 1
694
694
  const SemVer = requireSemver()
695
695
  const parse = (version, options, throwErrors = false) => {
696
696
  if (version instanceof SemVer) {
@@ -716,7 +716,7 @@ function requireValid() {
716
716
  return valid_1
717
717
  }
718
718
  hasRequiredValid = 1
719
- const parse = requireParse$2()
719
+ const parse = requireParse$1()
720
720
  const valid = (version, options) => {
721
721
  const v = parse(version, options)
722
722
  return v ? v.version : null
@@ -732,7 +732,7 @@ function requireClean() {
732
732
  return clean_1
733
733
  }
734
734
  hasRequiredClean = 1
735
- const parse = requireParse$2()
735
+ const parse = requireParse$1()
736
736
  const clean = (version, options) => {
737
737
  const s = parse(version.trim().replace(/^[=v]+/, ''), options)
738
738
  return s ? s.version : null
@@ -787,12 +787,15 @@ const require$$1$2 = [
787
787
  'Artistic-1.0-Perl',
788
788
  'Artistic-1.0-cl8',
789
789
  'Artistic-2.0',
790
+ 'Artistic-dist',
791
+ 'Aspell-RU',
790
792
  'BSD-1-Clause',
791
793
  'BSD-2-Clause',
792
794
  'BSD-2-Clause-Darwin',
793
795
  'BSD-2-Clause-Patent',
794
796
  'BSD-2-Clause-Views',
795
797
  'BSD-2-Clause-first-lines',
798
+ 'BSD-2-Clause-pkgconf-disclaimer',
796
799
  'BSD-3-Clause',
797
800
  'BSD-3-Clause-Attribution',
798
801
  'BSD-3-Clause-Clear',
@@ -933,6 +936,7 @@ const require$$1$2 = [
933
936
  'Cornell-Lossless-JPEG',
934
937
  'Cronyx',
935
938
  'Crossword',
939
+ 'CryptoSwift',
936
940
  'CrystalStacker',
937
941
  'Cube',
938
942
  'D-FSL-1.0',
@@ -943,6 +947,7 @@ const require$$1$2 = [
943
947
  'DRL-1.0',
944
948
  'DRL-1.1',
945
949
  'DSDP',
950
+ 'DocBook-DTD',
946
951
  'DocBook-Schema',
947
952
  'DocBook-Stylesheet',
948
953
  'DocBook-XML',
@@ -968,7 +973,10 @@ const require$$1$2 = [
968
973
  'FSFAP-no-warranty-disclaimer',
969
974
  'FSFUL',
970
975
  'FSFULLR',
976
+ 'FSFULLRSD',
971
977
  'FSFULLRWD',
978
+ 'FSL-1.1-ALv2',
979
+ 'FSL-1.1-MIT',
972
980
  'FTL',
973
981
  'Fair',
974
982
  'Ferguson-Twofish',
@@ -1004,11 +1012,13 @@ const require$$1$2 = [
1004
1012
  'GPL-2.0-or-later',
1005
1013
  'GPL-3.0-only',
1006
1014
  'GPL-3.0-or-later',
1015
+ 'Game-Programming-Gems',
1007
1016
  'Giftware',
1008
1017
  'Glide',
1009
1018
  'Glulxe',
1010
1019
  'Graphics-Gems',
1011
1020
  'Gutmann',
1021
+ 'HDF5',
1012
1022
  'HIDAPI',
1013
1023
  'HP-1986',
1014
1024
  'HP-1989',
@@ -1154,6 +1164,7 @@ const require$$1$2 = [
1154
1164
  'NPL-1.1',
1155
1165
  'NPOSL-3.0',
1156
1166
  'NRL',
1167
+ 'NTIA-PD',
1157
1168
  'NTP',
1158
1169
  'NTP-0',
1159
1170
  'Naumen',
@@ -1256,11 +1267,13 @@ const require$$1$2 = [
1256
1267
  'SMLNJ',
1257
1268
  'SMPPL',
1258
1269
  'SNIA',
1270
+ 'SOFA',
1259
1271
  'SPL-1.0',
1260
1272
  'SSH-OpenSSH',
1261
1273
  'SSH-short',
1262
1274
  'SSLeay-standalone',
1263
1275
  'SSPL-1.0',
1276
+ 'SUL-1.0',
1264
1277
  'SWL',
1265
1278
  'Saxpath',
1266
1279
  'SchemeReport',
@@ -1306,6 +1319,8 @@ const require$$1$2 = [
1306
1319
  'Unicode-TOU',
1307
1320
  'UnixCrypt',
1308
1321
  'Unlicense',
1322
+ 'Unlicense-libtelnet',
1323
+ 'Unlicense-libwhirlpool',
1309
1324
  'VOSTROM',
1310
1325
  'VSL-1.0',
1311
1326
  'Vim',
@@ -1359,6 +1374,8 @@ const require$$1$2 = [
1359
1374
  'gtkbook',
1360
1375
  'hdparm',
1361
1376
  'iMatix',
1377
+ 'jove',
1378
+ 'libpng-1.6.35',
1362
1379
  'libpng-2.0',
1363
1380
  'libselinux-1.0',
1364
1381
  'libtiff',
@@ -1366,10 +1383,12 @@ const require$$1$2 = [
1366
1383
  'lsof',
1367
1384
  'magaz',
1368
1385
  'mailprio',
1386
+ 'man2html',
1369
1387
  'metamail',
1370
1388
  'mpi-permissive',
1371
1389
  'mpich2',
1372
1390
  'mplus',
1391
+ 'ngrep',
1373
1392
  'pkgconf',
1374
1393
  'pnmstitch',
1375
1394
  'psfrag',
@@ -1490,276 +1509,6 @@ const require$$2 = [
1490
1509
  'x11vnc-openssl-exception'
1491
1510
  ]
1492
1511
 
1493
- let scan$1
1494
- let hasRequiredScan$1
1495
- function requireScan$1() {
1496
- if (hasRequiredScan$1) {
1497
- return scan$1
1498
- }
1499
- hasRequiredScan$1 = 1
1500
- const licenses = [].concat(require$$1$2).concat(require$$1$1)
1501
- const exceptions = require$$2
1502
- scan$1 = function (source) {
1503
- let index = 0
1504
- function hasMore() {
1505
- return index < source.length
1506
- }
1507
-
1508
- // `value` can be a regexp or a string.
1509
- // If it is recognized, the matching source string is returned and
1510
- // the index is incremented. Otherwise `undefined` is returned.
1511
- function read(value) {
1512
- if (value instanceof RegExp) {
1513
- const chars = source.slice(index)
1514
- const match = chars.match(value)
1515
- if (match) {
1516
- index += match[0].length
1517
- return match[0]
1518
- }
1519
- } else {
1520
- if (source.indexOf(value, index) === index) {
1521
- index += value.length
1522
- return value
1523
- }
1524
- }
1525
- }
1526
- function skipWhitespace() {
1527
- read(/[ ]*/)
1528
- }
1529
- function operator() {
1530
- let string
1531
- const possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
1532
- for (let i = 0; i < possibilities.length; i++) {
1533
- string = read(possibilities[i])
1534
- if (string) {
1535
- break
1536
- }
1537
- }
1538
- if (string === '+' && index > 1 && source[index - 2] === ' ') {
1539
- throw new Error('Space before `+`')
1540
- }
1541
- return (
1542
- string && {
1543
- type: 'OPERATOR',
1544
- string: string
1545
- }
1546
- )
1547
- }
1548
- function idstring() {
1549
- return read(/[A-Za-z0-9-.]+/)
1550
- }
1551
- function expectIdstring() {
1552
- const string = idstring()
1553
- if (!string) {
1554
- throw new Error('Expected idstring at offset ' + index)
1555
- }
1556
- return string
1557
- }
1558
- function documentRef() {
1559
- if (read('DocumentRef-')) {
1560
- const string = expectIdstring()
1561
- return {
1562
- type: 'DOCUMENTREF',
1563
- string: string
1564
- }
1565
- }
1566
- }
1567
- function licenseRef() {
1568
- if (read('LicenseRef-')) {
1569
- const string = expectIdstring()
1570
- return {
1571
- type: 'LICENSEREF',
1572
- string: string
1573
- }
1574
- }
1575
- }
1576
- function identifier() {
1577
- const begin = index
1578
- const string = idstring()
1579
- if (licenses.indexOf(string) !== -1) {
1580
- return {
1581
- type: 'LICENSE',
1582
- string: string
1583
- }
1584
- } else if (exceptions.indexOf(string) !== -1) {
1585
- return {
1586
- type: 'EXCEPTION',
1587
- string: string
1588
- }
1589
- }
1590
- index = begin
1591
- }
1592
-
1593
- // Tries to read the next token. Returns `undefined` if no token is
1594
- // recognized.
1595
- function parseToken() {
1596
- // Ordering matters
1597
- return operator() || documentRef() || licenseRef() || identifier()
1598
- }
1599
- const tokens = []
1600
- while (hasMore()) {
1601
- skipWhitespace()
1602
- if (!hasMore()) {
1603
- break
1604
- }
1605
- const token = parseToken()
1606
- if (!token) {
1607
- throw new Error('Unexpected `' + source[index] + '` at offset ' + index)
1608
- }
1609
- tokens.push(token)
1610
- }
1611
- return tokens
1612
- }
1613
- return scan$1
1614
- }
1615
-
1616
- let parse$1
1617
- let hasRequiredParse$1
1618
- function requireParse$1() {
1619
- if (hasRequiredParse$1) {
1620
- return parse$1
1621
- }
1622
- hasRequiredParse$1 = 1
1623
-
1624
- // The ABNF grammar in the spec is totally ambiguous.
1625
- //
1626
- // This parser follows the operator precedence defined in the
1627
- // `Order of Precedence and Parentheses` section.
1628
-
1629
- parse$1 = function (tokens) {
1630
- let index = 0
1631
- function hasMore() {
1632
- return index < tokens.length
1633
- }
1634
- function token() {
1635
- return hasMore() ? tokens[index] : null
1636
- }
1637
- function next() {
1638
- if (!hasMore()) {
1639
- throw new Error()
1640
- }
1641
- index++
1642
- }
1643
- function parseOperator(operator) {
1644
- const t = token()
1645
- if (t && t.type === 'OPERATOR' && operator === t.string) {
1646
- next()
1647
- return t.string
1648
- }
1649
- }
1650
- function parseWith() {
1651
- if (parseOperator('WITH')) {
1652
- const t = token()
1653
- if (t && t.type === 'EXCEPTION') {
1654
- next()
1655
- return t.string
1656
- }
1657
- throw new Error('Expected exception after `WITH`')
1658
- }
1659
- }
1660
- function parseLicenseRef() {
1661
- // TODO: Actually, everything is concatenated into one string
1662
- // for backward-compatibility but it could be better to return
1663
- // a nice structure.
1664
- const begin = index
1665
- let string = ''
1666
- let t = token()
1667
- if (t.type === 'DOCUMENTREF') {
1668
- next()
1669
- string += 'DocumentRef-' + t.string + ':'
1670
- if (!parseOperator(':')) {
1671
- throw new Error('Expected `:` after `DocumentRef-...`')
1672
- }
1673
- }
1674
- t = token()
1675
- if (t.type === 'LICENSEREF') {
1676
- next()
1677
- string += 'LicenseRef-' + t.string
1678
- return {
1679
- license: string
1680
- }
1681
- }
1682
- index = begin
1683
- }
1684
- function parseLicense() {
1685
- const t = token()
1686
- if (t && t.type === 'LICENSE') {
1687
- next()
1688
- const node = {
1689
- license: t.string
1690
- }
1691
- if (parseOperator('+')) {
1692
- node.plus = true
1693
- }
1694
- const exception = parseWith()
1695
- if (exception) {
1696
- node.exception = exception
1697
- }
1698
- return node
1699
- }
1700
- }
1701
- function parseParenthesizedExpression() {
1702
- const left = parseOperator('(')
1703
- if (!left) {
1704
- return
1705
- }
1706
- const expr = parseExpression()
1707
- if (!parseOperator(')')) {
1708
- throw new Error('Expected `)`')
1709
- }
1710
- return expr
1711
- }
1712
- function parseAtom() {
1713
- return (
1714
- parseParenthesizedExpression() || parseLicenseRef() || parseLicense()
1715
- )
1716
- }
1717
- function makeBinaryOpParser(operator, nextParser) {
1718
- return function parseBinaryOp() {
1719
- const left = nextParser()
1720
- if (!left) {
1721
- return
1722
- }
1723
- if (!parseOperator(operator)) {
1724
- return left
1725
- }
1726
- const right = parseBinaryOp()
1727
- if (!right) {
1728
- throw new Error('Expected expression')
1729
- }
1730
- return {
1731
- left: left,
1732
- conjunction: operator.toLowerCase(),
1733
- right: right
1734
- }
1735
- }
1736
- }
1737
- const parseAnd = makeBinaryOpParser('AND', parseAtom)
1738
- const parseExpression = makeBinaryOpParser('OR', parseAnd)
1739
- const node = parseExpression()
1740
- if (!node || hasMore()) {
1741
- throw new Error('Syntax error')
1742
- }
1743
- return node
1744
- }
1745
- return parse$1
1746
- }
1747
-
1748
- let spdxExpressionParse$1
1749
- let hasRequiredSpdxExpressionParse$1
1750
- function requireSpdxExpressionParse$1() {
1751
- if (hasRequiredSpdxExpressionParse$1) {
1752
- return spdxExpressionParse$1
1753
- }
1754
- hasRequiredSpdxExpressionParse$1 = 1
1755
- const scan = requireScan$1()
1756
- const parse = requireParse$1()
1757
- spdxExpressionParse$1 = function (source) {
1758
- return parse(scan(source))
1759
- }
1760
- return spdxExpressionParse$1
1761
- }
1762
-
1763
1512
  let scan
1764
1513
  let hasRequiredScan
1765
1514
  function requireScan() {
@@ -2451,7 +2200,7 @@ function requireValidateNpmPackageLicense() {
2451
2200
  return validateNpmPackageLicense
2452
2201
  }
2453
2202
  hasRequiredValidateNpmPackageLicense = 1
2454
- const parse = requireSpdxExpressionParse$1()
2203
+ const parse = requireSpdxExpressionParse()
2455
2204
  const correct = requireSpdxCorrect()
2456
2205
  const genericWarning =
2457
2206
  'license should be ' +
@@ -4867,7 +4616,10 @@ function requireIsCoreModule() {
4867
4616
  return isCoreModule
4868
4617
  }
4869
4618
  hasRequiredIsCoreModule = 1
4870
- const { isBuiltin } = require$$0$1
4619
+
4620
+ // eslint-disable-next-line n/prefer-node-protocol
4621
+ const nodeModule = require$$0$1
4622
+ const isBuiltin = nodeModule.isBuiltin
4871
4623
  isCoreModule = function isCore(moduleName, nodeVersion) {
4872
4624
  if (typeof nodeVersion === 'string') {
4873
4625
  throw new TypeError(
@@ -24,7 +24,7 @@ function requireCommonjs() {
24
24
  value: true
25
25
  })
26
26
  commonjs.LRUCache = void 0
27
- const perf =
27
+ const defaultPerf =
28
28
  typeof performance === 'object' &&
29
29
  performance &&
30
30
  typeof performance.now === 'function'
@@ -181,6 +181,13 @@ function requireCommonjs() {
181
181
  #disposeAfter
182
182
  #fetchMethod
183
183
  #memoMethod
184
+ #perf
185
+ /**
186
+ * {@link LRUCache.OptionsBase.perf}
187
+ */
188
+ get perf() {
189
+ return this.#perf
190
+ }
184
191
  /**
185
192
  * {@link LRUCache.OptionsBase.ttl}
186
193
  */
@@ -372,8 +379,17 @@ function requireCommonjs() {
372
379
  noDeleteOnStaleGet,
373
380
  allowStaleOnFetchRejection,
374
381
  allowStaleOnFetchAbort,
375
- ignoreFetchAbort
382
+ ignoreFetchAbort,
383
+ perf
376
384
  } = options
385
+ if (perf !== undefined) {
386
+ if (typeof perf?.now !== 'function') {
387
+ throw new TypeError(
388
+ 'perf option must have a now() method if specified'
389
+ )
390
+ }
391
+ }
392
+ this.#perf = perf ?? defaultPerf
377
393
  if (max !== 0 && !isPosInt(max)) {
378
394
  throw new TypeError('max option must be a nonnegative integer')
379
395
  }
@@ -493,7 +509,7 @@ function requireCommonjs() {
493
509
  const starts = new ZeroArray(this.#max)
494
510
  this.#ttls = ttls
495
511
  this.#starts = starts
496
- this.#setItemTTL = (index, ttl, start = perf.now()) => {
512
+ this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
497
513
  starts[index] = ttl !== 0 ? start : 0
498
514
  ttls[index] = ttl
499
515
  if (ttl !== 0 && this.ttlAutopurge) {
@@ -511,7 +527,7 @@ function requireCommonjs() {
511
527
  }
512
528
  }
513
529
  this.#updateItemAge = index => {
514
- starts[index] = ttls[index] !== 0 ? perf.now() : 0
530
+ starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0
515
531
  }
516
532
  this.#statusTTL = (status, index) => {
517
533
  if (ttls[index]) {
@@ -532,7 +548,7 @@ function requireCommonjs() {
532
548
  // that costly call repeatedly.
533
549
  let cachedNow = 0
534
550
  const getNow = () => {
535
- const n = perf.now()
551
+ const n = this.#perf.now()
536
552
  if (this.ttlResolution > 0) {
537
553
  cachedNow = n
538
554
  const t = setTimeout(() => (cachedNow = 0), this.ttlResolution)
@@ -851,10 +867,13 @@ function requireCommonjs() {
851
867
  return undefined
852
868
  }
853
869
  const v = this.#valList[i]
870
+ /* c8 ignore start - this isn't tested for the info function,
871
+ * but it's the same logic as found in other places. */
854
872
  const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
855
873
  if (value === undefined) {
856
874
  return undefined
857
875
  }
876
+ /* c8 ignore end */
858
877
  const entry = {
859
878
  value
860
879
  }
@@ -862,7 +881,7 @@ function requireCommonjs() {
862
881
  const ttl = this.#ttls[i]
863
882
  const start = this.#starts[i]
864
883
  if (ttl && start) {
865
- const remain = ttl - (perf.now() - start)
884
+ const remain = ttl - (this.#perf.now() - start)
866
885
  entry.ttl = remain
867
886
  entry.start = Date.now()
868
887
  }
@@ -903,7 +922,7 @@ function requireCommonjs() {
903
922
  entry.ttl = this.#ttls[i]
904
923
  // always dump the start relative to a portable timestamp
905
924
  // it's ok for this to be a bit slow, it's a rare operation.
906
- const age = perf.now() - this.#starts[i]
925
+ const age = this.#perf.now() - this.#starts[i]
907
926
  entry.start = Math.floor(Date.now() - age)
908
927
  }
909
928
  if (this.#sizes) {
@@ -933,7 +952,7 @@ function requireCommonjs() {
933
952
  //
934
953
  // it's ok for this to be a bit slow, it's a rare operation.
935
954
  const age = Date.now() - entry.start
936
- entry.start = perf.now() - age
955
+ entry.start = this.#perf.now() - age
937
956
  }
938
957
  this.set(key, entry.value, entry)
939
958
  }
@@ -1245,7 +1264,7 @@ function requireCommonjs() {
1245
1264
  const bf = p
1246
1265
  if (this.#valList[index] === p) {
1247
1266
  if (v === undefined) {
1248
- if (bf.__staleWhileFetching) {
1267
+ if (bf.__staleWhileFetching !== undefined) {
1249
1268
  this.#valList[index] = bf.__staleWhileFetching
1250
1269
  } else {
1251
1270
  this.#delete(k, 'fetch')