@powersync/common 1.57.1 → 2.0.0
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/lib/attachments/AttachmentContext.d.ts +5 -5
- package/lib/attachments/AttachmentContext.js +6 -2
- package/lib/attachments/AttachmentContext.js.map +1 -1
- package/lib/attachments/AttachmentQueue.d.ts +6 -6
- package/lib/attachments/AttachmentQueue.js +9 -8
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/AttachmentService.d.ts +3 -3
- package/lib/attachments/AttachmentService.js +4 -3
- package/lib/attachments/AttachmentService.js.map +1 -1
- package/lib/attachments/Schema.d.ts +2 -2
- package/lib/attachments/SyncingService.d.ts +2 -2
- package/lib/attachments/SyncingService.js +21 -6
- package/lib/attachments/SyncingService.js.map +1 -1
- package/lib/client/{AbstractPowerSyncDatabase.d.ts → CommonPowerSyncDatabase.d.ts} +56 -232
- package/lib/client/CommonPowerSyncDatabase.js +2 -0
- package/lib/client/CommonPowerSyncDatabase.js.map +1 -0
- package/lib/client/SQLOpenFactory.d.ts +35 -13
- package/lib/client/SQLOpenFactory.js +1 -25
- package/lib/client/SQLOpenFactory.js.map +1 -1
- package/lib/client/compilableQueryWatch.d.ts +2 -2
- package/lib/client/compilableQueryWatch.js +1 -2
- package/lib/client/compilableQueryWatch.js.map +1 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -3
- package/lib/client/runOnSchemaChange.d.ts +2 -2
- package/lib/client/runOnSchemaChange.js.map +1 -1
- package/lib/client/sync/bucket/CrudEntry.d.ts +3 -34
- package/lib/client/sync/bucket/CrudEntry.js +0 -99
- package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
- package/lib/client/sync/options.d.ts +65 -0
- package/lib/client/sync/options.js +25 -0
- package/lib/client/sync/options.js.map +1 -0
- package/lib/client/sync/sync-streams.d.ts +1 -1
- package/lib/client/triggers/TriggerManager.d.ts +9 -38
- package/lib/client/watched/GetAllQuery.d.ts +3 -3
- package/lib/client/watched/GetAllQuery.js +1 -1
- package/lib/client/watched/GetAllQuery.js.map +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +2 -10
- package/lib/client/watched/WatchedQuery.js +0 -11
- package/lib/client/watched/WatchedQuery.js.map +1 -1
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +0 -50
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +1 -176
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +0 -22
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +1 -82
- package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +72 -154
- package/lib/db/DBAdapter.js +70 -108
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/db/QueryResult.d.ts +104 -0
- package/lib/db/QueryResult.js +96 -0
- package/lib/db/QueryResult.js.map +1 -0
- package/lib/db/crud/SyncProgress.d.ts +1 -13
- package/lib/db/crud/SyncProgress.js +1 -62
- package/lib/db/crud/SyncProgress.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +32 -66
- package/lib/db/crud/SyncStatus.js +1 -253
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/schema/Column.d.ts +0 -7
- package/lib/db/schema/Column.js +0 -7
- package/lib/db/schema/Column.js.map +1 -1
- package/lib/db/schema/Index.d.ts +2 -6
- package/lib/db/schema/Index.js +1 -4
- package/lib/db/schema/Index.js.map +1 -1
- package/lib/db/schema/IndexedColumn.d.ts +2 -6
- package/lib/db/schema/IndexedColumn.js +1 -4
- package/lib/db/schema/IndexedColumn.js.map +1 -1
- package/lib/db/schema/Schema.d.ts +4 -28
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +50 -96
- package/lib/db/schema/Table.js +83 -91
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/index.d.ts +5 -21
- package/lib/index.js +5 -22
- package/lib/index.js.map +1 -1
- package/lib/utils/BaseObserver.d.ts +1 -1
- package/lib/utils/BaseObserver.js +1 -1
- package/lib/utils/Logger.d.ts +52 -23
- package/lib/utils/Logger.js +35 -33
- package/lib/utils/Logger.js.map +1 -1
- package/lib/utils/MetaBaseObserver.d.ts +11 -11
- package/lib/utils/MetaBaseObserver.js +1 -50
- package/lib/utils/MetaBaseObserver.js.map +1 -1
- package/lib/utils/mutex.d.ts +3 -53
- package/lib/utils/mutex.js +1 -156
- package/lib/utils/mutex.js.map +1 -1
- package/package.json +8 -45
- package/src/attachments/AttachmentContext.ts +11 -10
- package/src/attachments/AttachmentQueue.ts +15 -14
- package/src/attachments/AttachmentService.ts +7 -6
- package/src/attachments/Schema.ts +2 -2
- package/src/attachments/SyncingService.ts +23 -9
- package/src/client/CommonPowerSyncDatabase.ts +540 -0
- package/src/client/SQLOpenFactory.ts +38 -22
- package/src/client/compilableQueryWatch.ts +3 -4
- package/src/client/connection/PowerSyncBackendConnector.ts +3 -3
- package/src/client/runOnSchemaChange.ts +2 -2
- package/src/client/sync/bucket/CrudEntry.ts +4 -104
- package/src/client/sync/options.ts +77 -0
- package/src/client/sync/sync-streams.ts +1 -1
- package/src/client/triggers/TriggerManager.ts +10 -41
- package/src/client/watched/GetAllQuery.ts +3 -3
- package/src/client/watched/WatchedQuery.ts +2 -15
- package/src/client/watched/processors/DifferentialQueryProcessor.ts +0 -223
- package/src/client/watched/processors/OnChangeQueryProcessor.ts +0 -111
- package/src/db/DBAdapter.ts +141 -226
- package/src/db/QueryResult.ts +195 -0
- package/src/db/crud/SyncProgress.ts +2 -42
- package/src/db/crud/SyncStatus.ts +45 -220
- package/src/db/schema/Column.ts +0 -8
- package/src/db/schema/Index.ts +3 -6
- package/src/db/schema/IndexedColumn.ts +3 -6
- package/src/db/schema/Schema.ts +4 -4
- package/src/db/schema/Table.ts +111 -186
- package/src/index.ts +5 -21
- package/src/utils/BaseObserver.ts +1 -1
- package/src/utils/Logger.ts +80 -34
- package/src/utils/MetaBaseObserver.ts +14 -60
- package/src/utils/mutex.ts +4 -201
- package/dist/bundle.cjs +0 -14390
- package/dist/bundle.cjs.map +0 -1
- package/dist/bundle.mjs +0 -14309
- package/dist/bundle.mjs.map +0 -1
- package/dist/bundle.node.cjs +0 -12021
- package/dist/bundle.node.cjs.map +0 -1
- package/dist/bundle.node.mjs +0 -11940
- package/dist/bundle.node.mjs.map +0 -1
- package/dist/index.d.cts +0 -4651
- package/legacy/sync_protocol.d.ts +0 -103
- package/lib/client/AbstractPowerSyncDatabase.js +0 -990
- package/lib/client/AbstractPowerSyncDatabase.js.map +0 -1
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +0 -28
- package/lib/client/AbstractPowerSyncOpenFactory.js +0 -28
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +0 -1
- package/lib/client/ConnectionManager.d.ts +0 -115
- package/lib/client/ConnectionManager.js +0 -294
- package/lib/client/ConnectionManager.js.map +0 -1
- package/lib/client/CustomQuery.d.ts +0 -22
- package/lib/client/CustomQuery.js +0 -43
- package/lib/client/CustomQuery.js.map +0 -1
- package/lib/client/constants.d.ts +0 -4
- package/lib/client/constants.js +0 -5
- package/lib/client/constants.js.map +0 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +0 -56
- package/lib/client/sync/bucket/BucketStorageAdapter.js +0 -29
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +0 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +0 -37
- package/lib/client/sync/bucket/SqliteBucketStorage.js +0 -165
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +0 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +0 -180
- package/lib/client/sync/stream/AbstractRemote.js +0 -505
- package/lib/client/sync/stream/AbstractRemote.js.map +0 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +0 -265
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +0 -705
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +0 -1
- package/lib/client/sync/stream/WebsocketClientTransport.d.ts +0 -15
- package/lib/client/sync/stream/WebsocketClientTransport.js +0 -62
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +0 -1
- package/lib/client/sync/stream/core-instruction.d.ts +0 -77
- package/lib/client/sync/stream/core-instruction.js +0 -30
- package/lib/client/sync/stream/core-instruction.js.map +0 -1
- package/lib/client/triggers/MemoryTriggerClaimManager.d.ts +0 -6
- package/lib/client/triggers/MemoryTriggerClaimManager.js +0 -21
- package/lib/client/triggers/MemoryTriggerClaimManager.js.map +0 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +0 -39
- package/lib/client/triggers/TriggerManagerImpl.js +0 -410
- package/lib/client/triggers/TriggerManagerImpl.js.map +0 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +0 -68
- package/lib/client/watched/processors/AbstractQueryProcessor.js +0 -151
- package/lib/client/watched/processors/AbstractQueryProcessor.js.map +0 -1
- package/lib/db/ConnectionClosedError.d.ts +0 -12
- package/lib/db/ConnectionClosedError.js +0 -23
- package/lib/db/ConnectionClosedError.js.map +0 -1
- package/lib/db/schema/TableV2.d.ts +0 -11
- package/lib/db/schema/TableV2.js +0 -11
- package/lib/db/schema/TableV2.js.map +0 -1
- package/lib/utils/AbortOperation.d.ts +0 -11
- package/lib/utils/AbortOperation.js +0 -21
- package/lib/utils/AbortOperation.js.map +0 -1
- package/lib/utils/ControlledExecutor.d.ts +0 -31
- package/lib/utils/ControlledExecutor.js +0 -54
- package/lib/utils/ControlledExecutor.js.map +0 -1
- package/lib/utils/async.d.ts +0 -46
- package/lib/utils/async.js +0 -147
- package/lib/utils/async.js.map +0 -1
- package/lib/utils/compatibility.d.ts +0 -8
- package/lib/utils/compatibility.js +0 -9
- package/lib/utils/compatibility.js.map +0 -1
- package/lib/utils/parseQuery.d.ts +0 -12
- package/lib/utils/parseQuery.js +0 -20
- package/lib/utils/parseQuery.js.map +0 -1
- package/lib/utils/queue.d.ts +0 -16
- package/lib/utils/queue.js +0 -42
- package/lib/utils/queue.js.map +0 -1
- package/lib/utils/stream_transform.d.ts +0 -41
- package/lib/utils/stream_transform.js +0 -211
- package/lib/utils/stream_transform.js.map +0 -1
- package/src/client/AbstractPowerSyncDatabase.ts +0 -1408
- package/src/client/AbstractPowerSyncOpenFactory.ts +0 -45
- package/src/client/ConnectionManager.ts +0 -405
- package/src/client/CustomQuery.ts +0 -56
- package/src/client/constants.ts +0 -4
- package/src/client/sync/bucket/BucketStorageAdapter.ts +0 -65
- package/src/client/sync/bucket/SqliteBucketStorage.ts +0 -202
- package/src/client/sync/stream/AbstractRemote.ts +0 -644
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +0 -970
- package/src/client/sync/stream/WebsocketClientTransport.ts +0 -82
- package/src/client/sync/stream/core-instruction.ts +0 -109
- package/src/client/triggers/MemoryTriggerClaimManager.ts +0 -25
- package/src/client/triggers/TriggerManagerImpl.ts +0 -501
- package/src/client/watched/processors/AbstractQueryProcessor.ts +0 -226
- package/src/db/ConnectionClosedError.ts +0 -25
- package/src/db/schema/TableV2.ts +0 -11
- package/src/utils/AbortOperation.ts +0 -19
- package/src/utils/ControlledExecutor.ts +0 -78
- package/src/utils/async.ts +0 -185
- package/src/utils/compatibility.ts +0 -9
- package/src/utils/parseQuery.ts +0 -31
- package/src/utils/queue.ts +0 -48
- package/src/utils/stream_transform.ts +0 -260
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thrown when an underlying database connection is closed.
|
|
3
|
-
* This is particularly relevant when worker connections are marked as closed while
|
|
4
|
-
* operations are still in progress.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export class ConnectionClosedError extends Error {
|
|
9
|
-
static NAME = 'ConnectionClosedError';
|
|
10
|
-
static MATCHES(input) {
|
|
11
|
-
/**
|
|
12
|
-
* If there are weird package issues which cause multiple versions of classes to be present, the instanceof
|
|
13
|
-
* check might fail. This also performs a failsafe check.
|
|
14
|
-
* This might also happen if the Error is serialized and parsed over a bridging channel like a MessagePort.
|
|
15
|
-
*/
|
|
16
|
-
return (input instanceof ConnectionClosedError || (input instanceof Error && input.name == ConnectionClosedError.NAME));
|
|
17
|
-
}
|
|
18
|
-
constructor(message) {
|
|
19
|
-
super(message);
|
|
20
|
-
this.name = ConnectionClosedError.NAME;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=ConnectionClosedError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionClosedError.js","sourceRoot":"","sources":["../../src/db/ConnectionClosedError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,MAAM,CAAC,IAAI,GAAG,uBAAuB,CAAC;IAEtC,MAAM,CAAC,OAAO,CAAC,KAAU;QACvB;;;;WAIG;QACH,OAAO,CACL,KAAK,YAAY,qBAAqB,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAC/G,CAAC;IACJ,CAAC;IACD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;IACzC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ColumnsType } from './Column.js';
|
|
2
|
-
import { Table } from './Table.js';
|
|
3
|
-
/**
|
|
4
|
-
Generate a new table from the columns and indexes
|
|
5
|
-
@deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
|
|
6
|
-
This will be removed in the next major release.
|
|
7
|
-
|
|
8
|
-
@public
|
|
9
|
-
*/
|
|
10
|
-
export declare class TableV2<Columns extends ColumnsType = ColumnsType> extends Table<Columns> {
|
|
11
|
-
}
|
package/lib/db/schema/TableV2.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Table } from './Table.js';
|
|
2
|
-
/**
|
|
3
|
-
Generate a new table from the columns and indexes
|
|
4
|
-
@deprecated You should use {@link Table} instead as it now allows TableV2 syntax.
|
|
5
|
-
This will be removed in the next major release.
|
|
6
|
-
|
|
7
|
-
@public
|
|
8
|
-
*/
|
|
9
|
-
export class TableV2 extends Table {
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=TableV2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableV2.js","sourceRoot":"","sources":["../../../src/db/schema/TableV2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;EAME;AACF,MAAM,OAAO,OAAmD,SAAQ,KAAc;CAAG"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls to Abortcontroller.abort(reason: any) will result in the
|
|
3
|
-
* `reason` being thrown. This is not necessarily an error,
|
|
4
|
-
* but extends error for better logging purposes.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare class AbortOperation extends Error {
|
|
9
|
-
protected reason: string;
|
|
10
|
-
constructor(reason: string);
|
|
11
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls to Abortcontroller.abort(reason: any) will result in the
|
|
3
|
-
* `reason` being thrown. This is not necessarily an error,
|
|
4
|
-
* but extends error for better logging purposes.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export class AbortOperation extends Error {
|
|
9
|
-
reason;
|
|
10
|
-
constructor(reason) {
|
|
11
|
-
super(reason);
|
|
12
|
-
this.reason = reason;
|
|
13
|
-
// Set the prototype explicitly
|
|
14
|
-
Object.setPrototypeOf(this, AbortOperation.prototype);
|
|
15
|
-
// Capture stack trace
|
|
16
|
-
if (Error.captureStackTrace) {
|
|
17
|
-
Error.captureStackTrace(this, AbortOperation);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=AbortOperation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbortOperation.js","sourceRoot":"","sources":["../../src/utils/AbortOperation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACjB;IAAtB,YAAsB,MAAc;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;QADM,WAAM,GAAN,MAAM,CAAQ;QAElC,+BAA+B;QAC/B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;QAEtD,sBAAsB;QACtB,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export interface ControlledExecutorOptions {
|
|
5
|
-
/**
|
|
6
|
-
* If throttling is enabled, it ensures only one task runs at a time,
|
|
7
|
-
* and only one additional task can be scheduled to run after the current task completes. The pending task will be overwritten by the latest task.
|
|
8
|
-
* Enabled by default.
|
|
9
|
-
*/
|
|
10
|
-
throttleEnabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare class ControlledExecutor<T> {
|
|
16
|
-
private task;
|
|
17
|
-
/**
|
|
18
|
-
* Represents the currently running task, which could be a Promise or undefined if no task is running.
|
|
19
|
-
*/
|
|
20
|
-
private runningTask;
|
|
21
|
-
private pendingTaskParam;
|
|
22
|
-
/**
|
|
23
|
-
* Flag to determine if throttling is enabled, which controls whether tasks are queued or run immediately.
|
|
24
|
-
*/
|
|
25
|
-
private isThrottling;
|
|
26
|
-
private closed;
|
|
27
|
-
constructor(task: (param: T) => Promise<void> | void, options?: ControlledExecutorOptions);
|
|
28
|
-
schedule(param: T): void;
|
|
29
|
-
dispose(): void;
|
|
30
|
-
private execute;
|
|
31
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export class ControlledExecutor {
|
|
5
|
-
task;
|
|
6
|
-
/**
|
|
7
|
-
* Represents the currently running task, which could be a Promise or undefined if no task is running.
|
|
8
|
-
*/
|
|
9
|
-
runningTask;
|
|
10
|
-
pendingTaskParam;
|
|
11
|
-
/**
|
|
12
|
-
* Flag to determine if throttling is enabled, which controls whether tasks are queued or run immediately.
|
|
13
|
-
*/
|
|
14
|
-
isThrottling;
|
|
15
|
-
closed;
|
|
16
|
-
constructor(task, options) {
|
|
17
|
-
this.task = task;
|
|
18
|
-
const { throttleEnabled = true } = options ?? {};
|
|
19
|
-
this.isThrottling = throttleEnabled;
|
|
20
|
-
this.closed = false;
|
|
21
|
-
}
|
|
22
|
-
schedule(param) {
|
|
23
|
-
if (this.closed) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (!this.isThrottling) {
|
|
27
|
-
this.task(param);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (this.runningTask) {
|
|
31
|
-
// set or replace the pending task param with latest one
|
|
32
|
-
this.pendingTaskParam = param;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.execute(param);
|
|
36
|
-
}
|
|
37
|
-
dispose() {
|
|
38
|
-
this.closed = true;
|
|
39
|
-
if (this.runningTask) {
|
|
40
|
-
this.runningTask = undefined;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async execute(param) {
|
|
44
|
-
this.runningTask = this.task(param);
|
|
45
|
-
await this.runningTask;
|
|
46
|
-
this.runningTask = undefined;
|
|
47
|
-
if (this.pendingTaskParam) {
|
|
48
|
-
const pendingParam = this.pendingTaskParam;
|
|
49
|
-
this.pendingTaskParam = undefined;
|
|
50
|
-
this.execute(pendingParam);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=ControlledExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledExecutor.js","sourceRoot":"","sources":["../../src/utils/ControlledExecutor.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACrB,IAAI,CAAqC;IAEjD;;OAEG;IACK,WAAW,CAAqC;IAEhD,gBAAgB,CAAgB;IAExC;;OAEG;IACK,YAAY,CAAU;IAEtB,MAAM,CAAU;IAExB,YAAY,IAAwC,EAAE,OAAmC;QACvF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,EAAE,eAAe,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,QAAQ,CAAC,KAAQ;QACf,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACjB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,wDAAwD;YACxD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAEnB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC/B,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,KAAQ;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,MAAM,IAAI,CAAC,WAAW,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAE7B,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;YAC3C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAElC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
|
package/lib/utils/async.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
export interface AsyncNotifier {
|
|
9
|
-
/**
|
|
10
|
-
* @param signal Also resolve the promise once this signal completes.
|
|
11
|
-
* @returns A promise that resolves once {@link notify} is called after this promise was last resolved.
|
|
12
|
-
*/
|
|
13
|
-
waitForNotification(signal: AbortSignal): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Notifies a pending listener, or makes the next {@link waitForNotification} complete immediately if no listener
|
|
16
|
-
* is currently active.
|
|
17
|
-
*/
|
|
18
|
-
notify(): void;
|
|
19
|
-
}
|
|
20
|
-
export declare function asyncNotifier(): AsyncNotifier;
|
|
21
|
-
export interface QueueOptions {
|
|
22
|
-
eventDelivered?: () => void;
|
|
23
|
-
}
|
|
24
|
-
export declare class EventQueue<T> {
|
|
25
|
-
private readonly options;
|
|
26
|
-
private waitingConsumer;
|
|
27
|
-
private readonly outstandingEvents;
|
|
28
|
-
constructor(options?: QueueOptions);
|
|
29
|
-
/**
|
|
30
|
-
* The amount of buffered events not yet dispatched to listeners.
|
|
31
|
-
*/
|
|
32
|
-
get countOutstandingEvents(): number;
|
|
33
|
-
private notifyInner;
|
|
34
|
-
notify(value: T): void;
|
|
35
|
-
notifyError(error: unknown): void;
|
|
36
|
-
waitForEvent(signal: AbortSignal): Promise<T | undefined>;
|
|
37
|
-
/**
|
|
38
|
-
* Creates an async iterable backed by event queues.
|
|
39
|
-
*
|
|
40
|
-
* @param run A function invoked for every new listener. It receives a queue backing the async iterator.
|
|
41
|
-
* @param abort An additional abort signal. The `run` callback will also be aborted when `AsyncIterator.return` is
|
|
42
|
-
* called.
|
|
43
|
-
* @returns An object conforming to the async iterable protocol.
|
|
44
|
-
*/
|
|
45
|
-
static queueBasedAsyncIterable<T>(run: (queue: EventQueue<T>, abort: AbortSignal) => void, abort?: AbortSignal): AsyncIterable<T>;
|
|
46
|
-
}
|
package/lib/utils/async.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { symbolAsyncIterator } from './compatibility.js';
|
|
2
|
-
import { doneResult, valueResult } from './stream_transform.js';
|
|
3
|
-
/**
|
|
4
|
-
* Throttle a function to be called at most once every "wait" milliseconds,
|
|
5
|
-
* on the trailing edge.
|
|
6
|
-
*
|
|
7
|
-
* Roughly equivalent to lodash/throttle with {leading: false, trailing: true}
|
|
8
|
-
*/
|
|
9
|
-
export function throttleTrailing(func, wait) {
|
|
10
|
-
let timeoutId = null;
|
|
11
|
-
const later = () => {
|
|
12
|
-
func();
|
|
13
|
-
timeoutId = null;
|
|
14
|
-
};
|
|
15
|
-
return function () {
|
|
16
|
-
if (timeoutId == null) {
|
|
17
|
-
timeoutId = setTimeout(later, wait);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function asyncNotifier() {
|
|
22
|
-
const queue = new EventQueue();
|
|
23
|
-
return {
|
|
24
|
-
notify() {
|
|
25
|
-
if (queue.countOutstandingEvents > 0) {
|
|
26
|
-
// Already has an outstanding event, no need to buffer another one.
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
queue.notify();
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
waitForNotification(signal) {
|
|
33
|
-
return queue.waitForEvent(signal);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export class EventQueue {
|
|
38
|
-
options;
|
|
39
|
-
waitingConsumer;
|
|
40
|
-
outstandingEvents;
|
|
41
|
-
constructor(options = {}) {
|
|
42
|
-
this.options = options;
|
|
43
|
-
this.outstandingEvents = [];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The amount of buffered events not yet dispatched to listeners.
|
|
47
|
-
*/
|
|
48
|
-
get countOutstandingEvents() {
|
|
49
|
-
return this.outstandingEvents.length;
|
|
50
|
-
}
|
|
51
|
-
notifyInner(dispatch) {
|
|
52
|
-
const existing = this.waitingConsumer;
|
|
53
|
-
this.waitingConsumer = undefined;
|
|
54
|
-
const dispatchAndNotifyListeners = (waiter) => {
|
|
55
|
-
dispatch(waiter);
|
|
56
|
-
this.options.eventDelivered?.();
|
|
57
|
-
};
|
|
58
|
-
if (existing) {
|
|
59
|
-
dispatchAndNotifyListeners(existing);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.outstandingEvents.push(dispatchAndNotifyListeners);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
notify(value) {
|
|
66
|
-
this.notifyInner((l) => l.resolve(value));
|
|
67
|
-
}
|
|
68
|
-
notifyError(error) {
|
|
69
|
-
this.notifyInner((l) => l.reject(error));
|
|
70
|
-
}
|
|
71
|
-
waitForEvent(signal) {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
if (this.waitingConsumer != null) {
|
|
74
|
-
throw new Error('Illegal call to waitForEvent, already has a waiter.');
|
|
75
|
-
}
|
|
76
|
-
const complete = () => {
|
|
77
|
-
signal?.removeEventListener('abort', onAbort);
|
|
78
|
-
};
|
|
79
|
-
const onAbort = () => {
|
|
80
|
-
complete();
|
|
81
|
-
this.waitingConsumer = undefined;
|
|
82
|
-
resolve(undefined);
|
|
83
|
-
};
|
|
84
|
-
const waiter = {
|
|
85
|
-
resolve: (value) => {
|
|
86
|
-
complete();
|
|
87
|
-
resolve(value);
|
|
88
|
-
},
|
|
89
|
-
reject: (error) => {
|
|
90
|
-
complete();
|
|
91
|
-
reject(error);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
if (signal.aborted) {
|
|
95
|
-
resolve(undefined);
|
|
96
|
-
}
|
|
97
|
-
else if (this.countOutstandingEvents > 0) {
|
|
98
|
-
const [event] = this.outstandingEvents.splice(0, 1);
|
|
99
|
-
event(waiter);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
this.waitingConsumer = waiter;
|
|
103
|
-
signal.addEventListener('abort', onAbort);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Creates an async iterable backed by event queues.
|
|
109
|
-
*
|
|
110
|
-
* @param run A function invoked for every new listener. It receives a queue backing the async iterator.
|
|
111
|
-
* @param abort An additional abort signal. The `run` callback will also be aborted when `AsyncIterator.return` is
|
|
112
|
-
* called.
|
|
113
|
-
* @returns An object conforming to the async iterable protocol.
|
|
114
|
-
*/
|
|
115
|
-
static queueBasedAsyncIterable(run, abort) {
|
|
116
|
-
return {
|
|
117
|
-
[symbolAsyncIterator]: () => {
|
|
118
|
-
const queue = new EventQueue();
|
|
119
|
-
const controller = new AbortController();
|
|
120
|
-
function dispose() {
|
|
121
|
-
controller.abort();
|
|
122
|
-
abort?.removeEventListener('abort', dispose);
|
|
123
|
-
}
|
|
124
|
-
if (abort) {
|
|
125
|
-
if (abort.aborted) {
|
|
126
|
-
controller.abort();
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
abort.addEventListener('abort', dispose);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
run(queue, controller.signal);
|
|
133
|
-
return {
|
|
134
|
-
async next() {
|
|
135
|
-
const event = await queue.waitForEvent(controller.signal);
|
|
136
|
-
return event == null ? doneResult : valueResult(event);
|
|
137
|
-
},
|
|
138
|
-
async return() {
|
|
139
|
-
dispose();
|
|
140
|
-
return doneResult;
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=async.js.map
|
package/lib/utils/async.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/utils/async.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Some JavaScript engines, in particular older versions of React Native, don't support Symbol.asyncIterator.
|
|
3
|
-
*
|
|
4
|
-
* For those, users relying on async generators typically lower them with a transpiler and [this polyfill](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/core-asynciterator-polyfill_1.0.2/sdk/core/core-asynciterator-polyfill/src/index.ts#L4-L6).
|
|
5
|
-
* This definition is compatible with that polyfill, so transpiled apps can use async iterables created by the PowerSync
|
|
6
|
-
* SDK.
|
|
7
|
-
*/
|
|
8
|
-
export declare const symbolAsyncIterator: typeof Symbol.asyncIterator;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Some JavaScript engines, in particular older versions of React Native, don't support Symbol.asyncIterator.
|
|
3
|
-
*
|
|
4
|
-
* For those, users relying on async generators typically lower them with a transpiler and [this polyfill](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/core-asynciterator-polyfill_1.0.2/sdk/core/core-asynciterator-polyfill/src/index.ts#L4-L6).
|
|
5
|
-
* This definition is compatible with that polyfill, so transpiled apps can use async iterables created by the PowerSync
|
|
6
|
-
* SDK.
|
|
7
|
-
*/
|
|
8
|
-
export const symbolAsyncIterator = Symbol.asyncIterator ?? Symbol.for('Symbol.asyncIterator');
|
|
9
|
-
//# sourceMappingURL=compatibility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../../src/utils/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CompilableQuery } from '../types/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export interface ParsedQuery {
|
|
6
|
-
sqlStatement: string;
|
|
7
|
-
parameters: any[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare const parseQuery: <T>(query: string | CompilableQuery<T>, parameters: any[]) => ParsedQuery;
|
package/lib/utils/parseQuery.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export const parseQuery = (query, parameters) => {
|
|
5
|
-
let sqlStatement;
|
|
6
|
-
if (typeof query == 'string') {
|
|
7
|
-
sqlStatement = query;
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
const hasAdditionalParameters = parameters.length > 0;
|
|
11
|
-
if (hasAdditionalParameters) {
|
|
12
|
-
throw new Error('You cannot pass parameters to a compiled query.');
|
|
13
|
-
}
|
|
14
|
-
const compiled = query.compile();
|
|
15
|
-
sqlStatement = compiled.sql;
|
|
16
|
-
parameters = compiled.parameters;
|
|
17
|
-
}
|
|
18
|
-
return { sqlStatement, parameters: parameters };
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=parseQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseQuery.js","sourceRoot":"","sources":["../../src/utils/parseQuery.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAI,KAAkC,EAAE,UAAiB,EAAe,EAAE;IAClG,IAAI,YAAoB,CAAC;IAEzB,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,YAAY,GAAG,KAAK,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,MAAM,uBAAuB,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACtD,IAAI,uBAAuB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;QACjC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC;QAC5B,UAAU,GAAG,QAAQ,CAAC,UAAmB,CAAC;IAC5C,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAClD,CAAC,CAAC"}
|
package/lib/utils/queue.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple fixed-capacity queue implementation.
|
|
3
|
-
*
|
|
4
|
-
* Unlike a naive queue implemented by `array.push()` and `array.shift()`, this avoids moving array elements around
|
|
5
|
-
* and is `O(1)` for {@link addLast} and {@link removeFirst}.
|
|
6
|
-
*/
|
|
7
|
-
export declare class Queue<T> {
|
|
8
|
-
private table;
|
|
9
|
-
private head;
|
|
10
|
-
private _length;
|
|
11
|
-
constructor(initialItems: Iterable<T>);
|
|
12
|
-
get isEmpty(): boolean;
|
|
13
|
-
get length(): number;
|
|
14
|
-
removeFirst(): T;
|
|
15
|
-
addLast(element: T): void;
|
|
16
|
-
}
|
package/lib/utils/queue.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple fixed-capacity queue implementation.
|
|
3
|
-
*
|
|
4
|
-
* Unlike a naive queue implemented by `array.push()` and `array.shift()`, this avoids moving array elements around
|
|
5
|
-
* and is `O(1)` for {@link addLast} and {@link removeFirst}.
|
|
6
|
-
*/
|
|
7
|
-
export class Queue {
|
|
8
|
-
table;
|
|
9
|
-
// Index of the first element in the table.
|
|
10
|
-
head;
|
|
11
|
-
// Amount of items currently in the queue.
|
|
12
|
-
_length;
|
|
13
|
-
constructor(initialItems) {
|
|
14
|
-
this.table = [...initialItems];
|
|
15
|
-
this.head = 0;
|
|
16
|
-
this._length = this.table.length;
|
|
17
|
-
}
|
|
18
|
-
get isEmpty() {
|
|
19
|
-
return this.length == 0;
|
|
20
|
-
}
|
|
21
|
-
get length() {
|
|
22
|
-
return this._length;
|
|
23
|
-
}
|
|
24
|
-
removeFirst() {
|
|
25
|
-
if (this.isEmpty) {
|
|
26
|
-
throw new Error('Queue is empty');
|
|
27
|
-
}
|
|
28
|
-
const result = this.table[this.head];
|
|
29
|
-
this._length--;
|
|
30
|
-
this.table[this.head] = undefined;
|
|
31
|
-
this.head = (this.head + 1) % this.table.length;
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
addLast(element) {
|
|
35
|
-
if (this.length == this.table.length) {
|
|
36
|
-
throw new Error('Queue is full');
|
|
37
|
-
}
|
|
38
|
-
this.table[(this.head + this._length) % this.table.length] = element;
|
|
39
|
-
this._length++;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=queue.js.map
|
package/lib/utils/queue.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/utils/queue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,KAAK;IACR,KAAK,CAAoB;IACjC,2CAA2C;IACnC,IAAI,CAAS;IACrB,0CAA0C;IAClC,OAAO,CAAS;IAExB,YAAY,YAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IACnC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAM,CAAC;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAChD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,OAAU;QAChB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;QACrE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An async iterator that can't be cancelled.
|
|
3
|
-
*
|
|
4
|
-
* To keep data flow simple, we always pass an explicit cancellation token when subscribing to async streams. Once the
|
|
5
|
-
* `AbortSignal` aborts, iterators are supposed to clean up and then emit a final `{done: true}` event. This means
|
|
6
|
-
* that there's no way to distinguish between streams that have completed normally and streams that have been cancelled,
|
|
7
|
-
* but that is acceptable for our uses of this.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export type SimpleAsyncIterator<T> = Pick<AsyncIterator<T>, 'next'>;
|
|
12
|
-
export declare const doneResult: IteratorReturnResult<any>;
|
|
13
|
-
export declare function valueResult<T>(value: T): {
|
|
14
|
-
done: boolean;
|
|
15
|
-
value: T;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A variant of {@link Array.map} for async iterators.
|
|
19
|
-
*/
|
|
20
|
-
export declare function map<T1, T2>(source: SimpleAsyncIterator<T1>, map: (source: T1) => T2): SimpleAsyncIterator<T2>;
|
|
21
|
-
export interface InjectableIterator<T> extends SimpleAsyncIterator<T> {
|
|
22
|
-
inject(event: T): void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Expands a source async iterator by allowing to inject events asynchronously.
|
|
26
|
-
*
|
|
27
|
-
* The resulting iterator will emit all events from its source. Additionally though, events can be injected. These
|
|
28
|
-
* events are dropped once the main iterator completes, but are otherwise forwarded.
|
|
29
|
-
*
|
|
30
|
-
* The iterator completes when its source completes, and it supports backpressure by only calling `next()` on the source
|
|
31
|
-
* in response to a `next()` call from downstream if no pending injected events can be dispatched.
|
|
32
|
-
*/
|
|
33
|
-
export declare function injectable<T>(source: SimpleAsyncIterator<T>): InjectableIterator<T>;
|
|
34
|
-
/**
|
|
35
|
-
* Splits a byte stream at line endings, emitting each line as a string.
|
|
36
|
-
*/
|
|
37
|
-
export declare function extractJsonLines(source: SimpleAsyncIterator<Uint8Array>, decoder: TextDecoder): SimpleAsyncIterator<string>;
|
|
38
|
-
/**
|
|
39
|
-
* Splits a concatenated stream of BSON objects by emitting individual objects.
|
|
40
|
-
*/
|
|
41
|
-
export declare function extractBsonObjects(source: SimpleAsyncIterator<Uint8Array>): SimpleAsyncIterator<Uint8Array>;
|