@cloudflare/workers-utils 0.47.0 → 0.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';
2
2
  export { MetricsRegistry } from './chunk-6G6FCMPX.mjs';
3
- import { external_exports } from './chunk-PWC7WAOU.mjs';
4
- export { formatZodError } from './chunk-PWC7WAOU.mjs';
3
+ import { external_exports } from './chunk-CAPCWVOB.mjs';
4
+ export { formatZodError } from './chunk-CAPCWVOB.mjs';
5
5
  import { isRedirectedRawConfig, configFileName, formatConfigSnippet, partitionExports, getDurableObjectExports, getContainerNameToClassNameMap, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, isLiveDurableObjectExport, dir, parseTOML, modify, applyEdits, format, stringify, parseJSONC } from './chunk-TAK63GWY.mjs';
6
6
  export { APIError, ENVIRONMENT_TAG_PREFIX, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, configFileName, configFormat, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, getContainerDurableObjectClassNames, getContainerNameToClassNameMap, getDurableObjectClassNameToUseSQLiteMap, getDurableObjectContainerApps, getDurableObjectExports, getResolvedDurableObjectContainerApps, hasDurableObjectExports, indexLocation, isDurableObjectContainerApp, isLiveDurableObjectExport, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveContainerClassName, resolveWranglerConfigPath, searchLocation, validateDurableObjectContainerApplications } from './chunk-TAK63GWY.mjs';
7
7
  export { NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, getTodaysCompatDate, isCompatDate, isNodejsCompatDefaultOn, resolveNodejsCompat, stripRedundantNodejsCompatFlags } from './chunk-2Q77CKVU.mjs';
@@ -26,7 +26,8 @@ import { URLSearchParams as URLSearchParams$1 } from 'node:url';
26
26
  import { Headers, FormData, Response, fetch } from 'undici';
27
27
  import { execFileSync, spawn } from 'node:child_process';
28
28
  import { createHash, randomBytes } from 'node:crypto';
29
- import { arch } from 'node:os';
29
+ import { arch, tmpdir } from 'node:os';
30
+ import { readFile, mkdir, writeFile } from 'node:fs/promises';
30
31
  import * as timersPromises from 'node:timers/promises';
31
32
  import { setTimeout as setTimeout$1 } from 'node:timers/promises';
32
33
 
@@ -489,7 +490,7 @@ var require_command_exists = __commonJS({
489
490
  var exec = __require("child_process").exec;
490
491
  var execSync = __require("child_process").execSync;
491
492
  var fs4 = __require("fs");
492
- var path6 = __require("path");
493
+ var path7 = __require("path");
493
494
  var access = fs4.access;
494
495
  var accessSync2 = fs4.accessSync;
495
496
  var constants2 = fs4.constants || fs4;
@@ -593,8 +594,8 @@ var require_command_exists = __commonJS({
593
594
  cleanInput = /* @__PURE__ */ __name(function(s) {
594
595
  var isPathName = /[\\]/.test(s);
595
596
  if (isPathName) {
596
- var dirname4 = '"' + path6.dirname(s) + '"';
597
- var basename2 = '"' + path6.basename(s) + '"';
597
+ var dirname4 = '"' + path7.dirname(s) + '"';
598
+ var basename2 = '"' + path7.basename(s) + '"';
598
599
  return dirname4 + ":" + basename2;
599
600
  }
600
601
  return '"' + s + '"';
@@ -637,997 +638,6 @@ var require_command_exists2 = __commonJS({
637
638
  }
638
639
  });
639
640
 
640
- // ../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js
641
- var require_ini = __commonJS({
642
- "../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js"(exports$1) {
643
- exports$1.parse = exports$1.decode = decode;
644
- exports$1.stringify = exports$1.encode = encode;
645
- exports$1.safe = safe;
646
- exports$1.unsafe = unsafe;
647
- var eol = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
648
- function encode(obj, opt) {
649
- var children = [];
650
- var out = "";
651
- if (typeof opt === "string") {
652
- opt = {
653
- section: opt,
654
- whitespace: false
655
- };
656
- } else {
657
- opt = opt || {};
658
- opt.whitespace = opt.whitespace === true;
659
- }
660
- var separator = opt.whitespace ? " = " : "=";
661
- Object.keys(obj).forEach(function(k, _, __) {
662
- var val = obj[k];
663
- if (val && Array.isArray(val)) {
664
- val.forEach(function(item) {
665
- out += safe(k + "[]") + separator + safe(item) + "\n";
666
- });
667
- } else if (val && typeof val === "object")
668
- children.push(k);
669
- else
670
- out += safe(k) + separator + safe(val) + eol;
671
- });
672
- if (opt.section && out.length)
673
- out = "[" + safe(opt.section) + "]" + eol + out;
674
- children.forEach(function(k, _, __) {
675
- var nk = dotSplit(k).join("\\.");
676
- var section = (opt.section ? opt.section + "." : "") + nk;
677
- var child = encode(obj[k], {
678
- section,
679
- whitespace: opt.whitespace
680
- });
681
- if (out.length && child.length)
682
- out += eol;
683
- out += child;
684
- });
685
- return out;
686
- }
687
- __name(encode, "encode");
688
- function dotSplit(str) {
689
- return str.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map(function(part) {
690
- return part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, "");
691
- });
692
- }
693
- __name(dotSplit, "dotSplit");
694
- function decode(str) {
695
- var out = {};
696
- var p = out;
697
- var section = null;
698
- var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
699
- var lines = str.split(/[\r\n]+/g);
700
- lines.forEach(function(line, _, __) {
701
- if (!line || line.match(/^\s*[;#]/))
702
- return;
703
- var match = line.match(re);
704
- if (!match)
705
- return;
706
- if (match[1] !== void 0) {
707
- section = unsafe(match[1]);
708
- if (section === "__proto__") {
709
- p = {};
710
- return;
711
- }
712
- p = out[section] = out[section] || {};
713
- return;
714
- }
715
- var key = unsafe(match[2]);
716
- if (key === "__proto__")
717
- return;
718
- var value = match[3] ? unsafe(match[4]) : true;
719
- switch (value) {
720
- case "true":
721
- case "false":
722
- case "null":
723
- value = JSON.parse(value);
724
- }
725
- if (key.length > 2 && key.slice(-2) === "[]") {
726
- key = key.substring(0, key.length - 2);
727
- if (key === "__proto__")
728
- return;
729
- if (!p[key])
730
- p[key] = [];
731
- else if (!Array.isArray(p[key]))
732
- p[key] = [p[key]];
733
- }
734
- if (Array.isArray(p[key]))
735
- p[key].push(value);
736
- else
737
- p[key] = value;
738
- });
739
- Object.keys(out).filter(function(k, _, __) {
740
- if (!out[k] || typeof out[k] !== "object" || Array.isArray(out[k]))
741
- return false;
742
- var parts = dotSplit(k);
743
- var p2 = out;
744
- var l = parts.pop();
745
- var nl = l.replace(/\\\./g, ".");
746
- parts.forEach(function(part, _2, __2) {
747
- if (part === "__proto__")
748
- return;
749
- if (!p2[part] || typeof p2[part] !== "object")
750
- p2[part] = {};
751
- p2 = p2[part];
752
- });
753
- if (p2 === out && nl === l)
754
- return false;
755
- p2[nl] = out[k];
756
- return true;
757
- }).forEach(function(del, _, __) {
758
- delete out[del];
759
- });
760
- return out;
761
- }
762
- __name(decode, "decode");
763
- function isQuoted(val) {
764
- return val.charAt(0) === '"' && val.slice(-1) === '"' || val.charAt(0) === "'" && val.slice(-1) === "'";
765
- }
766
- __name(isQuoted, "isQuoted");
767
- function safe(val) {
768
- return typeof val !== "string" || val.match(/[=\r\n]/) || val.match(/^\[/) || val.length > 1 && isQuoted(val) || val !== val.trim() ? JSON.stringify(val) : val.replace(/;/g, "\\;").replace(/#/g, "\\#");
769
- }
770
- __name(safe, "safe");
771
- function unsafe(val, doUnesc) {
772
- val = (val || "").trim();
773
- if (isQuoted(val)) {
774
- if (val.charAt(0) === "'")
775
- val = val.substr(1, val.length - 2);
776
- try {
777
- val = JSON.parse(val);
778
- } catch (_) {
779
- }
780
- } else {
781
- var esc = false;
782
- var unesc = "";
783
- for (var i = 0, l = val.length; i < l; i++) {
784
- var c = val.charAt(i);
785
- if (esc) {
786
- if ("\\;#".indexOf(c) !== -1)
787
- unesc += c;
788
- else
789
- unesc += "\\" + c;
790
- esc = false;
791
- } else if (";#".indexOf(c) !== -1)
792
- break;
793
- else if (c === "\\")
794
- esc = true;
795
- else
796
- unesc += c;
797
- }
798
- if (esc)
799
- unesc += "\\";
800
- return unesc.trim();
801
- }
802
- return val;
803
- }
804
- __name(unsafe, "unsafe");
805
- }
806
- });
807
-
808
- // ../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js
809
- var require_strip_json_comments = __commonJS({
810
- "../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js"(exports$1, module) {
811
- var singleComment = 1;
812
- var multiComment = 2;
813
- function stripWithoutWhitespace() {
814
- return "";
815
- }
816
- __name(stripWithoutWhitespace, "stripWithoutWhitespace");
817
- function stripWithWhitespace(str, start, end) {
818
- return str.slice(start, end).replace(/\S/g, " ");
819
- }
820
- __name(stripWithWhitespace, "stripWithWhitespace");
821
- module.exports = function(str, opts) {
822
- opts = opts || {};
823
- var currentChar;
824
- var nextChar;
825
- var insideString = false;
826
- var insideComment = false;
827
- var offset = 0;
828
- var ret = "";
829
- var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
830
- for (var i = 0; i < str.length; i++) {
831
- currentChar = str[i];
832
- nextChar = str[i + 1];
833
- if (!insideComment && currentChar === '"') {
834
- var escaped = str[i - 1] === "\\" && str[i - 2] !== "\\";
835
- if (!escaped) {
836
- insideString = !insideString;
837
- }
838
- }
839
- if (insideString) {
840
- continue;
841
- }
842
- if (!insideComment && currentChar + nextChar === "//") {
843
- ret += str.slice(offset, i);
844
- offset = i;
845
- insideComment = singleComment;
846
- i++;
847
- } else if (insideComment === singleComment && currentChar + nextChar === "\r\n") {
848
- i++;
849
- insideComment = false;
850
- ret += strip(str, offset, i);
851
- offset = i;
852
- continue;
853
- } else if (insideComment === singleComment && currentChar === "\n") {
854
- insideComment = false;
855
- ret += strip(str, offset, i);
856
- offset = i;
857
- } else if (!insideComment && currentChar + nextChar === "/*") {
858
- ret += str.slice(offset, i);
859
- offset = i;
860
- insideComment = multiComment;
861
- i++;
862
- continue;
863
- } else if (insideComment === multiComment && currentChar + nextChar === "*/") {
864
- i++;
865
- insideComment = false;
866
- ret += strip(str, offset, i + 1);
867
- offset = i + 1;
868
- continue;
869
- }
870
- }
871
- return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
872
- };
873
- }
874
- });
875
-
876
- // ../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js
877
- var require_utils = __commonJS({
878
- "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js"(exports$1) {
879
- var fs4 = __require("fs");
880
- var ini = require_ini();
881
- var path6 = __require("path");
882
- var stripJsonComments = require_strip_json_comments();
883
- var parse = exports$1.parse = function(content) {
884
- if (/^\s*{/.test(content))
885
- return JSON.parse(stripJsonComments(content));
886
- return ini.parse(content);
887
- };
888
- var file = exports$1.file = function() {
889
- var args = [].slice.call(arguments).filter(function(arg) {
890
- return arg != null;
891
- });
892
- for (var i in args)
893
- if ("string" !== typeof args[i])
894
- return;
895
- var file2 = path6.join.apply(null, args);
896
- try {
897
- return fs4.readFileSync(file2, "utf-8");
898
- } catch (err) {
899
- return;
900
- }
901
- };
902
- exports$1.json = function() {
903
- var content = file.apply(null, arguments);
904
- return content ? parse(content) : null;
905
- };
906
- exports$1.env = function(prefix, env2) {
907
- env2 = env2 || process.env;
908
- var obj = {};
909
- var l = prefix.length;
910
- for (var k in env2) {
911
- if (k.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
912
- var keypath = k.substring(l).split("__");
913
- var _emptyStringIndex;
914
- while ((_emptyStringIndex = keypath.indexOf("")) > -1) {
915
- keypath.splice(_emptyStringIndex, 1);
916
- }
917
- var cursor = obj;
918
- keypath.forEach(/* @__PURE__ */ __name(function _buildSubObj(_subkey, i) {
919
- if (!_subkey || typeof cursor !== "object")
920
- return;
921
- if (i === keypath.length - 1)
922
- cursor[_subkey] = env2[k];
923
- if (cursor[_subkey] === void 0)
924
- cursor[_subkey] = {};
925
- cursor = cursor[_subkey];
926
- }, "_buildSubObj"));
927
- }
928
- }
929
- return obj;
930
- };
931
- exports$1.find = function() {
932
- var rel = path6.join.apply(null, [].slice.call(arguments));
933
- function find2(start, rel2) {
934
- var file2 = path6.join(start, rel2);
935
- try {
936
- fs4.statSync(file2);
937
- return file2;
938
- } catch (err) {
939
- if (path6.dirname(start) !== start)
940
- return find2(path6.dirname(start), rel2);
941
- }
942
- }
943
- __name(find2, "find");
944
- return find2(process.cwd(), rel);
945
- };
946
- }
947
- });
948
-
949
- // ../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js
950
- var require_deep_extend = __commonJS({
951
- "../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js"(exports$1, module) {
952
- function isSpecificValue(val) {
953
- return val instanceof Buffer || val instanceof Date || val instanceof RegExp ? true : false;
954
- }
955
- __name(isSpecificValue, "isSpecificValue");
956
- function cloneSpecificValue(val) {
957
- if (val instanceof Buffer) {
958
- var x = Buffer.alloc ? Buffer.alloc(val.length) : new Buffer(val.length);
959
- val.copy(x);
960
- return x;
961
- } else if (val instanceof Date) {
962
- return new Date(val.getTime());
963
- } else if (val instanceof RegExp) {
964
- return new RegExp(val);
965
- } else {
966
- throw new Error("Unexpected situation");
967
- }
968
- }
969
- __name(cloneSpecificValue, "cloneSpecificValue");
970
- function deepCloneArray(arr) {
971
- var clone = [];
972
- arr.forEach(function(item, index) {
973
- if (typeof item === "object" && item !== null) {
974
- if (Array.isArray(item)) {
975
- clone[index] = deepCloneArray(item);
976
- } else if (isSpecificValue(item)) {
977
- clone[index] = cloneSpecificValue(item);
978
- } else {
979
- clone[index] = deepExtend({}, item);
980
- }
981
- } else {
982
- clone[index] = item;
983
- }
984
- });
985
- return clone;
986
- }
987
- __name(deepCloneArray, "deepCloneArray");
988
- function safeGetProperty(object, property) {
989
- return property === "__proto__" ? void 0 : object[property];
990
- }
991
- __name(safeGetProperty, "safeGetProperty");
992
- var deepExtend = module.exports = function() {
993
- if (arguments.length < 1 || typeof arguments[0] !== "object") {
994
- return false;
995
- }
996
- if (arguments.length < 2) {
997
- return arguments[0];
998
- }
999
- var target = arguments[0];
1000
- var args = Array.prototype.slice.call(arguments, 1);
1001
- var val, src;
1002
- args.forEach(function(obj) {
1003
- if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
1004
- return;
1005
- }
1006
- Object.keys(obj).forEach(function(key) {
1007
- src = safeGetProperty(target, key);
1008
- val = safeGetProperty(obj, key);
1009
- if (val === target) {
1010
- return;
1011
- } else if (typeof val !== "object" || val === null) {
1012
- target[key] = val;
1013
- return;
1014
- } else if (Array.isArray(val)) {
1015
- target[key] = deepCloneArray(val);
1016
- return;
1017
- } else if (isSpecificValue(val)) {
1018
- target[key] = cloneSpecificValue(val);
1019
- return;
1020
- } else if (typeof src !== "object" || src === null || Array.isArray(src)) {
1021
- target[key] = deepExtend({}, val);
1022
- return;
1023
- } else {
1024
- target[key] = deepExtend(src, val);
1025
- return;
1026
- }
1027
- });
1028
- });
1029
- return target;
1030
- };
1031
- }
1032
- });
1033
-
1034
- // ../../node_modules/.pnpm/minimist@1.2.6/node_modules/minimist/index.js
1035
- var require_minimist = __commonJS({
1036
- "../../node_modules/.pnpm/minimist@1.2.6/node_modules/minimist/index.js"(exports$1, module) {
1037
- module.exports = function(args, opts) {
1038
- if (!opts) opts = {};
1039
- var flags = { bools: {}, strings: {}, unknownFn: null };
1040
- if (typeof opts["unknown"] === "function") {
1041
- flags.unknownFn = opts["unknown"];
1042
- }
1043
- if (typeof opts["boolean"] === "boolean" && opts["boolean"]) {
1044
- flags.allBools = true;
1045
- } else {
1046
- [].concat(opts["boolean"]).filter(Boolean).forEach(function(key2) {
1047
- flags.bools[key2] = true;
1048
- });
1049
- }
1050
- var aliases = {};
1051
- Object.keys(opts.alias || {}).forEach(function(key2) {
1052
- aliases[key2] = [].concat(opts.alias[key2]);
1053
- aliases[key2].forEach(function(x) {
1054
- aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
1055
- return x !== y;
1056
- }));
1057
- });
1058
- });
1059
- [].concat(opts.string).filter(Boolean).forEach(function(key2) {
1060
- flags.strings[key2] = true;
1061
- if (aliases[key2]) {
1062
- flags.strings[aliases[key2]] = true;
1063
- }
1064
- });
1065
- var defaults = opts["default"] || {};
1066
- var argv = { _: [] };
1067
- Object.keys(flags.bools).forEach(function(key2) {
1068
- setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
1069
- });
1070
- var notFlags = [];
1071
- if (args.indexOf("--") !== -1) {
1072
- notFlags = args.slice(args.indexOf("--") + 1);
1073
- args = args.slice(0, args.indexOf("--"));
1074
- }
1075
- function argDefined(key2, arg2) {
1076
- return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
1077
- }
1078
- __name(argDefined, "argDefined");
1079
- function setArg(key2, val, arg2) {
1080
- if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
1081
- if (flags.unknownFn(arg2) === false) return;
1082
- }
1083
- var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
1084
- setKey(argv, key2.split("."), value2);
1085
- (aliases[key2] || []).forEach(function(x) {
1086
- setKey(argv, x.split("."), value2);
1087
- });
1088
- }
1089
- __name(setArg, "setArg");
1090
- function setKey(obj, keys, value2) {
1091
- var o = obj;
1092
- for (var i2 = 0; i2 < keys.length - 1; i2++) {
1093
- var key2 = keys[i2];
1094
- if (isConstructorOrProto(o, key2)) return;
1095
- if (o[key2] === void 0) o[key2] = {};
1096
- if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) o[key2] = {};
1097
- if (o[key2] === Array.prototype) o[key2] = [];
1098
- o = o[key2];
1099
- }
1100
- var key2 = keys[keys.length - 1];
1101
- if (isConstructorOrProto(o, key2)) return;
1102
- if (o === Object.prototype || o === Number.prototype || o === String.prototype) o = {};
1103
- if (o === Array.prototype) o = [];
1104
- if (o[key2] === void 0 || flags.bools[key2] || typeof o[key2] === "boolean") {
1105
- o[key2] = value2;
1106
- } else if (Array.isArray(o[key2])) {
1107
- o[key2].push(value2);
1108
- } else {
1109
- o[key2] = [o[key2], value2];
1110
- }
1111
- }
1112
- __name(setKey, "setKey");
1113
- function aliasIsBoolean(key2) {
1114
- return aliases[key2].some(function(x) {
1115
- return flags.bools[x];
1116
- });
1117
- }
1118
- __name(aliasIsBoolean, "aliasIsBoolean");
1119
- for (var i = 0; i < args.length; i++) {
1120
- var arg = args[i];
1121
- if (/^--.+=/.test(arg)) {
1122
- var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
1123
- var key = m[1];
1124
- var value = m[2];
1125
- if (flags.bools[key]) {
1126
- value = value !== "false";
1127
- }
1128
- setArg(key, value, arg);
1129
- } else if (/^--no-.+/.test(arg)) {
1130
- var key = arg.match(/^--no-(.+)/)[1];
1131
- setArg(key, false, arg);
1132
- } else if (/^--.+/.test(arg)) {
1133
- var key = arg.match(/^--(.+)/)[1];
1134
- var next = args[i + 1];
1135
- if (next !== void 0 && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
1136
- setArg(key, next, arg);
1137
- i++;
1138
- } else if (/^(true|false)$/.test(next)) {
1139
- setArg(key, next === "true", arg);
1140
- i++;
1141
- } else {
1142
- setArg(key, flags.strings[key] ? "" : true, arg);
1143
- }
1144
- } else if (/^-[^-]+/.test(arg)) {
1145
- var letters = arg.slice(1, -1).split("");
1146
- var broken = false;
1147
- for (var j = 0; j < letters.length; j++) {
1148
- var next = arg.slice(j + 2);
1149
- if (next === "-") {
1150
- setArg(letters[j], next, arg);
1151
- continue;
1152
- }
1153
- if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
1154
- setArg(letters[j], next.split("=")[1], arg);
1155
- broken = true;
1156
- break;
1157
- }
1158
- if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
1159
- setArg(letters[j], next, arg);
1160
- broken = true;
1161
- break;
1162
- }
1163
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
1164
- setArg(letters[j], arg.slice(j + 2), arg);
1165
- broken = true;
1166
- break;
1167
- } else {
1168
- setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
1169
- }
1170
- }
1171
- var key = arg.slice(-1)[0];
1172
- if (!broken && key !== "-") {
1173
- if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
1174
- setArg(key, args[i + 1], arg);
1175
- i++;
1176
- } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
1177
- setArg(key, args[i + 1] === "true", arg);
1178
- i++;
1179
- } else {
1180
- setArg(key, flags.strings[key] ? "" : true, arg);
1181
- }
1182
- }
1183
- } else {
1184
- if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
1185
- argv._.push(
1186
- flags.strings["_"] || !isNumber(arg) ? arg : Number(arg)
1187
- );
1188
- }
1189
- if (opts.stopEarly) {
1190
- argv._.push.apply(argv._, args.slice(i + 1));
1191
- break;
1192
- }
1193
- }
1194
- }
1195
- Object.keys(defaults).forEach(function(key2) {
1196
- if (!hasKey(argv, key2.split("."))) {
1197
- setKey(argv, key2.split("."), defaults[key2]);
1198
- (aliases[key2] || []).forEach(function(x) {
1199
- setKey(argv, x.split("."), defaults[key2]);
1200
- });
1201
- }
1202
- });
1203
- if (opts["--"]) {
1204
- argv["--"] = new Array();
1205
- notFlags.forEach(function(key2) {
1206
- argv["--"].push(key2);
1207
- });
1208
- } else {
1209
- notFlags.forEach(function(key2) {
1210
- argv._.push(key2);
1211
- });
1212
- }
1213
- return argv;
1214
- };
1215
- function hasKey(obj, keys) {
1216
- var o = obj;
1217
- keys.slice(0, -1).forEach(function(key2) {
1218
- o = o[key2] || {};
1219
- });
1220
- var key = keys[keys.length - 1];
1221
- return key in o;
1222
- }
1223
- __name(hasKey, "hasKey");
1224
- function isNumber(x) {
1225
- if (typeof x === "number") return true;
1226
- if (/^0x[0-9a-f]+$/i.test(x)) return true;
1227
- return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
1228
- }
1229
- __name(isNumber, "isNumber");
1230
- function isConstructorOrProto(obj, key) {
1231
- return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
1232
- }
1233
- __name(isConstructorOrProto, "isConstructorOrProto");
1234
- }
1235
- });
1236
-
1237
- // ../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js
1238
- var require_rc = __commonJS({
1239
- "../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports$1, module) {
1240
- var cc = require_utils();
1241
- var join3 = __require("path").join;
1242
- var deepExtend = require_deep_extend();
1243
- var etc = "/etc";
1244
- var win = process.platform === "win32";
1245
- var home = win ? process.env.USERPROFILE : process.env.HOME;
1246
- module.exports = function(name, defaults, argv, parse) {
1247
- if ("string" !== typeof name)
1248
- throw new Error("rc(name): name *must* be string");
1249
- if (!argv)
1250
- argv = require_minimist()(process.argv.slice(2));
1251
- defaults = ("string" === typeof defaults ? cc.json(defaults) : defaults) || {};
1252
- parse = parse || cc.parse;
1253
- var env = cc.env(name + "_");
1254
- var configs = [defaults];
1255
- var configFiles = [];
1256
- function addConfigFile(file) {
1257
- if (configFiles.indexOf(file) >= 0) return;
1258
- var fileConfig = cc.file(file);
1259
- if (fileConfig) {
1260
- configs.push(parse(fileConfig));
1261
- configFiles.push(file);
1262
- }
1263
- }
1264
- __name(addConfigFile, "addConfigFile");
1265
- if (!win)
1266
- [
1267
- join3(etc, name, "config"),
1268
- join3(etc, name + "rc")
1269
- ].forEach(addConfigFile);
1270
- if (home)
1271
- [
1272
- join3(home, ".config", name, "config"),
1273
- join3(home, ".config", name),
1274
- join3(home, "." + name, "config"),
1275
- join3(home, "." + name + "rc")
1276
- ].forEach(addConfigFile);
1277
- addConfigFile(cc.find("." + name + "rc"));
1278
- if (env.config) addConfigFile(env.config);
1279
- if (argv.config) addConfigFile(argv.config);
1280
- return deepExtend.apply(null, configs.concat([
1281
- env,
1282
- argv,
1283
- configFiles.length ? { configs: configFiles, config: configFiles[configFiles.length - 1] } : void 0
1284
- ]));
1285
- };
1286
- }
1287
- });
1288
-
1289
- // ../../node_modules/.pnpm/registry-url@3.1.0/node_modules/registry-url/index.js
1290
- var require_registry_url = __commonJS({
1291
- "../../node_modules/.pnpm/registry-url@3.1.0/node_modules/registry-url/index.js"(exports$1, module) {
1292
- module.exports = function(scope) {
1293
- var rc = require_rc()("npm", { registry: "https://registry.npmjs.org/" });
1294
- var url = rc[scope + ":registry"] || rc.registry;
1295
- return url.slice(-1) === "/" ? url : url + "/";
1296
- };
1297
- }
1298
- });
1299
-
1300
- // ../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js
1301
- var require_safe_buffer = __commonJS({
1302
- "../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports$1, module) {
1303
- var buffer = __require("buffer");
1304
- var Buffer2 = buffer.Buffer;
1305
- function copyProps(src, dst) {
1306
- for (var key in src) {
1307
- dst[key] = src[key];
1308
- }
1309
- }
1310
- __name(copyProps, "copyProps");
1311
- if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
1312
- module.exports = buffer;
1313
- } else {
1314
- copyProps(buffer, exports$1);
1315
- exports$1.Buffer = SafeBuffer;
1316
- }
1317
- function SafeBuffer(arg, encodingOrOffset, length) {
1318
- return Buffer2(arg, encodingOrOffset, length);
1319
- }
1320
- __name(SafeBuffer, "SafeBuffer");
1321
- SafeBuffer.prototype = Object.create(Buffer2.prototype);
1322
- copyProps(Buffer2, SafeBuffer);
1323
- SafeBuffer.from = function(arg, encodingOrOffset, length) {
1324
- if (typeof arg === "number") {
1325
- throw new TypeError("Argument must not be a number");
1326
- }
1327
- return Buffer2(arg, encodingOrOffset, length);
1328
- };
1329
- SafeBuffer.alloc = function(size, fill, encoding) {
1330
- if (typeof size !== "number") {
1331
- throw new TypeError("Argument must be a number");
1332
- }
1333
- var buf = Buffer2(size);
1334
- if (fill !== void 0) {
1335
- if (typeof encoding === "string") {
1336
- buf.fill(fill, encoding);
1337
- } else {
1338
- buf.fill(fill);
1339
- }
1340
- } else {
1341
- buf.fill(0);
1342
- }
1343
- return buf;
1344
- };
1345
- SafeBuffer.allocUnsafe = function(size) {
1346
- if (typeof size !== "number") {
1347
- throw new TypeError("Argument must be a number");
1348
- }
1349
- return Buffer2(size);
1350
- };
1351
- SafeBuffer.allocUnsafeSlow = function(size) {
1352
- if (typeof size !== "number") {
1353
- throw new TypeError("Argument must be a number");
1354
- }
1355
- return buffer.SlowBuffer(size);
1356
- };
1357
- }
1358
- });
1359
-
1360
- // ../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/base64.js
1361
- var require_base64 = __commonJS({
1362
- "../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/base64.js"(exports$1, module) {
1363
- var safeBuffer = require_safe_buffer().Buffer;
1364
- function decodeBase64(base64) {
1365
- return safeBuffer.from(base64, "base64").toString("utf8");
1366
- }
1367
- __name(decodeBase64, "decodeBase64");
1368
- function encodeBase64(string) {
1369
- return safeBuffer.from(string, "utf8").toString("base64");
1370
- }
1371
- __name(encodeBase64, "encodeBase64");
1372
- module.exports = {
1373
- decodeBase64,
1374
- encodeBase64
1375
- };
1376
- }
1377
- });
1378
-
1379
- // ../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/index.js
1380
- var require_registry_auth_token = __commonJS({
1381
- "../../node_modules/.pnpm/registry-auth-token@3.3.2/node_modules/registry-auth-token/index.js"(exports$1, module) {
1382
- var url = __require("url");
1383
- var base64 = require_base64();
1384
- var decodeBase64 = base64.decodeBase64;
1385
- var encodeBase64 = base64.encodeBase64;
1386
- var tokenKey = ":_authToken";
1387
- var userKey = ":username";
1388
- var passwordKey = ":_password";
1389
- module.exports = function() {
1390
- var checkUrl;
1391
- var options;
1392
- if (arguments.length >= 2) {
1393
- checkUrl = arguments[0];
1394
- options = arguments[1];
1395
- } else if (typeof arguments[0] === "string") {
1396
- checkUrl = arguments[0];
1397
- } else {
1398
- options = arguments[0];
1399
- }
1400
- options = options || {};
1401
- options.npmrc = options.npmrc || require_rc()("npm", { registry: "https://registry.npmjs.org/" });
1402
- checkUrl = checkUrl || options.npmrc.registry;
1403
- return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc);
1404
- };
1405
- function getRegistryAuthInfo(checkUrl, options) {
1406
- var parsed = url.parse(checkUrl, false, true);
1407
- var pathname;
1408
- while (pathname !== "/" && parsed.pathname !== pathname) {
1409
- pathname = parsed.pathname || "/";
1410
- var regUrl = "//" + parsed.host + pathname.replace(/\/$/, "");
1411
- var authInfo = getAuthInfoForUrl(regUrl, options.npmrc);
1412
- if (authInfo) {
1413
- return authInfo;
1414
- }
1415
- if (!options.recursive) {
1416
- return /\/$/.test(checkUrl) ? void 0 : getRegistryAuthInfo(url.resolve(checkUrl, "."), options);
1417
- }
1418
- parsed.pathname = url.resolve(normalizePath(pathname), "..") || "/";
1419
- }
1420
- return void 0;
1421
- }
1422
- __name(getRegistryAuthInfo, "getRegistryAuthInfo");
1423
- function getLegacyAuthInfo(npmrc) {
1424
- if (npmrc._auth) {
1425
- return { token: npmrc._auth, type: "Basic" };
1426
- }
1427
- return void 0;
1428
- }
1429
- __name(getLegacyAuthInfo, "getLegacyAuthInfo");
1430
- function normalizePath(path6) {
1431
- return path6[path6.length - 1] === "/" ? path6 : path6 + "/";
1432
- }
1433
- __name(normalizePath, "normalizePath");
1434
- function getAuthInfoForUrl(regUrl, npmrc) {
1435
- var bearerAuth = getBearerToken(npmrc[regUrl + tokenKey] || npmrc[regUrl + "/" + tokenKey]);
1436
- if (bearerAuth) {
1437
- return bearerAuth;
1438
- }
1439
- var username = npmrc[regUrl + userKey] || npmrc[regUrl + "/" + userKey];
1440
- var password = npmrc[regUrl + passwordKey] || npmrc[regUrl + "/" + passwordKey];
1441
- var basicAuth = getTokenForUsernameAndPassword(username, password);
1442
- if (basicAuth) {
1443
- return basicAuth;
1444
- }
1445
- return void 0;
1446
- }
1447
- __name(getAuthInfoForUrl, "getAuthInfoForUrl");
1448
- function getBearerToken(tok) {
1449
- if (!tok) {
1450
- return void 0;
1451
- }
1452
- var token = tok.replace(/^\$\{?([^}]*)\}?$/, function(fullMatch, envVar) {
1453
- return process.env[envVar];
1454
- });
1455
- return { token, type: "Bearer" };
1456
- }
1457
- __name(getBearerToken, "getBearerToken");
1458
- function getTokenForUsernameAndPassword(username, password) {
1459
- if (!username || !password) {
1460
- return void 0;
1461
- }
1462
- var pass = decodeBase64(password.replace(/^\$\{?([^}]*)\}?$/, function(fullMatch, envVar) {
1463
- return process.env[envVar];
1464
- }));
1465
- var token = encodeBase64(username + ":" + pass);
1466
- return {
1467
- token,
1468
- type: "Basic",
1469
- password: pass,
1470
- username
1471
- };
1472
- }
1473
- __name(getTokenForUsernameAndPassword, "getTokenForUsernameAndPassword");
1474
- }
1475
- });
1476
-
1477
- // ../../node_modules/.pnpm/update-check@1.5.4/node_modules/update-check/index.js
1478
- var require_update_check = __commonJS({
1479
- "../../node_modules/.pnpm/update-check@1.5.4/node_modules/update-check/index.js"(exports$1, module) {
1480
- var { URL: URL2 } = __require("url");
1481
- var { join: join3 } = __require("path");
1482
- var fs4 = __require("fs");
1483
- var { promisify } = __require("util");
1484
- var { tmpdir } = __require("os");
1485
- var registryUrl = require_registry_url();
1486
- var writeFile = promisify(fs4.writeFile);
1487
- var mkdir = promisify(fs4.mkdir);
1488
- var readFile = promisify(fs4.readFile);
1489
- var compareVersions = /* @__PURE__ */ __name((a, b) => a.localeCompare(b, "en-US", { numeric: true }), "compareVersions");
1490
- var encode = /* @__PURE__ */ __name((value) => encodeURIComponent(value).replace(/^%40/, "@"), "encode");
1491
- var getFile = /* @__PURE__ */ __name(async (details, distTag) => {
1492
- const rootDir = tmpdir();
1493
- const subDir = join3(rootDir, "update-check");
1494
- if (!fs4.existsSync(subDir)) {
1495
- await mkdir(subDir);
1496
- }
1497
- let name = `${details.name}-${distTag}.json`;
1498
- if (details.scope) {
1499
- name = `${details.scope}-${name}`;
1500
- }
1501
- return join3(subDir, name);
1502
- }, "getFile");
1503
- var evaluateCache = /* @__PURE__ */ __name(async (file, time, interval) => {
1504
- if (fs4.existsSync(file)) {
1505
- const content = await readFile(file, "utf8");
1506
- const { lastUpdate, latest } = JSON.parse(content);
1507
- const nextCheck = lastUpdate + interval;
1508
- if (nextCheck > time) {
1509
- return {
1510
- shouldCheck: false,
1511
- latest
1512
- };
1513
- }
1514
- }
1515
- return {
1516
- shouldCheck: true,
1517
- latest: null
1518
- };
1519
- }, "evaluateCache");
1520
- var updateCache = /* @__PURE__ */ __name(async (file, latest, lastUpdate) => {
1521
- const content = JSON.stringify({
1522
- latest,
1523
- lastUpdate
1524
- });
1525
- await writeFile(file, content, "utf8");
1526
- }, "updateCache");
1527
- var loadPackage = /* @__PURE__ */ __name((url, authInfo) => new Promise((resolve3, reject) => {
1528
- const options = {
1529
- host: url.hostname,
1530
- path: url.pathname,
1531
- port: url.port,
1532
- headers: {
1533
- accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
1534
- },
1535
- timeout: 2e3
1536
- };
1537
- if (authInfo) {
1538
- options.headers.authorization = `${authInfo.type} ${authInfo.token}`;
1539
- }
1540
- const { get } = url.protocol === "https:" ? __require("https") : __require("http");
1541
- get(options, (response) => {
1542
- const { statusCode } = response;
1543
- if (statusCode !== 200) {
1544
- const error = new Error(`Request failed with code ${statusCode}`);
1545
- error.code = statusCode;
1546
- reject(error);
1547
- response.resume();
1548
- return;
1549
- }
1550
- let rawData = "";
1551
- response.setEncoding("utf8");
1552
- response.on("data", (chunk) => {
1553
- rawData += chunk;
1554
- });
1555
- response.on("end", () => {
1556
- try {
1557
- const parsedData = JSON.parse(rawData);
1558
- resolve3(parsedData);
1559
- } catch (e2) {
1560
- reject(e2);
1561
- }
1562
- });
1563
- }).on("error", reject).on("timeout", reject);
1564
- }), "loadPackage");
1565
- var getMostRecent = /* @__PURE__ */ __name(async ({ full, scope }, distTag) => {
1566
- const regURL = registryUrl(scope);
1567
- const url = new URL2(full, regURL);
1568
- let spec = null;
1569
- try {
1570
- spec = await loadPackage(url);
1571
- } catch (err) {
1572
- if (err.code && String(err.code).startsWith(4)) {
1573
- const registryAuthToken = require_registry_auth_token();
1574
- const authInfo = registryAuthToken(regURL, { recursive: true });
1575
- spec = await loadPackage(url, authInfo);
1576
- } else {
1577
- throw err;
1578
- }
1579
- }
1580
- const version = spec["dist-tags"][distTag];
1581
- if (!version) {
1582
- throw new Error(`Distribution tag ${distTag} is not available`);
1583
- }
1584
- return version;
1585
- }, "getMostRecent");
1586
- var defaultConfig = {
1587
- interval: 36e5,
1588
- distTag: "latest"
1589
- };
1590
- var getDetails = /* @__PURE__ */ __name((name) => {
1591
- const spec = {
1592
- full: encode(name)
1593
- };
1594
- if (name.includes("/")) {
1595
- const parts = name.split("/");
1596
- spec.scope = parts[0];
1597
- spec.name = parts[1];
1598
- } else {
1599
- spec.scope = null;
1600
- spec.name = name;
1601
- }
1602
- return spec;
1603
- }, "getDetails");
1604
- module.exports = async (pkg, config) => {
1605
- if (typeof pkg !== "object") {
1606
- throw new Error("The first parameter should be your package.json file content");
1607
- }
1608
- const details = getDetails(pkg.name);
1609
- const time = Date.now();
1610
- const { distTag, interval } = Object.assign({}, defaultConfig, config);
1611
- const file = await getFile(details, distTag);
1612
- let latest = null;
1613
- let shouldCheck = true;
1614
- ({ shouldCheck, latest } = await evaluateCache(file, time, interval));
1615
- if (shouldCheck) {
1616
- latest = await getMostRecent(details, distTag);
1617
- await updateCache(file, latest, time);
1618
- }
1619
- const comparision = compareVersions(pkg.version, latest);
1620
- if (comparision === -1) {
1621
- return {
1622
- latest,
1623
- fromCache: !shouldCheck
1624
- };
1625
- }
1626
- return null;
1627
- };
1628
- }
1629
- });
1630
-
1631
641
  // ../../node_modules/.pnpm/minimatch@5.1.6/node_modules/minimatch/lib/path.js
1632
642
  var require_path = __commonJS({
1633
643
  "../../node_modules/.pnpm/minimatch@5.1.6/node_modules/minimatch/lib/path.js"(exports$1, module) {
@@ -1867,8 +877,8 @@ var require_minimatch = __commonJS({
1867
877
  return new Minimatch2(pattern, options).match(p);
1868
878
  };
1869
879
  module.exports = minimatch;
1870
- var path6 = require_path();
1871
- minimatch.sep = path6.sep;
880
+ var path7 = require_path();
881
+ minimatch.sep = path7.sep;
1872
882
  var GLOBSTAR = Symbol("globstar **");
1873
883
  minimatch.GLOBSTAR = GLOBSTAR;
1874
884
  var expand = require_brace_expansion();
@@ -2383,8 +1393,8 @@ var require_minimatch = __commonJS({
2383
1393
  if (this.empty) return f === "";
2384
1394
  if (f === "/" && partial) return true;
2385
1395
  const options = this.options;
2386
- if (path6.sep !== "/") {
2387
- f = f.split(path6.sep).join("/");
1396
+ if (path7.sep !== "/") {
1397
+ f = f.split(path7.sep).join("/");
2388
1398
  }
2389
1399
  f = f.split(slashSplit);
2390
1400
  this.debug(this.pattern, "split", f);
@@ -2780,9 +1790,9 @@ Please add "${field}" to "env.${envName}".`
2780
1790
  return rawEnv[field] ?? defaultValue;
2781
1791
  }
2782
1792
  __name(notInheritable, "notInheritable");
2783
- function unwindPropertyPath(root, path6) {
1793
+ function unwindPropertyPath(root, path7) {
2784
1794
  let container = root;
2785
- const parts = path6.split(".");
1795
+ const parts = path7.split(".");
2786
1796
  for (let i = 0; i < parts.length - 1; i++) {
2787
1797
  if (!hasProperty(container, parts[i])) {
2788
1798
  return;
@@ -13133,21 +12143,16 @@ The local dev server started at ${origin.href}
13133
12143
  return new Error(errorMessage);
13134
12144
  }
13135
12145
  __name(createTunnelStartupError, "createTunnelStartupError");
13136
-
13137
- // src/update-check.ts
13138
- var import_update_check = __toESM(require_update_check());
13139
12146
  var UPDATE_CHECK_TIMEOUT_MS = 3e3;
12147
+ var CACHE_TTL_MS = 60 * 60 * 1e3;
12148
+ var NPM_REGISTRY_URL = "https://registry.npmjs.org/";
13140
12149
  var TIMED_OUT = Symbol("timed_out");
13141
12150
  async function fetchLatestNpmVersion(name, version) {
13142
- let result = null;
12151
+ const distTag = version.startsWith("0.0.0") ? "beta" : "latest";
12152
+ let latest;
13143
12153
  try {
13144
- result = await Promise.race([
13145
- (0, import_update_check.default)(
13146
- { name, version },
13147
- {
13148
- distTag: version.startsWith("0.0.0") ? "beta" : "latest"
13149
- }
13150
- ),
12154
+ latest = await Promise.race([
12155
+ getLatestVersion(name, distTag),
13151
12156
  timersPromises.setTimeout(UPDATE_CHECK_TIMEOUT_MS, TIMED_OUT, {
13152
12157
  ref: false
13153
12158
  })
@@ -13155,15 +12160,91 @@ async function fetchLatestNpmVersion(name, version) {
13155
12160
  } catch {
13156
12161
  return { status: "failed" };
13157
12162
  }
13158
- if (result === TIMED_OUT) {
12163
+ if (latest === TIMED_OUT) {
13159
12164
  return { status: "failed" };
13160
12165
  }
13161
- if (result === null) {
12166
+ if (latest === null || compareVersions(version, latest) >= 0) {
13162
12167
  return { status: "up-to-date" };
13163
12168
  }
13164
- return { status: "update-available", latest: result.latest };
12169
+ return { status: "update-available", latest };
13165
12170
  }
13166
12171
  __name(fetchLatestNpmVersion, "fetchLatestNpmVersion");
12172
+ async function getLatestVersion(name, distTag) {
12173
+ const cacheFile = getCacheFile(name, distTag);
12174
+ const now = Date.now();
12175
+ const cached = await readCache(cacheFile);
12176
+ if (cached !== null && cached.lastUpdate + CACHE_TTL_MS > now) {
12177
+ return cached.latest;
12178
+ }
12179
+ const latest = pickLatestVersion(await fetchPackument(name), distTag);
12180
+ await writeCache(cacheFile, { latest, lastUpdate: now });
12181
+ return latest;
12182
+ }
12183
+ __name(getLatestVersion, "getLatestVersion");
12184
+ function pickLatestVersion(packument, distTag) {
12185
+ const tagged = packument["dist-tags"][distTag];
12186
+ if (tagged === void 0) {
12187
+ throw new Error(`Distribution tag ${distTag} is not available`);
12188
+ }
12189
+ if (!packument.versions[tagged]?.deprecated) {
12190
+ return tagged;
12191
+ }
12192
+ if (distTag !== "latest") {
12193
+ return null;
12194
+ }
12195
+ const candidates = Object.entries(packument.versions).filter(
12196
+ ([candidate, meta]) => !meta.deprecated && !candidate.includes("-") && compareVersions(candidate, tagged) < 0
12197
+ ).map(([candidate]) => candidate).sort(compareVersions);
12198
+ return candidates.at(-1) ?? null;
12199
+ }
12200
+ __name(pickLatestVersion, "pickLatestVersion");
12201
+ async function fetchPackument(name) {
12202
+ const packageUrl = new URL(encodeURIComponent(name), NPM_REGISTRY_URL);
12203
+ const response = await fetch(packageUrl, {
12204
+ headers: {
12205
+ accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
12206
+ },
12207
+ signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)
12208
+ });
12209
+ if (!response.ok) {
12210
+ throw new Error(`Request failed with code ${response.status}`);
12211
+ }
12212
+ return await response.json();
12213
+ }
12214
+ __name(fetchPackument, "fetchPackument");
12215
+ function getCacheFile(name, distTag) {
12216
+ return path__default.join(
12217
+ tmpdir(),
12218
+ "update-check",
12219
+ `${name.replace("/", "-")}-${distTag}.json`
12220
+ );
12221
+ }
12222
+ __name(getCacheFile, "getCacheFile");
12223
+ async function readCache(file) {
12224
+ try {
12225
+ const parsed = JSON.parse(
12226
+ await readFile(file, "utf8")
12227
+ );
12228
+ if (typeof parsed.lastUpdate === "number" && (typeof parsed.latest === "string" || parsed.latest === null)) {
12229
+ return { latest: parsed.latest, lastUpdate: parsed.lastUpdate };
12230
+ }
12231
+ } catch {
12232
+ }
12233
+ return null;
12234
+ }
12235
+ __name(readCache, "readCache");
12236
+ async function writeCache(file, cache) {
12237
+ try {
12238
+ await mkdir(path__default.dirname(file), { recursive: true });
12239
+ await writeFile(file, JSON.stringify(cache), "utf8");
12240
+ } catch {
12241
+ }
12242
+ }
12243
+ __name(writeCache, "writeCache");
12244
+ function compareVersions(a, b) {
12245
+ return a.localeCompare(b, "en-US", { numeric: true });
12246
+ }
12247
+ __name(compareVersions, "compareVersions");
13167
12248
 
13168
12249
  // src/logger.ts
13169
12250
  var LOGGER_LEVELS = {
@@ -13551,38 +12632,5 @@ __name(leadingMigrationNumber, "leadingMigrationNumber");
13551
12632
 
13552
12633
  // src/index.ts
13553
12634
  var friendlyBindingNames2 = friendlyBindingNames;
13554
- /*! Bundled license information:
13555
-
13556
- deep-extend/lib/deep-extend.js:
13557
- (*!
13558
- * @description Recursive object extending
13559
- * @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
13560
- * @license MIT
13561
- *
13562
- * The MIT License (MIT)
13563
- *
13564
- * Copyright (c) 2013-2018 Viacheslav Lotsmanov
13565
- *
13566
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
13567
- * this software and associated documentation files (the "Software"), to deal in
13568
- * the Software without restriction, including without limitation the rights to
13569
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13570
- * the Software, and to permit persons to whom the Software is furnished to do so,
13571
- * subject to the following conditions:
13572
- *
13573
- * The above copyright notice and this permission notice shall be included in all
13574
- * copies or substantial portions of the Software.
13575
- *
13576
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13577
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13578
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13579
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13580
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
13581
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13582
- *)
13583
-
13584
- safe-buffer/index.js:
13585
- (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
13586
- */
13587
12635
 
13588
12636
  export { ARTIFACTS_EVENT_TYPES, BunPackageManager, DEFAULT_COMPAT_DATE, Diagnostics, LOGGER_LEVELS, NpmPackageManager, NubPackageManager, PatchConfigError, PnpmPackageManager, YarnPackageManager, addAuthorizationHeader, assertNever, bucketFormatMessage, checkWorkerNameValidity, clearOutputFilePath, compareMigrationPaths, constructWranglerConfig, convertConfigToBindings, createConfigCache, defaultWranglerConfig, experimental_patchConfig, extractAccountTag, extractBindingsOfType, extractWAFBlockRayId, fetchInternalBase, fetchKVGetValueBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, formatTime, friendlyBindingNames2 as friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBindings, getD1MigrationFiles, getHostFromRoute, getHostFromUrl, getInstalledPackageVersion, getPackagePath, getWorkerName, getWorkerNameFromProject, getWranglerHiddenDirPath, getWranglerTmpDir, getZoneFromRoute, hasCursor, hasMorePages, hasProperty, isCI, isDockerfile, isInteractive, isNonInteractiveOrCI, isOptionalProperty, isPackageInstalled, isPagesConfig, isRequiredProperty, isUnsafeBindingType, isValidR2BucketName, isWAFBlockResponse, mapWorkerMetadataBindings, maybeAddTraceHeader, normalizeAndValidateConfig, normalizeRelativePath, openInBrowser, parseRetryAfterMs, parseRetryAfterValue, performApiFetchBase, printBindings, renderError, resolveNamedTunnel, retryOnAPIFailure, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, toUrlPath, toValidWorkerName, truncate, validateBindingRemoteSetting, validatePagesConfig, writeOutput };