@hot-updater/react-native 0.16.4 → 0.16.6

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.
@@ -44,7 +44,7 @@ public abstract class NativeHotUpdaterSpec extends ReactContextBaseJavaModule im
44
44
 
45
45
  @ReactMethod
46
46
  @DoNotStrip
47
- public abstract void updateBundle(String bundleId, String zipUrl, Promise promise);
47
+ public abstract void updateBundle(String bundleId, @Nullable String zipUrl, Promise promise);
48
48
 
49
49
  @ReactMethod
50
50
  @DoNotStrip
@@ -21,7 +21,7 @@ static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_updateBundle(jsi::Ru
21
21
  return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->updateBundle(
22
22
  rt,
23
23
  count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
24
- count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
24
+ count <= 1 || args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt))
25
25
  );
26
26
  }
27
27
  static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_getAppVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
@@ -21,7 +21,7 @@ protected:
21
21
 
22
22
  public:
23
23
  virtual void reload(jsi::Runtime &rt) = 0;
24
- virtual jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, jsi::String zipUrl) = 0;
24
+ virtual jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, std::optional<jsi::String> zipUrl) = 0;
25
25
  virtual jsi::Value getAppVersion(jsi::Runtime &rt) = 0;
26
26
  virtual jsi::Value setChannel(jsi::Runtime &rt, jsi::String channel) = 0;
27
27
  virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0;
@@ -61,7 +61,7 @@ private:
61
61
  return bridging::callFromJs<void>(
62
62
  rt, &T::reload, jsInvoker_, instance_);
63
63
  }
64
- jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, jsi::String zipUrl) override {
64
+ jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, std::optional<jsi::String> zipUrl) override {
65
65
  static_assert(
66
66
  bridging::getParameterCount(&T::updateBundle) == 3,
67
67
  "Expected updateBundle(...) to have 3 parameters");
package/dist/index.d.ts CHANGED
@@ -61,7 +61,7 @@ export declare const HotUpdater: {
61
61
  /**
62
62
  * Sets the channel for the app.
63
63
  */
64
- setChannel: (channel: string) => Promise<any>;
64
+ setChannel: (channel: string) => Promise<void>;
65
65
  /**
66
66
  * Adds a listener to HotUpdater events.
67
67
  *
package/dist/index.js CHANGED
@@ -103,16 +103,15 @@ var __webpack_exports__ = {};
103
103
  };
104
104
  const NIL_UUID = "00000000-0000-0000-0000-000000000000";
105
105
  const HotUpdater = {
106
- HOT_UPDATER_BUNDLE_ID: NIL_UUID,
107
- CHANNEL: "production"
106
+ HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
107
+ CHANNEL: __HOT_UPDATER_CHANNEL || "production"
108
108
  };
109
+ const RCTNativeHotUpdater = __webpack_require__("./src/specs/NativeHotUpdater.ts").Z;
109
110
  const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
110
111
  ios: "- You have run 'pod install'\n",
111
112
  default: ""
112
113
  }) + "- You rebuilt the app after installing the package\n- You are not using Expo Go\n";
113
- const isTurboModuleEnabled = null != global.__turboModuleProxy;
114
- const HotUpdaterModule = isTurboModuleEnabled ? __webpack_require__("./src/specs/NativeHotUpdater.ts").Z : external_react_native_.NativeModules.HotUpdater;
115
- const HotUpdaterNative = HotUpdaterModule ? HotUpdaterModule : new Proxy({}, {
114
+ const HotUpdaterNative = RCTNativeHotUpdater ? RCTNativeHotUpdater : new Proxy({}, {
116
115
  get () {
117
116
  throw new Error(LINKING_ERROR);
118
117
  }
package/dist/index.mjs CHANGED
@@ -78,16 +78,15 @@ const fetchUpdateInfo = async (source, { appVersion, bundleId, platform, minBund
78
78
  };
79
79
  const NIL_UUID = "00000000-0000-0000-0000-000000000000";
80
80
  const HotUpdater = {
81
- HOT_UPDATER_BUNDLE_ID: NIL_UUID,
82
- CHANNEL: "production"
81
+ HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
82
+ CHANNEL: __HOT_UPDATER_CHANNEL || "production"
83
83
  };
84
+ const RCTNativeHotUpdater = __webpack_require__("./src/specs/NativeHotUpdater.ts").Z;
84
85
  const LINKING_ERROR = `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` + external_react_native_.Platform.select({
85
86
  ios: "- You have run 'pod install'\n",
86
87
  default: ""
87
88
  }) + "- You rebuilt the app after installing the package\n- You are not using Expo Go\n";
88
- const isTurboModuleEnabled = null != global.__turboModuleProxy;
89
- const HotUpdaterModule = isTurboModuleEnabled ? __webpack_require__("./src/specs/NativeHotUpdater.ts").Z : external_react_native_.NativeModules.HotUpdater;
90
- const HotUpdaterNative = HotUpdaterModule ? HotUpdaterModule : new Proxy({}, {
89
+ const HotUpdaterNative = RCTNativeHotUpdater ? RCTNativeHotUpdater : new Proxy({}, {
91
90
  get () {
92
91
  throw new Error(LINKING_ERROR);
93
92
  }
package/dist/native.d.ts CHANGED
@@ -37,5 +37,5 @@ export declare const getBundleId: () => string;
37
37
  /**
38
38
  * Sets the channel for the app.
39
39
  */
40
- export declare const setChannel: (channel: string) => Promise<any>;
40
+ export declare const setChannel: (channel: string) => Promise<void>;
41
41
  export declare const getChannel: () => string | null;
@@ -0,0 +1,20 @@
1
+ import type { TurboModule } from "react-native";
2
+ export interface Spec extends TurboModule {
3
+ reload(): void;
4
+ updateBundle(bundleId: string, zipUrl: string | null): Promise<boolean>;
5
+ /**
6
+ * @deprecated
7
+ * use getConstants().APP_VERSION instead
8
+ */
9
+ getAppVersion(): Promise<string | null>;
10
+ setChannel(channel: string): Promise<void>;
11
+ addListener(eventName: string): void;
12
+ removeListeners(count: number): void;
13
+ readonly getConstants: () => {
14
+ MIN_BUNDLE_ID: string;
15
+ APP_VERSION: string | null;
16
+ CHANNEL: string | null;
17
+ };
18
+ }
19
+ declare const _default: Spec | null;
20
+ export default _default;
@@ -63,7 +63,7 @@ namespace JS {
63
63
 
64
64
  - (void)reload;
65
65
  - (void)updateBundle:(NSString *)bundleId
66
- zipUrl:(NSString *)zipUrl
66
+ zipUrl:(NSString * _Nullable)zipUrl
67
67
  resolve:(RCTPromiseResolveBlock)resolve
68
68
  reject:(RCTPromiseRejectBlock)reject;
69
69
  - (void)getAppVersion:(RCTPromiseResolveBlock)resolve
@@ -21,7 +21,7 @@ static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_updateBundle(jsi::Ru
21
21
  return static_cast<NativeHotUpdaterCxxSpecJSI *>(&turboModule)->updateBundle(
22
22
  rt,
23
23
  count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
24
- count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
24
+ count <= 1 || args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt))
25
25
  );
26
26
  }
27
27
  static jsi::Value __hostFunction_NativeHotUpdaterCxxSpecJSI_getAppVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
@@ -21,7 +21,7 @@ protected:
21
21
 
22
22
  public:
23
23
  virtual void reload(jsi::Runtime &rt) = 0;
24
- virtual jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, jsi::String zipUrl) = 0;
24
+ virtual jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, std::optional<jsi::String> zipUrl) = 0;
25
25
  virtual jsi::Value getAppVersion(jsi::Runtime &rt) = 0;
26
26
  virtual jsi::Value setChannel(jsi::Runtime &rt, jsi::String channel) = 0;
27
27
  virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0;
@@ -61,7 +61,7 @@ private:
61
61
  return bridging::callFromJs<void>(
62
62
  rt, &T::reload, jsInvoker_, instance_);
63
63
  }
64
- jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, jsi::String zipUrl) override {
64
+ jsi::Value updateBundle(jsi::Runtime &rt, jsi::String bundleId, std::optional<jsi::String> zipUrl) override {
65
65
  static_assert(
66
66
  bridging::getParameterCount(&T::updateBundle) == 3,
67
67
  "Expected updateBundle(...) to have 3 parameters");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/react-native",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "description": "React Native OTA solution for self-hosted",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -81,8 +81,8 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "use-sync-external-store": "1.4.0",
84
- "@hot-updater/js": "0.16.4",
85
- "@hot-updater/core": "0.16.4"
84
+ "@hot-updater/js": "0.16.6",
85
+ "@hot-updater/core": "0.16.6"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "rslib build",
package/src/native.ts CHANGED
@@ -1,12 +1,17 @@
1
- import { NativeEventEmitter, NativeModules, Platform } from "react-native";
2
-
1
+ import { NativeEventEmitter, Platform } from "react-native";
2
+ import type { Spec } from "./specs/NativeHotUpdater";
3
3
  const NIL_UUID = "00000000-0000-0000-0000-000000000000";
4
4
 
5
+ declare const __HOT_UPDATER_BUNDLE_ID: string | undefined;
6
+ declare const __HOT_UPDATER_CHANNEL: string | undefined;
7
+
5
8
  const HotUpdater = {
6
- HOT_UPDATER_BUNDLE_ID: NIL_UUID,
7
- CHANNEL: "production",
9
+ HOT_UPDATER_BUNDLE_ID: __HOT_UPDATER_BUNDLE_ID || NIL_UUID,
10
+ CHANNEL: __HOT_UPDATER_CHANNEL || "production",
8
11
  };
9
12
 
13
+ const RCTNativeHotUpdater = require("./specs/NativeHotUpdater").default;
14
+
10
15
  const LINKING_ERROR =
11
16
  // biome-ignore lint/style/useTemplate: <explanation>
12
17
  `The package '@hot-updater/react-native' doesn't seem to be linked. Make sure: \n\n` +
@@ -14,23 +19,18 @@ const LINKING_ERROR =
14
19
  "- You rebuilt the app after installing the package\n" +
15
20
  "- You are not using Expo Go\n";
16
21
 
17
- // @ts-expect-error
18
- const isTurboModuleEnabled = global.__turboModuleProxy != null;
19
-
20
- const HotUpdaterModule = isTurboModuleEnabled
21
- ? require("./specs/NativeHotUpdater").default
22
- : NativeModules.HotUpdater;
23
-
24
- const HotUpdaterNative = HotUpdaterModule
25
- ? HotUpdaterModule
26
- : new Proxy(
27
- {},
28
- {
29
- get() {
30
- throw new Error(LINKING_ERROR);
22
+ const HotUpdaterNative = (
23
+ RCTNativeHotUpdater
24
+ ? RCTNativeHotUpdater
25
+ : new Proxy(
26
+ {},
27
+ {
28
+ get() {
29
+ throw new Error(LINKING_ERROR);
30
+ },
31
31
  },
32
- },
33
- );
32
+ )
33
+ ) as Spec;
34
34
 
35
35
  export type HotUpdaterEvent = {
36
36
  onProgress: {
@@ -1,10 +1,10 @@
1
1
  import type { TurboModule } from "react-native";
2
2
  import { TurboModuleRegistry } from "react-native";
3
3
 
4
- interface Spec extends TurboModule {
4
+ export interface Spec extends TurboModule {
5
5
  // Methods
6
6
  reload(): void;
7
- updateBundle(bundleId: string, zipUrl: string): Promise<boolean>;
7
+ updateBundle(bundleId: string, zipUrl: string | null): Promise<boolean>;
8
8
  /**
9
9
  * @deprecated
10
10
  * use getConstants().APP_VERSION instead