Skip to content

Commit 022cf11

Browse files
committed
fix: uuid issue by making js base uuid
1 parent 1aefa00 commit 022cf11

File tree

7 files changed

+25
-30
lines changed

7 files changed

+25
-30
lines changed

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ PODS:
293293
- glog
294294
- react-native-background-upload (6.5.0):
295295
- React
296-
- react-native-compressor (1.1.0):
296+
- react-native-compressor (1.2.0):
297297
- NextLevelSessionExporter
298298
- React-Core
299299
- react-native-create-thumbnail (1.4.1):
@@ -627,7 +627,7 @@ SPEC CHECKSUMS:
627627
React-jsinspector: 8c0517dee5e8c70cd6c3066f20213ff7ce54f176
628628
React-logger: bfddd3418dc1d45b77b822958f3e31422e2c179b
629629
react-native-background-upload: 994d4e8abbcc1d0b0cff68d950429906ed68ca67
630-
react-native-compressor: 2b0f75c5e887830955b32e0ddf22ef2efe0f179e
630+
react-native-compressor: 5b01bc19d1817c5ce89f8d5117b7c282e67615b9
631631
react-native-create-thumbnail: d31c84dd69fb4d60aec0ff2f49bc0de41ede7b2c
632632
react-native-document-picker: 226068006be4c52f8ef7f32d855ee025a12e9e64
633633
react-native-get-random-values: 2c4ff6b44cb71291dabe9a8ae87d3877dcf387da

example/src/Screens/Video/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import * as React from 'react';
22
import { View, Text, Button, Image, Alert, Platform } from 'react-native';
3-
import { Video } from 'react-native-compressor';
3+
import { Video, uuidv4 } from 'react-native-compressor';
44
import * as ImagePicker from 'react-native-image-picker';
55
import { createThumbnail } from 'react-native-create-thumbnail';
66
import * as Progress from 'react-native-progress';
77
const prettyBytes = require('pretty-bytes');
8-
import { v4 as uuidv4 } from 'uuid';
98
const RNFS = require('react-native-fs');
109
import { getFileInfo } from '../../Utils';
1110

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"@types/jest": "^26.0.0",
6767
"@types/react": "^17.0.8",
6868
"@types/react-native": "^0.64.7",
69-
"@types/uuid": "^8.0.0",
7069
"commitlint": "^11.0.0",
7170
"eslint": "^7.2.0",
7271
"eslint-config-prettier": "^7.0.0",
@@ -83,8 +82,7 @@
8382
},
8483
"peerDependencies": {
8584
"react": "*",
86-
"react-native": "*",
87-
"uuid": "*"
85+
"react-native": "*"
8886
},
8987
"jest": {
9088
"preset": "react-native",
@@ -164,8 +162,5 @@
164162
}
165163
]
166164
]
167-
},
168-
"dependencies": {
169-
"react-native-get-random-values": "^1.7.0"
170165
}
171166
}

src/Video/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {
44
Platform,
55
NativeEventSubscription,
66
} from 'react-native';
7-
import 'react-native-get-random-values';
8-
import { v4 as uuidv4 } from 'uuid';
7+
import { uuidv4 } from '../utils';
98

109
export declare enum FileSystemUploadType {
1110
BINARY_CONTENT = 0,

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Video, { VideoCompressorType, backgroundUpload } from './Video';
22
import Audio from './Audio';
33
import Image from './Image';
4-
import { getDetails } from './utils';
4+
import { getDetails, uuidv4 } from './utils';
55

66
export {
77
Video,
@@ -11,11 +11,13 @@ export {
1111
//type
1212
VideoCompressorType,
1313
getDetails,
14+
uuidv4,
1415
};
1516
export default {
1617
Video,
1718
Audio,
1819
Image,
1920
backgroundUpload,
2021
getDetails,
22+
uuidv4,
2123
};

src/utils/index.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-bitwise */
12
import { NativeModules } from 'react-native';
23
const { Compressor } = NativeModules;
34
export const AUDIO_BITRATE = [256, 192, 160, 128, 96, 64, 32];
@@ -152,3 +153,19 @@ export const checkUrlAndOptions = async (
152153
return defaultResult;
153154
}
154155
};
156+
157+
export const uuidv4 = () => {
158+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
159+
const r =
160+
(parseFloat(
161+
'0.' +
162+
Math.random().toString().replace('0.', '') +
163+
new Date().getTime()
164+
) *
165+
16) |
166+
0,
167+
// eslint-disable-next-line eqeqeq
168+
v = c == 'x' ? r : (r & 0x3) | 0x8;
169+
return v.toString(16);
170+
});
171+
};

yarn.lock

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,11 +2371,6 @@
23712371
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
23722372
integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==
23732373

2374-
"@types/uuid@^8.0.0":
2375-
version "8.3.0"
2376-
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f"
2377-
integrity sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==
2378-
23792374
"@types/yargs-parser@*":
23802375
version "20.2.0"
23812376
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.0.tgz#dd3e6699ba3237f0348cd085e4698780204842f9"
@@ -4504,11 +4499,6 @@ extglob@^2.0.4:
45044499
snapdragon "^0.8.1"
45054500
to-regex "^3.0.1"
45064501

4507-
fast-base64-decode@^1.0.0:
4508-
version "1.0.0"
4509-
resolved "https://registry.yarnpkg.com/fast-base64-decode/-/fast-base64-decode-1.0.0.tgz#b434a0dd7d92b12b43f26819300d2dafb83ee418"
4510-
integrity sha512-qwaScUgUGBYeDNRnbc/KyllVU88Jk1pRHPStuF/lO7B0/RTRLj7U0lkdTAutlBblY08rwZDff6tNU9cjv6j//Q==
4511-
45124502
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
45134503
version "3.1.3"
45144504
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
@@ -7970,13 +7960,6 @@ react-native-codegen@^0.0.7:
79707960
jscodeshift "^0.11.0"
79717961
nullthrows "^1.1.1"
79727962

7973-
react-native-get-random-values@^1.7.0:
7974-
version "1.7.0"
7975-
resolved "https://registry.yarnpkg.com/react-native-get-random-values/-/react-native-get-random-values-1.7.0.tgz#86d9d1960828b606392dba4540bf760605448530"
7976-
integrity sha512-zDhmpWUekGRFb9I+MQkxllHcqXN9HBSsgPwBQfrZ1KZYpzDspWLZ6/yLMMZrtq4pVqNR7C7N96L3SuLpXv1nhQ==
7977-
dependencies:
7978-
fast-base64-decode "^1.0.0"
7979-
79807963
react-native@^0.66.1:
79817964
version "0.66.1"
79827965
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.66.1.tgz#96defaf60579406321340ebe1dcea76a3c942806"

0 commit comments

Comments
 (0)