Skip to content

Add React Native support to the Typescript SDK #2955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdks/typescript/packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"undici": "^6.19.2"
},
"dependencies": {
"@zxing/text-encoding": "^0.9.0",
"base64-js": "^1.5.1"
}
}
2 changes: 2 additions & 0 deletions sdks/typescript/packages/sdk/src/binary_reader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TextDecoder } from '@zxing/text-encoding';

export default class BinaryReader {
#buffer: DataView;
#offset: number = 0;
Expand Down
1 change: 1 addition & 0 deletions sdks/typescript/packages/sdk/src/binary_writer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fromByteArray } from 'base64-js';
import { TextEncoder } from '@zxing/text-encoding';

export default class BinaryWriter {
#buffer: Uint8Array;
Expand Down
5 changes: 4 additions & 1 deletion sdks/typescript/packages/sdk/src/db_connection_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ export class DbConnectionImpl<
}: DbConnectionConfig) {
stdbLogger('info', 'Connecting to SpacetimeDB WS...');

let url = new URL(uri);
// We use .toString() here because some versions of React Native contain a bug where the URL constructor
// incorrectly treats a URL instance as a plain string.
// This results in an attempt to call .endsWith() on it, leading to an error.
let url = new URL(uri.toString());
if (!/^wss?:/.test(uri.protocol)) {
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
}
Expand Down
8 changes: 8 additions & 0 deletions sdks/typescript/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading