@vexor-push/react-native-code-push 0.2.0

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.
Files changed (57) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +61 -0
  3. package/android/build.gradle +129 -0
  4. package/android/generated/java/com/vexorpush/codepush/NativeVexorCodePushSpec.java +91 -0
  5. package/android/generated/jni/CMakeLists.txt +36 -0
  6. package/android/generated/jni/RNVexorCodePushSpec-generated.cpp +110 -0
  7. package/android/generated/jni/RNVexorCodePushSpec.h +31 -0
  8. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ComponentDescriptors.cpp +22 -0
  9. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ComponentDescriptors.h +24 -0
  10. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/EventEmitters.cpp +16 -0
  11. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/EventEmitters.h +17 -0
  12. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/Props.cpp +19 -0
  13. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/Props.h +18 -0
  14. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/RNVexorCodePushSpecJSI-generated.cpp +129 -0
  15. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/RNVexorCodePushSpecJSI.h +184 -0
  16. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ShadowNodes.cpp +17 -0
  17. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ShadowNodes.h +23 -0
  18. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/States.cpp +16 -0
  19. package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/States.h +19 -0
  20. package/android/gradle.properties +5 -0
  21. package/android/src/main/AndroidManifest.xml +3 -0
  22. package/android/src/main/AndroidManifestNew.xml +2 -0
  23. package/android/src/main/java/com/vexorpush/codepush/CrashHandler.kt +78 -0
  24. package/android/src/main/java/com/vexorpush/codepush/SharedPrefs.kt +60 -0
  25. package/android/src/main/java/com/vexorpush/codepush/Utils.kt +105 -0
  26. package/android/src/main/java/com/vexorpush/codepush/VexorCodePush.kt +100 -0
  27. package/android/src/main/java/com/vexorpush/codepush/VexorCodePushModule.kt +698 -0
  28. package/android/src/newarch/VexorCodePushSpec.kt +7 -0
  29. package/android/src/oldarch/VexorCodePushSpec.kt +24 -0
  30. package/app.plugin.js +1 -0
  31. package/current-version.js +27 -0
  32. package/deployment-state.js +33 -0
  33. package/index.d.ts +101 -0
  34. package/index.js +535 -0
  35. package/ios/VexorCodePush.h +13 -0
  36. package/ios/VexorCodePush.mm +949 -0
  37. package/ios/generated/RNVexorCodePushSpec/ComponentDescriptors.cpp +22 -0
  38. package/ios/generated/RNVexorCodePushSpec/ComponentDescriptors.h +24 -0
  39. package/ios/generated/RNVexorCodePushSpec/EventEmitters.cpp +16 -0
  40. package/ios/generated/RNVexorCodePushSpec/EventEmitters.h +17 -0
  41. package/ios/generated/RNVexorCodePushSpec/Props.cpp +19 -0
  42. package/ios/generated/RNVexorCodePushSpec/Props.h +18 -0
  43. package/ios/generated/RNVexorCodePushSpec/RCTComponentViewHelpers.h +18 -0
  44. package/ios/generated/RNVexorCodePushSpec/RNVexorCodePushSpec-generated.mm +130 -0
  45. package/ios/generated/RNVexorCodePushSpec/RNVexorCodePushSpec.h +109 -0
  46. package/ios/generated/RNVexorCodePushSpec/ShadowNodes.cpp +17 -0
  47. package/ios/generated/RNVexorCodePushSpec/ShadowNodes.h +23 -0
  48. package/ios/generated/RNVexorCodePushSpec/States.cpp +16 -0
  49. package/ios/generated/RNVexorCodePushSpec/States.h +19 -0
  50. package/ios/generated/RNVexorCodePushSpecJSI-generated.cpp +129 -0
  51. package/ios/generated/RNVexorCodePushSpecJSI.h +184 -0
  52. package/package.json +51 -0
  53. package/plugin/src/index.ts +92 -0
  54. package/plugin/tsconfig.json +9 -0
  55. package/react-native-code-push.podspec +48 -0
  56. package/react-native.config.js +13 -0
  57. package/src/NativeVexorCodePush.ts +21 -0
@@ -0,0 +1,24 @@
1
+ package com.vexorpush.codepush
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.Promise
6
+
7
+ abstract class VexorCodePushSpec internal constructor(context: ReactApplicationContext) :
8
+ ReactContextBaseJavaModule(context) {
9
+
10
+ abstract fun setupBundlePath(path: String?, extension: String?, version: Double?, maxVersions: Double?, metadata: String?, promise: Promise)
11
+ abstract fun downloadAndInstallBundle(url: String?, headersJson: String?, extension: String?, version: Double?, maxVersions: Double?, metadata: String?, promise: Promise)
12
+ abstract fun deleteBundle(i: Double, promise: Promise)
13
+ abstract fun restart()
14
+ abstract fun getCurrentVersion(a: Double, promise: Promise)
15
+ abstract fun setCurrentVersion(version: String?, promise: Promise)
16
+ abstract fun setExactBundlePath(path: String?, promise: Promise)
17
+ abstract fun rollbackToPreviousBundle(a: Double, promise: Promise)
18
+ abstract fun getUpdateMetadata(a: Double, promise: Promise)
19
+ abstract fun setUpdateMetadata(metadata: String?, promise: Promise)
20
+ abstract fun getBundleList(a: Double, promise: Promise)
21
+ abstract fun deleteBundleById(id: String, promise: Promise)
22
+ abstract fun clearAllBundles(a: Double, promise: Promise)
23
+ abstract fun writeFile(path: String?, base64Content: String?, encoding: String?, promise: Promise)
24
+ }
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build/index');
@@ -0,0 +1,27 @@
1
+ function normalizeVersion(value) {
2
+ const version = Number(value);
3
+ return Number.isFinite(version) ? version : undefined;
4
+ }
5
+
6
+ function resolveCurrentVersion({ storedVersion, pendingVersion, nativeVersion } = {}) {
7
+ const normalizedStoredVersion = normalizeVersion(storedVersion);
8
+
9
+ if (Number.isFinite(normalizedStoredVersion)) {
10
+ return normalizedStoredVersion;
11
+ }
12
+
13
+ const normalizedPendingVersion = normalizeVersion(pendingVersion);
14
+
15
+ if (Number.isFinite(normalizedPendingVersion)) {
16
+ return normalizedPendingVersion;
17
+ }
18
+
19
+ const normalizedNativeVersion = normalizeVersion(nativeVersion);
20
+
21
+ return Number.isFinite(normalizedNativeVersion) ? normalizedNativeVersion : 0;
22
+ }
23
+
24
+ module.exports = {
25
+ normalizeVersion,
26
+ resolveCurrentVersion,
27
+ };
@@ -0,0 +1,33 @@
1
+ function normalizeDeployment(deployment) {
2
+ const value = String(deployment || "").trim().toLowerCase();
3
+ if (value === "development" || value === "staging") return value;
4
+ return "production";
5
+ }
6
+
7
+ function normalizePlatform(platform) {
8
+ const value = String(platform || "").trim().toLowerCase();
9
+ return value === "android" ? "android" : "ios";
10
+ }
11
+
12
+ function getDeploymentScope(config = {}) {
13
+ const deploymentKey = String(config.deploymentKey || "").trim();
14
+ if (deploymentKey) {
15
+ return `deployment-key:${deploymentKey}`;
16
+ }
17
+
18
+ const platform = normalizePlatform(config.platform);
19
+ const appName = String(config.appName || "").trim() || "*";
20
+ const deployment = normalizeDeployment(config.deployment);
21
+ return `deployment:${platform}:${appName}:${deployment}`;
22
+ }
23
+
24
+ function makeScopedKey(prefix, config = {}) {
25
+ return `${prefix}:${getDeploymentScope(config)}`;
26
+ }
27
+
28
+ module.exports = {
29
+ getDeploymentScope,
30
+ makeScopedKey,
31
+ normalizeDeployment,
32
+ normalizePlatform,
33
+ };
package/index.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ import type { PlatformOSType } from "react-native";
2
+
3
+ export type UpdateMode = "force" | "background" | "deferred" | "prompt";
4
+
5
+ export type VexorOtaManifest = {
6
+ version: number;
7
+ downloadAndroidUrl?: string;
8
+ downloadIosUrl?: string;
9
+ download_url?: string;
10
+ label?: string;
11
+ is_mandatory?: boolean;
12
+ updateMode?: UpdateMode;
13
+ metadata?: Record<string, unknown> & {
14
+ mandatory?: boolean;
15
+ updateMode?: UpdateMode;
16
+ rollout?: number;
17
+ targetBinaryVersion?: string;
18
+ deploymentKey?: string;
19
+ };
20
+ [key: string]: unknown;
21
+ };
22
+
23
+ export type VexorOtaConfig = {
24
+ baseUrl?: string;
25
+ appName?: string;
26
+ deploymentKey?: string;
27
+ deployment?: string;
28
+ binaryVersion?: string;
29
+ platform?: PlatformOSType;
30
+ clientId?: string;
31
+ previousDeploymentKey?: string;
32
+ previousLabelOrAppVersion?: string;
33
+ downloadRetryAttempts?: number;
34
+ downloadRetryDelayMs?: number;
35
+ debug?: boolean;
36
+ storage?: {
37
+ getItem: (key: string) => string | null | Promise<string | null>;
38
+ setItem: (key: string, value: string) => void | Promise<void>;
39
+ removeItem: (key: string) => void | Promise<void>;
40
+ };
41
+ headers?: Record<string, string>;
42
+ };
43
+
44
+ export type CheckUpdateOptions = Partial<VexorOtaConfig> & {
45
+ currentVersion?: number;
46
+ };
47
+
48
+ export type VexorOtaUpdate = {
49
+ currentVersion: number;
50
+ hasUpdate: boolean;
51
+ manifest: VexorOtaManifest;
52
+ manifestUrl: string;
53
+ version: number;
54
+ downloadUrl?: string;
55
+ mandatory: boolean;
56
+ updateMode: UpdateMode;
57
+ metadata: Record<string, unknown>;
58
+ };
59
+
60
+ export type InstallUpdateOptions = Partial<VexorOtaConfig> & {
61
+ restartAfterInstall?: boolean;
62
+ restartDelay?: number;
63
+ extensionBundle?: string;
64
+ maxBundleVersions?: number;
65
+ rollbackOnFailedPending?: boolean;
66
+ restartAfterRollback?: boolean;
67
+ onSuccess?: () => void;
68
+ onError?: (error?: unknown) => void;
69
+ onProgress?: (received: string | number, total: string | number) => void;
70
+ onDownloadAttempt?: (info: {
71
+ attempt: number;
72
+ attempts: number;
73
+ downloadUrl: string;
74
+ version: number;
75
+ }) => void;
76
+ };
77
+
78
+ export function configure(config: VexorOtaConfig): VexorOtaConfig &
79
+ Required<Pick<VexorOtaConfig, "baseUrl" | "deployment" | "binaryVersion" | "platform">>;
80
+ export function getConfig(): Partial<VexorOtaConfig>;
81
+ export function getCurrentVersion(config?: Partial<VexorOtaConfig>): Promise<number>;
82
+ export function getClientUniqueId(config?: Partial<VexorOtaConfig>): Promise<string>;
83
+ export function checkUpdate(options?: CheckUpdateOptions): Promise<VexorOtaUpdate>;
84
+ export function installUpdate(update: VexorOtaUpdate | VexorOtaManifest, options?: InstallUpdateOptions): Promise<void>;
85
+ export function sync(options?: CheckUpdateOptions & InstallUpdateOptions): Promise<VexorOtaUpdate>;
86
+ export function reset(restart?: boolean): void;
87
+ export function notifyApplicationReady(options?: Partial<VexorOtaConfig>): Promise<{
88
+ status: "none" | "ready";
89
+ pending?: Record<string, unknown>;
90
+ }>;
91
+ export function checkPendingUpdate(options?: Partial<VexorOtaConfig> & {
92
+ rollbackOnFailedPending?: boolean;
93
+ restartAfterRollback?: boolean;
94
+ }): Promise<{
95
+ status: "none" | "pending" | "rolledBack";
96
+ pending?: Record<string, unknown>;
97
+ }>;
98
+ export function reportDownload(payload: Record<string, unknown>, config?: Partial<VexorOtaConfig>): Promise<void>;
99
+ export function reportDeploy(payload: Record<string, unknown>, config?: Partial<VexorOtaConfig>): Promise<void>;
100
+ export function buildManifestUrl(config: VexorOtaConfig, currentVersion?: number): string;
101
+ export function getDownloadUrl(manifest: VexorOtaManifest, platform?: PlatformOSType): string;