@appsonair.ir/react-native 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/config.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { OTAUpdaterConfig } from './types';
2
2
  export declare function configure(options: OTAUpdaterConfig): void;
3
3
  export declare function getConfig(): OTAUpdaterConfig | null;
4
+ export declare function getServerUrl(configOverride?: OTAUpdaterConfig | null): string;
package/lib/config.js CHANGED
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configure = configure;
4
4
  exports.getConfig = getConfig;
5
+ exports.getServerUrl = getServerUrl;
6
+ const constants_1 = require("./constants");
5
7
  let config = null;
6
8
  function configure(options) {
7
- config = options;
9
+ config = {
10
+ ...options,
11
+ serverUrl: (options.serverUrl || constants_1.DEFAULT_SERVER_URL).replace(/\/$/, ''),
12
+ };
8
13
  }
9
14
  function getConfig() {
10
15
  return config;
11
16
  }
17
+ function getServerUrl(configOverride) {
18
+ const conf = configOverride ?? config;
19
+ return (conf?.serverUrl || constants_1.DEFAULT_SERVER_URL).replace(/\/$/, '');
20
+ }
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_SERVER_URL = "https://appsonair.ir";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SERVER_URL = void 0;
4
+ exports.DEFAULT_SERVER_URL = 'https://appsonair.ir';
package/lib/index.d.ts CHANGED
@@ -2,7 +2,8 @@ import { configure, getConfig } from './config';
2
2
  import { configureFromProject, getDeploymentKey, isOtaConfigured, resolveUpdaterConfig } from './projectConfig';
3
3
  import { sync, restartApp, installApk, resumePendingApkInstall, clearUpdate, getInstalledBundlePath, notifyAppReady, isSyncInProgress } from './sync';
4
4
  import { UpdateCheckResult } from './types';
5
- export { configure, getConfig };
5
+ export { configure, getConfig, getServerUrl } from './config';
6
+ export { DEFAULT_SERVER_URL } from './constants';
6
7
  export { configureFromProject, getDeploymentKey, isOtaConfigured, resolveUpdaterConfig, };
7
8
  export type { ProjectOtaConfig } from './types';
8
9
  export declare function getCurrentLabel(): Promise<string | null>;
package/lib/index.js CHANGED
@@ -17,14 +17,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.OTAUpdater = exports.OTAUpdateProvider = exports.OTAUpdateModal = exports.isSyncInProgress = exports.notifyAppReady = exports.getInstalledBundlePath = exports.clearUpdate = exports.resumePendingApkInstall = exports.installApk = exports.restartApp = exports.sync = exports.resolveUpdaterConfig = exports.isOtaConfigured = exports.getDeploymentKey = exports.configureFromProject = exports.getConfig = exports.configure = void 0;
20
+ exports.OTAUpdater = exports.OTAUpdateProvider = exports.OTAUpdateModal = exports.isSyncInProgress = exports.notifyAppReady = exports.getInstalledBundlePath = exports.clearUpdate = exports.resumePendingApkInstall = exports.installApk = exports.restartApp = exports.sync = exports.resolveUpdaterConfig = exports.isOtaConfigured = exports.getDeploymentKey = exports.configureFromProject = exports.DEFAULT_SERVER_URL = exports.getServerUrl = exports.getConfig = exports.configure = void 0;
21
21
  exports.getCurrentLabel = getCurrentLabel;
22
22
  exports.checkUpdate = checkUpdate;
23
23
  const react_native_device_info_1 = __importDefault(require("react-native-device-info"));
24
24
  const react_native_1 = require("react-native");
25
25
  const config_1 = require("./config");
26
- Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return config_1.configure; } });
27
- Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
28
26
  const projectConfig_1 = require("./projectConfig");
29
27
  Object.defineProperty(exports, "configureFromProject", { enumerable: true, get: function () { return projectConfig_1.configureFromProject; } });
30
28
  Object.defineProperty(exports, "getDeploymentKey", { enumerable: true, get: function () { return projectConfig_1.getDeploymentKey; } });
@@ -39,6 +37,12 @@ Object.defineProperty(exports, "clearUpdate", { enumerable: true, get: function
39
37
  Object.defineProperty(exports, "getInstalledBundlePath", { enumerable: true, get: function () { return sync_1.getInstalledBundlePath; } });
40
38
  Object.defineProperty(exports, "notifyAppReady", { enumerable: true, get: function () { return sync_1.notifyAppReady; } });
41
39
  Object.defineProperty(exports, "isSyncInProgress", { enumerable: true, get: function () { return sync_1.isSyncInProgress; } });
40
+ var config_2 = require("./config");
41
+ Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return config_2.configure; } });
42
+ Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_2.getConfig; } });
43
+ Object.defineProperty(exports, "getServerUrl", { enumerable: true, get: function () { return config_2.getServerUrl; } });
44
+ var constants_1 = require("./constants");
45
+ Object.defineProperty(exports, "DEFAULT_SERVER_URL", { enumerable: true, get: function () { return constants_1.DEFAULT_SERVER_URL; } });
42
46
  async function getCurrentLabel() {
43
47
  const meta = await (0, sync_1.getStoredBundleMeta)();
44
48
  return meta?.label ?? null;
@@ -52,7 +56,7 @@ async function checkUpdate() {
52
56
  const meta = await (0, sync_1.getStoredBundleMeta)();
53
57
  const clientUniqueId = await (0, sync_1.getClientUniqueId)();
54
58
  const deviceAbi = react_native_1.Platform.OS === 'android' ? await (0, sync_1.getDeviceAbi)() : undefined;
55
- return (0, sync_1.checkForUpdate)(config.serverUrl, config.deploymentKey, appVersion, meta?.label, meta?.packageHash, clientUniqueId, react_native_1.Platform.OS === 'android' ? react_native_device_info_1.default.getBuildNumber() : undefined, deviceAbi);
59
+ return (0, sync_1.checkForUpdate)((0, config_1.getServerUrl)(config), config.deploymentKey, appVersion, meta?.label, meta?.packageHash, clientUniqueId, react_native_1.Platform.OS === 'android' ? react_native_device_info_1.default.getBuildNumber() : undefined, deviceAbi);
56
60
  }
57
61
  var OTAUpdateModal_1 = require("./ui/OTAUpdateModal");
58
62
  Object.defineProperty(exports, "OTAUpdateModal", { enumerable: true, get: function () { return OTAUpdateModal_1.OTAUpdateModal; } });
@@ -5,6 +5,7 @@ exports.resolveUpdaterConfig = resolveUpdaterConfig;
5
5
  exports.isOtaConfigured = isOtaConfigured;
6
6
  exports.configureFromProject = configureFromProject;
7
7
  const config_1 = require("./config");
8
+ const constants_1 = require("./constants");
8
9
  function getIsDev(isDev) {
9
10
  if (typeof isDev === 'boolean') {
10
11
  return isDev;
@@ -19,11 +20,11 @@ function getDeploymentKey(projectConfig, isDev) {
19
20
  }
20
21
  function resolveUpdaterConfig(projectConfig, isDev) {
21
22
  const deploymentKey = getDeploymentKey(projectConfig, isDev);
22
- if (!projectConfig.serverUrl || !deploymentKey) {
23
+ if (!deploymentKey) {
23
24
  return null;
24
25
  }
25
26
  return {
26
- serverUrl: projectConfig.serverUrl,
27
+ serverUrl: (projectConfig.serverUrl || constants_1.DEFAULT_SERVER_URL).replace(/\/$/, ''),
27
28
  deploymentKey,
28
29
  installMode: projectConfig.installMode,
29
30
  };
package/lib/sync.js CHANGED
@@ -578,7 +578,7 @@ async function performSync(options = {}, onProgress, messages) {
578
578
  const deviceAbi = enableApkUpdates && react_native_1.Platform.OS === 'android'
579
579
  ? await getDeviceAbi()
580
580
  : undefined;
581
- const update = await checkForUpdate(config.serverUrl, config.deploymentKey, react_native_device_info_1.default.getVersion(), meta?.label, meta?.packageHash, clientUniqueId, buildNumber, deviceAbi);
581
+ const update = await checkForUpdate((0, config_1.getServerUrl)(config), config.deploymentKey, react_native_device_info_1.default.getVersion(), meta?.label, meta?.packageHash, clientUniqueId, buildNumber, deviceAbi);
582
582
  if (!update.updateAvailable || !update.downloadUrl || !update.label || !update.packageHash) {
583
583
  if (update.reason === 'NATIVE_VERSION_MISMATCH') {
584
584
  console.warn(`[OTA] Native version mismatch: device=${update.clientAppVersion ?? 'unknown'}, ` +
package/lib/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  export interface ProjectOtaConfig {
3
- serverUrl: string;
3
+ /** Optional — defaults to https://appsonair.ir */
4
+ serverUrl?: string;
4
5
  entryFile?: string;
5
6
  installMode?: OTAUpdaterConfig['installMode'];
6
7
  deployments: {
@@ -9,8 +10,8 @@ export interface ProjectOtaConfig {
9
10
  };
10
11
  }
11
12
  export interface OTAUpdaterConfig {
12
- /** Base URL of your OTA server, e.g. https://ota.example.com */
13
- serverUrl: string;
13
+ /** Optional defaults to https://appsonair.ir */
14
+ serverUrl?: string;
14
15
  /** Deployment key from the OTA server (Staging or Production) */
15
16
  deploymentKey: string;
16
17
  /** When to apply downloaded updates (default: immediate) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsonair.ir/react-native",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "React Native client SDK for self-hosted OTA updates",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",