@powersync/react-native 1.33.1 → 1.34.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractRemote, AbstractRemoteOptions, BSONImplementation,
|
|
1
|
+
import { AbstractRemote, AbstractRemoteOptions, BSONImplementation, ILogger, RemoteConnector, SyncStreamOptions } from '@powersync/common';
|
|
2
2
|
import { TextDecoder } from 'text-encoding';
|
|
3
3
|
export declare const STREAMING_POST_TIMEOUT_MS = 30000;
|
|
4
4
|
export declare class ReactNativeRemote extends AbstractRemote {
|
|
@@ -7,6 +7,10 @@ export declare class ReactNativeRemote extends AbstractRemote {
|
|
|
7
7
|
constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
|
|
8
8
|
getUserAgent(): string;
|
|
9
9
|
getBSON(): Promise<BSONImplementation>;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
createTextDecoder(): TextDecoder;
|
|
11
|
+
protected get supportsStreamingBinaryResponses(): boolean;
|
|
12
|
+
protected fetchStreamRaw(options: SyncStreamOptions): Promise<{
|
|
13
|
+
isBson: boolean;
|
|
14
|
+
stream: import("@powersync/common").SimpleAsyncIterator<Uint8Array>;
|
|
15
|
+
}>;
|
|
12
16
|
}
|
|
@@ -40,14 +40,18 @@ export class ReactNativeRemote extends AbstractRemote {
|
|
|
40
40
|
createTextDecoder() {
|
|
41
41
|
return new TextDecoder();
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
get supportsStreamingBinaryResponses() {
|
|
44
|
+
// We have to pass textStreaming: true to get streamed responses at all, and those don't support binary data.
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
async fetchStreamRaw(options) {
|
|
44
48
|
const timeout = Platform.OS == 'android'
|
|
45
49
|
? setTimeout(() => {
|
|
46
50
|
this.logger.warn(`HTTP Streaming POST is taking longer than ${Math.ceil(STREAMING_POST_TIMEOUT_MS / 1000)} seconds to resolve. If using a debug build, please ensure Flipper Network plugin is disabled.`);
|
|
47
51
|
}, STREAMING_POST_TIMEOUT_MS)
|
|
48
52
|
: null;
|
|
49
53
|
try {
|
|
50
|
-
return await super.
|
|
54
|
+
return await super.fetchStreamRaw({
|
|
51
55
|
...options,
|
|
52
56
|
fetchOptions: {
|
|
53
57
|
...options.fetchOptions,
|
|
@@ -59,7 +63,7 @@ export class ReactNativeRemote extends AbstractRemote {
|
|
|
59
63
|
// @ts-expect-error https://github.com/react-native-community/fetch#enable-text-streaming
|
|
60
64
|
reactNative: { textStreaming: true }
|
|
61
65
|
}
|
|
62
|
-
}
|
|
66
|
+
});
|
|
63
67
|
}
|
|
64
68
|
finally {
|
|
65
69
|
if (timeout) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeRemote.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAGd,qBAAqB,
|
|
1
|
+
{"version":3,"file":"ReactNativeRemote.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAGd,qBAAqB,EAErB,2BAA2B,EAI5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,gGAAgG;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEhD;;;;GAIG;AACH,MAAM,wBAAyB,SAAQ,2BAA2B;IAChE,QAAQ;QACN,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB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ACZ,GAAG,OAAO,CAAC,YAAY;oBACvB;;;;uBAIG;oBACH,yFAAyF;oBACzF,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;iBACrC;aACF,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,OAAO,EAAE,CAAC;gBACZ,YAAY,CAAC,OAAO,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/powersync-ja/powersync-js.git"
|
|
20
20
|
},
|
|
21
|
-
"author": "
|
|
21
|
+
"author": "PowerSync",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"bugs": {
|
|
24
24
|
"url": "https://github.com/powersync-ja/powersync-js/issues"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"homepage": "https://docs.powersync.com/",
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@journeyapps/react-native-quick-sqlite": "^2.5.1",
|
|
29
|
-
"@powersync/common": "^1.
|
|
29
|
+
"@powersync/common": "^1.52.0",
|
|
30
30
|
"react": "*",
|
|
31
31
|
"react-native": "*"
|
|
32
32
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@powersync/common": "1.
|
|
39
|
+
"@powersync/common": "1.52.0",
|
|
40
40
|
"@powersync/react": "1.10.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
AbstractRemoteOptions,
|
|
4
4
|
BSONImplementation,
|
|
5
5
|
DEFAULT_REMOTE_LOGGER,
|
|
6
|
-
DataStream,
|
|
7
6
|
FetchImplementation,
|
|
8
7
|
FetchImplementationProvider,
|
|
9
8
|
ILogger,
|
|
@@ -55,11 +54,16 @@ export class ReactNativeRemote extends AbstractRemote {
|
|
|
55
54
|
return BSON;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
createTextDecoder(): TextDecoder {
|
|
59
58
|
return new TextDecoder();
|
|
60
59
|
}
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
protected get supportsStreamingBinaryResponses(): boolean {
|
|
62
|
+
// We have to pass textStreaming: true to get streamed responses at all, and those don't support binary data.
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected async fetchStreamRaw(options: SyncStreamOptions) {
|
|
63
67
|
const timeout =
|
|
64
68
|
Platform.OS == 'android'
|
|
65
69
|
? setTimeout(() => {
|
|
@@ -72,22 +76,19 @@ export class ReactNativeRemote extends AbstractRemote {
|
|
|
72
76
|
: null;
|
|
73
77
|
|
|
74
78
|
try {
|
|
75
|
-
return await super.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
fetchOptions
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
mapLine
|
|
90
|
-
);
|
|
79
|
+
return await super.fetchStreamRaw({
|
|
80
|
+
...options,
|
|
81
|
+
fetchOptions: {
|
|
82
|
+
...options.fetchOptions,
|
|
83
|
+
/**
|
|
84
|
+
* The `react-native-fetch-api` polyfill provides streaming support via
|
|
85
|
+
* this non-standard flag
|
|
86
|
+
* https://github.com/react-native-community/fetch#enable-text-streaming
|
|
87
|
+
*/
|
|
88
|
+
// @ts-expect-error https://github.com/react-native-community/fetch#enable-text-streaming
|
|
89
|
+
reactNative: { textStreaming: true }
|
|
90
|
+
}
|
|
91
|
+
});
|
|
91
92
|
} finally {
|
|
92
93
|
if (timeout) {
|
|
93
94
|
clearTimeout(timeout);
|