@dittolive/ditto 4.7.3 → 4.7.4-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/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 +10 -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/CMakeLists.txt +0 -36
  17. package/react-native/android/build.gradle +0 -190
  18. package/react-native/android/cpp-adapter.cpp +0 -259
  19. package/react-native/android/gradle.properties +0 -5
  20. package/react-native/android/src/main/AndroidManifest.xml +0 -4
  21. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +0 -120
  22. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +0 -28
  23. package/react-native/cpp/include/Arc.hpp +0 -159
  24. package/react-native/cpp/include/Attachment.h +0 -20
  25. package/react-native/cpp/include/Authentication.h +0 -23
  26. package/react-native/cpp/include/Collection.h +0 -13
  27. package/react-native/cpp/include/ConnectionRequest.h +0 -18
  28. package/react-native/cpp/include/DQL.h +0 -21
  29. package/react-native/cpp/include/Document.h +0 -17
  30. package/react-native/cpp/include/FFIUtils.h +0 -16
  31. package/react-native/cpp/include/IO.h +0 -13
  32. package/react-native/cpp/include/Identity.h +0 -17
  33. package/react-native/cpp/include/Lifecycle.h +0 -16
  34. package/react-native/cpp/include/LiveQuery.h +0 -17
  35. package/react-native/cpp/include/Logger.h +0 -22
  36. package/react-native/cpp/include/Misc.h +0 -30
  37. package/react-native/cpp/include/Presence.h +0 -18
  38. package/react-native/cpp/include/SmallPeerInfo.h +0 -19
  39. package/react-native/cpp/include/Transports.h +0 -25
  40. package/react-native/cpp/include/TypedArray.hpp +0 -167
  41. package/react-native/cpp/include/Utils.h +0 -70
  42. package/react-native/cpp/include/main.h +0 -10
  43. package/react-native/cpp/src/Attachment.cpp +0 -272
  44. package/react-native/cpp/src/Authentication.cpp +0 -227
  45. package/react-native/cpp/src/Collection.cpp +0 -56
  46. package/react-native/cpp/src/ConnectionRequest.cpp +0 -123
  47. package/react-native/cpp/src/DQL.cpp +0 -256
  48. package/react-native/cpp/src/Document.cpp +0 -146
  49. package/react-native/cpp/src/FFIUtils.cpp +0 -122
  50. package/react-native/cpp/src/IO.cpp +0 -35
  51. package/react-native/cpp/src/Identity.cpp +0 -122
  52. package/react-native/cpp/src/Lifecycle.cpp +0 -93
  53. package/react-native/cpp/src/LiveQuery.cpp +0 -63
  54. package/react-native/cpp/src/Logger.cpp +0 -199
  55. package/react-native/cpp/src/Misc.cpp +0 -322
  56. package/react-native/cpp/src/Presence.cpp +0 -166
  57. package/react-native/cpp/src/SmallPeerInfo.cpp +0 -142
  58. package/react-native/cpp/src/Transports.cpp +0 -275
  59. package/react-native/cpp/src/TypedArray.cpp +0 -303
  60. package/react-native/cpp/src/Utils.cpp +0 -139
  61. package/react-native/cpp/src/main.cpp +0 -178
  62. package/react-native/dittoffi/dittoffi.h +0 -4873
  63. package/react-native/dittoffi/ifaddrs.cpp +0 -385
  64. package/react-native/dittoffi/ifaddrs.h +0 -206
  65. package/react-native/ios/DittoRNSDK.h +0 -7
  66. package/react-native/ios/DittoRNSDK.mm +0 -159
  67. package/react-native/ios/YeetJSIUtils.h +0 -60
  68. package/react-native/ios/YeetJSIUtils.mm +0 -196
  69. package/react-native/lib/commonjs/ditto.rn.js +0 -93
  70. package/react-native/lib/commonjs/ditto.rn.js.map +0 -1
  71. package/react-native/lib/commonjs/index.js +0 -61
  72. package/react-native/lib/commonjs/index.js.map +0 -1
  73. package/react-native/lib/module/ditto.rn.js +0 -89
  74. package/react-native/lib/module/ditto.rn.js.map +0 -1
  75. package/react-native/lib/module/index.js +0 -27
  76. package/react-native/lib/module/index.js.map +0 -1
  77. package/react-native/lib/typescript/ditto.rn.d.ts +0 -15
  78. package/react-native/lib/typescript/ditto.rn.d.ts.map +0 -1
  79. package/react-native/lib/typescript/index.d.ts +0 -1
  80. package/react-native/lib/typescript/index.d.ts.map +0 -1
  81. package/react-native/src/ditto.rn.ts +0 -123
  82. package/react-native/src/environment/environment.fallback.ts +0 -4
  83. package/react-native/src/index.ts +0 -29
  84. package/react-native/src/sources/@cbor-redux.ts +0 -2
  85. package/react-native/src/sources/@ditto.core.ts +0 -1
  86. package/react-native/src/sources/@environment.ts +0 -1
  87. package/react-native/src/sources/attachment-fetch-event.ts +0 -54
  88. package/react-native/src/sources/attachment-fetcher-manager.ts +0 -145
  89. package/react-native/src/sources/attachment-fetcher.ts +0 -265
  90. package/react-native/src/sources/attachment-token.ts +0 -129
  91. package/react-native/src/sources/attachment.ts +0 -121
  92. package/react-native/src/sources/augment.ts +0 -108
  93. package/react-native/src/sources/authenticator.ts +0 -314
  94. package/react-native/src/sources/base-pending-cursor-operation.ts +0 -255
  95. package/react-native/src/sources/base-pending-id-specific-operation.ts +0 -112
  96. package/react-native/src/sources/bridge.ts +0 -557
  97. package/react-native/src/sources/build-time-constants.ts +0 -8
  98. package/react-native/src/sources/cbor.ts +0 -20
  99. package/react-native/src/sources/collection-interface.ts +0 -73
  100. package/react-native/src/sources/collection.ts +0 -219
  101. package/react-native/src/sources/collections-event.ts +0 -99
  102. package/react-native/src/sources/connection-request.ts +0 -142
  103. package/react-native/src/sources/counter.ts +0 -82
  104. package/react-native/src/sources/ditto.ts +0 -991
  105. package/react-native/src/sources/document-id.ts +0 -163
  106. package/react-native/src/sources/document-path.ts +0 -308
  107. package/react-native/src/sources/document.ts +0 -237
  108. package/react-native/src/sources/epilogue.ts +0 -32
  109. package/react-native/src/sources/error-codes.ts +0 -114
  110. package/react-native/src/sources/error.ts +0 -256
  111. package/react-native/src/sources/essentials.ts +0 -81
  112. package/react-native/src/sources/ffi-error.ts +0 -134
  113. package/react-native/src/sources/ffi.ts +0 -2190
  114. package/react-native/src/sources/identity.ts +0 -163
  115. package/react-native/src/sources/init.ts +0 -71
  116. package/react-native/src/sources/internal.ts +0 -143
  117. package/react-native/src/sources/keep-alive.ts +0 -73
  118. package/react-native/src/sources/key-path.ts +0 -198
  119. package/react-native/src/sources/live-query-event.ts +0 -208
  120. package/react-native/src/sources/live-query-manager.ts +0 -110
  121. package/react-native/src/sources/live-query.ts +0 -167
  122. package/react-native/src/sources/logger.ts +0 -196
  123. package/react-native/src/sources/main.ts +0 -61
  124. package/react-native/src/sources/observer-manager.ts +0 -185
  125. package/react-native/src/sources/observer.ts +0 -79
  126. package/react-native/src/sources/pending-collections-operation.ts +0 -241
  127. package/react-native/src/sources/pending-cursor-operation.ts +0 -218
  128. package/react-native/src/sources/pending-id-specific-operation.ts +0 -218
  129. package/react-native/src/sources/presence-manager.ts +0 -170
  130. package/react-native/src/sources/presence.ts +0 -427
  131. package/react-native/src/sources/query-result-item.ts +0 -131
  132. package/react-native/src/sources/query-result.ts +0 -55
  133. package/react-native/src/sources/register.ts +0 -95
  134. package/react-native/src/sources/small-peer-info.ts +0 -166
  135. package/react-native/src/sources/static-tcp-client.ts +0 -8
  136. package/react-native/src/sources/store-observer.ts +0 -170
  137. package/react-native/src/sources/store.ts +0 -630
  138. package/react-native/src/sources/subscription-manager.ts +0 -99
  139. package/react-native/src/sources/subscription.ts +0 -89
  140. package/react-native/src/sources/sync-subscription.ts +0 -90
  141. package/react-native/src/sources/sync.ts +0 -561
  142. package/react-native/src/sources/test-helpers.ts +0 -24
  143. package/react-native/src/sources/transport-conditions-manager.ts +0 -104
  144. package/react-native/src/sources/transport-config.ts +0 -430
  145. package/react-native/src/sources/update-result.ts +0 -66
  146. package/react-native/src/sources/update-results-map.ts +0 -65
  147. package/react-native/src/sources/websocket-client.ts +0 -7
  148. package/react-native/src/sources/write-transaction-collection.ts +0 -122
  149. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +0 -101
  150. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +0 -74
  151. package/react-native/src/sources/write-transaction.ts +0 -121
  152. package/react-native.config.js +0 -9
@@ -1,166 +0,0 @@
1
- //
2
- // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
- import { Bridge } from './bridge'
7
-
8
- import type { Ditto } from './ditto'
9
-
10
- /**
11
- * Specifies which peers to replicate the small peer info to when enabled.
12
- *
13
- * Possible values are:
14
- *
15
- * - `LocalPeerOnly`: no replication (default)
16
- * - `BigPeerOnly`: replicate to the Big Peer
17
- */
18
- export type SmallPeerInfoSyncScope = 'LocalPeerOnly' | 'BigPeerOnly'
19
-
20
- /**
21
- * The entrypoint for small peer user info collection. Small peer info consists
22
- * of information gathered into a system collection on a regular interval and
23
- * optionally synced to the Big Peer for device dashboard and debugging
24
- * purposes.
25
- *
26
- * An instance of this class is available on each `Ditto` instance via its
27
- * {@link Ditto.smallPeerInfo | `smallPeerInfo`} property. Instantiating this
28
- * class directly is not supported.
29
- */
30
- export class SmallPeerInfo {
31
- /**
32
- * Indicates whether small peer info collection is currently enabled, defaults
33
- * to `false`.
34
- *
35
- * **Note**: whether the background ingestion process is enabled or not is a
36
- * separate decision to whether this information is allowed to sync to other
37
- * peers (including the big peer). This is controlled by
38
- * {@link getSyncScope | getSyncScope()} and
39
- * {@link setSyncScope | setSyncScope()}.
40
- */
41
- get isEnabled(): boolean {
42
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
43
- return this.ditto.deferClose(() => {
44
- return FFI.dittoSmallPeerInfoGetIsEnabled(dittoHandle.deref())
45
- })
46
- }
47
-
48
- /**
49
- * Set whether small peer info collection is enabled.
50
- *
51
- * @throws when set to a non-boolean value.
52
- */
53
- set isEnabled(newValue: boolean) {
54
- if (typeof newValue !== 'boolean') {
55
- throw new TypeError(`Expected boolean, got ${typeof newValue}`)
56
- }
57
-
58
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
59
- void this.ditto.deferCloseAsync(async () => {
60
- return FFI.dittoSmallPeerInfoSetEnabled(dittoHandle.deref(), newValue)
61
- })
62
- }
63
-
64
- /**
65
- * The metadata associated with the small peer info.
66
- *
67
- * Small peer info metadata is a free-form, user-provided JSON object that
68
- * is inserted into the small peer info system document at each collection
69
- * interval.
70
- */
71
- get metadata(): Record<string, any> {
72
- return JSON.parse(this.metadataJSONString)
73
- }
74
-
75
- /**
76
- * Set the metadata associated with the small peer info.
77
- *
78
- * The metadata must be a JSON-serializable object that conforms to the
79
- * following constraints:
80
- *
81
- * - Must be a JSON object (not an array, string, number, etc.)
82
- * - The size when encoded as JSON must be less than 128 KB
83
- * - May only be nested up to 64 levels deep
84
- *
85
- * @example <caption>Valid metadata</caption>
86
- * ditto.smallPeerInfo.metadata = {
87
- * "foo": "bar",
88
- * "nested": {
89
- * "inner": "value"
90
- * }
91
- * }
92
- *
93
- * @throws when set to a value that violates any of the constraints listed
94
- * above.
95
- */
96
- set metadata(metadata: Record<string, any>) {
97
- this.metadataJSONString = JSON.stringify(metadata)
98
- }
99
-
100
- /**
101
- * The metadata associated with the small peer info, as a JSON string.
102
- */
103
- get metadataJSONString(): string {
104
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
105
- return this.ditto.deferClose(() => {
106
- return FFI.dittoSmallPeerInfoGetMetadata(dittoHandle.deref())
107
- })
108
- }
109
-
110
- /**
111
- * Set the metadata associated with the small peer info, as a JSON string.
112
- *
113
- * @see {@link SmallPeerInfo.metadata | `metadata`} for more information on
114
- * valid values.
115
- * @throws when set to a value that violates any of the constraints listed in
116
- * {@link SmallPeerInfo.metadata | `metadata`}.
117
- */
118
- set metadataJSONString(metadata: string) {
119
- if (typeof metadata !== 'string') {
120
- throw new TypeError(`Expected string, got ${typeof metadata}`)
121
- }
122
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
123
- this.ditto.deferClose(() => {
124
- // throws if any validation errors occur
125
- FFI.dittoSmallPeerInfoSetMetadata(dittoHandle.deref(), metadata)
126
- })
127
- }
128
-
129
- /**
130
- * Determines which "kind" of peers the small peer info will be
131
- * replicated to.
132
- *
133
- * Defaults to `LocalPeerOnly`, which means no replication. Set this to
134
- * `BigPeerOnly` to replicate collected info to the Big Peer.
135
- */
136
- async getSyncScope(): Promise<SmallPeerInfoSyncScope> {
137
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
138
- return this.ditto.deferCloseAsync(async () => {
139
- return FFI.dittoSmallPeerInfoGetSyncScope(dittoHandle.deref())
140
- })
141
- }
142
-
143
- /**
144
- * Set the sync scope.
145
- *
146
- * See {@link getSyncScope} for more information.
147
- *
148
- * @param syncScope the new sync scope.
149
- * @throws when set to a value other than `BigPeerOnly` or `LocalPeerOnly`.
150
- */
151
- async setSyncScope(syncScope: SmallPeerInfoSyncScope): Promise<void> {
152
- const dittoHandle = Bridge.ditto.handleFor(this.ditto)
153
- return this.ditto.deferCloseAsync(async () => {
154
- return FFI.dittoSmallPeerInfoSetSyncScope(dittoHandle.deref(), syncScope as any)
155
- })
156
- }
157
-
158
- // ----------------------------------------------------------- Internal ------
159
-
160
- private ditto: Ditto
161
-
162
- /** @internal */
163
- constructor(ditto: Ditto) {
164
- this.ditto = ditto
165
- }
166
- }
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- // HACK: don't export these publicly, only needed internally.
6
-
7
- /** @internal */
8
- export class StaticTCPClient {}
@@ -1,170 +0,0 @@
1
- //
2
- // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
-
7
- import { desugarJSObject } from './augment'
8
- import { Bridge } from './bridge'
9
- import { CBOR } from './cbor'
10
- import { DittoError, mapFFIErrors } from './error'
11
- import { Logger } from './logger'
12
- import { QueryResult } from './query-result'
13
-
14
- import type { Ditto } from './ditto'
15
- import type { DQLQueryArguments } from './essentials'
16
- import type { Store } from './store'
17
-
18
- /**
19
- * A store observation handler is called whenever an active store observer
20
- * receives new results.
21
- */
22
- export type StoreObservationHandler = (queryResult: QueryResult) => void
23
-
24
- /**
25
- * A store observation handler is called whenever an active store observer
26
- * receives new results.
27
- *
28
- * Call `signalNext()` to signal that the handler is ready to receive the next
29
- * callback from the store observer.
30
- */
31
- export type StoreObservationHandlerWithSignalNext = (queryResult: QueryResult, signalNext: () => void) => void
32
-
33
- /**
34
- * A store observer invokes a given handler whenever results for its query
35
- * change.
36
- *
37
- * The store observer will remain active until it is {@link cancel | cancelled},
38
- * or the Ditto instance managing the observer has been
39
- * {@link Ditto.close | closed}.
40
- *
41
- * Create a store observer by calling
42
- * {@link Store.registerObserver | `ditto.store.registerObserver()`}.
43
- */
44
- export class StoreObserver {
45
- /**
46
- * The Ditto instance this store observer is registered with.
47
- */
48
- readonly ditto: Ditto
49
-
50
- /**
51
- * The query string of the store observer (as passed when registering it).
52
- */
53
- readonly queryString: string
54
-
55
- /**
56
- * The query arguments of the store observer (as passed when registering it).
57
- */
58
- readonly queryArguments?: Readonly<DQLQueryArguments>
59
-
60
- /**
61
- * Convenience property, returns `true` once the store observer has been
62
- * cancelled.
63
- */
64
- get isCancelled(): boolean {
65
- return this._isCancelled
66
- }
67
-
68
- /**
69
- * Cancels the store observer and unregisters it. No-op if the
70
- * store observer has already been cancelled.
71
- */
72
- cancel() {
73
- if (this._isCancelled) return
74
- this._isCancelled = true
75
- this.ditto.store.unregisterObserver(this)
76
- }
77
-
78
- // --------------------------- Internal -------------------------------------
79
-
80
- /**
81
- * The ID of this observer's live query.
82
- *
83
- * @internal
84
- */
85
- readonly liveQueryID: number
86
-
87
- /** @internal */
88
- constructor(ditto: Ditto, query: string, queryArguments: DQLQueryArguments | null, observationHandler: StoreObservationHandlerWithSignalNext) {
89
- this.queryString = query
90
- this.queryArguments = queryArguments ? Object.freeze({ ...queryArguments }) : undefined
91
- this.ditto = ditto
92
-
93
- let queryArgumentsCBOR: Uint8Array | null = null
94
- if (queryArguments != null) {
95
- try {
96
- const queryArgumentsJSON = desugarJSObject(queryArguments)
97
- queryArgumentsCBOR = CBOR.encode(queryArgumentsJSON)
98
- } catch (error: any) {
99
- throw new DittoError('query/arguments-invalid')
100
- }
101
- }
102
- let storeObserverID: number | undefined
103
- const dittoHandle = Bridge.ditto.handleFor(ditto)
104
- this.ditto.deferClose(() => {
105
- const weakThis = new WeakRef(this)
106
-
107
- function wrappedObservationHandler(cCBParams: CCallbackParams): void {
108
- const strongThis = weakThis.deref()
109
- if (strongThis == null) {
110
- Logger.debug(`Ignoring change event received by store observer ${storeObserverID} after it was cancelled`)
111
- return
112
- }
113
-
114
- const result = Bridge.queryResult.bridge(cCBParams.query_result, () => new QueryResult(cCBParams.query_result))
115
-
116
- Logger.debug(`Invoking user event handler with new event for store observer ${storeObserverID}`)
117
- observationHandler(result, () => {
118
- return strongThis.signalNext()
119
- })
120
- }
121
-
122
- mapFFIErrors(() => {
123
- storeObserverID = FFI.tryExperimentalRegisterChangeObserver(dittoHandle.deref(), query, queryArgumentsCBOR, wrappedObservationHandler)
124
- })
125
- })
126
-
127
- if (storeObserverID == null) {
128
- throw new DittoError('internal', 'Internal inconsistency, store observer ID is undefined after registering')
129
- }
130
-
131
- this.liveQueryID = storeObserverID
132
- }
133
-
134
- // --------------------------- Private --------------------------------------
135
-
136
- /**
137
- * `true` when the store observer has been cancelled.
138
- *
139
- * We mark the store observer as cancelled here as an optimization to avoid a
140
- * scan of all store observers in the store whenever the `isCancelled`
141
- * property is checked.
142
- */
143
- private _isCancelled = false
144
-
145
- /**
146
- * Signals to Ditto Core that the observer is ready for the next event.
147
- */
148
- private signalNext() {
149
- const ditto = this.ditto
150
- if (!ditto || ditto.isClosed) return
151
-
152
- const dittoHandle = Bridge.ditto.handleFor(ditto)
153
- const dittoPointer = dittoHandle.derefOrNull()
154
- if (!dittoPointer) return
155
-
156
- if (this.liveQueryID == null) {
157
- throw new Error('live query ID is null while signaling ready for next event')
158
- }
159
-
160
- return ditto.deferCloseAsync(async () => {
161
- Logger.debug(`Signaling availability for live query ${this.liveQueryID}`)
162
- await FFI.liveQuerySignalAvailableNext(dittoPointer, this.liveQueryID)
163
- })
164
- }
165
- }
166
-
167
- // c.f. struct c_cb_params
168
- type CCallbackParams = {
169
- query_result: FFI.Pointer<FFI.FFIQueryResult>
170
- }