@powersync/common 0.0.0-dev-20250417091221 → 0.0.0-dev-20250418125956
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.
|
@@ -54,6 +54,13 @@ export type AbstractRemoteOptions = {
|
|
|
54
54
|
* Binding should be done before passing here.
|
|
55
55
|
*/
|
|
56
56
|
fetchImplementation: FetchImplementation | FetchImplementationProvider;
|
|
57
|
+
/**
|
|
58
|
+
* Optional options to pass directly to all `fetch` calls.
|
|
59
|
+
*
|
|
60
|
+
* This can include fields such as `dispatcher` (e.g. for proxy support),
|
|
61
|
+
* `cache`, or any other fetch-compatible options.
|
|
62
|
+
*/
|
|
63
|
+
fetchOptions?: {};
|
|
57
64
|
};
|
|
58
65
|
export declare const DEFAULT_REMOTE_OPTIONS: AbstractRemoteOptions;
|
|
59
66
|
export declare abstract class AbstractRemote {
|
|
@@ -84,6 +91,7 @@ export declare abstract class AbstractRemote {
|
|
|
84
91
|
* Provides a BSON implementation. The import nature of this varies depending on the platform
|
|
85
92
|
*/
|
|
86
93
|
abstract getBSON(): Promise<BSONImplementation>;
|
|
94
|
+
protected createSocket(url: string): WebSocket;
|
|
87
95
|
/**
|
|
88
96
|
* Connects to the sync/stream websocket endpoint
|
|
89
97
|
*/
|
|
@@ -44,7 +44,8 @@ export const DEFAULT_REMOTE_OPTIONS = {
|
|
|
44
44
|
socketUrlTransformer: (url) => url.replace(/^https?:\/\//, function (match) {
|
|
45
45
|
return match === 'https://' ? 'wss://' : 'ws://';
|
|
46
46
|
}),
|
|
47
|
-
fetchImplementation: new FetchImplementationProvider()
|
|
47
|
+
fetchImplementation: new FetchImplementationProvider(),
|
|
48
|
+
fetchOptions: {}
|
|
48
49
|
};
|
|
49
50
|
export class AbstractRemote {
|
|
50
51
|
connector;
|
|
@@ -153,6 +154,9 @@ export class AbstractRemote {
|
|
|
153
154
|
}
|
|
154
155
|
return res;
|
|
155
156
|
}
|
|
157
|
+
createSocket(url) {
|
|
158
|
+
return new WebSocket(url);
|
|
159
|
+
}
|
|
156
160
|
/**
|
|
157
161
|
* Connects to the sync/stream websocket endpoint
|
|
158
162
|
*/
|
|
@@ -167,7 +171,8 @@ export class AbstractRemote {
|
|
|
167
171
|
const userAgent = this.getUserAgent();
|
|
168
172
|
const connector = new RSocketConnector({
|
|
169
173
|
transport: new WebsocketClientTransport({
|
|
170
|
-
url: this.options.socketUrlTransformer(request.url)
|
|
174
|
+
url: this.options.socketUrlTransformer(request.url),
|
|
175
|
+
wsCreator: (url) => this.createSocket(url)
|
|
171
176
|
}),
|
|
172
177
|
setup: {
|
|
173
178
|
keepAlive: KEEP_ALIVE_MS,
|
|
@@ -318,6 +323,7 @@ export class AbstractRemote {
|
|
|
318
323
|
body: JSON.stringify(data),
|
|
319
324
|
signal: controller.signal,
|
|
320
325
|
cache: 'no-store',
|
|
326
|
+
...(this.options.fetchOptions ?? {}),
|
|
321
327
|
...options.fetchOptions
|
|
322
328
|
}).catch((ex) => {
|
|
323
329
|
if (ex.name == 'AbortError') {
|
package/lib/index.d.ts
CHANGED
|
@@ -32,6 +32,5 @@ export * from './db/DBAdapter.js';
|
|
|
32
32
|
export * from './utils/AbortOperation.js';
|
|
33
33
|
export * from './utils/BaseObserver.js';
|
|
34
34
|
export * from './utils/DataStream.js';
|
|
35
|
-
export * from './utils/Logger.js';
|
|
36
35
|
export * from './utils/parseQuery.js';
|
|
37
36
|
export * from './types/types.js';
|
package/lib/index.js
CHANGED
|
@@ -32,6 +32,5 @@ export * from './db/DBAdapter.js';
|
|
|
32
32
|
export * from './utils/AbortOperation.js';
|
|
33
33
|
export * from './utils/BaseObserver.js';
|
|
34
34
|
export * from './utils/DataStream.js';
|
|
35
|
-
export * from './utils/Logger.js';
|
|
36
35
|
export * from './utils/parseQuery.js';
|
|
37
36
|
export * from './types/types.js';
|
package/package.json
CHANGED
package/lib/utils/Logger.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Logger, { type ILogger, type ILogLevel } from 'js-logger';
|
|
2
|
-
export { GlobalLogger, ILogger, ILoggerOpts, ILogHandler, ILogLevel } from 'js-logger';
|
|
3
|
-
export declare const LogLevel: {
|
|
4
|
-
TRACE: Logger.ILogLevel;
|
|
5
|
-
DEBUG: Logger.ILogLevel;
|
|
6
|
-
INFO: Logger.ILogLevel;
|
|
7
|
-
TIME: Logger.ILogLevel;
|
|
8
|
-
WARN: Logger.ILogLevel;
|
|
9
|
-
ERROR: Logger.ILogLevel;
|
|
10
|
-
OFF: Logger.ILogLevel;
|
|
11
|
-
};
|
|
12
|
-
export interface CreateLoggerOptions {
|
|
13
|
-
logLevel?: ILogLevel;
|
|
14
|
-
}
|
|
15
|
-
export declare function createBaseLogger(): typeof Logger;
|
|
16
|
-
export declare function createLogger(name: string, options?: CreateLoggerOptions): ILogger;
|
package/lib/utils/Logger.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Logger from 'js-logger';
|
|
2
|
-
const TypedLogger = Logger;
|
|
3
|
-
export const LogLevel = {
|
|
4
|
-
TRACE: TypedLogger.TRACE,
|
|
5
|
-
DEBUG: TypedLogger.DEBUG,
|
|
6
|
-
INFO: TypedLogger.INFO,
|
|
7
|
-
TIME: TypedLogger.TIME,
|
|
8
|
-
WARN: TypedLogger.WARN,
|
|
9
|
-
ERROR: TypedLogger.ERROR,
|
|
10
|
-
OFF: TypedLogger.OFF
|
|
11
|
-
};
|
|
12
|
-
export function createBaseLogger() {
|
|
13
|
-
return Logger;
|
|
14
|
-
}
|
|
15
|
-
export function createLogger(name, options = {}) {
|
|
16
|
-
const logger = Logger.get(name);
|
|
17
|
-
if (options.logLevel) {
|
|
18
|
-
logger.setLevel(options.logLevel);
|
|
19
|
-
}
|
|
20
|
-
return logger;
|
|
21
|
-
}
|