@dittolive/ditto 4.7.4 → 4.7.5-rc.2

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 (160) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +1 -1
  3. package/node/ditto.darwin-arm64.node +0 -0
  4. package/node/ditto.darwin-x64.node +0 -0
  5. package/node/ditto.linux-arm.node +0 -0
  6. package/node/ditto.linux-arm64.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/node/transports.darwin-arm64.node +0 -0
  10. package/node/transports.darwin-x64.node +0 -0
  11. package/package.json +2 -5
  12. package/web/ditto.es6.js +1 -1
  13. package/web/ditto.umd.js +1 -1
  14. package/web/ditto.wasm +0 -0
  15. package/DittoReactNative.podspec +0 -27
  16. package/react-native/android/.gradle/8.9/checksums/checksums.lock +0 -0
  17. package/react-native/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  18. package/react-native/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  19. package/react-native/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  20. package/react-native/android/.gradle/8.9/gc.properties +0 -0
  21. package/react-native/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  22. package/react-native/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  23. package/react-native/android/.gradle/vcs-1/gc.properties +0 -0
  24. package/react-native/android/CMakeLists.txt +0 -36
  25. package/react-native/android/build.gradle +0 -190
  26. package/react-native/android/cpp-adapter.cpp +0 -259
  27. package/react-native/android/gradle.properties +0 -5
  28. package/react-native/android/src/main/AndroidManifest.xml +0 -4
  29. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +0 -120
  30. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +0 -28
  31. package/react-native/cpp/include/Arc.hpp +0 -159
  32. package/react-native/cpp/include/Attachment.h +0 -20
  33. package/react-native/cpp/include/Authentication.h +0 -23
  34. package/react-native/cpp/include/Collection.h +0 -13
  35. package/react-native/cpp/include/ConnectionRequest.h +0 -18
  36. package/react-native/cpp/include/DQL.h +0 -21
  37. package/react-native/cpp/include/Document.h +0 -17
  38. package/react-native/cpp/include/FFIUtils.h +0 -16
  39. package/react-native/cpp/include/IO.h +0 -13
  40. package/react-native/cpp/include/Identity.h +0 -17
  41. package/react-native/cpp/include/Lifecycle.h +0 -16
  42. package/react-native/cpp/include/LiveQuery.h +0 -17
  43. package/react-native/cpp/include/Logger.h +0 -22
  44. package/react-native/cpp/include/Misc.h +0 -30
  45. package/react-native/cpp/include/Presence.h +0 -18
  46. package/react-native/cpp/include/SmallPeerInfo.h +0 -19
  47. package/react-native/cpp/include/Transports.h +0 -25
  48. package/react-native/cpp/include/TypedArray.hpp +0 -167
  49. package/react-native/cpp/include/Utils.h +0 -70
  50. package/react-native/cpp/include/main.h +0 -10
  51. package/react-native/cpp/src/Attachment.cpp +0 -272
  52. package/react-native/cpp/src/Authentication.cpp +0 -227
  53. package/react-native/cpp/src/Collection.cpp +0 -56
  54. package/react-native/cpp/src/ConnectionRequest.cpp +0 -123
  55. package/react-native/cpp/src/DQL.cpp +0 -256
  56. package/react-native/cpp/src/Document.cpp +0 -146
  57. package/react-native/cpp/src/FFIUtils.cpp +0 -122
  58. package/react-native/cpp/src/IO.cpp +0 -35
  59. package/react-native/cpp/src/Identity.cpp +0 -122
  60. package/react-native/cpp/src/Lifecycle.cpp +0 -93
  61. package/react-native/cpp/src/LiveQuery.cpp +0 -63
  62. package/react-native/cpp/src/Logger.cpp +0 -199
  63. package/react-native/cpp/src/Misc.cpp +0 -322
  64. package/react-native/cpp/src/Presence.cpp +0 -166
  65. package/react-native/cpp/src/SmallPeerInfo.cpp +0 -142
  66. package/react-native/cpp/src/Transports.cpp +0 -275
  67. package/react-native/cpp/src/TypedArray.cpp +0 -303
  68. package/react-native/cpp/src/Utils.cpp +0 -139
  69. package/react-native/cpp/src/main.cpp +0 -178
  70. package/react-native/dittoffi/dittoffi.h +0 -4873
  71. package/react-native/dittoffi/ifaddrs.cpp +0 -385
  72. package/react-native/dittoffi/ifaddrs.h +0 -206
  73. package/react-native/ios/DittoRNSDK.h +0 -7
  74. package/react-native/ios/DittoRNSDK.mm +0 -159
  75. package/react-native/ios/YeetJSIUtils.h +0 -60
  76. package/react-native/ios/YeetJSIUtils.mm +0 -196
  77. package/react-native/lib/commonjs/ditto.rn.js +0 -93
  78. package/react-native/lib/commonjs/ditto.rn.js.map +0 -1
  79. package/react-native/lib/commonjs/index.js +0 -61
  80. package/react-native/lib/commonjs/index.js.map +0 -1
  81. package/react-native/lib/module/ditto.rn.js +0 -89
  82. package/react-native/lib/module/ditto.rn.js.map +0 -1
  83. package/react-native/lib/module/index.js +0 -27
  84. package/react-native/lib/module/index.js.map +0 -1
  85. package/react-native/lib/typescript/ditto.rn.d.ts +0 -15
  86. package/react-native/lib/typescript/ditto.rn.d.ts.map +0 -1
  87. package/react-native/lib/typescript/index.d.ts +0 -1
  88. package/react-native/lib/typescript/index.d.ts.map +0 -1
  89. package/react-native/src/ditto.rn.ts +0 -123
  90. package/react-native/src/environment/environment.fallback.ts +0 -4
  91. package/react-native/src/index.ts +0 -29
  92. package/react-native/src/sources/@cbor-redux.ts +0 -2
  93. package/react-native/src/sources/@ditto.core.ts +0 -1
  94. package/react-native/src/sources/@environment.ts +0 -1
  95. package/react-native/src/sources/attachment-fetch-event.ts +0 -54
  96. package/react-native/src/sources/attachment-fetcher-manager.ts +0 -145
  97. package/react-native/src/sources/attachment-fetcher.ts +0 -265
  98. package/react-native/src/sources/attachment-token.ts +0 -129
  99. package/react-native/src/sources/attachment.ts +0 -121
  100. package/react-native/src/sources/augment.ts +0 -108
  101. package/react-native/src/sources/authenticator.ts +0 -314
  102. package/react-native/src/sources/base-pending-cursor-operation.ts +0 -255
  103. package/react-native/src/sources/base-pending-id-specific-operation.ts +0 -112
  104. package/react-native/src/sources/bridge.ts +0 -557
  105. package/react-native/src/sources/build-time-constants.ts +0 -8
  106. package/react-native/src/sources/cbor.ts +0 -20
  107. package/react-native/src/sources/collection-interface.ts +0 -73
  108. package/react-native/src/sources/collection.ts +0 -219
  109. package/react-native/src/sources/collections-event.ts +0 -99
  110. package/react-native/src/sources/connection-request.ts +0 -142
  111. package/react-native/src/sources/counter.ts +0 -82
  112. package/react-native/src/sources/ditto.ts +0 -991
  113. package/react-native/src/sources/document-id.ts +0 -163
  114. package/react-native/src/sources/document-path.ts +0 -308
  115. package/react-native/src/sources/document.ts +0 -237
  116. package/react-native/src/sources/epilogue.ts +0 -32
  117. package/react-native/src/sources/error-codes.ts +0 -114
  118. package/react-native/src/sources/error.ts +0 -256
  119. package/react-native/src/sources/essentials.ts +0 -81
  120. package/react-native/src/sources/ffi-error.ts +0 -134
  121. package/react-native/src/sources/ffi.ts +0 -2190
  122. package/react-native/src/sources/identity.ts +0 -163
  123. package/react-native/src/sources/init.ts +0 -71
  124. package/react-native/src/sources/internal.ts +0 -143
  125. package/react-native/src/sources/keep-alive.ts +0 -73
  126. package/react-native/src/sources/key-path.ts +0 -198
  127. package/react-native/src/sources/live-query-event.ts +0 -208
  128. package/react-native/src/sources/live-query-manager.ts +0 -110
  129. package/react-native/src/sources/live-query.ts +0 -167
  130. package/react-native/src/sources/logger.ts +0 -196
  131. package/react-native/src/sources/main.ts +0 -61
  132. package/react-native/src/sources/observer-manager.ts +0 -185
  133. package/react-native/src/sources/observer.ts +0 -79
  134. package/react-native/src/sources/pending-collections-operation.ts +0 -241
  135. package/react-native/src/sources/pending-cursor-operation.ts +0 -218
  136. package/react-native/src/sources/pending-id-specific-operation.ts +0 -218
  137. package/react-native/src/sources/presence-manager.ts +0 -170
  138. package/react-native/src/sources/presence.ts +0 -427
  139. package/react-native/src/sources/query-result-item.ts +0 -131
  140. package/react-native/src/sources/query-result.ts +0 -55
  141. package/react-native/src/sources/register.ts +0 -95
  142. package/react-native/src/sources/small-peer-info.ts +0 -166
  143. package/react-native/src/sources/static-tcp-client.ts +0 -8
  144. package/react-native/src/sources/store-observer.ts +0 -170
  145. package/react-native/src/sources/store.ts +0 -630
  146. package/react-native/src/sources/subscription-manager.ts +0 -99
  147. package/react-native/src/sources/subscription.ts +0 -89
  148. package/react-native/src/sources/sync-subscription.ts +0 -90
  149. package/react-native/src/sources/sync.ts +0 -561
  150. package/react-native/src/sources/test-helpers.ts +0 -24
  151. package/react-native/src/sources/transport-conditions-manager.ts +0 -104
  152. package/react-native/src/sources/transport-config.ts +0 -430
  153. package/react-native/src/sources/update-result.ts +0 -66
  154. package/react-native/src/sources/update-results-map.ts +0 -65
  155. package/react-native/src/sources/websocket-client.ts +0 -7
  156. package/react-native/src/sources/write-transaction-collection.ts +0 -122
  157. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +0 -101
  158. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +0 -74
  159. package/react-native/src/sources/write-transaction.ts +0 -121
  160. package/react-native.config.js +0 -9
@@ -1,159 +0,0 @@
1
- #import "DittoRNSDK.h"
2
- #import <React/RCTBridge+Private.h>
3
- #import <React/RCTUtils.h>
4
- #import <jsi/jsi.h>
5
- #import "main.h"
6
- #import <sys/utsname.h>
7
- #import "YeetJSIUtils.h"
8
- #import <React/RCTBridge+Private.h>
9
- #import "TypedArray.hpp"
10
-
11
- using namespace facebook::jsi;
12
-
13
- @implementation DittoRNSDK
14
-
15
- @synthesize bridge = _bridge;
16
- @synthesize methodQueue = _methodQueue;
17
-
18
- RCT_EXPORT_MODULE()
19
-
20
- + (BOOL)requiresMainQueueSetup
21
- {
22
- return YES;
23
- }
24
-
25
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
26
- {
27
- RCTBridge* bridge = [RCTBridge currentBridge];
28
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
29
- Runtime *jsiRuntime = (Runtime *) cxxBridge.runtime;
30
-
31
- sharedjsi::install(*jsiRuntime);
32
- install(*jsiRuntime);
33
-
34
- return @true;
35
- }
36
-
37
- static void install(jsi::Runtime &jsiRuntime) {
38
- auto defaultDeviceName = Function::createFromHostFunction(jsiRuntime,
39
- PropNameID::forAscii(jsiRuntime,
40
- "defaultDeviceName"),
41
- 0,
42
- [](Runtime &runtime,
43
- const Value &thisValue,
44
- const Value *arguments,
45
- size_t count) -> Value {
46
-
47
- return convertNSStringToJSIString(runtime, [[UIDevice currentDevice] name]);
48
- });
49
-
50
- jsiRuntime.global().setProperty(jsiRuntime, "defaultDeviceName", std::move(defaultDeviceName));
51
-
52
- auto createDirectory = Function::createFromHostFunction(jsiRuntime,
53
- PropNameID::forAscii(jsiRuntime,
54
- "createDirectory"),
55
- 0,
56
- [](Runtime &runtime,
57
- const Value &thisValue,
58
- const Value *arguments,
59
- size_t count) -> Value {
60
-
61
- NSFileManager *fileManager = [NSFileManager defaultManager];
62
- NSString *path = convertJSIStringToNSString(runtime, arguments[0].toString(runtime));
63
- NSString *finalPath = path;
64
-
65
- if (![path hasPrefix:@"/"]) {
66
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
67
- NSString *documentsDirectory = [paths objectAtIndex:0];
68
- finalPath = [documentsDirectory stringByAppendingPathComponent:path];
69
- }
70
-
71
- if (![fileManager fileExistsAtPath:finalPath]) {
72
- NSError *error;
73
- [fileManager createDirectoryAtPath:finalPath withIntermediateDirectories:YES attributes:nil error:&error];
74
- if (error) {
75
- NSLog(@"Error creating directory: %@", error.localizedDescription);
76
- }
77
- }
78
-
79
- return convertNSStringToJSIString(runtime, finalPath);
80
- });
81
-
82
- jsiRuntime.global().setProperty(jsiRuntime, "createDirectory", std::move(createDirectory));
83
-
84
- auto copyFile = Function::createFromHostFunction(jsiRuntime,
85
- PropNameID::forAscii(jsiRuntime, "copyFile"),
86
- 3, // Expecting three arguments now
87
- [](Runtime &runtime,
88
- const Value &thisValue,
89
- const Value *arguments,
90
- size_t count) -> Value {
91
- NSString *sourcePath = convertJSIStringToNSString(runtime, arguments[0].toString(runtime));
92
- NSString *destinationPath = convertJSIStringToNSString(runtime, arguments[1].toString(runtime));
93
- NSString *defaultFolder = convertJSIStringToNSString(runtime, arguments[2].toString(runtime));
94
-
95
- NSFileManager *fileManager = [NSFileManager defaultManager];
96
-
97
- // Resolve full path for destination, considering the defaultFolder argument for relative paths
98
- NSString *finalDestinationPath = destinationPath;
99
- if (![destinationPath hasPrefix:@"/"]) {
100
- finalDestinationPath = [defaultFolder stringByAppendingPathComponent:destinationPath];
101
- }
102
-
103
- // Ensure the directory for the destination file exists
104
- NSString *destinationDirectory = [finalDestinationPath stringByDeletingLastPathComponent];
105
- if (![fileManager fileExistsAtPath:destinationDirectory]) {
106
- NSError *directoryError;
107
- [fileManager createDirectoryAtPath:destinationDirectory withIntermediateDirectories:YES attributes:nil error:&directoryError];
108
- if (directoryError) {
109
- NSLog(@"Error creating directory for file copy: %@", directoryError.localizedDescription);
110
- std::string errorMessage = std::string("Error creating directory: ") + std::string(directoryError.localizedDescription.UTF8String);
111
- throw jsi::JSError(runtime, errorMessage.c_str());
112
- }
113
- }
114
-
115
- // Check if the destination file already exists to prevent overwriting
116
- if ([fileManager fileExistsAtPath:finalDestinationPath]) {
117
- NSString *errorString = [NSString stringWithFormat:@"Destination file already exists and will not be overwritten: %@", finalDestinationPath];
118
- NSLog(@"%@", errorString);
119
- throw jsi::JSError(runtime, errorString.UTF8String);
120
- }
121
-
122
- // Perform the file copy
123
- NSError *copyError;
124
- BOOL success = [fileManager copyItemAtPath:sourcePath toPath:finalDestinationPath error:&copyError];
125
- if (!success) {
126
- NSLog(@"Error copying file: %@", copyError.localizedDescription);
127
- std::string errorMessage = std::string("Error copying file: ") + copyError.localizedDescription.UTF8String;
128
- throw jsi::JSError(runtime, errorMessage.c_str());
129
- }
130
-
131
- return Value();
132
- });
133
-
134
- jsiRuntime.global().setProperty(jsiRuntime, "copyFile", std::move(copyFile));
135
-
136
- auto getRandomValues = jsi::Function::createFromHostFunction(jsiRuntime,
137
- jsi::PropNameID::forUtf8(jsiRuntime, "getRandomValues"),
138
- 1,
139
- [](jsi::Runtime& runtime,
140
- const jsi::Value& thisArg,
141
- const jsi::Value* args,
142
- size_t count) -> jsi::Value {
143
- TypedArrayBase typedArrayBase(runtime, args[0].asObject(runtime));
144
- auto byteLength = typedArrayBase.byteLength(runtime);
145
-
146
- NSMutableData *data = [NSMutableData dataWithLength:byteLength];
147
- int result = SecRandomCopyBytes(kSecRandomDefault, byteLength, data.mutableBytes);
148
- if (result != errSecSuccess) { }
149
-
150
- auto typedArray = TypedArray<TypedArrayKind::Uint16Array>(runtime, byteLength);
151
- auto arrayBuffer = typedArray.getBuffer(runtime);
152
- memcpy(arrayBuffer.data(runtime), data.bytes, data.length);
153
- return typedArray;
154
- });
155
-
156
- jsiRuntime.global().setProperty(jsiRuntime, "getRandomValues", std::move(getRandomValues));
157
- }
158
-
159
- @end
@@ -1,60 +0,0 @@
1
- //
2
- // YeetJSIUTils.h
3
- // yeet
4
- //
5
- // Created by Jarred WSumner on 1/30/20.
6
- // Copyright © 2020 Facebook. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
- #import <jsi/jsi.h>
11
- #import <React/RCTBridgeModule.h>
12
-
13
- using namespace facebook;
14
- /**
15
- * All static helper functions are ObjC++ specific.
16
- */
17
- jsi::Value convertNSNumberToJSIBoolean(jsi::Runtime &runtime, NSNumber *value);
18
- jsi::Value convertNSNumberToJSINumber(jsi::Runtime &runtime, NSNumber *value);
19
- jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value);
20
- jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);;
21
- jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value);
22
- jsi::Array convertNSArrayToJSIArray(jsi::Runtime &runtime, NSArray *value);
23
- std::vector<jsi::Value> convertNSArrayToStdVector(jsi::Runtime &runtime, NSArray *value);
24
- jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);
25
- id convertJSIValueToObjCObject(
26
- jsi::Runtime &runtime,
27
- const jsi::Value &value);
28
- NSString* convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value);
29
- NSArray* convertJSIArrayToNSArray(
30
- jsi::Runtime &runtime,
31
- const jsi::Array &value);
32
- NSDictionary *convertJSIObjectToNSDictionary(
33
- jsi::Runtime &runtime,
34
- const jsi::Object &value);
35
- RCTResponseSenderBlock convertJSIFunctionToCallback(
36
- jsi::Runtime &runtime,
37
- const jsi::Function &value);
38
- id convertJSIValueToObjCObject(
39
- jsi::Runtime &runtime,
40
- const jsi::Value &value);
41
- RCTResponseSenderBlock convertJSIFunctionToCallback(
42
- jsi::Runtime &runtime,
43
- const jsi::Function &value);
44
-
45
- struct Promise {
46
- Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject);
47
-
48
- void resolve(const jsi::Value &result);
49
- void reject(const std::string &error);
50
-
51
- jsi::Runtime &runtime_;
52
- jsi::Function resolve_;
53
- jsi::Function reject_;
54
- };
55
-
56
- using PromiseSetupFunctionType =
57
- std::function<void(jsi::Runtime &rt, std::shared_ptr<Promise>)>;
58
- jsi::Value createPromiseAsJSIValue(
59
- jsi::Runtime &rt,
60
- const PromiseSetupFunctionType func);
@@ -1,196 +0,0 @@
1
- //
2
- // REAJsiUtilities.cpp
3
- // RNReanimated
4
- //
5
- // Created by Christian Falch on 25/04/2019.
6
- // Copyright © 2019 Facebook. All rights reserved.
7
- //
8
-
9
- #include "YeetJSIUtils.h"
10
- #import <React/RCTConvert.h>
11
- #import <React/RCTBridgeModule.h>
12
- //#import <ReactCommon/TurboModuleUtils.h>
13
-
14
- /**
15
- * All helper functions are ObjC++ specific.
16
- */
17
- jsi::Value convertNSNumberToJSIBoolean(jsi::Runtime &runtime, NSNumber *value)
18
- {
19
- return jsi::Value((bool)[value boolValue]);
20
- }
21
-
22
- jsi::Value convertNSNumberToJSINumber(jsi::Runtime &runtime, NSNumber *value)
23
- {
24
- return jsi::Value([value doubleValue]);
25
- }
26
-
27
- jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value)
28
- {
29
- return jsi::String::createFromUtf8(runtime, [value UTF8String] ?: "");
30
- }
31
-
32
- jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);
33
- jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value)
34
- {
35
- jsi::Object result = jsi::Object(runtime);
36
- for (NSString *k in value) {
37
- result.setProperty(runtime, [k UTF8String], convertObjCObjectToJSIValue(runtime, value[k]));
38
- }
39
- return result;
40
- }
41
-
42
- jsi::Array convertNSArrayToJSIArray(jsi::Runtime &runtime, NSArray *value)
43
- {
44
- jsi::Array result = jsi::Array(runtime, value.count);
45
- for (size_t i = 0; i < value.count; i++) {
46
- result.setValueAtIndex(runtime, i, convertObjCObjectToJSIValue(runtime, value[i]));
47
- }
48
- return result;
49
- }
50
-
51
- std::vector<jsi::Value> convertNSArrayToStdVector(jsi::Runtime &runtime, NSArray *value)
52
- {
53
- std::vector<jsi::Value> result;
54
- for (size_t i = 0; i < value.count; i++) {
55
- result.emplace_back(convertObjCObjectToJSIValue(runtime, value[i]));
56
- }
57
- return result;
58
- }
59
-
60
- jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value)
61
- {
62
- if ([value isKindOfClass:[NSString class]]) {
63
- return convertNSStringToJSIString(runtime, (NSString *)value);
64
- } else if ([value isKindOfClass:[NSNumber class]]) {
65
- if ([value isKindOfClass:[@YES class]]) {
66
- return convertNSNumberToJSIBoolean(runtime, (NSNumber *)value);
67
- }
68
- return convertNSNumberToJSINumber(runtime, (NSNumber *)value);
69
- } else if ([value isKindOfClass:[NSDictionary class]]) {
70
- return convertNSDictionaryToJSIObject(runtime, (NSDictionary *)value);
71
- } else if ([value isKindOfClass:[NSArray class]]) {
72
- return convertNSArrayToJSIArray(runtime, (NSArray *)value);
73
- } else if (value == (id)kCFNull) {
74
- return jsi::Value::null();
75
- }
76
- return jsi::Value::undefined();
77
- }
78
-
79
- id convertJSIValueToObjCObject(
80
- jsi::Runtime &runtime,
81
- const jsi::Value &value);
82
- NSString *convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value)
83
- {
84
- return [NSString stringWithUTF8String:value.utf8(runtime).c_str()];
85
- }
86
-
87
- NSArray *convertJSIArrayToNSArray(
88
- jsi::Runtime &runtime,
89
- const jsi::Array &value)
90
- {
91
- size_t size = value.size(runtime);
92
- NSMutableArray *result = [NSMutableArray new];
93
- for (size_t i = 0; i < size; i++) {
94
- // Insert kCFNull when it's `undefined` value to preserve the indices.
95
- [result
96
- addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i)) ?: (id)kCFNull];
97
- }
98
- return [result copy];
99
- }
100
-
101
- NSDictionary *convertJSIObjectToNSDictionary(
102
- jsi::Runtime &runtime,
103
- const jsi::Object &value)
104
- {
105
- jsi::Array propertyNames = value.getPropertyNames(runtime);
106
- size_t size = propertyNames.size(runtime);
107
- NSMutableDictionary *result = [NSMutableDictionary new];
108
- for (size_t i = 0; i < size; i++) {
109
- jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
110
- NSString *k = convertJSIStringToNSString(runtime, name);
111
- id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name));
112
- if (v) {
113
- result[k] = v;
114
- }
115
- }
116
- return [result copy];
117
- }
118
-
119
- RCTResponseSenderBlock convertJSIFunctionToCallback(
120
- jsi::Runtime &runtime,
121
- const jsi::Function &value)
122
- {
123
- __block auto cb = value.getFunction(runtime);
124
-
125
- return ^(NSArray *responses) {
126
- cb.call(runtime, convertNSArrayToJSIArray(runtime, responses), 2);
127
- };
128
- }
129
-
130
- id convertJSIValueToObjCObject(
131
- jsi::Runtime &runtime,
132
- const jsi::Value &value)
133
- {
134
- if (value.isUndefined() || value.isNull()) {
135
- return nil;
136
- }
137
- if (value.isBool()) {
138
- return @(value.getBool());
139
- }
140
- if (value.isNumber()) {
141
- return @(value.getNumber());
142
- }
143
- if (value.isString()) {
144
- return convertJSIStringToNSString(runtime, value.getString(runtime));
145
- }
146
- if (value.isObject()) {
147
- jsi::Object o = value.getObject(runtime);
148
- if (o.isArray(runtime)) {
149
- return convertJSIArrayToNSArray(runtime, o.getArray(runtime));
150
- }
151
- if (o.isFunction(runtime)) {
152
- return convertJSIFunctionToCallback(runtime, std::move(o.getFunction(runtime)));
153
- }
154
- return convertJSIObjectToNSDictionary(runtime, o);
155
- }
156
-
157
- throw std::runtime_error("Unsupported jsi::jsi::Value kind");
158
- }
159
-
160
- Promise::Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject)
161
- : runtime_(rt), resolve_(std::move(resolve)), reject_(std::move(reject)) {}
162
-
163
- void Promise::resolve(const jsi::Value &result) {
164
- resolve_.call(runtime_, result);
165
- }
166
-
167
- void Promise::reject(const std::string &message) {
168
- jsi::Object error(runtime_);
169
- error.setProperty(
170
- runtime_, "message", jsi::String::createFromUtf8(runtime_, message));
171
- reject_.call(runtime_, error);
172
- }
173
-
174
- jsi::Value createPromiseAsJSIValue(
175
- jsi::Runtime &rt,
176
- const PromiseSetupFunctionType func) {
177
- jsi::Function JSPromise = rt.global().getPropertyAsFunction(rt, "Promise");
178
- jsi::Function fn = jsi::Function::createFromHostFunction(
179
- rt,
180
- jsi::PropNameID::forAscii(rt, "fn"),
181
- 2,
182
- [func](
183
- jsi::Runtime &rt2,
184
- const jsi::Value &thisVal,
185
- const jsi::Value *args,
186
- size_t count) {
187
- jsi::Function resolve = args[0].getObject(rt2).getFunction(rt2);
188
- jsi::Function reject = args[1].getObject(rt2).getFunction(rt2);
189
- auto wrapper = std::make_shared<Promise>(
190
- rt2, std::move(resolve), std::move(reject));
191
- func(rt2, wrapper);
192
- return jsi::Value::undefined();
193
- });
194
-
195
- return JSPromise.callAsConstructor(rt, fn);
196
- }
@@ -1,93 +0,0 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
5
- })
6
- exports.boxCBytesIntoBuffer = boxCBytesIntoBuffer
7
- exports.boxCStringIntoString = boxCStringIntoString
8
- exports.ditto_sdk_transports_init = ditto_sdk_transports_init
9
- exports.getDeadlockTimeout = getDeadlockTimeout
10
- exports.getMissingAndroidPermissions = getMissingAndroidPermissions
11
- exports.setDeadlockTimeout = setDeadlockTimeout
12
- var _reactNative = require('react-native')
13
- var _weakrefs = require('@ungap/weakrefs')
14
- require('fastestsmallesttextencoderdecoder')
15
- // import { fullBuildVersionString } from '../../sources/build-time-constants';
16
-
17
- const dittoCore = global
18
- const isLoaded = typeof dittoCore.ditto_sdk_transports_init === 'function'
19
- if (!isLoaded) {
20
- var _NativeModules$DittoR
21
- const result = (_NativeModules$DittoR = _reactNative.NativeModules.DittoRNSDK) === null || _NativeModules$DittoR === void 0 ? void 0 : _NativeModules$DittoR.install()
22
- if (!result) {
23
- throw new Error('JSI bindings were not installed for: DittoRNSDK Module')
24
- }
25
-
26
- setInterval(() => {
27
- dittoCore.ditto_tick()
28
- }, 50)
29
-
30
- // Stay as close as possible to the JS SDK with the API
31
- // We have to rename the shim that has a different name.
32
- if (typeof global.FinalizationRegistry === 'undefined' && typeof _weakrefs.FinalizationGroup !== 'undefined') {
33
- global.FinalizationRegistry = _weakrefs.FinalizationGroup
34
- }
35
- const platformName = _reactNative.Platform.select({
36
- ios: 'Ios',
37
- android: 'Android',
38
- default: 'Unknown',
39
- })
40
- dittoCore.ditto_init_sdk_version(platformName, 'JavaScript', '4.5.3')
41
- }
42
-
43
- // Export JSI methods.
44
- Object.keys(dittoCore)
45
- // we will provide our own decorated implementation.
46
- .filter((key) => key !== 'ditto_sdk_transports_init')
47
- .forEach((key) => {
48
- exports[key] = dittoCore[key]
49
- })
50
-
51
- // Decorated implementation with an extra step of setting the context for
52
- // Transports to work on Android.
53
- function ditto_sdk_transports_init(transportsErrorPointer) {
54
- if (_reactNative.Platform.OS === 'android') {
55
- const res = dittoCore.ditto_sdk_transports_set_android_context()
56
- if (!res) {
57
- throw new Error("Couldn't manage to set Android context with `ditto_sdk_transports_set_android_context()`")
58
- }
59
- }
60
- return dittoCore.ditto_sdk_transports_init(transportsErrorPointer)
61
- }
62
-
63
- /**
64
- * Get the list of missing Android permissions for syncing. The returned value
65
- * can be passed directly to `PermissionsAndroid.requestMultiple()`.
66
- *
67
- * Returns an empty array on other platforms.
68
- */
69
- function getMissingAndroidPermissions() {
70
- if (_reactNative.Platform.OS !== 'android') {
71
- return []
72
- }
73
- return dittoCore.ditto_sdk_transports_android_missing_permissions()
74
- }
75
-
76
- //
77
- // Needed as for JS SDK API's.
78
- //
79
-
80
- function boxCStringIntoString(something) {
81
- return something
82
- }
83
- function boxCBytesIntoBuffer(cborBytes) {
84
- const bytes = dittoCore.sliceBoxedToUInt8Array(cborBytes)
85
- return bytes ? new Uint8Array(bytes) : null
86
- }
87
- function getDeadlockTimeout() {
88
- return 0
89
- }
90
- function setDeadlockTimeout(something) {
91
- return something
92
- }
93
- //# sourceMappingURL=ditto.rn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_weakrefs","dittoCore","global","isLoaded","ditto_sdk_transports_init","_NativeModules$DittoR","result","NativeModules","DittoRNSDK","install","Error","setInterval","ditto_tick","FinalizationRegistry","FinalizationGroup","platformName","Platform","select","ios","android","default","ditto_init_sdk_version","Object","keys","filter","key","forEach","exports","transportsErrorPointer","OS","res","ditto_sdk_transports_set_android_context","getMissingAndroidPermissions","ditto_sdk_transports_android_missing_permissions","boxCStringIntoString","something","boxCBytesIntoBuffer","cborBytes","bytes","sliceBoxedToUInt8Array","Uint8Array","getDeadlockTimeout","setDeadlockTimeout"],"sourceRoot":"../../src","sources":["ditto.rn.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAD,OAAA;AACAA,OAAA;AANA;;AAEA;AACA;AACA;AAIA;AAEA;AACA;AACA;AAoBA,MAAME,SAAS,GAAGC,MAAkC;AAEpD,MAAMC,QAAQ,GAAG,OAAOF,SAAS,CAACG,yBAAyB,KAAK,UAAU;AAC1E,IAAI,CAACD,QAAQ,EAAE;EAAA,IAAAE,qBAAA;EACb,MAAMC,MAAM,IAAAD,qBAAA,GAAGE,0BAAa,CAACC,UAAU,cAAAH,qBAAA,uBAAxBA,qBAAA,CAA0BI,OAAO,CAAC,CAAC;EAElD,IAAI,CAACH,MAAM,EAAE;IACX,MAAM,IAAII,KAAK,CAAC,wDAAwD,CAAC;EAC3E;;EAEA;EACA;EACA;EACAC,WAAW,CAAC,MAAM;IAChBV,SAAS,CAACW,UAAU,CAAC,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA;EACA,IACE,OAAOV,MAAM,CAACW,oBAAoB,KAAK,WAAW,IAClD,OAAOC,2BAAiB,KAAK,WAAW,EACxC;IACAZ,MAAM,CAACW,oBAAoB,GAAGC,2BAAiB;EACjD;EAEA,MAAMC,YAAiB,GAAGC,qBAAQ,CAACC,MAAM,CAAC;IACxCC,GAAG,EAAE,KAAK;IACVC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE;EACX,CAAC,CAAC;EAEFnB,SAAS,CAACoB,sBAAsB,CAACN,YAAY,EAAE,YAAY,EAAE,OAAO,CAAC;AACvE;;AAEA;AACAO,MAAM,CAACC,IAAI,CAACtB,SAAS;AACnB;AAAA,CACCuB,MAAM,CAAEC,GAAG,IAAKA,GAAG,KAAK,2BAA2B,CAAC,CACpDC,OAAO,CAAED,GAAG,IAAK;EAChBE,OAAO,CAACF,GAAG,CAAC,GAAGxB,SAAS,CAACwB,GAAG,CAAwB;AACtD,CAAC,CAAC;;AAEJ;AACA;AACO,SAASrB,yBAAyBA,CACvCwB,sBAA2B,EAClB;EACT,IAAIZ,qBAAQ,CAACa,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAG7B,SAAS,CAAC8B,wCAAwC,CAAC,CAAC;IAChE,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIpB,KAAK,CACb,0FACF,CAAC;IACH;EACF;EACA,OAAOT,SAAS,CAACG,yBAAyB,CAACwB,sBAAsB,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,4BAA4BA,CAAA,EAAiB;EAC3D,IAAIhB,qBAAQ,CAACa,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAO,EAAE;EACX;EACA,OAAO5B,SAAS,CAACgC,gDAAgD,CAAC,CAAC;AACrE;;AAEA;AACA;AACA;;AAEO,SAASC,oBAAoBA,CAACC,SAAc,EAAE;EACnD,OAAOA,SAAS;AAClB;AAEO,SAASC,mBAAmBA,CAACC,SAAc,EAAE;EAClD,MAAMC,KAAK,GAAGrC,SAAS,CAACsC,sBAAsB,CAACF,SAAS,CAAC;EACzD,OAAOC,KAAK,GAAG,IAAIE,UAAU,CAACF,KAAK,CAAC,GAAG,IAAI;AAC7C;AAEO,SAASG,kBAAkBA,CAAA,EAAW;EAC3C,OAAO,CAAC;AACV;AAEO,SAASC,kBAAkBA,CAACP,SAAc,EAAE;EACjD,OAAOA,SAAS;AAClB"}
@@ -1,61 +0,0 @@
1
- // // RN API
2
-
3
- // export { getMissingAndroidPermissions } from './ditto.rn';
4
-
5
- // // JS API
6
-
7
- // // export * from '../../sources/keep-alive';
8
-
9
- // export * from '../../sources/essentials';
10
- // // export * from '../../sources/counter';
11
- // // export * from '../../sources/register';
12
- // // export * from '../../sources/attachment-token';
13
-
14
- // // export * from '../../sources/init';
15
- // export * from '../../sources/logger';
16
- // export * from '../../sources/document-id';
17
- // export * from '../../sources/observer';
18
-
19
- // // export * from '../../sources/base-pending-cursor-operation';
20
- // // export * from '../../sources/base-pending-id-specific-operation';
21
- // export * from '../../sources/authenticator';
22
- // export * from '../../sources/identity';
23
- // export * from '../../sources/ditto';
24
- // export * from '../../sources/store-observer';
25
- // // export * from '../../sources/collection';
26
- // // export * from '../../sources/collection-interface';
27
- // // export * from '../../sources/collections-event';
28
- // // export * from '../../sources/document-path';
29
- // // export * from '../../sources/document';
30
- // export * from '../../sources/sync';
31
- // export * from '../../sources/sync-subscription';
32
- // export * from '../../sources/error';
33
- // export * from '../../sources/error-codes';
34
- // export * from '../../sources/query-result-item';
35
- // export * from '../../sources/query-result';
36
- // // export * from '../../sources/live-query-event';
37
- // // export * from '../../sources/live-query';
38
- // // export * from '../../sources/attachment';
39
- // // export * from '../../sources/attachment-fetcher';
40
- // // export * from '../../sources/attachment-fetch-event';
41
- // // export * from '../../sources/pending-cursor-operation';
42
- // // export * from '../../sources/pending-id-specific-operation';
43
- // // export * from '../../sources/pending-collections-operation';
44
- // export * from '../../sources/small-peer-info';
45
- // export * from '../../sources/store';
46
- // export * from '../../sources/presence';
47
- // // export * from '../../sources/subscription';
48
- // // export * from '../../sources/test-helpers';
49
- // export * from '../../sources/transport-config';
50
- // // export * from '../../sources/update-result';
51
- // // export * from '../../sources/update-results-map';
52
- // // export * from '../../sources/write-transaction';
53
- // // export * from '../../sources/write-transaction-collection';
54
- // // export * from '../../sources/write-transaction-pending-cursor-operation';
55
- // // export * from '../../sources/write-transaction-pending-id-specific-operation';
56
- // export * from '../../sources/epilogue';
57
-
58
- // // TEMPORARY: exported to deal with non-canonical IDs.
59
- // // export * from '../../sources/cbor';
60
- "use strict";
61
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AAAA"}
@@ -1,89 +0,0 @@
1
- import { NativeModules, Platform } from 'react-native'
2
- // import { fullBuildVersionString } from '../../sources/build-time-constants';
3
-
4
- // @ts-ignore No types provided by the 3rd party
5
- import { FinalizationGroup } from '@ungap/weakrefs'
6
- import 'fastestsmallesttextencoderdecoder'
7
-
8
- // import type { Language, Platform as SDKPlatform } from '../../sources/ffi';
9
-
10
- // No need to define types for each of them as these will not be used anywhere,
11
- // but rather just pollute and require maintenance. It's good to highlight that
12
- // these will be exported, though.
13
- const dittoCore = global
14
- const isLoaded = typeof dittoCore.ditto_sdk_transports_init === 'function'
15
- if (!isLoaded) {
16
- var _NativeModules$DittoR
17
- const result = (_NativeModules$DittoR = NativeModules.DittoRNSDK) === null || _NativeModules$DittoR === void 0 ? void 0 : _NativeModules$DittoR.install()
18
- if (!result) {
19
- throw new Error('JSI bindings were not installed for: DittoRNSDK Module')
20
- }
21
-
22
- setInterval(() => {
23
- dittoCore.ditto_tick()
24
- }, 50)
25
-
26
- // Stay as close as possible to the JS SDK with the API
27
- // We have to rename the shim that has a different name.
28
- if (typeof global.FinalizationRegistry === 'undefined' && typeof FinalizationGroup !== 'undefined') {
29
- global.FinalizationRegistry = FinalizationGroup
30
- }
31
- const platformName = Platform.select({
32
- ios: 'Ios',
33
- android: 'Android',
34
- default: 'Unknown',
35
- })
36
- dittoCore.ditto_init_sdk_version(platformName, 'JavaScript', '4.5.3')
37
- }
38
-
39
- // Export JSI methods.
40
- Object.keys(dittoCore)
41
- // we will provide our own decorated implementation.
42
- .filter((key) => key !== 'ditto_sdk_transports_init')
43
- .forEach((key) => {
44
- exports[key] = dittoCore[key]
45
- })
46
-
47
- // Decorated implementation with an extra step of setting the context for
48
- // Transports to work on Android.
49
- export function ditto_sdk_transports_init(transportsErrorPointer) {
50
- if (Platform.OS === 'android') {
51
- const res = dittoCore.ditto_sdk_transports_set_android_context()
52
- if (!res) {
53
- throw new Error("Couldn't manage to set Android context with `ditto_sdk_transports_set_android_context()`")
54
- }
55
- }
56
- return dittoCore.ditto_sdk_transports_init(transportsErrorPointer)
57
- }
58
-
59
- /**
60
- * Get the list of missing Android permissions for syncing. The returned value
61
- * can be passed directly to `PermissionsAndroid.requestMultiple()`.
62
- *
63
- * Returns an empty array on other platforms.
64
- */
65
- export function getMissingAndroidPermissions() {
66
- if (Platform.OS !== 'android') {
67
- return []
68
- }
69
- return dittoCore.ditto_sdk_transports_android_missing_permissions()
70
- }
71
-
72
- //
73
- // Needed as for JS SDK API's.
74
- //
75
-
76
- export function boxCStringIntoString(something) {
77
- return something
78
- }
79
- export function boxCBytesIntoBuffer(cborBytes) {
80
- const bytes = dittoCore.sliceBoxedToUInt8Array(cborBytes)
81
- return bytes ? new Uint8Array(bytes) : null
82
- }
83
- export function getDeadlockTimeout() {
84
- return 0
85
- }
86
- export function setDeadlockTimeout(something) {
87
- return something
88
- }
89
- //# sourceMappingURL=ditto.rn.js.map