@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 +0,0 @@
1
- {"version":3,"names":["NativeModules","Platform","FinalizationGroup","dittoCore","global","isLoaded","ditto_sdk_transports_init","_NativeModules$DittoR","result","DittoRNSDK","install","Error","setInterval","ditto_tick","FinalizationRegistry","platformName","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,SAASA,aAAa,EAAEC,QAAQ,QAAyB,cAAc;AACvE;;AAEA;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,OAAO,mCAAmC;;AAE1C;;AAEA;AACA;AACA;AAoBA,MAAMC,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,GAAGP,aAAa,CAACS,UAAU,cAAAF,qBAAA,uBAAxBA,qBAAA,CAA0BG,OAAO,CAAC,CAAC;EAElD,IAAI,CAACF,MAAM,EAAE;IACX,MAAM,IAAIG,KAAK,CAAC,wDAAwD,CAAC;EAC3E;;EAEA;EACA;EACA;EACAC,WAAW,CAAC,MAAM;IAChBT,SAAS,CAACU,UAAU,CAAC,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA;EACA,IACE,OAAOT,MAAM,CAACU,oBAAoB,KAAK,WAAW,IAClD,OAAOZ,iBAAiB,KAAK,WAAW,EACxC;IACAE,MAAM,CAACU,oBAAoB,GAAGZ,iBAAiB;EACjD;EAEA,MAAMa,YAAiB,GAAGd,QAAQ,CAACe,MAAM,CAAC;IACxCC,GAAG,EAAE,KAAK;IACVC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE;EACX,CAAC,CAAC;EAEFhB,SAAS,CAACiB,sBAAsB,CAACL,YAAY,EAAE,YAAY,EAAE,OAAO,CAAC;AACvE;;AAEA;AACAM,MAAM,CAACC,IAAI,CAACnB,SAAS;AACnB;AAAA,CACCoB,MAAM,CAAEC,GAAG,IAAKA,GAAG,KAAK,2BAA2B,CAAC,CACpDC,OAAO,CAAED,GAAG,IAAK;EAChBE,OAAO,CAACF,GAAG,CAAC,GAAGrB,SAAS,CAACqB,GAAG,CAAwB;AACtD,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,SAASlB,yBAAyBA,CACvCqB,sBAA2B,EAClB;EACT,IAAI1B,QAAQ,CAAC2B,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAG1B,SAAS,CAAC2B,wCAAwC,CAAC,CAAC;IAChE,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIlB,KAAK,CACb,0FACF,CAAC;IACH;EACF;EACA,OAAOR,SAAS,CAACG,yBAAyB,CAACqB,sBAAsB,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,4BAA4BA,CAAA,EAAiB;EAC3D,IAAI9B,QAAQ,CAAC2B,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAO,EAAE;EACX;EACA,OAAOzB,SAAS,CAAC6B,gDAAgD,CAAC,CAAC;AACrE;;AAEA;AACA;AACA;;AAEA,OAAO,SAASC,oBAAoBA,CAACC,SAAc,EAAE;EACnD,OAAOA,SAAS;AAClB;AAEA,OAAO,SAASC,mBAAmBA,CAACC,SAAc,EAAE;EAClD,MAAMC,KAAK,GAAGlC,SAAS,CAACmC,sBAAsB,CAACF,SAAS,CAAC;EACzD,OAAOC,KAAK,GAAG,IAAIE,UAAU,CAACF,KAAK,CAAC,GAAG,IAAI;AAC7C;AAEA,OAAO,SAASG,kBAAkBA,CAAA,EAAW;EAC3C,OAAO,CAAC;AACV;AAEA,OAAO,SAASC,kBAAkBA,CAACP,SAAc,EAAE;EACjD,OAAOA,SAAS;AAClB"}
@@ -1,27 +0,0 @@
1
- // RN API
2
-
3
- export { getMissingAndroidPermissions } from './ditto.rn';
4
-
5
- // JS API
6
-
7
- export * from '../../sources/essentials';
8
- export * from '../../sources/logger';
9
- export * from '../../sources/document-id';
10
- export * from '../../sources/observer';
11
- export * from '../../sources/authenticator';
12
- export * from '../../sources/identity';
13
- export * from '../../sources/ditto';
14
- export * from '../../sources/store-observer';
15
- export * from '../../sources/sync';
16
- export * from '../../sources/sync-subscription';
17
- export * from '../../sources/error';
18
- export * from '../../sources/error-codes';
19
- export * from '../../sources/query-result-item';
20
- export * from '../../sources/query-result';
21
- export * from '../../sources/small-peer-info';
22
- export * from '../../sources/store';
23
- export * from '../../sources/presence';
24
- export * from '../../sources/transport-config';
25
- export * from '../../sources/epilogue';
26
-
27
- # 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"}
@@ -1,15 +0,0 @@
1
- import { type Permission } from 'react-native';
2
- import 'fastestsmallesttextencoderdecoder';
3
- export declare function ditto_sdk_transports_init(transportsErrorPointer: any): boolean;
4
- /**
5
- * Get the list of missing Android permissions for syncing. The returned value
6
- * can be passed directly to `PermissionsAndroid.requestMultiple()`.
7
- *
8
- * Returns an empty array on other platforms.
9
- */
10
- export declare function getMissingAndroidPermissions(): Permission[];
11
- export declare function boxCStringIntoString(something: any): any;
12
- export declare function boxCBytesIntoBuffer(cborBytes: any): Uint8Array | null;
13
- export declare function getDeadlockTimeout(): number;
14
- export declare function setDeadlockTimeout(something: any): any;
15
- //# sourceMappingURL=ditto.rn.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ditto.rn.d.ts","sourceRoot":"","sources":["../../src/ditto.rn.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAOxE,OAAO,mCAAmC,CAAC;AAuE3C,wBAAgB,yBAAyB,CACvC,sBAAsB,EAAE,GAAG,GAC1B,OAAO,CAUT;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,IAAI,UAAU,EAAE,CAK3D;AAMD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,GAAG,OAElD;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,GAAG,qBAGjD;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,OAEhD"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
@@ -1,123 +0,0 @@
1
- import { NativeModules, Platform, type Permission } from 'react-native';
2
-
3
- import { FinalizationGroup } from '@ungap/weakrefs';
4
- import 'fastestsmallesttextencoderdecoder';
5
-
6
- import { type Language, type Platform as SDKPlatform } from './sources/ffi';
7
-
8
- interface JSSDKAPI {
9
- /* C++ methods */
10
- ditto_sdk_transports_init(transportsErrorPointer: any): boolean;
11
- ditto_init_sdk_version(
12
- platform: SDKPlatform,
13
- language: Language,
14
- semVer: string
15
- ): number;
16
- sliceBoxedToUInt8Array(cborBytes: any): Uint8Array | null;
17
- sliceRefToUInt8Array(cborBytes: any): Uint8Array | null;
18
- }
19
- interface PlatformSpecificAPI {
20
- getRandomValues<T extends ArrayBufferView>(array: T): T;
21
- ditto_tick(): void;
22
- createDirectory(path: string): string;
23
- readFile(path: string): string;
24
- copyFile(source: string, destination: string, dittoPath: string): string;
25
- checkDirectoryExists(path: string): string;
26
- defaultDeviceName(): string;
27
-
28
- // Android only
29
- ditto_sdk_transports_set_android_context(): boolean;
30
- ditto_sdk_transports_android_missing_permissions(): string[];
31
- }
32
-
33
- type DittoCoreType = JSSDKAPI & PlatformSpecificAPI;
34
- const dittoCore = global as unknown as DittoCoreType;
35
-
36
- const isLoaded = typeof dittoCore.ditto_sdk_transports_init === 'function';
37
- if (!isLoaded) {
38
- const result = NativeModules.DittoRNSDK?.install();
39
-
40
- if (!result) {
41
- throw new Error('JSI bindings were not installed for: DittoRNSDK Module');
42
- }
43
-
44
- setInterval(() => {
45
- dittoCore.ditto_tick();
46
- }, 50);
47
-
48
- if (
49
- typeof global.FinalizationRegistry === 'undefined' &&
50
- typeof FinalizationGroup !== 'undefined'
51
- ) {
52
- global.FinalizationRegistry = FinalizationGroup;
53
- }
54
-
55
- const platformName: SDKPlatform = Platform.select({
56
- ios: 'Ios',
57
- android: 'Android',
58
- default: 'Unknown',
59
- });
60
-
61
- dittoCore.ditto_init_sdk_version(
62
- platformName,
63
- 'JavaScript',
64
- '4.7.0-rc.1'
65
- );
66
- }
67
-
68
- // Export JSI methods.
69
- Object.keys(dittoCore)
70
- // we will provide our own decorated implementation.
71
- .filter((key) => key !== 'ditto_sdk_transports_init')
72
- .forEach((key) => {
73
- exports[key] = dittoCore[key as keyof DittoCoreType];
74
- });
75
-
76
- export function ditto_sdk_transports_init(
77
- transportsErrorPointer: any
78
- ): boolean {
79
- if (Platform.OS === 'android') {
80
- const res = dittoCore.ditto_sdk_transports_set_android_context();
81
- if (!res) {
82
- throw new Error(
83
- "Couldn't manage to set Android context with `ditto_sdk_transports_set_android_context()`"
84
- );
85
- }
86
- }
87
- return dittoCore.ditto_sdk_transports_init(transportsErrorPointer);
88
- }
89
-
90
- /**
91
- * Get the list of missing Android permissions for syncing. The returned value
92
- * can be passed directly to `PermissionsAndroid.requestMultiple()`.
93
- *
94
- * Returns an empty array on other platforms.
95
- */
96
- export function getMissingAndroidPermissions(): Permission[] {
97
- if (Platform.OS !== 'android') {
98
- return [];
99
- }
100
- return dittoCore.ditto_sdk_transports_android_missing_permissions() as Permission[];
101
- }
102
-
103
- //
104
- // Needed as for JS SDK API's.
105
- //
106
-
107
- export function boxCBytesIntoBuffer(cborBytes: any): Uint8Array | null {
108
- const bytes = dittoCore.sliceBoxedToUInt8Array(cborBytes);
109
- return bytes ? new Uint8Array(bytes) : null;
110
- }
111
-
112
- export function refCBytesIntoBuffer(cborBytes: any): Uint8Array | null {
113
- const bytes = dittoCore.sliceRefToUInt8Array(cborBytes);
114
- return bytes ? new Uint8Array(bytes) : null;
115
- }
116
-
117
- export function getDeadlockTimeout(): number {
118
- return 0;
119
- }
120
-
121
- export function setDeadlockTimeout(something: any) {
122
- return something;
123
- }
@@ -1,4 +0,0 @@
1
- export const isReactNativeBuild = true
2
- export const isNodeBuild = false
3
- export const isWebBuild = false
4
-
@@ -1,29 +0,0 @@
1
- export { getMissingAndroidPermissions } from './ditto.rn';
2
-
3
- export * from './sources/essentials';
4
-
5
- export * from './sources/attachment-token';
6
- export * from './sources/attachment';
7
- export * from './sources/attachment-fetcher';
8
- export * from './sources/attachment-fetch-event';
9
- export * from './sources/init';
10
- export * from './sources/logger';
11
- export * from './sources/document-id';
12
- export * from './sources/observer';
13
-
14
- export * from './sources/authenticator';
15
- export * from './sources/identity';
16
- export * from './sources/ditto';
17
- export * from './sources/store-observer';
18
- export * from './sources/sync';
19
- export * from './sources/sync-subscription';
20
- export * from './sources/error';
21
- export * from './sources/error-codes';
22
- export * from './sources/query-result-item';
23
- export * from './sources/query-result';
24
- export * from './sources/small-peer-info';
25
- export * from './sources/store';
26
- export * from './sources/presence';
27
- export * from './sources/transport-config';
28
- export * from './sources/epilogue';
29
- export * from './sources/connection-request';
@@ -1,2 +0,0 @@
1
- import * as CBOR from 'cbor-redux';
2
- export {CBOR};
@@ -1 +0,0 @@
1
- export * from '@dittolive/ditto/react-native/src/ditto.rn';
@@ -1 +0,0 @@
1
- export * from '@dittolive/ditto/react-native/src/environment/environment.fallback';
@@ -1,54 +0,0 @@
1
- //
2
- // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import type { Attachment } from './attachment'
6
- import type { Store } from './store'
7
-
8
- /**
9
- * The types of attachment fetch events that can be delivered to an attachment
10
- * fetcher's `callback`.
11
- */
12
- export type AttachmentFetchEventType = 'Completed' | 'Progress' | 'Deleted'
13
-
14
- /**
15
- * An attachment fetch event used when the attachment's download has completed.
16
- */
17
- export type AttachmentFetchEventCompleted = {
18
- type: 'Completed'
19
- attachment: Attachment
20
- }
21
-
22
- /**
23
- * An attachment fetch event used when the attachment's download progressed but
24
- * is not yet complete.
25
- */
26
- export type AttachmentFetchEventProgress = {
27
- type: 'Progress'
28
- totalBytes: number | BigInt
29
- downloadedBytes: number | BigInt
30
- }
31
-
32
- /**
33
- * An attachment fetch event used when the attachment is deleted.
34
- */
35
- export type AttachmentFetchEventDeleted = {
36
- type: 'Deleted'
37
- }
38
-
39
- /**
40
- * A representation of the events that can occur in relation to an attachment
41
- * fetch.
42
- *
43
- * There are three different attachment fetch events: `Completed`, `Progress`,
44
- * or `Deleted`.
45
- *
46
- * There will be at most one `Completed` or `Deleted` event per attachment
47
- * fetch. There can be many `Progress` events delivered for each attachment
48
- * fetch.
49
- *
50
- * Updates relating to an attachment fetch are delivered by registering an
51
- * {@link AttachmentFetcher} through a call to
52
- * {@link Store["fetchAttachment"] | ditto.store.fetchAttachment()}.
53
- */
54
- export type AttachmentFetchEvent = AttachmentFetchEventCompleted | AttachmentFetchEventProgress | AttachmentFetchEventDeleted
@@ -1,145 +0,0 @@
1
- //
2
- // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
-
7
- import { AttachmentFetcher } from './attachment-fetcher'
8
- import { AttachmentToken } from './attachment-token'
9
- import { Bridge } from './bridge'
10
-
11
- import type { AttachmentFetchEvent } from './attachment-fetch-event'
12
- import type { Ditto } from './ditto'
13
-
14
- /** @internal */
15
- type AttachmentFetcherContextInfo = {
16
- attachmentFetcher: WeakRef<AttachmentFetcher>
17
- // Attachment token is unique per attachment.
18
- attachmentTokenID: Uint8Array
19
- // This id is unique per attachment fetcher.
20
- id: string
21
- // Promise for a token that can be used to cancel the fetch. If `null`, the
22
- // fetch has already completed, errored, or been canceled.
23
- cancelTokenPromise: Promise<number | BigInt | null> | null
24
- }
25
-
26
- /**
27
- * Manages attachment fetchers to make sure we free all resources when the
28
- * fetcher is garbage collected and to allow us to wait for freeing of
29
- * ressources to be finished before the ditto instance is closed.
30
- *
31
- * @internal
32
- */
33
- export class AttachmentFetcherManager {
34
- readonly ditto: Ditto
35
-
36
- /** @internal */
37
- constructor(ditto: Ditto) {
38
- this.ditto = ditto
39
- }
40
-
41
- /**
42
- * Start an attachment fetcher.
43
- *
44
- * @internal */
45
- startAttachmentFetcher(token: AttachmentToken, eventHandler?: (attachmentFetchEvent: AttachmentFetchEvent) => void): AttachmentFetcher {
46
- return this.ditto.deferClose(() => {
47
- const attachmentFetcher = new AttachmentFetcher(this.ditto, token, this, eventHandler)
48
-
49
- // Register in finalization registry.
50
- const contextInfo: AttachmentFetcherContextInfo = {
51
- id: attachmentFetcher.id,
52
- attachmentTokenID: token.idBytes,
53
- cancelTokenPromise: attachmentFetcher.cancelTokenPromise,
54
- attachmentFetcher: new WeakRef(attachmentFetcher),
55
- }
56
- this.finalizationRegistry.register(attachmentFetcher, contextInfo, attachmentFetcher)
57
-
58
- // Keep a reference to the context info so that we can stop the fetcher.
59
- this.contextInfoByID[attachmentFetcher.id] = contextInfo
60
-
61
- // Prevent cancellation of the fetch once it was fulfilled or rejected.
62
- const resetCancelToken = () => {
63
- if (this.contextInfoByID[attachmentFetcher.id] != null) {
64
- this.contextInfoByID[attachmentFetcher.id].cancelTokenPromise = null
65
- }
66
- }
67
- attachmentFetcher.attachment.then(
68
- (value) => {
69
- resetCancelToken()
70
- return value
71
- },
72
- (reason) => {
73
- resetCancelToken()
74
- return reason
75
- },
76
- )
77
-
78
- // Keep the attachment fetcher alive until it is stopped.
79
- this.ditto.keepAlive.retain(`AttachmentFetcher.${attachmentFetcher.id})`)
80
-
81
- return attachmentFetcher
82
- })
83
- }
84
-
85
- /**
86
- * Stop an attachment fetcher and wait for it to be stopped.
87
- *
88
- * @internal */
89
- async stopAttachmentFetcher(attachmentFetcher: AttachmentFetcher): Promise<void> {
90
- this.finalizationRegistry.unregister(attachmentFetcher)
91
- const contextInfo = this.contextInfoByID[attachmentFetcher.id]
92
- if (contextInfo == null) {
93
- throw new Error(`Internal inconsistency: cannot stop attachment fetcher ${attachmentFetcher.id}, which is not registered.`)
94
- }
95
- await this.stopWithContextInfo(contextInfo)
96
- }
97
-
98
- /**
99
- * Closing the manager will cancel all attachment fetchers.
100
- *
101
- * @internal
102
- */
103
- close() {
104
- void this.ditto.deferCloseAsync(async () => {
105
- const contextInfos = Object.values(this.contextInfoByID)
106
- const stopped = contextInfos.map(async (contextInfo) => {
107
- const attachmentFetcher = contextInfo.attachmentFetcher.deref()
108
- if (attachmentFetcher != null) {
109
- await this.stopAttachmentFetcher(attachmentFetcher)
110
- }
111
- })
112
- await Promise.all(stopped)
113
- })
114
- }
115
-
116
- // --- Private ---
117
-
118
- private contextInfoByID: { [attachmentFetcherID: string]: AttachmentFetcherContextInfo } = {}
119
-
120
- private finalizationRegistry: FinalizationRegistry<AttachmentFetcherContextInfo> = new FinalizationRegistry(this.stopWithContextInfo)
121
-
122
- /**
123
- * Stop the attachment fetcher without unregistering it from the finalization
124
- * registry.
125
- */
126
- private stopWithContextInfo(contextInfo: AttachmentFetcherContextInfo): Promise<void> {
127
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
128
- return this.ditto.deferCloseAsync(async () => {
129
- // Remove the manager's own record of the context info.
130
- if (this.contextInfoByID[contextInfo.id] == null) {
131
- throw new Error(`Internal inconsistency: attachment fetcher ${contextInfo.id} not found in active attachment fetchers.`)
132
- }
133
- delete this.contextInfoByID[contextInfo.id]
134
-
135
- // Release the keep-alive.
136
- this.ditto.keepAlive.release(`AttachmentFetcher.${contextInfo.id})`)
137
-
138
- // Cancel the fetcher if it is still running.
139
- const cancelToken = await contextInfo.cancelTokenPromise
140
- if (cancelToken) {
141
- FFI.dittoCancelResolveAttachment(dittoHandle.deref(), contextInfo.attachmentTokenID, cancelToken)
142
- }
143
- })
144
- }
145
- }