@dittolive/ditto 4.12.0 → 5.0.0-experimental.js-cocoapods-publishing.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/types/ditto.d.ts CHANGED
@@ -693,7 +693,7 @@ declare class Authenticator {
693
693
  /** @internal */
694
694
  constructor(keepAlive: KeepAlive);
695
695
  /** @internal */
696
- '@ditto.authenticationExpiring'(secondsRemaining: number): void;
696
+ '@ditto.authenticationExpiring'(number: any): void;
697
697
  /** @internal */
698
698
  close(): void;
699
699
  /** @internal */
@@ -4421,7 +4421,6 @@ type Connection = {
4421
4421
  * and stable for any two peers.
4422
4422
  */
4423
4423
  peerKeyString2: string;
4424
- approximateDistanceInMeters?: number;
4425
4424
  };
4426
4425
  /**
4427
4426
  * The operating system a peer is running on, if known.
@@ -4647,28 +4646,53 @@ declare class Presence {
4647
4646
  *
4648
4647
  * Create a sync subscription by calling
4649
4648
  * {@link Sync.registerSubscription | `ditto.sync.registerSubscription()`}.
4650
- *
4651
- * @template T The type of query arguments passed to the sync subscription.
4652
4649
  */
4653
- declare class SyncSubscription<T extends DQLQueryArguments = DQLQueryArguments> {
4650
+ declare class SyncSubscription {
4654
4651
  /**
4655
4652
  * Documents matching this query will be included in the sync subscription.
4656
4653
  */
4657
- readonly queryString: string;
4654
+ get queryString(): string;
4658
4655
  /**
4659
- * The query arguments of the sync subscription (as passed when
4660
- * adding it to the store).
4656
+ * The query arguments of the sync subscription (as passed when adding it to
4657
+ * the store).
4658
+ *
4659
+ * Note that this value is not guaranteed to be strictly equal to the value
4660
+ * used when registering the sync subscription. In particular, any
4661
+ * {@link Attachment} values in query arguments will be represented by that
4662
+ * attachment's {@link AttachmentToken} here.
4663
+ *
4664
+ * Also see {@link queryArgumentsCBORData} and
4665
+ * {@link queryArgumentsJSONString} for the raw serialized representations of
4666
+ * the query arguments.
4661
4667
  */
4662
- readonly queryArguments?: Readonly<T>;
4668
+ get queryArguments(): Readonly<any> | undefined;
4663
4669
  /**
4664
- * The {@link Ditto} instance this sync subscription belongs to.
4670
+ * The query arguments of the sync subscription, serialized as CBOR, (as
4671
+ * passed when adding it to the store).
4672
+ *
4673
+ * Note that any {@link Attachment} values passed in as query arguments when
4674
+ * creating this sync subscription will be represented by that attachment's
4675
+ * {@link AttachmentToken} here.
4665
4676
  */
4666
- readonly ditto: Ditto;
4677
+ get queryArgumentsCBORData(): Uint8Array | undefined;
4678
+ /**
4679
+ * The query arguments of the sync subscription, serialized as JSON, (as
4680
+ * passed when adding it to the store).
4681
+ *
4682
+ * Note that any {@link Attachment} values passed in as query arguments when
4683
+ * creating this sync subscription will be represented by that attachment's
4684
+ * {@link AttachmentToken} here.
4685
+ */
4686
+ get queryArgumentsJSONString(): string | undefined;
4667
4687
  /**
4668
4688
  * `true` when the sync subscription has been cancelled or the {@link Ditto}
4669
4689
  * instance managing this subscription has been closed.
4670
4690
  */
4671
4691
  get isCancelled(): boolean;
4692
+ /**
4693
+ * The {@link Ditto} instance this sync subscription belongs to.
4694
+ */
4695
+ readonly ditto: Ditto;
4672
4696
  /**
4673
4697
  * Cancels the sync subscription and unregisters it. No-op
4674
4698
  * if the sync subscription has already been cancelled or the {@link Ditto}
@@ -4676,22 +4700,8 @@ declare class SyncSubscription<T extends DQLQueryArguments = DQLQueryArguments>
4676
4700
  */
4677
4701
  cancel(): void;
4678
4702
  /** @internal */
4679
- constructor(ditto: Ditto, query: string, queryArguments: T | null, queryArgumentsCBOR: Uint8Array | null);
4680
- /**
4681
- * The CBOR-encoded query arguments, or `null` if no query arguments were
4682
- * passed in.
4683
- *
4684
- * @internal
4685
- */
4686
- readonly queryArgumentsCBOR: Uint8Array | null;
4687
- /**
4688
- * `true` when the sync subscription has been cancelled.
4689
- *
4690
- * We mark the sync subscription as cancelled here as an optimization to avoid
4691
- * a scan of all subscriptions in the store whenever the `isCancelled`
4692
- * property is checked.
4693
- */
4694
- private _isCancelled;
4703
+ constructor(ditto: Ditto);
4704
+ private deref;
4695
4705
  }
4696
4706
 
4697
4707
  /**
@@ -4713,7 +4723,7 @@ declare class Sync {
4713
4723
  * {@link SyncSubscription.cancel | SyncSubscription.cancel()} to remove an
4714
4724
  * existing sync subscription.
4715
4725
  */
4716
- readonly subscriptions: Readonly<Array<SyncSubscription<any>>>;
4726
+ get subscriptions(): Readonly<Array<SyncSubscription>>;
4717
4727
  /**
4718
4728
  * Returns `true` if sync is active, otherwise returns `false`. Use
4719
4729
  * {@link Sync.start | ditto.sync.start()} to activate and
@@ -4764,7 +4774,6 @@ declare class Sync {
4764
4774
  * @param query a string containing a valid query expressed in DQL.
4765
4775
  * @param queryArguments an object containing the arguments for the query.
4766
4776
  * Example: `{mileage: 123}` for a query with `:mileage` placeholder.
4767
- * @template T The type of the query arguments.
4768
4777
  * @returns An active `SyncSubscription` for the passed in query and
4769
4778
  * arguments. It will remain active until it is
4770
4779
  * {@link SyncSubscription.cancel | cancelled} or the {@link Ditto} instance
@@ -4777,26 +4786,9 @@ declare class Sync {
4777
4786
  * `SELECT` query.
4778
4787
  * @throws {@link DittoError} may throw other errors.
4779
4788
  */
4780
- registerSubscription<T extends DQLQueryArguments = DQLQueryArguments>(query: string, queryArguments?: T): SyncSubscription<T>;
4789
+ registerSubscription(query: string, queryArguments?: DQLQueryArguments): SyncSubscription;
4781
4790
  /** @internal */
4782
4791
  constructor(ditto: Ditto);
4783
- /**
4784
- * Removes the passed in `syncSubscription`, configuring Ditto to not receive
4785
- * updates for documents matching the corresponding query anymore. No-op if
4786
- * the passed in `syncSubscription` has already been removed.
4787
- *
4788
- * This must only be called by the sync subscription itself.
4789
- *
4790
- * @param syncSubscription the sync subscription to remove
4791
- * @returns `true` if the passed in sync subscription could be found and has
4792
- * been removed, otherwise returns `false`.
4793
- * @throws {@link DittoError} `internal`: if the replication subscription does not
4794
- * belong to this store
4795
- * @throws {@link DittoError} `internal`: if the replication subscription has not
4796
- * been cancelled yet
4797
- * @internal
4798
- */
4799
- unregisterSubscription(syncSubscription: SyncSubscription): boolean;
4800
4792
  /** @internal */
4801
4793
  close(): void;
4802
4794
  }
@@ -5430,6 +5422,8 @@ declare class Bridge<T extends object, FFIType> {
5430
5422
  /** @internal */
5431
5423
  static readonly differ: Bridge<Differ, "dittoffi_differ_t">;
5432
5424
  /** @internal */
5425
+ static readonly syncSubscription: Bridge<SyncSubscription, "dittoffi_sync_subscription_t">;
5426
+ /** @internal */
5433
5427
  static readonly ditto: Bridge<Ditto, "CDitto_t">;
5434
5428
  private internalType;
5435
5429
  /**
@@ -5463,8 +5457,6 @@ type PresenceConnectionType = 'WiFi' | 'WebSocket' | 'AWDL' | 'BLE';
5463
5457
  type RemotePeer = {
5464
5458
  networkID: string;
5465
5459
  deviceName: string;
5466
- rssi?: number;
5467
- approximateDistanceInMeters?: number;
5468
5460
  connections: PresenceConnectionType[];
5469
5461
  };
5470
5462
  /**
@@ -5865,20 +5857,6 @@ declare class Ditto {
5865
5857
  * @deprecated use {@link Sync.stop | ditto.sync.stop()} instead.
5866
5858
  */
5867
5859
  stopSync(): void;
5868
- /**
5869
- * Registers an observer for info about Ditto peers in range of this device.
5870
- *
5871
- * Ditto will prevent the process from exiting as long as there are active
5872
- * peers observers (not relevant when running in the browser).
5873
- *
5874
- * @param callback called immediately with the current state of peers
5875
- * in range and whenever that state changes. Then it will be invoked
5876
- * repeatedly when Ditto devices come and go, or the active connections to
5877
- * them change.
5878
- *
5879
- * @deprecated please use {@link Presence.observe | presence.observe()} instead.
5880
- */
5881
- observePeers(callback: (peersData: RemotePeer[]) => void): Observer;
5882
5860
  /**
5883
5861
  * Register observer for changes of underlying transport conditions.
5884
5862
  *
@@ -5980,7 +5958,6 @@ declare class Ditto {
5980
5958
  */
5981
5959
  deferCloseAsync<T>(closure: (dittoHandle: Handle<Ditto, FFIDitto>) => Promise<T>): Promise<T>;
5982
5960
  private deferCloseAllowed;
5983
- private presenceManager;
5984
5961
  private transportConditionsManager;
5985
5962
  private _isClosed;
5986
5963
  /** Set of pending operations that need to complete before the Ditto instance can be closed in a safe manner. */
@@ -6129,7 +6106,7 @@ type DQLQueryArguments = {
6129
6106
  /**
6130
6107
  * Individual value in a {@link DQLQueryArguments} object.
6131
6108
  */
6132
- type DQLQueryArgumentValue = string | number | boolean | Uint8Array | null | Attachment | DocumentID | DQLQueryArgumentValue[] | {
6109
+ type DQLQueryArgumentValue = string | number | boolean | Uint8Array | null | Attachment | AttachmentToken | DocumentID | DQLQueryArgumentValue[] | {
6133
6110
  [key: string]: DQLQueryArgumentValue;
6134
6111
  };
6135
6112
 
@@ -6354,6 +6331,8 @@ declare class CBOR {
6354
6331
  /** @internal */
6355
6332
  static encode(data: any): Uint8Array;
6356
6333
  /** @internal */
6334
+ static encodeWithReplacer(data: any, replacer: (key: any, value: any) => any): Uint8Array;
6335
+ /** @internal */
6357
6336
  static decode(data: Uint8Array, reviver?: (key: any, value: any) => any): any;
6358
6337
  }
6359
6338