@dittolive/ditto 4.8.2-rc.1 → 4.8.3
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/README.md +2 -2
- package/node/ditto.cjs.js +172 -14
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-arm64.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/ditto.win32-x64.node +0 -0
- package/package.json +1 -1
- package/react-native/ditto.es6.js +1 -1
- package/types/ditto.d.ts +182 -11
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
package/node/ditto.cjs.js
CHANGED
|
@@ -108,6 +108,8 @@ class Observer {
|
|
|
108
108
|
}
|
|
109
109
|
Observer.finalizationRegistry = new FinalizationRegistry(Observer.finalize);
|
|
110
110
|
|
|
111
|
+
const isWebBuild = false;
|
|
112
|
+
|
|
111
113
|
//
|
|
112
114
|
// Copyright © 2021 DittoLive Incorporated. All rights reserved.
|
|
113
115
|
//
|
|
@@ -118,6 +120,8 @@ const privateToken$1 = Symbol('privateConstructorToken');
|
|
|
118
120
|
/**
|
|
119
121
|
* Represents a CRDT counter that can be upserted as part of a document or
|
|
120
122
|
* assigned to a property during an update of a document.
|
|
123
|
+
*
|
|
124
|
+
* Not available in React Native environments.
|
|
121
125
|
*/
|
|
122
126
|
class Counter {
|
|
123
127
|
/** The value of the counter. */
|
|
@@ -156,6 +160,8 @@ class MutableCounter extends Counter {
|
|
|
156
160
|
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
157
161
|
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
158
162
|
* otherwise an exception is thrown.
|
|
163
|
+
*
|
|
164
|
+
* @throws {Error} when called in a React Native environment.
|
|
159
165
|
*/
|
|
160
166
|
increment(amount) {
|
|
161
167
|
const mutDoc = this.mutDoc;
|
|
@@ -189,6 +195,8 @@ const privateToken = '@ditto.ff82dae89821c5ab822a8b539056bce4';
|
|
|
189
195
|
/**
|
|
190
196
|
* Represents a CRDT register that can be upserted as part of a document or
|
|
191
197
|
* assigned to a property during an update of a document.
|
|
198
|
+
*
|
|
199
|
+
* Not available in React Native environments.
|
|
192
200
|
*/
|
|
193
201
|
class Register {
|
|
194
202
|
/** Returns the value of the register. */
|
|
@@ -216,15 +224,24 @@ class Register {
|
|
|
216
224
|
* updating a document.
|
|
217
225
|
*
|
|
218
226
|
* This class can't be instantiated directly, it's returned automatically for
|
|
219
|
-
* any register property of a document within an update block via
|
|
227
|
+
* any register property of a document within an update block via
|
|
228
|
+
* {@link MutableDocumentPath.register}.
|
|
229
|
+
*
|
|
230
|
+
* Not available in React Native environments.
|
|
220
231
|
*/
|
|
221
232
|
class MutableRegister extends Register {
|
|
222
|
-
/**
|
|
233
|
+
/**
|
|
234
|
+
* Returns the value of the register.
|
|
235
|
+
*
|
|
236
|
+
* Not available in React Native environments.
|
|
237
|
+
*/
|
|
223
238
|
get value() {
|
|
224
239
|
return super.value;
|
|
225
240
|
}
|
|
226
241
|
/**
|
|
227
242
|
* Convenience setter, equivalent to {@link set | set()}.
|
|
243
|
+
*
|
|
244
|
+
* Not available in React Native environments.
|
|
228
245
|
*/
|
|
229
246
|
set value(value) {
|
|
230
247
|
this.set(value);
|
|
@@ -236,6 +253,8 @@ class MutableRegister extends Register {
|
|
|
236
253
|
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
237
254
|
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
238
255
|
* otherwise an exception is thrown.
|
|
256
|
+
*
|
|
257
|
+
* Not available in React Native environments.
|
|
239
258
|
*/
|
|
240
259
|
set(value) {
|
|
241
260
|
const mutableDocument = this['@ditto.mutableDocument'];
|
|
@@ -438,8 +457,6 @@ function refCStringToString(...args) { return ditto.refCStringToString(...args)
|
|
|
438
457
|
function setDeadlockTimeout$1(...args) { return ditto.setDeadlockTimeout(...args) }
|
|
439
458
|
function withOutBoxCBytes(...args) { return ditto.withOutBoxCBytes(...args) }
|
|
440
459
|
|
|
441
|
-
const isWebBuild = false;
|
|
442
|
-
|
|
443
460
|
//
|
|
444
461
|
// Copyright © 2023 DittoLive Incorporated. All rights reserved.
|
|
445
462
|
//
|
|
@@ -2233,7 +2250,7 @@ class AttachmentToken {
|
|
|
2233
2250
|
|
|
2234
2251
|
// NOTE: this is patched up with the actual build version by Jake task
|
|
2235
2252
|
// build:package and has to be a valid semantic version as defined here: https://semver.org.
|
|
2236
|
-
const fullBuildVersionString = '4.8.
|
|
2253
|
+
const fullBuildVersionString = '4.8.3';
|
|
2237
2254
|
|
|
2238
2255
|
//
|
|
2239
2256
|
// Copyright © 2021 DittoLive Incorporated. All rights reserved.
|
|
@@ -2383,7 +2400,7 @@ class Logger {
|
|
|
2383
2400
|
* callbacks.
|
|
2384
2401
|
*
|
|
2385
2402
|
* @throws {TypeError} if `callback` is not a function or `undefined`.
|
|
2386
|
-
* @throws {Error}
|
|
2403
|
+
* @throws {Error} when called in a React Native environment.
|
|
2387
2404
|
*/
|
|
2388
2405
|
static async setCustomLogCallback(callback) {
|
|
2389
2406
|
if (callback != null && typeof callback !== 'function') {
|
|
@@ -4319,6 +4336,8 @@ function checkForUnsupportedValues(jsObj) {
|
|
|
4319
4336
|
* - `set`
|
|
4320
4337
|
* - `removed`
|
|
4321
4338
|
* - `incremented`
|
|
4339
|
+
*
|
|
4340
|
+
* Not available in React Native environments.
|
|
4322
4341
|
*/
|
|
4323
4342
|
class UpdateResult {
|
|
4324
4343
|
// ----------------------------------------------------------- Internal ------
|
|
@@ -4623,6 +4642,8 @@ class KeyPath {
|
|
|
4623
4642
|
* type. You don't create a `DocumentPath` directly but obtain one via the
|
|
4624
4643
|
* {@link Document.path | path} property or the {@link Document.at | at()}
|
|
4625
4644
|
* method of {@link Document}.
|
|
4645
|
+
*
|
|
4646
|
+
* Not available in React Native environments.
|
|
4626
4647
|
*/
|
|
4627
4648
|
class DocumentPath {
|
|
4628
4649
|
/**
|
|
@@ -4643,6 +4664,8 @@ class DocumentPath {
|
|
|
4643
4664
|
* - `documentPath.at('passengers[2]')`
|
|
4644
4665
|
* - `documentPath.at('passengers[2].belongings[1].kind')`
|
|
4645
4666
|
* - `documentPath.at('.mileage')`
|
|
4667
|
+
*
|
|
4668
|
+
* @throws {Error} when called in a React Native environment.
|
|
4646
4669
|
*/
|
|
4647
4670
|
at(keyPathOrIndex) {
|
|
4648
4671
|
if (typeof keyPathOrIndex === 'string') {
|
|
@@ -4662,6 +4685,8 @@ class DocumentPath {
|
|
|
4662
4685
|
/**
|
|
4663
4686
|
* Traverses the document with the key-path represented by the receiver and
|
|
4664
4687
|
* returns the corresponding object or value.
|
|
4688
|
+
*
|
|
4689
|
+
* @throws {Error} when called in a React Native environment.
|
|
4665
4690
|
*/
|
|
4666
4691
|
get value() {
|
|
4667
4692
|
return this.underlyingValueForPathType('Any');
|
|
@@ -4669,6 +4694,8 @@ class DocumentPath {
|
|
|
4669
4694
|
/**
|
|
4670
4695
|
* Returns the value at the previously specified key in the document as a
|
|
4671
4696
|
* {@link Counter} if possible, otherwise returns `null`.
|
|
4697
|
+
*
|
|
4698
|
+
* @throws {Error} when called in a React Native environment.
|
|
4672
4699
|
*/
|
|
4673
4700
|
get counter() {
|
|
4674
4701
|
const underlyingValue = this.underlyingValueForPathType('Counter');
|
|
@@ -4677,6 +4704,8 @@ class DocumentPath {
|
|
|
4677
4704
|
/**
|
|
4678
4705
|
* Returns the value at the previously specified key in the document as a
|
|
4679
4706
|
* {@link Register} if possible, otherwise returns `null`.
|
|
4707
|
+
*
|
|
4708
|
+
* @throws {Error} when called in a React Native environment.
|
|
4680
4709
|
*/
|
|
4681
4710
|
get register() {
|
|
4682
4711
|
const underlyingValue = this.underlyingValueForPathType('Register');
|
|
@@ -4685,6 +4714,8 @@ class DocumentPath {
|
|
|
4685
4714
|
/**
|
|
4686
4715
|
* Returns the value at the previously specified key in the document as an
|
|
4687
4716
|
* {@link AttachmentToken} if possible, otherwise returns `null`.
|
|
4717
|
+
*
|
|
4718
|
+
* @throws {Error} when called in a React Native environment.
|
|
4688
4719
|
*/
|
|
4689
4720
|
get attachmentToken() {
|
|
4690
4721
|
const underlyingValue = this.underlyingValueForPathType('Attachment');
|
|
@@ -4710,6 +4741,8 @@ class DocumentPath {
|
|
|
4710
4741
|
* a specific key-path. You don't create a `MutableDocumentPath` directly but
|
|
4711
4742
|
* obtain one via the {@link MutableDocument.path | path} property or the
|
|
4712
4743
|
* {@link MutableDocument.at | at()} method of {@link MutableDocument}.
|
|
4744
|
+
*
|
|
4745
|
+
* Not available in React Native environments.
|
|
4713
4746
|
*/
|
|
4714
4747
|
class MutableDocumentPath {
|
|
4715
4748
|
/**
|
|
@@ -4730,6 +4763,8 @@ class MutableDocumentPath {
|
|
|
4730
4763
|
* - `mutableDocumentPath.at('passengers[2]')`
|
|
4731
4764
|
* - `mutableDocumentPath.at('passengers[2].belongings[1].kind')`
|
|
4732
4765
|
* - `mutableDocumentPath.at('.mileage')`
|
|
4766
|
+
*
|
|
4767
|
+
* @throws {Error} when called in a React Native environment.
|
|
4733
4768
|
*/
|
|
4734
4769
|
at(keyPathOrIndex) {
|
|
4735
4770
|
if (typeof keyPathOrIndex === 'string') {
|
|
@@ -4749,6 +4784,8 @@ class MutableDocumentPath {
|
|
|
4749
4784
|
/**
|
|
4750
4785
|
* Traverses the document with the key-path represented by the receiver and
|
|
4751
4786
|
* returns the corresponding object or value.
|
|
4787
|
+
*
|
|
4788
|
+
* @throws {Error} when called in a React Native environment.
|
|
4752
4789
|
*/
|
|
4753
4790
|
get value() {
|
|
4754
4791
|
return this.underlyingValueForPathType('Any');
|
|
@@ -4756,6 +4793,8 @@ class MutableDocumentPath {
|
|
|
4756
4793
|
/**
|
|
4757
4794
|
* Returns the value at the previously specified key in the document as a
|
|
4758
4795
|
* {@link MutableCounter} if possible, otherwise returns `null`.
|
|
4796
|
+
*
|
|
4797
|
+
* @throws {Error} when called in a React Native environment.
|
|
4759
4798
|
*/
|
|
4760
4799
|
get counter() {
|
|
4761
4800
|
const underlyingValue = this.underlyingValueForPathType('Counter');
|
|
@@ -4764,6 +4803,8 @@ class MutableDocumentPath {
|
|
|
4764
4803
|
/**
|
|
4765
4804
|
* Returns the value at the previously specified key in the document as a
|
|
4766
4805
|
* {@link MutableRegister} if possible, otherwise returns `null`.
|
|
4806
|
+
*
|
|
4807
|
+
* @throws {Error} when called in a React Native environment.
|
|
4767
4808
|
*/
|
|
4768
4809
|
get register() {
|
|
4769
4810
|
const underlyingValue = this.underlyingValueForPathType('Register');
|
|
@@ -4772,6 +4813,8 @@ class MutableDocumentPath {
|
|
|
4772
4813
|
/**
|
|
4773
4814
|
* Returns the value at the previously specified key in the document as a
|
|
4774
4815
|
* {@link AttachmentToken} if possible, otherwise returns `null`.
|
|
4816
|
+
*
|
|
4817
|
+
* @throws {Error} when called in a React Native environment.
|
|
4775
4818
|
*/
|
|
4776
4819
|
get attachmentToken() {
|
|
4777
4820
|
const underlyingValue = this.underlyingValueForPathType('Attachment');
|
|
@@ -4784,12 +4827,16 @@ class MutableDocumentPath {
|
|
|
4784
4827
|
* default value. Set this to `true` if you want to set a default value that
|
|
4785
4828
|
* you expect to be overwritten by other devices in the network. The default
|
|
4786
4829
|
* value is `false`.
|
|
4830
|
+
*
|
|
4831
|
+
* @throws {Error} when called in a React Native environment.
|
|
4787
4832
|
*/
|
|
4788
4833
|
set(value, isDefault) {
|
|
4789
4834
|
return this['@ditto.set'](value, isDefault);
|
|
4790
4835
|
}
|
|
4791
4836
|
/**
|
|
4792
4837
|
* Removes a value at the document's key-path defined by the receiver.
|
|
4838
|
+
*
|
|
4839
|
+
* @throws {Error} when called in a React Native environment.
|
|
4793
4840
|
*/
|
|
4794
4841
|
remove() {
|
|
4795
4842
|
return this['@ditto.remove']();
|
|
@@ -4876,10 +4923,16 @@ class MutableDocumentPath {
|
|
|
4876
4923
|
// the object is inspected with console.log() or util.inspect().
|
|
4877
4924
|
const CUSTOM_INSPECT_SYMBOL$1 = Symbol.for('nodejs.util.inspect.custom');
|
|
4878
4925
|
// -----------------------------------------------------------------------------
|
|
4879
|
-
/**
|
|
4926
|
+
/**
|
|
4927
|
+
* A document belonging to a {@link Collection} with an inner value.
|
|
4928
|
+
*
|
|
4929
|
+
* Not available in React Native environments.
|
|
4930
|
+
*/
|
|
4880
4931
|
class Document {
|
|
4881
4932
|
/**
|
|
4882
4933
|
* Returns a hash that represents the passed in document(s).
|
|
4934
|
+
*
|
|
4935
|
+
* @throws {Error} when called in a React Native environment.
|
|
4883
4936
|
*/
|
|
4884
4937
|
static hash(documentOrMany) {
|
|
4885
4938
|
const documents = documentsFrom(documentOrMany);
|
|
@@ -4889,6 +4942,8 @@ class Document {
|
|
|
4889
4942
|
/**
|
|
4890
4943
|
* Returns a pattern of words that together create a mnemonic, which
|
|
4891
4944
|
* represents the passed in document(s).
|
|
4945
|
+
*
|
|
4946
|
+
* @throws {Error} when called in a React Native environment.
|
|
4892
4947
|
*/
|
|
4893
4948
|
static hashMnemonic(documentOrMany) {
|
|
4894
4949
|
const documents = documentsFrom(documentOrMany);
|
|
@@ -4897,6 +4952,8 @@ class Document {
|
|
|
4897
4952
|
}
|
|
4898
4953
|
/**
|
|
4899
4954
|
* Returns the document ID.
|
|
4955
|
+
*
|
|
4956
|
+
* @throws {Error} when called in a React Native environment.
|
|
4900
4957
|
*/
|
|
4901
4958
|
get id() {
|
|
4902
4959
|
let id = this['@ditto.id'];
|
|
@@ -4910,6 +4967,8 @@ class Document {
|
|
|
4910
4967
|
}
|
|
4911
4968
|
/**
|
|
4912
4969
|
* Returns the document path at the root of the document.
|
|
4970
|
+
*
|
|
4971
|
+
* @throws {Error} when called in a React Native environment.
|
|
4913
4972
|
*/
|
|
4914
4973
|
get path() {
|
|
4915
4974
|
return new DocumentPath(this, '', false);
|
|
@@ -4918,6 +4977,8 @@ class Document {
|
|
|
4918
4977
|
* Convenience property, same as calling `path.value`. The value is cached on
|
|
4919
4978
|
* first access and returned on subsequent calls without calling `path.value`
|
|
4920
4979
|
* again.
|
|
4980
|
+
*
|
|
4981
|
+
* @throws {Error} when called in a React Native environment.
|
|
4921
4982
|
*/
|
|
4922
4983
|
get value() {
|
|
4923
4984
|
let value = this['@ditto.value'];
|
|
@@ -4929,6 +4990,8 @@ class Document {
|
|
|
4929
4990
|
}
|
|
4930
4991
|
/**
|
|
4931
4992
|
* Convenience method, same as calling `path.at()`.
|
|
4993
|
+
*
|
|
4994
|
+
* @throws {Error} when called in a React Native environment.
|
|
4932
4995
|
*/
|
|
4933
4996
|
at(keyPathOrIndex) {
|
|
4934
4997
|
return this.path.at(keyPathOrIndex);
|
|
@@ -4978,10 +5041,14 @@ class Document {
|
|
|
4978
5041
|
* `MutableDocument` directly but rather through the `update()` methods of
|
|
4979
5042
|
* {@link PendingCursorOperation.update | PendingCursorOperation} and
|
|
4980
5043
|
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation}.
|
|
5044
|
+
*
|
|
5045
|
+
* Not available in React Native environments.
|
|
4981
5046
|
*/
|
|
4982
5047
|
class MutableDocument {
|
|
4983
5048
|
/**
|
|
4984
5049
|
* Returns the ID of the document.
|
|
5050
|
+
*
|
|
5051
|
+
* @throws {Error} when called in a React Native environment.
|
|
4985
5052
|
*/
|
|
4986
5053
|
get id() {
|
|
4987
5054
|
let id = this['@ditto.id'];
|
|
@@ -4995,18 +5062,24 @@ class MutableDocument {
|
|
|
4995
5062
|
}
|
|
4996
5063
|
/**
|
|
4997
5064
|
* Returns the document path at the root of the document.
|
|
5065
|
+
*
|
|
5066
|
+
* @throws {Error} when called in a React Native environment.
|
|
4998
5067
|
*/
|
|
4999
5068
|
get path() {
|
|
5000
5069
|
return new MutableDocumentPath(this, '', false);
|
|
5001
5070
|
}
|
|
5002
5071
|
/**
|
|
5003
5072
|
* Convenience property, same as `path.value`.
|
|
5073
|
+
*
|
|
5074
|
+
* @throws {Error} when called in a React Native environment.
|
|
5004
5075
|
*/
|
|
5005
5076
|
get value() {
|
|
5006
5077
|
return this.path.value;
|
|
5007
5078
|
}
|
|
5008
5079
|
/**
|
|
5009
5080
|
* Convenience method, same as calling `path.at()`.
|
|
5081
|
+
*
|
|
5082
|
+
* @throws {Error} when called in a React Native environment.
|
|
5010
5083
|
*/
|
|
5011
5084
|
at(keyPathOrIndex) {
|
|
5012
5085
|
return this.path.at(keyPathOrIndex);
|
|
@@ -5062,6 +5135,8 @@ function documentsFrom(documentOrMany) {
|
|
|
5062
5135
|
* {@link UpdateResult | update results}. This is the data structure you get
|
|
5063
5136
|
* when {@link PendingCursorOperation.update | updating} a set of documents
|
|
5064
5137
|
* with detailed info about the performed updates.
|
|
5138
|
+
*
|
|
5139
|
+
* Not available in React Native environments.
|
|
5065
5140
|
*/
|
|
5066
5141
|
class UpdateResultsMap {
|
|
5067
5142
|
/**
|
|
@@ -5106,6 +5181,9 @@ class UpdateResultsMap {
|
|
|
5106
5181
|
//
|
|
5107
5182
|
// Copyright © 2023 DittoLive Incorporated. All rights reserved.
|
|
5108
5183
|
//
|
|
5184
|
+
/**
|
|
5185
|
+
* Not available in React Native environments.
|
|
5186
|
+
*/
|
|
5109
5187
|
class BasePendingCursorOperation {
|
|
5110
5188
|
/**
|
|
5111
5189
|
* Sorts the documents that match the query provided in the preceding
|
|
@@ -5119,6 +5197,7 @@ class BasePendingCursorOperation {
|
|
|
5119
5197
|
* @param direction Specify whether you want the sorting order to be
|
|
5120
5198
|
* `ascending` or `descending`. Defaults to `ascending`.
|
|
5121
5199
|
*
|
|
5200
|
+
* @throws {Error} when called in a React Native environment.
|
|
5122
5201
|
* @return A cursor that you can chain further function calls and then either
|
|
5123
5202
|
* get the matching documents immediately or get updates about them over time.
|
|
5124
5203
|
*/
|
|
@@ -5141,6 +5220,7 @@ class BasePendingCursorOperation {
|
|
|
5141
5220
|
* @param offset The number of matching documents that you want the eventual
|
|
5142
5221
|
* resulting set of matching documents to be offset by (and thus not include).
|
|
5143
5222
|
*
|
|
5223
|
+
* @throws {Error} when called in a React Native environment.
|
|
5144
5224
|
* @return A cursor that you can chain further function calls and then either
|
|
5145
5225
|
* get the matching documents immediately or get updates about them over time.
|
|
5146
5226
|
*/
|
|
@@ -5164,6 +5244,7 @@ class BasePendingCursorOperation {
|
|
|
5164
5244
|
*
|
|
5165
5245
|
* @param limit The maximum number of documents that will be returned.
|
|
5166
5246
|
*
|
|
5247
|
+
* @throws {Error} when called in a React Native environment.
|
|
5167
5248
|
* @return A cursor that you can chain further function calls and then either
|
|
5168
5249
|
* get the matching documents immediately or get updates about them over time.
|
|
5169
5250
|
*/
|
|
@@ -5185,6 +5266,7 @@ class BasePendingCursorOperation {
|
|
|
5185
5266
|
* Executes the query generated by the preceding function chaining and return
|
|
5186
5267
|
* the list of matching documents.
|
|
5187
5268
|
*
|
|
5269
|
+
* @throws {Error} when called in a React Native environment.
|
|
5188
5270
|
* @returns An array promise containing {@link Document | documents} matching
|
|
5189
5271
|
* the query generated by the preceding function chaining.
|
|
5190
5272
|
*/
|
|
@@ -5288,11 +5370,14 @@ class BasePendingCursorOperation {
|
|
|
5288
5370
|
* return value, or chain calls to update, evict or remove the document.
|
|
5289
5371
|
*
|
|
5290
5372
|
* Live queries and subscriptions are only available outside of a transaction.
|
|
5373
|
+
*
|
|
5374
|
+
* Not available in React Native environments.
|
|
5291
5375
|
*/
|
|
5292
5376
|
class BasePendingIDSpecificOperation {
|
|
5293
5377
|
/**
|
|
5294
5378
|
* Executes the find operation to return the document with the matching ID.
|
|
5295
5379
|
*
|
|
5380
|
+
* @throws {Error} when called in a React Native environment.
|
|
5296
5381
|
* @returns The {@link Document} promise with the ID provided in the
|
|
5297
5382
|
* {@link Collection.findByID | findByID()} call or `undefined` if the document was
|
|
5298
5383
|
* not found.
|
|
@@ -6220,6 +6305,11 @@ class AttachmentFetcher {
|
|
|
6220
6305
|
* While {@link Subscription} objects remain in scope they ensure that
|
|
6221
6306
|
* documents in the collection specified and that match the query provided will
|
|
6222
6307
|
* try to be kept up-to-date with the latest changes from remote peers.
|
|
6308
|
+
*
|
|
6309
|
+
* This class is used by Ditto's query builder APIs.
|
|
6310
|
+
* @see {@link SyncSubscription} for the DQL equivalent.
|
|
6311
|
+
*
|
|
6312
|
+
* Not available in React Native environments.
|
|
6223
6313
|
*/
|
|
6224
6314
|
class Subscription {
|
|
6225
6315
|
/**
|
|
@@ -6273,6 +6363,8 @@ class Subscription {
|
|
|
6273
6363
|
/**
|
|
6274
6364
|
* First event fired immediately after registering a live query without any
|
|
6275
6365
|
* mutations. All subsequent events are of type {@link LiveQueryEventUpdate}.
|
|
6366
|
+
*
|
|
6367
|
+
* Not available in React Native environments.
|
|
6276
6368
|
*/
|
|
6277
6369
|
class LiveQueryEventInitial {
|
|
6278
6370
|
constructor() {
|
|
@@ -6308,11 +6400,14 @@ class LiveQueryEventInitial {
|
|
|
6308
6400
|
/**
|
|
6309
6401
|
* Represents an update event describing all changes that occured for documents
|
|
6310
6402
|
* covered by a (live) query.
|
|
6403
|
+
*
|
|
6404
|
+
* Not available in React Native environments.
|
|
6311
6405
|
*/
|
|
6312
6406
|
class LiveQueryEventUpdate {
|
|
6313
6407
|
/**
|
|
6314
6408
|
* Returns a hash that represents the set of matching documents.
|
|
6315
6409
|
*
|
|
6410
|
+
* @throws {Error} when called in a React Native environment.
|
|
6316
6411
|
* @deprecated use {@link Document.hash | Document.hash()} instead.
|
|
6317
6412
|
*/
|
|
6318
6413
|
hash(documents) {
|
|
@@ -6324,6 +6419,7 @@ class LiveQueryEventUpdate {
|
|
|
6324
6419
|
* Returns a pattern of words that together create a mnemonic, which
|
|
6325
6420
|
* represents the set of matching documents.
|
|
6326
6421
|
*
|
|
6422
|
+
* @throws {Error} when called in a React Native environment.
|
|
6327
6423
|
* @deprecated use {@link Document.hashMnemonic | Document.hashMnemonic()} instead.
|
|
6328
6424
|
*/
|
|
6329
6425
|
hashMnemonic(documents) {
|
|
@@ -6395,6 +6491,8 @@ class SingleDocumentLiveQueryEvent {
|
|
|
6395
6491
|
* your event handler be called when there is an update to a document matching
|
|
6396
6492
|
* the query you provide. When you no longer want to receive updates about
|
|
6397
6493
|
* documents matching a query then you must call {@link stop | stop()}.
|
|
6494
|
+
*
|
|
6495
|
+
* Not available in React Native environments.
|
|
6398
6496
|
*/
|
|
6399
6497
|
class LiveQuery {
|
|
6400
6498
|
/** The name of the collection that the live query is based on. */
|
|
@@ -6407,6 +6505,8 @@ class LiveQuery {
|
|
|
6407
6505
|
}
|
|
6408
6506
|
/**
|
|
6409
6507
|
* Stop the live query from delivering updates.
|
|
6508
|
+
*
|
|
6509
|
+
* @throws {Error} when called in a React Native environment.
|
|
6410
6510
|
*/
|
|
6411
6511
|
stop() {
|
|
6412
6512
|
if (!this.isStopped) {
|
|
@@ -6495,6 +6595,8 @@ class LiveQuery {
|
|
|
6495
6595
|
* preceding `find`-like call.
|
|
6496
6596
|
*
|
|
6497
6597
|
* Update and remove functionality is also exposed through this object.
|
|
6598
|
+
*
|
|
6599
|
+
* Not available in React Native environments.
|
|
6498
6600
|
*/
|
|
6499
6601
|
class PendingCursorOperation extends BasePendingCursorOperation {
|
|
6500
6602
|
sort(propertyPath, direction = 'ascending') {
|
|
@@ -6558,6 +6660,8 @@ class PendingCursorOperation extends BasePendingCursorOperation {
|
|
|
6558
6660
|
* The returned {@link Subscription} object must be kept in scope for as long
|
|
6559
6661
|
* as you want to keep receiving updates.
|
|
6560
6662
|
*
|
|
6663
|
+
* @throws {Error} when called in a React Native environment.
|
|
6664
|
+
*
|
|
6561
6665
|
* @returns A {@link Subscription} object that must be kept in scope for as
|
|
6562
6666
|
* long as you want to keep receiving updates for documents that match the
|
|
6563
6667
|
* query specified in the preceding chain.
|
|
@@ -6588,6 +6692,8 @@ class PendingCursorOperation extends BasePendingCursorOperation {
|
|
|
6588
6692
|
* transaction committed to the store that involves modifications to documents
|
|
6589
6693
|
* matching the query in the collection this method was called on.
|
|
6590
6694
|
*
|
|
6695
|
+
* @throws {Error} when called in a React Native environment.
|
|
6696
|
+
*
|
|
6591
6697
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
6592
6698
|
* as you want to keep receiving updates.
|
|
6593
6699
|
*/
|
|
@@ -6617,6 +6723,8 @@ class PendingCursorOperation extends BasePendingCursorOperation {
|
|
|
6617
6723
|
* documents matching the query in the collection that this method was called
|
|
6618
6724
|
* on.
|
|
6619
6725
|
*
|
|
6726
|
+
* @throws {Error} when called in a React Native environment.
|
|
6727
|
+
*
|
|
6620
6728
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
6621
6729
|
* as you want to keep receiving updates.
|
|
6622
6730
|
*/
|
|
@@ -6668,6 +6776,8 @@ class PendingCursorOperation extends BasePendingCursorOperation {
|
|
|
6668
6776
|
* {@link Collection.findByID | findByID()} call.
|
|
6669
6777
|
*
|
|
6670
6778
|
* Update and remove functionality is also exposed through this object.
|
|
6779
|
+
*
|
|
6780
|
+
* Not available in React Native environments.
|
|
6671
6781
|
*/
|
|
6672
6782
|
class PendingIDSpecificOperation extends BasePendingIDSpecificOperation {
|
|
6673
6783
|
async remove() {
|
|
@@ -6722,6 +6832,8 @@ class PendingIDSpecificOperation extends BasePendingIDSpecificOperation {
|
|
|
6722
6832
|
* The returned {@link Subscription} object must be kept in scope for as long
|
|
6723
6833
|
* as you want to keep receiving updates.
|
|
6724
6834
|
*
|
|
6835
|
+
* @throws {Error} when called in a React Native environment.
|
|
6836
|
+
*
|
|
6725
6837
|
* @returns A {@link Subscription} object that must be kept in scope for as
|
|
6726
6838
|
* long as you want to keep receiving updates for the document.
|
|
6727
6839
|
*/
|
|
@@ -6749,6 +6861,8 @@ class PendingIDSpecificOperation extends BasePendingIDSpecificOperation {
|
|
|
6749
6861
|
* document with the relevant ID in the collection that
|
|
6750
6862
|
* {@link PendingIDSpecificOperation.observeLocal | observeLocal()} was called on.
|
|
6751
6863
|
*
|
|
6864
|
+
* @throws {Error} when called in a React Native environment.
|
|
6865
|
+
*
|
|
6752
6866
|
* @returns A {@link LiveQuery} object that must be kept in scope for as long
|
|
6753
6867
|
* as you want to keep receiving updates.
|
|
6754
6868
|
*/
|
|
@@ -6775,6 +6889,8 @@ class PendingIDSpecificOperation extends BasePendingIDSpecificOperation {
|
|
|
6775
6889
|
* document with the relevant ID in the collection that
|
|
6776
6890
|
* {@link PendingIDSpecificOperation.observeLocal | observeLocal()} was called on.
|
|
6777
6891
|
*
|
|
6892
|
+
* @throws {Error} when called in a React Native environment.
|
|
6893
|
+
*
|
|
6778
6894
|
* @returns A {@link LiveQuery} object that must be kept in scope for as long
|
|
6779
6895
|
* as you want to keep receiving updates.
|
|
6780
6896
|
*/
|
|
@@ -6836,6 +6952,8 @@ class PendingIDSpecificOperation extends BasePendingIDSpecificOperation {
|
|
|
6836
6952
|
* querying a collection. You can get a collection by calling
|
|
6837
6953
|
* {@link Store.collection | collection()} on a {@link Store} of a {@link Ditto}
|
|
6838
6954
|
* object.
|
|
6955
|
+
*
|
|
6956
|
+
* Not available in React Native environments.
|
|
6839
6957
|
*/
|
|
6840
6958
|
class Collection {
|
|
6841
6959
|
/**
|
|
@@ -6856,6 +6974,7 @@ class Collection {
|
|
|
6856
6974
|
* Find more information about the query string format in the documentation's
|
|
6857
6975
|
* section on {@link https://docs.ditto.live/javascript/common/concepts/querying Querying}
|
|
6858
6976
|
*
|
|
6977
|
+
* @throws {Error} when called in a React Native environment.
|
|
6859
6978
|
* @param query The query to run against the collection.
|
|
6860
6979
|
* @param queryArgs The arguments to use to replace placeholders in the
|
|
6861
6980
|
* provided query.
|
|
@@ -6878,6 +6997,7 @@ class Collection {
|
|
|
6878
6997
|
* remove or evict the document.
|
|
6879
6998
|
*
|
|
6880
6999
|
* @param id The ID of the document to find.
|
|
7000
|
+
* @throws {Error} when called in a React Native environment.
|
|
6881
7001
|
*/
|
|
6882
7002
|
findByID(id) {
|
|
6883
7003
|
const documentID = id instanceof DocumentID ? id : new DocumentID(id);
|
|
@@ -6918,9 +7038,10 @@ class Collection {
|
|
|
6918
7038
|
*
|
|
6919
7039
|
* @param pathOrData The path to the file that you want to create an
|
|
6920
7040
|
* attachment with or the raw data.
|
|
6921
|
-
*
|
|
6922
7041
|
* @param metadata Metadata relating to the attachment.
|
|
6923
7042
|
*
|
|
7043
|
+
* @throws {Error} when called in a React Native environment.
|
|
7044
|
+
*
|
|
6924
7045
|
* @deprecated Use {@link Store.newAttachment | ditto.store.newAttachment() }
|
|
6925
7046
|
* instead.
|
|
6926
7047
|
*/
|
|
@@ -6961,10 +7082,11 @@ class Collection {
|
|
|
6961
7082
|
*
|
|
6962
7083
|
* @param token The {@link AttachmentToken} relevant to the attachment that
|
|
6963
7084
|
* you wish to download and observe. Throws if token is invalid.
|
|
6964
|
-
*
|
|
6965
7085
|
* @param eventHandler An optional callback that will be called when there is
|
|
6966
7086
|
* an update to the status of the attachment fetch attempt.
|
|
6967
7087
|
*
|
|
7088
|
+
* @throws {Error} when called in a React Native environment.
|
|
7089
|
+
*
|
|
6968
7090
|
* @return An `AttachmentFetcher` object, which must be kept alive for the
|
|
6969
7091
|
* fetch request to proceed and for you to be notified about the attachment's
|
|
6970
7092
|
* fetch status changes.
|
|
@@ -7149,6 +7271,8 @@ class StoreObserver {
|
|
|
7149
7271
|
* the collections that were previously known about in the previous event, along
|
|
7150
7272
|
* with information about what collections have been inserted, deleted, updated,
|
|
7151
7273
|
* or moved since the last event.
|
|
7274
|
+
*
|
|
7275
|
+
* Not available in React Native environments.
|
|
7152
7276
|
*/
|
|
7153
7277
|
class CollectionsEvent {
|
|
7154
7278
|
/** @internal */
|
|
@@ -7196,6 +7320,8 @@ class CollectionsEvent {
|
|
|
7196
7320
|
* A subscription, established by calling {@link subscribe | subscribe()}, will
|
|
7197
7321
|
* act as a signal to other peers that the device connects to that you would
|
|
7198
7322
|
* like to receive updates from them about the collections that they know about.
|
|
7323
|
+
*
|
|
7324
|
+
* Not available in React Native environments.
|
|
7199
7325
|
*/
|
|
7200
7326
|
class PendingCollectionsOperation {
|
|
7201
7327
|
/**
|
|
@@ -7207,6 +7333,8 @@ class PendingCollectionsOperation {
|
|
|
7207
7333
|
* @param direction Specify whether you want the sorting order to be
|
|
7208
7334
|
* `Ascending` or `Descending`.
|
|
7209
7335
|
*
|
|
7336
|
+
* @throws {Error} when called in a React Native environment.
|
|
7337
|
+
*
|
|
7210
7338
|
* @return A {@link PendingCollectionsOperation} that you can chain further
|
|
7211
7339
|
* function calls to.
|
|
7212
7340
|
*/
|
|
@@ -7227,6 +7355,8 @@ class PendingCollectionsOperation {
|
|
|
7227
7355
|
* @param offset The number of collections that you want the eventual
|
|
7228
7356
|
* resulting set of collections to be offset by (and thus not include).
|
|
7229
7357
|
*
|
|
7358
|
+
* @throws {Error} when called in a React Native environment.
|
|
7359
|
+
*
|
|
7230
7360
|
* @return A {@link PendingCollectionsOperation} that you can chain further
|
|
7231
7361
|
* function calls to.
|
|
7232
7362
|
*/
|
|
@@ -7241,6 +7371,8 @@ class PendingCollectionsOperation {
|
|
|
7241
7371
|
*
|
|
7242
7372
|
* @param limit The maximum number of collections that will be returned.
|
|
7243
7373
|
*
|
|
7374
|
+
* @throws {Error} when called in a React Native environment.
|
|
7375
|
+
*
|
|
7244
7376
|
* @return A {@link PendingCollectionsOperation} that you can chain further
|
|
7245
7377
|
* function calls to.
|
|
7246
7378
|
*/
|
|
@@ -7257,6 +7389,8 @@ class PendingCollectionsOperation {
|
|
|
7257
7389
|
* The returned {@link Subscription} object must be kept in scope for as long
|
|
7258
7390
|
* as you want to keep receiving updates.
|
|
7259
7391
|
*
|
|
7392
|
+
* @throws {Error} when called in a React Native environment.
|
|
7393
|
+
*
|
|
7260
7394
|
* @return A {@link Subscription} object that must be kept in scope for as
|
|
7261
7395
|
* long as you want to keep receiving updates from other devices about the
|
|
7262
7396
|
* collections that they know about.
|
|
@@ -7279,6 +7413,8 @@ class PendingCollectionsOperation {
|
|
|
7279
7413
|
* @param handler A closure that will be called every time there is an update
|
|
7280
7414
|
* about the list of known about collections.
|
|
7281
7415
|
*
|
|
7416
|
+
* @throws {Error} when called in a React Native environment.
|
|
7417
|
+
*
|
|
7282
7418
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
7283
7419
|
* as you want to keep receiving updates.
|
|
7284
7420
|
*/
|
|
@@ -7300,6 +7436,8 @@ class PendingCollectionsOperation {
|
|
|
7300
7436
|
* @param handler A closure that will be called every time there is an update
|
|
7301
7437
|
* about the list of known about collections.
|
|
7302
7438
|
*
|
|
7439
|
+
* @throws {Error} when called in a React Native environment.
|
|
7440
|
+
*
|
|
7303
7441
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
7304
7442
|
* as you want to keep receiving updates.
|
|
7305
7443
|
*/
|
|
@@ -7310,6 +7448,8 @@ class PendingCollectionsOperation {
|
|
|
7310
7448
|
* Return the list of collections requested based on the preceding function
|
|
7311
7449
|
* chaining.
|
|
7312
7450
|
*
|
|
7451
|
+
* @throws {Error} when called in a React Native environment.
|
|
7452
|
+
*
|
|
7313
7453
|
* @return A list of {@link Collection}s based on the preceding function
|
|
7314
7454
|
* chaining.
|
|
7315
7455
|
*/
|
|
@@ -7392,6 +7532,8 @@ function collectionsFromDocuments(documents, store) {
|
|
|
7392
7532
|
* or evicting any matching documents.
|
|
7393
7533
|
*
|
|
7394
7534
|
* Live queries and subscriptions are only available outside of transactions.
|
|
7535
|
+
*
|
|
7536
|
+
* Not available in React Native environments.
|
|
7395
7537
|
*/
|
|
7396
7538
|
class WriteTransactionPendingCursorOperation extends BasePendingCursorOperation {
|
|
7397
7539
|
sort(propertyPath, direction = 'ascending') {
|
|
@@ -7509,6 +7651,8 @@ class WriteTransactionPendingIDSpecificOperation extends BasePendingIDSpecificOp
|
|
|
7509
7651
|
*
|
|
7510
7652
|
* Create a `WriteTransactionCollection` by starting a {@link WriteTransaction}
|
|
7511
7653
|
* and using its `scoped` method.
|
|
7654
|
+
*
|
|
7655
|
+
* Not available in React Native environments.
|
|
7512
7656
|
*/
|
|
7513
7657
|
class WriteTransactionCollection {
|
|
7514
7658
|
/**
|
|
@@ -7520,6 +7664,7 @@ class WriteTransactionCollection {
|
|
|
7520
7664
|
* @param query The query to run against the collection.
|
|
7521
7665
|
* @param queryArgs These arguments replace placeholders in the provided
|
|
7522
7666
|
* query.
|
|
7667
|
+
* @throws {Error} when called in a React Native environment.
|
|
7523
7668
|
*/
|
|
7524
7669
|
find(query, queryArgs) {
|
|
7525
7670
|
return new WriteTransactionPendingCursorOperation(query, queryArgs !== null && queryArgs !== void 0 ? queryArgs : null, this);
|
|
@@ -7527,6 +7672,8 @@ class WriteTransactionCollection {
|
|
|
7527
7672
|
/**
|
|
7528
7673
|
* Convenience method, equivalent to calling {@link find | find()} and passing
|
|
7529
7674
|
* the query `"true"`.
|
|
7675
|
+
*
|
|
7676
|
+
* @throws {Error} when called in a React Native environment.
|
|
7530
7677
|
*/
|
|
7531
7678
|
findAll() {
|
|
7532
7679
|
return this.find('true');
|
|
@@ -7538,6 +7685,7 @@ class WriteTransactionCollection {
|
|
|
7538
7685
|
* The returned object can be used to find and return the document. It can also be used to update, remove or evict the document.
|
|
7539
7686
|
*
|
|
7540
7687
|
* @param id The ID of the document to find.
|
|
7688
|
+
* @throws {Error} when called in a React Native environment.
|
|
7541
7689
|
*/
|
|
7542
7690
|
findByID(id) {
|
|
7543
7691
|
const documentID = id instanceof DocumentID ? id : new DocumentID(id);
|
|
@@ -7594,6 +7742,8 @@ class WriteTransaction {
|
|
|
7594
7742
|
* provided to this function. You can create many
|
|
7595
7743
|
* {@link WriteTransactionCollection | collection} objects per
|
|
7596
7744
|
* {@link WriteTransaction} object.
|
|
7745
|
+
*
|
|
7746
|
+
* @throws {Error} when called in a React Native environment.
|
|
7597
7747
|
* */
|
|
7598
7748
|
scoped(toCollectionNamed) {
|
|
7599
7749
|
if (typeof toCollectionNamed !== 'string') {
|
|
@@ -7779,6 +7929,8 @@ class Store {
|
|
|
7779
7929
|
* * it is not empty
|
|
7780
7930
|
* * it does not contain the char '\0'
|
|
7781
7931
|
* * it does not begin with "$TS_"
|
|
7932
|
+
*
|
|
7933
|
+
* @throws {Error} when called in a React Native environment.
|
|
7782
7934
|
*/
|
|
7783
7935
|
collection(name) {
|
|
7784
7936
|
return new Collection(name, this);
|
|
@@ -7789,6 +7941,8 @@ class Store {
|
|
|
7789
7941
|
*
|
|
7790
7942
|
* @return A {@link PendingCollectionsOperation} object that you can use to
|
|
7791
7943
|
* fetch or observe the collections in the store
|
|
7944
|
+
*
|
|
7945
|
+
* @throws {Error} when called in a React Native environment.
|
|
7792
7946
|
*/
|
|
7793
7947
|
collections() {
|
|
7794
7948
|
return new PendingCollectionsOperation(this);
|
|
@@ -7796,6 +7950,8 @@ class Store {
|
|
|
7796
7950
|
/**
|
|
7797
7951
|
* Returns the names of all available collections in the store of the
|
|
7798
7952
|
* related {@link Ditto} instance.
|
|
7953
|
+
*
|
|
7954
|
+
* @throws {Error} when called in a React Native environment.
|
|
7799
7955
|
*/
|
|
7800
7956
|
collectionNames() {
|
|
7801
7957
|
return this.ditto.deferClose((dittoHandle) => {
|
|
@@ -7856,6 +8012,7 @@ class Store {
|
|
|
7856
8012
|
* Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.
|
|
7857
8013
|
*
|
|
7858
8014
|
* @param callback is given access to a {@link WriteTransaction | write transaction object} that can be used to perform operations on the store.
|
|
8015
|
+
* @throws {Error} when called in a React Native environment.
|
|
7859
8016
|
* @returns a list of `WriteTransactionResult`s. There is a result for each operation performed as part of the write transaction.
|
|
7860
8017
|
*/
|
|
7861
8018
|
async write(callback) {
|
|
@@ -8823,7 +8980,7 @@ class Sync {
|
|
|
8823
8980
|
/** @internal */
|
|
8824
8981
|
constructor(ditto) {
|
|
8825
8982
|
/**
|
|
8826
|
-
* All currently active sync subscriptions.
|
|
8983
|
+
* All currently active {@link SyncSubscription | sync subscriptions}.
|
|
8827
8984
|
*
|
|
8828
8985
|
* **Note:** Manage sync subscriptions using
|
|
8829
8986
|
* {@link registerSubscription | registerSubscription()} to register a new
|
|
@@ -9748,7 +9905,7 @@ class Ditto {
|
|
|
9748
9905
|
* disables this behavior, thus allowing the use of an interactive debugger
|
|
9749
9906
|
* without triggering the deadlock detection.
|
|
9750
9907
|
*
|
|
9751
|
-
* This feature is
|
|
9908
|
+
* This feature is only available in Node.js environments.
|
|
9752
9909
|
*/
|
|
9753
9910
|
static disableDeadlockDetection() {
|
|
9754
9911
|
{
|
|
@@ -9770,8 +9927,8 @@ class Ditto {
|
|
|
9770
9927
|
* {@link Ditto.disableDeadlockDetection | Ditto.disableDeadlockDetection()}
|
|
9771
9928
|
* for more information.
|
|
9772
9929
|
*
|
|
9773
|
-
*
|
|
9774
|
-
* is
|
|
9930
|
+
* When called outside of a Node.js environment, this method always returns
|
|
9931
|
+
* `false` as deadlock detection is only available in Node.js.
|
|
9775
9932
|
*
|
|
9776
9933
|
* @returns `true` if deadlock detection is enabled
|
|
9777
9934
|
*/
|
|
@@ -10042,7 +10199,8 @@ class Ditto {
|
|
|
10042
10199
|
* This improves performance of initial sync when this peer has never before
|
|
10043
10200
|
* connected to a Ditto mesh for which sync with v3 peers is disabled.
|
|
10044
10201
|
*
|
|
10045
|
-
* @throws {Error}
|
|
10202
|
+
* @throws {Error} when called in a React Native environment where sync with v3
|
|
10203
|
+
* is always disabled.
|
|
10046
10204
|
*/
|
|
10047
10205
|
async disableSyncWithV3() {
|
|
10048
10206
|
return this.deferCloseAsync(async (dittoHandle) => {
|