@dittolive/ditto 4.10.2 → 4.11.0-preview.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 (44) hide show
  1. package/DittoReactNative.podspec +1 -17
  2. package/README.md +4 -80
  3. package/node/ditto.cjs.js +444 -81
  4. package/node/ditto.darwin-arm64.node +0 -0
  5. package/node/ditto.darwin-x64.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/package.json +1 -1
  10. package/react-native/android/build.gradle +29 -34
  11. package/react-native/android/cpp-adapter.cpp +10 -11
  12. package/react-native/android/dittoffi/src/ditto_transaction.cpp +1 -0
  13. package/react-native/android/dittoffi/src/ditto_transaction.h +91 -0
  14. package/react-native/android/dittoffi/src/dittoffi.h +587 -390
  15. package/react-native/android/dittoffi/src/dittoffi_java.cpp +3360 -1358
  16. package/react-native/android/dittoffi/src/dittoffi_java.h +59 -10
  17. package/react-native/android/dittoffi/src/dittoffi_java.i +2 -0
  18. package/react-native/android/dittoffi/src/dittostore_java.i +48 -0
  19. package/react-native/android/dittoffi/src/mesh_java_interfaces.h +81 -109
  20. package/react-native/android/gradle.properties +6 -5
  21. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.kt +23 -15
  22. package/react-native/cpp/include/DQL.h +1 -0
  23. package/react-native/cpp/include/Differ.h +14 -0
  24. package/react-native/cpp/include/Lifecycle.h +1 -1
  25. package/react-native/cpp/include/Transaction.h +18 -0
  26. package/react-native/cpp/include/Transports.h +1 -0
  27. package/react-native/cpp/include/Utils.h +27 -3
  28. package/react-native/cpp/include/main.h +2 -0
  29. package/react-native/cpp/src/DQL.cpp +21 -0
  30. package/react-native/cpp/src/Differ.cpp +57 -0
  31. package/react-native/cpp/src/Lifecycle.cpp +17 -7
  32. package/react-native/cpp/src/Misc.cpp +50 -32
  33. package/react-native/cpp/src/Transaction.cpp +195 -0
  34. package/react-native/cpp/src/Transports.cpp +77 -1
  35. package/react-native/cpp/src/Utils.cpp +11 -0
  36. package/react-native/cpp/src/main.cpp +18 -1
  37. package/react-native/ditto.es6.js +1 -1
  38. package/react-native/ios/DittoRNSDK.mm +2 -4
  39. package/types/ditto.d.ts +271 -33
  40. package/web/ditto.es6.js +1 -1
  41. package/web/ditto.umd.js +1 -1
  42. package/web/ditto.wasm +0 -0
  43. package/react-native/ios/YeetJSIUtils.h +0 -60
  44. package/react-native/ios/YeetJSIUtils.mm +0 -196
@@ -1,9 +1,7 @@
1
1
  #import <React/RCTBridge+Private.h>
2
2
  #import <ReactCommon/CallInvoker.h>
3
3
  #import "DittoRNSDK.h"
4
- #import "TypedArray.hpp"
5
4
  #import "main.h"
6
- #import "YeetJSIUtils.h"
7
5
 
8
6
  using namespace facebook::jsi;
9
7
 
@@ -41,7 +39,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
41
39
  return @true;
42
40
  }
43
41
 
44
- static void install(jsi::Runtime &jsiRuntime) {
42
+ static void install(Runtime &jsiRuntime) {
45
43
  auto defaultDeviceName = Function::createFromHostFunction(jsiRuntime,
46
44
  PropNameID::forAscii(jsiRuntime,
47
45
  "defaultDeviceName"),
@@ -51,7 +49,7 @@ static void install(jsi::Runtime &jsiRuntime) {
51
49
  const Value *arguments,
52
50
  size_t count) -> Value {
53
51
 
54
- return convertNSStringToJSIString(runtime, [[UIDevice currentDevice] name]);
52
+ return String::createFromUtf8(runtime, [[[UIDevice currentDevice] name] UTF8String]);
55
53
  });
56
54
 
57
55
  jsiRuntime.global().setProperty(jsiRuntime, "defaultDeviceName", std::move(defaultDeviceName));
package/types/ditto.d.ts CHANGED
@@ -115,7 +115,7 @@ declare class Observer {
115
115
  *
116
116
  * @internal
117
117
  */
118
- type FFIResultErrorCode = 'ActivationLicenseTokenExpired' | 'ActivationLicenseTokenInvalid' | 'ActivationLicenseUnsupportedFutureVersion' | 'ActivationNotActivated' | 'ActivationUnnecessary' | 'Base64Invalid' | 'CborInvalid' | 'CborUnsupported' | 'Crdt' | 'DqlEvaluationError' | 'DqlInvalidQueryArgs' | 'DqlQueryCompilation' | 'DqlUnsupported' | 'IoAlreadyExists' | 'IoNotFound' | 'IoOperationFailed' | 'IoPermissionDenied' | 'JsFloatingStoreOperation' | 'LockedDittoWorkingDirectory' | 'ParameterQuery' | 'StoreDatabase' | 'StoreDocumentId' | 'StoreDocumentNotFound' | 'StoreQuery' | 'Transport' | 'Unknown' | 'Unsupported' | 'ValidationDepthLimitExceeded' | 'ValidationInvalidCbor' | 'ValidationInvalidJson' | 'ValidationNotAMap' | 'ValidationInvalidTransportConfig' | 'ValidationSizeLimitExceeded';
118
+ type FFIResultErrorCode = 'ActivationLicenseTokenExpired' | 'ActivationLicenseTokenInvalid' | 'ActivationLicenseUnsupportedFutureVersion' | 'ActivationNotActivated' | 'ActivationUnnecessary' | 'Base64Invalid' | 'CborInvalid' | 'CborUnsupported' | 'Crdt' | 'DifferIdentityKeyPathInvalid' | 'DqlEvaluationError' | 'DqlInvalidQueryArgs' | 'DqlQueryCompilation' | 'DqlUnsupported' | 'IoAlreadyExists' | 'IoNotFound' | 'IoOperationFailed' | 'IoPermissionDenied' | 'JsFloatingStoreOperation' | 'LockedDittoWorkingDirectory' | 'EncryptionExtraneousPassphraseGiven' | 'ParameterQuery' | 'StoreDatabase' | 'StoreDocumentId' | 'StoreDocumentNotFound' | 'StoreTransactionReadOnly' | 'StoreQuery' | 'Transport' | 'Unknown' | 'Unsupported' | 'ValidationDepthLimitExceeded' | 'ValidationInvalidCbor' | 'ValidationInvalidJson' | 'ValidationNotAMap' | 'ValidationInvalidTransportConfig' | 'ValidationSizeLimitExceeded';
119
119
  /**
120
120
  * Represents an exception that occurred during a call into the Ditto FFI.
121
121
  *
@@ -159,8 +159,12 @@ declare const DittoCRDTTypeKey = "_ditto_internal_type_jkb12973t4b";
159
159
  /** @internal */
160
160
  type FFIAuthenticationStatus = 'dittoffi_authentication_status_t';
161
161
  /** @internal */
162
+ type FFIQueryResultItem = 'dittoffi_query_result_item_t';
163
+ /** @internal */
162
164
  type FFIQueryResult = 'dittoffi_query_result_t';
163
165
  /** @internal */
166
+ type FFIDiffer = 'dittoffi_differ_t';
167
+ /** @internal */
164
168
  type FFIWriteTransaction = 'CWriteTransaction_t';
165
169
  /** @internal */
166
170
  type FFIDitto = 'CDitto_t';
@@ -2117,6 +2121,10 @@ declare class QueryResultItem<T = any> {
2117
2121
  private materializedValue;
2118
2122
  /** @internal */
2119
2123
  constructor();
2124
+ /** @internal */
2125
+ static fromJSON(jsonData: string): QueryResultItem<any>;
2126
+ /** @internal */
2127
+ deref(): Pointer<FFIQueryResultItem>;
2120
2128
  }
2121
2129
 
2122
2130
  /**
@@ -2439,6 +2447,103 @@ declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
2439
2447
  private readonly pendingCursorOperation;
2440
2448
  }
2441
2449
 
2450
+ /**
2451
+ * Defines the interface for executing DQL queries. Implemented by
2452
+ * {@link Store | Store} and {@link Transaction | Transaction}.
2453
+ */
2454
+ interface QueryExecuting {
2455
+ /**
2456
+ * Executes a DQL query and returns matching items as a query result.
2457
+ *
2458
+ * **Note:** only returns results from the local store without waiting for any
2459
+ * {@link SyncSubscription | sync subscriptions} to have caught up with the
2460
+ * latest changes. Only use this method if your program must proceed with
2461
+ * immediate results. Use a {@link StoreObserver | store observer} to receive
2462
+ * updates to query results as soon as they have been synced to this peer.
2463
+ *
2464
+ * @param query A string containing a valid query expressed in DQL.
2465
+ * @param args An object of values keyed by the placeholder name
2466
+ * without the leading `:`. Example: `{ "name": "John" }` for a query like
2467
+ * `SELECT * FROM people WHERE name = :name`.
2468
+ * @template T The type of items returned by the query. This is a convenience
2469
+ * type that is neither inferred from the `query` parameter nor validated
2470
+ * against it.
2471
+ * @template U The type of the query arguments
2472
+ * @returns A promise for a {@link QueryResult} containing a
2473
+ * {@link QueryResultItem} for each match.
2474
+ * @throws {@link DittoError} `query/invalid`: if `query` argument is not a
2475
+ * string or not valid DQL.
2476
+ * @throws {@link DittoError} `query/arguments-invalid`: if `args`
2477
+ * argument is invalid (e.g. contains unsupported types).
2478
+ * @throws {@link DittoError} `transaction-read-only`: if a mutating DQL query
2479
+ * was attempted using a read-only transaction. (only for
2480
+ * the `transaction.execute()` API).
2481
+ * @throws {@link DittoError} may throw other errors.
2482
+ */
2483
+ execute<T = any, U extends DQLQueryArguments = DQLQueryArguments>(query: string, args?: U): Promise<QueryResult<T>>;
2484
+ }
2485
+
2486
+ /** Encapsulates information about a transaction.
2487
+ *
2488
+ * @see {@link Store.transaction | ditto.store.transaction()}
2489
+ */
2490
+ declare class TransactionInfo {
2491
+ /** A globally unique ID of the transaction. */
2492
+ id: string;
2493
+ /**
2494
+ * The user hint passed when creating the transaction, useful
2495
+ * for debugging and testing.
2496
+ */
2497
+ hint?: string;
2498
+ /**
2499
+ * Indicates whether mutating DQL statements can be executed in the
2500
+ * transaction. Defaults to `false`.
2501
+ */
2502
+ isReadOnly: boolean;
2503
+ constructor(id: string, isReadOnly: boolean, hint?: string);
2504
+ }
2505
+ /**
2506
+ * Represents an action that completes a transaction, by either committing it or
2507
+ * rolling it back.
2508
+ */
2509
+ type TransactionCompletionAction = 'commit' | 'rollback';
2510
+ /**
2511
+ * Represents a transaction in the Ditto store.
2512
+ *
2513
+ * A `Transaction` groups multiple operations into a single atomic unit,
2514
+ * ensuring that all operations within the transaction are either fully applied
2515
+ * or not applied at all, thereby maintaining data integrity.
2516
+ *
2517
+ * For more information on creating and using transactions, refer to the
2518
+ * {@link Store.transaction | ditto.store.transaction()} method. For a comprehensive guide on
2519
+ * transactions, please visit the
2520
+ * [Ditto documentation](https://docs.ditto.live/sdk/latest/crud/transactions).
2521
+ */
2522
+ declare class Transaction implements QueryExecuting {
2523
+ /** The store this transaction belongs to. */
2524
+ readonly store: Store;
2525
+ constructor(store: Store);
2526
+ /** Provides information about the current transaction. */
2527
+ get info(): TransactionInfo;
2528
+ execute<T = any, U extends DQLQueryArguments = DQLQueryArguments>(query: string, queryArguments?: U): Promise<QueryResult<T>>;
2529
+ /** @internal */
2530
+ complete(action: TransactionCompletionAction): Promise<TransactionCompletionAction>;
2531
+ }
2532
+
2533
+ /**
2534
+ * Interface representing options for a transaction.
2535
+ */
2536
+ type TransactionOptions = {
2537
+ /**
2538
+ * Indicates whether the transaction is read-only. Defaults to `false`.
2539
+ */
2540
+ isReadOnly?: boolean;
2541
+ /**
2542
+ * A hint for the transaction, useful for debugging and testing.
2543
+ * Defaults to `null`.
2544
+ */
2545
+ hint?: string;
2546
+ };
2442
2547
  /**
2443
2548
  * The entrypoint for all actions that relate to data stored by Ditto. Provides
2444
2549
  * access to collections, a write transaction API, and a query hash API.
@@ -2446,7 +2551,7 @@ declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
2446
2551
  * You don't create one directly but can access it from a particular
2447
2552
  * {@link Ditto} instance via its {@link Ditto.store | store} property.
2448
2553
  */
2449
- declare class Store {
2554
+ declare class Store implements QueryExecuting {
2450
2555
  /** The {@link Ditto} instance this store belongs to. */
2451
2556
  readonly ditto: Ditto;
2452
2557
  /**
@@ -2467,6 +2572,8 @@ declare class Store {
2467
2572
  * an existing attachment fetch.
2468
2573
  */
2469
2574
  readonly attachmentFetchers: Readonly<Array<AttachmentFetcher>>;
2575
+ /** @internal */
2576
+ get transactions(): TransactionInfo[];
2470
2577
  /**
2471
2578
  * Register a handler to be called whenever a query's results change in the
2472
2579
  * local store.
@@ -2567,31 +2674,6 @@ declare class Store {
2567
2674
  * @throws {Error} when called in a React Native environment.
2568
2675
  */
2569
2676
  collectionNames(): Promise<string[]>;
2570
- /**
2571
- * Executes a DQL query and returns matching items as a query result.
2572
- *
2573
- * **Note:** only returns results from the local store without waiting for any
2574
- * {@link SyncSubscription | sync subscriptions} to have caught up with the
2575
- * latest changes. Only use this method if your program must proceed with
2576
- * immediate results. Use a {@link StoreObserver | store observer} to receive
2577
- * updates to query results as soon as they have been synced to this peer.
2578
- *
2579
- * @param query A string containing a valid query expressed in DQL.
2580
- * @param queryArguments An object of values keyed by the placeholder name
2581
- * without the leading `:`. Example: `{ "name": "John" }` for a query like
2582
- * `SELECT * FROM people WHERE name = :name`.
2583
- * @template T The type of items returned by the query. This is a convenience
2584
- * type that is neither inferred from the `query` parameter nor validated
2585
- * against it.
2586
- * @template U The type of the query arguments
2587
- * @returns A promise for a {@link QueryResult} containing a
2588
- * {@link QueryResultItem} for each match.
2589
- * @throws {@link DittoError} `query/invalid`: if `query` argument is not a
2590
- * string or not valid DQL.
2591
- * @throws {@link DittoError} `query/arguments-invalid`: if `queryArguments`
2592
- * argument is invalid (e.g. contains unsupported types).
2593
- * @throws {@link DittoError} may throw other errors.
2594
- */
2595
2677
  execute<T = any, U extends DQLQueryArguments = DQLQueryArguments>(query: string, queryArguments?: U): Promise<QueryResult<T>>;
2596
2678
  /**
2597
2679
  * Initiate a write transaction in a callback.
@@ -2759,13 +2841,91 @@ declare class Store {
2759
2841
  * @internal
2760
2842
  */
2761
2843
  removeAttachmentFetcher(attachmentFetcher: AttachmentFetcher): boolean;
2762
- /** @internal */
2763
- close(): void;
2764
2844
  /**
2765
- * Private method, used only by the Portal https://github.com/getditto/ditto/pull/3652
2766
- * @internal
2845
+ * Executes multiple DQL queries within a single atomic transaction.
2846
+ *
2847
+ * This ensures that either all statements are executed successfully, or none
2848
+ * are executed at all, providing strong consistency guarantees. Certain mesh
2849
+ * configurations may impose limitations on these guarantees. For more
2850
+ * details, refer to the [Ditto
2851
+ * documentation](https://docs.ditto.live/sdk/latest/crud/transactions).
2852
+ *
2853
+ * Transactions are initiated as read-write by default, and only one
2854
+ * read-write transaction can be executed at any given time. Any other
2855
+ * read-write transaction started concurrently will wait until the current
2856
+ * transaction has been committed or rolled back. Therefore, it is crucial to
2857
+ * ensure a transaction finishes as early as possible to prevent blocking
2858
+ * other read-write transactions.
2859
+ *
2860
+ * A transaction can also be configured to be read-only using the `isReadOnly`
2861
+ * parameter. Multiple read-only transactions can be executed concurrently.
2862
+ * However, executing a mutating DQL statement in a read-only transaction will
2863
+ * throw an error.
2864
+ *
2865
+ * If errors occur in an `execute()` call within a transaction block and the
2866
+ * error is caught and handled within the block, the transaction will continue
2867
+ * to run and not be rolled back. When an error is thrown at any point inside
2868
+ * the transaction block or while committing the transaction, the transaction
2869
+ * is implicitly rolled back, and the error is propagated to the caller.
2870
+ *
2871
+ * When a Ditto instance goes out of scope, it will drive all pending
2872
+ * transactions to completion before being shut down.
2873
+ *
2874
+ * **Warning:** Calling `ditto.store.execute()` or creating a nested
2875
+ * transaction within a transaction may lead to a deadlock.
2876
+ *
2877
+ * The transaction closure provided here can either return a
2878
+ * {@link TransactionCompletionAction} or an arbitrary value, either of which
2879
+ * will then also be returned by the call to this method itself. If one of the
2880
+ * {@link TransactionCompletionAction} values `'commit'` or `'rollback'` is
2881
+ * returned from the closure, that action is applied. If any other value,
2882
+ * including `null`, is returned, the transaction is committed unless an error
2883
+ * is thrown from the closure.
2884
+ *
2885
+ * Example usage (explicit completion):
2886
+ *
2887
+ * ```ts
2888
+ * await store.transaction(async (transaction) => {
2889
+ * // ...
2890
+ * return 'commit'
2891
+ * })
2892
+ * ```
2893
+ *
2894
+ * Example usage (returning a custom type):
2895
+ *
2896
+ * ```ts
2897
+ * interface UserData {
2898
+ * id: string
2899
+ * name: string
2900
+ * }
2901
+ *
2902
+ * const user: UserData = await store.transaction<UserData>(async (transaction) => {
2903
+ * // ...
2904
+ * return { id: 'u1', name: 'Alice' }
2905
+ * })
2906
+ * ```
2907
+ *
2908
+ * @template T The type of the value returned from the `scope` function.
2909
+ * Defaults to `TransactionCompletionAction`.
2910
+ * @param {Function} scope A function that provides access to a transaction
2911
+ * object to execute DQL queries.
2912
+ * @param {TransactionOptions} [options] Optional settings for the
2913
+ * transaction.
2914
+ * @returns {Promise<T>} A promise that resolves to the value returned by the
2915
+ * scope function. If that value is a {@link TransactionCompletionAction}, the
2916
+ * transaction is completed with the same action.
2917
+ * @throws {DittoError} Throws `DittoError` of `store/transaction-read-only`
2918
+ * if a mutating query is executed in a read-only transaction.
2919
+ * @throws {DittoError} May throw other `DittoError`s.
2920
+ * @throws Will rethrow any error thrown within the `scope` function.
2921
+ * @see {@link Transaction}
2922
+ * @see {@link TransactionOptions}
2767
2923
  */
2768
- registerLiveQueryWebhook(collectionName: string, query: string, url: string): Promise<DocumentID>;
2924
+ transaction<T = TransactionCompletionAction>(scope: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
2925
+ /** @internal */
2926
+ beginTransaction(options?: TransactionOptions): Promise<Transaction>;
2927
+ /** @internal */
2928
+ close(): void;
2769
2929
  }
2770
2930
 
2771
2931
  /**
@@ -3338,12 +3498,24 @@ declare class SmallPeerInfo {
3338
3498
  * {@link SmallPeerInfo.metadata | `metadata`}.
3339
3499
  */
3340
3500
  set metadataJSONString(metadata: string);
3501
+ /**
3502
+ * Determines which "kind" of peers the small peer info will be replicated to.
3503
+ *
3504
+ * Defaults to `LocalPeerOnly`, which means no replication. Set this to
3505
+ * `BigPeerOnly` to replicate collected info to the Big Peer.
3506
+ *
3507
+ * @throws when set to a value other than `BigPeerOnly` or `LocalPeerOnly`.
3508
+ */
3509
+ get syncScope(): SmallPeerInfoSyncScope;
3510
+ set syncScope(syncScope: SmallPeerInfoSyncScope);
3341
3511
  /**
3342
3512
  * Determines which "kind" of peers the small peer info will be
3343
3513
  * replicated to.
3344
3514
  *
3345
3515
  * Defaults to `LocalPeerOnly`, which means no replication. Set this to
3346
3516
  * `BigPeerOnly` to replicate collected info to the Big Peer.
3517
+ *
3518
+ * @deprecated use {@link SmallPeerInfo.syncScope} instead.
3347
3519
  */
3348
3520
  getSyncScope(): Promise<SmallPeerInfoSyncScope>;
3349
3521
  /**
@@ -3353,6 +3525,7 @@ declare class SmallPeerInfo {
3353
3525
  *
3354
3526
  * @param syncScope the new sync scope.
3355
3527
  * @throws when set to a value other than `BigPeerOnly` or `LocalPeerOnly`.
3528
+ * @deprecated use {@link SmallPeerInfo.syncScope} instead.
3356
3529
  */
3357
3530
  setSyncScope(syncScope: SmallPeerInfoSyncScope): Promise<void>;
3358
3531
  private ditto;
@@ -3593,8 +3766,12 @@ declare const ERROR_CODES: {
3593
3766
  readonly 'store/crdt': "An error occurred processing a CRDT.";
3594
3767
  /** Error for a document not found. */
3595
3768
  readonly 'store/document-not-found': "The document with the provided ID could not be found.";
3769
+ /** Error for writing to a read-only transaction. */
3770
+ readonly 'store/transaction-read-only': "A mutating DQL query was attempted using a read-only transaction.";
3596
3771
  /** Error for an invalid document ID. */
3597
3772
  readonly 'store/document-id': "The document ID is invalid.";
3773
+ /** Error when the chosen persistence directory is already in use by another Ditto instance. */
3774
+ readonly 'store/persistence-directory-locked': "The chosen persistence directory is already in use by another Ditto instance.";
3598
3775
  /** Permission has been denied for a file operation when working with attachments. */
3599
3776
  readonly 'store/attachment-file-permission-denied': "Permission has been denied for a file operation when working with attachments.";
3600
3777
  /** The source file for an attachment does not exist. */
@@ -3631,6 +3808,15 @@ declare const ERROR_CODES: {
3631
3808
  readonly 'validation/not-json-compatible': "Value is not serializable as JSON.";
3632
3809
  /** A validation error where a size limit was exceeded. */
3633
3810
  readonly 'validation/size-limit-exceeded': "The size limit has been exceeded.";
3811
+ /**
3812
+ * Error when a passphrase was provided but the store is not encrypted.
3813
+ *
3814
+ * This error is not in use for the JavaScript SDK, which currently does not
3815
+ * support encrypted stores.
3816
+ */
3817
+ readonly 'encryption/extraneous-passphrase-given': "Unexpected passphrase provided for the currently unencrypted store.";
3818
+ /** */
3819
+ readonly 'differ/identity-key-path-invalid': "A provided identity key path is invalid.";
3634
3820
  };
3635
3821
 
3636
3822
  /**
@@ -3945,6 +4131,54 @@ declare class NotAvailableAuthenticator extends Authenticator {
3945
4131
  '@ditto.authenticationExpiring'(secondsRemaining: number): never;
3946
4132
  }
3947
4133
 
4134
+ /**
4135
+ * Represents a diff between two arrays.
4136
+ *
4137
+ * Create a diff between arrays of {@link QueryResultItem} using a {@link Differ}.
4138
+ */
4139
+ declare class Diff {
4140
+ /** The set of indexes in the _new_ array at which new items have been inserted. */
4141
+ readonly insertions: number[];
4142
+ /** The set of indexes in the _old_ array at which old items have been deleted. */
4143
+ readonly deletions: number[];
4144
+ /** The set of indexes in the _new_ array at which items have been updated. */
4145
+ readonly updates: number[];
4146
+ /**
4147
+ * A set of tuples each representing a move of an item `from` a particular
4148
+ * index in the _old_ array `to` a particular index in the _new_ array.
4149
+ */
4150
+ readonly moves: {
4151
+ from: number;
4152
+ to: number;
4153
+ }[];
4154
+ constructor(cborData: Uint8Array);
4155
+ }
4156
+ /**
4157
+ * Calculates diffs between arrays of {@link QueryResultItem}.
4158
+ *
4159
+ * Use a {@link Differ} with a {@link StoreObserver} to get the diff between
4160
+ * subsequent query results delivered by the store observer.
4161
+ */
4162
+ declare class Differ {
4163
+ /** Create a new differ. */
4164
+ constructor();
4165
+ /**
4166
+ * Calculate the diff of the provided items against the last set of items that
4167
+ * were passed to this differ.
4168
+ *
4169
+ * The returned {@link Diff} identifies changes from the old array of items
4170
+ * to the new array of items using indices into both arrays.
4171
+ *
4172
+ * Initially, the differ has no items, so the first call to this method will
4173
+ * always return a diff showing all items as insertions.
4174
+ *
4175
+ * The identity of items is determined by their `_id` field.
4176
+ */
4177
+ diff(items: QueryResultItem<any>[]): Diff;
4178
+ /** @internal */
4179
+ deref(): Pointer<FFIDiffer>;
4180
+ }
4181
+
3948
4182
  /**
3949
4183
  * A JavaScript class that identifies a bridge's type and may be used to create
3950
4184
  * new instances.
@@ -4161,6 +4395,10 @@ declare class Bridge<T extends object, FFIType> {
4161
4395
  /** @internal */
4162
4396
  static readonly queryResultItem: Bridge<QueryResultItem<any>, "dittoffi_query_result_item_t">;
4163
4397
  /** @internal */
4398
+ static readonly transaction: Bridge<Transaction, "dittoffi_transaction_t">;
4399
+ /** @internal */
4400
+ static readonly differ: Bridge<Differ, "dittoffi_differ_t">;
4401
+ /** @internal */
4164
4402
  static readonly ditto: Bridge<Ditto, "CDitto_t">;
4165
4403
  private internalType;
4166
4404
  /**
@@ -5047,5 +5285,5 @@ declare class CBOR {
5047
5285
  static decode(data: Uint8Array, reviver?: (key: any, value: any) => any): any;
5048
5286
  }
5049
5287
 
5050
- export { type Address, Attachment, type AttachmentFetchEvent, type AttachmentFetchEventCompleted, type AttachmentFetchEventDeleted, type AttachmentFetchEventProgress, type AttachmentFetchEventType, AttachmentFetcher, type AttachmentMetadata, AttachmentToken, type AuthenticationHandler, AuthenticationStatus, Authenticator, BasePendingCursorOperation, BasePendingIDSpecificOperation, CBOR, Collection, type CollectionInterface, CollectionsEvent, type CollectionsEventParams, type CollectionsObservationHandler, type ConditionSource, type Connection, ConnectionRequest, type ConnectionRequestAuthorization, type ConnectionRequestHandler, type ConnectionType, Counter, type CustomLogCallback, type DQLQueryArgumentValue, type DQLQueryArguments, Ditto, DittoError, Document, DocumentID, type DocumentIDValue, DocumentPath, type DocumentValue, ERROR_CODES, type ErrorCode, type ErrorContext, type Identity, type IdentityManual, type IdentityOfflinePlayground, type IdentityOnlinePlayground, type IdentityOnlineWithAuthentication, type IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, type InitOptions, KeepAlive, LiveQuery, type LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, type LiveQueryEventUpdateParams, type LiveQueryMove, type LogLevel, Logger, type LoginResult, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, type ObserverOptions, OnlineAuthenticator, type Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, type PresenceConnectionType, type PresenceGraph, type QueryArguments, type QueryObservationHandler, QueryResult, QueryResultItem, Register, type RemotePeer, SingleDocumentLiveQueryEvent, type SingleObservationHandler, SmallPeerInfo, type SmallPeerInfoSyncScope, type SortDirection, Store, type StoreObservationHandler, type StoreObservationHandlerWithSignalNext, StoreObserver, Subscription, Sync, SyncSubscription, type TransportCondition, TransportConfig, type TransportConfigConnect, type TransportConfigGlobal, type TransportConfigLan, type TransportConfigListen, type TransportConfigListenHTTP, type TransportConfigListenTCP, type TransportConfigPeerToPeer, type TypedAttachmentToken, type UntypedAttachmentToken, UpdateResult, type UpdateResultType, UpdateResultsMap, type UpsertOptions, type WebAssemblyModule, type WriteStrategy, WriteTransaction, WriteTransactionCollection, WriteTransactionPendingCursorOperation, WriteTransactionPendingIDSpecificOperation, type WriteTransactionResult, addressToString, checkAPIs, disableDeadlockTimeoutWhenDebugging, getBridgeLoad, init, mapFFIErrors, mapFFIErrorsAsync, transportConfigFromDeserializable, transportConfigToSerializable, validateAttachmentMetadata, validateDocumentIDCBOR, validateDocumentIDValue };
5288
+ export { type Address, Attachment, type AttachmentFetchEvent, type AttachmentFetchEventCompleted, type AttachmentFetchEventDeleted, type AttachmentFetchEventProgress, type AttachmentFetchEventType, AttachmentFetcher, type AttachmentMetadata, AttachmentToken, type AuthenticationHandler, AuthenticationStatus, Authenticator, BasePendingCursorOperation, BasePendingIDSpecificOperation, CBOR, Collection, type CollectionInterface, CollectionsEvent, type CollectionsEventParams, type CollectionsObservationHandler, type ConditionSource, type Connection, ConnectionRequest, type ConnectionRequestAuthorization, type ConnectionRequestHandler, type ConnectionType, Counter, type CustomLogCallback, type DQLQueryArgumentValue, type DQLQueryArguments, Diff, Differ, Ditto, DittoError, Document, DocumentID, type DocumentIDValue, DocumentPath, type DocumentValue, ERROR_CODES, type ErrorCode, type ErrorContext, type Identity, type IdentityManual, type IdentityOfflinePlayground, type IdentityOnlinePlayground, type IdentityOnlineWithAuthentication, type IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, type InitOptions, KeepAlive, LiveQuery, type LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, type LiveQueryEventUpdateParams, type LiveQueryMove, type LogLevel, Logger, type LoginResult, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, type ObserverOptions, OnlineAuthenticator, type Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, type PresenceConnectionType, type PresenceGraph, type QueryArguments, type QueryExecuting, type QueryObservationHandler, QueryResult, QueryResultItem, Register, type RemotePeer, SingleDocumentLiveQueryEvent, type SingleObservationHandler, SmallPeerInfo, type SmallPeerInfoSyncScope, type SortDirection, Store, type StoreObservationHandler, type StoreObservationHandlerWithSignalNext, StoreObserver, Subscription, Sync, SyncSubscription, Transaction, type TransactionCompletionAction, TransactionInfo, type TransactionOptions, type TransportCondition, TransportConfig, type TransportConfigConnect, type TransportConfigGlobal, type TransportConfigLan, type TransportConfigListen, type TransportConfigListenHTTP, type TransportConfigListenTCP, type TransportConfigPeerToPeer, type TypedAttachmentToken, type UntypedAttachmentToken, UpdateResult, type UpdateResultType, UpdateResultsMap, type UpsertOptions, type WebAssemblyModule, type WriteStrategy, WriteTransaction, WriteTransactionCollection, WriteTransactionPendingCursorOperation, WriteTransactionPendingIDSpecificOperation, type WriteTransactionResult, addressToString, checkAPIs, disableDeadlockTimeoutWhenDebugging, getBridgeLoad, init, mapFFIErrors, mapFFIErrorsAsync, transportConfigFromDeserializable, transportConfigToSerializable, validateAttachmentMetadata, validateDocumentIDCBOR, validateDocumentIDValue };
5051
5289
  //# sourceMappingURL=ditto.d.ts.map