@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.
- package/LICENSE +20 -0
- package/README.md +61 -0
- package/android/build.gradle +129 -0
- package/android/generated/java/com/vexorpush/codepush/NativeVexorCodePushSpec.java +91 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNVexorCodePushSpec-generated.cpp +110 -0
- package/android/generated/jni/RNVexorCodePushSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/EventEmitters.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/EventEmitters.h +17 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/Props.cpp +19 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/Props.h +18 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/RNVexorCodePushSpecJSI-generated.cpp +129 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/RNVexorCodePushSpecJSI.h +184 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/States.h +19 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/vexorpush/codepush/CrashHandler.kt +78 -0
- package/android/src/main/java/com/vexorpush/codepush/SharedPrefs.kt +60 -0
- package/android/src/main/java/com/vexorpush/codepush/Utils.kt +105 -0
- package/android/src/main/java/com/vexorpush/codepush/VexorCodePush.kt +100 -0
- package/android/src/main/java/com/vexorpush/codepush/VexorCodePushModule.kt +698 -0
- package/android/src/newarch/VexorCodePushSpec.kt +7 -0
- package/android/src/oldarch/VexorCodePushSpec.kt +24 -0
- package/app.plugin.js +1 -0
- package/current-version.js +27 -0
- package/deployment-state.js +33 -0
- package/index.d.ts +101 -0
- package/index.js +535 -0
- package/ios/VexorCodePush.h +13 -0
- package/ios/VexorCodePush.mm +949 -0
- package/ios/generated/RNVexorCodePushSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNVexorCodePushSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNVexorCodePushSpec/EventEmitters.cpp +16 -0
- package/ios/generated/RNVexorCodePushSpec/EventEmitters.h +17 -0
- package/ios/generated/RNVexorCodePushSpec/Props.cpp +19 -0
- package/ios/generated/RNVexorCodePushSpec/Props.h +18 -0
- package/ios/generated/RNVexorCodePushSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/RNVexorCodePushSpec/RNVexorCodePushSpec-generated.mm +130 -0
- package/ios/generated/RNVexorCodePushSpec/RNVexorCodePushSpec.h +109 -0
- package/ios/generated/RNVexorCodePushSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNVexorCodePushSpec/ShadowNodes.h +23 -0
- package/ios/generated/RNVexorCodePushSpec/States.cpp +16 -0
- package/ios/generated/RNVexorCodePushSpec/States.h +19 -0
- package/ios/generated/RNVexorCodePushSpecJSI-generated.cpp +129 -0
- package/ios/generated/RNVexorCodePushSpecJSI.h +184 -0
- package/package.json +51 -0
- package/plugin/src/index.ts +92 -0
- package/plugin/tsconfig.json +9 -0
- package/react-native-code-push.podspec +48 -0
- package/react-native.config.js +13 -0
- package/src/NativeVexorCodePush.ts +21 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNVexorCodePushSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_setupBundlePath(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->setupBundlePath(
|
|
16
|
+
rt,
|
|
17
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
18
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
19
|
+
count <= 2 || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asNumber()),
|
|
20
|
+
count <= 3 || args[3].isUndefined() ? std::nullopt : std::make_optional(args[3].asNumber()),
|
|
21
|
+
count <= 4 || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asString(rt))
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_downloadAndInstallBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
25
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->downloadAndInstallBundle(
|
|
26
|
+
rt,
|
|
27
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
28
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
29
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt),
|
|
30
|
+
count <= 3 || args[3].isUndefined() ? std::nullopt : std::make_optional(args[3].asNumber()),
|
|
31
|
+
count <= 4 || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asNumber()),
|
|
32
|
+
count <= 5 || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asString(rt))
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_setExactBundlePath(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
36
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->setExactBundlePath(
|
|
37
|
+
rt,
|
|
38
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_deleteBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
42
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->deleteBundle(
|
|
43
|
+
rt,
|
|
44
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_restart(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
48
|
+
static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->restart(
|
|
49
|
+
rt
|
|
50
|
+
);
|
|
51
|
+
return jsi::Value::undefined();
|
|
52
|
+
}
|
|
53
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_getCurrentVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
54
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->getCurrentVersion(
|
|
55
|
+
rt,
|
|
56
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_getUpdateMetadata(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
60
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->getUpdateMetadata(
|
|
61
|
+
rt,
|
|
62
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_setCurrentVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
66
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->setCurrentVersion(
|
|
67
|
+
rt,
|
|
68
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_setUpdateMetadata(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
72
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->setUpdateMetadata(
|
|
73
|
+
rt,
|
|
74
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_rollbackToPreviousBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
78
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->rollbackToPreviousBundle(
|
|
79
|
+
rt,
|
|
80
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_getBundleList(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
84
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->getBundleList(
|
|
85
|
+
rt,
|
|
86
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_deleteBundleById(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
90
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->deleteBundleById(
|
|
91
|
+
rt,
|
|
92
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_clearAllBundles(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
96
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->clearAllBundles(
|
|
97
|
+
rt,
|
|
98
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
static jsi::Value __hostFunction_NativeVexorCodePushCxxSpecJSI_writeFile(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
102
|
+
return static_cast<NativeVexorCodePushCxxSpecJSI *>(&turboModule)->writeFile(
|
|
103
|
+
rt,
|
|
104
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
105
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
106
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
NativeVexorCodePushCxxSpecJSI::NativeVexorCodePushCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
111
|
+
: TurboModule("VexorCodePush", jsInvoker) {
|
|
112
|
+
methodMap_["setupBundlePath"] = MethodMetadata {5, __hostFunction_NativeVexorCodePushCxxSpecJSI_setupBundlePath};
|
|
113
|
+
methodMap_["downloadAndInstallBundle"] = MethodMetadata {6, __hostFunction_NativeVexorCodePushCxxSpecJSI_downloadAndInstallBundle};
|
|
114
|
+
methodMap_["setExactBundlePath"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_setExactBundlePath};
|
|
115
|
+
methodMap_["deleteBundle"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_deleteBundle};
|
|
116
|
+
methodMap_["restart"] = MethodMetadata {0, __hostFunction_NativeVexorCodePushCxxSpecJSI_restart};
|
|
117
|
+
methodMap_["getCurrentVersion"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_getCurrentVersion};
|
|
118
|
+
methodMap_["getUpdateMetadata"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_getUpdateMetadata};
|
|
119
|
+
methodMap_["setCurrentVersion"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_setCurrentVersion};
|
|
120
|
+
methodMap_["setUpdateMetadata"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_setUpdateMetadata};
|
|
121
|
+
methodMap_["rollbackToPreviousBundle"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_rollbackToPreviousBundle};
|
|
122
|
+
methodMap_["getBundleList"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_getBundleList};
|
|
123
|
+
methodMap_["deleteBundleById"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_deleteBundleById};
|
|
124
|
+
methodMap_["clearAllBundles"] = MethodMetadata {1, __hostFunction_NativeVexorCodePushCxxSpecJSI_clearAllBundles};
|
|
125
|
+
methodMap_["writeFile"] = MethodMetadata {3, __hostFunction_NativeVexorCodePushCxxSpecJSI_writeFile};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
} // namespace facebook::react
|
package/android/generated/jni/react/renderer/components/RNVexorCodePushSpec/RNVexorCodePushSpecJSI.h
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeVexorCodePushCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeVexorCodePushCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual jsi::Value setupBundlePath(jsi::Runtime &rt, jsi::String path, jsi::String extension, std::optional<double> version, std::optional<double> maxVersions, std::optional<jsi::String> metadata) = 0;
|
|
24
|
+
virtual jsi::Value downloadAndInstallBundle(jsi::Runtime &rt, jsi::String url, jsi::String headersJson, jsi::String extension, std::optional<double> version, std::optional<double> maxVersions, std::optional<jsi::String> metadata) = 0;
|
|
25
|
+
virtual jsi::Value setExactBundlePath(jsi::Runtime &rt, jsi::String path) = 0;
|
|
26
|
+
virtual jsi::Value deleteBundle(jsi::Runtime &rt, double i) = 0;
|
|
27
|
+
virtual void restart(jsi::Runtime &rt) = 0;
|
|
28
|
+
virtual jsi::Value getCurrentVersion(jsi::Runtime &rt, double a) = 0;
|
|
29
|
+
virtual jsi::Value getUpdateMetadata(jsi::Runtime &rt, double a) = 0;
|
|
30
|
+
virtual jsi::Value setCurrentVersion(jsi::Runtime &rt, jsi::String version) = 0;
|
|
31
|
+
virtual jsi::Value setUpdateMetadata(jsi::Runtime &rt, jsi::String metadata) = 0;
|
|
32
|
+
virtual jsi::Value rollbackToPreviousBundle(jsi::Runtime &rt, double a) = 0;
|
|
33
|
+
virtual jsi::Value getBundleList(jsi::Runtime &rt, double a) = 0;
|
|
34
|
+
virtual jsi::Value deleteBundleById(jsi::Runtime &rt, jsi::String id) = 0;
|
|
35
|
+
virtual jsi::Value clearAllBundles(jsi::Runtime &rt, double a) = 0;
|
|
36
|
+
virtual jsi::Value writeFile(jsi::Runtime &rt, jsi::String path, jsi::String base64Content, jsi::String encoding) = 0;
|
|
37
|
+
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
template <typename T>
|
|
41
|
+
class JSI_EXPORT NativeVexorCodePushCxxSpec : public TurboModule {
|
|
42
|
+
public:
|
|
43
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
44
|
+
return delegate_.get(rt, propName);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static constexpr std::string_view kModuleName = "VexorCodePush";
|
|
48
|
+
|
|
49
|
+
protected:
|
|
50
|
+
NativeVexorCodePushCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
51
|
+
: TurboModule(std::string{NativeVexorCodePushCxxSpec::kModuleName}, jsInvoker),
|
|
52
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
class Delegate : public NativeVexorCodePushCxxSpecJSI {
|
|
57
|
+
public:
|
|
58
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
59
|
+
NativeVexorCodePushCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
jsi::Value setupBundlePath(jsi::Runtime &rt, jsi::String path, jsi::String extension, std::optional<double> version, std::optional<double> maxVersions, std::optional<jsi::String> metadata) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::setupBundlePath) == 6,
|
|
66
|
+
"Expected setupBundlePath(...) to have 6 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<jsi::Value>(
|
|
69
|
+
rt, &T::setupBundlePath, jsInvoker_, instance_, std::move(path), std::move(extension), std::move(version), std::move(maxVersions), std::move(metadata));
|
|
70
|
+
}
|
|
71
|
+
jsi::Value downloadAndInstallBundle(jsi::Runtime &rt, jsi::String url, jsi::String headersJson, jsi::String extension, std::optional<double> version, std::optional<double> maxVersions, std::optional<jsi::String> metadata) override {
|
|
72
|
+
static_assert(
|
|
73
|
+
bridging::getParameterCount(&T::downloadAndInstallBundle) == 7,
|
|
74
|
+
"Expected downloadAndInstallBundle(...) to have 7 parameters");
|
|
75
|
+
|
|
76
|
+
return bridging::callFromJs<jsi::Value>(
|
|
77
|
+
rt, &T::downloadAndInstallBundle, jsInvoker_, instance_, std::move(url), std::move(headersJson), std::move(extension), std::move(version), std::move(maxVersions), std::move(metadata));
|
|
78
|
+
}
|
|
79
|
+
jsi::Value setExactBundlePath(jsi::Runtime &rt, jsi::String path) override {
|
|
80
|
+
static_assert(
|
|
81
|
+
bridging::getParameterCount(&T::setExactBundlePath) == 2,
|
|
82
|
+
"Expected setExactBundlePath(...) to have 2 parameters");
|
|
83
|
+
|
|
84
|
+
return bridging::callFromJs<jsi::Value>(
|
|
85
|
+
rt, &T::setExactBundlePath, jsInvoker_, instance_, std::move(path));
|
|
86
|
+
}
|
|
87
|
+
jsi::Value deleteBundle(jsi::Runtime &rt, double i) override {
|
|
88
|
+
static_assert(
|
|
89
|
+
bridging::getParameterCount(&T::deleteBundle) == 2,
|
|
90
|
+
"Expected deleteBundle(...) to have 2 parameters");
|
|
91
|
+
|
|
92
|
+
return bridging::callFromJs<jsi::Value>(
|
|
93
|
+
rt, &T::deleteBundle, jsInvoker_, instance_, std::move(i));
|
|
94
|
+
}
|
|
95
|
+
void restart(jsi::Runtime &rt) override {
|
|
96
|
+
static_assert(
|
|
97
|
+
bridging::getParameterCount(&T::restart) == 1,
|
|
98
|
+
"Expected restart(...) to have 1 parameters");
|
|
99
|
+
|
|
100
|
+
return bridging::callFromJs<void>(
|
|
101
|
+
rt, &T::restart, jsInvoker_, instance_);
|
|
102
|
+
}
|
|
103
|
+
jsi::Value getCurrentVersion(jsi::Runtime &rt, double a) override {
|
|
104
|
+
static_assert(
|
|
105
|
+
bridging::getParameterCount(&T::getCurrentVersion) == 2,
|
|
106
|
+
"Expected getCurrentVersion(...) to have 2 parameters");
|
|
107
|
+
|
|
108
|
+
return bridging::callFromJs<jsi::Value>(
|
|
109
|
+
rt, &T::getCurrentVersion, jsInvoker_, instance_, std::move(a));
|
|
110
|
+
}
|
|
111
|
+
jsi::Value getUpdateMetadata(jsi::Runtime &rt, double a) override {
|
|
112
|
+
static_assert(
|
|
113
|
+
bridging::getParameterCount(&T::getUpdateMetadata) == 2,
|
|
114
|
+
"Expected getUpdateMetadata(...) to have 2 parameters");
|
|
115
|
+
|
|
116
|
+
return bridging::callFromJs<jsi::Value>(
|
|
117
|
+
rt, &T::getUpdateMetadata, jsInvoker_, instance_, std::move(a));
|
|
118
|
+
}
|
|
119
|
+
jsi::Value setCurrentVersion(jsi::Runtime &rt, jsi::String version) override {
|
|
120
|
+
static_assert(
|
|
121
|
+
bridging::getParameterCount(&T::setCurrentVersion) == 2,
|
|
122
|
+
"Expected setCurrentVersion(...) to have 2 parameters");
|
|
123
|
+
|
|
124
|
+
return bridging::callFromJs<jsi::Value>(
|
|
125
|
+
rt, &T::setCurrentVersion, jsInvoker_, instance_, std::move(version));
|
|
126
|
+
}
|
|
127
|
+
jsi::Value setUpdateMetadata(jsi::Runtime &rt, jsi::String metadata) override {
|
|
128
|
+
static_assert(
|
|
129
|
+
bridging::getParameterCount(&T::setUpdateMetadata) == 2,
|
|
130
|
+
"Expected setUpdateMetadata(...) to have 2 parameters");
|
|
131
|
+
|
|
132
|
+
return bridging::callFromJs<jsi::Value>(
|
|
133
|
+
rt, &T::setUpdateMetadata, jsInvoker_, instance_, std::move(metadata));
|
|
134
|
+
}
|
|
135
|
+
jsi::Value rollbackToPreviousBundle(jsi::Runtime &rt, double a) override {
|
|
136
|
+
static_assert(
|
|
137
|
+
bridging::getParameterCount(&T::rollbackToPreviousBundle) == 2,
|
|
138
|
+
"Expected rollbackToPreviousBundle(...) to have 2 parameters");
|
|
139
|
+
|
|
140
|
+
return bridging::callFromJs<jsi::Value>(
|
|
141
|
+
rt, &T::rollbackToPreviousBundle, jsInvoker_, instance_, std::move(a));
|
|
142
|
+
}
|
|
143
|
+
jsi::Value getBundleList(jsi::Runtime &rt, double a) override {
|
|
144
|
+
static_assert(
|
|
145
|
+
bridging::getParameterCount(&T::getBundleList) == 2,
|
|
146
|
+
"Expected getBundleList(...) to have 2 parameters");
|
|
147
|
+
|
|
148
|
+
return bridging::callFromJs<jsi::Value>(
|
|
149
|
+
rt, &T::getBundleList, jsInvoker_, instance_, std::move(a));
|
|
150
|
+
}
|
|
151
|
+
jsi::Value deleteBundleById(jsi::Runtime &rt, jsi::String id) override {
|
|
152
|
+
static_assert(
|
|
153
|
+
bridging::getParameterCount(&T::deleteBundleById) == 2,
|
|
154
|
+
"Expected deleteBundleById(...) to have 2 parameters");
|
|
155
|
+
|
|
156
|
+
return bridging::callFromJs<jsi::Value>(
|
|
157
|
+
rt, &T::deleteBundleById, jsInvoker_, instance_, std::move(id));
|
|
158
|
+
}
|
|
159
|
+
jsi::Value clearAllBundles(jsi::Runtime &rt, double a) override {
|
|
160
|
+
static_assert(
|
|
161
|
+
bridging::getParameterCount(&T::clearAllBundles) == 2,
|
|
162
|
+
"Expected clearAllBundles(...) to have 2 parameters");
|
|
163
|
+
|
|
164
|
+
return bridging::callFromJs<jsi::Value>(
|
|
165
|
+
rt, &T::clearAllBundles, jsInvoker_, instance_, std::move(a));
|
|
166
|
+
}
|
|
167
|
+
jsi::Value writeFile(jsi::Runtime &rt, jsi::String path, jsi::String base64Content, jsi::String encoding) override {
|
|
168
|
+
static_assert(
|
|
169
|
+
bridging::getParameterCount(&T::writeFile) == 4,
|
|
170
|
+
"Expected writeFile(...) to have 4 parameters");
|
|
171
|
+
|
|
172
|
+
return bridging::callFromJs<jsi::Value>(
|
|
173
|
+
rt, &T::writeFile, jsInvoker_, instance_, std::move(path), std::move(base64Content), std::move(encoding));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private:
|
|
177
|
+
friend class NativeVexorCodePushCxxSpec;
|
|
178
|
+
T *instance_;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
Delegate delegate_;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include "States.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
package com.vexorpush.codepush
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.widget.Toast
|
|
5
|
+
import com.jakewharton.processphoenix.ProcessPhoenix
|
|
6
|
+
import com.vexorpush.codepush.Common.PATH
|
|
7
|
+
import com.vexorpush.codepush.Common.VERSION
|
|
8
|
+
import com.vexorpush.codepush.Common.BUNDLE_HISTORY
|
|
9
|
+
import com.vexorpush.codepush.SharedPrefs
|
|
10
|
+
import kotlinx.coroutines.Dispatchers
|
|
11
|
+
import kotlinx.coroutines.GlobalScope
|
|
12
|
+
import kotlinx.coroutines.delay
|
|
13
|
+
import kotlinx.coroutines.launch
|
|
14
|
+
import org.json.JSONArray
|
|
15
|
+
import java.io.File
|
|
16
|
+
|
|
17
|
+
class CrashHandler(private val context: Context) : Thread.UncaughtExceptionHandler {
|
|
18
|
+
private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
|
|
19
|
+
private val utils: Utils = Utils(context)
|
|
20
|
+
private var beginning = true
|
|
21
|
+
init {
|
|
22
|
+
GlobalScope.launch(Dispatchers.IO) {
|
|
23
|
+
delay(2000)
|
|
24
|
+
beginning = false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
override fun uncaughtException(thread: Thread, throwable: Throwable) {
|
|
28
|
+
if (beginning) {
|
|
29
|
+
val sharedPrefs = SharedPrefs(context)
|
|
30
|
+
val currentPath = sharedPrefs.getString(PATH)
|
|
31
|
+
|
|
32
|
+
// Try to rollback using history system
|
|
33
|
+
val historyJson = sharedPrefs.getString(BUNDLE_HISTORY)
|
|
34
|
+
var rolledBack = false
|
|
35
|
+
|
|
36
|
+
if (!historyJson.isNullOrEmpty() && !currentPath.isNullOrEmpty()) {
|
|
37
|
+
try {
|
|
38
|
+
val jsonArray = JSONArray(historyJson)
|
|
39
|
+
val history = (0 until jsonArray.length()).map { i ->
|
|
40
|
+
val obj = jsonArray.getJSONObject(i)
|
|
41
|
+
Pair(obj.getInt("version"), obj.getString("path"))
|
|
42
|
+
}.sortedByDescending { it.first }
|
|
43
|
+
|
|
44
|
+
val currentBundle = history.find { it.second == currentPath }
|
|
45
|
+
if (currentBundle != null) {
|
|
46
|
+
val previousBundle = history
|
|
47
|
+
.filter { it.first < currentBundle.first }
|
|
48
|
+
.maxByOrNull { it.first }
|
|
49
|
+
|
|
50
|
+
if (previousBundle != null && File(previousBundle.second).exists()) {
|
|
51
|
+
val isDeleted = utils.deleteOldBundleIfneeded(PATH)
|
|
52
|
+
if (isDeleted) {
|
|
53
|
+
sharedPrefs.putString(PATH, previousBundle.second)
|
|
54
|
+
sharedPrefs.putString(VERSION, previousBundle.first.toString())
|
|
55
|
+
rolledBack = true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (e: Exception) {
|
|
60
|
+
// ignore, fall through to clear path
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!rolledBack) {
|
|
65
|
+
sharedPrefs.putString(PATH, "")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val errorMessage = throwable.message ?: "Unknown error occurred"
|
|
69
|
+
Toast.makeText(context, "Update failed: $errorMessage", Toast.LENGTH_LONG).show()
|
|
70
|
+
GlobalScope.launch(Dispatchers.IO) {
|
|
71
|
+
delay(1500)
|
|
72
|
+
ProcessPhoenix.triggerRebirth(context)
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
defaultHandler?.uncaughtException(thread, throwable)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package com.vexorpush.codepush
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.SharedPreferences
|
|
6
|
+
import android.util.Log
|
|
7
|
+
|
|
8
|
+
private const val DEBUG_TAG = "VEXOR-CODEPUSH-DEBUG"
|
|
9
|
+
|
|
10
|
+
private fun shortValue(value: String?): String {
|
|
11
|
+
if (value.isNullOrBlank()) return value ?: ""
|
|
12
|
+
return if (value.length > 120) "...${value.takeLast(120)}" else value
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class SharedPrefs internal constructor(context: Context) {
|
|
16
|
+
private val mSharedPreferences: SharedPreferences =
|
|
17
|
+
context.getSharedPreferences(Common.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE)
|
|
18
|
+
|
|
19
|
+
fun getString(key: String?): String? {
|
|
20
|
+
return mSharedPreferences.getString(key, "")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@SuppressLint("CommitPrefEdits")
|
|
24
|
+
fun putString(key: String?, value: String?) {
|
|
25
|
+
val editor = mSharedPreferences.edit()
|
|
26
|
+
editor.putString(key, value)
|
|
27
|
+
val committed = editor.commit()
|
|
28
|
+
if (key == Common.PATH || key == Common.VERSION || key == Common.CURRENT_VERSION_CODE) {
|
|
29
|
+
Log.d(DEBUG_TAG, "SharedPrefs.putString key=$key value=${shortValue(value)} committed=$committed")
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun getInt(key: String?, defaultValue: Int): Int {
|
|
34
|
+
return mSharedPreferences.getInt(key, defaultValue)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun putInt(key: String?, value: Int) {
|
|
38
|
+
val editor = mSharedPreferences.edit()
|
|
39
|
+
editor.putInt(key, value)
|
|
40
|
+
val committed = editor.commit()
|
|
41
|
+
Log.d(DEBUG_TAG, "SharedPrefs.putInt key=$key value=$value committed=$committed")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fun clear() {
|
|
45
|
+
val committed = mSharedPreferences.edit().clear().commit()
|
|
46
|
+
Log.d(DEBUG_TAG, "SharedPrefs.clear committed=$committed")
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
object Common {
|
|
50
|
+
val PATH = "PATH"
|
|
51
|
+
val PREVIOUS_PATH = "PREVIOUS_PATH"
|
|
52
|
+
val VERSION = "VERSION"
|
|
53
|
+
val PREVIOUS_VERSION = "PREVIOUS_VERSION"
|
|
54
|
+
val CURRENT_VERSION_CODE = "CURRENT_VERSION_CODE"
|
|
55
|
+
val SHARED_PREFERENCE_NAME = "VEXOR-CODE-PUSH-REACT_NATIVE"
|
|
56
|
+
val DEFAULT_BUNDLE = "assets://index.android.bundle"
|
|
57
|
+
val METADATA = "METADATA"
|
|
58
|
+
val BUNDLE_HISTORY = "BUNDLE_HISTORY"
|
|
59
|
+
const val DEFAULT_MAX_BUNDLE_VERSIONS = 2
|
|
60
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
package com.vexorpush.codepush
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.icu.text.SimpleDateFormat
|
|
5
|
+
import com.vexorpush.codepush.Common.PREVIOUS_PATH
|
|
6
|
+
import com.vexorpush.codepush.SharedPrefs
|
|
7
|
+
import java.io.File
|
|
8
|
+
import java.util.Date
|
|
9
|
+
import java.util.Locale
|
|
10
|
+
import java.util.zip.ZipFile
|
|
11
|
+
|
|
12
|
+
class Utils internal constructor(private val context: Context) {
|
|
13
|
+
|
|
14
|
+
fun deleteDirectory(directory: File): Boolean {
|
|
15
|
+
if (directory.isDirectory) {
|
|
16
|
+
// List all files and directories in the current directory
|
|
17
|
+
val files = directory.listFiles()
|
|
18
|
+
if (files != null) {
|
|
19
|
+
// Recursively delete all files and directories
|
|
20
|
+
for (file in files) {
|
|
21
|
+
if (!deleteDirectory(file)) {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Finally, delete the empty directory or file
|
|
28
|
+
return directory.delete()
|
|
29
|
+
}
|
|
30
|
+
fun deleteOldBundleIfneeded(pathKey: String?): Boolean {
|
|
31
|
+
val pathName = pathKey ?: PREVIOUS_PATH
|
|
32
|
+
val sharedPrefs = SharedPrefs(context)
|
|
33
|
+
val bundlePath = sharedPrefs.getString(pathName)
|
|
34
|
+
|
|
35
|
+
if (!bundlePath.isNullOrEmpty()) {
|
|
36
|
+
val bundleFile = File(bundlePath)
|
|
37
|
+
if (bundleFile.exists() && bundleFile.isFile) {
|
|
38
|
+
val outputFolder = bundleFile.parentFile
|
|
39
|
+
if (outputFolder != null && outputFolder.exists() && outputFolder.isDirectory) {
|
|
40
|
+
val isDeleted = deleteDirectory(outputFolder)
|
|
41
|
+
sharedPrefs.putString(pathName, "")
|
|
42
|
+
return isDeleted
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fun extractZipFile(
|
|
50
|
+
zipFile: File,extension: String, version: Int? = null
|
|
51
|
+
): String? {
|
|
52
|
+
return try {
|
|
53
|
+
val outputDir = zipFile.parentFile
|
|
54
|
+
val timestamp = SimpleDateFormat("yyyy_MM_dd_HH_mm", Locale.getDefault()).format(Date())
|
|
55
|
+
var topLevelFolder: String? = null
|
|
56
|
+
var bundlePath: String? = null
|
|
57
|
+
ZipFile(zipFile).use { zip ->
|
|
58
|
+
zip.entries().asSequence().forEach { entry ->
|
|
59
|
+
zip.getInputStream(entry).use { input ->
|
|
60
|
+
if (topLevelFolder == null) {
|
|
61
|
+
// Get root folder of zip file after unzip
|
|
62
|
+
val parts = entry.name.split("/")
|
|
63
|
+
if (parts.size > 1) {
|
|
64
|
+
topLevelFolder = parts.first()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
val outputFile = File(outputDir, entry.name)
|
|
68
|
+
if (entry.isDirectory) {
|
|
69
|
+
if (!outputFile.exists()) outputFile.mkdirs()
|
|
70
|
+
} else {
|
|
71
|
+
if (outputFile.parentFile?.exists() != true) outputFile.parentFile?.mkdirs()
|
|
72
|
+
outputFile.outputStream().use { output ->
|
|
73
|
+
input.copyTo(output)
|
|
74
|
+
}
|
|
75
|
+
if (outputFile.absolutePath.endsWith(extension)) {
|
|
76
|
+
bundlePath = outputFile.absolutePath
|
|
77
|
+
return@use // Exit early if found
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Rename the detected top-level folder
|
|
84
|
+
if (topLevelFolder != null) {
|
|
85
|
+
val extractedFolder = File(outputDir, topLevelFolder)
|
|
86
|
+
// Include version in folder name if provided, otherwise use timestamp only
|
|
87
|
+
val folderName = if (version != null) {
|
|
88
|
+
"output_v${version}_$timestamp"
|
|
89
|
+
} else {
|
|
90
|
+
"output_$timestamp"
|
|
91
|
+
}
|
|
92
|
+
val renamedFolder = File(outputDir, folderName)
|
|
93
|
+
if (extractedFolder.exists()) {
|
|
94
|
+
extractedFolder.renameTo(renamedFolder)
|
|
95
|
+
// Update bundlePath if the file was inside the renamed folder
|
|
96
|
+
bundlePath = bundlePath?.replace(extractedFolder.absolutePath, renamedFolder.absolutePath)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
bundlePath
|
|
100
|
+
} catch (e: Exception) {
|
|
101
|
+
e.printStackTrace()
|
|
102
|
+
null
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|