react-native-update 10.49.0 → 10.51.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 (61) hide show
  1. package/BUNDLEHASH_MIGRATION.md +22 -2
  2. package/NATIVE_CHECKUPDATE_DESIGN.md +251 -21
  3. package/NATIVE_CHECK_FOLLOWUPS.md +365 -0
  4. package/README-CN.md +14 -1
  5. package/README.md +14 -1
  6. package/android/jni/Android.mk +5 -1
  7. package/android/lib/arm64-v8a/librnupdate.so +0 -0
  8. package/android/lib/armeabi-v7a/librnupdate.so +0 -0
  9. package/android/lib/x86/librnupdate.so +0 -0
  10. package/android/lib/x86_64/librnupdate.so +0 -0
  11. package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +42 -9
  12. package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +98 -22
  13. package/android/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.java +3 -0
  14. package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +455 -0
  15. package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +23 -0
  16. package/android/src/main/java/cn/reactnative/modules/update/PatchFailedException.java +16 -0
  17. package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +196 -42
  18. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +56 -3
  19. package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +10 -0
  20. package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +10 -0
  21. package/cpp/patch_core/digest.cpp +53 -0
  22. package/cpp/patch_core/digest.h +18 -0
  23. package/cpp/patch_core/patch_core.cpp +17 -1
  24. package/cpp/patch_core/patch_core.h +8 -0
  25. package/cpp/patch_core/tests/patch_core_test.cpp +99 -0
  26. package/cpp/update_flow_core/flow_json.cpp +522 -0
  27. package/cpp/update_flow_core/flow_json.h +103 -0
  28. package/cpp/update_flow_core/tests/flow_vectors.json +1401 -0
  29. package/cpp/update_flow_core/tests/update_flow_core_test.cpp +317 -0
  30. package/cpp/update_flow_core/update_flow_core.cpp +301 -0
  31. package/cpp/update_flow_core/update_flow_core.h +77 -0
  32. package/cpp/update_flow_core/update_flow_jni.cpp +121 -0
  33. package/harmony/pushy/src/main/cpp/CMakeLists.txt +7 -0
  34. package/harmony/pushy/src/main/cpp/pushy.cpp +150 -1
  35. package/harmony/pushy/src/main/ets/DownloadTask.ts +133 -9
  36. package/harmony/pushy/src/main/ets/DownloadTaskParams.ts +3 -0
  37. package/harmony/pushy/src/main/ets/MonotonicClock.ts +13 -0
  38. package/harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts +500 -0
  39. package/harmony/pushy/src/main/ets/NativePatchCore.ts +16 -0
  40. package/harmony/pushy/src/main/ets/PathUtils.ts +21 -0
  41. package/harmony/pushy/src/main/ets/PushyTurboModule.ts +22 -0
  42. package/harmony/pushy/src/main/ets/UpdateContext.ts +152 -52
  43. package/harmony/pushy.har +0 -0
  44. package/ios/RCTPushy/RCTPushy.mm +840 -68
  45. package/ios/RCTPushy/RCTPushyDownloader.h +1 -0
  46. package/ios/RCTPushy/RCTPushyDownloader.mm +4 -3
  47. package/package.json +3 -1
  48. package/react-native-update.podspec +2 -0
  49. package/src/NativePushy.ts +14 -0
  50. package/src/client.ts +439 -122
  51. package/src/endpoint.ts +105 -80
  52. package/src/error.ts +4 -0
  53. package/src/locales/en.ts +4 -0
  54. package/src/locales/zh.ts +4 -0
  55. package/src/provider.tsx +74 -9
  56. package/src/telemetry.ts +8 -0
  57. package/src/type.ts +31 -0
  58. package/src/updateFlowCore.ts +320 -0
  59. package/src/utils.ts +14 -12
  60. package/src/isInRollout.ts +0 -86
  61. package/src/resolveCheckResult.ts +0 -30
@@ -0,0 +1,103 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <string>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ // Minimal JSON document model for the update-flow decision layer.
9
+ //
10
+ // Deliberately mirrors JavaScript object semantics where the ported decision
11
+ // logic depends on them, because the golden vectors are generated by the TS
12
+ // reference implementation and compared as serialized strings:
13
+ // - object members keep insertion order, and overwriting an existing key
14
+ // keeps its original position (JS spread/assignment semantics);
15
+ // - Kind::Undefined is distinct from Kind::Null: undefined-valued members
16
+ // are skipped by Stringify (like JSON.stringify), null is emitted;
17
+ // - Truthy() implements JS truthiness (undefined/null/false/0/NaN/'' are
18
+ // falsy; empty arrays and objects are truthy);
19
+ // - StrictEquals() implements === for primitives only (never for
20
+ // arrays/objects — reference equality cannot hold across a parse).
21
+ namespace flowjson {
22
+
23
+ class Value;
24
+ using Members = std::vector<std::pair<std::string, Value>>;
25
+ using Elements = std::vector<Value>;
26
+
27
+ class Value {
28
+ public:
29
+ enum class Kind { Undefined, Null, Bool, Number, String, Array, Object };
30
+
31
+ Value() = default;
32
+ static Value Undefined() { return Value(); }
33
+ static Value Null() { return Value(Kind::Null); }
34
+ static Value Bool(bool b) {
35
+ Value v(Kind::Bool);
36
+ v.bool_ = b;
37
+ return v;
38
+ }
39
+ static Value Number(double n) {
40
+ Value v(Kind::Number);
41
+ v.number_ = n;
42
+ return v;
43
+ }
44
+ static Value String(std::string s) {
45
+ Value v(Kind::String);
46
+ v.string_ = std::move(s);
47
+ return v;
48
+ }
49
+ static Value Array() { return Value(Kind::Array); }
50
+ static Value Object() { return Value(Kind::Object); }
51
+
52
+ Kind kind() const { return kind_; }
53
+ bool IsUndefined() const { return kind_ == Kind::Undefined; }
54
+ bool IsArray() const { return kind_ == Kind::Array; }
55
+ bool IsObject() const { return kind_ == Kind::Object; }
56
+ bool IsNumber() const { return kind_ == Kind::Number; }
57
+ bool IsString() const { return kind_ == Kind::String; }
58
+
59
+ bool AsBool() const { return bool_; }
60
+ double AsNumber() const { return number_; }
61
+ const std::string& AsString() const { return string_; }
62
+
63
+ bool Truthy() const;
64
+
65
+ // Array access.
66
+ const Elements& elements() const { return elements_; }
67
+ void Push(Value v) { elements_.push_back(std::move(v)); }
68
+ size_t Size() const { return elements_.size(); }
69
+ const Value& At(size_t i) const;
70
+
71
+ // Object access. Get returns Undefined for a missing key; Set overwrites
72
+ // in place (keeping the key's position) or appends.
73
+ const Members& members() const { return members_; }
74
+ const Value& Get(const std::string& key) const;
75
+ void Set(const std::string& key, Value v);
76
+ void Remove(const std::string& key);
77
+
78
+ static bool StrictEquals(const Value& a, const Value& b);
79
+
80
+ private:
81
+ explicit Value(Kind kind) : kind_(kind) {}
82
+
83
+ Kind kind_ = Kind::Undefined;
84
+ bool bool_ = false;
85
+ double number_ = 0;
86
+ std::string string_;
87
+ Elements elements_;
88
+ Members members_;
89
+ };
90
+
91
+ // JSON.stringify-compatible for the value shapes the decision layer produces
92
+ // (undefined members skipped, undefined array elements become null, integral
93
+ // numbers within the double-safe range print without a decimal point). A
94
+ // top-level Undefined prints as "undefined" so two undefined results compare
95
+ // equal.
96
+ std::string Stringify(const Value& v);
97
+
98
+ // Strict JSON parser (the vectors file and checkUpdate responses). Returns
99
+ // Undefined and sets *ok to false on malformed input; nesting beyond 64
100
+ // levels is rejected so hostile server data cannot exhaust the stack.
101
+ Value Parse(const std::string& text, bool* ok);
102
+
103
+ } // namespace flowjson