andysu-react-native 0.1.98 → 0.1.112

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.
@@ -2,7 +2,7 @@
2
2
  // uses the published API artifact (compileOnly: the host provides the one runtime copy).
3
3
  apply plugin: "com.android.library"
4
4
 
5
- def andysuVersion = project.findProperty("andysuVersion") ?: "0.1.98"
5
+ def andysuVersion = project.findProperty("andysuVersion") ?: "0.1.112"
6
6
 
7
7
  android {
8
8
  namespace "com.andysu.reactnative"
@@ -72,6 +72,20 @@ public class AndySUModule extends ReactContextBaseJavaModule {
72
72
  p.resolve(h == null ? "live" : h.updates().applyPolicy());
73
73
  }
74
74
 
75
+ // Update mode needs Host API level 3; older hosts lack the methods, so check first.
76
+ @ReactMethod
77
+ public void setUpdateMode(String mode) {
78
+ HostApi h = Host.current();
79
+ if (h != null && h.apiLevel() >= 3) h.updates().setMode(mode);
80
+ }
81
+
82
+ @ReactMethod
83
+ public void updateMode(Promise p) {
84
+ HostApi h = Host.current();
85
+ String m = (h != null && h.apiLevel() >= 3) ? h.updates().mode() : null;
86
+ p.resolve(m == null ? "" : m);
87
+ }
88
+
75
89
  @ReactMethod
76
90
  public void markHealthy() {
77
91
  HostApi h = Host.current();
package/lib/index.d.ts CHANGED
@@ -34,6 +34,15 @@ export type ApplyPolicy = 'live' | 'restart' | 'next_start';
34
34
  */
35
35
  export declare function setApplyPolicy(policy: ApplyPolicy | null): void;
36
36
  export declare function applyPolicy(): Promise<ApplyPolicy>;
37
+ export type UpdateMode = 'auto' | 'download_only' | 'check_only' | 'off';
38
+ /**
39
+ * How much automatic updating this install performs: 'auto', 'download_only', 'check_only' or
40
+ * 'off'. Pass null to return to the mode configured in the host. Needs Host API level 3; on an
41
+ * older host this does nothing.
42
+ */
43
+ export declare function setUpdateMode(mode: UpdateMode | null): void;
44
+ /** The effective update mode, or null when the host is absent or older than API level 3. */
45
+ export declare function updateMode(): Promise<UpdateMode | null>;
37
46
  /** Commit this payload generation (call once the app is known to work). */
38
47
  export declare function markHealthy(): void;
39
48
  /** Listen for status changes. Returns an unsubscribe function. */
package/lib/index.js CHANGED
@@ -7,6 +7,8 @@ exports.applyNow = applyNow;
7
7
  exports.restartNow = restartNow;
8
8
  exports.setApplyPolicy = setApplyPolicy;
9
9
  exports.applyPolicy = applyPolicy;
10
+ exports.setUpdateMode = setUpdateMode;
11
+ exports.updateMode = updateMode;
10
12
  exports.markHealthy = markHealthy;
11
13
  exports.onStatus = onStatus;
12
14
  const react_native_1 = require("react-native");
@@ -47,6 +49,21 @@ async function applyPolicy() {
47
49
  return 'live';
48
50
  return native.applyPolicy();
49
51
  }
52
+ /**
53
+ * How much automatic updating this install performs: 'auto', 'download_only', 'check_only' or
54
+ * 'off'. Pass null to return to the mode configured in the host. Needs Host API level 3; on an
55
+ * older host this does nothing.
56
+ */
57
+ function setUpdateMode(mode) {
58
+ native === null || native === void 0 ? void 0 : native.setUpdateMode(mode);
59
+ }
60
+ /** The effective update mode, or null when the host is absent or older than API level 3. */
61
+ async function updateMode() {
62
+ if (!native)
63
+ return null;
64
+ const m = await native.updateMode();
65
+ return m ? m : null;
66
+ }
50
67
  /** Commit this payload generation (call once the app is known to work). */
51
68
  function markHealthy() {
52
69
  native === null || native === void 0 ? void 0 : native.markHealthy();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "andysu-react-native",
3
- "version": "0.1.98",
3
+ "version": "0.1.112",
4
4
  "description": "AndySU self-updates for React Native and Expo apps on Android (status, check, apply)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/index.ts CHANGED
@@ -66,6 +66,24 @@ export async function applyPolicy(): Promise<ApplyPolicy> {
66
66
  return native.applyPolicy();
67
67
  }
68
68
 
69
+ export type UpdateMode = 'auto' | 'download_only' | 'check_only' | 'off';
70
+
71
+ /**
72
+ * How much automatic updating this install performs: 'auto', 'download_only', 'check_only' or
73
+ * 'off'. Pass null to return to the mode configured in the host. Needs Host API level 3; on an
74
+ * older host this does nothing.
75
+ */
76
+ export function setUpdateMode(mode: UpdateMode | null): void {
77
+ native?.setUpdateMode(mode);
78
+ }
79
+
80
+ /** The effective update mode, or null when the host is absent or older than API level 3. */
81
+ export async function updateMode(): Promise<UpdateMode | null> {
82
+ if (!native) return null;
83
+ const m: string = await native.updateMode();
84
+ return m ? (m as UpdateMode) : null;
85
+ }
86
+
69
87
  /** Commit this payload generation (call once the app is known to work). */
70
88
  export function markHealthy(): void {
71
89
  native?.markHealthy();