Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/tough-cities-make.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/react-native': patch
---

Polyfill for DOMException to handle usage in livekit-client
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'well-known-symbols/Symbol.asyncIterator/auto';
import 'well-known-symbols/Symbol.iterator/auto';
import './polyfills/MediaRecorderShim';
import './polyfills/DOMException';
import { registerGlobals as webrtcRegisterGlobals } from '@livekit/react-native-webrtc';
import { setupURLPolyfill } from 'react-native-url-polyfill';
import './polyfills/EncoderDecoderTogether.min.js';
Expand Down
21 changes: 21 additions & 0 deletions src/polyfills/DOMException.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* DOMException is missing in some React Native / JS runtimes but is required by
* web APIs (e.g. AbortController, fetch) that may be used in livekit-client.
*/

// @ts-expect-error: global may not declare DOMException in RN types.
if (typeof global.DOMException === 'undefined') {
class PolyfillDOMException extends Error {
readonly code: number;

constructor(message = '', name?: string) {
super(message);
this.message = message;
this.name = name ?? 'Error';
this.code = 0;
Object.setPrototypeOf(this, PolyfillDOMException.prototype);
}
};
// @ts-expect-error
global.DOMException = PolyfillDOMException;
}
Loading