@osimatic/helpers-js 1.0.56 → 1.0.59
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/.idea/helpers-js.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/network.js +43 -3
- package/package.json +1 -1
- package/web_rtc.js +4 -12
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/helpers-js.iml" filepath="$PROJECT_DIR$/.idea/helpers-js.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/network.js
CHANGED
|
@@ -53,6 +53,48 @@ class HTTPRequest {
|
|
|
53
53
|
this.headers['Authorization'] = 'Bearer ' + accessToken;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
static convertObjectToFormData(obj) {
|
|
57
|
+
// 30/05/2022 : ancienne version, qui ne fonctionne pas avec des tableaux
|
|
58
|
+
// let formData = new FormData();
|
|
59
|
+
// Object.entries(data).forEach(([key, value]) => formData.append(key, value));
|
|
60
|
+
// return formData;
|
|
61
|
+
|
|
62
|
+
var formData = new FormData();
|
|
63
|
+
|
|
64
|
+
function appendFormData(data, root) {
|
|
65
|
+
//console.log('appendFormData', data, root);
|
|
66
|
+
root = root || '';
|
|
67
|
+
if (data instanceof File) {
|
|
68
|
+
formData.append(root, data);
|
|
69
|
+
}
|
|
70
|
+
else if (Array.isArray(data)) {
|
|
71
|
+
for (var i = 0; i < data.length; i++) {
|
|
72
|
+
appendFormData(data[i], root + '[' + i + ']');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (typeof data === 'object' && data) {
|
|
76
|
+
for (var key in data) {
|
|
77
|
+
if (data.hasOwnProperty(key)) {
|
|
78
|
+
if (root === '') {
|
|
79
|
+
appendFormData(data[key], key);
|
|
80
|
+
} else {
|
|
81
|
+
appendFormData(data[key], root + '.' + key);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (data !== null && typeof data !== 'undefined') {
|
|
88
|
+
formData.append(root, data);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
appendFormData(obj);
|
|
94
|
+
|
|
95
|
+
return formData;
|
|
96
|
+
}
|
|
97
|
+
|
|
56
98
|
static formatQueryString(data) {
|
|
57
99
|
if (data == null) {
|
|
58
100
|
return '';
|
|
@@ -68,9 +110,7 @@ class HTTPRequest {
|
|
|
68
110
|
|
|
69
111
|
static formatFormData(data) {
|
|
70
112
|
if (!(data instanceof FormData)) {
|
|
71
|
-
|
|
72
|
-
Object.entries(data).forEach(([key, value]) => formData.append(key, value));
|
|
73
|
-
return formData;
|
|
113
|
+
return HTTPRequest.convertObjectToFormData(data);
|
|
74
114
|
}
|
|
75
115
|
return data;
|
|
76
116
|
}
|
package/package.json
CHANGED
package/web_rtc.js
CHANGED
|
@@ -8,7 +8,7 @@ class WebRTC {
|
|
|
8
8
|
this.turnSecret = turnSecret;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
static offer(stream, iceCandidateCallback
|
|
11
|
+
static offer(stream, iceCandidateCallback) {
|
|
12
12
|
return new Promise(async (resolve, reject) => {
|
|
13
13
|
try {
|
|
14
14
|
let { username, password } = this.getTurnCredentials();
|
|
@@ -16,7 +16,7 @@ class WebRTC {
|
|
|
16
16
|
{
|
|
17
17
|
iceServers: [
|
|
18
18
|
{
|
|
19
|
-
urls: [
|
|
19
|
+
urls: [this.turnUrl + '?transport=udp', this.turnUrl + '?transport=tcp'],
|
|
20
20
|
username: username,
|
|
21
21
|
credential: password
|
|
22
22
|
},
|
|
@@ -25,16 +25,12 @@ class WebRTC {
|
|
|
25
25
|
}
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
peerConn.oniceconnectionstatechange = (event) => connectionStateChangeCallback(event);
|
|
29
|
-
|
|
30
28
|
peerConn.onicecandidate = ((event) => {
|
|
31
29
|
if (event.candidate) {
|
|
32
30
|
iceCandidateCallback(event.candidate);
|
|
33
31
|
}
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
peerConn.onicecandidateerror = (event) => iceFailureCallback(event);
|
|
37
|
-
|
|
38
34
|
stream.getTracks().forEach(track => peerConn.addTrack(track, stream));
|
|
39
35
|
|
|
40
36
|
const offer = await peerConn.createOffer();
|
|
@@ -47,7 +43,7 @@ class WebRTC {
|
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
static answer(remoteDescription, onTrackCallback, iceCandidateCallback
|
|
46
|
+
static answer(remoteDescription, onTrackCallback, iceCandidateCallback) {
|
|
51
47
|
return new Promise(async (resolve, reject) => {
|
|
52
48
|
try {
|
|
53
49
|
let { username, password } = this.getTurnCredentials();
|
|
@@ -55,7 +51,7 @@ class WebRTC {
|
|
|
55
51
|
{
|
|
56
52
|
iceServers: [
|
|
57
53
|
{
|
|
58
|
-
urls: [
|
|
54
|
+
urls: [this.turnUrl + '?transport=udp', this.turnUrl + '?transport=tcp'],
|
|
59
55
|
username: username,
|
|
60
56
|
credential: password
|
|
61
57
|
},
|
|
@@ -64,16 +60,12 @@ class WebRTC {
|
|
|
64
60
|
}
|
|
65
61
|
);
|
|
66
62
|
|
|
67
|
-
peerConn.oniceconnectionstatechange = (event) => connectionStateChangeCallback(event);
|
|
68
|
-
|
|
69
63
|
peerConn.onicecandidate = ((event) => {
|
|
70
64
|
if (event.candidate) {
|
|
71
65
|
iceCandidateCallback(event.candidate);
|
|
72
66
|
}
|
|
73
67
|
});
|
|
74
68
|
|
|
75
|
-
peerConn.onicecandidateerror = (event) => iceFailureCallback(event);
|
|
76
|
-
|
|
77
69
|
peerConn.ontrack = (event) => onTrackCallback(event.streams);
|
|
78
70
|
|
|
79
71
|
peerConn.setRemoteDescription(new RTCSessionDescription(remoteDescription))
|