Skip to content

Commit 748ac30

Browse files
committed
fix: fixes
1 parent a5a16cb commit 748ac30

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
minSdkVersion = 24
55
compileSdkVersion = 34
66
targetSdkVersion = 34
7-
ndkVersion = "26.1.10909125"
7+
ndkVersion = "28.1.13356709"
88
kotlinVersion = "1.9.22"
99
}
1010
repositories {

src/index.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,25 @@ function shimIterator() {
105105
}
106106

107107
function shimCryptoUuid() {
108+
let crypto = global.crypto;
108109
if (typeof global.crypto?.randomUUID !== 'function') {
109-
global.crypto.randomUUID = () =>
110-
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
111-
/* eslint-disable no-bitwise */
112-
const r = (Math.random() * 16) | 0;
113-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
114-
return v.toString(16);
115-
}) as `${string}-${string}-${string}-${string}-${string}`;
110+
let createRandomUUID = () => {
111+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
112+
/[xy]/g,
113+
function (c) {
114+
/* eslint-disable no-bitwise */
115+
const r = (Math.random() * 16) | 0;
116+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
117+
return v.toString(16);
118+
}
119+
) as `${string}-${string}-${string}-${string}-${string}`;
120+
};
121+
122+
if (!crypto) {
123+
crypto = {} as typeof global.crypto;
124+
global.crypto = crypto;
125+
}
126+
crypto.randomUUID = createRandomUUID;
116127
}
117128
}
118129

@@ -126,7 +137,7 @@ function shimWebstreams() {
126137
// @ts-expect-error: global.ReadableStream isn't typed here.
127138
if (typeof global.ReadableStream === 'undefined') {
128139
// @ts-expect-error
129-
global.WritableStream = ReadableStream;
140+
global.ReadableStream = ReadableStream;
130141
}
131142
}
132143

0 commit comments

Comments
 (0)