@dittolive/ditto 4.5.1-experimental.aarch64-linux.1.aarch64 → 4.5.2-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 (152) hide show
  1. package/DittoReactNative.podspec +25 -0
  2. package/README.md +2 -2
  3. package/node/ditto.cjs.js +1 -1
  4. package/node/ditto.cjs.js.map +1 -0
  5. package/node/ditto.cjs.pretty.js +9655 -0
  6. package/node/ditto.cjs.pretty.js.map +1 -0
  7. package/node/ditto.darwin-arm64.node +0 -0
  8. package/node/ditto.darwin-x64.node +0 -0
  9. package/node/{ditto.linux-arm64.node → ditto.linux-x64.node} +0 -0
  10. package/node/transports.darwin-arm64.node +0 -0
  11. package/node/transports.darwin-x64.node +0 -0
  12. package/package.json +2 -1
  13. package/react-native/android/CMakeLists.txt +37 -0
  14. package/react-native/android/build.gradle +186 -0
  15. package/react-native/android/cpp-adapter.cpp +254 -0
  16. package/react-native/android/gradle.properties +5 -0
  17. package/react-native/android/src/main/AndroidManifest.xml +4 -0
  18. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
  19. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
  20. package/react-native/cpp/include/Arc.hpp +141 -0
  21. package/react-native/cpp/include/Attachment.h +16 -0
  22. package/react-native/cpp/include/Authentication.h +23 -0
  23. package/react-native/cpp/include/Collection.h +13 -0
  24. package/react-native/cpp/include/DQL.h +21 -0
  25. package/react-native/cpp/include/Document.h +17 -0
  26. package/react-native/cpp/include/Identity.h +17 -0
  27. package/react-native/cpp/include/Lifecycle.h +17 -0
  28. package/react-native/cpp/include/LiveQuery.h +17 -0
  29. package/react-native/cpp/include/Logger.h +22 -0
  30. package/react-native/cpp/include/Misc.h +27 -0
  31. package/react-native/cpp/include/Presence.h +14 -0
  32. package/react-native/cpp/include/SmallPeerInfo.h +19 -0
  33. package/react-native/cpp/include/Transports.h +25 -0
  34. package/react-native/cpp/include/TypedArray.hpp +167 -0
  35. package/react-native/cpp/include/Utils.h +61 -0
  36. package/react-native/cpp/include/main.h +10 -0
  37. package/react-native/cpp/src/Attachment.cpp +86 -0
  38. package/react-native/cpp/src/Authentication.cpp +227 -0
  39. package/react-native/cpp/src/Collection.cpp +54 -0
  40. package/react-native/cpp/src/DQL.cpp +256 -0
  41. package/react-native/cpp/src/Document.cpp +146 -0
  42. package/react-native/cpp/src/Identity.cpp +123 -0
  43. package/react-native/cpp/src/Lifecycle.cpp +110 -0
  44. package/react-native/cpp/src/LiveQuery.cpp +63 -0
  45. package/react-native/cpp/src/Logger.cpp +200 -0
  46. package/react-native/cpp/src/Misc.cpp +283 -0
  47. package/react-native/cpp/src/Presence.cpp +79 -0
  48. package/react-native/cpp/src/SmallPeerInfo.cpp +142 -0
  49. package/react-native/cpp/src/Transports.cpp +270 -0
  50. package/react-native/cpp/src/TypedArray.cpp +303 -0
  51. package/react-native/cpp/src/Utils.cpp +138 -0
  52. package/react-native/cpp/src/main.cpp +152 -0
  53. package/react-native/dittoffi/dittoffi.h +4700 -0
  54. package/react-native/dittoffi/ifaddrs.cpp +385 -0
  55. package/react-native/dittoffi/ifaddrs.h +206 -0
  56. package/react-native/ios/DittoRNSDK.h +7 -0
  57. package/react-native/ios/DittoRNSDK.mm +107 -0
  58. package/react-native/ios/YeetJSIUtils.h +60 -0
  59. package/react-native/ios/YeetJSIUtils.mm +196 -0
  60. package/react-native/lib/commonjs/ditto.rn.js +92 -0
  61. package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
  62. package/react-native/lib/commonjs/index.js +61 -0
  63. package/react-native/lib/commonjs/index.js.map +1 -0
  64. package/react-native/lib/module/ditto.rn.js +88 -0
  65. package/react-native/lib/module/ditto.rn.js.map +1 -0
  66. package/react-native/lib/module/index.js +27 -0
  67. package/react-native/lib/module/index.js.map +1 -0
  68. package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
  69. package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
  70. package/react-native/lib/typescript/index.d.ts +1 -0
  71. package/react-native/lib/typescript/index.d.ts.map +1 -0
  72. package/react-native/src/ditto.rn.ts +91 -0
  73. package/react-native/src/environment/environment.fallback.ts +4 -0
  74. package/react-native/src/index.ts +26 -0
  75. package/react-native/src/sources/@cbor-redux.ts +2 -0
  76. package/react-native/src/sources/@ditto.core.ts +1 -0
  77. package/react-native/src/sources/@environment.ts +1 -0
  78. package/react-native/src/sources/attachment-fetch-event.ts +54 -0
  79. package/react-native/src/sources/attachment-fetcher-manager.ts +144 -0
  80. package/react-native/src/sources/attachment-fetcher.ts +134 -0
  81. package/react-native/src/sources/attachment-token.ts +48 -0
  82. package/react-native/src/sources/attachment.ts +74 -0
  83. package/react-native/src/sources/augment.ts +101 -0
  84. package/react-native/src/sources/authenticator.ts +314 -0
  85. package/react-native/src/sources/base-pending-cursor-operation.ts +239 -0
  86. package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
  87. package/react-native/src/sources/bridge.ts +553 -0
  88. package/react-native/src/sources/build-time-constants.ts +8 -0
  89. package/react-native/src/sources/cbor.ts +35 -0
  90. package/react-native/src/sources/collection-interface.ts +67 -0
  91. package/react-native/src/sources/collection.ts +212 -0
  92. package/react-native/src/sources/collections-event.ts +99 -0
  93. package/react-native/src/sources/counter.ts +82 -0
  94. package/react-native/src/sources/ditto.ts +979 -0
  95. package/react-native/src/sources/document-id.ts +159 -0
  96. package/react-native/src/sources/document-path.ts +306 -0
  97. package/react-native/src/sources/document.ts +193 -0
  98. package/react-native/src/sources/epilogue.ts +30 -0
  99. package/react-native/src/sources/error-codes.ts +52 -0
  100. package/react-native/src/sources/error.ts +208 -0
  101. package/react-native/src/sources/essentials.ts +53 -0
  102. package/react-native/src/sources/ffi-error.ts +122 -0
  103. package/react-native/src/sources/ffi.ts +2012 -0
  104. package/react-native/src/sources/identity.ts +163 -0
  105. package/react-native/src/sources/init.ts +71 -0
  106. package/react-native/src/sources/internal.ts +109 -0
  107. package/react-native/src/sources/keep-alive.ts +73 -0
  108. package/react-native/src/sources/key-path.ts +198 -0
  109. package/react-native/src/sources/live-query-event.ts +208 -0
  110. package/react-native/src/sources/live-query-manager.ts +102 -0
  111. package/react-native/src/sources/live-query.ts +166 -0
  112. package/react-native/src/sources/logger.ts +196 -0
  113. package/react-native/src/sources/main.ts +60 -0
  114. package/react-native/src/sources/observer-manager.ts +178 -0
  115. package/react-native/src/sources/observer.ts +79 -0
  116. package/react-native/src/sources/pending-collections-operation.ts +232 -0
  117. package/react-native/src/sources/pending-cursor-operation.ts +218 -0
  118. package/react-native/src/sources/pending-id-specific-operation.ts +218 -0
  119. package/react-native/src/sources/presence-manager.ts +161 -0
  120. package/react-native/src/sources/presence.ts +233 -0
  121. package/react-native/src/sources/query-result-item.ts +116 -0
  122. package/react-native/src/sources/query-result.ts +55 -0
  123. package/react-native/src/sources/register.ts +95 -0
  124. package/react-native/src/sources/small-peer-info.ts +177 -0
  125. package/react-native/src/sources/static-tcp-client.ts +6 -0
  126. package/react-native/src/sources/store-observer.ts +177 -0
  127. package/react-native/src/sources/store.ts +385 -0
  128. package/react-native/src/sources/subscription-manager.ts +99 -0
  129. package/react-native/src/sources/subscription.ts +89 -0
  130. package/react-native/src/sources/sync-subscription.ts +90 -0
  131. package/react-native/src/sources/sync.ts +559 -0
  132. package/react-native/src/sources/test-helpers.ts +24 -0
  133. package/react-native/src/sources/transport-conditions-manager.ts +104 -0
  134. package/react-native/src/sources/transport-config.ts +430 -0
  135. package/react-native/src/sources/update-result.ts +66 -0
  136. package/react-native/src/sources/update-results-map.ts +57 -0
  137. package/react-native/src/sources/websocket-client.ts +7 -0
  138. package/react-native/src/sources/write-transaction-collection.ts +122 -0
  139. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
  140. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +74 -0
  141. package/react-native/src/sources/write-transaction.ts +121 -0
  142. package/react-native.config.js +9 -0
  143. package/types/ditto.d.ts.map +1 -0
  144. package/web/ditto.es6.js +1 -1
  145. package/web/ditto.es6.js.map +1 -0
  146. package/web/ditto.es6.pretty.js +12600 -0
  147. package/web/ditto.es6.pretty.js.map +1 -0
  148. package/web/ditto.umd.js +1 -1
  149. package/web/ditto.umd.js.map +1 -0
  150. package/web/ditto.umd.pretty.js +12669 -0
  151. package/web/ditto.umd.pretty.js.map +1 -0
  152. package/web/ditto.wasm +0 -0
@@ -0,0 +1,89 @@
1
+ //
2
+ // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3
+ //
4
+
5
+ import * as FFI from './ffi'
6
+ import { generateEphemeralToken } from './internal'
7
+
8
+ import type { Collection } from './collection'
9
+ import type { SubscriptionManager, SubscriptionContextInfo } from './subscription-manager'
10
+
11
+ /**
12
+ * Used to subscribe to receive updates from remote peers about matching
13
+ * documents.
14
+ *
15
+ * While {@link Subscription} objects remain in scope they ensure that
16
+ * documents in the collection specified and that match the query provided will
17
+ * try to be kept up-to-date with the latest changes from remote peers.
18
+ */
19
+ export class Subscription {
20
+ /**
21
+ * The query that the subscription is based on.
22
+ */
23
+ readonly query: string
24
+
25
+ /**
26
+ * Returns `true` if subscription has been explicitly cancelled, `false`
27
+ * otherwise.
28
+ */
29
+ get isCancelled(): boolean {
30
+ return this._isCancelled
31
+ }
32
+
33
+ /**
34
+ * The name of the collection that the subscription is based on.
35
+ */
36
+ get collectionName() {
37
+ return this.collection.name
38
+ }
39
+
40
+ /**
41
+ * Cancels a subscription and releases all associated resources.
42
+ */
43
+ cancel() {
44
+ if (!this.isCancelled) {
45
+ this._isCancelled = true
46
+ this.manager.remove(this)
47
+ }
48
+ }
49
+
50
+ // ----------------------------------------------------------- Internal ------
51
+
52
+ /** @internal */
53
+ constructor(collection: Collection, query: string, queryArgsCBOR: Uint8Array | null, orderBys: FFI.OrderBy[], limit: number, offset: number) {
54
+ // Query should be validated at this point.
55
+ this.query = query
56
+ this.queryArgsCBOR = queryArgsCBOR
57
+ this.collection = collection
58
+ this.contextInfo = {
59
+ id: generateEphemeralToken(),
60
+ collectionName: collection.name,
61
+ query,
62
+ queryArgsCBOR,
63
+ orderBys,
64
+ limit,
65
+ offset,
66
+ }
67
+ this.manager = collection.store.ditto.subscriptionManager
68
+ this.manager.add(this)
69
+ }
70
+
71
+ /**
72
+ * The collection this subscription belongs to.
73
+ * @internal Because not exposed in any of the other SDKs (yet?).
74
+ */
75
+ readonly collection: Collection
76
+
77
+ /**
78
+ * The corresponding named arguments for {@link query}, if any.
79
+ * @internal Because not exposed in any of the other SDKs (yet?).
80
+ */
81
+ readonly queryArgsCBOR: Uint8Array | null
82
+
83
+ /** @internal */
84
+ readonly contextInfo: SubscriptionContextInfo
85
+
86
+ private readonly manager: SubscriptionManager
87
+
88
+ private _isCancelled = false
89
+ }
@@ -0,0 +1,90 @@
1
+ //
2
+ // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
+ //
4
+
5
+ import { DittoError } from './error'
6
+
7
+ import type { DQLQueryArguments } from './essentials'
8
+ import type { Ditto } from './ditto'
9
+ import type { Sync } from './sync'
10
+
11
+ /**
12
+ * A sync subscription configures Ditto to receive updates from remote peers
13
+ * about documents matching the subscription's query.
14
+ *
15
+ * The sync subscription will remain active until it is
16
+ * {@link SyncSubscription.cancel | cancelled}, or the Ditto instance managing
17
+ * the subscription has been {@link Ditto.close | closed}.
18
+ *
19
+ * Create a sync subscription by calling
20
+ * {@link Sync.registerSubscription | `ditto.sync.registerSubscription()`}.
21
+ */
22
+ export class SyncSubscription {
23
+ /**
24
+ * Documents matching this query will be included in the sync subscription.
25
+ */
26
+ readonly queryString: string
27
+
28
+ /**
29
+ * The query arguments of the sync subscription (as passed when
30
+ * adding it to the store).
31
+ */
32
+ readonly queryArguments?: Readonly<DQLQueryArguments>
33
+
34
+ /**
35
+ * The {@link Ditto} instance this sync subscription belongs to.
36
+ */
37
+ readonly ditto: Ditto
38
+
39
+ /**
40
+ * `true` when the sync subscription has been cancelled or the {@link Ditto}
41
+ * instance managing this subscription has been closed.
42
+ */
43
+ get isCancelled() {
44
+ return this._isCancelled
45
+ }
46
+
47
+ /**
48
+ * Cancels the sync subscription and unregisters it. No-op
49
+ * if the sync subscription has already been cancelled or the {@link Ditto}
50
+ * instance managing this subscription has been closed.
51
+ */
52
+ cancel() {
53
+ if (this._isCancelled) return
54
+ this._isCancelled = true
55
+ this.ditto.sync.unregisterSubscription(this)
56
+ }
57
+
58
+ // --------------------------- Internal --------------------------------------
59
+
60
+ /** @internal */
61
+ constructor(ditto: Ditto, query: string, queryArguments: DQLQueryArguments | null, queryArgumentsCBOR: Uint8Array | null) {
62
+ if ((queryArguments == null) !== (queryArgumentsCBOR == null)) {
63
+ throw new DittoError('internal', 'Internal inconsistency, query arguments and query arguments CBOR must be both null or both non-null', { queryArguments, queryArgumentsCBOR })
64
+ }
65
+
66
+ this.ditto = ditto
67
+ this.queryString = query
68
+ this.queryArguments = queryArguments ? Object.freeze({ ...queryArguments }) : undefined
69
+ this.queryArgumentsCBOR = queryArgumentsCBOR
70
+ }
71
+
72
+ /**
73
+ * The CBOR-encoded query arguments, or `null` if no query arguments were
74
+ * passed in.
75
+ *
76
+ * @internal
77
+ */
78
+ readonly queryArgumentsCBOR: Uint8Array | null
79
+
80
+ // --------------------------- Private --------------------------------------
81
+
82
+ /**
83
+ * `true` when the ssync ubscription has been cancelled.
84
+ *
85
+ * We mark the sync subscription as cancelled here as an optimization to avoid
86
+ * a scan of all subscriptions in the store whenever the `isCancelled`
87
+ * property is checked.
88
+ */
89
+ private _isCancelled = false
90
+ }