@hot-updater/cloudflare 0.30.12 → 0.31.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.
@@ -1711,8 +1711,8 @@ var require_compare = __commonJS({
1711
1711
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1712
1712
  init_performance2();
1713
1713
  var SemVer = require_semver();
1714
- var compare = /* @__PURE__ */ __name((a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)), "compare");
1715
- module.exports = compare;
1714
+ var compare2 = /* @__PURE__ */ __name((a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)), "compare");
1715
+ module.exports = compare2;
1716
1716
  }
1717
1717
  });
1718
1718
 
@@ -1723,8 +1723,8 @@ var require_rcompare = __commonJS({
1723
1723
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1724
1724
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1725
1725
  init_performance2();
1726
- var compare = require_compare();
1727
- var rcompare = /* @__PURE__ */ __name((a, b, loose) => compare(b, a, loose), "rcompare");
1726
+ var compare2 = require_compare();
1727
+ var rcompare = /* @__PURE__ */ __name((a, b, loose) => compare2(b, a, loose), "rcompare");
1728
1728
  module.exports = rcompare;
1729
1729
  }
1730
1730
  });
@@ -1736,8 +1736,8 @@ var require_compare_loose = __commonJS({
1736
1736
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1737
1737
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1738
1738
  init_performance2();
1739
- var compare = require_compare();
1740
- var compareLoose = /* @__PURE__ */ __name((a, b) => compare(a, b, true), "compareLoose");
1739
+ var compare2 = require_compare();
1740
+ var compareLoose = /* @__PURE__ */ __name((a, b) => compare2(a, b, true), "compareLoose");
1741
1741
  module.exports = compareLoose;
1742
1742
  }
1743
1743
  });
@@ -1792,8 +1792,8 @@ var require_gt = __commonJS({
1792
1792
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1793
1793
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1794
1794
  init_performance2();
1795
- var compare = require_compare();
1796
- var gt = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) > 0, "gt");
1795
+ var compare2 = require_compare();
1796
+ var gt = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) > 0, "gt");
1797
1797
  module.exports = gt;
1798
1798
  }
1799
1799
  });
@@ -1805,8 +1805,8 @@ var require_lt = __commonJS({
1805
1805
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1806
1806
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1807
1807
  init_performance2();
1808
- var compare = require_compare();
1809
- var lt = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) < 0, "lt");
1808
+ var compare2 = require_compare();
1809
+ var lt = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) < 0, "lt");
1810
1810
  module.exports = lt;
1811
1811
  }
1812
1812
  });
@@ -1818,8 +1818,8 @@ var require_eq = __commonJS({
1818
1818
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1819
1819
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1820
1820
  init_performance2();
1821
- var compare = require_compare();
1822
- var eq = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) === 0, "eq");
1821
+ var compare2 = require_compare();
1822
+ var eq = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) === 0, "eq");
1823
1823
  module.exports = eq;
1824
1824
  }
1825
1825
  });
@@ -1831,8 +1831,8 @@ var require_neq = __commonJS({
1831
1831
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1832
1832
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1833
1833
  init_performance2();
1834
- var compare = require_compare();
1835
- var neq = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) !== 0, "neq");
1834
+ var compare2 = require_compare();
1835
+ var neq = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) !== 0, "neq");
1836
1836
  module.exports = neq;
1837
1837
  }
1838
1838
  });
@@ -1844,8 +1844,8 @@ var require_gte = __commonJS({
1844
1844
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1845
1845
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1846
1846
  init_performance2();
1847
- var compare = require_compare();
1848
- var gte = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) >= 0, "gte");
1847
+ var compare2 = require_compare();
1848
+ var gte = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) >= 0, "gte");
1849
1849
  module.exports = gte;
1850
1850
  }
1851
1851
  });
@@ -1857,8 +1857,8 @@ var require_lte = __commonJS({
1857
1857
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
1858
1858
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
1859
1859
  init_performance2();
1860
- var compare = require_compare();
1861
- var lte = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) <= 0, "lte");
1860
+ var compare2 = require_compare();
1861
+ var lte = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) <= 0, "lte");
1862
1862
  module.exports = lte;
1863
1863
  }
1864
1864
  });
@@ -2811,12 +2811,12 @@ var require_simplify = __commonJS({
2811
2811
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
2812
2812
  init_performance2();
2813
2813
  var satisfies = require_satisfies();
2814
- var compare = require_compare();
2814
+ var compare2 = require_compare();
2815
2815
  module.exports = (versions2, range, options) => {
2816
2816
  const set = [];
2817
2817
  let first = null;
2818
2818
  let prev = null;
2819
- const v = versions2.sort((a, b) => compare(a, b, options));
2819
+ const v = versions2.sort((a, b) => compare2(a, b, options));
2820
2820
  for (const version2 of v) {
2821
2821
  const included = satisfies(version2, range, options);
2822
2822
  if (included) {
@@ -2867,7 +2867,7 @@ var require_subset = __commonJS({
2867
2867
  var Comparator = require_comparator();
2868
2868
  var { ANY } = Comparator;
2869
2869
  var satisfies = require_satisfies();
2870
- var compare = require_compare();
2870
+ var compare2 = require_compare();
2871
2871
  var subset = /* @__PURE__ */ __name((sub, dom, options = {}) => {
2872
2872
  if (sub === dom) {
2873
2873
  return true;
@@ -2927,7 +2927,7 @@ var require_subset = __commonJS({
2927
2927
  }
2928
2928
  let gtltComp;
2929
2929
  if (gt && lt) {
2930
- gtltComp = compare(gt.semver, lt.semver, options);
2930
+ gtltComp = compare2(gt.semver, lt.semver, options);
2931
2931
  if (gtltComp > 0) {
2932
2932
  return null;
2933
2933
  } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
@@ -3007,14 +3007,14 @@ var require_subset = __commonJS({
3007
3007
  if (!a) {
3008
3008
  return b;
3009
3009
  }
3010
- const comp = compare(a.semver, b.semver, options);
3010
+ const comp = compare2(a.semver, b.semver, options);
3011
3011
  return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
3012
3012
  }, "higherGT");
3013
3013
  var lowerLT = /* @__PURE__ */ __name((a, b, options) => {
3014
3014
  if (!a) {
3015
3015
  return b;
3016
3016
  }
3017
- const comp = compare(a.semver, b.semver, options);
3017
+ const comp = compare2(a.semver, b.semver, options);
3018
3018
  return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
3019
3019
  }, "lowerLT");
3020
3020
  module.exports = subset;
@@ -3041,7 +3041,7 @@ var require_semver2 = __commonJS({
3041
3041
  var minor = require_minor();
3042
3042
  var patch = require_patch();
3043
3043
  var prerelease = require_prerelease();
3044
- var compare = require_compare();
3044
+ var compare2 = require_compare();
3045
3045
  var rcompare = require_rcompare();
3046
3046
  var compareLoose = require_compare_loose();
3047
3047
  var compareBuild = require_compare_build();
@@ -3079,7 +3079,2084 @@ var require_semver2 = __commonJS({
3079
3079
  minor,
3080
3080
  patch,
3081
3081
  prerelease,
3082
- compare,
3082
+ compare: compare2,
3083
+ rcompare,
3084
+ compareLoose,
3085
+ compareBuild,
3086
+ sort,
3087
+ rsort,
3088
+ gt,
3089
+ lt,
3090
+ eq,
3091
+ neq,
3092
+ gte,
3093
+ lte,
3094
+ cmp,
3095
+ coerce,
3096
+ Comparator,
3097
+ Range,
3098
+ satisfies,
3099
+ toComparators,
3100
+ maxSatisfying,
3101
+ minSatisfying,
3102
+ minVersion,
3103
+ validRange,
3104
+ outside,
3105
+ gtr,
3106
+ ltr,
3107
+ intersects,
3108
+ simplifyRange,
3109
+ subset,
3110
+ SemVer,
3111
+ re: internalRe.re,
3112
+ src: internalRe.src,
3113
+ tokens: internalRe.t,
3114
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
3115
+ RELEASE_TYPES: constants.RELEASE_TYPES,
3116
+ compareIdentifiers: identifiers.compareIdentifiers,
3117
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
3118
+ };
3119
+ }
3120
+ });
3121
+
3122
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
3123
+ var require_constants3 = __commonJS({
3124
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js"(exports, module) {
3125
+ "use strict";
3126
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3127
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3128
+ init_performance2();
3129
+ var SEMVER_SPEC_VERSION = "2.0.0";
3130
+ var MAX_LENGTH = 256;
3131
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
3132
+ 9007199254740991;
3133
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
3134
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
3135
+ var RELEASE_TYPES = [
3136
+ "major",
3137
+ "premajor",
3138
+ "minor",
3139
+ "preminor",
3140
+ "patch",
3141
+ "prepatch",
3142
+ "prerelease"
3143
+ ];
3144
+ module.exports = {
3145
+ MAX_LENGTH,
3146
+ MAX_SAFE_COMPONENT_LENGTH,
3147
+ MAX_SAFE_BUILD_LENGTH,
3148
+ MAX_SAFE_INTEGER,
3149
+ RELEASE_TYPES,
3150
+ SEMVER_SPEC_VERSION,
3151
+ FLAG_INCLUDE_PRERELEASE: 1,
3152
+ FLAG_LOOSE: 2
3153
+ };
3154
+ }
3155
+ });
3156
+
3157
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
3158
+ var require_debug3 = __commonJS({
3159
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js"(exports, module) {
3160
+ "use strict";
3161
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3162
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3163
+ init_performance2();
3164
+ var debug3 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
3165
+ };
3166
+ module.exports = debug3;
3167
+ }
3168
+ });
3169
+
3170
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js
3171
+ var require_re3 = __commonJS({
3172
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js"(exports, module) {
3173
+ "use strict";
3174
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3175
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3176
+ init_performance2();
3177
+ var {
3178
+ MAX_SAFE_COMPONENT_LENGTH,
3179
+ MAX_SAFE_BUILD_LENGTH,
3180
+ MAX_LENGTH
3181
+ } = require_constants3();
3182
+ var debug3 = require_debug3();
3183
+ exports = module.exports = {};
3184
+ var re = exports.re = [];
3185
+ var safeRe = exports.safeRe = [];
3186
+ var src = exports.src = [];
3187
+ var safeSrc = exports.safeSrc = [];
3188
+ var t = exports.t = {};
3189
+ var R = 0;
3190
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
3191
+ var safeRegexReplacements = [
3192
+ ["\\s", 1],
3193
+ ["\\d", MAX_LENGTH],
3194
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
3195
+ ];
3196
+ var makeSafeRegex = /* @__PURE__ */ __name((value) => {
3197
+ for (const [token, max] of safeRegexReplacements) {
3198
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
3199
+ }
3200
+ return value;
3201
+ }, "makeSafeRegex");
3202
+ var createToken = /* @__PURE__ */ __name((name, value, isGlobal) => {
3203
+ const safe = makeSafeRegex(value);
3204
+ const index = R++;
3205
+ debug3(name, index, value);
3206
+ t[name] = index;
3207
+ src[index] = value;
3208
+ safeSrc[index] = safe;
3209
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
3210
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
3211
+ }, "createToken");
3212
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
3213
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
3214
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
3215
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
3216
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
3217
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
3218
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
3219
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
3220
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
3221
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
3222
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
3223
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
3224
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
3225
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
3226
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
3227
+ createToken("GTLT", "((?:<|>)?=?)");
3228
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
3229
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
3230
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
3231
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
3232
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
3233
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
3234
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
3235
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
3236
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
3237
+ createToken("COERCERTL", src[t.COERCE], true);
3238
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
3239
+ createToken("LONETILDE", "(?:~>?)");
3240
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
3241
+ exports.tildeTrimReplace = "$1~";
3242
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
3243
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
3244
+ createToken("LONECARET", "(?:\\^)");
3245
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
3246
+ exports.caretTrimReplace = "$1^";
3247
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
3248
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
3249
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
3250
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
3251
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
3252
+ exports.comparatorTrimReplace = "$1$2$3";
3253
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
3254
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
3255
+ createToken("STAR", "(<|>)?=?\\s*\\*");
3256
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
3257
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
3258
+ }
3259
+ });
3260
+
3261
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js
3262
+ var require_parse_options3 = __commonJS({
3263
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js"(exports, module) {
3264
+ "use strict";
3265
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3266
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3267
+ init_performance2();
3268
+ var looseOption = Object.freeze({ loose: true });
3269
+ var emptyOpts = Object.freeze({});
3270
+ var parseOptions = /* @__PURE__ */ __name((options) => {
3271
+ if (!options) {
3272
+ return emptyOpts;
3273
+ }
3274
+ if (typeof options !== "object") {
3275
+ return looseOption;
3276
+ }
3277
+ return options;
3278
+ }, "parseOptions");
3279
+ module.exports = parseOptions;
3280
+ }
3281
+ });
3282
+
3283
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js
3284
+ var require_identifiers3 = __commonJS({
3285
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js"(exports, module) {
3286
+ "use strict";
3287
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3288
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3289
+ init_performance2();
3290
+ var numeric = /^[0-9]+$/;
3291
+ var compareIdentifiers = /* @__PURE__ */ __name((a, b) => {
3292
+ if (typeof a === "number" && typeof b === "number") {
3293
+ return a === b ? 0 : a < b ? -1 : 1;
3294
+ }
3295
+ const anum = numeric.test(a);
3296
+ const bnum = numeric.test(b);
3297
+ if (anum && bnum) {
3298
+ a = +a;
3299
+ b = +b;
3300
+ }
3301
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
3302
+ }, "compareIdentifiers");
3303
+ var rcompareIdentifiers = /* @__PURE__ */ __name((a, b) => compareIdentifiers(b, a), "rcompareIdentifiers");
3304
+ module.exports = {
3305
+ compareIdentifiers,
3306
+ rcompareIdentifiers
3307
+ };
3308
+ }
3309
+ });
3310
+
3311
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js
3312
+ var require_semver3 = __commonJS({
3313
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js"(exports, module) {
3314
+ "use strict";
3315
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3316
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3317
+ init_performance2();
3318
+ var debug3 = require_debug3();
3319
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants3();
3320
+ var { safeRe: re, t } = require_re3();
3321
+ var parseOptions = require_parse_options3();
3322
+ var { compareIdentifiers } = require_identifiers3();
3323
+ var SemVer = class _SemVer {
3324
+ static {
3325
+ __name(this, "SemVer");
3326
+ }
3327
+ constructor(version2, options) {
3328
+ options = parseOptions(options);
3329
+ if (version2 instanceof _SemVer) {
3330
+ if (version2.loose === !!options.loose && version2.includePrerelease === !!options.includePrerelease) {
3331
+ return version2;
3332
+ } else {
3333
+ version2 = version2.version;
3334
+ }
3335
+ } else if (typeof version2 !== "string") {
3336
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version2}".`);
3337
+ }
3338
+ if (version2.length > MAX_LENGTH) {
3339
+ throw new TypeError(
3340
+ `version is longer than ${MAX_LENGTH} characters`
3341
+ );
3342
+ }
3343
+ debug3("SemVer", version2, options);
3344
+ this.options = options;
3345
+ this.loose = !!options.loose;
3346
+ this.includePrerelease = !!options.includePrerelease;
3347
+ const m = version2.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
3348
+ if (!m) {
3349
+ throw new TypeError(`Invalid Version: ${version2}`);
3350
+ }
3351
+ this.raw = version2;
3352
+ this.major = +m[1];
3353
+ this.minor = +m[2];
3354
+ this.patch = +m[3];
3355
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
3356
+ throw new TypeError("Invalid major version");
3357
+ }
3358
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
3359
+ throw new TypeError("Invalid minor version");
3360
+ }
3361
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
3362
+ throw new TypeError("Invalid patch version");
3363
+ }
3364
+ if (!m[4]) {
3365
+ this.prerelease = [];
3366
+ } else {
3367
+ this.prerelease = m[4].split(".").map((id) => {
3368
+ if (/^[0-9]+$/.test(id)) {
3369
+ const num = +id;
3370
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
3371
+ return num;
3372
+ }
3373
+ }
3374
+ return id;
3375
+ });
3376
+ }
3377
+ this.build = m[5] ? m[5].split(".") : [];
3378
+ this.format();
3379
+ }
3380
+ format() {
3381
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
3382
+ if (this.prerelease.length) {
3383
+ this.version += `-${this.prerelease.join(".")}`;
3384
+ }
3385
+ return this.version;
3386
+ }
3387
+ toString() {
3388
+ return this.version;
3389
+ }
3390
+ compare(other) {
3391
+ debug3("SemVer.compare", this.version, this.options, other);
3392
+ if (!(other instanceof _SemVer)) {
3393
+ if (typeof other === "string" && other === this.version) {
3394
+ return 0;
3395
+ }
3396
+ other = new _SemVer(other, this.options);
3397
+ }
3398
+ if (other.version === this.version) {
3399
+ return 0;
3400
+ }
3401
+ return this.compareMain(other) || this.comparePre(other);
3402
+ }
3403
+ compareMain(other) {
3404
+ if (!(other instanceof _SemVer)) {
3405
+ other = new _SemVer(other, this.options);
3406
+ }
3407
+ if (this.major < other.major) {
3408
+ return -1;
3409
+ }
3410
+ if (this.major > other.major) {
3411
+ return 1;
3412
+ }
3413
+ if (this.minor < other.minor) {
3414
+ return -1;
3415
+ }
3416
+ if (this.minor > other.minor) {
3417
+ return 1;
3418
+ }
3419
+ if (this.patch < other.patch) {
3420
+ return -1;
3421
+ }
3422
+ if (this.patch > other.patch) {
3423
+ return 1;
3424
+ }
3425
+ return 0;
3426
+ }
3427
+ comparePre(other) {
3428
+ if (!(other instanceof _SemVer)) {
3429
+ other = new _SemVer(other, this.options);
3430
+ }
3431
+ if (this.prerelease.length && !other.prerelease.length) {
3432
+ return -1;
3433
+ } else if (!this.prerelease.length && other.prerelease.length) {
3434
+ return 1;
3435
+ } else if (!this.prerelease.length && !other.prerelease.length) {
3436
+ return 0;
3437
+ }
3438
+ let i = 0;
3439
+ do {
3440
+ const a = this.prerelease[i];
3441
+ const b = other.prerelease[i];
3442
+ debug3("prerelease compare", i, a, b);
3443
+ if (a === void 0 && b === void 0) {
3444
+ return 0;
3445
+ } else if (b === void 0) {
3446
+ return 1;
3447
+ } else if (a === void 0) {
3448
+ return -1;
3449
+ } else if (a === b) {
3450
+ continue;
3451
+ } else {
3452
+ return compareIdentifiers(a, b);
3453
+ }
3454
+ } while (++i);
3455
+ }
3456
+ compareBuild(other) {
3457
+ if (!(other instanceof _SemVer)) {
3458
+ other = new _SemVer(other, this.options);
3459
+ }
3460
+ let i = 0;
3461
+ do {
3462
+ const a = this.build[i];
3463
+ const b = other.build[i];
3464
+ debug3("build compare", i, a, b);
3465
+ if (a === void 0 && b === void 0) {
3466
+ return 0;
3467
+ } else if (b === void 0) {
3468
+ return 1;
3469
+ } else if (a === void 0) {
3470
+ return -1;
3471
+ } else if (a === b) {
3472
+ continue;
3473
+ } else {
3474
+ return compareIdentifiers(a, b);
3475
+ }
3476
+ } while (++i);
3477
+ }
3478
+ // preminor will bump the version up to the next minor release, and immediately
3479
+ // down to pre-release. premajor and prepatch work the same way.
3480
+ inc(release2, identifier, identifierBase) {
3481
+ if (release2.startsWith("pre")) {
3482
+ if (!identifier && identifierBase === false) {
3483
+ throw new Error("invalid increment argument: identifier is empty");
3484
+ }
3485
+ if (identifier) {
3486
+ const match2 = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
3487
+ if (!match2 || match2[1] !== identifier) {
3488
+ throw new Error(`invalid identifier: ${identifier}`);
3489
+ }
3490
+ }
3491
+ }
3492
+ switch (release2) {
3493
+ case "premajor":
3494
+ this.prerelease.length = 0;
3495
+ this.patch = 0;
3496
+ this.minor = 0;
3497
+ this.major++;
3498
+ this.inc("pre", identifier, identifierBase);
3499
+ break;
3500
+ case "preminor":
3501
+ this.prerelease.length = 0;
3502
+ this.patch = 0;
3503
+ this.minor++;
3504
+ this.inc("pre", identifier, identifierBase);
3505
+ break;
3506
+ case "prepatch":
3507
+ this.prerelease.length = 0;
3508
+ this.inc("patch", identifier, identifierBase);
3509
+ this.inc("pre", identifier, identifierBase);
3510
+ break;
3511
+ // If the input is a non-prerelease version, this acts the same as
3512
+ // prepatch.
3513
+ case "prerelease":
3514
+ if (this.prerelease.length === 0) {
3515
+ this.inc("patch", identifier, identifierBase);
3516
+ }
3517
+ this.inc("pre", identifier, identifierBase);
3518
+ break;
3519
+ case "release":
3520
+ if (this.prerelease.length === 0) {
3521
+ throw new Error(`version ${this.raw} is not a prerelease`);
3522
+ }
3523
+ this.prerelease.length = 0;
3524
+ break;
3525
+ case "major":
3526
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
3527
+ this.major++;
3528
+ }
3529
+ this.minor = 0;
3530
+ this.patch = 0;
3531
+ this.prerelease = [];
3532
+ break;
3533
+ case "minor":
3534
+ if (this.patch !== 0 || this.prerelease.length === 0) {
3535
+ this.minor++;
3536
+ }
3537
+ this.patch = 0;
3538
+ this.prerelease = [];
3539
+ break;
3540
+ case "patch":
3541
+ if (this.prerelease.length === 0) {
3542
+ this.patch++;
3543
+ }
3544
+ this.prerelease = [];
3545
+ break;
3546
+ // This probably shouldn't be used publicly.
3547
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
3548
+ case "pre": {
3549
+ const base = Number(identifierBase) ? 1 : 0;
3550
+ if (this.prerelease.length === 0) {
3551
+ this.prerelease = [base];
3552
+ } else {
3553
+ let i = this.prerelease.length;
3554
+ while (--i >= 0) {
3555
+ if (typeof this.prerelease[i] === "number") {
3556
+ this.prerelease[i]++;
3557
+ i = -2;
3558
+ }
3559
+ }
3560
+ if (i === -1) {
3561
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
3562
+ throw new Error("invalid increment argument: identifier already exists");
3563
+ }
3564
+ this.prerelease.push(base);
3565
+ }
3566
+ }
3567
+ if (identifier) {
3568
+ let prerelease = [identifier, base];
3569
+ if (identifierBase === false) {
3570
+ prerelease = [identifier];
3571
+ }
3572
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
3573
+ if (isNaN(this.prerelease[1])) {
3574
+ this.prerelease = prerelease;
3575
+ }
3576
+ } else {
3577
+ this.prerelease = prerelease;
3578
+ }
3579
+ }
3580
+ break;
3581
+ }
3582
+ default:
3583
+ throw new Error(`invalid increment argument: ${release2}`);
3584
+ }
3585
+ this.raw = this.format();
3586
+ if (this.build.length) {
3587
+ this.raw += `+${this.build.join(".")}`;
3588
+ }
3589
+ return this;
3590
+ }
3591
+ };
3592
+ module.exports = SemVer;
3593
+ }
3594
+ });
3595
+
3596
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js
3597
+ var require_parse3 = __commonJS({
3598
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js"(exports, module) {
3599
+ "use strict";
3600
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3601
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3602
+ init_performance2();
3603
+ var SemVer = require_semver3();
3604
+ var parse = /* @__PURE__ */ __name((version2, options, throwErrors = false) => {
3605
+ if (version2 instanceof SemVer) {
3606
+ return version2;
3607
+ }
3608
+ try {
3609
+ return new SemVer(version2, options);
3610
+ } catch (er) {
3611
+ if (!throwErrors) {
3612
+ return null;
3613
+ }
3614
+ throw er;
3615
+ }
3616
+ }, "parse");
3617
+ module.exports = parse;
3618
+ }
3619
+ });
3620
+
3621
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js
3622
+ var require_valid4 = __commonJS({
3623
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js"(exports, module) {
3624
+ "use strict";
3625
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3626
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3627
+ init_performance2();
3628
+ var parse = require_parse3();
3629
+ var valid = /* @__PURE__ */ __name((version2, options) => {
3630
+ const v = parse(version2, options);
3631
+ return v ? v.version : null;
3632
+ }, "valid");
3633
+ module.exports = valid;
3634
+ }
3635
+ });
3636
+
3637
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js
3638
+ var require_clean3 = __commonJS({
3639
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js"(exports, module) {
3640
+ "use strict";
3641
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3642
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3643
+ init_performance2();
3644
+ var parse = require_parse3();
3645
+ var clean = /* @__PURE__ */ __name((version2, options) => {
3646
+ const s = parse(version2.trim().replace(/^[=v]+/, ""), options);
3647
+ return s ? s.version : null;
3648
+ }, "clean");
3649
+ module.exports = clean;
3650
+ }
3651
+ });
3652
+
3653
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js
3654
+ var require_inc3 = __commonJS({
3655
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js"(exports, module) {
3656
+ "use strict";
3657
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3658
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3659
+ init_performance2();
3660
+ var SemVer = require_semver3();
3661
+ var inc = /* @__PURE__ */ __name((version2, release2, options, identifier, identifierBase) => {
3662
+ if (typeof options === "string") {
3663
+ identifierBase = identifier;
3664
+ identifier = options;
3665
+ options = void 0;
3666
+ }
3667
+ try {
3668
+ return new SemVer(
3669
+ version2 instanceof SemVer ? version2.version : version2,
3670
+ options
3671
+ ).inc(release2, identifier, identifierBase).version;
3672
+ } catch (er) {
3673
+ return null;
3674
+ }
3675
+ }, "inc");
3676
+ module.exports = inc;
3677
+ }
3678
+ });
3679
+
3680
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js
3681
+ var require_diff3 = __commonJS({
3682
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js"(exports, module) {
3683
+ "use strict";
3684
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3685
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3686
+ init_performance2();
3687
+ var parse = require_parse3();
3688
+ var diff = /* @__PURE__ */ __name((version1, version2) => {
3689
+ const v1 = parse(version1, null, true);
3690
+ const v2 = parse(version2, null, true);
3691
+ const comparison = v1.compare(v2);
3692
+ if (comparison === 0) {
3693
+ return null;
3694
+ }
3695
+ const v1Higher = comparison > 0;
3696
+ const highVersion = v1Higher ? v1 : v2;
3697
+ const lowVersion = v1Higher ? v2 : v1;
3698
+ const highHasPre = !!highVersion.prerelease.length;
3699
+ const lowHasPre = !!lowVersion.prerelease.length;
3700
+ if (lowHasPre && !highHasPre) {
3701
+ if (!lowVersion.patch && !lowVersion.minor) {
3702
+ return "major";
3703
+ }
3704
+ if (lowVersion.compareMain(highVersion) === 0) {
3705
+ if (lowVersion.minor && !lowVersion.patch) {
3706
+ return "minor";
3707
+ }
3708
+ return "patch";
3709
+ }
3710
+ }
3711
+ const prefix = highHasPre ? "pre" : "";
3712
+ if (v1.major !== v2.major) {
3713
+ return prefix + "major";
3714
+ }
3715
+ if (v1.minor !== v2.minor) {
3716
+ return prefix + "minor";
3717
+ }
3718
+ if (v1.patch !== v2.patch) {
3719
+ return prefix + "patch";
3720
+ }
3721
+ return "prerelease";
3722
+ }, "diff");
3723
+ module.exports = diff;
3724
+ }
3725
+ });
3726
+
3727
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js
3728
+ var require_major3 = __commonJS({
3729
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js"(exports, module) {
3730
+ "use strict";
3731
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3732
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3733
+ init_performance2();
3734
+ var SemVer = require_semver3();
3735
+ var major = /* @__PURE__ */ __name((a, loose) => new SemVer(a, loose).major, "major");
3736
+ module.exports = major;
3737
+ }
3738
+ });
3739
+
3740
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js
3741
+ var require_minor3 = __commonJS({
3742
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js"(exports, module) {
3743
+ "use strict";
3744
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3745
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3746
+ init_performance2();
3747
+ var SemVer = require_semver3();
3748
+ var minor = /* @__PURE__ */ __name((a, loose) => new SemVer(a, loose).minor, "minor");
3749
+ module.exports = minor;
3750
+ }
3751
+ });
3752
+
3753
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js
3754
+ var require_patch3 = __commonJS({
3755
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js"(exports, module) {
3756
+ "use strict";
3757
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3758
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3759
+ init_performance2();
3760
+ var SemVer = require_semver3();
3761
+ var patch = /* @__PURE__ */ __name((a, loose) => new SemVer(a, loose).patch, "patch");
3762
+ module.exports = patch;
3763
+ }
3764
+ });
3765
+
3766
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js
3767
+ var require_prerelease3 = __commonJS({
3768
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js"(exports, module) {
3769
+ "use strict";
3770
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3771
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3772
+ init_performance2();
3773
+ var parse = require_parse3();
3774
+ var prerelease = /* @__PURE__ */ __name((version2, options) => {
3775
+ const parsed = parse(version2, options);
3776
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
3777
+ }, "prerelease");
3778
+ module.exports = prerelease;
3779
+ }
3780
+ });
3781
+
3782
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js
3783
+ var require_compare3 = __commonJS({
3784
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js"(exports, module) {
3785
+ "use strict";
3786
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3787
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3788
+ init_performance2();
3789
+ var SemVer = require_semver3();
3790
+ var compare2 = /* @__PURE__ */ __name((a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)), "compare");
3791
+ module.exports = compare2;
3792
+ }
3793
+ });
3794
+
3795
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js
3796
+ var require_rcompare3 = __commonJS({
3797
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js"(exports, module) {
3798
+ "use strict";
3799
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3800
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3801
+ init_performance2();
3802
+ var compare2 = require_compare3();
3803
+ var rcompare = /* @__PURE__ */ __name((a, b, loose) => compare2(b, a, loose), "rcompare");
3804
+ module.exports = rcompare;
3805
+ }
3806
+ });
3807
+
3808
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js
3809
+ var require_compare_loose3 = __commonJS({
3810
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js"(exports, module) {
3811
+ "use strict";
3812
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3813
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3814
+ init_performance2();
3815
+ var compare2 = require_compare3();
3816
+ var compareLoose = /* @__PURE__ */ __name((a, b) => compare2(a, b, true), "compareLoose");
3817
+ module.exports = compareLoose;
3818
+ }
3819
+ });
3820
+
3821
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js
3822
+ var require_compare_build3 = __commonJS({
3823
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js"(exports, module) {
3824
+ "use strict";
3825
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3826
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3827
+ init_performance2();
3828
+ var SemVer = require_semver3();
3829
+ var compareBuild = /* @__PURE__ */ __name((a, b, loose) => {
3830
+ const versionA = new SemVer(a, loose);
3831
+ const versionB = new SemVer(b, loose);
3832
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
3833
+ }, "compareBuild");
3834
+ module.exports = compareBuild;
3835
+ }
3836
+ });
3837
+
3838
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js
3839
+ var require_sort3 = __commonJS({
3840
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js"(exports, module) {
3841
+ "use strict";
3842
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3843
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3844
+ init_performance2();
3845
+ var compareBuild = require_compare_build3();
3846
+ var sort = /* @__PURE__ */ __name((list, loose) => list.sort((a, b) => compareBuild(a, b, loose)), "sort");
3847
+ module.exports = sort;
3848
+ }
3849
+ });
3850
+
3851
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js
3852
+ var require_rsort3 = __commonJS({
3853
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js"(exports, module) {
3854
+ "use strict";
3855
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3856
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3857
+ init_performance2();
3858
+ var compareBuild = require_compare_build3();
3859
+ var rsort = /* @__PURE__ */ __name((list, loose) => list.sort((a, b) => compareBuild(b, a, loose)), "rsort");
3860
+ module.exports = rsort;
3861
+ }
3862
+ });
3863
+
3864
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js
3865
+ var require_gt3 = __commonJS({
3866
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js"(exports, module) {
3867
+ "use strict";
3868
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3869
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3870
+ init_performance2();
3871
+ var compare2 = require_compare3();
3872
+ var gt = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) > 0, "gt");
3873
+ module.exports = gt;
3874
+ }
3875
+ });
3876
+
3877
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js
3878
+ var require_lt3 = __commonJS({
3879
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js"(exports, module) {
3880
+ "use strict";
3881
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3882
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3883
+ init_performance2();
3884
+ var compare2 = require_compare3();
3885
+ var lt = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) < 0, "lt");
3886
+ module.exports = lt;
3887
+ }
3888
+ });
3889
+
3890
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js
3891
+ var require_eq3 = __commonJS({
3892
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js"(exports, module) {
3893
+ "use strict";
3894
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3895
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3896
+ init_performance2();
3897
+ var compare2 = require_compare3();
3898
+ var eq = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) === 0, "eq");
3899
+ module.exports = eq;
3900
+ }
3901
+ });
3902
+
3903
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js
3904
+ var require_neq3 = __commonJS({
3905
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js"(exports, module) {
3906
+ "use strict";
3907
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3908
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3909
+ init_performance2();
3910
+ var compare2 = require_compare3();
3911
+ var neq = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) !== 0, "neq");
3912
+ module.exports = neq;
3913
+ }
3914
+ });
3915
+
3916
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js
3917
+ var require_gte3 = __commonJS({
3918
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js"(exports, module) {
3919
+ "use strict";
3920
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3921
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3922
+ init_performance2();
3923
+ var compare2 = require_compare3();
3924
+ var gte = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) >= 0, "gte");
3925
+ module.exports = gte;
3926
+ }
3927
+ });
3928
+
3929
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js
3930
+ var require_lte3 = __commonJS({
3931
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js"(exports, module) {
3932
+ "use strict";
3933
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3934
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3935
+ init_performance2();
3936
+ var compare2 = require_compare3();
3937
+ var lte = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) <= 0, "lte");
3938
+ module.exports = lte;
3939
+ }
3940
+ });
3941
+
3942
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js
3943
+ var require_cmp3 = __commonJS({
3944
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js"(exports, module) {
3945
+ "use strict";
3946
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3947
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3948
+ init_performance2();
3949
+ var eq = require_eq3();
3950
+ var neq = require_neq3();
3951
+ var gt = require_gt3();
3952
+ var gte = require_gte3();
3953
+ var lt = require_lt3();
3954
+ var lte = require_lte3();
3955
+ var cmp = /* @__PURE__ */ __name((a, op, b, loose) => {
3956
+ switch (op) {
3957
+ case "===":
3958
+ if (typeof a === "object") {
3959
+ a = a.version;
3960
+ }
3961
+ if (typeof b === "object") {
3962
+ b = b.version;
3963
+ }
3964
+ return a === b;
3965
+ case "!==":
3966
+ if (typeof a === "object") {
3967
+ a = a.version;
3968
+ }
3969
+ if (typeof b === "object") {
3970
+ b = b.version;
3971
+ }
3972
+ return a !== b;
3973
+ case "":
3974
+ case "=":
3975
+ case "==":
3976
+ return eq(a, b, loose);
3977
+ case "!=":
3978
+ return neq(a, b, loose);
3979
+ case ">":
3980
+ return gt(a, b, loose);
3981
+ case ">=":
3982
+ return gte(a, b, loose);
3983
+ case "<":
3984
+ return lt(a, b, loose);
3985
+ case "<=":
3986
+ return lte(a, b, loose);
3987
+ default:
3988
+ throw new TypeError(`Invalid operator: ${op}`);
3989
+ }
3990
+ }, "cmp");
3991
+ module.exports = cmp;
3992
+ }
3993
+ });
3994
+
3995
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js
3996
+ var require_coerce3 = __commonJS({
3997
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js"(exports, module) {
3998
+ "use strict";
3999
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4000
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4001
+ init_performance2();
4002
+ var SemVer = require_semver3();
4003
+ var parse = require_parse3();
4004
+ var { safeRe: re, t } = require_re3();
4005
+ var coerce = /* @__PURE__ */ __name((version2, options) => {
4006
+ if (version2 instanceof SemVer) {
4007
+ return version2;
4008
+ }
4009
+ if (typeof version2 === "number") {
4010
+ version2 = String(version2);
4011
+ }
4012
+ if (typeof version2 !== "string") {
4013
+ return null;
4014
+ }
4015
+ options = options || {};
4016
+ let match2 = null;
4017
+ if (!options.rtl) {
4018
+ match2 = version2.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
4019
+ } else {
4020
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
4021
+ let next;
4022
+ while ((next = coerceRtlRegex.exec(version2)) && (!match2 || match2.index + match2[0].length !== version2.length)) {
4023
+ if (!match2 || next.index + next[0].length !== match2.index + match2[0].length) {
4024
+ match2 = next;
4025
+ }
4026
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
4027
+ }
4028
+ coerceRtlRegex.lastIndex = -1;
4029
+ }
4030
+ if (match2 === null) {
4031
+ return null;
4032
+ }
4033
+ const major = match2[2];
4034
+ const minor = match2[3] || "0";
4035
+ const patch = match2[4] || "0";
4036
+ const prerelease = options.includePrerelease && match2[5] ? `-${match2[5]}` : "";
4037
+ const build = options.includePrerelease && match2[6] ? `+${match2[6]}` : "";
4038
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
4039
+ }, "coerce");
4040
+ module.exports = coerce;
4041
+ }
4042
+ });
4043
+
4044
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js
4045
+ var require_lrucache3 = __commonJS({
4046
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js"(exports, module) {
4047
+ "use strict";
4048
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4049
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4050
+ init_performance2();
4051
+ var LRUCache = class {
4052
+ static {
4053
+ __name(this, "LRUCache");
4054
+ }
4055
+ constructor() {
4056
+ this.max = 1e3;
4057
+ this.map = /* @__PURE__ */ new Map();
4058
+ }
4059
+ get(key) {
4060
+ const value = this.map.get(key);
4061
+ if (value === void 0) {
4062
+ return void 0;
4063
+ } else {
4064
+ this.map.delete(key);
4065
+ this.map.set(key, value);
4066
+ return value;
4067
+ }
4068
+ }
4069
+ delete(key) {
4070
+ return this.map.delete(key);
4071
+ }
4072
+ set(key, value) {
4073
+ const deleted = this.delete(key);
4074
+ if (!deleted && value !== void 0) {
4075
+ if (this.map.size >= this.max) {
4076
+ const firstKey = this.map.keys().next().value;
4077
+ this.delete(firstKey);
4078
+ }
4079
+ this.map.set(key, value);
4080
+ }
4081
+ return this;
4082
+ }
4083
+ };
4084
+ module.exports = LRUCache;
4085
+ }
4086
+ });
4087
+
4088
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js
4089
+ var require_range3 = __commonJS({
4090
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js"(exports, module) {
4091
+ "use strict";
4092
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4093
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4094
+ init_performance2();
4095
+ var SPACE_CHARACTERS = /\s+/g;
4096
+ var Range = class _Range {
4097
+ static {
4098
+ __name(this, "Range");
4099
+ }
4100
+ constructor(range, options) {
4101
+ options = parseOptions(options);
4102
+ if (range instanceof _Range) {
4103
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
4104
+ return range;
4105
+ } else {
4106
+ return new _Range(range.raw, options);
4107
+ }
4108
+ }
4109
+ if (range instanceof Comparator) {
4110
+ this.raw = range.value;
4111
+ this.set = [[range]];
4112
+ this.formatted = void 0;
4113
+ return this;
4114
+ }
4115
+ this.options = options;
4116
+ this.loose = !!options.loose;
4117
+ this.includePrerelease = !!options.includePrerelease;
4118
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
4119
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
4120
+ if (!this.set.length) {
4121
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
4122
+ }
4123
+ if (this.set.length > 1) {
4124
+ const first = this.set[0];
4125
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
4126
+ if (this.set.length === 0) {
4127
+ this.set = [first];
4128
+ } else if (this.set.length > 1) {
4129
+ for (const c of this.set) {
4130
+ if (c.length === 1 && isAny(c[0])) {
4131
+ this.set = [c];
4132
+ break;
4133
+ }
4134
+ }
4135
+ }
4136
+ }
4137
+ this.formatted = void 0;
4138
+ }
4139
+ get range() {
4140
+ if (this.formatted === void 0) {
4141
+ this.formatted = "";
4142
+ for (let i = 0; i < this.set.length; i++) {
4143
+ if (i > 0) {
4144
+ this.formatted += "||";
4145
+ }
4146
+ const comps = this.set[i];
4147
+ for (let k = 0; k < comps.length; k++) {
4148
+ if (k > 0) {
4149
+ this.formatted += " ";
4150
+ }
4151
+ this.formatted += comps[k].toString().trim();
4152
+ }
4153
+ }
4154
+ }
4155
+ return this.formatted;
4156
+ }
4157
+ format() {
4158
+ return this.range;
4159
+ }
4160
+ toString() {
4161
+ return this.range;
4162
+ }
4163
+ parseRange(range) {
4164
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
4165
+ const memoKey = memoOpts + ":" + range;
4166
+ const cached = cache2.get(memoKey);
4167
+ if (cached) {
4168
+ return cached;
4169
+ }
4170
+ const loose = this.options.loose;
4171
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
4172
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
4173
+ debug3("hyphen replace", range);
4174
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
4175
+ debug3("comparator trim", range);
4176
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
4177
+ debug3("tilde trim", range);
4178
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
4179
+ debug3("caret trim", range);
4180
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
4181
+ if (loose) {
4182
+ rangeList = rangeList.filter((comp) => {
4183
+ debug3("loose invalid filter", comp, this.options);
4184
+ return !!comp.match(re[t.COMPARATORLOOSE]);
4185
+ });
4186
+ }
4187
+ debug3("range list", rangeList);
4188
+ const rangeMap = /* @__PURE__ */ new Map();
4189
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
4190
+ for (const comp of comparators) {
4191
+ if (isNullSet(comp)) {
4192
+ return [comp];
4193
+ }
4194
+ rangeMap.set(comp.value, comp);
4195
+ }
4196
+ if (rangeMap.size > 1 && rangeMap.has("")) {
4197
+ rangeMap.delete("");
4198
+ }
4199
+ const result = [...rangeMap.values()];
4200
+ cache2.set(memoKey, result);
4201
+ return result;
4202
+ }
4203
+ intersects(range, options) {
4204
+ if (!(range instanceof _Range)) {
4205
+ throw new TypeError("a Range is required");
4206
+ }
4207
+ return this.set.some((thisComparators) => {
4208
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
4209
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
4210
+ return rangeComparators.every((rangeComparator) => {
4211
+ return thisComparator.intersects(rangeComparator, options);
4212
+ });
4213
+ });
4214
+ });
4215
+ });
4216
+ }
4217
+ // if ANY of the sets match ALL of its comparators, then pass
4218
+ test(version2) {
4219
+ if (!version2) {
4220
+ return false;
4221
+ }
4222
+ if (typeof version2 === "string") {
4223
+ try {
4224
+ version2 = new SemVer(version2, this.options);
4225
+ } catch (er) {
4226
+ return false;
4227
+ }
4228
+ }
4229
+ for (let i = 0; i < this.set.length; i++) {
4230
+ if (testSet(this.set[i], version2, this.options)) {
4231
+ return true;
4232
+ }
4233
+ }
4234
+ return false;
4235
+ }
4236
+ };
4237
+ module.exports = Range;
4238
+ var LRU = require_lrucache3();
4239
+ var cache2 = new LRU();
4240
+ var parseOptions = require_parse_options3();
4241
+ var Comparator = require_comparator3();
4242
+ var debug3 = require_debug3();
4243
+ var SemVer = require_semver3();
4244
+ var {
4245
+ safeRe: re,
4246
+ t,
4247
+ comparatorTrimReplace,
4248
+ tildeTrimReplace,
4249
+ caretTrimReplace
4250
+ } = require_re3();
4251
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants3();
4252
+ var isNullSet = /* @__PURE__ */ __name((c) => c.value === "<0.0.0-0", "isNullSet");
4253
+ var isAny = /* @__PURE__ */ __name((c) => c.value === "", "isAny");
4254
+ var isSatisfiable = /* @__PURE__ */ __name((comparators, options) => {
4255
+ let result = true;
4256
+ const remainingComparators = comparators.slice();
4257
+ let testComparator = remainingComparators.pop();
4258
+ while (result && remainingComparators.length) {
4259
+ result = remainingComparators.every((otherComparator) => {
4260
+ return testComparator.intersects(otherComparator, options);
4261
+ });
4262
+ testComparator = remainingComparators.pop();
4263
+ }
4264
+ return result;
4265
+ }, "isSatisfiable");
4266
+ var parseComparator = /* @__PURE__ */ __name((comp, options) => {
4267
+ comp = comp.replace(re[t.BUILD], "");
4268
+ debug3("comp", comp, options);
4269
+ comp = replaceCarets(comp, options);
4270
+ debug3("caret", comp);
4271
+ comp = replaceTildes(comp, options);
4272
+ debug3("tildes", comp);
4273
+ comp = replaceXRanges(comp, options);
4274
+ debug3("xrange", comp);
4275
+ comp = replaceStars(comp, options);
4276
+ debug3("stars", comp);
4277
+ return comp;
4278
+ }, "parseComparator");
4279
+ var isX = /* @__PURE__ */ __name((id) => !id || id.toLowerCase() === "x" || id === "*", "isX");
4280
+ var replaceTildes = /* @__PURE__ */ __name((comp, options) => {
4281
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
4282
+ }, "replaceTildes");
4283
+ var replaceTilde = /* @__PURE__ */ __name((comp, options) => {
4284
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
4285
+ return comp.replace(r, (_, M, m, p, pr) => {
4286
+ debug3("tilde", comp, _, M, m, p, pr);
4287
+ let ret;
4288
+ if (isX(M)) {
4289
+ ret = "";
4290
+ } else if (isX(m)) {
4291
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
4292
+ } else if (isX(p)) {
4293
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
4294
+ } else if (pr) {
4295
+ debug3("replaceTilde pr", pr);
4296
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
4297
+ } else {
4298
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
4299
+ }
4300
+ debug3("tilde return", ret);
4301
+ return ret;
4302
+ });
4303
+ }, "replaceTilde");
4304
+ var replaceCarets = /* @__PURE__ */ __name((comp, options) => {
4305
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
4306
+ }, "replaceCarets");
4307
+ var replaceCaret = /* @__PURE__ */ __name((comp, options) => {
4308
+ debug3("caret", comp, options);
4309
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
4310
+ const z = options.includePrerelease ? "-0" : "";
4311
+ return comp.replace(r, (_, M, m, p, pr) => {
4312
+ debug3("caret", comp, _, M, m, p, pr);
4313
+ let ret;
4314
+ if (isX(M)) {
4315
+ ret = "";
4316
+ } else if (isX(m)) {
4317
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
4318
+ } else if (isX(p)) {
4319
+ if (M === "0") {
4320
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
4321
+ } else {
4322
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
4323
+ }
4324
+ } else if (pr) {
4325
+ debug3("replaceCaret pr", pr);
4326
+ if (M === "0") {
4327
+ if (m === "0") {
4328
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
4329
+ } else {
4330
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
4331
+ }
4332
+ } else {
4333
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
4334
+ }
4335
+ } else {
4336
+ debug3("no pr");
4337
+ if (M === "0") {
4338
+ if (m === "0") {
4339
+ ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
4340
+ } else {
4341
+ ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
4342
+ }
4343
+ } else {
4344
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
4345
+ }
4346
+ }
4347
+ debug3("caret return", ret);
4348
+ return ret;
4349
+ });
4350
+ }, "replaceCaret");
4351
+ var replaceXRanges = /* @__PURE__ */ __name((comp, options) => {
4352
+ debug3("replaceXRanges", comp, options);
4353
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
4354
+ }, "replaceXRanges");
4355
+ var replaceXRange = /* @__PURE__ */ __name((comp, options) => {
4356
+ comp = comp.trim();
4357
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
4358
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
4359
+ debug3("xRange", comp, ret, gtlt, M, m, p, pr);
4360
+ const xM = isX(M);
4361
+ const xm = xM || isX(m);
4362
+ const xp = xm || isX(p);
4363
+ const anyX = xp;
4364
+ if (gtlt === "=" && anyX) {
4365
+ gtlt = "";
4366
+ }
4367
+ pr = options.includePrerelease ? "-0" : "";
4368
+ if (xM) {
4369
+ if (gtlt === ">" || gtlt === "<") {
4370
+ ret = "<0.0.0-0";
4371
+ } else {
4372
+ ret = "*";
4373
+ }
4374
+ } else if (gtlt && anyX) {
4375
+ if (xm) {
4376
+ m = 0;
4377
+ }
4378
+ p = 0;
4379
+ if (gtlt === ">") {
4380
+ gtlt = ">=";
4381
+ if (xm) {
4382
+ M = +M + 1;
4383
+ m = 0;
4384
+ p = 0;
4385
+ } else {
4386
+ m = +m + 1;
4387
+ p = 0;
4388
+ }
4389
+ } else if (gtlt === "<=") {
4390
+ gtlt = "<";
4391
+ if (xm) {
4392
+ M = +M + 1;
4393
+ } else {
4394
+ m = +m + 1;
4395
+ }
4396
+ }
4397
+ if (gtlt === "<") {
4398
+ pr = "-0";
4399
+ }
4400
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
4401
+ } else if (xm) {
4402
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
4403
+ } else if (xp) {
4404
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
4405
+ }
4406
+ debug3("xRange return", ret);
4407
+ return ret;
4408
+ });
4409
+ }, "replaceXRange");
4410
+ var replaceStars = /* @__PURE__ */ __name((comp, options) => {
4411
+ debug3("replaceStars", comp, options);
4412
+ return comp.trim().replace(re[t.STAR], "");
4413
+ }, "replaceStars");
4414
+ var replaceGTE0 = /* @__PURE__ */ __name((comp, options) => {
4415
+ debug3("replaceGTE0", comp, options);
4416
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
4417
+ }, "replaceGTE0");
4418
+ var hyphenReplace = /* @__PURE__ */ __name((incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
4419
+ if (isX(fM)) {
4420
+ from = "";
4421
+ } else if (isX(fm)) {
4422
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
4423
+ } else if (isX(fp)) {
4424
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
4425
+ } else if (fpr) {
4426
+ from = `>=${from}`;
4427
+ } else {
4428
+ from = `>=${from}${incPr ? "-0" : ""}`;
4429
+ }
4430
+ if (isX(tM)) {
4431
+ to = "";
4432
+ } else if (isX(tm)) {
4433
+ to = `<${+tM + 1}.0.0-0`;
4434
+ } else if (isX(tp)) {
4435
+ to = `<${tM}.${+tm + 1}.0-0`;
4436
+ } else if (tpr) {
4437
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
4438
+ } else if (incPr) {
4439
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
4440
+ } else {
4441
+ to = `<=${to}`;
4442
+ }
4443
+ return `${from} ${to}`.trim();
4444
+ }, "hyphenReplace");
4445
+ var testSet = /* @__PURE__ */ __name((set, version2, options) => {
4446
+ for (let i = 0; i < set.length; i++) {
4447
+ if (!set[i].test(version2)) {
4448
+ return false;
4449
+ }
4450
+ }
4451
+ if (version2.prerelease.length && !options.includePrerelease) {
4452
+ for (let i = 0; i < set.length; i++) {
4453
+ debug3(set[i].semver);
4454
+ if (set[i].semver === Comparator.ANY) {
4455
+ continue;
4456
+ }
4457
+ if (set[i].semver.prerelease.length > 0) {
4458
+ const allowed = set[i].semver;
4459
+ if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
4460
+ return true;
4461
+ }
4462
+ }
4463
+ }
4464
+ return false;
4465
+ }
4466
+ return true;
4467
+ }, "testSet");
4468
+ }
4469
+ });
4470
+
4471
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js
4472
+ var require_comparator3 = __commonJS({
4473
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js"(exports, module) {
4474
+ "use strict";
4475
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4476
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4477
+ init_performance2();
4478
+ var ANY = Symbol("SemVer ANY");
4479
+ var Comparator = class _Comparator {
4480
+ static {
4481
+ __name(this, "Comparator");
4482
+ }
4483
+ static get ANY() {
4484
+ return ANY;
4485
+ }
4486
+ constructor(comp, options) {
4487
+ options = parseOptions(options);
4488
+ if (comp instanceof _Comparator) {
4489
+ if (comp.loose === !!options.loose) {
4490
+ return comp;
4491
+ } else {
4492
+ comp = comp.value;
4493
+ }
4494
+ }
4495
+ comp = comp.trim().split(/\s+/).join(" ");
4496
+ debug3("comparator", comp, options);
4497
+ this.options = options;
4498
+ this.loose = !!options.loose;
4499
+ this.parse(comp);
4500
+ if (this.semver === ANY) {
4501
+ this.value = "";
4502
+ } else {
4503
+ this.value = this.operator + this.semver.version;
4504
+ }
4505
+ debug3("comp", this);
4506
+ }
4507
+ parse(comp) {
4508
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
4509
+ const m = comp.match(r);
4510
+ if (!m) {
4511
+ throw new TypeError(`Invalid comparator: ${comp}`);
4512
+ }
4513
+ this.operator = m[1] !== void 0 ? m[1] : "";
4514
+ if (this.operator === "=") {
4515
+ this.operator = "";
4516
+ }
4517
+ if (!m[2]) {
4518
+ this.semver = ANY;
4519
+ } else {
4520
+ this.semver = new SemVer(m[2], this.options.loose);
4521
+ }
4522
+ }
4523
+ toString() {
4524
+ return this.value;
4525
+ }
4526
+ test(version2) {
4527
+ debug3("Comparator.test", version2, this.options.loose);
4528
+ if (this.semver === ANY || version2 === ANY) {
4529
+ return true;
4530
+ }
4531
+ if (typeof version2 === "string") {
4532
+ try {
4533
+ version2 = new SemVer(version2, this.options);
4534
+ } catch (er) {
4535
+ return false;
4536
+ }
4537
+ }
4538
+ return cmp(version2, this.operator, this.semver, this.options);
4539
+ }
4540
+ intersects(comp, options) {
4541
+ if (!(comp instanceof _Comparator)) {
4542
+ throw new TypeError("a Comparator is required");
4543
+ }
4544
+ if (this.operator === "") {
4545
+ if (this.value === "") {
4546
+ return true;
4547
+ }
4548
+ return new Range(comp.value, options).test(this.value);
4549
+ } else if (comp.operator === "") {
4550
+ if (comp.value === "") {
4551
+ return true;
4552
+ }
4553
+ return new Range(this.value, options).test(comp.semver);
4554
+ }
4555
+ options = parseOptions(options);
4556
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
4557
+ return false;
4558
+ }
4559
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
4560
+ return false;
4561
+ }
4562
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
4563
+ return true;
4564
+ }
4565
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
4566
+ return true;
4567
+ }
4568
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
4569
+ return true;
4570
+ }
4571
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
4572
+ return true;
4573
+ }
4574
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
4575
+ return true;
4576
+ }
4577
+ return false;
4578
+ }
4579
+ };
4580
+ module.exports = Comparator;
4581
+ var parseOptions = require_parse_options3();
4582
+ var { safeRe: re, t } = require_re3();
4583
+ var cmp = require_cmp3();
4584
+ var debug3 = require_debug3();
4585
+ var SemVer = require_semver3();
4586
+ var Range = require_range3();
4587
+ }
4588
+ });
4589
+
4590
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js
4591
+ var require_satisfies3 = __commonJS({
4592
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js"(exports, module) {
4593
+ "use strict";
4594
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4595
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4596
+ init_performance2();
4597
+ var Range = require_range3();
4598
+ var satisfies = /* @__PURE__ */ __name((version2, range, options) => {
4599
+ try {
4600
+ range = new Range(range, options);
4601
+ } catch (er) {
4602
+ return false;
4603
+ }
4604
+ return range.test(version2);
4605
+ }, "satisfies");
4606
+ module.exports = satisfies;
4607
+ }
4608
+ });
4609
+
4610
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js
4611
+ var require_to_comparators3 = __commonJS({
4612
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js"(exports, module) {
4613
+ "use strict";
4614
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4615
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4616
+ init_performance2();
4617
+ var Range = require_range3();
4618
+ var toComparators = /* @__PURE__ */ __name((range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" ")), "toComparators");
4619
+ module.exports = toComparators;
4620
+ }
4621
+ });
4622
+
4623
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js
4624
+ var require_max_satisfying3 = __commonJS({
4625
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js"(exports, module) {
4626
+ "use strict";
4627
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4628
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4629
+ init_performance2();
4630
+ var SemVer = require_semver3();
4631
+ var Range = require_range3();
4632
+ var maxSatisfying = /* @__PURE__ */ __name((versions2, range, options) => {
4633
+ let max = null;
4634
+ let maxSV = null;
4635
+ let rangeObj = null;
4636
+ try {
4637
+ rangeObj = new Range(range, options);
4638
+ } catch (er) {
4639
+ return null;
4640
+ }
4641
+ versions2.forEach((v) => {
4642
+ if (rangeObj.test(v)) {
4643
+ if (!max || maxSV.compare(v) === -1) {
4644
+ max = v;
4645
+ maxSV = new SemVer(max, options);
4646
+ }
4647
+ }
4648
+ });
4649
+ return max;
4650
+ }, "maxSatisfying");
4651
+ module.exports = maxSatisfying;
4652
+ }
4653
+ });
4654
+
4655
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js
4656
+ var require_min_satisfying3 = __commonJS({
4657
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js"(exports, module) {
4658
+ "use strict";
4659
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4660
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4661
+ init_performance2();
4662
+ var SemVer = require_semver3();
4663
+ var Range = require_range3();
4664
+ var minSatisfying = /* @__PURE__ */ __name((versions2, range, options) => {
4665
+ let min = null;
4666
+ let minSV = null;
4667
+ let rangeObj = null;
4668
+ try {
4669
+ rangeObj = new Range(range, options);
4670
+ } catch (er) {
4671
+ return null;
4672
+ }
4673
+ versions2.forEach((v) => {
4674
+ if (rangeObj.test(v)) {
4675
+ if (!min || minSV.compare(v) === 1) {
4676
+ min = v;
4677
+ minSV = new SemVer(min, options);
4678
+ }
4679
+ }
4680
+ });
4681
+ return min;
4682
+ }, "minSatisfying");
4683
+ module.exports = minSatisfying;
4684
+ }
4685
+ });
4686
+
4687
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js
4688
+ var require_min_version3 = __commonJS({
4689
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js"(exports, module) {
4690
+ "use strict";
4691
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4692
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4693
+ init_performance2();
4694
+ var SemVer = require_semver3();
4695
+ var Range = require_range3();
4696
+ var gt = require_gt3();
4697
+ var minVersion = /* @__PURE__ */ __name((range, loose) => {
4698
+ range = new Range(range, loose);
4699
+ let minver = new SemVer("0.0.0");
4700
+ if (range.test(minver)) {
4701
+ return minver;
4702
+ }
4703
+ minver = new SemVer("0.0.0-0");
4704
+ if (range.test(minver)) {
4705
+ return minver;
4706
+ }
4707
+ minver = null;
4708
+ for (let i = 0; i < range.set.length; ++i) {
4709
+ const comparators = range.set[i];
4710
+ let setMin = null;
4711
+ comparators.forEach((comparator) => {
4712
+ const compver = new SemVer(comparator.semver.version);
4713
+ switch (comparator.operator) {
4714
+ case ">":
4715
+ if (compver.prerelease.length === 0) {
4716
+ compver.patch++;
4717
+ } else {
4718
+ compver.prerelease.push(0);
4719
+ }
4720
+ compver.raw = compver.format();
4721
+ /* fallthrough */
4722
+ case "":
4723
+ case ">=":
4724
+ if (!setMin || gt(compver, setMin)) {
4725
+ setMin = compver;
4726
+ }
4727
+ break;
4728
+ case "<":
4729
+ case "<=":
4730
+ break;
4731
+ /* istanbul ignore next */
4732
+ default:
4733
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
4734
+ }
4735
+ });
4736
+ if (setMin && (!minver || gt(minver, setMin))) {
4737
+ minver = setMin;
4738
+ }
4739
+ }
4740
+ if (minver && range.test(minver)) {
4741
+ return minver;
4742
+ }
4743
+ return null;
4744
+ }, "minVersion");
4745
+ module.exports = minVersion;
4746
+ }
4747
+ });
4748
+
4749
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js
4750
+ var require_valid5 = __commonJS({
4751
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js"(exports, module) {
4752
+ "use strict";
4753
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4754
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4755
+ init_performance2();
4756
+ var Range = require_range3();
4757
+ var validRange = /* @__PURE__ */ __name((range, options) => {
4758
+ try {
4759
+ return new Range(range, options).range || "*";
4760
+ } catch (er) {
4761
+ return null;
4762
+ }
4763
+ }, "validRange");
4764
+ module.exports = validRange;
4765
+ }
4766
+ });
4767
+
4768
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js
4769
+ var require_outside3 = __commonJS({
4770
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js"(exports, module) {
4771
+ "use strict";
4772
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4773
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4774
+ init_performance2();
4775
+ var SemVer = require_semver3();
4776
+ var Comparator = require_comparator3();
4777
+ var { ANY } = Comparator;
4778
+ var Range = require_range3();
4779
+ var satisfies = require_satisfies3();
4780
+ var gt = require_gt3();
4781
+ var lt = require_lt3();
4782
+ var lte = require_lte3();
4783
+ var gte = require_gte3();
4784
+ var outside = /* @__PURE__ */ __name((version2, range, hilo, options) => {
4785
+ version2 = new SemVer(version2, options);
4786
+ range = new Range(range, options);
4787
+ let gtfn, ltefn, ltfn, comp, ecomp;
4788
+ switch (hilo) {
4789
+ case ">":
4790
+ gtfn = gt;
4791
+ ltefn = lte;
4792
+ ltfn = lt;
4793
+ comp = ">";
4794
+ ecomp = ">=";
4795
+ break;
4796
+ case "<":
4797
+ gtfn = lt;
4798
+ ltefn = gte;
4799
+ ltfn = gt;
4800
+ comp = "<";
4801
+ ecomp = "<=";
4802
+ break;
4803
+ default:
4804
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
4805
+ }
4806
+ if (satisfies(version2, range, options)) {
4807
+ return false;
4808
+ }
4809
+ for (let i = 0; i < range.set.length; ++i) {
4810
+ const comparators = range.set[i];
4811
+ let high = null;
4812
+ let low = null;
4813
+ comparators.forEach((comparator) => {
4814
+ if (comparator.semver === ANY) {
4815
+ comparator = new Comparator(">=0.0.0");
4816
+ }
4817
+ high = high || comparator;
4818
+ low = low || comparator;
4819
+ if (gtfn(comparator.semver, high.semver, options)) {
4820
+ high = comparator;
4821
+ } else if (ltfn(comparator.semver, low.semver, options)) {
4822
+ low = comparator;
4823
+ }
4824
+ });
4825
+ if (high.operator === comp || high.operator === ecomp) {
4826
+ return false;
4827
+ }
4828
+ if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
4829
+ return false;
4830
+ } else if (low.operator === ecomp && ltfn(version2, low.semver)) {
4831
+ return false;
4832
+ }
4833
+ }
4834
+ return true;
4835
+ }, "outside");
4836
+ module.exports = outside;
4837
+ }
4838
+ });
4839
+
4840
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js
4841
+ var require_gtr3 = __commonJS({
4842
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js"(exports, module) {
4843
+ "use strict";
4844
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4845
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4846
+ init_performance2();
4847
+ var outside = require_outside3();
4848
+ var gtr = /* @__PURE__ */ __name((version2, range, options) => outside(version2, range, ">", options), "gtr");
4849
+ module.exports = gtr;
4850
+ }
4851
+ });
4852
+
4853
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js
4854
+ var require_ltr3 = __commonJS({
4855
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js"(exports, module) {
4856
+ "use strict";
4857
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4858
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4859
+ init_performance2();
4860
+ var outside = require_outside3();
4861
+ var ltr = /* @__PURE__ */ __name((version2, range, options) => outside(version2, range, "<", options), "ltr");
4862
+ module.exports = ltr;
4863
+ }
4864
+ });
4865
+
4866
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js
4867
+ var require_intersects3 = __commonJS({
4868
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js"(exports, module) {
4869
+ "use strict";
4870
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4871
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4872
+ init_performance2();
4873
+ var Range = require_range3();
4874
+ var intersects = /* @__PURE__ */ __name((r1, r2, options) => {
4875
+ r1 = new Range(r1, options);
4876
+ r2 = new Range(r2, options);
4877
+ return r1.intersects(r2, options);
4878
+ }, "intersects");
4879
+ module.exports = intersects;
4880
+ }
4881
+ });
4882
+
4883
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js
4884
+ var require_simplify3 = __commonJS({
4885
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js"(exports, module) {
4886
+ "use strict";
4887
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4888
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4889
+ init_performance2();
4890
+ var satisfies = require_satisfies3();
4891
+ var compare2 = require_compare3();
4892
+ module.exports = (versions2, range, options) => {
4893
+ const set = [];
4894
+ let first = null;
4895
+ let prev = null;
4896
+ const v = versions2.sort((a, b) => compare2(a, b, options));
4897
+ for (const version2 of v) {
4898
+ const included = satisfies(version2, range, options);
4899
+ if (included) {
4900
+ prev = version2;
4901
+ if (!first) {
4902
+ first = version2;
4903
+ }
4904
+ } else {
4905
+ if (prev) {
4906
+ set.push([first, prev]);
4907
+ }
4908
+ prev = null;
4909
+ first = null;
4910
+ }
4911
+ }
4912
+ if (first) {
4913
+ set.push([first, null]);
4914
+ }
4915
+ const ranges = [];
4916
+ for (const [min, max] of set) {
4917
+ if (min === max) {
4918
+ ranges.push(min);
4919
+ } else if (!max && min === v[0]) {
4920
+ ranges.push("*");
4921
+ } else if (!max) {
4922
+ ranges.push(`>=${min}`);
4923
+ } else if (min === v[0]) {
4924
+ ranges.push(`<=${max}`);
4925
+ } else {
4926
+ ranges.push(`${min} - ${max}`);
4927
+ }
4928
+ }
4929
+ const simplified = ranges.join(" || ");
4930
+ const original = typeof range.raw === "string" ? range.raw : String(range);
4931
+ return simplified.length < original.length ? simplified : range;
4932
+ };
4933
+ }
4934
+ });
4935
+
4936
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js
4937
+ var require_subset3 = __commonJS({
4938
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js"(exports, module) {
4939
+ "use strict";
4940
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
4941
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
4942
+ init_performance2();
4943
+ var Range = require_range3();
4944
+ var Comparator = require_comparator3();
4945
+ var { ANY } = Comparator;
4946
+ var satisfies = require_satisfies3();
4947
+ var compare2 = require_compare3();
4948
+ var subset = /* @__PURE__ */ __name((sub, dom, options = {}) => {
4949
+ if (sub === dom) {
4950
+ return true;
4951
+ }
4952
+ sub = new Range(sub, options);
4953
+ dom = new Range(dom, options);
4954
+ let sawNonNull = false;
4955
+ OUTER: for (const simpleSub of sub.set) {
4956
+ for (const simpleDom of dom.set) {
4957
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
4958
+ sawNonNull = sawNonNull || isSub !== null;
4959
+ if (isSub) {
4960
+ continue OUTER;
4961
+ }
4962
+ }
4963
+ if (sawNonNull) {
4964
+ return false;
4965
+ }
4966
+ }
4967
+ return true;
4968
+ }, "subset");
4969
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
4970
+ var minimumVersion = [new Comparator(">=0.0.0")];
4971
+ var simpleSubset = /* @__PURE__ */ __name((sub, dom, options) => {
4972
+ if (sub === dom) {
4973
+ return true;
4974
+ }
4975
+ if (sub.length === 1 && sub[0].semver === ANY) {
4976
+ if (dom.length === 1 && dom[0].semver === ANY) {
4977
+ return true;
4978
+ } else if (options.includePrerelease) {
4979
+ sub = minimumVersionWithPreRelease;
4980
+ } else {
4981
+ sub = minimumVersion;
4982
+ }
4983
+ }
4984
+ if (dom.length === 1 && dom[0].semver === ANY) {
4985
+ if (options.includePrerelease) {
4986
+ return true;
4987
+ } else {
4988
+ dom = minimumVersion;
4989
+ }
4990
+ }
4991
+ const eqSet = /* @__PURE__ */ new Set();
4992
+ let gt, lt;
4993
+ for (const c of sub) {
4994
+ if (c.operator === ">" || c.operator === ">=") {
4995
+ gt = higherGT(gt, c, options);
4996
+ } else if (c.operator === "<" || c.operator === "<=") {
4997
+ lt = lowerLT(lt, c, options);
4998
+ } else {
4999
+ eqSet.add(c.semver);
5000
+ }
5001
+ }
5002
+ if (eqSet.size > 1) {
5003
+ return null;
5004
+ }
5005
+ let gtltComp;
5006
+ if (gt && lt) {
5007
+ gtltComp = compare2(gt.semver, lt.semver, options);
5008
+ if (gtltComp > 0) {
5009
+ return null;
5010
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
5011
+ return null;
5012
+ }
5013
+ }
5014
+ for (const eq of eqSet) {
5015
+ if (gt && !satisfies(eq, String(gt), options)) {
5016
+ return null;
5017
+ }
5018
+ if (lt && !satisfies(eq, String(lt), options)) {
5019
+ return null;
5020
+ }
5021
+ for (const c of dom) {
5022
+ if (!satisfies(eq, String(c), options)) {
5023
+ return false;
5024
+ }
5025
+ }
5026
+ return true;
5027
+ }
5028
+ let higher, lower;
5029
+ let hasDomLT, hasDomGT;
5030
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
5031
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
5032
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
5033
+ needDomLTPre = false;
5034
+ }
5035
+ for (const c of dom) {
5036
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
5037
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
5038
+ if (gt) {
5039
+ if (needDomGTPre) {
5040
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
5041
+ needDomGTPre = false;
5042
+ }
5043
+ }
5044
+ if (c.operator === ">" || c.operator === ">=") {
5045
+ higher = higherGT(gt, c, options);
5046
+ if (higher === c && higher !== gt) {
5047
+ return false;
5048
+ }
5049
+ } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) {
5050
+ return false;
5051
+ }
5052
+ }
5053
+ if (lt) {
5054
+ if (needDomLTPre) {
5055
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
5056
+ needDomLTPre = false;
5057
+ }
5058
+ }
5059
+ if (c.operator === "<" || c.operator === "<=") {
5060
+ lower = lowerLT(lt, c, options);
5061
+ if (lower === c && lower !== lt) {
5062
+ return false;
5063
+ }
5064
+ } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) {
5065
+ return false;
5066
+ }
5067
+ }
5068
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
5069
+ return false;
5070
+ }
5071
+ }
5072
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
5073
+ return false;
5074
+ }
5075
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
5076
+ return false;
5077
+ }
5078
+ if (needDomGTPre || needDomLTPre) {
5079
+ return false;
5080
+ }
5081
+ return true;
5082
+ }, "simpleSubset");
5083
+ var higherGT = /* @__PURE__ */ __name((a, b, options) => {
5084
+ if (!a) {
5085
+ return b;
5086
+ }
5087
+ const comp = compare2(a.semver, b.semver, options);
5088
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
5089
+ }, "higherGT");
5090
+ var lowerLT = /* @__PURE__ */ __name((a, b, options) => {
5091
+ if (!a) {
5092
+ return b;
5093
+ }
5094
+ const comp = compare2(a.semver, b.semver, options);
5095
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
5096
+ }, "lowerLT");
5097
+ module.exports = subset;
5098
+ }
5099
+ });
5100
+
5101
+ // ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js
5102
+ var require_semver4 = __commonJS({
5103
+ "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports, module) {
5104
+ "use strict";
5105
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
5106
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
5107
+ init_performance2();
5108
+ var internalRe = require_re3();
5109
+ var constants = require_constants3();
5110
+ var SemVer = require_semver3();
5111
+ var identifiers = require_identifiers3();
5112
+ var parse = require_parse3();
5113
+ var valid = require_valid4();
5114
+ var clean = require_clean3();
5115
+ var inc = require_inc3();
5116
+ var diff = require_diff3();
5117
+ var major = require_major3();
5118
+ var minor = require_minor3();
5119
+ var patch = require_patch3();
5120
+ var prerelease = require_prerelease3();
5121
+ var compare2 = require_compare3();
5122
+ var rcompare = require_rcompare3();
5123
+ var compareLoose = require_compare_loose3();
5124
+ var compareBuild = require_compare_build3();
5125
+ var sort = require_sort3();
5126
+ var rsort = require_rsort3();
5127
+ var gt = require_gt3();
5128
+ var lt = require_lt3();
5129
+ var eq = require_eq3();
5130
+ var neq = require_neq3();
5131
+ var gte = require_gte3();
5132
+ var lte = require_lte3();
5133
+ var cmp = require_cmp3();
5134
+ var coerce = require_coerce3();
5135
+ var Comparator = require_comparator3();
5136
+ var Range = require_range3();
5137
+ var satisfies = require_satisfies3();
5138
+ var toComparators = require_to_comparators3();
5139
+ var maxSatisfying = require_max_satisfying3();
5140
+ var minSatisfying = require_min_satisfying3();
5141
+ var minVersion = require_min_version3();
5142
+ var validRange = require_valid5();
5143
+ var outside = require_outside3();
5144
+ var gtr = require_gtr3();
5145
+ var ltr = require_ltr3();
5146
+ var intersects = require_intersects3();
5147
+ var simplifyRange = require_simplify3();
5148
+ var subset = require_subset3();
5149
+ module.exports = {
5150
+ parse,
5151
+ valid,
5152
+ clean,
5153
+ inc,
5154
+ diff,
5155
+ major,
5156
+ minor,
5157
+ patch,
5158
+ prerelease,
5159
+ compare: compare2,
3083
5160
  rcompare,
3084
5161
  compareLoose,
3085
5162
  compareBuild,
@@ -3129,117 +5206,6 @@ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3129
5206
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3130
5207
  init_performance2();
3131
5208
 
3132
- // ../../packages/server/src/db/pluginCore.ts
3133
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3134
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3135
- init_performance2();
3136
-
3137
- // ../../packages/core/dist/index.mjs
3138
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3139
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3140
- init_performance2();
3141
- var NUMERIC_COHORT_SIZE = 1e3;
3142
- var DEFAULT_ROLLOUT_COHORT_COUNT = NUMERIC_COHORT_SIZE;
3143
- function parseNumericCohortValue(cohort) {
3144
- if (!/^\d+$/.test(cohort)) return null;
3145
- const parsed = Number.parseInt(cohort, 10);
3146
- if (Number.isNaN(parsed) || parsed < 1 || parsed > 1e3) return null;
3147
- return parsed;
3148
- }
3149
- __name(parseNumericCohortValue, "parseNumericCohortValue");
3150
- function positiveMod(value, modulus) {
3151
- return (value % modulus + modulus) % modulus;
3152
- }
3153
- __name(positiveMod, "positiveMod");
3154
- function hashString(value) {
3155
- let hash = 0;
3156
- for (let i = 0; i < value.length; i++) {
3157
- const char = value.charCodeAt(i);
3158
- hash = (hash << 5) - hash + char;
3159
- hash |= 0;
3160
- }
3161
- return hash;
3162
- }
3163
- __name(hashString, "hashString");
3164
- function gcd(a, b) {
3165
- let x = Math.abs(a);
3166
- let y = Math.abs(b);
3167
- while (y !== 0) {
3168
- const next = x % y;
3169
- x = y;
3170
- y = next;
3171
- }
3172
- return x;
3173
- }
3174
- __name(gcd, "gcd");
3175
- function modularInverse(value, modulus) {
3176
- let t = 0;
3177
- let newT = 1;
3178
- let r = modulus;
3179
- let newR = positiveMod(value, modulus);
3180
- while (newR !== 0) {
3181
- const quotient = Math.floor(r / newR);
3182
- [t, newT] = [newT, t - quotient * newT];
3183
- [r, newR] = [newR, r - quotient * newR];
3184
- }
3185
- if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
3186
- return positiveMod(t, modulus);
3187
- }
3188
- __name(modularInverse, "modularInverse");
3189
- function getRolloutShuffleParameters(bundleId) {
3190
- let multiplier = positiveMod(hashString(`${bundleId}:multiplier`), 997);
3191
- if (multiplier === 0) multiplier = 1;
3192
- while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
3193
- multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
3194
- if (multiplier === 0) multiplier = 1;
3195
- }
3196
- const offset = positiveMod(hashString(`${bundleId}:offset`), NUMERIC_COHORT_SIZE);
3197
- return {
3198
- multiplier,
3199
- offset,
3200
- inverseMultiplier: modularInverse(multiplier, NUMERIC_COHORT_SIZE)
3201
- };
3202
- }
3203
- __name(getRolloutShuffleParameters, "getRolloutShuffleParameters");
3204
- function normalizeRolloutCohortCount(rolloutCohortCount) {
3205
- if (rolloutCohortCount === null || rolloutCohortCount === void 0) return DEFAULT_ROLLOUT_COHORT_COUNT;
3206
- if (rolloutCohortCount <= 0) return 0;
3207
- if (rolloutCohortCount >= 1e3) return NUMERIC_COHORT_SIZE;
3208
- return Math.floor(rolloutCohortCount);
3209
- }
3210
- __name(normalizeRolloutCohortCount, "normalizeRolloutCohortCount");
3211
- function normalizeCohortValue(cohort) {
3212
- const normalized = cohort.trim().toLowerCase();
3213
- const numericCohort = parseNumericCohortValue(normalized);
3214
- if (numericCohort !== null) return String(numericCohort);
3215
- return normalized;
3216
- }
3217
- __name(normalizeCohortValue, "normalizeCohortValue");
3218
- function getNumericCohortValue(cohort) {
3219
- return parseNumericCohortValue(normalizeCohortValue(cohort));
3220
- }
3221
- __name(getNumericCohortValue, "getNumericCohortValue");
3222
- function getNumericCohortRolloutPosition(bundleId, cohortValue) {
3223
- if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
3224
- const { offset, inverseMultiplier } = getRolloutShuffleParameters(bundleId);
3225
- return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
3226
- }
3227
- __name(getNumericCohortRolloutPosition, "getNumericCohortRolloutPosition");
3228
- function isCohortEligibleForUpdate(bundleId, cohort, rolloutCohortCount, targetCohorts) {
3229
- const normalizedCohort = cohort === null || cohort === void 0 ? void 0 : normalizeCohortValue(cohort);
3230
- const normalizedTargetCohorts = targetCohorts?.map((targetCohort) => normalizeCohortValue(targetCohort)) ?? [];
3231
- if (normalizedCohort !== void 0 && normalizedTargetCohorts.includes(normalizedCohort)) return true;
3232
- const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
3233
- if (normalizedRolloutCount <= 0) return false;
3234
- if (normalizedCohort === void 0) return normalizedRolloutCount >= NUMERIC_COHORT_SIZE;
3235
- const numericCohort = getNumericCohortValue(normalizedCohort);
3236
- if (numericCohort === null) return false;
3237
- if (normalizedRolloutCount >= 1e3) return true;
3238
- return getNumericCohortRolloutPosition(bundleId, numericCohort) < normalizedRolloutCount;
3239
- }
3240
- __name(isCohortEligibleForUpdate, "isCohortEligibleForUpdate");
3241
- var NIL_UUID = "00000000-0000-0000-0000-000000000000";
3242
-
3243
5209
  // ../plugin-core/dist/index.mjs
3244
5210
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3245
5211
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
@@ -3317,7 +5283,7 @@ function mergeWith(target, source, merge) {
3317
5283
  __name(mergeWith, "mergeWith");
3318
5284
 
3319
5285
  // ../plugin-core/dist/createDatabasePlugin.mjs
3320
- var REPLACE_ON_UPDATE_KEYS = ["targetCohorts"];
5286
+ var REPLACE_ON_UPDATE_KEYS = ["patches", "targetCohorts"];
3321
5287
  var DEFAULT_DESC_ORDER = {
3322
5288
  field: "id",
3323
5289
  direction: "desc"
@@ -3561,31 +5527,180 @@ function createDatabasePlugin(options) {
3561
5527
  };
3562
5528
  };
3563
5529
  }
3564
- __name(createDatabasePlugin, "createDatabasePlugin");
3565
-
3566
- // ../plugin-core/dist/semverSatisfies.mjs
3567
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3568
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3569
- init_performance2();
3570
- var import_semver = __toESM(require_semver2(), 1);
3571
- var semverSatisfies = /* @__PURE__ */ __name((targetAppVersion, currentVersion) => {
3572
- const currentCoerce = import_semver.default.coerce(currentVersion);
3573
- if (!currentCoerce) return false;
3574
- return import_semver.default.satisfies(currentCoerce.version, targetAppVersion);
3575
- }, "semverSatisfies");
3576
-
3577
- // ../plugin-core/dist/filterCompatibleAppVersions.mjs
3578
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3579
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3580
- init_performance2();
3581
- var filterCompatibleAppVersions = /* @__PURE__ */ __name((targetAppVersionList, currentVersion) => {
3582
- return targetAppVersionList.filter((version2) => semverSatisfies(version2, currentVersion)).sort((a, b) => b.localeCompare(a));
3583
- }, "filterCompatibleAppVersions");
5530
+ __name(createDatabasePlugin, "createDatabasePlugin");
5531
+
5532
+ // ../plugin-core/dist/semverSatisfies.mjs
5533
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
5534
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
5535
+ init_performance2();
5536
+ var import_semver = __toESM(require_semver2(), 1);
5537
+ var semverSatisfies = /* @__PURE__ */ __name((targetAppVersion, currentVersion) => {
5538
+ const currentCoerce = import_semver.default.coerce(currentVersion);
5539
+ if (!currentCoerce) return false;
5540
+ return import_semver.default.satisfies(currentCoerce.version, targetAppVersion);
5541
+ }, "semverSatisfies");
5542
+
5543
+ // ../plugin-core/dist/filterCompatibleAppVersions.mjs
5544
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
5545
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
5546
+ init_performance2();
5547
+ var filterCompatibleAppVersions = /* @__PURE__ */ __name((targetAppVersionList, currentVersion) => {
5548
+ return targetAppVersionList.filter((version2) => semverSatisfies(version2, currentVersion)).sort((a, b) => b.localeCompare(a));
5549
+ }, "filterCompatibleAppVersions");
5550
+
5551
+ // ../js/dist/index.mjs
5552
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
5553
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
5554
+ init_performance2();
5555
+
5556
+ // ../../packages/core/dist/index.mjs
5557
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
5558
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
5559
+ init_performance2();
5560
+ var stripBundleArtifactMetadata = /* @__PURE__ */ __name((metadata) => metadata, "stripBundleArtifactMetadata");
5561
+ var getManifestStorageUri = /* @__PURE__ */ __name((bundle) => bundle.manifestStorageUri ?? null, "getManifestStorageUri");
5562
+ var getManifestFileHash = /* @__PURE__ */ __name((bundle) => bundle.manifestFileHash ?? null, "getManifestFileHash");
5563
+ var getAssetBaseStorageUri = /* @__PURE__ */ __name((bundle) => bundle.assetBaseStorageUri ?? null, "getAssetBaseStorageUri");
5564
+ var isBundlePatchArtifact = /* @__PURE__ */ __name((value) => {
5565
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
5566
+ const candidate = value;
5567
+ return typeof candidate.baseBundleId === "string" && typeof candidate.baseFileHash === "string" && typeof candidate.patchFileHash === "string" && typeof candidate.patchStorageUri === "string";
5568
+ }, "isBundlePatchArtifact");
5569
+ var readBundlePatchArray = /* @__PURE__ */ __name((patches) => {
5570
+ if (!Array.isArray(patches)) return [];
5571
+ return patches.filter(isBundlePatchArtifact);
5572
+ }, "readBundlePatchArray");
5573
+ var getBundlePatches = /* @__PURE__ */ __name((bundle) => {
5574
+ const patches = readBundlePatchArray(bundle.patches);
5575
+ const seenBaseBundleIds = /* @__PURE__ */ new Set();
5576
+ return patches.filter((patch) => {
5577
+ if (seenBaseBundleIds.has(patch.baseBundleId)) return false;
5578
+ seenBaseBundleIds.add(patch.baseBundleId);
5579
+ return true;
5580
+ });
5581
+ }, "getBundlePatches");
5582
+ var getBundlePatch = /* @__PURE__ */ __name((bundle, baseBundleId) => {
5583
+ return getBundlePatches(bundle).find((patch) => patch.baseBundleId === baseBundleId) ?? null;
5584
+ }, "getBundlePatch");
5585
+ var NUMERIC_COHORT_SIZE = 1e3;
5586
+ var DEFAULT_ROLLOUT_COHORT_COUNT = NUMERIC_COHORT_SIZE;
5587
+ var INVALID_COHORT_ERROR_MESSAGE = `Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.`;
5588
+ var CUSTOM_COHORT_PATTERN = /^[a-z0-9-]+$/;
5589
+ function parseNumericCohortValue(cohort) {
5590
+ if (!/^\d+$/.test(cohort)) return null;
5591
+ const parsed = Number.parseInt(cohort, 10);
5592
+ if (Number.isNaN(parsed) || parsed < 1 || parsed > 1e3) return null;
5593
+ return parsed;
5594
+ }
5595
+ __name(parseNumericCohortValue, "parseNumericCohortValue");
5596
+ function positiveMod(value, modulus) {
5597
+ return (value % modulus + modulus) % modulus;
5598
+ }
5599
+ __name(positiveMod, "positiveMod");
5600
+ function hashString(value) {
5601
+ let hash = 0;
5602
+ for (let i = 0; i < value.length; i++) {
5603
+ const char = value.charCodeAt(i);
5604
+ hash = (hash << 5) - hash + char;
5605
+ hash |= 0;
5606
+ }
5607
+ return hash;
5608
+ }
5609
+ __name(hashString, "hashString");
5610
+ function gcd(a, b) {
5611
+ let x = Math.abs(a);
5612
+ let y = Math.abs(b);
5613
+ while (y !== 0) {
5614
+ const next = x % y;
5615
+ x = y;
5616
+ y = next;
5617
+ }
5618
+ return x;
5619
+ }
5620
+ __name(gcd, "gcd");
5621
+ function modularInverse(value, modulus) {
5622
+ let t = 0;
5623
+ let newT = 1;
5624
+ let r = modulus;
5625
+ let newR = positiveMod(value, modulus);
5626
+ while (newR !== 0) {
5627
+ const quotient = Math.floor(r / newR);
5628
+ [t, newT] = [newT, t - quotient * newT];
5629
+ [r, newR] = [newR, r - quotient * newR];
5630
+ }
5631
+ if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
5632
+ return positiveMod(t, modulus);
5633
+ }
5634
+ __name(modularInverse, "modularInverse");
5635
+ function getRolloutShuffleParameters(bundleId) {
5636
+ let multiplier = positiveMod(hashString(`${bundleId}:multiplier`), 997);
5637
+ if (multiplier === 0) multiplier = 1;
5638
+ while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
5639
+ multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
5640
+ if (multiplier === 0) multiplier = 1;
5641
+ }
5642
+ const offset = positiveMod(hashString(`${bundleId}:offset`), NUMERIC_COHORT_SIZE);
5643
+ return {
5644
+ multiplier,
5645
+ offset,
5646
+ inverseMultiplier: modularInverse(multiplier, NUMERIC_COHORT_SIZE)
5647
+ };
5648
+ }
5649
+ __name(getRolloutShuffleParameters, "getRolloutShuffleParameters");
5650
+ function normalizeRolloutCohortCount(rolloutCohortCount) {
5651
+ if (rolloutCohortCount === null || rolloutCohortCount === void 0) return DEFAULT_ROLLOUT_COHORT_COUNT;
5652
+ if (rolloutCohortCount <= 0) return 0;
5653
+ if (rolloutCohortCount >= 1e3) return NUMERIC_COHORT_SIZE;
5654
+ return Math.floor(rolloutCohortCount);
5655
+ }
5656
+ __name(normalizeRolloutCohortCount, "normalizeRolloutCohortCount");
5657
+ function normalizeCohortValue(cohort) {
5658
+ const normalized = cohort.trim().toLowerCase();
5659
+ const numericCohort = parseNumericCohortValue(normalized);
5660
+ if (numericCohort !== null) return String(numericCohort);
5661
+ return normalized;
5662
+ }
5663
+ __name(normalizeCohortValue, "normalizeCohortValue");
5664
+ function getNumericCohortValue(cohort) {
5665
+ return parseNumericCohortValue(normalizeCohortValue(cohort));
5666
+ }
5667
+ __name(getNumericCohortValue, "getNumericCohortValue");
5668
+ function isNumericCohort(cohort) {
5669
+ return getNumericCohortValue(cohort) !== null;
5670
+ }
5671
+ __name(isNumericCohort, "isNumericCohort");
5672
+ function isCustomCohort(cohort) {
5673
+ const normalized = normalizeCohortValue(cohort);
5674
+ return normalized.length > 0 && normalized.length <= 64 && !/^\d+$/.test(normalized) && CUSTOM_COHORT_PATTERN.test(normalized);
5675
+ }
5676
+ __name(isCustomCohort, "isCustomCohort");
5677
+ function isValidCohort(cohort) {
5678
+ const normalized = normalizeCohortValue(cohort);
5679
+ return isNumericCohort(normalized) || isCustomCohort(normalized);
5680
+ }
5681
+ __name(isValidCohort, "isValidCohort");
5682
+ function getNumericCohortRolloutPosition(bundleId, cohortValue) {
5683
+ if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
5684
+ const { offset, inverseMultiplier } = getRolloutShuffleParameters(bundleId);
5685
+ return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
5686
+ }
5687
+ __name(getNumericCohortRolloutPosition, "getNumericCohortRolloutPosition");
5688
+ function isCohortEligibleForUpdate(bundleId, cohort, rolloutCohortCount, targetCohorts) {
5689
+ const normalizedCohort = cohort === null || cohort === void 0 ? void 0 : normalizeCohortValue(cohort);
5690
+ const normalizedTargetCohorts = targetCohorts?.map((targetCohort) => normalizeCohortValue(targetCohort)) ?? [];
5691
+ if (normalizedCohort !== void 0 && normalizedTargetCohorts.includes(normalizedCohort)) return true;
5692
+ const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
5693
+ if (normalizedRolloutCount <= 0) return false;
5694
+ if (normalizedCohort === void 0) return normalizedRolloutCount >= NUMERIC_COHORT_SIZE;
5695
+ const numericCohort = getNumericCohortValue(normalizedCohort);
5696
+ if (numericCohort === null) return false;
5697
+ if (normalizedRolloutCount >= 1e3) return true;
5698
+ return getNumericCohortRolloutPosition(bundleId, numericCohort) < normalizedRolloutCount;
5699
+ }
5700
+ __name(isCohortEligibleForUpdate, "isCohortEligibleForUpdate");
5701
+ var NIL_UUID = "00000000-0000-0000-0000-000000000000";
3584
5702
 
3585
5703
  // ../js/dist/index.mjs
3586
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
3587
- init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
3588
- init_performance2();
3589
5704
  var __create2 = Object.create;
3590
5705
  var __defProp2 = Object.defineProperty;
3591
5706
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -4008,17 +6123,17 @@ var require_prerelease2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4008
6123
  });
4009
6124
  var require_compare2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4010
6125
  const SemVer = require_semver$1();
4011
- const compare = /* @__PURE__ */ __name((a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)), "compare");
4012
- module.exports = compare;
6126
+ const compare2 = /* @__PURE__ */ __name((a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)), "compare");
6127
+ module.exports = compare2;
4013
6128
  });
4014
6129
  var require_rcompare2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4015
- const compare = require_compare2();
4016
- const rcompare = /* @__PURE__ */ __name((a, b, loose) => compare(b, a, loose), "rcompare");
6130
+ const compare2 = require_compare2();
6131
+ const rcompare = /* @__PURE__ */ __name((a, b, loose) => compare2(b, a, loose), "rcompare");
4017
6132
  module.exports = rcompare;
4018
6133
  });
4019
6134
  var require_compare_loose2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4020
- const compare = require_compare2();
4021
- const compareLoose = /* @__PURE__ */ __name((a, b) => compare(a, b, true), "compareLoose");
6135
+ const compare2 = require_compare2();
6136
+ const compareLoose = /* @__PURE__ */ __name((a, b) => compare2(a, b, true), "compareLoose");
4022
6137
  module.exports = compareLoose;
4023
6138
  });
4024
6139
  var require_compare_build2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
@@ -4041,33 +6156,33 @@ var require_rsort2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4041
6156
  module.exports = rsort;
4042
6157
  });
4043
6158
  var require_gt2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4044
- const compare = require_compare2();
4045
- const gt = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) > 0, "gt");
6159
+ const compare2 = require_compare2();
6160
+ const gt = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) > 0, "gt");
4046
6161
  module.exports = gt;
4047
6162
  });
4048
6163
  var require_lt2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4049
- const compare = require_compare2();
4050
- const lt = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) < 0, "lt");
6164
+ const compare2 = require_compare2();
6165
+ const lt = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) < 0, "lt");
4051
6166
  module.exports = lt;
4052
6167
  });
4053
6168
  var require_eq2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4054
- const compare = require_compare2();
4055
- const eq = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) === 0, "eq");
6169
+ const compare2 = require_compare2();
6170
+ const eq = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) === 0, "eq");
4056
6171
  module.exports = eq;
4057
6172
  });
4058
6173
  var require_neq2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4059
- const compare = require_compare2();
4060
- const neq = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) !== 0, "neq");
6174
+ const compare2 = require_compare2();
6175
+ const neq = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) !== 0, "neq");
4061
6176
  module.exports = neq;
4062
6177
  });
4063
6178
  var require_gte2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4064
- const compare = require_compare2();
4065
- const gte = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) >= 0, "gte");
6179
+ const compare2 = require_compare2();
6180
+ const gte = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) >= 0, "gte");
4066
6181
  module.exports = gte;
4067
6182
  });
4068
6183
  var require_lte2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4069
- const compare = require_compare2();
4070
- const lte = /* @__PURE__ */ __name((a, b, loose) => compare(a, b, loose) <= 0, "lte");
6184
+ const compare2 = require_compare2();
6185
+ const lte = /* @__PURE__ */ __name((a, b, loose) => compare2(a, b, loose) <= 0, "lte");
4071
6186
  module.exports = lte;
4072
6187
  });
4073
6188
  var require_cmp2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
@@ -4698,12 +6813,12 @@ var require_intersects2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4698
6813
  });
4699
6814
  var require_simplify2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4700
6815
  const satisfies = require_satisfies2();
4701
- const compare = require_compare2();
6816
+ const compare2 = require_compare2();
4702
6817
  module.exports = (versions2, range, options) => {
4703
6818
  const set = [];
4704
6819
  let first = null;
4705
6820
  let prev = null;
4706
- const v = versions2.sort((a, b) => compare(a, b, options));
6821
+ const v = versions2.sort((a, b) => compare2(a, b, options));
4707
6822
  for (const version2 of v) if (satisfies(version2, range, options)) {
4708
6823
  prev = version2;
4709
6824
  if (!first) first = version2;
@@ -4729,7 +6844,7 @@ var require_subset2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4729
6844
  const Comparator = require_comparator2();
4730
6845
  const { ANY } = Comparator;
4731
6846
  const satisfies = require_satisfies2();
4732
- const compare = require_compare2();
6847
+ const compare2 = require_compare2();
4733
6848
  const subset = /* @__PURE__ */ __name((sub, dom, options = {}) => {
4734
6849
  if (sub === dom) return true;
4735
6850
  sub = new Range(sub, options);
@@ -4762,7 +6877,7 @@ var require_subset2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4762
6877
  if (eqSet.size > 1) return null;
4763
6878
  let gtltComp;
4764
6879
  if (gt && lt) {
4765
- gtltComp = compare(gt.semver, lt.semver, options);
6880
+ gtltComp = compare2(gt.semver, lt.semver, options);
4766
6881
  if (gtltComp > 0) return null;
4767
6882
  else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
4768
6883
  }
@@ -4807,12 +6922,12 @@ var require_subset2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
4807
6922
  }, "simpleSubset");
4808
6923
  const higherGT = /* @__PURE__ */ __name((a, b, options) => {
4809
6924
  if (!a) return b;
4810
- const comp = compare(a.semver, b.semver, options);
6925
+ const comp = compare2(a.semver, b.semver, options);
4811
6926
  return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
4812
6927
  }, "higherGT");
4813
6928
  const lowerLT = /* @__PURE__ */ __name((a, b, options) => {
4814
6929
  if (!a) return b;
4815
- const comp = compare(a.semver, b.semver, options);
6930
+ const comp = compare2(a.semver, b.semver, options);
4816
6931
  return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
4817
6932
  }, "lowerLT");
4818
6933
  module.exports = subset;
@@ -6144,6 +8259,359 @@ var createDatabasePluginGetUpdateInfo = /* @__PURE__ */ __name(({ getBundlesByFi
6144
8259
  };
6145
8260
  }, "createDatabasePluginGetUpdateInfo");
6146
8261
 
8262
+ // ../plugin-core/dist/createStoragePlugin.mjs
8263
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8264
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8265
+ init_performance2();
8266
+ var wrapNodeProfile = /* @__PURE__ */ __name((node, hooks) => ({
8267
+ ...node,
8268
+ async upload(key, filePath) {
8269
+ const result = await node.upload(key, filePath);
8270
+ await hooks?.onStorageUploaded?.();
8271
+ return result;
8272
+ }
8273
+ }), "wrapNodeProfile");
8274
+ var createProfiledStoragePlugin = /* @__PURE__ */ __name(({ createProfiles, name, profileShape, supportedProtocol }, hooks) => {
8275
+ let cachedProfiles = null;
8276
+ let cachedNodeProfile;
8277
+ let cachedRuntimeProfile;
8278
+ const getProfiles = /* @__PURE__ */ __name(() => {
8279
+ cachedProfiles ??= createProfiles();
8280
+ return cachedProfiles;
8281
+ }, "getProfiles");
8282
+ const getNodeProfile = /* @__PURE__ */ __name(() => {
8283
+ const node = getProfiles().node;
8284
+ if (!node) return;
8285
+ cachedNodeProfile ??= wrapNodeProfile(node, hooks);
8286
+ return cachedNodeProfile;
8287
+ }, "getNodeProfile");
8288
+ const requireNodeProfile = /* @__PURE__ */ __name(() => {
8289
+ const node = getNodeProfile();
8290
+ if (!node) throw new Error(`${name} does not implement the node storage profile for protocol "${supportedProtocol}".`);
8291
+ return node;
8292
+ }, "requireNodeProfile");
8293
+ const getRuntimeProfile = /* @__PURE__ */ __name(() => {
8294
+ const runtime = getProfiles().runtime;
8295
+ if (!runtime) return;
8296
+ cachedRuntimeProfile ??= runtime;
8297
+ return cachedRuntimeProfile;
8298
+ }, "getRuntimeProfile");
8299
+ const requireRuntimeProfile = /* @__PURE__ */ __name(() => {
8300
+ const runtime = getRuntimeProfile();
8301
+ if (!runtime) throw new Error(`${name} does not implement the runtime storage profile for protocol "${supportedProtocol}".`);
8302
+ return runtime;
8303
+ }, "requireRuntimeProfile");
8304
+ const profiles = {};
8305
+ if (profileShape?.node) profiles.node = {
8306
+ async delete(storageUri) {
8307
+ return requireNodeProfile().delete(storageUri);
8308
+ },
8309
+ async downloadFile(storageUri, filePath) {
8310
+ return requireNodeProfile().downloadFile(storageUri, filePath);
8311
+ },
8312
+ async upload(key, filePath) {
8313
+ return requireNodeProfile().upload(key, filePath);
8314
+ }
8315
+ };
8316
+ else if (profileShape?.node !== false) Object.defineProperty(profiles, "node", {
8317
+ enumerable: true,
8318
+ get: getNodeProfile
8319
+ });
8320
+ if (profileShape?.runtime) profiles.runtime = {
8321
+ async getDownloadUrl(storageUri, context2) {
8322
+ return requireRuntimeProfile().getDownloadUrl(storageUri, context2);
8323
+ },
8324
+ async readText(storageUri, context2) {
8325
+ return requireRuntimeProfile().readText(storageUri, context2);
8326
+ }
8327
+ };
8328
+ else if (profileShape?.runtime !== false) Object.defineProperty(profiles, "runtime", {
8329
+ enumerable: true,
8330
+ get: getRuntimeProfile
8331
+ });
8332
+ return {
8333
+ name,
8334
+ supportedProtocol,
8335
+ profiles
8336
+ };
8337
+ }, "createProfiledStoragePlugin");
8338
+ var createRuntimeStoragePlugin = /* @__PURE__ */ __name((options) => {
8339
+ return (config2, hooks) => {
8340
+ return () => createProfiledStoragePlugin({
8341
+ createProfiles: /* @__PURE__ */ __name(() => ({ runtime: options.factory(config2) }), "createProfiles"),
8342
+ name: options.name,
8343
+ profileShape: {
8344
+ node: false,
8345
+ runtime: true
8346
+ },
8347
+ supportedProtocol: options.supportedProtocol
8348
+ }, hooks);
8349
+ };
8350
+ }, "createRuntimeStoragePlugin");
8351
+
8352
+ // ../plugin-core/dist/storageProfile.mjs
8353
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8354
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8355
+ init_performance2();
8356
+ var createMissingProfileError = /* @__PURE__ */ __name((plugin, profile3) => /* @__PURE__ */ new Error(`${plugin.name} does not implement the ${profile3} storage profile for protocol "${plugin.supportedProtocol}".`), "createMissingProfileError");
8357
+ var isRuntimeStoragePlugin = /* @__PURE__ */ __name((plugin) => Boolean(plugin.profiles.runtime), "isRuntimeStoragePlugin");
8358
+ function assertRuntimeStoragePlugin(plugin) {
8359
+ if (!isRuntimeStoragePlugin(plugin)) throw createMissingProfileError(plugin, "runtime");
8360
+ }
8361
+ __name(assertRuntimeStoragePlugin, "assertRuntimeStoragePlugin");
8362
+
8363
+ // ../../packages/server/src/db/pluginCore.ts
8364
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8365
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8366
+ init_performance2();
8367
+
8368
+ // ../../packages/server/src/db/schemaEnhancements.ts
8369
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8370
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8371
+ init_performance2();
8372
+ var import_semver3 = __toESM(require_semver2(), 1);
8373
+ var normalizeNullableString = /* @__PURE__ */ __name((value) => {
8374
+ if (value === null || value === void 0) {
8375
+ return null;
8376
+ }
8377
+ const normalized = value.trim();
8378
+ return normalized.length > 0 ? normalized : null;
8379
+ }, "normalizeNullableString");
8380
+ var assertBundlePersistenceConstraints = /* @__PURE__ */ __name((bundle) => {
8381
+ const targetAppVersion = normalizeNullableString(bundle.targetAppVersion);
8382
+ const fingerprintHash = normalizeNullableString(bundle.fingerprintHash);
8383
+ if (!targetAppVersion && !fingerprintHash) {
8384
+ throw new Error(
8385
+ "Bundle must define either targetAppVersion or fingerprintHash."
8386
+ );
8387
+ }
8388
+ const rolloutCohortCount = bundle.rolloutCohortCount;
8389
+ if (rolloutCohortCount !== null && rolloutCohortCount !== void 0) {
8390
+ if (!Number.isInteger(rolloutCohortCount) || rolloutCohortCount < 0 || rolloutCohortCount > DEFAULT_ROLLOUT_COHORT_COUNT) {
8391
+ throw new Error(
8392
+ `rolloutCohortCount must be an integer between 0 and ${DEFAULT_ROLLOUT_COHORT_COUNT}.`
8393
+ );
8394
+ }
8395
+ }
8396
+ for (const cohort of bundle.targetCohorts ?? []) {
8397
+ if (!isValidCohort(cohort)) {
8398
+ throw new Error(
8399
+ `Invalid target cohort "${cohort}". ${INVALID_COHORT_ERROR_MESSAGE}`
8400
+ );
8401
+ }
8402
+ }
8403
+ }, "assertBundlePersistenceConstraints");
8404
+
8405
+ // ../../packages/server/src/db/updateArtifacts.ts
8406
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8407
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8408
+ init_performance2();
8409
+ var HBC_ASSET_PATH_RE = /\.bundle$/;
8410
+ var BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
8411
+ var resolveUniqueHbcAssetPath = /* @__PURE__ */ __name((manifest) => {
8412
+ const candidates = Object.keys(manifest.assets).sort((left, right) => left.localeCompare(right)).filter((candidate) => HBC_ASSET_PATH_RE.test(candidate));
8413
+ return candidates.length === 1 ? candidates[0] : null;
8414
+ }, "resolveUniqueHbcAssetPath");
8415
+ var isBundleManifest = /* @__PURE__ */ __name((value) => {
8416
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
8417
+ return false;
8418
+ }
8419
+ const manifest = value;
8420
+ if (typeof manifest.bundleId !== "string") {
8421
+ return false;
8422
+ }
8423
+ if (!manifest.assets || typeof manifest.assets !== "object") {
8424
+ return false;
8425
+ }
8426
+ return Object.values(manifest.assets).every(
8427
+ (asset) => {
8428
+ if (!asset || typeof asset !== "object" || Array.isArray(asset)) {
8429
+ return false;
8430
+ }
8431
+ const manifestAsset = asset;
8432
+ return typeof manifestAsset.fileHash === "string" && (manifestAsset.signature === void 0 || typeof manifestAsset.signature === "string");
8433
+ }
8434
+ );
8435
+ }, "isBundleManifest");
8436
+ var createChildStorageUri = /* @__PURE__ */ __name((baseStorageUri, relativePath) => {
8437
+ const baseUrl = new URL(baseStorageUri);
8438
+ const normalizedBasePath = baseUrl.pathname.replace(/\/+$/, "");
8439
+ const relativeSegments = relativePath.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment));
8440
+ baseUrl.pathname = `${normalizedBasePath}/${relativeSegments.join("/")}`;
8441
+ return baseUrl.toString();
8442
+ }, "createChildStorageUri");
8443
+ async function fetchBundleManifest(storageUri, readStorageText, resolveFileUrl, context2) {
8444
+ const [storageText, fileUrl] = await Promise.all([
8445
+ readStorageText(storageUri, context2),
8446
+ resolveFileUrl(storageUri, context2)
8447
+ ]);
8448
+ if (storageText === null) {
8449
+ return null;
8450
+ }
8451
+ let payload;
8452
+ try {
8453
+ payload = JSON.parse(storageText);
8454
+ } catch {
8455
+ return null;
8456
+ }
8457
+ if (!isBundleManifest(payload)) {
8458
+ return null;
8459
+ }
8460
+ if (!fileUrl) {
8461
+ return null;
8462
+ }
8463
+ return {
8464
+ fileUrl,
8465
+ manifest: payload
8466
+ };
8467
+ }
8468
+ __name(fetchBundleManifest, "fetchBundleManifest");
8469
+ async function resolveChangedAssets({
8470
+ assetBaseStorageUri,
8471
+ currentManifest,
8472
+ currentBundle,
8473
+ resolveFileUrl,
8474
+ targetBundle,
8475
+ targetManifest,
8476
+ context: context2
8477
+ }) {
8478
+ const patchDescriptor = await resolveHbcPatchDescriptor({
8479
+ currentBundle,
8480
+ resolveFileUrl,
8481
+ targetBundle,
8482
+ targetManifest,
8483
+ context: context2
8484
+ });
8485
+ const changedEntries = await Promise.all(
8486
+ Object.entries(targetManifest.assets).map(async ([assetPath, asset]) => {
8487
+ const currentAsset = currentManifest?.assets[assetPath];
8488
+ if (currentAsset?.fileHash === asset.fileHash) {
8489
+ return null;
8490
+ }
8491
+ const usesBrotliAsset = BR_COMPRESSED_ASSET_PATH_RE.test(assetPath);
8492
+ const downloadPath = usesBrotliAsset ? `${assetPath}.br` : assetPath;
8493
+ const storageUri = createChildStorageUri(
8494
+ assetBaseStorageUri,
8495
+ downloadPath
8496
+ );
8497
+ const patch = patchDescriptor?.assetPath === assetPath ? patchDescriptor.patch : null;
8498
+ let fileUrl = null;
8499
+ try {
8500
+ fileUrl = await resolveFileUrl(storageUri, context2);
8501
+ } catch (error3) {
8502
+ if (!patch) {
8503
+ throw error3;
8504
+ }
8505
+ }
8506
+ if (!fileUrl && !patch) {
8507
+ return false;
8508
+ }
8509
+ const changedAsset = {
8510
+ fileHash: asset.fileHash
8511
+ };
8512
+ if (fileUrl) {
8513
+ changedAsset.file = {
8514
+ url: fileUrl
8515
+ };
8516
+ if (usesBrotliAsset) {
8517
+ changedAsset.file.compression = "br";
8518
+ }
8519
+ }
8520
+ if (patch) {
8521
+ changedAsset.patch = patch;
8522
+ }
8523
+ return [assetPath, changedAsset];
8524
+ })
8525
+ );
8526
+ if (changedEntries.some((entry) => entry === false)) {
8527
+ return null;
8528
+ }
8529
+ return Object.fromEntries(
8530
+ changedEntries.filter(
8531
+ (entry) => entry !== null
8532
+ )
8533
+ );
8534
+ }
8535
+ __name(resolveChangedAssets, "resolveChangedAssets");
8536
+ async function resolveHbcPatchDescriptor({
8537
+ currentBundle,
8538
+ resolveFileUrl,
8539
+ targetBundle,
8540
+ targetManifest,
8541
+ context: context2
8542
+ }) {
8543
+ const matchingPatch = targetBundle && currentBundle ? getBundlePatch(targetBundle, currentBundle.id) : null;
8544
+ const patchAssetPath = resolveUniqueHbcAssetPath(targetManifest);
8545
+ if (!currentBundle || !matchingPatch || !patchAssetPath || !matchingPatch.patchStorageUri || !matchingPatch.patchFileHash || !matchingPatch.baseFileHash) {
8546
+ return null;
8547
+ }
8548
+ const patchUrl = await resolveFileUrl(matchingPatch.patchStorageUri, context2);
8549
+ if (!patchUrl) {
8550
+ return null;
8551
+ }
8552
+ return {
8553
+ assetPath: patchAssetPath,
8554
+ patch: {
8555
+ algorithm: "bsdiff",
8556
+ baseBundleId: matchingPatch.baseBundleId,
8557
+ baseFileHash: matchingPatch.baseFileHash,
8558
+ patchFileHash: matchingPatch.patchFileHash,
8559
+ patchUrl
8560
+ }
8561
+ };
8562
+ }
8563
+ __name(resolveHbcPatchDescriptor, "resolveHbcPatchDescriptor");
8564
+ async function resolveManifestArtifacts({
8565
+ currentBundle,
8566
+ resolveFileUrl,
8567
+ readStorageText,
8568
+ targetBundle,
8569
+ context: context2
8570
+ }) {
8571
+ const manifestStorageUri = targetBundle ? getManifestStorageUri(targetBundle) : null;
8572
+ const manifestFileHash = targetBundle ? getManifestFileHash(targetBundle) : null;
8573
+ const assetBaseStorageUri = targetBundle ? getAssetBaseStorageUri(targetBundle) : null;
8574
+ if (!manifestStorageUri || !manifestFileHash || !assetBaseStorageUri) {
8575
+ return null;
8576
+ }
8577
+ const currentManifestStorageUri = currentBundle ? getManifestStorageUri(currentBundle) : null;
8578
+ const [targetManifestResult, currentManifestResult] = await Promise.all([
8579
+ fetchBundleManifest(
8580
+ manifestStorageUri,
8581
+ readStorageText,
8582
+ resolveFileUrl,
8583
+ context2
8584
+ ),
8585
+ currentManifestStorageUri ? fetchBundleManifest(
8586
+ currentManifestStorageUri,
8587
+ readStorageText,
8588
+ resolveFileUrl,
8589
+ context2
8590
+ ) : null
8591
+ ]);
8592
+ if (!targetManifestResult) {
8593
+ return null;
8594
+ }
8595
+ const changedAssets = await resolveChangedAssets({
8596
+ assetBaseStorageUri,
8597
+ currentManifest: currentManifestResult?.manifest ?? null,
8598
+ currentBundle,
8599
+ resolveFileUrl,
8600
+ targetBundle,
8601
+ targetManifest: targetManifestResult.manifest,
8602
+ context: context2
8603
+ });
8604
+ if (!changedAssets) {
8605
+ return null;
8606
+ }
8607
+ return {
8608
+ changedAssets,
8609
+ manifestFileHash,
8610
+ manifestUrl: targetManifestResult.fileUrl
8611
+ };
8612
+ }
8613
+ __name(resolveManifestArtifacts, "resolveManifestArtifacts");
8614
+
6147
8615
  // ../../packages/server/src/db/pluginCore.ts
6148
8616
  var PAGE_SIZE = 100;
6149
8617
  var DESC_ORDER = { field: "id", direction: "desc" };
@@ -6355,8 +8823,32 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6355
8823
  return null;
6356
8824
  }
6357
8825
  const { storageUri, ...rest } = info3;
6358
- const fileUrl = await resolveFileUrl(storageUri ?? null, context2);
6359
- return { ...rest, fileUrl };
8826
+ const readStorageText = options?.readStorageText;
8827
+ if (info3.id === NIL_UUID || !readStorageText) {
8828
+ const fileUrl2 = await resolveFileUrl(storageUri ?? null, context2);
8829
+ const baseResponse2 = { ...rest, fileUrl: fileUrl2 };
8830
+ return baseResponse2;
8831
+ }
8832
+ const [fileUrl, targetBundle, currentBundle] = await Promise.all([
8833
+ resolveFileUrl(storageUri ?? null, context2),
8834
+ getPlugin().getBundleById(info3.id, context2),
8835
+ args.bundleId !== NIL_UUID ? getPlugin().getBundleById(args.bundleId, context2) : null
8836
+ ]);
8837
+ const baseResponse = { ...rest, fileUrl };
8838
+ const manifestArtifacts = await resolveManifestArtifacts({
8839
+ currentBundle,
8840
+ resolveFileUrl,
8841
+ readStorageText,
8842
+ targetBundle,
8843
+ context: context2
8844
+ });
8845
+ if (!manifestArtifacts) {
8846
+ return baseResponse;
8847
+ }
8848
+ return {
8849
+ ...baseResponse,
8850
+ ...manifestArtifacts
8851
+ };
6360
8852
  },
6361
8853
  async getChannels(context2) {
6362
8854
  return getPlugin().getChannels(context2);
@@ -6365,6 +8857,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6365
8857
  return getPlugin().getBundles(options2, context2);
6366
8858
  },
6367
8859
  async insertBundle(bundle, context2) {
8860
+ assertBundlePersistenceConstraints(bundle);
6368
8861
  await runWithMutationPlugin(async (plugin) => {
6369
8862
  await plugin.appendBundle(bundle, context2);
6370
8863
  await plugin.commitBundle(context2);
@@ -6372,6 +8865,11 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6372
8865
  },
6373
8866
  async updateBundleById(bundleId, newBundle, context2) {
6374
8867
  await runWithMutationPlugin(async (plugin) => {
8868
+ const current = await plugin.getBundleById(bundleId, context2);
8869
+ if (!current) {
8870
+ throw new Error("targetBundleId not found");
8871
+ }
8872
+ assertBundlePersistenceConstraints({ ...current, ...newBundle });
6375
8873
  await plugin.updateBundle(bundleId, newBundle, context2);
6376
8874
  await plugin.commitBundle(context2);
6377
8875
  });
@@ -6408,6 +8906,30 @@ __name(createPluginDatabaseCore, "createPluginDatabaseCore");
6408
8906
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
6409
8907
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
6410
8908
  init_performance2();
8909
+
8910
+ // ../../node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare+workers-types@4.20260313.1_@electric-sql+pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index.js
8911
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8912
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8913
+ init_performance2();
8914
+
8915
+ // ../../node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare+workers-types@4.20260313.1_@electric-sql+pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-7PZK4ONR.js
8916
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
8917
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
8918
+ init_performance2();
8919
+
8920
+ // ../../node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare+workers-types@4.20260313.1_@electric-sql+pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index.js
8921
+ var import_semver4 = __toESM(require_semver4(), 1);
8922
+ var sqlProviders = [
8923
+ "sqlite",
8924
+ "cockroachdb",
8925
+ "mysql",
8926
+ "postgresql",
8927
+ "mssql"
8928
+ ];
8929
+ var noSqlProviders = ["mongodb"];
8930
+ var providers = [...sqlProviders, ...noSqlProviders];
8931
+
8932
+ // ../../packages/server/src/db/types.ts
6411
8933
  function isDatabasePluginFactory(adapter) {
6412
8934
  return typeof adapter === "function";
6413
8935
  }
@@ -6421,6 +8943,7 @@ __name(isDatabasePlugin, "isDatabasePlugin");
6421
8943
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
6422
8944
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
6423
8945
  init_performance2();
8946
+ var import_semver5 = __toESM(require_semver2(), 1);
6424
8947
 
6425
8948
  // ../../packages/server/src/internalRouter.ts
6426
8949
  init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
@@ -6498,7 +9021,7 @@ init_performance2();
6498
9021
  // ../../packages/server/package.json
6499
9022
  var package_default = {
6500
9023
  name: "@hot-updater/server",
6501
- version: "0.30.12",
9024
+ version: "0.31.1",
6502
9025
  type: "module",
6503
9026
  description: "React Native OTA solution for self-hosted",
6504
9027
  sideEffects: false,
@@ -6552,10 +9075,13 @@ var package_default = {
6552
9075
  access: "public"
6553
9076
  },
6554
9077
  dependencies: {
9078
+ "@hot-updater/bsdiff": "workspace:*",
6555
9079
  "@hot-updater/core": "workspace:*",
6556
9080
  "@hot-updater/plugin-core": "workspace:*",
6557
9081
  "@hot-updater/js": "workspace:*",
6558
9082
  fumadb: "catalog:db",
9083
+ kysely: "catalog:db",
9084
+ mongodb: "catalog:db",
6559
9085
  rou3: "0.7.9",
6560
9086
  semver: "^7.7.2"
6561
9087
  },
@@ -6566,10 +9092,15 @@ var package_default = {
6566
9092
  "@types/node": "catalog:",
6567
9093
  "@types/semver": "^7.5.8",
6568
9094
  execa: "catalog:tools",
6569
- kysely: "catalog:db",
6570
9095
  "kysely-pglite-dialect": "catalog:db",
6571
9096
  msw: "^2.7.0",
6572
9097
  uuidv7: "^1.0.2"
9098
+ },
9099
+ inlinedDependencies: {
9100
+ "@noble/hashes": "1.8.0",
9101
+ "@paralleldrive/cuid2": "2.3.1",
9102
+ "drizzle-orm": "0.44.7",
9103
+ fumadb: "0.2.2"
6573
9104
  }
6574
9105
  };
6575
9106
 
@@ -6586,6 +9117,25 @@ var HandlerBadRequestError = class extends Error {
6586
9117
  this.name = "HandlerBadRequestError";
6587
9118
  }
6588
9119
  };
9120
+ var SDK_VERSION_HEADER = "Hot-Updater-SDK-Version";
9121
+ var EXPLICIT_NO_UPDATE_MIN_SDK_VERSION = "0.31.0";
9122
+ var supportsExplicitNoUpdateResponse = /* @__PURE__ */ __name((request) => {
9123
+ const sdkVersion = request.headers.get(SDK_VERSION_HEADER)?.trim();
9124
+ if (!sdkVersion) {
9125
+ return false;
9126
+ }
9127
+ const normalizedSdkVersion = import_semver5.default.valid(sdkVersion);
9128
+ return normalizedSdkVersion !== null && import_semver5.default.gte(normalizedSdkVersion, EXPLICIT_NO_UPDATE_MIN_SDK_VERSION);
9129
+ }, "supportsExplicitNoUpdateResponse");
9130
+ var serializeUpdateInfo = /* @__PURE__ */ __name((updateInfo, request) => {
9131
+ if (updateInfo) {
9132
+ return JSON.stringify(updateInfo);
9133
+ }
9134
+ if (supportsExplicitNoUpdateResponse(request)) {
9135
+ return JSON.stringify({ status: "UP_TO_DATE" });
9136
+ }
9137
+ return JSON.stringify(null);
9138
+ }, "serializeUpdateInfo");
6589
9139
  var handleVersion = /* @__PURE__ */ __name(async () => {
6590
9140
  return new Response(JSON.stringify({ version: HOT_UPDATER_SERVER_VERSION }), {
6591
9141
  status: 200,
@@ -6610,6 +9160,32 @@ var requireRouteParam = /* @__PURE__ */ __name((params, key) => {
6610
9160
  }
6611
9161
  return value;
6612
9162
  }, "requireRouteParam");
9163
+ var parseBooleanSearchParam = /* @__PURE__ */ __name((url, key) => {
9164
+ const value = url.searchParams.get(key);
9165
+ if (value === null) {
9166
+ return void 0;
9167
+ }
9168
+ if (value === "true") {
9169
+ return true;
9170
+ }
9171
+ if (value === "false") {
9172
+ return false;
9173
+ }
9174
+ throw new HandlerBadRequestError(
9175
+ `The '${key}' query parameter must be 'true' or 'false'.`
9176
+ );
9177
+ }, "parseBooleanSearchParam");
9178
+ var parseNullableStringSearchParam = /* @__PURE__ */ __name((url, key) => {
9179
+ const value = url.searchParams.get(key);
9180
+ if (value === null) {
9181
+ return void 0;
9182
+ }
9183
+ return value === "null" ? null : value;
9184
+ }, "parseNullableStringSearchParam");
9185
+ var parseStringArraySearchParam = /* @__PURE__ */ __name((url, key) => {
9186
+ const values = url.searchParams.getAll(key);
9187
+ return values.length > 0 ? values : void 0;
9188
+ }, "parseStringArraySearchParam");
6613
9189
  var requirePlatformParam = /* @__PURE__ */ __name((params) => {
6614
9190
  const platform2 = requireRouteParam(params, "platform");
6615
9191
  if (!isPlatform(platform2)) {
@@ -6630,7 +9206,7 @@ var requireBundlePatchPayload = /* @__PURE__ */ __name((payload, bundleId) => {
6630
9206
  const { id: _ignoredId, ...rest } = bundlePatch;
6631
9207
  return rest;
6632
9208
  }, "requireBundlePatchPayload");
6633
- var handleFingerprintUpdateWithCohort = /* @__PURE__ */ __name(async (params, _request, api, context2) => {
9209
+ var handleFingerprintUpdateWithCohort = /* @__PURE__ */ __name(async (params, request, api, context2) => {
6634
9210
  const platform2 = requirePlatformParam(params);
6635
9211
  const fingerprintHash = requireRouteParam(params, "fingerprintHash");
6636
9212
  const channel2 = requireRouteParam(params, "channel");
@@ -6648,12 +9224,12 @@ var handleFingerprintUpdateWithCohort = /* @__PURE__ */ __name(async (params, _r
6648
9224
  },
6649
9225
  context2
6650
9226
  );
6651
- return new Response(JSON.stringify(updateInfo), {
9227
+ return new Response(serializeUpdateInfo(updateInfo, request), {
6652
9228
  status: 200,
6653
9229
  headers: { "Content-Type": "application/json" }
6654
9230
  });
6655
9231
  }, "handleFingerprintUpdateWithCohort");
6656
- var handleAppVersionUpdateWithCohort = /* @__PURE__ */ __name(async (params, _request, api, context2) => {
9232
+ var handleAppVersionUpdateWithCohort = /* @__PURE__ */ __name(async (params, request, api, context2) => {
6657
9233
  const platform2 = requirePlatformParam(params);
6658
9234
  const appVersion = requireRouteParam(params, "appVersion");
6659
9235
  const channel2 = requireRouteParam(params, "channel");
@@ -6671,7 +9247,7 @@ var handleAppVersionUpdateWithCohort = /* @__PURE__ */ __name(async (params, _re
6671
9247
  },
6672
9248
  context2
6673
9249
  );
6674
- return new Response(JSON.stringify(updateInfo), {
9250
+ return new Response(serializeUpdateInfo(updateInfo, request), {
6675
9251
  status: 200,
6676
9252
  headers: { "Content-Type": "application/json" }
6677
9253
  });
@@ -6699,6 +9275,29 @@ var handleGetBundles = /* @__PURE__ */ __name(async (_params, request, api, cont
6699
9275
  const offset = url.searchParams.get("offset");
6700
9276
  const after = url.searchParams.get("after") ?? void 0;
6701
9277
  const before = url.searchParams.get("before") ?? void 0;
9278
+ const enabled = parseBooleanSearchParam(url, "enabled");
9279
+ const targetAppVersion = parseNullableStringSearchParam(
9280
+ url,
9281
+ "targetAppVersion"
9282
+ );
9283
+ const targetAppVersionIn = parseStringArraySearchParam(
9284
+ url,
9285
+ "targetAppVersionIn"
9286
+ );
9287
+ const targetAppVersionNotNull = parseBooleanSearchParam(
9288
+ url,
9289
+ "targetAppVersionNotNull"
9290
+ );
9291
+ const fingerprintHash = parseNullableStringSearchParam(
9292
+ url,
9293
+ "fingerprintHash"
9294
+ );
9295
+ const idEq = url.searchParams.get("idEq") ?? void 0;
9296
+ const idGt = url.searchParams.get("idGt") ?? void 0;
9297
+ const idGte = url.searchParams.get("idGte") ?? void 0;
9298
+ const idLt = url.searchParams.get("idLt") ?? void 0;
9299
+ const idLte = url.searchParams.get("idLte") ?? void 0;
9300
+ const idIn = parseStringArraySearchParam(url, "idIn");
6702
9301
  const page = pageParam === null ? void 0 : Number.isInteger(Number(pageParam)) && Number(pageParam) > 0 ? Number(pageParam) : null;
6703
9302
  if (offset !== null) {
6704
9303
  throw new HandlerBadRequestError(
@@ -6719,7 +9318,24 @@ var handleGetBundles = /* @__PURE__ */ __name(async (_params, request, api, cont
6719
9318
  {
6720
9319
  where: {
6721
9320
  ...channel2 && { channel: channel2 },
6722
- ...platform2 && { platform: platform2 }
9321
+ ...platform2 && { platform: platform2 },
9322
+ ...enabled !== void 0 && { enabled },
9323
+ ...idEq || idGt || idGte || idLt || idLte || idIn && idIn.length > 0 ? {
9324
+ id: {
9325
+ ...idEq && { eq: idEq },
9326
+ ...idGt && { gt: idGt },
9327
+ ...idGte && { gte: idGte },
9328
+ ...idLt && { lt: idLt },
9329
+ ...idLte && { lte: idLte },
9330
+ ...idIn && idIn.length > 0 && { in: idIn }
9331
+ }
9332
+ } : {},
9333
+ ...targetAppVersion !== void 0 && { targetAppVersion },
9334
+ ...targetAppVersionIn && { targetAppVersionIn },
9335
+ ...targetAppVersionNotNull !== void 0 && {
9336
+ targetAppVersionNotNull
9337
+ },
9338
+ ...fingerprintHash !== void 0 && { fingerprintHash }
6723
9339
  },
6724
9340
  limit,
6725
9341
  page,
@@ -6886,34 +9502,83 @@ var normalizeBasePath = /* @__PURE__ */ __name((basePath) => {
6886
9502
  return basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
6887
9503
  }, "normalizeBasePath");
6888
9504
 
6889
- // ../../packages/server/src/runtime.ts
6890
- function createHotUpdater(options) {
6891
- const database = options.database;
6892
- const basePath = normalizeBasePath(options.basePath ?? "/api");
6893
- const storagePlugins = (options.storages ?? options.storagePlugins ?? []).map(
6894
- (plugin2) => typeof plugin2 === "function" ? plugin2() : plugin2
9505
+ // ../../packages/server/src/storageAccess.ts
9506
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
9507
+ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
9508
+ init_performance2();
9509
+ var assertRemoteDownloadUrl = /* @__PURE__ */ __name((fileUrl) => {
9510
+ try {
9511
+ const protocol = new URL(fileUrl).protocol.replace(":", "");
9512
+ if (protocol === "http" || protocol === "https") {
9513
+ return fileUrl;
9514
+ }
9515
+ } catch {
9516
+ }
9517
+ throw new Error(
9518
+ "Storage plugin returned a local file path; runtime update checks require an HTTP(S) download URL."
6895
9519
  );
6896
- const resolveStoragePluginUrl = /* @__PURE__ */ __name(async (storageUri, context2) => {
9520
+ }, "assertRemoteDownloadUrl");
9521
+ var getStorageProtocol = /* @__PURE__ */ __name((storageUri) => new URL(storageUri).protocol.replace(":", ""), "getStorageProtocol");
9522
+ var isRemoteUrlProtocol = /* @__PURE__ */ __name((protocol) => protocol === "http" || protocol === "https", "isRemoteUrlProtocol");
9523
+ var createStorageAccess = /* @__PURE__ */ __name((storagePlugins) => {
9524
+ const findStoragePlugin = /* @__PURE__ */ __name((protocol) => {
9525
+ return storagePlugins.find((item) => item.supportedProtocol === protocol);
9526
+ }, "findStoragePlugin");
9527
+ const resolveFileUrl = /* @__PURE__ */ __name(async (storageUri, context2) => {
6897
9528
  if (!storageUri) {
6898
9529
  return null;
6899
9530
  }
6900
- const url = new URL(storageUri);
6901
- const protocol = url.protocol.replace(":", "");
6902
- if (protocol === "http" || protocol === "https") {
9531
+ const protocol = getStorageProtocol(storageUri);
9532
+ const plugin = findStoragePlugin(protocol);
9533
+ if (plugin) {
9534
+ const downloadTarget = await plugin.profiles.runtime.getDownloadUrl(
9535
+ storageUri,
9536
+ context2
9537
+ );
9538
+ const { fileUrl } = downloadTarget;
9539
+ if (!fileUrl) {
9540
+ throw new Error("Storage plugin returned empty fileUrl");
9541
+ }
9542
+ return assertRemoteDownloadUrl(fileUrl);
9543
+ }
9544
+ if (isRemoteUrlProtocol(protocol)) {
6903
9545
  return storageUri;
6904
9546
  }
6905
- const plugin2 = storagePlugins.find(
6906
- (item) => item.supportedProtocol === protocol
6907
- );
6908
- if (!plugin2) {
6909
- throw new Error(`No storage plugin for protocol: ${protocol}`);
9547
+ throw new Error(`No storage plugin for protocol: ${protocol}`);
9548
+ }, "resolveFileUrl");
9549
+ const readStorageText = /* @__PURE__ */ __name(async (storageUri, context2) => {
9550
+ const protocol = getStorageProtocol(storageUri);
9551
+ const plugin = findStoragePlugin(protocol);
9552
+ if (plugin) {
9553
+ return plugin.profiles.runtime.readText(storageUri, context2);
9554
+ }
9555
+ if (isRemoteUrlProtocol(protocol)) {
9556
+ const response = await fetch(storageUri);
9557
+ if (!response.ok) {
9558
+ return null;
9559
+ }
9560
+ return response.text();
6910
9561
  }
6911
- const { fileUrl } = await plugin2.getDownloadUrl(storageUri, context2);
6912
- if (!fileUrl) {
6913
- throw new Error("Storage plugin returned empty fileUrl");
9562
+ throw new Error(`No storage plugin for protocol: ${protocol}`);
9563
+ }, "readStorageText");
9564
+ return {
9565
+ readStorageText,
9566
+ resolveFileUrl
9567
+ };
9568
+ }, "createStorageAccess");
9569
+
9570
+ // ../../packages/server/src/runtime.ts
9571
+ function createHotUpdater(options) {
9572
+ const database = options.database;
9573
+ const basePath = normalizeBasePath(options.basePath ?? "/api");
9574
+ const storagePlugins = (options.storages ?? options.storagePlugins ?? []).map(
9575
+ (plugin2) => {
9576
+ const storagePlugin = typeof plugin2 === "function" ? plugin2() : plugin2;
9577
+ assertRuntimeStoragePlugin(storagePlugin);
9578
+ return storagePlugin;
6914
9579
  }
6915
- return fileUrl;
6916
- }, "resolveStoragePluginUrl");
9580
+ );
9581
+ const { readStorageText, resolveFileUrl } = createStorageAccess(storagePlugins);
6917
9582
  if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) {
6918
9583
  throw new Error(
6919
9584
  "@hot-updater/server/runtime only supports database plugins."
@@ -6922,10 +9587,11 @@ function createHotUpdater(options) {
6922
9587
  const plugin = isDatabasePluginFactory(database) ? database() : database;
6923
9588
  const core = createPluginDatabaseCore(
6924
9589
  () => plugin,
6925
- resolveStoragePluginUrl,
9590
+ resolveFileUrl,
6926
9591
  isDatabasePluginFactory(database) ? {
6927
- createMutationPlugin: /* @__PURE__ */ __name(() => database(), "createMutationPlugin")
6928
- } : void 0
9592
+ createMutationPlugin: /* @__PURE__ */ __name(() => database(), "createMutationPlugin"),
9593
+ readStorageText
9594
+ } : { readStorageText }
6929
9595
  );
6930
9596
  const api = {
6931
9597
  ...core.api,
@@ -9248,7 +11914,38 @@ function parseTargetCohorts(value) {
9248
11914
  return null;
9249
11915
  }
9250
11916
  __name(parseTargetCohorts, "parseTargetCohorts");
9251
- function transformRowToBundle(row) {
11917
+ var parseMetadata = /* @__PURE__ */ __name((value) => {
11918
+ if (!value) return void 0;
11919
+ if (typeof value === "string") {
11920
+ try {
11921
+ return parseMetadata(JSON.parse(value));
11922
+ } catch {
11923
+ return void 0;
11924
+ }
11925
+ }
11926
+ return typeof value === "object" && !Array.isArray(value) ? value : void 0;
11927
+ }, "parseMetadata");
11928
+ var buildBundlePatchId = /* @__PURE__ */ __name((bundleId, baseBundleId) => `${bundleId}:${baseBundleId}`, "buildBundlePatchId");
11929
+ var bundleToPatchRows = /* @__PURE__ */ __name((bundle) => getBundlePatches(bundle).map((patch, index) => ({
11930
+ id: buildBundlePatchId(bundle.id, patch.baseBundleId),
11931
+ bundle_id: bundle.id,
11932
+ base_bundle_id: patch.baseBundleId,
11933
+ base_file_hash: patch.baseFileHash,
11934
+ patch_file_hash: patch.patchFileHash,
11935
+ patch_storage_uri: patch.patchStorageUri,
11936
+ order_index: index
11937
+ })), "bundleToPatchRows");
11938
+ function transformRowToBundle(row, patchRows = []) {
11939
+ const rawMetadata = parseMetadata(row.metadata);
11940
+ const patches = patchRows.slice().sort(
11941
+ (left, right) => (left.order_index ?? 0) - (right.order_index ?? 0) || left.base_bundle_id.localeCompare(right.base_bundle_id)
11942
+ ).map((patch) => ({
11943
+ baseBundleId: patch.base_bundle_id,
11944
+ baseFileHash: patch.base_file_hash,
11945
+ patchFileHash: patch.patch_file_hash,
11946
+ patchStorageUri: patch.patch_storage_uri
11947
+ }));
11948
+ const primaryPatch = patches[0] ?? null;
9252
11949
  return {
9253
11950
  id: row.id,
9254
11951
  channel: row.channel,
@@ -9261,7 +11958,15 @@ function transformRowToBundle(row) {
9261
11958
  targetAppVersion: row.target_app_version,
9262
11959
  storageUri: row.storage_uri,
9263
11960
  fingerprintHash: row.fingerprint_hash,
9264
- metadata: row?.metadata ? JSON.parse(row.metadata) : {},
11961
+ metadata: stripBundleArtifactMetadata(rawMetadata),
11962
+ manifestStorageUri: row.manifest_storage_uri ?? null,
11963
+ manifestFileHash: row.manifest_file_hash ?? null,
11964
+ assetBaseStorageUri: row.asset_base_storage_uri ?? null,
11965
+ patches,
11966
+ patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
11967
+ patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
11968
+ patchFileHash: primaryPatch?.patchFileHash ?? null,
11969
+ patchStorageUri: primaryPatch?.patchStorageUri ?? null,
9265
11970
  rolloutCohortCount: row.rollout_cohort_count ?? DEFAULT_ROLLOUT_COHORT_COUNT,
9266
11971
  targetCohorts: parseTargetCohorts(row.target_cohorts)
9267
11972
  };
@@ -9287,6 +11992,29 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9287
11992
  const result = await config2.getDb(context2).prepare(sql).bind(...params).first();
9288
11993
  return result ?? null;
9289
11994
  }, "queryFirst");
11995
+ const getPatchMap = /* @__PURE__ */ __name(async (bundleIds, context2) => {
11996
+ const patchMap = /* @__PURE__ */ new Map();
11997
+ if (bundleIds.length === 0) {
11998
+ return patchMap;
11999
+ }
12000
+ const placeholders = bundleIds.map(() => "?").join(", ");
12001
+ const rows = await queryAll(
12002
+ `
12003
+ SELECT *
12004
+ FROM bundle_patches
12005
+ WHERE bundle_id IN (${placeholders})
12006
+ ORDER BY order_index ASC, base_bundle_id ASC
12007
+ `,
12008
+ bundleIds,
12009
+ context2
12010
+ );
12011
+ for (const row of rows) {
12012
+ const current = patchMap.get(row.bundle_id) ?? [];
12013
+ current.push(row);
12014
+ patchMap.set(row.bundle_id, current);
12015
+ }
12016
+ return patchMap;
12017
+ }, "getPatchMap");
9290
12018
  const queryBundlesForUpdateInfo = /* @__PURE__ */ __name(async (conditions, context2) => {
9291
12019
  const { sql: whereClause, params } = buildWhereClause(conditions);
9292
12020
  const rows = await queryAll(
@@ -9297,7 +12025,13 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9297
12025
  params,
9298
12026
  context2
9299
12027
  );
9300
- return rows.map(transformRowToBundle);
12028
+ const patchMap = await getPatchMap(
12029
+ rows.map((row) => row.id),
12030
+ context2
12031
+ );
12032
+ return rows.map(
12033
+ (row) => transformRowToBundle(row, patchMap.get(row.id))
12034
+ );
9301
12035
  }, "queryBundlesForUpdateInfo");
9302
12036
  const getTargetAppVersionsForUpdateInfo = /* @__PURE__ */ __name(async ({
9303
12037
  platform: platform2,
@@ -9353,12 +12087,15 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9353
12087
  }
9354
12088
  }),
9355
12089
  async getBundleById(bundleId, context2) {
9356
- const row = await queryFirst(
9357
- "SELECT * FROM bundles WHERE id = ? LIMIT 1",
9358
- [bundleId],
9359
- context2
9360
- );
9361
- return row ? transformRowToBundle(row) : null;
12090
+ const [row, patchMap] = await Promise.all([
12091
+ queryFirst(
12092
+ "SELECT * FROM bundles WHERE id = ? LIMIT 1",
12093
+ [bundleId],
12094
+ context2
12095
+ ),
12096
+ getPatchMap([bundleId], context2)
12097
+ ]);
12098
+ return row ? transformRowToBundle(row, patchMap.get(bundleId)) : null;
9362
12099
  },
9363
12100
  async getBundles(options, context2) {
9364
12101
  const { where, limit, orderBy } = options;
@@ -9376,7 +12113,13 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9376
12113
  [...params, limit, offset],
9377
12114
  context2
9378
12115
  );
9379
- const bundles = rows.map(transformRowToBundle);
12116
+ const patchMap = await getPatchMap(
12117
+ rows.map((row) => row.id),
12118
+ context2
12119
+ );
12120
+ const bundles = rows.map(
12121
+ (row) => transformRowToBundle(row, patchMap.get(row.id))
12122
+ );
9380
12123
  const paginationOptions = { limit, offset };
9381
12124
  return {
9382
12125
  data: bundles,
@@ -9398,6 +12141,8 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9398
12141
  const db = config2.getDb(context2);
9399
12142
  for (const operation of changedSets) {
9400
12143
  if (operation.operation === "delete") {
12144
+ await db.prepare("DELETE FROM bundle_patches WHERE bundle_id = ?").bind(operation.data.id).run();
12145
+ await db.prepare("DELETE FROM bundle_patches WHERE base_bundle_id = ?").bind(operation.data.id).run();
9401
12146
  await db.prepare("DELETE FROM bundles WHERE id = ?").bind(operation.data.id).run();
9402
12147
  continue;
9403
12148
  }
@@ -9416,10 +12161,13 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9416
12161
  storage_uri,
9417
12162
  fingerprint_hash,
9418
12163
  metadata,
12164
+ manifest_storage_uri,
12165
+ manifest_file_hash,
12166
+ asset_base_storage_uri,
9419
12167
  rollout_cohort_count,
9420
12168
  target_cohorts
9421
12169
  )
9422
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
12170
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
9423
12171
  `).bind(
9424
12172
  bundle.id,
9425
12173
  bundle.channel,
@@ -9432,10 +12180,39 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
9432
12180
  bundle.targetAppVersion,
9433
12181
  bundle.storageUri,
9434
12182
  bundle.fingerprintHash,
9435
- JSON.stringify(bundle.metadata ?? {}),
12183
+ JSON.stringify(
12184
+ stripBundleArtifactMetadata(bundle.metadata) ?? {}
12185
+ ),
12186
+ getManifestStorageUri(bundle),
12187
+ getManifestFileHash(bundle),
12188
+ getAssetBaseStorageUri(bundle),
9436
12189
  bundle.rolloutCohortCount ?? DEFAULT_ROLLOUT_COHORT_COUNT,
9437
12190
  bundle.targetCohorts ? JSON.stringify(bundle.targetCohorts) : null
9438
12191
  ).run();
12192
+ await db.prepare("DELETE FROM bundle_patches WHERE bundle_id = ?").bind(bundle.id).run();
12193
+ const patchRows = bundleToPatchRows(bundle);
12194
+ for (const patchRow of patchRows) {
12195
+ await db.prepare(`
12196
+ INSERT OR REPLACE INTO bundle_patches (
12197
+ id,
12198
+ bundle_id,
12199
+ base_bundle_id,
12200
+ base_file_hash,
12201
+ patch_file_hash,
12202
+ patch_storage_uri,
12203
+ order_index
12204
+ )
12205
+ VALUES (?, ?, ?, ?, ?, ?, ?)
12206
+ `).bind(
12207
+ patchRow.id,
12208
+ patchRow.bundle_id,
12209
+ patchRow.base_bundle_id,
12210
+ patchRow.base_file_hash,
12211
+ patchRow.patch_file_hash,
12212
+ patchRow.patch_storage_uri,
12213
+ patchRow.order_index ?? 0
12214
+ ).run();
12215
+ }
9439
12216
  }
9440
12217
  }
9441
12218
  };
@@ -9460,33 +12237,47 @@ var resolveJwtSecretFromContext = /* @__PURE__ */ __name((context2) => {
9460
12237
  }
9461
12238
  return jwtSecret;
9462
12239
  }, "resolveJwtSecretFromContext");
12240
+ var resolveR2BucketFromContext = /* @__PURE__ */ __name((context2) => {
12241
+ const bucket = context2?.env?.BUCKET;
12242
+ if (!bucket) {
12243
+ throw new Error(
12244
+ "r2WorkerStorage requires env.BUCKET in the hot updater context."
12245
+ );
12246
+ }
12247
+ return bucket;
12248
+ }, "resolveR2BucketFromContext");
12249
+ var createPublicObjectPath = /* @__PURE__ */ __name((storageUrl) => `${storageUrl.host}${storageUrl.pathname}`, "createPublicObjectPath");
12250
+ var createR2ObjectKey = /* @__PURE__ */ __name((storageUrl) => storageUrl.pathname.replace(/^\/+/, ""), "createR2ObjectKey");
9463
12251
  var r2WorkerStorage = /* @__PURE__ */ __name((config2) => {
9464
- return () => {
9465
- return {
9466
- name: "r2WorkerStorage",
9467
- supportedProtocol: "r2",
9468
- async upload() {
9469
- throw new Error(
9470
- "r2WorkerStorage does not support upload() in the worker runtime."
9471
- );
9472
- },
9473
- async delete() {
9474
- throw new Error(
9475
- "r2WorkerStorage does not support delete() in the worker runtime."
9476
- );
12252
+ return createRuntimeStoragePlugin({
12253
+ name: "r2WorkerStorage",
12254
+ supportedProtocol: "r2",
12255
+ factory: /* @__PURE__ */ __name((config3) => ({
12256
+ async readText(storageUri, context2) {
12257
+ const storageUrl = new URL(storageUri);
12258
+ if (storageUrl.protocol !== "r2:") {
12259
+ throw new Error("Invalid R2 storage URI protocol");
12260
+ }
12261
+ const bucket = resolveR2BucketFromContext(context2);
12262
+ const key = createR2ObjectKey(storageUrl);
12263
+ const object = await bucket.get(key);
12264
+ if (!object) {
12265
+ return null;
12266
+ }
12267
+ return object.text();
9477
12268
  },
9478
12269
  async getDownloadUrl(storageUri, context2) {
9479
12270
  const storageUrl = new URL(storageUri);
9480
12271
  if (storageUrl.protocol !== "r2:") {
9481
12272
  throw new Error("Invalid R2 storage URI protocol");
9482
12273
  }
9483
- const key = `${storageUrl.host}${storageUrl.pathname}`;
12274
+ const key = createPublicObjectPath(storageUrl);
9484
12275
  const [jwtSecret, publicBaseUrl] = await Promise.all([
9485
12276
  resolveContextValue(
9486
- config2.jwtSecret ?? resolveJwtSecretFromContext,
12277
+ config3.jwtSecret ?? resolveJwtSecretFromContext,
9487
12278
  context2
9488
12279
  ),
9489
- resolveContextValue(config2.publicBaseUrl, context2)
12280
+ resolveContextValue(config3.publicBaseUrl, context2)
9490
12281
  ]);
9491
12282
  const token = await signToken(key, jwtSecret);
9492
12283
  const url = new URL(publicBaseUrl);
@@ -9497,8 +12288,8 @@ var r2WorkerStorage = /* @__PURE__ */ __name((config2) => {
9497
12288
  fileUrl: url.toString()
9498
12289
  };
9499
12290
  }
9500
- };
9501
- };
12291
+ }), "factory")
12292
+ })(config2);
9502
12293
  }, "r2WorkerStorage");
9503
12294
 
9504
12295
  // src/worker/index.ts