hot-updater 0.31.2 → 0.31.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +59 -26
  2. package/package.json +14 -14
package/dist/index.mjs CHANGED
@@ -29319,7 +29319,19 @@ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
29319
29319
  defineLazyProperty(apps, "browser", () => "browser");
29320
29320
  defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
29321
29321
  //#endregion
29322
+ //#region ../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.js
29323
+ var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29324
+ const Range = require_range();
29325
+ const intersects = (r1, r2, options) => {
29326
+ r1 = new Range(r1, options);
29327
+ r2 = new Range(r2, options);
29328
+ return r1.intersects(r2, options);
29329
+ };
29330
+ module.exports = intersects;
29331
+ }));
29332
+ //#endregion
29322
29333
  //#region src/prompts/getPlatform.ts
29334
+ var import_intersects = /* @__PURE__ */ __toESM(require_intersects(), 1);
29323
29335
  const getPlatform = async (message) => {
29324
29336
  return await p.select({
29325
29337
  message,
@@ -29643,26 +29655,58 @@ const normalizePatchMaxBaseBundles = (maxBaseBundles) => {
29643
29655
  if (!Number.isInteger(maxBaseBundles) || maxBaseBundles < 1) throw new Error("Patch maxBaseBundles must be a positive integer");
29644
29656
  return maxBaseBundles;
29645
29657
  };
29658
+ const areTargetAppVersionsPatchCompatible = (a, b) => {
29659
+ const aRange = (0, import_valid.default)(a);
29660
+ const bRange = (0, import_valid.default)(b);
29661
+ if (!aRange || !bRange) return false;
29662
+ return (0, import_intersects.default)(aRange, bRange);
29663
+ };
29646
29664
  const getPatchBaseBundles = async ({ bundleId, channel, databasePlugin, maxBaseBundles, platform, target }) => {
29647
- const where = {
29665
+ const baseWhere = {
29648
29666
  channel,
29649
29667
  enabled: true,
29650
29668
  id: { lt: bundleId },
29651
- platform,
29652
- ...target.fingerprintHash ? { fingerprintHash: target.fingerprintHash } : {
29653
- targetAppVersion: target.appVersion,
29654
- targetAppVersionNotNull: true
29655
- }
29669
+ platform
29656
29670
  };
29657
- const { data } = await databasePlugin.getBundles({
29658
- limit: maxBaseBundles,
29659
- orderBy: {
29660
- direction: "desc",
29661
- field: "id"
29662
- },
29663
- where
29664
- });
29665
- return data.filter((bundle) => bundle.id !== bundleId).slice(0, maxBaseBundles);
29671
+ if (target.fingerprintHash) {
29672
+ const { data } = await databasePlugin.getBundles({
29673
+ limit: maxBaseBundles,
29674
+ orderBy: {
29675
+ direction: "desc",
29676
+ field: "id"
29677
+ },
29678
+ where: {
29679
+ ...baseWhere,
29680
+ fingerprintHash: target.fingerprintHash
29681
+ }
29682
+ });
29683
+ return data.filter((bundle) => bundle.id !== bundleId).slice(0, maxBaseBundles);
29684
+ }
29685
+ if (!target.appVersion) return [];
29686
+ const pageSize = Math.max(maxBaseBundles * 3, 10);
29687
+ const compatibleBundles = [];
29688
+ let cursorAfter;
29689
+ while (compatibleBundles.length < maxBaseBundles) {
29690
+ const { data, pagination } = await databasePlugin.getBundles({
29691
+ ...cursorAfter ? { cursor: { after: cursorAfter } } : {},
29692
+ limit: pageSize,
29693
+ orderBy: {
29694
+ direction: "desc",
29695
+ field: "id"
29696
+ },
29697
+ where: {
29698
+ ...baseWhere,
29699
+ targetAppVersionNotNull: true
29700
+ }
29701
+ });
29702
+ for (const bundle of data) {
29703
+ if (bundle.id !== bundleId && bundle.targetAppVersion && areTargetAppVersionsPatchCompatible(target.appVersion, bundle.targetAppVersion)) compatibleBundles.push(bundle);
29704
+ if (compatibleBundles.length >= maxBaseBundles) break;
29705
+ }
29706
+ if (!pagination.hasNextPage || !pagination.nextCursor) break;
29707
+ cursorAfter = pagination.nextCursor;
29708
+ }
29709
+ return compatibleBundles;
29666
29710
  };
29667
29711
  const createAutoPatches = async ({ bundleId, channel, databasePlugin, maxBaseBundles, platform, storagePlugin, target }) => {
29668
29712
  const baseBundles = await getPatchBaseBundles({
@@ -31103,17 +31147,6 @@ var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
31103
31147
  module.exports = ltr;
31104
31148
  }));
31105
31149
  //#endregion
31106
- //#region ../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/intersects.js
31107
- var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
31108
- const Range = require_range();
31109
- const intersects = (r1, r2, options) => {
31110
- r1 = new Range(r1, options);
31111
- r2 = new Range(r2, options);
31112
- return r1.intersects(r2, options);
31113
- };
31114
- module.exports = intersects;
31115
- }));
31116
- //#endregion
31117
31150
  //#region ../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/ranges/simplify.js
31118
31151
  var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
31119
31152
  const satisfies = require_satisfies();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hot-updater",
3
3
  "type": "module",
4
- "version": "0.31.2",
4
+ "version": "0.31.4",
5
5
  "engines": {
6
6
  "node": ">=20.19.0"
7
7
  },
@@ -46,13 +46,13 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "jiti": "2.6.1",
49
- "@hot-updater/android-helper": "0.31.2",
50
- "@hot-updater/cli-tools": "0.31.2",
51
- "@hot-updater/apple-helper": "0.31.2",
52
- "@hot-updater/console": "0.31.2",
53
- "@hot-updater/core": "0.31.2",
54
- "@hot-updater/server": "0.31.2",
55
- "@hot-updater/plugin-core": "0.31.2"
49
+ "@hot-updater/android-helper": "0.31.4",
50
+ "@hot-updater/apple-helper": "0.31.4",
51
+ "@hot-updater/cli-tools": "0.31.4",
52
+ "@hot-updater/console": "0.31.4",
53
+ "@hot-updater/core": "0.31.4",
54
+ "@hot-updater/plugin-core": "0.31.4",
55
+ "@hot-updater/server": "0.31.4"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@bacons/xcode": "1.0.0-alpha.24",
@@ -74,12 +74,12 @@
74
74
  "semver": "^7.6.3",
75
75
  "sql-formatter": "15.6.10",
76
76
  "typescript": "6.0.2",
77
- "@hot-updater/aws": "0.31.2",
78
- "@hot-updater/cloudflare": "0.31.2",
79
- "@hot-updater/firebase": "0.31.2",
80
- "@hot-updater/server": "0.31.2",
81
- "@hot-updater/supabase": "0.31.2",
82
- "@hot-updater/test-utils": "0.31.2"
77
+ "@hot-updater/aws": "0.31.4",
78
+ "@hot-updater/cloudflare": "0.31.4",
79
+ "@hot-updater/firebase": "0.31.4",
80
+ "@hot-updater/supabase": "0.31.4",
81
+ "@hot-updater/server": "0.31.4",
82
+ "@hot-updater/test-utils": "0.31.4"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@hot-updater/aws": "*",