@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
package/src/db/schema/Schema.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { encodeTableOptions } from './internal.js';
|
|
2
2
|
import { RawTable, RawTableType } from './RawTable.js';
|
|
3
|
-
import { RowType, Table } from './Table.js';
|
|
3
|
+
import { ResolvedTable, RowType, Table } from './Table.js';
|
|
4
4
|
|
|
5
5
|
type SchemaType = Record<string, Table<any>>;
|
|
6
6
|
|
|
@@ -22,10 +22,10 @@ export class Schema<S extends SchemaType = SchemaType> {
|
|
|
22
22
|
*/
|
|
23
23
|
readonly types!: SchemaTableType<S>;
|
|
24
24
|
readonly props!: S;
|
|
25
|
-
readonly tables:
|
|
25
|
+
readonly tables: ResolvedTable[];
|
|
26
26
|
readonly rawTables: RawTable[];
|
|
27
27
|
|
|
28
|
-
constructor(tables:
|
|
28
|
+
constructor(tables: ResolvedTable[] | S) {
|
|
29
29
|
if (Array.isArray(tables)) {
|
|
30
30
|
/*
|
|
31
31
|
We need to validate that the tables have a name here because a user could pass in an array
|
|
@@ -71,7 +71,7 @@ export class Schema<S extends SchemaType = SchemaType> {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
toJSON() {
|
|
74
|
+
toJSON(): unknown {
|
|
75
75
|
return {
|
|
76
76
|
tables: this.tables.map((t) => t.toJSON()),
|
|
77
77
|
raw_tables: this.rawTables.map(Schema.rawTableToJson)
|
package/src/db/schema/Table.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseColumnType,
|
|
3
|
-
Column,
|
|
4
|
-
ColumnsType,
|
|
5
|
-
ColumnType,
|
|
6
|
-
ExtractColumnValueType,
|
|
7
|
-
MAX_AMOUNT_OF_COLUMNS
|
|
8
|
-
} from './Column.js';
|
|
1
|
+
import { Column, ColumnsType, ExtractColumnValueType } from './Column.js';
|
|
9
2
|
import { Index } from './Index.js';
|
|
10
3
|
import { IndexedColumn } from './IndexedColumn.js';
|
|
11
4
|
import { encodeTableOptions } from './internal.js';
|
|
12
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* powersync-sqlite-core limits the number of column per table to 1999, due to internal SQLite limits.
|
|
8
|
+
* In earlier versions this was limited to 63.
|
|
9
|
+
*/
|
|
10
|
+
const MAX_AMOUNT_OF_COLUMNS = 1999;
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Options that apply both to JSON-based tables and raw tables.
|
|
@@ -45,7 +43,7 @@ export interface TrackPreviousOptions {
|
|
|
45
43
|
/**
|
|
46
44
|
* @public
|
|
47
45
|
*/
|
|
48
|
-
export interface
|
|
46
|
+
export interface ResolvedTableOptions extends SharedTableOptions {
|
|
49
47
|
/**
|
|
50
48
|
* The synced table name, matching sync rules
|
|
51
49
|
*/
|
|
@@ -57,29 +55,24 @@ export interface TableOptions extends SharedTableOptions {
|
|
|
57
55
|
/**
|
|
58
56
|
* @public
|
|
59
57
|
*/
|
|
60
|
-
export type RowType<T extends
|
|
61
|
-
|
|
62
|
-
} & {
|
|
63
|
-
|
|
64
|
-
};
|
|
58
|
+
export type RowType<T extends Table<any>> =
|
|
59
|
+
T extends Table<infer Columns>
|
|
60
|
+
? { [K in keyof Columns]: ExtractColumnValueType<Columns[K]> } & { id: string }
|
|
61
|
+
: never;
|
|
65
62
|
|
|
66
63
|
/**
|
|
67
64
|
* @public
|
|
68
65
|
*/
|
|
69
|
-
export type IndexShorthand = Record<string, string[]>;
|
|
66
|
+
export type IndexShorthand = Record<string, (string | IndexedColumn)[]>;
|
|
70
67
|
|
|
71
68
|
/**
|
|
72
69
|
* @public
|
|
73
70
|
*/
|
|
74
|
-
|
|
75
|
-
export interface TableV2Options extends SharedTableOptions {
|
|
71
|
+
export interface TableOptions extends SharedTableOptions {
|
|
76
72
|
indexes?: IndexShorthand;
|
|
77
73
|
}
|
|
78
74
|
|
|
79
|
-
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
export const DEFAULT_TABLE_OPTIONS = {
|
|
75
|
+
const DEFAULT_TABLE_OPTIONS = {
|
|
83
76
|
indexes: [],
|
|
84
77
|
insertOnly: false,
|
|
85
78
|
localOnly: false,
|
|
@@ -88,165 +81,18 @@ export const DEFAULT_TABLE_OPTIONS = {
|
|
|
88
81
|
ignoreEmptyUpdates: false
|
|
89
82
|
};
|
|
90
83
|
|
|
91
|
-
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
94
|
-
export const InvalidSQLCharacters = /["'%,.#\s[\]]/;
|
|
84
|
+
const InvalidSQLCharacters = /["'%,.#\s[\]]/;
|
|
95
85
|
|
|
96
86
|
/**
|
|
87
|
+
* A resolved table in the PowerSync schema, with all columns, index definitions and options.
|
|
88
|
+
*
|
|
89
|
+
* When constructing tables for your schema, consider using {@link Table} instead.
|
|
90
|
+
*
|
|
97
91
|
* @public
|
|
98
92
|
*/
|
|
99
|
-
export class
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
protected _mappedColumns!: Columns;
|
|
103
|
-
|
|
104
|
-
static createLocalOnly(options: TableOptions) {
|
|
105
|
-
return new Table({ ...options, localOnly: true, insertOnly: false });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static createInsertOnly(options: TableOptions) {
|
|
109
|
-
return new Table({ ...options, localOnly: false, insertOnly: true });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Create a table.
|
|
114
|
-
* @deprecated This was only only included for TableV2 and is no longer necessary.
|
|
115
|
-
* Prefer to use new Table() directly.
|
|
116
|
-
*
|
|
117
|
-
* TODO remove in the next major release.
|
|
118
|
-
*/
|
|
119
|
-
static createTable(name: string, table: Table) {
|
|
120
|
-
return new Table({
|
|
121
|
-
name,
|
|
122
|
-
columns: table.columns,
|
|
123
|
-
indexes: table.indexes,
|
|
124
|
-
localOnly: table.options.localOnly,
|
|
125
|
-
insertOnly: table.options.insertOnly,
|
|
126
|
-
viewName: table.options.viewName
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Creates a new Table instance.
|
|
132
|
-
*
|
|
133
|
-
* This constructor supports two different versions:
|
|
134
|
-
* 1. New constructor: Using a Columns object and an optional TableV2Options object
|
|
135
|
-
* 2. Deprecated constructor: Using a TableOptions object (will be removed in the next major release)
|
|
136
|
-
*
|
|
137
|
-
* @param columns - Either a Columns object (for V2 syntax) or a TableOptions object (for V1 syntax)
|
|
138
|
-
* @param options - Optional configuration options for V2 syntax
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```javascript
|
|
142
|
-
* // New Constructor
|
|
143
|
-
* const table = new Table(
|
|
144
|
-
* {
|
|
145
|
-
* name: column.text,
|
|
146
|
-
* age: column.integer
|
|
147
|
-
* },
|
|
148
|
-
* { indexes: { nameIndex: ['name'] } }
|
|
149
|
-
* );
|
|
150
|
-
*```
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```javascript
|
|
155
|
-
* // Deprecated Constructor
|
|
156
|
-
* const table = new Table({
|
|
157
|
-
* name: 'users',
|
|
158
|
-
* columns: [
|
|
159
|
-
* new Column({ name: 'name', type: ColumnType.TEXT }),
|
|
160
|
-
* new Column({ name: 'age', type: ColumnType.INTEGER })
|
|
161
|
-
* ]
|
|
162
|
-
* });
|
|
163
|
-
*```
|
|
164
|
-
*/
|
|
165
|
-
constructor(columns: Columns, options?: TableV2Options);
|
|
166
|
-
/**
|
|
167
|
-
* @deprecated This constructor will be removed in the next major release.
|
|
168
|
-
* Use the new constructor shown below instead as this does not show types.
|
|
169
|
-
* @example
|
|
170
|
-
* <caption>Use this instead</caption>
|
|
171
|
-
* ```javascript
|
|
172
|
-
* const table = new Table(
|
|
173
|
-
* {
|
|
174
|
-
* name: column.text,
|
|
175
|
-
* age: column.integer
|
|
176
|
-
* },
|
|
177
|
-
* { indexes: { nameIndex: ['name'] } }
|
|
178
|
-
* );
|
|
179
|
-
*```
|
|
180
|
-
*/
|
|
181
|
-
constructor(options: TableOptions);
|
|
182
|
-
constructor(optionsOrColumns: Columns | TableOptions, v2Options?: TableV2Options) {
|
|
183
|
-
if (this.isTableV1(optionsOrColumns)) {
|
|
184
|
-
this.initTableV1(optionsOrColumns);
|
|
185
|
-
} else {
|
|
186
|
-
this.initTableV2(optionsOrColumns, v2Options);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
copyWithName(name: string): Table {
|
|
191
|
-
return new Table({
|
|
192
|
-
...this.options,
|
|
193
|
-
name
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private isTableV1(arg: TableOptions | Columns): arg is TableOptions {
|
|
198
|
-
return 'columns' in arg && Array.isArray(arg.columns);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
private initTableV1(options: TableOptions) {
|
|
202
|
-
this.options = {
|
|
203
|
-
...options,
|
|
204
|
-
indexes: options.indexes || []
|
|
205
|
-
};
|
|
206
|
-
this.applyDefaultOptions();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
private initTableV2(columns: Columns, options?: TableV2Options) {
|
|
210
|
-
const convertedColumns = Object.entries(columns).map(
|
|
211
|
-
([name, columnInfo]) => new Column({ name, type: columnInfo.type })
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
const convertedIndexes = Object.entries(options?.indexes ?? {}).map(
|
|
215
|
-
([name, columnNames]) =>
|
|
216
|
-
new Index({
|
|
217
|
-
name,
|
|
218
|
-
columns: columnNames.map(
|
|
219
|
-
(name) =>
|
|
220
|
-
new IndexedColumn({
|
|
221
|
-
name: name.replace(/^-/, ''),
|
|
222
|
-
ascending: !name.startsWith('-')
|
|
223
|
-
})
|
|
224
|
-
)
|
|
225
|
-
})
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
this.options = {
|
|
229
|
-
name: '',
|
|
230
|
-
columns: convertedColumns,
|
|
231
|
-
indexes: convertedIndexes,
|
|
232
|
-
viewName: options?.viewName,
|
|
233
|
-
insertOnly: options?.insertOnly,
|
|
234
|
-
localOnly: options?.localOnly,
|
|
235
|
-
trackPrevious: options?.trackPrevious,
|
|
236
|
-
trackMetadata: options?.trackMetadata,
|
|
237
|
-
ignoreEmptyUpdates: options?.ignoreEmptyUpdates
|
|
238
|
-
};
|
|
93
|
+
export class ResolvedTable {
|
|
94
|
+
constructor(readonly options: ResolvedTableOptions) {
|
|
239
95
|
this.applyDefaultOptions();
|
|
240
|
-
|
|
241
|
-
this._mappedColumns = columns;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
private applyDefaultOptions() {
|
|
245
|
-
this.options.insertOnly ??= DEFAULT_TABLE_OPTIONS.insertOnly;
|
|
246
|
-
this.options.localOnly ??= DEFAULT_TABLE_OPTIONS.localOnly;
|
|
247
|
-
this.options.trackPrevious ??= DEFAULT_TABLE_OPTIONS.trackPrevious;
|
|
248
|
-
this.options.trackMetadata ??= DEFAULT_TABLE_OPTIONS.trackMetadata;
|
|
249
|
-
this.options.ignoreEmptyUpdates ??= DEFAULT_TABLE_OPTIONS.ignoreEmptyUpdates;
|
|
250
96
|
}
|
|
251
97
|
|
|
252
98
|
get name() {
|
|
@@ -265,16 +111,6 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
265
111
|
return this.options.columns;
|
|
266
112
|
}
|
|
267
113
|
|
|
268
|
-
get columnMap(): Columns {
|
|
269
|
-
return (
|
|
270
|
-
this._mappedColumns ??
|
|
271
|
-
this.columns.reduce((hash: Record<string, BaseColumnType<any>>, column) => {
|
|
272
|
-
hash[column.name] = { type: column.type ?? ColumnType.TEXT };
|
|
273
|
-
return hash;
|
|
274
|
-
}, {} as Columns)
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
114
|
get indexes() {
|
|
279
115
|
return this.options.indexes ?? [];
|
|
280
116
|
}
|
|
@@ -381,4 +217,93 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
|
|
|
381
217
|
...encodeTableOptions(this)
|
|
382
218
|
};
|
|
383
219
|
}
|
|
220
|
+
|
|
221
|
+
private applyDefaultOptions() {
|
|
222
|
+
this.options.insertOnly ??= DEFAULT_TABLE_OPTIONS.insertOnly;
|
|
223
|
+
this.options.localOnly ??= DEFAULT_TABLE_OPTIONS.localOnly;
|
|
224
|
+
this.options.trackPrevious ??= DEFAULT_TABLE_OPTIONS.trackPrevious;
|
|
225
|
+
this.options.trackMetadata ??= DEFAULT_TABLE_OPTIONS.trackMetadata;
|
|
226
|
+
this.options.ignoreEmptyUpdates ??= DEFAULT_TABLE_OPTIONS.ignoreEmptyUpdates;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* A table with a statically-typed `Columns` record structure.
|
|
232
|
+
*
|
|
233
|
+
* This is the recommended way to declare tables in PowerSync schemas.
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
export class Table<Columns extends ColumnsType = ColumnsType> extends ResolvedTable {
|
|
238
|
+
protected _mappedColumns!: Columns;
|
|
239
|
+
|
|
240
|
+
static createLocalOnly<Columns extends ColumnsType = ColumnsType>(columns: Columns, options?: TableOptions) {
|
|
241
|
+
return new Table(columns, { localOnly: true, insertOnly: false, ...options });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
static createInsertOnly<Columns extends ColumnsType = ColumnsType>(columns: Columns, options?: TableOptions) {
|
|
245
|
+
return new Table(columns, { localOnly: false, insertOnly: true, ...options });
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Creates a new Table instance.
|
|
250
|
+
*
|
|
251
|
+
* @param columns - A Columns object (a record of column names to column types).
|
|
252
|
+
* @param options - Optional configuration options for the table.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```javascript
|
|
256
|
+
* const table = new Table(
|
|
257
|
+
* {
|
|
258
|
+
* name: column.text,
|
|
259
|
+
* age: column.integer
|
|
260
|
+
* },
|
|
261
|
+
* { indexes: { nameIndex: ['name'] } }
|
|
262
|
+
* );
|
|
263
|
+
*```
|
|
264
|
+
*/
|
|
265
|
+
constructor(columns: Columns, options?: TableOptions) {
|
|
266
|
+
super(Table.optionsFromColumns<Columns>(columns, options));
|
|
267
|
+
this._mappedColumns = columns;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
copyWithName(name: string): ResolvedTable {
|
|
271
|
+
return new ResolvedTable({ ...this.options, name });
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private static optionsFromColumns<Columns extends ColumnsType>(
|
|
275
|
+
columns: Columns,
|
|
276
|
+
options?: TableOptions
|
|
277
|
+
): ResolvedTableOptions {
|
|
278
|
+
const convertedColumns = Object.entries(columns).map(
|
|
279
|
+
([name, columnInfo]) => new Column({ name, type: columnInfo.type })
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const convertedIndexes = Object.entries(options?.indexes ?? {}).map(
|
|
283
|
+
([name, columnNames]) =>
|
|
284
|
+
new Index({
|
|
285
|
+
name,
|
|
286
|
+
columns: columnNames.map((nameOrIndexedColumn) =>
|
|
287
|
+
typeof nameOrIndexedColumn === 'string'
|
|
288
|
+
? new IndexedColumn({
|
|
289
|
+
name: nameOrIndexedColumn.replace(/^-/, ''),
|
|
290
|
+
ascending: !nameOrIndexedColumn.startsWith('-')
|
|
291
|
+
})
|
|
292
|
+
: nameOrIndexedColumn
|
|
293
|
+
)
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
return {
|
|
298
|
+
name: '',
|
|
299
|
+
columns: convertedColumns,
|
|
300
|
+
indexes: convertedIndexes,
|
|
301
|
+
viewName: options?.viewName,
|
|
302
|
+
insertOnly: options?.insertOnly,
|
|
303
|
+
localOnly: options?.localOnly,
|
|
304
|
+
trackPrevious: options?.trackPrevious,
|
|
305
|
+
trackMetadata: options?.trackMetadata,
|
|
306
|
+
ignoreEmptyUpdates: options?.ignoreEmptyUpdates
|
|
307
|
+
};
|
|
308
|
+
}
|
|
384
309
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,63 +1,47 @@
|
|
|
1
1
|
export * from './attachments/AttachmentContext.js';
|
|
2
2
|
export * from './attachments/AttachmentErrorHandler.js';
|
|
3
3
|
export * from './attachments/AttachmentQueue.js';
|
|
4
|
-
export * from './attachments/AttachmentService.js';
|
|
5
4
|
export * from './attachments/LocalStorageAdapter.js';
|
|
6
5
|
export * from './attachments/RemoteStorageAdapter.js';
|
|
7
6
|
export * from './attachments/Schema.js';
|
|
8
|
-
export * from './attachments/SyncingService.js';
|
|
9
7
|
export * from './attachments/WatchedAttachmentItem.js';
|
|
10
8
|
|
|
11
|
-
export * from './client/
|
|
12
|
-
export * from './client/AbstractPowerSyncOpenFactory.js';
|
|
9
|
+
export * from './client/CommonPowerSyncDatabase.js';
|
|
13
10
|
export { compilableQueryWatch, CompilableQueryWatchHandler } from './client/compilableQueryWatch.js';
|
|
14
11
|
export * from './client/connection/PowerSyncBackendConnector.js';
|
|
15
12
|
export * from './client/connection/PowerSyncCredentials.js';
|
|
16
|
-
export { MAX_OP_ID } from './client/constants.js';
|
|
17
|
-
export { runOnSchemaChange } from './client/runOnSchemaChange.js';
|
|
18
13
|
export * from './client/SQLOpenFactory.js';
|
|
19
|
-
export * from './client/sync/bucket/BucketStorageAdapter.js';
|
|
20
14
|
export * from './client/sync/bucket/CrudBatch.js';
|
|
21
15
|
export { CrudEntry, OpId, UpdateType } from './client/sync/bucket/CrudEntry.js';
|
|
22
16
|
export * from './client/sync/bucket/CrudTransaction.js';
|
|
23
|
-
export * from './client/sync/bucket/SqliteBucketStorage.js';
|
|
24
|
-
export * from './client/sync/stream/AbstractRemote.js';
|
|
25
|
-
export * from './client/sync/stream/AbstractStreamingSyncImplementation.js';
|
|
26
17
|
export * from './client/sync/stream/JsonValue.js';
|
|
27
18
|
export * from './client/sync/sync-streams.js';
|
|
19
|
+
export { SyncOptions, SyncStreamConnectionMethod, FetchStrategy } from './client/sync/options.js';
|
|
28
20
|
|
|
29
|
-
export * from './client/ConnectionManager.js';
|
|
30
|
-
export * from './db/ConnectionClosedError.js';
|
|
31
21
|
export { ProgressWithOperations, SyncProgress } from './db/crud/SyncProgress.js';
|
|
32
22
|
export * from './db/crud/SyncStatus.js';
|
|
33
23
|
export * from './db/crud/UploadQueueStatus.js';
|
|
34
24
|
export * from './db/DBAdapter.js';
|
|
25
|
+
export * from './db/QueryResult.js';
|
|
35
26
|
export * from './db/schema/Column.js';
|
|
36
27
|
export * from './db/schema/Index.js';
|
|
37
28
|
export * from './db/schema/IndexedColumn.js';
|
|
38
29
|
export { PendingStatement, PendingStatementParameter, RawTableType } from './db/schema/RawTable.js';
|
|
39
30
|
export * from './db/schema/Schema.js';
|
|
40
31
|
export * from './db/schema/Table.js';
|
|
41
|
-
export * from './db/schema/TableV2.js';
|
|
42
32
|
|
|
43
33
|
export * from './client/Query.js';
|
|
44
|
-
export { MEMORY_TRIGGER_CLAIM_MANAGER } from './client/triggers/MemoryTriggerClaimManager.js';
|
|
45
34
|
export * from './client/triggers/sanitizeSQL.js';
|
|
46
35
|
export * from './client/triggers/TriggerManager.js';
|
|
47
|
-
export { TriggerManagerImpl } from './client/triggers/TriggerManagerImpl.js';
|
|
48
36
|
export * from './client/watched/GetAllQuery.js';
|
|
49
|
-
export * from './client/watched/processors/AbstractQueryProcessor.js';
|
|
50
37
|
export * from './client/watched/processors/comparators.js';
|
|
51
38
|
export * from './client/watched/processors/DifferentialQueryProcessor.js';
|
|
52
39
|
export * from './client/watched/processors/OnChangeQueryProcessor.js';
|
|
53
40
|
export * from './client/watched/WatchedQuery.js';
|
|
54
41
|
|
|
55
|
-
export
|
|
42
|
+
export { type Mutex } from './utils/mutex.js';
|
|
56
43
|
export * from './utils/BaseObserver.js';
|
|
57
|
-
export * from './utils/
|
|
44
|
+
export * from './utils/MetaBaseObserver.js';
|
|
58
45
|
export * from './utils/Logger.js';
|
|
59
|
-
export * from './utils/mutex.js';
|
|
60
|
-
export * from './utils/parseQuery.js';
|
|
61
|
-
export type { SimpleAsyncIterator } from './utils/stream_transform.js';
|
|
62
46
|
|
|
63
47
|
export * from './types/types.js';
|
|
@@ -18,7 +18,7 @@ export interface BaseObserverInterface<T extends BaseListener> {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* @
|
|
21
|
+
* @public
|
|
22
22
|
*/
|
|
23
23
|
export class BaseObserver<T extends BaseListener = BaseListener> implements BaseObserverInterface<T> {
|
|
24
24
|
protected listeners = new Set<Partial<T>>();
|
package/src/utils/Logger.ts
CHANGED
|
@@ -1,56 +1,102 @@
|
|
|
1
|
-
import Logger, { type ILogger, type ILogLevel } from 'js-logger';
|
|
2
|
-
|
|
3
|
-
export { GlobalLogger, ILogger, ILoggerOpts, ILogHandler, ILogLevel } from 'js-logger';
|
|
4
|
-
|
|
5
|
-
const TypedLogger: ILogger = Logger as any;
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* @public
|
|
9
3
|
*/
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
OFF: TypedLogger.OFF
|
|
18
|
-
};
|
|
4
|
+
export const LogLevels = {
|
|
5
|
+
trace: 10,
|
|
6
|
+
debug: 20,
|
|
7
|
+
info: 30,
|
|
8
|
+
warn: 40,
|
|
9
|
+
error: 50
|
|
10
|
+
} as const;
|
|
19
11
|
|
|
20
12
|
/**
|
|
13
|
+
* A log record passed to a {@link PowerSyncLogger}.
|
|
14
|
+
*
|
|
21
15
|
* @public
|
|
22
16
|
*/
|
|
23
|
-
export interface
|
|
24
|
-
|
|
17
|
+
export interface LogRecord {
|
|
18
|
+
/**
|
|
19
|
+
* The log level (see {@link LogLevels} for preconfigured values) for the message. Depending on how a receiving logger
|
|
20
|
+
* has been configured, messages below a configured minimum level may be ignored.
|
|
21
|
+
*/
|
|
22
|
+
level: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The main message to log.
|
|
26
|
+
*/
|
|
27
|
+
message: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* When the log message contains an error, the error causing the log.
|
|
31
|
+
*
|
|
32
|
+
* This is not guaranteed to be an `Error` instance. On the web, we might have to serialize objects across message
|
|
33
|
+
* channels and represent them as a string.
|
|
34
|
+
*/
|
|
35
|
+
error?: unknown;
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
/**
|
|
28
|
-
*
|
|
39
|
+
* A logger used by the PowerSync SDK.
|
|
29
40
|
*
|
|
30
|
-
* This
|
|
31
|
-
*
|
|
32
|
-
*
|
|
41
|
+
* This is deliberately a very simple interface, and it's not a designed to be a general-purpose logger you would use in
|
|
42
|
+
* your application. Instead, you can provide an implementation of this to PowerSync to make it use your preferred
|
|
43
|
+
* logging libraries.
|
|
44
|
+
*
|
|
45
|
+
* By default, the SDK uses a {@link createConsoleLogger} instance forwarding messages to `console.log`.
|
|
33
46
|
*
|
|
34
47
|
* @public
|
|
35
48
|
*/
|
|
36
|
-
export
|
|
37
|
-
|
|
49
|
+
export interface PowerSyncLogger {
|
|
50
|
+
log(record: LogRecord): void;
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
/**
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export interface CreateLoggerOptions {
|
|
57
|
+
/**
|
|
58
|
+
* A prefix for messages emitted by {@link createConsoleLogger} to make them more recognizable.
|
|
59
|
+
*
|
|
60
|
+
* Defaults to `'PowerSync'`.
|
|
61
|
+
*/
|
|
62
|
+
prefix: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The minimum log level to consider for messages. Defaults to {@link LogLevels.info}.
|
|
66
|
+
*/
|
|
67
|
+
minLevel: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A very simple {@link PowerSyncLogger} implementation forwarding messages to `console.log`.
|
|
46
72
|
*
|
|
73
|
+
* @param options - Options to configure a minimum severity of the logger or a prefix to make messages more recognizable.
|
|
47
74
|
* @public
|
|
48
75
|
*/
|
|
49
|
-
export function
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
76
|
+
export function createConsoleLogger(options?: Partial<CreateLoggerOptions>): PowerSyncLogger & CreateLoggerOptions {
|
|
77
|
+
const { prefix = 'PowerSync', minLevel = LogLevels.info } = options ?? {};
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
prefix,
|
|
81
|
+
minLevel,
|
|
82
|
+
log({ level, message, error }) {
|
|
83
|
+
if (level < this.minLevel) return;
|
|
84
|
+
|
|
85
|
+
let emitter = console.log;
|
|
86
|
+
if (level >= LogLevels.error) {
|
|
87
|
+
emitter = console.error;
|
|
88
|
+
} else if (level >= LogLevels.warn) {
|
|
89
|
+
emitter = console.warn;
|
|
90
|
+
} else if (level >= LogLevels.info) {
|
|
91
|
+
emitter = console.info;
|
|
92
|
+
}
|
|
54
93
|
|
|
55
|
-
|
|
94
|
+
const messageWithPrefix = `[${prefix}]: ${message}`;
|
|
95
|
+
if (error) {
|
|
96
|
+
emitter(messageWithPrefix, error);
|
|
97
|
+
} else {
|
|
98
|
+
emitter(messageWithPrefix);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
56
102
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { BaseListener,
|
|
1
|
+
import { BaseListener, BaseObserverInterface } from './BaseObserver.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Represents the counts of listeners for each event type in a BaseListener.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
5
7
|
*/
|
|
6
8
|
export type ListenerCounts<Listener extends BaseListener> = Partial<Record<keyof Listener, number>> & {
|
|
7
9
|
total: number;
|
|
@@ -9,73 +11,25 @@ export type ListenerCounts<Listener extends BaseListener> = Partial<Record<keyof
|
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Meta listener which reports the counts of listeners for each event type.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
12
16
|
*/
|
|
13
17
|
export interface MetaListener<ParentListener extends BaseListener> extends BaseListener {
|
|
14
18
|
listenersChanged?: (counts: ListenerCounts<ParentListener>) => void;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export interface ListenerMetaManager<Listener extends BaseListener> extends BaseObserverInterface<
|
|
25
|
+
MetaListener<Listener>
|
|
26
|
+
> {
|
|
19
27
|
counts: ListenerCounts<Listener>;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
export interface MetaBaseObserverInterface<Listener extends BaseListener> extends BaseObserverInterface<Listener> {
|
|
23
|
-
listenerMeta: ListenerMetaManager<Listener>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* @public
|
|
28
32
|
*/
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
implements MetaBaseObserverInterface<Listener>
|
|
32
|
-
{
|
|
33
|
-
protected get listenerCounts(): ListenerCounts<Listener> {
|
|
34
|
-
const counts = {} as Partial<Record<keyof Listener, number>>;
|
|
35
|
-
let total = 0;
|
|
36
|
-
for (const listener of this.listeners) {
|
|
37
|
-
for (const key in listener) {
|
|
38
|
-
if (listener[key]) {
|
|
39
|
-
counts[key] = (counts[key] ?? 0) + 1;
|
|
40
|
-
total++;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...counts,
|
|
46
|
-
total
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get listenerMeta(): ListenerMetaManager<Listener> {
|
|
51
|
-
return {
|
|
52
|
-
counts: this.listenerCounts,
|
|
53
|
-
// Allows registering a meta listener that will be notified of changes in listener counts
|
|
54
|
-
registerListener: (listener: Partial<MetaListener<Listener>>) => {
|
|
55
|
-
return this.metaListener.registerListener(listener);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
protected metaListener: BaseObserver<MetaListener<Listener>>;
|
|
61
|
-
|
|
62
|
-
constructor() {
|
|
63
|
-
super();
|
|
64
|
-
this.metaListener = new BaseObserver<MetaListener<Listener>>();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
registerListener(listener: Partial<Listener>): () => void {
|
|
68
|
-
const dispose = super.registerListener(listener);
|
|
69
|
-
const updatedCount = this.listenerCounts;
|
|
70
|
-
this.metaListener.iterateListeners((l) => {
|
|
71
|
-
l.listenersChanged?.(updatedCount);
|
|
72
|
-
});
|
|
73
|
-
return () => {
|
|
74
|
-
dispose();
|
|
75
|
-
const updatedCount = this.listenerCounts;
|
|
76
|
-
this.metaListener.iterateListeners((l) => {
|
|
77
|
-
l.listenersChanged?.(updatedCount);
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
}
|
|
33
|
+
export interface MetaBaseObserverInterface<Listener extends BaseListener> extends BaseObserverInterface<Listener> {
|
|
34
|
+
listenerMeta: ListenerMetaManager<Listener>;
|
|
81
35
|
}
|