@dittolive/ditto 3.0.3 → 4.0.0-beta1

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 CHANGED
@@ -3,10 +3,10 @@
3
3
  *Ditto is a cross platform SDK that allows mobile, web, and IoT apps to sync
4
4
  with and even without connectivity.*
5
5
 
6
- Version: **3.0.3**
6
+ Version: **4.0.0-beta1**
7
7
 
8
8
  Please visit [ditto.live](https://ditto.live) for more info as well as the
9
- [API Reference](https://software.ditto.live/js/Ditto/3.0.3/api-reference/) for this particular version.
9
+ [API Reference](https://software.ditto.live/js/Ditto/4.0.0-beta1/api-reference/) for this particular version.
10
10
 
11
11
  --------------------------------------------------------------------------------
12
12
 
package/node/ditto.cjs.js CHANGED
@@ -368,7 +368,7 @@ function ditto_collection_remove(...args) { return ditto.ditto_collection_remove
368
368
  function ditto_collection_remove_query_str(...args) { return ditto.ditto_collection_remove_query_str(...args) }
369
369
  function ditto_collection_update(...args) { return ditto.ditto_collection_update(...args) }
370
370
  function ditto_collection_update_multiple(...args) { return ditto.ditto_collection_update_multiple(...args) }
371
- function ditto_disable_sync_with_v2(...args) { return ditto.ditto_disable_sync_with_v2(...args) }
371
+ function ditto_disable_sync_with_v3(...args) { return ditto.ditto_disable_sync_with_v3(...args) }
372
372
  function ditto_document_free(...args) { return ditto.ditto_document_free(...args) }
373
373
  function ditto_document_get_cbor_with_path_type(...args) { return ditto.ditto_document_get_cbor_with_path_type(...args) }
374
374
  function ditto_document_id(...args) { return ditto.ditto_document_id(...args) }
@@ -495,19 +495,19 @@ function mdnsServerFreeHandle(handle) {
495
495
  }
496
496
  // ------------------------------------------------------------- Document ------
497
497
  /** @internal */
498
- function documentSetCBORWithTimestamp(document, path, cbor, createPath, timestamp) {
498
+ function documentSetCBORWithTimestamp(document, path, cbor, timestamp) {
499
499
  ensureInitialized();
500
500
  const pathX = bytesFromString(path);
501
- const errorCode = ditto_document_set_cbor_with_timestamp(document, pathX, cbor, createPath, timestamp);
501
+ const errorCode = ditto_document_set_cbor_with_timestamp(document, pathX, cbor, timestamp);
502
502
  if (errorCode !== 0)
503
503
  throw new Error(errorMessage() || `ditto_document_set_cbor_with_timestamp() failed with error code: ${errorCode}`);
504
504
  }
505
505
  /** @internal */
506
- function documentSetCBOR(document, path, cbor, createPath) {
506
+ function documentSetCBOR(document, path, cbor) {
507
507
  ensureInitialized();
508
508
  // NOTE: not sure if this should be async or not.
509
509
  const pathX = bytesFromString(path);
510
- const errorCode = ditto_document_set_cbor(document, pathX, cbor, createPath);
510
+ const errorCode = ditto_document_set_cbor(document, pathX, cbor);
511
511
  if (errorCode !== 0)
512
512
  throw new Error(errorMessage() || `ditto_document_set_cbor() failed with error code: ${errorCode}`);
513
513
  }
@@ -1151,11 +1151,11 @@ function dittoRunGarbageCollection(dittoPointer) {
1151
1151
  return ditto_run_garbage_collection(dittoPointer);
1152
1152
  }
1153
1153
  /** @internal */
1154
- async function dittoDisableSyncWithV2(dittoPointer) {
1154
+ async function dittoDisableSyncWithV3(dittoPointer) {
1155
1155
  ensureInitialized();
1156
- const errorCode = await ditto_disable_sync_with_v2(dittoPointer);
1156
+ const errorCode = await ditto_disable_sync_with_v3(dittoPointer);
1157
1157
  if (errorCode !== 0)
1158
- throw new Error(errorMessage() || `ditto_disable_sync_with_v2() failed with error code: ${errorCode}`);
1158
+ throw new Error(errorMessage() || `ditto_disable_sync_with_v3() failed with error code: ${errorCode}`);
1159
1159
  }
1160
1160
  // ------------------------------------------------------ Hash & Mnemonic ------
1161
1161
  /** @internal */
@@ -1434,7 +1434,7 @@ function awdlDestroy(awdl) {
1434
1434
 
1435
1435
  // NOTE: this is patched up with the actual build version by Jake task
1436
1436
  // build:package and has to be a valid semantic version as defined here: https://semver.org.
1437
- const fullBuildVersionString = '3.0.3';
1437
+ const fullBuildVersionString = '4.0.0-beta1';
1438
1438
 
1439
1439
  //
1440
1440
  /**
@@ -3083,33 +3083,6 @@ class MutableRegister extends Register {
3083
3083
  }
3084
3084
  }
3085
3085
 
3086
- //
3087
- // Copyright © 2022 DittoLive Incorporated. All rights reserved.
3088
- //
3089
- /**
3090
- * Represents a CRDT Replicated Growable Array (RGA).
3091
- *
3092
- * RGAs are deprecated and you should instead use a `Register` containing an
3093
- * array.
3094
- */
3095
- class RGA {
3096
- /** The array representation of the RGA. */
3097
- get value() {
3098
- return this['@ditto.value'];
3099
- }
3100
- /** @internal */
3101
- constructor(array = []) {
3102
- this['@ditto.value'] = array;
3103
- }
3104
- /** @internal */
3105
- static '@ditto.create'(path, value) {
3106
- const rga = new RGA(value);
3107
- rga['@ditto.path'] = path;
3108
- rga['@ditto.value'] = value;
3109
- return rga;
3110
- }
3111
- }
3112
-
3113
3086
  //
3114
3087
  // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3115
3088
  //
@@ -3164,10 +3137,6 @@ function augmentJSONValue(json, mutDoc, workingPath) {
3164
3137
  else if (json[DittoCRDTTypeKey] === DittoCRDTType.register) {
3165
3138
  return Register['@ditto.create'](mutDoc, workingPath, json[DittoCRDTValueKey]);
3166
3139
  }
3167
- else if (json[DittoCRDTTypeKey] === DittoCRDTType.rga) {
3168
- const augmentedValue = augmentJSONValue(json[DittoCRDTValueKey], mutDoc, workingPath);
3169
- return RGA['@ditto.create'](workingPath, augmentedValue);
3170
- }
3171
3140
  else if (json[DittoCRDTTypeKey] === DittoCRDTType.attachment) {
3172
3141
  return new AttachmentToken(json);
3173
3142
  }
@@ -3202,12 +3171,6 @@ function desugarJSObject(jsObj, atRoot = false) {
3202
3171
  registerJSON[DittoCRDTValueKey] = jsObj.value;
3203
3172
  return registerJSON;
3204
3173
  }
3205
- else if (jsObj instanceof RGA) {
3206
- const rgaJSON = {};
3207
- rgaJSON[DittoCRDTTypeKey] = DittoCRDTType.rga;
3208
- rgaJSON[DittoCRDTValueKey] = desugarJSObject(jsObj.value);
3209
- return rgaJSON;
3210
- }
3211
3174
  else if (jsObj instanceof Attachment) {
3212
3175
  const attachmentJSON = {
3213
3176
  _id: jsObj.token.id,
@@ -3450,17 +3413,6 @@ class DocumentPath {
3450
3413
  const underlyingValue = this.underlyingValueForPathType('Register');
3451
3414
  return typeof underlyingValue !== 'undefined' ? Register['@ditto.create'](null, this.path, underlyingValue) : null;
3452
3415
  }
3453
- /**
3454
- * Returns the value at the previously specified key in the document as an
3455
- * {@link RGA} if possible, otherwise returns `null`.
3456
- *
3457
- * @deprecated RGA usage should be replaced. Use arrays inside Registers
3458
- * instead.
3459
- */
3460
- get rga() {
3461
- const underlyingValue = this.underlyingValueForPathType('Rga');
3462
- return typeof underlyingValue !== 'undefined' ? RGA['@ditto.create'](this.path, underlyingValue) : null;
3463
- }
3464
3416
  /**
3465
3417
  * Returns the value at the previously specified key in the document as an
3466
3418
  * {@link AttachmentToken} if possible, otherwise returns `null`.
@@ -3548,21 +3500,6 @@ class MutableDocumentPath {
3548
3500
  const underlyingValue = this.underlyingValueForPathType('Register');
3549
3501
  return typeof underlyingValue !== 'undefined' ? Register['@ditto.create'](this.mutableDocument, this.path, underlyingValue) : null;
3550
3502
  }
3551
- /**
3552
- * Returns the value at the previously specified key in the document as a
3553
- * {@link RGA} if possible, otherwise returns `null`.
3554
- *
3555
- * Note that the returned type, {@link RGA}, is deprecated and does not allow
3556
- * any mutation. RGAs cannot be created or mutated with this version of the
3557
- * SDK; they can only be read and this is for backwards compatibility reasons.
3558
- *
3559
- * @deprecated RGA usage should be replaced. Use arrays inside Registers
3560
- * instead.
3561
- */
3562
- get rga() {
3563
- const underlyingValue = this.underlyingValueForPathType('Rga');
3564
- return typeof underlyingValue !== 'undefined' ? RGA['@ditto.create'](this.path, underlyingValue) : null;
3565
- }
3566
3503
  /**
3567
3504
  * Returns the value at the previously specified key in the document as a
3568
3505
  * {@link AttachmentToken} if possible, otherwise returns `null`.
@@ -3584,8 +3521,6 @@ class MutableDocumentPath {
3584
3521
  }
3585
3522
  /**
3586
3523
  * Removes a value at the document's key-path defined by the receiver.
3587
- * If removing an index from an `RGA`, any subsequent indexes will be shifted
3588
- * left to fill the gap.
3589
3524
  */
3590
3525
  remove() {
3591
3526
  return this['@ditto.remove']();
@@ -3619,10 +3554,10 @@ class MutableDocumentPath {
3619
3554
  const valueJSON = desugarJSObject(value, false);
3620
3555
  const valueCBOR = CBOR.encode(valueJSON);
3621
3556
  if (isDefault) {
3622
- documentSetCBORWithTimestamp(documentX, this.path, valueCBOR, true, 0);
3557
+ documentSetCBORWithTimestamp(documentX, this.path, valueCBOR, 0);
3623
3558
  }
3624
3559
  else {
3625
- documentSetCBOR(documentX, this.path, valueCBOR, true);
3560
+ documentSetCBOR(documentX, this.path, valueCBOR);
3626
3561
  }
3627
3562
  // HACK: we need a copy of value because the original value can be mutated
3628
3563
  // later on and an update result needs the state of the value at this
@@ -4957,18 +4892,19 @@ class PendingCollectionsOperation {
4957
4892
  // ----------------------------------------------------------- Internal ------
4958
4893
  /** @internal */
4959
4894
  _observe(handler, createSubscription, waitForNextSignal) {
4960
- const weakThis = new WeakRef(this);
4895
+ const weakStore = new WeakRef(this.store);
4961
4896
  const collectionsObservationHandler = function (documents, event, nextSignal) {
4962
- const strongThis = weakThis.deref();
4963
- if (strongThis === null)
4897
+ const strongStore = weakStore.deref();
4898
+ if (!strongStore) {
4964
4899
  return;
4965
- const collections = collectionsFromDocuments(documents, strongThis.store);
4900
+ }
4901
+ const collections = collectionsFromDocuments(documents, strongStore);
4966
4902
  let collEvent;
4967
4903
  if (event.isInitial === true) {
4968
4904
  collEvent = CollectionsEvent.initial(collections);
4969
4905
  }
4970
4906
  else {
4971
- const oldCollections = collectionsFromDocuments(event.oldDocuments, strongThis.store);
4907
+ const oldCollections = collectionsFromDocuments(event.oldDocuments, strongStore);
4972
4908
  collEvent = new CollectionsEvent({
4973
4909
  isInitial: false,
4974
4910
  collections,
@@ -5894,16 +5830,16 @@ class Ditto {
5894
5830
  }
5895
5831
  /**
5896
5832
  * Explicitly opt-in to disabling the ability to sync with Ditto peers running
5897
- * any version of the SDK in the v2 series of releases.
5833
+ * any version of the SDK in the v3 (or lower) series of releases.
5898
5834
  *
5899
5835
  * Assuming this succeeds then this peer will only be able to sync with other
5900
- * peers using SDKs in the v3 series of releases. Note that this disabling of
5901
- * sync spreads to peers that sync with a peer that has disabled, or has
5902
- * (transitively) had disabled, syncing with v2 SDK peers.
5836
+ * peers using SDKs in the v4 (or higher) series of releases. Note that this
5837
+ * disabling of sync spreads to peers that sync with a peer that has disabled,
5838
+ * or has (transitively) had disabled, syncing with v3 SDK peers.
5903
5839
  */
5904
- disableSyncWithV2() {
5840
+ disableSyncWithV3() {
5905
5841
  const dittoPointer = dittoBridge.pointerFor(this);
5906
- dittoDisableSyncWithV2(dittoPointer);
5842
+ dittoDisableSyncWithV3(dittoPointer);
5907
5843
  }
5908
5844
  authClientValidityChanged(isWebValid, isX509Valid) {
5909
5845
  const transportConfig = this.transportConfig;
@@ -6048,7 +5984,6 @@ exports.PendingCollectionsOperation = PendingCollectionsOperation;
6048
5984
  exports.PendingCursorOperation = PendingCursorOperation;
6049
5985
  exports.PendingIDSpecificOperation = PendingIDSpecificOperation;
6050
5986
  exports.Presence = Presence;
6051
- exports.RGA = RGA;
6052
5987
  exports.Register = Register;
6053
5988
  exports.SingleDocumentLiveQueryEvent = SingleDocumentLiveQueryEvent;
6054
5989
  exports.Store = Store;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dittolive/ditto",
3
- "version": "3.0.3",
3
+ "version": "4.0.0-beta1",
4
4
  "description": "Ditto is a cross-platform embeddable NoSQL database that can sync with or without an internet connection.",
5
5
  "homepage": "https://ditto.live",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
package/types/ditto.d.ts CHANGED
@@ -637,25 +637,6 @@ declare class MutableRegister extends Register {
637
637
  constructor(value: any);
638
638
  }
639
639
 
640
- /**
641
- * Represents a CRDT Replicated Growable Array (RGA).
642
- *
643
- * RGAs are deprecated and you should instead use a `Register` containing an
644
- * array.
645
- */
646
- declare class RGA {
647
- /** The array representation of the RGA. */
648
- get value(): any[];
649
- /** @internal */
650
- private constructor();
651
- /** @internal */
652
- static '@ditto.create'(path: any, value: any): RGA;
653
- /** @internal */
654
- protected '@ditto.path': any;
655
- /** @internal */
656
- protected '@ditto.value': any;
657
- }
658
-
659
640
  /**
660
641
  * Serves as a token for a specific attachment that you can pass to a call to
661
642
  * {@link Collection.fetchAttachment | fetchAttachment()} on a
@@ -723,14 +704,6 @@ declare class DocumentPath {
723
704
  * {@link Register} if possible, otherwise returns `null`.
724
705
  */
725
706
  get register(): Register | null;
726
- /**
727
- * Returns the value at the previously specified key in the document as an
728
- * {@link RGA} if possible, otherwise returns `null`.
729
- *
730
- * @deprecated RGA usage should be replaced. Use arrays inside Registers
731
- * instead.
732
- */
733
- get rga(): RGA | null;
734
707
  /**
735
708
  * Returns the value at the previously specified key in the document as an
736
709
  * {@link AttachmentToken} if possible, otherwise returns `null`.
@@ -787,18 +760,6 @@ declare class MutableDocumentPath {
787
760
  * {@link MutableRegister} if possible, otherwise returns `null`.
788
761
  */
789
762
  get register(): MutableRegister | null;
790
- /**
791
- * Returns the value at the previously specified key in the document as a
792
- * {@link RGA} if possible, otherwise returns `null`.
793
- *
794
- * Note that the returned type, {@link RGA}, is deprecated and does not allow
795
- * any mutation. RGAs cannot be created or mutated with this version of the
796
- * SDK; they can only be read and this is for backwards compatibility reasons.
797
- *
798
- * @deprecated RGA usage should be replaced. Use arrays inside Registers
799
- * instead.
800
- */
801
- get rga(): RGA | null;
802
763
  /**
803
764
  * Returns the value at the previously specified key in the document as a
804
765
  * {@link AttachmentToken} if possible, otherwise returns `null`.
@@ -815,8 +776,6 @@ declare class MutableDocumentPath {
815
776
  set(value: any, isDefault?: boolean): void;
816
777
  /**
817
778
  * Removes a value at the document's key-path defined by the receiver.
818
- * If removing an index from an `RGA`, any subsequent indexes will be shifted
819
- * left to fill the gap.
820
779
  */
821
780
  remove(): void;
822
781
  /** @internal */
@@ -2312,14 +2271,14 @@ declare class Ditto {
2312
2271
  runGarbageCollection(): void;
2313
2272
  /**
2314
2273
  * Explicitly opt-in to disabling the ability to sync with Ditto peers running
2315
- * any version of the SDK in the v2 series of releases.
2274
+ * any version of the SDK in the v3 (or lower) series of releases.
2316
2275
  *
2317
2276
  * Assuming this succeeds then this peer will only be able to sync with other
2318
- * peers using SDKs in the v3 series of releases. Note that this disabling of
2319
- * sync spreads to peers that sync with a peer that has disabled, or has
2320
- * (transitively) had disabled, syncing with v2 SDK peers.
2277
+ * peers using SDKs in the v4 (or higher) series of releases. Note that this
2278
+ * disabling of sync spreads to peers that sync with a peer that has disabled,
2279
+ * or has (transitively) had disabled, syncing with v3 SDK peers.
2321
2280
  */
2322
- disableSyncWithV2(): void;
2281
+ disableSyncWithV3(): void;
2323
2282
  /** @internal */
2324
2283
  keepAlive: KeepAlive;
2325
2284
  private sync;
@@ -2640,5 +2599,5 @@ declare class CBOR {
2640
2599
  static decode(data: Uint8Array): any;
2641
2600
  }
2642
2601
 
2643
- export { Address, Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, CBOR, Collection, CollectionsEvent, CollectionsEventParams, CollectionsObservationHandler, ConditionSource, Connection, ConnectionType, Counter, CustomLogCallback, Ditto, Document, DocumentID, DocumentIDValue, DocumentPath, DocumentValue, Identity, IdentityManual, IdentityOfflinePlayground, IdentityOnlinePlayground, IdentityOnlineWithAuthentication, IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, InitOptions, KeepAlive, LiveQuery, LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, LiveQueryEventUpdateParams, LiveQueryMove, LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, ObserverOptions, OnlineAuthenticator, Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, PresenceConnectionType, PresenceGraph, QueryArguments, QueryObservationHandler, RGA, Register, RemotePeer, SingleDocumentLiveQueryEvent, SingleObservationHandler, SortDirection, Store, Subscription, TransportCondition, TransportConfig, TransportConfigConnect, TransportConfigGlobal, TransportConfigLan, TransportConfigListen, TransportConfigListenHTTP, TransportConfigListenTCP, TransportConfigPeerToPeer, UpdateResult, UpdateResultType, UpdateResultsMap, UpsertOptions, Value, WebAssemblyModule, WriteStrategy, addressToString, attachmentBridge, dittoBridge, documentBridge, init, mutableDocumentBridge, validateDocumentIDCBOR, validateDocumentIDValue };
2602
+ export { Address, Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, CBOR, Collection, CollectionsEvent, CollectionsEventParams, CollectionsObservationHandler, ConditionSource, Connection, ConnectionType, Counter, CustomLogCallback, Ditto, Document, DocumentID, DocumentIDValue, DocumentPath, DocumentValue, Identity, IdentityManual, IdentityOfflinePlayground, IdentityOnlinePlayground, IdentityOnlineWithAuthentication, IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, InitOptions, KeepAlive, LiveQuery, LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, LiveQueryEventUpdateParams, LiveQueryMove, LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, ObserverOptions, OnlineAuthenticator, Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, PresenceConnectionType, PresenceGraph, QueryArguments, QueryObservationHandler, Register, RemotePeer, SingleDocumentLiveQueryEvent, SingleObservationHandler, SortDirection, Store, Subscription, TransportCondition, TransportConfig, TransportConfigConnect, TransportConfigGlobal, TransportConfigLan, TransportConfigListen, TransportConfigListenHTTP, TransportConfigListenTCP, TransportConfigPeerToPeer, UpdateResult, UpdateResultType, UpdateResultsMap, UpsertOptions, Value, WebAssemblyModule, WriteStrategy, addressToString, attachmentBridge, dittoBridge, documentBridge, init, mutableDocumentBridge, validateDocumentIDCBOR, validateDocumentIDValue };
2644
2603
  //# sourceMappingURL=ditto.d.ts.map