andysu-capacitor 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.
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Capacitor plugin. In an app it is linked by `npx cap sync`; in the AndySU repo it compiles
|
|
2
2
|
// against :api. The host provides the one runtime copy of the API (compileOnly).
|
|
3
3
|
apply plugin: "com.android.library"
|
|
4
|
-
def andysuVersion = project.findProperty("andysuVersion") ?: "0.1.
|
|
4
|
+
def andysuVersion = project.findProperty("andysuVersion") ?: "0.1.112"
|
|
5
5
|
android {
|
|
6
6
|
namespace "com.andysu.capacitor"
|
|
7
7
|
compileSdk 36
|
|
@@ -9,6 +9,7 @@ import com.getcapacitor.PluginMethod;
|
|
|
9
9
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
10
10
|
|
|
11
11
|
import org.json.JSONException;
|
|
12
|
+
import org.json.JSONObject;
|
|
12
13
|
|
|
13
14
|
/** Capacitor bridge to the AndySU host (com.andysu.api.Host). */
|
|
14
15
|
@CapacitorPlugin(name = "AndySU")
|
|
@@ -78,6 +79,28 @@ public class AndySUPlugin extends Plugin {
|
|
|
78
79
|
call.resolve(o);
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
// Update mode needs Host API level 3; older hosts lack the methods, so check first.
|
|
83
|
+
private static boolean hasUpdateMode(HostApi h) {
|
|
84
|
+
return h != null && h.apiLevel() >= 3;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@PluginMethod
|
|
88
|
+
public void setUpdateMode(PluginCall call) {
|
|
89
|
+
HostApi h = host();
|
|
90
|
+
if (hasUpdateMode(h)) h.updates().setMode(call.getString("mode"));
|
|
91
|
+
call.resolve();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@PluginMethod
|
|
95
|
+
public void updateMode(PluginCall call) {
|
|
96
|
+
HostApi h = host();
|
|
97
|
+
String m = hasUpdateMode(h) ? h.updates().mode() : null;
|
|
98
|
+
JSObject o = new JSObject();
|
|
99
|
+
// JSONObject.put(key, null) would drop the key; NULL keeps an explicit null in the result.
|
|
100
|
+
o.put("mode", m == null ? JSONObject.NULL : m);
|
|
101
|
+
call.resolve(o);
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
@Override
|
|
82
105
|
public void load() {
|
|
83
106
|
HostApi h = host();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PluginListenerHandle } from '@capacitor/core';
|
|
2
2
|
export type ApplyPolicy = 'live' | 'restart' | 'next_start';
|
|
3
|
+
export type UpdateMode = 'auto' | 'download_only' | 'check_only' | 'off';
|
|
3
4
|
export interface Status {
|
|
4
5
|
state: string;
|
|
5
6
|
release?: string;
|
|
@@ -24,6 +25,14 @@ export interface AndySUPlugin {
|
|
|
24
25
|
applyPolicy(): Promise<{
|
|
25
26
|
policy: ApplyPolicy;
|
|
26
27
|
}>;
|
|
28
|
+
/** Needs Host API level 3; a no-op on an older host. Null returns to the configured mode. */
|
|
29
|
+
setUpdateMode(o: {
|
|
30
|
+
mode: UpdateMode | null;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/** Resolves `mode: null` when the host is absent or older than API level 3. */
|
|
33
|
+
updateMode(): Promise<{
|
|
34
|
+
mode: UpdateMode | null;
|
|
35
|
+
}>;
|
|
27
36
|
addListener(event: 'status', cb: (s: Status) => void): Promise<PluginListenerHandle>;
|
|
28
37
|
}
|
|
29
38
|
export declare const AndySU: AndySUPlugin;
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ const web = {
|
|
|
12
12
|
markHealthy: async () => { },
|
|
13
13
|
setApplyPolicy: async () => { },
|
|
14
14
|
applyPolicy: async () => ({ policy: 'live' }),
|
|
15
|
+
setUpdateMode: async () => { },
|
|
16
|
+
updateMode: async () => ({ mode: null }),
|
|
15
17
|
addListener: async () => ({ remove: async () => { } }),
|
|
16
18
|
};
|
|
17
19
|
exports.AndySU = (0, core_1.registerPlugin)('AndySU', { web });
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { registerPlugin, PluginListenerHandle } from '@capacitor/core';
|
|
|
2
2
|
|
|
3
3
|
export type ApplyPolicy = 'live' | 'restart' | 'next_start';
|
|
4
4
|
|
|
5
|
+
export type UpdateMode = 'auto' | 'download_only' | 'check_only' | 'off';
|
|
6
|
+
|
|
5
7
|
export interface Status { state: string; release?: string; [k: string]: unknown }
|
|
6
8
|
|
|
7
9
|
export interface AndySUPlugin {
|
|
@@ -13,6 +15,10 @@ export interface AndySUPlugin {
|
|
|
13
15
|
markHealthy(): Promise<void>;
|
|
14
16
|
setApplyPolicy(o: { policy: ApplyPolicy | null }): Promise<void>;
|
|
15
17
|
applyPolicy(): Promise<{ policy: ApplyPolicy }>;
|
|
18
|
+
/** Needs Host API level 3; a no-op on an older host. Null returns to the configured mode. */
|
|
19
|
+
setUpdateMode(o: { mode: UpdateMode | null }): Promise<void>;
|
|
20
|
+
/** Resolves `mode: null` when the host is absent or older than API level 3. */
|
|
21
|
+
updateMode(): Promise<{ mode: UpdateMode | null }>;
|
|
16
22
|
addListener(event: 'status', cb: (s: Status) => void): Promise<PluginListenerHandle>;
|
|
17
23
|
}
|
|
18
24
|
|
|
@@ -26,6 +32,8 @@ const web: AndySUPlugin = {
|
|
|
26
32
|
markHealthy: async () => {},
|
|
27
33
|
setApplyPolicy: async () => {},
|
|
28
34
|
applyPolicy: async () => ({ policy: 'live' }),
|
|
35
|
+
setUpdateMode: async () => {},
|
|
36
|
+
updateMode: async () => ({ mode: null }),
|
|
29
37
|
addListener: async () => ({ remove: async () => {} }),
|
|
30
38
|
};
|
|
31
39
|
|