@amityco/ts-sdk-react-native 6.27.1-be8d01c.0 → 6.27.1-f6a08a6.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.
- package/dist/fileRepository/api/uploadFile.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
- package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -1
- package/dist/fileRepository/utils/rebuildFormDataWithMimeType.d.ts +2 -0
- package/dist/fileRepository/utils/rebuildFormDataWithMimeType.d.ts.map +1 -0
- package/dist/index.cjs.js +23 -9
- package/dist/index.esm.js +22 -9
- package/dist/index.umd.js +3 -3
- package/dist/storyRepository/utils/createOptimisticEvent.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/fileRepository/api/uploadFile.ts +10 -5
- package/src/fileRepository/api/uploadImage.ts +2 -1
- package/src/fileRepository/api/uploadVideo.ts +2 -1
- package/src/fileRepository/utils/rebuildFormDataWithMimeType.ts +16 -0
- package/src/storyRepository/utils/createOptimisticEvent.ts +14 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadFile.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,6CACX,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAoCpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadImage.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadImage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadImage.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadImage.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAoC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadVideo.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadVideo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadVideo.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadVideo.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,aACP,MAAM,eAAe,0BACT,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAwC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebuildFormDataWithMimeType.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/utils/rebuildFormDataWithMimeType.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,QAahE,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -11,6 +11,7 @@ var io = require('socket.io-client');
|
|
|
11
11
|
var AsyncStorage = require('@react-native-async-storage/async-storage');
|
|
12
12
|
var uuid$1 = require('react-native-uuid');
|
|
13
13
|
var reactNative = require('react-native');
|
|
14
|
+
var mime = require('mime');
|
|
14
15
|
var hash = require('object-hash');
|
|
15
16
|
var Hls = require('hls.js');
|
|
16
17
|
|
|
@@ -41,6 +42,7 @@ var HttpAgent__default = /*#__PURE__*/_interopDefaultLegacy(HttpAgent);
|
|
|
41
42
|
var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
|
|
42
43
|
var AsyncStorage__default = /*#__PURE__*/_interopDefaultLegacy(AsyncStorage);
|
|
43
44
|
var uuid__default = /*#__PURE__*/_interopDefaultLegacy(uuid$1);
|
|
45
|
+
var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
|
|
44
46
|
var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
|
|
45
47
|
var Hls__default = /*#__PURE__*/_interopDefaultLegacy(Hls);
|
|
46
48
|
|
|
@@ -11955,6 +11957,19 @@ getFile.locally = (fileId) => {
|
|
|
11955
11957
|
};
|
|
11956
11958
|
};
|
|
11957
11959
|
|
|
11960
|
+
const rebuildFormDataWithMimeType = (formData) => {
|
|
11961
|
+
const files = formData.getAll('files') || [];
|
|
11962
|
+
if (!files.length)
|
|
11963
|
+
return formData;
|
|
11964
|
+
const newFormData = new FormData();
|
|
11965
|
+
const imageFile = files[0];
|
|
11966
|
+
// In ReactNative Android, we need to define a file type for all upload items; otherwise backend will reject a request
|
|
11967
|
+
// @ts-ignore - we need to modify `type` because in android this value will not set by default (https://github.com/axios/axios/issues/4823)
|
|
11968
|
+
imageFile.type = mime__default["default"].getType(imageFile.uri);
|
|
11969
|
+
newFormData.append('files', imageFile);
|
|
11970
|
+
return newFormData;
|
|
11971
|
+
};
|
|
11972
|
+
|
|
11958
11973
|
/* begin_public_function
|
|
11959
11974
|
id: file.upload.file
|
|
11960
11975
|
*/
|
|
@@ -11983,7 +11998,7 @@ const uploadFile = async (formData, onProgress) => {
|
|
|
11983
11998
|
const headers = 'getHeaders' in formData
|
|
11984
11999
|
? formData.getHeaders()
|
|
11985
12000
|
: { 'content-type': 'multipart/form-data' };
|
|
11986
|
-
const { data } = await client.http.post('/api/v4/files', formData, {
|
|
12001
|
+
const { data } = await client.http.post('/api/v4/files', rebuildFormDataWithMimeType(formData), {
|
|
11987
12002
|
headers,
|
|
11988
12003
|
onUploadProgress({ loaded, total = 100 }) {
|
|
11989
12004
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -12071,7 +12086,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
12071
12086
|
const headers = 'getHeaders' in formData
|
|
12072
12087
|
? formData.getHeaders()
|
|
12073
12088
|
: { 'content-type': 'multipart/form-data' };
|
|
12074
|
-
const { data } = await client.http.post('/api/v4/videos', formData, {
|
|
12089
|
+
const { data } = await client.http.post('/api/v4/videos', rebuildFormDataWithMimeType(formData), {
|
|
12075
12090
|
headers,
|
|
12076
12091
|
onUploadProgress({ loaded, total = 100 }) {
|
|
12077
12092
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -12117,7 +12132,7 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
12117
12132
|
const headers = 'getHeaders' in formData
|
|
12118
12133
|
? formData.getHeaders()
|
|
12119
12134
|
: { 'content-type': 'multipart/form-data' };
|
|
12120
|
-
const { data } = await client.http.post('/api/v4/images', formData, {
|
|
12135
|
+
const { data } = await client.http.post('/api/v4/images', rebuildFormDataWithMimeType(formData), {
|
|
12121
12136
|
headers,
|
|
12122
12137
|
onUploadProgress({ loaded, total = 100 }) {
|
|
12123
12138
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -23588,12 +23603,11 @@ const createOptimisticEvent = ({ payload, formData = undefined, isVideo = false,
|
|
|
23588
23603
|
const fileObject = files[0] || undefined;
|
|
23589
23604
|
if (!fileObject)
|
|
23590
23605
|
return;
|
|
23591
|
-
const
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
};
|
|
23606
|
+
const optimisticData = Object.assign(Object.assign({}, payload), { data: Object.assign(Object.assign({}, payload.data), { fileId: undefined, fileData: fileObject.uri }) });
|
|
23607
|
+
if (isVideo) {
|
|
23608
|
+
optimisticData.data.videoFileId = { original: undefined };
|
|
23609
|
+
}
|
|
23610
|
+
return callback(saveOptimisticToCache(optimisticData));
|
|
23597
23611
|
}
|
|
23598
23612
|
return callback(saveOptimisticToCache(Object.assign(Object.assign({}, payload), { data: Object.assign(Object.assign({}, payload.data), { fileData: null }) })));
|
|
23599
23613
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -7,6 +7,7 @@ import io from 'socket.io-client';
|
|
|
7
7
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
8
8
|
import uuid$1 from 'react-native-uuid';
|
|
9
9
|
import { Platform } from 'react-native';
|
|
10
|
+
import mime from 'mime';
|
|
10
11
|
import hash from 'object-hash';
|
|
11
12
|
import Hls from 'hls.js';
|
|
12
13
|
|
|
@@ -28026,6 +28027,19 @@ getFile.locally = (fileId) => {
|
|
|
28026
28027
|
};
|
|
28027
28028
|
};
|
|
28028
28029
|
|
|
28030
|
+
const rebuildFormDataWithMimeType = (formData) => {
|
|
28031
|
+
const files = formData.getAll('files') || [];
|
|
28032
|
+
if (!files.length)
|
|
28033
|
+
return formData;
|
|
28034
|
+
const newFormData = new FormData();
|
|
28035
|
+
const imageFile = files[0];
|
|
28036
|
+
// In ReactNative Android, we need to define a file type for all upload items; otherwise backend will reject a request
|
|
28037
|
+
// @ts-ignore - we need to modify `type` because in android this value will not set by default (https://github.com/axios/axios/issues/4823)
|
|
28038
|
+
imageFile.type = mime.getType(imageFile.uri);
|
|
28039
|
+
newFormData.append('files', imageFile);
|
|
28040
|
+
return newFormData;
|
|
28041
|
+
};
|
|
28042
|
+
|
|
28029
28043
|
/* begin_public_function
|
|
28030
28044
|
id: file.upload.file
|
|
28031
28045
|
*/
|
|
@@ -28054,7 +28068,7 @@ const uploadFile = async (formData, onProgress) => {
|
|
|
28054
28068
|
const headers = 'getHeaders' in formData
|
|
28055
28069
|
? formData.getHeaders()
|
|
28056
28070
|
: { 'content-type': 'multipart/form-data' };
|
|
28057
|
-
const { data } = await client.http.post('/api/v4/files', formData, {
|
|
28071
|
+
const { data } = await client.http.post('/api/v4/files', rebuildFormDataWithMimeType(formData), {
|
|
28058
28072
|
headers,
|
|
28059
28073
|
onUploadProgress({ loaded, total = 100 }) {
|
|
28060
28074
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -28142,7 +28156,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
28142
28156
|
const headers = 'getHeaders' in formData
|
|
28143
28157
|
? formData.getHeaders()
|
|
28144
28158
|
: { 'content-type': 'multipart/form-data' };
|
|
28145
|
-
const { data } = await client.http.post('/api/v4/videos', formData, {
|
|
28159
|
+
const { data } = await client.http.post('/api/v4/videos', rebuildFormDataWithMimeType(formData), {
|
|
28146
28160
|
headers,
|
|
28147
28161
|
onUploadProgress({ loaded, total = 100 }) {
|
|
28148
28162
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -28188,7 +28202,7 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
28188
28202
|
const headers = 'getHeaders' in formData
|
|
28189
28203
|
? formData.getHeaders()
|
|
28190
28204
|
: { 'content-type': 'multipart/form-data' };
|
|
28191
|
-
const { data } = await client.http.post('/api/v4/images', formData, {
|
|
28205
|
+
const { data } = await client.http.post('/api/v4/images', rebuildFormDataWithMimeType(formData), {
|
|
28192
28206
|
headers,
|
|
28193
28207
|
onUploadProgress({ loaded, total = 100 }) {
|
|
28194
28208
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -39659,12 +39673,11 @@ const createOptimisticEvent = ({ payload, formData = undefined, isVideo = false,
|
|
|
39659
39673
|
const fileObject = files[0] || undefined;
|
|
39660
39674
|
if (!fileObject)
|
|
39661
39675
|
return;
|
|
39662
|
-
const
|
|
39663
|
-
|
|
39664
|
-
|
|
39665
|
-
|
|
39666
|
-
|
|
39667
|
-
};
|
|
39676
|
+
const optimisticData = Object.assign(Object.assign({}, payload), { data: Object.assign(Object.assign({}, payload.data), { fileId: undefined, fileData: fileObject.uri }) });
|
|
39677
|
+
if (isVideo) {
|
|
39678
|
+
optimisticData.data.videoFileId = { original: undefined };
|
|
39679
|
+
}
|
|
39680
|
+
return callback(saveOptimisticToCache(optimisticData));
|
|
39668
39681
|
}
|
|
39669
39682
|
return callback(saveOptimisticToCache(Object.assign(Object.assign({}, payload), { data: Object.assign(Object.assign({}, payload.data), { fileData: null }) })));
|
|
39670
39683
|
};
|