@hot-updater/js 0.6.0 → 0.6.1-rc.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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Filters target app versions that are compatible with the current app version.
3
+ * Returns only versions that are compatible with the current version according to semver rules.
4
+ *
5
+ * @param targetAppVersionList - List of target app versions to filter
6
+ * @param currentVersion - Current app version
7
+ * @returns Array of target app versions compatible with the current version
8
+ */
9
+ export declare const filterCompatibleAppVersions: (targetAppVersionList: string[], currentVersion: string) => string[];
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.cjs CHANGED
@@ -400,7 +400,7 @@ var __webpack_modules__ = {
400
400
  debug('prerelease compare', i, a, b);
401
401
  if (void 0 === a && void 0 === b) return 0;
402
402
  if (void 0 === b) return 1;
403
- else if (void 0 === a) return -1;
403
+ if (void 0 === a) return -1;
404
404
  else if (a === b) continue;
405
405
  else return compareIdentifiers(a, b);
406
406
  }while (++i);
@@ -414,7 +414,7 @@ var __webpack_modules__ = {
414
414
  debug('build compare', i, a, b);
415
415
  if (void 0 === a && void 0 === b) return 0;
416
416
  if (void 0 === b) return 1;
417
- else if (void 0 === a) return -1;
417
+ if (void 0 === a) return -1;
418
418
  else if (a === b) continue;
419
419
  else return compareIdentifiers(a, b);
420
420
  }while (++i);
@@ -1364,7 +1364,9 @@ var __webpack_exports__ = {};
1364
1364
  "use strict";
1365
1365
  __webpack_require__.r(__webpack_exports__);
1366
1366
  __webpack_require__.d(__webpack_exports__, {
1367
- getUpdateInfo: ()=>getUpdateInfo
1367
+ getUpdateInfo: ()=>getUpdateInfo,
1368
+ filterCompatibleAppVersions: ()=>filterCompatibleAppVersions,
1369
+ semverSatisfies: ()=>semverSatisfies
1368
1370
  });
1369
1371
  const core_namespaceObject = require("@hot-updater/core");
1370
1372
  const isNullable = (value)=>null == value;
@@ -1380,7 +1382,7 @@ var __webpack_exports__ = {};
1380
1382
  var semver_default = /*#__PURE__*/ __webpack_require__.n(semver);
1381
1383
  const semverSatisfies = (targetAppVersion, currentVersion)=>{
1382
1384
  const currentCoerce = semver_default().coerce(currentVersion);
1383
- if (!currentCoerce) throw new Error("Invalid current version");
1385
+ if (!currentCoerce) return false;
1384
1386
  return semver_default().satisfies(currentCoerce.version, targetAppVersion);
1385
1387
  };
1386
1388
  const findLatestBundles = (bundles)=>bundles?.filter((item)=>item.enabled)?.sort((a, b)=>b.id.localeCompare(a.id))?.[0] ?? null;
@@ -1403,7 +1405,7 @@ var __webpack_exports__ = {};
1403
1405
  if (latestBundle.id === bundleId) return null;
1404
1406
  if (latestBundle.id.localeCompare(bundleId) > 0) return {
1405
1407
  id: latestBundle.id,
1406
- shouldForceUpdate: latestBundle.shouldForceUpdate,
1408
+ shouldForceUpdate: Boolean(latestBundle.shouldForceUpdate),
1407
1409
  fileUrl: latestBundle.fileUrl,
1408
1410
  fileHash: latestBundle.fileHash,
1409
1411
  status: "UPDATE"
@@ -1419,13 +1421,17 @@ var __webpack_exports__ = {};
1419
1421
  }
1420
1422
  if (latestBundle.id.localeCompare(bundleId) > 0) return {
1421
1423
  id: latestBundle.id,
1422
- shouldForceUpdate: latestBundle.shouldForceUpdate,
1424
+ shouldForceUpdate: Boolean(latestBundle.shouldForceUpdate),
1423
1425
  fileUrl: latestBundle.fileUrl,
1424
1426
  fileHash: latestBundle.fileHash,
1425
1427
  status: "UPDATE"
1426
1428
  };
1427
1429
  return null;
1428
1430
  };
1431
+ const filterCompatibleAppVersions = (targetAppVersionList, currentVersion)=>{
1432
+ const compatibleAppVersionList = targetAppVersionList.filter((version)=>semverSatisfies(version, currentVersion));
1433
+ return compatibleAppVersionList.sort((a, b)=>b.localeCompare(a));
1434
+ };
1429
1435
  })();
1430
1436
  var __webpack_export_target__ = exports;
1431
1437
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from "./getUpdateInfo";
2
+ export * from "./semverSatisfies";
3
+ export * from "./filterCompatibleAppVersions";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_core__ from "@hot-updater/core";
1
+ import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_core_132f924c__ from "@hot-updater/core";
2
2
  var __webpack_modules__ = {
3
3
  "../../node_modules/.pnpm/semver@7.6.3/node_modules/semver/classes/comparator.js": function(module, __unused_webpack_exports, __webpack_require__) {
4
4
  const ANY = Symbol('SemVer ANY');
@@ -401,7 +401,7 @@ var __webpack_modules__ = {
401
401
  debug('prerelease compare', i, a, b);
402
402
  if (void 0 === a && void 0 === b) return 0;
403
403
  if (void 0 === b) return 1;
404
- else if (void 0 === a) return -1;
404
+ if (void 0 === a) return -1;
405
405
  else if (a === b) continue;
406
406
  else return compareIdentifiers(a, b);
407
407
  }while (++i);
@@ -415,7 +415,7 @@ var __webpack_modules__ = {
415
415
  debug('build compare', i, a, b);
416
416
  if (void 0 === a && void 0 === b) return 0;
417
417
  if (void 0 === b) return 1;
418
- else if (void 0 === a) return -1;
418
+ if (void 0 === a) return -1;
419
419
  else if (a === b) continue;
420
420
  else return compareIdentifiers(a, b);
421
421
  }while (++i);
@@ -1352,7 +1352,7 @@ function __webpack_require__(moduleId) {
1352
1352
  })();
1353
1353
  const isNullable = (value)=>null == value;
1354
1354
  const checkForRollback = (bundles, currentBundleId)=>{
1355
- if (currentBundleId === __WEBPACK_EXTERNAL_MODULE__hot_updater_core__.NIL_UUID) return false;
1355
+ if (currentBundleId === __WEBPACK_EXTERNAL_MODULE__hot_updater_core_132f924c__.NIL_UUID) return false;
1356
1356
  if (0 === bundles.length) return true;
1357
1357
  const enabled = bundles.find((item)=>item.id === currentBundleId)?.enabled;
1358
1358
  const availableOldVersion = bundles.find((item)=>item.id.localeCompare(currentBundleId) < 0 && item.enabled)?.enabled;
@@ -1363,7 +1363,7 @@ var semver = __webpack_require__("../../node_modules/.pnpm/semver@7.6.3/node_mod
1363
1363
  var semver_default = /*#__PURE__*/ __webpack_require__.n(semver);
1364
1364
  const semverSatisfies = (targetAppVersion, currentVersion)=>{
1365
1365
  const currentCoerce = semver_default().coerce(currentVersion);
1366
- if (!currentCoerce) throw new Error("Invalid current version");
1366
+ if (!currentCoerce) return false;
1367
1367
  return semver_default().satisfies(currentCoerce.version, targetAppVersion);
1368
1368
  };
1369
1369
  const findLatestBundles = (bundles)=>bundles?.filter((item)=>item.enabled)?.sort((a, b)=>b.id.localeCompare(a.id))?.[0] ?? null;
@@ -1373,7 +1373,7 @@ const getUpdateInfo = async (bundles, { platform, bundleId, appVersion })=>{
1373
1373
  const latestBundle = await findLatestBundles(filteredBundles);
1374
1374
  if (!latestBundle) {
1375
1375
  if (isRollback) return {
1376
- id: __WEBPACK_EXTERNAL_MODULE__hot_updater_core__.NIL_UUID,
1376
+ id: __WEBPACK_EXTERNAL_MODULE__hot_updater_core_132f924c__.NIL_UUID,
1377
1377
  shouldForceUpdate: true,
1378
1378
  fileUrl: null,
1379
1379
  fileHash: null,
@@ -1386,7 +1386,7 @@ const getUpdateInfo = async (bundles, { platform, bundleId, appVersion })=>{
1386
1386
  if (latestBundle.id === bundleId) return null;
1387
1387
  if (latestBundle.id.localeCompare(bundleId) > 0) return {
1388
1388
  id: latestBundle.id,
1389
- shouldForceUpdate: latestBundle.shouldForceUpdate,
1389
+ shouldForceUpdate: Boolean(latestBundle.shouldForceUpdate),
1390
1390
  fileUrl: latestBundle.fileUrl,
1391
1391
  fileHash: latestBundle.fileHash,
1392
1392
  status: "UPDATE"
@@ -1402,11 +1402,15 @@ const getUpdateInfo = async (bundles, { platform, bundleId, appVersion })=>{
1402
1402
  }
1403
1403
  if (latestBundle.id.localeCompare(bundleId) > 0) return {
1404
1404
  id: latestBundle.id,
1405
- shouldForceUpdate: latestBundle.shouldForceUpdate,
1405
+ shouldForceUpdate: Boolean(latestBundle.shouldForceUpdate),
1406
1406
  fileUrl: latestBundle.fileUrl,
1407
1407
  fileHash: latestBundle.fileHash,
1408
1408
  status: "UPDATE"
1409
1409
  };
1410
1410
  return null;
1411
1411
  };
1412
- export { getUpdateInfo };
1412
+ const filterCompatibleAppVersions = (targetAppVersionList, currentVersion)=>{
1413
+ const compatibleAppVersionList = targetAppVersionList.filter((version)=>semverSatisfies(version, currentVersion));
1414
+ return compatibleAppVersionList.sort((a, b)=>b.localeCompare(a));
1415
+ };
1416
+ export { filterCompatibleAppVersions, getUpdateInfo, semverSatisfies };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/js",
3
- "version": "0.6.0",
3
+ "version": "0.6.1-rc.1",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@hot-updater/core": "0.6.0"
41
+ "@hot-updater/core": "0.6.1-rc.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "semver": "^7.6.3",