@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.
- package/DittoReactNative.podspec +25 -0
- package/README.md +2 -2
- package/node/ditto.cjs.js +1 -1
- package/node/ditto.cjs.js.map +1 -0
- package/node/ditto.cjs.pretty.js +9655 -0
- package/node/ditto.cjs.pretty.js.map +1 -0
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/{ditto.linux-arm64.node → ditto.linux-x64.node} +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +2 -1
- package/react-native/android/CMakeLists.txt +37 -0
- package/react-native/android/build.gradle +186 -0
- package/react-native/android/cpp-adapter.cpp +254 -0
- package/react-native/android/gradle.properties +5 -0
- package/react-native/android/src/main/AndroidManifest.xml +4 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
- package/react-native/cpp/include/Arc.hpp +141 -0
- package/react-native/cpp/include/Attachment.h +16 -0
- package/react-native/cpp/include/Authentication.h +23 -0
- package/react-native/cpp/include/Collection.h +13 -0
- package/react-native/cpp/include/DQL.h +21 -0
- package/react-native/cpp/include/Document.h +17 -0
- package/react-native/cpp/include/Identity.h +17 -0
- package/react-native/cpp/include/Lifecycle.h +17 -0
- package/react-native/cpp/include/LiveQuery.h +17 -0
- package/react-native/cpp/include/Logger.h +22 -0
- package/react-native/cpp/include/Misc.h +27 -0
- package/react-native/cpp/include/Presence.h +14 -0
- package/react-native/cpp/include/SmallPeerInfo.h +19 -0
- package/react-native/cpp/include/Transports.h +25 -0
- package/react-native/cpp/include/TypedArray.hpp +167 -0
- package/react-native/cpp/include/Utils.h +61 -0
- package/react-native/cpp/include/main.h +10 -0
- package/react-native/cpp/src/Attachment.cpp +86 -0
- package/react-native/cpp/src/Authentication.cpp +227 -0
- package/react-native/cpp/src/Collection.cpp +54 -0
- package/react-native/cpp/src/DQL.cpp +256 -0
- package/react-native/cpp/src/Document.cpp +146 -0
- package/react-native/cpp/src/Identity.cpp +123 -0
- package/react-native/cpp/src/Lifecycle.cpp +110 -0
- package/react-native/cpp/src/LiveQuery.cpp +63 -0
- package/react-native/cpp/src/Logger.cpp +200 -0
- package/react-native/cpp/src/Misc.cpp +283 -0
- package/react-native/cpp/src/Presence.cpp +79 -0
- package/react-native/cpp/src/SmallPeerInfo.cpp +142 -0
- package/react-native/cpp/src/Transports.cpp +270 -0
- package/react-native/cpp/src/TypedArray.cpp +303 -0
- package/react-native/cpp/src/Utils.cpp +138 -0
- package/react-native/cpp/src/main.cpp +152 -0
- package/react-native/dittoffi/dittoffi.h +4700 -0
- package/react-native/dittoffi/ifaddrs.cpp +385 -0
- package/react-native/dittoffi/ifaddrs.h +206 -0
- package/react-native/ios/DittoRNSDK.h +7 -0
- package/react-native/ios/DittoRNSDK.mm +107 -0
- package/react-native/ios/YeetJSIUtils.h +60 -0
- package/react-native/ios/YeetJSIUtils.mm +196 -0
- package/react-native/lib/commonjs/ditto.rn.js +92 -0
- package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
- package/react-native/lib/commonjs/index.js +61 -0
- package/react-native/lib/commonjs/index.js.map +1 -0
- package/react-native/lib/module/ditto.rn.js +88 -0
- package/react-native/lib/module/ditto.rn.js.map +1 -0
- package/react-native/lib/module/index.js +27 -0
- package/react-native/lib/module/index.js.map +1 -0
- package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
- package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
- package/react-native/lib/typescript/index.d.ts +1 -0
- package/react-native/lib/typescript/index.d.ts.map +1 -0
- package/react-native/src/ditto.rn.ts +91 -0
- package/react-native/src/environment/environment.fallback.ts +4 -0
- package/react-native/src/index.ts +26 -0
- package/react-native/src/sources/@cbor-redux.ts +2 -0
- package/react-native/src/sources/@ditto.core.ts +1 -0
- package/react-native/src/sources/@environment.ts +1 -0
- package/react-native/src/sources/attachment-fetch-event.ts +54 -0
- package/react-native/src/sources/attachment-fetcher-manager.ts +144 -0
- package/react-native/src/sources/attachment-fetcher.ts +134 -0
- package/react-native/src/sources/attachment-token.ts +48 -0
- package/react-native/src/sources/attachment.ts +74 -0
- package/react-native/src/sources/augment.ts +101 -0
- package/react-native/src/sources/authenticator.ts +314 -0
- package/react-native/src/sources/base-pending-cursor-operation.ts +239 -0
- package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
- package/react-native/src/sources/bridge.ts +553 -0
- package/react-native/src/sources/build-time-constants.ts +8 -0
- package/react-native/src/sources/cbor.ts +35 -0
- package/react-native/src/sources/collection-interface.ts +67 -0
- package/react-native/src/sources/collection.ts +212 -0
- package/react-native/src/sources/collections-event.ts +99 -0
- package/react-native/src/sources/counter.ts +82 -0
- package/react-native/src/sources/ditto.ts +979 -0
- package/react-native/src/sources/document-id.ts +159 -0
- package/react-native/src/sources/document-path.ts +306 -0
- package/react-native/src/sources/document.ts +193 -0
- package/react-native/src/sources/epilogue.ts +30 -0
- package/react-native/src/sources/error-codes.ts +52 -0
- package/react-native/src/sources/error.ts +208 -0
- package/react-native/src/sources/essentials.ts +53 -0
- package/react-native/src/sources/ffi-error.ts +122 -0
- package/react-native/src/sources/ffi.ts +2012 -0
- package/react-native/src/sources/identity.ts +163 -0
- package/react-native/src/sources/init.ts +71 -0
- package/react-native/src/sources/internal.ts +109 -0
- package/react-native/src/sources/keep-alive.ts +73 -0
- package/react-native/src/sources/key-path.ts +198 -0
- package/react-native/src/sources/live-query-event.ts +208 -0
- package/react-native/src/sources/live-query-manager.ts +102 -0
- package/react-native/src/sources/live-query.ts +166 -0
- package/react-native/src/sources/logger.ts +196 -0
- package/react-native/src/sources/main.ts +60 -0
- package/react-native/src/sources/observer-manager.ts +178 -0
- package/react-native/src/sources/observer.ts +79 -0
- package/react-native/src/sources/pending-collections-operation.ts +232 -0
- package/react-native/src/sources/pending-cursor-operation.ts +218 -0
- package/react-native/src/sources/pending-id-specific-operation.ts +218 -0
- package/react-native/src/sources/presence-manager.ts +161 -0
- package/react-native/src/sources/presence.ts +233 -0
- package/react-native/src/sources/query-result-item.ts +116 -0
- package/react-native/src/sources/query-result.ts +55 -0
- package/react-native/src/sources/register.ts +95 -0
- package/react-native/src/sources/small-peer-info.ts +177 -0
- package/react-native/src/sources/static-tcp-client.ts +6 -0
- package/react-native/src/sources/store-observer.ts +177 -0
- package/react-native/src/sources/store.ts +385 -0
- package/react-native/src/sources/subscription-manager.ts +99 -0
- package/react-native/src/sources/subscription.ts +89 -0
- package/react-native/src/sources/sync-subscription.ts +90 -0
- package/react-native/src/sources/sync.ts +559 -0
- package/react-native/src/sources/test-helpers.ts +24 -0
- package/react-native/src/sources/transport-conditions-manager.ts +104 -0
- package/react-native/src/sources/transport-config.ts +430 -0
- package/react-native/src/sources/update-result.ts +66 -0
- package/react-native/src/sources/update-results-map.ts +57 -0
- package/react-native/src/sources/websocket-client.ts +7 -0
- package/react-native/src/sources/write-transaction-collection.ts +122 -0
- package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
- package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +74 -0
- package/react-native/src/sources/write-transaction.ts +121 -0
- package/react-native.config.js +9 -0
- package/types/ditto.d.ts.map +1 -0
- package/web/ditto.es6.js +1 -1
- package/web/ditto.es6.js.map +1 -0
- package/web/ditto.es6.pretty.js +12600 -0
- package/web/ditto.es6.pretty.js.map +1 -0
- package/web/ditto.umd.js +1 -1
- package/web/ditto.umd.js.map +1 -0
- package/web/ditto.umd.pretty.js +12669 -0
- package/web/ditto.umd.pretty.js.map +1 -0
- 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
|
+
}
|