@powersync/common 1.17.0 → 1.18.1
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/dist/bundle.mjs +17 -0
- package/lib/client/AbstractPowerSyncDatabase.d.ts +14 -14
- package/lib/client/AbstractPowerSyncDatabase.js +15 -16
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +5 -5
- package/lib/client/AbstractPowerSyncOpenFactory.js +0 -1
- package/lib/client/SQLOpenFactory.d.ts +1 -1
- package/lib/client/SQLOpenFactory.js +0 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +2 -2
- package/lib/client/connection/PowerSyncBackendConnector.js +0 -1
- package/lib/client/connection/PowerSyncCredentials.js +0 -1
- package/lib/client/constants.js +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +4 -4
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -1
- package/lib/client/sync/bucket/CrudBatch.d.ts +1 -1
- package/lib/client/sync/bucket/CrudBatch.js +0 -1
- package/lib/client/sync/bucket/CrudEntry.js +0 -1
- package/lib/client/sync/bucket/CrudTransaction.d.ts +2 -2
- package/lib/client/sync/bucket/CrudTransaction.js +1 -2
- package/lib/client/sync/bucket/OpType.js +0 -1
- package/lib/client/sync/bucket/OplogEntry.d.ts +2 -2
- package/lib/client/sync/bucket/OplogEntry.js +1 -2
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +6 -6
- package/lib/client/sync/bucket/SqliteBucketStorage.js +5 -6
- package/lib/client/sync/bucket/SyncDataBatch.d.ts +1 -1
- package/lib/client/sync/bucket/SyncDataBatch.js +1 -2
- package/lib/client/sync/bucket/SyncDataBucket.d.ts +2 -2
- package/lib/client/sync/bucket/SyncDataBucket.js +1 -2
- package/lib/client/sync/stream/AbstractRemote.d.ts +6 -6
- package/lib/client/sync/stream/AbstractRemote.js +4 -5
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +8 -8
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +9 -10
- package/lib/client/sync/stream/streaming-sync-types.d.ts +3 -3
- package/lib/client/sync/stream/streaming-sync-types.js +0 -1
- package/lib/db/DBAdapter.d.ts +1 -1
- package/lib/db/DBAdapter.js +0 -1
- package/lib/db/crud/SyncStatus.js +0 -1
- package/lib/db/crud/UploadQueueStatus.js +0 -1
- package/lib/db/schema/Column.js +0 -1
- package/lib/db/schema/Index.d.ts +3 -3
- package/lib/db/schema/Index.js +1 -2
- package/lib/db/schema/IndexedColumn.d.ts +2 -2
- package/lib/db/schema/IndexedColumn.js +1 -2
- package/lib/db/schema/Schema.d.ts +3 -3
- package/lib/db/schema/Schema.js +1 -2
- package/lib/db/schema/Table.d.ts +17 -17
- package/lib/db/schema/Table.js +3 -4
- package/lib/db/schema/TableV2.d.ts +2 -2
- package/lib/db/schema/TableV2.js +1 -2
- package/lib/index.d.ts +34 -34
- package/lib/index.js +34 -35
- package/lib/types/types.js +0 -1
- package/lib/utils/AbortOperation.js +0 -1
- package/lib/utils/BaseObserver.js +0 -1
- package/lib/utils/ControlledExecutor.js +0 -1
- package/lib/utils/DataStream.d.ts +1 -1
- package/lib/utils/DataStream.js +1 -2
- package/lib/utils/mutex.js +0 -1
- package/lib/utils/parseQuery.d.ts +1 -1
- package/lib/utils/parseQuery.js +0 -1
- package/lib/utils/throttle.d.ts +14 -0
- package/lib/utils/throttle.js +45 -0
- package/package.json +13 -5
- package/dist/index.js +0 -16
- package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
- package/lib/client/SQLOpenFactory.js.map +0 -1
- package/lib/client/connection/PowerSyncBackendConnector.js.map +0 -1
- package/lib/client/connection/PowerSyncCredentials.js.map +0 -1
- package/lib/client/constants.js.map +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/CrudBatch.js.map +0 -1
- package/lib/client/sync/bucket/CrudEntry.js.map +0 -1
- package/lib/client/sync/bucket/CrudTransaction.js.map +0 -1
- package/lib/client/sync/bucket/OpType.js.map +0 -1
- package/lib/client/sync/bucket/OplogEntry.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBatch.js.map +0 -1
- package/lib/client/sync/bucket/SyncDataBucket.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
- package/lib/client/sync/stream/streaming-sync-types.js.map +0 -1
- package/lib/db/DBAdapter.js.map +0 -1
- package/lib/db/crud/SyncStatus.js.map +0 -1
- package/lib/db/crud/UploadQueueStatus.js.map +0 -1
- package/lib/db/schema/Column.js.map +0 -1
- package/lib/db/schema/Index.js.map +0 -1
- package/lib/db/schema/IndexedColumn.js.map +0 -1
- package/lib/db/schema/Schema.js.map +0 -1
- package/lib/db/schema/Table.js.map +0 -1
- package/lib/db/schema/TableV2.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/types.js.map +0 -1
- package/lib/utils/AbortOperation.js.map +0 -1
- package/lib/utils/BaseObserver.js.map +0 -1
- package/lib/utils/ControlledExecutor.js.map +0 -1
- package/lib/utils/DataStream.js.map +0 -1
- package/lib/utils/mutex.js.map +0 -1
- package/lib/utils/parseQuery.js.map +0 -1
package/lib/db/schema/Table.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Column, ColumnsType, ColumnType, ExtractColumnValueType } from './Column';
|
|
2
|
-
import { Index } from './Index';
|
|
3
|
-
import { TableV2 } from './TableV2';
|
|
1
|
+
import { Column, ColumnsType, ColumnType, ExtractColumnValueType } from './Column.js';
|
|
2
|
+
import { Index } from './Index.js';
|
|
3
|
+
import { TableV2 } from './TableV2.js';
|
|
4
4
|
export interface TableOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The synced table name, matching sync rules
|
|
@@ -55,8 +55,8 @@ export declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
55
55
|
* @param {TableV2Options} [v2Options] - Optional configuration options for V2 syntax
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
|
-
* <caption>New constructor example</caption>
|
|
59
58
|
* ```javascript
|
|
59
|
+
* // New Constructor
|
|
60
60
|
* const table = new Table(
|
|
61
61
|
* {
|
|
62
62
|
* name: column.text,
|
|
@@ -68,8 +68,8 @@ export declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
68
68
|
*
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
|
-
* <caption>Deprecated constructor example</caption>
|
|
72
71
|
* ```javascript
|
|
72
|
+
* // Deprecated Constructor
|
|
73
73
|
* const table = new Table({
|
|
74
74
|
* name: 'users',
|
|
75
75
|
* columns: [
|
|
@@ -81,20 +81,20 @@ export declare class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
81
81
|
*/
|
|
82
82
|
constructor(columns: Columns, options?: TableV2Options);
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
* @deprecated This constructor will be removed in the next major release.
|
|
85
|
+
* Use the new constructor shown below instead as this does not show types.
|
|
86
|
+
* @example
|
|
87
|
+
* <caption>Use this instead</caption>
|
|
88
|
+
* ```javascript
|
|
89
|
+
* const table = new Table(
|
|
90
|
+
* {
|
|
91
91
|
* name: column.text,
|
|
92
92
|
* age: column.integer
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
* },
|
|
94
|
+
* { indexes: { nameIndex: ['name'] } }
|
|
95
|
+
* );
|
|
96
|
+
*```
|
|
97
|
+
*/
|
|
98
98
|
constructor(options: TableOptions);
|
|
99
99
|
private isTableV1;
|
|
100
100
|
private initTableV1;
|
package/lib/db/schema/Table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Column, ColumnType, MAX_AMOUNT_OF_COLUMNS } from './Column';
|
|
2
|
-
import { Index } from './Index';
|
|
3
|
-
import { IndexedColumn } from './IndexedColumn';
|
|
1
|
+
import { Column, ColumnType, MAX_AMOUNT_OF_COLUMNS } from './Column.js';
|
|
2
|
+
import { Index } from './Index.js';
|
|
3
|
+
import { IndexedColumn } from './IndexedColumn.js';
|
|
4
4
|
export const DEFAULT_TABLE_OPTIONS = {
|
|
5
5
|
indexes: [],
|
|
6
6
|
insertOnly: false,
|
|
@@ -166,4 +166,3 @@ export class Table {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
//# sourceMappingURL=Table.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnsType } from './Column';
|
|
2
|
-
import { Table } from './Table';
|
|
1
|
+
import { ColumnsType } from './Column.js';
|
|
2
|
+
import { Table } from './Table.js';
|
|
3
3
|
/**
|
|
4
4
|
Generate a new table from the columns and indexes
|
|
5
5
|
@deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
|
package/lib/db/schema/TableV2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Table } from './Table';
|
|
1
|
+
import { Table } from './Table.js';
|
|
2
2
|
/**
|
|
3
3
|
Generate a new table from the columns and indexes
|
|
4
4
|
@deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
|
|
@@ -6,4 +6,3 @@ import { Table } from './Table';
|
|
|
6
6
|
*/
|
|
7
7
|
export class TableV2 extends Table {
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=TableV2.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
export * from './client/AbstractPowerSyncDatabase';
|
|
2
|
-
export * from './client/AbstractPowerSyncOpenFactory';
|
|
3
|
-
export * from './client/SQLOpenFactory';
|
|
4
|
-
export * from './client/connection/PowerSyncBackendConnector';
|
|
5
|
-
export * from './client/connection/PowerSyncCredentials';
|
|
6
|
-
export * from './client/sync/bucket/BucketStorageAdapter';
|
|
7
|
-
export { UpdateType, CrudEntry, OpId } from './client/sync/bucket/CrudEntry';
|
|
8
|
-
export * from './client/sync/bucket/SqliteBucketStorage';
|
|
9
|
-
export * from './client/sync/bucket/CrudBatch';
|
|
10
|
-
export * from './client/sync/bucket/CrudTransaction';
|
|
11
|
-
export * from './client/sync/bucket/SyncDataBatch';
|
|
12
|
-
export * from './client/sync/bucket/SyncDataBucket';
|
|
13
|
-
export * from './client/sync/bucket/OpType';
|
|
14
|
-
export * from './client/sync/bucket/OplogEntry';
|
|
15
|
-
export * from './client/sync/stream/AbstractRemote';
|
|
16
|
-
export * from './client/sync/stream/AbstractStreamingSyncImplementation';
|
|
17
|
-
export * from './client/sync/stream/streaming-sync-types';
|
|
18
|
-
export { MAX_OP_ID } from './client/constants';
|
|
19
|
-
export * from './db/crud/SyncStatus';
|
|
20
|
-
export * from './db/crud/UploadQueueStatus';
|
|
21
|
-
export * from './db/schema/Schema';
|
|
22
|
-
export * from './db/schema/Table';
|
|
23
|
-
export * from './db/schema/Index';
|
|
24
|
-
export * from './db/schema/IndexedColumn';
|
|
25
|
-
export * from './db/schema/Column';
|
|
26
|
-
export * from './db/schema/TableV2';
|
|
27
|
-
export * from './db/crud/SyncStatus';
|
|
28
|
-
export * from './db/crud/UploadQueueStatus';
|
|
29
|
-
export * from './db/DBAdapter';
|
|
30
|
-
export * from './utils/AbortOperation';
|
|
31
|
-
export * from './utils/BaseObserver';
|
|
32
|
-
export * from './utils/DataStream';
|
|
33
|
-
export * from './utils/parseQuery';
|
|
34
|
-
export * from './types/types';
|
|
1
|
+
export * from './client/AbstractPowerSyncDatabase.js';
|
|
2
|
+
export * from './client/AbstractPowerSyncOpenFactory.js';
|
|
3
|
+
export * from './client/SQLOpenFactory.js';
|
|
4
|
+
export * from './client/connection/PowerSyncBackendConnector.js';
|
|
5
|
+
export * from './client/connection/PowerSyncCredentials.js';
|
|
6
|
+
export * from './client/sync/bucket/BucketStorageAdapter.js';
|
|
7
|
+
export { UpdateType, CrudEntry, OpId } from './client/sync/bucket/CrudEntry.js';
|
|
8
|
+
export * from './client/sync/bucket/SqliteBucketStorage.js';
|
|
9
|
+
export * from './client/sync/bucket/CrudBatch.js';
|
|
10
|
+
export * from './client/sync/bucket/CrudTransaction.js';
|
|
11
|
+
export * from './client/sync/bucket/SyncDataBatch.js';
|
|
12
|
+
export * from './client/sync/bucket/SyncDataBucket.js';
|
|
13
|
+
export * from './client/sync/bucket/OpType.js';
|
|
14
|
+
export * from './client/sync/bucket/OplogEntry.js';
|
|
15
|
+
export * from './client/sync/stream/AbstractRemote.js';
|
|
16
|
+
export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
17
|
+
export * from './client/sync/stream/streaming-sync-types.js';
|
|
18
|
+
export { MAX_OP_ID } from './client/constants.js';
|
|
19
|
+
export * from './db/crud/SyncStatus.js';
|
|
20
|
+
export * from './db/crud/UploadQueueStatus.js';
|
|
21
|
+
export * from './db/schema/Schema.js';
|
|
22
|
+
export * from './db/schema/Table.js';
|
|
23
|
+
export * from './db/schema/Index.js';
|
|
24
|
+
export * from './db/schema/IndexedColumn.js';
|
|
25
|
+
export * from './db/schema/Column.js';
|
|
26
|
+
export * from './db/schema/TableV2.js';
|
|
27
|
+
export * from './db/crud/SyncStatus.js';
|
|
28
|
+
export * from './db/crud/UploadQueueStatus.js';
|
|
29
|
+
export * from './db/DBAdapter.js';
|
|
30
|
+
export * from './utils/AbortOperation.js';
|
|
31
|
+
export * from './utils/BaseObserver.js';
|
|
32
|
+
export * from './utils/DataStream.js';
|
|
33
|
+
export * from './utils/parseQuery.js';
|
|
34
|
+
export * from './types/types.js';
|
package/lib/index.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
export * from './client/AbstractPowerSyncDatabase';
|
|
2
|
-
export * from './client/AbstractPowerSyncOpenFactory';
|
|
3
|
-
export * from './client/SQLOpenFactory';
|
|
4
|
-
export * from './client/connection/PowerSyncBackendConnector';
|
|
5
|
-
export * from './client/connection/PowerSyncCredentials';
|
|
6
|
-
export * from './client/sync/bucket/BucketStorageAdapter';
|
|
7
|
-
export { UpdateType, CrudEntry } from './client/sync/bucket/CrudEntry';
|
|
8
|
-
export * from './client/sync/bucket/SqliteBucketStorage';
|
|
9
|
-
export * from './client/sync/bucket/CrudBatch';
|
|
10
|
-
export * from './client/sync/bucket/CrudTransaction';
|
|
11
|
-
export * from './client/sync/bucket/SyncDataBatch';
|
|
12
|
-
export * from './client/sync/bucket/SyncDataBucket';
|
|
13
|
-
export * from './client/sync/bucket/OpType';
|
|
14
|
-
export * from './client/sync/bucket/OplogEntry';
|
|
15
|
-
export * from './client/sync/stream/AbstractRemote';
|
|
16
|
-
export * from './client/sync/stream/AbstractStreamingSyncImplementation';
|
|
17
|
-
export * from './client/sync/stream/streaming-sync-types';
|
|
18
|
-
export { MAX_OP_ID } from './client/constants';
|
|
19
|
-
export * from './db/crud/SyncStatus';
|
|
20
|
-
export * from './db/crud/UploadQueueStatus';
|
|
21
|
-
export * from './db/schema/Schema';
|
|
22
|
-
export * from './db/schema/Table';
|
|
23
|
-
export * from './db/schema/Index';
|
|
24
|
-
export * from './db/schema/IndexedColumn';
|
|
25
|
-
export * from './db/schema/Column';
|
|
26
|
-
export * from './db/schema/TableV2';
|
|
27
|
-
export * from './db/crud/SyncStatus';
|
|
28
|
-
export * from './db/crud/UploadQueueStatus';
|
|
29
|
-
export * from './db/DBAdapter';
|
|
30
|
-
export * from './utils/AbortOperation';
|
|
31
|
-
export * from './utils/BaseObserver';
|
|
32
|
-
export * from './utils/DataStream';
|
|
33
|
-
export * from './utils/parseQuery';
|
|
34
|
-
export * from './types/types';
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from './client/AbstractPowerSyncDatabase.js';
|
|
2
|
+
export * from './client/AbstractPowerSyncOpenFactory.js';
|
|
3
|
+
export * from './client/SQLOpenFactory.js';
|
|
4
|
+
export * from './client/connection/PowerSyncBackendConnector.js';
|
|
5
|
+
export * from './client/connection/PowerSyncCredentials.js';
|
|
6
|
+
export * from './client/sync/bucket/BucketStorageAdapter.js';
|
|
7
|
+
export { UpdateType, CrudEntry } from './client/sync/bucket/CrudEntry.js';
|
|
8
|
+
export * from './client/sync/bucket/SqliteBucketStorage.js';
|
|
9
|
+
export * from './client/sync/bucket/CrudBatch.js';
|
|
10
|
+
export * from './client/sync/bucket/CrudTransaction.js';
|
|
11
|
+
export * from './client/sync/bucket/SyncDataBatch.js';
|
|
12
|
+
export * from './client/sync/bucket/SyncDataBucket.js';
|
|
13
|
+
export * from './client/sync/bucket/OpType.js';
|
|
14
|
+
export * from './client/sync/bucket/OplogEntry.js';
|
|
15
|
+
export * from './client/sync/stream/AbstractRemote.js';
|
|
16
|
+
export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
17
|
+
export * from './client/sync/stream/streaming-sync-types.js';
|
|
18
|
+
export { MAX_OP_ID } from './client/constants.js';
|
|
19
|
+
export * from './db/crud/SyncStatus.js';
|
|
20
|
+
export * from './db/crud/UploadQueueStatus.js';
|
|
21
|
+
export * from './db/schema/Schema.js';
|
|
22
|
+
export * from './db/schema/Table.js';
|
|
23
|
+
export * from './db/schema/Index.js';
|
|
24
|
+
export * from './db/schema/IndexedColumn.js';
|
|
25
|
+
export * from './db/schema/Column.js';
|
|
26
|
+
export * from './db/schema/TableV2.js';
|
|
27
|
+
export * from './db/crud/SyncStatus.js';
|
|
28
|
+
export * from './db/crud/UploadQueueStatus.js';
|
|
29
|
+
export * from './db/DBAdapter.js';
|
|
30
|
+
export * from './utils/AbortOperation.js';
|
|
31
|
+
export * from './utils/BaseObserver.js';
|
|
32
|
+
export * from './utils/DataStream.js';
|
|
33
|
+
export * from './utils/parseQuery.js';
|
|
34
|
+
export * from './types/types.js';
|
package/lib/types/types.js
CHANGED
package/lib/utils/DataStream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Logger from 'js-logger';
|
|
2
|
-
import { BaseObserver } from './BaseObserver';
|
|
2
|
+
import { BaseObserver } from './BaseObserver.js';
|
|
3
3
|
export const DEFAULT_PRESSURE_LIMITS = {
|
|
4
4
|
highWater: 10,
|
|
5
5
|
lowWater: 0
|
|
@@ -160,4 +160,3 @@ export class DataStream extends BaseObserver {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
//# sourceMappingURL=DataStream.js.map
|
package/lib/utils/mutex.js
CHANGED
package/lib/utils/parseQuery.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle a function to be called at most once every "wait" milliseconds,
|
|
3
|
+
* on the trailing edge.
|
|
4
|
+
*
|
|
5
|
+
* Roughly equivalent to lodash/throttle with {leading: false, trailing: true}
|
|
6
|
+
*/
|
|
7
|
+
export declare function throttleTrailing(func: () => void, wait: number): () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Throttle a function to be called at most once every "wait" milliseconds,
|
|
10
|
+
* on the leading and trailing edge.
|
|
11
|
+
*
|
|
12
|
+
* Roughly equivalent to lodash/throttle with {leading: true, trailing: true}
|
|
13
|
+
*/
|
|
14
|
+
export declare function throttleLeadingTrailing(func: () => void, wait: number): () => void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle a function to be called at most once every "wait" milliseconds,
|
|
3
|
+
* on the trailing edge.
|
|
4
|
+
*
|
|
5
|
+
* Roughly equivalent to lodash/throttle with {leading: false, trailing: true}
|
|
6
|
+
*/
|
|
7
|
+
export function throttleTrailing(func, wait) {
|
|
8
|
+
let timeoutId = null;
|
|
9
|
+
const later = () => {
|
|
10
|
+
func();
|
|
11
|
+
timeoutId = null;
|
|
12
|
+
};
|
|
13
|
+
return function () {
|
|
14
|
+
if (timeoutId == null) {
|
|
15
|
+
timeoutId = setTimeout(later, wait);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Throttle a function to be called at most once every "wait" milliseconds,
|
|
21
|
+
* on the leading and trailing edge.
|
|
22
|
+
*
|
|
23
|
+
* Roughly equivalent to lodash/throttle with {leading: true, trailing: true}
|
|
24
|
+
*/
|
|
25
|
+
export function throttleLeadingTrailing(func, wait) {
|
|
26
|
+
let timeoutId = null;
|
|
27
|
+
let lastCallTime = 0;
|
|
28
|
+
const invokeFunction = () => {
|
|
29
|
+
func();
|
|
30
|
+
lastCallTime = Date.now();
|
|
31
|
+
timeoutId = null;
|
|
32
|
+
};
|
|
33
|
+
return function () {
|
|
34
|
+
const now = Date.now();
|
|
35
|
+
const timeToWait = wait - (now - lastCallTime);
|
|
36
|
+
if (timeToWait <= 0) {
|
|
37
|
+
// Leading edge: Call the function immediately if enough time has passed
|
|
38
|
+
invokeFunction();
|
|
39
|
+
}
|
|
40
|
+
else if (!timeoutId) {
|
|
41
|
+
// Set a timeout for the trailing edge if not already set
|
|
42
|
+
timeoutId = setTimeout(invokeFunction, timeToWait);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"description": "API definitions for JourneyApps PowerSync",
|
|
9
|
-
"
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "dist/bundle.mjs",
|
|
11
|
+
"module": "dist/bundle.mjs",
|
|
10
12
|
"types": "lib/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/bundle.mjs",
|
|
16
|
+
"default": "./dist/bundle.mjs",
|
|
17
|
+
"types": "./lib/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
11
20
|
"author": "JOURNEYAPPS",
|
|
12
21
|
"license": "Apache-2.0",
|
|
13
22
|
"files": [
|
|
@@ -31,7 +40,6 @@
|
|
|
31
40
|
"@rollup/plugin-json": "^6.1.0",
|
|
32
41
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
33
42
|
"@rollup/plugin-terser": "^0.4.4",
|
|
34
|
-
"@types/lodash": "^4.14.197",
|
|
35
43
|
"@types/node": "^20.5.9",
|
|
36
44
|
"@types/uuid": "^9.0.1",
|
|
37
45
|
"async-mutex": "^0.4.0",
|
|
@@ -40,7 +48,6 @@
|
|
|
40
48
|
"can-ndjson-stream": "^1.0.2",
|
|
41
49
|
"cross-fetch": "^4.0.0",
|
|
42
50
|
"event-iterator": "^2.0.0",
|
|
43
|
-
"lodash": "^4.17.21",
|
|
44
51
|
"rollup": "4.14.3",
|
|
45
52
|
"rsocket-core": "1.0.0-alpha.3",
|
|
46
53
|
"rsocket-websocket-client": "1.0.0-alpha.3",
|
|
@@ -51,7 +58,8 @@
|
|
|
51
58
|
},
|
|
52
59
|
"scripts": {
|
|
53
60
|
"build": "tsc -b && rollup -c rollup.config.mjs",
|
|
54
|
-
"
|
|
61
|
+
"build:prod": "tsc -b --sourceMap false && rollup -c rollup.config.mjs --sourceMap false",
|
|
62
|
+
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
|
|
55
63
|
"test": "vitest"
|
|
56
64
|
}
|
|
57
65
|
}
|